Skip to content

Commit

Permalink
chore: add dust tolerance on invariants
Browse files Browse the repository at this point in the history
  • Loading branch information
jmendiola222 committed Nov 27, 2024
1 parent 0225738 commit 8d19959
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 2 additions & 0 deletions test/invariant/BaseInvariants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { DistributionHandler } from "./handlers/DistributionHandler.sol";
import { IncentivizeHandler } from "./handlers/IncentivizeHandler.sol";

contract BaseInvariants is BaseTest {
uint256 constant DUST = 10_000;

TimeManager public timeManager;
BuilderHandler public builderHandler;
AllocateHandler public allocateHandler;
Expand Down
15 changes: 7 additions & 8 deletions test/invariant/RewardInvariants.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,18 @@ contract RewardInvariants is BaseInvariants {
_totalGaugesBalances + _backersManagerBalance + _totalBuilderBalances + _totalBackersBalances
);

assertLe(_backersManagerBalance, 10_000);
assertLe(_backersManagerBalance, DUST);

for (uint256 i = 0; i < gaugesArray.length; i++) {
uint256 _gaugeBalance = rewardToken.balanceOf(address(gaugesArray[i]));
uint256 _gaugeAccountedBalance;
if (gaugesArray[i].totalAllocation() > 0) {
uint256 _gaugeBalance = rewardToken.balanceOf(address(gaugesArray[i]))
- gaugesArray[i].rewardMissing(address(rewardToken)) / 10 ** 18;
assertLe(_gaugeBalance, 10_000);
_gaugeAccountedBalance = gaugesArray[i].rewardMissing(address(rewardToken)) / 10 ** 18;
} else {
assertEq(
rewardToken.balanceOf(address(gaugesArray[i])),
incentivizeHandler.rewardTokenIncentives(gaugesArray[i])
);
_gaugeAccountedBalance = incentivizeHandler.rewardTokenIncentives(gaugesArray[i]);
}
// There might be dust from previous cycles
assertLe(_gaugeBalance - _gaugeAccountedBalance, DUST);
}
}
}

0 comments on commit 8d19959

Please sign in to comment.