MOHAMAD23mamal Query
    Updated 2022-08-25
    WITH sports AS (
    SELECT
    concat('0x',substr(data,27,40)) AS market
    , ethereum.public.udf_hex_to_int(substr(data,3+17*64,64)) AS sport_code
    from
    optimism.core.fact_event_logs
    where
    contract_address = '0x2b91c14ce9aa828ed124d12541452a017d8a2148'
    AND topics[0] = '0x889e2060e46779287c2fcbf489c195ef20f5b44a74e3dcb58d491ae073c1370f'
    -- AND BLOCK_TIMESTAMP >= CURRENT_DATE - 14
    -- AND BLOCK_TIMESTAMP < CURRENT_DATE
    -- AND ORIGIN_FUNCTION_SIGNATURE = '0xac2c957c'
    ),
    markets AS (
    SELECT
    FROM_ADDRESS,
    TX_HASH,
    concat('0x',SUBSTR(INPUT_DATA, 35, 40)) as market,
    CASE
    WHEN
    ethereum.public.udf_hex_to_int(SUBSTR(INPUT_DATA, 203, 64))/pow(10,18) > 0.001
    THEN ethereum.public.udf_hex_to_int(SUBSTR(INPUT_DATA, 203, 64))/pow(10,18)
    ELSE ethereum.public.udf_hex_to_int(SUBSTR(INPUT_DATA, 203, 64))/pow(10,6)
    END AS amounts
    FROM optimism.core.fact_transactions
    WHERE TO_ADDRESS = lower('0x170a5714112daeff20e798b6e92e25b86ea603c1')
    AND BLOCK_TIMESTAMP >= CURRENT_DATE - 14
    AND BLOCK_TIMESTAMP < CURRENT_DATE
    ),
    bet_in AS (
    SELECT
    FROM_ADDRESS,
    -- TX_HASH,
    market,
    Run a query to Download Data