andurilSOL Transfer (Inflow) - Saga Wallets
    Updated 2023-12-20
    -- forked from Saga Wallet CEX Inflows @ https://flipsidecrypto.xyz/edit/queries/4a7703f1-1b83-4431-b7c2-aedd7e2f84e1

    with saga_minters as (
    select distinct
    signers[2] as minter
    FROM
    solana.core.fact_transactions
    WHERE
    date(block_timestamp) >= '2023-03-20'
    AND signers[0] = '7k5qzD2LLJCchakNG9wu9G3AvyFP7eWXBk4WbqgQypm6'
    AND signers[1] = 'D4v4527fUNT2CYgL4Wz7KnNLK3rTSd62ijQzYFYSjPTH'
    AND succeeded
    ),

    inflow_amounts as (
    select
    tx_to as wallet,
    sum(amount) as total_sol_inflow
    from
    solana.core.fact_transfers t
    where
    date(block_timestamp) between current_date()-31 and current_date()-1
    and mint = 'So11111111111111111111111111111111111111112'
    and tx_to in (select distinct minter from saga_minters)
    group by 1
    )


    SELECT
    CASE
    WHEN total_sol_inflow < 1 THEN 'Less than 1 SOL'
    WHEN total_sol_inflow BETWEEN 1 AND 10 THEN 'Between 1 and 10 SOL'
    WHEN total_sol_inflow BETWEEN 10 AND 100 THEN 'Between 10 and 100 SOL'
    WHEN total_sol_inflow BETWEEN 100 AND 1000 THEN 'Between 100 and 1000 SOL'
    ELSE 'Greater than 1000 SOL'
    END AS inflow_bucket,
    QueryRunArchived: QueryRun has been archived