@theliem/xmarket-sdk 3.29.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -7,11 +7,6 @@ interface ProgramIds {
7
7
  oracle: PublicKey;
8
8
  conditionalTokens: PublicKey;
9
9
  questionMarket: PublicKey;
10
- /**
11
- * Transfer-hook program (Token-2022).
12
- * Optional in V2 — V2 programs use plain SPL token (TOKEN_PROGRAM_ID), no transfer hook.
13
- */
14
- hook?: PublicKey;
15
10
  clobExchange: PublicKey;
16
11
  feeManagement?: PublicKey;
17
12
  presale?: PublicKey;
@@ -42,8 +37,7 @@ interface OracleConfig {
42
37
  owner: PublicKey;
43
38
  admin: PublicKey;
44
39
  questionCount: number;
45
- whitelist: PublicKey[];
46
- whitelistLen: number;
40
+ reporterCount: number;
47
41
  isPaused: boolean;
48
42
  bump: number;
49
43
  }
@@ -132,8 +126,6 @@ interface CreateQuestionParams {
132
126
  expirationTime: number;
133
127
  /** Collateral mint (e.g. USDC) */
134
128
  collateralMint: PublicKey;
135
- /** Hook program ID for Token-2022 transfer enforcement */
136
- hookProgram: PublicKey;
137
129
  /** Authorized CLOB program ID */
138
130
  authorizedClob: PublicKey;
139
131
  /** Override auto-generated questionId */
@@ -145,13 +137,6 @@ interface CtfConfig {
145
137
  owner: PublicKey;
146
138
  bump: number;
147
139
  }
148
- interface HookConfig {
149
- owner: PublicKey;
150
- whitelist: PublicKey[];
151
- whitelistLen: number;
152
- isFrozen: boolean;
153
- bump: number;
154
- }
155
140
  interface ClobConfig {
156
141
  owner: PublicKey;
157
142
  operators: PublicKey[];
@@ -282,15 +267,15 @@ declare class OracleClient {
282
267
  configPda(owner?: PublicKey): PublicKey;
283
268
  /** One-time setup. Caller becomes owner. */
284
269
  initialize(admin: PublicKey): Promise<TxResult>;
285
- /** Admin or owner adds an address to the oracle resolver whitelist. */
286
- addToWhitelist(address: PublicKey, ownerPubkey?: PublicKey): Promise<TxResult>;
287
- /** Admin or owner removes an address from the oracle resolver whitelist. */
288
- removeFromWhitelist(address: PublicKey, ownerPubkey?: PublicKey): Promise<TxResult>;
270
+ /** Admin or owner registers a reporter PDA. */
271
+ addReporter(reporterAddress: PublicKey, ownerPubkey?: PublicKey): Promise<TxResult>;
272
+ /** Admin or owner removes a reporter PDA. */
273
+ removeReporter(reporterAddress: PublicKey, ownerPubkey?: PublicKey): Promise<TxResult>;
289
274
  /**
290
- * Whitelisted reporter resolves a question.
291
- * reporter signs the instruction; payer covers the tx fee (Kora pattern).
275
+ * Registered reporter resolves a question.
276
+ * reporterSigner signs; payer covers rent for question_result PDA.
292
277
  */
293
- resolveQuestion(questionId: Uint8Array, outcomeCount: number, payoutNumerators: number[], conditionPda: PublicKey, reporter?: PublicKey, payer?: PublicKey, ownerPubkey?: PublicKey): Promise<Transaction>;
278
+ resolveQuestion(questionId: Uint8Array, outcomeCount: number, payoutNumerators: number[], reporterSigner?: PublicKey, payer?: PublicKey, ownerPubkey?: PublicKey): Promise<Transaction>;
294
279
  /** Owner updates the admin. */
295
280
  updateAdmin(newAdmin: PublicKey, ownerPubkey?: PublicKey): Promise<TxResult>;
296
281
  /** Owner transfers ownership to a new keypair. */
@@ -298,10 +283,12 @@ declare class OracleClient {
298
283
  /** Admin or owner pause/unpause the oracle. */
299
284
  pause(paused: boolean, ownerPubkey?: PublicKey): Promise<TxResult>;
300
285
  fetchConfig(owner?: PublicKey): Promise<OracleConfig | null>;
286
+ /** Check if an address is a registered reporter (Reporter PDA exists). */
287
+ isReporter(reporterAddress: PublicKey, ownerPubkey?: PublicKey): Promise<boolean>;
301
288
  fetchQuestionResult(questionId: Uint8Array, ownerPubkey?: PublicKey): Promise<QuestionResult | null>;
302
289
  }
303
290
 
304
- declare class CtfClientV2 {
291
+ declare class CtfClient {
305
292
  private readonly program;
306
293
  private readonly provider;
307
294
  private readonly programIds;
@@ -390,14 +377,14 @@ declare class CtfClientV2 {
390
377
  collateralVaultPda(collateralMint: PublicKey): PublicKey;
391
378
  }
392
379
 
393
- declare class MarketClientV2 {
380
+ declare class MarketClient {
394
381
  private readonly program;
395
382
  private readonly provider;
396
383
  private readonly programIds;
397
384
  readonly configPda: PublicKey;
398
- /** Injected by XMarketSDKV2 after construction — enables fetchQuestionBalances. */
399
- ctfClient?: CtfClientV2;
400
- /** Injected by XMarketSDKV2 — fee config owner (= market owner) for MarketFeeOverride PDA derivation */
385
+ /** Injected by XMarketSDK after construction — enables fetchQuestionBalances. */
386
+ ctfClient?: CtfClient;
387
+ /** Injected by XMarketSDK — fee config owner (= market owner) for MarketFeeOverride PDA derivation */
401
388
  feeConfigOwner?: PublicKey;
402
389
  constructor(program: anchor.Program, provider: anchor.AnchorProvider, programIds: ProgramIds, ownerPubkey: PublicKey);
403
390
  get walletPubkey(): PublicKey;
@@ -437,7 +424,7 @@ declare class MarketClientV2 {
437
424
  /**
438
425
  * Convenience: fetch YES and NO token balances for a question.
439
426
  * Returns null for each if question not approved or position not initialized.
440
- * Requires ctfClient to be injected (done automatically by XMarketSDKV2).
427
+ * Requires ctfClient to be injected (done automatically by XMarketSDK).
441
428
  */
442
429
  fetchQuestionBalances(questionPda: PublicKey, owner: PublicKey): Promise<{
443
430
  yes: Position | null;
@@ -512,6 +499,12 @@ declare class MarketClientV2 {
512
499
  caller?: PublicKey;
513
500
  payer?: PublicKey;
514
501
  }): Promise<Transaction>;
502
+ /**
503
+ * Resolve a question by reading the oracle question_result PDA and updating the CTF condition.
504
+ * Must be called after sdk.oracle.resolveQuestion records the result.
505
+ * Caller must be on the question_market whitelist.
506
+ */
507
+ resolveQuestion(questionId: Uint8Array, conditionPda: PublicKey, oracleOwner: PublicKey, payer?: PublicKey): Promise<Transaction>;
515
508
  /**
516
509
  * Whitelist-only: snapshot MST supply so holders can claim trading fees.
517
510
  * Call after oracle resolves the question.
@@ -598,23 +591,23 @@ declare class FeeManagementClient {
598
591
  }
599
592
 
600
593
  /**
601
- * ClobClientV2 — V2 variant of ClobClient.
602
- * Key differences from ClobClient (v1):
594
+ * ClobClient — V2 variant of the CLOB client.
595
+ * Key differences from the old v1 ClobClient:
603
596
  * - No hookClient dependency (Token-2022 hook removed)
604
597
  * - YES/NO token ATAs use TOKEN_PROGRAM_ID (plain SPL) instead of TOKEN_2022_PROGRAM_ID
605
598
  * - No hook accounts in remainingAccounts for any match instruction
606
599
  * - No extraAccountMetaList / hookConfig PDAs included in ALTs or remainingAccounts
607
600
  */
608
- declare class ClobClientV2 {
601
+ declare class ClobClient {
609
602
  private readonly program;
610
603
  private readonly provider;
611
604
  private readonly programIds;
612
605
  private readonly networkConfig;
613
- /** Injected by XMarketSDKV2 after construction — enables auto fee distribution */
606
+ /** Injected by XMarketSDK after construction — enables auto fee distribution */
614
607
  feeClient?: FeeManagementClient;
615
608
  feeConfigOwner?: PublicKey;
616
- /** Injected by XMarketSDKV2 — enables auto-derive of marketOracleVault for presale markets */
617
- ctfClient?: CtfClientV2;
609
+ /** Injected by XMarketSDK — enables auto-derive of marketOracleVault for presale markets */
610
+ ctfClient?: CtfClient;
618
611
  qmConfigPda?: PublicKey;
619
612
  /** Cached company_address from fee_config to avoid repeated RPC calls */
620
613
  private _companyAddress?;
@@ -1116,21 +1109,21 @@ declare class DisputeClient {
1116
1109
  }
1117
1110
 
1118
1111
  /**
1119
- * XMarketSDKV2 — V2 variant of XMarketSDK.
1112
+ * XMarketSDK — V2 SDK.
1120
1113
  *
1121
- * Key differences from XMarketSDK (v1):
1114
+ * Key differences from the old v1 SDK:
1122
1115
  * - Uses V2 program IDs (conditionalTokens, clobExchange, questionMarket)
1123
- * - CtfClientV2: plain SPL TOKEN_PROGRAM_ID for YES/NO mints, no hook
1124
- * - ClobClientV2: no hookClient, no hook accounts in match instructions
1125
- * - MarketClientV2: no hookProgram param in createQuestionAdmin / approvePresale
1126
- * - No HookClient (sdk.hook throws a clear error)
1116
+ * - CtfClient: plain SPL TOKEN_PROGRAM_ID for YES/NO mints, no hook
1117
+ * - ClobClient: no hookClient, no hook accounts in match instructions
1118
+ * - MarketClient: no hookProgram param in createQuestionAdmin / approvePresale
1119
+ * - No HookClient (hook program removed entirely)
1127
1120
  *
1128
1121
  * Usage:
1129
- * const sdk = new XMarketSDKV2(DEVNET_V2_CONFIG, wallet, marketOwner);
1122
+ * const sdk = new XMarketSDK(DEVNET_CONFIG, wallet, marketOwner);
1130
1123
  * await sdk.market.createQuestionAdmin(params, oracle); // no hookProgram
1131
1124
  * await sdk.clob.matchOrders(taker, makers); // no hook in remainingAccounts
1132
1125
  */
1133
- declare class XMarketSDKV2 {
1126
+ declare class XMarketSDK {
1134
1127
  readonly provider: anchor.AnchorProvider;
1135
1128
  readonly networkConfig: NetworkConfig;
1136
1129
  private readonly _programIds;
@@ -1148,14 +1141,9 @@ declare class XMarketSDKV2 {
1148
1141
  constructor(config: NetworkConfig, wallet: anchor.Wallet, marketOwner?: PublicKey);
1149
1142
  private _withAddress;
1150
1143
  get oracle(): OracleClient;
1151
- /**
1152
- * V2 does not use a hook program — calling this getter throws an error.
1153
- * The hook is not needed for plain SPL YES/NO mints.
1154
- */
1155
- get hook(): never;
1156
- get market(): MarketClientV2;
1157
- get ctf(): CtfClientV2;
1158
- get clob(): ClobClientV2;
1144
+ get market(): MarketClient;
1145
+ get ctf(): CtfClient;
1146
+ get clob(): ClobClient;
1159
1147
  get fee(): FeeManagementClient;
1160
1148
  get presale(): PresaleClient;
1161
1149
  get marketOracle(): MarketOracleClient;
@@ -1164,650 +1152,76 @@ declare class XMarketSDKV2 {
1164
1152
  get dispute(): DisputeClient;
1165
1153
  }
1166
1154
 
1167
- declare class HookClient {
1168
- private readonly program;
1169
- private readonly provider;
1170
- private readonly programIds;
1171
- constructor(program: anchor.Program, provider: anchor.AnchorProvider, programIds: ProgramIds);
1172
- get walletPubkey(): PublicKey;
1173
- configPda(): PublicKey;
1174
- /** One-time setup. Caller becomes owner. */
1175
- initialize(initialWhitelist: PublicKey[]): Promise<TxResult>;
1176
- /**
1177
- * Returns initializeExtraAccountMetaList instruction if the account doesn't exist yet, else null.
1178
- * Used by ClobClient to auto-prepend when extraAccountMetaList is missing.
1179
- */
1180
- buildInitHookIxIfNeeded(mint: PublicKey, payer: PublicKey): Promise<TransactionInstruction | null>;
1181
- /**
1182
- * Register extra account metas for a Token-2022 YES/NO mint.
1183
- * Must be called once per mint after CTF creates it.
1184
- */
1185
- initializeExtraAccountMetaList(mint: PublicKey): Promise<TxResult>;
1186
- /** Owner adds a program to the transfer whitelist. */
1187
- addToWhitelist(program: PublicKey): Promise<TxResult>;
1188
- /** Owner removes a program from the transfer whitelist. */
1189
- removeFromWhitelist(program: PublicKey): Promise<TxResult>;
1190
- /** Permanently freeze the whitelist — no further changes allowed. */
1191
- freezeWhitelist(): Promise<TxResult>;
1192
- /**
1193
- * SPL Transfer-Hook `execute` — invoked automatically by Token-2022 on every
1194
- * YES/NO token transfer. Validates the destination against the whitelist.
1195
- *
1196
- * Calling this directly is useful for:
1197
- * - Off-chain simulation ("would this transfer be allowed?")
1198
- * - Integration tests that verify whitelist enforcement
1199
- *
1200
- * Token-2022 calls this automatically; you normally don't call it manually.
1201
- *
1202
- * @param sourceToken - Source token account (tokens leaving)
1203
- * @param mint - The YES/NO Token-2022 mint
1204
- * @param destinationToken - Destination token account (tokens arriving)
1205
- * @param owner - Authority that authorized the transfer
1206
- * @param amount - Token amount being transferred
1207
- */
1208
- execute(sourceToken: PublicKey, mint: PublicKey, destinationToken: PublicKey, owner: PublicKey, amount: anchor.BN): Promise<TxResult>;
1209
- fetchConfig(): Promise<HookConfig | null>;
1210
- isWhitelisted(program: PublicKey): Promise<boolean>;
1211
- }
1212
-
1213
- declare class CtfClient {
1214
- private readonly program;
1215
- private readonly provider;
1216
- private readonly programIds;
1217
- constructor(program: anchor.Program, provider: anchor.AnchorProvider, programIds: ProgramIds);
1218
- get walletPubkey(): PublicKey;
1219
- /**
1220
- * Create a Condition directly (bypasses QuestionMarket).
1221
- * oracle is UncheckedAccount set it to any pubkey (e.g. user wallet)
1222
- * so that wallet can later sign reportPayouts.
1223
- * payer covers rent for condition + mints.
1224
- */
1225
- prepareCondition(questionId: Uint8Array, oracle: PublicKey, collateralMint: PublicKey, hookProgram: PublicKey, authorizedClob: PublicKey, payer?: PublicKey, signers?: Keypair[]): Promise<{
1226
- signature: string;
1227
- conditionPda: PublicKey;
1228
- yesMint: PublicKey;
1229
- noMint: PublicKey;
1230
- }>;
1231
- /** One-time setup. Caller becomes the CTF owner. Can only be called once. */
1232
- initializeCtfConfig(): Promise<TxResult>;
1233
- /**
1234
- * Create the shared collateral vault for a given collateral mint (e.g. USDC).
1235
- * Only callable by the CTF owner (as stored in ctf_config).
1236
- * authority defaults to the wallet — pass a different signer if needed.
1237
- */
1238
- initializeVault(collateralMint: PublicKey): Promise<TxResult>;
1239
- /**
1240
- * Initialize an empty Position account (balance = 0) for a user.
1241
- * Needed before redeemPositions when the user only holds the opposite outcome
1242
- * (e.g. buyer received YES via CLOB match but never had a NO position).
1243
- *
1244
- * Idempotent — call `fetchPosition` first to skip if already initialized.
1245
- */
1246
- initPosition(condition: PublicKey, outcomeIndex: number, user?: PublicKey): Promise<TxResult>;
1247
- /**
1248
- * Split `amount` collateral into equal YES + NO tokens.
1249
- * ATAs created automatically via `init_if_needed`.
1250
- */
1251
- splitPosition(condition: PublicKey, collateralMint: PublicKey, amount: anchor.BN, user?: PublicKey, payer?: PublicKey): Promise<Transaction>;
1252
- /**
1253
- * Merge `amount` YES + NO tokens back into collateral.
1254
- * Both token balances must be ≥ amount.
1255
- */
1256
- mergePosition(condition: PublicKey, collateralMint: PublicKey, amount: anchor.BN, user?: PublicKey, payer?: PublicKey): Promise<Transaction>;
1257
- /**
1258
- * After condition resolves: burn outcome tokens proportional to payout
1259
- * and receive USDC. Works for winning, losing, or both positions.
1260
- */
1261
- redeemPositions(condition: PublicKey, collateralMint: PublicKey, user?: PublicKey, payer?: PublicKey): Promise<Transaction>;
1262
- /**
1263
- * Oracle directly resolves a condition with payout numerators.
1264
- * Bypasses QuestionMarket — only for oracle-owned conditions.
1265
- */
1266
- reportPayouts(condition: PublicKey, payoutNumerators: number[]): Promise<TxResult>;
1267
- /**
1268
- * Build the `transfer_position` instruction for use in a CLOB CPI.
1269
- *
1270
- * This instruction requires `clob_authority` (the CLOB's PDA) to sign.
1271
- * A PDA can only sign from within its own program via CPI — this method
1272
- * CANNOT be called directly from a wallet transaction.
1273
- *
1274
- * Use-cases:
1275
- * - Custom CLOB implementations that call CTF.transfer_position via CPI
1276
- * - Anchor CPI builders in other Rust programs
1277
- *
1278
- * @param condition - Condition PDA
1279
- * @param outcomeMint - YES or NO mint
1280
- * @param fromUser - Source wallet
1281
- * @param fromTokenAccount - Source ATA
1282
- * @param fromPosition - Source Position PDA
1283
- * @param toUser - Destination wallet
1284
- * @param toTokenAccount - Destination ATA (created if needed — payer covers rent)
1285
- * @param toPosition - Destination Position PDA
1286
- * @param payer - Pays rent for toPosition + toTokenAccount creation
1287
- * @param clobAuthority - CLOB config PDA (must sign via CPI)
1288
- * @param outcomeIndex - 0 = NO, 1 = YES
1289
- * @param amount - Token amount to transfer
1290
- */
1291
- transferPositionIx(condition: PublicKey, outcomeMint: PublicKey, fromUser: PublicKey, fromTokenAccount: PublicKey, fromPosition: PublicKey, toUser: PublicKey, toTokenAccount: PublicKey, toPosition: PublicKey, payer: PublicKey, clobAuthority: PublicKey, outcomeIndex: number, amount: anchor.BN): Promise<TransactionInstruction>;
1292
- /**
1293
- * Update the authorized CLOB on a condition.
1294
- * Only callable by the condition's oracle (the wallet that signed createQuestion).
1295
- */
1296
- updateAuthorizedClob(condition: PublicKey, newAuthorizedClob: PublicKey): Promise<TxResult>;
1297
- fetchCtfConfig(): Promise<CtfConfig | null>;
1298
- fetchCondition(conditionPda: PublicKey): Promise<Condition | null>;
1299
- fetchVault(collateralMint: PublicKey): Promise<CollateralVault | null>;
1300
- fetchPosition(condition: PublicKey, outcomeIndex: number, owner?: PublicKey): Promise<Position | null>;
1301
- /** YES = outcome index 1, NO = outcome index 0. */
1302
- fetchBothPositions(condition: PublicKey, owner?: PublicKey): Promise<{
1303
- yes: Position | null;
1304
- no: Position | null;
1305
- }>;
1306
- /** Thin wrapper: fetch position for a single outcome token (0=NO, 1=YES). */
1307
- fetchTokenBalance(condition: PublicKey, tokenId: number, owner?: PublicKey): Promise<Position | null>;
1308
- yesMintPda(condition: PublicKey): PublicKey;
1309
- noMintPda(condition: PublicKey): PublicKey;
1310
- mintAuthorityPda(condition: PublicKey): PublicKey;
1311
- collateralVaultPda(collateralMint: PublicKey): PublicKey;
1155
+ declare const SEEDS: {
1156
+ readonly config: Buffer<ArrayBuffer>;
1157
+ readonly question: Buffer<ArrayBuffer>;
1158
+ readonly condition: Buffer<ArrayBuffer>;
1159
+ readonly collateralVault: Buffer<ArrayBuffer>;
1160
+ readonly vaultToken: Buffer<ArrayBuffer>;
1161
+ readonly position: Buffer<ArrayBuffer>;
1162
+ readonly yesMint: Buffer<ArrayBuffer>;
1163
+ readonly noMint: Buffer<ArrayBuffer>;
1164
+ readonly mintAuthority: Buffer<ArrayBuffer>;
1165
+ readonly reporter: Buffer<ArrayBuffer>;
1166
+ readonly result: Buffer<ArrayBuffer>;
1167
+ readonly ctfConfig: Buffer<ArrayBuffer>;
1168
+ readonly clobConfig: Buffer<ArrayBuffer>;
1169
+ readonly order: Buffer<ArrayBuffer>;
1170
+ readonly feeConfig: Buffer<ArrayBuffer>;
1171
+ readonly referralConfig: Buffer<ArrayBuffer>;
1172
+ readonly questionFee: Buffer<ArrayBuffer>;
1173
+ readonly marketFee: Buffer<ArrayBuffer>;
1174
+ readonly presale: Buffer<ArrayBuffer>;
1175
+ readonly qtMint: Buffer<ArrayBuffer>;
1176
+ readonly qtAuthority: Buffer<ArrayBuffer>;
1177
+ readonly userBuy: Buffer<ArrayBuffer>;
1178
+ readonly marketOracle: Buffer<ArrayBuffer>;
1179
+ readonly userClaim: Buffer<ArrayBuffer>;
1180
+ readonly adminConfig: Buffer<ArrayBuffer>;
1181
+ readonly claimRecord: Buffer<ArrayBuffer>;
1182
+ readonly disputeConfig: Buffer<ArrayBuffer>;
1183
+ readonly disputeMarket: Buffer<ArrayBuffer>;
1184
+ readonly userDispute: Buffer<ArrayBuffer>;
1185
+ };
1186
+ declare class PDA {
1187
+ static questionMarketConfig(owner: PublicKey, programIds: Pick<ProgramIds, "questionMarket">): [PublicKey, number];
1188
+ static question(config: PublicKey, questionId: Uint8Array, programIds: Pick<ProgramIds, "questionMarket">): [PublicKey, number];
1189
+ static ctfConfig(programIds: Pick<ProgramIds, "conditionalTokens">): [PublicKey, number];
1190
+ static condition(oracle: PublicKey, questionId: Uint8Array, programIds: Pick<ProgramIds, "conditionalTokens">): [PublicKey, number];
1191
+ static collateralVault(collateralMint: PublicKey, programIds: Pick<ProgramIds, "conditionalTokens">): [PublicKey, number];
1192
+ static vaultToken(collateralMint: PublicKey, programIds: Pick<ProgramIds, "conditionalTokens">): [PublicKey, number];
1193
+ static yesMint(condition: PublicKey, programIds: Pick<ProgramIds, "conditionalTokens">): [PublicKey, number];
1194
+ static noMint(condition: PublicKey, programIds: Pick<ProgramIds, "conditionalTokens">): [PublicKey, number];
1195
+ static mintAuthority(condition: PublicKey, programIds: Pick<ProgramIds, "conditionalTokens">): [PublicKey, number];
1196
+ static position(condition: PublicKey, outcomeIndex: number, owner: PublicKey, programIds: Pick<ProgramIds, "conditionalTokens">): [PublicKey, number];
1197
+ static oracleConfig(owner: PublicKey, programIds: Pick<ProgramIds, "oracle">): [PublicKey, number];
1198
+ static reporter(oracleConfig: PublicKey, reporterAddress: PublicKey, programIds: Pick<ProgramIds, "oracle">): [PublicKey, number];
1199
+ static questionResult(oracleConfig: PublicKey, questionId: Uint8Array, programIds: Pick<ProgramIds, "oracle">): [PublicKey, number];
1200
+ static clobConfig(programIds: Pick<ProgramIds, "clobExchange">): [PublicKey, number];
1201
+ static orderStatus(maker: PublicKey, nonce: BN, programIds: Pick<ProgramIds, "clobExchange">): [PublicKey, number];
1202
+ static orderRecord(maker: PublicKey, nonce: BN, programIds: Pick<ProgramIds, "clobExchange">): [PublicKey, number];
1203
+ static collectFeeOrderRecord(user: PublicKey, nonce: BN, programIds: Pick<ProgramIds, "clobExchange">): [PublicKey, number];
1204
+ static redeemFeeOrderRecord(user: PublicKey, nonce: BN, programIds: Pick<ProgramIds, "clobExchange">): [PublicKey, number];
1205
+ static feeConfig(owner: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
1206
+ static questionFee(conditionPda: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
1207
+ static marketFeeOverride(conditionPda: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
1208
+ static presale(questionMarketConfig: PublicKey, presaleIndex: BN, programIds: Pick<ProgramIds, "presale">): [PublicKey, number];
1209
+ static qtMint(presalePda: PublicKey, programIds: Pick<ProgramIds, "presale">): [PublicKey, number];
1210
+ static qtAuthority(presalePda: PublicKey, programIds: Pick<ProgramIds, "presale">): [PublicKey, number];
1211
+ static userBuyRecord(presalePda: PublicKey, user: PublicKey, programIds: Pick<ProgramIds, "presale">): [PublicKey, number];
1212
+ static marketOraclePda(questionPda: PublicKey, programIds: Pick<ProgramIds, "marketOracle">): [PublicKey, number];
1213
+ static userClaimRecord(marketOraclePda: PublicKey, user: PublicKey, programIds: Pick<ProgramIds, "marketOracle">): [PublicKey, number];
1214
+ static referralConfig(owner: PublicKey, programIds: Pick<ProgramIds, "referral">): [PublicKey, number];
1215
+ static adminConfig(owner: PublicKey, programIds: Pick<ProgramIds, "adminContract">): [PublicKey, number];
1216
+ static claimRecord(conditionId: Uint8Array, programIds: Pick<ProgramIds, "adminContract">): [PublicKey, number];
1217
+ static disputeConfig(owner: PublicKey, programIds: Pick<ProgramIds, "dispute">): [PublicKey, number];
1218
+ static disputeMarket(conditionId: Uint8Array, programIds: Pick<ProgramIds, "dispute">): [PublicKey, number];
1219
+ static userDispute(user: PublicKey, conditionId: Uint8Array, programIds: Pick<ProgramIds, "dispute">): [PublicKey, number];
1312
1220
  }
1313
-
1314
- declare class MarketClient {
1315
- private readonly program;
1316
- private readonly provider;
1317
- private readonly programIds;
1318
- readonly configPda: PublicKey;
1319
- /** Injected by XMarketSDK after construction — enables fetchQuestionBalances. */
1320
- ctfClient?: CtfClient;
1321
- /** Injected by XMarketSDK — fee config owner (= market owner) for MarketFeeOverride PDA derivation */
1322
- feeConfigOwner?: PublicKey;
1323
- constructor(program: anchor.Program, provider: anchor.AnchorProvider, programIds: ProgramIds, ownerPubkey: PublicKey);
1324
- get walletPubkey(): PublicKey;
1325
- initialize(admin: PublicKey, oracle: PublicKey, owner?: PublicKey): Promise<Transaction>;
1326
- /**
1327
- * Build createQuestionAdmin transaction (whitelist/admin path — status = Approved immediately).
1328
- * @param creator - Whitelisted creator (must be in whitelist or be admin/owner)
1329
- * @param payer - Fee payer (pays rent; can differ from creator)
1330
- */
1331
- createQuestionAdmin(params: CreateQuestionParams, oracle: PublicKey, creator?: PublicKey, payer?: PublicKey): Promise<{
1332
- tx: Transaction;
1333
- questionPda: PublicKey;
1334
- conditionPda: PublicKey;
1335
- questionId: Uint8Array;
1336
- }>;
1337
- approveQuestion(questionPda: PublicKey, admin?: PublicKey, payer?: PublicKey): Promise<Transaction>;
1338
- updateConfig(params: {
1339
- newAdmin?: PublicKey;
1340
- newOracle?: PublicKey;
1341
- isPaused?: boolean;
1342
- newConditionalTokensProgram?: PublicKey;
1343
- }, authority?: PublicKey, payer?: PublicKey): Promise<Transaction>;
1344
- /** Set the admin (owner only). Replaces any existing admin. */
1345
- addAdmin(newAdmin: PublicKey, owner?: PublicKey): Promise<Transaction>;
1346
- /** Clear the admin (owner only). Sets admin to default pubkey. */
1347
- removeAdmin(owner?: PublicKey): Promise<Transaction>;
1348
- addToWhitelist(address: PublicKey, authority?: PublicKey, payer?: PublicKey): Promise<Transaction>;
1349
- removeFromWhitelist(address: PublicKey, authority?: PublicKey, payer?: PublicKey): Promise<Transaction>;
1350
- growConfig(owner?: PublicKey, payer?: PublicKey): Promise<Transaction>;
1351
- restoreConfig(snapshot: Buffer, owner?: PublicKey, payer?: PublicKey): Promise<Transaction>;
1352
- bumpPresaleCount(count: number, authority: PublicKey): Promise<Transaction>;
1353
- fetchConfig(): Promise<QuestionMarketConfig | null>;
1354
- fetchQuestion(questionPda: PublicKey): Promise<Question | null>;
1355
- questionPda(questionId: Uint8Array): PublicKey;
1356
- private _parseStatus;
1357
- /**
1358
- * Convenience: fetch YES and NO token balances for a question.
1359
- * Returns null for each if question not approved or position not initialized.
1360
- * Requires ctfClient to be injected (done automatically by XMarketSDK).
1361
- */
1362
- fetchQuestionBalances(questionPda: PublicKey, owner: PublicKey): Promise<{
1363
- yes: Position | null;
1364
- no: Position | null;
1365
- }>;
1366
- /**
1367
- * Any user creates a presale + initial buy (question-market::create_presale).
1368
- * Reads agents_rev / company_rev from fee_config.
1369
- *
1370
- * @param feeConfig fee_management fee_config PDA (owner = feeConfigOwner)
1371
- * @param currencyMint collateral token (e.g. USDC)
1372
- * @param presaleIndex config.presale_count — fetch config first or pass 0 for first presale
1373
- */
1374
- createPresale(params: {
1375
- price: anchor.BN;
1376
- startTime: anchor.BN;
1377
- endTime: anchor.BN;
1378
- initialBuyAmount: anchor.BN;
1379
- }, feeConfig: PublicKey, currencyMint: PublicKey, presaleIndex: anchor.BN, creator?: PublicKey, payer?: PublicKey): Promise<{
1380
- tx: Transaction;
1381
- presalePda: PublicKey;
1382
- qtMint: PublicKey;
1383
- }>;
1384
- /**
1385
- * Whitelist-only: approve presale → creates question + CTF condition + market_oracle in one tx.
1386
- *
1387
- * @param presalePda the presale account
1388
- * @param contentHash 32-byte hash for question content
1389
- * @param hookProgram token-2022 transfer hook program
1390
- * @param authorizedClob clob program allowed to do CTF transfers
1391
- * @param expirationTime Unix seconds
1392
- * @param creator presale creator pubkey (stored in question)
1393
- * @param currencyMint collateral mint
1394
- */
1395
- approvePresale(params: {
1396
- presalePda: PublicKey;
1397
- contentHash: Uint8Array;
1398
- hookProgram: PublicKey;
1399
- authorizedClob: PublicKey;
1400
- expirationTime: anchor.BN;
1401
- creator: PublicKey;
1402
- currencyMint: PublicKey;
1403
- /** Revenue distribution — required: approvePresale now distributes 80/10/10 automatically */
1404
- referralAddress: PublicKey;
1405
- companyAddress: PublicKey;
1406
- adminOwner: PublicKey;
1407
- caller?: PublicKey;
1408
- payer?: PublicKey;
1409
- /** Provide an ALT to use VersionedTransaction (required: 31 accounts exceeds legacy tx limit) */
1410
- lookupTable?: AddressLookupTableAccount;
1411
- }): Promise<{
1412
- tx: Transaction | VersionedTransaction;
1413
- questionPda: PublicKey;
1414
- conditionPda: PublicKey;
1415
- marketOraclePda: PublicKey;
1416
- marketOracleVault: PublicKey;
1417
- }>;
1418
- /**
1419
- * Whitelist-only: reject presale so users can refund.
1420
- */
1421
- rejectPresale(presalePda: PublicKey, caller?: PublicKey): Promise<Transaction>;
1422
- /**
1423
- * Whitelist-only: distribute presale vault → 10% agents + 10% company + 80% botmm.
1424
- * Closes presale_vault ATA and presale PDA after distribution; lamports returned to payer.
1425
- */
1426
- collectPresaleRevenue(params: {
1427
- presalePda: PublicKey;
1428
- currencyMint: PublicKey;
1429
- conditionId: Uint8Array;
1430
- referralAddress: PublicKey;
1431
- companyAddress: PublicKey;
1432
- adminOwner: PublicKey;
1433
- caller?: PublicKey;
1434
- payer?: PublicKey;
1435
- }): Promise<Transaction>;
1436
- /**
1437
- * Whitelist-only: snapshot MST supply so holders can claim trading fees.
1438
- * Call after oracle resolves the question.
1439
- */
1440
- collectTradingFee(marketOraclePda: PublicKey, qtMint: PublicKey, caller?: PublicKey): Promise<Transaction>;
1441
- }
1442
-
1443
- declare class ClobClient {
1444
- private readonly program;
1445
- private readonly provider;
1446
- private readonly programIds;
1447
- private readonly networkConfig;
1448
- /** Injected by XMarketSDK after construction — enables auto fee distribution */
1449
- feeClient?: FeeManagementClient;
1450
- feeConfigOwner?: PublicKey;
1451
- /** Injected by XMarketSDK — enables auto-derive of marketOracleVault for presale markets */
1452
- ctfClient?: CtfClient;
1453
- qmConfigPda?: PublicKey;
1454
- /** Injected by XMarketSDK — enables auto-init extraAccountMetaList if missing */
1455
- hookClient?: HookClient;
1456
- /** Cached company_address from fee_config to avoid repeated RPC calls */
1457
- private _companyAddress?;
1458
- /** Cached referral_vault from fee_config */
1459
- private _referralVault?;
1460
- /** Cache: conditionPda.toBase58() → marketOracleVault ATA */
1461
- private _marketOracleVaultCache;
1462
- /** ALT cache: condition.toBase58() → loaded ALT account */
1463
- private _altCache;
1464
- constructor(program: anchor.Program, provider: anchor.AnchorProvider, programIds: ProgramIds, networkConfig: {
1465
- defaultCollateral: {
1466
- mint: PublicKey;
1467
- };
1468
- });
1469
- private companyAddress;
1470
- private referralVault;
1471
- /**
1472
- * Derive marketOracleVault ATA for a condition, cached per condition.
1473
- * Works for presale markets (market_oracle initialized by approvePresale).
1474
- * Returns undefined if ctfClient/qmConfigPda not injected or marketOracle not configured.
1475
- */
1476
- private getMarketOracleVault;
1477
- /**
1478
- * Returns a createATA ix for the oracle vault when:
1479
- * - takerFee > 0
1480
- * - marketFeeOverride exists for the condition
1481
- * - oracle vault ATA is not yet initialized
1482
- * Idempotent — safe to call every tx; returns null if vault already exists.
1483
- */
1484
- private buildInitOracleVaultIfNeeded;
1485
- get walletPubkey(): PublicKey;
1486
- /**
1487
- * Get or create an ALT for a condition.
1488
- * Includes order_record PDAs for taker + all makers so match tx stays under 1232 bytes.
1489
- */
1490
- ensureAlt(condition: PublicKey, collateralMint: PublicKey, takerSigned: SignedOrder, makers: SignedOrder[]): Promise<AddressLookupTableAccount>;
1491
- private _sendLegacyTxSig;
1492
- private _sendLegacyTx;
1493
- private _ensureClobOutcomeAtas;
1494
- /**
1495
- * Send a match transaction as versioned (v0) with optional ALT.
1496
- * Both operator wallet and payer (this.provider.wallet) sign.
1497
- */
1498
- sendMatchTx(instructions: TransactionInstruction[], lookupTable?: AddressLookupTableAccount, whitelistedWallet?: anchor.Wallet): Promise<string>;
1499
- configPda(): PublicKey;
1500
- /**
1501
- * Register a signed order on-chain.
1502
- * Sends Ed25519 precompile ix + register_order ix in one legacy tx.
1503
- * Called at match time (engine-triggered), not at order placement.
1504
- */
1505
- registerOrder(signed: SignedOrder): Promise<string>;
1506
- /** Register only if the PDA doesn't exist yet (idempotent). */
1507
- private registerOrderIfNeeded;
1508
- /**
1509
- * Build a legacy Transaction to register a CollectFeeOrder on-chain.
1510
- * Must be signed and sent before calling buildBatchCollectRedeemEarlyTx.
1511
- *
1512
- * Flow: [Ed25519 ix (1 user sig) + register_collect_fee_order ix]
1513
- * Caller signs with payer keypair and sends.
1514
- */
1515
- buildRegisterCollectFeeOrderTx(signedOrder: SignedCollectFeeOrder, payer: PublicKey): Promise<Transaction>;
1516
- /**
1517
- * Register a CollectFeeOrder on-chain and send immediately (operator-signed flow).
1518
- * Idempotent — skips if PDA already exists.
1519
- */
1520
- registerCollectFeeOrderIfNeeded(signedOrder: SignedCollectFeeOrder): Promise<void>;
1521
- /** Cancel an order — closes its OrderRecord PDA and returns rent to maker. */
1522
- cancelOrder(nonce: anchor.BN): Promise<TxResult>;
1523
- initialize(operators: PublicKey[], feeRecipient: PublicKey, feeRateBps: number): Promise<TxResult>;
1524
- addOperator(operator: PublicKey): Promise<TxResult>;
1525
- removeOperator(operator: PublicKey): Promise<TxResult>;
1526
- setPaused(paused: boolean): Promise<TxResult>;
1527
- forceResetClob(programData: PublicKey, newAdmin: PublicKey, newOperators: PublicKey[], newFeeRecipient: PublicKey, newFeeRateBps: number): Promise<TxResult>;
1528
- /**
1529
- * Build match_complementary instruction (no Ed25519 — OrderRecord PDAs used).
1530
- *
1531
- * remaining_accounts layout:
1532
- * [seller, order_record, seller_token, seller_collateral, seller_position, sell_status] × N
1533
- * [extraAccountMetaList, hookConfig, hookProgram]
1534
- * [feeManagement, fee_config, mkt_override, company_ata, oracle_vault] (when fee > 0)
1535
- */
1536
- buildMatchComplementaryIxs(takerSigned: SignedOrder, makersSigned: SignedOrder[], collateralMint: PublicKey, feeRecipient: PublicKey, operator: PublicKey, opts?: {
1537
- marketOracleVault?: PublicKey;
1538
- fillAmount?: anchor.BN;
1539
- }, useTakerPrice?: boolean, skipCrossingCheck?: boolean): Promise<TransactionInstruction[]>;
1540
- /**
1541
- * COMPLEMENTARY: 1 taker (BUY) + N makers (SELL), same tokenId.
1542
- * Phase 1: register taker + all makers in parallel.
1543
- * Phase 2: 1 atomic match tx.
1544
- */
1545
- private matchComplementary;
1546
- /**
1547
- * 1 SELL taker vs N BUY makers.
1548
- * Program now supports SELL-as-taker natively → 1 instruction with all BUY makers
1549
- * in remaining_accounts (same structure as BUY taker case).
1550
- */
1551
- private matchComplementarySellVsMultiBuy;
1552
- /**
1553
- * MINT: 1 YES buyer (taker) + N NO buyers (makers).
1554
- * Phase 1: register taker + all NO makers in parallel.
1555
- * Phase 2: 1 atomic match tx.
1556
- *
1557
- * remaining_accounts per NO maker (5):
1558
- * [order_record, buyer_no_token, buyer_no_collateral, buyer_no_position, no_order_status]
1559
- */
1560
- /** Build the match_mint_orders instruction (no signing, no sending). */
1561
- private _buildMintIx;
1562
- private matchMintOrders;
1563
- /**
1564
- * MERGE: 1 YES seller (taker) + N NO sellers (makers).
1565
- * Phase 1: register taker + all NO makers in parallel.
1566
- * Phase 2: 1 atomic match tx.
1567
- *
1568
- * remaining_accounts per NO maker (5):
1569
- * [order_record, seller_no_token, seller_no_collateral, seller_no_position, no_order_status]
1570
- * After all makers, optional 5 fee accounts.
1571
- */
1572
- /** Build the match_merge_orders instruction (no signing, no sending). */
1573
- private _buildMergeIx;
1574
- private matchMergeOrders;
1575
- /**
1576
- * Auto-detect match type and execute 2-phase:
1577
- * Phase 1 — register all orders (taker + makers) on-chain in parallel.
1578
- * Phase 2 — 1 atomic match transaction.
1579
- *
1580
- * Detection (pure, no RPC):
1581
- * taker.tokenId === makers[0].tokenId:
1582
- * taker BUY + all makers SELL → COMPLEMENTARY
1583
- * taker.tokenId !== makers[0].tokenId + all BUY → MINT
1584
- * taker.tokenId !== makers[0].tokenId + all SELL → MERGE
1585
- *
1586
- * @param opts.marketOracleVault Oracle vault ATA for presale markets.
1587
- * Omit for admin markets (payer used as placeholder).
1588
- */
1589
- matchOrders(taker: SignedOrder, makers: SignedOrder[], opts?: {
1590
- marketOracleVault?: PublicKey;
1591
- operatorWallet?: anchor.Wallet;
1592
- }): Promise<TxResult>;
1593
- /**
1594
- * High-level match: caller passes price + quantity + keypair — SDK builds,
1595
- * signs, and submits in one call. No manual amount calculation needed.
1596
- *
1597
- * Amounts are computed from each order's own limit `price` (percentage, e.g. 51 for 51%).
1598
- * NEVER pass averageMatchedPrice — that is an engine output, not an order input.
1599
- *
1600
- * @param taker { keypair, condition, tokenId, side, price, quantity, nonce?, expiry? }
1601
- * @param makers Array of same shape
1602
- * @param decimals Collateral decimals (default 9 for USDS)
1603
- */
1604
- matchOrdersFromPrice(taker: {
1605
- keypair: {
1606
- publicKey: PublicKey;
1607
- secretKey: Uint8Array;
1608
- };
1609
- condition: PublicKey;
1610
- tokenId: number;
1611
- side: 0 | 1;
1612
- price: number;
1613
- quantity: number;
1614
- nonce?: BN;
1615
- expiry?: BN;
1616
- fee?: BN;
1617
- taker?: PublicKey;
1618
- }, makers: Array<{
1619
- keypair: {
1620
- publicKey: PublicKey;
1621
- secretKey: Uint8Array;
1622
- };
1623
- condition: PublicKey;
1624
- tokenId: number;
1625
- side: 0 | 1;
1626
- price: number;
1627
- quantity: number;
1628
- nonce?: BN;
1629
- expiry?: BN;
1630
- fee?: BN;
1631
- taker?: PublicKey;
1632
- }>, decimals?: number, opts?: {
1633
- marketOracleVault?: PublicKey;
1634
- operatorWallet?: anchor.Wallet;
1635
- }): Promise<TxResult>;
1636
- /**
1637
- * Build an unsigned VersionedTransaction for a set of match instructions.
1638
- * Callers sign and send externally — mirrors createQuestionAdmin pattern.
1639
- */
1640
- private _buildUnsignedVtx;
1641
- /**
1642
- * Build unsigned VersionedTransaction(s) for matching orders.
1643
- *
1644
- * Mirrors createQuestionAdmin pattern — SDK registers orders internally but
1645
- * returns the match tx unsigned. BE signs with both keypairs and sends:
1646
- *
1647
- * const [vtx] = await sdk.clob.buildMatchOrdersTx(taker, makers, operatorPk, payerPk);
1648
- * vtx.sign([feePayerKeypair, operatorKeypair]);
1649
- * await connection.sendRawTransaction(vtx.serialize());
1650
- *
1651
- * All match types pack into a single VersionedTransaction — same as createQuestionAdmin pattern.
1652
- * NO-taker MINT/MERGE decomposes into N instructions but all packed in 1 tx.
1653
- *
1654
- * @param operator - Whitelisted CLOB operator pubkey (must sign)
1655
- * @param payer - Fee payer pubkey (must sign, pays tx fee + rent)
1656
- */
1657
- buildMatchOrdersTx(taker: SignedOrder, makers: SignedOrder[], operator: PublicKey, payer: PublicKey, opts?: {
1658
- marketOracleVault?: PublicKey;
1659
- }): Promise<VersionedTransaction>;
1660
- /**
1661
- * Build VersionedTransaction for batchCollectRedeemEarly.
1662
- *
1663
- * Prerequisite: each user's CollectFeeOrder must be registered on-chain via
1664
- * buildRegisterCollectFeeOrderTx (one tx per user).
1665
- *
1666
- * Flow: batchCollectRedeemEarly ix reads CollectFeeOrderRecord PDAs — no Ed25519 inline.
1667
- * No tx-size limit from signatures, supports 10+ orders in one tx.
1668
- *
1669
- * @param signedOrders - Array of { order, signature } (used to derive record PDAs)
1670
- * @param condition - Market condition PDA
1671
- * @param outcomeIndex - 0 = NO wins, 1 = YES wins
1672
- * @param operator - Whitelisted operator pubkey (must sign)
1673
- * @param payer - Fee payer pubkey (must sign)
1674
- * @param opts.marketOracleVault - MarketOracle vault for fee distribution
1675
- */
1676
- buildBatchCollectRedeemEarlyTx(signedOrders: SignedCollectFeeOrder[], condition: PublicKey, outcomeIndex: 0 | 1, operator: PublicKey, payer: PublicKey, opts?: {
1677
- marketOracleVault?: PublicKey;
1678
- lookupTable?: AddressLookupTableAccount;
1679
- }): Promise<VersionedTransaction>;
1680
- /**
1681
- * Build a Transaction to register a RedeemFeeOrder on-chain (Ed25519 verify + PDA).
1682
- * Must be sent before calling buildBatchRedeemWithFeeTx / buildBatchMergeWithFeeTx.
1683
- *
1684
- * ix[0]: batched Ed25519 { pubkey=order.user, sig, msg=128 bytes }
1685
- * ix[1]: register_redeem_fee_order(nonce)
1686
- */
1687
- buildRegisterRedeemFeeOrderTx(signedOrder: SignedRedeemFeeOrder, payer: PublicKey): Promise<anchor.web3.Transaction>;
1688
- /**
1689
- * Build a VersionedTransaction for batchRedeemWithFee.
1690
- * Each pair has a YES order + NO order for the same user (same signer or different).
1691
- * After resolution: YES holder taker_amount > 0, NO holder taker_amount = 0 (or vice versa).
1692
- *
1693
- * Prerequisite: each order's RedeemFeeOrderRecord must be registered via buildRegisterRedeemFeeOrderTx.
1694
- */
1695
- buildBatchRedeemWithFeeTx(orderPairs: RedeemFeeOrderPair[], condition: PublicKey, operator: PublicKey, payer: PublicKey, opts?: {
1696
- marketOracleVault?: PublicKey;
1697
- lookupTable?: AddressLookupTableAccount;
1698
- }): Promise<VersionedTransaction>;
1699
- /**
1700
- * Build a VersionedTransaction for batchMergeWithFee (pre-resolution merge with fee).
1701
- * Each pair: YES order + NO order with equal amounts for the same user.
1702
- * Only yes_signer receives net USDS (mirrors EVM _matchMergeOrder).
1703
- *
1704
- * Prerequisite: each order's RedeemFeeOrderRecord must be registered via buildRegisterRedeemFeeOrderTx.
1705
- */
1706
- buildBatchMergeWithFeeTx(orderPairs: RedeemFeeOrderPair[], condition: PublicKey, operator: PublicKey, payer: PublicKey, opts?: {
1707
- marketOracleVault?: PublicKey;
1708
- lookupTable?: AddressLookupTableAccount;
1709
- }): Promise<VersionedTransaction>;
1710
- /**
1711
- * Build ALT for batchCollectRedeemEarly — includes per-user accounts so all
1712
- * remaining_accounts fit as 1-byte ALT indices instead of 32-byte inline addresses.
1713
- */
1714
- buildAltForCollectBatch(condition: PublicKey, payer: PublicKey, collateralMint: PublicKey, signedOrders: SignedCollectFeeOrder[], outcomeIndex: 0 | 1): Promise<AddressLookupTableAccount>;
1715
- /**
1716
- * Build ALT with static accounts for a condition — no order-specific PDAs needed.
1717
- * Use before buildBatchCollectRedeemEarlyTx when no prior buildMatchOrdersTx ran in this session.
1718
- */
1719
- buildAltForCondition(condition: PublicKey, _payer: PublicKey, collateralMint?: PublicKey): Promise<AddressLookupTableAccount>;
1720
- fetchConfig(): Promise<ClobConfig | null>;
1721
- fetchOrderStatus(maker: PublicKey, nonce: anchor.BN): Promise<OrderStatus | null>;
1722
- fetchOrderRecord(maker: PublicKey, nonce: anchor.BN): Promise<{
1723
- maker: PublicKey;
1724
- condition: PublicKey;
1725
- tokenId: number;
1726
- side: number;
1727
- makerAmount: anchor.BN;
1728
- takerAmount: anchor.BN;
1729
- nonce: anchor.BN;
1730
- expiry: anchor.BN;
1731
- fee: anchor.BN;
1732
- taker: PublicKey;
1733
- signer: PublicKey;
1734
- } | null>;
1735
- }
1736
-
1737
- declare const SEEDS: {
1738
- readonly config: Buffer<ArrayBuffer>;
1739
- readonly question: Buffer<ArrayBuffer>;
1740
- readonly condition: Buffer<ArrayBuffer>;
1741
- readonly collateralVault: Buffer<ArrayBuffer>;
1742
- readonly vaultToken: Buffer<ArrayBuffer>;
1743
- readonly position: Buffer<ArrayBuffer>;
1744
- readonly yesMint: Buffer<ArrayBuffer>;
1745
- readonly noMint: Buffer<ArrayBuffer>;
1746
- readonly mintAuthority: Buffer<ArrayBuffer>;
1747
- readonly reporter: Buffer<ArrayBuffer>;
1748
- readonly result: Buffer<ArrayBuffer>;
1749
- readonly ctfConfig: Buffer<ArrayBuffer>;
1750
- readonly hookConfig: Buffer<ArrayBuffer>;
1751
- readonly extraAccountMetas: Buffer<ArrayBuffer>;
1752
- readonly clobConfig: Buffer<ArrayBuffer>;
1753
- readonly order: Buffer<ArrayBuffer>;
1754
- readonly feeConfig: Buffer<ArrayBuffer>;
1755
- readonly referralConfig: Buffer<ArrayBuffer>;
1756
- readonly questionFee: Buffer<ArrayBuffer>;
1757
- readonly marketFee: Buffer<ArrayBuffer>;
1758
- readonly presale: Buffer<ArrayBuffer>;
1759
- readonly qtMint: Buffer<ArrayBuffer>;
1760
- readonly qtAuthority: Buffer<ArrayBuffer>;
1761
- readonly userBuy: Buffer<ArrayBuffer>;
1762
- readonly marketOracle: Buffer<ArrayBuffer>;
1763
- readonly userClaim: Buffer<ArrayBuffer>;
1764
- readonly adminConfig: Buffer<ArrayBuffer>;
1765
- readonly claimRecord: Buffer<ArrayBuffer>;
1766
- readonly disputeConfig: Buffer<ArrayBuffer>;
1767
- readonly disputeMarket: Buffer<ArrayBuffer>;
1768
- readonly userDispute: Buffer<ArrayBuffer>;
1769
- };
1770
- declare class PDA {
1771
- static questionMarketConfig(owner: PublicKey, programIds: Pick<ProgramIds, "questionMarket">): [PublicKey, number];
1772
- static question(config: PublicKey, questionId: Uint8Array, programIds: Pick<ProgramIds, "questionMarket">): [PublicKey, number];
1773
- static ctfConfig(programIds: Pick<ProgramIds, "conditionalTokens">): [PublicKey, number];
1774
- static condition(oracle: PublicKey, questionId: Uint8Array, programIds: Pick<ProgramIds, "conditionalTokens">): [PublicKey, number];
1775
- static collateralVault(collateralMint: PublicKey, programIds: Pick<ProgramIds, "conditionalTokens">): [PublicKey, number];
1776
- static vaultToken(collateralMint: PublicKey, programIds: Pick<ProgramIds, "conditionalTokens">): [PublicKey, number];
1777
- static yesMint(condition: PublicKey, programIds: Pick<ProgramIds, "conditionalTokens">): [PublicKey, number];
1778
- static noMint(condition: PublicKey, programIds: Pick<ProgramIds, "conditionalTokens">): [PublicKey, number];
1779
- static mintAuthority(condition: PublicKey, programIds: Pick<ProgramIds, "conditionalTokens">): [PublicKey, number];
1780
- static position(condition: PublicKey, outcomeIndex: number, owner: PublicKey, programIds: Pick<ProgramIds, "conditionalTokens">): [PublicKey, number];
1781
- static oracleConfig(owner: PublicKey, programIds: Pick<ProgramIds, "oracle">): [PublicKey, number];
1782
- static reporter(oracleConfig: PublicKey, reporterAddress: PublicKey, programIds: Pick<ProgramIds, "oracle">): [PublicKey, number];
1783
- static questionResult(oracleConfig: PublicKey, questionId: Uint8Array, programIds: Pick<ProgramIds, "oracle">): [PublicKey, number];
1784
- static hookConfig(programIds: Pick<ProgramIds, "hook">): [PublicKey, number];
1785
- static extraAccountMetaList(mint: PublicKey, programIds: Pick<ProgramIds, "hook">): [PublicKey, number];
1786
- static clobConfig(programIds: Pick<ProgramIds, "clobExchange">): [PublicKey, number];
1787
- static orderStatus(maker: PublicKey, nonce: BN, programIds: Pick<ProgramIds, "clobExchange">): [PublicKey, number];
1788
- static orderRecord(maker: PublicKey, nonce: BN, programIds: Pick<ProgramIds, "clobExchange">): [PublicKey, number];
1789
- static collectFeeOrderRecord(user: PublicKey, nonce: BN, programIds: Pick<ProgramIds, "clobExchange">): [PublicKey, number];
1790
- static redeemFeeOrderRecord(user: PublicKey, nonce: BN, programIds: Pick<ProgramIds, "clobExchange">): [PublicKey, number];
1791
- static feeConfig(owner: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
1792
- static questionFee(conditionPda: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
1793
- static marketFeeOverride(conditionPda: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
1794
- static presale(questionMarketConfig: PublicKey, presaleIndex: BN, programIds: Pick<ProgramIds, "presale">): [PublicKey, number];
1795
- static qtMint(presalePda: PublicKey, programIds: Pick<ProgramIds, "presale">): [PublicKey, number];
1796
- static qtAuthority(presalePda: PublicKey, programIds: Pick<ProgramIds, "presale">): [PublicKey, number];
1797
- static userBuyRecord(presalePda: PublicKey, user: PublicKey, programIds: Pick<ProgramIds, "presale">): [PublicKey, number];
1798
- static marketOraclePda(questionPda: PublicKey, programIds: Pick<ProgramIds, "marketOracle">): [PublicKey, number];
1799
- static userClaimRecord(marketOraclePda: PublicKey, user: PublicKey, programIds: Pick<ProgramIds, "marketOracle">): [PublicKey, number];
1800
- static referralConfig(owner: PublicKey, programIds: Pick<ProgramIds, "referral">): [PublicKey, number];
1801
- static adminConfig(owner: PublicKey, programIds: Pick<ProgramIds, "adminContract">): [PublicKey, number];
1802
- static claimRecord(conditionId: Uint8Array, programIds: Pick<ProgramIds, "adminContract">): [PublicKey, number];
1803
- static disputeConfig(owner: PublicKey, programIds: Pick<ProgramIds, "dispute">): [PublicKey, number];
1804
- static disputeMarket(conditionId: Uint8Array, programIds: Pick<ProgramIds, "dispute">): [PublicKey, number];
1805
- static userDispute(user: PublicKey, conditionId: Uint8Array, programIds: Pick<ProgramIds, "dispute">): [PublicKey, number];
1806
- }
1807
- /** Unique 32-byte question ID: SHA-256(content + timestamp). Different each call. */
1808
- declare function generateQuestionId(content: string, salt?: number): Uint8Array;
1809
- /** Deterministic 32-byte content hash: SHA-256(content). Same content = same hash. */
1810
- declare function generateContentHash(content: string): Uint8Array;
1221
+ /** Unique 32-byte question ID: SHA-256(content + timestamp). Different each call. */
1222
+ declare function generateQuestionId(content: string, salt?: number): Uint8Array;
1223
+ /** Deterministic 32-byte content hash: SHA-256(content). Same content = same hash. */
1224
+ declare function generateContentHash(content: string): Uint8Array;
1811
1225
 
1812
1226
  declare function serializeOrderToBytes(order: Order): Uint8Array;
1813
1227
  /**
@@ -1982,22 +1396,50 @@ type MatchType = "COMPLEMENTARY" | "MINT" | "MERGE";
1982
1396
  declare function detectMatchType(a: Order | SignedOrder, b: Order | SignedOrder): MatchType;
1983
1397
 
1984
1398
  /**
1985
- * SPL Token approve utilities for the CLOB matching flow.
1986
- * V2: YES/NO mints are plain SPL tokens (TOKEN_PROGRAM_ID), no Token-2022.
1399
+ * SPL Token / Token-2022 approve utilities for the CLOB matching flow.
1400
+ *
1401
+ * Before a match instruction can transfer tokens on behalf of a user, the user
1402
+ * must approve the CLOB config PDA as a delegate. These helpers build the
1403
+ * approve transactions that need two signers:
1404
+ * - signer = the token owner (user wallet — must sign the approve instruction)
1405
+ * - payer = the BE wallet (pays transaction fees)
1406
+ *
1407
+ * Both must sign the resulting Transaction before sending.
1987
1408
  */
1988
1409
 
1410
+ /** Maximum u64 — approve "unlimited" amount. */
1989
1411
  declare const MAX_APPROVE_AMOUNT: BN;
1990
1412
  /**
1991
- * Build a Transaction that creates YES and NO SPL ATAs for a user (idempotent).
1413
+ * Build a Transaction that creates YES and NO ATAs for a user
1414
+ * (idempotent — safe to call even if they already exist).
1415
+ *
1416
+ * Required signer: payer (fee payer). No user signature needed.
1417
+ *
1418
+ * @param condition - condition PDA
1419
+ * @param user - wallet that will own the ATAs
1420
+ * @param payer - fee payer wallet pubkey
1421
+ * @param programIds - network program IDs
1992
1422
  */
1993
1423
  declare function buildCreateUserAtasTx(condition: PublicKey, user: PublicKey, payer: PublicKey, programIds: ProgramIds): Transaction;
1994
1424
  /**
1995
- * Build a Transaction that approves the CLOB config PDA to transfer collateral (USDS).
1425
+ * Build a Transaction that approves the CLOB config PDA to transfer collateral
1426
+ * (USDC) from the signer's ATA.
1427
+ *
1428
+ * Required signers: signer (token owner), payer (fee payer).
1429
+ *
1430
+ * @param collateralMint - e.g. USDC mint
1431
+ * @param signer - token owner (must sign)
1432
+ * @param payer - fee payer wallet pubkey
1433
+ * @param delegate - clob config PDA (the spender)
1434
+ * @param amount - amount to approve (defaults to MAX_APPROVE_AMOUNT)
1996
1435
  */
1997
1436
  declare function buildApproveCollateralTx(collateralMint: PublicKey, signer: PublicKey, payer: PublicKey, delegate: PublicKey, amount?: BN): Transaction;
1998
1437
  /**
1999
- * Build a Transaction that approves the CLOB config PDA to transfer YES and NO tokens.
1438
+ * Build a Transaction that approves the CLOB config PDA to transfer BOTH
1439
+ * YES and NO outcome tokens from the signer's ATAs (two approve instructions).
1440
+ *
1441
+ * Required signers: signer (token owner), payer (fee payer).
2000
1442
  */
2001
1443
  declare function buildApproveAllOutcomeTokensTx(condition: PublicKey, signer: PublicKey, payer: PublicKey, delegate: PublicKey, programIds: ProgramIds, amount?: BN): Transaction;
2002
1444
 
2003
- export { AccountNotFoundError, AdminClient, type AdminConfigInfo, type ClaimRecordInfo, ClobClient, ClobClientV2, type ClobConfig, type CollateralConfig, type CollateralVault, type CollectFeeOrder, type Condition, type CreateQuestionParams, CtfClient, CtfClientV2, type CtfConfig, DisputeClient, type DisputeConfigInfo, type DisputeMarketInfo, FEE_DENOMINATOR, FeeManagementClient, type FeesShareEstimate, HookClient, type HookConfig, IX_SYSVAR, InvalidParamError, MAX_APPROVE_AMOUNT, MarketClient, MarketClientV2, MarketOracleClient, type MarketOracleInfo, type MatchType, type NetworkConfig, type NetworkName, OracleClient, type OracleConfig, type Order, type OrderStatus, PDA, type Position, PresaleClient, type PresaleInfo, type ProgramIds, type Question, type QuestionFee, type QuestionMarketConfig, type QuestionResult, QuestionStatus, type RedeemFeeOrder, type RedeemFeeOrderPair, ReferralClient, type ReferralConfigInfo, SEEDS, type SignedCollectFeeOrder, type SignedOrder, type SignedRedeemFeeOrder, type TxResult, UnauthorizedError, type UserBuyRecord, type UserClaimRecord, type UserDisputeInfo, XMarketError, XMarketSDKV2 as XMarketSDK, XMarketSDKV2, buildApproveAllOutcomeTokensTx, buildApproveCollateralTx, buildBatchedCollectFeeEd25519Instruction, buildBatchedEd25519Instruction, buildBatchedRedeemFeeEd25519Instruction, buildCreateUserAtasTx, buildOrder, buildOrderFromPrice, deserializeSignedOrder, detectMatchType, generateContentHash, generateQuestionId, getOrderSignBytes, orderAmountsFromPrice, serializeCollectFeeOrderToBytes, serializeOrderToBytes, serializeRedeemFeeOrderToBytes, serializeSignedOrder, signOrder, signOrderWithKeypair, verifySignedOrder };
1445
+ export { AccountNotFoundError, AdminClient, type AdminConfigInfo, type ClaimRecordInfo, ClobClient, type ClobConfig, type CollateralConfig, type CollateralVault, type CollectFeeOrder, type Condition, type CreateQuestionParams, CtfClient, type CtfConfig, DisputeClient, type DisputeConfigInfo, type DisputeMarketInfo, FEE_DENOMINATOR, FeeManagementClient, type FeesShareEstimate, IX_SYSVAR, InvalidParamError, MAX_APPROVE_AMOUNT, MarketClient, MarketOracleClient, type MarketOracleInfo, type MatchType, type NetworkConfig, type NetworkName, OracleClient, type OracleConfig, type Order, type OrderStatus, PDA, type Position, PresaleClient, type PresaleInfo, type ProgramIds, type Question, type QuestionFee, type QuestionMarketConfig, type QuestionResult, QuestionStatus, type RedeemFeeOrder, type RedeemFeeOrderPair, ReferralClient, type ReferralConfigInfo, SEEDS, type SignedCollectFeeOrder, type SignedOrder, type SignedRedeemFeeOrder, type TxResult, UnauthorizedError, type UserBuyRecord, type UserClaimRecord, type UserDisputeInfo, XMarketError, XMarketSDK, buildApproveAllOutcomeTokensTx, buildApproveCollateralTx, buildBatchedCollectFeeEd25519Instruction, buildBatchedEd25519Instruction, buildBatchedRedeemFeeEd25519Instruction, buildCreateUserAtasTx, buildOrder, buildOrderFromPrice, deserializeSignedOrder, detectMatchType, generateContentHash, generateQuestionId, getOrderSignBytes, orderAmountsFromPrice, serializeCollectFeeOrderToBytes, serializeOrderToBytes, serializeRedeemFeeOrderToBytes, serializeSignedOrder, signOrder, signOrderWithKeypair, verifySignedOrder };