{
    "Function": "slitherConstructorVariables",
    "File": "contracts/ThecosomataETH.sol",
    "Parent Contracts": [
        "node_modules/@openzeppelin/contracts/access/Ownable.sol",
        "node_modules/@openzeppelin/contracts/utils/Context.sol"
    ],
    "High-Level Calls": [],
    "Internal Calls": [],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "contract ThecosomataETH is Ownable {\n    address public immutable BTRFLY;\n    address public immutable WETH;\n    address public immutable CURVEPOOL;\n    address public immutable TREASURY;\n\n    uint256 private immutable _btrflyDecimals;\n    uint256 private immutable _ethDecimals;\n\n    uint256 public slippage = 5; // in 1000th\n\n    event AddLiquidity(\n        uint256 ethLiquidity,\n        uint256 btrflyLiquidity,\n        uint256 btrflyBurned\n    );\n\n    constructor(\n        address _BTRFLY,\n        address _WETH,\n        address _TREASURY,\n        address _CURVEPOOL\n    ) {\n        require(_BTRFLY != address(0), \"Invalid BTRFLY address\");\n        BTRFLY = _BTRFLY;\n\n        require(_WETH != address(0), \"Invalid WETH address\");\n        WETH = _WETH;\n\n        require(_CURVEPOOL != address(0), \"Invalid POOL address\");\n        CURVEPOOL = _CURVEPOOL;\n\n        require(_TREASURY != address(0), \"Invalid TREASURY address\");\n        TREASURY = _TREASURY;\n\n        IERC20(_BTRFLY).approve(_CURVEPOOL, 2**256 - 1);\n        IERC20(_WETH).approve(_CURVEPOOL, 2**256 - 1);\n\n        _btrflyDecimals = IBTRFLY(_BTRFLY).decimals();\n        _ethDecimals = IBTRFLY(_WETH).decimals();\n    }\n\n    // Update slippage percentage (in 1000th)\n    function setSlippage(uint256 _slippage) external onlyOwner {\n        // Make sure the slippage is less than 10%\n        require(_slippage < 100, \"Slippage too high\");\n        slippage = _slippage;\n    }\n\n    // Return whether we should perform an upkeep based on the contract's BTRFLY balance\n    function checkUpkeep()\n        public\n        view\n        returns (bool upkeepNeeded)\n    {\n        if (IBTRFLY(BTRFLY).balanceOf(address(this)) > 0) {\n            return true;\n        }\n    }\n\n    // Fetch the equivalent value of either specified BTRFLY/ETH amount\n    function calculateAmountRequiredForLP(uint256 amount, bool isBTRFLY)\n        internal\n        view\n        returns (uint256)\n    {\n        // Default price is based off \"1 BTRFLY = X ETH\", in 10^18 format\n        uint256 priceOracle = ICurveCryptoPool(CURVEPOOL).price_oracle();\n\n        if (isBTRFLY) {\n            return (((amount * priceOracle) / (10**18)) * (10**_ethDecimals)) /\n                (10**_btrflyDecimals);\n        }\n\n        return\n            (((amount * (10**18)) / priceOracle) *\n                (10**_btrflyDecimals)) / (10**_ethDecimals);\n    }\n\n    // Calculate the min. LP token amount (after slippage) and attempt to add liquidity\n    function addLiquidity(uint256 ethAmount, uint256 btrflyAmount) internal {\n        uint256[2] memory amounts = [ethAmount, btrflyAmount];\n        uint256 expectedAmount = ICurveCryptoPool(CURVEPOOL).calc_token_amount(\n            amounts\n        );\n        uint256 minAmount = expectedAmount - ((expectedAmount * slippage) / 1000);\n\n        ICurveCryptoPool(CURVEPOOL).add_liquidity(amounts, minAmount);\n    }\n\n    // Perform the actual upkeep flow\n    function performUpkeep() external onlyOwner {\n        require(checkUpkeep(), \"Invalid upkeep state\");\n\n        uint256 btrfly = IBTRFLY(BTRFLY).balanceOf(address(this));\n        uint256 ethAmount = calculateAmountRequiredForLP(btrfly, true);\n        uint256 ethCap = IERC20(WETH).balanceOf(TREASURY);\n        uint256 ethLiquidity = ethCap > ethAmount ? ethAmount : ethCap;\n\n        // Use BTRFLY balance if remaining capacity is enough, otherwise, calculate BTRFLY amount\n        uint256 btrflyLiquidity = ethCap > ethAmount\n            ? btrfly\n            : calculateAmountRequiredForLP(ethLiquidity, false);\n\n        IRedactedTreasury(TREASURY).manage(WETH, ethLiquidity);\n\n        // Only complete upkeep only on sufficient amounts\n        require(ethLiquidity > 0 && btrflyLiquidity > 0, \"Insufficient amounts\");\n        addLiquidity(ethLiquidity, btrflyLiquidity);\n\n        // Transfer out the pool token to treasury\n        address token = ICurveCryptoPool(CURVEPOOL).token();\n        uint256 tokenBalance = IERC20(token).balanceOf(address(this));\n        IERC20(token).transfer(TREASURY, tokenBalance);\n\n        uint256 unusedBTRFLY = IBTRFLY(BTRFLY).balanceOf(address(this));\n\n        if (unusedBTRFLY > 0) {\n            IBTRFLY(BTRFLY).burn(unusedBTRFLY);\n        }\n\n        emit AddLiquidity(ethLiquidity, btrflyLiquidity, unusedBTRFLY);\n    }\n\n    // Withdraw arbitrary token and amount owned by the contract\n    function withdraw(\n        address token,\n        uint256 amount,\n        address recipient\n    ) external onlyOwner {\n        require(recipient != address(0), \"Invalid recipient\");\n        IERC20(token).transfer(recipient, amount);\n    }\n}"
}