tx · 33HXGRTLEydx9ES2EZ4HPKc3u7QdfMKTFKGnGxDSqMfc

3N61RYWc9QuqKUwLvowpZZLpgUnqpQSFwLq:  -0.01000000 Waves

2024.03.04 14:32 [3003212] smart account 3N61RYWc9QuqKUwLvowpZZLpgUnqpQSFwLq > SELF 0.00000000 Waves

{ "type": 13, "id": "33HXGRTLEydx9ES2EZ4HPKc3u7QdfMKTFKGnGxDSqMfc", "fee": 1000000, "feeAssetId": null, "timestamp": 1709551978491, "version": 2, "chainId": 84, "sender": "3N61RYWc9QuqKUwLvowpZZLpgUnqpQSFwLq", "senderPublicKey": "HdwFH8HPYu3HG27yK6bszu1CdR4uik4HgzyTimeSfcYf", "proofs": [ "3ZcVK22RZKQe8fZ4rMuHB187ys7AZJ27Ei3VrxdgGthmQaBeHp2f1Ccaop2Bkngcy5uGAtJ5iBaMxTzJsP6jHCyE" ], "script": "base64:BgIJCAISABIDCgEIDgAQYW1vdW50QXNzZXRJZEtleQINYW1vdW50QXNzZXRJZAAPcHJpY2VBc3NldElkS2V5AgxwcmljZUFzc2V0SWQACmZlZVJhdGVLZXkCB2ZlZVJhdGUBCmdldEFzc2V0SWQBDWFzc2V0SWRTdHJpbmcDCQAAAgUNYXNzZXRJZFN0cmluZwIFV0FWRVMFBHVuaXQJANkEAQUNYXNzZXRJZFN0cmluZwEPZ2V0QXNzZXRCYWxhbmNlAQdhc3NldElkBAckbWF0Y2gwBQdhc3NldElkAwkAAQIFByRtYXRjaDACCkJ5dGVWZWN0b3IEAmlkBQckbWF0Y2gwCQDwBwIFBHRoaXMFAmlkCAkA7wcBBQR0aGlzCWF2YWlsYWJsZQATYW1vdW50QXNzZXRJZFN0cmluZwkBEUBleHRyTmF0aXZlKDEwNTMpAgUEdGhpcwUQYW1vdW50QXNzZXRJZEtleQANYW1vdW50QXNzZXRJZAkBCmdldEFzc2V0SWQBBRNhbW91bnRBc3NldElkU3RyaW5nABJwcmljZUFzc2V0SWRTdHJpbmcJARFAZXh0ck5hdGl2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CAAAFCWZlZUFtb3VudAkAzAgCCQEOU2NyaXB0VHJhbnNmZXIDBQdhZGRyZXNzBQpzZW5kQW1vdW50BQtzZW5kQXNzZXRJZAUDbmlsCQACAQIRYW1vdW50IGlzIHRvbyBsb3cJAJQKAgULc2VuZEFjdGlvbnMJAJYKBAUKc2VuZEFtb3VudAUJZmVlQW1vdW50BQtzZW5kQXNzZXRJZAUNdXNlclJlYWxQcmljZQkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgIBaQEEc3dhcAAJAQxzd2FwSW50ZXJuYWwCCAUBaQZjYWxsZXIFAWkBaQEHc3dhcEZvcgEHYWRkcmVzcwkBDHN3YXBJbnRlcm5hbAIJARFAZXh0ck5hdGl2ZSgxMDYyKQEFB2FkZHJlc3MFAWkAvtOQIQ==", "height": 3003212, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 84HimeExGbNgyFFNkU9A4yjPrvhocm7dgrGYy3yxz3vb Next: 8uyPT7s4kuon3CLduEBBzpLXB9X6G1GyWGN9Fq94bVjd Diff:
OldNewDifferences
2424
2525 let amountAssetId = getAssetId(amountAssetIdString)
2626
27-let amountAssetBalance = getAssetBalance(amountAssetId)
28-
2927 let priceAssetIdString = getStringValue(this, priceAssetIdKey)
3028
3129 let priceAssetId = getAssetId(priceAssetIdString)
3230
33-let priceAssetBalance = getAssetBalance(priceAssetId)
34-
3531 let SCALE8 = 100000000
3632
37-let feeRate = valueOrElse(getInteger(this, feeRateKey), 1000000)
33+let feeRate = valueOrElse(getInteger(this, feeRateKey), 200000)
3834
3935 func calcRawSendAmount (initAmBal,initPrBal,paymentAmount) = {
4036 let newPrBal = (initPrBal + paymentAmount)
4541
4642
4743 func calcSendAmount (paymentAssetId,paymentAmount) = {
48- let $t013391491 = if ((paymentAssetId == amountAssetId))
44+ let $t012301382 = if ((paymentAssetId == amountAssetId))
4945 then $Tuple2(priceAssetId, amountAssetId)
5046 else $Tuple2(amountAssetId, priceAssetId)
51- let amAssetId = $t013391491._1
52- let prAssetId = $t013391491._2
47+ let amAssetId = $t012301382._1
48+ let prAssetId = $t012301382._2
5349 let initAmBal = getAssetBalance(amAssetId)
5450 let initPrBal = (getAssetBalance(prAssetId) - paymentAmount)
5551 let rawSendAmount = calcRawSendAmount(initAmBal, initPrBal, paymentAmount)
6561 func swapInternal (address,i) = {
6662 let checks = [if ((size(i.payments) > 0))
6763 then true
68- else throw("should be with 1 payment"), if (if ((i.payments[0].assetId == amountAssetId))
69- then true
70- else (i.payments[0].assetId == priceAssetId))
64+ else throw("should be with 1 payment"), if (containsElement([amountAssetId, priceAssetId], i.payments[0].assetId))
7165 then true
7266 else throw(makeString(["payment assetId should be (", amountAssetIdString, ") or (", priceAssetIdString, ")"], " "))]
7367 if ((checks == checks))
7468 then {
7569 let paymentAssetId = i.payments[0].assetId
7670 let paymentAmount = i.payments[0].amount
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
82- let sendActions = if ((feeAmount != 0))
71+ let $t023702473 = calcSendAmount(paymentAssetId, paymentAmount)
72+ let sendAmount = $t023702473._1
73+ let feeAmount = $t023702473._2
74+ let sendAssetId = $t023702473._3
75+ let userRealPrice = $t023702473._4
76+ let sendActions = if ((0 >= feeAmount))
8377 then [ScriptTransfer(address, sendAmount, sendAssetId)]
8478 else throw("amount is too low")
8579 $Tuple2(sendActions, $Tuple4(sendAmount, feeAmount, sendAssetId, userRealPrice))
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
27-let amountAssetBalance = getAssetBalance(amountAssetId)
28-
2927 let priceAssetIdString = getStringValue(this, priceAssetIdKey)
3028
3129 let priceAssetId = getAssetId(priceAssetIdString)
3230
33-let priceAssetBalance = getAssetBalance(priceAssetId)
34-
3531 let SCALE8 = 100000000
3632
37-let feeRate = valueOrElse(getInteger(this, feeRateKey), 1000000)
33+let feeRate = valueOrElse(getInteger(this, feeRateKey), 200000)
3834
3935 func calcRawSendAmount (initAmBal,initPrBal,paymentAmount) = {
4036 let newPrBal = (initPrBal + paymentAmount)
4137 let newAmBal = fraction(initAmBal, initPrBal, newPrBal)
4238 let sendAmount = (initAmBal - newAmBal)
4339 sendAmount
4440 }
4541
4642
4743 func calcSendAmount (paymentAssetId,paymentAmount) = {
48- let $t013391491 = if ((paymentAssetId == amountAssetId))
44+ let $t012301382 = if ((paymentAssetId == amountAssetId))
4945 then $Tuple2(priceAssetId, amountAssetId)
5046 else $Tuple2(amountAssetId, priceAssetId)
51- let amAssetId = $t013391491._1
52- let prAssetId = $t013391491._2
47+ let amAssetId = $t012301382._1
48+ let prAssetId = $t012301382._2
5349 let initAmBal = getAssetBalance(amAssetId)
5450 let initPrBal = (getAssetBalance(prAssetId) - paymentAmount)
5551 let rawSendAmount = calcRawSendAmount(initAmBal, initPrBal, paymentAmount)
5652 let feeAmount = fraction(rawSendAmount, feeRate, SCALE8)
5753 let sendAmount = (rawSendAmount - feeAmount)
5854 let userRealPrice = if ((paymentAssetId == amountAssetId))
5955 then fraction(sendAmount, SCALE8, paymentAmount)
6056 else fraction(paymentAmount, SCALE8, sendAmount)
6157 $Tuple4(sendAmount, feeAmount, amAssetId, userRealPrice)
6258 }
6359
6460
6561 func swapInternal (address,i) = {
6662 let checks = [if ((size(i.payments) > 0))
6763 then true
68- else throw("should be with 1 payment"), if (if ((i.payments[0].assetId == amountAssetId))
69- then true
70- else (i.payments[0].assetId == priceAssetId))
64+ else throw("should be with 1 payment"), if (containsElement([amountAssetId, priceAssetId], i.payments[0].assetId))
7165 then true
7266 else throw(makeString(["payment assetId should be (", amountAssetIdString, ") or (", priceAssetIdString, ")"], " "))]
7367 if ((checks == checks))
7468 then {
7569 let paymentAssetId = i.payments[0].assetId
7670 let paymentAmount = i.payments[0].amount
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
82- let sendActions = if ((feeAmount != 0))
71+ let $t023702473 = calcSendAmount(paymentAssetId, paymentAmount)
72+ let sendAmount = $t023702473._1
73+ let feeAmount = $t023702473._2
74+ let sendAssetId = $t023702473._3
75+ let userRealPrice = $t023702473._4
76+ let sendActions = if ((0 >= feeAmount))
8377 then [ScriptTransfer(address, sendAmount, sendAssetId)]
8478 else throw("amount is too low")
8579 $Tuple2(sendActions, $Tuple4(sendAmount, feeAmount, sendAssetId, userRealPrice))
8680 }
8781 else throw("Strict value is not equal to itself.")
8882 }
8983
9084
9185 @Callable(i)
9286 func swap () = swapInternal(i.caller, i)
9387
9488
9589
9690 @Callable(i)
9791 func swapFor (address) = swapInternal(addressFromStringValue(address), i)
9892
9993

github/deemru/w8io/026f985 
39.70 ms