Skip to content

Commit 83338da

Browse files
committed
feat: manage edge case of a rebate with zero stake
1 parent aed7323 commit 83338da

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

contracts/staking/libs/Rebates.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import "./Cobbs.sol";
1414
*/
1515
library Rebates {
1616
using SafeMath for uint256;
17+
using Rebates for Rebates.Pool;
1718

1819
// Tracks stats for allocations closed on a particular epoch for claiming
1920
// The pool also keeps tracks of total query fees collected and stake used
@@ -86,7 +87,7 @@ library Rebates {
8687
uint256 rebateReward = 0;
8788

8889
// Calculate the rebate rewards for the indexer
89-
if (pool.fees > 0) {
90+
if (pool.fees > 0 && _indexerEffectiveAllocatedStake > 0) {
9091
rebateReward = LibCobbDouglas.cobbDouglas(
9192
pool.fees, // totalRewards
9293
_indexerFees,
@@ -98,7 +99,7 @@ library Rebates {
9899
);
99100

100101
// Under NO circumstance we will reward more than total fees in the pool
101-
uint256 _unclaimedFees = pool.fees.sub(pool.claimedRewards);
102+
uint256 _unclaimedFees = pool.unclaimedFees();
102103
if (rebateReward > _unclaimedFees) {
103104
rebateReward = _unclaimedFees;
104105
}

0 commit comments

Comments
 (0)