tx · AedhUzzEoxMx1HxeTKckrhCuTAEmKim9aXjm3pQM6qip 3NADcxHXbecCheinqFbvhDjfzZhsMFZJUuH: -0.03700000 Waves 2023.01.04 17:49 [2390358] smart account 3NADcxHXbecCheinqFbvhDjfzZhsMFZJUuH > SELF 0.00000000 Waves
{ "type": 13, "id": "AedhUzzEoxMx1HxeTKckrhCuTAEmKim9aXjm3pQM6qip", "fee": 3700000, "feeAssetId": null, "timestamp": 1672843785229, "version": 2, "chainId": 84, "sender": "3NADcxHXbecCheinqFbvhDjfzZhsMFZJUuH", "senderPublicKey": "DKfzQgvVdTqPHgGbdZptWYA8G5xVfmSMAwL3UnhwQmdy", "proofs": [ "uwm8Lht6Hpds7yRyzJsfSipHQo1ZA7eKA4x5VNnwyxntSuafBNB4mudJz4fpAhBH9t5GdtV7ryLq8cxjtj9NfZo" ], "script": "base64:BgI3CAISAwoBCBIAEgMKAQESABIAEgMKAQQSAwoBARIDCgEBEgMKAQESAwoBARIAEgMKAQgSAwoBCF0ADWtfdG90YWxTdXBwbHkCDWtfdG90YWxTdXBwbHkAD2tfcmV3YXJkQmFsYW5jZQIPa19yZXdhcmRCYWxhbmNlAA9rX2xvY2tlZEJhbGFuY2UCD2tfbG9ja2VkQmFsYW5jZQAQa192TG9ja2VkQmFsYW5jZQIQa192TG9ja2VkQmFsYW5jZQANa19mcmVlQmFsYW5jZQINa19mcmVlQmFsYW5jZQAVa19mcmVlQmFsYW5jZUJvcnJvd2VkAhVrX2ZyZWVCYWxhbmNlQm9ycm93ZWQABmtfcmF0ZQIGa19yYXRlABBrX2xhc3RVcGRhdGVUaW1lAhBrX2xhc3RVcGRhdGVUaW1lABZrX3Jld2FyZFBlclRva2VuU3RvcmVkAhZrX3Jld2FyZFBlclRva2VuU3RvcmVkAAxrX3Jld2FyZFJhdGUCDGtfcmV3YXJkUmF0ZQAOa19wZXJpb2RGaW5pc2gCDmtfcGVyaW9kRmluaXNoABRrX3VzZXJSZXdhcmRQZXJUb2tlbgIUa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WJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAJAQ5hZG1pblB1YmxpY0tleQB/dYhT", "height": 2390358, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 7Sn8aJWrWUwG7L5o8ps4qXkCqXcDXAsBujNT1dxt1J8j Next: 7tHzJeGdLnkuqWxfD42ne6Dq4WmgfxnRvkHKKRcGUZs6 Diff:
Old | New | Differences | |
---|---|---|---|
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let k_totalSupply = "k_totalSupply" | |
5 | + | ||
6 | + | let k_rewardBalance = "k_rewardBalance" | |
5 | 7 | ||
6 | 8 | let k_lockedBalance = "k_lockedBalance" | |
7 | 9 | ||
12 | 14 | let k_freeBalanceBorrowed = "k_freeBalanceBorrowed" | |
13 | 15 | ||
14 | 16 | let k_rate = "k_rate" | |
17 | + | ||
18 | + | let k_lastUpdateTime = "k_lastUpdateTime" | |
19 | + | ||
20 | + | let k_rewardPerTokenStored = "k_rewardPerTokenStored" | |
21 | + | ||
22 | + | let k_rewardRate = "k_rewardRate" | |
23 | + | ||
24 | + | let k_periodFinish = "k_periodFinish" | |
25 | + | ||
26 | + | let k_userRewardPerToken = "k_userRewardPerToken" | |
27 | + | ||
28 | + | let k_userReward = "k_userReward" | |
15 | 29 | ||
16 | 30 | let k_balance = "k_balance" | |
17 | 31 | ||
28 | 42 | let k_coordinatorAddress = "k_coordinatorAddress" | |
29 | 43 | ||
30 | 44 | let k_amm = "k_amm" | |
45 | + | ||
46 | + | let k_governance_asset = "k_gov_asset" | |
31 | 47 | ||
32 | 48 | let k_quote_asset = "k_quote_asset" | |
33 | 49 | ||
51 | 67 | func adminPublicKey () = fromBase58String(getStringValue(coordinator(), k_admin_public_key)) | |
52 | 68 | ||
53 | 69 | ||
70 | + | func governanceAsset () = fromBase58String(getStringValue(coordinator(), k_governance_asset)) | |
71 | + | ||
72 | + | ||
54 | 73 | func adminAddress () = addressFromString(valueOrErrorMessage(getString(coordinator(), k_admin_address), "Admin address not set")) | |
55 | 74 | ||
56 | 75 | ||
65 | 84 | ||
66 | 85 | let DECIMAL_UNIT = (1 * (((((((10 * 10) * 10) * 10) * 10) * 10) * 10) * 10)) | |
67 | 86 | ||
68 | - | let DURATION = ((60 * 60) * 24) | |
87 | + | let DURATION = (((7 * 60) * 60) * 24) | |
69 | 88 | ||
70 | 89 | let NO_ADDRESS = "" | |
71 | 90 | ||
139 | 158 | func vLockedBalance () = int0(k_vLockedBalance) | |
140 | 159 | ||
141 | 160 | ||
161 | + | func rewardPerTokenStored () = int0(k_rewardPerTokenStored) | |
162 | + | ||
163 | + | ||
164 | + | func lastUpdateTime () = int0(k_lastUpdateTime) | |
165 | + | ||
166 | + | ||
167 | + | func rewardRate () = int0(k_rewardRate) | |
168 | + | ||
169 | + | ||
170 | + | func periodFinish () = int0(k_periodFinish) | |
171 | + | ||
172 | + | ||
173 | + | func rewardBalance () = int0(k_rewardBalance) | |
174 | + | ||
175 | + | ||
176 | + | func rewards (_staker) = int0(toCompositeKey(k_userReward, _staker)) | |
177 | + | ||
178 | + | ||
179 | + | func userRewardPerTokenPaid (_staker) = int0(toCompositeKey(k_userRewardPerToken, _staker)) | |
180 | + | ||
181 | + | ||
142 | 182 | func initialized () = valueOrElse(getBoolean(this, k_initialized), false) | |
143 | 183 | ||
144 | 184 | ||
185 | + | func currentTimestamp () = lastBlock.timestamp | |
186 | + | ||
187 | + | ||
188 | + | func currentTimestampSec () = (currentTimestamp() / 1000) | |
189 | + | ||
190 | + | ||
145 | 191 | func getWithdrawLimitLeft (_staker) = { | |
146 | - | let currentDate = | |
192 | + | let currentDate = currentTimestamp() | |
147 | 193 | let lastWithdrawDate = lastWithdrawnDate(_staker) | |
148 | - | let $ | |
194 | + | let $t054655729 = if (((currentDate - lastWithdrawDate) > WITHDRAW_PERIOD)) | |
149 | 195 | then $Tuple2(currentDate, withdrawLimit(_staker)) | |
150 | 196 | else $Tuple2(lastWithdrawDate, (withdrawLimit(_staker) - withdrawnInPeriod(_staker))) | |
151 | - | let newLastWithdrawnDate = $ | |
152 | - | let withdrawLimitLeft = $ | |
197 | + | let newLastWithdrawnDate = $t054655729._1 | |
198 | + | let withdrawLimitLeft = $t054655729._2 | |
153 | 199 | $Tuple2(newLastWithdrawnDate, withdrawLimitLeft) | |
154 | 200 | } | |
155 | 201 | ||
159 | 205 | then divd((freeBalance() + _amountOfQuoteAsset), totalSupply()) | |
160 | 206 | else DECIMAL_UNIT | |
161 | 207 | newRate | |
208 | + | } | |
209 | + | ||
210 | + | ||
211 | + | func lastTimeRewardApplicable () = minv(currentTimestampSec(), periodFinish()) | |
212 | + | ||
213 | + | ||
214 | + | func rewardPerToken (_balanceDelta) = if (((totalSupply() + _balanceDelta) == 0)) | |
215 | + | then rewardPerTokenStored() | |
216 | + | else { | |
217 | + | let timeInterval = (lastTimeRewardApplicable() - lastUpdateTime()) | |
218 | + | let actualTimeInterval = if ((0 > timeInterval)) | |
219 | + | then 0 | |
220 | + | else timeInterval | |
221 | + | let diff = divd((rewardRate() * actualTimeInterval), (totalSupply() + _balanceDelta)) | |
222 | + | (rewardPerTokenStored() + diff) | |
223 | + | } | |
224 | + | ||
225 | + | ||
226 | + | func earned (_staker,_balanceDelta) = { | |
227 | + | let rewardDelta = (rewardPerToken(_balanceDelta) - userRewardPerTokenPaid(_staker)) | |
228 | + | (muld((balanceOf(_staker) + _balanceDelta), rewardDelta) + rewards(_staker)) | |
229 | + | } | |
230 | + | ||
231 | + | ||
232 | + | func updateReward (_staker,_balanceDelta) = { | |
233 | + | let newRewardPerTokenStored = rewardPerToken(_balanceDelta) | |
234 | + | let newLastUpdateTime = currentTimestampSec() | |
235 | + | let $t069257117 = if ((_staker != "")) | |
236 | + | then $Tuple2(earned(_staker, _balanceDelta), newRewardPerTokenStored) | |
237 | + | else $Tuple2(0, 0) | |
238 | + | let stakerEarned = $t069257117._1 | |
239 | + | let stakerRewardPerTokenPaid = $t069257117._2 | |
240 | + | $Tuple4(newRewardPerTokenStored, newLastUpdateTime, stakerEarned, stakerRewardPerTokenPaid) | |
162 | 241 | } | |
163 | 242 | ||
164 | 243 | ||
207 | 286 | func setUserWithdrawParams (_user,_lastWithdrawDate,_withdrawn) = [IntegerEntry(toCompositeKey(k_last_withdraw_date, _user), _lastWithdrawDate), IntegerEntry(toCompositeKey(k_withdraw_in_period, _user), _withdrawn)] | |
208 | 287 | ||
209 | 288 | ||
289 | + | func updateRewardBalance (_delta) = [IntegerEntry(k_rewardBalance, (rewardBalance() + _delta))] | |
290 | + | ||
291 | + | ||
292 | + | func updateRewardRate (_rewardRate) = [IntegerEntry(k_rewardRate, _rewardRate)] | |
293 | + | ||
294 | + | ||
295 | + | func updateTime (_lastUpdateTime,_periodFinish) = [IntegerEntry(k_lastUpdateTime, _lastUpdateTime), IntegerEntry(k_periodFinish, _periodFinish)] | |
296 | + | ||
297 | + | ||
298 | + | func updateRewardPerTokenStored (_rewardPerTokenStored) = [IntegerEntry(k_rewardPerTokenStored, _rewardPerTokenStored)] | |
299 | + | ||
300 | + | ||
301 | + | func updateUserRewards (_staker,_reward,_userRewardPerToken) = [IntegerEntry(toCompositeKey(k_userReward, _staker), _reward), IntegerEntry(toCompositeKey(k_userRewardPerToken, _staker), _userRewardPerToken)] | |
302 | + | ||
303 | + | ||
210 | 304 | @Callable(i) | |
211 | 305 | func initialize (_coordinator) = if (initialized()) | |
212 | 306 | then throw("Already initialized") | |
223 | 317 | else !(initialized())) | |
224 | 318 | then throw("Invalid call to stake") | |
225 | 319 | else { | |
320 | + | let $t01075210981 = updateReward(_staker, 0) | |
321 | + | let newRewardPerTokenStored = $t01075210981._1 | |
322 | + | let newLastUpdateTime = $t01075210981._2 | |
323 | + | let stakerEarned = $t01075210981._3 | |
324 | + | let stakerRewardPerTokenPaid = $t01075210981._4 | |
226 | 325 | let currentRate = rate() | |
227 | 326 | let prevAverageRate = averageRate(_staker) | |
228 | 327 | let vAmount = divd(_amount, currentRate) | |
231 | 330 | let newWithdrawLimit = muld(newTotalBalance, WITHDRAW_PER_PERIOD) | |
232 | 331 | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), usdnFromDecimals(_amount))]) | |
233 | 332 | if ((stake == stake)) | |
234 | - | then ((((updateFreeBalance(_amount) ++ updateUserBalance(_staker, vAmount)) ++ setUserAverageRate(_staker, newAverageRate)) ++ setUserWithdrawLimit(_staker, newWithdrawLimit)) ++ updateTotalSupply(vAmount)) | |
333 | + | then (((((((updateUserRewards(_staker, stakerEarned, stakerRewardPerTokenPaid) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(newLastUpdateTime, periodFinish())) ++ updateFreeBalance(_amount)) ++ updateUserBalance(_staker, vAmount)) ++ setUserAverageRate(_staker, newAverageRate)) ++ setUserWithdrawLimit(_staker, newWithdrawLimit)) ++ updateTotalSupply(vAmount)) | |
235 | 334 | else throw("Strict value is not equal to itself.") | |
236 | 335 | } | |
237 | 336 | } | |
247 | 346 | else !(initialized())) | |
248 | 347 | then throw("Invalid call to unStake") | |
249 | 348 | else { | |
250 | - | let $t088939034 = getWithdrawLimitLeft(_staker) | |
251 | - | let newLastWithdrawnDate = $t088939034._1 | |
252 | - | let withdrawLimitLeft = $t088939034._2 | |
349 | + | let $t01230212518 = updateReward(_staker, 0) | |
350 | + | let newRewardPerTokenStored = $t01230212518._1 | |
351 | + | let newLastUpdateTime = $t01230212518._2 | |
352 | + | let stakerEarned = $t01230212518._3 | |
353 | + | let stakerRewardPerTokenPaid = $t01230212518._4 | |
354 | + | let $t01252512666 = getWithdrawLimitLeft(_staker) | |
355 | + | let newLastWithdrawnDate = $t01252512666._1 | |
356 | + | let withdrawLimitLeft = $t01252512666._2 | |
253 | 357 | let vAmount = divd(amountOfQuoteAsset, rate()) | |
254 | 358 | if ((vAmount > withdrawLimitLeft)) | |
255 | 359 | then throw("Invalid call to unStake: withdraw over limit") | |
260 | 364 | else { | |
261 | 365 | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), usdnFromDecimals(amountOfQuoteAsset)], nil) | |
262 | 366 | if ((unstake == unstake)) | |
263 | - | then ((((updateFreeBalance(-(amountOfQuoteAsset)) ++ updateUserBalance(_staker, -(vAmount))) ++ updateTotalSupply(-(vAmount))) ++ setUserWithdrawParams(_staker, newLastWithdrawnDate, newWithdrawnInPeriod)) ++ [ScriptTransfer(i.caller, usdnFromDecimals(amountOfQuoteAsset), quoteAsset())]) | |
367 | + | then (((((((updateUserRewards(_staker, stakerEarned, stakerRewardPerTokenPaid) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(newLastUpdateTime, periodFinish())) ++ updateFreeBalance(-(amountOfQuoteAsset))) ++ updateUserBalance(_staker, -(vAmount))) ++ updateTotalSupply(-(vAmount))) ++ setUserWithdrawParams(_staker, newLastWithdrawnDate, newWithdrawnInPeriod)) ++ [ScriptTransfer(i.caller, usdnFromDecimals(amountOfQuoteAsset), quoteAsset())]) | |
264 | 368 | else throw("Strict value is not equal to itself.") | |
265 | 369 | } | |
266 | 370 | } | |
267 | 371 | } | |
372 | + | } | |
373 | + | ||
374 | + | ||
375 | + | ||
376 | + | @Callable(i) | |
377 | + | func withdrawRewards () = { | |
378 | + | let _staker = toString(i.caller) | |
379 | + | let $t01400414149 = updateReward(_staker, 0) | |
380 | + | let newRewardPerTokenStored = $t01400414149._1 | |
381 | + | let newLastUpdateTime = $t01400414149._2 | |
382 | + | let stakerEarned = $t01400414149._3 | |
383 | + | let stakerRewardPerTokenPaid = $t01400414149._4 | |
384 | + | if (if ((0 >= stakerEarned)) | |
385 | + | then true | |
386 | + | else !(initialized())) | |
387 | + | then throw("No reward: Vault") | |
388 | + | else ((((updateUserRewards(_staker, 0, stakerRewardPerTokenPaid) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(newLastUpdateTime, periodFinish())) ++ updateRewardBalance(-(stakerEarned))) ++ [ScriptTransfer(i.caller, stakerEarned, governanceAsset())]) | |
268 | 389 | } | |
269 | 390 | ||
270 | 391 | ||
347 | 468 | else { | |
348 | 469 | let amountOfQuoteAsset = usdnToDecimals(_amount) | |
349 | 470 | let borrowedBalance = freeBalanceBorrowed() | |
350 | - | let $ | |
471 | + | let $t01698217469 = if (if ((amountOfQuoteAsset > 0)) | |
351 | 472 | then (borrowedBalance > 0) | |
352 | 473 | else false) | |
353 | 474 | then $Tuple2(-(amountOfQuoteAsset), -(minv(amountOfQuoteAsset, borrowedBalance))) | |
354 | 475 | else $Tuple2(-(amountOfQuoteAsset), 0) | |
355 | - | let freeUpdate = $ | |
356 | - | let freeBorrowedUpdate = $ | |
476 | + | let freeUpdate = $t01698217469._1 | |
477 | + | let freeBorrowedUpdate = $t01698217469._2 | |
357 | 478 | let newRate = computeNewRate(freeUpdate) | |
358 | 479 | (((updateLockedBalance(amountOfQuoteAsset) ++ updateFreeBalance(freeUpdate)) ++ updateFreeBorrowedBalance(freeBorrowedUpdate)) ++ updateRate(newRate)) | |
359 | 480 | } | |
373 | 494 | if ((unstake == unstake)) | |
374 | 495 | then { | |
375 | 496 | let lockBalanceNow = lockedBalance() | |
376 | - | let $ | |
497 | + | let $t01825318446 = if ((amountOfQuoteAsset > lockBalanceNow)) | |
377 | 498 | then $Tuple2(lockBalanceNow, (amountOfQuoteAsset - lockBalanceNow)) | |
378 | 499 | else $Tuple2(amountOfQuoteAsset, 0) | |
379 | - | let fromLocked = $ | |
380 | - | let fromFree = $ | |
500 | + | let fromLocked = $t01825318446._1 | |
501 | + | let fromFree = $t01825318446._2 | |
381 | 502 | let vLockBalanceNow = vLockedBalance() | |
382 | 503 | let realLockBalanceNow = (lockBalanceNow - vLockBalanceNow) | |
383 | - | let $ | |
504 | + | let $t01856418752 = if ((fromLocked > realLockBalanceNow)) | |
384 | 505 | then $Tuple2(realLockBalanceNow, (fromLocked - realLockBalanceNow)) | |
385 | 506 | else $Tuple2(fromLocked, 0) | |
386 | - | let fromRealLocked = $ | |
387 | - | let fromVLocked = $ | |
507 | + | let fromRealLocked = $t01856418752._1 | |
508 | + | let fromVLocked = $t01856418752._2 | |
388 | 509 | ((((if ((fromVLocked > 0)) | |
389 | 510 | then updateFreeBorrowedBalance(fromVLocked) | |
390 | 511 | else nil) ++ (if ((fromFree > 0)) | |
409 | 530 | else { | |
410 | 531 | let amountOfQuoteAsset = usdnToDecimals(_amountUsdn) | |
411 | 532 | let lockBalanceNow = lockedBalance() | |
412 | - | let $ | |
533 | + | let $t01960919802 = if ((amountOfQuoteAsset > lockBalanceNow)) | |
413 | 534 | then $Tuple2(lockBalanceNow, (amountOfQuoteAsset - lockBalanceNow)) | |
414 | 535 | else $Tuple2(amountOfQuoteAsset, 0) | |
415 | - | let fromLocked = $ | |
416 | - | let fromFree = $ | |
536 | + | let fromLocked = $t01960919802._1 | |
537 | + | let fromFree = $t01960919802._2 | |
417 | 538 | (((if ((fromFree > 0)) | |
418 | 539 | then { | |
419 | 540 | let newRate = computeNewRate(-(fromFree)) | |
425 | 546 | ||
426 | 547 | ||
427 | 548 | @Callable(i) | |
549 | + | func addRewards () = if (if ((i.payments[0].assetId != governanceAsset())) | |
550 | + | then true | |
551 | + | else !(initialized())) | |
552 | + | then throw("Invalid addRewards params") | |
553 | + | else { | |
554 | + | let _reward = i.payments[0].amount | |
555 | + | let newRewardPerTokenStored = updateReward(NO_ADDRESS, NO_STAKER)._1 | |
556 | + | let timestamp = currentTimestampSec() | |
557 | + | let newRewardRate = if ((timestamp > periodFinish())) | |
558 | + | then (_reward / DURATION) | |
559 | + | else { | |
560 | + | let remainingTime = (periodFinish() - timestamp) | |
561 | + | let leftover = (rewardRate() * remainingTime) | |
562 | + | ((_reward + leftover) / DURATION) | |
563 | + | } | |
564 | + | (((updateRewardRate(newRewardRate) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateRewardBalance(_reward)) ++ updateTime(timestamp, (timestamp + DURATION))) | |
565 | + | } | |
566 | + | ||
567 | + | ||
568 | + | ||
569 | + | @Callable(i) | |
428 | 570 | func view_reward (_staker) = { | |
429 | 571 | let balance = balanceOf(_staker) | |
430 | 572 | let depositedAmount = muld(averageRate(_staker), balance) | |
431 | 573 | let currentAmount = muld(rate(), balance) | |
432 | - | let | |
433 | - | throw(toString( | |
574 | + | let earnedQuote = (currentAmount - depositedAmount) | |
575 | + | throw(toString(earnedQuote)) | |
434 | 576 | } | |
435 | 577 | ||
436 | 578 |
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 | + | ||
6 | + | let k_rewardBalance = "k_rewardBalance" | |
5 | 7 | ||
6 | 8 | let k_lockedBalance = "k_lockedBalance" | |
7 | 9 | ||
8 | 10 | let k_vLockedBalance = "k_vLockedBalance" | |
9 | 11 | ||
10 | 12 | let k_freeBalance = "k_freeBalance" | |
11 | 13 | ||
12 | 14 | let k_freeBalanceBorrowed = "k_freeBalanceBorrowed" | |
13 | 15 | ||
14 | 16 | let k_rate = "k_rate" | |
17 | + | ||
18 | + | let k_lastUpdateTime = "k_lastUpdateTime" | |
19 | + | ||
20 | + | let k_rewardPerTokenStored = "k_rewardPerTokenStored" | |
21 | + | ||
22 | + | let k_rewardRate = "k_rewardRate" | |
23 | + | ||
24 | + | let k_periodFinish = "k_periodFinish" | |
25 | + | ||
26 | + | let k_userRewardPerToken = "k_userRewardPerToken" | |
27 | + | ||
28 | + | let k_userReward = "k_userReward" | |
15 | 29 | ||
16 | 30 | let k_balance = "k_balance" | |
17 | 31 | ||
18 | 32 | let k_average_rate = "k_average_rate" | |
19 | 33 | ||
20 | 34 | let k_withdraw_limit = "k_withdraw_limit" | |
21 | 35 | ||
22 | 36 | let k_last_withdraw_date = "k_last_withdraw_date" | |
23 | 37 | ||
24 | 38 | let k_withdraw_in_period = "k_withdraw_in_period" | |
25 | 39 | ||
26 | 40 | let k_initialized = "k_initialized" | |
27 | 41 | ||
28 | 42 | let k_coordinatorAddress = "k_coordinatorAddress" | |
29 | 43 | ||
30 | 44 | let k_amm = "k_amm" | |
45 | + | ||
46 | + | let k_governance_asset = "k_gov_asset" | |
31 | 47 | ||
32 | 48 | let k_quote_asset = "k_quote_asset" | |
33 | 49 | ||
34 | 50 | let k_admin_public_key = "k_admin_public_key" | |
35 | 51 | ||
36 | 52 | let k_admin_address = "k_admin_address" | |
37 | 53 | ||
38 | 54 | let k_manager_address = "k_manager_address" | |
39 | 55 | ||
40 | 56 | let k_collateral_address = "k_collateral_address" | |
41 | 57 | ||
42 | 58 | func toCompositeKey (_key,_address) = ((_key + "_") + _address) | |
43 | 59 | ||
44 | 60 | ||
45 | 61 | func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(this, k_coordinatorAddress)), "Coordinator not set") | |
46 | 62 | ||
47 | 63 | ||
48 | 64 | func isWhitelist (_address) = valueOrElse(getBoolean(coordinator(), toCompositeKey(k_amm, _address)), false) | |
49 | 65 | ||
50 | 66 | ||
51 | 67 | func adminPublicKey () = fromBase58String(getStringValue(coordinator(), k_admin_public_key)) | |
52 | 68 | ||
53 | 69 | ||
70 | + | func governanceAsset () = fromBase58String(getStringValue(coordinator(), k_governance_asset)) | |
71 | + | ||
72 | + | ||
54 | 73 | func adminAddress () = addressFromString(valueOrErrorMessage(getString(coordinator(), k_admin_address), "Admin address not set")) | |
55 | 74 | ||
56 | 75 | ||
57 | 76 | func quoteAsset () = fromBase58String(getStringValue(coordinator(), k_quote_asset)) | |
58 | 77 | ||
59 | 78 | ||
60 | 79 | func managerAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_manager_address)), "Manager not set") | |
61 | 80 | ||
62 | 81 | ||
63 | 82 | func collateralAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_collateral_address)), "Collateral Manager not set") | |
64 | 83 | ||
65 | 84 | ||
66 | 85 | let DECIMAL_UNIT = (1 * (((((((10 * 10) * 10) * 10) * 10) * 10) * 10) * 10)) | |
67 | 86 | ||
68 | - | let DURATION = ((60 * 60) * 24) | |
87 | + | let DURATION = (((7 * 60) * 60) * 24) | |
69 | 88 | ||
70 | 89 | let NO_ADDRESS = "" | |
71 | 90 | ||
72 | 91 | let NO_STAKER = 0 | |
73 | 92 | ||
74 | 93 | func usdnFromDecimals (_amount) = (_amount / 100) | |
75 | 94 | ||
76 | 95 | ||
77 | 96 | func usdnToDecimals (_amount) = (_amount * 100) | |
78 | 97 | ||
79 | 98 | ||
80 | 99 | func divd (_x,_y) = fraction(_x, DECIMAL_UNIT, _y, HALFEVEN) | |
81 | 100 | ||
82 | 101 | ||
83 | 102 | func muld (_x,_y) = fraction(_x, _y, DECIMAL_UNIT, HALFEVEN) | |
84 | 103 | ||
85 | 104 | ||
86 | 105 | func abs (_x) = if ((_x > 0)) | |
87 | 106 | then _x | |
88 | 107 | else -(_x) | |
89 | 108 | ||
90 | 109 | ||
91 | 110 | func minv (_x,_y) = if ((_x > _y)) | |
92 | 111 | then _y | |
93 | 112 | else _x | |
94 | 113 | ||
95 | 114 | ||
96 | 115 | let WITHDRAW_PERIOD = (86400 * 1000) | |
97 | 116 | ||
98 | 117 | let WITHDRAW_PER_PERIOD = divd((1 * DECIMAL_UNIT), (4 * DECIMAL_UNIT)) | |
99 | 118 | ||
100 | 119 | func int (k) = valueOrErrorMessage(getInteger(this, k), ("no value for " + k)) | |
101 | 120 | ||
102 | 121 | ||
103 | 122 | func int0 (k) = valueOrElse(getInteger(this, k), 0) | |
104 | 123 | ||
105 | 124 | ||
106 | 125 | func int1 (k) = valueOrElse(getInteger(this, k), DECIMAL_UNIT) | |
107 | 126 | ||
108 | 127 | ||
109 | 128 | func totalSupply () = int0(k_totalSupply) | |
110 | 129 | ||
111 | 130 | ||
112 | 131 | func rate () = int1(k_rate) | |
113 | 132 | ||
114 | 133 | ||
115 | 134 | func balanceOf (_staker) = int0(toCompositeKey(k_balance, _staker)) | |
116 | 135 | ||
117 | 136 | ||
118 | 137 | func averageRate (_staker) = int0(toCompositeKey(k_average_rate, _staker)) | |
119 | 138 | ||
120 | 139 | ||
121 | 140 | func withdrawLimit (_staker) = int0(toCompositeKey(k_withdraw_limit, _staker)) | |
122 | 141 | ||
123 | 142 | ||
124 | 143 | func withdrawnInPeriod (_staker) = int0(toCompositeKey(k_withdraw_in_period, _staker)) | |
125 | 144 | ||
126 | 145 | ||
127 | 146 | func lastWithdrawnDate (_staker) = int0(toCompositeKey(k_last_withdraw_date, _staker)) | |
128 | 147 | ||
129 | 148 | ||
130 | 149 | func freeBalance () = int0(k_freeBalance) | |
131 | 150 | ||
132 | 151 | ||
133 | 152 | func freeBalanceBorrowed () = int0(k_freeBalanceBorrowed) | |
134 | 153 | ||
135 | 154 | ||
136 | 155 | func lockedBalance () = int0(k_lockedBalance) | |
137 | 156 | ||
138 | 157 | ||
139 | 158 | func vLockedBalance () = int0(k_vLockedBalance) | |
140 | 159 | ||
141 | 160 | ||
161 | + | func rewardPerTokenStored () = int0(k_rewardPerTokenStored) | |
162 | + | ||
163 | + | ||
164 | + | func lastUpdateTime () = int0(k_lastUpdateTime) | |
165 | + | ||
166 | + | ||
167 | + | func rewardRate () = int0(k_rewardRate) | |
168 | + | ||
169 | + | ||
170 | + | func periodFinish () = int0(k_periodFinish) | |
171 | + | ||
172 | + | ||
173 | + | func rewardBalance () = int0(k_rewardBalance) | |
174 | + | ||
175 | + | ||
176 | + | func rewards (_staker) = int0(toCompositeKey(k_userReward, _staker)) | |
177 | + | ||
178 | + | ||
179 | + | func userRewardPerTokenPaid (_staker) = int0(toCompositeKey(k_userRewardPerToken, _staker)) | |
180 | + | ||
181 | + | ||
142 | 182 | func initialized () = valueOrElse(getBoolean(this, k_initialized), false) | |
143 | 183 | ||
144 | 184 | ||
185 | + | func currentTimestamp () = lastBlock.timestamp | |
186 | + | ||
187 | + | ||
188 | + | func currentTimestampSec () = (currentTimestamp() / 1000) | |
189 | + | ||
190 | + | ||
145 | 191 | func getWithdrawLimitLeft (_staker) = { | |
146 | - | let currentDate = | |
192 | + | let currentDate = currentTimestamp() | |
147 | 193 | let lastWithdrawDate = lastWithdrawnDate(_staker) | |
148 | - | let $ | |
194 | + | let $t054655729 = if (((currentDate - lastWithdrawDate) > WITHDRAW_PERIOD)) | |
149 | 195 | then $Tuple2(currentDate, withdrawLimit(_staker)) | |
150 | 196 | else $Tuple2(lastWithdrawDate, (withdrawLimit(_staker) - withdrawnInPeriod(_staker))) | |
151 | - | let newLastWithdrawnDate = $ | |
152 | - | let withdrawLimitLeft = $ | |
197 | + | let newLastWithdrawnDate = $t054655729._1 | |
198 | + | let withdrawLimitLeft = $t054655729._2 | |
153 | 199 | $Tuple2(newLastWithdrawnDate, withdrawLimitLeft) | |
154 | 200 | } | |
155 | 201 | ||
156 | 202 | ||
157 | 203 | func computeNewRate (_amountOfQuoteAsset) = { | |
158 | 204 | let newRate = if ((totalSupply() > 0)) | |
159 | 205 | then divd((freeBalance() + _amountOfQuoteAsset), totalSupply()) | |
160 | 206 | else DECIMAL_UNIT | |
161 | 207 | newRate | |
208 | + | } | |
209 | + | ||
210 | + | ||
211 | + | func lastTimeRewardApplicable () = minv(currentTimestampSec(), periodFinish()) | |
212 | + | ||
213 | + | ||
214 | + | func rewardPerToken (_balanceDelta) = if (((totalSupply() + _balanceDelta) == 0)) | |
215 | + | then rewardPerTokenStored() | |
216 | + | else { | |
217 | + | let timeInterval = (lastTimeRewardApplicable() - lastUpdateTime()) | |
218 | + | let actualTimeInterval = if ((0 > timeInterval)) | |
219 | + | then 0 | |
220 | + | else timeInterval | |
221 | + | let diff = divd((rewardRate() * actualTimeInterval), (totalSupply() + _balanceDelta)) | |
222 | + | (rewardPerTokenStored() + diff) | |
223 | + | } | |
224 | + | ||
225 | + | ||
226 | + | func earned (_staker,_balanceDelta) = { | |
227 | + | let rewardDelta = (rewardPerToken(_balanceDelta) - userRewardPerTokenPaid(_staker)) | |
228 | + | (muld((balanceOf(_staker) + _balanceDelta), rewardDelta) + rewards(_staker)) | |
229 | + | } | |
230 | + | ||
231 | + | ||
232 | + | func updateReward (_staker,_balanceDelta) = { | |
233 | + | let newRewardPerTokenStored = rewardPerToken(_balanceDelta) | |
234 | + | let newLastUpdateTime = currentTimestampSec() | |
235 | + | let $t069257117 = if ((_staker != "")) | |
236 | + | then $Tuple2(earned(_staker, _balanceDelta), newRewardPerTokenStored) | |
237 | + | else $Tuple2(0, 0) | |
238 | + | let stakerEarned = $t069257117._1 | |
239 | + | let stakerRewardPerTokenPaid = $t069257117._2 | |
240 | + | $Tuple4(newRewardPerTokenStored, newLastUpdateTime, stakerEarned, stakerRewardPerTokenPaid) | |
162 | 241 | } | |
163 | 242 | ||
164 | 243 | ||
165 | 244 | func updateUserBalance (_user,_change) = [IntegerEntry(toCompositeKey(k_balance, _user), (balanceOf(_user) + _change))] | |
166 | 245 | ||
167 | 246 | ||
168 | 247 | func setUserWithdrawLimit (_user,_rate) = [IntegerEntry(toCompositeKey(k_withdraw_limit, _user), _rate)] | |
169 | 248 | ||
170 | 249 | ||
171 | 250 | func setUserAverageRate (_user,_rate) = [IntegerEntry(toCompositeKey(k_average_rate, _user), _rate)] | |
172 | 251 | ||
173 | 252 | ||
174 | 253 | func updateFreeBalance (_change) = [IntegerEntry(k_freeBalance, (freeBalance() + _change))] | |
175 | 254 | ||
176 | 255 | ||
177 | 256 | func updateFreeBorrowedBalance (_change) = { | |
178 | 257 | let borrowedBalance = freeBalanceBorrowed() | |
179 | 258 | if (((borrowedBalance + _change) >= 0)) | |
180 | 259 | then [IntegerEntry(k_freeBalanceBorrowed, (borrowedBalance + _change))] | |
181 | 260 | else throw(((("Vault: can not update borrowed free balance. Balance: " + toString(borrowedBalance)) + " change: ") + toString(_change))) | |
182 | 261 | } | |
183 | 262 | ||
184 | 263 | ||
185 | 264 | func updateLockedBalance (_change) = { | |
186 | 265 | let balance = lockedBalance() | |
187 | 266 | if (((balance + _change) >= 0)) | |
188 | 267 | then [IntegerEntry(k_lockedBalance, (balance + _change))] | |
189 | 268 | else throw(((("Vault: can not update locked balance. Balance: " + toString(balance)) + " change: ") + toString(_change))) | |
190 | 269 | } | |
191 | 270 | ||
192 | 271 | ||
193 | 272 | func updateVLockedBalance (_change) = { | |
194 | 273 | let balance = vLockedBalance() | |
195 | 274 | if (((balance + _change) >= 0)) | |
196 | 275 | then [IntegerEntry(k_vLockedBalance, (balance + _change))] | |
197 | 276 | else throw(((("Vault: can not update v-locked balance. Balance: " + toString(balance)) + " change: ") + toString(_change))) | |
198 | 277 | } | |
199 | 278 | ||
200 | 279 | ||
201 | 280 | func updateTotalSupply (_change) = [IntegerEntry(k_totalSupply, (totalSupply() + _change))] | |
202 | 281 | ||
203 | 282 | ||
204 | 283 | func updateRate (_rate) = [IntegerEntry(k_rate, _rate)] | |
205 | 284 | ||
206 | 285 | ||
207 | 286 | func setUserWithdrawParams (_user,_lastWithdrawDate,_withdrawn) = [IntegerEntry(toCompositeKey(k_last_withdraw_date, _user), _lastWithdrawDate), IntegerEntry(toCompositeKey(k_withdraw_in_period, _user), _withdrawn)] | |
208 | 287 | ||
209 | 288 | ||
289 | + | func updateRewardBalance (_delta) = [IntegerEntry(k_rewardBalance, (rewardBalance() + _delta))] | |
290 | + | ||
291 | + | ||
292 | + | func updateRewardRate (_rewardRate) = [IntegerEntry(k_rewardRate, _rewardRate)] | |
293 | + | ||
294 | + | ||
295 | + | func updateTime (_lastUpdateTime,_periodFinish) = [IntegerEntry(k_lastUpdateTime, _lastUpdateTime), IntegerEntry(k_periodFinish, _periodFinish)] | |
296 | + | ||
297 | + | ||
298 | + | func updateRewardPerTokenStored (_rewardPerTokenStored) = [IntegerEntry(k_rewardPerTokenStored, _rewardPerTokenStored)] | |
299 | + | ||
300 | + | ||
301 | + | func updateUserRewards (_staker,_reward,_userRewardPerToken) = [IntegerEntry(toCompositeKey(k_userReward, _staker), _reward), IntegerEntry(toCompositeKey(k_userRewardPerToken, _staker), _userRewardPerToken)] | |
302 | + | ||
303 | + | ||
210 | 304 | @Callable(i) | |
211 | 305 | func initialize (_coordinator) = if (initialized()) | |
212 | 306 | then throw("Already initialized") | |
213 | 307 | else [StringEntry(k_coordinatorAddress, _coordinator), BooleanEntry(k_initialized, true)] | |
214 | 308 | ||
215 | 309 | ||
216 | 310 | ||
217 | 311 | @Callable(i) | |
218 | 312 | func stake () = { | |
219 | 313 | let _staker = toString(i.caller) | |
220 | 314 | let _amount = usdnToDecimals(i.payments[0].amount) | |
221 | 315 | if (if ((i.payments[0].assetId != quoteAsset())) | |
222 | 316 | then true | |
223 | 317 | else !(initialized())) | |
224 | 318 | then throw("Invalid call to stake") | |
225 | 319 | else { | |
320 | + | let $t01075210981 = updateReward(_staker, 0) | |
321 | + | let newRewardPerTokenStored = $t01075210981._1 | |
322 | + | let newLastUpdateTime = $t01075210981._2 | |
323 | + | let stakerEarned = $t01075210981._3 | |
324 | + | let stakerRewardPerTokenPaid = $t01075210981._4 | |
226 | 325 | let currentRate = rate() | |
227 | 326 | let prevAverageRate = averageRate(_staker) | |
228 | 327 | let vAmount = divd(_amount, currentRate) | |
229 | 328 | let newAverageRate = divd((muld(vAmount, currentRate) + muld(balanceOf(_staker), prevAverageRate)), (currentRate + prevAverageRate)) | |
230 | 329 | let newTotalBalance = (vAmount + balanceOf(_staker)) | |
231 | 330 | let newWithdrawLimit = muld(newTotalBalance, WITHDRAW_PER_PERIOD) | |
232 | 331 | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), usdnFromDecimals(_amount))]) | |
233 | 332 | if ((stake == stake)) | |
234 | - | then ((((updateFreeBalance(_amount) ++ updateUserBalance(_staker, vAmount)) ++ setUserAverageRate(_staker, newAverageRate)) ++ setUserWithdrawLimit(_staker, newWithdrawLimit)) ++ updateTotalSupply(vAmount)) | |
333 | + | then (((((((updateUserRewards(_staker, stakerEarned, stakerRewardPerTokenPaid) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(newLastUpdateTime, periodFinish())) ++ updateFreeBalance(_amount)) ++ updateUserBalance(_staker, vAmount)) ++ setUserAverageRate(_staker, newAverageRate)) ++ setUserWithdrawLimit(_staker, newWithdrawLimit)) ++ updateTotalSupply(vAmount)) | |
235 | 334 | else throw("Strict value is not equal to itself.") | |
236 | 335 | } | |
237 | 336 | } | |
238 | 337 | ||
239 | 338 | ||
240 | 339 | ||
241 | 340 | @Callable(i) | |
242 | 341 | func unStake (_amount) = { | |
243 | 342 | let _staker = toString(i.caller) | |
244 | 343 | let amountOfQuoteAsset = usdnToDecimals(_amount) | |
245 | 344 | if (if ((i.payments != nil)) | |
246 | 345 | then true | |
247 | 346 | else !(initialized())) | |
248 | 347 | then throw("Invalid call to unStake") | |
249 | 348 | else { | |
250 | - | let $t088939034 = getWithdrawLimitLeft(_staker) | |
251 | - | let newLastWithdrawnDate = $t088939034._1 | |
252 | - | let withdrawLimitLeft = $t088939034._2 | |
349 | + | let $t01230212518 = updateReward(_staker, 0) | |
350 | + | let newRewardPerTokenStored = $t01230212518._1 | |
351 | + | let newLastUpdateTime = $t01230212518._2 | |
352 | + | let stakerEarned = $t01230212518._3 | |
353 | + | let stakerRewardPerTokenPaid = $t01230212518._4 | |
354 | + | let $t01252512666 = getWithdrawLimitLeft(_staker) | |
355 | + | let newLastWithdrawnDate = $t01252512666._1 | |
356 | + | let withdrawLimitLeft = $t01252512666._2 | |
253 | 357 | let vAmount = divd(amountOfQuoteAsset, rate()) | |
254 | 358 | if ((vAmount > withdrawLimitLeft)) | |
255 | 359 | then throw("Invalid call to unStake: withdraw over limit") | |
256 | 360 | else { | |
257 | 361 | let newWithdrawnInPeriod = (withdrawnInPeriod(_staker) + vAmount) | |
258 | 362 | if ((amountOfQuoteAsset > freeBalance())) | |
259 | 363 | then throw("Invalid call to unStake: balance too low") | |
260 | 364 | else { | |
261 | 365 | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), usdnFromDecimals(amountOfQuoteAsset)], nil) | |
262 | 366 | if ((unstake == unstake)) | |
263 | - | then ((((updateFreeBalance(-(amountOfQuoteAsset)) ++ updateUserBalance(_staker, -(vAmount))) ++ updateTotalSupply(-(vAmount))) ++ setUserWithdrawParams(_staker, newLastWithdrawnDate, newWithdrawnInPeriod)) ++ [ScriptTransfer(i.caller, usdnFromDecimals(amountOfQuoteAsset), quoteAsset())]) | |
367 | + | then (((((((updateUserRewards(_staker, stakerEarned, stakerRewardPerTokenPaid) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(newLastUpdateTime, periodFinish())) ++ updateFreeBalance(-(amountOfQuoteAsset))) ++ updateUserBalance(_staker, -(vAmount))) ++ updateTotalSupply(-(vAmount))) ++ setUserWithdrawParams(_staker, newLastWithdrawnDate, newWithdrawnInPeriod)) ++ [ScriptTransfer(i.caller, usdnFromDecimals(amountOfQuoteAsset), quoteAsset())]) | |
264 | 368 | else throw("Strict value is not equal to itself.") | |
265 | 369 | } | |
266 | 370 | } | |
267 | 371 | } | |
372 | + | } | |
373 | + | ||
374 | + | ||
375 | + | ||
376 | + | @Callable(i) | |
377 | + | func withdrawRewards () = { | |
378 | + | let _staker = toString(i.caller) | |
379 | + | let $t01400414149 = updateReward(_staker, 0) | |
380 | + | let newRewardPerTokenStored = $t01400414149._1 | |
381 | + | let newLastUpdateTime = $t01400414149._2 | |
382 | + | let stakerEarned = $t01400414149._3 | |
383 | + | let stakerRewardPerTokenPaid = $t01400414149._4 | |
384 | + | if (if ((0 >= stakerEarned)) | |
385 | + | then true | |
386 | + | else !(initialized())) | |
387 | + | then throw("No reward: Vault") | |
388 | + | else ((((updateUserRewards(_staker, 0, stakerRewardPerTokenPaid) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(newLastUpdateTime, periodFinish())) ++ updateRewardBalance(-(stakerEarned))) ++ [ScriptTransfer(i.caller, stakerEarned, governanceAsset())]) | |
268 | 389 | } | |
269 | 390 | ||
270 | 391 | ||
271 | 392 | ||
272 | 393 | @Callable(i) | |
273 | 394 | func addFree () = { | |
274 | 395 | let _amount = usdnToDecimals(i.payments[0].amount) | |
275 | 396 | if (if (if ((i.payments[0].assetId != quoteAsset())) | |
276 | 397 | then true | |
277 | 398 | else !(initialized())) | |
278 | 399 | then true | |
279 | 400 | else !(if (isWhitelist(toString(i.caller))) | |
280 | 401 | then true | |
281 | 402 | else (i.caller == adminAddress()))) | |
282 | 403 | then throw("Invalid addFree params") | |
283 | 404 | else { | |
284 | 405 | let newRate = if ((totalSupply() > 0)) | |
285 | 406 | then divd((freeBalance() + _amount), totalSupply()) | |
286 | 407 | else DECIMAL_UNIT | |
287 | 408 | let unstake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), usdnFromDecimals(_amount))]) | |
288 | 409 | if ((unstake == unstake)) | |
289 | 410 | then (updateFreeBalance(_amount) ++ updateRate(newRate)) | |
290 | 411 | else throw("Strict value is not equal to itself.") | |
291 | 412 | } | |
292 | 413 | } | |
293 | 414 | ||
294 | 415 | ||
295 | 416 | ||
296 | 417 | @Callable(i) | |
297 | 418 | func addLocked (_repay) = { | |
298 | 419 | let _amount = usdnToDecimals(i.payments[0].amount) | |
299 | 420 | if (if (if ((i.payments[0].assetId != quoteAsset())) | |
300 | 421 | then true | |
301 | 422 | else !(initialized())) | |
302 | 423 | then true | |
303 | 424 | else !(if (if (isWhitelist(toString(i.caller))) | |
304 | 425 | then true | |
305 | 426 | else (i.caller == collateralAddress())) | |
306 | 427 | then true | |
307 | 428 | else (i.caller == adminAddress()))) | |
308 | 429 | then throw("Invalid addLocked params") | |
309 | 430 | else { | |
310 | 431 | let unstake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), usdnFromDecimals(_amount))]) | |
311 | 432 | if ((unstake == unstake)) | |
312 | 433 | then { | |
313 | 434 | let freeBorrowed = freeBalanceBorrowed() | |
314 | 435 | ((if (if (_repay) | |
315 | 436 | then (freeBorrowed > 0) | |
316 | 437 | else false) | |
317 | 438 | then updateFreeBorrowedBalance(-(minv(freeBorrowed, _amount))) | |
318 | 439 | else nil) ++ updateLockedBalance(_amount)) | |
319 | 440 | } | |
320 | 441 | else throw("Strict value is not equal to itself.") | |
321 | 442 | } | |
322 | 443 | } | |
323 | 444 | ||
324 | 445 | ||
325 | 446 | ||
326 | 447 | @Callable(i) | |
327 | 448 | func addLockedV (_amountUsdn) = { | |
328 | 449 | let _amount = usdnToDecimals(_amountUsdn) | |
329 | 450 | if (if (!(initialized())) | |
330 | 451 | then true | |
331 | 452 | else !(if ((i.caller == collateralAddress())) | |
332 | 453 | then true | |
333 | 454 | else (i.caller == adminAddress()))) | |
334 | 455 | then throw("Invalid addLockedV params") | |
335 | 456 | else (updateLockedBalance(_amount) ++ updateVLockedBalance(_amount)) | |
336 | 457 | } | |
337 | 458 | ||
338 | 459 | ||
339 | 460 | ||
340 | 461 | @Callable(i) | |
341 | 462 | func exchangeFreeAndLocked (_amount) = if (if (!(initialized())) | |
342 | 463 | then true | |
343 | 464 | else !(if (isWhitelist(toString(i.caller))) | |
344 | 465 | then true | |
345 | 466 | else (i.caller == adminAddress()))) | |
346 | 467 | then throw("Invalid exchangeFreeAndLocked params") | |
347 | 468 | else { | |
348 | 469 | let amountOfQuoteAsset = usdnToDecimals(_amount) | |
349 | 470 | let borrowedBalance = freeBalanceBorrowed() | |
350 | - | let $ | |
471 | + | let $t01698217469 = if (if ((amountOfQuoteAsset > 0)) | |
351 | 472 | then (borrowedBalance > 0) | |
352 | 473 | else false) | |
353 | 474 | then $Tuple2(-(amountOfQuoteAsset), -(minv(amountOfQuoteAsset, borrowedBalance))) | |
354 | 475 | else $Tuple2(-(amountOfQuoteAsset), 0) | |
355 | - | let freeUpdate = $ | |
356 | - | let freeBorrowedUpdate = $ | |
476 | + | let freeUpdate = $t01698217469._1 | |
477 | + | let freeBorrowedUpdate = $t01698217469._2 | |
357 | 478 | let newRate = computeNewRate(freeUpdate) | |
358 | 479 | (((updateLockedBalance(amountOfQuoteAsset) ++ updateFreeBalance(freeUpdate)) ++ updateFreeBorrowedBalance(freeBorrowedUpdate)) ++ updateRate(newRate)) | |
359 | 480 | } | |
360 | 481 | ||
361 | 482 | ||
362 | 483 | ||
363 | 484 | @Callable(i) | |
364 | 485 | func withdrawLocked (_amount) = if (if (if (!(initialized())) | |
365 | 486 | then true | |
366 | 487 | else (0 >= _amount)) | |
367 | 488 | then true | |
368 | 489 | else !(isWhitelist(toString(i.caller)))) | |
369 | 490 | then throw("Invalid withdrawLocked params") | |
370 | 491 | else { | |
371 | 492 | let amountOfQuoteAsset = usdnToDecimals(_amount) | |
372 | 493 | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), usdnFromDecimals(amountOfQuoteAsset)], nil) | |
373 | 494 | if ((unstake == unstake)) | |
374 | 495 | then { | |
375 | 496 | let lockBalanceNow = lockedBalance() | |
376 | - | let $ | |
497 | + | let $t01825318446 = if ((amountOfQuoteAsset > lockBalanceNow)) | |
377 | 498 | then $Tuple2(lockBalanceNow, (amountOfQuoteAsset - lockBalanceNow)) | |
378 | 499 | else $Tuple2(amountOfQuoteAsset, 0) | |
379 | - | let fromLocked = $ | |
380 | - | let fromFree = $ | |
500 | + | let fromLocked = $t01825318446._1 | |
501 | + | let fromFree = $t01825318446._2 | |
381 | 502 | let vLockBalanceNow = vLockedBalance() | |
382 | 503 | let realLockBalanceNow = (lockBalanceNow - vLockBalanceNow) | |
383 | - | let $ | |
504 | + | let $t01856418752 = if ((fromLocked > realLockBalanceNow)) | |
384 | 505 | then $Tuple2(realLockBalanceNow, (fromLocked - realLockBalanceNow)) | |
385 | 506 | else $Tuple2(fromLocked, 0) | |
386 | - | let fromRealLocked = $ | |
387 | - | let fromVLocked = $ | |
507 | + | let fromRealLocked = $t01856418752._1 | |
508 | + | let fromVLocked = $t01856418752._2 | |
388 | 509 | ((((if ((fromVLocked > 0)) | |
389 | 510 | then updateFreeBorrowedBalance(fromVLocked) | |
390 | 511 | else nil) ++ (if ((fromFree > 0)) | |
391 | 512 | then { | |
392 | 513 | let newRate = computeNewRate(-(fromFree)) | |
393 | 514 | (updateFreeBalance(-(fromFree)) ++ updateRate(newRate)) | |
394 | 515 | } | |
395 | 516 | else nil)) ++ updateLockedBalance(-(fromLocked))) ++ [ScriptTransfer(i.caller, usdnFromDecimals(amountOfQuoteAsset), quoteAsset())]) | |
396 | 517 | } | |
397 | 518 | else throw("Strict value is not equal to itself.") | |
398 | 519 | } | |
399 | 520 | ||
400 | 521 | ||
401 | 522 | ||
402 | 523 | @Callable(i) | |
403 | 524 | func withdrawLockedV (_amountUsdn) = if (if (if (!(initialized())) | |
404 | 525 | then true | |
405 | 526 | else (0 >= _amountUsdn)) | |
406 | 527 | then true | |
407 | 528 | else !((i.caller == collateralAddress()))) | |
408 | 529 | then throw("Invalid withdrawLockedV params") | |
409 | 530 | else { | |
410 | 531 | let amountOfQuoteAsset = usdnToDecimals(_amountUsdn) | |
411 | 532 | let lockBalanceNow = lockedBalance() | |
412 | - | let $ | |
533 | + | let $t01960919802 = if ((amountOfQuoteAsset > lockBalanceNow)) | |
413 | 534 | then $Tuple2(lockBalanceNow, (amountOfQuoteAsset - lockBalanceNow)) | |
414 | 535 | else $Tuple2(amountOfQuoteAsset, 0) | |
415 | - | let fromLocked = $ | |
416 | - | let fromFree = $ | |
536 | + | let fromLocked = $t01960919802._1 | |
537 | + | let fromFree = $t01960919802._2 | |
417 | 538 | (((if ((fromFree > 0)) | |
418 | 539 | then { | |
419 | 540 | let newRate = computeNewRate(-(fromFree)) | |
420 | 541 | (updateFreeBalance(-(fromFree)) ++ updateRate(newRate)) | |
421 | 542 | } | |
422 | 543 | else nil) ++ updateLockedBalance(-(fromLocked))) ++ updateVLockedBalance(-(amountOfQuoteAsset))) | |
423 | 544 | } | |
424 | 545 | ||
425 | 546 | ||
426 | 547 | ||
427 | 548 | @Callable(i) | |
549 | + | func addRewards () = if (if ((i.payments[0].assetId != governanceAsset())) | |
550 | + | then true | |
551 | + | else !(initialized())) | |
552 | + | then throw("Invalid addRewards params") | |
553 | + | else { | |
554 | + | let _reward = i.payments[0].amount | |
555 | + | let newRewardPerTokenStored = updateReward(NO_ADDRESS, NO_STAKER)._1 | |
556 | + | let timestamp = currentTimestampSec() | |
557 | + | let newRewardRate = if ((timestamp > periodFinish())) | |
558 | + | then (_reward / DURATION) | |
559 | + | else { | |
560 | + | let remainingTime = (periodFinish() - timestamp) | |
561 | + | let leftover = (rewardRate() * remainingTime) | |
562 | + | ((_reward + leftover) / DURATION) | |
563 | + | } | |
564 | + | (((updateRewardRate(newRewardRate) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateRewardBalance(_reward)) ++ updateTime(timestamp, (timestamp + DURATION))) | |
565 | + | } | |
566 | + | ||
567 | + | ||
568 | + | ||
569 | + | @Callable(i) | |
428 | 570 | func view_reward (_staker) = { | |
429 | 571 | let balance = balanceOf(_staker) | |
430 | 572 | let depositedAmount = muld(averageRate(_staker), balance) | |
431 | 573 | let currentAmount = muld(rate(), balance) | |
432 | - | let | |
433 | - | throw(toString( | |
574 | + | let earnedQuote = (currentAmount - depositedAmount) | |
575 | + | throw(toString(earnedQuote)) | |
434 | 576 | } | |
435 | 577 | ||
436 | 578 | ||
437 | 579 | ||
438 | 580 | @Callable(i) | |
439 | 581 | func view_withdrawLimit (_staker) = { | |
440 | 582 | let withdrawLimitLeft = getWithdrawLimitLeft(_staker)._2 | |
441 | 583 | let limitInUsdn = usdnFromDecimals(muld(withdrawLimitLeft, rate())) | |
442 | 584 | throw(toString(limitInUsdn)) | |
443 | 585 | } | |
444 | 586 | ||
445 | 587 | ||
446 | 588 | @Verifier(tx) | |
447 | 589 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], adminPublicKey()) | |
448 | 590 |
github/deemru/w8io/169f3d6 99.66 ms ◑