tx · 7H47rRJJgbyqm9JY4GNXc8WvaxqUoMBZZvcgNpVQPyp3 3N1FWHMYZ9QJDkUaMPxexydkBqiUxEk3J6o: -0.01400000 Waves 2020.10.07 13:12 [1210013] smart account 3N1FWHMYZ9QJDkUaMPxexydkBqiUxEk3J6o > SELF 0.00000000 Waves
{ "type": 13, "id": "7H47rRJJgbyqm9JY4GNXc8WvaxqUoMBZZvcgNpVQPyp3", "fee": 1400000, "feeAssetId": null, "timestamp": 1602065603532, "version": 1, "sender": "3N1FWHMYZ9QJDkUaMPxexydkBqiUxEk3J6o", "senderPublicKey": "oH6E3DnZcMibsYC4VB7KvfemJfz3koDVwZ5Z3pXGpCN", "proofs": [ "3omKvzyXX9b56kSWtUqQf1R3DhkNK7Ru87bNzPfErXRokTP547JYj8PecPf9VF2hPuV9dcbMFTu4UmfdyoCf6bMv" ], "script": "base64:AAIDAAAAAAAAAAwIARIAEgASBAoCAQEAAAAKAAAAAARVU0RUAgAAACw1U2g5S2doZmtaeWhqd3VvZG92RGhCNlBnaERVR0JIaUFQWjRNa3JQZ0t0WAAAAAAEVVNETgIAAAAsMjVGRXFFalJrcUs2eUNraVQ3THo2U0FZejdnVUZDdHhmQ0NobnJWRkQ1QVQAAAAABmlkVVNETgkAAlkAAAABBQAAAARVU0ROAAAAAAZpZFVTRFQJAAJZAAAAAQUAAAAEVVNEVAAAAAANd2l0aGRyYXdEZWxheQAAAAAAAAAAAgAAAAAPZGVjaW1hbFBhcnRVU0ROAAAAAAAAD0JAAAAAAA9kZWNpbWFsUGFydFVTRFQAAAAAAAAPQkAAAAAAF21pbmltYWxBbW91bnRUb1N3YXBVU0RUCQAAaAAAAAIAAAAAAAAAJxAFAAAAD2RlY2ltYWxQYXJ0VVNETgAAAAAXbWluaW1hbEFtb3VudFRvU3dhcFVTRE4JAABoAAAAAgAAAAAAAAAnEAUAAAAPZGVjaW1hbFBhcnRVU0RUAQAAAApjb2xsZWN0S2V5AAAAAwAAAAdhZGRyZXNzAAAAEW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AAtoZWlnaHRJbktleQkAAAAAAAACBQAAAA13aXRoZHJhd25JbmZvAgAAAA1ub3Rfd2l0aGRyYXduBwkBAAAADFNjcmlwdFJlc3VsdAAAAAIJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIFAAAAA2tleQIAAAAJd2l0aGRyYXduBQAAAANuaWwJAQAAAAtUcmFuc2ZlclNldAAAAAEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAACmNvbnRleHRPYmoAAAAGY2FsbGVyBQAAABFhbW91bnRUb1N3YXBJbktleQUAAAAGaWRVU0RUBQAAAANuaWwJAAACAAAAAQkAASwAAAACCQABLAAAAAICAAAAHXdpdGhkcmF3YWwgaXMgcG9zc2libGUgYWZ0ZXIgCQABpAAAAAEFAAAAC2hlaWdodEluS2V5AgAAACogaGVpZ2h0IG9yIHlvdSBoYXZlIGFscmVhZHkgd2l0aGRyYXduIFVTRFQAAAAAjwpWew==", "chainId": 84, "height": 1210013, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 3NAbdnrYj4jXW8mWr2D8uKgnXQBErrwUvEsVTxkjS1vB Next: 3ME835z4bBUvt9SCcmSsNdsy4TS7V5M5i6Fa6eDuyv3i Diff:
Old | New | Differences | |
---|---|---|---|
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let USDT = "5Sh9KghfkZyhjwuodovDhB6PghDUGBHiAPZ4MkrPgKtX" | |
5 | 5 | ||
6 | - | let USDN = " | |
6 | + | let USDN = "25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT" | |
7 | 7 | ||
8 | 8 | let idUSDN = fromBase58String(USDN) | |
9 | 9 | ||
98 | 98 | } | |
99 | 99 | ||
100 | 100 | ||
101 | - | @Verifier(contextObj) | |
102 | - | func verify () = true | |
103 | - |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let USDT = "5Sh9KghfkZyhjwuodovDhB6PghDUGBHiAPZ4MkrPgKtX" | |
5 | 5 | ||
6 | - | let USDN = " | |
6 | + | let USDN = "25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT" | |
7 | 7 | ||
8 | 8 | let idUSDN = fromBase58String(USDN) | |
9 | 9 | ||
10 | 10 | let idUSDT = fromBase58String(USDT) | |
11 | 11 | ||
12 | 12 | let withdrawDelay = 2 | |
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) = ((((toString(address) + "_WITHDRAW_") + toString(amountToSwapInKey)) + "_HEIGHT_") + toString(allowToWithdrawHeight)) | |
23 | 23 | ||
24 | 24 | ||
25 | 25 | @Callable(contextObj) | |
26 | 26 | func swapUSDTtoUSDN () = { | |
27 | 27 | let payment = match contextObj.payment { | |
28 | 28 | case p: AttachedPayment => | |
29 | 29 | p | |
30 | 30 | case _ => | |
31 | 31 | throw("Payment not attached") | |
32 | 32 | } | |
33 | 33 | let assetIdReceived = payment.assetId | |
34 | 34 | let tokenReceiveAmount = payment.amount | |
35 | 35 | let userAddress = contextObj.caller | |
36 | 36 | let currentClientBalanceUSDT = match getInteger(this, (toString(userAddress) + "_balance")) { | |
37 | 37 | case currentBalance: Int => | |
38 | 38 | value(getInteger(this, (toString(userAddress) + "_balance"))) | |
39 | 39 | case _ => | |
40 | 40 | 0 | |
41 | 41 | } | |
42 | 42 | if ((assetIdReceived != idUSDT)) | |
43 | 43 | then throw("to swap USDT to USDN you need attach payment in USDT") | |
44 | 44 | else if ((minimalAmountToSwapUSDT > tokenReceiveAmount)) | |
45 | 45 | then throw((("you can swap at least " + toString((minimalAmountToSwapUSDT / decimalPartUSDT))) + " tokens")) | |
46 | 46 | else ScriptResult(WriteSet([DataEntry((toString(contextObj.caller) + "_balance"), (currentClientBalanceUSDT + tokenReceiveAmount))]), TransferSet([ScriptTransfer(contextObj.caller, tokenReceiveAmount, idUSDN)])) | |
47 | 47 | } | |
48 | 48 | ||
49 | 49 | ||
50 | 50 | ||
51 | 51 | @Callable(contextObj) | |
52 | 52 | func initializationUSDNtoUSDTswap () = { | |
53 | 53 | let payment = match contextObj.payment { | |
54 | 54 | case p: AttachedPayment => | |
55 | 55 | p | |
56 | 56 | case _ => | |
57 | 57 | throw("Payment not attached") | |
58 | 58 | } | |
59 | 59 | let assetIdReceived = payment.assetId | |
60 | 60 | let paymentAmount = payment.amount | |
61 | 61 | let userAddress = contextObj.caller | |
62 | 62 | let currentClientBalanceUSDT = match getInteger(this, (toString(userAddress) + "_balance")) { | |
63 | 63 | case currentBalance: Int => | |
64 | 64 | getIntegerValue(this, (toString(userAddress) + "_balance")) | |
65 | 65 | case _ => | |
66 | 66 | 0 | |
67 | 67 | } | |
68 | 68 | if ((assetIdReceived != idUSDN)) | |
69 | 69 | then throw("to swap USDN to USDT you need attach payment in USDN") | |
70 | 70 | else if (if ((paymentAmount > currentClientBalanceUSDT)) | |
71 | 71 | then true | |
72 | 72 | else (minimalAmountToSwapUSDN > paymentAmount)) | |
73 | 73 | then throw("swap amount fail") | |
74 | 74 | else { | |
75 | 75 | let allowToWithDrawHeight = (height + withdrawDelay) | |
76 | 76 | if (isDefined(getString(this, collectKey(contextObj.caller, paymentAmount, allowToWithDrawHeight)))) | |
77 | 77 | then throw("you have already started withdrawal process, wait next block") | |
78 | 78 | else ScriptResult(WriteSet([DataEntry((toString(contextObj.caller) + "_balance"), (currentClientBalanceUSDT - paymentAmount)), DataEntry(collectKey(contextObj.caller, paymentAmount, allowToWithDrawHeight), "not_withdrawn")]), TransferSet(nil)) | |
79 | 79 | } | |
80 | 80 | } | |
81 | 81 | ||
82 | 82 | ||
83 | 83 | ||
84 | 84 | @Callable(contextObj) | |
85 | 85 | func swapUSDNtoUSDT (amountToSwapInKey,heightInKey) = { | |
86 | 86 | let key = collectKey(contextObj.caller, amountToSwapInKey, heightInKey) | |
87 | 87 | let withdrawnInfo = match getString(this, key) { | |
88 | 88 | case withdrawnInfo: String => | |
89 | 89 | getStringValue(this, key) | |
90 | 90 | case _ => | |
91 | 91 | throw(((("this key doesn't exists " + key) + " at address ") + toString(this))) | |
92 | 92 | } | |
93 | 93 | if (if ((height >= heightInKey)) | |
94 | 94 | then (withdrawnInfo == "not_withdrawn") | |
95 | 95 | else false) | |
96 | 96 | then ScriptResult(WriteSet([DataEntry(key, "withdrawn")]), TransferSet([ScriptTransfer(contextObj.caller, amountToSwapInKey, idUSDT)])) | |
97 | 97 | else throw((("withdrawal is possible after " + toString(heightInKey)) + " height or you have already withdrawn USDT")) | |
98 | 98 | } | |
99 | 99 | ||
100 | 100 | ||
101 | - | @Verifier(contextObj) | |
102 | - | func verify () = true | |
103 | - |
github/deemru/w8io/026f985 47.50 ms ◑