@theliem/xmarket-sdk 3.2.0 → 3.3.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.mts +66 -90
- package/dist/index.d.ts +66 -90
- package/dist/index.js +11322 -368
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11322 -360
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -5
- package/dist/clob_exchange-MQF4NI27.json +0 -1815
- package/dist/conditional_tokens-X53GZYAY.json +0 -2215
- package/dist/fee_management-VGF77YXG.json +0 -1337
- package/dist/hook-THBRGUM6.json +0 -481
- package/dist/market_oracle-E6UUARGR.json +0 -699
- package/dist/oracle-O53KMXDK.json +0 -663
- package/dist/presale-D7EQAQDZ.json +0 -1657
- package/dist/question_market-CD4WRZLT.json +0 -2535
- package/src/idls/clob_exchange.json +0 -1815
- package/src/idls/conditional_tokens.json +0 -2215
- package/src/idls/fee_management.json +0 -1337
- package/src/idls/hook.json +0 -481
- package/src/idls/market_oracle.json +0 -699
- package/src/idls/oracle.json +0 -663
- package/src/idls/presale.json +0 -1657
- package/src/idls/question_market.json +0 -2535
package/dist/index.d.mts
CHANGED
|
@@ -155,15 +155,10 @@ interface ClobConfig {
|
|
|
155
155
|
isPaused: boolean;
|
|
156
156
|
bump: number;
|
|
157
157
|
}
|
|
158
|
-
interface ClobWhitelistEntry {
|
|
159
|
-
address: PublicKey;
|
|
160
|
-
bump: number;
|
|
161
|
-
}
|
|
162
158
|
interface OrderStatus {
|
|
163
159
|
maker: PublicKey;
|
|
164
160
|
nonce: BN;
|
|
165
161
|
filledAmount: BN;
|
|
166
|
-
isCancelled: boolean;
|
|
167
162
|
bump: number;
|
|
168
163
|
}
|
|
169
164
|
/** Per-question fee rates, all out of FEE_DENOMINATOR (1_000_000). E.g. 2_000 = 0.2% */
|
|
@@ -436,6 +431,8 @@ declare class MarketClient {
|
|
|
436
431
|
removeAdmin(owner?: PublicKey): Promise<Transaction>;
|
|
437
432
|
addToWhitelist(address: PublicKey, authority?: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
438
433
|
removeFromWhitelist(address: PublicKey, authority?: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
434
|
+
growConfig(owner?: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
435
|
+
restoreConfig(snapshot: Buffer, owner?: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
439
436
|
fetchConfig(): Promise<QuestionMarketConfig | null>;
|
|
440
437
|
fetchQuestion(questionPda: PublicKey): Promise<Question | null>;
|
|
441
438
|
questionPda(questionId: Uint8Array): PublicKey;
|
|
@@ -551,123 +548,101 @@ declare class ClobClient {
|
|
|
551
548
|
get walletPubkey(): PublicKey;
|
|
552
549
|
/**
|
|
553
550
|
* Get or create an ALT for a condition.
|
|
554
|
-
*
|
|
555
|
-
* Subsequent calls for same condition: returns cached ALT instantly.
|
|
556
|
-
* BE devs never interact with this — called automatically by matchOrders.
|
|
551
|
+
* Includes order_record PDAs for taker + all makers so match tx stays under 1232 bytes.
|
|
557
552
|
*/
|
|
558
|
-
ensureAlt(condition: PublicKey, collateralMint: PublicKey,
|
|
553
|
+
ensureAlt(condition: PublicKey, collateralMint: PublicKey, takerSigned: SignedOrder, makers: SignedOrder[]): Promise<AddressLookupTableAccount>;
|
|
554
|
+
private _sendLegacyTxSig;
|
|
559
555
|
private _sendLegacyTx;
|
|
560
556
|
/**
|
|
561
|
-
* Send a match transaction as versioned (v0).
|
|
562
|
-
*
|
|
563
|
-
* stay under the 1232-byte limit — required for match_complementary which
|
|
564
|
-
* has ~25 accounts + 2 Ed25519 precompile instructions (~1697 bytes raw).
|
|
565
|
-
*
|
|
566
|
-
* If `whitelistedWallet` is provided and differs from `this.provider.wallet`,
|
|
567
|
-
* both wallets sign the transaction (whitelisted operator + payer).
|
|
557
|
+
* Send a match transaction as versioned (v0) with optional ALT.
|
|
558
|
+
* Both operator wallet and payer (this.provider.wallet) sign.
|
|
568
559
|
*/
|
|
569
560
|
sendMatchTx(instructions: TransactionInstruction[], lookupTable?: AddressLookupTableAccount, whitelistedWallet?: anchor.Wallet): Promise<string>;
|
|
570
|
-
/** PDA for a CLOB whitelist entry. */
|
|
571
|
-
whitelistEntryPda(address: PublicKey): PublicKey;
|
|
572
561
|
configPda(): PublicKey;
|
|
573
|
-
/**
|
|
562
|
+
/**
|
|
563
|
+
* Register a signed order on-chain.
|
|
564
|
+
* Sends Ed25519 precompile ix + register_order ix in one legacy tx.
|
|
565
|
+
* Called at match time (engine-triggered), not at order placement.
|
|
566
|
+
*/
|
|
567
|
+
registerOrder(signed: SignedOrder): Promise<string>;
|
|
568
|
+
/** Register only if the PDA doesn't exist yet (idempotent). */
|
|
569
|
+
private registerOrderIfNeeded;
|
|
570
|
+
/** Cancel an order — closes its OrderRecord PDA and returns rent to maker. */
|
|
571
|
+
cancelOrder(nonce: anchor.BN): Promise<TxResult>;
|
|
574
572
|
initialize(operators: PublicKey[], feeRecipient: PublicKey, feeRateBps: number): Promise<TxResult>;
|
|
575
|
-
/** Admin adds an operator to the whitelist. */
|
|
576
573
|
addOperator(operator: PublicKey): Promise<TxResult>;
|
|
577
|
-
/** Admin removes an operator from the whitelist. */
|
|
578
574
|
removeOperator(operator: PublicKey): Promise<TxResult>;
|
|
579
|
-
/** Admin pause/unpause the CLOB. */
|
|
580
575
|
setPaused(paused: boolean): Promise<TxResult>;
|
|
581
|
-
/**
|
|
582
|
-
* Maker cancels their own order.
|
|
583
|
-
* OrderStatus PDA is marked cancelled — any future fill rejected.
|
|
584
|
-
*/
|
|
585
|
-
cancelOrder(nonce: anchor.BN): Promise<TxResult>;
|
|
586
|
-
/**
|
|
587
|
-
* Emergency reset of CLOB config (upgrade authority only).
|
|
588
|
-
*/
|
|
589
576
|
forceResetClob(programData: PublicKey, newAdmin: PublicKey, newOperators: PublicKey[], newFeeRecipient: PublicKey, newFeeRateBps: number): Promise<TxResult>;
|
|
590
577
|
/**
|
|
591
|
-
*
|
|
578
|
+
* Build match_complementary instruction (no Ed25519 — OrderRecord PDAs used).
|
|
592
579
|
*
|
|
593
|
-
*
|
|
594
|
-
*
|
|
595
|
-
*
|
|
596
|
-
*
|
|
597
|
-
*
|
|
598
|
-
* remaining_accounts: [hook×3] [seller×5 × N]
|
|
599
|
-
*/
|
|
600
|
-
/** Build Ed25519 + matchComplementary instructions without sending.
|
|
601
|
-
*
|
|
602
|
-
* If `buySigned.order.fee > 0` and `feeClient` + `feeConfigOwner` are wired in,
|
|
603
|
-
* automatically appends 5 fee_management remaining_accounts so the program CPIs
|
|
604
|
-
* to distribute_fee internally. No manual `feeDistribute` param needed.
|
|
580
|
+
* remaining_accounts layout:
|
|
581
|
+
* [seller, order_record, seller_token, seller_collateral, seller_position, sell_status] × N
|
|
582
|
+
* [extraAccountMetaList, hookConfig, hookProgram]
|
|
583
|
+
* [feeManagement, fee_config, mkt_override, company_ata, oracle_vault] (when fee > 0)
|
|
605
584
|
*/
|
|
606
|
-
buildMatchComplementaryIxs(
|
|
585
|
+
buildMatchComplementaryIxs(takerSigned: SignedOrder, makersSigned: SignedOrder[], collateralMint: PublicKey, feeRecipient: PublicKey, operator: PublicKey, opts?: {
|
|
607
586
|
marketOracleVault?: PublicKey;
|
|
587
|
+
fillAmount?: anchor.BN;
|
|
608
588
|
}): Promise<TransactionInstruction[]>;
|
|
589
|
+
/**
|
|
590
|
+
* COMPLEMENTARY: 1 taker (BUY) + N makers (SELL), same tokenId.
|
|
591
|
+
* Phase 1: register taker + all makers in parallel.
|
|
592
|
+
* Phase 2: 1 atomic match tx.
|
|
593
|
+
*/
|
|
609
594
|
private matchComplementary;
|
|
610
595
|
/**
|
|
611
|
-
* MINT
|
|
596
|
+
* MINT: 1 YES buyer (taker) + N NO buyers (makers).
|
|
597
|
+
* Phase 1: register taker + all NO makers in parallel.
|
|
598
|
+
* Phase 2: 1 atomic match tx.
|
|
612
599
|
*
|
|
613
|
-
*
|
|
614
|
-
*
|
|
615
|
-
* ix[1+i] Ed25519(maker_i/NO buyer)
|
|
616
|
-
* ix[N+1] match_mint_orders(yesNonce, makerNonces[])
|
|
617
|
-
*
|
|
618
|
-
* remaining_accounts: [maker×5 × N] (no hook accounts — mint_to doesn't fire hook)
|
|
600
|
+
* remaining_accounts per NO maker (5):
|
|
601
|
+
* [order_record, buyer_no_token, buyer_no_collateral, buyer_no_position, no_order_status]
|
|
619
602
|
*/
|
|
620
603
|
private matchMintOrders;
|
|
621
604
|
/**
|
|
622
|
-
* MERGE
|
|
623
|
-
*
|
|
624
|
-
*
|
|
625
|
-
* ix[0] Ed25519(taker/YES seller)
|
|
626
|
-
* ix[1+i] Ed25519(maker_i/NO seller)
|
|
627
|
-
* ix[N+1] match_merge_orders(yesNonce, makerNonces[])
|
|
605
|
+
* MERGE: 1 YES seller (taker) + N NO sellers (makers).
|
|
606
|
+
* Phase 1: register taker + all NO makers in parallel.
|
|
607
|
+
* Phase 2: 1 atomic match tx.
|
|
628
608
|
*
|
|
629
|
-
* remaining_accounts
|
|
609
|
+
* remaining_accounts per NO maker (5):
|
|
610
|
+
* [order_record, seller_no_token, seller_no_collateral, seller_no_position, no_order_status]
|
|
611
|
+
* After all makers, optional 5 fee accounts.
|
|
630
612
|
*/
|
|
631
613
|
private matchMergeOrders;
|
|
632
614
|
/**
|
|
633
|
-
* Auto-detect match type and execute
|
|
634
|
-
*
|
|
635
|
-
*
|
|
636
|
-
* taker.tokenId === makers[0].tokenId: taker BUY + all makers SELL → COMPLEMENTARY
|
|
637
|
-
* taker.tokenId !== makers[0].tokenId + taker BUY + all makers BUY → MINT
|
|
638
|
-
* taker.tokenId !== makers[0].tokenId + taker SELL + all makers SELL → MERGE
|
|
639
|
-
* Otherwise → throws InvalidParamError
|
|
615
|
+
* Auto-detect match type and execute 2-phase:
|
|
616
|
+
* Phase 1 — register all orders (taker + makers) on-chain in parallel.
|
|
617
|
+
* Phase 2 — 1 atomic match transaction.
|
|
640
618
|
*
|
|
641
|
-
*
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
*
|
|
645
|
-
*
|
|
646
|
-
* feeRecipient and collateralMint are derived from on-chain config.
|
|
647
|
-
* Fee distribution (distribute_fee CPI) fires automatically when order.fee > 0.
|
|
619
|
+
* Detection (pure, no RPC):
|
|
620
|
+
* taker.tokenId === makers[0].tokenId:
|
|
621
|
+
* taker BUY + all makers SELL → COMPLEMENTARY
|
|
622
|
+
* taker.tokenId !== makers[0].tokenId + all BUY → MINT
|
|
623
|
+
* taker.tokenId !== makers[0].tokenId + all SELL → MERGE
|
|
648
624
|
*
|
|
649
|
-
* @param opts.marketOracleVault
|
|
650
|
-
*
|
|
651
|
-
* For admin markets (is_admin=true) omit — payer is used as placeholder (no transfer).
|
|
625
|
+
* @param opts.marketOracleVault Oracle vault ATA for presale markets.
|
|
626
|
+
* Omit for admin markets (payer used as placeholder).
|
|
652
627
|
*/
|
|
653
628
|
matchOrders(taker: SignedOrder, makers: SignedOrder[], opts?: {
|
|
654
629
|
marketOracleVault?: PublicKey;
|
|
655
630
|
}): Promise<TxResult>;
|
|
656
|
-
/** Add an address to the CLOB whitelist (owner only). */
|
|
657
|
-
addToWhitelist(address: PublicKey): Promise<TxResult>;
|
|
658
|
-
/** Batch-add addresses to the CLOB whitelist (owner only). All PDAs created in one tx. */
|
|
659
|
-
addToWhitelistBatch(addresses: PublicKey[]): Promise<TxResult>;
|
|
660
|
-
/** Remove an address from the CLOB whitelist (owner only). */
|
|
661
|
-
removeFromWhitelist(address: PublicKey, rentReceiver?: PublicKey): Promise<TxResult>;
|
|
662
|
-
/** Fetch a whitelist entry PDA (returns null if address is not whitelisted). */
|
|
663
|
-
fetchWhitelistEntry(address: PublicKey): Promise<ClobWhitelistEntry | null>;
|
|
664
|
-
/** Check if an address is on the CLOB whitelist. */
|
|
665
|
-
isWhitelisted(address: PublicKey): Promise<boolean>;
|
|
666
|
-
/** Fetch all whitelisted addresses (scans all ClobWhitelistEntry accounts). */
|
|
667
|
-
fetchWhitelist(): Promise<PublicKey[]>;
|
|
668
631
|
fetchConfig(): Promise<ClobConfig | null>;
|
|
669
632
|
fetchOrderStatus(maker: PublicKey, nonce: anchor.BN): Promise<OrderStatus | null>;
|
|
670
|
-
|
|
633
|
+
fetchOrderRecord(maker: PublicKey, nonce: anchor.BN): Promise<{
|
|
634
|
+
maker: PublicKey;
|
|
635
|
+
condition: PublicKey;
|
|
636
|
+
tokenId: number;
|
|
637
|
+
side: number;
|
|
638
|
+
makerAmount: anchor.BN;
|
|
639
|
+
takerAmount: anchor.BN;
|
|
640
|
+
nonce: anchor.BN;
|
|
641
|
+
expiry: anchor.BN;
|
|
642
|
+
fee: anchor.BN;
|
|
643
|
+
taker: PublicKey;
|
|
644
|
+
signer: PublicKey;
|
|
645
|
+
} | null>;
|
|
671
646
|
}
|
|
672
647
|
|
|
673
648
|
interface PresaleInfo {
|
|
@@ -717,7 +692,7 @@ declare class PresaleClient {
|
|
|
717
692
|
* Refund: burn user's MST and return USDC.
|
|
718
693
|
* Only callable when presale status = Rejected.
|
|
719
694
|
*/
|
|
720
|
-
refund(presalePda: PublicKey, user?: PublicKey): Promise<Transaction>;
|
|
695
|
+
refund(presalePda: PublicKey, user?: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
721
696
|
fetchPresale(presalePda: PublicKey): Promise<PresaleInfo | null>;
|
|
722
697
|
fetchUserBuyRecord(presalePda: PublicKey, user: PublicKey): Promise<UserBuyRecord | null>;
|
|
723
698
|
}
|
|
@@ -827,6 +802,7 @@ declare class PDA {
|
|
|
827
802
|
static extraAccountMetaList(mint: PublicKey, programIds: Pick<ProgramIds, "hook">): [PublicKey, number];
|
|
828
803
|
static clobConfig(programIds: Pick<ProgramIds, "clobExchange">): [PublicKey, number];
|
|
829
804
|
static orderStatus(maker: PublicKey, nonce: BN, programIds: Pick<ProgramIds, "clobExchange">): [PublicKey, number];
|
|
805
|
+
static orderRecord(maker: PublicKey, nonce: BN, programIds: Pick<ProgramIds, "clobExchange">): [PublicKey, number];
|
|
830
806
|
static feeConfig(owner: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
|
|
831
807
|
static questionFee(conditionPda: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
|
|
832
808
|
static marketFeeOverride(conditionPda: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
|
|
@@ -969,4 +945,4 @@ declare function buildApproveCollateralTx(collateralMint: PublicKey, signer: Pub
|
|
|
969
945
|
*/
|
|
970
946
|
declare function buildApproveAllOutcomeTokensTx(condition: PublicKey, signer: PublicKey, payer: PublicKey, delegate: PublicKey, programIds: ProgramIds, amount?: BN): Transaction;
|
|
971
947
|
|
|
972
|
-
export { AccountNotFoundError, ClobClient, type ClobConfig, type
|
|
948
|
+
export { AccountNotFoundError, ClobClient, type ClobConfig, type CollateralConfig, type CollateralVault, type Condition, type CreateQuestionParams, CtfClient, type CtfConfig, FEE_DENOMINATOR, FeeManagementClient, HookClient, type HookConfig, 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, SEEDS, type SignedOrder, type TxResult, UnauthorizedError, type UserBuyRecord, type UserClaimRecord, XMarketError, XMarketSDK, buildApproveAllOutcomeTokensTx, buildApproveCollateralTx, buildBatchedEd25519Instruction, buildOrder, deserializeSignedOrder, detectMatchType, generateContentHash, generateQuestionId, getOrderSignBytes, serializeOrderToBytes, serializeSignedOrder, signOrder, signOrderWithKeypair, verifySignedOrder };
|
package/dist/index.d.ts
CHANGED
|
@@ -155,15 +155,10 @@ interface ClobConfig {
|
|
|
155
155
|
isPaused: boolean;
|
|
156
156
|
bump: number;
|
|
157
157
|
}
|
|
158
|
-
interface ClobWhitelistEntry {
|
|
159
|
-
address: PublicKey;
|
|
160
|
-
bump: number;
|
|
161
|
-
}
|
|
162
158
|
interface OrderStatus {
|
|
163
159
|
maker: PublicKey;
|
|
164
160
|
nonce: BN;
|
|
165
161
|
filledAmount: BN;
|
|
166
|
-
isCancelled: boolean;
|
|
167
162
|
bump: number;
|
|
168
163
|
}
|
|
169
164
|
/** Per-question fee rates, all out of FEE_DENOMINATOR (1_000_000). E.g. 2_000 = 0.2% */
|
|
@@ -436,6 +431,8 @@ declare class MarketClient {
|
|
|
436
431
|
removeAdmin(owner?: PublicKey): Promise<Transaction>;
|
|
437
432
|
addToWhitelist(address: PublicKey, authority?: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
438
433
|
removeFromWhitelist(address: PublicKey, authority?: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
434
|
+
growConfig(owner?: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
435
|
+
restoreConfig(snapshot: Buffer, owner?: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
439
436
|
fetchConfig(): Promise<QuestionMarketConfig | null>;
|
|
440
437
|
fetchQuestion(questionPda: PublicKey): Promise<Question | null>;
|
|
441
438
|
questionPda(questionId: Uint8Array): PublicKey;
|
|
@@ -551,123 +548,101 @@ declare class ClobClient {
|
|
|
551
548
|
get walletPubkey(): PublicKey;
|
|
552
549
|
/**
|
|
553
550
|
* Get or create an ALT for a condition.
|
|
554
|
-
*
|
|
555
|
-
* Subsequent calls for same condition: returns cached ALT instantly.
|
|
556
|
-
* BE devs never interact with this — called automatically by matchOrders.
|
|
551
|
+
* Includes order_record PDAs for taker + all makers so match tx stays under 1232 bytes.
|
|
557
552
|
*/
|
|
558
|
-
ensureAlt(condition: PublicKey, collateralMint: PublicKey,
|
|
553
|
+
ensureAlt(condition: PublicKey, collateralMint: PublicKey, takerSigned: SignedOrder, makers: SignedOrder[]): Promise<AddressLookupTableAccount>;
|
|
554
|
+
private _sendLegacyTxSig;
|
|
559
555
|
private _sendLegacyTx;
|
|
560
556
|
/**
|
|
561
|
-
* Send a match transaction as versioned (v0).
|
|
562
|
-
*
|
|
563
|
-
* stay under the 1232-byte limit — required for match_complementary which
|
|
564
|
-
* has ~25 accounts + 2 Ed25519 precompile instructions (~1697 bytes raw).
|
|
565
|
-
*
|
|
566
|
-
* If `whitelistedWallet` is provided and differs from `this.provider.wallet`,
|
|
567
|
-
* both wallets sign the transaction (whitelisted operator + payer).
|
|
557
|
+
* Send a match transaction as versioned (v0) with optional ALT.
|
|
558
|
+
* Both operator wallet and payer (this.provider.wallet) sign.
|
|
568
559
|
*/
|
|
569
560
|
sendMatchTx(instructions: TransactionInstruction[], lookupTable?: AddressLookupTableAccount, whitelistedWallet?: anchor.Wallet): Promise<string>;
|
|
570
|
-
/** PDA for a CLOB whitelist entry. */
|
|
571
|
-
whitelistEntryPda(address: PublicKey): PublicKey;
|
|
572
561
|
configPda(): PublicKey;
|
|
573
|
-
/**
|
|
562
|
+
/**
|
|
563
|
+
* Register a signed order on-chain.
|
|
564
|
+
* Sends Ed25519 precompile ix + register_order ix in one legacy tx.
|
|
565
|
+
* Called at match time (engine-triggered), not at order placement.
|
|
566
|
+
*/
|
|
567
|
+
registerOrder(signed: SignedOrder): Promise<string>;
|
|
568
|
+
/** Register only if the PDA doesn't exist yet (idempotent). */
|
|
569
|
+
private registerOrderIfNeeded;
|
|
570
|
+
/** Cancel an order — closes its OrderRecord PDA and returns rent to maker. */
|
|
571
|
+
cancelOrder(nonce: anchor.BN): Promise<TxResult>;
|
|
574
572
|
initialize(operators: PublicKey[], feeRecipient: PublicKey, feeRateBps: number): Promise<TxResult>;
|
|
575
|
-
/** Admin adds an operator to the whitelist. */
|
|
576
573
|
addOperator(operator: PublicKey): Promise<TxResult>;
|
|
577
|
-
/** Admin removes an operator from the whitelist. */
|
|
578
574
|
removeOperator(operator: PublicKey): Promise<TxResult>;
|
|
579
|
-
/** Admin pause/unpause the CLOB. */
|
|
580
575
|
setPaused(paused: boolean): Promise<TxResult>;
|
|
581
|
-
/**
|
|
582
|
-
* Maker cancels their own order.
|
|
583
|
-
* OrderStatus PDA is marked cancelled — any future fill rejected.
|
|
584
|
-
*/
|
|
585
|
-
cancelOrder(nonce: anchor.BN): Promise<TxResult>;
|
|
586
|
-
/**
|
|
587
|
-
* Emergency reset of CLOB config (upgrade authority only).
|
|
588
|
-
*/
|
|
589
576
|
forceResetClob(programData: PublicKey, newAdmin: PublicKey, newOperators: PublicKey[], newFeeRecipient: PublicKey, newFeeRateBps: number): Promise<TxResult>;
|
|
590
577
|
/**
|
|
591
|
-
*
|
|
578
|
+
* Build match_complementary instruction (no Ed25519 — OrderRecord PDAs used).
|
|
592
579
|
*
|
|
593
|
-
*
|
|
594
|
-
*
|
|
595
|
-
*
|
|
596
|
-
*
|
|
597
|
-
*
|
|
598
|
-
* remaining_accounts: [hook×3] [seller×5 × N]
|
|
599
|
-
*/
|
|
600
|
-
/** Build Ed25519 + matchComplementary instructions without sending.
|
|
601
|
-
*
|
|
602
|
-
* If `buySigned.order.fee > 0` and `feeClient` + `feeConfigOwner` are wired in,
|
|
603
|
-
* automatically appends 5 fee_management remaining_accounts so the program CPIs
|
|
604
|
-
* to distribute_fee internally. No manual `feeDistribute` param needed.
|
|
580
|
+
* remaining_accounts layout:
|
|
581
|
+
* [seller, order_record, seller_token, seller_collateral, seller_position, sell_status] × N
|
|
582
|
+
* [extraAccountMetaList, hookConfig, hookProgram]
|
|
583
|
+
* [feeManagement, fee_config, mkt_override, company_ata, oracle_vault] (when fee > 0)
|
|
605
584
|
*/
|
|
606
|
-
buildMatchComplementaryIxs(
|
|
585
|
+
buildMatchComplementaryIxs(takerSigned: SignedOrder, makersSigned: SignedOrder[], collateralMint: PublicKey, feeRecipient: PublicKey, operator: PublicKey, opts?: {
|
|
607
586
|
marketOracleVault?: PublicKey;
|
|
587
|
+
fillAmount?: anchor.BN;
|
|
608
588
|
}): Promise<TransactionInstruction[]>;
|
|
589
|
+
/**
|
|
590
|
+
* COMPLEMENTARY: 1 taker (BUY) + N makers (SELL), same tokenId.
|
|
591
|
+
* Phase 1: register taker + all makers in parallel.
|
|
592
|
+
* Phase 2: 1 atomic match tx.
|
|
593
|
+
*/
|
|
609
594
|
private matchComplementary;
|
|
610
595
|
/**
|
|
611
|
-
* MINT
|
|
596
|
+
* MINT: 1 YES buyer (taker) + N NO buyers (makers).
|
|
597
|
+
* Phase 1: register taker + all NO makers in parallel.
|
|
598
|
+
* Phase 2: 1 atomic match tx.
|
|
612
599
|
*
|
|
613
|
-
*
|
|
614
|
-
*
|
|
615
|
-
* ix[1+i] Ed25519(maker_i/NO buyer)
|
|
616
|
-
* ix[N+1] match_mint_orders(yesNonce, makerNonces[])
|
|
617
|
-
*
|
|
618
|
-
* remaining_accounts: [maker×5 × N] (no hook accounts — mint_to doesn't fire hook)
|
|
600
|
+
* remaining_accounts per NO maker (5):
|
|
601
|
+
* [order_record, buyer_no_token, buyer_no_collateral, buyer_no_position, no_order_status]
|
|
619
602
|
*/
|
|
620
603
|
private matchMintOrders;
|
|
621
604
|
/**
|
|
622
|
-
* MERGE
|
|
623
|
-
*
|
|
624
|
-
*
|
|
625
|
-
* ix[0] Ed25519(taker/YES seller)
|
|
626
|
-
* ix[1+i] Ed25519(maker_i/NO seller)
|
|
627
|
-
* ix[N+1] match_merge_orders(yesNonce, makerNonces[])
|
|
605
|
+
* MERGE: 1 YES seller (taker) + N NO sellers (makers).
|
|
606
|
+
* Phase 1: register taker + all NO makers in parallel.
|
|
607
|
+
* Phase 2: 1 atomic match tx.
|
|
628
608
|
*
|
|
629
|
-
* remaining_accounts
|
|
609
|
+
* remaining_accounts per NO maker (5):
|
|
610
|
+
* [order_record, seller_no_token, seller_no_collateral, seller_no_position, no_order_status]
|
|
611
|
+
* After all makers, optional 5 fee accounts.
|
|
630
612
|
*/
|
|
631
613
|
private matchMergeOrders;
|
|
632
614
|
/**
|
|
633
|
-
* Auto-detect match type and execute
|
|
634
|
-
*
|
|
635
|
-
*
|
|
636
|
-
* taker.tokenId === makers[0].tokenId: taker BUY + all makers SELL → COMPLEMENTARY
|
|
637
|
-
* taker.tokenId !== makers[0].tokenId + taker BUY + all makers BUY → MINT
|
|
638
|
-
* taker.tokenId !== makers[0].tokenId + taker SELL + all makers SELL → MERGE
|
|
639
|
-
* Otherwise → throws InvalidParamError
|
|
615
|
+
* Auto-detect match type and execute 2-phase:
|
|
616
|
+
* Phase 1 — register all orders (taker + makers) on-chain in parallel.
|
|
617
|
+
* Phase 2 — 1 atomic match transaction.
|
|
640
618
|
*
|
|
641
|
-
*
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
*
|
|
645
|
-
*
|
|
646
|
-
* feeRecipient and collateralMint are derived from on-chain config.
|
|
647
|
-
* Fee distribution (distribute_fee CPI) fires automatically when order.fee > 0.
|
|
619
|
+
* Detection (pure, no RPC):
|
|
620
|
+
* taker.tokenId === makers[0].tokenId:
|
|
621
|
+
* taker BUY + all makers SELL → COMPLEMENTARY
|
|
622
|
+
* taker.tokenId !== makers[0].tokenId + all BUY → MINT
|
|
623
|
+
* taker.tokenId !== makers[0].tokenId + all SELL → MERGE
|
|
648
624
|
*
|
|
649
|
-
* @param opts.marketOracleVault
|
|
650
|
-
*
|
|
651
|
-
* For admin markets (is_admin=true) omit — payer is used as placeholder (no transfer).
|
|
625
|
+
* @param opts.marketOracleVault Oracle vault ATA for presale markets.
|
|
626
|
+
* Omit for admin markets (payer used as placeholder).
|
|
652
627
|
*/
|
|
653
628
|
matchOrders(taker: SignedOrder, makers: SignedOrder[], opts?: {
|
|
654
629
|
marketOracleVault?: PublicKey;
|
|
655
630
|
}): Promise<TxResult>;
|
|
656
|
-
/** Add an address to the CLOB whitelist (owner only). */
|
|
657
|
-
addToWhitelist(address: PublicKey): Promise<TxResult>;
|
|
658
|
-
/** Batch-add addresses to the CLOB whitelist (owner only). All PDAs created in one tx. */
|
|
659
|
-
addToWhitelistBatch(addresses: PublicKey[]): Promise<TxResult>;
|
|
660
|
-
/** Remove an address from the CLOB whitelist (owner only). */
|
|
661
|
-
removeFromWhitelist(address: PublicKey, rentReceiver?: PublicKey): Promise<TxResult>;
|
|
662
|
-
/** Fetch a whitelist entry PDA (returns null if address is not whitelisted). */
|
|
663
|
-
fetchWhitelistEntry(address: PublicKey): Promise<ClobWhitelistEntry | null>;
|
|
664
|
-
/** Check if an address is on the CLOB whitelist. */
|
|
665
|
-
isWhitelisted(address: PublicKey): Promise<boolean>;
|
|
666
|
-
/** Fetch all whitelisted addresses (scans all ClobWhitelistEntry accounts). */
|
|
667
|
-
fetchWhitelist(): Promise<PublicKey[]>;
|
|
668
631
|
fetchConfig(): Promise<ClobConfig | null>;
|
|
669
632
|
fetchOrderStatus(maker: PublicKey, nonce: anchor.BN): Promise<OrderStatus | null>;
|
|
670
|
-
|
|
633
|
+
fetchOrderRecord(maker: PublicKey, nonce: anchor.BN): Promise<{
|
|
634
|
+
maker: PublicKey;
|
|
635
|
+
condition: PublicKey;
|
|
636
|
+
tokenId: number;
|
|
637
|
+
side: number;
|
|
638
|
+
makerAmount: anchor.BN;
|
|
639
|
+
takerAmount: anchor.BN;
|
|
640
|
+
nonce: anchor.BN;
|
|
641
|
+
expiry: anchor.BN;
|
|
642
|
+
fee: anchor.BN;
|
|
643
|
+
taker: PublicKey;
|
|
644
|
+
signer: PublicKey;
|
|
645
|
+
} | null>;
|
|
671
646
|
}
|
|
672
647
|
|
|
673
648
|
interface PresaleInfo {
|
|
@@ -717,7 +692,7 @@ declare class PresaleClient {
|
|
|
717
692
|
* Refund: burn user's MST and return USDC.
|
|
718
693
|
* Only callable when presale status = Rejected.
|
|
719
694
|
*/
|
|
720
|
-
refund(presalePda: PublicKey, user?: PublicKey): Promise<Transaction>;
|
|
695
|
+
refund(presalePda: PublicKey, user?: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
721
696
|
fetchPresale(presalePda: PublicKey): Promise<PresaleInfo | null>;
|
|
722
697
|
fetchUserBuyRecord(presalePda: PublicKey, user: PublicKey): Promise<UserBuyRecord | null>;
|
|
723
698
|
}
|
|
@@ -827,6 +802,7 @@ declare class PDA {
|
|
|
827
802
|
static extraAccountMetaList(mint: PublicKey, programIds: Pick<ProgramIds, "hook">): [PublicKey, number];
|
|
828
803
|
static clobConfig(programIds: Pick<ProgramIds, "clobExchange">): [PublicKey, number];
|
|
829
804
|
static orderStatus(maker: PublicKey, nonce: BN, programIds: Pick<ProgramIds, "clobExchange">): [PublicKey, number];
|
|
805
|
+
static orderRecord(maker: PublicKey, nonce: BN, programIds: Pick<ProgramIds, "clobExchange">): [PublicKey, number];
|
|
830
806
|
static feeConfig(owner: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
|
|
831
807
|
static questionFee(conditionPda: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
|
|
832
808
|
static marketFeeOverride(conditionPda: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
|
|
@@ -969,4 +945,4 @@ declare function buildApproveCollateralTx(collateralMint: PublicKey, signer: Pub
|
|
|
969
945
|
*/
|
|
970
946
|
declare function buildApproveAllOutcomeTokensTx(condition: PublicKey, signer: PublicKey, payer: PublicKey, delegate: PublicKey, programIds: ProgramIds, amount?: BN): Transaction;
|
|
971
947
|
|
|
972
|
-
export { AccountNotFoundError, ClobClient, type ClobConfig, type
|
|
948
|
+
export { AccountNotFoundError, ClobClient, type ClobConfig, type CollateralConfig, type CollateralVault, type Condition, type CreateQuestionParams, CtfClient, type CtfConfig, FEE_DENOMINATOR, FeeManagementClient, HookClient, type HookConfig, 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, SEEDS, type SignedOrder, type TxResult, UnauthorizedError, type UserBuyRecord, type UserClaimRecord, XMarketError, XMarketSDK, buildApproveAllOutcomeTokensTx, buildApproveCollateralTx, buildBatchedEd25519Instruction, buildOrder, deserializeSignedOrder, detectMatchType, generateContentHash, generateQuestionId, getOrderSignBytes, serializeOrderToBytes, serializeSignedOrder, signOrder, signOrderWithKeypair, verifySignedOrder };
|