tx · EnqXRqANmnt62P53CMiTdAJxoruTeZQ4BmtHH972dng1

3N4Ph9WAuB4cPRsTbeicm8T6Pqr9vS88EjT:  -0.00500000 Waves

2023.03.20 10:02 [2498004] smart account 3N4Ph9WAuB4cPRsTbeicm8T6Pqr9vS88EjT > SELF 0.00000000 Waves

{ "type": 13, "id": "EnqXRqANmnt62P53CMiTdAJxoruTeZQ4BmtHH972dng1", "fee": 500000, "feeAssetId": null, "timestamp": 1679295768934, "version": 2, "chainId": 84, "sender": "3N4Ph9WAuB4cPRsTbeicm8T6Pqr9vS88EjT", "senderPublicKey": "ETecocSPYjiwv1GLwr7mcAMPpBjfWaK95CSKoJckSnzn", "proofs": [ "4uAywYQt1BwKVHhWdfpAsXigGShG9h1iEfsZngigW2teGGtEFuDb9MkuUfjbjrRS8EhMGEmC3Vy53rVLdsWfA34k" ], "script": null, "height": 2498004, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 6WSuRsL3SQyeCd7zUYAK7ooaAEGUSB1GTRvnBS3UV2D5 Next: 9kZe6t8M4Kq8aX6aCQHW3bDkiMpnFcYr4rrvCc7tpZZo Full:
OldNewDifferences
1-{-# STDLIB_VERSION 6 #-}
2-{-# SCRIPT_TYPE ACCOUNT #-}
3-{-# CONTENT_TYPE DAPP #-}
4-let SEP = "__"
5-
6-func keyManagerPublicKey () = "%s__managerPublicKey"
7-
8-
9-func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey"
10-
11-
12-func keyWithdrawDelay (assetA,assetB) = makeString(["%s%s%s", "withdrawDelay", assetA, assetB], SEP)
13-
14-
15-func keyDepositFeePermille (assetA,assetB) = makeString(["%s%s%s", "depositFeePermille", assetA, assetB], SEP)
16-
17-
18-func keyWithdrawFeePermille (assetA,assetB) = makeString(["%s%s%s", "withdrawFeePermille", assetA, assetB], SEP)
19-
20-
21-func keyMinAmountDeposit (assetA,assetB) = makeString(["%s%s%s", "minAmountDeposit", assetA, assetB], SEP)
22-
23-
24-func keyAssetsPairStatus (assetA,assetB) = makeString(["%s%s%s", "assetsPairStatus", assetA, assetB], SEP)
25-
26-
27-func keyMinAmountWithdraw (assetA,assetB) = makeString(["%s%s%s", "minAmountWithdraw", assetA, assetB], SEP)
28-
29-
30-func keyBalance (assetA,assetB,userAddress) = makeString(["%s%s%s%s", "balance", assetA, assetB, userAddress], SEP)
31-
32-
33-func keyTotalFeeCollectedDeposit (assetA,assetB) = makeString(["%s%s%s%s", "totalFeeCollected", "deposit", assetA, assetB], SEP)
34-
35-
36-func keyProcessInProgress (userAddress,assetA,assetB,heightInKey) = makeString(["%s%s%s%s%s%d", "withdrawProcess", "inProgress", userAddress, assetA, assetB, toString(heightInKey)], SEP)
37-
38-
39-func keyProcessDone (userAddress,assetA,assetB,heightInKey) = makeString(["%s%s%s%s%s%d", "withdrawProcess", "done", userAddress, assetA, assetB, toString(heightInKey)], SEP)
40-
41-
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-}
60-
61-
62-func mustManager (i) = {
63- let pd = throw("Permission denied.")
64- match managerPublicKeyOrUnit() {
65- case pk: ByteVector =>
66- if ((i.callerPublicKey == pk))
67- then true
68- else pd
69- case _: Unit =>
70- if ((i.caller == this))
71- then true
72- else pd
73- case _ =>
74- throw("Match error")
75- }
76- }
77-
78-
79-func fmtErr (msg) = makeString(["otc_multiasset.ride:", msg], " ")
80-
81-
82-func throwErr (msg) = throw(fmtErr(msg))
83-
84-
85-@Callable(i)
86-func registerAsset (assetA,assetB,withdrawDelay,depositFee,withdrawFee,minAmountDeposit,minAmountWithdraw,pairStatus) = {
87- let checkCaller = mustManager(i)
88- if ((checkCaller == checkCaller))
89- then {
90- let withdrawDelayKey = keyWithdrawDelay(assetA, assetB)
91- let depositFeePermilleKey = keyDepositFeePermille(assetA, assetB)
92- let withdrawFeePermilleKey = keyWithdrawFeePermille(assetA, assetB)
93- let minAmountDepositKey = keyMinAmountDeposit(assetA, assetB)
94- let minAmountWithdrawKey = keyMinAmountWithdraw(assetA, assetB)
95- let pairStatusKey = keyAssetsPairStatus(assetA, assetB)
96-[IntegerEntry(withdrawDelayKey, withdrawDelay), IntegerEntry(depositFeePermilleKey, depositFee), IntegerEntry(withdrawFeePermilleKey, withdrawFee), IntegerEntry(minAmountDepositKey, minAmountDeposit), IntegerEntry(minAmountWithdrawKey, minAmountWithdraw), IntegerEntry(pairStatusKey, pairStatus)]
97- }
98- else throw("Strict value is not equal to itself.")
99- }
100-
101-
102-
103-@Callable(i)
104-func swapAssetsAToB (assetB) = {
105- let payment = value(i.payments[0])
106- let assetA = toBase58String(value(payment.assetId))
107- let asset = fromBase58String(value(assetB))
108- let userAddress = toString(i.caller)
109- let minAmountDeposit = valueOrErrorMessage(getInteger(keyMinAmountDeposit(assetA, assetB)), fmtErr("This asset pair does not exist."))
110- let toDeposit = payment.amount
111- let depositFee = valueOrErrorMessage(getInteger(keyDepositFeePermille(assetA, assetB)), fmtErr("The deposit fee for this pair of assets is not set."))
112- let fee = ((toDeposit / 1000) * depositFee)
113- let currentUserBalance = valueOrElse(getInteger(keyBalance(assetA, assetB, userAddress)), 0)
114- let totalCommissions = valueOrElse(getInteger(keyTotalFeeCollectedDeposit(assetA, assetB)), 0)
115- let pairStatus = valueOrErrorMessage(getInteger(keyAssetsPairStatus(assetA, assetB)), fmtErr("The asset pair status for this pair of assets is not set."))
116- let checkPairStatus = if ((pairStatus == 0))
117- then true
118- else throwErr("The couple's deposit is blocked.")
119- if ((checkPairStatus == checkPairStatus))
120- then {
121- let checkPayment = if ((toDeposit >= minAmountDeposit))
122- then true
123- else throwErr("The deposit amount is less than the minimum.")
124- if ((checkPayment == checkPayment))
125- then {
126- let newBalance = ((currentUserBalance + toDeposit) - fee)
127- let checkBalance = if ((newBalance > 0))
128- then true
129- else throwErr("The final balance is less than or equal to 0.")
130- if ((checkBalance == checkBalance))
131- then [IntegerEntry(keyBalance(assetA, assetB, userAddress), newBalance), IntegerEntry(keyTotalFeeCollectedDeposit(assetA, assetB), (totalCommissions + fee)), ScriptTransfer(i.caller, (toDeposit - fee), asset)]
132- else throw("Strict value is not equal to itself.")
133- }
134- else throw("Strict value is not equal to itself.")
135- }
136- else throw("Strict value is not equal to itself.")
137- }
138-
139-
140-
141-@Callable(i)
142-func initializationSwapAssetsBToA (assetA) = {
143- let payment = value(i.payments[0])
144- let toWithdraw = payment.amount
145- let assetB = toBase58String(value(payment.assetId))
146- let userAddress = toString(i.caller)
147- let minAmountWithdraw = valueOrErrorMessage(getInteger(keyMinAmountWithdraw(assetA, assetB)), fmtErr("The minimum withdrawal amount for this pair of assets is not set."))
148- let assetLockHeight = (height + valueOrErrorMessage(getInteger(keyWithdrawDelay(assetA, assetB)), fmtErr("Withdrawal delay is not set for the specified pair.")))
149- let currentUserBalance = valueOrErrorMessage(getInteger(keyBalance(assetA, assetB, userAddress)), fmtErr("This user balance does not exist."))
150- let totalCommissions = valueOrElse(getInteger(keyTotalFeeCollectedDeposit(assetA, assetB)), 0)
151- let withdrawFeePermilleKey = keyWithdrawFeePermille(assetA, assetB)
152- let withdrawFee = valueOrErrorMessage(getInteger(withdrawFeePermilleKey), fmtErr("The withdrawal fee for this pair of assets is not set."))
153- let fee = ((toWithdraw / 1000) * withdrawFee)
154- let newBalance = (currentUserBalance - toWithdraw)
155- let checkBalance = if ((newBalance >= 0))
156- then true
157- else throwErr("Swap amount fail, amount is to small.")
158- if ((checkBalance == checkBalance))
159- then {
160- let checkPayment = if ((toWithdraw >= minAmountWithdraw))
161- then true
162- else throwErr("The withdraw amount is less than the minimum.")
163- if ((checkPayment == checkPayment))
164- then {
165- let checkProcessInProgress = if ((getInteger(keyProcessInProgress(userAddress, assetA, assetB, assetLockHeight)) == unit))
166- then true
167- else throwErr("At this height, there is already an exchange of this pair.")
168- if ((checkProcessInProgress == checkProcessInProgress))
169- then [IntegerEntry(keyBalance(assetA, assetB, userAddress), newBalance), IntegerEntry(keyProcessInProgress(userAddress, assetA, assetB, assetLockHeight), (toWithdraw - fee)), IntegerEntry(keyTotalFeeCollectedDeposit(assetA, assetB), (totalCommissions + fee))]
170- else throw("Strict value is not equal to itself.")
171- }
172- else throw("Strict value is not equal to itself.")
173- }
174- else throw("Strict value is not equal to itself.")
175- }
176-
177-
178-
179-@Callable(i)
180-func withdrawAsset (assetA,assetB,heightInKey) = {
181- let userAddress = toString(i.caller)
182- let toWithdraw = valueOrErrorMessage(getInteger(keyProcessInProgress(userAddress, assetA, assetB, heightInKey)), fmtErr("At this height, withdraw was not initialized with this pair of assets."))
183- let asset = fromBase58String(value(assetA))
184- let checkHeight = if ((height >= heightInKey))
185- then true
186- else throwErr((("Withdrawal is possible after " + toString(heightInKey)) + " height or you have already withdrawn."))
187- if ((checkHeight == checkHeight))
188- then [DeleteEntry(keyProcessInProgress(userAddress, assetA, assetB, heightInKey)), IntegerEntry(keyProcessDone(userAddress, assetA, assetB, heightInKey), toWithdraw), ScriptTransfer(i.caller, toWithdraw, asset)]
189- else throw("Strict value is not equal to itself.")
190- }
191-
192-
193-
194-@Callable(i)
195-func withdrawFee (assetA,assetB) = {
196- let checkCaller = mustManager(i)
197- if ((checkCaller == checkCaller))
198- then {
199- let toWithdrawA = valueOrElse(getInteger(keyTotalFeeCollectedDeposit(assetA, assetB)), 0)
200- let withdrawAssetA = fromBase58String(value(assetA))
201-[IntegerEntry(keyTotalFeeCollectedDeposit(assetA, assetB), 0), ScriptTransfer(i.caller, toWithdrawA, withdrawAssetA)]
202- }
203- else throw("Strict value is not equal to itself.")
204- }
205-
206-
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-
242-@Verifier(tx)
243-func verify () = {
244- let targetPublicKey = match managerPublicKeyOrUnit() {
245- case pk: ByteVector =>
246- pk
247- case _: Unit =>
248- tx.senderPublicKey
249- case _ =>
250- throw("Match error")
251- }
252- sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
253- }
254-
1+# no script

github/deemru/w8io/169f3d6 
32.42 ms