pragma solidity 0.8.10; interface IERC20 { function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address from, address to, uint256 amount) external returns (bool); function transfer(address to, uint256 amount) external returns (bool); function balanceOf(address account) external view returns (uint256); } /* * 1/ some scenario is broken * 2/ not secure * 3/ not gas efficient */ contract BrokenSwapper { IAugustus immutable augustus; constructor(IAugustus _augustus) { augustus = _augustus; } // swap ERC20 tokens and pure ETH function swapTokensWithParaSwap( IERC20 srcToken, IERC20 destToken, uint256 amount, bytes memory augustusCalldata // trusted data to pass down to augutus contract ) external { srcToken.transferFrom(msg.sender, address(this), amount); srcToken.approve(augustus, amount); address(augustus).call(augustusCalldata); // swap ERC20 and pure ETH destToken.transfer(msg.sender, destToken.balanceOf(address(this))); } }
0.4.18