Updated 2023-11-24
    -- Treasury
    WITH WALLET_LIST AS (
    SELECT
    'MvYgbzyYqKPxPn5XVxiBTWReEsX4w52esLunKYQmvBW' AS TREASURY
    ),
    cte_date (date_rec) as (
    select
    to_date('2023-03-07')
    union
    all
    select
    to_date(dateadd(day, 1, date_rec)) --or week, month, week, hour, minute instead of day
    from
    cte_date
    where
    date_rec < CURRENT_DATE()
    ),
    INCOMING_HXD AS (
    SELECT
    BLOCK_TIMESTAMP,
    DATE_TRUNC('Day', BLOCK_TIMESTAMP) AS DAY,
    AMOUNT
    FROM
    solana.core.fact_transfers
    WHERE
    BLOCK_ID >= 181334924
    AND TX_TO IN (
    SELECT
    *
    FROM
    WALLET_LIST
    )
    AND MINT = '3dgCCb15HMQSA4Pn3Tfii5vRk7aRqTH95LJjxzsG2Mug'
    ),
    OUTGOING_HXD AS (
    SELECT