Pool

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

Code

BuniCornPool.sol

Address

See Pool Addresses.

Events

Mint

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

Emitted each time liquidity tokens are created via mint.

Burn

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

Emitted each time liquidity tokens are destroyed via burn.

Swap

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

Emitted each time a swap occurs via swap.

Sync

event Sync(uint256 vReserve0, uint256 vReserve1, uint256 reserve0, uint256 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.

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. Also returns the block.timestamp (mod 2**32) of the last block during which an interaction occured for the pair.

kLast

function kLast() external view returns (uint256);

Returns the product of the reserves as of the most recent liquidity event.

State-Changing Functions

mint

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

Creates pool tokens, which are sent to the to address.

  • 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(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata callbackData) external;

Swaps tokens.

  • Emits Swap, Sync.

skim

function skim(address to) external;

Gets actual token balances to match the reserve accounted balances reserve0 and reserve1.

sync

function sync() external;

Syncs virtual and actual reserve accounted balances with actual token balances.

  • Emits Sync.

Interface

pragma solidity 0.6.12;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

import "./IBuniCornFactory.sol";

interface IBuniCornPool {
    function mint(address to) external returns (uint256 liquidity);

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

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

    function sync() external;

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

    function getTradeInfo()
        external
        view
        returns (
            uint112 _vReserve0,
            uint112 _vReserve1,
            uint112 reserve0,
            uint112 reserve1,
            uint256 feeInPrecision
        );

    function token0() external view returns (IERC20);

    function token1() external view returns (IERC20);

    function ampBps() external view returns (uint32);

    function factory() external view returns (IBuniCornFactory);

    function kLast() external view returns (uint256);
}

Last updated