tx · 6KYVAw5XzxsofqQhM5rsfFRR6im2PGwTENNmbNiZmJiA

3N61RYWc9QuqKUwLvowpZZLpgUnqpQSFwLq:  -0.01000000 Waves

2024.03.04 12:40 [3003089] smart account 3N61RYWc9QuqKUwLvowpZZLpgUnqpQSFwLq > SELF 0.00000000 Waves

{ "type": 13, "id": "6KYVAw5XzxsofqQhM5rsfFRR6im2PGwTENNmbNiZmJiA", "fee": 1000000, "feeAssetId": null, "timestamp": 1709545213972, "version": 2, "chainId": 84, "sender": "3N61RYWc9QuqKUwLvowpZZLpgUnqpQSFwLq", "senderPublicKey": "HdwFH8HPYu3HG27yK6bszu1CdR4uik4HgzyTimeSfcYf", "proofs": [ "v2aBg47zsymhTHg6bYBXrTM8m5UNFdWGQFeUNh4VqVMZVHUE7fpQU21a5k84qR6FdwRfQnJZtQcUaoijc2LX7qM" ], "script": "base64:BgIJCAISABIDCgEIEQAQYW1vdW50QXNzZXRJZEtleQINYW1vdW50QXNzZXRJZAAPcHJpY2VBc3NldElkS2V5AgxwcmljZUFzc2V0SWQACmZlZVJhdGVLZXkCB2ZlZVJhdGUBCmdldEFzc2V0SWQBDWFzc2V0SWRTdHJpbmcDCQAAAgUNYXNzZXRJZFN0cmluZwIFV0FWRVMFBHVuaXQJANkEAQUNYXNzZXRJZFN0cmluZwEPZ2V0QXNzZXRCYWxhbmNlAQdhc3NldElkBAckbWF0Y2gwBQdhc3NldElkAwkAAQIFByRtYXRjaDACCkJ5dGVWZWN0b3IEAmlkBQckbWF0Y2gwCQDwBwIFBHRoaXMFAmlkCAkA7wcBBQR0aGlzCWF2YWlsYWJsZQATYW1vdW50QXNzZXRJZFN0cmluZwkBEUBleHRyTmF0aXZlKDEwNTMpAgUEdGhpcwUQYW1vdW50QXNzZXRJZEtleQANYW1vdW50QXNzZXRJZAkBCmdldEFzc2V0SWQBBRNhbW91bnRBc3NldElkU3RyaW5nABJhbW91bnRBc3NldEJhbGFuY2UJAQ9nZXRBc3NldEJhbGFuY2UBBQ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mUoMTA2MikBBQdhZGRyZXNzBQFpAKhIVsM=", "height": 3003089, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 3RSuSX2HnzPk9WDn8is6wWyhe6fPwMcxBZvWSQF8mABE Next: 84HimeExGbNgyFFNkU9A4yjPrvhocm7dgrGYy3yxz3vb Diff:
OldNewDifferences
3838
3939 func ammCalc (initAmBal,initPrBal,paymentAmount) = {
4040 let newPrBal = (initPrBal + paymentAmount)
41- let newAmBal = (initAmBal - fraction(initAmBal, initPrBal, newPrBal))
41+ let newAmBal = fraction(initAmBal, initPrBal, newPrBal)
4242 let sendAmount = (initAmBal - newAmBal)
4343 let newK = (newAmBal * newPrBal)
4444 let oldK = (initAmBal * initPrBal)
4747
4848
4949 func calcRawSendAmount (amBal,prBal,paymentAmount) = {
50- let $t015341705 = ammCalc(amBal, prBal, paymentAmount)
51- let sendAmount = $t015341705._1
52- let initAmBal = $t015341705._2
53- let initPrBal = $t015341705._3
54- let oldK = $t015341705._4
55- let newAmBal = $t015341705._5
56- let newPrBal = $t015341705._6
57- let newK = $t015341705._7
50+ let $t015221693 = ammCalc(amBal, prBal, paymentAmount)
51+ let sendAmount = $t015221693._1
52+ let initAmBal = $t015221693._2
53+ let initPrBal = $t015221693._3
54+ let oldK = $t015221693._4
55+ let newAmBal = $t015221693._5
56+ let newPrBal = $t015221693._6
57+ let newK = $t015221693._7
5858 sendAmount
5959 }
6060
6161
6262 func calcSendAmount (paymentAssetId,paymentAmount) = {
63- let $t018061958 = if ((paymentAssetId == amountAssetId))
63+ let $t017941946 = if ((paymentAssetId == amountAssetId))
6464 then $Tuple2(priceAssetId, amountAssetId)
6565 else $Tuple2(amountAssetId, priceAssetId)
66- let amAssetId = $t018061958._1
67- let prAssetId = $t018061958._2
66+ let amAssetId = $t017941946._1
67+ let prAssetId = $t017941946._2
6868 let initAmBal = getAssetBalance(amAssetId)
6969 let initPrBal = (getAssetBalance(prAssetId) - paymentAmount)
7070 let rawSendAmount = calcRawSendAmount(initAmBal, initPrBal, paymentAmount)
8989 then {
9090 let paymentAssetId = i.payments[0].assetId
9191 let paymentAmount = i.payments[0].amount
92- let $t029553058 = calcSendAmount(paymentAssetId, paymentAmount)
93- let sendAmount = $t029553058._1
94- let feeAmount = $t029553058._2
95- let sendAssetId = $t029553058._3
96- let userRealPrice = $t029553058._4
92+ let $t029433046 = calcSendAmount(paymentAssetId, paymentAmount)
93+ let sendAmount = $t029433046._1
94+ let feeAmount = $t029433046._2
95+ let sendAssetId = $t029433046._3
96+ let userRealPrice = $t029433046._4
9797 let sendActions = if ((feeAmount != 0))
9898 then [ScriptTransfer(address, sendAmount, sendAssetId)]
9999 else throw("amount is too low")
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 amountAssetBalance = getAssetBalance(amountAssetId)
2828
2929 let priceAssetIdString = getStringValue(this, priceAssetIdKey)
3030
3131 let priceAssetId = getAssetId(priceAssetIdString)
3232
3333 let priceAssetBalance = getAssetBalance(priceAssetId)
3434
3535 let SCALE8 = 100000000
3636
3737 let feeRate = valueOrElse(getInteger(this, feeRateKey), 1000000)
3838
3939 func ammCalc (initAmBal,initPrBal,paymentAmount) = {
4040 let newPrBal = (initPrBal + paymentAmount)
41- let newAmBal = (initAmBal - fraction(initAmBal, initPrBal, newPrBal))
41+ let newAmBal = fraction(initAmBal, initPrBal, newPrBal)
4242 let sendAmount = (initAmBal - newAmBal)
4343 let newK = (newAmBal * newPrBal)
4444 let oldK = (initAmBal * initPrBal)
4545 $Tuple7(sendAmount, initAmBal, initPrBal, oldK, newAmBal, newPrBal, newK)
4646 }
4747
4848
4949 func calcRawSendAmount (amBal,prBal,paymentAmount) = {
50- let $t015341705 = ammCalc(amBal, prBal, paymentAmount)
51- let sendAmount = $t015341705._1
52- let initAmBal = $t015341705._2
53- let initPrBal = $t015341705._3
54- let oldK = $t015341705._4
55- let newAmBal = $t015341705._5
56- let newPrBal = $t015341705._6
57- let newK = $t015341705._7
50+ let $t015221693 = ammCalc(amBal, prBal, paymentAmount)
51+ let sendAmount = $t015221693._1
52+ let initAmBal = $t015221693._2
53+ let initPrBal = $t015221693._3
54+ let oldK = $t015221693._4
55+ let newAmBal = $t015221693._5
56+ let newPrBal = $t015221693._6
57+ let newK = $t015221693._7
5858 sendAmount
5959 }
6060
6161
6262 func calcSendAmount (paymentAssetId,paymentAmount) = {
63- let $t018061958 = if ((paymentAssetId == amountAssetId))
63+ let $t017941946 = if ((paymentAssetId == amountAssetId))
6464 then $Tuple2(priceAssetId, amountAssetId)
6565 else $Tuple2(amountAssetId, priceAssetId)
66- let amAssetId = $t018061958._1
67- let prAssetId = $t018061958._2
66+ let amAssetId = $t017941946._1
67+ let prAssetId = $t017941946._2
6868 let initAmBal = getAssetBalance(amAssetId)
6969 let initPrBal = (getAssetBalance(prAssetId) - paymentAmount)
7070 let rawSendAmount = calcRawSendAmount(initAmBal, initPrBal, paymentAmount)
7171 let feeAmount = fraction(rawSendAmount, feeRate, SCALE8)
7272 let sendAmount = (rawSendAmount - feeAmount)
7373 let userRealPrice = if ((paymentAssetId == amountAssetId))
7474 then fraction(sendAmount, SCALE8, paymentAmount)
7575 else fraction(paymentAmount, SCALE8, sendAmount)
7676 $Tuple4(sendAmount, feeAmount, amAssetId, userRealPrice)
7777 }
7878
7979
8080 func swapInternal (address,i) = {
8181 let checks = [if ((size(i.payments) > 0))
8282 then true
8383 else throw("should be with 1 payment"), if (if ((i.payments[0].assetId == amountAssetId))
8484 then true
8585 else (i.payments[0].assetId == priceAssetId))
8686 then true
8787 else throw(makeString(["payment assetId should be (", amountAssetIdString, ") or (", priceAssetIdString, ")"], " "))]
8888 if ((checks == checks))
8989 then {
9090 let paymentAssetId = i.payments[0].assetId
9191 let paymentAmount = i.payments[0].amount
92- let $t029553058 = calcSendAmount(paymentAssetId, paymentAmount)
93- let sendAmount = $t029553058._1
94- let feeAmount = $t029553058._2
95- let sendAssetId = $t029553058._3
96- let userRealPrice = $t029553058._4
92+ let $t029433046 = calcSendAmount(paymentAssetId, paymentAmount)
93+ let sendAmount = $t029433046._1
94+ let feeAmount = $t029433046._2
95+ let sendAssetId = $t029433046._3
96+ let userRealPrice = $t029433046._4
9797 let sendActions = if ((feeAmount != 0))
9898 then [ScriptTransfer(address, sendAmount, sendAssetId)]
9999 else throw("amount is too low")
100100 $Tuple2(sendActions, $Tuple4(sendAmount, feeAmount, sendAssetId, userRealPrice))
101101 }
102102 else throw("Strict value is not equal to itself.")
103103 }
104104
105105
106106 @Callable(i)
107107 func swap () = swapInternal(i.caller, i)
108108
109109
110110
111111 @Callable(i)
112112 func swapFor (address) = swapInternal(addressFromStringValue(address), i)
113113
114114

github/deemru/w8io/026f985 
40.80 ms