ChiefFleet Payments
    Updated 2023-05-03
    -- forked from Top Payments @ https://flipsidecrypto.xyz/edit/queries/57cd0ad1-7a02-4065-9e88-a6f53b2c7332

    -- SELECT
    -- instructions[0]:programId as program_id,
    -- *
    -- FROM solana.core.fact_transactions
    -- WHERE instructions[0]:programId = 'EEjwuvCMVYjgHUeX1BM9qmUog59Pft88c3jbt2ATwcJw'
    -- LIMIT 50

    with info as (
    SELECT
    tx_id,
    date_trunc('hour', block_timestamp) as date,
    flattened.value:pubkey as wallet,
    PARSE_JSON(inner_instructions[0]:instructions[1]:parsed:info:amount::int) / POW(10, 9) as amount,
    instructions[0]:programId as program_id
    FROM
    solana.core.fact_transactions t, LATERAL FLATTEN(account_keys) flattened
    -- JOIN program
    -- ON t.tx_id = program.tx_id
    -- AND block_timestamp > current_date - 5
    WHERE 1=1
    AND PARSE_JSON(inner_instructions[0]:instructions[1]:parsed:info:amount::int) > 0
    AND flattened.index = 5
    AND instructions[0]:programId = 'AFMLFi8Mh1yehDsE1gTQs5xcJcMN39cvzSorpU152HaE'
    -- AND block_timestamp BETWEEN current_date - 30 AND current_date - 90
    ),
    prices as (
    SELECT
    symbol,
    close,
    recorded_hour
    FROM
    solana.core.ez_token_prices_hourly
    WHERE
    token_address = '4vMsoUT2BWatFweudnQM1xedRLfJgJ7hswhcpz4xgBTy'
    Run a query to Download Data