Add New Farming Setups to a Contract

A host can add new setups to a contract in addition to those created during contract initialization.

To do this, they can use the setFarmingSetups function:

function setFarmingSetups(FarmingSetupConfiguration[] memory farmingSetups) public override byExtension

The function uses as input the FarmingSetupConfiguration struct:

struct FarmingSetupConfiguration {
    bool add; 
    bool disable;
    uint256 index; 
    FarmingSetupInfo info; 
}
  • add -> true

  • disable -> false

  • index -> the index of the new Farming setup. This parameter is empty in case of adding a new setup.

  • FarmingSetupInfo -> struct containing the new setup data

The setFarmingSetups calls internally the _setOrAddFarmingSetupInfo method to create the setup, which takes as input the information previously passed in the setFarmingSetups:

function _setOrAddFarmingSetupInfo(FarmingSetupInfo memory info, bool add, bool disable, uint256 setupIndex) private
  • info -> FarmingSetupInfo struct

  • add -> true

  • disable -> false

  • setupIndex -> the index of the new Farming setup

The FarmingSetupInfo struct is composed as follows:

struct FarmingSetupInfo {
    bool free; 
    uint256 blockDuration;
    uint256 startBlock;
    uint256 originalRewardPerBlock;
    uint256 minStakeable; 
    uint256 maxStakeable; 
    uint256 renewTimes; 
    address ammPlugin; 
    address liquidityPoolTokenAddress; 
    address mainTokenAddress; 
    address ethereumAddress;
    bool involvingETH; 
    uint256 penaltyFee; 
    uint256 setupsCount; 
    uint256 lastSetupIndex; 
}
  • free -> a boolean value representing if the setup to create is free (true) or locked (false)

  • blockDuration -> duration of the setup in blocks

  • startBlock -> start block of the setup*

  • originalRewardPerBlock -> the reward per block set when the setup is created; will remain the same unless the host modifies the reward per blocklater

  • minStakeable -> minimum amount of the main token that can be staked by a position in the setup

  • maxStakeable -> maximum amount stakeable in the setup (used for locked setups)

  • renewtimes -> if the setup is renewable or if it's one time

  • ammPlugin -> AMM plugin address used for this setup (eg. the Uniswap AMM plugin address)

  • liquidityPoolTokenAddress -> address of the liquidity pool used for the setup

  • mainTokenAddress -> address of the chosen main token; used to perform some checks such as the minStakeable or maxStakeable in case of a locked setup

  • ethereumAddress -> for internal use only

  • involvingETH -> a boolean value representing if ETH is involved as token in the setup (true) or not (false). Please refer to the AMM Aggregator section for more details

  • penaltyFee -> penalty fee expressed as percentage used in the unlock function in a locked setup

  • setupsCount -> number of setups created by this info (for internal use only)

  • lastSetupIndex -> index of last setup created by this info (for internal use only)

*Optional. Represents the block from which activation of the setup can be attempted; activatesetup cannot be called before that block is reached. If startBlock is set as zero, then the setup can be activated any time after it is created.

Last updated