Liquidity / staking pool
Include tokens added in liquidity pools or staking contracts into Voting Power calculation besides those held in users' wallets.
Last updated
Include tokens added in liquidity pools or staking contracts into Voting Power calculation besides those held in users' wallets.
Last updated
At the moment, Snapshot already supports calculating the Voting Power of the underlying token in the LP/staking contract from the most popular like Uniswap v2 and v3, Balancer, or SushiSwap.
This page only goes through popular strategies as projects may have a different method to call deposited balance in their contracts, which is often customized for a specific use case.
By enabling such a strategy in your space, you can allow the proposal to capture more users interested in your governance.
Some spaces allow only users holding tokens in liquidity/staking pools to have Voting Power.
The strategy fetches the balance of the input token address in all Uniswap-v2 liquidity pools.
This allows uni-v2 LP token holders to vote based on the underlying token cumulated in each pool.
For instance, users who have 1 DAI in the DAI-USDC pool, and 2 DAI in the DAI-ETH pool, will have 3 Voting Power.
Strategy setup:
You can test it out in the Playground on Snapshot:
Many platforms offer decent yields on one's Uniswap LP tokens.
By staking in their farms, users transfer their LP tokens to the contract they are interacting with (staking contract) and then can earn rewards from the farm they have joined.
The specific type of LP that can be farmed depends on the individual platforms.
The staked-uniswap
strategy allows you to get token balance of an LP in a staking contract.
Strategy setup:
tokenAddress
: the underlying token you want to use to calculate Voting Power
uniswapAddress
: the Uniswap LP address where users can deposit their token
stakingAddress
: the staking contract address where users stake their LP token
You can test it out in the Playground on Snapshot:
In comparison with v2, Uniswap v3 provides users with the most flexibility and granular control over personal assets by introducing features like concentrated liquidity and multiple LP fee tiers per pair — 0.05%, 0.30%, and 1.00%.
In this context, the USDC / ETH LPs with 0.3% and 0.05% fees represent different contract addresses (poolAddress)
respectively.
The demo illustrates how to get USDC balance in the USDC / ETH 0.3% liquidity pool. If you want to calculate the other token in the pool, you can change the paramtokenReserve
to 1.
Strategy setup:
You can test it out in the Playground on Snapshot:
LP tokens provided in SushiSwap are called SLP tokens, and the SLP tokens can be staked into the farm (MasterChef LP Staking Pool) to earn rewards.
This strategy can return the balance of the underlying token in SushiSwap's LP pools and farms as well.
Strategy setup:
address
- the underlying token address
useStakedBalances
- if true it will also return the token balances from the MasterChef LP Staking Pool
masterchefVersion
- if v2 it will return the token balances from the MasterChef V2 staking contract instead of MasterChef V1.
You can test it out in the Playground on Snapshot:
The MasterChef contract has been developed by many projects based on SushiSwap’s original contract like pancake's syrup pool. With MasterChef, users can stake their tokens and in exchange they will get a token reward.
The strategy is more generic and it gets the balance of the LP token or the underlying base token in the LP from a MasterChef staking pool.
Strategy setup:
chefAddress
: Masterchef contract address
pid
: masterchef pool id (starting with zero)
uniPairAddress
: address of a Uniswap pair (or a sushi pair or any other with the same interface)
if uniPairAddress
is null, returns staked LP token balance as is
if the uniPairAddress
option is provided, converts staked LP token balance to base token balance (based on the pair total supply and base token reserve)
tokenIndex
: index of a token in LP pair, by default 0, can switch to 1 for another base token
weight
: integer multiplier of the result (for combining strategies with different weights | optional)
weightDecimals
: integer divisor of the result (1 gives a decimal before the result | optional)
You can test it out in the Playground on Snapshot:
A lot of use cases are beyond regular LP/staking scope, for example calculating the balance of staked NFT or from a custom contract.
The good news is, if there's a method in your contract that reads the balance of the staked token with a single call (interaction with the Smart Contract), you don't need to create a new strategy.
Instead, use contract-call
strategy, which allows any contract method to be used to calculate voter scores.
As this is a more advanced strategy, don't hesitate to reach out to our support team on Help Center!
Strategy setup:
You can test it out in the Playground on Snapshot: