MoDeFiGPC - tokens trades week 4 contracts
    Updated 2025-04-08
    with tokens_data as (
    select *
    from $query('75f58bb3-b2cd-4208-85e9-e3d75d901a1c')),

    tokens_pool as (
    select *
    from $query('998239b1-00be-4fa2-8c02-617cd563917c')
    ),

    holders as (
    select a.*, case when pool_address is not null then 'Pool' when user in (select address from polygon.core.dim_contracts) then 'Contract' end as tag,
    row_number() over (partition by contract order by case when tag is null then 0 else 1 end, balance desc) as rank,
    row_number() over (partition by contract order by case when tag='Contract' or tag is null then 0 else 1 end, balance desc) as rank_with_contracts
    from
    (select user, symbol, a.contract, sum(amount/pow(10, decimal)) as balance
    from
    (
    select from_address as user, -RAW_AMOUNT_PRECISE as amount, tx_hash, contract
    from polygon.core.fact_token_transfers
    join tokens_data b
    on contract=CONTRACT_ADDRESS
    where BLOCK_TIMESTAMP::date>=start_date
    and BLOCK_TIMESTAMP<date_trunc(hour, '2025-04-04 18:00:00.000'::timestamp)
    union all
    select to_address, RAW_AMOUNT_PRECISE, tx_hash, contract
    from polygon.core.fact_token_transfers
    join tokens_data
    on contract=CONTRACT_ADDRESS
    where BLOCK_TIMESTAMP::date>=start_date
    and BLOCK_TIMESTAMP<date_trunc(hour, '2025-04-04 18:00:00.000'::timestamp)
    ) a
    join tokens_data b
    on a.contract=b.contract
    group by 1,2,3) a
    left join tokens_pool
    on user=pool_address
    Last run: 20 days ago
    SYMBOL
    CONTRACT
    AVG_CONTRACTS
    MED_CONTRACTS
    1
    CHAI0x6f75b5b0d58b36e1c71e6132e2896414b2007b04159.1532
    2
    LZR0x2fc359fc903040ac5d34ff9d50802e1fe0ced8fe98.4130
    3
    UNT0x4538727d7198e06019986bf2e1f562b5efdca90959.3925.5
    4
    SUPPLAI0x15987d862fbc435ac8445e809ebb377fb418ef8e126.3444.5
    5
    BONSAI0x3d2bd0e15829aa5c362a4144fdf4a1112fa29b5c104.7729
    6
    TFI0x12322531e5d0bba8f6218d28c8a2b586245d0a3222
    7
    MOS0x572e6feff8cf6ef5ce9bcd3dde4ac1343f681d91127.7430
    8
    BORGER0x90880ee788963585525241bac32e7c99c3d0630f64.3323
    9
    NOCAP0xc1404a86d2c3a00a4946ee3289c6b238257be700122.8831
    10
    GC0x8248bbf4b8595eea60ee73ed8ef2765ae4b68fb2102.2228
    11
    PAWL0xb6ab4a4b329435094907190b541f4bd92f14ebe6144.7239
    12
    XENX0x0f29965ca5f1111b073efa37a739dd2fafab11e03.140
    13
    DDD0x4bf82cf0d6b2afc87367052b793097153c859d3877.2721
    14
    CHMP0x2213dde228f71f9d4fc7ac78bd0fa1aed6ff1f949.59.5
    15
    AGTRAMON0xd00d2bcc83126adbd086a855531451ffb0373db952.216
    16
    IGS0xe302672798d12e7f68c783db2c2d5e6b48ccf3ce77.7316
    17
    DONR2D20x97b2cb568e0880b99cd16efc6edff5272aa0267696.7620
    18
    JOBS0xd376cfc6baba795f8ce6e18b623ca0b6a227329d113.3833
    19
    KC0x784665471bb8b945b57a76a9200b109ee214e789679.438
    20
    NOMAD0xd7b0c417365b63f098c1c4ad2ced35982d648876133.6634
    63
    4KB
    2s