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

Full node streaming -- perp position to signed int (backport #2544) #2562

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
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.

Loading