diff --git a/web/src/App.tsx b/web/src/App.tsx index 2c63a9a..a67c9e5 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -137,14 +137,12 @@ export const App = () => {
{formatThousands(totals.renewAverage)}
- {currentUSDCPrice ? ( -
-
- - {formatGas( - totals.renewGasPriceAverage - )} -
+
+
+ + {formatGas(totals.renewGasPriceAverage)} +
+ {currentUSDCPrice ? (
~{' '} {gasPriceMagic( @@ -154,8 +152,8 @@ export const App = () => { )}{' '} USD
-
- ) : undefined} + ) : undefined} +
) : (
Loading...
diff --git a/web/src/txHistory/TransactionEntry.tsx b/web/src/txHistory/TransactionEntry.tsx index 92d7b14..09d4aaf 100644 --- a/web/src/txHistory/TransactionEntry.tsx +++ b/web/src/txHistory/TransactionEntry.tsx @@ -7,6 +7,7 @@ import { FiBox, FiChevronDown } from 'react-icons/fi'; import { formatFullAndRelativeDate } from '../utils/date'; import { AllMultiReturnTypes } from '../utils/decodeTransaction'; import { useEthUsd } from '../utils/ethUsd'; +import { formatGas } from '../utils/formatGas'; import { formatThousands } from '../utils/formatThousands'; const formatAddress = (address: string) => @@ -59,18 +60,28 @@ export const TransactionEntry: FC<{ tx: AllMultiReturnTypes }> = ({ tx }) => { )} {tx.length > 0 && (
-
- {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); };