tx · 4iwV8vX9FoEeAgufLwch2Qkx3ACHNyds8mRVMQgQxtcG

3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq:  -0.01300000 Waves

2023.02.09 13:33 [2441981] smart account 3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq > SELF 0.00000000 Waves

{ "type": 13, "id": "4iwV8vX9FoEeAgufLwch2Qkx3ACHNyds8mRVMQgQxtcG", "fee": 1300000, "feeAssetId": null, "timestamp": 1675938833696, "version": 1, "sender": "3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq", "senderPublicKey": "2u2wYYcVBQv43Cc71zkhHPPitkqgg6dqTZ3nUMvYJ1uq", "proofs": [ "ssfkD1q6sTqD7XEfs4bN3pBV4jUo7FW1gmxJL9Zau9pzgMV5depwByZAvzhthvcogVKFfT7KHFpGAGCDoSRC7Hx" ], "script": "base64:BgIXCAISBQoDAQgIEgUKAwEICBIDCgEIEgAUAANTRVACAl9fAAhmZWVTY2FsZQkAtgIBAKCNBgEPZ2V0U3RyaW5nT3JGYWlsAQNrZXkJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkAnQgCBQR0aGlzBQNrZXkJAKwCAgIVTm8gZGF0YSBmb3IgdGhpcy5rZXk9BQNrZXkADHBvb2xEaXNhYmxlZAkAAgECDVBvb2wgZGlzYWJsZWQADHBvb2xOb3RFeGlzdAkAAgECEVBvb2wgaXMgbm90IGV4aXN0AA5zbGlwcGFnZVRvb0JpZwkAAgECE1NsaXBwYWdlIGlzIHRvbyBiaWcBE2tleU1hbmFnZXJQdWJsaWNLZXkAAhQlc19fbWFuYWdlclB1YmxpY0tleQEaa2V5UGVuZGluZ01hbmFnZXJQdWJsaWNLZXkAAhslc19fcGVuZGluZ01hbmFnZXJQdWJsaWNLZXkBAmZjAAITJXNfX2ZhY3RvcnlDb250cmFjdAAPZmFjdG9yeUNvbnRyYWN0CQERQGV4dHJOYXRpdmUoMTA2MikBCQEPZ2V0U3RyaW5nT3JGYWls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prev: 7RCQBYnNV6y55T3Yw8kRkD9BwgXFTZoxbCxHs5zGWRJC Next: F95e4GGkfnJoQwxw9Qtgbd1wWcT4vH5NThMZtNU8QX2A Diff:
OldNewDifferences
160160 then {
161161 let lpNonReverese = {
162162 let @ = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [toBase58String(assetIn), assetOut], nil)
163- if ($isInstanceOf(@, "String|Unit"))
163+ if ($isInstanceOf(@, "String"))
164164 then @
165- else throw(($getType(@) + " couldn't be cast to String|Unit"))
165+ else unit
166166 }
167167 let lpReverse = {
168168 let @ = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetOut, toBase58String(assetIn)], nil)
170170 then @
171171 else throw(($getType(@) + " couldn't be cast to String|Unit"))
172172 }
173- let $t043234836 = if ((lpNonReverese != unit))
173+ let $t043134826 = if ((lpNonReverese != unit))
174174 then {
175175 let isReverse = false
176176 let pool = {
193193 $Tuple2(isReverse, pool)
194194 }
195195 else poolNotExist
196- let isReverse = $t043234836._1
197- let pool = $t043234836._2
196+ let isReverse = $t043134826._1
197+ let pool = $t043134826._2
198198 let poolStatus = {
199199 let @ = invoke(factoryContract, "getPoolStatusREADONLY", [pool], nil)
200200 if ($isInstanceOf(@, "Int"))
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 = {
162162 let @ = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [toBase58String(assetIn), assetOut], nil)
163- if ($isInstanceOf(@, "String|Unit"))
163+ if ($isInstanceOf(@, "String"))
164164 then @
165- else throw(($getType(@) + " couldn't be cast to String|Unit"))
165+ else unit
166166 }
167167 let lpReverse = {
168168 let @ = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetOut, toBase58String(assetIn)], nil)
169169 if ($isInstanceOf(@, "String|Unit"))
170170 then @
171171 else throw(($getType(@) + " couldn't be cast to String|Unit"))
172172 }
173- let $t043234836 = if ((lpNonReverese != unit))
173+ let $t043134826 = if ((lpNonReverese != unit))
174174 then {
175175 let isReverse = false
176176 let pool = {
177177 let @ = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [value(lpNonReverese)], nil)
178178 if ($isInstanceOf(@, "String"))
179179 then @
180180 else throw(($getType(@) + " couldn't be cast to String"))
181181 }
182182 $Tuple2(isReverse, pool)
183183 }
184184 else if ((lpReverse != unit))
185185 then {
186186 let isReverse = true
187187 let pool = {
188188 let @ = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [lpReverse], nil)
189189 if ($isInstanceOf(@, "String"))
190190 then @
191191 else throw(($getType(@) + " couldn't be cast to String"))
192192 }
193193 $Tuple2(isReverse, pool)
194194 }
195195 else poolNotExist
196- let isReverse = $t043234836._1
197- let pool = $t043234836._2
196+ let isReverse = $t043134826._1
197+ let pool = $t043134826._2
198198 let poolStatus = {
199199 let @ = invoke(factoryContract, "getPoolStatusREADONLY", [pool], nil)
200200 if ($isInstanceOf(@, "Int"))
201201 then @
202202 else throw(($getType(@) + " couldn't be cast to Int"))
203203 }
204204 let check = if ((poolStatus == 1))
205205 then true
206206 else poolDisabled
207207 if ((check == check))
208208 then {
209209 let poolAdr = addressFromStringValue(pool)
210210 let totalGetRaw = {
211211 let @ = invoke(poolAdr, "calculateAmountOutForSwapAndSendTokens", [toInt(cleanAmountIn), isReverse, amountOutMin, addressTo], [AttachedPayment(assetIn, toInt(cleanAmountIn))])
212212 if ($isInstanceOf(@, "Int"))
213213 then @
214214 else throw(($getType(@) + " couldn't be cast to Int"))
215215 }
216216 $Tuple2([ScriptTransfer(feeContract, toInt(feeProtocolAmount), assetIn)], totalGetRaw)
217217 }
218218 else throw("Strict value is not equal to itself.")
219219 }
220220 else throw("Strict value is not equal to itself.")
221221 }
222222
223223
224224
225225 @Callable(i)
226226 func setManager (pendingManagerPublicKey) = {
227227 let checkCaller = mustManager(i)
228228 if ((checkCaller == checkCaller))
229229 then {
230230 let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey)
231231 if ((checkManagerPublicKey == checkManagerPublicKey))
232232 then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)]
233233 else throw("Strict value is not equal to itself.")
234234 }
235235 else throw("Strict value is not equal to itself.")
236236 }
237237
238238
239239
240240 @Callable(i)
241241 func confirmManager () = {
242242 let pm = pendingManagerPublicKeyOrUnit()
243243 let hasPM = if (isDefined(pm))
244244 then true
245245 else throw("no pending manager")
246246 if ((hasPM == hasPM))
247247 then {
248248 let checkPM = if ((i.callerPublicKey == value(pm)))
249249 then true
250250 else throw("you are not pending manager")
251251 if ((checkPM == checkPM))
252252 then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())]
253253 else throw("Strict value is not equal to itself.")
254254 }
255255 else throw("Strict value is not equal to itself.")
256256 }
257257
258258
259259 @Verifier(tx)
260260 func verify () = {
261261 let targetPublicKey = match managerPublicKeyOrUnit() {
262262 case pk: ByteVector =>
263263 pk
264264 case _: Unit =>
265265 tx.senderPublicKey
266266 case _ =>
267267 throw("Match error")
268268 }
269269 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
270270 }
271271

github/deemru/w8io/026f985 
37.78 ms