@theliem/xmarket-sdk 3.1.0 → 3.1.2
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 +11 -17
- package/dist/index.d.ts +11 -17
- package/dist/index.js +43 -58
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -59
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as anchor from '@coral-xyz/anchor';
|
|
2
2
|
import * as _solana_web3_js from '@solana/web3.js';
|
|
3
|
-
import { PublicKey, Keypair,
|
|
3
|
+
import { PublicKey, Keypair, Transaction, TransactionInstruction, AddressLookupTableAccount } from '@solana/web3.js';
|
|
4
4
|
import BN from 'bn.js';
|
|
5
5
|
|
|
6
6
|
interface ProgramIds {
|
|
@@ -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.
|
|
@@ -342,17 +342,17 @@ declare class CtfClient {
|
|
|
342
342
|
* Split `amount` collateral into equal YES + NO tokens.
|
|
343
343
|
* ATAs created automatically via `init_if_needed`.
|
|
344
344
|
*/
|
|
345
|
-
splitPosition(condition: PublicKey, collateralMint: PublicKey, amount: anchor.BN, user?: PublicKey, payer?: PublicKey
|
|
345
|
+
splitPosition(condition: PublicKey, collateralMint: PublicKey, amount: anchor.BN, user?: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
346
346
|
/**
|
|
347
347
|
* Merge `amount` YES + NO tokens back into collateral.
|
|
348
348
|
* Both token balances must be ≥ amount.
|
|
349
349
|
*/
|
|
350
|
-
mergePosition(condition: PublicKey, collateralMint: PublicKey, amount: anchor.BN, user?: PublicKey, payer?: PublicKey
|
|
350
|
+
mergePosition(condition: PublicKey, collateralMint: PublicKey, amount: anchor.BN, user?: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
351
351
|
/**
|
|
352
352
|
* After condition resolves: burn outcome tokens proportional to payout
|
|
353
353
|
* and receive USDC. Works for winning, losing, or both positions.
|
|
354
354
|
*/
|
|
355
|
-
redeemPositions(condition: PublicKey, collateralMint: PublicKey, user?: PublicKey, payer?: PublicKey
|
|
355
|
+
redeemPositions(condition: PublicKey, collateralMint: PublicKey, user?: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
356
356
|
/**
|
|
357
357
|
* Oracle directly resolves a condition with payout numerators.
|
|
358
358
|
* Bypasses QuestionMarket — only for oracle-owned conditions.
|
|
@@ -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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as anchor from '@coral-xyz/anchor';
|
|
2
2
|
import * as _solana_web3_js from '@solana/web3.js';
|
|
3
|
-
import { PublicKey, Keypair,
|
|
3
|
+
import { PublicKey, Keypair, Transaction, TransactionInstruction, AddressLookupTableAccount } from '@solana/web3.js';
|
|
4
4
|
import BN from 'bn.js';
|
|
5
5
|
|
|
6
6
|
interface ProgramIds {
|
|
@@ -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.
|
|
@@ -342,17 +342,17 @@ declare class CtfClient {
|
|
|
342
342
|
* Split `amount` collateral into equal YES + NO tokens.
|
|
343
343
|
* ATAs created automatically via `init_if_needed`.
|
|
344
344
|
*/
|
|
345
|
-
splitPosition(condition: PublicKey, collateralMint: PublicKey, amount: anchor.BN, user?: PublicKey, payer?: PublicKey
|
|
345
|
+
splitPosition(condition: PublicKey, collateralMint: PublicKey, amount: anchor.BN, user?: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
346
346
|
/**
|
|
347
347
|
* Merge `amount` YES + NO tokens back into collateral.
|
|
348
348
|
* Both token balances must be ≥ amount.
|
|
349
349
|
*/
|
|
350
|
-
mergePosition(condition: PublicKey, collateralMint: PublicKey, amount: anchor.BN, user?: PublicKey, payer?: PublicKey
|
|
350
|
+
mergePosition(condition: PublicKey, collateralMint: PublicKey, amount: anchor.BN, user?: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
351
351
|
/**
|
|
352
352
|
* After condition resolves: burn outcome tokens proportional to payout
|
|
353
353
|
* and receive USDC. Works for winning, losing, or both positions.
|
|
354
354
|
*/
|
|
355
|
-
redeemPositions(condition: PublicKey, collateralMint: PublicKey, user?: PublicKey, payer?: PublicKey
|
|
355
|
+
redeemPositions(condition: PublicKey, collateralMint: PublicKey, user?: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
356
356
|
/**
|
|
357
357
|
* Oracle directly resolves a condition with payout numerators.
|
|
358
358
|
* Bypasses QuestionMarket — only for oracle-owned conditions.
|
|
@@ -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,
|
|
@@ -1002,7 +970,7 @@ var CtfClient = class {
|
|
|
1002
970
|
* Split `amount` collateral into equal YES + NO tokens.
|
|
1003
971
|
* ATAs created automatically via `init_if_needed`.
|
|
1004
972
|
*/
|
|
1005
|
-
async splitPosition(condition, collateralMint, amount, user = this.walletPubkey, payer = this.walletPubkey
|
|
973
|
+
async splitPosition(condition, collateralMint, amount, user = this.walletPubkey, payer = this.walletPubkey) {
|
|
1006
974
|
const [collateralVault] = PDA.collateralVault(collateralMint, this.programIds);
|
|
1007
975
|
const [vaultTokenAccount] = PDA.vaultToken(collateralMint, this.programIds);
|
|
1008
976
|
const [yesMint] = PDA.yesMint(condition, this.programIds);
|
|
@@ -1013,7 +981,7 @@ var CtfClient = class {
|
|
|
1013
981
|
const userYesAta = splToken.getAssociatedTokenAddressSync(yesMint, user, false, splToken.TOKEN_2022_PROGRAM_ID);
|
|
1014
982
|
const userNoAta = splToken.getAssociatedTokenAddressSync(noMint, user, false, splToken.TOKEN_2022_PROGRAM_ID);
|
|
1015
983
|
const userCollateral = splToken.getAssociatedTokenAddressSync(collateralMint, user);
|
|
1016
|
-
|
|
984
|
+
return this.program.methods.splitPosition(amount).accounts({
|
|
1017
985
|
user,
|
|
1018
986
|
payer,
|
|
1019
987
|
condition,
|
|
@@ -1031,14 +999,13 @@ var CtfClient = class {
|
|
|
1031
999
|
token2022Program: splToken.TOKEN_2022_PROGRAM_ID,
|
|
1032
1000
|
associatedTokenProgram: splToken.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
1033
1001
|
systemProgram: web3_js.SystemProgram.programId
|
|
1034
|
-
}).
|
|
1035
|
-
return { signature: sig };
|
|
1002
|
+
}).transaction();
|
|
1036
1003
|
}
|
|
1037
1004
|
/**
|
|
1038
1005
|
* Merge `amount` YES + NO tokens back into collateral.
|
|
1039
1006
|
* Both token balances must be ≥ amount.
|
|
1040
1007
|
*/
|
|
1041
|
-
async mergePosition(condition, collateralMint, amount, user = this.walletPubkey, payer = this.walletPubkey
|
|
1008
|
+
async mergePosition(condition, collateralMint, amount, user = this.walletPubkey, payer = this.walletPubkey) {
|
|
1042
1009
|
const [collateralVault] = PDA.collateralVault(collateralMint, this.programIds);
|
|
1043
1010
|
const [vaultTokenAccount] = PDA.vaultToken(collateralMint, this.programIds);
|
|
1044
1011
|
const [yesMint] = PDA.yesMint(condition, this.programIds);
|
|
@@ -1048,7 +1015,7 @@ var CtfClient = class {
|
|
|
1048
1015
|
const userYesAta = splToken.getAssociatedTokenAddressSync(yesMint, user, false, splToken.TOKEN_2022_PROGRAM_ID);
|
|
1049
1016
|
const userNoAta = splToken.getAssociatedTokenAddressSync(noMint, user, false, splToken.TOKEN_2022_PROGRAM_ID);
|
|
1050
1017
|
const userCollateral = splToken.getAssociatedTokenAddressSync(collateralMint, user);
|
|
1051
|
-
|
|
1018
|
+
return this.program.methods.mergePosition(amount).accounts({
|
|
1052
1019
|
user,
|
|
1053
1020
|
payer,
|
|
1054
1021
|
condition,
|
|
@@ -1064,14 +1031,13 @@ var CtfClient = class {
|
|
|
1064
1031
|
tokenProgram: splToken.TOKEN_PROGRAM_ID,
|
|
1065
1032
|
token2022Program: splToken.TOKEN_2022_PROGRAM_ID,
|
|
1066
1033
|
systemProgram: web3_js.SystemProgram.programId
|
|
1067
|
-
}).
|
|
1068
|
-
return { signature: sig };
|
|
1034
|
+
}).transaction();
|
|
1069
1035
|
}
|
|
1070
1036
|
/**
|
|
1071
1037
|
* After condition resolves: burn outcome tokens proportional to payout
|
|
1072
1038
|
* and receive USDC. Works for winning, losing, or both positions.
|
|
1073
1039
|
*/
|
|
1074
|
-
async redeemPositions(condition, collateralMint, user = this.walletPubkey, payer = this.walletPubkey
|
|
1040
|
+
async redeemPositions(condition, collateralMint, user = this.walletPubkey, payer = this.walletPubkey) {
|
|
1075
1041
|
const [collateralVault] = PDA.collateralVault(collateralMint, this.programIds);
|
|
1076
1042
|
const [vaultTokenAccount] = PDA.vaultToken(collateralMint, this.programIds);
|
|
1077
1043
|
const [yesMint] = PDA.yesMint(condition, this.programIds);
|
|
@@ -1081,7 +1047,7 @@ var CtfClient = class {
|
|
|
1081
1047
|
const userYesAta = splToken.getAssociatedTokenAddressSync(yesMint, user, false, splToken.TOKEN_2022_PROGRAM_ID);
|
|
1082
1048
|
const userNoAta = splToken.getAssociatedTokenAddressSync(noMint, user, false, splToken.TOKEN_2022_PROGRAM_ID);
|
|
1083
1049
|
const userCollateral = splToken.getAssociatedTokenAddressSync(collateralMint, user);
|
|
1084
|
-
|
|
1050
|
+
return this.program.methods.redeemPositions().accounts({
|
|
1085
1051
|
user,
|
|
1086
1052
|
payer,
|
|
1087
1053
|
condition,
|
|
@@ -1097,8 +1063,7 @@ var CtfClient = class {
|
|
|
1097
1063
|
tokenProgram: splToken.TOKEN_PROGRAM_ID,
|
|
1098
1064
|
token2022Program: splToken.TOKEN_2022_PROGRAM_ID,
|
|
1099
1065
|
systemProgram: web3_js.SystemProgram.programId
|
|
1100
|
-
}).
|
|
1101
|
-
return { signature: sig };
|
|
1066
|
+
}).transaction();
|
|
1102
1067
|
}
|
|
1103
1068
|
/**
|
|
1104
1069
|
* Oracle directly resolves a condition with payout numerators.
|
|
@@ -1439,8 +1404,8 @@ var ClobClient = class {
|
|
|
1439
1404
|
async _sendLegacyTx(instructions) {
|
|
1440
1405
|
const { connection } = this.provider;
|
|
1441
1406
|
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash();
|
|
1442
|
-
const { Transaction:
|
|
1443
|
-
const tx = new
|
|
1407
|
+
const { Transaction: Transaction5 } = await import('@solana/web3.js');
|
|
1408
|
+
const tx = new Transaction5();
|
|
1444
1409
|
tx.recentBlockhash = blockhash;
|
|
1445
1410
|
tx.feePayer = this.walletPubkey;
|
|
1446
1411
|
tx.add(...instructions);
|
|
@@ -2199,6 +2164,26 @@ var PresaleClient = class {
|
|
|
2199
2164
|
}).signers(signers).rpc();
|
|
2200
2165
|
return { signature: sig };
|
|
2201
2166
|
}
|
|
2167
|
+
/**
|
|
2168
|
+
* Transfer creator_claimable_revenue (80%) to BOTMM wallet.
|
|
2169
|
+
* Call after collectPresaleRevenue (distribute_presale_revenue).
|
|
2170
|
+
*/
|
|
2171
|
+
async distributeBotmmRevenue(presalePda, botmmAddress, currencyMint) {
|
|
2172
|
+
if (!currencyMint) {
|
|
2173
|
+
const presale = await this.fetchPresale(presalePda);
|
|
2174
|
+
if (!presale) throw new Error(`Presale not found: ${presalePda.toBase58()}`);
|
|
2175
|
+
currencyMint = presale.currencyMint;
|
|
2176
|
+
}
|
|
2177
|
+
const presaleVault = splToken.getAssociatedTokenAddressSync(currencyMint, presalePda, true);
|
|
2178
|
+
const botmmTokenAccount = splToken.getAssociatedTokenAddressSync(currencyMint, botmmAddress);
|
|
2179
|
+
return this.program.methods.distributeBotmmRevenue().accounts({
|
|
2180
|
+
presale: presalePda,
|
|
2181
|
+
presaleVault,
|
|
2182
|
+
currencyMint,
|
|
2183
|
+
botmmTokenAccount,
|
|
2184
|
+
tokenProgram: splToken.TOKEN_PROGRAM_ID
|
|
2185
|
+
}).transaction();
|
|
2186
|
+
}
|
|
2202
2187
|
// ─── Queries ─────────────────────────────────────────────────────────────────
|
|
2203
2188
|
async fetchPresale(presalePda) {
|
|
2204
2189
|
try {
|