tx · BVW23vCXtEKVhQiNT7mAVE5iEMqFdvu5uguUFuenT7Bx 3N7nJwbFGppbebBtXy6bWVcQCGu7m3kXFaw: -0.01000000 Waves 2022.06.05 09:49 [2082721] smart account 3N7nJwbFGppbebBtXy6bWVcQCGu7m3kXFaw > SELF 0.00000000 Waves
{ "type": 13, "id": "BVW23vCXtEKVhQiNT7mAVE5iEMqFdvu5uguUFuenT7Bx", "fee": 1000000, "feeAssetId": null, "timestamp": 1654411812643, "version": 2, "chainId": 84, "sender": "3N7nJwbFGppbebBtXy6bWVcQCGu7m3kXFaw", "senderPublicKey": "GTKqLSK6nuFkRdebB5SmTwTU2DnTeLMvhymCFfT2CxX2", "proofs": [ "3kYa7MnbqcCUfmF5GT5UY8xkA9GoR3MTwJhYGriaAs8U8spmonfD7rAgRP476ScTUFpoK5UEBRDKMb9qn8VSH7Fs" ], "script": "base64:AAIFAAAAAAAAAAgIAhIAEgASAAAAAAIAAAAABEJVc2QBAAAAIAu+yPsU61UT6w/UBobJ3Bln9DA/EA0rHMeXciw6ixXjAAAAAAhkQXBwRmVlcwEAAAAaAVSnJAa+rdQxXJacpl/yZdtSATGRaLbaMxIAAAADAAAAAWkBAAAABVJlc2V0AAAAAAkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgkAASwAAAACCQACWAAAAAEICAUAAAABaQAAAAZjYWxsZXIAAAAFYnl0ZXMCAAAABF9MaXEAAAAAAAAAAAAJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIJAAEsAAAAAgkAAlgAAAABCAgFAAAAAWkAAAAGY2FsbGVyAAAABWJ5dGVzAgAAAAxfTGFzdFVuc3Rha2UAAAAAAAAAAAAJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIJAAEsAAAAAgkAAlgAAAABCAgFAAAAAWkAAAAGY2FsbGVyAAAABWJ5dGVzAgAAAAtfdHJ4VW5zdGFrZQAAAAAAAAAAAAUAAAADbmlsAAAAAWkBAAAADERlcG9zaX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VzCQAAaAAAAAIFAAAAB0ZlZVBhaWQAAAAAAAX14QAFAAAABEJVc2QFAAAAA25pbAUAAAAEQlVzZAAAAADlVTVi", "height": 2082721, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9DEqBQNy6gF24dGzCp6vACoGxFcSS5fvbWYV5xSTb9S Next: 9GXmGKeAVHoaPLvQ3aggYUJ8XyKWgcBE8TabPsRTvvza Diff:
Old | New | Differences | |
---|---|---|---|
31 | 31 | then throw("Can only deposit BUsd tokens, and amount should be at least 50 BUsd") | |
32 | 32 | else { | |
33 | 33 | let NewBalance = (UserBalance + pmt.amount) | |
34 | - | [IntegerEntry((toBase58String(i.caller.bytes) + "_Liq"), NewBalance), IntegerEntry((toBase58String(i.caller.bytes) + "_LastUnstake"), height)] | |
34 | + | [IntegerEntry((toBase58String(i.caller.bytes) + "_Liq"), NewBalance), IntegerEntry((toBase58String(i.caller.bytes) + "_Deposit"), NewBalance), IntegerEntry((toBase58String(i.caller.bytes) + "_LastUnstake"), height)] | |
35 | 35 | } | |
36 | 36 | } | |
37 | 37 | ||
42 | 42 | let UserLiquidity = (toBase58String(i.caller.bytes) + "_Liq") | |
43 | 43 | let LastUnstakeBlock = (toBase58String(i.caller.bytes) + "_LastUnstake") | |
44 | 44 | let trxUnstakeNum = (toBase58String(i.caller.bytes) + "_trxUnstake") | |
45 | + | let User1stDeposit = (toBase58String(i.caller.bytes) + "_Deposit") | |
45 | 46 | let dAppFrees = Address(dAppFees) | |
46 | 47 | let FeePaid = 1 | |
48 | + | let User1stDepositValue = match getInteger(this, User1stDeposit) { | |
49 | + | case a: Int => | |
50 | + | a | |
51 | + | case _ => | |
52 | + | 0 | |
53 | + | } | |
47 | 54 | let amount = match getInteger(this, UserLiquidity) { | |
48 | 55 | case a: Int => | |
49 | 56 | a | |
74 | 81 | let PaidtrxValue = if ((trxUnstakeValue == 3)) | |
75 | 82 | then 0 | |
76 | 83 | else (trxUnstakeValue + 1) | |
84 | + | let WithdrawAmount = ((User1stDepositValue / 4) - (FeePaid * 100000000)) | |
77 | 85 | let UserAccount = if ((trxUnstakeValue == 3)) | |
78 | 86 | then 0 | |
79 | - | else ((amount - (FeePaid * 100000000)) - (((PaidtrxValue * 25) * (amount - (FeePaid * 100000000))) / 100)) | |
80 | - | let WithdrawAmount = ((25 * amount) / 100) | |
87 | + | else (User1stDepositValue - (PaidtrxValue * WithdrawAmount)) | |
81 | 88 | $Tuple2([IntegerEntry((toBase58String(i.caller.bytes) + "_trxUnstake"), PaidtrxValue), IntegerEntry((toBase58String(i.caller.bytes) + "_Liq"), UserAccount), IntegerEntry((toBase58String(i.caller.bytes) + "_LastUnstake"), height), ScriptTransfer(i.caller, WithdrawAmount, BUsd), ScriptTransfer(dAppFrees, (FeePaid * 100000000), BUsd)], BUsd) | |
82 | 89 | } | |
83 | 90 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let BUsd = base58'nrDXX1zHfGht7xExqNxDu7voCy9wzmc9vJxwcc2jLga' | |
5 | 5 | ||
6 | 6 | let dAppFees = base58'3N59qn7Ndw24WrGFkNFk7PGTBCzdMETyKqj' | |
7 | 7 | ||
8 | 8 | @Callable(i) | |
9 | 9 | func Reset () = [IntegerEntry((toBase58String(i.caller.bytes) + "_Liq"), 0), IntegerEntry((toBase58String(i.caller.bytes) + "_LastUnstake"), 0), IntegerEntry((toBase58String(i.caller.bytes) + "_trxUnstake"), 0)] | |
10 | 10 | ||
11 | 11 | ||
12 | 12 | ||
13 | 13 | @Callable(i) | |
14 | 14 | func DepositFunds () = { | |
15 | 15 | let UserLiquidity = (toBase58String(i.caller.bytes) + "_Liq") | |
16 | 16 | let LastUnstakeBlock = (toBase58String(i.caller.bytes) + "_LastUnstake") | |
17 | 17 | let UserBalance = match getInteger(this, UserLiquidity) { | |
18 | 18 | case a: Int => | |
19 | 19 | a | |
20 | 20 | case _ => | |
21 | 21 | 0 | |
22 | 22 | } | |
23 | 23 | let pmt = if ((size(i.payments) == 1)) | |
24 | 24 | then i.payments[0] | |
25 | 25 | else throw("Attached payment is required") | |
26 | 26 | if ((UserBalance != 0)) | |
27 | 27 | then throw("You already have funds supplied, cannot supply more than once") | |
28 | 28 | else if (if (((50 * 100000000) > pmt.amount)) | |
29 | 29 | then true | |
30 | 30 | else (pmt.assetId != BUsd)) | |
31 | 31 | then throw("Can only deposit BUsd tokens, and amount should be at least 50 BUsd") | |
32 | 32 | else { | |
33 | 33 | let NewBalance = (UserBalance + pmt.amount) | |
34 | - | [IntegerEntry((toBase58String(i.caller.bytes) + "_Liq"), NewBalance), IntegerEntry((toBase58String(i.caller.bytes) + "_LastUnstake"), height)] | |
34 | + | [IntegerEntry((toBase58String(i.caller.bytes) + "_Liq"), NewBalance), IntegerEntry((toBase58String(i.caller.bytes) + "_Deposit"), NewBalance), IntegerEntry((toBase58String(i.caller.bytes) + "_LastUnstake"), height)] | |
35 | 35 | } | |
36 | 36 | } | |
37 | 37 | ||
38 | 38 | ||
39 | 39 | ||
40 | 40 | @Callable(i) | |
41 | 41 | func WithdrawLiq () = { | |
42 | 42 | let UserLiquidity = (toBase58String(i.caller.bytes) + "_Liq") | |
43 | 43 | let LastUnstakeBlock = (toBase58String(i.caller.bytes) + "_LastUnstake") | |
44 | 44 | let trxUnstakeNum = (toBase58String(i.caller.bytes) + "_trxUnstake") | |
45 | + | let User1stDeposit = (toBase58String(i.caller.bytes) + "_Deposit") | |
45 | 46 | let dAppFrees = Address(dAppFees) | |
46 | 47 | let FeePaid = 1 | |
48 | + | let User1stDepositValue = match getInteger(this, User1stDeposit) { | |
49 | + | case a: Int => | |
50 | + | a | |
51 | + | case _ => | |
52 | + | 0 | |
53 | + | } | |
47 | 54 | let amount = match getInteger(this, UserLiquidity) { | |
48 | 55 | case a: Int => | |
49 | 56 | a | |
50 | 57 | case _ => | |
51 | 58 | 0 | |
52 | 59 | } | |
53 | 60 | let trxUnstakeValue = match getInteger(this, trxUnstakeNum) { | |
54 | 61 | case a: Int => | |
55 | 62 | a | |
56 | 63 | case _ => | |
57 | 64 | 0 | |
58 | 65 | } | |
59 | 66 | let LastUnstakeBlockValue = match getInteger(this, LastUnstakeBlock) { | |
60 | 67 | case a: Int => | |
61 | 68 | a | |
62 | 69 | case _ => | |
63 | 70 | 0 | |
64 | 71 | } | |
65 | 72 | if ((amount == 0)) | |
66 | 73 | then throw(("You do not have enough funds to withdraw, your available funds are: " + toString((amount / 100000000)))) | |
67 | 74 | else { | |
68 | 75 | let WaitTime = if ((trxUnstakeValue == 0)) | |
69 | 76 | then 2 | |
70 | 77 | else 10 | |
71 | 78 | if (((LastUnstakeBlockValue + WaitTime) > height)) | |
72 | 79 | then throw((("Second withdraw cannot be done before " + toString(((height - LastUnstakeBlockValue) - WaitTime))) + " min")) | |
73 | 80 | else { | |
74 | 81 | let PaidtrxValue = if ((trxUnstakeValue == 3)) | |
75 | 82 | then 0 | |
76 | 83 | else (trxUnstakeValue + 1) | |
84 | + | let WithdrawAmount = ((User1stDepositValue / 4) - (FeePaid * 100000000)) | |
77 | 85 | let UserAccount = if ((trxUnstakeValue == 3)) | |
78 | 86 | then 0 | |
79 | - | else ((amount - (FeePaid * 100000000)) - (((PaidtrxValue * 25) * (amount - (FeePaid * 100000000))) / 100)) | |
80 | - | let WithdrawAmount = ((25 * amount) / 100) | |
87 | + | else (User1stDepositValue - (PaidtrxValue * WithdrawAmount)) | |
81 | 88 | $Tuple2([IntegerEntry((toBase58String(i.caller.bytes) + "_trxUnstake"), PaidtrxValue), IntegerEntry((toBase58String(i.caller.bytes) + "_Liq"), UserAccount), IntegerEntry((toBase58String(i.caller.bytes) + "_LastUnstake"), height), ScriptTransfer(i.caller, WithdrawAmount, BUsd), ScriptTransfer(dAppFrees, (FeePaid * 100000000), BUsd)], BUsd) | |
82 | 89 | } | |
83 | 90 | } | |
84 | 91 | } | |
85 | 92 | ||
86 | 93 |
github/deemru/w8io/169f3d6 26.76 ms ◑