samGmx liquidations on avalanche
    Updated 2022-08-17

    with liquidation_raw_labeled as (

    select
    block_timestamp,
    tx_hash,
    concat ( '0x', split ( substr(data, 67, 192) , '000000000000000000000000')[1] ) as user_that_provided_collateral,
    concat ( '0x', split ( substr(data, 67, 192) , '000000000000000000000000')[2] ) as collateral_token,
    l.address_name as collateral_token_name,
    concat ( '0x', split ( substr(data, 67, 192) , '000000000000000000000000')[3] ) as token_that_was_ls,
    m.address_name as token_that_was_ls_name,
    case
    when substr(data, 259, 64) = '0000000000000000000000000000000000000000000000000000000000000000' then 'Short'
    else 'Long' end as position_type
    from avalanche.core.fact_event_logs e

    left join avalanche.core.dim_labels l on concat ( '0x', split ( substr(data, 67, 192) , '000000000000000000000000')[2] ) = l.address
    left join avalanche.core.dim_labels m on concat ( '0x', split ( substr(data, 67, 192) ,'000000000000000000000000')[3] ) = m.address

    where 1 = 1
    and origin_function_signature = '0xde2ea948' -- liquidate function
    -- and tx_hash = '0x28d0934e87be33274abd4da3ac06bce6cfe846840ba566ca514dc5a8a4d538bc'
    and topics[0] in
    (
    '0x2e1f85a64a2f22cf2f0c42584e7c919ed4abe8d53675cff0f62bf1e95a1c676f' -- fully liquidate
    ,
    '0x93d75d64d1f84fc6f430a64fc578bdd4c1e090e90ea2d51773e626d19de56d30' -- correct
    ) -- partially liquidate
    and l.address_name is not null
    ),

    unlabeled_transactions as (
    select
    tx_hash from liquidation_raw_labeled
    Run a query to Download Data