Users are unable to obtain the remaining unclaimed collateral when totalCollateral less than unclaimedTotal
Summary
Users are unable to obtain the remaining unclaimed collateral when totalCollateral less than unclaimedTotal
Vulnerability Detail
Users are unable to obtain the remaining unclaimed collateral when totalCollateral less than unclaimedTotal. This problem arises due to a fail logic within the claim() function. It fails to handle situations where the available collateral is insufficient to cover the entire unclaimed amount. As a result, users receive a reduced collateral payout, and their unclaimed balance is not properly accounted for or carried forward.
Due to the existance of this following line before knowing that user will only get partial claim for their collateral, user will zeroed-out to claim the rest of their collateral.
_unclaimed[account] = UFixed18Lib.ZERO;
The claim() function should ensure that users receive the correct proportion of collateral based on their unclaimed balance, even if the total collateral is lower than the total unclaimed amount. Additionally, any remaining unclaimed collateral should be properly stored and made accessible to users for future claims.
Modify claim to allow users to claim their assets in partial amounts, or in full but ensure that the remaining unclaimed assets are still accessible for them to claim
bitsurfer
medium
Users are unable to obtain the remaining unclaimed collateral when
totalCollateral
less thanunclaimedTotal
Summary
Users are unable to obtain the remaining unclaimed collateral when
totalCollateral
less thanunclaimedTotal
Vulnerability Detail
Users are unable to obtain the remaining unclaimed collateral when
totalCollateral
less thanunclaimedTotal
. This problem arises due to a fail logic within theclaim()
function. It fails to handle situations where the available collateral is insufficient to cover the entire unclaimed amount. As a result, users receive a reduced collateral payout, and their unclaimed balance is not properly accounted for or carried forward.Due to the existance of this following line before knowing that user will only get partial claim for their collateral, user will zeroed-out to claim the rest of their collateral.
The
claim()
function should ensure that users receive the correct proportion of collateral based on their unclaimed balance, even if the total collateral is lower than the total unclaimed amount. Additionally, any remaining unclaimed collateral should be properly stored and made accessible to users for future claims.Impact
Users are unable to obtain the remaining unclaimed collateral
Code Snippet
https://github.com/sherlock-audit/2023-05-perennial/blob/main/perennial-mono/packages/perennial-vaults/contracts/balanced/BalancedVault.sol#L211-L228
Tool used
Manual Review
Recommendation
Modify claim to allow users to claim their assets in partial amounts, or in full but ensure that the remaining unclaimed assets are still accessible for them to claim