@theliem/xmarket-sdk 3.0.0 → 3.0.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.mjs CHANGED
@@ -6,7 +6,7 @@ import oracleIdl from './oracle-FZJJIJGI.json';
6
6
  import hookIdl from './hook-THBRGUM6.json';
7
7
  import questionMarketIdl from './question_market-CB6ZUZ5E.json';
8
8
  import conditionalTokensIdl from './conditional_tokens-3O5V46N5.json';
9
- import clobExchangeIdl from './clob_exchange-ATSH42KC.json';
9
+ import clobExchangeIdl from './clob_exchange-MQF4NI27.json';
10
10
  import BN4 from 'bn.js';
11
11
  import * as nacl from 'tweetnacl';
12
12
 
@@ -1244,14 +1244,13 @@ var ClobClient = class {
1244
1244
  *
1245
1245
  * remaining_accounts: [maker×5 × N] (no hook accounts — mint_to doesn't fire hook)
1246
1246
  */
1247
- async matchMintOrders(yesSigned, makersSigned, collateralMint, whitelistedWallet, lookupTable) {
1247
+ async matchMintOrders(yesSigned, makersSigned, collateralMint, feeRecipient, whitelistedWallet, lookupTable) {
1248
1248
  const condition = yesSigned.order.condition;
1249
1249
  const [yesMint] = PDA.yesMint(condition, this.programIds);
1250
1250
  const [noMint] = PDA.noMint(condition, this.programIds);
1251
1251
  const [mintAuthority] = PDA.mintAuthority(condition, this.programIds);
1252
1252
  const [collateralVault] = PDA.collateralVault(collateralMint, this.programIds);
1253
1253
  const [vaultTokenAccount] = PDA.vaultToken(collateralMint, this.programIds);
1254
- const [clobAuthority] = PDA.clobConfig(this.programIds);
1255
1254
  const buyerYes = yesSigned.order.maker;
1256
1255
  const buyerYesCollateral = getAssociatedTokenAddressSync(collateralMint, buyerYes);
1257
1256
  const buyerYesTokenAccount = getAssociatedTokenAddressSync(yesMint, buyerYes, false, TOKEN_2022_PROGRAM_ID);
@@ -1294,12 +1293,19 @@ var ClobClient = class {
1294
1293
  yesMint,
1295
1294
  noMint,
1296
1295
  mintAuthority,
1297
- clobAuthority,
1296
+ feeRecipient,
1298
1297
  conditionalTokensProgram: this.programIds.conditionalTokens,
1299
1298
  collateralTokenProgram: TOKEN_PROGRAM_ID,
1300
1299
  token2022Program: TOKEN_2022_PROGRAM_ID,
1301
1300
  systemProgram: SystemProgram.programId
1302
1301
  }).remainingAccounts(makerAccounts).instruction();
1302
+ const frKey = feeRecipient.toBase58();
1303
+ for (const k of matchIx.keys) {
1304
+ if (k.pubkey.toBase58() === frKey) {
1305
+ k.isWritable = true;
1306
+ break;
1307
+ }
1308
+ }
1303
1309
  const sig = await this._sendMatchTx(
1304
1310
  [...ed25519Ixs, matchIx],
1305
1311
  lookupTable,
@@ -1317,13 +1323,12 @@ var ClobClient = class {
1317
1323
  *
1318
1324
  * remaining_accounts: [maker×5 × N] (no hook accounts — burn doesn't fire hook)
1319
1325
  */
1320
- async matchMergeOrders(yesSigned, makersSigned, collateralMint, whitelistedWallet, lookupTable) {
1326
+ async matchMergeOrders(yesSigned, makersSigned, collateralMint, feeRecipient, whitelistedWallet, lookupTable) {
1321
1327
  const condition = yesSigned.order.condition;
1322
1328
  const [yesMint] = PDA.yesMint(condition, this.programIds);
1323
1329
  const [noMint] = PDA.noMint(condition, this.programIds);
1324
1330
  const [collateralVault] = PDA.collateralVault(collateralMint, this.programIds);
1325
1331
  const [vaultTokenAccount] = PDA.vaultToken(collateralMint, this.programIds);
1326
- const [clobAuthority] = PDA.clobConfig(this.programIds);
1327
1332
  const sellerYes = yesSigned.order.maker;
1328
1333
  const sellerYesTokenAccount = getAssociatedTokenAddressSync(yesMint, sellerYes, false, TOKEN_2022_PROGRAM_ID);
1329
1334
  const [sellerYesPosition] = PDA.position(condition, 1, sellerYes, this.programIds);
@@ -1365,12 +1370,19 @@ var ClobClient = class {
1365
1370
  vaultTokenAccount,
1366
1371
  yesMint,
1367
1372
  noMint,
1368
- clobAuthority,
1373
+ feeRecipient,
1369
1374
  conditionalTokensProgram: this.programIds.conditionalTokens,
1370
1375
  collateralTokenProgram: TOKEN_PROGRAM_ID,
1371
1376
  token2022Program: TOKEN_2022_PROGRAM_ID,
1372
1377
  systemProgram: SystemProgram.programId
1373
1378
  }).remainingAccounts(makerAccounts).instruction();
1379
+ const frKeyM = feeRecipient.toBase58();
1380
+ for (const k of matchIx.keys) {
1381
+ if (k.pubkey.toBase58() === frKeyM) {
1382
+ k.isWritable = true;
1383
+ break;
1384
+ }
1385
+ }
1374
1386
  const sig = await this._sendMatchTx(
1375
1387
  [...ed25519Ixs, matchIx],
1376
1388
  lookupTable,
@@ -1393,8 +1405,8 @@ var ClobClient = class {
1393
1405
  if (makers.length === 0) throw new InvalidParamError("At least 1 maker required");
1394
1406
  const t = taker.order;
1395
1407
  const m0 = makers[0].order;
1396
- const SIDE_BUY = 1;
1397
- const SIDE_SELL = 0;
1408
+ const SIDE_BUY = 0;
1409
+ const SIDE_SELL = 1;
1398
1410
  if (t.tokenId === m0.tokenId) {
1399
1411
  if (t.side === SIDE_BUY && makers.every((m) => m.order.side === SIDE_SELL)) {
1400
1412
  return this.matchComplementary(taker, makers, collateralMint, feeRecipient, whitelistedWallet, lookupTable);
@@ -1416,9 +1428,9 @@ var ClobClient = class {
1416
1428
  throw new InvalidParamError("MINT/MERGE: all makers must be the NO side (tokenId=0)");
1417
1429
  }
1418
1430
  if (allBuy) {
1419
- return this.matchMintOrders(taker, makers, collateralMint, whitelistedWallet, lookupTable);
1431
+ return this.matchMintOrders(taker, makers, collateralMint, feeRecipient, whitelistedWallet, lookupTable);
1420
1432
  }
1421
- return this.matchMergeOrders(taker, makers, collateralMint, whitelistedWallet, lookupTable);
1433
+ return this.matchMergeOrders(taker, makers, collateralMint, feeRecipient, whitelistedWallet, lookupTable);
1422
1434
  }
1423
1435
  // ─── Whitelist admin ─────────────────────────────────────────────────────────
1424
1436
  /** Add an address to the CLOB whitelist (owner only). */
@@ -1636,7 +1648,7 @@ function detectMatchType(a, b) {
1636
1648
  return _detectMatchType(_a, _b);
1637
1649
  }
1638
1650
  function _detectMatchType(a, b) {
1639
- const SIDE_BUY = 1;
1651
+ const SIDE_BUY = 0;
1640
1652
  if (a.tokenId === b.tokenId) {
1641
1653
  const aBuy2 = a.side === SIDE_BUY;
1642
1654
  const bBuy2 = b.side === SIDE_BUY;