pnp-sdk 0.2.8 → 0.2.9
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/package.json +1 -1
- package/dist/chunk-HN2SKUTC.js +0 -11664
- package/dist/chunk-HN2SKUTC.js.map +0 -1
- package/dist/cli.cjs +0 -11904
- package/dist/cli.cjs.map +0 -1
- package/dist/cli.d.cts +0 -1
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +0 -310
- package/dist/cli.js.map +0 -1
- package/dist/index.cjs +0 -11686
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -1188
- package/dist/index.d.ts +0 -1188
- package/dist/index.js +0 -25
- package/dist/index.js.map +0 -1
package/dist/index.d.ts
DELETED
|
@@ -1,1188 +0,0 @@
|
|
|
1
|
-
import * as _solana_web3_js from '@solana/web3.js';
|
|
2
|
-
import { Connection, PublicKey, Commitment as Commitment$1, Transaction, VersionedTransaction, Keypair } from '@solana/web3.js';
|
|
3
|
-
import { z } from 'zod';
|
|
4
|
-
import * as anchor from '@coral-xyz/anchor';
|
|
5
|
-
import { Idl } from '@coral-xyz/anchor';
|
|
6
|
-
import { BN } from 'bn.js';
|
|
7
|
-
|
|
8
|
-
type Commitment = "processed" | "confirmed" | "finalized";
|
|
9
|
-
interface Logger {
|
|
10
|
-
debug?: (...args: any[]) => void;
|
|
11
|
-
info?: (...args: any[]) => void;
|
|
12
|
-
warn?: (...args: any[]) => void;
|
|
13
|
-
error?: (...args: any[]) => void;
|
|
14
|
-
}
|
|
15
|
-
interface SdkConfig {
|
|
16
|
-
rpcUrl: string;
|
|
17
|
-
commitment?: Commitment;
|
|
18
|
-
httpHeaders?: Record<string, string>;
|
|
19
|
-
priorityFeeMicroLamports?: number;
|
|
20
|
-
computeUnitLimit?: number;
|
|
21
|
-
computeUnitPriceMicroLamports?: number;
|
|
22
|
-
addressLookupTables?: unknown[];
|
|
23
|
-
logger?: Logger;
|
|
24
|
-
}
|
|
25
|
-
declare class SdkError extends Error {
|
|
26
|
-
code: string;
|
|
27
|
-
details?: unknown;
|
|
28
|
-
constructor(code: string, message: string, details?: unknown);
|
|
29
|
-
}
|
|
30
|
-
declare class ValidationError extends SdkError {
|
|
31
|
-
constructor(message: string, details?: unknown);
|
|
32
|
-
}
|
|
33
|
-
declare class TransportError extends SdkError {
|
|
34
|
-
constructor(message: string, details?: unknown);
|
|
35
|
-
}
|
|
36
|
-
declare class ProgramError extends SdkError {
|
|
37
|
-
programErrorCode?: number;
|
|
38
|
-
logs?: string[];
|
|
39
|
-
constructor(message: string, details?: unknown, programErrorCode?: number, logs?: string[]);
|
|
40
|
-
}
|
|
41
|
-
type PubkeyLike = string;
|
|
42
|
-
type U64Like = bigint | number | string;
|
|
43
|
-
type WinningTokenLike = "none" | "yes" | "no" | number | Record<string, unknown> | null;
|
|
44
|
-
interface MarketType {
|
|
45
|
-
id: U64Like;
|
|
46
|
-
resolved: boolean;
|
|
47
|
-
market_reserves: U64Like;
|
|
48
|
-
collateral_token: PubkeyLike;
|
|
49
|
-
winning_token_id: WinningTokenLike;
|
|
50
|
-
yes_token_mint: PubkeyLike;
|
|
51
|
-
no_token_mint: PubkeyLike;
|
|
52
|
-
yes_token_supply_minted: U64Like;
|
|
53
|
-
no_token_supply_minted: U64Like;
|
|
54
|
-
creator: PubkeyLike;
|
|
55
|
-
creator_fee_treasury: PubkeyLike;
|
|
56
|
-
question: string;
|
|
57
|
-
initial_liquidity: U64Like;
|
|
58
|
-
end_time: U64Like;
|
|
59
|
-
bump: number;
|
|
60
|
-
creation_time: U64Like;
|
|
61
|
-
resolvable: boolean;
|
|
62
|
-
force_resolve: boolean;
|
|
63
|
-
version: number;
|
|
64
|
-
}
|
|
65
|
-
interface MarketsResponse {
|
|
66
|
-
count: number;
|
|
67
|
-
data: Array<{
|
|
68
|
-
publicKey: string;
|
|
69
|
-
account: MarketType;
|
|
70
|
-
}>;
|
|
71
|
-
}
|
|
72
|
-
interface GlobalConfigType {
|
|
73
|
-
admin: PubkeyLike;
|
|
74
|
-
oracle_program: PubkeyLike;
|
|
75
|
-
fee: U64Like;
|
|
76
|
-
creator_fee: U64Like;
|
|
77
|
-
bump: number;
|
|
78
|
-
yes_global_metadata: string;
|
|
79
|
-
no_global_metadata: string;
|
|
80
|
-
collateral_token_mint: PubkeyLike;
|
|
81
|
-
global_id: U64Like;
|
|
82
|
-
min_liquidity: U64Like;
|
|
83
|
-
buffer_period: U64Like;
|
|
84
|
-
burn_fee: U64Like;
|
|
85
|
-
trading_paused: boolean;
|
|
86
|
-
}
|
|
87
|
-
interface SettlementCriteria {
|
|
88
|
-
category: string;
|
|
89
|
-
reasoning: string;
|
|
90
|
-
resolvable: boolean;
|
|
91
|
-
resolution_sources: string[];
|
|
92
|
-
settlement_criteria: string;
|
|
93
|
-
suggested_improvements: string;
|
|
94
|
-
}
|
|
95
|
-
interface SettlementData {
|
|
96
|
-
answer: string;
|
|
97
|
-
reasoning: string;
|
|
98
|
-
resolved?: boolean;
|
|
99
|
-
winning_token_id?: string;
|
|
100
|
-
resolution_time?: string;
|
|
101
|
-
settlement_description?: string;
|
|
102
|
-
resolution_source?: string;
|
|
103
|
-
}
|
|
104
|
-
interface MarketMeta {
|
|
105
|
-
market: string;
|
|
106
|
-
market_volume: number;
|
|
107
|
-
image: string | null;
|
|
108
|
-
initial_liquidity: number;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Web3-agnostic shape for the result of a P2P market operation.
|
|
112
|
-
* Note: The Anchor-based module returns actual PublicKey instances at runtime.
|
|
113
|
-
* When exposing results at the SDK boundary, prefer serializing these to base58 strings to match P2PMarketResponse.
|
|
114
|
-
*/
|
|
115
|
-
interface P2PMarketResponse {
|
|
116
|
-
signature: string;
|
|
117
|
-
market: PubkeyLike;
|
|
118
|
-
yesTokenMint: PubkeyLike;
|
|
119
|
-
noTokenMint: PubkeyLike;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
declare class Client {
|
|
123
|
-
readonly connection: Connection;
|
|
124
|
-
readonly programId: PublicKey;
|
|
125
|
-
readonly commitment: Commitment$1;
|
|
126
|
-
readonly logger: Logger;
|
|
127
|
-
readonly isDevnet: boolean;
|
|
128
|
-
constructor(cfg: SdkConfig);
|
|
129
|
-
fail(code: string, message: string, details?: unknown): TransportError;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
type AccountsMap = Record<string, PublicKey>;
|
|
133
|
-
|
|
134
|
-
type CreateMarketArgs = {
|
|
135
|
-
question: string;
|
|
136
|
-
initial_liquidity: bigint;
|
|
137
|
-
end_time: bigint;
|
|
138
|
-
creator?: PublicKey;
|
|
139
|
-
yes_odds_bps?: number;
|
|
140
|
-
oracle?: PublicKey;
|
|
141
|
-
};
|
|
142
|
-
type MintDecisionTokensArgs = {
|
|
143
|
-
amount: bigint;
|
|
144
|
-
buy_yes_token: boolean;
|
|
145
|
-
minimum_out: bigint;
|
|
146
|
-
};
|
|
147
|
-
type BurnDecisionTokensArgs = {
|
|
148
|
-
amount: bigint;
|
|
149
|
-
burn_yes_token: boolean;
|
|
150
|
-
};
|
|
151
|
-
type SetMarketResolvableV2Args = {
|
|
152
|
-
market_id: bigint;
|
|
153
|
-
resolvable: boolean;
|
|
154
|
-
force_resolve?: boolean;
|
|
155
|
-
};
|
|
156
|
-
type SetMarketResolvableV3Args = {
|
|
157
|
-
resolvable: boolean;
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
interface SignerLike {
|
|
161
|
-
publicKey: PublicKey;
|
|
162
|
-
signTransaction(tx: Transaction | VersionedTransaction): Promise<Transaction | VersionedTransaction>;
|
|
163
|
-
signAllTransactions?(txs: (Transaction | VersionedTransaction)[]): Promise<(Transaction | VersionedTransaction)[]>;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
declare const CreateMarketSchema: z.ZodObject<{
|
|
167
|
-
baseMint: z.ZodOptional<z.ZodType<PublicKey, z.ZodTypeDef, PublicKey>>;
|
|
168
|
-
quoteMint: z.ZodOptional<z.ZodType<PublicKey, z.ZodTypeDef, PublicKey>>;
|
|
169
|
-
question: z.ZodOptional<z.ZodString>;
|
|
170
|
-
initialLiquidity: z.ZodOptional<z.ZodBigInt>;
|
|
171
|
-
endTime: z.ZodOptional<z.ZodBigInt>;
|
|
172
|
-
tickSize: z.ZodOptional<z.ZodBigInt>;
|
|
173
|
-
lotSize: z.ZodOptional<z.ZodBigInt>;
|
|
174
|
-
}, "strip", z.ZodTypeAny, {
|
|
175
|
-
question?: string | undefined;
|
|
176
|
-
initialLiquidity?: bigint | undefined;
|
|
177
|
-
endTime?: bigint | undefined;
|
|
178
|
-
baseMint?: PublicKey | undefined;
|
|
179
|
-
quoteMint?: PublicKey | undefined;
|
|
180
|
-
tickSize?: bigint | undefined;
|
|
181
|
-
lotSize?: bigint | undefined;
|
|
182
|
-
}, {
|
|
183
|
-
question?: string | undefined;
|
|
184
|
-
initialLiquidity?: bigint | undefined;
|
|
185
|
-
endTime?: bigint | undefined;
|
|
186
|
-
baseMint?: PublicKey | undefined;
|
|
187
|
-
quoteMint?: PublicKey | undefined;
|
|
188
|
-
tickSize?: bigint | undefined;
|
|
189
|
-
lotSize?: bigint | undefined;
|
|
190
|
-
}>;
|
|
191
|
-
declare class MarketModule {
|
|
192
|
-
private readonly client;
|
|
193
|
-
private readonly signer;
|
|
194
|
-
constructor(client: Client, signer: SignerLike);
|
|
195
|
-
createMarket(params: z.infer<typeof CreateMarketSchema>): Promise<{
|
|
196
|
-
signature: string | undefined;
|
|
197
|
-
market: PublicKey;
|
|
198
|
-
}>;
|
|
199
|
-
createMarketIdl(accounts: AccountsMap, args: CreateMarketArgs): Promise<{
|
|
200
|
-
signature: string | undefined;
|
|
201
|
-
}>;
|
|
202
|
-
createMarketDerived(params: {
|
|
203
|
-
question: string;
|
|
204
|
-
initialLiquidity: bigint;
|
|
205
|
-
endTime: bigint;
|
|
206
|
-
collateralMint?: PublicKey;
|
|
207
|
-
}): Promise<{
|
|
208
|
-
signature: string | undefined;
|
|
209
|
-
market: PublicKey;
|
|
210
|
-
}>;
|
|
211
|
-
fetchGlobalConfig(): Promise<{
|
|
212
|
-
publicKey: PublicKey;
|
|
213
|
-
account: any;
|
|
214
|
-
}>;
|
|
215
|
-
fetchMarket(market: PublicKey): Promise<{
|
|
216
|
-
publicKey: PublicKey;
|
|
217
|
-
account: any;
|
|
218
|
-
}>;
|
|
219
|
-
/**
|
|
220
|
-
* ⚠️ DEVNET/TESTING ONLY - This function is for devnet and testing purposes only.
|
|
221
|
-
* It will NOT work on mainnet. Use this only for development and testing.
|
|
222
|
-
*/
|
|
223
|
-
setMarketResolvableIdl(accounts: AccountsMap, args: SetMarketResolvableV2Args): Promise<{
|
|
224
|
-
signature: string;
|
|
225
|
-
}>;
|
|
226
|
-
/**
|
|
227
|
-
* Set market resolvable status for V2 markets.
|
|
228
|
-
*
|
|
229
|
-
* ⚠️ DEVNET/TESTING ONLY - This function is for devnet and testing purposes only.
|
|
230
|
-
* It will NOT work on mainnet. Use this only for development and testing.
|
|
231
|
-
*
|
|
232
|
-
* @param params - Parameters for setting market resolvable status
|
|
233
|
-
* @param params.market - Market public key
|
|
234
|
-
* @param params.resolvable - New resolvable status (true/false)
|
|
235
|
-
* @param params.forceResolve - Optional: force resolve (allow immediate refunds)
|
|
236
|
-
* @returns Transaction signature
|
|
237
|
-
*/
|
|
238
|
-
setMarketResolvable(params: {
|
|
239
|
-
market: PublicKey;
|
|
240
|
-
resolvable: boolean;
|
|
241
|
-
forceResolve?: boolean;
|
|
242
|
-
}): Promise<{
|
|
243
|
-
signature: string;
|
|
244
|
-
}>;
|
|
245
|
-
/**
|
|
246
|
-
* ⚠️ DEVNET/TESTING ONLY - This function is for devnet and testing purposes only.
|
|
247
|
-
* It will NOT work on mainnet. Use this only for development and testing.
|
|
248
|
-
*/
|
|
249
|
-
setMarketResolvableP2pIdl(accounts: AccountsMap, args: SetMarketResolvableV3Args): Promise<{
|
|
250
|
-
signature: string;
|
|
251
|
-
}>;
|
|
252
|
-
/**
|
|
253
|
-
* Set market resolvable status for V3/P2P markets.
|
|
254
|
-
*
|
|
255
|
-
* ⚠️ DEVNET/TESTING ONLY - This function is for devnet and testing purposes only.
|
|
256
|
-
* It will NOT work on mainnet. Use this only for development and testing.
|
|
257
|
-
*
|
|
258
|
-
* @param params - Parameters for setting market resolvable status
|
|
259
|
-
* @param params.market - Market public key
|
|
260
|
-
* @param params.resolvable - New resolvable status (true/false)
|
|
261
|
-
* @returns Transaction signature
|
|
262
|
-
*/
|
|
263
|
-
setMarketResolvableP2p(params: {
|
|
264
|
-
market: PublicKey;
|
|
265
|
-
resolvable: boolean;
|
|
266
|
-
}): Promise<{
|
|
267
|
-
signature: string;
|
|
268
|
-
}>;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
declare const TradeSchema: z.ZodObject<{
|
|
272
|
-
market: z.ZodType<PublicKey, z.ZodTypeDef, PublicKey>;
|
|
273
|
-
side: z.ZodUnion<[z.ZodLiteral<"buy">, z.ZodLiteral<"sell">]>;
|
|
274
|
-
price: z.ZodBigInt;
|
|
275
|
-
size: z.ZodBigInt;
|
|
276
|
-
}, "strip", z.ZodTypeAny, {
|
|
277
|
-
market: PublicKey;
|
|
278
|
-
side: "buy" | "sell";
|
|
279
|
-
price: bigint;
|
|
280
|
-
size: bigint;
|
|
281
|
-
}, {
|
|
282
|
-
market: PublicKey;
|
|
283
|
-
side: "buy" | "sell";
|
|
284
|
-
price: bigint;
|
|
285
|
-
size: bigint;
|
|
286
|
-
}>;
|
|
287
|
-
declare class TradingModule {
|
|
288
|
-
private readonly client;
|
|
289
|
-
private readonly signer;
|
|
290
|
-
constructor(client: Client, signer: SignerLike);
|
|
291
|
-
private static readonly MARKET_CREATED_V3_DISCRIMINATOR;
|
|
292
|
-
private decodeMarketAny;
|
|
293
|
-
trade(params: z.infer<typeof TradeSchema>): Promise<{
|
|
294
|
-
signature: string | undefined;
|
|
295
|
-
}>;
|
|
296
|
-
mintDecisionTokens(accounts: AccountsMap, args: MintDecisionTokensArgs): Promise<{
|
|
297
|
-
signature: string | undefined;
|
|
298
|
-
}>;
|
|
299
|
-
burnDecisionTokens(accounts: AccountsMap, args: BurnDecisionTokensArgs): Promise<{
|
|
300
|
-
signature: string | undefined;
|
|
301
|
-
}>;
|
|
302
|
-
mintDecisionTokensDerived(params: {
|
|
303
|
-
market: PublicKey;
|
|
304
|
-
amount: bigint;
|
|
305
|
-
buyYesToken: boolean;
|
|
306
|
-
minimumOut: bigint;
|
|
307
|
-
}): Promise<{
|
|
308
|
-
signature: string | undefined;
|
|
309
|
-
}>;
|
|
310
|
-
burnDecisionTokensDerived(params: {
|
|
311
|
-
market: PublicKey;
|
|
312
|
-
amount: bigint;
|
|
313
|
-
burnYesToken: boolean;
|
|
314
|
-
}): Promise<{
|
|
315
|
-
signature: string | undefined;
|
|
316
|
-
}>;
|
|
317
|
-
getMarketInfo(market: PublicKey): Promise<{
|
|
318
|
-
address: PublicKey;
|
|
319
|
-
question: any;
|
|
320
|
-
id: any;
|
|
321
|
-
creator: PublicKey;
|
|
322
|
-
initialLiquidity: any;
|
|
323
|
-
marketReserves: any;
|
|
324
|
-
endTime: any;
|
|
325
|
-
resolvable: any;
|
|
326
|
-
resolved: any;
|
|
327
|
-
winningTokenId: any;
|
|
328
|
-
yesTokenMint: PublicKey;
|
|
329
|
-
noTokenMint: PublicKey;
|
|
330
|
-
collateralToken: PublicKey;
|
|
331
|
-
yesTokenSupplyMinted: any;
|
|
332
|
-
noTokenSupplyMinted: any;
|
|
333
|
-
}>;
|
|
334
|
-
getBalances(market: PublicKey): Promise<{
|
|
335
|
-
collateral: {
|
|
336
|
-
account: PublicKey;
|
|
337
|
-
amount: any;
|
|
338
|
-
uiAmount: any;
|
|
339
|
-
uiAmountString: any;
|
|
340
|
-
};
|
|
341
|
-
yes: {
|
|
342
|
-
account: PublicKey;
|
|
343
|
-
amount: any;
|
|
344
|
-
uiAmount: any;
|
|
345
|
-
uiAmountString: any;
|
|
346
|
-
};
|
|
347
|
-
no: {
|
|
348
|
-
account: PublicKey;
|
|
349
|
-
amount: any;
|
|
350
|
-
uiAmount: any;
|
|
351
|
-
uiAmountString: any;
|
|
352
|
-
};
|
|
353
|
-
}>;
|
|
354
|
-
getPrices(market: PublicKey): Promise<{
|
|
355
|
-
yesMinted: number;
|
|
356
|
-
noMinted: number;
|
|
357
|
-
totalMinted: number;
|
|
358
|
-
yesShare: number;
|
|
359
|
-
noShare: number;
|
|
360
|
-
}>;
|
|
361
|
-
buyTokensUsdc(params: {
|
|
362
|
-
market: PublicKey;
|
|
363
|
-
buyYesToken: boolean;
|
|
364
|
-
amountUsdc: number;
|
|
365
|
-
minimumOut?: bigint;
|
|
366
|
-
}): Promise<{
|
|
367
|
-
signature: string;
|
|
368
|
-
usdcSpent: number;
|
|
369
|
-
tokensReceived: number;
|
|
370
|
-
before: {
|
|
371
|
-
collateral: {
|
|
372
|
-
account: PublicKey;
|
|
373
|
-
amount: any;
|
|
374
|
-
uiAmount: any;
|
|
375
|
-
uiAmountString: any;
|
|
376
|
-
};
|
|
377
|
-
yes: {
|
|
378
|
-
account: PublicKey;
|
|
379
|
-
amount: any;
|
|
380
|
-
uiAmount: any;
|
|
381
|
-
uiAmountString: any;
|
|
382
|
-
};
|
|
383
|
-
no: {
|
|
384
|
-
account: PublicKey;
|
|
385
|
-
amount: any;
|
|
386
|
-
uiAmount: any;
|
|
387
|
-
uiAmountString: any;
|
|
388
|
-
};
|
|
389
|
-
};
|
|
390
|
-
after: {
|
|
391
|
-
collateral: {
|
|
392
|
-
account: PublicKey;
|
|
393
|
-
amount: any;
|
|
394
|
-
uiAmount: any;
|
|
395
|
-
uiAmountString: any;
|
|
396
|
-
};
|
|
397
|
-
yes: {
|
|
398
|
-
account: PublicKey;
|
|
399
|
-
amount: any;
|
|
400
|
-
uiAmount: any;
|
|
401
|
-
uiAmountString: any;
|
|
402
|
-
};
|
|
403
|
-
no: {
|
|
404
|
-
account: PublicKey;
|
|
405
|
-
amount: any;
|
|
406
|
-
uiAmount: any;
|
|
407
|
-
uiAmountString: any;
|
|
408
|
-
};
|
|
409
|
-
};
|
|
410
|
-
}>;
|
|
411
|
-
sellTokensBase(params: {
|
|
412
|
-
market: PublicKey;
|
|
413
|
-
burnYesToken: boolean;
|
|
414
|
-
amountBaseUnits: bigint;
|
|
415
|
-
}): Promise<{
|
|
416
|
-
signature: string;
|
|
417
|
-
tokensSold: number;
|
|
418
|
-
usdcReceived: number;
|
|
419
|
-
before: {
|
|
420
|
-
collateral: {
|
|
421
|
-
account: PublicKey;
|
|
422
|
-
amount: any;
|
|
423
|
-
uiAmount: any;
|
|
424
|
-
uiAmountString: any;
|
|
425
|
-
};
|
|
426
|
-
yes: {
|
|
427
|
-
account: PublicKey;
|
|
428
|
-
amount: any;
|
|
429
|
-
uiAmount: any;
|
|
430
|
-
uiAmountString: any;
|
|
431
|
-
};
|
|
432
|
-
no: {
|
|
433
|
-
account: PublicKey;
|
|
434
|
-
amount: any;
|
|
435
|
-
uiAmount: any;
|
|
436
|
-
uiAmountString: any;
|
|
437
|
-
};
|
|
438
|
-
};
|
|
439
|
-
after: {
|
|
440
|
-
collateral: {
|
|
441
|
-
account: PublicKey;
|
|
442
|
-
amount: any;
|
|
443
|
-
uiAmount: any;
|
|
444
|
-
uiAmountString: any;
|
|
445
|
-
};
|
|
446
|
-
yes: {
|
|
447
|
-
account: PublicKey;
|
|
448
|
-
amount: any;
|
|
449
|
-
uiAmount: any;
|
|
450
|
-
uiAmountString: any;
|
|
451
|
-
};
|
|
452
|
-
no: {
|
|
453
|
-
account: PublicKey;
|
|
454
|
-
amount: any;
|
|
455
|
-
uiAmount: any;
|
|
456
|
-
uiAmountString: any;
|
|
457
|
-
};
|
|
458
|
-
};
|
|
459
|
-
}>;
|
|
460
|
-
redeemPosition(market: PublicKey): Promise<void>;
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
declare const RedeemSchema: z.ZodObject<{
|
|
464
|
-
market: z.ZodType<PublicKey, z.ZodTypeDef, PublicKey>;
|
|
465
|
-
position: z.ZodType<PublicKey, z.ZodTypeDef, PublicKey>;
|
|
466
|
-
amount: z.ZodBigInt;
|
|
467
|
-
to: z.ZodOptional<z.ZodType<PublicKey, z.ZodTypeDef, PublicKey>>;
|
|
468
|
-
}, "strip", z.ZodTypeAny, {
|
|
469
|
-
market: PublicKey;
|
|
470
|
-
amount: bigint;
|
|
471
|
-
position: PublicKey;
|
|
472
|
-
to?: PublicKey | undefined;
|
|
473
|
-
}, {
|
|
474
|
-
market: PublicKey;
|
|
475
|
-
amount: bigint;
|
|
476
|
-
position: PublicKey;
|
|
477
|
-
to?: PublicKey | undefined;
|
|
478
|
-
}>;
|
|
479
|
-
declare class RedemptionModule {
|
|
480
|
-
private readonly client;
|
|
481
|
-
private readonly signer;
|
|
482
|
-
constructor(client: Client, signer: SignerLike);
|
|
483
|
-
redeemPosition(params: z.infer<typeof RedeemSchema>): Promise<{
|
|
484
|
-
signature: string | undefined;
|
|
485
|
-
}>;
|
|
486
|
-
claimCreatorFee(accounts: AccountsMap): Promise<{
|
|
487
|
-
signature: string | undefined;
|
|
488
|
-
}>;
|
|
489
|
-
creatorRefund(accounts: AccountsMap): Promise<{
|
|
490
|
-
signature: string | undefined;
|
|
491
|
-
}>;
|
|
492
|
-
creatorRefundV2(accounts: AccountsMap): Promise<{
|
|
493
|
-
signature: string | undefined;
|
|
494
|
-
}>;
|
|
495
|
-
creatorRefundV3(accounts: AccountsMap): Promise<{
|
|
496
|
-
signature: string | undefined;
|
|
497
|
-
}>;
|
|
498
|
-
/**
|
|
499
|
-
* Redeem a winning position from a resolved market
|
|
500
|
-
* @param accounts - Account mapping for the redemption instruction
|
|
501
|
-
* @returns Transaction signature
|
|
502
|
-
*/
|
|
503
|
-
redeemPositionV2(accounts: AccountsMap): Promise<{
|
|
504
|
-
signature: string | undefined;
|
|
505
|
-
}>;
|
|
506
|
-
/**
|
|
507
|
-
* Redeem a winning position from a resolved V3 market
|
|
508
|
-
* @param accounts - Account mapping for the V3 redemption instruction
|
|
509
|
-
* @returns Transaction signature
|
|
510
|
-
*/
|
|
511
|
-
redeemV3Position(accounts: AccountsMap): Promise<{
|
|
512
|
-
signature: string | undefined;
|
|
513
|
-
}>;
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
/**
|
|
517
|
-
* Provides a wrapper for Anchor program interactions
|
|
518
|
-
* Following the same pattern as the JavaScript example
|
|
519
|
-
*/
|
|
520
|
-
declare class AnchorClient {
|
|
521
|
-
readonly connection: Connection;
|
|
522
|
-
readonly signer: Keypair;
|
|
523
|
-
readonly idlOverride?: Idl | undefined;
|
|
524
|
-
readonly programIdOverride?: PublicKey | undefined;
|
|
525
|
-
readonly provider: anchor.AnchorProvider;
|
|
526
|
-
readonly wallet: anchor.Wallet;
|
|
527
|
-
readonly program: anchor.Program;
|
|
528
|
-
constructor(connection: Connection, signer: Keypair, idlOverride?: Idl | undefined, programIdOverride?: PublicKey | undefined);
|
|
529
|
-
/**
|
|
530
|
-
* Convert a JavaScript BigInt or number to Anchor BN
|
|
531
|
-
*/
|
|
532
|
-
static toBN(value: bigint | number): typeof BN.prototype;
|
|
533
|
-
/**
|
|
534
|
-
* Returns the IDL for the PNP program
|
|
535
|
-
*/
|
|
536
|
-
static getIdl(): Promise<Idl>;
|
|
537
|
-
static fromIdl(connection: Connection, signer: Keypair, idl: Idl): AnchorClient;
|
|
538
|
-
/**
|
|
539
|
-
* Get the wallet's public key
|
|
540
|
-
*/
|
|
541
|
-
get walletPublicKey(): PublicKey;
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
/**
|
|
545
|
-
* Market module that uses direct Anchor program calls
|
|
546
|
-
*/
|
|
547
|
-
declare class AnchorMarketModule {
|
|
548
|
-
private anchorClient;
|
|
549
|
-
constructor(anchorClient: AnchorClient);
|
|
550
|
-
/**
|
|
551
|
-
* Create a new prediction market using direct Anchor program calls
|
|
552
|
-
* Following the same structure as the working JavaScript example
|
|
553
|
-
*/
|
|
554
|
-
createMarket(params: {
|
|
555
|
-
question: string;
|
|
556
|
-
initialLiquidity: bigint;
|
|
557
|
-
endTime: bigint;
|
|
558
|
-
collateralTokenMint: PublicKey;
|
|
559
|
-
creator?: PublicKey;
|
|
560
|
-
yesOddsBps?: number;
|
|
561
|
-
oracle?: PublicKey;
|
|
562
|
-
}): Promise<{
|
|
563
|
-
signature: any;
|
|
564
|
-
market: PublicKey;
|
|
565
|
-
marketDetails: any;
|
|
566
|
-
} | {
|
|
567
|
-
signature: any;
|
|
568
|
-
market: PublicKey;
|
|
569
|
-
marketDetails?: undefined;
|
|
570
|
-
}>;
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
type TokenSide = "yes" | "no";
|
|
574
|
-
/**
|
|
575
|
-
* Market module that uses direct Anchor program calls for V3 markets
|
|
576
|
-
*/
|
|
577
|
-
declare class AnchorMarketV3Module {
|
|
578
|
-
private anchorClient;
|
|
579
|
-
constructor(anchorClient: AnchorClient);
|
|
580
|
-
/**
|
|
581
|
-
* Create a new V3 prediction market using direct Anchor program calls
|
|
582
|
-
*/
|
|
583
|
-
createMarketV3(params: {
|
|
584
|
-
question: string;
|
|
585
|
-
initialAmount: bigint;
|
|
586
|
-
side: TokenSide;
|
|
587
|
-
creatorSideCap: bigint;
|
|
588
|
-
endTime: bigint;
|
|
589
|
-
maxPotRatio?: number;
|
|
590
|
-
collateralTokenMint: PublicKey;
|
|
591
|
-
creator?: PublicKey;
|
|
592
|
-
oddsBps?: number;
|
|
593
|
-
oracle?: PublicKey;
|
|
594
|
-
}): Promise<{
|
|
595
|
-
signature: any;
|
|
596
|
-
market: PublicKey;
|
|
597
|
-
yesTokenMint: PublicKey;
|
|
598
|
-
noTokenMint: PublicKey;
|
|
599
|
-
}>;
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
declare class PNPClient {
|
|
603
|
-
readonly client: Client;
|
|
604
|
-
readonly signer?: SignerLike;
|
|
605
|
-
readonly market?: MarketModule;
|
|
606
|
-
readonly trading?: TradingModule;
|
|
607
|
-
readonly redemption?: RedemptionModule;
|
|
608
|
-
readonly anchorMarket?: AnchorMarketModule;
|
|
609
|
-
readonly anchorMarketV3?: AnchorMarketV3Module;
|
|
610
|
-
readonly anchorClient?: AnchorClient;
|
|
611
|
-
private static readonly MARKET_V3_DISCRIMINATOR;
|
|
612
|
-
get connection(): _solana_web3_js.Connection;
|
|
613
|
-
/**
|
|
614
|
-
* Decode market account data from buffer
|
|
615
|
-
* @param data Buffer containing account data
|
|
616
|
-
* @returns Decoded market account data
|
|
617
|
-
*/
|
|
618
|
-
private decodeMarketAny;
|
|
619
|
-
constructor(rpcUrl: string, privateKey?: Uint8Array | string | {
|
|
620
|
-
secretKey: Uint8Array;
|
|
621
|
-
});
|
|
622
|
-
/**
|
|
623
|
-
* Create a P2P market (high-level wrapper) and return a web3-agnostic result.
|
|
624
|
-
* Serializes PublicKeys to base58 strings to match P2PMarketResponse.
|
|
625
|
-
*/
|
|
626
|
-
createP2PMarketGeneral(params: {
|
|
627
|
-
question: string;
|
|
628
|
-
initialAmount: bigint;
|
|
629
|
-
side: "yes" | "no";
|
|
630
|
-
creatorSideCap: bigint;
|
|
631
|
-
endTime: bigint;
|
|
632
|
-
maxPotRatio?: number;
|
|
633
|
-
collateralTokenMint: PublicKey;
|
|
634
|
-
creator?: PublicKey;
|
|
635
|
-
}): Promise<P2PMarketResponse>;
|
|
636
|
-
/**
|
|
637
|
-
* Create a P2P market using simple, UI-friendly parameters.
|
|
638
|
-
* - Accepts amount in USDC (number) and converts to raw units internally (assumes 6 decimals).
|
|
639
|
-
* - Defaults to mainnet USDC as collateral mint if not provided.
|
|
640
|
-
* - Defaults creatorSideCap to 5x the initial amount if not provided.
|
|
641
|
-
* - Defaults end time to `daysUntilEnd` days from now (30 days by default).
|
|
642
|
-
*/
|
|
643
|
-
createP2PMarketSimple(params: {
|
|
644
|
-
question: string;
|
|
645
|
-
side: "yes" | "no";
|
|
646
|
-
amountUsdc: number;
|
|
647
|
-
daysUntilEnd?: number;
|
|
648
|
-
creatorSideCapMultiplier?: number;
|
|
649
|
-
collateralTokenMint?: PublicKey;
|
|
650
|
-
maxPotRatio?: number;
|
|
651
|
-
creator?: PublicKey;
|
|
652
|
-
}): Promise<P2PMarketResponse>;
|
|
653
|
-
/**
|
|
654
|
-
* Create a P2P market with YouTube URL detection (high-level wrapper).
|
|
655
|
-
* Automatically detects and extracts YouTube URLs from the question.
|
|
656
|
-
* Serializes PublicKeys to base58 strings to match P2PMarketResponse.
|
|
657
|
-
*/
|
|
658
|
-
createP2PMarketYoutube(params: {
|
|
659
|
-
question: string;
|
|
660
|
-
youtubeUrl: string;
|
|
661
|
-
initialAmount: bigint;
|
|
662
|
-
side: "yes" | "no";
|
|
663
|
-
creatorSideCap: bigint;
|
|
664
|
-
endTime: bigint;
|
|
665
|
-
maxPotRatio?: number;
|
|
666
|
-
collateralTokenMint: PublicKey;
|
|
667
|
-
creator?: PublicKey;
|
|
668
|
-
}): Promise<P2PMarketResponse & {
|
|
669
|
-
detectedYoutubeUrl?: string;
|
|
670
|
-
}>;
|
|
671
|
-
/**
|
|
672
|
-
* Create a P2P market with DeFiLlama protocol/metric detection (high-level wrapper).
|
|
673
|
-
* Automatically formats the question with DeFiLlama reference.
|
|
674
|
-
* Serializes PublicKeys to base58 strings to match P2PMarketResponse.
|
|
675
|
-
*/
|
|
676
|
-
createP2PMarketDefiLlama(params: {
|
|
677
|
-
question: string;
|
|
678
|
-
protocolName: string;
|
|
679
|
-
metric: string;
|
|
680
|
-
initialAmount: bigint;
|
|
681
|
-
side: "yes" | "no";
|
|
682
|
-
creatorSideCap: bigint;
|
|
683
|
-
endTime: bigint;
|
|
684
|
-
maxPotRatio?: number;
|
|
685
|
-
collateralTokenMint: PublicKey;
|
|
686
|
-
creator?: PublicKey;
|
|
687
|
-
}): Promise<P2PMarketResponse & {
|
|
688
|
-
detectedProtocol?: string;
|
|
689
|
-
detectedMetric?: string;
|
|
690
|
-
}>;
|
|
691
|
-
/**
|
|
692
|
-
* Simple helper to create a P2P market with a YouTube URL using UI-friendly parameters.
|
|
693
|
-
* - Accepts amount in USDC (number) and converts to raw units internally (assumes 6 decimals).
|
|
694
|
-
* - Defaults to mainnet USDC as collateral mint if not provided.
|
|
695
|
-
* - Defaults creatorSideCap to 5x the initial amount if not provided.
|
|
696
|
-
* - Defaults end time to `daysUntilEnd` days from now (30 days by default).
|
|
697
|
-
*/
|
|
698
|
-
createP2PMarketYoutubeSimple(params: {
|
|
699
|
-
question: string;
|
|
700
|
-
youtubeUrl: string;
|
|
701
|
-
side: "yes" | "no";
|
|
702
|
-
amountUsdc: number;
|
|
703
|
-
daysUntilEnd?: number;
|
|
704
|
-
creatorSideCapMultiplier?: number;
|
|
705
|
-
collateralTokenMint?: PublicKey;
|
|
706
|
-
maxPotRatio?: number;
|
|
707
|
-
creator?: PublicKey;
|
|
708
|
-
}): Promise<P2PMarketResponse & {
|
|
709
|
-
detectedYoutubeUrl?: string;
|
|
710
|
-
}>;
|
|
711
|
-
/**
|
|
712
|
-
* Create a V2 (AMM) market with Twitter URL detection (high-level wrapper).
|
|
713
|
-
* Automatically detects and extracts Twitter URLs from the question.
|
|
714
|
-
* Serializes PublicKeys to base58 strings.
|
|
715
|
-
*/
|
|
716
|
-
createMarketTwitter(params: {
|
|
717
|
-
question: string;
|
|
718
|
-
tweetUrl: string;
|
|
719
|
-
initialLiquidity: bigint;
|
|
720
|
-
endTime: bigint;
|
|
721
|
-
collateralTokenMint: PublicKey;
|
|
722
|
-
}): Promise<{
|
|
723
|
-
signature: string;
|
|
724
|
-
market: string;
|
|
725
|
-
detectedTwitterUrl?: string;
|
|
726
|
-
isTweetIdFormat?: boolean;
|
|
727
|
-
}>;
|
|
728
|
-
/**
|
|
729
|
-
* Create a V2 (AMM) market with YouTube URL detection (high-level wrapper).
|
|
730
|
-
* Automatically detects and extracts YouTube URLs from the question.
|
|
731
|
-
* Serializes PublicKeys to base58 strings.
|
|
732
|
-
*/
|
|
733
|
-
createMarketYoutube(params: {
|
|
734
|
-
question: string;
|
|
735
|
-
youtubeUrl: string;
|
|
736
|
-
initialLiquidity: bigint;
|
|
737
|
-
endTime: bigint;
|
|
738
|
-
collateralTokenMint: PublicKey;
|
|
739
|
-
}): Promise<{
|
|
740
|
-
signature: string;
|
|
741
|
-
market: string;
|
|
742
|
-
detectedYoutubeUrl?: string;
|
|
743
|
-
}>;
|
|
744
|
-
/**
|
|
745
|
-
* Create a V2 (AMM) market with DeFiLlama protocol/metric detection (high-level wrapper).
|
|
746
|
-
* Automatically formats the question with DeFiLlama reference.
|
|
747
|
-
* Serializes PublicKeys to base58 strings.
|
|
748
|
-
*/
|
|
749
|
-
createMarketDefiLlama(params: {
|
|
750
|
-
question: string;
|
|
751
|
-
protocolName: string;
|
|
752
|
-
metric: string;
|
|
753
|
-
initialLiquidity: bigint;
|
|
754
|
-
endTime: bigint;
|
|
755
|
-
collateralTokenMint: PublicKey;
|
|
756
|
-
}): Promise<{
|
|
757
|
-
signature: string;
|
|
758
|
-
market: string;
|
|
759
|
-
detectedProtocol?: string;
|
|
760
|
-
detectedMetric?: string;
|
|
761
|
-
}>;
|
|
762
|
-
/**
|
|
763
|
-
* Create a P2P market with Twitter URL detection (high-level wrapper).
|
|
764
|
-
* Automatically detects and extracts Twitter URLs from the question.
|
|
765
|
-
* Serializes PublicKeys to base58 strings to match P2PMarketResponse.
|
|
766
|
-
*/
|
|
767
|
-
createP2PMarketTwitter(params: {
|
|
768
|
-
question: string;
|
|
769
|
-
tweetUrl: string;
|
|
770
|
-
initialAmount: bigint;
|
|
771
|
-
side: "yes" | "no";
|
|
772
|
-
creatorSideCap: bigint;
|
|
773
|
-
endTime: bigint;
|
|
774
|
-
maxPotRatio?: number;
|
|
775
|
-
collateralTokenMint: PublicKey;
|
|
776
|
-
creator?: PublicKey;
|
|
777
|
-
}): Promise<P2PMarketResponse & {
|
|
778
|
-
detectedTwitterUrl?: string;
|
|
779
|
-
isTweetIdFormat?: boolean;
|
|
780
|
-
}>;
|
|
781
|
-
/**
|
|
782
|
-
* Simple helper to create a P2P market with a Twitter / X URL using UI-friendly parameters.
|
|
783
|
-
* - Accepts amount in USDC (number) and converts to raw units internally (assumes 6 decimals).
|
|
784
|
-
* - Defaults to mainnet USDC as collateral mint if not provided.
|
|
785
|
-
* - Defaults creatorSideCap to 5x the initial amount if not provided.
|
|
786
|
-
* - Defaults end time to `daysUntilEnd` days from now (30 days by default).
|
|
787
|
-
*/
|
|
788
|
-
createP2PMarketTwitterSimple(params: {
|
|
789
|
-
question: string;
|
|
790
|
-
tweetUrl: string;
|
|
791
|
-
side: "yes" | "no";
|
|
792
|
-
amountUsdc: number;
|
|
793
|
-
daysUntilEnd?: number;
|
|
794
|
-
creatorSideCapMultiplier?: number;
|
|
795
|
-
collateralTokenMint?: PublicKey;
|
|
796
|
-
maxPotRatio?: number;
|
|
797
|
-
creator?: PublicKey;
|
|
798
|
-
}): Promise<P2PMarketResponse & {
|
|
799
|
-
detectedTwitterUrl?: string;
|
|
800
|
-
isTweetIdFormat?: boolean;
|
|
801
|
-
}>;
|
|
802
|
-
/**
|
|
803
|
-
* Simple helper to create a P2P market with DeFiLlama protocol/metric using UI-friendly parameters.
|
|
804
|
-
* - Accepts amount in USDC (number) and converts to raw units internally (assumes 6 decimals).
|
|
805
|
-
* - Defaults to mainnet USDC as collateral mint if not provided.
|
|
806
|
-
* - Defaults creatorSideCap to 5x the initial amount if not provided.
|
|
807
|
-
* - Defaults end time to `daysUntilEnd` days from now (30 days by default).
|
|
808
|
-
*/
|
|
809
|
-
createP2PMarketDefiLlamaSimple(params: {
|
|
810
|
-
question: string;
|
|
811
|
-
protocolName: string;
|
|
812
|
-
metric: string;
|
|
813
|
-
side: "yes" | "no";
|
|
814
|
-
amountUsdc: number;
|
|
815
|
-
daysUntilEnd?: number;
|
|
816
|
-
creatorSideCapMultiplier?: number;
|
|
817
|
-
collateralTokenMint?: PublicKey;
|
|
818
|
-
maxPotRatio?: number;
|
|
819
|
-
creator?: PublicKey;
|
|
820
|
-
}): Promise<P2PMarketResponse & {
|
|
821
|
-
detectedProtocol?: string;
|
|
822
|
-
detectedMetric?: string;
|
|
823
|
-
}>;
|
|
824
|
-
/**
|
|
825
|
-
* Create a V2 (AMM) market with custom initial odds and/or a custom oracle.
|
|
826
|
-
*
|
|
827
|
-
* @param params - Market creation parameters
|
|
828
|
-
* @param params.yesOddsBps - Initial YES odds in basis points (100-9900).
|
|
829
|
-
* Example: 7000 = 70% YES / 30% NO
|
|
830
|
-
* @param params.oracle - Optional custom oracle for settlement (default: global oracle)
|
|
831
|
-
* @returns Object with transaction signature and market PDA
|
|
832
|
-
*/
|
|
833
|
-
createMarketV2WithCustomOdds(params: {
|
|
834
|
-
question: string;
|
|
835
|
-
initialLiquidity: bigint;
|
|
836
|
-
endTime: bigint;
|
|
837
|
-
collateralTokenMint: PublicKey;
|
|
838
|
-
yesOddsBps: number;
|
|
839
|
-
oracle?: PublicKey;
|
|
840
|
-
creator?: PublicKey;
|
|
841
|
-
}): Promise<{
|
|
842
|
-
signature: any;
|
|
843
|
-
market: string;
|
|
844
|
-
}>;
|
|
845
|
-
/**
|
|
846
|
-
* Create a P2P (V3) market with custom initial odds (high-level wrapper).
|
|
847
|
-
* Custom odds allow splitting the initial liquidity between YES and NO sides
|
|
848
|
-
* instead of the default 100% to creator side.
|
|
849
|
-
*
|
|
850
|
-
* @param params - Market creation parameters
|
|
851
|
-
* @param params.oddsBps - Initial odds in basis points (100-9900).
|
|
852
|
-
* Example: 7000 = 70% YES / 30% NO for a YES-side creator
|
|
853
|
-
* @param params.oracle - Optional custom oracle for settlement (default: global oracle)
|
|
854
|
-
* @returns P2PMarketResponse with market address and token mints
|
|
855
|
-
*/
|
|
856
|
-
createMarketP2PWithCustomOdds(params: {
|
|
857
|
-
question: string;
|
|
858
|
-
initialAmount: bigint;
|
|
859
|
-
side: "yes" | "no";
|
|
860
|
-
creatorSideCap: bigint;
|
|
861
|
-
endTime: bigint;
|
|
862
|
-
oddsBps: number;
|
|
863
|
-
oracle?: PublicKey;
|
|
864
|
-
maxPotRatio?: number;
|
|
865
|
-
collateralTokenMint: PublicKey;
|
|
866
|
-
creator?: PublicKey;
|
|
867
|
-
}): Promise<P2PMarketResponse>;
|
|
868
|
-
/**
|
|
869
|
-
* Detects if a question contains a Twitter URL or tweet ID format after the question mark
|
|
870
|
-
* @param questionText The question text to analyze
|
|
871
|
-
* @returns Object containing the cleaned question, Twitter URL if present, and isTweetIdFormat flag indicating if X {tweet_id} format was used
|
|
872
|
-
* @example
|
|
873
|
-
* // With URL format
|
|
874
|
-
* detectTwitterUrl("Will X happen? https://twitter.com/user/status/1234567890");
|
|
875
|
-
* // With X {tweet id} format - with space
|
|
876
|
-
* detectTwitterUrl("Will X happen? X 1234567890");
|
|
877
|
-
* // With X {tweet id} format - with curly braces
|
|
878
|
-
* detectTwitterUrl("Will X happen? X {1234567890}");
|
|
879
|
-
*/
|
|
880
|
-
static detectTwitterUrl(questionText: string): {
|
|
881
|
-
question: string;
|
|
882
|
-
twitterUrl?: string;
|
|
883
|
-
isTweetIdFormat?: boolean;
|
|
884
|
-
};
|
|
885
|
-
/**
|
|
886
|
-
* Detects if a question contains a YouTube URL after the question mark
|
|
887
|
-
* @param questionText The question text to analyze
|
|
888
|
-
* @returns Object containing the cleaned question and YouTube URL if present
|
|
889
|
-
*/
|
|
890
|
-
static detectYoutubeUrl(questionText: string): {
|
|
891
|
-
question: string;
|
|
892
|
-
youtubeUrl?: string;
|
|
893
|
-
};
|
|
894
|
-
/**
|
|
895
|
-
* Detects if a question contains a DeFiLlama format after the question mark
|
|
896
|
-
* @param questionText The question text to analyze
|
|
897
|
-
* @returns Object containing the cleaned question and DeFiLlama protocol/metric info if present
|
|
898
|
-
* @example
|
|
899
|
-
* detectDefiLlamaUrl("Will Uniswap TVL exceed $5B? df uniswap-v3 tvl");
|
|
900
|
-
*/
|
|
901
|
-
static detectDefiLlamaUrl(questionText: string): {
|
|
902
|
-
question: string;
|
|
903
|
-
protocol?: string;
|
|
904
|
-
metric?: string;
|
|
905
|
-
};
|
|
906
|
-
/**
|
|
907
|
-
* Parse a private key from a string that could be a JSON array or base58 encoded
|
|
908
|
-
* @param keyString Private key as JSON array or base58 string
|
|
909
|
-
* @returns Uint8Array containing the private key bytes
|
|
910
|
-
*/
|
|
911
|
-
static parseSecretKey(keyString: string): Uint8Array;
|
|
912
|
-
/**
|
|
913
|
-
* Convert UI amount to raw amount based on decimals (defaults to 6 for USDC)
|
|
914
|
-
* @param amount UI amount with decimal places
|
|
915
|
-
* @param decimals Token decimals (default: 6 for USDC)
|
|
916
|
-
* @returns Raw token amount as bigint
|
|
917
|
-
*/
|
|
918
|
-
uiToRaw(amount: number, decimals?: number): bigint;
|
|
919
|
-
/**
|
|
920
|
-
* Buy tokens on a V3 market using USDC
|
|
921
|
-
* @param params Buy parameters including market, side, and amount
|
|
922
|
-
* @returns Transaction signature
|
|
923
|
-
*/
|
|
924
|
-
buyV3TokensUsdc(params: {
|
|
925
|
-
market: PublicKey;
|
|
926
|
-
buyYesToken: boolean;
|
|
927
|
-
amountUsdc: number;
|
|
928
|
-
}): Promise<{
|
|
929
|
-
signature: string;
|
|
930
|
-
}>;
|
|
931
|
-
/**
|
|
932
|
-
* Redeems a winning position in a resolved market
|
|
933
|
-
* @param market - The public key of the market where the position was created
|
|
934
|
-
* @param options - Optional parameters for customizing the redemption
|
|
935
|
-
* @returns Transaction signature
|
|
936
|
-
*/
|
|
937
|
-
redeemPosition(market: PublicKey, options?: {
|
|
938
|
-
admin?: PublicKey;
|
|
939
|
-
marketCreator?: PublicKey;
|
|
940
|
-
creatorFeeTreasury?: PublicKey;
|
|
941
|
-
}): Promise<{
|
|
942
|
-
signature: string | undefined;
|
|
943
|
-
}>;
|
|
944
|
-
/**
|
|
945
|
-
* Redeems a winning position in a resolved V3 market
|
|
946
|
-
* @param market - The public key of the V3 market where the position was created
|
|
947
|
-
* @returns Transaction signature
|
|
948
|
-
*/
|
|
949
|
-
redeemV3Position(market: PublicKey): Promise<{
|
|
950
|
-
signature: any;
|
|
951
|
-
}>;
|
|
952
|
-
/**
|
|
953
|
-
* Redeem a winning position from a resolved P2P (V3) market.
|
|
954
|
-
* Thin wrapper around redeemV3Position that accepts either a string or PublicKey.
|
|
955
|
-
*/
|
|
956
|
-
redeemP2PPosition(market: PublicKey | string): Promise<{
|
|
957
|
-
signature: string;
|
|
958
|
-
}>;
|
|
959
|
-
fetchGlobalConfig(): Promise<{
|
|
960
|
-
publicKey: PublicKey;
|
|
961
|
-
account: GlobalConfigType;
|
|
962
|
-
}>;
|
|
963
|
-
/**
|
|
964
|
-
* Set market resolvable status (V2 markets)
|
|
965
|
-
*
|
|
966
|
-
* ⚠️ DEVNET/TESTING ONLY - This function is for devnet and testing purposes only.
|
|
967
|
-
* It will NOT work on mainnet. Use this only for development and testing.
|
|
968
|
-
*
|
|
969
|
-
* @param market - Market public key or address string
|
|
970
|
-
* @param resolvable - New resolvable status
|
|
971
|
-
* @param forceResolve - Optional: force resolve (allow immediate refunds)
|
|
972
|
-
* @returns Transaction signature
|
|
973
|
-
*/
|
|
974
|
-
/**
|
|
975
|
-
* Set market resolvable status for V2 markets.
|
|
976
|
-
* Automatically handles market extension accounts for custom oracles.
|
|
977
|
-
*
|
|
978
|
-
* @param market - Market public key or address string
|
|
979
|
-
* @param resolvable - New resolvable status (true/false)
|
|
980
|
-
* @param forceResolve - Optional: force resolve (allow immediate refunds)
|
|
981
|
-
* @returns Transaction signature
|
|
982
|
-
*/
|
|
983
|
-
setMarketResolvable(market: PublicKey | string, resolvable: boolean, forceResolve?: boolean): Promise<{
|
|
984
|
-
signature: string;
|
|
985
|
-
}>;
|
|
986
|
-
/**
|
|
987
|
-
* High-level method to create a V2 market with a custom oracle (settler).
|
|
988
|
-
*
|
|
989
|
-
* @param params Market parameters including settler address and optional odds
|
|
990
|
-
* @returns Created market details
|
|
991
|
-
*/
|
|
992
|
-
createMarketWithCustomOracle(params: {
|
|
993
|
-
question: string;
|
|
994
|
-
initialLiquidity: bigint;
|
|
995
|
-
endTime: bigint;
|
|
996
|
-
collateralMint: PublicKey;
|
|
997
|
-
settlerAddress: PublicKey;
|
|
998
|
-
yesOddsBps?: number;
|
|
999
|
-
}): Promise<{
|
|
1000
|
-
market: PublicKey;
|
|
1001
|
-
signature: string;
|
|
1002
|
-
}>;
|
|
1003
|
-
/**
|
|
1004
|
-
* Set market resolvable status (V3/P2P markets)
|
|
1005
|
-
*
|
|
1006
|
-
* ⚠️ DEVNET/TESTING ONLY - This function is for devnet and testing purposes only.
|
|
1007
|
-
* It will NOT work on mainnet. Use this only for development and testing.
|
|
1008
|
-
*
|
|
1009
|
-
* @param market - Market public key or address string
|
|
1010
|
-
* @param resolvable - New resolvable status
|
|
1011
|
-
* @returns Transaction signature
|
|
1012
|
-
*/
|
|
1013
|
-
setMarketResolvableP2p(market: PublicKey | string, resolvable: boolean): Promise<{
|
|
1014
|
-
signature: string;
|
|
1015
|
-
}>;
|
|
1016
|
-
fetchMarket(market: PublicKey): Promise<{
|
|
1017
|
-
publicKey: PublicKey;
|
|
1018
|
-
account: MarketType;
|
|
1019
|
-
}>;
|
|
1020
|
-
fetchMarkets(): Promise<MarketsResponse>;
|
|
1021
|
-
/**
|
|
1022
|
-
* Fetch settlement criteria for a market from the proxy server
|
|
1023
|
-
* @param market - Market public key (as string or PublicKey)
|
|
1024
|
-
* @param baseUrl - Optional base URL for the proxy server
|
|
1025
|
-
* @returns Settlement criteria data
|
|
1026
|
-
*/
|
|
1027
|
-
fetchSettlementCriteria(market: string | PublicKey, baseUrl?: string): Promise<SettlementCriteria>;
|
|
1028
|
-
/**
|
|
1029
|
-
* Get settlement criteria for a market from the proxy server (alias for fetchSettlementCriteria)
|
|
1030
|
-
* @param market - Market public key (as string or PublicKey)
|
|
1031
|
-
* @param baseUrl - Optional base URL for the proxy server
|
|
1032
|
-
* @returns Settlement criteria data
|
|
1033
|
-
*/
|
|
1034
|
-
getSettlementCriteria(market: string | PublicKey, baseUrl?: string, options?: {
|
|
1035
|
-
retryDelayMs?: number;
|
|
1036
|
-
maxRetryTimeMs?: number;
|
|
1037
|
-
}): Promise<SettlementCriteria>;
|
|
1038
|
-
/**
|
|
1039
|
-
* Convenience helper: wait for settlement criteria and provide a small summary.
|
|
1040
|
-
* - Uses getSettlementCriteria() (with retry) under the hood
|
|
1041
|
-
* - Derives a friendly YES/NO answer when possible
|
|
1042
|
-
* - Surfaces resolvable if provided by the proxy
|
|
1043
|
-
*/
|
|
1044
|
-
waitForSettlementCriteria(market: string | PublicKey, baseUrl?: string, options?: {
|
|
1045
|
-
retryDelayMs?: number;
|
|
1046
|
-
maxRetryTimeMs?: number;
|
|
1047
|
-
}): Promise<{
|
|
1048
|
-
resolvable?: boolean;
|
|
1049
|
-
answer?: string;
|
|
1050
|
-
criteria: SettlementCriteria;
|
|
1051
|
-
}>;
|
|
1052
|
-
/**
|
|
1053
|
-
* Fetch settlement data for a market from the proxy server
|
|
1054
|
-
* @param market - Market public key (as string or PublicKey)
|
|
1055
|
-
* @param baseUrl - Optional base URL for the proxy server
|
|
1056
|
-
* @returns Settlement data
|
|
1057
|
-
*/
|
|
1058
|
-
fetchSettlementData(market: string | PublicKey, baseUrl?: string): Promise<SettlementData>;
|
|
1059
|
-
/**
|
|
1060
|
-
* Get settlement data for a market from the proxy server (alias for fetchSettlementData)
|
|
1061
|
-
* @param market - Market public key (as string or PublicKey)
|
|
1062
|
-
* @param baseUrl - Optional base URL for the proxy server
|
|
1063
|
-
* @returns Settlement data
|
|
1064
|
-
*/
|
|
1065
|
-
getSettlementData(market: string | PublicKey, baseUrl?: string): Promise<SettlementData>;
|
|
1066
|
-
/**
|
|
1067
|
-
* Fetch market addresses from the proxy server
|
|
1068
|
-
* @param baseUrl - Optional base URL for the proxy server
|
|
1069
|
-
* @returns Array of market addresses
|
|
1070
|
-
*/
|
|
1071
|
-
fetchMarketAddresses(baseUrl?: string): Promise<string[]>;
|
|
1072
|
-
/**
|
|
1073
|
-
* Get comprehensive information for a P2P market (V3), including reserves, token mints, and settlement criteria
|
|
1074
|
-
* @param marketAddress Market address as PublicKey or string
|
|
1075
|
-
* @param options Optional parameters like base URL
|
|
1076
|
-
* @returns Combined market info with both on-chain data and settlement criteria
|
|
1077
|
-
*/
|
|
1078
|
-
getP2PMarketInfo(marketAddress: PublicKey | string, options?: {
|
|
1079
|
-
baseUrl?: string;
|
|
1080
|
-
}): Promise<{
|
|
1081
|
-
question: string;
|
|
1082
|
-
yesMint: string;
|
|
1083
|
-
noMint: string;
|
|
1084
|
-
yesReserve: string;
|
|
1085
|
-
noReserve: string;
|
|
1086
|
-
collateralMint: string;
|
|
1087
|
-
settlementCriteria: SettlementCriteria | null;
|
|
1088
|
-
endTime: Date;
|
|
1089
|
-
}>;
|
|
1090
|
-
/**
|
|
1091
|
-
* Get comprehensive market information for a V2 market, combining on-chain data and settlement criteria
|
|
1092
|
-
* @param marketAddress Market address as PublicKey or string
|
|
1093
|
-
* @param options Optional parameters like base URL
|
|
1094
|
-
* @returns Combined market info with both on-chain data and settlement criteria
|
|
1095
|
-
*/
|
|
1096
|
-
getV2MarketInfo(marketAddress: PublicKey | string, options?: {
|
|
1097
|
-
baseUrl?: string;
|
|
1098
|
-
}): Promise<{
|
|
1099
|
-
yesMint: string;
|
|
1100
|
-
noMint: string;
|
|
1101
|
-
question: string;
|
|
1102
|
-
creator: string;
|
|
1103
|
-
settlementCriteria: SettlementCriteria | null;
|
|
1104
|
-
yesMultiplier: number;
|
|
1105
|
-
noMultiplier: number;
|
|
1106
|
-
endTime: Date;
|
|
1107
|
-
}>;
|
|
1108
|
-
/**
|
|
1109
|
-
* Fetch V3 market addresses from the proxy server
|
|
1110
|
-
* @param baseUrl - Optional base URL for the proxy server
|
|
1111
|
-
* @returns Array of market addresses
|
|
1112
|
-
*/
|
|
1113
|
-
fetchV3MarketAddresses(baseUrl?: string): Promise<string[]>;
|
|
1114
|
-
/**
|
|
1115
|
-
* Get market metadata (volume, image, initial liquidity) for multiple markets in a single API call
|
|
1116
|
-
* @param markets - Array of market public keys (as strings or PublicKeys)
|
|
1117
|
-
* @param baseUrl - Optional base URL for the proxy server
|
|
1118
|
-
* @returns Array of market metadata including volume, image, and initial liquidity
|
|
1119
|
-
*/
|
|
1120
|
-
getMarketMetaBatch(markets: (string | PublicKey)[], baseUrl?: string): Promise<MarketMeta[]>;
|
|
1121
|
-
/**
|
|
1122
|
-
* Get market metadata (volume, image, initial liquidity) for a single market
|
|
1123
|
-
* @param market - Market public key (as string or PublicKey)
|
|
1124
|
-
* @param baseUrl - Optional base URL for the proxy server
|
|
1125
|
-
* @returns Market metadata including volume, image, and initial liquidity
|
|
1126
|
-
*/
|
|
1127
|
-
getMarketMeta(market: string | PublicKey, baseUrl?: string): Promise<MarketMeta>;
|
|
1128
|
-
/**
|
|
1129
|
-
* Claim creator refund for a market.
|
|
1130
|
-
* Behavior parity with scripts/claimCreatorRefund.ts:
|
|
1131
|
-
* - Eligible if market is not resolvable (proxy or on-chain flag) AND signer is the creator
|
|
1132
|
-
* - Mixed token programs => use creator_refund_v2 with accountsPartial (yes/no token mints null)
|
|
1133
|
-
* - Uniform token programs => try creator_refund_v2 then fallback to v1
|
|
1134
|
-
*/
|
|
1135
|
-
claimMarketRefund(market: PublicKey): Promise<{
|
|
1136
|
-
signature: string;
|
|
1137
|
-
}>;
|
|
1138
|
-
/**
|
|
1139
|
-
* Claim creator refund for a P2P (V3) market by market address.
|
|
1140
|
-
* - Uses getP2PMarketInfo to discover collateral mint
|
|
1141
|
-
* - Decodes MarketV3 to discover creator
|
|
1142
|
-
* - Enforces that the signer is the creator
|
|
1143
|
-
* - Automatically wires all required PDAs and token accounts
|
|
1144
|
-
*/
|
|
1145
|
-
claimP2PMarketRefund(marketAddress: PublicKey | string): Promise<{
|
|
1146
|
-
signature: string;
|
|
1147
|
-
}>;
|
|
1148
|
-
/**
|
|
1149
|
-
* Settle a V2 market by determining the winning outcome.
|
|
1150
|
-
* Only callable by the oracle/admin after market is resolvable.
|
|
1151
|
-
*
|
|
1152
|
-
* @param params Market address and outcome (true for YES winner, false for NO winner)
|
|
1153
|
-
* @returns Transaction signature
|
|
1154
|
-
*/
|
|
1155
|
-
settleMarket(params: {
|
|
1156
|
-
market: PublicKey;
|
|
1157
|
-
yesWinner: boolean;
|
|
1158
|
-
}): Promise<{
|
|
1159
|
-
signature: string;
|
|
1160
|
-
}>;
|
|
1161
|
-
}
|
|
1162
|
-
|
|
1163
|
-
declare function deriveMarketPda(baseMint: PublicKey, quoteMint: PublicKey, programId: PublicKey): [PublicKey, number];
|
|
1164
|
-
declare function derivePositionPda(market: PublicKey, owner: PublicKey, programId: PublicKey): [PublicKey, number];
|
|
1165
|
-
declare function deriveGlobalConfigPda(programId: PublicKey): [PublicKey, number];
|
|
1166
|
-
declare function deriveCreatorFeeTreasuryPda(creator: PublicKey, programId: PublicKey, collateralMint: PublicKey): [PublicKey, number];
|
|
1167
|
-
declare function deriveCreatorFeeTreasuryPdaLegacy(creator: PublicKey, programId: PublicKey): [PublicKey, number];
|
|
1168
|
-
declare function deriveAta(owner: PublicKey, mint: PublicKey, allowOwnerOffCurve?: boolean, tokenProgramId?: PublicKey, ataProgramId?: PublicKey): PublicKey;
|
|
1169
|
-
declare function deriveMarketPdaFromMints(yesMint: PublicKey, noMint: PublicKey, programId: PublicKey): [PublicKey, number];
|
|
1170
|
-
declare function deriveYesTokenMint(globalId: bigint, programId: PublicKey): [PublicKey, number];
|
|
1171
|
-
declare function deriveNoTokenMint(globalId: bigint, programId: PublicKey): [PublicKey, number];
|
|
1172
|
-
declare function deriveTokenMetadataPda(mint: PublicKey, metadataProgramId: PublicKey): [PublicKey, number];
|
|
1173
|
-
|
|
1174
|
-
declare const pdas_deriveAta: typeof deriveAta;
|
|
1175
|
-
declare const pdas_deriveCreatorFeeTreasuryPda: typeof deriveCreatorFeeTreasuryPda;
|
|
1176
|
-
declare const pdas_deriveCreatorFeeTreasuryPdaLegacy: typeof deriveCreatorFeeTreasuryPdaLegacy;
|
|
1177
|
-
declare const pdas_deriveGlobalConfigPda: typeof deriveGlobalConfigPda;
|
|
1178
|
-
declare const pdas_deriveMarketPda: typeof deriveMarketPda;
|
|
1179
|
-
declare const pdas_deriveMarketPdaFromMints: typeof deriveMarketPdaFromMints;
|
|
1180
|
-
declare const pdas_deriveNoTokenMint: typeof deriveNoTokenMint;
|
|
1181
|
-
declare const pdas_derivePositionPda: typeof derivePositionPda;
|
|
1182
|
-
declare const pdas_deriveTokenMetadataPda: typeof deriveTokenMetadataPda;
|
|
1183
|
-
declare const pdas_deriveYesTokenMint: typeof deriveYesTokenMint;
|
|
1184
|
-
declare namespace pdas {
|
|
1185
|
-
export { pdas_deriveAta as deriveAta, pdas_deriveCreatorFeeTreasuryPda as deriveCreatorFeeTreasuryPda, pdas_deriveCreatorFeeTreasuryPdaLegacy as deriveCreatorFeeTreasuryPdaLegacy, pdas_deriveGlobalConfigPda as deriveGlobalConfigPda, pdas_deriveMarketPda as deriveMarketPda, pdas_deriveMarketPdaFromMints as deriveMarketPdaFromMints, pdas_deriveNoTokenMint as deriveNoTokenMint, pdas_derivePositionPda as derivePositionPda, pdas_deriveTokenMetadataPda as deriveTokenMetadataPda, pdas_deriveYesTokenMint as deriveYesTokenMint };
|
|
1186
|
-
}
|
|
1187
|
-
|
|
1188
|
-
export { Client, type Commitment, type GlobalConfigType, type Logger, type MarketMeta, MarketModule, type MarketType, type MarketsResponse, type P2PMarketResponse, PNPClient, ProgramError, type PubkeyLike, RedemptionModule, type SdkConfig, SdkError, type SettlementCriteria, type SettlementData, TradingModule, TransportError, type U64Like, ValidationError, type WinningTokenLike, pdas };
|