@theliem/xmarket-sdk 3.29.0 → 3.29.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,17 +1,13 @@
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 {
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;
10
+ hook: PublicKey;
15
11
  clobExchange: PublicKey;
16
12
  feeManagement?: PublicKey;
17
13
  presale?: PublicKey;
@@ -301,7 +297,53 @@ declare class OracleClient {
301
297
  fetchQuestionResult(questionId: Uint8Array, ownerPubkey?: PublicKey): Promise<QuestionResult | null>;
302
298
  }
303
299
 
304
- declare class CtfClientV2 {
300
+ declare class HookClient {
301
+ private readonly program;
302
+ private readonly provider;
303
+ private readonly programIds;
304
+ constructor(program: anchor.Program, provider: anchor.AnchorProvider, programIds: ProgramIds);
305
+ get walletPubkey(): PublicKey;
306
+ configPda(): PublicKey;
307
+ /** One-time setup. Caller becomes owner. */
308
+ initialize(initialWhitelist: PublicKey[]): Promise<TxResult>;
309
+ /**
310
+ * Returns initializeExtraAccountMetaList instruction if the account doesn't exist yet, else null.
311
+ * Used by ClobClient to auto-prepend when extraAccountMetaList is missing.
312
+ */
313
+ buildInitHookIxIfNeeded(mint: PublicKey, payer: PublicKey): Promise<TransactionInstruction | null>;
314
+ /**
315
+ * Register extra account metas for a Token-2022 YES/NO mint.
316
+ * Must be called once per mint after CTF creates it.
317
+ */
318
+ initializeExtraAccountMetaList(mint: PublicKey): Promise<TxResult>;
319
+ /** Owner adds a program to the transfer whitelist. */
320
+ addToWhitelist(program: PublicKey): Promise<TxResult>;
321
+ /** Owner removes a program from the transfer whitelist. */
322
+ removeFromWhitelist(program: PublicKey): Promise<TxResult>;
323
+ /** Permanently freeze the whitelist — no further changes allowed. */
324
+ freezeWhitelist(): Promise<TxResult>;
325
+ /**
326
+ * SPL Transfer-Hook `execute` — invoked automatically by Token-2022 on every
327
+ * YES/NO token transfer. Validates the destination against the whitelist.
328
+ *
329
+ * Calling this directly is useful for:
330
+ * - Off-chain simulation ("would this transfer be allowed?")
331
+ * - Integration tests that verify whitelist enforcement
332
+ *
333
+ * Token-2022 calls this automatically; you normally don't call it manually.
334
+ *
335
+ * @param sourceToken - Source token account (tokens leaving)
336
+ * @param mint - The YES/NO Token-2022 mint
337
+ * @param destinationToken - Destination token account (tokens arriving)
338
+ * @param owner - Authority that authorized the transfer
339
+ * @param amount - Token amount being transferred
340
+ */
341
+ execute(sourceToken: PublicKey, mint: PublicKey, destinationToken: PublicKey, owner: PublicKey, amount: anchor.BN): Promise<TxResult>;
342
+ fetchConfig(): Promise<HookConfig | null>;
343
+ isWhitelisted(program: PublicKey): Promise<boolean>;
344
+ }
345
+
346
+ declare class CtfClient {
305
347
  private readonly program;
306
348
  private readonly provider;
307
349
  private readonly programIds;
@@ -309,12 +351,11 @@ declare class CtfClientV2 {
309
351
  get walletPubkey(): PublicKey;
310
352
  /**
311
353
  * Create a Condition directly (bypasses QuestionMarket).
312
- * V2: uses plain SPL TOKEN_PROGRAM_ID for YES/NO mints — no hook program.
313
354
  * oracle is UncheckedAccount — set it to any pubkey (e.g. user wallet)
314
355
  * so that wallet can later sign reportPayouts.
315
356
  * payer covers rent for condition + mints.
316
357
  */
317
- prepareCondition(questionId: Uint8Array, oracle: PublicKey, collateralMint: PublicKey, authorizedClob: PublicKey, payer?: PublicKey, signers?: Keypair[]): Promise<{
358
+ prepareCondition(questionId: Uint8Array, oracle: PublicKey, collateralMint: PublicKey, hookProgram: PublicKey, authorizedClob: PublicKey, payer?: PublicKey, signers?: Keypair[]): Promise<{
318
359
  signature: string;
319
360
  conditionPda: PublicKey;
320
361
  yesMint: PublicKey;
@@ -338,20 +379,17 @@ declare class CtfClientV2 {
338
379
  initPosition(condition: PublicKey, outcomeIndex: number, user?: PublicKey): Promise<TxResult>;
339
380
  /**
340
381
  * Split `amount` collateral into equal YES + NO tokens.
341
- * V2: uses TOKEN_PROGRAM_ID for YES/NO mints (plain SPL, no Token-2022).
342
382
  * ATAs created automatically via `init_if_needed`.
343
383
  */
344
384
  splitPosition(condition: PublicKey, collateralMint: PublicKey, amount: anchor.BN, user?: PublicKey, payer?: PublicKey): Promise<Transaction>;
345
385
  /**
346
386
  * Merge `amount` YES + NO tokens back into collateral.
347
- * V2: uses TOKEN_PROGRAM_ID for YES/NO mints (plain SPL, no Token-2022).
348
387
  * Both token balances must be ≥ amount.
349
388
  */
350
389
  mergePosition(condition: PublicKey, collateralMint: PublicKey, amount: anchor.BN, user?: PublicKey, payer?: PublicKey): Promise<Transaction>;
351
390
  /**
352
391
  * After condition resolves: burn outcome tokens proportional to payout
353
392
  * and receive USDC. Works for winning, losing, or both positions.
354
- * V2: uses TOKEN_PROGRAM_ID for YES/NO mints (plain SPL, no Token-2022).
355
393
  */
356
394
  redeemPositions(condition: PublicKey, collateralMint: PublicKey, user?: PublicKey, payer?: PublicKey): Promise<Transaction>;
357
395
  /**
@@ -361,11 +399,27 @@ declare class CtfClientV2 {
361
399
  reportPayouts(condition: PublicKey, payoutNumerators: number[]): Promise<TxResult>;
362
400
  /**
363
401
  * Build the `transfer_position` instruction for use in a CLOB CPI.
364
- * V2: uses TOKEN_PROGRAM_ID (plain SPL) for outcome mints.
365
402
  *
366
403
  * This instruction requires `clob_authority` (the CLOB's PDA) to sign.
367
404
  * A PDA can only sign from within its own program via CPI — this method
368
405
  * CANNOT be called directly from a wallet transaction.
406
+ *
407
+ * Use-cases:
408
+ * - Custom CLOB implementations that call CTF.transfer_position via CPI
409
+ * - Anchor CPI builders in other Rust programs
410
+ *
411
+ * @param condition - Condition PDA
412
+ * @param outcomeMint - YES or NO mint
413
+ * @param fromUser - Source wallet
414
+ * @param fromTokenAccount - Source ATA
415
+ * @param fromPosition - Source Position PDA
416
+ * @param toUser - Destination wallet
417
+ * @param toTokenAccount - Destination ATA (created if needed — payer covers rent)
418
+ * @param toPosition - Destination Position PDA
419
+ * @param payer - Pays rent for toPosition + toTokenAccount creation
420
+ * @param clobAuthority - CLOB config PDA (must sign via CPI)
421
+ * @param outcomeIndex - 0 = NO, 1 = YES
422
+ * @param amount - Token amount to transfer
369
423
  */
370
424
  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>;
371
425
  /**
@@ -390,25 +444,24 @@ declare class CtfClientV2 {
390
444
  collateralVaultPda(collateralMint: PublicKey): PublicKey;
391
445
  }
392
446
 
393
- declare class MarketClientV2 {
447
+ declare class MarketClient {
394
448
  private readonly program;
395
449
  private readonly provider;
396
450
  private readonly programIds;
397
451
  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 */
452
+ /** Injected by XMarketSDK after construction — enables fetchQuestionBalances. */
453
+ ctfClient?: CtfClient;
454
+ /** Injected by XMarketSDK — fee config owner (= market owner) for MarketFeeOverride PDA derivation */
401
455
  feeConfigOwner?: PublicKey;
402
456
  constructor(program: anchor.Program, provider: anchor.AnchorProvider, programIds: ProgramIds, ownerPubkey: PublicKey);
403
457
  get walletPubkey(): PublicKey;
404
458
  initialize(admin: PublicKey, oracle: PublicKey, owner?: PublicKey): Promise<Transaction>;
405
459
  /**
406
460
  * Build createQuestionAdmin transaction (whitelist/admin path — status = Approved immediately).
407
- * V2: no hookProgram param, uses TOKEN_PROGRAM_ID for YES/NO mints.
408
461
  * @param creator - Whitelisted creator (must be in whitelist or be admin/owner)
409
462
  * @param payer - Fee payer (pays rent; can differ from creator)
410
463
  */
411
- createQuestionAdmin(params: Omit<CreateQuestionParams, "hookProgram">, oracle: PublicKey, creator?: PublicKey, payer?: PublicKey): Promise<{
464
+ createQuestionAdmin(params: CreateQuestionParams, oracle: PublicKey, creator?: PublicKey, payer?: PublicKey): Promise<{
412
465
  tx: Transaction;
413
466
  questionPda: PublicKey;
414
467
  conditionPda: PublicKey;
@@ -437,7 +490,7 @@ declare class MarketClientV2 {
437
490
  /**
438
491
  * Convenience: fetch YES and NO token balances for a question.
439
492
  * Returns null for each if question not approved or position not initialized.
440
- * Requires ctfClient to be injected (done automatically by XMarketSDKV2).
493
+ * Requires ctfClient to be injected (done automatically by XMarketSDK).
441
494
  */
442
495
  fetchQuestionBalances(questionPda: PublicKey, owner: PublicKey): Promise<{
443
496
  yes: Position | null;
@@ -463,10 +516,10 @@ declare class MarketClientV2 {
463
516
  }>;
464
517
  /**
465
518
  * Whitelist-only: approve presale → creates question + CTF condition + market_oracle in one tx.
466
- * V2: no hookProgram param — removes Token-2022 hook from CPI call.
467
519
  *
468
520
  * @param presalePda the presale account
469
521
  * @param contentHash 32-byte hash for question content
522
+ * @param hookProgram token-2022 transfer hook program
470
523
  * @param authorizedClob clob program allowed to do CTF transfers
471
524
  * @param expirationTime Unix seconds
472
525
  * @param creator presale creator pubkey (stored in question)
@@ -475,6 +528,7 @@ declare class MarketClientV2 {
475
528
  approvePresale(params: {
476
529
  presalePda: PublicKey;
477
530
  contentHash: Uint8Array;
531
+ hookProgram: PublicKey;
478
532
  authorizedClob: PublicKey;
479
533
  expirationTime: anchor.BN;
480
534
  creator: PublicKey;
@@ -597,25 +651,19 @@ declare class FeeManagementClient {
597
651
  buildSetAdminTx(newAdmin: PublicKey, feeConfigOwner: PublicKey, authority: PublicKey): Promise<Transaction>;
598
652
  }
599
653
 
600
- /**
601
- * ClobClientV2 — V2 variant of ClobClient.
602
- * Key differences from ClobClient (v1):
603
- * - No hookClient dependency (Token-2022 hook removed)
604
- * - YES/NO token ATAs use TOKEN_PROGRAM_ID (plain SPL) instead of TOKEN_2022_PROGRAM_ID
605
- * - No hook accounts in remainingAccounts for any match instruction
606
- * - No extraAccountMetaList / hookConfig PDAs included in ALTs or remainingAccounts
607
- */
608
- declare class ClobClientV2 {
654
+ declare class ClobClient {
609
655
  private readonly program;
610
656
  private readonly provider;
611
657
  private readonly programIds;
612
658
  private readonly networkConfig;
613
- /** Injected by XMarketSDKV2 after construction — enables auto fee distribution */
659
+ /** Injected by XMarketSDK after construction — enables auto fee distribution */
614
660
  feeClient?: FeeManagementClient;
615
661
  feeConfigOwner?: PublicKey;
616
- /** Injected by XMarketSDKV2 — enables auto-derive of marketOracleVault for presale markets */
617
- ctfClient?: CtfClientV2;
662
+ /** Injected by XMarketSDK — enables auto-derive of marketOracleVault for presale markets */
663
+ ctfClient?: CtfClient;
618
664
  qmConfigPda?: PublicKey;
665
+ /** Injected by XMarketSDK — enables auto-init extraAccountMetaList if missing */
666
+ hookClient?: HookClient;
619
667
  /** Cached company_address from fee_config to avoid repeated RPC calls */
620
668
  private _companyAddress?;
621
669
  /** Cached referral_vault from fee_config */
@@ -648,7 +696,6 @@ declare class ClobClientV2 {
648
696
  get walletPubkey(): PublicKey;
649
697
  /**
650
698
  * Get or create an ALT for a condition.
651
- * V2: no hook accounts — TOKEN_2022_PROGRAM_ID and hook PDAs are excluded.
652
699
  * Includes order_record PDAs for taker + all makers so match tx stays under 1232 bytes.
653
700
  */
654
701
  ensureAlt(condition: PublicKey, collateralMint: PublicKey, takerSigned: SignedOrder, makers: SignedOrder[]): Promise<AddressLookupTableAccount>;
@@ -691,11 +738,11 @@ declare class ClobClientV2 {
691
738
  forceResetClob(programData: PublicKey, newAdmin: PublicKey, newOperators: PublicKey[], newFeeRecipient: PublicKey, newFeeRateBps: number): Promise<TxResult>;
692
739
  /**
693
740
  * Build match_complementary instruction (no Ed25519 — OrderRecord PDAs used).
694
- * V2: no hook accounts in remainingAccounts.
695
741
  *
696
742
  * remaining_accounts layout:
697
743
  * [seller, order_record, seller_token, seller_collateral, seller_position, sell_status] × N
698
- * [feeManagement, fee_config, mkt_override, company_ata, oracle_vault, referral_vault] (when fee > 0)
744
+ * [extraAccountMetaList, hookConfig, hookProgram]
745
+ * [feeManagement, fee_config, mkt_override, company_ata, oracle_vault] (when fee > 0)
699
746
  */
700
747
  buildMatchComplementaryIxs(takerSigned: SignedOrder, makersSigned: SignedOrder[], collateralMint: PublicKey, feeRecipient: PublicKey, operator: PublicKey, opts?: {
701
748
  marketOracleVault?: PublicKey;
@@ -715,21 +762,25 @@ declare class ClobClientV2 {
715
762
  private matchComplementarySellVsMultiBuy;
716
763
  /**
717
764
  * MINT: 1 YES buyer (taker) + N NO buyers (makers).
718
- * V2: no hook accounts in remainingAccounts.
765
+ * Phase 1: register taker + all NO makers in parallel.
766
+ * Phase 2: 1 atomic match tx.
719
767
  *
720
- * remaining_accounts per NO maker (6):
721
- * [maker, order_record, buyer_no_token, buyer_no_collateral, buyer_no_position, no_order_status]
768
+ * remaining_accounts per NO maker (5):
769
+ * [order_record, buyer_no_token, buyer_no_collateral, buyer_no_position, no_order_status]
722
770
  */
771
+ /** Build the match_mint_orders instruction (no signing, no sending). */
723
772
  private _buildMintIx;
724
773
  private matchMintOrders;
725
774
  /**
726
775
  * MERGE: 1 YES seller (taker) + N NO sellers (makers).
727
- * V2: no hook accounts in remainingAccounts.
776
+ * Phase 1: register taker + all NO makers in parallel.
777
+ * Phase 2: 1 atomic match tx.
728
778
  *
729
- * remaining_accounts per NO maker (6):
730
- * [maker, order_record, seller_no_token, seller_no_collateral, seller_no_position, no_order_status]
731
- * After all makers, optional 6 fee accounts.
779
+ * remaining_accounts per NO maker (5):
780
+ * [order_record, seller_no_token, seller_no_collateral, seller_no_position, no_order_status]
781
+ * After all makers, optional 5 fee accounts.
732
782
  */
783
+ /** Build the match_merge_orders instruction (no signing, no sending). */
733
784
  private _buildMergeIx;
734
785
  private matchMergeOrders;
735
786
  /**
@@ -753,6 +804,13 @@ declare class ClobClientV2 {
753
804
  /**
754
805
  * High-level match: caller passes price + quantity + keypair — SDK builds,
755
806
  * signs, and submits in one call. No manual amount calculation needed.
807
+ *
808
+ * Amounts are computed from each order's own limit `price` (percentage, e.g. 51 for 51%).
809
+ * NEVER pass averageMatchedPrice — that is an engine output, not an order input.
810
+ *
811
+ * @param taker { keypair, condition, tokenId, side, price, quantity, nonce?, expiry? }
812
+ * @param makers Array of same shape
813
+ * @param decimals Collateral decimals (default 9 for USDS)
756
814
  */
757
815
  matchOrdersFromPrice(taker: {
758
816
  keypair: {
@@ -788,11 +846,21 @@ declare class ClobClientV2 {
788
846
  }): Promise<TxResult>;
789
847
  /**
790
848
  * Build an unsigned VersionedTransaction for a set of match instructions.
849
+ * Callers sign and send externally — mirrors createQuestionAdmin pattern.
791
850
  */
792
851
  private _buildUnsignedVtx;
793
852
  /**
794
853
  * Build unsigned VersionedTransaction(s) for matching orders.
795
- * V2: no hookClient, no hook init ixs prepended.
854
+ *
855
+ * Mirrors createQuestionAdmin pattern — SDK registers orders internally but
856
+ * returns the match tx unsigned. BE signs with both keypairs and sends:
857
+ *
858
+ * const [vtx] = await sdk.clob.buildMatchOrdersTx(taker, makers, operatorPk, payerPk);
859
+ * vtx.sign([feePayerKeypair, operatorKeypair]);
860
+ * await connection.sendRawTransaction(vtx.serialize());
861
+ *
862
+ * All match types pack into a single VersionedTransaction — same as createQuestionAdmin pattern.
863
+ * NO-taker MINT/MERGE decomposes into N instructions but all packed in 1 tx.
796
864
  *
797
865
  * @param operator - Whitelisted CLOB operator pubkey (must sign)
798
866
  * @param payer - Fee payer pubkey (must sign, pays tx fee + rent)
@@ -802,7 +870,12 @@ declare class ClobClientV2 {
802
870
  }): Promise<VersionedTransaction>;
803
871
  /**
804
872
  * Build VersionedTransaction for batchCollectRedeemEarly.
805
- * V2: no hook accounts in remainingAccounts, uses TOKEN_PROGRAM_ID for outcome mints.
873
+ *
874
+ * Prerequisite: each user's CollectFeeOrder must be registered on-chain via
875
+ * buildRegisterCollectFeeOrderTx (one tx per user).
876
+ *
877
+ * Flow: batchCollectRedeemEarly ix reads CollectFeeOrderRecord PDAs — no Ed25519 inline.
878
+ * No tx-size limit from signatures, supports 10+ orders in one tx.
806
879
  *
807
880
  * @param signedOrders - Array of { order, signature } (used to derive record PDAs)
808
881
  * @param condition - Market condition PDA
@@ -818,13 +891,16 @@ declare class ClobClientV2 {
818
891
  /**
819
892
  * Build a Transaction to register a RedeemFeeOrder on-chain (Ed25519 verify + PDA).
820
893
  * Must be sent before calling buildBatchRedeemWithFeeTx / buildBatchMergeWithFeeTx.
894
+ *
895
+ * ix[0]: batched Ed25519 { pubkey=order.user, sig, msg=128 bytes }
896
+ * ix[1]: register_redeem_fee_order(nonce)
821
897
  */
822
898
  buildRegisterRedeemFeeOrderTx(signedOrder: SignedRedeemFeeOrder, payer: PublicKey): Promise<anchor.web3.Transaction>;
823
899
  /**
824
900
  * Build a VersionedTransaction for batchRedeemWithFee.
825
- * V2: no hook accounts, uses TOKEN_PROGRAM_ID for outcome mints.
826
- *
827
901
  * Each pair has a YES order + NO order for the same user (same signer or different).
902
+ * After resolution: YES holder taker_amount > 0, NO holder taker_amount = 0 (or vice versa).
903
+ *
828
904
  * Prerequisite: each order's RedeemFeeOrderRecord must be registered via buildRegisterRedeemFeeOrderTx.
829
905
  */
830
906
  buildBatchRedeemWithFeeTx(orderPairs: RedeemFeeOrderPair[], condition: PublicKey, operator: PublicKey, payer: PublicKey, opts?: {
@@ -833,7 +909,8 @@ declare class ClobClientV2 {
833
909
  }): Promise<VersionedTransaction>;
834
910
  /**
835
911
  * Build a VersionedTransaction for batchMergeWithFee (pre-resolution merge with fee).
836
- * V2: no hook accounts, uses TOKEN_PROGRAM_ID for outcome mints.
912
+ * Each pair: YES order + NO order with equal amounts for the same user.
913
+ * Only yes_signer receives net USDS (mirrors EVM _matchMergeOrder).
837
914
  *
838
915
  * Prerequisite: each order's RedeemFeeOrderRecord must be registered via buildRegisterRedeemFeeOrderTx.
839
916
  */
@@ -844,12 +921,11 @@ declare class ClobClientV2 {
844
921
  /**
845
922
  * Build ALT for batchCollectRedeemEarly — includes per-user accounts so all
846
923
  * remaining_accounts fit as 1-byte ALT indices instead of 32-byte inline addresses.
847
- * V2: no hook program or hook PDAs included.
848
924
  */
849
925
  buildAltForCollectBatch(condition: PublicKey, payer: PublicKey, collateralMint: PublicKey, signedOrders: SignedCollectFeeOrder[], outcomeIndex: 0 | 1): Promise<AddressLookupTableAccount>;
850
926
  /**
851
927
  * Build ALT with static accounts for a condition — no order-specific PDAs needed.
852
- * V2: no hook program or hook PDAs included.
928
+ * Use before buildBatchCollectRedeemEarlyTx when no prior buildMatchOrdersTx ran in this session.
853
929
  */
854
930
  buildAltForCondition(condition: PublicKey, _payer: PublicKey, collateralMint?: PublicKey): Promise<AddressLookupTableAccount>;
855
931
  fetchConfig(): Promise<ClobConfig | null>;
@@ -1115,27 +1191,13 @@ declare class DisputeClient {
1115
1191
  buildResolveDisputeTx(conditionId: Uint8Array, amount: anchor.BN, isRefunded: boolean, owner: PublicKey, admin?: PublicKey): Promise<Transaction>;
1116
1192
  }
1117
1193
 
1118
- /**
1119
- * XMarketSDKV2 — V2 variant of XMarketSDK.
1120
- *
1121
- * Key differences from XMarketSDK (v1):
1122
- * - 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)
1127
- *
1128
- * Usage:
1129
- * const sdk = new XMarketSDKV2(DEVNET_V2_CONFIG, wallet, marketOwner);
1130
- * await sdk.market.createQuestionAdmin(params, oracle); // no hookProgram
1131
- * await sdk.clob.matchOrders(taker, makers); // no hook in remainingAccounts
1132
- */
1133
- declare class XMarketSDKV2 {
1194
+ declare class XMarketSDK {
1134
1195
  readonly provider: anchor.AnchorProvider;
1135
1196
  readonly networkConfig: NetworkConfig;
1136
1197
  private readonly _programIds;
1137
1198
  private readonly _marketOwner;
1138
1199
  private _oracle?;
1200
+ private _hook?;
1139
1201
  private _market?;
1140
1202
  private _ctf?;
1141
1203
  private _clob?;
@@ -1148,14 +1210,10 @@ declare class XMarketSDKV2 {
1148
1210
  constructor(config: NetworkConfig, wallet: anchor.Wallet, marketOwner?: PublicKey);
1149
1211
  private _withAddress;
1150
1212
  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;
1213
+ get hook(): HookClient;
1214
+ get market(): MarketClient;
1215
+ get ctf(): CtfClient;
1216
+ get clob(): ClobClient;
1159
1217
  get fee(): FeeManagementClient;
1160
1218
  get presale(): PresaleClient;
1161
1219
  get marketOracle(): MarketOracleClient;
@@ -1164,53 +1222,7 @@ declare class XMarketSDKV2 {
1164
1222
  get dispute(): DisputeClient;
1165
1223
  }
1166
1224
 
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 {
1225
+ declare class CtfClientV2 {
1214
1226
  private readonly program;
1215
1227
  private readonly provider;
1216
1228
  private readonly programIds;
@@ -1218,11 +1230,12 @@ declare class CtfClient {
1218
1230
  get walletPubkey(): PublicKey;
1219
1231
  /**
1220
1232
  * Create a Condition directly (bypasses QuestionMarket).
1233
+ * V2: uses plain SPL TOKEN_PROGRAM_ID for YES/NO mints — no hook program.
1221
1234
  * oracle is UncheckedAccount — set it to any pubkey (e.g. user wallet)
1222
1235
  * so that wallet can later sign reportPayouts.
1223
1236
  * payer covers rent for condition + mints.
1224
1237
  */
1225
- prepareCondition(questionId: Uint8Array, oracle: PublicKey, collateralMint: PublicKey, hookProgram: PublicKey, authorizedClob: PublicKey, payer?: PublicKey, signers?: Keypair[]): Promise<{
1238
+ prepareCondition(questionId: Uint8Array, oracle: PublicKey, collateralMint: PublicKey, authorizedClob: PublicKey, payer?: PublicKey, signers?: Keypair[]): Promise<{
1226
1239
  signature: string;
1227
1240
  conditionPda: PublicKey;
1228
1241
  yesMint: PublicKey;
@@ -1246,17 +1259,20 @@ declare class CtfClient {
1246
1259
  initPosition(condition: PublicKey, outcomeIndex: number, user?: PublicKey): Promise<TxResult>;
1247
1260
  /**
1248
1261
  * Split `amount` collateral into equal YES + NO tokens.
1262
+ * V2: uses TOKEN_PROGRAM_ID for YES/NO mints (plain SPL, no Token-2022).
1249
1263
  * ATAs created automatically via `init_if_needed`.
1250
1264
  */
1251
1265
  splitPosition(condition: PublicKey, collateralMint: PublicKey, amount: anchor.BN, user?: PublicKey, payer?: PublicKey): Promise<Transaction>;
1252
1266
  /**
1253
1267
  * Merge `amount` YES + NO tokens back into collateral.
1268
+ * V2: uses TOKEN_PROGRAM_ID for YES/NO mints (plain SPL, no Token-2022).
1254
1269
  * Both token balances must be ≥ amount.
1255
1270
  */
1256
1271
  mergePosition(condition: PublicKey, collateralMint: PublicKey, amount: anchor.BN, user?: PublicKey, payer?: PublicKey): Promise<Transaction>;
1257
1272
  /**
1258
1273
  * After condition resolves: burn outcome tokens proportional to payout
1259
1274
  * and receive USDC. Works for winning, losing, or both positions.
1275
+ * V2: uses TOKEN_PROGRAM_ID for YES/NO mints (plain SPL, no Token-2022).
1260
1276
  */
1261
1277
  redeemPositions(condition: PublicKey, collateralMint: PublicKey, user?: PublicKey, payer?: PublicKey): Promise<Transaction>;
1262
1278
  /**
@@ -1266,27 +1282,11 @@ declare class CtfClient {
1266
1282
  reportPayouts(condition: PublicKey, payoutNumerators: number[]): Promise<TxResult>;
1267
1283
  /**
1268
1284
  * Build the `transfer_position` instruction for use in a CLOB CPI.
1285
+ * V2: uses TOKEN_PROGRAM_ID (plain SPL) for outcome mints.
1269
1286
  *
1270
1287
  * This instruction requires `clob_authority` (the CLOB's PDA) to sign.
1271
1288
  * A PDA can only sign from within its own program via CPI — this method
1272
1289
  * 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
1290
  */
1291
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
1292
  /**
@@ -1311,24 +1311,25 @@ declare class CtfClient {
1311
1311
  collateralVaultPda(collateralMint: PublicKey): PublicKey;
1312
1312
  }
1313
1313
 
1314
- declare class MarketClient {
1314
+ declare class MarketClientV2 {
1315
1315
  private readonly program;
1316
1316
  private readonly provider;
1317
1317
  private readonly programIds;
1318
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 */
1319
+ /** Injected by XMarketSDKV2 after construction — enables fetchQuestionBalances. */
1320
+ ctfClient?: CtfClientV2;
1321
+ /** Injected by XMarketSDKV2 — fee config owner (= market owner) for MarketFeeOverride PDA derivation */
1322
1322
  feeConfigOwner?: PublicKey;
1323
1323
  constructor(program: anchor.Program, provider: anchor.AnchorProvider, programIds: ProgramIds, ownerPubkey: PublicKey);
1324
1324
  get walletPubkey(): PublicKey;
1325
1325
  initialize(admin: PublicKey, oracle: PublicKey, owner?: PublicKey): Promise<Transaction>;
1326
1326
  /**
1327
1327
  * Build createQuestionAdmin transaction (whitelist/admin path — status = Approved immediately).
1328
+ * V2: no hookProgram param, uses TOKEN_PROGRAM_ID for YES/NO mints.
1328
1329
  * @param creator - Whitelisted creator (must be in whitelist or be admin/owner)
1329
1330
  * @param payer - Fee payer (pays rent; can differ from creator)
1330
1331
  */
1331
- createQuestionAdmin(params: CreateQuestionParams, oracle: PublicKey, creator?: PublicKey, payer?: PublicKey): Promise<{
1332
+ createQuestionAdmin(params: Omit<CreateQuestionParams, "hookProgram">, oracle: PublicKey, creator?: PublicKey, payer?: PublicKey): Promise<{
1332
1333
  tx: Transaction;
1333
1334
  questionPda: PublicKey;
1334
1335
  conditionPda: PublicKey;
@@ -1357,7 +1358,7 @@ declare class MarketClient {
1357
1358
  /**
1358
1359
  * Convenience: fetch YES and NO token balances for a question.
1359
1360
  * Returns null for each if question not approved or position not initialized.
1360
- * Requires ctfClient to be injected (done automatically by XMarketSDK).
1361
+ * Requires ctfClient to be injected (done automatically by XMarketSDKV2).
1361
1362
  */
1362
1363
  fetchQuestionBalances(questionPda: PublicKey, owner: PublicKey): Promise<{
1363
1364
  yes: Position | null;
@@ -1383,10 +1384,10 @@ declare class MarketClient {
1383
1384
  }>;
1384
1385
  /**
1385
1386
  * Whitelist-only: approve presale → creates question + CTF condition + market_oracle in one tx.
1387
+ * V2: no hookProgram param — removes Token-2022 hook from CPI call.
1386
1388
  *
1387
1389
  * @param presalePda the presale account
1388
1390
  * @param contentHash 32-byte hash for question content
1389
- * @param hookProgram token-2022 transfer hook program
1390
1391
  * @param authorizedClob clob program allowed to do CTF transfers
1391
1392
  * @param expirationTime Unix seconds
1392
1393
  * @param creator presale creator pubkey (stored in question)
@@ -1395,7 +1396,6 @@ declare class MarketClient {
1395
1396
  approvePresale(params: {
1396
1397
  presalePda: PublicKey;
1397
1398
  contentHash: Uint8Array;
1398
- hookProgram: PublicKey;
1399
1399
  authorizedClob: PublicKey;
1400
1400
  expirationTime: anchor.BN;
1401
1401
  creator: PublicKey;
@@ -1440,19 +1440,25 @@ declare class MarketClient {
1440
1440
  collectTradingFee(marketOraclePda: PublicKey, qtMint: PublicKey, caller?: PublicKey): Promise<Transaction>;
1441
1441
  }
1442
1442
 
1443
- declare class ClobClient {
1443
+ /**
1444
+ * ClobClientV2 — V2 variant of ClobClient.
1445
+ * Key differences from ClobClient (v1):
1446
+ * - No hookClient dependency (Token-2022 hook removed)
1447
+ * - YES/NO token ATAs use TOKEN_PROGRAM_ID (plain SPL) instead of TOKEN_2022_PROGRAM_ID
1448
+ * - No hook accounts in remainingAccounts for any match instruction
1449
+ * - No extraAccountMetaList / hookConfig PDAs included in ALTs or remainingAccounts
1450
+ */
1451
+ declare class ClobClientV2 {
1444
1452
  private readonly program;
1445
1453
  private readonly provider;
1446
1454
  private readonly programIds;
1447
1455
  private readonly networkConfig;
1448
- /** Injected by XMarketSDK after construction — enables auto fee distribution */
1456
+ /** Injected by XMarketSDKV2 after construction — enables auto fee distribution */
1449
1457
  feeClient?: FeeManagementClient;
1450
1458
  feeConfigOwner?: PublicKey;
1451
- /** Injected by XMarketSDK — enables auto-derive of marketOracleVault for presale markets */
1452
- ctfClient?: CtfClient;
1459
+ /** Injected by XMarketSDKV2 — enables auto-derive of marketOracleVault for presale markets */
1460
+ ctfClient?: CtfClientV2;
1453
1461
  qmConfigPda?: PublicKey;
1454
- /** Injected by XMarketSDK — enables auto-init extraAccountMetaList if missing */
1455
- hookClient?: HookClient;
1456
1462
  /** Cached company_address from fee_config to avoid repeated RPC calls */
1457
1463
  private _companyAddress?;
1458
1464
  /** Cached referral_vault from fee_config */
@@ -1485,6 +1491,7 @@ declare class ClobClient {
1485
1491
  get walletPubkey(): PublicKey;
1486
1492
  /**
1487
1493
  * Get or create an ALT for a condition.
1494
+ * V2: no hook accounts — TOKEN_2022_PROGRAM_ID and hook PDAs are excluded.
1488
1495
  * Includes order_record PDAs for taker + all makers so match tx stays under 1232 bytes.
1489
1496
  */
1490
1497
  ensureAlt(condition: PublicKey, collateralMint: PublicKey, takerSigned: SignedOrder, makers: SignedOrder[]): Promise<AddressLookupTableAccount>;
@@ -1527,11 +1534,11 @@ declare class ClobClient {
1527
1534
  forceResetClob(programData: PublicKey, newAdmin: PublicKey, newOperators: PublicKey[], newFeeRecipient: PublicKey, newFeeRateBps: number): Promise<TxResult>;
1528
1535
  /**
1529
1536
  * Build match_complementary instruction (no Ed25519 — OrderRecord PDAs used).
1537
+ * V2: no hook accounts in remainingAccounts.
1530
1538
  *
1531
1539
  * remaining_accounts layout:
1532
1540
  * [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)
1541
+ * [feeManagement, fee_config, mkt_override, company_ata, oracle_vault, referral_vault] (when fee > 0)
1535
1542
  */
1536
1543
  buildMatchComplementaryIxs(takerSigned: SignedOrder, makersSigned: SignedOrder[], collateralMint: PublicKey, feeRecipient: PublicKey, operator: PublicKey, opts?: {
1537
1544
  marketOracleVault?: PublicKey;
@@ -1551,25 +1558,21 @@ declare class ClobClient {
1551
1558
  private matchComplementarySellVsMultiBuy;
1552
1559
  /**
1553
1560
  * 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.
1561
+ * V2: no hook accounts in remainingAccounts.
1556
1562
  *
1557
- * remaining_accounts per NO maker (5):
1558
- * [order_record, buyer_no_token, buyer_no_collateral, buyer_no_position, no_order_status]
1563
+ * remaining_accounts per NO maker (6):
1564
+ * [maker, order_record, buyer_no_token, buyer_no_collateral, buyer_no_position, no_order_status]
1559
1565
  */
1560
- /** Build the match_mint_orders instruction (no signing, no sending). */
1561
1566
  private _buildMintIx;
1562
1567
  private matchMintOrders;
1563
1568
  /**
1564
1569
  * 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.
1570
+ * V2: no hook accounts in remainingAccounts.
1567
1571
  *
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.
1572
+ * remaining_accounts per NO maker (6):
1573
+ * [maker, order_record, seller_no_token, seller_no_collateral, seller_no_position, no_order_status]
1574
+ * After all makers, optional 6 fee accounts.
1571
1575
  */
1572
- /** Build the match_merge_orders instruction (no signing, no sending). */
1573
1576
  private _buildMergeIx;
1574
1577
  private matchMergeOrders;
1575
1578
  /**
@@ -1593,13 +1596,6 @@ declare class ClobClient {
1593
1596
  /**
1594
1597
  * High-level match: caller passes price + quantity + keypair — SDK builds,
1595
1598
  * 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
1599
  */
1604
1600
  matchOrdersFromPrice(taker: {
1605
1601
  keypair: {
@@ -1635,21 +1631,11 @@ declare class ClobClient {
1635
1631
  }): Promise<TxResult>;
1636
1632
  /**
1637
1633
  * Build an unsigned VersionedTransaction for a set of match instructions.
1638
- * Callers sign and send externally — mirrors createQuestionAdmin pattern.
1639
1634
  */
1640
1635
  private _buildUnsignedVtx;
1641
1636
  /**
1642
1637
  * 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.
1638
+ * V2: no hookClient, no hook init ixs prepended.
1653
1639
  *
1654
1640
  * @param operator - Whitelisted CLOB operator pubkey (must sign)
1655
1641
  * @param payer - Fee payer pubkey (must sign, pays tx fee + rent)
@@ -1659,12 +1645,7 @@ declare class ClobClient {
1659
1645
  }): Promise<VersionedTransaction>;
1660
1646
  /**
1661
1647
  * 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.
1648
+ * V2: no hook accounts in remainingAccounts, uses TOKEN_PROGRAM_ID for outcome mints.
1668
1649
  *
1669
1650
  * @param signedOrders - Array of { order, signature } (used to derive record PDAs)
1670
1651
  * @param condition - Market condition PDA
@@ -1680,16 +1661,13 @@ declare class ClobClient {
1680
1661
  /**
1681
1662
  * Build a Transaction to register a RedeemFeeOrder on-chain (Ed25519 verify + PDA).
1682
1663
  * 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
1664
  */
1687
1665
  buildRegisterRedeemFeeOrderTx(signedOrder: SignedRedeemFeeOrder, payer: PublicKey): Promise<anchor.web3.Transaction>;
1688
1666
  /**
1689
1667
  * 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).
1668
+ * V2: no hook accounts, uses TOKEN_PROGRAM_ID for outcome mints.
1692
1669
  *
1670
+ * Each pair has a YES order + NO order for the same user (same signer or different).
1693
1671
  * Prerequisite: each order's RedeemFeeOrderRecord must be registered via buildRegisterRedeemFeeOrderTx.
1694
1672
  */
1695
1673
  buildBatchRedeemWithFeeTx(orderPairs: RedeemFeeOrderPair[], condition: PublicKey, operator: PublicKey, payer: PublicKey, opts?: {
@@ -1698,8 +1676,7 @@ declare class ClobClient {
1698
1676
  }): Promise<VersionedTransaction>;
1699
1677
  /**
1700
1678
  * 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).
1679
+ * V2: no hook accounts, uses TOKEN_PROGRAM_ID for outcome mints.
1703
1680
  *
1704
1681
  * Prerequisite: each order's RedeemFeeOrderRecord must be registered via buildRegisterRedeemFeeOrderTx.
1705
1682
  */
@@ -1710,11 +1687,12 @@ declare class ClobClient {
1710
1687
  /**
1711
1688
  * Build ALT for batchCollectRedeemEarly — includes per-user accounts so all
1712
1689
  * remaining_accounts fit as 1-byte ALT indices instead of 32-byte inline addresses.
1690
+ * V2: no hook program or hook PDAs included.
1713
1691
  */
1714
1692
  buildAltForCollectBatch(condition: PublicKey, payer: PublicKey, collateralMint: PublicKey, signedOrders: SignedCollectFeeOrder[], outcomeIndex: 0 | 1): Promise<AddressLookupTableAccount>;
1715
1693
  /**
1716
1694
  * 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.
1695
+ * V2: no hook program or hook PDAs included.
1718
1696
  */
1719
1697
  buildAltForCondition(condition: PublicKey, _payer: PublicKey, collateralMint?: PublicKey): Promise<AddressLookupTableAccount>;
1720
1698
  fetchConfig(): Promise<ClobConfig | null>;
@@ -1734,6 +1712,55 @@ declare class ClobClient {
1734
1712
  } | null>;
1735
1713
  }
1736
1714
 
1715
+ /**
1716
+ * XMarketSDKV2 — V2 variant of XMarketSDK.
1717
+ *
1718
+ * Key differences from XMarketSDK (v1):
1719
+ * - Uses V2 program IDs (conditionalTokens, clobExchange, questionMarket)
1720
+ * - CtfClientV2: plain SPL TOKEN_PROGRAM_ID for YES/NO mints, no hook
1721
+ * - ClobClientV2: no hookClient, no hook accounts in match instructions
1722
+ * - MarketClientV2: no hookProgram param in createQuestionAdmin / approvePresale
1723
+ * - No HookClient (sdk.hook throws a clear error)
1724
+ *
1725
+ * Usage:
1726
+ * const sdk = new XMarketSDKV2(DEVNET_V2_CONFIG, wallet, marketOwner);
1727
+ * await sdk.market.createQuestionAdmin(params, oracle); // no hookProgram
1728
+ * await sdk.clob.matchOrders(taker, makers); // no hook in remainingAccounts
1729
+ */
1730
+ declare class XMarketSDKV2 {
1731
+ readonly provider: anchor.AnchorProvider;
1732
+ readonly networkConfig: NetworkConfig;
1733
+ private readonly _programIds;
1734
+ private readonly _marketOwner;
1735
+ private _oracle?;
1736
+ private _market?;
1737
+ private _ctf?;
1738
+ private _clob?;
1739
+ private _fee?;
1740
+ private _presale?;
1741
+ private _marketOracle?;
1742
+ private _admin?;
1743
+ private _referral?;
1744
+ private _dispute?;
1745
+ constructor(config: NetworkConfig, wallet: anchor.Wallet, marketOwner?: PublicKey);
1746
+ private _withAddress;
1747
+ get oracle(): OracleClient;
1748
+ /**
1749
+ * V2 does not use a hook program — calling this getter throws an error.
1750
+ * The hook is not needed for plain SPL YES/NO mints.
1751
+ */
1752
+ get hook(): never;
1753
+ get market(): MarketClientV2;
1754
+ get ctf(): CtfClientV2;
1755
+ get clob(): ClobClientV2;
1756
+ get fee(): FeeManagementClient;
1757
+ get presale(): PresaleClient;
1758
+ get marketOracle(): MarketOracleClient;
1759
+ get admin(): AdminClient;
1760
+ get referral(): ReferralClient;
1761
+ get dispute(): DisputeClient;
1762
+ }
1763
+
1737
1764
  declare const SEEDS: {
1738
1765
  readonly config: Buffer<ArrayBuffer>;
1739
1766
  readonly question: Buffer<ArrayBuffer>;
@@ -1982,22 +2009,50 @@ type MatchType = "COMPLEMENTARY" | "MINT" | "MERGE";
1982
2009
  declare function detectMatchType(a: Order | SignedOrder, b: Order | SignedOrder): MatchType;
1983
2010
 
1984
2011
  /**
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.
2012
+ * SPL Token / Token-2022 approve utilities for the CLOB matching flow.
2013
+ *
2014
+ * Before a match instruction can transfer tokens on behalf of a user, the user
2015
+ * must approve the CLOB config PDA as a delegate. These helpers build the
2016
+ * approve transactions that need two signers:
2017
+ * - signer = the token owner (user wallet — must sign the approve instruction)
2018
+ * - payer = the BE wallet (pays transaction fees)
2019
+ *
2020
+ * Both must sign the resulting Transaction before sending.
1987
2021
  */
1988
2022
 
2023
+ /** Maximum u64 — approve "unlimited" amount. */
1989
2024
  declare const MAX_APPROVE_AMOUNT: BN;
1990
2025
  /**
1991
- * Build a Transaction that creates YES and NO SPL ATAs for a user (idempotent).
2026
+ * Build a Transaction that creates YES and NO Token-2022 ATAs for a user
2027
+ * (idempotent — safe to call even if they already exist).
2028
+ *
2029
+ * Required signer: payer (fee payer). No user signature needed.
2030
+ *
2031
+ * @param condition - condition PDA
2032
+ * @param user - wallet that will own the ATAs
2033
+ * @param payer - fee payer wallet pubkey
2034
+ * @param programIds - network program IDs
1992
2035
  */
1993
2036
  declare function buildCreateUserAtasTx(condition: PublicKey, user: PublicKey, payer: PublicKey, programIds: ProgramIds): Transaction;
1994
2037
  /**
1995
- * Build a Transaction that approves the CLOB config PDA to transfer collateral (USDS).
2038
+ * Build a Transaction that approves the CLOB config PDA to transfer collateral
2039
+ * (USDC) from the signer's ATA.
2040
+ *
2041
+ * Required signers: signer (token owner), payer (fee payer).
2042
+ *
2043
+ * @param collateralMint - e.g. USDC mint
2044
+ * @param signer - token owner (must sign)
2045
+ * @param payer - fee payer wallet pubkey
2046
+ * @param delegate - clob config PDA (the spender)
2047
+ * @param amount - amount to approve (defaults to MAX_APPROVE_AMOUNT)
1996
2048
  */
1997
2049
  declare function buildApproveCollateralTx(collateralMint: PublicKey, signer: PublicKey, payer: PublicKey, delegate: PublicKey, amount?: BN): Transaction;
1998
2050
  /**
1999
- * Build a Transaction that approves the CLOB config PDA to transfer YES and NO tokens.
2051
+ * Build a Transaction that approves the CLOB config PDA to transfer BOTH
2052
+ * YES and NO outcome tokens from the signer's ATAs (two approve instructions).
2053
+ *
2054
+ * Required signers: signer (token owner), payer (fee payer).
2000
2055
  */
2001
2056
  declare function buildApproveAllOutcomeTokensTx(condition: PublicKey, signer: PublicKey, payer: PublicKey, delegate: PublicKey, programIds: ProgramIds, amount?: BN): Transaction;
2002
2057
 
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 };
2058
+ 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, XMarketSDK, XMarketSDKV2, buildApproveAllOutcomeTokensTx, buildApproveCollateralTx, buildBatchedCollectFeeEd25519Instruction, buildBatchedEd25519Instruction, buildBatchedRedeemFeeEd25519Instruction, buildCreateUserAtasTx, buildOrder, buildOrderFromPrice, deserializeSignedOrder, detectMatchType, generateContentHash, generateQuestionId, getOrderSignBytes, orderAmountsFromPrice, serializeCollectFeeOrderToBytes, serializeOrderToBytes, serializeRedeemFeeOrderToBytes, serializeSignedOrder, signOrder, signOrderWithKeypair, verifySignedOrder };