Query editor
with cow_trades as (SELECTtx_hashFROM cow_protocol_gnosis.tradesWHERE block_date >= date(timestamp '2023-05-01')),oneinch as (SELECTevt_tx_hash as tx_hashFROM oneinch_gnosis.AggregationRouterV5_evt_OrderFilledWHERE evt_block_time >= date(timestamp '2023-05-01')),aggregators as(selectDATE_TRUNC('Month', block_time) AS month,project,case when o.tx_hash is not null then 'OneInch'when t.tx_to in (0x1111111254eeb25477b68fb85ed929f73a960582,0x111111125421ca6dc452d289314280a0f8842a65) then 'OneInch'when c.tx_hash is not null then 'Cow'when t.tx_to = 0xba12222222228d8ba445958a75a0704d566bf2c8 then 'Balancer'when t.tx_to in (0xa6a147946facac9e0b99824870b36088764f969f) then 'Contango'else 'Others'end as router,sum(amount_usd) as amountfrom dex.trades tleft join cow_trades c on c.tx_hash=t.tx_hashleft join oneinch o on o.tx_hash=t.tx_hashwhereblockchain = 'gnosis'and block_date >= date(timestamp '2023-05-01')group by 1,2,3)selectmonth,(sum(case when router in ('Cow') then amount else 0 end)/sum(amount)) as cow_market_share,(sum(case when router in ('Balancer') then amount else 0 end)/sum(amount)) as Balancer_market_share,(sum(case when router in ('Contango') then amount else 0 end)/sum(amount)) as Contango_market_share,(sum(case when router in ('OneInch') then amount else 0 end)/sum(amount)) as oneinch_market_share,(sum(case when router in ('OneInch','Cow','Contango') then amount else 0 end)/sum(amount)) as aggregators_market_share,sum(amount) as total_volumefrom aggregatorsgroup by 1