tx · 2xTuDxd9TYCpDyWZsfoVoLSbKkZjBHCzwPdEtBjkjDPr 3N1p8KYgT8gPKQKmEAwC7dZqaCxixcLQENQ: -0.03200000 Waves 2022.06.12 07:18 [2092669] smart account 3N1p8KYgT8gPKQKmEAwC7dZqaCxixcLQENQ > SELF 0.00000000 Waves
{ "type": 13, "id": "2xTuDxd9TYCpDyWZsfoVoLSbKkZjBHCzwPdEtBjkjDPr", "fee": 3200000, "feeAssetId": null, "timestamp": 1655007529804, "version": 2, "chainId": 84, "sender": "3N1p8KYgT8gPKQKmEAwC7dZqaCxixcLQENQ", "senderPublicKey": "2j8G3B9DwxqTkiUNTjLcakB9EwF3vC2XjM1Wpo1WXo2a", "proofs": [ "4zoitVD5DAyd9sbE1uciCDhQgUCotUJ4NZPGRMsQUXUJKNFezR6rApHsVfhhANaRVGPGyjWz7fAFDrzrTm1WL1w6" ], "script": "base64:AAIFAAAAAAAAABIIAhIAEgMKAQESABIAEgMKAQgAAAAmAAAAAA1rX3RvdGFsU3VwcGx5AgAAAA1rX3RvdGFsU3VwcGx5AAAAABBrX2xhc3RVcGRhdGVUaW1lAgAAABBrX2xhc3RVcGRhdGVUaW1lAAAAABZrX3Jld2FyZFBlclRva2VuU3RvcmVkAgAAABZrX3Jld2FyZFBlclRva2VuU3RvcmVkAAAAAAxrX3Jld2FyZFJhdGUCAAAADGtfcmV3YXJkUmF0ZQAAAAAOa19wZXJpb2RGaW5pc2gCAAAADmtfcGVyaW9kRmluaXNoAAAAAAlrX2JhbGFuY2UCAAAACWtfYmFsYW5jZQAAAAAUa191c2VyUmV3YXJkUGVyVG9rZW4CAAAAFGtfdXNlclJld2FyZFBlclRva2VuAAAAAAxrX3VzZXJSZXdhcmQCAAAADGtfdXNlclJld2FyZAAAAAANQURNSU5fQUREUkVTUwkBAAAAB0FkZHJlc3MAAAABAQAAABoBVIt1l0LJos0vBhIo6NUhsvEOx80Z5hl1twAAAAAEVVNETgEAAAAg93bq9/eDymXbbhPuAjvPWCm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WtlcgQAAAAMc3Rha2VyRWFybmVkCAkBAAAADHVwZGF0ZVJld2FyZAAAAAIFAAAAB19zdGFrZXIJAQAAAAliYWxhbmNlT2YAAAABBQAAAAdfc3Rha2VyAAAAAl8zCQAAAgAAAAEJAAGkAAAAAQUAAAAMc3Rha2VyRWFybmVkAAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXl3o0f4", "height": 2092669, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 5 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let k_totalSupply = "k_totalSupply" | |
5 | + | ||
6 | + | let k_lastUpdateTime = "k_lastUpdateTime" | |
7 | + | ||
8 | + | let k_rewardPerTokenStored = "k_rewardPerTokenStored" | |
9 | + | ||
10 | + | let k_rewardRate = "k_rewardRate" | |
11 | + | ||
12 | + | let k_periodFinish = "k_periodFinish" | |
13 | + | ||
14 | + | let k_balance = "k_balance" | |
15 | + | ||
16 | + | let k_userRewardPerToken = "k_userRewardPerToken" | |
17 | + | ||
18 | + | let k_userReward = "k_userReward" | |
19 | + | ||
20 | + | let ADMIN_ADDRESS = Address(base58'3N2dUZwYyfMXi4dXxbXgq2X9GyruHcrkscS') | |
21 | + | ||
22 | + | let USDN = base58'HezsdQuRDtzksAYUy97gfhKy7Z1NW2uXYSHA3bgqenNZ' | |
23 | + | ||
24 | + | let TSN = base58'HezsdQuRDtzksAYUy97gfhKy7Z1NW2uXYSHA3bgqenNY' | |
25 | + | ||
26 | + | let DECIMAL_UNIT = (1 * (((((10 * 10) * 10) * 10) * 10) * 10)) | |
27 | + | ||
28 | + | let DURATION = ((60 * 60) * 24) | |
29 | + | ||
30 | + | let NO_ADDDRESS = "" | |
31 | + | ||
32 | + | let NO_STAKER = 0 | |
33 | + | ||
34 | + | func divd (_x,_y) = fraction(_x, DECIMAL_UNIT, _y, HALFEVEN) | |
35 | + | ||
36 | + | ||
37 | + | func muld (_x,_y) = fraction(_x, _y, DECIMAL_UNIT, HALFEVEN) | |
38 | + | ||
39 | + | ||
40 | + | func abs (_x) = if ((_x > 0)) | |
41 | + | then _x | |
42 | + | else -(_x) | |
43 | + | ||
44 | + | ||
45 | + | func toCompositeKey (_key,_address) = ((_key + "_") + _address) | |
46 | + | ||
47 | + | ||
48 | + | func int (k) = valueOrErrorMessage(getInteger(this, k), ("no value for " + k)) | |
49 | + | ||
50 | + | ||
51 | + | func int0 (k) = valueOrElse(getInteger(this, k), 0) | |
52 | + | ||
53 | + | ||
54 | + | func totalSupply () = int(k_totalSupply) | |
55 | + | ||
56 | + | ||
57 | + | func rewardPerTokenStored () = int(k_rewardPerTokenStored) | |
58 | + | ||
59 | + | ||
60 | + | func lastUpdateTime () = int(k_lastUpdateTime) | |
61 | + | ||
62 | + | ||
63 | + | func rewardRate () = int(k_rewardRate) | |
64 | + | ||
65 | + | ||
66 | + | func periodFinish () = int0(k_periodFinish) | |
67 | + | ||
68 | + | ||
69 | + | func rewards (_staker) = int0(toCompositeKey(k_userReward, _staker)) | |
70 | + | ||
71 | + | ||
72 | + | func userRewardPerTokenPaid (_staker) = int0(toCompositeKey(k_userRewardPerToken, _staker)) | |
73 | + | ||
74 | + | ||
75 | + | func balanceOf (_staker) = int0(toCompositeKey(k_balance, _staker)) | |
76 | + | ||
77 | + | ||
78 | + | func updateRewardRate (_rewardRate) = [IntegerEntry(k_rewardRate, _rewardRate)] | |
79 | + | ||
80 | + | ||
81 | + | func updateTime (_lastUpdateTime,_periodFinish) = [IntegerEntry(k_lastUpdateTime, _lastUpdateTime), IntegerEntry(k_periodFinish, _periodFinish)] | |
82 | + | ||
83 | + | ||
84 | + | func updateRewardPerTokenStored (_rewardPerTokenStored) = [IntegerEntry(k_rewardPerTokenStored, _rewardPerTokenStored)] | |
85 | + | ||
86 | + | ||
87 | + | func updateUserRewards (_staker,_reward,_userRewardPerToken) = [IntegerEntry(toCompositeKey(k_userReward, _staker), _reward), IntegerEntry(toCompositeKey(k_userRewardPerToken, _staker), _userRewardPerToken)] | |
88 | + | ||
89 | + | ||
90 | + | func updateBalance (_staker,_delta) = [IntegerEntry(toCompositeKey(k_balance, _staker), (balanceOf(_staker) + _delta))] | |
91 | + | ||
92 | + | ||
93 | + | func currentTimestampSec () = (lastBlock.timestamp / 1000) | |
94 | + | ||
95 | + | ||
96 | + | func rewardPerToken () = if ((totalSupply() == 0)) | |
97 | + | then rewardPerTokenStored() | |
98 | + | else (rewardPerTokenStored() + (((currentTimestampSec() - lastUpdateTime()) * rewardRate()) / totalSupply())) | |
99 | + | ||
100 | + | ||
101 | + | func earned (_staker,_balance) = { | |
102 | + | let rewardDelta = (rewardPerToken() - userRewardPerTokenPaid(_staker)) | |
103 | + | ((_balance * rewardDelta) + rewards(_staker)) | |
104 | + | } | |
105 | + | ||
106 | + | ||
107 | + | func updateReward (_staker,_balance) = { | |
108 | + | let newRewardPerTokenStored = rewardPerToken() | |
109 | + | let newLastUpdateTime = currentTimestampSec() | |
110 | + | let $t033133486 = if ((_staker != "")) | |
111 | + | then $Tuple2(earned(_staker, _balance), newRewardPerTokenStored) | |
112 | + | else $Tuple2(0, 0) | |
113 | + | let stakerEarned = $t033133486._1 | |
114 | + | let stakerRewardPerTokenPaid = $t033133486._2 | |
115 | + | $Tuple4(newRewardPerTokenStored, newLastUpdateTime, stakerEarned, stakerRewardPerTokenPaid) | |
116 | + | } | |
117 | + | ||
118 | + | ||
119 | + | @Callable(i) | |
120 | + | func stake () = { | |
121 | + | let _staker = toString(i.caller) | |
122 | + | let _amount = i.payments[0].amount | |
123 | + | if ((i.payments[0].assetId != TSN)) | |
124 | + | then throw("Invalid staking asset") | |
125 | + | else { | |
126 | + | let $t037963978 = updateReward(_staker, (balanceOf(_staker) + _amount)) | |
127 | + | let newRewardPerTokenStored = $t037963978._1 | |
128 | + | let newLastUpdateTime = $t037963978._2 | |
129 | + | let stakerEarned = $t037963978._3 | |
130 | + | let stakerRewardPerTokenPaid = $t037963978._4 | |
131 | + | (((updateUserRewards(_staker, 0, stakerRewardPerTokenPaid) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(newLastUpdateTime, periodFinish())) ++ updateBalance(_staker, _amount)) | |
132 | + | } | |
133 | + | } | |
134 | + | ||
135 | + | ||
136 | + | ||
137 | + | @Callable(i) | |
138 | + | func unStake (_amount) = { | |
139 | + | let _staker = toString(i.caller) | |
140 | + | if ((_amount > balanceOf(_staker))) | |
141 | + | then throw("Invalid balance") | |
142 | + | else { | |
143 | + | let $t043934575 = updateReward(_staker, (balanceOf(_staker) - _amount)) | |
144 | + | let newRewardPerTokenStored = $t043934575._1 | |
145 | + | let newLastUpdateTime = $t043934575._2 | |
146 | + | let stakerEarned = $t043934575._3 | |
147 | + | let stakerRewardPerTokenPaid = $t043934575._4 | |
148 | + | ((((updateUserRewards(_staker, 0, stakerRewardPerTokenPaid) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(newLastUpdateTime, periodFinish())) ++ updateBalance(_staker, -(_amount))) ++ [ScriptTransfer(i.caller, _amount, TSN)]) | |
149 | + | } | |
150 | + | } | |
151 | + | ||
152 | + | ||
153 | + | ||
154 | + | @Callable(i) | |
155 | + | func withdrawRewards () = { | |
156 | + | let _staker = toString(i.caller) | |
157 | + | let $t049905142 = updateReward(_staker, balanceOf(_staker)) | |
158 | + | let newRewardPerTokenStored = $t049905142._1 | |
159 | + | let newLastUpdateTime = $t049905142._2 | |
160 | + | let stakerEarned = $t049905142._3 | |
161 | + | let stakerRewardPerTokenPaid = $t049905142._4 | |
162 | + | if ((0 >= stakerEarned)) | |
163 | + | then throw("No reward") | |
164 | + | else (((updateUserRewards(_staker, 0, stakerRewardPerTokenPaid) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(newLastUpdateTime, periodFinish())) ++ [ScriptTransfer(i.caller, stakerEarned, USDN)]) | |
165 | + | } | |
166 | + | ||
167 | + | ||
168 | + | ||
169 | + | @Callable(i) | |
170 | + | func addRewards () = if ((i.payments[0].assetId != USDN)) | |
171 | + | then throw("Invaliid addRewards params") | |
172 | + | else { | |
173 | + | let _reward = i.payments[0].amount | |
174 | + | let newRewardPerTokenStored = updateReward(NO_ADDDRESS, NO_STAKER)._1 | |
175 | + | let timestamp = currentTimestampSec() | |
176 | + | let newRewardRate = if ((timestamp > periodFinish())) | |
177 | + | then (_reward / DURATION) | |
178 | + | else { | |
179 | + | let remainingTime = (periodFinish() - timestamp) | |
180 | + | let leftover = (rewardRate() * remainingTime) | |
181 | + | ((_reward + leftover) / DURATION) | |
182 | + | } | |
183 | + | ((updateRewardRate(newRewardRate) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(timestamp, (timestamp + DURATION))) | |
184 | + | } | |
185 | + | ||
186 | + | ||
187 | + | ||
188 | + | @Callable(i) | |
189 | + | func view_reward (_staker) = { | |
190 | + | let stakerEarned = updateReward(_staker, balanceOf(_staker))._3 | |
191 | + | throw(toString(stakerEarned)) | |
192 | + | } | |
193 | + | ||
194 | + | ||
195 | + | @Verifier(tx) | |
196 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
197 | + |
github/deemru/w8io/169f3d6 45.49 ms ◑