{
    "Function": "slitherConstructorConstantVariables",
    "File": "contracts/dex-v2/pool/VaderPoolV2.sol",
    "Parent Contracts": [
        "node_modules/@openzeppelin/contracts/access/Ownable.sol",
        "contracts/dex-v2/pool/BasePoolV2.sol",
        "node_modules/@openzeppelin/contracts/security/ReentrancyGuard.sol",
        "node_modules/@openzeppelin/contracts/token/ERC721/ERC721.sol",
        "node_modules/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol",
        "contracts/interfaces/dex-v2/pool/IVaderPoolV2.sol",
        "node_modules/@openzeppelin/contracts/token/ERC721/IERC721.sol",
        "node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol",
        "node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol",
        "node_modules/@openzeppelin/contracts/utils/Context.sol",
        "contracts/dex/utils/GasThrottle.sol",
        "contracts/shared/ProtocolConstants.sol",
        "contracts/interfaces/dex-v2/pool/IBasePoolV2.sol"
    ],
    "High-Level Calls": [],
    "Internal Calls": [],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "contract VaderPoolV2 is IVaderPoolV2, BasePoolV2, 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    // The LP wrapper contract\r\n    ILPWrapper public wrapper;\r\n\r\n    // The Synth Factory\r\n    ISynthFactory public synthFactory;\r\n\r\n    // Denotes whether the queue system is active\r\n    bool public queueActive;\r\n\r\n    /* ========== CONSTRUCTOR ========== */\r\n\r\n    /*\r\n     * @dev Initialised the contract state by passing the native asset's address\r\n     * to the inherited {BasePoolV2} contract's constructor and setting queue status\r\n     * to the {queueActive} state variable.\r\n     **/\r\n    constructor(bool _queueActive, IERC20 _nativeAsset)\r\n        BasePoolV2(_nativeAsset)\r\n    {\r\n        queueActive = _queueActive;\r\n    }\r\n\r\n    /* ========== VIEWS ========== */\r\n\r\n    /*\r\n     * @dev Returns cumulative prices and the timestamp the were last updated\r\n     * for both native and foreign assets against the pair specified by\r\n     * parameter {foreignAsset}.\r\n     **/\r\n    function cumulativePrices(IERC20 foreignAsset)\r\n        public\r\n        view\r\n        returns (\r\n            uint256 price0CumulativeLast,\r\n            uint256 price1CumulativeLast,\r\n            uint32 blockTimestampLast\r\n        )\r\n    {\r\n        PriceCumulative memory priceCumulative = pairInfo[foreignAsset]\r\n            .priceCumulative;\r\n        price0CumulativeLast = priceCumulative.nativeLast;\r\n        price1CumulativeLast = priceCumulative.foreignLast;\r\n        blockTimestampLast = pairInfo[foreignAsset].blockTimestampLast;\r\n    }\r\n\r\n    /* ========== MUTATIVE FUNCTIONS ========== */\r\n\r\n    /*\r\n     * @dev Initializes contract's state with LP wrapper, synth factory\r\n     * and router addresses.\r\n     *\r\n     * Requirements:\r\n     * - None of the parameters are zero addresses.\r\n     * - The parameters are not already set.\r\n     * - Only callable by contract owner.\r\n     **/\r\n    function initialize(\r\n        ILPWrapper _wrapper,\r\n        ISynthFactory _synthFactory,\r\n        address _router\r\n    ) external onlyOwner {\r\n        require(\r\n            wrapper == ILPWrapper(_ZERO_ADDRESS),\r\n            \"VaderPoolV2::initialize: Already initialized\"\r\n        );\r\n        require(\r\n            _wrapper != ILPWrapper(_ZERO_ADDRESS),\r\n            \"VaderPoolV2::initialize: Incorrect Wrapper Specified\"\r\n        );\r\n        require(\r\n            _synthFactory != ISynthFactory(_ZERO_ADDRESS),\r\n            \"VaderPoolV2::initialize: Incorrect SynthFactory Specified\"\r\n        );\r\n        require(\r\n            _router != _ZERO_ADDRESS,\r\n            \"VaderPoolV2::initialize: Incorrect Router Specified\"\r\n        );\r\n        wrapper = _wrapper;\r\n        synthFactory = _synthFactory;\r\n        router = _router;\r\n    }\r\n\r\n    /*\r\n     * @dev Allows minting of synthetic assets corresponding to the {foreignAsset} based\r\n     * on the native asset amount deposited and returns the minted synth asset amount.\r\n     *\r\n     * Creates the synthetic asset against {foreignAsset} if it does not already exist.\r\n     *\r\n     * Updates the cumulative prices for native and foreign assets.\r\n     *\r\n     * Requirements:\r\n     * - {foreignAsset} must be a supported token.\r\n     **/\r\n    function mintSynth(\r\n        IERC20 foreignAsset,\r\n        uint256 nativeDeposit,\r\n        address from,\r\n        address to\r\n    )\r\n        external\r\n        override\r\n        nonReentrant\r\n        supportedToken(foreignAsset)\r\n        returns (uint256 amountSynth)\r\n    {\r\n        nativeAsset.safeTransferFrom(from, address(this), nativeDeposit);\r\n\r\n        ISynth synth = synthFactory.synths(foreignAsset);\r\n\r\n        if (synth == ISynth(_ZERO_ADDRESS))\r\n            synth = synthFactory.createSynth(\r\n                IERC20Extended(address(foreignAsset))\r\n            );\r\n\r\n        (uint112 reserveNative, uint112 reserveForeign, ) = getReserves(\r\n            foreignAsset\r\n        ); // gas savings\r\n\r\n        amountSynth = VaderMath.calculateSwap(\r\n            nativeDeposit,\r\n            reserveNative,\r\n            reserveForeign\r\n        );\r\n\r\n        // TODO: Clarify\r\n        _update(\r\n            foreignAsset,\r\n            reserveNative + nativeDeposit,\r\n            reserveForeign,\r\n            reserveNative,\r\n            reserveForeign\r\n        );\r\n\r\n        synth.mint(to, amountSynth);\r\n    }\r\n\r\n    /*\r\n     * @dev Allows burning of synthetic assets corresponding to the {foreignAsset}\r\n     * and returns the redeemed amount of native asset.\r\n     *\r\n     * Updates the cumulative prices for native and foreign assets.\r\n     *\r\n     * Requirements:\r\n     * - {foreignAsset} must have a valid synthetic asset against it.\r\n     * - {synthAmount} must be greater than zero.\r\n     **/\r\n    function burnSynth(\r\n        IERC20 foreignAsset,\r\n        uint256 synthAmount,\r\n        address to\r\n    ) external override nonReentrant returns (uint256 amountNative) {\r\n        ISynth synth = synthFactory.synths(foreignAsset);\r\n\r\n        require(\r\n            synth != ISynth(_ZERO_ADDRESS),\r\n            \"VaderPoolV2::burnSynth: Inexistent Synth\"\r\n        );\r\n\r\n        require(\r\n            synthAmount > 0,\r\n            \"VaderPoolV2::burnSynth: Insufficient Synth Amount\"\r\n        );\r\n\r\n        IERC20(synth).safeTransferFrom(msg.sender, address(this), synthAmount);\r\n        synth.burn(synthAmount);\r\n\r\n        (uint112 reserveNative, uint112 reserveForeign, ) = getReserves(\r\n            foreignAsset\r\n        ); // gas savings\r\n\r\n        amountNative = VaderMath.calculateSwap(\r\n            synthAmount,\r\n            reserveForeign,\r\n            reserveNative\r\n        );\r\n\r\n        // TODO: Clarify\r\n        _update(\r\n            foreignAsset,\r\n            reserveNative - amountNative,\r\n            reserveForeign,\r\n            reserveNative,\r\n            reserveForeign\r\n        );\r\n\r\n        nativeAsset.safeTransfer(to, amountNative);\r\n    }\r\n\r\n    /*\r\n     * @dev Allows burning of NFT represented by param {id} for liquidity redeeming.\r\n     *\r\n     * Deletes the position in {positions} mapping against the burned NFT token.\r\n     *\r\n     * Internally calls `_burn` function on {BasePoolV2} contract.\r\n     *\r\n     * Calculates the impermanent loss incurred by the position.\r\n     *\r\n     * Returns the amounts for native and foreign assets sent to the {to} address\r\n     * along with the covered loss.\r\n     *\r\n     * Requirements:\r\n     * - Can only be called by the Router.\r\n     **/\r\n    // NOTE: IL is only covered via router!\r\n    function burn(uint256 id, address to)\r\n        external\r\n        override\r\n        onlyRouter\r\n        returns (\r\n            uint256 amountNative,\r\n            uint256 amountForeign,\r\n            uint256 coveredLoss\r\n        )\r\n    {\r\n        (amountNative, amountForeign) = _burn(id, to);\r\n\r\n        Position storage position = positions[id];\r\n\r\n        uint256 creation = position.creation;\r\n        uint256 originalNative = position.originalNative;\r\n        uint256 originalForeign = position.originalForeign;\r\n\r\n        delete positions[id];\r\n\r\n        // NOTE: Validate it behaves as expected for non-18 decimal tokens\r\n        uint256 loss = VaderMath.calculateLoss(\r\n            originalNative,\r\n            originalForeign,\r\n            amountNative,\r\n            amountForeign\r\n        );\r\n\r\n        // TODO: Original Implementation Applied 100 Days\r\n        coveredLoss =\r\n            (loss * _min(block.timestamp - creation, _ONE_YEAR)) /\r\n            _ONE_YEAR;\r\n    }\r\n\r\n    /*\r\n     * @dev Allows minting of liquidity in fungible tokens. The fungible token\r\n     * is a wrapped LP token against a particular pair. The liquidity issued is also\r\n     * tracked within this contract along with liquidity issued against non-fungible\r\n     * token.\r\n     *\r\n     * Updates the cumulative prices for native and foreign assets.\r\n     *\r\n     * Calls 'mint' on the LP wrapper token contract.\r\n     *\r\n     * Requirements:\r\n     * - LP wrapper token must exist against {foreignAsset}.\r\n     **/\r\n    function mintFungible(\r\n        IERC20 foreignAsset,\r\n        uint256 nativeDeposit,\r\n        uint256 foreignDeposit,\r\n        address from,\r\n        address to\r\n    ) external override nonReentrant returns (uint256 liquidity) {\r\n        IERC20Extended lp = wrapper.tokens(foreignAsset);\r\n\r\n        require(\r\n            lp != IERC20Extended(_ZERO_ADDRESS),\r\n            \"VaderPoolV2::mintFungible: Unsupported Token\"\r\n        );\r\n\r\n        (uint112 reserveNative, uint112 reserveForeign, ) = getReserves(\r\n            foreignAsset\r\n        ); // gas savings\r\n\r\n        nativeAsset.safeTransferFrom(from, address(this), nativeDeposit);\r\n        foreignAsset.safeTransferFrom(from, address(this), foreignDeposit);\r\n\r\n        PairInfo storage pair = pairInfo[foreignAsset];\r\n        uint256 totalLiquidityUnits = pair.totalSupply;\r\n        if (totalLiquidityUnits == 0) liquidity = nativeDeposit;\r\n        else\r\n            liquidity = VaderMath.calculateLiquidityUnits(\r\n                nativeDeposit,\r\n                reserveNative,\r\n                foreignDeposit,\r\n                reserveForeign,\r\n                totalLiquidityUnits\r\n            );\r\n\r\n        require(\r\n            liquidity > 0,\r\n            \"VaderPoolV2::mintFungible: Insufficient Liquidity Provided\"\r\n        );\r\n\r\n        pair.totalSupply = totalLiquidityUnits + liquidity;\r\n\r\n        _update(\r\n            foreignAsset,\r\n            reserveNative + nativeDeposit,\r\n            reserveForeign + foreignDeposit,\r\n            reserveNative,\r\n            reserveForeign\r\n        );\r\n\r\n        lp.mint(to, liquidity);\r\n\r\n        emit Mint(from, to, nativeDeposit, foreignDeposit);\r\n    }\r\n\r\n    /*\r\n     * @dev Allows burning of liquidity issued in fungible tokens.\r\n     *\r\n     * Updates the cumulative prices for native and foreign assets.\r\n     *\r\n     * Calls 'burn' on the LP wrapper token contract.\r\n     *\r\n     * Requirements:\r\n     * - LP wrapper token must exist against {foreignAsset}.\r\n     * - {amountNative} and {amountForeign} redeemed, both must be greater than zero.,\r\n     **/\r\n    function burnFungible(\r\n        IERC20 foreignAsset,\r\n        uint256 liquidity,\r\n        address to\r\n    )\r\n        external\r\n        override\r\n        nonReentrant\r\n        returns (uint256 amountNative, uint256 amountForeign)\r\n    {\r\n        IERC20Extended lp = wrapper.tokens(foreignAsset);\r\n\r\n        require(\r\n            lp != IERC20Extended(_ZERO_ADDRESS),\r\n            \"VaderPoolV2::burnFungible: Unsupported Token\"\r\n        );\r\n\r\n        IERC20(lp).safeTransferFrom(msg.sender, address(this), liquidity);\r\n        lp.burn(liquidity);\r\n\r\n        (uint112 reserveNative, uint112 reserveForeign, ) = getReserves(\r\n            foreignAsset\r\n        ); // gas savings\r\n\r\n        PairInfo storage pair = pairInfo[foreignAsset];\r\n        uint256 _totalSupply = pair.totalSupply;\r\n        amountNative = (liquidity * reserveNative) / _totalSupply;\r\n        amountForeign = (liquidity * reserveForeign) / _totalSupply;\r\n\r\n        require(\r\n            amountNative > 0 && amountForeign > 0,\r\n            \"VaderPoolV2::burnFungible: Insufficient Liquidity Burned\"\r\n        );\r\n\r\n        pair.totalSupply = _totalSupply - liquidity;\r\n\r\n        nativeAsset.safeTransfer(to, amountNative);\r\n        foreignAsset.safeTransfer(to, amountForeign);\r\n\r\n        _update(\r\n            foreignAsset,\r\n            reserveNative - amountNative,\r\n            reserveForeign - amountForeign,\r\n            reserveNative,\r\n            reserveForeign\r\n        );\r\n\r\n        emit Burn(msg.sender, amountNative, amountForeign, to);\r\n    }\r\n\r\n    /* ========== RESTRICTED FUNCTIONS ========== */\r\n\r\n    // TODO: Investigate Necessity\r\n    function toggleQueue() external override onlyOwner {\r\n        bool _queueActive = !queueActive;\r\n        queueActive = _queueActive;\r\n        emit QueueActive(_queueActive);\r\n    }\r\n\r\n    /*\r\n     * @dev Sets the supported state of the token represented by param {foreignAsset}.\r\n     *\r\n     * Requirements:\r\n     * - The param {foreignAsset} is not already a supported token.\r\n     **/\r\n    function setTokenSupport(IERC20 foreignAsset, bool support)\r\n        external\r\n        override\r\n        onlyOwner\r\n    {\r\n        require(\r\n            supported[foreignAsset] != support,\r\n            \"VaderPoolV2::supportToken: Already At Desired State\"\r\n        );\r\n        supported[foreignAsset] = support;\r\n    }\r\n\r\n    /*\r\n     * @dev Sets the supported state of the token represented by param {foreignAsset}.\r\n     *\r\n     * Requirements:\r\n     * - The param {foreignAsset} is not already a supported token.\r\n     **/\r\n    function setFungibleTokenSupport(IERC20 foreignAsset)\r\n        external\r\n        override\r\n        onlyOwner\r\n    {\r\n        wrapper.createWrapper(foreignAsset);\r\n    }\r\n\r\n    /* ========== INTERNAL FUNCTIONS ========== */\r\n\r\n    /* ========== PRIVATE FUNCTIONS ========== */\r\n\r\n    /**\r\n     * @dev Calculates the minimum of the two values\r\n     */\r\n    function _min(uint256 a, uint256 b) private pure returns (uint256) {\r\n        return a < b ? a : b;\r\n    }\r\n}"
}