How does Demeter Work?

Overview

Demeter is a protocol that enables DAOs to launch and manage decentralized exchange (DEX) liquidity pools and farms on platforms like Uniswap V2, Uniswap V3, Camelot V2, Camelot V3 and Balancer V2. The protocol simplifies the process of incentivizing liquidity for the DAOs' native tokens without requiring coding expertise. Demeter automates the creation, management, and reward distribution for liquidity pools, providing support in engineering, marketing, and financial incentives.

Launching Demeter Farm (For Farm Admins)

Steps to Launch a Farm

  1. Approve Fees Spend: Users must first approve the spending of the fee token for the farm creation fee. The fee is 100 USDs on Arbitrum. On any chain not supporting USDs, it can be any other stable coin supported on that chain.

  2. Input Pool and Farm Parameters: Users must provide necessary parameters for the pool and farm.

  3. Execute Transaction: A transaction is executed to create the farm and pay the farm creation fee.

    • Reversion Conditions:

      • If the pool does not exist, the transaction reverts.

      • If the user does not have enough fee tokens to pay the fee, the transaction reverts.

Pool Parameters

  1. Token address

    • Token A

    • Token B

  2. Fee Tier (for Uniswap V3 Pools)

  3. Liquidity Parameter L - An LP token parameter which is set based on the user’s liquidity inside the pool. Updating this parameter will allow the farm users to add or remove liquidity. When the LP token is updated, the LP token should start receiving rewards based on the new L parameter. This will allow users to add or remove liquidity without having to unstake their entire LP position.

  4. Active Liquidity Time Check - (a Boolean value of true or false which determines whether the position is in the current price range) - To check if the position is in the current price range, as only that liquidity will be rewarded which is in range. However, users will be allowed to remove any locked liquidity during the period when the liquidity is not in the current price range.

Base Farm Parameters

  1. Farm admin: It is the address that will have admin control on the farm. It can be the same as the deployer’s address or any other desired address which will be used to manage the farm.

  2. Price range for the LP

  3. Reward tokens

    • Token addresses

    • Token address managers: Each token will have its own token manager.

    • Reward tokens have to be added at the time of farm creation and can't be added or removed after the farm is created. Maximum 4 reward tokens are possible for a farm.

    • For reward tokens emitting fixed APR, Token manager will be the Rewarder contract deployed through the Rewarder factory.

  4. Cooldown Period for Locked Liquidity - It is the number of days users have to wait after initiating cooldown before they can unstake from a locked position. Only whole numbers are allowed for this parameter.

    • If Cooldown Period = 0, then the farm only allows creation of unlocked positions. Unlocked positions can be unstaked anytime.

    • If Cooldown Period > =1, the farm will allow creation of both locked and unlocked positions. For unstaking a locked position, users have to initiate cooldown and wait for cooldown period before unstaking.

  5. Start date time stamp - Reward emission starts from this date. This date can be changed by the farm admin using admin functions (updateFarmStartTime). However, date change is not allowed after the farm starts.

    • The farms start accepting liquidity immediately after the creation of the farm contract. However, the reward accrual starts from the farm start date time stamp.

  6. Annual Percentage Return APR - The farm admin can set a fixed APR which will guarantee a reward to the LPs based on the current price of the reward tokens. The farm admin will also have to choose one or more base tokens out of the tokens present in the farm for calculation of the daily number of reward tokens emitted.

    • Let’s say APR set = APR%.

    • Total value of Base Tokens in USD = Σ (Number of Base tokens in farm x USD value of Base Token)

    • No. of Reward tokens per day = [(APR x Total value of Base Tokens in USD) / (100 x 365)] / (Price of 1 reward token based on the oracle)]

  7. Maximum number of Rewards Tokens Emitted Per Day - The farm admin would be able to add the maximum number of reward tokens per day that the farm can distribute, to prevent any deficiency in the farm’s reward tokens in cases when many LPs deposit on the same day since then all the withdrawals may also happen on the same day.

    • It will override the reward tokens value calculated using the formula mentioned above in point no 6. The rewards emitted per day will be the minimum of the amount calculated above or the max reward rate set by the reward manager.

Expirable Farm Parameters

This is a new feature which has all the above parameters along with the expiry date feature:

  1. Expiry Date - Farms will have an expiry date associated with them. Users can specify the expiry date while creating the farms. The initial launch fee of 100 USDs (or some other stable coin if USDs is not present on that chain) will add 100 days to the farm expiry. After that users have the option to extend the farm expiry date. Post that users will have to extend the farm in the multiple of 1 USDs/day with minimum of 100 days at a time and a maximum of 300 days.

    • Farm admins will not be able to update any farm parameters once the farm has expired. However, they can remove any unclaimed reward tokens from the contract.

    • Farm users can still claim any accrued rewards from the farm or remove liquidity from them once that farm has expired.

    • Farms that have expired will be available on the Dashboard for removing liquidity up to 30 days beyond expiry. After that the farms will only appear on the expired farm list and admins cannot make the expired farms active again. Users or admins will be able to apply all actions through the smart contract.

    • Expired farms shall be removed from the Sperax Gauge and would not be eligible for SPA rewards.

    • Farm does not accrue rewards after the expiration so users can call updateFarmRewardData function on the farm to accrue rewards before farmEndTime to avoid any loss of rewards.

Fee

  • Demeter will charge a flat $100 fee to launch the farm, which will add 100 days to the expiry date set while the creation of the farm.

  • After that users have the option to extend the farm expiry date. They can do so in the multiple of 1 USDs/day with minimum of 100 days at a time and a maximum of 300 days. The fees can be paid in either USDs or in any other stable coin provided USDs is not present in that chain.

  • The fee collected belongs to the SPA stakers and can be transferred directly to the wallet address where all Sperax protocol fees are collected. Fee amount can be changed in future through governance.

  • The Fee details can be fetched from getFeeParams function on the Farm registry contract.

Farm Management

No one can make changes to the farm contract once deployed. Farm admins can do the following:

  1. Transfer farm ownership to another address

  2. Change start date of the farm - Farm will emit rewards from this date. The date can be changed after farm creation. However, date change is not allowed after the farm starts.

  3. Update cooldown period of the locked positions

  4. Pause or Unpause the farm

    • Pause the farm - All reward distributions are paused, LPs do not earn any rewards during this period. Withdrawals are allowed (including lockup LPs) and users can also claim previously accrued rewards. Admin/managers can make changes to the distribution rates and the other parameters when the farm is paused.

    • Unpause the farm - Resume the reward distribution. The reward distribution rate remains the same as set by the reward managers.

  5. Update Expiry Date of the Farm by paying Subscription Fees

    • Farm admins can choose and update the expiry date of farms as mentioned in the Farm Parameters.

  6. Close the farm - The farms can be closed before the expiry date and will automatically get closed once the expiry date is reached. Once the farm is closed, all liquidity providers including lockup users can now unstake their liquidity pool tokens and claim the accrued rewards from the farm.

Reward Management

Each reward token will be assigned a reward token manager. Farm admin cannot update the reward token manager once the farms are deployed. Reward token managers can do the following:

  1. Add reward token balance

  2. Update reward distribution rate per second for each token. Only future distribution rates can be affected through this. Reward distribution can be paused by setting the rate to 0. These actions can be done:

    1. For all liquidity providers.

    2. For lockup liquidity providers (If cooldown period is greater than 0)

  3. Changing the maximum number of token rewards per day - Farm admins can increase or decrease the reward tokens limit in the fixed APR model as per their choice.

  4. Withdraw reward tokens (Any rewards already accrued to LPs cannot be removed).

  5. Transfer reward token management to another address.

Setting up a Farm Position (For Liquidity Providers/Retail Users)

Adding a Farm Position:

  1. Select the farm: LPs need to choose the required farm from the whitelisted farms which are present on the dashboard, based on their choice of tokens and price range.

  2. Enter the number of farm tokens: Post that, they can enter the number of one of the tokens for the position, the other tokens are automatically calculated.

  3. Execute Transaction: The user then needs to approve the wallet transactions for the spending of tokens and creation of a farm position.

    • Reversion Conditions:

      • If the user does not have the required tokens in their wallet, the transaction reverts.

  4. LP Token: On successful execution of the transaction, the Liquidity Provider will receive the LP token(s) in their wallet.

  5. Depositing the LP Token: Users then need to deposit the lp tokens inside the farm to create a position.

Updating Liquidity in the LP Tokens:

  1. Updating the Liquidity Balance - This will allow LPs to add to or remove liquidity from the LP Token without having to unstake their entire LP position. When the LP token is updated, the LP token should start receiving rewards based on the new L parameter.

Rewards Emission:

  1. Fixed APR Rewards - The LPs will receive fixed APR rewards (this fixed APR will be set by the farm admin) generated from their invested farms. Each farm will have some base reward tokens which will be the base for calculating the number of reward tokens to be emitted per day. The LP will receive the reward tokens (selected by the farm admin) in their wallet, which will be calculated as:

    • Let’s say APR set = APR%.

    • Total value of Base Tokens in USD = Σ (Number of Base tokens in farm x USD value of Base Token)

    • No. of Reward tokens per day = [(APR x Total value of Base Tokens in USD) / (100 x 365)] / (Price of 1 reward token based on the oracle)]

  2. Maximum number of Rewards Tokens Emitted Per Day - However, the number of reward tokens to be emitted by the farm has been capped. The farm admin would be able to add the maximum number of reward tokens per day that the farm can distribute, to prevent any deficiency in the farm’s reward tokens in cases when many LPs deposit on the same day since then all the withdrawals may also happen on the same day.

Last updated