diff --git a/app/components/UI/Stake/hooks/usePoolStakedUnstake/index.ts b/app/components/UI/Stake/hooks/usePoolStakedUnstake/index.ts index cf9f3e733dc..641a2fd9c49 100644 --- a/app/components/UI/Stake/hooks/usePoolStakedUnstake/index.ts +++ b/app/components/UI/Stake/hooks/usePoolStakedUnstake/index.ts @@ -29,11 +29,13 @@ const attemptUnstakeTransaction = // Note: receiver is the user address attempting to unstake. async (valueWei: string, receiver: string) => { try { - // STAKE-867: This is a temporary check for if we intend to unstake all and if so send the - // total user shares this is done here as a quick fix for mobile but will be refactored in - //the future this is done to avoid the case where contract level rounding error causes 1 wei - // of dust to be left over when converting valueWei to shares and unstaking. Here we ensure - // that all the user's shares are unstaked when unstaking all. + // STAKE-867: This is temporary logic for the unstake all action + // if we are unstaking the total assets we send the total shares + // the user has in the vault through getShares contract method + // this is a quick fix for mobile only and will be refactored to cover + // portfolio in the future. We avoid the case where contract level rounding + // error causes 1 wei dust to be left when converting assets to shares + // and attempting to unstake all assets let shares; if (valueWei === stakedBalanceWei) { // create the interface for the getShares method and call getShares to get user shares diff --git a/app/components/UI/Stake/hooks/usePoolStakedUnstake/usePoolStakedUnstake.test.tsx b/app/components/UI/Stake/hooks/usePoolStakedUnstake/usePoolStakedUnstake.test.tsx index eced52d3b1b..780791f1d0c 100644 --- a/app/components/UI/Stake/hooks/usePoolStakedUnstake/usePoolStakedUnstake.test.tsx +++ b/app/components/UI/Stake/hooks/usePoolStakedUnstake/usePoolStakedUnstake.test.tsx @@ -88,7 +88,7 @@ const mockPooledStakingContractService: PooledStakingContract = { contract: { ...new Contract('0x0000000000000000000000000000000000000000', []), provider: { - call: jest.fn().mockResolvedValue('0x00000sommeresponse'), + call: jest.fn(), }, } as unknown as Contract, convertToShares: mockConvertToShares, @@ -149,14 +149,13 @@ describe('usePoolStakedUnstake', () => { it('attempts to create and submit an unstake all transaction', async () => { jest.spyOn(ethers.utils, 'Interface').mockImplementation(() => ({ - encodeFunctionData: jest.fn().mockReturnValue('0x0000000000000000000000000000000000000000000000000000000000000000'), + encodeFunctionData: jest.fn(), decodeFunctionResult: jest.fn().mockReturnValue([BigNumber.from(MOCK_UNSTAKE_ALL_VALUE_WEI)]), } as unknown as ethers.utils.Interface)); const { result } = renderHookWithProvider(() => usePoolStakedUnstake(), { state: mockInitialState, }); - mockPooledStakingContractService.contract.provider.call = jest.fn(); await result.current.attemptUnstakeTransaction( MOCK_UNSTAKE_ALL_VALUE_WEI,