Query editor
WITH history_raw AS (SELECTJSON_QUERY(HTTP_GET('https://stablecoins.llama.fi/stablecoinchains') /* 199 is the FDUSD stablecoin id on defillama */,'lax $[*]?(@.name == "Ethereum" || @.name == "BSC")'WITH ARRAY WRAPPER) AS record),history AS (SELECTCAST(JSON_EXTRACT(history, '$.name') AS VARCHAR) AS chain,CAST(JSON_EXTRACT(history, '$.totalCirculatingUSD.peggedUSD') AS DOUBLE) AS total_supplyFROM history_raw, UNNEST(CAST(JSON_EXTRACT(CAST(record AS VARCHAR),'$') AS ARRAY(JSON))) AS t(history)),fdusd_supply AS (SELECT*FROM query_4257883 -- https://dune.com/queries/4257883ORDER BY day DESCLIMIT 2),summary_stats AS (SELECTfdusd.chain,fdusd.circulating_supply,fdusd.minted_supply,fdusd.unreleased_supply,fdusd.circulating_supply / fdusd.minted_supply AS "Stablecoin Circulating Supply (%)",fdusd.circulating_supply / agg.total_supply AS "Stabelcoin Market Share (%)"FROM fdusd_supply AS fdusdLEFT JOIN history AS aggON lower(fdusd.chain) = lower(agg.chain))SELECT * FROM summary_stats