Query editor
/*- @dev:- txns earlier than 2021.11.11 are not part of the current blockchain and must be retrieved from legacy tables.https://docs.optimism.io/builders/tools/monitor/regenesis-history- list of bridged tokens:https://docs.optimism.io/chain/tokenlist- USDS and BUIDL are post-regenesis tokens, no legacy data needed.*/withasset_type as (select asset, address, category, start_dtfrom (values('USDT', 0x94b008aa00579c1307b0ef2c499ad98a8ce58e58, 'fiat-backed', date '2021-06-01'),('USDC', 0x0b2c639c533813f4aa9d7837caf62653d097ff85, 'fiat-backed', date '2023-06-01'),('USDC.e', 0x7f5c764cbc14f9669b88837ca1490cca17c31607, 'fiat-backed', date '2021-06-01'),('USDS', 0x0000000000000000000000000000000000000000, 'crypto-backed', date '2025-05-01'), -- TODO: replace 0x0 with actual USDS address on Optimism('BUIDL', 0xa1cdab15bba75a80df4089cafba013e376957cf5, 'fiat-backed', date '2024-11-01'),('sUSD', 0x8c6f28f2f1a3c87f0f938b96d27520d9751ec8d9, 'crypto-backed', date '2021-06-01'),('DAI', 0xda10009cbd5d07dd0cecc66161fc93d7c9000da1, 'crypto-backed', date '2021-06-01')) as t(asset, address, category, start_dt)),period_range as (selecta.asset,a.address,a.category,d.dtfrom asset_type across join unnest(sequence(a.start_dt, current_date, interval '1' day)) as d(dt)),usdt as (select'USDT' as asset,evt_block_date as dt,sum(casewhen "from" = 0x0000000000000000000000000000000000000000 then valuewhen "to" = 0x0000000000000000000000000000000000000000 then -valueend) / 1e6 as amount,sum(value) / 1e6 as volume,count(*) as txn_countfrom usdt_optimism.usdt_evt_transfergroup by 1, 2union allselect'USDT' as asset,date(block_time) as dt,sum(casewhen varbinary_ltrim(topic1) = 0x then varbinary_to_decimal(varbinary_ltrim(data))when varbinary_ltrim(topic2) = 0x then -varbinary_to_decimal(varbinary_ltrim(data))end) / 1e6 as amount,sum(varbinary_to_decimal(varbinary_ltrim(data))) / 1e6 as volume,count(*) as txn_countfrom optimism_legacy_ovm1.logswhere contract_address = 0x94b008aa00579c1307b0ef2c499ad98a8ce58e58and topic0 = 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef