Query editor
WITH tvl_data AS (WITH history_raw AS (SELECTJSON_QUERY(HTTP_GET('https://stablecoins.llama.fi/stablecoin/195'), /* USD0 stablecoin ID */'lax $.chainBalances') AS record),history AS (SELECTFROM_UNIXTIME(CAST(JSON_EXTRACT(t.history, '$.date') AS DOUBLE)) AS day,'ethereum' AS chain,CAST(JSON_EXTRACT(t.history, '$.circulating.peggedUSD') AS DOUBLE) AS circulating_supply,CAST(JSON_EXTRACT(t.history, '$.minted.peggedUSD') AS DOUBLE) AS minted_supply,CAST(JSON_EXTRACT(t.history, '$.minted.peggedUSD') AS DOUBLE) - CAST(JSON_EXTRACT(t.history, '$.circulating.peggedUSD') AS DOUBLE) AS unreleased_supplyFROM history_raw, UNNEST(TRY_CAST(JSON_EXTRACT(TRY_CAST(record AS VARCHAR),'$.Ethereum.tokens') AS ARRAY(JSON))) AS t(history)UNION ALLSELECTFROM_UNIXTIME(CAST(JSON_EXTRACT(t.history, '$.date') AS DOUBLE)) AS day,'bnb' AS chain,CAST(JSON_EXTRACT(t.history, '$.circulating.peggedUSD') AS DOUBLE) AS circulating_supply,CAST(JSON_EXTRACT(t.history, '$.minted.peggedUSD') AS DOUBLE) AS minted_supply,CAST(JSON_EXTRACT(t.history, '$.minted.peggedUSD') AS DOUBLE) - CAST(JSON_EXTRACT(t.history, '$.circulating.peggedUSD') AS DOUBLE) AS unreleased_supplyFROM history_raw, UNNEST(TRY_CAST(JSON_EXTRACT(TRY_CAST(record AS VARCHAR),'$.BSC.tokens') AS ARRAY(JSON))) AS t(history))SELECTday,chain AS blockchain,circulating_supply AS tvlFROM history),dex_volume AS (SELECTDATE_TRUNC('day', block_date) AS day,blockchain,SUM(amount_usd) AS volume,COUNT(DISTINCT(taker)) AS active_userFROM dex.tradesWHERE(token_bought_address = 0x73A15FeD60Bf67631dC6cd7Bc5B6e8da8190aCF5OR token_sold_address = 0x73A15FeD60Bf67631dC6cd7Bc5B6e8da8190aCF5)AND blockchain IN ('ethereum')AND block_date > TIMESTAMP '2023-03-27 00:00:00 UTC'GROUP BY 1, 2