@theliem/xmarket-sdk 3.7.0 → 3.9.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(),
@@ -1963,7 +1967,7 @@ ${logs.join("\n")}`);
1963
1967
  { pubkey: hookConfig, isSigner: false, isWritable: false },
1964
1968
  { pubkey: hookProgram, isSigner: false, isWritable: false }
1965
1969
  );
1966
- const matchIx = await this.program.methods.matchMintOrders(takerNonce, fillAmount).accounts({
1970
+ const matchIx = await this.program.methods.matchMintOrders(takerNonce, fillAmount, true).accounts({
1967
1971
  operator: operatorWallet.publicKey,
1968
1972
  payer: this.walletPubkey,
1969
1973
  clobConfig,
@@ -2059,17 +2063,21 @@ ${logs.join("\n")}`);
2059
2063
  if (yesSigned.order.fee.gtn(0) && this.programIds.feeManagement && this.feeConfigOwner) {
2060
2064
  const companyAddr = await this.companyAddress();
2061
2065
  if (companyAddr) {
2062
- const oracleVault = opts?.marketOracleVault ?? this.walletPubkey;
2063
- remainingAccounts.push(
2064
- { pubkey: this.programIds.feeManagement, isSigner: false, isWritable: false },
2065
- { pubkey: PDA.feeConfig(this.feeConfigOwner, this.programIds)[0], isSigner: false, isWritable: false },
2066
- { pubkey: PDA.marketFeeOverride(condition, this.programIds)[0], isSigner: false, isWritable: false },
2067
- { pubkey: splToken.getAssociatedTokenAddressSync(collateralMint, companyAddr), isSigner: false, isWritable: true },
2068
- { pubkey: oracleVault, isSigner: false, isWritable: true }
2069
- );
2066
+ const feeOverridePda = PDA.marketFeeOverride(condition, this.programIds)[0];
2067
+ const feeOverrideExists = await this.provider.connection.getAccountInfo(feeOverridePda);
2068
+ if (feeOverrideExists) {
2069
+ const oracleVault = opts?.marketOracleVault ?? this.walletPubkey;
2070
+ remainingAccounts.push(
2071
+ { pubkey: this.programIds.feeManagement, isSigner: false, isWritable: false },
2072
+ { pubkey: PDA.feeConfig(this.feeConfigOwner, this.programIds)[0], isSigner: false, isWritable: false },
2073
+ { pubkey: feeOverridePda, isSigner: false, isWritable: false },
2074
+ { pubkey: splToken.getAssociatedTokenAddressSync(collateralMint, companyAddr), isSigner: false, isWritable: true },
2075
+ { pubkey: oracleVault, isSigner: false, isWritable: true }
2076
+ );
2077
+ }
2070
2078
  }
2071
2079
  }
2072
- const matchIx = await this.program.methods.matchMergeOrders(takerNonce, fillAmount).accounts({
2080
+ const matchIx = await this.program.methods.matchMergeOrders(takerNonce, fillAmount, true).accounts({
2073
2081
  operator: operatorWallet.publicKey,
2074
2082
  payer: this.walletPubkey,
2075
2083
  clobConfig,
@@ -2142,17 +2150,6 @@ ${logs.join("\n")}`);
2142
2150
  } else {
2143
2151
  throw new InvalidParamError("COMPLEMENTARY requires one BUY and one or more SELLs on same tokenId");
2144
2152
  }
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
2153
  const finalSells = sellCandidates;
2157
2154
  return this.matchComplementary(buySignedOrder, finalSells, collateralMint, feeRecipient, operatorWallet, alt, opts);
2158
2155
  }
@@ -8854,6 +8851,10 @@ var clob_exchange_default = {
8854
8851
  {
8855
8852
  name: "use_taker_price",
8856
8853
  type: "bool"
8854
+ },
8855
+ {
8856
+ name: "skip_crossing_check",
8857
+ type: "bool"
8857
8858
  }
8858
8859
  ]
8859
8860
  },
@@ -9129,6 +9130,10 @@ var clob_exchange_default = {
9129
9130
  {
9130
9131
  name: "fill_amount",
9131
9132
  type: "u64"
9133
+ },
9134
+ {
9135
+ name: "skip_crossing_check",
9136
+ type: "bool"
9132
9137
  }
9133
9138
  ]
9134
9139
  },
@@ -9420,6 +9425,10 @@ var clob_exchange_default = {
9420
9425
  {
9421
9426
  name: "fill_amount",
9422
9427
  type: "u64"
9428
+ },
9429
+ {
9430
+ name: "skip_crossing_check",
9431
+ type: "bool"
9423
9432
  }
9424
9433
  ]
9425
9434
  },