Liquidity Staking (Farming)
Contract Interface
1. Notations & Structs
1.1. Payment
EnterFarmResultType
= EsdtTokenPayment
FARM token: a Meta-ESDT token representing the farming position.
1.2. FarmTokenAttributes
Get attributes of Farm MetaESDT token.
1.3. InteractFarmEvent
2. Write functions
2.1. enterFarm
Start farming.
Attached tokens:
LP tokens from Ashswapâs pools
old FARM tokens: if you attach multiple FARM tokens, they will be automatically merged with the new FARM token (like mergeFarmTokens).
Return: ManagedVec<EsdtTokenPayment>
A new Farm token
Reward tokens from
old FARM tokens
above.
2.2. exitFarm
Claim reward + withdraw LP token. You can only exit one farm using one FARM token per transaction.
Attached token: FARM token received from enterFarm
function.
Return: ManagedVec<EsdtTokenPayment>
1st
EsdtTokenPayment
: LP token2nd
EsdtTokenPayment
: Reward token
2.3. claimRewards
Claim rewards (ASH token) without withdrawal. You can only claim rewards from one FARM token in one transaction.
Return: ManagedVec<EsdtTokenPayment>
1st
EsdtTokenPayment
: LP token2nd
EsdtTokenPayment
: Reward token
3. Read functions
3.1. getState
Get the current state of a farm.
3.2. getRewardPerShare
Return:
BigUint
- the number of ASH tokens received each block per FARM token.
3.3. getFarmTokenSupply
Return:
BigUint
- the total supply of the FARM token.
3.4 calculateRewardsForGivenPosition
Get your current reward from a farm.
Params:
amount: BigUint
- your FARM tokenâs balanceattributes: FarmTokenAttributes
Note: The struct is decoded from FARM tokenâs attributes.
4. Events
4.1. Interact farm event
Event for enterFarm
, exitFarm
, claimRewards
Last updated