tx · v8PNEpxBnSPUFF8j2JDntX9weaDytHw4hfTaDYsJAja

3Mzj8MyE3E3G55SLVE6Dgd6ew2uERLxiE4U:  -0.01300000 Waves

2022.07.20 13:26 [2147961] smart account 3Mzj8MyE3E3G55SLVE6Dgd6ew2uERLxiE4U > SELF 0.00000000 Waves

{ "type": 13, "id": "v8PNEpxBnSPUFF8j2JDntX9weaDytHw4hfTaDYsJAja", "fee": 1300000, "feeAssetId": null, "timestamp": 1658312878198, "version": 1, "sender": "3Mzj8MyE3E3G55SLVE6Dgd6ew2uERLxiE4U", "senderPublicKey": "8E1ZoUTJyyA7ybXtP2NxUZKdAwvR1ruiQUxZD2bYJJMF", "proofs": [ "3MRdmpPJtreXR7affgMGf9KrypaQjCf4iWw2sF4TKBhCE7i81S1fuiSm5PzGnM6436rYw54uKM4CkC3QcwuxUrqN" ], "script": "base64:BgIjCAISAwoBARIDCgEBEgQKAggIEgASABIECgIBARIDCgEIEgAaAA13aXRoZHJhd0RlbGF5ALQLAA9kZWNpbWFsUGFydFVTRE4AwIQ9AA9kZWNpbWFsUGFydFVTRFQAwIQ9ABdtaW5pbWFsQW1vdW50VG9Td2FwVVNEVAkAaAIAkE4FD2RlY2ltYWxQYXJ0VVNETgAXbWluaW1hbEFtb3VudFRvU3dhcFVTRE4JAGgCAJBOBQ9kZWNpbWFsUGFydFVTRFQBE2tleU1hbmFnZXJQdWJsaWNLZXkAAhQlc19fbWFuYWdlclB1YmxpY0tleQEaa2V5UGVuZGluZ01hbmFnZXJQdWJsaWNLZXkAAhslc19fcGVuZGluZ01hbmFnZXJQdWJsaWNLZXkBDmtleVVzZHRBc3NldElkAAIPJXNfX3VzZHRBc3NldElkAQ5rZXlVc2RuQXNzZXRJZAACDyVzX191c2RuQXNzZXRJZAENa2V5RGVwb3NpdEZlZQACDiVzX19kZXBvc2l0RmVlAQ5rZXlXaXRoZHJhd0ZlZQACDyVzX193aXRoZHJhd0ZlZQEEdXNkdAAJANkEAQkBBXZhbHVlAQkA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GluZ01hbmFnZXJQdWJsaWNLZXkFA25pbAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgFpAQ5jb25maXJtTWFuYWdlcgAEAnBtCQEdcGVuZGluZ01hbmFnZXJQdWJsaWNLZXlPclVuaXQABAVoYXNQTQMJAQlpc0RlZmluZWQBBQJwbQYJAAIBAhJObyBwZW5kaW5nIG1hbmFnZXIDCQAAAgUFaGFzUE0FBWhhc1BNBAdjaGVja1BNAwkAAAIIBQFpD2NhbGxlclB1YmxpY0tleQkBBXZhbHVlAQUCcG0GCQACAQIbWW91IGFyZSBub3QgcGVuZGluZyBtYW5hZ2VyAwkAAAIFB2NoZWNrUE0FB2NoZWNrUE0JAMwIAgkBC1N0cmluZ0VudHJ5AgkBE2tleU1hbmFnZXJQdWJsaWNLZXkACQDYBAEJAQV2YWx1ZQEFAnBtCQDMCAIJAQtEZWxldGVFbnRyeQEJARprZXlQZW5kaW5nTWFuYWdlclB1YmxpY0tleQAFA25pbAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgECdHgBBnZlcmlmeQAED3RhcmdldFB1YmxpY0tleQQHJG1hdGNoMAkBFm1hbmFnZXJQdWJsaWNLZXlPclVuaXQAAwkAAQIFByRtYXRjaDACCkJ5dGVWZWN0b3IEAnBrBQckbWF0Y2gwBQJwawMJAAECBQckbWF0Y2gwAgRVbml0CAUCdHgPc2VuZGVyUHVibGljS2V5CQACAQILTWF0Y2ggZXJyb3IJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAFD3RhcmdldFB1YmxpY0tlebituT4=", "chainId": 84, "height": 2147961, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4Sh1sWEgaRyo5KrvZiZhbGp6ri4p2j1sWLU9kjoYF89D Next: AKQ6cD67p5XycYGToaPcc77SuK4B8L6dX6Efz9CGJooP Diff:
OldNewDifferences
2323 func keyUsdnAssetId () = "%s__usdnAssetId"
2424
2525
26-func keyDepositFee () = "%s__deposiFee"
26+func keyDepositFee () = "%s__depositFee"
2727
2828
2929 func keyWithdrawFee () = "%s__withdrawFee"
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let withdrawDelay = 1460
55
66 let decimalPartUSDN = 1000000
77
88 let decimalPartUSDT = 1000000
99
1010 let minimalAmountToSwapUSDT = (10000 * decimalPartUSDN)
1111
1212 let minimalAmountToSwapUSDN = (10000 * decimalPartUSDT)
1313
1414 func keyManagerPublicKey () = "%s__managerPublicKey"
1515
1616
1717 func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey"
1818
1919
2020 func keyUsdtAssetId () = "%s__usdtAssetId"
2121
2222
2323 func keyUsdnAssetId () = "%s__usdnAssetId"
2424
2525
26-func keyDepositFee () = "%s__deposiFee"
26+func keyDepositFee () = "%s__depositFee"
2727
2828
2929 func keyWithdrawFee () = "%s__withdrawFee"
3030
3131
3232 func usdt () = fromBase58String(value(getString(keyUsdtAssetId())))
3333
3434
3535 func usdn () = fromBase58String(value(getString(keyUsdnAssetId())))
3636
3737
3838 func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) {
3939 case s: String =>
4040 fromBase58String(s)
4141 case _: Unit =>
4242 unit
4343 case _ =>
4444 throw("Match error")
4545 }
4646
4747
4848 func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) {
4949 case s: String =>
5050 fromBase58String(s)
5151 case _: Unit =>
5252 unit
5353 case _ =>
5454 throw("Match error")
5555 }
5656
5757
5858 func collectKey (address,amountToSwapInKey,allowToWithdrawHeight) = makeString([address, "WITHDRAW", toString(amountToSwapInKey), "HEIGHT", toString(allowToWithdrawHeight)], "_")
5959
6060
6161 func collectBalanceKey (address) = makeString([address, "balance"], "_")
6262
6363
6464 func collectBalanceKeyWithFee (address) = makeString([address, "balance_with_fee"], "_")
6565
6666
6767 func usdtToUsdnAssetError () = throw("To swap USDT to USDN you need attach payment in USDT")
6868
6969
7070 func usdnToUsdtAssetError () = throw("To swap USDN to USDT you need attach payment in USDN")
7171
7272
7373 func usdtToUsdnLowLimitError () = throw((("you can swap at least " + toString((minimalAmountToSwapUSDT / decimalPartUSDT))) + " tokens"))
7474
7575
7676 func abs (n) = if ((0 > n))
7777 then (n * -1)
7878 else n
7979
8080
8181 func getWithoutFeeWithdraw (amount,balanceWithoutFee) = min([amount, balanceWithoutFee])
8282
8383
8484 func getListElementOrDefault (list,index,default) = if ((size(list) > index))
8585 then list[index]
8686 else default
8787
8888
8989 func currentWithdrawals (address,amount) = {
9090 let balanceKey = collectBalanceKey(address)
9191 let balanceWithFeeKey = collectBalanceKeyWithFee(address)
9292 let currentClientBalance = valueOrElse(getInteger(this, balanceKey), 0)
9393 let currentClientBalanceWithFee = valueOrElse(getInteger(this, balanceWithFeeKey), 0)
9494 let userBalance = (currentClientBalance + currentClientBalanceWithFee)
9595 if (if ((amount > userBalance))
9696 then true
9797 else (minimalAmountToSwapUSDN > amount))
9898 then throw("Swap amount fail, amount is to small or to big.")
9999 else {
100100 let toWithdrawWithoutFee = getWithoutFeeWithdraw(amount, currentClientBalance)
101101 let toWithdrawWithFee = (amount - toWithdrawWithoutFee)
102102 let fee = ((toWithdrawWithFee / 100) * value(getInteger(keyWithdrawFee())))
103103 [toWithdrawWithoutFee, toWithdrawWithFee, fee]
104104 }
105105 }
106106
107107
108108 func mustManager (i) = {
109109 let pd = throw("Permission denied")
110110 match managerPublicKeyOrUnit() {
111111 case pk: ByteVector =>
112112 if ((i.callerPublicKey == pk))
113113 then true
114114 else pd
115115 case _: Unit =>
116116 if ((i.caller == this))
117117 then true
118118 else pd
119119 case _ =>
120120 throw("Match error")
121121 }
122122 }
123123
124124
125125 @Callable(i)
126126 func setWithdrawFee (newFee) = {
127127 let checkCaller = mustManager(i)
128128 if ((checkCaller == checkCaller))
129129 then [IntegerEntry(keyWithdrawFee(), newFee)]
130130 else throw("Strict value is not equal to itself.")
131131 }
132132
133133
134134
135135 @Callable(i)
136136 func setDepositFee (newFee) = {
137137 let checkCaller = mustManager(i)
138138 if ((checkCaller == checkCaller))
139139 then [IntegerEntry(keyDepositFee(), newFee)]
140140 else throw("Strict value is not equal to itself.")
141141 }
142142
143143
144144
145145 @Callable(i)
146146 func constructor (usdtAssetId,usdnAssetId) = {
147147 let checkCaller = mustManager(i)
148148 if ((checkCaller == checkCaller))
149149 then [StringEntry(keyUsdtAssetId(), usdtAssetId), StringEntry(keyUsdnAssetId(), usdnAssetId)]
150150 else throw("Strict value is not equal to itself.")
151151 }
152152
153153
154154
155155 @Callable(invoke)
156156 func swapUSDTtoUSDN () = {
157157 let balanceKey = collectBalanceKeyWithFee(toString(invoke.caller))
158158 let payment = value(invoke.payments[0])
159159 if ((payment.assetId != usdt()))
160160 then usdtToUsdnAssetError()
161161 else {
162162 let amount = payment.amount
163163 let fee = ((amount / 100) * value(getInteger(keyDepositFee())))
164164 let currentClientBalanceUSDT = valueOrElse(getInteger(this, balanceKey), 0)
165165 if ((minimalAmountToSwapUSDT > amount))
166166 then usdtToUsdnLowLimitError()
167167 else [IntegerEntry(balanceKey, (currentClientBalanceUSDT + amount)), ScriptTransfer(invoke.caller, (amount - fee), usdn())]
168168 }
169169 }
170170
171171
172172
173173 @Callable(invoke)
174174 func initializationUSDNtoUSDTswap () = {
175175 let payment = value(invoke.payments[0])
176176 let address = toString(invoke.caller)
177177 if ((payment.assetId != usdn()))
178178 then usdnToUsdtAssetError()
179179 else {
180180 let amount = payment.amount
181181 let balanceKey = collectBalanceKey(address)
182182 let balanceWithFeeKey = collectBalanceKeyWithFee(address)
183183 let currentClientBalance = valueOrElse(getInteger(this, balanceKey), 0)
184184 let currentClientBalanceWithFee = valueOrElse(getInteger(this, balanceWithFeeKey), 0)
185185 let userBalance = (currentClientBalance + currentClientBalanceWithFee)
186186 let data = currentWithdrawals(toString(invoke.caller), amount)
187187 let toWithdrawWithoutFee = valueOrErrorMessage(data[0], "Wrong 'currentWithdrawals' method!")
188188 let toWithdrawWithFee = valueOrErrorMessage(data[1], "Wrong 'currentWithdrawals' method!")
189189 let fee = valueOrErrorMessage(data[2], "Wrong 'currentWithdrawals' method!")
190190 let total = ((toWithdrawWithFee + toWithdrawWithoutFee) - fee)
191191 let allowToWithDrawHeight = (height + withdrawDelay)
192192 if (isDefined(getString(this, collectKey(toString(invoke.caller), amount, allowToWithDrawHeight))))
193193 then throw("You have already started withdrawal process, wait next block.")
194194 else [IntegerEntry(balanceKey, (currentClientBalance - toWithdrawWithoutFee)), IntegerEntry(balanceWithFeeKey, (currentClientBalanceWithFee - toWithdrawWithFee)), StringEntry(collectKey(toString(invoke.caller), amount, allowToWithDrawHeight), makeString(["not_withdrawn", toString((amount - fee))], "_"))]
195195 }
196196 }
197197
198198
199199
200200 @Callable(invoke)
201201 func swapUSDNtoUSDT (amount,heightInKey) = {
202202 let key = collectKey(toString(invoke.caller), amount, heightInKey)
203203 let withdrawnInfo = valueOrErrorMessage(getString(this, key), ((("This key doesn't exists " + key) + " at address ") + toString(this)))
204204 let toWithdraw = getListElementOrDefault(split(withdrawnInfo, "_"), 2, toString(amount))
205205 if (if ((height >= heightInKey))
206206 then contains(withdrawnInfo, "not_withdrawn")
207207 else false)
208208 then [DeleteEntry(key), ScriptTransfer(invoke.caller, valueOrErrorMessage(parseInt(toWithdraw), "Wrong withdraw data!"), usdt())]
209209 else throw((("Withdrawal is possible after " + toString(heightInKey)) + " height or you have already withdrawn USDT."))
210210 }
211211
212212
213213
214214 @Callable(i)
215215 func setManager (pendingManagerPublicKey) = {
216216 let checkCaller = mustManager(i)
217217 if ((checkCaller == checkCaller))
218218 then {
219219 let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey)
220220 if ((checkManagerPublicKey == checkManagerPublicKey))
221221 then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)]
222222 else throw("Strict value is not equal to itself.")
223223 }
224224 else throw("Strict value is not equal to itself.")
225225 }
226226
227227
228228
229229 @Callable(i)
230230 func confirmManager () = {
231231 let pm = pendingManagerPublicKeyOrUnit()
232232 let hasPM = if (isDefined(pm))
233233 then true
234234 else throw("No pending manager")
235235 if ((hasPM == hasPM))
236236 then {
237237 let checkPM = if ((i.callerPublicKey == value(pm)))
238238 then true
239239 else throw("You are not pending manager")
240240 if ((checkPM == checkPM))
241241 then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())]
242242 else throw("Strict value is not equal to itself.")
243243 }
244244 else throw("Strict value is not equal to itself.")
245245 }
246246
247247
248248 @Verifier(tx)
249249 func verify () = {
250250 let targetPublicKey = match managerPublicKeyOrUnit() {
251251 case pk: ByteVector =>
252252 pk
253253 case _: Unit =>
254254 tx.senderPublicKey
255255 case _ =>
256256 throw("Match error")
257257 }
258258 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
259259 }
260260

github/deemru/w8io/026f985 
51.74 ms