@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.d.mts +7 -13
- package/dist/index.d.ts +7 -13
- package/dist/index.js +34 -46
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -47
- package/dist/index.mjs.map +1 -1
- package/dist/{oracle-A5VOIMGM.json → oracle-O53KMXDK.json} +119 -155
- package/dist/{presale-ZZJXXQS3.json → presale-Q4NDVQFN.json} +169 -0
- package/dist/{question_market-77YI4LRP.json → question_market-RP3J3N2M.json} +492 -369
- package/package.json +1 -1
- package/src/idls/oracle.json +119 -155
- package/src/idls/presale.json +169 -0
- package/src/idls/question_market.json +492 -369
package/dist/index.d.mts
CHANGED
|
@@ -241,9 +241,9 @@ declare class OracleClient {
|
|
|
241
241
|
configPda(owner?: PublicKey): PublicKey;
|
|
242
242
|
/** One-time setup. Caller becomes owner. */
|
|
243
243
|
initialize(admin: PublicKey): Promise<TxResult>;
|
|
244
|
-
/** Admin or owner adds an address to the oracle whitelist. */
|
|
244
|
+
/** Admin or owner adds an address to the oracle resolver whitelist. */
|
|
245
245
|
addToWhitelist(address: PublicKey, ownerPubkey?: PublicKey): Promise<TxResult>;
|
|
246
|
-
/** Admin or owner removes an address from the oracle whitelist. */
|
|
246
|
+
/** Admin or owner removes an address from the oracle resolver whitelist. */
|
|
247
247
|
removeFromWhitelist(address: PublicKey, ownerPubkey?: PublicKey): Promise<TxResult>;
|
|
248
248
|
/**
|
|
249
249
|
* Whitelisted reporter resolves a question.
|
|
@@ -415,17 +415,6 @@ declare class MarketClient {
|
|
|
415
415
|
constructor(program: anchor.Program, provider: anchor.AnchorProvider, programIds: ProgramIds, ownerPubkey: PublicKey);
|
|
416
416
|
get walletPubkey(): PublicKey;
|
|
417
417
|
initialize(admin: PublicKey, oracle: PublicKey, owner?: PublicKey): Promise<Transaction>;
|
|
418
|
-
/**
|
|
419
|
-
* Build createQuestion transaction.
|
|
420
|
-
* @param payer - Pays rent for all new accounts (can differ from creator)
|
|
421
|
-
* @param creator - Identity of the question creator (signs but does not pay)
|
|
422
|
-
*/
|
|
423
|
-
createQuestion(params: CreateQuestionParams, oracle: PublicKey, creator?: PublicKey, payer?: PublicKey): Promise<{
|
|
424
|
-
tx: Transaction;
|
|
425
|
-
questionPda: PublicKey;
|
|
426
|
-
conditionPda: PublicKey;
|
|
427
|
-
questionId: Uint8Array;
|
|
428
|
-
}>;
|
|
429
418
|
/**
|
|
430
419
|
* Build createQuestionAdmin transaction (whitelist/admin path — status = Approved immediately).
|
|
431
420
|
* @param creator - Whitelisted creator (must be in whitelist or be admin/owner)
|
|
@@ -736,6 +725,11 @@ declare class PresaleClient {
|
|
|
736
725
|
* Creator claims their share of presale revenue after distribute_presale_revenue.
|
|
737
726
|
*/
|
|
738
727
|
claimRevenue(presalePda: PublicKey, creator?: PublicKey, signers?: Keypair[]): Promise<TxResult>;
|
|
728
|
+
/**
|
|
729
|
+
* Transfer creator_claimable_revenue (80%) to BOTMM wallet.
|
|
730
|
+
* Call after collectPresaleRevenue (distribute_presale_revenue).
|
|
731
|
+
*/
|
|
732
|
+
distributeBotmmRevenue(presalePda: PublicKey, botmmAddress: PublicKey, currencyMint?: PublicKey): Promise<Transaction>;
|
|
739
733
|
fetchPresale(presalePda: PublicKey): Promise<PresaleInfo | null>;
|
|
740
734
|
fetchUserBuyRecord(presalePda: PublicKey, user: PublicKey): Promise<UserBuyRecord | null>;
|
|
741
735
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -241,9 +241,9 @@ declare class OracleClient {
|
|
|
241
241
|
configPda(owner?: PublicKey): PublicKey;
|
|
242
242
|
/** One-time setup. Caller becomes owner. */
|
|
243
243
|
initialize(admin: PublicKey): Promise<TxResult>;
|
|
244
|
-
/** Admin or owner adds an address to the oracle whitelist. */
|
|
244
|
+
/** Admin or owner adds an address to the oracle resolver whitelist. */
|
|
245
245
|
addToWhitelist(address: PublicKey, ownerPubkey?: PublicKey): Promise<TxResult>;
|
|
246
|
-
/** Admin or owner removes an address from the oracle whitelist. */
|
|
246
|
+
/** Admin or owner removes an address from the oracle resolver whitelist. */
|
|
247
247
|
removeFromWhitelist(address: PublicKey, ownerPubkey?: PublicKey): Promise<TxResult>;
|
|
248
248
|
/**
|
|
249
249
|
* Whitelisted reporter resolves a question.
|
|
@@ -415,17 +415,6 @@ declare class MarketClient {
|
|
|
415
415
|
constructor(program: anchor.Program, provider: anchor.AnchorProvider, programIds: ProgramIds, ownerPubkey: PublicKey);
|
|
416
416
|
get walletPubkey(): PublicKey;
|
|
417
417
|
initialize(admin: PublicKey, oracle: PublicKey, owner?: PublicKey): Promise<Transaction>;
|
|
418
|
-
/**
|
|
419
|
-
* Build createQuestion transaction.
|
|
420
|
-
* @param payer - Pays rent for all new accounts (can differ from creator)
|
|
421
|
-
* @param creator - Identity of the question creator (signs but does not pay)
|
|
422
|
-
*/
|
|
423
|
-
createQuestion(params: CreateQuestionParams, oracle: PublicKey, creator?: PublicKey, payer?: PublicKey): Promise<{
|
|
424
|
-
tx: Transaction;
|
|
425
|
-
questionPda: PublicKey;
|
|
426
|
-
conditionPda: PublicKey;
|
|
427
|
-
questionId: Uint8Array;
|
|
428
|
-
}>;
|
|
429
418
|
/**
|
|
430
419
|
* Build createQuestionAdmin transaction (whitelist/admin path — status = Approved immediately).
|
|
431
420
|
* @param creator - Whitelisted creator (must be in whitelist or be admin/owner)
|
|
@@ -736,6 +725,11 @@ declare class PresaleClient {
|
|
|
736
725
|
* Creator claims their share of presale revenue after distribute_presale_revenue.
|
|
737
726
|
*/
|
|
738
727
|
claimRevenue(presalePda: PublicKey, creator?: PublicKey, signers?: Keypair[]): Promise<TxResult>;
|
|
728
|
+
/**
|
|
729
|
+
* Transfer creator_claimable_revenue (80%) to BOTMM wallet.
|
|
730
|
+
* Call after collectPresaleRevenue (distribute_presale_revenue).
|
|
731
|
+
*/
|
|
732
|
+
distributeBotmmRevenue(presalePda: PublicKey, botmmAddress: PublicKey, currencyMint?: PublicKey): Promise<Transaction>;
|
|
739
733
|
fetchPresale(presalePda: PublicKey): Promise<PresaleInfo | null>;
|
|
740
734
|
fetchUserBuyRecord(presalePda: PublicKey, user: PublicKey): Promise<UserBuyRecord | null>;
|
|
741
735
|
}
|
package/dist/index.js
CHANGED
|
@@ -4,13 +4,13 @@ var anchor4 = require('@coral-xyz/anchor');
|
|
|
4
4
|
var web3_js = require('@solana/web3.js');
|
|
5
5
|
var crypto = require('crypto');
|
|
6
6
|
var splToken = require('@solana/spl-token');
|
|
7
|
-
var oracleIdl = require('./oracle-
|
|
7
|
+
var oracleIdl = require('./oracle-O53KMXDK.json');
|
|
8
8
|
var hookIdl = require('./hook-THBRGUM6.json');
|
|
9
|
-
var questionMarketIdl = require('./question_market-
|
|
9
|
+
var questionMarketIdl = require('./question_market-RP3J3N2M.json');
|
|
10
10
|
var conditionalTokensIdl = require('./conditional_tokens-3O5V46N5.json');
|
|
11
11
|
var clobExchangeIdl = require('./clob_exchange-MQF4NI27.json');
|
|
12
12
|
var feeManagementIdl = require('./fee_management-VGF77YXG.json');
|
|
13
|
-
var presaleIdl = require('./presale-
|
|
13
|
+
var presaleIdl = require('./presale-Q4NDVQFN.json');
|
|
14
14
|
var marketOracleIdl = require('./market_oracle-E6UUARGR.json');
|
|
15
15
|
var BN4 = require('bn.js');
|
|
16
16
|
var nacl = require('tweetnacl');
|
|
@@ -287,7 +287,7 @@ var OracleClient = class {
|
|
|
287
287
|
}).rpc();
|
|
288
288
|
return { signature: sig };
|
|
289
289
|
}
|
|
290
|
-
/** Admin or owner adds an address to the oracle whitelist. */
|
|
290
|
+
/** Admin or owner adds an address to the oracle resolver whitelist. */
|
|
291
291
|
async addToWhitelist(address, ownerPubkey) {
|
|
292
292
|
const sig = await this.program.methods.addToWhitelist(address).accounts({
|
|
293
293
|
authority: this.walletPubkey,
|
|
@@ -296,7 +296,7 @@ var OracleClient = class {
|
|
|
296
296
|
}).rpc();
|
|
297
297
|
return { signature: sig };
|
|
298
298
|
}
|
|
299
|
-
/** Admin or owner removes an address from the oracle whitelist. */
|
|
299
|
+
/** Admin or owner removes an address from the oracle resolver whitelist. */
|
|
300
300
|
async removeFromWhitelist(address, ownerPubkey) {
|
|
301
301
|
const sig = await this.program.methods.removeFromWhitelist(address).accounts({
|
|
302
302
|
authority: this.walletPubkey,
|
|
@@ -544,6 +544,7 @@ var InvalidParamError = class extends XMarketError {
|
|
|
544
544
|
};
|
|
545
545
|
|
|
546
546
|
// src/programs/market.ts
|
|
547
|
+
var TOKEN_METADATA_PROGRAM_ID = new web3_js.PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s");
|
|
547
548
|
var MarketClient = class {
|
|
548
549
|
constructor(program, provider, programIds, ownerPubkey) {
|
|
549
550
|
this.program = program;
|
|
@@ -566,45 +567,6 @@ var MarketClient = class {
|
|
|
566
567
|
systemProgram: web3_js.SystemProgram.programId
|
|
567
568
|
}).transaction();
|
|
568
569
|
}
|
|
569
|
-
/**
|
|
570
|
-
* Build createQuestion transaction.
|
|
571
|
-
* @param payer - Pays rent for all new accounts (can differ from creator)
|
|
572
|
-
* @param creator - Identity of the question creator (signs but does not pay)
|
|
573
|
-
*/
|
|
574
|
-
async createQuestion(params, oracle, creator = this.walletPubkey, payer = this.walletPubkey) {
|
|
575
|
-
const questionId = params.questionId ?? generateQuestionId(params.content);
|
|
576
|
-
const contentHash = params.contentHash ?? generateContentHash(params.content);
|
|
577
|
-
const [questionPda] = PDA.question(this.configPda, questionId, this.programIds);
|
|
578
|
-
const [conditionPda] = PDA.condition(oracle, questionId, this.programIds);
|
|
579
|
-
const [yesMint] = PDA.yesMint(conditionPda, this.programIds);
|
|
580
|
-
const [noMint] = PDA.noMint(conditionPda, this.programIds);
|
|
581
|
-
const [mintAuthority] = PDA.mintAuthority(conditionPda, this.programIds);
|
|
582
|
-
const [collateralVault] = PDA.collateralVault(params.collateralMint, this.programIds);
|
|
583
|
-
const tx = await this.program.methods.createQuestionWithCondition({
|
|
584
|
-
questionId: Array.from(questionId),
|
|
585
|
-
contentHash: Array.from(contentHash),
|
|
586
|
-
hookProgram: params.hookProgram,
|
|
587
|
-
authorizedClob: params.authorizedClob,
|
|
588
|
-
expirationTime: new anchor4__namespace.BN(params.expirationTime)
|
|
589
|
-
}).accounts({
|
|
590
|
-
payer,
|
|
591
|
-
creator,
|
|
592
|
-
config: this.configPda,
|
|
593
|
-
question: questionPda,
|
|
594
|
-
currencyMint: params.collateralMint,
|
|
595
|
-
oracle,
|
|
596
|
-
condition: conditionPda,
|
|
597
|
-
yesMint,
|
|
598
|
-
noMint,
|
|
599
|
-
mintAuthority,
|
|
600
|
-
collateralVault,
|
|
601
|
-
conditionalTokensProgram: this.programIds.conditionalTokens,
|
|
602
|
-
tokenProgram: splToken.TOKEN_2022_PROGRAM_ID,
|
|
603
|
-
systemProgram: web3_js.SystemProgram.programId,
|
|
604
|
-
rent: web3_js.SYSVAR_RENT_PUBKEY
|
|
605
|
-
}).transaction();
|
|
606
|
-
return { tx, questionPda, conditionPda, questionId };
|
|
607
|
-
}
|
|
608
570
|
/**
|
|
609
571
|
* Build createQuestionAdmin transaction (whitelist/admin path — status = Approved immediately).
|
|
610
572
|
* @param creator - Whitelisted creator (must be in whitelist or be admin/owner)
|
|
@@ -774,6 +736,10 @@ var MarketClient = class {
|
|
|
774
736
|
const presaleVault = splToken.getAssociatedTokenAddressSync(currencyMint, presalePda, true);
|
|
775
737
|
const creatorQtAta = splToken.getAssociatedTokenAddressSync(qtMint, creator);
|
|
776
738
|
const creatorCurrencyAta = splToken.getAssociatedTokenAddressSync(currencyMint, creator);
|
|
739
|
+
const [qtMetadata] = web3_js.PublicKey.findProgramAddressSync(
|
|
740
|
+
[Buffer.from("metadata"), TOKEN_METADATA_PROGRAM_ID.toBuffer(), qtMint.toBuffer()],
|
|
741
|
+
TOKEN_METADATA_PROGRAM_ID
|
|
742
|
+
);
|
|
777
743
|
const tx = await this.program.methods.createPresale({
|
|
778
744
|
price: params.price,
|
|
779
745
|
startTime: params.startTime,
|
|
@@ -792,6 +758,8 @@ var MarketClient = class {
|
|
|
792
758
|
creatorCurrencyAta,
|
|
793
759
|
creatorQtAta,
|
|
794
760
|
userBuyRecord,
|
|
761
|
+
qtMetadata,
|
|
762
|
+
tokenMetadataProgram: TOKEN_METADATA_PROGRAM_ID,
|
|
795
763
|
presaleProgram: this.programIds.presale,
|
|
796
764
|
tokenProgram: splToken.TOKEN_PROGRAM_ID,
|
|
797
765
|
associatedTokenProgram: splToken.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
@@ -1439,8 +1407,8 @@ var ClobClient = class {
|
|
|
1439
1407
|
async _sendLegacyTx(instructions) {
|
|
1440
1408
|
const { connection } = this.provider;
|
|
1441
1409
|
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash();
|
|
1442
|
-
const { Transaction:
|
|
1443
|
-
const tx = new
|
|
1410
|
+
const { Transaction: Transaction4 } = await import('@solana/web3.js');
|
|
1411
|
+
const tx = new Transaction4();
|
|
1444
1412
|
tx.recentBlockhash = blockhash;
|
|
1445
1413
|
tx.feePayer = this.walletPubkey;
|
|
1446
1414
|
tx.add(...instructions);
|
|
@@ -2199,6 +2167,26 @@ var PresaleClient = class {
|
|
|
2199
2167
|
}).signers(signers).rpc();
|
|
2200
2168
|
return { signature: sig };
|
|
2201
2169
|
}
|
|
2170
|
+
/**
|
|
2171
|
+
* Transfer creator_claimable_revenue (80%) to BOTMM wallet.
|
|
2172
|
+
* Call after collectPresaleRevenue (distribute_presale_revenue).
|
|
2173
|
+
*/
|
|
2174
|
+
async distributeBotmmRevenue(presalePda, botmmAddress, currencyMint) {
|
|
2175
|
+
if (!currencyMint) {
|
|
2176
|
+
const presale = await this.fetchPresale(presalePda);
|
|
2177
|
+
if (!presale) throw new Error(`Presale not found: ${presalePda.toBase58()}`);
|
|
2178
|
+
currencyMint = presale.currencyMint;
|
|
2179
|
+
}
|
|
2180
|
+
const presaleVault = splToken.getAssociatedTokenAddressSync(currencyMint, presalePda, true);
|
|
2181
|
+
const botmmTokenAccount = splToken.getAssociatedTokenAddressSync(currencyMint, botmmAddress);
|
|
2182
|
+
return this.program.methods.distributeBotmmRevenue().accounts({
|
|
2183
|
+
presale: presalePda,
|
|
2184
|
+
presaleVault,
|
|
2185
|
+
currencyMint,
|
|
2186
|
+
botmmTokenAccount,
|
|
2187
|
+
tokenProgram: splToken.TOKEN_PROGRAM_ID
|
|
2188
|
+
}).transaction();
|
|
2189
|
+
}
|
|
2202
2190
|
// ─── Queries ─────────────────────────────────────────────────────────────────
|
|
2203
2191
|
async fetchPresale(presalePda) {
|
|
2204
2192
|
try {
|