@cypher-zk/sdk 0.5.0 → 0.7.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.
- package/README.md +114 -81
- package/dist/{client-B0EueahJ.d.ts → client-sr7mY_Wj.d.ts} +43 -12
- package/dist/{cypher-M5PH6UM5.json → cypher-G57ZWFM3.json} +17 -4
- package/dist/index.d.ts +8 -7
- package/dist/index.js +23 -12
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.ts +5 -2
- package/dist/react/index.js +2 -1
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
- package/src/idl/cypher.json +17 -4
- package/src/idl/cypher.ts +17 -4
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[]()
|
|
6
6
|
[]()
|
|
7
7
|
[]()
|
|
8
|
-
[]()
|
|
9
9
|
[](./LICENSE)
|
|
10
10
|
|
|
11
11
|
A framework-agnostic core (Node, Bun, browser) with an optional React
|
|
@@ -42,8 +42,8 @@ const result = await client.actions.placeBet({
|
|
|
42
42
|
payer: wallet.publicKey,
|
|
43
43
|
user: wallet.publicKey,
|
|
44
44
|
marketId: 7n,
|
|
45
|
-
side: 1,
|
|
46
|
-
amountUsdc: 5_000_000n,
|
|
45
|
+
side: 1, // 1 = YES
|
|
46
|
+
amountUsdc: 5_000_000n, // $5 (6 decimals)
|
|
47
47
|
onProgress: (e) => updateLoaderUI(e.stage, e.message),
|
|
48
48
|
});
|
|
49
49
|
// Persist result.userKeypair.privateKey under the wallet's key — that's
|
|
@@ -102,9 +102,9 @@ npm install @cypher-zk/sdk
|
|
|
102
102
|
|
|
103
103
|
### Peer dependencies
|
|
104
104
|
|
|
105
|
-
| Package
|
|
106
|
-
|
|
|
107
|
-
| `react` ^18 \|\| ^19
|
|
105
|
+
| Package | Required for |
|
|
106
|
+
| -------------------------- | ----------------------------------- |
|
|
107
|
+
| `react` ^18 \|\| ^19 | `@cypher-zk/sdk/react` subpath only |
|
|
108
108
|
| `@tanstack/react-query` ^5 | `@cypher-zk/sdk/react` subpath only |
|
|
109
109
|
|
|
110
110
|
Core SDK works in any TypeScript environment with no peer requirements.
|
|
@@ -134,8 +134,8 @@ const gs = await client.globalState.fetch();
|
|
|
134
134
|
console.log("Protocol fee:", gs.protocolFeeRate, "bps");
|
|
135
135
|
|
|
136
136
|
const market = await client.markets.fetch(0n);
|
|
137
|
-
const active = await client.markets.byState(0);
|
|
138
|
-
const mine
|
|
137
|
+
const active = await client.markets.byState(0); // MarketState.Active
|
|
138
|
+
const mine = await client.markets.byCreator(wallet.publicKey);
|
|
139
139
|
const myBets = await client.positions.byUser(wallet.publicKey);
|
|
140
140
|
```
|
|
141
141
|
|
|
@@ -149,15 +149,20 @@ const preview = computeFees(5_000_000n, {
|
|
|
149
149
|
protocolFeeRateBps: gs.protocolFeeRate,
|
|
150
150
|
lpFeeRateBps: gs.lpFeeRate,
|
|
151
151
|
});
|
|
152
|
-
console.log(
|
|
152
|
+
console.log(
|
|
153
|
+
"Net stake:",
|
|
154
|
+
preview.netAmount,
|
|
155
|
+
"after fees:",
|
|
156
|
+
preview.protocolFee + preview.lpFee,
|
|
157
|
+
);
|
|
153
158
|
|
|
154
159
|
// Fire the end-to-end flow:
|
|
155
160
|
const { signature, position, userKeypair } = await client.actions.placeBet({
|
|
156
161
|
payer: wallet.publicKey,
|
|
157
162
|
user: wallet.publicKey,
|
|
158
163
|
marketId: 0n,
|
|
159
|
-
side: 1,
|
|
160
|
-
amountUsdc: 5_000_000n,
|
|
164
|
+
side: 1, // 0 = NO, 1 = YES
|
|
165
|
+
amountUsdc: 5_000_000n, // $5 (USDC has 6 decimals)
|
|
161
166
|
onProgress: ({ stage, message, signature }) => {
|
|
162
167
|
// stage ∈ "validating" | "fetching-state" | "encrypting" | "submitting"
|
|
163
168
|
// | "awaiting-callback" | "refetching" | "done"
|
|
@@ -190,7 +195,7 @@ const { marketId, marketPda, signature } = await client.actions.createMarket({
|
|
|
190
195
|
creator: wallet.publicKey,
|
|
191
196
|
question: "Will ETH hit $10k by end of 2026?",
|
|
192
197
|
closeTime: BigInt(Math.floor(Date.now() / 1000) + 7 * 24 * 3600),
|
|
193
|
-
category: 0,
|
|
198
|
+
category: 0, // MarketCategory.Crypto
|
|
194
199
|
// v0.2+: optional. Defaults to MIN_CHALLENGE_PERIOD_SECS (24h).
|
|
195
200
|
// Must be in [MIN_CHALLENGE_PERIOD_SECS, MAX_CHALLENGE_PERIOD_SECS]
|
|
196
201
|
// (24h–48h). Pin shorter for prediction markets that settle fast.
|
|
@@ -244,7 +249,9 @@ refund) so the user never burns gas on a guaranteed-to-fail tx.
|
|
|
244
249
|
// Real-time (WebSocket):
|
|
245
250
|
const sub = client.events.onBetPlaced((data) => {
|
|
246
251
|
// `data` is BetPlacedEvent — fully typed (camelCase fields, bigint amounts):
|
|
247
|
-
console.log(
|
|
252
|
+
console.log(
|
|
253
|
+
`Bet placed on market ${data.market.toBase58()} — odds ${data.entryOdds}`,
|
|
254
|
+
);
|
|
248
255
|
});
|
|
249
256
|
|
|
250
257
|
// Generic, typed by name:
|
|
@@ -275,9 +282,14 @@ for (const { event, signature, slot } of recent) {
|
|
|
275
282
|
|
|
276
283
|
// Parse events out of a known transaction:
|
|
277
284
|
import { parseLogs, parseLogsFor } from "@cypher-zk/sdk";
|
|
278
|
-
const tx = await connection.getTransaction(sig, {
|
|
279
|
-
|
|
280
|
-
|
|
285
|
+
const tx = await connection.getTransaction(sig, {
|
|
286
|
+
maxSupportedTransactionVersion: 0,
|
|
287
|
+
});
|
|
288
|
+
const allEvents = parseLogs(tx?.meta?.logMessages ?? []);
|
|
289
|
+
const payoutsOnly = parseLogsFor(
|
|
290
|
+
tx?.meta?.logMessages ?? [],
|
|
291
|
+
"PayoutClaimedEvent",
|
|
292
|
+
);
|
|
281
293
|
```
|
|
282
294
|
|
|
283
295
|
### 7. Phase helpers
|
|
@@ -287,20 +299,32 @@ import { marketPhase, projectDeadlines } from "@cypher-zk/sdk";
|
|
|
287
299
|
|
|
288
300
|
// Compute what action is currently available on a market:
|
|
289
301
|
switch (marketPhase(market)) {
|
|
290
|
-
case "betting":
|
|
291
|
-
|
|
292
|
-
case "
|
|
293
|
-
|
|
294
|
-
case "
|
|
295
|
-
|
|
296
|
-
case "
|
|
297
|
-
|
|
298
|
-
case "
|
|
302
|
+
case "betting":
|
|
303
|
+
/* show "Bet" button */ break;
|
|
304
|
+
case "awaitingResolve":
|
|
305
|
+
/* show "Pending resolution" */ break;
|
|
306
|
+
case "pendingResolution":
|
|
307
|
+
/* v0.2: in challenge window — show countdown + "Flag" */ break;
|
|
308
|
+
case "awaitingFinalize":
|
|
309
|
+
/* v0.2: window elapsed — show "Finalize" button */ break;
|
|
310
|
+
case "disputed":
|
|
311
|
+
/* v0.2: flagged — admin override required */ break;
|
|
312
|
+
case "claimable":
|
|
313
|
+
/* show "Claim payout" */ break;
|
|
314
|
+
case "refundable":
|
|
315
|
+
/* show "Claim refund" */ break;
|
|
316
|
+
case "expired":
|
|
317
|
+
/* show "Admin sweep eligible" */ break;
|
|
318
|
+
case "cancelled":
|
|
319
|
+
/* show "Cancelled" */ break;
|
|
299
320
|
}
|
|
300
321
|
|
|
301
322
|
// Preview deadlines for a draft market the user is filling in:
|
|
302
323
|
const projected = projectDeadlines(BigInt(closeTimeSec));
|
|
303
|
-
console.log(
|
|
324
|
+
console.log(
|
|
325
|
+
"Resolution deadline:",
|
|
326
|
+
new Date(Number(projected.resolutionDeadline) * 1000),
|
|
327
|
+
);
|
|
304
328
|
```
|
|
305
329
|
|
|
306
330
|
---
|
|
@@ -376,12 +400,12 @@ stages and refuses pre-flight if the market isn't in the right phase
|
|
|
376
400
|
`marketPhase(market)` returns the three new values whenever
|
|
377
401
|
`state === PendingResolution`:
|
|
378
402
|
|
|
379
|
-
| `marketPhase`
|
|
380
|
-
|
|
|
381
|
-
| `"pendingResolution"` | inside challenge window, not flagged
|
|
382
|
-
| `"awaitingFinalize"`
|
|
383
|
-
| `"disputed"`
|
|
384
|
-
| `"claimable"`
|
|
403
|
+
| `marketPhase` | Meaning | Clickable |
|
|
404
|
+
| --------------------- | ------------------------------------------ | -------------------------------------- |
|
|
405
|
+
| `"pendingResolution"` | inside challenge window, not flagged | `flagResolution` (any user) |
|
|
406
|
+
| `"awaitingFinalize"` | window elapsed, not flagged | `finalizeResolution` (any user) |
|
|
407
|
+
| `"disputed"` | flagged during window | `adminOverrideResolution` (admin only) |
|
|
408
|
+
| `"claimable"` | finalized → window closed (state=Resolved) | `claimPayout` |
|
|
385
409
|
|
|
386
410
|
`claimPayoutAction` and `useClaimPayout` reject pre-flight in the
|
|
387
411
|
first three phases with a hint to call `finalizeResolution` first.
|
|
@@ -406,8 +430,13 @@ function ChallengeWindowControls({ marketId }: { marketId: bigint }) {
|
|
|
406
430
|
if (phase === "pendingResolution") {
|
|
407
431
|
return (
|
|
408
432
|
<>
|
|
409
|
-
<p>
|
|
410
|
-
|
|
433
|
+
<p>
|
|
434
|
+
Challenge closes at{" "}
|
|
435
|
+
{new Date(Number(market.challengeDeadline) * 1000).toLocaleString()}
|
|
436
|
+
</p>
|
|
437
|
+
<button
|
|
438
|
+
onClick={() => flag.mutate({ flagger: wallet.publicKey!, marketId })}
|
|
439
|
+
>
|
|
411
440
|
Flag this resolution
|
|
412
441
|
</button>
|
|
413
442
|
</>
|
|
@@ -415,7 +444,9 @@ function ChallengeWindowControls({ marketId }: { marketId: bigint }) {
|
|
|
415
444
|
}
|
|
416
445
|
if (phase === "awaitingFinalize") {
|
|
417
446
|
return (
|
|
418
|
-
<button
|
|
447
|
+
<button
|
|
448
|
+
onClick={() => finalize.mutate({ caller: wallet.publicKey!, marketId })}
|
|
449
|
+
>
|
|
419
450
|
Finalize resolution
|
|
420
451
|
</button>
|
|
421
452
|
);
|
|
@@ -429,9 +460,9 @@ function ChallengeWindowControls({ marketId }: { marketId: bigint }) {
|
|
|
429
460
|
|
|
430
461
|
### Defaults & bounds
|
|
431
462
|
|
|
432
|
-
| Constant
|
|
433
|
-
|
|
|
434
|
-
| `MIN_CHALLENGE_PERIOD_SECS` | `24 * 3600` (24h) | Action helpers default here
|
|
463
|
+
| Constant | Value | Notes |
|
|
464
|
+
| --------------------------- | ----------------- | --------------------------------- |
|
|
465
|
+
| `MIN_CHALLENGE_PERIOD_SECS` | `24 * 3600` (24h) | Action helpers default here |
|
|
435
466
|
| `MAX_CHALLENGE_PERIOD_SECS` | `48 * 3600` (48h) | Hard ceiling enforced by contract |
|
|
436
467
|
|
|
437
468
|
The high-level `client.actions.createMarket` makes `challengePeriod`
|
|
@@ -441,14 +472,14 @@ client-side before the tx is built.
|
|
|
441
472
|
|
|
442
473
|
### Six new error codes
|
|
443
474
|
|
|
444
|
-
| Code
|
|
445
|
-
|
|
|
446
|
-
| `6036` | `InvalidChallengePeriod`
|
|
447
|
-
| `6037` | `NotPendingResolution`
|
|
448
|
-
| `6038` | `ChallengePeriodNotElapsed` | finalize called too early
|
|
449
|
-
| `6039` | `ChallengePeriodElapsed`
|
|
450
|
-
| `6040` | `MarketDisputed`
|
|
451
|
-
| `6041` | `MarketNotDisputed`
|
|
475
|
+
| Code | Name | When |
|
|
476
|
+
| ------ | --------------------------- | ------------------------------------- |
|
|
477
|
+
| `6036` | `InvalidChallengePeriod` | `challengePeriod` outside 24h–48h |
|
|
478
|
+
| `6037` | `NotPendingResolution` | flag/finalize/override on wrong state |
|
|
479
|
+
| `6038` | `ChallengePeriodNotElapsed` | finalize called too early |
|
|
480
|
+
| `6039` | `ChallengePeriodElapsed` | flag called after window closed |
|
|
481
|
+
| `6040` | `MarketDisputed` | finalize on a flagged market |
|
|
482
|
+
| `6041` | `MarketNotDisputed` | admin override on a clean market |
|
|
452
483
|
|
|
453
484
|
Use `parseCypherError(err)` to extract a typed `CypherErrorCode` for
|
|
454
485
|
branching.
|
|
@@ -498,7 +529,7 @@ function MarketView({ marketId }: { marketId: bigint }) {
|
|
|
498
529
|
});
|
|
499
530
|
|
|
500
531
|
if (isLoading) return <p>Loading market…</p>;
|
|
501
|
-
if (!market)
|
|
532
|
+
if (!market) return <p>Market not found.</p>;
|
|
502
533
|
|
|
503
534
|
return (
|
|
504
535
|
<div>
|
|
@@ -518,7 +549,9 @@ function MarketView({ marketId }: { marketId: bigint }) {
|
|
|
518
549
|
>
|
|
519
550
|
{placeBet.isPending && stage ? `Bet → ${stage.stage}` : "Bet $5 YES"}
|
|
520
551
|
</button>
|
|
521
|
-
{placeBet.error &&
|
|
552
|
+
{placeBet.error && (
|
|
553
|
+
<p style={{ color: "crimson" }}>{placeBet.error.message}</p>
|
|
554
|
+
)}
|
|
522
555
|
</div>
|
|
523
556
|
);
|
|
524
557
|
}
|
|
@@ -526,22 +559,22 @@ function MarketView({ marketId }: { marketId: bigint }) {
|
|
|
526
559
|
|
|
527
560
|
### Available hooks
|
|
528
561
|
|
|
529
|
-
| Hook
|
|
530
|
-
|
|
|
531
|
-
| `useGlobalState()`
|
|
532
|
-
| `useMarket(id)`
|
|
533
|
-
| `useMarkets(filter?)`
|
|
534
|
-
| `useUserPositions(user)`
|
|
535
|
-
| `usePlaceBet()`
|
|
536
|
-
| `useCreateMarket()`
|
|
537
|
-
| `useResolveMarket()`
|
|
538
|
-
| `useClaimPayout()`
|
|
539
|
-
| `useClaimRefund()`
|
|
540
|
-
| `useCancelMarket()`
|
|
541
|
-
| `useFlagResolution()`
|
|
542
|
-
| `useFinalizeResolution()`
|
|
543
|
-
| `useAdminOverrideResolution()`
|
|
544
|
-
| `useMarketEvents()`
|
|
562
|
+
| Hook | Kind | Description |
|
|
563
|
+
| --------------------------------------- | ------------ | ----------------------------------------------------------------- |
|
|
564
|
+
| `useGlobalState()` | Query | Protocol config (fees, mint, admin, counter) |
|
|
565
|
+
| `useMarket(id)` | Query | Single market by ID |
|
|
566
|
+
| `useMarkets(filter?)` | Query | All/filtered markets (creator, state) |
|
|
567
|
+
| `useUserPositions(user)` | Query | All bet positions for a user |
|
|
568
|
+
| `usePlaceBet()` | Mutation | End-to-end private bet |
|
|
569
|
+
| `useCreateMarket()` | Mutation | Create a new market |
|
|
570
|
+
| `useResolveMarket()` | Mutation | Submit outcome + await reveal |
|
|
571
|
+
| `useClaimPayout()` | Mutation | Claim winning payout |
|
|
572
|
+
| `useClaimRefund()` | Mutation | Claim refund on unresolved market |
|
|
573
|
+
| `useCancelMarket()` | Mutation | Cancel a zero-bet market |
|
|
574
|
+
| `useFlagResolution()` _(v0.2)_ | Mutation | Flag a pending resolution during the challenge window |
|
|
575
|
+
| `useFinalizeResolution()` _(v0.2)_ | Mutation | Finalize a pending resolution after the window elapses undisputed |
|
|
576
|
+
| `useAdminOverrideResolution()` _(v0.2)_ | Mutation | Admin re-resolves a disputed market |
|
|
577
|
+
| `useMarketEvents()` | Subscription | Live event stream (component-scoped) |
|
|
545
578
|
|
|
546
579
|
Mutation hooks auto-invalidate the relevant query keys on success. Read
|
|
547
580
|
hooks expose their `queryKey` factories (`marketKeys.one(id)`,
|
|
@@ -597,11 +630,11 @@ The SDK is **cluster-agnostic at runtime**: it reads the accepted SPL mint
|
|
|
597
630
|
from `GlobalState.accepted_mint` on every flow rather than hard-coding
|
|
598
631
|
CSDC vs USDC. The same build works against any Cypher deployment.
|
|
599
632
|
|
|
600
|
-
| Cluster
|
|
601
|
-
|
|
|
602
|
-
| `devnet`
|
|
603
|
-
| `mainnet`
|
|
604
|
-
| `localnet` | `localhost:8899`
|
|
633
|
+
| Cluster | RPC default | Accepted mint | Arcium offset |
|
|
634
|
+
| ---------- | ----------------------------- | ------------------ | --------------- |
|
|
635
|
+
| `devnet` | `api.devnet.solana.com` | CSDC (`8AF9BABN…`) | `456` |
|
|
636
|
+
| `mainnet` | `api.mainnet-beta.solana.com` | USDC (`EPjFWdd5…`) | (set at deploy) |
|
|
637
|
+
| `localnet` | `localhost:8899` | CSDC (test build) | `1116522022` |
|
|
605
638
|
|
|
606
639
|
```ts
|
|
607
640
|
// Explicit preset:
|
|
@@ -624,17 +657,17 @@ const client = new CypherClient({
|
|
|
624
657
|
|
|
625
658
|
## Scripts
|
|
626
659
|
|
|
627
|
-
| Command
|
|
628
|
-
|
|
|
629
|
-
| `bun install`
|
|
630
|
-
| `bun test`
|
|
631
|
-
| `bun run test:unit`
|
|
632
|
-
| `bun run test:integration` | `INTEGRATION=1` — Arcium localnet lifecycle
|
|
633
|
-
| `bun run test:devnet`
|
|
634
|
-
| `bun run typecheck`
|
|
635
|
-
| `bun run build`
|
|
636
|
-
| `bun run sync:idl`
|
|
637
|
-
| `bun run prepublishOnly`
|
|
660
|
+
| Command | Purpose |
|
|
661
|
+
| -------------------------- | --------------------------------------------- |
|
|
662
|
+
| `bun install` | Install deps |
|
|
663
|
+
| `bun test` | All unit suites (gates skipped) |
|
|
664
|
+
| `bun run test:unit` | Unit-only |
|
|
665
|
+
| `bun run test:integration` | `INTEGRATION=1` — Arcium localnet lifecycle |
|
|
666
|
+
| `bun run test:devnet` | `DEVNET=1` — devnet read-only + opt-in writes |
|
|
667
|
+
| `bun run typecheck` | `tsc --noEmit` (strict) |
|
|
668
|
+
| `bun run build` | ESM + `.d.ts` via tsup → `dist/` |
|
|
669
|
+
| `bun run sync:idl` | Re-copy IDL + types from `../cypher-main` |
|
|
670
|
+
| `bun run prepublishOnly` | sync IDL → typecheck → unit tests → build |
|
|
638
671
|
|
|
639
672
|
---
|
|
640
673
|
|
|
@@ -674,7 +707,7 @@ The SDK adds defense-in-depth client-side:
|
|
|
674
707
|
|
|
675
708
|
- **NEW**: 3 instructions (`flagResolution`, `finalizeResolution`,
|
|
676
709
|
`adminOverrideResolution`) + 3 actions + 3 React hooks + 3 events
|
|
677
|
-
|
|
710
|
+
- 6 error codes (6036–6041).
|
|
678
711
|
- **NEW**: `MarketState.PendingResolution = 4` and three new
|
|
679
712
|
`marketPhase` values: `pendingResolution`, `awaitingFinalize`,
|
|
680
713
|
`disputed`.
|
|
@@ -178,8 +178,13 @@ declare const CLUSTERS: Record<ClusterName, ClusterConfig>;
|
|
|
178
178
|
declare const ACCOUNT_DISCRIMINATOR_SIZE = 8;
|
|
179
179
|
/** Minimum bet size: $1 USDC in lamports (1e6 micro-units). */
|
|
180
180
|
declare const MIN_BET_USDC = 1000000n;
|
|
181
|
-
/**
|
|
182
|
-
|
|
181
|
+
/**
|
|
182
|
+
* Minimum creator bond: $20 USDC/CSDC.
|
|
183
|
+
* The creator may deposit any amount >= this value at market creation.
|
|
184
|
+
* The actual bond is stored per-market in `MarketAccount.creatorBond`.
|
|
185
|
+
* @deprecated `CREATOR_BOND` (the old $10 fixed constant) is removed upstream — use `MIN_CREATOR_BOND`.
|
|
186
|
+
*/
|
|
187
|
+
declare const MIN_CREATOR_BOND = 20000000n;
|
|
183
188
|
/**
|
|
184
189
|
* Window after `close_time` during which the designated resolver may submit
|
|
185
190
|
* an outcome. After this elapses, the market is eligible for refunds.
|
|
@@ -1841,6 +1846,10 @@ type Cypher = {
|
|
|
1841
1846
|
{
|
|
1842
1847
|
"name": "challengePeriod";
|
|
1843
1848
|
"type": "i64";
|
|
1849
|
+
},
|
|
1850
|
+
{
|
|
1851
|
+
"name": "bondAmount";
|
|
1852
|
+
"type": "u64";
|
|
1844
1853
|
}
|
|
1845
1854
|
];
|
|
1846
1855
|
},
|
|
@@ -2010,6 +2019,10 @@ type Cypher = {
|
|
|
2010
2019
|
{
|
|
2011
2020
|
"name": "challengePeriod";
|
|
2012
2021
|
"type": "i64";
|
|
2022
|
+
},
|
|
2023
|
+
{
|
|
2024
|
+
"name": "bondAmount";
|
|
2025
|
+
"type": "u64";
|
|
2013
2026
|
}
|
|
2014
2027
|
];
|
|
2015
2028
|
},
|
|
@@ -4159,26 +4172,31 @@ type Cypher = {
|
|
|
4159
4172
|
},
|
|
4160
4173
|
{
|
|
4161
4174
|
"code": 6037;
|
|
4175
|
+
"name": "bondTooSmall";
|
|
4176
|
+
"msg": "Creator bond is below the protocol minimum";
|
|
4177
|
+
},
|
|
4178
|
+
{
|
|
4179
|
+
"code": 6038;
|
|
4162
4180
|
"name": "notPendingResolution";
|
|
4163
4181
|
"msg": "Market is not pending resolution";
|
|
4164
4182
|
},
|
|
4165
4183
|
{
|
|
4166
|
-
"code":
|
|
4184
|
+
"code": 6039;
|
|
4167
4185
|
"name": "challengePeriodNotElapsed";
|
|
4168
4186
|
"msg": "Challenge period has not elapsed yet";
|
|
4169
4187
|
},
|
|
4170
4188
|
{
|
|
4171
|
-
"code":
|
|
4189
|
+
"code": 6040;
|
|
4172
4190
|
"name": "challengePeriodElapsed";
|
|
4173
4191
|
"msg": "Challenge period has already elapsed";
|
|
4174
4192
|
},
|
|
4175
4193
|
{
|
|
4176
|
-
"code":
|
|
4194
|
+
"code": 6041;
|
|
4177
4195
|
"name": "marketDisputed";
|
|
4178
4196
|
"msg": "Market resolution is disputed — admin must override";
|
|
4179
4197
|
},
|
|
4180
4198
|
{
|
|
4181
|
-
"code":
|
|
4199
|
+
"code": 6042;
|
|
4182
4200
|
"name": "marketNotDisputed";
|
|
4183
4201
|
"msg": "Market resolution is not disputed";
|
|
4184
4202
|
}
|
|
@@ -6255,7 +6273,7 @@ declare function buildAllInitCompDefIx(client: CypherClient, params: InitCompDef
|
|
|
6255
6273
|
}>>;
|
|
6256
6274
|
|
|
6257
6275
|
interface CreateMarketParams {
|
|
6258
|
-
/** Creator (and signer) — also pays the
|
|
6276
|
+
/** Creator (and signer) — also pays the bond. */
|
|
6259
6277
|
creator: PublicKey;
|
|
6260
6278
|
/** Pinned accepted mint — read from `GlobalState.accepted_mint`. */
|
|
6261
6279
|
acceptedMint: PublicKey;
|
|
@@ -6279,6 +6297,13 @@ interface CreateMarketParams {
|
|
|
6279
6297
|
* `PendingResolution` for this long, during which anyone can flag.
|
|
6280
6298
|
*/
|
|
6281
6299
|
challengePeriod: bigint | number;
|
|
6300
|
+
/**
|
|
6301
|
+
* Creator bond in micro-USDC/CSDC (u64). Must be ≥ `MIN_CREATOR_BOND`
|
|
6302
|
+
* ($20 USDC). No upper bound — creators may lock more to signal
|
|
6303
|
+
* commitment. Stored per-market in `MarketAccount.creatorBond` and
|
|
6304
|
+
* returned via `withdrawCreatorFunds` after resolution.
|
|
6305
|
+
*/
|
|
6306
|
+
bondAmount: bigint | number;
|
|
6282
6307
|
}
|
|
6283
6308
|
/**
|
|
6284
6309
|
* Build a `create_market` instruction (YesNo).
|
|
@@ -6524,16 +6549,19 @@ interface CreateMarketResult {
|
|
|
6524
6549
|
market: MarketAccount | null;
|
|
6525
6550
|
}
|
|
6526
6551
|
/** Create a YES/NO market end-to-end. */
|
|
6527
|
-
declare function createMarketAction(client: CypherClient, inputs: Omit<CreateMarketParams, "expectedMarketId" | "acceptedMint" | "challengePeriod"> & {
|
|
6552
|
+
declare function createMarketAction(client: CypherClient, inputs: Omit<CreateMarketParams, "expectedMarketId" | "acceptedMint" | "challengePeriod" | "bondAmount"> & {
|
|
6528
6553
|
acceptedMint?: PublicKey;
|
|
6529
6554
|
/** v0.2+: defaults to MIN_CHALLENGE_PERIOD_SECS (24h) if omitted. */
|
|
6530
6555
|
challengePeriod?: bigint | number;
|
|
6556
|
+
/** Defaults to MIN_CREATOR_BOND ($20 USDC). Pass a larger value to signal stronger commitment. */
|
|
6557
|
+
bondAmount?: bigint | number;
|
|
6531
6558
|
onProgress?: ProgressCallback;
|
|
6532
6559
|
}): Promise<CreateMarketResult>;
|
|
6533
6560
|
/** Create a multi-outcome market (2–4 outcomes) end-to-end. */
|
|
6534
|
-
declare function createMarketMultiAction(client: CypherClient, inputs: Omit<CreateMarketMultiParams, "expectedMarketId" | "acceptedMint" | "challengePeriod"> & {
|
|
6561
|
+
declare function createMarketMultiAction(client: CypherClient, inputs: Omit<CreateMarketMultiParams, "expectedMarketId" | "acceptedMint" | "challengePeriod" | "bondAmount"> & {
|
|
6535
6562
|
acceptedMint?: PublicKey;
|
|
6536
6563
|
challengePeriod?: bigint | number;
|
|
6564
|
+
bondAmount?: bigint | number;
|
|
6537
6565
|
onProgress?: ProgressCallback;
|
|
6538
6566
|
}): Promise<CreateMarketResult>;
|
|
6539
6567
|
/** Cancel a market that has no bets. Returns the post-cancel `Market`. */
|
|
@@ -6930,15 +6958,18 @@ declare class CypherClient {
|
|
|
6930
6958
|
*/
|
|
6931
6959
|
readonly actions: {
|
|
6932
6960
|
/** Create a YES/NO market. Fetches GlobalState for marketId + mint automatically. */
|
|
6933
|
-
createMarket: (inputs: Omit<CreateMarketParams, "expectedMarketId" | "acceptedMint" | "challengePeriod"> & {
|
|
6961
|
+
createMarket: (inputs: Omit<CreateMarketParams, "expectedMarketId" | "acceptedMint" | "challengePeriod" | "bondAmount"> & {
|
|
6934
6962
|
acceptedMint?: PublicKey;
|
|
6935
6963
|
/** v0.2+: defaults to MIN_CHALLENGE_PERIOD_SECS (24h) if omitted. */
|
|
6936
6964
|
challengePeriod?: bigint | number;
|
|
6965
|
+
/** Defaults to MIN_CREATOR_BOND ($20 USDC). Pass a larger amount to signal commitment. */
|
|
6966
|
+
bondAmount?: bigint | number;
|
|
6937
6967
|
}) => Promise<CreateMarketResult>;
|
|
6938
6968
|
/** Create a multi-outcome market (2–4 outcomes). */
|
|
6939
|
-
createMarketMulti: (inputs: Omit<CreateMarketMultiParams, "expectedMarketId" | "acceptedMint" | "challengePeriod"> & {
|
|
6969
|
+
createMarketMulti: (inputs: Omit<CreateMarketMultiParams, "expectedMarketId" | "acceptedMint" | "challengePeriod" | "bondAmount"> & {
|
|
6940
6970
|
acceptedMint?: PublicKey;
|
|
6941
6971
|
challengePeriod?: bigint | number;
|
|
6972
|
+
bondAmount?: bigint | number;
|
|
6942
6973
|
}) => Promise<CreateMarketResult>;
|
|
6943
6974
|
/** Cancel a market with zero bets. Returns bond to creator. */
|
|
6944
6975
|
cancelMarket: (inputs: Omit<CancelMarketParams, "acceptedMint"> & {
|
|
@@ -7046,4 +7077,4 @@ declare class CypherClient {
|
|
|
7046
7077
|
constructor(opts: CypherClientOptions);
|
|
7047
7078
|
}
|
|
7048
7079
|
|
|
7049
|
-
export {
|
|
7080
|
+
export { type LpPositionAccount as $, type AdminOverrideResolutionInputs as A, BPS_DENOMINATOR as B, CypherClient as C, type ComputationResult as D, type EncryptedPositionAccount as E, type FinalizeResolutionInputs as F, type GlobalStateAccount as G, type CreateMarketMultiParams as H, type CreatorWithdrawnEvent as I, type CypherClientOptions as J, type CypherEventName as K, DEFAULT_CLAIM_PERIOD_SECS as L, type MarketAccount as M, DEFAULT_REFUND_PERIOD_SECS as N, DEFAULT_RESOLUTION_WINDOW_SECS as O, type PlaceBetResult as P, type EventCallback as Q, type ResolutionActionResult as R, type SubscribeOptions as S, type EventSubscription as T, type FinalizeResolutionParams as U, type FlagResolutionParams as V, INIT_COMP_DEF_INSTRUCTIONS as W, type InitCompDefMethodName as X, type InitCompDefParams as Y, type InitializeParams as Z, KNOWN_MINTS as _, type CancelMarketParams as a, fetchMarketsByState as a$, MAX_CHALLENGE_PERIOD_SECS as a0, MAX_LP_FEE_BPS as a1, MAX_OUTCOMES_MULTI as a2, MAX_PROTOCOL_FEE_BPS as a3, MAX_QUESTION_BYTES as a4, MIN_BET_USDC as a5, MIN_CHALLENGE_PERIOD_SECS as a6, MIN_CREATOR_BOND as a7, MIN_OUTCOMES_MULTI as a8, type MarketCancelledEvent as a9, adminOverrideResolutionAction as aA, adminOverrideResolutionIx as aB, awaitComputation as aC, buildAllInitCompDefIx as aD, cancelMarketAction as aE, cancelMarketIx as aF, claimPayoutAction as aG, claimPayoutMultiIx as aH, claimPayoutYesnoIx as aI, claimRefundAction as aJ, claimRefundMultiIx as aK, claimRefundYesnoIx as aL, compDefOffsetBytes as aM, compDefOffsetU32 as aN, createCipher as aO, createMarketAction as aP, createMarketIx as aQ, createMarketMultiAction as aR, createMarketMultiIx as aS, createUserKeypair as aT, deriveSharedSecret as aU, fetchAllMarkets as aV, fetchGlobalState as aW, fetchLpPosition as aX, fetchLpPositionsByProvider as aY, fetchMarket as aZ, fetchMarketsByCreator as a_, MarketCategory as aa, type MarketCategoryValue as ab, type MarketCreatedEvent as ac, type MarketFinalizedEvent as ad, type MarketResolvedEvent as ae, MarketState as af, type MarketStateValue as ag, MarketType as ah, type MarketTypeValue as ai, ODDS_SCALE as aj, PROGRAM_ID as ak, type PayoutClaimedEvent as al, type PlacePrivateBetParams as am, type PollEventsOptions as an, type PolledEvent as ao, type ProgressCallback as ap, type RefundClaimedEvent as aq, type ResolutionFlaggedEvent as ar, type ResolutionOverriddenEvent as as, type ResolveMarketParams as at, type SendIxOptions as au, type UpdateAcceptedMintParams as av, type UserCryptoKeypair as aw, type Wallet as ax, type WithdrawCreatorFundsParams as ay, adminClaimRemainingIx as az, type ClaimResult as b, fetchMxePublicKey as b0, fetchPosition as b1, fetchPositionsForMarket as b2, fetchUserPositions as b3, finalizeResolutionAction as b4, finalizeResolutionIx as b5, flagResolutionAction as b6, flagResolutionIx as b7, freshNonce as b8, initCompDefIx as b9, subscribeAll as bA, subscribeEvent as bB, updateAcceptedMintIx as bC, withdrawCreatorFundsAction as bD, withdrawCreatorFundsIx as bE, initializeIx as ba, keypairToWallet as bb, leBytesToBigInt as bc, onBetPlaced as bd, onCreatorWithdrawn as be, onMarketCancelled as bf, onMarketCreated as bg, onMarketFinalized as bh, onMarketResolved as bi, onPayoutClaimed as bj, onRefundClaimed as bk, onResolutionFlagged as bl, onResolutionOverridden as bm, parseLogs as bn, parseLogsFor as bo, placeBetAction as bp, placePrivateBetMultiIx as bq, placePrivateBetYesnoIx as br, pollEvents as bs, randomComputationOffset as bt, readonlyWallet as bu, resolveMarketAction as bv, resolveMarketMultiIx as bw, resolveMarketYesnoIx as bx, sendIx as by, sendIxAndAwaitArcium as bz, type ClaimInputs as c, type CreateMarketResult as d, type CreateMarketParams as e, type FlagResolutionInputs as f, type PlaceBetInputs as g, type ResolveMarketResult as h, type ResolveMarketInputs as i, type CypherEvent as j, type Cypher as k, type CircuitName as l, ACCOUNT_DISCRIMINATOR_SIZE as m, ALL_CIRCUITS as n, ALL_EVENT_NAMES as o, type ActionProgressEvent as p, type ActionStage as q, type AdminClaimRemainingParams as r, type AdminOverrideResolutionParams as s, type AwaitComputationOptions as t, type BetPlacedEvent as u, CIRCUITS as v, CLUSTERS as w, type ClaimParams as x, type ClusterConfig as y, type ClusterName as z };
|
|
@@ -1577,6 +1577,10 @@
|
|
|
1577
1577
|
{
|
|
1578
1578
|
"name": "challenge_period",
|
|
1579
1579
|
"type": "i64"
|
|
1580
|
+
},
|
|
1581
|
+
{
|
|
1582
|
+
"name": "bond_amount",
|
|
1583
|
+
"type": "u64"
|
|
1580
1584
|
}
|
|
1581
1585
|
]
|
|
1582
1586
|
},
|
|
@@ -1746,6 +1750,10 @@
|
|
|
1746
1750
|
{
|
|
1747
1751
|
"name": "challenge_period",
|
|
1748
1752
|
"type": "i64"
|
|
1753
|
+
},
|
|
1754
|
+
{
|
|
1755
|
+
"name": "bond_amount",
|
|
1756
|
+
"type": "u64"
|
|
1749
1757
|
}
|
|
1750
1758
|
]
|
|
1751
1759
|
},
|
|
@@ -3895,26 +3903,31 @@
|
|
|
3895
3903
|
},
|
|
3896
3904
|
{
|
|
3897
3905
|
"code": 6037,
|
|
3906
|
+
"name": "BondTooSmall",
|
|
3907
|
+
"msg": "Creator bond is below the protocol minimum"
|
|
3908
|
+
},
|
|
3909
|
+
{
|
|
3910
|
+
"code": 6038,
|
|
3898
3911
|
"name": "NotPendingResolution",
|
|
3899
3912
|
"msg": "Market is not pending resolution"
|
|
3900
3913
|
},
|
|
3901
3914
|
{
|
|
3902
|
-
"code":
|
|
3915
|
+
"code": 6039,
|
|
3903
3916
|
"name": "ChallengePeriodNotElapsed",
|
|
3904
3917
|
"msg": "Challenge period has not elapsed yet"
|
|
3905
3918
|
},
|
|
3906
3919
|
{
|
|
3907
|
-
"code":
|
|
3920
|
+
"code": 6040,
|
|
3908
3921
|
"name": "ChallengePeriodElapsed",
|
|
3909
3922
|
"msg": "Challenge period has already elapsed"
|
|
3910
3923
|
},
|
|
3911
3924
|
{
|
|
3912
|
-
"code":
|
|
3925
|
+
"code": 6041,
|
|
3913
3926
|
"name": "MarketDisputed",
|
|
3914
3927
|
"msg": "Market resolution is disputed — admin must override"
|
|
3915
3928
|
},
|
|
3916
3929
|
{
|
|
3917
|
-
"code":
|
|
3930
|
+
"code": 6042,
|
|
3918
3931
|
"name": "MarketNotDisputed",
|
|
3919
3932
|
"msg": "Market resolution is not disputed"
|
|
3920
3933
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { k as Cypher, C as CypherClient, l as CircuitName } from './client-
|
|
2
|
-
export { m as ACCOUNT_DISCRIMINATOR_SIZE, n as ALL_CIRCUITS, o as ALL_EVENT_NAMES, p as ActionProgressEvent, q as ActionStage, r as AdminClaimRemainingParams, A as AdminOverrideResolutionInputs, s as AdminOverrideResolutionParams, t as AwaitComputationOptions, B as BPS_DENOMINATOR, u as BetPlacedEvent, v as CIRCUITS, w as CLUSTERS,
|
|
1
|
+
import { k as Cypher, C as CypherClient, l as CircuitName } from './client-sr7mY_Wj.js';
|
|
2
|
+
export { m as ACCOUNT_DISCRIMINATOR_SIZE, n as ALL_CIRCUITS, o as ALL_EVENT_NAMES, p as ActionProgressEvent, q as ActionStage, r as AdminClaimRemainingParams, A as AdminOverrideResolutionInputs, s as AdminOverrideResolutionParams, t as AwaitComputationOptions, B as BPS_DENOMINATOR, u as BetPlacedEvent, v as CIRCUITS, w as CLUSTERS, a as CancelMarketParams, c as ClaimInputs, x as ClaimParams, b as ClaimResult, y as ClusterConfig, z as ClusterName, D as ComputationResult, H as CreateMarketMultiParams, e as CreateMarketParams, d as CreateMarketResult, I as CreatorWithdrawnEvent, J as CypherClientOptions, j as CypherEvent, K as CypherEventName, L as DEFAULT_CLAIM_PERIOD_SECS, N as DEFAULT_REFUND_PERIOD_SECS, O as DEFAULT_RESOLUTION_WINDOW_SECS, E as EncryptedPositionAccount, Q as EventCallback, T as EventSubscription, F as FinalizeResolutionInputs, U as FinalizeResolutionParams, f as FlagResolutionInputs, V as FlagResolutionParams, G as GlobalStateAccount, W as INIT_COMP_DEF_INSTRUCTIONS, X as InitCompDefMethodName, Y as InitCompDefParams, Z as InitializeParams, _ as KNOWN_MINTS, $ as LpPositionAccount, a0 as MAX_CHALLENGE_PERIOD_SECS, a1 as MAX_LP_FEE_BPS, a2 as MAX_OUTCOMES_MULTI, a3 as MAX_PROTOCOL_FEE_BPS, a4 as MAX_QUESTION_BYTES, a5 as MIN_BET_USDC, a6 as MIN_CHALLENGE_PERIOD_SECS, a7 as MIN_CREATOR_BOND, a8 as MIN_OUTCOMES_MULTI, M as MarketAccount, a9 as MarketCancelledEvent, aa as MarketCategory, ab as MarketCategoryValue, ac as MarketCreatedEvent, ad as MarketFinalizedEvent, ae as MarketResolvedEvent, af as MarketState, ag as MarketStateValue, ah as MarketType, ai as MarketTypeValue, aj as ODDS_SCALE, ak as PROGRAM_ID, al as PayoutClaimedEvent, g as PlaceBetInputs, P as PlaceBetResult, am as PlacePrivateBetParams, an as PollEventsOptions, ao as PolledEvent, ap as ProgressCallback, aq as RefundClaimedEvent, R as ResolutionActionResult, ar as ResolutionFlaggedEvent, as as ResolutionOverriddenEvent, i as ResolveMarketInputs, at as ResolveMarketParams, h as ResolveMarketResult, au as SendIxOptions, S as SubscribeOptions, av as UpdateAcceptedMintParams, aw as UserCryptoKeypair, ax as Wallet, ay as WithdrawCreatorFundsParams, az as adminClaimRemainingIx, aA as adminOverrideResolutionAction, aB as adminOverrideResolutionIx, aC as awaitComputation, aD as buildAllInitCompDefIx, aE as cancelMarketAction, aF as cancelMarketIx, aG as claimPayoutAction, aH as claimPayoutMultiIx, aI as claimPayoutYesnoIx, aJ as claimRefundAction, aK as claimRefundMultiIx, aL as claimRefundYesnoIx, aM as compDefOffsetBytes, aN as compDefOffsetU32, aO as createCipher, aP as createMarketAction, aQ as createMarketIx, aR as createMarketMultiAction, aS as createMarketMultiIx, aT as createUserKeypair, aU as deriveSharedSecret, aV as fetchAllMarkets, aW as fetchGlobalState, aX as fetchLpPosition, aY as fetchLpPositionsByProvider, aZ as fetchMarket, a_ as fetchMarketsByCreator, a$ as fetchMarketsByState, b0 as fetchMxePublicKey, b1 as fetchPosition, b2 as fetchPositionsForMarket, b3 as fetchUserPositions, b4 as finalizeResolutionAction, b5 as finalizeResolutionIx, b6 as flagResolutionAction, b7 as flagResolutionIx, b8 as freshNonce, b9 as initCompDefIx, ba as initializeIx, bb as keypairToWallet, bc as leBytesToBigInt, bd as onBetPlaced, be as onCreatorWithdrawn, bf as onMarketCancelled, bg as onMarketCreated, bh as onMarketFinalized, bi as onMarketResolved, bj as onPayoutClaimed, bk as onRefundClaimed, bl as onResolutionFlagged, bm as onResolutionOverridden, bn as parseLogs, bo as parseLogsFor, bp as placeBetAction, bq as placePrivateBetMultiIx, br as placePrivateBetYesnoIx, bs as pollEvents, bt as randomComputationOffset, bu as readonlyWallet, bv as resolveMarketAction, bw as resolveMarketMultiIx, bx as resolveMarketYesnoIx, by as sendIx, bz as sendIxAndAwaitArcium, bA as subscribeAll, bB as subscribeEvent, bC as updateAcceptedMintIx, bD as withdrawCreatorFundsAction, bE as withdrawCreatorFundsIx } from './client-sr7mY_Wj.js';
|
|
3
3
|
import { GetProgramAccountsFilter, PublicKey } from '@solana/web3.js';
|
|
4
4
|
import { BN } from '@anchor-lang/core';
|
|
5
5
|
import { RescueCipher } from '@arcium-hq/client';
|
|
@@ -401,11 +401,12 @@ declare const CypherErrorCode: {
|
|
|
401
401
|
readonly NotAcceptedMint: 6034;
|
|
402
402
|
readonly InvalidCategory: 6035;
|
|
403
403
|
readonly InvalidChallengePeriod: 6036;
|
|
404
|
-
readonly
|
|
405
|
-
readonly
|
|
406
|
-
readonly
|
|
407
|
-
readonly
|
|
408
|
-
readonly
|
|
404
|
+
readonly BondTooSmall: 6037;
|
|
405
|
+
readonly NotPendingResolution: 6038;
|
|
406
|
+
readonly ChallengePeriodNotElapsed: 6039;
|
|
407
|
+
readonly ChallengePeriodElapsed: 6040;
|
|
408
|
+
readonly MarketDisputed: 6041;
|
|
409
|
+
readonly MarketNotDisputed: 6042;
|
|
409
410
|
};
|
|
410
411
|
type CypherErrorName = keyof typeof CypherErrorCode;
|
|
411
412
|
type CypherErrorCodeValue = (typeof CypherErrorCode)[keyof typeof CypherErrorCode];
|