Skip to content

Latest commit

 

History

History
369 lines (207 loc) · 8.92 KB

File metadata and controls

369 lines (207 loc) · 8.92 KB

@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

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

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

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

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

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

entities/pool.ts:159


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

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

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.

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

Name Type Description
zeroForOne boolean Whether the amount in is token0 or token1
amountSpecified default The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)
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<{ 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

Name Type
tokenA Token
tokenB Token
fee FeeAmount
initCodeHashManualOverride? string
factoryAddressOverride? string

Returns

string

Defined in

entities/pool.ts:44