tx · 4mAEE6mkGF31F2dz8awaZhAakdKKC1Xv3dWeoB8AAyR3

3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq:  -0.01100000 Waves

2024.11.19 14:36 [3378275] smart account 3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq > SELF 0.00000000 Waves

{ "type": 13, "id": "4mAEE6mkGF31F2dz8awaZhAakdKKC1Xv3dWeoB8AAyR3", "fee": 1100000, "feeAssetId": null, "timestamp": 1732016252155, "version": 1, "sender": "3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq", "senderPublicKey": "2u2wYYcVBQv43Cc71zkhHPPitkqgg6dqTZ3nUMvYJ1uq", "proofs": [ "58VyEDmddd7dYJtFEMzgFHYzWCYGSUPcqsZbhFbMk9k8AsRZ2ijmDqLz1EPi26Vq2bNgf85PXu3i36UTxzWQKvsR" ], "script": "base64:BgIQCAISBQoDAQgIEgUKAwEICBkAA1NFUAICX18ACGZlZVNjYWxlCQC2AgEAgMLXLwEPZ2V0U3RyaW5nT3JGYWlsAQNrZXkJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkAnQgCBQR0aGlzBQNrZXkJAKwCAgIVTm8gZGF0YSBmb3IgdGhpcy5rZXk9BQNrZXkADHBvb2xEaXNhYmxlZAkAAgECDVBvb2wgZGlzYWJsZWQADHBvb2xOb3RFeGlzdAkAAgECEVBvb2wgaXMgbm90IGV4aXN0AA5zbGlwcGFnZVRvb0JpZwkAAgECE1NsaXBwYWdlIGlzIHRvbyBiaWcBE2tleU1hbmFnZXJQdWJsaWNLZXkAAhQlc19fbWFuYWdlclB1YmxpY0tleQEWa2V5TWFuYWdlclZhdWx0QWRkcmVzcwACFyVzX19tYW5hZ2VyVmF1bHRBZGRyZXNzAQJmYwACEyVzX19mYWN0b3J5Q29udHJhY3QAD2ZhY3RvcnlDb250cmFjdAkBEUBleHRyTmF0aXZlKDEwNjIpAQkBD2dldFN0cmluZ09yRmFpbAEJAQJmYwABC3Byb3RvY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bWF0Y2gwAgRVbml0CAUCdHgPc2VuZGVyUHVibGljS2V5CQACAQILTWF0Y2ggZXJyb3IJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAFD3RhcmdldFB1YmxpY0tleZOeEmc=", "chainId": 84, "height": 3378275, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: Hdr2qht6YgFPXdN3fvAwRQhRZQq7LZRt5cDfuzKK2ehC Next: none Diff:
OldNewDifferences
187187 else throw(($getType(@) + " couldn't be cast to Int"))
188188 }
189189 let newTotalGet = if ((isReverse == true))
190- then totalGetRaw
190+ then max([0, totalGetRaw])
191191 else {
192192 let feeProtocolFromGetCalc = fraction(toBigInt(totalGetRaw), toBigInt(prFee), feeScale)
193193 let feeProtocolAmountFromGet = if ((toInt(feeProtocolFromGetCalc) == 0))
194194 then toInt(toBigInt(1))
195195 else toInt(feeProtocolFromGetCalc)
196- (totalGetRaw - feeProtocolAmountFromGet)
196+ max([0, (totalGetRaw - feeProtocolAmountFromGet)])
197197 }
198198 $Tuple2(nil, newTotalGet)
199199 }
215215 then "WAVES"
216216 else toBase58String(value(pmt.assetId))
217217 let amountIn = value(pmt.amount)
218- let $t059165994 = getPoolAddressAndCheckPoolStatus(assetIn, assetOut)
219- let poolAdr = $t059165994._1
220- let isReverse = $t059165994._2
221- let $t059976049 = getSwapFees(toString(poolAdr))
222- let plFee = $t059976049._1
223- let prFee = $t059976049._2
218+ let $t059386016 = getPoolAddressAndCheckPoolStatus(assetIn, assetOut)
219+ let poolAdr = $t059386016._1
220+ let isReverse = $t059386016._2
221+ let $t060196071 = getSwapFees(toString(poolAdr))
222+ let plFee = $t060196071._1
223+ let prFee = $t060196071._2
224224 let feeProtocolAmountCalc = fraction(toBigInt(amountIn), toBigInt(prFee), feeScale)
225225 let feePoolAmountCalc = fraction(toBigInt(amountIn), toBigInt(plFee), feeScale)
226226 let addressTo_a = addressFromStringValue(addressTo)
240240 then @
241241 else throw(($getType(@) + " couldn't be cast to Int"))
242242 }
243- let $t072077801 = if ((isReverse == true))
244- then $Tuple2([ScriptTransfer(feeCollectorAddress, toInt(feeProtocolAmount), assetInAttachedPayment)], totalGetRaw)
243+ let $t072297882 = if ((isReverse == true))
244+ then $Tuple2([ScriptTransfer(feeCollectorAddress, toInt(feeProtocolAmount), assetInAttachedPayment)], max([0, totalGetRaw]))
245245 else {
246246 let feeProtocolFromGetCalc = fraction(toBigInt(totalGetRaw), toBigInt(prFee), feeScale)
247247 let feeProtocolAmountFromGet = if ((toInt(feeProtocolFromGetCalc) == 0))
248248 then toInt(toBigInt(1))
249249 else toInt(feeProtocolFromGetCalc)
250- $Tuple2([ScriptTransfer(feeCollectorAddress, feeProtocolAmountFromGet, stringToAssetId(assetOut))], (totalGetRaw - feeProtocolAmountFromGet))
250+ $Tuple2([ScriptTransfer(feeCollectorAddress, feeProtocolAmountFromGet, stringToAssetId(assetOut))], max([0, (totalGetRaw - feeProtocolAmountFromGet)]))
251251 }
252- let protocolFeeActions = $t072077801._1
253- let newTotalGet = $t072077801._2
252+ let protocolFeeActions = $t072297882._1
253+ let newTotalGet = $t072297882._2
254254 $Tuple2((protocolFeeActions ++ [ScriptTransfer(poolAdr, toInt(feePoolAmount), assetInAttachedPayment), ScriptTransfer(addressTo_a, newTotalGet, stringToAssetId(assetOut))]), newTotalGet)
255255 }
256256 else throw("Strict value is not equal to itself.")
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
9393 func stringToAssetId (assetIdString) = if ((assetIdString == "WAVES"))
9494 then unit
9595 else fromBase58String(assetIdString)
9696
9797
9898 func getSwapFees (poolAddressStr) = {
9999 let poolFeeDefault = value(getInteger(this, poolFee()))
100100 let protocolFeeDefault = value(getInteger(this, protocolFee()))
101101 match invoke(factoryContract, "getSwapFeeREADONLY", [poolAddressStr], nil) {
102102 case fees: (Int, Int) =>
103103 $Tuple2(fees._1, fees._2)
104104 case _ =>
105105 $Tuple2(poolFeeDefault, protocolFeeDefault)
106106 }
107107 }
108108
109109
110110 func getPoolAddressAndCheckPoolStatus (assetIn,assetOut) = {
111111 let lpNonReverse = {
112112 let @ = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetIn, assetOut], nil)
113113 if ($isInstanceOf(@, "String"))
114114 then @
115115 else unit
116116 }
117117 let lpReverse = {
118118 let @ = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetOut, assetIn], nil)
119119 if ($isInstanceOf(@, "String"))
120120 then @
121121 else unit
122122 }
123123 let $t031283587 = if ((lpNonReverse != unit))
124124 then {
125125 let pool = {
126126 let @ = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [value(lpNonReverse)], nil)
127127 if ($isInstanceOf(@, "String"))
128128 then @
129129 else throw(($getType(@) + " couldn't be cast to String"))
130130 }
131131 $Tuple2(false, pool)
132132 }
133133 else if ((lpReverse != unit))
134134 then {
135135 let pool = {
136136 let @ = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [value(lpReverse)], nil)
137137 if ($isInstanceOf(@, "String"))
138138 then @
139139 else throw(($getType(@) + " couldn't be cast to String"))
140140 }
141141 $Tuple2(true, pool)
142142 }
143143 else poolNotExist
144144 let isReverse = $t031283587._1
145145 let pool = $t031283587._2
146146 let poolStatus = {
147147 let @ = invoke(factoryContract, "getPoolStatusREADONLY", [pool], nil)
148148 if ($isInstanceOf(@, "Int"))
149149 then @
150150 else throw(($getType(@) + " couldn't be cast to Int"))
151151 }
152152 let check = if ((poolStatus == 1))
153153 then true
154154 else poolDisabled
155155 if ((check == check))
156156 then {
157157 let poolAdr = addressFromStringValue(valueOrElse(pool, ""))
158158 $Tuple2(poolAdr, isReverse)
159159 }
160160 else throw("Strict value is not equal to itself.")
161161 }
162162
163163
164164 @Callable(i)
165165 func swapCalculateREADONLY (amountIn,assetIn,assetOut) = {
166166 let $t039834061 = getPoolAddressAndCheckPoolStatus(assetIn, assetOut)
167167 let poolAdr = $t039834061._1
168168 let isReverse = $t039834061._2
169169 let $t040654117 = getSwapFees(toString(poolAdr))
170170 let plFee = $t040654117._1
171171 let prFee = $t040654117._2
172172 let feeProtocolAmountCalc = fraction(toBigInt(amountIn), toBigInt(prFee), feeScale)
173173 let feePoolAmountCalc = fraction(toBigInt(amountIn), toBigInt(plFee), feeScale)
174174 let feeProtocolAmount = if ((toInt(feeProtocolAmountCalc) == 0))
175175 then toBigInt(1)
176176 else feeProtocolAmountCalc
177177 let feePoolAmount = if ((toInt(feePoolAmountCalc) == 0))
178178 then toBigInt(1)
179179 else feePoolAmountCalc
180180 let cleanAmountIn = if ((isReverse == true))
181181 then ((toBigInt(amountIn) - feeProtocolAmount) - feePoolAmount)
182182 else (toBigInt(amountIn) - feePoolAmount)
183183 let totalGetRaw = {
184184 let @ = invoke(poolAdr, "calculateAmountOutForSwapREADONLY", [toInt(cleanAmountIn), isReverse, toInt(feePoolAmount)], nil)
185185 if ($isInstanceOf(@, "Int"))
186186 then @
187187 else throw(($getType(@) + " couldn't be cast to Int"))
188188 }
189189 let newTotalGet = if ((isReverse == true))
190- then totalGetRaw
190+ then max([0, totalGetRaw])
191191 else {
192192 let feeProtocolFromGetCalc = fraction(toBigInt(totalGetRaw), toBigInt(prFee), feeScale)
193193 let feeProtocolAmountFromGet = if ((toInt(feeProtocolFromGetCalc) == 0))
194194 then toInt(toBigInt(1))
195195 else toInt(feeProtocolFromGetCalc)
196- (totalGetRaw - feeProtocolAmountFromGet)
196+ max([0, (totalGetRaw - feeProtocolAmountFromGet)])
197197 }
198198 $Tuple2(nil, newTotalGet)
199199 }
200200
201201
202202
203203 @Callable(i)
204204 func swap (amountOutMin,assetOutRaw,addressTo) = {
205205 let checks = [if ((size(i.payments) == 1))
206206 then true
207207 else throw("exactly 1 payment are expected")]
208208 if ((checks == checks))
209209 then {
210210 let assetOut = if ((assetOutRaw == ""))
211211 then "WAVES"
212212 else assetOutRaw
213213 let pmt = value(i.payments[0])
214214 let assetIn = if ((pmt.assetId == unit))
215215 then "WAVES"
216216 else toBase58String(value(pmt.assetId))
217217 let amountIn = value(pmt.amount)
218- let $t059165994 = getPoolAddressAndCheckPoolStatus(assetIn, assetOut)
219- let poolAdr = $t059165994._1
220- let isReverse = $t059165994._2
221- let $t059976049 = getSwapFees(toString(poolAdr))
222- let plFee = $t059976049._1
223- let prFee = $t059976049._2
218+ let $t059386016 = getPoolAddressAndCheckPoolStatus(assetIn, assetOut)
219+ let poolAdr = $t059386016._1
220+ let isReverse = $t059386016._2
221+ let $t060196071 = getSwapFees(toString(poolAdr))
222+ let plFee = $t060196071._1
223+ let prFee = $t060196071._2
224224 let feeProtocolAmountCalc = fraction(toBigInt(amountIn), toBigInt(prFee), feeScale)
225225 let feePoolAmountCalc = fraction(toBigInt(amountIn), toBigInt(plFee), feeScale)
226226 let addressTo_a = addressFromStringValue(addressTo)
227227 let feeProtocolAmount = if ((toInt(feeProtocolAmountCalc) == 0))
228228 then toBigInt(1)
229229 else feeProtocolAmountCalc
230230 let feePoolAmount = if ((toInt(feePoolAmountCalc) == 0))
231231 then toBigInt(1)
232232 else feePoolAmountCalc
233233 let cleanAmountIn = if ((isReverse == true))
234234 then ((toBigInt(amountIn) - feeProtocolAmount) - feePoolAmount)
235235 else (toBigInt(amountIn) - feePoolAmount)
236236 let assetInAttachedPayment = stringToAssetId(assetIn)
237237 let totalGetRaw = {
238238 let @ = invoke(poolAdr, "calculateAmountOutForSwapAndSendTokens", [toInt(cleanAmountIn), isReverse, amountOutMin, toString(this), toInt(feePoolAmount)], [AttachedPayment(assetInAttachedPayment, toInt(cleanAmountIn))])
239239 if ($isInstanceOf(@, "Int"))
240240 then @
241241 else throw(($getType(@) + " couldn't be cast to Int"))
242242 }
243- let $t072077801 = if ((isReverse == true))
244- then $Tuple2([ScriptTransfer(feeCollectorAddress, toInt(feeProtocolAmount), assetInAttachedPayment)], totalGetRaw)
243+ let $t072297882 = if ((isReverse == true))
244+ then $Tuple2([ScriptTransfer(feeCollectorAddress, toInt(feeProtocolAmount), assetInAttachedPayment)], max([0, totalGetRaw]))
245245 else {
246246 let feeProtocolFromGetCalc = fraction(toBigInt(totalGetRaw), toBigInt(prFee), feeScale)
247247 let feeProtocolAmountFromGet = if ((toInt(feeProtocolFromGetCalc) == 0))
248248 then toInt(toBigInt(1))
249249 else toInt(feeProtocolFromGetCalc)
250- $Tuple2([ScriptTransfer(feeCollectorAddress, feeProtocolAmountFromGet, stringToAssetId(assetOut))], (totalGetRaw - feeProtocolAmountFromGet))
250+ $Tuple2([ScriptTransfer(feeCollectorAddress, feeProtocolAmountFromGet, stringToAssetId(assetOut))], max([0, (totalGetRaw - feeProtocolAmountFromGet)]))
251251 }
252- let protocolFeeActions = $t072077801._1
253- let newTotalGet = $t072077801._2
252+ let protocolFeeActions = $t072297882._1
253+ let newTotalGet = $t072297882._2
254254 $Tuple2((protocolFeeActions ++ [ScriptTransfer(poolAdr, toInt(feePoolAmount), assetInAttachedPayment), ScriptTransfer(addressTo_a, newTotalGet, stringToAssetId(assetOut))]), newTotalGet)
255255 }
256256 else throw("Strict value is not equal to itself.")
257257 }
258258
259259
260260 @Verifier(tx)
261261 func verify () = {
262262 let targetPublicKey = match managerPublicKeyOrUnit() {
263263 case pk: ByteVector =>
264264 pk
265265 case _: Unit =>
266266 tx.senderPublicKey
267267 case _ =>
268268 throw("Match error")
269269 }
270270 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
271271 }
272272

github/deemru/w8io/026f985 
34.31 ms