SandeshTotal staked amount champs
    Updated 2024-11-20

    -- Description:
    -- This query performs a series of calculations to analyze token balances across two chains: Arbitrum and Ethereum.
    -- It computes supply metrics such as Total Supply, Locked Supply, Circulating Supply, and others.
    -- Key techniques include the use of CTEs, window functions, and filtering for specific user types (e.g., Gam3sg-controlled, contracts, EOAs).



    WITH dates AS (
    SELECT
    date_trunc('hour', date_day) AS date
    FROM ethereum.core.dim_dates
    WHERE date_day >= '2024-05-05'
    AND date_day <= date_day
    GROUP BY date
    ),
    -- CTE to calculate daily buy and sell amounts on BASE
    buy_sell_table AS (
    (
    SELECT
    date_trunc('hour', block_timestamp) AS date,
    to_address AS address,
    amount
    FROM base.core.ez_token_transfers
    WHERE 1=1 -- Placeholder for easy addition of conditions
    AND block_timestamp>= '2024-05-05'
    AND contract_address = LOWER('0xEb6d78148F001F3aA2f588997c5E102E489Ad341') -- token address of champ
    AND to_address=lower('0x56f9341eE2d2ede918BAEAAA6D236EEcEdA44468')
    )
    UNION ALL
    (
    SELECT
    date_trunc('hour', block_timestamp) AS date,
    from_address AS address,
    -1 * amount -- Negative amount for sell transactions
    QueryRunArchived: QueryRun has been archived