diff --git a/README.md b/README.md index 90d41c80..ce2e5c97 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.9-blue) +![Version](https://img.shields.io/badge/version-1.3.0-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) @@ -245,18 +245,19 @@ Returns the withdrawal queue for a specific user. type Position = { exitQueueIndex: bigint positionTicket: string + timestamp: string } type Output = { total: bigint - data: Position[] withdrawable: bigint + positions: Position[] } ``` | Name | Description | |------|-------------| -| `data` | Queue positions | +| `positions` | Queue positions | | `total` | Total withdrawal amount (in ETH) | | `withdrawable` | Amount available for withdrawal (in ETH) | @@ -902,7 +903,7 @@ Take the freed tokens from the queue | Name | Type | Type | Description | |------|------|-------------|---------| -| positions | `string` | **Require** | `data` from [sdk.vault.getExitQueuePositions](#sdkvaultgetexitqueuepositions) | +| positions | `string` | **Require** | `postions` from [sdk.vault.getExitQueuePositions](#sdkvaultgetexitqueuepositions) | | userAddress | `string` | **Require** | - | | vaultAddress | `string` | **Require** | - | diff --git a/src/contracts/vaultMulticall.ts b/src/contracts/vaultMulticall.ts index 95bed8a9..94100c51 100644 --- a/src/contracts/vaultMulticall.ts +++ b/src/contracts/vaultMulticall.ts @@ -64,7 +64,7 @@ const vaultMulticall = async (values: VaultMulticallInput): P }) if (callStatic) { - let result = await contract.multicall.staticCall(calls) + let result = await contract.multicall.staticCall(calls, { from: userAddress }) if (canHarvest) { // Data from updateState not needed diff --git a/src/methods/vault/requests/getExitQueuePositions/parseExitRequests.spec.ts b/src/methods/vault/requests/getExitQueuePositions/parseExitRequests.spec.ts index 50e75988..e4837e81 100644 --- a/src/methods/vault/requests/getExitQueuePositions/parseExitRequests.spec.ts +++ b/src/methods/vault/requests/getExitQueuePositions/parseExitRequests.spec.ts @@ -69,11 +69,13 @@ describe('parseExitRequests function', () => { positions: [ { exitQueueIndex: 1n, + totalShares: '100', timestamp: '123456', positionTicket: 'positionTicket-1', }, { exitQueueIndex: 2n, + totalShares: '200', timestamp: '123456', positionTicket: 'positionTicket-2', }, @@ -120,6 +122,7 @@ describe('parseExitRequests function', () => { expect(result).toEqual({ positions: [ { exitQueueIndex: 1n, + totalShares: '200', timestamp: '123456', positionTicket: 'positionTicket-2', } ], @@ -146,11 +149,13 @@ describe('parseExitRequests function', () => { positions: [ { exitQueueIndex: 0n, + totalShares: '100', timestamp: '123456', positionTicket: 'positionTicket-1', }, { exitQueueIndex: 1n, + totalShares: '200', timestamp: '123456', positionTicket: 'positionTicket-2', }, @@ -177,11 +182,13 @@ describe('parseExitRequests function', () => { positions: [ { exitQueueIndex: 0n, + totalShares: '100', timestamp: '123456', positionTicket: 'positionTicket-1', }, { exitQueueIndex: 1n, + totalShares: '200', timestamp: '123456', positionTicket: 'positionTicket-2', }, diff --git a/src/methods/vault/requests/getExitQueuePositions/parseExitRequests.ts b/src/methods/vault/requests/getExitQueuePositions/parseExitRequests.ts index 4c65a1bc..0e5efd23 100644 --- a/src/methods/vault/requests/getExitQueuePositions/parseExitRequests.ts +++ b/src/methods/vault/requests/getExitQueuePositions/parseExitRequests.ts @@ -63,12 +63,9 @@ const parseExitRequests = async (values: ParseExitRequestsInput): Promise { 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, timestamp } + const item = { exitQueueIndex, ...exitRequests[index] } return [ ...acc, item ] } @@ -85,7 +82,7 @@ const parseExitRequests = async (values: ParseExitRequestsInput): Promise ({ method: 'claimExitedAssets', - args: [ positionTicket, exitQueueIndex, timestamp ], + args: [ positionTicket, timestamp, exitQueueIndex ], })), callStatic: true, }, diff --git a/src/methods/vault/requests/getMaxWithdraw.ts b/src/methods/vault/requests/getMaxWithdraw.ts index 13b3f9d6..161832ea 100644 --- a/src/methods/vault/requests/getMaxWithdraw.ts +++ b/src/methods/vault/requests/getMaxWithdraw.ts @@ -10,10 +10,12 @@ type GetMaxWithdrawInput = { contracts: StakeWise.Contracts } +const min = parseEther('0.00001') + const getMaxWithdraw = async (values: GetMaxWithdrawInput) => { const { contracts, mintedAssets, stakedAssets, ltvPercent } = values - if (ltvPercent <= 0) { + if (ltvPercent <= 0 || stakedAssets < min) { return 0n } diff --git a/src/methods/vault/transactions/claimExitQueue/common.ts b/src/methods/vault/transactions/claimExitQueue/common.ts index 6bc9d5f3..a1f69a5a 100644 --- a/src/methods/vault/transactions/claimExitQueue/common.ts +++ b/src/methods/vault/transactions/claimExitQueue/common.ts @@ -24,11 +24,11 @@ export const commonLogic = async (values: ClaimExitQueueInput) => { } const params: Parameters[0]['request']['params'] = positions.map((position) => { - const { positionTicket, exitQueueIndex } = position + const { positionTicket, exitQueueIndex, timestamp } = position return { method: 'claimExitedAssets', - args: [ positionTicket, exitQueueIndex ], + args: [ positionTicket, timestamp, exitQueueIndex ], } }) diff --git a/src/methods/vault/transactions/claimExitQueue/types.d.ts b/src/methods/vault/transactions/claimExitQueue/types.d.ts index 2143a8a8..f58c8959 100644 --- a/src/methods/vault/transactions/claimExitQueue/types.d.ts +++ b/src/methods/vault/transactions/claimExitQueue/types.d.ts @@ -8,7 +8,7 @@ export type ClaimExitQueueInput = { options: StakeWise.Options provider: StakeWise.Provider contracts: StakeWise.Contracts - positions: Awaited>['data'] + positions: Awaited>['positions'] } export interface ClaimExitQueue {