IOrderBook

AddLiquidityParams

  struct AddLiquidityParams(
    address trader
    address baseToken
    uint256 base
    uint256 quote
    int24 lowerTick
    int24 upperTick
    struct Funding.Growth fundingGrowthGlobal
  )

RemoveLiquidityParams

  struct RemoveLiquidityParams(
    address maker
    address baseToken
    int24 lowerTick
    int24 upperTick
    uint128 liquidity
  )

AddLiquidityResponse

  struct AddLiquidityResponse(
    uint256 base
    uint256 quote
    uint256 fee
    uint128 liquidity
  )

RemoveLiquidityResponse

  struct RemoveLiquidityResponse(
    uint256 base
    uint256 quote
    uint256 fee
    int256 takerBase
    int256 takerQuote
  )

ReplaySwapParams

  struct ReplaySwapParams(
    address baseToken
    bool isBaseToQuote
    bool shouldUpdateState
    int256 amount
    uint160 sqrtPriceLimitX96
    uint24 exchangeFeeRatio
    uint24 uniswapFeeRatio
    struct Funding.Growth globalFundingGrowth
    address pool
    uint24 insuranceFundFeeRatio
  )

ReplaySwapResponse

  struct ReplaySwapResponse(
    int24 tick
    uint256 fee
    uint256 insuranceFundFee
  )

MintCallbackData

  struct MintCallbackData(
    address trader
    address pool
  )

Functions

addLiquidity

  function addLiquidity(
    struct IOrderBook.AddLiquidityParams params
  ) external returns (struct IOrderBook.AddLiquidityResponse response)

Add liquidity logic

Only used by ClearingHouse contract

Parameters:

Return Values:

removeLiquidity

  function removeLiquidity(
    struct IOrderBook.RemoveLiquidityParams params
  ) external returns (struct IOrderBook.RemoveLiquidityResponse response)

Remove liquidity logic, only used by ClearingHouse contract

Parameters:

Return Values:

updateFundingGrowthAndLiquidityCoefficientInFundingPayment

  function updateFundingGrowthAndLiquidityCoefficientInFundingPayment(
    address trader,
    address baseToken,
    struct Funding.Growth fundingGrowthGlobal
  ) external returns (int256 liquidityCoefficientInFundingPayment)

This is the non-view version of getLiquidityCoefficientInFundingPayment(), only can be called by Exchange contract

Parameters:

Return Values:

replaySwap

  function replaySwap(
    struct IOrderBook.ReplaySwapParams params
  ) external returns (struct IOrderBook.ReplaySwapResponse response)

Replay the swap and get the swap result (price impact and swap fee), only can be called by Exchange contract;

ReplaySwapResponse.insuranceFundFee = fee * insuranceFundFeeRatio

Parameters:

Return Values:

updateOrderDebt

  function updateOrderDebt(
  ) external

getOpenOrderIds

  function getOpenOrderIds(
    address trader,
    address baseToken
  ) external returns (bytes32[] orderIds)

Get open order ids of a trader in the given market

Parameters:

Return Values:

getOpenOrderById

  function getOpenOrderById(
    bytes32 orderId
  ) external returns (struct OpenOrder.Info info)

Get open order info by given order id

Parameters:

Return Values:

getOpenOrder

  function getOpenOrder(
    address trader,
    address baseToken,
    int24 upperTick,
    int24 lowerTick
  ) external returns (struct OpenOrder.Info info)

Get open order info by given base token, upper tick and lower tick

Parameters:

Return Values:

hasOrder

  function hasOrder(
    address trader,
    address[] tokens
  ) external returns (bool hasOrder)

Check if the specified trader has order in given markets

Parameters:

Return Values:

getTotalQuoteBalanceAndPendingFee

  function getTotalQuoteBalanceAndPendingFee(
    address trader,
    address[] baseTokens
  ) external returns (int256 totalQuoteAmountInPools, uint256 totalPendingFee)

Get the total quote token amount and pending fees of all orders in given markets

Parameters:

Return Values:

getTotalTokenAmountInPoolAndPendingFee

  function getTotalTokenAmountInPoolAndPendingFee(
    address trader,
    address baseToken,
    bool fetchBase
  ) external returns (uint256 tokenAmount, uint256 totalPendingFee)

Get the total token amount (quote or base) and pending fees of all orders in the given market

Parameters:

Return Values:

getTotalOrderDebt

  function getTotalOrderDebt(
    address trader,
    address baseToken,
    bool fetchBase
  ) external returns (uint256 debtAmount)

Get the total debt token amount (base or quote) of all orders in the given market

Parameters:

Return Values:

getLiquidityCoefficientInFundingPayment

  function getLiquidityCoefficientInFundingPayment(
  ) external returns (int256 liquidityCoefficientInFundingPayment)

Get the pending funding payment of all orders in the given market

This is the view version of updateFundingGrowthAndLiquidityCoefficientInFundingPayment(), so only part of the funding payment will be returned. Use it with caution because it does not return all the pending funding payment of orders. Normally you won't need to use this function

Return Values:

getPendingFee

  function getPendingFee(
    address trader,
    address baseToken,
    int24 lowerTick,
    int24 upperTick
  ) external returns (uint256 fee)

Get the pending fees of a order

Parameters:

Return Values:

getExchange

  function getExchange(
  ) external returns (address exchange)

Get Exchange contract address

Return Values:

Events

ExchangeChanged

  event ExchangeChanged(
    address exchange
  )

Emitted when the Exchange contract address changed

Parameters:

Last updated