Quickswap Documentation
  • πŸ‰What is Quickswap?
  • Overview
    • ♻️Quickswap AMM
    • πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦Ecosystem Participants
    • ✨Key Features
    • πŸ”Swap
    • πŸ’¦Pools
    • πŸ‘¨β€πŸŒΎFarms
    • 🀝Bonds
    • βš–οΈPerps
    • 🐲Dragon's Lair
    • πŸ›οΈGovernance
    • πŸ—ΊοΈRoadmap
    • πŸ“²Social Media
    • πŸ“Contracts & Addresses
  • Tokens
    • πŸͺ™QUICK
    • πŸͺ™DD
  • Networks & Wallets
    • ⛓️Supported Chains
    • πŸ’³Supported Wallets
  • How To Guides
    • πŸ”How To Swap
      • ℹ️dLIMIT Guide
      • ℹ️dTWAP Guide
    • πŸ’§LP (Liquidity Providing)
    • πŸ‘©β€πŸŒΎFarm
    • πŸ₯©Stake
  • πŸ’»Technical Reference
    • πŸ‘©β€πŸ’»API
      • API Overview
      • Entities
      • Queries
    • πŸ“œSmart Contracts
      • 2️⃣V2
        • Factory
        • Pair
        • Pair (ERC-20)
        • Library
        • Router02
        • Router01
        • Common Errors
      • 3️⃣V3
        • Position Manager
        • Factory
        • Pool Deployer
        • Quoter
        • V3 Migrator
        • Farming Center
        • Limit Farming
        • Pool
        • Audits
    • ⌨️SDK
      • Getting Started
      • Token
      • Pair
      • Route
      • Trade
      • Fractions
      • Fetcher
      • Other Exports
    • ❔Guides
      • Interface Integration
        • Using the API
        • Query Parameters
        • Iframe Integration
      • Javascript SDK
        • SDK Quick start
        • Fetching Data
        • Pricing
        • Trading
        • Pair Addresses
      • Smart Contract Integration
        • Smart Contract Quick Start
        • Implement A Swap
        • Providing Liquidity
        • Building An Oracle
        • Flash Swaps
        • V2 Pair Addresses
        • Supporting Meta Transactions
        • V3 Pool Addresses
    • πŸ”ŽSubgraphs
    • ℹ️Glossary
    • πŸ“–Core Concepts
      • Swaps
      • Pools
      • Flash Swaps
      • Oracles
    • βš–οΈAdvanced Topics
      • Fees
      • Pricing
      • Understanding Returns
      • Security
      • Math
      • Research
Powered by GitBook
On this page
  • Example
  • Static Methods
  • getAddress
  • Properties
  • liquidityToken
  • token0
  • token1
  • reserve0
  • reserve1
  • Methods
  • reserveOf
  • getOutputAmount
  • getInputAmount
  • getLiquidityMinted
  • getLiquidityValue
  1. Technical Reference
  2. SDK

Pair

constructor(tokenAmountA: TokenAmount, tokenAmountB: TokenAmount)

The Pair entity represents a Uniswap pair with a balance of each of its pair tokens.

Example

import { ChainId, Token, TokenAmount, Pair } from '@uniswap/sdk'

const HOT = new Token(ChainId.MAINNET, '0xc0FFee0000000000000000000000000000000000', 18, 'HOT', 'Caffeine')
const NOT = new Token(ChainId.MAINNET, '0xDeCAf00000000000000000000000000000000000', 18, 'NOT', 'Caffeine')

const pair = new Pair(new TokenAmount(HOT, '2000000000000000000'), new TokenAmount(NOT, '1000000000000000000'))

Static Methods

getAddress

getAddress(tokenA: Token, tokenB: Token): string

Computes the pair address for the passed Tokens. See Pair Addresses.

Properties

liquidityToken

liquidityToken: Token

A Token representing the liquidity token for the pair. See Pair (ERC-20).

token0

token0: Token

See .

token1

token1: Token

See .

reserve0

reserve0: TokenAmount

The reserve of token0.

reserve1

reserve1: TokenAmount

The reserve of token1.

Methods

reserveOf

reserveOf(token: Token): TokenAmount

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

getOutputAmount

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

Pricing function for exact input amounts. Returns maximum output amount based on current reserves and the new Pair that would exist if the trade were executed.

getInputAmount

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

Pricing function for exact output amounts. Returns minimum input amount based on current reserves and the new Pair that would exist if the trade were executed.

getLiquidityMinted

getLiquidityMinted(totalSupply: TokenAmount, tokenAmountA: TokenAmount, tokenAmountB: TokenAmount): TokenAmount

Calculates the exact amount of liquidity tokens minted from a given amount of token0 and token1.

  • totalSupply must be looked up on-chain.

  • The value returned from this function cannot be used as an input to getLiquidityValue.

getLiquidityValue

getLiquidityValue(
  token: Token,
  totalSupply: TokenAmount,
  liquidity: TokenAmount,
  feeOn: boolean = false,
  kLast?: BigintIsh
): TokenAmount

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

  • 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.

PreviousTokenNextRoute
πŸ’»
⌨️