drethereumLSD Net Deposits & Withdrawals by Day
    Updated 2023-11-07
    WITH deposits AS (
    SELECT
    date_trunc('day',block_timestamp) AS day,
    platform,
    token_symbol,
    SUM(eth_amount) AS total_eth_deposit,
    SUM(eth_amount_usd) AS total_usd_deposit
    FROM ethereum.defi.ez_liquid_staking_deposits
    WHERE day >= CURRENT_DATE - {{days}}
    GROUP BY 1,2,3
    ),

    withdrawals AS (
    SELECT
    date_trunc('day',block_timestamp) AS day,
    platform,
    token_symbol,
    SUM(eth_amount) AS total_eth_withdrawn,
    SUM(eth_amount_usd) AS total_usd_withdrawn
    FROM ethereum.defi.ez_liquid_staking_withdrawals
    WHERE day >= CURRENT_DATE - {{days}}
    GROUP BY 1,2,3
    ),

    net AS (
    SELECT
    day,
    platform,
    token_symbol,
    ROUND(total_eth_deposit,0) AS total_eth_deposit,
    ROUND(total_eth_withdrawn,0) AS total_eth_withdrawn,
    ROUND(total_eth_deposit - COALESCE(total_eth_withdrawn,0),0) AS net_eth,
    ROUND(total_usd_deposit - COALESCE(total_usd_withdrawn,0),0) AS net_usd
    FROM deposits
    LEFT JOIN withdrawals USING(platform,day)
    ORDER BY 1 DESC, 6 DESC
    Run a query to Download Data