@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.js CHANGED
@@ -195,6 +195,14 @@ var PDA = class {
195
195
  programIds.clobExchange
196
196
  );
197
197
  }
198
+ static redeemFeeOrderRecord(user, nonce, programIds) {
199
+ const nonceBuf = Buffer.alloc(8);
200
+ nonceBuf.writeBigUInt64LE(BigInt(nonce.toString()));
201
+ return web3_js.PublicKey.findProgramAddressSync(
202
+ [Buffer.from("redeem_fee_order"), user.toBuffer(), nonceBuf],
203
+ programIds.clobExchange
204
+ );
205
+ }
198
206
  // ─── Fee Management ─────────────────────────────────────────────────────────
199
207
  static feeConfig(owner, programIds) {
200
208
  if (!programIds.feeManagement) throw new Error("feeManagement program ID not configured");
@@ -1504,6 +1512,50 @@ function buildBatchedCollectFeeEd25519Instruction(orders) {
1504
1512
  data
1505
1513
  });
1506
1514
  }
1515
+ function serializeRedeemFeeOrderToBytes(order) {
1516
+ const buf = new Uint8Array(128);
1517
+ buf.set(order.user.toBytes(), 0);
1518
+ buf.set(order.condition.toBytes(), 32);
1519
+ buf.set(order.tokenMint.toBytes(), 64);
1520
+ buf.set(order.amount.toArrayLike(Buffer, "le", 8), 96);
1521
+ buf.set(order.takerAmount.toArrayLike(Buffer, "le", 8), 104);
1522
+ buf.set(order.nonce.toArrayLike(Buffer, "le", 8), 112);
1523
+ buf.set(order.expiry.toArrayLike(Buffer, "le", 8), 120);
1524
+ return buf;
1525
+ }
1526
+ function buildBatchedRedeemFeeEd25519Instruction(orders) {
1527
+ const N = orders.length;
1528
+ if (N === 0) throw new Error("At least 1 order required");
1529
+ const MSG_SIZE = 128;
1530
+ const SIG_SIZE = 64;
1531
+ const PK_SIZE = 32;
1532
+ const HEADER = 2 + N * 14;
1533
+ const sigBase = HEADER;
1534
+ const pkBase = sigBase + N * SIG_SIZE;
1535
+ const msgBase = pkBase + N * PK_SIZE;
1536
+ const totalSize = msgBase + N * MSG_SIZE;
1537
+ const data = Buffer.alloc(totalSize);
1538
+ data[0] = N;
1539
+ data[1] = 0;
1540
+ for (let i = 0; i < N; i++) {
1541
+ const e = 2 + i * 14;
1542
+ data.writeUInt16LE(sigBase + i * SIG_SIZE, e);
1543
+ data.writeUInt16LE(65535, e + 2);
1544
+ data.writeUInt16LE(pkBase + i * PK_SIZE, e + 4);
1545
+ data.writeUInt16LE(65535, e + 6);
1546
+ data.writeUInt16LE(msgBase + i * MSG_SIZE, e + 8);
1547
+ data.writeUInt16LE(MSG_SIZE, e + 10);
1548
+ data.writeUInt16LE(65535, e + 12);
1549
+ data.set(orders[i].signature, sigBase + i * SIG_SIZE);
1550
+ data.set(orders[i].order.user.toBytes(), pkBase + i * PK_SIZE);
1551
+ data.set(serializeRedeemFeeOrderToBytes(orders[i].order), msgBase + i * MSG_SIZE);
1552
+ }
1553
+ return new web3_js.TransactionInstruction({
1554
+ keys: [],
1555
+ programId: web3_js.Ed25519Program.programId,
1556
+ data
1557
+ });
1558
+ }
1507
1559
  function buildOrder(params) {
1508
1560
  return {
1509
1561
  maker: params.maker,
@@ -2749,6 +2801,236 @@ ${logs.join("\n")}`);
2749
2801
  const alt = opts?.lookupTable ?? await this.buildAltForCollectBatch(condition, payer, collateralMint, signedOrders, outcomeIndex);
2750
2802
  return this._buildUnsignedVtx([...hookInitIxs, collectIx], alt, payer);
2751
2803
  }
2804
+ // ─── Register RedeemFeeOrder ─────────────────────────────────────────────────
2805
+ /**
2806
+ * Build a Transaction to register a RedeemFeeOrder on-chain (Ed25519 verify + PDA).
2807
+ * Must be sent before calling buildBatchRedeemWithFeeTx / buildBatchMergeWithFeeTx.
2808
+ *
2809
+ * ix[0]: batched Ed25519 { pubkey=order.user, sig, msg=128 bytes }
2810
+ * ix[1]: register_redeem_fee_order(nonce)
2811
+ */
2812
+ async buildRegisterRedeemFeeOrderTx(signedOrder, payer) {
2813
+ const { order } = signedOrder;
2814
+ const [redeemFeeOrderRecord] = PDA.redeemFeeOrderRecord(order.user, order.nonce, this.programIds);
2815
+ const ed25519Ix = buildBatchedRedeemFeeEd25519Instruction([signedOrder]);
2816
+ const registerIx = await this.program.methods.registerRedeemFeeOrder(order.nonce).accounts({
2817
+ payer,
2818
+ clobConfig: this.configPda(),
2819
+ ixSysvar: IX_SYSVAR,
2820
+ orderSigner: order.user,
2821
+ redeemFeeOrderRecord,
2822
+ systemProgram: anchor5__namespace.web3.SystemProgram.programId
2823
+ }).instruction();
2824
+ const tx = new anchor5__namespace.web3.Transaction();
2825
+ tx.add(ed25519Ix, registerIx);
2826
+ return tx;
2827
+ }
2828
+ // ─── batchRedeemWithFee ───────────────────────────────────────────────────────
2829
+ /**
2830
+ * Build a VersionedTransaction for batchRedeemWithFee.
2831
+ * Each pair has a YES order + NO order for the same user (same signer or different).
2832
+ * After resolution: YES holder taker_amount > 0, NO holder taker_amount = 0 (or vice versa).
2833
+ *
2834
+ * Prerequisite: each order's RedeemFeeOrderRecord must be registered via buildRegisterRedeemFeeOrderTx.
2835
+ */
2836
+ async buildBatchRedeemWithFeeTx(orderPairs, condition, operator, payer, opts) {
2837
+ if (orderPairs.length === 0) throw new InvalidParamError("At least 1 order pair required");
2838
+ const collateralMint = this.networkConfig.defaultCollateral.mint;
2839
+ const cfg = await this.fetchConfig();
2840
+ if (!cfg) throw new InvalidParamError("CLOB config not found on-chain");
2841
+ const clobConfig = this.configPda();
2842
+ const [yesMint] = PDA.yesMint(condition, this.programIds);
2843
+ const [noMint] = PDA.noMint(condition, this.programIds);
2844
+ const [collateralVault] = PDA.collateralVault(collateralMint, this.programIds);
2845
+ const [vaultTokenAccount] = PDA.vaultToken(collateralMint, this.programIds);
2846
+ const [yesExtraMeta] = PDA.extraAccountMetaList(yesMint, this.programIds);
2847
+ const [noExtraMeta] = PDA.extraAccountMetaList(noMint, this.programIds);
2848
+ const [hookConfig] = PDA.hookConfig(this.programIds);
2849
+ const [clobYesPosition] = PDA.position(condition, 1, clobConfig, this.programIds);
2850
+ const [clobNoPosition] = PDA.position(condition, 0, clobConfig, this.programIds);
2851
+ const clobYesAta = splToken.getAssociatedTokenAddressSync(yesMint, clobConfig, true, splToken.TOKEN_2022_PROGRAM_ID);
2852
+ const clobNoAta = splToken.getAssociatedTokenAddressSync(noMint, clobConfig, true, splToken.TOKEN_2022_PROGRAM_ID);
2853
+ const userAccounts = [];
2854
+ for (const { yes, no } of orderPairs) {
2855
+ const [yesRecord] = PDA.redeemFeeOrderRecord(yes.order.user, yes.order.nonce, this.programIds);
2856
+ const [noRecord] = PDA.redeemFeeOrderRecord(no.order.user, no.order.nonce, this.programIds);
2857
+ const userYesAta = splToken.getAssociatedTokenAddressSync(yesMint, yes.order.user, false, splToken.TOKEN_2022_PROGRAM_ID);
2858
+ const userNoAta = splToken.getAssociatedTokenAddressSync(noMint, no.order.user, false, splToken.TOKEN_2022_PROGRAM_ID);
2859
+ const [userYesPos] = PDA.position(condition, 1, yes.order.user, this.programIds);
2860
+ const [userNoPos] = PDA.position(condition, 0, no.order.user, this.programIds);
2861
+ const yesCollateral = splToken.getAssociatedTokenAddressSync(collateralMint, yes.order.user);
2862
+ const noCollateral = splToken.getAssociatedTokenAddressSync(collateralMint, no.order.user);
2863
+ userAccounts.push(
2864
+ { pubkey: yesRecord, isSigner: false, isWritable: true },
2865
+ { pubkey: noRecord, isSigner: false, isWritable: true },
2866
+ { pubkey: yes.order.user, isSigner: false, isWritable: false },
2867
+ { pubkey: no.order.user, isSigner: false, isWritable: false },
2868
+ { pubkey: userYesAta, isSigner: false, isWritable: true },
2869
+ { pubkey: userNoAta, isSigner: false, isWritable: true },
2870
+ { pubkey: userYesPos, isSigner: false, isWritable: true },
2871
+ { pubkey: userNoPos, isSigner: false, isWritable: true },
2872
+ { pubkey: yesCollateral, isSigner: false, isWritable: true },
2873
+ { pubkey: noCollateral, isSigner: false, isWritable: true }
2874
+ );
2875
+ }
2876
+ const hookAccounts = [
2877
+ { pubkey: yesExtraMeta, isSigner: false, isWritable: false },
2878
+ { pubkey: noExtraMeta, isSigner: false, isWritable: false },
2879
+ { pubkey: hookConfig, isSigner: false, isWritable: false },
2880
+ { pubkey: this.programIds.hook, isSigner: false, isWritable: false }
2881
+ ];
2882
+ let feeAccounts = [];
2883
+ if (this.programIds.feeManagement && this.feeConfigOwner) {
2884
+ const companyAddr = await this.companyAddress();
2885
+ const refVault = await this.referralVault();
2886
+ if (companyAddr && refVault) {
2887
+ const feeOverridePda = PDA.marketFeeOverride(condition, this.programIds)[0];
2888
+ const feeOverrideExists = await this.provider.connection.getAccountInfo(feeOverridePda);
2889
+ if (feeOverrideExists) {
2890
+ const oracleVault = opts?.marketOracleVault ?? await this.getMarketOracleVault(condition, collateralMint) ?? payer;
2891
+ feeAccounts = [
2892
+ { pubkey: this.programIds.feeManagement, isSigner: false, isWritable: false },
2893
+ { pubkey: PDA.feeConfig(this.feeConfigOwner, this.programIds)[0], isSigner: false, isWritable: false },
2894
+ { pubkey: feeOverridePda, isSigner: false, isWritable: false },
2895
+ { pubkey: splToken.getAssociatedTokenAddressSync(collateralMint, companyAddr), isSigner: false, isWritable: true },
2896
+ { pubkey: oracleVault, isSigner: false, isWritable: true },
2897
+ { pubkey: refVault, isSigner: false, isWritable: true }
2898
+ ];
2899
+ }
2900
+ }
2901
+ }
2902
+ await this._ensureClobOutcomeAtas(yesMint, noMint, clobConfig, clobYesAta, clobNoAta);
2903
+ const hookInitIxs = [];
2904
+ if (this.hookClient) {
2905
+ for (const mint of [yesMint, noMint]) {
2906
+ const ix = await this.hookClient.buildInitHookIxIfNeeded(mint, payer);
2907
+ if (ix) hookInitIxs.push(ix);
2908
+ }
2909
+ }
2910
+ const redeemIx = await this.program.methods.batchRedeemWithFee(orderPairs.length).accounts({
2911
+ operator,
2912
+ payer,
2913
+ clobConfig,
2914
+ condition,
2915
+ collateralVault,
2916
+ vaultTokenAccount,
2917
+ feeRecipient: cfg.feeRecipient,
2918
+ yesMint,
2919
+ noMint,
2920
+ clobYesAta,
2921
+ clobNoAta,
2922
+ clobYesPosition,
2923
+ clobNoPosition,
2924
+ conditionalTokensProgram: this.programIds.conditionalTokens,
2925
+ tokenProgram: splToken.TOKEN_PROGRAM_ID,
2926
+ token2022Program: splToken.TOKEN_2022_PROGRAM_ID,
2927
+ systemProgram: anchor5__namespace.web3.SystemProgram.programId
2928
+ }).remainingAccounts([...userAccounts, ...hookAccounts, ...feeAccounts]).instruction();
2929
+ const alt = opts?.lookupTable ?? await this.buildAltForCondition(condition, payer, collateralMint);
2930
+ return this._buildUnsignedVtx([...hookInitIxs, redeemIx], alt, payer);
2931
+ }
2932
+ // ─── batchMergeWithFee ────────────────────────────────────────────────────────
2933
+ /**
2934
+ * Build a VersionedTransaction for batchMergeWithFee (pre-resolution merge with fee).
2935
+ * Each pair: YES order + NO order with equal amounts for the same user.
2936
+ * Only yes_signer receives net USDS (mirrors EVM _matchMergeOrder).
2937
+ *
2938
+ * Prerequisite: each order's RedeemFeeOrderRecord must be registered via buildRegisterRedeemFeeOrderTx.
2939
+ */
2940
+ async buildBatchMergeWithFeeTx(orderPairs, condition, operator, payer, opts) {
2941
+ if (orderPairs.length === 0) throw new InvalidParamError("At least 1 order pair required");
2942
+ const collateralMint = this.networkConfig.defaultCollateral.mint;
2943
+ const cfg = await this.fetchConfig();
2944
+ if (!cfg) throw new InvalidParamError("CLOB config not found on-chain");
2945
+ const clobConfig = this.configPda();
2946
+ const [yesMint] = PDA.yesMint(condition, this.programIds);
2947
+ const [noMint] = PDA.noMint(condition, this.programIds);
2948
+ const [collateralVault] = PDA.collateralVault(collateralMint, this.programIds);
2949
+ const [vaultTokenAccount] = PDA.vaultToken(collateralMint, this.programIds);
2950
+ const [yesExtraMeta] = PDA.extraAccountMetaList(yesMint, this.programIds);
2951
+ const [noExtraMeta] = PDA.extraAccountMetaList(noMint, this.programIds);
2952
+ const [hookConfig] = PDA.hookConfig(this.programIds);
2953
+ const [clobYesPosition] = PDA.position(condition, 1, clobConfig, this.programIds);
2954
+ const [clobNoPosition] = PDA.position(condition, 0, clobConfig, this.programIds);
2955
+ const clobYesAta = splToken.getAssociatedTokenAddressSync(yesMint, clobConfig, true, splToken.TOKEN_2022_PROGRAM_ID);
2956
+ const clobNoAta = splToken.getAssociatedTokenAddressSync(noMint, clobConfig, true, splToken.TOKEN_2022_PROGRAM_ID);
2957
+ const userAccounts = [];
2958
+ for (const { yes, no } of orderPairs) {
2959
+ const [yesRecord] = PDA.redeemFeeOrderRecord(yes.order.user, yes.order.nonce, this.programIds);
2960
+ const [noRecord] = PDA.redeemFeeOrderRecord(no.order.user, no.order.nonce, this.programIds);
2961
+ const userYesAta = splToken.getAssociatedTokenAddressSync(yesMint, yes.order.user, false, splToken.TOKEN_2022_PROGRAM_ID);
2962
+ const userNoAta = splToken.getAssociatedTokenAddressSync(noMint, no.order.user, false, splToken.TOKEN_2022_PROGRAM_ID);
2963
+ const [userYesPos] = PDA.position(condition, 1, yes.order.user, this.programIds);
2964
+ const [userNoPos] = PDA.position(condition, 0, no.order.user, this.programIds);
2965
+ const yesCollateral = splToken.getAssociatedTokenAddressSync(collateralMint, yes.order.user);
2966
+ userAccounts.push(
2967
+ { pubkey: yesRecord, isSigner: false, isWritable: true },
2968
+ { pubkey: noRecord, isSigner: false, isWritable: true },
2969
+ { pubkey: yes.order.user, isSigner: false, isWritable: false },
2970
+ { pubkey: no.order.user, isSigner: false, isWritable: false },
2971
+ { pubkey: userYesAta, isSigner: false, isWritable: true },
2972
+ { pubkey: userNoAta, isSigner: false, isWritable: true },
2973
+ { pubkey: userYesPos, isSigner: false, isWritable: true },
2974
+ { pubkey: userNoPos, isSigner: false, isWritable: true },
2975
+ { pubkey: yesCollateral, isSigner: false, isWritable: true }
2976
+ );
2977
+ }
2978
+ const hookAccounts = [
2979
+ { pubkey: yesExtraMeta, isSigner: false, isWritable: false },
2980
+ { pubkey: noExtraMeta, isSigner: false, isWritable: false },
2981
+ { pubkey: hookConfig, isSigner: false, isWritable: false },
2982
+ { pubkey: this.programIds.hook, isSigner: false, isWritable: false }
2983
+ ];
2984
+ let feeAccounts = [];
2985
+ if (this.programIds.feeManagement && this.feeConfigOwner) {
2986
+ const companyAddr = await this.companyAddress();
2987
+ const refVault = await this.referralVault();
2988
+ if (companyAddr && refVault) {
2989
+ const feeOverridePda = PDA.marketFeeOverride(condition, this.programIds)[0];
2990
+ const feeOverrideExists = await this.provider.connection.getAccountInfo(feeOverridePda);
2991
+ if (feeOverrideExists) {
2992
+ const oracleVault = opts?.marketOracleVault ?? await this.getMarketOracleVault(condition, collateralMint) ?? payer;
2993
+ feeAccounts = [
2994
+ { pubkey: this.programIds.feeManagement, isSigner: false, isWritable: false },
2995
+ { pubkey: PDA.feeConfig(this.feeConfigOwner, this.programIds)[0], isSigner: false, isWritable: false },
2996
+ { pubkey: feeOverridePda, isSigner: false, isWritable: false },
2997
+ { pubkey: splToken.getAssociatedTokenAddressSync(collateralMint, companyAddr), isSigner: false, isWritable: true },
2998
+ { pubkey: oracleVault, isSigner: false, isWritable: true },
2999
+ { pubkey: refVault, isSigner: false, isWritable: true }
3000
+ ];
3001
+ }
3002
+ }
3003
+ }
3004
+ await this._ensureClobOutcomeAtas(yesMint, noMint, clobConfig, clobYesAta, clobNoAta);
3005
+ const hookInitIxs = [];
3006
+ if (this.hookClient) {
3007
+ for (const mint of [yesMint, noMint]) {
3008
+ const ix = await this.hookClient.buildInitHookIxIfNeeded(mint, payer);
3009
+ if (ix) hookInitIxs.push(ix);
3010
+ }
3011
+ }
3012
+ const mergeIx = await this.program.methods.batchMergeWithFee(orderPairs.length).accounts({
3013
+ operator,
3014
+ payer,
3015
+ clobConfig,
3016
+ condition,
3017
+ collateralVault,
3018
+ vaultTokenAccount,
3019
+ feeRecipient: cfg.feeRecipient,
3020
+ yesMint,
3021
+ noMint,
3022
+ clobYesAta,
3023
+ clobNoAta,
3024
+ clobYesPosition,
3025
+ clobNoPosition,
3026
+ conditionalTokensProgram: this.programIds.conditionalTokens,
3027
+ tokenProgram: splToken.TOKEN_PROGRAM_ID,
3028
+ token2022Program: splToken.TOKEN_2022_PROGRAM_ID,
3029
+ systemProgram: anchor5__namespace.web3.SystemProgram.programId
3030
+ }).remainingAccounts([...userAccounts, ...hookAccounts, ...feeAccounts]).instruction();
3031
+ const alt = opts?.lookupTable ?? await this.buildAltForCondition(condition, payer, collateralMint);
3032
+ return this._buildUnsignedVtx([...hookInitIxs, mergeIx], alt, payer);
3033
+ }
2752
3034
  /**
2753
3035
  * Build ALT for batchCollectRedeemEarly — includes per-user accounts so all
2754
3036
  * remaining_accounts fit as 1-byte ALT indices instead of 32-byte inline addresses.
@@ -9752,75 +10034,377 @@ var clob_exchange_default = {
9752
10034
  ]
9753
10035
  },
9754
10036
  {
9755
- name: "cancel_order",
10037
+ name: "batch_merge_with_fee",
9756
10038
  docs: [
9757
- "Cancel an order \u2014 close OrderRecord PDA, return rent to maker."
10039
+ "Batch merge YES+NO tokens before resolution. Returns net USDS to yes_signer, keeps fee.",
10040
+ "Mirrors EVM _matchMergeOrder flow."
9758
10041
  ],
9759
10042
  discriminator: [
9760
- 95,
9761
- 129,
9762
- 237,
9763
- 240,
9764
- 8,
9765
- 49,
9766
- 223,
9767
- 132
10043
+ 56,
10044
+ 127,
10045
+ 113,
10046
+ 232,
10047
+ 208,
10048
+ 177,
10049
+ 157,
10050
+ 230
9768
10051
  ],
9769
10052
  accounts: [
9770
10053
  {
9771
- name: "maker",
9772
- docs: [
9773
- "Must be the order maker/signer"
9774
- ],
10054
+ name: "operator",
9775
10055
  signer: true
9776
10056
  },
9777
10057
  {
9778
- name: "order_record",
10058
+ name: "payer",
10059
+ writable: true,
10060
+ signer: true
10061
+ },
10062
+ {
10063
+ name: "clob_config",
9779
10064
  writable: true,
9780
10065
  pda: {
9781
10066
  seeds: [
9782
10067
  {
9783
10068
  kind: "const",
9784
10069
  value: [
10070
+ 99,
10071
+ 108,
9785
10072
  111,
9786
- 114,
9787
- 100,
9788
- 101,
9789
- 114,
10073
+ 98,
9790
10074
  95,
9791
- 114,
9792
- 101,
9793
10075
  99,
9794
10076
  111,
9795
- 114,
9796
- 100
10077
+ 110,
10078
+ 102,
10079
+ 105,
10080
+ 103
9797
10081
  ]
9798
- },
9799
- {
9800
- kind: "account",
9801
- path: "maker"
9802
- },
9803
- {
9804
- kind: "arg",
9805
- path: "nonce"
9806
10082
  }
9807
10083
  ]
9808
10084
  }
9809
10085
  },
9810
10086
  {
9811
- name: "system_program",
9812
- address: "11111111111111111111111111111111"
9813
- }
9814
- ],
9815
- args: [
10087
+ name: "condition",
10088
+ writable: true
10089
+ },
9816
10090
  {
9817
- name: "nonce",
9818
- type: "u64"
9819
- }
9820
- ]
9821
- },
9822
- {
9823
- name: "force_reset_clob",
10091
+ name: "collateral_vault",
10092
+ writable: true,
10093
+ pda: {
10094
+ seeds: [
10095
+ {
10096
+ kind: "const",
10097
+ value: [
10098
+ 99,
10099
+ 111,
10100
+ 108,
10101
+ 108,
10102
+ 97,
10103
+ 116,
10104
+ 101,
10105
+ 114,
10106
+ 97,
10107
+ 108,
10108
+ 95,
10109
+ 118,
10110
+ 97,
10111
+ 117,
10112
+ 108,
10113
+ 116
10114
+ ]
10115
+ },
10116
+ {
10117
+ kind: "account",
10118
+ path: "condition.collateral_mint",
10119
+ account: "Condition"
10120
+ }
10121
+ ],
10122
+ program: {
10123
+ kind: "account",
10124
+ path: "conditional_tokens_program"
10125
+ }
10126
+ }
10127
+ },
10128
+ {
10129
+ name: "vault_token_account",
10130
+ writable: true
10131
+ },
10132
+ {
10133
+ name: "fee_recipient",
10134
+ docs: [
10135
+ "CLOB USDS ATA \u2014 receives USDS from merge, distributes to users + fee."
10136
+ ],
10137
+ writable: true
10138
+ },
10139
+ {
10140
+ name: "yes_mint",
10141
+ writable: true
10142
+ },
10143
+ {
10144
+ name: "no_mint",
10145
+ writable: true
10146
+ },
10147
+ {
10148
+ name: "clob_yes_ata",
10149
+ writable: true
10150
+ },
10151
+ {
10152
+ name: "clob_no_ata",
10153
+ writable: true
10154
+ },
10155
+ {
10156
+ name: "clob_yes_position",
10157
+ writable: true
10158
+ },
10159
+ {
10160
+ name: "clob_no_position",
10161
+ writable: true
10162
+ },
10163
+ {
10164
+ name: "conditional_tokens_program",
10165
+ address: "A6N1F8MRsdgcojAx8p6FaECvw8mo8w6qJcWsbKQBANK4"
10166
+ },
10167
+ {
10168
+ name: "token_program",
10169
+ address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
10170
+ },
10171
+ {
10172
+ name: "token_2022_program",
10173
+ address: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
10174
+ },
10175
+ {
10176
+ name: "system_program",
10177
+ address: "11111111111111111111111111111111"
10178
+ }
10179
+ ],
10180
+ args: [
10181
+ {
10182
+ name: "order_count",
10183
+ type: "u8"
10184
+ }
10185
+ ]
10186
+ },
10187
+ {
10188
+ name: "batch_redeem_with_fee",
10189
+ docs: [
10190
+ "Batch redeem YES+NO tokens after resolution. Returns net USDS to users, keeps fee.",
10191
+ "Mirrors EVM _matchRedeemOrder flow."
10192
+ ],
10193
+ discriminator: [
10194
+ 240,
10195
+ 238,
10196
+ 168,
10197
+ 110,
10198
+ 84,
10199
+ 41,
10200
+ 165,
10201
+ 2
10202
+ ],
10203
+ accounts: [
10204
+ {
10205
+ name: "operator",
10206
+ signer: true
10207
+ },
10208
+ {
10209
+ name: "payer",
10210
+ writable: true,
10211
+ signer: true
10212
+ },
10213
+ {
10214
+ name: "clob_config",
10215
+ writable: true,
10216
+ pda: {
10217
+ seeds: [
10218
+ {
10219
+ kind: "const",
10220
+ value: [
10221
+ 99,
10222
+ 108,
10223
+ 111,
10224
+ 98,
10225
+ 95,
10226
+ 99,
10227
+ 111,
10228
+ 110,
10229
+ 102,
10230
+ 105,
10231
+ 103
10232
+ ]
10233
+ }
10234
+ ]
10235
+ }
10236
+ },
10237
+ {
10238
+ name: "condition",
10239
+ writable: true
10240
+ },
10241
+ {
10242
+ name: "collateral_vault",
10243
+ writable: true,
10244
+ pda: {
10245
+ seeds: [
10246
+ {
10247
+ kind: "const",
10248
+ value: [
10249
+ 99,
10250
+ 111,
10251
+ 108,
10252
+ 108,
10253
+ 97,
10254
+ 116,
10255
+ 101,
10256
+ 114,
10257
+ 97,
10258
+ 108,
10259
+ 95,
10260
+ 118,
10261
+ 97,
10262
+ 117,
10263
+ 108,
10264
+ 116
10265
+ ]
10266
+ },
10267
+ {
10268
+ kind: "account",
10269
+ path: "condition.collateral_mint",
10270
+ account: "Condition"
10271
+ }
10272
+ ],
10273
+ program: {
10274
+ kind: "account",
10275
+ path: "conditional_tokens_program"
10276
+ }
10277
+ }
10278
+ },
10279
+ {
10280
+ name: "vault_token_account",
10281
+ writable: true
10282
+ },
10283
+ {
10284
+ name: "fee_recipient",
10285
+ docs: [
10286
+ "CLOB USDS ATA \u2014 receives USDS from redeem, distributes to users + fee."
10287
+ ],
10288
+ writable: true
10289
+ },
10290
+ {
10291
+ name: "yes_mint",
10292
+ writable: true
10293
+ },
10294
+ {
10295
+ name: "no_mint",
10296
+ writable: true
10297
+ },
10298
+ {
10299
+ name: "clob_yes_ata",
10300
+ writable: true
10301
+ },
10302
+ {
10303
+ name: "clob_no_ata",
10304
+ writable: true
10305
+ },
10306
+ {
10307
+ name: "clob_yes_position",
10308
+ writable: true
10309
+ },
10310
+ {
10311
+ name: "clob_no_position",
10312
+ writable: true
10313
+ },
10314
+ {
10315
+ name: "conditional_tokens_program",
10316
+ address: "A6N1F8MRsdgcojAx8p6FaECvw8mo8w6qJcWsbKQBANK4"
10317
+ },
10318
+ {
10319
+ name: "token_program",
10320
+ address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
10321
+ },
10322
+ {
10323
+ name: "token_2022_program",
10324
+ address: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
10325
+ },
10326
+ {
10327
+ name: "system_program",
10328
+ address: "11111111111111111111111111111111"
10329
+ }
10330
+ ],
10331
+ args: [
10332
+ {
10333
+ name: "order_count",
10334
+ type: "u8"
10335
+ }
10336
+ ]
10337
+ },
10338
+ {
10339
+ name: "cancel_order",
10340
+ docs: [
10341
+ "Cancel an order \u2014 close OrderRecord PDA, return rent to maker."
10342
+ ],
10343
+ discriminator: [
10344
+ 95,
10345
+ 129,
10346
+ 237,
10347
+ 240,
10348
+ 8,
10349
+ 49,
10350
+ 223,
10351
+ 132
10352
+ ],
10353
+ accounts: [
10354
+ {
10355
+ name: "maker",
10356
+ docs: [
10357
+ "Must be the order maker/signer"
10358
+ ],
10359
+ signer: true
10360
+ },
10361
+ {
10362
+ name: "order_record",
10363
+ writable: true,
10364
+ pda: {
10365
+ seeds: [
10366
+ {
10367
+ kind: "const",
10368
+ value: [
10369
+ 111,
10370
+ 114,
10371
+ 100,
10372
+ 101,
10373
+ 114,
10374
+ 95,
10375
+ 114,
10376
+ 101,
10377
+ 99,
10378
+ 111,
10379
+ 114,
10380
+ 100
10381
+ ]
10382
+ },
10383
+ {
10384
+ kind: "account",
10385
+ path: "maker"
10386
+ },
10387
+ {
10388
+ kind: "arg",
10389
+ path: "nonce"
10390
+ }
10391
+ ]
10392
+ }
10393
+ },
10394
+ {
10395
+ name: "system_program",
10396
+ address: "11111111111111111111111111111111"
10397
+ }
10398
+ ],
10399
+ args: [
10400
+ {
10401
+ name: "nonce",
10402
+ type: "u64"
10403
+ }
10404
+ ]
10405
+ },
10406
+ {
10407
+ name: "force_reset_clob",
9824
10408
  discriminator: [
9825
10409
  96,
9826
10410
  95,
@@ -10911,6 +11495,107 @@ var clob_exchange_default = {
10911
11495
  }
10912
11496
  ]
10913
11497
  },
11498
+ {
11499
+ name: "register_redeem_fee_order",
11500
+ docs: [
11501
+ "Register a signed RedeemFeeOrder on-chain (Ed25519 verify + PDA creation).",
11502
+ "Prerequisite for batch_redeem_with_fee and batch_merge_with_fee."
11503
+ ],
11504
+ discriminator: [
11505
+ 129,
11506
+ 167,
11507
+ 199,
11508
+ 14,
11509
+ 217,
11510
+ 12,
11511
+ 76,
11512
+ 162
11513
+ ],
11514
+ accounts: [
11515
+ {
11516
+ name: "payer",
11517
+ writable: true,
11518
+ signer: true
11519
+ },
11520
+ {
11521
+ name: "clob_config",
11522
+ pda: {
11523
+ seeds: [
11524
+ {
11525
+ kind: "const",
11526
+ value: [
11527
+ 99,
11528
+ 108,
11529
+ 111,
11530
+ 98,
11531
+ 95,
11532
+ 99,
11533
+ 111,
11534
+ 110,
11535
+ 102,
11536
+ 105,
11537
+ 103
11538
+ ]
11539
+ }
11540
+ ]
11541
+ }
11542
+ },
11543
+ {
11544
+ name: "ix_sysvar",
11545
+ address: "Sysvar1nstructions1111111111111111111111111"
11546
+ },
11547
+ {
11548
+ name: "order_signer"
11549
+ },
11550
+ {
11551
+ name: "redeem_fee_order_record",
11552
+ writable: true,
11553
+ pda: {
11554
+ seeds: [
11555
+ {
11556
+ kind: "const",
11557
+ value: [
11558
+ 114,
11559
+ 101,
11560
+ 100,
11561
+ 101,
11562
+ 101,
11563
+ 109,
11564
+ 95,
11565
+ 102,
11566
+ 101,
11567
+ 101,
11568
+ 95,
11569
+ 111,
11570
+ 114,
11571
+ 100,
11572
+ 101,
11573
+ 114
11574
+ ]
11575
+ },
11576
+ {
11577
+ kind: "account",
11578
+ path: "order_signer"
11579
+ },
11580
+ {
11581
+ kind: "arg",
11582
+ path: "nonce"
11583
+ }
11584
+ ]
11585
+ }
11586
+ },
11587
+ {
11588
+ name: "system_program",
11589
+ address: "11111111111111111111111111111111"
11590
+ }
11591
+ ],
11592
+ args: [
11593
+ {
11594
+ name: "nonce",
11595
+ type: "u64"
11596
+ }
11597
+ ]
11598
+ },
10914
11599
  {
10915
11600
  name: "reinit_clob",
10916
11601
  discriminator: [
@@ -11101,6 +11786,19 @@ var clob_exchange_default = {
11101
11786
  3
11102
11787
  ]
11103
11788
  },
11789
+ {
11790
+ name: "RedeemFeeOrderRecord",
11791
+ discriminator: [
11792
+ 88,
11793
+ 3,
11794
+ 122,
11795
+ 192,
11796
+ 131,
11797
+ 243,
11798
+ 143,
11799
+ 146
11800
+ ]
11801
+ },
11104
11802
  {
11105
11803
  name: "SignedOrderRecord",
11106
11804
  discriminator: [
@@ -11576,6 +12274,57 @@ var clob_exchange_default = {
11576
12274
  ]
11577
12275
  }
11578
12276
  },
12277
+ {
12278
+ name: "RedeemFeeOrderRecord",
12279
+ docs: [
12280
+ "On-chain record of a signed RedeemFeeOrder.",
12281
+ "Created by `register_redeem_fee_order` after Ed25519 verification.",
12282
+ "Read and marked collected by `batch_redeem_with_fee` / `batch_merge_with_fee`.",
12283
+ "",
12284
+ 'PDA seeds: [b"redeem_fee_order", user, nonce_le_bytes]'
12285
+ ],
12286
+ type: {
12287
+ kind: "struct",
12288
+ fields: [
12289
+ {
12290
+ name: "user",
12291
+ type: "pubkey"
12292
+ },
12293
+ {
12294
+ name: "condition",
12295
+ type: "pubkey"
12296
+ },
12297
+ {
12298
+ name: "token_mint",
12299
+ type: "pubkey"
12300
+ },
12301
+ {
12302
+ name: "amount",
12303
+ type: "u64"
12304
+ },
12305
+ {
12306
+ name: "taker_amount",
12307
+ type: "u64"
12308
+ },
12309
+ {
12310
+ name: "nonce",
12311
+ type: "u64"
12312
+ },
12313
+ {
12314
+ name: "expiry",
12315
+ type: "i64"
12316
+ },
12317
+ {
12318
+ name: "is_collected",
12319
+ type: "bool"
12320
+ },
12321
+ {
12322
+ name: "bump",
12323
+ type: "u8"
12324
+ }
12325
+ ]
12326
+ }
12327
+ },
11579
12328
  {
11580
12329
  name: "SignedOrderRecord",
11581
12330
  docs: [
@@ -18176,6 +18925,7 @@ exports.buildApproveAllOutcomeTokensTx = buildApproveAllOutcomeTokensTx;
18176
18925
  exports.buildApproveCollateralTx = buildApproveCollateralTx;
18177
18926
  exports.buildBatchedCollectFeeEd25519Instruction = buildBatchedCollectFeeEd25519Instruction;
18178
18927
  exports.buildBatchedEd25519Instruction = buildBatchedEd25519Instruction;
18928
+ exports.buildBatchedRedeemFeeEd25519Instruction = buildBatchedRedeemFeeEd25519Instruction;
18179
18929
  exports.buildCreateUserAtasTx = buildCreateUserAtasTx;
18180
18930
  exports.buildOrder = buildOrder;
18181
18931
  exports.buildOrderFromPrice = buildOrderFromPrice;
@@ -18187,6 +18937,7 @@ exports.getOrderSignBytes = getOrderSignBytes;
18187
18937
  exports.orderAmountsFromPrice = orderAmountsFromPrice;
18188
18938
  exports.serializeCollectFeeOrderToBytes = serializeCollectFeeOrderToBytes;
18189
18939
  exports.serializeOrderToBytes = serializeOrderToBytes;
18940
+ exports.serializeRedeemFeeOrderToBytes = serializeRedeemFeeOrderToBytes;
18190
18941
  exports.serializeSignedOrder = serializeSignedOrder;
18191
18942
  exports.signOrder = signOrder;
18192
18943
  exports.signOrderWithKeypair = signOrderWithKeypair;