mmdrezaorca rank
    Updated 2024-12-25
    -- forked from jackguy / silky-scarlet copy copy copy @ https://flipsidecrypto.xyz/jackguy/q/0c4a6-SYMFNE/silky-scarlet-copy-copy-copy

    WITH log_data AS (
    SELECT
    signers[0] as wallet,
    tx_id as tx
    FROM
    eclipse.core.fact_transactions t,
    TABLE(FLATTEN(log_messages)) f
    WHERE SUCCEEDED
    AND value in ('Program log: Instruction: SwapV2', 'Program log: Instruction: TwoHopSwapV2')
    ), tab1 as (
    SELECT
    tx_id,
    block_timestamp,
    wallet,
    mint as mint_out,
    amount/power(10, decimal) as out_amount
    from eclipse.core.fact_transfers
    left outer join log_data
    on tx = tx_id
    where tx_id in (SELECT tx from log_data)
    and wallet = tx_to
    ), tab2 as (
    SELECT
    tx_id as tx,
    mint as mint_in,
    amount/power(10, decimal) as in_amount
    from eclipse.core.fact_transfers
    left outer join log_data
    on tx = tx_id
    where tx_id in (SELECT tx from log_data)
    and wallet = tx_from
    ), tab3 as (
    QueryRunArchived: QueryRun has been archived