@theliem/xmarket-sdk 3.7.0 → 3.8.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
@@ -596,7 +596,7 @@ declare class ClobClient {
596
596
  buildMatchComplementaryIxs(takerSigned: SignedOrder, makersSigned: SignedOrder[], collateralMint: PublicKey, feeRecipient: PublicKey, operator: PublicKey, opts?: {
597
597
  marketOracleVault?: PublicKey;
598
598
  fillAmount?: anchor.BN;
599
- }, useTakerPrice?: boolean): Promise<TransactionInstruction[]>;
599
+ }, useTakerPrice?: boolean, skipCrossingCheck?: boolean): Promise<TransactionInstruction[]>;
600
600
  /**
601
601
  * COMPLEMENTARY: 1 taker (BUY) + N makers (SELL), same tokenId.
602
602
  * Phase 1: register taker + all makers in parallel.
package/dist/index.d.ts CHANGED
@@ -596,7 +596,7 @@ declare class ClobClient {
596
596
  buildMatchComplementaryIxs(takerSigned: SignedOrder, makersSigned: SignedOrder[], collateralMint: PublicKey, feeRecipient: PublicKey, operator: PublicKey, opts?: {
597
597
  marketOracleVault?: PublicKey;
598
598
  fillAmount?: anchor.BN;
599
- }, useTakerPrice?: boolean): Promise<TransactionInstruction[]>;
599
+ }, useTakerPrice?: boolean, skipCrossingCheck?: boolean): Promise<TransactionInstruction[]>;
600
600
  /**
601
601
  * COMPLEMENTARY: 1 taker (BUY) + N makers (SELL), same tokenId.
602
602
  * Phase 1: register taker + all makers in parallel.
package/dist/index.js CHANGED
@@ -1776,7 +1776,7 @@ ${logs.join("\n")}`);
1776
1776
  * [extraAccountMetaList, hookConfig, hookProgram]
1777
1777
  * [feeManagement, fee_config, mkt_override, company_ata, oracle_vault] (when fee > 0)
1778
1778
  */
1779
- async buildMatchComplementaryIxs(takerSigned, makersSigned, collateralMint, feeRecipient, operator, opts, useTakerPrice = false) {
1779
+ async buildMatchComplementaryIxs(takerSigned, makersSigned, collateralMint, feeRecipient, operator, opts, useTakerPrice = false, skipCrossingCheck = true) {
1780
1780
  const condition = takerSigned.order.condition;
1781
1781
  const tokenId = takerSigned.order.tokenId;
1782
1782
  const taker = takerSigned.order.maker;
@@ -1816,17 +1816,21 @@ ${logs.join("\n")}`);
1816
1816
  if (takerSigned.order.fee.gtn(0) && this.programIds.feeManagement && this.feeConfigOwner) {
1817
1817
  const companyAddr = await this.companyAddress();
1818
1818
  if (companyAddr) {
1819
- const oracleVault = opts?.marketOracleVault ?? this.walletPubkey;
1820
- feeAccounts = [
1821
- { pubkey: this.programIds.feeManagement, isSigner: false, isWritable: false },
1822
- { pubkey: PDA.feeConfig(this.feeConfigOwner, this.programIds)[0], isSigner: false, isWritable: false },
1823
- { pubkey: PDA.marketFeeOverride(condition, this.programIds)[0], isSigner: false, isWritable: false },
1824
- { pubkey: splToken.getAssociatedTokenAddressSync(collateralMint, companyAddr), isSigner: false, isWritable: true },
1825
- { pubkey: oracleVault, isSigner: false, isWritable: true }
1826
- ];
1819
+ const feeOverridePda = PDA.marketFeeOverride(condition, this.programIds)[0];
1820
+ const feeOverrideExists = await this.provider.connection.getAccountInfo(feeOverridePda);
1821
+ if (feeOverrideExists) {
1822
+ const oracleVault = opts?.marketOracleVault ?? this.walletPubkey;
1823
+ feeAccounts = [
1824
+ { pubkey: this.programIds.feeManagement, isSigner: false, isWritable: false },
1825
+ { pubkey: PDA.feeConfig(this.feeConfigOwner, this.programIds)[0], isSigner: false, isWritable: false },
1826
+ { pubkey: feeOverridePda, isSigner: false, isWritable: false },
1827
+ { pubkey: splToken.getAssociatedTokenAddressSync(collateralMint, companyAddr), isSigner: false, isWritable: true },
1828
+ { pubkey: oracleVault, isSigner: false, isWritable: true }
1829
+ ];
1830
+ }
1827
1831
  }
1828
1832
  }
1829
- const matchIx = await this.program.methods.matchComplementary(takerNonce, fillAmount, useTakerPrice).accounts({
1833
+ const matchIx = await this.program.methods.matchComplementary(takerNonce, fillAmount, useTakerPrice, skipCrossingCheck).accounts({
1830
1834
  operator,
1831
1835
  payer: this.walletPubkey,
1832
1836
  clobConfig: this.configPda(),
@@ -2142,17 +2146,6 @@ ${logs.join("\n")}`);
2142
2146
  } else {
2143
2147
  throw new InvalidParamError("COMPLEMENTARY requires one BUY and one or more SELLs on same tokenId");
2144
2148
  }
2145
- const buy = buySignedOrder.order;
2146
- const totalSellDemand = sellCandidates.reduce(
2147
- (acc, s) => acc + BigInt(s.order.takerAmount.toString()),
2148
- BigInt(0)
2149
- );
2150
- const buyBudget = BigInt(buy.makerAmount.toString());
2151
- if (buyBudget < totalSellDemand) {
2152
- throw new InvalidParamError(
2153
- `COMPLEMENTARY: total sell demand ${totalSellDemand} > buy budget ${buyBudget}. Build taker order with limitPrice, not averageMatchedPrice.`
2154
- );
2155
- }
2156
2149
  const finalSells = sellCandidates;
2157
2150
  return this.matchComplementary(buySignedOrder, finalSells, collateralMint, feeRecipient, operatorWallet, alt, opts);
2158
2151
  }
@@ -8854,6 +8847,10 @@ var clob_exchange_default = {
8854
8847
  {
8855
8848
  name: "use_taker_price",
8856
8849
  type: "bool"
8850
+ },
8851
+ {
8852
+ name: "skip_crossing_check",
8853
+ type: "bool"
8857
8854
  }
8858
8855
  ]
8859
8856
  },