cybergenlabTop 50 $GMX holders
    Updated 2024-03-08
    --Note to self the origing_to_address and origin_from_address cannot be used here (false address)

    with token_flow as (
    select
    --tx_hash,
    concat('0x', right(get(topics, 2), 40)) as address, -- get to address from log
    --ethereum.public.udf_hex_to_int(data) / pow(10,18) as amount, --get amount from log
    utils.udf_hex_to_int(data) / pow(10,18) as amount -- get amount from log (link: https://docs.flipsidecrypto.com/products/get-started/examples/utility-functions/hex-converters#udf_hex_to_string)
    from arbitrum.core.fact_event_logs
    where contract_address = '0xfc5a1a6eb076a2c7ad06ed22c90d7e710e35ad0a'
    and get(topics, 0) = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' --Transfer
    and concat('0x', right(get(topics, 2), 40)) != '0x908c4d94d34924765f1edc22a1dd098397c59dd4'
    --and tx_hash= '0xc2623dcb4dc13c519d8d485ac04a3e4c58ccee527440f01fb5a5029b91c57d21'
    union all
    select
    -- tx_hash,
    concat('0x', right(get(topics, 1), 40)) as address, -- get from address from log
    - (utils.udf_hex_to_int(data) / pow(10,18)) as amount -- get amount from log (link: https://docs.flipsidecrypto.com/products/get-started/examples/utility-functions/hex-converters#udf_hex_to_string)
    from arbitrum.core.fact_event_logs
    where contract_address = '0xfc5a1a6eb076a2c7ad06ed22c90d7e710e35ad0a'
    and get(topics, 0) = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' --Transfer
    and concat('0x', right(get(topics, 2), 40)) != '0x908c4d94d34924765f1edc22a1dd098397c59dd4'
    --and tx_hash= '0xc2623dcb4dc13c519d8d485ac04a3e4c58ccee527440f01fb5a5029b91c57d21'
    ),

    staking_flow as (
    -- see algo page for explanation
    select
    concat('0x', right(get(topics, 2), 40)) as address, -- get to address from log
    utils.udf_hex_to_int(data) / pow(10,18) as amount -- get amount from log (link: https://docs.flipsidecrypto.com/products/get-started/examples/utility-functions/hex-converters#udf_hex_to_string)
    from arbitrum.core.fact_event_logs
    where contract_address = '0xfc5a1a6eb076a2c7ad06ed22c90d7e710e35ad0a'
    and get(topics, 0) = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' --Transfer
    QueryRunArchived: QueryRun has been archived