Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
The Order Book is a module for the order book and fund management over module accounts and actors.
The Order Book module has the following parameters:
Max order book participation: maximum allowed participation count of an order book.
Batch Settlement Count: Automatic batch settlement count in each block.
Requeue Threshold: This is a defined value for resetting the fulfillment queue if liquidity is less than this value.
The proto for the params are as follows:
Defines the way in which the state of the Order book is being stored in the chain.
The OrderBook message is used to store the data of a particular order book in the blockchain. The OrderBook entity consists of the following fields:
uid
: The UID of the order book.
participation_count
: The count of participation in this book.
odds_count
: Count of odds registered in the market related to this book.
status
: the status of the book.
The proto for the Order Book messages is as follows:
The BookParticipation message is used to store the data of a particular participation in the OrderBook in the blockchain. The BookParticipation entity consists of the following fields:
index
: The sequential index of participation in a book.
order_book_uid
: The uinque identifier of the OrderBook.
participant_address
: The account address of the participant.
liquidity
: The amount of participation minus fees.
current_round_liquidity
: Participations are calculated in multiple rounds depending on the payout amount.
exposures_not_filled
: The count of exposures that are not filled till now.
total_bet_amount
: Total value of bet amount that is calculated from the payout.
current_round_total_bet_amount
: Total value of bet amount in the current round calculations.
max_loss
: Maximum possible loss of participation.
current_round_max_loss_odds_uid
: UID list of odds with maximum calculated loss.
actual_profit
: The pure profit that goes to the participant account balance.
is_settled
: Show whether the participation is settled or not.
The proto for the Order Book messages is as follows:
The ParticipationBetPair message is used to store the data of a particular participation and bet in the OrderBook in the blockchain. The ParticipationBetPair entity consists of the following fields:
order_book_uid
: The uinque identifier of the OrderBook.
participant_index
: The index of participation in a book.
bet_uid
: True unique identifier of bet that payout was done from participation.
The BookOddsExposure message is used to store the data of a particular exposure of odds in the OrderBook in the blockchain. The BookOddsExposure entity consists of the following fields:
order_book_uid
: The uinque identifier of the OrderBook.
odds_uid
: The unique identifier of the odds.
fulfillment_queue
: The queue of bet fulfillment for the odds exposure.
The ParticipationExposure message is used to store the data of a particular exposure of participation in the OrderBook in the blockchain. The ParticipationExposure entity consists of the following fields:
order_book_uid
: The uinque identifier of the OrderBook.
odds_uid
: The unique identifier of the Odds.
participation_index
: The index of participation in the Order book.
exposure
: The exposure is the payout that should be done.
bet_amount
: The calculated bet amount of the expected payout.
is_fulfilled
: Fulfillment status of the exposure.
round
: Current round of calculation of exposures.
The OrderBookStats message is used to store the statistics data of Order Books in the blockchain. The OrderBookStats entity consists of the following fields:
resolved_unsettled
: The list of resolved markets that have unsettled bets.
Purpose
The purpose of this lock is to maintain idempotency in the system. The payout lock checks for idempotency whenever an exported keeper function of the module is invoked by any other module. It follows the following conditions:
While wagering
If a payout lock (or bet UID) exists in the store, then the wager request is rejected, inferring that the bet has already been placed in the blockchain with the same bet UID.
If the payout lock does not exist, then the wager request is accepted and a payout lock with the bet UID of the bet is stored in the blockchain.
While bet settlement
If the payout lock does not exist in the store, then the bet settlement request is rejected.
If the payout lock exists, then the bet settlement request is accepted, the settlement is processed, and the payout is deleted from the store.
The main logic of the Order Book module definitions and methods.
There are several steps for a deposit to be made:
Create an Order Book for the market.
For each odds UID of the market, Set exposures for the order book in the state
Set order book in the state.
There are several steps for a deposit to be made:
Get the market and order book and validate if it is allowed to add more participation.
Transfer the fee to the house fee collector module account.
Transfer liquidity to the order book liquidity pool module account.
Set participation for the order book in the state.
For each odds exposure of the order book:
Append the index to the fulfillment queue of the order book odds exposure item.
Set the order book odds exposures in the state.
Set participation exposure in the state.
Set the order book in the state.
There are several steps for a deposit to be made:
Get order book participation and validate it.
Calculate the maximum amount that can be transferred:
According to the withdrawal mode, transfer the requested amount from the liquidity module.
Set participation currentRoundLiquidity
and liquidity
in the state.
For each odds exposure, set the fulfillment queue item at the start of the queue and set it in the state.
There are several steps for a deposit to be made:
Get the OrderBook, Participations, Odds Exposures, and Particpation Exposures.
Refine book exposures fulfillment queue one by one:
Get queue item participation.
Calculate available liquidity by multiplying the maxLossMultiplier of the selected odds by the current round liquidity amount minus participation exposure.
If there is no available liquidity:
Set the participation exposure as fulfilled.
Remove queue item.
If the available liquidity is less than the payout that should be paid:
Fulfill the bet with available liquidity (all of the liquidity will be consumed).
Set the participation exposure as fulfilled.
Remove queue item.
There is more liquidity available than the payout that should be paid:
If the requeue threshold is not being met:
Set the participation exposure as fulfilled.
Remove queue item.
Fulfill the bet with the payout amount that should be paid.
Set Participations exposures in the state.
Set the updated fulfillment queue into the book exposure.
Transfer bet fee to bet fee collector module account.
Transfer the calculated fulfilled bet amount to the order book liquidity pool module account.
Order book module, module accounts definition.
The Order Book module has one module account which is as follows:
Book Liquidity Account
Name: orderbook_liquidity_pool
This account holds the liquidity of the books and bets amount and payout of all accounts.
Order Book module CLI.
This section specifies the queries, transactions, and required payloads. By following this section, one can get a deep understanding of the functioning of the orderbook
module in the SGE Network chain.
The below table explains the details of the argument required for the above query:
The below table explains the details of the argument required for the above query:
The below table explains the details of the argument required for the above query:
The below table explains the details of the argument required for the above query:
The below table explains the details of the argument required for the above query:
The below table explains the details of the argument required for the above query:
Params | Description | Type | Validation | Example |
---|---|---|---|---|
Params | Description | Type | Validation | Example |
---|---|---|---|---|
Params | Description | Type | Validation | Example |
---|---|---|---|---|
Params | Description | Type | Validation | Example |
---|---|---|---|---|
Params | Description | Type | Validation | Example |
---|---|---|---|---|
Params | Description | Type | Validation | Example |
---|---|---|---|---|
order-book-id
uuid of the order book
string
Required
Valid UUID
0435e5b6-635f-11ed-90a6-bb470175dfce
order-book-id
uuid of the order book
string
Required
Valid UUID
0435e5b6-635f-11ed-90a6-bb470175dfce
order-book-id
uuid of the order book
string
Required
Valid UUID
0435e5b6-635f-11ed-90a6-bb470175dfce
participation-index
index of the participation
uint64
Required
Positive Number
1
order-book-id
uuid of the order book
string
Required
Valid UUID
0435e5b6-635f-11ed-90a6-bb470175dfce
order-book-id
uuid of the order book
string
Required
Valid UUID
0435e5b6-635f-11ed-90a6-bb470175dfce
odds-uid
uuid of the odds
string
Required
Valid UUID
0435e5b6-635f-11ed-90a6-bb470175dfce
order-book-id
uuid of the order book
string
Required
Valid UUID
0435e5b6-635f-11ed-90a6-bb470175dfce