Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor / Remove Redundant function and types name appendixes #221

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/specs/Bet/01_Overview.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# **Overview**

The Bet module is responsible for receiving and processing requests to place and settle bets. In the case of placement, it validates the request and places the bet.
The Bet module is responsible for receiving and processing requests to wager and settle bets. In the case of wagering, it validates the request and places the bet.

For the settlement, blockchain automatically queries resolved markets then for each of these markets, checks the result of the market, determines the bet result, and settles the bet using `orderbook` module.
6 changes: 3 additions & 3 deletions docs/specs/Bet/02_Concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Bet module is tasked with placement and settlement of the bets. the user can place bet on a same market multiple times with different or equal odds through commandline or singing and broadcasting the bet placement message.

> Bet Placement will be done using a ticket containing odds info signed by a trusted source. Verifying this ticket will be done in the placement state itself.
> Wagering will be done using a ticket containing odds info signed by a trusted source. Verifying this ticket will be done in the placement state itself.
> Bet amount can not be less than a minimum amount which is defined for each market. A module parameter is used for this purpose.
> Also, a betting fee has been defined for each market, A module parameter is used for this purpose.

Expand All @@ -24,7 +24,7 @@ Before accepting bet some validation should take place:
- If Ignore is false in bet ticket payload, then the status of kyc approval should be true and tx signer and kyc id should be same for a bet to be placed.
- If Ignore is true in bet ticket payload, then kyc validation is not required and bet can be placed without kyc check.

Placement Assumptions:
Wager Assumptions:

- For bet placement user can raise a request to place a single bet, it can be done for a single bet only.
- When a user is raising a transaction to place a bet, the creator of the transaction is the owner of the bet.
Expand All @@ -33,7 +33,7 @@ After a bet is accepted:

- Bet amount transfer to the `orderbook_liquidity_pool` module account this is done by the `orderbook` module.
- Betting fee will be transferred to the `bet_fee_collector` module account. this is done by the `orderbook` module.
- Bet fulfillments are being processed by `orderbook` module in the `ProcessBetPlacement` keeper's method.
- Bet fulfillments are being processed by `orderbook` module in the `ProcessWager` keeper's method.

## Supported Odds Types

Expand Down
2 changes: 1 addition & 1 deletion docs/specs/Bet/03_Accounts.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ There is one account in the Bet module.

During bet placement, betting fee is transferred from the bettor's account to the bet module account in the Bet module.

## Placement Transfer
## Wager Transfer

The bet amount (deducted by betting fee) is transferred to the `orderbook_liquidity_pool` module account in `orderbook` module.

Expand Down
2 changes: 1 addition & 1 deletion docs/specs/Bet/05_State_Transitions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This section defines the state transitions of the bet module's KVStore in all scenarios:

## **Place bet**
## **Wager**

When this is processed:

Expand Down
30 changes: 15 additions & 15 deletions docs/specs/Bet/06_Messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@ handler endpoints is as follows
```proto
// Msg defines the Msg service.
service Msg {
// PlaceBet defines a method to place a bet with the given data
rpc PlaceBet(MsgPlaceBet) returns (MsgPlaceBetResponse);
// Wager defines a method to place a bet with the given data
rpc Wager(MsgWager) returns (MsgWagerResponse);
}
```

## **MsgPlaceBet**
## **MsgWager**

Within this message, the user specifies the bet information they wish to place.

```proto
// MsgPlaceBet defines a message to place a bet with the given data
message MsgPlaceBet {
// MsgWager defines a message to place a bet with the given data
message MsgWager {
// creator is the bettor address
string creator = 1;

// bet is the info of bet to place
PlaceBetFields bet = 2;
// props is the info of bet to place
WagerProps props = 2;
}

// PlaceBetFields contains attributes which come in Place bet tx request.
message PlaceBetFields {
// WagerProps contains attributes which come in wager tx request.
message WagerProps {
// uid is the universal unique identifier assigned to bet.
string uid = 1 [
(gogoproto.customname) = "UID",
Expand All @@ -44,12 +44,12 @@ message PlaceBetFields {
string ticket = 3;
}

// MsgPlaceBetResponse is the returning value in the response
// of MsgPlaceBet request.
message MsgPlaceBetResponse { PlaceBetFields bet = 1; }
// MsgWagerResponse is the returning value in the response
// of MsgWager request.
message MsgWagerResponse { WagerProps props = 1; }
```

### **Sample Place bet ticket**
### **Sample Wager ticket**

```json
{
Expand All @@ -72,7 +72,7 @@ message MsgPlaceBetResponse { PlaceBetFields bet = 1; }
}
```

### **Placement Failure cases**
### **Wager Failure cases**

The transaction will fail if:

Expand All @@ -92,7 +92,7 @@ The transaction will fail if:
- The market does not contain the selected odds
- Bet amount is less than minimum allowed amount
- The creator address is not valid
- There is an error in `ProcessBetPlacement` in `orderbook` module
- There is an error in `ProcessWager` in `orderbook` module

### **What Happens if bet placement fails**

Expand Down
2 changes: 1 addition & 1 deletion docs/specs/Bet/07_Events.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The Bet module emits the following events

## *MsgPlaceBet*
## *MsgWager*

| Type | Attribute Key| Attribute Value |
|:-------------:|:-------------:|:---------------------:|
Expand Down
26 changes: 13 additions & 13 deletions docs/specs/Market/03_Messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ The Market module exposes the following services:
```proto
// Msg defines the Msg service.
service Msg {
rpc AddMarket(MsgAddMarket) returns (MarketResponse);
rpc ResolveMarket(MsgResolveMarket) returns (MarketResponse);
rpc UpdateMarket(MsgUpdateMarket) returns (MarketResponse);
rpc Add(MsgAdd) returns (MarketResponse);
rpc Resolve(MsgResolve) returns (MarketResponse);
rpc Update(MsgUpdate) returns (MarketResponse);
}
```

---

## **MsgAddMarket**
## **MsgAdd**

This message is used to add new market to the chain

```proto
message MsgAddMarket {
message MsgAdd {
string creator = 1;
string ticket = 2;
}
Expand Down Expand Up @@ -97,14 +97,14 @@ message MarketAddTicketPayload {

---

## **MsgUpdateMarket**
## **MsgUpdate**

This message is used to update already existent markets on the chain

```proto
// MsgUpdateMarket is the message type for updating market data.
// MsgUpdate is the message type for updating market data.
// in the state
message MsgUpdateMarket {
message MsgUpdate {
// creator is the address of the creator account of the market.
string creator = 1;
// ticket is the jwt ticket data.
Expand Down Expand Up @@ -160,8 +160,8 @@ message MarketUpdateTicketPayload {
This is the common response to all the messages

```proto
// MsgAddMarketResponse response for adding market.
message MsgAddMarketResponse {
// MsgAddResponse response for adding market.
message MsgAddResponse {
// error contains an error if adding a market faces any issues.
string error = 1 [ (gogoproto.nullable) = true ];
// data is the data of market.
Expand All @@ -171,13 +171,13 @@ message MsgAddMarketResponse {

---

## **MsgResolveMarket**
## **MsgResolve**

This message is used to resolve already existent markets on the chain

```proto
// MsgResolveMarket is the message type for resolving a market.
message MsgResolveMarket {
// MsgResolve is the message type for resolving a market.
message MsgResolve {
// creator is the address of the creator account of the market.
string creator = 1;
// ticket is the jwt ticket data.
Expand Down
6 changes: 3 additions & 3 deletions docs/specs/Market/05_Events.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The Market module emits the following events:

## *MsgAddMarket*
## *MsgAdd*

| **Type** | **Attribute Key** | **Attribute Value** |
|----------------------------|---------------------------|-----------------------|
Expand All @@ -14,7 +14,7 @@ The Market module emits the following events:

---

## *MsgUpdateMarket*
## *MsgUpdate*

| **Type** | **Attribute Key** | **Attribute Value** |
|:------------------------:|:---------------------------:|:---------------------:|
Expand All @@ -25,7 +25,7 @@ The Market module emits the following events:

---

## *MsgResolveMarket*
## *MsgResolve*

| **Type** | **Attribute Key** | **Attribute Value** |
|---------------------------|--------------------------|-----------------------|
Expand Down
2 changes: 1 addition & 1 deletion docs/specs/OrderBook/04_State_Transitions.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ When a user deposits tokens:

---

## **Process Bet Placement**
## **Process Wager**

1. Get order book and odds exposures.
2. Check all fulfillment queue items:
Expand Down
4 changes: 2 additions & 2 deletions proto/sge/bet/ticket.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import "sge/bet/odds_type.proto";

option go_package = "github.com/sge-network/sge/x/bet/types";

// BetPlacementTicketPayload indicates data of bet placement ticket.
message BetPlacementTicketPayload {
// WagerTicketPayload indicates data of bet placement ticket.
message WagerTicketPayload {
// selected_odds is the user-selected odds to place bet.
BetOdds selected_odds = 1;
// kyc_data contains the details of user kyc.
Expand Down
20 changes: 10 additions & 10 deletions proto/sge/bet/tx.proto
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
syntax = "proto3";
package sgenetwork.sge.bet;

import "sge/bet/place_bet_fields.proto";
import "sge/bet/wager.proto";

option go_package = "github.com/sge-network/sge/x/bet/types";

// Msg defines the Msg service.
service Msg {

// PlaceBet defines a method to place a bet with the given data.
rpc PlaceBet(MsgPlaceBet) returns (MsgPlaceBetResponse);
// Wager defines a method to place a bet with the given data.
rpc Wager(MsgWager) returns (MsgWagerResponse);
}

// MsgPlaceBet defines a message to place a bet with the given data.
message MsgPlaceBet {
// MsgWager defines a message to place a bet with the given data.
message MsgWager {
// creator is the bettor address.
string creator = 1;
// PlaceBetFields contains bet fields.
PlaceBetFields bet = 2;
// props contains bet properties.
WagerProps props = 2;
}

// MsgPlaceBetResponse is the returning value in the response
// of MsgPlaceBet request.
message MsgPlaceBetResponse { PlaceBetFields bet = 1; }
// MsgWagerResponse is the returning value in the response
// of MsgWagerResponse request.
message MsgWagerResponse { WagerProps props = 1; }
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import "gogoproto/gogo.proto";

option go_package = "github.com/sge-network/sge/x/bet/types";

// PlaceBetFields contains attributes which come in Place bet tx request.
message PlaceBetFields {
// WagerProps contains attributes which come in wager tx request.
message WagerProps {
// uid is the universal unique identifier assigned to bet.
string uid = 1 [
(gogoproto.customname) = "UID",
Expand Down
36 changes: 18 additions & 18 deletions proto/sge/market/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,58 +8,58 @@ option go_package = "github.com/sge-network/sge/x/market/types";

// Msg defines the Msg service.
service Msg {
// AddMarket defines a method to add the market with the given data.
rpc AddMarket(MsgAddMarket) returns (MsgAddMarketResponse);
// ResolveMarket defines a method to resolve the market.
rpc ResolveMarket(MsgResolveMarket) returns (MsgResolveMarketResponse);
// UpdateMarket defines a method to update a market.
rpc UpdateMarket(MsgUpdateMarket) returns (MsgUpdateMarketResponse);
// Add defines a method to add the market with the given data.
rpc Add(MsgAdd) returns (MsgAddResponse);
// Resolve defines a method to resolve the market.
rpc Resolve(MsgResolve) returns (MsgResolveResponse);
// Update defines a method to update a market.
rpc Update(MsgUpdate) returns (MsgUpdateResponse);
}

// MsgAddMarket is the message type for adding the market into the
// MsgAdd is the message type for adding the market into the
// state.
message MsgAddMarket {
message MsgAdd {
// creator is the address of the creator account of the market.
string creator = 1;
// ticket is the jwt ticket data.
string ticket = 2;
}

// MsgAddMarketResponse response for adding market.
message MsgAddMarketResponse {
// MsgAddResponse response for adding market.
message MsgAddResponse {
// error contains an error if adding a market faces any issues.
string error = 1 [ (gogoproto.nullable) = true ];
// data is the data of market.
Market data = 2 [ (gogoproto.nullable) = true ];
}

// MsgResolveMarket is the message type for resolving a market.
message MsgResolveMarket {
// MsgResolve is the message type for resolving a market.
message MsgResolve {
// creator is the address of the creator account of the market.
string creator = 1;
// ticket is the jwt ticket data.
string ticket = 2;
}

// MsgResolveMarketResponse response for resolving a market.
message MsgResolveMarketResponse {
// MsgResolveResponse response for resolving a market.
message MsgResolveResponse {
// error contains an error if resolving a market faces any issues.
string error = 1 [ (gogoproto.nullable) = true ];
// data is the data of market.
Market data = 2 [ (gogoproto.nullable) = true ];
}

// MsgUpdateMarket is the message type for updating market data.
// MsgUpdate is the message type for updating market data.
// in the state
message MsgUpdateMarket {
message MsgUpdate {
// creator is the address of the creator account of the market.
string creator = 1;
// ticket is the jwt ticket data.
string ticket = 2;
}

// MsgUpdateMarketResponse response for updating a market.
message MsgUpdateMarketResponse {
// MsgUpdateResponse response for updating a market.
message MsgUpdateResponse {
// error contains an error if updating a market faces any issues.
string error = 1 [ (gogoproto.nullable) = true ];
// data is the data of market
Expand Down
6 changes: 4 additions & 2 deletions proto/sge/orderbook/orderbookevent.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ option go_package = "github.com/sge-network/sge/x/orderbook/types";
// OrderBookEvent to publish the order book event
message OrderBookEvent {

// ParticipationExposure to publish the order book event, participation exposure
// ParticipationExposure to publish the order book event, participation
// exposure
repeated ParticipationExposure participation_exposure = 1;

// OrderBookOddsExposure to publish the order book event, order book odds exposure
// OrderBookOddsExposure to publish the order book event, order book odds
// exposure
repeated OrderBookOddsExposure order_book_odds_exposure = 2;
}
2 changes: 1 addition & 1 deletion x/bet/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func GetTxCmd() *cobra.Command {
RunE: client.ValidateCmd,
}

cmd.AddCommand(CmdPlaceBet())
cmd.AddCommand(CmdWager())

return cmd
}
Loading
Loading