Skip to content

Commit

Permalink
feat: try to get elRewards
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyWh1te committed Jan 23, 2025
1 parent 6ae1888 commit ea08979
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
30 changes: 23 additions & 7 deletions test/0.8.25/Accounting.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,24 @@ contract AccountingHandler is CommonBase, StdCheats, StdUtils {

uint256 public ghost_clValidators;
uint256 public ghost_depositedValidators;

address private accountingOracle;
address private lidoExecutionLayerRewardVault;
LimitsList public limitList;

constructor(address _accounting, address _lido, address _accountingOracle, LimitsList memory _limitList) {
constructor(
address _accounting,
address _lido,
address _accountingOracle,
LimitsList memory _limitList,
address _lidoExecutionLayerRewardVault
) {
accounting = IAccounting(_accounting);
lido = ILido(_lido);
accountingOracle = _accountingOracle;
ghost_clValidators = 0;
limitList = _limitList;
lidoExecutionLayerRewardVault = _lidoExecutionLayerRewardVault;
}

function handleOracleReport(
Expand Down Expand Up @@ -90,7 +99,7 @@ contract AccountingHandler is CommonBase, StdCheats, StdUtils {
_preClValidators,
_preClValidators + limitList.appearedValidatorsPerDayLimit
);
_clBalance = bound(_clBalance, _clValidators * stableBalance, _clValidators * stableBalance);
_clBalance = bound(_clBalance, _clValidators * stableBalance, _clValidators * stableBalance + 1_000);

// depositedValidators is always greater or equal to beaconValidators
// Todo: Upper extremum ?
Expand All @@ -105,13 +114,17 @@ contract AccountingHandler is CommonBase, StdCheats, StdUtils {
vm.store(address(lido), keccak256("lido.Lido.beaconValidators"), bytes32(_preClValidators));
vm.store(address(lido), keccak256("lido.Lido.beaconBalance"), bytes32(_preClBalance * 1 ether));

vm.deal(lidoExecutionLayerRewardVault, 1000 * 1 ether);
// IncorrectELRewardsVaultBalance(0)
// sharesToMintAsFees

ReportValues memory currentReport = ReportValues({
timestamp: _timestamp,
timeElapsed: _timeElapsed,
clValidators: _clValidators,
clBalance: _clBalance * 1 ether,
withdrawalVaultBalance: 0,
elRewardsVaultBalance: 0,
elRewardsVaultBalance: 1_000 * 1 ether,
sharesRequestedToBurn: 0,
withdrawalFinalizationBatches: new uint256[](0),
vaultValues: new uint256[](0),
Expand All @@ -138,7 +151,8 @@ contract AccountingTest is BaseProtocolTest {
lidoLocator.accounting(),
lidoLocator.lido(),
lidoLocator.accountingOracle(),
limitList
limitList,
lidoLocator.elRewardsVault()
);

// Set target contract to the accounting handler
Expand All @@ -156,20 +170,22 @@ contract AccountingTest is BaseProtocolTest {

//function invariant_fuzzTotalShares() public {
// - 0 OR 10% OF PROTOCOL FEES SHOULD BE REPORTED (Collect total fees from reports in handler)
// CLb + ELr <= 10%

// - user tokens must not be used except burner contract (from Zero / to Zero)
// - solvency - stETH <> ETH = 1:1 - internal and total share rates are equal
// - vault params do not affect protocol share rate
//}

/**
* https://book.getfoundry.sh/reference/config/inline-test-config#in-line-invariant-configs
* forge-config: default.invariant.runs = 256
* forge-config: default.invariant.depth = 256
* forge-config: default.invariant.runs = 1
* forge-config: default.invariant.depth = 1
* forge-config: default.invariant.fail-on-revert = true
*
* Should not be able to decrease validator number
*/
function invariant_clValidators() public {
function invariant_clValidators() public view {
ILido lido = ILido(lidoLocator.lido());
(uint256 depositedValidators, uint256 clValidators, uint256 clBalance) = lido.getBeaconStat();

Expand Down
10 changes: 10 additions & 0 deletions test/0.8.25/Protocol__Deployment.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ contract BaseProtocolTest is Test {

uint256 public genesisTimestamp = 1_695_902_400;
address private depositContract = address(0x4242424242424242424242424242424242424242);
address public lidoTreasury = makeAddr("dummy-lido:treasury");

LimitsList public limitList =
LimitsList({
Expand Down Expand Up @@ -164,6 +165,13 @@ contract BaseProtocolTest is Test {
lidoLocator.burner()
);

// Add burner contract to the protocol
deployCodeTo(
"LidoExecutionLayerRewardsVault.sol:LidoExecutionLayerRewardsVault",
abi.encode(rootAccount, lidoProxyAddress, lidoTreasury),
lidoLocator.elRewardsVault()
);

// Add staking router contract to the protocol
deployCodeTo("StakingRouter.sol:StakingRouter", abi.encode(depositContract), lidoLocator.stakingRouter());

Expand Down Expand Up @@ -199,6 +207,8 @@ contract BaseProtocolTest is Test {

IAccounting(lidoLocator.accounting()).initialize(rootAccount);

// contracts/0.8.9/LidoExecutionLayerRewardsVault.sol

/// @dev deploy eip712steth
address eip712steth = deployCode("EIP712StETH.sol:EIP712StETH", abi.encode(lidoProxyAddress));

Expand Down

0 comments on commit ea08979

Please sign in to comment.