Skip to content

Commit

Permalink
[CLOB-1045] proto updates for daemon liquidation request (#885)
Browse files Browse the repository at this point in the history
* [CLOB-1045] proto updates for daemon liquidation request

* fix proto format

* switch from map to slice
  • Loading branch information
jayy04 authored Dec 12, 2023
1 parent 35b87db commit bffa5b6
Show file tree
Hide file tree
Showing 10 changed files with 285 additions and 53 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { SubaccountId, SubaccountIdSDKType } from "../../subaccounts/subaccount";
import { SubaccountOpenPositionInfo, SubaccountOpenPositionInfoSDKType } from "../../clob/liquidations";
import * as _m0 from "protobufjs/minimal";
import { DeepPartial } from "../../../helpers";
/**
Expand All @@ -9,7 +10,15 @@ import { DeepPartial } from "../../../helpers";
*/

export interface LiquidateSubaccountsRequest {
subaccountIds: SubaccountId[];
/** The block height at which the liquidation daemon is processing. */
blockHeight: number;
/** The list of liquidatable subaccount ids. */

liquidatableSubaccountIds: SubaccountId[];
/** The list of subaccount ids with negative total net collateral. */

negativeTncSubaccountIds: SubaccountId[];
subaccountOpenPositionInfo: SubaccountOpenPositionInfo[];
}
/**
* LiquidateSubaccountsRequest is a request message that contains a list of
Expand All @@ -19,7 +28,15 @@ export interface LiquidateSubaccountsRequest {
*/

export interface LiquidateSubaccountsRequestSDKType {
subaccount_ids: SubaccountIdSDKType[];
/** The block height at which the liquidation daemon is processing. */
block_height: number;
/** The list of liquidatable subaccount ids. */

liquidatable_subaccount_ids: SubaccountIdSDKType[];
/** The list of subaccount ids with negative total net collateral. */

negative_tnc_subaccount_ids: SubaccountIdSDKType[];
subaccount_open_position_info: SubaccountOpenPositionInfoSDKType[];
}
/**
* LiquidateSubaccountsResponse is a response message for
Expand All @@ -36,14 +53,29 @@ export interface LiquidateSubaccountsResponseSDKType {}

function createBaseLiquidateSubaccountsRequest(): LiquidateSubaccountsRequest {
return {
subaccountIds: []
blockHeight: 0,
liquidatableSubaccountIds: [],
negativeTncSubaccountIds: [],
subaccountOpenPositionInfo: []
};
}

export const LiquidateSubaccountsRequest = {
encode(message: LiquidateSubaccountsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
for (const v of message.subaccountIds) {
SubaccountId.encode(v!, writer.uint32(10).fork()).ldelim();
if (message.blockHeight !== 0) {
writer.uint32(8).uint32(message.blockHeight);
}

for (const v of message.liquidatableSubaccountIds) {
SubaccountId.encode(v!, writer.uint32(18).fork()).ldelim();
}

for (const v of message.negativeTncSubaccountIds) {
SubaccountId.encode(v!, writer.uint32(26).fork()).ldelim();
}

for (const v of message.subaccountOpenPositionInfo) {
SubaccountOpenPositionInfo.encode(v!, writer.uint32(34).fork()).ldelim();
}

return writer;
Expand All @@ -59,7 +91,19 @@ export const LiquidateSubaccountsRequest = {

switch (tag >>> 3) {
case 1:
message.subaccountIds.push(SubaccountId.decode(reader, reader.uint32()));
message.blockHeight = reader.uint32();
break;

case 2:
message.liquidatableSubaccountIds.push(SubaccountId.decode(reader, reader.uint32()));
break;

case 3:
message.negativeTncSubaccountIds.push(SubaccountId.decode(reader, reader.uint32()));
break;

case 4:
message.subaccountOpenPositionInfo.push(SubaccountOpenPositionInfo.decode(reader, reader.uint32()));
break;

default:
Expand All @@ -73,7 +117,10 @@ export const LiquidateSubaccountsRequest = {

fromPartial(object: DeepPartial<LiquidateSubaccountsRequest>): LiquidateSubaccountsRequest {
const message = createBaseLiquidateSubaccountsRequest();
message.subaccountIds = object.subaccountIds?.map(e => SubaccountId.fromPartial(e)) || [];
message.blockHeight = object.blockHeight ?? 0;
message.liquidatableSubaccountIds = object.liquidatableSubaccountIds?.map(e => SubaccountId.fromPartial(e)) || [];
message.negativeTncSubaccountIds = object.negativeTncSubaccountIds?.map(e => SubaccountId.fromPartial(e)) || [];
message.subaccountOpenPositionInfo = object.subaccountOpenPositionInfo?.map(e => SubaccountOpenPositionInfo.fromPartial(e)) || [];
return message;
}

Expand Down
15 changes: 14 additions & 1 deletion proto/dydxprotocol/daemons/liquidation/liquidation.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package dydxprotocol.daemons.liquidation;

import "gogoproto/gogo.proto";
import "dydxprotocol/subaccounts/subaccount.proto";
import "dydxprotocol/clob/liquidations.proto";

option go_package = "github.com/dydxprotocol/v4-chain/protocol/daemons/liquidation/api";

Expand All @@ -18,8 +19,20 @@ service LiquidationService {
// ids should not contain duplicates. The application should re-verify these
// subaccount ids against current state before liquidating their positions.
message LiquidateSubaccountsRequest {
repeated dydxprotocol.subaccounts.SubaccountId subaccount_ids = 1
// The block height at which the liquidation daemon is processing.
uint32 block_height = 1;

// The list of liquidatable subaccount ids.
repeated dydxprotocol.subaccounts.SubaccountId liquidatable_subaccount_ids = 2
[ (gogoproto.nullable) = false ];

// The list of subaccount ids with negative total net collateral.
repeated dydxprotocol.subaccounts.SubaccountId negative_tnc_subaccount_ids = 3
[ (gogoproto.nullable) = false ];

// A map of perpetual id to subaccount open position info.
repeated dydxprotocol.clob.SubaccountOpenPositionInfo
subaccount_open_position_info = 4 [ (gogoproto.nullable) = false ];
}

// LiquidateSubaccountsResponse is a response message for
Expand Down
Loading

0 comments on commit bffa5b6

Please sign in to comment.