Skip to main content
Helpful?

Pool

@uniswap/v3-sdk / Exports / Pool

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

NameTypeDefault valueDescription
tokenATokenundefinedOne of the tokens in the pool
tokenBTokenundefinedThe other token in the pool
feeFeeAmountundefinedThe fee in hundredths of a bips of the input amount of every swap that is collected by the pool
sqrtRatioX96BigintIshundefinedThe sqrt of the current ratio of amounts of token1 to token0
liquidityBigintIshundefinedThe current value of in range liquidity
tickCurrentnumberundefinedThe current tick of the pool
ticksTickDataProvider | (Tick | TickConstructorArgs)[]NO_TICK_DATA_PROVIDER_DEFAULTThe current state of the pool ticks or a data provider that can return tick data

Defined in

entities/pool.ts:70

Properties

_token0Price

Private Optional _token0Price: Price<Token, Token>

Defined in

entities/pool.ts:41


_token1Price

Private Optional _token1Price: Price<Token, Token>

Defined in

entities/pool.ts:42


fee

Readonly fee: FeeAmount

Defined in

entities/pool.ts:35


liquidity

Readonly liquidity: default

Defined in

entities/pool.ts:37


sqrtRatioX96

Readonly sqrtRatioX96: default

Defined in

entities/pool.ts:36


tickCurrent

Readonly tickCurrent: number

Defined in

entities/pool.ts:38


tickDataProvider

Readonly tickDataProvider: TickDataProvider

Defined in

entities/pool.ts:39


token0

Readonly token0: Token

Defined in

entities/pool.ts:33


token1

Readonly token1: Token

Defined in

entities/pool.ts:34

Accessors

chainId

get chainId(): number

Returns the chain ID of the tokens in the pool.

Returns

number

Defined in

entities/pool.ts:149


tickSpacing

get tickSpacing(): number

Returns

number

Defined in

entities/pool.ts:317


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

entities/pool.ts:109


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

entities/pool.ts:124

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

NameTypeDescription
outputAmountCurrencyAmount<Token>the output amount for which to quote the input amount
sqrtPriceLimitX96?defaultThe 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

entities/pool.ts:185


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

NameTypeDescription
inputAmountCurrencyAmount<Token>The input amount for which to quote the output amount
sqrtPriceLimitX96?defaultThe Q64.96 sqrt price limit

Returns

Promise<[CurrencyAmount<Token>, Pool]>

The output amount and the pool with updated state

Defined in

entities/pool.ts:159


involvesToken

involvesToken(token): boolean

Returns true if the token is either token0 or token1

Parameters

NameTypeDescription
tokenTokenThe token to check

Returns

boolean

True if token is either token0 or token

Defined in

entities/pool.ts:102


priceOf

priceOf(token): Price<Token, Token>

Return the price of the given token in terms of the other token in the pool.

Parameters

NameTypeDescription
tokenTokenThe token to return price of

Returns

Price<Token, Token>

The price of the given token, in terms of the other.

Defined in

entities/pool.ts:141


swap

Private swap(zeroForOne, amountSpecified, sqrtPriceLimitX96?): Promise<{ amountCalculated: default ; liquidity: default ; sqrtRatioX96: default ; tickCurrent: number }>

Executes a swap

Parameters

NameTypeDescription
zeroForOnebooleanWhether the amount in is token0 or token1
amountSpecifieddefaultThe amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)
sqrtPriceLimitX96?defaultThe 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<{ amountCalculated: default ; liquidity: default ; sqrtRatioX96: default ; tickCurrent: number }>

amountCalculated

sqrtRatioX96

liquidity

tickCurrent

Defined in

entities/pool.ts:215


getAddress

Static getAddress(tokenA, tokenB, fee, initCodeHashManualOverride?, factoryAddressOverride?): string

Parameters

NameType
tokenAToken
tokenBToken
feeFeeAmount
initCodeHashManualOverride?string
factoryAddressOverride?string

Returns

string

Defined in

entities/pool.ts:44

Helpful?