WITH markets AS (
SELECT
DISTINCT event_inputs:addr as market_address
FROM polygon.core.fact_event_logs
WHERE origin_to_address = '0xc040f84cf7046409f92d578ef9040fe45e6ef4be'
AND event_name = 'MarketCreated'
), txs AS (
SELECT
b.block_timestamp,
b.from_address as user,
b.tx_hash,
a.*
FROM markets as a JOIN polygon.core.fact_transactions as b on a.market_address = b.to_address
)
SELECT
count(DISTINCT tx_hash) as "Transaction Count",
count(DISTINCT user) as "User Count"
FROM txs
WHERE block_timestamp > CURRENT_DATE - 90