Class: Pool
Represents a V3 pool
Table of contents
Constructors
Properties
Accessors
Methods
Constructors
constructor
new Pool(tokenA
, tokenB
, fee
, sqrtRatioX96
, liquidity
, tickCurrent
, ticks?
)
Construct a pool
Parameters
Name | Type | Default value | Description |
---|---|---|---|
tokenA | Token | undefined | One of the tokens in the pool |
tokenB | Token | undefined | The other token in the pool |
fee | FeeAmount | undefined | The fee in hundredths of a bips of the input amount of every swap that is collected by the pool |
sqrtRatioX96 | BigintIsh | undefined | The sqrt of the current ratio of amounts of token1 to token0 |
liquidity | BigintIsh | undefined | The current value of in range liquidity |
tickCurrent | number | undefined | The current tick of the pool |
ticks | TickDataProvider | (Tick | TickConstructorArgs )[] | NO_TICK_DATA_PROVIDER_DEFAULT | The current state of the pool ticks or a data provider that can return tick data |
Defined in
Properties
_token0Price
Private,Optional
_token0Price: Price <Token, Token>
Defined in
_token1Price
Private,Optional
_token1Price: Price <Token, Token>
Defined in
fee
Readonly
fee: FeeAmount
Defined in
liquidity
Readonly
liquidity: default
Defined in
sqrtRatioX96
Readonly
sqrtRatioX96: default
Defined in
tickCurrent
Readonly
tickCurrent: number
Defined in
tickDataProvider
Readonly
tickDataProvider: TickDataProvider
Defined in
token0
Readonly
token0: Token
Defined in
token1
Readonly
token1: Token
Defined in
Accessors
chainId
get
chainId(): number
Returns the chain ID of the tokens in the pool.
Returns
number
Defined in
tickSpacing
get
tickSpacing(): number
Returns
number
Defined in
token0Price
get
token0Price(): Price <Token, Token>
Returns the current mid price of the pool in terms of token0, i.e. the ratio of token1 over token0
Returns
Price <Token, Token>
Defined in
token1Price
get
token1Price(): Price <Token, Token>
Returns the current mid price of the pool in terms of token1, i.e. the ratio of token0 over token1
Returns
Price <Token, Token>
Defined in
Methods
getInputAmount
getInputAmount(outputAmount
, sqrtPriceLimitX96?
): Promise <[CurrencyAmount <Token>
, Pool
]>
Given a desired output amount of a token, return the computed input amount and a pool with state updated after the trade
Parameters
Name | Type | Description |
---|---|---|
outputAmount | CurrencyAmount <Token> | the output amount for which to quote the input amount |
sqrtPriceLimitX96? | default | 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
Promise <[CurrencyAmount <Token>
, Pool
]>
The input amount and the pool with updated state
Defined in
getOutputAmount
getOutputAmount(inputAmount
, sqrtPriceLimitX96?
): Promise <[CurrencyAmount <Token>
, Pool
]>
Given an input amount of a token, return the computed output amount, and a pool with state updated after the trade
Parameters
Name | Type | Description |
---|---|---|
inputAmount | CurrencyAmount <Token> | The input amount for which to quote the output amount |
sqrtPriceLimitX96? | default | The Q64.96 sqrt price limit |
Returns
Promise <[CurrencyAmount <Token>
, Pool
]>
The output amount and the pool with updated state
Defined in
involvesToken
involvesToken(token
): boolean
Returns true if the token is either token0 or token1
Parameters
Name | Type | Description |
---|---|---|
token | Token | The token to check |
Returns
boolean
True if token is either token0 or token
Defined in
priceOf
priceOf(token
): Price <Token, Token>
Return the price of the given token in terms of the other token in the pool.
Parameters
Name | Type | Description |
---|---|---|
token | Token | The token to return price of |
Returns
Price <Token, Token>
The price of the given token, in terms of the other.