@uniswap/v3-sdk / Exports / Pool
Represents a V3 pool
• new Pool(tokenA
, tokenB
, fee
, sqrtRatioX96
, liquidity
, tickCurrent
, ticks?
)
Construct a pool
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 |
• Private
Optional
_token0Price: Price
<Token
, Token
>
• Private
Optional
_token1Price: Price
<Token
, Token
>
• Readonly
fee: FeeAmount
• Readonly
liquidity: default
• Readonly
sqrtRatioX96: default
• Readonly
tickCurrent: number
• Readonly
tickDataProvider: TickDataProvider
• Readonly
token0: Token
• Readonly
token1: Token
• get
chainId(): number
Returns the chain ID of the tokens in the pool.
number
• get
tickSpacing(): number
number
• 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
Price
<Token
, Token
>
• 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
Price
<Token
, Token
>
â–¸ 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
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 |
Promise
<[CurrencyAmount
<Token
>, Pool
]>
The input amount and the pool with updated state
â–¸ 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
Name | Type | Description |
---|---|---|
inputAmount |
CurrencyAmount <Token > |
The input amount for which to quote the output amount |
sqrtPriceLimitX96? |
default |
The Q64.96 sqrt price limit |
Promise
<[CurrencyAmount
<Token
>, Pool
]>
The output amount and the pool with updated state
â–¸ involvesToken(token
): boolean
Returns true if the token is either token0 or token1
Name | Type | Description |
---|---|---|
token |
Token |
The token to check |
boolean
True if token is either token0 or token
â–¸ priceOf(token
): Price
<Token
, Token
>
Return the price of the given token in terms of the other token in the pool.
Name | Type | Description |
---|---|---|
token |
Token |
The token to return price of |
Price
<Token
, Token
>
The price of the given token, in terms of the other.
â–¸ Private
swap(zeroForOne
, amountSpecified
, sqrtPriceLimitX96?
): Promise
<{ amountCalculated
: default
; liquidity
: default
; sqrtRatioX96
: default
; tickCurrent
: number
}>
Executes a swap
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 |
Promise
<{ amountCalculated
: default
; liquidity
: default
; sqrtRatioX96
: default
; tickCurrent
: number
}>
amountCalculated
sqrtRatioX96
liquidity
tickCurrent
â–¸ Static
getAddress(tokenA
, tokenB
, fee
, initCodeHashManualOverride?
, factoryAddressOverride?
): string
Name | Type |
---|---|
tokenA |
Token |
tokenB |
Token |
fee |
FeeAmount |
initCodeHashManualOverride? |
string |
factoryAddressOverride? |
string |
string