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