tx · 61Ugg3z9sEYP74ELdkP4JTk42NJrLNhnEiq29rFuqaXq

3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq:  -0.01300000 Waves

2023.03.10 12:12 [2483780] smart account 3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq > SELF 0.00000000 Waves

{ "type": 13, "id": "61Ugg3z9sEYP74ELdkP4JTk42NJrLNhnEiq29rFuqaXq", "fee": 1300000, "feeAssetId": null, "timestamp": 1678439547556, "version": 2, "chainId": 84, "sender": "3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq", "senderPublicKey": "2u2wYYcVBQv43Cc71zkhHPPitkqgg6dqTZ3nUMvYJ1uq", "proofs": [ "4DFwBHEYsCmWcHyJUGsSWVVxSKNZLYExrdefEeUPGM4FRhS9xEcExeuPPRhNKzRBfg4dTW5ReJ4Tm5aWJTAbFBHC" ], "script": "base64:BgIXCAISBQoDAQgIEgUKAwEICBIDCgEIEgAXAANTRVACAl9fAAhmZWVTY2FsZQkAtgIBAIDC1y8BD2dldFN0cmluZ09yRmFpbAEDa2V5CQETdmFsdWVPckVycm9yTWVzc2FnZQIJAJ0IAgUEdGhpcwUDa2V5CQCsAgICFU5vIGRhdGEgZm9yIHRoaXMua2V5PQUDa2V5AAxwb29sRGlzYWJsZWQJAAIBAg1Qb29sIGRpc2FibGVkAAxwb29sTm90RXhpc3QJAAIBAhFQb29sIGlzIG5vdCBleGlzdAAOc2xpcHBhZ2VUb29CaWcJAAIBAhNTbGlwcGFnZSBpcyB0b28gYmlnARNrZXlNYW5hZ2VyUHVibGljS2V5AAIUJXNfX21hbmFnZXJQdWJsaWNLZXkBGmtleVBlbmRpbmdNYW5hZ2VyUHVibGljS2V5AAIbJXNfX3BlbmRpbmdNYW5hZ2VyUHVibGljS2V5AQJmYwACEyVzX19mYWN0b3J5Q29udHJhY3QAD2ZhY3RvcnlDb250cmFjdAkBEUBleHRyTmF0aXZlKDEwNjIpAQkBD2dldFN0cmluZ09yRmFp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LZXlPclVuaXQAAwkAAQIFByRtYXRjaDACCkJ5dGVWZWN0b3IEAnBrBQckbWF0Y2gwBQJwawMJAAECBQckbWF0Y2gwAgRVbml0CAUCdHgPc2VuZGVyUHVibGljS2V5CQACAQILTWF0Y2ggZXJyb3IJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAFD3RhcmdldFB1YmxpY0tleVf/3mw=", "height": 2483780, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9imWsuzCkLEoifysiyrct7UqCtvntWuTP4nggovRb5kg Next: 6E7AJAL9JMV4gZg7a6XTZ5rDXmhx3wGLr2XpbPSi7f7f Diff:
OldNewDifferences
160160 let poolAdr = $t039804058._1
161161 let isReverse = $t039804058._2
162162 let res = {
163- let @ = invoke(poolAdr, "calculateAmountOutForSwapREADONLY", [toInt(cleanAmountIn), isReverse], nil)
163+ let @ = invoke(poolAdr, "calculateAmountOutForSwapREADONLY", [toInt(cleanAmountIn), isReverse, toInt(feePoolAmount)], nil)
164164 if ($isInstanceOf(@, "Int"))
165165 then @
166166 else throw(($getType(@) + " couldn't be cast to Int"))
171171
172172
173173 @Callable(i)
174-func swap (amountOutMin,assetOut,addressTo) = {
174+func swap (amountOutMin,assetOutRaw,addressTo) = {
175+ let assetOut = if ((assetOutRaw == ""))
176+ then "WAVES"
177+ else assetOutRaw
175178 let pmt = value(i.payments[0])
176179 let assetIn = if ((pmt.assetId == unit))
177180 then "WAVES"
193196 else throw("exactly 1 payment are expected")]
194197 if ((checks == checks))
195198 then {
196- let $t051645242 = getPoolAddressAndCheckPoolStatus(assetIn, assetOut)
197- let poolAdr = $t051645242._1
198- let isReverse = $t051645242._2
199+ let $t052605338 = getPoolAddressAndCheckPoolStatus(assetIn, assetOut)
200+ let poolAdr = $t052605338._1
201+ let isReverse = $t052605338._2
199202 let assetInAttachedPayment = if ((assetIn == "WAVES"))
200203 then unit
201204 else fromBase58String(assetIn)
202205 let totalGetRaw = {
203- let @ = invoke(poolAdr, "calculateAmountOutForSwapAndSendTokens", [toInt(cleanAmountIn), isReverse, amountOutMin, addressTo], [AttachedPayment(assetInAttachedPayment, toInt(cleanAmountIn))])
206+ let @ = invoke(poolAdr, "calculateAmountOutForSwapAndSendTokens", [toInt(cleanAmountIn), isReverse, amountOutMin, addressTo, toInt(feePoolAmount)], [AttachedPayment(assetInAttachedPayment, toInt(cleanAmountIn))])
204207 if ($isInstanceOf(@, "Int"))
205208 then @
206209 else throw(($getType(@) + " couldn't be cast to Int"))
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let SEP = "__"
55
66 let feeScale = toBigInt(100000000)
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 protocolFee () = makeString(["%s", "protocolFee"], SEP)
2929
3030
3131 func poolFee () = makeString(["%s", "poolFee"], SEP)
3232
3333
3434 func getStringOrFailFromAddress (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
3535
3636
3737 let keyFeeCollectorAddress = "%s__feeCollectorAddress"
3838
3939 let feeCollectorAddress = addressFromStringValue(getStringOrFailFromAddress(factoryContract, keyFeeCollectorAddress))
4040
4141 func asInt (val) = match val {
4242 case valInt: Int =>
4343 valInt
4444 case _ =>
4545 throw("fail to cast into Int")
4646 }
4747
4848
4949 func dataMappingPoolAssets (internalAmountAssetStr,internalPriceAssetStr) = makeString(["%d%d", toString(internalAmountAssetStr), toString(internalPriceAssetStr)], SEP)
5050
5151
5252 func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) {
5353 case s: String =>
5454 fromBase58String(s)
5555 case _: Unit =>
5656 unit
5757 case _ =>
5858 throw("Match error")
5959 }
6060
6161
6262 func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) {
6363 case s: String =>
6464 fromBase58String(s)
6565 case _: Unit =>
6666 unit
6767 case _ =>
6868 throw("Match error")
6969 }
7070
7171
7272 func isManager (i) = match managerPublicKeyOrUnit() {
7373 case pk: ByteVector =>
7474 (i.callerPublicKey == pk)
7575 case _: Unit =>
7676 (i.caller == this)
7777 case _ =>
7878 throw("Match error")
7979 }
8080
8181
8282 func mustManager (i) = if (isManager(i))
8383 then true
8484 else throw("permission denied")
8585
8686
8787 func getAccBalance (assetId) = if ((assetId == "WAVES"))
8888 then wavesBalance(this).available
8989 else assetBalance(this, fromBase58String(assetId))
9090
9191
9292 func getPoolAddressAndCheckPoolStatus (assetIn,assetOut) = {
9393 let lpNonReverse = {
9494 let @ = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetIn, assetOut], nil)
9595 if ($isInstanceOf(@, "String"))
9696 then @
9797 else unit
9898 }
9999 let lpReverse = {
100100 let @ = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetOut, assetIn], nil)
101101 if ($isInstanceOf(@, "String"))
102102 then @
103103 else unit
104104 }
105105 let $t025332992 = if ((lpNonReverse != unit))
106106 then {
107107 let pool = {
108108 let @ = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [value(lpNonReverse)], nil)
109109 if ($isInstanceOf(@, "String"))
110110 then @
111111 else throw(($getType(@) + " couldn't be cast to String"))
112112 }
113113 $Tuple2(false, pool)
114114 }
115115 else if ((lpReverse != unit))
116116 then {
117117 let pool = {
118118 let @ = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [value(lpReverse)], nil)
119119 if ($isInstanceOf(@, "String"))
120120 then @
121121 else throw(($getType(@) + " couldn't be cast to String"))
122122 }
123123 $Tuple2(true, pool)
124124 }
125125 else poolNotExist
126126 let isReverse = $t025332992._1
127127 let pool = $t025332992._2
128128 let poolStatus = {
129129 let @ = invoke(factoryContract, "getPoolStatusREADONLY", [pool], nil)
130130 if ($isInstanceOf(@, "Int"))
131131 then @
132132 else throw(($getType(@) + " couldn't be cast to Int"))
133133 }
134134 let check = if ((poolStatus == 1))
135135 then true
136136 else poolDisabled
137137 if ((check == check))
138138 then {
139139 let poolAdr = addressFromStringValue(valueOrElse(pool, ""))
140140 $Tuple2(poolAdr, isReverse)
141141 }
142142 else throw("Strict value is not equal to itself.")
143143 }
144144
145145
146146 @Callable(i)
147147 func swapCalculateREADONLY (amountIn,assetIn,assetOut) = {
148148 let prFee = value(getInteger(protocolFee()))
149149 let feeProtocolAmountCalc = fraction(toBigInt(amountIn), toBigInt(prFee), feeScale)
150150 let plFee = value(getInteger(poolFee()))
151151 let feePoolAmountCalc = fraction(toBigInt(amountIn), toBigInt(plFee), feeScale)
152152 let feeProtocolAmount = if ((toInt(feeProtocolAmountCalc) == 0))
153153 then toBigInt(1)
154154 else feeProtocolAmountCalc
155155 let feePoolAmount = if ((toInt(feePoolAmountCalc) == 0))
156156 then toBigInt(1)
157157 else feePoolAmountCalc
158158 let cleanAmountIn = ((toBigInt(amountIn) - feeProtocolAmount) - feePoolAmount)
159159 let $t039804058 = getPoolAddressAndCheckPoolStatus(assetIn, assetOut)
160160 let poolAdr = $t039804058._1
161161 let isReverse = $t039804058._2
162162 let res = {
163- let @ = invoke(poolAdr, "calculateAmountOutForSwapREADONLY", [toInt(cleanAmountIn), isReverse], nil)
163+ let @ = invoke(poolAdr, "calculateAmountOutForSwapREADONLY", [toInt(cleanAmountIn), isReverse, toInt(feePoolAmount)], nil)
164164 if ($isInstanceOf(@, "Int"))
165165 then @
166166 else throw(($getType(@) + " couldn't be cast to Int"))
167167 }
168168 $Tuple2(nil, res)
169169 }
170170
171171
172172
173173 @Callable(i)
174-func swap (amountOutMin,assetOut,addressTo) = {
174+func swap (amountOutMin,assetOutRaw,addressTo) = {
175+ let assetOut = if ((assetOutRaw == ""))
176+ then "WAVES"
177+ else assetOutRaw
175178 let pmt = value(i.payments[0])
176179 let assetIn = if ((pmt.assetId == unit))
177180 then "WAVES"
178181 else toBase58String(value(pmt.assetId))
179182 let amountIn = value(pmt.amount)
180183 let prFee = value(getInteger(protocolFee()))
181184 let feeProtocolAmountCalc = fraction(toBigInt(amountIn), toBigInt(prFee), feeScale)
182185 let plFee = value(getInteger(poolFee()))
183186 let feePoolAmountCalc = fraction(toBigInt(amountIn), toBigInt(plFee), feeScale)
184187 let feeProtocolAmount = if ((toInt(feeProtocolAmountCalc) == 0))
185188 then toBigInt(1)
186189 else feeProtocolAmountCalc
187190 let feePoolAmount = if ((toInt(feePoolAmountCalc) == 0))
188191 then toBigInt(1)
189192 else feePoolAmountCalc
190193 let cleanAmountIn = ((toBigInt(amountIn) - feeProtocolAmount) - feePoolAmount)
191194 let checks = [if ((size(i.payments) == 1))
192195 then true
193196 else throw("exactly 1 payment are expected")]
194197 if ((checks == checks))
195198 then {
196- let $t051645242 = getPoolAddressAndCheckPoolStatus(assetIn, assetOut)
197- let poolAdr = $t051645242._1
198- let isReverse = $t051645242._2
199+ let $t052605338 = getPoolAddressAndCheckPoolStatus(assetIn, assetOut)
200+ let poolAdr = $t052605338._1
201+ let isReverse = $t052605338._2
199202 let assetInAttachedPayment = if ((assetIn == "WAVES"))
200203 then unit
201204 else fromBase58String(assetIn)
202205 let totalGetRaw = {
203- let @ = invoke(poolAdr, "calculateAmountOutForSwapAndSendTokens", [toInt(cleanAmountIn), isReverse, amountOutMin, addressTo], [AttachedPayment(assetInAttachedPayment, toInt(cleanAmountIn))])
206+ let @ = invoke(poolAdr, "calculateAmountOutForSwapAndSendTokens", [toInt(cleanAmountIn), isReverse, amountOutMin, addressTo, toInt(feePoolAmount)], [AttachedPayment(assetInAttachedPayment, toInt(cleanAmountIn))])
204207 if ($isInstanceOf(@, "Int"))
205208 then @
206209 else throw(($getType(@) + " couldn't be cast to Int"))
207210 }
208211 $Tuple2([ScriptTransfer(feeCollectorAddress, toInt(feeProtocolAmount), assetInAttachedPayment), ScriptTransfer(poolAdr, toInt(feePoolAmount), assetInAttachedPayment)], totalGetRaw)
209212 }
210213 else throw("Strict value is not equal to itself.")
211214 }
212215
213216
214217
215218 @Callable(i)
216219 func setManager (pendingManagerPublicKey) = {
217220 let checkCaller = mustManager(i)
218221 if ((checkCaller == checkCaller))
219222 then {
220223 let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey)
221224 if ((checkManagerPublicKey == checkManagerPublicKey))
222225 then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)]
223226 else throw("Strict value is not equal to itself.")
224227 }
225228 else throw("Strict value is not equal to itself.")
226229 }
227230
228231
229232
230233 @Callable(i)
231234 func confirmManager () = {
232235 let pm = pendingManagerPublicKeyOrUnit()
233236 let hasPM = if (isDefined(pm))
234237 then true
235238 else throw("no pending manager")
236239 if ((hasPM == hasPM))
237240 then {
238241 let checkPM = if ((i.callerPublicKey == value(pm)))
239242 then true
240243 else throw("you are not pending manager")
241244 if ((checkPM == checkPM))
242245 then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())]
243246 else throw("Strict value is not equal to itself.")
244247 }
245248 else throw("Strict value is not equal to itself.")
246249 }
247250
248251
249252 @Verifier(tx)
250253 func verify () = {
251254 let targetPublicKey = match managerPublicKeyOrUnit() {
252255 case pk: ByteVector =>
253256 pk
254257 case _: Unit =>
255258 tx.senderPublicKey
256259 case _ =>
257260 throw("Match error")
258261 }
259262 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
260263 }
261264

github/deemru/w8io/026f985 
38.43 ms