The maxDeposit function in ZlpVault.sol contains a critical decimal mismatch when comparing depositCap (18 decimals) with totalAssets() (asset decimals). This leads to incorrect calculation of the maximum deposit amount, potentially causing various issues with deposits depending on the scenario.
This is the maxDeposit implementation:
The totalAssets() function, inherited from ERC4626, returns the total amount of underlying assets in the vault using the asset's native decimals (e.g., 6 for USDC).
However, depositCap is maintained in 18 decimals. This has been confirmed by the sponsors in the discord:
This presents an issue when vault's asset decimals != 18.
Example Scenario (USDC - 6 decimals):
Deposit Cap: 1,000,000 USDC
In 18 decimals: 1,000,000 * 10^18 = 1e24
Current total assets: 900,000 USDC
In 6 decimals: 900,000 * 10^6 = 9e11
In maxDeposit:
The function returns a massive number (~1e24) as the maximum deposit amount, which is incorrect as it should be 100,000 USDC (1e11 in 6 decimals).
Function returns incorrect maximum deposit amounts that are much larger than intended making it impossible for the contract to properly enforce deposit caps
Manual Review
Normalize the decimals before comparison in maxDeposit
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.