Skip to main content

Module network

Module network 

Source
Expand description

Network timekeeping for multi-chain quoting.

eth-prices splits network state into two complementary types:

Because a single route can hop across different chains (e.g. swap on Ethereum, bridge to Arbitrum, swap again), the Quoter::rate method always receives a NetworkInstant so each step can look up the correct provider and block height.

§Construction

There are two entry points:

1. From a single network — use NetworkTime::instant():

use eth_prices::network::NetworkTime;
use alloy::primitives::BlockNumber;

let network = NetworkTime::EVM(1, BlockNumber::from(20_000_000), provider).instant();

2. From scratch using the builder pattern — chain multiple NetworkInstant builder methods together:

use eth_prices::network::NetworkInstant;

let networks = NetworkInstant::default()
    .with_fiat_timestamp(1_700_000_000)
    .with_evm_block(1, 20_000_000, eth_provider)
    .with_evm_block(42161, 200_000_000, arb_provider);

The async builders with_evm_latest and with_evm_provider fetch the latest block height from the RPC before inserting:

let networks = NetworkInstant::default()
    .with_evm_latest(1, eth_provider)
    .await?
    .with_fiat_timestamp(now);

Re-exports§

pub use instant::NetworkInstant;
pub use time::NetworkTime;

Modules§

instant
time

Structs§

NetworkId

Enums§

Network