tx · H12CjEbh8JuxwA8w3U8b78Y3XGuu2VTuKTNZZoV1CHHL 3P54B92RNzMrgqPmKhsqL413NjAGwf4q9ep: -0.01400000 Waves 2022.05.19 13:08 [3123872] smart account 3P54B92RNzMrgqPmKhsqL413NjAGwf4q9ep > SELF 0.00000000 Waves
{ "type": 13, "id": "H12CjEbh8JuxwA8w3U8b78Y3XGuu2VTuKTNZZoV1CHHL", "fee": 1400000, "feeAssetId": null, "timestamp": 1652954375409, "version": 1, "sender": "3P54B92RNzMrgqPmKhsqL413NjAGwf4q9ep", "senderPublicKey": "MuJFxUBAQVpXXraxYbYJEzWYG8NukYhQEQFm7CaZLcT", "proofs": [ "4YNoU5hKzKrM96kChb7zJug7wqKSUETjsfiGRjP7QrUj8yffrT62kY5GhNy7neVVi5mti8TWc47cv35jAu5moc1e" ], "script": "base64:AAIEAAAAAAAAAAwIAhIAEgASBAoCAQEAAAATAAAAAARVU0RUAgAAACwzNE45WWNFRVRMV245M3FZUTY0RXNQMXg4OXRTcnVKVTQ0UnJFTVNYWEVQSgAAAAAEVVNETgIAAAAsREcyeEZrUGREd0tVb0JrekdBaFF0THBTR3pmWExpQ1lQRXplS0gyQWQyNHAAAAAABmlkVVNETgkAAlkAAAABBQAAAARVU0ROAAAAAAZpZFVTRFQJAAJZAAAAAQUAAAAEVVNEVAAAAAANd2l0aGRyYXdEZWxheQAAAAAAAAAFtAAAAAAPZGVjaW1hbFBhcnRVU0ROAAAAAAAAD0JAAAAAAA9kZWNpbWFsUGFydFVTRFQAAAAAAAAPQkAAAAAAF21pbmltYWxBbW91bnRUb1N3YXBVU0RUCQAAaAAAAAIAAAAAAAAAJxAFAAAAD2RlY2ltYWxQYXJ0VVNETgAAAAAXbWluaW1hbEFtb3VudFRvU3dhcFVTRE4JAABoAAAAAgAAAAAAAAAnEAUAAAAPZGVjaW1hbFBhcnRVU0RUAQAAAApjb2xsZWN0S2V5AAAAAwAAAAdhZGRyZXNzAAAAEWFtb3VudFRvU3dhcEluS2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2FwIGFtb3VudCBmYWlsLCBhbW91bnQgaXMgdG8gc21hbGwgb3IgdG8gYmlnLgQAAAAUdG9XaXRoZHJhd1dpdGhvdXRGZWUJAQAAABVnZXRXaXRob3V0RmVlV2l0aGRyYXcAAAACBQAAAAZhbW91bnQFAAAAFGN1cnJlbnRDbGllbnRCYWxhbmNlBAAAABF0b1dpdGhkcmF3V2l0aEZlZQkAAGUAAAACBQAAAAZhbW91bnQFAAAAFHRvV2l0aGRyYXdXaXRob3V0RmVlBAAAAANmZWUJAABoAAAAAgkAAGkAAAACBQAAABF0b1dpdGhkcmF3V2l0aEZlZQAAAAAAAAAAZAAAAAAAAAAAAgkABEwAAAACBQAAABR0b1dpdGhkcmF3V2l0aG91dEZlZQkABEwAAAACBQAAABF0b1dpdGhkcmF3V2l0aEZlZQkABEwAAAACBQAAAANmZWUFAAAAA25pbAAAAAMAAAAGaW52b2tlAQAAAA5zd2FwVVNEVHRvVVNETgAAAAAJAAACAAAAAQIAAAADb2ZmAAAABmludm9rZQEAAAAcaW5pdGlhbGl6YXRpb25VU0ROdG9VU0RUc3dhcAAAAAAJAAACAAAAAQIAAAADb2ZmAAAABmludm9rZQEAAAAOc3dhcFVTRE50b1VTRFQAAAACAAAABmFtb3VudAAAAAtoZWlnaHRJbktleQkAAAIAAAABAgAAAANvZmYAAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAACQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAkAAlkAAAABAgAAACwyQ2JkOG96RzdBMVJ5Uk5DM25OblpnSHU3UnU0SzNKQ2ZweVBraHFyOXp4ceFjUeg=", "chainId": 87, "height": 3123872, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: FHvaox4UhxG43uvp7iaHTCUWgwMivVNeuswdUarWETtB Next: HJa9mJ6Bm4iwN3v1vezY5VGkJfaHF4F9BaT4uaaxToit Diff:
Old | New | Differences | |
---|---|---|---|
70 | 70 | ||
71 | 71 | ||
72 | 72 | @Callable(invoke) | |
73 | - | func swapUSDTtoUSDN () = { | |
74 | - | let balanceKey = collectBalanceKeyWithFee(toString(invoke.caller)) | |
75 | - | let payment = value(invoke.payments[0]) | |
76 | - | if ((payment.assetId != idUSDT)) | |
77 | - | then usdtToUsdnAssetError() | |
78 | - | else { | |
79 | - | let amount = payment.amount | |
80 | - | let fee = ((amount / 100) * 2) | |
81 | - | let currentClientBalanceUSDT = valueOrElse(getInteger(this, balanceKey), 0) | |
82 | - | if ((minimalAmountToSwapUSDT > amount)) | |
83 | - | then usdtToUsdnLowLimitError() | |
84 | - | else [IntegerEntry(balanceKey, (currentClientBalanceUSDT + amount)), ScriptTransfer(invoke.caller, (amount - fee), idUSDN)] | |
85 | - | } | |
86 | - | } | |
73 | + | func swapUSDTtoUSDN () = throw("off") | |
87 | 74 | ||
88 | 75 | ||
89 | 76 | ||
90 | 77 | @Callable(invoke) | |
91 | - | func initializationUSDNtoUSDTswap () = { | |
92 | - | let payment = value(invoke.payments[0]) | |
93 | - | let address = toString(invoke.caller) | |
94 | - | if ((payment.assetId != idUSDN)) | |
95 | - | then usdnToUsdtAssetError() | |
96 | - | else { | |
97 | - | let amount = payment.amount | |
98 | - | let balanceKey = collectBalanceKey(address) | |
99 | - | let balanceWithFeeKey = collectBalanceKeyWithFee(address) | |
100 | - | let currentClientBalance = valueOrElse(getInteger(this, balanceKey), 0) | |
101 | - | let currentClientBalanceWithFee = valueOrElse(getInteger(this, balanceWithFeeKey), 0) | |
102 | - | let userBalance = (currentClientBalance + currentClientBalanceWithFee) | |
103 | - | let data = currentWithdrawals(toString(invoke.caller), amount) | |
104 | - | let toWithdrawWithoutFee = valueOrErrorMessage(data[0], "Wrong 'currentWithdrawals' method!") | |
105 | - | let toWithdrawWithFee = valueOrErrorMessage(data[1], "Wrong 'currentWithdrawals' method!") | |
106 | - | let fee = valueOrErrorMessage(data[2], "Wrong 'currentWithdrawals' method!") | |
107 | - | let total = ((toWithdrawWithFee + toWithdrawWithoutFee) - fee) | |
108 | - | let allowToWithDrawHeight = (height + withdrawDelay) | |
109 | - | if (isDefined(getString(this, collectKey(toString(invoke.caller), amount, allowToWithDrawHeight)))) | |
110 | - | then throw("You have already started withdrawal process, wait next block.") | |
111 | - | else [IntegerEntry(balanceKey, (currentClientBalance - toWithdrawWithoutFee)), IntegerEntry(balanceWithFeeKey, (currentClientBalanceWithFee - toWithdrawWithFee)), StringEntry(collectKey(toString(invoke.caller), amount, allowToWithDrawHeight), makeString(["not_withdrawn", toString((amount - fee))], "_"))] | |
112 | - | } | |
113 | - | } | |
78 | + | func initializationUSDNtoUSDTswap () = throw("off") | |
114 | 79 | ||
115 | 80 | ||
116 | 81 | ||
117 | 82 | @Callable(invoke) | |
118 | - | func swapUSDNtoUSDT (amount,heightInKey) = { | |
119 | - | let key = collectKey(toString(invoke.caller), amount, heightInKey) | |
120 | - | let withdrawnInfo = valueOrErrorMessage(getString(this, key), ((("This key doesn't exists " + key) + " at address ") + toString(this))) | |
121 | - | let toWithdraw = getListElementOrDefault(split(withdrawnInfo, "_"), 2, toString(amount)) | |
122 | - | if (if ((height >= heightInKey)) | |
123 | - | then contains(withdrawnInfo, "not_withdrawn") | |
124 | - | else false) | |
125 | - | then [DeleteEntry(key), ScriptTransfer(invoke.caller, valueOrErrorMessage(parseInt(toWithdraw), "Wrong withdraw data!"), idUSDT)] | |
126 | - | else throw((("Withdrawal is possible after " + toString(heightInKey)) + " height or you have already withdrawn USDT.")) | |
127 | - | } | |
83 | + | func swapUSDNtoUSDT (amount,heightInKey) = throw("off") | |
128 | 84 | ||
85 | + | ||
86 | + | @Verifier(tx) | |
87 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], fromBase58String("2Cbd8ozG7A1RyRNC3nNnZgHu7Ru4K3JCfpyPkhqr9zxq")) | |
129 | 88 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let USDT = "34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ" | |
5 | 5 | ||
6 | 6 | let USDN = "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p" | |
7 | 7 | ||
8 | 8 | let idUSDN = fromBase58String(USDN) | |
9 | 9 | ||
10 | 10 | let idUSDT = fromBase58String(USDT) | |
11 | 11 | ||
12 | 12 | let withdrawDelay = 1460 | |
13 | 13 | ||
14 | 14 | let decimalPartUSDN = 1000000 | |
15 | 15 | ||
16 | 16 | let decimalPartUSDT = 1000000 | |
17 | 17 | ||
18 | 18 | let minimalAmountToSwapUSDT = (10000 * decimalPartUSDN) | |
19 | 19 | ||
20 | 20 | let minimalAmountToSwapUSDN = (10000 * decimalPartUSDT) | |
21 | 21 | ||
22 | 22 | func collectKey (address,amountToSwapInKey,allowToWithdrawHeight) = makeString([address, "WITHDRAW", toString(amountToSwapInKey), "HEIGHT", toString(allowToWithdrawHeight)], "_") | |
23 | 23 | ||
24 | 24 | ||
25 | 25 | func collectBalanceKey (address) = makeString([address, "balance"], "_") | |
26 | 26 | ||
27 | 27 | ||
28 | 28 | func collectBalanceKeyWithFee (address) = makeString([address, "balance_with_fee"], "_") | |
29 | 29 | ||
30 | 30 | ||
31 | 31 | func usdtToUsdnAssetError () = throw("To swap USDT to USDN you need attach payment in USDT") | |
32 | 32 | ||
33 | 33 | ||
34 | 34 | func usdnToUsdtAssetError () = throw("To swap USDN to USDT you need attach payment in USDN") | |
35 | 35 | ||
36 | 36 | ||
37 | 37 | func usdtToUsdnLowLimitError () = throw((("you can swap at least " + toString((minimalAmountToSwapUSDT / decimalPartUSDT))) + " tokens")) | |
38 | 38 | ||
39 | 39 | ||
40 | 40 | func abs (n) = if ((0 > n)) | |
41 | 41 | then (n * -1) | |
42 | 42 | else n | |
43 | 43 | ||
44 | 44 | ||
45 | 45 | func getWithoutFeeWithdraw (amount,balanceWithoutFee) = min([amount, balanceWithoutFee]) | |
46 | 46 | ||
47 | 47 | ||
48 | 48 | func getListElementOrDefault (list,index,default) = if ((size(list) > index)) | |
49 | 49 | then list[index] | |
50 | 50 | else default | |
51 | 51 | ||
52 | 52 | ||
53 | 53 | func currentWithdrawals (address,amount) = { | |
54 | 54 | let balanceKey = collectBalanceKey(address) | |
55 | 55 | let balanceWithFeeKey = collectBalanceKeyWithFee(address) | |
56 | 56 | let currentClientBalance = valueOrElse(getInteger(this, balanceKey), 0) | |
57 | 57 | let currentClientBalanceWithFee = valueOrElse(getInteger(this, balanceWithFeeKey), 0) | |
58 | 58 | let userBalance = (currentClientBalance + currentClientBalanceWithFee) | |
59 | 59 | if (if ((amount > userBalance)) | |
60 | 60 | then true | |
61 | 61 | else (minimalAmountToSwapUSDN > amount)) | |
62 | 62 | then throw("Swap amount fail, amount is to small or to big.") | |
63 | 63 | else { | |
64 | 64 | let toWithdrawWithoutFee = getWithoutFeeWithdraw(amount, currentClientBalance) | |
65 | 65 | let toWithdrawWithFee = (amount - toWithdrawWithoutFee) | |
66 | 66 | let fee = ((toWithdrawWithFee / 100) * 2) | |
67 | 67 | [toWithdrawWithoutFee, toWithdrawWithFee, fee] | |
68 | 68 | } | |
69 | 69 | } | |
70 | 70 | ||
71 | 71 | ||
72 | 72 | @Callable(invoke) | |
73 | - | func swapUSDTtoUSDN () = { | |
74 | - | let balanceKey = collectBalanceKeyWithFee(toString(invoke.caller)) | |
75 | - | let payment = value(invoke.payments[0]) | |
76 | - | if ((payment.assetId != idUSDT)) | |
77 | - | then usdtToUsdnAssetError() | |
78 | - | else { | |
79 | - | let amount = payment.amount | |
80 | - | let fee = ((amount / 100) * 2) | |
81 | - | let currentClientBalanceUSDT = valueOrElse(getInteger(this, balanceKey), 0) | |
82 | - | if ((minimalAmountToSwapUSDT > amount)) | |
83 | - | then usdtToUsdnLowLimitError() | |
84 | - | else [IntegerEntry(balanceKey, (currentClientBalanceUSDT + amount)), ScriptTransfer(invoke.caller, (amount - fee), idUSDN)] | |
85 | - | } | |
86 | - | } | |
73 | + | func swapUSDTtoUSDN () = throw("off") | |
87 | 74 | ||
88 | 75 | ||
89 | 76 | ||
90 | 77 | @Callable(invoke) | |
91 | - | func initializationUSDNtoUSDTswap () = { | |
92 | - | let payment = value(invoke.payments[0]) | |
93 | - | let address = toString(invoke.caller) | |
94 | - | if ((payment.assetId != idUSDN)) | |
95 | - | then usdnToUsdtAssetError() | |
96 | - | else { | |
97 | - | let amount = payment.amount | |
98 | - | let balanceKey = collectBalanceKey(address) | |
99 | - | let balanceWithFeeKey = collectBalanceKeyWithFee(address) | |
100 | - | let currentClientBalance = valueOrElse(getInteger(this, balanceKey), 0) | |
101 | - | let currentClientBalanceWithFee = valueOrElse(getInteger(this, balanceWithFeeKey), 0) | |
102 | - | let userBalance = (currentClientBalance + currentClientBalanceWithFee) | |
103 | - | let data = currentWithdrawals(toString(invoke.caller), amount) | |
104 | - | let toWithdrawWithoutFee = valueOrErrorMessage(data[0], "Wrong 'currentWithdrawals' method!") | |
105 | - | let toWithdrawWithFee = valueOrErrorMessage(data[1], "Wrong 'currentWithdrawals' method!") | |
106 | - | let fee = valueOrErrorMessage(data[2], "Wrong 'currentWithdrawals' method!") | |
107 | - | let total = ((toWithdrawWithFee + toWithdrawWithoutFee) - fee) | |
108 | - | let allowToWithDrawHeight = (height + withdrawDelay) | |
109 | - | if (isDefined(getString(this, collectKey(toString(invoke.caller), amount, allowToWithDrawHeight)))) | |
110 | - | then throw("You have already started withdrawal process, wait next block.") | |
111 | - | else [IntegerEntry(balanceKey, (currentClientBalance - toWithdrawWithoutFee)), IntegerEntry(balanceWithFeeKey, (currentClientBalanceWithFee - toWithdrawWithFee)), StringEntry(collectKey(toString(invoke.caller), amount, allowToWithDrawHeight), makeString(["not_withdrawn", toString((amount - fee))], "_"))] | |
112 | - | } | |
113 | - | } | |
78 | + | func initializationUSDNtoUSDTswap () = throw("off") | |
114 | 79 | ||
115 | 80 | ||
116 | 81 | ||
117 | 82 | @Callable(invoke) | |
118 | - | func swapUSDNtoUSDT (amount,heightInKey) = { | |
119 | - | let key = collectKey(toString(invoke.caller), amount, heightInKey) | |
120 | - | let withdrawnInfo = valueOrErrorMessage(getString(this, key), ((("This key doesn't exists " + key) + " at address ") + toString(this))) | |
121 | - | let toWithdraw = getListElementOrDefault(split(withdrawnInfo, "_"), 2, toString(amount)) | |
122 | - | if (if ((height >= heightInKey)) | |
123 | - | then contains(withdrawnInfo, "not_withdrawn") | |
124 | - | else false) | |
125 | - | then [DeleteEntry(key), ScriptTransfer(invoke.caller, valueOrErrorMessage(parseInt(toWithdraw), "Wrong withdraw data!"), idUSDT)] | |
126 | - | else throw((("Withdrawal is possible after " + toString(heightInKey)) + " height or you have already withdrawn USDT.")) | |
127 | - | } | |
83 | + | func swapUSDNtoUSDT (amount,heightInKey) = throw("off") | |
128 | 84 | ||
85 | + | ||
86 | + | @Verifier(tx) | |
87 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], fromBase58String("2Cbd8ozG7A1RyRNC3nNnZgHu7Ru4K3JCfpyPkhqr9zxq")) | |
129 | 88 |
github/deemru/w8io/3ef1775 53.73 ms ◑