SpecterSingle and multi-outcome markets
    Updated 2024-11-04
    -- forked from Summary @ https://flipsidecrypto.xyz/studio/queries/1335fcb2-5caf-47e0-b8b0-0543acd1c0c9

    WITH predictfun AS (
    SELECT
    tx_hash, block_timestamp,
    decoded_log:taker as taker,
    decoded_log:maker as maker, 'Single' AS Type,
    CASE
    WHEN decoded_log:takerAssetId = 0 then decoded_log:takerAmountFilled
    when decoded_log:makerAssetId = 0 then decoded_log:makerAmountFilled
    end / 1e18 as Amount_USD,
    decoded_log:fee / 1e18 as fee_usd,
    FROM blast.core.fact_decoded_event_logs
    where contract_address in ('0x739f0331594029064c252559436edce0e468e37a')
    --and tx_hash = '0x9723decd36215e9b6433246cfe8437c44a3d3de416a1bd113aef408b1a098f36'
    AND event_name = 'OrderFilled'

    UNION ALL

    SELECT
    tx_hash, block_timestamp,
    decoded_log:taker as taker,
    decoded_log:maker as maker, 'Multi' AS Type,
    CASE
    WHEN decoded_log:takerAssetId = 0 then decoded_log:takerAmountFilled
    when decoded_log:makerAssetId = 0 then decoded_log:makerAmountFilled
    end / 1e18 as Amount_USD,
    decoded_log:fee / 1e18 as fee_usd,
    FROM blast.core.fact_decoded_event_logs
    where contract_address in ('0x6a3796c21e733a3016bc0ba41edf763016247e72')
    --and tx_hash = '0x9723decd36215e9b6433246cfe8437c44a3d3de416a1bd113aef408b1a098f36'
    AND event_name = 'OrderFilled'
    )

    SELECT DATE_TRUNC('day', block_timestamp) AS date, type,
    COUNT(DISTINCT tx_hash) AS transactions,
    QueryRunArchived: QueryRun has been archived