Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TRA-103] Add subaccountNumber field in fills response result #1192

Merged
merged 1 commit into from
Mar 18, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ describe('fills-controller#V4', () => {
orderId: ethOrder.id,
createdAt: ethFill.createdAt,
createdAtHeight: ethFill.createdAtHeight,
subaccountNumber: defaultSubaccountNumber,
};

// Only the ETH-USD order should be returned
Expand Down
10 changes: 7 additions & 3 deletions indexer/services/comlink/public/api-documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,8 @@ fetch('https://dydx-testnet.imperator.co/v4/fills?address=string&subaccountNumbe
"createdAt": "string",
"createdAtHeight": "string",
"orderId": "string",
"clientMetadata": "string"
"clientMetadata": "string",
"subaccountNumber": 0
}
]
}
Expand Down Expand Up @@ -2598,7 +2599,8 @@ This operation does not require authentication
"createdAt": "string",
"createdAtHeight": "string",
"orderId": "string",
"clientMetadata": "string"
"clientMetadata": "string",
"subaccountNumber": 0
}

```
Expand All @@ -2620,6 +2622,7 @@ This operation does not require authentication
|createdAtHeight|string|true|none|none|
|orderId|string|false|none|none|
|clientMetadata|string|false|none|none|
|subaccountNumber|number(double)|true|none|none|

## FillResponse

Expand All @@ -2644,7 +2647,8 @@ This operation does not require authentication
"createdAt": "string",
"createdAtHeight": "string",
"orderId": "string",
"clientMetadata": "string"
"clientMetadata": "string",
"subaccountNumber": 0
}
]
}
Expand Down
7 changes: 6 additions & 1 deletion indexer/services/comlink/public/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,10 @@
},
"clientMetadata": {
"type": "string"
},
"subaccountNumber": {
"type": "number",
"format": "double"
}
},
"required": [
Expand All @@ -422,7 +426,8 @@
"size",
"fee",
"createdAt",
"createdAtHeight"
"createdAtHeight",
"subaccountNumber"
],
"type": "object",
"additionalProperties": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class FillsController extends Controller {

return {
fills: fills.map((fill: FillFromDatabase): FillResponseObject => {
return fillToResponseObject(fill, clobPairIdToMarket);
return fillToResponseObject(fill, clobPairIdToMarket, subaccountNumber);
}),
};
}
Expand Down Expand Up @@ -139,13 +139,16 @@ router.get(
createdBeforeOrAt,
}: FillRequest = matchedData(req) as FillRequest;

// The schema checks allow subaccountNumber to be a string, but we know it's a number here.
const subaccountNum : number = +subaccountNumber;

// TODO(DEC-656): Change to using a cache of markets in Redis similar to Librarian instead of
// querying the DB.
try {
const controller: FillsController = new FillsController();
const response: FillResponse = await controller.getFills(
address,
subaccountNumber,
subaccountNum,
market,
marketType,
limit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export function assetPositionToResponseObject(
export function fillToResponseObject(
fill: FillFromDatabase,
marketsByClobPairId: MarketAndTypeByClobPairId,
subaccountNumber: number,
): FillResponseObject {
return {
id: fill.id,
Expand All @@ -149,6 +150,7 @@ export function fillToResponseObject(
createdAtHeight: fill.createdAtHeight,
orderId: fill.orderId,
clientMetadata: fill.clientMetadata,
subaccountNumber,
};
}

Expand Down
1 change: 1 addition & 0 deletions indexer/services/comlink/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export interface FillResponseObject {
createdAtHeight: string,
orderId?: string,
clientMetadata?: string,
subaccountNumber: number,
}

/* ------- TRANSFER TYPES ------- */
Expand Down
Loading