Initialize currentEpoch at 1 instead of 0
This commit is contained in:
parent
7b7c64fc6a
commit
1a409c3731
@ -232,19 +232,13 @@ contract MixinStakingPoolRewards is
|
||||
view
|
||||
returns (uint256 reward)
|
||||
{
|
||||
// There can be no rewards in epoch 0 because there is no delegated
|
||||
// stake.
|
||||
uint256 _currentEpoch = currentEpoch;
|
||||
if (_currentEpoch == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint256 currentEpoch_ = currentEpoch;
|
||||
IStructs.StoredBalance memory delegatedStake = _delegatedStakeToPoolByOwner[member][poolId];
|
||||
|
||||
// There can be no rewards if the last epoch when stake was stored is
|
||||
// equal to the current epoch, because all prior rewards, including
|
||||
// rewards finalized this epoch have been claimed.
|
||||
if (delegatedStake.currentEpoch == _currentEpoch) {
|
||||
if (delegatedStake.currentEpoch == currentEpoch_) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -253,7 +247,7 @@ contract MixinStakingPoolRewards is
|
||||
// 1/3 Unfinalized rewards earned in `currentEpoch - 1`.
|
||||
reward = _computeUnfinalizedDelegatorReward(
|
||||
delegatedStake,
|
||||
_currentEpoch,
|
||||
currentEpoch_,
|
||||
unfinalizedMembersReward,
|
||||
unfinalizedMembersStake
|
||||
);
|
||||
@ -275,7 +269,7 @@ contract MixinStakingPoolRewards is
|
||||
poolId,
|
||||
delegatedStake.nextEpochBalance,
|
||||
delegatedStakeNextEpoch,
|
||||
_currentEpoch
|
||||
currentEpoch_
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -99,12 +99,6 @@ contract MixinFinalizer is
|
||||
function finalizePool(bytes32 poolId)
|
||||
public
|
||||
{
|
||||
// Noop on epoch 0
|
||||
uint256 currentEpoch_ = currentEpoch;
|
||||
if (currentEpoch_ == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Load the finalization and pool state into memory.
|
||||
IStructs.UnfinalizedState memory state = unfinalizedState;
|
||||
|
||||
@ -113,6 +107,7 @@ contract MixinFinalizer is
|
||||
return;
|
||||
}
|
||||
|
||||
uint256 currentEpoch_ = currentEpoch;
|
||||
uint256 prevEpoch = currentEpoch_.safeSub(1);
|
||||
IStructs.ActivePool memory pool = _getActivePoolFromEpoch(prevEpoch, poolId);
|
||||
|
||||
@ -182,12 +177,10 @@ contract MixinFinalizer is
|
||||
uint256 membersStake
|
||||
)
|
||||
{
|
||||
uint256 epoch = currentEpoch;
|
||||
// There are no pools to finalize at epoch 0.
|
||||
if (epoch == 0) {
|
||||
return (0, 0);
|
||||
}
|
||||
IStructs.ActivePool memory pool = _getActivePoolFromEpoch(epoch - 1, poolId);
|
||||
IStructs.ActivePool memory pool = _getActivePoolFromEpoch(
|
||||
currentEpoch.safeSub(1),
|
||||
poolId
|
||||
);
|
||||
reward = _getUnfinalizedPoolRewardsFromState(pool, unfinalizedState);
|
||||
membersStake = pool.membersStake;
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ contract MixinScheduler is
|
||||
|
||||
// solhint-disable-next-line
|
||||
currentEpochStartTimeInSeconds = block.timestamp;
|
||||
currentEpoch = 1;
|
||||
}
|
||||
|
||||
/// @dev Moves to the next epoch, given the current epoch period has ended.
|
||||
|
Loading…
x
Reference in New Issue
Block a user