IOrderbook
This interface defines the functions that can be called on the Orderbook contract. These functions provide various operations related to initializing the orderbook, managing orders, retrieving orderbook information, and executing trades.
Functions
initialize
initialize
Initializes the orderbook with the specified ID, base asset, quote asset, and engine address.
Parameters
id
uint256
The ID of the orderbook.
base_
address
The address of the base asset in the pair.
quote_
address
The address of the quote asset in the pair.
engine_
address
The address of the engine contract.
fpop
fpop
Removes and returns the first order from the orderbook at the specified price.
Parameters
isBid
bool
Flag indicating whether the order is a bid (true) or ask (false).
price
uint256
The price at which the order is placed.
Returns
orderId
uint256
The ID of the removed order.
setLmp
setLmp
Sets the last matched price (LMP) of the orderbook.
Parameters
lmp
uint256
The last matched price.
mktPrice()
mktPrice()
Retrieves the market price of the orderbook.
Returns
mktPrice
uint256
The market price of the orderbook.
assetValue
assetValue
Converts the specified amount of base or quote asset to its corresponding value in the other asset.
Parameters
amount
uint256
The amount of the asset to convert.
isBid
bool
Flag indicating whether the asset is a bid asset (true) or ask asset (false).
Returns
converted
uint256
The converted value of the asset.
isEmpty
isEmpty
Checks if the orderbook at the specified price is empty.
Parameters
isBid
bool
Flag indicating whether the orderbook is a bid orderbook (true) or ask orderbook (false).
price
uint256
The price at which to check.
Returns
isEmpty
bool
Flag indicating if the orderbook at the specified price is empty.
getRequired
getRequired
Retrieves the required amount to execute the specified order at the given price.
Parameters
isBid
bool
Flag indicating whether the order is a bid (true) or ask (false).
price
uint256
The price at which the order is placed.
orderId
uint256
The ID of the order.
Returns
required
uint256
The required amount to execute the order.
placeAsk
placeAsk
Places an ask order in the orderbook with the specified owner, price, and amount.
Parameters
owner
address
The address of the order owner.
price
uint256
The price at which to place the ask order.
amount
uint256
The amount of the ask order.
placeBid
placeBid
Places a bid order in the orderbook with the specified owner, price, and amount.
Parameters
owner
address
The address of the order owner.
price
uint256
The price at which to place the ask order.
amount
uint256
The amount of the ask order.
cancelOrder
cancelOrder
Cancels the specified order in the orderbook.
Parameters
orderId
uint256
The ID of the order to cancel.
isBid
bool
Flag indicating whether the order is a bid (true) or ask (false).
owner
address
The address of the order owner.
Returns
remaining
uint256
The remaining amount of the canceled order.
base
address
The address of the base asset of the canceled order.
quote
address
The address of the quote asset of the canceled order.
execute
execute
Executes the specified order at the given price and amount.
Parameters
orderId
uint256
The ID of the order to execute.
isBid
bool
Flag indicating whether the order is a bid (true) or ask (false).
price
uint256
The price at which to execute the order.
sender
address
The address of the sender executing the order.
amount
uint256
The amount to execute.
Returns
owner
address
The address of the order owner.
heads()
heads()
Retrieves the head of the bid and ask orderbooks.
Returns
bidHead
uint256
The head of the bid orderbook.
askHead
uint256
The head of the ask orderbook.
askHead()
askHead()
Retrieves the head of the ask orderbook.
Returns
askHead
uint256
The head of the ask orderbook.
bidHead()
bidHead()
Retrieves the head of the bid orderbook.
Returns
bidHead
uint256
The head of the bid orderbook.
getPrices
getPrices
Retrieves the prices from the orderbook.
Parameters
isBid
bool
Flag indicating whether to retrieve prices from the bid orderbook (true) or ask orderbook (false).
n
uint256
The number of prices to retrieve.
Returns
prices
uint256[] memory
An array of prices retrieved from the orderbook.
getOrders
getOrders
Retrieves the orders from the orderbook at the specified price.
Parameters
isBid
bool
Flag indicating whether to retrieve orders from the bid orderbook (true) or ask orderbook (false).
price
uint256
The price at which to retrieve orders.
n
uint256
The number of orders to retrieve.
Returns
orders
NewOrderOrderbook.Order[] memory
An array of orders from the orderbook.
getOrder
getOrder
Retrieves the order from the orderbook with the specified ID.
Parameters
isBid
bool
Flag indicating whether to retrieve the order from the bid orderbook (true) or ask orderbook (false).
orderId
uint256
The ID of the order to retrieve.
Returns
order
NewOrderOrderbook.Order
The order from the orderbook.
getOrderIds
getOrderIds
Retrieves the order IDs from the orderbook at the specified price.
Parameters
isBid
bool
Flag indicating whether to retrieve order IDs from the bid orderbook (true) or ask orderbook (false).
price
uint256
The price at which to retrieve order IDs.
n
uint256
The number of order IDs to retrieve.
Returns
orderIds
uint256[] memory
An array of order IDs from the orderbook.
Last updated