tx · FZp5a9PRkYdVhgjhRfcvwv41SP13UBuFmCXvLzmkHT92 3N4QWZXfZqNf284CJVbtxzCerqARoALxJEy: -0.03700000 Waves 2022.10.06 10:42 [2260170] smart account 3N4QWZXfZqNf284CJVbtxzCerqARoALxJEy > SELF 0.00000000 Waves
{ "type": 13, "id": "FZp5a9PRkYdVhgjhRfcvwv41SP13UBuFmCXvLzmkHT92", "fee": 3700000, "feeAssetId": null, "timestamp": 1665042161809, "version": 2, "chainId": 84, "sender": "3N4QWZXfZqNf284CJVbtxzCerqARoALxJEy", "senderPublicKey": "GzEvTfwa3251fRwyTL99QzUmkDGBdn4cNr2mR6XQ1UmR", "proofs": [ "2VrxujthqFidNLfVQXajbKpiJSPrv6R94B9ZsCbi4i5XVxW8cS3q1NCTxp9FJhpUvb6v3mQ2BsrSHgrdzhiHWihG" ], "script": "base64:BgIgCAISAwoBCBIAEgMKAQESABIAEgASAwoBCBIDCgEIEgA2AA1rX3RvdGFsU3VwcGx5Ag1rX3RvdGFsU3VwcGx5AA9rX3Jld2FyZEJhbGFuY2UCD2tfcmV3YXJkQmFsYW5jZQAQa19sYXN0VXBkYXRlVGltZQIQa19sYXN0VXBkYXRlVGltZQAWa19yZXdhcmRQZXJUb2tlblN0b3JlZAIWa19yZXdhcmRQZXJUb2tlblN0b3JlZAAMa19yZXdhcmRSYXRlAgxrX3Jld2FyZFJhdGUADmtfcGVyaW9kRmluaXNoAg5rX3BlcmlvZEZpbmlzaAAJa19iYWxhbmNlAglrX2JhbGFuY2UAFGtfdXNlclJld2FyZFBlclRva2VuAhRrX3VzZXJSZXdhcmRQZXJUb2tlbgAMa191c2VyUmV3YXJkAgxrX3VzZXJSZXdhcmQADWtfaW5pdGlhbGl6ZWQCDWtfaW5pdGlhbGl6ZWQAFGtfY29vcmRpbmF0b3JBZGRyZXNzAhRrX2Nvb3JkaW5hdG9yQWRkcmVzcwASa19nb3Zlcm5hbmNlX2Fzc2V0AgtrX2dvdl9hc3NldAANa19xdW90Z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5hZG1pblB1YmxpY0tleQBsPlOF", "height": 2260170, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: AZfJwranHSXKucjoToZXrfqpxi7VyY46kqZXSp8sFwUu Next: Fg769VxgVGD1eyQm9t5TBbnuSWeEnEkQsDSpstSqGSZZ Diff:
Old | New | Differences | |
---|---|---|---|
29 | 29 | ||
30 | 30 | let k_admin_public_key = "k_admin_public_key" | |
31 | 31 | ||
32 | + | let k_manager_address = "k_manager_address" | |
33 | + | ||
32 | 34 | func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(this, k_coordinatorAddress)), "Coordinator not set") | |
33 | 35 | ||
34 | 36 | ||
39 | 41 | ||
40 | 42 | ||
41 | 43 | func quoteAsset () = fromBase58String(getStringValue(coordinator(), k_quote_asset)) | |
44 | + | ||
45 | + | ||
46 | + | func managerAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_manager_address)), "Manager not set") | |
42 | 47 | ||
43 | 48 | ||
44 | 49 | let DECIMAL_UNIT = (1 * (((((((10 * 10) * 10) * 10) * 10) * 10) * 10) * 10)) | |
155 | 160 | func updateReward (_staker,_balanceDelta) = { | |
156 | 161 | let newRewardPerTokenStored = rewardPerToken(_balanceDelta) | |
157 | 162 | let newLastUpdateTime = currentTimestampSec() | |
158 | - | let $ | |
163 | + | let $t050205212 = if ((_staker != "")) | |
159 | 164 | then $Tuple2(earned(_staker, _balanceDelta), newRewardPerTokenStored) | |
160 | 165 | else $Tuple2(0, 0) | |
161 | - | let stakerEarned = $ | |
162 | - | let stakerRewardPerTokenPaid = $ | |
166 | + | let stakerEarned = $t050205212._1 | |
167 | + | let stakerRewardPerTokenPaid = $t050205212._2 | |
163 | 168 | $Tuple4(newRewardPerTokenStored, newLastUpdateTime, stakerEarned, stakerRewardPerTokenPaid) | |
164 | 169 | } | |
165 | 170 | ||
180 | 185 | else !(initialized())) | |
181 | 186 | then throw("Invalid call to stake") | |
182 | 187 | else { | |
183 | - | let $ | |
184 | - | let newRewardPerTokenStored = $ | |
185 | - | let newLastUpdateTime = $ | |
186 | - | let stakerEarned = $ | |
187 | - | let stakerRewardPerTokenPaid = $ | |
188 | + | let $t058686033 = updateReward(_staker, 0) | |
189 | + | let newRewardPerTokenStored = $t058686033._1 | |
190 | + | let newLastUpdateTime = $t058686033._2 | |
191 | + | let stakerEarned = $t058686033._3 | |
192 | + | let stakerRewardPerTokenPaid = $t058686033._4 | |
188 | 193 | (((updateUserRewards(_staker, stakerEarned, stakerRewardPerTokenPaid) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(newLastUpdateTime, periodFinish())) ++ updateBalance(_staker, _amount)) | |
189 | 194 | } | |
190 | 195 | } | |
201 | 206 | else !(initialized())) | |
202 | 207 | then throw("Invalid unStake parameters") | |
203 | 208 | else { | |
204 | - | let $ | |
205 | - | let newRewardPerTokenStored = $ | |
206 | - | let newLastUpdateTime = $ | |
207 | - | let stakerEarned = $ | |
208 | - | let stakerRewardPerTokenPaid = $ | |
209 | + | let $t065646729 = updateReward(_staker, 0) | |
210 | + | let newRewardPerTokenStored = $t065646729._1 | |
211 | + | let newLastUpdateTime = $t065646729._2 | |
212 | + | let stakerEarned = $t065646729._3 | |
213 | + | let stakerRewardPerTokenPaid = $t065646729._4 | |
209 | 214 | ((((updateUserRewards(_staker, stakerEarned, stakerRewardPerTokenPaid) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(newLastUpdateTime, periodFinish())) ++ updateBalance(_staker, -(_amount))) ++ [ScriptTransfer(i.caller, _amount, governanceAsset())]) | |
210 | 215 | } | |
211 | 216 | } | |
215 | 220 | @Callable(i) | |
216 | 221 | func withdrawRewards () = { | |
217 | 222 | let _staker = toString(i.caller) | |
218 | - | let $ | |
219 | - | let newRewardPerTokenStored = $ | |
220 | - | let newLastUpdateTime = $ | |
221 | - | let stakerEarned = $ | |
222 | - | let stakerRewardPerTokenPaid = $ | |
223 | + | let $t072057350 = updateReward(_staker, 0) | |
224 | + | let newRewardPerTokenStored = $t072057350._1 | |
225 | + | let newLastUpdateTime = $t072057350._2 | |
226 | + | let stakerEarned = $t072057350._3 | |
227 | + | let stakerRewardPerTokenPaid = $t072057350._4 | |
223 | 228 | if (if ((0 >= stakerEarned)) | |
224 | 229 | then true | |
225 | 230 | else !(initialized())) | |
226 | 231 | then throw("No reward") | |
227 | - | else ((((updateUserRewards(_staker, 0, stakerRewardPerTokenPaid) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(newLastUpdateTime, periodFinish())) ++ updateRewardBalance(-(stakerEarned))) ++ [ScriptTransfer(i.caller, usdnFromDecimals(stakerEarned), quoteAsset())]) | |
232 | + | else { | |
233 | + | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), usdnFromDecimals(stakerEarned)], nil) | |
234 | + | if ((unstake == unstake)) | |
235 | + | then ((((updateUserRewards(_staker, 0, stakerRewardPerTokenPaid) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(newLastUpdateTime, periodFinish())) ++ updateRewardBalance(-(stakerEarned))) ++ [ScriptTransfer(i.caller, usdnFromDecimals(stakerEarned), quoteAsset())]) | |
236 | + | else throw("Strict value is not equal to itself.") | |
237 | + | } | |
228 | 238 | } | |
229 | 239 | ||
230 | 240 | ||
236 | 246 | then throw("Invalid addRewards params") | |
237 | 247 | else { | |
238 | 248 | let _reward = usdnToDecimals(i.payments[0].amount) | |
239 | - | let newRewardPerTokenStored = updateReward(NO_ADDRESS, NO_STAKER)._1 | |
240 | - | let timestamp = currentTimestampSec() | |
241 | - | let newRewardRate = if ((timestamp > periodFinish())) | |
242 | - | then (_reward / DURATION) | |
243 | - | else { | |
244 | - | let remainingTime = (periodFinish() - timestamp) | |
245 | - | let leftover = (rewardRate() * remainingTime) | |
246 | - | ((_reward + leftover) / DURATION) | |
249 | + | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), usdnFromDecimals(_reward))]) | |
250 | + | if ((stake == stake)) | |
251 | + | then { | |
252 | + | let newRewardPerTokenStored = updateReward(NO_ADDRESS, NO_STAKER)._1 | |
253 | + | let timestamp = currentTimestampSec() | |
254 | + | let newRewardRate = if ((timestamp > periodFinish())) | |
255 | + | then (_reward / DURATION) | |
256 | + | else { | |
257 | + | let remainingTime = (periodFinish() - timestamp) | |
258 | + | let leftover = (rewardRate() * remainingTime) | |
259 | + | ((_reward + leftover) / DURATION) | |
260 | + | } | |
261 | + | (((updateRewardRate(newRewardRate) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateRewardBalance(_reward)) ++ updateTime(timestamp, (timestamp + DURATION))) | |
247 | 262 | } | |
248 | - | ( | |
263 | + | else throw("Strict value is not equal to itself.") | |
249 | 264 | } | |
250 | 265 | ||
251 | 266 | ||
258 | 273 | if ((0 >= rewardDelta)) | |
259 | 274 | then throw("Invalid ackRewards params") | |
260 | 275 | else { | |
261 | - | let _reward = rewardDelta | |
262 | - | let newRewardPerTokenStored = updateReward(NO_ADDRESS, NO_STAKER)._1 | |
263 | - | let timestamp = currentTimestampSec() | |
264 | - | let newRewardRate = if ((timestamp > periodFinish())) | |
265 | - | then (_reward / DURATION) | |
266 | - | else { | |
267 | - | let remainingTime = (periodFinish() - timestamp) | |
268 | - | let leftover = (rewardRate() * remainingTime) | |
269 | - | ((_reward + leftover) / DURATION) | |
276 | + | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), usdnFromDecimals(rewardDelta))]) | |
277 | + | if ((stake == stake)) | |
278 | + | then { | |
279 | + | let _reward = rewardDelta | |
280 | + | let newRewardPerTokenStored = updateReward(NO_ADDRESS, NO_STAKER)._1 | |
281 | + | let timestamp = currentTimestampSec() | |
282 | + | let newRewardRate = if ((timestamp > periodFinish())) | |
283 | + | then (_reward / DURATION) | |
284 | + | else { | |
285 | + | let remainingTime = (periodFinish() - timestamp) | |
286 | + | let leftover = (rewardRate() * remainingTime) | |
287 | + | ((_reward + leftover) / DURATION) | |
288 | + | } | |
289 | + | (((updateRewardRate(newRewardRate) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateRewardBalance(_reward)) ++ updateTime(timestamp, (timestamp + DURATION))) | |
270 | 290 | } | |
271 | - | ( | |
291 | + | else throw("Strict value is not equal to itself.") | |
272 | 292 | } | |
273 | 293 | } | |
274 | 294 | ||
289 | 309 | } | |
290 | 310 | ||
291 | 311 | ||
312 | + | ||
313 | + | @Callable(i) | |
314 | + | func migrateLiquidity () = { | |
315 | + | let amount = usdnFromDecimals(rewardBalance()) | |
316 | + | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), amount)]) | |
317 | + | if ((stake == stake)) | |
318 | + | then nil | |
319 | + | else throw("Strict value is not equal to itself.") | |
320 | + | } | |
321 | + | ||
322 | + | ||
292 | 323 | @Verifier(tx) | |
293 | 324 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], adminPublicKey()) | |
294 | 325 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let k_totalSupply = "k_totalSupply" | |
5 | 5 | ||
6 | 6 | let k_rewardBalance = "k_rewardBalance" | |
7 | 7 | ||
8 | 8 | let k_lastUpdateTime = "k_lastUpdateTime" | |
9 | 9 | ||
10 | 10 | let k_rewardPerTokenStored = "k_rewardPerTokenStored" | |
11 | 11 | ||
12 | 12 | let k_rewardRate = "k_rewardRate" | |
13 | 13 | ||
14 | 14 | let k_periodFinish = "k_periodFinish" | |
15 | 15 | ||
16 | 16 | let k_balance = "k_balance" | |
17 | 17 | ||
18 | 18 | let k_userRewardPerToken = "k_userRewardPerToken" | |
19 | 19 | ||
20 | 20 | let k_userReward = "k_userReward" | |
21 | 21 | ||
22 | 22 | let k_initialized = "k_initialized" | |
23 | 23 | ||
24 | 24 | let k_coordinatorAddress = "k_coordinatorAddress" | |
25 | 25 | ||
26 | 26 | let k_governance_asset = "k_gov_asset" | |
27 | 27 | ||
28 | 28 | let k_quote_asset = "k_quote_asset" | |
29 | 29 | ||
30 | 30 | let k_admin_public_key = "k_admin_public_key" | |
31 | 31 | ||
32 | + | let k_manager_address = "k_manager_address" | |
33 | + | ||
32 | 34 | func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(this, k_coordinatorAddress)), "Coordinator not set") | |
33 | 35 | ||
34 | 36 | ||
35 | 37 | func adminPublicKey () = fromBase58String(getStringValue(coordinator(), k_admin_public_key)) | |
36 | 38 | ||
37 | 39 | ||
38 | 40 | func governanceAsset () = fromBase58String(getStringValue(coordinator(), k_governance_asset)) | |
39 | 41 | ||
40 | 42 | ||
41 | 43 | func quoteAsset () = fromBase58String(getStringValue(coordinator(), k_quote_asset)) | |
44 | + | ||
45 | + | ||
46 | + | func managerAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_manager_address)), "Manager not set") | |
42 | 47 | ||
43 | 48 | ||
44 | 49 | let DECIMAL_UNIT = (1 * (((((((10 * 10) * 10) * 10) * 10) * 10) * 10) * 10)) | |
45 | 50 | ||
46 | 51 | let DURATION = ((60 * 60) * 24) | |
47 | 52 | ||
48 | 53 | let NO_ADDRESS = "" | |
49 | 54 | ||
50 | 55 | let NO_STAKER = 0 | |
51 | 56 | ||
52 | 57 | func usdnFromDecimals (_amount) = (_amount / 100) | |
53 | 58 | ||
54 | 59 | ||
55 | 60 | func usdnToDecimals (_amount) = (_amount * 100) | |
56 | 61 | ||
57 | 62 | ||
58 | 63 | func divd (_x,_y) = fraction(_x, DECIMAL_UNIT, _y, HALFEVEN) | |
59 | 64 | ||
60 | 65 | ||
61 | 66 | func muld (_x,_y) = fraction(_x, _y, DECIMAL_UNIT, HALFEVEN) | |
62 | 67 | ||
63 | 68 | ||
64 | 69 | func abs (_x) = if ((_x > 0)) | |
65 | 70 | then _x | |
66 | 71 | else -(_x) | |
67 | 72 | ||
68 | 73 | ||
69 | 74 | func minv (_x,_y) = if ((_x > _y)) | |
70 | 75 | then _y | |
71 | 76 | else _x | |
72 | 77 | ||
73 | 78 | ||
74 | 79 | func toCompositeKey (_key,_address) = ((_key + "_") + _address) | |
75 | 80 | ||
76 | 81 | ||
77 | 82 | func int (k) = valueOrErrorMessage(getInteger(this, k), ("no value for " + k)) | |
78 | 83 | ||
79 | 84 | ||
80 | 85 | func int0 (k) = valueOrElse(getInteger(this, k), 0) | |
81 | 86 | ||
82 | 87 | ||
83 | 88 | func totalSupply () = int0(k_totalSupply) | |
84 | 89 | ||
85 | 90 | ||
86 | 91 | func rewardPerTokenStored () = int0(k_rewardPerTokenStored) | |
87 | 92 | ||
88 | 93 | ||
89 | 94 | func lastUpdateTime () = int0(k_lastUpdateTime) | |
90 | 95 | ||
91 | 96 | ||
92 | 97 | func rewardRate () = int0(k_rewardRate) | |
93 | 98 | ||
94 | 99 | ||
95 | 100 | func periodFinish () = int0(k_periodFinish) | |
96 | 101 | ||
97 | 102 | ||
98 | 103 | func rewardBalance () = int0(k_rewardBalance) | |
99 | 104 | ||
100 | 105 | ||
101 | 106 | func rewards (_staker) = int0(toCompositeKey(k_userReward, _staker)) | |
102 | 107 | ||
103 | 108 | ||
104 | 109 | func userRewardPerTokenPaid (_staker) = int0(toCompositeKey(k_userRewardPerToken, _staker)) | |
105 | 110 | ||
106 | 111 | ||
107 | 112 | func balanceOf (_staker) = int0(toCompositeKey(k_balance, _staker)) | |
108 | 113 | ||
109 | 114 | ||
110 | 115 | func initialized () = valueOrElse(getBoolean(this, k_initialized), false) | |
111 | 116 | ||
112 | 117 | ||
113 | 118 | func updateRewardBalance (_delta) = [IntegerEntry(k_rewardBalance, (rewardBalance() + _delta))] | |
114 | 119 | ||
115 | 120 | ||
116 | 121 | func updateRewardRate (_rewardRate) = [IntegerEntry(k_rewardRate, _rewardRate)] | |
117 | 122 | ||
118 | 123 | ||
119 | 124 | func updateTime (_lastUpdateTime,_periodFinish) = [IntegerEntry(k_lastUpdateTime, _lastUpdateTime), IntegerEntry(k_periodFinish, _periodFinish)] | |
120 | 125 | ||
121 | 126 | ||
122 | 127 | func updateRewardPerTokenStored (_rewardPerTokenStored) = [IntegerEntry(k_rewardPerTokenStored, _rewardPerTokenStored)] | |
123 | 128 | ||
124 | 129 | ||
125 | 130 | func updateUserRewards (_staker,_reward,_userRewardPerToken) = [IntegerEntry(toCompositeKey(k_userReward, _staker), _reward), IntegerEntry(toCompositeKey(k_userRewardPerToken, _staker), _userRewardPerToken)] | |
126 | 131 | ||
127 | 132 | ||
128 | 133 | func updateBalance (_staker,_delta) = [IntegerEntry(toCompositeKey(k_balance, _staker), (balanceOf(_staker) + _delta)), IntegerEntry(k_totalSupply, (totalSupply() + _delta))] | |
129 | 134 | ||
130 | 135 | ||
131 | 136 | func currentTimestampSec () = (lastBlock.timestamp / 1000) | |
132 | 137 | ||
133 | 138 | ||
134 | 139 | func lastTimeRewardApplicable () = minv(currentTimestampSec(), periodFinish()) | |
135 | 140 | ||
136 | 141 | ||
137 | 142 | func rewardPerToken (_balanceDelta) = if (((totalSupply() + _balanceDelta) == 0)) | |
138 | 143 | then rewardPerTokenStored() | |
139 | 144 | else { | |
140 | 145 | let timeInterval = (lastTimeRewardApplicable() - lastUpdateTime()) | |
141 | 146 | let actualTimeInterval = if ((0 > timeInterval)) | |
142 | 147 | then 0 | |
143 | 148 | else timeInterval | |
144 | 149 | let diff = divd((rewardRate() * actualTimeInterval), (totalSupply() + _balanceDelta)) | |
145 | 150 | (rewardPerTokenStored() + diff) | |
146 | 151 | } | |
147 | 152 | ||
148 | 153 | ||
149 | 154 | func earned (_staker,_balanceDelta) = { | |
150 | 155 | let rewardDelta = (rewardPerToken(_balanceDelta) - userRewardPerTokenPaid(_staker)) | |
151 | 156 | (muld((balanceOf(_staker) + _balanceDelta), rewardDelta) + rewards(_staker)) | |
152 | 157 | } | |
153 | 158 | ||
154 | 159 | ||
155 | 160 | func updateReward (_staker,_balanceDelta) = { | |
156 | 161 | let newRewardPerTokenStored = rewardPerToken(_balanceDelta) | |
157 | 162 | let newLastUpdateTime = currentTimestampSec() | |
158 | - | let $ | |
163 | + | let $t050205212 = if ((_staker != "")) | |
159 | 164 | then $Tuple2(earned(_staker, _balanceDelta), newRewardPerTokenStored) | |
160 | 165 | else $Tuple2(0, 0) | |
161 | - | let stakerEarned = $ | |
162 | - | let stakerRewardPerTokenPaid = $ | |
166 | + | let stakerEarned = $t050205212._1 | |
167 | + | let stakerRewardPerTokenPaid = $t050205212._2 | |
163 | 168 | $Tuple4(newRewardPerTokenStored, newLastUpdateTime, stakerEarned, stakerRewardPerTokenPaid) | |
164 | 169 | } | |
165 | 170 | ||
166 | 171 | ||
167 | 172 | @Callable(i) | |
168 | 173 | func initialize (_coordinator) = if (initialized()) | |
169 | 174 | then throw("Already initialized") | |
170 | 175 | else [StringEntry(k_coordinatorAddress, _coordinator), BooleanEntry(k_initialized, true)] | |
171 | 176 | ||
172 | 177 | ||
173 | 178 | ||
174 | 179 | @Callable(i) | |
175 | 180 | func stake () = { | |
176 | 181 | let _staker = toString(i.caller) | |
177 | 182 | let _amount = i.payments[0].amount | |
178 | 183 | if (if ((i.payments[0].assetId != governanceAsset())) | |
179 | 184 | then true | |
180 | 185 | else !(initialized())) | |
181 | 186 | then throw("Invalid call to stake") | |
182 | 187 | else { | |
183 | - | let $ | |
184 | - | let newRewardPerTokenStored = $ | |
185 | - | let newLastUpdateTime = $ | |
186 | - | let stakerEarned = $ | |
187 | - | let stakerRewardPerTokenPaid = $ | |
188 | + | let $t058686033 = updateReward(_staker, 0) | |
189 | + | let newRewardPerTokenStored = $t058686033._1 | |
190 | + | let newLastUpdateTime = $t058686033._2 | |
191 | + | let stakerEarned = $t058686033._3 | |
192 | + | let stakerRewardPerTokenPaid = $t058686033._4 | |
188 | 193 | (((updateUserRewards(_staker, stakerEarned, stakerRewardPerTokenPaid) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(newLastUpdateTime, periodFinish())) ++ updateBalance(_staker, _amount)) | |
189 | 194 | } | |
190 | 195 | } | |
191 | 196 | ||
192 | 197 | ||
193 | 198 | ||
194 | 199 | @Callable(i) | |
195 | 200 | func unStake (_amount) = { | |
196 | 201 | let _staker = toString(i.caller) | |
197 | 202 | if (if (if ((_amount > balanceOf(_staker))) | |
198 | 203 | then true | |
199 | 204 | else (i.payments != nil)) | |
200 | 205 | then true | |
201 | 206 | else !(initialized())) | |
202 | 207 | then throw("Invalid unStake parameters") | |
203 | 208 | else { | |
204 | - | let $ | |
205 | - | let newRewardPerTokenStored = $ | |
206 | - | let newLastUpdateTime = $ | |
207 | - | let stakerEarned = $ | |
208 | - | let stakerRewardPerTokenPaid = $ | |
209 | + | let $t065646729 = updateReward(_staker, 0) | |
210 | + | let newRewardPerTokenStored = $t065646729._1 | |
211 | + | let newLastUpdateTime = $t065646729._2 | |
212 | + | let stakerEarned = $t065646729._3 | |
213 | + | let stakerRewardPerTokenPaid = $t065646729._4 | |
209 | 214 | ((((updateUserRewards(_staker, stakerEarned, stakerRewardPerTokenPaid) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(newLastUpdateTime, periodFinish())) ++ updateBalance(_staker, -(_amount))) ++ [ScriptTransfer(i.caller, _amount, governanceAsset())]) | |
210 | 215 | } | |
211 | 216 | } | |
212 | 217 | ||
213 | 218 | ||
214 | 219 | ||
215 | 220 | @Callable(i) | |
216 | 221 | func withdrawRewards () = { | |
217 | 222 | let _staker = toString(i.caller) | |
218 | - | let $ | |
219 | - | let newRewardPerTokenStored = $ | |
220 | - | let newLastUpdateTime = $ | |
221 | - | let stakerEarned = $ | |
222 | - | let stakerRewardPerTokenPaid = $ | |
223 | + | let $t072057350 = updateReward(_staker, 0) | |
224 | + | let newRewardPerTokenStored = $t072057350._1 | |
225 | + | let newLastUpdateTime = $t072057350._2 | |
226 | + | let stakerEarned = $t072057350._3 | |
227 | + | let stakerRewardPerTokenPaid = $t072057350._4 | |
223 | 228 | if (if ((0 >= stakerEarned)) | |
224 | 229 | then true | |
225 | 230 | else !(initialized())) | |
226 | 231 | then throw("No reward") | |
227 | - | else ((((updateUserRewards(_staker, 0, stakerRewardPerTokenPaid) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(newLastUpdateTime, periodFinish())) ++ updateRewardBalance(-(stakerEarned))) ++ [ScriptTransfer(i.caller, usdnFromDecimals(stakerEarned), quoteAsset())]) | |
232 | + | else { | |
233 | + | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), usdnFromDecimals(stakerEarned)], nil) | |
234 | + | if ((unstake == unstake)) | |
235 | + | then ((((updateUserRewards(_staker, 0, stakerRewardPerTokenPaid) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(newLastUpdateTime, periodFinish())) ++ updateRewardBalance(-(stakerEarned))) ++ [ScriptTransfer(i.caller, usdnFromDecimals(stakerEarned), quoteAsset())]) | |
236 | + | else throw("Strict value is not equal to itself.") | |
237 | + | } | |
228 | 238 | } | |
229 | 239 | ||
230 | 240 | ||
231 | 241 | ||
232 | 242 | @Callable(i) | |
233 | 243 | func addRewards () = if (if ((i.payments[0].assetId != quoteAsset())) | |
234 | 244 | then true | |
235 | 245 | else !(initialized())) | |
236 | 246 | then throw("Invalid addRewards params") | |
237 | 247 | else { | |
238 | 248 | let _reward = usdnToDecimals(i.payments[0].amount) | |
239 | - | let newRewardPerTokenStored = updateReward(NO_ADDRESS, NO_STAKER)._1 | |
240 | - | let timestamp = currentTimestampSec() | |
241 | - | let newRewardRate = if ((timestamp > periodFinish())) | |
242 | - | then (_reward / DURATION) | |
243 | - | else { | |
244 | - | let remainingTime = (periodFinish() - timestamp) | |
245 | - | let leftover = (rewardRate() * remainingTime) | |
246 | - | ((_reward + leftover) / DURATION) | |
249 | + | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), usdnFromDecimals(_reward))]) | |
250 | + | if ((stake == stake)) | |
251 | + | then { | |
252 | + | let newRewardPerTokenStored = updateReward(NO_ADDRESS, NO_STAKER)._1 | |
253 | + | let timestamp = currentTimestampSec() | |
254 | + | let newRewardRate = if ((timestamp > periodFinish())) | |
255 | + | then (_reward / DURATION) | |
256 | + | else { | |
257 | + | let remainingTime = (periodFinish() - timestamp) | |
258 | + | let leftover = (rewardRate() * remainingTime) | |
259 | + | ((_reward + leftover) / DURATION) | |
260 | + | } | |
261 | + | (((updateRewardRate(newRewardRate) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateRewardBalance(_reward)) ++ updateTime(timestamp, (timestamp + DURATION))) | |
247 | 262 | } | |
248 | - | ( | |
263 | + | else throw("Strict value is not equal to itself.") | |
249 | 264 | } | |
250 | 265 | ||
251 | 266 | ||
252 | 267 | ||
253 | 268 | @Callable(i) | |
254 | 269 | func ackRewards () = { | |
255 | 270 | let currentBalance = usdnToDecimals(assetBalance(this, quoteAsset())) | |
256 | 271 | let _rewardBalance = rewardBalance() | |
257 | 272 | let rewardDelta = (currentBalance - _rewardBalance) | |
258 | 273 | if ((0 >= rewardDelta)) | |
259 | 274 | then throw("Invalid ackRewards params") | |
260 | 275 | else { | |
261 | - | let _reward = rewardDelta | |
262 | - | let newRewardPerTokenStored = updateReward(NO_ADDRESS, NO_STAKER)._1 | |
263 | - | let timestamp = currentTimestampSec() | |
264 | - | let newRewardRate = if ((timestamp > periodFinish())) | |
265 | - | then (_reward / DURATION) | |
266 | - | else { | |
267 | - | let remainingTime = (periodFinish() - timestamp) | |
268 | - | let leftover = (rewardRate() * remainingTime) | |
269 | - | ((_reward + leftover) / DURATION) | |
276 | + | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), usdnFromDecimals(rewardDelta))]) | |
277 | + | if ((stake == stake)) | |
278 | + | then { | |
279 | + | let _reward = rewardDelta | |
280 | + | let newRewardPerTokenStored = updateReward(NO_ADDRESS, NO_STAKER)._1 | |
281 | + | let timestamp = currentTimestampSec() | |
282 | + | let newRewardRate = if ((timestamp > periodFinish())) | |
283 | + | then (_reward / DURATION) | |
284 | + | else { | |
285 | + | let remainingTime = (periodFinish() - timestamp) | |
286 | + | let leftover = (rewardRate() * remainingTime) | |
287 | + | ((_reward + leftover) / DURATION) | |
288 | + | } | |
289 | + | (((updateRewardRate(newRewardRate) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateRewardBalance(_reward)) ++ updateTime(timestamp, (timestamp + DURATION))) | |
270 | 290 | } | |
271 | - | ( | |
291 | + | else throw("Strict value is not equal to itself.") | |
272 | 292 | } | |
273 | 293 | } | |
274 | 294 | ||
275 | 295 | ||
276 | 296 | ||
277 | 297 | @Callable(i) | |
278 | 298 | func view_reward (_staker) = { | |
279 | 299 | let stakerEarned = updateReward(_staker, 0)._3 | |
280 | 300 | throw(toString(usdnFromDecimals(stakerEarned))) | |
281 | 301 | } | |
282 | 302 | ||
283 | 303 | ||
284 | 304 | ||
285 | 305 | @Callable(i) | |
286 | 306 | func computeReward (_staker) = { | |
287 | 307 | let stakerEarned = updateReward(_staker, 0)._3 | |
288 | 308 | $Tuple2(nil, stakerEarned) | |
289 | 309 | } | |
290 | 310 | ||
291 | 311 | ||
312 | + | ||
313 | + | @Callable(i) | |
314 | + | func migrateLiquidity () = { | |
315 | + | let amount = usdnFromDecimals(rewardBalance()) | |
316 | + | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), amount)]) | |
317 | + | if ((stake == stake)) | |
318 | + | then nil | |
319 | + | else throw("Strict value is not equal to itself.") | |
320 | + | } | |
321 | + | ||
322 | + | ||
292 | 323 | @Verifier(tx) | |
293 | 324 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], adminPublicKey()) | |
294 | 325 |
github/deemru/w8io/169f3d6 63.90 ms ◑