When users attempt to remove liquidity with _positionTokenAmount = type(uint256).max
, the contract calculates the redeemable amount as the minimum of their short and long token balances. If balances are mismatched (e.g., one is zero), this results in a zero-amount redemption, causing wasted gas or DIVA Protocol reverts.
In the above call, if the user passes type(uint256).max and if _userBalanceShort is 0 and _userBalanceLong is greater than 0, _userBalanceShort (zero) will be returned and the function will revert as it is stated in the comments shortly afterwards:
In the same scenario, if the reverse is the case and _userBalanceLong is 0 and _userBalanceShort greater than 0, _positionTokenAmountToRemove will be given the value of _userBalanceLong andthus 0, the function will not work.
Users may unintentionally trigger failed transactions or pay gas for no benefit.
Manual review
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.