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