tx · 7bpWDhjCWCfPPE3ABFxMTJ2nGJZiKhmBH82UGDeox8W5

3MvXnAcEtL9x3i499UcvTQZPufrT5ZZUEd5:  -0.01300000 Waves

2023.05.02 09:53 [2559809] smart account 3MvXnAcEtL9x3i499UcvTQZPufrT5ZZUEd5 > SELF 0.00000000 Waves

{ "type": 13, "id": "7bpWDhjCWCfPPE3ABFxMTJ2nGJZiKhmBH82UGDeox8W5", "fee": 1300000, "feeAssetId": null, "timestamp": 1683010447109, "version": 2, "chainId": 84, "sender": "3MvXnAcEtL9x3i499UcvTQZPufrT5ZZUEd5", "senderPublicKey": "GSAhb4fdky75LiCZ4p4DDK4rmWpmsgGBg1ZVdtPfmRES", "proofs": [ "2vEab2pS58SPtGHCqSateRHLiWuT3Jmf5huhWGDAxyTtxkFUC1yfF9Qkv6buTLkFwH3NNWexW6jzjtdPxUVhE3o5" ], "script": "base64:BgKuBwgCEgoKCAgIAQEBAQEBEgMKAQgSAwoBCBIFCgMICAESBAoCCAgiA1NFUCITa2V5TWFuYWdlclB1YmxpY0tleSIWa2V5TWFuYWdlclZhdWx0QWRkcmVzcyIXZ2V0TWFuYWdlckFkZHJlc3NPckZhaWwiEGtleVdpdGhkcmF3RGVsYXkiBmFzc2V0QSIGYXNzZXRCIhVrZXlEZXBvc2l0RmVlUGVybWlsbGUiFmtleVdpdGhkcmF3RmVlUGVybWlsbGUiE2tleU1pbkFtb3VudERlcG9zaXQiE2tleUFzc2V0c1BhaXJTdGF0dXMiFGtleU1pbkFtb3VudFdpdGhkcmF3IgprZXlCYWxhbmNlIgt1c2VyQWRkcmVzcyIba2V5VG90YWxGZWVDb2xsZWN0ZWREZXBvc2l0IhRrZXlQcm9jZXNzSW5Qcm9ncmVzcyILaGVpZ2h0SW5LZXkiDmtleVByb2Nlc3NEb25lIhZtYW5hZ2VyUHVibGljS2V5T3JVbml0IhNtYW5hZ2VyVmF1bHRBZGRyZXNzIgckbWF0Y2gwIgFzIgttdXN0TWFuYWdlciIBaSICcG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JpcHRUcmFuc2ZlcgMIBQF4BmNhbGxlcgUCYWEFAVIFA25pbAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgF4AQt3aXRoZHJhd0ZlZQIBZgFnBAFKCQEBdwEFAXgDCQAAAgUBSgUBSgQCYWUJAQt2YWx1ZU9yRWxzZQIJAJ8IAQkBAW8CBQFmBQFnAAAEAmFmCQDZBAEJAQV2YWx1ZQEFAWYJAMwIAgkBDEludGVnZXJFbnRyeQIJAQFvAgUBZgUBZwAACQDMCAIJAQ5TY3JpcHRUcmFuc2ZlcgMIBQF4BmNhbGxlcgUCYWUFAmFmBQNuaWwJAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4BAmFnAQJhaAAEAmFpBAF1CQEBcwADCQABAgUBdQIKQnl0ZVZlY3RvcgQBegUBdQUBegMJAAECBQF1AgRVbml0CAUCYWcPc2VuZGVyUHVibGljS2V5CQACAQILTWF0Y2ggZXJyb3IJAPQDAwgFAmFnCWJvZHlCeXRlcwkAkQMCCAUCYWcGcHJvb2ZzAAAFAmFp2xPD2g==", "height": 2559809, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 84gnY6HC6ERQjGTitcx2UbHM8DgAh1LMJJ85xiRB2b6t Next: none Diff:
OldNewDifferences
66 func keyManagerPublicKey () = "%s__managerPublicKey"
77
88
9-func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey"
9+func keyManagerVaultAddress () = "%s__managerVaultAddress"
10+
11+
12+func getManagerAddressOrFail () = addressFromStringValue(getStringValue(keyManagerVaultAddress()))
1013
1114
1215 func keyWithdrawDelay (assetA,assetB) = makeString(["%s%s%s", "withdrawDelay", assetA, assetB], SEP)
3942 func keyProcessDone (userAddress,assetA,assetB,heightInKey) = makeString(["%s%s%s%s%s%d", "withdrawProcess", "done", userAddress, assetA, assetB, toString(heightInKey)], SEP)
4043
4144
42-func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) {
43- case s: String =>
44- fromBase58String(s)
45- case _: Unit =>
46- unit
47- case _ =>
48- throw("Match error")
49-}
50-
51-
52-func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) {
53- case s: String =>
54- fromBase58String(s)
55- case _: Unit =>
56- unit
57- case _ =>
58- throw("Match error")
59-}
45+func managerPublicKeyOrUnit () = {
46+ let managerVaultAddress = getManagerAddressOrFail()
47+ match getString(managerVaultAddress, keyManagerPublicKey()) {
48+ case s: String =>
49+ fromBase58String(s)
50+ case _: Unit =>
51+ unit
52+ case _ =>
53+ throw("Match error")
54+ }
55+ }
6056
6157
6258 func mustManager (i) = {
204200 }
205201
206202
207-
208-@Callable(i)
209-func setManager (pendingManagerPublicKey) = {
210- let checkCaller = mustManager(i)
211- if ((checkCaller == checkCaller))
212- then {
213- let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey)
214- if ((checkManagerPublicKey == checkManagerPublicKey))
215- then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)]
216- else throw("Strict value is not equal to itself.")
217- }
218- else throw("Strict value is not equal to itself.")
219- }
220-
221-
222-
223-@Callable(i)
224-func confirmManager () = {
225- let pm = pendingManagerPublicKeyOrUnit()
226- let hasPM = if (isDefined(pm))
227- then true
228- else throwErr("No pending manager.")
229- if ((hasPM == hasPM))
230- then {
231- let checkPM = if ((i.callerPublicKey == value(pm)))
232- then true
233- else throwErr("You are not pending manager.")
234- if ((checkPM == checkPM))
235- then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())]
236- else throw("Strict value is not equal to itself.")
237- }
238- else throw("Strict value is not equal to itself.")
239- }
240-
241-
242203 @Verifier(tx)
243204 func verify () = {
244205 let targetPublicKey = match managerPublicKeyOrUnit() {
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let SEP = "__"
55
66 func keyManagerPublicKey () = "%s__managerPublicKey"
77
88
9-func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey"
9+func keyManagerVaultAddress () = "%s__managerVaultAddress"
10+
11+
12+func getManagerAddressOrFail () = addressFromStringValue(getStringValue(keyManagerVaultAddress()))
1013
1114
1215 func keyWithdrawDelay (assetA,assetB) = makeString(["%s%s%s", "withdrawDelay", assetA, assetB], SEP)
1316
1417
1518 func keyDepositFeePermille (assetA,assetB) = makeString(["%s%s%s", "depositFeePermille", assetA, assetB], SEP)
1619
1720
1821 func keyWithdrawFeePermille (assetA,assetB) = makeString(["%s%s%s", "withdrawFeePermille", assetA, assetB], SEP)
1922
2023
2124 func keyMinAmountDeposit (assetA,assetB) = makeString(["%s%s%s", "minAmountDeposit", assetA, assetB], SEP)
2225
2326
2427 func keyAssetsPairStatus (assetA,assetB) = makeString(["%s%s%s", "assetsPairStatus", assetA, assetB], SEP)
2528
2629
2730 func keyMinAmountWithdraw (assetA,assetB) = makeString(["%s%s%s", "minAmountWithdraw", assetA, assetB], SEP)
2831
2932
3033 func keyBalance (assetA,assetB,userAddress) = makeString(["%s%s%s%s", "balance", assetA, assetB, userAddress], SEP)
3134
3235
3336 func keyTotalFeeCollectedDeposit (assetA,assetB) = makeString(["%s%s%s%s", "totalFeeCollected", "deposit", assetA, assetB], SEP)
3437
3538
3639 func keyProcessInProgress (userAddress,assetA,assetB,heightInKey) = makeString(["%s%s%s%s%s%d", "withdrawProcess", "inProgress", userAddress, assetA, assetB, toString(heightInKey)], SEP)
3740
3841
3942 func keyProcessDone (userAddress,assetA,assetB,heightInKey) = makeString(["%s%s%s%s%s%d", "withdrawProcess", "done", userAddress, assetA, assetB, toString(heightInKey)], SEP)
4043
4144
42-func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) {
43- case s: String =>
44- fromBase58String(s)
45- case _: Unit =>
46- unit
47- case _ =>
48- throw("Match error")
49-}
50-
51-
52-func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) {
53- case s: String =>
54- fromBase58String(s)
55- case _: Unit =>
56- unit
57- case _ =>
58- throw("Match error")
59-}
45+func managerPublicKeyOrUnit () = {
46+ let managerVaultAddress = getManagerAddressOrFail()
47+ match getString(managerVaultAddress, keyManagerPublicKey()) {
48+ case s: String =>
49+ fromBase58String(s)
50+ case _: Unit =>
51+ unit
52+ case _ =>
53+ throw("Match error")
54+ }
55+ }
6056
6157
6258 func mustManager (i) = {
6359 let pd = throw("Permission denied.")
6460 match managerPublicKeyOrUnit() {
6561 case pk: ByteVector =>
6662 if ((i.callerPublicKey == pk))
6763 then true
6864 else pd
6965 case _: Unit =>
7066 if ((i.caller == this))
7167 then true
7268 else pd
7369 case _ =>
7470 throw("Match error")
7571 }
7672 }
7773
7874
7975 func fmtErr (msg) = makeString(["otc_multiasset.ride:", msg], " ")
8076
8177
8278 func throwErr (msg) = throw(fmtErr(msg))
8379
8480
8581 @Callable(i)
8682 func registerAsset (assetA,assetB,withdrawDelay,depositFee,withdrawFee,minAmountDeposit,minAmountWithdraw,pairStatus) = {
8783 let checkCaller = mustManager(i)
8884 if ((checkCaller == checkCaller))
8985 then {
9086 let withdrawDelayKey = keyWithdrawDelay(assetA, assetB)
9187 let depositFeePermilleKey = keyDepositFeePermille(assetA, assetB)
9288 let withdrawFeePermilleKey = keyWithdrawFeePermille(assetA, assetB)
9389 let minAmountDepositKey = keyMinAmountDeposit(assetA, assetB)
9490 let minAmountWithdrawKey = keyMinAmountWithdraw(assetA, assetB)
9591 let pairStatusKey = keyAssetsPairStatus(assetA, assetB)
9692 [IntegerEntry(withdrawDelayKey, withdrawDelay), IntegerEntry(depositFeePermilleKey, depositFee), IntegerEntry(withdrawFeePermilleKey, withdrawFee), IntegerEntry(minAmountDepositKey, minAmountDeposit), IntegerEntry(minAmountWithdrawKey, minAmountWithdraw), IntegerEntry(pairStatusKey, pairStatus)]
9793 }
9894 else throw("Strict value is not equal to itself.")
9995 }
10096
10197
10298
10399 @Callable(i)
104100 func swapAssetsAToB (assetB) = {
105101 let payment = value(i.payments[0])
106102 let assetA = toBase58String(value(payment.assetId))
107103 let asset = fromBase58String(value(assetB))
108104 let userAddress = toString(i.caller)
109105 let minAmountDeposit = valueOrErrorMessage(getInteger(keyMinAmountDeposit(assetA, assetB)), fmtErr("This asset pair does not exist."))
110106 let toDeposit = payment.amount
111107 let depositFee = valueOrErrorMessage(getInteger(keyDepositFeePermille(assetA, assetB)), fmtErr("The deposit fee for this pair of assets is not set."))
112108 let fee = ((toDeposit / 1000) * depositFee)
113109 let currentUserBalance = valueOrElse(getInteger(keyBalance(assetA, assetB, userAddress)), 0)
114110 let totalCommissions = valueOrElse(getInteger(keyTotalFeeCollectedDeposit(assetA, assetB)), 0)
115111 let pairStatus = valueOrErrorMessage(getInteger(keyAssetsPairStatus(assetA, assetB)), fmtErr("The asset pair status for this pair of assets is not set."))
116112 let checkPairStatus = if ((pairStatus == 0))
117113 then true
118114 else throwErr("The couple's deposit is blocked.")
119115 if ((checkPairStatus == checkPairStatus))
120116 then {
121117 let checkPayment = if ((toDeposit >= minAmountDeposit))
122118 then true
123119 else throwErr("The deposit amount is less than the minimum.")
124120 if ((checkPayment == checkPayment))
125121 then {
126122 let newBalance = ((currentUserBalance + toDeposit) - fee)
127123 let checkBalance = if ((newBalance > 0))
128124 then true
129125 else throwErr("The final balance is less than or equal to 0.")
130126 if ((checkBalance == checkBalance))
131127 then [IntegerEntry(keyBalance(assetA, assetB, userAddress), newBalance), IntegerEntry(keyTotalFeeCollectedDeposit(assetA, assetB), (totalCommissions + fee)), ScriptTransfer(i.caller, (toDeposit - fee), asset)]
132128 else throw("Strict value is not equal to itself.")
133129 }
134130 else throw("Strict value is not equal to itself.")
135131 }
136132 else throw("Strict value is not equal to itself.")
137133 }
138134
139135
140136
141137 @Callable(i)
142138 func initializationSwapAssetsBToA (assetA) = {
143139 let payment = value(i.payments[0])
144140 let toWithdraw = payment.amount
145141 let assetB = toBase58String(value(payment.assetId))
146142 let userAddress = toString(i.caller)
147143 let minAmountWithdraw = valueOrErrorMessage(getInteger(keyMinAmountWithdraw(assetA, assetB)), fmtErr("The minimum withdrawal amount for this pair of assets is not set."))
148144 let assetLockHeight = (height + valueOrErrorMessage(getInteger(keyWithdrawDelay(assetA, assetB)), fmtErr("Withdrawal delay is not set for the specified pair.")))
149145 let currentUserBalance = valueOrErrorMessage(getInteger(keyBalance(assetA, assetB, userAddress)), fmtErr("This user balance does not exist."))
150146 let totalCommissions = valueOrElse(getInteger(keyTotalFeeCollectedDeposit(assetA, assetB)), 0)
151147 let withdrawFeePermilleKey = keyWithdrawFeePermille(assetA, assetB)
152148 let withdrawFee = valueOrErrorMessage(getInteger(withdrawFeePermilleKey), fmtErr("The withdrawal fee for this pair of assets is not set."))
153149 let fee = ((toWithdraw / 1000) * withdrawFee)
154150 let newBalance = (currentUserBalance - toWithdraw)
155151 let checkBalance = if ((newBalance >= 0))
156152 then true
157153 else throwErr("Swap amount fail, amount is to small.")
158154 if ((checkBalance == checkBalance))
159155 then {
160156 let checkPayment = if ((toWithdraw >= minAmountWithdraw))
161157 then true
162158 else throwErr("The withdraw amount is less than the minimum.")
163159 if ((checkPayment == checkPayment))
164160 then {
165161 let checkProcessInProgress = if ((getInteger(keyProcessInProgress(userAddress, assetA, assetB, assetLockHeight)) == unit))
166162 then true
167163 else throwErr("At this height, there is already an exchange of this pair.")
168164 if ((checkProcessInProgress == checkProcessInProgress))
169165 then [IntegerEntry(keyBalance(assetA, assetB, userAddress), newBalance), IntegerEntry(keyProcessInProgress(userAddress, assetA, assetB, assetLockHeight), (toWithdraw - fee)), IntegerEntry(keyTotalFeeCollectedDeposit(assetA, assetB), (totalCommissions + fee))]
170166 else throw("Strict value is not equal to itself.")
171167 }
172168 else throw("Strict value is not equal to itself.")
173169 }
174170 else throw("Strict value is not equal to itself.")
175171 }
176172
177173
178174
179175 @Callable(i)
180176 func withdrawAsset (assetA,assetB,heightInKey) = {
181177 let userAddress = toString(i.caller)
182178 let toWithdraw = valueOrErrorMessage(getInteger(keyProcessInProgress(userAddress, assetA, assetB, heightInKey)), fmtErr("At this height, withdraw was not initialized with this pair of assets."))
183179 let asset = fromBase58String(value(assetA))
184180 let checkHeight = if ((height >= heightInKey))
185181 then true
186182 else throwErr((("Withdrawal is possible after " + toString(heightInKey)) + " height or you have already withdrawn."))
187183 if ((checkHeight == checkHeight))
188184 then [DeleteEntry(keyProcessInProgress(userAddress, assetA, assetB, heightInKey)), IntegerEntry(keyProcessDone(userAddress, assetA, assetB, heightInKey), toWithdraw), ScriptTransfer(i.caller, toWithdraw, asset)]
189185 else throw("Strict value is not equal to itself.")
190186 }
191187
192188
193189
194190 @Callable(i)
195191 func withdrawFee (assetA,assetB) = {
196192 let checkCaller = mustManager(i)
197193 if ((checkCaller == checkCaller))
198194 then {
199195 let toWithdrawA = valueOrElse(getInteger(keyTotalFeeCollectedDeposit(assetA, assetB)), 0)
200196 let withdrawAssetA = fromBase58String(value(assetA))
201197 [IntegerEntry(keyTotalFeeCollectedDeposit(assetA, assetB), 0), ScriptTransfer(i.caller, toWithdrawA, withdrawAssetA)]
202198 }
203199 else throw("Strict value is not equal to itself.")
204200 }
205201
206202
207-
208-@Callable(i)
209-func setManager (pendingManagerPublicKey) = {
210- let checkCaller = mustManager(i)
211- if ((checkCaller == checkCaller))
212- then {
213- let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey)
214- if ((checkManagerPublicKey == checkManagerPublicKey))
215- then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)]
216- else throw("Strict value is not equal to itself.")
217- }
218- else throw("Strict value is not equal to itself.")
219- }
220-
221-
222-
223-@Callable(i)
224-func confirmManager () = {
225- let pm = pendingManagerPublicKeyOrUnit()
226- let hasPM = if (isDefined(pm))
227- then true
228- else throwErr("No pending manager.")
229- if ((hasPM == hasPM))
230- then {
231- let checkPM = if ((i.callerPublicKey == value(pm)))
232- then true
233- else throwErr("You are not pending manager.")
234- if ((checkPM == checkPM))
235- then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())]
236- else throw("Strict value is not equal to itself.")
237- }
238- else throw("Strict value is not equal to itself.")
239- }
240-
241-
242203 @Verifier(tx)
243204 func verify () = {
244205 let targetPublicKey = match managerPublicKeyOrUnit() {
245206 case pk: ByteVector =>
246207 pk
247208 case _: Unit =>
248209 tx.senderPublicKey
249210 case _ =>
250211 throw("Match error")
251212 }
252213 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
253214 }
254215

github/deemru/w8io/169f3d6 
59.49 ms