Skip to content

Commit 63a5a1e

Browse files
abarmatdavekay100
authored andcommitted
staking: rename allocatedStake to effectiveAllocatedStake
1 parent 6a138fd commit 63a5a1e

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

contracts/staking/libs/Rebates.sol

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ library Rebates {
1818
// Only one rebate pool exists per epoch
1919
struct Pool {
2020
uint256 fees; // total query fees in the rebate pool
21-
uint256 allocatedStake; // total effective allocation of stake
21+
uint256 effectiveAllocatedStake; // total effective allocation of stake
2222
uint256 claimedRewards; // total claimed rewards from the rebate pool
2323
uint32 unclaimedAllocationsCount; // amount of unclaimed allocations
2424
uint32 alphaNumerator; // numerator of `alpha` in the cobb-douglas function
@@ -43,7 +43,7 @@ library Rebates {
4343
* @dev Return true if the rebate pool was already initialized.
4444
*/
4545
function exists(Rebates.Pool storage pool) internal view returns (bool) {
46-
return pool.allocatedStake > 0;
46+
return pool.effectiveAllocatedStake > 0;
4747
}
4848

4949
/**
@@ -56,37 +56,39 @@ library Rebates {
5656
/**
5757
* @dev Deposit tokens into the rebate pool.
5858
* @param _indexerFees Amount of fees collected in tokens
59-
* @param _indexerAllocatedStake Effective stake allocated by indexer for a period of epochs
59+
* @param _indexerEffectiveAllocatedStake Effective stake allocated by indexer for a period of epochs
6060
*/
6161
function addToPool(
6262
Rebates.Pool storage pool,
6363
uint256 _indexerFees,
64-
uint256 _indexerAllocatedStake
64+
uint256 _indexerEffectiveAllocatedStake
6565
) internal {
6666
pool.fees = pool.fees.add(_indexerFees);
67-
pool.allocatedStake = pool.allocatedStake.add(_indexerAllocatedStake);
67+
pool.effectiveAllocatedStake = pool.effectiveAllocatedStake.add(
68+
_indexerEffectiveAllocatedStake
69+
);
6870
pool.unclaimedAllocationsCount += 1;
6971
}
7072

7173
/**
7274
* @dev Redeem tokens from the rebate pool.
7375
* @param _indexerFees Amount of fees collected in tokens
74-
* @param _indexerAllocatedStake Effective stake allocated by indexer for a period of epochs
76+
* @param _indexerEffectiveAllocatedStake Effective stake allocated by indexer for a period of epochs
7577
* @return Amount of reward tokens according to Cobb-Douglas rebate formula
7678
*/
7779
function redeem(
7880
Rebates.Pool storage pool,
7981
uint256 _indexerFees,
80-
uint256 _indexerAllocatedStake
82+
uint256 _indexerEffectiveAllocatedStake
8183
) internal returns (uint256) {
8284
// Calculate the rebate rewards for the indexer
8385
uint256 totalRewards = pool.fees;
8486
uint256 rebateReward = LibCobbDouglas.cobbDouglas(
8587
totalRewards,
8688
_indexerFees,
8789
pool.fees,
88-
_indexerAllocatedStake,
89-
pool.allocatedStake,
90+
_indexerEffectiveAllocatedStake,
91+
pool.effectiveAllocatedStake,
9092
pool.alphaNumerator,
9193
pool.alphaDenominator
9294
);

test/staking/allocation.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,8 @@ describe('Staking:Allocation', () => {
491491
expect(afterAlloc.effectiveAllocation).eq(effectiveAllocation)
492492
// Rebate updated
493493
expect(afterRebatePool.fees).eq(beforeRebatePool.fees.add(beforeAlloc.collectedFees))
494-
expect(afterRebatePool.allocatedStake).eq(
495-
beforeRebatePool.allocatedStake.add(effectiveAllocation),
494+
expect(afterRebatePool.effectiveAllocatedStake).eq(
495+
beforeRebatePool.effectiveAllocatedStake.add(effectiveAllocation),
496496
)
497497
expect(afterRebatePool.unclaimedAllocationsCount).eq(
498498
beforeRebatePool.unclaimedAllocationsCount + 1,
@@ -605,11 +605,11 @@ describe('Staking:Allocation', () => {
605605
)
606606
if (afterRebatePool.unclaimedAllocationsCount === 0) {
607607
// Rebate pool is empty and then pruned
608-
expect(afterRebatePool.allocatedStake).eq(toGRT('0'))
608+
expect(afterRebatePool.effectiveAllocatedStake).eq(toGRT('0'))
609609
expect(afterRebatePool.fees).eq(toGRT('0'))
610610
} else {
611611
// There are still more unclaimed allocations in the rebate pool
612-
expect(afterRebatePool.allocatedStake).eq(beforeRebatePool.allocatedStake)
612+
expect(afterRebatePool.effectiveAllocatedStake).eq(beforeRebatePool.effectiveAllocatedStake)
613613
expect(afterRebatePool.fees).eq(beforeRebatePool.fees.sub(tokensToClaim))
614614
}
615615
}

0 commit comments

Comments
 (0)