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