Skip to main content

OrderBookHelper

OrderBookHelper

Helpful view functions for OrderBookV2.

Addresses

ChainAddress
Arbitrum Sepolia0x9f517B144D1B9655E634Ab97f19C80cadf33F42B

Functions

constructor

constructor(contract OrderBookV2 _orderBook) public

getMinimumUserCollateral

Get an amount of user-supplied collateral, below which this order will definitely fail to execute. Unless order includes a DECREASE_SIZE or the trade fee rate changes, this amount also guarantees that the order will not run out of collateral. In other words, you can use it to find the collateral amount to submit for a simple order.

function getMinimumUserCollateral(
struct OrderBookV2.Action[] actions
) external view returns (
uint256 minimumCollateral
)
Dev note

More complicated orders will result in a number of constraints for each "group" of collateral inputs. Computing and usefully processing these are best done off-chain.

Parameters

NameTypeDescription
actionsstruct OrderBookV2.Action[]list of actions

Return Values

NameTypeDescription
minimumCollateraluint256minimum collateral submitted with the order

canExecute

Return whether the given orders are ready to execute.

function canExecute(
OrderId[] _orderIds
) external returns (
bool[] executable,
string[] errorStrings,
bytes[] errors
)
Dev note

Use callStatic; can't be a view function because getFundingRate may change state.

Parameters

NameTypeDescription
_orderIdsOrderId[]List of orders to be executed

Return Values

NameTypeDescription
executablebool[]For each order, true if its execution trigger is active; false if it isn't active or failed to evaluate.
errorStringsstring[]For each order, the error string (if any) emitted during trigger evaluation
errorsbytes[]For each order, the error bytes (if any) emitted during trigger evaluation

canCancel

Return whether the given orders can be canceled by addresses other than the owner. Note that the order's owner can always cancel it.

function canCancel(
OrderId[] _orderIds
) external returns (
bool[] cancelable,
string[] errorStrings,
bytes[] errors
)
Dev note

Use callStatic; can't be a view function because getFundingRate may change state.

Parameters

NameTypeDescription
_orderIdsOrderId[]List of orders to be canceled

Return Values

NameTypeDescription
cancelablebool[]For each order, true if its cancelation trigger is active; false if it isn't active or failed to evaluate.
errorStringsstring[]For each order, the error string (if any) emitted during trigger evaluation
errorsbytes[]For each order, the error bytes (if any) emitted during trigger evaluation

Variables

DONT_SKIP

Actions with skipIf==DONT_SKIP won't skip

uint256 DONT_SKIP = type(uint256).max;

SKIP

Actions with skipIf==SKIP skip without evaluating

uint256 SKIP = type(uint256).max - 1;

orderBook

domFiPerp