tx · 84HimeExGbNgyFFNkU9A4yjPrvhocm7dgrGYy3yxz3vb

3N61RYWc9QuqKUwLvowpZZLpgUnqpQSFwLq:  -0.01000000 Waves

2024.03.04 12:50 [3003098] smart account 3N61RYWc9QuqKUwLvowpZZLpgUnqpQSFwLq > SELF 0.00000000 Waves

{ "type": 13, "id": "84HimeExGbNgyFFNkU9A4yjPrvhocm7dgrGYy3yxz3vb", "fee": 1000000, "feeAssetId": null, "timestamp": 1709545848145, "version": 2, "chainId": 84, "sender": "3N61RYWc9QuqKUwLvowpZZLpgUnqpQSFwLq", "senderPublicKey": "HdwFH8HPYu3HG27yK6bszu1CdR4uik4HgzyTimeSfcYf", "proofs": [ "5weY6zttZekUUD8rUUuaL1BUstuziaGZHy8QueDs4ZKqvc4fwKR8ZZx21Av9qJtxpAFtWJGMMmLi3WoJgWffyC2" ], "script": "base64:BgIJCAISABIDCgEIEAAQYW1vdW50QXNzZXRJZEtleQINYW1vdW50QXNzZXRJZAAPcHJpY2VBc3NldElkS2V5AgxwcmljZUFzc2V0SWQACmZlZVJhdGVLZXkCB2ZlZVJhdGUBCmdldEFzc2V0SWQBDWFzc2V0SWRTdHJpbmcDCQAAAgUNYXNzZXRJZFN0cmluZwIFV0FWRVMFBHVuaXQJANkEAQUNYXNzZXRJZFN0cmluZwEPZ2V0QXNzZXRCYWxhbmNlAQdhc3NldElkBAckbWF0Y2gwBQdhc3NldElkAwkAAQIFByRtYXRjaDACCkJ5dGVWZWN0b3IEAmlkBQckbWF0Y2gwCQDwBwIFBHRoaXMFAmlkCAkA7wcBBQR0aGlzCWF2YWlsYWJsZQATYW1vdW50QXNzZXRJZFN0cmluZwkBEUBleHRyTmF0aXZlKDEwNTMpAgUEdGhpcwUQYW1vdW50QXNzZXRJZEtleQANYW1vdW50QXNzZXRJZAkBCmdldEFzc2V0SWQBBRNhbW91bnRBc3NldElkU3RyaW5nABJhbW91bnRBc3NldEJhbGFuY2UJAQ9nZXRBc3NldEJhbGFuY2UBBQ1h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xBAlmZWVBbW91bnQIBQskdDAyNDg4MjU5MQJfMgQLc2VuZEFzc2V0SWQIBQskdDAyNDg4MjU5MQJfMwQNdXNlclJlYWxQcmljZQgFCyR0MDI0ODgyNTkxAl80BAtzZW5kQWN0aW9ucwMJAQIhPQIFCWZlZUFtb3VudAAACQDMCAIJAQ5TY3JpcHRUcmFuc2ZlcgMFB2FkZHJlc3MFCnNlbmRBbW91bnQFC3NlbmRBc3NldElkBQNuaWwJAAIBAhFhbW91bnQgaXMgdG9vIGxvdwkAlAoCBQtzZW5kQWN0aW9ucwkAlgoEBQpzZW5kQW1vdW50BQlmZWVBbW91bnQFC3NlbmRBc3NldElkBQ11c2VyUmVhbFByaWNlCQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAgFpAQRzd2FwAAkBDHN3YXBJbnRlcm5hbAIIBQFpBmNhbGxlcgUBaQFpAQdzd2FwRm9yAQdhZGRyZXNzCQEMc3dhcEludGVybmFsAgkBEUBleHRyTmF0aXZlKDEwNjIpAQUHYWRkcmVzcwUBaQBLIh4h", "height": 3003098, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 6KYVAw5XzxsofqQhM5rsfFRR6im2PGwTENNmbNiZmJiA Next: 33HXGRTLEydx9ES2EZ4HPKc3u7QdfMKTFKGnGxDSqMfc Diff:
OldNewDifferences
3636
3737 let feeRate = valueOrElse(getInteger(this, feeRateKey), 1000000)
3838
39-func ammCalc (initAmBal,initPrBal,paymentAmount) = {
39+func calcRawSendAmount (initAmBal,initPrBal,paymentAmount) = {
4040 let newPrBal = (initPrBal + paymentAmount)
4141 let newAmBal = fraction(initAmBal, initPrBal, newPrBal)
4242 let sendAmount = (initAmBal - newAmBal)
43- let newK = (newAmBal * newPrBal)
44- let oldK = (initAmBal * initPrBal)
45- $Tuple7(sendAmount, initAmBal, initPrBal, oldK, newAmBal, newPrBal, newK)
46- }
47-
48-
49-func calcRawSendAmount (amBal,prBal,paymentAmount) = {
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
5843 sendAmount
5944 }
6045
6146
6247 func calcSendAmount (paymentAssetId,paymentAmount) = {
63- let $t017941946 = if ((paymentAssetId == amountAssetId))
48+ let $t013391491 = if ((paymentAssetId == amountAssetId))
6449 then $Tuple2(priceAssetId, amountAssetId)
6550 else $Tuple2(amountAssetId, priceAssetId)
66- let amAssetId = $t017941946._1
67- let prAssetId = $t017941946._2
51+ let amAssetId = $t013391491._1
52+ let prAssetId = $t013391491._2
6853 let initAmBal = getAssetBalance(amAssetId)
6954 let initPrBal = (getAssetBalance(prAssetId) - paymentAmount)
7055 let rawSendAmount = calcRawSendAmount(initAmBal, initPrBal, paymentAmount)
8974 then {
9075 let paymentAssetId = i.payments[0].assetId
9176 let paymentAmount = i.payments[0].amount
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
77+ let $t024882591 = calcSendAmount(paymentAssetId, paymentAmount)
78+ let sendAmount = $t024882591._1
79+ let feeAmount = $t024882591._2
80+ let sendAssetId = $t024882591._3
81+ let userRealPrice = $t024882591._4
9782 let sendActions = if ((feeAmount != 0))
9883 then [ScriptTransfer(address, sendAmount, sendAssetId)]
9984 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
39-func ammCalc (initAmBal,initPrBal,paymentAmount) = {
39+func calcRawSendAmount (initAmBal,initPrBal,paymentAmount) = {
4040 let newPrBal = (initPrBal + paymentAmount)
4141 let newAmBal = fraction(initAmBal, initPrBal, newPrBal)
4242 let sendAmount = (initAmBal - newAmBal)
43- let newK = (newAmBal * newPrBal)
44- let oldK = (initAmBal * initPrBal)
45- $Tuple7(sendAmount, initAmBal, initPrBal, oldK, newAmBal, newPrBal, newK)
46- }
47-
48-
49-func calcRawSendAmount (amBal,prBal,paymentAmount) = {
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
5843 sendAmount
5944 }
6045
6146
6247 func calcSendAmount (paymentAssetId,paymentAmount) = {
63- let $t017941946 = if ((paymentAssetId == amountAssetId))
48+ let $t013391491 = if ((paymentAssetId == amountAssetId))
6449 then $Tuple2(priceAssetId, amountAssetId)
6550 else $Tuple2(amountAssetId, priceAssetId)
66- let amAssetId = $t017941946._1
67- let prAssetId = $t017941946._2
51+ let amAssetId = $t013391491._1
52+ let prAssetId = $t013391491._2
6853 let initAmBal = getAssetBalance(amAssetId)
6954 let initPrBal = (getAssetBalance(prAssetId) - paymentAmount)
7055 let rawSendAmount = calcRawSendAmount(initAmBal, initPrBal, paymentAmount)
7156 let feeAmount = fraction(rawSendAmount, feeRate, SCALE8)
7257 let sendAmount = (rawSendAmount - feeAmount)
7358 let userRealPrice = if ((paymentAssetId == amountAssetId))
7459 then fraction(sendAmount, SCALE8, paymentAmount)
7560 else fraction(paymentAmount, SCALE8, sendAmount)
7661 $Tuple4(sendAmount, feeAmount, amAssetId, userRealPrice)
7762 }
7863
7964
8065 func swapInternal (address,i) = {
8166 let checks = [if ((size(i.payments) > 0))
8267 then true
8368 else throw("should be with 1 payment"), if (if ((i.payments[0].assetId == amountAssetId))
8469 then true
8570 else (i.payments[0].assetId == priceAssetId))
8671 then true
8772 else throw(makeString(["payment assetId should be (", amountAssetIdString, ") or (", priceAssetIdString, ")"], " "))]
8873 if ((checks == checks))
8974 then {
9075 let paymentAssetId = i.payments[0].assetId
9176 let paymentAmount = i.payments[0].amount
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
77+ let $t024882591 = calcSendAmount(paymentAssetId, paymentAmount)
78+ let sendAmount = $t024882591._1
79+ let feeAmount = $t024882591._2
80+ let sendAssetId = $t024882591._3
81+ let userRealPrice = $t024882591._4
9782 let sendActions = if ((feeAmount != 0))
9883 then [ScriptTransfer(address, sendAmount, sendAssetId)]
9984 else throw("amount is too low")
10085 $Tuple2(sendActions, $Tuple4(sendAmount, feeAmount, sendAssetId, userRealPrice))
10186 }
10287 else throw("Strict value is not equal to itself.")
10388 }
10489
10590
10691 @Callable(i)
10792 func swap () = swapInternal(i.caller, i)
10893
10994
11095
11196 @Callable(i)
11297 func swapFor (address) = swapInternal(addressFromStringValue(address), i)
11398
11499

github/deemru/w8io/026f985 
48.93 ms