eferPlayground - Optimism daily bridges (Last 60days) - Playground_1
    Updated 2022-06-17
    -- deposits
    -- withdrawals

    WITH native_bridge AS (
    SELECT
    CAST(DATE_TRUNC('day', BLOCK_TIMESTAMP) AS DATE) AS date,
    COALESCE(AMOUNT, 0)
    FROM ethereum.core.ez_eth_transfers
    WHERE ETH_TO_ADDRESS = '0x52ec2f3d7c5977a8e558c8d9c6000b615098e8fc' -- Optimism Wrap Speed Bridge Contract (V2)
    AND date > CURRENT_DATE - 60
    GROUP BY date
    ), old_bridge AS (
    SELECT
    CAST(DATE_TRUNC('day', BLOCK_TIMESTAMP) AS DATE) AS date,
    SUM(AMOUNT) AS eth
    FROM ethereum.core.ez_eth_transfers
    WHERE ETH_TO_ADDRESS = '0x99c9fc46f92e8a1c0dec1b1747d010903e884be1' -- Optimism Main Bridge Contract (V1)
    AND date > CURRENT_DATE - 60
    GROUP BY date
    ), generated_time AS (
    SELECT CURRENT_DATE + 1 - ROW_NUMBER() OVER (ORDER BY 1 DESC) AS date
    FROM old_bridge
    )

    SELECT generated_time.date as date, COALESCE(native_bridge.eth, 0)
    FROM generated_time
    LEFT JOIN native_bridge ON native_bridge.date = generated_time.date

    Run a query to Download Data