0xasmrUntitled Query
    Updated 2022-09-03
    WITH eth_deposits AS (
    SELECT
    block_timestamp,
    date_trunc('hour', block_timestamp) AS hour,
    from_address AS user,
    eth_value AS eth_deposited
    FROM ethereum.core.fact_transactions
    WHERE to_address = '0x3b968d2d299b895a5fcf3bba7a64ad0f566e6f88'
    AND origin_function_signature = '0x58c22be7'
    AND block_timestamp >= CURRENT_DATE - interval '1 month'
    ),
    eth_withdrawals AS(
    SELECT
    block_timestamp,
    date_trunc('hour', block_timestamp) AS hour,
    origin_from_address AS user,
    ethereum.public.udf_hex_to_int(data)/pow(10, 18) AS eth_withdrawn
    FROM ethereum.core.fact_event_logs
    WHERE contract_address = '0x70b97a0da65c15dfb0ffa02aee6fa36e507c2762'
    AND origin_to_address = '0x3b968d2d299b895a5fcf3bba7a64ad0f566e6f88'
    AND origin_function_signature = '0x36118b52'
    AND topics[0] = '0x3ed4ee04a905a278b050a856bbe7ddaaf327a30514373e65aa6103beeae488c3'
    AND origin_from_address IN (SELECT user FROM eth_deposits)
    AND block_timestamp >= CURRENT_DATE - interval '1 month'
    ),
    eth_withdrawals_usd AS(
    SELECT
    w.block_timestamp,
    w.user,
    w.eth_withdrawn,
    p.price
    FROM eth_withdrawals w
    INNER JOIN ethereum.core.fact_hourly_token_prices p
    ON p.hour = w.hour
    WHERE p.symbol = 'WETH'
    )
    Run a query to Download Data