Flipside Data ScienceThorchain Swap on AVAX
    Updated 2024-06-12
    with t0 as (
    SELECT distinct
    t.tx_hash as tx_id,
    t.block_timestamp as block_timestamp,
    t.origin_from_address as address,
    1 as action_count,
    1 as quest_step,
    'USDC' as currency,
    l.decoded_log:memo::string,
    t.amount ,
    case when amount > 0.008 then TRUE else FALSE end as valid,
    amount_usd as token_amount,
    tx.tx_fee as fee_amount

    FROM avalanche.core.ez_native_transfers t
    LEFT JOIN avalanche.core.fact_decoded_event_logs l
    on t.tx_hash = l.tx_hash
    LEFT JOIN avalanche.core.fact_transactions tx
    on t.tx_hash = tx.tx_hash


    WHERE
    l.event_name = 'Deposit'
    and l.decoded_log:memo::string ilike any ('s:%', 'swap:%', '=:%')
    -- and t.to_address = lower('0x8F66c4AE756BEbC49Ec8B81966DD8bba9f127549')
    and t.origin_function_signature in (
    '0x44bc937b'
    , '0xe4d0c7f0'
    , '0x08a018aa'
    , '0xdf759fce'
    , '0x972250fe'
    , '0x2541ec57'
    , '0x3d21e25a'
    , '0x1fece7b4'
    )
    and lower(t.origin_from_address) in (:userAddresses)