Query editor
with-- Calculate DMT and WETH balances for the Uniswap V3 Pair contractdmt_transfers as (select date_trunc('day', evt_block_time) as date,sum(case when "to" = 0xe3170D65018882a336743a9c396C52eA4B9c5563 then value/1e18 else cast(0 as decimal) end) -sum(case when "from" = 0xe3170D65018882a336743a9c396C52eA4B9c5563 then value/1e18 else cast(0 as decimal) end) as net_dmtfrom erc20_ethereum.evt_Transferwhere contract_address = 0x0B7f0e51Cd1739D6C96982D55aD8fA634dd43A9Cand ("to" = 0xe3170D65018882a336743a9c396C52eA4B9c5563 or "from" = 0xe3170D65018882a336743a9c396C52eA4B9c5563)group by date_trunc('day', evt_block_time)),weth_transfers as (select date_trunc('day', evt_block_time) as date,sum(case when "to" = 0xe3170D65018882a336743a9c396C52eA4B9c5563 then value/1e18 else cast(0 as decimal) end) -sum(case when "from" = 0xe3170D65018882a336743a9c396C52eA4B9c5563 then value/1e18 else cast(0 as decimal) end) as net_wethfrom erc20_ethereum.evt_Transferwhere contract_address = 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2and ("to" = 0xe3170D65018882a336743a9c396C52eA4B9c5563 or "from" = 0xe3170D65018882a336743a9c396C52eA4B9c5563)GROUP BY date_trunc('day', evt_block_time)),eth_liq as (select(select date, net_dmt from dmt_transfers) as dmt,(select date, net_weth from weth_transfers) as weth),arb_liq as (WITH last_entry_per_day AS (SELECTdate_trunc('day', call_block_time) as date,output__reserve0,output__reserve1,ROW_NUMBER() OVER (PARTITION BY date_trunc('day', call_block_time) ORDER BY call_block_time DESC) as rnFROMcamelot_arbitrum.CamelotPair_call_getReservesWHEREcontract_address = 0x410c879c62f22794bD5eE98e2EE01490F6d47A6b)SELECTdate,output__reserve0 / 1e18 as dmt,output__reserve1 / 1e6 as usdc,(output__reserve1 / 1e6) / (output__reserve0 / 1e18) as usd_priceFROMlast_entry_per_dayWHERErn = 1),staking_inflow as (select date_trunc('day', evt_block_time) as date,sum(value/1e18) as inffrom erc20_arbitrum.evt_Transferwhere contract_address = 0x8B0E6f19Ee57089F7649A455D89D7bC6314D04e8and to = 0x2d7a092036cc1E39AC37a4c4c7F6F9aAdCFd5f80GROUP BY date_trunc('day', evt_block_time)),staking_outflow as (