-
Notifications
You must be signed in to change notification settings - Fork 91
/
Copy pathStakingFacet.sol
140 lines (126 loc) · 4.98 KB
/
StakingFacet.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import {LibStaking} from "../libraries/LibStaking.sol";
import {Modifiers} from "../libraries/LibAppStorage.sol";
import {IStaking} from "../../dollar/interfaces/IStaking.sol";
/// @notice Staking facet
contract StakingFacet is Modifiers, IStaking {
/**
* @notice Removes Ubiquity Dollar unilaterally from the curve LP share sitting inside
* the staking contract and sends the Ubiquity Dollar received to the treasury. This will
* have the immediate effect of pushing the Ubiquity Dollar price HIGHER
* @notice It will remove one coin only from the curve LP share sitting in the staking contract
* @param amount Amount of LP token to be removed for Ubiquity Dollar
*/
function dollarPriceReset(uint256 amount) external onlyStakingManager {
LibStaking.dollarPriceReset(amount);
}
/**
* @notice Remove 3CRV unilaterally from the curve LP share sitting inside
* the staking contract and send the 3CRV received to the treasury. This will
* have the immediate effect of pushing the Ubiquity Dollar price LOWER.
* @notice It will remove one coin only from the curve LP share sitting in the staking contract
* @param amount Amount of LP token to be removed for 3CRV tokens
*/
function crvPriceReset(uint256 amount) external onlyStakingManager {
LibStaking.crvPriceReset(amount);
}
/**
* @notice Sets staking discount multiplier
* @param _stakingDiscountMultiplier New staking discount multiplier
*/
function setStakingDiscountMultiplier(
uint256 _stakingDiscountMultiplier
) external onlyStakingManager {
LibStaking.setStakingDiscountMultiplier(_stakingDiscountMultiplier);
}
/**
* @notice Returns staking discount multiplier
* @return Staking discount multiplier
*/
function stakingDiscountMultiplier() external view returns (uint256) {
return LibStaking.stakingDiscountMultiplier();
}
/**
* @notice Returns number of blocks in a week
* @return Number of blocks in a week
*/
function blockCountInAWeek() external view returns (uint256) {
return LibStaking.blockCountInAWeek();
}
/**
* @notice Sets number of blocks in a week
* @param _blockCountInAWeek Number of blocks in a week
*/
function setBlockCountInAWeek(
uint256 _blockCountInAWeek
) external onlyStakingManager {
LibStaking.setBlockCountInAWeek(_blockCountInAWeek);
}
/**
* @notice Deposits UbiquityDollar-3CRV LP tokens for a duration to receive staking shares
* @notice Weeks act as a multiplier for the amount of staking shares to be received
* @param _lpsAmount Amount of LP tokens to send
* @param _weeks Number of weeks during which LP tokens will be held
* @return _id Staking share id
*/
function deposit(
uint256 _lpsAmount,
uint256 _weeks
) external whenNotPaused returns (uint256 _id) {
return LibStaking.deposit(_lpsAmount, _weeks);
}
/**
* @notice Adds an amount of UbiquityDollar-3CRV LP tokens
* @notice Staking shares are ERC1155 (aka NFT) because they have an expiration date
* @param _amount Amount of LP token to deposit
* @param _id Staking share id
* @param _weeks Number of weeks during which LP tokens will be held
*/
function addLiquidity(
uint256 _amount,
uint256 _id,
uint256 _weeks
) external whenNotPaused {
LibStaking.addLiquidity(_amount, _id, _weeks);
}
/**
* @notice Removes an amount of UbiquityDollar-3CRV LP tokens
* @notice Staking shares are ERC1155 (aka NFT) because they have an expiration date
* @param _amount Amount of LP token deposited when `_id` was created to be withdrawn
* @param _id Staking share id
*/
function removeLiquidity(
uint256 _amount,
uint256 _id
) external whenNotPaused {
LibStaking.removeLiquidity(_amount, _id);
}
/**
* @notice View function to see pending LP rewards on frontend
* @param _id Staking share id
* @return Amount of LP rewards
*/
function pendingLpRewards(uint256 _id) external view returns (uint256) {
return LibStaking.pendingLpRewards(_id);
}
/**
* @notice Returns the amount of LP token rewards an amount of shares entitled
* @param amount Amount of staking shares
* @param lpRewardDebt Amount of LP rewards that have already been distributed
* @return pendingLpReward Amount of pending LP rewards
*/
function lpRewardForShares(
uint256 amount,
uint256 lpRewardDebt
) external view returns (uint256 pendingLpReward) {
return LibStaking.lpRewardForShares(amount, lpRewardDebt);
}
/**
* @notice Returns current share price
* @return priceShare Share price
*/
function currentShareValue() external view returns (uint256 priceShare) {
priceShare = LibStaking.currentShareValue();
}
}