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