{
    "Function": "slitherConstructorVariables",
    "File": "contracts/Utils.sol",
    "Parent Contracts": [],
    "High-Level Calls": [],
    "Internal Calls": [],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "contract Utils {\n    address public BASE;\n    uint public one = 10**18;\n\n    constructor (address _base) {\n        BASE = _base;\n    }\n\n    struct PoolDataStruct {\n        address tokenAddress;\n        address poolAddress;\n        uint genesis;\n        uint baseAmount;\n        uint tokenAmount;\n        uint fees;\n        uint volume;\n        uint txCount;\n        uint poolUnits;\n    }\n\n    function _DAO() internal view returns(iDAO) {\n        return iBASE(BASE).DAO();\n    }\n\n    //================================== HELPERS ================================//\n\n    function getPoolData(address token) external view returns(PoolDataStruct memory poolData){\n        address pool = getPool(token);\n        poolData.poolAddress = pool;\n        poolData.tokenAddress = token;\n        poolData.genesis = iPOOL(pool).genesis();\n        poolData.baseAmount = iPOOL(pool).baseAmount();\n        poolData.tokenAmount = iPOOL(pool).tokenAmount();\n        poolData.poolUnits = iBEP20(pool).totalSupply();\n        return poolData;\n    }\n\n    function getPoolShareWeight(address token, uint units) external view returns(uint weight){\n        address pool = getPool(token);\n        weight = calcShare(units, iBEP20(pool).totalSupply(), iPOOL(pool).baseAmount());\n        return (weight);\n    }\n\n    function getPool(address token) public view returns(address pool){\n        return iPOOLFACTORY(_DAO().POOLFACTORY()).getPool(token);\n    }\n\n    //================================== CORE-MATH ==================================//\n    \n    // Calculate the feeBurn's feeOnTransfer based on total supply\n    function getFeeOnTransfer(uint256 totalSupply, uint256 maxSupply) external pure returns (uint256) {\n        return calcShare(totalSupply, maxSupply, 100); // 0 -> 100bp\n    }\n\n    // Calculate 'part' of a total using basis points | 10,000 basis points = 100.00%\n    function calcPart(uint256 bp, uint256 total) external pure returns (uint256) {\n        require(bp <= 10000, \"!bp\"); // basis points must be valid\n        return calcShare(bp, 10000, total);\n    }\n\n    // Calc share | share = amount * part / total\n    function calcShare(uint256 part, uint256 total, uint256 amount) public pure returns (uint256 share) {\n        if (part > total) {\n            part = total; // Part cant be greater than the total\n        }\n        if (total > 0) {\n            share = (amount * part) / total;\n        }\n    }\n\n    // Calculate liquidity units\n    function calcLiquidityUnits(uint b, uint B, uint t, uint T, uint P) external view returns (uint units){\n        if(P == 0){\n            return b; // If pool is empty; use b as initial units\n        } else {\n            // units = ((P (t B + T b))/(2 T B)) * slipAdjustment\n            // P * (part1 + part2) / (part3) * slipAdjustment\n            uint slipAdjustment = getSlipAdustment(b, B, t, T);\n            uint part1 = t*(B);\n            uint part2 = T*(b);\n            uint part3 = T*(B)*(2);\n            uint _units = (P * (part1 + (part2))) / (part3);\n            return _units * slipAdjustment / one;  // Divide by 10**18\n        }\n    }\n\n    // Get slip adjustment\n    function getSlipAdustment(uint b, uint B, uint t, uint T) public view returns (uint slipAdjustment){\n        // slipAdjustment = (1 - ABS((B t - b T)/((2 b + B) (t + T))))\n        // 1 - ABS(part1 - part2)/(part3 * part4))\n        uint part1 = B * (t);\n        uint part2 = b * (T);\n        uint part3 = b * (2) + (B);\n        uint part4 = t + (T);\n        uint numerator;\n        if(part1 > part2){\n            numerator = part1 - (part2);\n        } else {\n            numerator = part2 - (part1);\n        }\n        uint denominator = part3 * (part4);\n        return one - ((numerator * (one)) / (denominator)); // Multiply by 10**18\n    }\n\n    // Calculate symmetrical redemption value of LP tokens (per side)\n    function calcLiquidityHoldings(uint units, address token, address pool) external view returns (uint share){\n        // share = amount * part / total\n        // address pool = getPool(token);\n        uint amount;\n        if(token == BASE){\n            amount = iPOOL(pool).baseAmount();\n        } else {\n            amount = iPOOL(pool).tokenAmount();\n        }\n        uint totalSupply = iBEP20(pool).totalSupply();\n        return(amount*(units))/(totalSupply);\n    }\n\n    function calcSwapOutput(uint x, uint X, uint Y) public pure returns (uint output){\n        // y = (x * X * Y )/(x + X)^2\n        uint numerator = x * (X * (Y));\n        uint denominator = (x + (X)) * (x + (X));\n        return numerator / (denominator);\n    }\n\n    function calcSwapFee(uint x, uint X, uint Y) external pure returns (uint output){\n        // y = (x * x * Y) / (x + X)^2\n        uint numerator = x * (x * (Y));\n        uint denominator = (x + (X)) * (x + (X));\n        return numerator / (denominator);\n    }\n\n    // Calculate asymmetrical redemption value of LP tokens (remove all to TOKEN)\n    function calcAsymmetricValueToken(address pool, uint amount) external view returns (uint tokenValue){\n        uint baseAmount = calcShare(amount, iBEP20(pool).totalSupply(), iPOOL(pool).baseAmount());\n        uint tokenAmount = calcShare(amount, iBEP20(pool).totalSupply(), iPOOL(pool).tokenAmount());\n        uint baseSwapped = calcSwapValueInTokenWithPool(pool, baseAmount);\n        tokenValue = tokenAmount + baseSwapped;\n        return tokenValue;\n    }\n\n    function calcLiquidityUnitsAsym(uint amount, address pool) external view returns (uint units){\n        // synthUnits += (P b)/(2 (b + B))\n        uint baseAmount = iPOOL(pool).baseAmount();\n        uint totalSupply = iBEP20(pool).totalSupply();\n        uint two = 2;\n        return (totalSupply * amount) / (two * (amount + baseAmount));\n    }\n\n    //==================================== PRICING ====================================//\n\n    function calcSpotValueInBase(address token, uint amount) external view returns (uint value){\n        address pool = getPool(token);\n        return calcSpotValueInBaseWithPool(pool, amount);\n    }\n\n    function calcSpotValueInToken(address token, uint amount) external view returns (uint value){\n        address pool = getPool(token);\n        return calcSpotValueInTokenWithPool(pool, amount);\n    }\n\n    function calcSwapValueInBase(address token, uint amount) external view returns (uint _output){\n        address pool = getPool(token);\n        return  calcSwapValueInBaseWithPool(pool, amount);\n    }\n\n    function calcSwapValueInBaseWithSYNTH(address synth, uint amount) external view returns (uint _output){\n        address token = iSYNTH(synth).LayerONE();\n        address pool = getPool(token);\n        return  calcSwapValueInBaseWithPool(pool, amount);\n    }\n\n    function calcSwapValueInToken(address token, uint amount) external view returns (uint _output){\n        address pool = getPool(token);\n        return  calcSwapValueInTokenWithPool(pool, amount);\n    }\n\n    function calcSpotValueInBaseWithPool(address pool, uint amount) public view returns (uint value){\n        uint _baseAmount = iPOOL(pool).baseAmount();\n        uint _tokenAmount = iPOOL(pool).tokenAmount();\n        return (amount*(_baseAmount))/(_tokenAmount);\n    }\n\n    function calcSpotValueInTokenWithPool(address pool, uint amount) public view returns (uint value){\n        uint _baseAmount = iPOOL(pool).baseAmount();\n        uint _tokenAmount = iPOOL(pool).tokenAmount();\n        return (amount*(_tokenAmount))/(_baseAmount);\n    }\n\n    function calcSwapValueInBaseWithPool(address pool, uint amount) public view returns (uint _output){\n        uint _baseAmount = iPOOL(pool).baseAmount();\n        uint _tokenAmount = iPOOL(pool).tokenAmount();\n        return  calcSwapOutput(amount, _tokenAmount, _baseAmount);\n    }\n\n    function calcSwapValueInTokenWithPool(address pool, uint amount) public view returns (uint _output){\n        uint _baseAmount = iPOOL(pool).baseAmount();\n        uint _tokenAmount = iPOOL(pool).tokenAmount();\n        return  calcSwapOutput(amount, _baseAmount, _tokenAmount);\n    }\n\n    function calcActualSynthUnits(uint amount, address synth) external view returns (uint _output) {\n        address token = iSYNTH(synth).LayerONE();\n        address pool = getPool(token);\n        uint _baseAmount = iPOOL(pool).baseAmount();\n        uint _tokenAmount = iPOOL(pool).tokenAmount();\n        return ((amount * _baseAmount) / (2 * _tokenAmount));\n    }\n}"
}