Query editor
WITHtrades AS (SELECT*,date_trunc('day', block_time) AS block_dateFROM/* Trades */query_4086080),openInterestChanges AS (SELECT*FROM/* Open Interest Changes */query_4086137),lifetimeOpenInterestStats AS (SELECTSUM(amount) AS openInterestUSD,SUM(IF(direction = 'Long', amount, NULL)) AS longOpenInterestUSD,SUM(IF(direction = 'Short', amount, NULL)) AS shortOpenInterestUSDFROMopenInterestChanges),lifetimeStats AS (SELECTSUM(sizeDelta) AS volumeUSD,SUM(fee) + SUM(fundingFee) + SUM(borrowFee) AS totalFees,SUM(fee) AS feesUSD,SUM(fundingFee) AS fundingFeesUSD,SUM(borrowFee) AS borrowFeesUSD,COUNT(DISTINCT (trades.user)) AS numberOfUsers,COUNT(DISTINCT (tx_hash)) AS numberOfTrades,COUNT(DISTINCT (IF(direction = 'Long', tx_hash, NULL))) AS numberOfLongs,COUNT(DISTINCT (IF(direction = 'Short', tx_hash, NULL))) AS numberOfShorts,COUNT(DISTINCT (IF(type = 'Liquidate', tx_hash, NULL))) AS numberOfLiquidations,COUNT(DISTINCT (posId)) AS numberOfPositions,COUNT(DISTINCT (tokenId)) AS numberOfMarketsFROMtrades),dailyAverageStats7dMA AS (SELECTFLOOR(AVG(numberOfTrades)) AS averageDailyNumberOfTrades7dMA,FLOOR(AVG(numberOfUsers)) AS averageDailyNumberOfUsers7dMA,AVG(volumeUSD) AS averageDailyVolumeUSD7dMA,AVG(totalFees) AS averageDailyFeesUSD7dMAFROM(SELECTCOUNT(DISTINCT (tx_hash)) AS numberOfTrades,COUNT(DISTINCT (user)) AS numberOfUsers,SUM(sizeDelta) AS volumeUSD,SUM(fee) + SUM(fundingFee) + SUM(borrowFee) AS totalFeesFROMtradesWHEREblock_date >= date_trunc('day', NOW() - INTERVAL '7' day)AND block_date < date_trunc('day', NOW())GROUP BY