Skip to content

Commit

Permalink
chore: clean up commenting and unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
nickewansmith committed Nov 14, 2024
1 parent 40fed3d commit 7f12c6c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
12 changes: 7 additions & 5 deletions app/components/UI/Stake/hooks/usePoolStakedUnstake/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 7f12c6c

Please sign in to comment.