Inherits: FarmStorage, OwnableUpgradeable, ReentrancyGuardUpgradeable, MulticallUpgradeable
Author: Sperax Foundation.
This contract contains the core logic for the Demeter farms.
Function to be called to withdraw deposit.
Parameters
Name | Type | Description |
---|---|---|
A function to be called by the depositor to claim rewards.
Parameters
Function to be called to initiate cooldown for a staked deposit.
_depositId is corresponding to the user's deposit.
Parameters
Add rewards to the farm.
Parameters
Update the cooldown period.
Parameters
Pause / UnPause the farm.
Parameters
A function to explicitly close the farm.
Recovers remaining non accrued rewards.
Recover erc20 tokens other than the reward tokens.
Parameters
Get the remaining reward balance out of the farm.
Function recovers minOf(_amount, rewardsLeft).
Parameters
Function to update reward params for a fund.
Parameters
Transfer the tokenManagerRole to other user.
Only the existing tokenManager for a reward can call this function.
Parameters
Function to compute the total accrued rewards for a deposit for each subscription.
Parameters
Returns
Get the reward fund details.
Returns
Get the reward details for specified reward token.
Parameters
Returns
Get deposit info for a deposit id.
Parameters
Returns
Get number of subscriptions for an account.
Parameters
Returns
Get subscription stats for a deposit.
Parameters
Returns
Get reward rates for a rewardToken.
Parameters
Returns
Get farm reward fund info.
Parameters
Returns
Function to get the reward tokens added in the farm.
Returns
Function to be called by Demeter Rewarder to get tokens and amounts associated with the farm's liquidity.
This function should be overridden to add the respective logic.
Returns
Function to update the FarmRewardData for all funds.
Claim rewards and send it to another account.
Only the depositor can call this function.
Parameters
Update the farm start time.
Can be updated only before the farm start. New start time should be in future.
Parameters
Returns if farm is open. Farm is open if it is not closed.
This function can be overridden to add any new/additional logic.
Returns
Returns if farm is active. Farm is active if it is not paused and not closed.
This function can be overridden to add any new/additional logic.
Returns
Get the reward balance for specified reward token.
This function calculates the available reward balance by considering the accrued rewards and the token supply.
Parameters
Returns
Common logic for deposit in the demeter farm.
Parameters
Returns
Common logic for initiating cooldown.
Parameters
Common logic for withdraw.
Parameters
Claim rewards for the user.
NOTE: any function calling this private function should be marked as non-reentrant.
Parameters
Claim rewards for the user and send it to another account.
NOTE: any function calling this private function should be marked as non-reentrant.
Parameters
Get the remaining reward balance out of the farm.
Function recovers minOf(_amount, rewardsLeft).
In case of partial withdraw of funds, the reward rate has to be set manually again.
Parameters
Function to update reward params for a fund.
Parameters
Function to setup the reward funds and initialize the farm global params during construction.
Parameters
Adds new reward token to the farm.
Parameters
Update the last reward accrual time.
Computes the accrued reward for a given fund id and time interval.
_alreadyAccRewardBal
is useful when this function called from computeRewards
function. As computeReward
is a view function and it doesn't update the accRewardBal
in the rewardData
.
Parameters
Returns
Validate the deposit for account.
Parameters
A function to validate deposit ts to prevent flash loan vulnerabilities
Reverts when deposit made in the same transaction.
Parameters
Validate if farm is open. Revert otherwise.
This function can be overridden to add any new/additional logic.
Validate if farm is active. Revert otherwise. Farm is active if it is not paused and not closed.
This function can be overridden to add any new/additional logic.
Validate the caller is the token Manager. Revert otherwise.
Parameters
Validate the reward token is valid.
Parameters
Get the time elapsed since the last reward accrual.
Returns
An internal function to validate cooldown period.
Parameters
Validate address.
Parameters
Add subscription to the reward fund for a deposit.
Parameters
Unsubscribe a reward fund from a deposit.
The rewards claimed from the reward fund is persisted in the event.
Parameters
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
_depositId
uint256
The id of the deposit.
_depositId
uint256
The id of the deposit.
_depositId
uint256
The id of the deposit to be locked.
_rwdToken
address
The reward token's address.
_amount
uint256
The amount of reward tokens to add.
_newCooldownPeriod
uint256
The new cooldown period (in days). E.g: 7 means 7 days.
_isPaused
bool
Desired state of the farm (true to pause the farm).
_token
address
Address of token to be recovered.
_rwdToken
address
The reward token's address.
_amount
uint256
The amount of the reward tokens to be withdrawn.
_rwdToken
address
The reward token's address.
_newRewardRates
uint128[]
The new reward rate for the fund (includes the precision).
_rwdToken
address
The reward token's address.
_newTknManager
address
Address of the new token manager.
_account
address
The user's address.
_depositId
uint256
The id of the deposit.
rewards
uint256[][]
The total accrued rewards for the deposit for each subscription (uint256[][]).
<none>
RewardFund[]
The available reward funds' details for all the reward funds.
_rwdToken
address
The address of the reward token.
<none>
RewardData
The available reward details for the specified reward token.
_depositId
uint256
The id of the deposit.
<none>
Deposit
The deposit info (Deposit).
_depositId
uint256
The deposit id.
<none>
uint256
The number of subscriptions for the deposit.
_depositId
uint256
The deposit id.
_subscriptionId
uint256
The subscription's id.
<none>
Subscription
The subscription info (Subscription).
_rwdToken
address
The reward token's address.
<none>
uint256[]
The reward rates for the reward token (uint256[]).
_fundId
uint8
The fund's id.
<none>
RewardFund
The reward fund info (RewardFund).
<none>
address[]
The reward tokens added in the farm.
<none>
address[]
Tokens associated with the farm's pool.
<none>
uint256[]
Amounts associated with the farm's liquidity.
_account
address
To receive the rewards.
_depositId
uint256
The id of the deposit.
_newStartTime
uint256
The new farm start time.
<none>
bool
bool True if farm is open.
<none>
bool
bool True if farm is active.
_rwdToken
address
The address of the reward token.
<none>
uint256
The available reward balance for the specified reward token.
_account
address
Address of the depositor.
_lockup
bool
Lockup option for the deposit.
_liquidity
uint256
Liquidity amount to be added to the pool.
<none>
uint256
The deposit id.
_depositId
uint256
User's deposit Id.
_depositId
uint256
User's deposit id.
_depositId
uint256
The id of the deposit.
_depositId
uint256
The id of the deposit.
_receiver
address
The receiver of the rewards (Could be different from depositor)
_rwdToken
address
The reward token's address.
_amount
uint256
The amount of the reward token to be withdrawn.
_rwdToken
address
The reward token's address.
_newRewardRates
uint128[]
The new reward rate for the fund (includes the precision).
_farmId
string
ID of the farm. E.g: Demeter_Camelot_V2
.
_farmStartTime
uint256
- Farm start time.
_cooldownPeriod
uint256
- Cooldown period in days for locked deposits. E.g: 7 means 7 days.
_rwdTokenData
RewardTokenData[]
- Reward data for each reward token.
_token
address
Address of the reward token to be added.
_tknManager
address
Address of the reward token Manager.
_rwdId
uint8
Id of the reward token.
_fundId
uint8
Id of the reward fund.
_time
uint256
Time interval for the reward computation.
_alreadyAccRewardBal
uint256
Already accrued reward balance.
<none>
uint256
accRewards Accrued rewards for the given _rwdId
, _fundId
and _time
.
_account
address
Address of the caller to be checked against depositor.
_depositId
uint256
Id of the deposit.
_depositTs
uint256
depositTs of user's deposit. (It represents deposit ts or increaseDeposit ts)
_rwdToken
address
Address of reward token.
_rwdToken
address
Address of reward token.
<none>
uint256
time The time elapsed since the last reward accrual.
_cooldownPeriod
uint256
Period to be validated.
_addr
address
Address to be validated.
_fundId
uint8
The reward fund id.
_depositId
uint256
The unique ID of the deposit.
_liquidity
uint256
The liquidity of the deposit.
_fundId
uint8
The reward fund id.
_depositId
uint256
The deposit id corresponding to the user.