tx · DSdMaVasgRi8PCoaaq2ri7xwsWEjn81ztJjfdxVez3gY 3NDFcJ3K5esyuknc2ngNcw59e8SJXtfgaHB: -0.01000000 Waves 2023.09.22 21:04 [2766923] smart account 3NDFcJ3K5esyuknc2ngNcw59e8SJXtfgaHB > SELF 0.00000000 Waves
{ "type": 13, "id": "DSdMaVasgRi8PCoaaq2ri7xwsWEjn81ztJjfdxVez3gY", "fee": 1000000, "feeAssetId": null, "timestamp": 1695405918858, "version": 2, "chainId": 84, "sender": "3NDFcJ3K5esyuknc2ngNcw59e8SJXtfgaHB", "senderPublicKey": "8M2WuphuhMvTZMcpBocfLqUvkcFJisjdcCZaaPHxpwmS", "proofs": [ "2XmZWg4FBbnKTo5XxYzYnKJkQi2hSDC7WZcNGbtH4EorQuMPh3nN39qDkNsUKfKA9nvVE4vum8YUr6qkUjta83n7" ], "script": "base64:BgLAAggCEgASAwoBARIAEgAiBnVzZG5JZCIJdXNkbklkU3RyIghwdXp6bGVJZCILcHV6emxlSWRTdHIiBVNjYWxlIg10cnlHZXRJbnRlZ2VyIgNrZXkiByRtYXRjaDAiAWIiEGNsYWltQWxpYXNSZXN1bHQiB2FkZHJlc3MiCmFzc2V0SWRTdHIiCmFkZHJlc3NTdHIiD2N1cnJlbnRJbnRlcmVzdCIMc3Rha2VkQW1vdW50IhhsYXN0Q2hlY2tJbnRlcmVzdEluU3RhdGUiEWxhc3RDaGVja0ludGVyZXN0IgZyZXdhcmQiC2NsYWltUmVzdWx0IgFpIgZhbW91bnQiEXRvdGFsU3Rha2VkQW1vdW50IghwbXRBc3NldCIJcG10QW1vdW50Ig1pbnRlcmVzdERlbHRhIgJ0eCIGdmVyaWZ5CAABYQEgbySjyqsw3FIpmOgsYVruWn8jTcItdbvpnapU4NLQB8EAAWICLDhVcmZEVmQ1R3JlZVV3bTd1UGs3ZVl6MWVNdjM3Nmt6UjUyQzZzQU5Qa3dTAAFjASBhIEdqteU0lNOM+a3jecT6cJU92ajDMxppPdJKJ6I3Y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WwFAXUJAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4BAXoBAUEACQD0AwMIBQF6CWJvZHlCeXRlcwkAkQMCCAUBegZwcm9vZnMAAAgFAXoPc2VuZGVyUHVibGljS2V56Ta5Sg==", "height": 2766923, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: FNpyEmdbhsfxaghg8FrLSBSruzAQmXWSDukqbmmNSKGw Next: 7KoKHebjbi7Sr441at7eCZRdJPqn2yJ9jhpet6wR4TNm Diff:
Old | New | Differences | |
---|---|---|---|
80 | 80 | let interestDelta = if ((totalStakedAmount > 0)) | |
81 | 81 | then fraction(amount, Scale, totalStakedAmount) | |
82 | 82 | else 0 | |
83 | - | if ((pmtAsset != usdnId)) | |
84 | - | then $Tuple2([IntegerEntry((("global_" + puzzleIdStr) + "_earnings"), (tryGetInteger((("global_" + puzzleIdStr) + "_earnings")) + amount)), IntegerEntry((("global_lastCheck_" + puzzleIdStr) + "_interest"), (currentInterest + interestDelta))], amount) | |
85 | - | else nil | |
83 | + | $Tuple2([IntegerEntry((("global_" + puzzleIdStr) + "_earnings"), (tryGetInteger((("global_" + puzzleIdStr) + "_earnings")) + amount)), IntegerEntry((("global_lastCheck_" + puzzleIdStr) + "_interest"), (currentInterest + interestDelta))], amount) | |
86 | 84 | } | |
87 | 85 | else throw("Strict value is not equal to itself.") | |
88 | 86 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let usdnId = base58'8UrfDVd5GreeUwm7uPk7eYz1eMv376kzR52C6sANPkwS' | |
5 | 5 | ||
6 | 6 | let usdnIdStr = "8UrfDVd5GreeUwm7uPk7eYz1eMv376kzR52C6sANPkwS" | |
7 | 7 | ||
8 | 8 | let puzzleId = base58'7Y96UTbBQ45cjWoHeFj2EhnjdgEt6iK2LnA4eTcfxdoD' | |
9 | 9 | ||
10 | 10 | let puzzleIdStr = "7Y96UTbBQ45cjWoHeFj2EhnjdgEt6iK2LnA4eTcfxdoD" | |
11 | 11 | ||
12 | 12 | let Scale = 1000000000000 | |
13 | 13 | ||
14 | 14 | func tryGetInteger (key) = match getInteger(this, key) { | |
15 | 15 | case b: Int => | |
16 | 16 | b | |
17 | 17 | case _ => | |
18 | 18 | 0 | |
19 | 19 | } | |
20 | 20 | ||
21 | 21 | ||
22 | 22 | func claimAliasResult (address,assetIdStr) = { | |
23 | 23 | let addressStr = toString(address) | |
24 | 24 | let currentInterest = tryGetInteger((("global_lastCheck_" + assetIdStr) + "_interest")) | |
25 | 25 | let stakedAmount = tryGetInteger((addressStr + "_staked")) | |
26 | 26 | let lastCheckInterestInState = tryGetInteger((((addressStr + "_lastCheck_") + assetIdStr) + "_interest")) | |
27 | 27 | let lastCheckInterest = if ((lastCheckInterestInState == 0)) | |
28 | 28 | then 0 | |
29 | 29 | else lastCheckInterestInState | |
30 | 30 | let reward = fraction((currentInterest - lastCheckInterest), stakedAmount, Scale) | |
31 | 31 | [IntegerEntry((((addressStr + "_lastCheck_") + assetIdStr) + "_interest"), currentInterest), IntegerEntry((((addressStr + "_") + assetIdStr) + "_claimed"), (tryGetInteger((((addressStr + "_") + assetIdStr) + "_claimed")) + reward)), ScriptTransfer(address, reward, fromBase58String(assetIdStr))] | |
32 | 32 | } | |
33 | 33 | ||
34 | 34 | ||
35 | 35 | func claimResult (address) = (claimAliasResult(address, usdnIdStr) ++ claimAliasResult(address, puzzleIdStr)) | |
36 | 36 | ||
37 | 37 | ||
38 | 38 | @Callable(i) | |
39 | 39 | func stake () = { | |
40 | 40 | let amount = i.payments[0].amount | |
41 | 41 | let addressStr = toString(i.caller) | |
42 | 42 | let assetIdStr = toBase58String(usdnId) | |
43 | 43 | let totalStakedAmount = tryGetInteger("global_staked") | |
44 | 44 | if ((i.payments[0].assetId != puzzleId)) | |
45 | 45 | then throw("wrong asset attached") | |
46 | 46 | else (claimResult(i.caller) ++ [IntegerEntry("global_staked", (totalStakedAmount + amount)), IntegerEntry((addressStr + "_staked"), (tryGetInteger((addressStr + "_staked")) + amount))]) | |
47 | 47 | } | |
48 | 48 | ||
49 | 49 | ||
50 | 50 | ||
51 | 51 | @Callable(i) | |
52 | 52 | func unStake (amount) = { | |
53 | 53 | let addressStr = toString(i.caller) | |
54 | 54 | let stakedAmount = tryGetInteger((addressStr + "_staked")) | |
55 | 55 | if ((amount > stakedAmount)) | |
56 | 56 | then throw("you don't have tokens available") | |
57 | 57 | else (claimResult(i.caller) ++ [IntegerEntry((addressStr + "_staked"), (stakedAmount - amount)), IntegerEntry("global_staked", (tryGetInteger("global_staked") - amount)), ScriptTransfer(i.caller, amount, puzzleId)]) | |
58 | 58 | } | |
59 | 59 | ||
60 | 60 | ||
61 | 61 | ||
62 | 62 | @Callable(i) | |
63 | 63 | func claimReward () = claimResult(i.caller) | |
64 | 64 | ||
65 | 65 | ||
66 | 66 | ||
67 | 67 | @Callable(i) | |
68 | 68 | func topUpReward () = { | |
69 | 69 | let pmtAsset = value(i.payments[0].assetId) | |
70 | 70 | let pmtAmount = i.payments[0].amount | |
71 | 71 | let amount = if ((pmtAsset == usdnId)) | |
72 | 72 | then 0 | |
73 | 73 | else if ((pmtAsset == puzzleId)) | |
74 | 74 | then pmtAmount | |
75 | 75 | else throw("not correct asset attached") | |
76 | 76 | if ((amount == amount)) | |
77 | 77 | then { | |
78 | 78 | let currentInterest = tryGetInteger((("global_lastCheck_" + puzzleIdStr) + "_interest")) | |
79 | 79 | let totalStakedAmount = tryGetInteger("global_staked") | |
80 | 80 | let interestDelta = if ((totalStakedAmount > 0)) | |
81 | 81 | then fraction(amount, Scale, totalStakedAmount) | |
82 | 82 | else 0 | |
83 | - | if ((pmtAsset != usdnId)) | |
84 | - | then $Tuple2([IntegerEntry((("global_" + puzzleIdStr) + "_earnings"), (tryGetInteger((("global_" + puzzleIdStr) + "_earnings")) + amount)), IntegerEntry((("global_lastCheck_" + puzzleIdStr) + "_interest"), (currentInterest + interestDelta))], amount) | |
85 | - | else nil | |
83 | + | $Tuple2([IntegerEntry((("global_" + puzzleIdStr) + "_earnings"), (tryGetInteger((("global_" + puzzleIdStr) + "_earnings")) + amount)), IntegerEntry((("global_lastCheck_" + puzzleIdStr) + "_interest"), (currentInterest + interestDelta))], amount) | |
86 | 84 | } | |
87 | 85 | else throw("Strict value is not equal to itself.") | |
88 | 86 | } | |
89 | 87 | ||
90 | 88 | ||
91 | 89 | @Verifier(tx) | |
92 | 90 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
93 | 91 |
github/deemru/w8io/026f985 22.44 ms ◑