binhachonFlipside Algorand Wallet Behavior - Wallet's bounty distribution in Algo
    Updated 2022-04-08
    with bounty_hunter_list as (
    select
    receiver,
    sum(amount) as total_received
    from algorand.payment_transaction
    where sender = 'TLR47MQCEIC6HSSYLXEI7NJIINWJESIT3XROAYC2DUEFMSRQ6HBVJ3ZWLE'
    and amount < 10000
    group by 1
    ),
    account_balance as (
    select
    address,
    balance,
    total_received,
    case when total_received > balance then 100 else 100 * total_received/balance end as percent_from_bounty
    from algorand.account
    inner join bounty_hunter_list on (address = receiver)
    )
    select
    round(balance, -2)::string as rounded_balance,
    sum(balance) as "Total holding",
    sum(total_received) as "Total payouts"
    from account_balance
    group by 1