@theliem/xmarket-sdk 4.1.0 → 4.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 +33 -6
- package/dist/index.d.ts +33 -6
- package/dist/index.js +127 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +121 -26
- 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;
|
|
@@ -95,6 +111,7 @@ interface QuestionMarketConfig {
|
|
|
95
111
|
owner: PublicKey;
|
|
96
112
|
admin: PublicKey;
|
|
97
113
|
oracle: PublicKey;
|
|
114
|
+
oracleProgram: PublicKey;
|
|
98
115
|
conditionalTokensProgram: PublicKey;
|
|
99
116
|
questionCount: number;
|
|
100
117
|
approvedCount: number;
|
|
@@ -388,7 +405,7 @@ declare class MarketClient {
|
|
|
388
405
|
feeConfigOwner?: PublicKey;
|
|
389
406
|
constructor(program: anchor.Program, provider: anchor.AnchorProvider, programIds: ProgramIds, ownerPubkey: PublicKey);
|
|
390
407
|
get walletPubkey(): PublicKey;
|
|
391
|
-
initialize(admin: PublicKey, oracle: PublicKey, owner?: PublicKey): Promise<Transaction>;
|
|
408
|
+
initialize(admin: PublicKey, oracle: PublicKey, oracleProgram: PublicKey, owner?: PublicKey): Promise<Transaction>;
|
|
392
409
|
/**
|
|
393
410
|
* Build createQuestionAdmin transaction (whitelist/admin path — status = Approved immediately).
|
|
394
411
|
* @param creator - Whitelisted creator (must be in whitelist or be admin/owner)
|
|
@@ -406,6 +423,7 @@ declare class MarketClient {
|
|
|
406
423
|
newOracle?: PublicKey;
|
|
407
424
|
isPaused?: boolean;
|
|
408
425
|
newConditionalTokensProgram?: PublicKey;
|
|
426
|
+
newOracleProgram?: PublicKey;
|
|
409
427
|
}, authority?: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
410
428
|
/** Set the admin (owner only). Replaces any existing admin. */
|
|
411
429
|
addAdmin(newAdmin: PublicKey, owner?: PublicKey): Promise<Transaction>;
|
|
@@ -416,7 +434,11 @@ declare class MarketClient {
|
|
|
416
434
|
growConfig(owner?: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
417
435
|
restoreConfig(snapshot: Buffer, owner?: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
418
436
|
bumpPresaleCount(count: number, authority: PublicKey): Promise<Transaction>;
|
|
437
|
+
private configNotFoundMessage;
|
|
419
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;
|
|
420
442
|
/** Check if address is in question_market whitelist (can call createQuestion) */
|
|
421
443
|
isWhitelisted(address: PublicKey): Promise<boolean>;
|
|
422
444
|
fetchQuestion(questionPda: PublicKey): Promise<Question | null>;
|
|
@@ -435,9 +457,10 @@ declare class MarketClient {
|
|
|
435
457
|
* Any user creates a presale + initial buy (question-market::create_presale).
|
|
436
458
|
* Reads agents_rev / company_rev from fee_config.
|
|
437
459
|
*
|
|
438
|
-
*
|
|
439
|
-
*
|
|
440
|
-
*
|
|
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()
|
|
441
464
|
*/
|
|
442
465
|
createPresale(params: {
|
|
443
466
|
price: anchor.BN;
|
|
@@ -1137,7 +1160,8 @@ declare class DisputeClient {
|
|
|
1137
1160
|
* - No HookClient (hook program removed entirely)
|
|
1138
1161
|
*
|
|
1139
1162
|
* Usage:
|
|
1140
|
-
* 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)
|
|
1141
1165
|
* await sdk.market.createQuestionAdmin(params, oracle); // no hookProgram
|
|
1142
1166
|
* await sdk.clob.matchOrders(taker, makers); // no hook in remainingAccounts
|
|
1143
1167
|
*/
|
|
@@ -1157,6 +1181,8 @@ declare class XMarketSDK {
|
|
|
1157
1181
|
private _referral?;
|
|
1158
1182
|
private _dispute?;
|
|
1159
1183
|
constructor(config: NetworkConfig, wallet: anchor.Wallet, marketOwner?: PublicKey);
|
|
1184
|
+
/** Question market config PDA derived from marketOwner + questionMarket program. */
|
|
1185
|
+
get questionMarketConfigPda(): PublicKey;
|
|
1160
1186
|
private _withAddress;
|
|
1161
1187
|
get oracle(): OracleClient;
|
|
1162
1188
|
get market(): MarketClient;
|
|
@@ -1223,6 +1249,7 @@ declare class PDA {
|
|
|
1223
1249
|
static feeConfig(owner: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
|
|
1224
1250
|
static questionFee(conditionPda: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
|
|
1225
1251
|
static marketFeeOverride(conditionPda: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
|
|
1252
|
+
/** seeds: ["presale", questionMarketConfig, presale_index u64 LE] under presale program */
|
|
1226
1253
|
static presale(questionMarketConfig: PublicKey, presaleIndex: BN, programIds: Pick<ProgramIds, "presale">): [PublicKey, number];
|
|
1227
1254
|
static qtMint(presalePda: PublicKey, programIds: Pick<ProgramIds, "presale">): [PublicKey, number];
|
|
1228
1255
|
static qtAuthority(presalePda: PublicKey, programIds: Pick<ProgramIds, "presale">): [PublicKey, number];
|
|
@@ -1460,4 +1487,4 @@ declare function buildApproveCollateralTx(collateralMint: PublicKey, signer: Pub
|
|
|
1460
1487
|
*/
|
|
1461
1488
|
declare function buildApproveAllOutcomeTokensTx(condition: PublicKey, signer: PublicKey, payer: PublicKey, delegate: PublicKey, programIds: ProgramIds, amount?: BN): Transaction;
|
|
1462
1489
|
|
|
1463
|
-
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;
|
|
@@ -95,6 +111,7 @@ interface QuestionMarketConfig {
|
|
|
95
111
|
owner: PublicKey;
|
|
96
112
|
admin: PublicKey;
|
|
97
113
|
oracle: PublicKey;
|
|
114
|
+
oracleProgram: PublicKey;
|
|
98
115
|
conditionalTokensProgram: PublicKey;
|
|
99
116
|
questionCount: number;
|
|
100
117
|
approvedCount: number;
|
|
@@ -388,7 +405,7 @@ declare class MarketClient {
|
|
|
388
405
|
feeConfigOwner?: PublicKey;
|
|
389
406
|
constructor(program: anchor.Program, provider: anchor.AnchorProvider, programIds: ProgramIds, ownerPubkey: PublicKey);
|
|
390
407
|
get walletPubkey(): PublicKey;
|
|
391
|
-
initialize(admin: PublicKey, oracle: PublicKey, owner?: PublicKey): Promise<Transaction>;
|
|
408
|
+
initialize(admin: PublicKey, oracle: PublicKey, oracleProgram: PublicKey, owner?: PublicKey): Promise<Transaction>;
|
|
392
409
|
/**
|
|
393
410
|
* Build createQuestionAdmin transaction (whitelist/admin path — status = Approved immediately).
|
|
394
411
|
* @param creator - Whitelisted creator (must be in whitelist or be admin/owner)
|
|
@@ -406,6 +423,7 @@ declare class MarketClient {
|
|
|
406
423
|
newOracle?: PublicKey;
|
|
407
424
|
isPaused?: boolean;
|
|
408
425
|
newConditionalTokensProgram?: PublicKey;
|
|
426
|
+
newOracleProgram?: PublicKey;
|
|
409
427
|
}, authority?: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
410
428
|
/** Set the admin (owner only). Replaces any existing admin. */
|
|
411
429
|
addAdmin(newAdmin: PublicKey, owner?: PublicKey): Promise<Transaction>;
|
|
@@ -416,7 +434,11 @@ declare class MarketClient {
|
|
|
416
434
|
growConfig(owner?: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
417
435
|
restoreConfig(snapshot: Buffer, owner?: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
418
436
|
bumpPresaleCount(count: number, authority: PublicKey): Promise<Transaction>;
|
|
437
|
+
private configNotFoundMessage;
|
|
419
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;
|
|
420
442
|
/** Check if address is in question_market whitelist (can call createQuestion) */
|
|
421
443
|
isWhitelisted(address: PublicKey): Promise<boolean>;
|
|
422
444
|
fetchQuestion(questionPda: PublicKey): Promise<Question | null>;
|
|
@@ -435,9 +457,10 @@ declare class MarketClient {
|
|
|
435
457
|
* Any user creates a presale + initial buy (question-market::create_presale).
|
|
436
458
|
* Reads agents_rev / company_rev from fee_config.
|
|
437
459
|
*
|
|
438
|
-
*
|
|
439
|
-
*
|
|
440
|
-
*
|
|
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()
|
|
441
464
|
*/
|
|
442
465
|
createPresale(params: {
|
|
443
466
|
price: anchor.BN;
|
|
@@ -1137,7 +1160,8 @@ declare class DisputeClient {
|
|
|
1137
1160
|
* - No HookClient (hook program removed entirely)
|
|
1138
1161
|
*
|
|
1139
1162
|
* Usage:
|
|
1140
|
-
* 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)
|
|
1141
1165
|
* await sdk.market.createQuestionAdmin(params, oracle); // no hookProgram
|
|
1142
1166
|
* await sdk.clob.matchOrders(taker, makers); // no hook in remainingAccounts
|
|
1143
1167
|
*/
|
|
@@ -1157,6 +1181,8 @@ declare class XMarketSDK {
|
|
|
1157
1181
|
private _referral?;
|
|
1158
1182
|
private _dispute?;
|
|
1159
1183
|
constructor(config: NetworkConfig, wallet: anchor.Wallet, marketOwner?: PublicKey);
|
|
1184
|
+
/** Question market config PDA derived from marketOwner + questionMarket program. */
|
|
1185
|
+
get questionMarketConfigPda(): PublicKey;
|
|
1160
1186
|
private _withAddress;
|
|
1161
1187
|
get oracle(): OracleClient;
|
|
1162
1188
|
get market(): MarketClient;
|
|
@@ -1223,6 +1249,7 @@ declare class PDA {
|
|
|
1223
1249
|
static feeConfig(owner: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
|
|
1224
1250
|
static questionFee(conditionPda: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
|
|
1225
1251
|
static marketFeeOverride(conditionPda: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
|
|
1252
|
+
/** seeds: ["presale", questionMarketConfig, presale_index u64 LE] under presale program */
|
|
1226
1253
|
static presale(questionMarketConfig: PublicKey, presaleIndex: BN, programIds: Pick<ProgramIds, "presale">): [PublicKey, number];
|
|
1227
1254
|
static qtMint(presalePda: PublicKey, programIds: Pick<ProgramIds, "presale">): [PublicKey, number];
|
|
1228
1255
|
static qtAuthority(presalePda: PublicKey, programIds: Pick<ProgramIds, "presale">): [PublicKey, number];
|
|
@@ -1460,4 +1487,4 @@ declare function buildApproveCollateralTx(collateralMint: PublicKey, signer: Pub
|
|
|
1460
1487
|
*/
|
|
1461
1488
|
declare function buildApproveAllOutcomeTokensTx(condition: PublicKey, signer: PublicKey, payer: PublicKey, delegate: PublicKey, programIds: ProgramIds, amount?: BN): Transaction;
|
|
1462
1489
|
|
|
1463
|
-
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);
|
|
@@ -505,11 +506,12 @@ var MarketClient = class {
|
|
|
505
506
|
return this.provider.wallet.publicKey;
|
|
506
507
|
}
|
|
507
508
|
// ─── Instructions (return Transaction — caller signs + sends) ───────────────
|
|
508
|
-
async initialize(admin, oracle, owner = this.walletPubkey) {
|
|
509
|
+
async initialize(admin, oracle, oracleProgram, owner = this.walletPubkey) {
|
|
509
510
|
return this.program.methods.initialize({
|
|
510
511
|
admin,
|
|
511
512
|
conditionalTokensProgram: this.programIds.conditionalTokens,
|
|
512
|
-
oracle
|
|
513
|
+
oracle,
|
|
514
|
+
oracleProgram
|
|
513
515
|
}).accounts({
|
|
514
516
|
owner,
|
|
515
517
|
config: this.configPda,
|
|
@@ -576,7 +578,8 @@ var MarketClient = class {
|
|
|
576
578
|
newAdmin: params.newAdmin ?? null,
|
|
577
579
|
newOracle: params.newOracle ?? null,
|
|
578
580
|
isPaused: params.isPaused ?? null,
|
|
579
|
-
newConditionalTokensProgram: params.newConditionalTokensProgram ?? null
|
|
581
|
+
newConditionalTokensProgram: params.newConditionalTokensProgram ?? null,
|
|
582
|
+
newOracleProgram: params.newOracleProgram ?? null
|
|
580
583
|
}).accounts({
|
|
581
584
|
authority,
|
|
582
585
|
payer,
|
|
@@ -631,27 +634,52 @@ var MarketClient = class {
|
|
|
631
634
|
return this.program.methods.bumpPresaleCount(new anchor6__namespace.BN(count)).accounts({ authority, config: this.configPda }).transaction();
|
|
632
635
|
}
|
|
633
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
|
+
}
|
|
634
640
|
async fetchConfig() {
|
|
641
|
+
const info = await this.provider.connection.getAccountInfo(this.configPda);
|
|
642
|
+
if (!info) return null;
|
|
635
643
|
try {
|
|
636
644
|
const acc = await this.program.account.questionMarketConfig.fetch(this.configPda);
|
|
637
|
-
return
|
|
638
|
-
owner: acc.owner,
|
|
639
|
-
admin: acc.admin,
|
|
640
|
-
oracle: acc.oracle,
|
|
641
|
-
conditionalTokensProgram: acc.conditionalTokensProgram,
|
|
642
|
-
questionCount: acc.questionCount.toNumber(),
|
|
643
|
-
approvedCount: acc.approvedCount.toNumber(),
|
|
644
|
-
rejectedCount: acc.rejectedCount.toNumber(),
|
|
645
|
-
presaleCount: acc.presaleCount.toNumber(),
|
|
646
|
-
whitelist: acc.whitelist.slice(0, acc.whitelistLen),
|
|
647
|
-
whitelistLen: acc.whitelistLen,
|
|
648
|
-
isPaused: acc.isPaused,
|
|
649
|
-
bump: acc.bump
|
|
650
|
-
};
|
|
645
|
+
return this.mapQuestionMarketConfig(acc);
|
|
651
646
|
} catch {
|
|
652
647
|
return null;
|
|
653
648
|
}
|
|
654
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
|
+
}
|
|
655
683
|
/** Check if address is in question_market whitelist (can call createQuestion) */
|
|
656
684
|
async isWhitelisted(address) {
|
|
657
685
|
const cfg = await this.fetchConfig();
|
|
@@ -704,9 +732,10 @@ var MarketClient = class {
|
|
|
704
732
|
* Any user creates a presale + initial buy (question-market::create_presale).
|
|
705
733
|
* Reads agents_rev / company_rev from fee_config.
|
|
706
734
|
*
|
|
707
|
-
*
|
|
708
|
-
*
|
|
709
|
-
*
|
|
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()
|
|
710
739
|
*/
|
|
711
740
|
async createPresale(params, feeConfig, currencyMint, presaleIndex, creator = this.walletPubkey, payer = creator) {
|
|
712
741
|
if (!this.programIds.presale) throw new Error("presale program ID not configured");
|
|
@@ -6101,7 +6130,7 @@ var question_market_default = {
|
|
|
6101
6130
|
{
|
|
6102
6131
|
name: "oracle_program",
|
|
6103
6132
|
docs: [
|
|
6104
|
-
"Oracle program (for reading QuestionResult)"
|
|
6133
|
+
"Oracle program (for reading QuestionResult) \u2014 must match config.oracle_program"
|
|
6105
6134
|
]
|
|
6106
6135
|
},
|
|
6107
6136
|
{
|
|
@@ -6724,7 +6753,14 @@ var question_market_default = {
|
|
|
6724
6753
|
{
|
|
6725
6754
|
name: "oracle",
|
|
6726
6755
|
docs: [
|
|
6727
|
-
"Oracle
|
|
6756
|
+
"Oracle config PDA that will resolve conditions"
|
|
6757
|
+
],
|
|
6758
|
+
type: "pubkey"
|
|
6759
|
+
},
|
|
6760
|
+
{
|
|
6761
|
+
name: "oracle_program",
|
|
6762
|
+
docs: [
|
|
6763
|
+
"Oracle program ID \u2014 used to validate oracle proofs in resolve_question"
|
|
6728
6764
|
],
|
|
6729
6765
|
type: "pubkey"
|
|
6730
6766
|
}
|
|
@@ -7196,7 +7232,7 @@ var question_market_default = {
|
|
|
7196
7232
|
{
|
|
7197
7233
|
name: "oracle",
|
|
7198
7234
|
docs: [
|
|
7199
|
-
"Oracle
|
|
7235
|
+
"Oracle config PDA that will resolve conditions"
|
|
7200
7236
|
],
|
|
7201
7237
|
type: "pubkey"
|
|
7202
7238
|
},
|
|
@@ -7261,6 +7297,14 @@ var question_market_default = {
|
|
|
7261
7297
|
],
|
|
7262
7298
|
type: "u64"
|
|
7263
7299
|
},
|
|
7300
|
+
{
|
|
7301
|
+
name: "oracle_program",
|
|
7302
|
+
docs: [
|
|
7303
|
+
"Oracle program ID \u2014 pinned for CPI validation in resolve_question",
|
|
7304
|
+
"Placed at end of meaningful fields to avoid layout shift on old accounts."
|
|
7305
|
+
],
|
|
7306
|
+
type: "pubkey"
|
|
7307
|
+
},
|
|
7264
7308
|
{
|
|
7265
7309
|
name: "_reserved",
|
|
7266
7310
|
docs: [
|
|
@@ -7269,7 +7313,7 @@ var question_market_default = {
|
|
|
7269
7313
|
type: {
|
|
7270
7314
|
array: [
|
|
7271
7315
|
"u8",
|
|
7272
|
-
|
|
7316
|
+
408
|
|
7273
7317
|
]
|
|
7274
7318
|
}
|
|
7275
7319
|
}
|
|
@@ -7467,6 +7511,15 @@ var question_market_default = {
|
|
|
7467
7511
|
type: {
|
|
7468
7512
|
option: "pubkey"
|
|
7469
7513
|
}
|
|
7514
|
+
},
|
|
7515
|
+
{
|
|
7516
|
+
name: "new_oracle_program",
|
|
7517
|
+
docs: [
|
|
7518
|
+
"New oracle program ID (optional) \u2014 used to validate oracle proofs in resolve_question"
|
|
7519
|
+
],
|
|
7520
|
+
type: {
|
|
7521
|
+
option: "pubkey"
|
|
7522
|
+
}
|
|
7470
7523
|
}
|
|
7471
7524
|
]
|
|
7472
7525
|
}
|
|
@@ -18042,7 +18095,11 @@ var XMarketSDK = class {
|
|
|
18042
18095
|
);
|
|
18043
18096
|
anchor6__namespace.setProvider(this.provider);
|
|
18044
18097
|
this._programIds = config.programIds;
|
|
18045
|
-
this._marketOwner = marketOwner ?? wallet.publicKey;
|
|
18098
|
+
this._marketOwner = marketOwner ?? config.marketOwner ?? wallet.publicKey;
|
|
18099
|
+
}
|
|
18100
|
+
/** Question market config PDA derived from marketOwner + questionMarket program. */
|
|
18101
|
+
get questionMarketConfigPda() {
|
|
18102
|
+
return this.market.configPda;
|
|
18046
18103
|
}
|
|
18047
18104
|
_withAddress(idl, address) {
|
|
18048
18105
|
return { ...idl, address: address.toBase58() };
|
|
@@ -18132,6 +18189,44 @@ var XMarketSDK = class {
|
|
|
18132
18189
|
return this._dispute;
|
|
18133
18190
|
}
|
|
18134
18191
|
};
|
|
18192
|
+
var V2_PROGRAM_IDS = {
|
|
18193
|
+
oracle: new web3_js.PublicKey("8uNiLDZnarxyFyoCi1bE1qkBMsLs2Tpyohtdzdvjkg8j"),
|
|
18194
|
+
conditionalTokens: new web3_js.PublicKey("xpn3htSptTZECudoRA8WJmAEtiijxDseTqtawYysVNT"),
|
|
18195
|
+
questionMarket: new web3_js.PublicKey("FkpHo3zb5h2nNS5n6tWAvDwXPTXR2qqVLjDmEkMayott"),
|
|
18196
|
+
clobExchange: new web3_js.PublicKey("AFT8SM1Vv8g8AQTf81LoE5oLteUTyhWzWTLj7SKZjkY1"),
|
|
18197
|
+
feeManagement: new web3_js.PublicKey("8S6hxqbDc8kgHf4uUzq2t15PeY36QSCYEpBVvM4Fhrkm"),
|
|
18198
|
+
presale: new web3_js.PublicKey("CKd94vPibAMAr8R5eLv21r8PYXkgLRithipBe8GV7J6C"),
|
|
18199
|
+
marketOracle: new web3_js.PublicKey("Agt6beCbghi4jV9A8v9geRP5dnt2wDkJBVgy9oM33zit"),
|
|
18200
|
+
adminContract: new web3_js.PublicKey("2HsyCdr59W5ndeboaE9JAmhEQ46m5Gm2ZWBfYEs1tC1i"),
|
|
18201
|
+
referral: new web3_js.PublicKey("9kyNMtUEFR6hDeZHUTbRKH3t1EJisfSvWQKKUev7ujoC"),
|
|
18202
|
+
dispute: new web3_js.PublicKey("8gqHPY1WtGFGmYNbrGrPVoct1kqPL6cCaUtJ17EHSsFp")
|
|
18203
|
+
};
|
|
18204
|
+
var DEVNET_MARKET_OWNER = new web3_js.PublicKey(
|
|
18205
|
+
"7eGpbyRpcM7WpNKQtd6XkteNQWHbWXP7icZjKzNK2aTk"
|
|
18206
|
+
);
|
|
18207
|
+
var DEVNET_QUESTION_MARKET_CONFIG = new web3_js.PublicKey(
|
|
18208
|
+
"7n8y2oQYmxTp9fn2Wf2dFE1pC7ZESXYJ4yXSbYSEuRn5"
|
|
18209
|
+
);
|
|
18210
|
+
var DEVNET_USDC_MINT = new web3_js.PublicKey(
|
|
18211
|
+
"4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU"
|
|
18212
|
+
);
|
|
18213
|
+
var MAINNET_USDC_MINT = new web3_js.PublicKey(
|
|
18214
|
+
"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
|
|
18215
|
+
);
|
|
18216
|
+
var DEVNET_CONFIG = {
|
|
18217
|
+
name: "devnet",
|
|
18218
|
+
rpcUrl: "https://api.devnet.solana.com",
|
|
18219
|
+
programIds: V2_PROGRAM_IDS,
|
|
18220
|
+
defaultCollateral: { mint: DEVNET_USDC_MINT, decimals: 6 },
|
|
18221
|
+
marketOwner: DEVNET_MARKET_OWNER,
|
|
18222
|
+
feeConfigOwner: DEVNET_MARKET_OWNER
|
|
18223
|
+
};
|
|
18224
|
+
var MAINNET_CONFIG = {
|
|
18225
|
+
name: "mainnet",
|
|
18226
|
+
rpcUrl: "https://api.mainnet-beta.solana.com",
|
|
18227
|
+
programIds: V2_PROGRAM_IDS,
|
|
18228
|
+
defaultCollateral: { mint: MAINNET_USDC_MINT, decimals: 6 }
|
|
18229
|
+
};
|
|
18135
18230
|
var MAX_APPROVE_AMOUNT = new BN4__default.default("18446744073709551615");
|
|
18136
18231
|
function buildCreateUserAtasTx(condition, user, payer, programIds) {
|
|
18137
18232
|
const [yesMint] = PDA.yesMint(condition, programIds);
|
|
@@ -18205,11 +18300,17 @@ exports.AccountNotFoundError = AccountNotFoundError;
|
|
|
18205
18300
|
exports.AdminClient = AdminClient;
|
|
18206
18301
|
exports.ClobClient = ClobClient;
|
|
18207
18302
|
exports.CtfClient = CtfClient;
|
|
18303
|
+
exports.DEVNET_CONFIG = DEVNET_CONFIG;
|
|
18304
|
+
exports.DEVNET_MARKET_OWNER = DEVNET_MARKET_OWNER;
|
|
18305
|
+
exports.DEVNET_QUESTION_MARKET_CONFIG = DEVNET_QUESTION_MARKET_CONFIG;
|
|
18306
|
+
exports.DEVNET_USDC_MINT = DEVNET_USDC_MINT;
|
|
18208
18307
|
exports.DisputeClient = DisputeClient;
|
|
18209
18308
|
exports.FEE_DENOMINATOR = FEE_DENOMINATOR;
|
|
18210
18309
|
exports.FeeManagementClient = FeeManagementClient;
|
|
18211
18310
|
exports.IX_SYSVAR = IX_SYSVAR;
|
|
18212
18311
|
exports.InvalidParamError = InvalidParamError;
|
|
18312
|
+
exports.MAINNET_CONFIG = MAINNET_CONFIG;
|
|
18313
|
+
exports.MAINNET_USDC_MINT = MAINNET_USDC_MINT;
|
|
18213
18314
|
exports.MAX_APPROVE_AMOUNT = MAX_APPROVE_AMOUNT;
|
|
18214
18315
|
exports.MarketClient = MarketClient;
|
|
18215
18316
|
exports.MarketOracleClient = MarketOracleClient;
|
|
@@ -18220,6 +18321,7 @@ exports.QuestionStatus = QuestionStatus;
|
|
|
18220
18321
|
exports.ReferralClient = ReferralClient;
|
|
18221
18322
|
exports.SEEDS = SEEDS;
|
|
18222
18323
|
exports.UnauthorizedError = UnauthorizedError;
|
|
18324
|
+
exports.V2_PROGRAM_IDS = V2_PROGRAM_IDS;
|
|
18223
18325
|
exports.XMarketError = XMarketError;
|
|
18224
18326
|
exports.XMarketSDK = XMarketSDK;
|
|
18225
18327
|
exports.buildApproveAllOutcomeTokensTx = buildApproveAllOutcomeTokensTx;
|