ICLOB
CLOB Interface
Structs & Enums
PostLimitOrderArgs
amountInBaseLots
: The size of the order, measured in base lots.priceInTicks
: The price of the order, expressed in ticks (quote lots per base unit).cancelTimestamp
: Unix timestamp after which the order is automatically canceled; ignored if set to 0.side
: Defined in theSide
enum:limitOrderType
: Defined in the LimitOrderType enum.settlement
: Defined in the Settlement enum.
PostLimitOrderResult
orderId
: A unique identifier for the submitted order.amountPostedInBaseLots
: The amount of the order that was successfully posted to the order book, measured in base lots.quoteTokenAmountTradedInAtoms
: The amount of quote tokens traded, measured in atoms; negative if outgoing, positive if incoming, and includes fees.baseTokenAmountTradedInAtoms
: The amount of base tokens traded, measured in atoms; negative if outgoing, positive if incoming.
PostFillOrderArgs
amountInBaseLots
: The size of the fill order, measured in base lots.priceInTicks
: The price of the fill order, expressed in ticks.side
: Defined in theSide
enum:fillOrderType
: Defined in the FillOrderType enum.settlement
: Defined in the Settlement enum.
PostFillOrderResult
orderId
: A unique identifier for the fill order.amountFilledInBaseLots
: The amount of the order that was successfully filled, measured in base lots.quoteTokenAmountTradedInAtoms
: The amount of quote tokens traded, measured in atoms; negative if outgoing, positive if incoming, and includes fees.baseTokenAmountTradedInAtoms
: The amount of base tokens traded, measured in atoms; negative if outgoing, positive if incoming.
ReduceArgs
orderId
: The unique identifier of the order to be reduced.amountInBaseLots
: The amount by which the order should be reduced, measured in base lots.settlement
: Defined in the Settlement enum.
CancelArgs
orderIds
: An array of unique identifiers for the orders to be canceled.settlement
: Defined in the Settlement enum.
Settlement
INSTANT
: Immediate token transfers upon cancel, reduce, or trade execution.ACCOUNT
: Updates internal account balances within the CLOB contracts without immediate token transfers.
LimitOrderType
GOOD_TILL_CANCELLED
: Orders remain in the book until filled or canceled.POST_ONLY
: Orders are added only if they do not immediately match.
FillOrderType
FILL_OR_KILL
: Orders are filled immediately, completely or not at all.IMMEDIATE_OR_CANCEL
: Orders are filled immediately if possible, with any remaining portion canceled.
Events
Deposit
account
: The address of the account making the deposit.token
: The address of the token being deposited.amountInAtoms
: The amount of the token being deposited, measured in atoms.
Withdraw
account
: The address of the account making the withdrawal.token
: The address of the token being withdrawn.amountInAtoms
: The amount of the token being withdrawn, measured in atoms.
LimitOrderSubmitted
orderId
: A unique identifier for the submitted order.amountInBaseLots
: The size of the order, measured in base lots.priceInTicks
: The price level of the order, expressed in ticks.cancelTimestamp
: Unix timestamp after which the order is automatically canceled; ignored if set to 0.side
: The side of the order. EitherBUY
orSELL
.limitOrderType
: Defined in the LimitOrderType enum.settlement
: Defined in the Settlement enum.owner
: The address of the account submitting the order.
LimitOrderProcessed
orderId
: A unique identifier for the processed order.amountPostedInBaseLots
: The amount of the order that was successfully posted to the order book, measured in base lots.quoteTokenAmountTradedInAtoms
: The amount of quote tokens traded, measured in atoms; negative if outgoing, positive if incoming, and includes fees.baseTokenAmountTradedInAtoms
: The amount of base tokens traded, measured in atoms; negative if outgoing, positive if incoming.
FillOrderSubmitted
orderId
: A unique identifier for the submitted order.amountInBaseLots
: The size of the order, measured in base lots.priceInTicks
: The price level of the order, expressed in ticks.side
: The side of the order. EitherBUY
orSELL
.fillOrderType
: Defined in the FillOrderType enum.settlement
: Defined in the Settlement enum.owner
: The address of the account submitting the order.
FillOrderProcessed
orderId
: A unique identifier for the processed order.amountFilledInBaseLots
: The amount of the order that was successfully filled, measured in base lots.quoteTokenAmountTradedInAtoms
: The amount of quote tokens traded, measured in atoms; negative if outgoing, positive if incoming, and includes fees.baseTokenAmountTradedInAtoms
: The amount of base tokens traded, measured in atoms; negative if outgoing, positive if incoming.
OrderMatched
makerOrderId
: A unique identifier for the maker order.takerOrderId
: A unique identifier for the taker order.amountInBaseLots
: The size of the fill, measured in base lots.priceInTicks
: The price level of the fill, expressed in ticks.makerSide
: The side of the maker order. EitherBUY
orSELL
.maker
: The address of the maker.taker
: The address of the taker.
OrderReduced
orderId
: A unique identifier for the reduced order.newAmountInBaseLots
: The new amount of the order, measured in base lots.refundAmountInBaseLots
: The amount of the order that was refunded, measured in base lots.settlement
: Defined in the Settlement enum.
OrderCanceled
orderId
: A unique identifier for the canceled order.owner
: The address of the account canceling the order.quoteTokenRefundedInAtoms
: The amount of quote tokens refunded, measured in atoms.baseTokenRefundedInAtoms
: The amount of base tokens refunded, measured in atoms.settlement
: Defined in the Settlement enum.
CancelFailed
orderId
: A unique identifier for the canceled order.owner
: The address of the account canceling the order.
Functions
deposit
Allows a user to deposit a specified amount of a token into their account on the CLOB platform. The function checks if the token is valid and if the user has approved the contract to transfer the specified amount. If the token is the quote token, it updates the user’s quote token balance; otherwise, it updates the base token balance.
Parameters
Type | Name | Description |
---|---|---|
address | token | The address of the token to be deposited. |
uint256 | amount | The amount of the token to be deposited. |
Events
Reverts
InsufficientTokenApproved
: If the user has not approved enough tokens for the contract to transfer.
withdraw
Allows a user to withdraw a specified amount of a token from their account on the CLOB platform. The function checks if the token is valid and if the user has sufficient balance. If the token is the quote token, it updates the user’s quote token balance; otherwise, it updates the base token balance.
Parameters
Type | Name | Description |
---|---|---|
address | token | The address of the token to be withdrawn. |
uint256 | amount | The amount of the token to be withdrawn. |
Events
Reverts
InsufficientTokenBalance
: If the user does not have enough balance to withdraw the specified amount.
postLimitOrder
Submits a limit order to the CLOB platform. The order will be matched and filled against existing orders in the order book as much as possible. Any unmatched portion of the order will be added to the order book. For GOOD_TILL_CANCELLED
orders, the unmatched portion remains in the book until filled or canceled, while POST_ONLY
orders are added only if they do not immediately match, ensuring no taker fees are incurred. The function returns details about the order’s execution, including the amount posted and the tokens traded.
Parameters
Type | Name | Description |
---|---|---|
PostLimitOrderArgs | args | A struct containing the order details, including amount, price, side, and settlement type. |
Return Values
Type | Description |
---|---|
PostLimitOrderResult | A struct containing the order ID, amount posted, and the amounts of quote and base tokens traded. |
Events
Reverts
PostOnlyOrderWouldBeFilled
: If a post-only order would be immediately filled.MaxOrdersInBookPostNotCompetitive
: If the order book is full and the new order is not competitive enough to replace an existing order.
postFillOrder
Submits a fill order to the CLOB platform. This order attempts to match existing orders in the order book immediately.
For a FILL_OR_KILL
order, the order must be immediately completely filled or not at all. For an IMMEDIATE_OR_CANCEL
order, the order immediately fills as much as possible and any remaining amount is not added to the order book.
The function returns details about the order’s execution, including the amount filled and the tokens traded.
Parameters
Type | Name | Description |
---|---|---|
PostFillOrderArgs | args | A struct containing the order details, including amount, price, side, and settlement type. |
Return Values
Type | Description |
---|---|
PostFillOrderResult | A struct containing the order ID, amount filled, and the amounts of quote and base tokens traded. |
Events
Reverts
FOKNotFilled
: If a fill-or-kill order is not completely filled.
reduce
Reduces the amount of an existing order on the CLOB platform. This function allows the order owner to decrease the order size, and it returns the amount of tokens refunded as a result of the reduction.
Parameters
Type | Name | Description |
---|---|---|
ReduceArgs | args | A struct containing the order ID, amount to reduce, and settlement type. |
Return Values
Type | Description |
---|---|
uint256 | The amount of tokens refunded in atoms as a result of the order reduction. |
Events
Reverts
ReduceAmountOutOfBounds
: If the reduction amount is zero or exceeds the order’s current amount.UnauthorizedReduce
: If the caller is not the owner of the order.
cancel
Cancels one or more existing orders on the CLOB platform. This function allows the order owner to cancel their orders and receive a refund of the tokens. It returns the total amounts of quote and base tokens refunded.
Parameters
Type | Name | Description |
---|---|---|
CancelArgs | args | A struct containing the order IDs to cancel and the settlement type. |
Return Values
Type | Description |
---|---|
uint256 | The total amount of quote tokens refunded in atoms. |
uint256 | The total amount of base tokens refunded in atoms. |
Events
Reverts
UnauthorizedCancel
: If the caller is not the owner of the order.
Getter Functions
getQuoteToken
Retrieves the quote token used in the CLOB platform.
Return Values
Type | Description |
---|---|
IERC20 | The address of the quote token. |
getBaseToken
Retrieves the base token used in the CLOB platform.
Return Values
Type | Description |
---|---|
IERC20 | The address of the base token. |
getMarketConfig
Retrieves the market configuration settings for the CLOB platform.
Return Values
Type | Description |
---|---|
MarketConfig | A struct containing market settings. |
getTokenConfig
Retrieves the token configuration settings for the CLOB platform.
Return Values
Type | Description |
---|---|
TokenConfig | A struct containing token settings. |
getOpenInterest
Retrieves the current open interest for both quote and base tokens in the CLOB platform.
Return Values
Type | Description |
---|---|
uint256 | The open interest of quote tokens in atoms. |
uint256 | The open interest of base tokens in atoms. |
getOrder
Retrieves the details of a specific order by its unique identifier.
Parameters
Type | Name | Description |
---|---|---|
uint256 | orderId | The unique identifier of the order. |
Return Values
Type | Description |
---|---|
Order | A struct containing order details. |
getTOB
Retrieves the top of book prices for both bid and ask sides (the highest bid and lowest ask).
Return Values
Type | Description |
---|---|
uint256 | The highest bid price in ticks. |
uint256 | The lowest ask price in ticks. |
getLimit
Retrieves the limit level details at a specific price level for a given side.
Parameters
Type | Name | Description |
---|---|---|
uint256 | priceInTicks | The price level in ticks. |
Side | side | The side of the order (BUY or SELL). |
Return Values
Type | Description |
---|---|
Limit | A struct containing limit details. |
getNumBids
Retrieves the total number of bid orders currently in the order book.
Return Values
Type | Description |
---|---|
uint256 | The number of bid orders. |
getNumAsks
Retrieves the total number of ask orders currently in the order book.
Return Values
Type | Description |
---|---|
uint256 | The number of ask orders. |
getNextBiggestTick
Retrieves the next biggest price tick for a given side in the order book.
Parameters
Type | Name | Description |
---|---|---|
uint256 | priceInTicks | The current price level in ticks. |
Side | side | The side of the order (BUY or SELL). |
Return Values
Type | Description |
---|---|
uint256 | The next biggest price tick. |
getNextSmallestTick
Retrieves the next smallest price tick for a given side in the order book.
Parameters
Type | Name | Description |
---|---|---|
uint256 | priceInTicks | The current price level in ticks. |
Side | side | The side of the order (BUY or SELL). |
Return Values
Type | Description |
---|---|
uint256 | The next smallest price tick. |
getOrders
Retrieves a list of orders starting from a specific order ID.
Parameters
Type | Name | Description |
---|---|---|
uint256 | startOrderId | The starting order ID. |
uint256 | numOrders | The number of orders to retrieve. |
Return Values
Type | Description |
---|---|
Order[] | An array of order structs. |
getQuoteTokenAccountBalance
Retrieves the quote token balance of a specific account.
Parameters
Type | Name | Description |
---|---|---|
address | account | The address of the account. |
Return Values
Type | Description |
---|---|
uint256 | The quote token balance in atoms. |
getBaseTokenAccountBalance
Retrieves the base token balance of a specific account.
Parameters
Type | Name | Description |
---|---|---|
address | account | The address of the account. |
Return Values
Type | Description |
---|---|
uint256 | The base token balance in atoms. |
getNextOrderId
Retrieves the next order ID that will be assigned to a new order on the CLOB platform.
Return Values
Type | Description |
---|---|
uint256 | The next order ID. |
getFactory
Retrieves the address of the factory associated with the CLOB platform.
Return Values
Type | Description |
---|---|
address | The address of the factory. |
getFactoryOwner
Retrieves the owner of the factory associated with the CLOB platform.
Return Values
Type | Description |
---|---|
address | The address of the factory owner. |
getFeeRecipient
Retrieves the address designated to receive fees on the CLOB platform.
Return Values
Type | Description |
---|---|
address | The address of the fee recipient. |