Skip to main content
Version: V1

Pool

The Pool entity represents a token pair with a balance of each of its tokens.

Source Code

constructor(
address: string,
tokenAmountA: TokenAmount,
tokenAmountB: TokenAmount,
virtualTokenAmountA: TokenAmount,
virtualTokenAmountB: TokenAmount,
fee: JSBI,
amp: JSBI

Methods#

reserveOf#

Returns reserve0 or reserve1, depending on whether token0 or token1 is passed in.

reserveOf(token: Token): TokenAmount

virtualReserveOf#

Returns virtual reserve0 or reserve1, depending on whether token0 or token1 is passed in.

reserveOf(token: Token): TokenAmount

getOutputAmount#

Returns maximum output amount based on current pool and the new balances of the pools if the trade were executed.

getOutputAmount(inputAmount: TokenAmount):
[TokenAmount, TokenAmount[]]

getInputAmount#

Returns minimum input amount based on current reserves and the new balances of the tokens in the respective pools

getInputAmount(
outputAmount: TokenAmount):
[TokenAmount, TokenAmount[]]

getLiquidityMinted#

calculates the exact amount of liquidity tokens minted.

  • totalSupply requires on-chain lookup.
  • The value returned from this function cannot be used as an input to getLiquidityValue.
getLiquidityMinted(
totalSupply: TokenAmount,
tokenAmountA: TokenAmount,
tokenAmountB: TokenAmount
): TokenAmount

getLiquidityValue#

Calculates the exact amount of token0 or token1 that the given amount of liquidity tokens represent.

  • totalSupply, kLast involves on-chain lookup.
  • Values returned from this function cannot be used as inputs to getLiquidityMinted.
getLiquidityValue(
token: Token,
totalSupply: TokenAmount,
liquidity: TokenAmount,
feeBps: JSBI = ZERO,
kLast?: BigintIsh
): TokenAmount

Static Methods#

involvesToken#

Returns true if the token is either token0 or token1

involvesToken(token: Token): boolean

priceOf#

Returns the price of the given token in terms of the other token in the pair.

priceOf(token: Token): Price

reserve0#

returns token0 amount of the reserve.

reserve0: TokenAmount

virtualReserve0#

returns virtual token0 amount of virtual reserve.

virtaulReserve1: TokenAmount

reserve1#

returns token1 amount of the reserve.

reserve1: TokenAmount

virtualReserve1#

returns virtual token1 amount of virtual reserve.

virtaulReserve1: TokenAmount