Managing Positions

A position is managed through two different structs.

The first is the FarmingPositionRequest struct, which is used to open a new position or to add liquidity to an existing position.

All other position management operations (position transfer, reward withdrawal, liquidity withdrawal, etc.) internally use the FarmingPositionstruct.

FarmingPositionRequest Struct

The FarmingPositionRequest struct is structured as follow:

struct FarmingPositionRequest {
    uint256 setupIndex; 
    uint256 amount0; 
    uint256 amount1; 
    address positionOwner;
  • setupIndex -> Index of the chosen farming setup.

  • amount0 -> amount of the first token (token0).

  • amount1 -> amount of the second token (token1).

  • positionOwner -> the position owner address. address(0)is used to represent the msg.sender; otherwise, input the address of your choice. This means that by using the OpenPosition function, you can also open a position for another address.

FarmingPosition Struct

The FarmingPosition struct contains all of the data of the position of a farmer in a setup and is populated and modified through the position management functions. It is composed as follows:

struct FarmingPosition {
    address uniqueOwner; 
    uint256 setupIndex; 
    uint256 creationBlock; 
    uint256 tokenId; 
    uint256 reward;
  • uniqueOwner -> address representing the position owner address.

  • setupIndex -> Index of the chosen farming setup for the position.

  • creationBlock -> the block at which the position is created.

  • tokenId -> the id of the NFT of a specific position. This parameter is used by the farming contract to retrieve information about the NFT, such as the amount of liquidity or trading fees collected.

  • reward -> rewards for the position. initially unpopulated, and subsequently repopulated as rewards are recalculated on a block-to-block basis.

Last updated