boomer77bluechip terra nft daily vol
    Updated 2022-02-14
    with re as (select msg_value,
    date(block_timestamp) as dates,
    msg_value:execute_msg:ledger_proxy:msg:execute_order:order:order:maker_asset:info:nft:contract_addr::string as nft_maker,
    msg_value:execute_msg:ledger_proxy:msg:execute_order:order:order:taker_asset:info:nft:contract_addr::string as nft_taker, case
    when nft_maker is not null then nft_maker
    when nft_maker is null then nft_taker end as nft_contract_address,
    (msg_value:execute_msg:ledger_proxy:msg:execute_order:order:order:taker_asset:amount::int)/1000000 as amount
    from terra.msgs
    where msg_value:contract::string = 'terra1eek0ymmhyzja60830xhzm7k7jkrk99a60q2z2t'
    and tx_status = 'SUCCEEDED'
    and (msg_value:execute_msg:execute_order is not null or msg_value:execute_msg:ledger_proxy:msg:execute_order is not null)
    ),

    randomearth as (select
    date_trunc('day', dates) as dt, nft_contract_address as NFTs, sum(round(amount,2)) as Volume
    from re
    where amount > 0.1 and dates >= CURRENT_DATE - 90 and nft_contract_address in ('terra103z9cnqm8psy0nyxqtugg6m7xnwvlkqdzm4s4k','terra1trn7mhgc9e2wfkm5mhr65p3eu7a2lc526uwny2')
    group by 1,2
    order by 1 desc),

    luart as (select block_timestamp, tx_id, event_attributes:nft_contract_address::string as NFTs, event_attributes:"1_token_id" as NFT_ID,
    event_attributes:price/1e6 as Price,
    event_attributes:denom::string as currency
    from terra.msg_events
    where event_type = 'wasm' and event_attributes:"1_sender"::string = 'terra1fj44gmt0rtphu623zxge7u3t85qy0jg6p5ucnk' and tx_status = 'SUCCEEDED'
    and event_attributes:method::string = 'execute_order'),

    luna_p as (select date_trunc('day', block_timestamp) as dt, currency, avg(price_usd) as luna
    from terra.oracle_prices
    where symbol in ('LUNA')
    group by 1,2),

    btc as (select date_trunc('day', block_timestamp) as dt, currency, avg(price_usd) as btc
    from terra.oracle_prices
    where symbol in ('mBTC')
    group by 1,2),
    Run a query to Download Data