Liquidity Farming

FarmPool

FarmPool allows to deposit liquidity points (LP) and allocates reward tokens each second among all LP stakeholder. Reward allocation is proportional to user's share of LP. User can deposit LP or exit (withdraw + claim reward) at any time. FarmPool is active until all reward is allocated and can be restarted for the next farming cycle


lpToken

address lpToken

address of LP token


rewardToken

address rewardToken

address of reward token


lpStakeBalance

uint256 lpStakeBalance

returns total amount of staked LP


lpFeeBalance

uint256 lpFeeBalance

returns balance of accumulated LP fee


rewardBalance

uint256 rewardBalance

returns total amount of reward token


poolReward

uint256 poolReward

returns pool reward for current farming cycle


farmPeriod

uint256 farmPeriod

returns period (in seconds) of current farming cycle


farmStartTime

uint256 farmStartTime

returns start time of current farming cycle


farmEndTime

uint256 farmEndTime

returns end time of current farming cycle


lastAllocationTime

uint256 lastAllocationTime

returns time of last reward allocation


activeUsers

uint256 activeUsers

returns number of active users with LP shares


rewardPerSec

uint256 rewardPerSec

returns pool reward allocated each second


accumPerLP

uint256 accumPerLP

returns accummulated reward per LP


userInfo

mapping(address => struct FarmPool.PoolStake) userInfo

mapping to store user's info - amount of LP staked and claimed reward


constructor

constructor(address _lpToken, address _rewardToken, uint256 _rewardPerSec) public

farming pool constructor

Parameters

Name
Type
Description

_lpToken

address

address of LP token

_rewardToken

address

address of reward token

_rewardPerSec

uint256


start

function start(uint256 _warmUpPeriod, address _from, uint256 _reward) external

admin function to start farming cycle

Parameters

Name
Type
Description

_warmUpPeriod

uint256

war up period (delay) before starting farm pool

_from

address

address of the wallet to transfer a reward from

_reward

uint256

farming reward in tokens


depositLP

function depositLP(uint256 _lpAmount) external

external function to deposit LP tokens

Parameters

Name
Type
Description

_lpAmount

uint256

amount of LP tokens to deposit


withdrawLP

function withdrawLP(uint256 _lpAmount) external

external function to withdraw LP tokens

1% fee is applied

Parameters

Name
Type
Description

_lpAmount

uint256

amount of LP tokens to withdraw


claimReward

function claimReward() external

external function to claim reward (transfer to user's wallet)


transferLP

function transferLP(address _recipient) external

admin function to transfer LP tokens to recipient's wallet

it is possible to transfer LP tokens only when farming is inactive

Parameters

Name
Type
Description

_recipient

address

address of recipient's wallet


getReward

function getReward() external view returns (uint256)

extrnal view function to get user's total reward


isStarted

function isStarted() public view returns (bool)

view function to check if farming is started

pool in "started" state till all reward is allocated


isActive

function isActive() public view returns (bool)

view function to check if farming is active

pool is in "active" state when it is "started" and passed warm-up period

Last updated