Query editor
WITH history_raw AS (SELECTJSON_QUERY(HTTP_GET('https://stablecoins.llama.fi/stablecoin/119') /* 199 is the FDUSD stablecoin id on defillama */,'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))SELECT * FROM history