Query editor
-- get GYD volume-weighted average price (or VWAP) from gyd/usdc trading pool on ethereum: 0xC2AA60465BfFa1A88f5bA471a59cA0435c3ec5c1 ---- refer to query_3450867 --with gyd_swaps as (select * from dex.tradeswhere (token_bought_address = 0xe07F9D810a48ab5c3c914BA3cA53AF14E4491e8Aor token_sold_address = 0xe07F9D810a48ab5c3c914BA3cA53AF14E4491e8A)and project_contract_address = 0xC2AA60465BfFa1A88f5bA471a59cA0435c3ec5c1and blockchain = 'ethereum'),swaps_data as (selectblock_time,tx_hash,if(token_bought_address = 0xe07F9D810a48ab5c3c914BA3cA53AF14E4491e8A, token_bought_amount, token_sold_amount) as gyd_amount,if(token_bought_address = 0xe07F9D810a48ab5c3c914BA3cA53AF14E4491e8A, token_sold_amount, token_bought_amount) as usdc_amount,if(token_bought_address = 0xe07F9D810a48ab5c3c914BA3cA53AF14E4491e8A, token_bought_amount_raw, token_sold_amount_raw) as gyd_amount_raw,if(token_bought_address = 0xe07F9D810a48ab5c3c914BA3cA53AF14E4491e8A, token_sold_amount_raw, token_bought_amount_raw) as usdc_amount_raw,if(token_bought_address = 0xe07F9D810a48ab5c3c914BA3cA53AF14E4491e8A, 'buy', 'sell') as sidefrom gyd_swaps),swaps_amount as (selectblock_time, tx_hash,coalesce(gyd_amount, cast(gyd_amount_raw as double)/1e18) as gyd_amount,coalesce(usdc_amount, cast(usdc_amount_raw as double)/1e18) as usdc_amount,sidefrom swaps_data),gyd_vwap as (selectdate_trunc('day', block_time) as day,sum(gyd_amount) as gyd_amount,sum(usdc_amount) as usdc_amount,sum(usdc_amount)/sum(gyd_amount) as vwap_gyd_usdc,(sum(usdc_amount)/sum(gyd_amount) - 1) * 1e4 as price_dev_bpfrom swaps_amountwhere block_time >= cast('2023-12-07' as timestamp)group by 1)select * from gyd_vwaporder by 1 desc