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

Fix / OrderBook status and events #269

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/_sidebar.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- docs/_sidebar.md -->

* [About Sge Network](README.md)
* [About Sge Network](../README.md)
* [Modules](specs/README.md)
* [Bet](specs/Bet/01_Overview.md)
* [OVM](specs/OVM/01_Overview.md)
Expand Down
3 changes: 2 additions & 1 deletion docs/specs/Bet/_sidebar.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!-- docs/_sidebar.md -->

* [About SGE Network](../../README.md)
* [Home](/)
* [About SGE Network](../../../README.md)
* [Modules](../README.md)
* [Bet](../Bet/01_Overview.md)
* [Overview](../Bet/01_Overview.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/specs/House/_sidebar.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- docs/_sidebar.md -->

* [Home](/)
* [About SGE Network](../README.md)
* [About SGE Network](../../../README.md)
* [Modules](../README.md)
* [Bet](../Bet/01_Overview.md)
* [OVM](../OVM/01_Overview.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/specs/Market/_sidebar.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- docs/_sidebar.md -->

* [Home](/)
* [About SGE Network](../README.md)
* [About SGE Network](../../../README.md)
* [Modules](../README.md)
* [Bet](../Bet/01_Overview.md)
* [OVM](../OVM/01_Overview.md)
Expand Down
3 changes: 2 additions & 1 deletion docs/specs/Mint/_sidebar.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!-- docs/_sidebar.md -->

* [About SGE Network](../../README.md)
* [Home](/)
* [About SGE Network](../../../README.md)
* [Modules](../README.md)
* [Bet](../Bet/01_Overview.md)
* [OVM](../OVM/01_Overview.md)
Expand Down
3 changes: 2 additions & 1 deletion docs/specs/OVM/_sidebar.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!-- docs/_sidebar.md -->

* [About SGE Network](../../README.md)
* [Home](/)
* [About SGE Network](../../../README.md)
* [Modules](../README.md)
* [Bet](../Bet/01_Overview.md)
* [OVM](../OVM/01_Overview.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/specs/OrderBook/_sidebar.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- docs/_sidebar.md -->

* [Home](/)
* [About SGE Network](../README.md)
* [About SGE Network](../../../README.md)
* [Modules](../README.md)
* [Bet](../Bet/01_Overview.md)
* [OVM](../OVM/01_Overview.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/specs/_sidebar.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- docs/_sidebar.md -->

* [About SGE Network](../README.md)
* [About Sge Network](../../README.md)
* [Modules](README.md)
* [Bet](Bet/01_Overview.md)
* [OVM](OVM/01_Overview.md)
Expand Down
18 changes: 0 additions & 18 deletions proto/sge/orderbook/orderbookevent.proto

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/protocgen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -eo pipefail

# get protoc executions
go get github.com/cosmos/[email protected].10 2>/dev/null
go get github.com/cosmos/[email protected].11 2>/dev/null

# get cosmos sdk from github
go get github.com/cosmos/[email protected] 2>/dev/null
Expand Down
1 change: 0 additions & 1 deletion x/bet/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,4 @@ type OrderbookKeeper interface {
) error
SetOrderBookAsUnsettledResolved(ctx sdk.Context, orderBookUID string) error
WithdrawBetFee(ctx sdk.Context, marketCreator sdk.AccAddress, betFee sdkmath.Int) error
PublishOrderBookEvent(ctx sdk.Context, orderBookUID string)
}
2 changes: 0 additions & 2 deletions x/house/keeper/deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,5 @@ func (k Keeper) Deposit(ctx sdk.Context, creator, depositor string,

k.SetDeposit(ctx, deposit)

k.orderbookKeeper.PublishOrderBookEvent(ctx, marketUID)

return participationIndex, err
}
2 changes: 0 additions & 2 deletions x/house/keeper/withdrawal.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,5 @@ func (k Keeper) Withdraw(
deposit.TotalWithdrawalAmount = deposit.TotalWithdrawalAmount.Add(withdrawableAmount)
k.SetDeposit(ctx, deposit)

k.orderbookKeeper.PublishOrderBookEvent(ctx, marketUID)

return withdrawalID, nil
}
1 change: 0 additions & 1 deletion x/house/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ type OrderbookKeeper interface {
WithdrawOrderBookParticipation(ctx sdk.Context, marketUID string,
participationIndex uint64, amount sdkmath.Int,
) error
PublishOrderBookEvent(ctx sdk.Context, orderBookUID string)
}

// OVMKeeper defines the expected interface needed to verify ticket and unmarshal it
Expand Down
27 changes: 1 addition & 26 deletions x/orderbook/keeper/bet_wager.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package keeper

import (
"fmt"

sdkmath "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
Expand Down Expand Up @@ -71,31 +69,8 @@ func (k Keeper) ProcessWager(
if err := k.fund(types.OrderBookLiquidityFunder{}, ctx, bettorAddress, fInfo.fulfilledBetAmount); err != nil {
return nil, err
}
k.PublishOrderBookEvent(ctx, bookUID)
return fInfo.fulfillments, nil
}

func (k Keeper) PublishOrderBookEvent(ctx sdk.Context, orderBookUID string) {
event := types.NewOrderBookEvent()
boes, err := k.GetOddsExposuresByOrderBook(ctx, orderBookUID)
if err != nil {
k.Logger(ctx).Error(fmt.Sprintf("Error in publishing order book event error: %s", err))
return
}

for _, boe := range boes {
event.AddOrderBookOddsExposure(boe)
pes, err := k.GetExposureByOrderBookAndOdds(ctx, orderBookUID, boe.OddsUID)
if err != nil {
k.Logger(ctx).Error(fmt.Sprintf("Error in publishing order book event error: %s", err))
return
}
for _, pe := range pes {
event.AddParticipationExposure(pe)
}
}

event.Emit(ctx)
return fInfo.fulfillments, nil
}

// fulfillBetByParticipationQueue fulfills the bet wagering payout using the participations
Expand Down
4 changes: 0 additions & 4 deletions x/orderbook/keeper/exposure_odds.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,12 @@ func (k Keeper) initParticipationExposures(
) error {
// Update book odds exposures and add participant exposures
boes, err := k.GetOddsExposuresByOrderBook(ctx, orderBookUID)
bookEvent := types.NewOrderBookEvent()
if err != nil {
return err
}
for _, boe := range boes {
boe.FulfillmentQueue = append(boe.FulfillmentQueue, participationIndex)
k.SetOrderBookOddsExposure(ctx, boe)
bookEvent.AddOrderBookOddsExposure(boe)

pe := types.NewParticipationExposure(
orderBookUID,
Expand All @@ -101,9 +99,7 @@ func (k Keeper) initParticipationExposures(
false,
)
k.SetParticipationExposure(ctx, pe)
bookEvent.AddParticipationExposure(pe)
}
bookEvent.Emit(ctx)

return nil
}
Expand Down
3 changes: 3 additions & 0 deletions x/orderbook/keeper/orderbook_settle.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ func (k Keeper) BatchOrderBookSettlements(ctx sdk.Context) error {
// we need to remove its uid from the list of unsettled resolved orderbooks.
if allSettled {
k.RemoveUnsettledResolvedOrderBook(ctx, orderBookUID)

book.Status = types.OrderBookStatus_ORDER_BOOK_STATUS_STATUS_SETTLED
k.SetOrderBook(ctx, book)
}

return nil
Expand Down
9 changes: 0 additions & 9 deletions x/orderbook/types/events.go

This file was deleted.

29 changes: 0 additions & 29 deletions x/orderbook/types/order_book_event.go

This file was deleted.

Loading
Loading