{
    "Function": "redeem",
    "File": "contracts/staking/libs/Rebates.sol",
    "Parent Contracts": [],
    "High-Level Calls": [
        "Rebates",
        "LibCobbDouglas",
        "SafeMath"
    ],
    "Internal Calls": [],
    "Library Calls": [
        "unclaimedFees",
        "add",
        "cobbDouglas"
    ],
    "Low-Level Calls": [],
    "Code": "function redeem(\n        Rebates.Pool storage pool,\n        uint256 _indexerFees,\n        uint256 _indexerEffectiveAllocatedStake\n    ) internal returns (uint256) {\n        uint256 rebateReward = 0;\n\n        // Calculate the rebate rewards for the indexer\n        if (pool.fees > 0 && pool.effectiveAllocatedStake > 0) {\n            rebateReward = LibCobbDouglas.cobbDouglas(\n                pool.fees, // totalRewards\n                _indexerFees,\n                pool.fees,\n                _indexerEffectiveAllocatedStake,\n                pool.effectiveAllocatedStake,\n                pool.alphaNumerator,\n                pool.alphaDenominator\n            );\n\n            // Under NO circumstance we will reward more than total fees in the pool\n            uint256 _unclaimedFees = pool.unclaimedFees();\n            if (rebateReward > _unclaimedFees) {\n                rebateReward = _unclaimedFees;\n            }\n        }\n\n        // Update pool state\n        pool.unclaimedAllocationsCount -= 1;\n        pool.claimedRewards = pool.claimedRewards.add(rebateReward);\n\n        return rebateReward;\n    }"
}