The _removeLiquidity function contains flawed logic when handling maximum withdrawal requests (type(uint256).max), potentially allowing imbalanced position token transfers and creating liquidation risks.
Affected Code:
Core Issues:
Imbalanced Withdrawal Enforcement
When using max withdrawal, the function takes the smaller of short/long balances instead of requiring equal amounts
Allows partial withdrawal even when position tokens are imbalanced
Creates potential for leftover "stranded" position tokens
Incorrect Assumption About Balances
Fails to account for possible manual transfers of position tokens
Users could intentionally create imbalanced positions to manipulate pool liquidity
Enables partial liquidity removal without full position token sets
May lead to accounting inconsistencies in Aave collateral backing
Creates attack surface for liquidity manipulation
Violates DIVA Protocol's position token parity requirement
Manual code analysis
DIVA Protocol documentation review
ERC-20 token standard reference
Enforce Position Token Parity
Add Explicit Balance Checks
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.