MatchingEngine
Last updated
Last updated
The MatchingEngine
contract is an on-chain matching engine for executing orders. It allows users to trade assets using limit and market orders.
Name | Type | Description |
---|---|---|
OrderCanceled
Event emitted when an order is canceled.
Name | Type | Description |
---|---|---|
OrderMatched
Event emitted when an order is matched.
PairAdded
Event emitted when a trading pair is added to the orderbook.
initialize
Initializes the matching engine with the orderbook factory and listing requirements.
Requirements:
The caller must have the DEFAULT_ADMIN_ROLE
.
setListingFee
Sets the listing requirements.
Requirements:
The caller must have the DEFAULT_ADMIN_ROLE
.
setOrderbookFactory
Sets the address of the orderbook factory.
Requirements:
The caller must have the DEFAULT_ADMIN_ROLE
.
setMembership
Sets the address of the membership contract.
membership_(address)
: Address of the membership contract.
Requirements:
The caller must have the DEFAULT_ADMIN_ROLE
.
setAccountant
Sets the address of the accountant contract.
accountant_(address)
: Address of the accountant contract.
Requirements:
The caller must have the DEFAULT_ADMIN_ROLE
.
setFee
Sets the fee numerator and denominator of trading.
feeNum_(uint256)
: The numerator of the fee fraction.
feeDenom_(uint256)
: The denominator of the fee fraction.
Requirements:
The caller must have the DEFAULT_ADMIN_ROLE
.
The fee numerator and denominator must be valid.
setFeeTo
Sets the fee recipient.
feeTo_(address)
: Address of the fee recipient.
Requirements:
The caller must have the DEFAULT_ADMIN_ROLE
.
marketBuy
Executes a market buy order, buying the base asset using the quote asset at the best available price in the orderbook up to n
orders, and makes an order at the market price.
true
if the order was successfully executed, otherwise false
.
marketSell
Executes a market sell order, selling the base asset for the quote asset at the best available price in the orderbook up to n
orders, and makes an order at the market price.
true
if the order was successfully executed, otherwise false
.
limitBuy
Executes a limit buy order, places a limit order in the orderbook for buying the base asset using the quote asset at a specified price, and makes an order at the limit price.
true
if the order was successfully executed, otherwise false
.
limitSell
Executes a limit sell order, places a limit order in the orderbook for selling the base asset for the quote asset at a specified price, and makes an order at the limit price.
true
if the order was successfully executed, otherwise false
.
makeBuy
Stores a bid order in the orderbook for the base asset using the quote asset, with a specified price at
.
true
if the order was successfully executed, otherwise false
.
makeSell
Stores an ask order in the orderbook for the quote asset using the base asset, with a specified price at
.
true
if the order was successfully executed, otherwise false
.
addPair
Creates an orderbook for a new trading pair and returns its address.
book
: The address of the newly created orderbook.
cancelOrder
Cancels an order in an orderbook by the given order ID and order type.
true
if the order was successfully canceled, otherwise false
.
getOrderbookById
Returns the address of the orderbook with the given ID.
The address of the orderbook.
getBaseQuote
Returns the base and quote asset addresses for the given orderbook.
getFee
Returns the fee numerator and denominator.
Returns:
numerator(uint256)
: The fee numerator.
denominator(uint256)
: The fee denominator.
getFeeTo
Returns the address of the fee recipient.
Returns:
The address of the fee recipient.
getOrderbookFactory
Returns the address of the orderbook factory contract.
Returns:
The address of the orderbook factory contract.
getListingFee
Returns the listing fee token address and amount.
Returns:
feeToken(address)
: The address of the listing fee token.
feeAmount(uint256)
: The listing fee token amount.
getMembership
Returns the address of the membership contract.
Returns:
The address of the membership contract.
getAccountant
Returns the address of the accountant contract.
Returns:
The address of the accountant contract.
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Parameter | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Parameter | Type | Description |
---|---|---|
Parameter | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Parameter | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|