Open a Position
The openPosition
function is used to open a new farming position. This function requires, as input, the FarmingPositionRequest
struct:
At the moment of creation, a positionID
that represents the position is generated:
Each generated id is encoded with the uniqueOwner
(owner position) address
. This means that each address can correspond to one and only one position within each setup; a single address cannot have multiple positions in a setup.
A user can also open a position for another address
. In this case, the uniqueOwner
is not the msg.sender
, but rather the address
passed in the FarmingPositionRequest
:
Initial liquidity is transferred from the farmer to the contract and added and added to the setup via the _addLiquidity function, which calculates the amount (liquidityAmount
) as well as the minted NFT’s id.
In fact, when a user opens a position, the _addLiquidity function uses the Uniswap v3 MultiCall method to mint the NFT (and, in doing so, generate the NFT’s id) using the parameters established when the setup was created by the host.
(_addLiquidity
can then call the increaseLiquidity
method of INonfungiblePositionManager
).
At this point, the FarmingPosition
struct for the created position is populated as follow:
Creating a position increases the number of positions within a specific setup by one, given by:
Last updated