Skip to content

Commit 465b37c

Browse files
Full node streaming -- perp position to signed int (backport #2544) (#2562)
Co-authored-by: Jonathan Fung <121899091+jonfung-dydx@users.noreply.github.com>
1 parent b3b12f3 commit 465b37c

File tree

4 files changed

+38
-38
lines changed

4 files changed

+38
-38
lines changed

indexer/packages/v4-protos/src/codegen/dydxprotocol/subaccounts/streaming.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export interface StreamSubaccountUpdateSDKType {
5959
export interface SubaccountPerpetualPosition {
6060
/** The `Id` of the `Perpetual`. */
6161
perpetualId: number;
62-
/** The size of the position in base quantums. */
62+
/** The size of the position in base quantums. Negative means short. */
6363

6464
quantums: Long;
6565
}
@@ -71,7 +71,7 @@ export interface SubaccountPerpetualPosition {
7171
export interface SubaccountPerpetualPositionSDKType {
7272
/** The `Id` of the `Perpetual`. */
7373
perpetual_id: number;
74-
/** The size of the position in base quantums. */
74+
/** The size of the position in base quantums. Negative means short. */
7575

7676
quantums: Long;
7777
}
@@ -178,7 +178,7 @@ export const StreamSubaccountUpdate = {
178178
function createBaseSubaccountPerpetualPosition(): SubaccountPerpetualPosition {
179179
return {
180180
perpetualId: 0,
181-
quantums: Long.UZERO
181+
quantums: Long.ZERO
182182
};
183183
}
184184

@@ -189,7 +189,7 @@ export const SubaccountPerpetualPosition = {
189189
}
190190

191191
if (!message.quantums.isZero()) {
192-
writer.uint32(16).uint64(message.quantums);
192+
writer.uint32(16).int64(message.quantums);
193193
}
194194

195195
return writer;
@@ -209,7 +209,7 @@ export const SubaccountPerpetualPosition = {
209209
break;
210210

211211
case 2:
212-
message.quantums = (reader.uint64() as Long);
212+
message.quantums = (reader.int64() as Long);
213213
break;
214214

215215
default:
@@ -224,7 +224,7 @@ export const SubaccountPerpetualPosition = {
224224
fromPartial(object: DeepPartial<SubaccountPerpetualPosition>): SubaccountPerpetualPosition {
225225
const message = createBaseSubaccountPerpetualPosition();
226226
message.perpetualId = object.perpetualId ?? 0;
227-
message.quantums = object.quantums !== undefined && object.quantums !== null ? Long.fromValue(object.quantums) : Long.UZERO;
227+
message.quantums = object.quantums !== undefined && object.quantums !== null ? Long.fromValue(object.quantums) : Long.ZERO;
228228
return message;
229229
}
230230

proto/dydxprotocol/subaccounts/streaming.proto

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ message StreamSubaccountUpdate {
2828
message SubaccountPerpetualPosition {
2929
// The `Id` of the `Perpetual`.
3030
uint32 perpetual_id = 1;
31-
// The size of the position in base quantums.
32-
uint64 quantums = 2;
31+
// The size of the position in base quantums. Negative means short.
32+
int64 quantums = 2;
3333
}
3434

3535
// SubaccountAssetPosition provides information on a subaccount's updated asset

protocol/x/subaccounts/keeper/subaccount.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func (k Keeper) GetStreamSubaccountUpdate(
150150
for i, pp := range subaccount.PerpetualPositions {
151151
perpetualPositions[i] = &types.SubaccountPerpetualPosition{
152152
PerpetualId: pp.PerpetualId,
153-
Quantums: pp.Quantums.BigInt().Uint64(),
153+
Quantums: pp.Quantums.BigInt().Int64(),
154154
}
155155
}
156156

@@ -298,7 +298,7 @@ func GenerateStreamSubaccountUpdate(
298298
for i, pp := range updatedPerpetualPositions {
299299
perpetualPositions[i] = &types.SubaccountPerpetualPosition{
300300
PerpetualId: pp.PerpetualId,
301-
Quantums: pp.Quantums.BigInt().Uint64(),
301+
Quantums: pp.Quantums.BigInt().Int64(),
302302
}
303303
}
304304

protocol/x/subaccounts/types/streaming.pb.go

Lines changed: 28 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)