WITH hash_tx_deposit_to_pool AS(
SELECT
TX_HASH
FROM ethereum.core.fact_event_logs
WHERE ORIGIN_TO_ADDRESS = '0xd89a09084555a7d0abe7b111b1f78dfeddd638be'
AND event_name = 'Deposit'
AND block_timestamp::date > CURRENT_DATE - 30
),
amount_deposit_to_pool as(
SELECT
DISTINCT hash_tx_deposit_to_pool.TX_HASH,
(AMOUNT_USD) as amount_USD
FROM ethereum.core.ez_token_transfers JOIN hash_tx_deposit_to_pool
ON ethereum.core.ez_token_transfers.TX_HASH = hash_tx_deposit_to_pool.TX_HASH
WHERE SYMBOL = 'USDC'
)
SELECT
sum(amount_USD) as total_usd,
(sum(amount_USD) / 30 ) as daily_avg
FROM
amount_deposit_to_pool