tx · EBuUVGfgwytQdJ4X5KnaAodkQ94fU1q4J554Fr5XrSGg

3Myb6G8DkdBb8YcZzhrky65HrmiNuac3kvS:  -0.00200000 Waves

2023.05.17 13:14 [2581821] smart account 3Myb6G8DkdBb8YcZzhrky65HrmiNuac3kvS > SELF 0.00000000 Waves

{ "type": 13, "id": "EBuUVGfgwytQdJ4X5KnaAodkQ94fU1q4J554Fr5XrSGg", "fee": 200000, "feeAssetId": null, "timestamp": 1684318537307, "version": 2, "chainId": 84, "sender": "3Myb6G8DkdBb8YcZzhrky65HrmiNuac3kvS", "senderPublicKey": "Ab4L9nu8oFkaz3goia9d2YmgZZCZciUsmuKTWq8rMYN4", "proofs": [ "3PnRxJt3GGa2rSxwepWRKWYTeDvKnDU6cKRwQbyxvHYijMvK4467XRcYwEZ62kPif9qCfZpFuevNZbrzYJjtY5VL" ], "script": "base64:BgIECAISAAoAA1NFUAICX18ABU1VTFQ2AMCEPQAFTVVMVDgAgMLXLwAKV0FWRVNJRFNUUgIFV0FWRVMAB1dBVkVTSUQJANkEAQUKV0FWRVNJRFNUUgAIWFROSURTVFICLDI1RkVxRWpSa3FLNnlDa2lUN0x6NlNBWXo3Z1VGQ3R4ZkNDaG5yVkZENUFUAAhORVVUUklOTwIjM016YngzNEV4NXJSYm4zOXZVSHg5a2l3aDNubmVGOFM1d2UAE1dYX1NXQVBfQUREUkVTU19TVFICIzNONkxIamZHYjZGZ2N5N1lzVmNOeEd5UFRqNDlYYlFBaWpxAA9XWF9TV0FQX0FERFJFU1MJARFAZXh0ck5hdGl2ZSgxMDYyKQEFE1dYX1NXQVBfQUREUkVTU19TVFIBFmtleU1pbkRpc3RyaWJ1dGVBbW91bnQAAh4lcyVzX19jZmdfX21pbkRpc3RyaWJ1dGVBbW91bnQBAWkBCmJ1eUJhY2tYdG4ABApidXlCYWNrQW10CQELdmFsdWVPckVsc2UCCQCaCAIFBHRoaXMJARZrZXlNaW5EaXN0cmlidXRlQW1vdW50AAkAaAIADQUFTVVM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JkBQR1bml0BQNuaWwJAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4AczSd8w==", "height": 2581821, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4dApoDbCd5w35jBWoMz1GnakH7iLHP24CkAomndkYNeS Next: 6Gv8G5ZeVt4oCtr73CMW686siYUuSuJm6Pr1hYipbEHo Diff:
OldNewDifferences
2424
2525 @Callable(i)
2626 func buyBackXtn () = {
27- let minDistributeAmount = valueOrElse(getInteger(this, keyMinDistributeAmount()), (13 * MULT8))
28- if ((size(i.payments) != 1))
27+ let buyBackAmt = valueOrElse(getInteger(this, keyMinDistributeAmount()), (13 * MULT8))
28+ if ((size(i.payments) != 0))
2929 then throw("exact 1 payment must be attached")
3030 else if ((i.caller != i.originCaller))
3131 then throw("dapp to dapp calls are not allowed")
3232 else {
33- let pmt = i.payments[0]
34- let pmtAmt = pmt.amount
35- let pmtAssetId = valueOrElse(pmt.assetId, WAVESID)
3633 let feeAmt = i.fee
3734 let feeAssetId = valueOrElse(i.feeAssetId, WAVESID)
3835 let allowedFee = ((5 * MULT8) / 1000)
3936 let callerReward = (2 * allowedFee)
40- if ((pmtAmt != minDistributeAmount))
41- then throw((("attached payment must be exact " + toString(minDistributeAmount)) + " Wavelets"))
42- else if ((pmtAssetId != WAVESID))
43- then throw("only Waves can be used in payment")
44- else if ((feeAssetId != WAVESID))
45- then throw("only Waves can be used in fees")
46- else if ((feeAmt != allowedFee))
47- then throw("fee amount couldn't exceed 0.005")
48- else {
49- let buyBackAmt = (pmtAmt - callerReward)
50- let swapResult = invoke(WX_SWAP_ADDRESS, "swap", [1, XTNIDSTR, NEUTRINO], [AttachedPayment(unit, buyBackAmt)])
51- if ((swapResult == swapResult))
52- then [ScriptTransfer(i.caller, callerReward, unit)]
53- else throw("Strict value is not equal to itself.")
54- }
37+ let minRequiredWavesBalance = (buyBackAmt + callerReward)
38+ if ((feeAssetId != WAVESID))
39+ then throw("only Waves can be used in fees")
40+ else if ((feeAmt != allowedFee))
41+ then throw("fee amount couldn't exceed 0.005")
42+ else if ((minRequiredWavesBalance > wavesBalance(this).available))
43+ then throw(("wavelets balance is less then " + toString(minRequiredWavesBalance)))
44+ else {
45+ let swapResult = invoke(WX_SWAP_ADDRESS, "swap", [1, XTNIDSTR, NEUTRINO], [AttachedPayment(unit, buyBackAmt)])
46+ if ((swapResult == swapResult))
47+ then [ScriptTransfer(i.caller, callerReward, unit)]
48+ else throw("Strict value is not equal to itself.")
49+ }
5550 }
5651 }
5752
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let SEP = "__"
55
66 let MULT6 = 1000000
77
88 let MULT8 = 100000000
99
1010 let WAVESIDSTR = "WAVES"
1111
1212 let WAVESID = fromBase58String(WAVESIDSTR)
1313
1414 let XTNIDSTR = "25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT"
1515
1616 let NEUTRINO = "3Mzbx34Ex5rRbn39vUHx9kiwh3nneF8S5we"
1717
1818 let WX_SWAP_ADDRESS_STR = "3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq"
1919
2020 let WX_SWAP_ADDRESS = addressFromStringValue(WX_SWAP_ADDRESS_STR)
2121
2222 func keyMinDistributeAmount () = "%s%s__cfg__minDistributeAmount"
2323
2424
2525 @Callable(i)
2626 func buyBackXtn () = {
27- let minDistributeAmount = valueOrElse(getInteger(this, keyMinDistributeAmount()), (13 * MULT8))
28- if ((size(i.payments) != 1))
27+ let buyBackAmt = valueOrElse(getInteger(this, keyMinDistributeAmount()), (13 * MULT8))
28+ if ((size(i.payments) != 0))
2929 then throw("exact 1 payment must be attached")
3030 else if ((i.caller != i.originCaller))
3131 then throw("dapp to dapp calls are not allowed")
3232 else {
33- let pmt = i.payments[0]
34- let pmtAmt = pmt.amount
35- let pmtAssetId = valueOrElse(pmt.assetId, WAVESID)
3633 let feeAmt = i.fee
3734 let feeAssetId = valueOrElse(i.feeAssetId, WAVESID)
3835 let allowedFee = ((5 * MULT8) / 1000)
3936 let callerReward = (2 * allowedFee)
40- if ((pmtAmt != minDistributeAmount))
41- then throw((("attached payment must be exact " + toString(minDistributeAmount)) + " Wavelets"))
42- else if ((pmtAssetId != WAVESID))
43- then throw("only Waves can be used in payment")
44- else if ((feeAssetId != WAVESID))
45- then throw("only Waves can be used in fees")
46- else if ((feeAmt != allowedFee))
47- then throw("fee amount couldn't exceed 0.005")
48- else {
49- let buyBackAmt = (pmtAmt - callerReward)
50- let swapResult = invoke(WX_SWAP_ADDRESS, "swap", [1, XTNIDSTR, NEUTRINO], [AttachedPayment(unit, buyBackAmt)])
51- if ((swapResult == swapResult))
52- then [ScriptTransfer(i.caller, callerReward, unit)]
53- else throw("Strict value is not equal to itself.")
54- }
37+ let minRequiredWavesBalance = (buyBackAmt + callerReward)
38+ if ((feeAssetId != WAVESID))
39+ then throw("only Waves can be used in fees")
40+ else if ((feeAmt != allowedFee))
41+ then throw("fee amount couldn't exceed 0.005")
42+ else if ((minRequiredWavesBalance > wavesBalance(this).available))
43+ then throw(("wavelets balance is less then " + toString(minRequiredWavesBalance)))
44+ else {
45+ let swapResult = invoke(WX_SWAP_ADDRESS, "swap", [1, XTNIDSTR, NEUTRINO], [AttachedPayment(unit, buyBackAmt)])
46+ if ((swapResult == swapResult))
47+ then [ScriptTransfer(i.caller, callerReward, unit)]
48+ else throw("Strict value is not equal to itself.")
49+ }
5550 }
5651 }
5752
5853

github/deemru/w8io/169f3d6 
32.40 ms