Liquidity Pools

What is a Liquidity pool?

A liquidity pool is a collection of funds locked in a smart contract. Liquidity pools are used to facilitate decentralized trading, lending, and many more functions that the ShibaSwap supports.

To pool liquidity, the amounts a user supplies must be equally divided between two coins: the primary token and the base token.

When you add to a liquidity pool you will receive Shiba Swap Liquidity Provider tokens (SSLP tokens). These tokens represent a proportional share of the pooled assets, allowing a user to reclaim their funds at any point.

For example, if a user deposited $SHIB and $ETH into a pool, you would receive ETH-SHIB SSLP tokens.

Every time a user trades between $SHIB and $ETH or any other coin pair on ShibaSwap,

  • a 0.3% Liquidity Provider Fee is taken on the trade.

    • If that trade involves $WBTC or $USDC i.e if $WBTC or $USDC is swapped for another token

      • 0.1% of the fees for that trade goes back to the $LEASH-ETH LP pool as $WBTC & $USDC

    • If that trade involves $DAI or $USDT i.e if $DAI or $USDT is swapped for another token

      • 0.1% of the fees for that trade goes back to the $BONE-ETH LP pool as $DAI & $USDT

How does it Work?

Let's begin by assuming

  • a Liquidity pool of $USDC and $SHI (an imaginary(!) coin) that contains 10 USDC & 1000 $SHI

    • Starting value of $SHI is 0.01 USD (10/1000 = 0.01)

      • Starting value of a new coin like $SHI is determined by the ratio of the assets in the Liquidity pool for a new coin.

      • ShibaSwap follows Uniswap V2 in how it defines liquidity.

        • Uniswap V3 has additional requirements. Since they don't apply to ShibaSwap, it won't be explained in detail.

A buy happens

  • Assuming a swap from $USDC to $SHI - 1 USDC is being used to buy $SHI

  • The trade happens from the Liquidity pool of $USDC and $SHI

  • This pool is governed by a formula called Constant product formula

    • xy=kx * y = k where

      • x is the quantity of first token in the pair

      • y is the quantity of the second token in the pair

      • k is the product of x and y and it should always remain the same

  • This formula is used to determine the price appreciation and depreciation of the coins in that LP pair.

  • Before the trade

    • x = 10 ($USDC)

    • y = 1000 ($SHI)

    • k = 10 * 1000 = 10000

  • After this trade goes through

    • x = 10 + 1 = 11 ($USDC)

    • y = ? How much $SHI should be returned, as we need to keep k = 10000

    • going by k=xyk = x * y

      • y=k/xy = k/x=> 10000/11 = 909.0909090909

  • Now, to keep k at 10000 with x at 11 we only need y to be 909.0909090909

  • Current count of y = 1000

  • Difference between starting/current count of y and the calculated count = 1000 - 909.0909090909 = 90.9090909091

  • This means we have an extra 90.9090909091$SHI coins in the pool

  • This is what will be returned to the user in exchange of 1 $USDC

  • Let's now calculate the current USD value of $SHI coin

    • Before the swap

      • Value of coins

        • 1 $USDC = 1 USD

        • 1 $SHI = 0.01 USD

          • from the ratio 10 $USDC : 1000 $SHI

          • 1 $SHI = 10 / 1000 = 0.01 $USDC

      • This means 1 USD would have fetched you 100 $SHI

    • Swap Request

      • 1 $USDC has now come in to pool

        • x = 11 ($USDC) i.e value of 1 $USDC = 1 USD

        • k = 10000 i.e 100 USD

        • y = 909.0909090909 $SHI as calculated above

        • An extra 90.9090909091$SHI coins in the pool

      • This means 1 USD now fetches you 90.9090909091$SHI instead of 100 $SHI

      • So the value of 1 $SHI now is 1/90.9090909091 = 0.011 USD

  • Now the LP pool that started with

    • 10 $USDC and 1000 $SHI with 1 $USDC at 1 USD and 1 $SHI at 0.01 USD now has

    • 11 $USDC and 909.0909090909 $SHI with 1 $USDC at 1 USD and 1 $SHI at 0.011 USD

A sell happened

  • Assuming a swap from $SHI to $USDC - 100 $SHI is being sold

  • The trade happens from the Liquidity pool of $USDC and $SHI

  • This pool is governed by a formula called Constant product formula

    • xy=kx * y = k where

      • x is the quantity of first token in the pair

      • y is the quantity of the second token in the pair

      • k is the product of x and y and it should always remain the same

  • This formula is used to determine the price appreciation and depreciation of the coins in that LP pair.

  • Before the trade

    • x = 10 ($USDC)

    • y = 1000 ($SHI)

    • k = 10 * 1000 = 10000

  • After this trade goes through

    • x = ? ($USDC) How much $USDC should be returned, as we need to keep k = 10000

    • y = 1000 + 100 = 1100

    • going by k=xyk = x * y

      • x=k/yx = k/y => 10000/1100 = 9.0909090909

  • Now, to keep k at 10000 with y at 1100 we only need y to be 9.0909090909

  • Current count of x = 10

  • Difference between starting/current count of x and the calculated count = 10 - 9.0909090909 = 0.9090909091

  • This means we have an extra 0.9090909091 $USDC coins in the pool

  • This is what will be returned to the user in exchange of 100 $SHI

  • Let's now calculate the current USD value of $SHI coin

    • Before the swap

      • Value of coins

        • 1 $USDC = 1 USD

        • 1 $SHI = 0.01 USD

          • from the ratio 10 $USDC : 1000 $SHI

          • 1 $SHI = 10 / 1000 = 0.01 $USDC

      • This means 100 $SHI would have fetched you 1 USD

    • Swap Request

      • 100 $SHI has now come in to the pool

        • x = 9.0909090909 ($USDC) as calculated above but value of 1 $USDC = 1 USD

        • k = 10000 i.e 100 USD

        • y = 1100 $SHI as calculated above

        • 0.9090909091 $USDC coins will be returned to the user

      • This means 100 $SHI will now fetched you 0.9090909091 $USDC instead of 1 $USDC

      • So the value of 1 $SHI now is 0.9090909091/100 = 0.009090909091 USD

  • Now the LP pool that started with

    • 10 $USDC and 1000 $SHI with 1 $USDC at 1 USD and 1 $SHI at 0.01 USD now has

    • 9 $USDC and 1100 $SHI with 1 $USDC at 1 USD and 1 $SHI at 0.009090909091 USD

Liquidity Pools on ShibaSwap

  1. Liquidity providers have two choices after Adding Liquidity

  2. They can choose to

    1. Hold the SSLP tokens with them and earn a proportional percentage of Swap fees

    2. Enter the Farm and drop their SSLP tokens in one of the many WOOF pools and earn more rewards.

Last updated