Position
Maintains information about a Position. Contains additional methods that aids in calculating liquidity and token amoutns for the purposes of creating or closing positions.
GitHub File: position.ts
Properties
Public
Property | Type | Modifier | Description |
---|---|---|---|
pool | readonly | The pool in which the position was created. | |
tickLower | number | readonly | The lower tick of the position. The position is out-of-range if the pool's active tick is below this. |
tickUpper | number | readonly | The upper tick of the position. The position is out-of-range if the pool's active tick is above this. |
liquidity | readonly | The current value of in-range liquidity. |
Private
Property | Type | Description |
---|---|---|
_token0Amount | CurrencyAmount<Token> | null | The position's token0 amount. Default is |
_token1Amount | CurrencyAmount<Token> | null | The position's token1 amount. Default is |
_mintAmounts | The amount of liquidity held by the position at the current price of the pool. |
Constructor
Parameters
Params | Type | Description |
---|---|---|
{} | An object that that contains the following:
|
Methods
token0PriceLower() - public
get
public
get
Returns the price of token0 at the position's lower tick quoted in terms of token1.
Returns
token0PriceUpper() - public
get
public
get
Returns the price of token0 at the position's upper tick quoted in terms of token1.
Returns
amount0() - public
get
public
get
Returns the position's token0 balance at the current price. This is the token0 amount that can be withdrawn if the NFT representing the position is burned.
Returns
Type | Description |
---|---|
The position's token0 balance at the current price. Denominated in the token0 currency format. |
amount1() - public
get
public
get
Returns the position's token1 balance at the current price. This is the token1 amount that can be withdrawn if the NFT representing the position is burned.
Returns
Type | Description |
---|---|
The position's token1 balance at the current price. Denominated in the token1 currency format. |
ratiosAfterSlippage() - private
private
Returns the lower and upper price boundaries given a slippage tolerance percentage value.
Parameters
Params | Type | Description |
---|---|---|
slippageTolerance | The % amount that the final executed price can differ from the expected price before the transaction will revert. |
Returns
Type | Description |
---|---|
{} |
mintAmountsWithSlippage() - public
public
Given a slippage tolerance percentage value, returns the minimum amount of each pool token that is required for the position to be safely created (i.e. mint the position NFT).
Parameters
Params | Type | Description |
---|---|---|
slippageTolerance | The % amount that the final executed price can differ from the expected price before the transaction will revert. |
Returns
Type | Description |
---|---|
ReadOnly<{}> |
burnAmountsWithSlippage() - public
public
Given a slippage tolerance percentage value, returns the minimum amount of each pool token that can be safely returned when the position is closed (i.e. burn the position NFT).
Parameters
Params | Type | Description |
---|---|---|
slippageTolerance | The % amount that the final executed price can differ from the expected price before the transaction will revert. |
Returns
Type | Description |
---|---|
ReadOnly<{}> |
mintAmounts() - public
get
public
get
Returns the minimum amount of each pool token that is required for the position to be safely created (i.e. mint the position NFT).
Returns
Type | Description |
---|---|
ReadOnly<{}> |
fromAmounts() - public
static
public
static
Given both token amounts and the position's tick range, calculates the maximum liquidity for the position being created. The result is returned as a new Position instance.
Parameters
Params | Type | Description |
---|---|---|
{} | object | An object consisting of:
|
Returns
Type | Description |
---|---|
Position | A new Position instance which consists of the max liquidity value. |
fromAmount0() - public
static
public
static
Given a token0 amount and the position's tick range, calculates the maximum liquidity for the position being created. Assumes an unlimited amount of token1. The result is returned as a new Position instance.
Parameters
Params | Type | Description |
---|---|---|
{} | object | An object consisting of:
|
Returns
Type | Description |
---|---|
Position | A new Position instance which consists of the max liquidity value. |
fromAmount1() - public
static
public
static
Given a token1 amount and the position's tick range, calculates the maximum liquidity for the position being created. Assumes an unlimited amount of token0. The result is returned as a new Position instance.
Note that the function uses the full precision to calculate the liquidity amount.
Parameters
Params | Type | Description |
---|---|---|
{} | object |
Returns
Type | Description |
---|---|
Position | A new Position instance which consists of the max liquidity value. |
Last updated