tx · 7bLkhTLYM1UZWF91TKLDp9eJNWr2brhKyuzSUiDwWaZY

3N61RYWc9QuqKUwLvowpZZLpgUnqpQSFwLq:  -0.01000000 Waves

2024.03.05 23:57 [3005225] smart account 3N61RYWc9QuqKUwLvowpZZLpgUnqpQSFwLq > SELF 0.00000000 Waves

{ "type": 13, "id": "7bLkhTLYM1UZWF91TKLDp9eJNWr2brhKyuzSUiDwWaZY", "fee": 1000000, "feeAssetId": null, "timestamp": 1709672241235, "version": 2, "chainId": 84, "sender": "3N61RYWc9QuqKUwLvowpZZLpgUnqpQSFwLq", "senderPublicKey": "HdwFH8HPYu3HG27yK6bszu1CdR4uik4HgzyTimeSfcYf", "proofs": [ "41hDEWuU1Nxf5i7NUkDhbbABX3Fn4S5hcbH4n6WVYEC7rGKtgekACjbqrtyM2Z89GZQKXoveFfph176MGeimHoNj" ], "script": "base64:BgIOCAISABIDCgEBEgMKAQgPABBhbW91bnRBc3NldElkS2V5Ag1hbW91bnRBc3NldElkAA9wcmljZUFzc2V0SWRLZXkCDHByaWNlQXNzZXRJZAAKZmVlUmF0ZUtleQIHZmVlUmF0ZQEKZ2V0QXNzZXRJZAENYXNzZXRJZFN0cmluZwMJAAACBQ1hc3NldElkU3RyaW5nAgVXQVZFUwUEdW5pdAkA2QQBBQ1hc3NldElkU3RyaW5nAQ9nZXRBc3NldEJhbGFuY2UBB2Fzc2V0SWQEByRtYXRjaDAFB2Fzc2V0SWQDCQABAgUHJG1hdGNoMAIKQnl0ZVZlY3RvcgQCaWQFByRtYXRjaDAJAPAHAgUEdGhpcwUCaWQICQDvBwEFBHRoaXMJYXZhaWxhYmxlABNhbW91bnRBc3NldElkU3RyaW5nCQERQGV4dHJOYXRpdmUoMTA1MykCBQR0aGlzBRBhbW91bnRBc3NldElkS2V5AA1hbW91bnRBc3NldElkCQEKZ2V0QXNzZXRJZAEFE2Ftb3VudEFzc2V0SWRTdHJpbmcAEnByaWNlQXNzZXRJZFN0cmluZwkBEUBleHRyTmF0a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kcmVzcwkBDHN3YXBJbnRlcm5hbAIJARFAZXh0ck5hdGl2ZSgxMDYyKQEFB2FkZHJlc3MFAWkAe/KElw==", "height": 3005225, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 62q9vi4LD3HiJ5WcLB9THCwBaxTnGJojVLAywVhPULra Next: Dsqx1vYTXVkoXgB9eMjse8rbhQVLaRQWBXzWRvWnPsp Diff:
OldNewDifferences
4343 }
4444
4545
46-func calcSendAmount (paymentAssetId,paymentAmount) = {
47- let $t013381490 = if ((paymentAssetId == amountAssetId))
46+func calcSendAmount (paymentAssetId,paymentAmount,readonly) = {
47+ let $t013571509 = if ((paymentAssetId == amountAssetId))
4848 then $Tuple2(priceAssetId, amountAssetId)
4949 else $Tuple2(amountAssetId, priceAssetId)
50- let amAssetId = $t013381490._1
51- let prAssetId = $t013381490._2
50+ let amAssetId = $t013571509._1
51+ let prAssetId = $t013571509._2
5252 let initAmBal = getAssetBalance(amAssetId)
53- let initPrBal = getAssetBalance(prAssetId)
53+ let initPrBal = (getAssetBalance(prAssetId) - (if (readonly)
54+ then 0
55+ else paymentAmount))
5456 let rawSendAmount = calcRawSendAmount(initAmBal, initPrBal, paymentAmount)
5557 let feeAmount = fraction(rawSendAmount, feeRate, SCALE8)
5658 let sendAmount = (rawSendAmount - feeAmount)
7173 then {
7274 let paymentAssetId = i.payments[0].assetId
7375 let paymentAmount = i.payments[0].amount
74- let $t025162619 = calcSendAmount(paymentAssetId, paymentAmount)
75- let sendAmount = $t025162619._1
76- let feeAmount = $t025162619._2
77- let sendAssetId = $t025162619._3
78- let userRealPrice = $t025162619._4
76+ let $t025122622 = calcSendAmount(paymentAssetId, paymentAmount, false)
77+ let sendAmount = $t025122622._1
78+ let feeAmount = $t025122622._2
79+ let sendAssetId = $t025122622._3
80+ let userRealPrice = $t025122622._4
7981 let sendActions = if ((feeAmount > 0))
8082 then [ScriptTransfer(address, sendAmount, sendAssetId)]
8183 else throw("amount is too low")
9294
9395 @Callable(i)
9496 func swapNoLess (minAmount) = {
95- let $t029773029 = swapInternal(i.caller, i)
96- let sendActions = $t029773029._1
97- let tuple = $t029773029._2
98- let $t030343097 = tuple
99- let sendAmount = $t030343097._1
100- let feeAmount = $t030343097._2
101- let sendAssetId = $t030343097._3
102- let userRealPrice = $t030343097._4
97+ let $t029803032 = swapInternal(i.caller, i)
98+ let sendActions = $t029803032._1
99+ let tuple = $t029803032._2
100+ let $t030373100 = tuple
101+ let sendAmount = $t030373100._1
102+ let feeAmount = $t030373100._2
103+ let sendAssetId = $t030373100._3
104+ let userRealPrice = $t030373100._4
103105 if ((minAmount > sendAmount))
104106 then throw(makeString(["Price slipped. minAmount: ", toString(minAmount), " swapAmount: ", toString(sendAmount)], ""))
105107 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
46-func calcSendAmount (paymentAssetId,paymentAmount) = {
47- let $t013381490 = if ((paymentAssetId == amountAssetId))
46+func calcSendAmount (paymentAssetId,paymentAmount,readonly) = {
47+ let $t013571509 = if ((paymentAssetId == amountAssetId))
4848 then $Tuple2(priceAssetId, amountAssetId)
4949 else $Tuple2(amountAssetId, priceAssetId)
50- let amAssetId = $t013381490._1
51- let prAssetId = $t013381490._2
50+ let amAssetId = $t013571509._1
51+ let prAssetId = $t013571509._2
5252 let initAmBal = getAssetBalance(amAssetId)
53- let initPrBal = getAssetBalance(prAssetId)
53+ let initPrBal = (getAssetBalance(prAssetId) - (if (readonly)
54+ then 0
55+ else paymentAmount))
5456 let rawSendAmount = calcRawSendAmount(initAmBal, initPrBal, paymentAmount)
5557 let feeAmount = fraction(rawSendAmount, feeRate, SCALE8)
5658 let sendAmount = (rawSendAmount - feeAmount)
5759 let userRealPrice = if ((paymentAssetId == amountAssetId))
5860 then fraction(sendAmount, SCALE8, paymentAmount)
5961 else fraction(paymentAmount, SCALE8, sendAmount)
6062 $Tuple4(sendAmount, feeAmount, amAssetId, userRealPrice)
6163 }
6264
6365
6466 func swapInternal (address,i) = {
6567 let checks = [if ((size(i.payments) > 0))
6668 then true
6769 else throw("should be with 1 payment"), if (containsElement([amountAssetId, priceAssetId], i.payments[0].assetId))
6870 then true
6971 else throw(makeString(["payment assetId should be", amountAssetIdString, "or", priceAssetIdString], " "))]
7072 if ((checks == checks))
7173 then {
7274 let paymentAssetId = i.payments[0].assetId
7375 let paymentAmount = i.payments[0].amount
74- let $t025162619 = calcSendAmount(paymentAssetId, paymentAmount)
75- let sendAmount = $t025162619._1
76- let feeAmount = $t025162619._2
77- let sendAssetId = $t025162619._3
78- let userRealPrice = $t025162619._4
76+ let $t025122622 = calcSendAmount(paymentAssetId, paymentAmount, false)
77+ let sendAmount = $t025122622._1
78+ let feeAmount = $t025122622._2
79+ let sendAssetId = $t025122622._3
80+ let userRealPrice = $t025122622._4
7981 let sendActions = if ((feeAmount > 0))
8082 then [ScriptTransfer(address, sendAmount, sendAssetId)]
8183 else throw("amount is too low")
8284 $Tuple2(sendActions, $Tuple4(sendAmount, feeAmount, sendAssetId, userRealPrice))
8385 }
8486 else throw("Strict value is not equal to itself.")
8587 }
8688
8789
8890 @Callable(i)
8991 func swap () = swapInternal(i.caller, i)
9092
9193
9294
9395 @Callable(i)
9496 func swapNoLess (minAmount) = {
95- let $t029773029 = swapInternal(i.caller, i)
96- let sendActions = $t029773029._1
97- let tuple = $t029773029._2
98- let $t030343097 = tuple
99- let sendAmount = $t030343097._1
100- let feeAmount = $t030343097._2
101- let sendAssetId = $t030343097._3
102- let userRealPrice = $t030343097._4
97+ let $t029803032 = swapInternal(i.caller, i)
98+ let sendActions = $t029803032._1
99+ let tuple = $t029803032._2
100+ let $t030373100 = tuple
101+ let sendAmount = $t030373100._1
102+ let feeAmount = $t030373100._2
103+ let sendAssetId = $t030373100._3
104+ let userRealPrice = $t030373100._4
103105 if ((minAmount > sendAmount))
104106 then throw(makeString(["Price slipped. minAmount: ", toString(minAmount), " swapAmount: ", toString(sendAmount)], ""))
105107 else $Tuple2(sendActions, tuple)
106108 }
107109
108110
109111
110112 @Callable(i)
111113 func swapFor (address) = swapInternal(addressFromStringValue(address), i)
112114
113115

github/deemru/w8io/169f3d6 
39.75 ms