sam[1124] CoW protocol
    Updated 2024-11-29
    with eth_orders as (

    select
    block_timestamp,
    event_index,
    tx_hash,
    decoded_log:order:buyAmount::int as buy_amount,
    decoded_log:order:buyToken::string as buy_token,
    decoded_log:order:sellAmount::int as sell_amount,
    decoded_log:order:sellToken::string as sell_token,
    decoded_log:order:feeAmount::int as fee,
    decoded_log:order:receiver::string as swapper,
    decoded_log:order:partiallyFillable as is_partial


    from ethereum.core.ez_decoded_event_logs
    where tx_hash = '0x543fb1944b1c5b4fe76977f14d2803ce016ad2082c7bcc7a699de3396578cc4e'
    and block_timestamp::date >= '2024-11-11'
    and event_name = 'OrderPlacement'
    and contract_address = '0x40a50cf069e992aa4536211b23f286ef88752187'
    ),

    eth_orderhash as (
    select
    tx_hash,
    trace_index,
    output
    from ethereum.core.fact_traces
    where tx_hash = '0x543fb1944b1c5b4fe76977f14d2803ce016ad2082c7bcc7a699de3396578cc4e'
    and block_timestamp::date >= '2024-11-11'
    and to_address = '0x40a50cf069e992aa4536211b23f286ef88752187'
    and left(input, 10) = '0x322bba21'
    ),


    trades as (
    QueryRunArchived: QueryRun has been archived