pecio222summary all orders with values
    Updated 2025-07-01
    with all_orders as (
    select
    block_timestamp,
    tx_hash,
    data,
    origin_from_address,
    case
    when topic_0 = '0xd3955b947a583716b4e04990ee4386c1bd0259aa58196533648dd1f74f322de9' then 'LimitOrderCanceled'
    when topic_0 = '0x72af4e3dd5d4c62ccbd4b91788afb636b00e7d46767240f4e9e065ad8d0b0fd3' then 'LimitOrderExecuted'
    when topic_0 = '0x89a6c0f009ae9db477ba7ef7c650a04c2b7d25e7d3b091ef6d6d698bc9e07a64' then 'LimitOrderPosted'
    when topic_0 = '0x5f5b8c240ce1e7c4c8e2942d6ad73b50e9224df9f50a27c1fd96b7c3a0c581e0' then 'RecurringOrderCanceled'
    when topic_0 = '0x1a0e338cbd463542135cbd63861ab659dd2a4ed55ac612dbd753d9ec0865e7c7' then 'RecurringOrderExecuted'
    when topic_0 = '0x6225945cd9908b36744d3f282f6decbcd16acac932e2d580843d29e984ef3e20' then 'RecurringOrderPosted'
    when topic_0 = '0xa0b760a55882ac810ef7a1f4f55a701022cf232a8a257f32c87d43b52ac6438c' then 'StopLimitOrderCanceled'
    when topic_0 = '0xd4f5780f8e15932a9be75ffb83a49d86ea9129da71b73a9b96a78b0cb5697188' then 'StopLimitOrderExecuted'
    when topic_0 = '0x19ab3e2eed00568e54168d944e18f1d5c1e0dd1af6c2c65a10206b62250807cf' then 'StopLimitOrderPosted'
    else 'others'
    end as order_type
    from
    avalanche.core.fact_event_logs
    where
    contract_address = lower('0x03Cf7a8238dA2239BDDE9349f41fa14A81d3Af3d')
    and block_timestamp > to_timestamp(1750118400)
    ),
    decoded_executed as (
    select
    *,
    concat('0x', substring(data, 3 + 0 * 64 + 24, 40)) as owner,
    concat('0x', substring(data, 3 + 1 * 64 + 24, 40)) as token_in,
    concat('0x', substring(data, 3 + 2 * 64 + 24, 40)) as token_out,
    case
    when order_type = 'RecurringOrderExecuted' then utils.udf_hex_to_int (substring(data, 3 + 8 * 64, 64))
    when order_type = 'LimitOrderExecuted' then utils.udf_hex_to_int (substring(data, 3 + 6 * 64, 64))
    when order_type = 'StopLimitOrderExecuted' then utils.udf_hex_to_int (substring(data, 3 + 8 * 64, 64))
    end as amount_in_executed,
    case
    Last run: 13 days ago
    ORDERS
    USD_VALUE_EXECUTED
    FEE_USD_VALUE
    1
    Limit Orders219558.9426835965823.135626527
    2
    Recurring Orders266479.7458803592664.79786826
    3
    Stop Limit Orders933.6385404779.336386455
    3
    150B
    37s