tx · DqUYMbqMi7EP2SrhxKQHm8GASJtcNP2DRTLDQjHd2Jtw

3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq:  -0.01300000 Waves

2023.02.09 11:50 [2441880] smart account 3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq > SELF 0.00000000 Waves

{ "type": 13, "id": "DqUYMbqMi7EP2SrhxKQHm8GASJtcNP2DRTLDQjHd2Jtw", "fee": 1300000, "feeAssetId": null, "timestamp": 1675932658457, "version": 1, "sender": "3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq", "senderPublicKey": "2u2wYYcVBQv43Cc71zkhHPPitkqgg6dqTZ3nUMvYJ1uq", "proofs": [ "2Su297goi1hKGMMPvsquLR3k2d6AkjR5b5raEKyqBEfnxWmoCVt5FfZUxRrsUNJ872423m5K2ZHGHhEkYYE44MQ1" ], "script": "base64:BgIXCAISBQoDAQgIEgUKAwEICBIDCgEIEgAUAANTRVACAl9fAAhmZWVTY2FsZQkAtgIBAKCNBgEPZ2V0U3RyaW5nT3JGYWlsAQNrZXkJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkAnQgCBQR0aGlzBQNrZXkJAKwCAgIVTm8gZGF0YSBmb3IgdGhpcy5rZXk9BQNrZXkADHBvb2xEaXNhYmxlZAkAAgECDVBvb2wgZGlzYWJsZWQADHBvb2xOb3RFeGlzdAkAAgECEVBvb2wgaXMgbm90IGV4aXN0AA5zbGlwcGFnZVRvb0JpZwkAAgECE1NsaXBwYWdlIGlzIHRvbyBiaWcBE2tleU1hbmFnZXJQdWJsaWNLZXkAAhQlc19fbWFuYWdlclB1YmxpY0tleQEaa2V5UGVuZGluZ01hbmFnZXJQdWJsaWNLZXkAAhslc19fcGVuZGluZ01hbmFnZXJQdWJsaWNLZXkBAmZjAAITJXNfX2ZhY3RvcnlDb250cmFjdAAPZmFjdG9yeUNvbnRyYWN0CQERQGV4dHJOYXRpdmUoMTA2MikBCQEPZ2V0U3RyaW5nT3JGYWl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hbmFnZXIABAJwbQkBHXBlbmRpbmdNYW5hZ2VyUHVibGljS2V5T3JVbml0AAQFaGFzUE0DCQEJaXNEZWZpbmVkAQUCcG0GCQACAQISbm8gcGVuZGluZyBtYW5hZ2VyAwkAAAIFBWhhc1BNBQVoYXNQTQQHY2hlY2tQTQMJAAACCAUBaQ9jYWxsZXJQdWJsaWNLZXkJAQV2YWx1ZQEFAnBtBgkAAgECG3lvdSBhcmUgbm90IHBlbmRpbmcgbWFuYWdlcgMJAAACBQdjaGVja1BNBQdjaGVja1BNCQDMCAIJAQtTdHJpbmdFbnRyeQIJARNrZXlNYW5hZ2VyUHVibGljS2V5AAkA2AQBCQEFdmFsdWUBBQJwbQkAzAgCCQELRGVsZXRlRW50cnkBCQEaa2V5UGVuZGluZ01hbmFnZXJQdWJsaWNLZXkABQNuaWwJAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4JAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4BAnR4AQZ2ZXJpZnkABA90YXJnZXRQdWJsaWNLZXkEByRtYXRjaDAJARZtYW5hZ2VyUHVibGljS2V5T3JVbml0AAMJAAECBQckbWF0Y2gwAgpCeXRlVmVjdG9yBAJwawUHJG1hdGNoMAUCcGsDCQABAgUHJG1hdGNoMAIEVW5pdAgFAnR4D3NlbmRlclB1YmxpY0tleQkAAgECC01hdGNoIGVycm9yCQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAABQ90YXJnZXRQdWJsaWNLZXmuu4pQ", "chainId": 84, "height": 2441880, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: GjoAa61M4wMsoaaCAQmkJrPFH7jnphpWm2td6uGXJE83 Next: 7RCQBYnNV6y55T3Yw8kRkD9BwgXFTZoxbCxHs5zGWRJC Diff:
OldNewDifferences
185185 else poolNotExist
186186 let isReverse = $t042814786._1
187187 let pool = $t042814786._2
188- let isPoolOneTokenOperationsDisabled = {
189- let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [pool], nil)
190- if ($isInstanceOf(@, "Boolean"))
188+ let poolStatus = {
189+ let @ = invoke(factoryContract, "getPoolStatusREADONLY", [pool], nil)
190+ if ($isInstanceOf(@, "Int"))
191191 then @
192- else throw(($getType(@) + " couldn't be cast to Boolean"))
192+ else throw(($getType(@) + " couldn't be cast to Int"))
193193 }
194- let check = if (isPoolOneTokenOperationsDisabled)
194+ let check = if ((poolStatus == 1))
195195 then true
196196 else poolDisabled
197197 if ((check == check))
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let SEP = "__"
55
66 let feeScale = toBigInt(100000)
77
88 func getStringOrFail (key) = valueOrErrorMessage(getString(this, key), ("No data for this.key=" + key))
99
1010
1111 let poolDisabled = throw("Pool disabled")
1212
1313 let poolNotExist = throw("Pool is not exist")
1414
1515 let slippageTooBig = throw("Slippage is too big")
1616
1717 func keyManagerPublicKey () = "%s__managerPublicKey"
1818
1919
2020 func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey"
2121
2222
2323 func fc () = "%s__factoryContract"
2424
2525
2626 let factoryContract = addressFromStringValue(getStringOrFail(fc()))
2727
2828 func feeProtocolContractAddress () = makeString(["%s", "feeProtocolContractAddress"], SEP)
2929
3030
3131 let feeContract = addressFromStringValue(getStringOrFail(feeProtocolContractAddress()))
3232
3333 func protocolFee () = makeString(["%s", "protocolFee"], SEP)
3434
3535
3636 func asInt (val) = match val {
3737 case valInt: Int =>
3838 valInt
3939 case _ =>
4040 throw("fail to cast into Int")
4141 }
4242
4343
4444 func dataMappingPoolAssets (internalAmountAssetStr,internalPriceAssetStr) = makeString(["%d%d", toString(internalAmountAssetStr), toString(internalPriceAssetStr)], SEP)
4545
4646
4747 func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) {
4848 case s: String =>
4949 fromBase58String(s)
5050 case _: Unit =>
5151 unit
5252 case _ =>
5353 throw("Match error")
5454 }
5555
5656
5757 func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) {
5858 case s: String =>
5959 fromBase58String(s)
6060 case _: Unit =>
6161 unit
6262 case _ =>
6363 throw("Match error")
6464 }
6565
6666
6767 func isManager (i) = match managerPublicKeyOrUnit() {
6868 case pk: ByteVector =>
6969 (i.callerPublicKey == pk)
7070 case _: Unit =>
7171 (i.caller == this)
7272 case _ =>
7373 throw("Match error")
7474 }
7575
7676
7777 func mustManager (i) = if (isManager(i))
7878 then true
7979 else throw("permission denied")
8080
8181
8282 func getAccBalance (assetId) = if ((assetId == "WAVES"))
8383 then wavesBalance(this).available
8484 else assetBalance(this, fromBase58String(assetId))
8585
8686
8787 @Callable(i)
8888 func swapCalculateREADONLY (amountIn,assetIn,assetOut) = {
8989 let prFee = value(getInteger(protocolFee()))
9090 let feeProtocolAmount = fraction(toBigInt(amountIn), toBigInt(prFee), feeScale)
9191 let cleanAmountIn = if ((toInt(feeProtocolAmount) == 0))
9292 then toBigInt(1)
9393 else (toBigInt(amountIn) - feeProtocolAmount)
9494 let lpNonReverese = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetIn, assetOut], nil)
9595 let lpReverse = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetOut, assetIn], nil)
9696 let $t025613066 = if ((lpNonReverese != unit))
9797 then {
9898 let isReverse = false
9999 let pool = {
100100 let @ = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [lpNonReverese], nil)
101101 if ($isInstanceOf(@, "String"))
102102 then @
103103 else throw(($getType(@) + " couldn't be cast to String"))
104104 }
105105 $Tuple2(isReverse, pool)
106106 }
107107 else if ((lpReverse != unit))
108108 then {
109109 let isReverse = true
110110 let pool = {
111111 let @ = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [lpReverse], nil)
112112 if ($isInstanceOf(@, "String"))
113113 then @
114114 else throw(($getType(@) + " couldn't be cast to String"))
115115 }
116116 $Tuple2(isReverse, pool)
117117 }
118118 else poolNotExist
119119 let isReverse = $t025613066._1
120120 let pool = $t025613066._2
121121 let poolStatus = {
122122 let @ = invoke(factoryContract, "getPoolStatusREADONLY", [pool], nil)
123123 if ($isInstanceOf(@, "Int"))
124124 then @
125125 else throw(($getType(@) + " couldn't be cast to Int"))
126126 }
127127 let check = if ((poolStatus == 1))
128128 then true
129129 else poolDisabled
130130 if ((check == check))
131131 then {
132132 let poolAdr = addressFromStringValue(valueOrElse(pool, ""))
133133 let res = {
134134 let @ = invoke(poolAdr, "calculateAmountOutForSwapREADONLY", [toInt(cleanAmountIn), isReverse], nil)
135135 if ($isInstanceOf(@, "Int"))
136136 then @
137137 else throw(($getType(@) + " couldn't be cast to Int"))
138138 }
139139 $Tuple2(nil, res)
140140 }
141141 else throw("Strict value is not equal to itself.")
142142 }
143143
144144
145145
146146 @Callable(i)
147147 func swap (amountOutMin,assetOut,addressTo) = {
148148 let pmt = value(i.payments[0])
149149 let assetIn = if ((pmt.assetId == unit))
150150 then toBytes("WAVES")
151151 else value(pmt.assetId)
152152 let amountIn = value(pmt.amount)
153153 let prFee = value(getInteger(protocolFee()))
154154 let feeProtocolAmount = fraction(toBigInt(amountIn), toBigInt(prFee), feeScale)
155155 let cleanAmountIn = (toBigInt(amountIn) - feeProtocolAmount)
156156 let checks = [if ((size(i.payments) == 1))
157157 then true
158158 else throw("exactly 1 payment are expected")]
159159 if ((checks == checks))
160160 then {
161161 let lpNonReverese = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [toBase58String(assetIn), assetOut], nil)
162162 let lpReverse = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetOut, toBase58String(assetIn)], nil)
163163 let $t042814786 = if ((lpNonReverese != unit))
164164 then {
165165 let isReverse = false
166166 let pool = {
167167 let @ = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [lpNonReverese], nil)
168168 if ($isInstanceOf(@, "String"))
169169 then @
170170 else throw(($getType(@) + " couldn't be cast to String"))
171171 }
172172 $Tuple2(isReverse, pool)
173173 }
174174 else if ((lpReverse != unit))
175175 then {
176176 let isReverse = true
177177 let pool = {
178178 let @ = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [lpReverse], nil)
179179 if ($isInstanceOf(@, "String"))
180180 then @
181181 else throw(($getType(@) + " couldn't be cast to String"))
182182 }
183183 $Tuple2(isReverse, pool)
184184 }
185185 else poolNotExist
186186 let isReverse = $t042814786._1
187187 let pool = $t042814786._2
188- let isPoolOneTokenOperationsDisabled = {
189- let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [pool], nil)
190- if ($isInstanceOf(@, "Boolean"))
188+ let poolStatus = {
189+ let @ = invoke(factoryContract, "getPoolStatusREADONLY", [pool], nil)
190+ if ($isInstanceOf(@, "Int"))
191191 then @
192- else throw(($getType(@) + " couldn't be cast to Boolean"))
192+ else throw(($getType(@) + " couldn't be cast to Int"))
193193 }
194- let check = if (isPoolOneTokenOperationsDisabled)
194+ let check = if ((poolStatus == 1))
195195 then true
196196 else poolDisabled
197197 if ((check == check))
198198 then {
199199 let poolAdr = addressFromStringValue(pool)
200200 let res = {
201201 let @ = invoke(poolAdr, "calculateAmountOutForSwapAndSendTokens", [toInt(cleanAmountIn), isReverse, amountOutMin, addressTo], [AttachedPayment(assetIn, toInt(cleanAmountIn))])
202202 if ($isInstanceOf(@, "Boolean"))
203203 then @
204204 else throw(($getType(@) + " couldn't be cast to Boolean"))
205205 }
206206 $Tuple2([ScriptTransfer(feeContract, toInt(feeProtocolAmount), assetIn)], res)
207207 }
208208 else throw("Strict value is not equal to itself.")
209209 }
210210 else throw("Strict value is not equal to itself.")
211211 }
212212
213213
214214
215215 @Callable(i)
216216 func setManager (pendingManagerPublicKey) = {
217217 let checkCaller = mustManager(i)
218218 if ((checkCaller == checkCaller))
219219 then {
220220 let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey)
221221 if ((checkManagerPublicKey == checkManagerPublicKey))
222222 then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)]
223223 else throw("Strict value is not equal to itself.")
224224 }
225225 else throw("Strict value is not equal to itself.")
226226 }
227227
228228
229229
230230 @Callable(i)
231231 func confirmManager () = {
232232 let pm = pendingManagerPublicKeyOrUnit()
233233 let hasPM = if (isDefined(pm))
234234 then true
235235 else throw("no pending manager")
236236 if ((hasPM == hasPM))
237237 then {
238238 let checkPM = if ((i.callerPublicKey == value(pm)))
239239 then true
240240 else throw("you are not pending manager")
241241 if ((checkPM == checkPM))
242242 then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())]
243243 else throw("Strict value is not equal to itself.")
244244 }
245245 else throw("Strict value is not equal to itself.")
246246 }
247247
248248
249249 @Verifier(tx)
250250 func verify () = {
251251 let targetPublicKey = match managerPublicKeyOrUnit() {
252252 case pk: ByteVector =>
253253 pk
254254 case _: Unit =>
255255 tx.senderPublicKey
256256 case _ =>
257257 throw("Match error")
258258 }
259259 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
260260 }
261261

github/deemru/w8io/169f3d6 
45.94 ms