@kuest/bindings 0.0.0-stage → 0.13.1

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.
@@ -0,0 +1,2 @@
1
+ import {ba,Ra,Fa,da,fa,qa,pa,Ea,aa,Oa,$ as $$1,Aa,Ua,Y as Y$1,na,Qa,ia,Pa,A as A$1,Ga,w,U,q,G}from'../chunk-2KNK5TP7.js';import {z}from'zod';var Y=(_=>(_.TRADE="TRADE",_.SPLIT="SPLIT",_.MERGE="MERGE",_.REDEEM="REDEEM",_.REWARD="REWARD",_.CONVERSION="CONVERSION",_.MIGRATION="MIGRATION",_.MAKER_REBATE="MAKER_REBATE",_.REFERRAL_REWARD="REFERRAL_REWARD",_.YIELD="YIELD",_.DEPOSIT="DEPOSIT",_.WITHDRAWAL="WITHDRAWAL",_.TAKER_REBATE="TAKER_REBATE",_.TIP="TIP",_))(Y||{}),me=z.enum(Y),de=(i=>(i.In="IN",i.Out="OUT",i))(de||{}),$=z.enum(de),ce=(i=>(i.Asc="ASC",i.Desc="DESC",i))(ce||{}),wt=z.enum(ce),pe=(i=>(i.Cash="CASH",i.Tokens="TOKENS",i))(pe||{}),Zt=z.enum(pe);function Ze(e){let t=e.length===64?`${e}00`:e;return q(t.toLowerCase())}function Ke(e){if(e.length===66)return true;let t=e.toLowerCase();return t.startsWith("0x01")||t.startsWith("0x02")}var Kt=ba.refine(Ke,"Expected a 32-byte condition ID or a 31-byte protocol v2 market condition ID").transform(Ze);function A(e){return z.object({data:z.array(e),pagination:z.object({limit:z.number().int(),offset:z.number().int(),has_more:z.boolean(),next_cursor:z.string().min(1).nullable()})}).refine(t=>t.pagination.has_more===(t.pagination.next_cursor!==null),{message:"has_more and next_cursor must agree",path:["pagination","next_cursor"]}).transform(({data:t,pagination:i})=>({items:t,hasMore:i.has_more,nextCursor:i.next_cursor===null?void 0:G(i.next_cursor)}))}function f(e){return z.object({data:e}).transform(t=>t.data)}var ge=(l=>(l.Open="OPEN",l.Redeemable="REDEEMABLE",l.Partial="PARTIAL",l.ResolvedPartial="RESOLVED_PARTIAL",l.ResolvedWin="RESOLVED_WIN",l.ResolvedLoss="RESOLVED_LOSS",l))(ge||{}),_e=z.enum(ge),be=(m=>(m.Open="OPEN",m.Redeemable="REDEEMABLE",m.RedeemableLost="REDEEMABLE_LOST",m.Mergeable="MERGEABLE",m.Closed="CLOSED",m))(be||{}),eo=z.enum(be),Ge=z.enum(["OPEN","REDEEMABLE","CLOSED"]),ye=(p=>(p.CurrentValue="CURRENT_VALUE",p.Price="PRICE",p.Tokens="TOKENS",p.UnrealizedPnl="UNREALIZED_PNL",p.RealizedPnl="REALIZED_PNL",p.TotalPnl="TOTAL_PNL",p.Timestamp="TIMESTAMP",p))(ye||{}),to=z.enum(ye),Se=(i=>(i.Cash="CASH",i.Tokens="TOKENS",i))(Se||{}),oo=z.enum(Se),fe=(r=>(r.FirstEntry="FIRST_ENTRY",r.EntryCost="ENTRY_COST",r.CurrentValue="CURRENT_VALUE",r.Updated="UPDATED",r))(fe||{}),no=z.enum(fe),k=z.preprocess(e=>e===""?void 0:e,z.string().optional()),qe=z.preprocess(e=>e===999?void 0:e,z.number().int().optional()),Ye=z.object({proxy_wallet:da,token_id:Fa,condition_id:ba,current_size:Ra,avg_price:Ra,entry_cost_usdc:Ra,entry_fees_usdc:Ra,total_cost_usdc:Ra,current_price:Ra,current_value:Ra,total_size:Ra,realized_pnl:Ra,unrealized_pnl:Ra,total_pnl:Ra,percent_pnl:Ra,percent_realized_pnl:Ra,status:Ge,redeemable:z.boolean(),mergeable:z.boolean(),negative_risk:z.boolean(),archived:z.boolean(),title:k,slug:k,icon:k,event_id:k,event_slug:k,outcome:k,outcome_index:qe,opposite_outcome:k,opposite_token_id:z.preprocess(e=>e===""?void 0:e,Fa.optional()),end_date:z.preprocess(e=>e===""?void 0:e,qa.optional()),last_event_at:z.preprocess(e=>e===0?void 0:e,fa.optional()),first_entry_at:z.preprocess(e=>e===0?void 0:e,fa.optional()),name:k,profile_image:k,verified:z.boolean()}).transform(e=>({wallet:e.proxy_wallet,assetId:e.token_id,tokenId:e.token_id,conditionId:e.condition_id,currentSize:e.current_size,avgPrice:e.avg_price,entryCostUsdc:e.entry_cost_usdc,entryFeesUsdc:e.entry_fees_usdc,totalCostUsdc:e.total_cost_usdc,currentPrice:e.current_price,currentValue:e.current_value,totalSize:e.total_size,realizedPnl:e.realized_pnl,unrealizedPnl:e.unrealized_pnl,totalPnl:e.total_pnl,percentPnl:e.percent_pnl,percentRealizedPnl:e.percent_realized_pnl,status:e.status,redeemable:e.redeemable,mergeable:e.mergeable,negativeRisk:e.negative_risk,archived:e.archived,title:e.title,slug:e.slug,icon:e.icon,eventId:e.event_id,eventSlug:e.event_slug,outcome:e.outcome,outcomeIndex:e.outcome_index,oppositeOutcome:e.opposite_outcome,oppositeAssetId:e.opposite_token_id,oppositeTokenId:e.opposite_token_id,endDate:e.end_date,lastEventAt:e.last_event_at,firstEntryAt:e.first_entry_at,name:e.name,profileImage:e.profile_image,verified:e.verified})),$e=z.object({proxy_wallet:da,value:Ra}).transform(({proxy_wallet:e,value:t})=>({wallet:e,value:t})),he=(l=>(l.Max="max",l.OneMonth="1m",l.OneWeek="1w",l.OneDay="1d",l.TwelveHours="12h",l.SixHours="6h",l))(he||{}),Qe=z.enum(he),Ie=(m=>(m.OneDay="1d",m.EighteenHours="18h",m.TwelveHours="12h",m.ThreeHours="3h",m.OneHour="1h",m))(Ie||{}),ue=z.enum(Ie),b=Ra.nullish().transform(e=>e??null),ve=z.object({timestamp:fa,source_block:z.number().int().nonnegative(),realized_market_pnl:Ra,realized_lp_pnl:Ra,realized_combo_pnl:Ra,unrealized_pnl:b,fees_refunded:b,maker_rebate:b,taker_rebate:b,reward_income:b,yield_income:b,referral_income:b,deposits:b,withdrawals:b,realized_pnl:Ra,wallet_income:b,position_pnl:b,settled_pnl:b,economic_pnl:b,trade_pnl:b,sponsored_income:b,fees:b,fees_paid:b,cashflow_net:b,volume:Ra,volume_usdc:Ra,trade_count:z.number().int().nonnegative()}).transform(({source_block:e,realized_market_pnl:t,realized_lp_pnl:i,realized_combo_pnl:a,unrealized_pnl:r,fees_refunded:m,maker_rebate:l,taker_rebate:p,reward_income:O,yield_income:C,referral_income:H,realized_pnl:F,wallet_income:j,position_pnl:w,settled_pnl:_,economic_pnl:Z,trade_pnl:K,sponsored_income:G,fees_paid:We,cashflow_net:He,volume_usdc:Fe,trade_count:je,...we})=>({...we,sourceBlock:e,realizedMarketPnl:t,realizedLpPnl:i,realizedComboPnl:a,unrealizedPnl:r,feesRefunded:m,makerRebate:l,takerRebate:p,rewardIncome:O,yieldIncome:C,referralIncome:H,realizedPnl:F,walletIncome:j,positionPnl:w,settledPnl:_,economicPnl:Z,tradePnl:K,sponsoredIncome:G,feesPaid:We,cashflowNet:He,volumeUsdc:Fe,tradeCount:je})),Je=z.object({proxy_wallet:da,interval:Qe,fidelity:ue,source_fidelity:ue,points:z.array(ve)}).transform(({proxy_wallet:e,source_fidelity:t,...i})=>({...i,wallet:e,sourceFidelity:t})),Xe=z.object({volume:Ra,volume_usdc:Ra,trade_count:z.number().int().nonnegative()}).transform(({volume_usdc:e,trade_count:t,...i})=>({...i,volumeUsdc:e,tradeCount:t})),et=z.object({proxy_wallet:da,trades:z.number().int().nonnegative(),biggest_win:Ra,views:z.number().int().nonnegative(),join_date:fa.nullish(),all_time_pnl:ve.nullish()}).transform(({proxy_wallet:e,trades:t,biggest_win:i,join_date:a,all_time_pnl:r,...m})=>({...m,wallet:e,tradedMarketCount:t,biggestWin:i,joinDate:a??null,allTimePnl:r??null})),tt=z.object({event_id:z.string().nullish(),event_slug:z.string().nullish(),event_title:z.string().nullish(),event_image:z.string().nullish()}).transform(({event_id:e,event_slug:t,event_title:i,event_image:a})=>({eventId:e,eventSlug:t,eventTitle:i,eventImage:a})),ot=z.object({market_id:z.string().nullish(),slug:z.string().nullish(),title:z.string().nullish(),question:z.string().nullish(),group_item_title:z.string().nullish(),sports_market_type:z.string().nullish(),line:z.number().nullish(),outcomes:z.array(z.string()).nullish(),outcome:z.string().nullish(),image_url:z.string().nullish(),icon_url:z.string().nullish(),category:z.string().nullish(),subcategory:z.string().nullish(),tags:z.array(z.string()).nullish(),end_date:pa.nullish(),event:tt.nullish()}).transform(({market_id:e,image_url:t,icon_url:i,end_date:a,group_item_title:r,sports_market_type:m,...l})=>({...l,marketId:e,groupItemTitle:r,sportsMarketType:m,imageUrl:t,iconUrl:i,endDate:a})),Q=z.object({leg_index:z.number().int(),leg_position_id:Ea,leg_condition_id:ba,leg_outcome_index:z.number().int(),leg_outcome_label:z.string().nullish(),leg_status:_e,leg_resolved_at:pa.nullish(),leg_current_price:Ra.nullish(),market:ot.nullish()}).transform(({leg_index:e,leg_position_id:t,leg_condition_id:i,leg_outcome_index:a,leg_outcome_label:r,leg_status:m,leg_resolved_at:l,leg_current_price:p,...O})=>({...O,legIndex:e,legPositionId:t,legConditionId:i,legOutcomeIndex:a,legOutcomeLabel:r,legStatus:m,legResolvedAt:l,legCurrentPrice:p})),nt=z.object({combo_condition_id:aa,outcome_index:z.number().int(),outcome_label:z.string(),combo_position_id:Ea,proxy_wallet:da,current_size:Ra,entry_avg_price_usdc:Ra,entry_cost_usdc:Ra,gross_entry_cost_usdc:Ra,entry_fees_usdc:Ra,realized_payout_usdc:Ra,status:_e,redeemable:z.boolean(),first_entry_at:pa,resolved_at:pa.nullish(),legs_total:z.number().int(),legs_resolved:z.number().int(),legs_pending:z.number().int(),legs:z.array(Q),updated_at:pa}).transform(({combo_condition_id:e,outcome_index:t,outcome_label:i,combo_position_id:a,proxy_wallet:r,current_size:m,entry_avg_price_usdc:l,entry_cost_usdc:p,gross_entry_cost_usdc:O,entry_fees_usdc:C,realized_payout_usdc:H,first_entry_at:F,resolved_at:j,legs_total:w,legs_resolved:_,legs_pending:Z,updated_at:K,...G})=>({...G,conditionId:e,outcomeIndex:t,outcomeLabel:i,positionId:a,wallet:r,currentSize:m,entryAvgPriceUsdc:l,entryCostUsdc:p,grossEntryCostUsdc:O,entryFeesUsdc:C,realizedPayoutUsdc:H,firstEntryAt:F,resolvedAt:j,legsTotal:w,legsResolved:_,legsPending:Z,updatedAt:K})),io=A(Ye),ro=f($e),so=f(et.nullable()),ao=f(Je),lo=f(Xe),mo=A(nt);var xe=(p=>(p.Split="SPLIT",p.Merge="MERGE",p.Convert="CONVERT",p.Compress="COMPRESS",p.Wrap="WRAP",p.Unwrap="UNWRAP",p.Redeem="REDEEM",p))(xe||{}),it=z.enum(xe),rt=z.object({id:$$1,type:it,proxy_wallet:da,combo_condition_id:aa,combo_position_id:Ea,amount_usdc:Ra.nullish(),payout_usdc:Ra.nullish(),timestamp:fa,transaction_hash:Oa,block_number:z.number().int(),legs:z.array(Q)}),st=rt.transform(dt),u=z.preprocess(e=>e===""?void 0:e,z.string().optional()),Ae=z.preprocess(e=>e===999?void 0:e,z.number().int().optional()),at=z.object({proxy_wallet:da,side:Aa,token_id:Fa,condition_id:ba,size:Ra,price:Ra,timestamp:fa,title:u,slug:u,icon:u,event_slug:u,outcome:u,outcome_index:Ae,name:u,pseudonym:u,bio:u,profile_image:u,profile_image_optimized:u,transaction_hash:Oa}).transform(e=>({wallet:e.proxy_wallet,side:e.side,assetId:e.token_id,tokenId:e.token_id,conditionId:e.condition_id,size:e.size,price:e.price,timestamp:e.timestamp,title:e.title,slug:e.slug,icon:e.icon,eventSlug:e.event_slug,outcome:e.outcome,outcomeIndex:e.outcome_index,name:e.name,pseudonym:e.pseudonym,bio:e.bio,profileImage:e.profile_image,profileImageOptimized:e.profile_image_optimized,transactionHash:e.transaction_hash})),lt=z.object({proxy_wallet:da,timestamp:fa,condition_id:z.preprocess(e=>e===""?void 0:e,ba.optional()),type:me,size:Ra,usdc_size:Ra,transaction_hash:Oa,price:Ra,token_id:z.preprocess(e=>e===""?void 0:e,Fa.optional()),side:z.preprocess(e=>e===""?void 0:e,z.union([Aa,$]).optional()),is_combo:z.boolean().optional(),outcome_index:Ae,title:u,slug:u,icon:u,event_slug:u,outcome:u,name:u,pseudonym:u,bio:u,profile_image:u,profile_image_optimized:u}).superRefine((e,t)=>{if(e.is_combo!==true||e.type!=="TRADE"&&e.type!=="REDEEM"&&e.type!=="SPLIT"&&e.type!=="MERGE")return;let i=aa.safeParse(e.condition_id);if(!i.success)for(let a of i.error.issues)t.addIssue({...a,path:["condition_id",...a.path]});}),mt=lt.transform(pt),yo=A(at),So=A(mt),fo=A(st);function dt(e){let t=ct(e);switch(e.type){case "SPLIT":return {...t,type:"SPLIT"};case "MERGE":return {...t,type:"MERGE"};case "CONVERT":return {...t,type:"CONVERT"};case "COMPRESS":return {...t,type:"COMPRESS"};case "WRAP":return {...t,type:"WRAP"};case "UNWRAP":return {...t,type:"UNWRAP"};case "REDEEM":return {...t,type:"REDEEM",payout:e.payout_usdc??null}}}function ct(e){return {id:e.id,type:e.type,wallet:e.proxy_wallet,conditionId:e.combo_condition_id,positionId:e.combo_position_id,amount:e.amount_usdc??null,timestamp:e.timestamp,transactionHash:e.transaction_hash,blockNumber:e.block_number,legs:e.legs}}function pt(e){let t=_t(e);switch(e.type){case "TRADE":return ut(e,t);case "REDEEM":return gt(e,t);case "SPLIT":case "MERGE":return e.is_combo===true?{...t,type:e.type,isCombo:true,conditionId:aa.parse(e.condition_id),amount:e.usdc_size,title:e.title,icon:e.icon??null}:{...t,type:e.type,isCombo:false,conditionId:c(e.condition_id,"condition_id"),amount:e.usdc_size,title:c(e.title,"title"),slug:c(e.slug,"slug"),icon:e.icon??null,eventSlug:c(e.event_slug,"event_slug")};case "CONVERSION":return {...t,type:e.type,conditionId:c(e.condition_id,"condition_id"),amount:e.usdc_size,title:c(e.title,"title"),slug:c(e.slug,"slug"),icon:e.icon??null,eventSlug:c(e.event_slug,"event_slug")};case "MIGRATION":case "REWARD":case "MAKER_REBATE":case "REFERRAL_REWARD":case "YIELD":case "DEPOSIT":case "WITHDRAWAL":case "TAKER_REBATE":return {...t,type:e.type,amount:e.usdc_size};case "TIP":return {...t,type:e.type,amount:e.usdc_size,side:e.side===void 0?null:$.parse(e.side)}}}function ut(e,t){let i={...t,type:"TRADE",side:Aa.parse(c(e.side,"side")),shares:e.size,amount:e.usdc_size,price:e.price,title:c(e.title,"title"),icon:e.icon??null};if(e.is_combo===true)return {...i,isCombo:true,conditionId:aa.parse(c(e.condition_id,"condition_id")),positionId:Ea.parse(c(e.token_id,"token_id")),outcome:e.outcome,outcomeIndex:e.outcome_index};let a=c(e.token_id,"token_id");return {...i,isCombo:false,conditionId:c(e.condition_id,"condition_id"),assetId:a,tokenId:a,outcome:c(e.outcome,"outcome"),outcomeIndex:e.outcome_index,slug:c(e.slug,"slug"),eventSlug:c(e.event_slug,"event_slug")}}function gt(e,t){let i={...t,type:"REDEEM",amount:e.usdc_size,title:e.title,icon:e.icon??null,outcome:e.outcome,outcomeIndex:e.outcome_index};return e.is_combo===true?{...i,isCombo:true,conditionId:aa.parse(c(e.condition_id,"condition_id"))}:{...i,isCombo:false,title:c(e.title,"title"),conditionId:c(e.condition_id,"condition_id"),slug:c(e.slug,"slug"),eventSlug:c(e.event_slug,"event_slug")}}function _t(e){return {wallet:e.proxy_wallet,timestamp:e.timestamp,transactionHash:e.transaction_hash,name:e.name??null,pseudonym:e.pseudonym??null,bio:e.bio??null,profileImage:e.profile_image??null,profileImageOptimized:e.profile_image_optimized??null}}function c(e,t){if(e==null)throw new TypeError(`Expected activity.${t} to be present`);return e}var Ce=(l=>(l.Max="max",l.OneMonth="1m",l.OneWeek="1w",l.OneDay="1d",l.SixHours="6h",l.OneHour="1h",l))(Ce||{}),Ao=z.enum(Ce),bt=z.object({timestamp:fa,price:Ra,resolution_seconds:z.number().int().nonnegative()}).transform(({price:e,resolution_seconds:t,timestamp:i})=>({timestamp:i,price:e,resolutionSeconds:t})),Co=A(bt),B=z.preprocess(e=>e===""?null:e,z.string().nullable()),yt=z.object({proxy_wallet:da,bio:B,token_id:Fa,pseudonym:B,amount:Ra,display_username_public:z.boolean(),outcome_index:z.preprocess(e=>e===999?null:e,z.number().int().nullable()),name:B,profile_image:B,profile_image_optimized:B,verified:z.boolean(),avg_price:Ra.nullish(),entry_cost_usdc:Ra.nullish(),current_price:Ra.nullish(),current_value:Ra.nullish(),realized_pnl:Ra.nullish(),unrealized_pnl:Ra.nullish(),total_pnl:Ra.nullish()}).transform(e=>({wallet:e.proxy_wallet,assetId:e.token_id,tokenId:e.token_id,amount:e.amount,displayUsernamePublic:e.display_username_public,outcomeIndex:e.outcome_index,verified:e.verified,bio:e.bio,pseudonym:e.pseudonym,name:e.name,profileImage:e.profile_image,profileImageOptimized:e.profile_image_optimized,avgPrice:e.avg_price,entryCostUsdc:e.entry_cost_usdc,currentPrice:e.current_price,currentValue:e.current_value,realizedPnl:e.realized_pnl,unrealizedPnl:e.unrealized_pnl,totalPnl:e.total_pnl})),St=z.object({token_id:Fa,holders:z.array(yt)}).transform(({holders:e,token_id:t})=>({assetId:t,token:t,holders:e})),ft=z.object({condition_id:z.union([ba,z.literal("GLOBAL")]),value:Ra}).transform(({condition_id:e,value:t})=>({conditionId:e==="GLOBAL"?null:e,value:t})),ht=z.object({condition_id:z.preprocess(Ua,ba.nullable()),taker_volume:Ra}).transform(({condition_id:e,taker_volume:t})=>({conditionId:e,takerVolume:t})),It=z.object({taker_volume_total:Ra,conditions:z.array(ht)}).transform(({conditions:e,taker_volume_total:t})=>({markets:e,takerVolumeTotal:t})),Ro=A(St),Eo=f(z.array(ft)),To=f(It);var vt=(i=>(i.Erc20="ERC20",i.Erc1155="ERC1155",i))(vt||{}),xt=z.union([z.literal("max"),z.string().regex(/^(0|[1-9][0-9]{0,77})$/).transform(BigInt).refine(e=>e<=2n**256n-1n,"Expected a uint256 amount")]),At=z.discriminatedUnion("standard",[z.object({token:da,spender:da,standard:z.literal("ERC20"),amount:xt,approved:z.boolean()}),z.object({token:da,spender:da,standard:z.literal("ERC1155"),approved:z.boolean()})]),Ct=z.object({token:z.string(),spender:z.string()}).transform(e=>({token:e.token,spender:e.spender,standard:void 0})),Rt=z.union([At,Ct]),Lo=f(z.object({address:da,chain_id:z.number().int().positive(),contracts:z.array(Rt)}).transform(({chain_id:e,...t})=>({...t,chainId:e})));var Re=(r=>(r.Day="day",r.Week="week",r.Month="month",r.All="all",r))(Re||{}),No=z.enum(Re),Ee=(r=>(r.Day="day",r.Week="week",r.Month="month",r.Year="all",r))(Ee||{}),Vo=z.enum(Ee),Te=(i=>(i.Pnl="PNL",i.Volume="VOLUME",i))(Te||{}),Wo=z.enum(Te),ke=(i=>(i.Market="market",i.Combo="combo",i))(ke||{}),Ho=z.enum(ke),Et=z.object({rank:z.number().int().positive(),builder_name:z.string(),builder_code:Y$1,profile_image:z.string(),verified:z.boolean(),volume:Ra,active_users:z.number().int().min(0)}).transform(({active_users:e,builder_code:t,builder_name:i,profile_image:a,...r})=>({...r,activeUsers:e,builderCode:t,builderName:i,...a===""?{}:{profileImage:a}})),Tt=z.object({date:qa,rank:z.number().int().min(0),builder_name:z.string(),builder_code:Y$1,profile_image:z.string(),verified:z.boolean(),volume:Ra,active_users:z.number().int().min(0)}).transform(({active_users:e,builder_code:t,builder_name:i,date:a,profile_image:r,...m})=>({...m,activeUsers:e,bucketDate:a,builderCode:t,builderName:i,...r===""?{}:{profileImage:r}})),T=z.preprocess(Ua,z.string().nullable()),kt=z.object({rank:z.number().int().min(0),user_id:da,pnl:Ra,volume:Ra,user_name:T,profile_image:T,x_username:T,verified:z.boolean()}).transform(({profile_image:e,user_id:t,user_name:i,x_username:a,...r})=>({...r,wallet:t,userName:i,profileImage:e,xUsername:a})),Dt=z.object({user_id:da,pnl:Ra,volume:Ra,rank_pnl:z.number().int().positive().nullable(),rank_volume:z.number().int().positive().nullable(),user_name:T,profile_image:T,x_username:T,verified:z.boolean()}).transform(({profile_image:e,rank_pnl:t,rank_volume:i,user_id:a,user_name:r,x_username:m,...l})=>({...l,wallet:a,pnlRank:t,volumeRank:i,userName:r,profileImage:e,xUsername:m})),Pt=z.object({win_rank:z.number().int().positive(),kind:z.literal("market"),user_id:da,pnl:Ra,initial_value:Ra,final_value:Ra,resolved_at:fa,condition_id:ba,position_id:Fa,event_id:na,event_slug:z.string(),event_title:z.string(),user_name:T,profile_image:T}),zt=z.object({win_rank:z.number().int().positive(),kind:z.literal("combo"),user_id:da,pnl:Ra,initial_value:Ra,final_value:Ra,resolved_at:fa,condition_id:aa,position_id:Ea,event_id:z.literal(0),event_slug:z.literal(""),event_title:z.string(),user_name:T,profile_image:T}),Lt=z.discriminatedUnion("kind",[Pt,zt]).transform(e=>e.kind==="combo"?{rank:e.win_rank,kind:e.kind,wallet:e.user_id,pnl:e.pnl,initialValue:e.initial_value,finalValue:e.final_value,resolvedAt:e.resolved_at,conditionId:e.condition_id,positionId:e.position_id,eventId:null,eventSlug:null,eventTitle:e.event_title,userName:e.user_name,profileImage:e.profile_image}:{rank:e.win_rank,kind:e.kind,wallet:e.user_id,pnl:e.pnl,initialValue:e.initial_value,finalValue:e.final_value,resolvedAt:e.resolved_at,conditionId:e.condition_id,assetId:e.position_id,eventId:e.event_id,eventSlug:e.event_slug,eventTitle:e.event_title,userName:e.user_name,profileImage:e.profile_image}),Fo=A(Et),jo=f(z.array(Tt)),wo=A(kt),Zo=f(Dt.nullable()),Ko=A(Lt);var Pe=(C=>(C.Initialized="initialized",C.Posed="posed",C.Proposed="proposed",C.Challenged="challenged",C.Reproposed="reproposed",C.Disputed="disputed",C.Active="active",C.Arbitration="arbitration",C.Resolved="resolved",C))(Pe||{}),Mt=z.enum(Pe),ze=(a=>(a.Binary="BINARY",a.IncrementalNegRisk="INCREMENTAL_NEGRISK",a.AtomicNegRisk="ATOMIC_NEGRISK",a))(ze||{}),Ot=z.enum(ze),Le=(i=>(i.Reported="reported",i.Derived="derived",i))(Le||{}),Bt=z.enum(Le),Me=(a=>(a.UmaOptimisticOracle="UMA_OO",a.Chainlink="CHAINLINK",a.Eoa="EOA",a))(Me||{}),Ut=z.enum(Me),Oe=(r=>(r.ManagedProposalExpiration="managed_proposal_expiration",r.ProposalExpiration="proposal_expiration",r.Liveness="liveness",r.DvmRoundEstimate="dvm_round_estimate",r))(Oe||{}),Nt=z.enum(Oe),De=z.number().int().min(0).transform(String).pipe(Qa),Vt=z.object({question_id:Ga.optional(),condition_id:ba.optional(),status:Mt,extended_review:z.boolean(),expected_settlement_time:z.iso.datetime().transform(A$1).optional(),settlement_time_basis:Nt.optional(),was_disputed:z.boolean(),new_version_q:z.boolean(),proposed_price:Pa.optional(),reproposed_price:Pa.optional(),price:Pa.optional(),transaction_hash:z.preprocess(Ua,Oa.nullable()),log_index:z.preprocess(Ua,z.string().regex(/^\d+$/).transform(Number).nullable()),last_update_timestamp:ia,market_type:Ot.optional(),payouts:z.tuple([De,De]).optional(),resolution_source:Bt.optional(),reporter:Ut.optional(),was_arbitrated:z.boolean().optional(),resolved_block:z.number().int().min(0).optional(),resolved_at:pa.optional()}).transform(e=>{let t={status:e.status,extendedReview:e.extended_review,wasDisputed:e.was_disputed,questionRulesUpdated:e.new_version_q,transactionHash:e.transaction_hash,logIndex:e.log_index,lastUpdatedAt:e.last_update_timestamp};return e.question_id!==void 0&&(t.questionId=e.question_id),e.condition_id!==void 0&&(t.conditionId=e.condition_id),e.expected_settlement_time!==void 0&&(t.expectedSettlementTime=e.expected_settlement_time),e.settlement_time_basis!==void 0&&(t.settlementTimeBasis=e.settlement_time_basis),e.proposed_price!==void 0&&e.proposed_price!=="69"&&(t.proposedPrice=e.proposed_price),e.reproposed_price!==void 0&&e.reproposed_price!=="69"&&(t.reproposedPrice=e.reproposed_price),e.price!==void 0&&e.price!=="69"&&(t.price=e.price),e.market_type!==void 0&&(t.marketType=e.market_type),e.payouts!==void 0&&(t.payouts=e.payouts),e.resolution_source!==void 0&&(t.resolutionSource=e.resolution_source),e.reporter!==void 0&&(t.reporter=e.reporter),e.was_arbitrated!==void 0&&(t.wasArbitrated=e.was_arbitrated),e.resolved_block!==void 0&&(t.resolvedBlock=e.resolved_block),e.resolved_at!==void 0&&(t.resolvedAt=e.resolved_at),t}),Qo=f(z.array(Vt));var Ve=(r=>(r.V1Ctf="v1_ctf",r.Binary="binary",r.NegRisk="neg_risk",r.Combo="combo",r))(Ve||{}),Wt=z.enum(Ve),Be=z.string().regex(/^[0-9]{1,78}$/).pipe(Fa),J=z.string().regex(/^0x[0-9a-fA-F]{64}$/).pipe(ba),Ue=z.number().int().min(-32768).max(32767),Ne=z.number().int().min(-2147483648).max(2147483647),Ht=z.object({token_id:Be,condition_id:J,structural_condition_id:J.nullable(),module:Wt,outcome_index:Ue,clob_index:Ue.nullable(),outcome:z.string().nullable(),opposite_token_id:Be.nullable(),resolved:z.boolean(),final_price:z.number().transform(e=>U(String(e))).nullable(),title:z.string().nullable(),market_slug:z.string().nullable(),closed:z.boolean().nullable(),neg_risk:z.boolean().nullable(),neg_risk_market_id:J.nullable(),question_index:Ne.nullable(),event_id:Ne.transform(e=>w(String(e))).nullable(),event_slug:z.string().nullable()}).transform(e=>({assetId:e.token_id,conditionId:e.condition_id,structuralConditionId:e.structural_condition_id,module:e.module,outcomeIndex:e.outcome_index,clobIndex:e.clob_index,outcome:e.outcome,oppositeAssetId:e.opposite_token_id,resolved:e.resolved,finalPrice:e.final_price,title:e.title,marketSlug:e.market_slug,closed:e.closed,negRisk:e.neg_risk,negRiskMarketId:e.neg_risk_market_id,questionIndex:e.question_index,eventId:e.event_id,eventSlug:e.event_slug})),on=f(z.array(Ht));export{mt as ActivitySchema,Y as ActivityType,me as ActivityTypeSchema,vt as ApprovalStandard,ke as BiggestWinnerKind,Ho as BiggestWinnerKindSchema,Lt as BiggestWinnerSchema,Et as BuilderStandingSchema,Ee as BuilderVolumeInterval,Vo as BuilderVolumeIntervalSchema,Tt as BuilderVolumePointSchema,Kt as CanonicalMarketConditionIdSchema,st as ComboActivitySchema,xe as ComboActivityType,Q as ComboPositionLegSchema,tt as ComboPositionMarketEventSchema,ot as ComboPositionMarketSchema,nt as ComboPositionSchema,fe as ComboPositionSortBy,no as ComboPositionSortBySchema,ge as ComboPositionStatus,_e as ComboPositionStatusSchema,Lo as FetchApprovalsResponseSchema,jo as FetchBuilderVolumeResponseSchema,To as FetchEventLiveVolumeResponseSchema,Eo as FetchOpenInterestResponseSchema,ro as FetchPortfolioValueResponseSchema,Qo as FetchResolutionsResponseSchema,on as FetchTokenReferencesResponseSchema,Zo as FetchTraderLeaderboardStandingResponseSchema,ao as FetchUserPnlResponseSchema,so as FetchUserStatsResponseSchema,lo as FetchUserVolumeResponseSchema,yt as HolderSchema,Re as LeaderboardWindow,No as LeaderboardWindowSchema,So as ListActivityResponseSchema,Ko as ListBiggestWinnersResponseSchema,Fo as ListBuilderLeaderboardResponseSchema,fo as ListComboActivityResponseSchema,mo as ListComboPositionsResponseSchema,Ro as ListMarketHoldersResponseSchema,io as ListPositionsResponseSchema,Co as ListPriceHistoryResponseSchema,wo as ListTraderLeaderboardResponseSchema,yo as ListTradesResponseSchema,It as LiveVolumeSchema,ht as MarketLiveVolumeSchema,St as MetaHolderSchema,ft as OpenInterestSchema,$e as PortfolioValueSchema,Se as PositionFilterType,oo as PositionFilterTypeSchema,Ge as PositionRowStatusSchema,Ye as PositionSchema,ye as PositionSortBy,to as PositionSortBySchema,be as PositionStatus,eo as PositionStatusSchema,Ce as PriceHistoryInterval,Ao as PriceHistoryIntervalSchema,bt as PriceHistoryPointSchema,ze as ResolutionMarketType,Ot as ResolutionMarketTypeSchema,Me as ResolutionReporter,Ut as ResolutionReporterSchema,Vt as ResolutionSchema,Oe as ResolutionSettlementTimeBasis,Nt as ResolutionSettlementTimeBasisSchema,Le as ResolutionSource,Bt as ResolutionSourceSchema,Pe as ResolutionStatus,Mt as ResolutionStatusSchema,ce as SortDirection,wt as SortDirectionSchema,de as TipSide,$ as TipSideSchema,Ve as TokenModule,Wt as TokenModuleSchema,Ht as TokenReferenceSchema,pe as TradeFilterType,Zt as TradeFilterTypeSchema,at as TradeSchema,kt as TraderLeaderboardEntrySchema,Te as TraderLeaderboardSort,Wo as TraderLeaderboardSortSchema,Dt as TraderLeaderboardStandingSchema,Ie as UserPnlFidelity,ue as UserPnlFidelitySchema,he as UserPnlInterval,Qe as UserPnlIntervalSchema,ve as UserPnlPointSchema,Je as UserPnlSeriesSchema,et as UserStatsSchema,Xe as UserVolumeSchema,f as dataEnvelopeSchema,A as dataPageSchema};//# sourceMappingURL=index.js.map
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/data/common.ts","../../src/data/envelope.ts","../../src/data/portfolio.ts","../../src/data/activity.ts","../../src/data/analytics.ts","../../src/data/approvals.ts","../../src/data/leaderboard.ts","../../src/data/resolutions.ts","../../src/data/tokens.ts"],"names":["ActivityType","ActivityTypeSchema","z","TipSide","TipSideSchema","SortDirection","SortDirectionSchema","TradeFilterType","TradeFilterTypeSchema","toCanonicalMarketConditionId","conditionId","paddedConditionId","toConditionId","isSupportedMarketConditionId","normalizedConditionId","CanonicalMarketConditionIdSchema","ConditionIdSchema","dataPageSchema","item","value","data","pagination","toPaginationCursor","dataEnvelopeSchema","payload","envelope","ComboPositionStatus","ComboPositionStatusSchema","PositionStatus","PositionStatusSchema","PositionRowStatusSchema","PositionSortBy","PositionSortBySchema","PositionFilterType","PositionFilterTypeSchema","ComboPositionSortBy","ComboPositionSortBySchema","OptionalTextSchema","UnknownOutcomeIndexToUndefinedSchema","PositionSchema","EvmAddressSchema","ClobAssetIdSchema","DecimalishSchema","IsoCalendarDateStringSchema","EpochSecondsToMillisecondsSchema","position","PortfolioValueSchema","proxy_wallet","UserPnlInterval","UserPnlIntervalSchema","UserPnlFidelity","UserPnlFidelitySchema","UncoveredAmountSchema","amount","UserPnlPointSchema","source_block","realized_market_pnl","realized_lp_pnl","realized_combo_pnl","unrealized_pnl","fees_refunded","maker_rebate","taker_rebate","reward_income","yield_income","referral_income","realized_pnl","wallet_income","position_pnl","settled_pnl","economic_pnl","trade_pnl","sponsored_income","fees_paid","cashflow_net","volume_usdc","trade_count","point","UserPnlSeriesSchema","source_fidelity","series","UserVolumeSchema","volume","UserStatsSchema","trades","biggest_win","join_date","all_time_pnl","stats","ComboPositionMarketEventSchema","event_id","event_slug","event_title","event_image","ComboPositionMarketSchema","IsoDateTimeStringSchema","market_id","image_url","icon_url","end_date","group_item_title","sports_market_type","rest","ComboPositionLegSchema","PositionIdSchema","leg_index","leg_position_id","leg_condition_id","leg_outcome_index","leg_outcome_label","leg_status","leg_resolved_at","leg_current_price","ComboPositionSchema","ComboConditionIdSchema","combo_condition_id","outcome_index","outcome_label","combo_position_id","current_size","entry_avg_price_usdc","entry_cost_usdc","gross_entry_cost_usdc","entry_fees_usdc","realized_payout_usdc","first_entry_at","resolved_at","legs_total","legs_resolved","legs_pending","updated_at","ListPositionsResponseSchema","FetchPortfolioValueResponseSchema","FetchUserStatsResponseSchema","FetchUserPnlResponseSchema","FetchUserVolumeResponseSchema","ListComboPositionsResponseSchema","ComboActivityType","ComboActivityTypeSchema","RawComboActivitySchema","ComboActivityIdSchema","TxHashSchema","ComboActivitySchema","normalizeComboActivity","TradeSchema","OrderSideSchema","trade","RawActivitySchema","activity","ctx","condition","issue","ActivitySchema","normalizeActivity","ListTradesResponseSchema","ListActivityResponseSchema","ListComboActivityResponseSchema","base","normalizeComboActivityBase","normalizeActivityBase","normalizeTradeActivity","normalizeRedeemActivity","expectPresent","assetId","redemption","field","PriceHistoryInterval","PriceHistoryIntervalSchema","PriceHistoryPointSchema","price","resolution_seconds","timestamp","ListPriceHistoryResponseSchema","NullableHolderTextSchema","HolderSchema","holder","MetaHolderSchema","holders","token_id","OpenInterestSchema","condition_id","MarketLiveVolumeSchema","emptyStringToNull","taker_volume","LiveVolumeSchema","conditions","taker_volume_total","ListMarketHoldersResponseSchema","FetchOpenInterestResponseSchema","FetchEventLiveVolumeResponseSchema","ApprovalStandard","ApprovalAmountSchema","KnownApprovalContractSchema","UnknownApprovalContractSchema","row","ApprovalContractSchema","FetchApprovalsResponseSchema","chain_id","snapshot","LeaderboardWindow","LeaderboardWindowSchema","BuilderVolumeInterval","BuilderVolumeIntervalSchema","TraderLeaderboardSort","TraderLeaderboardSortSchema","BiggestWinnerKind","BiggestWinnerKindSchema","BuilderStandingSchema","BuilderCodeSchema","active_users","builder_code","builder_name","profile_image","BuilderVolumePointSchema","date","NullableTextSchema","TraderLeaderboardEntrySchema","user_id","user_name","x_username","entry","TraderLeaderboardStandingSchema","rank_pnl","rank_volume","standing","MarketBiggestWinnerSchema","EventIdSchema","ComboBiggestWinnerSchema","BiggestWinnerSchema","winner","ListBuilderLeaderboardResponseSchema","FetchBuilderVolumeResponseSchema","ListTraderLeaderboardResponseSchema","FetchTraderLeaderboardStandingResponseSchema","ListBiggestWinnersResponseSchema","ResolutionStatus","ResolutionStatusSchema","ResolutionMarketType","ResolutionMarketTypeSchema","ResolutionSource","ResolutionSourceSchema","ResolutionReporter","ResolutionReporterSchema","ResolutionSettlementTimeBasis","ResolutionSettlementTimeBasisSchema","PayoutSchema","E6BigIntStringToDecimalStringSchema","ResolutionSchema","QuestionIdSchema","toIsoDateTimeString","DecimalStringSchema","EpochLikeToIsoDateTimeStringSchema","wire","resolution","FetchResolutionsResponseSchema","TokenModule","TokenModuleSchema","DecimalAssetIdSchema","Bytes32ConditionIdSchema","Int16Schema","Int32Schema","TokenReferenceSchema","toDecimalString","toEventId","FetchTokenReferencesResponseSchema"],"mappings":"6IAGO,IAAKA,CAAAA,CAAAA,CAAAA,CAAAA,GACVA,CAAAA,CAAA,KAAA,CAAQ,OAAA,CACRA,CAAAA,CAAA,KAAA,CAAQ,OAAA,CACRA,CAAAA,CAAA,KAAA,CAAQ,OAAA,CACRA,CAAAA,CAAA,MAAA,CAAS,QAAA,CACTA,CAAAA,CAAA,MAAA,CAAS,QAAA,CACTA,CAAAA,CAAA,UAAA,CAAa,YAAA,CACbA,CAAAA,CAAA,SAAA,CAAY,WAAA,CACZA,CAAAA,CAAA,YAAA,CAAe,cAAA,CACfA,CAAAA,CAAA,eAAA,CAAkB,iBAAA,CAClBA,CAAA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,EAC/BoP,CAAAA,CAAU,MAAA,CAAOpP,CAAK,CAAC,CACzB,CAAA,CAAE,QAAA,EAAS,CACX,UAAA,CAAYjB,CAAAA,CAAE,MAAA,EAAO,CAAE,QAAA,EACzB,CAAC,CAAA,CACA,SAAA,CAAWgM,CAAAA,GAAS,CACnB,OAAA,CAASA,CAAAA,CAAI,QAAA,CACb,WAAA,CAAaA,CAAAA,CAAI,YAAA,CACjB,qBAAA,CAAuBA,CAAAA,CAAI,uBAAA,CAC3B,MAAA,CAAQA,CAAAA,CAAI,MAAA,CACZ,YAAA,CAAcA,CAAAA,CAAI,aAAA,CAClB,SAAA,CAAWA,CAAAA,CAAI,UAAA,CACf,OAAA,CAASA,CAAAA,CAAI,OAAA,CACb,eAAA,CAAiBA,CAAAA,CAAI,iBAAA,CACrB,QAAA,CAAUA,CAAAA,CAAI,QAAA,CACd,WAAYA,CAAAA,CAAI,WAAA,CAChB,KAAA,CAAOA,CAAAA,CAAI,KAAA,CACX,UAAA,CAAYA,CAAAA,CAAI,WAAA,CAChB,MAAA,CAAQA,CAAAA,CAAI,MAAA,CACZ,OAAA,CAASA,CAAAA,CAAI,QAAA,CACb,eAAA,CAAiBA,CAAAA,CAAI,kBAAA,CACrB,aAAA,CAAeA,CAAAA,CAAI,cAAA,CACnB,OAAA,CAASA,CAAAA,CAAI,QAAA,CACb,SAAA,CAAWA,CAAAA,CAAI,UACjB,CAAA,CAAE,CAAA,CAESsE,EAAAA,CAAqCjP,CAAAA,CAChDrB,CAAAA,CAAE,KAAA,CAAMmQ,EAAoB,CAC9B","file":"index.js","sourcesContent":["import { z } from 'zod';\nimport { type ConditionId, ConditionIdSchema, toConditionId } from '../shared';\n\nexport enum ActivityType {\n TRADE = 'TRADE',\n SPLIT = 'SPLIT',\n MERGE = 'MERGE',\n REDEEM = 'REDEEM',\n REWARD = 'REWARD',\n CONVERSION = 'CONVERSION',\n MIGRATION = 'MIGRATION',\n MAKER_REBATE = 'MAKER_REBATE',\n REFERRAL_REWARD = 'REFERRAL_REWARD',\n YIELD = 'YIELD',\n DEPOSIT = 'DEPOSIT',\n WITHDRAWAL = 'WITHDRAWAL',\n TAKER_REBATE = 'TAKER_REBATE',\n /** A user-to-user tip, served in the feed like every other type. */\n TIP = 'TIP',\n}\n\nexport const ActivityTypeSchema = z.enum(ActivityType);\n\n/** Direction of a TIP from the row wallet's perspective. */\nexport enum TipSide {\n In = 'IN',\n Out = 'OUT',\n}\n\nexport const TipSideSchema = z.enum(TipSide);\n\n/** Sort order of a listed feed. */\nexport enum SortDirection {\n Asc = 'ASC',\n Desc = 'DESC',\n}\n\nexport const SortDirectionSchema = z.enum(SortDirection);\n\n/** Unit the trades dust filter applies to. */\nexport enum TradeFilterType {\n Cash = 'CASH',\n Tokens = 'TOKENS',\n}\n\nexport const TradeFilterTypeSchema = z.enum(TradeFilterType);\n\nfunction toCanonicalMarketConditionId(conditionId: ConditionId): ConditionId {\n const paddedConditionId =\n conditionId.length === 64 ? `${conditionId}00` : conditionId;\n\n return toConditionId(paddedConditionId.toLowerCase());\n}\n\nfunction isSupportedMarketConditionId(conditionId: ConditionId): boolean {\n if (conditionId.length === 66) return true;\n\n const normalizedConditionId = conditionId.toLowerCase();\n return (\n normalizedConditionId.startsWith('0x01') ||\n normalizedConditionId.startsWith('0x02')\n );\n}\n\n/**\n * A canonical 32-byte market condition ID. A 31-byte protocol v2 market ID is\n * right-padded to its canonical representation; combo condition IDs are\n * rejected.\n */\nexport const CanonicalMarketConditionIdSchema = ConditionIdSchema.refine(\n isSupportedMarketConditionId,\n 'Expected a 32-byte condition ID or a 31-byte protocol v2 market condition ID',\n).transform(toCanonicalMarketConditionId);\n","import { z } from 'zod';\nimport { toPaginationCursor } from '../shared';\n\n/**\n * Parses the data-service paginated list envelope straight into the SDK's page shape\n * — `{ items, hasMore, nextCursor }` — so actions hand the result to the\n * pagination walker as-is. The wire envelope never escapes bindings, and no\n * second pagination vocabulary exists: whatever the upstream strategy, the\n * SDK exposes the one cursor-shaped page.\n *\n * `hasMore` is exact on this surface (the service probes one row past the\n * page). `nextCursor` is server-minted and opaque — never derived or\n * synthesized client-side; a `null` wire cursor (final page) normalizes to\n * `undefined`. The wire's `limit`/`offset` echoes are dropped: they restate\n * the request.\n */\nexport function dataPageSchema<TItem extends z.ZodType>(item: TItem) {\n return (\n z\n .object({\n data: z.array(item),\n pagination: z.object({\n limit: z.number().int(),\n offset: z.number().int(),\n has_more: z.boolean(),\n next_cursor: z.string().min(1).nullable(),\n }),\n })\n // The service mints the cursor exactly when another page exists, so the\n // two fields are equivalent. Enforcing that here turns a broken upstream\n // invariant into a loud validation failure instead of its silent failure\n // mode: `hasMore: true` with no cursor restarts the page walker from the\n // first page, forever.\n .refine(\n (value) =>\n value.pagination.has_more === (value.pagination.next_cursor !== null),\n {\n message: 'has_more and next_cursor must agree',\n path: ['pagination', 'next_cursor'],\n },\n )\n .transform(({ data, pagination }) => ({\n items: data,\n hasMore: pagination.has_more,\n nextCursor:\n pagination.next_cursor === null\n ? undefined\n : toPaginationCursor(pagination.next_cursor),\n }))\n );\n}\n\n/**\n * Parses the data-service single-object envelope — `{ data }` — and unwraps it to\n * the payload, so the envelope never escapes bindings.\n *\n * Endpoints whose ordinary answer includes \"no such row\" serve `data: null`;\n * model that by passing a nullable payload schema, so absence stays a parsed\n * value rather than a validation failure.\n */\nexport function dataEnvelopeSchema<TPayload extends z.ZodType>(\n payload: TPayload,\n) {\n // The inference cast is load-bearing: for a bare generic payload schema,\n // zod's mapped envelope type stays opaque to the declaration build, so the\n // callback cannot destructure or annotate its argument.\n return z\n .object({ data: payload })\n .transform((envelope) => (envelope as { data: z.output<TPayload> }).data);\n}\n","import type { EvmAddress } from '@kuest/types';\nimport { z } from 'zod';\nimport {\n ClobAssetIdSchema,\n ComboConditionIdSchema,\n type ConditionId,\n ConditionIdSchema,\n DecimalishSchema,\n type DecimalString,\n type EpochMilliseconds,\n EpochSecondsToMillisecondsSchema,\n EvmAddressSchema,\n type IsoCalendarDateString,\n IsoCalendarDateStringSchema,\n IsoDateTimeStringSchema,\n type PositionId,\n PositionIdSchema,\n type TokenId,\n} from '../shared';\nimport { dataEnvelopeSchema, dataPageSchema } from './envelope';\n\nexport enum ComboPositionStatus {\n Open = 'OPEN',\n Redeemable = 'REDEEMABLE',\n Partial = 'PARTIAL',\n ResolvedPartial = 'RESOLVED_PARTIAL',\n ResolvedWin = 'RESOLVED_WIN',\n ResolvedLoss = 'RESOLVED_LOSS',\n}\n\nexport const ComboPositionStatusSchema = z.enum(ComboPositionStatus);\n\n/** Lifecycle filter for a positions listing. */\nexport enum PositionStatus {\n Open = 'OPEN',\n Redeemable = 'REDEEMABLE',\n /** Still-held, zero-payout (lost) positions, ranked on frozen values. */\n RedeemableLost = 'REDEEMABLE_LOST',\n /**\n * Live complementary pairs the wallet can merge back to collateral (holds >= 2\n * live outcome tokens of a condition). Settled pairs are excluded; they are a\n * redeem, not a merge.\n */\n Mergeable = 'MERGEABLE',\n Closed = 'CLOSED',\n}\n\nexport const PositionStatusSchema = z.enum(PositionStatus);\n\n/**\n * The statuses a position row itself reports, which is narrower than the\n * listing filter: `REDEEMABLE_LOST` and `MERGEABLE` are filter vocabulary\n * only. A lost holding still reports `REDEEMABLE`, and a mergeable one\n * reports `OPEN`.\n */\nexport type PositionRowStatus =\n | PositionStatus.Open\n | PositionStatus.Redeemable\n | PositionStatus.Closed;\n\nexport const PositionRowStatusSchema = z.enum([\n PositionStatus.Open,\n PositionStatus.Redeemable,\n PositionStatus.Closed,\n]) satisfies z.ZodType<PositionRowStatus>;\n\n/** Sort key for position listings. */\nexport enum PositionSortBy {\n CurrentValue = 'CURRENT_VALUE',\n /** Current effective price; wallet closed positions use realized PnL instead. */\n Price = 'PRICE',\n Tokens = 'TOKENS',\n UnrealizedPnl = 'UNREALIZED_PNL',\n RealizedPnl = 'REALIZED_PNL',\n TotalPnl = 'TOTAL_PNL',\n Timestamp = 'TIMESTAMP',\n}\n\nexport const PositionSortBySchema = z.enum(PositionSortBy);\n\n/** Unit the positions dust filter applies to. */\nexport enum PositionFilterType {\n Cash = 'CASH',\n Tokens = 'TOKENS',\n}\n\nexport const PositionFilterTypeSchema = z.enum(PositionFilterType);\n\n/** Sort key for combo position listings. */\nexport enum ComboPositionSortBy {\n FirstEntry = 'FIRST_ENTRY',\n EntryCost = 'ENTRY_COST',\n CurrentValue = 'CURRENT_VALUE',\n Updated = 'UPDATED',\n}\n\nexport const ComboPositionSortBySchema = z.enum(ComboPositionSortBy);\n\nconst OptionalTextSchema = z.preprocess(\n (value) => (value === '' ? undefined : value),\n z.string().optional(),\n);\n\nconst UnknownOutcomeIndexToUndefinedSchema = z.preprocess(\n (value) => (value === 999 ? undefined : value),\n z.number().int().optional(),\n);\n\nexport type Position = {\n wallet: EvmAddress;\n /** Outcome identifier for a CTF token or Polymarket V2 position. */\n assetId: TokenId | PositionId;\n /** @deprecated Use `assetId`. */\n tokenId: TokenId | PositionId;\n conditionId: ConditionId;\n /** The current holding, in shares (a ~0 residual on CLOSED rows). */\n currentSize: DecimalString;\n avgPrice: DecimalString;\n /** The fee-exclusive entry basis in USD. */\n entryCostUsdc: DecimalString;\n /**\n * Attributed BUY-fee total in USD. Disclosure only — `entryCostUsdc` is\n * already fee-exclusive, so never re-deduct this from a PnL figure.\n */\n entryFeesUsdc: DecimalString;\n /** Gross (fee-inclusive) basis: always `entryCostUsdc + entryFeesUsdc`. */\n totalCostUsdc: DecimalString;\n currentPrice: DecimalString;\n currentValue: DecimalString;\n /**\n * Lifetime bought shares (the average-cost denominator) — never the\n * current balance, which is `currentSize`.\n */\n totalSize: DecimalString;\n realizedPnl: DecimalString;\n /** Mark-to-market PnL: `currentValue - entryCostUsdc`. */\n unrealizedPnl: DecimalString;\n /** Always `realizedPnl + unrealizedPnl`. */\n totalPnl: DecimalString;\n percentPnl: DecimalString;\n percentRealizedPnl: DecimalString;\n /**\n * The row's actual state — can be narrower than the requested status,\n * since an OPEN request also returns REDEEMABLE rows, and a\n * REDEEMABLE_LOST or MERGEABLE listing reports REDEEMABLE or OPEN rows.\n */\n status: PositionRowStatus;\n redeemable: boolean;\n mergeable: boolean;\n negativeRisk: boolean;\n /** Whether the market is archived (surfaced by `includeArchived`). */\n archived: boolean;\n title?: string;\n slug?: string;\n icon?: string;\n eventId?: string;\n eventSlug?: string;\n outcome?: string;\n outcomeIndex?: number;\n oppositeOutcome?: string;\n /** Opposite outcome identifier for a CTF token or Polymarket V2 position. */\n oppositeAssetId?: TokenId | PositionId;\n /** @deprecated Use `oppositeAssetId`. */\n oppositeTokenId?: TokenId | PositionId;\n endDate?: IsoCalendarDateString;\n /**\n * The row's last economics event as Unix epoch milliseconds; absent on\n * positions with no native economics.\n */\n lastEventAt?: EpochMilliseconds;\n /** First acquisition as Unix epoch milliseconds; absent when unrecorded. */\n firstEntryAt?: EpochMilliseconds;\n name?: string;\n profileImage?: string;\n verified: boolean;\n};\n\n/**\n * A positions row, normalized to the SDK vocabulary.\n *\n * The wire is strict snake_case: absence arrives as an empty string (or the\n * unknown-outcome sentinel `999`), normalized to `undefined` here. Timestamps\n * arrive as epoch seconds and normalize to epoch milliseconds, with `0`\n * (no recorded timestamp) normalized to `undefined`.\n */\nexport const PositionSchema = z\n .object({\n proxy_wallet: EvmAddressSchema,\n token_id: ClobAssetIdSchema,\n condition_id: ConditionIdSchema,\n current_size: DecimalishSchema,\n avg_price: DecimalishSchema,\n entry_cost_usdc: DecimalishSchema,\n entry_fees_usdc: DecimalishSchema,\n total_cost_usdc: DecimalishSchema,\n current_price: DecimalishSchema,\n current_value: DecimalishSchema,\n total_size: DecimalishSchema,\n realized_pnl: DecimalishSchema,\n unrealized_pnl: DecimalishSchema,\n total_pnl: DecimalishSchema,\n percent_pnl: DecimalishSchema,\n percent_realized_pnl: DecimalishSchema,\n status: PositionRowStatusSchema,\n redeemable: z.boolean(),\n mergeable: z.boolean(),\n negative_risk: z.boolean(),\n archived: z.boolean(),\n title: OptionalTextSchema,\n slug: OptionalTextSchema,\n icon: OptionalTextSchema,\n event_id: OptionalTextSchema,\n event_slug: OptionalTextSchema,\n outcome: OptionalTextSchema,\n outcome_index: UnknownOutcomeIndexToUndefinedSchema,\n opposite_outcome: OptionalTextSchema,\n opposite_token_id: z.preprocess(\n (value) => (value === '' ? undefined : value),\n ClobAssetIdSchema.optional(),\n ),\n end_date: z.preprocess(\n (value) => (value === '' ? undefined : value),\n IsoCalendarDateStringSchema.optional(),\n ),\n last_event_at: z.preprocess(\n (value) => (value === 0 ? undefined : value),\n EpochSecondsToMillisecondsSchema.optional(),\n ),\n first_entry_at: z.preprocess(\n (value) => (value === 0 ? undefined : value),\n EpochSecondsToMillisecondsSchema.optional(),\n ),\n name: OptionalTextSchema,\n profile_image: OptionalTextSchema,\n verified: z.boolean(),\n })\n .transform((position) => ({\n wallet: position.proxy_wallet,\n assetId: position.token_id,\n tokenId: position.token_id,\n conditionId: position.condition_id,\n currentSize: position.current_size,\n avgPrice: position.avg_price,\n entryCostUsdc: position.entry_cost_usdc,\n entryFeesUsdc: position.entry_fees_usdc,\n totalCostUsdc: position.total_cost_usdc,\n currentPrice: position.current_price,\n currentValue: position.current_value,\n totalSize: position.total_size,\n realizedPnl: position.realized_pnl,\n unrealizedPnl: position.unrealized_pnl,\n totalPnl: position.total_pnl,\n percentPnl: position.percent_pnl,\n percentRealizedPnl: position.percent_realized_pnl,\n status: position.status,\n redeemable: position.redeemable,\n mergeable: position.mergeable,\n negativeRisk: position.negative_risk,\n archived: position.archived,\n title: position.title,\n slug: position.slug,\n icon: position.icon,\n eventId: position.event_id,\n eventSlug: position.event_slug,\n outcome: position.outcome,\n outcomeIndex: position.outcome_index,\n oppositeOutcome: position.opposite_outcome,\n oppositeAssetId: position.opposite_token_id,\n oppositeTokenId: position.opposite_token_id,\n endDate: position.end_date,\n lastEventAt: position.last_event_at,\n firstEntryAt: position.first_entry_at,\n name: position.name,\n profileImage: position.profile_image,\n verified: position.verified,\n })) satisfies z.ZodType<Position>;\n\nexport type PortfolioValue = {\n wallet: EvmAddress;\n /** Total marked portfolio value, in USDC, rounded to four decimals. */\n value: DecimalString;\n};\n\nexport const PortfolioValueSchema = z\n .object({\n proxy_wallet: EvmAddressSchema,\n value: DecimalishSchema,\n })\n .transform(({ proxy_wallet, value }) => ({\n wallet: proxy_wallet,\n value,\n })) satisfies z.ZodType<PortfolioValue>;\n\n/** Window served by a user PnL series. */\nexport enum UserPnlInterval {\n Max = 'max',\n OneMonth = '1m',\n OneWeek = '1w',\n OneDay = '1d',\n TwelveHours = '12h',\n SixHours = '6h',\n}\n\nexport const UserPnlIntervalSchema = z.enum(UserPnlInterval);\n\n/** Time step between points in a user PnL series. */\nexport enum UserPnlFidelity {\n OneDay = '1d',\n EighteenHours = '18h',\n TwelveHours = '12h',\n ThreeHours = '3h',\n OneHour = '1h',\n}\n\nexport const UserPnlFidelitySchema = z.enum(UserPnlFidelity);\n\n/**\n * One cumulative wallet PnL observation. Fractional money and size values\n * are normalized to decimal strings.\n */\nexport type UserPnlPoint = {\n /** Observation time as Unix epoch milliseconds. */\n timestamp: EpochMilliseconds;\n /** Chain block at which the point was observed. */\n sourceBlock: number;\n /** Realized PnL from market positions. */\n realizedMarketPnl: DecimalString;\n /** Realized PnL from liquidity-provision activity. */\n realizedLpPnl: DecimalString;\n /** Realized PnL from combo positions. */\n realizedComboPnl: DecimalString;\n /** Mark-to-market PnL of open inventory. */\n unrealizedPnl: DecimalString | null;\n feesRefunded: DecimalString | null;\n makerRebate: DecimalString | null;\n takerRebate: DecimalString | null;\n rewardIncome: DecimalString | null;\n yieldIncome: DecimalString | null;\n referralIncome: DecimalString | null;\n deposits: DecimalString | null;\n withdrawals: DecimalString | null;\n /** Sum of market, liquidity-provision, and combo realized PnL. */\n realizedPnl: DecimalString;\n /** Rebates plus reward, yield, and referral income. */\n walletIncome: DecimalString | null;\n /** Realized plus unrealized position PnL. */\n positionPnl: DecimalString | null;\n /** Realized PnL plus wallet income. */\n settledPnl: DecimalString | null;\n /** Position PnL plus wallet income. */\n economicPnl: DecimalString | null;\n /** Compatibility trading-PnL series. */\n tradePnl: DecimalString | null;\n /** Reward, yield, and referral income. */\n sponsoredIncome: DecimalString | null;\n /** Cumulative fee charges, represented as a negative amount. */\n fees: DecimalString | null;\n /** Fee refunds minus charges. */\n feesPaid: DecimalString | null;\n /** Deposits minus withdrawals. */\n cashflowNet: DecimalString | null;\n /** Cumulative maker-attributed fill volume, in shares. */\n volume: DecimalString;\n /** Cumulative maker-attributed fill volume, in USDC. */\n volumeUsdc: DecimalString;\n /** Cumulative maker-attributed canonical fill count. */\n tradeCount: number;\n};\n\nconst UncoveredAmountSchema = DecimalishSchema.nullish().transform(\n (amount) => amount ?? null,\n);\n\nexport const UserPnlPointSchema = z\n .object({\n timestamp: EpochSecondsToMillisecondsSchema,\n source_block: z.number().int().nonnegative(),\n realized_market_pnl: DecimalishSchema,\n realized_lp_pnl: DecimalishSchema,\n realized_combo_pnl: DecimalishSchema,\n unrealized_pnl: UncoveredAmountSchema,\n fees_refunded: UncoveredAmountSchema,\n maker_rebate: UncoveredAmountSchema,\n taker_rebate: UncoveredAmountSchema,\n reward_income: UncoveredAmountSchema,\n yield_income: UncoveredAmountSchema,\n referral_income: UncoveredAmountSchema,\n deposits: UncoveredAmountSchema,\n withdrawals: UncoveredAmountSchema,\n realized_pnl: DecimalishSchema,\n wallet_income: UncoveredAmountSchema,\n position_pnl: UncoveredAmountSchema,\n settled_pnl: UncoveredAmountSchema,\n economic_pnl: UncoveredAmountSchema,\n trade_pnl: UncoveredAmountSchema,\n sponsored_income: UncoveredAmountSchema,\n fees: UncoveredAmountSchema,\n fees_paid: UncoveredAmountSchema,\n cashflow_net: UncoveredAmountSchema,\n volume: DecimalishSchema,\n volume_usdc: DecimalishSchema,\n trade_count: z.number().int().nonnegative(),\n })\n .transform(\n ({\n source_block,\n realized_market_pnl,\n realized_lp_pnl,\n realized_combo_pnl,\n unrealized_pnl,\n fees_refunded,\n maker_rebate,\n taker_rebate,\n reward_income,\n yield_income,\n referral_income,\n realized_pnl,\n wallet_income,\n position_pnl,\n settled_pnl,\n economic_pnl,\n trade_pnl,\n sponsored_income,\n fees_paid,\n cashflow_net,\n volume_usdc,\n trade_count,\n ...point\n }) => ({\n ...point,\n sourceBlock: source_block,\n realizedMarketPnl: realized_market_pnl,\n realizedLpPnl: realized_lp_pnl,\n realizedComboPnl: realized_combo_pnl,\n unrealizedPnl: unrealized_pnl,\n feesRefunded: fees_refunded,\n makerRebate: maker_rebate,\n takerRebate: taker_rebate,\n rewardIncome: reward_income,\n yieldIncome: yield_income,\n referralIncome: referral_income,\n realizedPnl: realized_pnl,\n walletIncome: wallet_income,\n positionPnl: position_pnl,\n settledPnl: settled_pnl,\n economicPnl: economic_pnl,\n tradePnl: trade_pnl,\n sponsoredIncome: sponsored_income,\n feesPaid: fees_paid,\n cashflowNet: cashflow_net,\n volumeUsdc: volume_usdc,\n tradeCount: trade_count,\n }),\n ) satisfies z.ZodType<UserPnlPoint>;\n\nexport type UserPnlSeries = {\n wallet: EvmAddress;\n interval: UserPnlInterval;\n fidelity: UserPnlFidelity;\n /** Fidelity of the underlying observations before grid synthesis. */\n sourceFidelity: UserPnlFidelity;\n /** Dense cumulative points, oldest first. */\n points: UserPnlPoint[];\n};\n\nexport const UserPnlSeriesSchema = z\n .object({\n proxy_wallet: EvmAddressSchema,\n interval: UserPnlIntervalSchema,\n fidelity: UserPnlFidelitySchema,\n source_fidelity: UserPnlFidelitySchema,\n points: z.array(UserPnlPointSchema),\n })\n .transform(({ proxy_wallet, source_fidelity, ...series }) => ({\n ...series,\n wallet: proxy_wallet,\n sourceFidelity: source_fidelity,\n })) satisfies z.ZodType<UserPnlSeries>;\n\nexport type UserVolume = {\n /** Both-sides traded volume in shares. */\n volume: DecimalString;\n /** Both-sides traded volume in USD. */\n volumeUsdc: DecimalString;\n /** Number of fills in the served window. */\n tradeCount: number;\n};\n\nexport const UserVolumeSchema = z\n .object({\n volume: DecimalishSchema,\n volume_usdc: DecimalishSchema,\n trade_count: z.number().int().nonnegative(),\n })\n .transform(({ volume_usdc, trade_count, ...volume }) => ({\n ...volume,\n volumeUsdc: volume_usdc,\n tradeCount: trade_count,\n })) satisfies z.ZodType<UserVolume>;\n\nexport type UserStats = {\n wallet: EvmAddress;\n /** Exact number of distinct markets the wallet has traded. */\n tradedMarketCount: number;\n /** Largest resolved position win over $1, in USDC; otherwise zero. */\n biggestWin: DecimalString;\n views: number;\n /** Account join time as Unix epoch milliseconds, when known. */\n joinDate: EpochMilliseconds | null;\n /** Latest cumulative all-time PnL observation, when published. */\n allTimePnl: UserPnlPoint | null;\n};\n\nexport const UserStatsSchema = z\n .object({\n proxy_wallet: EvmAddressSchema,\n trades: z.number().int().nonnegative(),\n biggest_win: DecimalishSchema,\n views: z.number().int().nonnegative(),\n join_date: EpochSecondsToMillisecondsSchema.nullish(),\n all_time_pnl: UserPnlPointSchema.nullish(),\n })\n .transform(\n ({\n proxy_wallet,\n trades,\n biggest_win,\n join_date,\n all_time_pnl,\n ...stats\n }) => ({\n ...stats,\n wallet: proxy_wallet,\n tradedMarketCount: trades,\n biggestWin: biggest_win,\n joinDate: join_date ?? null,\n allTimePnl: all_time_pnl ?? null,\n }),\n ) satisfies z.ZodType<UserStats>;\n\nexport const ComboPositionMarketEventSchema = z\n .object({\n event_id: z.string().nullish(),\n event_slug: z.string().nullish(),\n event_title: z.string().nullish(),\n event_image: z.string().nullish(),\n })\n .transform(({ event_id, event_slug, event_title, event_image }) => ({\n eventId: event_id,\n eventSlug: event_slug,\n eventTitle: event_title,\n eventImage: event_image,\n }));\n\nexport const ComboPositionMarketSchema = z\n .object({\n market_id: z.string().nullish(),\n slug: z.string().nullish(),\n title: z.string().nullish(),\n /** Full market question. */\n question: z.string().nullish(),\n /** Short per-leg label before the title fallback. */\n group_item_title: z.string().nullish(),\n /** Sports market classification, empty for non-sports markets. */\n sports_market_type: z.string().nullish(),\n /** Sports line, or null when the market has none. */\n line: z.number().nullish(),\n /** Outcome labels in outcome-index order. */\n outcomes: z.array(z.string()).nullish(),\n outcome: z.string().nullish(),\n image_url: z.string().nullish(),\n icon_url: z.string().nullish(),\n category: z.string().nullish(),\n subcategory: z.string().nullish(),\n tags: z.array(z.string()).nullish(),\n end_date: IsoDateTimeStringSchema.nullish(),\n event: ComboPositionMarketEventSchema.nullish(),\n })\n .transform(\n ({\n market_id,\n image_url,\n icon_url,\n end_date,\n group_item_title,\n sports_market_type,\n ...rest\n }) => ({\n ...rest,\n marketId: market_id,\n groupItemTitle: group_item_title,\n sportsMarketType: sports_market_type,\n imageUrl: image_url,\n iconUrl: icon_url,\n endDate: end_date,\n }),\n );\n\nexport const ComboPositionLegSchema = z\n .object({\n leg_index: z.number().int(),\n leg_position_id: PositionIdSchema,\n leg_condition_id: ConditionIdSchema,\n leg_outcome_index: z.number().int(),\n leg_outcome_label: z.string().nullish(),\n leg_status: ComboPositionStatusSchema,\n leg_resolved_at: IsoDateTimeStringSchema.nullish(),\n leg_current_price: DecimalishSchema.nullish(),\n market: ComboPositionMarketSchema.nullish(),\n })\n .transform(\n ({\n leg_index,\n leg_position_id,\n leg_condition_id,\n leg_outcome_index,\n leg_outcome_label,\n leg_status,\n leg_resolved_at,\n leg_current_price,\n ...rest\n }) => ({\n ...rest,\n legIndex: leg_index,\n legPositionId: leg_position_id,\n legConditionId: leg_condition_id,\n legOutcomeIndex: leg_outcome_index,\n legOutcomeLabel: leg_outcome_label,\n legStatus: leg_status,\n legResolvedAt: leg_resolved_at,\n legCurrentPrice: leg_current_price,\n }),\n );\n\nexport const ComboPositionSchema = z\n .object({\n combo_condition_id: ComboConditionIdSchema,\n outcome_index: z.number().int(),\n outcome_label: z.string(),\n combo_position_id: PositionIdSchema,\n proxy_wallet: EvmAddressSchema,\n current_size: DecimalishSchema,\n entry_avg_price_usdc: DecimalishSchema,\n entry_cost_usdc: DecimalishSchema,\n // Exact 6-dp basis pair — never reconstruct one from the others:\n // `entry_cost_usdc` is rounded weighted-average cost, while the\n // fee-exclusive basis is `gross_entry_cost_usdc − entry_fees_usdc`.\n gross_entry_cost_usdc: DecimalishSchema,\n entry_fees_usdc: DecimalishSchema,\n realized_payout_usdc: DecimalishSchema,\n status: ComboPositionStatusSchema,\n redeemable: z.boolean(),\n first_entry_at: IsoDateTimeStringSchema,\n resolved_at: IsoDateTimeStringSchema.nullish(),\n legs_total: z.number().int(),\n legs_resolved: z.number().int(),\n legs_pending: z.number().int(),\n legs: z.array(ComboPositionLegSchema),\n updated_at: IsoDateTimeStringSchema,\n })\n .transform(\n ({\n combo_condition_id,\n outcome_index,\n outcome_label,\n combo_position_id,\n proxy_wallet,\n current_size,\n entry_avg_price_usdc,\n entry_cost_usdc,\n gross_entry_cost_usdc,\n entry_fees_usdc,\n realized_payout_usdc,\n first_entry_at,\n resolved_at,\n legs_total,\n legs_resolved,\n legs_pending,\n updated_at,\n ...rest\n }) => ({\n ...rest,\n conditionId: combo_condition_id,\n outcomeIndex: outcome_index,\n outcomeLabel: outcome_label,\n positionId: combo_position_id,\n wallet: proxy_wallet,\n currentSize: current_size,\n entryAvgPriceUsdc: entry_avg_price_usdc,\n entryCostUsdc: entry_cost_usdc,\n grossEntryCostUsdc: gross_entry_cost_usdc,\n entryFeesUsdc: entry_fees_usdc,\n realizedPayoutUsdc: realized_payout_usdc,\n firstEntryAt: first_entry_at,\n resolvedAt: resolved_at,\n legsTotal: legs_total,\n legsResolved: legs_resolved,\n legsPending: legs_pending,\n updatedAt: updated_at,\n }),\n );\n\nexport const ListPositionsResponseSchema = dataPageSchema(PositionSchema);\nexport const FetchPortfolioValueResponseSchema =\n dataEnvelopeSchema(PortfolioValueSchema);\nexport const FetchUserStatsResponseSchema = dataEnvelopeSchema(\n UserStatsSchema.nullable(),\n);\nexport const FetchUserPnlResponseSchema =\n dataEnvelopeSchema(UserPnlSeriesSchema);\nexport const FetchUserVolumeResponseSchema =\n dataEnvelopeSchema(UserVolumeSchema);\nexport const ListComboPositionsResponseSchema =\n dataPageSchema(ComboPositionSchema);\n\nexport type ComboPositionMarketEvent = z.infer<\n typeof ComboPositionMarketEventSchema\n>;\nexport type ComboPositionMarket = z.infer<typeof ComboPositionMarketSchema>;\nexport type ComboPositionLeg = z.infer<typeof ComboPositionLegSchema>;\nexport type ComboPosition = z.infer<typeof ComboPositionSchema>;\nexport type ListPositionsResponse = z.infer<typeof ListPositionsResponseSchema>;\nexport type FetchPortfolioValueResponse = z.infer<\n typeof FetchPortfolioValueResponseSchema\n>;\nexport type FetchUserStatsResponse = z.infer<\n typeof FetchUserStatsResponseSchema\n>;\nexport type FetchUserPnlResponse = z.infer<typeof FetchUserPnlResponseSchema>;\nexport type FetchUserVolumeResponse = z.infer<\n typeof FetchUserVolumeResponseSchema\n>;\nexport type ListComboPositionsResponse = z.infer<\n typeof ListComboPositionsResponseSchema\n>;\n","import type { EvmAddress } from '@kuest/types';\nimport { z } from 'zod';\nimport {\n ClobAssetIdSchema,\n type ComboActivityId,\n ComboActivityIdSchema,\n type ComboConditionId,\n ComboConditionIdSchema,\n type ConditionId,\n ConditionIdSchema,\n DecimalishSchema,\n type DecimalString,\n type EpochMilliseconds,\n EpochSecondsToMillisecondsSchema,\n EvmAddressSchema,\n type OrderSide,\n OrderSideSchema,\n type PositionId,\n PositionIdSchema,\n type TokenId,\n type TxHash,\n TxHashSchema,\n} from '../shared';\nimport {\n ActivityType,\n ActivityTypeSchema,\n type TipSide,\n TipSideSchema,\n} from './common';\nimport { dataPageSchema } from './envelope';\nimport { type ComboPositionLeg, ComboPositionLegSchema } from './portfolio';\n\nexport enum ComboActivityType {\n Split = 'SPLIT',\n Merge = 'MERGE',\n Convert = 'CONVERT',\n Compress = 'COMPRESS',\n Wrap = 'WRAP',\n Unwrap = 'UNWRAP',\n Redeem = 'REDEEM',\n}\n\nconst ComboActivityTypeSchema = z.enum(ComboActivityType);\n\nexport type ActivityBase = {\n /** Wallet address whose account history contains this activity. */\n wallet: EvmAddress;\n /** Activity time as Unix epoch milliseconds. */\n timestamp: EpochMilliseconds;\n /** Polygon transaction hash that produced or records this activity. */\n transactionHash: TxHash;\n /** Display name of the wallet owner at the time returned by the API. */\n name: string | null;\n /** Public pseudonym of the wallet owner at the time returned by the API. */\n pseudonym: string | null;\n /** Profile biography of the wallet owner at the time returned by the API. */\n bio: string | null;\n /** Source profile image URL for the wallet owner. */\n profileImage: string | null;\n /** Optimized profile image URL for the wallet owner. */\n profileImageOptimized: string | null;\n};\n\ntype TradeActivityBase = ActivityBase & {\n /** A directional outcome trade. */\n type: ActivityType.TRADE;\n /** Whether this trade is for a Combo position instead of an ordinary market. */\n isCombo: boolean;\n /** Direction of the wallet's trade. */\n side: OrderSide;\n /** Number of shares traded by the wallet. */\n shares: DecimalString;\n /** The notional value of the traded shares in USD. */\n amount: DecimalString;\n /** The execution price per share in USD. */\n price: DecimalString;\n /** Human-readable title of the traded market or Combo. */\n title: string;\n /** Icon URL for the traded market or Combo, when available. */\n icon: string | null;\n};\n\nexport type ClobTradeActivity = TradeActivityBase & {\n /** Ordinary market trades are distinct from Combo position trades. */\n isCombo: false;\n /** Condition id of the market traded by the wallet. */\n conditionId: ConditionId;\n /** Outcome identifier for a CTF token or Polymarket V2 position. */\n assetId: TokenId | PositionId;\n /** @deprecated Use `assetId`. */\n tokenId: TokenId | PositionId;\n /** Display label of the outcome traded by the wallet. */\n outcome: string;\n /** Zero-based index of the outcome in the market's outcome list, when known. */\n outcomeIndex?: number;\n /** URL slug of the market traded by the wallet. */\n slug: string;\n /** URL slug of the event containing the traded market. */\n eventSlug: string;\n};\n\nexport type ComboTradeActivity = TradeActivityBase & {\n /** Combo trades are protocol v2 Combo position trades. */\n isCombo: true;\n /** Combo condition id traded by the wallet. */\n conditionId: ComboConditionId;\n /** Combo position id bought or sold by the wallet. */\n positionId: PositionId;\n /** Basket token label, when available; never a selected leg's label. */\n outcome?: string;\n /** Basket token side index, when known. Missing is not zero. */\n outcomeIndex?: number;\n};\n\nexport type TradeActivity = ClobTradeActivity | ComboTradeActivity;\n\n/** Collateral split into a market or Combo complete set; narrow on isCombo for market URLs. */\nexport type SplitActivity = ActivityBase &\n (\n | {\n /** Splitting collateral into a complete market set. */\n type: 'SPLIT';\n /** Ordinary complete-set activity; parsed rows return false. */\n isCombo?: false;\n /** Condition id of the market whose complete set was created. */\n conditionId: ConditionId;\n /** The collateral amount split into the complete set in USD. */\n amount: DecimalString;\n /** Human-readable title of the market whose complete set was created. */\n title: string;\n /** URL slug of the market whose complete set was created. */\n slug: string;\n /** Icon URL for the market whose complete set was created, when available. */\n icon: string | null;\n /** URL slug of the event containing the split market. */\n eventSlug: string;\n }\n | {\n /** Complete-set activity for a Combo basket. */\n type: 'SPLIT';\n isCombo: true;\n /** Canonical Combo condition id of the basket. */\n conditionId: ComboConditionId;\n /** Collateral amount in USD. */\n amount: DecimalString;\n /** Human-readable basket title, when available. */\n title?: string;\n icon: string | null;\n }\n );\n\n/** A complete set merged into collateral; narrow on isCombo for market URLs. */\nexport type MergeActivity = ActivityBase &\n (\n | {\n /** Merging a complete market set into collateral. */\n type: 'MERGE';\n /** Ordinary complete-set activity; parsed rows return false. */\n isCombo?: false;\n /** Condition id of the market whose complete set was merged. */\n conditionId: ConditionId;\n /** The collateral amount received from merging the complete set in USD. */\n amount: DecimalString;\n /** Human-readable title of the market whose complete set was merged. */\n title: string;\n /** URL slug of the market whose complete set was merged. */\n slug: string;\n /** Icon URL for the market whose complete set was merged, when available. */\n icon: string | null;\n /** URL slug of the event containing the merged market. */\n eventSlug: string;\n }\n | {\n /** Complete-set activity for a Combo basket. */\n type: 'MERGE';\n isCombo: true;\n /** Canonical Combo condition id of the basket. */\n conditionId: ComboConditionId;\n /** Collateral amount in USD. */\n amount: DecimalString;\n /** Human-readable basket title, when available. */\n title?: string;\n icon: string | null;\n }\n );\n\nexport type ClobRedeemActivity = ActivityBase & {\n /** Redeeming resolved market proceeds. */\n type: 'REDEEM';\n /** Ordinary redemption; parsed rows return false, constructed values may omit it. */\n isCombo?: false;\n /** Label of the redeemed token, when available. */\n outcome?: string;\n /** Index of the redeemed token's outcome, when known. */\n outcomeIndex?: number;\n /** Condition id of the market redeemed by the wallet. */\n conditionId: ConditionId;\n /** The proceeds redeemed from the resolved market in USD. */\n amount: DecimalString;\n /** Human-readable title of the market redeemed by the wallet. */\n title: string;\n /** URL slug of the market redeemed by the wallet. */\n slug: string;\n /** Icon URL for the market redeemed by the wallet, when available. */\n icon: string | null;\n /** URL slug of the event containing the redeemed market. */\n eventSlug: string;\n};\n\n/** A resolved Combo token's proceeds in wallet activity history. */\nexport type ComboRedemptionActivity = ActivityBase & {\n type: 'REDEEM';\n isCombo: true;\n /** Canonical Combo condition id of the redeemed basket. */\n conditionId: ComboConditionId;\n /** Proceeds redeemed in USD. */\n amount: DecimalString;\n /** Human-readable title of the redeemed basket, when available. */\n title?: string;\n icon: string | null;\n /** Basket token label, when available; never a selected leg's label. */\n outcome?: string;\n /** Basket token side index, when known. Missing is not zero. */\n outcomeIndex?: number;\n};\n\n/** Wallet redemption; narrow on isCombo before using market-only metadata. */\nexport type RedeemActivity = ClobRedeemActivity | ComboRedemptionActivity;\n\nexport type ConversionActivity = ActivityBase & {\n /** A market conversion or migration activity. */\n type: 'CONVERSION';\n /** Condition id of the market involved in the conversion. */\n conditionId: ConditionId;\n /** The amount converted or migrated for the market in USD. */\n amount: DecimalString;\n /** Human-readable title of the market involved in the conversion. */\n title: string;\n /** URL slug of the market involved in the conversion. */\n slug: string;\n /** Icon URL for the market involved in the conversion, when available. */\n icon: string | null;\n /** URL slug of the event containing the converted market. */\n eventSlug: string;\n};\n\nexport type MigrationActivity = ActivityBase & {\n /** A position migrated from the legacy protocol to protocol v2. */\n type: 'MIGRATION';\n /** The migrated position value in USD. */\n amount: DecimalString;\n};\n\nexport type RewardActivity = ActivityBase & {\n /** An account-level reward credit. */\n type: 'REWARD';\n /** The reward amount credited to the wallet in USD. */\n amount: DecimalString;\n};\n\nexport type MakerRebateActivity = ActivityBase & {\n /** An account-level maker rebate credit. */\n type: 'MAKER_REBATE';\n /** The maker rebate amount credited to the wallet in USD. */\n amount: DecimalString;\n};\n\nexport type ReferralRewardActivity = ActivityBase & {\n /** An account-level referral reward credit. */\n type: 'REFERRAL_REWARD';\n /** The referral reward amount credited to the wallet in USD. */\n amount: DecimalString;\n};\n\nexport type YieldActivity = ActivityBase & {\n /** An account-level yield credit. */\n type: 'YIELD';\n /** The yield amount credited to the wallet in USD. */\n amount: DecimalString;\n};\n\nexport type DepositActivity = ActivityBase & {\n /** An account-level deposit credit. */\n type: 'DEPOSIT';\n /** The deposit amount credited to the wallet in USD. */\n amount: DecimalString;\n};\n\nexport type WithdrawalActivity = ActivityBase & {\n /** An account-level withdrawal debit. */\n type: 'WITHDRAWAL';\n /** The withdrawal amount debited from the wallet in USD. */\n amount: DecimalString;\n};\n\nexport type TakerRebateActivity = ActivityBase & {\n /** An account-level taker rebate credit. */\n type: 'TAKER_REBATE';\n /** The taker rebate amount credited to the wallet in USD. */\n amount: DecimalString;\n};\n\nexport type TipActivity = ActivityBase & {\n /** A user-to-user tip. */\n type: 'TIP';\n /** The tipped amount in USD. */\n amount: DecimalString;\n /**\n * Direction from this wallet's perspective: `IN` received, `OUT` sent.\n * `null` on rows served before the wire carried a direction.\n */\n side: TipSide | null;\n};\n\nexport type Activity =\n | TradeActivity\n | SplitActivity\n | MergeActivity\n | RedeemActivity\n | ConversionActivity\n | MigrationActivity\n | RewardActivity\n | MakerRebateActivity\n | ReferralRewardActivity\n | YieldActivity\n | DepositActivity\n | WithdrawalActivity\n | TakerRebateActivity\n | TipActivity;\n\ntype ComboActivityBase = {\n /** Stable row id derived from the transaction hash and log index. */\n id: ComboActivityId;\n /** Normalized lifecycle activity type. */\n type: ComboActivityType;\n /** Wallet address whose account history contains this activity. */\n wallet: EvmAddress;\n /** Combo condition id involved in this activity. */\n conditionId: ComboConditionId;\n /** Combo position id involved in this activity. */\n positionId: PositionId;\n /** Amount associated with the lifecycle event in USD. */\n amount: DecimalString | null;\n /** Activity time as Unix epoch milliseconds. */\n timestamp: EpochMilliseconds;\n /** Polygon transaction hash that produced this activity. */\n transactionHash: TxHash;\n /** Polygon block number. */\n blockNumber: number;\n /** Combo legs enriched with market metadata at read time. */\n legs: ComboPositionLeg[];\n};\n\nexport type ComboSplitActivity = ComboActivityBase & {\n type: ComboActivityType.Split;\n};\n\nexport type ComboMergeActivity = ComboActivityBase & {\n type: ComboActivityType.Merge;\n};\n\nexport type ComboConvertActivity = ComboActivityBase & {\n type: ComboActivityType.Convert;\n};\n\nexport type ComboCompressActivity = ComboActivityBase & {\n type: ComboActivityType.Compress;\n};\n\nexport type ComboWrapActivity = ComboActivityBase & {\n type: ComboActivityType.Wrap;\n};\n\nexport type ComboUnwrapActivity = ComboActivityBase & {\n type: ComboActivityType.Unwrap;\n};\n\nexport type ComboRedeemActivity = ComboActivityBase & {\n type: ComboActivityType.Redeem;\n /** Payout from the redemption in USD. Only redeem rows carry payout semantics. */\n payout: DecimalString | null;\n};\n\nexport type ComboActivity =\n | ComboSplitActivity\n | ComboMergeActivity\n | ComboConvertActivity\n | ComboCompressActivity\n | ComboWrapActivity\n | ComboUnwrapActivity\n | ComboRedeemActivity;\n\nconst RawComboActivitySchema = z.object({\n id: ComboActivityIdSchema,\n type: ComboActivityTypeSchema,\n proxy_wallet: EvmAddressSchema,\n combo_condition_id: ComboConditionIdSchema,\n combo_position_id: PositionIdSchema,\n amount_usdc: DecimalishSchema.nullish(),\n payout_usdc: DecimalishSchema.nullish(),\n timestamp: EpochSecondsToMillisecondsSchema,\n transaction_hash: TxHashSchema,\n block_number: z.number().int(),\n legs: z.array(ComboPositionLegSchema),\n});\n\nexport const ComboActivitySchema: z.ZodType<ComboActivity> =\n RawComboActivitySchema.transform(normalizeComboActivity);\n\nconst OptionalTextSchema = z.preprocess(\n (value) => (value === '' ? undefined : value),\n z.string().optional(),\n);\n\nconst UnknownOutcomeIndexToUndefinedSchema = z.preprocess(\n (value) => (value === 999 ? undefined : value),\n z.number().int().optional(),\n);\n\nexport type Trade = {\n wallet: EvmAddress;\n side: OrderSide;\n /** Outcome identifier for a CTF token or Polymarket V2 position. */\n assetId: TokenId | PositionId;\n /** @deprecated Use `assetId`. */\n tokenId: TokenId | PositionId;\n conditionId: ConditionId;\n size: DecimalString;\n price: DecimalString;\n timestamp: EpochMilliseconds;\n title?: string;\n slug?: string;\n icon?: string;\n eventSlug?: string;\n outcome?: string;\n outcomeIndex?: number;\n name?: string;\n pseudonym?: string;\n bio?: string;\n profileImage?: string;\n profileImageOptimized?: string;\n transactionHash: TxHash;\n};\n\n/**\n * A trades-feed row, normalized to the SDK vocabulary.\n *\n * The wire is strict snake_case with every field present: absence arrives\n * as an empty string (normalized to `undefined` here) and an unknown outcome\n * index arrives as the sentinel `999` (also normalized to `undefined` —\n * missing is never `0`). Timestamps arrive as epoch seconds and normalize to\n * epoch milliseconds. `size` is a share count and `price` is USD per share.\n * The asset is a CTF token id or a Polymarket V2 position id.\n */\nexport const TradeSchema = z\n .object({\n proxy_wallet: EvmAddressSchema,\n side: OrderSideSchema,\n token_id: ClobAssetIdSchema,\n condition_id: ConditionIdSchema,\n size: DecimalishSchema,\n price: DecimalishSchema,\n timestamp: EpochSecondsToMillisecondsSchema,\n title: OptionalTextSchema,\n slug: OptionalTextSchema,\n icon: OptionalTextSchema,\n event_slug: OptionalTextSchema,\n outcome: OptionalTextSchema,\n outcome_index: UnknownOutcomeIndexToUndefinedSchema,\n name: OptionalTextSchema,\n pseudonym: OptionalTextSchema,\n bio: OptionalTextSchema,\n profile_image: OptionalTextSchema,\n profile_image_optimized: OptionalTextSchema,\n transaction_hash: TxHashSchema,\n })\n .transform((trade) => ({\n wallet: trade.proxy_wallet,\n side: trade.side,\n assetId: trade.token_id,\n tokenId: trade.token_id,\n conditionId: trade.condition_id,\n size: trade.size,\n price: trade.price,\n timestamp: trade.timestamp,\n title: trade.title,\n slug: trade.slug,\n icon: trade.icon,\n eventSlug: trade.event_slug,\n outcome: trade.outcome,\n outcomeIndex: trade.outcome_index,\n name: trade.name,\n pseudonym: trade.pseudonym,\n bio: trade.bio,\n profileImage: trade.profile_image,\n profileImageOptimized: trade.profile_image_optimized,\n transactionHash: trade.transaction_hash,\n })) satisfies z.ZodType<Trade>;\n\nconst RawActivitySchema = z\n .object({\n proxy_wallet: EvmAddressSchema,\n timestamp: EpochSecondsToMillisecondsSchema,\n condition_id: z.preprocess(\n (value) => (value === '' ? undefined : value),\n ConditionIdSchema.optional(),\n ),\n type: ActivityTypeSchema,\n size: DecimalishSchema,\n usdc_size: DecimalishSchema,\n transaction_hash: TxHashSchema,\n price: DecimalishSchema,\n token_id: z.preprocess(\n (value) => (value === '' ? undefined : value),\n ClobAssetIdSchema.optional(),\n ),\n // Trade rows carry BUY/SELL; TIP rows carry IN/OUT. The per-variant\n // normalizers narrow to the vocabulary their type allows.\n side: z.preprocess(\n (value) => (value === '' ? undefined : value),\n z.union([OrderSideSchema, TipSideSchema]).optional(),\n ),\n // Combo flag for general activity rows; ordinary rows may omit it.\n is_combo: z.boolean().optional(),\n outcome_index: UnknownOutcomeIndexToUndefinedSchema,\n title: OptionalTextSchema,\n slug: OptionalTextSchema,\n icon: OptionalTextSchema,\n event_slug: OptionalTextSchema,\n outcome: OptionalTextSchema,\n name: OptionalTextSchema,\n pseudonym: OptionalTextSchema,\n bio: OptionalTextSchema,\n profile_image: OptionalTextSchema,\n profile_image_optimized: OptionalTextSchema,\n })\n .superRefine((activity, ctx) => {\n if (\n activity.is_combo !== true ||\n (activity.type !== ActivityType.TRADE &&\n activity.type !== ActivityType.REDEEM &&\n activity.type !== ActivityType.SPLIT &&\n activity.type !== ActivityType.MERGE)\n ) {\n return;\n }\n\n const condition = ComboConditionIdSchema.safeParse(activity.condition_id);\n if (!condition.success) {\n for (const issue of condition.error.issues) {\n ctx.addIssue({ ...issue, path: ['condition_id', ...issue.path] });\n }\n }\n });\n\nexport const ActivitySchema: z.ZodType<Activity> =\n RawActivitySchema.transform(normalizeActivity);\n\nexport const ListTradesResponseSchema = dataPageSchema(TradeSchema);\nexport const ListActivityResponseSchema = dataPageSchema(ActivitySchema);\nexport const ListComboActivityResponseSchema =\n dataPageSchema(ComboActivitySchema);\n\nexport type ListTradesResponse = z.infer<typeof ListTradesResponseSchema>;\nexport type ListActivityResponse = z.infer<typeof ListActivityResponseSchema>;\nexport type ListComboActivityResponse = z.infer<\n typeof ListComboActivityResponseSchema\n>;\n\ntype RawComboActivity = z.infer<typeof RawComboActivitySchema>;\ntype RawActivity = z.infer<typeof RawActivitySchema>;\n\nfunction normalizeComboActivity(activity: RawComboActivity): ComboActivity {\n const base = normalizeComboActivityBase(activity);\n\n switch (activity.type) {\n case ComboActivityType.Split:\n return { ...base, type: ComboActivityType.Split };\n case ComboActivityType.Merge:\n return { ...base, type: ComboActivityType.Merge };\n case ComboActivityType.Convert:\n return { ...base, type: ComboActivityType.Convert };\n case ComboActivityType.Compress:\n return { ...base, type: ComboActivityType.Compress };\n case ComboActivityType.Wrap:\n return { ...base, type: ComboActivityType.Wrap };\n case ComboActivityType.Unwrap:\n return { ...base, type: ComboActivityType.Unwrap };\n case ComboActivityType.Redeem:\n return {\n ...base,\n type: ComboActivityType.Redeem,\n payout: activity.payout_usdc ?? null,\n };\n }\n}\n\nfunction normalizeComboActivityBase(\n activity: RawComboActivity,\n): ComboActivityBase {\n return {\n id: activity.id,\n type: activity.type,\n wallet: activity.proxy_wallet,\n conditionId: activity.combo_condition_id,\n positionId: activity.combo_position_id,\n amount: activity.amount_usdc ?? null,\n timestamp: activity.timestamp,\n transactionHash: activity.transaction_hash,\n blockNumber: activity.block_number,\n legs: activity.legs,\n };\n}\n\nfunction normalizeActivity(activity: RawActivity): Activity {\n const base = normalizeActivityBase(activity);\n\n switch (activity.type) {\n case ActivityType.TRADE:\n return normalizeTradeActivity(activity, base);\n case ActivityType.REDEEM:\n return normalizeRedeemActivity(activity, base);\n case ActivityType.SPLIT:\n case ActivityType.MERGE:\n if (activity.is_combo === true) {\n return {\n ...base,\n type: activity.type,\n isCombo: true,\n conditionId: ComboConditionIdSchema.parse(activity.condition_id),\n amount: activity.usdc_size,\n title: activity.title,\n icon: activity.icon ?? null,\n };\n }\n return {\n ...base,\n type: activity.type,\n isCombo: false,\n conditionId: expectPresent(activity.condition_id, 'condition_id'),\n amount: activity.usdc_size,\n title: expectPresent(activity.title, 'title'),\n slug: expectPresent(activity.slug, 'slug'),\n icon: activity.icon ?? null,\n eventSlug: expectPresent(activity.event_slug, 'event_slug'),\n };\n case ActivityType.CONVERSION:\n return {\n ...base,\n type: activity.type,\n conditionId: expectPresent(activity.condition_id, 'condition_id'),\n amount: activity.usdc_size,\n title: expectPresent(activity.title, 'title'),\n slug: expectPresent(activity.slug, 'slug'),\n icon: activity.icon ?? null,\n eventSlug: expectPresent(activity.event_slug, 'event_slug'),\n };\n case ActivityType.MIGRATION:\n case ActivityType.REWARD:\n case ActivityType.MAKER_REBATE:\n case ActivityType.REFERRAL_REWARD:\n case ActivityType.YIELD:\n case ActivityType.DEPOSIT:\n case ActivityType.WITHDRAWAL:\n case ActivityType.TAKER_REBATE:\n return {\n ...base,\n type: activity.type,\n amount: activity.usdc_size,\n };\n case ActivityType.TIP:\n return {\n ...base,\n type: activity.type,\n amount: activity.usdc_size,\n side:\n activity.side === undefined\n ? null\n : TipSideSchema.parse(activity.side),\n };\n }\n}\n\nfunction normalizeTradeActivity(\n activity: RawActivity,\n base: ActivityBase,\n): TradeActivity {\n const trade = {\n ...base,\n type: ActivityType.TRADE as ActivityType.TRADE,\n side: OrderSideSchema.parse(expectPresent(activity.side, 'side')),\n shares: activity.size,\n amount: activity.usdc_size,\n price: activity.price,\n title: expectPresent(activity.title, 'title'),\n icon: activity.icon ?? null,\n };\n\n if (activity.is_combo === true) {\n return {\n ...trade,\n isCombo: true,\n conditionId: ComboConditionIdSchema.parse(\n expectPresent(activity.condition_id, 'condition_id'),\n ),\n positionId: PositionIdSchema.parse(\n expectPresent(activity.token_id, 'token_id'),\n ),\n outcome: activity.outcome,\n outcomeIndex: activity.outcome_index,\n };\n }\n\n const assetId = expectPresent(activity.token_id, 'token_id');\n\n return {\n ...trade,\n isCombo: false,\n conditionId: expectPresent(activity.condition_id, 'condition_id'),\n assetId,\n tokenId: assetId,\n outcome: expectPresent(activity.outcome, 'outcome'),\n outcomeIndex: activity.outcome_index,\n slug: expectPresent(activity.slug, 'slug'),\n eventSlug: expectPresent(activity.event_slug, 'event_slug'),\n };\n}\n\nfunction normalizeRedeemActivity(\n activity: RawActivity,\n base: ActivityBase,\n): RedeemActivity {\n const redemption = {\n ...base,\n type: ActivityType.REDEEM as ActivityType.REDEEM,\n amount: activity.usdc_size,\n title: activity.title,\n icon: activity.icon ?? null,\n outcome: activity.outcome,\n outcomeIndex: activity.outcome_index,\n };\n\n if (activity.is_combo === true) {\n return {\n ...redemption,\n isCombo: true,\n conditionId: ComboConditionIdSchema.parse(\n expectPresent(activity.condition_id, 'condition_id'),\n ),\n };\n }\n\n return {\n ...redemption,\n isCombo: false,\n title: expectPresent(activity.title, 'title'),\n conditionId: expectPresent(activity.condition_id, 'condition_id'),\n slug: expectPresent(activity.slug, 'slug'),\n eventSlug: expectPresent(activity.event_slug, 'event_slug'),\n };\n}\n\nfunction normalizeActivityBase(activity: RawActivity): ActivityBase {\n return {\n wallet: activity.proxy_wallet,\n timestamp: activity.timestamp,\n transactionHash: activity.transaction_hash,\n name: activity.name ?? null,\n pseudonym: activity.pseudonym ?? null,\n bio: activity.bio ?? null,\n profileImage: activity.profile_image ?? null,\n profileImageOptimized: activity.profile_image_optimized ?? null,\n };\n}\n\nfunction expectPresent<T>(value: T | null | undefined, field: string): T {\n if (value === null || value === undefined) {\n throw new TypeError(`Expected activity.${field} to be present`);\n }\n\n return value;\n}\n","import type { EvmAddress } from '@kuest/types';\nimport { z } from 'zod';\nimport {\n ClobAssetIdSchema,\n type ConditionId,\n ConditionIdSchema,\n DecimalishSchema,\n type DecimalString,\n type EpochMilliseconds,\n EpochSecondsToMillisecondsSchema,\n EvmAddressSchema,\n emptyStringToNull,\n type PositionId,\n type TokenId,\n} from '../shared';\nimport { dataEnvelopeSchema, dataPageSchema } from './envelope';\n\n/** Relative window for a token's price history. */\nexport enum PriceHistoryInterval {\n Max = 'max',\n OneMonth = '1m',\n OneWeek = '1w',\n OneDay = '1d',\n SixHours = '6h',\n OneHour = '1h',\n}\n\nexport const PriceHistoryIntervalSchema = z.enum(PriceHistoryInterval);\n\nexport type PriceHistoryPoint = {\n /** Observation time as Unix epoch milliseconds. */\n timestamp: EpochMilliseconds;\n /** Observed price, normalized to a decimal string. */\n price: DecimalString;\n /** Width of the observation window in seconds; zero identifies an exact tick. */\n resolutionSeconds: number;\n};\n\nexport const PriceHistoryPointSchema = z\n .object({\n timestamp: EpochSecondsToMillisecondsSchema,\n price: DecimalishSchema,\n resolution_seconds: z.number().int().nonnegative(),\n })\n .transform(({ price, resolution_seconds, timestamp }) => ({\n timestamp,\n price,\n resolutionSeconds: resolution_seconds,\n })) satisfies z.ZodType<PriceHistoryPoint>;\n\nexport const ListPriceHistoryResponseSchema = dataPageSchema(\n PriceHistoryPointSchema,\n);\nexport type ListPriceHistoryResponse = z.infer<\n typeof ListPriceHistoryResponseSchema\n>;\n\nexport type Holder = {\n wallet: EvmAddress;\n /** Outcome identifier for a CTF token or Polymarket V2 position. */\n assetId: TokenId | PositionId;\n /** @deprecated Use `assetId`. */\n tokenId: TokenId | PositionId;\n /** Holding in shares: net by default, per-side gross with PnL included. */\n amount: DecimalString;\n displayUsernamePublic: boolean;\n outcomeIndex: number | null;\n verified: boolean;\n bio: string | null;\n pseudonym: string | null;\n name: string | null;\n profileImage: string | null;\n profileImageOptimized: string | null;\n /** Historical entry price per share, when PnL is included. */\n avgPrice?: DecimalString | null;\n /** Fee-exclusive entry cost in USDC, when PnL is included. */\n entryCostUsdc?: DecimalString | null;\n /** Current outcome price, when PnL is included. */\n currentPrice?: DecimalString | null;\n /** Current holding value in USDC, when PnL is included. */\n currentValue?: DecimalString | null;\n /** Realized PnL in USDC, when PnL is included. */\n realizedPnl?: DecimalString | null;\n /** Unrealized PnL in USDC, when PnL is included. */\n unrealizedPnl?: DecimalString | null;\n /** Total PnL in USDC, when PnL is included. */\n totalPnl?: DecimalString | null;\n};\n\nconst NullableHolderTextSchema = z.preprocess(\n (value) => (value === '' ? null : value),\n z.string().nullable(),\n);\n\nexport const HolderSchema = z\n .object({\n proxy_wallet: EvmAddressSchema,\n bio: NullableHolderTextSchema,\n token_id: ClobAssetIdSchema,\n pseudonym: NullableHolderTextSchema,\n amount: DecimalishSchema,\n display_username_public: z.boolean(),\n outcome_index: z.preprocess(\n (value) => (value === 999 ? null : value),\n z.number().int().nullable(),\n ),\n name: NullableHolderTextSchema,\n profile_image: NullableHolderTextSchema,\n profile_image_optimized: NullableHolderTextSchema,\n verified: z.boolean(),\n avg_price: DecimalishSchema.nullish(),\n entry_cost_usdc: DecimalishSchema.nullish(),\n current_price: DecimalishSchema.nullish(),\n current_value: DecimalishSchema.nullish(),\n realized_pnl: DecimalishSchema.nullish(),\n unrealized_pnl: DecimalishSchema.nullish(),\n total_pnl: DecimalishSchema.nullish(),\n })\n .transform((holder) => ({\n wallet: holder.proxy_wallet,\n assetId: holder.token_id,\n tokenId: holder.token_id,\n amount: holder.amount,\n displayUsernamePublic: holder.display_username_public,\n outcomeIndex: holder.outcome_index,\n verified: holder.verified,\n bio: holder.bio,\n pseudonym: holder.pseudonym,\n name: holder.name,\n profileImage: holder.profile_image,\n profileImageOptimized: holder.profile_image_optimized,\n avgPrice: holder.avg_price,\n entryCostUsdc: holder.entry_cost_usdc,\n currentPrice: holder.current_price,\n currentValue: holder.current_value,\n realizedPnl: holder.realized_pnl,\n unrealizedPnl: holder.unrealized_pnl,\n totalPnl: holder.total_pnl,\n })) satisfies z.ZodType<Holder>;\n\nexport type MetaHolder = {\n /** Outcome identifier for a CTF token or Polymarket V2 position. */\n assetId: TokenId | PositionId;\n /** @deprecated Use `assetId`. */\n token: TokenId | PositionId;\n /** Holders for this outcome, ordered by amount descending. */\n holders: Holder[];\n};\n\nexport const MetaHolderSchema = z\n .object({\n token_id: ClobAssetIdSchema,\n holders: z.array(HolderSchema),\n })\n .transform(({ holders, token_id }) => ({\n assetId: token_id,\n token: token_id,\n holders,\n })) satisfies z.ZodType<MetaHolder>;\n\nexport type OpenInterest = {\n /** Condition ID of the market, or `null` for the global aggregate. */\n conditionId: ConditionId | null;\n /** Priced gross open interest in USDC. */\n value: DecimalString;\n};\n\nexport const OpenInterestSchema = z\n .object({\n condition_id: z.union([ConditionIdSchema, z.literal('GLOBAL')]),\n value: DecimalishSchema,\n })\n .transform(({ condition_id, value }) => ({\n conditionId: condition_id === 'GLOBAL' ? null : condition_id,\n value,\n })) satisfies z.ZodType<OpenInterest>;\n\nexport type MarketLiveVolume = {\n /** Condition ID of the market, or `null` when the source row is unidentified. */\n conditionId: ConditionId | null;\n /** Cumulative one-side taker volume in shares. */\n takerVolume: DecimalString;\n};\n\nexport const MarketLiveVolumeSchema = z\n .object({\n condition_id: z.preprocess(emptyStringToNull, ConditionIdSchema.nullable()),\n taker_volume: DecimalishSchema,\n })\n .transform(({ condition_id, taker_volume }) => ({\n conditionId: condition_id,\n takerVolume: taker_volume,\n })) satisfies z.ZodType<MarketLiveVolume>;\n\nexport type LiveVolume = {\n /** Sum of every returned market's taker volume, in shares. */\n takerVolumeTotal: DecimalString;\n /** Markets ordered by taker volume descending. */\n markets: MarketLiveVolume[];\n};\n\nexport const LiveVolumeSchema = z\n .object({\n taker_volume_total: DecimalishSchema,\n conditions: z.array(MarketLiveVolumeSchema),\n })\n .transform(({ conditions, taker_volume_total }) => ({\n markets: conditions,\n takerVolumeTotal: taker_volume_total,\n })) satisfies z.ZodType<LiveVolume>;\n\nexport const ListMarketHoldersResponseSchema = dataPageSchema(MetaHolderSchema);\nexport const FetchOpenInterestResponseSchema = dataEnvelopeSchema(\n z.array(OpenInterestSchema),\n);\nexport const FetchEventLiveVolumeResponseSchema =\n dataEnvelopeSchema(LiveVolumeSchema);\n\nexport type ListMarketHoldersResponse = z.infer<\n typeof ListMarketHoldersResponseSchema\n>;\nexport type FetchOpenInterestResponse = z.infer<\n typeof FetchOpenInterestResponseSchema\n>;\nexport type FetchEventLiveVolumeResponse = z.infer<\n typeof FetchEventLiveVolumeResponseSchema\n>;\n","import { z } from 'zod';\nimport { EvmAddressSchema } from '../shared';\nimport { dataEnvelopeSchema } from './envelope';\n\nexport enum ApprovalStandard {\n Erc20 = 'ERC20',\n Erc1155 = 'ERC1155',\n}\n\nconst ApprovalAmountSchema = z.union([\n z.literal('max'),\n z\n .string()\n .regex(/^(0|[1-9][0-9]{0,77})$/)\n .transform(BigInt)\n .refine((amount) => amount <= 2n ** 256n - 1n, 'Expected a uint256 amount'),\n]);\n\n/**\n * Rows for the standards the SDK evaluates. Every field a consumer relies on\n * is validated here, so a malformed required row fails loudly downstream.\n */\nconst KnownApprovalContractSchema = z.discriminatedUnion('standard', [\n z.object({\n token: EvmAddressSchema,\n spender: EvmAddressSchema,\n standard: z.literal(ApprovalStandard.Erc20),\n amount: ApprovalAmountSchema,\n approved: z.boolean(),\n }),\n z.object({\n token: EvmAddressSchema,\n spender: EvmAddressSchema,\n standard: z.literal(ApprovalStandard.Erc1155),\n approved: z.boolean(),\n }),\n]);\n\n/**\n * Any other row. The catalog grows independently of SDK releases, so rows the\n * SDK does not evaluate must parse without failing the whole snapshot. Only\n * the addresses are kept, so consumers can match and then reject the row if\n * they actually needed it.\n */\nconst UnknownApprovalContractSchema = z\n .object({\n token: z.string(),\n spender: z.string(),\n })\n .transform((row) => ({\n token: row.token,\n spender: row.spender,\n standard: undefined,\n }));\n\nconst ApprovalContractSchema = z.union([\n KnownApprovalContractSchema,\n UnknownApprovalContractSchema,\n]);\n\nexport type ApprovalContract = z.infer<typeof ApprovalContractSchema>;\n\n/** An indexed approval snapshot. Recent changes may not yet be reflected. */\nexport const FetchApprovalsResponseSchema = dataEnvelopeSchema(\n z\n .object({\n address: EvmAddressSchema,\n chain_id: z.number().int().positive(),\n contracts: z.array(ApprovalContractSchema),\n })\n .transform(({ chain_id, ...snapshot }) => ({\n ...snapshot,\n chainId: chain_id,\n })),\n);\n\nexport type ApprovalsSnapshot = z.infer<typeof FetchApprovalsResponseSchema>;\n","import { z } from 'zod';\nimport {\n type BuilderCode,\n BuilderCodeSchema,\n type ClobAssetId,\n ClobAssetIdSchema,\n type ComboConditionId,\n ComboConditionIdSchema,\n type ConditionId,\n ConditionIdSchema,\n DecimalishSchema,\n type DecimalString,\n type EpochMilliseconds,\n EpochSecondsToMillisecondsSchema,\n type EventId,\n EventIdSchema,\n type EvmAddress,\n EvmAddressSchema,\n emptyStringToNull,\n type IsoCalendarDateString,\n IsoCalendarDateStringSchema,\n type PositionId,\n PositionIdSchema,\n} from '../shared';\nimport { dataEnvelopeSchema, dataPageSchema } from './envelope';\n\n/** Window used to rank a leaderboard. */\nexport enum LeaderboardWindow {\n Day = 'day',\n Week = 'week',\n Month = 'month',\n All = 'all',\n}\n\nexport const LeaderboardWindowSchema = z.enum(LeaderboardWindow);\n\n/** Bucket width used by the builder volume time series. */\nexport enum BuilderVolumeInterval {\n Day = 'day',\n Week = 'week',\n Month = 'month',\n /** Groups the series by calendar year. */\n Year = 'all',\n}\n\nexport const BuilderVolumeIntervalSchema = z.enum(BuilderVolumeInterval);\n\n/** Metric used to rank traders on the leaderboard. */\nexport enum TraderLeaderboardSort {\n Pnl = 'PNL',\n Volume = 'VOLUME',\n}\n\nexport const TraderLeaderboardSortSchema = z.enum(TraderLeaderboardSort);\n\n/** Source of a winning position. */\nexport enum BiggestWinnerKind {\n Market = 'market',\n Combo = 'combo',\n}\n\nexport const BiggestWinnerKindSchema = z.enum(BiggestWinnerKind);\n\nexport type BuilderStanding = {\n /** Rank in the selected leaderboard window. */\n rank: number;\n /** Display name; use `builderCode` as the stable identifier. */\n builderName: string;\n /** Stable builder identifier. */\n builderCode: BuilderCode;\n profileImage?: string;\n verified: boolean;\n /** Builder-attributed volume in shares. */\n volume: DecimalString;\n /** Distinct active users attributed to the builder. */\n activeUsers: number;\n};\n\nexport const BuilderStandingSchema = z\n .object({\n rank: z.number().int().positive(),\n builder_name: z.string(),\n builder_code: BuilderCodeSchema,\n profile_image: z.string(),\n verified: z.boolean(),\n volume: DecimalishSchema,\n active_users: z.number().int().min(0),\n })\n .transform(\n ({ active_users, builder_code, builder_name, profile_image, ...rest }) => ({\n ...rest,\n activeUsers: active_users,\n builderCode: builder_code,\n builderName: builder_name,\n ...(profile_image === '' ? {} : { profileImage: profile_image }),\n }),\n ) satisfies z.ZodType<BuilderStanding>;\n\nexport type BuilderVolumePoint = {\n /** UTC start date of the volume bucket. */\n bucketDate: IsoCalendarDateString;\n /** Builder rank within this bucket. */\n rank: number;\n /** Display name; use `builderCode` as the stable identifier. */\n builderName: string;\n /** Stable builder identifier. */\n builderCode: BuilderCode;\n profileImage?: string;\n verified: boolean;\n /** Builder-attributed volume in shares for this bucket. */\n volume: DecimalString;\n /** Distinct active users attributed within this bucket. */\n activeUsers: number;\n};\n\nexport const BuilderVolumePointSchema = z\n .object({\n date: IsoCalendarDateStringSchema,\n rank: z.number().int().min(0),\n builder_name: z.string(),\n builder_code: BuilderCodeSchema,\n profile_image: z.string(),\n verified: z.boolean(),\n volume: DecimalishSchema,\n active_users: z.number().int().min(0),\n })\n .transform(\n ({\n active_users,\n builder_code,\n builder_name,\n date,\n profile_image,\n ...rest\n }) => ({\n ...rest,\n activeUsers: active_users,\n bucketDate: date,\n builderCode: builder_code,\n builderName: builder_name,\n ...(profile_image === '' ? {} : { profileImage: profile_image }),\n }),\n ) satisfies z.ZodType<BuilderVolumePoint>;\n\nconst NullableTextSchema = z.preprocess(\n emptyStringToNull,\n z.string().nullable(),\n);\n\nexport type TraderLeaderboardEntry = {\n /** Competition rank on the selected board; ties share a rank and the next rank skips. */\n rank: number;\n /** Ranked wallet. */\n wallet: EvmAddress;\n /** PnL in USD for the selected window. */\n pnl: DecimalString;\n /** Both-sides traded volume in shares. */\n volume: DecimalString;\n userName: string | null;\n profileImage: string | null;\n xUsername: string | null;\n verified: boolean;\n};\n\nexport const TraderLeaderboardEntrySchema = z\n .object({\n rank: z.number().int().min(0),\n user_id: EvmAddressSchema,\n pnl: DecimalishSchema,\n volume: DecimalishSchema,\n user_name: NullableTextSchema,\n profile_image: NullableTextSchema,\n x_username: NullableTextSchema,\n verified: z.boolean(),\n })\n .transform(({ profile_image, user_id, user_name, x_username, ...entry }) => ({\n ...entry,\n wallet: user_id,\n userName: user_name,\n profileImage: profile_image,\n xUsername: x_username,\n })) satisfies z.ZodType<TraderLeaderboardEntry>;\n\nexport type TraderLeaderboardStanding = {\n /** Looked-up wallet. */\n wallet: EvmAddress;\n /** PnL in USD for the selected window. */\n pnl: DecimalString;\n /** Both-sides traded volume in shares. */\n volume: DecimalString;\n /** Competition rank on the PnL board, or `null` when unranked. */\n pnlRank: number | null;\n /** Competition rank on the volume board, or `null` when unranked. */\n volumeRank: number | null;\n userName: string | null;\n profileImage: string | null;\n xUsername: string | null;\n verified: boolean;\n};\n\nexport const TraderLeaderboardStandingSchema = z\n .object({\n user_id: EvmAddressSchema,\n pnl: DecimalishSchema,\n volume: DecimalishSchema,\n rank_pnl: z.number().int().positive().nullable(),\n rank_volume: z.number().int().positive().nullable(),\n user_name: NullableTextSchema,\n profile_image: NullableTextSchema,\n x_username: NullableTextSchema,\n verified: z.boolean(),\n })\n .transform(\n ({\n profile_image,\n rank_pnl,\n rank_volume,\n user_id,\n user_name,\n x_username,\n ...standing\n }) => ({\n ...standing,\n wallet: user_id,\n pnlRank: rank_pnl,\n volumeRank: rank_volume,\n userName: user_name,\n profileImage: profile_image,\n xUsername: x_username,\n }),\n ) satisfies z.ZodType<TraderLeaderboardStanding>;\n\nexport type MarketBiggestWinner = {\n /** Unique one-based row ordinal on the selected board. */\n rank: number;\n kind: BiggestWinnerKind.Market;\n wallet: EvmAddress;\n /** Profit from this winning position, in USD. */\n pnl: DecimalString;\n /** Cost basis of this winning position, in USD. */\n initialValue: DecimalString;\n /** Value of this winning position at resolution, in USD. */\n finalValue: DecimalString;\n /** Resolution time as Unix epoch milliseconds. */\n resolvedAt: EpochMilliseconds;\n conditionId: ConditionId;\n assetId: ClobAssetId;\n eventId: EventId;\n eventSlug: string;\n eventTitle: string;\n userName: string | null;\n profileImage: string | null;\n};\n\nexport type ComboBiggestWinner = {\n /** Unique one-based row ordinal on the selected board. */\n rank: number;\n kind: BiggestWinnerKind.Combo;\n wallet: EvmAddress;\n /** Profit from this winning position, in USD. */\n pnl: DecimalString;\n /** Cost basis of this winning position, in USD. */\n initialValue: DecimalString;\n /** Value of this winning position at resolution, in USD. */\n finalValue: DecimalString;\n /** Resolution time as Unix epoch milliseconds. */\n resolvedAt: EpochMilliseconds;\n conditionId: ComboConditionId;\n positionId: PositionId;\n eventId: null;\n eventSlug: null;\n /** Questions of the Combo's legs joined with ` / `. */\n eventTitle: string;\n userName: string | null;\n profileImage: string | null;\n};\n\nexport type BiggestWinner = MarketBiggestWinner | ComboBiggestWinner;\n\nconst MarketBiggestWinnerSchema = z.object({\n win_rank: z.number().int().positive(),\n kind: z.literal(BiggestWinnerKind.Market),\n user_id: EvmAddressSchema,\n pnl: DecimalishSchema,\n initial_value: DecimalishSchema,\n final_value: DecimalishSchema,\n resolved_at: EpochSecondsToMillisecondsSchema,\n condition_id: ConditionIdSchema,\n position_id: ClobAssetIdSchema,\n event_id: EventIdSchema,\n event_slug: z.string(),\n event_title: z.string(),\n user_name: NullableTextSchema,\n profile_image: NullableTextSchema,\n});\n\nconst ComboBiggestWinnerSchema = z.object({\n win_rank: z.number().int().positive(),\n kind: z.literal(BiggestWinnerKind.Combo),\n user_id: EvmAddressSchema,\n pnl: DecimalishSchema,\n initial_value: DecimalishSchema,\n final_value: DecimalishSchema,\n resolved_at: EpochSecondsToMillisecondsSchema,\n condition_id: ComboConditionIdSchema,\n position_id: PositionIdSchema,\n event_id: z.literal(0),\n event_slug: z.literal(''),\n event_title: z.string(),\n user_name: NullableTextSchema,\n profile_image: NullableTextSchema,\n});\n\nexport const BiggestWinnerSchema = z\n .discriminatedUnion('kind', [\n MarketBiggestWinnerSchema,\n ComboBiggestWinnerSchema,\n ])\n .transform((winner): BiggestWinner => {\n if (winner.kind === BiggestWinnerKind.Combo) {\n return {\n rank: winner.win_rank,\n kind: winner.kind,\n wallet: winner.user_id,\n pnl: winner.pnl,\n initialValue: winner.initial_value,\n finalValue: winner.final_value,\n resolvedAt: winner.resolved_at,\n conditionId: winner.condition_id,\n positionId: winner.position_id,\n eventId: null,\n eventSlug: null,\n eventTitle: winner.event_title,\n userName: winner.user_name,\n profileImage: winner.profile_image,\n };\n }\n\n return {\n rank: winner.win_rank,\n kind: winner.kind,\n wallet: winner.user_id,\n pnl: winner.pnl,\n initialValue: winner.initial_value,\n finalValue: winner.final_value,\n resolvedAt: winner.resolved_at,\n conditionId: winner.condition_id,\n assetId: winner.position_id,\n eventId: winner.event_id,\n eventSlug: winner.event_slug,\n eventTitle: winner.event_title,\n userName: winner.user_name,\n profileImage: winner.profile_image,\n };\n }) satisfies z.ZodType<BiggestWinner>;\n\nexport const ListBuilderLeaderboardResponseSchema = dataPageSchema(\n BuilderStandingSchema,\n);\nexport const FetchBuilderVolumeResponseSchema = dataEnvelopeSchema(\n z.array(BuilderVolumePointSchema),\n);\nexport const ListTraderLeaderboardResponseSchema = dataPageSchema(\n TraderLeaderboardEntrySchema,\n);\nexport const FetchTraderLeaderboardStandingResponseSchema = dataEnvelopeSchema(\n TraderLeaderboardStandingSchema.nullable(),\n);\nexport const ListBiggestWinnersResponseSchema =\n dataPageSchema(BiggestWinnerSchema);\n\nexport type ListBuilderLeaderboardResponse = z.infer<\n typeof ListBuilderLeaderboardResponseSchema\n>;\nexport type FetchBuilderVolumeResponse = z.infer<\n typeof FetchBuilderVolumeResponseSchema\n>;\nexport type ListTraderLeaderboardResponse = z.infer<\n typeof ListTraderLeaderboardResponseSchema\n>;\nexport type FetchTraderLeaderboardStandingResponse = z.infer<\n typeof FetchTraderLeaderboardStandingResponseSchema\n>;\nexport type ListBiggestWinnersResponse = z.infer<\n typeof ListBiggestWinnersResponseSchema\n>;\n","import { z } from 'zod';\nimport {\n type ConditionId,\n ConditionIdSchema,\n type DecimalString,\n DecimalStringSchema,\n E6BigIntStringToDecimalStringSchema,\n EpochLikeToIsoDateTimeStringSchema,\n emptyStringToNull,\n type IsoDateTimeString,\n IsoDateTimeStringSchema,\n type QuestionId,\n QuestionIdSchema,\n type TxHash,\n TxHashSchema,\n toIsoDateTimeString,\n} from '../shared';\nimport { dataEnvelopeSchema } from './envelope';\n\n/** Lifecycle state of a market resolution. */\nexport enum ResolutionStatus {\n Initialized = 'initialized',\n Posed = 'posed',\n Proposed = 'proposed',\n Challenged = 'challenged',\n Reproposed = 'reproposed',\n Disputed = 'disputed',\n Active = 'active',\n Arbitration = 'arbitration',\n Resolved = 'resolved',\n}\n\nexport const ResolutionStatusSchema = z.enum(ResolutionStatus);\n\n/** Market structure associated with a condition-keyed resolution. */\nexport enum ResolutionMarketType {\n Binary = 'BINARY',\n IncrementalNegRisk = 'INCREMENTAL_NEGRISK',\n AtomicNegRisk = 'ATOMIC_NEGRISK',\n}\n\nexport const ResolutionMarketTypeSchema = z.enum(ResolutionMarketType);\n\n/** How a condition's final payout was obtained. */\nexport enum ResolutionSource {\n Reported = 'reported',\n Derived = 'derived',\n}\n\nexport const ResolutionSourceSchema = z.enum(ResolutionSource);\n\n/** Reporter family that supplied a condition's resolution. */\nexport enum ResolutionReporter {\n UmaOptimisticOracle = 'UMA_OO',\n Chainlink = 'CHAINLINK',\n Eoa = 'EOA',\n}\n\nexport const ResolutionReporterSchema = z.enum(ResolutionReporter);\n\n/** Basis for a resolution's earliest estimated settlement time. */\nexport enum ResolutionSettlementTimeBasis {\n ManagedProposalExpiration = 'managed_proposal_expiration',\n ProposalExpiration = 'proposal_expiration',\n Liveness = 'liveness',\n DvmRoundEstimate = 'dvm_round_estimate',\n}\n\nexport const ResolutionSettlementTimeBasisSchema = z.enum(\n ResolutionSettlementTimeBasis,\n);\n\nexport type Resolution = {\n /** Oracle question identifier, when the resolution has one. */\n questionId?: QuestionId;\n /** Market condition identifier, when selected by condition or event. */\n conditionId?: ConditionId;\n status: ResolutionStatus;\n /** Whether a managed proposal is in extended review. */\n extendedReview: boolean;\n /** Earliest estimated settlement time, not a deadline; may have elapsed. */\n expectedSettlementTime?: IsoDateTimeString;\n /** Estimate basis, omitted when unavailable. Voting estimates can roll to a later round. */\n settlementTimeBasis?: ResolutionSettlementTimeBasis;\n /** Whether the resolution was disputed at any point. */\n wasDisputed: boolean;\n /** Whether the question rules were updated after the question was posed. */\n questionRulesUpdated: boolean;\n /** First proposed oracle price, omitted until set. */\n proposedPrice?: DecimalString;\n /** Second proposed oracle price, omitted until set. */\n reproposedPrice?: DecimalString;\n /** Final oracle settlement price, omitted until set. */\n price?: DecimalString;\n /**\n * Transaction for the latest lifecycle event, or `null` when unavailable.\n * On UMA lifecycle rows, this can differ from the initial RequestPrice\n * transaction whose log index is retained in `logIndex`.\n */\n transactionHash: TxHash | null;\n /**\n * Initial RequestPrice log index on UMA lifecycle rows, or `null` when\n * unavailable. It need not belong to `transactionHash`.\n * Condition-resolution fallback rows instead carry their condition event's\n * log index and transaction hash.\n */\n logIndex: number | null;\n /** Latest lifecycle change as an ISO 8601 datetime. */\n lastUpdatedAt: IsoDateTimeString;\n marketType?: ResolutionMarketType;\n /** Per-outcome payout in collateral units per share. */\n payouts?: [outcome0: DecimalString, outcome1: DecimalString];\n resolutionSource?: ResolutionSource;\n reporter?: ResolutionReporter;\n wasArbitrated?: boolean;\n resolvedBlock?: number;\n resolvedAt?: IsoDateTimeString;\n};\n\nconst PayoutSchema = z\n .number()\n .int()\n .min(0)\n .transform(String)\n .pipe(E6BigIntStringToDecimalStringSchema);\n\nexport const ResolutionSchema = z\n .object({\n question_id: QuestionIdSchema.optional(),\n condition_id: ConditionIdSchema.optional(),\n status: ResolutionStatusSchema,\n extended_review: z.boolean(),\n expected_settlement_time: z.iso\n .datetime()\n .transform(toIsoDateTimeString)\n .optional(),\n settlement_time_basis: ResolutionSettlementTimeBasisSchema.optional(),\n was_disputed: z.boolean(),\n new_version_q: z.boolean(),\n proposed_price: DecimalStringSchema.optional(),\n reproposed_price: DecimalStringSchema.optional(),\n price: DecimalStringSchema.optional(),\n transaction_hash: z.preprocess(emptyStringToNull, TxHashSchema.nullable()),\n log_index: z.preprocess(\n emptyStringToNull,\n z.string().regex(/^\\d+$/).transform(Number).nullable(),\n ),\n last_update_timestamp: EpochLikeToIsoDateTimeStringSchema,\n market_type: ResolutionMarketTypeSchema.optional(),\n payouts: z.tuple([PayoutSchema, PayoutSchema]).optional(),\n resolution_source: ResolutionSourceSchema.optional(),\n reporter: ResolutionReporterSchema.optional(),\n was_arbitrated: z.boolean().optional(),\n resolved_block: z.number().int().min(0).optional(),\n resolved_at: IsoDateTimeStringSchema.optional(),\n })\n .transform((wire): Resolution => {\n const resolution: Resolution = {\n status: wire.status,\n extendedReview: wire.extended_review,\n wasDisputed: wire.was_disputed,\n questionRulesUpdated: wire.new_version_q,\n transactionHash: wire.transaction_hash,\n logIndex: wire.log_index,\n lastUpdatedAt: wire.last_update_timestamp,\n };\n\n if (wire.question_id !== undefined)\n resolution.questionId = wire.question_id;\n if (wire.condition_id !== undefined)\n resolution.conditionId = wire.condition_id;\n if (wire.expected_settlement_time !== undefined) {\n resolution.expectedSettlementTime = wire.expected_settlement_time;\n }\n if (wire.settlement_time_basis !== undefined) {\n resolution.settlementTimeBasis = wire.settlement_time_basis;\n }\n if (wire.proposed_price !== undefined && wire.proposed_price !== '69') {\n resolution.proposedPrice = wire.proposed_price;\n }\n if (wire.reproposed_price !== undefined && wire.reproposed_price !== '69') {\n resolution.reproposedPrice = wire.reproposed_price;\n }\n if (wire.price !== undefined && wire.price !== '69') {\n resolution.price = wire.price;\n }\n if (wire.market_type !== undefined)\n resolution.marketType = wire.market_type;\n if (wire.payouts !== undefined) resolution.payouts = wire.payouts;\n if (wire.resolution_source !== undefined) {\n resolution.resolutionSource = wire.resolution_source;\n }\n if (wire.reporter !== undefined) resolution.reporter = wire.reporter;\n if (wire.was_arbitrated !== undefined) {\n resolution.wasArbitrated = wire.was_arbitrated;\n }\n if (wire.resolved_block !== undefined) {\n resolution.resolvedBlock = wire.resolved_block;\n }\n if (wire.resolved_at !== undefined)\n resolution.resolvedAt = wire.resolved_at;\n\n return resolution;\n }) satisfies z.ZodType<Resolution>;\n\nexport const FetchResolutionsResponseSchema = dataEnvelopeSchema(\n z.array(ResolutionSchema),\n);\n\nexport type FetchResolutionsResponse = z.infer<\n typeof FetchResolutionsResponseSchema\n>;\n","import { z } from 'zod';\nimport {\n type ClobAssetId,\n ClobAssetIdSchema,\n type ConditionId,\n ConditionIdSchema,\n type DecimalString,\n type EventId,\n toDecimalString,\n toEventId,\n} from '../shared';\nimport { dataEnvelopeSchema } from './envelope';\n\n/** Contract family that issued an outcome asset. */\nexport enum TokenModule {\n V1Ctf = 'v1_ctf',\n Binary = 'binary',\n NegRisk = 'neg_risk',\n Combo = 'combo',\n}\n\nexport const TokenModuleSchema = z.enum(TokenModule);\n\n/** Reference facts and current settlement metadata for an outcome asset. */\nexport type TokenReference = {\n /** Decimal ERC-1155 identifier, including structured protocol v2 assets. */\n assetId: ClobAssetId;\n /** Market condition in its 32-byte representation. */\n conditionId: ConditionId;\n /** On-chain protocol v2 condition in its 32-byte form; null for v1 assets. */\n structuralConditionId: ConditionId | null;\n module: TokenModule;\n /** On-chain outcome slot; this can differ from the market's order-book slot. */\n outcomeIndex: number;\n /** Order-book token-list slot; null before registration or outside v1. */\n clobIndex: number | null;\n /** Outcome label, which can lag by up to a minute. */\n outcome: string | null;\n /** The other asset of a two-outcome condition; otherwise null. */\n oppositeAssetId: ClobAssetId | null;\n /** Whether an on-chain payout exists; this can lag by up to a minute. */\n resolved: boolean;\n /** Payout rate, including fractional split payouts; null while unresolved. */\n finalPrice: DecimalString | null;\n title: string | null;\n marketSlug: string | null;\n /** Market closure state, which can lag by up to a minute. */\n closed: boolean | null;\n negRisk: boolean | null;\n /** Identifier of the containing neg-risk structure. */\n negRiskMarketId: ConditionId | null;\n /** Market's question index within its neg-risk structure. */\n questionIndex: number | null;\n /** Lowest event ID associated with the market. */\n eventId: EventId | null;\n eventSlug: string | null;\n};\n\nconst DecimalAssetIdSchema = z\n .string()\n .regex(/^[0-9]{1,78}$/)\n .pipe(ClobAssetIdSchema);\nconst Bytes32ConditionIdSchema = z\n .string()\n .regex(/^0x[0-9a-fA-F]{64}$/)\n .pipe(ConditionIdSchema);\nconst Int16Schema = z.number().int().min(-32768).max(32767);\nconst Int32Schema = z.number().int().min(-2147483648).max(2147483647);\n\nexport const TokenReferenceSchema = z\n .object({\n token_id: DecimalAssetIdSchema,\n condition_id: Bytes32ConditionIdSchema,\n structural_condition_id: Bytes32ConditionIdSchema.nullable(),\n module: TokenModuleSchema,\n outcome_index: Int16Schema,\n clob_index: Int16Schema.nullable(),\n outcome: z.string().nullable(),\n opposite_token_id: DecimalAssetIdSchema.nullable(),\n resolved: z.boolean(),\n final_price: z\n .number()\n .transform((value) => toDecimalString(String(value)))\n .nullable(),\n title: z.string().nullable(),\n market_slug: z.string().nullable(),\n closed: z.boolean().nullable(),\n neg_risk: z.boolean().nullable(),\n neg_risk_market_id: Bytes32ConditionIdSchema.nullable(),\n question_index: Int32Schema.nullable(),\n event_id: Int32Schema.transform((value) =>\n toEventId(String(value)),\n ).nullable(),\n event_slug: z.string().nullable(),\n })\n .transform((row) => ({\n assetId: row.token_id,\n conditionId: row.condition_id,\n structuralConditionId: row.structural_condition_id,\n module: row.module,\n outcomeIndex: row.outcome_index,\n clobIndex: row.clob_index,\n outcome: row.outcome,\n oppositeAssetId: row.opposite_token_id,\n resolved: row.resolved,\n finalPrice: row.final_price,\n title: row.title,\n marketSlug: row.market_slug,\n closed: row.closed,\n negRisk: row.neg_risk,\n negRiskMarketId: row.neg_risk_market_id,\n questionIndex: row.question_index,\n eventId: row.event_id,\n eventSlug: row.event_slug,\n })) satisfies z.ZodType<TokenReference>;\n\nexport const FetchTokenReferencesResponseSchema = dataEnvelopeSchema(\n z.array(TokenReferenceSchema),\n);\nexport type FetchTokenReferencesResponse = z.infer<\n typeof FetchTokenReferencesResponseSchema\n>;\n"]}