lotus-v4-sdk
Version:
⚒️ An SDK for building applications on top of Lotus V4
145 lines (144 loc) • 6.27 kB
TypeScript
import { BigintIsh, Percent, Price, CurrencyAmount, Currency } from '@uniswap/sdk-core';
import JSBI from 'jsbi';
import { Pool } from './pool';
import { AllowanceTransferPermitBatch } from '../PositionManager';
interface PositionConstructorArgs {
pool: Pool;
liquidity: BigintIsh;
tickLower: number;
tickUpper: number;
}
/**
* Represents a position on a Uniswap V4 Pool
* @dev Similar to the V3 implementation
* - using Currency instead of Token
* - keep in mind that Pool and liquidity must be fetched from the pool manager
*/
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<Currency, Currency>;
/**
* Returns the price of token0 at the upper tick
*/
get token0PriceUpper(): Price<Currency, Currency>;
/**
* Returns the amount of token0 that this position's liquidity could be burned for at the current pool price
*/
get amount0(): CurrencyAmount<Currency>;
/**
* Returns the amount of token1 that this position's liquidity could be burned for at the current pool price
*/
get amount1(): CurrencyAmount<Currency>;
/**
* 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 maximum amount of token0 and token1 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
* @dev In v4, minting and increasing is protected by maximum amounts of token0 and token1.
*/
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;
}>;
/**
* Returns the AllowanceTransferPermitBatch for adding liquidity to a position
* @param slippageTolerance The amount by which the price can 'slip' before the transaction will revert
* @param spender The spender of the permit (should usually be the PositionManager)
* @param nonce A valid permit2 nonce
* @param deadline The deadline for the permit
*/
permitBatchData(slippageTolerance: Percent, spender: string, nonce: BigintIsh, deadline: BigintIsh): AllowanceTransferPermitBatch;
/**
* 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 amountzw
* @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 {};