CLOB
CLOB Contract
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.