@theliem/xmarket-sdk 3.29.1 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,13 +1,12 @@
1
1
  import * as anchor from '@coral-xyz/anchor';
2
2
  import * as _solana_web3_js from '@solana/web3.js';
3
- import { PublicKey, Transaction, TransactionInstruction, Keypair, AddressLookupTableAccount, VersionedTransaction } from '@solana/web3.js';
3
+ import { PublicKey, Transaction, Keypair, TransactionInstruction, 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
- hook: PublicKey;
11
10
  clobExchange: PublicKey;
12
11
  feeManagement?: PublicKey;
13
12
  presale?: PublicKey;
@@ -38,8 +37,7 @@ interface OracleConfig {
38
37
  owner: PublicKey;
39
38
  admin: PublicKey;
40
39
  questionCount: number;
41
- whitelist: PublicKey[];
42
- whitelistLen: number;
40
+ reporterCount: number;
43
41
  isPaused: boolean;
44
42
  bump: number;
45
43
  }
@@ -128,8 +126,6 @@ interface CreateQuestionParams {
128
126
  expirationTime: number;
129
127
  /** Collateral mint (e.g. USDC) */
130
128
  collateralMint: PublicKey;
131
- /** Hook program ID for Token-2022 transfer enforcement */
132
- hookProgram: PublicKey;
133
129
  /** Authorized CLOB program ID */
134
130
  authorizedClob: PublicKey;
135
131
  /** Override auto-generated questionId */
@@ -141,13 +137,6 @@ interface CtfConfig {
141
137
  owner: PublicKey;
142
138
  bump: number;
143
139
  }
144
- interface HookConfig {
145
- owner: PublicKey;
146
- whitelist: PublicKey[];
147
- whitelistLen: number;
148
- isFrozen: boolean;
149
- bump: number;
150
- }
151
140
  interface ClobConfig {
152
141
  owner: PublicKey;
153
142
  operators: PublicKey[];
@@ -278,15 +267,15 @@ declare class OracleClient {
278
267
  configPda(owner?: PublicKey): PublicKey;
279
268
  /** One-time setup. Caller becomes owner. */
280
269
  initialize(admin: PublicKey): Promise<TxResult>;
281
- /** Admin or owner adds an address to the oracle resolver whitelist. */
282
- addToWhitelist(address: PublicKey, ownerPubkey?: PublicKey): Promise<TxResult>;
283
- /** Admin or owner removes an address from the oracle resolver whitelist. */
284
- removeFromWhitelist(address: PublicKey, ownerPubkey?: PublicKey): Promise<TxResult>;
270
+ /** Admin or owner registers a reporter PDA. */
271
+ addReporter(reporterAddress: PublicKey, ownerPubkey?: PublicKey): Promise<TxResult>;
272
+ /** Admin or owner removes a reporter PDA. */
273
+ removeReporter(reporterAddress: PublicKey, ownerPubkey?: PublicKey): Promise<TxResult>;
285
274
  /**
286
- * Whitelisted reporter resolves a question.
287
- * reporter signs the instruction; payer covers the tx fee (Kora pattern).
275
+ * Registered reporter resolves a question.
276
+ * reporterSigner signs; payer covers rent for question_result PDA.
288
277
  */
289
- resolveQuestion(questionId: Uint8Array, outcomeCount: number, payoutNumerators: number[], conditionPda: PublicKey, reporter?: PublicKey, payer?: PublicKey, ownerPubkey?: PublicKey): Promise<Transaction>;
278
+ resolveQuestion(questionId: Uint8Array, outcomeCount: number, payoutNumerators: number[], reporterSigner?: PublicKey, payer?: PublicKey, ownerPubkey?: PublicKey): Promise<Transaction>;
290
279
  /** Owner updates the admin. */
291
280
  updateAdmin(newAdmin: PublicKey, ownerPubkey?: PublicKey): Promise<TxResult>;
292
281
  /** Owner transfers ownership to a new keypair. */
@@ -294,55 +283,11 @@ declare class OracleClient {
294
283
  /** Admin or owner pause/unpause the oracle. */
295
284
  pause(paused: boolean, ownerPubkey?: PublicKey): Promise<TxResult>;
296
285
  fetchConfig(owner?: PublicKey): Promise<OracleConfig | null>;
286
+ /** Check if an address is a registered reporter (Reporter PDA exists). */
287
+ isReporter(reporterAddress: PublicKey, ownerPubkey?: PublicKey): Promise<boolean>;
297
288
  fetchQuestionResult(questionId: Uint8Array, ownerPubkey?: PublicKey): Promise<QuestionResult | null>;
298
289
  }
299
290
 
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
291
  declare class CtfClient {
347
292
  private readonly program;
348
293
  private readonly provider;
@@ -351,11 +296,12 @@ declare class CtfClient {
351
296
  get walletPubkey(): PublicKey;
352
297
  /**
353
298
  * Create a Condition directly (bypasses QuestionMarket).
299
+ * V2: uses plain SPL TOKEN_PROGRAM_ID for YES/NO mints — no hook program.
354
300
  * oracle is UncheckedAccount — set it to any pubkey (e.g. user wallet)
355
301
  * so that wallet can later sign reportPayouts.
356
302
  * payer covers rent for condition + mints.
357
303
  */
358
- prepareCondition(questionId: Uint8Array, oracle: PublicKey, collateralMint: PublicKey, hookProgram: PublicKey, authorizedClob: PublicKey, payer?: PublicKey, signers?: Keypair[]): Promise<{
304
+ prepareCondition(questionId: Uint8Array, oracle: PublicKey, collateralMint: PublicKey, authorizedClob: PublicKey, payer?: PublicKey, signers?: Keypair[]): Promise<{
359
305
  signature: string;
360
306
  conditionPda: PublicKey;
361
307
  yesMint: PublicKey;
@@ -379,17 +325,20 @@ declare class CtfClient {
379
325
  initPosition(condition: PublicKey, outcomeIndex: number, user?: PublicKey): Promise<TxResult>;
380
326
  /**
381
327
  * Split `amount` collateral into equal YES + NO tokens.
328
+ * V2: uses TOKEN_PROGRAM_ID for YES/NO mints (plain SPL, no Token-2022).
382
329
  * ATAs created automatically via `init_if_needed`.
383
330
  */
384
331
  splitPosition(condition: PublicKey, collateralMint: PublicKey, amount: anchor.BN, user?: PublicKey, payer?: PublicKey): Promise<Transaction>;
385
332
  /**
386
333
  * Merge `amount` YES + NO tokens back into collateral.
334
+ * V2: uses TOKEN_PROGRAM_ID for YES/NO mints (plain SPL, no Token-2022).
387
335
  * Both token balances must be ≥ amount.
388
336
  */
389
337
  mergePosition(condition: PublicKey, collateralMint: PublicKey, amount: anchor.BN, user?: PublicKey, payer?: PublicKey): Promise<Transaction>;
390
338
  /**
391
339
  * After condition resolves: burn outcome tokens proportional to payout
392
340
  * and receive USDC. Works for winning, losing, or both positions.
341
+ * V2: uses TOKEN_PROGRAM_ID for YES/NO mints (plain SPL, no Token-2022).
393
342
  */
394
343
  redeemPositions(condition: PublicKey, collateralMint: PublicKey, user?: PublicKey, payer?: PublicKey): Promise<Transaction>;
395
344
  /**
@@ -399,27 +348,11 @@ declare class CtfClient {
399
348
  reportPayouts(condition: PublicKey, payoutNumerators: number[]): Promise<TxResult>;
400
349
  /**
401
350
  * Build the `transfer_position` instruction for use in a CLOB CPI.
351
+ * V2: uses TOKEN_PROGRAM_ID (plain SPL) for outcome mints.
402
352
  *
403
353
  * This instruction requires `clob_authority` (the CLOB's PDA) to sign.
404
354
  * A PDA can only sign from within its own program via CPI — this method
405
355
  * 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
423
356
  */
424
357
  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>;
425
358
  /**
@@ -458,10 +391,11 @@ declare class MarketClient {
458
391
  initialize(admin: PublicKey, oracle: PublicKey, owner?: PublicKey): Promise<Transaction>;
459
392
  /**
460
393
  * Build createQuestionAdmin transaction (whitelist/admin path — status = Approved immediately).
394
+ * V2: no hookProgram param, uses TOKEN_PROGRAM_ID for YES/NO mints.
461
395
  * @param creator - Whitelisted creator (must be in whitelist or be admin/owner)
462
396
  * @param payer - Fee payer (pays rent; can differ from creator)
463
397
  */
464
- createQuestionAdmin(params: CreateQuestionParams, oracle: PublicKey, creator?: PublicKey, payer?: PublicKey): Promise<{
398
+ createQuestionAdmin(params: Omit<CreateQuestionParams, "hookProgram">, oracle: PublicKey, creator?: PublicKey, payer?: PublicKey): Promise<{
465
399
  tx: Transaction;
466
400
  questionPda: PublicKey;
467
401
  conditionPda: PublicKey;
@@ -516,10 +450,10 @@ declare class MarketClient {
516
450
  }>;
517
451
  /**
518
452
  * Whitelist-only: approve presale → creates question + CTF condition + market_oracle in one tx.
453
+ * V2: no hookProgram param — removes Token-2022 hook from CPI call.
519
454
  *
520
455
  * @param presalePda the presale account
521
456
  * @param contentHash 32-byte hash for question content
522
- * @param hookProgram token-2022 transfer hook program
523
457
  * @param authorizedClob clob program allowed to do CTF transfers
524
458
  * @param expirationTime Unix seconds
525
459
  * @param creator presale creator pubkey (stored in question)
@@ -528,7 +462,6 @@ declare class MarketClient {
528
462
  approvePresale(params: {
529
463
  presalePda: PublicKey;
530
464
  contentHash: Uint8Array;
531
- hookProgram: PublicKey;
532
465
  authorizedClob: PublicKey;
533
466
  expirationTime: anchor.BN;
534
467
  creator: PublicKey;
@@ -566,6 +499,12 @@ declare class MarketClient {
566
499
  caller?: PublicKey;
567
500
  payer?: PublicKey;
568
501
  }): Promise<Transaction>;
502
+ /**
503
+ * Resolve a question by reading the oracle question_result PDA and updating the CTF condition.
504
+ * Must be called after sdk.oracle.resolveQuestion records the result.
505
+ * Caller must be on the question_market whitelist.
506
+ */
507
+ resolveQuestion(questionId: Uint8Array, conditionPda: PublicKey, oracleOwner: PublicKey, payer?: PublicKey): Promise<Transaction>;
569
508
  /**
570
509
  * Whitelist-only: snapshot MST supply so holders can claim trading fees.
571
510
  * Call after oracle resolves the question.
@@ -651,6 +590,14 @@ declare class FeeManagementClient {
651
590
  buildSetAdminTx(newAdmin: PublicKey, feeConfigOwner: PublicKey, authority: PublicKey): Promise<Transaction>;
652
591
  }
653
592
 
593
+ /**
594
+ * ClobClient — V2 variant of the CLOB client.
595
+ * Key differences from the old v1 ClobClient:
596
+ * - No hookClient dependency (Token-2022 hook removed)
597
+ * - YES/NO token ATAs use TOKEN_PROGRAM_ID (plain SPL) instead of TOKEN_2022_PROGRAM_ID
598
+ * - No hook accounts in remainingAccounts for any match instruction
599
+ * - No extraAccountMetaList / hookConfig PDAs included in ALTs or remainingAccounts
600
+ */
654
601
  declare class ClobClient {
655
602
  private readonly program;
656
603
  private readonly provider;
@@ -662,8 +609,6 @@ declare class ClobClient {
662
609
  /** Injected by XMarketSDK — enables auto-derive of marketOracleVault for presale markets */
663
610
  ctfClient?: CtfClient;
664
611
  qmConfigPda?: PublicKey;
665
- /** Injected by XMarketSDK — enables auto-init extraAccountMetaList if missing */
666
- hookClient?: HookClient;
667
612
  /** Cached company_address from fee_config to avoid repeated RPC calls */
668
613
  private _companyAddress?;
669
614
  /** Cached referral_vault from fee_config */
@@ -696,6 +641,7 @@ declare class ClobClient {
696
641
  get walletPubkey(): PublicKey;
697
642
  /**
698
643
  * Get or create an ALT for a condition.
644
+ * V2: no hook accounts — TOKEN_2022_PROGRAM_ID and hook PDAs are excluded.
699
645
  * Includes order_record PDAs for taker + all makers so match tx stays under 1232 bytes.
700
646
  */
701
647
  ensureAlt(condition: PublicKey, collateralMint: PublicKey, takerSigned: SignedOrder, makers: SignedOrder[]): Promise<AddressLookupTableAccount>;
@@ -738,11 +684,11 @@ declare class ClobClient {
738
684
  forceResetClob(programData: PublicKey, newAdmin: PublicKey, newOperators: PublicKey[], newFeeRecipient: PublicKey, newFeeRateBps: number): Promise<TxResult>;
739
685
  /**
740
686
  * Build match_complementary instruction (no Ed25519 — OrderRecord PDAs used).
687
+ * V2: no hook accounts in remainingAccounts.
741
688
  *
742
689
  * remaining_accounts layout:
743
690
  * [seller, order_record, seller_token, seller_collateral, seller_position, sell_status] × N
744
- * [extraAccountMetaList, hookConfig, hookProgram]
745
- * [feeManagement, fee_config, mkt_override, company_ata, oracle_vault] (when fee > 0)
691
+ * [feeManagement, fee_config, mkt_override, company_ata, oracle_vault, referral_vault] (when fee > 0)
746
692
  */
747
693
  buildMatchComplementaryIxs(takerSigned: SignedOrder, makersSigned: SignedOrder[], collateralMint: PublicKey, feeRecipient: PublicKey, operator: PublicKey, opts?: {
748
694
  marketOracleVault?: PublicKey;
@@ -762,25 +708,21 @@ declare class ClobClient {
762
708
  private matchComplementarySellVsMultiBuy;
763
709
  /**
764
710
  * MINT: 1 YES buyer (taker) + N NO buyers (makers).
765
- * Phase 1: register taker + all NO makers in parallel.
766
- * Phase 2: 1 atomic match tx.
711
+ * V2: no hook accounts in remainingAccounts.
767
712
  *
768
- * remaining_accounts per NO maker (5):
769
- * [order_record, buyer_no_token, buyer_no_collateral, buyer_no_position, no_order_status]
713
+ * remaining_accounts per NO maker (6):
714
+ * [maker, order_record, buyer_no_token, buyer_no_collateral, buyer_no_position, no_order_status]
770
715
  */
771
- /** Build the match_mint_orders instruction (no signing, no sending). */
772
716
  private _buildMintIx;
773
717
  private matchMintOrders;
774
718
  /**
775
719
  * MERGE: 1 YES seller (taker) + N NO sellers (makers).
776
- * Phase 1: register taker + all NO makers in parallel.
777
- * Phase 2: 1 atomic match tx.
720
+ * V2: no hook accounts in remainingAccounts.
778
721
  *
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.
722
+ * remaining_accounts per NO maker (6):
723
+ * [maker, order_record, seller_no_token, seller_no_collateral, seller_no_position, no_order_status]
724
+ * After all makers, optional 6 fee accounts.
782
725
  */
783
- /** Build the match_merge_orders instruction (no signing, no sending). */
784
726
  private _buildMergeIx;
785
727
  private matchMergeOrders;
786
728
  /**
@@ -804,13 +746,6 @@ declare class ClobClient {
804
746
  /**
805
747
  * High-level match: caller passes price + quantity + keypair — SDK builds,
806
748
  * 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)
814
749
  */
815
750
  matchOrdersFromPrice(taker: {
816
751
  keypair: {
@@ -846,21 +781,11 @@ declare class ClobClient {
846
781
  }): Promise<TxResult>;
847
782
  /**
848
783
  * Build an unsigned VersionedTransaction for a set of match instructions.
849
- * Callers sign and send externally — mirrors createQuestionAdmin pattern.
850
784
  */
851
785
  private _buildUnsignedVtx;
852
786
  /**
853
787
  * Build unsigned VersionedTransaction(s) for matching orders.
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.
788
+ * V2: no hookClient, no hook init ixs prepended.
864
789
  *
865
790
  * @param operator - Whitelisted CLOB operator pubkey (must sign)
866
791
  * @param payer - Fee payer pubkey (must sign, pays tx fee + rent)
@@ -870,12 +795,7 @@ declare class ClobClient {
870
795
  }): Promise<VersionedTransaction>;
871
796
  /**
872
797
  * Build VersionedTransaction for batchCollectRedeemEarly.
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.
798
+ * V2: no hook accounts in remainingAccounts, uses TOKEN_PROGRAM_ID for outcome mints.
879
799
  *
880
800
  * @param signedOrders - Array of { order, signature } (used to derive record PDAs)
881
801
  * @param condition - Market condition PDA
@@ -891,16 +811,13 @@ declare class ClobClient {
891
811
  /**
892
812
  * Build a Transaction to register a RedeemFeeOrder on-chain (Ed25519 verify + PDA).
893
813
  * 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)
897
814
  */
898
815
  buildRegisterRedeemFeeOrderTx(signedOrder: SignedRedeemFeeOrder, payer: PublicKey): Promise<anchor.web3.Transaction>;
899
816
  /**
900
817
  * Build a VersionedTransaction for batchRedeemWithFee.
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).
818
+ * V2: no hook accounts, uses TOKEN_PROGRAM_ID for outcome mints.
903
819
  *
820
+ * Each pair has a YES order + NO order for the same user (same signer or different).
904
821
  * Prerequisite: each order's RedeemFeeOrderRecord must be registered via buildRegisterRedeemFeeOrderTx.
905
822
  */
906
823
  buildBatchRedeemWithFeeTx(orderPairs: RedeemFeeOrderPair[], condition: PublicKey, operator: PublicKey, payer: PublicKey, opts?: {
@@ -909,8 +826,7 @@ declare class ClobClient {
909
826
  }): Promise<VersionedTransaction>;
910
827
  /**
911
828
  * Build a VersionedTransaction for batchMergeWithFee (pre-resolution merge with fee).
912
- * Each pair: YES order + NO order with equal amounts for the same user.
913
- * Only yes_signer receives net USDS (mirrors EVM _matchMergeOrder).
829
+ * V2: no hook accounts, uses TOKEN_PROGRAM_ID for outcome mints.
914
830
  *
915
831
  * Prerequisite: each order's RedeemFeeOrderRecord must be registered via buildRegisterRedeemFeeOrderTx.
916
832
  */
@@ -921,11 +837,12 @@ declare class ClobClient {
921
837
  /**
922
838
  * Build ALT for batchCollectRedeemEarly — includes per-user accounts so all
923
839
  * remaining_accounts fit as 1-byte ALT indices instead of 32-byte inline addresses.
840
+ * V2: no hook program or hook PDAs included.
924
841
  */
925
842
  buildAltForCollectBatch(condition: PublicKey, payer: PublicKey, collateralMint: PublicKey, signedOrders: SignedCollectFeeOrder[], outcomeIndex: 0 | 1): Promise<AddressLookupTableAccount>;
926
843
  /**
927
844
  * Build ALT with static accounts for a condition — no order-specific PDAs needed.
928
- * Use before buildBatchCollectRedeemEarlyTx when no prior buildMatchOrdersTx ran in this session.
845
+ * V2: no hook program or hook PDAs included.
929
846
  */
930
847
  buildAltForCondition(condition: PublicKey, _payer: PublicKey, collateralMint?: PublicKey): Promise<AddressLookupTableAccount>;
931
848
  fetchConfig(): Promise<ClobConfig | null>;
@@ -1191,13 +1108,27 @@ declare class DisputeClient {
1191
1108
  buildResolveDisputeTx(conditionId: Uint8Array, amount: anchor.BN, isRefunded: boolean, owner: PublicKey, admin?: PublicKey): Promise<Transaction>;
1192
1109
  }
1193
1110
 
1111
+ /**
1112
+ * XMarketSDK — V2 SDK.
1113
+ *
1114
+ * Key differences from the old v1 SDK:
1115
+ * - Uses V2 program IDs (conditionalTokens, clobExchange, questionMarket)
1116
+ * - CtfClient: plain SPL TOKEN_PROGRAM_ID for YES/NO mints, no hook
1117
+ * - ClobClient: no hookClient, no hook accounts in match instructions
1118
+ * - MarketClient: no hookProgram param in createQuestionAdmin / approvePresale
1119
+ * - No HookClient (hook program removed entirely)
1120
+ *
1121
+ * Usage:
1122
+ * const sdk = new XMarketSDK(DEVNET_CONFIG, wallet, marketOwner);
1123
+ * await sdk.market.createQuestionAdmin(params, oracle); // no hookProgram
1124
+ * await sdk.clob.matchOrders(taker, makers); // no hook in remainingAccounts
1125
+ */
1194
1126
  declare class XMarketSDK {
1195
1127
  readonly provider: anchor.AnchorProvider;
1196
1128
  readonly networkConfig: NetworkConfig;
1197
1129
  private readonly _programIds;
1198
1130
  private readonly _marketOwner;
1199
1131
  private _oracle?;
1200
- private _hook?;
1201
1132
  private _market?;
1202
1133
  private _ctf?;
1203
1134
  private _clob?;
@@ -1210,7 +1141,6 @@ declare class XMarketSDK {
1210
1141
  constructor(config: NetworkConfig, wallet: anchor.Wallet, marketOwner?: PublicKey);
1211
1142
  private _withAddress;
1212
1143
  get oracle(): OracleClient;
1213
- get hook(): HookClient;
1214
1144
  get market(): MarketClient;
1215
1145
  get ctf(): CtfClient;
1216
1146
  get clob(): ClobClient;
@@ -1222,545 +1152,6 @@ declare class XMarketSDK {
1222
1152
  get dispute(): DisputeClient;
1223
1153
  }
1224
1154
 
1225
- declare class CtfClientV2 {
1226
- private readonly program;
1227
- private readonly provider;
1228
- private readonly programIds;
1229
- constructor(program: anchor.Program, provider: anchor.AnchorProvider, programIds: ProgramIds);
1230
- get walletPubkey(): PublicKey;
1231
- /**
1232
- * Create a Condition directly (bypasses QuestionMarket).
1233
- * V2: uses plain SPL TOKEN_PROGRAM_ID for YES/NO mints — no hook program.
1234
- * oracle is UncheckedAccount — set it to any pubkey (e.g. user wallet)
1235
- * so that wallet can later sign reportPayouts.
1236
- * payer covers rent for condition + mints.
1237
- */
1238
- prepareCondition(questionId: Uint8Array, oracle: PublicKey, collateralMint: PublicKey, authorizedClob: PublicKey, payer?: PublicKey, signers?: Keypair[]): Promise<{
1239
- signature: string;
1240
- conditionPda: PublicKey;
1241
- yesMint: PublicKey;
1242
- noMint: PublicKey;
1243
- }>;
1244
- /** One-time setup. Caller becomes the CTF owner. Can only be called once. */
1245
- initializeCtfConfig(): Promise<TxResult>;
1246
- /**
1247
- * Create the shared collateral vault for a given collateral mint (e.g. USDC).
1248
- * Only callable by the CTF owner (as stored in ctf_config).
1249
- * authority defaults to the wallet — pass a different signer if needed.
1250
- */
1251
- initializeVault(collateralMint: PublicKey): Promise<TxResult>;
1252
- /**
1253
- * Initialize an empty Position account (balance = 0) for a user.
1254
- * Needed before redeemPositions when the user only holds the opposite outcome
1255
- * (e.g. buyer received YES via CLOB match but never had a NO position).
1256
- *
1257
- * Idempotent — call `fetchPosition` first to skip if already initialized.
1258
- */
1259
- initPosition(condition: PublicKey, outcomeIndex: number, user?: PublicKey): Promise<TxResult>;
1260
- /**
1261
- * Split `amount` collateral into equal YES + NO tokens.
1262
- * V2: uses TOKEN_PROGRAM_ID for YES/NO mints (plain SPL, no Token-2022).
1263
- * ATAs created automatically via `init_if_needed`.
1264
- */
1265
- splitPosition(condition: PublicKey, collateralMint: PublicKey, amount: anchor.BN, user?: PublicKey, payer?: PublicKey): Promise<Transaction>;
1266
- /**
1267
- * Merge `amount` YES + NO tokens back into collateral.
1268
- * V2: uses TOKEN_PROGRAM_ID for YES/NO mints (plain SPL, no Token-2022).
1269
- * Both token balances must be ≥ amount.
1270
- */
1271
- mergePosition(condition: PublicKey, collateralMint: PublicKey, amount: anchor.BN, user?: PublicKey, payer?: PublicKey): Promise<Transaction>;
1272
- /**
1273
- * After condition resolves: burn outcome tokens proportional to payout
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).
1276
- */
1277
- redeemPositions(condition: PublicKey, collateralMint: PublicKey, user?: PublicKey, payer?: PublicKey): Promise<Transaction>;
1278
- /**
1279
- * Oracle directly resolves a condition with payout numerators.
1280
- * Bypasses QuestionMarket — only for oracle-owned conditions.
1281
- */
1282
- reportPayouts(condition: PublicKey, payoutNumerators: number[]): Promise<TxResult>;
1283
- /**
1284
- * Build the `transfer_position` instruction for use in a CLOB CPI.
1285
- * V2: uses TOKEN_PROGRAM_ID (plain SPL) for outcome mints.
1286
- *
1287
- * This instruction requires `clob_authority` (the CLOB's PDA) to sign.
1288
- * A PDA can only sign from within its own program via CPI — this method
1289
- * CANNOT be called directly from a wallet transaction.
1290
- */
1291
- transferPositionIx(condition: PublicKey, outcomeMint: PublicKey, fromUser: PublicKey, fromTokenAccount: PublicKey, fromPosition: PublicKey, toUser: PublicKey, toTokenAccount: PublicKey, toPosition: PublicKey, payer: PublicKey, clobAuthority: PublicKey, outcomeIndex: number, amount: anchor.BN): Promise<TransactionInstruction>;
1292
- /**
1293
- * Update the authorized CLOB on a condition.
1294
- * Only callable by the condition's oracle (the wallet that signed createQuestion).
1295
- */
1296
- updateAuthorizedClob(condition: PublicKey, newAuthorizedClob: PublicKey): Promise<TxResult>;
1297
- fetchCtfConfig(): Promise<CtfConfig | null>;
1298
- fetchCondition(conditionPda: PublicKey): Promise<Condition | null>;
1299
- fetchVault(collateralMint: PublicKey): Promise<CollateralVault | null>;
1300
- fetchPosition(condition: PublicKey, outcomeIndex: number, owner?: PublicKey): Promise<Position | null>;
1301
- /** YES = outcome index 1, NO = outcome index 0. */
1302
- fetchBothPositions(condition: PublicKey, owner?: PublicKey): Promise<{
1303
- yes: Position | null;
1304
- no: Position | null;
1305
- }>;
1306
- /** Thin wrapper: fetch position for a single outcome token (0=NO, 1=YES). */
1307
- fetchTokenBalance(condition: PublicKey, tokenId: number, owner?: PublicKey): Promise<Position | null>;
1308
- yesMintPda(condition: PublicKey): PublicKey;
1309
- noMintPda(condition: PublicKey): PublicKey;
1310
- mintAuthorityPda(condition: PublicKey): PublicKey;
1311
- collateralVaultPda(collateralMint: PublicKey): PublicKey;
1312
- }
1313
-
1314
- declare class MarketClientV2 {
1315
- private readonly program;
1316
- private readonly provider;
1317
- private readonly programIds;
1318
- readonly configPda: PublicKey;
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
- feeConfigOwner?: PublicKey;
1323
- constructor(program: anchor.Program, provider: anchor.AnchorProvider, programIds: ProgramIds, ownerPubkey: PublicKey);
1324
- get walletPubkey(): PublicKey;
1325
- initialize(admin: PublicKey, oracle: PublicKey, owner?: PublicKey): Promise<Transaction>;
1326
- /**
1327
- * Build createQuestionAdmin transaction (whitelist/admin path — status = Approved immediately).
1328
- * V2: no hookProgram param, uses TOKEN_PROGRAM_ID for YES/NO mints.
1329
- * @param creator - Whitelisted creator (must be in whitelist or be admin/owner)
1330
- * @param payer - Fee payer (pays rent; can differ from creator)
1331
- */
1332
- createQuestionAdmin(params: Omit<CreateQuestionParams, "hookProgram">, oracle: PublicKey, creator?: PublicKey, payer?: PublicKey): Promise<{
1333
- tx: Transaction;
1334
- questionPda: PublicKey;
1335
- conditionPda: PublicKey;
1336
- questionId: Uint8Array;
1337
- }>;
1338
- approveQuestion(questionPda: PublicKey, admin?: PublicKey, payer?: PublicKey): Promise<Transaction>;
1339
- updateConfig(params: {
1340
- newAdmin?: PublicKey;
1341
- newOracle?: PublicKey;
1342
- isPaused?: boolean;
1343
- newConditionalTokensProgram?: PublicKey;
1344
- }, authority?: PublicKey, payer?: PublicKey): Promise<Transaction>;
1345
- /** Set the admin (owner only). Replaces any existing admin. */
1346
- addAdmin(newAdmin: PublicKey, owner?: PublicKey): Promise<Transaction>;
1347
- /** Clear the admin (owner only). Sets admin to default pubkey. */
1348
- removeAdmin(owner?: PublicKey): Promise<Transaction>;
1349
- addToWhitelist(address: PublicKey, authority?: PublicKey, payer?: PublicKey): Promise<Transaction>;
1350
- removeFromWhitelist(address: PublicKey, authority?: PublicKey, payer?: PublicKey): Promise<Transaction>;
1351
- growConfig(owner?: PublicKey, payer?: PublicKey): Promise<Transaction>;
1352
- restoreConfig(snapshot: Buffer, owner?: PublicKey, payer?: PublicKey): Promise<Transaction>;
1353
- bumpPresaleCount(count: number, authority: PublicKey): Promise<Transaction>;
1354
- fetchConfig(): Promise<QuestionMarketConfig | null>;
1355
- fetchQuestion(questionPda: PublicKey): Promise<Question | null>;
1356
- questionPda(questionId: Uint8Array): PublicKey;
1357
- private _parseStatus;
1358
- /**
1359
- * Convenience: fetch YES and NO token balances for a question.
1360
- * Returns null for each if question not approved or position not initialized.
1361
- * Requires ctfClient to be injected (done automatically by XMarketSDKV2).
1362
- */
1363
- fetchQuestionBalances(questionPda: PublicKey, owner: PublicKey): Promise<{
1364
- yes: Position | null;
1365
- no: Position | null;
1366
- }>;
1367
- /**
1368
- * Any user creates a presale + initial buy (question-market::create_presale).
1369
- * Reads agents_rev / company_rev from fee_config.
1370
- *
1371
- * @param feeConfig fee_management fee_config PDA (owner = feeConfigOwner)
1372
- * @param currencyMint collateral token (e.g. USDC)
1373
- * @param presaleIndex config.presale_count — fetch config first or pass 0 for first presale
1374
- */
1375
- createPresale(params: {
1376
- price: anchor.BN;
1377
- startTime: anchor.BN;
1378
- endTime: anchor.BN;
1379
- initialBuyAmount: anchor.BN;
1380
- }, feeConfig: PublicKey, currencyMint: PublicKey, presaleIndex: anchor.BN, creator?: PublicKey, payer?: PublicKey): Promise<{
1381
- tx: Transaction;
1382
- presalePda: PublicKey;
1383
- qtMint: PublicKey;
1384
- }>;
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.
1388
- *
1389
- * @param presalePda the presale account
1390
- * @param contentHash 32-byte hash for question content
1391
- * @param authorizedClob clob program allowed to do CTF transfers
1392
- * @param expirationTime Unix seconds
1393
- * @param creator presale creator pubkey (stored in question)
1394
- * @param currencyMint collateral mint
1395
- */
1396
- approvePresale(params: {
1397
- presalePda: PublicKey;
1398
- contentHash: Uint8Array;
1399
- authorizedClob: PublicKey;
1400
- expirationTime: anchor.BN;
1401
- creator: PublicKey;
1402
- currencyMint: PublicKey;
1403
- /** Revenue distribution — required: approvePresale now distributes 80/10/10 automatically */
1404
- referralAddress: PublicKey;
1405
- companyAddress: PublicKey;
1406
- adminOwner: PublicKey;
1407
- caller?: PublicKey;
1408
- payer?: PublicKey;
1409
- /** Provide an ALT to use VersionedTransaction (required: 31 accounts exceeds legacy tx limit) */
1410
- lookupTable?: AddressLookupTableAccount;
1411
- }): Promise<{
1412
- tx: Transaction | VersionedTransaction;
1413
- questionPda: PublicKey;
1414
- conditionPda: PublicKey;
1415
- marketOraclePda: PublicKey;
1416
- marketOracleVault: PublicKey;
1417
- }>;
1418
- /**
1419
- * Whitelist-only: reject presale so users can refund.
1420
- */
1421
- rejectPresale(presalePda: PublicKey, caller?: PublicKey): Promise<Transaction>;
1422
- /**
1423
- * Whitelist-only: distribute presale vault → 10% agents + 10% company + 80% botmm.
1424
- * Closes presale_vault ATA and presale PDA after distribution; lamports returned to payer.
1425
- */
1426
- collectPresaleRevenue(params: {
1427
- presalePda: PublicKey;
1428
- currencyMint: PublicKey;
1429
- conditionId: Uint8Array;
1430
- referralAddress: PublicKey;
1431
- companyAddress: PublicKey;
1432
- adminOwner: PublicKey;
1433
- caller?: PublicKey;
1434
- payer?: PublicKey;
1435
- }): Promise<Transaction>;
1436
- /**
1437
- * Whitelist-only: snapshot MST supply so holders can claim trading fees.
1438
- * Call after oracle resolves the question.
1439
- */
1440
- collectTradingFee(marketOraclePda: PublicKey, qtMint: PublicKey, caller?: PublicKey): Promise<Transaction>;
1441
- }
1442
-
1443
- /**
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 {
1452
- private readonly program;
1453
- private readonly provider;
1454
- private readonly programIds;
1455
- private readonly networkConfig;
1456
- /** Injected by XMarketSDKV2 after construction — enables auto fee distribution */
1457
- feeClient?: FeeManagementClient;
1458
- feeConfigOwner?: PublicKey;
1459
- /** Injected by XMarketSDKV2 — enables auto-derive of marketOracleVault for presale markets */
1460
- ctfClient?: CtfClientV2;
1461
- qmConfigPda?: PublicKey;
1462
- /** Cached company_address from fee_config to avoid repeated RPC calls */
1463
- private _companyAddress?;
1464
- /** Cached referral_vault from fee_config */
1465
- private _referralVault?;
1466
- /** Cache: conditionPda.toBase58() → marketOracleVault ATA */
1467
- private _marketOracleVaultCache;
1468
- /** ALT cache: condition.toBase58() → loaded ALT account */
1469
- private _altCache;
1470
- constructor(program: anchor.Program, provider: anchor.AnchorProvider, programIds: ProgramIds, networkConfig: {
1471
- defaultCollateral: {
1472
- mint: PublicKey;
1473
- };
1474
- });
1475
- private companyAddress;
1476
- private referralVault;
1477
- /**
1478
- * Derive marketOracleVault ATA for a condition, cached per condition.
1479
- * Works for presale markets (market_oracle initialized by approvePresale).
1480
- * Returns undefined if ctfClient/qmConfigPda not injected or marketOracle not configured.
1481
- */
1482
- private getMarketOracleVault;
1483
- /**
1484
- * Returns a createATA ix for the oracle vault when:
1485
- * - takerFee > 0
1486
- * - marketFeeOverride exists for the condition
1487
- * - oracle vault ATA is not yet initialized
1488
- * Idempotent — safe to call every tx; returns null if vault already exists.
1489
- */
1490
- private buildInitOracleVaultIfNeeded;
1491
- get walletPubkey(): PublicKey;
1492
- /**
1493
- * Get or create an ALT for a condition.
1494
- * V2: no hook accounts — TOKEN_2022_PROGRAM_ID and hook PDAs are excluded.
1495
- * Includes order_record PDAs for taker + all makers so match tx stays under 1232 bytes.
1496
- */
1497
- ensureAlt(condition: PublicKey, collateralMint: PublicKey, takerSigned: SignedOrder, makers: SignedOrder[]): Promise<AddressLookupTableAccount>;
1498
- private _sendLegacyTxSig;
1499
- private _sendLegacyTx;
1500
- private _ensureClobOutcomeAtas;
1501
- /**
1502
- * Send a match transaction as versioned (v0) with optional ALT.
1503
- * Both operator wallet and payer (this.provider.wallet) sign.
1504
- */
1505
- sendMatchTx(instructions: TransactionInstruction[], lookupTable?: AddressLookupTableAccount, whitelistedWallet?: anchor.Wallet): Promise<string>;
1506
- configPda(): PublicKey;
1507
- /**
1508
- * Register a signed order on-chain.
1509
- * Sends Ed25519 precompile ix + register_order ix in one legacy tx.
1510
- * Called at match time (engine-triggered), not at order placement.
1511
- */
1512
- registerOrder(signed: SignedOrder): Promise<string>;
1513
- /** Register only if the PDA doesn't exist yet (idempotent). */
1514
- private registerOrderIfNeeded;
1515
- /**
1516
- * Build a legacy Transaction to register a CollectFeeOrder on-chain.
1517
- * Must be signed and sent before calling buildBatchCollectRedeemEarlyTx.
1518
- *
1519
- * Flow: [Ed25519 ix (1 user sig) + register_collect_fee_order ix]
1520
- * Caller signs with payer keypair and sends.
1521
- */
1522
- buildRegisterCollectFeeOrderTx(signedOrder: SignedCollectFeeOrder, payer: PublicKey): Promise<Transaction>;
1523
- /**
1524
- * Register a CollectFeeOrder on-chain and send immediately (operator-signed flow).
1525
- * Idempotent — skips if PDA already exists.
1526
- */
1527
- registerCollectFeeOrderIfNeeded(signedOrder: SignedCollectFeeOrder): Promise<void>;
1528
- /** Cancel an order — closes its OrderRecord PDA and returns rent to maker. */
1529
- cancelOrder(nonce: anchor.BN): Promise<TxResult>;
1530
- initialize(operators: PublicKey[], feeRecipient: PublicKey, feeRateBps: number): Promise<TxResult>;
1531
- addOperator(operator: PublicKey): Promise<TxResult>;
1532
- removeOperator(operator: PublicKey): Promise<TxResult>;
1533
- setPaused(paused: boolean): Promise<TxResult>;
1534
- forceResetClob(programData: PublicKey, newAdmin: PublicKey, newOperators: PublicKey[], newFeeRecipient: PublicKey, newFeeRateBps: number): Promise<TxResult>;
1535
- /**
1536
- * Build match_complementary instruction (no Ed25519 — OrderRecord PDAs used).
1537
- * V2: no hook accounts in remainingAccounts.
1538
- *
1539
- * remaining_accounts layout:
1540
- * [seller, order_record, seller_token, seller_collateral, seller_position, sell_status] × N
1541
- * [feeManagement, fee_config, mkt_override, company_ata, oracle_vault, referral_vault] (when fee > 0)
1542
- */
1543
- buildMatchComplementaryIxs(takerSigned: SignedOrder, makersSigned: SignedOrder[], collateralMint: PublicKey, feeRecipient: PublicKey, operator: PublicKey, opts?: {
1544
- marketOracleVault?: PublicKey;
1545
- fillAmount?: anchor.BN;
1546
- }, useTakerPrice?: boolean, skipCrossingCheck?: boolean): Promise<TransactionInstruction[]>;
1547
- /**
1548
- * COMPLEMENTARY: 1 taker (BUY) + N makers (SELL), same tokenId.
1549
- * Phase 1: register taker + all makers in parallel.
1550
- * Phase 2: 1 atomic match tx.
1551
- */
1552
- private matchComplementary;
1553
- /**
1554
- * 1 SELL taker vs N BUY makers.
1555
- * Program now supports SELL-as-taker natively → 1 instruction with all BUY makers
1556
- * in remaining_accounts (same structure as BUY taker case).
1557
- */
1558
- private matchComplementarySellVsMultiBuy;
1559
- /**
1560
- * MINT: 1 YES buyer (taker) + N NO buyers (makers).
1561
- * V2: no hook accounts in remainingAccounts.
1562
- *
1563
- * remaining_accounts per NO maker (6):
1564
- * [maker, order_record, buyer_no_token, buyer_no_collateral, buyer_no_position, no_order_status]
1565
- */
1566
- private _buildMintIx;
1567
- private matchMintOrders;
1568
- /**
1569
- * MERGE: 1 YES seller (taker) + N NO sellers (makers).
1570
- * V2: no hook accounts in remainingAccounts.
1571
- *
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.
1575
- */
1576
- private _buildMergeIx;
1577
- private matchMergeOrders;
1578
- /**
1579
- * Auto-detect match type and execute 2-phase:
1580
- * Phase 1 — register all orders (taker + makers) on-chain in parallel.
1581
- * Phase 2 — 1 atomic match transaction.
1582
- *
1583
- * Detection (pure, no RPC):
1584
- * taker.tokenId === makers[0].tokenId:
1585
- * taker BUY + all makers SELL → COMPLEMENTARY
1586
- * taker.tokenId !== makers[0].tokenId + all BUY → MINT
1587
- * taker.tokenId !== makers[0].tokenId + all SELL → MERGE
1588
- *
1589
- * @param opts.marketOracleVault Oracle vault ATA for presale markets.
1590
- * Omit for admin markets (payer used as placeholder).
1591
- */
1592
- matchOrders(taker: SignedOrder, makers: SignedOrder[], opts?: {
1593
- marketOracleVault?: PublicKey;
1594
- operatorWallet?: anchor.Wallet;
1595
- }): Promise<TxResult>;
1596
- /**
1597
- * High-level match: caller passes price + quantity + keypair — SDK builds,
1598
- * signs, and submits in one call. No manual amount calculation needed.
1599
- */
1600
- matchOrdersFromPrice(taker: {
1601
- keypair: {
1602
- publicKey: PublicKey;
1603
- secretKey: Uint8Array;
1604
- };
1605
- condition: PublicKey;
1606
- tokenId: number;
1607
- side: 0 | 1;
1608
- price: number;
1609
- quantity: number;
1610
- nonce?: BN;
1611
- expiry?: BN;
1612
- fee?: BN;
1613
- taker?: PublicKey;
1614
- }, makers: Array<{
1615
- keypair: {
1616
- publicKey: PublicKey;
1617
- secretKey: Uint8Array;
1618
- };
1619
- condition: PublicKey;
1620
- tokenId: number;
1621
- side: 0 | 1;
1622
- price: number;
1623
- quantity: number;
1624
- nonce?: BN;
1625
- expiry?: BN;
1626
- fee?: BN;
1627
- taker?: PublicKey;
1628
- }>, decimals?: number, opts?: {
1629
- marketOracleVault?: PublicKey;
1630
- operatorWallet?: anchor.Wallet;
1631
- }): Promise<TxResult>;
1632
- /**
1633
- * Build an unsigned VersionedTransaction for a set of match instructions.
1634
- */
1635
- private _buildUnsignedVtx;
1636
- /**
1637
- * Build unsigned VersionedTransaction(s) for matching orders.
1638
- * V2: no hookClient, no hook init ixs prepended.
1639
- *
1640
- * @param operator - Whitelisted CLOB operator pubkey (must sign)
1641
- * @param payer - Fee payer pubkey (must sign, pays tx fee + rent)
1642
- */
1643
- buildMatchOrdersTx(taker: SignedOrder, makers: SignedOrder[], operator: PublicKey, payer: PublicKey, opts?: {
1644
- marketOracleVault?: PublicKey;
1645
- }): Promise<VersionedTransaction>;
1646
- /**
1647
- * Build VersionedTransaction for batchCollectRedeemEarly.
1648
- * V2: no hook accounts in remainingAccounts, uses TOKEN_PROGRAM_ID for outcome mints.
1649
- *
1650
- * @param signedOrders - Array of { order, signature } (used to derive record PDAs)
1651
- * @param condition - Market condition PDA
1652
- * @param outcomeIndex - 0 = NO wins, 1 = YES wins
1653
- * @param operator - Whitelisted operator pubkey (must sign)
1654
- * @param payer - Fee payer pubkey (must sign)
1655
- * @param opts.marketOracleVault - MarketOracle vault for fee distribution
1656
- */
1657
- buildBatchCollectRedeemEarlyTx(signedOrders: SignedCollectFeeOrder[], condition: PublicKey, outcomeIndex: 0 | 1, operator: PublicKey, payer: PublicKey, opts?: {
1658
- marketOracleVault?: PublicKey;
1659
- lookupTable?: AddressLookupTableAccount;
1660
- }): Promise<VersionedTransaction>;
1661
- /**
1662
- * Build a Transaction to register a RedeemFeeOrder on-chain (Ed25519 verify + PDA).
1663
- * Must be sent before calling buildBatchRedeemWithFeeTx / buildBatchMergeWithFeeTx.
1664
- */
1665
- buildRegisterRedeemFeeOrderTx(signedOrder: SignedRedeemFeeOrder, payer: PublicKey): Promise<anchor.web3.Transaction>;
1666
- /**
1667
- * Build a VersionedTransaction for batchRedeemWithFee.
1668
- * V2: no hook accounts, uses TOKEN_PROGRAM_ID for outcome mints.
1669
- *
1670
- * Each pair has a YES order + NO order for the same user (same signer or different).
1671
- * Prerequisite: each order's RedeemFeeOrderRecord must be registered via buildRegisterRedeemFeeOrderTx.
1672
- */
1673
- buildBatchRedeemWithFeeTx(orderPairs: RedeemFeeOrderPair[], condition: PublicKey, operator: PublicKey, payer: PublicKey, opts?: {
1674
- marketOracleVault?: PublicKey;
1675
- lookupTable?: AddressLookupTableAccount;
1676
- }): Promise<VersionedTransaction>;
1677
- /**
1678
- * Build a VersionedTransaction for batchMergeWithFee (pre-resolution merge with fee).
1679
- * V2: no hook accounts, uses TOKEN_PROGRAM_ID for outcome mints.
1680
- *
1681
- * Prerequisite: each order's RedeemFeeOrderRecord must be registered via buildRegisterRedeemFeeOrderTx.
1682
- */
1683
- buildBatchMergeWithFeeTx(orderPairs: RedeemFeeOrderPair[], condition: PublicKey, operator: PublicKey, payer: PublicKey, opts?: {
1684
- marketOracleVault?: PublicKey;
1685
- lookupTable?: AddressLookupTableAccount;
1686
- }): Promise<VersionedTransaction>;
1687
- /**
1688
- * Build ALT for batchCollectRedeemEarly — includes per-user accounts so all
1689
- * remaining_accounts fit as 1-byte ALT indices instead of 32-byte inline addresses.
1690
- * V2: no hook program or hook PDAs included.
1691
- */
1692
- buildAltForCollectBatch(condition: PublicKey, payer: PublicKey, collateralMint: PublicKey, signedOrders: SignedCollectFeeOrder[], outcomeIndex: 0 | 1): Promise<AddressLookupTableAccount>;
1693
- /**
1694
- * Build ALT with static accounts for a condition — no order-specific PDAs needed.
1695
- * V2: no hook program or hook PDAs included.
1696
- */
1697
- buildAltForCondition(condition: PublicKey, _payer: PublicKey, collateralMint?: PublicKey): Promise<AddressLookupTableAccount>;
1698
- fetchConfig(): Promise<ClobConfig | null>;
1699
- fetchOrderStatus(maker: PublicKey, nonce: anchor.BN): Promise<OrderStatus | null>;
1700
- fetchOrderRecord(maker: PublicKey, nonce: anchor.BN): Promise<{
1701
- maker: PublicKey;
1702
- condition: PublicKey;
1703
- tokenId: number;
1704
- side: number;
1705
- makerAmount: anchor.BN;
1706
- takerAmount: anchor.BN;
1707
- nonce: anchor.BN;
1708
- expiry: anchor.BN;
1709
- fee: anchor.BN;
1710
- taker: PublicKey;
1711
- signer: PublicKey;
1712
- } | null>;
1713
- }
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
-
1764
1155
  declare const SEEDS: {
1765
1156
  readonly config: Buffer<ArrayBuffer>;
1766
1157
  readonly question: Buffer<ArrayBuffer>;
@@ -1774,8 +1165,6 @@ declare const SEEDS: {
1774
1165
  readonly reporter: Buffer<ArrayBuffer>;
1775
1166
  readonly result: Buffer<ArrayBuffer>;
1776
1167
  readonly ctfConfig: Buffer<ArrayBuffer>;
1777
- readonly hookConfig: Buffer<ArrayBuffer>;
1778
- readonly extraAccountMetas: Buffer<ArrayBuffer>;
1779
1168
  readonly clobConfig: Buffer<ArrayBuffer>;
1780
1169
  readonly order: Buffer<ArrayBuffer>;
1781
1170
  readonly feeConfig: Buffer<ArrayBuffer>;
@@ -1808,8 +1197,6 @@ declare class PDA {
1808
1197
  static oracleConfig(owner: PublicKey, programIds: Pick<ProgramIds, "oracle">): [PublicKey, number];
1809
1198
  static reporter(oracleConfig: PublicKey, reporterAddress: PublicKey, programIds: Pick<ProgramIds, "oracle">): [PublicKey, number];
1810
1199
  static questionResult(oracleConfig: PublicKey, questionId: Uint8Array, programIds: Pick<ProgramIds, "oracle">): [PublicKey, number];
1811
- static hookConfig(programIds: Pick<ProgramIds, "hook">): [PublicKey, number];
1812
- static extraAccountMetaList(mint: PublicKey, programIds: Pick<ProgramIds, "hook">): [PublicKey, number];
1813
1200
  static clobConfig(programIds: Pick<ProgramIds, "clobExchange">): [PublicKey, number];
1814
1201
  static orderStatus(maker: PublicKey, nonce: BN, programIds: Pick<ProgramIds, "clobExchange">): [PublicKey, number];
1815
1202
  static orderRecord(maker: PublicKey, nonce: BN, programIds: Pick<ProgramIds, "clobExchange">): [PublicKey, number];
@@ -2023,7 +1410,7 @@ declare function detectMatchType(a: Order | SignedOrder, b: Order | SignedOrder)
2023
1410
  /** Maximum u64 — approve "unlimited" amount. */
2024
1411
  declare const MAX_APPROVE_AMOUNT: BN;
2025
1412
  /**
2026
- * Build a Transaction that creates YES and NO Token-2022 ATAs for a user
1413
+ * Build a Transaction that creates YES and NO ATAs for a user
2027
1414
  * (idempotent — safe to call even if they already exist).
2028
1415
  *
2029
1416
  * Required signer: payer (fee payer). No user signature needed.
@@ -2055,4 +1442,4 @@ declare function buildApproveCollateralTx(collateralMint: PublicKey, signer: Pub
2055
1442
  */
2056
1443
  declare function buildApproveAllOutcomeTokensTx(condition: PublicKey, signer: PublicKey, payer: PublicKey, delegate: PublicKey, programIds: ProgramIds, amount?: BN): Transaction;
2057
1444
 
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 };
1445
+ export { AccountNotFoundError, AdminClient, type AdminConfigInfo, type ClaimRecordInfo, ClobClient, type ClobConfig, type CollateralConfig, type CollateralVault, type CollectFeeOrder, type Condition, type CreateQuestionParams, CtfClient, type CtfConfig, DisputeClient, type DisputeConfigInfo, type DisputeMarketInfo, FEE_DENOMINATOR, FeeManagementClient, type FeesShareEstimate, IX_SYSVAR, InvalidParamError, MAX_APPROVE_AMOUNT, MarketClient, MarketOracleClient, type MarketOracleInfo, type MatchType, type NetworkConfig, type NetworkName, OracleClient, type OracleConfig, type Order, type OrderStatus, PDA, type Position, PresaleClient, type PresaleInfo, type ProgramIds, type Question, type QuestionFee, type QuestionMarketConfig, type QuestionResult, QuestionStatus, type RedeemFeeOrder, type RedeemFeeOrderPair, ReferralClient, type ReferralConfigInfo, SEEDS, type SignedCollectFeeOrder, type SignedOrder, type SignedRedeemFeeOrder, type TxResult, UnauthorizedError, type UserBuyRecord, type UserClaimRecord, type UserDisputeInfo, XMarketError, XMarketSDK, buildApproveAllOutcomeTokensTx, buildApproveCollateralTx, buildBatchedCollectFeeEd25519Instruction, buildBatchedEd25519Instruction, buildBatchedRedeemFeeEd25519Instruction, buildCreateUserAtasTx, buildOrder, buildOrderFromPrice, deserializeSignedOrder, detectMatchType, generateContentHash, generateQuestionId, getOrderSignBytes, orderAmountsFromPrice, serializeCollectFeeOrderToBytes, serializeOrderToBytes, serializeRedeemFeeOrderToBytes, serializeSignedOrder, signOrder, signOrderWithKeypair, verifySignedOrder };