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