@vercora-protocol/sdk 0.0.18 → 0.0.20
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 +20 -0
- package/README.md +35 -21
- package/agents/skill.md +6 -1
- package/dist/client.d.ts +34 -4
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +130 -3
- package/dist/client.js.map +1 -1
- package/dist/generated/vercora.d.ts +283 -2
- package/dist/generated/vercora.d.ts.map +1 -1
- package/dist/idl/vercora.json +283 -2
- package/dist/pda.d.ts +15 -1
- package/dist/pda.d.ts.map +1 -1
- package/dist/pda.js +53 -2
- package/dist/pda.js.map +1 -1
- package/dist/types.d.ts +57 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,22 @@ 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.20](https://github.com/vercora/vercora-anchor/compare/v0.0.19...v0.0.20) (2026-04-16)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **all:** add min and max stake allowed per wallet ([ecac974](https://github.com/vercora/vercora-anchor/commit/ecac974c671140fc4a65d3a2aded958fc830cda5))
|
|
14
|
+
|
|
15
|
+
### [0.0.20](https://github.com/vercora/vercora-anchor/compare/v0.0.19...v0.0.20) (2026-04-16)
|
|
16
|
+
|
|
17
|
+
### [0.0.19](https://github.com/vercora/vercora-anchor/compare/v0.0.18...v0.0.19) (2026-04-12)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* **all:** add updates to void market and withdraw surplus ([fd4a496](https://github.com/vercora/vercora-anchor/commit/fd4a49678f11f34be9e5078b87f7e877b49e88c1))
|
|
23
|
+
|
|
8
24
|
### [0.0.18](https://github.com/vercora/vercora-anchor/compare/v0.0.17...v0.0.18) (2026-04-11)
|
|
9
25
|
|
|
10
26
|
|
|
@@ -12,6 +28,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
|
12
28
|
|
|
13
29
|
* **anchor:** allow void parimutuel and withdraw all stake ([0a8d955](https://github.com/vercora/vercora-anchor/commit/0a8d955639700a9f6fd2a527ec9583b220daed81))
|
|
14
30
|
|
|
31
|
+
### Changed
|
|
32
|
+
|
|
33
|
+
* **anchor:** market **creator** cannot `void_market` while pari **outcome pools** (active stakes) or complete-set outstanding is non-zero; **global config** authorities can still void (use a platform wallet to cancel live markets).
|
|
34
|
+
|
|
15
35
|
### 0.0.17 (2026-04-10)
|
|
16
36
|
|
|
17
37
|
### Features
|
package/README.md
CHANGED
|
@@ -61,6 +61,8 @@ Public properties: **`program`**, **`connection`**, **`globalConfig`** (PDA).
|
|
|
61
61
|
| ----------------------------------- | ---------------------------------------------- |
|
|
62
62
|
| `initializeConfig(params)` | One-time init; `authority` = connected wallet. |
|
|
63
63
|
| `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).
|
|
64
66
|
| `addAllowedCollateralMint(mint)` | Allowlist a collateral mint. |
|
|
65
67
|
| `removeAllowedCollateralMint(mint)` | Remove from allowlist. |
|
|
66
68
|
|
|
@@ -82,9 +84,13 @@ Public properties: **`program`**, **`connection`**, **`globalConfig`** (PDA).
|
|
|
82
84
|
| `initializeMarketMints(marketPda, marketId)` | Mint 8 outcome SPLs (complete-set only). |
|
|
83
85
|
| `initializeParimutuelState(marketPda, params)` | Standalone pari pool + penalty params (if not bundled with resolvers). |
|
|
84
86
|
| `createMarketFull(creator, collateralMint, creatorFeeAccount, resolverPubkeys, params)` | Runs create → outcomes → resolvers (+ mints **or** pari state in one flow). |
|
|
85
|
-
| `updateParimutuelState(marketPda, params)` | Creator updates penalty split and **`
|
|
87
|
+
| `updateParimutuelState(marketPda, params)` | Creator updates penalty split, **`isEarlyWithdrawAllowed`**, **`maxWalletOutcomeInvestment`**, and **`isWalletOutcomeStakeExact`** (open pari pool). |
|
|
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.
|
|
86
90
|
|
|
87
|
-
**`
|
|
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
|
+
|
|
93
|
+
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`**.
|
|
88
94
|
|
|
89
95
|
### Complete-set trading
|
|
90
96
|
|
|
@@ -110,7 +116,8 @@ Public properties: **`program`**, **`connection`**, **`globalConfig`** (PDA).
|
|
|
110
116
|
| `revokeResolutionVote(marketPda, params)` | Clear vote before changing. |
|
|
111
117
|
| `finalizeResolution(marketPda, params)` | Anyone, once threshold met. |
|
|
112
118
|
| `closeMarketEarly(marketPda, params)` | Creator / config authority before `close_at`. |
|
|
113
|
-
| `voidMarket(marketPda, params)` | Void market.
|
|
119
|
+
| `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
|
+
| `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. |
|
|
114
121
|
| `abandonMarket(marketPda, params)` | Creator abandons empty market (reclaim rent). |
|
|
115
122
|
|
|
116
123
|
### Discovery & reads
|
|
@@ -121,6 +128,8 @@ Public properties: **`program`**, **`connection`**, **`globalConfig`** (PDA).
|
|
|
121
128
|
| `fetchMarket(marketPda)` | `Market` account. |
|
|
122
129
|
| `fetchAllMarkets(platformId?)` | All markets (optional `memcmp` on `platform_id`); includes outcome labels. |
|
|
123
130
|
| `fetchMarketsByPlatform(platformId)` | Same as `fetchAllMarkets(platformId)`. |
|
|
131
|
+
| `fetchVoidedMarkets()` | `Market` accounts with `is_voided` only (RPC `memcmp` + `dataSize`). |
|
|
132
|
+
| `fetchVoidedParimutuelSurplusCandidates()` | Subset: voided **pari**, not resolved, `sum(outcome_pools)=0`, `total_pool` > 0 (claimable). |
|
|
124
133
|
| `fetchMarketsByCreator(creator)` | Raw rows `{ pubkey, account }[]`, memcmp on creator. |
|
|
125
134
|
| `getUsersMarkets(creator, filters?)` | **`ListedMarket[]`** for creator; optional `platformId` (RPC) + `categoryId` (client filter). |
|
|
126
135
|
| `fetchMarketOutcomeLabels(marketPda, outcomeCount)` | Outcome labels. |
|
|
@@ -345,9 +354,9 @@ const state = await client.fetchParimutuelState(marketPda);
|
|
|
345
354
|
const odds = client.computeParimutuelOdds(state, 2);
|
|
346
355
|
```
|
|
347
356
|
|
|
348
|
-
### Creator: update
|
|
357
|
+
### Creator: update pari pool settings (`updateParimutuelState`)
|
|
349
358
|
|
|
350
|
-
Only the **market creator** can call this while the market is open (not resolved/voided). Pass **current**
|
|
359
|
+
Only the **market creator** can call this while the market is open (not resolved/voided). The instruction updates **penalty bps**, **early-withdraw allowance**, and **per-wallet per-outcome stake rules** in one transaction. Pass **current** values from **`fetchParimutuelState`** and **`fetchMarket`** for any field you are not changing:
|
|
351
360
|
|
|
352
361
|
```ts
|
|
353
362
|
const m = await client.fetchMarket(marketPda);
|
|
@@ -358,17 +367,33 @@ await client.updateParimutuelState(marketPda, {
|
|
|
358
367
|
earlyWithdrawPenaltyBps: pari.earlyWithdrawPenaltyBps,
|
|
359
368
|
penaltyKeptInPoolBps: pari.penaltyKeptInPoolBps,
|
|
360
369
|
isEarlyWithdrawAllowed: false, // block parimutuelWithdraw until close/resolution
|
|
370
|
+
maxWalletOutcomeInvestment: m.maxWalletOutcomeInvestment, // keep existing cap
|
|
371
|
+
isWalletOutcomeStakeExact: m.isWalletOutcomeStakeExact, // keep exact vs ceiling mode
|
|
361
372
|
});
|
|
362
373
|
|
|
363
|
-
// Re-enable early exit later:
|
|
374
|
+
// Re-enable early exit later (still pass wallet fields from `m`):
|
|
364
375
|
await client.updateParimutuelState(marketPda, {
|
|
365
376
|
marketId,
|
|
366
377
|
earlyWithdrawPenaltyBps: pari.earlyWithdrawPenaltyBps,
|
|
367
378
|
penaltyKeptInPoolBps: pari.penaltyKeptInPoolBps,
|
|
368
379
|
isEarlyWithdrawAllowed: true,
|
|
380
|
+
maxWalletOutcomeInvestment: m.maxWalletOutcomeInvestment,
|
|
381
|
+
isWalletOutcomeStakeExact: m.isWalletOutcomeStakeExact,
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
// Example: set a per-wallet cap (base units) and ceiling mode only:
|
|
385
|
+
await client.updateParimutuelState(marketPda, {
|
|
386
|
+
marketId,
|
|
387
|
+
earlyWithdrawPenaltyBps: pari.earlyWithdrawPenaltyBps,
|
|
388
|
+
penaltyKeptInPoolBps: pari.penaltyKeptInPoolBps,
|
|
389
|
+
isEarlyWithdrawAllowed: m.isEarlyWithdrawAllowed,
|
|
390
|
+
maxWalletOutcomeInvestment: new BN(1_000_000),
|
|
391
|
+
isWalletOutcomeStakeExact: false,
|
|
369
392
|
});
|
|
370
393
|
```
|
|
371
394
|
|
|
395
|
+
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
|
+
|
|
372
397
|
### Resolution
|
|
373
398
|
|
|
374
399
|
```ts
|
|
@@ -427,7 +452,7 @@ Use **`derivePlatformRegistry`**, **`derivePlatformProfile`**, **`deriveMarketCa
|
|
|
427
452
|
|
|
428
453
|
Use `marketType: 'parimutuel'` or `'completeSet'` at creation; the choice is permanent.
|
|
429
454
|
|
|
430
|
-
- **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. After **`voidMarket`**, participants **`parimutuelWithdraw`** full net stakes (no penalty / withdraw fees).
|
|
455
|
+
- **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).
|
|
431
456
|
- **Complete-set** — outcome SPL tokens; you still need external liquidity for single-leg trading.
|
|
432
457
|
|
|
433
458
|
## PDA helpers
|
|
@@ -463,7 +488,7 @@ const marketPda = deriveMarket(PROGRAM_ID, creatorPubkey, marketId);
|
|
|
463
488
|
const vaultPda = deriveVault(PROGRAM_ID, marketPda);
|
|
464
489
|
```
|
|
465
490
|
|
|
466
|
-
Offsets **`MARKET_ACCOUNT_CREATOR_MEMCMP_OFFSET
|
|
491
|
+
Offsets **`MARKET_ACCOUNT_CREATOR_MEMCMP_OFFSET`**, **`MARKET_ACCOUNT_PLATFORM_ID_MEMCMP_OFFSET`**, and **`MARKET_ACCOUNT_IS_VOIDED_MEMCMP_OFFSET`** are exported for custom `getProgramAccounts` filters. Use **`marketIsVoidedMemcmp(true)`** for the Borsh-encoded `bool` bytes at that offset. **`fetchVoidedMarkets`** / **`fetchVoidedParimutuelSurplusCandidates`** apply the voided filter so listing cost scales with voided markets only.
|
|
467
492
|
|
|
468
493
|
## `marketUi` helpers
|
|
469
494
|
|
|
@@ -508,26 +533,15 @@ Start from **`agents/skill.md`** in this package for a stable entrypoint; the fu
|
|
|
508
533
|
- Optional: `registerPlatform` → `createMarketCategory` → `createMarket` with ids.
|
|
509
534
|
- Create: `createMarketFull` **or** `createMarket` + resolver / outcome / mint **or** pari init.
|
|
510
535
|
- Complete-set: `mintCompleteSet` → `redeemCompleteSet` → `redeemWinning`.
|
|
511
|
-
- Parimutuel: `parimutuelStake` → optional `parimutuelWithdraw` (if `isEarlyWithdrawAllowed`, or after `voidMarket` for full refunds) → `parimutuelClaim`; creator may
|
|
536
|
+
- 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).
|
|
512
537
|
- Resolution: `voteResolution` → `finalizeResolution`.
|
|
513
|
-
4. **Discovery**: `fetchAllMarkets`, `getUsersMarkets`, `fetchMarketsByCreator`.
|
|
538
|
+
4. **Discovery**: `fetchAllMarkets`, `getUsersMarkets`, `fetchMarketsByCreator`, `fetchVoidedMarkets`, `fetchVoidedParimutuelSurplusCandidates`.
|
|
514
539
|
5. **Safety**: verify signers, PDAs, ATAs, and RPC limits on `getProgramAccounts`.
|
|
515
540
|
|
|
516
541
|
## Changelog
|
|
517
542
|
|
|
518
543
|
See [`CHANGELOG.md`](./CHANGELOG.md) in the package (published to npm). Releases are generated with [standard-version](https://github.com/conventional-changelog/standard-version) from [Conventional Commits](https://www.conventionalcommits.org/) in `app/sdk` (e.g. `feat:`, `fix:`). After running a release script you can edit `CHANGELOG.md` or amend the release commit before `npm publish`.
|
|
519
544
|
|
|
520
|
-
## Releasing (maintainers)
|
|
521
|
-
|
|
522
|
-
From `prediction_market/app/sdk`:
|
|
523
|
-
|
|
524
|
-
1. Commit SDK work with conventional messages so the next bump has sensible notes.
|
|
525
|
-
2. `npm run release:check` — confirms `package.json` version matches git tag `v<version>` (follow the script’s hints if not).
|
|
526
|
-
3. `npm run release:patch`, `release:minor`, or `release:major` — bumps version, updates `CHANGELOG.md`, creates a release commit, and tags `vX.Y.Z`.
|
|
527
|
-
4. Adjust `CHANGELOG.md` or message if needed (`git commit --amend` or a follow-up commit), then `npm publish`.
|
|
528
|
-
|
|
529
|
-
Preview without writing: `npx standard-version --dry-run --release-as patch` (only after `release:check` passes).
|
|
530
|
-
|
|
531
545
|
## Links
|
|
532
546
|
|
|
533
547
|
- [Vercora app](https://vercora.xyz)
|
package/agents/skill.md
CHANGED
|
@@ -68,5 +68,10 @@ Paths are under `node_modules/@vercora-protocol/sdk/` after install.
|
|
|
68
68
|
|
|
69
69
|
## Quick guardrails (parimutuel)
|
|
70
70
|
|
|
71
|
-
-
|
|
71
|
+
- **`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.
|
|
72
|
+
- After `fetchMarket(marketPda)`, read **`isEarlyWithdrawAllowed`**. If `false`, do not propose early-exit **`parimutuelWithdraw`** until close/resolution (**`EarlyWithdrawNotAllowed`**), **unless `isVoided`** — then **`parimutuelWithdraw`** refunds full net stakes (no penalty / withdraw fees).
|
|
73
|
+
- Also read **`maxWalletOutcomeInvestment`** (`BN`, `0` = unlimited) and **`isWalletOutcomeStakeExact`**. When proposing **`parimutuelStake`**, enforce per-wallet caps and exact-stake rules (**`WalletOutcomeInvestmentCapExceeded`**, **`WalletOutcomeExactStakeMismatch`**).
|
|
74
|
+
- **Creators** (open pari market, not resolved/voided): **`updateParimutuelState`** updates penalty bps, **`isEarlyWithdrawAllowed`**, **`maxWalletOutcomeInvestment`**, and **`isWalletOutcomeStakeExact`** in one instruction — pass **full** params (current values from **`fetchMarket`** + **`fetchParimutuelState`** for fields you keep unchanged). If **`isWalletOutcomeStakeExact`** is `true`, **`maxWalletOutcomeInvestment`** must be **> 0** (**`InvalidWalletOutcomeStakeExactConfig`** otherwise).
|
|
75
|
+
- **`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
|
+
- **`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.
|
|
72
77
|
- Use **`isClosedEarly`**, **`isVoided`**, **`winningOutcomeIndex`** for lifecycle — not legacy `closed` / `voided` / `resolvedOutcomeIndex` names.
|
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, AbandonMarketParams, GlobalConfigAccount, MarketAccount, ResolverAccount, UpsertUserProfileParams, VerifyUserProfileParams, UserProfileAccount, UpsertPlatformProfileParams, VerifyPlatformProfileParams, PlatformProfileAccount, ParimutuelStateAccount, ParimutuelPositionAccount, ParimutuelOdds, MarketCategoryAccount, CreateMarketCategoryParams, UpdateMarketCategoryParams, RegisterPlatformParams, UpdateParimutuelStateParams, ResolutionVoteAccount, ListedMarket, GetUsersMarketsFilters } 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, ListedMarket, GetUsersMarketsFilters, VoidedParimutuelSurplusCandidate } from './types';
|
|
6
6
|
export declare class PredictionMarketClient {
|
|
7
7
|
readonly program: Program<Vercora>;
|
|
8
8
|
readonly connection: Connection;
|
|
@@ -33,6 +33,8 @@ export declare class PredictionMarketClient {
|
|
|
33
33
|
/**
|
|
34
34
|
* Update global config. Pass `newAuthority` equal to current authority to keep it unchanged.
|
|
35
35
|
* To rotate the primary authority pass the new pubkey — it must be a valid system account.
|
|
36
|
+
* `params.secondaryAuthority` is the **on-chain** secondary after this tx — pass the intended
|
|
37
|
+
* backup/platform pubkey each time (see `UpdateConfigParams`), not only when rotating secondaries.
|
|
36
38
|
*/
|
|
37
39
|
updateConfig(params: UpdateConfigParams, opts?: anchor.web3.ConfirmOptions): Promise<string>;
|
|
38
40
|
/**
|
|
@@ -91,9 +93,10 @@ export declare class PredictionMarketClient {
|
|
|
91
93
|
/** Pari-mutuel pool + penalty params (step after resolvers, replaces mint init). */
|
|
92
94
|
initializeParimutuelState(marketPda: PublicKey, params: InitializeParimutuelStateParams, opts?: anchor.web3.ConfirmOptions): Promise<string>;
|
|
93
95
|
/**
|
|
94
|
-
* Update early-exit penalty parameters
|
|
96
|
+
* Update early-exit penalty parameters, whether early `parimutuelWithdraw` is allowed (`Market.isEarlyWithdrawAllowed`),
|
|
97
|
+
* and per-wallet per-outcome stake rules (`maxWalletOutcomeInvestment`, `isWalletOutcomeStakeExact`).
|
|
95
98
|
* Only the market creator; market must be pari-mutuel and not resolved/voided.
|
|
96
|
-
* To
|
|
99
|
+
* To change only one knob, pass current values from `fetchMarket` / `fetchParimutuelState` for the rest.
|
|
97
100
|
*/
|
|
98
101
|
updateParimutuelState(marketPda: PublicKey, params: UpdateParimutuelStateParams, opts?: anchor.web3.ConfirmOptions): Promise<string>;
|
|
99
102
|
parimutuelStake(marketPda: PublicKey, params: ParimutuelStakeParams, opts?: anchor.web3.ConfirmOptions): Promise<string>;
|
|
@@ -145,8 +148,21 @@ export declare class PredictionMarketClient {
|
|
|
145
148
|
redeemWinning(user: PublicKey, marketPda: PublicKey, collateralMint: PublicKey, userCollateralAccount: PublicKey, params: RedeemWinningParams, opts?: anchor.web3.ConfirmOptions, platformTreasuryWallet?: PublicKey): Promise<string>;
|
|
146
149
|
/** Market creator or global config authority can close the market before `close_at`. */
|
|
147
150
|
closeMarketEarly(marketPda: PublicKey, params: CloseMarketEarlyParams, opts?: anchor.web3.ConfirmOptions): Promise<string>;
|
|
148
|
-
/**
|
|
151
|
+
/**
|
|
152
|
+
* Void the market (cancel). Creator or global authority only.
|
|
153
|
+
*
|
|
154
|
+
* **Creator** cannot void while pari **outcome pools** (active stakes) or **complete-set outstanding**
|
|
155
|
+
* is non-zero (`CreatorCannotVoidWithActiveLiquidity`). Use a **global config** wallet to cancel live markets.
|
|
156
|
+
* Passes **`parimutuelState`** for pari markets (`null` for complete-set).
|
|
157
|
+
*/
|
|
149
158
|
voidMarket(marketPda: PublicKey, params: VoidMarketParams, opts?: anchor.web3.ConfirmOptions): Promise<string>;
|
|
159
|
+
/**
|
|
160
|
+
* Sweep stranded pari **total_pool** (early-exit pool-keep bonus) on a **voided** market to the
|
|
161
|
+
* platform treasury when **outcome pools are already zero** (no remaining stakes).
|
|
162
|
+
*
|
|
163
|
+
* **Global config primary or secondary authority only** — the connected wallet must be an allowed authority.
|
|
164
|
+
*/
|
|
165
|
+
claimVoidedParimutuelSurplus(marketPda: PublicKey, params: ClaimVoidedParimutuelSurplusParams, opts?: anchor.web3.ConfirmOptions): Promise<string>;
|
|
150
166
|
/**
|
|
151
167
|
* Abandon an incomplete market and recover all rent (market account + vault).
|
|
152
168
|
*
|
|
@@ -190,6 +206,20 @@ export declare class PredictionMarketClient {
|
|
|
190
206
|
* Sorted by `market_id` ascending.
|
|
191
207
|
*/
|
|
192
208
|
getUsersMarkets(creator: PublicKey, filters?: GetUsersMarketsFilters): Promise<ListedMarket[]>;
|
|
209
|
+
/**
|
|
210
|
+
* List `Market` accounts with `is_voided === true` via RPC `memcmp` + `dataSize`
|
|
211
|
+
* (does **not** scan non-voided markets). Uses {@link marketIsVoidedMemcmp}.
|
|
212
|
+
*/
|
|
213
|
+
fetchVoidedMarkets(): Promise<{
|
|
214
|
+
pubkey: PublicKey;
|
|
215
|
+
account: MarketAccount;
|
|
216
|
+
}[]>;
|
|
217
|
+
/**
|
|
218
|
+
* Voided pari markets where every outcome bucket is zero but `total_pool` still holds early-exit
|
|
219
|
+
* pool-keep — claimable via {@link claimVoidedParimutuelSurplus}. Uses {@link fetchVoidedMarkets}
|
|
220
|
+
* so RPC listing cost scales with **voided** markets only (not all markets).
|
|
221
|
+
*/
|
|
222
|
+
fetchVoidedParimutuelSurplusCandidates(): Promise<VoidedParimutuelSurplusCandidate[]>;
|
|
193
223
|
/**
|
|
194
224
|
* Read `MarketOutcome.label` for each active outcome index (parallel fetches).
|
|
195
225
|
* Missing accounts yield `Outcome {i+1}` placeholders.
|
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,O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CA2B1B"}
|
package/dist/client.js
CHANGED
|
@@ -201,6 +201,8 @@ class PredictionMarketClient {
|
|
|
201
201
|
/**
|
|
202
202
|
* Update global config. Pass `newAuthority` equal to current authority to keep it unchanged.
|
|
203
203
|
* To rotate the primary authority pass the new pubkey — it must be a valid system account.
|
|
204
|
+
* `params.secondaryAuthority` is the **on-chain** secondary after this tx — pass the intended
|
|
205
|
+
* backup/platform pubkey each time (see `UpdateConfigParams`), not only when rotating secondaries.
|
|
204
206
|
*/
|
|
205
207
|
async updateConfig(params, opts) {
|
|
206
208
|
return this.program.methods
|
|
@@ -336,11 +338,13 @@ class PredictionMarketClient {
|
|
|
336
338
|
depositPlatformFeeBps: params.depositPlatformFeeBps,
|
|
337
339
|
numResolvers: params.numResolvers,
|
|
338
340
|
maxOutcomeInvestment: params.maxOutcomeInvestment ?? new anchor_1.BN(0),
|
|
341
|
+
maxWalletOutcomeInvestment: params.maxWalletOutcomeInvestment ?? new anchor_1.BN(0),
|
|
339
342
|
title: params.title,
|
|
340
343
|
marketType: (0, types_1.toMarketTypeIx)(params.marketType),
|
|
341
344
|
platformId: (0, pda_1.bnToU32)(platformIdBn),
|
|
342
345
|
categoryId: (0, pda_1.bnToU8)(categoryIdBn),
|
|
343
346
|
isEarlyWithdrawAllowed: params.isEarlyWithdrawAllowed ?? true,
|
|
347
|
+
isWalletOutcomeStakeExact: params.isWalletOutcomeStakeExact ?? false,
|
|
344
348
|
})
|
|
345
349
|
.accounts({
|
|
346
350
|
payer: this.walletKey,
|
|
@@ -529,9 +533,10 @@ class PredictionMarketClient {
|
|
|
529
533
|
return await provider.sendAndConfirm(tx, [], opts ?? { commitment: 'confirmed', skipPreflight: true });
|
|
530
534
|
}
|
|
531
535
|
/**
|
|
532
|
-
* Update early-exit penalty parameters
|
|
536
|
+
* Update early-exit penalty parameters, whether early `parimutuelWithdraw` is allowed (`Market.isEarlyWithdrawAllowed`),
|
|
537
|
+
* and per-wallet per-outcome stake rules (`maxWalletOutcomeInvestment`, `isWalletOutcomeStakeExact`).
|
|
533
538
|
* Only the market creator; market must be pari-mutuel and not resolved/voided.
|
|
534
|
-
* To
|
|
539
|
+
* To change only one knob, pass current values from `fetchMarket` / `fetchParimutuelState` for the rest.
|
|
535
540
|
*/
|
|
536
541
|
async updateParimutuelState(marketPda, params, opts) {
|
|
537
542
|
return this.program.methods
|
|
@@ -540,6 +545,8 @@ class PredictionMarketClient {
|
|
|
540
545
|
earlyWithdrawPenaltyBps: params.earlyWithdrawPenaltyBps,
|
|
541
546
|
penaltyKeptInPoolBps: params.penaltyKeptInPoolBps,
|
|
542
547
|
isEarlyWithdrawAllowed: params.isEarlyWithdrawAllowed,
|
|
548
|
+
maxWalletOutcomeInvestment: params.maxWalletOutcomeInvestment,
|
|
549
|
+
isWalletOutcomeStakeExact: params.isWalletOutcomeStakeExact,
|
|
543
550
|
})
|
|
544
551
|
.accounts({
|
|
545
552
|
creator: this.walletKey,
|
|
@@ -846,14 +853,58 @@ class PredictionMarketClient {
|
|
|
846
853
|
})
|
|
847
854
|
.rpc(opts ?? { skipPreflight: true });
|
|
848
855
|
}
|
|
849
|
-
/**
|
|
856
|
+
/**
|
|
857
|
+
* Void the market (cancel). Creator or global authority only.
|
|
858
|
+
*
|
|
859
|
+
* **Creator** cannot void while pari **outcome pools** (active stakes) or **complete-set outstanding**
|
|
860
|
+
* is non-zero (`CreatorCannotVoidWithActiveLiquidity`). Use a **global config** wallet to cancel live markets.
|
|
861
|
+
* Passes **`parimutuelState`** for pari markets (`null` for complete-set).
|
|
862
|
+
*/
|
|
850
863
|
async voidMarket(marketPda, params, opts) {
|
|
864
|
+
const market = await this.fetchMarket(marketPda);
|
|
865
|
+
const isPari = market.marketType &&
|
|
866
|
+
typeof market.marketType === "object" &&
|
|
867
|
+
"parimutuel" in market.marketType;
|
|
868
|
+
const parimutuelState = isPari
|
|
869
|
+
? (0, pda_1.deriveParimutuelState)(this.program.programId, marketPda)
|
|
870
|
+
: null;
|
|
851
871
|
return this.program.methods
|
|
852
872
|
.voidMarket({ marketId: params.marketId })
|
|
853
873
|
.accounts({
|
|
854
874
|
signer: this.walletKey,
|
|
855
875
|
globalConfig: this.globalConfig,
|
|
856
876
|
market: marketPda,
|
|
877
|
+
parimutuelState,
|
|
878
|
+
})
|
|
879
|
+
.rpc(opts ?? { skipPreflight: true });
|
|
880
|
+
}
|
|
881
|
+
/**
|
|
882
|
+
* Sweep stranded pari **total_pool** (early-exit pool-keep bonus) on a **voided** market to the
|
|
883
|
+
* platform treasury when **outcome pools are already zero** (no remaining stakes).
|
|
884
|
+
*
|
|
885
|
+
* **Global config primary or secondary authority only** — the connected wallet must be an allowed authority.
|
|
886
|
+
*/
|
|
887
|
+
async claimVoidedParimutuelSurplus(marketPda, params, opts) {
|
|
888
|
+
const market = await this.fetchMarket(marketPda);
|
|
889
|
+
const collateralMint = market.collateralMint;
|
|
890
|
+
const collateralTokenProgram = await this.collateralTokenProgramForMint(collateralMint);
|
|
891
|
+
const globalConfig = await this.fetchGlobalConfig();
|
|
892
|
+
const platformTreasuryWallet = globalConfig.platformTreasury;
|
|
893
|
+
const platformTreasuryAta = (0, spl_token_1.getAssociatedTokenAddressSync)(collateralMint, platformTreasuryWallet, false, collateralTokenProgram, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
|
|
894
|
+
return this.program.methods
|
|
895
|
+
.claimVoidedParimutuelSurplus({ marketId: params.marketId })
|
|
896
|
+
.accounts({
|
|
897
|
+
authority: this.walletKey,
|
|
898
|
+
globalConfig: this.globalConfig,
|
|
899
|
+
market: marketPda,
|
|
900
|
+
parimutuelState: (0, pda_1.deriveParimutuelState)(this.program.programId, marketPda),
|
|
901
|
+
vault: (0, pda_1.deriveVault)(this.program.programId, marketPda),
|
|
902
|
+
collateralMint,
|
|
903
|
+
platformTreasuryWallet,
|
|
904
|
+
platformTreasuryAta,
|
|
905
|
+
collateralTokenProgram,
|
|
906
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
907
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
857
908
|
})
|
|
858
909
|
.rpc(opts ?? { skipPreflight: true });
|
|
859
910
|
}
|
|
@@ -922,11 +973,15 @@ class PredictionMarketClient {
|
|
|
922
973
|
isVoided: Boolean(pickDecodedField(acc, 'isVoided', 'is_voided')),
|
|
923
974
|
isEarlyWithdrawAllowed: Boolean(pickDecodedField(acc, 'isEarlyWithdrawAllowed', 'is_early_withdraw_allowed') ??
|
|
924
975
|
true),
|
|
976
|
+
isWalletOutcomeStakeExact: Boolean(pickDecodedField(acc, 'isWalletOutcomeStakeExact', 'is_wallet_outcome_stake_exact') ??
|
|
977
|
+
pickDecodedField(acc, 'walletOutcomeStakeIsExactAmount', 'wallet_outcome_stake_is_exact_amount') ??
|
|
978
|
+
false),
|
|
925
979
|
resolutionThreshold: acc.resolutionThreshold,
|
|
926
980
|
title: String(acc.title ?? ''),
|
|
927
981
|
categoryId: this.bnFieldToListedString(acc.categoryId),
|
|
928
982
|
marketKind,
|
|
929
983
|
maxOutcomeInvestment: this.bnFieldToListedString(acc.maxOutcomeInvestment),
|
|
984
|
+
maxWalletOutcomeInvestment: this.bnFieldToListedString(acc.maxWalletOutcomeInvestment),
|
|
930
985
|
completeSetPerOutcomeOutstanding: this.bnFieldToListedString(acc.completeSetPerOutcomeOutstanding),
|
|
931
986
|
collateralDecimals: Number(acc.collateralDecimals ?? 0),
|
|
932
987
|
platformId: this.bnFieldToListedString(acc.platformId),
|
|
@@ -1031,6 +1086,78 @@ class PredictionMarketClient {
|
|
|
1031
1086
|
}
|
|
1032
1087
|
return listed;
|
|
1033
1088
|
}
|
|
1089
|
+
/**
|
|
1090
|
+
* List `Market` accounts with `is_voided === true` via RPC `memcmp` + `dataSize`
|
|
1091
|
+
* (does **not** scan non-voided markets). Uses {@link marketIsVoidedMemcmp}.
|
|
1092
|
+
*/
|
|
1093
|
+
async fetchVoidedMarkets() {
|
|
1094
|
+
const marketClient = this.program.account.market;
|
|
1095
|
+
const filters = [
|
|
1096
|
+
{ memcmp: (0, pda_1.marketIsVoidedMemcmp)(true) },
|
|
1097
|
+
{ dataSize: marketClient.size },
|
|
1098
|
+
];
|
|
1099
|
+
const rows = await marketClient.all(filters);
|
|
1100
|
+
return rows.map((r) => ({ pubkey: r.publicKey, account: r.account }));
|
|
1101
|
+
}
|
|
1102
|
+
/**
|
|
1103
|
+
* Voided pari markets where every outcome bucket is zero but `total_pool` still holds early-exit
|
|
1104
|
+
* pool-keep — claimable via {@link claimVoidedParimutuelSurplus}. Uses {@link fetchVoidedMarkets}
|
|
1105
|
+
* so RPC listing cost scales with **voided** markets only (not all markets).
|
|
1106
|
+
*/
|
|
1107
|
+
async fetchVoidedParimutuelSurplusCandidates() {
|
|
1108
|
+
const voided = await this.fetchVoidedMarkets();
|
|
1109
|
+
const pariClient = this.program.account.parimutuelState;
|
|
1110
|
+
const narrowed = voided.filter(({ account }) => {
|
|
1111
|
+
const isPari = account.marketType &&
|
|
1112
|
+
typeof account.marketType === 'object' &&
|
|
1113
|
+
'parimutuel' in account.marketType;
|
|
1114
|
+
if (!isPari)
|
|
1115
|
+
return false;
|
|
1116
|
+
if (account.winningOutcomeIndex != null)
|
|
1117
|
+
return false;
|
|
1118
|
+
return true;
|
|
1119
|
+
});
|
|
1120
|
+
const out = [];
|
|
1121
|
+
const chunkSize = 25;
|
|
1122
|
+
for (let i = 0; i < narrowed.length; i += chunkSize) {
|
|
1123
|
+
const chunk = narrowed.slice(i, i + chunkSize);
|
|
1124
|
+
const pariStates = await Promise.all(chunk.map((c) => pariClient
|
|
1125
|
+
.fetch((0, pda_1.deriveParimutuelState)(this.program.programId, c.pubkey))
|
|
1126
|
+
.catch(() => null)));
|
|
1127
|
+
for (let j = 0; j < chunk.length; j++) {
|
|
1128
|
+
const pari = pariStates[j];
|
|
1129
|
+
if (!pari)
|
|
1130
|
+
continue;
|
|
1131
|
+
const outcomeCount = chunk[j].account.outcomeCount;
|
|
1132
|
+
let sumPools = new anchor_1.BN(0);
|
|
1133
|
+
for (let k = 0; k < outcomeCount; k++) {
|
|
1134
|
+
sumPools = sumPools.add((0, pda_1.bnLike)(pari.outcomePools[k] ?? 0));
|
|
1135
|
+
}
|
|
1136
|
+
const totalPool = (0, pda_1.bnLike)(pari.totalPool);
|
|
1137
|
+
if (sumPools.isZero() && totalPool.gt(new anchor_1.BN(0))) {
|
|
1138
|
+
const a = chunk[j].account;
|
|
1139
|
+
out.push({
|
|
1140
|
+
marketPda: chunk[j].pubkey.toBase58(),
|
|
1141
|
+
title: a.title ?? '',
|
|
1142
|
+
marketId: a.marketId.toString(10),
|
|
1143
|
+
creator: a.creator.toBase58(),
|
|
1144
|
+
surplusBaseUnits: totalPool.toString(10),
|
|
1145
|
+
collateralDecimals: a.collateralDecimals,
|
|
1146
|
+
});
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
out.sort((a, b) => {
|
|
1151
|
+
const ba = BigInt(a.surplusBaseUnits);
|
|
1152
|
+
const bb = BigInt(b.surplusBaseUnits);
|
|
1153
|
+
if (bb > ba)
|
|
1154
|
+
return 1;
|
|
1155
|
+
if (bb < ba)
|
|
1156
|
+
return -1;
|
|
1157
|
+
return 0;
|
|
1158
|
+
});
|
|
1159
|
+
return out;
|
|
1160
|
+
}
|
|
1034
1161
|
/**
|
|
1035
1162
|
* Read `MarketOutcome.label` for each active outcome index (parallel fetches).
|
|
1036
1163
|
* Missing accounts yield `Outcome {i+1}` placeholders.
|