tx · Aqa2PjQNBQtuAGrfk4HVzGNDgTSJhossQtug3jbYkwL1

3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq:  -0.01100000 Waves

2024.07.15 10:03 [3194820] smart account 3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq > SELF 0.00000000 Waves

{ "type": 13, "id": "Aqa2PjQNBQtuAGrfk4HVzGNDgTSJhossQtug3jbYkwL1", "fee": 1100000, "feeAssetId": null, "timestamp": 1721027040519, "version": 1, "sender": "3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq", "senderPublicKey": "2u2wYYcVBQv43Cc71zkhHPPitkqgg6dqTZ3nUMvYJ1uq", "proofs": [ "4MrWKUq1G2zN14zvuaedcZ8a82fD3x6zjqYW7giCtskvLgF9UndKMBBsvjV58my642vZaUUqaYLWLA7UzQHmRrwj" ], "script": "base64:BgIQCAISBQoDAQgIEgUKAwEICBkAA1NFUAICX18ACGZlZVNjYWxlCQC2AgEAgMLXLwEPZ2V0U3RyaW5nT3JGYWlsAQNrZXkJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkAnQgCBQR0aGlzBQNrZXkJAKwCAgIVTm8gZGF0YSBmb3IgdGhpcy5rZXk9BQNrZXkADHBvb2xEaXNhYmxlZAkAAgECDVBvb2wgZGlzYWJsZWQADHBvb2xOb3RFeGlzdAkAAgECEVBvb2wgaXMgbm90IGV4aXN0AA5zbGlwcGFnZVRvb0JpZwkAAgECE1NsaXBwYWdlIGlzIHRvbyBiaWcBE2tleU1hbmFnZXJQdWJsaWNLZXkAAhQlc19fbWFuYWdlclB1YmxpY0tleQEWa2V5TWFuYWdlclZhdWx0QWRkcmVzcwACFyVzX19tYW5hZ2VyVmF1bHRBZGRyZXNzAQJmYwACEyVzX19mYWN0b3J5Q29udHJhY3QAD2ZhY3RvcnlDb250cmFjdAkBEUBleHRyTmF0aXZlKDEwNjIpAQkBD2dldFN0cmluZ09yRmFpbAEJAQJmYwABC3Byb3RvY29sRmVlA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IBQskdDA2NTA2NzEwMAJfMgkAlAoCCQDOCAIFEnByb3RvY29sRmVlQWN0aW9ucwkAzAgCCQEOU2NyaXB0VHJhbnNmZXIDBQdwb29sQWRyCQCgAwEFDWZlZVBvb2xBbW91bnQFFmFzc2V0SW5BdHRhY2hlZFBheW1lbnQJAMwIAgkBDlNjcmlwdFRyYW5zZmVyAwULYWRkcmVzc1RvX2EFC25ld1RvdGFsR2V0CQEPc3RyaW5nVG9Bc3NldElkAQUIYXNzZXRPdXQFA25pbAULbmV3VG90YWxHZXQJAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4BAnR4AQZ2ZXJpZnkABA90YXJnZXRQdWJsaWNLZXkEByRtYXRjaDAJARZtYW5hZ2VyUHVibGljS2V5T3JVbml0AAMJAAECBQckbWF0Y2gwAgpCeXRlVmVjdG9yBAJwawUHJG1hdGNoMAUCcGsDCQABAgUHJG1hdGNoMAIEVW5pdAgFAnR4D3NlbmRlclB1YmxpY0tleQkAAgECC01hdGNoIGVycm9yCQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAABQ90YXJnZXRQdWJsaWNLZXnz+huy", "chainId": 84, "height": 3194820, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: iagmBQd5s4ACoPgKuu5dDpiEWRo7oDUQSJ43x9jpEQA Next: EtVYfFaBUbs2evGPSU4RvB9nEUHYpAzej2tNzNm6ijmM Diff:
OldNewDifferences
9090 else assetBalance(this, fromBase58String(assetId))
9191
9292
93+func stringToAssetId (assetIdString) = if ((assetIdString == "WAVES"))
94+ then unit
95+ else fromBase58String(assetIdString)
96+
97+
9398 func getSwapFees (poolAddressStr) = {
9499 let poolFeeDefault = value(getInteger(this, poolFee()))
95100 let protocolFeeDefault = value(getInteger(this, protocolFee()))
115120 then @
116121 else unit
117122 }
118- let $t029983457 = if ((lpNonReverse != unit))
123+ let $t031283587 = if ((lpNonReverse != unit))
119124 then {
120125 let pool = {
121126 let @ = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [value(lpNonReverse)], nil)
136141 $Tuple2(true, pool)
137142 }
138143 else poolNotExist
139- let isReverse = $t029983457._1
140- let pool = $t029983457._2
144+ let isReverse = $t031283587._1
145+ let pool = $t031283587._2
141146 let poolStatus = {
142147 let @ = invoke(factoryContract, "getPoolStatusREADONLY", [pool], nil)
143148 if ($isInstanceOf(@, "Int"))
158163
159164 @Callable(i)
160165 func swapCalculateREADONLY (amountIn,assetIn,assetOut) = {
161- let $t038533931 = getPoolAddressAndCheckPoolStatus(assetIn, assetOut)
162- let poolAdr = $t038533931._1
163- let isReverse = $t038533931._2
164- let $t039353987 = getSwapFees(toString(poolAdr))
165- let plFee = $t039353987._1
166- let prFee = $t039353987._2
166+ let $t039834061 = getPoolAddressAndCheckPoolStatus(assetIn, assetOut)
167+ let poolAdr = $t039834061._1
168+ let isReverse = $t039834061._2
169+ let $t040654117 = getSwapFees(toString(poolAdr))
170+ let plFee = $t040654117._1
171+ let prFee = $t040654117._2
167172 let feeProtocolAmountCalc = fraction(toBigInt(amountIn), toBigInt(prFee), feeScale)
168173 let feePoolAmountCalc = fraction(toBigInt(amountIn), toBigInt(plFee), feeScale)
169174 let feeProtocolAmount = if ((toInt(feeProtocolAmountCalc) == 0))
194199 then "WAVES"
195200 else toBase58String(value(pmt.assetId))
196201 let amountIn = value(pmt.amount)
197- let $t050005078 = getPoolAddressAndCheckPoolStatus(assetIn, assetOut)
198- let poolAdr = $t050005078._1
199- let isReverse = $t050005078._2
200- let $t050815133 = getSwapFees(toString(poolAdr))
201- let plFee = $t050815133._1
202- let prFee = $t050815133._2
202+ let $t051305208 = getPoolAddressAndCheckPoolStatus(assetIn, assetOut)
203+ let poolAdr = $t051305208._1
204+ let isReverse = $t051305208._2
205+ let $t052115263 = getSwapFees(toString(poolAdr))
206+ let plFee = $t052115263._1
207+ let prFee = $t052115263._2
203208 let feeProtocolAmountCalc = fraction(toBigInt(amountIn), toBigInt(prFee), feeScale)
204209 let feePoolAmountCalc = fraction(toBigInt(amountIn), toBigInt(plFee), feeScale)
210+ let addressTo_a = addressFromStringValue(addressTo)
205211 let feeProtocolAmount = if ((toInt(feeProtocolAmountCalc) == 0))
206212 then toBigInt(1)
207213 else feeProtocolAmountCalc
208214 let feePoolAmount = if ((toInt(feePoolAmountCalc) == 0))
209215 then toBigInt(1)
210216 else feePoolAmountCalc
211- let cleanAmountIn = ((toBigInt(amountIn) - feeProtocolAmount) - feePoolAmount)
217+ let cleanAmountIn = if ((isReverse == true))
218+ then ((toBigInt(amountIn) - feeProtocolAmount) - feePoolAmount)
219+ else (toBigInt(amountIn) - feePoolAmount)
212220 let checks = [if ((size(i.payments) == 1))
213221 then true
214222 else throw("exactly 1 payment are expected")]
215223 if ((checks == checks))
216224 then {
217- let assetInAttachedPayment = if ((assetIn == "WAVES"))
218- then unit
219- else fromBase58String(assetIn)
225+ let assetInAttachedPayment = stringToAssetId(assetIn)
220226 let totalGetRaw = {
221- let @ = invoke(poolAdr, "calculateAmountOutForSwapAndSendTokens", [toInt(cleanAmountIn), isReverse, amountOutMin, addressTo, toInt(feePoolAmount)], [AttachedPayment(assetInAttachedPayment, toInt(cleanAmountIn))])
227+ let @ = invoke(poolAdr, "calculateAmountOutForSwapAndSendTokens", [toInt(cleanAmountIn), isReverse, amountOutMin, this, toInt(feePoolAmount)], [AttachedPayment(assetInAttachedPayment, toInt(cleanAmountIn))])
222228 if ($isInstanceOf(@, "Int"))
223229 then @
224230 else throw(($getType(@) + " couldn't be cast to Int"))
225231 }
226- $Tuple2([ScriptTransfer(feeCollectorAddress, toInt(feeProtocolAmount), assetInAttachedPayment), ScriptTransfer(poolAdr, toInt(feePoolAmount), assetInAttachedPayment)], totalGetRaw)
232+ let $t065067100 = if ((isReverse == true))
233+ then $Tuple2([ScriptTransfer(feeCollectorAddress, toInt(feeProtocolAmount), assetInAttachedPayment)], totalGetRaw)
234+ else {
235+ let feeProtocolFromGetCalc = fraction(toBigInt(totalGetRaw), toBigInt(prFee), feeScale)
236+ let feeProtocolAmountFromGet = if ((toInt(feeProtocolFromGetCalc) == 0))
237+ then toInt(toBigInt(1))
238+ else toInt(feeProtocolFromGetCalc)
239+ $Tuple2([ScriptTransfer(feeCollectorAddress, feeProtocolAmountFromGet, stringToAssetId(assetOut))], (totalGetRaw - feeProtocolAmountFromGet))
240+ }
241+ let protocolFeeActions = $t065067100._1
242+ let newTotalGet = $t065067100._2
243+ $Tuple2((protocolFeeActions ++ [ScriptTransfer(poolAdr, toInt(feePoolAmount), assetInAttachedPayment), ScriptTransfer(addressTo_a, newTotalGet, stringToAssetId(assetOut))]), newTotalGet)
227244 }
228245 else throw("Strict value is not equal to itself.")
229246 }
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 keyManagerVaultAddress () = "%s__managerVaultAddress"
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 getManagerVaultAddressOrThis () = match getString(keyManagerVaultAddress()) {
4242 case s: String =>
4343 addressFromStringValue(s)
4444 case _ =>
4545 this
4646 }
4747
4848
4949 func asInt (val) = match val {
5050 case valInt: Int =>
5151 valInt
5252 case _ =>
5353 throw("fail to cast into Int")
5454 }
5555
5656
5757 func dataMappingPoolAssets (internalAmountAssetStr,internalPriceAssetStr) = makeString(["%d%d", toString(internalAmountAssetStr), toString(internalPriceAssetStr)], SEP)
5858
5959
6060 func managerPublicKeyOrUnit () = {
6161 let managerVaultAddress = getManagerVaultAddressOrThis()
6262 match getString(managerVaultAddress, keyManagerPublicKey()) {
6363 case s: String =>
6464 fromBase58String(s)
6565 case _: Unit =>
6666 unit
6767 case _ =>
6868 throw("Match error")
6969 }
7070 }
7171
7272
7373 func isManager (i) = match managerPublicKeyOrUnit() {
7474 case pk: ByteVector =>
7575 (i.callerPublicKey == pk)
7676 case _: Unit =>
7777 (i.caller == this)
7878 case _ =>
7979 throw("Match error")
8080 }
8181
8282
8383 func mustManager (i) = if (isManager(i))
8484 then true
8585 else throw("permission denied")
8686
8787
8888 func getAccBalance (assetId) = if ((assetId == "WAVES"))
8989 then wavesBalance(this).available
9090 else assetBalance(this, fromBase58String(assetId))
9191
9292
93+func stringToAssetId (assetIdString) = if ((assetIdString == "WAVES"))
94+ then unit
95+ else fromBase58String(assetIdString)
96+
97+
9398 func getSwapFees (poolAddressStr) = {
9499 let poolFeeDefault = value(getInteger(this, poolFee()))
95100 let protocolFeeDefault = value(getInteger(this, protocolFee()))
96101 match invoke(factoryContract, "getSwapFeeREADONLY", [poolAddressStr], nil) {
97102 case fees: (Int, Int) =>
98103 $Tuple2(fees._1, fees._2)
99104 case _ =>
100105 $Tuple2(poolFeeDefault, protocolFeeDefault)
101106 }
102107 }
103108
104109
105110 func getPoolAddressAndCheckPoolStatus (assetIn,assetOut) = {
106111 let lpNonReverse = {
107112 let @ = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetIn, assetOut], nil)
108113 if ($isInstanceOf(@, "String"))
109114 then @
110115 else unit
111116 }
112117 let lpReverse = {
113118 let @ = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetOut, assetIn], nil)
114119 if ($isInstanceOf(@, "String"))
115120 then @
116121 else unit
117122 }
118- let $t029983457 = if ((lpNonReverse != unit))
123+ let $t031283587 = if ((lpNonReverse != unit))
119124 then {
120125 let pool = {
121126 let @ = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [value(lpNonReverse)], nil)
122127 if ($isInstanceOf(@, "String"))
123128 then @
124129 else throw(($getType(@) + " couldn't be cast to String"))
125130 }
126131 $Tuple2(false, pool)
127132 }
128133 else if ((lpReverse != unit))
129134 then {
130135 let pool = {
131136 let @ = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [value(lpReverse)], nil)
132137 if ($isInstanceOf(@, "String"))
133138 then @
134139 else throw(($getType(@) + " couldn't be cast to String"))
135140 }
136141 $Tuple2(true, pool)
137142 }
138143 else poolNotExist
139- let isReverse = $t029983457._1
140- let pool = $t029983457._2
144+ let isReverse = $t031283587._1
145+ let pool = $t031283587._2
141146 let poolStatus = {
142147 let @ = invoke(factoryContract, "getPoolStatusREADONLY", [pool], nil)
143148 if ($isInstanceOf(@, "Int"))
144149 then @
145150 else throw(($getType(@) + " couldn't be cast to Int"))
146151 }
147152 let check = if ((poolStatus == 1))
148153 then true
149154 else poolDisabled
150155 if ((check == check))
151156 then {
152157 let poolAdr = addressFromStringValue(valueOrElse(pool, ""))
153158 $Tuple2(poolAdr, isReverse)
154159 }
155160 else throw("Strict value is not equal to itself.")
156161 }
157162
158163
159164 @Callable(i)
160165 func swapCalculateREADONLY (amountIn,assetIn,assetOut) = {
161- let $t038533931 = getPoolAddressAndCheckPoolStatus(assetIn, assetOut)
162- let poolAdr = $t038533931._1
163- let isReverse = $t038533931._2
164- let $t039353987 = getSwapFees(toString(poolAdr))
165- let plFee = $t039353987._1
166- let prFee = $t039353987._2
166+ let $t039834061 = getPoolAddressAndCheckPoolStatus(assetIn, assetOut)
167+ let poolAdr = $t039834061._1
168+ let isReverse = $t039834061._2
169+ let $t040654117 = getSwapFees(toString(poolAdr))
170+ let plFee = $t040654117._1
171+ let prFee = $t040654117._2
167172 let feeProtocolAmountCalc = fraction(toBigInt(amountIn), toBigInt(prFee), feeScale)
168173 let feePoolAmountCalc = fraction(toBigInt(amountIn), toBigInt(plFee), feeScale)
169174 let feeProtocolAmount = if ((toInt(feeProtocolAmountCalc) == 0))
170175 then toBigInt(1)
171176 else feeProtocolAmountCalc
172177 let feePoolAmount = if ((toInt(feePoolAmountCalc) == 0))
173178 then toBigInt(1)
174179 else feePoolAmountCalc
175180 let cleanAmountIn = ((toBigInt(amountIn) - feeProtocolAmount) - feePoolAmount)
176181 let res = {
177182 let @ = invoke(poolAdr, "calculateAmountOutForSwapREADONLY", [toInt(cleanAmountIn), isReverse, toInt(feePoolAmount)], nil)
178183 if ($isInstanceOf(@, "Int"))
179184 then @
180185 else throw(($getType(@) + " couldn't be cast to Int"))
181186 }
182187 $Tuple2(nil, res)
183188 }
184189
185190
186191
187192 @Callable(i)
188193 func swap (amountOutMin,assetOutRaw,addressTo) = {
189194 let assetOut = if ((assetOutRaw == ""))
190195 then "WAVES"
191196 else assetOutRaw
192197 let pmt = value(i.payments[0])
193198 let assetIn = if ((pmt.assetId == unit))
194199 then "WAVES"
195200 else toBase58String(value(pmt.assetId))
196201 let amountIn = value(pmt.amount)
197- let $t050005078 = getPoolAddressAndCheckPoolStatus(assetIn, assetOut)
198- let poolAdr = $t050005078._1
199- let isReverse = $t050005078._2
200- let $t050815133 = getSwapFees(toString(poolAdr))
201- let plFee = $t050815133._1
202- let prFee = $t050815133._2
202+ let $t051305208 = getPoolAddressAndCheckPoolStatus(assetIn, assetOut)
203+ let poolAdr = $t051305208._1
204+ let isReverse = $t051305208._2
205+ let $t052115263 = getSwapFees(toString(poolAdr))
206+ let plFee = $t052115263._1
207+ let prFee = $t052115263._2
203208 let feeProtocolAmountCalc = fraction(toBigInt(amountIn), toBigInt(prFee), feeScale)
204209 let feePoolAmountCalc = fraction(toBigInt(amountIn), toBigInt(plFee), feeScale)
210+ let addressTo_a = addressFromStringValue(addressTo)
205211 let feeProtocolAmount = if ((toInt(feeProtocolAmountCalc) == 0))
206212 then toBigInt(1)
207213 else feeProtocolAmountCalc
208214 let feePoolAmount = if ((toInt(feePoolAmountCalc) == 0))
209215 then toBigInt(1)
210216 else feePoolAmountCalc
211- let cleanAmountIn = ((toBigInt(amountIn) - feeProtocolAmount) - feePoolAmount)
217+ let cleanAmountIn = if ((isReverse == true))
218+ then ((toBigInt(amountIn) - feeProtocolAmount) - feePoolAmount)
219+ else (toBigInt(amountIn) - feePoolAmount)
212220 let checks = [if ((size(i.payments) == 1))
213221 then true
214222 else throw("exactly 1 payment are expected")]
215223 if ((checks == checks))
216224 then {
217- let assetInAttachedPayment = if ((assetIn == "WAVES"))
218- then unit
219- else fromBase58String(assetIn)
225+ let assetInAttachedPayment = stringToAssetId(assetIn)
220226 let totalGetRaw = {
221- let @ = invoke(poolAdr, "calculateAmountOutForSwapAndSendTokens", [toInt(cleanAmountIn), isReverse, amountOutMin, addressTo, toInt(feePoolAmount)], [AttachedPayment(assetInAttachedPayment, toInt(cleanAmountIn))])
227+ let @ = invoke(poolAdr, "calculateAmountOutForSwapAndSendTokens", [toInt(cleanAmountIn), isReverse, amountOutMin, this, toInt(feePoolAmount)], [AttachedPayment(assetInAttachedPayment, toInt(cleanAmountIn))])
222228 if ($isInstanceOf(@, "Int"))
223229 then @
224230 else throw(($getType(@) + " couldn't be cast to Int"))
225231 }
226- $Tuple2([ScriptTransfer(feeCollectorAddress, toInt(feeProtocolAmount), assetInAttachedPayment), ScriptTransfer(poolAdr, toInt(feePoolAmount), assetInAttachedPayment)], totalGetRaw)
232+ let $t065067100 = if ((isReverse == true))
233+ then $Tuple2([ScriptTransfer(feeCollectorAddress, toInt(feeProtocolAmount), assetInAttachedPayment)], totalGetRaw)
234+ else {
235+ let feeProtocolFromGetCalc = fraction(toBigInt(totalGetRaw), toBigInt(prFee), feeScale)
236+ let feeProtocolAmountFromGet = if ((toInt(feeProtocolFromGetCalc) == 0))
237+ then toInt(toBigInt(1))
238+ else toInt(feeProtocolFromGetCalc)
239+ $Tuple2([ScriptTransfer(feeCollectorAddress, feeProtocolAmountFromGet, stringToAssetId(assetOut))], (totalGetRaw - feeProtocolAmountFromGet))
240+ }
241+ let protocolFeeActions = $t065067100._1
242+ let newTotalGet = $t065067100._2
243+ $Tuple2((protocolFeeActions ++ [ScriptTransfer(poolAdr, toInt(feePoolAmount), assetInAttachedPayment), ScriptTransfer(addressTo_a, newTotalGet, stringToAssetId(assetOut))]), newTotalGet)
227244 }
228245 else throw("Strict value is not equal to itself.")
229246 }
230247
231248
232249 @Verifier(tx)
233250 func verify () = {
234251 let targetPublicKey = match managerPublicKeyOrUnit() {
235252 case pk: ByteVector =>
236253 pk
237254 case _: Unit =>
238255 tx.senderPublicKey
239256 case _ =>
240257 throw("Match error")
241258 }
242259 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
243260 }
244261

github/deemru/w8io/169f3d6 
37.76 ms