Fee-on-Transfer tokens cause problems in multiple places
The protocol's transfer functions require the contract to receive the exact intended amount, which fails for fee-on-transfer tokens because the fee reduces the received amount. This causes any function using these transfers to revert, blocking deposits, withdrawals, and bids for such tokens.
Submitted by Ch_301
The protocol is designed to ensure it is compatible with fee-on-transfer tokens (Fee-on-transfer is in scope). For example, the erc20TransferInLiquidity() function checks the balance before and after, and calculates the difference between these values to measure the tokens received
File: VaultLogic.sol
448: function erc20TransferInBidAmount(DataTypes.AssetData storage assetData, address from, uint256 amount) internal {
449: address asset = assetData.underlyingAsset;
450: uint256 poolSizeBefore = IERC20Upgradeable(asset).balanceOf(address(this));
451:
452: assetData.totalBidAmout += amount;
453:
454: IERC20Upgradeable(asset).safeTransferFrom(from, address(this), amount);
455:
456: uint256 poolSizeAfter = IERC20Upgradeable(asset).balanceOf(address(this));
457: require(poolSizeAfter == (poolSizeBefore + amount), Errors.INVALID_TRANSFER_AMOUNT);
458: }
But at the end of the logic, it has a required check if the contract received the exact intended amount these two features are not compatible If the asset is Fee-on-transfer tokens the requirement will keep revert
Example:
- Contract
balanceOfis 2000 of Fee-on-transfer tokens. - Contract transfer from user
amount == 1000. - Fee is collected, so the contract received only 950 tokens, but the require will check
2000 + 1000 == 2950and revert.
Impact
Any function/feature that calls:
erc20TransferInLiquidity()erc20TransferOutLiquidity()erc20TransferBetweenWallets()erc20TransferOutBidAmount()erc20TransferInBidAmount()
in VaultLogic.sol will revert if the asset is Fee-on-transfer tokens.
Recommended Mitigation Steps
When fee-on-transfer tokens should be supported, you need to check the actual balance differences but don’t expect to receive the exact amount. If they are not supported, this should be documented.
Assessed type
ERC20
thorseldon (BendDAO) disputed and commented:
We suggest adjust the severity level to Informative.
For now we don’t support the token fee-on-transfer. Maybe it’s will be optimised in future if we really need to support those tokens.
I fully understand your point. However, the audit
READMEstates thatFee on transfer ERC20sare in scope. The auditREADMEis part of the source of truth for wardens during this audit and I have to judge according to that. Therefore, I cannot legitimately downgrade this finding even if it’s not of relevance.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The code requires the received balance to increase by exactly the transfer amount, which is incompatible with fee-on-transfer tokens that deduct a fee.
Impact
Any function that calls the affected transfer functions will revert if the asset is a fee-on-transfer token, preventing its use in the protocol.
What the attacker needed
The asset is a fee-on-transfer token
The fix
The code should check the actual balance difference rather than expecting the exact amount, or document that fee-on-transfer tokens are not supported.
How it was found
- Contract holds 2000 fee-on-transfer tokens.
- User transfers 1000 tokens to the contract.
- A fee is deducted, so the contract receives only 950 tokens.
- The require checks 2000 + 1000 == 2950, which fails, causing a revert.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Some tokens take a small fee when transferred, so the receiver gets less than the sender sent. The code here checks that the exact amount arrived, so it always fails for these tokens. That means users cannot use those tokens with the protocol.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.