UNPKG

thena-v3-sdk

Version:

⚒️ An SDK for building applications on top of Thena V3 Fusion

132 lines (131 loc) 5.37 kB
import { BigintIsh, Percent, Price, CurrencyAmount, Token } from 'thena-sdk-core'; import JSBI from 'jsbi'; import { Pool } from './pool'; interface PositionConstructorArgs { pool: Pool; tickLower: number; tickUpper: number; liquidity: BigintIsh; } /** * Represents a position on a Thena Fusion Pool */ export declare class Position { readonly pool: Pool; 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<Token, Token>; /** * Returns the price of token0 at the upper tick */ get token0PriceUpper(): Price<Token, Token>; /** * Returns the amount of token0 that this position's liquidity could be burned for at the current pool price */ get amount0(): CurrencyAmount<Token>; /** * Returns the amount of token1 that this position's liquidity could be burned for at the current pool price */ get amount1(): CurrencyAmount<Token>; /** * 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 */ 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: Pool; 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: Pool; 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: Pool; tickLower: number; tickUpper: number; amount1: BigintIsh; }): Position; } export {};