Weighted Pools
Last updated
Last updated
Weighted Pools are highly versatile and configurable pools. Weighted Pools use Weighted Math, which makes them great for general cases, including tokens that don't necessarily have any price correlation (ex. stNEAR/USDC). Unlike pools in other DeFi protocols that only provide 50/50 weightings, Polaris Weighted Pools enable users to build pools with different token counts and weightings, such as pools with 80/20 or 60/20/20 weightings.
Please note that the weightings here are in the term of value, not the amount of the tokens. An 80/20 pNEAR/USDC pool means that pNEAR accounts for 80% of the pool value and the other 20% is made of USDC.
The weighted math equation is a generalization of the xāy=k constant product formula. It accounts for cases with no less than 2 tokens in a pool, as well as weightings that are not an even split.
Please note that the weights are those of the equivalent value of the tokens in the weighted pools, not the number of tokens.
The weighted poolās AMM is defined by a function of the poolās balances and weights, constraining V to a constant (āInvariant Vā).ā
Where >
ranges over the tokens in the pool
is the balance of the token in the pool
āis the normalized weight of the tokens, such that the sum of all normalized weights is 1.
If you take a closer look at Uniswapās model, it is actually a special case of the equation above, when t=2 and W1=W2=50%; which can be translated to
Based on this value function, Polaris Finance allows users to create pools with up to eight assets, user-defined weights, and customizable swap fees.
Assuming pNEAR price is 100 USDC, we may create two pools, containing 20,000 USD (1USDC=1USD) liquidity respectively, but with different weights.
Total Liquidity (USD)
20,000
20,000
20,000
pNEAR Value in the pool (USD)
10,000
16,000
4,000
No. of pNEAR
100
160
40
USDC Value in the pool (USD)
10,000
4,000
16,000
No. of USDC
10,000
4,000
16,000
Price of pNEAR (USD)
100
100
100
Though a weighted pool may have multiple tokens in its composition, swaps in these pools occur between only two token assets, which means one is trading one cryptoasset for another in the pool, like a trading pair.
Unlike the pricing mechanism in Uniswap, the weighted pool considers the token weights when defining the spot price of a swap.
b1 is the balance of token 1, the token being sold by the trader which is going into the pool
b2 is the balance of token 2, the token being bought by the trader which is going out of the pool
W1 is the weight of token 1 and W2 is the weight of token 2
No matter what exchanges are carried out, the share of the value of each token in the pool remains constant.
Due to the weight differences, pools have different slippage when users make the same transactions in pools with varied weights. Letās follow the example above with the three pNEARUSDC pools. (Supposing there are no transaction costs.)
Total Liquidity (USD)
20,000
20,000
20,000
No. of pNEAR
100
160
40
No. of USDC
10,000
4,000
16,000
Price of pNEAR
100
100
100
Invariant
1,000.00
304.58
4,827.34
When one buys 1 pNEAR from the pool
No. of pNEAR
99
159
39
No. of USDC
10,101.01
4,101.58
16,101.59
Invariant
1,000.00
304.58
4,827.34
Price of pNEAR after the trade
102.03
103.18
103.22
Price of pNEAR for the trade
101.01
101.58
101.59
Note:
The pool invariant stays unchanged before and after the trade.
No. of pNEAR is reduced by 1 pNEAR due to the purchase of the user.
Price of pNEAR for the trade is the USDC the user pays for this 1 pNEAR purchase, translated into the increase of USDC in the pool.
Price of pNEAR for the trade is the price of pNEAR determined by the pool compositions after the trade.
From the table above, we may notice that though the three weighted pools have the same initial liquidity, the slippage tend to vary. The 50/50 pool has the smallest slippage. Pools with highly biased weights may lead to higher price slippage.
Weighted Pools allow users to choose their levels of exposure to certain assets while still maintaining the ability to provide liquidity. The higher a token's weight in a pool, the less impermanent loss it will experience in the event of a price surge.
For example, if a user wants to provide liquidity for pNEAR and wETH, they can choose the weight that most aligns with their strategy. A pool more heavily favouring pNEAR implies they expect bigger gains for pNEAR, while a pool more heavily favouring wETH implies bigger gains for wETH. An evenly balanced pool is a good choice for assets that are expected to remain proportional in value in the long run.
For example, an 80/20 pNEAR/USDC pool means that pNEAR accounts for 80% of the pool value. If you are bullish on pNEAR while expecting to earn some extra transaction fees from contributing liquidity while limiting your USDC exposure, contributing liquidity in this pool is a better choice than a 50/50 pool like in the Uniswap model.
Impermanent Loss is the difference in value between holding a set of assets and providing liquidity for those same assets.
For pools that heavily weigh one token over another, there is far less impermanent loss, but with higher slippage when making trades due to the fact that one side has much less liquidity.
Since each token in a pool can be traded with any other token in a pool, the number of trading pairs grows significantly with each additional token. By providing more trading pairs, pools are able to facilitate more swaps, giving them more opportunities to collect fees.
like is a constant.
is the Spot Price of token 2, relative to token 1;
For example, an SPOLAR/XPOLAR/pNEAR pool can facilitate trades between SPOLAR/XPOLAR, XPOLAR/pNEAR and SPOLAR/pNEAR. The number of trading pairs in a pool follows the combinations equation, where ā āis the number of tokens in the pool.