SocioAnalyticaTop bettor by Total Profit
    Updated 2024-06-21
    with all_azuro_tx as (
    SELECT
    DISTINCT tx_hash
    FROM polygon.core.ez_decoded_event_logs
    WHERE contract_name ilike '%Azuro%'
    AND block_timestamp::date >= '2023-01-01'
    AND
    TX_STATUS = 'SUCCESS'
    )
    ,
    azuro_NewBet as (
    SELECT
    block_timestamp,
    block_number,
    a.tx_hash,
    event_index,
    contract_address,
    decoded_log:affiliate as affiliate,
    decoded_log:amount/1e6 as amount,
    decoded_log:bettor as bettor,
    decoded_log:conditionId as conditionId,
    decoded_log:funds as funds,
    decoded_log:odds/1e12 as odds,
    decoded_log:outcomeId as outcomeid,
    decoded_log:tokenId as tokenId
    FROM polygon.core.ez_decoded_event_logs a
    JOIN all_azuro_tx b ON a.tx_hash = b.tx_hash
    WHERE event_name = 'NewBet'
    AND block_timestamp::date >= '2023-01-01'
    AND
    TX_STATUS = 'SUCCESS'
    )
    ,
    bettor_win as (
    SELECT
    block_timestamp,
    QueryRunArchived: QueryRun has been archived