Query editor
with price_strk as (selectdate_trunc('day', timestamp) as day,max(price) as pricefrom prices.daywhere blockchain = 'ethereum' and contract_address in (0xca14007eff0db1f8135f4c25b34de49ab0d42766) -- STRKand timestamp < current_dateand timestamp >= current_date - interval '{{days}}' dayGROUP BY 1),price_eth as (selectdate_trunc('day', timestamp) as day,pricefrom prices.daywhere blockchain = 'ethereum' and contract_address = 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 -- ETHand timestamp < current_dateand timestamp >= current_date - interval '{{days}}' day),prices as (selectstrk.day,strk.price as price_strk,eth.price as price_eth,strk.price/eth.price as strk_per_ethfrom price_strk strkinner join price_eth eth on strk.day = eth.day),calls_enriched as (SELECTc.block_date,c.contract_address,c.transaction_hash,t.sender_address,t.execution_status,CASEWHEN t.actual_fee_unit = 'WEI' THEN t.actual_fee_amount / 1e18WHEN t.actual_fee_unit = 'FRI' THEN (t.actual_fee_amount / 1e18) * p.strk_per_ethELSE 0END AS tx_fee_eth,CASEWHEN t.actual_fee_unit = 'WEI' THEN (t.actual_fee_amount / 1e18) * p.price_ethWHEN t.actual_fee_unit = 'FRI' THEN (t.actual_fee_amount / 1e18) * p.strk_per_eth * p.price_ethELSE 0END AS tx_fee_usd,COUNT(*) OVER (PARTITION BY c.transaction_hash) AS calls_in_tx,COUNT(distinct c.contract_address) OVER (PARTITION BY c.transaction_hash) AS contracts_called_in_txFROM starknet.calls cLEFT JOIN starknet.transactions tON c.transaction_hash = t.hashLEFT JOIN prices pON t.block_date = p.dayWHERE c.block_date < current_dateand c.block_date >= current_date - interval '{{days}}' dayand t.block_date < current_dateand t.block_date >= current_date - interval '{{days}}' day