@vercora-protocol/sdk 0.4.1 → 0.5.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/CHANGELOG.md +19 -0
- package/README.md +132 -33
- package/agents/skill.md +16 -11
- package/dist/client.d.ts +4 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +25 -3
- package/dist/client.js.map +1 -1
- package/dist/generated/vercora.d.ts +2 -0
- package/dist/generated/vercora.d.ts.map +1 -1
- package/dist/idl/vercora.json +4 -2
- package/dist/pda.d.ts +9 -0
- package/dist/pda.d.ts.map +1 -1
- package/dist/pda.js +13 -0
- package/dist/pda.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,8 +5,27 @@ 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.5.0](https://github.com/vercora/vercora-anchor/compare/v0.4.2...v0.5.0) (2026-05-01)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **all:** update brand position and landing page ([4e6f1a9](https://github.com/vercora/vercora-anchor/commit/4e6f1a9a351f5de532d2414190969575b5345850))
|
|
14
|
+
|
|
15
|
+
### [0.4.2](https://github.com/vercora/vercora-anchor/compare/v0.4.1...v0.4.2) (2026-04-24)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* **all:** update and fix claim resolver stake ([931673a](https://github.com/vercora/vercora-anchor/commit/931673ab1c1fbd9c08d8bdf91f544dcd1a9a3f72))
|
|
21
|
+
* **web:** update to fix vite config ([b38165e](https://github.com/vercora/vercora-anchor/commit/b38165e5c6332a2f26ce6f292285ad506799aa57))
|
|
22
|
+
|
|
8
23
|
### [0.4.1](https://github.com/vercora/vercora-anchor/compare/v0.4.0...v0.4.1) (2026-04-24)
|
|
9
24
|
|
|
25
|
+
### Fixed
|
|
26
|
+
|
|
27
|
+
* **anchor / idl:** `claim_resolver_stake` and `resolve_refute` mark **`platform_treasury_wallet`** as **writable** so optional **`platform_fee_lamports`** SOL fee CPIs no longer trigger **writable privilege escalation** on the treasury wallet. **Requires a program deploy** that includes this account meta change; refresh the bundled IDL after upgrading the on-chain program.
|
|
28
|
+
|
|
10
29
|
### [0.4.0](https://github.com/vercora/vercora-anchor/compare/v0.3.1...v0.4.0) (2026-04-24)
|
|
11
30
|
|
|
12
31
|
### ⚠️ Breaking changes
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @vercora-protocol/sdk
|
|
2
2
|
|
|
3
|
-
TypeScript SDK for
|
|
3
|
+
TypeScript SDK for **[Vercora Protocol](https://vercora.xyz)** on Solana (Anchor). **Vercora** is **token utility infrastructure** for LST and utility-token programs; **this package** documents the **outcome markets** program today (`PredictionMarketClient`, bundled IDL). A second product lane (issuer upside and diversification into broader assets) is on the **roadmap** and is **not** exposed in this SDK yet.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -10,7 +10,7 @@ npm install @vercora-protocol/sdk
|
|
|
10
10
|
yarn add @vercora-protocol/sdk
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
**Peer dependencies** (install alongside):
|
|
13
|
+
**Peer dependencies** (install alongside, keep versions aligned; see [IDL, account metas, and peer deps](#idl-account-metas-and-peer-deps-browser--raw-anchor) for SendTransactionError notes):
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
16
|
npm install @coral-xyz/anchor @solana/web3.js @solana/spl-token bn.js
|
|
@@ -30,7 +30,7 @@ const connection = new Connection(clusterApiUrl("devnet"));
|
|
|
30
30
|
const provider = new anchor.AnchorProvider(connection, wallet, {});
|
|
31
31
|
anchor.setProvider(provider);
|
|
32
32
|
|
|
33
|
-
// Bundled IDL
|
|
33
|
+
// Bundled IDL, program id is embedded in `IDL.address` (`PROGRAM_ID` matches it)
|
|
34
34
|
const program = new anchor.Program<Vercora>(IDL, provider);
|
|
35
35
|
const client = new PredictionMarketClient(program);
|
|
36
36
|
```
|
|
@@ -51,6 +51,40 @@ Most transaction methods use **`provider.wallet.publicKey`** as the signer (`use
|
|
|
51
51
|
|
|
52
52
|
---
|
|
53
53
|
|
|
54
|
+
## IDL, account metas, and peer deps (browser + raw Anchor)
|
|
55
|
+
|
|
56
|
+
These topics come up often in integrator issues; the **published IDL** in this package (`dist/idl/vercora.json`, same bytes as `IDL` export) is generated from the **same Anchor build** as the on-chain program we ship against.
|
|
57
|
+
|
|
58
|
+
### platform_treasury_wallet writable flag (SOL fee CPIs)
|
|
59
|
+
|
|
60
|
+
For **`claim_resolver_stake`** and **`resolve_refute`**, the program may transfer **`platform_fee_lamports`** (lamports) from the signer to **`platform_treasury_wallet`** before SPL CPIs. The treasury wallet account must therefore appear as **writable** in the outer transaction’s `AccountMeta`s. If your IDL marks it read-only, the runtime can raise **`PrivilegeEscalation`** / “writable privilege escalated” on that pubkey.
|
|
61
|
+
|
|
62
|
+
**Mitigation:** Use the **IDL bundled with the same `@vercora-protocol/sdk` version** you installed (or regenerate from the program source). Do not fork the JSON IDL with weaker `writable` flags for those instructions.
|
|
63
|
+
|
|
64
|
+
### Served IDL vs package IDL (drift and disputerCollateral not provided)
|
|
65
|
+
|
|
66
|
+
If the app loads IDL from **`fetchIdl()`**, a static **`public/idl/vercora.json`**, or a CDN URL, it can **drift** from `node_modules/@vercora-protocol/sdk/dist/idl/vercora.json`. Anchor then builds **wrong or incomplete account lists** while `PredictionMarketClient` assumes the bundled layout, e.g. **`Account 'disputerCollateral' not provided`** when metas omit accounts present in the current IDL.
|
|
67
|
+
|
|
68
|
+
**Recommendation:** Prefer **`import { IDL } from '@vercora-protocol/sdk'`** (or copy **`dist/idl/vercora.json`** from the exact npm version) so the Program client and high-level client agree. If you must hot-reload IDL from HTTP, **version and cache-bust** the URL to match the deployed program + SDK release.
|
|
69
|
+
|
|
70
|
+
### Disputer collateral on resolve_refute
|
|
71
|
+
|
|
72
|
+
**`disputer_collateral`** is the **refuter’s collateral SPL ATA** for the market mint, the same role as **`refuter_collateral`** on **`open_refute`**. It is **always** in the **`resolve_refute`** account list: on **dismiss** the handler does not transfer the refute bond into it, but the account must still be present and valid (mint + **owner = `ResolutionState.disputer`**). On **accept**, the bond is refunded into this ATA.
|
|
73
|
+
|
|
74
|
+
It is **not** the market trading vault, pari pool vault, or treasury ATA.
|
|
75
|
+
|
|
76
|
+
### Who may sign resolve_refute (vs market resolvers)
|
|
77
|
+
|
|
78
|
+
**Signers:** **`GlobalConfig`** **primary** or **secondary** authority, **or** **`PlatformRegistry.profile_authority`** (platform operator). These are **config / registry** keys, **not** the per-market **`voteResolution`** resolver wallets.
|
|
79
|
+
|
|
80
|
+
**`GlobalConfig.dispute_resolution_authority`** (if still present in older docs) is **legacy / unused** for **`resolve_refute`** authorization; do not assume market resolver PDAs can sign it.
|
|
81
|
+
|
|
82
|
+
### `SendTransactionError: Unknown action 'undefined'` (tooling)
|
|
83
|
+
|
|
84
|
+
Some **`@coral-xyz/anchor`** + **`@solana/web3.js`** combinations surface this when error deserialization paths disagree. It is **not** Vercora-specific. Stay on the **peer dependency ranges** listed in this package’s `package.json`, or align **`@solana/web3.js`** with the version Anchor’s release notes recommend for your Anchor **minor** line.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
54
88
|
## `PredictionMarketClient` API
|
|
55
89
|
|
|
56
90
|
Public properties: **`program`**, **`connection`**, **`globalConfig`** (PDA).
|
|
@@ -61,11 +95,11 @@ Public properties: **`program`**, **`connection`**, **`globalConfig`** (PDA).
|
|
|
61
95
|
| ----------------------------------- | ---------------------------------------------- |
|
|
62
96
|
| `initializeConfig(params)` | One-time init; `authority` = connected wallet. |
|
|
63
97
|
| `updateConfig(params)` | Update fees, treasury, authorities. |
|
|
64
|
-
|
|
65
|
-
**`secondaryAuthority` in `InitializeConfigParams` / `UpdateConfigParams`:** both map to the **instruction data** field `secondary_authority` on-chain (not only the `secondaryAuthority` account meta). Every `updateConfig` **rewrites** `GlobalConfig.secondary_authority` from `params.secondaryAuthority`. When you only change fees or treasury, pass the **existing** secondary pubkey you want to keep (from `fetchGlobalConfig()`); passing the primary key here collapses secondary into primary and removes the backup signer used for platform-only actions (e.g. voiding markets that still hold user liquidity).
|
|
66
98
|
| `addAllowedCollateralMint(mint)` | Allowlist a collateral mint. |
|
|
67
99
|
| `removeAllowedCollateralMint(mint)` | Remove from allowlist. |
|
|
68
100
|
|
|
101
|
+
**`secondaryAuthority` in `InitializeConfigParams` / `UpdateConfigParams`:** both map to the **instruction data** field `secondary_authority` on-chain (not only the `secondaryAuthority` account meta). Every `updateConfig` **rewrites** `GlobalConfig.secondary_authority` from `params.secondaryAuthority`. When you only change fees or treasury, pass the **existing** secondary pubkey you want to keep (from `fetchGlobalConfig()`); passing the primary key here collapses secondary into primary and removes the backup signer used for platform-only actions (e.g. voiding markets that still hold user liquidity).
|
|
102
|
+
|
|
69
103
|
### Platforms & categories
|
|
70
104
|
|
|
71
105
|
| Method | Purpose |
|
|
@@ -86,11 +120,11 @@ Public properties: **`program`**, **`connection`**, **`globalConfig`** (PDA).
|
|
|
86
120
|
| `createMarketFull(creator, collateralMint, creatorFeeAccount, resolverPubkeys, params)` | Runs create → outcomes → resolvers (+ mints **or** pari state in one flow). |
|
|
87
121
|
| `updateParimutuelState(marketPda, params)` | Creator updates penalty split, **`isEarlyWithdrawAllowed`**, **`maxWalletOutcomeInvestment`**, and **`isWalletOutcomeStakeExact`** (open pari pool). |
|
|
88
122
|
|
|
89
|
-
**`CreateMarketParams`:** requires **`platformId`** (**`> 0`**, BN) with a registered platform + **`upsertPlatformProfile`** (global config authority; resolver stake, challenge window, and refute bond are set on the profile
|
|
123
|
+
**`CreateMarketParams`:** requires **`platformId`** (**`> 0`**, BN) with a registered platform + **`upsertPlatformProfile`** (global config authority; 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
124
|
|
|
91
|
-
**`UpdateParimutuelStateParams`:** every call writes **all** fields
|
|
125
|
+
**`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
126
|
|
|
93
|
-
When **`isEarlyWithdrawAllowed`** is **`false`**, early **`parimutuelWithdraw`** fails with **`EarlyWithdrawNotAllowed`** until close or resolution **(voided markets are exempt
|
|
127
|
+
When **`isEarlyWithdrawAllowed`** is **`false`**, early **`parimutuelWithdraw`** fails with **`EarlyWithdrawNotAllowed`** until close or resolution **(voided markets are exempt, full net-stake refunds, no penalty fees).** Read **`fetchMarket(marketPda)`** for **`isEarlyWithdrawAllowed`**, **`maxWalletOutcomeInvestment`**, **`isWalletOutcomeStakeExact`**.
|
|
94
128
|
|
|
95
129
|
### Complete-set trading
|
|
96
130
|
|
|
@@ -114,18 +148,82 @@ When **`isEarlyWithdrawAllowed`** is **`false`**, early **`parimutuelWithdraw`**
|
|
|
114
148
|
| ----------------------------------------- | --------------------------------------------- |
|
|
115
149
|
| `voteResolution(marketPda, params)` | Resolver vote; may escrow **resolver stake** to the market’s resolver stake vault (see platform policy). |
|
|
116
150
|
| `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
|
|
151
|
+
| `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
152
|
| `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
153
|
| `openRefute(marketPda, params)` | During the challenge window: post a **refute bond** and name an alternative winning outcome (dispute). |
|
|
120
|
-
| `resolveRefute(marketPda, params)` | `params.accept === false`: slash refute bond to treasury. `accept === true`: refund bond to refuter and set **`winning_outcome_index`** to disputed outcome (no **`confirmResolution`**). Signer
|
|
154
|
+
| `resolveRefute(marketPda, params)` | `params.accept === false`: slash refute bond to treasury. `accept === true`: refund bond to refuter and set **`winning_outcome_index`** to disputed outcome (no **`confirmResolution`**). **Signer (not market resolvers):** global **primary or secondary** authority, or platform **`profileAuthority`**. Optional **`params.disputerCollateral`** defaults to the refuter’s ATA derived from **`ResolutionState.disputer`**. |
|
|
121
155
|
| `claimResolverStake(marketPda, params)` | After resolution: matching vote → stake returned to resolver; otherwise stake **slashed** to platform treasury. |
|
|
122
156
|
| `fetchResolutionState(marketPda)` | Read proposal, dispute, refute bond locked (`ResolutionState`). Challenge length and resolver stake size come from **`fetchPlatformProfile`**. |
|
|
123
157
|
| `closeMarketEarly(marketPda, params)` | Creator / config authority before `close_at`. |
|
|
124
|
-
| `voidMarket(marketPda, params)` | Void market. **Creator** cannot void while pari **outcome pools** (active stakes) or complete-set outstanding is non-zero
|
|
158
|
+
| `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. **Cannot void while a refute dispute is open.** Parimutuel: then **`parimutuelWithdraw`** for full net refunds. |
|
|
125
159
|
| `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. |
|
|
126
160
|
| `abandonMarket(marketPda, params)` | Creator abandons empty market (reclaim rent). |
|
|
127
161
|
|
|
128
|
-
**`resolveRefute` (
|
|
162
|
+
**`resolveRefute`, account meta `disputerCollateral` (common pitfall):** Anchor’s JS client expects **camelCase** keys in `.accounts()` / `.accountsStrict()`, matching the camelCase IDL. The JSON IDL field is `disputer_collateral`; if you pass **`disputer_collateral`** in the accounts object, Anchor ignores it and you get **`Account 'disputerCollateral' not provided`**. Use **`disputerCollateral`**. The account is **always required** for the instruction (see **Disputer collateral on resolve_refute** under [IDL, account metas, and peer deps](#idl-account-metas-and-peer-deps-browser--raw-anchor), dismiss does not fund it, but it must be present). For raw `program.methods`, supply every remaining account explicitly; **`as never`** on the accounts object is only to satisfy stale generated TypeScript, the chain still needs the meta. **IDL drift** (served JSON vs npm bundle) also produces “not provided”; prefer **`import { IDL } from '@vercora-protocol/sdk'`** or the same **`dist/idl/vercora.json`** as your installed package version.
|
|
163
|
+
|
|
164
|
+
#### `resolveRefute` examples
|
|
165
|
+
|
|
166
|
+
High-level client (derives refuter ATA when `disputerCollateral` is omitted):
|
|
167
|
+
|
|
168
|
+
```ts
|
|
169
|
+
await client.resolveRefute(marketPda, {
|
|
170
|
+
marketId,
|
|
171
|
+
accept: false, // dismiss: bond → platform treasury
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
// Optional: pass the refuter collateral ATA explicitly (same as derive from ResolutionState.disputer)
|
|
175
|
+
import { disputerCollateralAta } from "@vercora-protocol/sdk";
|
|
176
|
+
import { TOKEN_PROGRAM_ID } from "@solana/spl-token";
|
|
177
|
+
const rs = await client.fetchResolutionState(marketPda);
|
|
178
|
+
const mint = (await client.fetchMarket(marketPda)).collateralMint;
|
|
179
|
+
// Use TOKEN_2022_PROGRAM_ID when the collateral mint uses Token-2022.
|
|
180
|
+
const ata = disputerCollateralAta(mint, rs.disputer as PublicKey, TOKEN_PROGRAM_ID);
|
|
181
|
+
await client.resolveRefute(marketPda, { marketId, accept: true, disputerCollateral: ata });
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Raw Anchor (wallet = authority signer). **Every** account meta below uses **camelCase** names:
|
|
185
|
+
|
|
186
|
+
```ts
|
|
187
|
+
import { SystemProgram } from "@solana/web3.js";
|
|
188
|
+
import {
|
|
189
|
+
disputerCollateralAta,
|
|
190
|
+
deriveGlobalConfig,
|
|
191
|
+
derivePlatformRegistry,
|
|
192
|
+
deriveResolverStakeVault,
|
|
193
|
+
} from "@vercora-protocol/sdk";
|
|
194
|
+
import { getAssociatedTokenAddressSync, TOKEN_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID } from "@solana/spl-token";
|
|
195
|
+
|
|
196
|
+
const marketAccount = await program.account.market.fetch(marketPda);
|
|
197
|
+
// After openRefute: read disputer from chain (use your resolution PDA)
|
|
198
|
+
const rs = await program.account.resolutionState.fetch(resolutionStatePk);
|
|
199
|
+
const disputer = rs.disputer as PublicKey;
|
|
200
|
+
const disputerCollateral = disputerCollateralAta(collateralMint, disputer, TOKEN_PROGRAM_ID);
|
|
201
|
+
const treasuryAta = getAssociatedTokenAddressSync(
|
|
202
|
+
collateralMint,
|
|
203
|
+
platformTreasuryWallet,
|
|
204
|
+
false,
|
|
205
|
+
TOKEN_PROGRAM_ID,
|
|
206
|
+
ASSOCIATED_TOKEN_PROGRAM_ID
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
await program.methods
|
|
210
|
+
.resolveRefute({ marketId, accept: false })
|
|
211
|
+
.accounts({
|
|
212
|
+
authority: wallet.publicKey,
|
|
213
|
+
market: marketPda,
|
|
214
|
+
resolutionState: resolutionStatePk,
|
|
215
|
+
resolverStakeVault: deriveResolverStakeVault(program.programId, marketPda),
|
|
216
|
+
collateralMint,
|
|
217
|
+
disputerCollateral, // required, camelCase key (`disputer_collateral` in JSON IDL is ignored)
|
|
218
|
+
globalConfig: deriveGlobalConfig(program.programId),
|
|
219
|
+
platformRegistry: derivePlatformRegistry(program.programId, marketAccount.platformId),
|
|
220
|
+
platformTreasuryWallet,
|
|
221
|
+
platformTreasuryAta: treasuryAta,
|
|
222
|
+
collateralTokenProgram: TOKEN_PROGRAM_ID,
|
|
223
|
+
systemProgram: SystemProgram.programId,
|
|
224
|
+
} as any) // narrow only if your typegen omits `disputerCollateral`
|
|
225
|
+
.rpc();
|
|
226
|
+
```
|
|
129
227
|
|
|
130
228
|
See **[Resolution approval flow](#resolution-approval-flow-propose--challenge--confirm-or-refute-accept)** below for the full sequence and SDK usage.
|
|
131
229
|
|
|
@@ -183,7 +281,7 @@ import { PublicKey } from "@solana/web3.js";
|
|
|
183
281
|
import BN from "bn.js";
|
|
184
282
|
|
|
185
283
|
await client.initializeConfig({
|
|
186
|
-
// System program / “none” placeholder
|
|
284
|
+
// System program / “none” placeholder, use a real secondary authority pubkey in production
|
|
187
285
|
secondaryAuthority: new PublicKey("11111111111111111111111111111111"),
|
|
188
286
|
depositPlatformFeeBps: 100,
|
|
189
287
|
platformTreasuryWallet: treasuryPubkey,
|
|
@@ -226,7 +324,7 @@ const { marketPda } = await client.createMarket(
|
|
|
226
324
|
maxOutcomeInvestment: new BN(0),
|
|
227
325
|
title: "Will it rain tomorrow?",
|
|
228
326
|
marketType: "completeSet",
|
|
229
|
-
platformId: new BN(1), // must be > 0
|
|
327
|
+
platformId: new BN(1), // must be > 0, register_platform + upsert_platform_profile first
|
|
230
328
|
categoryId: new BN(0),
|
|
231
329
|
},
|
|
232
330
|
);
|
|
@@ -292,7 +390,7 @@ const marketPda = await client.createMarketFull(
|
|
|
292
390
|
outcomeLabels: ["A", "B"],
|
|
293
391
|
platformId: new BN(1),
|
|
294
392
|
categoryId: new BN(0),
|
|
295
|
-
// Optional
|
|
393
|
+
// Optional, default true. Set false to lock stakes until close/resolution (no early parimutuelWithdraw).
|
|
296
394
|
isEarlyWithdrawAllowed: true,
|
|
297
395
|
parimutuelInit: {
|
|
298
396
|
earlyWithdrawPenaltyBps: 500,
|
|
@@ -353,7 +451,7 @@ await client.parimutuelWithdraw(marketPda, {
|
|
|
353
451
|
outcomeIndex: 0,
|
|
354
452
|
amount: new BN(500_000),
|
|
355
453
|
});
|
|
356
|
-
// If Market.isEarlyWithdrawAllowed is false (from create or updateParimutuelState), parimutuelWithdraw throws EarlyWithdrawNotAllowed
|
|
454
|
+
// If Market.isEarlyWithdrawAllowed is false (from create or updateParimutuelState), parimutuelWithdraw throws EarlyWithdrawNotAllowed, unless the market is voided (then full net stake back, no fees).
|
|
357
455
|
|
|
358
456
|
// After voidMarket on a pari pool, recover stakes (repeat per outcome / until active stake is 0):
|
|
359
457
|
// await client.voidMarket(marketPda, { marketId });
|
|
@@ -435,7 +533,7 @@ const all = await client.fetchAllMarkets();
|
|
|
435
533
|
// By platform (memcmp)
|
|
436
534
|
const byPlatform = await client.fetchAllMarkets(new BN(1));
|
|
437
535
|
|
|
438
|
-
// Markets created by a wallet
|
|
536
|
+
// Markets created by a wallet, full rows with labels + filters
|
|
439
537
|
const mine = await client.getUsersMarkets(creatorPubkey, {
|
|
440
538
|
platformId: new BN(1), // optional RPC filter
|
|
441
539
|
categoryId: 2, // optional; applied after decode
|
|
@@ -460,25 +558,25 @@ const profile = await client.fetchUserProfile(wallet.publicKey);
|
|
|
460
558
|
|
|
461
559
|
## Resolution approval flow (propose → challenge → confirm or refute-accept)
|
|
462
560
|
|
|
463
|
-
Settlement is **two-phase**: first a **proposal** is recorded on `ResolutionState`, then
|
|
561
|
+
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.
|
|
464
562
|
|
|
465
|
-
1. **Platform prerequisite
|
|
563
|
+
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`**.
|
|
466
564
|
|
|
467
|
-
2. **Votes
|
|
565
|
+
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**.
|
|
468
566
|
|
|
469
|
-
3. **Propose (`finalizeResolution`)
|
|
567
|
+
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`**).
|
|
470
568
|
|
|
471
|
-
4. **Challenge window
|
|
569
|
+
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 **primary or secondary** authority, or platform **`profileAuthority`**) may **`resolveRefute`**: **`accept: false`** dismisses (bond → treasury), **`accept: true`** accepts (bond refunded, **`winning_outcome_index`** set immediately). While a dispute is active, **`confirmResolution`** is rejected. **`voidMarket`** is rejected while a dispute is open.
|
|
472
570
|
|
|
473
|
-
5. **Confirm (final approval)
|
|
571
|
+
5. **Confirm (final approval)**, After **`proposal_ts + challenge_window`**, if there is **no** blocking dispute and the market was not already finalized by **`resolveRefute(accept: true)`**, anyone calls **`confirmResolution`**. This writes **`Market.winning_outcome_index`**, the outcome is now final for **`redeemWinning`** / **`parimutuelClaim`**.
|
|
474
572
|
|
|
475
|
-
6. **Resolver stake
|
|
573
|
+
6. **Resolver stake**, After settlement, resolvers use **`claimResolverStake`**: stake returns to the resolver if their vote matched the final winner; otherwise it is transferred to the platform treasury.
|
|
476
574
|
|
|
477
575
|
**Reads**
|
|
478
576
|
|
|
479
|
-
- **`fetchResolutionState(marketPda)
|
|
480
|
-
- **`fetchPlatformProfile(platformId)
|
|
481
|
-
- **`fetchMarket(marketPda)
|
|
577
|
+
- **`fetchResolutionState(marketPda)`**, `proposed_outcome`, `proposal_ts`, `dispute_active`, `refute_bond_amount`, etc.
|
|
578
|
+
- **`fetchPlatformProfile(platformId)`**, `challenge_window_secs`, `resolver_stake`, `refute_bond` (challenge length and stake are not stored on `ResolutionState`).
|
|
579
|
+
- **`fetchMarket(marketPda)`**, `winningOutcomeIndex` is **`null`** until **`confirmResolution`** or **`resolveRefute({ accept: true })`** succeeds.
|
|
482
580
|
|
|
483
581
|
**UI / agent logic**
|
|
484
582
|
|
|
@@ -489,10 +587,10 @@ Settlement is **two-phase**: first a **proposal** is recorded on `ResolutionStat
|
|
|
489
587
|
|
|
490
588
|
On-chain, **`platform_id`** is **`u32`** and **`category_id`** is **`u8`** in `CreateMarketArgs` (not pubkeys).
|
|
491
589
|
|
|
492
|
-
1. **`register_platform
|
|
493
|
-
2. **`upsert_platform_profile
|
|
494
|
-
3. **`create_market_category
|
|
495
|
-
4. **`create_market
|
|
590
|
+
1. **`register_platform`**, assigns the next id from `GlobalConfig.next_platform_id` (starts at **1**); PDA `["platform", platform_id le u32]`.
|
|
591
|
+
2. **`upsert_platform_profile`**, metadata + **resolution policy** (`resolver_stake`, `challenge_window_secs`, `refute_bond`); signed by **global config** primary or secondary authority.
|
|
592
|
+
3. **`create_market_category`**, `category_id` must equal `PlatformRegistry.next_category_id`; PDA `["market-category", platform_id, category_id]`.
|
|
593
|
+
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.
|
|
496
594
|
|
|
497
595
|
Use **`derivePlatformRegistry`**, **`derivePlatformProfile`**, **`deriveMarketCategory`**, **`deriveResolutionState`**, **`deriveResolverStakeVault`** when building instructions manually.
|
|
498
596
|
|
|
@@ -500,8 +598,8 @@ Use **`derivePlatformRegistry`**, **`derivePlatformProfile`**, **`deriveMarketCa
|
|
|
500
598
|
|
|
501
599
|
Use `marketType: 'parimutuel'` or `'completeSet'` at creation; the choice is permanent.
|
|
502
600
|
|
|
503
|
-
- **Parimutuel
|
|
504
|
-
- **Complete-set
|
|
601
|
+
- **Parimutuel**, pooled stakes, no outcome SPLs; good default for prediction apps. **`isEarlyWithdrawAllowed`** is set at create (default **allowed**) and can be changed by the creator via **`updateParimutuelState`**; when disabled, early **`parimutuelWithdraw`** is blocked until close or resolution. **`maxWalletOutcomeInvestment`** and **`isWalletOutcomeStakeExact`** are set at create and can be updated via **`updateParimutuelState`** (same instruction as penalty / early-withdraw edits). After **`voidMarket`**, participants **`parimutuelWithdraw`** full net stakes (no penalty / withdraw fees).
|
|
602
|
+
- **Complete-set**, outcome SPL tokens; you still need external liquidity for single-leg trading.
|
|
505
603
|
|
|
506
604
|
## PDA helpers
|
|
507
605
|
|
|
@@ -529,6 +627,7 @@ import {
|
|
|
529
627
|
deriveMarketCategory,
|
|
530
628
|
deriveResolutionState,
|
|
531
629
|
deriveResolverStakeVault,
|
|
630
|
+
disputerCollateralAta,
|
|
532
631
|
bnLike,
|
|
533
632
|
bnToU32,
|
|
534
633
|
bnToU8,
|
package/agents/skill.md
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
# Vercora Protocol
|
|
1
|
+
# Vercora Protocol: agent skill entry (`@vercora-protocol/sdk`)
|
|
2
2
|
|
|
3
3
|
This file ships **inside** the npm package (`agents/skill.md`) so AI agents, clawbots, and operator scripts can load instructions without depending on a particular website.
|
|
4
4
|
|
|
5
|
+
**Scope:** Vercora Protocol is **multi-product issuer infrastructure** over time. **This skill and the bundled SDK** target the **outcome markets** program only (markets, resolution, settlement). Do not assume other product lanes (e.g. issuer diversification) are available in `PredictionMarketClient` until documented in this package.
|
|
6
|
+
|
|
5
7
|
## Public production deployment (Vercora)
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
When you **do not** have the monorepo, the canonical HTTPS deployment is **[vercora.xyz](https://vercora.xyz)**. Fetch these over TLS; use a Solana `Connection` and cluster that match the deployment you operate against (see this package’s `README.md`).
|
|
8
10
|
|
|
9
11
|
| Resource | URL |
|
|
10
12
|
|----------|-----|
|
|
11
13
|
| Full AI playbook (markdown) | `https://vercora.xyz/agents/playbook.md` |
|
|
12
14
|
| This skill entry (markdown) | `https://vercora.xyz/agents/skill.md` |
|
|
13
15
|
| Pointer manifest (JSON) | `https://vercora.xyz/.well-known/vercora-agents.json` |
|
|
14
|
-
| Developer docs (human) | `https://vercora.xyz/docs` (includes **Resolution flow
|
|
15
|
-
| AI / agents playbook (human + markdown) | `https://vercora.xyz/docs/agents
|
|
16
|
+
| Developer docs (human) | `https://vercora.xyz/docs` (includes **Resolution flow**, same narrative as agents) |
|
|
17
|
+
| AI / agents playbook (human + markdown) | `https://vercora.xyz/docs/agents`, full playbook + **resolution at a glance** |
|
|
16
18
|
|
|
17
19
|
Example:
|
|
18
20
|
|
|
@@ -26,8 +28,8 @@ For self-hosted or staging sites, use the same path suffixes with your origin: `
|
|
|
26
28
|
|
|
27
29
|
## What to read first
|
|
28
30
|
|
|
29
|
-
1. **This package’s `README.md
|
|
30
|
-
2. **Human playbook UI**
|
|
31
|
+
1. **This package’s `README.md`**: install, exports, `PredictionMarketClient` API, and the **AI agent integration** section (workflow map).
|
|
32
|
+
2. **Human playbook UI** at **`https://vercora.xyz/docs/agents`**: same playbook as below, plus a **Resolution at a glance** block (vote → propose → challenge → **confirm or refute-accept**), aligned with **`https://vercora.xyz/docs#resolution-flow`**.
|
|
31
33
|
3. **Full playbook** (skills, pitfalls, decision trees):
|
|
32
34
|
- **Production:** `https://vercora.xyz/agents/playbook.md`
|
|
33
35
|
- **Monorepo (contributors):** `prediction_market/docs/AI-AGENT-SDK-PLAYBOOK.md` (content matches the production mirror).
|
|
@@ -70,17 +72,20 @@ Paths are under `node_modules/@vercora-protocol/sdk/` after install.
|
|
|
70
72
|
## Quick guardrails (parimutuel)
|
|
71
73
|
|
|
72
74
|
- **`updateConfig`:** `params.secondaryAuthority` is written to chain on **every** call. When only adjusting fees/treasury, pass the **existing** secondary pubkey to keep (from `fetchGlobalConfig()`). Passing the primary key there removes the backup authority.
|
|
73
|
-
- After `fetchMarket(marketPda)`, read **`isEarlyWithdrawAllowed`**. If `false`, do not propose early-exit **`parimutuelWithdraw`** until close
|
|
75
|
+
- After `fetchMarket(marketPda)`, read **`isEarlyWithdrawAllowed`**. If `false`, do not propose early-exit **`parimutuelWithdraw`** until close or resolution (you hit **`EarlyWithdrawNotAllowed`**). If **`isVoided`**, **`parimutuelWithdraw`** still refunds full net stakes (no penalty / withdraw fees).
|
|
74
76
|
- Also read **`maxWalletOutcomeInvestment`** (`BN`, `0` = unlimited) and **`isWalletOutcomeStakeExact`**. When proposing **`parimutuelStake`**, enforce per-wallet caps and exact-stake rules (**`WalletOutcomeInvestmentCapExceeded`**, **`WalletOutcomeExactStakeMismatch`**).
|
|
75
|
-
- **Creators** (open pari market, not resolved/voided): **`updateParimutuelState`** updates penalty bps, **`isEarlyWithdrawAllowed`**, **`maxWalletOutcomeInvestment`**, and **`isWalletOutcomeStakeExact`** in one instruction
|
|
77
|
+
- **Creators** (open pari market, not resolved/voided): **`updateParimutuelState`** updates penalty bps, **`isEarlyWithdrawAllowed`**, **`maxWalletOutcomeInvestment`**, and **`isWalletOutcomeStakeExact`** in one instruction. Always pass **full** params (current values from **`fetchMarket`** + **`fetchParimutuelState`** for fields you keep unchanged). If **`isWalletOutcomeStakeExact`** is `true`, **`maxWalletOutcomeInvestment`** must be **> 0** (**`InvalidWalletOutcomeStakeExactConfig`** otherwise).
|
|
76
78
|
- **`voidMarket`:** the **creator** cannot void while pari **outcome pools** (active stakes) or complete-set outstanding is non-zero (**`CreatorCannotVoidWithActiveLiquidity`**). **Cannot void while an `openRefute` dispute is active** (**`CannotVoidWithOpenDispute`**). Propose a **global config authority** wallet to cancel live markets; SDK passes **`resolutionState`** and **`parimutuelState`** (pari) or `null` (complete-set).
|
|
77
|
-
- **`claimVoidedParimutuelSurplus`:** **global authority only
|
|
78
|
-
- Use **`isClosedEarly`**, **`isVoided`**, **`winningOutcomeIndex`** for lifecycle
|
|
79
|
+
- **`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.
|
|
80
|
+
- Use **`isClosedEarly`**, **`isVoided`**, **`winningOutcomeIndex`** for lifecycle, not legacy `closed` / `voided` / `resolvedOutcomeIndex` names.
|
|
79
81
|
|
|
80
82
|
## Quick guardrails (resolution)
|
|
81
83
|
|
|
82
84
|
- **`create_market`** requires **`platform_id > 0`**: register a platform, **`upsert_platform_profile`** (global config primary or secondary authority signs), and pass **`platform_registry`**, **`platform_profile`**, **`resolution_state`**, **`resolver_stake_vault`** (SDK methods wire PDAs when you use `PredictionMarketClient`).
|
|
83
85
|
- Settlement is **two-phase**: **`finalizeResolution`** records a **proposal** on **`fetchResolutionState`** (`proposed_outcome`, `proposal_ts`). It does **not** set **`winningOutcomeIndex`** on the market.
|
|
84
86
|
- 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`** during the window; **`resolveRefute`** with **`accept: false`** slashes the bond to treasury, **`accept: true`** refunds the refuter and sets **`winningOutcomeIndex`** immediately.
|
|
87
|
+
- Optional dispute: **`openRefute`** during the window; **`resolveRefute`** with **`accept: false`** slashes the bond to treasury, **`accept: true`** refunds the refuter and sets **`winningOutcomeIndex`** immediately. **Who signs `resolveRefute`:** global **primary/secondary** (`GlobalConfig`) or platform **`profileAuthority`** on **`PlatformRegistry`**, **not** the per-market **`voteResolution`** resolver wallets. Legacy **`dispute_resolution_authority`** on config does **not** gate this instruction. **`confirmResolution`** fails while a dispute blocks it; skip **`confirmResolution`** if accept already finalized the market.
|
|
88
|
+
- **`disputer_collateral`** on **`resolve_refute`**: the refuter’s collateral ATA (same role as **`refuter_collateral`** on **`open_refute`**). **Always** in the account list. **Dismiss** does not transfer the bond into it, but the account must still be present and valid. Raw Anchor: use camelCase **`disputerCollateral`** in `.accounts()` or Anchor reports **Account disputerCollateral not provided**. Prefer the **IDL from `@vercora-protocol/sdk`** (`import { IDL } …` or `dist/idl/vercora.json`); a separately hosted / `fetchIdl` JSON that drifts from the package causes the same error.
|
|
89
|
+
- **`claim_resolver_stake`** / **`resolve_refute`**: if **`platform_fee_lamports` > 0**, the program transfers SOL to **`platform_treasury_wallet`**. The IDL must mark that wallet **writable** or you can hit **PrivilegeEscalation** (“writable privilege escalated”). Use the published package IDL; do not strip `writable` when forking JSON.
|
|
86
90
|
- After final winner is set, resolvers may **`claimResolverStake`** (wrong outcome → slash to treasury). Read **`fetchResolutionState`** + **`fetchMarket`** together for UI (proposal vs final).
|
|
91
|
+
- **Tooling:** **`SendTransactionError: Unknown action 'undefined'`** can appear with some **`@coral-xyz/anchor`** + **`@solana/web3.js`** pairs (error ctor mismatch). Stay on the SDK **`package.json`** peer ranges or align **`@solana/web3.js`** with Anchor’s guidance for your Anchor minor.
|
package/dist/client.d.ts
CHANGED
|
@@ -151,6 +151,10 @@ export declare class PredictionMarketClient {
|
|
|
151
151
|
* (no `confirmResolution` step).
|
|
152
152
|
*
|
|
153
153
|
* Signer must be **global primary or secondary** (`GlobalConfig`) or the platform **`profileAuthority`** on registry.
|
|
154
|
+
*
|
|
155
|
+
* **`disputerCollateral`:** optional; defaults to the refuter’s ATA for `ResolutionState.disputer` (same mint / token
|
|
156
|
+
* program as the market). Pass explicitly if you already have the ATA. Raw `program.methods.resolveRefute` must pass
|
|
157
|
+
* account meta **`disputerCollateral`** (camelCase — not `disputer_collateral` from the JSON IDL); see README examples.
|
|
154
158
|
*/
|
|
155
159
|
resolveRefute(marketPda: PublicKey, params: {
|
|
156
160
|
marketId: BN;
|
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":"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;AAsCnD,OAAO,KAAK,EACV,kBAAkB,EAClB,+BAA+B,EAC/B,qBAAqB,EACrB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,mCAAmC,EACnC,kCAAkC,EAClC,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,EACpB,wBAAwB,EACxB,0BAA0B,EAC1B,mBAAmB,EACnB,sBAAsB,EACtB,gBAAgB,EAChB,kCAAkC,EAClC,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,eAAe,EACf,uBAAuB,EACvB,u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AM,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;;;;;;;;;OASG;IACG,iBAAiB,CACrB,MAAM,EAAE,SAAS,EACjB,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,GAC5B,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,SAAS,CAAA;KAAE,EAAE,CAAC;YAyL5C,WAAW;CA2B1B"}
|
package/dist/client.js
CHANGED
|
@@ -872,15 +872,37 @@ class PredictionMarketClient {
|
|
|
872
872
|
* (no `confirmResolution` step).
|
|
873
873
|
*
|
|
874
874
|
* Signer must be **global primary or secondary** (`GlobalConfig`) or the platform **`profileAuthority`** on registry.
|
|
875
|
+
*
|
|
876
|
+
* **`disputerCollateral`:** optional; defaults to the refuter’s ATA for `ResolutionState.disputer` (same mint / token
|
|
877
|
+
* program as the market). Pass explicitly if you already have the ATA. Raw `program.methods.resolveRefute` must pass
|
|
878
|
+
* account meta **`disputerCollateral`** (camelCase — not `disputer_collateral` from the JSON IDL); see README examples.
|
|
875
879
|
*/
|
|
876
880
|
async resolveRefute(marketPda, params, opts) {
|
|
877
881
|
const market = await this.fetchMarket(marketPda);
|
|
878
882
|
const collateralMint = market.collateralMint;
|
|
879
883
|
const collateralTokenProgram = await this.collateralTokenProgramForMint(collateralMint);
|
|
880
|
-
const
|
|
881
|
-
const
|
|
884
|
+
const resolutionPk = (0, pda_1.deriveResolutionState)(this.program.programId, marketPda);
|
|
885
|
+
const rsRaw = (await this.program.account.resolutionState.fetch(resolutionPk));
|
|
886
|
+
const disputeActive = pickDecodedField(rsRaw, 'disputeActive', 'dispute_active');
|
|
887
|
+
if (!disputeActive) {
|
|
888
|
+
throw new Error('resolveRefute: no open refute (ResolutionState.disputeActive is false). Open a refute first, or confirm the market PDA.');
|
|
889
|
+
}
|
|
890
|
+
const disputerDecoded = pickDecodedField(rsRaw, 'disputer', 'disputer');
|
|
891
|
+
let disputerKey;
|
|
892
|
+
try {
|
|
893
|
+
disputerKey =
|
|
894
|
+
disputerDecoded instanceof web3_js_1.PublicKey
|
|
895
|
+
? disputerDecoded
|
|
896
|
+
: new web3_js_1.PublicKey(String(disputerDecoded?.toString?.() ?? disputerDecoded));
|
|
897
|
+
}
|
|
898
|
+
catch {
|
|
899
|
+
throw new Error('resolveRefute: could not read ResolutionState.disputer. Pass params.disputerCollateral (refuter collateral ATA) explicitly.');
|
|
900
|
+
}
|
|
901
|
+
if (disputerKey.equals(web3_js_1.PublicKey.default)) {
|
|
902
|
+
throw new Error('resolveRefute: ResolutionState.disputer is unset — cannot derive disputerCollateral. Pass params.disputerCollateral (refuter collateral ATA) explicitly.');
|
|
903
|
+
}
|
|
882
904
|
const disputerCollateral = params.disputerCollateral ??
|
|
883
|
-
(0,
|
|
905
|
+
(0, pda_1.disputerCollateralAta)(collateralMint, disputerKey, collateralTokenProgram);
|
|
884
906
|
const gc = await this.fetchGlobalConfig();
|
|
885
907
|
const treasuryWallet = gc.platformTreasury;
|
|
886
908
|
const treasuryAta = (0, spl_token_1.getAssociatedTokenAddressSync)(collateralMint, treasuryWallet, false, collateralTokenProgram, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
|