šŸ”¬
InterSwap Docs
  • Welcome
  • Protocol Level
    • Liquidity Pools
      • Weighted Pools
      • Stable Pools
      • Dynamic Weights
      • Gas Tokens Index(GTI)
    • Add/Remove Liquidity
      • New Pool Creation
      • Add Liquidity
      • Remove Liquidity
    • Swap
  • Integration Level
    • You Integrate us
    • We Integrate you
    • Cross-Chain Smart Routing
  • Supported networks
  • How To
    • Setting Up a Wallet
      • Creating a New Wallet
      • Adding Networks to Metamask
      • Connecting Your Wallet
    • Swap
    • Add Liquidity
    • Remove Liquidity
  • Security
    • Audits
    • Bug Bounty
    • Deployed Contracts
  • TOKENOMICS & GOVERNANCE
    • Allocation & Lockups
    • Token Value Accrual
    • Fees
    • Governance Model
    • Proposals & Voting
  • Information
    • FAQ
Powered by GitBook
On this page
  • Stable Math
  • Invariant
  1. Protocol Level
  2. Liquidity Pools

Stable Pools

PreviousWeighted PoolsNextDynamic Weights

Last updated 2 years ago

Stable Pools are designed specifically for assets that are expected to consistently trade at or near parity, such as different varieties of stablecoins or synthetics. Stable Pools use Stable Math (based on StableSwap, popularized by Curve) which allows for significantly larger trades before encountering substantial price impact, vastly increasing capital efficiency for like-kind swaps.

Stable Math

Stable Math is designed to allow for swaps between any assets that have the same price, or are "pegged" to the same asset. The most common examples are stablecoins that track US Dollars (DAI, USDT, USDC), and assets that track the price of Ethereum or Bitcoin (WETH, WBTC). Prices are determined by the pool balances, the amplification parameter, and amounts of the tokens that are being swapped.

In an ideal scenario, it would make sense to simply allow 1-to-1 trades for these assets; this would be a Constant Sum curve. In a worst case scenario where one or more of these assets loses their peg and their value diverges, it would make sense to enforce trade rules for uncorrelated assets; this would be a Constant Product curve, such as the one in Weighted Math.

Since most cases are neither ideal nor disasters, the Stable Math curve combines the Constant Sum and Constant Product curves and is designed to facilitate approximately 1-to-1 trades that incur large price changes only when token balances differ greatly. The amplification parameter, AAA, defines the degree to which the Stable Math curve approximates the Constant Product curve (when A=0A=0A=0), or the Constant Sum curve (when Aā†’āˆžA\rightarrow \inftyAā†’āˆž).

Invariant

Since the Stable Math equation is quite complex, determining the invariant, DDD, is typically done iteratively. For an example of how to do this, please refer to .

Aā‹…nnā‹…āˆ‘xi+D=Aā‹…Dā‹…nn+Dn+1nnā‹…āˆxiA \cdot n^n \cdot \sum{x_i} +D = A \cdot D \cdot n^n + { \frac{D^{n+1}}{{n}^{n}\cdot \prod{x_i} } }Aā‹…nnā‹…āˆ‘xi​+D=Aā‹…Dā‹…nn+nnā‹…āˆxi​Dn+1​

Where:

  • nnn is the number of tokens.

  • xix_ixi​ is is balance of token iii.

  • AAA is the amplification parameter.

Text above is taken from docs.

this function
balancer.fi