tx · AZjGnbZw7ZCnJQtKYJWFb1koPB1b2hnMo4NGKWHX3EmM

3MxCNvgYGmRUBapjxYK6QJe93k3zGKmESW5:  -0.01400000 Waves

2020.08.05 15:14 [1119101] smart account 3MxCNvgYGmRUBapjxYK6QJe93k3zGKmESW5 > SELF 0.00000000 Waves

{ "type": 13, "id": "AZjGnbZw7ZCnJQtKYJWFb1koPB1b2hnMo4NGKWHX3EmM", "fee": 1400000, "feeAssetId": null, "timestamp": 1596629685584, "version": 1, "sender": "3MxCNvgYGmRUBapjxYK6QJe93k3zGKmESW5", "senderPublicKey": "DUAUjNB9PvmJwZsXoeDa41DLxMj8tYAfSCr5NEzkuWku", "proofs": [ "23bmJbeHGGtSxJCAcqxxFJJgbuF3jkaWztLH5TGewVrkpt8QUKbV52ABBrTBxZ5ySi93LE695JwJzcc6aZZBxspd" ], "script": "base64:AAIDAAAAAAAAAAwIARIAEgASBAoCAQEAAAAJAAAAAARVU0RUAgAAACxETUplTTlYSlRFbmhCbVlyTEJkVktrWXg2R2ViMzdlOXBneUVjMjZSMUpLWgAAAAAEVVNETgIAAAAsN1lXVmJydld4Qm5UU1pHUk12UkJmcTV2cUFTOWtROFVmNXY1QlN4eWE2Wm8AAAAABmlkVVNETgkAAlkAAAABBQAAAARVU0ROAAAAAAZpZFVTRFQJAAJZAAAAAQUAAAAEVVNEVAAAAAANd2l0aGRyYXdEZWxheQAAAAAAAAAAAQAAAAAPZGVjaW1hbFBhcnRVU0ROAAAAAAAAD0JAAAAAAA9kZWNpbWFsUGFydFVTRFQAAAAAAAAPQkAAAAAAF21pbmltYWxBbW91bnRUb1N3YXBVU0RUCQAAaAAAAAIAAAAAAAABhqAFAAAAD2RlY2ltYWxQYXJ0VVNETgAAAAAXbWluaW1hbEFtb3VudFRvU3dhcFVTRE4JAABoAAAAAgAAAAAAAADDUAUAAAAPZGVjaW1hbFBhcnRVU0RUAAAAAwAAAApjb250ZXh0T2JqAQAAAA5zd2FwVVNEVHRvVVNETgAAAAA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dAAAAAIJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIFAAAAA2tleQIAAAAJd2l0aGRyYXduBQAAAANuaWwJAQAAAAtUcmFuc2ZlclNldAAAAAEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAACmNvbnRleHRPYmoAAAAGY2FsbGVyBQAAABFhbW91bnRUb1N3YXBJbktleQUAAAAGaWRVU0RUBQAAAANuaWwJAAACAAAAAQkAASwAAAACCQABLAAAAAICAAAAHXdpdGhkcmF3YWwgaXMgcG9zc2libGUgYWZ0ZXIgCQABpAAAAAEFAAAAC2hlaWdodEluS2V5AgAAACogaGVpZ2h0IG9yIHlvdSBoYXZlIGFscmVhZHkgd2l0aGRyYXduIFVTRFQAAAAA45j+gg==", "chainId": 84, "height": 1119101, "spentComplexity": 0 } View: original | compacted Prev: 2ZVenyYBikzveCsLwJnkDRkU8FQYTeE6pwfNvn4dtiLs Next: BrrPwBp1mQrE92yjfFyAgzAEuAy1qUW4E97RNWAFYqnY Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let USDT = "DMJeM9XJTEnhBmYrLBdVKkYx6Geb37e9pgyEc26R1JKZ"
55
66 let USDN = "7YWVbrvWxBnTSZGRMvRBfq5vqAS9kQ8Uf5v5BSxya6Zo"
77
88 let idUSDN = fromBase58String(USDN)
99
1010 let idUSDT = fromBase58String(USDT)
1111
1212 let withdrawDelay = 1
1313
1414 let decimalPartUSDN = 1000000
1515
1616 let decimalPartUSDT = 1000000
1717
1818 let minimalAmountToSwapUSDT = (100000 * decimalPartUSDN)
1919
2020 let minimalAmountToSwapUSDN = (50000 * decimalPartUSDT)
2121
2222 @Callable(contextObj)
2323 func swapUSDTtoUSDN () = {
2424 let payment = match contextObj.payment {
2525 case p: AttachedPayment =>
2626 p
2727 case _ =>
2828 throw("Payment not attached")
2929 }
3030 let assetIdReceived = payment.assetId
3131 let tokenReceiveAmount = payment.amount
3232 let userAddress = contextObj.caller
3333 let currentClientBalanceUSDT = match getInteger(this, (toString(userAddress) + "_balance")) {
3434 case currentBalance: Int =>
3535 value(getInteger(this, (toString(userAddress) + "_balance")))
3636 case _ =>
3737 0
3838 }
3939 if ((assetIdReceived != idUSDT))
4040 then throw("to swap USDT to USDN you need attach payment in USDT")
4141 else if ((minimalAmountToSwapUSDT > tokenReceiveAmount))
4242 then throw((("you can swap at least " + toString((minimalAmountToSwapUSDT / decimalPartUSDN))) + " tokens"))
4343 else ScriptResult(WriteSet([DataEntry((toString(contextObj.caller) + "_balance"), (currentClientBalanceUSDT + tokenReceiveAmount))]), TransferSet([ScriptTransfer(contextObj.caller, tokenReceiveAmount, idUSDN)]))
4444 }
4545
4646
4747
4848 @Callable(contextObj)
4949 func initializationUSDNtoUSDTswap () = {
5050 let payment = match contextObj.payment {
5151 case p: AttachedPayment =>
5252 p
5353 case _ =>
5454 throw("Payment not attached")
5555 }
5656 let assetIdReceived = payment.assetId
5757 let paymentAmount = payment.amount
5858 let userAddress = contextObj.caller
5959 let currentClientBalanceUSDT = match getInteger(this, (toString(userAddress) + "_balance")) {
6060 case currentBalance: Int =>
6161 getIntegerValue(this, (toString(userAddress) + "_balance"))
6262 case _ =>
6363 0
6464 }
6565 if ((assetIdReceived != idUSDN))
6666 then throw("to swap USDN to USDT you need attach payment in USDN")
6767 else if (if ((paymentAmount > currentClientBalanceUSDT))
6868 then true
6969 else (minimalAmountToSwapUSDN > paymentAmount))
7070 then throw("swap amount fail")
7171 else if (isDefined(getString(this, ((((toString(contextObj.caller) + "_WITHDRAW_") + toString(paymentAmount)) + "_HEIGHT_") + toString((height + withdrawDelay))))))
7272 then throw("you have already started withdrawal process, wait next block")
7373 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))
7474 }
7575
7676
7777
7878 @Callable(contextObj)
7979 func swapUSDNtoUSDT (amountToSwapInKey,heightInKey) = {
8080 let key = ((((toString(contextObj.caller) + "_WITHDRAW_") + toString(amountToSwapInKey)) + "_HEIGHT_") + toString(heightInKey))
8181 let withdrawnInfo = match getString(this, key) {
8282 case withdrawnInfo: String =>
8383 getStringValue(this, key)
8484 case _ =>
8585 throw(((("this key doesn't exists " + key) + " at address ") + toString(this)))
8686 }
8787 if (if ((height >= heightInKey))
8888 then (withdrawnInfo == "not_withdrawn")
8989 else false)
9090 then ScriptResult(WriteSet([DataEntry(key, "withdrawn")]), TransferSet([ScriptTransfer(contextObj.caller, amountToSwapInKey, idUSDT)]))
9191 else throw((("withdrawal is possible after " + toString(heightInKey)) + " height or you have already withdrawn USDT"))
9292 }
9393
9494

github/deemru/w8io/169f3d6 
38.77 ms