Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions indexer/packages/postgres/src/stores/fill-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { getUuid } from '../helpers/uuid';
import { getSubaccountQueryForParent } from '../lib/parent-subaccount-helpers';
import FillModel from '../models/fill-model';
import {
CostOfFills,
FillColumns,
FillCreateObject,
FillFromDatabase,
Expand All @@ -26,7 +27,6 @@ import {
OrderedFillsWithFundingIndices,
Ordering,
OrderSide,
CostOfFills,
PaginationFromDatabase,
QueryableField,
QueryConfig,
Expand Down Expand Up @@ -96,6 +96,8 @@ export async function findAll(
side,
liquidity,
type,
includeTypes,
excludeTypes,
clobPairId,
eventId,
transactionHash,
Expand Down Expand Up @@ -165,6 +167,14 @@ export async function findAll(
baseQuery = baseQuery.where(FillColumns.type, type);
}

if (includeTypes !== undefined && includeTypes.length > 0) {
baseQuery = baseQuery.whereIn(FillColumns.type, includeTypes);
}

if (excludeTypes !== undefined && excludeTypes.length > 0) {
baseQuery = baseQuery.whereNotIn(FillColumns.type, excludeTypes);
}

if (clobPairId !== undefined) {
baseQuery = baseQuery.where(FillColumns.clobPairId, clobPairId);
}
Expand Down Expand Up @@ -246,8 +256,8 @@ export async function update(
): Promise<FillFromDatabase | undefined> {
const fill = await FillModel.query(
Transaction.get(options.txId),
// TODO fix expression typing so we dont have to use any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
// TODO fix expression typing so we dont have to use any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
).findById(fields.id).patch(fields as any).returning('*');
// The objection types mistakenly think the query returns an array of fills.
return fill as unknown as (FillFromDatabase | undefined);
Expand Down
10 changes: 10 additions & 0 deletions indexer/packages/postgres/src/stores/order-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ export async function findAll(
totalFilled,
price,
type,
includeTypes,
excludeTypes,
statuses,
reduceOnly,
orderFlags,
Expand Down Expand Up @@ -153,6 +155,14 @@ export async function findAll(
baseQuery = baseQuery.where(OrderColumns.type, type);
}

if (includeTypes !== undefined && includeTypes.length > 0) {
baseQuery = baseQuery.whereIn(OrderColumns.type, includeTypes);
}

if (excludeTypes !== undefined && excludeTypes.length > 0) {
baseQuery = baseQuery.whereNotIn(OrderColumns.type, excludeTypes);
}

if (statuses !== undefined) {
baseQuery = baseQuery.whereIn(OrderColumns.status, statuses);
}
Expand Down
10 changes: 8 additions & 2 deletions indexer/packages/postgres/src/types/query-types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* ------- QUERY TYPES ------- */

import { CandleResolution } from './candle-types';
import { Liquidity } from './fill-types';
import { FillType, Liquidity } from './fill-types';
import { OrderSide, OrderStatus, OrderType } from './order-types';
import { PerpetualPositionStatus } from './perpetual-position-types';
import { PositionSide } from './position-types';
Expand Down Expand Up @@ -29,6 +29,8 @@ export enum QueryableField {
TYPE = 'type',
STATUS = 'status',
STATUSES = 'statuses',
INCLUDE_TYPES = 'includeTypes',
EXCLUDE_TYPES = 'excludeTypes',
POST_ONLY = 'postOnly',
REDUCE_ONLY = 'reduceOnly',
PERPETUAL_ID = 'perpetualId',
Expand Down Expand Up @@ -149,6 +151,8 @@ export interface OrderQueryConfig extends QueryConfig {
[QueryableField.TOTAL_FILLED]?: string,
[QueryableField.PRICE]?: string,
[QueryableField.TYPE]?: OrderType,
[QueryableField.INCLUDE_TYPES]?: OrderType[],
[QueryableField.EXCLUDE_TYPES]?: OrderType[],
[QueryableField.STATUSES]?: OrderStatus[],
[QueryableField.POST_ONLY]?: boolean,
[QueryableField.REDUCE_ONLY]?: boolean,
Expand All @@ -173,7 +177,9 @@ export interface FillQueryConfig extends QueryConfig {
[QueryableField.SUBACCOUNT_ID]?: string[],
[QueryableField.SIDE]?: OrderSide,
[QueryableField.LIQUIDITY]?: Liquidity,
[QueryableField.TYPE]?: OrderType,
[QueryableField.TYPE]?: FillType,
[QueryableField.INCLUDE_TYPES]?: FillType[],
[QueryableField.EXCLUDE_TYPES]?: FillType[],
[QueryableField.CLOB_PAIR_ID]?: string,
[QueryableField.EVENT_ID]?: Buffer,
[QueryableField.TRANSACTION_HASH]?: string,
Expand Down
73 changes: 73 additions & 0 deletions indexer/services/comlink/public/api-documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -1253,6 +1253,8 @@ fetch(`${baseURL}/fills?address=string&subaccountNumber=0.1`,
|subaccountNumber|query|number(double)|true|none|
|market|query|string|false|none|
|marketType|query|[MarketType](#schemamarkettype)|false|none|
|includeTypes|query|array[string]|false|none|
|excludeTypes|query|array[string]|false|none|
|limit|query|number(double)|false|none|
|createdBeforeOrAtHeight|query|number(double)|false|none|
|createdBeforeOrAt|query|[IsoString](#schemaisostring)|false|none|
Expand All @@ -1264,6 +1266,18 @@ fetch(`${baseURL}/fills?address=string&subaccountNumber=0.1`,
|---|---|
|marketType|PERPETUAL|
|marketType|SPOT|
|includeTypes|LIMIT|
|includeTypes|LIQUIDATED|
|includeTypes|LIQUIDATION|
|includeTypes|DELEVERAGED|
|includeTypes|OFFSETTING|
|includeTypes|TWAP_SUBORDER|
|excludeTypes|LIMIT|
|excludeTypes|LIQUIDATED|
|excludeTypes|LIQUIDATION|
|excludeTypes|DELEVERAGED|
|excludeTypes|OFFSETTING|
|excludeTypes|TWAP_SUBORDER|

> Example responses

Expand Down Expand Up @@ -1366,9 +1380,28 @@ fetch(`${baseURL}/fills/parentSubaccount?address=string&parentSubaccountNumber=0
|---|---|---|---|---|
|address|query|string|true|none|
|parentSubaccountNumber|query|number(double)|true|none|
|includeTypes|query|array[string]|false|none|
|excludeTypes|query|array[string]|false|none|
|limit|query|number(double)|false|none|
|page|query|number(double)|false|none|

#### Enumerated Values

|Parameter|Value|
|---|---|
|includeTypes|LIMIT|
|includeTypes|LIQUIDATED|
|includeTypes|LIQUIDATION|
|includeTypes|DELEVERAGED|
|includeTypes|OFFSETTING|
|includeTypes|TWAP_SUBORDER|
|excludeTypes|LIMIT|
|excludeTypes|LIQUIDATED|
|excludeTypes|LIQUIDATION|
|excludeTypes|DELEVERAGED|
|excludeTypes|OFFSETTING|
|excludeTypes|TWAP_SUBORDER|

> Example responses

> 200 Response
Expand Down Expand Up @@ -2279,6 +2312,8 @@ fetch(`${baseURL}/orders?address=string&subaccountNumber=0.1`,
|ticker|query|string|false|none|
|side|query|[OrderSide](#schemaorderside)|false|none|
|type|query|[OrderType](#schemaordertype)|false|none|
|includeTypes|query|array[string]|false|none|
|excludeTypes|query|array[string]|false|none|
|status|query|array[any]|false|none|
|goodTilBlockBeforeOrAt|query|number(double)|false|none|
|goodTilBlockAfter|query|number(double)|false|none|
Expand All @@ -2301,6 +2336,24 @@ fetch(`${baseURL}/orders?address=string&subaccountNumber=0.1`,
|type|TAKE_PROFIT_MARKET|
|type|TWAP|
|type|TWAP_SUBORDER|
|includeTypes|LIMIT|
|includeTypes|MARKET|
|includeTypes|STOP_LIMIT|
|includeTypes|STOP_MARKET|
|includeTypes|TRAILING_STOP|
|includeTypes|TAKE_PROFIT|
|includeTypes|TAKE_PROFIT_MARKET|
|includeTypes|TWAP|
|includeTypes|TWAP_SUBORDER|
|excludeTypes|LIMIT|
|excludeTypes|MARKET|
|excludeTypes|STOP_LIMIT|
|excludeTypes|STOP_MARKET|
|excludeTypes|TRAILING_STOP|
|excludeTypes|TAKE_PROFIT|
|excludeTypes|TAKE_PROFIT_MARKET|
|excludeTypes|TWAP|
|excludeTypes|TWAP_SUBORDER|

> Example responses

Expand Down Expand Up @@ -2492,6 +2545,8 @@ fetch(`${baseURL}/orders/parentSubaccountNumber?address=string&parentSubaccountN
|ticker|query|string|false|none|
|side|query|[OrderSide](#schemaorderside)|false|none|
|type|query|[OrderType](#schemaordertype)|false|none|
|includeTypes|query|array[string]|false|none|
|excludeTypes|query|array[string]|false|none|
|status|query|array[any]|false|none|
|goodTilBlockBeforeOrAt|query|number(double)|false|none|
|goodTilBlockAfter|query|number(double)|false|none|
Expand All @@ -2514,6 +2569,24 @@ fetch(`${baseURL}/orders/parentSubaccountNumber?address=string&parentSubaccountN
|type|TAKE_PROFIT_MARKET|
|type|TWAP|
|type|TWAP_SUBORDER|
|includeTypes|LIMIT|
|includeTypes|MARKET|
|includeTypes|STOP_LIMIT|
|includeTypes|STOP_MARKET|
|includeTypes|TRAILING_STOP|
|includeTypes|TAKE_PROFIT|
|includeTypes|TAKE_PROFIT_MARKET|
|includeTypes|TWAP|
|includeTypes|TWAP_SUBORDER|
|excludeTypes|LIMIT|
|excludeTypes|MARKET|
|excludeTypes|STOP_LIMIT|
|excludeTypes|STOP_MARKET|
|excludeTypes|TRAILING_STOP|
|excludeTypes|TAKE_PROFIT|
|excludeTypes|TAKE_PROFIT_MARKET|
|excludeTypes|TWAP|
|excludeTypes|TWAP_SUBORDER|

> Example responses

Expand Down
88 changes: 88 additions & 0 deletions indexer/services/comlink/public/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2508,6 +2508,28 @@
"$ref": "#/components/schemas/MarketType"
}
},
{
"in": "query",
"name": "includeTypes",
"required": false,
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/FillType"
}
}
},
{
"in": "query",
"name": "excludeTypes",
"required": false,
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/FillType"
}
}
},
{
"in": "query",
"name": "limit",
Expand Down Expand Up @@ -2580,6 +2602,28 @@
"type": "number"
}
},
{
"in": "query",
"name": "includeTypes",
"required": false,
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/FillType"
}
}
},
{
"in": "query",
"name": "excludeTypes",
"required": false,
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/FillType"
}
}
},
{
"in": "query",
"name": "limit",
Expand Down Expand Up @@ -3205,6 +3249,28 @@
"$ref": "#/components/schemas/OrderType"
}
},
{
"in": "query",
"name": "includeTypes",
"required": false,
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/OrderType"
}
}
},
{
"in": "query",
"name": "excludeTypes",
"required": false,
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/OrderType"
}
}
},
{
"in": "query",
"name": "status",
Expand Down Expand Up @@ -3331,6 +3397,28 @@
"$ref": "#/components/schemas/OrderType"
}
},
{
"in": "query",
"name": "includeTypes",
"required": false,
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/OrderType"
}
}
},
{
"in": "query",
"name": "excludeTypes",
"required": false,
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/OrderType"
}
}
},
{
"in": "query",
"name": "status",
Expand Down
Loading
Loading