@theliem/xmarket-sdk 4.1.1 → 4.1.2

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
@@ -25,10 +25,26 @@ interface NetworkConfig {
25
25
  rpcUrl: string;
26
26
  programIds: ProgramIds;
27
27
  defaultCollateral: CollateralConfig;
28
+ /**
29
+ * Owner pubkey used to derive question_market config PDA: ["config", owner].
30
+ * Pass to XMarketSDK as the 3rd constructor arg when set.
31
+ */
32
+ marketOwner?: PublicKey;
28
33
  /** Owner of the fee_config PDA — used to auto-derive fee distribution accounts */
29
34
  feeConfigOwner?: PublicKey;
30
35
  }
31
36
  type NetworkName = string;
37
+ /** pm-svm v2 program IDs (same on devnet redeploy and mainnet). */
38
+ declare const V2_PROGRAM_IDS: ProgramIds;
39
+ /** Devnet question_market config owner (= config PDA seed). */
40
+ declare const DEVNET_MARKET_OWNER: PublicKey;
41
+ /** Devnet question_market config PDA for DEVNET_MARKET_OWNER + V2 questionMarket program. */
42
+ declare const DEVNET_QUESTION_MARKET_CONFIG: PublicKey;
43
+ declare const DEVNET_USDC_MINT: PublicKey;
44
+ declare const MAINNET_USDC_MINT: PublicKey;
45
+ /** Default devnet config — override rpcUrl if using a private RPC (e.g. Chainstack). */
46
+ declare const DEVNET_CONFIG: NetworkConfig;
47
+ declare const MAINNET_CONFIG: NetworkConfig;
32
48
 
33
49
  interface TxResult {
34
50
  signature: string;
@@ -418,7 +434,11 @@ declare class MarketClient {
418
434
  growConfig(owner?: PublicKey, payer?: PublicKey): Promise<Transaction>;
419
435
  restoreConfig(snapshot: Buffer, owner?: PublicKey, payer?: PublicKey): Promise<Transaction>;
420
436
  bumpPresaleCount(count: number, authority: PublicKey): Promise<Transaction>;
437
+ private configNotFoundMessage;
421
438
  fetchConfig(): Promise<QuestionMarketConfig | null>;
439
+ /** Like fetchConfig but throws with a hint when the config account is missing or invalid. */
440
+ fetchConfigOrThrow(): Promise<QuestionMarketConfig>;
441
+ private mapQuestionMarketConfig;
422
442
  /** Check if address is in question_market whitelist (can call createQuestion) */
423
443
  isWhitelisted(address: PublicKey): Promise<boolean>;
424
444
  fetchQuestion(questionPda: PublicKey): Promise<Question | null>;
@@ -437,9 +457,10 @@ declare class MarketClient {
437
457
  * Any user creates a presale + initial buy (question-market::create_presale).
438
458
  * Reads agents_rev / company_rev from fee_config.
439
459
  *
440
- * @param feeConfig fee_management fee_config PDA (owner = feeConfigOwner)
441
- * @param currencyMint collateral token (e.g. USDC)
442
- * @param presaleIndex config.presale_count — fetch config first or pass 0 for first presale
460
+ * Presale PDA seeds (presale program): ["presale", config, presale_index]
461
+ * where presale_index must equal config.presale_count at execution time.
462
+ *
463
+ * @param presaleIndex config.presale_count — fetch config first via fetchConfig()
443
464
  */
444
465
  createPresale(params: {
445
466
  price: anchor.BN;
@@ -1139,7 +1160,8 @@ declare class DisputeClient {
1139
1160
  * - No HookClient (hook program removed entirely)
1140
1161
  *
1141
1162
  * Usage:
1142
- * const sdk = new XMarketSDK(DEVNET_CONFIG, wallet, marketOwner);
1163
+ * const sdk = new XMarketSDK({ ...DEVNET_CONFIG, rpcUrl: YOUR_RPC }, wallet);
1164
+ * // marketOwner defaults to config.marketOwner (required for fetchConfig / createPresale)
1143
1165
  * await sdk.market.createQuestionAdmin(params, oracle); // no hookProgram
1144
1166
  * await sdk.clob.matchOrders(taker, makers); // no hook in remainingAccounts
1145
1167
  */
@@ -1159,6 +1181,8 @@ declare class XMarketSDK {
1159
1181
  private _referral?;
1160
1182
  private _dispute?;
1161
1183
  constructor(config: NetworkConfig, wallet: anchor.Wallet, marketOwner?: PublicKey);
1184
+ /** Question market config PDA derived from marketOwner + questionMarket program. */
1185
+ get questionMarketConfigPda(): PublicKey;
1162
1186
  private _withAddress;
1163
1187
  get oracle(): OracleClient;
1164
1188
  get market(): MarketClient;
@@ -1225,6 +1249,7 @@ declare class PDA {
1225
1249
  static feeConfig(owner: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
1226
1250
  static questionFee(conditionPda: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
1227
1251
  static marketFeeOverride(conditionPda: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
1252
+ /** seeds: ["presale", questionMarketConfig, presale_index u64 LE] under presale program */
1228
1253
  static presale(questionMarketConfig: PublicKey, presaleIndex: BN, programIds: Pick<ProgramIds, "presale">): [PublicKey, number];
1229
1254
  static qtMint(presalePda: PublicKey, programIds: Pick<ProgramIds, "presale">): [PublicKey, number];
1230
1255
  static qtAuthority(presalePda: PublicKey, programIds: Pick<ProgramIds, "presale">): [PublicKey, number];
@@ -1462,4 +1487,4 @@ declare function buildApproveCollateralTx(collateralMint: PublicKey, signer: Pub
1462
1487
  */
1463
1488
  declare function buildApproveAllOutcomeTokensTx(condition: PublicKey, signer: PublicKey, payer: PublicKey, delegate: PublicKey, programIds: ProgramIds, amount?: BN): Transaction;
1464
1489
 
1465
- 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 };
1490
+ export { AccountNotFoundError, AdminClient, type AdminConfigInfo, type ClaimRecordInfo, ClobClient, type ClobConfig, type CollateralConfig, type CollateralVault, type CollectFeeOrder, type Condition, type CreateQuestionParams, CtfClient, type CtfConfig, DEVNET_CONFIG, DEVNET_MARKET_OWNER, DEVNET_QUESTION_MARKET_CONFIG, DEVNET_USDC_MINT, DisputeClient, type DisputeConfigInfo, type DisputeMarketInfo, FEE_DENOMINATOR, FeeManagementClient, type FeesShareEstimate, IX_SYSVAR, InvalidParamError, MAINNET_CONFIG, MAINNET_USDC_MINT, 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, V2_PROGRAM_IDS, XMarketError, XMarketSDK, buildApproveAllOutcomeTokensTx, buildApproveCollateralTx, buildBatchedCollectFeeEd25519Instruction, buildBatchedEd25519Instruction, buildBatchedRedeemFeeEd25519Instruction, buildCreateUserAtasTx, buildOrder, buildOrderFromPrice, deserializeSignedOrder, detectMatchType, generateContentHash, generateQuestionId, getOrderSignBytes, orderAmountsFromPrice, serializeCollectFeeOrderToBytes, serializeOrderToBytes, serializeRedeemFeeOrderToBytes, serializeSignedOrder, signOrder, signOrderWithKeypair, verifySignedOrder };
package/dist/index.d.ts CHANGED
@@ -25,10 +25,26 @@ interface NetworkConfig {
25
25
  rpcUrl: string;
26
26
  programIds: ProgramIds;
27
27
  defaultCollateral: CollateralConfig;
28
+ /**
29
+ * Owner pubkey used to derive question_market config PDA: ["config", owner].
30
+ * Pass to XMarketSDK as the 3rd constructor arg when set.
31
+ */
32
+ marketOwner?: PublicKey;
28
33
  /** Owner of the fee_config PDA — used to auto-derive fee distribution accounts */
29
34
  feeConfigOwner?: PublicKey;
30
35
  }
31
36
  type NetworkName = string;
37
+ /** pm-svm v2 program IDs (same on devnet redeploy and mainnet). */
38
+ declare const V2_PROGRAM_IDS: ProgramIds;
39
+ /** Devnet question_market config owner (= config PDA seed). */
40
+ declare const DEVNET_MARKET_OWNER: PublicKey;
41
+ /** Devnet question_market config PDA for DEVNET_MARKET_OWNER + V2 questionMarket program. */
42
+ declare const DEVNET_QUESTION_MARKET_CONFIG: PublicKey;
43
+ declare const DEVNET_USDC_MINT: PublicKey;
44
+ declare const MAINNET_USDC_MINT: PublicKey;
45
+ /** Default devnet config — override rpcUrl if using a private RPC (e.g. Chainstack). */
46
+ declare const DEVNET_CONFIG: NetworkConfig;
47
+ declare const MAINNET_CONFIG: NetworkConfig;
32
48
 
33
49
  interface TxResult {
34
50
  signature: string;
@@ -418,7 +434,11 @@ declare class MarketClient {
418
434
  growConfig(owner?: PublicKey, payer?: PublicKey): Promise<Transaction>;
419
435
  restoreConfig(snapshot: Buffer, owner?: PublicKey, payer?: PublicKey): Promise<Transaction>;
420
436
  bumpPresaleCount(count: number, authority: PublicKey): Promise<Transaction>;
437
+ private configNotFoundMessage;
421
438
  fetchConfig(): Promise<QuestionMarketConfig | null>;
439
+ /** Like fetchConfig but throws with a hint when the config account is missing or invalid. */
440
+ fetchConfigOrThrow(): Promise<QuestionMarketConfig>;
441
+ private mapQuestionMarketConfig;
422
442
  /** Check if address is in question_market whitelist (can call createQuestion) */
423
443
  isWhitelisted(address: PublicKey): Promise<boolean>;
424
444
  fetchQuestion(questionPda: PublicKey): Promise<Question | null>;
@@ -437,9 +457,10 @@ declare class MarketClient {
437
457
  * Any user creates a presale + initial buy (question-market::create_presale).
438
458
  * Reads agents_rev / company_rev from fee_config.
439
459
  *
440
- * @param feeConfig fee_management fee_config PDA (owner = feeConfigOwner)
441
- * @param currencyMint collateral token (e.g. USDC)
442
- * @param presaleIndex config.presale_count — fetch config first or pass 0 for first presale
460
+ * Presale PDA seeds (presale program): ["presale", config, presale_index]
461
+ * where presale_index must equal config.presale_count at execution time.
462
+ *
463
+ * @param presaleIndex config.presale_count — fetch config first via fetchConfig()
443
464
  */
444
465
  createPresale(params: {
445
466
  price: anchor.BN;
@@ -1139,7 +1160,8 @@ declare class DisputeClient {
1139
1160
  * - No HookClient (hook program removed entirely)
1140
1161
  *
1141
1162
  * Usage:
1142
- * const sdk = new XMarketSDK(DEVNET_CONFIG, wallet, marketOwner);
1163
+ * const sdk = new XMarketSDK({ ...DEVNET_CONFIG, rpcUrl: YOUR_RPC }, wallet);
1164
+ * // marketOwner defaults to config.marketOwner (required for fetchConfig / createPresale)
1143
1165
  * await sdk.market.createQuestionAdmin(params, oracle); // no hookProgram
1144
1166
  * await sdk.clob.matchOrders(taker, makers); // no hook in remainingAccounts
1145
1167
  */
@@ -1159,6 +1181,8 @@ declare class XMarketSDK {
1159
1181
  private _referral?;
1160
1182
  private _dispute?;
1161
1183
  constructor(config: NetworkConfig, wallet: anchor.Wallet, marketOwner?: PublicKey);
1184
+ /** Question market config PDA derived from marketOwner + questionMarket program. */
1185
+ get questionMarketConfigPda(): PublicKey;
1162
1186
  private _withAddress;
1163
1187
  get oracle(): OracleClient;
1164
1188
  get market(): MarketClient;
@@ -1225,6 +1249,7 @@ declare class PDA {
1225
1249
  static feeConfig(owner: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
1226
1250
  static questionFee(conditionPda: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
1227
1251
  static marketFeeOverride(conditionPda: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
1252
+ /** seeds: ["presale", questionMarketConfig, presale_index u64 LE] under presale program */
1228
1253
  static presale(questionMarketConfig: PublicKey, presaleIndex: BN, programIds: Pick<ProgramIds, "presale">): [PublicKey, number];
1229
1254
  static qtMint(presalePda: PublicKey, programIds: Pick<ProgramIds, "presale">): [PublicKey, number];
1230
1255
  static qtAuthority(presalePda: PublicKey, programIds: Pick<ProgramIds, "presale">): [PublicKey, number];
@@ -1462,4 +1487,4 @@ declare function buildApproveCollateralTx(collateralMint: PublicKey, signer: Pub
1462
1487
  */
1463
1488
  declare function buildApproveAllOutcomeTokensTx(condition: PublicKey, signer: PublicKey, payer: PublicKey, delegate: PublicKey, programIds: ProgramIds, amount?: BN): Transaction;
1464
1489
 
1465
- 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 };
1490
+ export { AccountNotFoundError, AdminClient, type AdminConfigInfo, type ClaimRecordInfo, ClobClient, type ClobConfig, type CollateralConfig, type CollateralVault, type CollectFeeOrder, type Condition, type CreateQuestionParams, CtfClient, type CtfConfig, DEVNET_CONFIG, DEVNET_MARKET_OWNER, DEVNET_QUESTION_MARKET_CONFIG, DEVNET_USDC_MINT, DisputeClient, type DisputeConfigInfo, type DisputeMarketInfo, FEE_DENOMINATOR, FeeManagementClient, type FeesShareEstimate, IX_SYSVAR, InvalidParamError, MAINNET_CONFIG, MAINNET_USDC_MINT, 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, V2_PROGRAM_IDS, XMarketError, XMarketSDK, buildApproveAllOutcomeTokensTx, buildApproveCollateralTx, buildBatchedCollectFeeEd25519Instruction, buildBatchedEd25519Instruction, buildBatchedRedeemFeeEd25519Instruction, buildCreateUserAtasTx, buildOrder, buildOrderFromPrice, deserializeSignedOrder, detectMatchType, generateContentHash, generateQuestionId, getOrderSignBytes, orderAmountsFromPrice, serializeCollectFeeOrderToBytes, serializeOrderToBytes, serializeRedeemFeeOrderToBytes, serializeSignedOrder, signOrder, signOrderWithKeypair, verifySignedOrder };
package/dist/index.js CHANGED
@@ -211,6 +211,7 @@ var PDA = class {
211
211
  );
212
212
  }
213
213
  // ─── Presale ─────────────────────────────────────────────────────────────────
214
+ /** seeds: ["presale", questionMarketConfig, presale_index u64 LE] under presale program */
214
215
  static presale(questionMarketConfig, presaleIndex, programIds) {
215
216
  if (!programIds.presale) throw new Error("presale program ID not configured");
216
217
  const idxBuf = Buffer.alloc(8);
@@ -633,28 +634,52 @@ var MarketClient = class {
633
634
  return this.program.methods.bumpPresaleCount(new anchor6__namespace.BN(count)).accounts({ authority, config: this.configPda }).transaction();
634
635
  }
635
636
  // ─── Queries ─────────────────────────────────────────────────────────────────
637
+ configNotFoundMessage() {
638
+ return `Question market config not found at ${this.configPda.toBase58()}. Check NetworkConfig.programIds.questionMarket (v2 FkpHo3...) and marketOwner (config owner pubkey \u2014 not the user wallet). Devnet: use DEVNET_CONFIG or marketOwner DEVNET_MARKET_OWNER.`;
639
+ }
636
640
  async fetchConfig() {
641
+ const info = await this.provider.connection.getAccountInfo(this.configPda);
642
+ if (!info) return null;
637
643
  try {
638
644
  const acc = await this.program.account.questionMarketConfig.fetch(this.configPda);
639
- return {
640
- owner: acc.owner,
641
- admin: acc.admin,
642
- oracle: acc.oracle,
643
- oracleProgram: acc.oracleProgram,
644
- conditionalTokensProgram: acc.conditionalTokensProgram,
645
- questionCount: acc.questionCount.toNumber(),
646
- approvedCount: acc.approvedCount.toNumber(),
647
- rejectedCount: acc.rejectedCount.toNumber(),
648
- presaleCount: acc.presaleCount.toNumber(),
649
- whitelist: acc.whitelist.slice(0, acc.whitelistLen),
650
- whitelistLen: acc.whitelistLen,
651
- isPaused: acc.isPaused,
652
- bump: acc.bump
653
- };
645
+ return this.mapQuestionMarketConfig(acc);
654
646
  } catch {
655
647
  return null;
656
648
  }
657
649
  }
650
+ /** Like fetchConfig but throws with a hint when the config account is missing or invalid. */
651
+ async fetchConfigOrThrow() {
652
+ const info = await this.provider.connection.getAccountInfo(this.configPda);
653
+ if (!info) {
654
+ throw new Error(this.configNotFoundMessage());
655
+ }
656
+ try {
657
+ const acc = await this.program.account.questionMarketConfig.fetch(this.configPda);
658
+ return this.mapQuestionMarketConfig(acc);
659
+ } catch (e) {
660
+ throw new Error(
661
+ `${this.configNotFoundMessage()} Deserialize failed: ${e instanceof Error ? e.message : e}`
662
+ );
663
+ }
664
+ }
665
+ mapQuestionMarketConfig(acc) {
666
+ const accAny = acc;
667
+ return {
668
+ owner: accAny.owner,
669
+ admin: accAny.admin,
670
+ oracle: accAny.oracle,
671
+ oracleProgram: accAny.oracleProgram,
672
+ conditionalTokensProgram: accAny.conditionalTokensProgram,
673
+ questionCount: Number(accAny.questionCount.toString()),
674
+ approvedCount: Number(accAny.approvedCount.toString()),
675
+ rejectedCount: Number(accAny.rejectedCount.toString()),
676
+ presaleCount: Number(accAny.presaleCount.toString()),
677
+ whitelist: accAny.whitelist.slice(0, accAny.whitelistLen),
678
+ whitelistLen: accAny.whitelistLen,
679
+ isPaused: accAny.isPaused,
680
+ bump: accAny.bump
681
+ };
682
+ }
658
683
  /** Check if address is in question_market whitelist (can call createQuestion) */
659
684
  async isWhitelisted(address) {
660
685
  const cfg = await this.fetchConfig();
@@ -707,9 +732,10 @@ var MarketClient = class {
707
732
  * Any user creates a presale + initial buy (question-market::create_presale).
708
733
  * Reads agents_rev / company_rev from fee_config.
709
734
  *
710
- * @param feeConfig fee_management fee_config PDA (owner = feeConfigOwner)
711
- * @param currencyMint collateral token (e.g. USDC)
712
- * @param presaleIndex config.presale_count — fetch config first or pass 0 for first presale
735
+ * Presale PDA seeds (presale program): ["presale", config, presale_index]
736
+ * where presale_index must equal config.presale_count at execution time.
737
+ *
738
+ * @param presaleIndex config.presale_count — fetch config first via fetchConfig()
713
739
  */
714
740
  async createPresale(params, feeConfig, currencyMint, presaleIndex, creator = this.walletPubkey, payer = creator) {
715
741
  if (!this.programIds.presale) throw new Error("presale program ID not configured");
@@ -7210,13 +7236,6 @@ var question_market_default = {
7210
7236
  ],
7211
7237
  type: "pubkey"
7212
7238
  },
7213
- {
7214
- name: "oracle_program",
7215
- docs: [
7216
- "Oracle program ID \u2014 pinned for CPI validation in resolve_question"
7217
- ],
7218
- type: "pubkey"
7219
- },
7220
7239
  {
7221
7240
  name: "question_count",
7222
7241
  docs: [
@@ -7278,6 +7297,14 @@ var question_market_default = {
7278
7297
  ],
7279
7298
  type: "u64"
7280
7299
  },
7300
+ {
7301
+ name: "oracle_program",
7302
+ docs: [
7303
+ "Oracle program ID \u2014 pinned for CPI validation in resolve_question",
7304
+ "Placed at end of meaningful fields to avoid layout shift on old accounts."
7305
+ ],
7306
+ type: "pubkey"
7307
+ },
7281
7308
  {
7282
7309
  name: "_reserved",
7283
7310
  docs: [
@@ -18068,7 +18095,11 @@ var XMarketSDK = class {
18068
18095
  );
18069
18096
  anchor6__namespace.setProvider(this.provider);
18070
18097
  this._programIds = config.programIds;
18071
- this._marketOwner = marketOwner ?? wallet.publicKey;
18098
+ this._marketOwner = marketOwner ?? config.marketOwner ?? wallet.publicKey;
18099
+ }
18100
+ /** Question market config PDA derived from marketOwner + questionMarket program. */
18101
+ get questionMarketConfigPda() {
18102
+ return this.market.configPda;
18072
18103
  }
18073
18104
  _withAddress(idl, address) {
18074
18105
  return { ...idl, address: address.toBase58() };
@@ -18158,6 +18189,44 @@ var XMarketSDK = class {
18158
18189
  return this._dispute;
18159
18190
  }
18160
18191
  };
18192
+ var V2_PROGRAM_IDS = {
18193
+ oracle: new web3_js.PublicKey("8uNiLDZnarxyFyoCi1bE1qkBMsLs2Tpyohtdzdvjkg8j"),
18194
+ conditionalTokens: new web3_js.PublicKey("xpn3htSptTZECudoRA8WJmAEtiijxDseTqtawYysVNT"),
18195
+ questionMarket: new web3_js.PublicKey("FkpHo3zb5h2nNS5n6tWAvDwXPTXR2qqVLjDmEkMayott"),
18196
+ clobExchange: new web3_js.PublicKey("AFT8SM1Vv8g8AQTf81LoE5oLteUTyhWzWTLj7SKZjkY1"),
18197
+ feeManagement: new web3_js.PublicKey("8S6hxqbDc8kgHf4uUzq2t15PeY36QSCYEpBVvM4Fhrkm"),
18198
+ presale: new web3_js.PublicKey("CKd94vPibAMAr8R5eLv21r8PYXkgLRithipBe8GV7J6C"),
18199
+ marketOracle: new web3_js.PublicKey("Agt6beCbghi4jV9A8v9geRP5dnt2wDkJBVgy9oM33zit"),
18200
+ adminContract: new web3_js.PublicKey("2HsyCdr59W5ndeboaE9JAmhEQ46m5Gm2ZWBfYEs1tC1i"),
18201
+ referral: new web3_js.PublicKey("9kyNMtUEFR6hDeZHUTbRKH3t1EJisfSvWQKKUev7ujoC"),
18202
+ dispute: new web3_js.PublicKey("8gqHPY1WtGFGmYNbrGrPVoct1kqPL6cCaUtJ17EHSsFp")
18203
+ };
18204
+ var DEVNET_MARKET_OWNER = new web3_js.PublicKey(
18205
+ "7eGpbyRpcM7WpNKQtd6XkteNQWHbWXP7icZjKzNK2aTk"
18206
+ );
18207
+ var DEVNET_QUESTION_MARKET_CONFIG = new web3_js.PublicKey(
18208
+ "7n8y2oQYmxTp9fn2Wf2dFE1pC7ZESXYJ4yXSbYSEuRn5"
18209
+ );
18210
+ var DEVNET_USDC_MINT = new web3_js.PublicKey(
18211
+ "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU"
18212
+ );
18213
+ var MAINNET_USDC_MINT = new web3_js.PublicKey(
18214
+ "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
18215
+ );
18216
+ var DEVNET_CONFIG = {
18217
+ name: "devnet",
18218
+ rpcUrl: "https://api.devnet.solana.com",
18219
+ programIds: V2_PROGRAM_IDS,
18220
+ defaultCollateral: { mint: DEVNET_USDC_MINT, decimals: 6 },
18221
+ marketOwner: DEVNET_MARKET_OWNER,
18222
+ feeConfigOwner: DEVNET_MARKET_OWNER
18223
+ };
18224
+ var MAINNET_CONFIG = {
18225
+ name: "mainnet",
18226
+ rpcUrl: "https://api.mainnet-beta.solana.com",
18227
+ programIds: V2_PROGRAM_IDS,
18228
+ defaultCollateral: { mint: MAINNET_USDC_MINT, decimals: 6 }
18229
+ };
18161
18230
  var MAX_APPROVE_AMOUNT = new BN4__default.default("18446744073709551615");
18162
18231
  function buildCreateUserAtasTx(condition, user, payer, programIds) {
18163
18232
  const [yesMint] = PDA.yesMint(condition, programIds);
@@ -18231,11 +18300,17 @@ exports.AccountNotFoundError = AccountNotFoundError;
18231
18300
  exports.AdminClient = AdminClient;
18232
18301
  exports.ClobClient = ClobClient;
18233
18302
  exports.CtfClient = CtfClient;
18303
+ exports.DEVNET_CONFIG = DEVNET_CONFIG;
18304
+ exports.DEVNET_MARKET_OWNER = DEVNET_MARKET_OWNER;
18305
+ exports.DEVNET_QUESTION_MARKET_CONFIG = DEVNET_QUESTION_MARKET_CONFIG;
18306
+ exports.DEVNET_USDC_MINT = DEVNET_USDC_MINT;
18234
18307
  exports.DisputeClient = DisputeClient;
18235
18308
  exports.FEE_DENOMINATOR = FEE_DENOMINATOR;
18236
18309
  exports.FeeManagementClient = FeeManagementClient;
18237
18310
  exports.IX_SYSVAR = IX_SYSVAR;
18238
18311
  exports.InvalidParamError = InvalidParamError;
18312
+ exports.MAINNET_CONFIG = MAINNET_CONFIG;
18313
+ exports.MAINNET_USDC_MINT = MAINNET_USDC_MINT;
18239
18314
  exports.MAX_APPROVE_AMOUNT = MAX_APPROVE_AMOUNT;
18240
18315
  exports.MarketClient = MarketClient;
18241
18316
  exports.MarketOracleClient = MarketOracleClient;
@@ -18246,6 +18321,7 @@ exports.QuestionStatus = QuestionStatus;
18246
18321
  exports.ReferralClient = ReferralClient;
18247
18322
  exports.SEEDS = SEEDS;
18248
18323
  exports.UnauthorizedError = UnauthorizedError;
18324
+ exports.V2_PROGRAM_IDS = V2_PROGRAM_IDS;
18249
18325
  exports.XMarketError = XMarketError;
18250
18326
  exports.XMarketSDK = XMarketSDK;
18251
18327
  exports.buildApproveAllOutcomeTokensTx = buildApproveAllOutcomeTokensTx;