Skip to content

Commit

Permalink
feat: update weekly block count to 49930
Browse files Browse the repository at this point in the history
Set weekly block count to 49930 as measured in February 2024

npx tsx scripts/task/task.ts BlocksInWeek --network=mainnet
...
Calculating number of blocks in the last week...
Recent average block time: 12 seconds
Estimated blocks in a week best case 50400
Produced 49930 blocks, 470 worst than the best case

Resolves: sherlock-audit/2023-12-ubiquity-judging#230
  • Loading branch information
gitcoindev committed Feb 2, 2024
1 parent 0e481f1 commit 56207cb
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/contracts/src/dollar/libraries/LibStaking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ library LibStaking {
// deposit new shares
LibChef.deposit(msg.sender, _sharesAmount, _id);
// calculate end locking period block number
// 1 week = 45361 blocks = 2371753*7/366
// n = (block + duration * 45361)
// 1 week = 49930 blocks
// n = (block number + duration * 49930)
stake.endBlock = block.number + _weeks * ss.blockCountInAWeek;

// should be done after masterchef withdraw
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ contract DiamondInit is Modifiers {
// staking
LibStaking.StakingData storage ls = LibStaking.stakingStorage();
ls.stakingDiscountMultiplier = uint256(0.001 ether); // 0.001
ls.blockCountInAWeek = 45361;
ls.blockCountInAWeek = 49930;

// reentrancy guard
_initReentrancyGuard();
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/test/diamond/facets/ChefFacet.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ contract DepositStateChefTest is DepositStateChef {

// advance the block number to staking time so the withdraw is possible
uint256 currentBlock = block.number;
blocks = bound(blocks, 45361, 2 ** 128 - 1);
blocks = bound(blocks, 49930, 2 ** 128 - 1);
assertEq(chefFacet.totalShares(), shares);

uint256 preBal = governanceToken.balanceOf(fourthAccount);
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/test/diamond/facets/StakingFacet.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ contract DepositStateTest is DepositStateStaking {

// advance the block number to staking time so the withdraw is possible
uint256 currentBlock = block.number;
blocks = bound(blocks, 45361, 2 ** 128 - 1);
blocks = bound(blocks, 49930, 2 ** 128 - 1);
assertEq(chefFacet.totalShares(), shares);

uint256 preBal = governanceToken.balanceOf(fourthAccount);
Expand Down

0 comments on commit 56207cb

Please sign in to comment.