{
    "Function": "slitherConstructorConstantVariables",
    "File": "contracts/dex-v2/router/VaderRouterV2.sol",
    "Parent Contracts": [
        "node_modules/@openzeppelin/contracts/access/Ownable.sol",
        "node_modules/@openzeppelin/contracts/utils/Context.sol",
        "contracts/shared/ProtocolConstants.sol",
        "contracts/interfaces/dex-v2/router/IVaderRouterV2.sol"
    ],
    "High-Level Calls": [],
    "Internal Calls": [],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "contract VaderRouterV2 is IVaderRouterV2, ProtocolConstants, Ownable {\r\n    /* ========== LIBRARIES ========== */\r\n\r\n    // Used for safe token transfers\r\n    using SafeERC20 for IERC20;\r\n\r\n    /* ========== STATE VARIABLES ========== */\r\n\r\n    // Address of the Vader pool contract.\r\n    IVaderPoolV2 public immutable pool;\r\n\r\n    // Address of native asset (USDV or Vader).\r\n    IERC20 public immutable nativeAsset;\r\n\r\n    // Address of reserve contract.\r\n    IVaderReserve public reserve;\r\n\r\n    /* ========== CONSTRUCTOR ========== */\r\n\r\n    /*\r\n     * @dev Initialises contract by setting pool and native asset addresses.\r\n     *\r\n     * Native assets address is taken from param {_pool} and native asset's address\r\n     * is retrieved from {VaderPoolV2} contract.\r\n     **/\r\n    constructor(IVaderPoolV2 _pool) {\r\n        require(\r\n            _pool != IVaderPoolV2(_ZERO_ADDRESS),\r\n            \"VaderRouterV2::constructor: Incorrect Arguments\"\r\n        );\r\n\r\n        pool = _pool;\r\n        nativeAsset = pool.nativeAsset();\r\n    }\r\n\r\n    /* ========== VIEWS ========== */\r\n\r\n    /* ========== MUTATIVE FUNCTIONS ========== */\r\n\r\n    /*\r\n     * @dev Allows adding of liquidity to the Vader pool.\r\n     *\r\n     * Internally calls {addLiquidity} function.\r\n     *\r\n     * Returns the amount of liquidity minted.\r\n     **/\r\n    // NOTE: For Uniswap V2 compliancy, necessary due to stack too deep\r\n    function addLiquidity(\r\n        IERC20 tokenA,\r\n        IERC20 tokenB,\r\n        uint256 amountADesired,\r\n        uint256 amountBDesired,\r\n        uint256, // amountAMin = unused\r\n        uint256, // amountBMin = unused\r\n        address to,\r\n        uint256 deadline\r\n    ) external override returns (uint256 liquidity) {\r\n        return\r\n            addLiquidity(\r\n                tokenA,\r\n                tokenB,\r\n                amountADesired,\r\n                amountBDesired,\r\n                to,\r\n                deadline\r\n            );\r\n    }\r\n\r\n    /*\r\n     * @dev Allows adding of liquidity to the Vader pool.\r\n     *\r\n     * Calls `mint` function on the {BasePoolV2} contract.\r\n     *\r\n     * Pair is determined based {tokenA} and {tokenB} where one of them represents\r\n     * native asset and the other one represents foreign asset.\r\n     *\r\n     * Returns the amount of liquidity units minted against a pair.\r\n     *\r\n     * Requirements:\r\n     * - The current timestamp has not exceeded the param {deadline}.\r\n     * - Amongst {tokenA} and {tokenB}, one should be the native asset and the other\r\n     *   one must be the foreign asset.\r\n     * - The foreign asset among {tokenA} and {tokenB} must be a supported token.\r\n     **/\r\n    function addLiquidity(\r\n        IERC20 tokenA,\r\n        IERC20 tokenB,\r\n        uint256 amountADesired,\r\n        uint256 amountBDesired,\r\n        address to,\r\n        uint256 deadline\r\n    ) public override ensure(deadline) returns (uint256 liquidity) {\r\n        IERC20 foreignAsset;\r\n        uint256 nativeDeposit;\r\n        uint256 foreignDeposit;\r\n\r\n        if (tokenA == nativeAsset) {\r\n            require(\r\n                pool.supported(tokenB),\r\n                \"VaderRouterV2::addLiquidity: Unsupported Assets Specified\"\r\n            );\r\n            foreignAsset = tokenB;\r\n            foreignDeposit = amountBDesired;\r\n            nativeDeposit = amountADesired;\r\n        } else {\r\n            require(\r\n                tokenB == nativeAsset && pool.supported(tokenA),\r\n                \"VaderRouterV2::addLiquidity: Unsupported Assets Specified\"\r\n            );\r\n            foreignAsset = tokenA;\r\n            foreignDeposit = amountADesired;\r\n            nativeDeposit = amountBDesired;\r\n        }\r\n\r\n        liquidity = pool.mint(\r\n            foreignAsset,\r\n            nativeDeposit,\r\n            foreignDeposit,\r\n            msg.sender,\r\n            to\r\n        );\r\n    }\r\n\r\n    /*\r\n     * @dev Allows removing of liquidity by {msg.sender} and transfers the\r\n     * underlying assets to {to} address.\r\n     *\r\n     * The liquidity is removed from a pair represented by {tokenA} and {tokenB}.\r\n     *\r\n     * Transfers the NFT with Id {id} representing user's position, to the pool address,\r\n     * so the pool is able to burn it in the `burn` function call.\r\n     *\r\n     * Calls the `burn` function on the pool contract.\r\n     *\r\n     * Calls the `reimburseImpermanentLoss` on reserve contract to cover impermanent loss\r\n     * for the liquidity being removed.\r\n     *\r\n     * Requirements:\r\n     * - The underlying assets amounts of {amountA} and {amountB} must\r\n     *   be greater than or equal to {amountAMin} and {amountBMin}, respectively.\r\n     * - The current timestamp has not exceeded the param {deadline}.\r\n     * - Either of {tokenA} or {tokenB} should be a native asset and the other one\r\n     *   must be the foreign asset associated with the NFT representing liquidity.\r\n     **/\r\n    function removeLiquidity(\r\n        address tokenA,\r\n        address tokenB,\r\n        uint256 id,\r\n        uint256 amountAMin,\r\n        uint256 amountBMin,\r\n        address to,\r\n        uint256 deadline\r\n    )\r\n        public\r\n        override\r\n        ensure(deadline)\r\n        returns (uint256 amountA, uint256 amountB)\r\n    {\r\n        IERC20 _foreignAsset = pool.positionForeignAsset(id);\r\n        IERC20 _nativeAsset = nativeAsset;\r\n\r\n        bool isNativeA = _nativeAsset == IERC20(tokenA);\r\n\r\n        if (isNativeA) {\r\n            require(\r\n                IERC20(tokenB) == _foreignAsset,\r\n                \"VaderRouterV2::removeLiquidity: Incorrect Addresses Specified\"\r\n            );\r\n        } else {\r\n            require(\r\n                IERC20(tokenA) == _foreignAsset &&\r\n                    IERC20(tokenB) == _nativeAsset,\r\n                \"VaderRouterV2::removeLiquidity: Incorrect Addresses Specified\"\r\n            );\r\n        }\r\n\r\n        pool.transferFrom(msg.sender, address(pool), id);\r\n\r\n        (\r\n            uint256 amountNative,\r\n            uint256 amountForeign,\r\n            uint256 coveredLoss\r\n        ) = pool.burn(id, to);\r\n\r\n        (amountA, amountB) = isNativeA\r\n            ? (amountNative, amountForeign)\r\n            : (amountForeign, amountNative);\r\n\r\n        require(amountA >= amountAMin, \"VaderRouterV2: INSUFFICIENT_A_AMOUNT\");\r\n        require(amountB >= amountBMin, \"VaderRouterV2: INSUFFICIENT_B_AMOUNT\");\r\n\r\n        reserve.reimburseImpermanentLoss(msg.sender, coveredLoss);\r\n    }\r\n\r\n    /*\r\n     * @dev Allows swapping of exact source token amount to destination\r\n     * token amount.\r\n     *\r\n     * Internally calls {_swap} function.\r\n     *\r\n     * Requirements:\r\n     * - The destination amount {amountOut} must greater than or equal to param {amountOutMin}.\r\n     * - The current timestamp has not exceeded the param {deadline}.\r\n     **/\r\n    function swapExactTokensForTokens(\r\n        uint256 amountIn,\r\n        uint256 amountOutMin,\r\n        IERC20[] calldata path,\r\n        address to,\r\n        uint256 deadline\r\n    ) external virtual override ensure(deadline) returns (uint256 amountOut) {\r\n        amountOut = _swap(amountIn, path, to);\r\n\r\n        require(\r\n            amountOut >= amountOutMin,\r\n            \"VaderRouterV2::swapExactTokensForTokens: Insufficient Trade Output\"\r\n        );\r\n    }\r\n\r\n    /* ========== RESTRICTED FUNCTIONS ========== */\r\n\r\n    /*\r\n     * @dev Sets the reserve address and renounces contract's ownership.\r\n     *\r\n     * Requirements:\r\n     * - Only existing owner can call this function.\r\n     * - Param {_reserve} cannot be a zero address.\r\n     **/\r\n    function initialize(IVaderReserve _reserve) external onlyOwner {\r\n        require(\r\n            _reserve != IVaderReserve(_ZERO_ADDRESS),\r\n            \"VaderRouterV2::initialize: Incorrect Reserve Specified\"\r\n        );\r\n\r\n        reserve = _reserve;\r\n\r\n        renounceOwnership();\r\n    }\r\n\r\n    /* ========== INTERNAL FUNCTIONS ========== */\r\n\r\n    /* ========== PRIVATE FUNCTIONS ========== */\r\n\r\n    /*\r\n     * @dev Allows swapping of assets from within a single Vader pool pair or\r\n     * across two different Vader pairs.\r\n     *\r\n     * In case of a single Vader pair, the native asset can be swapped for foreign\r\n     * asset and vice versa.\r\n     *\r\n     * In case of two Vader pairs, the foreign asset is swapped for native asset from\r\n     * the first Vader pool and the native asset retrieved from the first Vader pair is swapped\r\n     * for foreign asset from the second Vader pair.\r\n     *\r\n     * Requirements:\r\n     * - Param {path} length can be either 2 or 3.\r\n     * - If the {path} length is 3 the index 0 and 1 must contain foreign assets' addresses\r\n     *   and index 1 must contain native asset's address.\r\n     * - If the {path} length is 2 then either of indexes must contain foreign asset's address\r\n     *   and the other one must contain native asset's address.\r\n     **/\r\n    function _swap(\r\n        uint256 amountIn,\r\n        IERC20[] calldata path,\r\n        address to\r\n    ) private returns (uint256 amountOut) {\r\n        if (path.length == 3) {\r\n            require(\r\n                path[0] != path[1] &&\r\n                    path[1] == pool.nativeAsset() &&\r\n                    path[2] != path[1],\r\n                \"VaderRouterV2::_swap: Incorrect Path\"\r\n            );\r\n\r\n            path[0].safeTransferFrom(msg.sender, address(pool), amountIn);\r\n\r\n            return pool.doubleSwap(path[0], path[2], amountIn, to);\r\n        } else {\r\n            require(\r\n                path.length == 2,\r\n                \"VaderRouterV2::_swap: Incorrect Path Length\"\r\n            );\r\n            IERC20 _nativeAsset = nativeAsset;\r\n            require(path[0] != path[1], \"VaderRouterV2::_swap: Incorrect Path\");\r\n\r\n            path[0].safeTransferFrom(msg.sender, address(pool), amountIn);\r\n            if (path[0] == _nativeAsset) {\r\n                return pool.swap(path[1], amountIn, 0, to);\r\n            } else {\r\n                require(\r\n                    path[1] == _nativeAsset,\r\n                    \"VaderRouterV2::_swap: Incorrect Path\"\r\n                );\r\n                return pool.swap(path[0], 0, amountIn, to);\r\n            }\r\n        }\r\n    }\r\n\r\n    /* ========== MODIFIERS ========== */\r\n\r\n    // Guard ensuring that the current timestamp has not exceeded the param {deadline}.\r\n    modifier ensure(uint256 deadline) {\r\n        require(deadline >= block.timestamp, \"VaderRouterV2::ensure: Expired\");\r\n        _;\r\n    }\r\n}"
}