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