Query editor
-- Date completed: March 11, 2023-- By: Rick Alexander (discord "Rick the Comm Guy#5791")-- Token: lsMatic on polygon (0x858bCEE0E62dd0c961611ddDDB908767B0ce801C)-- Query Name: PRICE of lsMatic - daily average-- grab all transactions in the last 30 dayswith price as (SELECT--tx_hash,block_date, token_bought_symbol, token_bought_address, token_bought_amount,token_sold_symbol, token_sold_address, token_sold_amount,token_bought_amount_raw as amt, amount_usd, 'buy' as type,amount_usd / (token_bought_amount_raw / 1e18) as priceFROM balancer.tradeswheretoken_bought_address = 0x858bCEE0E62dd0c961611ddDDB908767B0ce801Cand token_sold_symbol = 'USDC'and amount_usd is not nullAND block_time >= NOW() - interval '30' dayunion allSELECT--tx_hash,block_date, token_bought_symbol, token_bought_address, token_bought_amount,token_sold_symbol, token_sold_address, token_sold_amount,token_sold_amount_raw, amount_usd, 'sold',amount_usd / (token_sold_amount_raw / 1e18)FROM balancer.tradeswheretoken_sold_address = 0x858bCEE0E62dd0c961611ddDDB908767B0ce801Cand token_bought_symbol = 'USDC'and amount_usd is not nullAND block_time >= NOW() - interval '30' day)-- outputselectdate(block_date) as DAY,--date_trunc('day', block_date) AS DAY,cast(round(sum(amount_usd) / sum(amt / 1e18), 4) as varchar) as PRICEfrom PRICEgroup by 1Order by 1 desc