@theliem/xmarket-sdk 3.3.1 → 3.4.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.js CHANGED
@@ -59,7 +59,10 @@ var SEEDS = {
59
59
  userBuy: Buffer.from("user_buy"),
60
60
  // Market Oracle
61
61
  marketOracle: Buffer.from("market_oracle"),
62
- userClaim: Buffer.from("user_claim")
62
+ userClaim: Buffer.from("user_claim"),
63
+ // Admin Contract
64
+ adminConfig: Buffer.from("admin_config"),
65
+ claimRecord: Buffer.from("claim_record")
63
66
  };
64
67
  var PDA = class {
65
68
  // ─── Question Market ────────────────────────────────────────────────────────
@@ -247,6 +250,21 @@ var PDA = class {
247
250
  programIds.marketOracle
248
251
  );
249
252
  }
253
+ // ─── Admin Contract ──────────────────────────────────────────────────────
254
+ static adminConfig(owner, programIds) {
255
+ if (!programIds.adminContract) throw new Error("adminContract program ID not configured");
256
+ return web3_js.PublicKey.findProgramAddressSync(
257
+ [SEEDS.adminConfig, owner.toBuffer()],
258
+ programIds.adminContract
259
+ );
260
+ }
261
+ static claimRecord(conditionId, programIds) {
262
+ if (!programIds.adminContract) throw new Error("adminContract program ID not configured");
263
+ return web3_js.PublicKey.findProgramAddressSync(
264
+ [SEEDS.claimRecord, conditionId],
265
+ programIds.adminContract
266
+ );
267
+ }
250
268
  };
251
269
  function generateQuestionId(content, salt) {
252
270
  const input = content + (salt ?? Date.now());
@@ -849,13 +867,26 @@ var MarketClient = class {
849
867
  * Whitelist-only: distribute presale vault → 10% agents + 10% company + 80% botmm.
850
868
  * Closes presale_vault ATA and presale PDA after distribution; lamports returned to payer.
851
869
  */
852
- async collectPresaleRevenue(presalePda, currencyMint, referralAddress, companyAddress, botmmAddress, caller = this.walletPubkey, payer = this.walletPubkey) {
870
+ async collectPresaleRevenue(params) {
871
+ const {
872
+ presalePda,
873
+ currencyMint,
874
+ conditionId,
875
+ referralAddress,
876
+ companyAddress,
877
+ adminOwner
878
+ } = params;
879
+ const caller = params.caller ?? this.walletPubkey;
880
+ const payer = params.payer ?? this.walletPubkey;
853
881
  if (!this.programIds.presale) throw new Error("presale program ID not configured");
882
+ if (!this.programIds.adminContract) throw new Error("adminContract program ID not configured");
854
883
  const presaleVault = splToken.getAssociatedTokenAddressSync(currencyMint, presalePda, true);
855
884
  const referralTokenAccount = splToken.getAssociatedTokenAddressSync(currencyMint, referralAddress);
856
885
  const companyTokenAccount = splToken.getAssociatedTokenAddressSync(currencyMint, companyAddress);
857
- const botmmTokenAccount = splToken.getAssociatedTokenAddressSync(currencyMint, botmmAddress);
858
- return this.program.methods.collectPresaleRevenue().accounts({
886
+ const [adminConfig] = PDA.adminConfig(adminOwner, this.programIds);
887
+ const [claimRecord] = PDA.claimRecord(conditionId, this.programIds);
888
+ const adminVault = splToken.getAssociatedTokenAddressSync(currencyMint, adminConfig, true);
889
+ return this.program.methods.collectPresaleRevenue(Array.from(conditionId)).accounts({
859
890
  caller,
860
891
  config: this.configPda,
861
892
  presale: presalePda,
@@ -863,9 +894,12 @@ var MarketClient = class {
863
894
  currencyMint,
864
895
  referralTokenAccount,
865
896
  companyTokenAccount,
866
- botmmTokenAccount,
897
+ adminVault,
898
+ adminConfig,
899
+ claimRecord,
867
900
  payer,
868
901
  presaleProgram: this.programIds.presale,
902
+ adminProgram: this.programIds.adminContract,
869
903
  tokenProgram: splToken.TOKEN_PROGRAM_ID,
870
904
  associatedTokenProgram: splToken.ASSOCIATED_TOKEN_PROGRAM_ID,
871
905
  systemProgram: web3_js.SystemProgram.programId
@@ -1432,8 +1466,8 @@ var ClobClient = class {
1432
1466
  async _sendLegacyTxSig(instructions) {
1433
1467
  const { connection } = this.provider;
1434
1468
  const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash();
1435
- const { Transaction: Transaction7 } = await import('@solana/web3.js');
1436
- const tx = new Transaction7();
1469
+ const { Transaction: Transaction8 } = await import('@solana/web3.js');
1470
+ const tx = new Transaction8();
1437
1471
  tx.recentBlockhash = blockhash;
1438
1472
  tx.feePayer = this.walletPubkey;
1439
1473
  tx.add(...instructions);
@@ -1860,7 +1894,10 @@ ${logs.join("\n")}`);
1860
1894
  if (t.side === SIDE_BUY && makers.every((m) => m.order.side === SIDE_SELL)) {
1861
1895
  return this.matchComplementary(taker, makers, collateralMint, feeRecipient, operatorWallet, alt, opts);
1862
1896
  }
1863
- throw new InvalidParamError("COMPLEMENTARY requires taker=BUY, makers=SELL on same tokenId");
1897
+ if (t.side === SIDE_SELL && makers.every((m) => m.order.side === SIDE_BUY)) {
1898
+ return this.matchComplementary(makers[0], [taker, ...makers.slice(1)], collateralMint, feeRecipient, operatorWallet, alt, opts);
1899
+ }
1900
+ throw new InvalidParamError("COMPLEMENTARY requires one BUY and one SELL on same tokenId");
1864
1901
  }
1865
1902
  const allBuy = t.side === SIDE_BUY && makers.every((m) => m.order.side === SIDE_BUY);
1866
1903
  const allSell = t.side === SIDE_SELL && makers.every((m) => m.order.side === SIDE_SELL);
@@ -2254,6 +2291,139 @@ var MarketOracleClient = class {
2254
2291
  }
2255
2292
  }
2256
2293
  };
2294
+ var AdminClient = class {
2295
+ constructor(program, provider, programIds) {
2296
+ this.program = program;
2297
+ this.provider = provider;
2298
+ this.programIds = programIds;
2299
+ }
2300
+ get walletPubkey() {
2301
+ return this.provider.wallet.publicKey;
2302
+ }
2303
+ get configPda() {
2304
+ const [pda] = PDA.adminConfig(this.walletPubkey, this.programIds);
2305
+ return pda;
2306
+ }
2307
+ configPdaFor(owner) {
2308
+ const [pda] = PDA.adminConfig(owner, this.programIds);
2309
+ return pda;
2310
+ }
2311
+ adminVault(owner, collateralMint) {
2312
+ const configPda = this.configPdaFor(owner);
2313
+ return splToken.getAssociatedTokenAddressSync(collateralMint, configPda, true);
2314
+ }
2315
+ // ─── Fetch ────────────────────────────────────────────────────────────────
2316
+ async fetchConfig(owner = this.walletPubkey) {
2317
+ const [configPda] = PDA.adminConfig(owner, this.programIds);
2318
+ try {
2319
+ const acc = await this.program.account.adminConfig.fetch(configPda);
2320
+ return {
2321
+ version: acc.version,
2322
+ owner: acc.owner,
2323
+ collateralMint: acc.collateralMint,
2324
+ authorizedCaller: acc.authorizedCaller,
2325
+ adminWhitelist: acc.adminWhitelist.slice(0, acc.adminWhitelistLen),
2326
+ whitelist: acc.whitelist.slice(0, acc.whitelistLen),
2327
+ bump: acc.bump
2328
+ };
2329
+ } catch {
2330
+ return null;
2331
+ }
2332
+ }
2333
+ async fetchClaimRecord(conditionId) {
2334
+ const [pda] = PDA.claimRecord(conditionId, this.programIds);
2335
+ try {
2336
+ const acc = await this.program.account.claimRecord.fetch(pda);
2337
+ return {
2338
+ conditionId: acc.conditionId,
2339
+ amount: acc.amount,
2340
+ bump: acc.bump
2341
+ };
2342
+ } catch {
2343
+ return null;
2344
+ }
2345
+ }
2346
+ // ─── Instructions ─────────────────────────────────────────────────────────
2347
+ async initialize(authorizedCaller, collateralMint, owner = this.walletPubkey) {
2348
+ const [configPda] = PDA.adminConfig(owner, this.programIds);
2349
+ const vault = splToken.getAssociatedTokenAddressSync(collateralMint, configPda, true);
2350
+ return this.program.methods.initialize(authorizedCaller).accounts({
2351
+ owner,
2352
+ config: configPda,
2353
+ collateralMint,
2354
+ adminVault: vault,
2355
+ tokenProgram: splToken.TOKEN_PROGRAM_ID,
2356
+ associatedTokenProgram: splToken.ASSOCIATED_TOKEN_PROGRAM_ID,
2357
+ systemProgram: web3_js.SystemProgram.programId
2358
+ }).transaction();
2359
+ }
2360
+ async addAdmin(address, owner = this.walletPubkey) {
2361
+ const [configPda] = PDA.adminConfig(owner, this.programIds);
2362
+ return this.program.methods.addAdmin(address).accounts({ owner, config: configPda }).transaction();
2363
+ }
2364
+ async removeAdmin(address, owner = this.walletPubkey) {
2365
+ const [configPda] = PDA.adminConfig(owner, this.programIds);
2366
+ return this.program.methods.removeAdmin(address).accounts({ owner, config: configPda }).transaction();
2367
+ }
2368
+ async addToWhitelist(address, owner, admin = this.walletPubkey, payer = admin) {
2369
+ const [configPda] = PDA.adminConfig(owner, this.programIds);
2370
+ return this.program.methods.addToWhitelist(address).accounts({ admin, payer, config: configPda }).transaction();
2371
+ }
2372
+ async removeFromWhitelist(address, owner, admin = this.walletPubkey, payer = admin) {
2373
+ const [configPda] = PDA.adminConfig(owner, this.programIds);
2374
+ return this.program.methods.removeFromWhitelist(address).accounts({ admin, payer, config: configPda }).transaction();
2375
+ }
2376
+ /**
2377
+ * Normally called via CPI from question_market (authorized_caller signs).
2378
+ * For testing: initialize with authorizedCaller = wallet, call directly.
2379
+ */
2380
+ async setPresaleAmount(conditionId, amount, owner = this.walletPubkey, caller = this.walletPubkey, payer = caller) {
2381
+ const [configPda] = PDA.adminConfig(owner, this.programIds);
2382
+ const [claimRecord] = PDA.claimRecord(conditionId, this.programIds);
2383
+ return this.program.methods.setPresaleAmount(Array.from(conditionId), amount).accounts({
2384
+ caller,
2385
+ payer,
2386
+ config: configPda,
2387
+ claimRecord,
2388
+ systemProgram: web3_js.SystemProgram.programId
2389
+ }).transaction();
2390
+ }
2391
+ async claim(conditionId, collateralMint, owner, claimer = this.walletPubkey, payer = claimer) {
2392
+ const [configPda] = PDA.adminConfig(owner, this.programIds);
2393
+ const [claimRecord] = PDA.claimRecord(conditionId, this.programIds);
2394
+ const vault = splToken.getAssociatedTokenAddressSync(collateralMint, configPda, true);
2395
+ const claimerAta = splToken.getAssociatedTokenAddressSync(collateralMint, claimer);
2396
+ return this.program.methods.claim(Array.from(conditionId)).accounts({
2397
+ claimer,
2398
+ payer,
2399
+ config: configPda,
2400
+ adminVault: vault,
2401
+ claimRecord,
2402
+ claimerTokenAccount: claimerAta,
2403
+ tokenProgram: splToken.TOKEN_PROGRAM_ID
2404
+ }).transaction();
2405
+ }
2406
+ async updateConfig(authorizedCaller, owner = this.walletPubkey) {
2407
+ const [configPda] = PDA.adminConfig(owner, this.programIds);
2408
+ return this.program.methods.updateConfig(authorizedCaller).accounts({ owner, config: configPda }).transaction();
2409
+ }
2410
+ /**
2411
+ * BOTMM sends USDC from their wallet to the market_oracle vault for a condition.
2412
+ * Whitelist-only. No amount validation — caller responsible.
2413
+ */
2414
+ async distributeMarket(conditionId, amount, collateralMint, marketOracleVault, owner, claimer = this.walletPubkey, payer = claimer) {
2415
+ const [configPda] = PDA.adminConfig(owner, this.programIds);
2416
+ const claimerTokenAcct = splToken.getAssociatedTokenAddressSync(collateralMint, claimer);
2417
+ return this.program.methods.distributeMarket(Array.from(conditionId), amount).accounts({
2418
+ claimer,
2419
+ payer,
2420
+ config: configPda,
2421
+ claimerTokenAccount: claimerTokenAcct,
2422
+ marketOracleVault,
2423
+ tokenProgram: splToken.TOKEN_PROGRAM_ID
2424
+ }).transaction();
2425
+ }
2426
+ };
2257
2427
 
2258
2428
  // src/idls/oracle.json
2259
2429
  var oracle_default = {
@@ -3820,7 +3990,7 @@ var question_market_default = {
3820
3990
  {
3821
3991
  name: "presale_vault",
3822
3992
  docs: [
3823
- "Presale USDC vault \u2014 closed inside presale program"
3993
+ "Presale USDC vault \u2014 read balance before CPI, closed inside presale program"
3824
3994
  ],
3825
3995
  writable: true
3826
3996
  },
@@ -3830,24 +4000,66 @@ var question_market_default = {
3830
4000
  {
3831
4001
  name: "referral_token_account",
3832
4002
  docs: [
3833
- "Referral address USDC token account"
4003
+ "Referral address USDC token account (10%)"
3834
4004
  ],
3835
4005
  writable: true
3836
4006
  },
3837
4007
  {
3838
4008
  name: "company_token_account",
3839
4009
  docs: [
3840
- "Company address USDC token account"
4010
+ "Company address USDC token account (10%)"
3841
4011
  ],
3842
4012
  writable: true
3843
4013
  },
3844
4014
  {
3845
- name: "botmm_token_account",
4015
+ name: "admin_vault",
3846
4016
  docs: [
3847
- "BOTMM token account (receives ~80%)"
4017
+ "admin_contract vault ATA \u2014 receives 80% instead of BOTMM wallet directly"
3848
4018
  ],
3849
4019
  writable: true
3850
4020
  },
4021
+ {
4022
+ name: "admin_config",
4023
+ docs: [
4024
+ "admin_contract config PDA"
4025
+ ]
4026
+ },
4027
+ {
4028
+ name: "claim_record",
4029
+ docs: [
4030
+ "ClaimRecord PDA for this conditionId (created by admin_contract CPI)"
4031
+ ],
4032
+ writable: true,
4033
+ pda: {
4034
+ seeds: [
4035
+ {
4036
+ kind: "const",
4037
+ value: [
4038
+ 99,
4039
+ 108,
4040
+ 97,
4041
+ 105,
4042
+ 109,
4043
+ 95,
4044
+ 114,
4045
+ 101,
4046
+ 99,
4047
+ 111,
4048
+ 114,
4049
+ 100
4050
+ ]
4051
+ },
4052
+ {
4053
+ kind: "arg",
4054
+ path: "condition_id"
4055
+ }
4056
+ ],
4057
+ program: {
4058
+ kind: "account",
4059
+ path: "admin_program"
4060
+ }
4061
+ }
4062
+ },
3851
4063
  {
3852
4064
  name: "payer",
3853
4065
  docs: [
@@ -3859,6 +4071,10 @@ var question_market_default = {
3859
4071
  name: "presale_program",
3860
4072
  address: "2Rnw1VoEtsUMQ7wkvYZjDehqSqRob6uNkeymDfvKrquB"
3861
4073
  },
4074
+ {
4075
+ name: "admin_program",
4076
+ address: "4NdD5962SfGqofmeyjfifJpdGnwTAiKaUKB5Z42UDc9T"
4077
+ },
3862
4078
  {
3863
4079
  name: "token_program",
3864
4080
  address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
@@ -3872,7 +4088,17 @@ var question_market_default = {
3872
4088
  address: "11111111111111111111111111111111"
3873
4089
  }
3874
4090
  ],
3875
- args: []
4091
+ args: [
4092
+ {
4093
+ name: "condition_id",
4094
+ type: {
4095
+ array: [
4096
+ "u8",
4097
+ 32
4098
+ ]
4099
+ }
4100
+ }
4101
+ ]
3876
4102
  },
3877
4103
  {
3878
4104
  name: "collect_trading_fee",
@@ -13220,85 +13446,1067 @@ var market_oracle_default = {
13220
13446
  ]
13221
13447
  };
13222
13448
 
13223
- // src/sdk.ts
13224
- var XMarketSDK = class {
13225
- constructor(config, wallet, marketOwner) {
13226
- this.networkConfig = config;
13227
- this.provider = new anchor5__namespace.AnchorProvider(
13228
- new web3_js.Connection(config.rpcUrl, "confirmed"),
13229
- wallet,
13230
- { commitment: "confirmed", preflightCommitment: "confirmed" }
13231
- );
13232
- anchor5__namespace.setProvider(this.provider);
13233
- this._programIds = config.programIds;
13234
- this._marketOwner = marketOwner ?? wallet.publicKey;
13235
- }
13236
- _withAddress(idl, address) {
13237
- return { ...idl, address: address.toBase58() };
13238
- }
13239
- get oracle() {
13240
- if (!this._oracle) {
13241
- const program = new anchor5__namespace.Program(this._withAddress(oracle_default, this._programIds.oracle), this.provider);
13242
- this._oracle = new OracleClient(program, this.provider, this._programIds);
13243
- }
13244
- return this._oracle;
13245
- }
13246
- get hook() {
13247
- if (!this._hook) {
13248
- const program = new anchor5__namespace.Program(this._withAddress(hook_default, this._programIds.hook), this.provider);
13249
- this._hook = new HookClient(program, this.provider, this._programIds);
13250
- }
13251
- return this._hook;
13252
- }
13253
- get market() {
13254
- if (!this._market) {
13255
- const program = new anchor5__namespace.Program(this._withAddress(question_market_default, this._programIds.questionMarket), this.provider);
13256
- this._market = new MarketClient(program, this.provider, this._programIds, this._marketOwner);
13257
- this._market.ctfClient = this.ctf;
13258
- }
13259
- return this._market;
13260
- }
13261
- get ctf() {
13262
- if (!this._ctf) {
13263
- const program = new anchor5__namespace.Program(this._withAddress(conditional_tokens_default, this._programIds.conditionalTokens), this.provider);
13264
- this._ctf = new CtfClient(program, this.provider, this._programIds);
13265
- }
13266
- return this._ctf;
13267
- }
13268
- get clob() {
13269
- if (!this._clob) {
13270
- const program = new anchor5__namespace.Program(this._withAddress(clob_exchange_default, this._programIds.clobExchange), this.provider);
13271
- this._clob = new ClobClient(program, this.provider, this._programIds, this.networkConfig);
13272
- if (this.networkConfig.feeConfigOwner && this._programIds.feeManagement) {
13273
- this._clob.feeConfigOwner = this.networkConfig.feeConfigOwner;
13274
- this._clob.feeClient = this.fee;
13275
- }
13276
- }
13277
- return this._clob;
13278
- }
13279
- get fee() {
13280
- if (!this._fee) {
13281
- if (!this._programIds.feeManagement) throw new Error("feeManagement program ID not configured in NetworkConfig");
13282
- const program = new anchor5__namespace.Program(this._withAddress(fee_management_default, this._programIds.feeManagement), this.provider);
13283
- this._fee = new FeeManagementClient(program, this.provider, this._programIds);
13284
- }
13285
- return this._fee;
13286
- }
13287
- get presale() {
13288
- if (!this._presale) {
13289
- if (!this._programIds.presale) throw new Error("presale program ID not configured in NetworkConfig");
13290
- const program = new anchor5__namespace.Program(this._withAddress(presale_default, this._programIds.presale), this.provider);
13291
- this._presale = new PresaleClient(program, this.provider, this._programIds);
13292
- }
13293
- return this._presale;
13294
- }
13295
- get marketOracle() {
13296
- if (!this._marketOracle) {
13297
- if (!this._programIds.marketOracle) throw new Error("marketOracle program ID not configured in NetworkConfig");
13298
- const program = new anchor5__namespace.Program(this._withAddress(market_oracle_default, this._programIds.marketOracle), this.provider);
13299
- this._marketOracle = new MarketOracleClient(program, this.provider, this._programIds);
13300
- }
13301
- return this._marketOracle;
13449
+ // src/idls/admin_contract.json
13450
+ var admin_contract_default = {
13451
+ address: "4NdD5962SfGqofmeyjfifJpdGnwTAiKaUKB5Z42UDc9T",
13452
+ metadata: {
13453
+ name: "admin_contract",
13454
+ version: "0.1.0",
13455
+ spec: "0.1.0",
13456
+ description: "Admin contract for XMarket \u2014 whitelist, presale revenue custody, claim"
13457
+ },
13458
+ instructions: [
13459
+ {
13460
+ name: "add_admin",
13461
+ discriminator: [
13462
+ 177,
13463
+ 236,
13464
+ 33,
13465
+ 205,
13466
+ 124,
13467
+ 152,
13468
+ 55,
13469
+ 186
13470
+ ],
13471
+ accounts: [
13472
+ {
13473
+ name: "owner",
13474
+ signer: true
13475
+ },
13476
+ {
13477
+ name: "config",
13478
+ writable: true,
13479
+ pda: {
13480
+ seeds: [
13481
+ {
13482
+ kind: "const",
13483
+ value: [
13484
+ 97,
13485
+ 100,
13486
+ 109,
13487
+ 105,
13488
+ 110,
13489
+ 95,
13490
+ 99,
13491
+ 111,
13492
+ 110,
13493
+ 102,
13494
+ 105,
13495
+ 103
13496
+ ]
13497
+ },
13498
+ {
13499
+ kind: "account",
13500
+ path: "config.owner",
13501
+ account: "AdminConfig"
13502
+ }
13503
+ ]
13504
+ }
13505
+ }
13506
+ ],
13507
+ args: [
13508
+ {
13509
+ name: "address",
13510
+ type: "pubkey"
13511
+ }
13512
+ ]
13513
+ },
13514
+ {
13515
+ name: "add_to_whitelist",
13516
+ discriminator: [
13517
+ 157,
13518
+ 211,
13519
+ 52,
13520
+ 54,
13521
+ 144,
13522
+ 81,
13523
+ 5,
13524
+ 55
13525
+ ],
13526
+ accounts: [
13527
+ {
13528
+ name: "admin",
13529
+ signer: true
13530
+ },
13531
+ {
13532
+ name: "payer",
13533
+ writable: true,
13534
+ signer: true
13535
+ },
13536
+ {
13537
+ name: "config",
13538
+ writable: true,
13539
+ pda: {
13540
+ seeds: [
13541
+ {
13542
+ kind: "const",
13543
+ value: [
13544
+ 97,
13545
+ 100,
13546
+ 109,
13547
+ 105,
13548
+ 110,
13549
+ 95,
13550
+ 99,
13551
+ 111,
13552
+ 110,
13553
+ 102,
13554
+ 105,
13555
+ 103
13556
+ ]
13557
+ },
13558
+ {
13559
+ kind: "account",
13560
+ path: "config.owner",
13561
+ account: "AdminConfig"
13562
+ }
13563
+ ]
13564
+ }
13565
+ }
13566
+ ],
13567
+ args: [
13568
+ {
13569
+ name: "address",
13570
+ type: "pubkey"
13571
+ }
13572
+ ]
13573
+ },
13574
+ {
13575
+ name: "claim",
13576
+ discriminator: [
13577
+ 62,
13578
+ 198,
13579
+ 214,
13580
+ 193,
13581
+ 213,
13582
+ 159,
13583
+ 108,
13584
+ 210
13585
+ ],
13586
+ accounts: [
13587
+ {
13588
+ name: "claimer",
13589
+ signer: true
13590
+ },
13591
+ {
13592
+ name: "payer",
13593
+ writable: true,
13594
+ signer: true
13595
+ },
13596
+ {
13597
+ name: "config",
13598
+ pda: {
13599
+ seeds: [
13600
+ {
13601
+ kind: "const",
13602
+ value: [
13603
+ 97,
13604
+ 100,
13605
+ 109,
13606
+ 105,
13607
+ 110,
13608
+ 95,
13609
+ 99,
13610
+ 111,
13611
+ 110,
13612
+ 102,
13613
+ 105,
13614
+ 103
13615
+ ]
13616
+ },
13617
+ {
13618
+ kind: "account",
13619
+ path: "config.owner",
13620
+ account: "AdminConfig"
13621
+ }
13622
+ ]
13623
+ }
13624
+ },
13625
+ {
13626
+ name: "admin_vault",
13627
+ docs: [
13628
+ "ATA owned by config PDA"
13629
+ ],
13630
+ writable: true,
13631
+ pda: {
13632
+ seeds: [
13633
+ {
13634
+ kind: "account",
13635
+ path: "config"
13636
+ },
13637
+ {
13638
+ kind: "const",
13639
+ value: [
13640
+ 6,
13641
+ 221,
13642
+ 246,
13643
+ 225,
13644
+ 215,
13645
+ 101,
13646
+ 161,
13647
+ 147,
13648
+ 217,
13649
+ 203,
13650
+ 225,
13651
+ 70,
13652
+ 206,
13653
+ 235,
13654
+ 121,
13655
+ 172,
13656
+ 28,
13657
+ 180,
13658
+ 133,
13659
+ 237,
13660
+ 95,
13661
+ 91,
13662
+ 55,
13663
+ 145,
13664
+ 58,
13665
+ 140,
13666
+ 245,
13667
+ 133,
13668
+ 126,
13669
+ 255,
13670
+ 0,
13671
+ 169
13672
+ ]
13673
+ },
13674
+ {
13675
+ kind: "account",
13676
+ path: "config.collateral_mint",
13677
+ account: "AdminConfig"
13678
+ }
13679
+ ],
13680
+ program: {
13681
+ kind: "const",
13682
+ value: [
13683
+ 140,
13684
+ 151,
13685
+ 37,
13686
+ 143,
13687
+ 78,
13688
+ 36,
13689
+ 137,
13690
+ 241,
13691
+ 187,
13692
+ 61,
13693
+ 16,
13694
+ 41,
13695
+ 20,
13696
+ 142,
13697
+ 13,
13698
+ 131,
13699
+ 11,
13700
+ 90,
13701
+ 19,
13702
+ 153,
13703
+ 218,
13704
+ 255,
13705
+ 16,
13706
+ 132,
13707
+ 4,
13708
+ 142,
13709
+ 123,
13710
+ 216,
13711
+ 219,
13712
+ 233,
13713
+ 248,
13714
+ 89
13715
+ ]
13716
+ }
13717
+ }
13718
+ },
13719
+ {
13720
+ name: "claim_record",
13721
+ writable: true,
13722
+ pda: {
13723
+ seeds: [
13724
+ {
13725
+ kind: "const",
13726
+ value: [
13727
+ 99,
13728
+ 108,
13729
+ 97,
13730
+ 105,
13731
+ 109,
13732
+ 95,
13733
+ 114,
13734
+ 101,
13735
+ 99,
13736
+ 111,
13737
+ 114,
13738
+ 100
13739
+ ]
13740
+ },
13741
+ {
13742
+ kind: "arg",
13743
+ path: "condition_id"
13744
+ }
13745
+ ]
13746
+ }
13747
+ },
13748
+ {
13749
+ name: "claimer_token_account",
13750
+ docs: [
13751
+ "Claimer's USDC token account (receives payout)"
13752
+ ],
13753
+ writable: true
13754
+ },
13755
+ {
13756
+ name: "token_program",
13757
+ address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
13758
+ }
13759
+ ],
13760
+ args: [
13761
+ {
13762
+ name: "condition_id",
13763
+ type: {
13764
+ array: [
13765
+ "u8",
13766
+ 32
13767
+ ]
13768
+ }
13769
+ }
13770
+ ]
13771
+ },
13772
+ {
13773
+ name: "distribute_market",
13774
+ discriminator: [
13775
+ 130,
13776
+ 221,
13777
+ 123,
13778
+ 201,
13779
+ 185,
13780
+ 168,
13781
+ 63,
13782
+ 19
13783
+ ],
13784
+ accounts: [
13785
+ {
13786
+ name: "claimer",
13787
+ docs: [
13788
+ "BOTMM \u2014 must be in whitelist"
13789
+ ],
13790
+ signer: true
13791
+ },
13792
+ {
13793
+ name: "payer",
13794
+ writable: true,
13795
+ signer: true
13796
+ },
13797
+ {
13798
+ name: "config",
13799
+ pda: {
13800
+ seeds: [
13801
+ {
13802
+ kind: "const",
13803
+ value: [
13804
+ 97,
13805
+ 100,
13806
+ 109,
13807
+ 105,
13808
+ 110,
13809
+ 95,
13810
+ 99,
13811
+ 111,
13812
+ 110,
13813
+ 102,
13814
+ 105,
13815
+ 103
13816
+ ]
13817
+ },
13818
+ {
13819
+ kind: "account",
13820
+ path: "config.owner",
13821
+ account: "AdminConfig"
13822
+ }
13823
+ ]
13824
+ }
13825
+ },
13826
+ {
13827
+ name: "claimer_token_account",
13828
+ docs: [
13829
+ "BOTMM's USDC token account (source \u2014 claimer signs)"
13830
+ ],
13831
+ writable: true
13832
+ },
13833
+ {
13834
+ name: "market_oracle_vault",
13835
+ docs: [
13836
+ "market_oracle vault \u2014 MST holder reward pool for this condition"
13837
+ ],
13838
+ writable: true
13839
+ },
13840
+ {
13841
+ name: "token_program",
13842
+ address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
13843
+ }
13844
+ ],
13845
+ args: [
13846
+ {
13847
+ name: "condition_id",
13848
+ type: {
13849
+ array: [
13850
+ "u8",
13851
+ 32
13852
+ ]
13853
+ }
13854
+ },
13855
+ {
13856
+ name: "amount",
13857
+ type: "u64"
13858
+ }
13859
+ ]
13860
+ },
13861
+ {
13862
+ name: "initialize",
13863
+ discriminator: [
13864
+ 175,
13865
+ 175,
13866
+ 109,
13867
+ 31,
13868
+ 13,
13869
+ 152,
13870
+ 155,
13871
+ 237
13872
+ ],
13873
+ accounts: [
13874
+ {
13875
+ name: "owner",
13876
+ writable: true,
13877
+ signer: true
13878
+ },
13879
+ {
13880
+ name: "config",
13881
+ writable: true,
13882
+ pda: {
13883
+ seeds: [
13884
+ {
13885
+ kind: "const",
13886
+ value: [
13887
+ 97,
13888
+ 100,
13889
+ 109,
13890
+ 105,
13891
+ 110,
13892
+ 95,
13893
+ 99,
13894
+ 111,
13895
+ 110,
13896
+ 102,
13897
+ 105,
13898
+ 103
13899
+ ]
13900
+ },
13901
+ {
13902
+ kind: "account",
13903
+ path: "owner"
13904
+ }
13905
+ ]
13906
+ }
13907
+ },
13908
+ {
13909
+ name: "collateral_mint"
13910
+ },
13911
+ {
13912
+ name: "admin_vault",
13913
+ docs: [
13914
+ "ATA owned by config PDA \u2014 holds USDC for unclaimed presale revenue"
13915
+ ],
13916
+ writable: true,
13917
+ pda: {
13918
+ seeds: [
13919
+ {
13920
+ kind: "account",
13921
+ path: "config"
13922
+ },
13923
+ {
13924
+ kind: "const",
13925
+ value: [
13926
+ 6,
13927
+ 221,
13928
+ 246,
13929
+ 225,
13930
+ 215,
13931
+ 101,
13932
+ 161,
13933
+ 147,
13934
+ 217,
13935
+ 203,
13936
+ 225,
13937
+ 70,
13938
+ 206,
13939
+ 235,
13940
+ 121,
13941
+ 172,
13942
+ 28,
13943
+ 180,
13944
+ 133,
13945
+ 237,
13946
+ 95,
13947
+ 91,
13948
+ 55,
13949
+ 145,
13950
+ 58,
13951
+ 140,
13952
+ 245,
13953
+ 133,
13954
+ 126,
13955
+ 255,
13956
+ 0,
13957
+ 169
13958
+ ]
13959
+ },
13960
+ {
13961
+ kind: "account",
13962
+ path: "collateral_mint"
13963
+ }
13964
+ ],
13965
+ program: {
13966
+ kind: "const",
13967
+ value: [
13968
+ 140,
13969
+ 151,
13970
+ 37,
13971
+ 143,
13972
+ 78,
13973
+ 36,
13974
+ 137,
13975
+ 241,
13976
+ 187,
13977
+ 61,
13978
+ 16,
13979
+ 41,
13980
+ 20,
13981
+ 142,
13982
+ 13,
13983
+ 131,
13984
+ 11,
13985
+ 90,
13986
+ 19,
13987
+ 153,
13988
+ 218,
13989
+ 255,
13990
+ 16,
13991
+ 132,
13992
+ 4,
13993
+ 142,
13994
+ 123,
13995
+ 216,
13996
+ 219,
13997
+ 233,
13998
+ 248,
13999
+ 89
14000
+ ]
14001
+ }
14002
+ }
14003
+ },
14004
+ {
14005
+ name: "token_program",
14006
+ address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
14007
+ },
14008
+ {
14009
+ name: "associated_token_program",
14010
+ address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
14011
+ },
14012
+ {
14013
+ name: "system_program",
14014
+ address: "11111111111111111111111111111111"
14015
+ }
14016
+ ],
14017
+ args: [
14018
+ {
14019
+ name: "authorized_caller",
14020
+ type: "pubkey"
14021
+ }
14022
+ ]
14023
+ },
14024
+ {
14025
+ name: "remove_admin",
14026
+ discriminator: [
14027
+ 74,
14028
+ 202,
14029
+ 71,
14030
+ 106,
14031
+ 252,
14032
+ 31,
14033
+ 72,
14034
+ 183
14035
+ ],
14036
+ accounts: [
14037
+ {
14038
+ name: "owner",
14039
+ signer: true
14040
+ },
14041
+ {
14042
+ name: "config",
14043
+ writable: true,
14044
+ pda: {
14045
+ seeds: [
14046
+ {
14047
+ kind: "const",
14048
+ value: [
14049
+ 97,
14050
+ 100,
14051
+ 109,
14052
+ 105,
14053
+ 110,
14054
+ 95,
14055
+ 99,
14056
+ 111,
14057
+ 110,
14058
+ 102,
14059
+ 105,
14060
+ 103
14061
+ ]
14062
+ },
14063
+ {
14064
+ kind: "account",
14065
+ path: "config.owner",
14066
+ account: "AdminConfig"
14067
+ }
14068
+ ]
14069
+ }
14070
+ }
14071
+ ],
14072
+ args: [
14073
+ {
14074
+ name: "address",
14075
+ type: "pubkey"
14076
+ }
14077
+ ]
14078
+ },
14079
+ {
14080
+ name: "remove_from_whitelist",
14081
+ discriminator: [
14082
+ 7,
14083
+ 144,
14084
+ 216,
14085
+ 239,
14086
+ 243,
14087
+ 236,
14088
+ 193,
14089
+ 235
14090
+ ],
14091
+ accounts: [
14092
+ {
14093
+ name: "admin",
14094
+ signer: true
14095
+ },
14096
+ {
14097
+ name: "payer",
14098
+ writable: true,
14099
+ signer: true
14100
+ },
14101
+ {
14102
+ name: "config",
14103
+ writable: true,
14104
+ pda: {
14105
+ seeds: [
14106
+ {
14107
+ kind: "const",
14108
+ value: [
14109
+ 97,
14110
+ 100,
14111
+ 109,
14112
+ 105,
14113
+ 110,
14114
+ 95,
14115
+ 99,
14116
+ 111,
14117
+ 110,
14118
+ 102,
14119
+ 105,
14120
+ 103
14121
+ ]
14122
+ },
14123
+ {
14124
+ kind: "account",
14125
+ path: "config.owner",
14126
+ account: "AdminConfig"
14127
+ }
14128
+ ]
14129
+ }
14130
+ }
14131
+ ],
14132
+ args: [
14133
+ {
14134
+ name: "address",
14135
+ type: "pubkey"
14136
+ }
14137
+ ]
14138
+ },
14139
+ {
14140
+ name: "set_presale_amount",
14141
+ discriminator: [
14142
+ 73,
14143
+ 71,
14144
+ 238,
14145
+ 3,
14146
+ 202,
14147
+ 163,
14148
+ 8,
14149
+ 254
14150
+ ],
14151
+ accounts: [
14152
+ {
14153
+ name: "caller",
14154
+ docs: [
14155
+ "question_market config PDA \u2014 signs this CPI call via seeds"
14156
+ ],
14157
+ signer: true
14158
+ },
14159
+ {
14160
+ name: "payer",
14161
+ writable: true,
14162
+ signer: true
14163
+ },
14164
+ {
14165
+ name: "config",
14166
+ pda: {
14167
+ seeds: [
14168
+ {
14169
+ kind: "const",
14170
+ value: [
14171
+ 97,
14172
+ 100,
14173
+ 109,
14174
+ 105,
14175
+ 110,
14176
+ 95,
14177
+ 99,
14178
+ 111,
14179
+ 110,
14180
+ 102,
14181
+ 105,
14182
+ 103
14183
+ ]
14184
+ },
14185
+ {
14186
+ kind: "account",
14187
+ path: "config.owner",
14188
+ account: "AdminConfig"
14189
+ }
14190
+ ]
14191
+ }
14192
+ },
14193
+ {
14194
+ name: "claim_record",
14195
+ writable: true,
14196
+ pda: {
14197
+ seeds: [
14198
+ {
14199
+ kind: "const",
14200
+ value: [
14201
+ 99,
14202
+ 108,
14203
+ 97,
14204
+ 105,
14205
+ 109,
14206
+ 95,
14207
+ 114,
14208
+ 101,
14209
+ 99,
14210
+ 111,
14211
+ 114,
14212
+ 100
14213
+ ]
14214
+ },
14215
+ {
14216
+ kind: "arg",
14217
+ path: "condition_id"
14218
+ }
14219
+ ]
14220
+ }
14221
+ },
14222
+ {
14223
+ name: "system_program",
14224
+ address: "11111111111111111111111111111111"
14225
+ }
14226
+ ],
14227
+ args: [
14228
+ {
14229
+ name: "condition_id",
14230
+ type: {
14231
+ array: [
14232
+ "u8",
14233
+ 32
14234
+ ]
14235
+ }
14236
+ },
14237
+ {
14238
+ name: "amount",
14239
+ type: "u64"
14240
+ }
14241
+ ]
14242
+ },
14243
+ {
14244
+ name: "update_config",
14245
+ discriminator: [
14246
+ 29,
14247
+ 158,
14248
+ 252,
14249
+ 191,
14250
+ 10,
14251
+ 83,
14252
+ 219,
14253
+ 99
14254
+ ],
14255
+ accounts: [
14256
+ {
14257
+ name: "owner",
14258
+ signer: true
14259
+ },
14260
+ {
14261
+ name: "config",
14262
+ writable: true,
14263
+ pda: {
14264
+ seeds: [
14265
+ {
14266
+ kind: "const",
14267
+ value: [
14268
+ 97,
14269
+ 100,
14270
+ 109,
14271
+ 105,
14272
+ 110,
14273
+ 95,
14274
+ 99,
14275
+ 111,
14276
+ 110,
14277
+ 102,
14278
+ 105,
14279
+ 103
14280
+ ]
14281
+ },
14282
+ {
14283
+ kind: "account",
14284
+ path: "config.owner",
14285
+ account: "AdminConfig"
14286
+ }
14287
+ ]
14288
+ }
14289
+ }
14290
+ ],
14291
+ args: [
14292
+ {
14293
+ name: "authorized_caller",
14294
+ type: "pubkey"
14295
+ }
14296
+ ]
14297
+ }
14298
+ ],
14299
+ accounts: [
14300
+ {
14301
+ name: "AdminConfig",
14302
+ discriminator: [
14303
+ 156,
14304
+ 10,
14305
+ 79,
14306
+ 161,
14307
+ 71,
14308
+ 9,
14309
+ 62,
14310
+ 77
14311
+ ]
14312
+ },
14313
+ {
14314
+ name: "ClaimRecord",
14315
+ discriminator: [
14316
+ 57,
14317
+ 229,
14318
+ 0,
14319
+ 9,
14320
+ 65,
14321
+ 62,
14322
+ 96,
14323
+ 7
14324
+ ]
14325
+ }
14326
+ ],
14327
+ types: [
14328
+ {
14329
+ name: "AdminConfig",
14330
+ type: {
14331
+ kind: "struct",
14332
+ fields: [
14333
+ {
14334
+ name: "version",
14335
+ type: "u8"
14336
+ },
14337
+ {
14338
+ name: "owner",
14339
+ type: "pubkey"
14340
+ },
14341
+ {
14342
+ name: "collateral_mint",
14343
+ type: "pubkey"
14344
+ },
14345
+ {
14346
+ name: "authorized_caller",
14347
+ docs: [
14348
+ "question_market config PDA \u2014 only this can call set_presale_amount"
14349
+ ],
14350
+ type: "pubkey"
14351
+ },
14352
+ {
14353
+ name: "admin_whitelist",
14354
+ type: {
14355
+ array: [
14356
+ "pubkey",
14357
+ 10
14358
+ ]
14359
+ }
14360
+ },
14361
+ {
14362
+ name: "admin_whitelist_len",
14363
+ type: "u8"
14364
+ },
14365
+ {
14366
+ name: "whitelist",
14367
+ type: {
14368
+ array: [
14369
+ "pubkey",
14370
+ 30
14371
+ ]
14372
+ }
14373
+ },
14374
+ {
14375
+ name: "whitelist_len",
14376
+ type: "u8"
14377
+ },
14378
+ {
14379
+ name: "bump",
14380
+ type: "u8"
14381
+ },
14382
+ {
14383
+ name: "_reserved",
14384
+ type: {
14385
+ array: [
14386
+ "u8",
14387
+ 64
14388
+ ]
14389
+ }
14390
+ }
14391
+ ]
14392
+ }
14393
+ },
14394
+ {
14395
+ name: "ClaimRecord",
14396
+ type: {
14397
+ kind: "struct",
14398
+ fields: [
14399
+ {
14400
+ name: "condition_id",
14401
+ type: {
14402
+ array: [
14403
+ "u8",
14404
+ 32
14405
+ ]
14406
+ }
14407
+ },
14408
+ {
14409
+ name: "amount",
14410
+ type: "u64"
14411
+ },
14412
+ {
14413
+ name: "bump",
14414
+ type: "u8"
14415
+ }
14416
+ ]
14417
+ }
14418
+ }
14419
+ ]
14420
+ };
14421
+
14422
+ // src/sdk.ts
14423
+ var XMarketSDK = class {
14424
+ // lazy-init in get admin()
14425
+ constructor(config, wallet, marketOwner) {
14426
+ this.networkConfig = config;
14427
+ this.provider = new anchor5__namespace.AnchorProvider(
14428
+ new web3_js.Connection(config.rpcUrl, "confirmed"),
14429
+ wallet,
14430
+ { commitment: "confirmed", preflightCommitment: "confirmed" }
14431
+ );
14432
+ anchor5__namespace.setProvider(this.provider);
14433
+ this._programIds = config.programIds;
14434
+ this._marketOwner = marketOwner ?? wallet.publicKey;
14435
+ }
14436
+ _withAddress(idl, address) {
14437
+ return { ...idl, address: address.toBase58() };
14438
+ }
14439
+ get oracle() {
14440
+ if (!this._oracle) {
14441
+ const program = new anchor5__namespace.Program(this._withAddress(oracle_default, this._programIds.oracle), this.provider);
14442
+ this._oracle = new OracleClient(program, this.provider, this._programIds);
14443
+ }
14444
+ return this._oracle;
14445
+ }
14446
+ get hook() {
14447
+ if (!this._hook) {
14448
+ const program = new anchor5__namespace.Program(this._withAddress(hook_default, this._programIds.hook), this.provider);
14449
+ this._hook = new HookClient(program, this.provider, this._programIds);
14450
+ }
14451
+ return this._hook;
14452
+ }
14453
+ get market() {
14454
+ if (!this._market) {
14455
+ const program = new anchor5__namespace.Program(this._withAddress(question_market_default, this._programIds.questionMarket), this.provider);
14456
+ this._market = new MarketClient(program, this.provider, this._programIds, this._marketOwner);
14457
+ this._market.ctfClient = this.ctf;
14458
+ }
14459
+ return this._market;
14460
+ }
14461
+ get ctf() {
14462
+ if (!this._ctf) {
14463
+ const program = new anchor5__namespace.Program(this._withAddress(conditional_tokens_default, this._programIds.conditionalTokens), this.provider);
14464
+ this._ctf = new CtfClient(program, this.provider, this._programIds);
14465
+ }
14466
+ return this._ctf;
14467
+ }
14468
+ get clob() {
14469
+ if (!this._clob) {
14470
+ const program = new anchor5__namespace.Program(this._withAddress(clob_exchange_default, this._programIds.clobExchange), this.provider);
14471
+ this._clob = new ClobClient(program, this.provider, this._programIds, this.networkConfig);
14472
+ if (this.networkConfig.feeConfigOwner && this._programIds.feeManagement) {
14473
+ this._clob.feeConfigOwner = this.networkConfig.feeConfigOwner;
14474
+ this._clob.feeClient = this.fee;
14475
+ }
14476
+ }
14477
+ return this._clob;
14478
+ }
14479
+ get fee() {
14480
+ if (!this._fee) {
14481
+ if (!this._programIds.feeManagement) throw new Error("feeManagement program ID not configured in NetworkConfig");
14482
+ const program = new anchor5__namespace.Program(this._withAddress(fee_management_default, this._programIds.feeManagement), this.provider);
14483
+ this._fee = new FeeManagementClient(program, this.provider, this._programIds);
14484
+ }
14485
+ return this._fee;
14486
+ }
14487
+ get presale() {
14488
+ if (!this._presale) {
14489
+ if (!this._programIds.presale) throw new Error("presale program ID not configured in NetworkConfig");
14490
+ const program = new anchor5__namespace.Program(this._withAddress(presale_default, this._programIds.presale), this.provider);
14491
+ this._presale = new PresaleClient(program, this.provider, this._programIds);
14492
+ }
14493
+ return this._presale;
14494
+ }
14495
+ get marketOracle() {
14496
+ if (!this._marketOracle) {
14497
+ if (!this._programIds.marketOracle) throw new Error("marketOracle program ID not configured in NetworkConfig");
14498
+ const program = new anchor5__namespace.Program(this._withAddress(market_oracle_default, this._programIds.marketOracle), this.provider);
14499
+ this._marketOracle = new MarketOracleClient(program, this.provider, this._programIds);
14500
+ }
14501
+ return this._marketOracle;
14502
+ }
14503
+ get admin() {
14504
+ if (!this._admin) {
14505
+ if (!this._programIds.adminContract) throw new Error("adminContract program ID not configured in NetworkConfig");
14506
+ const program = new anchor5__namespace.Program(this._withAddress(admin_contract_default, this._programIds.adminContract), this.provider);
14507
+ this._admin = new AdminClient(program, this.provider, this._programIds);
14508
+ }
14509
+ return this._admin;
13302
14510
  }
13303
14511
  };
13304
14512
  function buildOrder(params) {
@@ -13430,6 +14638,7 @@ function buildApproveAllOutcomeTokensTx(condition, signer, payer, delegate, prog
13430
14638
  }
13431
14639
 
13432
14640
  exports.AccountNotFoundError = AccountNotFoundError;
14641
+ exports.AdminClient = AdminClient;
13433
14642
  exports.ClobClient = ClobClient;
13434
14643
  exports.CtfClient = CtfClient;
13435
14644
  exports.FEE_DENOMINATOR = FEE_DENOMINATOR;