@theliem/xmarket-sdk 3.19.0 → 3.21.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
@@ -1,6 +1,6 @@
1
1
  import * as anchor from '@coral-xyz/anchor';
2
2
  import * as _solana_web3_js from '@solana/web3.js';
3
- import { PublicKey, Transaction, Keypair, TransactionInstruction, AddressLookupTableAccount, VersionedTransaction } from '@solana/web3.js';
3
+ import { PublicKey, Transaction, TransactionInstruction, Keypair, AddressLookupTableAccount, VersionedTransaction } from '@solana/web3.js';
4
4
  import BN from 'bn.js';
5
5
 
6
6
  interface ProgramIds {
@@ -281,6 +281,11 @@ declare class HookClient {
281
281
  configPda(): PublicKey;
282
282
  /** One-time setup. Caller becomes owner. */
283
283
  initialize(initialWhitelist: PublicKey[]): Promise<TxResult>;
284
+ /**
285
+ * Returns initializeExtraAccountMetaList instruction if the account doesn't exist yet, else null.
286
+ * Used by ClobClient to auto-prepend when extraAccountMetaList is missing.
287
+ */
288
+ buildInitHookIxIfNeeded(mint: PublicKey, payer: PublicKey): Promise<TransactionInstruction | null>;
284
289
  /**
285
290
  * Register extra account metas for a Token-2022 YES/NO mint.
286
291
  * Must be called once per mint after CTF creates it.
@@ -421,6 +426,8 @@ declare class MarketClient {
421
426
  readonly configPda: PublicKey;
422
427
  /** Injected by XMarketSDK after construction — enables fetchQuestionBalances. */
423
428
  ctfClient?: CtfClient;
429
+ /** Injected by XMarketSDK — fee config owner (= market owner) for MarketFeeOverride PDA derivation */
430
+ feeConfigOwner?: PublicKey;
424
431
  constructor(program: anchor.Program, provider: anchor.AnchorProvider, programIds: ProgramIds, ownerPubkey: PublicKey);
425
432
  get walletPubkey(): PublicKey;
426
433
  initialize(admin: PublicKey, oracle: PublicKey, owner?: PublicKey): Promise<Transaction>;
@@ -450,6 +457,7 @@ declare class MarketClient {
450
457
  removeFromWhitelist(address: PublicKey, authority?: PublicKey, payer?: PublicKey): Promise<Transaction>;
451
458
  growConfig(owner?: PublicKey, payer?: PublicKey): Promise<Transaction>;
452
459
  restoreConfig(snapshot: Buffer, owner?: PublicKey, payer?: PublicKey): Promise<Transaction>;
460
+ bumpPresaleCount(count: number, authority: PublicKey): Promise<Transaction>;
453
461
  fetchConfig(): Promise<QuestionMarketConfig | null>;
454
462
  fetchQuestion(questionPda: PublicKey): Promise<Question | null>;
455
463
  questionPda(questionId: Uint8Array): PublicKey;
@@ -626,10 +634,17 @@ declare class ClobClient {
626
634
  /** Injected by XMarketSDK after construction — enables auto fee distribution */
627
635
  feeClient?: FeeManagementClient;
628
636
  feeConfigOwner?: PublicKey;
637
+ /** Injected by XMarketSDK — enables auto-derive of marketOracleVault for presale markets */
638
+ ctfClient?: CtfClient;
639
+ qmConfigPda?: PublicKey;
640
+ /** Injected by XMarketSDK — enables auto-init extraAccountMetaList if missing */
641
+ hookClient?: HookClient;
629
642
  /** Cached company_address from fee_config to avoid repeated RPC calls */
630
643
  private _companyAddress?;
631
644
  /** Cached referral_vault from fee_config */
632
645
  private _referralVault?;
646
+ /** Cache: conditionPda.toBase58() → marketOracleVault ATA */
647
+ private _marketOracleVaultCache;
633
648
  /** ALT cache: condition.toBase58() → loaded ALT account */
634
649
  private _altCache;
635
650
  constructor(program: anchor.Program, provider: anchor.AnchorProvider, programIds: ProgramIds, networkConfig: {
@@ -639,6 +654,12 @@ declare class ClobClient {
639
654
  });
640
655
  private companyAddress;
641
656
  private referralVault;
657
+ /**
658
+ * Derive marketOracleVault ATA for a condition, cached per condition.
659
+ * Works for presale markets (market_oracle initialized by approvePresale).
660
+ * Returns undefined if ctfClient/qmConfigPda not injected or marketOracle not configured.
661
+ */
662
+ private getMarketOracleVault;
642
663
  get walletPubkey(): PublicKey;
643
664
  /**
644
665
  * Get or create an ALT for a condition.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as anchor from '@coral-xyz/anchor';
2
2
  import * as _solana_web3_js from '@solana/web3.js';
3
- import { PublicKey, Transaction, Keypair, TransactionInstruction, AddressLookupTableAccount, VersionedTransaction } from '@solana/web3.js';
3
+ import { PublicKey, Transaction, TransactionInstruction, Keypair, AddressLookupTableAccount, VersionedTransaction } from '@solana/web3.js';
4
4
  import BN from 'bn.js';
5
5
 
6
6
  interface ProgramIds {
@@ -281,6 +281,11 @@ declare class HookClient {
281
281
  configPda(): PublicKey;
282
282
  /** One-time setup. Caller becomes owner. */
283
283
  initialize(initialWhitelist: PublicKey[]): Promise<TxResult>;
284
+ /**
285
+ * Returns initializeExtraAccountMetaList instruction if the account doesn't exist yet, else null.
286
+ * Used by ClobClient to auto-prepend when extraAccountMetaList is missing.
287
+ */
288
+ buildInitHookIxIfNeeded(mint: PublicKey, payer: PublicKey): Promise<TransactionInstruction | null>;
284
289
  /**
285
290
  * Register extra account metas for a Token-2022 YES/NO mint.
286
291
  * Must be called once per mint after CTF creates it.
@@ -421,6 +426,8 @@ declare class MarketClient {
421
426
  readonly configPda: PublicKey;
422
427
  /** Injected by XMarketSDK after construction — enables fetchQuestionBalances. */
423
428
  ctfClient?: CtfClient;
429
+ /** Injected by XMarketSDK — fee config owner (= market owner) for MarketFeeOverride PDA derivation */
430
+ feeConfigOwner?: PublicKey;
424
431
  constructor(program: anchor.Program, provider: anchor.AnchorProvider, programIds: ProgramIds, ownerPubkey: PublicKey);
425
432
  get walletPubkey(): PublicKey;
426
433
  initialize(admin: PublicKey, oracle: PublicKey, owner?: PublicKey): Promise<Transaction>;
@@ -450,6 +457,7 @@ declare class MarketClient {
450
457
  removeFromWhitelist(address: PublicKey, authority?: PublicKey, payer?: PublicKey): Promise<Transaction>;
451
458
  growConfig(owner?: PublicKey, payer?: PublicKey): Promise<Transaction>;
452
459
  restoreConfig(snapshot: Buffer, owner?: PublicKey, payer?: PublicKey): Promise<Transaction>;
460
+ bumpPresaleCount(count: number, authority: PublicKey): Promise<Transaction>;
453
461
  fetchConfig(): Promise<QuestionMarketConfig | null>;
454
462
  fetchQuestion(questionPda: PublicKey): Promise<Question | null>;
455
463
  questionPda(questionId: Uint8Array): PublicKey;
@@ -626,10 +634,17 @@ declare class ClobClient {
626
634
  /** Injected by XMarketSDK after construction — enables auto fee distribution */
627
635
  feeClient?: FeeManagementClient;
628
636
  feeConfigOwner?: PublicKey;
637
+ /** Injected by XMarketSDK — enables auto-derive of marketOracleVault for presale markets */
638
+ ctfClient?: CtfClient;
639
+ qmConfigPda?: PublicKey;
640
+ /** Injected by XMarketSDK — enables auto-init extraAccountMetaList if missing */
641
+ hookClient?: HookClient;
629
642
  /** Cached company_address from fee_config to avoid repeated RPC calls */
630
643
  private _companyAddress?;
631
644
  /** Cached referral_vault from fee_config */
632
645
  private _referralVault?;
646
+ /** Cache: conditionPda.toBase58() → marketOracleVault ATA */
647
+ private _marketOracleVaultCache;
633
648
  /** ALT cache: condition.toBase58() → loaded ALT account */
634
649
  private _altCache;
635
650
  constructor(program: anchor.Program, provider: anchor.AnchorProvider, programIds: ProgramIds, networkConfig: {
@@ -639,6 +654,12 @@ declare class ClobClient {
639
654
  });
640
655
  private companyAddress;
641
656
  private referralVault;
657
+ /**
658
+ * Derive marketOracleVault ATA for a condition, cached per condition.
659
+ * Works for presale markets (market_oracle initialized by approvePresale).
660
+ * Returns undefined if ctfClient/qmConfigPda not injected or marketOracle not configured.
661
+ */
662
+ private getMarketOracleVault;
642
663
  get walletPubkey(): PublicKey;
643
664
  /**
644
665
  * Get or create an ALT for a condition.
package/dist/index.js CHANGED
@@ -380,7 +380,7 @@ var OracleClient = class {
380
380
  owner: acc.owner,
381
381
  admin: acc.admin,
382
382
  questionCount: acc.questionCount.toNumber(),
383
- whitelist: acc.whitelist,
383
+ whitelist: acc.whitelist.slice(0, acc.whitelistLen),
384
384
  whitelistLen: acc.whitelistLen,
385
385
  isPaused: acc.isPaused,
386
386
  bump: acc.bump
@@ -433,6 +433,23 @@ var HookClient = class {
433
433
  }).rpc();
434
434
  return { signature: sig };
435
435
  }
436
+ /**
437
+ * Returns initializeExtraAccountMetaList instruction if the account doesn't exist yet, else null.
438
+ * Used by ClobClient to auto-prepend when extraAccountMetaList is missing.
439
+ */
440
+ async buildInitHookIxIfNeeded(mint, payer) {
441
+ const [extraAccountMetaList] = PDA.extraAccountMetaList(mint, this.programIds);
442
+ const existing = await this.provider.connection.getAccountInfo(extraAccountMetaList);
443
+ if (existing) return null;
444
+ return this.program.methods.initializeExtraAccountMetaList().accounts({
445
+ payer,
446
+ extraAccountMetaList,
447
+ mint,
448
+ hookConfig: this.configPda(),
449
+ tokenProgram: splToken.TOKEN_2022_PROGRAM_ID,
450
+ systemProgram: web3_js.SystemProgram.programId
451
+ }).instruction();
452
+ }
436
453
  /**
437
454
  * Register extra account metas for a Token-2022 YES/NO mint.
438
455
  * Must be called once per mint after CTF creates it.
@@ -507,7 +524,7 @@ var HookClient = class {
507
524
  const acc = await this.program.account.hookConfig.fetch(this.configPda());
508
525
  return {
509
526
  owner: acc.owner,
510
- whitelist: acc.whitelist,
527
+ whitelist: acc.whitelist.slice(0, acc.whitelistLen),
511
528
  whitelistLen: acc.whitelistLen,
512
529
  isFrozen: acc.isFrozen,
513
530
  bump: acc.bump
@@ -597,7 +614,10 @@ var MarketClient = class {
597
614
  const [mintAuthority] = PDA.mintAuthority(conditionPda, this.programIds);
598
615
  const [collateralVault] = PDA.collateralVault(params.collateralMint, this.programIds);
599
616
  if (!this.programIds.feeManagement) throw new Error("feeManagement program ID not configured");
617
+ if (!this.feeConfigOwner) throw new Error("feeConfigOwner not configured");
600
618
  const [questionFeePda] = PDA.questionFee(conditionPda, this.programIds);
619
+ const [feeConfigPda] = PDA.feeConfig(this.feeConfigOwner, this.programIds);
620
+ const [marketFeeOverride] = PDA.marketFeeOverride(conditionPda, this.programIds);
601
621
  const tx = await this.program.methods.createQuestionAdmin({
602
622
  questionId: Array.from(questionId),
603
623
  contentHash: Array.from(contentHash),
@@ -618,6 +638,8 @@ var MarketClient = class {
618
638
  collateralVault,
619
639
  conditionalTokensProgram: this.programIds.conditionalTokens,
620
640
  questionFee: questionFeePda,
641
+ feeConfig: feeConfigPda,
642
+ marketFeeOverride,
621
643
  feeManagementProgram: this.programIds.feeManagement,
622
644
  tokenProgram: splToken.TOKEN_2022_PROGRAM_ID,
623
645
  systemProgram: web3_js.SystemProgram.programId,
@@ -689,6 +711,9 @@ var MarketClient = class {
689
711
  systemProgram: web3_js.SystemProgram.programId
690
712
  }).transaction();
691
713
  }
714
+ async bumpPresaleCount(count, authority) {
715
+ return this.program.methods.bumpPresaleCount(new anchor5__namespace.BN(count)).accounts({ authority, config: this.configPda }).transaction();
716
+ }
692
717
  // ─── Queries ─────────────────────────────────────────────────────────────────
693
718
  async fetchConfig() {
694
719
  try {
@@ -702,7 +727,7 @@ var MarketClient = class {
702
727
  approvedCount: acc.approvedCount.toNumber(),
703
728
  rejectedCount: acc.rejectedCount.toNumber(),
704
729
  presaleCount: acc.presaleCount.toNumber(),
705
- whitelist: acc.whitelist,
730
+ whitelist: acc.whitelist.slice(0, acc.whitelistLen),
706
731
  whitelistLen: acc.whitelistLen,
707
732
  isPaused: acc.isPaused,
708
733
  bump: acc.bump
@@ -855,6 +880,9 @@ var MarketClient = class {
855
880
  const [adminConfig] = PDA.adminConfig(adminOwner, this.programIds);
856
881
  const adminVault = splToken.getAssociatedTokenAddressSync(currencyMint, adminConfig, true);
857
882
  const [claimRecord] = PDA.claimRecord(conditionPda.toBytes(), this.programIds);
883
+ const feeConfigOwner = this.feeConfigOwner ?? adminOwner;
884
+ const [feeConfigPda] = PDA.feeConfig(feeConfigOwner, this.programIds);
885
+ const [marketFeeOverride] = PDA.marketFeeOverride(conditionPda, this.programIds);
858
886
  const builder = this.program.methods.approvePresale({
859
887
  contentHash: Array.from(contentHash),
860
888
  hookProgram,
@@ -883,6 +911,8 @@ var MarketClient = class {
883
911
  adminConfig,
884
912
  claimRecord,
885
913
  questionFee: questionFeePda,
914
+ feeConfig: feeConfigPda,
915
+ marketFeeOverride,
886
916
  feeManagementProgram: this.programIds.feeManagement,
887
917
  conditionalTokensProgram: this.programIds.conditionalTokens,
888
918
  presaleProgram: this.programIds.presale,
@@ -1546,6 +1576,8 @@ function _detectMatchType(a, b) {
1546
1576
  // src/programs/clob.ts
1547
1577
  var ClobClient = class {
1548
1578
  constructor(program, provider, programIds, networkConfig) {
1579
+ /** Cache: conditionPda.toBase58() → marketOracleVault ATA */
1580
+ this._marketOracleVaultCache = /* @__PURE__ */ new Map();
1549
1581
  /** ALT cache: condition.toBase58() → loaded ALT account */
1550
1582
  this._altCache = /* @__PURE__ */ new Map();
1551
1583
  this.program = program;
@@ -1568,6 +1600,24 @@ var ClobClient = class {
1568
1600
  await this.companyAddress();
1569
1601
  return this._referralVault;
1570
1602
  }
1603
+ /**
1604
+ * Derive marketOracleVault ATA for a condition, cached per condition.
1605
+ * Works for presale markets (market_oracle initialized by approvePresale).
1606
+ * Returns undefined if ctfClient/qmConfigPda not injected or marketOracle not configured.
1607
+ */
1608
+ async getMarketOracleVault(condition, collateralMint) {
1609
+ if (!this.ctfClient || !this.qmConfigPda || !this.programIds.marketOracle) return void 0;
1610
+ const key = condition.toBase58();
1611
+ const cached = this._marketOracleVaultCache.get(key);
1612
+ if (cached) return cached;
1613
+ const cond = await this.ctfClient.fetchCondition(condition);
1614
+ if (!cond) return void 0;
1615
+ const [questionPda] = PDA.question(this.qmConfigPda, cond.questionId, this.programIds);
1616
+ const [marketOraclePda] = PDA.marketOraclePda(questionPda, this.programIds);
1617
+ const vault = splToken.getAssociatedTokenAddressSync(collateralMint, marketOraclePda, true);
1618
+ this._marketOracleVaultCache.set(key, vault);
1619
+ return vault;
1620
+ }
1571
1621
  get walletPubkey() {
1572
1622
  return this.provider.wallet.publicKey;
1573
1623
  }
@@ -1667,11 +1717,11 @@ var ClobClient = class {
1667
1717
  if (companyAddr) {
1668
1718
  addresses.push(splToken.getAssociatedTokenAddressSync(collateralMint, companyAddr));
1669
1719
  }
1670
- addresses.push(payer);
1720
+ const oracleVaultForAlt = await this.getMarketOracleVault(condition, collateralMint) ?? payer;
1721
+ addresses.push(oracleVaultForAlt);
1671
1722
  if (refVault) {
1672
1723
  addresses.push(refVault);
1673
1724
  }
1674
- addresses.push(splToken.TOKEN_PROGRAM_ID);
1675
1725
  }
1676
1726
  const slot = await connection.getSlot("finalized");
1677
1727
  const [createIx, altAddress] = web3_js.AddressLookupTableProgram.createLookupTable({
@@ -1934,7 +1984,7 @@ ${logs.join("\n")}`);
1934
1984
  const feeOverridePda = PDA.marketFeeOverride(condition, this.programIds)[0];
1935
1985
  const feeOverrideExists = await this.provider.connection.getAccountInfo(feeOverridePda);
1936
1986
  if (feeOverrideExists) {
1937
- const oracleVault = opts?.marketOracleVault ?? this.walletPubkey;
1987
+ const oracleVault = opts?.marketOracleVault ?? await this.getMarketOracleVault(condition, collateralMint) ?? this.walletPubkey;
1938
1988
  feeAccounts = [
1939
1989
  { pubkey: this.programIds.feeManagement, isSigner: false, isWritable: false },
1940
1990
  { pubkey: PDA.feeConfig(this.feeConfigOwner, this.programIds)[0], isSigner: false, isWritable: false },
@@ -2190,15 +2240,14 @@ ${logs.join("\n")}`);
2190
2240
  const feeOverridePda = PDA.marketFeeOverride(condition, this.programIds)[0];
2191
2241
  const feeOverrideExists = await this.provider.connection.getAccountInfo(feeOverridePda);
2192
2242
  if (feeOverrideExists) {
2193
- const oracleVault = opts?.marketOracleVault ?? payer;
2243
+ const oracleVault = opts?.marketOracleVault ?? await this.getMarketOracleVault(condition, collateralMint) ?? payer;
2194
2244
  remainingAccounts.push(
2195
2245
  { pubkey: this.programIds.feeManagement, isSigner: false, isWritable: false },
2196
2246
  { pubkey: PDA.feeConfig(this.feeConfigOwner, this.programIds)[0], isSigner: false, isWritable: false },
2197
2247
  { pubkey: feeOverridePda, isSigner: false, isWritable: false },
2198
2248
  { pubkey: splToken.getAssociatedTokenAddressSync(collateralMint, companyAddr), isSigner: false, isWritable: true },
2199
2249
  { pubkey: oracleVault, isSigner: false, isWritable: true },
2200
- { pubkey: refVault, isSigner: false, isWritable: true },
2201
- { pubkey: splToken.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false }
2250
+ { pubkey: refVault, isSigner: false, isWritable: true }
2202
2251
  );
2203
2252
  }
2204
2253
  }
@@ -2399,6 +2448,18 @@ ${logs.join("\n")}`);
2399
2448
  const m0 = makers[0].order;
2400
2449
  const SIDE_BUY = 0;
2401
2450
  const SIDE_SELL = 1;
2451
+ const hookInitIxs = [];
2452
+ if (this.hookClient) {
2453
+ const condition0 = t.condition;
2454
+ const [ym] = PDA.yesMint(condition0, this.programIds);
2455
+ const [nm] = PDA.noMint(condition0, this.programIds);
2456
+ const [yIx, nIx] = await Promise.all([
2457
+ this.hookClient.buildInitHookIxIfNeeded(ym, payer),
2458
+ this.hookClient.buildInitHookIxIfNeeded(nm, payer)
2459
+ ]);
2460
+ if (yIx) hookInitIxs.push(yIx);
2461
+ if (nIx) hookInitIxs.push(nIx);
2462
+ }
2402
2463
  if (t.tokenId === m0.tokenId) {
2403
2464
  let buySignedOrder, sellCandidates;
2404
2465
  if (t.side === SIDE_BUY && makers.every((m) => m.order.side === SIDE_SELL)) {
@@ -2418,7 +2479,7 @@ ${logs.join("\n")}`);
2418
2479
  opts,
2419
2480
  false
2420
2481
  );
2421
- return this._buildUnsignedVtx(ixs3, alt, payer);
2482
+ return this._buildUnsignedVtx([...hookInitIxs, ...ixs3], alt, payer);
2422
2483
  } else {
2423
2484
  throw new InvalidParamError("COMPLEMENTARY requires one BUY and one or more SELLs on same tokenId");
2424
2485
  }
@@ -2434,7 +2495,7 @@ ${logs.join("\n")}`);
2434
2495
  operator,
2435
2496
  opts
2436
2497
  );
2437
- return this._buildUnsignedVtx(ixs2, alt, payer);
2498
+ return this._buildUnsignedVtx([...hookInitIxs, ...ixs2], alt, payer);
2438
2499
  }
2439
2500
  const allBuy = t.side === SIDE_BUY && makers.every((m) => m.order.side === SIDE_BUY);
2440
2501
  const allSell = t.side === SIDE_SELL && makers.every((m) => m.order.side === SIDE_SELL);
@@ -2455,7 +2516,7 @@ ${logs.join("\n")}`);
2455
2516
  ]);
2456
2517
  await this._ensureClobOutcomeAtas(yesMint, noMint, clobConfig, clobYesAta, clobNoAta);
2457
2518
  const ix = allBuy ? await this._buildMintIx(taker, makers, collateralMint, operator, payer) : await this._buildMergeIx(taker, makers, collateralMint, operator, payer, opts);
2458
- return this._buildUnsignedVtx([ix], alt, payer);
2519
+ return this._buildUnsignedVtx([...hookInitIxs, ix], alt, payer);
2459
2520
  }
2460
2521
  await Promise.all([
2461
2522
  this.registerOrderIfNeeded(taker),
@@ -2467,7 +2528,7 @@ ${logs.join("\n")}`);
2467
2528
  const ix = allBuy ? await this._buildMintIx(yesMaker, [taker], collateralMint, operator, payer) : await this._buildMergeIx(yesMaker, [taker], collateralMint, operator, payer, opts);
2468
2529
  ixs.push(ix);
2469
2530
  }
2470
- return this._buildUnsignedVtx(ixs, alt, payer);
2531
+ return this._buildUnsignedVtx([...hookInitIxs, ...ixs], alt, payer);
2471
2532
  }
2472
2533
  // ─── batchCollectRedeemEarly ─────────────────────────────────────────────────
2473
2534
  /**
@@ -2524,7 +2585,7 @@ ${logs.join("\n")}`);
2524
2585
  const feeOverridePda = PDA.marketFeeOverride(condition, this.programIds)[0];
2525
2586
  const feeOverrideExists = await this.provider.connection.getAccountInfo(feeOverridePda);
2526
2587
  if (feeOverrideExists) {
2527
- const oracleVault = opts?.marketOracleVault ?? payer;
2588
+ const oracleVault = opts?.marketOracleVault ?? await this.getMarketOracleVault(condition, collateralMint) ?? payer;
2528
2589
  feeAccounts = [
2529
2590
  { pubkey: this.programIds.feeManagement, isSigner: false, isWritable: false },
2530
2591
  { pubkey: PDA.feeConfig(this.feeConfigOwner, this.programIds)[0], isSigner: false, isWritable: false },
@@ -2537,10 +2598,16 @@ ${logs.join("\n")}`);
2537
2598
  }
2538
2599
  }
2539
2600
  await this._ensureClobOutcomeAtas(yesMint, noMint, clobConfig, clobYesAta, clobNoAta);
2601
+ const hookInitIxs = [];
2602
+ if (this.hookClient) {
2603
+ const ix = await this.hookClient.buildInitHookIxIfNeeded(outcomeMint, payer);
2604
+ if (ix) hookInitIxs.push(ix);
2605
+ }
2540
2606
  const ed25519Ix = buildBatchedCollectFeeEd25519Instruction(signedOrders);
2607
+ const ed25519IxIndex = 2 + hookInitIxs.length;
2541
2608
  const collectIx = await this.program.methods.batchCollectRedeemEarly(
2542
- 2,
2543
- // ix_index: Ed25519 ix is ix[2] (cuLimit=0, heapFrame=1, ed25519=2)
2609
+ ed25519IxIndex,
2610
+ // ix_index: adjusted for any prepended hook init ixs
2544
2611
  signedOrders.length,
2545
2612
  outcomeIndex
2546
2613
  ).accounts({
@@ -2564,7 +2631,7 @@ ${logs.join("\n")}`);
2564
2631
  systemProgram: web3_js.SystemProgram.programId
2565
2632
  }).remainingAccounts([...userAccounts, ...hookAccounts, ...feeAccounts]).instruction();
2566
2633
  const cachedAlt = this._altCache.get(condition.toBase58());
2567
- return this._buildUnsignedVtx([ed25519Ix, collectIx], cachedAlt, payer);
2634
+ return this._buildUnsignedVtx([...hookInitIxs, ed25519Ix, collectIx], cachedAlt, payer);
2568
2635
  }
2569
2636
  // ─── Queries ─────────────────────────────────────────────────────────────────
2570
2637
  async fetchConfig() {
@@ -4662,6 +4729,20 @@ var question_market_default = {
4662
4729
  ],
4663
4730
  writable: true
4664
4731
  },
4732
+ {
4733
+ name: "fee_config",
4734
+ docs: [
4735
+ "FeeConfig PDA \u2014 passed to set_market_fee_override CPI."
4736
+ ],
4737
+ writable: true
4738
+ },
4739
+ {
4740
+ name: "market_fee_override",
4741
+ docs: [
4742
+ "MarketFeeOverride PDA \u2014 auto-init with is_admin=false and fee_config defaults."
4743
+ ],
4744
+ writable: true
4745
+ },
4665
4746
  {
4666
4747
  name: "fee_management_program",
4667
4748
  address: "DuYyXguB5PVSKg6E2p4XPrrXZSCJnuBhoGpkGCBN5bBb"
@@ -4767,6 +4848,55 @@ var question_market_default = {
4767
4848
  ],
4768
4849
  args: []
4769
4850
  },
4851
+ {
4852
+ name: "bump_presale_count",
4853
+ discriminator: [
4854
+ 42,
4855
+ 84,
4856
+ 98,
4857
+ 9,
4858
+ 208,
4859
+ 168,
4860
+ 38,
4861
+ 55
4862
+ ],
4863
+ accounts: [
4864
+ {
4865
+ name: "authority",
4866
+ signer: true
4867
+ },
4868
+ {
4869
+ name: "config",
4870
+ writable: true,
4871
+ pda: {
4872
+ seeds: [
4873
+ {
4874
+ kind: "const",
4875
+ value: [
4876
+ 99,
4877
+ 111,
4878
+ 110,
4879
+ 102,
4880
+ 105,
4881
+ 103
4882
+ ]
4883
+ },
4884
+ {
4885
+ kind: "account",
4886
+ path: "config.owner",
4887
+ account: "QuestionMarketConfig"
4888
+ }
4889
+ ]
4890
+ }
4891
+ }
4892
+ ],
4893
+ args: [
4894
+ {
4895
+ name: "count",
4896
+ type: "u64"
4897
+ }
4898
+ ]
4899
+ },
4770
4900
  {
4771
4901
  name: "collect_presale_revenue",
4772
4902
  discriminator: [
@@ -5323,39 +5453,23 @@ var question_market_default = {
5323
5453
  {
5324
5454
  name: "question_fee",
5325
5455
  docs: [
5326
- "QuestionFee PDA \u2014 initialized with default fees via CPI to fee-management.",
5327
- "Seed uses condition.key() bytes (consistent with existing set_question_fee SDK convention)."
5456
+ "QuestionFee PDA \u2014 initialized with default fees via CPI to fee-management."
5328
5457
  ],
5329
- writable: true,
5330
- pda: {
5331
- seeds: [
5332
- {
5333
- kind: "const",
5334
- value: [
5335
- 113,
5336
- 117,
5337
- 101,
5338
- 115,
5339
- 116,
5340
- 105,
5341
- 111,
5342
- 110,
5343
- 95,
5344
- 102,
5345
- 101,
5346
- 101
5347
- ]
5348
- },
5349
- {
5350
- kind: "account",
5351
- path: "condition"
5352
- }
5353
- ],
5354
- program: {
5355
- kind: "account",
5356
- path: "fee_management_program"
5357
- }
5358
- }
5458
+ writable: true
5459
+ },
5460
+ {
5461
+ name: "fee_config",
5462
+ docs: [
5463
+ "FeeConfig PDA \u2014 passed to set_market_fee_override CPI as authority validator."
5464
+ ],
5465
+ writable: true
5466
+ },
5467
+ {
5468
+ name: "market_fee_override",
5469
+ docs: [
5470
+ "MarketFeeOverride PDA \u2014 init'd by set_market_fee_override CPI (is_admin=true)."
5471
+ ],
5472
+ writable: true
5359
5473
  },
5360
5474
  {
5361
5475
  name: "fee_management_program",
@@ -6921,7 +7035,7 @@ var question_market_default = {
6921
7035
  type: {
6922
7036
  array: [
6923
7037
  "pubkey",
6924
- 30
7038
+ 20
6925
7039
  ]
6926
7040
  }
6927
7041
  },
@@ -6961,7 +7075,7 @@ var question_market_default = {
6961
7075
  type: {
6962
7076
  array: [
6963
7077
  "u8",
6964
- 120
7078
+ 440
6965
7079
  ]
6966
7080
  }
6967
7081
  }
@@ -16312,6 +16426,7 @@ var XMarketSDK = class {
16312
16426
  const program = new anchor5__namespace.Program(this._withAddress(question_market_default, this._programIds.questionMarket), this.provider);
16313
16427
  this._market = new MarketClient(program, this.provider, this._programIds, this._marketOwner);
16314
16428
  this._market.ctfClient = this.ctf;
16429
+ this._market.feeConfigOwner = this.networkConfig.feeConfigOwner ?? this._marketOwner;
16315
16430
  }
16316
16431
  return this._market;
16317
16432
  }
@@ -16330,6 +16445,9 @@ var XMarketSDK = class {
16330
16445
  this._clob.feeConfigOwner = this.networkConfig.feeConfigOwner;
16331
16446
  this._clob.feeClient = this.fee;
16332
16447
  }
16448
+ this._clob.ctfClient = this.ctf;
16449
+ this._clob.qmConfigPda = this.market.configPda;
16450
+ this._clob.hookClient = this.hook;
16333
16451
  }
16334
16452
  return this._clob;
16335
16453
  }