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:BgIECAISAAoAA1NFUAICX18ABU1VTFQ2AMCEPQAFTVVMVDgAgMLXLwAKV0FWRVNJRFNUUgIFV0FWRVMAB1dBVkVTSUQJANkEAQUKV0FWRVNJRFNUUgAIWFROSURTVFICLDI1RkVxRWpSa3FLNnlDa2lUN0x6NlNBWXo3Z1VGQ3R4ZkNDaG5yVkZENUFUAAhORVVUUklOTwIjM016YngzNEV4NXJSYm4zOXZVSHg5a2l3aDNubmVGOFM1d2UAE1dYX1NXQVBfQUREUkVTU19TVFICIzNONkxIamZHYjZGZ2N5N1lzVmNOeEd5UFRqNDlYYlFBaWpxAA9XWF9TV0FQX0FERFJFU1MJARFAZXh0ck5hdGl2ZSgxMDYyKQEFE1dYX1NXQVBfQUREUkVTU19TVFIBFmtleU1pbkRpc3RyaWJ1dGVBbW91bnQAAh4lcyVzX19jZmdfX21pbkRpc3RyaWJ1dGVBbW91bnQBAWkBCmJ1eUJhY2tYdG4ABApidXlCYWNrQW10CQELdmFsdWVPckVsc2UCCQCaCAIFBHRoaXMJARZrZXlNaW5EaXN0cmlidXRlQW1vdW50AAkAaAIADQUFTVVMV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kBQR1bml0BQNuaWwJAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4AczSd8w==", "height": 2581821, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4dApoDbCd5w35jBWoMz1GnakH7iLHP24CkAomndkYNeS Next: 6Gv8G5ZeVt4oCtr73CMW686siYUuSuJm6Pr1hYipbEHo Diff:
Old | New | Differences | |
---|---|---|---|
24 | 24 | ||
25 | 25 | @Callable(i) | |
26 | 26 | func buyBackXtn () = { | |
27 | - | let | |
28 | - | if ((size(i.payments) != | |
27 | + | let buyBackAmt = valueOrElse(getInteger(this, keyMinDistributeAmount()), (13 * MULT8)) | |
28 | + | if ((size(i.payments) != 0)) | |
29 | 29 | then throw("exact 1 payment must be attached") | |
30 | 30 | else if ((i.caller != i.originCaller)) | |
31 | 31 | then throw("dapp to dapp calls are not allowed") | |
32 | 32 | else { | |
33 | - | let pmt = i.payments[0] | |
34 | - | let pmtAmt = pmt.amount | |
35 | - | let pmtAssetId = valueOrElse(pmt.assetId, WAVESID) | |
36 | 33 | let feeAmt = i.fee | |
37 | 34 | let feeAssetId = valueOrElse(i.feeAssetId, WAVESID) | |
38 | 35 | let allowedFee = ((5 * MULT8) / 1000) | |
39 | 36 | 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 | + | } | |
55 | 50 | } | |
56 | 51 | } | |
57 | 52 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SEP = "__" | |
5 | 5 | ||
6 | 6 | let MULT6 = 1000000 | |
7 | 7 | ||
8 | 8 | let MULT8 = 100000000 | |
9 | 9 | ||
10 | 10 | let WAVESIDSTR = "WAVES" | |
11 | 11 | ||
12 | 12 | let WAVESID = fromBase58String(WAVESIDSTR) | |
13 | 13 | ||
14 | 14 | let XTNIDSTR = "25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT" | |
15 | 15 | ||
16 | 16 | let NEUTRINO = "3Mzbx34Ex5rRbn39vUHx9kiwh3nneF8S5we" | |
17 | 17 | ||
18 | 18 | let WX_SWAP_ADDRESS_STR = "3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq" | |
19 | 19 | ||
20 | 20 | let WX_SWAP_ADDRESS = addressFromStringValue(WX_SWAP_ADDRESS_STR) | |
21 | 21 | ||
22 | 22 | func keyMinDistributeAmount () = "%s%s__cfg__minDistributeAmount" | |
23 | 23 | ||
24 | 24 | ||
25 | 25 | @Callable(i) | |
26 | 26 | func buyBackXtn () = { | |
27 | - | let | |
28 | - | if ((size(i.payments) != | |
27 | + | let buyBackAmt = valueOrElse(getInteger(this, keyMinDistributeAmount()), (13 * MULT8)) | |
28 | + | if ((size(i.payments) != 0)) | |
29 | 29 | then throw("exact 1 payment must be attached") | |
30 | 30 | else if ((i.caller != i.originCaller)) | |
31 | 31 | then throw("dapp to dapp calls are not allowed") | |
32 | 32 | else { | |
33 | - | let pmt = i.payments[0] | |
34 | - | let pmtAmt = pmt.amount | |
35 | - | let pmtAssetId = valueOrElse(pmt.assetId, WAVESID) | |
36 | 33 | let feeAmt = i.fee | |
37 | 34 | let feeAssetId = valueOrElse(i.feeAssetId, WAVESID) | |
38 | 35 | let allowedFee = ((5 * MULT8) / 1000) | |
39 | 36 | 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 | + | } | |
55 | 50 | } | |
56 | 51 | } | |
57 | 52 | ||
58 | 53 |
github/deemru/w8io/169f3d6 32.40 ms ◑