Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vizay9652 - strict equality check in LidoVault::deposit function prevents vault from starting. #158

Open
sherlock-admin4 opened this issue Sep 21, 2024 · 0 comments

Comments

@sherlock-admin4
Copy link

sherlock-admin4 commented Sep 21, 2024

vizay9652

Medium

strict equality check in LidoVault::deposit function prevents vault from starting.

Summary

The LidoVault::deposit function has a condition where strict equality check, which prevents the vault from starting.

Vulnerability Detail

In LidoVault.sol:382 and LidoVault.sol:383 lines uses strict equality checks

  1. let us assume fixedSideCapacity is 1000 ether.
  2. users started depositing their ETH in this contract.
  3. If fixedETHDepositTokenTotalSupply becomes 999.999 eth
  4. Now user has to deposit 0.001 eth in order to satisfy these conditions fixedETHDepositTokenTotalSupply == fixedSideCapacity && variableBearerTokenTotalSupply == variableSideCapacity.
  5. But he can't deposit 0.001 eth because minimumDepositAmount is 0.01 eth.
  6. So, the strict equality conditions fails and prevents the vault from starting.

Code Snippet

https://github.com/sherlock-audit/2024-08-saffron-finance/blob/main/lido-fiv/contracts/LidoVault.sol#L382-L383

 if (
@>      fixedETHDepositTokenTotalSupply == fixedSideCapacity && variableBearerTokenTotalSupply == variableSideCapacity
    ) {
      startTime = block.timestamp;
      endTime = block.timestamp + duration;
      fixedSidestETHOnStartCapacity = stakingBalance();
      fixedIntialTokenTotalSupply = fixedClaimTokenTotalSupply;
      emit VaultStarted(block.timestamp, msg.sender);
    }

Tool used

Manual Review

Recommendation

use tolerance

+  uint256 tolerance = 0.01 ether;
    if (
-     fixedETHDepositTokenTotalSupply == fixedSideCapacity && variableBearerTokenTotalSupply == variableSideCapacity
+    (fixedETHDepositTokenTotalSupply >= fixedSideCapacity - tolerance && fixedETHDepositTokenTotalSupply <= fixedSideCapacity) && (variableBearerTokenTotalSupply >= variableSideCapacity - tolerance && variableBearerTokenTotalSupply <= variableSideCapacity)
    ) 
@sherlock-admin4 sherlock-admin4 changed the title Swift Rouge Grasshopper - strict equality check in LidoVault::deposit function prevents vault from starting. vizay9652 - strict equality check in LidoVault::deposit function prevents vault from starting. Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant