Skip to content

Commit

Permalink
⚡ Adjust invariant error tolerance.
Browse files Browse the repository at this point in the history
  • Loading branch information
clement-ux committed Dec 16, 2024
1 parent 74879bb commit a5e11f5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions test/invariants/TargetFunction.sol
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ abstract contract TargetFunction is Properties {

// Prank Owner
vm.prank(lidoARM.owner());
lidoARM.claimLidoWithdrawals(requestToClaim);
lidoARM.claimLidoWithdrawals(requestToClaim, new uint256[](0));

uint256 outstandingAfter = lidoARM.lidoWithdrawalQueueAmount();
uint256 diff = outstandingBefore - outstandingAfter;
Expand Down Expand Up @@ -308,10 +308,11 @@ abstract contract TargetFunction is Properties {
/// --- DONATION
////////////////////////////////////////////////////
uint256 constant DONATION_PROBABILITY = 10;
uint256 constant DONATION_THRESHOLD = 1e20;

function handler_donate(bool stETH, uint64 amount, uint256 probability) public {
// Reduce probability to 10%
vm.assume(probability % DONATION_PROBABILITY == 0);
vm.assume(probability % DONATION_PROBABILITY == 0 && lidoARM.totalSupply() > DONATION_THRESHOLD);

IERC20 token = stETH ? IERC20(address(steth)) : IERC20(address(weth));

Expand All @@ -326,12 +327,14 @@ abstract contract TargetFunction is Properties {
////////////////////////////////////////////////////
/// --- HELPERS
////////////////////////////////////////////////////
uint256 constant SHARES_UP_ONLY__ERROR_TOLERANCE = 1e4;

function finalizeLidoClaims() public {
if (lidoWithdrawRequests.length == 0) return;

// Prank Owner
vm.prank(lidoARM.owner());
lidoARM.claimLidoWithdrawals(lidoWithdrawRequests);
lidoARM.claimLidoWithdrawals(lidoWithdrawRequests, new uint256[](0));

require(lidoARM.lidoWithdrawalQueueAmount() == 0, "FINALIZE_FAILED");
}
Expand Down Expand Up @@ -373,7 +376,7 @@ abstract contract TargetFunction is Properties {
address user = lps[i];
uint256 shares = lidoARM.balanceOf(user);
uint256 sum = weth.balanceOf(user) + lidoARM.previewRedeem(shares);
if (!gte(sum * (1e18 + 1e6) / 1e18, initialBalance)) {
if (!gte(sum * (1e18 + SHARES_UP_ONLY__ERROR_TOLERANCE) / 1e18, initialBalance)) {
return false;
}
}
Expand Down

0 comments on commit a5e11f5

Please sign in to comment.