tx · 3V18Ah8VfcL3jsdija7PcSaYeWDpdnwjD9f5pvLwqyCY

3N5DUGD1Pwp7PDbT95caYuGsZoX6r3zFLBN:  -0.01300000 Waves

2023.05.10 13:15 [2571655] smart account 3N5DUGD1Pwp7PDbT95caYuGsZoX6r3zFLBN > SELF 0.00000000 Waves

{ "type": 13, "id": "3V18Ah8VfcL3jsdija7PcSaYeWDpdnwjD9f5pvLwqyCY", "fee": 1300000, "feeAssetId": null, "timestamp": 1683713776942, "version": 2, "chainId": 84, "sender": "3N5DUGD1Pwp7PDbT95caYuGsZoX6r3zFLBN", "senderPublicKey": "2oPK8ZcQp2MAGDK7eL3Nd2PukBG1CWU3M2e3JqmC1m3g", "proofs": [ "CNJyh7KszJmc5VSVdQd5cVoC3pQmihDAJMbfwtEXcySsvpvGiechXFd8f5N4NgVPqdx7Jn1zTydvQptmzkKayyC" ], "script": "base64:BgKzBwgCEgoKCAgIAQEBAQEBEgMKAQgSAwoBCBIFCgMICAESBAoCCAgiA1NFUCITa2V5TWFuYWdlclB1YmxpY0tleSIWa2V5TWFuYWdlclZhdWx0QWRkcmVzcyIcZ2V0TWFuYWdlclZhdWx0QWRkcmVzc09yVGhpcyIHJG1hdGNoMCIBcyIQa2V5V2l0aGRyYXdEZWxheSIGYXNzZXRBIgZhc3NldEIiFWtleURlcG9zaXRGZWVQZXJtaWxsZSIWa2V5V2l0aGRyYXdGZWVQZXJtaWxsZSITa2V5TWluQW1vdW50RGVwb3NpdCITa2V5QXNzZXRzUGFpclN0YXR1cyIUa2V5TWluQW1vdW50V2l0aGRyYXciCmtleUJhbGFuY2UiC3VzZXJBZGRyZXNzIhtrZXlUb3RhbEZlZUNvbGxlY3RlZERlcG9zaXQiFGtleVByb2Nlc3NJblByb2dyZXNzIgtoZWlnaHRJbktleSIOa2V5UHJvY2Vzc0RvbmUiFm1hbmFnZXJQdWJsaWNLZXlPclVuaXQiE21hbmFnZXJWYXVsdEFkZHJlc3MiC211c3RNYW5hZ2VyIgFpIg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Y2FsbGVyBQJhYQUBUgUDbmlsCQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAXgBC3dpdGhkcmF3RmVlAgFoAWkEAUoJAQF3AQUBeAMJAAACBQFKBQFKBAJhZQkBC3ZhbHVlT3JFbHNlAgkAnwgBCQEBcQIFAWgFAWkAAAQCYWYJANkEAQkBBXZhbHVlAQUBaAkAzAgCCQEMSW50ZWdlckVudHJ5AgkBAXECBQFoBQFpAAAJAMwIAgkBDlNjcmlwdFRyYW5zZmVyAwgFAXgGY2FsbGVyBQJhZQUCYWYFA25pbAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgECYWcBAmFoAAQCYWkEAWUJAQF1AAMJAAECBQFlAgpCeXRlVmVjdG9yBAF6BQFlBQF6AwkAAQIFAWUCBFVuaXQIBQJhZw9zZW5kZXJQdWJsaWNLZXkJAAIBAgtNYXRjaCBlcnJvcgkA9AMDCAUCYWcJYm9keUJ5dGVzCQCRAwIIBQJhZwZwcm9vZnMAAAUCYWlDMecp", "height": 2571655, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: J5PRGpthwVJyTMa4HWDbKujLuckEJaRDYF5fHtohXyNi Next: none Diff:
OldNewDifferences
99 func keyManagerVaultAddress () = "%s__managerVaultAddress"
1010
1111
12-func getManagerAddressOrFail () = addressFromStringValue(getStringValue(keyManagerVaultAddress()))
12+func getManagerVaultAddressOrThis () = match getString(keyManagerVaultAddress()) {
13+ case s: String =>
14+ addressFromStringValue(s)
15+ case _ =>
16+ this
17+}
1318
1419
1520 func keyWithdrawDelay (assetA,assetB) = makeString(["%s%s%s", "withdrawDelay", assetA, assetB], SEP)
4348
4449
4550 func managerPublicKeyOrUnit () = {
46- let managerVaultAddress = getManagerAddressOrFail()
51+ let managerVaultAddress = getManagerVaultAddressOrThis()
4752 match getString(managerVaultAddress, keyManagerPublicKey()) {
4853 case s: String =>
4954 fromBase58String(s)
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
99 func keyManagerVaultAddress () = "%s__managerVaultAddress"
1010
1111
12-func getManagerAddressOrFail () = addressFromStringValue(getStringValue(keyManagerVaultAddress()))
12+func getManagerVaultAddressOrThis () = match getString(keyManagerVaultAddress()) {
13+ case s: String =>
14+ addressFromStringValue(s)
15+ case _ =>
16+ this
17+}
1318
1419
1520 func keyWithdrawDelay (assetA,assetB) = makeString(["%s%s%s", "withdrawDelay", assetA, assetB], SEP)
1621
1722
1823 func keyDepositFeePermille (assetA,assetB) = makeString(["%s%s%s", "depositFeePermille", assetA, assetB], SEP)
1924
2025
2126 func keyWithdrawFeePermille (assetA,assetB) = makeString(["%s%s%s", "withdrawFeePermille", assetA, assetB], SEP)
2227
2328
2429 func keyMinAmountDeposit (assetA,assetB) = makeString(["%s%s%s", "minAmountDeposit", assetA, assetB], SEP)
2530
2631
2732 func keyAssetsPairStatus (assetA,assetB) = makeString(["%s%s%s", "assetsPairStatus", assetA, assetB], SEP)
2833
2934
3035 func keyMinAmountWithdraw (assetA,assetB) = makeString(["%s%s%s", "minAmountWithdraw", assetA, assetB], SEP)
3136
3237
3338 func keyBalance (assetA,assetB,userAddress) = makeString(["%s%s%s%s", "balance", assetA, assetB, userAddress], SEP)
3439
3540
3641 func keyTotalFeeCollectedDeposit (assetA,assetB) = makeString(["%s%s%s%s", "totalFeeCollected", "deposit", assetA, assetB], SEP)
3742
3843
3944 func keyProcessInProgress (userAddress,assetA,assetB,heightInKey) = makeString(["%s%s%s%s%s%d", "withdrawProcess", "inProgress", userAddress, assetA, assetB, toString(heightInKey)], SEP)
4045
4146
4247 func keyProcessDone (userAddress,assetA,assetB,heightInKey) = makeString(["%s%s%s%s%s%d", "withdrawProcess", "done", userAddress, assetA, assetB, toString(heightInKey)], SEP)
4348
4449
4550 func managerPublicKeyOrUnit () = {
46- let managerVaultAddress = getManagerAddressOrFail()
51+ let managerVaultAddress = getManagerVaultAddressOrThis()
4752 match getString(managerVaultAddress, keyManagerPublicKey()) {
4853 case s: String =>
4954 fromBase58String(s)
5055 case _: Unit =>
5156 unit
5257 case _ =>
5358 throw("Match error")
5459 }
5560 }
5661
5762
5863 func mustManager (i) = {
5964 let pd = throw("Permission denied.")
6065 match managerPublicKeyOrUnit() {
6166 case pk: ByteVector =>
6267 if ((i.callerPublicKey == pk))
6368 then true
6469 else pd
6570 case _: Unit =>
6671 if ((i.caller == this))
6772 then true
6873 else pd
6974 case _ =>
7075 throw("Match error")
7176 }
7277 }
7378
7479
7580 func fmtErr (msg) = makeString(["otc_multiasset.ride:", msg], " ")
7681
7782
7883 func throwErr (msg) = throw(fmtErr(msg))
7984
8085
8186 @Callable(i)
8287 func registerAsset (assetA,assetB,withdrawDelay,depositFee,withdrawFee,minAmountDeposit,minAmountWithdraw,pairStatus) = {
8388 let checkCaller = mustManager(i)
8489 if ((checkCaller == checkCaller))
8590 then {
8691 let withdrawDelayKey = keyWithdrawDelay(assetA, assetB)
8792 let depositFeePermilleKey = keyDepositFeePermille(assetA, assetB)
8893 let withdrawFeePermilleKey = keyWithdrawFeePermille(assetA, assetB)
8994 let minAmountDepositKey = keyMinAmountDeposit(assetA, assetB)
9095 let minAmountWithdrawKey = keyMinAmountWithdraw(assetA, assetB)
9196 let pairStatusKey = keyAssetsPairStatus(assetA, assetB)
9297 [IntegerEntry(withdrawDelayKey, withdrawDelay), IntegerEntry(depositFeePermilleKey, depositFee), IntegerEntry(withdrawFeePermilleKey, withdrawFee), IntegerEntry(minAmountDepositKey, minAmountDeposit), IntegerEntry(minAmountWithdrawKey, minAmountWithdraw), IntegerEntry(pairStatusKey, pairStatus)]
9398 }
9499 else throw("Strict value is not equal to itself.")
95100 }
96101
97102
98103
99104 @Callable(i)
100105 func swapAssetsAToB (assetB) = {
101106 let payment = value(i.payments[0])
102107 let assetA = toBase58String(value(payment.assetId))
103108 let asset = fromBase58String(value(assetB))
104109 let userAddress = toString(i.caller)
105110 let minAmountDeposit = valueOrErrorMessage(getInteger(keyMinAmountDeposit(assetA, assetB)), fmtErr("This asset pair does not exist."))
106111 let toDeposit = payment.amount
107112 let depositFee = valueOrErrorMessage(getInteger(keyDepositFeePermille(assetA, assetB)), fmtErr("The deposit fee for this pair of assets is not set."))
108113 let fee = ((toDeposit / 1000) * depositFee)
109114 let currentUserBalance = valueOrElse(getInteger(keyBalance(assetA, assetB, userAddress)), 0)
110115 let totalCommissions = valueOrElse(getInteger(keyTotalFeeCollectedDeposit(assetA, assetB)), 0)
111116 let pairStatus = valueOrErrorMessage(getInteger(keyAssetsPairStatus(assetA, assetB)), fmtErr("The asset pair status for this pair of assets is not set."))
112117 let checkPairStatus = if ((pairStatus == 0))
113118 then true
114119 else throwErr("The couple's deposit is blocked.")
115120 if ((checkPairStatus == checkPairStatus))
116121 then {
117122 let checkPayment = if ((toDeposit >= minAmountDeposit))
118123 then true
119124 else throwErr("The deposit amount is less than the minimum.")
120125 if ((checkPayment == checkPayment))
121126 then {
122127 let newBalance = ((currentUserBalance + toDeposit) - fee)
123128 let checkBalance = if ((newBalance > 0))
124129 then true
125130 else throwErr("The final balance is less than or equal to 0.")
126131 if ((checkBalance == checkBalance))
127132 then [IntegerEntry(keyBalance(assetA, assetB, userAddress), newBalance), IntegerEntry(keyTotalFeeCollectedDeposit(assetA, assetB), (totalCommissions + fee)), ScriptTransfer(i.caller, (toDeposit - fee), asset)]
128133 else throw("Strict value is not equal to itself.")
129134 }
130135 else throw("Strict value is not equal to itself.")
131136 }
132137 else throw("Strict value is not equal to itself.")
133138 }
134139
135140
136141
137142 @Callable(i)
138143 func initializationSwapAssetsBToA (assetA) = {
139144 let payment = value(i.payments[0])
140145 let toWithdraw = payment.amount
141146 let assetB = toBase58String(value(payment.assetId))
142147 let userAddress = toString(i.caller)
143148 let minAmountWithdraw = valueOrErrorMessage(getInteger(keyMinAmountWithdraw(assetA, assetB)), fmtErr("The minimum withdrawal amount for this pair of assets is not set."))
144149 let assetLockHeight = (height + valueOrErrorMessage(getInteger(keyWithdrawDelay(assetA, assetB)), fmtErr("Withdrawal delay is not set for the specified pair.")))
145150 let currentUserBalance = valueOrErrorMessage(getInteger(keyBalance(assetA, assetB, userAddress)), fmtErr("This user balance does not exist."))
146151 let totalCommissions = valueOrElse(getInteger(keyTotalFeeCollectedDeposit(assetA, assetB)), 0)
147152 let withdrawFeePermilleKey = keyWithdrawFeePermille(assetA, assetB)
148153 let withdrawFee = valueOrErrorMessage(getInteger(withdrawFeePermilleKey), fmtErr("The withdrawal fee for this pair of assets is not set."))
149154 let fee = ((toWithdraw / 1000) * withdrawFee)
150155 let newBalance = (currentUserBalance - toWithdraw)
151156 let checkBalance = if ((newBalance >= 0))
152157 then true
153158 else throwErr("Swap amount fail, amount is to small.")
154159 if ((checkBalance == checkBalance))
155160 then {
156161 let checkPayment = if ((toWithdraw >= minAmountWithdraw))
157162 then true
158163 else throwErr("The withdraw amount is less than the minimum.")
159164 if ((checkPayment == checkPayment))
160165 then {
161166 let checkProcessInProgress = if ((getInteger(keyProcessInProgress(userAddress, assetA, assetB, assetLockHeight)) == unit))
162167 then true
163168 else throwErr("At this height, there is already an exchange of this pair.")
164169 if ((checkProcessInProgress == checkProcessInProgress))
165170 then [IntegerEntry(keyBalance(assetA, assetB, userAddress), newBalance), IntegerEntry(keyProcessInProgress(userAddress, assetA, assetB, assetLockHeight), (toWithdraw - fee)), IntegerEntry(keyTotalFeeCollectedDeposit(assetA, assetB), (totalCommissions + fee))]
166171 else throw("Strict value is not equal to itself.")
167172 }
168173 else throw("Strict value is not equal to itself.")
169174 }
170175 else throw("Strict value is not equal to itself.")
171176 }
172177
173178
174179
175180 @Callable(i)
176181 func withdrawAsset (assetA,assetB,heightInKey) = {
177182 let userAddress = toString(i.caller)
178183 let toWithdraw = valueOrErrorMessage(getInteger(keyProcessInProgress(userAddress, assetA, assetB, heightInKey)), fmtErr("At this height, withdraw was not initialized with this pair of assets."))
179184 let asset = fromBase58String(value(assetA))
180185 let checkHeight = if ((height >= heightInKey))
181186 then true
182187 else throwErr((("Withdrawal is possible after " + toString(heightInKey)) + " height or you have already withdrawn."))
183188 if ((checkHeight == checkHeight))
184189 then [DeleteEntry(keyProcessInProgress(userAddress, assetA, assetB, heightInKey)), IntegerEntry(keyProcessDone(userAddress, assetA, assetB, heightInKey), toWithdraw), ScriptTransfer(i.caller, toWithdraw, asset)]
185190 else throw("Strict value is not equal to itself.")
186191 }
187192
188193
189194
190195 @Callable(i)
191196 func withdrawFee (assetA,assetB) = {
192197 let checkCaller = mustManager(i)
193198 if ((checkCaller == checkCaller))
194199 then {
195200 let toWithdrawA = valueOrElse(getInteger(keyTotalFeeCollectedDeposit(assetA, assetB)), 0)
196201 let withdrawAssetA = fromBase58String(value(assetA))
197202 [IntegerEntry(keyTotalFeeCollectedDeposit(assetA, assetB), 0), ScriptTransfer(i.caller, toWithdrawA, withdrawAssetA)]
198203 }
199204 else throw("Strict value is not equal to itself.")
200205 }
201206
202207
203208 @Verifier(tx)
204209 func verify () = {
205210 let targetPublicKey = match managerPublicKeyOrUnit() {
206211 case pk: ByteVector =>
207212 pk
208213 case _: Unit =>
209214 tx.senderPublicKey
210215 case _ =>
211216 throw("Match error")
212217 }
213218 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
214219 }
215220

github/deemru/w8io/026f985 
63.66 ms