UNPKG

@pangolindex/sdk

Version:

🛠 An SDK for building applications on top of Pangolin.

85 lines (84 loc) • 4.36 kB
import { Price, Token, TokenAmount } from '../../entities'; import { BigintIsh } from '../../constants'; import JSBI from 'jsbi'; import { FeeAmount } from '../constants'; import { Tick, TickConstructorArgs } from './tick'; import { TickDataProvider } from './tickDataProvider'; /** * Represents a V3 pool */ export declare class ElixirPool { readonly token0: Token; readonly token1: Token; readonly fee: FeeAmount; readonly initialFee: FeeAmount; readonly sqrtRatioX96: JSBI; readonly liquidity: JSBI; readonly tickCurrent: number; readonly tickDataProvider: TickDataProvider; private _token0Price?; private _token1Price?; static getAddress(tokenA: Token, tokenB: Token, fee: FeeAmount, initCodeHashManualOverride?: string, factoryAddressOverride?: string): string; /** * Construct a pool * @param tokenA One of the tokens in the pool * @param tokenB The other token in the pool * @param fee The fee in hundredths of a bips of the input amount of every swap that is collected by the pool * @param initialFee The initialFee in hundredths of a bips of the input amount of every swap that is collected by the pool * @param sqrtRatioX96 The sqrt of the current ratio of amounts of token1 to token0 * @param liquidity The current value of in range liquidity * @param tickCurrent The current tick of the pool * @param ticks The current state of the pool ticks or a data provider that can return tick data */ constructor(tokenA: Token, tokenB: Token, fee: FeeAmount, initialFee: FeeAmount, sqrtRatioX96: BigintIsh, liquidity: BigintIsh, tickCurrent: number, ticks?: TickDataProvider | (Tick | TickConstructorArgs)[]); /** * Returns true if the token is either token0 or token1 * @param token The token to check * @returns True if token is either token0 or token */ involvesToken(token: Token): boolean; /** * Returns the current mid price of the pool in terms of token0, i.e. the ratio of token1 over token0 */ get token0Price(): Price; /** * Returns the current mid price of the pool in terms of token1, i.e. the ratio of token0 over token1 */ get token1Price(): Price; /** * Return the price of the given token in terms of the other token in the pool. * @param token The token to return price of * @returns The price of the given token, in terms of the other. */ priceOf(token: Token): Price; /** * Returns the chain ID of the tokens in the pool. */ get chainId(): number; /** * Given an input amount of a token, return the computed output amount, and a pool with state updated after the trade * @param inputAmount The input amount for which to quote the output amount * @param sqrtPriceLimitX96 The Q64.96 sqrt price limit * @returns The output amount and the pool with updated state */ getOutputAmount(inputAmount: TokenAmount, sqrtPriceLimitX96?: JSBI): Promise<[TokenAmount, ElixirPool]>; /** * Given a desired output amount of a token, return the computed input amount and a pool with state updated after the trade * @param outputAmount the output amount for which to quote the input amount * @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this value after the swap. If one for zero, the price cannot be greater than this value after the swap * @returns The input amount and the pool with updated state */ getInputAmount(outputAmount: TokenAmount, sqrtPriceLimitX96?: JSBI): Promise<[TokenAmount, ElixirPool]>; /** * Executes a swap * @param zeroForOne Whether the amount in is token0 or token1 * @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative) * @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this value after the swap. If one for zero, the price cannot be greater than this value after the swap * @returns amountCalculated * @returns sqrtRatioX96 * @returns liquidity * @returns tickCurrent */ private swap; get tickSpacing(): number; }