@theliem/xmarket-sdk 3.22.0 → 3.23.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.mjs CHANGED
@@ -37,7 +37,11 @@ var SEEDS = {
37
37
  userClaim: Buffer.from("user_claim"),
38
38
  // Admin Contract
39
39
  adminConfig: Buffer.from("admin_config"),
40
- claimRecord: Buffer.from("claim_record")
40
+ claimRecord: Buffer.from("claim_record"),
41
+ // Dispute
42
+ disputeConfig: Buffer.from("dispute_config"),
43
+ disputeMarket: Buffer.from("dispute_market"),
44
+ userDispute: Buffer.from("user_dispute")
41
45
  };
42
46
  var PDA = class {
43
47
  // ─── Question Market ────────────────────────────────────────────────────────
@@ -248,6 +252,28 @@ var PDA = class {
248
252
  programIds.adminContract
249
253
  );
250
254
  }
255
+ // ─── Dispute ─────────────────────────────────────────────────────────────
256
+ static disputeConfig(owner, programIds) {
257
+ if (!programIds.dispute) throw new Error("dispute program ID not configured");
258
+ return PublicKey.findProgramAddressSync(
259
+ [SEEDS.disputeConfig, owner.toBuffer()],
260
+ programIds.dispute
261
+ );
262
+ }
263
+ static disputeMarket(conditionId, programIds) {
264
+ if (!programIds.dispute) throw new Error("dispute program ID not configured");
265
+ return PublicKey.findProgramAddressSync(
266
+ [SEEDS.disputeMarket, Buffer.from(conditionId)],
267
+ programIds.dispute
268
+ );
269
+ }
270
+ static userDispute(user, conditionId, programIds) {
271
+ if (!programIds.dispute) throw new Error("dispute program ID not configured");
272
+ return PublicKey.findProgramAddressSync(
273
+ [SEEDS.userDispute, user.toBuffer(), Buffer.from(conditionId)],
274
+ programIds.dispute
275
+ );
276
+ }
251
277
  };
252
278
  function generateQuestionId(content, salt) {
253
279
  const input = content + (salt ?? Date.now());
@@ -1730,8 +1756,8 @@ var ClobClient = class {
1730
1756
  async _sendLegacyTxSig(instructions) {
1731
1757
  const { connection } = this.provider;
1732
1758
  const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash();
1733
- const { Transaction: Transaction10 } = await import('@solana/web3.js');
1734
- const tx = new Transaction10();
1759
+ const { Transaction: Transaction11 } = await import('@solana/web3.js');
1760
+ const tx = new Transaction11();
1735
1761
  tx.recentBlockhash = blockhash;
1736
1762
  tx.feePayer = this.walletPubkey;
1737
1763
  tx.add(...instructions);
@@ -3319,6 +3345,137 @@ var ReferralClient = class {
3319
3345
  ).transaction();
3320
3346
  }
3321
3347
  };
3348
+ var DisputeClient = class {
3349
+ constructor(program, provider, programIds) {
3350
+ this.program = program;
3351
+ this.provider = provider;
3352
+ this.programIds = programIds;
3353
+ }
3354
+ get walletPubkey() {
3355
+ return this.provider.wallet.publicKey;
3356
+ }
3357
+ configPdaFor(owner) {
3358
+ const [pda] = PDA.disputeConfig(owner, this.programIds);
3359
+ return pda;
3360
+ }
3361
+ disputeVault(owner, collateralMint) {
3362
+ const configPda = this.configPdaFor(owner);
3363
+ return getAssociatedTokenAddressSync(collateralMint, configPda, true);
3364
+ }
3365
+ // ─── Fetch ────────────────────────────────────────────────────────────────
3366
+ async fetchConfig(owner = this.walletPubkey) {
3367
+ const [configPda] = PDA.disputeConfig(owner, this.programIds);
3368
+ try {
3369
+ const acc = await this.program.account.disputeConfig.fetch(configPda);
3370
+ return {
3371
+ version: acc.version,
3372
+ owner: acc.owner,
3373
+ admin: acc.admin,
3374
+ collateralMint: acc.collateralMint,
3375
+ bump: acc.bump
3376
+ };
3377
+ } catch {
3378
+ return null;
3379
+ }
3380
+ }
3381
+ async fetchDisputeMarket(conditionId) {
3382
+ const [pda] = PDA.disputeMarket(conditionId, this.programIds);
3383
+ try {
3384
+ const acc = await this.program.account.disputeMarket.fetch(pda);
3385
+ return {
3386
+ version: acc.version,
3387
+ conditionId: acc.conditionId,
3388
+ deadline: acc.deadline,
3389
+ bond: acc.bond,
3390
+ amount: acc.amount,
3391
+ isResolved: acc.isResolved,
3392
+ bump: acc.bump
3393
+ };
3394
+ } catch {
3395
+ return null;
3396
+ }
3397
+ }
3398
+ async fetchUserDispute(user, conditionId) {
3399
+ const [pda] = PDA.userDispute(user, conditionId, this.programIds);
3400
+ try {
3401
+ const acc = await this.program.account.userDispute.fetch(pda);
3402
+ return {
3403
+ version: acc.version,
3404
+ user: acc.user,
3405
+ conditionId: acc.conditionId,
3406
+ amount: acc.amount,
3407
+ bump: acc.bump
3408
+ };
3409
+ } catch {
3410
+ return null;
3411
+ }
3412
+ }
3413
+ // ─── Instructions ─────────────────────────────────────────────────────────
3414
+ async initialize(collateralMint, owner = this.walletPubkey) {
3415
+ const [configPda] = PDA.disputeConfig(owner, this.programIds);
3416
+ const vault = getAssociatedTokenAddressSync(collateralMint, configPda, true);
3417
+ return this.program.methods.initialize().accounts({
3418
+ owner,
3419
+ disputeConfig: configPda,
3420
+ collateralMint,
3421
+ disputeVault: vault,
3422
+ tokenProgram: TOKEN_PROGRAM_ID,
3423
+ associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
3424
+ systemProgram: SystemProgram.programId
3425
+ }).transaction();
3426
+ }
3427
+ async buildSetAdminTx(newAdmin, owner = this.walletPubkey) {
3428
+ const [configPda] = PDA.disputeConfig(owner, this.programIds);
3429
+ return this.program.methods.setAdmin(newAdmin).accounts({
3430
+ owner,
3431
+ disputeConfig: configPda
3432
+ }).transaction();
3433
+ }
3434
+ async buildRaiseDisputeTx(conditionId, collateralMint, owner, user = this.walletPubkey, payer = user) {
3435
+ const [configPda] = PDA.disputeConfig(owner, this.programIds);
3436
+ const [disputeMarket] = PDA.disputeMarket(conditionId, this.programIds);
3437
+ const [userDispute] = PDA.userDispute(user, conditionId, this.programIds);
3438
+ const userAta = getAssociatedTokenAddressSync(collateralMint, user);
3439
+ const vault = getAssociatedTokenAddressSync(collateralMint, configPda, true);
3440
+ return this.program.methods.raiseDispute(Array.from(conditionId)).accounts({
3441
+ user,
3442
+ payer,
3443
+ disputeConfig: configPda,
3444
+ disputeMarket,
3445
+ userDispute,
3446
+ userAta,
3447
+ disputeVault: vault,
3448
+ tokenProgram: TOKEN_PROGRAM_ID,
3449
+ associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
3450
+ systemProgram: SystemProgram.programId
3451
+ }).transaction();
3452
+ }
3453
+ async buildClaimTx(conditionId, collateralMint, owner, user = this.walletPubkey) {
3454
+ const [configPda] = PDA.disputeConfig(owner, this.programIds);
3455
+ const [disputeMarket] = PDA.disputeMarket(conditionId, this.programIds);
3456
+ const [userDispute] = PDA.userDispute(user, conditionId, this.programIds);
3457
+ const vault = getAssociatedTokenAddressSync(collateralMint, configPda, true);
3458
+ const userAta = getAssociatedTokenAddressSync(collateralMint, user);
3459
+ return this.program.methods.claim(Array.from(conditionId)).accounts({
3460
+ user,
3461
+ disputeConfig: configPda,
3462
+ disputeMarket,
3463
+ userDispute,
3464
+ disputeVault: vault,
3465
+ userAta,
3466
+ tokenProgram: TOKEN_PROGRAM_ID
3467
+ }).transaction();
3468
+ }
3469
+ async buildResolveDisputeTx(conditionId, amount, isRefunded, owner, admin = this.walletPubkey) {
3470
+ const [configPda] = PDA.disputeConfig(owner, this.programIds);
3471
+ const [disputeMarket] = PDA.disputeMarket(conditionId, this.programIds);
3472
+ return this.program.methods.resolveDispute(Array.from(conditionId), amount, isRefunded).accounts({
3473
+ admin,
3474
+ disputeConfig: configPda,
3475
+ disputeMarket
3476
+ }).transaction();
3477
+ }
3478
+ };
3322
3479
 
3323
3480
  // src/idls/oracle.json
3324
3481
  var oracle_default = {
@@ -16440,105 +16597,1134 @@ var referral_default = {
16440
16597
  ]
16441
16598
  };
16442
16599
 
16443
- // src/sdk.ts
16444
- var XMarketSDK = class {
16445
- constructor(config, wallet, marketOwner) {
16446
- this.networkConfig = config;
16447
- this.provider = new anchor5.AnchorProvider(
16448
- new Connection(config.rpcUrl, "confirmed"),
16449
- wallet,
16450
- { commitment: "confirmed", preflightCommitment: "confirmed" }
16451
- );
16452
- anchor5.setProvider(this.provider);
16453
- this._programIds = config.programIds;
16454
- this._marketOwner = marketOwner ?? wallet.publicKey;
16455
- }
16456
- _withAddress(idl, address) {
16457
- return { ...idl, address: address.toBase58() };
16458
- }
16459
- get oracle() {
16460
- if (!this._oracle) {
16461
- const program = new anchor5.Program(this._withAddress(oracle_default, this._programIds.oracle), this.provider);
16462
- this._oracle = new OracleClient(program, this.provider, this._programIds);
16463
- }
16464
- return this._oracle;
16465
- }
16466
- get hook() {
16467
- if (!this._hook) {
16468
- const program = new anchor5.Program(this._withAddress(hook_default, this._programIds.hook), this.provider);
16469
- this._hook = new HookClient(program, this.provider, this._programIds);
16470
- }
16471
- return this._hook;
16472
- }
16473
- get market() {
16474
- if (!this._market) {
16475
- const program = new anchor5.Program(this._withAddress(question_market_default, this._programIds.questionMarket), this.provider);
16476
- this._market = new MarketClient(program, this.provider, this._programIds, this._marketOwner);
16477
- this._market.ctfClient = this.ctf;
16478
- this._market.feeConfigOwner = this.networkConfig.feeConfigOwner ?? this._marketOwner;
16479
- }
16480
- return this._market;
16481
- }
16482
- get ctf() {
16483
- if (!this._ctf) {
16484
- const program = new anchor5.Program(this._withAddress(conditional_tokens_default, this._programIds.conditionalTokens), this.provider);
16485
- this._ctf = new CtfClient(program, this.provider, this._programIds);
16486
- }
16487
- return this._ctf;
16488
- }
16489
- get clob() {
16490
- if (!this._clob) {
16491
- const program = new anchor5.Program(this._withAddress(clob_exchange_default, this._programIds.clobExchange), this.provider);
16492
- this._clob = new ClobClient(program, this.provider, this._programIds, this.networkConfig);
16493
- if (this.networkConfig.feeConfigOwner && this._programIds.feeManagement) {
16494
- this._clob.feeConfigOwner = this.networkConfig.feeConfigOwner;
16495
- this._clob.feeClient = this.fee;
16496
- }
16497
- this._clob.ctfClient = this.ctf;
16498
- this._clob.qmConfigPda = this.market.configPda;
16499
- this._clob.hookClient = this.hook;
16500
- }
16501
- return this._clob;
16502
- }
16503
- get fee() {
16504
- if (!this._fee) {
16505
- if (!this._programIds.feeManagement) throw new Error("feeManagement program ID not configured in NetworkConfig");
16506
- const program = new anchor5.Program(this._withAddress(fee_management_default, this._programIds.feeManagement), this.provider);
16507
- this._fee = new FeeManagementClient(program, this.provider, this._programIds);
16508
- }
16509
- return this._fee;
16510
- }
16511
- get presale() {
16512
- if (!this._presale) {
16513
- if (!this._programIds.presale) throw new Error("presale program ID not configured in NetworkConfig");
16514
- const program = new anchor5.Program(this._withAddress(presale_default, this._programIds.presale), this.provider);
16515
- this._presale = new PresaleClient(program, this.provider, this._programIds);
16516
- }
16517
- return this._presale;
16518
- }
16519
- get marketOracle() {
16520
- if (!this._marketOracle) {
16521
- if (!this._programIds.marketOracle) throw new Error("marketOracle program ID not configured in NetworkConfig");
16522
- const program = new anchor5.Program(this._withAddress(market_oracle_default, this._programIds.marketOracle), this.provider);
16523
- this._marketOracle = new MarketOracleClient(program, this.provider, this._programIds);
16524
- }
16525
- return this._marketOracle;
16526
- }
16527
- get admin() {
16528
- if (!this._admin) {
16529
- if (!this._programIds.adminContract) throw new Error("adminContract program ID not configured in NetworkConfig");
16530
- const program = new anchor5.Program(this._withAddress(admin_contract_default, this._programIds.adminContract), this.provider);
16531
- this._admin = new AdminClient(program, this.provider, this._programIds);
16532
- }
16533
- return this._admin;
16534
- }
16535
- get referral() {
16536
- if (!this._referral) {
16537
- if (!this._programIds.referral) throw new Error("referral program ID not configured in NetworkConfig");
16538
- const program = new anchor5.Program(this._withAddress(referral_default, this._programIds.referral), this.provider);
16539
- this._referral = new ReferralClient(program, this.provider, this._programIds);
16540
- }
16541
- return this._referral;
16600
+ // src/idls/dispute.json
16601
+ var dispute_default = {
16602
+ address: "4toSDWDCcx37R6HZ78P71nDp3NNoJvcmQpzP4sfivVvL",
16603
+ metadata: {
16604
+ name: "dispute",
16605
+ version: "0.1.0",
16606
+ spec: "0.1.0",
16607
+ description: "Dispute program for XMarket \u2014 raise/resolve/claim disputes on prediction markets"
16608
+ },
16609
+ instructions: [
16610
+ {
16611
+ name: "claim",
16612
+ discriminator: [
16613
+ 62,
16614
+ 198,
16615
+ 214,
16616
+ 193,
16617
+ 213,
16618
+ 159,
16619
+ 108,
16620
+ 210
16621
+ ],
16622
+ accounts: [
16623
+ {
16624
+ name: "user",
16625
+ signer: true
16626
+ },
16627
+ {
16628
+ name: "dispute_config",
16629
+ pda: {
16630
+ seeds: [
16631
+ {
16632
+ kind: "const",
16633
+ value: [
16634
+ 100,
16635
+ 105,
16636
+ 115,
16637
+ 112,
16638
+ 117,
16639
+ 116,
16640
+ 101,
16641
+ 95,
16642
+ 99,
16643
+ 111,
16644
+ 110,
16645
+ 102,
16646
+ 105,
16647
+ 103
16648
+ ]
16649
+ },
16650
+ {
16651
+ kind: "account",
16652
+ path: "dispute_config.owner",
16653
+ account: "DisputeConfig"
16654
+ }
16655
+ ]
16656
+ }
16657
+ },
16658
+ {
16659
+ name: "dispute_market",
16660
+ pda: {
16661
+ seeds: [
16662
+ {
16663
+ kind: "const",
16664
+ value: [
16665
+ 100,
16666
+ 105,
16667
+ 115,
16668
+ 112,
16669
+ 117,
16670
+ 116,
16671
+ 101,
16672
+ 95,
16673
+ 109,
16674
+ 97,
16675
+ 114,
16676
+ 107,
16677
+ 101,
16678
+ 116
16679
+ ]
16680
+ },
16681
+ {
16682
+ kind: "arg",
16683
+ path: "condition_id"
16684
+ }
16685
+ ]
16686
+ }
16687
+ },
16688
+ {
16689
+ name: "user_dispute",
16690
+ writable: true,
16691
+ pda: {
16692
+ seeds: [
16693
+ {
16694
+ kind: "const",
16695
+ value: [
16696
+ 117,
16697
+ 115,
16698
+ 101,
16699
+ 114,
16700
+ 95,
16701
+ 100,
16702
+ 105,
16703
+ 115,
16704
+ 112,
16705
+ 117,
16706
+ 116,
16707
+ 101
16708
+ ]
16709
+ },
16710
+ {
16711
+ kind: "account",
16712
+ path: "user"
16713
+ },
16714
+ {
16715
+ kind: "arg",
16716
+ path: "condition_id"
16717
+ }
16718
+ ]
16719
+ }
16720
+ },
16721
+ {
16722
+ name: "dispute_vault",
16723
+ writable: true,
16724
+ pda: {
16725
+ seeds: [
16726
+ {
16727
+ kind: "account",
16728
+ path: "dispute_config"
16729
+ },
16730
+ {
16731
+ kind: "const",
16732
+ value: [
16733
+ 6,
16734
+ 221,
16735
+ 246,
16736
+ 225,
16737
+ 215,
16738
+ 101,
16739
+ 161,
16740
+ 147,
16741
+ 217,
16742
+ 203,
16743
+ 225,
16744
+ 70,
16745
+ 206,
16746
+ 235,
16747
+ 121,
16748
+ 172,
16749
+ 28,
16750
+ 180,
16751
+ 133,
16752
+ 237,
16753
+ 95,
16754
+ 91,
16755
+ 55,
16756
+ 145,
16757
+ 58,
16758
+ 140,
16759
+ 245,
16760
+ 133,
16761
+ 126,
16762
+ 255,
16763
+ 0,
16764
+ 169
16765
+ ]
16766
+ },
16767
+ {
16768
+ kind: "account",
16769
+ path: "dispute_config.collateral_mint",
16770
+ account: "DisputeConfig"
16771
+ }
16772
+ ],
16773
+ program: {
16774
+ kind: "const",
16775
+ value: [
16776
+ 140,
16777
+ 151,
16778
+ 37,
16779
+ 143,
16780
+ 78,
16781
+ 36,
16782
+ 137,
16783
+ 241,
16784
+ 187,
16785
+ 61,
16786
+ 16,
16787
+ 41,
16788
+ 20,
16789
+ 142,
16790
+ 13,
16791
+ 131,
16792
+ 11,
16793
+ 90,
16794
+ 19,
16795
+ 153,
16796
+ 218,
16797
+ 255,
16798
+ 16,
16799
+ 132,
16800
+ 4,
16801
+ 142,
16802
+ 123,
16803
+ 216,
16804
+ 219,
16805
+ 233,
16806
+ 248,
16807
+ 89
16808
+ ]
16809
+ }
16810
+ }
16811
+ },
16812
+ {
16813
+ name: "user_ata",
16814
+ writable: true
16815
+ },
16816
+ {
16817
+ name: "token_program",
16818
+ address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
16819
+ }
16820
+ ],
16821
+ args: [
16822
+ {
16823
+ name: "condition_id",
16824
+ type: {
16825
+ array: [
16826
+ "u8",
16827
+ 32
16828
+ ]
16829
+ }
16830
+ }
16831
+ ]
16832
+ },
16833
+ {
16834
+ name: "initialize",
16835
+ discriminator: [
16836
+ 175,
16837
+ 175,
16838
+ 109,
16839
+ 31,
16840
+ 13,
16841
+ 152,
16842
+ 155,
16843
+ 237
16844
+ ],
16845
+ accounts: [
16846
+ {
16847
+ name: "owner",
16848
+ writable: true,
16849
+ signer: true
16850
+ },
16851
+ {
16852
+ name: "dispute_config",
16853
+ writable: true,
16854
+ pda: {
16855
+ seeds: [
16856
+ {
16857
+ kind: "const",
16858
+ value: [
16859
+ 100,
16860
+ 105,
16861
+ 115,
16862
+ 112,
16863
+ 117,
16864
+ 116,
16865
+ 101,
16866
+ 95,
16867
+ 99,
16868
+ 111,
16869
+ 110,
16870
+ 102,
16871
+ 105,
16872
+ 103
16873
+ ]
16874
+ },
16875
+ {
16876
+ kind: "account",
16877
+ path: "owner"
16878
+ }
16879
+ ]
16880
+ }
16881
+ },
16882
+ {
16883
+ name: "collateral_mint"
16884
+ },
16885
+ {
16886
+ name: "dispute_vault",
16887
+ docs: [
16888
+ "ATA owned by dispute_config PDA \u2014 holds USDS bonds from all dispute raisers"
16889
+ ],
16890
+ writable: true,
16891
+ pda: {
16892
+ seeds: [
16893
+ {
16894
+ kind: "account",
16895
+ path: "dispute_config"
16896
+ },
16897
+ {
16898
+ kind: "const",
16899
+ value: [
16900
+ 6,
16901
+ 221,
16902
+ 246,
16903
+ 225,
16904
+ 215,
16905
+ 101,
16906
+ 161,
16907
+ 147,
16908
+ 217,
16909
+ 203,
16910
+ 225,
16911
+ 70,
16912
+ 206,
16913
+ 235,
16914
+ 121,
16915
+ 172,
16916
+ 28,
16917
+ 180,
16918
+ 133,
16919
+ 237,
16920
+ 95,
16921
+ 91,
16922
+ 55,
16923
+ 145,
16924
+ 58,
16925
+ 140,
16926
+ 245,
16927
+ 133,
16928
+ 126,
16929
+ 255,
16930
+ 0,
16931
+ 169
16932
+ ]
16933
+ },
16934
+ {
16935
+ kind: "account",
16936
+ path: "collateral_mint"
16937
+ }
16938
+ ],
16939
+ program: {
16940
+ kind: "const",
16941
+ value: [
16942
+ 140,
16943
+ 151,
16944
+ 37,
16945
+ 143,
16946
+ 78,
16947
+ 36,
16948
+ 137,
16949
+ 241,
16950
+ 187,
16951
+ 61,
16952
+ 16,
16953
+ 41,
16954
+ 20,
16955
+ 142,
16956
+ 13,
16957
+ 131,
16958
+ 11,
16959
+ 90,
16960
+ 19,
16961
+ 153,
16962
+ 218,
16963
+ 255,
16964
+ 16,
16965
+ 132,
16966
+ 4,
16967
+ 142,
16968
+ 123,
16969
+ 216,
16970
+ 219,
16971
+ 233,
16972
+ 248,
16973
+ 89
16974
+ ]
16975
+ }
16976
+ }
16977
+ },
16978
+ {
16979
+ name: "token_program",
16980
+ address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
16981
+ },
16982
+ {
16983
+ name: "associated_token_program",
16984
+ address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
16985
+ },
16986
+ {
16987
+ name: "system_program",
16988
+ address: "11111111111111111111111111111111"
16989
+ }
16990
+ ],
16991
+ args: []
16992
+ },
16993
+ {
16994
+ name: "raise_dispute",
16995
+ discriminator: [
16996
+ 41,
16997
+ 243,
16998
+ 1,
16999
+ 51,
17000
+ 150,
17001
+ 95,
17002
+ 246,
17003
+ 73
17004
+ ],
17005
+ accounts: [
17006
+ {
17007
+ name: "user",
17008
+ signer: true
17009
+ },
17010
+ {
17011
+ name: "payer",
17012
+ writable: true,
17013
+ signer: true
17014
+ },
17015
+ {
17016
+ name: "dispute_config",
17017
+ pda: {
17018
+ seeds: [
17019
+ {
17020
+ kind: "const",
17021
+ value: [
17022
+ 100,
17023
+ 105,
17024
+ 115,
17025
+ 112,
17026
+ 117,
17027
+ 116,
17028
+ 101,
17029
+ 95,
17030
+ 99,
17031
+ 111,
17032
+ 110,
17033
+ 102,
17034
+ 105,
17035
+ 103
17036
+ ]
17037
+ },
17038
+ {
17039
+ kind: "account",
17040
+ path: "dispute_config.owner",
17041
+ account: "DisputeConfig"
17042
+ }
17043
+ ]
17044
+ }
17045
+ },
17046
+ {
17047
+ name: "dispute_market",
17048
+ writable: true,
17049
+ pda: {
17050
+ seeds: [
17051
+ {
17052
+ kind: "const",
17053
+ value: [
17054
+ 100,
17055
+ 105,
17056
+ 115,
17057
+ 112,
17058
+ 117,
17059
+ 116,
17060
+ 101,
17061
+ 95,
17062
+ 109,
17063
+ 97,
17064
+ 114,
17065
+ 107,
17066
+ 101,
17067
+ 116
17068
+ ]
17069
+ },
17070
+ {
17071
+ kind: "arg",
17072
+ path: "condition_id"
17073
+ }
17074
+ ]
17075
+ }
17076
+ },
17077
+ {
17078
+ name: "user_dispute",
17079
+ writable: true,
17080
+ pda: {
17081
+ seeds: [
17082
+ {
17083
+ kind: "const",
17084
+ value: [
17085
+ 117,
17086
+ 115,
17087
+ 101,
17088
+ 114,
17089
+ 95,
17090
+ 100,
17091
+ 105,
17092
+ 115,
17093
+ 112,
17094
+ 117,
17095
+ 116,
17096
+ 101
17097
+ ]
17098
+ },
17099
+ {
17100
+ kind: "account",
17101
+ path: "user"
17102
+ },
17103
+ {
17104
+ kind: "arg",
17105
+ path: "condition_id"
17106
+ }
17107
+ ]
17108
+ }
17109
+ },
17110
+ {
17111
+ name: "user_ata",
17112
+ writable: true,
17113
+ pda: {
17114
+ seeds: [
17115
+ {
17116
+ kind: "account",
17117
+ path: "user"
17118
+ },
17119
+ {
17120
+ kind: "const",
17121
+ value: [
17122
+ 6,
17123
+ 221,
17124
+ 246,
17125
+ 225,
17126
+ 215,
17127
+ 101,
17128
+ 161,
17129
+ 147,
17130
+ 217,
17131
+ 203,
17132
+ 225,
17133
+ 70,
17134
+ 206,
17135
+ 235,
17136
+ 121,
17137
+ 172,
17138
+ 28,
17139
+ 180,
17140
+ 133,
17141
+ 237,
17142
+ 95,
17143
+ 91,
17144
+ 55,
17145
+ 145,
17146
+ 58,
17147
+ 140,
17148
+ 245,
17149
+ 133,
17150
+ 126,
17151
+ 255,
17152
+ 0,
17153
+ 169
17154
+ ]
17155
+ },
17156
+ {
17157
+ kind: "account",
17158
+ path: "dispute_config.collateral_mint",
17159
+ account: "DisputeConfig"
17160
+ }
17161
+ ],
17162
+ program: {
17163
+ kind: "const",
17164
+ value: [
17165
+ 140,
17166
+ 151,
17167
+ 37,
17168
+ 143,
17169
+ 78,
17170
+ 36,
17171
+ 137,
17172
+ 241,
17173
+ 187,
17174
+ 61,
17175
+ 16,
17176
+ 41,
17177
+ 20,
17178
+ 142,
17179
+ 13,
17180
+ 131,
17181
+ 11,
17182
+ 90,
17183
+ 19,
17184
+ 153,
17185
+ 218,
17186
+ 255,
17187
+ 16,
17188
+ 132,
17189
+ 4,
17190
+ 142,
17191
+ 123,
17192
+ 216,
17193
+ 219,
17194
+ 233,
17195
+ 248,
17196
+ 89
17197
+ ]
17198
+ }
17199
+ }
17200
+ },
17201
+ {
17202
+ name: "dispute_vault",
17203
+ writable: true,
17204
+ pda: {
17205
+ seeds: [
17206
+ {
17207
+ kind: "account",
17208
+ path: "dispute_config"
17209
+ },
17210
+ {
17211
+ kind: "const",
17212
+ value: [
17213
+ 6,
17214
+ 221,
17215
+ 246,
17216
+ 225,
17217
+ 215,
17218
+ 101,
17219
+ 161,
17220
+ 147,
17221
+ 217,
17222
+ 203,
17223
+ 225,
17224
+ 70,
17225
+ 206,
17226
+ 235,
17227
+ 121,
17228
+ 172,
17229
+ 28,
17230
+ 180,
17231
+ 133,
17232
+ 237,
17233
+ 95,
17234
+ 91,
17235
+ 55,
17236
+ 145,
17237
+ 58,
17238
+ 140,
17239
+ 245,
17240
+ 133,
17241
+ 126,
17242
+ 255,
17243
+ 0,
17244
+ 169
17245
+ ]
17246
+ },
17247
+ {
17248
+ kind: "account",
17249
+ path: "dispute_config.collateral_mint",
17250
+ account: "DisputeConfig"
17251
+ }
17252
+ ],
17253
+ program: {
17254
+ kind: "const",
17255
+ value: [
17256
+ 140,
17257
+ 151,
17258
+ 37,
17259
+ 143,
17260
+ 78,
17261
+ 36,
17262
+ 137,
17263
+ 241,
17264
+ 187,
17265
+ 61,
17266
+ 16,
17267
+ 41,
17268
+ 20,
17269
+ 142,
17270
+ 13,
17271
+ 131,
17272
+ 11,
17273
+ 90,
17274
+ 19,
17275
+ 153,
17276
+ 218,
17277
+ 255,
17278
+ 16,
17279
+ 132,
17280
+ 4,
17281
+ 142,
17282
+ 123,
17283
+ 216,
17284
+ 219,
17285
+ 233,
17286
+ 248,
17287
+ 89
17288
+ ]
17289
+ }
17290
+ }
17291
+ },
17292
+ {
17293
+ name: "token_program",
17294
+ address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
17295
+ },
17296
+ {
17297
+ name: "associated_token_program",
17298
+ address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
17299
+ },
17300
+ {
17301
+ name: "system_program",
17302
+ address: "11111111111111111111111111111111"
17303
+ }
17304
+ ],
17305
+ args: [
17306
+ {
17307
+ name: "condition_id",
17308
+ type: {
17309
+ array: [
17310
+ "u8",
17311
+ 32
17312
+ ]
17313
+ }
17314
+ }
17315
+ ]
17316
+ },
17317
+ {
17318
+ name: "resolve_dispute",
17319
+ discriminator: [
17320
+ 231,
17321
+ 6,
17322
+ 202,
17323
+ 6,
17324
+ 96,
17325
+ 103,
17326
+ 12,
17327
+ 230
17328
+ ],
17329
+ accounts: [
17330
+ {
17331
+ name: "admin",
17332
+ signer: true
17333
+ },
17334
+ {
17335
+ name: "dispute_config",
17336
+ pda: {
17337
+ seeds: [
17338
+ {
17339
+ kind: "const",
17340
+ value: [
17341
+ 100,
17342
+ 105,
17343
+ 115,
17344
+ 112,
17345
+ 117,
17346
+ 116,
17347
+ 101,
17348
+ 95,
17349
+ 99,
17350
+ 111,
17351
+ 110,
17352
+ 102,
17353
+ 105,
17354
+ 103
17355
+ ]
17356
+ },
17357
+ {
17358
+ kind: "account",
17359
+ path: "dispute_config.owner",
17360
+ account: "DisputeConfig"
17361
+ }
17362
+ ]
17363
+ }
17364
+ },
17365
+ {
17366
+ name: "dispute_market",
17367
+ writable: true,
17368
+ pda: {
17369
+ seeds: [
17370
+ {
17371
+ kind: "const",
17372
+ value: [
17373
+ 100,
17374
+ 105,
17375
+ 115,
17376
+ 112,
17377
+ 117,
17378
+ 116,
17379
+ 101,
17380
+ 95,
17381
+ 109,
17382
+ 97,
17383
+ 114,
17384
+ 107,
17385
+ 101,
17386
+ 116
17387
+ ]
17388
+ },
17389
+ {
17390
+ kind: "arg",
17391
+ path: "condition_id"
17392
+ }
17393
+ ]
17394
+ }
17395
+ }
17396
+ ],
17397
+ args: [
17398
+ {
17399
+ name: "condition_id",
17400
+ type: {
17401
+ array: [
17402
+ "u8",
17403
+ 32
17404
+ ]
17405
+ }
17406
+ },
17407
+ {
17408
+ name: "amount",
17409
+ type: "u64"
17410
+ },
17411
+ {
17412
+ name: "is_refunded",
17413
+ type: "bool"
17414
+ }
17415
+ ]
17416
+ },
17417
+ {
17418
+ name: "set_admin",
17419
+ discriminator: [
17420
+ 251,
17421
+ 163,
17422
+ 0,
17423
+ 52,
17424
+ 91,
17425
+ 194,
17426
+ 187,
17427
+ 92
17428
+ ],
17429
+ accounts: [
17430
+ {
17431
+ name: "owner",
17432
+ signer: true
17433
+ },
17434
+ {
17435
+ name: "dispute_config",
17436
+ writable: true,
17437
+ pda: {
17438
+ seeds: [
17439
+ {
17440
+ kind: "const",
17441
+ value: [
17442
+ 100,
17443
+ 105,
17444
+ 115,
17445
+ 112,
17446
+ 117,
17447
+ 116,
17448
+ 101,
17449
+ 95,
17450
+ 99,
17451
+ 111,
17452
+ 110,
17453
+ 102,
17454
+ 105,
17455
+ 103
17456
+ ]
17457
+ },
17458
+ {
17459
+ kind: "account",
17460
+ path: "owner"
17461
+ }
17462
+ ]
17463
+ }
17464
+ }
17465
+ ],
17466
+ args: [
17467
+ {
17468
+ name: "new_admin",
17469
+ type: "pubkey"
17470
+ }
17471
+ ]
17472
+ }
17473
+ ],
17474
+ accounts: [
17475
+ {
17476
+ name: "DisputeConfig",
17477
+ discriminator: [
17478
+ 230,
17479
+ 88,
17480
+ 200,
17481
+ 99,
17482
+ 12,
17483
+ 93,
17484
+ 56,
17485
+ 156
17486
+ ]
17487
+ },
17488
+ {
17489
+ name: "DisputeMarket",
17490
+ discriminator: [
17491
+ 235,
17492
+ 222,
17493
+ 113,
17494
+ 250,
17495
+ 83,
17496
+ 196,
17497
+ 239,
17498
+ 159
17499
+ ]
17500
+ },
17501
+ {
17502
+ name: "UserDispute",
17503
+ discriminator: [
17504
+ 54,
17505
+ 252,
17506
+ 42,
17507
+ 67,
17508
+ 211,
17509
+ 11,
17510
+ 192,
17511
+ 188
17512
+ ]
17513
+ }
17514
+ ],
17515
+ types: [
17516
+ {
17517
+ name: "DisputeConfig",
17518
+ type: {
17519
+ kind: "struct",
17520
+ fields: [
17521
+ {
17522
+ name: "version",
17523
+ type: "u8"
17524
+ },
17525
+ {
17526
+ name: "owner",
17527
+ type: "pubkey"
17528
+ },
17529
+ {
17530
+ name: "admin",
17531
+ type: "pubkey"
17532
+ },
17533
+ {
17534
+ name: "collateral_mint",
17535
+ type: "pubkey"
17536
+ },
17537
+ {
17538
+ name: "bump",
17539
+ type: "u8"
17540
+ }
17541
+ ]
17542
+ }
17543
+ },
17544
+ {
17545
+ name: "DisputeMarket",
17546
+ type: {
17547
+ kind: "struct",
17548
+ fields: [
17549
+ {
17550
+ name: "version",
17551
+ type: "u8"
17552
+ },
17553
+ {
17554
+ name: "condition_id",
17555
+ type: {
17556
+ array: [
17557
+ "u8",
17558
+ 32
17559
+ ]
17560
+ }
17561
+ },
17562
+ {
17563
+ name: "deadline",
17564
+ type: "i64"
17565
+ },
17566
+ {
17567
+ name: "bond",
17568
+ type: "u64"
17569
+ },
17570
+ {
17571
+ name: "amount",
17572
+ type: "u64"
17573
+ },
17574
+ {
17575
+ name: "is_resolved",
17576
+ type: "bool"
17577
+ },
17578
+ {
17579
+ name: "bump",
17580
+ type: "u8"
17581
+ }
17582
+ ]
17583
+ }
17584
+ },
17585
+ {
17586
+ name: "UserDispute",
17587
+ type: {
17588
+ kind: "struct",
17589
+ fields: [
17590
+ {
17591
+ name: "version",
17592
+ type: "u8"
17593
+ },
17594
+ {
17595
+ name: "user",
17596
+ type: "pubkey"
17597
+ },
17598
+ {
17599
+ name: "condition_id",
17600
+ type: {
17601
+ array: [
17602
+ "u8",
17603
+ 32
17604
+ ]
17605
+ }
17606
+ },
17607
+ {
17608
+ name: "amount",
17609
+ type: "u64"
17610
+ },
17611
+ {
17612
+ name: "bump",
17613
+ type: "u8"
17614
+ }
17615
+ ]
17616
+ }
17617
+ }
17618
+ ]
17619
+ };
17620
+
17621
+ // src/sdk.ts
17622
+ var XMarketSDK = class {
17623
+ constructor(config, wallet, marketOwner) {
17624
+ this.networkConfig = config;
17625
+ this.provider = new anchor5.AnchorProvider(
17626
+ new Connection(config.rpcUrl, "confirmed"),
17627
+ wallet,
17628
+ { commitment: "confirmed", preflightCommitment: "confirmed" }
17629
+ );
17630
+ anchor5.setProvider(this.provider);
17631
+ this._programIds = config.programIds;
17632
+ this._marketOwner = marketOwner ?? wallet.publicKey;
17633
+ }
17634
+ _withAddress(idl, address) {
17635
+ return { ...idl, address: address.toBase58() };
17636
+ }
17637
+ get oracle() {
17638
+ if (!this._oracle) {
17639
+ const program = new anchor5.Program(this._withAddress(oracle_default, this._programIds.oracle), this.provider);
17640
+ this._oracle = new OracleClient(program, this.provider, this._programIds);
17641
+ }
17642
+ return this._oracle;
17643
+ }
17644
+ get hook() {
17645
+ if (!this._hook) {
17646
+ const program = new anchor5.Program(this._withAddress(hook_default, this._programIds.hook), this.provider);
17647
+ this._hook = new HookClient(program, this.provider, this._programIds);
17648
+ }
17649
+ return this._hook;
17650
+ }
17651
+ get market() {
17652
+ if (!this._market) {
17653
+ const program = new anchor5.Program(this._withAddress(question_market_default, this._programIds.questionMarket), this.provider);
17654
+ this._market = new MarketClient(program, this.provider, this._programIds, this._marketOwner);
17655
+ this._market.ctfClient = this.ctf;
17656
+ this._market.feeConfigOwner = this.networkConfig.feeConfigOwner ?? this._marketOwner;
17657
+ }
17658
+ return this._market;
17659
+ }
17660
+ get ctf() {
17661
+ if (!this._ctf) {
17662
+ const program = new anchor5.Program(this._withAddress(conditional_tokens_default, this._programIds.conditionalTokens), this.provider);
17663
+ this._ctf = new CtfClient(program, this.provider, this._programIds);
17664
+ }
17665
+ return this._ctf;
17666
+ }
17667
+ get clob() {
17668
+ if (!this._clob) {
17669
+ const program = new anchor5.Program(this._withAddress(clob_exchange_default, this._programIds.clobExchange), this.provider);
17670
+ this._clob = new ClobClient(program, this.provider, this._programIds, this.networkConfig);
17671
+ if (this.networkConfig.feeConfigOwner && this._programIds.feeManagement) {
17672
+ this._clob.feeConfigOwner = this.networkConfig.feeConfigOwner;
17673
+ this._clob.feeClient = this.fee;
17674
+ }
17675
+ this._clob.ctfClient = this.ctf;
17676
+ this._clob.qmConfigPda = this.market.configPda;
17677
+ this._clob.hookClient = this.hook;
17678
+ }
17679
+ return this._clob;
17680
+ }
17681
+ get fee() {
17682
+ if (!this._fee) {
17683
+ if (!this._programIds.feeManagement) throw new Error("feeManagement program ID not configured in NetworkConfig");
17684
+ const program = new anchor5.Program(this._withAddress(fee_management_default, this._programIds.feeManagement), this.provider);
17685
+ this._fee = new FeeManagementClient(program, this.provider, this._programIds);
17686
+ }
17687
+ return this._fee;
17688
+ }
17689
+ get presale() {
17690
+ if (!this._presale) {
17691
+ if (!this._programIds.presale) throw new Error("presale program ID not configured in NetworkConfig");
17692
+ const program = new anchor5.Program(this._withAddress(presale_default, this._programIds.presale), this.provider);
17693
+ this._presale = new PresaleClient(program, this.provider, this._programIds);
17694
+ }
17695
+ return this._presale;
17696
+ }
17697
+ get marketOracle() {
17698
+ if (!this._marketOracle) {
17699
+ if (!this._programIds.marketOracle) throw new Error("marketOracle program ID not configured in NetworkConfig");
17700
+ const program = new anchor5.Program(this._withAddress(market_oracle_default, this._programIds.marketOracle), this.provider);
17701
+ this._marketOracle = new MarketOracleClient(program, this.provider, this._programIds);
17702
+ }
17703
+ return this._marketOracle;
17704
+ }
17705
+ get admin() {
17706
+ if (!this._admin) {
17707
+ if (!this._programIds.adminContract) throw new Error("adminContract program ID not configured in NetworkConfig");
17708
+ const program = new anchor5.Program(this._withAddress(admin_contract_default, this._programIds.adminContract), this.provider);
17709
+ this._admin = new AdminClient(program, this.provider, this._programIds);
17710
+ }
17711
+ return this._admin;
17712
+ }
17713
+ get referral() {
17714
+ if (!this._referral) {
17715
+ if (!this._programIds.referral) throw new Error("referral program ID not configured in NetworkConfig");
17716
+ const program = new anchor5.Program(this._withAddress(referral_default, this._programIds.referral), this.provider);
17717
+ this._referral = new ReferralClient(program, this.provider, this._programIds);
17718
+ }
17719
+ return this._referral;
17720
+ }
17721
+ get dispute() {
17722
+ if (!this._dispute) {
17723
+ if (!this._programIds.dispute) throw new Error("dispute program ID not configured in NetworkConfig");
17724
+ const program = new anchor5.Program(this._withAddress(dispute_default, this._programIds.dispute), this.provider);
17725
+ this._dispute = new DisputeClient(program, this.provider, this._programIds);
17726
+ }
17727
+ return this._dispute;
16542
17728
  }
16543
17729
  };
16544
17730
  var MAX_APPROVE_AMOUNT = new BN4("18446744073709551615");
@@ -16612,6 +17798,6 @@ function buildApproveAllOutcomeTokensTx(condition, signer, payer, delegate, prog
16612
17798
  return tx;
16613
17799
  }
16614
17800
 
16615
- export { AccountNotFoundError, AdminClient, ClobClient, CtfClient, FEE_DENOMINATOR, FeeManagementClient, HookClient, IX_SYSVAR, InvalidParamError, MAX_APPROVE_AMOUNT, MarketClient, MarketOracleClient, OracleClient, PDA, PresaleClient, QuestionStatus, ReferralClient, SEEDS, UnauthorizedError, XMarketError, XMarketSDK, buildApproveAllOutcomeTokensTx, buildApproveCollateralTx, buildBatchedCollectFeeEd25519Instruction, buildBatchedEd25519Instruction, buildCreateUserAtasTx, buildOrder, buildOrderFromPrice, deserializeSignedOrder, detectMatchType, generateContentHash, generateQuestionId, getOrderSignBytes, orderAmountsFromPrice, serializeCollectFeeOrderToBytes, serializeOrderToBytes, serializeSignedOrder, signOrder, signOrderWithKeypair, verifySignedOrder };
17801
+ export { AccountNotFoundError, AdminClient, ClobClient, CtfClient, DisputeClient, FEE_DENOMINATOR, FeeManagementClient, HookClient, IX_SYSVAR, InvalidParamError, MAX_APPROVE_AMOUNT, MarketClient, MarketOracleClient, OracleClient, PDA, PresaleClient, QuestionStatus, ReferralClient, SEEDS, UnauthorizedError, XMarketError, XMarketSDK, buildApproveAllOutcomeTokensTx, buildApproveCollateralTx, buildBatchedCollectFeeEd25519Instruction, buildBatchedEd25519Instruction, buildCreateUserAtasTx, buildOrder, buildOrderFromPrice, deserializeSignedOrder, detectMatchType, generateContentHash, generateQuestionId, getOrderSignBytes, orderAmountsFromPrice, serializeCollectFeeOrderToBytes, serializeOrderToBytes, serializeSignedOrder, signOrder, signOrderWithKeypair, verifySignedOrder };
16616
17802
  //# sourceMappingURL=index.mjs.map
16617
17803
  //# sourceMappingURL=index.mjs.map