Query editor
-- Materialized view: dune.1inch.result_fusion_resolvers_mapping_materialized-- https://dune.com/queries/6978288withstatic as (select'{{timebox}}' as timeframe, split('{{blockchain}}', ',') as blockchains, coalesce(try_cast('{{period from}}' as timestamp), timestamp '2024-01-01') as period_from)selectdate_trunc(static.timeframe, s.block_time) as time-- resolver_name priority:-- no match on either path -> 'UNREGISTERED'-- otherwise first non-null of:-- 1. nft.resolver_name (KYC-NFT holder name)-- 2. wl.resolver_name (whitelist registry name)-- 3. wl.resolver_address as string (whitelisted but unnamed; '0x' sentinel -> skip)-- 4. s.tx_to as string (NFT row matched but has no name), casewhen wl.tx_from is null and nft.tx_to is null then 'UNREGISTERED'else coalesce(nft.resolver_name, wl.resolver_name, nullif(cast(wl.resolver_address as varchar), '0x'), cast(s.tx_to as varchar))end as resolver_name, sum(s.amount_usd) as volume, sum(sum(s.amount_usd)) over (partition by date_trunc(static.timeframe, s.block_time)) as volume_total_timeframe, count(*) as fills, count(distinct s.tx_hash) as txs, count(distinct s.order_hash) as orders, count(distinct s.user) as wallets, max_by(s.blockchain, s.amount_usd) as blockchain_example, max_by(get_href(get_chain_explorer_tx_hash(s.blockchain, cast(s.tx_hash as varchar)),cast(s.tx_hash as varchar)),s.amount_usd) as tx_hash_examplefrom oneinch.swaps sjoin static on true-- on (not using): USING forbids qualified column referencesleft join dune."1inch".result_fusion_resolvers_mapping_materialized wlon wl.blockchain = s.blockchainand wl.tx_from = s.tx_fromleft join dune."1inch".result_fusion_resolvers_mapping_materialized nfton nft.blockchain = s.blockchainand nft.tx_to = s.tx_towhere s.mode = 'fusion'and (array_position(static.blockchains, '= all =') > 0or array_position(static.blockchains, s.blockchain) > 0)and s.block_time >= static.period_fromand s.tx_success and s.call_successgroup by 1, 2order by 1 desc, 3 desc