tx · 5JLXz32PHBWVcFX4VkgRzYo1PPEm3P5fFUYyu75sxJJb 3MxZ7YNAqigXR5jrgvpb48Uc6B29ouDzQyN: -0.03700000 Waves 2023.06.23 11:46 [2635075] smart account 3MxZ7YNAqigXR5jrgvpb48Uc6B29ouDzQyN > SELF 0.00000000 Waves
{ "type": 13, "id": "5JLXz32PHBWVcFX4VkgRzYo1PPEm3P5fFUYyu75sxJJb", "fee": 3700000, "feeAssetId": null, "timestamp": 1687510047350, "version": 2, "chainId": 84, "sender": "3MxZ7YNAqigXR5jrgvpb48Uc6B29ouDzQyN", "senderPublicKey": "HHCdafdi3D2htEYJw8cBoNYC8w76euLWKYENK4kanmGM", "proofs": [ "tygyjdJZtQKQpRThKZkYTLk9i1bYWPr4FhnLm6EkV8rV9JwYp1RDyPKboNimqGbGsDowVXvzENVUdsFvoYWWVXG" ], "script": "base64:BgJACAISBAoCAQESBQoDCAgBEgASAwoBARIAEgASABIDCgEBEgMKAQESAwoBARIAEgASABIDCgEIEgMKAQgSAwoBCGMADWtfdG90YWxTdXBwbHkCDWtfdG90YWxTdXBwbHkAD2tfcmV3YXJkQmFsYW5jZQIPa19yZXdhcmRCYWxhbmNlAA9rX2xvY2tlZEJhbGFuY2UCD2tfbG9ja2VkQmFsYW5jZQANa19mcmVlQmFsYW5jZQINa19mcmVlQmFsYW5jZQAPa19leGNlc3NCYWxhbmNlAg9rX2V4Y2Vzc0JhbGFuY2UADGtfdmF1bHRBc3NldAIMa192YXVsdEFzc2V0ABRrX3ZhdWx0QXNzZXREZWNpbWFscwIUa192YXVsdEFzc2V0RGVjaW1hbHMAFGtfbWF4U3BvdFV0aWxpemF0aW9uAhRrX21heFNwb3RVdGlsaXphdGlvbgATa193aXRoZHJhd1BlclBlcmlvZAITa193aXRoZHJhd1BlclBlcmlvZAAGa19yYXRlAgZrX3JhdGUAEGtfbGFzdFVwZGF0ZVRpbWUCEGtfbGFzdFVwZGF0ZVRpbWUAFmtfcmV3YXJkUGVyVG9rZW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XJpZnk6IGFkbWluIG5vdCBzZXQgaW4gY29vcmRpbmF0b3IJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAIBQJ0eA9zZW5kZXJQdWJsaWNLZXm3K1uB", "height": 2635075, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4LQkM8FVzsKULzCRucq5Xu3LFzP8DdXrBhc8t99f5dfs Next: 37j5GHYvnciKjeiEYLjeAJ3Pkf7TD5LQjEGmea7NEx3c Diff:
Old | New | Differences | |
---|---|---|---|
16 | 16 | let k_vaultAssetDecimals = "k_vaultAssetDecimals" | |
17 | 17 | ||
18 | 18 | let k_maxSpotUtilization = "k_maxSpotUtilization" | |
19 | + | ||
20 | + | let k_withdrawPerPeriod = "k_withdrawPerPeriod" | |
19 | 21 | ||
20 | 22 | let k_rate = "k_rate" | |
21 | 23 | ||
154 | 156 | func int1 (k) = valueOrElse(getInteger(this, k), DECIMAL_UNIT) | |
155 | 157 | ||
156 | 158 | ||
159 | + | func intOr (k,val) = valueOrElse(getInteger(this, k), val) | |
160 | + | ||
161 | + | ||
157 | 162 | func totalSupply () = int0(k_totalSupply) | |
158 | 163 | ||
159 | 164 | ||
208 | 213 | func maxSpotUtilization () = int0(k_maxSpotUtilization) | |
209 | 214 | ||
210 | 215 | ||
216 | + | func withdrawPerPeriod () = intOr(k_withdrawPerPeriod, WITHDRAW_PER_PERIOD) | |
217 | + | ||
218 | + | ||
211 | 219 | func initialized () = valueOrElse(getBoolean(this, k_initialized), false) | |
212 | 220 | ||
213 | 221 | ||
220 | 228 | func getWithdrawLimitLeft (_staker) = { | |
221 | 229 | let currentDate = currentTimestamp() | |
222 | 230 | let lastWithdrawDate = lastWithdrawnDate(_staker) | |
223 | - | let $ | |
231 | + | let $t064646785 = if (((currentDate - lastWithdrawDate) > WITHDRAW_PERIOD)) | |
224 | 232 | then $Tuple3(currentDate, withdrawLimit(_staker), 0) | |
225 | 233 | else $Tuple3(lastWithdrawDate, (withdrawLimit(_staker) - withdrawnInPeriod(_staker)), withdrawnInPeriod(_staker)) | |
226 | - | let newLastWithdrawnDate = $ | |
227 | - | let withdrawLimitLeft = $ | |
228 | - | let alreadyWithdrawnInPeriod = $ | |
234 | + | let newLastWithdrawnDate = $t064646785._1 | |
235 | + | let withdrawLimitLeft = $t064646785._2 | |
236 | + | let alreadyWithdrawnInPeriod = $t064646785._3 | |
229 | 237 | $Tuple3(newLastWithdrawnDate, withdrawLimitLeft, alreadyWithdrawnInPeriod) | |
230 | 238 | } | |
231 | 239 | ||
262 | 270 | func updateReward (_staker,_balanceDelta) = { | |
263 | 271 | let newRewardPerTokenStored = rewardPerToken(_balanceDelta) | |
264 | 272 | let newLastUpdateTime = currentTimestampSec() | |
265 | - | let $ | |
273 | + | let $t080078199 = if ((_staker != "")) | |
266 | 274 | then $Tuple2(earned(_staker, _balanceDelta), newRewardPerTokenStored) | |
267 | 275 | else $Tuple2(0, 0) | |
268 | - | let stakerEarned = $ | |
269 | - | let stakerRewardPerTokenPaid = $ | |
276 | + | let stakerEarned = $t080078199._1 | |
277 | + | let stakerRewardPerTokenPaid = $t080078199._2 | |
270 | 278 | $Tuple4(newRewardPerTokenStored, newLastUpdateTime, stakerEarned, stakerRewardPerTokenPaid) | |
271 | 279 | } | |
272 | 280 | ||
332 | 340 | ||
333 | 341 | ||
334 | 342 | @Callable(i) | |
335 | - | func changeSettings (_maxSpotUtilization) = if (if (if (!(initialized())) | |
343 | + | func changeSettings (_maxSpotUtilization,_withdrawPerPeriod) = if (if (if (if (!(initialized())) | |
336 | 344 | then true | |
337 | 345 | else (i.caller != adminAddress())) | |
338 | 346 | then true | |
339 | 347 | else if ((0 > _maxSpotUtilization)) | |
340 | 348 | then true | |
341 | 349 | else (_maxSpotUtilization > DECIMAL_UNIT)) | |
350 | + | then true | |
351 | + | else if ((0 > _withdrawPerPeriod)) | |
352 | + | then true | |
353 | + | else (_withdrawPerPeriod > DECIMAL_UNIT)) | |
342 | 354 | then throw("Invalid changeSettings params") | |
343 | - | else [IntegerEntry(k_maxSpotUtilization, _maxSpotUtilization)] | |
355 | + | else [IntegerEntry(k_maxSpotUtilization, _maxSpotUtilization), IntegerEntry(k_withdrawPerPeriod, _withdrawPerPeriod)] | |
344 | 356 | ||
345 | 357 | ||
346 | 358 | ||
376 | 388 | else !(initialized())) | |
377 | 389 | then throw("Invalid call to stake") | |
378 | 390 | else { | |
379 | - | let $ | |
380 | - | let newRewardPerTokenStored = $ | |
381 | - | let newLastUpdateTime = $ | |
382 | - | let stakerEarned = $ | |
383 | - | let stakerRewardPerTokenPaid = $ | |
391 | + | let $t01327313502 = updateReward(_staker, 0) | |
392 | + | let newRewardPerTokenStored = $t01327313502._1 | |
393 | + | let newLastUpdateTime = $t01327313502._2 | |
394 | + | let stakerEarned = $t01327313502._3 | |
395 | + | let stakerRewardPerTokenPaid = $t01327313502._4 | |
384 | 396 | let currentRate = rate() | |
385 | 397 | let prevAverageRate = averageRate(_staker) | |
386 | 398 | let vAmount = divd(_amount, currentRate) | |
387 | 399 | let newAverageRate = divd((muld(vAmount, currentRate) + muld(balanceOf(_staker), prevAverageRate)), (vAmount + balanceOf(_staker))) | |
388 | 400 | let newTotalBalance = (vAmount + balanceOf(_staker)) | |
389 | - | let newWithdrawLimit = muld(newTotalBalance, | |
401 | + | let newWithdrawLimit = muld(newTotalBalance, withdrawPerPeriod()) | |
390 | 402 | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(vaultAsset(), assetFromDecimals(_amount))]) | |
391 | 403 | if ((stake == stake)) | |
392 | 404 | then { | |
414 | 426 | else !(initialized())) | |
415 | 427 | then throw("Invalid call to unStake") | |
416 | 428 | else { | |
417 | - | let $ | |
418 | - | let newRewardPerTokenStored = $ | |
419 | - | let newLastUpdateTime = $ | |
420 | - | let stakerEarned = $ | |
421 | - | let stakerRewardPerTokenPaid = $ | |
422 | - | let $ | |
423 | - | let newLastWithdrawnDate = $ | |
424 | - | let withdrawLimitLeft = $ | |
425 | - | let alreadyWithdrawnInPeriod = $ | |
429 | + | let $t01509215308 = updateReward(_staker, 0) | |
430 | + | let newRewardPerTokenStored = $t01509215308._1 | |
431 | + | let newLastUpdateTime = $t01509215308._2 | |
432 | + | let stakerEarned = $t01509215308._3 | |
433 | + | let stakerRewardPerTokenPaid = $t01509215308._4 | |
434 | + | let $t01531515482 = getWithdrawLimitLeft(_staker) | |
435 | + | let newLastWithdrawnDate = $t01531515482._1 | |
436 | + | let withdrawLimitLeft = $t01531515482._2 | |
437 | + | let alreadyWithdrawnInPeriod = $t01531515482._3 | |
426 | 438 | let vAmount = divd(amountOfQuoteAsset, rate()) | |
427 | 439 | if ((vAmount > withdrawLimitLeft)) | |
428 | 440 | then throw("Invalid call to unStake: withdraw over limit") | |
452 | 464 | @Callable(i) | |
453 | 465 | func withdrawRewards () = { | |
454 | 466 | let _staker = toString(i.caller) | |
455 | - | let $ | |
456 | - | let newRewardPerTokenStored = $ | |
457 | - | let newLastUpdateTime = $ | |
458 | - | let stakerEarned = $ | |
459 | - | let stakerRewardPerTokenPaid = $ | |
467 | + | let $t01709217237 = updateReward(_staker, 0) | |
468 | + | let newRewardPerTokenStored = $t01709217237._1 | |
469 | + | let newLastUpdateTime = $t01709217237._2 | |
470 | + | let stakerEarned = $t01709217237._3 | |
471 | + | let stakerRewardPerTokenPaid = $t01709217237._4 | |
460 | 472 | if (if ((0 >= stakerEarned)) | |
461 | 473 | then true | |
462 | 474 | else !(initialized())) |
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_lockedBalance = "k_lockedBalance" | |
9 | 9 | ||
10 | 10 | let k_freeBalance = "k_freeBalance" | |
11 | 11 | ||
12 | 12 | let k_excessBalance = "k_excessBalance" | |
13 | 13 | ||
14 | 14 | let k_vaultAsset = "k_vaultAsset" | |
15 | 15 | ||
16 | 16 | let k_vaultAssetDecimals = "k_vaultAssetDecimals" | |
17 | 17 | ||
18 | 18 | let k_maxSpotUtilization = "k_maxSpotUtilization" | |
19 | + | ||
20 | + | let k_withdrawPerPeriod = "k_withdrawPerPeriod" | |
19 | 21 | ||
20 | 22 | let k_rate = "k_rate" | |
21 | 23 | ||
22 | 24 | let k_lastUpdateTime = "k_lastUpdateTime" | |
23 | 25 | ||
24 | 26 | let k_rewardPerTokenStored = "k_rewardPerTokenStored" | |
25 | 27 | ||
26 | 28 | let k_rewardRate = "k_rewardRate" | |
27 | 29 | ||
28 | 30 | let k_periodFinish = "k_periodFinish" | |
29 | 31 | ||
30 | 32 | let k_userRewardPerToken = "k_userRewardPerToken" | |
31 | 33 | ||
32 | 34 | let k_userReward = "k_userReward" | |
33 | 35 | ||
34 | 36 | let k_balance = "k_balance" | |
35 | 37 | ||
36 | 38 | let k_average_rate = "k_average_rate" | |
37 | 39 | ||
38 | 40 | let k_withdraw_limit = "k_withdraw_limit" | |
39 | 41 | ||
40 | 42 | let k_last_withdraw_date = "k_last_withdraw_date" | |
41 | 43 | ||
42 | 44 | let k_withdraw_in_period = "k_withdraw_in_period" | |
43 | 45 | ||
44 | 46 | let k_initialized = "k_initialized" | |
45 | 47 | ||
46 | 48 | let k_coordinatorAddress = "k_coordinatorAddress" | |
47 | 49 | ||
48 | 50 | let k_amm = "k_amm" | |
49 | 51 | ||
50 | 52 | let k_governance_asset = "k_gov_asset" | |
51 | 53 | ||
52 | 54 | let k_quote_asset = "k_quote_asset" | |
53 | 55 | ||
54 | 56 | let k_admin_address = "k_admin_address" | |
55 | 57 | ||
56 | 58 | let k_manager_address = "k_manager_address" | |
57 | 59 | ||
58 | 60 | let k_spot_address = "k_spot_address" | |
59 | 61 | ||
60 | 62 | let k_collateral_address = "k_collateral_address" | |
61 | 63 | ||
62 | 64 | func toCompositeKey (_key,_address) = ((_key + "_") + _address) | |
63 | 65 | ||
64 | 66 | ||
65 | 67 | func coordinator () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(this, k_coordinatorAddress), "Coordinator not set")), "Coordinator address invalid") | |
66 | 68 | ||
67 | 69 | ||
68 | 70 | func adminAddress () = addressFromString(valueOrErrorMessage(getString(coordinator(), k_admin_address), "Admin address not set")) | |
69 | 71 | ||
70 | 72 | ||
71 | 73 | func isWhitelist (_address) = valueOrElse(getBoolean(coordinator(), toCompositeKey(k_amm, _address)), false) | |
72 | 74 | ||
73 | 75 | ||
74 | 76 | func spotAddress () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(coordinator(), k_spot_address), "Spot address not set")), "Spot address invalid") | |
75 | 77 | ||
76 | 78 | ||
77 | 79 | func governanceAsset () = fromBase58String(valueOrErrorMessage(getString(coordinator(), k_governance_asset), "Governance asset not set")) | |
78 | 80 | ||
79 | 81 | ||
80 | 82 | func quoteAsset () = fromBase58String(getStringValue(coordinator(), k_quote_asset)) | |
81 | 83 | ||
82 | 84 | ||
83 | 85 | func vaultAssetStr () = valueOrErrorMessage(getString(this, k_vaultAsset), "Vault asset not set") | |
84 | 86 | ||
85 | 87 | ||
86 | 88 | func vaultAsset () = { | |
87 | 89 | let _assetIdStr = vaultAssetStr() | |
88 | 90 | if ((_assetIdStr == "WAVES")) | |
89 | 91 | then unit | |
90 | 92 | else fromBase58String(_assetIdStr) | |
91 | 93 | } | |
92 | 94 | ||
93 | 95 | ||
94 | 96 | func vaultAssetDecimals () = valueOrErrorMessage(getInteger(this, k_vaultAssetDecimals), "Vault asset decimals not set") | |
95 | 97 | ||
96 | 98 | ||
97 | 99 | func managerAddress () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(coordinator(), k_manager_address), "Manager address not set")), "Manager address invalid") | |
98 | 100 | ||
99 | 101 | ||
100 | 102 | let DECIMAL_UNIT = (1 * (((((((10 * 10) * 10) * 10) * 10) * 10) * 10) * 10)) | |
101 | 103 | ||
102 | 104 | let DURATION = (((7 * 60) * 60) * 24) | |
103 | 105 | ||
104 | 106 | let NO_ADDRESS = "" | |
105 | 107 | ||
106 | 108 | let NO_STAKER = 0 | |
107 | 109 | ||
108 | 110 | func assetFromDecimals (_amount) = { | |
109 | 111 | let assetDecimals = vaultAssetDecimals() | |
110 | 112 | if ((assetDecimals == 6)) | |
111 | 113 | then (_amount / 100) | |
112 | 114 | else if ((assetDecimals == 8)) | |
113 | 115 | then _amount | |
114 | 116 | else throw("Invalid asset decimals") | |
115 | 117 | } | |
116 | 118 | ||
117 | 119 | ||
118 | 120 | func assetToDecimals (_amount) = { | |
119 | 121 | let assetDecimals = vaultAssetDecimals() | |
120 | 122 | if ((assetDecimals == 6)) | |
121 | 123 | then (_amount * 100) | |
122 | 124 | else if ((assetDecimals == 8)) | |
123 | 125 | then _amount | |
124 | 126 | else throw("Invalid asset decimals") | |
125 | 127 | } | |
126 | 128 | ||
127 | 129 | ||
128 | 130 | func divd (_x,_y) = fraction(_x, DECIMAL_UNIT, _y, HALFEVEN) | |
129 | 131 | ||
130 | 132 | ||
131 | 133 | func muld (_x,_y) = fraction(_x, _y, DECIMAL_UNIT, HALFEVEN) | |
132 | 134 | ||
133 | 135 | ||
134 | 136 | func abs (_x) = if ((_x > 0)) | |
135 | 137 | then _x | |
136 | 138 | else -(_x) | |
137 | 139 | ||
138 | 140 | ||
139 | 141 | func minv (_x,_y) = if ((_x > _y)) | |
140 | 142 | then _y | |
141 | 143 | else _x | |
142 | 144 | ||
143 | 145 | ||
144 | 146 | let WITHDRAW_PERIOD = (86400 * 1000) | |
145 | 147 | ||
146 | 148 | let WITHDRAW_PER_PERIOD = divd((1 * DECIMAL_UNIT), (4 * DECIMAL_UNIT)) | |
147 | 149 | ||
148 | 150 | func int (k) = valueOrErrorMessage(getInteger(this, k), ("no value for " + k)) | |
149 | 151 | ||
150 | 152 | ||
151 | 153 | func int0 (k) = valueOrElse(getInteger(this, k), 0) | |
152 | 154 | ||
153 | 155 | ||
154 | 156 | func int1 (k) = valueOrElse(getInteger(this, k), DECIMAL_UNIT) | |
155 | 157 | ||
156 | 158 | ||
159 | + | func intOr (k,val) = valueOrElse(getInteger(this, k), val) | |
160 | + | ||
161 | + | ||
157 | 162 | func totalSupply () = int0(k_totalSupply) | |
158 | 163 | ||
159 | 164 | ||
160 | 165 | func rate () = int1(k_rate) | |
161 | 166 | ||
162 | 167 | ||
163 | 168 | func balanceOf (_staker) = int0(toCompositeKey(k_balance, _staker)) | |
164 | 169 | ||
165 | 170 | ||
166 | 171 | func averageRate (_staker) = int0(toCompositeKey(k_average_rate, _staker)) | |
167 | 172 | ||
168 | 173 | ||
169 | 174 | func withdrawLimit (_staker) = int0(toCompositeKey(k_withdraw_limit, _staker)) | |
170 | 175 | ||
171 | 176 | ||
172 | 177 | func withdrawnInPeriod (_staker) = int0(toCompositeKey(k_withdraw_in_period, _staker)) | |
173 | 178 | ||
174 | 179 | ||
175 | 180 | func lastWithdrawnDate (_staker) = int0(toCompositeKey(k_last_withdraw_date, _staker)) | |
176 | 181 | ||
177 | 182 | ||
178 | 183 | func freeBalance () = int0(k_freeBalance) | |
179 | 184 | ||
180 | 185 | ||
181 | 186 | func lockedBalance () = int0(k_lockedBalance) | |
182 | 187 | ||
183 | 188 | ||
184 | 189 | func excessBalance () = int0(k_excessBalance) | |
185 | 190 | ||
186 | 191 | ||
187 | 192 | func rewardPerTokenStored () = int0(k_rewardPerTokenStored) | |
188 | 193 | ||
189 | 194 | ||
190 | 195 | func lastUpdateTime () = int0(k_lastUpdateTime) | |
191 | 196 | ||
192 | 197 | ||
193 | 198 | func rewardRate () = int0(k_rewardRate) | |
194 | 199 | ||
195 | 200 | ||
196 | 201 | func periodFinish () = int0(k_periodFinish) | |
197 | 202 | ||
198 | 203 | ||
199 | 204 | func rewardBalance () = int0(k_rewardBalance) | |
200 | 205 | ||
201 | 206 | ||
202 | 207 | func rewards (_staker) = int0(toCompositeKey(k_userReward, _staker)) | |
203 | 208 | ||
204 | 209 | ||
205 | 210 | func userRewardPerTokenPaid (_staker) = int0(toCompositeKey(k_userRewardPerToken, _staker)) | |
206 | 211 | ||
207 | 212 | ||
208 | 213 | func maxSpotUtilization () = int0(k_maxSpotUtilization) | |
209 | 214 | ||
210 | 215 | ||
216 | + | func withdrawPerPeriod () = intOr(k_withdrawPerPeriod, WITHDRAW_PER_PERIOD) | |
217 | + | ||
218 | + | ||
211 | 219 | func initialized () = valueOrElse(getBoolean(this, k_initialized), false) | |
212 | 220 | ||
213 | 221 | ||
214 | 222 | func currentTimestamp () = lastBlock.timestamp | |
215 | 223 | ||
216 | 224 | ||
217 | 225 | func currentTimestampSec () = (currentTimestamp() / 1000) | |
218 | 226 | ||
219 | 227 | ||
220 | 228 | func getWithdrawLimitLeft (_staker) = { | |
221 | 229 | let currentDate = currentTimestamp() | |
222 | 230 | let lastWithdrawDate = lastWithdrawnDate(_staker) | |
223 | - | let $ | |
231 | + | let $t064646785 = if (((currentDate - lastWithdrawDate) > WITHDRAW_PERIOD)) | |
224 | 232 | then $Tuple3(currentDate, withdrawLimit(_staker), 0) | |
225 | 233 | else $Tuple3(lastWithdrawDate, (withdrawLimit(_staker) - withdrawnInPeriod(_staker)), withdrawnInPeriod(_staker)) | |
226 | - | let newLastWithdrawnDate = $ | |
227 | - | let withdrawLimitLeft = $ | |
228 | - | let alreadyWithdrawnInPeriod = $ | |
234 | + | let newLastWithdrawnDate = $t064646785._1 | |
235 | + | let withdrawLimitLeft = $t064646785._2 | |
236 | + | let alreadyWithdrawnInPeriod = $t064646785._3 | |
229 | 237 | $Tuple3(newLastWithdrawnDate, withdrawLimitLeft, alreadyWithdrawnInPeriod) | |
230 | 238 | } | |
231 | 239 | ||
232 | 240 | ||
233 | 241 | func computeNewRate (_amountOfQuoteAsset) = { | |
234 | 242 | let newRate = if ((totalSupply() > 0)) | |
235 | 243 | then divd((freeBalance() + _amountOfQuoteAsset), totalSupply()) | |
236 | 244 | else DECIMAL_UNIT | |
237 | 245 | newRate | |
238 | 246 | } | |
239 | 247 | ||
240 | 248 | ||
241 | 249 | func lastTimeRewardApplicable () = minv(currentTimestampSec(), periodFinish()) | |
242 | 250 | ||
243 | 251 | ||
244 | 252 | func rewardPerToken (_balanceDelta) = if (((totalSupply() + _balanceDelta) == 0)) | |
245 | 253 | then rewardPerTokenStored() | |
246 | 254 | else { | |
247 | 255 | let timeInterval = (lastTimeRewardApplicable() - lastUpdateTime()) | |
248 | 256 | let actualTimeInterval = if ((0 > timeInterval)) | |
249 | 257 | then 0 | |
250 | 258 | else timeInterval | |
251 | 259 | let diff = divd((rewardRate() * actualTimeInterval), (totalSupply() + _balanceDelta)) | |
252 | 260 | (rewardPerTokenStored() + diff) | |
253 | 261 | } | |
254 | 262 | ||
255 | 263 | ||
256 | 264 | func earned (_staker,_balanceDelta) = { | |
257 | 265 | let rewardDelta = (rewardPerToken(_balanceDelta) - userRewardPerTokenPaid(_staker)) | |
258 | 266 | (muld((balanceOf(_staker) + _balanceDelta), rewardDelta) + rewards(_staker)) | |
259 | 267 | } | |
260 | 268 | ||
261 | 269 | ||
262 | 270 | func updateReward (_staker,_balanceDelta) = { | |
263 | 271 | let newRewardPerTokenStored = rewardPerToken(_balanceDelta) | |
264 | 272 | let newLastUpdateTime = currentTimestampSec() | |
265 | - | let $ | |
273 | + | let $t080078199 = if ((_staker != "")) | |
266 | 274 | then $Tuple2(earned(_staker, _balanceDelta), newRewardPerTokenStored) | |
267 | 275 | else $Tuple2(0, 0) | |
268 | - | let stakerEarned = $ | |
269 | - | let stakerRewardPerTokenPaid = $ | |
276 | + | let stakerEarned = $t080078199._1 | |
277 | + | let stakerRewardPerTokenPaid = $t080078199._2 | |
270 | 278 | $Tuple4(newRewardPerTokenStored, newLastUpdateTime, stakerEarned, stakerRewardPerTokenPaid) | |
271 | 279 | } | |
272 | 280 | ||
273 | 281 | ||
274 | 282 | func updateUserBalance (_user,_change) = if (((balanceOf(_user) + _change) >= 0)) | |
275 | 283 | then [IntegerEntry(toCompositeKey(k_balance, _user), (balanceOf(_user) + _change))] | |
276 | 284 | else throw(((("Vault: can not update user balance. Balance: " + toString(balanceOf(_user))) + " change: ") + toString(_change))) | |
277 | 285 | ||
278 | 286 | ||
279 | 287 | func setUserWithdrawLimit (_user,_rate) = [IntegerEntry(toCompositeKey(k_withdraw_limit, _user), _rate)] | |
280 | 288 | ||
281 | 289 | ||
282 | 290 | func setUserAverageRate (_user,_rate) = [IntegerEntry(toCompositeKey(k_average_rate, _user), _rate)] | |
283 | 291 | ||
284 | 292 | ||
285 | 293 | func updateFreeBalance (_change) = { | |
286 | 294 | let balance = freeBalance() | |
287 | 295 | if (((balance + _change) >= 0)) | |
288 | 296 | then [IntegerEntry(k_freeBalance, (balance + _change))] | |
289 | 297 | else throw(((("Vault: can not update free balance. Balance: " + toString(balance)) + " change: ") + toString(_change))) | |
290 | 298 | } | |
291 | 299 | ||
292 | 300 | ||
293 | 301 | func updateLockedBalance (_change) = { | |
294 | 302 | let balance = lockedBalance() | |
295 | 303 | if (((balance + _change) >= 0)) | |
296 | 304 | then [IntegerEntry(k_lockedBalance, (balance + _change))] | |
297 | 305 | else throw(((("Vault: can not update locked balance. Balance: " + toString(balance)) + " change: ") + toString(_change))) | |
298 | 306 | } | |
299 | 307 | ||
300 | 308 | ||
301 | 309 | func updateExcessBalance (_change) = { | |
302 | 310 | let newImbalance = (excessBalance() + _change) | |
303 | 311 | let utilizationRate = divd(abs(newImbalance), freeBalance()) | |
304 | 312 | if ((maxSpotUtilization() > utilizationRate)) | |
305 | 313 | then [IntegerEntry(k_excessBalance, newImbalance)] | |
306 | 314 | else throw(((((((("Vault: can not update excess balance. Balance: " + toString(excessBalance())) + " change: ") + toString(_change)) + " utilization rate: ") + toString(utilizationRate)) + " max utilization rate: ") + toString(maxSpotUtilization()))) | |
307 | 315 | } | |
308 | 316 | ||
309 | 317 | ||
310 | 318 | func updateTotalSupply (_change) = [IntegerEntry(k_totalSupply, (totalSupply() + _change))] | |
311 | 319 | ||
312 | 320 | ||
313 | 321 | func updateRate (_rate) = [IntegerEntry(k_rate, _rate)] | |
314 | 322 | ||
315 | 323 | ||
316 | 324 | func setUserWithdrawParams (_user,_lastWithdrawDate,_withdrawn) = [IntegerEntry(toCompositeKey(k_last_withdraw_date, _user), _lastWithdrawDate), IntegerEntry(toCompositeKey(k_withdraw_in_period, _user), _withdrawn)] | |
317 | 325 | ||
318 | 326 | ||
319 | 327 | func updateRewardBalance (_delta) = [IntegerEntry(k_rewardBalance, (rewardBalance() + _delta))] | |
320 | 328 | ||
321 | 329 | ||
322 | 330 | func updateRewardRate (_rewardRate) = [IntegerEntry(k_rewardRate, _rewardRate)] | |
323 | 331 | ||
324 | 332 | ||
325 | 333 | func updateTime (_lastUpdateTime,_periodFinish) = [IntegerEntry(k_lastUpdateTime, _lastUpdateTime), IntegerEntry(k_periodFinish, _periodFinish)] | |
326 | 334 | ||
327 | 335 | ||
328 | 336 | func updateRewardPerTokenStored (_rewardPerTokenStored) = [IntegerEntry(k_rewardPerTokenStored, _rewardPerTokenStored)] | |
329 | 337 | ||
330 | 338 | ||
331 | 339 | func updateUserRewards (_staker,_reward,_userRewardPerToken) = [IntegerEntry(toCompositeKey(k_userReward, _staker), _reward), IntegerEntry(toCompositeKey(k_userRewardPerToken, _staker), _userRewardPerToken)] | |
332 | 340 | ||
333 | 341 | ||
334 | 342 | @Callable(i) | |
335 | - | func changeSettings (_maxSpotUtilization) = if (if (if (!(initialized())) | |
343 | + | func changeSettings (_maxSpotUtilization,_withdrawPerPeriod) = if (if (if (if (!(initialized())) | |
336 | 344 | then true | |
337 | 345 | else (i.caller != adminAddress())) | |
338 | 346 | then true | |
339 | 347 | else if ((0 > _maxSpotUtilization)) | |
340 | 348 | then true | |
341 | 349 | else (_maxSpotUtilization > DECIMAL_UNIT)) | |
350 | + | then true | |
351 | + | else if ((0 > _withdrawPerPeriod)) | |
352 | + | then true | |
353 | + | else (_withdrawPerPeriod > DECIMAL_UNIT)) | |
342 | 354 | then throw("Invalid changeSettings params") | |
343 | - | else [IntegerEntry(k_maxSpotUtilization, _maxSpotUtilization)] | |
355 | + | else [IntegerEntry(k_maxSpotUtilization, _maxSpotUtilization), IntegerEntry(k_withdrawPerPeriod, _withdrawPerPeriod)] | |
344 | 356 | ||
345 | 357 | ||
346 | 358 | ||
347 | 359 | @Callable(i) | |
348 | 360 | func initialize (_coordinator,_vaultAsset,_maxSpotUtilization) = if (if (if (if (initialized()) | |
349 | 361 | then true | |
350 | 362 | else (i.caller != this)) | |
351 | 363 | then true | |
352 | 364 | else (0 > _maxSpotUtilization)) | |
353 | 365 | then true | |
354 | 366 | else (_maxSpotUtilization > DECIMAL_UNIT)) | |
355 | 367 | then throw("Unable to initialize") | |
356 | 368 | else { | |
357 | 369 | let assetDecimals = if ((_vaultAsset == "WAVES")) | |
358 | 370 | then 8 | |
359 | 371 | else { | |
360 | 372 | let info = valueOrErrorMessage(assetInfo(fromBase58String(_vaultAsset)), ("Invalid token id: " + _vaultAsset)) | |
361 | 373 | info.decimals | |
362 | 374 | } | |
363 | 375 | [StringEntry(k_coordinatorAddress, toString(valueOrErrorMessage(addressFromString(_coordinator), "Invalid coordinator address"))), StringEntry(k_vaultAsset, _vaultAsset), IntegerEntry(k_vaultAssetDecimals, assetDecimals), IntegerEntry(k_maxSpotUtilization, _maxSpotUtilization), BooleanEntry(k_initialized, true)] | |
364 | 376 | } | |
365 | 377 | ||
366 | 378 | ||
367 | 379 | ||
368 | 380 | @Callable(i) | |
369 | 381 | func stake () = { | |
370 | 382 | let _staker = toString(i.caller) | |
371 | 383 | let _amount = assetToDecimals(i.payments[0].amount) | |
372 | 384 | if (if (if ((i.payments[0].assetId != vaultAsset())) | |
373 | 385 | then true | |
374 | 386 | else (size(i.payments) != 1)) | |
375 | 387 | then true | |
376 | 388 | else !(initialized())) | |
377 | 389 | then throw("Invalid call to stake") | |
378 | 390 | else { | |
379 | - | let $ | |
380 | - | let newRewardPerTokenStored = $ | |
381 | - | let newLastUpdateTime = $ | |
382 | - | let stakerEarned = $ | |
383 | - | let stakerRewardPerTokenPaid = $ | |
391 | + | let $t01327313502 = updateReward(_staker, 0) | |
392 | + | let newRewardPerTokenStored = $t01327313502._1 | |
393 | + | let newLastUpdateTime = $t01327313502._2 | |
394 | + | let stakerEarned = $t01327313502._3 | |
395 | + | let stakerRewardPerTokenPaid = $t01327313502._4 | |
384 | 396 | let currentRate = rate() | |
385 | 397 | let prevAverageRate = averageRate(_staker) | |
386 | 398 | let vAmount = divd(_amount, currentRate) | |
387 | 399 | let newAverageRate = divd((muld(vAmount, currentRate) + muld(balanceOf(_staker), prevAverageRate)), (vAmount + balanceOf(_staker))) | |
388 | 400 | let newTotalBalance = (vAmount + balanceOf(_staker)) | |
389 | - | let newWithdrawLimit = muld(newTotalBalance, | |
401 | + | let newWithdrawLimit = muld(newTotalBalance, withdrawPerPeriod()) | |
390 | 402 | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(vaultAsset(), assetFromDecimals(_amount))]) | |
391 | 403 | if ((stake == stake)) | |
392 | 404 | then { | |
393 | 405 | let notify = if ((maxSpotUtilization() > 0)) | |
394 | 406 | then invoke(spotAddress(), "notifyVaultBalanceChange", [vaultAssetStr(), _amount], nil) | |
395 | 407 | else nil | |
396 | 408 | if ((notify == notify)) | |
397 | 409 | then (((((((updateUserRewards(_staker, stakerEarned, stakerRewardPerTokenPaid) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(newLastUpdateTime, periodFinish())) ++ updateFreeBalance(_amount)) ++ updateUserBalance(_staker, vAmount)) ++ setUserAverageRate(_staker, newAverageRate)) ++ setUserWithdrawLimit(_staker, newWithdrawLimit)) ++ updateTotalSupply(vAmount)) | |
398 | 410 | else throw("Strict value is not equal to itself.") | |
399 | 411 | } | |
400 | 412 | else throw("Strict value is not equal to itself.") | |
401 | 413 | } | |
402 | 414 | } | |
403 | 415 | ||
404 | 416 | ||
405 | 417 | ||
406 | 418 | @Callable(i) | |
407 | 419 | func unStake (_amount) = { | |
408 | 420 | let _staker = toString(i.caller) | |
409 | 421 | let amountOfQuoteAsset = assetToDecimals(_amount) | |
410 | 422 | if (if (if ((i.payments != nil)) | |
411 | 423 | then true | |
412 | 424 | else (0 >= amountOfQuoteAsset)) | |
413 | 425 | then true | |
414 | 426 | else !(initialized())) | |
415 | 427 | then throw("Invalid call to unStake") | |
416 | 428 | else { | |
417 | - | let $ | |
418 | - | let newRewardPerTokenStored = $ | |
419 | - | let newLastUpdateTime = $ | |
420 | - | let stakerEarned = $ | |
421 | - | let stakerRewardPerTokenPaid = $ | |
422 | - | let $ | |
423 | - | let newLastWithdrawnDate = $ | |
424 | - | let withdrawLimitLeft = $ | |
425 | - | let alreadyWithdrawnInPeriod = $ | |
429 | + | let $t01509215308 = updateReward(_staker, 0) | |
430 | + | let newRewardPerTokenStored = $t01509215308._1 | |
431 | + | let newLastUpdateTime = $t01509215308._2 | |
432 | + | let stakerEarned = $t01509215308._3 | |
433 | + | let stakerRewardPerTokenPaid = $t01509215308._4 | |
434 | + | let $t01531515482 = getWithdrawLimitLeft(_staker) | |
435 | + | let newLastWithdrawnDate = $t01531515482._1 | |
436 | + | let withdrawLimitLeft = $t01531515482._2 | |
437 | + | let alreadyWithdrawnInPeriod = $t01531515482._3 | |
426 | 438 | let vAmount = divd(amountOfQuoteAsset, rate()) | |
427 | 439 | if ((vAmount > withdrawLimitLeft)) | |
428 | 440 | then throw("Invalid call to unStake: withdraw over limit") | |
429 | 441 | else { | |
430 | 442 | let newWithdrawnInPeriod = (alreadyWithdrawnInPeriod + vAmount) | |
431 | 443 | if ((amountOfQuoteAsset > freeBalance())) | |
432 | 444 | then throw("Invalid call to unStake: balance too low") | |
433 | 445 | else { | |
434 | 446 | let unstake = invoke(managerAddress(), "withdraw", [vaultAssetStr(), assetFromDecimals(amountOfQuoteAsset)], nil) | |
435 | 447 | if ((unstake == unstake)) | |
436 | 448 | then { | |
437 | 449 | let notify = if ((maxSpotUtilization() > 0)) | |
438 | 450 | then invoke(spotAddress(), "notifyVaultBalanceChange", [vaultAssetStr(), -(amountOfQuoteAsset)], nil) | |
439 | 451 | else nil | |
440 | 452 | if ((notify == notify)) | |
441 | 453 | then (((((((updateUserRewards(_staker, stakerEarned, stakerRewardPerTokenPaid) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(newLastUpdateTime, periodFinish())) ++ updateFreeBalance(-(amountOfQuoteAsset))) ++ updateUserBalance(_staker, -(vAmount))) ++ updateTotalSupply(-(vAmount))) ++ setUserWithdrawParams(_staker, newLastWithdrawnDate, newWithdrawnInPeriod)) ++ [ScriptTransfer(i.caller, assetFromDecimals(amountOfQuoteAsset), vaultAsset())]) | |
442 | 454 | else throw("Strict value is not equal to itself.") | |
443 | 455 | } | |
444 | 456 | else throw("Strict value is not equal to itself.") | |
445 | 457 | } | |
446 | 458 | } | |
447 | 459 | } | |
448 | 460 | } | |
449 | 461 | ||
450 | 462 | ||
451 | 463 | ||
452 | 464 | @Callable(i) | |
453 | 465 | func withdrawRewards () = { | |
454 | 466 | let _staker = toString(i.caller) | |
455 | - | let $ | |
456 | - | let newRewardPerTokenStored = $ | |
457 | - | let newLastUpdateTime = $ | |
458 | - | let stakerEarned = $ | |
459 | - | let stakerRewardPerTokenPaid = $ | |
467 | + | let $t01709217237 = updateReward(_staker, 0) | |
468 | + | let newRewardPerTokenStored = $t01709217237._1 | |
469 | + | let newLastUpdateTime = $t01709217237._2 | |
470 | + | let stakerEarned = $t01709217237._3 | |
471 | + | let stakerRewardPerTokenPaid = $t01709217237._4 | |
460 | 472 | if (if ((0 >= stakerEarned)) | |
461 | 473 | then true | |
462 | 474 | else !(initialized())) | |
463 | 475 | then throw("No reward: Vault") | |
464 | 476 | else ((((updateUserRewards(_staker, 0, stakerRewardPerTokenPaid) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(newLastUpdateTime, periodFinish())) ++ updateRewardBalance(-(stakerEarned))) ++ [ScriptTransfer(i.caller, stakerEarned, governanceAsset())]) | |
465 | 477 | } | |
466 | 478 | ||
467 | 479 | ||
468 | 480 | ||
469 | 481 | @Callable(i) | |
470 | 482 | func addFree () = { | |
471 | 483 | let _amount = assetToDecimals(i.payments[0].amount) | |
472 | 484 | if (if (if (if ((i.payments[0].assetId != vaultAsset())) | |
473 | 485 | then true | |
474 | 486 | else (size(i.payments) != 1)) | |
475 | 487 | then true | |
476 | 488 | else !(initialized())) | |
477 | 489 | then true | |
478 | 490 | else !(if (if (isWhitelist(toString(i.caller))) | |
479 | 491 | then true | |
480 | 492 | else (i.caller == spotAddress())) | |
481 | 493 | then true | |
482 | 494 | else (i.caller == adminAddress()))) | |
483 | 495 | then throw("Invalid addFree params") | |
484 | 496 | else { | |
485 | 497 | let newRate = computeNewRate(_amount) | |
486 | 498 | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(vaultAsset(), assetFromDecimals(_amount))]) | |
487 | 499 | if ((stake == stake)) | |
488 | 500 | then (updateFreeBalance(_amount) ++ updateRate(newRate)) | |
489 | 501 | else throw("Strict value is not equal to itself.") | |
490 | 502 | } | |
491 | 503 | } | |
492 | 504 | ||
493 | 505 | ||
494 | 506 | ||
495 | 507 | @Callable(i) | |
496 | 508 | func addLocked () = { | |
497 | 509 | let _amount = assetToDecimals(i.payments[0].amount) | |
498 | 510 | if (if (if (if ((i.payments[0].assetId != vaultAsset())) | |
499 | 511 | then true | |
500 | 512 | else (size(i.payments) != 1)) | |
501 | 513 | then true | |
502 | 514 | else !(initialized())) | |
503 | 515 | then true | |
504 | 516 | else !(if (isWhitelist(toString(i.caller))) | |
505 | 517 | then true | |
506 | 518 | else (i.caller == adminAddress()))) | |
507 | 519 | then throw("Invalid addLocked params") | |
508 | 520 | else { | |
509 | 521 | let unstake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(vaultAsset(), assetFromDecimals(_amount))]) | |
510 | 522 | if ((unstake == unstake)) | |
511 | 523 | then updateLockedBalance(_amount) | |
512 | 524 | else throw("Strict value is not equal to itself.") | |
513 | 525 | } | |
514 | 526 | } | |
515 | 527 | ||
516 | 528 | ||
517 | 529 | ||
518 | 530 | @Callable(i) | |
519 | 531 | func exchangeFreeAndLocked (_amount) = if (if (!(initialized())) | |
520 | 532 | then true | |
521 | 533 | else if (!(isWhitelist(toString(i.caller)))) | |
522 | 534 | then (i.caller != adminAddress()) | |
523 | 535 | else false) | |
524 | 536 | then throw("Invalid exchangeFreeAndLocked params") | |
525 | 537 | else { | |
526 | 538 | let amountOfQuoteAsset = assetToDecimals(_amount) | |
527 | 539 | let newRate = computeNewRate(-(amountOfQuoteAsset)) | |
528 | 540 | ((updateLockedBalance(amountOfQuoteAsset) ++ updateFreeBalance(-(amountOfQuoteAsset))) ++ updateRate(newRate)) | |
529 | 541 | } | |
530 | 542 | ||
531 | 543 | ||
532 | 544 | ||
533 | 545 | @Callable(i) | |
534 | 546 | func withdrawLocked (_amount) = if (if (if (!(initialized())) | |
535 | 547 | then true | |
536 | 548 | else (0 >= _amount)) | |
537 | 549 | then true | |
538 | 550 | else !(isWhitelist(toString(i.caller)))) | |
539 | 551 | then throw("Invalid withdrawLocked params") | |
540 | 552 | else { | |
541 | 553 | let amountOfQuoteAsset = assetToDecimals(_amount) | |
542 | 554 | let unstake = invoke(managerAddress(), "withdraw", [vaultAssetStr(), assetFromDecimals(amountOfQuoteAsset)], nil) | |
543 | 555 | if ((unstake == unstake)) | |
544 | 556 | then (updateLockedBalance(-(amountOfQuoteAsset)) ++ [ScriptTransfer(i.caller, assetFromDecimals(amountOfQuoteAsset), vaultAsset())]) | |
545 | 557 | else throw("Strict value is not equal to itself.") | |
546 | 558 | } | |
547 | 559 | ||
548 | 560 | ||
549 | 561 | ||
550 | 562 | @Callable(i) | |
551 | 563 | func borrow (_amount) = if (if (if (!(initialized())) | |
552 | 564 | then true | |
553 | 565 | else (0 >= _amount)) | |
554 | 566 | then true | |
555 | 567 | else !((i.caller == spotAddress()))) | |
556 | 568 | then throw("Invalid borrow params") | |
557 | 569 | else { | |
558 | 570 | let amountOfQuoteAsset = assetToDecimals(_amount) | |
559 | 571 | let unstake = invoke(managerAddress(), "withdraw", [vaultAssetStr(), assetFromDecimals(amountOfQuoteAsset)], nil) | |
560 | 572 | if ((unstake == unstake)) | |
561 | 573 | then (updateExcessBalance(-(amountOfQuoteAsset)) ++ [ScriptTransfer(i.caller, assetFromDecimals(amountOfQuoteAsset), vaultAsset())]) | |
562 | 574 | else throw("Strict value is not equal to itself.") | |
563 | 575 | } | |
564 | 576 | ||
565 | 577 | ||
566 | 578 | ||
567 | 579 | @Callable(i) | |
568 | 580 | func repay () = { | |
569 | 581 | let _amount = assetToDecimals(i.payments[0].amount) | |
570 | 582 | if (if (if (if ((i.payments[0].assetId != vaultAsset())) | |
571 | 583 | then true | |
572 | 584 | else (size(i.payments) != 1)) | |
573 | 585 | then true | |
574 | 586 | else !(initialized())) | |
575 | 587 | then true | |
576 | 588 | else !(if ((i.caller == spotAddress())) | |
577 | 589 | then true | |
578 | 590 | else (i.caller == adminAddress()))) | |
579 | 591 | then throw("Invalid repay params") | |
580 | 592 | else { | |
581 | 593 | let unstake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(vaultAsset(), assetFromDecimals(_amount))]) | |
582 | 594 | if ((unstake == unstake)) | |
583 | 595 | then updateExcessBalance(_amount) | |
584 | 596 | else throw("Strict value is not equal to itself.") | |
585 | 597 | } | |
586 | 598 | } | |
587 | 599 | ||
588 | 600 | ||
589 | 601 | ||
590 | 602 | @Callable(i) | |
591 | 603 | func addRewards () = if (if (if ((i.payments[0].assetId != governanceAsset())) | |
592 | 604 | then true | |
593 | 605 | else (size(i.payments) != 1)) | |
594 | 606 | then true | |
595 | 607 | else !(initialized())) | |
596 | 608 | then throw("Invalid addRewards params") | |
597 | 609 | else { | |
598 | 610 | let _reward = i.payments[0].amount | |
599 | 611 | let newRewardPerTokenStored = updateReward(NO_ADDRESS, NO_STAKER)._1 | |
600 | 612 | let timestamp = currentTimestampSec() | |
601 | 613 | let newRewardRate = if ((timestamp > periodFinish())) | |
602 | 614 | then (_reward / DURATION) | |
603 | 615 | else { | |
604 | 616 | let remainingTime = (periodFinish() - timestamp) | |
605 | 617 | let leftover = (rewardRate() * remainingTime) | |
606 | 618 | ((_reward + leftover) / DURATION) | |
607 | 619 | } | |
608 | 620 | (((updateRewardRate(newRewardRate) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateRewardBalance(_reward)) ++ updateTime(timestamp, (timestamp + DURATION))) | |
609 | 621 | } | |
610 | 622 | ||
611 | 623 | ||
612 | 624 | ||
613 | 625 | @Callable(i) | |
614 | 626 | func ackRewards () = { | |
615 | 627 | let profitResp = invoke(managerAddress(), "claimProfit", [vaultAssetStr()], nil) | |
616 | 628 | if ((profitResp == profitResp)) | |
617 | 629 | then { | |
618 | 630 | let profit = match profitResp { | |
619 | 631 | case p: Int => | |
620 | 632 | assetToDecimals(p) | |
621 | 633 | case _ => | |
622 | 634 | throw("Invalid claimProfit response") | |
623 | 635 | } | |
624 | 636 | let result = if ((profit > 0)) | |
625 | 637 | then { | |
626 | 638 | let newRate = computeNewRate(profit) | |
627 | 639 | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(vaultAsset(), assetFromDecimals(profit))]) | |
628 | 640 | if ((stake == stake)) | |
629 | 641 | then (updateFreeBalance(profit) ++ updateRate(newRate)) | |
630 | 642 | else throw("Strict value is not equal to itself.") | |
631 | 643 | } | |
632 | 644 | else nil | |
633 | 645 | if ((result == result)) | |
634 | 646 | then result | |
635 | 647 | else throw("Strict value is not equal to itself.") | |
636 | 648 | } | |
637 | 649 | else throw("Strict value is not equal to itself.") | |
638 | 650 | } | |
639 | 651 | ||
640 | 652 | ||
641 | 653 | ||
642 | 654 | @Callable(i) | |
643 | 655 | func view_reward (_staker) = { | |
644 | 656 | let balance = balanceOf(_staker) | |
645 | 657 | let depositedAmount = muld(averageRate(_staker), balance) | |
646 | 658 | let currentAmount = muld(rate(), balance) | |
647 | 659 | let earnedQuote = (currentAmount - depositedAmount) | |
648 | 660 | throw(toString(earnedQuote)) | |
649 | 661 | } | |
650 | 662 | ||
651 | 663 | ||
652 | 664 | ||
653 | 665 | @Callable(i) | |
654 | 666 | func view_stakingReward (_staker) = { | |
655 | 667 | let stakerEarned = updateReward(_staker, 0)._3 | |
656 | 668 | throw(toString(assetFromDecimals(stakerEarned))) | |
657 | 669 | } | |
658 | 670 | ||
659 | 671 | ||
660 | 672 | ||
661 | 673 | @Callable(i) | |
662 | 674 | func view_withdrawLimit (_staker) = { | |
663 | 675 | let withdrawLimitLeft = getWithdrawLimitLeft(_staker)._2 | |
664 | 676 | let limitInAsset = assetFromDecimals(muld(withdrawLimitLeft, rate())) | |
665 | 677 | throw(toString(limitInAsset)) | |
666 | 678 | } | |
667 | 679 | ||
668 | 680 | ||
669 | 681 | @Verifier(tx) | |
670 | 682 | func verify () = { | |
671 | 683 | let coordinatorStr = getString(this, k_coordinatorAddress) | |
672 | 684 | if (isDefined(coordinatorStr)) | |
673 | 685 | then { | |
674 | 686 | let admin = getString(addressFromStringValue(value(coordinatorStr)), k_admin_address) | |
675 | 687 | if (isDefined(admin)) | |
676 | 688 | then valueOrElse(getBoolean(addressFromStringValue(value(admin)), ((("status_" + toString(this)) + "_") + toBase58String(tx.id))), false) | |
677 | 689 | else throw("unable to verify: admin not set in coordinator") | |
678 | 690 | } | |
679 | 691 | else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
680 | 692 | } | |
681 | 693 |
github/deemru/w8io/169f3d6 90.70 ms ◑