MoDeFiGPC - tokens trades liqudity week 2
    Updated 2025-02-25
    with tokens_data as (
    select *
    from $query('75f58bb3-b2cd-4208-85e9-e3d75d901a1c')
    ),

    tokens_supply as (
    select *
    from $query('d113b02b-ad6c-4fc4-8bfb-df28c696d7da')
    ),

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

    tokens_pools_balance as (
    select token_address, b.symbol, replace(pair_symbol,'WMATIC','WPOL') as pair_symbol, b.pool_address,
    sum(change) as balance
    from
    (select *, case when from_address in (select pool_address from tokens_pool) then from_address else to_address end as pool_address,
    case when from_address in (select pool_address from tokens_pool) then -AMOUNT_PRECISE else AMOUNT_PRECISE end change
    from polygon.core.ez_token_transfers
    where (from_address in (select pool_address from tokens_pool) or to_address in (select pool_address from tokens_pool))
    and contract_address in ('0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270','0xc2132d05d31c914a87c6611c10748aeb04b58e8f',
    '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619','0x2791bca1f2de4661ed88a30c99a7a9449aa84174','0x3c499c542cef5e3811e1192ce70d8cc03d5c3359')
    and BLOCK_TIMESTAMP>='2023-04-09'
    and from_address!=to_address
    union all
    select *, case when to_address in (select pool_address from tokens_pool) then to_address else from_address end as pool_address,
    case when to_address in (select pool_address from tokens_pool) then AMOUNT_PRECISE else -AMOUNT_PRECISE end change
    from polygon.core.ez_token_transfers
    where (from_address in (select pool_address from tokens_pool) and to_address in (select pool_address from tokens_pool))
    and contract_address in ('0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270','0xc2132d05d31c914a87c6611c10748aeb04b58e8f',
    '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619','0x2791bca1f2de4661ed88a30c99a7a9449aa84174','0x3c499c542cef5e3811e1192ce70d8cc03d5c3359')
    and BLOCK_TIMESTAMP>='2023-04-09'
    and from_address!=to_address) a
    QueryRunArchived: QueryRun has been archived