Skip to content

Commit

Permalink
fix: modify accounting to enable negative rebase checker
Browse files Browse the repository at this point in the history
  • Loading branch information
vp4242 committed Sep 19, 2024
1 parent 87a29e0 commit ecf9fd0
Showing 1 changed file with 57 additions and 13 deletions.
70 changes: 57 additions & 13 deletions lib/protocol/helpers/accounting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
impersonate,
log,
ONE_GWEI,
streccak,
trace,
} from "lib";

Expand Down Expand Up @@ -352,19 +353,62 @@ const simulateReport = async (
"El Rewards Vault Balance": formatEther(elRewardsVaultBalance),
});

const [postTotalPooledEther, postTotalShares, withdrawals, elRewards] = await lido
.connect(accountingOracleAccount)
.handleOracleReport.staticCall(
reportTimestamp,
1n * 24n * 60n * 60n, // 1 day
beaconValidators,
clBalance,
withdrawalVaultBalance,
elRewardsVaultBalance,
0n,
[],
0n,
);
// NOTE: To enable negative rebase sanity checker, the static call below should be
// replaced with advanced eth_call with stateDiff.

// const [postTotalPooledEther1, postTotalShares1, withdrawals1, elRewards1] = await lido
// .connect(accountingOracleAccount)
// .handleOracleReport.staticCall(
// reportTimestamp,
// 1n * 24n * 60n * 60n, // 1 day
// beaconValidators,
// clBalance,
// withdrawalVaultBalance,
// elRewardsVaultBalance,
// 0n,
// [],
// 0n,
// );

// Step 1: Encode the function call data
const data = lido.interface.encodeFunctionData("handleOracleReport", [
reportTimestamp,
BigInt(24 * 60 * 60), // 1 day in seconds
beaconValidators,
clBalance,
withdrawalVaultBalance,
elRewardsVaultBalance,
BigInt(0),
[],
BigInt(0),
]);

// Step 2: Prepare the transaction object
const transactionObject = {
to: lido.address,
from: accountingOracleAccount.address,
data: data,
};

// Step 3: Prepare call parameters, state diff and perform eth_call
const accountingOracleAddr = await accountingOracle.getAddress();
const callParams = [transactionObject, "latest"];
const LAST_PROCESSING_REF_SLOT_POSITION = streccak("lido.BaseOracle.lastProcessingRefSlot");
const stateDiff = {
[accountingOracleAddr]: {
stateDiff: {
[LAST_PROCESSING_REF_SLOT_POSITION]: refSlot, // setting the processing refslot for the sanity checker
},
},
};

const returnData = await ethers.provider.send("eth_call", [...callParams, stateDiff]);

// Step 4: Decode the returned data
const [[postTotalPooledEther, postTotalShares, withdrawals, elRewards]] = lido.interface.decodeFunctionResult(
"handleOracleReport",
returnData,
);

log.debug("Simulation result", {
"Post Total Pooled Ether": formatEther(postTotalPooledEther),
Expand Down

0 comments on commit ecf9fd0

Please sign in to comment.