UNPKG

@pangolindex/sdk

Version:

🛠 An SDK for building applications on top of Pangolin.

133 lines (132 loc) • 5.39 kB
import { Percent, Price, TokenAmount } from '../../entities'; import JSBI from 'jsbi'; import { BigintIsh } from '../../constants'; import { ElixirPool } from './pool'; interface PositionConstructorArgs { pool: ElixirPool; tickLower: number; tickUpper: number; liquidity: BigintIsh; } /** * Represents a position on a Uniswap V3 Pool */ export declare class Position { readonly pool: ElixirPool; readonly tickLower: number; readonly tickUpper: number; readonly liquidity: JSBI; private _token0Amount; private _token1Amount; private _mintAmounts; /** * Constructs a position for a given pool with the given liquidity * @param pool For which pool the liquidity is assigned * @param liquidity The amount of liquidity that is in the position * @param tickLower The lower tick of the position * @param tickUpper The upper tick of the position */ constructor({ pool, liquidity, tickLower, tickUpper }: PositionConstructorArgs); /** * Returns the price of token0 at the lower tick */ get token0PriceLower(): Price; /** * Returns the price of token0 at the upper tick */ get token0PriceUpper(): Price; /** * Returns the amount of token0 that this position's liquidity could be burned for at the current pool price */ get amount0(): TokenAmount; /** * Returns the amount of token1 that this position's liquidity could be burned for at the current pool price */ get amount1(): TokenAmount; /** * Returns the lower and upper sqrt ratios if the price 'slips' up to slippage tolerance percentage * @param slippageTolerance The amount by which the price can 'slip' before the transaction will revert * @returns The sqrt ratios after slippage ====S */ private ratiosAfterSlippage; /** * Returns the minimum amounts that must be sent in order to safely mint the amount of liquidity held by the position * with the given slippage tolerance * @param slippageTolerance Tolerance of unfavorable slippage from the current price * @returns The amounts, with slippage */ mintAmountsWithSlippage(slippageTolerance: Percent): Readonly<{ amount0: JSBI; amount1: JSBI; }>; /** * Returns the minimum amounts that should be requested in order to safely burn the amount of liquidity held by the * position with the given slippage tolerance * @param slippageTolerance tolerance of unfavorable slippage from the current price * @returns The amounts, with slippage */ burnAmountsWithSlippage(slippageTolerance: Percent): Readonly<{ amount0: JSBI; amount1: JSBI; }>; /** * Returns the minimum amounts that must be sent in order to mint the amount of liquidity held by the position at * the current price for the pool */ get mintAmounts(): Readonly<{ amount0: JSBI; amount1: JSBI; }>; /** * Computes the maximum amount of liquidity received for a given amount of token0, token1, * and the prices at the tick boundaries. * @param pool The pool for which the position should be created * @param tickLower The lower tick of the position * @param tickUpper The upper tick of the position * @param amount0 token0 amount * @param amount1 token1 amount * @param useFullPrecision If false, liquidity will be maximized according to what the router can calculate, * not what core can theoretically support * @returns The amount of liquidity for the position */ static fromAmounts({ pool, tickLower, tickUpper, amount0, amount1, useFullPrecision }: { pool: ElixirPool; tickLower: number; tickUpper: number; amount0: BigintIsh; amount1: BigintIsh; useFullPrecision: boolean; }): Position; /** * Computes a position with the maximum amount of liquidity received for a given amount of token0, assuming an unlimited amount of token1 * @param pool The pool for which the position is created * @param tickLower The lower tick * @param tickUpper The upper tick * @param amount0 The desired amount of token0 * @param useFullPrecision If true, liquidity will be maximized according to what the router can calculate, * not what core can theoretically support * @returns The position */ static fromAmount0({ pool, tickLower, tickUpper, amount0, useFullPrecision }: { pool: ElixirPool; tickLower: number; tickUpper: number; amount0: BigintIsh; useFullPrecision: boolean; }): Position; /** * Computes a position with the maximum amount of liquidity received for a given amount of token1, assuming an unlimited amount of token0 * @param pool The pool for which the position is created * @param tickLower The lower tick * @param tickUpper The upper tick * @param amount1 The desired amount of token1 * @returns The position */ static fromAmount1({ pool, tickLower, tickUpper, amount1 }: { pool: ElixirPool; tickLower: number; tickUpper: number; amount1: BigintIsh; }): Position; } export {};