Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Overview and Concepts
The Market module serves the following purposes in the SGE Network chain:
The market module pushes the verified data of the sports events onto the SGE Network chain from off-chain sources. This way the sport-event is added to the blockchain and becomes readily available for the bettors to wager on it.
It stores the markets pushed to the blockchain.
It also resolves the markets when the market is finished and the winner odds are passed to it, hence declaring the result of the market.
It can update the markets as and when the update request is made.
It can activate or deactivate the markets, thus making them available or unavailable, respectively, for placing bets.
Market module parameter types and definition.
The Market module do not have any parameters.
This section defines the way in which the state of the Market is being stored in the chain.
A market is an entity being stored in the SGE Network chain to hold the data related to a market that has been verifiably pushed to the blockchain. It contains the following fields:
uid
: It is the unique identifier of a market.
start_ts
: It is the timestamp when a particular market will start.
end_ts
: It is the timestamp when a particular market will end.
odds
: It is a list of all the odds for a particular market. the meta
is a human-readable description of the odds, it can be a JSON string to be used by oracle services.
Ex: { "uid" :uid_win_event, "meta": "tam A wins" }, { "uid": uid_draw_event, "meta": "draw"}, { "uid": uid_loose_event, "meta": "team A loose"}
winner_odds_uids
: It is a list of all the UIDs of odds that have won the market. This should necessarily be a subset of the above-provided odds_uids.
status
: It defines the current state of the market.
resolution_ts
: It is the timestamp when the market came to a resolution i.e. when the system received a resolution request for a market.
creator
: It holds the account address responsible for the addition of the market to the blockchain.
meta
: It is a human-readable description of the market, it can be a JSON string to be used by oracle services.
book_id
is the ID of the order book created and assigned to the market, this is the same value as market UID.
The proto for the market is as follows:
The status of a market in the chain can be defined in either of the five following ways:
This section elaborates on the transaction message handler methods being exposed by the Market module.
When a transaction of adding a market is processed, the following actions take place:
The creator address and the ticket format are validated in the market module.
The OVM module is invoked to retrieve the ticket's contents and validate it.
If the ticket is valid, it is checked if the market already exists.
If the market does not already exist, a new market is created with the provided data and added to the market module's KVStore. The market is created as shown below:
The RPC for adding a market is as follows:
The request message for Add
is MsgAdd
. The proto for the request message is as follows:
The response message of the MsgAdd
is MsgAddResponse
. The proto for the response message is as follows:
When a transaction of resolving a market is processed, the following actions take place:
The creator address and the ticket format are validated in the market module.
The OVM module is invoked to retrieve the ticket's contents and validate it.
If the ticket is valid, it is checked if the market already exists.
If the market already exists, the market status should,types.MarketStatus_STATUS_ACTIVE
so that the market can be resolved now.
Then the market is resolved as per the provided odds value and status and stored in the KVStore of the market module.
The RPC for resolving a market is as follows:
The request message for Resolve
is MsgResolve
. The proto for the request message is as follows:
The response message of the MsgResolve
is MsgResolveResponse
. The proto for the response message is as follows:
When a transaction of updating a market is processed, the following actions take place:
The creator address and the ticket format are validated in the market module.
The OVM module is invoked to retrieve the ticket's contents and validate it.
If the ticket is valid, it is checked if the market already exists.
If the market already exists, the market status should be types.MarketStatus_STATUS_Active
or types.MarketStatus_STATUS_Inactive
Then the market is updated as per the provided data and stored in the KVStore of the market module again in the following way:
The RPC for updating a market is as follows:
The request message for Update
is MsgUpdate
. The proto for the request message is as follows:
The response message of the Update
is MsgUpdateResponse
. The proto for the response message is as follows:
Market 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 house
module in the SGE Network chain.
Market module CLI queries
Queries of this module can be used to get the data of markets and params. The following queries have been exposed by the market module:
Gets a single UID and returns the corresponding market, the following table explains the details of the argument required for the above query:
Gets a list of comma-separated UID and returns the list of markets. The below table explains the details of the argument required for the above query:
Params | Description | Type | Validation | Example |
---|---|---|---|---|
Params | Description | Type | Validation | Example |
---|---|---|---|---|
uid
Unique Identifier of a market
string
Required
Valid UUID
0435e5b6-635f-11ed-90a6-bb470175dfce
uid
A list of unique identifiers of markets separated by ,
string
Required
Valid UUID
0435e5b6-635f-11ed-90a6-bb470175dfce
The exposed transactions CLI commands and ticket payloads by the Market module.
The below transaction can be used to add a market to the blockchain.
The payload for the add-market transaction is as follows:
The values in the payload should be changed according to the data.
The below transaction can be used to update a market stored in the blockchain.
The payload for the update-market transaction is as follows:
The values in the payload should be changed according to the data.
The below transaction can be used to resolve a market to the blockchain.
The payload for the resolve-market transaction is as follows:
The values in the payload should be changed according to the data.
The below transaction can be used to update a market to the blockchain.
The payload for the update-market transaction is as follows:
The values in the payload should be changed according to the data.