IAlgebraEternalFarming

IAlgebraEternalFarming

IAlgebraEternalFarming

Algebra Eternal Farming Interface

Allows farming nonfungible liquidity tokens in exchange for reward tokens without locking NFT for incentive time

Events

IncentiveDeactivated

event IncentiveDeactivated(bytes32 incentiveId)

Event emitted when a liquidity mining incentive has been stopped from the outside

NameTypeDescription
incentiveIdbytes32The stopped incentive

FarmEntered

event FarmEntered(uint256 tokenId, bytes32 incentiveId, uint128 liquidity)

Event emitted when a Algebra LP token has been farmd

NameTypeDescription
tokenIduint256The unique identifier of an Algebra LP token
incentiveIdbytes32The incentive in which the token is farming
liquidityuint128The amount of liquidity farmd

FarmEnded

event FarmEnded(uint256 tokenId, bytes32 incentiveId, address rewardAddress, address bonusRewardToken, address owner, uint256 reward, uint256 bonusReward)

Event emitted when a Algebra LP token has been exitFarmingd

NameTypeDescription
tokenIduint256The unique identifier of an Algebra LP token
incentiveIdbytes32The incentive in which the token is farming
rewardAddressaddressThe token being distributed as a reward
bonusRewardTokenaddressThe token being distributed as a bonus reward
owneraddressThe address where claimed rewards were sent to
rewarduint256The amount of reward tokens to be distributed
bonusRewarduint256The amount of bonus reward tokens to be distributed

IncentiveMaker

event IncentiveMaker(address incentiveMaker)

Emitted when the incentive maker is changed

NameTypeDescription
incentiveMakeraddressThe incentive maker after the address was changed

FarmingCenter

event FarmingCenter(address farmingCenter)

Emitted when the farming center is changed

NameTypeDescription
farmingCenteraddressThe farming center after the address was changed

RewardsAdded

event RewardsAdded(uint256 rewardAmount, uint256 bonusRewardAmount, bytes32 incentiveId)

Event emitted when rewards were added

NameTypeDescription
rewardAmountuint256The additional amount of main token
bonusRewardAmountuint256The additional amount of bonus token
incentiveIdbytes32The ID of the incentive for which rewards were added

RewardAmountsDecreased

event RewardAmountsDecreased(uint256 reward, uint256 bonusReward, bytes32 incentiveId)

NameTypeDescription
rewarduint256
bonusRewarduint256
incentiveIdbytes32

RewardClaimed

event RewardClaimed(address to, uint256 reward, address rewardAddress, address owner)

Event emitted when a reward token has been claimed

NameTypeDescription
toaddressThe address where claimed rewards were sent to
rewarduint256The amount of reward tokens claimed
rewardAddressaddressThe token reward address
owneraddressThe address where claimed rewards were sent to

RewardsRatesChanged

event RewardsRatesChanged(uint128 rewardRate, uint128 bonusRewardRate, bytes32 incentiveId)

Event emitted when reward rates were changed

NameTypeDescription
rewardRateuint128The new rate of main token distribution per sec
bonusRewardRateuint128The new rate of bonus token distribution per sec
incentiveIdbytes32The ID of the incentive for which rates were changed

RewardsCollected

event RewardsCollected(uint256 tokenId, bytes32 incentiveId, uint256 rewardAmount, uint256 bonusRewardAmount)

Event emitted when rewards were collected

NameTypeDescription
tokenIduint256The ID of the token for which rewards were collected
incentiveIdbytes32The ID of the incentive for which rewards were collected
rewardAmountuint256Collected amount of reward
bonusRewardAmountuint256Collected amount of bonus reward

EternalFarmingCreated

event EternalFarmingCreated(contract IERC20Minimal rewardToken, contract IERC20Minimal bonusRewardToken, contract IAlgebraPool pool, address virtualPool, uint256 nonce, uint256 reward, uint256 bonusReward, uint24 minimalAllowedPositionWidth)

Event emitted when a liquidity mining incentive has been created

NameTypeDescription
rewardTokencontract IERC20MinimalThe token being distributed as a reward
bonusRewardTokencontract IERC20MinimalThe token being distributed as a bonus reward
poolcontract IAlgebraPoolThe Algebra pool
virtualPooladdressThe virtual pool address
nonceuint256The nonce of new farming
rewarduint256The amount of reward tokens to be distributed
bonusRewarduint256The amount of bonus reward tokens to be distributed
minimalAllowedPositionWidthuint24The minimal allowed position width (tickUpper - tickLower)

Functions

nonfungiblePositionManager

function nonfungiblePositionManager() external view returns (contract INonfungiblePositionManager) view external

The nonfungible position manager with which this farming contract is compatible

Returns:

NameTypeDescription
[0]contract INonfungiblePositionManager

incentives

function incentives(bytes32 incentiveId) external view returns (uint128 totalReward, uint128 bonusReward, address virtualPoolAddress, uint24 minimalPositionWidth, bool deactivated) view external

Represents a farming incentive

NameTypeDescription
incentiveIdbytes32The ID of the incentive computed from its parameters

Returns:

NameTypeDescription
totalRewarduint128
bonusRewarduint128
virtualPoolAddressaddress
minimalPositionWidthuint24
deactivatedbool

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

deactivateIncentive

function deactivateIncentive(struct IncentiveKey key) external external

Detach incentive from the pool and deactivate it

NameTypeDescription
keystruct IncentiveKeyThe key of the incentive

addRewards

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

NameTypeDescription
keystruct IncentiveKey
rewardAmountuint128
bonusRewardAmountuint128

decreaseRewardsAmount

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

NameTypeDescription
keystruct IncentiveKey
rewardAmountuint128
bonusRewardAmountuint128

rewards

function rewards(address owner, contract IERC20Minimal rewardToken) external view returns (uint256 rewardsOwed) view external

Returns amounts of reward tokens owed to a given address according to the last time all farms were updated

NameTypeDescription
owneraddressThe owner for which the rewards owed are checked
rewardTokencontract IERC20MinimalThe token for which to check rewards

Returns:

NameTypeDescription
rewardsOweduint256The amount of the reward token claimable by the owner

setFarmingCenterAddress

function setFarmingCenterAddress(address _farmingCenter) external external

Updates farming center address

NameTypeDescription
_farmingCenteraddressThe new farming center contract address

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 returns (uint256 reward, uint256 bonusReward) external

Calculates the reward amount that will be received for the given farm

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

farms

function farms(uint256 tokenId, bytes32 incentiveId) external view returns (uint128 liquidity, int24 tickLower, int24 tickUpper, uint256 innerRewardGrowth0, uint256 innerRewardGrowth1) view external

Returns information about a farmd liquidity NFT

NameTypeDescription
tokenIduint256The ID of the farmd token
incentiveIdbytes32The ID of the incentive for which the token is farmd

Returns:

NameTypeDescription
liquidityuint128The amount of liquidity in the NFT as of the last time the rewards were computed, tickLower The lower tick of position, tickUpper The upper tick of position, innerRewardGrowth0 The last saved reward0 growth inside position, innerRewardGrowth1 The last saved reward1 growth inside position
tickLowerint24
tickUpperint24
innerRewardGrowth0uint256
innerRewardGrowth1uint256

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

setRates

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

NameTypeDescription
keystruct IncentiveKey
rewardRateuint128
bonusRewardRateuint128

collectRewards

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

NameTypeDescription
keystruct IncentiveKey
tokenIduint256
_owneraddress

Returns:

NameTypeDescription
rewarduint256
bonusRewarduint256

Errors

farmingAlreadyExists

error farmingAlreadyExists()

farmDoesNotExist

error farmDoesNotExist()

tokenAlreadyFarmed

error tokenAlreadyFarmed()

incentiveNotExist

error incentiveNotExist()

incentiveStopped

error incentiveStopped()

anotherFarmingIsActive

error anotherFarmingIsActive()

minimalPositionWidthTooWide

error minimalPositionWidthTooWide()

zeroRewardAmount

error zeroRewardAmount()

positionIsTooNarrow

error positionIsTooNarrow()

zeroLiquidity

error zeroLiquidity()

invalidPool

error invalidPool()

claimToZeroAddress

error claimToZeroAddress()