API reference v2.0
Introduction
core
periphery
AlgebraEternalFarming

AlgebraEternalFarming

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

NameTypeDescription
_deployercontract IAlgebraPoolDeployerpool deployer contract address
_nonfungiblePositionManagercontract INonfungiblePositionManagerthe 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

NameTypeDescription
incentiveIdbytes32The ID of the incentive computed from its parameters
poolcontract IAlgebraPoolCorresponding Algebra pool

Returns:

NameTypeDescription
resboolTrue 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

NameTypeDescription
keystruct IncentiveKeyDetails of the incentive to create
paramsstruct IAlgebraEternalFarming.IncentiveParamsParams of incentive

Returns:

NameTypeDescription
virtualPooladdressThe virtual pool

deactivateIncentive

function deactivateIncentive(struct IncentiveKey key) external external

Detach incentive from the pool and deactivate it

NameTypeDescription
keystruct IncentiveKeyThe key of the incentive

decreaseRewardsAmount

function decreaseRewardsAmount(struct IncentiveKey key, uint128 rewardAmount, uint128 bonusRewardAmount) external external

NameTypeDescription
keystruct IncentiveKey
rewardAmountuint128
bonusRewardAmountuint128

setFarmingCenterAddress

function setFarmingCenterAddress(address _farmingCenter) external external

Updates farming center address

NameTypeDescription
_farmingCenteraddressThe new farming center contract address

addRewards

function addRewards(struct IncentiveKey key, uint128 rewardAmount, uint128 bonusRewardAmount) external external

NameTypeDescription
keystruct IncentiveKey
rewardAmountuint128
bonusRewardAmountuint128

setRates

function setRates(struct IncentiveKey key, uint128 rewardRate, uint128 bonusRewardRate) external external

NameTypeDescription
keystruct IncentiveKey
rewardRateuint128
bonusRewardRateuint128

enterFarming

function enterFarming(struct IncentiveKey key, uint256 tokenId) external external

enter farming for Algebra LP token

NameTypeDescription
keystruct IncentiveKeyThe key of the incentive for which to enterFarming the NFT
tokenIduint256The ID of the token to exitFarming

exitFarming

function exitFarming(struct IncentiveKey key, uint256 tokenId, address _owner) external external

exitFarmings for Algebra LP token

NameTypeDescription
keystruct IncentiveKeyThe key of the incentive for which to exitFarming the NFT
tokenIduint256The ID of the token to exitFarming
_owneraddressOwner 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`

NameTypeDescription
rewardTokencontract IERC20MinimalThe token being distributed as a reward
toaddressThe address where claimed rewards will be sent to
amountRequesteduint256The amount of reward tokens to claim. Claims entire reward amount if set to 0.

Returns:

NameTypeDescription
rewarduint256The 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

NameTypeDescription
rewardTokencontract IERC20MinimalThe token being distributed as a reward
fromaddressThe address of position owner
toaddressThe address where claimed rewards will be sent to
amountRequesteduint256The amount of reward tokens to claim. Claims entire reward amount if set to 0.

Returns:

NameTypeDescription
rewarduint256The 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

NameTypeDescription
keystruct IncentiveKeyThe key of the incentive
tokenIduint256The ID of the token

Returns:

NameTypeDescription
rewarduint256The reward accrued to the NFT for the given incentive thus far
bonusRewarduint256The 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

NameTypeDescription
keystruct IncentiveKey
tokenIduint256
_owneraddress

Returns:

NameTypeDescription
rewarduint256
bonusRewarduint256