Skip to main content

Pair

Imported types#

Token#

type Token {
chainId: ChainId!
address: String!
currency: Currency!
}

TokenAmount#

type TokenAmount {
token: Token!
amount: String! # UInt256!
}

Query schemas#

pairAddress#

Returns address of pair liquidity token contract.

pairAddress(
token0: Token!
token1: Token!
): String!

pairLiquidityToken#

Returns pair liquidity token.

pairLiquidityToken(
pair: Pair!
): Token!

pairReserves#

Returns reserves for pair tokens in sorted order.

pairReserves(
pair: Pair!
): [TokenAmount!]!

pairToken0Price#

Returns the current mid price of the pair in terms of token0, i.e. the ratio of reserve1 to reserve0.

pairToken0Price(
pair: Pair!
): String!

pairToken1Price#

Returns the current mid price of the pair in terms of token1, i.e. the ratio of reserve0 to reserve1.

pairToken1Price(
pair: Pair!
): String!

pairOutputAmount#

Pricing function for exact input amounts. Returns maximum output amount, based on current reserves, if the trade were executed.

pairOutputAmount(
pair: Pair!
inputAmount: TokenAmount!
): TokenAmount!

pairOutputNextPair#

Pricing function for exact input amounts. Returns next pair state, based on current reserves, if the trade were executed.

pairOutputNextPair(
pair: Pair!
inputAmount: TokenAmount!
): Pair!

pairInputNextPair#

Pricing function for exact output amounts. Returns next pair state, based on current reserves, if the trade were executed.

pairInputNextPair(
pair: Pair!
inputAmount: TokenAmount!
): Pair!

pairInputAmount#

Pricing function for exact output amounts. Returns minimum input amount, based on current reserves, if the trade were executed.

pairInputAmount(
pair: Pair!
outputAmount: TokenAmount!
): TokenAmount!

pairLiquidityMinted#

Calculates the exact amount of liquidity tokens minted from a given amount of token0 and token1. totalSupply is total supply of pair liquidity token. totalSupply must be looked up on-chain. The value returned from this function cannot be used as an input to getLiquidityValue.

pairLiquidityMinted(
pair: Pair!
totalSupply: TokenAmount!
tokenAmount0: TokenAmount!
tokenAmount1: TokenAmount!
): TokenAmount

pairLiquidityMinted#

Calculates the exact amount of token0 or token1 that the given amount of liquidity tokens represent. totalSupply is total supply of pair liquidity token. totalSupply must be looked up on-chain. If the protocol charge is on, feeOn must be set to true, and kLast must be provided from an on-chain lookup. Values returned from this function cannot be used as inputs to getLiquidityMinted.

pairLiquidityValue(
pair: Pair!
totalSupply: TokenAmount!
liquidity: TokenAmount!
feeOn: Boolean
kLast: BigInt
): [TokenAmount!]!