The _mint() function in the PerpetualVault contract manually calculates shares when users deposit assets. However, it does not follow the ERC-4626 standard, leading to inaccurate share allocations, potential rounding errors, and reduced composability with DeFi protocols. Implementing ERC-4626 would ensure standardized and accurate share issuance.
The _mint() function is responsible for issuing shares to users when they deposit assets into the vault:
_mint()Manual Share Calculation Instead of ERC-4626’s Built-in Functions
The function manually computes:
This introduces potential rounding errors and inaccuracies.
ERC-4626 provides convertToShares(amount), which should be used instead.
Arbitrary Fallback to totalAmountBefore = 1
If totalAmountBefore == 0, the function sets it to 1, leading to incorrect share minting:
This artificially inflates the share count, which can over-reward early depositors.
No Standardized Minting Process
ERC-4626 includes deposit(), mint(), and redeem() functions, ensuring accurate asset-to-share conversion and withdrawal calculations.
Without it, the vault cannot integrate with DeFi protocols expecting ERC-4626 compliance.
Inaccurate Share Allocations – Users may receive incorrect shares, leading to potential over- or under-minting.
Withdrawal Issues – Incorrect share calculations may cause unexpected behavior when redeeming assets, leading to incorrect payouts.
DeFi Incompatibility – The vault cannot integrate with yield aggregators, lending platforms, or protocols that expect ERC-4626 compliance, limiting its adoption.
Manuel Review
OpenZeppelin ERC-4626 standard documentation
Inherit ERC-4626 to standardize minting and withdrawals:
Replace manual _mint() logic with ERC-4626 functions:
Use convertToAssets() for withdrawals:
By implementing ERC-4626, the vault will eliminate unnecessary complexity, improve accuracy, and increase composability across DeFi protocols.
No proof when this can happen: Most of the time totalAmountBefore equals 0 (balance minus amount sent), it means totalShares equals 0. If it could happen with very specific conditions, report with that tag didn't add the needed details to be validated.
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.