Skip to content

Commit

Permalink
fix(generate): support whitelist nstETH + !ETH
Browse files Browse the repository at this point in the history
In the event that the Bootstrap contract has whitelisted `nstETH` but
not `ETH`, the `nstETH` entry will only fetch the effective balance and
the token price from the `ETH` entry will be missing. This commit fixes
that by manually adding an `ETH` entry to the oracle state in such an
event.
  • Loading branch information
MaxMustermann2 committed Nov 22, 2024
1 parent e8fdc53 commit 6a270bf
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion script/generate.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const nativeAsset = {
"staking_total_amount": "0"
};
const EXOCORE_BECH32_PREFIX = 'exo';
const VIRTUAL_STAKED_ETH_ADDR = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
const VIRTUAL_STAKED_ETH_ADDR = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
const GWEI_TO_WEI = new Decimal(1e9);

import dotenv from 'dotenv';
Expand Down Expand Up @@ -302,12 +302,35 @@ async function updateGenesisFile() {
// break;
}
// bind nstETH asset_id to the ETH token, if nstETH is found.
let found = false;
genesisJSON.app_state.oracle.params.tokens = oracleTokens.map((token) => {
if (token.name == hasNst.remainder) {
found = true;
token.asset_id += "," + hasNst.asset_id;
}
return token;
});
if (!found && hasNst.status) {
// add `ETH` manually, if `nstETH` exists but not `ETH` in the oracle tokens.
// the former in `tokens` is to get the validator effective balance from beacon, denominated in ETH.
// the latter in `tokens` is to get the price of ETH in USD.
genesisJSON.app_state.oracle.params.tokens.push({
name: hasNst.remainder,
chain_id: 1,
contract_address: VIRTUAL_STAKED_ETH_ADDR,
active: true,
asset_id: hasNst.asset_id,
decimal: 8,
});
genesisJSON.app_state.oracle.params.token_feeders.push({
token_id: (Number(supportedTokensCount) + 1).toString(),
rule_id: "1",
start_round_id: "1",
start_base_block: (height + 20).toString(),
interval: "30",
end_block: "0",
});
}
genesisJSON.app_state.oracle.params.token_feeders = oracleTokenFeeders;
supportedTokens.sort((a, b) => {
if (a.asset_basic_info.symbol < b.asset_basic_info.symbol) {
Expand Down

0 comments on commit 6a270bf

Please sign in to comment.