diff --git a/src/lib/render/markdown.ts b/src/lib/render/markdown.ts index 4bc420a..3475bcd 100644 --- a/src/lib/render/markdown.ts +++ b/src/lib/render/markdown.ts @@ -51,6 +51,7 @@ export function generateMarkdownTable( let gasPrices: string[][]; let l1gwei: string | number | undefined; let l2gwei: string | number | undefined; + let l1GweiBlobBaseFee: string | number | undefined; const { network, currency, nonZeroMsg, intrinsicMsg } = getCommonTableVals(options); let tokenPrice = "-"; let rate: string; @@ -60,6 +61,7 @@ export function generateMarkdownTable( ({ l1gwei, l2gwei, + l1GweiBlobBaseFee, rate, token } = getCommonTableVals(options)); @@ -72,7 +74,7 @@ export function generateMarkdownTable( ] : [ [`L1 Base Fee`, `${options.baseFee!} gwei`], - [`L1 Blob Base Fee`, `${options.blobBaseFee!} gwei`], + [`L1 Blob Base Fee`, `${l1GweiBlobBaseFee!} gwei`], [`L2 Gas Price`, `${l2gwei} gwei` ] ] diff --git a/src/lib/render/terminal.ts b/src/lib/render/terminal.ts index 57522dd..24585d9 100644 --- a/src/lib/render/terminal.ts +++ b/src/lib/render/terminal.ts @@ -288,6 +288,7 @@ export function generateTerminalTextTable( l2gwei, l1gweiNote, l2gweiNote, + l1GweiBlobBaseFee, network, rate, currency, @@ -327,7 +328,7 @@ export function generateTerminalTextTable( opStackConfig.push({ hAlign: "left", colSpan: 2, - content: chalk.cyan(`L1: ${options.blobBaseFee!} gwei (blobBaseFee)`) + content: chalk.cyan(`L1: ${l1GweiBlobBaseFee!} gwei (blobBaseFee)`) }); opStackConfig.push({ hAlign: "left", diff --git a/src/utils/prices.ts b/src/utils/prices.ts index 3f6fadb..66031b1 100644 --- a/src/utils/prices.ts +++ b/src/utils/prices.ts @@ -129,9 +129,10 @@ export async function setGasAndPriceRates(options: GasReporterOptions): Promise< !options.blobBaseFee ) { try { - const blobBaseFee = await axiosInstance.get(blobBaseFeeUrl); - checkForEtherscanError(blobBaseFee.data.result); - options.blobBaseFee = Math.round(hexWeiToIntGwei(blobBaseFee.data.result)) + const response = await axiosInstance.get(blobBaseFeeUrl); + checkForEtherscanError(response.data.result); + const blobBaseFee = hexWeiToIntGwei(response.data.result); + options.blobBaseFee = (blobBaseFee >= 1 ) ? Math.round(blobBaseFee) : blobBaseFee; } catch (error) { options.blobBaseFee = DEFAULT_BLOB_BASE_FEE; warnings.push(warnBlobBaseFeeRemoteCallFailed(error)); diff --git a/src/utils/ui.ts b/src/utils/ui.ts index f5fd025..8e5a4be 100644 --- a/src/utils/ui.ts +++ b/src/utils/ui.ts @@ -211,6 +211,7 @@ export function getCommonTableVals(options: GasReporterOptions) { let l2BaseFeeNote = "(baseFee)"; let l1GweiForL2 = options.baseFee; + let l1GweiBlobBaseFee: string | number | undefined = options.blobBaseFee; if (options.L2 === "arbitrum"){ l2BaseFeeNote = "(baseFeePerByte)" @@ -245,6 +246,10 @@ export function getCommonTableVals(options: GasReporterOptions) { l2gwei = parseFloat(l2gwei.toString()).toFixed(DEFAULT_GAS_PRICE_PRECISION); } + if (typeof l1GweiBlobBaseFee === "number" && l1GweiBlobBaseFee < 1) { + l1GweiBlobBaseFee = parseFloat(l1GweiBlobBaseFee.toString()).toFixed(DEFAULT_GAS_PRICE_PRECISION); + } + const nonZeroMsg = "Cost was non-zero but below the precision setting for the currency display (see options)"; const intrinsicMsg = "Execution gas for this method does not include intrinsic gas overhead "; @@ -253,6 +258,7 @@ export function getCommonTableVals(options: GasReporterOptions) { l2gwei, l1gweiNote, l2gweiNote, + l1GweiBlobBaseFee, network, rate, currency, diff --git a/test/integration/options.e.ts b/test/integration/options.e.ts index e0866a1..9325a21 100644 --- a/test/integration/options.e.ts +++ b/test/integration/options.e.ts @@ -54,7 +54,7 @@ describe("Options E (OPStack:optimism with live pricing & `reportPureAndViewMeth assert.isDefined(options.gasPrice); assert.isDefined(options.blobBaseFee); assert.isBelow(options.gasPrice!, 1); - assert.isAbove(options.blobBaseFee!, 1); + assert.isAbove(options.blobBaseFee!, 0); assert.isDefined(options.tokenPrice); assert.isAbove(parseFloat(options.tokenPrice!), 1000); // Eth-ish diff --git a/test/integration/options.f.ts b/test/integration/options.f.ts index 3304922..d50caae 100644 --- a/test/integration/options.f.ts +++ b/test/integration/options.f.ts @@ -54,7 +54,7 @@ describe("Options F (OPStack:base with live pricing & `reportPureAndViewMethods` assert.isDefined(options.gasPrice); assert.isDefined(options.blobBaseFee); assert.isBelow(options.gasPrice!, 1); - assert.isAbove(options.blobBaseFee!, 1); + assert.isAbove(options.blobBaseFee!, 0); assert.isDefined(options.tokenPrice); assert.isAbove(parseFloat(options.tokenPrice!), 1000); // Eth-ish diff --git a/test/integration/options.g.ts b/test/integration/options.g.ts index 9406386..e26e8f7 100644 --- a/test/integration/options.g.ts +++ b/test/integration/options.g.ts @@ -53,7 +53,7 @@ describe("Options G (Arbitrum with live pricing & `reportPureAndViewMethods`)", assert.isDefined(options.gasPrice); assert.isDefined(options.baseFeePerByte); assert.isBelow(options.gasPrice!, 1); - assert.isAbove(options.baseFeePerByte!, 1); + assert.isAbove(options.baseFeePerByte!, 0); assert.isDefined(options.tokenPrice); assert.isAbove(parseFloat(options.tokenPrice!), 1000); // Eth-ish diff --git a/test/projects/options/hardhat.options.g.config.ts b/test/projects/options/hardhat.options.g.config.ts index 568fad0..e4a892a 100644 --- a/test/projects/options/hardhat.options.g.config.ts +++ b/test/projects/options/hardhat.options.g.config.ts @@ -19,6 +19,7 @@ const config: HardhatUserConfig = { }, gasReporter: { coinmarketcap: process.env.CMC_API_KEY, + currencyDisplayPrecision: 4, L2: "arbitrum", L1Etherscan: process.env.ETHERSCAN_API_KEY, L2Etherscan: process.env.ARBITRUM_API_KEY,