Weighted Pools

Overview

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.

Invariant

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’).‌

V=tBtWtV= \prod_t B_t^{W_t}

Where >

  • tt ranges over the tokens in the pool

  • BtB_t is the balance of the token in the pool

  • WtW_t​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

InvariantV=B10.5×B20.5Invariant\, V={B}^{0.5}_{1}\times {B}^{0.5}_{2}

like B1×B2{B}_{1}\times {B}_{2} is a constant.

Based on this value function, Polaris Finance allows users to create pools with up to eight assets, user-defined weights, and customizable swap fees.

An Example of how weights may affect the pool contributions

Assuming pNEAR price is 100 USDC, we may create two pools, containing 20,000 USD (1USDC=1USD) liquidity respectively, but with different weights.

Pools50/50 pNEAR/USDC80/20 pNEAR/USDC20/80 pNEAR/USDC

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

Token Price

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.

SP12=b1w1b2w2 {SP}^{2}_{1}=\frac {\frac {{b}_{1}} {{w}_{1}}} {\frac {{b}_{2}} {{w}_{2}}}
  • SP12 {SP}^{2}_{1} is the Spot Price of token 2, relative to token 1;

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

How trades affect the pool and the price

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

Pools50/50 pNEAR/USDC80/20 pNEAR/USDC20/80 pNEAR/USDC

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.

Advantages

Exposure Control

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

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.

Trading Pairs

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.

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 equationC(n,2)=n!2!(n2)!C(n,2) = \frac{n!}{2!(n-2)!}, where nn​ ​is the number of tokens in the pool.

Last updated