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