tx · 9DCFNnHQ5Tf696ysBjpiG25jpmQshBPFxYfymbqv3LyM 3MyUDpTMG43mkmScfDKgG9gep4reUboH9YF: -0.01000000 Waves 2024.05.02 00:23 [3087623] smart account 3MyUDpTMG43mkmScfDKgG9gep4reUboH9YF > SELF 0.00000000 Waves
{ "type": 13, "id": "9DCFNnHQ5Tf696ysBjpiG25jpmQshBPFxYfymbqv3LyM", "fee": 1000000, "feeAssetId": null, "timestamp": 1714598616010, "version": 2, "chainId": 84, "sender": "3MyUDpTMG43mkmScfDKgG9gep4reUboH9YF", "senderPublicKey": "5pPySirDYzGqBH24WnXUvbKDkDVA5qoNuUgCDvkKYJTT", "proofs": [ "4DdpZ9NwJh48Saj95QGfsHDzZjzyprhA2xJjKmfsbYof1SjWy56S1yWpLAzSHpjVZehC624EofEWGidihmPAcyk" ], "script": "base64:BgITCAISCAoGCAgICAEBEgUKAwgIARUAB1dhdmVzSWQCBVdBVkVTAAZIZWlnaHQFBmhlaWdodAAQQ2FsbGVyQWRkcmVzc0tleQITc2V0dXBfY2FsbGVyQWRkcmVzcwAaUHV6emxlQWdncmVnYXRvckFkZHJlc3NLZXkCHXNldHVwX3B1enpsZUFnZ3JlZ2F0b3JBZGRyZXNzABdQdXp6bGVTdGFraW5nQWRkcmVzc0tleQIac2V0dXBfcHV6emxlU3Rha2luZ0FkZHJlc3MAC1B1enpsZUlkS2V5Ag5zZXR1cF9wdXp6bGVJZAAUQnV5YmFja0l0ZXJhdGlvbnNLZXkCF3NldHVwX2J1eWJhY2tJdGVyYXRpb25zAA9CdXliYWNrRGVsYXlLZXkCEnNldHVwX2J1eWJhY2tEZWxheQAUVG90YWxCb3VnaHRQdXp6bGVLZXkCEXRvdGFsQm91Z2h0UHV6emxlAA1DYWxsZXJBZGRyZXNzCQERQGV4dHJOYXRpdmUoMTA2MikBCQERQGV4dHJOYXRpdmUoMTA1MykCBQR0aGlzBRBDYWxsZXJBZGRyZXNzS2V5ABdQdXp6bGVBZ2dyZWdhdG9y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pbAkAzAgCCQEPQXR0YWNoZWRQYXltZW50AgUIUHV6emxlSWQFDGJvdWdodFB1enpsZQUDbmlsAwkAAAIFC3RvcFVwSW52b2tlBQt0b3BVcEludm9rZQQRdG90YWxCb3VnaHRQdXp6bGUJAGQCCQELdmFsdWVPckVsc2UCCQCaCAIFBHRoaXMFFFRvdGFsQm91Z2h0UHV6emxlS2V5AAAFDGJvdWdodFB1enpsZQQIc3RhdHNLZXkJAQxtYWtlU3RhdHNLZXkDBQFpBQxidXliYWNrSW5wdXQFBWFzc2V0CQDMCAIJAQxJbnRlZ2VyRW50cnkCCQEYbWFrZUxhc3RCdXliYWNrSGVpZ2h0S2V5AQUFYXNzZXQFBkhlaWdodAkAzAgCCQEMSW50ZWdlckVudHJ5AgkBE21ha2VCdXliYWNrSW5wdXRLZXkCBQVhc3NldAULZXBvY2hIZWlnaHQFEWVwb2NoQnV5YmFja0lucHV0CQDMCAIJAQxJbnRlZ2VyRW50cnkCBQhzdGF0c0tleQUMYm91Z2h0UHV6emxlCQDMCAIJAQxJbnRlZ2VyRW50cnkCBRRUb3RhbEJvdWdodFB1enpsZUtleQURdG90YWxCb3VnaHRQdXp6bGUFA25pbAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgECdHgBBnZlcmlmeQAJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAIBQJ0eA9zZW5kZXJQdWJsaWNLZXn5bv6N", "height": 3087623, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: CaKDo4wPYe63FFW5TBzmubKcDEsiZxUdA3GGp7RTBg9v Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 6 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let WavesId = "WAVES" | |
5 | + | ||
6 | + | let Height = height | |
7 | + | ||
8 | + | let CallerAddressKey = "setup_callerAddress" | |
9 | + | ||
10 | + | let PuzzleAggregatorAddressKey = "setup_puzzleAggregatorAddress" | |
11 | + | ||
12 | + | let PuzzleStakingAddressKey = "setup_puzzleStakingAddress" | |
13 | + | ||
14 | + | let PuzzleIdKey = "setup_puzzleId" | |
15 | + | ||
16 | + | let BuybackIterationsKey = "setup_buybackIterations" | |
17 | + | ||
18 | + | let BuybackDelayKey = "setup_buybackDelay" | |
19 | + | ||
20 | + | let TotalBoughtPuzzleKey = "totalBoughtPuzzle" | |
21 | + | ||
22 | + | let CallerAddress = addressFromStringValue(getStringValue(this, CallerAddressKey)) | |
23 | + | ||
24 | + | let PuzzleAggregatorAddress = addressFromStringValue(getStringValue(this, PuzzleAggregatorAddressKey)) | |
25 | + | ||
26 | + | let PuzzleStakingAddress = addressFromStringValue(getStringValue(this, PuzzleStakingAddressKey)) | |
27 | + | ||
28 | + | let PuzzleId = getBinaryValue(this, PuzzleIdKey) | |
29 | + | ||
30 | + | let BuybackIterations = getIntegerValue(this, BuybackIterationsKey) | |
31 | + | ||
32 | + | let BuybackDelay = getIntegerValue(this, BuybackDelayKey) | |
33 | + | ||
34 | + | let BuybackEpochLength = (BuybackIterations * BuybackDelay) | |
35 | + | ||
36 | + | func makeLastBuybackHeightKey (asset) = ("lastBuybackHeight_" + asset) | |
37 | + | ||
38 | + | ||
39 | + | func makeBuybackInputKey (asset,epochHeight) = ((("buybackInput_" + asset) + "_") + toString(epochHeight)) | |
40 | + | ||
41 | + | ||
42 | + | func makeStatsKey (i,buybackInput,asset) = makeString(["stats", toBase58String(i.transactionId), toString(Height), toString(lastBlock.timestamp), toString(buybackInput), asset], "_") | |
43 | + | ||
44 | + | ||
45 | + | func getLastBuybackHeight (asset) = valueOrElse(getInteger(this, makeLastBuybackHeightKey(asset)), 0) | |
46 | + | ||
47 | + | ||
48 | + | func getBuybackInput (asset,epochHeight) = getInteger(this, makeBuybackInputKey(asset, epochHeight)) | |
49 | + | ||
50 | + | ||
51 | + | @Callable(i) | |
52 | + | func setup (callerAddress,puzzleAggregatorAddress,puzzleStakingAddress,puzzleId,buybackIterations,buybackDelay) = if ((getBinary(PuzzleIdKey) != unit)) | |
53 | + | then throw("Can be called only once") | |
54 | + | else if ((addressFromString(callerAddress) == unit)) | |
55 | + | then throw(("Invalid callerAddress: " + callerAddress)) | |
56 | + | else if ((addressFromString(puzzleAggregatorAddress) == unit)) | |
57 | + | then throw(("Invalid puzzleAggregatorAddress: " + puzzleAggregatorAddress)) | |
58 | + | else if ((addressFromString(puzzleStakingAddress) == unit)) | |
59 | + | then throw(("Invalid puzzleStakingAddress: " + puzzleStakingAddress)) | |
60 | + | else if ((assetInfo(fromBase58String(puzzleId)) == unit)) | |
61 | + | then throw(("Unknown puzzleId: " + puzzleId)) | |
62 | + | else if ((0 >= buybackIterations)) | |
63 | + | then throw(("buybackIterations should be positive, current value: " + toString(buybackIterations))) | |
64 | + | else if ((0 >= buybackDelay)) | |
65 | + | then throw(("buybackDelay should be positive, current value: " + toString(buybackDelay))) | |
66 | + | else [StringEntry(CallerAddressKey, callerAddress), StringEntry(PuzzleAggregatorAddressKey, puzzleAggregatorAddress), StringEntry(PuzzleStakingAddressKey, puzzleStakingAddress), BinaryEntry(PuzzleIdKey, fromBase58String(puzzleId)), IntegerEntry(BuybackIterationsKey, buybackIterations), IntegerEntry(BuybackDelayKey, buybackDelay)] | |
67 | + | ||
68 | + | ||
69 | + | ||
70 | + | @Callable(i) | |
71 | + | func buybackPuzzleAndTopUpRewards (asset,route,minToReceive) = if ((i.caller != CallerAddress)) | |
72 | + | then throw("Whitelisted only") | |
73 | + | else { | |
74 | + | let lastBuybackHeight = getLastBuybackHeight(asset) | |
75 | + | if (((lastBuybackHeight + BuybackDelay) > Height)) | |
76 | + | then throw("Not yet") | |
77 | + | else { | |
78 | + | let $t032713542 = if ((asset == WavesId)) | |
79 | + | then $Tuple2(unit, wavesBalance(this).available) | |
80 | + | else { | |
81 | + | let currentAssetId = fromBase58String(asset) | |
82 | + | let currentAssetBalance = assetBalance(this, currentAssetId) | |
83 | + | $Tuple2(currentAssetId, currentAssetBalance) | |
84 | + | } | |
85 | + | let assetId = $t032713542._1 | |
86 | + | let balance = $t032713542._2 | |
87 | + | let epochHeight = ((Height / BuybackEpochLength) * BuybackEpochLength) | |
88 | + | let epochBuybackInput = valueOrElse(getBuybackInput(asset, epochHeight), (balance / BuybackIterations)) | |
89 | + | let buybackInput = if ((epochBuybackInput > balance)) | |
90 | + | then balance | |
91 | + | else epochBuybackInput | |
92 | + | if ((0 >= buybackInput)) | |
93 | + | then throw(("Empty balance of " + asset)) | |
94 | + | else { | |
95 | + | let swapInvoke = invoke(PuzzleAggregatorAddress, "swapWithReferral", [route, minToReceive, "puzzlenode"], [AttachedPayment(assetId, buybackInput)]) | |
96 | + | if ((swapInvoke == swapInvoke)) | |
97 | + | then { | |
98 | + | let boughtPuzzle = assetBalance(this, PuzzleId) | |
99 | + | if ((0 >= boughtPuzzle)) | |
100 | + | then throw(((("Puzzle was not bought, asset: " + asset) + ", route: ") + route)) | |
101 | + | else { | |
102 | + | let topUpInvoke = invoke(PuzzleStakingAddress, "topUpReward", nil, [AttachedPayment(PuzzleId, boughtPuzzle)]) | |
103 | + | if ((topUpInvoke == topUpInvoke)) | |
104 | + | then { | |
105 | + | let totalBoughtPuzzle = (valueOrElse(getInteger(this, TotalBoughtPuzzleKey), 0) + boughtPuzzle) | |
106 | + | let statsKey = makeStatsKey(i, buybackInput, asset) | |
107 | + | [IntegerEntry(makeLastBuybackHeightKey(asset), Height), IntegerEntry(makeBuybackInputKey(asset, epochHeight), epochBuybackInput), IntegerEntry(statsKey, boughtPuzzle), IntegerEntry(TotalBoughtPuzzleKey, totalBoughtPuzzle)] | |
108 | + | } | |
109 | + | else throw("Strict value is not equal to itself.") | |
110 | + | } | |
111 | + | } | |
112 | + | else throw("Strict value is not equal to itself.") | |
113 | + | } | |
114 | + | } | |
115 | + | } | |
116 | + | ||
117 | + | ||
118 | + | @Verifier(tx) | |
119 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
120 | + |
github/deemru/w8io/026f985 18.02 ms ◑