tx · 2gECLJX4JF4fwzgw8zN7RgW1HCuFS8ZX5nXu7JDMRNTm 3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq: -0.01300000 Waves 2023.02.21 09:42 [2459056] smart account 3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq > SELF 0.00000000 Waves
{ "type": 13, "id": "2gECLJX4JF4fwzgw8zN7RgW1HCuFS8ZX5nXu7JDMRNTm", "fee": 1300000, "feeAssetId": null, "timestamp": 1676961744074, "version": 2, "chainId": 84, "sender": "3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq", "senderPublicKey": "2u2wYYcVBQv43Cc71zkhHPPitkqgg6dqTZ3nUMvYJ1uq", "proofs": [ "3aSucKD7JyFoqUJz5Tgfq1wh8xQ1LNHgveh371ad8LP1paAgZebmbCfELT2W4xQn9LYXdhRAADeMj8yTuDiiEvnj" ], "script": "base64:BgIXCAISBQoDAQgIEgUKAwEICBIDCgEIEgAXAANTRVACAl9fAAhmZWVTY2FsZQkAtgIBAIDC1y8BD2dldFN0cmluZ09yRmFpbAEDa2V5CQETdmFsdWVPckVycm9yTWVzc2FnZQIJAJ0IAgUEdGhpcwUDa2V5CQCsAgICFU5vIGRhdGEgZm9yIHRoaXMua2V5PQUDa2V5AAxwb29sRGlzYWJsZWQJAAIBAg1Qb29sIGRpc2FibGVkAAxwb29sTm90RXhpc3QJAAIBAhFQb29sIGlzIG5vdCBleGlzdAAOc2xpcHBhZ2VUb29CaWcJAAIBAhNTbGlwcGFnZSBpcyB0b28gYmlnARNrZXlNYW5hZ2VyUHVibGljS2V5AAIUJXNfX21hbmFnZXJQdWJsaWNLZXkBGmtleVBlbmRpbmdNYW5hZ2VyUHVibGljS2V5AAIbJXNfX3BlbmRpbmdNYW5hZ2VyUHVibGljS2V5AQJmYwACEyVzX19mYWN0b3J5Q29udHJhY3QAD2ZhY3RvcnlDb250cmFjdAkBEUBleHRyTmF0aXZlKDEwNjIpAQkBD2dldFN0cmluZ09yRmFp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GNoMAUCcGsDCQABAgUHJG1hdGNoMAIEVW5pdAgFAnR4D3NlbmRlclB1YmxpY0tleQkAAgECC01hdGNoIGVycm9yCQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAABQ90YXJnZXRQdWJsaWNLZXnDUTPn", "height": 2459056, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: xYqMb1fJX98Bdwa3XKpguLt7hTGQc7bAq1Fe9tkBmQ9 Next: 9imWsuzCkLEoifysiyrct7UqCtvntWuTP4nggovRb5kg Diff:
Old | New | Differences | |
---|---|---|---|
160 | 160 | let poolAdr = $t039804058._1 | |
161 | 161 | let isReverse = $t039804058._2 | |
162 | 162 | let res = { | |
163 | - | let @ = invoke(poolAdr, "calculateAmountOutForSwapREADONLY", [toInt(cleanAmountIn), isReverse, feePoolAmount], nil) | |
163 | + | let @ = invoke(poolAdr, "calculateAmountOutForSwapREADONLY", [toInt(cleanAmountIn), isReverse, toInt(feePoolAmount)], nil) | |
164 | 164 | if ($isInstanceOf(@, "Int")) | |
165 | 165 | then @ | |
166 | 166 | else throw(($getType(@) + " couldn't be cast to Int")) | |
193 | 193 | else throw("exactly 1 payment are expected")] | |
194 | 194 | if ((checks == checks)) | |
195 | 195 | then { | |
196 | - | let $ | |
197 | - | let poolAdr = $ | |
198 | - | let isReverse = $ | |
196 | + | let $t051875265 = getPoolAddressAndCheckPoolStatus(assetIn, assetOut) | |
197 | + | let poolAdr = $t051875265._1 | |
198 | + | let isReverse = $t051875265._2 | |
199 | 199 | let assetInAttachedPayment = if ((assetIn == "WAVES")) | |
200 | 200 | then unit | |
201 | 201 | else fromBase58String(assetIn) | |
202 | 202 | let totalGetRaw = { | |
203 | - | let @ = invoke(poolAdr, "calculateAmountOutForSwapAndSendTokens", [toInt(cleanAmountIn), isReverse, amountOutMin, addressTo, feePoolAmount], [AttachedPayment(assetInAttachedPayment, toInt(cleanAmountIn))]) | |
203 | + | let @ = invoke(poolAdr, "calculateAmountOutForSwapAndSendTokens", [toInt(cleanAmountIn), isReverse, amountOutMin, addressTo, toInt(feePoolAmount)], [AttachedPayment(assetInAttachedPayment, toInt(cleanAmountIn))]) | |
204 | 204 | if ($isInstanceOf(@, "Int")) | |
205 | 205 | then @ | |
206 | 206 | else throw(($getType(@) + " couldn't be cast to 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 | func getPoolAddressAndCheckPoolStatus (assetIn,assetOut) = { | |
93 | 93 | let lpNonReverse = { | |
94 | 94 | let @ = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetIn, assetOut], nil) | |
95 | 95 | if ($isInstanceOf(@, "String")) | |
96 | 96 | then @ | |
97 | 97 | else unit | |
98 | 98 | } | |
99 | 99 | let lpReverse = { | |
100 | 100 | let @ = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetOut, assetIn], nil) | |
101 | 101 | if ($isInstanceOf(@, "String")) | |
102 | 102 | then @ | |
103 | 103 | else unit | |
104 | 104 | } | |
105 | 105 | let $t025332992 = if ((lpNonReverse != unit)) | |
106 | 106 | then { | |
107 | 107 | let pool = { | |
108 | 108 | let @ = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [value(lpNonReverse)], nil) | |
109 | 109 | if ($isInstanceOf(@, "String")) | |
110 | 110 | then @ | |
111 | 111 | else throw(($getType(@) + " couldn't be cast to String")) | |
112 | 112 | } | |
113 | 113 | $Tuple2(false, pool) | |
114 | 114 | } | |
115 | 115 | else if ((lpReverse != unit)) | |
116 | 116 | then { | |
117 | 117 | let pool = { | |
118 | 118 | let @ = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [value(lpReverse)], nil) | |
119 | 119 | if ($isInstanceOf(@, "String")) | |
120 | 120 | then @ | |
121 | 121 | else throw(($getType(@) + " couldn't be cast to String")) | |
122 | 122 | } | |
123 | 123 | $Tuple2(true, pool) | |
124 | 124 | } | |
125 | 125 | else poolNotExist | |
126 | 126 | let isReverse = $t025332992._1 | |
127 | 127 | let pool = $t025332992._2 | |
128 | 128 | let poolStatus = { | |
129 | 129 | let @ = invoke(factoryContract, "getPoolStatusREADONLY", [pool], nil) | |
130 | 130 | if ($isInstanceOf(@, "Int")) | |
131 | 131 | then @ | |
132 | 132 | else throw(($getType(@) + " couldn't be cast to Int")) | |
133 | 133 | } | |
134 | 134 | let check = if ((poolStatus == 1)) | |
135 | 135 | then true | |
136 | 136 | else poolDisabled | |
137 | 137 | if ((check == check)) | |
138 | 138 | then { | |
139 | 139 | let poolAdr = addressFromStringValue(valueOrElse(pool, "")) | |
140 | 140 | $Tuple2(poolAdr, isReverse) | |
141 | 141 | } | |
142 | 142 | else throw("Strict value is not equal to itself.") | |
143 | 143 | } | |
144 | 144 | ||
145 | 145 | ||
146 | 146 | @Callable(i) | |
147 | 147 | func swapCalculateREADONLY (amountIn,assetIn,assetOut) = { | |
148 | 148 | let prFee = value(getInteger(protocolFee())) | |
149 | 149 | let feeProtocolAmountCalc = fraction(toBigInt(amountIn), toBigInt(prFee), feeScale) | |
150 | 150 | let plFee = value(getInteger(poolFee())) | |
151 | 151 | let feePoolAmountCalc = fraction(toBigInt(amountIn), toBigInt(plFee), feeScale) | |
152 | 152 | let feeProtocolAmount = if ((toInt(feeProtocolAmountCalc) == 0)) | |
153 | 153 | then toBigInt(1) | |
154 | 154 | else feeProtocolAmountCalc | |
155 | 155 | let feePoolAmount = if ((toInt(feePoolAmountCalc) == 0)) | |
156 | 156 | then toBigInt(1) | |
157 | 157 | else feePoolAmountCalc | |
158 | 158 | let cleanAmountIn = ((toBigInt(amountIn) - feeProtocolAmount) - feePoolAmount) | |
159 | 159 | let $t039804058 = getPoolAddressAndCheckPoolStatus(assetIn, assetOut) | |
160 | 160 | let poolAdr = $t039804058._1 | |
161 | 161 | let isReverse = $t039804058._2 | |
162 | 162 | let res = { | |
163 | - | let @ = invoke(poolAdr, "calculateAmountOutForSwapREADONLY", [toInt(cleanAmountIn), isReverse, feePoolAmount], nil) | |
163 | + | let @ = invoke(poolAdr, "calculateAmountOutForSwapREADONLY", [toInt(cleanAmountIn), isReverse, toInt(feePoolAmount)], nil) | |
164 | 164 | if ($isInstanceOf(@, "Int")) | |
165 | 165 | then @ | |
166 | 166 | else throw(($getType(@) + " couldn't be cast to Int")) | |
167 | 167 | } | |
168 | 168 | $Tuple2(nil, res) | |
169 | 169 | } | |
170 | 170 | ||
171 | 171 | ||
172 | 172 | ||
173 | 173 | @Callable(i) | |
174 | 174 | func swap (amountOutMin,assetOut,addressTo) = { | |
175 | 175 | let pmt = value(i.payments[0]) | |
176 | 176 | let assetIn = if ((pmt.assetId == unit)) | |
177 | 177 | then "WAVES" | |
178 | 178 | else toBase58String(value(pmt.assetId)) | |
179 | 179 | let amountIn = value(pmt.amount) | |
180 | 180 | let prFee = value(getInteger(protocolFee())) | |
181 | 181 | let feeProtocolAmountCalc = fraction(toBigInt(amountIn), toBigInt(prFee), feeScale) | |
182 | 182 | let plFee = value(getInteger(poolFee())) | |
183 | 183 | let feePoolAmountCalc = fraction(toBigInt(amountIn), toBigInt(plFee), feeScale) | |
184 | 184 | let feeProtocolAmount = if ((toInt(feeProtocolAmountCalc) == 0)) | |
185 | 185 | then toBigInt(1) | |
186 | 186 | else feeProtocolAmountCalc | |
187 | 187 | let feePoolAmount = if ((toInt(feePoolAmountCalc) == 0)) | |
188 | 188 | then toBigInt(1) | |
189 | 189 | else feePoolAmountCalc | |
190 | 190 | let cleanAmountIn = ((toBigInt(amountIn) - feeProtocolAmount) - feePoolAmount) | |
191 | 191 | let checks = [if ((size(i.payments) == 1)) | |
192 | 192 | then true | |
193 | 193 | else throw("exactly 1 payment are expected")] | |
194 | 194 | if ((checks == checks)) | |
195 | 195 | then { | |
196 | - | let $ | |
197 | - | let poolAdr = $ | |
198 | - | let isReverse = $ | |
196 | + | let $t051875265 = getPoolAddressAndCheckPoolStatus(assetIn, assetOut) | |
197 | + | let poolAdr = $t051875265._1 | |
198 | + | let isReverse = $t051875265._2 | |
199 | 199 | let assetInAttachedPayment = if ((assetIn == "WAVES")) | |
200 | 200 | then unit | |
201 | 201 | else fromBase58String(assetIn) | |
202 | 202 | let totalGetRaw = { | |
203 | - | let @ = invoke(poolAdr, "calculateAmountOutForSwapAndSendTokens", [toInt(cleanAmountIn), isReverse, amountOutMin, addressTo, feePoolAmount], [AttachedPayment(assetInAttachedPayment, toInt(cleanAmountIn))]) | |
203 | + | let @ = invoke(poolAdr, "calculateAmountOutForSwapAndSendTokens", [toInt(cleanAmountIn), isReverse, amountOutMin, addressTo, toInt(feePoolAmount)], [AttachedPayment(assetInAttachedPayment, toInt(cleanAmountIn))]) | |
204 | 204 | if ($isInstanceOf(@, "Int")) | |
205 | 205 | then @ | |
206 | 206 | else throw(($getType(@) + " couldn't be cast to Int")) | |
207 | 207 | } | |
208 | 208 | $Tuple2([ScriptTransfer(feeCollectorAddress, toInt(feeProtocolAmount), assetInAttachedPayment), ScriptTransfer(poolAdr, toInt(feePoolAmount), assetInAttachedPayment)], totalGetRaw) | |
209 | 209 | } | |
210 | 210 | else throw("Strict value is not equal to itself.") | |
211 | 211 | } | |
212 | 212 | ||
213 | 213 | ||
214 | 214 | ||
215 | 215 | @Callable(i) | |
216 | 216 | func setManager (pendingManagerPublicKey) = { | |
217 | 217 | let checkCaller = mustManager(i) | |
218 | 218 | if ((checkCaller == checkCaller)) | |
219 | 219 | then { | |
220 | 220 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
221 | 221 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
222 | 222 | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
223 | 223 | else throw("Strict value is not equal to itself.") | |
224 | 224 | } | |
225 | 225 | else throw("Strict value is not equal to itself.") | |
226 | 226 | } | |
227 | 227 | ||
228 | 228 | ||
229 | 229 | ||
230 | 230 | @Callable(i) | |
231 | 231 | func confirmManager () = { | |
232 | 232 | let pm = pendingManagerPublicKeyOrUnit() | |
233 | 233 | let hasPM = if (isDefined(pm)) | |
234 | 234 | then true | |
235 | 235 | else throw("no pending manager") | |
236 | 236 | if ((hasPM == hasPM)) | |
237 | 237 | then { | |
238 | 238 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
239 | 239 | then true | |
240 | 240 | else throw("you are not pending manager") | |
241 | 241 | if ((checkPM == checkPM)) | |
242 | 242 | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
243 | 243 | else throw("Strict value is not equal to itself.") | |
244 | 244 | } | |
245 | 245 | else throw("Strict value is not equal to itself.") | |
246 | 246 | } | |
247 | 247 | ||
248 | 248 | ||
249 | 249 | @Verifier(tx) | |
250 | 250 | func verify () = { | |
251 | 251 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
252 | 252 | case pk: ByteVector => | |
253 | 253 | pk | |
254 | 254 | case _: Unit => | |
255 | 255 | tx.senderPublicKey | |
256 | 256 | case _ => | |
257 | 257 | throw("Match error") | |
258 | 258 | } | |
259 | 259 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
260 | 260 | } | |
261 | 261 |
github/deemru/w8io/026f985 77.55 ms ◑