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