Flipside Data ScienceProvide ggAVAX Liquidity on Pharaoh
    Updated 2024-07-08
    WITH t0 AS (
    SELECT
    ds.block_timestamp,
    ds.tx_hash as tx_id,
    1 as action_count,
    LOWER(ds.origin_from_address) as address,
    TRUE as valid,
    1 as quest_step,
    'AVAX' as currency,
    amount_usd as usd_amount,
    ds.amount as raw_token_amount,
    usd_amount / ap.price as token_amount,
    tx.tx_fee as fee_amount,
    ROW_NUMBER() OVER (
    PARTITION BY address
    ORDER BY
    ap.hour DESC
    ) AS rn
    FROM
    avalanche.core.ez_token_transfers ds
    LEFT JOIN avalanche.core.fact_transactions tx on ds.tx_hash = tx.tx_hash
    LEFT JOIN avalanche.PRICE.ez_prices_hourly ap ON ap.hour = date_trunc('hour', ds.block_timestamp)
    and ap.token_address = lower('0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7')
    WHERE
    ds.from_address = ds.origin_from_address
    and ds.origin_to_address = '0xaaa78e8c4241990b4ce159e105da08129345946a'
    and ds.contract_address = '0xa25eaf2906fa1a3a13edac9b9657108af7b703e3'
    and ds.origin_from_address in (:userAddresses)
    and ds.block_timestamp :: date >= :startsAt
    and tx.block_timestamp :: date >= :startsAt
    )
    SELECT
    ':questId' as quest_id,
    block_timestamp,
    tx_id,
    action_count,
    QueryRunArchived: QueryRun has been archived