InfraredVault.sol
The purpose of InfraredVault.sol
is to create a simple and general API that can host all tokenized liquidity positions and reflect them on proof-of-liquidity. It is built in a familiar and robust APIs for staking, and streaming rewards on a per second basis. This Smart contract will be used for all staking, including LP tokens, and iBGT. It allows multi rewards to be accrued (1 stake token, many reward tokens).
Inherits:
ReentrancyGuard
, Pausable
, IMultiRewards
Fork of MultiRewards with hooks on stake/withdraw of LP tokens
State variables
stakingToken
rewardTokens
userRewardPerTokenPaid
rewards
rewardsVault
Functions
totalSupply
Returns the number of staked tokens.
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | uint256 The number of staked tokens. |
balanceOf
Returns the balance of staked tokens for the given account.
Parameters
Name | Type | Description |
---|---|---|
account | address | address The account to get the balance for. |
Returns
Name | Type | Description |
---|---|---|
_balance | uint256 | uint256 The balance of staked tokens. |
lastTimeRewardApplicable
Calculates the last time reward is applicable for a given rewards token.
This function returns the minimum between the current block timestamp and the period finish time of the rewards token.
Parameters
Name | Type | Description |
---|---|---|
_rewardsToken | address | address The address of the rewards token. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | uint256 value representing the last time reward is applicable. |
rewardPerToken
Calculates the reward per token for a given rewards token.
This function returns the stored reward per token if the total supply is 0. Otherwise, it calculates the reward per token by adding the stored reward per token to the product of the reward rate and the time difference between the last applicable time for rewards and the last update time, multiplied by 1e18 and divided by the total supply.
Parameters
Name | Type | Description |
---|---|---|
_rewardsToken | address | address The address of the rewards token. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | A uint256 value representing the reward per token. |
earned
Calculates the earned rewards for a given account and rewards token.
This function calculates the earned rewards by multiplying the account balance by the difference between the reward per token and the paid reward per token for the account, dividing by 1e18, and adding the rewards for the account.
Parameters
Name | Type | Description |
---|---|---|
account | address | address The address of the account. |
_rewardsToken | address | address The address of the rewards token. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | uint256 value representing the earned rewards. |
getRewardForDuration
Calculates the total reward for the duration of a given rewards token.
This function calculates the total reward by multiplying the reward rate by the rewards duration for the given rewards token.
Parameters
Name | Type | Description |
---|---|---|
_rewardsToken | address | address The address of the rewards token. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | uint256 value representing the total reward for the duration. |
stake
Stakes the given amount of tokens for the user (msg.sender).
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | uint256 The amount of tokens to stake. |
onStake
Hook called in the stake function after transfering staking token in
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | The amount of staking token transferred in to the contract |
withdraw
Withdraws the staked tokens for the user (msg.sender).
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | uint256 The amount of staked tokens to withdraw. |
onWithdraw
Hook called in withdraw function before transferring staking token out
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | The amount of staking token to be transferred out of the contract |
getRewardForUser
Claims the rewards for the given user.
Parameters
Name | Type | Description |
---|---|---|
_user | address | address The address of the user to claim the rewards for. |
onReward
Hook called in getRewardForUser function after updating rewards
getReward
Claims all pending rewards for msg sender.
Change from forked MultiRewards.sol to allow for claim of reward for any user to their address
exit
Withdraws the staked tokens and all rewards for the user.