John_GaltyLuna Sold by Address
    Updated 2022-03-15
    with table1 as (select -- this is for simple swaps where yluna is buying prism
    distinct event_attributes:receiver::string as user_address,
    sum(event_attributes:offer_amount) / pow(10, 6) as yluna_spent
    from terra.msg_events
    where date(block_timestamp) > '2022-02-10'
    and event_attributes:"0_to" = 'terra1kqc65n5060rtvcgcktsxycdt2a4r67q2zlvhce'
    and event_attributes:"1_action" = 'swap'
    and event_index = 3
    and event_attributes:"ask_asset" = 'cw20:terra1dh9478k2qvqhqeajhn75a2a7dsnf74y5ukregw' --prism
    and event_attributes:"offer_asset" = 'cw20:terra17wkadg0tah554r35x6wvff0y5s7ve8npcjfuhz' --yluna
    group by user_address

    union all
    select
    distinct event_attributes:"1_receiver"::string as user_address, -- this is for a routed transaction where yluna is buying prism
    sum(event_attributes:"0_offer_amount") / pow(10, 6) as yluna_spent
    from terra.msg_events
    where date(block_timestamp) > '2022-02-10'
    and event_attributes:"1_to" = 'terra1kqc65n5060rtvcgcktsxycdt2a4r67q2zlvhce'
    and event_index = 3
    and event_attributes:"2_action" = 'swap'
    and event_attributes:"0_offer_asset" = 'cw20:terra17wkadg0tah554r35x6wvff0y5s7ve8npcjfuhz' --yluna
    and event_attributes:"0_ask_asset" = 'cw20:terra1dh9478k2qvqhqeajhn75a2a7dsnf74y5ukregw' --prism
    group by user_address
    )

    select table1.user_address, sum(table1.yluna_spent) as yluna_spent
    from table1
    group by user_address
    order by yluna_spent
    Run a query to Download Data