Afonso_Diaz2023-10-24 09:04 PM
    Updated 2023-10-24
    with

    t1 as (
    select distinct tx_id
    from sei.core.fact_msg_attributes
    where attribute_key = '_contract_address'
    and msg_type = 'wasm-execute-exchange'
    and attribute_value = 'sei1pdwlx9h8nc3fp6073mweug654wfkxjaelgkum0a9wtsktwuydw5sduczvz'
    and tx_succeeded = 1
    ),

    t2 as (
    select
    tx_id,
    a.block_timestamp,
    a.attribute_value / 1e6 as amount_sei,
    b.attribute_value as seller,
    c.tx_from as buyer,
    (replace(fee, 'usei') / 1e6)::float as fee_sei
    from sei.core.fact_msg_attributes a
    join sei.core.fact_msg_attributes b
    using(tx_id, block_timestamp)
    join sei.core.fact_transactions c
    using(tx_id, block_timestamp)
    where a.attribute_key = 'exchange-token-amount'
    and a.msg_type = 'wasm-accept-request'
    and b.attribute_key = 'seller'
    and b.msg_type = 'wasm-accept-request'
    and b.msg_index = 12
    and tx_id in (select distinct tx_id from t1)
    ),

    t3 as (
    select
    seller as user,
    count(distinct tx_id) as transactions
    Run a query to Download Data