@theliem/xmarket-sdk 3.25.0 → 3.26.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
@@ -169,6 +169,14 @@ var PDA = class {
169
169
  programIds.clobExchange
170
170
  );
171
171
  }
172
+ static redeemFeeOrderRecord(user, nonce, programIds) {
173
+ const nonceBuf = Buffer.alloc(8);
174
+ nonceBuf.writeBigUInt64LE(BigInt(nonce.toString()));
175
+ return PublicKey.findProgramAddressSync(
176
+ [Buffer.from("redeem_fee_order"), user.toBuffer(), nonceBuf],
177
+ programIds.clobExchange
178
+ );
179
+ }
172
180
  // ─── Fee Management ─────────────────────────────────────────────────────────
173
181
  static feeConfig(owner, programIds) {
174
182
  if (!programIds.feeManagement) throw new Error("feeManagement program ID not configured");
@@ -1478,6 +1486,50 @@ function buildBatchedCollectFeeEd25519Instruction(orders) {
1478
1486
  data
1479
1487
  });
1480
1488
  }
1489
+ function serializeRedeemFeeOrderToBytes(order) {
1490
+ const buf = new Uint8Array(128);
1491
+ buf.set(order.user.toBytes(), 0);
1492
+ buf.set(order.condition.toBytes(), 32);
1493
+ buf.set(order.tokenMint.toBytes(), 64);
1494
+ buf.set(order.amount.toArrayLike(Buffer, "le", 8), 96);
1495
+ buf.set(order.takerAmount.toArrayLike(Buffer, "le", 8), 104);
1496
+ buf.set(order.nonce.toArrayLike(Buffer, "le", 8), 112);
1497
+ buf.set(order.expiry.toArrayLike(Buffer, "le", 8), 120);
1498
+ return buf;
1499
+ }
1500
+ function buildBatchedRedeemFeeEd25519Instruction(orders) {
1501
+ const N = orders.length;
1502
+ if (N === 0) throw new Error("At least 1 order required");
1503
+ const MSG_SIZE = 128;
1504
+ const SIG_SIZE = 64;
1505
+ const PK_SIZE = 32;
1506
+ const HEADER = 2 + N * 14;
1507
+ const sigBase = HEADER;
1508
+ const pkBase = sigBase + N * SIG_SIZE;
1509
+ const msgBase = pkBase + N * PK_SIZE;
1510
+ const totalSize = msgBase + N * MSG_SIZE;
1511
+ const data = Buffer.alloc(totalSize);
1512
+ data[0] = N;
1513
+ data[1] = 0;
1514
+ for (let i = 0; i < N; i++) {
1515
+ const e = 2 + i * 14;
1516
+ data.writeUInt16LE(sigBase + i * SIG_SIZE, e);
1517
+ data.writeUInt16LE(65535, e + 2);
1518
+ data.writeUInt16LE(pkBase + i * PK_SIZE, e + 4);
1519
+ data.writeUInt16LE(65535, e + 6);
1520
+ data.writeUInt16LE(msgBase + i * MSG_SIZE, e + 8);
1521
+ data.writeUInt16LE(MSG_SIZE, e + 10);
1522
+ data.writeUInt16LE(65535, e + 12);
1523
+ data.set(orders[i].signature, sigBase + i * SIG_SIZE);
1524
+ data.set(orders[i].order.user.toBytes(), pkBase + i * PK_SIZE);
1525
+ data.set(serializeRedeemFeeOrderToBytes(orders[i].order), msgBase + i * MSG_SIZE);
1526
+ }
1527
+ return new TransactionInstruction({
1528
+ keys: [],
1529
+ programId: Ed25519Program.programId,
1530
+ data
1531
+ });
1532
+ }
1481
1533
  function buildOrder(params) {
1482
1534
  return {
1483
1535
  maker: params.maker,
@@ -2723,6 +2775,236 @@ ${logs.join("\n")}`);
2723
2775
  const alt = opts?.lookupTable ?? await this.buildAltForCollectBatch(condition, payer, collateralMint, signedOrders, outcomeIndex);
2724
2776
  return this._buildUnsignedVtx([...hookInitIxs, collectIx], alt, payer);
2725
2777
  }
2778
+ // ─── Register RedeemFeeOrder ─────────────────────────────────────────────────
2779
+ /**
2780
+ * Build a Transaction to register a RedeemFeeOrder on-chain (Ed25519 verify + PDA).
2781
+ * Must be sent before calling buildBatchRedeemWithFeeTx / buildBatchMergeWithFeeTx.
2782
+ *
2783
+ * ix[0]: batched Ed25519 { pubkey=order.user, sig, msg=128 bytes }
2784
+ * ix[1]: register_redeem_fee_order(nonce)
2785
+ */
2786
+ async buildRegisterRedeemFeeOrderTx(signedOrder, payer) {
2787
+ const { order } = signedOrder;
2788
+ const [redeemFeeOrderRecord] = PDA.redeemFeeOrderRecord(order.user, order.nonce, this.programIds);
2789
+ const ed25519Ix = buildBatchedRedeemFeeEd25519Instruction([signedOrder]);
2790
+ const registerIx = await this.program.methods.registerRedeemFeeOrder(order.nonce).accounts({
2791
+ payer,
2792
+ clobConfig: this.configPda(),
2793
+ ixSysvar: IX_SYSVAR,
2794
+ orderSigner: order.user,
2795
+ redeemFeeOrderRecord,
2796
+ systemProgram: anchor5.web3.SystemProgram.programId
2797
+ }).instruction();
2798
+ const tx = new anchor5.web3.Transaction();
2799
+ tx.add(ed25519Ix, registerIx);
2800
+ return tx;
2801
+ }
2802
+ // ─── batchRedeemWithFee ───────────────────────────────────────────────────────
2803
+ /**
2804
+ * Build a VersionedTransaction for batchRedeemWithFee.
2805
+ * Each pair has a YES order + NO order for the same user (same signer or different).
2806
+ * After resolution: YES holder taker_amount > 0, NO holder taker_amount = 0 (or vice versa).
2807
+ *
2808
+ * Prerequisite: each order's RedeemFeeOrderRecord must be registered via buildRegisterRedeemFeeOrderTx.
2809
+ */
2810
+ async buildBatchRedeemWithFeeTx(orderPairs, condition, operator, payer, opts) {
2811
+ if (orderPairs.length === 0) throw new InvalidParamError("At least 1 order pair required");
2812
+ const collateralMint = this.networkConfig.defaultCollateral.mint;
2813
+ const cfg = await this.fetchConfig();
2814
+ if (!cfg) throw new InvalidParamError("CLOB config not found on-chain");
2815
+ const clobConfig = this.configPda();
2816
+ const [yesMint] = PDA.yesMint(condition, this.programIds);
2817
+ const [noMint] = PDA.noMint(condition, this.programIds);
2818
+ const [collateralVault] = PDA.collateralVault(collateralMint, this.programIds);
2819
+ const [vaultTokenAccount] = PDA.vaultToken(collateralMint, this.programIds);
2820
+ const [yesExtraMeta] = PDA.extraAccountMetaList(yesMint, this.programIds);
2821
+ const [noExtraMeta] = PDA.extraAccountMetaList(noMint, this.programIds);
2822
+ const [hookConfig] = PDA.hookConfig(this.programIds);
2823
+ const [clobYesPosition] = PDA.position(condition, 1, clobConfig, this.programIds);
2824
+ const [clobNoPosition] = PDA.position(condition, 0, clobConfig, this.programIds);
2825
+ const clobYesAta = getAssociatedTokenAddressSync(yesMint, clobConfig, true, TOKEN_2022_PROGRAM_ID);
2826
+ const clobNoAta = getAssociatedTokenAddressSync(noMint, clobConfig, true, TOKEN_2022_PROGRAM_ID);
2827
+ const userAccounts = [];
2828
+ for (const { yes, no } of orderPairs) {
2829
+ const [yesRecord] = PDA.redeemFeeOrderRecord(yes.order.user, yes.order.nonce, this.programIds);
2830
+ const [noRecord] = PDA.redeemFeeOrderRecord(no.order.user, no.order.nonce, this.programIds);
2831
+ const userYesAta = getAssociatedTokenAddressSync(yesMint, yes.order.user, false, TOKEN_2022_PROGRAM_ID);
2832
+ const userNoAta = getAssociatedTokenAddressSync(noMint, no.order.user, false, TOKEN_2022_PROGRAM_ID);
2833
+ const [userYesPos] = PDA.position(condition, 1, yes.order.user, this.programIds);
2834
+ const [userNoPos] = PDA.position(condition, 0, no.order.user, this.programIds);
2835
+ const yesCollateral = getAssociatedTokenAddressSync(collateralMint, yes.order.user);
2836
+ const noCollateral = getAssociatedTokenAddressSync(collateralMint, no.order.user);
2837
+ userAccounts.push(
2838
+ { pubkey: yesRecord, isSigner: false, isWritable: true },
2839
+ { pubkey: noRecord, isSigner: false, isWritable: true },
2840
+ { pubkey: yes.order.user, isSigner: false, isWritable: false },
2841
+ { pubkey: no.order.user, isSigner: false, isWritable: false },
2842
+ { pubkey: userYesAta, isSigner: false, isWritable: true },
2843
+ { pubkey: userNoAta, isSigner: false, isWritable: true },
2844
+ { pubkey: userYesPos, isSigner: false, isWritable: true },
2845
+ { pubkey: userNoPos, isSigner: false, isWritable: true },
2846
+ { pubkey: yesCollateral, isSigner: false, isWritable: true },
2847
+ { pubkey: noCollateral, isSigner: false, isWritable: true }
2848
+ );
2849
+ }
2850
+ const hookAccounts = [
2851
+ { pubkey: yesExtraMeta, isSigner: false, isWritable: false },
2852
+ { pubkey: noExtraMeta, isSigner: false, isWritable: false },
2853
+ { pubkey: hookConfig, isSigner: false, isWritable: false },
2854
+ { pubkey: this.programIds.hook, isSigner: false, isWritable: false }
2855
+ ];
2856
+ let feeAccounts = [];
2857
+ if (this.programIds.feeManagement && this.feeConfigOwner) {
2858
+ const companyAddr = await this.companyAddress();
2859
+ const refVault = await this.referralVault();
2860
+ if (companyAddr && refVault) {
2861
+ const feeOverridePda = PDA.marketFeeOverride(condition, this.programIds)[0];
2862
+ const feeOverrideExists = await this.provider.connection.getAccountInfo(feeOverridePda);
2863
+ if (feeOverrideExists) {
2864
+ const oracleVault = opts?.marketOracleVault ?? await this.getMarketOracleVault(condition, collateralMint) ?? payer;
2865
+ feeAccounts = [
2866
+ { pubkey: this.programIds.feeManagement, isSigner: false, isWritable: false },
2867
+ { pubkey: PDA.feeConfig(this.feeConfigOwner, this.programIds)[0], isSigner: false, isWritable: false },
2868
+ { pubkey: feeOverridePda, isSigner: false, isWritable: false },
2869
+ { pubkey: getAssociatedTokenAddressSync(collateralMint, companyAddr), isSigner: false, isWritable: true },
2870
+ { pubkey: oracleVault, isSigner: false, isWritable: true },
2871
+ { pubkey: refVault, isSigner: false, isWritable: true }
2872
+ ];
2873
+ }
2874
+ }
2875
+ }
2876
+ await this._ensureClobOutcomeAtas(yesMint, noMint, clobConfig, clobYesAta, clobNoAta);
2877
+ const hookInitIxs = [];
2878
+ if (this.hookClient) {
2879
+ for (const mint of [yesMint, noMint]) {
2880
+ const ix = await this.hookClient.buildInitHookIxIfNeeded(mint, payer);
2881
+ if (ix) hookInitIxs.push(ix);
2882
+ }
2883
+ }
2884
+ const redeemIx = await this.program.methods.batchRedeemWithFee(orderPairs.length).accounts({
2885
+ operator,
2886
+ payer,
2887
+ clobConfig,
2888
+ condition,
2889
+ collateralVault,
2890
+ vaultTokenAccount,
2891
+ feeRecipient: cfg.feeRecipient,
2892
+ yesMint,
2893
+ noMint,
2894
+ clobYesAta,
2895
+ clobNoAta,
2896
+ clobYesPosition,
2897
+ clobNoPosition,
2898
+ conditionalTokensProgram: this.programIds.conditionalTokens,
2899
+ tokenProgram: TOKEN_PROGRAM_ID,
2900
+ token2022Program: TOKEN_2022_PROGRAM_ID,
2901
+ systemProgram: anchor5.web3.SystemProgram.programId
2902
+ }).remainingAccounts([...userAccounts, ...hookAccounts, ...feeAccounts]).instruction();
2903
+ const alt = opts?.lookupTable ?? await this.buildAltForCondition(condition, payer, collateralMint);
2904
+ return this._buildUnsignedVtx([...hookInitIxs, redeemIx], alt, payer);
2905
+ }
2906
+ // ─── batchMergeWithFee ────────────────────────────────────────────────────────
2907
+ /**
2908
+ * Build a VersionedTransaction for batchMergeWithFee (pre-resolution merge with fee).
2909
+ * Each pair: YES order + NO order with equal amounts for the same user.
2910
+ * Only yes_signer receives net USDS (mirrors EVM _matchMergeOrder).
2911
+ *
2912
+ * Prerequisite: each order's RedeemFeeOrderRecord must be registered via buildRegisterRedeemFeeOrderTx.
2913
+ */
2914
+ async buildBatchMergeWithFeeTx(orderPairs, condition, operator, payer, opts) {
2915
+ if (orderPairs.length === 0) throw new InvalidParamError("At least 1 order pair required");
2916
+ const collateralMint = this.networkConfig.defaultCollateral.mint;
2917
+ const cfg = await this.fetchConfig();
2918
+ if (!cfg) throw new InvalidParamError("CLOB config not found on-chain");
2919
+ const clobConfig = this.configPda();
2920
+ const [yesMint] = PDA.yesMint(condition, this.programIds);
2921
+ const [noMint] = PDA.noMint(condition, this.programIds);
2922
+ const [collateralVault] = PDA.collateralVault(collateralMint, this.programIds);
2923
+ const [vaultTokenAccount] = PDA.vaultToken(collateralMint, this.programIds);
2924
+ const [yesExtraMeta] = PDA.extraAccountMetaList(yesMint, this.programIds);
2925
+ const [noExtraMeta] = PDA.extraAccountMetaList(noMint, this.programIds);
2926
+ const [hookConfig] = PDA.hookConfig(this.programIds);
2927
+ const [clobYesPosition] = PDA.position(condition, 1, clobConfig, this.programIds);
2928
+ const [clobNoPosition] = PDA.position(condition, 0, clobConfig, this.programIds);
2929
+ const clobYesAta = getAssociatedTokenAddressSync(yesMint, clobConfig, true, TOKEN_2022_PROGRAM_ID);
2930
+ const clobNoAta = getAssociatedTokenAddressSync(noMint, clobConfig, true, TOKEN_2022_PROGRAM_ID);
2931
+ const userAccounts = [];
2932
+ for (const { yes, no } of orderPairs) {
2933
+ const [yesRecord] = PDA.redeemFeeOrderRecord(yes.order.user, yes.order.nonce, this.programIds);
2934
+ const [noRecord] = PDA.redeemFeeOrderRecord(no.order.user, no.order.nonce, this.programIds);
2935
+ const userYesAta = getAssociatedTokenAddressSync(yesMint, yes.order.user, false, TOKEN_2022_PROGRAM_ID);
2936
+ const userNoAta = getAssociatedTokenAddressSync(noMint, no.order.user, false, TOKEN_2022_PROGRAM_ID);
2937
+ const [userYesPos] = PDA.position(condition, 1, yes.order.user, this.programIds);
2938
+ const [userNoPos] = PDA.position(condition, 0, no.order.user, this.programIds);
2939
+ const yesCollateral = getAssociatedTokenAddressSync(collateralMint, yes.order.user);
2940
+ userAccounts.push(
2941
+ { pubkey: yesRecord, isSigner: false, isWritable: true },
2942
+ { pubkey: noRecord, isSigner: false, isWritable: true },
2943
+ { pubkey: yes.order.user, isSigner: false, isWritable: false },
2944
+ { pubkey: no.order.user, isSigner: false, isWritable: false },
2945
+ { pubkey: userYesAta, isSigner: false, isWritable: true },
2946
+ { pubkey: userNoAta, isSigner: false, isWritable: true },
2947
+ { pubkey: userYesPos, isSigner: false, isWritable: true },
2948
+ { pubkey: userNoPos, isSigner: false, isWritable: true },
2949
+ { pubkey: yesCollateral, isSigner: false, isWritable: true }
2950
+ );
2951
+ }
2952
+ const hookAccounts = [
2953
+ { pubkey: yesExtraMeta, isSigner: false, isWritable: false },
2954
+ { pubkey: noExtraMeta, isSigner: false, isWritable: false },
2955
+ { pubkey: hookConfig, isSigner: false, isWritable: false },
2956
+ { pubkey: this.programIds.hook, isSigner: false, isWritable: false }
2957
+ ];
2958
+ let feeAccounts = [];
2959
+ if (this.programIds.feeManagement && this.feeConfigOwner) {
2960
+ const companyAddr = await this.companyAddress();
2961
+ const refVault = await this.referralVault();
2962
+ if (companyAddr && refVault) {
2963
+ const feeOverridePda = PDA.marketFeeOverride(condition, this.programIds)[0];
2964
+ const feeOverrideExists = await this.provider.connection.getAccountInfo(feeOverridePda);
2965
+ if (feeOverrideExists) {
2966
+ const oracleVault = opts?.marketOracleVault ?? await this.getMarketOracleVault(condition, collateralMint) ?? payer;
2967
+ feeAccounts = [
2968
+ { pubkey: this.programIds.feeManagement, isSigner: false, isWritable: false },
2969
+ { pubkey: PDA.feeConfig(this.feeConfigOwner, this.programIds)[0], isSigner: false, isWritable: false },
2970
+ { pubkey: feeOverridePda, isSigner: false, isWritable: false },
2971
+ { pubkey: getAssociatedTokenAddressSync(collateralMint, companyAddr), isSigner: false, isWritable: true },
2972
+ { pubkey: oracleVault, isSigner: false, isWritable: true },
2973
+ { pubkey: refVault, isSigner: false, isWritable: true }
2974
+ ];
2975
+ }
2976
+ }
2977
+ }
2978
+ await this._ensureClobOutcomeAtas(yesMint, noMint, clobConfig, clobYesAta, clobNoAta);
2979
+ const hookInitIxs = [];
2980
+ if (this.hookClient) {
2981
+ for (const mint of [yesMint, noMint]) {
2982
+ const ix = await this.hookClient.buildInitHookIxIfNeeded(mint, payer);
2983
+ if (ix) hookInitIxs.push(ix);
2984
+ }
2985
+ }
2986
+ const mergeIx = await this.program.methods.batchMergeWithFee(orderPairs.length).accounts({
2987
+ operator,
2988
+ payer,
2989
+ clobConfig,
2990
+ condition,
2991
+ collateralVault,
2992
+ vaultTokenAccount,
2993
+ feeRecipient: cfg.feeRecipient,
2994
+ yesMint,
2995
+ noMint,
2996
+ clobYesAta,
2997
+ clobNoAta,
2998
+ clobYesPosition,
2999
+ clobNoPosition,
3000
+ conditionalTokensProgram: this.programIds.conditionalTokens,
3001
+ tokenProgram: TOKEN_PROGRAM_ID,
3002
+ token2022Program: TOKEN_2022_PROGRAM_ID,
3003
+ systemProgram: anchor5.web3.SystemProgram.programId
3004
+ }).remainingAccounts([...userAccounts, ...hookAccounts, ...feeAccounts]).instruction();
3005
+ const alt = opts?.lookupTable ?? await this.buildAltForCondition(condition, payer, collateralMint);
3006
+ return this._buildUnsignedVtx([...hookInitIxs, mergeIx], alt, payer);
3007
+ }
2726
3008
  /**
2727
3009
  * Build ALT for batchCollectRedeemEarly — includes per-user accounts so all
2728
3010
  * remaining_accounts fit as 1-byte ALT indices instead of 32-byte inline addresses.
@@ -9726,75 +10008,377 @@ var clob_exchange_default = {
9726
10008
  ]
9727
10009
  },
9728
10010
  {
9729
- name: "cancel_order",
10011
+ name: "batch_merge_with_fee",
9730
10012
  docs: [
9731
- "Cancel an order \u2014 close OrderRecord PDA, return rent to maker."
10013
+ "Batch merge YES+NO tokens before resolution. Returns net USDS to yes_signer, keeps fee.",
10014
+ "Mirrors EVM _matchMergeOrder flow."
9732
10015
  ],
9733
10016
  discriminator: [
9734
- 95,
9735
- 129,
9736
- 237,
9737
- 240,
9738
- 8,
9739
- 49,
9740
- 223,
9741
- 132
10017
+ 56,
10018
+ 127,
10019
+ 113,
10020
+ 232,
10021
+ 208,
10022
+ 177,
10023
+ 157,
10024
+ 230
9742
10025
  ],
9743
10026
  accounts: [
9744
10027
  {
9745
- name: "maker",
9746
- docs: [
9747
- "Must be the order maker/signer"
9748
- ],
10028
+ name: "operator",
9749
10029
  signer: true
9750
10030
  },
9751
10031
  {
9752
- name: "order_record",
10032
+ name: "payer",
10033
+ writable: true,
10034
+ signer: true
10035
+ },
10036
+ {
10037
+ name: "clob_config",
9753
10038
  writable: true,
9754
10039
  pda: {
9755
10040
  seeds: [
9756
10041
  {
9757
10042
  kind: "const",
9758
10043
  value: [
10044
+ 99,
10045
+ 108,
9759
10046
  111,
9760
- 114,
9761
- 100,
9762
- 101,
9763
- 114,
10047
+ 98,
9764
10048
  95,
9765
- 114,
9766
- 101,
9767
10049
  99,
9768
10050
  111,
9769
- 114,
9770
- 100
10051
+ 110,
10052
+ 102,
10053
+ 105,
10054
+ 103
9771
10055
  ]
9772
- },
9773
- {
9774
- kind: "account",
9775
- path: "maker"
9776
- },
9777
- {
9778
- kind: "arg",
9779
- path: "nonce"
9780
10056
  }
9781
10057
  ]
9782
10058
  }
9783
10059
  },
9784
10060
  {
9785
- name: "system_program",
9786
- address: "11111111111111111111111111111111"
9787
- }
9788
- ],
9789
- args: [
10061
+ name: "condition",
10062
+ writable: true
10063
+ },
9790
10064
  {
9791
- name: "nonce",
9792
- type: "u64"
9793
- }
9794
- ]
9795
- },
9796
- {
9797
- name: "force_reset_clob",
10065
+ name: "collateral_vault",
10066
+ writable: true,
10067
+ pda: {
10068
+ seeds: [
10069
+ {
10070
+ kind: "const",
10071
+ value: [
10072
+ 99,
10073
+ 111,
10074
+ 108,
10075
+ 108,
10076
+ 97,
10077
+ 116,
10078
+ 101,
10079
+ 114,
10080
+ 97,
10081
+ 108,
10082
+ 95,
10083
+ 118,
10084
+ 97,
10085
+ 117,
10086
+ 108,
10087
+ 116
10088
+ ]
10089
+ },
10090
+ {
10091
+ kind: "account",
10092
+ path: "condition.collateral_mint",
10093
+ account: "Condition"
10094
+ }
10095
+ ],
10096
+ program: {
10097
+ kind: "account",
10098
+ path: "conditional_tokens_program"
10099
+ }
10100
+ }
10101
+ },
10102
+ {
10103
+ name: "vault_token_account",
10104
+ writable: true
10105
+ },
10106
+ {
10107
+ name: "fee_recipient",
10108
+ docs: [
10109
+ "CLOB USDS ATA \u2014 receives USDS from merge, distributes to users + fee."
10110
+ ],
10111
+ writable: true
10112
+ },
10113
+ {
10114
+ name: "yes_mint",
10115
+ writable: true
10116
+ },
10117
+ {
10118
+ name: "no_mint",
10119
+ writable: true
10120
+ },
10121
+ {
10122
+ name: "clob_yes_ata",
10123
+ writable: true
10124
+ },
10125
+ {
10126
+ name: "clob_no_ata",
10127
+ writable: true
10128
+ },
10129
+ {
10130
+ name: "clob_yes_position",
10131
+ writable: true
10132
+ },
10133
+ {
10134
+ name: "clob_no_position",
10135
+ writable: true
10136
+ },
10137
+ {
10138
+ name: "conditional_tokens_program",
10139
+ address: "A6N1F8MRsdgcojAx8p6FaECvw8mo8w6qJcWsbKQBANK4"
10140
+ },
10141
+ {
10142
+ name: "token_program",
10143
+ address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
10144
+ },
10145
+ {
10146
+ name: "token_2022_program",
10147
+ address: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
10148
+ },
10149
+ {
10150
+ name: "system_program",
10151
+ address: "11111111111111111111111111111111"
10152
+ }
10153
+ ],
10154
+ args: [
10155
+ {
10156
+ name: "order_count",
10157
+ type: "u8"
10158
+ }
10159
+ ]
10160
+ },
10161
+ {
10162
+ name: "batch_redeem_with_fee",
10163
+ docs: [
10164
+ "Batch redeem YES+NO tokens after resolution. Returns net USDS to users, keeps fee.",
10165
+ "Mirrors EVM _matchRedeemOrder flow."
10166
+ ],
10167
+ discriminator: [
10168
+ 240,
10169
+ 238,
10170
+ 168,
10171
+ 110,
10172
+ 84,
10173
+ 41,
10174
+ 165,
10175
+ 2
10176
+ ],
10177
+ accounts: [
10178
+ {
10179
+ name: "operator",
10180
+ signer: true
10181
+ },
10182
+ {
10183
+ name: "payer",
10184
+ writable: true,
10185
+ signer: true
10186
+ },
10187
+ {
10188
+ name: "clob_config",
10189
+ writable: true,
10190
+ pda: {
10191
+ seeds: [
10192
+ {
10193
+ kind: "const",
10194
+ value: [
10195
+ 99,
10196
+ 108,
10197
+ 111,
10198
+ 98,
10199
+ 95,
10200
+ 99,
10201
+ 111,
10202
+ 110,
10203
+ 102,
10204
+ 105,
10205
+ 103
10206
+ ]
10207
+ }
10208
+ ]
10209
+ }
10210
+ },
10211
+ {
10212
+ name: "condition",
10213
+ writable: true
10214
+ },
10215
+ {
10216
+ name: "collateral_vault",
10217
+ writable: true,
10218
+ pda: {
10219
+ seeds: [
10220
+ {
10221
+ kind: "const",
10222
+ value: [
10223
+ 99,
10224
+ 111,
10225
+ 108,
10226
+ 108,
10227
+ 97,
10228
+ 116,
10229
+ 101,
10230
+ 114,
10231
+ 97,
10232
+ 108,
10233
+ 95,
10234
+ 118,
10235
+ 97,
10236
+ 117,
10237
+ 108,
10238
+ 116
10239
+ ]
10240
+ },
10241
+ {
10242
+ kind: "account",
10243
+ path: "condition.collateral_mint",
10244
+ account: "Condition"
10245
+ }
10246
+ ],
10247
+ program: {
10248
+ kind: "account",
10249
+ path: "conditional_tokens_program"
10250
+ }
10251
+ }
10252
+ },
10253
+ {
10254
+ name: "vault_token_account",
10255
+ writable: true
10256
+ },
10257
+ {
10258
+ name: "fee_recipient",
10259
+ docs: [
10260
+ "CLOB USDS ATA \u2014 receives USDS from redeem, distributes to users + fee."
10261
+ ],
10262
+ writable: true
10263
+ },
10264
+ {
10265
+ name: "yes_mint",
10266
+ writable: true
10267
+ },
10268
+ {
10269
+ name: "no_mint",
10270
+ writable: true
10271
+ },
10272
+ {
10273
+ name: "clob_yes_ata",
10274
+ writable: true
10275
+ },
10276
+ {
10277
+ name: "clob_no_ata",
10278
+ writable: true
10279
+ },
10280
+ {
10281
+ name: "clob_yes_position",
10282
+ writable: true
10283
+ },
10284
+ {
10285
+ name: "clob_no_position",
10286
+ writable: true
10287
+ },
10288
+ {
10289
+ name: "conditional_tokens_program",
10290
+ address: "A6N1F8MRsdgcojAx8p6FaECvw8mo8w6qJcWsbKQBANK4"
10291
+ },
10292
+ {
10293
+ name: "token_program",
10294
+ address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
10295
+ },
10296
+ {
10297
+ name: "token_2022_program",
10298
+ address: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
10299
+ },
10300
+ {
10301
+ name: "system_program",
10302
+ address: "11111111111111111111111111111111"
10303
+ }
10304
+ ],
10305
+ args: [
10306
+ {
10307
+ name: "order_count",
10308
+ type: "u8"
10309
+ }
10310
+ ]
10311
+ },
10312
+ {
10313
+ name: "cancel_order",
10314
+ docs: [
10315
+ "Cancel an order \u2014 close OrderRecord PDA, return rent to maker."
10316
+ ],
10317
+ discriminator: [
10318
+ 95,
10319
+ 129,
10320
+ 237,
10321
+ 240,
10322
+ 8,
10323
+ 49,
10324
+ 223,
10325
+ 132
10326
+ ],
10327
+ accounts: [
10328
+ {
10329
+ name: "maker",
10330
+ docs: [
10331
+ "Must be the order maker/signer"
10332
+ ],
10333
+ signer: true
10334
+ },
10335
+ {
10336
+ name: "order_record",
10337
+ writable: true,
10338
+ pda: {
10339
+ seeds: [
10340
+ {
10341
+ kind: "const",
10342
+ value: [
10343
+ 111,
10344
+ 114,
10345
+ 100,
10346
+ 101,
10347
+ 114,
10348
+ 95,
10349
+ 114,
10350
+ 101,
10351
+ 99,
10352
+ 111,
10353
+ 114,
10354
+ 100
10355
+ ]
10356
+ },
10357
+ {
10358
+ kind: "account",
10359
+ path: "maker"
10360
+ },
10361
+ {
10362
+ kind: "arg",
10363
+ path: "nonce"
10364
+ }
10365
+ ]
10366
+ }
10367
+ },
10368
+ {
10369
+ name: "system_program",
10370
+ address: "11111111111111111111111111111111"
10371
+ }
10372
+ ],
10373
+ args: [
10374
+ {
10375
+ name: "nonce",
10376
+ type: "u64"
10377
+ }
10378
+ ]
10379
+ },
10380
+ {
10381
+ name: "force_reset_clob",
9798
10382
  discriminator: [
9799
10383
  96,
9800
10384
  95,
@@ -10885,6 +11469,107 @@ var clob_exchange_default = {
10885
11469
  }
10886
11470
  ]
10887
11471
  },
11472
+ {
11473
+ name: "register_redeem_fee_order",
11474
+ docs: [
11475
+ "Register a signed RedeemFeeOrder on-chain (Ed25519 verify + PDA creation).",
11476
+ "Prerequisite for batch_redeem_with_fee and batch_merge_with_fee."
11477
+ ],
11478
+ discriminator: [
11479
+ 129,
11480
+ 167,
11481
+ 199,
11482
+ 14,
11483
+ 217,
11484
+ 12,
11485
+ 76,
11486
+ 162
11487
+ ],
11488
+ accounts: [
11489
+ {
11490
+ name: "payer",
11491
+ writable: true,
11492
+ signer: true
11493
+ },
11494
+ {
11495
+ name: "clob_config",
11496
+ pda: {
11497
+ seeds: [
11498
+ {
11499
+ kind: "const",
11500
+ value: [
11501
+ 99,
11502
+ 108,
11503
+ 111,
11504
+ 98,
11505
+ 95,
11506
+ 99,
11507
+ 111,
11508
+ 110,
11509
+ 102,
11510
+ 105,
11511
+ 103
11512
+ ]
11513
+ }
11514
+ ]
11515
+ }
11516
+ },
11517
+ {
11518
+ name: "ix_sysvar",
11519
+ address: "Sysvar1nstructions1111111111111111111111111"
11520
+ },
11521
+ {
11522
+ name: "order_signer"
11523
+ },
11524
+ {
11525
+ name: "redeem_fee_order_record",
11526
+ writable: true,
11527
+ pda: {
11528
+ seeds: [
11529
+ {
11530
+ kind: "const",
11531
+ value: [
11532
+ 114,
11533
+ 101,
11534
+ 100,
11535
+ 101,
11536
+ 101,
11537
+ 109,
11538
+ 95,
11539
+ 102,
11540
+ 101,
11541
+ 101,
11542
+ 95,
11543
+ 111,
11544
+ 114,
11545
+ 100,
11546
+ 101,
11547
+ 114
11548
+ ]
11549
+ },
11550
+ {
11551
+ kind: "account",
11552
+ path: "order_signer"
11553
+ },
11554
+ {
11555
+ kind: "arg",
11556
+ path: "nonce"
11557
+ }
11558
+ ]
11559
+ }
11560
+ },
11561
+ {
11562
+ name: "system_program",
11563
+ address: "11111111111111111111111111111111"
11564
+ }
11565
+ ],
11566
+ args: [
11567
+ {
11568
+ name: "nonce",
11569
+ type: "u64"
11570
+ }
11571
+ ]
11572
+ },
10888
11573
  {
10889
11574
  name: "reinit_clob",
10890
11575
  discriminator: [
@@ -11075,6 +11760,19 @@ var clob_exchange_default = {
11075
11760
  3
11076
11761
  ]
11077
11762
  },
11763
+ {
11764
+ name: "RedeemFeeOrderRecord",
11765
+ discriminator: [
11766
+ 88,
11767
+ 3,
11768
+ 122,
11769
+ 192,
11770
+ 131,
11771
+ 243,
11772
+ 143,
11773
+ 146
11774
+ ]
11775
+ },
11078
11776
  {
11079
11777
  name: "SignedOrderRecord",
11080
11778
  discriminator: [
@@ -11550,6 +12248,57 @@ var clob_exchange_default = {
11550
12248
  ]
11551
12249
  }
11552
12250
  },
12251
+ {
12252
+ name: "RedeemFeeOrderRecord",
12253
+ docs: [
12254
+ "On-chain record of a signed RedeemFeeOrder.",
12255
+ "Created by `register_redeem_fee_order` after Ed25519 verification.",
12256
+ "Read and marked collected by `batch_redeem_with_fee` / `batch_merge_with_fee`.",
12257
+ "",
12258
+ 'PDA seeds: [b"redeem_fee_order", user, nonce_le_bytes]'
12259
+ ],
12260
+ type: {
12261
+ kind: "struct",
12262
+ fields: [
12263
+ {
12264
+ name: "user",
12265
+ type: "pubkey"
12266
+ },
12267
+ {
12268
+ name: "condition",
12269
+ type: "pubkey"
12270
+ },
12271
+ {
12272
+ name: "token_mint",
12273
+ type: "pubkey"
12274
+ },
12275
+ {
12276
+ name: "amount",
12277
+ type: "u64"
12278
+ },
12279
+ {
12280
+ name: "taker_amount",
12281
+ type: "u64"
12282
+ },
12283
+ {
12284
+ name: "nonce",
12285
+ type: "u64"
12286
+ },
12287
+ {
12288
+ name: "expiry",
12289
+ type: "i64"
12290
+ },
12291
+ {
12292
+ name: "is_collected",
12293
+ type: "bool"
12294
+ },
12295
+ {
12296
+ name: "bump",
12297
+ type: "u8"
12298
+ }
12299
+ ]
12300
+ }
12301
+ },
11553
12302
  {
11554
12303
  name: "SignedOrderRecord",
11555
12304
  docs: [
@@ -18124,6 +18873,6 @@ function buildApproveAllOutcomeTokensTx(condition, signer, payer, delegate, prog
18124
18873
  return tx;
18125
18874
  }
18126
18875
 
18127
- 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 };
18876
+ 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, buildBatchedRedeemFeeEd25519Instruction, buildCreateUserAtasTx, buildOrder, buildOrderFromPrice, deserializeSignedOrder, detectMatchType, generateContentHash, generateQuestionId, getOrderSignBytes, orderAmountsFromPrice, serializeCollectFeeOrderToBytes, serializeOrderToBytes, serializeRedeemFeeOrderToBytes, serializeSignedOrder, signOrder, signOrderWithKeypair, verifySignedOrder };
18128
18877
  //# sourceMappingURL=index.mjs.map
18129
18878
  //# sourceMappingURL=index.mjs.map