@theliem/xmarket-sdk 3.1.0 → 3.1.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
@@ -1,14 +1,14 @@
1
1
  import * as anchor4 from '@coral-xyz/anchor';
2
- import { SYSVAR_INSTRUCTIONS_PUBKEY, PublicKey, SystemProgram, SYSVAR_RENT_PUBKEY, TransactionInstruction, Ed25519Program, AddressLookupTableProgram, TransactionMessage, VersionedTransaction, Connection, Transaction } from '@solana/web3.js';
2
+ import { PublicKey, SYSVAR_INSTRUCTIONS_PUBKEY, SystemProgram, SYSVAR_RENT_PUBKEY, TransactionInstruction, Ed25519Program, AddressLookupTableProgram, TransactionMessage, VersionedTransaction, Connection, Transaction } from '@solana/web3.js';
3
3
  import { createHash } from 'crypto';
4
4
  import { TOKEN_2022_PROGRAM_ID, getAssociatedTokenAddressSync, ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID, createApproveInstruction } from '@solana/spl-token';
5
- import oracleIdl from './oracle-A5VOIMGM.json';
5
+ import oracleIdl from './oracle-O53KMXDK.json';
6
6
  import hookIdl from './hook-THBRGUM6.json';
7
- import questionMarketIdl from './question_market-77YI4LRP.json';
7
+ import questionMarketIdl from './question_market-RP3J3N2M.json';
8
8
  import conditionalTokensIdl from './conditional_tokens-3O5V46N5.json';
9
9
  import clobExchangeIdl from './clob_exchange-MQF4NI27.json';
10
10
  import feeManagementIdl from './fee_management-VGF77YXG.json';
11
- import presaleIdl from './presale-ZZJXXQS3.json';
11
+ import presaleIdl from './presale-Q4NDVQFN.json';
12
12
  import marketOracleIdl from './market_oracle-E6UUARGR.json';
13
13
  import BN4 from 'bn.js';
14
14
  import * as nacl from 'tweetnacl';
@@ -253,7 +253,7 @@ var OracleClient = class {
253
253
  }).rpc();
254
254
  return { signature: sig };
255
255
  }
256
- /** Admin or owner adds an address to the oracle whitelist. */
256
+ /** Admin or owner adds an address to the oracle resolver whitelist. */
257
257
  async addToWhitelist(address, ownerPubkey) {
258
258
  const sig = await this.program.methods.addToWhitelist(address).accounts({
259
259
  authority: this.walletPubkey,
@@ -262,7 +262,7 @@ var OracleClient = class {
262
262
  }).rpc();
263
263
  return { signature: sig };
264
264
  }
265
- /** Admin or owner removes an address from the oracle whitelist. */
265
+ /** Admin or owner removes an address from the oracle resolver whitelist. */
266
266
  async removeFromWhitelist(address, ownerPubkey) {
267
267
  const sig = await this.program.methods.removeFromWhitelist(address).accounts({
268
268
  authority: this.walletPubkey,
@@ -510,6 +510,7 @@ var InvalidParamError = class extends XMarketError {
510
510
  };
511
511
 
512
512
  // src/programs/market.ts
513
+ var TOKEN_METADATA_PROGRAM_ID = new PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s");
513
514
  var MarketClient = class {
514
515
  constructor(program, provider, programIds, ownerPubkey) {
515
516
  this.program = program;
@@ -532,45 +533,6 @@ var MarketClient = class {
532
533
  systemProgram: SystemProgram.programId
533
534
  }).transaction();
534
535
  }
535
- /**
536
- * Build createQuestion transaction.
537
- * @param payer - Pays rent for all new accounts (can differ from creator)
538
- * @param creator - Identity of the question creator (signs but does not pay)
539
- */
540
- async createQuestion(params, oracle, creator = this.walletPubkey, payer = this.walletPubkey) {
541
- const questionId = params.questionId ?? generateQuestionId(params.content);
542
- const contentHash = params.contentHash ?? generateContentHash(params.content);
543
- const [questionPda] = PDA.question(this.configPda, questionId, this.programIds);
544
- const [conditionPda] = PDA.condition(oracle, questionId, this.programIds);
545
- const [yesMint] = PDA.yesMint(conditionPda, this.programIds);
546
- const [noMint] = PDA.noMint(conditionPda, this.programIds);
547
- const [mintAuthority] = PDA.mintAuthority(conditionPda, this.programIds);
548
- const [collateralVault] = PDA.collateralVault(params.collateralMint, this.programIds);
549
- const tx = await this.program.methods.createQuestionWithCondition({
550
- questionId: Array.from(questionId),
551
- contentHash: Array.from(contentHash),
552
- hookProgram: params.hookProgram,
553
- authorizedClob: params.authorizedClob,
554
- expirationTime: new anchor4.BN(params.expirationTime)
555
- }).accounts({
556
- payer,
557
- creator,
558
- config: this.configPda,
559
- question: questionPda,
560
- currencyMint: params.collateralMint,
561
- oracle,
562
- condition: conditionPda,
563
- yesMint,
564
- noMint,
565
- mintAuthority,
566
- collateralVault,
567
- conditionalTokensProgram: this.programIds.conditionalTokens,
568
- tokenProgram: TOKEN_2022_PROGRAM_ID,
569
- systemProgram: SystemProgram.programId,
570
- rent: SYSVAR_RENT_PUBKEY
571
- }).transaction();
572
- return { tx, questionPda, conditionPda, questionId };
573
- }
574
536
  /**
575
537
  * Build createQuestionAdmin transaction (whitelist/admin path — status = Approved immediately).
576
538
  * @param creator - Whitelisted creator (must be in whitelist or be admin/owner)
@@ -740,6 +702,10 @@ var MarketClient = class {
740
702
  const presaleVault = getAssociatedTokenAddressSync(currencyMint, presalePda, true);
741
703
  const creatorQtAta = getAssociatedTokenAddressSync(qtMint, creator);
742
704
  const creatorCurrencyAta = getAssociatedTokenAddressSync(currencyMint, creator);
705
+ const [qtMetadata] = PublicKey.findProgramAddressSync(
706
+ [Buffer.from("metadata"), TOKEN_METADATA_PROGRAM_ID.toBuffer(), qtMint.toBuffer()],
707
+ TOKEN_METADATA_PROGRAM_ID
708
+ );
743
709
  const tx = await this.program.methods.createPresale({
744
710
  price: params.price,
745
711
  startTime: params.startTime,
@@ -758,6 +724,8 @@ var MarketClient = class {
758
724
  creatorCurrencyAta,
759
725
  creatorQtAta,
760
726
  userBuyRecord,
727
+ qtMetadata,
728
+ tokenMetadataProgram: TOKEN_METADATA_PROGRAM_ID,
761
729
  presaleProgram: this.programIds.presale,
762
730
  tokenProgram: TOKEN_PROGRAM_ID,
763
731
  associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
@@ -1405,8 +1373,8 @@ var ClobClient = class {
1405
1373
  async _sendLegacyTx(instructions) {
1406
1374
  const { connection } = this.provider;
1407
1375
  const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash();
1408
- const { Transaction: Transaction3 } = await import('@solana/web3.js');
1409
- const tx = new Transaction3();
1376
+ const { Transaction: Transaction4 } = await import('@solana/web3.js');
1377
+ const tx = new Transaction4();
1410
1378
  tx.recentBlockhash = blockhash;
1411
1379
  tx.feePayer = this.walletPubkey;
1412
1380
  tx.add(...instructions);
@@ -2165,6 +2133,26 @@ var PresaleClient = class {
2165
2133
  }).signers(signers).rpc();
2166
2134
  return { signature: sig };
2167
2135
  }
2136
+ /**
2137
+ * Transfer creator_claimable_revenue (80%) to BOTMM wallet.
2138
+ * Call after collectPresaleRevenue (distribute_presale_revenue).
2139
+ */
2140
+ async distributeBotmmRevenue(presalePda, botmmAddress, currencyMint) {
2141
+ if (!currencyMint) {
2142
+ const presale = await this.fetchPresale(presalePda);
2143
+ if (!presale) throw new Error(`Presale not found: ${presalePda.toBase58()}`);
2144
+ currencyMint = presale.currencyMint;
2145
+ }
2146
+ const presaleVault = getAssociatedTokenAddressSync(currencyMint, presalePda, true);
2147
+ const botmmTokenAccount = getAssociatedTokenAddressSync(currencyMint, botmmAddress);
2148
+ return this.program.methods.distributeBotmmRevenue().accounts({
2149
+ presale: presalePda,
2150
+ presaleVault,
2151
+ currencyMint,
2152
+ botmmTokenAccount,
2153
+ tokenProgram: TOKEN_PROGRAM_ID
2154
+ }).transaction();
2155
+ }
2168
2156
  // ─── Queries ─────────────────────────────────────────────────────────────────
2169
2157
  async fetchPresale(presalePda) {
2170
2158
  try {