anvil_zksync_common/utils/
cost.rs

1use alloy::primitives::utils::format_ether;
2use alloy::primitives::utils::format_units;
3use zksync_types::U256;
4
5/// Formats a `U256` value as Ether without capping decimal points.
6pub fn format_eth(value: U256) -> String {
7    let value = alloy::primitives::U256::from_limbs(value.0);
8    let var_name = format!("{} ETH", format_ether(value));
9    var_name
10}
11/// Formats a `U256` value as Gwei without capping decimal points.
12pub fn format_gwei(value: U256) -> String {
13    let value = alloy::primitives::U256::from_limbs(value.0);
14    format!("{:.8} gwei", format_units(value, "gwei").unwrap())
15}