diff --git a/indexer/packages/postgres/src/types/index.ts b/indexer/packages/postgres/src/types/index.ts
index a4b86b9446..18452d6304 100644
--- a/indexer/packages/postgres/src/types/index.ts
+++ b/indexer/packages/postgres/src/types/index.ts
@@ -12,6 +12,7 @@ export * from './utility-types';
export * from './asset-types';
export * from './asset-position-types';
export * from './transfer-types';
+export * from './trade-types';
export * from './market-types';
export * from './oracle-price-types';
export * from './websocket-message-types';
diff --git a/indexer/packages/postgres/src/types/trade-types.ts b/indexer/packages/postgres/src/types/trade-types.ts
new file mode 100644
index 0000000000..26b15be4e3
--- /dev/null
+++ b/indexer/packages/postgres/src/types/trade-types.ts
@@ -0,0 +1,23 @@
+import { FillType } from './fill-types';
+
+export enum TradeType {
+ // LIMIT is the trade type for a fill with a limit taker order.
+ LIMIT = 'LIMIT',
+ // LIQUIDATED is the trade type for a fill with a liquidated taker order.
+ LIQUIDATED = 'LIQUIDATED',
+ // DELEVERAGED is the trade type for a fill with a deleveraged taker order.
+ DELEVERAGED = 'DELEVERAGED',
+}
+
+export function fillTypeToTradeType(fillType: FillType): TradeType {
+ switch (fillType) {
+ case FillType.LIMIT:
+ return TradeType.LIMIT;
+ case FillType.LIQUIDATED:
+ return TradeType.LIQUIDATED;
+ case FillType.DELEVERAGED:
+ return TradeType.DELEVERAGED;
+ default:
+ throw new Error(`Unknown fill type: ${fillType}`);
+ }
+}
diff --git a/indexer/packages/postgres/src/types/websocket-message-types.ts b/indexer/packages/postgres/src/types/websocket-message-types.ts
index 5b81b64c09..fe22d02866 100644
--- a/indexer/packages/postgres/src/types/websocket-message-types.ts
+++ b/indexer/packages/postgres/src/types/websocket-message-types.ts
@@ -8,6 +8,7 @@ import {
import { PerpetualMarketStatus } from './perpetual-market-types';
import { PerpetualPositionStatus } from './perpetual-position-types';
import { PositionSide } from './position-types';
+import { TradeType } from './trade-types';
import { TransferType } from './transfer-types';
import { IsoString } from './utility-types';
@@ -175,7 +176,7 @@ export interface TradeContent {
price: string,
side: string,
createdAt: IsoString,
- type: FillType,
+ type: TradeType,
}
/* ------- MarketMessageContents ------- */
diff --git a/indexer/services/comlink/public/api-documentation.md b/indexer/services/comlink/public/api-documentation.md
index 459cff2273..141caedf8b 100644
--- a/indexer/services/comlink/public/api-documentation.md
+++ b/indexer/services/comlink/public/api-documentation.md
@@ -3049,6 +3049,32 @@ or
|iso|[IsoString](#schemaisostring)|true|none|none|
|epoch|number(double)|true|none|none|
+## TradeType
+
+
+
+
+
+
+```json
+"LIMIT"
+
+```
+
+### Properties
+
+|Name|Type|Required|Restrictions|Description|
+|---|---|---|---|---|
+|*anonymous*|string|false|none|none|
+
+#### Enumerated Values
+
+|Property|Value|
+|---|---|
+|*anonymous*|LIMIT|
+|*anonymous*|LIQUIDATED|
+|*anonymous*|DELEVERAGED|
+
## TradeResponseObject
@@ -3077,7 +3103,7 @@ or
|side|[OrderSide](#schemaorderside)|true|none|none|
|size|string|true|none|none|
|price|string|true|none|none|
-|type|[FillType](#schemafilltype)|true|none|none|
+|type|[TradeType](#schematradetype)|true|none|none|
|createdAt|[IsoString](#schemaisostring)|true|none|none|
|createdAtHeight|string|true|none|none|
diff --git a/indexer/services/comlink/public/swagger.json b/indexer/services/comlink/public/swagger.json
index 6e74f995c9..f6036eef70 100644
--- a/indexer/services/comlink/public/swagger.json
+++ b/indexer/services/comlink/public/swagger.json
@@ -844,6 +844,14 @@
"type": "object",
"additionalProperties": false
},
+ "TradeType": {
+ "enum": [
+ "LIMIT",
+ "LIQUIDATED",
+ "DELEVERAGED"
+ ],
+ "type": "string"
+ },
"TradeResponseObject": {
"properties": {
"id": {
@@ -859,7 +867,7 @@
"type": "string"
},
"type": {
- "$ref": "#/components/schemas/FillType"
+ "$ref": "#/components/schemas/TradeType"
},
"createdAt": {
"$ref": "#/components/schemas/IsoString"
diff --git a/indexer/services/comlink/public/websocket-documentation.md b/indexer/services/comlink/public/websocket-documentation.md
index b0b5f634b6..495e3a6eff 100644
--- a/indexer/services/comlink/public/websocket-documentation.md
+++ b/indexer/services/comlink/public/websocket-documentation.md
@@ -266,6 +266,15 @@ export enum FillType {
OFFSETTING = 'OFFSETTING',
}
+export enum TradeType {
+ // LIMIT is the trade type for a fill with a limit taker order.
+ LIMIT = 'LIMIT',
+ // LIQUIDATED is the trade type for a fill with a liquidated taker order.
+ LIQUIDATED = 'LIQUIDATED',
+ // DELEVERAGED is the trade type for a fill with a deleveraged taker order.
+ DELEVERAGED = 'DELEVERAGED',
+}
+
export interface TransferSubaccountMessageContents {
sender: {
address: string,
@@ -712,7 +721,7 @@ interface TradeContent {
price: string,
side: string,
createdAt: IsoString,
- type: FillType,
+ type: TradeType,
}
```
@@ -734,7 +743,7 @@ interface TradeContent {
"price": "27839",
"side": "BUY",
"createdAt": "2023-04-04T00:29:19.353Z",
- "type": "LIQUIDATION"
+ "type": "LIQUIDATED"
},
{
"id": "38e64479-af09-5417-a795-195f83879156",
@@ -742,7 +751,7 @@ interface TradeContent {
"price": "27839",
"side": "BUY",
"createdAt": "2023-04-04T00:29:19.353Z",
- "type": "LIQUIDATION"
+ "type": "LIQUIDATED"
},
{
"id": "d310c32c-f066-5ba8-a97d-10a29d9a6c84",
diff --git a/indexer/services/comlink/src/request-helpers/request-transformer.ts b/indexer/services/comlink/src/request-helpers/request-transformer.ts
index ac42f78370..388e33f13f 100644
--- a/indexer/services/comlink/src/request-helpers/request-transformer.ts
+++ b/indexer/services/comlink/src/request-helpers/request-transformer.ts
@@ -4,7 +4,7 @@ import {
BestEffortOpenedStatus,
CandleColumns,
CandleFromDatabase,
- FillFromDatabase,
+ FillFromDatabase, fillTypeToTradeType,
FundingIndexUpdatesFromDatabase,
helpers,
LiquidityTiersFromDatabase,
@@ -177,7 +177,7 @@ export function fillToTradeResponseObject(
side: fill.side,
size: fill.size,
price: fill.price,
- type: fill.type,
+ type: fillTypeToTradeType(fill.type),
createdAt: fill.createdAt,
createdAtHeight: fill.createdAtHeight,
};
diff --git a/indexer/services/comlink/src/types.ts b/indexer/services/comlink/src/types.ts
index bb15fe85f0..dd99426685 100644
--- a/indexer/services/comlink/src/types.ts
+++ b/indexer/services/comlink/src/types.ts
@@ -16,7 +16,7 @@ import {
PerpetualPositionFromDatabase,
PerpetualPositionStatus,
PositionSide,
- SubaccountFromDatabase,
+ SubaccountFromDatabase, TradeType,
TransferType,
} from '@dydxprotocol-indexer/postgres';
import { RedisOrder } from '@dydxprotocol-indexer/v4-protos';
@@ -174,7 +174,7 @@ export interface TradeResponseObject {
side: OrderSide,
size: string,
price: string,
- type: FillType,
+ type: TradeType,
createdAt: IsoString,
createdAtHeight: string,
}
diff --git a/indexer/services/ender/__tests__/helpers/constants.ts b/indexer/services/ender/__tests__/helpers/constants.ts
index 4e8dfbeba5..cd583a6ac3 100644
--- a/indexer/services/ender/__tests__/helpers/constants.ts
+++ b/indexer/services/ender/__tests__/helpers/constants.ts
@@ -1,5 +1,5 @@
import { SUBACCOUNTS_WEBSOCKET_MESSAGE_VERSION } from '@dydxprotocol-indexer/kafka';
-import { FillType, testConstants, TradeContent } from '@dydxprotocol-indexer/postgres';
+import { testConstants, TradeContent, TradeType } from '@dydxprotocol-indexer/postgres';
import {
bigIntToBytes,
ORDER_FLAG_CONDITIONAL,
@@ -325,7 +325,7 @@ export const defaultTradeContent: TradeContent = {
price: '10000',
side: 'BUY',
createdAt: 'createdAt',
- type: FillType.LIMIT,
+ type: TradeType.LIMIT,
};
export const defaultTradeMessage: SingleTradeMessage = contentToSingleTradeMessage(
defaultTradeContent,
diff --git a/indexer/services/ender/__tests__/helpers/indexer-proto-helpers.ts b/indexer/services/ender/__tests__/helpers/indexer-proto-helpers.ts
index 684dc0665b..0a1fc7dbea 100644
--- a/indexer/services/ender/__tests__/helpers/indexer-proto-helpers.ts
+++ b/indexer/services/ender/__tests__/helpers/indexer-proto-helpers.ts
@@ -29,6 +29,7 @@ import {
PerpetualMarketFromDatabase,
PerpetualMarketTable,
IsoString,
+ fillTypeToTradeType,
} from '@dydxprotocol-indexer/postgres';
import { getOrderIdHash } from '@dydxprotocol-indexer/v4-proto-parser';
import {
@@ -805,7 +806,7 @@ export async function expectDefaultTradeKafkaMessageFromTakerFillId(
price: takerFill!.price,
side: takerFill!.side.toString(),
createdAt: takerFill!.createdAt,
- type: takerFill!.type,
+ type: fillTypeToTradeType(takerFill!.type),
},
],
};
diff --git a/indexer/services/ender/__tests__/lib/kafka-publisher.test.ts b/indexer/services/ender/__tests__/lib/kafka-publisher.test.ts
index 184ddfd104..3656be98b3 100644
--- a/indexer/services/ender/__tests__/lib/kafka-publisher.test.ts
+++ b/indexer/services/ender/__tests__/lib/kafka-publisher.test.ts
@@ -14,6 +14,7 @@ import {
testConstants,
TradeContent,
TradeMessageContents,
+ TradeType,
TransferFromDatabase,
} from '@dydxprotocol-indexer/postgres';
import { IndexerSubaccountId, SubaccountMessage, TradeMessage } from '@dydxprotocol-indexer/v4-protos';
@@ -409,7 +410,7 @@ describe('kafka-publisher', () => {
price: '10000',
side: 'side',
createdAt: 'today',
- type: FillType.LIMIT,
+ type: TradeType.LIMIT,
};
const singleTrade1: SingleTradeMessage = contentToSingleTradeMessage(
tradeContent1,
@@ -422,7 +423,7 @@ describe('kafka-publisher', () => {
price: '12000',
side: 'side',
createdAt: 'today',
- type: FillType.LIMIT,
+ type: TradeType.LIMIT,
};
const singleTrade2: SingleTradeMessage = contentToSingleTradeMessage(
tradeContent2,
@@ -436,7 +437,7 @@ describe('kafka-publisher', () => {
price: '1000',
side: 'side',
createdAt: 'today',
- type: FillType.LIMIT,
+ type: TradeType.LIMIT,
};
const singleTrade3: SingleTradeMessage = contentToSingleTradeMessage(
tradeContent3,
diff --git a/indexer/services/ender/src/handlers/order-fills/abstract-order-fill-handler.ts b/indexer/services/ender/src/handlers/order-fills/abstract-order-fill-handler.ts
index d1e718817d..b3fefe9531 100644
--- a/indexer/services/ender/src/handlers/order-fills/abstract-order-fill-handler.ts
+++ b/indexer/services/ender/src/handlers/order-fills/abstract-order-fill-handler.ts
@@ -6,6 +6,7 @@ import {
FillFromDatabase,
FillTable,
FillType,
+ fillTypeToTradeType,
Liquidity,
OrderCreateObject,
OrderFromDatabase,
@@ -426,7 +427,7 @@ export abstract class AbstractOrderFillHandler extends Handler {
price: fill.price,
side: fill.side.toString(),
createdAt: fill.createdAt,
- type: fill.type,
+ type: fillTypeToTradeType(fill.type),
},
],
};