Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
3810ef3
feat: add vault hub test for vaults with bad validator
kovalgek Apr 11, 2025
01f456f
Merge branch 'feat/vaults-fuzzing' into feat/vault-hub-solvency-tests
kovalgek Apr 11, 2025
fae6072
Merge branch 'feat/vaults-fuzzing' into feat/vault-hub-solvency-tests
kovalgek Apr 13, 2025
a289d7e
feat: add merkle library for tests
kovalgek Apr 15, 2025
44ad3ad
feat: modify tests to align with last changes in hub and vault
kovalgek Apr 15, 2025
c9942b9
Merge branch 'feat/vaults-fuzzing' into feat/vault-hub-solvency-tests
kovalgek Apr 21, 2025
ac50d25
fix: fix accounting tests
kovalgek Apr 22, 2025
5b28369
fix: fix test according to new changes in vault logic and naming
kovalgek Apr 22, 2025
7e571bf
fix: add comments, generate randomly some factos, fix according to ne…
kovalgek Apr 22, 2025
123921f
fix: refactoring, process bad dept state
kovalgek Apr 25, 2025
9e7f14a
fix: uncomment tests, remove logs
kovalgek Apr 25, 2025
953a4ce
Merge branch 'feat/vaults-fuzzing' into feat/vault-hub-solvency-tests
kovalgek May 27, 2025
cd57b51
Merge branch 'feat/vaults-fuzzing' into feat/vault-hub-solvency-tests
kovalgek May 28, 2025
50e9aeb
fix: adapt solvency tests for new changes in vault hub, remove solven…
kovalgek May 29, 2025
302bb46
fix: remove murky submodule
kovalgek May 29, 2025
33c144e
fix: apply review feedback. Add additional transitiosns and adjust ch…
kovalgek May 30, 2025
ed85f7e
Merge branch 'feat/vaults-fuzzing' into feat/vault-hub-solvency-tests
kovalgek Jun 14, 2025
a46821a
fix: add hash consensus mock, fix mint
kovalgek Jun 16, 2025
94d7be8
fix: fix protocol deployment for fuzzing tests
kovalgek Jun 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions test/0.8.25/Accounting.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,7 @@ contract AccountingHandler is CommonBase, StdCheats, StdUtils {
withdrawalVaultBalance: 0,
sharesRequestedToBurn: 0,
withdrawalFinalizationBatches: new uint256[](0),
vaultValues: new uint256[](0),
inOutDeltas: new int256[](0)
vaultsTotalDeficit: 0
});

ghost.unifiedClBalanceWei = int256(fuzz._clBalanceWei + currentReport.withdrawalVaultBalance); // ?
Expand Down
16 changes: 12 additions & 4 deletions test/0.8.25/Protocol__Deployment.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import {LidoLocator} from "contracts/0.8.9/LidoLocator.sol";
import {LimitsList} from "contracts/0.8.9/sanity_checks/OracleReportSanityChecker.sol";

import {StakingRouter__MockForLidoAccountingFuzzing} from "./contracts/StakingRouter__MockForLidoAccountingFuzzing.sol";
import {SecondOpinionOracle__MockForAccountingFuzzing} from "./contracts/SecondOpinionOracle__MockForAccountingFuzzing.sol";
import {
SecondOpinionOracle__MockForAccountingFuzzing
} from "./contracts/SecondOpinionOracle__MockForAccountingFuzzing.sol";
import {WithdrawalQueue, IWstETH} from "../../contracts/0.8.9/WithdrawalQueue.sol";
import {WithdrawalQueueERC721} from "../../contracts/0.8.9/WithdrawalQueueERC721.sol";

Expand Down Expand Up @@ -265,7 +267,7 @@ contract BaseProtocolTest is Test {
// Deploy AccountingOracle
deployCodeTo(
"AccountingOracle.sol:AccountingOracle",
abi.encode(address(lidoLocator), lidoLocator.legacyOracle(), 12, genesisTimestamp),
abi.encode(address(lidoLocator), 12, genesisTimestamp),
lidoLocator.accountingOracle()
);

Expand Down Expand Up @@ -296,6 +298,8 @@ contract BaseProtocolTest is Test {
"OracleReportSanityChecker.sol:OracleReportSanityChecker",
abi.encode(
address(lidoLocator),
lidoLocator.accountingOracle(),
lidoLocator.accounting(),
rootAccount,
[
limitList.exitedValidatorsPerDayLimit,
Expand Down Expand Up @@ -394,7 +398,6 @@ contract BaseProtocolTest is Test {
accountingOracle: makeAddr("dummy-locator:accountingOracle"),
depositSecurityModule: makeAddr("dummy-locator:depositSecurityModule"),
elRewardsVault: makeAddr("dummy-locator:elRewardsVault"),
legacyOracle: makeAddr("dummy-locator:legacyOracle"),
lido: lido,
oracleReportSanityChecker: makeAddr("dummy-locator:oracleReportSanityChecker"),
postTokenRebaseReceiver: address(0),
Expand All @@ -408,7 +411,12 @@ contract BaseProtocolTest is Test {
accounting: makeAddr("dummy-locator:accounting"),
predepositGuarantee: makeAddr("dummy-locator:predeposit_guarantee"),
wstETH: wstETHAdr,
vaultHub: makeAddr("dummy-locator:vaultHub")
vaultHub: makeAddr("dummy-locator:vaultHub"),
lazyOracle: makeAddr("dummy-locator:lazyOracle"),
operatorGrid: makeAddr("dummy-locator:operatorGrid"),
validatorExitDelayVerifier: makeAddr("dummy-locator:validatorExitDelayVerifier"),
triggerableWithdrawalsGateway: makeAddr("dummy-locator:triggerableWithdrawalsGateway"),
vaultFactory: makeAddr("dummy-locator:vaultFactory")
});

return LidoLocator(deployCode("LidoLocator.sol:LidoLocator", abi.encode(config)));
Expand Down
51 changes: 51 additions & 0 deletions test/0.8.25/vaults/staking-vault/RewardSimulator.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

import {RandomLib} from "./RandomLib.sol";

contract RewardSimulator {
using RandomLib for RandomLib.Storage;

uint256 constant SECONDS_PER_DAY = 86400;
uint256 constant APR_DENOMINATOR = 10000;
uint256 constant DAYS_PER_YEAR = 365;

uint256 internal immutable APR_MIN;
uint256 internal immutable APR_MAX;
uint256 internal immutable MIN_VALIDATOR_BALANCE;

uint256 private currentAPR;
uint256 private lastRewardTimestamp;
RandomLib.Storage private rnd;

constructor(uint256 _seed, uint256 _aprMin, uint256 _aprMax, uint256 _minValidatorBalance) {
rnd.seed = _seed;
lastRewardTimestamp = block.timestamp;
APR_MIN = _aprMin;
APR_MAX = _aprMax;
MIN_VALIDATOR_BALANCE = _minValidatorBalance;
currentAPR = APR_MIN + rnd.randInt(APR_MAX - APR_MIN);
}

function getDailyReward() public returns (uint256) {
uint256 timePassed = block.timestamp - lastRewardTimestamp;
if (timePassed < SECONDS_PER_DAY) {
return 0;
}

uint256 daysPassed = timePassed / SECONDS_PER_DAY;
lastRewardTimestamp += daysPassed * SECONDS_PER_DAY;

uint256 yearlyReward = (MIN_VALIDATOR_BALANCE * currentAPR) / APR_DENOMINATOR;
uint256 dailyReward = (yearlyReward * daysPassed) / DAYS_PER_YEAR;

int256 randomVariation = int256(rnd.randInt(200)) - 100;
dailyReward = uint256((int256(dailyReward) * (1000 + randomVariation)) / 1000);

if (rnd.randBool()) {
currentAPR = APR_MIN + rnd.randInt(APR_MAX - APR_MIN);
}

return dailyReward;
}
}
Loading
Loading