The TokenManager contract employs strict balance checks in the _transfer function, which can cause valid transfers to revert when dealing with certain ERC20 tokens. These tokens may include fee-on-transfer tokens, rebasing tokens, or any other tokens that do not follow the standard balance update behavior.
The _transfer function in the TokenManager contract contains strict balance checks to ensure that the transferred amounts match exactly with the expected before and after balances.
These conditions rely on exact arithmetic to verify the transfer amounts. While this approach works for most ERC20 tokens, it can fail for ERC20 tokens with special accounting rules, such as:
Fee-on-Transfer Tokens: These tokens deduct a fee from the transferred amount. For example, if a 1% fee is deducted on a transfer of 100 tokens, the recipient receives 99 tokens. Consequently, the balance check fails as the toBalanceAft will not match toBalanceBef + _amount.
Rebasing Tokens: These tokens periodically adjust balances, leading to dynamic balance updates that may not align with the simple difference expected in the balance checks.
The strict balance checks will cause valid transfers to revert for some ERC20 tokens, leading to:
User Frustration: Users attempting to transfer fee-on-transfer tokens or rebasing tokens through the TokenManager contract will face failed transactions.
Inaccessible Funds: The inability to transfer tokens correctly might lock user funds within the contract or prevent them from using certain tokens within the broader application context.
Operational Failures: If the application relies on these token transfers for functionality, it might lead to broader operational issues and disruptions.
Foundry
Adjust the balance checks to accommodate potential discrepancies caused by all ERC20 token behaviors.
Implement a flag or mechanism to detect fee-on-transfer tokens and handle them appropriately.
Valid medium, there are disruptions to the ability to take market actions. The following functions will be disrupted without the possibiliy of reaching settlement, since the respective offers cannot be created/listed regardless of mode when transferring collateral token required to the CapitalPool contract or when refunding token from user to capital pool during relisting. So withdrawal is not an issue - `createOffer()` - reverts [here](https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/PreMarkets.sol#L96-L102) - `listOffer()` - reverts [here](https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/PreMarkets.sol#L355-L362) - `relistOffer()` - reverts [here](https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/PreMarkets.sol#L515-L521) - `createTaker()` - reverts [here](https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/PreMarkets.sol#L831-L836) I believe medium severity is appropriate although the likelihood is high and impact is medium (only some level of disruption i.e. FOT tokens not supported and no funds at risk)
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.