tx · AUT1JaVsQcktijNetUsnNgs9p94j3aQHep5BLzF3mtAF

3N61RYWc9QuqKUwLvowpZZLpgUnqpQSFwLq:  -0.01000000 Waves

2024.03.04 14:45 [3003223] smart account 3N61RYWc9QuqKUwLvowpZZLpgUnqpQSFwLq > SELF 0.00000000 Waves

{ "type": 13, "id": "AUT1JaVsQcktijNetUsnNgs9p94j3aQHep5BLzF3mtAF", "fee": 1000000, "feeAssetId": null, "timestamp": 1709552727926, "version": 2, "chainId": 84, "sender": "3N61RYWc9QuqKUwLvowpZZLpgUnqpQSFwLq", "senderPublicKey": "HdwFH8HPYu3HG27yK6bszu1CdR4uik4HgzyTimeSfcYf", "proofs": [ "AE4b8w5WZkDKtuWwx2xPXG5HR3o6VmNuaU1JjN8ATTjF3ECdFHqPDx3Dtq55D578R26bLYUx2gGMG5pA6M5rL1t" ], "script": "base64:BgIOCAISABIDCgEBEgMKAQgPABBhbW91bnRBc3NldElkS2V5Ag1hbW91bnRBc3NldElkAA9wcmljZUFzc2V0SWRLZXkCDHByaWNlQXNzZXRJZAAKZmVlUmF0ZUtleQIHZmVlUmF0ZQEKZ2V0QXNzZXRJZAENYXNzZXRJZFN0cmluZwMJAAACBQ1hc3NldElkU3RyaW5nAgVXQVZFUwUEdW5pdAkA2QQBBQ1hc3NldElkU3RyaW5nAQ9nZXRBc3NldEJhbGFuY2UBB2Fzc2V0SWQEByRtYXRjaDAFB2Fzc2V0SWQDCQABAgUHJG1hdGNoMAIKQnl0ZVZlY3RvcgQCaWQFByRtYXRjaDAJAPAHAgUEdGhpcwUCaWQICQDvBwEFBHRoaXMJYXZhaWxhYmxlABNhbW91bnRBc3NldElkU3RyaW5nCQERQGV4dHJOYXRpdmUoMTA1MykCBQR0aGlzBRBhbW91bnRBc3NldElkS2V5AA1hbW91bnRBc3NldElkCQEKZ2V0QXNzZXRJZAEFE2Ftb3VudEFzc2V0SWRTdHJpbmcAEnByaWNlQXNzZXRJZFN0cmluZwkBEUBleHRyTmF0aXZlK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mUoMTA2MikBBQdhZGRyZXNzBQFpADRaQeA=", "height": 3003223, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 2TXNUoCatBrgcHKhwMQcQstCekjbmLRbzv2i4wygavVN Next: 62q9vi4LD3HiJ5WcLB9THCwBaxTnGJojVLAywVhPULra Diff:
OldNewDifferences
3232
3333 let feeRate = valueOrElse(getInteger(this, feeRateKey), 200000)
3434
35-func calcPrice () = fraction(getAssetBalance(amountAssetId), SCALE8, getAssetBalance(priceAssetId))
35+func calcPrice () = fraction(getAssetBalance(priceAssetId), SCALE8, getAssetBalance(amountAssetId))
3636
3737
3838 func calcRawSendAmount (initAmBal,initPrBal,paymentAmount) = {
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let amountAssetIdKey = "amountAssetId"
55
66 let priceAssetIdKey = "priceAssetId"
77
88 let feeRateKey = "feeRate"
99
1010 func getAssetId (assetIdString) = if ((assetIdString == "WAVES"))
1111 then unit
1212 else fromBase58String(assetIdString)
1313
1414
1515 func getAssetBalance (assetId) = match assetId {
1616 case id: ByteVector =>
1717 assetBalance(this, id)
1818 case _ =>
1919 wavesBalance(this).available
2020 }
2121
2222
2323 let amountAssetIdString = getStringValue(this, amountAssetIdKey)
2424
2525 let amountAssetId = getAssetId(amountAssetIdString)
2626
2727 let priceAssetIdString = getStringValue(this, priceAssetIdKey)
2828
2929 let priceAssetId = getAssetId(priceAssetIdString)
3030
3131 let SCALE8 = 100000000
3232
3333 let feeRate = valueOrElse(getInteger(this, feeRateKey), 200000)
3434
35-func calcPrice () = fraction(getAssetBalance(amountAssetId), SCALE8, getAssetBalance(priceAssetId))
35+func calcPrice () = fraction(getAssetBalance(priceAssetId), SCALE8, getAssetBalance(amountAssetId))
3636
3737
3838 func calcRawSendAmount (initAmBal,initPrBal,paymentAmount) = {
3939 let newPrBal = (initPrBal + paymentAmount)
4040 let newAmBal = fraction(initAmBal, initPrBal, newPrBal)
4141 let sendAmount = (initAmBal - newAmBal)
4242 sendAmount
4343 }
4444
4545
4646 func calcSendAmount (paymentAssetId,paymentAmount) = {
4747 let $t013381490 = if ((paymentAssetId == amountAssetId))
4848 then $Tuple2(priceAssetId, amountAssetId)
4949 else $Tuple2(amountAssetId, priceAssetId)
5050 let amAssetId = $t013381490._1
5151 let prAssetId = $t013381490._2
5252 let initAmBal = getAssetBalance(amAssetId)
5353 let initPrBal = (getAssetBalance(prAssetId) - paymentAmount)
5454 let rawSendAmount = calcRawSendAmount(initAmBal, initPrBal, paymentAmount)
5555 let feeAmount = fraction(rawSendAmount, feeRate, SCALE8)
5656 let sendAmount = (rawSendAmount - feeAmount)
5757 let userRealPrice = if ((paymentAssetId == amountAssetId))
5858 then fraction(sendAmount, SCALE8, paymentAmount)
5959 else fraction(paymentAmount, SCALE8, sendAmount)
6060 $Tuple4(sendAmount, feeAmount, amAssetId, userRealPrice)
6161 }
6262
6363
6464 func swapInternal (address,i) = {
6565 let checks = [if ((size(i.payments) > 0))
6666 then true
6767 else throw("should be with 1 payment"), if (containsElement([amountAssetId, priceAssetId], i.payments[0].assetId))
6868 then true
6969 else throw(makeString(["payment assetId should be", amountAssetIdString, "or", priceAssetIdString], " "))]
7070 if ((checks == checks))
7171 then {
7272 let paymentAssetId = i.payments[0].assetId
7373 let paymentAmount = i.payments[0].amount
7474 let $t024672570 = calcSendAmount(paymentAssetId, paymentAmount)
7575 let sendAmount = $t024672570._1
7676 let feeAmount = $t024672570._2
7777 let sendAssetId = $t024672570._3
7878 let userRealPrice = $t024672570._4
7979 let sendActions = if ((feeAmount > 0))
8080 then [ScriptTransfer(address, sendAmount, sendAssetId)]
8181 else throw("amount is too low")
8282 $Tuple2(sendActions, $Tuple4(sendAmount, feeAmount, sendAssetId, userRealPrice))
8383 }
8484 else throw("Strict value is not equal to itself.")
8585 }
8686
8787
8888 @Callable(i)
8989 func swap () = swapInternal(i.caller, i)
9090
9191
9292
9393 @Callable(i)
9494 func swapNoLess (minAmount) = {
9595 let $t029282980 = swapInternal(i.caller, i)
9696 let sendActions = $t029282980._1
9797 let tuple = $t029282980._2
9898 let $t029853048 = tuple
9999 let sendAmount = $t029853048._1
100100 let feeAmount = $t029853048._2
101101 let sendAssetId = $t029853048._3
102102 let userRealPrice = $t029853048._4
103103 if ((minAmount > sendAmount))
104104 then throw(makeString(["Price slipped. minAmount: ", toString(minAmount), " swapAmount: ", toString(sendAmount)], ""))
105105 else $Tuple2(sendActions, tuple)
106106 }
107107
108108
109109
110110 @Callable(i)
111111 func swapFor (address) = swapInternal(addressFromStringValue(address), i)
112112
113113

github/deemru/w8io/169f3d6 
26.80 ms