@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 {b}from'../chunk-HOD4LKZU.js';import {ba,wa,Pa,Ea,Da,Qa,da,ea,aa,Ka,Ia,Ja,Oa,V as V$1,Y as Y$1,na}from'../chunk-2KNK5TP7.js';import {z as z$1}from'zod';import {expectHexString}from'@kuest/types';var f=(d=>(d.Buy="BUY",d.Sell="SELL",d))(f||{}),h=(d=>(d.Yes="YES",d.No="NO",d))(h||{}),k=(d=>(d.Confirm="CONFIRM",d.Decline="DECLINE",d))(k||{}),g=(E=>(E.Matched="MATCHED",E.Mined="MINED",E.Confirmed="CONFIRMED",E.Retrying="RETRYING",E.Failed="FAILED",E))(g||{}),O=(d=>(d.Notional="notional",d.Shares="shares",d))(O||{}),G=(t=>(t.AddressMismatch="ADDRESS_MISMATCH",t.AllowanceValidationFailed="ALLOWANCE_VALIDATION_FAILED",t.BalanceValidationFailed="BALANCE_VALIDATION_FAILED",t.ContradictoryLegs="CONTRADICTORY_LEGS",t.ExpiredRfq="EXPIRED_RFQ",t.InvalidAcceptance="INVALID_ACCEPTANCE",t.InvalidConfirmation="INVALID_CONFIRMATION",t.InvalidExecutionResult="INVALID_EXECUTION_RESULT",t.InvalidIdentity="INVALID_IDENTITY",t.InvalidMessage="INVALID_MESSAGE",t.InvalidOrderSide="INVALID_ORDER_SIDE",t.InvalidQuote="INVALID_QUOTE",t.InvalidRfq="INVALID_RFQ",t.InvalidRfqState="INVALID_RFQ_STATE",t.InvalidRole="INVALID_ROLE",t.InvalidSignature="INVALID_SIGNATURE",t.InvalidSignatureType="INVALID_SIGNATURE_TYPE",t.InternalError="INTERNAL_ERROR",t.LegMetadataUnavailable="LEG_METADATA_UNAVAILABLE",t.MakerAlreadyResponded="MAKER_ALREADY_RESPONDED",t.MakerDeclined="MAKER_DECLINED",t.MakerNotRequired="MAKER_NOT_REQUIRED",t.MakerQuoteLimited="MAKER_QUOTE_LIMITED",t.MissingMakerAddressInQuote="MISSING_MAKER_ADDRESS_IN_QUOTE",t.MissingMakerAmountInSignedOrder="MISSING_MAKER_AMOUNT_IN_SIGNED_ORDER",t.MissingMakerInSignedOrder="MISSING_MAKER_IN_SIGNED_ORDER",t.MissingQuoteId="MISSING_QUOTE_ID",t.MissingRfqId="MISSING_RFQ_ID",t.MissingSaltInSignedOrder="MISSING_SALT_IN_SIGNED_ORDER",t.MissingSignatureInSignedOrder="MISSING_SIGNATURE_IN_SIGNED_ORDER",t.MissingSignerAddressInQuote="MISSING_SIGNER_ADDRESS_IN_QUOTE",t.MissingSignerInSignedOrder="MISSING_SIGNER_IN_SIGNED_ORDER",t.MissingTakerAmountInSignedOrder="MISSING_TAKER_AMOUNT_IN_SIGNED_ORDER",t.MissingTimestampInSignedOrder="MISSING_TIMESTAMP_IN_SIGNED_ORDER",t.MissingTokenIdInSignedOrder="MISSING_TOKEN_ID_IN_SIGNED_ORDER",t.NoQuotes="NO_QUOTES",t.OrderSideOrTokenDoesNotMatchRequest="ORDER_SIDE_OR_TOKEN_DOES_NOT_MATCH_REQUEST",t.PreExecutionBalanceReservationFailed="PRE_EXECUTION_BALANCE_RESERVATION_FAILED",t.PriceE6NotPositive="PRICE_E6_NOT_POSITIVE",t.QuoteMismatch="QUOTE_MISMATCH",t.QuoteUnavailable="QUOTE_UNAVAILABLE",t.QuotedPriceAboveSafetyThreshold="QUOTED_PRICE_ABOVE_SAFETY_THRESHOLD",t.QuotedPriceOutOfRange="QUOTED_PRICE_OUT_OF_RANGE",t.RateLimited="RATE_LIMITED",t.RequestFailed="REQUEST_FAILED",t.ServiceUnavailable="SERVICE_UNAVAILABLE",t.SignedOrderMakerAmountNotPositive="SIGNED_ORDER_MAKER_AMOUNT_NOT_POSITIVE",t.SignedOrderMakerDoesNotMatchAuth="SIGNED_ORDER_MAKER_DOES_NOT_MATCH_AUTH",t.SignedOrderPriceWorseThanQuote="SIGNED_ORDER_PRICE_WORSE_THAN_QUOTE",t.SignedOrderSignatureTypeDoesNotMatchAuth="SIGNED_ORDER_SIGNATURE_TYPE_DOES_NOT_MATCH_AUTH",t.SignedOrderSignerDoesNotMatchAuth="SIGNED_ORDER_SIGNER_DOES_NOT_MATCH_AUTH",t.SignedOrderSizeDoesNotCoverQuote="SIGNED_ORDER_SIZE_DOES_NOT_COVER_QUOTE",t.SignedOrderTakerAmountNotPositive="SIGNED_ORDER_TAKER_AMOUNT_NOT_POSITIVE",t.SizeE6NotPositive="SIZE_E6_NOT_POSITIVE",t.SizeTooLarge="SIZE_TOO_LARGE",t.SubmissionWindowClosed="SUBMISSION_WINDOW_CLOSED",t.TradeSubmissionFailed="TRADE_SUBMISSION_FAILED",t.Unauthenticated="UNAUTHENTICATED",t.UnauthorizedRole="UNAUTHORIZED_ROLE",t.UnknownRfq="UNKNOWN_RFQ",t))(G||{}),D=z$1.enum(f),y=z$1.literal("YES"),V=z$1.enum(k),H=z$1.enum(g),W=z$1.string().transform(e=>e),Y=z$1.object({id:wa,condition_id:ba,position_ids:z$1.array(Ea),pending:z$1.boolean(),slug:z$1.string(),title:z$1.string(),outcomes:z$1.array(z$1.string()),outcome_prices:z$1.array(Pa),image:z$1.string(),volume:z$1.number(),tags:z$1.array(z$1.string())}).superRefine((e,N)=>{e.outcomes.length!==2&&N.addIssue({code:"custom",message:`Expected binary combo market outcomes, received ${e.outcomes.length}.`,path:["outcomes"]}),e.position_ids.length!==e.outcomes.length&&N.addIssue({code:"custom",message:"Expected position_ids and outcomes to have matching lengths.",path:["position_ids"]}),e.outcome_prices.length!==e.outcomes.length&&N.addIssue({code:"custom",message:"Expected outcome_prices and outcomes to have matching lengths.",path:["outcome_prices"]});}).transform(e=>({conditionId:e.condition_id,id:e.id,image:e.image,pending:e.pending,outcomes:{yes:{label:e.outcomes[0],positionId:e.position_ids[0],price:e.outcome_prices[0]},no:{label:e.outcomes[1],positionId:e.position_ids[1],price:e.outcome_prices[1]}},slug:e.slug,tags:e.tags,title:e.title,volume:e.volume})),fe=z$1.object({markets:z$1.array(Y),next_cursor:Da.nullish()}).transform(e=>({markets:e.markets,nextCursor:e.next_cursor??void 0})),X=z$1.discriminatedUnion("unit",[z$1.object({unit:z$1.literal("notional"),value_e6:Qa}),z$1.object({unit:z$1.literal("shares"),value_e6:Qa})]).transform(e=>({unit:e.unit,value:e.value_e6})),Z=(c=>(c.Auth="auth",c.QuoteRequest="RFQ_REQUEST",c.QuoteAck="ACK_RFQ_QUOTE",c.QuoteCancelAck="ACK_RFQ_QUOTE_CANCEL",c.ConfirmationRequest="RFQ_CONFIRMATION_REQUEST",c.ConfirmationAck="ACK_RFQ_CONFIRMATION_RESPONSE",c.ExecutionUpdate="RFQ_EXECUTION_UPDATE",c.Trade="RFQ_TRADE",c.Error="RFQ_ERROR",c))(Z||{}),j=z$1.object({type:z$1.literal("auth"),success:z$1.boolean(),address:da.optional(),role:z$1.string().optional(),error:z$1.string().optional()}),$=z$1.object({type:z$1.literal("RFQ_REQUEST"),rfq_id:Ia,requestor_public_id:Ka,leg_position_ids:z$1.array(Ea),condition_id:aa,yes_position_id:Ea,no_position_id:Ea,direction:D,side:y,requested_size:X,submission_deadline:ea}).transform(e=>({conditionId:e.condition_id,direction:e.direction,legPositionIds:e.leg_position_ids,noPositionId:e.no_position_id,requestorPublicId:e.requestor_public_id,requestedSize:e.requested_size,rfqId:e.rfq_id,side:e.side,submissionDeadline:e.submission_deadline,type:"quote_request",yesPositionId:e.yes_position_id})),J=z$1.object({type:z$1.literal("ACK_RFQ_QUOTE"),rfq_id:Ia,quote_id:Ja}).transform(e=>({quoteId:e.quote_id,rfqId:e.rfq_id,type:"quote_ack"})),w=z$1.object({type:z$1.literal("ACK_RFQ_QUOTE_CANCEL"),rfq_id:Ia,quote_id:Ja}).transform(e=>({quoteId:e.quote_id,rfqId:e.rfq_id,type:"quote_cancel_ack"})),K=z$1.object({type:z$1.literal("RFQ_CONFIRMATION_REQUEST"),rfq_id:Ia,quote_id:Ja,signer_address:da,maker_address:da,signature_type:b,leg_position_ids:z$1.array(Ea),condition_id:aa,yes_position_id:Ea,no_position_id:Ea,direction:D,side:y,fill_size_e6:Qa,price_e6:Qa,confirm_by:ea}).transform(e=>({conditionId:e.condition_id,confirmBy:e.confirm_by,direction:e.direction,fillSize:e.fill_size_e6,legPositionIds:e.leg_position_ids,makerAddress:e.maker_address,noPositionId:e.no_position_id,price:e.price_e6,quoteId:e.quote_id,rfqId:e.rfq_id,side:e.side,signatureType:e.signature_type,signerAddress:e.signer_address,type:"confirmation_request",yesPositionId:e.yes_position_id})),ee=z$1.object({type:z$1.literal("ACK_RFQ_CONFIRMATION_RESPONSE"),rfq_id:Ia,quote_id:Ja,decision:V}).transform(e=>({decision:e.decision,quoteId:e.quote_id,rfqId:e.rfq_id,type:"confirmation_ack"})),te=z$1.object({type:z$1.literal("RFQ_EXECUTION_UPDATE"),rfq_id:Ia,status:H,tx_hash:Oa.optional()}).transform(e=>({rfqId:e.rfq_id,status:e.status,...e.tx_hash===void 0?{}:{txHash:e.tx_hash},type:"execution_update"})),ie=z$1.object({type:z$1.literal("RFQ_TRADE"),rfq_id:Ia,requester_id:Ka,condition_id:aa,leg_position_ids:z$1.array(Ea),direction:D,side:y,price_e6:Qa,size_e6:Qa,executed_at:ea}).transform(e=>({conditionId:e.condition_id,direction:e.direction,executedAt:e.executed_at,legPositionIds:e.leg_position_ids,price:e.price_e6,requesterId:e.requester_id,rfqId:e.rfq_id,side:e.side,size:e.size_e6,type:"trade"})),oe=z$1.object({type:z$1.literal("RFQ_ERROR"),error_id:z$1.string().optional(),request_type:z$1.string().optional(),rfq_id:Ia.optional(),quote_id:Ja.optional(),code:W,error:z$1.string(),request:z$1.unknown().optional()}).transform(e=>({code:e.code,errorId:e.error_id,message:e.error,quoteId:e.quote_id,requestType:e.request_type,rfqId:e.rfq_id,type:"rfq_error"})),ge=z$1.discriminatedUnion("type",[j,$,J,w,K,ee,te,ie,oe]);var B=(S=>(S.AwaitingRequesterAcceptance="AWAITING_REQUESTER_ACCEPTANCE",S.AwaitingMakerConfirmation="AWAITING_MAKER_CONFIRMATION",S.Executing="EXECUTING",S.Filled="FILLED",S.Failed="FAILED",S.Expired="EXPIRED",S.Canceled="CANCELED",S))(B||{}),ne=(o=>(o.InvalidJson="INVALID_JSON",o.InvalidMessage="INVALID_MESSAGE",o.InvalidRole="INVALID_ROLE",o.UnauthorizedRole="UNAUTHORIZED_ROLE",o.Unauthenticated="UNAUTHENTICATED",o.AddressMismatch="ADDRESS_MISMATCH",o.InvalidRfq="INVALID_RFQ",o.ContradictoryLegs="CONTRADICTORY_LEGS",o.LegMetadataUnavailable="LEG_METADATA_UNAVAILABLE",o.InvalidAcceptance="INVALID_ACCEPTANCE",o.InvalidQuote="INVALID_QUOTE",o.InvalidSignature="INVALID_SIGNATURE",o.InvalidIdentity="INVALID_IDENTITY",o.UnknownRfq="UNKNOWN_RFQ",o.ExpiredRfq="EXPIRED_RFQ",o.InvalidRfqState="INVALID_RFQ_STATE",o.QuoteMismatch="QUOTE_MISMATCH",o.SubmissionWindowClosed="SUBMISSION_WINDOW_CLOSED",o.ServiceUnavailable="SERVICE_UNAVAILABLE",o.PreExecutionBalanceReservationFailed="PRE_EXECUTION_BALANCE_RESERVATION_FAILED",o.BalanceValidationFailed="BALANCE_VALIDATION_FAILED",o.AllowanceValidationFailed="ALLOWANCE_VALIDATION_FAILED",o.TradeSubmissionFailed="TRADE_SUBMISSION_FAILED",o.RequestFailed="REQUEST_FAILED",o))(ne||{}),re=(d=>(d.NoQuotes="NO_QUOTES",d.SizeTooLarge="SIZE_TOO_LARGE",d))(re||{}),se=(q=>(q.MakerDeclined="MAKER_DECLINED",q.AcceptanceWindowExpired="ACCEPTANCE_WINDOW_EXPIRED",q.ExecutionFailed="EXECUTION_FAILED",q))(se||{}),F=z$1.object({code:z$1.string().transform(e=>e),message:z$1.string()}).transform(e=>({code:e.code,message:e.message})),ae=z$1.object({quote_id:Ja,blended_price_e6:Qa,maker_amount_e6:Qa,taker_amount_e6:Qa,total_required_e6:Qa,net_receive_e6:Qa.optional()}).transform(e=>({blendedPrice:e.blended_price_e6,makerAmount:e.maker_amount_e6,quoteId:e.quote_id,takerAmount:e.taker_amount_e6,totalRequired:e.total_required_e6,...e.net_receive_e6===void 0?{}:{netReceive:e.net_receive_e6}})),de=z$1.object({unit:z$1.enum(O),value_e6:z$1.string().regex(/^\d+$/).transform(e=>V$1(BigInt(e).toString()))}).transform(e=>({unit:e.unit,valueE6:e.value_e6})),_e=z$1.object({rfq_id:Ia,leg_position_ids:z$1.array(Ea),condition_id:aa,yes_position_id:Ea,no_position_id:Ea,direction:z$1.enum(f),side:z$1.enum(h),requested_size:de}).transform(e=>({conditionId:e.condition_id,direction:e.direction,legPositionIds:e.leg_position_ids,noPositionId:e.no_position_id,requestedSize:e.requested_size,rfqId:e.rfq_id,side:e.side,yesPositionId:e.yes_position_id})),ue=z$1.object({rfq_id:Ia,status:z$1.literal("AWAITING_REQUESTER_ACCEPTANCE"),expires_at:ea,builder_code:Y$1,request:_e,quote:ae}).transform(e=>({builderCode:e.builder_code,expiresAt:e.expires_at,quote:e.quote,request:e.request,rfqId:e.rfq_id,status:e.status})),ce=z$1.object({rfq_id:Ia,status:z$1.enum(["FAILED","EXPIRED","CANCELED"]),error:F.optional()}).transform(e=>({rfqId:e.rfq_id,status:e.status,...e.error===void 0?{}:{error:e.error}})),Oe=z$1.union([ue,ce]),De=z$1.object({rfq_id:Ia,status:z$1.union([z$1.enum(B),z$1.enum(g)]),taker_order_hash:z$1.string().optional(),tx_hash:Oa.optional(),error:F.optional()}).transform(e=>({rfqId:e.rfq_id,status:e.status,...e.taker_order_hash===void 0?{}:{takerOrderHash:e.taker_order_hash},...e.tx_hash===void 0?{}:{txHash:e.tx_hash},...e.error===void 0?{}:{error:e.error}}));var x=z$1.string().transform(e=>expectHexString(e)),le=(u=>(u.Split="split",u.Merge="merge",u.Redeem="redeem",u.SplitOnCondition="split_on_condition",u.MergeOnCondition="merge_on_condition",u.SplitOnEvent="split_on_event",u.MergeOnEvent="merge_on_event",u.ConvertOnEvent="convert_on_event",u.Extract="extract",u.Inject="inject",u.ConvertToYesBasket="convert_to_yes_basket",u.MergeFromYesBasket="merge_from_yes_basket",u.Compress="compress",u))(le||{}),pe=z$1.string().transform(e=>e),Se=z$1.object({kind:pe,condition_id:aa.optional(),event_id:na.optional(),position_id:Ea.optional(),condition_index:z$1.number().int().nonnegative().optional().default(0),amount:Qa}).transform(e=>({amount:e.amount,conditionId:e.condition_id,conditionIndex:e.condition_index,eventId:e.event_id,kind:e.kind,positionId:e.position_id})),M=z$1.object({position_id:Ea,amount:Qa}).transform(e=>({amount:e.amount,positionId:e.position_id})),me=z$1.object({consumed:z$1.array(M),created:z$1.array(M)}).transform(e=>({consumed:e.consumed,created:e.created})),z=z$1.object({to:da,data:x}).transform(e=>({data:e.data,to:e.to})),Qe=z$1.looseObject({planHash:x,chainId:z$1.number().int(),wallet:da,routerCall:z}),Le=z$1.object({plan_hash:x,chain_id:z$1.number().int(),wallet:da,block_number:z$1.string().regex(/^\d+$/).transform(BigInt),starting_pusd:Pa,net_pusd_out:Pa,final_pusd:Pa,operations:z$1.array(Se),operation_count:z$1.number().int(),truncated:z$1.boolean(),estimated_cost:z$1.number(),required_pusd_input:Pa,required_positions:z$1.array(M),position_summary:me.optional(),candidate_position_ids:z$1.array(Ea),router_call:z}).transform(e=>({blockNumber:e.block_number,candidatePositionIds:e.candidate_position_ids,chainId:e.chain_id,estimatedCost:e.estimated_cost,finalPusd:e.final_pusd,netPusdOut:e.net_pusd_out,operationCount:e.operation_count,operations:e.operations,planHash:e.plan_hash,positionSummary:e.position_summary??{consumed:[],created:[]},requiredPositions:e.required_positions,requiredPusdInput:e.required_pusd_input,routerCall:e.router_call,startingPusd:e.starting_pusd,truncated:e.truncated,wallet:e.wallet}));export{Oe as BuilderRfqCreateResponseSchema,De as BuilderRfqStatusResponseSchema,le as CollateralReturnKnownOperationKind,Le as CollateralReturnPlanResponseSchema,Qe as CollateralReturnPlanSchema,se as ComboAcceptFailureReason,re as ComboQuoteUnavailableReason,fe as ListComboMarketsResponseSchema,k as RfqConfirmationDecision,f as RfqDirection,g as RfqExecutionStatus,G as RfqKnownErrorCode,Z as RfqKnownInboundType,ge as RfqQuoterInboundMessageSchema,ne as RfqRejectionCode,O as RfqRequestedSizeUnit,h as RfqSide,B as RfqStatus};//# sourceMappingURL=index.js.map
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/combos/rfq.ts","../../src/combos/builder-rfq.ts","../../src/combos/plan.ts"],"names":["RfqDirection","RfqSide","RfqConfirmationDecision","RfqExecutionStatus","RfqRequestedSizeUnit","RfqKnownErrorCode","RfqDirectionSchema","z","RfqSideSchema","RfqConfirmationDecisionSchema","RfqExecutionStatusSchema","RfqErrorCodeSchema","value","ComboMarketSchema","MarketIdSchema","ConditionIdSchema","PositionIdSchema","DecimalStringSchema","market","context","ListComboMarketsResponseSchema","PaginationCursorSchema","response","RfqRequestedSizeSchema","E6BigIntStringToDecimalStringSchema","size","RfqKnownInboundType","RfqAuthResponseMessageSchema","EvmAddressSchema","RfqQuoteRequestSchema","RfqIdSchema","RfqRequestorPublicIdSchema","ComboConditionIdSchema","EpochMillisecondsSchema","message","RfqQuoteAckSchema","RfqQuoteIdSchema","RfqQuoteCancelAckSchema","RfqConfirmationRequestSchema","SignatureTypeSchema","RfqConfirmationAckSchema","RfqExecutionUpdateSchema","TxHashSchema","RfqTradeSchema","RfqErrorMessageSchema","RfqQuoterInboundMessageSchema","RfqStatus","RfqRejectionCode","ComboQuoteUnavailableReason","ComboAcceptFailureReason","BuilderRfqErrorSchema","error","BuilderRfqQuoteSchema","quote","BuilderRfqResponseRequestedSizeSchema","toBaseUnits","BuilderRfqResponseRequestSchema","request","BuilderRfqQuoteReadyResponseSchema","BuilderCodeSchema","BuilderRfqFinalStateResponseSchema","BuilderRfqCreateResponseSchema","BuilderRfqStatusResponseSchema","HexStringSchema","expectHexString","CollateralReturnKnownOperationKind","CollateralReturnOperationKindSchema","CollateralReturnOperationSchema","EventIdSchema","operation","CollateralReturnPositionAmountSchema","position","CollateralReturnPositionSummarySchema","summary","CollateralReturnRouterCallSchema","call","CollateralReturnPlanSchema","CollateralReturnPlanResponseSchema"],"mappings":"0MAwCO,IAAKA,CAAAA,CAAAA,CAAAA,CAAAA,GACVA,CAAAA,CAAA,GAAA,CAAM,KAAA,CACNA,EAAA,IAAA,CAAO,MAAA,CAFGA,CAAAA,CAAAA,EAAAA,CAAAA,EAAA,EAAA,CAAA,CAKAC,CAAAA,CAAAA,CAAAA,CAAAA,GACVA,CAAAA,CAAA,GAAA,CAAM,KAAA,CACNA,CAAAA,CAAA,EAAA,CAAK,IAAA,CAFKA,CAAAA,CAAAA,EAAAA,CAAAA,EAAA,EAAA,CAAA,CAKAC,CAAAA,CAAAA,CAAAA,CAAAA,GACVA,EAAA,OAAA,CAAU,SAAA,CACVA,CAAAA,CAAA,OAAA,CAAU,SAAA,CAFAA,CAAAA,CAAAA,EAAAA,CAAAA,EAAA,IAKAC,CAAAA,CAAAA,CAAAA,CAAAA,GACVA,CAAAA,CAAA,OAAA,CAAU,SAAA,CACVA,CAAAA,CAAA,KAAA,CAAQ,QACRA,CAAAA,CAAA,SAAA,CAAY,WAAA,CACZA,CAAAA,CAAA,QAAA,CAAW,UAAA,CACXA,CAAAA,CAAA,MAAA,CAAS,QAAA,CALCA,CAAAA,CAAAA,EAAAA,CAAAA,EAAA,EAAA,CAAA,CAQAC,CAAAA,CAAAA,CAAAA,CAAAA,GACVA,CAAAA,CAAA,QAAA,CAAW,WACXA,CAAAA,CAAA,MAAA,CAAS,QAAA,CAFCA,CAAAA,CAAAA,EAAAA,CAAAA,EAAA,EAAA,CAAA,CAKAC,CAAAA,CAAAA,CAAAA,CAAAA,GACVA,EAAA,eAAA,CAAkB,kBAAA,CAClBA,CAAAA,CAAA,yBAAA,C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ACrB,cAAA,CAAgBA,GAAAA,CAAE,MAAA,EAAO,CACzB,mBAAA,CAAqBU,GACrB,kBAAA,CAAoBV,GAAAA,CAAE,KAAA,CAAM+D,CAAoC,CAAA,CAEhE,gBAAA,CAAkBE,GAAsC,QAAA,EAAS,CACjE,sBAAA,CAAwBjE,GAAAA,CAAE,KAAA,CAAMS,EAAgB,CAAA,CAChD,WAAA,CAAa0D,CACf,CAAC,CAAA,CACA,SAAA,CACEpD,CAAAA,GAA4C,CAC3C,YAAaA,CAAAA,CAAS,YAAA,CACtB,oBAAA,CAAsBA,CAAAA,CAAS,sBAAA,CAC/B,OAAA,CAASA,EAAS,QAAA,CAClB,aAAA,CAAeA,CAAAA,CAAS,cAAA,CACxB,SAAA,CAAWA,CAAAA,CAAS,WACpB,UAAA,CAAYA,CAAAA,CAAS,YAAA,CACrB,cAAA,CAAgBA,CAAAA,CAAS,eAAA,CACzB,UAAA,CAAYA,CAAAA,CAAS,UAAA,CACrB,QAAA,CAAUA,CAAAA,CAAS,SAAA,CACnB,eAAA,CAAiBA,CAAAA,CAAS,kBAAoB,CAC5C,QAAA,CAAU,EAAC,CACX,OAAA,CAAS,EACX,CAAA,CACA,iBAAA,CAAmBA,CAAAA,CAAS,kBAAA,CAC5B,iBAAA,CAAmBA,CAAAA,CAAS,oBAC5B,UAAA,CAAYA,CAAAA,CAAS,WAAA,CACrB,YAAA,CAAcA,CAAAA,CAAS,aAAA,CACvB,SAAA,CAAWA,CAAAA,CAAS,SAAA,CACpB,MAAA,CAAQA,CAAAA,CAAS,MACnB,CAAA,CACF","file":"index.js","sourcesContent":["import type { Erc1271Signature, EvmSignature, HexString } from '@kuest/types';\nimport { z } from 'zod';\nimport {\n type SignatureType,\n SignatureTypeSchema,\n} from '../clob/signature-type';\nimport type {\n BaseUnits,\n ConditionId,\n DecimalString,\n EvmAddress,\n MarketId,\n TokenId,\n} from '../shared';\nimport {\n ComboConditionIdSchema,\n ConditionIdSchema,\n DecimalStringSchema,\n E6BigIntStringToDecimalStringSchema,\n EpochMillisecondsSchema,\n EvmAddressSchema,\n MarketIdSchema,\n type OrderSide,\n PaginationCursorSchema,\n type PositionId,\n PositionIdSchema,\n type RfqId,\n RfqIdSchema,\n type RfqQuoteId,\n RfqQuoteIdSchema,\n RfqRequestorPublicIdSchema,\n TxHashSchema,\n} from '../shared';\n\nexport type {\n RfqId,\n RfqQuoteId,\n RfqRequestorPublicId,\n} from '../shared';\n\nexport enum RfqDirection {\n Buy = 'BUY',\n Sell = 'SELL',\n}\n\nexport enum RfqSide {\n Yes = 'YES',\n No = 'NO',\n}\n\nexport enum RfqConfirmationDecision {\n Confirm = 'CONFIRM',\n Decline = 'DECLINE',\n}\n\nexport enum RfqExecutionStatus {\n Matched = 'MATCHED',\n Mined = 'MINED',\n Confirmed = 'CONFIRMED',\n Retrying = 'RETRYING',\n Failed = 'FAILED',\n}\n\nexport enum RfqRequestedSizeUnit {\n Notional = 'notional',\n Shares = 'shares',\n}\n\nexport enum RfqKnownErrorCode {\n AddressMismatch = 'ADDRESS_MISMATCH',\n AllowanceValidationFailed = 'ALLOWANCE_VALIDATION_FAILED',\n BalanceValidationFailed = 'BALANCE_VALIDATION_FAILED',\n ContradictoryLegs = 'CONTRADICTORY_LEGS',\n ExpiredRfq = 'EXPIRED_RFQ',\n InvalidAcceptance = 'INVALID_ACCEPTANCE',\n InvalidConfirmation = 'INVALID_CONFIRMATION',\n InvalidExecutionResult = 'INVALID_EXECUTION_RESULT',\n InvalidIdentity = 'INVALID_IDENTITY',\n InvalidMessage = 'INVALID_MESSAGE',\n InvalidOrderSide = 'INVALID_ORDER_SIDE',\n InvalidQuote = 'INVALID_QUOTE',\n InvalidRfq = 'INVALID_RFQ',\n InvalidRfqState = 'INVALID_RFQ_STATE',\n InvalidRole = 'INVALID_ROLE',\n InvalidSignature = 'INVALID_SIGNATURE',\n InvalidSignatureType = 'INVALID_SIGNATURE_TYPE',\n InternalError = 'INTERNAL_ERROR',\n LegMetadataUnavailable = 'LEG_METADATA_UNAVAILABLE',\n MakerAlreadyResponded = 'MAKER_ALREADY_RESPONDED',\n MakerDeclined = 'MAKER_DECLINED',\n MakerNotRequired = 'MAKER_NOT_REQUIRED',\n MakerQuoteLimited = 'MAKER_QUOTE_LIMITED',\n MissingMakerAddressInQuote = 'MISSING_MAKER_ADDRESS_IN_QUOTE',\n MissingMakerAmountInSignedOrder = 'MISSING_MAKER_AMOUNT_IN_SIGNED_ORDER',\n MissingMakerInSignedOrder = 'MISSING_MAKER_IN_SIGNED_ORDER',\n MissingQuoteId = 'MISSING_QUOTE_ID',\n MissingRfqId = 'MISSING_RFQ_ID',\n MissingSaltInSignedOrder = 'MISSING_SALT_IN_SIGNED_ORDER',\n MissingSignatureInSignedOrder = 'MISSING_SIGNATURE_IN_SIGNED_ORDER',\n MissingSignerAddressInQuote = 'MISSING_SIGNER_ADDRESS_IN_QUOTE',\n MissingSignerInSignedOrder = 'MISSING_SIGNER_IN_SIGNED_ORDER',\n MissingTakerAmountInSignedOrder = 'MISSING_TAKER_AMOUNT_IN_SIGNED_ORDER',\n MissingTimestampInSignedOrder = 'MISSING_TIMESTAMP_IN_SIGNED_ORDER',\n MissingTokenIdInSignedOrder = 'MISSING_TOKEN_ID_IN_SIGNED_ORDER',\n NoQuotes = 'NO_QUOTES',\n OrderSideOrTokenDoesNotMatchRequest = 'ORDER_SIDE_OR_TOKEN_DOES_NOT_MATCH_REQUEST',\n PreExecutionBalanceReservationFailed = 'PRE_EXECUTION_BALANCE_RESERVATION_FAILED',\n PriceE6NotPositive = 'PRICE_E6_NOT_POSITIVE',\n QuoteMismatch = 'QUOTE_MISMATCH',\n QuoteUnavailable = 'QUOTE_UNAVAILABLE',\n QuotedPriceAboveSafetyThreshold = 'QUOTED_PRICE_ABOVE_SAFETY_THRESHOLD',\n QuotedPriceOutOfRange = 'QUOTED_PRICE_OUT_OF_RANGE',\n RateLimited = 'RATE_LIMITED',\n RequestFailed = 'REQUEST_FAILED',\n ServiceUnavailable = 'SERVICE_UNAVAILABLE',\n SignedOrderMakerAmountNotPositive = 'SIGNED_ORDER_MAKER_AMOUNT_NOT_POSITIVE',\n SignedOrderMakerDoesNotMatchAuth = 'SIGNED_ORDER_MAKER_DOES_NOT_MATCH_AUTH',\n SignedOrderPriceWorseThanQuote = 'SIGNED_ORDER_PRICE_WORSE_THAN_QUOTE',\n SignedOrderSignatureTypeDoesNotMatchAuth = 'SIGNED_ORDER_SIGNATURE_TYPE_DOES_NOT_MATCH_AUTH',\n SignedOrderSignerDoesNotMatchAuth = 'SIGNED_ORDER_SIGNER_DOES_NOT_MATCH_AUTH',\n SignedOrderSizeDoesNotCoverQuote = 'SIGNED_ORDER_SIZE_DOES_NOT_COVER_QUOTE',\n SignedOrderTakerAmountNotPositive = 'SIGNED_ORDER_TAKER_AMOUNT_NOT_POSITIVE',\n SizeE6NotPositive = 'SIZE_E6_NOT_POSITIVE',\n SizeTooLarge = 'SIZE_TOO_LARGE',\n SubmissionWindowClosed = 'SUBMISSION_WINDOW_CLOSED',\n TradeSubmissionFailed = 'TRADE_SUBMISSION_FAILED',\n Unauthenticated = 'UNAUTHENTICATED',\n UnauthorizedRole = 'UNAUTHORIZED_ROLE',\n UnknownRfq = 'UNKNOWN_RFQ',\n}\n\n/**\n * An RFQ error code. Known codes are enumerated in {@link RfqKnownErrorCode};\n * newly introduced codes flow through as plain strings so they can be handled\n * before a client release that enumerates them.\n */\nexport type RfqErrorCode = RfqKnownErrorCode | (string & {});\n\nconst RfqDirectionSchema = z.enum(RfqDirection);\nconst RfqSideSchema = z.literal(RfqSide.Yes);\nconst RfqConfirmationDecisionSchema = z.enum(RfqConfirmationDecision);\nconst RfqExecutionStatusSchema = z.enum(RfqExecutionStatus);\n\n// Error codes evolve independently of released clients. Codes not yet\n// enumerated in RfqKnownErrorCode must still parse and flow through as-is.\nconst RfqErrorCodeSchema = z.string().transform((value): RfqErrorCode => value);\n\nexport type ComboMarket = {\n id: MarketId;\n conditionId: ConditionId;\n /** Whether Combo enablement is still pending for this market. */\n pending: boolean;\n slug: string;\n title: string;\n outcomes: ComboMarketOutcomes;\n image: string;\n volume: number;\n tags: string[];\n};\n\nexport type ComboMarketOutcome = {\n label: string;\n positionId: PositionId;\n price: DecimalString;\n};\n\nexport type ComboMarketOutcomes = {\n yes: ComboMarketOutcome;\n no: ComboMarketOutcome;\n};\n\nconst ComboMarketSchema = z\n .object({\n id: MarketIdSchema,\n condition_id: ConditionIdSchema,\n position_ids: z.array(PositionIdSchema),\n pending: z.boolean(),\n slug: z.string(),\n title: z.string(),\n outcomes: z.array(z.string()),\n outcome_prices: z.array(DecimalStringSchema),\n image: z.string(),\n volume: z.number(),\n tags: z.array(z.string()),\n })\n .superRefine((market, context) => {\n if (market.outcomes.length !== 2) {\n context.addIssue({\n code: 'custom',\n message: `Expected binary combo market outcomes, received ${market.outcomes.length}.`,\n path: ['outcomes'],\n });\n }\n\n if (market.position_ids.length !== market.outcomes.length) {\n context.addIssue({\n code: 'custom',\n message: 'Expected position_ids and outcomes to have matching lengths.',\n path: ['position_ids'],\n });\n }\n\n if (market.outcome_prices.length !== market.outcomes.length) {\n context.addIssue({\n code: 'custom',\n message:\n 'Expected outcome_prices and outcomes to have matching lengths.',\n path: ['outcome_prices'],\n });\n }\n })\n .transform(\n (market): ComboMarket => ({\n conditionId: market.condition_id,\n id: market.id,\n image: market.image,\n pending: market.pending,\n outcomes: {\n yes: {\n label: market.outcomes[0] as string,\n positionId: market.position_ids[0] as PositionId,\n price: market.outcome_prices[0] as DecimalString,\n },\n no: {\n label: market.outcomes[1] as string,\n positionId: market.position_ids[1] as PositionId,\n price: market.outcome_prices[1] as DecimalString,\n },\n },\n slug: market.slug,\n tags: market.tags,\n title: market.title,\n volume: market.volume,\n }),\n );\n\nexport const ListComboMarketsResponseSchema = z\n .object({\n markets: z.array(ComboMarketSchema),\n next_cursor: PaginationCursorSchema.nullish(),\n })\n .transform((response) => ({\n markets: response.markets,\n nextCursor: response.next_cursor ?? undefined,\n }));\n\nexport type ListComboMarketsResponse = z.infer<\n typeof ListComboMarketsResponseSchema\n>;\n\nexport type RfqRequestedSize =\n | {\n unit: RfqRequestedSizeUnit.Notional;\n value: DecimalString;\n }\n | {\n unit: RfqRequestedSizeUnit.Shares;\n value: DecimalString;\n };\n\nconst RfqRequestedSizeSchema = z\n .discriminatedUnion('unit', [\n z.object({\n unit: z.literal(RfqRequestedSizeUnit.Notional),\n value_e6: E6BigIntStringToDecimalStringSchema,\n }),\n z.object({\n unit: z.literal(RfqRequestedSizeUnit.Shares),\n value_e6: E6BigIntStringToDecimalStringSchema,\n }),\n ])\n .transform(\n (size): RfqRequestedSize => ({\n unit: size.unit,\n value: size.value_e6,\n }),\n ) satisfies z.ZodType<RfqRequestedSize>;\n\nexport type RfqSignedOrder = {\n salt: string;\n maker: EvmAddress;\n signer: EvmAddress;\n tokenId: PositionId | TokenId;\n makerAmount: BaseUnits;\n takerAmount: BaseUnits;\n side: RfqOrderSide;\n signatureType: SignatureType;\n timestamp: string;\n builder?: HexString;\n expiration?: string;\n metadata?: HexString;\n signature: EvmSignature | Erc1271Signature;\n};\n\nexport type RfqOrderSide = OrderSide | 0 | 1;\n\nexport type RfqAuthMessage = {\n type: 'auth';\n auth: {\n apiKey: string;\n passphrase: string;\n secret: string;\n };\n identity: {\n signer_address: EvmAddress;\n maker_address: EvmAddress;\n signature_type: SignatureType;\n };\n};\n\nexport enum RfqKnownInboundType {\n Auth = 'auth',\n QuoteRequest = 'RFQ_REQUEST',\n QuoteAck = 'ACK_RFQ_QUOTE',\n QuoteCancelAck = 'ACK_RFQ_QUOTE_CANCEL',\n ConfirmationRequest = 'RFQ_CONFIRMATION_REQUEST',\n ConfirmationAck = 'ACK_RFQ_CONFIRMATION_RESPONSE',\n ExecutionUpdate = 'RFQ_EXECUTION_UPDATE',\n Trade = 'RFQ_TRADE',\n Error = 'RFQ_ERROR',\n}\n\nconst RfqAuthResponseMessageSchema = z.object({\n type: z.literal(RfqKnownInboundType.Auth),\n success: z.boolean(),\n address: EvmAddressSchema.optional(),\n role: z.string().optional(),\n error: z.string().optional(),\n});\n\nexport type RfqAuthResponseMessage = z.infer<\n typeof RfqAuthResponseMessageSchema\n>;\n\nconst RfqQuoteRequestSchema = z\n .object({\n type: z.literal(RfqKnownInboundType.QuoteRequest),\n rfq_id: RfqIdSchema,\n requestor_public_id: RfqRequestorPublicIdSchema,\n leg_position_ids: z.array(PositionIdSchema),\n condition_id: ComboConditionIdSchema,\n yes_position_id: PositionIdSchema,\n no_position_id: PositionIdSchema,\n direction: RfqDirectionSchema,\n side: RfqSideSchema,\n requested_size: RfqRequestedSizeSchema,\n submission_deadline: EpochMillisecondsSchema,\n })\n .transform((message) => ({\n conditionId: message.condition_id,\n direction: message.direction,\n legPositionIds: message.leg_position_ids,\n noPositionId: message.no_position_id,\n requestorPublicId: message.requestor_public_id,\n requestedSize: message.requested_size,\n rfqId: message.rfq_id,\n side: message.side,\n submissionDeadline: message.submission_deadline,\n type: 'quote_request' as const,\n yesPositionId: message.yes_position_id,\n }));\n\nexport type RfqQuoteRequest = z.infer<typeof RfqQuoteRequestSchema>;\n\nexport type RfqQuoteMessage = {\n type: 'RFQ_QUOTE';\n rfq_id: RfqId;\n price_e6: string;\n size_e6: string;\n signed_order: RfqSignedOrder;\n};\n\nexport type RfqQuoteCancelMessage = {\n type: 'RFQ_QUOTE_CANCEL';\n rfq_id: RfqId;\n quote_id: RfqQuoteId;\n signer_address: EvmAddress;\n maker_address: EvmAddress;\n};\n\nconst RfqQuoteAckSchema = z\n .object({\n type: z.literal(RfqKnownInboundType.QuoteAck),\n rfq_id: RfqIdSchema,\n quote_id: RfqQuoteIdSchema,\n })\n .transform((message) => ({\n quoteId: message.quote_id,\n rfqId: message.rfq_id,\n type: 'quote_ack' as const,\n }));\n\nexport type RfqQuoteAck = z.infer<typeof RfqQuoteAckSchema>;\n\nconst RfqQuoteCancelAckSchema = z\n .object({\n type: z.literal(RfqKnownInboundType.QuoteCancelAck),\n rfq_id: RfqIdSchema,\n quote_id: RfqQuoteIdSchema,\n })\n .transform((message) => ({\n quoteId: message.quote_id,\n rfqId: message.rfq_id,\n type: 'quote_cancel_ack' as const,\n }));\n\nexport type RfqQuoteCancelAck = z.infer<typeof RfqQuoteCancelAckSchema>;\n\nconst RfqConfirmationRequestSchema = z\n .object({\n type: z.literal(RfqKnownInboundType.ConfirmationRequest),\n rfq_id: RfqIdSchema,\n quote_id: RfqQuoteIdSchema,\n signer_address: EvmAddressSchema,\n maker_address: EvmAddressSchema,\n signature_type: SignatureTypeSchema,\n leg_position_ids: z.array(PositionIdSchema),\n condition_id: ComboConditionIdSchema,\n yes_position_id: PositionIdSchema,\n no_position_id: PositionIdSchema,\n direction: RfqDirectionSchema,\n side: RfqSideSchema,\n fill_size_e6: E6BigIntStringToDecimalStringSchema,\n price_e6: E6BigIntStringToDecimalStringSchema,\n confirm_by: EpochMillisecondsSchema,\n })\n .transform((message) => ({\n conditionId: message.condition_id,\n confirmBy: message.confirm_by,\n direction: message.direction,\n fillSize: message.fill_size_e6,\n legPositionIds: message.leg_position_ids,\n makerAddress: message.maker_address,\n noPositionId: message.no_position_id,\n price: message.price_e6,\n quoteId: message.quote_id,\n rfqId: message.rfq_id,\n side: message.side,\n signatureType: message.signature_type,\n signerAddress: message.signer_address,\n type: 'confirmation_request' as const,\n yesPositionId: message.yes_position_id,\n }));\n\nexport type RfqConfirmationRequest = z.infer<\n typeof RfqConfirmationRequestSchema\n>;\n\nexport type RfqConfirmationResponseMessage = {\n type: 'RFQ_CONFIRMATION_RESPONSE';\n rfq_id: RfqId;\n quote_id: RfqQuoteId;\n decision: RfqConfirmationDecision;\n};\n\nconst RfqConfirmationAckSchema = z\n .object({\n type: z.literal(RfqKnownInboundType.ConfirmationAck),\n rfq_id: RfqIdSchema,\n quote_id: RfqQuoteIdSchema,\n decision: RfqConfirmationDecisionSchema,\n })\n .transform((message) => ({\n decision: message.decision,\n quoteId: message.quote_id,\n rfqId: message.rfq_id,\n type: 'confirmation_ack' as const,\n }));\n\nexport type RfqConfirmationAck = z.infer<typeof RfqConfirmationAckSchema>;\n\nconst RfqExecutionUpdateSchema = z\n .object({\n type: z.literal(RfqKnownInboundType.ExecutionUpdate),\n rfq_id: RfqIdSchema,\n status: RfqExecutionStatusSchema,\n tx_hash: TxHashSchema.optional(),\n })\n .transform((message) => ({\n rfqId: message.rfq_id,\n status: message.status,\n ...(message.tx_hash === undefined ? {} : { txHash: message.tx_hash }),\n type: 'execution_update' as const,\n }));\n\nexport type RfqExecutionUpdate = z.infer<typeof RfqExecutionUpdateSchema>;\n\nconst RfqTradeSchema = z\n .object({\n type: z.literal(RfqKnownInboundType.Trade),\n rfq_id: RfqIdSchema,\n requester_id: RfqRequestorPublicIdSchema,\n condition_id: ComboConditionIdSchema,\n leg_position_ids: z.array(PositionIdSchema),\n direction: RfqDirectionSchema,\n side: RfqSideSchema,\n price_e6: E6BigIntStringToDecimalStringSchema,\n size_e6: E6BigIntStringToDecimalStringSchema,\n executed_at: EpochMillisecondsSchema,\n })\n .transform((message) => ({\n conditionId: message.condition_id,\n direction: message.direction,\n executedAt: message.executed_at,\n legPositionIds: message.leg_position_ids,\n price: message.price_e6,\n requesterId: message.requester_id,\n rfqId: message.rfq_id,\n side: message.side,\n size: message.size_e6,\n type: 'trade' as const,\n }));\n\nexport type RfqTrade = z.infer<typeof RfqTradeSchema>;\n\nconst RfqErrorMessageSchema = z\n .object({\n type: z.literal(RfqKnownInboundType.Error),\n error_id: z.string().optional(),\n request_type: z.string().optional(),\n rfq_id: RfqIdSchema.optional(),\n quote_id: RfqQuoteIdSchema.optional(),\n code: RfqErrorCodeSchema,\n error: z.string(),\n request: z.unknown().optional(),\n })\n .transform((message) => ({\n code: message.code,\n errorId: message.error_id,\n message: message.error,\n quoteId: message.quote_id,\n requestType: message.request_type,\n rfqId: message.rfq_id,\n type: 'rfq_error' as const,\n }));\n\nexport type RfqErrorMessage = z.infer<typeof RfqErrorMessageSchema>;\n\nexport const RfqQuoterInboundMessageSchema = z.discriminatedUnion('type', [\n RfqAuthResponseMessageSchema,\n RfqQuoteRequestSchema,\n RfqQuoteAckSchema,\n RfqQuoteCancelAckSchema,\n RfqConfirmationRequestSchema,\n RfqConfirmationAckSchema,\n RfqExecutionUpdateSchema,\n RfqTradeSchema,\n RfqErrorMessageSchema,\n]);\n\nexport type RfqQuoterInboundMessage = z.infer<\n typeof RfqQuoterInboundMessageSchema\n>;\n\nexport type RfqQuoterOutboundMessage =\n | RfqQuoteMessage\n | RfqQuoteCancelMessage\n | RfqConfirmationResponseMessage;\n","import { z } from 'zod';\nimport type { SignatureType } from '../clob/signature-type';\nimport type {\n BaseUnits,\n BuilderCode,\n ComboConditionId,\n DecimalString,\n EpochMilliseconds,\n EvmAddress,\n PositionId,\n RfqId,\n RfqQuoteId,\n TxHash,\n} from '../shared';\nimport {\n BuilderCodeSchema,\n ComboConditionIdSchema,\n E6BigIntStringToDecimalStringSchema,\n EpochMillisecondsSchema,\n PositionIdSchema,\n RfqIdSchema,\n RfqQuoteIdSchema,\n TxHashSchema,\n toBaseUnits,\n} from '../shared';\nimport {\n RfqDirection,\n type RfqErrorCode,\n RfqExecutionStatus,\n RfqRequestedSizeUnit,\n RfqSide,\n type RfqSignedOrder,\n} from './rfq';\n\n/** Lifecycle status of an RFQ. */\nexport enum RfqStatus {\n AwaitingRequesterAcceptance = 'AWAITING_REQUESTER_ACCEPTANCE',\n AwaitingMakerConfirmation = 'AWAITING_MAKER_CONFIRMATION',\n Executing = 'EXECUTING',\n Filled = 'FILLED',\n Failed = 'FAILED',\n Expired = 'EXPIRED',\n Canceled = 'CANCELED',\n}\n\n/**\n * Machine-readable reason an RFQ request or acceptance was rejected.\n *\n * @remarks\n * Codes not enumerated in this SDK release are classified as\n * {@link RfqRejectionCode.RequestFailed} with the original error preserved on\n * `cause`.\n */\nexport enum RfqRejectionCode {\n /** The request body could not be decoded as JSON. */\n InvalidJson = 'INVALID_JSON',\n /** The request message is malformed. */\n InvalidMessage = 'INVALID_MESSAGE',\n /** The authenticated role is not valid for this request. */\n InvalidRole = 'INVALID_ROLE',\n /** The authenticated role is not authorized for this request. */\n UnauthorizedRole = 'UNAUTHORIZED_ROLE',\n /** Authentication credentials are missing or invalid. */\n Unauthenticated = 'UNAUTHENTICATED',\n /** The authenticated address does not match the request. */\n AddressMismatch = 'ADDRESS_MISMATCH',\n /** The request is malformed or references invalid legs. */\n InvalidRfq = 'INVALID_RFQ',\n /** The legs are mutually exclusive (e.g. YES and NO on the same market). */\n ContradictoryLegs = 'CONTRADICTORY_LEGS',\n /** Leg metadata is temporarily unavailable; the request may be retried. */\n LegMetadataUnavailable = 'LEG_METADATA_UNAVAILABLE',\n /** The acceptance is invalid (unknown RFQ, wrong state, quote/builder mismatch). */\n InvalidAcceptance = 'INVALID_ACCEPTANCE',\n /** The referenced quote is invalid or no longer available. */\n InvalidQuote = 'INVALID_QUOTE',\n /** The order signature failed verification. */\n InvalidSignature = 'INVALID_SIGNATURE',\n /** The request identity is invalid. */\n InvalidIdentity = 'INVALID_IDENTITY',\n /** The RFQ does not exist for the authenticated requester. */\n UnknownRfq = 'UNKNOWN_RFQ',\n /** The RFQ acceptance window has expired. */\n ExpiredRfq = 'EXPIRED_RFQ',\n /** The RFQ is not in a state that permits this operation. */\n InvalidRfqState = 'INVALID_RFQ_STATE',\n /** The quote does not match the RFQ being accepted. */\n QuoteMismatch = 'QUOTE_MISMATCH',\n /** The submission window is closed. */\n SubmissionWindowClosed = 'SUBMISSION_WINDOW_CLOSED',\n /** A required service is temporarily unavailable. */\n ServiceUnavailable = 'SERVICE_UNAVAILABLE',\n /** Balance reservation failed before execution. */\n PreExecutionBalanceReservationFailed = 'PRE_EXECUTION_BALANCE_RESERVATION_FAILED',\n /** The requester does not have sufficient balance. */\n BalanceValidationFailed = 'BALANCE_VALIDATION_FAILED',\n /** The requester does not have sufficient allowance. */\n AllowanceValidationFailed = 'ALLOWANCE_VALIDATION_FAILED',\n /** The accepted trade could not be submitted for execution. */\n TradeSubmissionFailed = 'TRADE_SUBMISSION_FAILED',\n /** The request failed without a more specific classification. */\n RequestFailed = 'REQUEST_FAILED',\n}\n\n/** Reason no quote was returned for a combo quote request. */\nexport enum ComboQuoteUnavailableReason {\n NoQuotes = 'NO_QUOTES',\n SizeTooLarge = 'SIZE_TOO_LARGE',\n}\n\n/** Reason an accepted combo quote did not proceed to a fill. */\nexport enum ComboAcceptFailureReason {\n MakerDeclined = 'MAKER_DECLINED',\n AcceptanceWindowExpired = 'ACCEPTANCE_WINDOW_EXPIRED',\n /** The trade failed before or during onchain execution handoff. */\n ExecutionFailed = 'EXECUTION_FAILED',\n}\n\nexport type BuilderRfqRequestedSize = {\n unit: RfqRequestedSizeUnit;\n value_e6: string;\n};\n\nexport type BuilderRfqCreateRequest = {\n signer_address: EvmAddress;\n maker_address: EvmAddress;\n signature_type: SignatureType;\n leg_position_ids: string[];\n direction: RfqDirection;\n side: RfqSide;\n requested_size: BuilderRfqRequestedSize;\n};\n\nexport type BuilderRfqAcceptRequest = {\n quote_id: string;\n signed_order: RfqSignedOrder;\n};\n\n/** Structured error carried inside combo RFQ responses. */\nexport type BuilderRfqError = {\n code: RfqErrorCode;\n message: string;\n};\n\n// Error codes evolve independently of released clients. Codes not yet\n// enumerated in RfqKnownErrorCode must still parse and flow through as-is.\nconst BuilderRfqErrorSchema = z\n .object({\n code: z.string().transform((value): RfqErrorCode => value),\n message: z.string(),\n })\n .transform(\n (error): BuilderRfqError => ({\n code: error.code,\n message: error.message,\n }),\n );\n\n/** The winning quote for an RFQ. */\nexport type BuilderRfqQuote = {\n quoteId: RfqQuoteId;\n /** Blended price across legs, in collateral per outcome token. */\n blendedPrice: DecimalString;\n /** Signed-order collateral for BUY, or position shares for SELL. */\n makerAmount: DecimalString;\n /** Signed-order shares for BUY, or gross collateral limit for SELL. */\n takerAmount: DecimalString;\n /** Total collateral (BUY) or position-share (SELL) balance required to accept. */\n totalRequired: DecimalString;\n /** Exact collateral proceeds after fees. Present only for SELL quotes. */\n netReceive?: DecimalString;\n};\n\nconst BuilderRfqQuoteSchema = z\n .object({\n quote_id: RfqQuoteIdSchema,\n blended_price_e6: E6BigIntStringToDecimalStringSchema,\n maker_amount_e6: E6BigIntStringToDecimalStringSchema,\n taker_amount_e6: E6BigIntStringToDecimalStringSchema,\n total_required_e6: E6BigIntStringToDecimalStringSchema,\n net_receive_e6: E6BigIntStringToDecimalStringSchema.optional(),\n })\n .transform(\n (quote): BuilderRfqQuote => ({\n blendedPrice: quote.blended_price_e6,\n makerAmount: quote.maker_amount_e6,\n quoteId: quote.quote_id,\n takerAmount: quote.taker_amount_e6,\n totalRequired: quote.total_required_e6,\n ...(quote.net_receive_e6 === undefined\n ? {}\n : { netReceive: quote.net_receive_e6 }),\n }),\n );\n\nexport type BuilderRfqResponseRequestedSize = {\n unit: RfqRequestedSizeUnit;\n valueE6: BaseUnits;\n};\n\nconst BuilderRfqResponseRequestedSizeSchema = z\n .object({\n unit: z.enum(RfqRequestedSizeUnit),\n value_e6: z\n .string()\n .regex(/^\\d+$/)\n .transform((value) => toBaseUnits(BigInt(value).toString())),\n })\n .transform(\n (size): BuilderRfqResponseRequestedSize => ({\n unit: size.unit,\n valueE6: size.value_e6,\n }),\n );\n\n/** Original request echoed by a quote-ready builder RFQ response. */\nexport type BuilderRfqResponseRequest = {\n rfqId: RfqId;\n legPositionIds: PositionId[];\n conditionId: ComboConditionId;\n yesPositionId: PositionId;\n noPositionId: PositionId;\n direction: RfqDirection;\n side: RfqSide;\n requestedSize: BuilderRfqResponseRequestedSize;\n};\n\nconst BuilderRfqResponseRequestSchema = z\n .object({\n rfq_id: RfqIdSchema,\n leg_position_ids: z.array(PositionIdSchema),\n condition_id: ComboConditionIdSchema,\n yes_position_id: PositionIdSchema,\n no_position_id: PositionIdSchema,\n direction: z.enum(RfqDirection),\n side: z.enum(RfqSide),\n requested_size: BuilderRfqResponseRequestedSizeSchema,\n })\n .transform(\n (request): BuilderRfqResponseRequest => ({\n conditionId: request.condition_id,\n direction: request.direction,\n legPositionIds: request.leg_position_ids,\n noPositionId: request.no_position_id,\n requestedSize: request.requested_size,\n rfqId: request.rfq_id,\n side: request.side,\n yesPositionId: request.yes_position_id,\n }),\n );\n\nexport type BuilderRfqQuoteReadyResponse = {\n rfqId: RfqId;\n status: RfqStatus.AwaitingRequesterAcceptance;\n /** Acceptance deadline (Unix ms). */\n expiresAt: EpochMilliseconds;\n builderCode: BuilderCode;\n request: BuilderRfqResponseRequest;\n quote: BuilderRfqQuote;\n};\n\nconst BuilderRfqQuoteReadyResponseSchema = z\n .object({\n rfq_id: RfqIdSchema,\n status: z.literal(RfqStatus.AwaitingRequesterAcceptance),\n expires_at: EpochMillisecondsSchema,\n builder_code: BuilderCodeSchema,\n request: BuilderRfqResponseRequestSchema,\n quote: BuilderRfqQuoteSchema,\n })\n .transform(\n (response): BuilderRfqQuoteReadyResponse => ({\n builderCode: response.builder_code,\n expiresAt: response.expires_at,\n quote: response.quote,\n request: response.request,\n rfqId: response.rfq_id,\n status: response.status,\n }),\n );\n\nexport type BuilderRfqFinalStateResponse = {\n rfqId: RfqId;\n status: RfqStatus.Failed | RfqStatus.Expired | RfqStatus.Canceled;\n error?: BuilderRfqError;\n};\n\nconst BuilderRfqFinalStateResponseSchema = z\n .object({\n rfq_id: RfqIdSchema,\n status: z.enum([RfqStatus.Failed, RfqStatus.Expired, RfqStatus.Canceled]),\n error: BuilderRfqErrorSchema.optional(),\n })\n .transform(\n (response): BuilderRfqFinalStateResponse => ({\n rfqId: response.rfq_id,\n status: response.status,\n ...(response.error === undefined ? {} : { error: response.error }),\n }),\n );\n\nexport const BuilderRfqCreateResponseSchema = z.union([\n BuilderRfqQuoteReadyResponseSchema,\n BuilderRfqFinalStateResponseSchema,\n]);\n\nexport type BuilderRfqCreateResponse =\n | BuilderRfqQuoteReadyResponse\n | BuilderRfqFinalStateResponse;\n\n/**\n * Status projection returned on accept responses and post-acceptance status\n * reads.\n *\n * @remarks\n * Onchain execution progress is merged into the top-level `status`:\n * {@link RfqExecutionStatus} values surface alongside the RFQ lifecycle\n * (`MATCHED` is reported as {@link RfqStatus.Executing}).\n */\nexport type BuilderRfqStatusResponse = {\n rfqId: RfqId;\n status: RfqStatus | RfqExecutionStatus;\n takerOrderHash?: string;\n txHash?: TxHash;\n error?: BuilderRfqError;\n};\n\nexport const BuilderRfqStatusResponseSchema = z\n .object({\n rfq_id: RfqIdSchema,\n status: z.union([z.enum(RfqStatus), z.enum(RfqExecutionStatus)]),\n taker_order_hash: z.string().optional(),\n tx_hash: TxHashSchema.optional(),\n error: BuilderRfqErrorSchema.optional(),\n })\n .transform(\n (response): BuilderRfqStatusResponse => ({\n rfqId: response.rfq_id,\n status: response.status,\n ...(response.taker_order_hash === undefined\n ? {}\n : { takerOrderHash: response.taker_order_hash }),\n ...(response.tx_hash === undefined ? {} : { txHash: response.tx_hash }),\n ...(response.error === undefined ? {} : { error: response.error }),\n }),\n );\n","import { expectHexString, type HexString } from '@kuest/types';\nimport { z } from 'zod';\nimport type {\n ComboConditionId,\n DecimalString,\n EventId,\n EvmAddress,\n PositionId,\n} from '../shared';\nimport {\n ComboConditionIdSchema,\n DecimalStringSchema,\n E6BigIntStringToDecimalStringSchema,\n EventIdSchema,\n EvmAddressSchema,\n PositionIdSchema,\n} from '../shared';\n\nconst HexStringSchema = z.string().transform((value) => expectHexString(value));\n\n/**\n * Known collateral-return plan operation kinds.\n *\n * The service evolves this set independently of released clients, so plan\n * parsing accepts unknown kinds as plain strings; see\n * {@link CollateralReturnOperationKind}.\n */\nexport enum CollateralReturnKnownOperationKind {\n Split = 'split',\n Merge = 'merge',\n Redeem = 'redeem',\n SplitOnCondition = 'split_on_condition',\n MergeOnCondition = 'merge_on_condition',\n SplitOnEvent = 'split_on_event',\n MergeOnEvent = 'merge_on_event',\n ConvertOnEvent = 'convert_on_event',\n Extract = 'extract',\n Inject = 'inject',\n ConvertToYesBasket = 'convert_to_yes_basket',\n MergeFromYesBasket = 'merge_from_yes_basket',\n Compress = 'compress',\n}\n\n/**\n * A collateral-return operation kind. Known kinds are enumerated in\n * {@link CollateralReturnKnownOperationKind}; newly introduced kinds flow\n * through as plain strings so plans keep parsing before a client release that\n * enumerates them.\n */\nexport type CollateralReturnOperationKind =\n | CollateralReturnKnownOperationKind\n | (string & {});\n\nconst CollateralReturnOperationKindSchema = z\n .string()\n .transform((value): CollateralReturnOperationKind => value);\n\nexport type CollateralReturnOperation = {\n kind: CollateralReturnOperationKind;\n conditionId?: ComboConditionId;\n eventId?: EventId;\n positionId?: PositionId;\n conditionIndex: number;\n amount: DecimalString;\n};\n\nconst CollateralReturnOperationSchema = z\n .object({\n kind: CollateralReturnOperationKindSchema,\n condition_id: ComboConditionIdSchema.optional(),\n event_id: EventIdSchema.optional(),\n position_id: PositionIdSchema.optional(),\n // The wire format omits zero values, so an absent index means 0.\n condition_index: z.number().int().nonnegative().optional().default(0),\n amount: E6BigIntStringToDecimalStringSchema,\n })\n .transform(\n (operation): CollateralReturnOperation => ({\n amount: operation.amount,\n conditionId: operation.condition_id,\n conditionIndex: operation.condition_index,\n eventId: operation.event_id,\n kind: operation.kind,\n positionId: operation.position_id,\n }),\n );\n\nexport type CollateralReturnPositionAmount = {\n positionId: PositionId;\n amount: DecimalString;\n};\n\nconst CollateralReturnPositionAmountSchema = z\n .object({\n position_id: PositionIdSchema,\n amount: E6BigIntStringToDecimalStringSchema,\n })\n .transform(\n (position): CollateralReturnPositionAmount => ({\n amount: position.amount,\n positionId: position.position_id,\n }),\n );\n\nexport type CollateralReturnPositionSummary = {\n consumed: CollateralReturnPositionAmount[];\n created: CollateralReturnPositionAmount[];\n};\n\nconst CollateralReturnPositionSummarySchema = z\n .object({\n consumed: z.array(CollateralReturnPositionAmountSchema),\n created: z.array(CollateralReturnPositionAmountSchema),\n })\n .transform(\n (summary): CollateralReturnPositionSummary => ({\n consumed: summary.consumed,\n created: summary.created,\n }),\n );\n\nexport type CollateralReturnRouterCall = {\n to: EvmAddress;\n data: HexString;\n};\n\nconst CollateralReturnRouterCallSchema = z\n .object({\n to: EvmAddressSchema,\n data: HexStringSchema,\n })\n .transform(\n (call): CollateralReturnRouterCall => ({\n data: call.data,\n to: call.to,\n }),\n );\n\n/**\n * The plan fields execution consumes: the plan identifier round-tripped to\n * the service, the chain and wallet the plan was computed for, and the exact\n * Router call the execution signs and submits.\n */\nexport const CollateralReturnPlanSchema = z.looseObject({\n planHash: HexStringSchema,\n chainId: z.number().int(),\n wallet: EvmAddressSchema,\n routerCall: CollateralReturnRouterCallSchema,\n});\n\nexport type CollateralReturnPlanResponse = {\n planHash: HexString;\n chainId: number;\n wallet: EvmAddress;\n blockNumber: bigint;\n startingPusd: DecimalString;\n netPusdOut: DecimalString;\n finalPusd: DecimalString;\n operations: CollateralReturnOperation[];\n operationCount: number;\n truncated: boolean;\n estimatedCost: number;\n requiredPusdInput: DecimalString;\n requiredPositions: CollateralReturnPositionAmount[];\n positionSummary: CollateralReturnPositionSummary;\n candidatePositionIds: PositionId[];\n routerCall: CollateralReturnRouterCall;\n};\n\nexport const CollateralReturnPlanResponseSchema = z\n .object({\n plan_hash: HexStringSchema,\n chain_id: z.number().int(),\n wallet: EvmAddressSchema,\n block_number: z.string().regex(/^\\d+$/).transform(BigInt),\n starting_pusd: DecimalStringSchema,\n net_pusd_out: DecimalStringSchema,\n final_pusd: DecimalStringSchema,\n operations: z.array(CollateralReturnOperationSchema),\n operation_count: z.number().int(),\n truncated: z.boolean(),\n estimated_cost: z.number(),\n required_pusd_input: DecimalStringSchema,\n required_positions: z.array(CollateralReturnPositionAmountSchema),\n // Tolerate older service builds that predate the summary field.\n position_summary: CollateralReturnPositionSummarySchema.optional(),\n candidate_position_ids: z.array(PositionIdSchema),\n router_call: CollateralReturnRouterCallSchema,\n })\n .transform(\n (response): CollateralReturnPlanResponse => ({\n blockNumber: response.block_number,\n candidatePositionIds: response.candidate_position_ids,\n chainId: response.chain_id,\n estimatedCost: response.estimated_cost,\n finalPusd: response.final_pusd,\n netPusdOut: response.net_pusd_out,\n operationCount: response.operation_count,\n operations: response.operations,\n planHash: response.plan_hash,\n positionSummary: response.position_summary ?? {\n consumed: [],\n created: [],\n },\n requiredPositions: response.required_positions,\n requiredPusdInput: response.required_pusd_input,\n routerCall: response.router_call,\n startingPusd: response.starting_pusd,\n truncated: response.truncated,\n wallet: response.wallet,\n }),\n );\n"]}