@theliem/xmarket-sdk 3.25.0 → 3.27.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.
@@ -3278,6 +3560,17 @@ var MarketOracleClient = class {
3278
3560
  return null;
3279
3561
  }
3280
3562
  }
3563
+ /**
3564
+ * Derive marketOracleVault from presaleAddress and return its USDS balance.
3565
+ * presaleAddress is used as the questionId seed in the question PDA.
3566
+ */
3567
+ async getOracleVaultBalance(presaleAddress, qmConfigPda, collateralMint) {
3568
+ const [questionPda] = PDA.question(qmConfigPda, presaleAddress.toBytes(), this.programIds);
3569
+ const [marketOraclePda] = PDA.marketOraclePda(questionPda, this.programIds);
3570
+ const vault = getAssociatedTokenAddressSync(collateralMint, marketOraclePda, true);
3571
+ const bal = await this.program.provider.connection.getTokenAccountBalance(vault);
3572
+ return bal.value.uiAmount ?? 0;
3573
+ }
3281
3574
  async fetchUserClaimRecord(marketOraclePda, user) {
3282
3575
  try {
3283
3576
  const pda = this.userClaimRecordPda(marketOraclePda, user);
@@ -9726,70 +10019,372 @@ var clob_exchange_default = {
9726
10019
  ]
9727
10020
  },
9728
10021
  {
9729
- name: "cancel_order",
10022
+ name: "batch_merge_with_fee",
9730
10023
  docs: [
9731
- "Cancel an order \u2014 close OrderRecord PDA, return rent to maker."
10024
+ "Batch merge YES+NO tokens before resolution. Returns net USDS to yes_signer, keeps fee.",
10025
+ "Mirrors EVM _matchMergeOrder flow."
9732
10026
  ],
9733
10027
  discriminator: [
9734
- 95,
9735
- 129,
9736
- 237,
9737
- 240,
9738
- 8,
9739
- 49,
9740
- 223,
9741
- 132
10028
+ 56,
10029
+ 127,
10030
+ 113,
10031
+ 232,
10032
+ 208,
10033
+ 177,
10034
+ 157,
10035
+ 230
9742
10036
  ],
9743
10037
  accounts: [
9744
10038
  {
9745
- name: "maker",
9746
- docs: [
9747
- "Must be the order maker/signer"
9748
- ],
10039
+ name: "operator",
9749
10040
  signer: true
9750
10041
  },
9751
10042
  {
9752
- name: "order_record",
10043
+ name: "payer",
10044
+ writable: true,
10045
+ signer: true
10046
+ },
10047
+ {
10048
+ name: "clob_config",
9753
10049
  writable: true,
9754
10050
  pda: {
9755
10051
  seeds: [
9756
10052
  {
9757
10053
  kind: "const",
9758
10054
  value: [
10055
+ 99,
10056
+ 108,
9759
10057
  111,
9760
- 114,
9761
- 100,
9762
- 101,
9763
- 114,
10058
+ 98,
9764
10059
  95,
9765
- 114,
9766
- 101,
9767
10060
  99,
9768
10061
  111,
9769
- 114,
9770
- 100
10062
+ 110,
10063
+ 102,
10064
+ 105,
10065
+ 103
9771
10066
  ]
9772
- },
9773
- {
9774
- kind: "account",
9775
- path: "maker"
9776
- },
9777
- {
9778
- kind: "arg",
9779
- path: "nonce"
9780
10067
  }
9781
10068
  ]
9782
10069
  }
9783
10070
  },
9784
10071
  {
9785
- name: "system_program",
9786
- address: "11111111111111111111111111111111"
9787
- }
9788
- ],
9789
- args: [
10072
+ name: "condition",
10073
+ writable: true
10074
+ },
9790
10075
  {
9791
- name: "nonce",
9792
- type: "u64"
10076
+ name: "collateral_vault",
10077
+ writable: true,
10078
+ pda: {
10079
+ seeds: [
10080
+ {
10081
+ kind: "const",
10082
+ value: [
10083
+ 99,
10084
+ 111,
10085
+ 108,
10086
+ 108,
10087
+ 97,
10088
+ 116,
10089
+ 101,
10090
+ 114,
10091
+ 97,
10092
+ 108,
10093
+ 95,
10094
+ 118,
10095
+ 97,
10096
+ 117,
10097
+ 108,
10098
+ 116
10099
+ ]
10100
+ },
10101
+ {
10102
+ kind: "account",
10103
+ path: "condition.collateral_mint",
10104
+ account: "Condition"
10105
+ }
10106
+ ],
10107
+ program: {
10108
+ kind: "account",
10109
+ path: "conditional_tokens_program"
10110
+ }
10111
+ }
10112
+ },
10113
+ {
10114
+ name: "vault_token_account",
10115
+ writable: true
10116
+ },
10117
+ {
10118
+ name: "fee_recipient",
10119
+ docs: [
10120
+ "CLOB USDS ATA \u2014 receives USDS from merge, distributes to users + fee."
10121
+ ],
10122
+ writable: true
10123
+ },
10124
+ {
10125
+ name: "yes_mint",
10126
+ writable: true
10127
+ },
10128
+ {
10129
+ name: "no_mint",
10130
+ writable: true
10131
+ },
10132
+ {
10133
+ name: "clob_yes_ata",
10134
+ writable: true
10135
+ },
10136
+ {
10137
+ name: "clob_no_ata",
10138
+ writable: true
10139
+ },
10140
+ {
10141
+ name: "clob_yes_position",
10142
+ writable: true
10143
+ },
10144
+ {
10145
+ name: "clob_no_position",
10146
+ writable: true
10147
+ },
10148
+ {
10149
+ name: "conditional_tokens_program",
10150
+ address: "A6N1F8MRsdgcojAx8p6FaECvw8mo8w6qJcWsbKQBANK4"
10151
+ },
10152
+ {
10153
+ name: "token_program",
10154
+ address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
10155
+ },
10156
+ {
10157
+ name: "token_2022_program",
10158
+ address: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
10159
+ },
10160
+ {
10161
+ name: "system_program",
10162
+ address: "11111111111111111111111111111111"
10163
+ }
10164
+ ],
10165
+ args: [
10166
+ {
10167
+ name: "order_count",
10168
+ type: "u8"
10169
+ }
10170
+ ]
10171
+ },
10172
+ {
10173
+ name: "batch_redeem_with_fee",
10174
+ docs: [
10175
+ "Batch redeem YES+NO tokens after resolution. Returns net USDS to users, keeps fee.",
10176
+ "Mirrors EVM _matchRedeemOrder flow."
10177
+ ],
10178
+ discriminator: [
10179
+ 240,
10180
+ 238,
10181
+ 168,
10182
+ 110,
10183
+ 84,
10184
+ 41,
10185
+ 165,
10186
+ 2
10187
+ ],
10188
+ accounts: [
10189
+ {
10190
+ name: "operator",
10191
+ signer: true
10192
+ },
10193
+ {
10194
+ name: "payer",
10195
+ writable: true,
10196
+ signer: true
10197
+ },
10198
+ {
10199
+ name: "clob_config",
10200
+ writable: true,
10201
+ pda: {
10202
+ seeds: [
10203
+ {
10204
+ kind: "const",
10205
+ value: [
10206
+ 99,
10207
+ 108,
10208
+ 111,
10209
+ 98,
10210
+ 95,
10211
+ 99,
10212
+ 111,
10213
+ 110,
10214
+ 102,
10215
+ 105,
10216
+ 103
10217
+ ]
10218
+ }
10219
+ ]
10220
+ }
10221
+ },
10222
+ {
10223
+ name: "condition",
10224
+ writable: true
10225
+ },
10226
+ {
10227
+ name: "collateral_vault",
10228
+ writable: true,
10229
+ pda: {
10230
+ seeds: [
10231
+ {
10232
+ kind: "const",
10233
+ value: [
10234
+ 99,
10235
+ 111,
10236
+ 108,
10237
+ 108,
10238
+ 97,
10239
+ 116,
10240
+ 101,
10241
+ 114,
10242
+ 97,
10243
+ 108,
10244
+ 95,
10245
+ 118,
10246
+ 97,
10247
+ 117,
10248
+ 108,
10249
+ 116
10250
+ ]
10251
+ },
10252
+ {
10253
+ kind: "account",
10254
+ path: "condition.collateral_mint",
10255
+ account: "Condition"
10256
+ }
10257
+ ],
10258
+ program: {
10259
+ kind: "account",
10260
+ path: "conditional_tokens_program"
10261
+ }
10262
+ }
10263
+ },
10264
+ {
10265
+ name: "vault_token_account",
10266
+ writable: true
10267
+ },
10268
+ {
10269
+ name: "fee_recipient",
10270
+ docs: [
10271
+ "CLOB USDS ATA \u2014 receives USDS from redeem, distributes to users + fee."
10272
+ ],
10273
+ writable: true
10274
+ },
10275
+ {
10276
+ name: "yes_mint",
10277
+ writable: true
10278
+ },
10279
+ {
10280
+ name: "no_mint",
10281
+ writable: true
10282
+ },
10283
+ {
10284
+ name: "clob_yes_ata",
10285
+ writable: true
10286
+ },
10287
+ {
10288
+ name: "clob_no_ata",
10289
+ writable: true
10290
+ },
10291
+ {
10292
+ name: "clob_yes_position",
10293
+ writable: true
10294
+ },
10295
+ {
10296
+ name: "clob_no_position",
10297
+ writable: true
10298
+ },
10299
+ {
10300
+ name: "conditional_tokens_program",
10301
+ address: "A6N1F8MRsdgcojAx8p6FaECvw8mo8w6qJcWsbKQBANK4"
10302
+ },
10303
+ {
10304
+ name: "token_program",
10305
+ address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
10306
+ },
10307
+ {
10308
+ name: "token_2022_program",
10309
+ address: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
10310
+ },
10311
+ {
10312
+ name: "system_program",
10313
+ address: "11111111111111111111111111111111"
10314
+ }
10315
+ ],
10316
+ args: [
10317
+ {
10318
+ name: "order_count",
10319
+ type: "u8"
10320
+ }
10321
+ ]
10322
+ },
10323
+ {
10324
+ name: "cancel_order",
10325
+ docs: [
10326
+ "Cancel an order \u2014 close OrderRecord PDA, return rent to maker."
10327
+ ],
10328
+ discriminator: [
10329
+ 95,
10330
+ 129,
10331
+ 237,
10332
+ 240,
10333
+ 8,
10334
+ 49,
10335
+ 223,
10336
+ 132
10337
+ ],
10338
+ accounts: [
10339
+ {
10340
+ name: "maker",
10341
+ docs: [
10342
+ "Must be the order maker/signer"
10343
+ ],
10344
+ signer: true
10345
+ },
10346
+ {
10347
+ name: "order_record",
10348
+ writable: true,
10349
+ pda: {
10350
+ seeds: [
10351
+ {
10352
+ kind: "const",
10353
+ value: [
10354
+ 111,
10355
+ 114,
10356
+ 100,
10357
+ 101,
10358
+ 114,
10359
+ 95,
10360
+ 114,
10361
+ 101,
10362
+ 99,
10363
+ 111,
10364
+ 114,
10365
+ 100
10366
+ ]
10367
+ },
10368
+ {
10369
+ kind: "account",
10370
+ path: "maker"
10371
+ },
10372
+ {
10373
+ kind: "arg",
10374
+ path: "nonce"
10375
+ }
10376
+ ]
10377
+ }
10378
+ },
10379
+ {
10380
+ name: "system_program",
10381
+ address: "11111111111111111111111111111111"
10382
+ }
10383
+ ],
10384
+ args: [
10385
+ {
10386
+ name: "nonce",
10387
+ type: "u64"
9793
10388
  }
9794
10389
  ]
9795
10390
  },
@@ -10885,6 +11480,107 @@ var clob_exchange_default = {
10885
11480
  }
10886
11481
  ]
10887
11482
  },
11483
+ {
11484
+ name: "register_redeem_fee_order",
11485
+ docs: [
11486
+ "Register a signed RedeemFeeOrder on-chain (Ed25519 verify + PDA creation).",
11487
+ "Prerequisite for batch_redeem_with_fee and batch_merge_with_fee."
11488
+ ],
11489
+ discriminator: [
11490
+ 129,
11491
+ 167,
11492
+ 199,
11493
+ 14,
11494
+ 217,
11495
+ 12,
11496
+ 76,
11497
+ 162
11498
+ ],
11499
+ accounts: [
11500
+ {
11501
+ name: "payer",
11502
+ writable: true,
11503
+ signer: true
11504
+ },
11505
+ {
11506
+ name: "clob_config",
11507
+ pda: {
11508
+ seeds: [
11509
+ {
11510
+ kind: "const",
11511
+ value: [
11512
+ 99,
11513
+ 108,
11514
+ 111,
11515
+ 98,
11516
+ 95,
11517
+ 99,
11518
+ 111,
11519
+ 110,
11520
+ 102,
11521
+ 105,
11522
+ 103
11523
+ ]
11524
+ }
11525
+ ]
11526
+ }
11527
+ },
11528
+ {
11529
+ name: "ix_sysvar",
11530
+ address: "Sysvar1nstructions1111111111111111111111111"
11531
+ },
11532
+ {
11533
+ name: "order_signer"
11534
+ },
11535
+ {
11536
+ name: "redeem_fee_order_record",
11537
+ writable: true,
11538
+ pda: {
11539
+ seeds: [
11540
+ {
11541
+ kind: "const",
11542
+ value: [
11543
+ 114,
11544
+ 101,
11545
+ 100,
11546
+ 101,
11547
+ 101,
11548
+ 109,
11549
+ 95,
11550
+ 102,
11551
+ 101,
11552
+ 101,
11553
+ 95,
11554
+ 111,
11555
+ 114,
11556
+ 100,
11557
+ 101,
11558
+ 114
11559
+ ]
11560
+ },
11561
+ {
11562
+ kind: "account",
11563
+ path: "order_signer"
11564
+ },
11565
+ {
11566
+ kind: "arg",
11567
+ path: "nonce"
11568
+ }
11569
+ ]
11570
+ }
11571
+ },
11572
+ {
11573
+ name: "system_program",
11574
+ address: "11111111111111111111111111111111"
11575
+ }
11576
+ ],
11577
+ args: [
11578
+ {
11579
+ name: "nonce",
11580
+ type: "u64"
11581
+ }
11582
+ ]
11583
+ },
10888
11584
  {
10889
11585
  name: "reinit_clob",
10890
11586
  discriminator: [
@@ -11075,6 +11771,19 @@ var clob_exchange_default = {
11075
11771
  3
11076
11772
  ]
11077
11773
  },
11774
+ {
11775
+ name: "RedeemFeeOrderRecord",
11776
+ discriminator: [
11777
+ 88,
11778
+ 3,
11779
+ 122,
11780
+ 192,
11781
+ 131,
11782
+ 243,
11783
+ 143,
11784
+ 146
11785
+ ]
11786
+ },
11078
11787
  {
11079
11788
  name: "SignedOrderRecord",
11080
11789
  discriminator: [
@@ -11550,6 +12259,57 @@ var clob_exchange_default = {
11550
12259
  ]
11551
12260
  }
11552
12261
  },
12262
+ {
12263
+ name: "RedeemFeeOrderRecord",
12264
+ docs: [
12265
+ "On-chain record of a signed RedeemFeeOrder.",
12266
+ "Created by `register_redeem_fee_order` after Ed25519 verification.",
12267
+ "Read and marked collected by `batch_redeem_with_fee` / `batch_merge_with_fee`.",
12268
+ "",
12269
+ 'PDA seeds: [b"redeem_fee_order", user, nonce_le_bytes]'
12270
+ ],
12271
+ type: {
12272
+ kind: "struct",
12273
+ fields: [
12274
+ {
12275
+ name: "user",
12276
+ type: "pubkey"
12277
+ },
12278
+ {
12279
+ name: "condition",
12280
+ type: "pubkey"
12281
+ },
12282
+ {
12283
+ name: "token_mint",
12284
+ type: "pubkey"
12285
+ },
12286
+ {
12287
+ name: "amount",
12288
+ type: "u64"
12289
+ },
12290
+ {
12291
+ name: "taker_amount",
12292
+ type: "u64"
12293
+ },
12294
+ {
12295
+ name: "nonce",
12296
+ type: "u64"
12297
+ },
12298
+ {
12299
+ name: "expiry",
12300
+ type: "i64"
12301
+ },
12302
+ {
12303
+ name: "is_collected",
12304
+ type: "bool"
12305
+ },
12306
+ {
12307
+ name: "bump",
12308
+ type: "u8"
12309
+ }
12310
+ ]
12311
+ }
12312
+ },
11553
12313
  {
11554
12314
  name: "SignedOrderRecord",
11555
12315
  docs: [
@@ -18124,6 +18884,6 @@ function buildApproveAllOutcomeTokensTx(condition, signer, payer, delegate, prog
18124
18884
  return tx;
18125
18885
  }
18126
18886
 
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 };
18887
+ 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
18888
  //# sourceMappingURL=index.mjs.map
18129
18889
  //# sourceMappingURL=index.mjs.map