@theliem/xmarket-sdk 3.8.0 → 3.10.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.mjs CHANGED
@@ -1593,10 +1593,10 @@ ${logs.join("\n")}`);
1593
1593
  connection.getAccountInfo(clobYesAta),
1594
1594
  connection.getAccountInfo(clobNoAta)
1595
1595
  ]);
1596
- const { createAssociatedTokenAccountIdempotentInstruction: createAssociatedTokenAccountIdempotentInstruction2 } = await import('@solana/spl-token');
1596
+ const { createAssociatedTokenAccountIdempotentInstruction: createAssociatedTokenAccountIdempotentInstruction3 } = await import('@solana/spl-token');
1597
1597
  const ixs = [];
1598
1598
  if (!yesInfo) {
1599
- ixs.push(createAssociatedTokenAccountIdempotentInstruction2(
1599
+ ixs.push(createAssociatedTokenAccountIdempotentInstruction3(
1600
1600
  this.walletPubkey,
1601
1601
  clobYesAta,
1602
1602
  clobConfig,
@@ -1605,7 +1605,7 @@ ${logs.join("\n")}`);
1605
1605
  ));
1606
1606
  }
1607
1607
  if (!noInfo) {
1608
- ixs.push(createAssociatedTokenAccountIdempotentInstruction2(
1608
+ ixs.push(createAssociatedTokenAccountIdempotentInstruction3(
1609
1609
  this.walletPubkey,
1610
1610
  clobNoAta,
1611
1611
  clobConfig,
@@ -1941,7 +1941,7 @@ ${logs.join("\n")}`);
1941
1941
  { pubkey: hookConfig, isSigner: false, isWritable: false },
1942
1942
  { pubkey: hookProgram, isSigner: false, isWritable: false }
1943
1943
  );
1944
- const matchIx = await this.program.methods.matchMintOrders(takerNonce, fillAmount).accounts({
1944
+ const matchIx = await this.program.methods.matchMintOrders(takerNonce, fillAmount, true).accounts({
1945
1945
  operator: operatorWallet.publicKey,
1946
1946
  payer: this.walletPubkey,
1947
1947
  clobConfig,
@@ -2037,17 +2037,21 @@ ${logs.join("\n")}`);
2037
2037
  if (yesSigned.order.fee.gtn(0) && this.programIds.feeManagement && this.feeConfigOwner) {
2038
2038
  const companyAddr = await this.companyAddress();
2039
2039
  if (companyAddr) {
2040
- const oracleVault = opts?.marketOracleVault ?? this.walletPubkey;
2041
- remainingAccounts.push(
2042
- { pubkey: this.programIds.feeManagement, isSigner: false, isWritable: false },
2043
- { pubkey: PDA.feeConfig(this.feeConfigOwner, this.programIds)[0], isSigner: false, isWritable: false },
2044
- { pubkey: PDA.marketFeeOverride(condition, this.programIds)[0], isSigner: false, isWritable: false },
2045
- { pubkey: getAssociatedTokenAddressSync(collateralMint, companyAddr), isSigner: false, isWritable: true },
2046
- { pubkey: oracleVault, isSigner: false, isWritable: true }
2047
- );
2040
+ const feeOverridePda = PDA.marketFeeOverride(condition, this.programIds)[0];
2041
+ const feeOverrideExists = await this.provider.connection.getAccountInfo(feeOverridePda);
2042
+ if (feeOverrideExists) {
2043
+ const oracleVault = opts?.marketOracleVault ?? this.walletPubkey;
2044
+ remainingAccounts.push(
2045
+ { pubkey: this.programIds.feeManagement, isSigner: false, isWritable: false },
2046
+ { pubkey: PDA.feeConfig(this.feeConfigOwner, this.programIds)[0], isSigner: false, isWritable: false },
2047
+ { pubkey: feeOverridePda, isSigner: false, isWritable: false },
2048
+ { pubkey: getAssociatedTokenAddressSync(collateralMint, companyAddr), isSigner: false, isWritable: true },
2049
+ { pubkey: oracleVault, isSigner: false, isWritable: true }
2050
+ );
2051
+ }
2048
2052
  }
2049
2053
  }
2050
- const matchIx = await this.program.methods.matchMergeOrders(takerNonce, fillAmount).accounts({
2054
+ const matchIx = await this.program.methods.matchMergeOrders(takerNonce, fillAmount, true).accounts({
2051
2055
  operator: operatorWallet.publicKey,
2052
2056
  payer: this.walletPubkey,
2053
2057
  clobConfig,
@@ -2126,10 +2130,19 @@ ${logs.join("\n")}`);
2126
2130
  const allBuy = t.side === SIDE_BUY && makers.every((m) => m.order.side === SIDE_BUY);
2127
2131
  const allSell = t.side === SIDE_SELL && makers.every((m) => m.order.side === SIDE_SELL);
2128
2132
  if (!allBuy && !allSell) throw new InvalidParamError("MINT/MERGE: all orders must be same side");
2129
- if (t.tokenId !== 1) throw new InvalidParamError("MINT/MERGE: taker must be YES (tokenId=1)");
2130
- if (!makers.every((m) => m.order.tokenId === 0)) throw new InvalidParamError("MINT/MERGE: makers must be NO (tokenId=0)");
2131
- if (allBuy) return this.matchMintOrders(taker, makers, collateralMint, feeRecipient, operatorWallet, alt);
2132
- return this.matchMergeOrders(taker, makers, collateralMint, feeRecipient, operatorWallet, alt, opts);
2133
+ const takerIsYes = t.tokenId === 1 && makers.every((m) => m.order.tokenId === 0);
2134
+ const takerIsNo = t.tokenId === 0 && makers.every((m) => m.order.tokenId === 1);
2135
+ if (!takerIsYes && !takerIsNo) throw new InvalidParamError("MINT/MERGE: orders must be complementary YES+NO pair");
2136
+ if (takerIsYes) {
2137
+ if (allBuy) return this.matchMintOrders(taker, makers, collateralMint, feeRecipient, operatorWallet, alt);
2138
+ return this.matchMergeOrders(taker, makers, collateralMint, feeRecipient, operatorWallet, alt, opts);
2139
+ }
2140
+ let lastResult;
2141
+ for (const yesMaker of makers) {
2142
+ if (allBuy) lastResult = await this.matchMintOrders(yesMaker, [taker], collateralMint, feeRecipient, operatorWallet, alt);
2143
+ else lastResult = await this.matchMergeOrders(yesMaker, [taker], collateralMint, feeRecipient, operatorWallet, alt, opts);
2144
+ }
2145
+ return lastResult;
2133
2146
  }
2134
2147
  /**
2135
2148
  * High-level match: caller passes price + quantity + keypair — SDK builds,
@@ -9100,6 +9113,10 @@ var clob_exchange_default = {
9100
9113
  {
9101
9114
  name: "fill_amount",
9102
9115
  type: "u64"
9116
+ },
9117
+ {
9118
+ name: "skip_crossing_check",
9119
+ type: "bool"
9103
9120
  }
9104
9121
  ]
9105
9122
  },
@@ -9391,6 +9408,10 @@ var clob_exchange_default = {
9391
9408
  {
9392
9409
  name: "fill_amount",
9393
9410
  type: "u64"
9411
+ },
9412
+ {
9413
+ name: "skip_crossing_check",
9414
+ type: "bool"
9394
9415
  }
9395
9416
  ]
9396
9417
  },
@@ -14969,6 +14990,33 @@ var XMarketSDK = class {
14969
14990
  }
14970
14991
  };
14971
14992
  var MAX_APPROVE_AMOUNT = new BN4("18446744073709551615");
14993
+ function buildCreateUserAtasTx(condition, user, payer, programIds) {
14994
+ const [yesMint] = PDA.yesMint(condition, programIds);
14995
+ const [noMint] = PDA.noMint(condition, programIds);
14996
+ const yesAta = getAssociatedTokenAddressSync(yesMint, user, false, TOKEN_2022_PROGRAM_ID);
14997
+ const noAta = getAssociatedTokenAddressSync(noMint, user, false, TOKEN_2022_PROGRAM_ID);
14998
+ const tx = new Transaction();
14999
+ tx.feePayer = payer;
15000
+ tx.add(
15001
+ createAssociatedTokenAccountIdempotentInstruction(
15002
+ payer,
15003
+ yesAta,
15004
+ user,
15005
+ yesMint,
15006
+ TOKEN_2022_PROGRAM_ID,
15007
+ ASSOCIATED_TOKEN_PROGRAM_ID
15008
+ ),
15009
+ createAssociatedTokenAccountIdempotentInstruction(
15010
+ payer,
15011
+ noAta,
15012
+ user,
15013
+ noMint,
15014
+ TOKEN_2022_PROGRAM_ID,
15015
+ ASSOCIATED_TOKEN_PROGRAM_ID
15016
+ )
15017
+ );
15018
+ return tx;
15019
+ }
14972
15020
  function buildApproveCollateralTx(collateralMint, signer, payer, delegate, amount = MAX_APPROVE_AMOUNT) {
14973
15021
  const ownerAta = getAssociatedTokenAddressSync(collateralMint, signer, false, TOKEN_PROGRAM_ID);
14974
15022
  const approveIx = createApproveInstruction(
@@ -15012,6 +15060,6 @@ function buildApproveAllOutcomeTokensTx(condition, signer, payer, delegate, prog
15012
15060
  return tx;
15013
15061
  }
15014
15062
 
15015
- export { AccountNotFoundError, AdminClient, ClobClient, CtfClient, FEE_DENOMINATOR, FeeManagementClient, HookClient, IX_SYSVAR, InvalidParamError, MAX_APPROVE_AMOUNT, MarketClient, MarketOracleClient, OracleClient, PDA, PresaleClient, QuestionStatus, SEEDS, UnauthorizedError, XMarketError, XMarketSDK, buildApproveAllOutcomeTokensTx, buildApproveCollateralTx, buildBatchedEd25519Instruction, buildOrder, buildOrderFromPrice, deserializeSignedOrder, detectMatchType, generateContentHash, generateQuestionId, getOrderSignBytes, orderAmountsFromPrice, serializeOrderToBytes, serializeSignedOrder, signOrder, signOrderWithKeypair, verifySignedOrder };
15063
+ export { AccountNotFoundError, AdminClient, ClobClient, CtfClient, FEE_DENOMINATOR, FeeManagementClient, HookClient, IX_SYSVAR, InvalidParamError, MAX_APPROVE_AMOUNT, MarketClient, MarketOracleClient, OracleClient, PDA, PresaleClient, QuestionStatus, SEEDS, UnauthorizedError, XMarketError, XMarketSDK, buildApproveAllOutcomeTokensTx, buildApproveCollateralTx, buildBatchedEd25519Instruction, buildCreateUserAtasTx, buildOrder, buildOrderFromPrice, deserializeSignedOrder, detectMatchType, generateContentHash, generateQuestionId, getOrderSignBytes, orderAmountsFromPrice, serializeOrderToBytes, serializeSignedOrder, signOrder, signOrderWithKeypair, verifySignedOrder };
15016
15064
  //# sourceMappingURL=index.mjs.map
15017
15065
  //# sourceMappingURL=index.mjs.map