jackguymgprwmpweomgmwempowemgpwem[
    Updated 2023-04-10
    with tab1 as (
    SELECT tx_hash
    FROM polygon.core.fact_token_transfers
    LEFT OUTER JOIN ethereum.core.dim_contracts
    on address = contract_address
    WHERE to_address LIKE lower('0xce16f69375520ab01377ce7b88f5ba8c48f8d666')
    AND SYMBOL LIKE 'USDC'
    --LIMIT 100
    ), tab2 as (
    SELECT
    date_trunc('day', block_timestamp) as day,
    to_chain,
    sum(USDC_AMOUNT) as volume,
    count(*) as transactions
    FROM (
    SELECT
    block_timestamp,
    DECODED_LOG:amount / power(10, 6) as usdc_amount,
    DECODED_LOG:destinationChain AS to_chain,
    'Ethereum' as from_chain,
    DECODED_LOG:refundAddress as sender
    FROM ethereum.core.fact_decoded_event_logs
    WHERE EVENT_NAME LIKE 'NativeGasPaidForContractCallWithToken'
    AND tx_hash in (SELECT * FROM tab1)
    )
    GROUP BY 1,2
    )


    SELECT --*
    -- tx_hash,
    date_trunc('day', block_timestamp) as day,
    CASE when from_address LIKE lower('0x99a58482BD75cbab83b27EC03CA68fF489b5788f') then 'Curve.fi'
    when project_name is NULL OR project_name in ('coinbase', 'idex') then 'no dex swap' else project_name end as dex,
    sum(raw_amount / power(10, 6)) as volume,
    count(DISTINCT tx_hash) as events
    Run a query to Download Data