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