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