@prophecy-dev/sdk 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +73 -47
- package/dist/index.cjs.map +3 -3
- package/dist/index.js +48 -22
- package/dist/index.js.map +3 -3
- package/dist/market-creation.d.ts +6 -6
- package/dist/market-defaults.d.ts +2 -13
- package/dist/market-defaults.d.ts.map +1 -1
- package/dist/market-prompts.d.ts +14 -6
- package/dist/market-prompts.d.ts.map +1 -1
- package/dist/market-validation.d.ts.map +1 -1
- package/package.json +62 -62
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var F=Object.defineProperty;var Be=Object.getOwnPropertyDescriptor;var $e=Object.getOwnPropertyNames;var Fe=Object.prototype.hasOwnProperty;var Ye=(e,t)=>()=>(e&&(t=e(e=0)),t);var G=(e,t)=>{for(var r in t)F(e,r,{get:t[r],enumerable:!0})},Ve=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of $e(t))!Fe.call(e,i)&&i!==r&&F(e,i,{get:()=>t[i],enumerable:!(n=Be(t,i))||n.enumerable});return e};var qe=e=>Ve(F({},"__esModule",{value:!0}),e);var V={};G(V,{ApiError:()=>m,authedDelete:()=>Y,authedPost:()=>f,get:()=>s,post:()=>g});async function T(e,t={}){let r={"Content-Type":"application/json",...t.headers},n=await fetch(e,{method:t.method??"GET",headers:r,body:t.body?JSON.stringify(t.body):void 0});if(!n.ok){let i=await n.json().catch(()=>null);throw new m(n.status,i)}return n.json()}function s(e,t,r){let n=new URL(t,e);if(r)for(let[i,a]of Object.entries(r))a!==void 0&&n.searchParams.set(i,String(a));return T(n)}function g(e,t,r){return T(new URL(t,e),{method:"POST",body:r})}function f(e,t,r,n){return T(new URL(t,e),{method:"POST",body:r,headers:{Authorization:`Bearer ${n}`}})}function Y(e,t,r){return T(new URL(t,e),{method:"DELETE",headers:{Authorization:`Bearer ${r}`}})}var m,u=Ye(()=>{"use strict";m=class extends Error{constructor(r,n){super(`API error ${r}`);this.status=r;this.body=n;this.name="ApiError"}}});var ze={};G(ze,{ACTIVE_MARKET_CAP:()=>le,ApiError:()=>m,BANNED_DOMAINS:()=>l,CATEGORIES:()=>y,DEFAULT_CATEGORY:()=>b,DEFAULT_DURATION_HOURS:()=>h,DEFAULT_LIQUIDITY:()=>se,DEFAULT_RESOLUTION_HOURS:()=>ue,DEFAULT_TRADING_START_BUFFER_SECONDS:()=>ce,DURATION_HINTS:()=>w,ENTITY_TYPES:()=>v,LOW_CONFIDENCE_OVERRIDE:()=>P,MARKET_DEFAULTS:()=>ye,MAX_BINARY_PROBABILITY:()=>M,MAX_DURATION_HOURS:()=>U,MAX_OPTION_PROBABILITY:()=>$,MIN_BINARY_PROBABILITY:()=>D,MIN_DURATION_HOURS:()=>L,MIN_OPTION_PROBABILITY:()=>B,RESOLUTION_CONFIDENCE_THRESHOLD:()=>ae,SIMILARITY_THRESHOLD:()=>oe,VIRALITY_THRESHOLD:()=>ie,buildCarouselPrompt:()=>Te,buildEntityExtractionPrompt:()=>Ae,buildGroupingPrompt:()=>we,buildMarketGenerationPrompt:()=>be,buildNewsContextPrompt:()=>Ie,buildProbabilityEstimationPrompt:()=>Ee,buildReframePrompt:()=>ve,buildResolutionEvalPrompt:()=>Pe,buildUrlGuidanceBlock:()=>Re,clampBinaryProbability:()=>xe,clampDuration:()=>H,createCache:()=>R,createChainClient:()=>k,createEventsApiNamespace:()=>C,createMarketDefinition:()=>ne,createProphecyClient:()=>te,getEventRating:()=>I,getPPLeaderboard:()=>_,getPnLLeaderboard:()=>N,getVolumeLeaderboard:()=>S,googleNewsFallbackUrl:()=>Ne,isBannedDomain:()=>_e,isValidUrl:()=>Ce,marketDefinitionSchema:()=>O,normalizeOptionProbabilities:()=>ke,parseLlmMarketJson:()=>Se,previewRating:()=>E,rateMarketDraft:()=>A,signCreateMarketPermit:()=>De,signTradePermit:()=>Ue});module.exports=qe(ze);u();function j(e){return{prompt:e.prompt,answer_type:e.answerType,source_urls:e.sourceUrls,min_agreement:e.minAgreement,trading_start:e.tradingStart,trading_end:e.tradingEnd,resolution_start:e.resolutionStart,resolution_end:e.resolutionEnd}}function He(e){return{ratedAt:e.rated_at,finalScore:e.final_score,ratingBand:{rating:e.rating_band.rating,minScore:e.rating_band.min_score,maxScore:e.rating_band.max_score,definition:e.rating_band.definition},criteria:e.criteria.map(t=>({key:t.key,name:t.name,criterionType:t.criterion_type,evaluation:t.evaluation,status:t.status,summary:t.summary,weight:t.weight,score:t.score,weightedScore:t.weighted_score}))}}async function E(e,t){return g(e,"/v1/arbiter/preview",j(t))}async function A(e,t){let r=await g(e,"/v1/arbiter/preview",j(t));return He(r)}async function I(e,t,r){return s(e,`/v1/arbiter/events/${t}/${r}`)}function R(e={}){let t=e.defaultTtlMs??15e3,r=new Map;return{get(n){if(t===0)return;let i=r.get(n);if(i){if(Date.now()>i.expiresAt){r.delete(n);return}return i.data}},set(n,i,a){let o=a??t;o!==0&&r.set(n,{data:i,expiresAt:Date.now()+o})},invalidate(n){for(let i of r.keys())i.startsWith(n)&&r.delete(i)},clear(){r.clear()}}}var p=require("viem"),We=[{inputs:[{internalType:"uint256",name:"venueId",type:"uint256"},{internalType:"address",name:"user",type:"address"}],name:"getNonce",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"}],x=[{inputs:[{internalType:"uint256",name:"marketId",type:"uint256"},{internalType:"address",name:"user",type:"address"}],name:"getUserPosition",outputs:[{components:[{internalType:"uint256",name:"yes",type:"uint256"},{internalType:"uint256",name:"no",type:"uint256"},{internalType:"bool",name:"claimed",type:"bool"}],internalType:"struct IProphecyCore.SharePosition",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"marketId",type:"uint256"}],name:"getMarketCore",outputs:[{components:[{internalType:"uint256",name:"tradingStartTs",type:"uint256"},{internalType:"uint256",name:"tradingEndTs",type:"uint256"},{internalType:"uint256",name:"resolutionStartTs",type:"uint256"},{internalType:"uint256",name:"resolutionEndTs",type:"uint256"},{internalType:"address",name:"creator",type:"address"},{internalType:"address",name:"resolver",type:"address"},{internalType:"address",name:"stakeToken",type:"address"},{internalType:"bool",name:"resolved",type:"bool"},{internalType:"uint8",name:"outcome",type:"uint8"},{internalType:"uint256",name:"totalYesShares",type:"uint256"},{internalType:"uint256",name:"totalNoShares",type:"uint256"},{internalType:"uint256",name:"totalShares",type:"uint256"},{internalType:"uint256",name:"participantCount",type:"uint256"},{internalType:"uint256",name:"initialLiquidityBase",type:"uint256"},{internalType:"uint256",name:"feeBps",type:"uint256"}],internalType:"struct IProphecyCore.MarketCore",name:"core",type:"tuple"},{internalType:"string",name:"name",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"marketId",type:"uint256"}],name:"getCurrentReserves",outputs:[{internalType:"uint256",name:"yesPool",type:"uint256"},{internalType:"uint256",name:"noPool",type:"uint256"}],stateMutability:"view",type:"function"}],Ge=[{inputs:[{internalType:"uint256",name:"marketId",type:"uint256"}],name:"claimSettlement",outputs:[{internalType:"uint256",name:"payout",type:"uint256"}],stateMutability:"nonpayable",type:"function"}];function k(e){let t=(0,p.defineChain)({id:e.chainId,name:`Somnia (${e.chainId})`,nativeCurrency:{name:"STT",symbol:"STT",decimals:18},rpcUrls:{default:{http:[e.rpcUrl]}}}),r=(0,p.createPublicClient)({chain:t,transport:(0,p.http)(e.rpcUrl)});return{async getVenueNonce(n,i){return r.readContract({address:e.venueRegistryAddress,abi:We,functionName:"getNonce",args:[n,i]})},async getMarketCore(n){let[i,a]=await r.readContract({address:e.prophecyCoreAddress,abi:x,functionName:"getMarketCore",args:[n]});return{core:i,name:a}},async getReserves(n){let[i,a]=await r.readContract({address:e.prophecyCoreAddress,abi:x,functionName:"getCurrentReserves",args:[n]});return{yesPool:i,noPool:a}},async getUserPosition(n,i){return await r.readContract({address:e.prophecyCoreAddress,abi:x,functionName:"getUserPosition",args:[n,i]})},async getUserPositions(n,i){if(n.length===0)return[];let a=n.map(d=>({address:e.prophecyCoreAddress,abi:x,functionName:"getUserPosition",args:[d,i]}));return(await r.multicall({contracts:a})).map(d=>d.status!=="success"?null:d.result)},encodeClaimSettlement(n){if(!e.prophecySettlementAddress)throw new Error("prophecySettlementAddress is required in ChainConfig for claim operations");return{to:e.prophecySettlementAddress,data:(0,p.encodeFunctionData)({abi:Ge,functionName:"claimSettlement",args:[n]})}}}}function K(e,t){return{venueId:e,getAuthHeader:()=>`Bearer ${t}`}}function J(e,t){async function r(n,i){let a=new URL(`/v1/events${n}`,e),o=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json",Authorization:t.getAuthHeader()},body:JSON.stringify(i)});if(!o.ok){let d=await o.json().catch(()=>null),{ApiError:Me}=await Promise.resolve().then(()=>(u(),V));throw new Me(o.status,d)}return o.json()}return{socialShare:(n,i)=>r("/social-share",{wallet:n,marketId:i}),receiptInspect:(n,i)=>r("/receipt-inspect",{wallet:n,marketId:i}),dailyChallenge:n=>r("/daily-challenge",{wallet:n})}}u();function C(e,t){return{async search(r){let n=new URL("/v0/events",e);if(r?.q&&n.searchParams.set("q",r.q),r?.venue&&n.searchParams.set("venue",r.venue),r?.tag&&n.searchParams.set("tag",r.tag),r?.created_by&&n.searchParams.set("created_by",r.created_by),r?.sort&&n.searchParams.set("sort",r.sort),r?.order&&n.searchParams.set("order",r.order),r?.limit&&n.searchParams.set("limit",String(r.limit)),r?.cursor&&n.searchParams.set("cursor",r.cursor),r?.status)for(let o of r.status)n.searchParams.append("status",o);let i=await fetch(n,{headers:{"Content-Type":"application/json"}});if(!i.ok)throw new m(i.status,await i.json().catch(()=>null));let a=await i.json();return{items:a.items,hasMore:a.has_more,nextCursor:a.next_cursor}},async get(r,n){let i=`event:${r}:${n}`,a=t.get(i);if(a)return a;let o=await s(e,`/v0/events/${r}/${n}`);return t.set(i,o),o}}}u();function X(e,t,r){return{async eligibility(n){return s(e,`/v1/faucet/eligibility?wallet=${n.toLowerCase()}&venue=${t}`)},async claim(n){return r?f(e,"/v1/faucet/claim",{wallet:n.toLowerCase()},r.getAuthHeader()):{success:!1,error:"venueId and venueApiKey required for faucet claims"}}}}u();async function _(e,t){return s(e,"/v1/stats/top-traders",{venue:t?.venue,limit:t?.limit})}async function N(e,t){return s(e,"/v0/leaderboard/pnl",{venue:t?.venue,period:t?.period,limit:t?.limit,cursor:t?.cursor})}async function S(e,t){return s(e,"/v0/leaderboard/volume",{venue:t?.venue,period:t?.period,limit:t?.limit,cursor:t?.cursor})}u();function z(e,t){return{async search(r){let n=new URL("/v0/markets",e);if(r?.q&&n.searchParams.set("q",r.q),r?.venue&&n.searchParams.set("venue",r.venue),r?.sort&&n.searchParams.set("sort",r.sort),r?.order&&n.searchParams.set("order",r.order),r?.limit&&n.searchParams.set("limit",String(r.limit)),r?.cursor&&n.searchParams.set("cursor",r.cursor),r?.status)for(let a of r.status)n.searchParams.append("status",a);let i=await fetch(n,{headers:{"Content-Type":"application/json"}});if(!i.ok){let{ApiError:a}=await Promise.resolve().then(()=>(u(),V));throw new a(i.status,await i.json().catch(()=>null))}return i.json()},async get(r,n){let i=`market:${r}:${n}`,a=t.get(i);if(a)return a;let o=await s(e,`/v0/markets/${r}/${n}`);return t.set(i,o),o}}}u();function Q(e,t){return{async active(){let r="season:active",n=t.get(r);if(n!==void 0)return n;let i=await s(e,"/v1/seasons/active").catch(()=>null);return t.set(r,i,6e4),i},async config(){let r="season:config",n=t.get(r);if(n!==void 0)return n;let i=await s(e,"/v1/seasons/active/config").catch(()=>null);return t.set(r,i,6e4),i}}}u();function Z(e,t){return{async points(r,n){let i=`user:${r}:points:${n?.season??"current"}`,a=t.get(i);if(a)return a;let o=await s(e,`/v1/points/${r}`,n?.season?{season:n.season}:void 0);return t.set(i,o),o},async dashboard(r,n){let i=`user:${r}:dashboard:${n?.venue??"all"}`,a=t.get(i);if(a)return a;let o=await s(e,`/v1/users/${r}/dashboard`,n?.venue?{venue:n.venue}:void 0);return t.set(i,o),o},linkWallet:r=>g(e,"/v1/identity/link",r),linkedWallets:r=>s(e,`/v1/identity/${r}`)}}u();function ee(e,t){return{markets:{async list(r,n){let i=`venue:${r}:markets:${n?.status??"all"}`,a=t.get(i);if(a)return a;let o=await s(e,`/v1/venues/${r}/markets`,{status:n?.status});return t.set(i,o),o},async add(r,n,i){let a=await f(e,`/v1/venues/${r}/markets`,{markets:n},i);return t.invalidate(`venue:${r}`),a},async remove(r,n,i,a){let o=await Y(e,`/v1/venues/${r}/markets/${n}/${i}`,a);return t.invalidate(`venue:${r}`),o}},async stats(r,n){let i=`venue:${r}:stats:${n??"current"}`,a=t.get(i);if(a)return a;let o=await s(e,`/v1/points/venue/${r}`,n?{season:n}:void 0);return t.set(i,o),o},invalidate:r=>t.invalidate(`venue:${r}`),clearCache:()=>t.invalidate("venue:")}}function te(e){let t=R(e.cache),r=k({chainId:e.chainId,rpcUrl:e.rpcUrl,venueRegistryAddress:e.venueRegistryAddress,prophecyCoreAddress:e.prophecyCoreAddress,prophecySettlementAddress:e.prophecySettlementAddress}),n=e.venueId&&e.venueApiKey?K(e.venueId,e.venueApiKey):null,i={socialShare:()=>Promise.reject(new Error("venueId and venueApiKey required for event reporting")),receiptInspect:()=>Promise.reject(new Error("venueId and venueApiKey required for event reporting")),dailyChallenge:()=>Promise.reject(new Error("venueId and venueApiKey required for event reporting"))};return{chain:r,markets:z(e.dataApiUrl,t),eventsApi:C(e.dataApiUrl,t),venue:ee(e.partnersApiUrl,t),user:Z(e.partnersApiUrl,t),season:Q(e.partnersApiUrl,t),leaderboard:{pp:a=>_(e.partnersApiUrl,a),pnl:a=>N(e.dataApiUrl,a),volume:a=>S(e.dataApiUrl,a)},faucet:X(e.partnersApiUrl,e.venueId??"",n),events:n?J(e.partnersApiUrl,n):i,arbiter:{rate:a=>A(e.partnersApiUrl,a),preview:a=>E(e.partnersApiUrl,a),eventRating:(a,o)=>I(e.partnersApiUrl,a,o)},auth:n}}u();var re=require("ai"),c=require("zod"),O=c.z.object({type:c.z.enum(["ai","creator"]).describe("ai = verifiable from URL, creator = manual resolution"),name:c.z.string().describe("Market title \u2014 frames the specific prediction"),description:c.z.string().describe("What will be extracted / resolution criteria"),tradingStartTs:c.z.string().describe("ISO 8601 \u2014 when trading opens"),tradingEndTs:c.z.string().describe("ISO 8601 \u2014 when trading closes"),resolutionStartTs:c.z.string().describe("ISO 8601 \u2014 when resolution can begin"),resolutionEndTs:c.z.string().describe("ISO 8601 \u2014 resolution deadline"),extractionPrompt:c.z.string().optional().describe("Prompt used to extract the answer from sources"),urls:c.z.array(c.z.string()).optional().describe("Credible source URLs (2-4 recommended)"),options:c.z.array(c.z.string()).optional().describe("Possible outcomes for string extractions"),expectedOutcome:c.z.string().optional().describe("The user's prediction \u2014 inferred from the question"),resultType:c.z.enum(["string","number"]).optional().describe("Type of extraction result")});function je(){return`You are a prediction market configurator. Given a user's question or prediction, create a structured market definition.
|
|
1
|
+
"use strict";var Y=Object.defineProperty;var Be=Object.getOwnPropertyDescriptor;var $e=Object.getOwnPropertyNames;var Fe=Object.prototype.hasOwnProperty;var Ye=(t,e)=>()=>(t&&(e=t(t=0)),e);var G=(t,e)=>{for(var r in e)Y(t,r,{get:e[r],enumerable:!0})},Ve=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of $e(e))!Fe.call(t,a)&&a!==r&&Y(t,a,{get:()=>e[a],enumerable:!(n=Be(e,a))||n.enumerable});return t};var qe=t=>Ve(Y({},"__esModule",{value:!0}),t);var q={};G(q,{ApiError:()=>m,authedDelete:()=>V,authedPost:()=>f,get:()=>o,post:()=>g});async function P(t,e={}){let r={"Content-Type":"application/json",...e.headers},n=await fetch(t,{method:e.method??"GET",headers:r,body:e.body?JSON.stringify(e.body):void 0});if(!n.ok){let a=await n.json().catch(()=>null);throw new m(n.status,a)}return n.json()}function o(t,e,r){let n=new URL(e,t);if(r)for(let[a,i]of Object.entries(r))i!==void 0&&n.searchParams.set(a,String(i));return P(n)}function g(t,e,r){return P(new URL(e,t),{method:"POST",body:r})}function f(t,e,r,n){return P(new URL(e,t),{method:"POST",body:r,headers:{Authorization:`Bearer ${n}`}})}function V(t,e,r){return P(new URL(e,t),{method:"DELETE",headers:{Authorization:`Bearer ${r}`}})}var m,u=Ye(()=>{"use strict";m=class extends Error{constructor(r,n){super(`API error ${r}`);this.status=r;this.body=n;this.name="ApiError"}}});var ze={};G(ze,{ACTIVE_MARKET_CAP:()=>le,ApiError:()=>m,BANNED_DOMAINS:()=>l,CATEGORIES:()=>h,DEFAULT_CATEGORY:()=>b,DEFAULT_DURATION_HOURS:()=>y,DEFAULT_LIQUIDITY:()=>oe,DEFAULT_RESOLUTION_HOURS:()=>ue,DEFAULT_TRADING_START_BUFFER_SECONDS:()=>ce,DURATION_HINTS:()=>w,ENTITY_TYPES:()=>v,LOW_CONFIDENCE_OVERRIDE:()=>T,MARKET_DEFAULTS:()=>he,MAX_BINARY_PROBABILITY:()=>B,MAX_DURATION_HOURS:()=>D,MAX_OPTION_PROBABILITY:()=>F,MIN_BINARY_PROBABILITY:()=>M,MIN_DURATION_HOURS:()=>U,MIN_OPTION_PROBABILITY:()=>$,RESOLUTION_CONFIDENCE_THRESHOLD:()=>ie,SIMILARITY_THRESHOLD:()=>se,VIRALITY_THRESHOLD:()=>ae,buildCarouselPrompt:()=>Ee,buildEntityExtractionPrompt:()=>Ae,buildGroupingPrompt:()=>we,buildMarketGenerationPrompt:()=>be,buildNewsContextPrompt:()=>Re,buildProbabilityEstimationPrompt:()=>Pe,buildReframePrompt:()=>ve,buildResolutionEvalPrompt:()=>Te,buildUrlGuidanceBlock:()=>Ie,clampBinaryProbability:()=>ke,clampDuration:()=>E,createCache:()=>k,createChainClient:()=>C,createEventsApiNamespace:()=>_,createMarketDefinition:()=>ne,createProphecyClient:()=>te,getEventRating:()=>I,getPPLeaderboard:()=>N,getPnLLeaderboard:()=>O,getVolumeLeaderboard:()=>S,googleNewsFallbackUrl:()=>Ne,isBannedDomain:()=>_e,isValidUrl:()=>Ce,marketDefinitionSchema:()=>L,normalizeOptionProbabilities:()=>xe,parseLlmMarketJson:()=>Oe,previewRating:()=>A,rateMarketDraft:()=>R,signCreateMarketPermit:()=>De,signTradePermit:()=>Ue});module.exports=qe(ze);u();function j(t){return{prompt:t.prompt,answer_type:t.answerType,source_urls:t.sourceUrls,min_agreement:t.minAgreement,trading_start:t.tradingStart,trading_end:t.tradingEnd,resolution_start:t.resolutionStart,resolution_end:t.resolutionEnd}}function We(t){return{ratedAt:t.rated_at,finalScore:t.final_score,ratingBand:{rating:t.rating_band.rating,minScore:t.rating_band.min_score,maxScore:t.rating_band.max_score,definition:t.rating_band.definition},criteria:t.criteria.map(e=>({key:e.key,name:e.name,criterionType:e.criterion_type,evaluation:e.evaluation,status:e.status,summary:e.summary,weight:e.weight,score:e.score,weightedScore:e.weighted_score}))}}async function A(t,e){return g(t,"/v1/arbiter/preview",j(e))}async function R(t,e){let r=await g(t,"/v1/arbiter/preview",j(e));return We(r)}async function I(t,e,r){return o(t,`/v1/arbiter/events/${e}/${r}`)}function k(t={}){let e=t.defaultTtlMs??15e3,r=new Map;return{get(n){if(e===0)return;let a=r.get(n);if(a){if(Date.now()>a.expiresAt){r.delete(n);return}return a.data}},set(n,a,i){let s=i??e;s!==0&&r.set(n,{data:a,expiresAt:Date.now()+s})},invalidate(n){for(let a of r.keys())a.startsWith(n)&&r.delete(a)},clear(){r.clear()}}}var p=require("viem"),He=[{inputs:[{internalType:"uint256",name:"venueId",type:"uint256"},{internalType:"address",name:"user",type:"address"}],name:"getNonce",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"}],x=[{inputs:[{internalType:"uint256",name:"marketId",type:"uint256"},{internalType:"address",name:"user",type:"address"}],name:"getUserPosition",outputs:[{components:[{internalType:"uint256",name:"yes",type:"uint256"},{internalType:"uint256",name:"no",type:"uint256"},{internalType:"bool",name:"claimed",type:"bool"}],internalType:"struct IProphecyCore.SharePosition",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"marketId",type:"uint256"}],name:"getMarketCore",outputs:[{components:[{internalType:"uint256",name:"tradingStartTs",type:"uint256"},{internalType:"uint256",name:"tradingEndTs",type:"uint256"},{internalType:"uint256",name:"resolutionStartTs",type:"uint256"},{internalType:"uint256",name:"resolutionEndTs",type:"uint256"},{internalType:"address",name:"creator",type:"address"},{internalType:"address",name:"resolver",type:"address"},{internalType:"address",name:"stakeToken",type:"address"},{internalType:"bool",name:"resolved",type:"bool"},{internalType:"uint8",name:"outcome",type:"uint8"},{internalType:"uint256",name:"totalYesShares",type:"uint256"},{internalType:"uint256",name:"totalNoShares",type:"uint256"},{internalType:"uint256",name:"totalShares",type:"uint256"},{internalType:"uint256",name:"participantCount",type:"uint256"},{internalType:"uint256",name:"initialLiquidityBase",type:"uint256"},{internalType:"uint256",name:"feeBps",type:"uint256"}],internalType:"struct IProphecyCore.MarketCore",name:"core",type:"tuple"},{internalType:"string",name:"name",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"marketId",type:"uint256"}],name:"getCurrentReserves",outputs:[{internalType:"uint256",name:"yesPool",type:"uint256"},{internalType:"uint256",name:"noPool",type:"uint256"}],stateMutability:"view",type:"function"}],Ge=[{inputs:[{internalType:"uint256",name:"marketId",type:"uint256"}],name:"claimSettlement",outputs:[{internalType:"uint256",name:"payout",type:"uint256"}],stateMutability:"nonpayable",type:"function"}];function C(t){let e=(0,p.defineChain)({id:t.chainId,name:`Somnia (${t.chainId})`,nativeCurrency:{name:"STT",symbol:"STT",decimals:18},rpcUrls:{default:{http:[t.rpcUrl]}}}),r=(0,p.createPublicClient)({chain:e,transport:(0,p.http)(t.rpcUrl)});return{async getVenueNonce(n,a){return r.readContract({address:t.venueRegistryAddress,abi:He,functionName:"getNonce",args:[n,a]})},async getMarketCore(n){let[a,i]=await r.readContract({address:t.prophecyCoreAddress,abi:x,functionName:"getMarketCore",args:[n]});return{core:a,name:i}},async getReserves(n){let[a,i]=await r.readContract({address:t.prophecyCoreAddress,abi:x,functionName:"getCurrentReserves",args:[n]});return{yesPool:a,noPool:i}},async getUserPosition(n,a){return await r.readContract({address:t.prophecyCoreAddress,abi:x,functionName:"getUserPosition",args:[n,a]})},async getUserPositions(n,a){if(n.length===0)return[];let i=n.map(d=>({address:t.prophecyCoreAddress,abi:x,functionName:"getUserPosition",args:[d,a]}));return(await r.multicall({contracts:i})).map(d=>d.status!=="success"?null:d.result)},encodeClaimSettlement(n){if(!t.prophecySettlementAddress)throw new Error("prophecySettlementAddress is required in ChainConfig for claim operations");return{to:t.prophecySettlementAddress,data:(0,p.encodeFunctionData)({abi:Ge,functionName:"claimSettlement",args:[n]})}}}}function K(t,e){return{venueId:t,getAuthHeader:()=>`Bearer ${e}`}}function J(t,e){async function r(n,a){let i=new URL(`/v1/events${n}`,t),s=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",Authorization:e.getAuthHeader()},body:JSON.stringify(a)});if(!s.ok){let d=await s.json().catch(()=>null),{ApiError:Me}=await Promise.resolve().then(()=>(u(),q));throw new Me(s.status,d)}return s.json()}return{socialShare:(n,a)=>r("/social-share",{wallet:n,marketId:a}),receiptInspect:(n,a)=>r("/receipt-inspect",{wallet:n,marketId:a}),dailyChallenge:n=>r("/daily-challenge",{wallet:n})}}u();function _(t,e){return{async search(r){let n=new URL("/v0/events",t);if(r?.q&&n.searchParams.set("q",r.q),r?.venue&&n.searchParams.set("venue",r.venue),r?.tag&&n.searchParams.set("tag",r.tag),r?.created_by&&n.searchParams.set("created_by",r.created_by),r?.sort&&n.searchParams.set("sort",r.sort),r?.order&&n.searchParams.set("order",r.order),r?.limit&&n.searchParams.set("limit",String(r.limit)),r?.cursor&&n.searchParams.set("cursor",r.cursor),r?.status)for(let s of r.status)n.searchParams.append("status",s);let a=await fetch(n,{headers:{"Content-Type":"application/json"}});if(!a.ok)throw new m(a.status,await a.json().catch(()=>null));let i=await a.json();return{items:i.items,hasMore:i.has_more,nextCursor:i.next_cursor}},async get(r,n){let a=`event:${r}:${n}`,i=e.get(a);if(i)return i;let s=await o(t,`/v0/events/${r}/${n}`);return e.set(a,s),s}}}u();function X(t,e,r){return{async eligibility(n){return o(t,`/v1/faucet/eligibility?wallet=${n.toLowerCase()}&venue=${e}`)},async claim(n){return r?f(t,"/v1/faucet/claim",{wallet:n.toLowerCase()},r.getAuthHeader()):{success:!1,error:"venueId and venueApiKey required for faucet claims"}}}}u();async function N(t,e){return o(t,"/v1/stats/top-traders",{venue:e?.venue,limit:e?.limit})}async function O(t,e){return o(t,"/v0/leaderboard/pnl",{venue:e?.venue,period:e?.period,limit:e?.limit,cursor:e?.cursor})}async function S(t,e){return o(t,"/v0/leaderboard/volume",{venue:e?.venue,period:e?.period,limit:e?.limit,cursor:e?.cursor})}u();function z(t,e){return{async search(r){let n=new URL("/v0/markets",t);if(r?.q&&n.searchParams.set("q",r.q),r?.venue&&n.searchParams.set("venue",r.venue),r?.sort&&n.searchParams.set("sort",r.sort),r?.order&&n.searchParams.set("order",r.order),r?.limit&&n.searchParams.set("limit",String(r.limit)),r?.cursor&&n.searchParams.set("cursor",r.cursor),r?.status)for(let i of r.status)n.searchParams.append("status",i);let a=await fetch(n,{headers:{"Content-Type":"application/json"}});if(!a.ok){let{ApiError:i}=await Promise.resolve().then(()=>(u(),q));throw new i(a.status,await a.json().catch(()=>null))}return a.json()},async get(r,n){let a=`market:${r}:${n}`,i=e.get(a);if(i)return i;let s=await o(t,`/v0/markets/${r}/${n}`);return e.set(a,s),s}}}u();function Q(t,e){return{async active(){let r="season:active",n=e.get(r);if(n!==void 0)return n;let a=await o(t,"/v1/seasons/active").catch(()=>null);return e.set(r,a,6e4),a},async config(){let r="season:config",n=e.get(r);if(n!==void 0)return n;let a=await o(t,"/v1/seasons/active/config").catch(()=>null);return e.set(r,a,6e4),a}}}u();function Z(t,e){return{async points(r,n){let a=`user:${r}:points:${n?.season??"current"}`,i=e.get(a);if(i)return i;let s=await o(t,`/v1/points/${r}`,n?.season?{season:n.season}:void 0);return e.set(a,s),s},async dashboard(r,n){let a=`user:${r}:dashboard:${n?.venue??"all"}`,i=e.get(a);if(i)return i;let s=await o(t,`/v1/users/${r}/dashboard`,n?.venue?{venue:n.venue}:void 0);return e.set(a,s),s},linkWallet:r=>g(t,"/v1/identity/link",r),linkedWallets:r=>o(t,`/v1/identity/${r}`)}}u();function ee(t,e){return{markets:{async list(r,n){let a=`venue:${r}:markets:${n?.status??"all"}`,i=e.get(a);if(i)return i;let s=await o(t,`/v1/venues/${r}/markets`,{status:n?.status});return e.set(a,s),s},async add(r,n,a){let i=await f(t,`/v1/venues/${r}/markets`,{markets:n},a);return e.invalidate(`venue:${r}`),i},async remove(r,n,a,i){let s=await V(t,`/v1/venues/${r}/markets/${n}/${a}`,i);return e.invalidate(`venue:${r}`),s}},async stats(r,n){let a=`venue:${r}:stats:${n??"current"}`,i=e.get(a);if(i)return i;let s=await o(t,`/v1/points/venue/${r}`,n?{season:n}:void 0);return e.set(a,s),s},invalidate:r=>e.invalidate(`venue:${r}`),clearCache:()=>e.invalidate("venue:")}}function te(t){let e=k(t.cache),r=C({chainId:t.chainId,rpcUrl:t.rpcUrl,venueRegistryAddress:t.venueRegistryAddress,prophecyCoreAddress:t.prophecyCoreAddress,prophecySettlementAddress:t.prophecySettlementAddress}),n=t.venueId&&t.venueApiKey?K(t.venueId,t.venueApiKey):null,a={socialShare:()=>Promise.reject(new Error("venueId and venueApiKey required for event reporting")),receiptInspect:()=>Promise.reject(new Error("venueId and venueApiKey required for event reporting")),dailyChallenge:()=>Promise.reject(new Error("venueId and venueApiKey required for event reporting"))};return{chain:r,markets:z(t.dataApiUrl,e),eventsApi:_(t.dataApiUrl,e),venue:ee(t.partnersApiUrl,e),user:Z(t.partnersApiUrl,e),season:Q(t.partnersApiUrl,e),leaderboard:{pp:i=>N(t.partnersApiUrl,i),pnl:i=>O(t.dataApiUrl,i),volume:i=>S(t.dataApiUrl,i)},faucet:X(t.partnersApiUrl,t.venueId??"",n),events:n?J(t.partnersApiUrl,n):a,arbiter:{rate:i=>R(t.partnersApiUrl,i),preview:i=>A(t.partnersApiUrl,i),eventRating:(i,s)=>I(t.partnersApiUrl,i,s)},auth:n}}u();var re=require("ai"),c=require("zod"),L=c.z.object({type:c.z.enum(["ai","creator"]).describe("ai = verifiable from URL, creator = manual resolution"),name:c.z.string().describe("Market title \u2014 frames the specific prediction"),description:c.z.string().describe("What will be extracted / resolution criteria"),tradingStartTs:c.z.string().describe("ISO 8601 \u2014 when trading opens"),tradingEndTs:c.z.string().describe("ISO 8601 \u2014 when trading closes"),resolutionStartTs:c.z.string().describe("ISO 8601 \u2014 when resolution can begin"),resolutionEndTs:c.z.string().describe("ISO 8601 \u2014 resolution deadline"),extractionPrompt:c.z.string().optional().describe("Prompt used to extract the answer from sources"),urls:c.z.array(c.z.string()).optional().describe("Credible source URLs (2-4 recommended)"),options:c.z.array(c.z.string()).optional().describe("Possible outcomes for string extractions"),expectedOutcome:c.z.string().optional().describe("The user's prediction \u2014 inferred from the question"),resultType:c.z.enum(["string","number"]).optional().describe("Type of extraction result")});function je(){return`You are a prediction market configurator. Given a user's question or prediction, create a structured market definition.
|
|
2
2
|
|
|
3
3
|
Today's date (UTC) is: ${new Date().toISOString().split("T")[0]}
|
|
4
4
|
|
|
@@ -17,15 +17,33 @@ For creator-resolved markets:
|
|
|
17
17
|
|
|
18
18
|
Set appropriate timestamps:
|
|
19
19
|
- tradingStartTs: when trading opens (usually now or soon)
|
|
20
|
-
- tradingEndTs: when trading closes (
|
|
20
|
+
- tradingEndTs: when trading closes \u2014 CRITICAL: if the user mentions a specific date (e.g. "before April 22"), use that date. Do not estimate a duration that falls short of the stated deadline.
|
|
21
21
|
- resolutionStartTs: when the outcome can be checked (usually when event concludes)
|
|
22
|
-
- resolutionEndTs: deadline for resolution (usually hours/days after event)`}async function ne(
|
|
23
|
-
User timezone: ${
|
|
22
|
+
- resolutionEndTs: deadline for resolution (usually hours/days after event)`}async function ne(t){let e=t.systemPrompt??je(),r=t.userTimeZone?`
|
|
23
|
+
User timezone: ${t.userTimeZone}. Interpret relative dates accordingly.`:"",{text:n}=await(0,re.generateText)({model:t.model,system:`${e}
|
|
24
24
|
|
|
25
25
|
Respond ONLY with valid JSON matching this schema. No markdown, no explanation.
|
|
26
|
-
Schema: ${JSON.stringify(
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
Schema: ${JSON.stringify(L.shape)}`,prompt:`Create a prediction market for: "${t.question}"${r}`});return L.parse(JSON.parse(n))}var h=["crypto","sport","pop_culture","technology","politics","science","entertainment"],b="politics",v=["country","person","company","team","crypto","topic"],ae=6,ie=4,se=.85,y=168,U=1,D=720,M=.05,B=.95,$=.02,F=.95,oe="100",ce=60,ue=1,le=5e3,l=["x.com","twitter.com","charts.spotify.com","xtracker.polymarket.com","www.youtube.com","youtube.com","www.espncricinfo.com","espncricinfo.com","liquipedia.net","www.dotabuff.com","dotabuff.com","www.premierleague.com","premierleague.com","gol.gg","www.gol.gg"],w={crypto:"1-4h",sport:"4-12h",news:"18-24h",politics:"18-24h"},de={"9-10":"massive global interest (Super Bowl, elections)","7-8":"mainstream (top-20 crypto, major sports leagues, significant news)","5-6":"niche interest","1-4":"very low interest"},me={"9-10":"URL always contains the answer (CoinGecko, ESPN scoreboard)","7-8":"URL very likely has the answer (major news, official standings)","4-6":"uncertain (general news, social media)","1-3":"unlikely to have a clear answer"},pe={explicit:{min:.9,max:1,label:"URL explicitly states the outcome"},strong:{min:.5,max:.8,label:"Strong but indirect evidence"},tangential:{min:.1,max:.4,label:"Tangentially related content"},none:{min:0,max:.1,label:"No relevant information \u2014 UNKNOWN"}},T=.6,ge={frontrunner:{min:.1,max:.3},midfield:{min:.02,max:.08},backmarker:{min:.002,max:.02}},he={categories:h,defaultCategory:b,entityTypes:v,viralityThreshold:6,resolutionConfidenceThreshold:4,similarityThreshold:.85,defaultDurationHours:168,minDurationHours:1,maxDurationHours:720,minBinaryProbability:.05,maxBinaryProbability:.95,minOptionProbability:.02,maxOptionProbability:.95,defaultLiquidity:"100",defaultTradingStartBufferSeconds:60,defaultResolutionHours:1,activeMarketCap:5e3,bannedDomains:l,durationHints:w,lowConfidenceOverride:T};function ye(){return new Date().toUTCString()}function Ke(){return new Date().toISOString().slice(0,10)}function W(t){return`BANNED RESOLUTION DOMAINS (JS-rendered/auth-walled): ${t.join(", ")}. Use alternatives or set confidence \u2264 2.`}function fe(t){return t.join("|")}function be(t){let e={categories:h,defaultDurationHours:168,bannedDomains:l,includeResolutionMeta:!1,stalenessMode:"strict",requireCompleteOptions:!1,includeContentGuidelines:!1,...t},r=ye(),n=e.includeResolutionMeta?`
|
|
27
|
+
"resolution_url_confidence": 7,
|
|
28
|
+
"is_already_decided": false,
|
|
29
|
+
"already_decided_reason": "",`:"",a=e.requireCompleteOptions?`- For multi-option markets (e.g., "Who will win?"), include ALL plausible options \u2014 do NOT truncate to a short list. For example, an F1 race should include all 22 drivers on the grid, not just the top 8. Completeness is more important than brevity. You may add an "Other" option if there are edge cases, but do not use "Other" as a substitute for listing all known options.
|
|
30
|
+
- For multi-option markets, use web search to verify the options are CURRENT participants. For sports, use the current season's roster/entry list \u2014 not last year's. For elections, use confirmed candidates. Always include an "Other" option as the last choice.`:`- For multi-option markets (e.g. "who will win"), use web search to verify the options are CURRENT participants. For sports, use the current season's roster/entry list \u2014 not last year's. For elections, use confirmed candidates. Always include an "Other" option as the last choice.`,i=e.stalenessMode==="lenient"?`Staleness detection:
|
|
31
|
+
- ONLY set "is_already_decided": true if you have CONCRETE EVIDENCE that the event has ALREADY OCCURRED or the result is ALREADY KNOWN as of ${r}.
|
|
32
|
+
- Common stale patterns: awards already given, matches already played, nominations already announced, elections already held, records already broken, deadlines already passed.
|
|
33
|
+
- If you cannot find information about an event, that does NOT mean it already happened. The user may be creating a market about something niche, internal, or not yet public. When in doubt, assume the event is upcoming and set "is_already_decided": false.
|
|
34
|
+
- Only block the market if you have positive evidence the outcome is already determined.`:`Staleness detection \u2014 CRITICAL:
|
|
35
|
+
- If the event has ALREADY OCCURRED or the result is ALREADY KNOWN as of ${r}, set "is_already_decided": true and explain in "already_decided_reason".
|
|
36
|
+
- Common stale patterns: awards already given, matches already played, nominations already announced, elections already held, records already broken, deadlines already passed.
|
|
37
|
+
- If unsure whether an event has happened, err on the side of caution and mark it as decided with a reason.
|
|
38
|
+
- Only create markets for events that are genuinely upcoming or currently unresolved.`,s=e.includeContentGuidelines?`
|
|
39
|
+
Content guidelines:
|
|
40
|
+
- No markets about violence, hate speech, self-harm, or illegal activity
|
|
41
|
+
- No markets that could manipulate real-world outcomes (e.g., assassination markets)
|
|
42
|
+
- No markets about specific private individuals without public relevance
|
|
43
|
+
- Markets should be verifiable using publicly available information`:"";return`You are a prediction market designer for Prophecy, a blockchain-based prediction market platform. Given a user's natural language prompt, generate a complete, well-structured prediction market.
|
|
44
|
+
|
|
45
|
+
CURRENT DATE/TIME: ${r}
|
|
46
|
+
Use this to assess whether events have already occurred or deadlines have passed.
|
|
29
47
|
|
|
30
48
|
Return ONLY valid JSON (no markdown, no code fences) with this exact structure:
|
|
31
49
|
{
|
|
@@ -35,18 +53,20 @@ Return ONLY valid JSON (no markdown, no code fences) with this exact structure:
|
|
|
35
53
|
"prompt": "Instructions for the AI resolver: what to look for on the resolution page and how to determine YES or NO",
|
|
36
54
|
"options": ["YES", "NO"],
|
|
37
55
|
"expected_result": "YES",
|
|
38
|
-
"category": "${fe(
|
|
56
|
+
"category": "${fe(e.categories)}",
|
|
39
57
|
"subcategory": "a more specific subcategory",
|
|
40
58
|
"tags": ["relevant", "tags", "for", "discovery"],
|
|
41
|
-
"
|
|
42
|
-
"
|
|
59
|
+
"trading_end_time": "ISO 8601 UTC timestamp when trading should close",
|
|
60
|
+
"suggested_duration_hours": ${e.defaultDurationHours},
|
|
61
|
+
"source_references": ["https://relevant-source.com/specific-page"],${n}
|
|
43
62
|
"news_context": [{"title": "Article headline", "url": "https://source.com/article", "source": "Publication Name"}]
|
|
44
63
|
}
|
|
45
64
|
|
|
46
65
|
News context (news_context field):
|
|
47
66
|
- Include 2-4 real, relevant news articles that provide background context for this market.
|
|
48
67
|
- Each entry needs: "title" (article headline), "url" (full URL to the article), "source" (publication name).
|
|
49
|
-
- Only include articles you found via web search \u2014 do NOT fabricate URLs.
|
|
68
|
+
- Prefer recent articles from reputable sources. Only include articles you found via web search \u2014 do NOT fabricate URLs.
|
|
69
|
+
- If you cannot find relevant articles, return an empty array [].
|
|
50
70
|
|
|
51
71
|
Rules:
|
|
52
72
|
- The question must be specific, unambiguous, and have a clear resolution date or condition
|
|
@@ -55,19 +75,25 @@ Rules:
|
|
|
55
75
|
- If a specific event has ALREADY HAPPENED (results exist), do NOT create a market for it. Find the next upcoming instance instead.
|
|
56
76
|
- Example: if user says "next F1 race winner" and the Australian GP already happened, find the actual next race on the calendar.
|
|
57
77
|
- If the user specifies custom options (not yes/no), use those options instead
|
|
58
|
-
|
|
78
|
+
${a}
|
|
59
79
|
- expected_result should be one of the options
|
|
60
|
-
-
|
|
80
|
+
- trading_end_time (PREFERRED): When the user mentions a specific date or the event has a known deadline, set trading_end_time to an ISO 8601 UTC timestamp. This is more precise than suggested_duration_hours. Example: "before April 22" \u2192 set trading_end_time to "2026-04-22T00:00:00Z".
|
|
81
|
+
- suggested_duration_hours: Fallback when no specific date is mentioned (1-720 hours). The market MUST end BEFORE the event resolves \u2014 set duration so trading closes just before the event starts/result is announced.
|
|
61
82
|
- source_references should be real, relevant websites that could help verify the outcome \u2014 use FULL URLs to specific pages, not just domains
|
|
83
|
+
- source_references[0] is the URL the AI resolution agent will actually VISIT to determine the outcome. It must be a FULL URL to a specific page containing the relevant data.
|
|
62
84
|
- Do NOT guess URL path segments you are unsure about (e.g., race numbers, event IDs). Use stable hub/event pages instead.
|
|
63
|
-
-
|
|
85
|
+
- If you cannot find a reliable, specific URL, use a Google News search URL as fallback: https://news.google.com/search?q=relevant+search+terms
|
|
86
|
+
- The prompt field is what the AI resolver will see when resolving the market \u2014 make it a clear, answerable question with instructions on what data to check
|
|
64
87
|
- Keep descriptions concise but informative
|
|
65
88
|
- Tags should be lowercase, relevant keywords
|
|
66
|
-
${
|
|
67
|
-
${
|
|
68
|
-
|
|
69
|
-
${
|
|
70
|
-
${
|
|
89
|
+
${e.urlGuidance?`
|
|
90
|
+
${e.urlGuidance}`:""}
|
|
91
|
+
|
|
92
|
+
${i}
|
|
93
|
+
${s}
|
|
94
|
+
${e.extraInstructions?`
|
|
95
|
+
${e.extraInstructions}`:""}
|
|
96
|
+
${W(e.bannedDomains)}`}function ve(t){let e={categories:h,durationHints:w,bannedDomains:l,...t},r=Object.entries(e.durationHints).map(([n,a])=>`${n} ${a}`).join(", ");return`You are a prediction market designer for Prophecy, a blockchain-based prediction market platform. Reframe market candidates as SHORT-DURATION prediction markets with clear, near-term resolution.
|
|
71
97
|
|
|
72
98
|
MARKET FORMAT:
|
|
73
99
|
|
|
@@ -84,7 +110,7 @@ Do NOT convert genuinely binary questions: price targets, policy decisions, weat
|
|
|
84
110
|
When converting, include 4-8 realistic contenders plus "Other".
|
|
85
111
|
|
|
86
112
|
Return ONLY valid JSON (no markdown, no code fences):
|
|
87
|
-
{"question":"...", "description":"2-3 sentences", "resolution_criteria":"...", "prompt":"AI resolver instructions", "options":["YES","NO"], "expected_result":"YES", "category":"${fe(
|
|
113
|
+
{"question":"...", "description":"2-3 sentences", "resolution_criteria":"...", "prompt":"AI resolver instructions", "options":["YES","NO"], "expected_result":"YES", "category":"${fe(e.categories)}", "subcategory":"...", "tags":["lowercase"], "suggested_duration_hours":24, "trading_end_time":"ISO 8601 UTC (optional)", "source_references":["full URL"], "virality_score":7, "resolution_url_confidence":8, "is_already_decided":false, "already_decided_reason":"", "yes_probability":0.55, "option_probabilities":null, "news_context":[{"title":"...", "url":"...", "source":"..."}]}
|
|
88
114
|
|
|
89
115
|
FIELD GUIDANCE:
|
|
90
116
|
- prompt: Binary \u2192 tell agent what to check and YES/NO criteria. Multi-outcome \u2192 tell agent which option won, returning exact option string.
|
|
@@ -100,8 +126,8 @@ QUESTION NAMING \u2014 be SPECIFIC:
|
|
|
100
126
|
Always include teams/competitors + competition, price thresholds + timeframe, specific event/award names, who + what + when. A reader must understand the question without additional context.
|
|
101
127
|
|
|
102
128
|
SCORING:
|
|
103
|
-
- virality_score (1-10): ${Object.entries(de).map(([n,
|
|
104
|
-
- resolution_url_confidence (1-10): ${Object.entries(me).map(([n,
|
|
129
|
+
- virality_score (1-10): ${Object.entries(de).map(([n,a])=>`${n} ${a}`).join(", ")}.
|
|
130
|
+
- resolution_url_confidence (1-10): ${Object.entries(me).map(([n,a])=>`${n} ${a}`).join(", ")}.
|
|
105
131
|
|
|
106
132
|
SOURCE-SPECIFIC RULES:
|
|
107
133
|
- Crypto: Use CoinGecko coin pages, confidence 9-10, duration 1-6h.
|
|
@@ -109,11 +135,11 @@ SOURCE-SPECIFIC RULES:
|
|
|
109
135
|
- News: Find specific data-rich pages. For search-based: use news.google.com/search?q=... URLs.
|
|
110
136
|
- Polymarket: Keep same trading_end_time, proposition, deadline, threshold. Use outcomePrices for probabilities. EXCEPTION: convert hidden multi-outcome as above.
|
|
111
137
|
|
|
112
|
-
${
|
|
138
|
+
${W(e.bannedDomains)}
|
|
113
139
|
|
|
114
140
|
source_references[0] is the URL the AI resolver visits. Must be a FULL URL to a specific page with relevant data. The "prompt" field tells the resolver exactly what to look for on that page.
|
|
115
|
-
${
|
|
116
|
-
${
|
|
141
|
+
${e.extraInstructions?`
|
|
142
|
+
${e.extraInstructions}`:""}`}function we(t){let e={minOptions:4,maxOptions:10,...t};return`You are a prediction market analyst. Given a list of market candidate headlines, identify groups of candidates that are about the SAME underlying event or competition and should be combined into a single multi-outcome market instead of separate binary yes/no markets.
|
|
117
143
|
|
|
118
144
|
Examples of candidates that should be grouped:
|
|
119
145
|
- "Will Naomi Osaka win the 2026 WTA Miami Open?" + "Will Aryna Sabalenka win the 2026 WTA Miami Open?" \u2192 "Who will win the 2026 WTA Miami Open?" with all realistic contenders
|
|
@@ -128,15 +154,15 @@ Examples that should NOT be grouped:
|
|
|
128
154
|
For each group you identify:
|
|
129
155
|
1. Write the multi-outcome question (e.g., "Who will win X?")
|
|
130
156
|
2. List ALL realistic options, not just the ones from the candidates. Add well-known contenders, favorites, and realistic possibilities that the source missed. Include "Other" as the last option.
|
|
131
|
-
3. Aim for ${
|
|
157
|
+
3. Aim for ${e.minOptions}-${e.maxOptions} options (including Other). Include anyone with a realistic chance (>2%).
|
|
132
158
|
4. Only group candidates that are clearly about the same specific event/competition.
|
|
133
159
|
|
|
134
160
|
Return ONLY valid JSON (no markdown, no code fences):
|
|
135
161
|
{ "groups": [{ "question": "...", "candidateIndices": [0, 3, 7], "options": ["Option A", "Option B", ..., "Other"] }] }
|
|
136
162
|
|
|
137
163
|
If no candidates should be grouped, return: { "groups": [] }
|
|
138
|
-
${
|
|
139
|
-
${
|
|
164
|
+
${e.extraInstructions?`
|
|
165
|
+
${e.extraInstructions}`:""}`}function Te(t){let e={confidenceTiers:pe,lowConfidenceOverride:T,...t},r=e.confidenceTiers;return`You are evaluating whether a prediction market resolved correctly. You will be given the market question, resolution criteria, and content from a resolution URL. Your job is to determine the outcome based SOLELY on evidence found in the URL content.
|
|
140
166
|
|
|
141
167
|
EVIDENCE RULES:
|
|
142
168
|
- Your ONLY source of truth is the provided URL content. Nothing else.
|
|
@@ -152,7 +178,7 @@ CONFIDENCE RULES:
|
|
|
152
178
|
- ${r.tangential.min}-${r.tangential.max}: ${r.tangential.label}.
|
|
153
179
|
- ${r.none.min}-${r.none.max}: ${r.none.label}. You MUST return UNKNOWN in this case.
|
|
154
180
|
|
|
155
|
-
Current date/time: ${
|
|
181
|
+
Current date/time: ${ye()}
|
|
156
182
|
|
|
157
183
|
Respond with ONLY valid JSON (no markdown, no code fences):
|
|
158
184
|
{
|
|
@@ -160,22 +186,22 @@ Respond with ONLY valid JSON (no markdown, no code fences):
|
|
|
160
186
|
"confidence": 0.0 to 1.0,
|
|
161
187
|
"reasoning": "Quote or cite the specific evidence from the URL content that supports your answer, or explain why the URL content was insufficient"
|
|
162
188
|
}
|
|
163
|
-
${
|
|
164
|
-
${
|
|
189
|
+
${e.extraInstructions?`
|
|
190
|
+
${e.extraInstructions}`:""}`}function Ee(t){let e={maxSlots:10,...t};return`You are a prediction market curator selecting events for a homepage carousel.
|
|
165
191
|
|
|
166
|
-
Pick exactly ${
|
|
192
|
+
Pick exactly ${e.maxSlots} events from the candidate list to maximize engagement. Selection criteria (priority order):
|
|
167
193
|
1. Trending & timely \u2014 cross-reference with Polymarket trending data. Prefer current hot topics.
|
|
168
194
|
2. Category diversity \u2014 spread across politics, sport, tech, pop_culture, crypto, entertainment, science.
|
|
169
195
|
3. Urgency \u2014 events closing within 1-7 days beat distant ones.
|
|
170
196
|
4. Volume signal \u2014 higher volume = more interest.
|
|
171
197
|
5. De-prioritize lightning markets (5-min BTC) unless genuinely trending.
|
|
172
198
|
6. Match Polymarket trends \u2014 prefer events covering the same hot topics.
|
|
173
|
-
${
|
|
199
|
+
${e.extraCriteria?`7. ${e.extraCriteria}`:""}
|
|
174
200
|
|
|
175
201
|
ONLY select from candidate event ids. Return ONLY raw JSON:
|
|
176
202
|
{"selected_event_ids": [123, 456, ...], "reasoning": "Brief explanation"}
|
|
177
|
-
${
|
|
178
|
-
${
|
|
203
|
+
${e.extraInstructions?`
|
|
204
|
+
${e.extraInstructions}`:""}`}function Pe(t){let e={calibration:ge,...t},r=e.calibration;return`You are a world-class probability estimation expert with deep domain knowledge. Given a group of mutually exclusive outcomes, estimate realistic probabilities that each will occur. Your probabilities MUST sum to exactly 1.0.
|
|
179
205
|
|
|
180
206
|
Current date: ${Ke()}
|
|
181
207
|
|
|
@@ -191,14 +217,14 @@ CALIBRATION RULES \u2014 critical for realistic odds:
|
|
|
191
217
|
- Your estimates should resemble real betting/prediction market odds
|
|
192
218
|
|
|
193
219
|
Return ONLY a JSON object mapping each option name (exactly as given) to its probability. No explanation.
|
|
194
|
-
${
|
|
195
|
-
${
|
|
220
|
+
${e.extraInstructions?`
|
|
221
|
+
${e.extraInstructions}`:""}`}function Ae(t){let e={entityTypes:v,maxEntities:2,...t};return`Analyze this prediction market question and extract the PRIMARY visual entity that should be shown as a thumbnail image.
|
|
196
222
|
|
|
197
223
|
Return ONLY valid JSON (no markdown) with this structure:
|
|
198
224
|
{
|
|
199
225
|
"entities": [
|
|
200
226
|
{
|
|
201
|
-
"type": "${
|
|
227
|
+
"type": "${e.entityTypes.join("|")}",
|
|
202
228
|
"name": "exact name",
|
|
203
229
|
"searchQuery": "optimized search query for finding an image"
|
|
204
230
|
}
|
|
@@ -206,7 +232,7 @@ Return ONLY valid JSON (no markdown) with this structure:
|
|
|
206
232
|
}
|
|
207
233
|
|
|
208
234
|
Rules:
|
|
209
|
-
- Return at most ${
|
|
235
|
+
- Return at most ${e.maxEntities} entities, prioritizing the MOST VISUALLY DISTINCTIVE one first
|
|
210
236
|
- For geopolitical events (wars, treaties, sanctions): extract the PRIMARY country involved
|
|
211
237
|
- For sports: extract the team name (not the league)
|
|
212
238
|
- For people (politicians, celebrities, athletes): extract the person's full name
|
|
@@ -220,21 +246,21 @@ Examples:
|
|
|
220
246
|
- "Will Trump win the election?" \u2192 [{"type": "person", "name": "Donald Trump", "searchQuery": "Donald Trump portrait"}]
|
|
221
247
|
- "Lakers vs Celtics game" \u2192 [{"type": "team", "name": "Los Angeles Lakers", "searchQuery": "Lakers logo"}]
|
|
222
248
|
- "S&P 500 price movement" \u2192 [{"type": "topic", "name": "S&P 500", "searchQuery": "stock market chart"}]
|
|
223
|
-
${
|
|
224
|
-
${
|
|
249
|
+
${e.extraInstructions?`
|
|
250
|
+
${e.extraInstructions}`:""}`}function Re(t){let e={maxArticles:4,preferredSources:["ESPN","BBC","Reuters","CoinDesk","Bloomberg","AP News"],...t};return`You are a news research assistant. Given a prediction market question, find 2-${e.maxArticles} real, currently accessible news articles that provide relevant background context for this market.
|
|
225
251
|
|
|
226
252
|
Return ONLY valid JSON (no markdown, no code fences) \u2014 an array of objects:
|
|
227
253
|
[{"title": "Article headline", "url": "https://full-url.com/article", "source": "Publication Name"}]
|
|
228
254
|
|
|
229
255
|
Rules:
|
|
230
256
|
- Only include articles you found via web search \u2014 do NOT fabricate or guess URLs.
|
|
231
|
-
- Prefer recent articles from reputable sources (${
|
|
257
|
+
- Prefer recent articles from reputable sources (${e.preferredSources.join(", ")}, etc.).
|
|
232
258
|
- For sports: match previews, team form, injury reports, head-to-head records.
|
|
233
259
|
- For crypto: price analysis, market commentary, regulatory news.
|
|
234
260
|
- For politics: polling data, policy analysis, expert commentary.
|
|
235
261
|
- If you cannot find relevant articles, return an empty array [].
|
|
236
|
-
${
|
|
237
|
-
${
|
|
262
|
+
${e.extraInstructions?`
|
|
263
|
+
${e.extraInstructions}`:""}`}function Ie(t){let e={bannedDomains:l,...t};return`Resolution URL confidence rubric (resolution_url_confidence, 1-10):
|
|
238
264
|
- 9-10: URL always contains the answer (CoinGecko price page, ESPN scoreboard, official results page)
|
|
239
265
|
- 7-8: URL very likely has the answer (major news site live page, official standings)
|
|
240
266
|
- 4-6: URL might have relevant info but uncertain (general news article, social media)
|
|
@@ -252,8 +278,8 @@ Source-specific URL guidance:
|
|
|
252
278
|
- News: Find the most specific, data-rich page possible. For search-based resolution: Use Google News search URLs like https://news.google.com/search?q=specific+search+terms.
|
|
253
279
|
- Pop culture / entertainment: Use official announcement pages or news search URLs.
|
|
254
280
|
|
|
255
|
-
${
|
|
281
|
+
${W(e.bannedDomains)}
|
|
256
282
|
If the only resolution URL for a market would be a banned domain, either find an alternative or set resolution_url_confidence to 2 or below.
|
|
257
|
-
${
|
|
258
|
-
${
|
|
283
|
+
${e.extraGuidance?`
|
|
284
|
+
${e.extraGuidance}`:""}`}function E(t,e){let r=e?.min??1,n=e?.max??720,a=e?.fallback??168,i=typeof t=="number"&&Number.isFinite(t)?t:a;return Math.min(n,Math.max(r,i))}function ke(t,e){let r=e?.min??.05,n=e?.max??.95;return Math.min(n,Math.max(r,t))}function xe(t,e){let r=e?.min??.02,n=e?.max??.95,a=t.map(s=>Math.min(n,Math.max(r,s))),i=a.reduce((s,d)=>s+d,0);return i===0?t.map(()=>1/t.length):a.map(s=>s/i)}function Ce(t){try{let e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}}function _e(t,e){let r=new Set(e??l);try{let n=new URL(t).hostname;return r.has(n)||r.has(n.replace(/^www\./,""))}catch{return!1}}function Ne(t){let e=t.replace(/[?!.,;:'"]/g,"").split(/\s+/).slice(0,10).join("+");return`https://news.google.com/search?q=${encodeURIComponent(e)}`}function Oe(t){let e=t.trim();if(e.includes("```")){let i=e.match(/```(?:json)?\s*([\s\S]*?)```/);i?.[1]&&(e=i[1].trim())}if(!e.startsWith("{")){let i=e.indexOf("{");i!==-1&&(e=e.slice(i))}if(e.includes("}")){let i=e.lastIndexOf("}");e=e.slice(0,i+1)}e=e.replace(/"(?:[^"\\]|\\.)*"/g,i=>i.replace(/\n/g,"\\n").replace(/\r/g,"\\r")),e=e.replace(/,\s*([}\]])/g,"$1");let r;try{r=JSON.parse(e)}catch{throw new Error("Failed to parse LLM response as JSON. Please try again.")}let n=r;if(typeof n.question!="string"||!n.question)throw new Error("Generated market is missing a question");if(!Array.isArray(n.options)||n.options.length<2)throw new Error("Generated market must have at least 2 options");let a;if(typeof n.trading_end_time=="string"&&n.trading_end_time){let i=new Date(n.trading_end_time),s=Date.now();!Number.isNaN(i.getTime())&&i.getTime()>s?a=E((i.getTime()-s)/36e5):a=E(n.suggested_duration_hours)}else a=E(n.suggested_duration_hours);return{question:n.question,description:n.description||"",resolution_criteria:n.resolution_criteria||"",prompt:n.prompt||n.question,options:n.options,expected_result:n.expected_result||n.options[0]||"",category:n.category||b,subcategory:n.subcategory||"",tags:Array.isArray(n.tags)?n.tags:[],suggested_duration_hours:a,source_references:Array.isArray(n.source_references)?n.source_references:[],_raw:n}}var H=require("viem/accounts"),Se=60,Le={name:"VenueRegistry",version:"1"},Je={CreateMarketPermit:[{name:"name",type:"string"},{name:"venueId",type:"uint256"},{name:"tradingStartTs",type:"uint256"},{name:"tradingEndTs",type:"uint256"},{name:"resolutionStartTs",type:"uint256"},{name:"resolutionEndTs",type:"uint256"},{name:"stakeToken",type:"address"},{name:"initialLiquidityBase",type:"uint256"},{name:"noMatchOutcome",type:"uint8"},{name:"resolverType",type:"uint8"},{name:"creator",type:"address"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},Xe={TradePermit:[{name:"marketId",type:"uint256"},{name:"venueId",type:"uint256"},{name:"user",type:"address"},{name:"amount",type:"uint256"},{name:"action",type:"uint8"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]};async function Ue(t){let e=(0,H.privateKeyToAccount)(t.operatorPrivateKey),r=BigInt(Math.floor(Date.now()/1e3)+Se);return{signature:await e.signTypedData({domain:{...Le,chainId:t.chainId,verifyingContract:t.venueRegistryAddress},types:Xe,primaryType:"TradePermit",message:{marketId:t.marketId,venueId:t.venueId,user:t.user,amount:t.amount,action:t.action,nonce:t.nonce,deadline:r}}),signer:e.address,deadline:r}}async function De(t){let e=(0,H.privateKeyToAccount)(t.operatorPrivateKey),r=BigInt(Math.floor(Date.now()/1e3)+Se);return{signature:await e.signTypedData({domain:{...Le,chainId:t.chainId,verifyingContract:t.venueRegistryAddress},types:Je,primaryType:"CreateMarketPermit",message:{name:t.name,venueId:t.venueId,tradingStartTs:BigInt(t.tradingStartTs),tradingEndTs:BigInt(t.tradingEndTs),resolutionStartTs:BigInt(t.resolutionStartTs),resolutionEndTs:BigInt(t.resolutionEndTs),stakeToken:t.stakeToken,initialLiquidityBase:t.initialLiquidityBase,noMatchOutcome:t.noMatchOutcome,resolverType:t.resolverType,creator:t.creator,nonce:t.nonce,deadline:r}}),signer:e.address,deadline:r}}0&&(module.exports={ACTIVE_MARKET_CAP,ApiError,BANNED_DOMAINS,CATEGORIES,DEFAULT_CATEGORY,DEFAULT_DURATION_HOURS,DEFAULT_LIQUIDITY,DEFAULT_RESOLUTION_HOURS,DEFAULT_TRADING_START_BUFFER_SECONDS,DURATION_HINTS,ENTITY_TYPES,LOW_CONFIDENCE_OVERRIDE,MARKET_DEFAULTS,MAX_BINARY_PROBABILITY,MAX_DURATION_HOURS,MAX_OPTION_PROBABILITY,MIN_BINARY_PROBABILITY,MIN_DURATION_HOURS,MIN_OPTION_PROBABILITY,RESOLUTION_CONFIDENCE_THRESHOLD,SIMILARITY_THRESHOLD,VIRALITY_THRESHOLD,buildCarouselPrompt,buildEntityExtractionPrompt,buildGroupingPrompt,buildMarketGenerationPrompt,buildNewsContextPrompt,buildProbabilityEstimationPrompt,buildReframePrompt,buildResolutionEvalPrompt,buildUrlGuidanceBlock,clampBinaryProbability,clampDuration,createCache,createChainClient,createEventsApiNamespace,createMarketDefinition,createProphecyClient,getEventRating,getPPLeaderboard,getPnLLeaderboard,getVolumeLeaderboard,googleNewsFallbackUrl,isBannedDomain,isValidUrl,marketDefinitionSchema,normalizeOptionProbabilities,parseLlmMarketJson,previewRating,rateMarketDraft,signCreateMarketPermit,signTradePermit});
|
|
259
285
|
//# sourceMappingURL=index.cjs.map
|