{
    "Function": "swap",
    "File": "contracts/adapters/strategy/MetaStrategyAdapter.sol",
    "Parent Contracts": [
        "contracts/adapters/BaseAdapter.sol",
        "contracts/interfaces/IBaseAdapter.sol"
    ],
    "High-Level Calls": [
        "SafeERC20",
        "IERC20",
        "SafeERC20",
        "IStrategyController",
        "SafeERC20",
        "SafeERC20",
        "IStrategyController"
    ],
    "Internal Calls": [
        "require(bool,string)",
        "require(bool,string)",
        "require(bool,string)"
    ],
    "Library Calls": [
        "safeTransferFrom",
        "safeTransfer",
        "safeApprove",
        "safeApprove"
    ],
    "Low-Level Calls": [],
    "Code": "function swap(\n        uint256 amount,\n        uint256 expected,\n        address tokenIn,\n        address tokenOut,\n        address from,\n        address to\n    ) public override {\n        require(tokenIn != tokenOut, \"Tokens cannot match\");\n        require(tokenIn == weth || tokenOut == weth, \"No WETH\");\n\n        if (from != address(this))\n            IERC20(tokenIn).safeTransferFrom(from, address(this), amount);\n\n        if (tokenIn == weth) {\n            if(address(router) != address(this))\n                IERC20(tokenIn).safeApprove(address(router), amount);\n            //Assumes the use of LoopRouter when depositing tokens\n            controller.deposit(IStrategy(tokenOut), router, amount, DEFAULT_SLIPPAGE, \"0x\");\n            if(address(router) != address(this))\n                IERC20(tokenIn).safeApprove(address(router), 0);\n        }\n\n        if (tokenOut == weth)\n            controller.withdrawWETH(IStrategy(tokenIn), router, amount, DEFAULT_SLIPPAGE, \"0x\");\n\n        uint256 received = IERC20(tokenOut).balanceOf(address(this));\n        require(received >= expected, \"Insufficient tokenOut amount\");\n\n        if (to != address(this))\n          IERC20(tokenOut).safeTransfer(to, received);\n    }"
}