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