prbhvgupta2023-12-12 02:50 PM
    with transfers as (

    select
    date(block_timestamp) as date,
    trf.CONTRACT_ADDRESS as token_contract_address,
    trf.TX_HASH as transaction_hash,
    trf.FROM_ADDRESS as "from",
    trf.TO_ADDRESS as "to",
    cast(trf. RAW_AMOUNT as double) as value
    from optimism.core.fact_token_transfers trf
    where 1=1
    and date > '2023-11-23' and date < '2023-12-01'
    --trf.{{topics_length_column}} = 3
    and trf.CONTRACT_ADDRESS in
    ('0x7f5c764cbc14f9669b88837ca1490cca17c31607',
    '0xda10009cbd5d07dd0cecc66161fc93d7c9000da1',
    '0x94b008aa00579c1307b0ef2c499ad98a8ce58e58')

    ),

    transfer_in as (
    select
    date,
    token_contract_address,
    transaction_hash,
    "to" as address,
    sum(cast(value as double)) as amount_in
    from transfers
    -- AND cast(value as double) > 0
    group by 1,2,3,4
    ),
    transfer_out as (
    select
    date,
    token_contract_address,
    transaction_hash,
    Run a query to Download Data