WITH ust as (select date, sum(balance) as UST_supply
from terra.daily_balances
where date >= '2021-01-01'
and balance > 0
and currency = 'UST'
group by 1
),
dai AS (
SELECT
balance_date, sum(amount_usd) as DAI_supply
FROM ethereum.erc20_balances
WHERE symbol = 'DAI'
AND balance > 0
AND amount_usd > 0
AND balance_date >= '2021-01-01'
GROUP BY balance_date
)
SELECT
ust.date, UST_supply, DAI_supply
FROM ust
JOIN dai
ON ust.date = dai.balance_date