permaryHolder analysis
    Updated 2024-11-20
    with token_holders as (
    select
    to_address as holder,
    sum(amount) as total_received,
    count(distinct tx_hash) as receive_transactions
    from mantle.core.ez_token_transfers
    where
    contract_address = lower('0x9F0C013016E8656bC256f948CD4B79ab25c7b94D')
    group by 1
    ),
    token_senders as (
    select
    from_address as holder,
    sum(amount) as total_sent,
    count(distinct tx_hash) as send_transactions
    from mantle.core.ez_token_transfers
    where
    contract_address = lower('0x9F0C013016E8656bC256f948CD4B79ab25c7b94D')
    group by 1
    ),
    holder_balances as (
    select
    coalesce(r.holder, s.holder) as address,
    coalesce(r.total_received, 0) as total_received,
    coalesce(s.total_sent, 0) as total_sent,
    coalesce(r.total_received, 0) - coalesce(s.total_sent, 0) as net_balance,
    coalesce(r.receive_transactions, 0) as receive_transactions,
    coalesce(s.send_transactions, 0) as send_transactions
    from token_holders r
    full outer join token_senders s on r.holder = s.holder
    )
    select
    address,
    net_balance,
    total_received,
    total_sent,
    QueryRunArchived: QueryRun has been archived