diff --git a/README.md b/README.md index b49973e2..90d41c80 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ The official SDK designed for effortless data retrieval from the StakeWise platform. This SDK provides a streamlined interface over GraphQL requests and contract interactions. -![Version](https://img.shields.io/badge/version-1.2.8-blue) +![Version](https://img.shields.io/badge/version-1.2.9-blue) ![Unit Tests](https://github.com/stakewise/v3-sdk/actions/workflows/unit-tests.yml/badge.svg) ![GitHub issues](https://img.shields.io/github/issues-raw/stakewise/v3-sdk) ![GitHub pull requests](https://img.shields.io/github/issues-pr-raw/stakewise/v3-sdk) diff --git a/src/graphql/subgraph/exitQueue/exitQueueQuery.graphql b/src/graphql/subgraph/exitQueue/exitQueueQuery.graphql index 684ea2ca..e330eeb7 100644 --- a/src/graphql/subgraph/exitQueue/exitQueueQuery.graphql +++ b/src/graphql/subgraph/exitQueue/exitQueueQuery.graphql @@ -5,5 +5,6 @@ query exitQueue($receiver: Bytes, $vault: String!) { }) { positionTicket totalShares + timestamp } } diff --git a/src/methods/vault/requests/getExitQueuePositions/parseExitRequests.spec.ts b/src/methods/vault/requests/getExitQueuePositions/parseExitRequests.spec.ts index 899d7a1a..50e75988 100644 --- a/src/methods/vault/requests/getExitQueuePositions/parseExitRequests.spec.ts +++ b/src/methods/vault/requests/getExitQueuePositions/parseExitRequests.spec.ts @@ -24,10 +24,12 @@ describe('parseExitRequests function', () => { exitRequests: [ { positionTicket: 'positionTicket-1', + timestamp: '123456', totalShares: '100', }, { positionTicket: 'positionTicket-2', + timestamp: '123456', totalShares: '200', }, ], @@ -65,8 +67,16 @@ describe('parseExitRequests function', () => { expect(result).toEqual({ positions: [ - { exitQueueIndex: 1n, positionTicket: 'positionTicket-1' }, - { exitQueueIndex: 2n, positionTicket: 'positionTicket-2' }, + { + exitQueueIndex: 1n, + timestamp: '123456', + positionTicket: 'positionTicket-1', + }, + { + exitQueueIndex: 2n, + timestamp: '123456', + positionTicket: 'positionTicket-2', + }, ], total: 100n, withdrawable: 31n, @@ -108,7 +118,11 @@ describe('parseExitRequests function', () => { const result = await parseExitRequests(input) expect(result).toEqual({ - positions: [ { exitQueueIndex: 1n, positionTicket: 'positionTicket-2' } ], + positions: [ { + exitQueueIndex: 1n, + timestamp: '123456', + positionTicket: 'positionTicket-2', + } ], total: 50n, withdrawable: 30n, }) @@ -130,8 +144,16 @@ describe('parseExitRequests function', () => { expect(result).toEqual({ positions: [ - { exitQueueIndex: 0n, positionTicket: 'positionTicket-1' }, - { exitQueueIndex: 1n, positionTicket: 'positionTicket-2' }, + { + exitQueueIndex: 0n, + timestamp: '123456', + positionTicket: 'positionTicket-1', + }, + { + exitQueueIndex: 1n, + timestamp: '123456', + positionTicket: 'positionTicket-2', + }, ], total: 0n, withdrawable: 0n, @@ -153,8 +175,16 @@ describe('parseExitRequests function', () => { expect(result).toEqual({ positions: [ - { exitQueueIndex: 0n, positionTicket: 'positionTicket-1' }, - { exitQueueIndex: 1n, positionTicket: 'positionTicket-2' }, + { + exitQueueIndex: 0n, + timestamp: '123456', + positionTicket: 'positionTicket-1', + }, + { + exitQueueIndex: 1n, + timestamp: '123456', + positionTicket: 'positionTicket-2', + }, ], total: 0n, withdrawable: 30n, diff --git a/src/methods/vault/requests/getExitQueuePositions/parseExitRequests.ts b/src/methods/vault/requests/getExitQueuePositions/parseExitRequests.ts index b8fae38a..4c65a1bc 100644 --- a/src/methods/vault/requests/getExitQueuePositions/parseExitRequests.ts +++ b/src/methods/vault/requests/getExitQueuePositions/parseExitRequests.ts @@ -10,12 +10,14 @@ export type ParseExitRequestsInput = { exitRequests: Array<{ positionTicket: string totalShares: string + timestamp: string }> } type Position = { exitQueueIndex: bigint positionTicket: string + timestamp: string } type ParseExitRequestsOutput = { @@ -58,13 +60,15 @@ const parseExitRequests = async (values: ParseExitRequestsInput): Promise { - const exitQueueIndex = result[0] + const claims = (indexesResponse || []).reduce((acc, item, index) => { + const exitQueueIndex = item[0] + + const timestamp = exitRequests[index].timestamp const positionTicket = exitRequests[index].positionTicket // If the index is -1 then we cannot claim anything. Otherwise, the value is >= 0. if (exitQueueIndex > -1n) { - const item = { exitQueueIndex, positionTicket } + const item = { exitQueueIndex, positionTicket, timestamp } return [ ...acc, item ] } @@ -79,9 +83,9 @@ const parseExitRequests = async (values: ParseExitRequestsInput): Promise({ ...commonMulticallParams, request: { - params: claims.map(({ positionTicket, exitQueueIndex }) => ({ + params: claims.map(({ positionTicket, exitQueueIndex, timestamp }) => ({ method: 'claimExitedAssets', - args: [ positionTicket, exitQueueIndex ], + args: [ positionTicket, exitQueueIndex, timestamp ], })), callStatic: true, },