Using a malicious/strange ERC20 token in the Escrow contract could effectively cause problems.
A token that accidentally reverts in transfer or transferFrom could prevent funds from being transferred correctly.
A token with arbitrary logic in transferFrom could lead to unexpected state changes.
A token that mints new tokens in transfer could manipulate balances.
function test_change() public {
vm.startPrank(BUYER);
ERC20Mock(address(i_tokenContract)).mint(BUYER, PRICE);
ERC20Mock(address(i_tokenContract)).approve(address(escrowFactory), PRICE);
escrow = escrowFactory.newEscrow(PRICE, i_tokenContract, SELLER, ARBITER, ARBITER_FEE, SALT1)
escrow.getTokenContract();
vm.stopPrank();
vm.startPrank(alice);
ERC20Mock(address(Ohack_usd)).mint(alice, PRICE);
ERC20Mock(address(Ohack_usd)).approve(address(escrowFactory), PRICE);
uint256 balanceHackusdBefore= ERC20Mock(address(Ohack_usd)).balanceOf(0x667e2b4406371e78029953Fa820Be795C7AFdeb7);
console.log("balanceHackusdBefore",balanceHackusdBefore);
assertEq(0,balanceHackusdBefore);
escrow = escrowFactory.newEscrow(PRICE, Ohack_usd, SELLER, ARBITER, ARBITER_FEE, SALT1)
escrow.getTokenContract();
ERC20Mock(address(i_tokenContract)).totalSupply();
ERC20Mock(address(Ohack_usd)).totalSupply();
ERC20Mock(address(i_tokenContract)).balanceOf(0xBDbbA0C45E0AEd4aA03A4Ff629C8EE750cBf3437);
uint256 balanceHackusd= ERC20Mock(address(Ohack_usd)).balanceOf(0x8b5D2A146eED65EF59A3BD909c91A500afcb6283);
console.log("balanceHackusdBefore",balanceHackusd);
assertEq(PRICE,balanceHackusd);
vm.stopPrank();
}
Maintaining a whitelist of permitted tokens in EscrowFactory.
Validating that the token adheres to the ERC20 standard correctly.
Introducing emergency pauses in case a malicious token is detected.
Limiting access to critical functions like transfer/transferFrom.