RCPSwap
  • Introduction
  • Protocol Overview
    • How Uniswap works
    • Ecosystem Participants
    • Smart Contract
      • Factory
      • Pair
      • Pair (ERC-20)
      • Library
      • Router02
    • Glossary
  • Core Concepts
    • Swaps
    • Pools
    • Flash Swaps
    • Oracles
  • Advanced Topics
    • Fees
    • Pricing
    • Understanding Returns
    • Security
    • Math
    • Research
Powered by GitBook
On this page
  • Code
  • Events
  • Approval
  • Transfer
  • Read-Only Functions
  • name
  • symbol
  • decimals
  • totalSupply
  • balanceOf
  • allowance
  • DOMAIN_SEPARATOR
  • PERMIT_TYPEHASH
  • nonces
  • State-Changing Functions
  • approve
  • transfer
  • transferFrom
  • permit
  • Interface
  • ABI
  1. Protocol Overview
  2. Smart Contract

Pair (ERC-20)

PreviousPairNextLibrary

Last updated 2 years ago

This documentation covers ERC-20 functionality for denominating pool tokens. For Uniswap-specific functionality, see .

Code

Events

Approval

event Approval(address indexed owner, address indexed spender, uint value);Copy

Emitted each time an approval occurs via or .

Transfer

event Transfer(address indexed from, address indexed to, uint value);Copy

Emitted each time a transfer occurs via , , mint, or burn.

Read-Only Functions

name

function name() external pure returns (string memory);Copy

Returns Uniswap V2 for all pairs.

symbol

function symbol() external pure returns (string memory);Copy

Returns UNI-V2 for all pairs.

decimals

function decimals() external pure returns (uint8);Copy

Returns 18 for all pairs.

totalSupply

function totalSupply() external view returns (uint);Copy

Returns the total amount of pool tokens for a pair.

balanceOf

function balanceOf(address owner) external view returns (uint);Copy

Returns the amount of pool tokens owned by an address.

allowance

function allowance(address owner, address spender) external view returns (uint);Copy

DOMAIN_SEPARATOR

function DOMAIN_SEPARATOR() external view returns (bytes32);Copy

PERMIT_TYPEHASH

function PERMIT_TYPEHASH() external view returns (bytes32);Copy

nonces

function nonces(address owner) external view returns (uint);Copy

State-Changing Functions

approve

function approve(address spender, uint value) external returns (bool);Copy

Lets msg.sender set their allowance for a spender.

transfer

function transfer(address to, uint value) external returns (bool);Copy

Lets msg.sender send pool tokens to an address.

transferFrom

function transferFrom(address from, address to, uint value) external returns (bool);Copy

Sends pool tokens from one address to another.

  • Requires approval.

permit

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

Sets the allowance for a spender where approval is granted via a signature.

Interface

import '@uniswap/v2-core/contracts/interfaces/IUniswapV2ERC20.sol';Copy
pragma solidity >=0.5.0;interface IUniswapV2ERC20 {  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;}Copy

ABI

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

Returns the amount of liquidity tokens owned by an address that a spender is allowed to transfer via .

Returns a domain separator for use in .

Returns a typehash for use in .

Returns the current nonce for an address for use in .

Emits .

Emits .

Emits .

See .

Emits .

Pair
UniswapV2ERC20.sol
approve
permit
transfer
transferFrom
transferFrom
permit
permit
permit
Approval
Transfer
Transfer
Using Permit
Approval