@theliem/xmarket-sdk 3.1.3 → 3.2.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
@@ -1,14 +1,14 @@
1
1
  import * as anchor4 from '@coral-xyz/anchor';
2
- import { PublicKey, SYSVAR_INSTRUCTIONS_PUBKEY, 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, ComputeBudgetProgram, 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
5
  import oracleIdl from './oracle-O53KMXDK.json';
6
6
  import hookIdl from './hook-THBRGUM6.json';
7
- import questionMarketIdl from './question_market-RP3J3N2M.json';
8
- import conditionalTokensIdl from './conditional_tokens-3O5V46N5.json';
7
+ import questionMarketIdl from './question_market-CD4WRZLT.json';
8
+ import conditionalTokensIdl from './conditional_tokens-X53GZYAY.json';
9
9
  import clobExchangeIdl from './clob_exchange-MQF4NI27.json';
10
10
  import feeManagementIdl from './fee_management-VGF77YXG.json';
11
- import presaleIdl from './presale-Q4NDVQFN.json';
11
+ import presaleIdl from './presale-D7EQAQDZ.json';
12
12
  import marketOracleIdl from './market_oracle-E6UUARGR.json';
13
13
  import BN4 from 'bn.js';
14
14
  import * as nacl from 'tweetnacl';
@@ -728,6 +728,9 @@ var MarketClient = class {
728
728
  systemProgram: SystemProgram.programId,
729
729
  rent: SYSVAR_RENT_PUBKEY
730
730
  }).transaction();
731
+ tx.instructions.unshift(
732
+ ComputeBudgetProgram.setComputeUnitLimit({ units: 4e5 })
733
+ );
731
734
  return { tx, presalePda, qtMint };
732
735
  }
733
736
  /**
@@ -801,14 +804,15 @@ var MarketClient = class {
801
804
  }).transaction();
802
805
  }
803
806
  /**
804
- * Whitelist-only: distribute presale vault funds agents_rev% + company_rev% + rest to creator.
805
- * Must be called after approvePresale.
807
+ * Whitelist-only: distribute presale vault → 10% agents + 10% company + 80% botmm.
808
+ * Closes presale_vault ATA and presale PDA after distribution; lamports returned to payer.
806
809
  */
807
- async collectPresaleRevenue(presalePda, currencyMint, referralAddress, companyAddress, caller = this.walletPubkey) {
810
+ async collectPresaleRevenue(presalePda, currencyMint, referralAddress, companyAddress, botmmAddress, caller = this.walletPubkey, payer = this.walletPubkey) {
808
811
  if (!this.programIds.presale) throw new Error("presale program ID not configured");
809
812
  const presaleVault = getAssociatedTokenAddressSync(currencyMint, presalePda, true);
810
813
  const referralTokenAccount = getAssociatedTokenAddressSync(currencyMint, referralAddress);
811
814
  const companyTokenAccount = getAssociatedTokenAddressSync(currencyMint, companyAddress);
815
+ const botmmTokenAccount = getAssociatedTokenAddressSync(currencyMint, botmmAddress);
812
816
  return this.program.methods.collectPresaleRevenue().accounts({
813
817
  caller,
814
818
  config: this.configPda,
@@ -817,6 +821,8 @@ var MarketClient = class {
817
821
  currencyMint,
818
822
  referralTokenAccount,
819
823
  companyTokenAccount,
824
+ botmmTokenAccount,
825
+ payer,
820
826
  presaleProgram: this.programIds.presale,
821
827
  tokenProgram: TOKEN_PROGRAM_ID,
822
828
  associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
@@ -2103,46 +2109,6 @@ var PresaleClient = class {
2103
2109
  systemProgram: SystemProgram.programId
2104
2110
  }).transaction();
2105
2111
  }
2106
- /**
2107
- * Creator claims their share of presale revenue after distribute_presale_revenue.
2108
- */
2109
- async claimRevenue(presalePda, creator = this.walletPubkey) {
2110
- const presale = await this.fetchPresale(presalePda);
2111
- if (!presale) throw new Error(`Presale not found: ${presalePda.toBase58()}`);
2112
- const currencyMint = presale.currencyMint;
2113
- const presaleVault = getAssociatedTokenAddressSync(currencyMint, presalePda, true);
2114
- const creatorCurrencyAta = getAssociatedTokenAddressSync(currencyMint, creator);
2115
- return this.program.methods.claimRevenue().accounts({
2116
- creator,
2117
- presale: presalePda,
2118
- presaleVault,
2119
- creatorCurrencyAta,
2120
- currencyMint,
2121
- tokenProgram: TOKEN_PROGRAM_ID,
2122
- associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
2123
- systemProgram: SystemProgram.programId
2124
- }).transaction();
2125
- }
2126
- /**
2127
- * Transfer creator_claimable_revenue (80%) to BOTMM wallet.
2128
- * Call after collectPresaleRevenue (distribute_presale_revenue).
2129
- */
2130
- async distributeBotmmRevenue(presalePda, botmmAddress, currencyMint) {
2131
- if (!currencyMint) {
2132
- const presale = await this.fetchPresale(presalePda);
2133
- if (!presale) throw new Error(`Presale not found: ${presalePda.toBase58()}`);
2134
- currencyMint = presale.currencyMint;
2135
- }
2136
- const presaleVault = getAssociatedTokenAddressSync(currencyMint, presalePda, true);
2137
- const botmmTokenAccount = getAssociatedTokenAddressSync(currencyMint, botmmAddress);
2138
- return this.program.methods.distributeBotmmRevenue().accounts({
2139
- presale: presalePda,
2140
- presaleVault,
2141
- currencyMint,
2142
- botmmTokenAccount,
2143
- tokenProgram: TOKEN_PROGRAM_ID
2144
- }).transaction();
2145
- }
2146
2112
  // ─── Queries ─────────────────────────────────────────────────────────────────
2147
2113
  async fetchPresale(presalePda) {
2148
2114
  try {