BlockTrackermain query
    Updated 2025-01-08
    with invariant_txs as (
    select
    tx_id ,
    signers[0] as swapper
    from eclipse.core.fact_events
    where program_id = 'iNvTyprs4TX8m6UeUEkeqDFjAL9zRCRWcexK9Sd4WEU'
    and block_timestamp::date >= '2024-10-22'
    )
    , swap_txs as (
    select
    tx_id ,
    swapper
    from eclipse.core.fact_transactions
    join invariant_txs using(tx_id)
    join LATERAL FLATTEN (log_messages) as f
    where
    f.value IN ('Program log: INVARIANT: SWAP','Program log: Instruction: Swap')
    --and tx_id = 'B7NSwxgpB9HwdySaE1QsUpiTDvQhZSiSNY6DBEaz28RV5wAbRJydb2mGwoRyR9L4Sfk3uM73h96WNSYPQ9YqYim'
    and block_timestamp::date >= '2024-10-22'
    )
    ,
    swap_asc_tx as (
    select
    *
    from eclipse.core.fact_transfers
    join swap_txs using(tx_id)
    where block_timestamp::date >= '2024-10-22'
    and SUCCEEDED
    qualify row_number () over (partition by tx_id order by inner_index desc) = 1
    )
    ,
    swap_desc_tx as (
    select
    *
    from eclipse.core.fact_transfers
    join swap_txs using(tx_id)