Removed lingering references to stale terminology ("active pools")

This commit is contained in:
Greg Hysen 2019-10-22 06:28:15 -07:00
parent 6617ad9531
commit ce8fd44234
9 changed files with 30 additions and 33 deletions

View File

@ -86,7 +86,7 @@ contract MixinExchangeFees is
IStructs.PoolStats memory poolStats = poolStatsByEpoch[poolId][currentEpoch_]; IStructs.PoolStats memory poolStats = poolStatsByEpoch[poolId][currentEpoch_];
IStructs.AggregatedStats memory aggregatedStats = aggregatedStatsByEpoch[currentEpoch_]; IStructs.AggregatedStats memory aggregatedStats = aggregatedStatsByEpoch[currentEpoch_];
// If the pool was previously inactive in this epoch, initialize it. // Perform some initialization if this is the first protocol fee collected in this epoch.
if (poolStats.feesCollected == 0) { if (poolStats.feesCollected == 0) {
// Compute member and total weighted stake. // Compute member and total weighted stake.
(poolStats.membersStake, poolStats.weightedStake) = _computeMembersAndWeightedStake(poolId, poolStake); (poolStats.membersStake, poolStats.weightedStake) = _computeMembersAndWeightedStake(poolId, poolStake);
@ -94,7 +94,7 @@ contract MixinExchangeFees is
// Increase the total weighted stake. // Increase the total weighted stake.
aggregatedStats.totalWeightedStake = aggregatedStats.totalWeightedStake.safeAdd(poolStats.weightedStake); aggregatedStats.totalWeightedStake = aggregatedStats.totalWeightedStake.safeAdd(poolStats.weightedStake);
// Increase the number of active pools. // Increase the number of pools to finalize.
aggregatedStats.poolsToFinalize = aggregatedStats.poolsToFinalize.safeAdd(1); aggregatedStats.poolsToFinalize = aggregatedStats.poolsToFinalize.safeAdd(1);
// Emit an event so keepers know what pools earned rewards this epoch. // Emit an event so keepers know what pools earned rewards this epoch.
@ -112,7 +112,7 @@ contract MixinExchangeFees is
aggregatedStatsByEpoch[currentEpoch_] = aggregatedStats; aggregatedStatsByEpoch[currentEpoch_] = aggregatedStats;
} }
/// @dev Get information on an active staking pool in this epoch. /// @dev Get stats on a staking pool in this epoch.
/// @param poolId Pool Id to query. /// @param poolId Pool Id to query.
/// @return PoolStats struct for pool id. /// @return PoolStats struct for pool id.
function getStakingPoolStatsThisEpoch(bytes32 poolId) function getStakingPoolStatsThisEpoch(bytes32 poolId)

View File

@ -43,7 +43,7 @@ interface IStakingEvents {
address exchangeAddress address exchangeAddress
); );
/// @dev Emitted by MixinExchangeFees when a pool will earn rewards. /// @dev Emitted by MixinExchangeFees when a pool starts earning rewards in an epoch.
/// @param epoch The epoch in which the pool earned rewards. /// @param epoch The epoch in which the pool earned rewards.
/// @param poolId The ID of the pool. /// @param poolId The ID of the pool.
event StakingPoolEarnedRewardsInEpoch( event StakingPoolEarnedRewardsInEpoch(
@ -53,10 +53,10 @@ interface IStakingEvents {
/// @dev Emitted by MixinFinalizer when an epoch has ended. /// @dev Emitted by MixinFinalizer when an epoch has ended.
/// @param epoch The closing epoch. /// @param epoch The closing epoch.
/// @param poolsToFinalize Number of pools to finalize in the closing epoch. /// @param poolsToFinalize Number of pools that earned rewards during `epoch` and must be finalized.
/// @param rewardsAvailable Rewards available to all active pools. /// @param rewardsAvailable Rewards available to all pools that earned rewards during `epoch`.
/// @param totalWeightedStake Total weighted stake across all active pools. /// @param totalWeightedStake Total weighted stake across all pools that earned rewards during `epoch`.
/// @param totalFeesCollected Total fees collected across all active pools. /// @param totalFeesCollected Total fees collected across all pools that earned rewards during `epoch`.
event EpochEnded( event EpochEnded(
uint256 indexed epoch, uint256 indexed epoch,
uint256 poolsToFinalize, uint256 poolsToFinalize,

View File

@ -29,7 +29,7 @@ interface IStructs {
uint96 lastSetTimestamp; uint96 lastSetTimestamp;
} }
/// @dev Stats for a pool that actively traded. /// @dev Stats for a pool that earned rewards.
/// @param feesCollected Fees collected in ETH by this pool. /// @param feesCollected Fees collected in ETH by this pool.
/// @param weightedStake Amount of weighted stake in the pool. /// @param weightedStake Amount of weighted stake in the pool.
/// @param membersStake Amount of non-operator stake in the pool. /// @param membersStake Amount of non-operator stake in the pool.

View File

@ -33,11 +33,9 @@ library LibCobbDouglas {
/// 0 <= alphaNumerator / alphaDenominator <= 1 /// 0 <= alphaNumerator / alphaDenominator <= 1
/// @param totalRewards collected over an epoch. /// @param totalRewards collected over an epoch.
/// @param fees Fees attributed to the the staking pool. /// @param fees Fees attributed to the the staking pool.
/// @param totalFees Total fees collected across all active staking pools in /// @param totalFees Total fees collected across all pools that earned rewards.
/// the epoch.
/// @param stake Stake attributed to the staking pool. /// @param stake Stake attributed to the staking pool.
/// @param totalStake Total stake across all active staking pools in the /// @param totalStake Total stake across all pools that earned rewards.
/// epoch.
/// @param alphaNumerator Numerator of `alpha` in the cobb-douglas function. /// @param alphaNumerator Numerator of `alpha` in the cobb-douglas function.
/// @param alphaDenominator Denominator of `alpha` in the cobb-douglas /// @param alphaDenominator Denominator of `alpha` in the cobb-douglas
/// function. /// function.

View File

@ -72,7 +72,7 @@ contract MixinStakeBalances is
/// @dev Returns the total stake for a given staker. /// @dev Returns the total stake for a given staker.
/// @param staker of stake. /// @param staker of stake.
/// @return Total active stake for staker. /// @return Total ZRX staked by `staker`.
function getTotalStake(address staker) function getTotalStake(address staker)
public public
view view

View File

@ -35,9 +35,9 @@ contract MixinFinalizer is
/// @dev Begins a new epoch, preparing the prior one for finalization. /// @dev Begins a new epoch, preparing the prior one for finalization.
/// Throws if not enough time has passed between epochs or if the /// Throws if not enough time has passed between epochs or if the
/// previous epoch was not fully finalized. /// previous epoch was not fully finalized.
/// If there were no active pools in the closing epoch, the epoch /// If no pools earned rewards in the closing epoch, the epoch
/// will be instantly finalized here. Otherwise, `finalizePool()` /// will be instantly finalized here. Otherwise, `finalizePool()`
/// should be called on each active pool afterwards. /// should be called on these pools afterward calling this function.
/// @return poolsToFinalize The number of unfinalized pools. /// @return poolsToFinalize The number of unfinalized pools.
function endEpoch() function endEpoch()
external external
@ -80,7 +80,7 @@ contract MixinFinalizer is
// Advance the epoch. This will revert if not enough time has passed. // Advance the epoch. This will revert if not enough time has passed.
_goToNextEpoch(); _goToNextEpoch();
// If there were no active pools, the epoch is already finalized. // If there are no pools to finalize then the epoch is finalized.
if (aggregatedStats.poolsToFinalize == 0) { if (aggregatedStats.poolsToFinalize == 0) {
emit EpochFinalized(closingEpoch, 0, aggregatedStats.rewardsAvailable); emit EpochFinalized(closingEpoch, 0, aggregatedStats.rewardsAvailable);
} }
@ -88,11 +88,11 @@ contract MixinFinalizer is
return aggregatedStats.poolsToFinalize; return aggregatedStats.poolsToFinalize;
} }
/// @dev Instantly finalizes a single pool that was active in the previous /// @dev Instantly finalizes a single pool that earned rewards in the previous
/// epoch, crediting it rewards for members and withdrawing operator's /// epoch, crediting it rewards for members and withdrawing operator's
/// rewards as WETH. This can be called by internal functions that need /// rewards as WETH. This can be called by internal functions that need
/// to finalize a pool immediately. Does nothing if the pool is already /// to finalize a pool immediately. Does nothing if the pool is already
/// finalized or was not active in the previous epoch. /// finalized or did not earn rewards in the previous epoch.
/// @param poolId The pool ID to finalize. /// @param poolId The pool ID to finalize.
function finalizePool(bytes32 poolId) function finalizePool(bytes32 poolId)
external external
@ -107,7 +107,7 @@ contract MixinFinalizer is
return; return;
} }
// Noop if the pool was not active or already finalized (has no fees). // Noop if the pool did not earn rewards or already finalized (has no fees).
IStructs.PoolStats memory poolStats = poolStatsByEpoch[poolId][prevEpoch]; IStructs.PoolStats memory poolStats = poolStatsByEpoch[poolId][prevEpoch];
if (poolStats.feesCollected == 0) { if (poolStats.feesCollected == 0) {
return; return;
@ -235,8 +235,7 @@ contract MixinFinalizer is
view view
returns (uint256 rewards) returns (uint256 rewards)
{ {
// There can't be any rewards if the pool was active or if it has // There can't be any rewards if the pool did not collect any fees.
// no stake.
if (poolStats.feesCollected == 0) { if (poolStats.feesCollected == 0) {
return rewards; return rewards;
} }

View File

@ -94,7 +94,7 @@ contract TestDelegatorRewards is
currentEpoch += 1; currentEpoch += 1;
} }
/// @dev Create and delegate stake that is active in the current epoch. /// @dev Create and delegate stake to the current epoch.
/// Only used to test purportedly unreachable states. /// Only used to test purportedly unreachable states.
/// Also withdraws pending rewards. /// Also withdraws pending rewards.
function delegateStakeNow( function delegateStakeNow(

View File

@ -281,7 +281,7 @@ blockchainTests.resets('Finalizer unit tests', env => {
}); });
}); });
it('immediately finalizes if there are no active pools', async () => { it('immediately finalizes if there are no pools to finalize', async () => {
const receipt = await testContract.endEpoch.awaitTransactionSuccessAsync(); const receipt = await testContract.endEpoch.awaitTransactionSuccessAsync();
assertEpochFinalizedEvent(receipt.logs, { assertEpochFinalizedEvent(receipt.logs, {
epoch: stakingConstants.INITIAL_EPOCH, epoch: stakingConstants.INITIAL_EPOCH,
@ -290,7 +290,7 @@ blockchainTests.resets('Finalizer unit tests', env => {
}); });
}); });
it('does not immediately finalize if there is an active pool', async () => { it('does not immediately finalize if there is a pool to finalize', async () => {
await addActivePoolAsync(); await addActivePoolAsync();
const receipt = await testContract.endEpoch.awaitTransactionSuccessAsync(); const receipt = await testContract.endEpoch.awaitTransactionSuccessAsync();
const events = filterLogsToArguments<IStakingEventsEpochFinalizedEventArgs>( const events = filterLogsToArguments<IStakingEventsEpochFinalizedEventArgs>(
@ -355,7 +355,7 @@ blockchainTests.resets('Finalizer unit tests', env => {
}); });
describe('_finalizePool()', () => { describe('_finalizePool()', () => {
it('does nothing if there were no active pools', async () => { it('does nothing if there were no pools to finalize', async () => {
await testContract.endEpoch.awaitTransactionSuccessAsync(); await testContract.endEpoch.awaitTransactionSuccessAsync();
const poolId = hexRandom(); const poolId = hexRandom();
const logs = await finalizePoolsAsync([poolId]); const logs = await finalizePoolsAsync([poolId]);
@ -445,7 +445,7 @@ blockchainTests.resets('Finalizer unit tests', env => {
return expect(getCurrentEpochAsync()).to.become(stakingConstants.INITIAL_EPOCH.plus(2)); return expect(getCurrentEpochAsync()).to.become(stakingConstants.INITIAL_EPOCH.plus(2));
}); });
it('does not reward a pool that was only active 2 epochs ago', async () => { it('does not reward a pool that only earned rewards 2 epochs ago', async () => {
const pool1 = await addActivePoolAsync(); const pool1 = await addActivePoolAsync();
await testContract.endEpoch.awaitTransactionSuccessAsync(); await testContract.endEpoch.awaitTransactionSuccessAsync();
await finalizePoolsAsync([pool1.poolId]); await finalizePoolsAsync([pool1.poolId]);
@ -457,7 +457,7 @@ blockchainTests.resets('Finalizer unit tests', env => {
expect(rewardsPaidEvents).to.deep.eq([]); expect(rewardsPaidEvents).to.deep.eq([]);
}); });
it('does not reward a pool that was only active 3 epochs ago', async () => { it('does not reward a pool that only earned rewards 3 epochs ago', async () => {
const pool1 = await addActivePoolAsync(); const pool1 = await addActivePoolAsync();
await testContract.endEpoch.awaitTransactionSuccessAsync(); await testContract.endEpoch.awaitTransactionSuccessAsync();
await finalizePoolsAsync([pool1.poolId]); await finalizePoolsAsync([pool1.poolId]);
@ -512,18 +512,18 @@ blockchainTests.resets('Finalizer unit tests', env => {
return assertUnfinalizedPoolRewardsAsync(poolId, ZERO_REWARDS); return assertUnfinalizedPoolRewardsAsync(poolId, ZERO_REWARDS);
}); });
it('returns empty if pool was not active', async () => { it('returns empty if pool did not earn rewards', async () => {
await testContract.endEpoch.awaitTransactionSuccessAsync(); await testContract.endEpoch.awaitTransactionSuccessAsync();
const poolId = hexRandom(); const poolId = hexRandom();
return assertUnfinalizedPoolRewardsAsync(poolId, ZERO_REWARDS); return assertUnfinalizedPoolRewardsAsync(poolId, ZERO_REWARDS);
}); });
it('returns empty if pool is active only in the current epoch', async () => { it('returns empty if pool is earned rewards only in the current epoch', async () => {
const pool = await addActivePoolAsync(); const pool = await addActivePoolAsync();
return assertUnfinalizedPoolRewardsAsync(pool.poolId, ZERO_REWARDS); return assertUnfinalizedPoolRewardsAsync(pool.poolId, ZERO_REWARDS);
}); });
it('returns empty if pool was only active in the 2 epochs ago', async () => { it('returns empty if pool only earned rewards in the 2 epochs ago', async () => {
const pool = await addActivePoolAsync(); const pool = await addActivePoolAsync();
await testContract.endEpoch.awaitTransactionSuccessAsync(); await testContract.endEpoch.awaitTransactionSuccessAsync();
await finalizePoolsAsync([pool.poolId]); await finalizePoolsAsync([pool.poolId]);

View File

@ -413,7 +413,7 @@ blockchainTests('Protocol Fees unit tests', env => {
.plus(operatorStake); .plus(operatorStake);
} }
it('no active pools to start', async () => { it('no pools to finalize to start', async () => {
const state = await getFinalizationStateAsync(); const state = await getFinalizationStateAsync();
expect(state.poolsToFinalize).to.bignumber.eq(0); expect(state.poolsToFinalize).to.bignumber.eq(0);
expect(state.totalFeesCollected).to.bignumber.eq(0); expect(state.totalFeesCollected).to.bignumber.eq(0);
@ -428,7 +428,7 @@ blockchainTests('Protocol Fees unit tests', env => {
expect(pool.weightedStake).to.bignumber.eq(0); expect(pool.weightedStake).to.bignumber.eq(0);
}); });
it('activates a active pool the first time it earns a fee', async () => { it('correctly emits event for pool the first time it earns a fee', async () => {
const pool = await createTestPoolAsync(); const pool = await createTestPoolAsync();
const { const {
poolId, poolId,