{
    "Function": "convert",
    "File": "contracts/v3/converters/StablesConverter.sol",
    "Parent Contracts": [
        "contracts/v3/interfaces/IConverter.sol"
    ],
    "High-Level Calls": [
        "IERC20",
        "SafeERC20",
        "ICurve3Pool",
        "ICurve3Pool",
        "SafeERC20",
        "SafeMath",
        "IERC20",
        "SafeERC20",
        "IERC20",
        "SafeMath",
        "IERC20",
        "IERC20",
        "ICurve3Pool"
    ],
    "Internal Calls": [
        "onlyAuthorized"
    ],
    "Library Calls": [
        "safeTransfer",
        "sub",
        "sub",
        "safeTransfer",
        "safeTransfer"
    ],
    "Low-Level Calls": [],
    "Code": "function convert(\n        address _input,\n        address _output,\n        uint256 _inputAmount,\n        uint256 _estimatedOutput\n    )\n        external\n        override\n        onlyAuthorized\n        returns (uint256 _outputAmount)\n    {\n        if (_output == address(token3CRV)) { // convert to 3CRV\n            uint256[3] memory amounts;\n            for (uint8 i = 0; i < 3; i++) {\n                if (_input == address(tokens[i])) {\n                    amounts[i] = _inputAmount;\n                    uint256 _before = token3CRV.balanceOf(address(this));\n                    stableSwap3Pool.add_liquidity(amounts, _estimatedOutput);\n                    uint256 _after = token3CRV.balanceOf(address(this));\n                    _outputAmount = _after.sub(_before);\n                    token3CRV.safeTransfer(msg.sender, _outputAmount);\n                    return _outputAmount;\n                }\n            }\n        } else if (_input == address(token3CRV)) { // convert from 3CRV\n            // A temporary cache, used to save gas.\n            IERC20 _token;\n            for (uint8 i = 0; i < 3; i++) {\n                _token = tokens[i];\n                if (_output == address(_token)) {\n                    uint256 _before = _token.balanceOf(address(this));\n                    stableSwap3Pool.remove_liquidity_one_coin(\n                        _inputAmount,\n                        i,\n                        _estimatedOutput\n                    );\n                    uint256 _after = _token.balanceOf(address(this));\n                    _outputAmount = _after.sub(_before);\n                    _token.safeTransfer(msg.sender, _outputAmount);\n                    return _outputAmount;\n                }\n            }\n        } else {\n            stableSwap3Pool.exchange(\n                indices[_input],\n                indices[_output],\n                _inputAmount,\n                _estimatedOutput\n            );\n            _outputAmount = IERC20(_output).balanceOf(address(this));\n            IERC20(_output).safeTransfer(msg.sender, _outputAmount);\n            return _outputAmount;\n        }\n        return 0;\n    }"
}