@theliem/xmarket-sdk 3.19.0 → 3.20.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 +14 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +123 -41
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +123 -41
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -571,7 +571,10 @@ var MarketClient = class {
|
|
|
571
571
|
const [mintAuthority] = PDA.mintAuthority(conditionPda, this.programIds);
|
|
572
572
|
const [collateralVault] = PDA.collateralVault(params.collateralMint, this.programIds);
|
|
573
573
|
if (!this.programIds.feeManagement) throw new Error("feeManagement program ID not configured");
|
|
574
|
+
if (!this.feeConfigOwner) throw new Error("feeConfigOwner not configured");
|
|
574
575
|
const [questionFeePda] = PDA.questionFee(conditionPda, this.programIds);
|
|
576
|
+
const [feeConfigPda] = PDA.feeConfig(this.feeConfigOwner, this.programIds);
|
|
577
|
+
const [marketFeeOverride] = PDA.marketFeeOverride(conditionPda, this.programIds);
|
|
575
578
|
const tx = await this.program.methods.createQuestionAdmin({
|
|
576
579
|
questionId: Array.from(questionId),
|
|
577
580
|
contentHash: Array.from(contentHash),
|
|
@@ -592,6 +595,8 @@ var MarketClient = class {
|
|
|
592
595
|
collateralVault,
|
|
593
596
|
conditionalTokensProgram: this.programIds.conditionalTokens,
|
|
594
597
|
questionFee: questionFeePda,
|
|
598
|
+
feeConfig: feeConfigPda,
|
|
599
|
+
marketFeeOverride,
|
|
595
600
|
feeManagementProgram: this.programIds.feeManagement,
|
|
596
601
|
tokenProgram: TOKEN_2022_PROGRAM_ID,
|
|
597
602
|
systemProgram: SystemProgram.programId,
|
|
@@ -663,6 +668,9 @@ var MarketClient = class {
|
|
|
663
668
|
systemProgram: SystemProgram.programId
|
|
664
669
|
}).transaction();
|
|
665
670
|
}
|
|
671
|
+
async bumpPresaleCount(count, authority) {
|
|
672
|
+
return this.program.methods.bumpPresaleCount(new anchor5.BN(count)).accounts({ authority, config: this.configPda }).transaction();
|
|
673
|
+
}
|
|
666
674
|
// ─── Queries ─────────────────────────────────────────────────────────────────
|
|
667
675
|
async fetchConfig() {
|
|
668
676
|
try {
|
|
@@ -829,6 +837,9 @@ var MarketClient = class {
|
|
|
829
837
|
const [adminConfig] = PDA.adminConfig(adminOwner, this.programIds);
|
|
830
838
|
const adminVault = getAssociatedTokenAddressSync(currencyMint, adminConfig, true);
|
|
831
839
|
const [claimRecord] = PDA.claimRecord(conditionPda.toBytes(), this.programIds);
|
|
840
|
+
const feeConfigOwner = this.feeConfigOwner ?? adminOwner;
|
|
841
|
+
const [feeConfigPda] = PDA.feeConfig(feeConfigOwner, this.programIds);
|
|
842
|
+
const [marketFeeOverride] = PDA.marketFeeOverride(conditionPda, this.programIds);
|
|
832
843
|
const builder = this.program.methods.approvePresale({
|
|
833
844
|
contentHash: Array.from(contentHash),
|
|
834
845
|
hookProgram,
|
|
@@ -857,6 +868,8 @@ var MarketClient = class {
|
|
|
857
868
|
adminConfig,
|
|
858
869
|
claimRecord,
|
|
859
870
|
questionFee: questionFeePda,
|
|
871
|
+
feeConfig: feeConfigPda,
|
|
872
|
+
marketFeeOverride,
|
|
860
873
|
feeManagementProgram: this.programIds.feeManagement,
|
|
861
874
|
conditionalTokensProgram: this.programIds.conditionalTokens,
|
|
862
875
|
presaleProgram: this.programIds.presale,
|
|
@@ -1520,6 +1533,8 @@ function _detectMatchType(a, b) {
|
|
|
1520
1533
|
// src/programs/clob.ts
|
|
1521
1534
|
var ClobClient = class {
|
|
1522
1535
|
constructor(program, provider, programIds, networkConfig) {
|
|
1536
|
+
/** Cache: conditionPda.toBase58() → marketOracleVault ATA */
|
|
1537
|
+
this._marketOracleVaultCache = /* @__PURE__ */ new Map();
|
|
1523
1538
|
/** ALT cache: condition.toBase58() → loaded ALT account */
|
|
1524
1539
|
this._altCache = /* @__PURE__ */ new Map();
|
|
1525
1540
|
this.program = program;
|
|
@@ -1542,6 +1557,24 @@ var ClobClient = class {
|
|
|
1542
1557
|
await this.companyAddress();
|
|
1543
1558
|
return this._referralVault;
|
|
1544
1559
|
}
|
|
1560
|
+
/**
|
|
1561
|
+
* Derive marketOracleVault ATA for a condition, cached per condition.
|
|
1562
|
+
* Works for presale markets (market_oracle initialized by approvePresale).
|
|
1563
|
+
* Returns undefined if ctfClient/qmConfigPda not injected or marketOracle not configured.
|
|
1564
|
+
*/
|
|
1565
|
+
async getMarketOracleVault(condition, collateralMint) {
|
|
1566
|
+
if (!this.ctfClient || !this.qmConfigPda || !this.programIds.marketOracle) return void 0;
|
|
1567
|
+
const key = condition.toBase58();
|
|
1568
|
+
const cached = this._marketOracleVaultCache.get(key);
|
|
1569
|
+
if (cached) return cached;
|
|
1570
|
+
const cond = await this.ctfClient.fetchCondition(condition);
|
|
1571
|
+
if (!cond) return void 0;
|
|
1572
|
+
const [questionPda] = PDA.question(this.qmConfigPda, cond.questionId, this.programIds);
|
|
1573
|
+
const [marketOraclePda] = PDA.marketOraclePda(questionPda, this.programIds);
|
|
1574
|
+
const vault = getAssociatedTokenAddressSync(collateralMint, marketOraclePda, true);
|
|
1575
|
+
this._marketOracleVaultCache.set(key, vault);
|
|
1576
|
+
return vault;
|
|
1577
|
+
}
|
|
1545
1578
|
get walletPubkey() {
|
|
1546
1579
|
return this.provider.wallet.publicKey;
|
|
1547
1580
|
}
|
|
@@ -1641,11 +1674,11 @@ var ClobClient = class {
|
|
|
1641
1674
|
if (companyAddr) {
|
|
1642
1675
|
addresses.push(getAssociatedTokenAddressSync(collateralMint, companyAddr));
|
|
1643
1676
|
}
|
|
1644
|
-
|
|
1677
|
+
const oracleVaultForAlt = await this.getMarketOracleVault(condition, collateralMint) ?? payer;
|
|
1678
|
+
addresses.push(oracleVaultForAlt);
|
|
1645
1679
|
if (refVault) {
|
|
1646
1680
|
addresses.push(refVault);
|
|
1647
1681
|
}
|
|
1648
|
-
addresses.push(TOKEN_PROGRAM_ID);
|
|
1649
1682
|
}
|
|
1650
1683
|
const slot = await connection.getSlot("finalized");
|
|
1651
1684
|
const [createIx, altAddress] = AddressLookupTableProgram.createLookupTable({
|
|
@@ -1908,7 +1941,7 @@ ${logs.join("\n")}`);
|
|
|
1908
1941
|
const feeOverridePda = PDA.marketFeeOverride(condition, this.programIds)[0];
|
|
1909
1942
|
const feeOverrideExists = await this.provider.connection.getAccountInfo(feeOverridePda);
|
|
1910
1943
|
if (feeOverrideExists) {
|
|
1911
|
-
const oracleVault = opts?.marketOracleVault ?? this.walletPubkey;
|
|
1944
|
+
const oracleVault = opts?.marketOracleVault ?? await this.getMarketOracleVault(condition, collateralMint) ?? this.walletPubkey;
|
|
1912
1945
|
feeAccounts = [
|
|
1913
1946
|
{ pubkey: this.programIds.feeManagement, isSigner: false, isWritable: false },
|
|
1914
1947
|
{ pubkey: PDA.feeConfig(this.feeConfigOwner, this.programIds)[0], isSigner: false, isWritable: false },
|
|
@@ -2164,15 +2197,14 @@ ${logs.join("\n")}`);
|
|
|
2164
2197
|
const feeOverridePda = PDA.marketFeeOverride(condition, this.programIds)[0];
|
|
2165
2198
|
const feeOverrideExists = await this.provider.connection.getAccountInfo(feeOverridePda);
|
|
2166
2199
|
if (feeOverrideExists) {
|
|
2167
|
-
const oracleVault = opts?.marketOracleVault ?? payer;
|
|
2200
|
+
const oracleVault = opts?.marketOracleVault ?? await this.getMarketOracleVault(condition, collateralMint) ?? payer;
|
|
2168
2201
|
remainingAccounts.push(
|
|
2169
2202
|
{ pubkey: this.programIds.feeManagement, isSigner: false, isWritable: false },
|
|
2170
2203
|
{ pubkey: PDA.feeConfig(this.feeConfigOwner, this.programIds)[0], isSigner: false, isWritable: false },
|
|
2171
2204
|
{ pubkey: feeOverridePda, isSigner: false, isWritable: false },
|
|
2172
2205
|
{ pubkey: getAssociatedTokenAddressSync(collateralMint, companyAddr), isSigner: false, isWritable: true },
|
|
2173
2206
|
{ pubkey: oracleVault, isSigner: false, isWritable: true },
|
|
2174
|
-
{ pubkey: refVault, isSigner: false, isWritable: true }
|
|
2175
|
-
{ pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false }
|
|
2207
|
+
{ pubkey: refVault, isSigner: false, isWritable: true }
|
|
2176
2208
|
);
|
|
2177
2209
|
}
|
|
2178
2210
|
}
|
|
@@ -2498,7 +2530,7 @@ ${logs.join("\n")}`);
|
|
|
2498
2530
|
const feeOverridePda = PDA.marketFeeOverride(condition, this.programIds)[0];
|
|
2499
2531
|
const feeOverrideExists = await this.provider.connection.getAccountInfo(feeOverridePda);
|
|
2500
2532
|
if (feeOverrideExists) {
|
|
2501
|
-
const oracleVault = opts?.marketOracleVault ?? payer;
|
|
2533
|
+
const oracleVault = opts?.marketOracleVault ?? await this.getMarketOracleVault(condition, collateralMint) ?? payer;
|
|
2502
2534
|
feeAccounts = [
|
|
2503
2535
|
{ pubkey: this.programIds.feeManagement, isSigner: false, isWritable: false },
|
|
2504
2536
|
{ pubkey: PDA.feeConfig(this.feeConfigOwner, this.programIds)[0], isSigner: false, isWritable: false },
|
|
@@ -4636,6 +4668,20 @@ var question_market_default = {
|
|
|
4636
4668
|
],
|
|
4637
4669
|
writable: true
|
|
4638
4670
|
},
|
|
4671
|
+
{
|
|
4672
|
+
name: "fee_config",
|
|
4673
|
+
docs: [
|
|
4674
|
+
"FeeConfig PDA \u2014 passed to set_market_fee_override CPI."
|
|
4675
|
+
],
|
|
4676
|
+
writable: true
|
|
4677
|
+
},
|
|
4678
|
+
{
|
|
4679
|
+
name: "market_fee_override",
|
|
4680
|
+
docs: [
|
|
4681
|
+
"MarketFeeOverride PDA \u2014 auto-init with is_admin=false and fee_config defaults."
|
|
4682
|
+
],
|
|
4683
|
+
writable: true
|
|
4684
|
+
},
|
|
4639
4685
|
{
|
|
4640
4686
|
name: "fee_management_program",
|
|
4641
4687
|
address: "DuYyXguB5PVSKg6E2p4XPrrXZSCJnuBhoGpkGCBN5bBb"
|
|
@@ -4741,6 +4787,55 @@ var question_market_default = {
|
|
|
4741
4787
|
],
|
|
4742
4788
|
args: []
|
|
4743
4789
|
},
|
|
4790
|
+
{
|
|
4791
|
+
name: "bump_presale_count",
|
|
4792
|
+
discriminator: [
|
|
4793
|
+
42,
|
|
4794
|
+
84,
|
|
4795
|
+
98,
|
|
4796
|
+
9,
|
|
4797
|
+
208,
|
|
4798
|
+
168,
|
|
4799
|
+
38,
|
|
4800
|
+
55
|
|
4801
|
+
],
|
|
4802
|
+
accounts: [
|
|
4803
|
+
{
|
|
4804
|
+
name: "authority",
|
|
4805
|
+
signer: true
|
|
4806
|
+
},
|
|
4807
|
+
{
|
|
4808
|
+
name: "config",
|
|
4809
|
+
writable: true,
|
|
4810
|
+
pda: {
|
|
4811
|
+
seeds: [
|
|
4812
|
+
{
|
|
4813
|
+
kind: "const",
|
|
4814
|
+
value: [
|
|
4815
|
+
99,
|
|
4816
|
+
111,
|
|
4817
|
+
110,
|
|
4818
|
+
102,
|
|
4819
|
+
105,
|
|
4820
|
+
103
|
|
4821
|
+
]
|
|
4822
|
+
},
|
|
4823
|
+
{
|
|
4824
|
+
kind: "account",
|
|
4825
|
+
path: "config.owner",
|
|
4826
|
+
account: "QuestionMarketConfig"
|
|
4827
|
+
}
|
|
4828
|
+
]
|
|
4829
|
+
}
|
|
4830
|
+
}
|
|
4831
|
+
],
|
|
4832
|
+
args: [
|
|
4833
|
+
{
|
|
4834
|
+
name: "count",
|
|
4835
|
+
type: "u64"
|
|
4836
|
+
}
|
|
4837
|
+
]
|
|
4838
|
+
},
|
|
4744
4839
|
{
|
|
4745
4840
|
name: "collect_presale_revenue",
|
|
4746
4841
|
discriminator: [
|
|
@@ -5297,39 +5392,23 @@ var question_market_default = {
|
|
|
5297
5392
|
{
|
|
5298
5393
|
name: "question_fee",
|
|
5299
5394
|
docs: [
|
|
5300
|
-
"QuestionFee PDA \u2014 initialized with default fees via CPI to fee-management."
|
|
5301
|
-
"Seed uses condition.key() bytes (consistent with existing set_question_fee SDK convention)."
|
|
5395
|
+
"QuestionFee PDA \u2014 initialized with default fees via CPI to fee-management."
|
|
5302
5396
|
],
|
|
5303
|
-
writable: true
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
-
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
102,
|
|
5319
|
-
101,
|
|
5320
|
-
101
|
|
5321
|
-
]
|
|
5322
|
-
},
|
|
5323
|
-
{
|
|
5324
|
-
kind: "account",
|
|
5325
|
-
path: "condition"
|
|
5326
|
-
}
|
|
5327
|
-
],
|
|
5328
|
-
program: {
|
|
5329
|
-
kind: "account",
|
|
5330
|
-
path: "fee_management_program"
|
|
5331
|
-
}
|
|
5332
|
-
}
|
|
5397
|
+
writable: true
|
|
5398
|
+
},
|
|
5399
|
+
{
|
|
5400
|
+
name: "fee_config",
|
|
5401
|
+
docs: [
|
|
5402
|
+
"FeeConfig PDA \u2014 passed to set_market_fee_override CPI as authority validator."
|
|
5403
|
+
],
|
|
5404
|
+
writable: true
|
|
5405
|
+
},
|
|
5406
|
+
{
|
|
5407
|
+
name: "market_fee_override",
|
|
5408
|
+
docs: [
|
|
5409
|
+
"MarketFeeOverride PDA \u2014 init'd by set_market_fee_override CPI (is_admin=true)."
|
|
5410
|
+
],
|
|
5411
|
+
writable: true
|
|
5333
5412
|
},
|
|
5334
5413
|
{
|
|
5335
5414
|
name: "fee_management_program",
|
|
@@ -6895,7 +6974,7 @@ var question_market_default = {
|
|
|
6895
6974
|
type: {
|
|
6896
6975
|
array: [
|
|
6897
6976
|
"pubkey",
|
|
6898
|
-
|
|
6977
|
+
20
|
|
6899
6978
|
]
|
|
6900
6979
|
}
|
|
6901
6980
|
},
|
|
@@ -6935,7 +7014,7 @@ var question_market_default = {
|
|
|
6935
7014
|
type: {
|
|
6936
7015
|
array: [
|
|
6937
7016
|
"u8",
|
|
6938
|
-
|
|
7017
|
+
440
|
|
6939
7018
|
]
|
|
6940
7019
|
}
|
|
6941
7020
|
}
|
|
@@ -16286,6 +16365,7 @@ var XMarketSDK = class {
|
|
|
16286
16365
|
const program = new anchor5.Program(this._withAddress(question_market_default, this._programIds.questionMarket), this.provider);
|
|
16287
16366
|
this._market = new MarketClient(program, this.provider, this._programIds, this._marketOwner);
|
|
16288
16367
|
this._market.ctfClient = this.ctf;
|
|
16368
|
+
this._market.feeConfigOwner = this.networkConfig.feeConfigOwner ?? this._marketOwner;
|
|
16289
16369
|
}
|
|
16290
16370
|
return this._market;
|
|
16291
16371
|
}
|
|
@@ -16304,6 +16384,8 @@ var XMarketSDK = class {
|
|
|
16304
16384
|
this._clob.feeConfigOwner = this.networkConfig.feeConfigOwner;
|
|
16305
16385
|
this._clob.feeClient = this.fee;
|
|
16306
16386
|
}
|
|
16387
|
+
this._clob.ctfClient = this.ctf;
|
|
16388
|
+
this._clob.qmConfigPda = this.market.configPda;
|
|
16307
16389
|
}
|
|
16308
16390
|
return this._clob;
|
|
16309
16391
|
}
|