@cypher-zk/sdk 0.1.0

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,507 @@
1
+ import { i as Cypher, C as CypherClient, j as ComputationResult, k as CircuitName } from './client-CO5-Gpyu.js';
2
+ export { A as ACCOUNT_DISCRIMINATOR_SIZE, l as ALL_CIRCUITS, m as ALL_EVENT_NAMES, n as AdminClaimRemainingParams, o as AwaitComputationOptions, B as BPS_DENOMINATOR, p as BetPlacedEvent, q as CIRCUITS, r as CLUSTERS, s as CREATOR_BOND, a as CancelMarketParams, c as ClaimInputs, t as ClaimParams, b as ClaimResult, u as ClusterConfig, v as ClusterName, w as CreateMarketMultiParams, e as CreateMarketParams, d as CreateMarketResult, x as CreatorWithdrawnEvent, y as CypherClientOptions, h as CypherEvent, z as CypherEventName, D as DEFAULT_CLAIM_PERIOD_SECS, F as DEFAULT_REFUND_PERIOD_SECS, H as DEFAULT_RESOLUTION_WINDOW_SECS, E as EncryptedPositionAccount, I as EventCallback, J as EventSubscription, G as GlobalStateAccount, K as INIT_COMP_DEF_INSTRUCTIONS, L as InitCompDefMethodName, N as InitCompDefParams, O as InitializeParams, Q as KNOWN_MINTS, T as LpPositionAccount, U as MAX_LP_FEE_BPS, V as MAX_OUTCOMES_MULTI, W as MAX_PROTOCOL_FEE_BPS, X as MAX_QUESTION_BYTES, Y as MIN_BET_USDC, Z as MIN_OUTCOMES_MULTI, M as MarketAccount, _ as MarketCancelledEvent, $ as MarketCategory, a0 as MarketCategoryValue, a1 as MarketCreatedEvent, a2 as MarketResolvedEvent, a3 as MarketState, a4 as MarketStateValue, a5 as MarketType, a6 as MarketTypeValue, a7 as ODDS_SCALE, a8 as PROGRAM_ID, a9 as PayoutClaimedEvent, f as PlaceBetInputs, P as PlaceBetResult, aa as PlacePrivateBetParams, ab as PollEventsOptions, ac as PolledEvent, ad as RefundClaimedEvent, g as ResolveMarketInputs, ae as ResolveMarketParams, R as ResolveMarketResult, S as SubscribeOptions, af as UpdateAcceptedMintParams, ag as UserCryptoKeypair, ah as Wallet, ai as WithdrawCreatorFundsParams, aj as adminClaimRemainingIx, ak as awaitComputation, al as buildAllInitCompDefIx, am as cancelMarketAction, an as cancelMarketIx, ao as claimPayoutAction, ap as claimPayoutMultiIx, aq as claimPayoutYesnoIx, ar as claimRefundAction, as as claimRefundMultiIx, at as claimRefundYesnoIx, au as compDefOffsetBytes, av as compDefOffsetU32, aw as createCipher, ax as createMarketAction, ay as createMarketIx, az as createMarketMultiAction, aA as createMarketMultiIx, aB as createUserKeypair, aC as deriveSharedSecret, aD as fetchAllMarkets, aE as fetchGlobalState, aF as fetchLpPosition, aG as fetchLpPositionsByProvider, aH as fetchMarket, aI as fetchMarketsByCreator, aJ as fetchMarketsByState, aK as fetchMxePublicKey, aL as fetchPosition, aM as fetchPositionsForMarket, aN as fetchUserPositions, aO as freshNonce, aP as initCompDefIx, aQ as initializeIx, aR as keypairToWallet, aS as leBytesToBigInt, aT as onBetPlaced, aU as onCreatorWithdrawn, aV as onMarketCancelled, aW as onMarketCreated, aX as onMarketResolved, aY as onPayoutClaimed, aZ as onRefundClaimed, a_ as parseLogs, a$ as parseLogsFor, b0 as placeBetAction, b1 as placePrivateBetMultiIx, b2 as placePrivateBetYesnoIx, b3 as pollEvents, b4 as randomComputationOffset, b5 as readonlyWallet, b6 as resolveMarketAction, b7 as resolveMarketMultiIx, b8 as resolveMarketYesnoIx, b9 as subscribeAll, ba as subscribeEvent, bb as updateAcceptedMintIx, bc as withdrawCreatorFundsAction, bd as withdrawCreatorFundsIx } from './client-CO5-Gpyu.js';
3
+ import { GetProgramAccountsFilter, PublicKey, Signer, ConfirmOptions, TransactionInstruction } from '@solana/web3.js';
4
+ import { BN } from '@anchor-lang/core';
5
+ import { RescueCipher } from '@arcium-hq/client';
6
+ export { ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID, getAssociatedTokenAddressSync } from '@solana/spl-token';
7
+
8
+ declare const IDL: Cypher;
9
+ declare const IDL_PROGRAM_ID: "cyphPe923pnPGVXJL3a3P7t2W9mJsagBcg1oeauoh2B";
10
+
11
+ /** Filter matching the 8-byte Anchor discriminator of `accountName`. */
12
+ declare function discriminatorFilter(accountName: string): GetProgramAccountsFilter;
13
+ declare const marketFilters: {
14
+ discriminator: () => GetProgramAccountsFilter;
15
+ byCreator: (creator: PublicKey) => GetProgramAccountsFilter;
16
+ byResolver: (resolver: PublicKey) => GetProgramAccountsFilter;
17
+ byState: (state: number) => GetProgramAccountsFilter;
18
+ byCategory: (category: number) => GetProgramAccountsFilter;
19
+ byMarketType: (mt: number) => GetProgramAccountsFilter;
20
+ };
21
+ declare const positionFilters: {
22
+ discriminator: () => GetProgramAccountsFilter;
23
+ byUser: (user: PublicKey) => GetProgramAccountsFilter;
24
+ byMarket: (market: PublicKey) => GetProgramAccountsFilter;
25
+ };
26
+ declare const lpPositionFilters: {
27
+ discriminator: () => GetProgramAccountsFilter;
28
+ byProvider: (lpProvider: PublicKey) => GetProgramAccountsFilter;
29
+ byMarket: (market: PublicKey) => GetProgramAccountsFilter;
30
+ };
31
+
32
+ /**
33
+ * Hard-coded byte offsets (post-discriminator) for memcmp filters on every
34
+ * `getProgramAccounts` query the SDK runs.
35
+ *
36
+ * These mirror the field order in `cypher-main/programs/cypher_main/src/states.rs`.
37
+ * `accounts/filter.test.ts` recomputes them dynamically from the synced IDL
38
+ * type layout and asserts equality — so if a contributor reorders a field
39
+ * upstream, the SDK build fails on the next `bun run sync:idl`.
40
+ *
41
+ * Offsets here are *relative to the account body*. Helpers in `filter.ts`
42
+ * add `ACCOUNT_DISCRIMINATOR_SIZE` (8) when emitting memcmp filters.
43
+ */
44
+ declare const MARKET_OFFSETS: {
45
+ readonly marketId: 0;
46
+ readonly question: 8;
47
+ readonly questionLen: 208;
48
+ readonly marketType: 209;
49
+ readonly numOutcomes: 210;
50
+ readonly category: 211;
51
+ readonly creator: 212;
52
+ readonly resolver: 244;
53
+ readonly creatorBond: 276;
54
+ readonly bondWithdrawn: 284;
55
+ readonly totalBetsCount: 285;
56
+ readonly encryptedPool0: 293;
57
+ readonly encryptedPool1: 325;
58
+ readonly encryptedPool2: 357;
59
+ readonly encryptedPool3: 389;
60
+ readonly mxeNonce: 421;
61
+ readonly revealedPool0: 437;
62
+ readonly revealedPool1: 445;
63
+ readonly revealedPool2: 453;
64
+ readonly revealedPool3: 461;
65
+ readonly state: 469;
66
+ readonly outcome: 470;
67
+ readonly pendingOutcome: 471;
68
+ readonly closeTime: 472;
69
+ readonly resolutionTime: 480;
70
+ readonly payoutRatio: 488;
71
+ readonly accumulatedLpFees: 496;
72
+ readonly accumulatedProtocolFees: 504;
73
+ readonly minBet: 512;
74
+ readonly totalPayoutsClaimed: 520;
75
+ readonly totalRefundsClaimed: 528;
76
+ readonly adminClaimedRemaining: 536;
77
+ readonly resolutionDeadline: 537;
78
+ readonly claimDeadline: 545;
79
+ readonly refundDeadline: 553;
80
+ readonly bump: 561;
81
+ readonly vaultBump: 562;
82
+ };
83
+ declare const ENCRYPTED_POSITION_OFFSETS: {
84
+ readonly user: 0;
85
+ readonly market: 32;
86
+ readonly encryptedAmount: 64;
87
+ readonly encryptedSide: 96;
88
+ readonly userPubkey: 128;
89
+ readonly nonce: 160;
90
+ readonly entryOdds: 176;
91
+ readonly netAmount: 184;
92
+ readonly claimed: 192;
93
+ readonly bump: 193;
94
+ };
95
+ declare const LP_POSITION_OFFSETS: {
96
+ readonly lpProvider: 0;
97
+ readonly market: 32;
98
+ readonly liquidityProvided: 64;
99
+ readonly feesEarned: 72;
100
+ readonly feesClaimed: 80;
101
+ readonly feesClaimedAmount: 81;
102
+ readonly bump: 89;
103
+ };
104
+ declare const GLOBAL_STATE_OFFSETS: {
105
+ readonly marketCounter: 0;
106
+ readonly protocolFeeRate: 8;
107
+ readonly lpFeeRate: 10;
108
+ readonly protocolTreasury: 12;
109
+ readonly acceptedMint: 44;
110
+ readonly admin: 76;
111
+ readonly bump: 108;
112
+ };
113
+
114
+ /** Address Lookup Table program ID — required by `init_*_comp_def` ixs. */
115
+ declare const ADDRESS_LOOKUP_TABLE_PROGRAM_ID: PublicKey;
116
+ /** Convert `bigint | number | BN` → `BN`. Idempotent. */
117
+ declare function toBN(v: bigint | number | BN): BN;
118
+ /** The default ATA derivation for `(owner, mint)`. */
119
+ declare function userAta(owner: PublicKey, mint: PublicKey): PublicKey;
120
+
121
+ interface SendIxOptions {
122
+ /** Additional Keypair signers (most flows only need the wallet's signer). */
123
+ signers?: Signer[];
124
+ /** Anchor confirmation options override. */
125
+ confirmOptions?: ConfirmOptions;
126
+ }
127
+ /**
128
+ * Wrap a single instruction in a legacy `Transaction`, sign with the
129
+ * provider's wallet (plus any extra `signers`), and send via the Anchor
130
+ * provider. Returns the confirmed signature.
131
+ *
132
+ * Errors are reshaped through `parseCypherError` so the caller gets a
133
+ * `ParsedCypherError` (when the program rejected the call) instead of
134
+ * Anchor's nested error objects.
135
+ */
136
+ declare function sendIx(client: CypherClient, ix: TransactionInstruction, opts?: SendIxOptions): Promise<string>;
137
+ /**
138
+ * Send an instruction that queues an Arcium computation, then block until
139
+ * the MPC nodes finalize the callback. Returns both the queue tx
140
+ * signature and the computation finalization details.
141
+ *
142
+ * Used by every action that touches the bet / resolve / claim path.
143
+ */
144
+ declare function sendIxAndAwaitArcium(client: CypherClient, ix: TransactionInstruction, params: {
145
+ computationOffset: bigint;
146
+ timeoutMs?: number;
147
+ signers?: Signer[];
148
+ confirmOptions?: ConfirmOptions;
149
+ }): Promise<{
150
+ signature: string;
151
+ computation: ComputationResult;
152
+ }>;
153
+
154
+ /**
155
+ * A user's plaintext bet input as the circuits expect it.
156
+ *
157
+ * `amount` is the **net** stake (after on-chain protocol + LP fee) — the
158
+ * circuit asserts equality with the on-chain `net_amount` argument, so a
159
+ * caller who encrypts the gross bet will see the queue succeed and the
160
+ * callback hard-zero their stake (see audit finding H-1 / the
161
+ * `net_amount_plaintext` checks in `encrypted-ixs/src/lib.rs`).
162
+ */
163
+ interface BetInput {
164
+ /** Net stake in micro-USDC. Must equal `bet_amount - protocol_fee - lp_fee`. */
165
+ amount: bigint;
166
+ /** Outcome index: 0 / 1 for YesNo, 0..3 for MultiOutcome. */
167
+ side: number;
168
+ }
169
+ /** Plaintext input to the refund circuit — the user's original net stake. */
170
+ interface RefundInput {
171
+ amount: bigint;
172
+ }
173
+ /** Encrypted form of a `BetInput`, ready for the queue instruction. */
174
+ interface EncryptedBetInput {
175
+ /** 32-byte ciphertext for `amount`. */
176
+ encryptedAmount: Uint8Array;
177
+ /** 32-byte ciphertext for `side`. */
178
+ encryptedSide: Uint8Array;
179
+ /** 16-byte nonce used for *both* ciphertexts (CTR mode, single message). */
180
+ nonceBytes: Uint8Array;
181
+ /** Same nonce as a `u128` `bigint` — the form the on-chain ix takes. */
182
+ nonce: bigint;
183
+ }
184
+ /** Encrypted form of a `RefundInput` (single scalar — only the amount is private). */
185
+ interface EncryptedRefundInput {
186
+ encryptedAmount: Uint8Array;
187
+ nonceBytes: Uint8Array;
188
+ nonce: bigint;
189
+ }
190
+ /**
191
+ * Encrypt `(amount, side)` as a single Rescue message with one nonce.
192
+ *
193
+ * Returns **two separate 32-byte ciphertexts** — they are *not*
194
+ * concatenated. Each scalar maps to its own ciphertext per the Arcium
195
+ * SKILL.md gotcha ("Combined ciphertext arrays"): the on-chain ix expects
196
+ * `encrypted_amount: [u8; 32]` and `encrypted_side: [u8; 32]` as
197
+ * independent arguments.
198
+ *
199
+ * The caller is responsible for picking a fresh nonce per call — pass
200
+ * `nonceBytes` if you want to control it, otherwise a 16-byte random
201
+ * nonce is generated.
202
+ */
203
+ declare function encryptBetInput(input: BetInput, cipher: RescueCipher, nonceBytes?: Uint8Array): EncryptedBetInput;
204
+ /**
205
+ * Encrypt the refund input — a single scalar (the user's net stake).
206
+ *
207
+ * The refund circuit decrypts the amount and caps it to the on-chain
208
+ * `net_amount_plaintext` argument before transferring, so the caller
209
+ * must pass the same `amount` the on-chain `EncryptedPosition.net_amount`
210
+ * already records.
211
+ */
212
+ declare function encryptRefundInput(input: RefundInput, cipher: RescueCipher, nonceBytes?: Uint8Array): EncryptedRefundInput;
213
+ /**
214
+ * Decrypt a previously-encrypted `BetInput` — used by the SDK consumer
215
+ * who held onto their x25519 private key and wants to display the stake +
216
+ * side after fetching their `EncryptedPosition` from chain.
217
+ *
218
+ * The caller must hand the same 16-byte nonce the original encrypt used;
219
+ * it lives on `EncryptedPosition.nonce` (a `u128`) so call
220
+ * `bigIntToLeBytes(position.nonce, 16)` to round-trip.
221
+ */
222
+ declare function decryptBetInput(encrypted: {
223
+ encryptedAmount: Uint8Array;
224
+ encryptedSide: Uint8Array;
225
+ }, cipher: RescueCipher, nonceBytes: Uint8Array): BetInput;
226
+ /** Round-trip helper: bigint → 16-byte LE Uint8Array (for u128 nonces). */
227
+ declare function bigIntToLeBytes(value: bigint, byteLength: number): Uint8Array;
228
+
229
+ /**
230
+ * PDA derivation helpers for every account the Cypher program creates.
231
+ *
232
+ * Seeds mirror `programs/cypher_main/src/lib.rs` exactly — verified
233
+ * against the synced IDL in `pda.test.ts`. Always call these helpers
234
+ * rather than re-deriving inline; on-chain seed changes will then show
235
+ * up in one place.
236
+ *
237
+ * Every helper accepts an optional `programId` argument so callers can
238
+ * derive against a non-default deployment (e.g., the `arcium localnet`
239
+ * harness occasionally redeploys under a fresh keypair).
240
+ */
241
+ /** Accepts bigint, number, or any BN-like (anything with .toString → u64 string). */
242
+ type U64Like = bigint | number | {
243
+ toString(): string;
244
+ };
245
+ /** `[b"global_state"]` — singleton config PDA. */
246
+ declare function globalStatePda(programId?: PublicKey): [PublicKey, number];
247
+ /** `[b"market", market_id u64 LE]` — one per market. Accepts BN-like. */
248
+ declare function marketPda(marketId: U64Like, programId?: PublicKey): [PublicKey, number];
249
+ /** `[b"market_vault", market]` — PDA-owned SPL token account holding stakes. */
250
+ declare function marketVaultPda(market: PublicKey, programId?: PublicKey): [PublicKey, number];
251
+ /** `[b"position", market, user]` — encrypted bet position per user per market. */
252
+ declare function positionPda(market: PublicKey, user: PublicKey, programId?: PublicKey): [PublicKey, number];
253
+ /** `[b"lp-position", market, creator]` — bond + LP fee accounting. */
254
+ declare function lpPositionPda(market: PublicKey, creator: PublicKey, programId?: PublicKey): [PublicKey, number];
255
+ /**
256
+ * `[b"ArciumSignerAccount"]` — Arcium-side signer PDA used as the queue-time
257
+ * CPI authority for callback verification. The seed literal is dictated by
258
+ * the Arcium macro `derive_sign_pda!()`; see arcium SKILL.md.
259
+ */
260
+ declare function arciumSignerPda(programId?: PublicKey): [PublicKey, number];
261
+
262
+ /**
263
+ * Snapshot of the on-chain fee configuration the user needs to compute
264
+ * exact pre-trade values without a `getAccountInfo` round-trip.
265
+ *
266
+ * Populate `protocolFeeRateBps` / `lpFeeRateBps` from `GlobalState`.
267
+ */
268
+ interface FeeRates {
269
+ /** Protocol fee in basis points (max 100 = 1%). */
270
+ protocolFeeRateBps: number;
271
+ /** LP fee in basis points (max 500 = 5%). */
272
+ lpFeeRateBps: number;
273
+ }
274
+ /**
275
+ * Breakdown of the on-chain math applied to a bet of `amount` micro-USDC.
276
+ *
277
+ * Mirrors the program exactly (see `place_private_bet_yesno` in
278
+ * `cypher-main/programs/cypher_main/src/lib.rs`):
279
+ *
280
+ * protocolFee = floor(amount * protocolFeeRateBps / 10_000)
281
+ * lpFee = floor(amount * lpFeeRateBps / 10_000)
282
+ * netAmount = amount - protocolFee - lpFee
283
+ *
284
+ * The circuit asserts `netAmount` matches what the client encrypted, so
285
+ * surfacing it here is critical for UX previews and equally critical for
286
+ * the place-bet action helper that gets built in a later phase.
287
+ */
288
+ interface FeeBreakdown {
289
+ /** Original bet, unchanged (just echoed back for symmetry). */
290
+ amount: bigint;
291
+ /** Protocol fee that leaves the market vault → treasury. */
292
+ protocolFee: bigint;
293
+ /** LP fee credited to `market.accumulated_lp_fees`. */
294
+ lpFee: bigint;
295
+ /**
296
+ * Net stake that ends up in the encrypted position and is shielded
297
+ * by the circuit (`net_amount_plaintext` argument to the bet circuit).
298
+ */
299
+ netAmount: bigint;
300
+ }
301
+ /**
302
+ * Compute the fee split for a single bet, matching on-chain math exactly.
303
+ *
304
+ * Uses `bigint` end-to-end to mirror Solana's `u64` overflow semantics.
305
+ * Throws if any value would exceed `u64`.
306
+ */
307
+ declare function computeFees(amount: bigint, rates: FeeRates): FeeBreakdown;
308
+ /**
309
+ * Returns `true` if `amount` satisfies `market.min_bet` *and* leaves a
310
+ * non-zero `netAmount` after fees. The on-chain check is just the first
311
+ * half — but a bet that nets to zero would create a useless position, so
312
+ * we surface the stronger condition here.
313
+ */
314
+ declare function isBetAmountValid(amount: bigint, rates: FeeRates, minBet?: bigint): boolean;
315
+
316
+ /**
317
+ * High-level lifecycle phase of a market — what action (if any) is
318
+ * available *right now* to which user.
319
+ *
320
+ * Mirrors the on-chain require!() guards across the program so a frontend
321
+ * doesn't have to keep them in sync separately.
322
+ */
323
+ type MarketPhase =
324
+ /** Market is open for bets (state=Active, now < close_time). */
325
+ "betting"
326
+ /** Bets closed, resolver may submit an outcome (now in resolution window). */
327
+ | "awaitingResolve"
328
+ /** Resolved + within claim window → winners can claim payouts. */
329
+ | "claimable"
330
+ /** Unresolved + past resolution deadline → bettors can claim refunds. */
331
+ | "refundable"
332
+ /** Resolution claim period expired; admin sweep eligible. */
333
+ | "expired"
334
+ /** Creator cancelled before any bets were placed. */
335
+ | "cancelled";
336
+ /**
337
+ * The fields off `Market` the deadline math depends on. Kept as a minimal
338
+ * interface so callers can pass either a fully-decoded `Market` account or
339
+ * a hand-built record (e.g., from a draft create-market form).
340
+ */
341
+ interface MarketDeadlineInputs {
342
+ state: number;
343
+ closeTime: bigint;
344
+ resolutionDeadline: bigint;
345
+ claimDeadline: bigint;
346
+ refundDeadline: bigint;
347
+ totalBetsCount?: bigint;
348
+ }
349
+ /**
350
+ * Compute the phase of `market` at `nowSec` (defaults to wall-clock now).
351
+ *
352
+ * Returns one of the `MarketPhase` literals — see its docs for what each
353
+ * means. Pure: no chain access.
354
+ */
355
+ declare function marketPhase(market: MarketDeadlineInputs, nowSec?: bigint): MarketPhase;
356
+ /**
357
+ * For a draft market with only `closeTime` decided, derive the four
358
+ * deadlines the program will set on creation (`resolution_deadline`,
359
+ * `claim_deadline` / `refund_deadline` are zeroed at create-time and
360
+ * filled in on resolve, but this helper projects the intended values so a
361
+ * UI can preview them).
362
+ */
363
+ declare function projectDeadlines(closeTime: bigint): {
364
+ closeTime: bigint;
365
+ resolutionDeadline: bigint;
366
+ projectedClaimDeadline: bigint;
367
+ projectedRefundDeadline: bigint;
368
+ };
369
+ /**
370
+ * Returns `true` iff `closeTime` is at least 60 seconds in the future.
371
+ *
372
+ * The on-chain check is `close_time > now`, but a 60-second cushion makes
373
+ * the dapp robust against clock skew between the user, the RPC, and the
374
+ * validator.
375
+ */
376
+ declare function isValidCloseTime(closeTime: bigint, nowSec?: bigint): boolean;
377
+
378
+ /**
379
+ * Numeric error codes as declared by the `#[error_code] pub enum CypherError`
380
+ * block in `cypher-main/programs/cypher_main/src/lib.rs`. Synced via the
381
+ * shared IDL — any new error in the contract automatically becomes a new
382
+ * entry on this map as long as `bun run sync:idl` is rerun.
383
+ *
384
+ * Codes start at Anchor's default `6000` offset.
385
+ */
386
+ declare const CypherErrorCode: {
387
+ readonly MarketNotActive: 6000;
388
+ readonly MarketClosed: 6001;
389
+ readonly MarketStillOpen: 6002;
390
+ readonly AlreadyResolved: 6003;
391
+ readonly NotResolved: 6004;
392
+ readonly UnauthorizedResolver: 6005;
393
+ readonly UnauthorizedAdmin: 6006;
394
+ readonly AlreadyClaimed: 6007;
395
+ readonly PositionLost: 6008;
396
+ readonly BetTooSmall: 6009;
397
+ readonly InsufficientVaultBalance: 6010;
398
+ readonly NoFeesToClaim: 6011;
399
+ readonly LiquidityTooLow: 6012;
400
+ readonly InvalidCloseTime: 6013;
401
+ readonly EmptyQuestion: 6014;
402
+ readonly QuestionTooLong: 6015;
403
+ readonly Overflow: 6016;
404
+ readonly InvalidOutcome: 6017;
405
+ readonly InvalidFeeRate: 6018;
406
+ readonly InvalidTreasury: 6019;
407
+ readonly BondAlreadyWithdrawn: 6020;
408
+ readonly NotMarketCreator: 6021;
409
+ readonly MarketHasBets: 6022;
410
+ readonly ResolutionDeadlinePassed: 6023;
411
+ readonly MarketNotUnresolved: 6024;
412
+ readonly ResolutionDeadlineNotReached: 6025;
413
+ readonly ClaimPeriodExpired: 6026;
414
+ readonly RefundPeriodExpired: 6027;
415
+ readonly AbortedComputation: 6028;
416
+ readonly ComputationVerificationFailed: 6029;
417
+ readonly CannotWithdrawFromUnresolved: 6030;
418
+ readonly AdminAlreadyClaimed: 6031;
419
+ readonly WrongMarketType: 6032;
420
+ readonly WrongMint: 6033;
421
+ readonly NotAcceptedMint: 6034;
422
+ readonly InvalidCategory: 6035;
423
+ };
424
+ type CypherErrorName = keyof typeof CypherErrorCode;
425
+ type CypherErrorCodeValue = (typeof CypherErrorCode)[keyof typeof CypherErrorCode];
426
+ /** Human-readable description for every code, sourced from the IDL `msg`. */
427
+ declare const CYPHER_ERROR_MESSAGES: Readonly<Record<CypherErrorName, string>>;
428
+ /** Look up a Cypher error name by its numeric code. */
429
+ declare function cypherErrorName(code: number): CypherErrorName | undefined;
430
+ /** Structured result of parsing an Anchor error. */
431
+ interface ParsedCypherError {
432
+ code: CypherErrorCodeValue;
433
+ name: CypherErrorName;
434
+ msg: string;
435
+ }
436
+ /**
437
+ * Walk a thrown value and extract a CypherError if one is present.
438
+ *
439
+ * Anchor wraps program errors several different ways depending on whether
440
+ * the call went through `.rpc()`, `.simulate()`, or a raw transaction
441
+ * send; this helper handles every shape we've seen in the wild:
442
+ *
443
+ * - Direct `AnchorError` instances with `.error.errorCode.number`.
444
+ * - Plain `Error.message` strings that contain `custom program error: 0xNNNN`.
445
+ * - `SendTransactionError.logs` containing the same log line.
446
+ *
447
+ * Returns `null` if the input is not a Cypher error (e.g., a network
448
+ * timeout or a different program's error).
449
+ */
450
+ declare function parseCypherError(input: unknown): ParsedCypherError | null;
451
+
452
+ /**
453
+ * The bundle of Arcium-side accounts every `queue_*` Anchor instruction
454
+ * expects. Each field corresponds to one entry in the on-chain
455
+ * `#[queue_computation_accounts(...)]` macro in `cypher-main/src/lib.rs`.
456
+ *
457
+ * Naming matches the Anchor account context fields in cypher-main so
458
+ * spread-into-`.accountsPartial(...)` works cleanly.
459
+ */
460
+ interface ArciumQueueAccounts {
461
+ /** The per-computation PDA derived from `(clusterOffset, computationOffset)`. */
462
+ computationAccount: PublicKey;
463
+ /** Cluster PDA on the chosen Arcium cluster. */
464
+ clusterAccount: PublicKey;
465
+ /** MXE PDA for the Cypher program — the on-chain metadata holder. */
466
+ mxeAccount: PublicKey;
467
+ /** Mempool that buffers computations before assignment to executors. */
468
+ mempoolAccount: PublicKey;
469
+ /** Currently-executing pool on the cluster. */
470
+ executingPool: PublicKey;
471
+ /** Comp-def PDA holding the compiled circuit bytecode + verifier key. */
472
+ compDefAccount: PublicKey;
473
+ /** Shared Arcium fee-pool PDA. */
474
+ poolAccount: PublicKey;
475
+ /** Shared Arcium clock PDA — used to enforce monotonic ordering. */
476
+ clockAccount: PublicKey;
477
+ /** Cypher program-side signer PDA (`b"ArciumSignerAccount"`). */
478
+ signPdaAccount: PublicKey;
479
+ /** Arcium executable program ID — included for the program CPI. */
480
+ arciumProgram: PublicKey;
481
+ /** v0 lookup table containing the MXE's heavy accounts. */
482
+ addressLookupTable: PublicKey;
483
+ }
484
+ /**
485
+ * Derive every Arcium account the Cypher program expects for a single
486
+ * `queue_*` invocation. Pure: only reads from the `client` config and a
487
+ * caller-supplied `computationOffset`.
488
+ *
489
+ * `computationOffset` is the random u64 the caller picks per request —
490
+ * the on-chain `place_private_bet_*`, `resolve_market_*`, `claim_*`
491
+ * instructions all take it as their first argument and use it as the PDA
492
+ * seed for the computation account.
493
+ */
494
+ declare function buildArciumQueueAccounts(client: CypherClient, params: {
495
+ circuit: CircuitName;
496
+ computationOffset: bigint | BN;
497
+ /** Lookup table address; if omitted, derived from the MXE account. */
498
+ addressLookupTable?: PublicKey;
499
+ /** Optional MXE LUT offset slot — needed only if you pre-fetched the MXE. */
500
+ lutOffsetSlot?: BN;
501
+ }): ArciumQueueAccounts;
502
+ declare function fetchMxeLookupTable(client: CypherClient): Promise<{
503
+ lut: PublicKey;
504
+ slot: BN;
505
+ }>;
506
+
507
+ export { ADDRESS_LOOKUP_TABLE_PROGRAM_ID, type ArciumQueueAccounts, type BetInput, CYPHER_ERROR_MESSAGES, CircuitName, ComputationResult, Cypher, CypherClient, CypherErrorCode, type CypherErrorCodeValue, type CypherErrorName, ENCRYPTED_POSITION_OFFSETS, type EncryptedBetInput, type EncryptedRefundInput, type FeeBreakdown, type FeeRates, GLOBAL_STATE_OFFSETS, IDL, IDL_PROGRAM_ID, LP_POSITION_OFFSETS, MARKET_OFFSETS, type MarketDeadlineInputs, type MarketPhase, type ParsedCypherError, type RefundInput, type SendIxOptions, arciumSignerPda, bigIntToLeBytes, buildArciumQueueAccounts, computeFees, cypherErrorName, decryptBetInput, discriminatorFilter, encryptBetInput, encryptRefundInput, fetchMxeLookupTable, globalStatePda, isBetAmountValid, isValidCloseTime, lpPositionFilters, lpPositionPda, marketFilters, marketPda, marketPhase, marketVaultPda, parseCypherError, positionFilters, positionPda, projectDeadlines, sendIx, sendIxAndAwaitArcium, toBN, userAta };