@vercora-protocol/sdk 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +240 -0
- package/dist/client.d.ts +169 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +749 -0
- package/dist/client.js.map +1 -0
- package/dist/generated/vercora.d.ts +3717 -0
- package/dist/generated/vercora.d.ts.map +1 -0
- package/dist/generated/vercora.js +3 -0
- package/dist/generated/vercora.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/pda.d.ts +33 -0
- package/dist/pda.d.ts.map +1 -0
- package/dist/pda.js +50 -0
- package/dist/pda.js.map +1 -0
- package/dist/types.d.ts +268 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -0
- package/package.json +31 -0
package/README.md
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
# @vercora-protocol/sdk
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for the [Vercora](https://vercora.xyz) prediction market protocol on Solana (Anchor).
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @vercora-protocol/sdk
|
|
9
|
+
# or
|
|
10
|
+
yarn add @vercora-protocol/sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
**Peer dependencies** (install alongside):
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @coral-xyz/anchor @solana/web3.js @solana/spl-token bn.js
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Quick start
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import * as anchor from "@coral-xyz/anchor";
|
|
23
|
+
import { Program } from "@coral-xyz/anchor";
|
|
24
|
+
import { Connection, clusterApiUrl } from "@solana/web3.js";
|
|
25
|
+
import { PredictionMarketClient } from "@vercora-protocol/sdk";
|
|
26
|
+
import type { Vercora } from "@vercora-protocol/sdk";
|
|
27
|
+
import { BN } from "bn.js";
|
|
28
|
+
|
|
29
|
+
// 1. Set up an Anchor provider (browser wallet / NodeWallet)
|
|
30
|
+
const connection = new Connection(clusterApiUrl("devnet"));
|
|
31
|
+
const provider = new anchor.AnchorProvider(connection, wallet, {});
|
|
32
|
+
anchor.setProvider(provider);
|
|
33
|
+
|
|
34
|
+
// 2. Load the on-chain program (IDL is bundled — no extra file needed)
|
|
35
|
+
import { IDL, PROGRAM_ID } from "@vercora-protocol/sdk";
|
|
36
|
+
const program = new anchor.Program<Vercora>(IDL, PROGRAM_ID, provider);
|
|
37
|
+
|
|
38
|
+
// 3. Create the client
|
|
39
|
+
const client = new PredictionMarketClient(program);
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Market types
|
|
43
|
+
|
|
44
|
+
Use `marketType: 'parimutuel'` or `marketType: 'completeSet'` when creating a market (the Anchor default is `completeSet` if you omit the field — set `parimutuel` explicitly for pool mode). The choice is permanent.
|
|
45
|
+
|
|
46
|
+
### `parimutuel` — pool markets (**easiest to get started**)
|
|
47
|
+
|
|
48
|
+
Stakes go into shared outcome pools on-chain. No outcome SPL tokens are minted. Odds follow pool sizes; the winning side splits the pot at settlement.
|
|
49
|
+
|
|
50
|
+
- **No liquidity layer required** — the pool is the market. Ship without wiring a DEX or running an AMM.
|
|
51
|
+
- **Minimal integration** — stake, withdraw, claim; no outcome-token listings to maintain.
|
|
52
|
+
- Positions are ledger entries, not transferable tokens. Early withdrawal may use a configurable penalty.
|
|
53
|
+
- **Best for:** most prediction-style apps and teams that want live odds and settlement without operating liquidity infrastructure.
|
|
54
|
+
|
|
55
|
+
### `completeSet` — token markets (**needs a liquidity layer**)
|
|
56
|
+
|
|
57
|
+
The protocol mints one SPL outcome token per outcome when users deposit collateral. The **program does not include an order book or AMM** — you must provide or integrate liquidity so users can trade between outcomes.
|
|
58
|
+
|
|
59
|
+
- Outcome tokens are composable SPL assets (wallets, DEXes, DeFi).
|
|
60
|
+
- Mint/redeem full complete sets before close without a counterparty for that step.
|
|
61
|
+
- **Single-outcome trading requires external liquidity** (AMM, RFQ, market-maker, etc.) or users cannot reliably move between legs.
|
|
62
|
+
- **Best for:** teams that control or integrate a DEX, run their own pools, or pair the program with an explicit liquidity strategy.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Usage examples
|
|
67
|
+
|
|
68
|
+
### Create a market
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
import { BN } from "bn.js";
|
|
72
|
+
|
|
73
|
+
const marketId = new BN(Date.now()); // unique u64 per creator
|
|
74
|
+
const { marketPda } = await client.createMarket(
|
|
75
|
+
provider.wallet.publicKey, // creator
|
|
76
|
+
collateralMintPubkey,
|
|
77
|
+
creatorFeeAccountPubkey,
|
|
78
|
+
{
|
|
79
|
+
marketId,
|
|
80
|
+
outcomeCount: 2,
|
|
81
|
+
resolutionThreshold: 1,
|
|
82
|
+
closeAt: new BN(Math.floor(Date.now() / 1000) + 86400), // 24 h from now
|
|
83
|
+
creatorFeeBps: 50,
|
|
84
|
+
depositPlatformFeeBps: 0, // 0 = inherit global config
|
|
85
|
+
numResolvers: 1,
|
|
86
|
+
title: "Will it rain tomorrow?",
|
|
87
|
+
marketType: "completeSet", // or 'parimutuel'
|
|
88
|
+
},
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
// Resolver slots and outcome mints must be initialised before trading
|
|
92
|
+
await client.initializeMarketResolverSlots(marketPda, {
|
|
93
|
+
marketId,
|
|
94
|
+
resolverPubkeys: [resolverPubkey],
|
|
95
|
+
});
|
|
96
|
+
await client.initializeMarketMints(marketPda, marketId);
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Complete-set trading
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
// Mint one complete set (all outcomes)
|
|
103
|
+
await client.mintCompleteSet(
|
|
104
|
+
user,
|
|
105
|
+
marketPda,
|
|
106
|
+
collateralMint,
|
|
107
|
+
userCollateralAta,
|
|
108
|
+
platformTreasury,
|
|
109
|
+
creatorFeeAccount,
|
|
110
|
+
{ marketId, amount: new BN(1_000_000) },
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
// Redeem a complete set back to collateral
|
|
114
|
+
await client.redeemCompleteSet(
|
|
115
|
+
user,
|
|
116
|
+
marketPda,
|
|
117
|
+
collateralMint,
|
|
118
|
+
userCollateralAta,
|
|
119
|
+
{ marketId },
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
// After resolution — redeem the winning outcome tokens
|
|
123
|
+
await client.redeemWinning(user, marketPda, collateralMint, userCollateralAta, {
|
|
124
|
+
marketId,
|
|
125
|
+
amount: winningBalance,
|
|
126
|
+
});
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Parimutuel trading
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
// Stake on an outcome
|
|
133
|
+
await client.parimutuelStake(
|
|
134
|
+
user,
|
|
135
|
+
marketPda,
|
|
136
|
+
collateralMint,
|
|
137
|
+
userCollateralAta,
|
|
138
|
+
platformTreasury,
|
|
139
|
+
creatorFeeAccount,
|
|
140
|
+
{ marketId, outcomeIndex: 0, amount: new BN(500_000) },
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
// Withdraw before market closes (penalty may apply)
|
|
144
|
+
await client.parimutuelWithdraw(
|
|
145
|
+
user,
|
|
146
|
+
marketPda,
|
|
147
|
+
collateralMint,
|
|
148
|
+
userCollateralAta,
|
|
149
|
+
{ marketId, outcomeIndex: 0, amount: new BN(500_000) },
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
// Claim winnings after resolution
|
|
153
|
+
await client.parimutuelClaim(
|
|
154
|
+
user,
|
|
155
|
+
marketPda,
|
|
156
|
+
collateralMint,
|
|
157
|
+
userCollateralAta,
|
|
158
|
+
{ marketId, outcomeIndex: 0 },
|
|
159
|
+
);
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Resolution
|
|
163
|
+
|
|
164
|
+
```ts
|
|
165
|
+
// Resolver votes on the winning outcome
|
|
166
|
+
await client.voteResolution(marketPda, {
|
|
167
|
+
marketId,
|
|
168
|
+
resolverIndex: 0,
|
|
169
|
+
outcomeIndex: 1, // 0-based
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
// Once the threshold is met, anyone can finalize
|
|
173
|
+
await client.finalizeResolution(marketPda, { marketId });
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Read on-chain state
|
|
177
|
+
|
|
178
|
+
```ts
|
|
179
|
+
const market = await client.fetchMarket(marketPda);
|
|
180
|
+
console.log(market.title, market.marketType, market.closed);
|
|
181
|
+
|
|
182
|
+
const config = await client.fetchGlobalConfig();
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## PDA helpers
|
|
186
|
+
|
|
187
|
+
All PDAs are derived in `pda.ts` and re-exported from the package:
|
|
188
|
+
|
|
189
|
+
```ts
|
|
190
|
+
import {
|
|
191
|
+
deriveGlobalConfig,
|
|
192
|
+
deriveAllowedMint,
|
|
193
|
+
deriveMarket,
|
|
194
|
+
deriveVault,
|
|
195
|
+
deriveOutcomeMint,
|
|
196
|
+
deriveAllOutcomeMints,
|
|
197
|
+
deriveResolver,
|
|
198
|
+
deriveAllResolvers,
|
|
199
|
+
deriveResolutionVote,
|
|
200
|
+
deriveUserProfile,
|
|
201
|
+
} from "@vercora-protocol/sdk";
|
|
202
|
+
|
|
203
|
+
const marketPda = deriveMarket(program.programId, creatorPubkey, marketId);
|
|
204
|
+
const vaultPda = deriveVault(program.programId, marketPda);
|
|
205
|
+
const [mint0] = deriveAllOutcomeMints(program.programId, marketPda, 2);
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## TypeScript types
|
|
209
|
+
|
|
210
|
+
All parameter and account types are exported directly:
|
|
211
|
+
|
|
212
|
+
```ts
|
|
213
|
+
import type {
|
|
214
|
+
CreateMarketParams,
|
|
215
|
+
MarketAccount,
|
|
216
|
+
ParimutuelStateAccount,
|
|
217
|
+
ParimutuelOdds,
|
|
218
|
+
GlobalConfigAccount,
|
|
219
|
+
UserProfileAccount,
|
|
220
|
+
} from "@vercora-protocol/sdk";
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## AI agent integration
|
|
224
|
+
|
|
225
|
+
If you are building agents or automation on top of this protocol:
|
|
226
|
+
|
|
227
|
+
1. **Bootstrap**: create a `Connection`, wallet, `Program<Vercora>`, then `PredictionMarketClient`.
|
|
228
|
+
2. **Read + route**: call `fetchMarket(marketPda)` and branch by `market.marketType`.
|
|
229
|
+
3. **Flow**:
|
|
230
|
+
- Create: `createMarket` → `initializeMarketResolverSlots` → `initializeMarketMints` (or `initializeParimutuelState`)
|
|
231
|
+
- Complete-set: `mintCompleteSet` → `redeemCompleteSet` → `redeemWinning`
|
|
232
|
+
- Parimutuel: `parimutuelStake` → `parimutuelWithdraw` → `parimutuelClaim`
|
|
233
|
+
- Resolution: `voteResolution` → `finalizeResolution`
|
|
234
|
+
4. **Safety**: verify signer role, derive PDAs with helpers, handle missing ATAs, return tx signatures.
|
|
235
|
+
|
|
236
|
+
## Links
|
|
237
|
+
|
|
238
|
+
- [GitHub source](https://github.com/vercora/vercora-anchor)
|
|
239
|
+
- [Vercora app](https://vercora.xyz)
|
|
240
|
+
- [npm package](https://www.npmjs.com/package/@vercora-protocol/sdk)
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import * as anchor from '@coral-xyz/anchor';
|
|
2
|
+
import { Program, BN } from '@coral-xyz/anchor';
|
|
3
|
+
import { Connection, PublicKey } from '@solana/web3.js';
|
|
4
|
+
import type { Vercora } from './generated/vercora';
|
|
5
|
+
import type { CreateMarketParams, InitializeParimutuelStateParams, ParimutuelStakeParams, ParimutuelWithdrawParams, ParimutuelClaimParams, InitializeConfigParams, UpdateConfigParams, InitializeMarketResolverSlotsParams, MintCompleteSetParams, RedeemCompleteSetParams, VoteResolutionParams, FinalizeResolutionParams, RevokeResolutionVoteParams, RedeemWinningParams, CloseMarketEarlyParams, VoidMarketParams, GlobalConfigAccount, MarketAccount, ResolverAccount, UpsertUserProfileParams, VerifyUserProfileParams, UserProfileAccount, ParimutuelStateAccount, ParimutuelPositionAccount, ParimutuelOdds } from './types';
|
|
6
|
+
export declare class PredictionMarketClient {
|
|
7
|
+
readonly program: Program<Vercora>;
|
|
8
|
+
readonly connection: Connection;
|
|
9
|
+
readonly globalConfig: PublicKey;
|
|
10
|
+
constructor(program: Program<Vercora>);
|
|
11
|
+
private get walletKey();
|
|
12
|
+
private collateralTokenProgramForMint;
|
|
13
|
+
/** Platform treasury wallet ATA for `collateralMint`, created by payer if missing (e.g. before pari init). */
|
|
14
|
+
private treasuryCollateralAtaCreateIfMissingInstructions;
|
|
15
|
+
/** Create collateral ATA for `owner` if it does not exist yet (bundled with `createMarket`). */
|
|
16
|
+
private createCollateralAtaIfMissingInstructions;
|
|
17
|
+
/**
|
|
18
|
+
* Initialize the global config. Must be called once by the platform authority.
|
|
19
|
+
* `platformTreasuryWallet` is the wallet address that receives platform fees;
|
|
20
|
+
* ATAs are derived per-mint automatically during mint/redeem.
|
|
21
|
+
*/
|
|
22
|
+
initializeConfig(params: InitializeConfigParams, opts?: anchor.web3.ConfirmOptions): Promise<string>;
|
|
23
|
+
/**
|
|
24
|
+
* Update global config. Pass `newAuthority` equal to current authority to keep it unchanged.
|
|
25
|
+
* To rotate the primary authority pass the new pubkey — it must be a valid system account.
|
|
26
|
+
*/
|
|
27
|
+
updateConfig(params: UpdateConfigParams, opts?: anchor.web3.ConfirmOptions): Promise<string>;
|
|
28
|
+
/**
|
|
29
|
+
* Add a collateral mint to the allowlist.
|
|
30
|
+
* Only the global config authority can call this.
|
|
31
|
+
*/
|
|
32
|
+
addAllowedCollateralMint(mint: PublicKey, opts?: anchor.web3.ConfirmOptions): Promise<string>;
|
|
33
|
+
/** Remove a collateral mint from the allowlist. */
|
|
34
|
+
removeAllowedCollateralMint(mint: PublicKey, opts?: anchor.web3.ConfirmOptions): Promise<string>;
|
|
35
|
+
/**
|
|
36
|
+
* Step 1 — Create Market + Vault.
|
|
37
|
+
* Returns the market PDA and the transaction signature.
|
|
38
|
+
*/
|
|
39
|
+
createMarket(creator: PublicKey, collateralMint: PublicKey, creatorFeeAccount: PublicKey, params: CreateMarketParams, opts?: anchor.web3.ConfirmOptions): Promise<{
|
|
40
|
+
marketPda: PublicKey;
|
|
41
|
+
sig: string;
|
|
42
|
+
}>;
|
|
43
|
+
/**
|
|
44
|
+
* Step 2 — Initialize resolver PDAs for slots `0..resolverPubkeys.length-1` in **one** transaction.
|
|
45
|
+
* Optional `parimutuelStateParams` appends `initializeParimutuelState` in the same tx (no ordering
|
|
46
|
+
* dependency vs resolvers on-chain).
|
|
47
|
+
*/
|
|
48
|
+
initializeMarketResolverSlots(marketPda: PublicKey, params: InitializeMarketResolverSlotsParams, opts?: anchor.web3.ConfirmOptions, parimutuelStateParams?: InitializeParimutuelStateParams): Promise<string>;
|
|
49
|
+
/**
|
|
50
|
+
* Step 3 — Initialize 8 Outcome Mints.
|
|
51
|
+
* Decimals are inherited from the collateral mint stored on the market account.
|
|
52
|
+
*/
|
|
53
|
+
initializeMarketMints(marketPda: PublicKey, marketId: BN, opts?: anchor.web3.ConfirmOptions): Promise<string>;
|
|
54
|
+
/**
|
|
55
|
+
* Convenience: run all 3 market creation steps in sequence.
|
|
56
|
+
* Returns the market PDA.
|
|
57
|
+
*/
|
|
58
|
+
createMarketFull(creator: PublicKey, collateralMint: PublicKey, creatorFeeAccount: PublicKey,
|
|
59
|
+
/** Length must equal `params.numResolvers` (typically the first N of an 8-slot UI). */
|
|
60
|
+
resolverPubkeys: PublicKey[], params: CreateMarketParams, opts?: anchor.web3.ConfirmOptions): Promise<PublicKey>;
|
|
61
|
+
/** Pari-mutuel pool + penalty params (step after resolvers, replaces mint init). */
|
|
62
|
+
initializeParimutuelState(marketPda: PublicKey, params: InitializeParimutuelStateParams, opts?: anchor.web3.ConfirmOptions): Promise<string>;
|
|
63
|
+
parimutuelStake(marketPda: PublicKey, params: ParimutuelStakeParams, opts?: anchor.web3.ConfirmOptions): Promise<string>;
|
|
64
|
+
parimutuelWithdraw(marketPda: PublicKey, params: ParimutuelWithdrawParams, opts?: anchor.web3.ConfirmOptions): Promise<string>;
|
|
65
|
+
parimutuelClaim(marketPda: PublicKey, params: ParimutuelClaimParams, opts?: anchor.web3.ConfirmOptions): Promise<string>;
|
|
66
|
+
/**
|
|
67
|
+
* Mint a complete set of outcome tokens.
|
|
68
|
+
* Fetches `market.outcomeCount` and passes `2 * outcomeCount` remaining accounts:
|
|
69
|
+
* `[outcome_mint_i, user_ata_i]` for each active outcome.
|
|
70
|
+
* Creates any missing outcome ATAs for `user` before sending the instruction.
|
|
71
|
+
* `platformTreasuryWallet` must match GlobalConfig.platformTreasury. The treasury
|
|
72
|
+
* ATA for this collateral mint must already exist (create it client-side if needed).
|
|
73
|
+
* Pass `collateralTokenProgram` as TOKEN_2022_PROGRAM_ID for Token-2022 mints.
|
|
74
|
+
*/
|
|
75
|
+
mintCompleteSet(user: PublicKey, marketPda: PublicKey, collateralMint: PublicKey, userCollateralAccount: PublicKey, platformTreasuryWallet: PublicKey, creatorFeeAccount: PublicKey, params: MintCompleteSetParams, opts?: anchor.web3.ConfirmOptions, collateralTokenProgram?: PublicKey): Promise<string>;
|
|
76
|
+
/**
|
|
77
|
+
* Burn one complete set (10^decimals base units of each outcome) and receive
|
|
78
|
+
* the same amount of collateral base units back.
|
|
79
|
+
*/
|
|
80
|
+
redeemCompleteSet(user: PublicKey, marketPda: PublicKey, collateralMint: PublicKey, userCollateralAccount: PublicKey, params: RedeemCompleteSetParams, opts?: anchor.web3.ConfirmOptions): Promise<string>;
|
|
81
|
+
/**
|
|
82
|
+
* Resolver casts a vote for an outcome. Fails if they already have an active vote;
|
|
83
|
+
* call `revokeResolutionVote` first to change outcome (tally 1 → 0 → 1).
|
|
84
|
+
*/
|
|
85
|
+
voteResolution(marketPda: PublicKey, params: VoteResolutionParams, opts?: anchor.web3.ConfirmOptions): Promise<string>;
|
|
86
|
+
/** Clears the resolver’s active vote and decrements that outcome’s on-chain tally. */
|
|
87
|
+
revokeResolutionVote(marketPda: PublicKey, params: RevokeResolutionVoteParams, opts?: anchor.web3.ConfirmOptions): Promise<string>;
|
|
88
|
+
/**
|
|
89
|
+
* Anyone can call `finalizeResolution`. It is a no-op if the threshold is
|
|
90
|
+
* not yet reached; resolves the market once M votes agree on one outcome.
|
|
91
|
+
* Passes optional per-outcome tally accounts (null if that tally PDA was never created).
|
|
92
|
+
*/
|
|
93
|
+
finalizeResolution(marketPda: PublicKey, params: FinalizeResolutionParams, opts?: anchor.web3.ConfirmOptions): Promise<string>;
|
|
94
|
+
/**
|
|
95
|
+
* Burn `amount` winning outcome token base units and receive the same
|
|
96
|
+
* amount of collateral base units from the vault.
|
|
97
|
+
* `platformTreasuryWallet` is the wallet address from GlobalConfig — fetched
|
|
98
|
+
* automatically from on-chain state if not provided.
|
|
99
|
+
*/
|
|
100
|
+
redeemWinning(user: PublicKey, marketPda: PublicKey, collateralMint: PublicKey, userCollateralAccount: PublicKey, params: RedeemWinningParams, opts?: anchor.web3.ConfirmOptions, platformTreasuryWallet?: PublicKey): Promise<string>;
|
|
101
|
+
/** Market creator or global config authority can close the market before `close_at`. */
|
|
102
|
+
closeMarketEarly(marketPda: PublicKey, params: CloseMarketEarlyParams, opts?: anchor.web3.ConfirmOptions): Promise<string>;
|
|
103
|
+
/** Void the market (cancel); enables full-set redemption for all holders. Creator or global authority only. */
|
|
104
|
+
voidMarket(marketPda: PublicKey, params: VoidMarketParams, opts?: anchor.web3.ConfirmOptions): Promise<string>;
|
|
105
|
+
fetchGlobalConfig(): Promise<GlobalConfigAccount>;
|
|
106
|
+
fetchMarket(market: PublicKey): Promise<MarketAccount>;
|
|
107
|
+
/** Returns the collateral balance (base units) held in the vault. */
|
|
108
|
+
fetchVaultBalance(market: PublicKey): Promise<bigint>;
|
|
109
|
+
/** Returns the outcome token balance (base units) for a user and outcome index. */
|
|
110
|
+
fetchOutcomeBalance(market: PublicKey, user: PublicKey, outcomeIndex: number): Promise<bigint>;
|
|
111
|
+
/**
|
|
112
|
+
* Create or update the caller's on-chain user profile.
|
|
113
|
+
* The PDA `["user-profile", wallet]` is initialized on first call (payer = wallet);
|
|
114
|
+
* subsequent calls update `display_name` and `url` without resetting the `verified` flag.
|
|
115
|
+
*/
|
|
116
|
+
upsertUserProfile(params: UpsertUserProfileParams, opts?: anchor.web3.ConfirmOptions): Promise<string>;
|
|
117
|
+
/**
|
|
118
|
+
* Close the caller's user profile, reclaiming the rent lamports.
|
|
119
|
+
* The profile PDA is zeroed and lamports are returned to the wallet.
|
|
120
|
+
*/
|
|
121
|
+
closeUserProfile(opts?: anchor.web3.ConfirmOptions): Promise<string>;
|
|
122
|
+
/**
|
|
123
|
+
* Set or revoke the `verified` flag on any user's profile.
|
|
124
|
+
* Only callable by the platform primary or secondary authority (stored in GlobalConfig).
|
|
125
|
+
*
|
|
126
|
+
* @param targetWallet - The wallet whose profile to update.
|
|
127
|
+
* @param params - `{ verified: boolean }` — true to verify, false to revoke.
|
|
128
|
+
*/
|
|
129
|
+
verifyUserProfile(targetWallet: PublicKey, params: VerifyUserProfileParams, opts?: anchor.web3.ConfirmOptions): Promise<string>;
|
|
130
|
+
/**
|
|
131
|
+
* Fetch a user's on-chain profile. Returns `null` if the profile has never
|
|
132
|
+
* been created (or has been closed).
|
|
133
|
+
*/
|
|
134
|
+
fetchUserProfile(wallet: PublicKey): Promise<UserProfileAccount | null>;
|
|
135
|
+
/** Fetch the parimutuel pool state (pool totals, penalty parameters, resolved snapshots). */
|
|
136
|
+
fetchParimutuelState(market: PublicKey): Promise<ParimutuelStateAccount>;
|
|
137
|
+
/**
|
|
138
|
+
* Fetch a user's parimutuel stake position for one outcome.
|
|
139
|
+
* Returns `null` if the position PDA has never been initialized.
|
|
140
|
+
*/
|
|
141
|
+
fetchParimutuelPosition(market: PublicKey, user: PublicKey, outcomeIndex: number): Promise<ParimutuelPositionAccount | null>;
|
|
142
|
+
/**
|
|
143
|
+
* Fetch outcome token balances (base units) for all active outcomes for a user in a
|
|
144
|
+
* complete-set market. Returns an array of length `outcomeCount`; missing ATAs yield `0n`.
|
|
145
|
+
*/
|
|
146
|
+
fetchAllOutcomeBalances(market: PublicKey, user: PublicKey, outcomeCount: number): Promise<bigint[]>;
|
|
147
|
+
/**
|
|
148
|
+
* Compute implied win probabilities and gross payout multipliers from a `ParimutuelStateAccount`.
|
|
149
|
+
* Outcomes with a zero pool are treated as having 0 probability and 0 multiplier.
|
|
150
|
+
*
|
|
151
|
+
* @param state - Result of `fetchParimutuelState`.
|
|
152
|
+
* @param outcomeCount - Number of active outcomes (from `MarketAccount.outcomeCount`).
|
|
153
|
+
*/
|
|
154
|
+
computeParimutuelOdds(state: ParimutuelStateAccount, outcomeCount: number): ParimutuelOdds;
|
|
155
|
+
/** Fetch the resolver account for a given slot index (0–7). */
|
|
156
|
+
fetchResolver(market: PublicKey, resolverIndex: number): Promise<ResolverAccount>;
|
|
157
|
+
/**
|
|
158
|
+
* Fetch all initialized resolver accounts for a market in parallel.
|
|
159
|
+
* Slots whose PDA has never been created are omitted from the result.
|
|
160
|
+
*
|
|
161
|
+
* @param numResolvers - Value of `MarketAccount.numResolvers` (or an upper bound like 8).
|
|
162
|
+
*/
|
|
163
|
+
fetchAllResolvers(market: PublicKey, numResolvers: number): Promise<{
|
|
164
|
+
index: number;
|
|
165
|
+
resolverPubkey: PublicKey;
|
|
166
|
+
}[]>;
|
|
167
|
+
private _ensureAtas;
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +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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