tx · 3mrufDkoHKzzESv7NXcZSGk5zhWC6qoV8if8Etj8mGBi 3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq: -0.01300000 Waves 2023.02.13 09:08 [2447450] smart account 3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq > SELF 0.00000000 Waves
{ "type": 13, "id": "3mrufDkoHKzzESv7NXcZSGk5zhWC6qoV8if8Etj8mGBi", "fee": 1300000, "feeAssetId": null, "timestamp": 1676268561783, "version": 2, "chainId": 84, "sender": "3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq", "senderPublicKey": "2u2wYYcVBQv43Cc71zkhHPPitkqgg6dqTZ3nUMvYJ1uq", "proofs": [ "2TfFnuAkT8XN3B5CHxCFX9MS1oeipCCd4UrHMi5d2cnMquL2Ht34q6bxCchEh64cGwFWqoenQ3ukzZ66xYavD5Zb" ], "script": "base64:BgIXCAISBQoDAQgIEgUKAwEICBIDCgEIEgAWAANTRVACAl9fAAhmZWVTY2FsZQkAtgIBAIDC1y8BD2dldFN0cmluZ09yRmFpbAEDa2V5CQETdmFsdWVPckVycm9yTWVzc2FnZQIJAJ0IAgUEdGhpcwUDa2V5CQCsAgICFU5vIGRhdGEgZm9yIHRoaXMua2V5PQUDa2V5AAxwb29sRGlzYWJsZWQJAAIBAg1Qb29sIGRpc2FibGVkAAxwb29sTm90RXhpc3QJAAIBAhFQb29sIGlzIG5vdCBleGlzdAAOc2xpcHBhZ2VUb29CaWcJAAIBAhNTbGlwcGFnZSBpcyB0b28gYmlnARNrZXlNYW5hZ2VyUHVibGljS2V5AAIUJXNfX21hbmFnZXJQdWJsaWNLZXkBGmtleVBlbmRpbmdNYW5hZ2VyUHVibGljS2V5AAIbJXNfX3BlbmRpbmdNYW5hZ2VyUHVibGljS2V5AQJmYwACEyVzX19mYWN0b3J5Q29udHJhY3QAD2ZhY3RvcnlDb250cmFjdAkBEUBleHRyTmF0aXZlKDEwNjIpAQkBD2dldFN0cmluZ09yRmFpbAEJ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9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAUPdGFyZ2V0UHVibGljS2V5g0zV9A==", "height": 2447450, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: HekPHHP92aciJwYgQwZ4f8i2kX6Kdj6oEyD72yEJ3DgS Next: ALnuBBV9sSqPtwwqrSwPmNEpknEHcjw3jb5QgSmSnuE8 Diff:
Old | New | Differences | |
---|---|---|---|
101 | 101 | let feePoolAmount = if ((toInt(feePoolAmountCalc) == 0)) | |
102 | 102 | then toBigInt(1) | |
103 | 103 | else feePoolAmountCalc | |
104 | - | let cleanAmountIn = ((toBigInt(amountIn) - feeProtocolAmount) - | |
104 | + | let cleanAmountIn = ((toBigInt(amountIn) - feeProtocolAmount) - feePoolAmount) | |
105 | 105 | let lpNonReverse = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetIn, assetOut], nil) | |
106 | 106 | let lpReverse = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetOut, assetIn], nil) | |
107 | - | let $ | |
107 | + | let $t031223625 = if ((lpNonReverse != unit)) | |
108 | 108 | then { | |
109 | 109 | let isReverse = false | |
110 | 110 | let pool = { | |
127 | 127 | $Tuple2(isReverse, pool) | |
128 | 128 | } | |
129 | 129 | else poolNotExist | |
130 | - | let isReverse = $ | |
131 | - | let pool = $ | |
130 | + | let isReverse = $t031223625._1 | |
131 | + | let pool = $t031223625._2 | |
132 | 132 | let poolStatus = { | |
133 | 133 | let @ = invoke(factoryContract, "getPoolStatusREADONLY", [pool], nil) | |
134 | 134 | if ($isInstanceOf(@, "Int")) | |
189 | 189 | then @ | |
190 | 190 | else unit | |
191 | 191 | } | |
192 | - | let $ | |
192 | + | let $t052305832 = if ((lpNonReverse != unit)) | |
193 | 193 | then { | |
194 | 194 | let isReverse = false | |
195 | 195 | let pool = { | |
212 | 212 | $Tuple2(isReverse, pool) | |
213 | 213 | } | |
214 | 214 | else throw(((("pool is not exist: assetIn=" + assetIn) + " assetOut=") + assetOut)) | |
215 | - | let isReverse = $ | |
216 | - | let pool = $ | |
215 | + | let isReverse = $t052305832._1 | |
216 | + | let pool = $t052305832._2 | |
217 | 217 | let poolStatus = { | |
218 | 218 | let @ = invoke(factoryContract, "getPoolStatusREADONLY", [pool], nil) | |
219 | 219 | if ($isInstanceOf(@, "Int")) |
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 | let feeScale = toBigInt(100000000) | |
7 | 7 | ||
8 | 8 | func getStringOrFail (key) = valueOrErrorMessage(getString(this, key), ("No data for this.key=" + key)) | |
9 | 9 | ||
10 | 10 | ||
11 | 11 | let poolDisabled = throw("Pool disabled") | |
12 | 12 | ||
13 | 13 | let poolNotExist = throw("Pool is not exist") | |
14 | 14 | ||
15 | 15 | let slippageTooBig = throw("Slippage is too big") | |
16 | 16 | ||
17 | 17 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
18 | 18 | ||
19 | 19 | ||
20 | 20 | func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey" | |
21 | 21 | ||
22 | 22 | ||
23 | 23 | func fc () = "%s__factoryContract" | |
24 | 24 | ||
25 | 25 | ||
26 | 26 | let factoryContract = addressFromStringValue(getStringOrFail(fc())) | |
27 | 27 | ||
28 | 28 | func protocolFee () = makeString(["%s", "protocolFee"], SEP) | |
29 | 29 | ||
30 | 30 | ||
31 | 31 | func poolFee () = makeString(["%s", "poolFee"], SEP) | |
32 | 32 | ||
33 | 33 | ||
34 | 34 | func getStringOrFailFromAddress (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
35 | 35 | ||
36 | 36 | ||
37 | 37 | let keyFeeCollectorAddress = "%s__feeCollectorAddress" | |
38 | 38 | ||
39 | 39 | let feeCollectorAddress = addressFromStringValue(getStringOrFailFromAddress(factoryContract, keyFeeCollectorAddress)) | |
40 | 40 | ||
41 | 41 | func asInt (val) = match val { | |
42 | 42 | case valInt: Int => | |
43 | 43 | valInt | |
44 | 44 | case _ => | |
45 | 45 | throw("fail to cast into Int") | |
46 | 46 | } | |
47 | 47 | ||
48 | 48 | ||
49 | 49 | func dataMappingPoolAssets (internalAmountAssetStr,internalPriceAssetStr) = makeString(["%d%d", toString(internalAmountAssetStr), toString(internalPriceAssetStr)], SEP) | |
50 | 50 | ||
51 | 51 | ||
52 | 52 | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
53 | 53 | case s: String => | |
54 | 54 | fromBase58String(s) | |
55 | 55 | case _: Unit => | |
56 | 56 | unit | |
57 | 57 | case _ => | |
58 | 58 | throw("Match error") | |
59 | 59 | } | |
60 | 60 | ||
61 | 61 | ||
62 | 62 | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
63 | 63 | case s: String => | |
64 | 64 | fromBase58String(s) | |
65 | 65 | case _: Unit => | |
66 | 66 | unit | |
67 | 67 | case _ => | |
68 | 68 | throw("Match error") | |
69 | 69 | } | |
70 | 70 | ||
71 | 71 | ||
72 | 72 | func isManager (i) = match managerPublicKeyOrUnit() { | |
73 | 73 | case pk: ByteVector => | |
74 | 74 | (i.callerPublicKey == pk) | |
75 | 75 | case _: Unit => | |
76 | 76 | (i.caller == this) | |
77 | 77 | case _ => | |
78 | 78 | throw("Match error") | |
79 | 79 | } | |
80 | 80 | ||
81 | 81 | ||
82 | 82 | func mustManager (i) = if (isManager(i)) | |
83 | 83 | then true | |
84 | 84 | else throw("permission denied") | |
85 | 85 | ||
86 | 86 | ||
87 | 87 | func getAccBalance (assetId) = if ((assetId == "WAVES")) | |
88 | 88 | then wavesBalance(this).available | |
89 | 89 | else assetBalance(this, fromBase58String(assetId)) | |
90 | 90 | ||
91 | 91 | ||
92 | 92 | @Callable(i) | |
93 | 93 | func swapCalculateREADONLY (amountIn,assetIn,assetOut) = { | |
94 | 94 | let prFee = value(getInteger(protocolFee())) | |
95 | 95 | let feeProtocolAmountCalc = fraction(toBigInt(amountIn), toBigInt(prFee), feeScale) | |
96 | 96 | let plFee = value(getInteger(poolFee())) | |
97 | 97 | let feePoolAmountCalc = fraction(toBigInt(amountIn), toBigInt(plFee), feeScale) | |
98 | 98 | let feeProtocolAmount = if ((toInt(feeProtocolAmountCalc) == 0)) | |
99 | 99 | then toBigInt(1) | |
100 | 100 | else feeProtocolAmountCalc | |
101 | 101 | let feePoolAmount = if ((toInt(feePoolAmountCalc) == 0)) | |
102 | 102 | then toBigInt(1) | |
103 | 103 | else feePoolAmountCalc | |
104 | - | let cleanAmountIn = ((toBigInt(amountIn) - feeProtocolAmount) - | |
104 | + | let cleanAmountIn = ((toBigInt(amountIn) - feeProtocolAmount) - feePoolAmount) | |
105 | 105 | let lpNonReverse = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetIn, assetOut], nil) | |
106 | 106 | let lpReverse = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetOut, assetIn], nil) | |
107 | - | let $ | |
107 | + | let $t031223625 = if ((lpNonReverse != unit)) | |
108 | 108 | then { | |
109 | 109 | let isReverse = false | |
110 | 110 | let pool = { | |
111 | 111 | let @ = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [lpNonReverse], nil) | |
112 | 112 | if ($isInstanceOf(@, "String")) | |
113 | 113 | then @ | |
114 | 114 | else throw(($getType(@) + " couldn't be cast to String")) | |
115 | 115 | } | |
116 | 116 | $Tuple2(isReverse, pool) | |
117 | 117 | } | |
118 | 118 | else if ((lpReverse != unit)) | |
119 | 119 | then { | |
120 | 120 | let isReverse = true | |
121 | 121 | let pool = { | |
122 | 122 | let @ = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [lpReverse], nil) | |
123 | 123 | if ($isInstanceOf(@, "String")) | |
124 | 124 | then @ | |
125 | 125 | else throw(($getType(@) + " couldn't be cast to String")) | |
126 | 126 | } | |
127 | 127 | $Tuple2(isReverse, pool) | |
128 | 128 | } | |
129 | 129 | else poolNotExist | |
130 | - | let isReverse = $ | |
131 | - | let pool = $ | |
130 | + | let isReverse = $t031223625._1 | |
131 | + | let pool = $t031223625._2 | |
132 | 132 | let poolStatus = { | |
133 | 133 | let @ = invoke(factoryContract, "getPoolStatusREADONLY", [pool], nil) | |
134 | 134 | if ($isInstanceOf(@, "Int")) | |
135 | 135 | then @ | |
136 | 136 | else throw(($getType(@) + " couldn't be cast to Int")) | |
137 | 137 | } | |
138 | 138 | let check = if ((poolStatus == 1)) | |
139 | 139 | then true | |
140 | 140 | else poolDisabled | |
141 | 141 | if ((check == check)) | |
142 | 142 | then { | |
143 | 143 | let poolAdr = addressFromStringValue(valueOrElse(pool, "")) | |
144 | 144 | let res = { | |
145 | 145 | let @ = invoke(poolAdr, "calculateAmountOutForSwapREADONLY", [toInt(cleanAmountIn), isReverse], nil) | |
146 | 146 | if ($isInstanceOf(@, "Int")) | |
147 | 147 | then @ | |
148 | 148 | else throw(($getType(@) + " couldn't be cast to Int")) | |
149 | 149 | } | |
150 | 150 | $Tuple2(nil, res) | |
151 | 151 | } | |
152 | 152 | else throw("Strict value is not equal to itself.") | |
153 | 153 | } | |
154 | 154 | ||
155 | 155 | ||
156 | 156 | ||
157 | 157 | @Callable(i) | |
158 | 158 | func swap (amountOutMin,assetOut,addressTo) = { | |
159 | 159 | let pmt = value(i.payments[0]) | |
160 | 160 | let assetIn = if ((pmt.assetId == unit)) | |
161 | 161 | then "WAVES" | |
162 | 162 | else toBase58String(value(pmt.assetId)) | |
163 | 163 | let amountIn = value(pmt.amount) | |
164 | 164 | let prFee = value(getInteger(protocolFee())) | |
165 | 165 | let feeProtocolAmountCalc = fraction(toBigInt(amountIn), toBigInt(prFee), feeScale) | |
166 | 166 | let plFee = value(getInteger(poolFee())) | |
167 | 167 | let feePoolAmountCalc = fraction(toBigInt(amountIn), toBigInt(plFee), feeScale) | |
168 | 168 | let feeProtocolAmount = if ((toInt(feeProtocolAmountCalc) == 0)) | |
169 | 169 | then toBigInt(1) | |
170 | 170 | else feeProtocolAmountCalc | |
171 | 171 | let feePoolAmount = if ((toInt(feePoolAmountCalc) == 0)) | |
172 | 172 | then toBigInt(1) | |
173 | 173 | else feePoolAmountCalc | |
174 | 174 | let cleanAmountIn = ((toBigInt(amountIn) - feeProtocolAmount) - feePoolAmount) | |
175 | 175 | let checks = [if ((size(i.payments) == 1)) | |
176 | 176 | then true | |
177 | 177 | else throw("exactly 1 payment are expected")] | |
178 | 178 | if ((checks == checks)) | |
179 | 179 | then { | |
180 | 180 | let lpNonReverse = { | |
181 | 181 | let @ = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetIn, assetOut], nil) | |
182 | 182 | if ($isInstanceOf(@, "String")) | |
183 | 183 | then @ | |
184 | 184 | else unit | |
185 | 185 | } | |
186 | 186 | let lpReverse = { | |
187 | 187 | let @ = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetOut, assetIn], nil) | |
188 | 188 | if ($isInstanceOf(@, "String")) | |
189 | 189 | then @ | |
190 | 190 | else unit | |
191 | 191 | } | |
192 | - | let $ | |
192 | + | let $t052305832 = if ((lpNonReverse != unit)) | |
193 | 193 | then { | |
194 | 194 | let isReverse = false | |
195 | 195 | let pool = { | |
196 | 196 | let @ = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [value(lpNonReverse)], nil) | |
197 | 197 | if ($isInstanceOf(@, "String")) | |
198 | 198 | then @ | |
199 | 199 | else throw(($getType(@) + " couldn't be cast to String")) | |
200 | 200 | } | |
201 | 201 | $Tuple2(isReverse, pool) | |
202 | 202 | } | |
203 | 203 | else if ((lpReverse != unit)) | |
204 | 204 | then { | |
205 | 205 | let isReverse = true | |
206 | 206 | let pool = { | |
207 | 207 | let @ = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [value(lpReverse)], nil) | |
208 | 208 | if ($isInstanceOf(@, "String")) | |
209 | 209 | then @ | |
210 | 210 | else throw(($getType(@) + " couldn't be cast to String")) | |
211 | 211 | } | |
212 | 212 | $Tuple2(isReverse, pool) | |
213 | 213 | } | |
214 | 214 | else throw(((("pool is not exist: assetIn=" + assetIn) + " assetOut=") + assetOut)) | |
215 | - | let isReverse = $ | |
216 | - | let pool = $ | |
215 | + | let isReverse = $t052305832._1 | |
216 | + | let pool = $t052305832._2 | |
217 | 217 | let poolStatus = { | |
218 | 218 | let @ = invoke(factoryContract, "getPoolStatusREADONLY", [pool], nil) | |
219 | 219 | if ($isInstanceOf(@, "Int")) | |
220 | 220 | then @ | |
221 | 221 | else throw(($getType(@) + " couldn't be cast to Int")) | |
222 | 222 | } | |
223 | 223 | let check = if ((poolStatus == 1)) | |
224 | 224 | then true | |
225 | 225 | else poolDisabled | |
226 | 226 | if ((check == check)) | |
227 | 227 | then { | |
228 | 228 | let poolAdr = addressFromStringValue(pool) | |
229 | 229 | let assetInAttachedPayment = if ((assetIn == "WAVES")) | |
230 | 230 | then unit | |
231 | 231 | else fromBase58String(assetIn) | |
232 | 232 | let totalGetRaw = { | |
233 | 233 | let @ = invoke(poolAdr, "calculateAmountOutForSwapAndSendTokens", [toInt(cleanAmountIn), isReverse, amountOutMin, addressTo], [AttachedPayment(assetInAttachedPayment, toInt(cleanAmountIn))]) | |
234 | 234 | if ($isInstanceOf(@, "Int")) | |
235 | 235 | then @ | |
236 | 236 | else throw(($getType(@) + " couldn't be cast to Int")) | |
237 | 237 | } | |
238 | 238 | $Tuple2([ScriptTransfer(feeCollectorAddress, toInt(feeProtocolAmount), assetInAttachedPayment), ScriptTransfer(poolAdr, toInt(feePoolAmount), assetInAttachedPayment)], totalGetRaw) | |
239 | 239 | } | |
240 | 240 | else throw("Strict value is not equal to itself.") | |
241 | 241 | } | |
242 | 242 | else throw("Strict value is not equal to itself.") | |
243 | 243 | } | |
244 | 244 | ||
245 | 245 | ||
246 | 246 | ||
247 | 247 | @Callable(i) | |
248 | 248 | func setManager (pendingManagerPublicKey) = { | |
249 | 249 | let checkCaller = mustManager(i) | |
250 | 250 | if ((checkCaller == checkCaller)) | |
251 | 251 | then { | |
252 | 252 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
253 | 253 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
254 | 254 | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
255 | 255 | else throw("Strict value is not equal to itself.") | |
256 | 256 | } | |
257 | 257 | else throw("Strict value is not equal to itself.") | |
258 | 258 | } | |
259 | 259 | ||
260 | 260 | ||
261 | 261 | ||
262 | 262 | @Callable(i) | |
263 | 263 | func confirmManager () = { | |
264 | 264 | let pm = pendingManagerPublicKeyOrUnit() | |
265 | 265 | let hasPM = if (isDefined(pm)) | |
266 | 266 | then true | |
267 | 267 | else throw("no pending manager") | |
268 | 268 | if ((hasPM == hasPM)) | |
269 | 269 | then { | |
270 | 270 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
271 | 271 | then true | |
272 | 272 | else throw("you are not pending manager") | |
273 | 273 | if ((checkPM == checkPM)) | |
274 | 274 | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
275 | 275 | else throw("Strict value is not equal to itself.") | |
276 | 276 | } | |
277 | 277 | else throw("Strict value is not equal to itself.") | |
278 | 278 | } | |
279 | 279 | ||
280 | 280 | ||
281 | 281 | @Verifier(tx) | |
282 | 282 | func verify () = { | |
283 | 283 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
284 | 284 | case pk: ByteVector => | |
285 | 285 | pk | |
286 | 286 | case _: Unit => | |
287 | 287 | tx.senderPublicKey | |
288 | 288 | case _ => | |
289 | 289 | throw("Match error") | |
290 | 290 | } | |
291 | 291 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
292 | 292 | } | |
293 | 293 |
github/deemru/w8io/026f985 56.48 ms ◑