John_GaltpLuna Price on PS and A
    Updated 2022-06-03
    with table1 as (select -- this is for simple swaps where pluna is buying prism --First we start out with buys and sells on Prism Swap
    date_trunc('hour', block_timestamp) as day_hour,
    event_attributes:"offer_amount" / pow(10, 6) as pluna,
    event_attributes:"return_amount" / pow(10,6) as prism,
    prism / pluna as pluna_in_prism
    from terra.msg_events
    where date(block_timestamp) > '2022-03-30'
    and event_attributes:"0_to" = 'terra1persuahr6f8fm6nyup0xjc7aveaur89nwgs5vs'
    and event_attributes:"1_action" = 'swap'
    and event_index = 3
    and event_attributes:"ask_asset" = 'cw20:terra1dh9478k2qvqhqeajhn75a2a7dsnf74y5ukregw' --prism
    and event_attributes:"offer_asset" = 'cw20:terra1tlgelulz9pdkhls6uglfn5lmxarx7f2gxtdzh2' --pluna

    union all

    select -- this is for simple swaps where prism is buying pluna
    date_trunc('hour', block_timestamp) as day_hour,
    event_attributes:"return_amount" / pow(10,6) as pluna,
    event_attributes:"offer_amount" / pow(10, 6) as prism,
    prism / pluna as pluna_in_prism
    from terra.msg_events
    where date(block_timestamp) > '2022-03-30'
    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

    union all
    select
    date_trunc('hour', block_timestamp) as day_hour, -- this is for a routed transaction where pluna is buying prism
    event_attributes:"0_offer_amount" / pow(10, 6) as pluna,
    event_attributes:"0_return_amount" / pow(10,6) as prism,
    prism / pluna as pluna_in_prism
    from terra.msg_events
    Run a query to Download Data