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; 
}

Passing the following parameters:

  • 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(look below).

The FarmingSetupInfo struct is composed as follows:

struct FarmingSetupInfo {
    bool free; 
    uint256 blockDuration;
    uint256 startBlock;
    uint256 originalRewardPerBlock;
    uint256 minStakeable; 
    uint256 renewTimes; 
    address ammPlugin; 
    address liquidityPoolTokenAddress; 
    address mainTokenAddress; 
    address ethereumAddress;
    bool involvingETH; 
    uint256 setupsCount; 
    uint256 lastSetupIndex; 
}
  • free -> must be passed as true

  • blockDuration -> duration of the setup in blocks.

  • startBlock -> start block of the setup*

  • originalRewardPerBlock -> reward per block chosen; it 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.

  • 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.

  • 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.

  • setupsCount -> populated automatically by the contract and it's used for internal use only.

  • lastSetupIndex -> populated automatically by the contract and it's used 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