Query editor
WITH-- Collect average daily prices for ETHprices as (select'nETH' as symbol,DATE_TRUNC('day', p.minute) AS day,AVG(p.price) as pricefromprices.usd pWHEREp.blockchain = 'ethereum'AND p.symbol = 'WETH'group BY1,2),-- Aggregate all TokenMint and TokenMintAndSwap eventsevents_all as (SELECT'M' as event,evt_tx_hash,amount,fee,token,FALSE as swapSuccessFROMsynapse_optimism.SynapseBridge_evt_TokenMintWHEREevt_block_time >= timestamp '{{start_date}}'UNION ALLSELECT'MS' as event,evt_tx_hash,amount,fee,token,swapSuccessFROMsynapse_optimism.SynapseBridge_evt_TokenMintAndSwapWHEREevt_block_time >= timestamp '{{start_date}}'),-- Add bridge token symbol for nETH, nUSD-- Figure out how much native asset user received from bridging, excluding gas airdropevents_symbol as (SELECT*,CASEWHEN bytearray_starts_with (token, 0x809DC529f07651bD43A172e8dB6f4a7a0d771036) then 'nETH'WHEN bytearray_starts_with (token, 0x67C10C397dD0Ba417329543c1a40eb48AAa7cd00) then 'nUSD'ELSE 'Other'END as symbol,CASEWHEN bytearray_starts_with (token, 0x809DC529f07651bD43A172e8dB6f4a7a0d771036)AND event = 'MS'AND swapSuccess = TRUE THEN amountELSE 0END as amount_nativeFROMevents_all