tx · 47XFd1viawS1782AFAiqcsWBSXUdtELv9ixndhRCcyCj

3N61RYWc9QuqKUwLvowpZZLpgUnqpQSFwLq:  -0.01000000 Waves

2024.03.04 12:34 [3003083] smart account 3N61RYWc9QuqKUwLvowpZZLpgUnqpQSFwLq > SELF 0.00000000 Waves

{ "type": 13, "id": "47XFd1viawS1782AFAiqcsWBSXUdtELv9ixndhRCcyCj", "fee": 1000000, "feeAssetId": null, "timestamp": 1709544882633, "version": 2, "chainId": 84, "sender": "3N61RYWc9QuqKUwLvowpZZLpgUnqpQSFwLq", "senderPublicKey": "HdwFH8HPYu3HG27yK6bszu1CdR4uik4HgzyTimeSfcYf", "proofs": [ "niFeiscvQMiGigwmK3tq4waABTg8L6jDpaagDMkQPhSrP2GFEfdeQWazLeGDHKarTV9NWX5EiFGuS62uvfiMcii" ], "script": "base64:BgIJCAISABIDCgEIEQAQYW1vdW50QXNzZXRJZEtleQINYW1vdW50QXNzZXRJZAAPcHJpY2VBc3NldElkS2V5AgxwcmljZUFzc2V0SWQACmZlZVJhdGVLZXkCB2ZlZVJhdGUBCmdldEFzc2V0SWQBDWFzc2V0SWRTdHJpbmcDCQAAAgUNYXNzZXRJZFN0cmluZwIFV0FWRVMFBHVuaXQJANkEAQUNYXNzZXRJZFN0cmluZwEPZ2V0QXNzZXRCYWxhbmNlAQdhc3NldElkBAckbWF0Y2gwBQdhc3NldElkAwkAAQIFByRtYXRjaDACCkJ5dGVWZWN0b3IEAmlkBQckbWF0Y2gwCQDwBwIFBHRoaXMFAmlkCAkA7wcBBQR0aGlzCWF2YWlsYWJsZQATYW1vdW50QXNzZXRJZFN0cmluZwkBEUBleHRyTmF0aXZlKDEwNTMpAgUEdGhpcwUQYW1vdW50QXNzZXRJZEtleQANYW1vdW50QXNzZXRJZAkBCmdldEFzc2V0SWQBBRNhbW91bnRBc3NldElkU3RyaW5nABJhbW91bnRBc3NldEJhbGFuY2UJAQ9nZXRBc3NldEJhbGFuY2UBBQ1hbW91bnRBc3N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HYXNzZXRJZAUMcHJpY2VBc3NldElkBgkAAgEJALkJAgkAzAgCAhtwYXltZW50IGFzc2V0SWQgc2hvdWxkIGJlICgJAMwIAgUTYW1vdW50QXNzZXRJZFN0cmluZwkAzAgCAgYpIG9yICgJAMwIAgUScHJpY2VBc3NldElkU3RyaW5nCQDMCAICASkFA25pbAIBIAUDbmlsAwkAAAIFBmNoZWNrcwUGY2hlY2tzBA5wYXltZW50QXNzZXRJZAgJAJEDAggFAWkIcGF5bWVudHMAAAdhc3NldElkBA1wYXltZW50QW1vdW50CAkAkQMCCAUBaQhwYXltZW50cwAABmFtb3VudAQLJHQwMjk4ODMwOTEJAQ5jYWxjU2VuZEFtb3VudAIFDnBheW1lbnRBc3NldElkBQ1wYXltZW50QW1vdW50BApzZW5kQW1vdW50CAULJHQwMjk4ODMwOTECXzEECWZlZUFtb3VudAgFCyR0MDI5ODgzMDkxAl8yBAtzZW5kQXNzZXRJZAgFCyR0MDI5ODgzMDkxAl8zBA11c2VyUmVhbFByaWNlCAULJHQwMjk4ODMwOTECXzQEC3NlbmRBY3Rpb25zAwkBAiE9AgUJZmVlQW1vdW50AAAJAMwIAgkBDlNjcmlwdFRyYW5zZmVyAwUHYWRkcmVzcwUKc2VuZEFtb3VudAULc2VuZEFzc2V0SWQFA25pbAkAAgECEWFtb3VudCBpcyB0b28gbG93CQCUCgIFC3NlbmRBY3Rpb25zCQCWCgQFCnNlbmRBbW91bnQFCWZlZUFtb3VudAULc2VuZEFzc2V0SWQFDXVzZXJSZWFsUHJpY2UJAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4CAWkBBHN3YXAACQEMc3dhcEludGVybmFsAggFAWkGY2FsbGVyBQFpAWkBB3N3YXBGb3IBB2FkZHJlc3MJAQxzd2FwSW50ZXJuYWwCCQERQGV4dHJOYXRpdmUoMTA2MikBBQdhZGRyZXNzBQFpAGOxTBY=", "height": 3003083, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: H6nozFM2yfZ3KB3F8zKweSGE18fi1PH9HA5cfpG858zS Next: 3RSuSX2HnzPk9WDn8is6wWyhe6fPwMcxBZvWSQF8mABE Diff:
OldNewDifferences
6565 let rawSendAmount = calcRawSendAmount(initAmBal, initPrBal, paymentAmount)
6666 let feeAmount = fraction(rawSendAmount, feeRate, SCALE8)
6767 let sendAmount = (rawSendAmount - feeAmount)
68- let userRealPrice = fraction(sendAmount, SCALE8, paymentAmount)
68+ let userRealPrice = if ((paymentAssetId == amountAssetId))
69+ then fraction(sendAmount, SCALE8, paymentAmount)
70+ else fraction(paymentAmount, SCALE8, sendAmount)
6971 $Tuple4(sendAmount, feeAmount, amAssetId, userRealPrice)
7072 }
7173
8284 then {
8385 let paymentAssetId = i.payments[0].assetId
8486 let paymentAmount = i.payments[0].amount
85- let $t028802983 = calcSendAmount(paymentAssetId, paymentAmount)
86- let sendAmount = $t028802983._1
87- let feeAmount = $t028802983._2
88- let sendAssetId = $t028802983._3
89- let userRealPrice = $t028802983._4
87+ let $t029883091 = calcSendAmount(paymentAssetId, paymentAmount)
88+ let sendAmount = $t029883091._1
89+ let feeAmount = $t029883091._2
90+ let sendAssetId = $t029883091._3
91+ let userRealPrice = $t029883091._4
9092 let sendActions = if ((feeAmount != 0))
9193 then [ScriptTransfer(address, sendAmount, sendAssetId)]
9294 else throw("amount is too low")
93- $Tuple2(sendActions, $Tuple3(sendAmount, feeAmount, userRealPrice))
95+ $Tuple2(sendActions, $Tuple4(sendAmount, feeAmount, sendAssetId, userRealPrice))
9496 }
9597 else throw("Strict value is not equal to itself.")
9698 }
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 sendAmount = (initAmBal - fraction(initAmBal, initPrBal, (initPrBal + paymentAmount)))
4141 let newAmBal = (initAmBal - sendAmount)
4242 let newPrBal = (initPrBal + paymentAmount)
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 (initAmBal,initPrBal,paymentAmount) = {
5050 let sendAmount = (initAmBal - fraction(initAmBal, initPrBal, (initPrBal + paymentAmount)))
5151 let newAmBal = (initAmBal - sendAmount)
5252 let newPrBal = (initPrBal + paymentAmount)
5353 sendAmount
5454 }
5555
5656
5757 func calcSendAmount (paymentAssetId,paymentAmount) = {
5858 let $t018391991 = if ((paymentAssetId == amountAssetId))
5959 then $Tuple2(priceAssetId, amountAssetId)
6060 else $Tuple2(amountAssetId, priceAssetId)
6161 let amAssetId = $t018391991._1
6262 let prAssetId = $t018391991._2
6363 let initAmBal = getAssetBalance(amAssetId)
6464 let initPrBal = (getAssetBalance(prAssetId) - paymentAmount)
6565 let rawSendAmount = calcRawSendAmount(initAmBal, initPrBal, paymentAmount)
6666 let feeAmount = fraction(rawSendAmount, feeRate, SCALE8)
6767 let sendAmount = (rawSendAmount - feeAmount)
68- let userRealPrice = fraction(sendAmount, SCALE8, paymentAmount)
68+ let userRealPrice = if ((paymentAssetId == amountAssetId))
69+ then fraction(sendAmount, SCALE8, paymentAmount)
70+ else fraction(paymentAmount, SCALE8, sendAmount)
6971 $Tuple4(sendAmount, feeAmount, amAssetId, userRealPrice)
7072 }
7173
7274
7375 func swapInternal (address,i) = {
7476 let checks = [if ((size(i.payments) > 0))
7577 then true
7678 else throw("should be with 1 payment"), if (if ((i.payments[0].assetId == amountAssetId))
7779 then true
7880 else (i.payments[0].assetId == priceAssetId))
7981 then true
8082 else throw(makeString(["payment assetId should be (", amountAssetIdString, ") or (", priceAssetIdString, ")"], " "))]
8183 if ((checks == checks))
8284 then {
8385 let paymentAssetId = i.payments[0].assetId
8486 let paymentAmount = i.payments[0].amount
85- let $t028802983 = calcSendAmount(paymentAssetId, paymentAmount)
86- let sendAmount = $t028802983._1
87- let feeAmount = $t028802983._2
88- let sendAssetId = $t028802983._3
89- let userRealPrice = $t028802983._4
87+ let $t029883091 = calcSendAmount(paymentAssetId, paymentAmount)
88+ let sendAmount = $t029883091._1
89+ let feeAmount = $t029883091._2
90+ let sendAssetId = $t029883091._3
91+ let userRealPrice = $t029883091._4
9092 let sendActions = if ((feeAmount != 0))
9193 then [ScriptTransfer(address, sendAmount, sendAssetId)]
9294 else throw("amount is too low")
93- $Tuple2(sendActions, $Tuple3(sendAmount, feeAmount, userRealPrice))
95+ $Tuple2(sendActions, $Tuple4(sendAmount, feeAmount, sendAssetId, userRealPrice))
9496 }
9597 else throw("Strict value is not equal to itself.")
9698 }
9799
98100
99101 @Callable(i)
100102 func swap () = swapInternal(i.caller, i)
101103
102104
103105
104106 @Callable(i)
105107 func swapFor (address) = swapInternal(addressFromStringValue(address), i)
106108
107109

github/deemru/w8io/169f3d6 
25.22 ms