John_GaltThe pLuna Cartel
    Updated 2022-03-15
    with table1 as (select -- buying pluna
    TO_CHAR(block_timestamp, 'YYYY-MM-DD"T"HH24') as date,
    event_attributes:"return_amount" / pow(10,6) as pluna_received
    from terra.msg_events
    where block_timestamp > '2022-02-10'
    and event_attributes:"0_to" = 'terra1persuahr6f8fm6nyup0xjc7aveaur89nwgs5vs'
    and event_attributes:"1_action" = 'swap'
    and event_index = 3
    and event_attributes:"ask_asset" = 'cw20:terra1tlgelulz9pdkhls6uglfn5lmxarx7f2gxtdzh2' --pluna
    and event_attributes:"offer_asset" = 'cw20:terra1dh9478k2qvqhqeajhn75a2a7dsnf74y5ukregw' --prism
    and (event_attributes:receiver = 'terra1nw9n3cr2xpn0wgzsr5myymwmwzxwhrmru2zh7m'
    or event_attributes:receiver = 'terra1qlza4svxszm7c2j6ll2z2nd6pa55dm2ud79jzu'
    or event_attributes:receiver = 'terra1rt4tuw8s7qxg24c2e00z8m8lpygeszpn5n8sch'
    or event_attributes:receiver = 'terra1eklvz8zp52rygj5x5d6pj0fgr0a9uucv68mlrm'
    or event_attributes:receiver = 'terra1e5ncelsh4qhqt3s97vn43hxlhmt7zd43yszdnf')
    union all
    select
    TO_CHAR(block_timestamp, 'YYYY-MM-DD"T"HH24') as date, --
    event_attributes:"1_return_amount" / pow(10,6) as pluna_received
    from terra.msg_events
    where block_timestamp > '2022-02-10'
    and event_attributes:"2_to" = 'terra1persuahr6f8fm6nyup0xjc7aveaur89nwgs5vs'
    and event_index = 3
    and event_attributes:"4_action" = 'swap'
    and event_attributes:"1_offer_asset" = 'cw20:terra1dh9478k2qvqhqeajhn75a2a7dsnf74y5ukregw' --prism
    and event_attributes:"1_ask_asset" = 'cw20:terra1tlgelulz9pdkhls6uglfn5lmxarx7f2gxtdzh2' --pluna
    and (event_attributes:"1_receiver" = 'terra1nw9n3cr2xpn0wgzsr5myymwmwzxwhrmru2zh7m'
    or event_attributes:"1_receiver" = 'terra1qlza4svxszm7c2j6ll2z2nd6pa55dm2ud79jzu'
    or event_attributes:"1_receiver" = 'terra1rt4tuw8s7qxg24c2e00z8m8lpygeszpn5n8sch'
    or event_attributes:"1_receiver" = 'terra1eklvz8zp52rygj5x5d6pj0fgr0a9uucv68mlrm'
    or event_attributes:"1_receiver" = 'terra1e5ncelsh4qhqt3s97vn43hxlhmt7zd43yszdnf')
    union all

    Run a query to Download Data