Lordkingpolygon cex
    Updated 2022-09-25
    with
    cex_polygon as
    ( select
    address,
    -- case when LABEL_SUBTYPE like '%group%' then 'others' else LABEL_SUBTYPE end as label,
    PROJECT_NAME as LABEL
    from polygon.core.dim_labels
    where LABEL_TYPE = 'cex' )

    , ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    inflow_polygon as
    (select
    BLOCK_TIMESTAMP::date as date ,
    count(distinct ORIGIN_FROM_ADDRESS) as address ,
    count(distinct TX_HASH) as trxs ,
    sum(AMOUNT) as volume ,
    sum(AMOUNT_USD) as USD ,
    LABEL ,
    'inflow_polygon' as title
    from
    polygon.core.ez_matic_transfers inner join cex_polygon
    on ORIGIN_TO_ADDRESS = address
    where BLOCK_TIMESTAMP::date > CURRENT_DATE -10

    group by date ,title ,label )

    , ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    outflow_polygon as
    (select
    BLOCK_TIMESTAMP::date as date ,
    count(distinct ORIGIN_FROM_ADDRESS) as address ,
    count(distinct TX_HASH) as trxs ,
    sum(AMOUNT) as volume ,
    sum(AMOUNT_USD) as USD ,
    LABEL ,
    'outflow_polygon' as title
    Run a query to Download Data