@vercora-protocol/sdk 0.0.20 → 0.0.21
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/CHANGELOG.md +7 -0
- package/README.md +61 -13
- package/agents/skill.md +13 -4
- package/dist/client.d.ts +22 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +146 -7
- package/dist/client.js.map +1 -1
- package/dist/generated/vercora.d.ts +2214 -1024
- package/dist/generated/vercora.d.ts.map +1 -1
- package/dist/idl/vercora.json +2221 -1031
- package/dist/pda.d.ts +4 -0
- package/dist/pda.d.ts.map +1 -1
- package/dist/pda.js +7 -1
- package/dist/pda.js.map +1 -1
- package/dist/types.d.ts +36 -4
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,13 @@ All notable changes to `@vercora-protocol/sdk` are documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
7
|
|
|
8
|
+
### [0.0.21](https://github.com/vercora/vercora-anchor/compare/v0.0.20...v0.0.21) (2026-04-17)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **all:** add bonded staked vote ([d7dc0c3](https://github.com/vercora/vercora-anchor/commit/d7dc0c3d22b6ab005a0be6a17bc6922d7a1da266))
|
|
14
|
+
|
|
8
15
|
### [0.0.20](https://github.com/vercora/vercora-anchor/compare/v0.0.19...v0.0.20) (2026-04-16)
|
|
9
16
|
|
|
10
17
|
|
package/README.md
CHANGED
|
@@ -47,7 +47,7 @@ Most transaction methods use **`provider.wallet.publicKey`** as the signer (`use
|
|
|
47
47
|
| `types` | Params and account shapes (`CreateMarketParams`, `ListedMarket`, …). |
|
|
48
48
|
| `marketUi` | Pure UI helpers (`getMarketLifecycleStatus`, `formatTimeLeft`, …). |
|
|
49
49
|
| `Vercora` (type) | Anchor `Program` generic for `Program<Vercora>`. |
|
|
50
|
-
| `agents/skill.md` | Short **AI agent entrypoint** (production: `https://vercora.xyz/agents/skill.md`). |
|
|
50
|
+
| `agents/skill.md` | Short **AI agent entrypoint** (production: `https://vercora.xyz/agents/skill.md`). Human UI with the same resolution narrative: **`https://vercora.xyz/docs/agents`**. |
|
|
51
51
|
|
|
52
52
|
---
|
|
53
53
|
|
|
@@ -86,7 +86,7 @@ Public properties: **`program`**, **`connection`**, **`globalConfig`** (PDA).
|
|
|
86
86
|
| `createMarketFull(creator, collateralMint, creatorFeeAccount, resolverPubkeys, params)` | Runs create → outcomes → resolvers (+ mints **or** pari state in one flow). |
|
|
87
87
|
| `updateParimutuelState(marketPda, params)` | Creator updates penalty split, **`isEarlyWithdrawAllowed`**, **`maxWalletOutcomeInvestment`**, and **`isWalletOutcomeStakeExact`** (open pari pool). |
|
|
88
88
|
|
|
89
|
-
**`CreateMarketParams` (pari-mutuel):** optional **`isEarlyWithdrawAllowed`** (default **`true`**). Optional **`maxWalletOutcomeInvestment`** (`BN`, **`0`** = unlimited per-wallet per-outcome net stake cap in collateral base units). Optional **`isWalletOutcomeStakeExact`**: when **`true`** (parimutuel only), each stake must bring the wallet’s net on that outcome to **exactly** `maxWalletOutcomeInvestment`; requires **`maxWalletOutcomeInvestment > 0`**. Setting exact mode on a complete-set market fails with **`InvalidWalletOutcomeStakeExactConfig`**. Ignored for complete-set markets otherwise.
|
|
89
|
+
**`CreateMarketParams`:** requires **`platformId`** (**`> 0`**, BN) with a registered platform + **`upsertPlatformProfile`** (resolver stake, challenge window, and refute bond are set on the profile — not per market). **`CreateMarketParams` (pari-mutuel):** optional **`isEarlyWithdrawAllowed`** (default **`true`**). Optional **`maxWalletOutcomeInvestment`** (`BN`, **`0`** = unlimited per-wallet per-outcome net stake cap in collateral base units). Optional **`isWalletOutcomeStakeExact`**: when **`true`** (parimutuel only), each stake must bring the wallet’s net on that outcome to **exactly** `maxWalletOutcomeInvestment`; requires **`maxWalletOutcomeInvestment > 0`**. Setting exact mode on a complete-set market fails with **`InvalidWalletOutcomeStakeExactConfig`**. Ignored for complete-set markets otherwise.
|
|
90
90
|
|
|
91
91
|
**`UpdateParimutuelStateParams`:** every call writes **all** fields — pass **current** values from **`fetchMarket`** / **`fetchParimutuelState`** for anything you are not changing. Includes **`earlyWithdrawPenaltyBps`**, **`penaltyKeptInPoolBps`**, **`isEarlyWithdrawAllowed`**, **`maxWalletOutcomeInvestment`**, **`isWalletOutcomeStakeExact`**. If **`isWalletOutcomeStakeExact`** is **`true`**, **`maxWalletOutcomeInvestment`** must be **> 0** (same rule as create). Use this to tighten or relax per-wallet caps and to toggle exact vs ceiling mode **after** launch (market must still be open and not resolved/voided).
|
|
92
92
|
|
|
@@ -112,14 +112,21 @@ When **`isEarlyWithdrawAllowed`** is **`false`**, early **`parimutuelWithdraw`**
|
|
|
112
112
|
|
|
113
113
|
| Method | Purpose |
|
|
114
114
|
| ----------------------------------------- | --------------------------------------------- |
|
|
115
|
-
| `voteResolution(marketPda, params)` | Resolver vote.
|
|
116
|
-
| `revokeResolutionVote(marketPda, params)` | Clear vote before changing.
|
|
117
|
-
| `finalizeResolution(marketPda, params)` |
|
|
115
|
+
| `voteResolution(marketPda, params)` | Resolver vote; may escrow **resolver stake** to the market’s resolver stake vault (see platform policy). |
|
|
116
|
+
| `revokeResolutionVote(marketPda, params)` | Clear vote before changing (blocked once a proposal exists). |
|
|
117
|
+
| `finalizeResolution(marketPda, params)` | When M-of-N agree on one outcome, **proposes** that outcome — sets `ResolutionState.proposed_outcome` + `proposal_ts`; does **not** set `Market.winning_outcome_index` yet. |
|
|
118
|
+
| `confirmResolution(marketPda, params)` | After the **challenge window** elapses with **no open dispute**, anyone can call this to set **`Market.winning_outcome_index`** (final approval / settlement). |
|
|
119
|
+
| `openRefute(marketPda, params)` | During the challenge window: post a **refute bond** and name an alternative winning outcome (dispute). |
|
|
120
|
+
| `resolveRefute(marketPda, params)` | Authority dismisses an open refute (signer: `GlobalConfig.dispute_resolution_authority`, or primary/secondary if unset, or platform `profileAuthority`). |
|
|
121
|
+
| `claimResolverStake(marketPda, params)` | After resolution: resolver claims stake back or protocol routes slash per rules. |
|
|
122
|
+
| `fetchResolutionState(marketPda)` | Read proposal, dispute, refute bond locked (`ResolutionState`). Challenge length and resolver stake size come from **`fetchPlatformProfile`**. |
|
|
118
123
|
| `closeMarketEarly(marketPda, params)` | Creator / config authority before `close_at`. |
|
|
119
124
|
| `voidMarket(marketPda, params)` | Void market. **Creator** cannot void while pari **outcome pools** (active stakes) or complete-set outstanding is non-zero — use a **global config** authority to cancel live markets. Parimutuel: then **`parimutuelWithdraw`** for full net refunds. |
|
|
120
125
|
| `claimVoidedParimutuelSurplus(marketPda, params)` | **Global config authority only.** After void, if pari **outcome pools** are zero but **`total_pool`** still holds early-exit **pool-keep** (no stakers left), sweeps that amount from the vault to the platform treasury. |
|
|
121
126
|
| `abandonMarket(marketPda, params)` | Creator abandons empty market (reclaim rent). |
|
|
122
127
|
|
|
128
|
+
See **[Resolution approval flow](#resolution-approval-flow-propose--challenge--confirm)** below for the full sequence and SDK usage.
|
|
129
|
+
|
|
123
130
|
### Discovery & reads
|
|
124
131
|
|
|
125
132
|
| Method | Purpose |
|
|
@@ -139,6 +146,7 @@ When **`isEarlyWithdrawAllowed`** is **`false`**, early **`parimutuelWithdraw`**
|
|
|
139
146
|
| `fetchMarketCategory(categoryPda)` | One category. |
|
|
140
147
|
| `fetchAllMarketCategories()` | All categories (sorted). |
|
|
141
148
|
| `fetchResolutionVote(marketPda, resolverIndex)` | Vote PDA or null. |
|
|
149
|
+
| `fetchResolutionState(marketPda)` | Proposal, dispute, refute bond (`ResolutionState` PDA). Use **`fetchPlatformProfile`** for challenge window and resolver stake. |
|
|
142
150
|
| `fetchMarketOutcomesSnapshot(marketPda, outcomeCount)` | Decoded outcomes + tallies. |
|
|
143
151
|
| `fetchOutcomeTallyCounts(marketPda)` | Quick tally array. |
|
|
144
152
|
| `fetchAllowedCollateralMints()` | Allowlist mints. |
|
|
@@ -216,7 +224,7 @@ const { marketPda } = await client.createMarket(
|
|
|
216
224
|
maxOutcomeInvestment: new BN(0),
|
|
217
225
|
title: "Will it rain tomorrow?",
|
|
218
226
|
marketType: "completeSet",
|
|
219
|
-
platformId: new BN(
|
|
227
|
+
platformId: new BN(1), // must be > 0 — register_platform + upsert_platform_profile first
|
|
220
228
|
categoryId: new BN(0),
|
|
221
229
|
},
|
|
222
230
|
);
|
|
@@ -254,6 +262,8 @@ const marketPda = await client.createMarketFull(
|
|
|
254
262
|
title: "Two-outcome market",
|
|
255
263
|
marketType: "completeSet",
|
|
256
264
|
outcomeLabels: ["Yes", "No"],
|
|
265
|
+
platformId: new BN(1),
|
|
266
|
+
categoryId: new BN(0),
|
|
257
267
|
},
|
|
258
268
|
);
|
|
259
269
|
```
|
|
@@ -278,6 +288,8 @@ const marketPda = await client.createMarketFull(
|
|
|
278
288
|
title: "Pari pool",
|
|
279
289
|
marketType: "parimutuel",
|
|
280
290
|
outcomeLabels: ["A", "B"],
|
|
291
|
+
platformId: new BN(1),
|
|
292
|
+
categoryId: new BN(0),
|
|
281
293
|
// Optional — default true. Set false to lock stakes until close/resolution (no early parimutuelWithdraw).
|
|
282
294
|
isEarlyWithdrawAllowed: true,
|
|
283
295
|
parimutuelInit: {
|
|
@@ -394,7 +406,9 @@ await client.updateParimutuelState(marketPda, {
|
|
|
394
406
|
|
|
395
407
|
Staking errors when caps apply: **`WalletOutcomeInvestmentCapExceeded`** (6050), **`WalletOutcomeExactStakeMismatch`** (6052) when exact mode is on, **`InvalidWalletOutcomeStakeExactConfig`** (6051) if exact mode is enabled with a zero cap (create or update).
|
|
396
408
|
|
|
397
|
-
### Resolution
|
|
409
|
+
### Resolution (minimal)
|
|
410
|
+
|
|
411
|
+
Resolvers vote, then **`finalizeResolution`** records a **proposal**. After the **challenge window**, if no dispute blocks confirmation, **`confirmResolution`** sets the final winner on the market account. See the full flow in the next section.
|
|
398
412
|
|
|
399
413
|
```ts
|
|
400
414
|
await client.voteResolution(marketPda, {
|
|
@@ -403,7 +417,11 @@ await client.voteResolution(marketPda, {
|
|
|
403
417
|
outcomeIndex: 1,
|
|
404
418
|
});
|
|
405
419
|
|
|
420
|
+
// Records proposed_outcome + proposal_ts when M-of-N threshold is met (not final settlement yet).
|
|
406
421
|
await client.finalizeResolution(marketPda, { marketId });
|
|
422
|
+
|
|
423
|
+
// After challenge_window_secs (and no open refute blocking), anyone confirms final outcome:
|
|
424
|
+
await client.confirmResolution(marketPda, { marketId });
|
|
407
425
|
```
|
|
408
426
|
|
|
409
427
|
### Discovery
|
|
@@ -438,15 +456,43 @@ const profile = await client.fetchUserProfile(wallet.publicKey);
|
|
|
438
456
|
|
|
439
457
|
---
|
|
440
458
|
|
|
459
|
+
## Resolution approval flow (propose → challenge → confirm)
|
|
460
|
+
|
|
461
|
+
Settlement is **two-phase**: first a **proposal** is recorded on `ResolutionState`, then — after an optional **challenge window** — the market is **approved** into a final winner on the `Market` account.
|
|
462
|
+
|
|
463
|
+
1. **Platform prerequisite** — `create_market` requires **`platform_id > 0`**: a registered **`PlatformRegistry`**, an initialized **`PlatformProfile`** (single **`resolver_stake`**, **`challenge_window_secs`**, **`refute_bond`** for that platform), and PDAs for **`resolution_state`** and **`resolver_stake_vault`**.
|
|
464
|
+
|
|
465
|
+
2. **Votes** — Each assigned resolver calls **`voteResolution`** with their outcome. Votes update per-outcome tallies; resolver **stake** (from **`PlatformProfile.resolver_stake`**) transfers into the market’s **resolver stake vault**.
|
|
466
|
+
|
|
467
|
+
3. **Propose (`finalizeResolution`)** — When at least **`resolution_threshold`** resolvers agree on the **same** outcome, anyone may call **`finalizeResolution`**. On-chain this **does not** immediately set `Market.winning_outcome_index`. It sets **`ResolutionState.proposed_outcome`**, **`proposal_ts`**, and starts the **challenge window** (duration from **`PlatformProfile.challenge_window_secs`**).
|
|
468
|
+
|
|
469
|
+
4. **Challenge window** — Until **`proposal_ts + challenge_window_secs`** elapses, a participant may **`openRefute`** with **exactly** **`platform_profile.refute_bond`**: lock that collateral and assert a **different** winning outcome. An authorized party (global **dispute resolution authority**, or platform **profile authority** when configured) may **`resolveRefute`** to dismiss a refute. While a dispute is active, **`confirmResolution`** is rejected.
|
|
470
|
+
|
|
471
|
+
5. **Confirm (final approval)** — After **`proposal_ts + challenge_window`**, if there is **no** blocking dispute, anyone calls **`confirmResolution`**. This writes **`Market.winning_outcome_index`** — the outcome is now final for **`redeemWinning`** / **`parimutuelClaim`**.
|
|
472
|
+
|
|
473
|
+
6. **Resolver stake** — After settlement, resolvers use **`claimResolverStake`** to recover escrowed stake or accept protocol routing of bonds per rules.
|
|
474
|
+
|
|
475
|
+
**Reads**
|
|
476
|
+
|
|
477
|
+
- **`fetchResolutionState(marketPda)`** — `proposed_outcome`, `proposal_ts`, `dispute_active`, `refute_bond_amount`, etc.
|
|
478
|
+
- **`fetchPlatformProfile(platformId)`** — `challenge_window_secs`, `resolver_stake`, `refute_bond` (challenge length and stake are not stored on `ResolutionState`).
|
|
479
|
+
- **`fetchMarket(marketPda)`** — `winningOutcomeIndex` is **`null`** until **`confirmResolution`** succeeds.
|
|
480
|
+
|
|
481
|
+
**UI / agent logic**
|
|
482
|
+
|
|
483
|
+
- Treat **`finalizeResolution`** as “proposal passed”; show countdown until **`confirmResolution`** is allowed.
|
|
484
|
+
- Gate “resolved” UX on **`winningOutcomeIndex !== null`**, not on proposal alone.
|
|
485
|
+
|
|
441
486
|
## Platforms and categories
|
|
442
487
|
|
|
443
488
|
On-chain, **`platform_id`** is **`u32`** and **`category_id`** is **`u8`** in `CreateMarketArgs` (not pubkeys).
|
|
444
489
|
|
|
445
|
-
1. **`register_platform`** — assigns the next id from `GlobalConfig.next_platform_id
|
|
446
|
-
2. **`
|
|
447
|
-
3. **`
|
|
490
|
+
1. **`register_platform`** — assigns the next id from `GlobalConfig.next_platform_id` (starts at **1**); PDA `["platform", platform_id le u32]`.
|
|
491
|
+
2. **`upsert_platform_profile`** — metadata + **resolution policy** (`resolver_stake`, `challenge_window_secs`, `refute_bond`).
|
|
492
|
+
3. **`create_market_category`** — `category_id` must equal `PlatformRegistry.next_category_id`; PDA `["market-category", platform_id, category_id]`.
|
|
493
|
+
4. **`create_market`** — requires **`platform_id > 0`**, **`platform_registry`**, **`platform_profile`**, **`resolution_state`**, **`resolver_stake_vault`**. Use **`category_id == 0`** for uncategorized markets (omit **`market_category`** account). Non-zero **`category_id`** requires an active **`market_category`** PDA for that platform.
|
|
448
494
|
|
|
449
|
-
Use **`derivePlatformRegistry`**, **`derivePlatformProfile`**, **`deriveMarketCategory`** when building instructions manually.
|
|
495
|
+
Use **`derivePlatformRegistry`**, **`derivePlatformProfile`**, **`deriveMarketCategory`**, **`deriveResolutionState`**, **`deriveResolverStakeVault`** when building instructions manually.
|
|
450
496
|
|
|
451
497
|
## Market types
|
|
452
498
|
|
|
@@ -479,6 +525,8 @@ import {
|
|
|
479
525
|
derivePlatformRegistry,
|
|
480
526
|
derivePlatformProfile,
|
|
481
527
|
deriveMarketCategory,
|
|
528
|
+
deriveResolutionState,
|
|
529
|
+
deriveResolverStakeVault,
|
|
482
530
|
bnLike,
|
|
483
531
|
bnToU32,
|
|
484
532
|
bnToU8,
|
|
@@ -525,7 +573,7 @@ import type {
|
|
|
525
573
|
|
|
526
574
|
## AI agent integration
|
|
527
575
|
|
|
528
|
-
Start from **`agents/skill.md`** in this package for a stable entrypoint; the full playbook is at **`https://vercora.xyz/agents/playbook.md`** (production), or `docs/AI-AGENT-SDK-PLAYBOOK.md` in the monorepo.
|
|
576
|
+
Start from **`agents/skill.md`** in this package for a stable entrypoint; the full playbook is at **`https://vercora.xyz/agents/playbook.md`** (production), or `docs/AI-AGENT-SDK-PLAYBOOK.md` in the monorepo. **Humans:** the web app serves the same playbook at **`https://vercora.xyz/docs/agents`** with a **Resolution at a glance** summary (aligned with **`https://vercora.xyz/docs#resolution-flow`**).
|
|
529
577
|
|
|
530
578
|
1. **Bootstrap**: `Connection` → `AnchorProvider` → `Program<Vercora>` from `IDL` → `PredictionMarketClient`.
|
|
531
579
|
2. **Branch**: `fetchMarket` → `market.marketType` (`completeSet` vs `parimutuel`).
|
|
@@ -534,7 +582,7 @@ Start from **`agents/skill.md`** in this package for a stable entrypoint; the fu
|
|
|
534
582
|
- Create: `createMarketFull` **or** `createMarket` + resolver / outcome / mint **or** pari init.
|
|
535
583
|
- Complete-set: `mintCompleteSet` → `redeemCompleteSet` → `redeemWinning`.
|
|
536
584
|
- Parimutuel: `parimutuelStake` → optional `parimutuelWithdraw` (if `isEarlyWithdrawAllowed`, or after `voidMarket` for full refunds) → `parimutuelClaim`; creator may change penalty split, early withdraw, and per-wallet caps (`maxWalletOutcomeInvestment`, `isWalletOutcomeStakeExact`) with `updateParimutuelState` (pass full params from `fetchMarket` / `fetchParimutuelState` when only changing some fields).
|
|
537
|
-
- Resolution: `voteResolution` → `finalizeResolution
|
|
585
|
+
- Resolution: `voteResolution` → `finalizeResolution` (proposal) → challenge window → optional `openRefute` / `resolveRefute` → `confirmResolution` (final `winningOutcomeIndex`) → `claimResolverStake`; then redeem/claim for traders.
|
|
538
586
|
4. **Discovery**: `fetchAllMarkets`, `getUsersMarkets`, `fetchMarketsByCreator`, `fetchVoidedMarkets`, `fetchVoidedParimutuelSurplusCandidates`.
|
|
539
587
|
5. **Safety**: verify signers, PDAs, ATAs, and RPC limits on `getProgramAccounts`.
|
|
540
588
|
|
package/agents/skill.md
CHANGED
|
@@ -11,8 +11,8 @@ The canonical HTTPS deployment—use this when you **do not** have the monorepo
|
|
|
11
11
|
| Full AI playbook (markdown) | `https://vercora.xyz/agents/playbook.md` |
|
|
12
12
|
| This skill entry (markdown) | `https://vercora.xyz/agents/skill.md` |
|
|
13
13
|
| Pointer manifest (JSON) | `https://vercora.xyz/.well-known/vercora-agents.json` |
|
|
14
|
-
| Developer docs (human) | `https://vercora.xyz/docs` |
|
|
15
|
-
| AI / agents
|
|
14
|
+
| Developer docs (human) | `https://vercora.xyz/docs` (includes **Resolution flow** — same narrative as agents) |
|
|
15
|
+
| AI / agents playbook (human + markdown) | `https://vercora.xyz/docs/agents` — full playbook + **resolution at a glance** |
|
|
16
16
|
|
|
17
17
|
Example:
|
|
18
18
|
|
|
@@ -27,11 +27,12 @@ For self-hosted or staging sites, use the same path suffixes with your origin: `
|
|
|
27
27
|
## What to read first
|
|
28
28
|
|
|
29
29
|
1. **This package’s `README.md`** — install, exports, `PredictionMarketClient` API, and the **AI agent integration** section (workflow map).
|
|
30
|
-
2. **
|
|
30
|
+
2. **Human playbook UI** — **`https://vercora.xyz/docs/agents`**: same playbook as below, plus a **Resolution at a glance** block (vote → propose → challenge → confirm), aligned with **`https://vercora.xyz/docs#resolution-flow`**.
|
|
31
|
+
3. **Full playbook** (skills, pitfalls, decision trees):
|
|
31
32
|
- **Production:** `https://vercora.xyz/agents/playbook.md`
|
|
32
33
|
- **Monorepo (contributors):** `prediction_market/docs/AI-AGENT-SDK-PLAYBOOK.md` (content matches the production mirror).
|
|
33
34
|
|
|
34
|
-
The playbook is the source of truth for instruction order, branching, and edge cases.
|
|
35
|
+
The playbook is the source of truth for instruction order, branching, and edge cases (humans and agents use the same narrative).
|
|
35
36
|
|
|
36
37
|
## Key files in the published npm package
|
|
37
38
|
|
|
@@ -75,3 +76,11 @@ Paths are under `node_modules/@vercora-protocol/sdk/` after install.
|
|
|
75
76
|
- **`voidMarket`:** the **creator** cannot void while pari **outcome pools** (active stakes) or complete-set outstanding is non-zero (**`CreatorCannotVoidWithActiveLiquidity`**). Propose a **global config authority** wallet to cancel live markets; SDK passes **`parimutuelState`** for pari markets.
|
|
76
77
|
- **`claimVoidedParimutuelSurplus`:** **global authority only** — if a voided pari market has **zero outcome stakes** but **`total_pool` > 0** (early-exit pool-keep left in the vault), sweep that surplus to the platform treasury. Call after users have finished void refunds.
|
|
77
78
|
- Use **`isClosedEarly`**, **`isVoided`**, **`winningOutcomeIndex`** for lifecycle — not legacy `closed` / `voided` / `resolvedOutcomeIndex` names.
|
|
79
|
+
|
|
80
|
+
## Quick guardrails (resolution)
|
|
81
|
+
|
|
82
|
+
- **`create_market`** requires **`platform_id > 0`**: register a platform, **`upsert_platform_profile`**, and pass **`platform_registry`**, **`platform_profile`**, **`resolution_state`**, **`resolver_stake_vault`** (SDK methods wire PDAs when you use `PredictionMarketClient`).
|
|
83
|
+
- Settlement is **two-phase**: **`finalizeResolution`** records a **proposal** on **`fetchResolutionState`** (`proposed_outcome`, `proposal_ts`). It does **not** set **`winningOutcomeIndex`** on the market.
|
|
84
|
+
- After **`challenge_window_secs`** from **`fetchPlatformProfile(platformId)`** (same value used on-chain for the challenge window), call **`confirmResolution`** to finalize **`Market.winningOutcomeIndex`**. Until then, traders cannot **`redeemWinning`** / **`parimutuelClaim`** as “resolved.”
|
|
85
|
+
- Optional dispute: **`openRefute`** (bond + alternative outcome) during the window; **`resolveRefute`** dismisses refutes (authorized signers per program). **`confirmResolution`** fails while a dispute blocks it.
|
|
86
|
+
- After final winner is set, resolvers may **`claimResolverStake`**. Read **`fetchResolutionState`** + **`fetchMarket`** together for UI (proposal vs final).
|
package/dist/client.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as anchor from '@coral-xyz/anchor';
|
|
|
2
2
|
import { Program, BN } from '@coral-xyz/anchor';
|
|
3
3
|
import { Connection, PublicKey } from '@solana/web3.js';
|
|
4
4
|
import type { Vercora } from './generated/vercora';
|
|
5
|
-
import type { CreateMarketParams, InitializeParimutuelStateParams, ParimutuelStakeParams, ParimutuelWithdrawParams, ParimutuelClaimParams, InitializeConfigParams, UpdateConfigParams, InitializeMarketResolverSlotsParams, InitializeMarketOutcomeSlotsParams, MintCompleteSetParams, RedeemCompleteSetParams, VoteResolutionParams, FinalizeResolutionParams, RevokeResolutionVoteParams, RedeemWinningParams, CloseMarketEarlyParams, VoidMarketParams, ClaimVoidedParimutuelSurplusParams, AbandonMarketParams, GlobalConfigAccount, MarketAccount, ResolverAccount, UpsertUserProfileParams, VerifyUserProfileParams, UserProfileAccount, UpsertPlatformProfileParams, VerifyPlatformProfileParams, PlatformProfileAccount, ParimutuelStateAccount, ParimutuelPositionAccount, ParimutuelOdds, MarketCategoryAccount, CreateMarketCategoryParams, UpdateMarketCategoryParams, RegisterPlatformParams, UpdateParimutuelStateParams, ResolutionVoteAccount, ListedMarket, GetUsersMarketsFilters, VoidedParimutuelSurplusCandidate } from './types';
|
|
5
|
+
import type { CreateMarketParams, InitializeParimutuelStateParams, ParimutuelStakeParams, ParimutuelWithdrawParams, ParimutuelClaimParams, InitializeConfigParams, UpdateConfigParams, InitializeMarketResolverSlotsParams, InitializeMarketOutcomeSlotsParams, MintCompleteSetParams, RedeemCompleteSetParams, VoteResolutionParams, FinalizeResolutionParams, RevokeResolutionVoteParams, RedeemWinningParams, CloseMarketEarlyParams, VoidMarketParams, ClaimVoidedParimutuelSurplusParams, AbandonMarketParams, GlobalConfigAccount, MarketAccount, ResolverAccount, UpsertUserProfileParams, VerifyUserProfileParams, UserProfileAccount, UpsertPlatformProfileParams, VerifyPlatformProfileParams, PlatformProfileAccount, ParimutuelStateAccount, ParimutuelPositionAccount, ParimutuelOdds, MarketCategoryAccount, CreateMarketCategoryParams, UpdateMarketCategoryParams, RegisterPlatformParams, UpdateParimutuelStateParams, ResolutionVoteAccount, ResolutionStateAccount, ListedMarket, GetUsersMarketsFilters, VoidedParimutuelSurplusCandidate } from './types';
|
|
6
6
|
export declare class PredictionMarketClient {
|
|
7
7
|
readonly program: Program<Vercora>;
|
|
8
8
|
readonly connection: Connection;
|
|
@@ -139,6 +139,27 @@ export declare class PredictionMarketClient {
|
|
|
139
139
|
* Passes optional per-outcome tally accounts (null if that tally PDA was never created).
|
|
140
140
|
*/
|
|
141
141
|
finalizeResolution(marketPda: PublicKey, params: FinalizeResolutionParams, opts?: anchor.web3.ConfirmOptions): Promise<string>;
|
|
142
|
+
/** During the challenge window: post a refute bond (collateral) and claim an alternative outcome. */
|
|
143
|
+
openRefute(marketPda: PublicKey, params: {
|
|
144
|
+
marketId: BN;
|
|
145
|
+
refuteBondAmount: BN;
|
|
146
|
+
disputedOutcome: number;
|
|
147
|
+
}, opts?: anchor.web3.ConfirmOptions): Promise<string>;
|
|
148
|
+
/**
|
|
149
|
+
* Dismiss an open refute: slash the bond to the platform treasury ATA.
|
|
150
|
+
* Signer must be `GlobalConfig.disputeResolutionAuthority` (or primary/secondary if unset) or platform `profileAuthority`.
|
|
151
|
+
*/
|
|
152
|
+
resolveRefute(marketPda: PublicKey, params: {
|
|
153
|
+
marketId: BN;
|
|
154
|
+
}, opts?: anchor.web3.ConfirmOptions): Promise<string>;
|
|
155
|
+
/** After resolution: claim staked collateral back if correct, or slash to treasury if wrong. */
|
|
156
|
+
claimResolverStake(marketPda: PublicKey, params: {
|
|
157
|
+
marketId: BN;
|
|
158
|
+
resolverIndex: number;
|
|
159
|
+
}, opts?: anchor.web3.ConfirmOptions): Promise<string>;
|
|
160
|
+
fetchResolutionState(marketPda: PublicKey): Promise<ResolutionStateAccount>;
|
|
161
|
+
/** After the challenge window, if no open dispute — finalize `winning_outcome_index`. */
|
|
162
|
+
confirmResolution(marketPda: PublicKey, params: FinalizeResolutionParams, opts?: anchor.web3.ConfirmOptions): Promise<string>;
|
|
142
163
|
/**
|
|
143
164
|
* Burn `amount` winning outcome token base units and receive the same
|
|
144
165
|
* amount of collateral base units from the vault.
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EACL,UAAU,EACV,SAAS,EAOV,MAAM,iBAAiB,CAAC;AASzB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"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C,OAAO,CAAC,MAAM,CAAC;IAYZ,oBAAoB,CAAC,UAAU,EAAE,EAAE,GAAG,MAAM,GAAG,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC;IAO3F,6FAA6F;IACvF,oBAAoB,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAK9E;;;OAGG;IACG,uBAAuB,CAC3B,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,SAAS,EACf,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC;IAyB5C;;OAEG;IACG,gCAAgC,CACpC,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,SAAS,EACf,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,EAAE,EAAE,CAAC;IAgBhB;;;OAGG;IACG,uBAAuB,CAC3B,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,SAAS,EACf,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,MAAM,EAAE,CAAC;IAiBpB;;;;;;OAMG;IACH,qBAAqB,CAAC,KAAK,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,GAAG,cAAc;IAQ1F,+DAA+D;IACzD,aAAa,CAAC,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAKvF;;;;;OAKG;IACG,iBAAiB,CACrB,MAAM,EAAE,SAAS,EACjB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,SAAS,CAAA;KAAE,EAAE,CAAC;YAsC5C,WAAW;CA2B1B"}
|
package/dist/client.js
CHANGED
|
@@ -189,7 +189,7 @@ class PredictionMarketClient {
|
|
|
189
189
|
*/
|
|
190
190
|
async initializeConfig(params, opts) {
|
|
191
191
|
return this.program.methods
|
|
192
|
-
.initializeConfig(params.secondaryAuthority, params.depositPlatformFeeBps, params.platformTreasuryWallet, params.platformFeeLamports, params.parimutuelWithdrawPlatformFeeBps)
|
|
192
|
+
.initializeConfig(params.secondaryAuthority, params.depositPlatformFeeBps, params.platformTreasuryWallet, params.platformFeeLamports, params.parimutuelWithdrawPlatformFeeBps, params.disputeResolutionAuthority ?? web3_js_1.PublicKey.default)
|
|
193
193
|
.accounts({
|
|
194
194
|
globalConfig: this.globalConfig,
|
|
195
195
|
authority: this.walletKey,
|
|
@@ -206,7 +206,7 @@ class PredictionMarketClient {
|
|
|
206
206
|
*/
|
|
207
207
|
async updateConfig(params, opts) {
|
|
208
208
|
return this.program.methods
|
|
209
|
-
.updateConfig(params.secondaryAuthority, params.depositPlatformFeeBps, params.platformTreasuryWallet, params.platformFeeLamports, params.parimutuelWithdrawPlatformFeeBps)
|
|
209
|
+
.updateConfig(params.secondaryAuthority, params.depositPlatformFeeBps, params.platformTreasuryWallet, params.platformFeeLamports, params.parimutuelWithdrawPlatformFeeBps, params.disputeResolutionAuthority ?? web3_js_1.PublicKey.default)
|
|
210
210
|
.accounts({
|
|
211
211
|
globalConfig: this.globalConfig,
|
|
212
212
|
authority: this.walletKey,
|
|
@@ -320,11 +320,15 @@ class PredictionMarketClient {
|
|
|
320
320
|
const preIxs = [];
|
|
321
321
|
preIxs.push(...(await this.createCollateralAtaIfMissingInstructions(this.walletKey, collateralMint, creator, collateralTokenProgram)));
|
|
322
322
|
preIxs.push(...(await this.createCollateralAtaIfMissingInstructions(this.walletKey, collateralMint, platformTreasuryWallet, collateralTokenProgram)));
|
|
323
|
-
const platformIdBn = (0, pda_1.bnLike)(params.platformId
|
|
323
|
+
const platformIdBn = (0, pda_1.bnLike)(params.platformId);
|
|
324
|
+
if (platformIdBn.isZero()) {
|
|
325
|
+
throw new Error('platformId must be non-zero (registered platform required)');
|
|
326
|
+
}
|
|
324
327
|
const categoryIdBn = (0, pda_1.bnLike)(params.categoryId ?? new anchor_1.BN(0));
|
|
325
|
-
const platformRegistryPk =
|
|
326
|
-
|
|
327
|
-
|
|
328
|
+
const platformRegistryPk = (0, pda_1.derivePlatformRegistry)(this.program.programId, platformIdBn);
|
|
329
|
+
const platformProfilePk = (0, pda_1.derivePlatformProfile)(this.program.programId, platformIdBn);
|
|
330
|
+
const resolutionStatePk = (0, pda_1.deriveResolutionState)(this.program.programId, marketPda);
|
|
331
|
+
const resolverStakeVaultPk = (0, pda_1.deriveResolverStakeVault)(this.program.programId, marketPda);
|
|
328
332
|
const marketCategoryPk = !categoryIdBn.isZero()
|
|
329
333
|
? (0, pda_1.deriveMarketCategory)(this.program.programId, platformIdBn, categoryIdBn)
|
|
330
334
|
: null;
|
|
@@ -350,12 +354,15 @@ class PredictionMarketClient {
|
|
|
350
354
|
payer: this.walletKey,
|
|
351
355
|
market: marketPda,
|
|
352
356
|
vault: vaultPda,
|
|
357
|
+
resolverStakeVault: resolverStakeVaultPk,
|
|
358
|
+
resolutionState: resolutionStatePk,
|
|
353
359
|
collateralMint,
|
|
354
360
|
creator,
|
|
355
361
|
creatorFeeAccount: expectedCreatorAta,
|
|
356
362
|
globalConfig: this.globalConfig,
|
|
357
363
|
allowedMint: (0, pda_1.deriveAllowedMint)(this.program.programId, collateralMint),
|
|
358
364
|
platformRegistry: platformRegistryPk,
|
|
365
|
+
platformProfile: platformProfilePk,
|
|
359
366
|
marketCategory: marketCategoryPk,
|
|
360
367
|
collateralTokenProgram,
|
|
361
368
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
@@ -743,6 +750,11 @@ class PredictionMarketClient {
|
|
|
743
750
|
async voteResolution(marketPda, params, opts) {
|
|
744
751
|
const votePda = (0, pda_1.deriveResolutionVote)(this.program.programId, marketPda, params.resolverIndex);
|
|
745
752
|
const marketOutcomePda = (0, pda_1.deriveMarketOutcome)(this.program.programId, marketPda, params.outcomeIndex);
|
|
753
|
+
const market = await this.fetchMarket(marketPda);
|
|
754
|
+
const collateralMint = market.collateralMint;
|
|
755
|
+
const collateralTokenProgram = await this.collateralTokenProgramForMint(collateralMint);
|
|
756
|
+
const resolverUserCollateral = (0, spl_token_1.getAssociatedTokenAddressSync)(collateralMint, this.walletKey, false, collateralTokenProgram, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
|
|
757
|
+
const platformProfilePk = (0, pda_1.derivePlatformProfile)(this.program.programId, (0, pda_1.bnLike)(market.platformId));
|
|
746
758
|
return this.program.methods
|
|
747
759
|
.voteResolution({
|
|
748
760
|
marketId: params.marketId,
|
|
@@ -752,9 +764,15 @@ class PredictionMarketClient {
|
|
|
752
764
|
.accounts({
|
|
753
765
|
resolverSigner: this.walletKey,
|
|
754
766
|
market: marketPda,
|
|
767
|
+
platformProfile: platformProfilePk,
|
|
768
|
+
resolutionState: (0, pda_1.deriveResolutionState)(this.program.programId, marketPda),
|
|
769
|
+
resolverStakeVault: (0, pda_1.deriveResolverStakeVault)(this.program.programId, marketPda),
|
|
770
|
+
collateralMint,
|
|
771
|
+
resolverUserCollateral,
|
|
755
772
|
resolver: (0, pda_1.deriveResolver)(this.program.programId, marketPda, params.resolverIndex),
|
|
756
773
|
resolutionVote: votePda,
|
|
757
774
|
marketOutcome: marketOutcomePda,
|
|
775
|
+
collateralTokenProgram,
|
|
758
776
|
systemProgram: web3_js_1.SystemProgram.programId,
|
|
759
777
|
})
|
|
760
778
|
.rpc(opts ?? { skipPreflight: true });
|
|
@@ -763,6 +781,10 @@ class PredictionMarketClient {
|
|
|
763
781
|
async revokeResolutionVote(marketPda, params, opts) {
|
|
764
782
|
const votePda = (0, pda_1.deriveResolutionVote)(this.program.programId, marketPda, params.resolverIndex);
|
|
765
783
|
const marketOutcomePda = (0, pda_1.deriveMarketOutcome)(this.program.programId, marketPda, params.outcomeIndex);
|
|
784
|
+
const market = await this.fetchMarket(marketPda);
|
|
785
|
+
const collateralMint = market.collateralMint;
|
|
786
|
+
const collateralTokenProgram = await this.collateralTokenProgramForMint(collateralMint);
|
|
787
|
+
const resolverUserCollateral = (0, spl_token_1.getAssociatedTokenAddressSync)(collateralMint, this.walletKey, false, collateralTokenProgram, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
|
|
766
788
|
return this.program.methods
|
|
767
789
|
.revokeResolutionVote({
|
|
768
790
|
marketId: params.marketId,
|
|
@@ -772,9 +794,14 @@ class PredictionMarketClient {
|
|
|
772
794
|
.accounts({
|
|
773
795
|
resolverSigner: this.walletKey,
|
|
774
796
|
market: marketPda,
|
|
797
|
+
resolutionState: (0, pda_1.deriveResolutionState)(this.program.programId, marketPda),
|
|
798
|
+
resolverStakeVault: (0, pda_1.deriveResolverStakeVault)(this.program.programId, marketPda),
|
|
799
|
+
collateralMint,
|
|
800
|
+
resolverUserCollateral,
|
|
775
801
|
resolver: (0, pda_1.deriveResolver)(this.program.programId, marketPda, params.resolverIndex),
|
|
776
802
|
resolutionVote: votePda,
|
|
777
803
|
marketOutcome: marketOutcomePda,
|
|
804
|
+
collateralTokenProgram,
|
|
778
805
|
})
|
|
779
806
|
.rpc(opts ?? { skipPreflight: true });
|
|
780
807
|
}
|
|
@@ -790,6 +817,118 @@ class PredictionMarketClient {
|
|
|
790
817
|
.finalizeResolution({ marketId: params.marketId })
|
|
791
818
|
.accounts({
|
|
792
819
|
market: marketPda,
|
|
820
|
+
resolutionState: (0, pda_1.deriveResolutionState)(this.program.programId, marketPda),
|
|
821
|
+
marketOutcome0: infos[0] ? outcomes[0] : null,
|
|
822
|
+
marketOutcome1: infos[1] ? outcomes[1] : null,
|
|
823
|
+
marketOutcome2: infos[2] ? outcomes[2] : null,
|
|
824
|
+
marketOutcome3: infos[3] ? outcomes[3] : null,
|
|
825
|
+
marketOutcome4: infos[4] ? outcomes[4] : null,
|
|
826
|
+
marketOutcome5: infos[5] ? outcomes[5] : null,
|
|
827
|
+
marketOutcome6: infos[6] ? outcomes[6] : null,
|
|
828
|
+
marketOutcome7: infos[7] ? outcomes[7] : null,
|
|
829
|
+
})
|
|
830
|
+
.rpc(opts ?? { skipPreflight: true });
|
|
831
|
+
}
|
|
832
|
+
/** During the challenge window: post a refute bond (collateral) and claim an alternative outcome. */
|
|
833
|
+
async openRefute(marketPda, params, opts) {
|
|
834
|
+
const market = await this.fetchMarket(marketPda);
|
|
835
|
+
const collateralMint = market.collateralMint;
|
|
836
|
+
const collateralTokenProgram = await this.collateralTokenProgramForMint(collateralMint);
|
|
837
|
+
const refuterCollateral = (0, spl_token_1.getAssociatedTokenAddressSync)(collateralMint, this.walletKey, false, collateralTokenProgram, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
|
|
838
|
+
const pid = (0, pda_1.bnToU32)((0, pda_1.bnLike)(market.platformId));
|
|
839
|
+
return this.program.methods
|
|
840
|
+
.openRefute({
|
|
841
|
+
marketId: params.marketId,
|
|
842
|
+
refuteBondAmount: params.refuteBondAmount,
|
|
843
|
+
disputedOutcome: params.disputedOutcome,
|
|
844
|
+
})
|
|
845
|
+
.accounts({
|
|
846
|
+
refuter: this.walletKey,
|
|
847
|
+
market: marketPda,
|
|
848
|
+
resolutionState: (0, pda_1.deriveResolutionState)(this.program.programId, marketPda),
|
|
849
|
+
resolverStakeVault: (0, pda_1.deriveResolverStakeVault)(this.program.programId, marketPda),
|
|
850
|
+
collateralMint,
|
|
851
|
+
refuterCollateral,
|
|
852
|
+
platformProfile: (0, pda_1.derivePlatformProfile)(this.program.programId, pid),
|
|
853
|
+
collateralTokenProgram,
|
|
854
|
+
})
|
|
855
|
+
.rpc(opts ?? { skipPreflight: true });
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* Dismiss an open refute: slash the bond to the platform treasury ATA.
|
|
859
|
+
* Signer must be `GlobalConfig.disputeResolutionAuthority` (or primary/secondary if unset) or platform `profileAuthority`.
|
|
860
|
+
*/
|
|
861
|
+
async resolveRefute(marketPda, params, opts) {
|
|
862
|
+
const market = await this.fetchMarket(marketPda);
|
|
863
|
+
const collateralMint = market.collateralMint;
|
|
864
|
+
const collateralTokenProgram = await this.collateralTokenProgramForMint(collateralMint);
|
|
865
|
+
const gc = await this.fetchGlobalConfig();
|
|
866
|
+
const treasuryWallet = gc.platformTreasury;
|
|
867
|
+
const treasuryAta = (0, spl_token_1.getAssociatedTokenAddressSync)(collateralMint, treasuryWallet, false, collateralTokenProgram, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
|
|
868
|
+
const pid = (0, pda_1.bnToU32)((0, pda_1.bnLike)(market.platformId));
|
|
869
|
+
return this.program.methods
|
|
870
|
+
.resolveRefute({ marketId: params.marketId })
|
|
871
|
+
.accounts({
|
|
872
|
+
authority: this.walletKey,
|
|
873
|
+
market: marketPda,
|
|
874
|
+
resolutionState: (0, pda_1.deriveResolutionState)(this.program.programId, marketPda),
|
|
875
|
+
resolverStakeVault: (0, pda_1.deriveResolverStakeVault)(this.program.programId, marketPda),
|
|
876
|
+
collateralMint,
|
|
877
|
+
globalConfig: this.globalConfig,
|
|
878
|
+
platformRegistry: (0, pda_1.derivePlatformRegistry)(this.program.programId, pid),
|
|
879
|
+
platformTreasuryWallet: treasuryWallet,
|
|
880
|
+
platformTreasuryAta: treasuryAta,
|
|
881
|
+
collateralTokenProgram,
|
|
882
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
883
|
+
})
|
|
884
|
+
.rpc(opts ?? { skipPreflight: true });
|
|
885
|
+
}
|
|
886
|
+
/** After resolution: claim staked collateral back if correct, or slash to treasury if wrong. */
|
|
887
|
+
async claimResolverStake(marketPda, params, opts) {
|
|
888
|
+
const market = await this.fetchMarket(marketPda);
|
|
889
|
+
const collateralMint = market.collateralMint;
|
|
890
|
+
const collateralTokenProgram = await this.collateralTokenProgramForMint(collateralMint);
|
|
891
|
+
const resolverUserCollateral = (0, spl_token_1.getAssociatedTokenAddressSync)(collateralMint, this.walletKey, false, collateralTokenProgram, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
|
|
892
|
+
const gc = await this.fetchGlobalConfig();
|
|
893
|
+
const treasuryWallet = gc.platformTreasury;
|
|
894
|
+
const treasuryAta = (0, spl_token_1.getAssociatedTokenAddressSync)(collateralMint, treasuryWallet, false, collateralTokenProgram, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
|
|
895
|
+
return this.program.methods
|
|
896
|
+
.claimResolverStake({
|
|
897
|
+
marketId: params.marketId,
|
|
898
|
+
resolverIndex: params.resolverIndex,
|
|
899
|
+
})
|
|
900
|
+
.accounts({
|
|
901
|
+
resolverSigner: this.walletKey,
|
|
902
|
+
market: marketPda,
|
|
903
|
+
resolverStakeVault: (0, pda_1.deriveResolverStakeVault)(this.program.programId, marketPda),
|
|
904
|
+
collateralMint,
|
|
905
|
+
resolverUserCollateral,
|
|
906
|
+
resolver: (0, pda_1.deriveResolver)(this.program.programId, marketPda, params.resolverIndex),
|
|
907
|
+
resolutionVote: (0, pda_1.deriveResolutionVote)(this.program.programId, marketPda, params.resolverIndex),
|
|
908
|
+
globalConfig: this.globalConfig,
|
|
909
|
+
platformTreasuryWallet: treasuryWallet,
|
|
910
|
+
platformTreasuryAta: treasuryAta,
|
|
911
|
+
collateralTokenProgram,
|
|
912
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
913
|
+
})
|
|
914
|
+
.rpc(opts ?? { skipPreflight: true });
|
|
915
|
+
}
|
|
916
|
+
async fetchResolutionState(marketPda) {
|
|
917
|
+
const pda = (0, pda_1.deriveResolutionState)(this.program.programId, marketPda);
|
|
918
|
+
return this.program.account.resolutionState.fetch(pda);
|
|
919
|
+
}
|
|
920
|
+
/** After the challenge window, if no open dispute — finalize `winning_outcome_index`. */
|
|
921
|
+
async confirmResolution(marketPda, params, opts) {
|
|
922
|
+
const market = await this.fetchMarket(marketPda);
|
|
923
|
+
const platformProfilePk = (0, pda_1.derivePlatformProfile)(this.program.programId, (0, pda_1.bnLike)(market.platformId));
|
|
924
|
+
const outcomes = (0, pda_1.deriveAllMarketOutcomes)(this.program.programId, marketPda);
|
|
925
|
+
const infos = await Promise.all(outcomes.map((p) => this.connection.getAccountInfo(p)));
|
|
926
|
+
return this.program.methods
|
|
927
|
+
.confirmResolution({ marketId: params.marketId })
|
|
928
|
+
.accounts({
|
|
929
|
+
market: marketPda,
|
|
930
|
+
platformProfile: platformProfilePk,
|
|
931
|
+
resolutionState: (0, pda_1.deriveResolutionState)(this.program.programId, marketPda),
|
|
793
932
|
marketOutcome0: infos[0] ? outcomes[0] : null,
|
|
794
933
|
marketOutcome1: infos[1] ? outcomes[1] : null,
|
|
795
934
|
marketOutcome2: infos[2] ? outcomes[2] : null,
|
|
@@ -1365,7 +1504,7 @@ class PredictionMarketClient {
|
|
|
1365
1504
|
const pid = (0, pda_1.bnToU32)(params.platformId);
|
|
1366
1505
|
const platformRegistry = (0, pda_1.derivePlatformRegistry)(this.program.programId, pid);
|
|
1367
1506
|
return this.program.methods
|
|
1368
|
-
.upsertPlatformProfile(pid, params.displayName, params.url)
|
|
1507
|
+
.upsertPlatformProfile(pid, params.displayName, params.url, params.policy)
|
|
1369
1508
|
.accounts({
|
|
1370
1509
|
platformRegistry,
|
|
1371
1510
|
platformProfile: (0, pda_1.derivePlatformProfile)(this.program.programId, pid),
|