@theliem/xmarket-sdk 4.1.1 → 4.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.d.mts +30 -5
- package/dist/index.d.ts +30 -5
- package/dist/index.js +125 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +119 -29
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -25,10 +25,26 @@ interface NetworkConfig {
|
|
|
25
25
|
rpcUrl: string;
|
|
26
26
|
programIds: ProgramIds;
|
|
27
27
|
defaultCollateral: CollateralConfig;
|
|
28
|
+
/**
|
|
29
|
+
* Owner pubkey used to derive question_market config PDA: ["config", owner].
|
|
30
|
+
* Pass to XMarketSDK as the 3rd constructor arg when set.
|
|
31
|
+
*/
|
|
32
|
+
marketOwner?: PublicKey;
|
|
28
33
|
/** Owner of the fee_config PDA — used to auto-derive fee distribution accounts */
|
|
29
34
|
feeConfigOwner?: PublicKey;
|
|
30
35
|
}
|
|
31
36
|
type NetworkName = string;
|
|
37
|
+
/** pm-svm v2 program IDs (same on devnet redeploy and mainnet). */
|
|
38
|
+
declare const V2_PROGRAM_IDS: ProgramIds;
|
|
39
|
+
/** Devnet question_market config owner (= config PDA seed). */
|
|
40
|
+
declare const DEVNET_MARKET_OWNER: PublicKey;
|
|
41
|
+
/** Devnet question_market config PDA for DEVNET_MARKET_OWNER + V2 questionMarket program. */
|
|
42
|
+
declare const DEVNET_QUESTION_MARKET_CONFIG: PublicKey;
|
|
43
|
+
declare const DEVNET_USDC_MINT: PublicKey;
|
|
44
|
+
declare const MAINNET_USDC_MINT: PublicKey;
|
|
45
|
+
/** Default devnet config — override rpcUrl if using a private RPC (e.g. Chainstack). */
|
|
46
|
+
declare const DEVNET_CONFIG: NetworkConfig;
|
|
47
|
+
declare const MAINNET_CONFIG: NetworkConfig;
|
|
32
48
|
|
|
33
49
|
interface TxResult {
|
|
34
50
|
signature: string;
|
|
@@ -418,7 +434,11 @@ declare class MarketClient {
|
|
|
418
434
|
growConfig(owner?: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
419
435
|
restoreConfig(snapshot: Buffer, owner?: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
420
436
|
bumpPresaleCount(count: number, authority: PublicKey): Promise<Transaction>;
|
|
437
|
+
private configNotFoundMessage;
|
|
421
438
|
fetchConfig(): Promise<QuestionMarketConfig | null>;
|
|
439
|
+
/** Like fetchConfig but throws with a hint when the config account is missing or invalid. */
|
|
440
|
+
fetchConfigOrThrow(): Promise<QuestionMarketConfig>;
|
|
441
|
+
private mapQuestionMarketConfig;
|
|
422
442
|
/** Check if address is in question_market whitelist (can call createQuestion) */
|
|
423
443
|
isWhitelisted(address: PublicKey): Promise<boolean>;
|
|
424
444
|
fetchQuestion(questionPda: PublicKey): Promise<Question | null>;
|
|
@@ -437,9 +457,10 @@ declare class MarketClient {
|
|
|
437
457
|
* Any user creates a presale + initial buy (question-market::create_presale).
|
|
438
458
|
* Reads agents_rev / company_rev from fee_config.
|
|
439
459
|
*
|
|
440
|
-
*
|
|
441
|
-
*
|
|
442
|
-
*
|
|
460
|
+
* Presale PDA seeds (presale program): ["presale", config, presale_index]
|
|
461
|
+
* where presale_index must equal config.presale_count at execution time.
|
|
462
|
+
*
|
|
463
|
+
* @param presaleIndex config.presale_count — fetch config first via fetchConfig()
|
|
443
464
|
*/
|
|
444
465
|
createPresale(params: {
|
|
445
466
|
price: anchor.BN;
|
|
@@ -1139,7 +1160,8 @@ declare class DisputeClient {
|
|
|
1139
1160
|
* - No HookClient (hook program removed entirely)
|
|
1140
1161
|
*
|
|
1141
1162
|
* Usage:
|
|
1142
|
-
* const sdk = new XMarketSDK(DEVNET_CONFIG,
|
|
1163
|
+
* const sdk = new XMarketSDK({ ...DEVNET_CONFIG, rpcUrl: YOUR_RPC }, wallet);
|
|
1164
|
+
* // marketOwner defaults to config.marketOwner (required for fetchConfig / createPresale)
|
|
1143
1165
|
* await sdk.market.createQuestionAdmin(params, oracle); // no hookProgram
|
|
1144
1166
|
* await sdk.clob.matchOrders(taker, makers); // no hook in remainingAccounts
|
|
1145
1167
|
*/
|
|
@@ -1159,6 +1181,8 @@ declare class XMarketSDK {
|
|
|
1159
1181
|
private _referral?;
|
|
1160
1182
|
private _dispute?;
|
|
1161
1183
|
constructor(config: NetworkConfig, wallet: anchor.Wallet, marketOwner?: PublicKey);
|
|
1184
|
+
/** Question market config PDA derived from marketOwner + questionMarket program. */
|
|
1185
|
+
get questionMarketConfigPda(): PublicKey;
|
|
1162
1186
|
private _withAddress;
|
|
1163
1187
|
get oracle(): OracleClient;
|
|
1164
1188
|
get market(): MarketClient;
|
|
@@ -1225,6 +1249,7 @@ declare class PDA {
|
|
|
1225
1249
|
static feeConfig(owner: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
|
|
1226
1250
|
static questionFee(conditionPda: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
|
|
1227
1251
|
static marketFeeOverride(conditionPda: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
|
|
1252
|
+
/** seeds: ["presale", questionMarketConfig, presale_index u64 LE] under presale program */
|
|
1228
1253
|
static presale(questionMarketConfig: PublicKey, presaleIndex: BN, programIds: Pick<ProgramIds, "presale">): [PublicKey, number];
|
|
1229
1254
|
static qtMint(presalePda: PublicKey, programIds: Pick<ProgramIds, "presale">): [PublicKey, number];
|
|
1230
1255
|
static qtAuthority(presalePda: PublicKey, programIds: Pick<ProgramIds, "presale">): [PublicKey, number];
|
|
@@ -1462,4 +1487,4 @@ declare function buildApproveCollateralTx(collateralMint: PublicKey, signer: Pub
|
|
|
1462
1487
|
*/
|
|
1463
1488
|
declare function buildApproveAllOutcomeTokensTx(condition: PublicKey, signer: PublicKey, payer: PublicKey, delegate: PublicKey, programIds: ProgramIds, amount?: BN): Transaction;
|
|
1464
1489
|
|
|
1465
|
-
export { AccountNotFoundError, AdminClient, type AdminConfigInfo, type ClaimRecordInfo, ClobClient, type ClobConfig, type CollateralConfig, type CollateralVault, type CollectFeeOrder, type Condition, type CreateQuestionParams, CtfClient, type CtfConfig, DisputeClient, type DisputeConfigInfo, type DisputeMarketInfo, FEE_DENOMINATOR, FeeManagementClient, type FeesShareEstimate, IX_SYSVAR, InvalidParamError, MAX_APPROVE_AMOUNT, MarketClient, MarketOracleClient, type MarketOracleInfo, type MatchType, type NetworkConfig, type NetworkName, OracleClient, type OracleConfig, type Order, type OrderStatus, PDA, type Position, PresaleClient, type PresaleInfo, type ProgramIds, type Question, type QuestionFee, type QuestionMarketConfig, type QuestionResult, QuestionStatus, type RedeemFeeOrder, type RedeemFeeOrderPair, ReferralClient, type ReferralConfigInfo, SEEDS, type SignedCollectFeeOrder, type SignedOrder, type SignedRedeemFeeOrder, type TxResult, UnauthorizedError, type UserBuyRecord, type UserClaimRecord, type UserDisputeInfo, XMarketError, XMarketSDK, buildApproveAllOutcomeTokensTx, buildApproveCollateralTx, buildBatchedCollectFeeEd25519Instruction, buildBatchedEd25519Instruction, buildBatchedRedeemFeeEd25519Instruction, buildCreateUserAtasTx, buildOrder, buildOrderFromPrice, deserializeSignedOrder, detectMatchType, generateContentHash, generateQuestionId, getOrderSignBytes, orderAmountsFromPrice, serializeCollectFeeOrderToBytes, serializeOrderToBytes, serializeRedeemFeeOrderToBytes, serializeSignedOrder, signOrder, signOrderWithKeypair, verifySignedOrder };
|
|
1490
|
+
export { AccountNotFoundError, AdminClient, type AdminConfigInfo, type ClaimRecordInfo, ClobClient, type ClobConfig, type CollateralConfig, type CollateralVault, type CollectFeeOrder, type Condition, type CreateQuestionParams, CtfClient, type CtfConfig, DEVNET_CONFIG, DEVNET_MARKET_OWNER, DEVNET_QUESTION_MARKET_CONFIG, DEVNET_USDC_MINT, DisputeClient, type DisputeConfigInfo, type DisputeMarketInfo, FEE_DENOMINATOR, FeeManagementClient, type FeesShareEstimate, IX_SYSVAR, InvalidParamError, MAINNET_CONFIG, MAINNET_USDC_MINT, MAX_APPROVE_AMOUNT, MarketClient, MarketOracleClient, type MarketOracleInfo, type MatchType, type NetworkConfig, type NetworkName, OracleClient, type OracleConfig, type Order, type OrderStatus, PDA, type Position, PresaleClient, type PresaleInfo, type ProgramIds, type Question, type QuestionFee, type QuestionMarketConfig, type QuestionResult, QuestionStatus, type RedeemFeeOrder, type RedeemFeeOrderPair, ReferralClient, type ReferralConfigInfo, SEEDS, type SignedCollectFeeOrder, type SignedOrder, type SignedRedeemFeeOrder, type TxResult, UnauthorizedError, type UserBuyRecord, type UserClaimRecord, type UserDisputeInfo, V2_PROGRAM_IDS, XMarketError, XMarketSDK, buildApproveAllOutcomeTokensTx, buildApproveCollateralTx, buildBatchedCollectFeeEd25519Instruction, buildBatchedEd25519Instruction, buildBatchedRedeemFeeEd25519Instruction, buildCreateUserAtasTx, buildOrder, buildOrderFromPrice, deserializeSignedOrder, detectMatchType, generateContentHash, generateQuestionId, getOrderSignBytes, orderAmountsFromPrice, serializeCollectFeeOrderToBytes, serializeOrderToBytes, serializeRedeemFeeOrderToBytes, serializeSignedOrder, signOrder, signOrderWithKeypair, verifySignedOrder };
|
package/dist/index.d.ts
CHANGED
|
@@ -25,10 +25,26 @@ interface NetworkConfig {
|
|
|
25
25
|
rpcUrl: string;
|
|
26
26
|
programIds: ProgramIds;
|
|
27
27
|
defaultCollateral: CollateralConfig;
|
|
28
|
+
/**
|
|
29
|
+
* Owner pubkey used to derive question_market config PDA: ["config", owner].
|
|
30
|
+
* Pass to XMarketSDK as the 3rd constructor arg when set.
|
|
31
|
+
*/
|
|
32
|
+
marketOwner?: PublicKey;
|
|
28
33
|
/** Owner of the fee_config PDA — used to auto-derive fee distribution accounts */
|
|
29
34
|
feeConfigOwner?: PublicKey;
|
|
30
35
|
}
|
|
31
36
|
type NetworkName = string;
|
|
37
|
+
/** pm-svm v2 program IDs (same on devnet redeploy and mainnet). */
|
|
38
|
+
declare const V2_PROGRAM_IDS: ProgramIds;
|
|
39
|
+
/** Devnet question_market config owner (= config PDA seed). */
|
|
40
|
+
declare const DEVNET_MARKET_OWNER: PublicKey;
|
|
41
|
+
/** Devnet question_market config PDA for DEVNET_MARKET_OWNER + V2 questionMarket program. */
|
|
42
|
+
declare const DEVNET_QUESTION_MARKET_CONFIG: PublicKey;
|
|
43
|
+
declare const DEVNET_USDC_MINT: PublicKey;
|
|
44
|
+
declare const MAINNET_USDC_MINT: PublicKey;
|
|
45
|
+
/** Default devnet config — override rpcUrl if using a private RPC (e.g. Chainstack). */
|
|
46
|
+
declare const DEVNET_CONFIG: NetworkConfig;
|
|
47
|
+
declare const MAINNET_CONFIG: NetworkConfig;
|
|
32
48
|
|
|
33
49
|
interface TxResult {
|
|
34
50
|
signature: string;
|
|
@@ -418,7 +434,11 @@ declare class MarketClient {
|
|
|
418
434
|
growConfig(owner?: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
419
435
|
restoreConfig(snapshot: Buffer, owner?: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
420
436
|
bumpPresaleCount(count: number, authority: PublicKey): Promise<Transaction>;
|
|
437
|
+
private configNotFoundMessage;
|
|
421
438
|
fetchConfig(): Promise<QuestionMarketConfig | null>;
|
|
439
|
+
/** Like fetchConfig but throws with a hint when the config account is missing or invalid. */
|
|
440
|
+
fetchConfigOrThrow(): Promise<QuestionMarketConfig>;
|
|
441
|
+
private mapQuestionMarketConfig;
|
|
422
442
|
/** Check if address is in question_market whitelist (can call createQuestion) */
|
|
423
443
|
isWhitelisted(address: PublicKey): Promise<boolean>;
|
|
424
444
|
fetchQuestion(questionPda: PublicKey): Promise<Question | null>;
|
|
@@ -437,9 +457,10 @@ declare class MarketClient {
|
|
|
437
457
|
* Any user creates a presale + initial buy (question-market::create_presale).
|
|
438
458
|
* Reads agents_rev / company_rev from fee_config.
|
|
439
459
|
*
|
|
440
|
-
*
|
|
441
|
-
*
|
|
442
|
-
*
|
|
460
|
+
* Presale PDA seeds (presale program): ["presale", config, presale_index]
|
|
461
|
+
* where presale_index must equal config.presale_count at execution time.
|
|
462
|
+
*
|
|
463
|
+
* @param presaleIndex config.presale_count — fetch config first via fetchConfig()
|
|
443
464
|
*/
|
|
444
465
|
createPresale(params: {
|
|
445
466
|
price: anchor.BN;
|
|
@@ -1139,7 +1160,8 @@ declare class DisputeClient {
|
|
|
1139
1160
|
* - No HookClient (hook program removed entirely)
|
|
1140
1161
|
*
|
|
1141
1162
|
* Usage:
|
|
1142
|
-
* const sdk = new XMarketSDK(DEVNET_CONFIG,
|
|
1163
|
+
* const sdk = new XMarketSDK({ ...DEVNET_CONFIG, rpcUrl: YOUR_RPC }, wallet);
|
|
1164
|
+
* // marketOwner defaults to config.marketOwner (required for fetchConfig / createPresale)
|
|
1143
1165
|
* await sdk.market.createQuestionAdmin(params, oracle); // no hookProgram
|
|
1144
1166
|
* await sdk.clob.matchOrders(taker, makers); // no hook in remainingAccounts
|
|
1145
1167
|
*/
|
|
@@ -1159,6 +1181,8 @@ declare class XMarketSDK {
|
|
|
1159
1181
|
private _referral?;
|
|
1160
1182
|
private _dispute?;
|
|
1161
1183
|
constructor(config: NetworkConfig, wallet: anchor.Wallet, marketOwner?: PublicKey);
|
|
1184
|
+
/** Question market config PDA derived from marketOwner + questionMarket program. */
|
|
1185
|
+
get questionMarketConfigPda(): PublicKey;
|
|
1162
1186
|
private _withAddress;
|
|
1163
1187
|
get oracle(): OracleClient;
|
|
1164
1188
|
get market(): MarketClient;
|
|
@@ -1225,6 +1249,7 @@ declare class PDA {
|
|
|
1225
1249
|
static feeConfig(owner: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
|
|
1226
1250
|
static questionFee(conditionPda: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
|
|
1227
1251
|
static marketFeeOverride(conditionPda: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
|
|
1252
|
+
/** seeds: ["presale", questionMarketConfig, presale_index u64 LE] under presale program */
|
|
1228
1253
|
static presale(questionMarketConfig: PublicKey, presaleIndex: BN, programIds: Pick<ProgramIds, "presale">): [PublicKey, number];
|
|
1229
1254
|
static qtMint(presalePda: PublicKey, programIds: Pick<ProgramIds, "presale">): [PublicKey, number];
|
|
1230
1255
|
static qtAuthority(presalePda: PublicKey, programIds: Pick<ProgramIds, "presale">): [PublicKey, number];
|
|
@@ -1462,4 +1487,4 @@ declare function buildApproveCollateralTx(collateralMint: PublicKey, signer: Pub
|
|
|
1462
1487
|
*/
|
|
1463
1488
|
declare function buildApproveAllOutcomeTokensTx(condition: PublicKey, signer: PublicKey, payer: PublicKey, delegate: PublicKey, programIds: ProgramIds, amount?: BN): Transaction;
|
|
1464
1489
|
|
|
1465
|
-
export { AccountNotFoundError, AdminClient, type AdminConfigInfo, type ClaimRecordInfo, ClobClient, type ClobConfig, type CollateralConfig, type CollateralVault, type CollectFeeOrder, type Condition, type CreateQuestionParams, CtfClient, type CtfConfig, DisputeClient, type DisputeConfigInfo, type DisputeMarketInfo, FEE_DENOMINATOR, FeeManagementClient, type FeesShareEstimate, IX_SYSVAR, InvalidParamError, MAX_APPROVE_AMOUNT, MarketClient, MarketOracleClient, type MarketOracleInfo, type MatchType, type NetworkConfig, type NetworkName, OracleClient, type OracleConfig, type Order, type OrderStatus, PDA, type Position, PresaleClient, type PresaleInfo, type ProgramIds, type Question, type QuestionFee, type QuestionMarketConfig, type QuestionResult, QuestionStatus, type RedeemFeeOrder, type RedeemFeeOrderPair, ReferralClient, type ReferralConfigInfo, SEEDS, type SignedCollectFeeOrder, type SignedOrder, type SignedRedeemFeeOrder, type TxResult, UnauthorizedError, type UserBuyRecord, type UserClaimRecord, type UserDisputeInfo, XMarketError, XMarketSDK, buildApproveAllOutcomeTokensTx, buildApproveCollateralTx, buildBatchedCollectFeeEd25519Instruction, buildBatchedEd25519Instruction, buildBatchedRedeemFeeEd25519Instruction, buildCreateUserAtasTx, buildOrder, buildOrderFromPrice, deserializeSignedOrder, detectMatchType, generateContentHash, generateQuestionId, getOrderSignBytes, orderAmountsFromPrice, serializeCollectFeeOrderToBytes, serializeOrderToBytes, serializeRedeemFeeOrderToBytes, serializeSignedOrder, signOrder, signOrderWithKeypair, verifySignedOrder };
|
|
1490
|
+
export { AccountNotFoundError, AdminClient, type AdminConfigInfo, type ClaimRecordInfo, ClobClient, type ClobConfig, type CollateralConfig, type CollateralVault, type CollectFeeOrder, type Condition, type CreateQuestionParams, CtfClient, type CtfConfig, DEVNET_CONFIG, DEVNET_MARKET_OWNER, DEVNET_QUESTION_MARKET_CONFIG, DEVNET_USDC_MINT, DisputeClient, type DisputeConfigInfo, type DisputeMarketInfo, FEE_DENOMINATOR, FeeManagementClient, type FeesShareEstimate, IX_SYSVAR, InvalidParamError, MAINNET_CONFIG, MAINNET_USDC_MINT, MAX_APPROVE_AMOUNT, MarketClient, MarketOracleClient, type MarketOracleInfo, type MatchType, type NetworkConfig, type NetworkName, OracleClient, type OracleConfig, type Order, type OrderStatus, PDA, type Position, PresaleClient, type PresaleInfo, type ProgramIds, type Question, type QuestionFee, type QuestionMarketConfig, type QuestionResult, QuestionStatus, type RedeemFeeOrder, type RedeemFeeOrderPair, ReferralClient, type ReferralConfigInfo, SEEDS, type SignedCollectFeeOrder, type SignedOrder, type SignedRedeemFeeOrder, type TxResult, UnauthorizedError, type UserBuyRecord, type UserClaimRecord, type UserDisputeInfo, V2_PROGRAM_IDS, XMarketError, XMarketSDK, buildApproveAllOutcomeTokensTx, buildApproveCollateralTx, buildBatchedCollectFeeEd25519Instruction, buildBatchedEd25519Instruction, buildBatchedRedeemFeeEd25519Instruction, buildCreateUserAtasTx, buildOrder, buildOrderFromPrice, deserializeSignedOrder, detectMatchType, generateContentHash, generateQuestionId, getOrderSignBytes, orderAmountsFromPrice, serializeCollectFeeOrderToBytes, serializeOrderToBytes, serializeRedeemFeeOrderToBytes, serializeSignedOrder, signOrder, signOrderWithKeypair, verifySignedOrder };
|
package/dist/index.js
CHANGED
|
@@ -211,6 +211,7 @@ var PDA = class {
|
|
|
211
211
|
);
|
|
212
212
|
}
|
|
213
213
|
// ─── Presale ─────────────────────────────────────────────────────────────────
|
|
214
|
+
/** seeds: ["presale", questionMarketConfig, presale_index u64 LE] under presale program */
|
|
214
215
|
static presale(questionMarketConfig, presaleIndex, programIds) {
|
|
215
216
|
if (!programIds.presale) throw new Error("presale program ID not configured");
|
|
216
217
|
const idxBuf = Buffer.alloc(8);
|
|
@@ -633,28 +634,52 @@ var MarketClient = class {
|
|
|
633
634
|
return this.program.methods.bumpPresaleCount(new anchor6__namespace.BN(count)).accounts({ authority, config: this.configPda }).transaction();
|
|
634
635
|
}
|
|
635
636
|
// ─── Queries ─────────────────────────────────────────────────────────────────
|
|
637
|
+
configNotFoundMessage() {
|
|
638
|
+
return `Question market config not found at ${this.configPda.toBase58()}. Check NetworkConfig.programIds.questionMarket (v2 FkpHo3...) and marketOwner (config owner pubkey \u2014 not the user wallet). Devnet: use DEVNET_CONFIG or marketOwner DEVNET_MARKET_OWNER.`;
|
|
639
|
+
}
|
|
636
640
|
async fetchConfig() {
|
|
641
|
+
const info = await this.provider.connection.getAccountInfo(this.configPda);
|
|
642
|
+
if (!info) return null;
|
|
637
643
|
try {
|
|
638
644
|
const acc = await this.program.account.questionMarketConfig.fetch(this.configPda);
|
|
639
|
-
return
|
|
640
|
-
owner: acc.owner,
|
|
641
|
-
admin: acc.admin,
|
|
642
|
-
oracle: acc.oracle,
|
|
643
|
-
oracleProgram: acc.oracleProgram,
|
|
644
|
-
conditionalTokensProgram: acc.conditionalTokensProgram,
|
|
645
|
-
questionCount: acc.questionCount.toNumber(),
|
|
646
|
-
approvedCount: acc.approvedCount.toNumber(),
|
|
647
|
-
rejectedCount: acc.rejectedCount.toNumber(),
|
|
648
|
-
presaleCount: acc.presaleCount.toNumber(),
|
|
649
|
-
whitelist: acc.whitelist.slice(0, acc.whitelistLen),
|
|
650
|
-
whitelistLen: acc.whitelistLen,
|
|
651
|
-
isPaused: acc.isPaused,
|
|
652
|
-
bump: acc.bump
|
|
653
|
-
};
|
|
645
|
+
return this.mapQuestionMarketConfig(acc);
|
|
654
646
|
} catch {
|
|
655
647
|
return null;
|
|
656
648
|
}
|
|
657
649
|
}
|
|
650
|
+
/** Like fetchConfig but throws with a hint when the config account is missing or invalid. */
|
|
651
|
+
async fetchConfigOrThrow() {
|
|
652
|
+
const info = await this.provider.connection.getAccountInfo(this.configPda);
|
|
653
|
+
if (!info) {
|
|
654
|
+
throw new Error(this.configNotFoundMessage());
|
|
655
|
+
}
|
|
656
|
+
try {
|
|
657
|
+
const acc = await this.program.account.questionMarketConfig.fetch(this.configPda);
|
|
658
|
+
return this.mapQuestionMarketConfig(acc);
|
|
659
|
+
} catch (e) {
|
|
660
|
+
throw new Error(
|
|
661
|
+
`${this.configNotFoundMessage()} Deserialize failed: ${e instanceof Error ? e.message : e}`
|
|
662
|
+
);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
mapQuestionMarketConfig(acc) {
|
|
666
|
+
const accAny = acc;
|
|
667
|
+
return {
|
|
668
|
+
owner: accAny.owner,
|
|
669
|
+
admin: accAny.admin,
|
|
670
|
+
oracle: accAny.oracle,
|
|
671
|
+
oracleProgram: accAny.oracleProgram,
|
|
672
|
+
conditionalTokensProgram: accAny.conditionalTokensProgram,
|
|
673
|
+
questionCount: Number(accAny.questionCount.toString()),
|
|
674
|
+
approvedCount: Number(accAny.approvedCount.toString()),
|
|
675
|
+
rejectedCount: Number(accAny.rejectedCount.toString()),
|
|
676
|
+
presaleCount: Number(accAny.presaleCount.toString()),
|
|
677
|
+
whitelist: accAny.whitelist.slice(0, accAny.whitelistLen),
|
|
678
|
+
whitelistLen: accAny.whitelistLen,
|
|
679
|
+
isPaused: accAny.isPaused,
|
|
680
|
+
bump: accAny.bump
|
|
681
|
+
};
|
|
682
|
+
}
|
|
658
683
|
/** Check if address is in question_market whitelist (can call createQuestion) */
|
|
659
684
|
async isWhitelisted(address) {
|
|
660
685
|
const cfg = await this.fetchConfig();
|
|
@@ -707,9 +732,10 @@ var MarketClient = class {
|
|
|
707
732
|
* Any user creates a presale + initial buy (question-market::create_presale).
|
|
708
733
|
* Reads agents_rev / company_rev from fee_config.
|
|
709
734
|
*
|
|
710
|
-
*
|
|
711
|
-
*
|
|
712
|
-
*
|
|
735
|
+
* Presale PDA seeds (presale program): ["presale", config, presale_index]
|
|
736
|
+
* where presale_index must equal config.presale_count at execution time.
|
|
737
|
+
*
|
|
738
|
+
* @param presaleIndex config.presale_count — fetch config first via fetchConfig()
|
|
713
739
|
*/
|
|
714
740
|
async createPresale(params, feeConfig, currencyMint, presaleIndex, creator = this.walletPubkey, payer = creator) {
|
|
715
741
|
if (!this.programIds.presale) throw new Error("presale program ID not configured");
|
|
@@ -2108,7 +2134,7 @@ ${logs.join("\n")}`);
|
|
|
2108
2134
|
* remaining_accounts per NO maker (6):
|
|
2109
2135
|
* [maker, order_record, buyer_no_token, buyer_no_collateral, buyer_no_position, no_order_status]
|
|
2110
2136
|
*/
|
|
2111
|
-
async _buildMintIx(yesSigned, noMakers, collateralMint, operator, payer) {
|
|
2137
|
+
async _buildMintIx(yesSigned, noMakers, collateralMint, operator, payer, feeRecipient, opts) {
|
|
2112
2138
|
const condition = yesSigned.order.condition;
|
|
2113
2139
|
const taker = yesSigned.order.maker;
|
|
2114
2140
|
const takerNonce = yesSigned.order.nonce;
|
|
@@ -2146,6 +2172,26 @@ ${logs.join("\n")}`);
|
|
|
2146
2172
|
{ pubkey: noStatus, isSigner: false, isWritable: true }
|
|
2147
2173
|
);
|
|
2148
2174
|
}
|
|
2175
|
+
if (yesSigned.order.fee.gtn(0) && this.programIds.feeManagement && this.feeConfigOwner) {
|
|
2176
|
+
const companyAddr = await this.companyAddress();
|
|
2177
|
+
const refVault = await this.referralVault();
|
|
2178
|
+
if (companyAddr && refVault) {
|
|
2179
|
+
const feeOverridePda = PDA.marketFeeOverride(condition, this.programIds)[0];
|
|
2180
|
+
const feeOverrideExists = await this.provider.connection.getAccountInfo(feeOverridePda);
|
|
2181
|
+
if (feeOverrideExists) {
|
|
2182
|
+
const oracleVault = opts?.marketOracleVault ?? await this.getMarketOracleVault(condition, collateralMint) ?? payer;
|
|
2183
|
+
remainingAccounts.push(
|
|
2184
|
+
{ pubkey: this.programIds.feeManagement, isSigner: false, isWritable: false },
|
|
2185
|
+
{ pubkey: PDA.feeConfig(this.feeConfigOwner, this.programIds)[0], isSigner: false, isWritable: false },
|
|
2186
|
+
{ pubkey: feeOverridePda, isSigner: false, isWritable: false },
|
|
2187
|
+
{ pubkey: splToken.getAssociatedTokenAddressSync(collateralMint, companyAddr), isSigner: false, isWritable: true },
|
|
2188
|
+
{ pubkey: oracleVault, isSigner: false, isWritable: true },
|
|
2189
|
+
{ pubkey: refVault, isSigner: false, isWritable: true }
|
|
2190
|
+
);
|
|
2191
|
+
}
|
|
2192
|
+
}
|
|
2193
|
+
}
|
|
2194
|
+
const resolvedFeeRecipient = feeRecipient ?? clobUsdcAta;
|
|
2149
2195
|
return this.program.methods.matchMintOrders(takerNonce, fillAmount, true).accounts({
|
|
2150
2196
|
operator,
|
|
2151
2197
|
payer,
|
|
@@ -2157,6 +2203,7 @@ ${logs.join("\n")}`);
|
|
|
2157
2203
|
takerYesToken,
|
|
2158
2204
|
takerYesPosition,
|
|
2159
2205
|
takerOrderStatus,
|
|
2206
|
+
feeRecipient: resolvedFeeRecipient,
|
|
2160
2207
|
clobUsdcAta,
|
|
2161
2208
|
clobYesAta,
|
|
2162
2209
|
clobNoAta,
|
|
@@ -2186,7 +2233,7 @@ ${logs.join("\n")}`);
|
|
|
2186
2233
|
const [noMint] = PDA.noMint(condition, this.programIds);
|
|
2187
2234
|
const clobYesAta = splToken.getAssociatedTokenAddressSync(yesMint, clobConfig, true, splToken.TOKEN_PROGRAM_ID);
|
|
2188
2235
|
const clobNoAta = splToken.getAssociatedTokenAddressSync(noMint, clobConfig, true, splToken.TOKEN_PROGRAM_ID);
|
|
2189
|
-
const matchIx = await this._buildMintIx(yesSigned, noMakers, collateralMint, operatorWallet.publicKey, this.walletPubkey);
|
|
2236
|
+
const matchIx = await this._buildMintIx(yesSigned, noMakers, collateralMint, operatorWallet.publicKey, this.walletPubkey, _feeRecipient);
|
|
2190
2237
|
await this._ensureClobOutcomeAtas(yesMint, noMint, clobConfig, clobYesAta, clobNoAta);
|
|
2191
2238
|
const sig = await this.sendMatchTx([matchIx], lookupTable, operatorWallet);
|
|
2192
2239
|
return { signature: sig };
|
|
@@ -7210,13 +7257,6 @@ var question_market_default = {
|
|
|
7210
7257
|
],
|
|
7211
7258
|
type: "pubkey"
|
|
7212
7259
|
},
|
|
7213
|
-
{
|
|
7214
|
-
name: "oracle_program",
|
|
7215
|
-
docs: [
|
|
7216
|
-
"Oracle program ID \u2014 pinned for CPI validation in resolve_question"
|
|
7217
|
-
],
|
|
7218
|
-
type: "pubkey"
|
|
7219
|
-
},
|
|
7220
7260
|
{
|
|
7221
7261
|
name: "question_count",
|
|
7222
7262
|
docs: [
|
|
@@ -7278,6 +7318,14 @@ var question_market_default = {
|
|
|
7278
7318
|
],
|
|
7279
7319
|
type: "u64"
|
|
7280
7320
|
},
|
|
7321
|
+
{
|
|
7322
|
+
name: "oracle_program",
|
|
7323
|
+
docs: [
|
|
7324
|
+
"Oracle program ID \u2014 pinned for CPI validation in resolve_question",
|
|
7325
|
+
"Placed at end of meaningful fields to avoid layout shift on old accounts."
|
|
7326
|
+
],
|
|
7327
|
+
type: "pubkey"
|
|
7328
|
+
},
|
|
7281
7329
|
{
|
|
7282
7330
|
name: "_reserved",
|
|
7283
7331
|
docs: [
|
|
@@ -18068,7 +18116,11 @@ var XMarketSDK = class {
|
|
|
18068
18116
|
);
|
|
18069
18117
|
anchor6__namespace.setProvider(this.provider);
|
|
18070
18118
|
this._programIds = config.programIds;
|
|
18071
|
-
this._marketOwner = marketOwner ?? wallet.publicKey;
|
|
18119
|
+
this._marketOwner = marketOwner ?? config.marketOwner ?? wallet.publicKey;
|
|
18120
|
+
}
|
|
18121
|
+
/** Question market config PDA derived from marketOwner + questionMarket program. */
|
|
18122
|
+
get questionMarketConfigPda() {
|
|
18123
|
+
return this.market.configPda;
|
|
18072
18124
|
}
|
|
18073
18125
|
_withAddress(idl, address) {
|
|
18074
18126
|
return { ...idl, address: address.toBase58() };
|
|
@@ -18158,6 +18210,44 @@ var XMarketSDK = class {
|
|
|
18158
18210
|
return this._dispute;
|
|
18159
18211
|
}
|
|
18160
18212
|
};
|
|
18213
|
+
var V2_PROGRAM_IDS = {
|
|
18214
|
+
oracle: new web3_js.PublicKey("8uNiLDZnarxyFyoCi1bE1qkBMsLs2Tpyohtdzdvjkg8j"),
|
|
18215
|
+
conditionalTokens: new web3_js.PublicKey("xpn3htSptTZECudoRA8WJmAEtiijxDseTqtawYysVNT"),
|
|
18216
|
+
questionMarket: new web3_js.PublicKey("FkpHo3zb5h2nNS5n6tWAvDwXPTXR2qqVLjDmEkMayott"),
|
|
18217
|
+
clobExchange: new web3_js.PublicKey("AFT8SM1Vv8g8AQTf81LoE5oLteUTyhWzWTLj7SKZjkY1"),
|
|
18218
|
+
feeManagement: new web3_js.PublicKey("8S6hxqbDc8kgHf4uUzq2t15PeY36QSCYEpBVvM4Fhrkm"),
|
|
18219
|
+
presale: new web3_js.PublicKey("CKd94vPibAMAr8R5eLv21r8PYXkgLRithipBe8GV7J6C"),
|
|
18220
|
+
marketOracle: new web3_js.PublicKey("Agt6beCbghi4jV9A8v9geRP5dnt2wDkJBVgy9oM33zit"),
|
|
18221
|
+
adminContract: new web3_js.PublicKey("2HsyCdr59W5ndeboaE9JAmhEQ46m5Gm2ZWBfYEs1tC1i"),
|
|
18222
|
+
referral: new web3_js.PublicKey("9kyNMtUEFR6hDeZHUTbRKH3t1EJisfSvWQKKUev7ujoC"),
|
|
18223
|
+
dispute: new web3_js.PublicKey("8gqHPY1WtGFGmYNbrGrPVoct1kqPL6cCaUtJ17EHSsFp")
|
|
18224
|
+
};
|
|
18225
|
+
var DEVNET_MARKET_OWNER = new web3_js.PublicKey(
|
|
18226
|
+
"7eGpbyRpcM7WpNKQtd6XkteNQWHbWXP7icZjKzNK2aTk"
|
|
18227
|
+
);
|
|
18228
|
+
var DEVNET_QUESTION_MARKET_CONFIG = new web3_js.PublicKey(
|
|
18229
|
+
"7n8y2oQYmxTp9fn2Wf2dFE1pC7ZESXYJ4yXSbYSEuRn5"
|
|
18230
|
+
);
|
|
18231
|
+
var DEVNET_USDC_MINT = new web3_js.PublicKey(
|
|
18232
|
+
"4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU"
|
|
18233
|
+
);
|
|
18234
|
+
var MAINNET_USDC_MINT = new web3_js.PublicKey(
|
|
18235
|
+
"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
|
|
18236
|
+
);
|
|
18237
|
+
var DEVNET_CONFIG = {
|
|
18238
|
+
name: "devnet",
|
|
18239
|
+
rpcUrl: "https://api.devnet.solana.com",
|
|
18240
|
+
programIds: V2_PROGRAM_IDS,
|
|
18241
|
+
defaultCollateral: { mint: DEVNET_USDC_MINT, decimals: 6 },
|
|
18242
|
+
marketOwner: DEVNET_MARKET_OWNER,
|
|
18243
|
+
feeConfigOwner: DEVNET_MARKET_OWNER
|
|
18244
|
+
};
|
|
18245
|
+
var MAINNET_CONFIG = {
|
|
18246
|
+
name: "mainnet",
|
|
18247
|
+
rpcUrl: "https://api.mainnet-beta.solana.com",
|
|
18248
|
+
programIds: V2_PROGRAM_IDS,
|
|
18249
|
+
defaultCollateral: { mint: MAINNET_USDC_MINT, decimals: 6 }
|
|
18250
|
+
};
|
|
18161
18251
|
var MAX_APPROVE_AMOUNT = new BN4__default.default("18446744073709551615");
|
|
18162
18252
|
function buildCreateUserAtasTx(condition, user, payer, programIds) {
|
|
18163
18253
|
const [yesMint] = PDA.yesMint(condition, programIds);
|
|
@@ -18231,11 +18321,17 @@ exports.AccountNotFoundError = AccountNotFoundError;
|
|
|
18231
18321
|
exports.AdminClient = AdminClient;
|
|
18232
18322
|
exports.ClobClient = ClobClient;
|
|
18233
18323
|
exports.CtfClient = CtfClient;
|
|
18324
|
+
exports.DEVNET_CONFIG = DEVNET_CONFIG;
|
|
18325
|
+
exports.DEVNET_MARKET_OWNER = DEVNET_MARKET_OWNER;
|
|
18326
|
+
exports.DEVNET_QUESTION_MARKET_CONFIG = DEVNET_QUESTION_MARKET_CONFIG;
|
|
18327
|
+
exports.DEVNET_USDC_MINT = DEVNET_USDC_MINT;
|
|
18234
18328
|
exports.DisputeClient = DisputeClient;
|
|
18235
18329
|
exports.FEE_DENOMINATOR = FEE_DENOMINATOR;
|
|
18236
18330
|
exports.FeeManagementClient = FeeManagementClient;
|
|
18237
18331
|
exports.IX_SYSVAR = IX_SYSVAR;
|
|
18238
18332
|
exports.InvalidParamError = InvalidParamError;
|
|
18333
|
+
exports.MAINNET_CONFIG = MAINNET_CONFIG;
|
|
18334
|
+
exports.MAINNET_USDC_MINT = MAINNET_USDC_MINT;
|
|
18239
18335
|
exports.MAX_APPROVE_AMOUNT = MAX_APPROVE_AMOUNT;
|
|
18240
18336
|
exports.MarketClient = MarketClient;
|
|
18241
18337
|
exports.MarketOracleClient = MarketOracleClient;
|
|
@@ -18246,6 +18342,7 @@ exports.QuestionStatus = QuestionStatus;
|
|
|
18246
18342
|
exports.ReferralClient = ReferralClient;
|
|
18247
18343
|
exports.SEEDS = SEEDS;
|
|
18248
18344
|
exports.UnauthorizedError = UnauthorizedError;
|
|
18345
|
+
exports.V2_PROGRAM_IDS = V2_PROGRAM_IDS;
|
|
18249
18346
|
exports.XMarketError = XMarketError;
|
|
18250
18347
|
exports.XMarketSDK = XMarketSDK;
|
|
18251
18348
|
exports.buildApproveAllOutcomeTokensTx = buildApproveAllOutcomeTokensTx;
|