Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dydxwill committed Aug 12, 2024
1 parent 4ba411b commit d63bec6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
7 changes: 0 additions & 7 deletions protocol/streaming/noop_streaming_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@ func (sm *NoopGrpcStreamingManager) SendOrderbookFillUpdates(
) {
}

func (sm *NoopGrpcStreamingManager) SendSubaccountUpdates(
subaccountUpdates []satypes.StreamSubaccountUpdate,
blockHeight uint32,
execMode sdk.ExecMode,
) {
}

func (sm *NoopGrpcStreamingManager) SendTakerOrderStatus(
takerOrder clobtypes.StreamTakerOrder,
blockHeight uint32,
Expand Down
5 changes: 0 additions & 5 deletions protocol/streaming/types/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ type FullNodeStreamingManager interface {
execMode sdk.ExecMode,
perpetualIdToClobPairId map[uint32][]clobtypes.ClobPairId,
)
SendSubaccountUpdates(
subaccountUpdates []satypes.StreamSubaccountUpdate,
blockHeight uint32,
execMode sdk.ExecMode,
)
SendTakerOrderStatus(
takerOrder clobtypes.StreamTakerOrder,
blockHeight uint32,
Expand Down
28 changes: 28 additions & 0 deletions protocol/x/subaccounts/keeper/subaccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,34 @@ func (k Keeper) GetSubaccount(
return val
}

func (k Keeper) GetStreamSubaccountUpdate(
ctx sdk.Context,
id types.SubaccountId,
) (val types.StreamSubaccountUpdate) {
subaccount := k.GetSubaccount(ctx, id)
assetPositions := make([]*types.SubaccountAssetPosition, len(subaccount.AssetPositions))
for i, ap := range subaccount.AssetPositions {
assetPositions[i] = &types.SubaccountAssetPosition{
AssetId: ap.AssetId,
Quantums: ap.Quantums.BigInt().Uint64(),
}
}
perpetualPositions := make([]*types.SubaccountPerpetualPosition, len(subaccount.PerpetualPositions))
for i, pp := range subaccount.PerpetualPositions {
perpetualPositions[i] = &types.SubaccountPerpetualPosition{
PerpetualId: pp.PerpetualId,
Quantums: pp.Quantums.BigInt().Uint64(),
}
}

return types.StreamSubaccountUpdate{
SubaccountId: &id,
UpdatedAssetPositions: assetPositions,
UpdatedPerpetualPositions: perpetualPositions,
Snapshot: true,
}
}

// GetAllSubaccount returns all subaccount.
// For more performant searching and iteration, use `ForEachSubaccount`.
func (k Keeper) GetAllSubaccount(ctx sdk.Context) (list []types.Subaccount) {
Expand Down

0 comments on commit d63bec6

Please sign in to comment.