Skip to content

Commit

Permalink
Merge branch 'jakob-dydx/final-settlement-endblocker' into jakob-dydx…
Browse files Browse the repository at this point in the history
…/final-settlement-pcs
  • Loading branch information
jakob-dydx committed Dec 20, 2023
2 parents 7ce548b + c70b5e9 commit 2bddbbe
Show file tree
Hide file tree
Showing 65 changed files with 4,705 additions and 2,061 deletions.
8 changes: 6 additions & 2 deletions indexer/packages/compliance/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
export const INDEXER_GEOBLOCKED_PAYLOAD = 'Because you appear to be a resident of, or trading from, a jurisdiction that violates our terms of use, or have engaged in activity that violates our terms of use, you have been blocked. You may withdraw your funds from the protocol at any time.';
export const INDEXER_COMPLIANCE_BLOCKED_PAYLOAD = 'Because this address appears to be a resident of, or trading from, a jurisdiction that violates our terms of use, or has engaged in activity that violates our terms of use, this address has been blocked.';
export const INDEXER_GEOBLOCKED_PAYLOAD: string = 'Because you appear to be a resident of, or trading from, a jurisdiction that violates our terms of use, or have engaged in activity that violates our terms of use, you have been blocked. You may withdraw your funds from the protocol at any time.';
export const INDEXER_COMPLIANCE_BLOCKED_PAYLOAD: string = 'Because this address appears to be a resident of, or trading from, a jurisdiction that violates our terms of use, or has engaged in activity that violates our terms of use, this address has been blocked.';

// For use by other services packages, can't be used to index on the actual requests
// object as that needs to be a string literal.
export const COUNTRY_HEADER_KEY: string = 'cf-ipcountry';
8 changes: 4 additions & 4 deletions indexer/packages/v4-protos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
"homepage": "https://github.com/dydxprotocol/indexer#readme",
"dependencies": {
"@bufbuild/buf": "1.19.0-1",
"@cosmjs/amino": "^0.29.3",
"@cosmjs/proto-signing": "^0.29.3",
"@cosmjs/stargate": "^0.29.3",
"@cosmjs/tendermint-rpc": "^0.29.3",
"@cosmjs/amino": "^0.32.1",
"@cosmjs/proto-signing": "^0.32.1",
"@cosmjs/stargate": "^0.32.1",
"@cosmjs/tendermint-rpc": "^0.32.1",
"@osmonauts/lcd": "^0.6.0",
"bech32": "^2.0.0",
"dotenv-flow": "^3.2.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Rpc } from "../../helpers";
import * as _m0 from "protobufjs/minimal";
import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate";
import { QueryGetClobPairRequest, QueryClobPairResponse, QueryAllClobPairRequest, QueryClobPairAllResponse, AreSubaccountsLiquidatableRequest, AreSubaccountsLiquidatableResponse, MevNodeToNodeCalculationRequest, MevNodeToNodeCalculationResponse, QueryEquityTierLimitConfigurationRequest, QueryEquityTierLimitConfigurationResponse, QueryBlockRateLimitConfigurationRequest, QueryBlockRateLimitConfigurationResponse, QueryLiquidationsConfigurationRequest, QueryLiquidationsConfigurationResponse } from "./query";
import { QueryGetClobPairRequest, QueryClobPairResponse, QueryAllClobPairRequest, QueryClobPairAllResponse, MevNodeToNodeCalculationRequest, MevNodeToNodeCalculationResponse, QueryEquityTierLimitConfigurationRequest, QueryEquityTierLimitConfigurationResponse, QueryBlockRateLimitConfigurationRequest, QueryBlockRateLimitConfigurationResponse, QueryLiquidationsConfigurationRequest, QueryLiquidationsConfigurationResponse } from "./query";
/** Query defines the gRPC querier service. */

export interface Query {
Expand All @@ -10,9 +10,6 @@ export interface Query {
/** Queries a list of ClobPair items. */

clobPairAll(request?: QueryAllClobPairRequest): Promise<QueryClobPairAllResponse>;
/** Returns whether a subaccount is liquidatable. */

areSubaccountsLiquidatable(request: AreSubaccountsLiquidatableRequest): Promise<AreSubaccountsLiquidatableResponse>;
/** Runs the MEV node <> node calculation with the provided parameters. */

mevNodeToNodeCalculation(request: MevNodeToNodeCalculationRequest): Promise<MevNodeToNodeCalculationResponse>;
Expand All @@ -33,7 +30,6 @@ export class QueryClientImpl implements Query {
this.rpc = rpc;
this.clobPair = this.clobPair.bind(this);
this.clobPairAll = this.clobPairAll.bind(this);
this.areSubaccountsLiquidatable = this.areSubaccountsLiquidatable.bind(this);
this.mevNodeToNodeCalculation = this.mevNodeToNodeCalculation.bind(this);
this.equityTierLimitConfiguration = this.equityTierLimitConfiguration.bind(this);
this.blockRateLimitConfiguration = this.blockRateLimitConfiguration.bind(this);
Expand All @@ -54,12 +50,6 @@ export class QueryClientImpl implements Query {
return promise.then(data => QueryClobPairAllResponse.decode(new _m0.Reader(data)));
}

areSubaccountsLiquidatable(request: AreSubaccountsLiquidatableRequest): Promise<AreSubaccountsLiquidatableResponse> {
const data = AreSubaccountsLiquidatableRequest.encode(request).finish();
const promise = this.rpc.request("dydxprotocol.clob.Query", "AreSubaccountsLiquidatable", data);
return promise.then(data => AreSubaccountsLiquidatableResponse.decode(new _m0.Reader(data)));
}

mevNodeToNodeCalculation(request: MevNodeToNodeCalculationRequest): Promise<MevNodeToNodeCalculationResponse> {
const data = MevNodeToNodeCalculationRequest.encode(request).finish();
const promise = this.rpc.request("dydxprotocol.clob.Query", "MevNodeToNodeCalculation", data);
Expand Down Expand Up @@ -97,10 +87,6 @@ export const createRpcQueryExtension = (base: QueryClient) => {
return queryService.clobPairAll(request);
},

areSubaccountsLiquidatable(request: AreSubaccountsLiquidatableRequest): Promise<AreSubaccountsLiquidatableResponse> {
return queryService.areSubaccountsLiquidatable(request);
},

mevNodeToNodeCalculation(request: MevNodeToNodeCalculationRequest): Promise<MevNodeToNodeCalculationResponse> {
return queryService.mevNodeToNodeCalculation(request);
},
Expand Down
192 changes: 0 additions & 192 deletions indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/query.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../cosmos/base/query/v1beta1/pagination";
import { SubaccountId, SubaccountIdSDKType } from "../subaccounts/subaccount";
import { ValidatorMevMatches, ValidatorMevMatchesSDKType, MevNodeToNodeMetrics, MevNodeToNodeMetricsSDKType } from "./mev";
import { ClobPair, ClobPairSDKType } from "./clob_pair";
import { EquityTierLimitConfiguration, EquityTierLimitConfigurationSDKType } from "./equity_tier_limit_config";
Expand Down Expand Up @@ -51,52 +50,6 @@ export interface QueryClobPairAllResponseSDKType {
clob_pair: ClobPairSDKType[];
pagination?: PageResponseSDKType;
}
/**
* AreSubaccountsLiquidatableRequest is a request message used to check whether
* the given subaccounts are liquidatable.
* The subaccount ids should not contain duplicates.
*/

export interface AreSubaccountsLiquidatableRequest {
subaccountIds: SubaccountId[];
}
/**
* AreSubaccountsLiquidatableRequest is a request message used to check whether
* the given subaccounts are liquidatable.
* The subaccount ids should not contain duplicates.
*/

export interface AreSubaccountsLiquidatableRequestSDKType {
subaccount_ids: SubaccountIdSDKType[];
}
/**
* AreSubaccountsLiquidatableResponse is a response message that contains the
* liquidation status for each subaccount.
*/

export interface AreSubaccountsLiquidatableResponse {
results: AreSubaccountsLiquidatableResponse_Result[];
}
/**
* AreSubaccountsLiquidatableResponse is a response message that contains the
* liquidation status for each subaccount.
*/

export interface AreSubaccountsLiquidatableResponseSDKType {
results: AreSubaccountsLiquidatableResponse_ResultSDKType[];
}
/** Result returns whether a subaccount should be liquidated. */

export interface AreSubaccountsLiquidatableResponse_Result {
subaccountId?: SubaccountId;
isLiquidatable: boolean;
}
/** Result returns whether a subaccount should be liquidated. */

export interface AreSubaccountsLiquidatableResponse_ResultSDKType {
subaccount_id?: SubaccountIdSDKType;
is_liquidatable: boolean;
}
/**
* MevNodeToNodeCalculationRequest is a request message used to run the
* MEV node <> node calculation.
Expand Down Expand Up @@ -436,151 +389,6 @@ export const QueryClobPairAllResponse = {

};

function createBaseAreSubaccountsLiquidatableRequest(): AreSubaccountsLiquidatableRequest {
return {
subaccountIds: []
};
}

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

return writer;
},

decode(input: _m0.Reader | Uint8Array, length?: number): AreSubaccountsLiquidatableRequest {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseAreSubaccountsLiquidatableRequest();

while (reader.pos < end) {
const tag = reader.uint32();

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

default:
reader.skipType(tag & 7);
break;
}
}

return message;
},

fromPartial(object: DeepPartial<AreSubaccountsLiquidatableRequest>): AreSubaccountsLiquidatableRequest {
const message = createBaseAreSubaccountsLiquidatableRequest();
message.subaccountIds = object.subaccountIds?.map(e => SubaccountId.fromPartial(e)) || [];
return message;
}

};

function createBaseAreSubaccountsLiquidatableResponse(): AreSubaccountsLiquidatableResponse {
return {
results: []
};
}

export const AreSubaccountsLiquidatableResponse = {
encode(message: AreSubaccountsLiquidatableResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
for (const v of message.results) {
AreSubaccountsLiquidatableResponse_Result.encode(v!, writer.uint32(10).fork()).ldelim();
}

return writer;
},

decode(input: _m0.Reader | Uint8Array, length?: number): AreSubaccountsLiquidatableResponse {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseAreSubaccountsLiquidatableResponse();

while (reader.pos < end) {
const tag = reader.uint32();

switch (tag >>> 3) {
case 1:
message.results.push(AreSubaccountsLiquidatableResponse_Result.decode(reader, reader.uint32()));
break;

default:
reader.skipType(tag & 7);
break;
}
}

return message;
},

fromPartial(object: DeepPartial<AreSubaccountsLiquidatableResponse>): AreSubaccountsLiquidatableResponse {
const message = createBaseAreSubaccountsLiquidatableResponse();
message.results = object.results?.map(e => AreSubaccountsLiquidatableResponse_Result.fromPartial(e)) || [];
return message;
}

};

function createBaseAreSubaccountsLiquidatableResponse_Result(): AreSubaccountsLiquidatableResponse_Result {
return {
subaccountId: undefined,
isLiquidatable: false
};
}

export const AreSubaccountsLiquidatableResponse_Result = {
encode(message: AreSubaccountsLiquidatableResponse_Result, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.subaccountId !== undefined) {
SubaccountId.encode(message.subaccountId, writer.uint32(10).fork()).ldelim();
}

if (message.isLiquidatable === true) {
writer.uint32(16).bool(message.isLiquidatable);
}

return writer;
},

decode(input: _m0.Reader | Uint8Array, length?: number): AreSubaccountsLiquidatableResponse_Result {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseAreSubaccountsLiquidatableResponse_Result();

while (reader.pos < end) {
const tag = reader.uint32();

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

case 2:
message.isLiquidatable = reader.bool();
break;

default:
reader.skipType(tag & 7);
break;
}
}

return message;
},

fromPartial(object: DeepPartial<AreSubaccountsLiquidatableResponse_Result>): AreSubaccountsLiquidatableResponse_Result {
const message = createBaseAreSubaccountsLiquidatableResponse_Result();
message.subaccountId = object.subaccountId !== undefined && object.subaccountId !== null ? SubaccountId.fromPartial(object.subaccountId) : undefined;
message.isLiquidatable = object.isLiquidatable ?? false;
return message;
}

};

function createBaseMevNodeToNodeCalculationRequest(): MevNodeToNodeCalculationRequest {
return {
blockProposerMatches: undefined,
Expand Down
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
Loading

0 comments on commit 2bddbbe

Please sign in to comment.