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