diff --git a/functions/src/scripts/contest/create-markets.ts b/functions/src/scripts/contest/create-markets.ts index d5e54faa..a7fb9932 100644 --- a/functions/src/scripts/contest/create-markets.ts +++ b/functions/src/scripts/contest/create-markets.ts @@ -6,8 +6,6 @@ import { data } from './criticism-and-red-teaming' // const API_KEY = '188f014c-0ba2-4c35-9e6d-88252e281dbf' // DEV API key for Criticism and Red Teaming (@CARTBot) const API_KEY = '6ff1f78a-32fe-43b2-b31b-9e3c78c5f18c' -// Prod API key for @CEPBot -// const API_KEY = 'b5cc8c88-64a3-45fe-a6b5-ac6a224ac56a' type CEPSubmission = { title: string diff --git a/functions/src/scripts/contest/resolve-markets.ts b/functions/src/scripts/contest/resolve-markets.ts new file mode 100644 index 00000000..7f6cefe2 --- /dev/null +++ b/functions/src/scripts/contest/resolve-markets.ts @@ -0,0 +1,69 @@ +// Run with `npx ts-node src/scripts/contest/resolve-markets.ts` + +import { data } from './criticism-and-red-teaming' + +const DOMAIN = 'dev.manifold.markets' +// Dev API key for Cause Exploration Prizes (@CEP) +// const API_KEY = '188f014c-0ba2-4c35-9e6d-88252e281dbf' +// DEV API key for Criticism and Red Teaming (@CARTBot) +const API_KEY = '6ff1f78a-32fe-43b2-b31b-9e3c78c5f18c' + +// Warning: Checking these in can be dangerous! +// Prod API key for @CEPBot + +// Can just curl /v0/group/{slug} to get a group +async function getGroupBySlug(slug: string) { + const resp = await fetch(`https://${DOMAIN}/api/v0/group/${slug}`) + return await resp.json() +} + +async function getMarketsByGroupId(id: string) { + // API structure: /v0/group/by-id/[id]/markets + const resp = await fetch(`https://${DOMAIN}/api/v0/group/by-id/${id}/markets`) + return await resp.json() +} + +/* Example curl request: +# Resolve a binary market +$ curl https://manifold.markets/api/v0/market/{marketId}/resolve -X POST \ + -H 'Content-Type: application/json' \ + -H 'Authorization: Key {...}' \ + --data-raw '{"outcome": "YES"}' +*/ +async function resolveMarketById( + id: string, + outcome: 'YES' | 'NO' | 'MKT' | 'CANCEL' +) { + const resp = await fetch(`https://${DOMAIN}/api/v0/market/${id}/resolve`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + Authorization: `Key ${API_KEY}`, + }, + body: JSON.stringify({ + outcome, + }), + }) + return await resp.json() +} + +async function main() { + const group = await getGroupBySlug('predict-cep') + const markets = await getMarketsByGroupId(group.id) + + // Count up some metrics + console.log('Number of markets', markets.length) + console.log( + 'Number of resolved markets', + markets.filter((m: any) => m.isResolved).length + ) + + // Resolve each market to NO + for (const market of markets) { + if (!market.isResolved) { + console.log(`Resolving market ${market.url} to NO`) + const resp = await resolveMarketById(market.id, 'NO') + } + } +} +main()