{
    "Function": "_getEffectiveLiquidityForPoolsPurge",
    "File": "contracts/test/BalancerRegistry.sol",
    "Parent Contracts": [],
    "High-Level Calls": [
        "SafeMath",
        "SafeMath",
        "EnumerableSet",
        "EnumerableSet",
        "EnumerableSet",
        "EnumerableSet",
        "SafeMath",
        "IBPool",
        "EnumerableSet",
        "EnumerableSet",
        "SafeMath",
        "SafeMath",
        "SafeMath",
        "IBPool",
        "EnumerableSet"
    ],
    "Internal Calls": [
        "_createKey",
        "bmul",
        "bdiv",
        "bdiv"
    ],
    "Library Calls": [
        "length",
        "add",
        "add",
        "remove",
        "at",
        "mul",
        "at",
        "length",
        "at",
        "add",
        "add",
        "mul",
        "length"
    ],
    "Low-Level Calls": [],
    "Code": "function _getEffectiveLiquidityForPoolsPurge(address token1, address token2, address[] memory pools)\n        public returns(uint256[] memory effectiveLiquidity)\n    {\n        uint256 totalLiq = 0;\n        bytes32 key = _createKey(token1, token2);\n\n        // Store each pools liquidity and sum total liquidity\n        for (uint i = 0; i < pools.length; i++) {\n            PoolPairInfo memory info = _infos[pools[i]][key];\n            if (token1 < token2) {\n                // we define effective liquidity as b2 * w1 / (w1 + w2)\n                _infos[pools[i]][key].liq = bdiv(uint256(info.weight1), uint256(info.weight1).add(uint256(info.weight2)));\n                _infos[pools[i]][key].liq = _infos[pools[i]][key].liq.mul(IBPool(pools[i]).getBalance(token2));\n                totalLiq = totalLiq.add(_infos[pools[i]][key].liq);\n            } else {\n                _infos[pools[i]][key].liq = bdiv(uint256(info.weight2), uint256(info.weight1).add(uint256(info.weight2)));\n                _infos[pools[i]][key].liq = _infos[pools[i]][key].liq.mul(IBPool(pools[i]).getBalance(token2));\n                totalLiq = totalLiq.add(_infos[pools[i]][key].liq);\n            }\n        }\n\n        uint256 threshold = bmul(totalLiq, ((10 * BONE) / 100));\n\n        // Delete any pools that aren't greater than threshold (10% of total)\n        for(uint i = 0;i < _pools[key].pools.length();i++){\n            if(_infos[_pools[key].pools.at(i)][key].liq < threshold){\n                _pools[key].pools.remove(_pools[key].pools.at(i));\n            }\n        }\n\n        effectiveLiquidity = new uint256[](_pools[key].pools.length());\n\n        // pool.remove reorders pools so need to use correct liq for index\n        for(uint i = 0;i < _pools[key].pools.length();i++){\n            effectiveLiquidity[i] = _infos[_pools[key].pools.at(i)][key].liq;\n        }\n    }"
}