tx · 5CbWP6npU5HkvemdY48ChsjY3PB9cyKFv7LyREAF6Xz3

3Mzj8MyE3E3G55SLVE6Dgd6ew2uERLxiE4U:  -0.01300000 Waves

2022.10.27 10:05 [2290508] smart account 3Mzj8MyE3E3G55SLVE6Dgd6ew2uERLxiE4U > SELF 0.00000000 Waves

{ "type": 13, "id": "5CbWP6npU5HkvemdY48ChsjY3PB9cyKFv7LyREAF6Xz3", "fee": 1300000, "feeAssetId": null, "timestamp": 1666854343094, "version": 1, "sender": "3Mzj8MyE3E3G55SLVE6Dgd6ew2uERLxiE4U", "senderPublicKey": "8E1ZoUTJyyA7ybXtP2NxUZKdAwvR1ruiQUxZD2bYJJMF", "proofs": [ "5Ws4Z2B7xK3mpSv5VAdpE2k4VrB8wkjZHhEfA4hvNN5mUWDb3C9r4vJrfkSpS5T9uNZDt9U5qEqxqkAJPGE5gsWq" ], "script": "base64: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", "chainId": 84, "height": 2290508, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: FsnYb5e7XbijH5A9nr5ZuwCPKMryaqNDnoABr7it6Ytw Next: Gq3EjRnmETyUCvUVkuhe91aMDGXT5kiWKNPJAhoi2qXK Diff:
OldNewDifferences
1-{-# STDLIB_VERSION 6 #-}
1+{-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let decimalPartUSDN = 1000000
5-
6-let decimalPartUSDT = 1000000
7-
8-func keyWithdrawDelay () = "%s__withdrawDelay"
9-
10-
11-func withdrawDelay () = value(getInteger(keyWithdrawDelay()))
12-
13-
14-func keyMinimalAmountToSwapUsdt () = "%s__minimalAmountToSwapUsdt"
15-
16-
17-func keyMinimalAmountToSwapUsdn () = "%s__minimalAmountToSwapUsdn"
18-
19-
20-func minUsdt () = value(getInteger(keyMinimalAmountToSwapUsdt()))
21-
22-
23-func minUsdn () = value(getInteger(keyMinimalAmountToSwapUsdn()))
24-
25-
264 func keyManagerPublicKey () = "%s__managerPublicKey"
275
286
297 func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey"
30-
31-
32-func keyUsdtAssetId () = "%s__usdtAssetId"
33-
34-
35-func keyUsdnAssetId () = "%s__usdnAssetId"
36-
37-
38-func keyDepositFee () = "%s__depositFee"
39-
40-
41-func keyWithdrawFee () = "%s__withdrawFee"
42-
43-
44-func usdt () = fromBase58String(value(getString(keyUsdtAssetId())))
45-
46-
47-func usdn () = fromBase58String(value(getString(keyUsdnAssetId())))
488
499
5010 func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) {
6727 }
6828
6929
70-func collectKey (address,amountToSwapInKey,allowToWithdrawHeight) = makeString([address, "WITHDRAW", toString(amountToSwapInKey), "HEIGHT", toString(allowToWithdrawHeight)], "_")
71-
72-
73-func collectBalanceKey (address) = makeString([address, "balance"], "_")
74-
75-
76-func collectBalanceKeyWithFee (address) = makeString([address, "balance_with_fee"], "_")
77-
78-
79-func usdtToUsdnAssetError () = throw("To swap USDT to USDN you need attach payment in USDT")
80-
81-
82-func usdnToUsdtAssetError () = throw("To swap USDN to USDT you need attach payment in USDN")
83-
84-
85-func usdtToUsdnLowLimitError () = throw((("you can swap at least " + toString((minUsdt() / decimalPartUSDT))) + " tokens"))
86-
87-
88-func abs (n) = if ((0 > n))
89- then (n * -1)
90- else n
91-
92-
93-func getWithoutFeeWithdraw (amount,balanceWithoutFee) = min([amount, balanceWithoutFee])
94-
95-
96-func getListElementOrDefault (list,index,default) = if ((size(list) > index))
97- then list[index]
98- else default
99-
100-
101-func currentWithdrawals (address,amount) = {
102- let balanceKey = collectBalanceKey(address)
103- let balanceWithFeeKey = collectBalanceKeyWithFee(address)
104- let currentClientBalance = valueOrElse(getInteger(this, balanceKey), 0)
105- let currentClientBalanceWithFee = valueOrElse(getInteger(this, balanceWithFeeKey), 0)
106- let userBalance = (currentClientBalance + currentClientBalanceWithFee)
107- if (if ((amount > userBalance))
108- then true
109- else (minUsdn() > amount))
110- then throw("Swap amount fail, amount is to small or to big.")
111- else {
112- let toWithdrawWithoutFee = getWithoutFeeWithdraw(amount, currentClientBalance)
113- let toWithdrawWithFee = (amount - toWithdrawWithoutFee)
114- let fee = ((toWithdrawWithFee / 100) * value(getInteger(keyWithdrawFee())))
115-[toWithdrawWithoutFee, toWithdrawWithFee, fee]
116- }
117- }
118-
119-
12030 func mustManager (i) = {
12131 let pd = throw("Permission denied")
12232 match managerPublicKeyOrUnit() {
13242 throw("Match error")
13343 }
13444 }
135-
136-
137-@Callable(i)
138-func setWithdrawDelay (newWithdrawDelay) = {
139- let checkCaller = mustManager(i)
140- if ((checkCaller == checkCaller))
141- then [IntegerEntry(keyWithdrawDelay(), newWithdrawDelay)]
142- else throw("Strict value is not equal to itself.")
143- }
144-
145-
146-
147-@Callable(i)
148-func setMinimalAmountToSwapUsdt (newMinimalAmount) = {
149- let checkCaller = mustManager(i)
150- if ((checkCaller == checkCaller))
151- then [IntegerEntry(keyMinimalAmountToSwapUsdt(), newMinimalAmount)]
152- else throw("Strict value is not equal to itself.")
153- }
154-
155-
156-
157-@Callable(i)
158-func setMinimalAmountToSwapUsdn (newMinimalAmount) = {
159- let checkCaller = mustManager(i)
160- if ((checkCaller == checkCaller))
161- then [IntegerEntry(keyMinimalAmountToSwapUsdn(), newMinimalAmount)]
162- else throw("Strict value is not equal to itself.")
163- }
164-
165-
166-
167-@Callable(i)
168-func setWithdrawFee (newFee) = {
169- let checkCaller = mustManager(i)
170- if ((checkCaller == checkCaller))
171- then [IntegerEntry(keyWithdrawFee(), newFee)]
172- else throw("Strict value is not equal to itself.")
173- }
174-
175-
176-
177-@Callable(i)
178-func setDepositFee (newFee) = {
179- let checkCaller = mustManager(i)
180- if ((checkCaller == checkCaller))
181- then [IntegerEntry(keyDepositFee(), newFee)]
182- else throw("Strict value is not equal to itself.")
183- }
184-
185-
186-
187-@Callable(i)
188-func constructor (usdtAssetId,usdnAssetId) = {
189- let checkCaller = mustManager(i)
190- if ((checkCaller == checkCaller))
191- then [StringEntry(keyUsdtAssetId(), usdtAssetId), StringEntry(keyUsdnAssetId(), usdnAssetId)]
192- else throw("Strict value is not equal to itself.")
193- }
194-
195-
196-
197-@Callable(invoke)
198-func swapUSDTtoUSDN () = {
199- let balanceKey = collectBalanceKeyWithFee(toString(invoke.caller))
200- let payment = value(invoke.payments[0])
201- if ((payment.assetId != usdt()))
202- then usdtToUsdnAssetError()
203- else {
204- let amount = payment.amount
205- let fee = ((amount / 100) * value(getInteger(keyDepositFee())))
206- let currentClientBalanceUSDT = valueOrElse(getInteger(this, balanceKey), 0)
207- if ((minUsdt() > amount))
208- then usdtToUsdnLowLimitError()
209- else [IntegerEntry(balanceKey, (currentClientBalanceUSDT + amount)), ScriptTransfer(invoke.caller, (amount - fee), usdn())]
210- }
211- }
212-
213-
214-
215-@Callable(invoke)
216-func initializationUSDNtoUSDTswap () = {
217- let payment = value(invoke.payments[0])
218- let address = toString(invoke.caller)
219- if ((payment.assetId != usdn()))
220- then usdnToUsdtAssetError()
221- else {
222- let amount = payment.amount
223- let balanceKey = collectBalanceKey(address)
224- let balanceWithFeeKey = collectBalanceKeyWithFee(address)
225- let currentClientBalance = valueOrElse(getInteger(this, balanceKey), 0)
226- let currentClientBalanceWithFee = valueOrElse(getInteger(this, balanceWithFeeKey), 0)
227- let userBalance = (currentClientBalance + currentClientBalanceWithFee)
228- let data = currentWithdrawals(toString(invoke.caller), amount)
229- let toWithdrawWithoutFee = valueOrErrorMessage(data[0], "Wrong 'currentWithdrawals' method!")
230- let toWithdrawWithFee = valueOrErrorMessage(data[1], "Wrong 'currentWithdrawals' method!")
231- let fee = valueOrErrorMessage(data[2], "Wrong 'currentWithdrawals' method!")
232- let total = ((toWithdrawWithFee + toWithdrawWithoutFee) - fee)
233- let allowToWithDrawHeight = (height + withdrawDelay())
234- if (isDefined(getString(this, collectKey(toString(invoke.caller), amount, allowToWithDrawHeight))))
235- then throw("You have already started withdrawal process, wait next block.")
236- else [IntegerEntry(balanceKey, (currentClientBalance - toWithdrawWithoutFee)), IntegerEntry(balanceWithFeeKey, (currentClientBalanceWithFee - toWithdrawWithFee)), StringEntry(collectKey(toString(invoke.caller), amount, allowToWithDrawHeight), makeString(["not_withdrawn", toString((amount - fee))], "_"))]
237- }
238- }
239-
240-
241-
242-@Callable(invoke)
243-func swapUSDNtoUSDT (amount,heightInKey) = {
244- let key = collectKey(toString(invoke.caller), amount, heightInKey)
245- let withdrawnInfo = valueOrErrorMessage(getString(this, key), ((("This key doesn't exists " + key) + " at address ") + toString(this)))
246- let toWithdraw = getListElementOrDefault(split(withdrawnInfo, "_"), 2, toString(amount))
247- if (if ((height >= heightInKey))
248- then contains(withdrawnInfo, "not_withdrawn")
249- else false)
250- then [DeleteEntry(key), ScriptTransfer(invoke.caller, valueOrErrorMessage(parseInt(toWithdraw), "Wrong withdraw data!"), usdt())]
251- else throw((("Withdrawal is possible after " + toString(heightInKey)) + " height or you have already withdrawn USDT."))
252- }
253-
25445
25546
25647 @Callable(i)
Full:
OldNewDifferences
1-{-# STDLIB_VERSION 6 #-}
1+{-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let decimalPartUSDN = 1000000
5-
6-let decimalPartUSDT = 1000000
7-
8-func keyWithdrawDelay () = "%s__withdrawDelay"
9-
10-
11-func withdrawDelay () = value(getInteger(keyWithdrawDelay()))
12-
13-
14-func keyMinimalAmountToSwapUsdt () = "%s__minimalAmountToSwapUsdt"
15-
16-
17-func keyMinimalAmountToSwapUsdn () = "%s__minimalAmountToSwapUsdn"
18-
19-
20-func minUsdt () = value(getInteger(keyMinimalAmountToSwapUsdt()))
21-
22-
23-func minUsdn () = value(getInteger(keyMinimalAmountToSwapUsdn()))
24-
25-
264 func keyManagerPublicKey () = "%s__managerPublicKey"
275
286
297 func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey"
30-
31-
32-func keyUsdtAssetId () = "%s__usdtAssetId"
33-
34-
35-func keyUsdnAssetId () = "%s__usdnAssetId"
36-
37-
38-func keyDepositFee () = "%s__depositFee"
39-
40-
41-func keyWithdrawFee () = "%s__withdrawFee"
42-
43-
44-func usdt () = fromBase58String(value(getString(keyUsdtAssetId())))
45-
46-
47-func usdn () = fromBase58String(value(getString(keyUsdnAssetId())))
488
499
5010 func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) {
5111 case s: String =>
5212 fromBase58String(s)
5313 case _: Unit =>
5414 unit
5515 case _ =>
5616 throw("Match error")
5717 }
5818
5919
6020 func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) {
6121 case s: String =>
6222 fromBase58String(s)
6323 case _: Unit =>
6424 unit
6525 case _ =>
6626 throw("Match error")
6727 }
6828
6929
70-func collectKey (address,amountToSwapInKey,allowToWithdrawHeight) = makeString([address, "WITHDRAW", toString(amountToSwapInKey), "HEIGHT", toString(allowToWithdrawHeight)], "_")
71-
72-
73-func collectBalanceKey (address) = makeString([address, "balance"], "_")
74-
75-
76-func collectBalanceKeyWithFee (address) = makeString([address, "balance_with_fee"], "_")
77-
78-
79-func usdtToUsdnAssetError () = throw("To swap USDT to USDN you need attach payment in USDT")
80-
81-
82-func usdnToUsdtAssetError () = throw("To swap USDN to USDT you need attach payment in USDN")
83-
84-
85-func usdtToUsdnLowLimitError () = throw((("you can swap at least " + toString((minUsdt() / decimalPartUSDT))) + " tokens"))
86-
87-
88-func abs (n) = if ((0 > n))
89- then (n * -1)
90- else n
91-
92-
93-func getWithoutFeeWithdraw (amount,balanceWithoutFee) = min([amount, balanceWithoutFee])
94-
95-
96-func getListElementOrDefault (list,index,default) = if ((size(list) > index))
97- then list[index]
98- else default
99-
100-
101-func currentWithdrawals (address,amount) = {
102- let balanceKey = collectBalanceKey(address)
103- let balanceWithFeeKey = collectBalanceKeyWithFee(address)
104- let currentClientBalance = valueOrElse(getInteger(this, balanceKey), 0)
105- let currentClientBalanceWithFee = valueOrElse(getInteger(this, balanceWithFeeKey), 0)
106- let userBalance = (currentClientBalance + currentClientBalanceWithFee)
107- if (if ((amount > userBalance))
108- then true
109- else (minUsdn() > amount))
110- then throw("Swap amount fail, amount is to small or to big.")
111- else {
112- let toWithdrawWithoutFee = getWithoutFeeWithdraw(amount, currentClientBalance)
113- let toWithdrawWithFee = (amount - toWithdrawWithoutFee)
114- let fee = ((toWithdrawWithFee / 100) * value(getInteger(keyWithdrawFee())))
115-[toWithdrawWithoutFee, toWithdrawWithFee, fee]
116- }
117- }
118-
119-
12030 func mustManager (i) = {
12131 let pd = throw("Permission denied")
12232 match managerPublicKeyOrUnit() {
12333 case pk: ByteVector =>
12434 if ((i.callerPublicKey == pk))
12535 then true
12636 else pd
12737 case _: Unit =>
12838 if ((i.caller == this))
12939 then true
13040 else pd
13141 case _ =>
13242 throw("Match error")
13343 }
13444 }
135-
136-
137-@Callable(i)
138-func setWithdrawDelay (newWithdrawDelay) = {
139- let checkCaller = mustManager(i)
140- if ((checkCaller == checkCaller))
141- then [IntegerEntry(keyWithdrawDelay(), newWithdrawDelay)]
142- else throw("Strict value is not equal to itself.")
143- }
144-
145-
146-
147-@Callable(i)
148-func setMinimalAmountToSwapUsdt (newMinimalAmount) = {
149- let checkCaller = mustManager(i)
150- if ((checkCaller == checkCaller))
151- then [IntegerEntry(keyMinimalAmountToSwapUsdt(), newMinimalAmount)]
152- else throw("Strict value is not equal to itself.")
153- }
154-
155-
156-
157-@Callable(i)
158-func setMinimalAmountToSwapUsdn (newMinimalAmount) = {
159- let checkCaller = mustManager(i)
160- if ((checkCaller == checkCaller))
161- then [IntegerEntry(keyMinimalAmountToSwapUsdn(), newMinimalAmount)]
162- else throw("Strict value is not equal to itself.")
163- }
164-
165-
166-
167-@Callable(i)
168-func setWithdrawFee (newFee) = {
169- let checkCaller = mustManager(i)
170- if ((checkCaller == checkCaller))
171- then [IntegerEntry(keyWithdrawFee(), newFee)]
172- else throw("Strict value is not equal to itself.")
173- }
174-
175-
176-
177-@Callable(i)
178-func setDepositFee (newFee) = {
179- let checkCaller = mustManager(i)
180- if ((checkCaller == checkCaller))
181- then [IntegerEntry(keyDepositFee(), newFee)]
182- else throw("Strict value is not equal to itself.")
183- }
184-
185-
186-
187-@Callable(i)
188-func constructor (usdtAssetId,usdnAssetId) = {
189- let checkCaller = mustManager(i)
190- if ((checkCaller == checkCaller))
191- then [StringEntry(keyUsdtAssetId(), usdtAssetId), StringEntry(keyUsdnAssetId(), usdnAssetId)]
192- else throw("Strict value is not equal to itself.")
193- }
194-
195-
196-
197-@Callable(invoke)
198-func swapUSDTtoUSDN () = {
199- let balanceKey = collectBalanceKeyWithFee(toString(invoke.caller))
200- let payment = value(invoke.payments[0])
201- if ((payment.assetId != usdt()))
202- then usdtToUsdnAssetError()
203- else {
204- let amount = payment.amount
205- let fee = ((amount / 100) * value(getInteger(keyDepositFee())))
206- let currentClientBalanceUSDT = valueOrElse(getInteger(this, balanceKey), 0)
207- if ((minUsdt() > amount))
208- then usdtToUsdnLowLimitError()
209- else [IntegerEntry(balanceKey, (currentClientBalanceUSDT + amount)), ScriptTransfer(invoke.caller, (amount - fee), usdn())]
210- }
211- }
212-
213-
214-
215-@Callable(invoke)
216-func initializationUSDNtoUSDTswap () = {
217- let payment = value(invoke.payments[0])
218- let address = toString(invoke.caller)
219- if ((payment.assetId != usdn()))
220- then usdnToUsdtAssetError()
221- else {
222- let amount = payment.amount
223- let balanceKey = collectBalanceKey(address)
224- let balanceWithFeeKey = collectBalanceKeyWithFee(address)
225- let currentClientBalance = valueOrElse(getInteger(this, balanceKey), 0)
226- let currentClientBalanceWithFee = valueOrElse(getInteger(this, balanceWithFeeKey), 0)
227- let userBalance = (currentClientBalance + currentClientBalanceWithFee)
228- let data = currentWithdrawals(toString(invoke.caller), amount)
229- let toWithdrawWithoutFee = valueOrErrorMessage(data[0], "Wrong 'currentWithdrawals' method!")
230- let toWithdrawWithFee = valueOrErrorMessage(data[1], "Wrong 'currentWithdrawals' method!")
231- let fee = valueOrErrorMessage(data[2], "Wrong 'currentWithdrawals' method!")
232- let total = ((toWithdrawWithFee + toWithdrawWithoutFee) - fee)
233- let allowToWithDrawHeight = (height + withdrawDelay())
234- if (isDefined(getString(this, collectKey(toString(invoke.caller), amount, allowToWithDrawHeight))))
235- then throw("You have already started withdrawal process, wait next block.")
236- else [IntegerEntry(balanceKey, (currentClientBalance - toWithdrawWithoutFee)), IntegerEntry(balanceWithFeeKey, (currentClientBalanceWithFee - toWithdrawWithFee)), StringEntry(collectKey(toString(invoke.caller), amount, allowToWithDrawHeight), makeString(["not_withdrawn", toString((amount - fee))], "_"))]
237- }
238- }
239-
240-
241-
242-@Callable(invoke)
243-func swapUSDNtoUSDT (amount,heightInKey) = {
244- let key = collectKey(toString(invoke.caller), amount, heightInKey)
245- let withdrawnInfo = valueOrErrorMessage(getString(this, key), ((("This key doesn't exists " + key) + " at address ") + toString(this)))
246- let toWithdraw = getListElementOrDefault(split(withdrawnInfo, "_"), 2, toString(amount))
247- if (if ((height >= heightInKey))
248- then contains(withdrawnInfo, "not_withdrawn")
249- else false)
250- then [DeleteEntry(key), ScriptTransfer(invoke.caller, valueOrErrorMessage(parseInt(toWithdraw), "Wrong withdraw data!"), usdt())]
251- else throw((("Withdrawal is possible after " + toString(heightInKey)) + " height or you have already withdrawn USDT."))
252- }
253-
25445
25546
25647 @Callable(i)
25748 func setManager (pendingManagerPublicKey) = {
25849 let checkCaller = mustManager(i)
25950 if ((checkCaller == checkCaller))
26051 then {
26152 let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey)
26253 if ((checkManagerPublicKey == checkManagerPublicKey))
26354 then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)]
26455 else throw("Strict value is not equal to itself.")
26556 }
26657 else throw("Strict value is not equal to itself.")
26758 }
26859
26960
27061
27162 @Callable(i)
27263 func confirmManager () = {
27364 let pm = pendingManagerPublicKeyOrUnit()
27465 let hasPM = if (isDefined(pm))
27566 then true
27667 else throw("No pending manager")
27768 if ((hasPM == hasPM))
27869 then {
27970 let checkPM = if ((i.callerPublicKey == value(pm)))
28071 then true
28172 else throw("You are not pending manager")
28273 if ((checkPM == checkPM))
28374 then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())]
28475 else throw("Strict value is not equal to itself.")
28576 }
28677 else throw("Strict value is not equal to itself.")
28778 }
28879
28980
29081 @Verifier(tx)
29182 func verify () = {
29283 let targetPublicKey = match managerPublicKeyOrUnit() {
29384 case pk: ByteVector =>
29485 pk
29586 case _: Unit =>
29687 tx.senderPublicKey
29788 case _ =>
29889 throw("Match error")
29990 }
30091 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
30192 }
30293

github/deemru/w8io/873ac7e 
52.36 ms