🕊️
DoveSwap
  • 👋Welcome to DoveSwap
  • 🕊️Overview
  • Concepts
    • 💡Ecosystem Participants
    • ✨Glossary
    • 🧠Core Concepts
      • Swaps
      • Pools
      • Flash Swaps
      • Oracles
    • 🔬Advanced Concepts
      • Fees
      • Pricing
      • Understanding Returns
  • 📖Guides
    • 📈Swapping tokens
    • 💰Adding Liquidity
  • 🛠️Technical Reference
    • Smart Contracts
      • Factory
      • Pair
      • Pair (ERC-20)
      • Library
      • Router
    • Governance
Powered by GitBook
On this page
  • 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​
  1. Technical Reference
  2. Smart Contracts

Pair

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

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;

Functions as a recovery mechanism in case enough tokens are sent to an pair to overflow the two uint112 storage slots for reserves, which could otherwise cause trades to fail. skim() allows a user to withdraw the difference between the current balance of the pair and 2**112−1 to the caller, if that difference is greater than 0

sync​

function sync() external;

Functions as a recovery mechanism in the case that a token asynchronously deflates the balance of a pair. In this case, trades will receive sub-optimal rates, and if no liquidity provider is willing to rectify the situation, the pair is stuck. sync() exists to set the reserves of the contract to the current balances, providing a somewhat graceful recoveryfrom this situation

  • Emits Sync.

PreviousFactoryNextPair (ERC-20)

Last updated 2 years ago

🛠️