tx · HhD2BVD5Nrzp9NkMnioivX7qSq4THeTBajYR1mXwDVQZ

3N61RYWc9QuqKUwLvowpZZLpgUnqpQSFwLq:  -0.01000000 Waves

2024.03.07 12:11 [3007424] smart account 3N61RYWc9QuqKUwLvowpZZLpgUnqpQSFwLq > SELF 0.00000000 Waves

{ "type": 13, "id": "HhD2BVD5Nrzp9NkMnioivX7qSq4THeTBajYR1mXwDVQZ", "fee": 1000000, "feeAssetId": null, "timestamp": 1709802704104, "version": 2, "chainId": 84, "sender": "3N61RYWc9QuqKUwLvowpZZLpgUnqpQSFwLq", "senderPublicKey": "HdwFH8HPYu3HG27yK6bszu1CdR4uik4HgzyTimeSfcYf", "proofs": [ "4WxeMLDqNi97kukGR5guLan4wqAFD8h8gPGt14iUzHZmaBzVbgh3yKgSrHtKCuWRCghF1Fs4bDCAAioNHf8oLa42" ], "script": "base64:BgIOCAISABIDCgEBEgMKAQgQABBhbW91bnRBc3NldElkS2V5Ag1hbW91bnRBc3NldElkAA9wcmljZUFzc2V0SWRLZXkCDHByaWNlQXNzZXRJZAAKZmVlUmF0ZUtleQIHZmVlUmF0ZQEKZ2V0QXNzZXRJZAENYXNzZXRJZFN0cmluZwMJAAACBQ1hc3NldElkU3RyaW5nAgVXQVZFUwUEdW5pdAkA2QQBBQ1hc3NldElkU3RyaW5nAQ9nZXRBc3NldEJhbGFuY2UBB2Fzc2V0SWQEByRtYXRjaDAFB2Fzc2V0SWQDCQABAgUHJG1hdGNoMAIKQnl0ZVZlY3RvcgQCaWQFByRtYXRjaDAJAPAHAgUEdGhpcwUCaWQICQDvBwEFBHRoaXMJYXZhaWxhYmxlABNhbW91bnRBc3NldElkU3RyaW5nCQERQGV4dHJOYXRpdmUoMTA1MykCBQR0aGlzBRBhbW91bnRBc3NldElkS2V5AA1hbW91bnRBc3NldElkCQEKZ2V0QXNzZXRJZAEFE2Ftb3VudEFzc2V0SWRTdHJpbmcAEnByaWNlQXNzZXRJZFN0cmluZwkBEUBleHRyTmF0aX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bW91bnQIBQskdDAzMzE5MzM4MgJfMQQJZmVlQW1vdW50CAULJHQwMzMxOTMzODICXzIEC3NlbmRBc3NldElkCAULJHQwMzMxOTMzODICXzMEDXVzZXJSZWFsUHJpY2UIBQskdDAzMzE5MzM4MgJfNAMJAGYCBQltaW5BbW91bnQFCnNlbmRBbW91bnQJAAIBCQC5CQIJAMwIAgIaUHJpY2Ugc2xpcHBlZC4gbWluQW1vdW50OiAJAMwIAgkApAMBBQltaW5BbW91bnQJAMwIAgINIHN3YXBBbW91bnQ6IAkAzAgCCQCkAwEFCnNlbmRBbW91bnQFA25pbAIACQCUCgIFC3NlbmRBY3Rpb25zBQV0dXBsZQFpAQdzd2FwRm9yAQdhZGRyZXNzCQEMc3dhcEludGVybmFsAgkBEUBleHRyTmF0aXZlKDEwNjIpAQUHYWRkcmVzcwUBaQDrQitC", "height": 3007424, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: Dsqx1vYTXVkoXgB9eMjse8rbhQVLaRQWBXzWRvWnPsp Next: 3EkWVLxCyv7nZ5cY3GPJsqTUodzdYsD61AY3FN76aeZc Diff:
OldNewDifferences
8787 }
8888
8989
90+func calcSendAmountREADONLY (paymentAssetString,paymentAmount) = {
91+ let $t029563080 = calcSendAmount(getAssetId(paymentAssetString), paymentAmount, true)
92+ let sendAmount = $t029563080._1
93+ let feeAmount = $t029563080._2
94+ let amAssetId = $t029563080._3
95+ let userRealPrice = $t029563080._4
96+ $Tuple3(sendAmount, userRealPrice, amAssetId)
97+ }
98+
99+
90100 @Callable(i)
91101 func swap () = swapInternal(i.caller, i)
92102
94104
95105 @Callable(i)
96106 func swapNoLess (minAmount) = {
97- let $t029823034 = swapInternal(i.caller, i)
98- let sendActions = $t029823034._1
99- let tuple = $t029823034._2
100- let $t030393102 = tuple
101- let sendAmount = $t030393102._1
102- let feeAmount = $t030393102._2
103- let sendAssetId = $t030393102._3
104- let userRealPrice = $t030393102._4
107+ let $t032623314 = swapInternal(i.caller, i)
108+ let sendActions = $t032623314._1
109+ let tuple = $t032623314._2
110+ let $t033193382 = tuple
111+ let sendAmount = $t033193382._1
112+ let feeAmount = $t033193382._2
113+ let sendAssetId = $t033193382._3
114+ let userRealPrice = $t033193382._4
105115 if ((minAmount > sendAmount))
106116 then throw(makeString(["Price slipped. minAmount: ", toString(minAmount), " swapAmount: ", toString(sendAmount)], ""))
107117 else $Tuple2(sendActions, tuple)
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
3535 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,readonly) = {
4747 let $t013571509 = if ((paymentAssetId == amountAssetId))
4848 then $Tuple2(priceAssetId, amountAssetId)
4949 else $Tuple2(amountAssetId, priceAssetId)
5050 let amAssetId = $t013571509._1
5151 let prAssetId = $t013571509._2
5252 let initAmBal = getAssetBalance(amAssetId)
5353 let initPrBal = (getAssetBalance(prAssetId) - (if (readonly)
5454 then 0
5555 else paymentAmount))
5656 let rawSendAmount = calcRawSendAmount(initAmBal, initPrBal, paymentAmount)
5757 let feeAmount = fraction(rawSendAmount, feeRate, SCALE8)
5858 let sendAmount = (rawSendAmount - feeAmount)
5959 let userRealPrice = if ((paymentAssetId == amountAssetId))
6060 then fraction(sendAmount, SCALE8, paymentAmount)
6161 else fraction(paymentAmount, SCALE8, sendAmount)
6262 $Tuple4(sendAmount, feeAmount, amAssetId, userRealPrice)
6363 }
6464
6565
6666 func swapInternal (address,i) = {
6767 let checks = [if ((size(i.payments) > 0))
6868 then true
6969 else throw("should be with 1 payment"), if (containsElement([amountAssetId, priceAssetId], i.payments[0].assetId))
7070 then true
7171 else throw(makeString(["payment assetId should be", amountAssetIdString, "or", priceAssetIdString], " "))]
7272 if ((checks == checks))
7373 then {
7474 let paymentAssetId = i.payments[0].assetId
7575 let paymentAmount = i.payments[0].amount
7676 let $t025142624 = calcSendAmount(paymentAssetId, paymentAmount, false)
7777 let sendAmount = $t025142624._1
7878 let feeAmount = $t025142624._2
7979 let sendAssetId = $t025142624._3
8080 let userRealPrice = $t025142624._4
8181 let sendActions = if ((feeAmount > 0))
8282 then [ScriptTransfer(address, sendAmount, sendAssetId)]
8383 else throw("amount is too low")
8484 $Tuple2(sendActions, $Tuple4(sendAmount, feeAmount, sendAssetId, userRealPrice))
8585 }
8686 else throw("Strict value is not equal to itself.")
8787 }
8888
8989
90+func calcSendAmountREADONLY (paymentAssetString,paymentAmount) = {
91+ let $t029563080 = calcSendAmount(getAssetId(paymentAssetString), paymentAmount, true)
92+ let sendAmount = $t029563080._1
93+ let feeAmount = $t029563080._2
94+ let amAssetId = $t029563080._3
95+ let userRealPrice = $t029563080._4
96+ $Tuple3(sendAmount, userRealPrice, amAssetId)
97+ }
98+
99+
90100 @Callable(i)
91101 func swap () = swapInternal(i.caller, i)
92102
93103
94104
95105 @Callable(i)
96106 func swapNoLess (minAmount) = {
97- let $t029823034 = swapInternal(i.caller, i)
98- let sendActions = $t029823034._1
99- let tuple = $t029823034._2
100- let $t030393102 = tuple
101- let sendAmount = $t030393102._1
102- let feeAmount = $t030393102._2
103- let sendAssetId = $t030393102._3
104- let userRealPrice = $t030393102._4
107+ let $t032623314 = swapInternal(i.caller, i)
108+ let sendActions = $t032623314._1
109+ let tuple = $t032623314._2
110+ let $t033193382 = tuple
111+ let sendAmount = $t033193382._1
112+ let feeAmount = $t033193382._2
113+ let sendAssetId = $t033193382._3
114+ let userRealPrice = $t033193382._4
105115 if ((minAmount > sendAmount))
106116 then throw(makeString(["Price slipped. minAmount: ", toString(minAmount), " swapAmount: ", toString(sendAmount)], ""))
107117 else $Tuple2(sendActions, tuple)
108118 }
109119
110120
111121
112122 @Callable(i)
113123 func swapFor (address) = swapInternal(addressFromStringValue(address), i)
114124
115125

github/deemru/w8io/026f985 
62.51 ms