tx · FsnYb5e7XbijH5A9nr5ZuwCPKMryaqNDnoABr7it6Ytw

3Mzj8MyE3E3G55SLVE6Dgd6ew2uERLxiE4U:  -0.01300000 Waves

2022.10.20 11:14 [2280469] smart account 3Mzj8MyE3E3G55SLVE6Dgd6ew2uERLxiE4U > SELF 0.00000000 Waves

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

github/deemru/w8io/169f3d6 
35.37 ms