John_GaltxPRISM Bid Orders (Denominated in PRISM)
    Updated 2022-07-07
    with xprism_bid as (select
    block_timestamp as date,
    event_attributes:order_id as order_id,
    event_attributes:bidder_addr as address,
    SPLIT_PART(event_attributes:offer_asset, ':', 3) / pow(10, 6) as prism_offered,
    SPLIT_PART(event_attributes:ask_asset, ':', 3) / pow(10, 6) as xprism_asked,
    prism_offered / xprism_asked as execute_price
    from terra.msg_events
    where date(block_timestamp) > '2022-04-23'
    and event_attributes:"0_contract_address" = 'terra1zctyc83qmcunc5zww7hzgzmrtxhjhsj4kfgvg6'
    and event_attributes:"0_action" = 'submit_order'
    and SPLIT_PART(event_attributes:offer_asset, ':', 2) = 'terra1dh9478k2qvqhqeajhn75a2a7dsnf74y5ukregw' -- prism token
    and SPLIT_PART(event_attributes:ask_asset, ':', 2) = 'terra1042wzrwg2uk6jqxjm34ysqquyr9esdgm5qyswz' -- xprism token
    and event_index = 3
    ),

    xprism_ask as (select
    block_timestamp as date,
    event_attributes:order_id as order_id,
    event_attributes:bidder_addr as address,
    SPLIT_PART(event_attributes:offer_asset, ':', 3) / pow(10, 6) as xprism_offered,
    SPLIT_PART(event_attributes:ask_asset, ':', 3) / pow(10, 6) as prism_asked,
    prism_asked / xprism_offered as execute_price
    from terra.msg_events
    where date(block_timestamp) > '2022-04-23'
    and event_attributes:"0_contract_address" = 'terra1zctyc83qmcunc5zww7hzgzmrtxhjhsj4kfgvg6'
    and event_attributes:"0_action" = 'submit_order'
    and SPLIT_PART(event_attributes:offer_asset, ':', 2) = 'terra1042wzrwg2uk6jqxjm34ysqquyr9esdgm5qyswz' -- xprism token
    and SPLIT_PART(event_attributes:ask_asset, ':', 2) = 'terra1dh9478k2qvqhqeajhn75a2a7dsnf74y5ukregw' -- prism token
    and event_index = 3
    ),

    order_check as (select
    block_timestamp as date,
    event_attributes:order_id as order_id,
    event_attributes:"0_action" as token_action,