Free Farming Positions
The following section presents all the operations that a user can perform on a Free Farming Multi-AMM setup:
Open a Farming Position
The openPosition
function is used to open a new farming position. It can be called only if the setup is already active. This function requires, as input, the FarmingPositionRequest
struct.
At the moment of creation, a positionID
that represents the position is generated:
Each id is generated encoding the uniqueOwner
(owner's position) address
in a free setup. This means that each address can correspond to one and only one position within each setup, so there can be no multiple positions related to an address in a free setup.
Add Liquidity to an Existing Position
In a free setup position, more liquidity can be added to an already open position through theaddLiquidity
function. This function requires, as input:
positionId
-> Id of the corresponding farming position.FarmingPositionRequest
struct.
To withdraw the position reward, thewithdrawReward
function is used. It requires, as input:
positionId
-> id corresponding to the position to be transferred
Withdraw Reward
To withdraw the position reward, thewithdrawReward
function is used. It requires, as input:
positionId
-> id corresponding to the position to be transferred
It can be called at any time to withdraw the amount of reward thus far accumulated.
If there is a claimable reward amount, the function transfers the amount to the position owner's address
.
The withdrawn reward amount is considered and added to the rewardPaid
of the position that represent the total amount of reward already claimed from the position:
Please note that withdrawReward
can be either be called directly or it is internally called when the withdrawLiquidity
function is used in a Free setup.
Withdraw Liquidity
To withdraw a position's liquidity, withdrawLiquidity
is used. This function can be called at any time.
This function requires, as input:
positionId
-> id corresponding to the position to be transferredunwrapPair
-> boolean value representing if the required liquidity to be withdrawn is wanted in LP tokens (true
) or in pair tokens (false
).removedLiquidity
-> amount of liquidity to be removed. Therefore in a free setup it is possible to remove at any time any amount of liquidity from one's position (not necessarily all of the liquidity)
Please note: as mentioned above, the withdrawLiquidity
function also internally calls the withdrawReward
method on the position's rewards accumulated until that moment.
If the liquidity withdrawn is equal to the entire amount of liquidity of the position (and therefore the remaining liquidity is 0), the position is automatically deleted from the setup and from the contract memory:
When the last position is closed and the setup goes inactive (see the Activate / Disactivate farming setup section to learn more), the entire setup is deleted from the memory of the contract.
Last updated