Summary
MockERC20 in CharonLiquidator.t.sol implements balanceOf, mint, transfer, approve, and allowance, but not transferFrom. The current test usage is limited to rescue tests where only transfer is needed.
However, any future mocked unit test for executeOperation will require transferFrom because:
- PancakeSwap's
exactInputSingle pulls tokens from the caller via transferFrom
- Some ERC-20 implementations of
liquidateBorrow on the debt side use transferFrom
Without transferFrom, any attempt to wire MockERC20 into an executeOperation unit test will silently fail (fallback to no-op or revert) and mask the real behavior.
Location
contracts/test/CharonLiquidator.t.sol — MockERC20 contract definition
Fix
Add transferFrom to MockERC20:
function transferFrom(address from, address to, uint256 amount) external returns (bool) {
require(balanceOf[from] >= amount, "insufficient");
balanceOf[from] -= amount;
balanceOf[to] += amount;
return true;
}
Refs #38
Summary
MockERC20inCharonLiquidator.t.solimplementsbalanceOf,mint,transfer,approve, andallowance, but nottransferFrom. The current test usage is limited to rescue tests where onlytransferis needed.However, any future mocked unit test for
executeOperationwill requiretransferFrombecause:exactInputSinglepulls tokens from the caller viatransferFromliquidateBorrowon the debt side usetransferFromWithout
transferFrom, any attempt to wireMockERC20into an executeOperation unit test will silently fail (fallback to no-op or revert) and mask the real behavior.Location
contracts/test/CharonLiquidator.t.sol—MockERC20contract definitionFix
Add
transferFromtoMockERC20:Refs #38