API reference v2.0
Introduction
core
periphery
FarmingCenter

FarmingCenter

FarmingCenter

Algebra main farming contract

Developer note: Manages farmings and performs entry, exit and other actions.

Modifiers

isOwner

modifier isOwner(uint256 tokenId) internal

NameTypeDescription
tokenIduint256

Variables

contract IAlgebraEternalFarming eternalFarming immutable

The eternal farming contract

contract INonfungiblePositionManager nonfungiblePositionManager immutable

The nonfungible position manager with which this farming contract is compatible

address algebraPoolDeployer immutable

The Algebra poolDeployer contract

mapping(address => address) virtualPoolAddresses

Developer note: saves addresses of virtual pools for pool

mapping(uint256 => bytes32) deposits

Developer note: deposits[tokenId] => incentiveId

mapping(bytes32 => struct IncentiveKey) incentiveKeys

Functions

constructor

constructor(contract IAlgebraEternalFarming _eternalFarming, contract INonfungiblePositionManager _nonfungiblePositionManager) public public

NameTypeDescription
_eternalFarmingcontract IAlgebraEternalFarming
_nonfungiblePositionManagercontract INonfungiblePositionManager

enterFarming

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

Enters in incentive (time-limited or eternal farming) with NFT-position token Developer note: token must be deposited in FarmingCenter

NameTypeDescription
keystruct IncentiveKeyThe incentive event key
tokenIduint256The id of position NFT

exitFarming

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

Exits from incentive (time-limited or eternal farming) with NFT-position token

NameTypeDescription
keystruct IncentiveKeyThe incentive event key
tokenIduint256The id of position NFT

applyLiquidityDelta

function applyLiquidityDelta(uint256 tokenId, int256 liquidityDelta) external external

Report a change of liquidity in position

NameTypeDescription
tokenIduint256The ID of the token for which liquidity is being added
liquidityDeltaint256The amount of added liquidity

increaseLiquidity

function increaseLiquidity(uint256 tokenId, uint256 liquidityDelta) external external

NameTypeDescription
tokenIduint256
liquidityDeltauint256

decreaseLiquidity

function decreaseLiquidity(uint256 tokenId, uint256 liquidityDelta) external returns (bool success) external

NameTypeDescription
tokenIduint256
liquidityDeltauint256

Returns:

NameTypeDescription
successbool

burnPosition

function burnPosition(uint256 tokenId) external returns (bool success) external

Report a burn of position token

NameTypeDescription
tokenIduint256The ID of the token which is being burned

Returns:

NameTypeDescription
successbool

collectRewards

function collectRewards(struct IncentiveKey key, uint256 tokenId) external returns (uint256 reward, uint256 bonusReward) external

Used to collect reward from eternal farming. Then reward can be claimed.

NameTypeDescription
keystruct IncentiveKeyThe incentive event key
tokenIduint256The id of position NFT

Returns:

NameTypeDescription
rewarduint256The amount of collected reward
bonusRewarduint256The amount of collected bonus reward

claimReward

function claimReward(contract IERC20Minimal rewardToken, address to, uint256 amountRequested) external returns (uint256 reward) external

Used to claim and send rewards from farming(s) Developer note: can be used via static call to get current rewards for user

NameTypeDescription
rewardTokencontract IERC20MinimalThe token that is a reward
toaddressThe address to be rewarded
amountRequesteduint256Amount to claim in eternal farming

Returns:

NameTypeDescription
rewarduint256The summary amount of claimed rewards

connectVirtualPool

function connectVirtualPool(contract IAlgebraPool pool, address newVirtualPool) external external

Updates activeIncentive in AlgebraPool Developer note: only farming can do it

NameTypeDescription
poolcontract IAlgebraPoolThe AlgebraPool for which farming was created
newVirtualPooladdress