Platform: Code4rena
Start Date: 20/01/2022
Pot Size: $50,000 USDC
Total HM: 3
Participants: 35
Period: 7 days
Judge: GalloDaSballo
Total Solo HM: 2
Id: 77
League: ETH
Rank: 14/35
Findings: 1
Award: $202.80
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: harleythedog
cmichel
The Exchange.addLiquidity
function has code to catch and reject fee-on-transfer tokens:
if (tokenQtys.baseTokenQty != 0) { bool isExchangeEmpty = IERC20(baseToken).balanceOf(address(this)) == 0; // transfer base tokens to Exchange IERC20(baseToken).safeTransferFrom( msg.sender, address(this), tokenQtys.baseTokenQty ); if (isExchangeEmpty) { // @audit only executed once at the beginning require( IERC20(baseToken).balanceOf(address(this)) == tokenQtys.baseTokenQty, "Exchange: FEE_ON_TRANSFER_NOT_SUPPORTED" ); } }
However, the check is only executed at the initial liquidity provision, when the exchange has zero tokens (isExchangeEmpty
).
This does not reliably catch fee-on-transfer tokens because:
1
where the transfer fees would usually be zero.The provided protection does not work correctly and can easily be bypassed.
Consider using the actual received amount as the baseTokenQty
by comparing post- and pre-transfer balances.
#0 - 0xean
2022-01-31T14:41:07Z
dupe of #119