Skip to content

Commit

Permalink
Full node streaming -- perp position to signed int (#2544)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonfung-dydx authored Oct 28, 2024
1 parent 338f1ce commit 0e185fd
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export interface StreamSubaccountUpdateSDKType {
export interface SubaccountPerpetualPosition {
/** The `Id` of the `Perpetual`. */
perpetualId: number;
/** The size of the position in base quantums. */
/** The size of the position in base quantums. Negative means short. */

quantums: Long;
}
Expand All @@ -71,7 +71,7 @@ export interface SubaccountPerpetualPosition {
export interface SubaccountPerpetualPositionSDKType {
/** The `Id` of the `Perpetual`. */
perpetual_id: number;
/** The size of the position in base quantums. */
/** The size of the position in base quantums. Negative means short. */

quantums: Long;
}
Expand Down Expand Up @@ -178,7 +178,7 @@ export const StreamSubaccountUpdate = {
function createBaseSubaccountPerpetualPosition(): SubaccountPerpetualPosition {
return {
perpetualId: 0,
quantums: Long.UZERO
quantums: Long.ZERO
};
}

Expand All @@ -189,7 +189,7 @@ export const SubaccountPerpetualPosition = {
}

if (!message.quantums.isZero()) {
writer.uint32(16).uint64(message.quantums);
writer.uint32(16).int64(message.quantums);
}

return writer;
Expand All @@ -209,7 +209,7 @@ export const SubaccountPerpetualPosition = {
break;

case 2:
message.quantums = (reader.uint64() as Long);
message.quantums = (reader.int64() as Long);
break;

default:
Expand All @@ -224,7 +224,7 @@ export const SubaccountPerpetualPosition = {
fromPartial(object: DeepPartial<SubaccountPerpetualPosition>): SubaccountPerpetualPosition {
const message = createBaseSubaccountPerpetualPosition();
message.perpetualId = object.perpetualId ?? 0;
message.quantums = object.quantums !== undefined && object.quantums !== null ? Long.fromValue(object.quantums) : Long.UZERO;
message.quantums = object.quantums !== undefined && object.quantums !== null ? Long.fromValue(object.quantums) : Long.ZERO;
return message;
}

Expand Down
4 changes: 2 additions & 2 deletions proto/dydxprotocol/subaccounts/streaming.proto
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ message StreamSubaccountUpdate {
message SubaccountPerpetualPosition {
// The `Id` of the `Perpetual`.
uint32 perpetual_id = 1;
// The size of the position in base quantums.
uint64 quantums = 2;
// The size of the position in base quantums. Negative means short.
int64 quantums = 2;
}

// SubaccountAssetPosition provides information on a subaccount's updated asset
Expand Down
4 changes: 2 additions & 2 deletions protocol/x/subaccounts/keeper/subaccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func (k Keeper) GetStreamSubaccountUpdate(
for i, pp := range subaccount.PerpetualPositions {
perpetualPositions[i] = &types.SubaccountPerpetualPosition{
PerpetualId: pp.PerpetualId,
Quantums: pp.Quantums.BigInt().Uint64(),
Quantums: pp.Quantums.BigInt().Int64(),
}
}

Expand Down Expand Up @@ -298,7 +298,7 @@ func GenerateStreamSubaccountUpdate(
for i, pp := range updatedPerpetualPositions {
perpetualPositions[i] = &types.SubaccountPerpetualPosition{
PerpetualId: pp.PerpetualId,
Quantums: pp.Quantums.BigInt().Uint64(),
Quantums: pp.Quantums.BigInt().Int64(),
}
}

Expand Down
56 changes: 28 additions & 28 deletions protocol/x/subaccounts/types/streaming.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0e185fd

Please sign in to comment.