winnie-fsPrivate query - private copy
    Updated 2024-03-07
    -- forked from Private query - private @ https://flipsidecrypto.xyz/edit/queries/d9ffc58b-8fc3-48b9-bf64-0560fe81b11a

    -- forked from cadmusbenedictus / YES Balances @ https://flipsidecrypto.xyz/cadmusbenedictus/q/aLHczm2J_ULy/yes-balances

    WITH base_transfers AS (
    SELECT
    from_address,
    to_address,
    AMOUNT_PRECISE
    FROM
    blast.core.ez_token_transfers
    WHERE
    contract_address = lower('0x20fE91f17ec9080E3caC2d688b4EcB48C5aC3a9C')
    ),
    inbound AS (
    SELECT
    to_address AS wallet,
    SUM(AMOUNT_PRECISE) AS tokens_in
    FROM
    base_transfers
    GROUP BY
    wallet
    ),
    outbound AS (
    SELECT
    from_address AS wallet,
    SUM(AMOUNT_PRECISE) AS tokens_out
    FROM
    base_transfers
    WHERE
    to_address <> lower('0x14eB8d9b6e19842B5930030B18c50B0391561f27')
    GROUP BY
    wallet
    ),
    looped_assets AS (
    SELECT
    QueryRunArchived: QueryRun has been archived