Skip to Content
GlowSwap Documentation 🎉
DevelopersGlowSwap Basics - Video Series

GlowSwap Basics - Video Series

Welcome to the GlowSwap video series. This series should walk through the GlowSwap basics such as CPAMMs, exclusive pools, and more.

Recommended to watch in order at 1.5x speed.

1. CPAMM Refresher

This video is a basic refresher on CPAMMs.

Key Points

Swapping

  • Swapping must follow the x * y = k curve.
  • When you swap, the amount of tokens you receive is determined by the ratio of the tokens in the pool.
  • The pool’s k value is always the same before and after the swap.

Adding Liquidity

  • Liquidity providers receive LP tokens in exchange for adding liquidity to the pool.
  • LP Tokens represent a share of the underlying liquidity of the pool.
  • The equation for minting LP Tokens is sqrt((x+dx)*(y+dy)) - sqrt(x*y).
    • Where x and y are the initial amounts of tokens in the pool.
    • dx and dy are the amounts of tokens added to the pool.

Removing Liquidity

  • The amount of liquidity you are entitled to is equal to totalLiquidity * balanceOf(me) / totalSupply()
  • When removing liquidity, you can remove any amount of tokens you want as long as the liquidity impact is less than or equal to the liquidity you are entitled to.
  • Liquidity impact can be calculated by Absolute Value (sqrt((x-dx)*(y-dy)) - sqrt(x*y))
    • Where x and y are the initial amounts of tokens in the pool.
    • dx and dy are the amounts of tokens removed from the pool.

2. Defining Liquidity

This video walks through how GlowSwap defines liquidity.

Key Points

  • liquidity is defined as sqrt(x * y) in a pool
  • liquidity impact is defined as the absolute value of the difference between some original sqrt(x * y) and some new sqrt((x ± dx) * (y ± dy)) after altering the amount of tokens in the pool.

3. Introduction To Exclusive Pools

This video introduces the concept of exclusive pools.

Key Points

  • Exclusive pools borrow liquidity from the main pool.
  • The size of the exclusive pool’s loan is determined by the amount of liquidity it borrows from the main pool.
  • Exclusive pools are CPAMMs that only the exclusive pool’s creator can swap against.
  • Exclusive pool borrowers prepay interest to prevent liquidations.
  • Exclusive pools pay back interest in some creator-defined ratio of tokenX:tokenY.
  • Exclusive pool borrowers can execute strategies like collateralized borrowing, leverage, or building more complex DeFi applications.

4. Exclusive Pool Minimum Liquidity Requirements

This video walks through the minimum liquidity requirements for exclusive pools.

Key Points

  • Exclusive pools must have at least as much independent liquidity as the liquidity impact of their loan
  • Independent liquidity is defined as sqrt(exclusivePoolTokenX * exclusivePoolTokenY)

5. Initialization Fees and Paying Interest

This video walks through the initialization fees and paying interest on exclusive pools.

Key Points

  • Initialization fees are paid into main pool when the pool is created.
  • Interest is paid in some creator-defined ratio of tokenX:tokenY.
  • Borrowers should prepay interest to prevent liquidations.

Note on Exclusive Pool Reserves vs. Their Loan Size

It’s important to distinct between an exclusive pool’s actual liquidity vs their minimum liquidity.

  • actual liquidity is the amount of liquidity in the exclusive pool defined by sqrt(exclusivePoolTokenX * exclusivePoolTokenY)
  • minimum liquidity is the amount of liquidity that the exclusive pool must have at any given time and is the size of their loan which they pay interest on.

The actual liquidity must ALWAYS be greater than or equal to the minimum liquidity. That’s why in the video the exclusive pool has reserves (100,100) even though their minimum liquidity is 10. The delta between the actual liquidity and the minimum liquidity is the amount of buffer that the exclusive pool has to pay interest with.

6. Interest Rates

This video walks through the interest rates and how utilization rates affect them.

Key Points

  • Interest rates are determined by the utilization rate of the exclusive pool.
  • The interest rate is a function of the utilization rate.
  • GlowSwap targets 80% utilization rate.
    • If the utilization rate is greater than 80%, the interest rate will increase.
    • If the utilization rate is less than 80%, the interest rate will decrease.
  • Interest rates generally increase maximum 20% relative per day.

7. Recap (Optional)

Quick recap of the previous videos.

Key Points

  • Exclusive pools borrow liquidity from the main pool.
  • Exclusive pools must have at least as much independent liquidity as the liquidity impact of their loan.
  • Exclusive pools pay interest on their loan.
  • Interest rates are determined by the utilization rate of the exclusive pool.
  • The interest rate is a function of the utilization rate.

8. Liquidity Queues

This video walks through the liquidity queues and how they work.

Key Points

  • There can be cases where a liquidity provider wants to exit their position, but the main pool has insufficient liquidity to satisfy the withdrawal because of high borrowing utilization.
  • Liquidity queues establish a first in first out (FIFO) priority queue for liquidity providers to exit their positions.
  • As new liquidity comes in through interest collections or additional liquidity deposits , that liquidity is reserves for the next queue position.
  • If queue positions are open, that means that utilization rates are high which means that interest rates will climp sharply.
  • The worst case to exit is 57 days. This occurs when the interest rate starts at 0.1%.
Last updated on