diff --git a/v4-client-js/__tests__/modules/client/AccountEndpoints.test.ts b/v4-client-js/__tests__/modules/client/AccountEndpoints.test.ts index e1ca2b4e..d8161cf4 100644 --- a/v4-client-js/__tests__/modules/client/AccountEndpoints.test.ts +++ b/v4-client-js/__tests__/modules/client/AccountEndpoints.test.ts @@ -56,6 +56,17 @@ describe('IndexerClient', () => { } }); + it('Transfers ParentSubaccountNumber', async () => { + const response = await client.account.getParentSubaccountNumberTransfers(DYDX_TEST_ADDRESS, 0); + expect(response).not.toBeNull(); + const transfers = response.transfers; + expect(transfers).not.toBeNull(); + if (transfers.length > 0) { + const transfer = transfers[0]; + expect(transfer).not.toBeNull(); + } + }); + it('Transfers Pagination', async () => { const response = await client.account.getSubaccountTransfers( DYDX_TEST_ADDRESS, @@ -80,6 +91,30 @@ describe('IndexerClient', () => { expect(response.offset).toStrictEqual(0); }); + it('Transfers ParentSubaccountNumber Pagination', async () => { + const response = await client.account.getParentSubaccountNumberTransfers( + DYDX_TEST_ADDRESS, + 0, + 1, + undefined, + undefined, + 1, + ); + expect(response).not.toBeNull(); + const transfers = response.transfers; + + expect(transfers).not.toBeNull(); + if (transfers.length > 0) { + const transfer = transfers[0]; + expect(transfer).not.toBeNull(); + + expect(response.totalResults).toBeGreaterThanOrEqual(1); + } + + expect(response.pageSize).toStrictEqual(1); + expect(response.offset).toStrictEqual(0); + }); + it('Orders', async () => { const response = await client.account.getSubaccountOrders(DYDX_TEST_ADDRESS, 0); expect(response).not.toBeNull(); @@ -102,6 +137,17 @@ describe('IndexerClient', () => { } }); + it('Fills ParentSubaccountNumber', async () => { + const response = await client.account.getParentSubaccountNumberFills(DYDX_TEST_ADDRESS, 0); + expect(response).not.toBeNull(); + const fills = response.fills; + expect(fills).not.toBeNull(); + if (fills.length > 0) { + const fill = fills[0]; + expect(fill).not.toBeNull(); + } + }); + it('Fills Pagination', async () => { const response = await client.account.getSubaccountFills( DYDX_TEST_ADDRESS, @@ -127,6 +173,31 @@ describe('IndexerClient', () => { expect(response.offset).toStrictEqual(0); }); + it('Fills ParentSubaccountNumber Pagination', async () => { + const response = await client.account.getParentSubaccountNumberFills( + DYDX_TEST_ADDRESS, + 0, + undefined, + undefined, + 1, + undefined, + undefined, + 1, + ); + + expect(response).not.toBeNull(); + const fills = response.fills; + expect(fills).not.toBeNull(); + if (fills.length > 0) { + const fill = fills[0]; + expect(fill).not.toBeNull(); + expect(response.totalResults).toBeGreaterThanOrEqual(1); + } + + expect(response.pageSize).toStrictEqual(1); + expect(response.offset).toStrictEqual(0); + }); + it('Historical PNL', async () => { const response = await client.account.getSubaccountHistoricalPNLs(DYDX_TEST_ADDRESS, 0); expect(response).not.toBeNull(); diff --git a/v4-client-js/src/clients/modules/account.ts b/v4-client-js/src/clients/modules/account.ts index c4379ba2..4797f2a1 100644 --- a/v4-client-js/src/clients/modules/account.ts +++ b/v4-client-js/src/clients/modules/account.ts @@ -73,6 +73,25 @@ export default class AccountClient extends RestClient { }); } + async getParentSubaccountNumberTransfers( + address: string, + parentSubaccountNumber: number, + limit?: number | null, + createdBeforeOrAtHeight?: number | null, + createdBeforeOrAt?: string | null, + page?: number | null, + ): Promise { + const uri = '/v4/transfers/parentSubaccountNumber'; + return this.get(uri, { + address, + parentSubaccountNumber, + limit, + createdBeforeOrAtHeight, + createdBeforeOrAt, + page, + }); + } + async getSubaccountOrders( address: string, subaccountNumber: number, @@ -130,6 +149,29 @@ export default class AccountClient extends RestClient { }); } + async getParentSubaccountNumberFills( + address: string, + parentSubaccountNumber: number, + ticker?: string | null, + tickerType: TickerType = TickerType.PERPETUAL, + limit?: number | null, + createdBeforeOrAtHeight?: number | null, + createdBeforeOrAt?: string | null, + page?: number | null, + ): Promise { + const uri = '/v4/fills/parentSubaccountNumber'; + return this.get(uri, { + address, + parentSubaccountNumber, + ticker, + tickerType, + limit, + createdBeforeOrAtHeight, + createdBeforeOrAt, + page, + }); + } + async getSubaccountHistoricalPNLs( address: string, subaccountNumber: number,