Staking
Allows staking Uniswap trading pair liquidity pool tokens in exchange for FXS rewards.
Based on Synthetix's staking contract:

Description

Frax users are able to stake in select Uniswap liquidity pool tokens in exchange for FXS rewards. Future pools and incentives can be added by governance.

Deployment

Liquidity Pool Tokens (LP)
Uniswap FRAX/WETH LP: 0xFD0A40Bc83C5faE4203DEc7e5929B446b07d1C76
Uniswap FRAX/USDC LP: 0x97C4adc5d28A86f9470C70DD91Dc6CC2f20d2d4D
Uniswap FRAX/FXS LP: 0xE1573B9D29e2183B1AF0e743Dc2754979A40D237
Uniswap FXS/WETH LP: 0xecBa967D84fCF0405F6b32Bc45F4d36BfDBB2E81
Staking Contracts
Uniswap FRAX/WETH staking: 0xD875628B942f8970De3CcEaf6417005F68540d4f
Uniswap FRAX/USDC staking: 0xa29367a3f057F3191b62bd4055845a33411892b6
Uniswap FRAX/FXS staking: 0xda2c338350a0E59Ce71CDCED9679A3A590Dd9BEC
Uniswap FXS/WETH staking (deprecated): 0xDc65f3514725206Dd83A8843AAE2aC3D99771C88

State Variables

1
FRAXStablecoin private FRAX
Copied!
Instance of the FRAX contract.
1
ERC20 public rewardsToken
Copied!
Instance for the reward token.
1
ERC20 public stakingToken
Copied!
Instance for the staking token.
1
uint256 public periodFinish
Copied!
Block when the staking period will finish.
1
uint256 public rewardRate
Copied!
Maximum reward per second.
1
uint256 public rewardsDuration
Copied!
Reward period, in seconds.
1
uint256 public lastUpdateTime
Copied!
Last timestamp where the contract was updated / state change.
1
uint256 public rewardPerTokenStored
Copied!
Actual reward per token in the current period.
1
uint256 public locked_stake_max_multiplier
Copied!
Maximum boost / weight multiplier for locked stakes.
1
uint256 public locked_stake_time_for_max_multiplier
Copied!
The time, in seconds, to reach locked_stake_max_multiplier .
1
uint256 public locked_stake_min_time
Copied!
Minimum staking time for a locked staked, in seconds.
1
string public locked_stake_min_time_str
Copied!
String version is locked_stake_min_time_str .
1
uint256 public cr_boost_max_multiplier
Copied!
Maximum boost / weight multiplier from the collateral ratio (CR). This is applied to both locked and unlocked stakes.
1
mapping(address => uint256) public userRewardPerTokenPaid
Copied!
Keeps track of when an address last collected a reward. If they collect it some time later, they will get the correct amount because rewardPerTokenStored is constantly varying.
1
mapping(address => uint256) public rewards
Copied!
Current rewards balance for a given address.
1
uint256 private _staking_token_supply
Copied!
Total amount of pool tokens staked .
1
uint256 private _staking_token_boosted_supply
Copied!
_staking_token_supply with the time and CR boosts accounted for. This is not an actual amount of pool tokens, but rather a 'weighed denominator'.
1
mapping(address => uint256) private _balances
Copied!
Balance of pool tokens staked for a given address.
1
mapping(address => uint256) private _boosted_balances
Copied!
_balances , but with the time and CR boosts accounted for, like _staking_token_boosted_supply.
1
mapping(address => LockedStake[]) private lockedStakes
Copied!
Gives a list of locked stake lots for a given address.
1
struct LockedStake {
2
bytes32 kek_id;
3
uint256 start_timestamp;
4
uint256 amount;
5
uint256 ending_timestamp;
6
uint256 multiplier; // 6 decimals of precision. 1x = 1000000
7
}
Copied!
A locked stake 'lot'.

View Functions

totalSupply
1
totalSupply() external override view returns (uint256)
Copied!
Get the total number of staked liquidity pool tokens.
stakingMultiplier
1
stakingMultiplier(uint256 secs) public view returns (uint256)
Copied!
Get the time-based staking multiplier, given the secs length of the stake.
crBoostMultiplier
1
crBoostMultiplier() public view returns (uint256)
Copied!
Get the collateral ratio (CR) - based staking multiplier.
stakingTokenSupply
1
stakingTokenSupply() external view returns (uint256)
Copied!
same as totalSupply().
balanceOf
1
balanceOf(address account) external override view returns (uint256)
Copied!
Get the amount of staked liquidity pool tokens for a given account.
boostedBalanceOf
1
boostedBalanceOf(address account) external view returns (uint256)
Copied!
Get the boosted amount of staked liquidity pool tokens for a given account. Boosted accounts for the CR and time-based multipliers.
lockedBalanceOf
1
lockedBalanceOf(address account) public view returns (uint256)
Copied!
Get the amount of locked staked liquidity pool tokens for a given account .
unlockedBalanceOf
1
unlockedBalanceOf(address account) external view returns (uint256)
Copied!
Get the amount of unlocked / free staked liquidity pool tokens for a given account .
lockedStakesOf
1
lockedStakesOf(address account) external view returns (LockedStake[] memory)
Copied!
Return an array of all the locked stake 'lots' for
stakingDecimals
1
stakingDecimals() external view returns (uint256)
Copied!
Returns the decimals() for stakingToken .
rewardsFor
1
rewardsFor(address account) external view returns (uint256)
Copied!
Get the amount of FXS rewards for a given account .
lastTimeRewardApplicable
1
lastTimeRewardApplicable() public override view returns (uint256)
Copied!
Used internally to keep track of rewardPerTokenStored .
rewardPerToken
1
rewardPerToken() public override view returns (uint256)
Copied!
The current amount of FXS rewards for staking a liquidity pool token.
earned
1
earned(address account) public override view returns (uint256)
Copied!
Returns the amount of unclaimed FXS rewards for a given account .
getRewardForDuration
1
getRewardForDuration() external override view returns (uint256)
Copied!
Calculates the FXS reward for a given rewardsDuration period.

Mutative Functions

stake
1
stake(uint256 amount) external override nonReentrant notPaused updateReward(msg.sender)
Copied!
Stakes some Uniswap liquidity pool tokens. These tokens are freely withdrawable and are only boosted by the crBoostMultiplier().
stakeLocked
1
stakeLocked(uint256 amount, uint256 secs) external nonReentrant notPaused updateReward(msg.sender)
Copied!
Stakes some Uniswap liquidity pool tokens and also locks them for the specified secs . In return for having their tokens locked, the staker's base amount will be multiplied by a linear time-based multiplier, which ranges from 1 at secs = 0 to locked_stake_max_multiplier at locked_stake_time_for_max_multiplier. The staked value is also multiplied by the crBoostMultiplier() . This multiplied value is added to _boosted_balances and acts as a weighted amount when calculating the staker's share of a given period reward.
withdraw
1
withdraw(uint256 amount) public override nonReentrant updateReward(msg.sender)
Copied!
Withdraw unlocked Uniswap liquidity pool tokens.
withdrawLocked
1
withdrawLocked(bytes32 kek_id) public nonReentrant updateReward(msg.sender)
Copied!
Withdraw locked Uniswap liquidity pool tokens. Will fail if the staking time for the specific kek_id staking lot has not elapsed yet.
getReward
1
getReward() public override nonReentrant updateReward(msg.sender)
Copied!
Claim FXS rewards.
exit
1
exit() external override
Copied!
Withdraw all unlocked pool tokens and also collect rewards.
renewIfApplicable
1
renewIfApplicable() external
Copied!
Renew a reward period if the period's finish time has completed. Calls retroCatchUp() .
retroCatchUp
1
retroCatchUp() internal
Copied!
Renews the period and updates periodFinish , rewardPerTokenStored , and lastUpdateTime .

Restricted Functions

notifyRewardAmount
1
notifyRewardAmount(uint256 reward) external override onlyRewardsDistribution updateReward(address(0))
Copied!
This notifies people (via the event RewardAdded ) that the reward is being changed.
recoverERC20
1
recoverERC20(address tokenAddress, uint256 tokenAmount) external onlyOwner
Copied!
Added to support recovering LP Rewards from other systems to be distributed to holders.
setRewardsDuration
1
setRewardsDuration(uint256 _rewardsDuration) external onlyOwner
Copied!
Set the duration of the rewards period.
setLockedStakeMaxMultiplierUpdated
1
setLockedStakeMaxMultiplierUpdated(uint256 _locked_stake_max_multiplier) external onlyOwner
Copied!
Set the maximum multiplier for locked stakes.
setLockedStakeTimeForMaxMultiplier
1
setLockedStakeTimeForMaxMultiplier(uint256 _locked_stake_time_for_max_multiplier) external onlyOwner
Copied!
Set the time, in seconds, when the locked stake multiplier reaches locked_stake_max_multiplier .
setLockedStakeMinTime
1
setLockedStakeMinTime(uint256 _locked_stake_min_time) external onlyOwner
Copied!
Set the minimum time, in seconds, of a locked stake.
setMaxCRBoostMultiplier
1
setMaxCRBoostMultiplier(uint256 _max_boost_multiplier) external onlyOwner
Copied!
aaa
initializeDefault
1
initializeDefault() external onlyOwner
Copied!
Intended to only be called once in the lifetime of the contract. Initializes lastUpdateTime and periodFinish .

Modifiers

updateReward
1
updateReward(address account)
Copied!
Calls retroCatchUp() , if applicable, and otherwise syncs rewardPerTokenStored and lastUpdateTime . Also, syncs the rewards and userRewardPerTokenPaid for the provided account .
Last modified 11mo ago