pragma solidity 0.8.10; interface IAugustus { function getTokenTransferProxy() external view returns (address); } 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; } // this should allow swaps with ERC20 tokens and native 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.getTokenTransferProxy(), amount); address(augustus).delegatecall{value: msg.value}(augustusCalldata); // swap ERC20 and pure ETH destToken.transfer(msg.sender, destToken.balanceOf(address(this))); } }
0.4.18