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:AAIEAAAAAAAAAAwIAhIAEgASBAoCAQEAAAATAAAAAARVU0RUAgAAACwzNE45WWNFRVRMV245M3FZUTY0RXNQMXg4OXRTcnVKVTQ0UnJFTVNYWEVQSgAAAAAEVVNETgIAAAAsREcyeEZrUGREd0tVb0JrekdBaFF0THBTR3pmWExpQ1lQRXplS0gyQWQyNHAAAAAABmlkVVNETgkAAlkAAAABBQAAAARVU0ROAAAAAAZpZFVTRFQJAAJZAAAAAQUAAAAEVVNEVAAAAAANd2l0aGRyYXdEZWxheQAAAAAAAAAFtAAAAAAPZGVjaW1hbFBhcnRVU0ROAAAAAAAAD0JAAAAAAA9kZWNpbWFsUGFydFVTRFQAAAAAAAAPQkAAAAAAF21pbmltYWxBbW91bnRUb1N3YXBVU0RUCQAAaAAAAAIAAAAAAAAAJxAFAAAAD2RlY2ltYWxQYXJ0VVNETgAAAAAXbWluaW1hbEFtb3VudFRvU3dhcFVTRE4JAABoAAAAAgAAAAAAAAAnEAUAAAAPZGVjaW1hbFBhcnRVU0RUAQAAAApjb2xsZWN0S2V5AAAAAwAAAAdhZGRyZXNzAAAAEWFtb3VudFRvU3dhcEluS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td2FwIGFtb3VudCBmYWlsLCBhbW91bnQgaXMgdG8gc21hbGwgb3IgdG8gYmlnLgQAAAAUdG9XaXRoZHJhd1dpdGhvdXRGZWUJAQAAABVnZXRXaXRob3V0RmVlV2l0aGRyYXcAAAACBQAAAAZhbW91bnQFAAAAFGN1cnJlbnRDbGllbnRCYWxhbmNlBAAAABF0b1dpdGhkcmF3V2l0aEZlZQkAAGUAAAACBQAAAAZhbW91bnQFAAAAFHRvV2l0aGRyYXdXaXRob3V0RmVlBAAAAANmZWUJAABoAAAAAgkAAGkAAAACBQAAABF0b1dpdGhkcmF3V2l0aEZlZQAAAAAAAAAAZAAAAAAAAAAAAgkABEwAAAACBQAAABR0b1dpdGhkcmF3V2l0aG91dEZlZQkABEwAAAACBQAAABF0b1dpdGhkcmF3V2l0aEZlZQkABEwAAAACBQAAAANmZWUFAAAAA25pbAAAAAMAAAAGaW52b2tlAQAAAA5zd2FwVVNEVHRvVVNETgAAAAAJAAACAAAAAQIAAAADb2ZmAAAABmludm9rZQEAAAAcaW5pdGlhbGl6YXRpb25VU0ROdG9VU0RUc3dhcAAAAAAJAAACAAAAAQIAAAADb2ZmAAAABmludm9rZQEAAAAOc3dhcFVTRE50b1VTRFQAAAACAAAABmFtb3VudAAAAAtoZWlnaHRJbktleQkAAAIAAAABAgAAAANvZmYAAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAACQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAkAAlkAAAABAgAAACwyQ2JkOG96RzdBMVJ5Uk5DM25OblpnSHU3UnU0SzNKQ2ZweVBraHFyOXp4ceFjUeg=", "chainId": 87, "height": 3123872, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: FHvaox4UhxG43uvp7iaHTCUWgwMivVNeuswdUarWETtB Next: HJa9mJ6Bm4iwN3v1vezY5VGkJfaHF4F9BaT4uaaxToit Diff:
OldNewDifferences
7070
7171
7272 @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")
8774
8875
8976
9077 @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")
11479
11580
11681
11782 @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")
12884
85+
86+@Verifier(tx)
87+func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], fromBase58String("2Cbd8ozG7A1RyRNC3nNnZgHu7Ru4K3JCfpyPkhqr9zxq"))
12988
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 4 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let USDT = "34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ"
55
66 let USDN = "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p"
77
88 let idUSDN = fromBase58String(USDN)
99
1010 let idUSDT = fromBase58String(USDT)
1111
1212 let withdrawDelay = 1460
1313
1414 let decimalPartUSDN = 1000000
1515
1616 let decimalPartUSDT = 1000000
1717
1818 let minimalAmountToSwapUSDT = (10000 * decimalPartUSDN)
1919
2020 let minimalAmountToSwapUSDN = (10000 * decimalPartUSDT)
2121
2222 func collectKey (address,amountToSwapInKey,allowToWithdrawHeight) = makeString([address, "WITHDRAW", toString(amountToSwapInKey), "HEIGHT", toString(allowToWithdrawHeight)], "_")
2323
2424
2525 func collectBalanceKey (address) = makeString([address, "balance"], "_")
2626
2727
2828 func collectBalanceKeyWithFee (address) = makeString([address, "balance_with_fee"], "_")
2929
3030
3131 func usdtToUsdnAssetError () = throw("To swap USDT to USDN you need attach payment in USDT")
3232
3333
3434 func usdnToUsdtAssetError () = throw("To swap USDN to USDT you need attach payment in USDN")
3535
3636
3737 func usdtToUsdnLowLimitError () = throw((("you can swap at least " + toString((minimalAmountToSwapUSDT / decimalPartUSDT))) + " tokens"))
3838
3939
4040 func abs (n) = if ((0 > n))
4141 then (n * -1)
4242 else n
4343
4444
4545 func getWithoutFeeWithdraw (amount,balanceWithoutFee) = min([amount, balanceWithoutFee])
4646
4747
4848 func getListElementOrDefault (list,index,default) = if ((size(list) > index))
4949 then list[index]
5050 else default
5151
5252
5353 func currentWithdrawals (address,amount) = {
5454 let balanceKey = collectBalanceKey(address)
5555 let balanceWithFeeKey = collectBalanceKeyWithFee(address)
5656 let currentClientBalance = valueOrElse(getInteger(this, balanceKey), 0)
5757 let currentClientBalanceWithFee = valueOrElse(getInteger(this, balanceWithFeeKey), 0)
5858 let userBalance = (currentClientBalance + currentClientBalanceWithFee)
5959 if (if ((amount > userBalance))
6060 then true
6161 else (minimalAmountToSwapUSDN > amount))
6262 then throw("Swap amount fail, amount is to small or to big.")
6363 else {
6464 let toWithdrawWithoutFee = getWithoutFeeWithdraw(amount, currentClientBalance)
6565 let toWithdrawWithFee = (amount - toWithdrawWithoutFee)
6666 let fee = ((toWithdrawWithFee / 100) * 2)
6767 [toWithdrawWithoutFee, toWithdrawWithFee, fee]
6868 }
6969 }
7070
7171
7272 @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")
8774
8875
8976
9077 @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")
11479
11580
11681
11782 @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")
12884
85+
86+@Verifier(tx)
87+func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], fromBase58String("2Cbd8ozG7A1RyRNC3nNnZgHu7Ru4K3JCfpyPkhqr9zxq"))
12988

github/deemru/w8io/3ef1775 
53.73 ms