Tokens implementing a fee-on-transfer mechanism, which deduct a fee from the recipient on each transfer, are incompatible with the current implementation of the TokenManager::_transfer function. This incompatibility arises because the _transfer function includes a check to verify whether the recipient's balance has been correctly incremented by the transferred amount. Since fee-on-transfer tokens adjust the recipient's balance after deducting the fee, this check fails, preventing users from depositing or withdrawing these types of tokens.
The problematic check within the _transfer function ensures that the recipient's balance (toBalanceAft) equals the initial balance plus the transferred amount (toBalanceBef + _amount). However, for tokens with a fee-on-transfer feature, the actual balance increase is less due to the fee deduction, causing the check to revert.
The inability to handle fee-on-transfer tokens limits the protocol's compatibility with a broader range of ERC20-compliant tokens, potentially excluding users who wish to interact with these tokens within the protocol.
To demonstrate this issue, consider integrating a fee-on-transfer token into the testing environment and attempting to perform operations with it:
Install the library of wierd tokens and import it in test file:
Run the following test in exsiting test suit:
Manual Review
To resolve this issue, consider removing the balance check entirely or modifying it to account for the fee deducted during the transfer. Alternatively, introduce a parameter to specify the fee rate for tokens with a fee-on-transfer mechanism, allowing the protocol to accurately calculate the expected recipient balance post-transfer.
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.