pecio222USERS by amount summary lfj aggregator using router events
    Updated 2025-06-18
    -- forked from USERS by size summary lfj aggregator using router events @ https://flipsidecrypto.xyz/studio/queries/4114a98d-c0c2-425f-87c1-a0e345712281

    -- forked from USERS summary lfj aggregator using router events @ https://flipsidecrypto.xyz/studio/queries/6dbd2b4c-a66b-4cfd-9d59-76c37c2e972b
    with all_events as (
    select
    block_timestamp,
    date_trunc('hour', block_timestamp) as hour,
    tx_hash,
    case
    when DECODED_LOG ['tokenIn'] = '0x0000000000000000000000000000000000000000' then '0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7'
    else DECODED_LOG ['tokenIn']
    end as token_in,
    case
    when DECODED_LOG ['tokenOut'] = '0x0000000000000000000000000000000000000000' then '0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7'
    else DECODED_LOG ['tokenOut']
    end as token_out,
    DECODED_LOG ['amountIn'] as amount_in,
    DECODED_LOG ['amountOut'] as amount_out,
    DECODED_LOG ['sender'] as user
    from
    avalanche.core.ez_decoded_event_logs
    where
    contract_address = lower('0x45a62b090df48243f12a21897e7ed91863e2c86b')
    and ORIGIN_TO_ADDRESS = lower('0x45a62b090df48243f12a21897e7ed91863e2c86b') --only directly with router, ignore LO etc
    and block_timestamp > TO_TIMESTAMP(1742947200) -- Wednesday, 26 March 2025 00:00:00
    ),
    all_txs as (
    select
    block_timestamp,
    tx_hash,
    case
    when concat('0x', substring(INPUT_DATA, 11 + 24, 40)) = '0xb35033d71cf5e13cab5eb8618260f94363dff9cf' then 'LFJ'
    when concat('0x', substring(INPUT_DATA, 11 + 24, 40)) = '0xc04f291347d21dc663f7646056db22bff8ce8430' then (
    CASE
    WHEN SUBSTRING(INPUT_DATA, 11 + 24 + 8 * 64 + 2 * 40, 40) = '88de50b233052e4fb783d4f6db78cc34fea3e9fc' THEN 'ODOS'
    WHEN SUBSTRING(INPUT_DATA, 11 + 24 + 8 * 64 + 2 * 40, 40) = '6131b5fae19ea4f9d964eac0408e4408b66337b5' THEN 'KYBER'
    Last run: 15 days ago
    LABEL
    VALUE
    1
    users_over_100_txs553
    2
    users_11_to_100_txs4668
    3
    users_2_to_10_txs16270
    4
    users_1_tx16342
    4
    106B
    11s