@prophecy-dev/sdk 0.1.2 → 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 CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var Y=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)Y(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&&Y(e,i,{get:()=>t[i],enumerable:!(n=Be(t,i))||n.enumerable});return e};var qe=e=>Ve(Y({},"__esModule",{value:!0}),e);var q={};G(q,{ApiError:()=>m,authedDelete:()=>V,authedPost:()=>f,get:()=>o,post:()=>g});async function E(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 o(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 E(n)}function g(e,t,r){return E(new URL(t,e),{method:"POST",body:r})}function f(e,t,r,n){return E(new URL(t,e),{method:"POST",body:r,headers:{Authorization:`Bearer ${n}`}})}function V(e,t,r){return E(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:()=>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:()=>ae,SIMILARITY_THRESHOLD:()=>se,VIRALITY_THRESHOLD:()=>ie,buildCarouselPrompt:()=>Pe,buildEntityExtractionPrompt:()=>Ae,buildGroupingPrompt:()=>we,buildMarketGenerationPrompt:()=>be,buildNewsContextPrompt:()=>Ie,buildProbabilityEstimationPrompt:()=>Ee,buildReframePrompt:()=>ve,buildResolutionEvalPrompt:()=>Te,buildUrlGuidanceBlock:()=>Re,clampBinaryProbability:()=>xe,clampDuration:()=>P,createCache:()=>x,createChainClient:()=>_,createEventsApiNamespace:()=>C,createMarketDefinition:()=>ne,createProphecyClient:()=>te,getEventRating:()=>R,getPPLeaderboard:()=>N,getPnLLeaderboard:()=>S,getVolumeLeaderboard:()=>O,googleNewsFallbackUrl:()=>Ne,isBannedDomain:()=>Ce,isValidUrl:()=>_e,marketDefinitionSchema:()=>L,normalizeOptionProbabilities:()=>ke,parseLlmMarketJson:()=>Se,previewRating:()=>A,rateMarketDraft:()=>I,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 A(e,t){return g(e,"/v1/arbiter/preview",j(t))}async function I(e,t){let r=await g(e,"/v1/arbiter/preview",j(t));return He(r)}async function R(e,t,r){return o(e,`/v1/arbiter/events/${t}/${r}`)}function x(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 s=a??t;s!==0&&r.set(n,{data:i,expiresAt:Date.now()+s})},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"}],k=[{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 _(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:k,functionName:"getMarketCore",args:[n]});return{core:i,name:a}},async getReserves(n){let[i,a]=await r.readContract({address:e.prophecyCoreAddress,abi:k,functionName:"getCurrentReserves",args:[n]});return{yesPool:i,noPool:a}},async getUserPosition(n,i){return await r.readContract({address:e.prophecyCoreAddress,abi:k,functionName:"getUserPosition",args:[n,i]})},async getUserPositions(n,i){if(n.length===0)return[];let a=n.map(d=>({address:e.prophecyCoreAddress,abi:k,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),s=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json",Authorization:t.getAuthHeader()},body:JSON.stringify(i)});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,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 s of r.status)n.searchParams.append("status",s);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 s=await o(e,`/v0/events/${r}/${n}`);return t.set(i,s),s}}}u();function X(e,t,r){return{async eligibility(n){return o(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 N(e,t){return o(e,"/v1/stats/top-traders",{venue:t?.venue,limit:t?.limit})}async function S(e,t){return o(e,"/v0/leaderboard/pnl",{venue:t?.venue,period:t?.period,limit:t?.limit,cursor:t?.cursor})}async function O(e,t){return o(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(),q));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 s=await o(e,`/v0/markets/${r}/${n}`);return t.set(i,s),s}}}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 o(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 o(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 s=await o(e,`/v1/points/${r}`,n?.season?{season:n.season}:void 0);return t.set(i,s),s},async dashboard(r,n){let i=`user:${r}:dashboard:${n?.venue??"all"}`,a=t.get(i);if(a)return a;let s=await o(e,`/v1/users/${r}/dashboard`,n?.venue?{venue:n.venue}:void 0);return t.set(i,s),s},linkWallet:r=>g(e,"/v1/identity/link",r),linkedWallets:r=>o(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 s=await o(e,`/v1/venues/${r}/markets`,{status:n?.status});return t.set(i,s),s},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 s=await V(e,`/v1/venues/${r}/markets/${n}/${i}`,a);return t.invalidate(`venue:${r}`),s}},async stats(r,n){let i=`venue:${r}:stats:${n??"current"}`,a=t.get(i);if(a)return a;let s=await o(e,`/v1/points/venue/${r}`,n?{season:n}:void 0);return t.set(i,s),s},invalidate:r=>t.invalidate(`venue:${r}`),clearCache:()=>t.invalidate("venue:")}}function te(e){let t=x(e.cache),r=_({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=>N(e.partnersApiUrl,a),pnl:a=>S(e.dataApiUrl,a),volume:a=>O(e.dataApiUrl,a)},faucet:X(e.partnersApiUrl,e.venueId??"",n),events:n?J(e.partnersApiUrl,n):i,arbiter:{rate:a=>I(e.partnersApiUrl,a),preview:a=>A(e.partnersApiUrl,a),eventRating:(a,s)=>R(e.partnersApiUrl,a,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.
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
 
@@ -19,13 +19,31 @@ Set appropriate timestamps:
19
19
  - tradingStartTs: when trading opens (usually now or soon)
20
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(e){let t=e.systemPrompt??je(),r=e.userTimeZone?`
23
- User timezone: ${e.userTimeZone}. Interpret relative dates accordingly.`:"",{text:n}=await(0,re.generateText)({model:e.model,system:`${t}
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(L.shape)}`,prompt:`Create a prediction market for: "${e.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"],ie=6,ae=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 H(e){return`BANNED RESOLUTION DOMAINS (JS-rendered/auth-walled): ${e.join(", ")}. Use alternatives or set confidence \u2264 2.`}function fe(e){return e.join("|")}function be(e){let t={categories:h,defaultDurationHours:168,bannedDomains:l,...e};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.
27
-
28
- CURRENT DATE/TIME: ${ye()}
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,19 +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(t.categories)}",
56
+ "category": "${fe(e.categories)}",
39
57
  "subcategory": "a more specific subcategory",
40
58
  "tags": ["relevant", "tags", "for", "discovery"],
41
59
  "trading_end_time": "ISO 8601 UTC timestamp when trading should close",
42
- "suggested_duration_hours": ${t.defaultDurationHours},
43
- "source_references": ["https://relevant-source.com/specific-page"],
60
+ "suggested_duration_hours": ${e.defaultDurationHours},
61
+ "source_references": ["https://relevant-source.com/specific-page"],${n}
44
62
  "news_context": [{"title": "Article headline", "url": "https://source.com/article", "source": "Publication Name"}]
45
63
  }
46
64
 
47
65
  News context (news_context field):
48
66
  - Include 2-4 real, relevant news articles that provide background context for this market.
49
67
  - Each entry needs: "title" (article headline), "url" (full URL to the article), "source" (publication name).
50
- - Only include articles you found via web search \u2014 do NOT fabricate URLs. Return [] if none found.
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 [].
51
70
 
52
71
  Rules:
53
72
  - The question must be specific, unambiguous, and have a clear resolution date or condition
@@ -56,20 +75,25 @@ Rules:
56
75
  - If a specific event has ALREADY HAPPENED (results exist), do NOT create a market for it. Find the next upcoming instance instead.
57
76
  - Example: if user says "next F1 race winner" and the Australian GP already happened, find the actual next race on the calendar.
58
77
  - If the user specifies custom options (not yes/no), use those options instead
59
- - 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.
78
+ ${a}
60
79
  - expected_result should be one of the options
61
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".
62
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.
63
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.
64
84
  - Do NOT guess URL path segments you are unsure about (e.g., race numbers, event IDs). Use stable hub/event pages instead.
65
- - The prompt field is what the AI resolver will see when resolving the market \u2014 make it a clear, answerable question
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
66
87
  - Keep descriptions concise but informative
67
88
  - Tags should be lowercase, relevant keywords
68
- ${t.urlGuidance?`
69
- ${t.urlGuidance}`:""}
70
- ${t.extraInstructions?`
71
- ${t.extraInstructions}`:""}
72
- ${H(t.bannedDomains)}`}function ve(e){let t={categories:h,durationHints:w,bannedDomains:l,...e},r=Object.entries(t.durationHints).map(([n,i])=>`${n} ${i}`).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.
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.
73
97
 
74
98
  MARKET FORMAT:
75
99
 
@@ -86,7 +110,7 @@ Do NOT convert genuinely binary questions: price targets, policy decisions, weat
86
110
  When converting, include 4-8 realistic contenders plus "Other".
87
111
 
88
112
  Return ONLY valid JSON (no markdown, no code fences):
89
- {"question":"...", "description":"2-3 sentences", "resolution_criteria":"...", "prompt":"AI resolver instructions", "options":["YES","NO"], "expected_result":"YES", "category":"${fe(t.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":"..."}]}
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":"..."}]}
90
114
 
91
115
  FIELD GUIDANCE:
92
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.
@@ -102,8 +126,8 @@ QUESTION NAMING \u2014 be SPECIFIC:
102
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.
103
127
 
104
128
  SCORING:
105
- - virality_score (1-10): ${Object.entries(de).map(([n,i])=>`${n} ${i}`).join(", ")}.
106
- - resolution_url_confidence (1-10): ${Object.entries(me).map(([n,i])=>`${n} ${i}`).join(", ")}.
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(", ")}.
107
131
 
108
132
  SOURCE-SPECIFIC RULES:
109
133
  - Crypto: Use CoinGecko coin pages, confidence 9-10, duration 1-6h.
@@ -111,11 +135,11 @@ SOURCE-SPECIFIC RULES:
111
135
  - News: Find specific data-rich pages. For search-based: use news.google.com/search?q=... URLs.
112
136
  - Polymarket: Keep same trading_end_time, proposition, deadline, threshold. Use outcomePrices for probabilities. EXCEPTION: convert hidden multi-outcome as above.
113
137
 
114
- ${H(t.bannedDomains)}
138
+ ${W(e.bannedDomains)}
115
139
 
116
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.
117
- ${t.extraInstructions?`
118
- ${t.extraInstructions}`:""}`}function we(e){let t={minOptions:4,maxOptions:10,...e};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.
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.
119
143
 
120
144
  Examples of candidates that should be grouped:
121
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
@@ -130,15 +154,15 @@ Examples that should NOT be grouped:
130
154
  For each group you identify:
131
155
  1. Write the multi-outcome question (e.g., "Who will win X?")
132
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.
133
- 3. Aim for ${t.minOptions}-${t.maxOptions} options (including Other). Include anyone with a realistic chance (>2%).
157
+ 3. Aim for ${e.minOptions}-${e.maxOptions} options (including Other). Include anyone with a realistic chance (>2%).
134
158
  4. Only group candidates that are clearly about the same specific event/competition.
135
159
 
136
160
  Return ONLY valid JSON (no markdown, no code fences):
137
161
  { "groups": [{ "question": "...", "candidateIndices": [0, 3, 7], "options": ["Option A", "Option B", ..., "Other"] }] }
138
162
 
139
163
  If no candidates should be grouped, return: { "groups": [] }
140
- ${t.extraInstructions?`
141
- ${t.extraInstructions}`:""}`}function Te(e){let t={confidenceTiers:pe,lowConfidenceOverride:T,...e},r=t.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.
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.
142
166
 
143
167
  EVIDENCE RULES:
144
168
  - Your ONLY source of truth is the provided URL content. Nothing else.
@@ -162,22 +186,22 @@ Respond with ONLY valid JSON (no markdown, no code fences):
162
186
  "confidence": 0.0 to 1.0,
163
187
  "reasoning": "Quote or cite the specific evidence from the URL content that supports your answer, or explain why the URL content was insufficient"
164
188
  }
165
- ${t.extraInstructions?`
166
- ${t.extraInstructions}`:""}`}function Pe(e){let t={maxSlots:10,...e};return`You are a prediction market curator selecting events for a homepage carousel.
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.
167
191
 
168
- Pick exactly ${t.maxSlots} events from the candidate list to maximize engagement. Selection criteria (priority order):
192
+ Pick exactly ${e.maxSlots} events from the candidate list to maximize engagement. Selection criteria (priority order):
169
193
  1. Trending & timely \u2014 cross-reference with Polymarket trending data. Prefer current hot topics.
170
194
  2. Category diversity \u2014 spread across politics, sport, tech, pop_culture, crypto, entertainment, science.
171
195
  3. Urgency \u2014 events closing within 1-7 days beat distant ones.
172
196
  4. Volume signal \u2014 higher volume = more interest.
173
197
  5. De-prioritize lightning markets (5-min BTC) unless genuinely trending.
174
198
  6. Match Polymarket trends \u2014 prefer events covering the same hot topics.
175
- ${t.extraCriteria?`7. ${t.extraCriteria}`:""}
199
+ ${e.extraCriteria?`7. ${e.extraCriteria}`:""}
176
200
 
177
201
  ONLY select from candidate event ids. Return ONLY raw JSON:
178
202
  {"selected_event_ids": [123, 456, ...], "reasoning": "Brief explanation"}
179
- ${t.extraInstructions?`
180
- ${t.extraInstructions}`:""}`}function Ee(e){let t={calibration:ge,...e},r=t.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.
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.
181
205
 
182
206
  Current date: ${Ke()}
183
207
 
@@ -193,14 +217,14 @@ CALIBRATION RULES \u2014 critical for realistic odds:
193
217
  - Your estimates should resemble real betting/prediction market odds
194
218
 
195
219
  Return ONLY a JSON object mapping each option name (exactly as given) to its probability. No explanation.
196
- ${t.extraInstructions?`
197
- ${t.extraInstructions}`:""}`}function Ae(e){let t={entityTypes:v,maxEntities:2,...e};return`Analyze this prediction market question and extract the PRIMARY visual entity that should be shown as a thumbnail image.
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.
198
222
 
199
223
  Return ONLY valid JSON (no markdown) with this structure:
200
224
  {
201
225
  "entities": [
202
226
  {
203
- "type": "${t.entityTypes.join("|")}",
227
+ "type": "${e.entityTypes.join("|")}",
204
228
  "name": "exact name",
205
229
  "searchQuery": "optimized search query for finding an image"
206
230
  }
@@ -208,7 +232,7 @@ Return ONLY valid JSON (no markdown) with this structure:
208
232
  }
209
233
 
210
234
  Rules:
211
- - Return at most ${t.maxEntities} entities, prioritizing the MOST VISUALLY DISTINCTIVE one first
235
+ - Return at most ${e.maxEntities} entities, prioritizing the MOST VISUALLY DISTINCTIVE one first
212
236
  - For geopolitical events (wars, treaties, sanctions): extract the PRIMARY country involved
213
237
  - For sports: extract the team name (not the league)
214
238
  - For people (politicians, celebrities, athletes): extract the person's full name
@@ -222,21 +246,21 @@ Examples:
222
246
  - "Will Trump win the election?" \u2192 [{"type": "person", "name": "Donald Trump", "searchQuery": "Donald Trump portrait"}]
223
247
  - "Lakers vs Celtics game" \u2192 [{"type": "team", "name": "Los Angeles Lakers", "searchQuery": "Lakers logo"}]
224
248
  - "S&P 500 price movement" \u2192 [{"type": "topic", "name": "S&P 500", "searchQuery": "stock market chart"}]
225
- ${t.extraInstructions?`
226
- ${t.extraInstructions}`:""}`}function Ie(e){let t={maxArticles:4,preferredSources:["ESPN","BBC","Reuters","CoinDesk","Bloomberg","AP News"],...e};return`You are a news research assistant. Given a prediction market question, find 2-${t.maxArticles} real, currently accessible news articles that provide relevant background context for this market.
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.
227
251
 
228
252
  Return ONLY valid JSON (no markdown, no code fences) \u2014 an array of objects:
229
253
  [{"title": "Article headline", "url": "https://full-url.com/article", "source": "Publication Name"}]
230
254
 
231
255
  Rules:
232
256
  - Only include articles you found via web search \u2014 do NOT fabricate or guess URLs.
233
- - Prefer recent articles from reputable sources (${t.preferredSources.join(", ")}, etc.).
257
+ - Prefer recent articles from reputable sources (${e.preferredSources.join(", ")}, etc.).
234
258
  - For sports: match previews, team form, injury reports, head-to-head records.
235
259
  - For crypto: price analysis, market commentary, regulatory news.
236
260
  - For politics: polling data, policy analysis, expert commentary.
237
261
  - If you cannot find relevant articles, return an empty array [].
238
- ${t.extraInstructions?`
239
- ${t.extraInstructions}`:""}`}function Re(e){let t={bannedDomains:l,...e};return`Resolution URL confidence rubric (resolution_url_confidence, 1-10):
262
+ ${e.extraInstructions?`
263
+ ${e.extraInstructions}`:""}`}function Ie(t){let e={bannedDomains:l,...t};return`Resolution URL confidence rubric (resolution_url_confidence, 1-10):
240
264
  - 9-10: URL always contains the answer (CoinGecko price page, ESPN scoreboard, official results page)
241
265
  - 7-8: URL very likely has the answer (major news site live page, official standings)
242
266
  - 4-6: URL might have relevant info but uncertain (general news article, social media)
@@ -254,8 +278,8 @@ Source-specific URL guidance:
254
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.
255
279
  - Pop culture / entertainment: Use official announcement pages or news search URLs.
256
280
 
257
- ${H(t.bannedDomains)}
281
+ ${W(e.bannedDomains)}
258
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.
259
- ${t.extraGuidance?`
260
- ${t.extraGuidance}`:""}`}function P(e,t){let r=t?.min??1,n=t?.max??720,i=t?.fallback??168,a=typeof e=="number"&&Number.isFinite(e)?e:i;return Math.min(n,Math.max(r,a))}function xe(e,t){let r=t?.min??.05,n=t?.max??.95;return Math.min(n,Math.max(r,e))}function ke(e,t){let r=t?.min??.02,n=t?.max??.95,i=e.map(s=>Math.min(n,Math.max(r,s))),a=i.reduce((s,d)=>s+d,0);return a===0?e.map(()=>1/e.length):i.map(s=>s/a)}function _e(e){try{let t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}function Ce(e,t){let r=new Set(t??l);try{let n=new URL(e).hostname;return r.has(n)||r.has(n.replace(/^www\./,""))}catch{return!1}}function Ne(e){let t=e.replace(/[?!.,;:'"]/g,"").split(/\s+/).slice(0,10).join("+");return`https://news.google.com/search?q=${encodeURIComponent(t)}`}function Se(e){let t=e.trim();if(t.includes("```")){let a=t.match(/```(?:json)?\s*([\s\S]*?)```/);a?.[1]&&(t=a[1].trim())}if(!t.startsWith("{")){let a=t.indexOf("{");a!==-1&&(t=t.slice(a))}if(t.includes("}")){let a=t.lastIndexOf("}");t=t.slice(0,a+1)}t=t.replace(/"(?:[^"\\]|\\.)*"/g,a=>a.replace(/\n/g,"\\n").replace(/\r/g,"\\r")),t=t.replace(/,\s*([}\]])/g,"$1");let r;try{r=JSON.parse(t)}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 i;if(typeof n.trading_end_time=="string"&&n.trading_end_time){let a=new Date(n.trading_end_time),s=Date.now();!Number.isNaN(a.getTime())&&a.getTime()>s?i=P((a.getTime()-s)/36e5):i=P(n.suggested_duration_hours)}else i=P(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:i,source_references:Array.isArray(n.source_references)?n.source_references:[],_raw:n}}var W=require("viem/accounts"),Oe=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(e){let t=(0,W.privateKeyToAccount)(e.operatorPrivateKey),r=BigInt(Math.floor(Date.now()/1e3)+Oe);return{signature:await t.signTypedData({domain:{...Le,chainId:e.chainId,verifyingContract:e.venueRegistryAddress},types:Xe,primaryType:"TradePermit",message:{marketId:e.marketId,venueId:e.venueId,user:e.user,amount:e.amount,action:e.action,nonce:e.nonce,deadline:r}}),signer:t.address,deadline:r}}async function De(e){let t=(0,W.privateKeyToAccount)(e.operatorPrivateKey),r=BigInt(Math.floor(Date.now()/1e3)+Oe);return{signature:await t.signTypedData({domain:{...Le,chainId:e.chainId,verifyingContract:e.venueRegistryAddress},types:Je,primaryType:"CreateMarketPermit",message:{name:e.name,venueId:e.venueId,tradingStartTs:BigInt(e.tradingStartTs),tradingEndTs:BigInt(e.tradingEndTs),resolutionStartTs:BigInt(e.resolutionStartTs),resolutionEndTs:BigInt(e.resolutionEndTs),stakeToken:e.stakeToken,initialLiquidityBase:e.initialLiquidityBase,noMatchOutcome:e.noMatchOutcome,resolverType:e.resolverType,creator:e.creator,nonce:e.nonce,deadline:r}}),signer:t.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});
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});
261
285
  //# sourceMappingURL=index.cjs.map