rezarwzsimulate the distribution of points among users
    Updated 2023-12-14
    with pol as (
    SELECT
    'pol' AS network,
    ua,
    SUM(v) AS total_v,
    SUM(t) AS total_t,
    d
    FROM
    (
    SELECT
    ev.ORIGIN_FROM_ADDRESS as ua,
    COALESCE(SUM(ma.AMOUNT_USD), 0) + COALESCE(SUM(tr.AMOUNT_USD), 0) as v,
    count(DISTINCT ev.tx_hash) as t,
    date_trunc('month', ev.BLOCK_TIMESTAMP) as d
    FROM
    polygon.core.ez_decoded_event_logs ev
    left JOIN polygon.core.ez_matic_transfers ma on ma.tx_hash = ev.tx_hash
    and ev.ORIGIN_FROM_ADDRESS = ma.matic_from_address
    left join polygon.core.ez_token_transfers tr on tr.tx_hash = ev.tx_hash
    and ev.ORIGIN_FROM_ADDRESS = tr.from_address
    where
    ev.block_number >= 42020325
    and ev.contract_Address = '0x3a23f943181408eac424116af7b7790c94cb97a5'
    and event_name in ('SocketBridge', 'SocketSwapTokens')
    and DECODED_LOG:metadata = '0x00000000000000000000000000000000000000000000000000000000000000cd'
    GROUP by
    1,
    4
    UNION
    all
    SELECT
    matic_From_address as ua,
    sum(amount_usd) as v,
    count(DISTINCT tx_hash) as t,
    date_trunc('month', ez.BLOCK_TIMESTAMP) as d
    from
    Run a query to Download Data