elsinaLuna Flash bounty : Top 10 Luna Receiver address by TX Count
    Updated 2022-10-07
    with luna_transfer as (
    select
    tx_id,
    block_timestamp::date as "Day",
    tx:body:messages[0]:from_address as from_address,
    tx:body:messages[0]:to_address as to_address,
    tx:body:messages[0]:amount[0]:amount/1e6 as "Amount"
    from terra.core.fact_transactions
    where tx:body:messages[0]:"@type" = '/cosmos.bank.v1beta1.MsgSend' and TX_SUCCEEDED = true and tx:body:messages[0]:amount[0]:denom = 'uluna'
    )
    select
    count(1) as "# TX",
    to_address as "Receiver Address",
    case
    when to_address = 'terra1ncjg4a59x2pgvqy9qjyqprlj8lrwshm0wleht5' then 'Binance'
    when to_address = 'terra14l46jrdgdhaw4cejukx50ndp0hss95ekt2kfmw' then 'Kucoin'
    when to_address = 'terra18vnrzlzm2c4xfsx382pj2xndqtt00rvhu24sqe' then 'Binance Withdraw 2'
    when to_address = 'terra13s4gwzxv6dycfctvddfuy6r3zm7d6zklynzzj5' then 'OKX'
    else to_address
    end as "To Address",
    count(DISTINCT from_address) as "# unique Senders",
    sum("Amount") as "Volume",
    row_number() over (order by "# TX" desc) as "Rank"
    from
    luna_transfer
    group by
    to_address
    qualify row_number() over (order by "# TX" desc) <= 10

    Run a query to Download Data