tx · 4Sh1sWEgaRyo5KrvZiZhbGp6ri4p2j1sWLU9kjoYF89D

3Mzj8MyE3E3G55SLVE6Dgd6ew2uERLxiE4U:  -0.01300000 Waves

2022.07.20 13:15 [2147947] smart account 3Mzj8MyE3E3G55SLVE6Dgd6ew2uERLxiE4U > SELF 0.00000000 Waves

{ "type": 13, "id": "4Sh1sWEgaRyo5KrvZiZhbGp6ri4p2j1sWLU9kjoYF89D", "fee": 1300000, "feeAssetId": null, "timestamp": 1658312111926, "version": 1, "sender": "3Mzj8MyE3E3G55SLVE6Dgd6ew2uERLxiE4U", "senderPublicKey": "8E1ZoUTJyyA7ybXtP2NxUZKdAwvR1ruiQUxZD2bYJJMF", "proofs": [ "5fBZMLx3z2TntY1xNbKt9Mx9sarU4WGCCsRmsqsZnU9CPzhW3bD8FTgJa9FUncNN7p33sFfpVgBCEWtnYCZFmWqF" ], "script": "base64:BgIjCAISAwoBARIDCgEBEgQKAggIEgASABIECgIBARIDCgEIEgAaAA13aXRoZHJhd0RlbGF5ALQLAA9kZWNpbWFsUGFydFVTRE4AwIQ9AA9kZWNpbWFsUGFydFVTRFQAwIQ9ABdtaW5pbWFsQW1vdW50VG9Td2FwVVNEVAkAaAIAkE4FD2RlY2ltYWxQYXJ0VVNETgAXbWluaW1hbEFtb3VudFRvU3dhcFVTRE4JAGgCAJBOBQ9kZWNpbWFsUGFydFVTRFQBE2tleU1hbmFnZXJQdWJsaWNLZXkAAhQlc19fbWFuYWdlclB1YmxpY0tleQEaa2V5UGVuZGluZ01hbmFnZXJQdWJsaWNLZXkAAhslc19fcGVuZGluZ01hbmFnZXJQdWJsaWNLZXkBDmtleVVzZHRBc3NldElkAAIPJXNfX3VzZHRBc3NldElkAQ5rZXlVc2RuQXNzZXRJZAACDyVzX191c2RuQXNzZXRJZAENa2V5RGVwb3NpdEZlZQACDSVzX19kZXBvc2lGZWUBDmtleVdpdGhkcmF3RmVlAAIPJXNfX3dpdGhkcmF3RmVlAQR1c2R0AAkA2QQB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Status": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: GNg83bYGYeVzNGCTkkY5pfv9w4gmXSSSj9hstpHakDgi Next: v8PNEpxBnSPUFF8j2JDntX9weaDytHw4hfTaDYsJAja Diff:
OldNewDifferences
1717 func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey"
1818
1919
20-func keyUsdtAssetId () = "%s__USDT"
20+func keyUsdtAssetId () = "%s__usdtAssetId"
2121
2222
23-func keyUsdnAssetId () = "%s__USDN"
23+func keyUsdnAssetId () = "%s__usdnAssetId"
24+
25+
26+func keyDepositFee () = "%s__deposiFee"
27+
28+
29+func keyWithdrawFee () = "%s__withdrawFee"
30+
31+
32+func usdt () = fromBase58String(value(getString(keyUsdtAssetId())))
33+
34+
35+func usdn () = fromBase58String(value(getString(keyUsdnAssetId())))
2436
2537
2638 func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) {
8799 else {
88100 let toWithdrawWithoutFee = getWithoutFeeWithdraw(amount, currentClientBalance)
89101 let toWithdrawWithFee = (amount - toWithdrawWithoutFee)
90- let fee = ((toWithdrawWithFee / 100) * 2)
102+ let fee = ((toWithdrawWithFee / 100) * value(getInteger(keyWithdrawFee())))
91103 [toWithdrawWithoutFee, toWithdrawWithFee, fee]
92104 }
93105 }
111123
112124
113125 @Callable(i)
126+func setWithdrawFee (newFee) = {
127+ let checkCaller = mustManager(i)
128+ if ((checkCaller == checkCaller))
129+ then [IntegerEntry(keyWithdrawFee(), newFee)]
130+ else throw("Strict value is not equal to itself.")
131+ }
132+
133+
134+
135+@Callable(i)
136+func setDepositFee (newFee) = {
137+ let checkCaller = mustManager(i)
138+ if ((checkCaller == checkCaller))
139+ then [IntegerEntry(keyDepositFee(), newFee)]
140+ else throw("Strict value is not equal to itself.")
141+ }
142+
143+
144+
145+@Callable(i)
114146 func constructor (usdtAssetId,usdnAssetId) = {
115147 let checkCaller = mustManager(i)
116148 if ((checkCaller == checkCaller))
124156 func swapUSDTtoUSDN () = {
125157 let balanceKey = collectBalanceKeyWithFee(toString(invoke.caller))
126158 let payment = value(invoke.payments[0])
127- if ((payment.assetId != fromBase58String(keyUsdtAssetId())))
159+ if ((payment.assetId != usdt()))
128160 then usdtToUsdnAssetError()
129161 else {
130162 let amount = payment.amount
131- let fee = ((amount / 100) * 2)
163+ let fee = ((amount / 100) * value(getInteger(keyDepositFee())))
132164 let currentClientBalanceUSDT = valueOrElse(getInteger(this, balanceKey), 0)
133165 if ((minimalAmountToSwapUSDT > amount))
134166 then usdtToUsdnLowLimitError()
135- else [IntegerEntry(balanceKey, (currentClientBalanceUSDT + amount)), ScriptTransfer(invoke.caller, (amount - fee), fromBase58String(keyUsdnAssetId()))]
167+ else [IntegerEntry(balanceKey, (currentClientBalanceUSDT + amount)), ScriptTransfer(invoke.caller, (amount - fee), usdn())]
136168 }
137169 }
138170
142174 func initializationUSDNtoUSDTswap () = {
143175 let payment = value(invoke.payments[0])
144176 let address = toString(invoke.caller)
145- if ((payment.assetId != fromBase58String(keyUsdnAssetId())))
177+ if ((payment.assetId != usdn()))
146178 then usdnToUsdtAssetError()
147179 else {
148180 let amount = payment.amount
173205 if (if ((height >= heightInKey))
174206 then contains(withdrawnInfo, "not_withdrawn")
175207 else false)
176- then [DeleteEntry(key), ScriptTransfer(invoke.caller, valueOrErrorMessage(parseInt(toWithdraw), "Wrong withdraw data!"), fromBase58String(keyUsdtAssetId()))]
208+ then [DeleteEntry(key), ScriptTransfer(invoke.caller, valueOrErrorMessage(parseInt(toWithdraw), "Wrong withdraw data!"), usdt())]
177209 else throw((("Withdrawal is possible after " + toString(heightInKey)) + " height or you have already withdrawn USDT."))
178210 }
179211
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
20-func keyUsdtAssetId () = "%s__USDT"
20+func keyUsdtAssetId () = "%s__usdtAssetId"
2121
2222
23-func keyUsdnAssetId () = "%s__USDN"
23+func keyUsdnAssetId () = "%s__usdnAssetId"
24+
25+
26+func keyDepositFee () = "%s__deposiFee"
27+
28+
29+func keyWithdrawFee () = "%s__withdrawFee"
30+
31+
32+func usdt () = fromBase58String(value(getString(keyUsdtAssetId())))
33+
34+
35+func usdn () = fromBase58String(value(getString(keyUsdnAssetId())))
2436
2537
2638 func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) {
2739 case s: String =>
2840 fromBase58String(s)
2941 case _: Unit =>
3042 unit
3143 case _ =>
3244 throw("Match error")
3345 }
3446
3547
3648 func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) {
3749 case s: String =>
3850 fromBase58String(s)
3951 case _: Unit =>
4052 unit
4153 case _ =>
4254 throw("Match error")
4355 }
4456
4557
4658 func collectKey (address,amountToSwapInKey,allowToWithdrawHeight) = makeString([address, "WITHDRAW", toString(amountToSwapInKey), "HEIGHT", toString(allowToWithdrawHeight)], "_")
4759
4860
4961 func collectBalanceKey (address) = makeString([address, "balance"], "_")
5062
5163
5264 func collectBalanceKeyWithFee (address) = makeString([address, "balance_with_fee"], "_")
5365
5466
5567 func usdtToUsdnAssetError () = throw("To swap USDT to USDN you need attach payment in USDT")
5668
5769
5870 func usdnToUsdtAssetError () = throw("To swap USDN to USDT you need attach payment in USDN")
5971
6072
6173 func usdtToUsdnLowLimitError () = throw((("you can swap at least " + toString((minimalAmountToSwapUSDT / decimalPartUSDT))) + " tokens"))
6274
6375
6476 func abs (n) = if ((0 > n))
6577 then (n * -1)
6678 else n
6779
6880
6981 func getWithoutFeeWithdraw (amount,balanceWithoutFee) = min([amount, balanceWithoutFee])
7082
7183
7284 func getListElementOrDefault (list,index,default) = if ((size(list) > index))
7385 then list[index]
7486 else default
7587
7688
7789 func currentWithdrawals (address,amount) = {
7890 let balanceKey = collectBalanceKey(address)
7991 let balanceWithFeeKey = collectBalanceKeyWithFee(address)
8092 let currentClientBalance = valueOrElse(getInteger(this, balanceKey), 0)
8193 let currentClientBalanceWithFee = valueOrElse(getInteger(this, balanceWithFeeKey), 0)
8294 let userBalance = (currentClientBalance + currentClientBalanceWithFee)
8395 if (if ((amount > userBalance))
8496 then true
8597 else (minimalAmountToSwapUSDN > amount))
8698 then throw("Swap amount fail, amount is to small or to big.")
8799 else {
88100 let toWithdrawWithoutFee = getWithoutFeeWithdraw(amount, currentClientBalance)
89101 let toWithdrawWithFee = (amount - toWithdrawWithoutFee)
90- let fee = ((toWithdrawWithFee / 100) * 2)
102+ let fee = ((toWithdrawWithFee / 100) * value(getInteger(keyWithdrawFee())))
91103 [toWithdrawWithoutFee, toWithdrawWithFee, fee]
92104 }
93105 }
94106
95107
96108 func mustManager (i) = {
97109 let pd = throw("Permission denied")
98110 match managerPublicKeyOrUnit() {
99111 case pk: ByteVector =>
100112 if ((i.callerPublicKey == pk))
101113 then true
102114 else pd
103115 case _: Unit =>
104116 if ((i.caller == this))
105117 then true
106118 else pd
107119 case _ =>
108120 throw("Match error")
109121 }
110122 }
111123
112124
113125 @Callable(i)
126+func setWithdrawFee (newFee) = {
127+ let checkCaller = mustManager(i)
128+ if ((checkCaller == checkCaller))
129+ then [IntegerEntry(keyWithdrawFee(), newFee)]
130+ else throw("Strict value is not equal to itself.")
131+ }
132+
133+
134+
135+@Callable(i)
136+func setDepositFee (newFee) = {
137+ let checkCaller = mustManager(i)
138+ if ((checkCaller == checkCaller))
139+ then [IntegerEntry(keyDepositFee(), newFee)]
140+ else throw("Strict value is not equal to itself.")
141+ }
142+
143+
144+
145+@Callable(i)
114146 func constructor (usdtAssetId,usdnAssetId) = {
115147 let checkCaller = mustManager(i)
116148 if ((checkCaller == checkCaller))
117149 then [StringEntry(keyUsdtAssetId(), usdtAssetId), StringEntry(keyUsdnAssetId(), usdnAssetId)]
118150 else throw("Strict value is not equal to itself.")
119151 }
120152
121153
122154
123155 @Callable(invoke)
124156 func swapUSDTtoUSDN () = {
125157 let balanceKey = collectBalanceKeyWithFee(toString(invoke.caller))
126158 let payment = value(invoke.payments[0])
127- if ((payment.assetId != fromBase58String(keyUsdtAssetId())))
159+ if ((payment.assetId != usdt()))
128160 then usdtToUsdnAssetError()
129161 else {
130162 let amount = payment.amount
131- let fee = ((amount / 100) * 2)
163+ let fee = ((amount / 100) * value(getInteger(keyDepositFee())))
132164 let currentClientBalanceUSDT = valueOrElse(getInteger(this, balanceKey), 0)
133165 if ((minimalAmountToSwapUSDT > amount))
134166 then usdtToUsdnLowLimitError()
135- else [IntegerEntry(balanceKey, (currentClientBalanceUSDT + amount)), ScriptTransfer(invoke.caller, (amount - fee), fromBase58String(keyUsdnAssetId()))]
167+ else [IntegerEntry(balanceKey, (currentClientBalanceUSDT + amount)), ScriptTransfer(invoke.caller, (amount - fee), usdn())]
136168 }
137169 }
138170
139171
140172
141173 @Callable(invoke)
142174 func initializationUSDNtoUSDTswap () = {
143175 let payment = value(invoke.payments[0])
144176 let address = toString(invoke.caller)
145- if ((payment.assetId != fromBase58String(keyUsdnAssetId())))
177+ if ((payment.assetId != usdn()))
146178 then usdnToUsdtAssetError()
147179 else {
148180 let amount = payment.amount
149181 let balanceKey = collectBalanceKey(address)
150182 let balanceWithFeeKey = collectBalanceKeyWithFee(address)
151183 let currentClientBalance = valueOrElse(getInteger(this, balanceKey), 0)
152184 let currentClientBalanceWithFee = valueOrElse(getInteger(this, balanceWithFeeKey), 0)
153185 let userBalance = (currentClientBalance + currentClientBalanceWithFee)
154186 let data = currentWithdrawals(toString(invoke.caller), amount)
155187 let toWithdrawWithoutFee = valueOrErrorMessage(data[0], "Wrong 'currentWithdrawals' method!")
156188 let toWithdrawWithFee = valueOrErrorMessage(data[1], "Wrong 'currentWithdrawals' method!")
157189 let fee = valueOrErrorMessage(data[2], "Wrong 'currentWithdrawals' method!")
158190 let total = ((toWithdrawWithFee + toWithdrawWithoutFee) - fee)
159191 let allowToWithDrawHeight = (height + withdrawDelay)
160192 if (isDefined(getString(this, collectKey(toString(invoke.caller), amount, allowToWithDrawHeight))))
161193 then throw("You have already started withdrawal process, wait next block.")
162194 else [IntegerEntry(balanceKey, (currentClientBalance - toWithdrawWithoutFee)), IntegerEntry(balanceWithFeeKey, (currentClientBalanceWithFee - toWithdrawWithFee)), StringEntry(collectKey(toString(invoke.caller), amount, allowToWithDrawHeight), makeString(["not_withdrawn", toString((amount - fee))], "_"))]
163195 }
164196 }
165197
166198
167199
168200 @Callable(invoke)
169201 func swapUSDNtoUSDT (amount,heightInKey) = {
170202 let key = collectKey(toString(invoke.caller), amount, heightInKey)
171203 let withdrawnInfo = valueOrErrorMessage(getString(this, key), ((("This key doesn't exists " + key) + " at address ") + toString(this)))
172204 let toWithdraw = getListElementOrDefault(split(withdrawnInfo, "_"), 2, toString(amount))
173205 if (if ((height >= heightInKey))
174206 then contains(withdrawnInfo, "not_withdrawn")
175207 else false)
176- then [DeleteEntry(key), ScriptTransfer(invoke.caller, valueOrErrorMessage(parseInt(toWithdraw), "Wrong withdraw data!"), fromBase58String(keyUsdtAssetId()))]
208+ then [DeleteEntry(key), ScriptTransfer(invoke.caller, valueOrErrorMessage(parseInt(toWithdraw), "Wrong withdraw data!"), usdt())]
177209 else throw((("Withdrawal is possible after " + toString(heightInKey)) + " height or you have already withdrawn USDT."))
178210 }
179211
180212
181213
182214 @Callable(i)
183215 func setManager (pendingManagerPublicKey) = {
184216 let checkCaller = mustManager(i)
185217 if ((checkCaller == checkCaller))
186218 then {
187219 let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey)
188220 if ((checkManagerPublicKey == checkManagerPublicKey))
189221 then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)]
190222 else throw("Strict value is not equal to itself.")
191223 }
192224 else throw("Strict value is not equal to itself.")
193225 }
194226
195227
196228
197229 @Callable(i)
198230 func confirmManager () = {
199231 let pm = pendingManagerPublicKeyOrUnit()
200232 let hasPM = if (isDefined(pm))
201233 then true
202234 else throw("No pending manager")
203235 if ((hasPM == hasPM))
204236 then {
205237 let checkPM = if ((i.callerPublicKey == value(pm)))
206238 then true
207239 else throw("You are not pending manager")
208240 if ((checkPM == checkPM))
209241 then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())]
210242 else throw("Strict value is not equal to itself.")
211243 }
212244 else throw("Strict value is not equal to itself.")
213245 }
214246
215247
216248 @Verifier(tx)
217249 func verify () = {
218250 let targetPublicKey = match managerPublicKeyOrUnit() {
219251 case pk: ByteVector =>
220252 pk
221253 case _: Unit =>
222254 tx.senderPublicKey
223255 case _ =>
224256 throw("Match error")
225257 }
226258 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
227259 }
228260

github/deemru/w8io/026f985 
47.15 ms