@theliem/xmarket-sdk 3.1.2 → 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/{conditional_tokens-3O5V46N5.json → conditional_tokens-X53GZYAY.json} +17 -17
- package/dist/index.d.mts +9 -21
- package/dist/index.d.ts +9 -21
- package/dist/index.js +28 -70
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -71
- package/dist/index.mjs.map +1 -1
- package/dist/{presale-Q4NDVQFN.json → presale-D7EQAQDZ.json} +16 -320
- package/dist/{question_market-RP3J3N2M.json → question_market-CD4WRZLT.json} +15 -1
- package/package.json +1 -1
- package/src/idls/conditional_tokens.json +17 -17
- package/src/idls/presale.json +16 -320
- package/src/idls/question_market.json +15 -1
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-
|
|
8
|
-
import conditionalTokensIdl from './conditional_tokens-
|
|
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-
|
|
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';
|
|
@@ -273,28 +273,24 @@ var OracleClient = class {
|
|
|
273
273
|
}
|
|
274
274
|
/**
|
|
275
275
|
* Whitelisted reporter resolves a question.
|
|
276
|
-
*
|
|
277
|
-
* @param conditionPda - CTF condition account (oracle_config = oraclePda, question_id must match)
|
|
278
|
-
* @param ownerPubkey - oracle config owner (defaults to wallet)
|
|
279
|
-
* @param payer - fee payer (defaults to wallet)
|
|
276
|
+
* reporter signs the instruction; payer covers the tx fee (Kora pattern).
|
|
280
277
|
*/
|
|
281
|
-
async resolveQuestion(questionId, outcomeCount, payoutNumerators, conditionPda,
|
|
278
|
+
async resolveQuestion(questionId, outcomeCount, payoutNumerators, conditionPda, reporter = this.walletPubkey, payer = this.walletPubkey, ownerPubkey) {
|
|
282
279
|
const oracleConfig = this.configPda(ownerPubkey);
|
|
283
280
|
const [questionResultPda] = PDA.questionResult(oracleConfig, questionId, this.programIds);
|
|
284
|
-
|
|
281
|
+
return this.program.methods.resolveQuestion(
|
|
285
282
|
Array.from(questionId),
|
|
286
283
|
outcomeCount,
|
|
287
284
|
payoutNumerators.map((n) => new anchor4.BN(n))
|
|
288
285
|
).accounts({
|
|
289
|
-
reporter
|
|
286
|
+
reporter,
|
|
290
287
|
oracleConfig,
|
|
291
288
|
questionResult: questionResultPda,
|
|
292
289
|
condition: conditionPda,
|
|
293
290
|
conditionalTokensProgram: this.programIds.conditionalTokens,
|
|
294
|
-
payer
|
|
291
|
+
payer,
|
|
295
292
|
systemProgram: SystemProgram.programId
|
|
296
|
-
}).
|
|
297
|
-
return { signature: sig };
|
|
293
|
+
}).transaction();
|
|
298
294
|
}
|
|
299
295
|
/** Owner updates the admin. */
|
|
300
296
|
async updateAdmin(newAdmin, ownerPubkey) {
|
|
@@ -732,6 +728,9 @@ var MarketClient = class {
|
|
|
732
728
|
systemProgram: SystemProgram.programId,
|
|
733
729
|
rent: SYSVAR_RENT_PUBKEY
|
|
734
730
|
}).transaction();
|
|
731
|
+
tx.instructions.unshift(
|
|
732
|
+
ComputeBudgetProgram.setComputeUnitLimit({ units: 4e5 })
|
|
733
|
+
);
|
|
735
734
|
return { tx, presalePda, qtMint };
|
|
736
735
|
}
|
|
737
736
|
/**
|
|
@@ -805,14 +804,15 @@ var MarketClient = class {
|
|
|
805
804
|
}).transaction();
|
|
806
805
|
}
|
|
807
806
|
/**
|
|
808
|
-
* Whitelist-only: distribute presale vault
|
|
809
|
-
*
|
|
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.
|
|
810
809
|
*/
|
|
811
|
-
async collectPresaleRevenue(presalePda, currencyMint, referralAddress, companyAddress, caller = this.walletPubkey) {
|
|
810
|
+
async collectPresaleRevenue(presalePda, currencyMint, referralAddress, companyAddress, botmmAddress, caller = this.walletPubkey, payer = this.walletPubkey) {
|
|
812
811
|
if (!this.programIds.presale) throw new Error("presale program ID not configured");
|
|
813
812
|
const presaleVault = getAssociatedTokenAddressSync(currencyMint, presalePda, true);
|
|
814
813
|
const referralTokenAccount = getAssociatedTokenAddressSync(currencyMint, referralAddress);
|
|
815
814
|
const companyTokenAccount = getAssociatedTokenAddressSync(currencyMint, companyAddress);
|
|
815
|
+
const botmmTokenAccount = getAssociatedTokenAddressSync(currencyMint, botmmAddress);
|
|
816
816
|
return this.program.methods.collectPresaleRevenue().accounts({
|
|
817
817
|
caller,
|
|
818
818
|
config: this.configPda,
|
|
@@ -821,6 +821,8 @@ var MarketClient = class {
|
|
|
821
821
|
currencyMint,
|
|
822
822
|
referralTokenAccount,
|
|
823
823
|
companyTokenAccount,
|
|
824
|
+
botmmTokenAccount,
|
|
825
|
+
payer,
|
|
824
826
|
presaleProgram: this.programIds.presale,
|
|
825
827
|
tokenProgram: TOKEN_PROGRAM_ID,
|
|
826
828
|
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
@@ -1370,8 +1372,8 @@ var ClobClient = class {
|
|
|
1370
1372
|
async _sendLegacyTx(instructions) {
|
|
1371
1373
|
const { connection } = this.provider;
|
|
1372
1374
|
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash();
|
|
1373
|
-
const { Transaction:
|
|
1374
|
-
const tx = new
|
|
1375
|
+
const { Transaction: Transaction7 } = await import('@solana/web3.js');
|
|
1376
|
+
const tx = new Transaction7();
|
|
1375
1377
|
tx.recentBlockhash = blockhash;
|
|
1376
1378
|
tx.feePayer = this.walletPubkey;
|
|
1377
1379
|
tx.add(...instructions);
|
|
@@ -2054,7 +2056,7 @@ var PresaleClient = class {
|
|
|
2054
2056
|
* qtAmount: amount of MST to receive (9 decimals).
|
|
2055
2057
|
* USDC cost = qtAmount * price / 1e9.
|
|
2056
2058
|
*/
|
|
2057
|
-
async buy(presalePda, qtAmount, buyer = this.walletPubkey, payer = this.walletPubkey
|
|
2059
|
+
async buy(presalePda, qtAmount, buyer = this.walletPubkey, payer = this.walletPubkey) {
|
|
2058
2060
|
const presale = await this.fetchPresale(presalePda);
|
|
2059
2061
|
if (!presale) throw new Error(`Presale not found: ${presalePda.toBase58()}`);
|
|
2060
2062
|
const qtMint = presale.qtMint;
|
|
@@ -2064,7 +2066,7 @@ var PresaleClient = class {
|
|
|
2064
2066
|
const buyerQtAta = getAssociatedTokenAddressSync(qtMint, buyer);
|
|
2065
2067
|
const buyerCurrencyAta = getAssociatedTokenAddressSync(currencyMint, buyer);
|
|
2066
2068
|
const presaleVault = getAssociatedTokenAddressSync(currencyMint, presalePda, true);
|
|
2067
|
-
|
|
2069
|
+
return this.program.methods.buy(qtAmount).accounts({
|
|
2068
2070
|
buyer,
|
|
2069
2071
|
payer,
|
|
2070
2072
|
presale: presalePda,
|
|
@@ -2078,14 +2080,13 @@ var PresaleClient = class {
|
|
|
2078
2080
|
tokenProgram: TOKEN_PROGRAM_ID,
|
|
2079
2081
|
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
2080
2082
|
systemProgram: SystemProgram.programId
|
|
2081
|
-
}).
|
|
2082
|
-
return { signature: sig };
|
|
2083
|
+
}).transaction();
|
|
2083
2084
|
}
|
|
2084
2085
|
/**
|
|
2085
2086
|
* Refund: burn user's MST and return USDC.
|
|
2086
2087
|
* Only callable when presale status = Rejected.
|
|
2087
2088
|
*/
|
|
2088
|
-
async refund(presalePda, user = this.walletPubkey
|
|
2089
|
+
async refund(presalePda, user = this.walletPubkey) {
|
|
2089
2090
|
const presale = await this.fetchPresale(presalePda);
|
|
2090
2091
|
if (!presale) throw new Error(`Presale not found: ${presalePda.toBase58()}`);
|
|
2091
2092
|
const qtMint = presale.qtMint;
|
|
@@ -2094,7 +2095,7 @@ var PresaleClient = class {
|
|
|
2094
2095
|
const userQtAta = getAssociatedTokenAddressSync(qtMint, user);
|
|
2095
2096
|
const userCurrencyAta = getAssociatedTokenAddressSync(currencyMint, user);
|
|
2096
2097
|
const presaleVault = getAssociatedTokenAddressSync(currencyMint, presalePda, true);
|
|
2097
|
-
|
|
2098
|
+
return this.program.methods.refund().accounts({
|
|
2098
2099
|
user,
|
|
2099
2100
|
presale: presalePda,
|
|
2100
2101
|
qtMint,
|
|
@@ -2106,48 +2107,6 @@ var PresaleClient = class {
|
|
|
2106
2107
|
tokenProgram: TOKEN_PROGRAM_ID,
|
|
2107
2108
|
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
2108
2109
|
systemProgram: SystemProgram.programId
|
|
2109
|
-
}).signers(signers).rpc();
|
|
2110
|
-
return { signature: sig };
|
|
2111
|
-
}
|
|
2112
|
-
/**
|
|
2113
|
-
* Creator claims their share of presale revenue after distribute_presale_revenue.
|
|
2114
|
-
*/
|
|
2115
|
-
async claimRevenue(presalePda, creator = this.walletPubkey, signers = []) {
|
|
2116
|
-
const presale = await this.fetchPresale(presalePda);
|
|
2117
|
-
if (!presale) throw new Error(`Presale not found: ${presalePda.toBase58()}`);
|
|
2118
|
-
const currencyMint = presale.currencyMint;
|
|
2119
|
-
const presaleVault = getAssociatedTokenAddressSync(currencyMint, presalePda, true);
|
|
2120
|
-
const creatorCurrencyAta = getAssociatedTokenAddressSync(currencyMint, creator);
|
|
2121
|
-
const sig = await this.program.methods.claimRevenue().accounts({
|
|
2122
|
-
creator,
|
|
2123
|
-
presale: presalePda,
|
|
2124
|
-
presaleVault,
|
|
2125
|
-
creatorCurrencyAta,
|
|
2126
|
-
currencyMint,
|
|
2127
|
-
tokenProgram: TOKEN_PROGRAM_ID,
|
|
2128
|
-
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
2129
|
-
systemProgram: SystemProgram.programId
|
|
2130
|
-
}).signers(signers).rpc();
|
|
2131
|
-
return { signature: sig };
|
|
2132
|
-
}
|
|
2133
|
-
/**
|
|
2134
|
-
* Transfer creator_claimable_revenue (80%) to BOTMM wallet.
|
|
2135
|
-
* Call after collectPresaleRevenue (distribute_presale_revenue).
|
|
2136
|
-
*/
|
|
2137
|
-
async distributeBotmmRevenue(presalePda, botmmAddress, currencyMint) {
|
|
2138
|
-
if (!currencyMint) {
|
|
2139
|
-
const presale = await this.fetchPresale(presalePda);
|
|
2140
|
-
if (!presale) throw new Error(`Presale not found: ${presalePda.toBase58()}`);
|
|
2141
|
-
currencyMint = presale.currencyMint;
|
|
2142
|
-
}
|
|
2143
|
-
const presaleVault = getAssociatedTokenAddressSync(currencyMint, presalePda, true);
|
|
2144
|
-
const botmmTokenAccount = getAssociatedTokenAddressSync(currencyMint, botmmAddress);
|
|
2145
|
-
return this.program.methods.distributeBotmmRevenue().accounts({
|
|
2146
|
-
presale: presalePda,
|
|
2147
|
-
presaleVault,
|
|
2148
|
-
currencyMint,
|
|
2149
|
-
botmmTokenAccount,
|
|
2150
|
-
tokenProgram: TOKEN_PROGRAM_ID
|
|
2151
2110
|
}).transaction();
|
|
2152
2111
|
}
|
|
2153
2112
|
// ─── Queries ─────────────────────────────────────────────────────────────────
|
|
@@ -2215,7 +2174,7 @@ var MarketOracleClient = class {
|
|
|
2215
2174
|
* User burns their MST and claims proportional share of oracle vault USDC.
|
|
2216
2175
|
* Call after market.collectTradingFee snapshotted qt supply.
|
|
2217
2176
|
*/
|
|
2218
|
-
async claimFeesShare(marketOraclePda, user = this.walletPubkey, payer = this.walletPubkey
|
|
2177
|
+
async claimFeesShare(marketOraclePda, user = this.walletPubkey, payer = this.walletPubkey) {
|
|
2219
2178
|
const oracle = await this.fetchMarketOracle(marketOraclePda);
|
|
2220
2179
|
if (!oracle) throw new Error(`MarketOracle not found: ${marketOraclePda.toBase58()}`);
|
|
2221
2180
|
const currencyMint = oracle.currencyMint;
|
|
@@ -2224,7 +2183,7 @@ var MarketOracleClient = class {
|
|
|
2224
2183
|
const userQtAta = getAssociatedTokenAddressSync(qtMint, user);
|
|
2225
2184
|
const userCurrencyAta = getAssociatedTokenAddressSync(currencyMint, user);
|
|
2226
2185
|
const userClaimRecord = this.userClaimRecordPda(marketOraclePda, user);
|
|
2227
|
-
|
|
2186
|
+
return this.program.methods.claimFeesShare().accounts({
|
|
2228
2187
|
user,
|
|
2229
2188
|
payer,
|
|
2230
2189
|
marketOracle: marketOraclePda,
|
|
@@ -2237,8 +2196,7 @@ var MarketOracleClient = class {
|
|
|
2237
2196
|
tokenProgram: TOKEN_PROGRAM_ID,
|
|
2238
2197
|
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
2239
2198
|
systemProgram: SystemProgram.programId
|
|
2240
|
-
}).
|
|
2241
|
-
return { signature: sig };
|
|
2199
|
+
}).transaction();
|
|
2242
2200
|
}
|
|
2243
2201
|
// ─── Queries ─────────────────────────────────────────────────────────────────
|
|
2244
2202
|
async fetchMarketOracle(marketOraclePda) {
|