Summary
Boost calculation is done with the intent of using time weighted functions, however they are not used in the function definition.
This will lead to unexpected behavior when expecting time related details to affect Boost for users and the calculation for it
Vulnerability Details
function calculateTimeWeightedBoost(
BoostState storage state,
uint256 userBalance,
uint256 totalSupply,
uint256 amount
) internal view returns (uint256 boostBasisPoints, uint256 boostedAmount) {
if (totalSupply == 0 || amount == 0) {
return (0, amount);
}
BoostParameters memory params = BoostParameters({
maxBoost: state.maxBoost,
minBoost: state.minBoost,
boostWindow: state.boostWindow,
totalWeight: state.totalWeight,
totalVotingPower: state.totalVotingPower,
votingPower: state.votingPower
});
boostBasisPoints = calculateBoost(
userBalance,
totalSupply,
params
);
boostedAmount = (amount * boostBasisPoints) / 10000;
return (boostBasisPoints, boostedAmount);
}
function calculateTimeWeightedBoost(
BoostParameters memory params,
uint256 userBalance,
uint256 totalSupply,
uint256 amount
) internal pure returns (uint256 boostBasisPoints, uint256 boostedAmount) {
if (totalSupply == 0 || amount == 0) {
return (0, amount);
}
boostBasisPoints = calculateBoost(
userBalance,
totalSupply,
params
);
boostedAmount = (amount * boostBasisPoints) / 10000;
return (boostBasisPoints, boostedAmount);
}
We can see that it doesn't account for the time weight boost based on time but a regular calculation dependent on the Boost percentage
Impact
The time related effects won't affect the boost calculation and it will default on normal calculation instead of enforcing time related boosts or penalities.
Tools Used
manual analysis
Recommendations
Use time calculations like intervals with it