{
    "Function": "registerPair",
    "File": "contracts/twap/TwapOracle.sol",
    "Parent Contracts": [
        "node_modules/@openzeppelin/contracts/access/Ownable.sol",
        "node_modules/@openzeppelin/contracts/utils/Context.sol"
    ],
    "High-Level Calls": [
        "IVaderPoolV2",
        "IUniswapV2Factory",
        "IUniswapV2Pair",
        "IUniswapV2Pair",
        "IVaderPoolV2",
        "IUniswapV2Pair"
    ],
    "Internal Calls": [
        "abi.encodePacked()",
        "require(bool,string)",
        "pairExists",
        "keccak256(bytes)",
        "initialized",
        "require(bool,string)",
        "require(bool,string)",
        "onlyOwner",
        "require(bool,string)"
    ],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "function registerPair(\n        address factory,\n        address token0,\n        address token1\n    ) external onlyOwner initialized {\n        require(\n            token0 == VADER || token0 == USDV,\n            \"TwapOracle::registerPair: Invalid token0 address\"\n        );\n        require(\n            token0 != token1,\n            \"TwapOracle::registerPair: Same token address\"\n        );\n        require(\n            !pairExists(token0, token1),\n            \"TwapOracle::registerPair: Pair exists\"\n        );\n\n        address pairAddr;\n        uint256 price0CumulativeLast;\n        uint256 price1CumulativeLast;\n        uint112 reserve0;\n        uint112 reserve1;\n        uint32 blockTimestampLast;\n\n        if (token0 == VADER) {\n            IUniswapV2Pair pair = IUniswapV2Pair(\n                IUniswapV2Factory(factory).getPair(token0, token1)\n            );\n            pairAddr = address(pair);\n            price0CumulativeLast = pair.price0CumulativeLast();\n            price1CumulativeLast = pair.price1CumulativeLast();\n            (reserve0, reserve1, blockTimestampLast) = pair.getReserves();\n        } else {\n            pairAddr = address(_vaderPool);\n            (price0CumulativeLast, price1CumulativeLast, ) = _vaderPool\n                .cumulativePrices(IERC20(token1));\n            (reserve0, reserve1, blockTimestampLast) = _vaderPool.getReserves(\n                IERC20(token1)\n            );\n        }\n\n        require(\n            reserve0 != 0 && reserve1 != 0,\n            \"TwapOracle::registerPair: No reserves\"\n        );\n\n        _pairExists[keccak256(abi.encodePacked(token0, token1))] = true;\n\n        _pairs.push(\n            PairData({\n                pair: pairAddr,\n                token0: token0,\n                token1: token1,\n                price0CumulativeLast: price0CumulativeLast,\n                price1CumulativeLast: price1CumulativeLast,\n                blockTimestampLast: blockTimestampLast,\n                price0Average: FixedPoint.uq112x112({_x: 0}),\n                price1Average: FixedPoint.uq112x112({_x: 0})\n            })\n        );\n    }"
}