{
    "Function": "swap",
    "File": "contracts/adapters/exchanges/CurveAdapter.sol",
    "Parent Contracts": [
        "contracts/adapters/BaseAdapter.sol",
        "contracts/interfaces/IBaseAdapter.sol"
    ],
    "High-Level Calls": [
        "ICurveRegistry",
        "SafeERC20",
        "ICurveAddressProvider",
        "SafeERC20",
        "ICurveStableSwap",
        "SafeERC20",
        "ICurveStableSwap",
        "ICurveRegistry",
        "IERC20"
    ],
    "Internal Calls": [
        "require(bool,string)",
        "require(bool,string)",
        "require(bool,string)"
    ],
    "Library Calls": [
        "safeTransferFrom",
        "safeTransfer",
        "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        ICurveRegistry curveRegistry = ICurveRegistry(addressProvider.get_registry());\n        if (from != address(this))\n            IERC20(tokenIn).safeTransferFrom(from, address(this), amount);\n        address pool = curveRegistry.find_pool_for_coins(tokenIn, tokenOut, 0);\n        require(pool != address(0), \"Pool not found\");\n        (int128 indexIn, int128 indexOut, bool isUnderlying) = curveRegistry.get_coin_indices(pool, tokenIn, tokenOut);\n        IERC20(tokenIn).safeApprove(pool, amount);\n        if (isUnderlying) {\n            ICurveStableSwap(pool).exchange_underlying(indexIn, indexOut, amount, 1);\n        } else {\n            ICurveStableSwap(pool).exchange(indexIn, indexOut, amount, 1);\n        }\n        uint256 received = IERC20(tokenOut).balanceOf(address(this));\n        require(received >= expected, \"Insufficient tokenOut amount\");\n        if (to != address(this))\n            IERC20(tokenOut).safeTransfer(to, received);\n    }"
}