Query editor
-- prices.usd not currently pulling, using median dex price as a stop-gap until functionality is restored.with pairs as (select 0xeB16239E886422852b5a2B1B86d910eB72663B4a as pool, 'WBTC-USDC' as pair, 'WBTC' as symbol1, 'USDC' as symbol2union allselect 0x8b8149dd385955dc1ce77a4be7700ccd6a212e65 as pool, 'WETH-USDC' as pair, 'WETH' as symbol1, 'USDC' as symbol2union allselect 0x969f7699fbb9c79d8b61315630cdeed95977cfb8 as pool, 'Threepool' as pai, 'DAI' as symbol1, 'USDC' as symbol2union allselect 0xf69223b75d9cf7c454bb44e30a3772202bee72cf as pool, 'ZYB-WETH' as pair, 'ZYB' as symbol1, 'WETH' as symbol2union allselect 0x3ec0eddcd1e25025077327886a78133589082fb2 as pool, 'ZYB-USDC' as pair, 'ZYB' as symbol1, 'USDC' as symbol2union allselect 0x252cd7185db7c3689a571096d5b57d45681aa080 as pool, 'DAI-USDC' as pair, 'DAI' as symbol1, 'USDC' as symbol2union allselect 0xf942e32861ee145963503ddb69fc3b0237f0888c as pool, 'USDT-USDC' as pair, 'USDT' as symbol1, 'USDC' as symbol2union allselect 0x5bcb14eeb3739a2140ea23535c96394597c85e82 as pool, 'WETH-CARROT' as pair, 'WETH' as symbol1, 'CARROT' as symbol2union allselect 0xc27139355df8d1c11bacac0c34b5378e253c36c0 as pool, 'GLT-WETH' as pair, 'GLT' as symbol1, 'WETH' as symbol2union allselect 0x8cb81053ba864fed008ce8e45cb8c622f1dfb8f6 as pool, 'WETH-BIRD' as pair, 'WETH' as symbol1, 'BIRD' as symbol2),trades as (select dt, pool, pair, symbol1, symbol2,cast(sum(amount0In) as double) as tokenAin,sum(amount0Out) as tokenAout,cast(sum(amount1In) as double) as tokenBin,sum(amount1Out) as tokenBout,count(*) as txsfrom (select evt_block_time as dt,-- date_trunc('day', evt_block_time) as dt,pool, pair,symbol1, symbol2,cast(amount0In as double) as amount0In,cast(amount0Out as double) as amount0Out,cast(amount1In as double) as amount1In,cast(amount1Out as double) as amount1Outfrom zyberswap_arbitrum.ZyberPair_evt_Swap sjoin pairs on pairs.pool = s.contract_address) kiwigroup by 1, 2, 3, 4, 5),conversion as (select dt, pool, pair, txs,(tokenAin) / 1e18 as zyb_in,(tokenBin) / 1e18 as eth_in,(tokenBin * (select price from prices.usd where symbol = 'WETH' and minute = t.dt and blockchain = 'arbitrum')) / 1e18 as eth_in_usd,-- (tokenBin * (select median_price from dex.prices where contract_address = 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1 and hour = t.dt and blockchain = 'arbitrum')) / 1e18 as eth_in_usd,(tokenAout) / 1e18 as zyb_out,(tokenBout) / 1e18 as eth_out,(tokenBout * (select price from prices.usd where symbol = 'WETH' and minute = t.dt and blockchain = 'arbitrum')) / 1e18 as eth_out_usd-- (tokenBout * (select median_price from dex.prices where contract_address = 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1 and hour = t.dt and blockchain = 'arbitrum')) / 1e18 as eth_out_usdfrom trades twhere dt >= timestamp '2023-01-27 00:00:00'