collateralUserCap is not properly checked when depositing
Summary
line 96 when checking collateralUserCap against the user balance it exclude the newly deposit amount
Vulnerability Detail
in AssetsProcess function deposit line 96 when checking the user deposited amount against the collateralUserCap it only check against the previous user deposit amount and it will not check the new one so since it exclude the newly deposit amount the user can bypass the collateralUserCap by depositing two times with collateralUserCap amount
jah
High
collateralUserCap is not properly checked when depositing
Summary
line 96 when checking collateralUserCap against the user balance it exclude the newly deposit amount
Vulnerability Detail
in AssetsProcess function deposit line 96 when checking the user deposited amount against the collateralUserCap it only check against the previous user deposit amount and it will not check the new one so since it exclude the newly deposit amount the user can bypass the collateralUserCap by depositing two times with collateralUserCap amount
Impact
breaks the contract policy
Code Snippet
https://github.com/sherlock-audit/2024-05-elfi-protocol/blob/main/elfi-perp-contracts/contracts/process/AssetsProcess.sol#L96
Tool used
Manual Review
Recommendation
update the account before checking
Duplicate of #262