tx · 2ZVenyYBikzveCsLwJnkDRkU8FQYTeE6pwfNvn4dtiLs 3MxCNvgYGmRUBapjxYK6QJe93k3zGKmESW5: -0.01400000 Waves 2020.08.05 15:13 [1119099] smart account 3MxCNvgYGmRUBapjxYK6QJe93k3zGKmESW5 > SELF 0.00000000 Waves
{ "type": 13, "id": "2ZVenyYBikzveCsLwJnkDRkU8FQYTeE6pwfNvn4dtiLs", "fee": 1400000, "feeAssetId": null, "timestamp": 1596629593753, "version": 1, "sender": "3MxCNvgYGmRUBapjxYK6QJe93k3zGKmESW5", "senderPublicKey": "DUAUjNB9PvmJwZsXoeDa41DLxMj8tYAfSCr5NEzkuWku", "proofs": [ "3LAFu3BvnJaNyhB269ikFtgWrNufPVacWFJn8U7Jz8GAya1iKXb1TjB4V3Z4p8kUtuTdwTsXvBcyzM4GhwLtVc3t" ], "script": "base64:AAIDAAAAAAAAAAwIARIAEgASBAoCAQEAAAAJAAAAAARVU0RUAgAAACxETUplTTlYSlRFbmhCbVlyTEJkVktrWXg2R2ViMzdlOXBneUVjMjZSMUpLWgAAAAAEVVNETgIAAAAsN1lXVmJydld4Qm5UU1pHUk12UkJmcTV2cUFTOWtROFVmNXY1QlN4eWE2Wm8AAAAABmlkVVNETgkAAlkAAAABBQAAAARVU0ROAAAAAAZpZFVTRFQJAAJZAAAAAQUAAAAEVVNEVAAAAAANd2l0aGRyYXdEZWxheQAAAAAAAAAAAQAAAAAPZGVjaW1hbFBhcnRVU0ROAAAAAAAAD0JAAAAAAA9kZWNpbWFsUGFydFVTRFQAAAAAAAAPQkAAAAAAF21pbmltYWxBbW91bnRUb1N3YXBVU0RUCQAAaAAAAAIAAAAAAAABhqAFAAAAD2RlY2ltYWxQYXJ0VVNETgAAAAAXbWluaW1hbEFtb3VudFRvU3dhcFVTRE4JAABoAAAAAgAAAAAAAADDUAUAAAAPZGVjaW1hbFBhcnRVU0RUAAAAAwAAAApjb250ZXh0T2JqAQAAAA5zd2FwVVNEVHRvVVNETgAAAAA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dAAAAAIJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIFAAAAA2tleQIAAAAJd2l0aGRyYXduBQAAAANuaWwJAQAAAAtUcmFuc2ZlclNldAAAAAEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAACmNvbnRleHRPYmoAAAAGY2FsbGVyBQAAABFhbW91bnRUb1N3YXBJbktleQUAAAAGaWRVU0RUBQAAAANuaWwJAAACAAAAAQkAASwAAAACCQABLAAAAAICAAAAHXdpdGhkcmF3YWwgaXMgcG9zc2libGUgYWZ0ZXIgCQABpAAAAAEFAAAAC2hlaWdodEluS2V5AgAAACogaGVpZ2h0IG9yIHlvdSBoYXZlIGFscmVhZHkgd2l0aGRyYXduIFVTRFQAAAAA45j+gg==", "chainId": 84, "height": 1119099, "spentComplexity": 0 } View: original | compacted Prev: none Next: AZjGnbZw7ZCnJQtKYJWFb1koPB1b2hnMo4NGKWHX3EmM Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 3 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let USDT = "DMJeM9XJTEnhBmYrLBdVKkYx6Geb37e9pgyEc26R1JKZ" | |
5 | + | ||
6 | + | let USDN = "7YWVbrvWxBnTSZGRMvRBfq5vqAS9kQ8Uf5v5BSxya6Zo" | |
7 | + | ||
8 | + | let idUSDN = fromBase58String(USDN) | |
9 | + | ||
10 | + | let idUSDT = fromBase58String(USDT) | |
11 | + | ||
12 | + | let withdrawDelay = 1 | |
13 | + | ||
14 | + | let decimalPartUSDN = 1000000 | |
15 | + | ||
16 | + | let decimalPartUSDT = 1000000 | |
17 | + | ||
18 | + | let minimalAmountToSwapUSDT = (100000 * decimalPartUSDN) | |
19 | + | ||
20 | + | let minimalAmountToSwapUSDN = (50000 * decimalPartUSDT) | |
21 | + | ||
22 | + | @Callable(contextObj) | |
23 | + | func swapUSDTtoUSDN () = { | |
24 | + | let payment = match contextObj.payment { | |
25 | + | case p: AttachedPayment => | |
26 | + | p | |
27 | + | case _ => | |
28 | + | throw("Payment not attached") | |
29 | + | } | |
30 | + | let assetIdReceived = payment.assetId | |
31 | + | let tokenReceiveAmount = payment.amount | |
32 | + | let userAddress = contextObj.caller | |
33 | + | let currentClientBalanceUSDT = match getInteger(this, (toString(userAddress) + "_balance")) { | |
34 | + | case currentBalance: Int => | |
35 | + | value(getInteger(this, (toString(userAddress) + "_balance"))) | |
36 | + | case _ => | |
37 | + | 0 | |
38 | + | } | |
39 | + | if ((assetIdReceived != idUSDT)) | |
40 | + | then throw("to swap USDT to USDN you need attach payment in USDT") | |
41 | + | else if ((minimalAmountToSwapUSDT > tokenReceiveAmount)) | |
42 | + | then throw((("you can swap at least " + toString((minimalAmountToSwapUSDT / decimalPartUSDN))) + " tokens")) | |
43 | + | else ScriptResult(WriteSet([DataEntry((toString(contextObj.caller) + "_balance"), (currentClientBalanceUSDT + tokenReceiveAmount))]), TransferSet([ScriptTransfer(contextObj.caller, tokenReceiveAmount, idUSDN)])) | |
44 | + | } | |
45 | + | ||
46 | + | ||
47 | + | ||
48 | + | @Callable(contextObj) | |
49 | + | func initializationUSDNtoUSDTswap () = { | |
50 | + | let payment = match contextObj.payment { | |
51 | + | case p: AttachedPayment => | |
52 | + | p | |
53 | + | case _ => | |
54 | + | throw("Payment not attached") | |
55 | + | } | |
56 | + | let assetIdReceived = payment.assetId | |
57 | + | let paymentAmount = payment.amount | |
58 | + | let userAddress = contextObj.caller | |
59 | + | let currentClientBalanceUSDT = match getInteger(this, (toString(userAddress) + "_balance")) { | |
60 | + | case currentBalance: Int => | |
61 | + | getIntegerValue(this, (toString(userAddress) + "_balance")) | |
62 | + | case _ => | |
63 | + | 0 | |
64 | + | } | |
65 | + | if ((assetIdReceived != idUSDN)) | |
66 | + | then throw("to swap USDN to USDT you need attach payment in USDN") | |
67 | + | else if (if ((paymentAmount > currentClientBalanceUSDT)) | |
68 | + | then true | |
69 | + | else (minimalAmountToSwapUSDN > paymentAmount)) | |
70 | + | then throw("swap amount fail") | |
71 | + | else if (isDefined(getString(this, ((((toString(contextObj.caller) + "_WITHDRAW_") + toString(paymentAmount)) + "_HEIGHT_") + toString((height + withdrawDelay)))))) | |
72 | + | then throw("you have already started withdrawal process, wait next block") | |
73 | + | else ScriptResult(WriteSet([DataEntry((toString(contextObj.caller) + "_balance"), (currentClientBalanceUSDT - paymentAmount)), DataEntry(((((toString(contextObj.caller) + "_WITHDRAW_") + toString(paymentAmount)) + "_HEIGHT_") + toString((height + withdrawDelay))), "not_withdrawn")]), TransferSet(nil)) | |
74 | + | } | |
75 | + | ||
76 | + | ||
77 | + | ||
78 | + | @Callable(contextObj) | |
79 | + | func swapUSDNtoUSDT (amountToSwapInKey,heightInKey) = { | |
80 | + | let key = ((((toString(contextObj.caller) + "_WITHDRAW_") + toString(amountToSwapInKey)) + "_HEIGHT_") + toString(heightInKey)) | |
81 | + | let withdrawnInfo = match getString(this, key) { | |
82 | + | case withdrawnInfo: String => | |
83 | + | getStringValue(this, key) | |
84 | + | case _ => | |
85 | + | throw(((("this key doesn't exists " + key) + " at address ") + toString(this))) | |
86 | + | } | |
87 | + | if (if ((height >= heightInKey)) | |
88 | + | then (withdrawnInfo == "not_withdrawn") | |
89 | + | else false) | |
90 | + | then ScriptResult(WriteSet([DataEntry(key, "withdrawn")]), TransferSet([ScriptTransfer(contextObj.caller, amountToSwapInKey, idUSDT)])) | |
91 | + | else throw((("withdrawal is possible after " + toString(heightInKey)) + " height or you have already withdrawn USDT")) | |
92 | + | } | |
93 | + | ||
94 | + |
github/deemru/w8io/169f3d6 17.51 ms ◑