SELECT block_timestamp::DATE AS date,
contract_label,
event_type,
AVG(amount_usd) as avg_amount,
MEDIAN(amount_usd) as median_amount
FROM terra.classic.ez_anchor_collateral
WHERE amount_usd < 40000000 --filtering result to handle outliers
GROUP BY date, contract_label, event_type
HAVING contract_label IN ('bLuna Custody', 'bETH mmCustody')
ORDER BY date DESC