mo1152023-03-25 02:25 PM
    Updated 2023-03-25
    With Arbitrum as (With Arbitrum1 as (with arbitrum_fees as
    (select
    date_trunc('day',BLOCK_TIMESTAMP) as date,
    FROM_ADDRESS as address,
    sum (TX_FEE) as gas_paid
    from arbitrum.core.fact_transactions
    where FROM_ADDRESS = lower('{{ADDRESS}}')
    group by 1,2),
    ETH as (select date_trunc ('day',HOUR) as date, avg(PRICE)as price
    from ethereum.core.fact_hourly_token_prices
    where SYMBOL = 'WETH'
    group by 1)
    select a.date, address,gas_paid as gas_paid_ETH, (gas_paid*price) as gas_paid_USD
    from arbitrum_fees a left join ETH e on a.date=e.date)
    select 'Arbitrum' as network , sum(gas_paid_ETH)as Token , sum(gas_paid_USD)as USD, (USD/Token) as Average_Price
    from Arbitrum1),
    ETHc as(select 'Arbitrum' as network , max(HOUR) , avg(PRICE)as Current_price
    from ethereum.core.fact_hourly_token_prices
    where SYMBOL = 'WETH'),
    data as (select
    'Arbitrum' as network ,
    max( NONCE) as transactions,
    min(BLOCK_TIMESTAMP) as first_transaction,
    max(BLOCK_TIMESTAMP) as last_transaction
    from arbitrum.core.fact_transactions
    where FROM_ADDRESS = lower('{{ADDRESS}}')
    group by 1)
    select
    a.network,
    first_transaction,
    last_transaction,
    transactions as "Number of Transactions",
    Token as "Gas Paid (Native Token)",
    USD as "Gas Paid (USD)",
    (Token/transactions) as "Average Native Token Paid per Transaction ",
    (USD/transactions) as "Average USD Paid per Transaction ",
    Run a query to Download Data