tx · 3g5NcMPY9HAShJa14jcya7jbSGYd2nEV69qgeRrpajxG 3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq: -0.01300000 Waves 2023.02.03 13:50 [2433343] smart account 3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq > SELF 0.00000000 Waves
{ "type": 13, "id": "3g5NcMPY9HAShJa14jcya7jbSGYd2nEV69qgeRrpajxG", "fee": 1300000, "feeAssetId": null, "timestamp": 1675421476152, "version": 1, "sender": "3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq", "senderPublicKey": "2u2wYYcVBQv43Cc71zkhHPPitkqgg6dqTZ3nUMvYJ1uq", "proofs": [ "5Yf8ZiHaseqdRh5yHUvLmPyzQXhF2GHUMRQmt8r46wiCDs3NAXMdPorDPbkJ68JyN9ZMk6hYEvtQCW92kdFdJRoQ" ], "script": "base64:BgIXCAISBQoDAQgIEgUKAwEICBIDCgEIEgAUAANTRVACAl9fAAhmZWVTY2FsZQkAtgIBAKCNBgEPZ2V0U3RyaW5nT3JGYWlsAQNrZXkJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkAnQgCBQR0aGlzBQNrZXkJAKwCAgIVTm8gZGF0YSBmb3IgdGhpcy5rZXk9BQNrZXkADHBvb2xEaXNhYmxlZAkAAgECDVBvb2wgZGlzYWJsZWQADHBvb2xOb3RFeGlzdAkAAgECEVBvb2wgaXMgbm90IGV4aXN0AA5zbGlwcGFnZVRvb0JpZwkAAgECE1NsaXBwYWdlIGlzIHRvbyBiaWcBE2tleU1hbmFnZXJQdWJsaWNLZXkAAhQlc19fbWFuYWdlclB1YmxpY0tleQEaa2V5UGVuZGluZ01hbmFnZXJQdWJsaWNLZXkAAhslc19fcGVuZGluZ01hbmFnZXJQdWJsaWNLZXkBAmZjAAITJXNfX2ZhY3RvcnlDb250cmFjdAAPZmFjdG9yeUNvbnRyYWN0CQERQGV4dHJOYXRpdmUoMTA2MikBCQEPZ2V0U3RyaW5nT3JGYWlsAQ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ff:
Old | New | Differences | |
---|---|---|---|
94 | 94 | let cleanAmountIn = (amountInToPool - feeLiquidityAmount) | |
95 | 95 | let lpNonReverese = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetIn, assetOut], nil) | |
96 | 96 | let lpReverse = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetOut, assetIn], nil) | |
97 | - | let $ | |
97 | + | let $t026413114 = if ((lpNonReverese != unit)) | |
98 | 98 | then { | |
99 | 99 | let isReverse = false | |
100 | - | let pool = { | |
101 | - | let @ = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [lpNonReverese], nil) | |
102 | - | if ($isInstanceOf(@, "Address")) | |
103 | - | then @ | |
104 | - | else throw(($getType(@) + " couldn't be cast to Address")) | |
105 | - | } | |
100 | + | let pool = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [lpNonReverese], nil) | |
106 | 101 | $Tuple2(isReverse, pool) | |
107 | 102 | } | |
108 | 103 | else if ((lpReverse != unit)) | |
112 | 107 | $Tuple2(isReverse, pool) | |
113 | 108 | } | |
114 | 109 | else poolNotExist | |
115 | - | let isReverse = $ | |
116 | - | let pool = $ | |
110 | + | let isReverse = $t026413114._1 | |
111 | + | let pool = $t026413114._2 | |
117 | 112 | let isPoolOneTokenOperationsDisabled = { | |
118 | 113 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [pool], nil) | |
119 | 114 | if ($isInstanceOf(@, "Boolean")) | |
158 | 153 | then { | |
159 | 154 | let lpNonReverese = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetIn, assetOut], nil) | |
160 | 155 | let lpReverse = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetOut, assetIn], nil) | |
161 | - | let $ | |
156 | + | let $t045345024 = if ((lpNonReverese != unit)) | |
162 | 157 | then { | |
163 | 158 | let isReverse = false | |
164 | 159 | let pool = { | |
176 | 171 | $Tuple2(isReverse, pool) | |
177 | 172 | } | |
178 | 173 | else poolNotExist | |
179 | - | let isReverse = $ | |
180 | - | let pool = $ | |
174 | + | let isReverse = $t045345024._1 | |
175 | + | let pool = $t045345024._2 | |
181 | 176 | let isPoolOneTokenOperationsDisabled = { | |
182 | 177 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [pool], nil) | |
183 | 178 | if ($isInstanceOf(@, "Boolean")) |
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(100000) | |
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 feeLiquidityContractAddress () = makeString(["%s", "feeLiquidityContractAddress"], SEP) | |
29 | 29 | ||
30 | 30 | ||
31 | 31 | func feeLiquidity () = makeString(["%s", "feeLiquidity"], SEP) | |
32 | 32 | ||
33 | 33 | ||
34 | 34 | func protocolFee () = makeString(["%s", "protocolFee"], SEP) | |
35 | 35 | ||
36 | 36 | ||
37 | 37 | func asInt (val) = match val { | |
38 | 38 | case valInt: Int => | |
39 | 39 | valInt | |
40 | 40 | case _ => | |
41 | 41 | throw("fail to cast into Int") | |
42 | 42 | } | |
43 | 43 | ||
44 | 44 | ||
45 | 45 | func dataMappingPoolAssets (internalAmountAssetStr,internalPriceAssetStr) = makeString(["%d%d", toString(internalAmountAssetStr), toString(internalPriceAssetStr)], SEP) | |
46 | 46 | ||
47 | 47 | ||
48 | 48 | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
49 | 49 | case s: String => | |
50 | 50 | fromBase58String(s) | |
51 | 51 | case _: Unit => | |
52 | 52 | unit | |
53 | 53 | case _ => | |
54 | 54 | throw("Match error") | |
55 | 55 | } | |
56 | 56 | ||
57 | 57 | ||
58 | 58 | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
59 | 59 | case s: String => | |
60 | 60 | fromBase58String(s) | |
61 | 61 | case _: Unit => | |
62 | 62 | unit | |
63 | 63 | case _ => | |
64 | 64 | throw("Match error") | |
65 | 65 | } | |
66 | 66 | ||
67 | 67 | ||
68 | 68 | func isManager (i) = match managerPublicKeyOrUnit() { | |
69 | 69 | case pk: ByteVector => | |
70 | 70 | (i.callerPublicKey == pk) | |
71 | 71 | case _: Unit => | |
72 | 72 | (i.caller == this) | |
73 | 73 | case _ => | |
74 | 74 | throw("Match error") | |
75 | 75 | } | |
76 | 76 | ||
77 | 77 | ||
78 | 78 | func mustManager (i) = if (isManager(i)) | |
79 | 79 | then true | |
80 | 80 | else throw("permission denied") | |
81 | 81 | ||
82 | 82 | ||
83 | 83 | func getAccBalance (assetId) = if ((assetId == "WAVES")) | |
84 | 84 | then wavesBalance(this).available | |
85 | 85 | else assetBalance(this, fromBase58String(assetId)) | |
86 | 86 | ||
87 | 87 | ||
88 | 88 | @Callable(i) | |
89 | 89 | func swapCalculateREADONLY (amountIn,assetIn,assetOut) = { | |
90 | 90 | let prFee = value(getInteger(protocolFee())) | |
91 | 91 | let feeProtocolAmount = fraction(toBigInt(amountIn), toBigInt(prFee), feeScale) | |
92 | 92 | let feeLiquidityAmount = fraction(toBigInt(amountIn), toBigInt(prFee), feeScale) | |
93 | 93 | let amountInToPool = (toBigInt(amountIn) - feeProtocolAmount) | |
94 | 94 | let cleanAmountIn = (amountInToPool - feeLiquidityAmount) | |
95 | 95 | let lpNonReverese = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetIn, assetOut], nil) | |
96 | 96 | let lpReverse = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetOut, assetIn], nil) | |
97 | - | let $ | |
97 | + | let $t026413114 = if ((lpNonReverese != unit)) | |
98 | 98 | then { | |
99 | 99 | let isReverse = false | |
100 | - | let pool = { | |
101 | - | let @ = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [lpNonReverese], nil) | |
102 | - | if ($isInstanceOf(@, "Address")) | |
103 | - | then @ | |
104 | - | else throw(($getType(@) + " couldn't be cast to Address")) | |
105 | - | } | |
100 | + | let pool = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [lpNonReverese], nil) | |
106 | 101 | $Tuple2(isReverse, pool) | |
107 | 102 | } | |
108 | 103 | else if ((lpReverse != unit)) | |
109 | 104 | then { | |
110 | 105 | let isReverse = true | |
111 | 106 | let pool = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [lpReverse], nil) | |
112 | 107 | $Tuple2(isReverse, pool) | |
113 | 108 | } | |
114 | 109 | else poolNotExist | |
115 | - | let isReverse = $ | |
116 | - | let pool = $ | |
110 | + | let isReverse = $t026413114._1 | |
111 | + | let pool = $t026413114._2 | |
117 | 112 | let isPoolOneTokenOperationsDisabled = { | |
118 | 113 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [pool], nil) | |
119 | 114 | if ($isInstanceOf(@, "Boolean")) | |
120 | 115 | then @ | |
121 | 116 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
122 | 117 | } | |
123 | 118 | let check = if (isPoolOneTokenOperationsDisabled) | |
124 | 119 | then true | |
125 | 120 | else poolDisabled | |
126 | 121 | if ((check == check)) | |
127 | 122 | then { | |
128 | 123 | let poolAdr = addressFromStringValue(valueOrElse(pool, "")) | |
129 | 124 | let res = { | |
130 | 125 | let @ = invoke(poolAdr, "calculateAmountOutForSwapREADONLY", [cleanAmountIn, isReverse], nil) | |
131 | 126 | if ($isInstanceOf(@, "Int")) | |
132 | 127 | then @ | |
133 | 128 | else throw(($getType(@) + " couldn't be cast to Int")) | |
134 | 129 | } | |
135 | 130 | $Tuple2(nil, res) | |
136 | 131 | } | |
137 | 132 | else throw("Strict value is not equal to itself.") | |
138 | 133 | } | |
139 | 134 | ||
140 | 135 | ||
141 | 136 | ||
142 | 137 | @Callable(i) | |
143 | 138 | func swap (amountOutMin,assetOut,addressTo) = { | |
144 | 139 | let pmt = value(i.payments[0]) | |
145 | 140 | let assetIn = if ((pmt.assetId == unit)) | |
146 | 141 | then toBytes("WAVES") | |
147 | 142 | else value(pmt.assetId) | |
148 | 143 | let amountIn = value(pmt.amount) | |
149 | 144 | let prFee = value(getInteger(protocolFee())) | |
150 | 145 | let feeProtocolAmount = fraction(toBigInt(amountIn), toBigInt(prFee), feeScale) | |
151 | 146 | let feeLiquidityAmount = fraction(toBigInt(amountIn), toBigInt(prFee), feeScale) | |
152 | 147 | let amountInToPool = (toBigInt(amountIn) - feeProtocolAmount) | |
153 | 148 | let cleanAmountIn = (amountInToPool - feeLiquidityAmount) | |
154 | 149 | let checks = [if ((size(i.payments) == 1)) | |
155 | 150 | then true | |
156 | 151 | else throw("exactly 1 payment are expected")] | |
157 | 152 | if ((checks == checks)) | |
158 | 153 | then { | |
159 | 154 | let lpNonReverese = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetIn, assetOut], nil) | |
160 | 155 | let lpReverse = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetOut, assetIn], nil) | |
161 | - | let $ | |
156 | + | let $t045345024 = if ((lpNonReverese != unit)) | |
162 | 157 | then { | |
163 | 158 | let isReverse = false | |
164 | 159 | let pool = { | |
165 | 160 | let @ = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [lpNonReverese], nil) | |
166 | 161 | if ($isInstanceOf(@, "Address")) | |
167 | 162 | then @ | |
168 | 163 | else throw(($getType(@) + " couldn't be cast to Address")) | |
169 | 164 | } | |
170 | 165 | $Tuple2(isReverse, pool) | |
171 | 166 | } | |
172 | 167 | else if ((lpReverse != unit)) | |
173 | 168 | then { | |
174 | 169 | let isReverse = true | |
175 | 170 | let pool = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [lpReverse], nil) | |
176 | 171 | $Tuple2(isReverse, pool) | |
177 | 172 | } | |
178 | 173 | else poolNotExist | |
179 | - | let isReverse = $ | |
180 | - | let pool = $ | |
174 | + | let isReverse = $t045345024._1 | |
175 | + | let pool = $t045345024._2 | |
181 | 176 | let isPoolOneTokenOperationsDisabled = { | |
182 | 177 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [pool], nil) | |
183 | 178 | if ($isInstanceOf(@, "Boolean")) | |
184 | 179 | then @ | |
185 | 180 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
186 | 181 | } | |
187 | 182 | let check = if (isPoolOneTokenOperationsDisabled) | |
188 | 183 | then true | |
189 | 184 | else poolDisabled | |
190 | 185 | if ((check == check)) | |
191 | 186 | then { | |
192 | 187 | let poolAdr = addressFromStringValue(valueOrElse(pool, "")) | |
193 | 188 | let res = { | |
194 | 189 | let @ = invoke(poolAdr, "calculateAmountOutForSwapAndSendTokens", [cleanAmountIn, isReverse, amountOutMin, addressTo], [AttachedPayment(assetIn, toInt(amountInToPool))]) | |
195 | 190 | if ($isInstanceOf(@, "Boolean")) | |
196 | 191 | then @ | |
197 | 192 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
198 | 193 | } | |
199 | 194 | $Tuple2(nil, res) | |
200 | 195 | } | |
201 | 196 | else throw("Strict value is not equal to itself.") | |
202 | 197 | } | |
203 | 198 | else throw("Strict value is not equal to itself.") | |
204 | 199 | } | |
205 | 200 | ||
206 | 201 | ||
207 | 202 | ||
208 | 203 | @Callable(i) | |
209 | 204 | func setManager (pendingManagerPublicKey) = { | |
210 | 205 | let checkCaller = mustManager(i) | |
211 | 206 | if ((checkCaller == checkCaller)) | |
212 | 207 | then { | |
213 | 208 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
214 | 209 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
215 | 210 | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
216 | 211 | else throw("Strict value is not equal to itself.") | |
217 | 212 | } | |
218 | 213 | else throw("Strict value is not equal to itself.") | |
219 | 214 | } | |
220 | 215 | ||
221 | 216 | ||
222 | 217 | ||
223 | 218 | @Callable(i) | |
224 | 219 | func confirmManager () = { | |
225 | 220 | let pm = pendingManagerPublicKeyOrUnit() | |
226 | 221 | let hasPM = if (isDefined(pm)) | |
227 | 222 | then true | |
228 | 223 | else throw("no pending manager") | |
229 | 224 | if ((hasPM == hasPM)) | |
230 | 225 | then { | |
231 | 226 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
232 | 227 | then true | |
233 | 228 | else throw("you are not pending manager") | |
234 | 229 | if ((checkPM == checkPM)) | |
235 | 230 | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
236 | 231 | else throw("Strict value is not equal to itself.") | |
237 | 232 | } | |
238 | 233 | else throw("Strict value is not equal to itself.") | |
239 | 234 | } | |
240 | 235 | ||
241 | 236 | ||
242 | 237 | @Verifier(tx) | |
243 | 238 | func verify () = { | |
244 | 239 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
245 | 240 | case pk: ByteVector => | |
246 | 241 | pk | |
247 | 242 | case _: Unit => | |
248 | 243 | tx.senderPublicKey | |
249 | 244 | case _ => | |
250 | 245 | throw("Match error") | |
251 | 246 | } | |
252 | 247 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
253 | 248 | } | |
254 | 249 |
github/deemru/w8io/026f985 35.95 ms ◑