In LinearDistributor.declareReward , distributed represents the reward to distribute and is calculated using netVest(currentlyVested - previouslyVested).
At the same time, distributed cannot exceed balance, which means that if balance < linearBondedValue * netVest / vestingBondedValue, part of the rewards in netVest will be lost.
uint256 netVest = currentlyVested - previouslyVested;
uint256 netTime = block.timestamp - previouslyVestedTimestamp;
if (netVest == 0 || vestingBondedValue == 0) {
return;
}
uint256 linearBondedValue = rewardMine.valueOfBonded();
uint256 distributed = (linearBondedValue * netVest) / vestingBondedValue;
uint256 balance = collateralToken.balanceOf(address(this));
if (distributed > balance) {
distributed = balance;
}
At the end of the function, previouslyVested is directly assigned to currentlyVested instead of using the Vested adjusted according to distributed, which means that the previously lost rewards will also be skipped in the next distribution.
previouslyVested = currentlyVested;
previouslyVestedTimestamp = block.timestamp;
Also, in the next distribution, bufferRequirement will be small because distributed is small, so it may increase the number of forfeits.
if (netTime < buf) {
bufferRequirement = (distributed * buf * 10000) / netTime / 10000;
} else {
bufferRequirement = distributed;
}
if (balance > bufferRequirement) {
// We have more than the buffer required. Forfeit the rest
uint256 net = balance - bufferRequirement;
_forfeit(net);
}
None
Consider adapting previouslyVested based on distributed
uint256 linearBondedValue = rewardMine.valueOfBonded();
uint256 distributed = (linearBondedValue * netVest) / vestingBondedValue;
uint256 balance = collateralToken.balanceOf(address(this));
if (distributed > balance) {
distributed = balance;
+ currentlyVested = distributed * vestingBondedValue / linearBondedValue + previouslyVested;
}
The text was updated successfully, but these errors were encountered:
All reactions