Sbhn_NPpuny-tan
    Updated 2025-03-25
    with deposit as (select from_address,
    sum(amount) as deposited,
    sum(amount_usd) as deposited_usd
    from avalanche.core.ez_token_transfers
    join avalanche.core.fact_event_logs using(tx_hash)
    where contract_address = '0x06d47f3fb376649c3a9dafe069b3d6e35572219e'
    and topics[0] = '0x30385c845b448a36257a6a1716e6ad2e1bc2cbe333cde1e69fe849ad6511adfe'
    and to_address = '0xdb8b3bd77b7a28c2835c9e8e3c15f7adbc2cd267'
    group by 1),


    redeem as (select to_address,
    sum(amount) as redeemed,
    sum(amount_usd) as redeemed_usd
    from avalanche.core.ez_token_transfers
    join avalanche.core.fact_event_logs using(tx_hash)
    where contract_address = '0x06d47f3fb376649c3a9dafe069b3d6e35572219e'
    and topics[0] = '0xdd8b8dbb53fec7033579b7466dc8fd28b088f5b31bca605ca8fa24a570e366ca'
    and from_address = '0xdb8b3bd77b7a28c2835c9e8e3c15f7adbc2cd267'
    group by 1)

    SELECT
    COALESCE(a.from_address, b.to_address) AS "User",
    COALESCE(deposited_usd, 0) AS "Deposited $",
    COALESCE(redeemed_usd, 0) AS "Redeemed $",
    COALESCE(deposited_usd, 0) - COALESCE(redeemed_usd, 0) AS "Current Deposited $",
    FROM deposit a
    FULL JOIN redeem b
    ON a.from_address = b.to_address
    having "User" is not null
    ORDER BY 4 DESC

    QueryRunArchived: QueryRun has been archived