DeFiFoundry
20,000 USDC
View results
Submission Details
Severity: low
Invalid

It' more convenience for admin can set the lastDistribution in FjordPoints contract.

Summary

The ability to set the lastDistribution combined with the function setStakingContract in the FjordPoints contract supply more convenience for the admin.

Vulnerability Details

The default value of lastDistribution is the deployed time when deployed the FjordPoints contract . It seems the startTime in the FjordStaking contract and the lastDistribution value in the FjordPoints contract are same when checking the deploy scripts.

So when users do operations(stake or unstake) , meanwhile the FjordPoints can record the users's rewards points in the corresponding's epoch.

It's more convenient to make the admin can set the lastDistribution instead of using the deployed time. For example, if the admin wants to start the points rewards campaign at a specific time or depending on their intention.

Another point is that the owner of FjordPoints can set stakingContract. If the owner sets the stakingContract, how do they sync their epochs for FjordPoints and stakingContract? The ability to set the lastDistribution would make it easier in this situation.

//FjordPoints contract
constructor() ERC20("BjordBoint", "BJB") {
owner = msg.sender;
lastDistribution = block.timestamp; // apply deployed time as lastDistribution
pointsPerEpoch = 100 ether;
}
function setStakingContract(address _staking) external onlyOwner {
if (_staking == address(0)) {
revert InvalidAddress();
}
staking = _staking;
}

Impact

Applying this change will give the admin the ability to set the beginning time of points rewards based on their intention.

Tools Used

Manual

Recommendations

Add param: startTime in the constructor of FjordPoints contract.

error InvalidStartTime();
/**
* @dev Sets the staking contract address and initializes the ERC20 token.
*/
constructor(uint256 startTime) ERC20("BjordBoint", "BJB") {
if (startTime <= block.timestamp) {
revert InvalidStartTime();
}
owner = msg.sender;
lastDistribution = startTime;
pointsPerEpoch = 100 ether;
}
Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.