Skip to Content
GlowSwap Documentation 🎉
Core ConceptsRethinking Liquidity

Rethinking Liquidity

In traditional DeFi, “liquidity” typically refers to the availability of assets that can be easily traded or converted into other assets without significantly impacting the market price. The more liquid an asset or trading pair is, the easier it is to execute large trades with minimal price slippage.

Let’s look at two common examples:

  1. DEX Liquidity Pools

    • When people talk about liquidity on Uniswap or similar DEXs, they’re referring to the tokens deposited in trading pools
    • For example, a ETH/USDC pool with $10M of liquidity means there’s roughly $5M worth of ETH and $5M of USDC available for trading
    • Larger liquidity pools generally mean better prices and less slippage for traders
  2. Lending Protocol Liquidity

    • On platforms like Aave or Compound, liquidity refers to the amount of assets available for borrowing
    • If a lending pool has 1000 ETH in liquidity, it means users can borrow up to that amount (subject to collateralization requirements)
    • Low liquidity in lending pools can result in higher borrowing costs or inability to borrow desired amounts

In both cases, liquidity represents assets that are “locked” or “committed” to a specific protocol function, whether that’s facilitating trades or enabling loans.

Introducing Liquidity In GlowSwap

In GlowSwap, liquidity is thought of as a sqrt(tokenX * tokenY) relationship between the reserves of the trading pair; or in the other words, the sqrt(k) in the x * y = k equation.

This is best illustrated by an example;

When a token pair is first created, the initial liquidity provider adds some amount of tokenX and tokenY to the pool. In return, they receive some amount of liquidity tokens. The liquidity provider receives enough liquidity tokens such that if they were to burn all of their liquidity tokens, they would receive the initial amount of tokenX and tokenY that was deposited into the pool. In CPAMMs, the amount of tokens they receive can be formalized to the equation:

Liquidity Tokens To Receive On First Deposit = sqrt(tokenX * tokenY)

When a second user adds some amount of tokenX and tokenY to the pool, they should also receive some amount of liquidity tokens that would allow them to remove their deposits from the pool.

GlowSwap formalizes the amount of liquidity tokens they should receive as the difference in the square root of the product of the total reserves of the pool.

Liquidity After First Deposit = sqrt(tokenX_total * tokenY_total) - sqrt(tokenX_initial * tokenY_initial)

These are actually the same exact equations, except that sqrt(tokenX_initial * tokenY_initial) is zero in the first equation.

Why This Matters

While we can derive the amount of extra liquidity that adding a certain amount of tokenX and tokenY will yield, we can also determine how much liquidity will be removed from a pool when removing a certain amount of tokenX and tokenY .

In GlowSwap, when a user borrows liquidity, they declare some amount of tokenX and tokenY that they would like to borrow. The difference in the square root of the product of the total reserves after the loan vs before the loan is the size of the loan that the user is creating.

In other words,

Loan Size = sqrt(tokenX_afterLoan * tokenY_afterLoan) - sqrt(tokenX_initial * tokenY_initial)

Let’s look at two examples:

Taking out a Loan Example 1

1
Main Pool starts with 1000 GLOW and 1000 USDC (1000 liquidity)
2
Exclusive Pool borrows 100 GLOW and 100 USDC from Main Pool
3
Main Pool now has 900 GLOW and 900 USDC (900 liquidity)
4
Exclusive Pool now has 100 GLOW and 100 USDC (100 liquidity)
5
Difference in Main Pool liquidity is 100 (1000 - 900)
6
Exclusive Pool liquidity (100) >= Difference in Main Pool liquidity (100) âś…
PoolGLOWUSDCLiquidity (sqrt(x*y))Notes
Main Pool (Initial)100010001000Starting state
Main Pool (After)900900900After loan
Exclusive Pool100100100Borrowed amount
Changes
Main Pool Liquidity Change-100Decrease in liquidity
Loan Validity Checkâś…Exclusive Pool liquidity (100) >= Main Pool change (100)

In the above example, the main pool reserves were 1000 GLOW and 1000 USDC. The borrower moved 100 GLOW and 100 USDC into an exclusive pool. This decreased the liquidity in the main pool by 100. Since the exclusive pool independently has 100 liquidity, the loan is allowed to be created.


Taking out a Loan Example 2

If a borrower wants to borrow reserves from the main pool in a ratio that is different from the ratio of the reserves in the main pool, the borrower must put up their own reserves to ensure that the exclusive pools sqrt(k) is greater than or equal to the difference in liquidity in the main pool that the loan is creating.

1
Main Pool starts with 1000 GLOW and 1000 USDC (1000 liquidity)
2
Borrower wants to borrow 750 GLOW and 0 USDC
3
Main Pool would have 250 GLOW and 1000 USDC (500 liquidity)
4
Exclusive Pool would have 750 GLOW and 0 USDC (0 liquidity)
5
Difference in Main Pool liquidity is 500 (1000 - 500)
6
Exclusive Pool liquidity (0) < Difference in Main Pool liquidity (500) ❌
PoolGLOWUSDCLiquidity (sqrt(x*y))Notes
Main Pool (Initial)100010001000Starting state
Main Pool (After)2501000500After attempted loan
Exclusive Pool75000Attempted borrow amount
Changes
Main Pool Liquidity Change-500Decrease in liquidity
Loan Validity Check❌Exclusive Pool liquidity (0) < Main Pool change (500)

This loan will fail because the exclusive pool does not have enough liquidity to repay the loan

If the borrower wants the following loan to go through, they’ll have to provide USDC such that the amount of sqrt(GLOW*USDC) in the exclusive pool is greater than or equal to 500.

In the case above, the borrower can determine the amount of USDC they need to add by solving the following equation:

Minimum Liquidity "sqrt(k)" = 500 Reserves Glow = 750 750 * USDC = 500^2 USDC = 500^2 / 750 = ~333.33

If the borrower independently adds 333.33 USDC into the exclusive pool as they borrow 750 GLOW, the exclusive pool will be greated.

Exclusive Pool Reserves = 750 GLOW, ~333.33 USDC Exclusive Pool Liquidity = sqrt(750 * ~333.33) = 500

The Liquidity Mental Model

When thinking of adding , borrowing, removing, or paying interest on liquidity in GlowSwap, it’s important to remember that it all stems from the simple primitive that a main pool’s liquidity is equal to sqrt(k) in the x * y = k equation. The delta between adding or removing reserves from the main pool is measured by the difference in the square root of the product of the reserves. This is called liquidity impact.

Key Points

  • The amount of liquidity in a pool is equal to sqrt(k) in the x * y = k equation.
  • When a user adds or removes reserves from the main pool, the liquidity impact is the difference in the square root of the product of the reserves.
  • When a user borrows liquidity, the amount of liquidity in the exclusive pool must be greater than or equal to the liquidity impact of the loan.
  • Any liquidity in excess of the liquidity impact of the loan is used to pay interest on the loan and can be pulled out of the exclusive pool (minus already accrued interest).
Last updated on