Some ERC20 tokens(e.g. STA,PAXG) charge a fee any time transfer() or transferFrom() is called and there are some that might in the future (USDC,USDT).
This will cause a difference between the value stored in rewards[abi.encodePacked(_position.holder, asset.token.symbol)] and the actual amount of the token in the contract.
Example:
portion is 100, but 0.2% are paid for fee and the actual amount sent to the LiquidationPool contract is 98 (https://github.com/Cyfrin/2023-12-the-standard/blob/main/contracts/LiquidationPool.sol#L232) but portion is still cached as 100 in rewards. (https://github.com/Cyfrin/2023-12-the-standard/blob/main/contracts/LiquidationPool.sol#L227)
When the user tries to claim his rewards by calling claimRewards() _rewardAmount is going to be 100 (https://github.com/Cyfrin/2023-12-the-standard/blob/main/contracts/LiquidationPool.sol#L168), it will pass the if condition if is bigger than 0,
but it will revert in the transfer logic as the actual amount is 98 (https://github.com/Cyfrin/2023-12-the-standard/blob/main/contracts/LiquidationPool.sol#L175)
The rewardAmount is set at 227L in LiqudationPool.distributeAssets(), then a portion of the token is sent at 232L but it's not taken in account the 0.2% transfer fee
Then when a user tries to claim his rewards by calling LiqudationPool.claimRewards() there will be a difference between the value stored in rewards[abi.encodePacked(_position.holder, asset.token.symbol)] and the actual amount of the token in the contract
As it might happen only on weird tokens which charges a fee-on-transfer I consider it as a Medium.
Manual review
Pre-calculating the fee, so the _rewardAmount has the correct value
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.