MLDZMNctoken3-swaps
    Updated 2022-08-04
    with tb1 as (select
    distinct SIGNERS[0] as wallets,
    tx_id,
    INNER_INSTRUCTIONS[0]:instructions[1]:parsed:info:mint as ctokens,
    INNER_INSTRUCTIONS[0]:instructions[1]:parsed:info:amount/1e6 as amount
    --PRE_TOKEN_BALANCES[1]:uiTokenAmount:uiAmount as amount


    from solana.fact_transactions
    where INSTRUCTIONS[0]:programId='So1endDq2YkqhipRh3WViPa8hdiSpxWy6z3Z6tMCpAo'
    and INNER_INSTRUCTIONS[0]:instructions[1]:parsed:info:mintAuthority='DdZR6zRFiUt4S5mg7AV1uKB2z1f1WzcNYCaTEEWPAuby'
    and INNER_INSTRUCTIONS[0]:instructions[1]:parsed:type='mintTo'
    and BLOCK_TIMESTAMP>=CURRENT_DATE-3 having amount is not null
    )

    select
    date_trunc('week',BLOCK_TIMESTAMP) as week,
    ADDRESS_NAME as tokens,
    count(tx_id) as swapfrom
    from solana.core.fact_swaps x join solana.core.dim_labels y on x.SWAP_FROM_MINT=y.ADDRESS
    where SWAP_FROM_MINT in (select ctokens from tb1)
    and BLOCK_TIMESTAMP>='2022-01-01'
    group by 1,2
    union all
    select
    date_trunc('week',BLOCK_TIMESTAMP) as week,
    ADDRESS_NAME as tokens,
    count(tx_id) as swapfrom
    from solana.core.fact_swaps x join solana.core.dim_labels y on x.SWAP_TO_MINT=y.ADDRESS
    where SWAP_FROM_MINT in (select ctokens from tb1)
    and BLOCK_TIMESTAMP>='2022-01-01'
    group by 1,2
    Run a query to Download Data