{
    "Function": "swap",
    "File": "contracts/adapters/borrow/AaveV2DebtAdapter.sol",
    "Parent Contracts": [
        "contracts/adapters/BaseAdapter.sol",
        "contracts/interfaces/IBaseAdapter.sol"
    ],
    "High-Level Calls": [
        "SafeERC20",
        "ILendingPool",
        "ILendingPool",
        "ILendingPoolAddressesProvider",
        "SafeERC20",
        "SafeERC20"
    ],
    "Internal Calls": [
        "require(bool,string)",
        "_convert",
        "revert()",
        "require(bool,string)"
    ],
    "Library Calls": [
        "safeApprove",
        "safeTransferFrom",
        "safeTransfer"
    ],
    "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        address lendingPool = addressesProvider.getLendingPool();\n        // use zero address to represent strategy's collateral pool reserve which is valued in weth (doesn't matter that it isn't an erc20, since no erc20 functions are used)\n        if (tokenOut == address(0)) {\n            // since tokenOut is collateral pool, we are paying back loan\n            if (from != address(this))\n                IERC20(tokenIn).safeTransferFrom(from, address(this), amount);\n            IERC20(tokenIn).safeApprove(lendingPool, amount);\n            ILendingPool(lendingPool).repay(tokenIn, amount, 1, to);\n        } else if (tokenIn == address(0)) {\n            // tokenIn is collateral pool meaning we are taking out loan\n            uint256 received = _convert(amount, weth, tokenOut); // lendingPool is valued in weth\n            require(received >= expected, \"Insufficient tokenOut amount\");\n            ILendingPool(lendingPool).borrow(tokenOut, received, 1, 0, from);\n            if (to != address(this))\n                IERC20(tokenOut).safeTransfer(to, received);\n        } else {\n            revert();\n        }\n    }"
}