- {formatThousands(
- BigInt(tx.gas_used) / BigInt(tx.length)
- )}
+
+
+ {formatThousands(
+ BigInt(tx.gas_used) / BigInt(tx.length)
+ )}
+ {tx.length > 1 && ' each'}
+
-
Per Name
+ {tx.length > 1 && (
+
+
+ {formatThousands(BigInt(tx.gas_used))}
+ {' '}
+ total
+
+ )}
-
{formatThousands(BigInt(tx.gas_used))}
+
{formatGas(BigInt(tx.gas_price))}
{ethUsd.data ? (
diff --git a/web/src/utils/aggregateTotals.ts b/web/src/utils/aggregateTotals.ts
index a670368..3b5a8d5 100644
--- a/web/src/utils/aggregateTotals.ts
+++ b/web/src/utils/aggregateTotals.ts
@@ -1,5 +1,7 @@
import { AllMultiReturnTypes } from './decodeTransaction';
+// gas_price - 9 decimals
+
export const aggregateTotals = (txs: AllMultiReturnTypes[]) => {
const aggregates = txs.reduce(
(aggregate, current) => {
@@ -38,6 +40,8 @@ export const aggregateTotals = (txs: AllMultiReturnTypes[]) => {
}
);
+ console.log({ aggregates });
+
return {
commitAverage: aggregates.commitTotal / aggregates.commitCount,
commitGasPriceAverage:
diff --git a/web/src/utils/formatGas.ts b/web/src/utils/formatGas.ts
index e0bf24c..aec9ecd 100644
--- a/web/src/utils/formatGas.ts
+++ b/web/src/utils/formatGas.ts
@@ -1,4 +1,4 @@
// Divide by 10e8 to get gwei but keep 2 decimals of precision so 1.23 return as string
export const formatGas = (gas: BigInt): string => {
- return (Number(BigInt(gas.toString()) / BigInt(10e6)) / 10).toString();
+ return (Number(BigInt(gas.toString()) / BigInt(10e6)) / 100).toString();
};
diff --git a/web/src/utils/gasMagic.ts b/web/src/utils/gasMagic.ts
index 177b821..d8757a8 100644
--- a/web/src/utils/gasMagic.ts
+++ b/web/src/utils/gasMagic.ts
@@ -4,12 +4,6 @@ export const gasPriceMagic = (
ethUSDC: bigint
) => {
return (
- Number(
- BigInt(
- Math.round(
- Number(BigInt((gas * gasPrice) / 10_000n) * BigInt(ethUSDC))
- )
- ) / 1_000_000n
- ) / 1_000_000_000_000
+ Number((BigInt(gas * gasPrice) * BigInt(ethUSDC)) / 1_000_000n) / 1e18
).toPrecision(3);
};