Skip to content

Commit

Permalink
[OTE-248] Update LiquidityTierUpsertEvent to add OI caps (#1242)
Browse files Browse the repository at this point in the history
* Update LiquidityTierUpsertEvent to add OI caps

* add some constants

* type fix
  • Loading branch information
affanv14 authored Mar 27, 2024
1 parent ddd1715 commit a100739
Show file tree
Hide file tree
Showing 7 changed files with 260 additions and 135 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,12 @@ export interface LiquidityTierUpsertEventV1 {
/** @deprecated */

basePositionNotional: Long;
/** Lower cap of open interest in quote quantums. */

openInterestLowerCap: Long;
/** Upper cap of open interest in quote quantums. */

openInterestUpperCap: Long;
}
/**
* LiquidityTierUpsertEventV1 message contains all the information to
Expand Down Expand Up @@ -992,6 +998,12 @@ export interface LiquidityTierUpsertEventV1SDKType {
/** @deprecated */

base_position_notional: Long;
/** Lower cap of open interest in quote quantums. */

open_interest_lower_cap: Long;
/** Upper cap of open interest in quote quantums. */

open_interest_upper_cap: Long;
}
/**
* UpdateClobPairEventV1 message contains all the information about an update to
Expand Down Expand Up @@ -2675,7 +2687,9 @@ function createBaseLiquidityTierUpsertEventV1(): LiquidityTierUpsertEventV1 {
name: "",
initialMarginPpm: 0,
maintenanceFractionPpm: 0,
basePositionNotional: Long.UZERO
basePositionNotional: Long.UZERO,
openInterestLowerCap: Long.UZERO,
openInterestUpperCap: Long.UZERO
};
}

Expand All @@ -2701,6 +2715,14 @@ export const LiquidityTierUpsertEventV1 = {
writer.uint32(40).uint64(message.basePositionNotional);
}

if (!message.openInterestLowerCap.isZero()) {
writer.uint32(48).uint64(message.openInterestLowerCap);
}

if (!message.openInterestUpperCap.isZero()) {
writer.uint32(56).uint64(message.openInterestUpperCap);
}

return writer;
},

Expand Down Expand Up @@ -2733,6 +2755,14 @@ export const LiquidityTierUpsertEventV1 = {
message.basePositionNotional = (reader.uint64() as Long);
break;

case 6:
message.openInterestLowerCap = (reader.uint64() as Long);
break;

case 7:
message.openInterestUpperCap = (reader.uint64() as Long);
break;

default:
reader.skipType(tag & 7);
break;
Expand All @@ -2749,6 +2779,8 @@ export const LiquidityTierUpsertEventV1 = {
message.initialMarginPpm = object.initialMarginPpm ?? 0;
message.maintenanceFractionPpm = object.maintenanceFractionPpm ?? 0;
message.basePositionNotional = object.basePositionNotional !== undefined && object.basePositionNotional !== null ? Long.fromValue(object.basePositionNotional) : Long.UZERO;
message.openInterestLowerCap = object.openInterestLowerCap !== undefined && object.openInterestLowerCap !== null ? Long.fromValue(object.openInterestLowerCap) : Long.UZERO;
message.openInterestUpperCap = object.openInterestUpperCap !== undefined && object.openInterestUpperCap !== null ? Long.fromValue(object.openInterestUpperCap) : Long.UZERO;
return message;
}

Expand Down
2 changes: 2 additions & 0 deletions indexer/services/ender/__tests__/helpers/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ export const defaultLiquidityTierUpsertEvent: LiquidityTierUpsertEventV1 = {
initialMarginPpm: 50000, // 5%
maintenanceFractionPpm: 600000, // 60% of IM = 3%
basePositionNotional: Long.fromValue(1_000_000_000_000, true), // 1_000_000 USDC
openInterestLowerCap: Long.fromValue(0, true),
openInterestUpperCap: Long.fromValue(1_000_000_000, true),
};

export const defaultUpdatePerpetualEvent: UpdatePerpetualEventV1 = {
Expand Down
6 changes: 6 additions & 0 deletions proto/dydxprotocol/indexer/events/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,12 @@ message LiquidityTierUpsertEventV1 {
//
// Deprecated since v3.x.
uint64 base_position_notional = 5 [ deprecated = true ];

// Lower cap of open interest in quote quantums.
uint64 open_interest_lower_cap = 6;

// Upper cap of open interest in quote quantums.
uint64 open_interest_upper_cap = 7;
}

// UpdateClobPairEventV1 message contains all the information about an update to
Expand Down
Loading

0 comments on commit a100739

Please sign in to comment.