Options
All
  • Public
  • Public/Protected
  • All
Menu

An implementation of a math behind stableswap pools.

Hierarchy

  • StableswapCalculator

Implements

Index

Constructors

Properties

mintTokensInvariantIterations: number = 0

The same as swapInvariantIterations but for adding liquidity.

pool: Pool
swapInvariantIterations: number = 0

Keeps the amount of iteration used to calculate invariant in the last call to getSwapGrossAmountReceived or getSwapAmountDeposited. Needed to calculate transaction fee.

Accessors

Methods

  • _getPrice(decimalLiqA: number, decimalLiqB: number, retries: number): number
  • Price is calculated by simulating a swap for 10**6 of micro values. This price is highly inaccurate for low liquidity pools. In case of ConvergenceError we try to simulate a swap using a different swap amount. Returns NaN if all retries will fail.

    Parameters

    • decimalLiqA: number
    • decimalLiqB: number
    • retries: number

    Returns number

  • getAmplifier(): bigint
  • getMintedLiquidityTokens(addedLiqA: bigint, addedLiqB: bigint): bigint
  • getPrice(decimalLiqA: number, decimalLiqB: number): number
  • getSwapAmountDeposited(liqA: bigint, liqB: bigint, grossAmountReceived: bigint, saveIterations?: boolean): bigint
  • getSwapGrossAmountReceived(liqA: bigint, liqB: bigint, amountDeposited: bigint, saveIterations?: boolean): bigint

Generated using TypeDoc