DiamondProd EM Daily Unique + First Time Traders Overall
    Updated 2023-06-05
    WITH
    a as (
    select
    BLOCK_TIMESTAMP,
    to_date(BLOCK_TIMESTAMP) as SessDate,
    LEFT_SWAP_USER.value:value:value as LEFT_SWAP_USER,
    RIGHT_SWAP_USER.value:value:value as RIGHT_SWAP_USER,
    f.*
    from
    FLOW.CORE.FACT_EVENTS,
    table (flatten(event_data)) f,
    LATERAL flatten(ARRAY_SLICE(parse_json(f.Value), 3, 4)) AS LEFT_SWAP_USER,
    LATERAL flatten(ARRAY_SLICE(parse_json(f.Value), 5, 6)) AS RIGHT_SWAP_USER
    where
    event_contract IN ('A.9066631feda9e518.Swap')
    and event_type = 'ProposalExecuted'
    and TX_SUCCEEDED = TRUE
    ),
    user_swaps AS (
    SELECT
    SessDate,
    SWAP_USER AS SWAP_USER
    FROM
    (
    select
    SessDate,
    LEFT_SWAP_USER as SWAP_USER
    from
    a
    UNION
    select
    SessDate,
    RIGHT_SWAP_USER as SWAP_USER
    from
    a
    )
    Run a query to Download Data