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
  • Code
  • Address
  • Events
  • Mint
  • Burn
  • Swap
  • Sync
  • Read-Only Functions
  • MINIMUM_LIQUIDITY
  • factory
  • token0
  • token1
  • getReserves
  • price0CumulativeLast
  • price1CumulativeLast
  • kLast
  • State-Changing Functions
  • mint
  • burn
  • swap
  • skim
  • sync
  • Interface
  • ABI
  1. Technical Reference
  2. Smart Contracts
  3. V2

Pair

PreviousFactoryNextPair (ERC-20)

This documentation covers Uniswap-specific functionality. For ERC-20 functionality, see Pair (ERC-20).

Code

Address

See Pair Addresses.

Events

Mint

event Mint(address indexed sender, uint amount0, uint amount1);

Emitted each time liquidity tokens are created via mint.

Burn

event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);

Emitted each time liquidity tokens are destroyed via burn.

Swap

event Swap(
  address indexed sender,
  uint amount0In,
  uint amount1In,
  uint amount0Out,
  uint amount1Out,
  address indexed to
);

Emitted each time a swap occurs via swap.

Sync

event Sync(uint112 reserve0, uint112 reserve1);

Emitted each time reserves are updated via mint, burn, swap, or sync.

Read-Only Functions

MINIMUM_LIQUIDITY

function MINIMUM_LIQUIDITY() external pure returns (uint);

Returns 1000 for all pairs. See Minimum Liquidity.

factory

function factory() external view returns (address);

Returns the factory address.

token0

function token0() external view returns (address);

Returns the address of the pair token with the lower sort order.

token1

function token1() external view returns (address);

Returns the address of the pair token with the higher sort order.

getReserves

function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);

Returns the reserves of token0 and token1 used to price trades and distribute liquidity. See Pricing. Also returns the block.timestamp (mod 2**32) of the last block during which an interaction occured for the pair.

price0CumulativeLast

function price0CumulativeLast() external view returns (uint);

See Oracles.

price1CumulativeLast

function price1CumulativeLast() external view returns (uint);

See Oracles.

kLast

function kLast() external view returns (uint);

Returns the product of the reserves as of the most recent liquidity event. See Protocol Charge Calculation.

State-Changing Functions

mint

function mint(address to) external returns (uint liquidity);

Creates pool tokens.

  • Emits Mint, Sync, Transfer.

burn

function burn(address to) external returns (uint amount0, uint amount1);

Destroys pool tokens.

  • Emits Burn, Sync, Transfer.

swap

function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;

Swaps tokens. For regular swaps, data.length must be 0. Also see Flash Swaps.

  • Emits Swap, Sync.

skim

function skim(address to) external;

See the whitepaper.

sync

function sync() external;

See the whitepaper.

  • Emits Sync.

Interface

import '@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol';
pragma solidity >=0.5.0;

interface IUniswapV2Pair {
  event Approval(address indexed owner, address indexed spender, uint value);
  event Transfer(address indexed from, address indexed to, uint value);

  function name() external pure returns (string memory);
  function symbol() external pure returns (string memory);
  function decimals() external pure returns (uint8);
  function totalSupply() external view returns (uint);
  function balanceOf(address owner) external view returns (uint);
  function allowance(address owner, address spender) external view returns (uint);

  function approve(address spender, uint value) external returns (bool);
  function transfer(address to, uint value) external returns (bool);
  function transferFrom(address from, address to, uint value) external returns (bool);

  function DOMAIN_SEPARATOR() external view returns (bytes32);
  function PERMIT_TYPEHASH() external pure returns (bytes32);
  function nonces(address owner) external view returns (uint);

  function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;

  event Mint(address indexed sender, uint amount0, uint amount1);
  event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
  event Swap(
      address indexed sender,
      uint amount0In,
      uint amount1In,
      uint amount0Out,
      uint amount1Out,
      address indexed to
  );
  event Sync(uint112 reserve0, uint112 reserve1);

  function MINIMUM_LIQUIDITY() external pure returns (uint);
  function factory() external view returns (address);
  function token0() external view returns (address);
  function token1() external view returns (address);
  function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
  function price0CumulativeLast() external view returns (uint);
  function price1CumulativeLast() external view returns (uint);
  function kLast() external view returns (uint);

  function mint(address to) external returns (uint liquidity);
  function burn(address to) external returns (uint amount0, uint amount1);
  function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
  function skim(address to) external;
  function sync() external;
}

ABI

import IUniswapV2Pair from '@uniswap/v2-core/build/IUniswapV2Pair.json'

πŸ’»
πŸ“œ
2️⃣
UniswapV2Pair.sol
https://unpkg.com/@uniswap/v2-core@1.0.0/build/IUniswapV2Pair.json