OrderBookHelper
OrderBookHelper
Helpful view functions for OrderBookV2.
Addresses
Chain | Address |
---|---|
Arbitrum Sepolia | 0x9f517B144D1B9655E634Ab97f19C80cadf33F42B |
Zircuit | 0x24A075e53c85650383B116CEE90FC5D3e6FC668b |
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
)
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
Name | Type | Description |
---|---|---|
actions | struct OrderBookV2.Action[] | list of actions |
Return Values
Name | Type | Description |
---|---|---|
minimumCollateral | uint256 | minimum 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
)
Use callStatic
; can't be a view function because getFundingRate
may change state.
Parameters
Name | Type | Description |
---|---|---|
_orderIds | OrderId[] | List of orders to be executed |
Return Values
Name | Type | Description |
---|---|---|
executable | bool[] | For each order, true if its execution trigger is active; false if it isn't active or failed to evaluate. |
errorStrings | string[] | For each order, the error string (if any) emitted during trigger evaluation |
errors | bytes[] | 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
)
Use callStatic
; can't be a view function because getFundingRate
may change state.
Parameters
Name | Type | Description |
---|---|---|
_orderIds | OrderId[] | List of orders to be canceled |
Return Values
Name | Type | Description |
---|---|---|
cancelable | bool[] | For each order, true if its cancelation trigger is active; false if it isn't active or failed to evaluate. |
errorStrings | string[] | For each order, the error string (if any) emitted during trigger evaluation |
errors | bytes[] | 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;