AlgebraEternalFarming
Algebra eternal (v2-like) farming
Modifiers
onlyIncentiveMaker
modifier onlyIncentiveMaker()
internal
onlyAdministrator
modifier onlyAdministrator()
internal
onlyFarmingCenter
modifier onlyFarmingCenter()
internal
Variables
contract INonfungiblePositionManager nonfungiblePositionManager immutable
The nonfungible position manager with which this farming contract is compatible
contract IFarmingCenter farmingCenter
mapping(bytes32 => struct AlgebraEternalFarming.Incentive) incentives
Represents a farming incentive
Developer note: bytes32 refers to the return value of IncentiveId.compute
mapping(uint256 => mapping(bytes32 => struct AlgebraEternalFarming.Farm)) farms
Returns information about a farmd liquidity NFT
Developer note: farms[tokenId][incentiveHash] => Farm
uint256 numOfIncentives
bytes32 INCENTIVE_MAKER_ROLE constant
bytes32 FARMINGS_ADMINISTRATOR_ROLE constant
mapping(address => mapping(contract IERC20Minimal => uint256)) rewards
Returns amounts of reward tokens owed to a given address according to the last time all farms were updated
Developer note: rewards[owner][rewardToken] => uint256
Functions
constructor
constructor(contract IAlgebraPoolDeployer _deployer, contract INonfungiblePositionManager _nonfungiblePositionManager) public
public
Name | Type | Description |
---|---|---|
_deployer | contract IAlgebraPoolDeployer | pool deployer contract address |
_nonfungiblePositionManager | contract INonfungiblePositionManager | the NFT position manager contract address |
isIncentiveActiveInPool
function isIncentiveActiveInPool(bytes32 incentiveId, contract IAlgebraPool pool) external view returns (bool res)
view external
Check if incentive is active in Algebra pool Developer note: Does not check that the pool is indeed an Algebra pool
Name | Type | Description |
---|---|---|
incentiveId | bytes32 | The ID of the incentive computed from its parameters |
pool | contract IAlgebraPool | Corresponding Algebra pool |
Returns:
Name | Type | Description |
---|---|---|
res | bool | True if incentive is active in Algebra pool |
createEternalFarming
function createEternalFarming(struct IncentiveKey key, struct IAlgebraEternalFarming.IncentiveParams params) external returns (address virtualPool)
external
Creates a new liquidity mining incentive program
Name | Type | Description |
---|---|---|
key | struct IncentiveKey | Details of the incentive to create |
params | struct IAlgebraEternalFarming.IncentiveParams | Params of incentive |
Returns:
Name | Type | Description |
---|---|---|
virtualPool | address | The virtual pool |
deactivateIncentive
function deactivateIncentive(struct IncentiveKey key) external
external
Detach incentive from the pool and deactivate it
Name | Type | Description |
---|---|---|
key | struct IncentiveKey | The key of the incentive |
decreaseRewardsAmount
function decreaseRewardsAmount(struct IncentiveKey key, uint128 rewardAmount, uint128 bonusRewardAmount) external
external
Name | Type | Description |
---|---|---|
key | struct IncentiveKey | |
rewardAmount | uint128 | |
bonusRewardAmount | uint128 |
setFarmingCenterAddress
function setFarmingCenterAddress(address _farmingCenter) external
external
Updates farming center address
Name | Type | Description |
---|---|---|
_farmingCenter | address | The new farming center contract address |
addRewards
function addRewards(struct IncentiveKey key, uint128 rewardAmount, uint128 bonusRewardAmount) external
external
Name | Type | Description |
---|---|---|
key | struct IncentiveKey | |
rewardAmount | uint128 | |
bonusRewardAmount | uint128 |
setRates
function setRates(struct IncentiveKey key, uint128 rewardRate, uint128 bonusRewardRate) external
external
Name | Type | Description |
---|---|---|
key | struct IncentiveKey | |
rewardRate | uint128 | |
bonusRewardRate | uint128 |
enterFarming
function enterFarming(struct IncentiveKey key, uint256 tokenId) external
external
enter farming for Algebra LP token
Name | Type | Description |
---|---|---|
key | struct IncentiveKey | The key of the incentive for which to enterFarming the NFT |
tokenId | uint256 | The ID of the token to exitFarming |
exitFarming
function exitFarming(struct IncentiveKey key, uint256 tokenId, address _owner) external
external
exitFarmings for Algebra LP token
Name | Type | Description |
---|---|---|
key | struct IncentiveKey | The key of the incentive for which to exitFarming the NFT |
tokenId | uint256 | The ID of the token to exitFarming |
_owner | address | Owner of the token |
claimReward
function claimReward(contract IERC20Minimal rewardToken, address to, uint256 amountRequested) external returns (uint256 reward)
external
Transfers `amountRequested` of accrued `rewardToken` rewards from the contract to the recipient `to`
Name | Type | Description |
---|---|---|
rewardToken | contract IERC20Minimal | The token being distributed as a reward |
to | address | The address where claimed rewards will be sent to |
amountRequested | uint256 | The amount of reward tokens to claim. Claims entire reward amount if set to 0. |
Returns:
Name | Type | Description |
---|---|---|
reward | uint256 | The amount of reward tokens claimed |
claimRewardFrom
function claimRewardFrom(contract IERC20Minimal rewardToken, address from, address to, uint256 amountRequested) external returns (uint256 reward)
external
Transfers `amountRequested` of accrued `rewardToken` rewards from the contract to the recipient `to` only for FarmingCenter
Name | Type | Description |
---|---|---|
rewardToken | contract IERC20Minimal | The token being distributed as a reward |
from | address | The address of position owner |
to | address | The address where claimed rewards will be sent to |
amountRequested | uint256 | The amount of reward tokens to claim. Claims entire reward amount if set to 0. |
Returns:
Name | Type | Description |
---|---|---|
reward | uint256 | The amount of reward tokens claimed |
getRewardInfo
function getRewardInfo(struct IncentiveKey key, uint256 tokenId) external view returns (uint256 reward, uint256 bonusReward)
view external
reward amounts can be outdated, actual amounts could be obtained via static call of `collectRewards` in FarmingCenter
Name | Type | Description |
---|---|---|
key | struct IncentiveKey | The key of the incentive |
tokenId | uint256 | The ID of the token |
Returns:
Name | Type | Description |
---|---|---|
reward | uint256 | The reward accrued to the NFT for the given incentive thus far |
bonusReward | uint256 | The bonus reward accrued to the NFT for the given incentive thus far |
collectRewards
function collectRewards(struct IncentiveKey key, uint256 tokenId, address _owner) external returns (uint256 reward, uint256 bonusReward)
external
reward amounts should be updated before calling this method
Name | Type | Description |
---|---|---|
key | struct IncentiveKey | |
tokenId | uint256 | |
_owner | address |
Returns:
Name | Type | Description |
---|---|---|
reward | uint256 | |
bonusReward | uint256 |