IOrderBook

AddLiquidityParamsarrow-up-right

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

RemoveLiquidityParamsarrow-up-right

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

AddLiquidityResponsearrow-up-right

RemoveLiquidityResponsearrow-up-right

ReplaySwapParamsarrow-up-right

ReplaySwapResponsearrow-up-right

MintCallbackDataarrow-up-right

addLiquidityarrow-up-right

Add liquidity logic

Only used by ClearingHouse contract

Parameters:arrow-up-right

Name
Type
Description

params

struct IOrderBook.AddLiquidityParams

Add liquidity params, detail on IOrderBook.AddLiquidityParams

Return Values:arrow-up-right

Name
Type
Description

response

struct IOrderBook.AddLiquidityResponse

Add liquidity response, detail on IOrderBook.AddLiquidityResponse

removeLiquidityarrow-up-right

Remove liquidity logic, only used by ClearingHouse contract

Parameters:arrow-up-right

Name
Type
Description

params

struct IOrderBook.RemoveLiquidityParams

Remove liquidity params, detail on IOrderBook.RemoveLiquidityParams

Return Values:arrow-up-right

Name
Type
Description

response

struct IOrderBook.RemoveLiquidityResponse

Remove liquidity response, detail on IOrderBook.RemoveLiquidityResponse

updateFundingGrowthAndLiquidityCoefficientInFundingPaymentarrow-up-right

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

Parameters:arrow-up-right

Name
Type
Description

trader

address

The trader address

baseToken

address

The base token address

fundingGrowthGlobal

struct Funding.Growth

The funding growth info, detail on Funding.Growth

Return Values:arrow-up-right

Name
Type
Description

liquidityCoefficientInFundingPayment

int256

the funding payment of all orders/liquidity of a maker

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:arrow-up-right

Name
Type
Description

params

struct IOrderBook.ReplaySwapParams

ReplaySwap params, detail on IOrderBook.ReplaySwapParams

Return Values:arrow-up-right

Name
Type
Description

response

struct IOrderBook.ReplaySwapResponse

The swap result encoded in ReplaySwapResponse

updateOrderDebtarrow-up-right

getOpenOrderIdsarrow-up-right

Get open order ids of a trader in the given market

Parameters:arrow-up-right

Name
Type
Description

trader

address

The trader address

baseToken

address

The base token address

Return Values:arrow-up-right

Name
Type
Description

orderIds

bytes32[]

The open order ids

getOpenOrderByIdarrow-up-right

Get open order info by given order id

Parameters:arrow-up-right

Name
Type
Description

orderId

bytes32

The order id

Return Values:arrow-up-right

Name
Type
Description

info

struct OpenOrder.Info

The open order info encoded in OpenOrder.Info

getOpenOrderarrow-up-right

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

Parameters:arrow-up-right

Name
Type
Description

trader

address

The trader address

baseToken

address

The base token address

upperTick

int24

The upper tick

lowerTick

int24

The lower tick

Return Values:arrow-up-right

Name
Type
Description

info

struct OpenOrder.Info

he open order info encoded in OpenOrder.Info

Check if the specified trader has order in given markets

Parameters:arrow-up-right

Name
Type
Description

trader

address

The trader address

tokens

address[]

The base token addresses

Return Values:arrow-up-right

Name
Type
Description

hasOrder

bool

True if the trader has order in given markets

getTotalQuoteBalanceAndPendingFeearrow-up-right

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

Parameters:arrow-up-right

Name
Type
Description

trader

address

The trader address

baseTokens

address[]

The base token addresses

Return Values:arrow-up-right

Name
Type
Description

totalQuoteAmountInPools

int256

The total quote token amount

totalPendingFee

uint256

The total pending fees in the orders

getTotalTokenAmountInPoolAndPendingFeearrow-up-right

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

Parameters:arrow-up-right

Name
Type
Description

trader

address

The trader address

baseToken

address

The base token addresses

fetchBase

bool

True if fetch base token amount, false if fetch quote token amount

Return Values:arrow-up-right

Name
Type
Description

tokenAmount

uint256

The total quote/base token amount

totalPendingFee

uint256

The total pending fees in the orders

getTotalOrderDebtarrow-up-right

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

Parameters:arrow-up-right

Name
Type
Description

trader

address

The trader address

baseToken

address

The base token address

fetchBase

bool

True if fetch base token amount, false if fetch quote token amount

Return Values:arrow-up-right

Name
Type
Description

debtAmount

uint256

The total debt token amount

getLiquidityCoefficientInFundingPaymentarrow-up-right

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:arrow-up-right

Name
Type
Description

liquidityCoefficientInFundingPayment

int256

the funding payment of all orders/liquidity of a maker

getPendingFeearrow-up-right

Get the pending fees of a order

Parameters:arrow-up-right

Name
Type
Description

trader

address

The trader address

baseToken

address

The base token address

lowerTick

int24

The lower tick

upperTick

int24

The upper tick

Return Values:arrow-up-right

Name
Type
Description

fee

uint256

The pending fees

Get Exchange contract address

Return Values:arrow-up-right

Name
Type
Description

exchange

address

The Exchange contract address

ExchangeChangedarrow-up-right

Emitted when the Exchange contract address changed

Parameters:arrow-up-right

Name
Type
Description

exchange

address

The address of exchange contract

Last updated

Was this helpful?