PowerMaker
  • PowerMaker Document Hub
  • Disclaimer
  • Resources
  • Quick Start
    • FAQ
    • Providing Liquidity
    • Tutorial: Perform a Trade
    • Tutorial: Providing Liquidity
    • Tutorial: Create a Market
  • Concepts
    • Power Perpetuals
      • PPT - Power Perpetual Token
    • Example Use Cases
      • Hedging Uniswap V3
  • Protocol
    • Overview
    • Capped Power Invariant
    • Understanding Returns
    • Security
    • Protocol Participants
    • Smart Contracts
      • Factory
      • Pair
      • ImmutableState
      • JumpRate
      • Lendgine
      • LendgineRouter
      • LiquidityManager
    • Deployed Contracts
  • Discord
  • Twitter
  • Github
Powered by GitBook
On this page
  • Code
  • Events
  • Mint
  • Burn
  • Swap
  • Errors
  • InvariantError
  • InsufficientOutputError
  • Read-only functions
  • reserve0
  • reserve1
  • totalLiquidity
  • invariant
  • State-changing functions
  • swap
  • mint
  • burn
  1. Protocol
  2. Smart Contracts

Pair

The pair smart contract is abstract and inherited by lendgine. They are separated for readability.

PreviousFactoryNextImmutableState

Last updated 2 years ago

Code

Events

Mint

event Mint(uint256 amount0In, uint256 amount1In, uint256 liquidity);

Emitted when liquidity is minted in the pair.

Burn

event Burn(uint256 amount0Out, uint256 amount1Out, uint256 liquidity, address indexed to);

Emitted when liquidity is burned in the pair.

Swap

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

Emitted when a swap occurs in the pair.

Errors

InvariantError

error InvariantError();

Occurs when an account takes an action and the resulting pair balances don't satisfy the invariant.

InsufficientOutputError

error InsufficientOutputError();

Occurs when the output of an actions is 0.

Read-only functions

reserve0

function reserve0() external view returns (uint120);

Returns the balance of the token0 reserves held in the automated market maker.

reserve1

function reserve1() external view returns (uint120);

Returns the balance of the token1 reserves held in the automated market maker.

totalLiquidity

function totalLiquidity() external view returns (uint256);

Returns the total amount of liquidity currently held in the automated market maker.

invariant

function invariant(uint256 amount0, uint256 amount1, uint256 liquidity) external view returns (bool);

Implements the capped power invariant and returns true if the invariant is satisfied by the parameters.

State-changing functions

swap

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

Swaps tokens. Sends the amounts out to the to address. A callback is called and data is passed back.

mint

function mint(uint256 liquidity, bytes calldata data) internal;

Mints liquidity. A calback is called and data is passed back.

burn

function burn(address to, uint256 liquidity) internal returns (uint256 amount0, uint256 amount1);

Burns liquidity.

Pair.sol