@optimex-xyz/market-maker-sdk 0.4.8 → 0.4.9

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/README.md CHANGED
@@ -127,13 +127,12 @@ Provides an indicative quote for the given token pair and trade amount. The quot
127
127
  - **Query Parameters**:
128
128
  - `from_token_id` (string): The ID of the source token.
129
129
  - `to_token_id` (string): The ID of the destination token.
130
- - `amount` (string): The amount of the source token to be traded, represented as a string in base 10 to accommodate large numbers.
131
- - `session_id` (string, optional): A unique identifier for the session.
130
+ - `amount` (string): The amount of the source token to be traded, represented as a string in base 10 to accommodate large numbers. This should be treated as a BigInt in your implementation.
132
131
 
133
132
  #### Example Request
134
133
 
135
134
  ```
136
- GET /indicative-quote?from_token_id=ETH&to_token_id=BTC&amount=1000000000000000000&session_id=12345
135
+ GET /indicative-quote?from_token_id=ETH&to_token_id=BTC&amount=1000000000000000000
137
136
  ```
138
137
 
139
138
  #### Expected Response
@@ -152,7 +151,7 @@ GET /indicative-quote?from_token_id=ETH&to_token_id=BTC&amount=10000000000000000
152
151
 
153
152
  - `session_id` (string): The session ID associated with the request.
154
153
  - `pmm_receiving_address` (string): The receiving address where the user will send the `from_token`.
155
- - `indicative_quote` (string): The indicative quote value, represented as a string.
154
+ - `indicative_quote` (string): The indicative quote value, represented as a string. Should be treated as a BigInt in your implementation.
156
155
  - `error` (string): Error message, if any (empty if no error).
157
156
 
158
157
  #### Example Implementation
@@ -183,7 +182,9 @@ async function getIndicativeQuote(req, res) {
183
182
  }
184
183
 
185
184
  // Calculate the quote (implementation specific to your PMM)
186
- const quote = calculateQuote(fromToken, toToken, amount);
185
+ // Note: Treat amount as BigInt
186
+ const amountBigInt = BigInt(amount);
187
+ const quote = calculateQuote(fromToken, toToken, amountBigInt);
187
188
 
188
189
  // Get the receiving address for this token pair
189
190
  const pmmReceivingAddress = getPMMReceivingAddress(fromToken.network_id);
@@ -191,7 +192,7 @@ async function getIndicativeQuote(req, res) {
191
192
  return res.status(200).json({
192
193
  session_id: sessionId,
193
194
  pmm_receiving_address: pmmReceivingAddress,
194
- indicative_quote: quote,
195
+ indicative_quote: quote.toString(),
195
196
  error: ''
196
197
  });
197
198
  } catch (error) {
@@ -216,21 +217,21 @@ Provides a commitment quote for a specific trade, representing a firm commitment
216
217
  - **HTTP Method**: `GET`
217
218
  - **Query Parameters**:
218
219
  - `session_id` (string): A unique identifier for the session.
219
- - `trade_id` (string): The unique identifier for the trade.
220
+ - `trade_id` (string): The unique identifier for the trade. Example format: `0x3bfe2fc4889a98a39b31b348e7b212ea3f2bea63fd1ea2e0c8ba326433677328`.
220
221
  - `from_token_id` (string): The ID of the source token.
221
222
  - `to_token_id` (string): The ID of the destination token.
222
- - `amount` (string): The amount of the source token to be traded, in base 10.
223
+ - `amount` (string): The amount of the source token to be traded, in base 10. This should be treated as a BigInt in your implementation.
223
224
  - `from_user_address` (string): The address of the user initiating the trade.
224
225
  - `to_user_address` (string): The address where the user will receive the `to_token`.
225
226
  - `user_deposit_tx` (string): The transaction hash where the user deposited their funds.
226
227
  - `user_deposit_vault` (string): The vault where the user's deposit is kept.
227
- - `trade_deadline` (string): The UNIX timestamp (in seconds) by which the user expects to receive payment.
228
- - `script_deadline` (string): The UNIX timestamp (in seconds) after which the user can withdraw their deposit if not paid.
228
+ - `trade_deadline` (string): The UNIX timestamp (in seconds) by which the user expects to receive payment. Should be treated as a BigInt in your implementation.
229
+ - `script_deadline` (string): The UNIX timestamp (in seconds) after which the user can withdraw their deposit if not paid. Should be treated as a BigInt in your implementation.
229
230
 
230
231
  #### Example Request
231
232
 
232
233
  ```
233
- GET /commitment-quote?session_id=12345&trade_id=abcd1234&from_token_id=ETH&to_token_id=BTC&amount=1000000000000000000&from_user_address=0xUserAddress&to_user_address=0xReceivingAddress&user_deposit_tx=0xDepositTxHash&user_deposit_vault=VaultData&trade_deadline=1696012800&script_deadline=1696016400
234
+ GET /commitment-quote?session_id=12345&trade_id=0x3bfe2fc4889a98a39b31b348e7b212ea3f2bea63fd1ea2e0c8ba326433677328&from_token_id=ETH&to_token_id=BTC&amount=1000000000000000000&from_user_address=0xUserAddress&to_user_address=0xReceivingAddress&user_deposit_tx=0xDepositTxHash&user_deposit_vault=VaultData&trade_deadline=1696012800&script_deadline=1696016400
234
235
  ```
235
236
 
236
237
  #### Expected Response
@@ -240,14 +241,14 @@ GET /commitment-quote?session_id=12345&trade_id=abcd1234&from_token_id=ETH&to_to
240
241
 
241
242
  ```json
242
243
  {
243
- "trade_id": "abcd1234",
244
+ "trade_id": "0x3bfe2fc4889a98a39b31b348e7b212ea3f2bea63fd1ea2e0c8ba326433677328",
244
245
  "commitment_quote": "987654321000000000",
245
246
  "error": "" // Empty if no error
246
247
  }
247
248
  ```
248
249
 
249
250
  - `trade_id` (string): The trade ID associated with the request.
250
- - `commitment_quote` (string): The committed quote value, represented as a string.
251
+ - `commitment_quote` (string): The committed quote value, represented as a string. Should be treated as a BigInt in your implementation.
251
252
  - `error` (string): Error message, if any (empty if no error).
252
253
 
253
254
  #### Example Implementation
@@ -296,7 +297,9 @@ async function getCommitmentQuote(req, res) {
296
297
  }
297
298
 
298
299
  // Calculate the final quote (implementation specific to your PMM)
299
- const quote = calculateFinalQuote(fromToken, toToken, amount, trade_deadline);
300
+ // Note: Treat numeric values as BigInt
301
+ const amountBigInt = BigInt(amount);
302
+ const quote = calculateFinalQuote(fromToken, toToken, amountBigInt, trade_deadline);
300
303
 
301
304
  // Store the trade in the database
302
305
  await tradeRepository.create({
@@ -304,19 +307,19 @@ async function getCommitmentQuote(req, res) {
304
307
  sessionId: session_id,
305
308
  fromTokenId: from_token_id,
306
309
  toTokenId: to_token_id,
307
- amount,
310
+ amount: amountBigInt.toString(),
308
311
  fromUserAddress: from_user_address,
309
312
  toUserAddress: to_user_address,
310
313
  userDepositTx: user_deposit_tx,
311
314
  userDepositVault: user_deposit_vault,
312
315
  tradeDeadline: trade_deadline,
313
316
  scriptDeadline: script_deadline,
314
- commitmentQuote: quote
317
+ commitmentQuote: quote.toString()
315
318
  });
316
319
 
317
320
  return res.status(200).json({
318
321
  trade_id,
319
- commitment_quote: quote,
322
+ commitment_quote: quote.toString(),
320
323
  error: ''
321
324
  });
322
325
  } catch (error) {
@@ -339,15 +342,16 @@ Returns a signature from the PMM to confirm the settlement quote, required to fi
339
342
 
340
343
  - **HTTP Method**: `GET`
341
344
  - **Query Parameters**:
342
- - `trade_id` (string): The unique identifier for the trade.
343
- - `committed_quote` (string): The committed quote value in base 10.
345
+ - `trade_id` (string): The unique identifier for the trade. Example format: `0x3d09b8eb94466bffa126aeda68c8c0f330633a7d0058f57269d795530415498a`.
346
+ - `committed_quote` (string): The committed quote value in base 10. This should be treated as a BigInt in your implementation.
344
347
  - `trade_deadline` (string): The UNIX timestamp (in seconds) by which the user expects to receive payment.
345
348
  - `script_deadline` (string): The UNIX timestamp (in seconds) after which the user can withdraw their deposit if not paid.
346
349
 
350
+
347
351
  #### Example Request
348
352
 
349
353
  ```
350
- GET /settlement-signature?trade_id=abcd1234&committed_quote=987654321000000000&trade_deadline=1696012800&script_deadline=1696016400
354
+ GET /settlement-signature?trade_id=0x3d09b8eb94466bffa126aeda68c8c0f330633a7d0058f57269d795530415498a&committed_quote=987654321000000000&trade_deadline=1696012800&script_deadline=1696016400
351
355
  ```
352
356
 
353
357
  #### Expected Response
@@ -357,7 +361,7 @@ GET /settlement-signature?trade_id=abcd1234&committed_quote=987654321000000000&t
357
361
 
358
362
  ```json
359
363
  {
360
- "trade_id": "abcd1234",
364
+ "trade_id": "0x3d09b8eb94466bffa126aeda68c8c0f330633a7d0058f57269d795530415498a",
361
365
  "signature": "0xSignatureData",
362
366
  "deadline": 1696012800,
363
367
  "error": "" // Empty if no error
@@ -401,12 +405,14 @@ async function getSettlementSignature(req, res) {
401
405
  const { from_token, to_token } = tradeDetails.data;
402
406
 
403
407
  // Create a commitment info hash
408
+ // Note: Treat numeric values as BigInt
409
+ const committedQuoteBigInt = BigInt(committed_quote);
404
410
  const commitInfoHash = createCommitInfoHash(
405
411
  pmmId,
406
412
  trade.pmmReceivingAddress,
407
413
  to_token.chain,
408
414
  to_token.address,
409
- committed_quote,
415
+ committedQuoteBigInt,
410
416
  deadline
411
417
  );
412
418
 
@@ -441,7 +447,7 @@ Used by the solver to acknowledge to the PMM about a successful settlement, indi
441
447
 
442
448
  - **HTTP Method**: `POST`
443
449
  - **Form Parameters**:
444
- - `trade_id` (string): The unique identifier for the trade.
450
+ - `trade_id` (string): The unique identifier for the trade. Example format: `0x024be4dae899989e0c3d9b4459e5811613bcd04016dc56529f16a19d2a7724c0`.
445
451
  - `trade_deadline` (string): The UNIX timestamp (in seconds) by which the user expects to receive payment.
446
452
  - `script_deadline` (string): The UNIX timestamp (in seconds) after which the user can withdraw their deposit if not paid.
447
453
  - `chosen` (string): `"true"` if the PMM is selected, `"false"` otherwise.
@@ -452,7 +458,7 @@ Used by the solver to acknowledge to the PMM about a successful settlement, indi
452
458
  POST /ack-settlement
453
459
  Content-Type: application/x-www-form-urlencoded
454
460
 
455
- trade_id=abcd1234&trade_deadline=1696012800&script_deadline=1696016400&chosen=true
461
+ trade_id=0x024be4dae899989e0c3d9b4459e5811613bcd04016dc56529f16a19d2a7724c0&trade_deadline=1696012800&script_deadline=1696016400&chosen=true
456
462
  ```
457
463
 
458
464
  #### Expected Response
@@ -462,7 +468,7 @@ trade_id=abcd1234&trade_deadline=1696012800&script_deadline=1696016400&chosen=tr
462
468
 
463
469
  ```json
464
470
  {
465
- "trade_id": "abcd1234",
471
+ "trade_id": "0x024be4dae899989e0c3d9b4459e5811613bcd04016dc56529f16a19d2a7724c0",
466
472
  "status": "acknowledged",
467
473
  "error": "" // Empty if no error
468
474
  }
@@ -521,10 +527,10 @@ Used by the solver to signal the chosen PMM to start submitting their payment.
521
527
 
522
528
  - **HTTP Method**: `POST`
523
529
  - **Form Parameters**:
524
- - `trade_id` (string): The unique identifier for the trade.
525
- - `total_fee_amount` (string): The amount of total fee the PMM has to submit, in base 10.
530
+ - `trade_id` (string): The unique identifier for the trade. Example format: `0x3bfe2fc4889a98a39b31b348e7b212ea3f2bea63fd1ea2e0c8ba326433677328`.
526
531
  - `trade_deadline` (string): The UNIX timestamp (in seconds) by which the user expects to receive payment.
527
532
  - `script_deadline` (string): The UNIX timestamp (in seconds) after which the user can withdraw their deposit if not paid.
533
+ - `total_fee_amount` (string): The amount of total fee the PMM has to submit, in base 10. This should be treated as a BigInt in your implementation.
528
534
 
529
535
  #### Example Request
530
536
 
@@ -532,7 +538,7 @@ Used by the solver to signal the chosen PMM to start submitting their payment.
532
538
  POST /signal-payment
533
539
  Content-Type: application/x-www-form-urlencoded
534
540
 
535
- trade_id=abcd1234&total_fee_amount=1000000000000000&trade_deadline=1696012800&script_deadline=1696016400
541
+ trade_id=0x3bfe2fc4889a98a39b31b348e7b212ea3f2bea63fd1ea2e0c8ba326433677328&total_fee_amount=1000000000000000&trade_deadline=1696012800&script_deadline=1696016400
536
542
  ```
537
543
 
538
544
  #### Expected Response
@@ -542,7 +548,7 @@ trade_id=abcd1234&total_fee_amount=1000000000000000&trade_deadline=1696012800&sc
542
548
 
543
549
  ```json
544
550
  {
545
- "trade_id": "abcd1234",
551
+ "trade_id": "0x3bfe2fc4889a98a39b31b348e7b212ea3f2bea63fd1ea2e0c8ba326433677328",
546
552
  "status": "acknowledged",
547
553
  "error": "" // Empty if no error
548
554
  }
@@ -721,7 +727,7 @@ Allows the PMM to submit the settlement transaction hash for one or more trades.
721
727
 
722
728
  - `trade_ids` (array of strings): An array of trade IDs associated with the settlement transaction.
723
729
  - `pmm_id` (string): The PMM's ID, which must match the one committed for the trade(s).
724
- - `settlement_tx` (string): The raw transaction data representing the settlement.
730
+ - `settlement_tx` (string): The txHash of the settlement.
725
731
  - `signature` (string): The PMM's signature on the settlement transaction.
726
732
  - `start_index` (integer): The index indicating the starting point for settlement processing (used for batch settlements).
727
733
  - `signed_at` (integer): The UNIX timestamp (in seconds) when the PMM signed the settlement transaction.
@@ -849,3 +855,123 @@ In case the target chain is Bitcoin, the transaction should have at least N + 1
849
855
  Example implementation:
850
856
 
851
857
  ```js
858
+ import * as bitcoin from 'bitcoinjs-lib'
859
+ import { ECPairFactory } from 'ecpair'
860
+ import * as ecc from 'tiny-secp256k1'
861
+ import axios from 'axios'
862
+ import { getTradeIdsHash } from '@optimex-xyz/market-maker-sdk'
863
+
864
+ async function makeBitcoinPayment(params) {
865
+ const { toAddress, amount, token, tradeId } = params
866
+ const ECPair = ECPairFactory(ecc)
867
+
868
+ // Set up Bitcoin library
869
+ bitcoin.initEccLib(ecc)
870
+
871
+ // Get network configuration
872
+ const network = getNetwork(token.networkId)
873
+ const rpcUrl = getRpcUrl(token.networkId)
874
+
875
+ // Create keypair from private key
876
+ const keyPair = ECPair.fromWIF(process.env.PMM_BTC_PRIVATE_KEY, network)
877
+ const payment = bitcoin.payments.p2tr({
878
+ internalPubkey: Buffer.from(keyPair.publicKey.slice(1, 33)),
879
+ network,
880
+ })
881
+
882
+ if (!payment.address) {
883
+ throw new Error('Could not generate address')
884
+ }
885
+
886
+ // Get UTXOs for the address
887
+ const utxos = await getUTXOs(payment.address, rpcUrl)
888
+ if (utxos.length === 0) {
889
+ throw new Error(`No UTXOs found in ${token.networkSymbol} wallet`)
890
+ }
891
+
892
+ // Create and sign transaction
893
+ const psbt = new bitcoin.Psbt({ network })
894
+ let totalInput = 0n
895
+
896
+ // Add inputs
897
+ for (const utxo of utxos) {
898
+ if (!payment.output) {
899
+ throw new Error('Could not generate output script')
900
+ }
901
+
902
+ const internalKey = Buffer.from(keyPair.publicKey.slice(1, 33))
903
+
904
+ psbt.addInput({
905
+ hash: utxo.txid,
906
+ index: utxo.vout,
907
+ witnessUtxo: {
908
+ script: payment.output,
909
+ value: BigInt(utxo.value),
910
+ },
911
+ tapInternalKey: internalKey,
912
+ })
913
+
914
+ totalInput += BigInt(utxo.value)
915
+ }
916
+
917
+ // Check if we have enough balance
918
+ if (totalInput < amount) {
919
+ throw new Error(
920
+ `Insufficient balance. Need ${amount} satoshis, but only have ${totalInput} satoshis`
921
+ )
922
+ }
923
+
924
+ // Get fee rate
925
+ const feeRate = await getFeeRate(rpcUrl)
926
+ const fee = BigInt(Math.ceil(200 * feeRate))
927
+ const changeAmount = totalInput - amount - fee
928
+
929
+ // Add recipient output
930
+ psbt.addOutput({
931
+ address: toAddress,
932
+ value: amount,
933
+ })
934
+
935
+ // Add change output if needed
936
+ if (changeAmount > 546n) {
937
+ psbt.addOutput({
938
+ address: payment.address,
939
+ value: changeAmount,
940
+ })
941
+ }
942
+
943
+ // Add OP_RETURN output with trade ID hash
944
+ const tradeIdsHash = getTradeIdsHash([tradeId])
945
+ psbt.addOutput({
946
+ script: bitcoin.script.compile([
947
+ bitcoin.opcodes.OP_RETURN,
948
+ Buffer.from(tradeIdsHash.slice(2), 'hex')
949
+ ]),
950
+ value: 0n,
951
+ })
952
+
953
+ // Sign inputs
954
+ const toXOnly = (pubKey) => (pubKey.length === 32 ? pubKey : pubKey.slice(1, 33))
955
+ const tweakedSigner = keyPair.tweak(bitcoin.crypto.taggedHash('TapTweak', toXOnly(keyPair.publicKey)))
956
+
957
+ for (let i = 0; i < psbt.data.inputs.length; i++) {
958
+ psbt.signInput(i, tweakedSigner, [bitcoin.Transaction.SIGHASH_DEFAULT])
959
+ }
960
+
961
+ psbt.finalizeAllInputs()
962
+
963
+ // Extract transaction
964
+ const tx = psbt.extractTransaction()
965
+ const rawTx = tx.toHex()
966
+
967
+ // Broadcast transaction
968
+ const response = await axios.post(`${rpcUrl}/api/tx`, rawTx, {
969
+ headers: {
970
+ 'Content-Type': 'text/plain',
971
+ },
972
+ })
973
+
974
+ return response.data // Transaction ID
975
+ }
976
+
977
+ ```
package/dist/index.d.mts CHANGED
@@ -4719,7 +4719,6 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
4719
4719
  amountAfterFees: z.ZodString;
4720
4720
  fromUserAddress: z.ZodString;
4721
4721
  userReceivingAddress: z.ZodString;
4722
- deadline: z.ZodNumber;
4723
4722
  protocolFeeInBps: z.ZodString;
4724
4723
  protocolMpcPubkey: z.ZodString;
4725
4724
  protocolMpcAddress: z.ZodString;
@@ -4745,7 +4744,6 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
4745
4744
  pmmFailureStats: z.ZodRecord<z.ZodString, z.ZodNumber>;
4746
4745
  commitedSignature: z.ZodString;
4747
4746
  minAmountOut: z.ZodNull;
4748
- sessionDeadline: z.ZodNumber;
4749
4747
  userDepositTx: z.ZodString;
4750
4748
  depositVault: z.ZodString;
4751
4749
  paymentBundle: z.ZodObject<{
@@ -4777,12 +4775,20 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
4777
4775
  state: z.ZodString;
4778
4776
  lastUpdateMsg: z.ZodString;
4779
4777
  version: z.ZodNumber;
4778
+ scriptTimeout: z.ZodNumber;
4779
+ affiliateFeeInBps: z.ZodString;
4780
+ totalFee: z.ZodString;
4781
+ protocolFee: z.ZodString;
4782
+ affiliateFee: z.ZodString;
4783
+ tradeTimeout: z.ZodNumber;
4780
4784
  }, "strip", z.ZodTypeAny, {
4781
4785
  version: number;
4782
- deadline: number;
4783
4786
  tradeId: string;
4787
+ totalFee: string;
4784
4788
  minAmountOut: null;
4789
+ tradeTimeout: number;
4785
4790
  sessionId: string;
4791
+ scriptTimeout: number;
4786
4792
  solverAddress: string;
4787
4793
  fromToken: {
4788
4794
  address: string;
@@ -4820,7 +4826,6 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
4820
4826
  commitmentRetries: number;
4821
4827
  pmmFailureStats: Record<string, number>;
4822
4828
  commitedSignature: string;
4823
- sessionDeadline: number;
4824
4829
  userDepositTx: string;
4825
4830
  depositVault: string;
4826
4831
  paymentBundle: {
@@ -4837,12 +4842,17 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
4837
4842
  tradeMakePaymentTx: string;
4838
4843
  state: string;
4839
4844
  lastUpdateMsg: string;
4845
+ affiliateFeeInBps: string;
4846
+ protocolFee: string;
4847
+ affiliateFee: string;
4840
4848
  }, {
4841
4849
  version: number;
4842
- deadline: number;
4843
4850
  tradeId: string;
4851
+ totalFee: string;
4844
4852
  minAmountOut: null;
4853
+ tradeTimeout: number;
4845
4854
  sessionId: string;
4855
+ scriptTimeout: number;
4846
4856
  solverAddress: string;
4847
4857
  fromToken: {
4848
4858
  address: string;
@@ -4880,7 +4890,6 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
4880
4890
  commitmentRetries: number;
4881
4891
  pmmFailureStats: Record<string, number>;
4882
4892
  commitedSignature: string;
4883
- sessionDeadline: number;
4884
4893
  userDepositTx: string;
4885
4894
  depositVault: string;
4886
4895
  paymentBundle: {
@@ -4897,15 +4906,20 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
4897
4906
  tradeMakePaymentTx: string;
4898
4907
  state: string;
4899
4908
  lastUpdateMsg: string;
4909
+ affiliateFeeInBps: string;
4910
+ protocolFee: string;
4911
+ affiliateFee: string;
4900
4912
  }>;
4901
4913
  traceId: z.ZodString;
4902
4914
  }, "strip", z.ZodTypeAny, {
4903
4915
  data: {
4904
4916
  version: number;
4905
- deadline: number;
4906
4917
  tradeId: string;
4918
+ totalFee: string;
4907
4919
  minAmountOut: null;
4920
+ tradeTimeout: number;
4908
4921
  sessionId: string;
4922
+ scriptTimeout: number;
4909
4923
  solverAddress: string;
4910
4924
  fromToken: {
4911
4925
  address: string;
@@ -4943,7 +4957,6 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
4943
4957
  commitmentRetries: number;
4944
4958
  pmmFailureStats: Record<string, number>;
4945
4959
  commitedSignature: string;
4946
- sessionDeadline: number;
4947
4960
  userDepositTx: string;
4948
4961
  depositVault: string;
4949
4962
  paymentBundle: {
@@ -4960,15 +4973,20 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
4960
4973
  tradeMakePaymentTx: string;
4961
4974
  state: string;
4962
4975
  lastUpdateMsg: string;
4976
+ affiliateFeeInBps: string;
4977
+ protocolFee: string;
4978
+ affiliateFee: string;
4963
4979
  };
4964
4980
  traceId: string;
4965
4981
  }, {
4966
4982
  data: {
4967
4983
  version: number;
4968
- deadline: number;
4969
4984
  tradeId: string;
4985
+ totalFee: string;
4970
4986
  minAmountOut: null;
4987
+ tradeTimeout: number;
4971
4988
  sessionId: string;
4989
+ scriptTimeout: number;
4972
4990
  solverAddress: string;
4973
4991
  fromToken: {
4974
4992
  address: string;
@@ -5006,7 +5024,6 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
5006
5024
  commitmentRetries: number;
5007
5025
  pmmFailureStats: Record<string, number>;
5008
5026
  commitedSignature: string;
5009
- sessionDeadline: number;
5010
5027
  userDepositTx: string;
5011
5028
  depositVault: string;
5012
5029
  paymentBundle: {
@@ -5023,6 +5040,9 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
5023
5040
  tradeMakePaymentTx: string;
5024
5041
  state: string;
5025
5042
  lastUpdateMsg: string;
5043
+ affiliateFeeInBps: string;
5044
+ protocolFee: string;
5045
+ affiliateFee: string;
5026
5046
  };
5027
5047
  traceId: string;
5028
5048
  }>;
package/dist/index.d.ts CHANGED
@@ -4719,7 +4719,6 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
4719
4719
  amountAfterFees: z.ZodString;
4720
4720
  fromUserAddress: z.ZodString;
4721
4721
  userReceivingAddress: z.ZodString;
4722
- deadline: z.ZodNumber;
4723
4722
  protocolFeeInBps: z.ZodString;
4724
4723
  protocolMpcPubkey: z.ZodString;
4725
4724
  protocolMpcAddress: z.ZodString;
@@ -4745,7 +4744,6 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
4745
4744
  pmmFailureStats: z.ZodRecord<z.ZodString, z.ZodNumber>;
4746
4745
  commitedSignature: z.ZodString;
4747
4746
  minAmountOut: z.ZodNull;
4748
- sessionDeadline: z.ZodNumber;
4749
4747
  userDepositTx: z.ZodString;
4750
4748
  depositVault: z.ZodString;
4751
4749
  paymentBundle: z.ZodObject<{
@@ -4777,12 +4775,20 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
4777
4775
  state: z.ZodString;
4778
4776
  lastUpdateMsg: z.ZodString;
4779
4777
  version: z.ZodNumber;
4778
+ scriptTimeout: z.ZodNumber;
4779
+ affiliateFeeInBps: z.ZodString;
4780
+ totalFee: z.ZodString;
4781
+ protocolFee: z.ZodString;
4782
+ affiliateFee: z.ZodString;
4783
+ tradeTimeout: z.ZodNumber;
4780
4784
  }, "strip", z.ZodTypeAny, {
4781
4785
  version: number;
4782
- deadline: number;
4783
4786
  tradeId: string;
4787
+ totalFee: string;
4784
4788
  minAmountOut: null;
4789
+ tradeTimeout: number;
4785
4790
  sessionId: string;
4791
+ scriptTimeout: number;
4786
4792
  solverAddress: string;
4787
4793
  fromToken: {
4788
4794
  address: string;
@@ -4820,7 +4826,6 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
4820
4826
  commitmentRetries: number;
4821
4827
  pmmFailureStats: Record<string, number>;
4822
4828
  commitedSignature: string;
4823
- sessionDeadline: number;
4824
4829
  userDepositTx: string;
4825
4830
  depositVault: string;
4826
4831
  paymentBundle: {
@@ -4837,12 +4842,17 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
4837
4842
  tradeMakePaymentTx: string;
4838
4843
  state: string;
4839
4844
  lastUpdateMsg: string;
4845
+ affiliateFeeInBps: string;
4846
+ protocolFee: string;
4847
+ affiliateFee: string;
4840
4848
  }, {
4841
4849
  version: number;
4842
- deadline: number;
4843
4850
  tradeId: string;
4851
+ totalFee: string;
4844
4852
  minAmountOut: null;
4853
+ tradeTimeout: number;
4845
4854
  sessionId: string;
4855
+ scriptTimeout: number;
4846
4856
  solverAddress: string;
4847
4857
  fromToken: {
4848
4858
  address: string;
@@ -4880,7 +4890,6 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
4880
4890
  commitmentRetries: number;
4881
4891
  pmmFailureStats: Record<string, number>;
4882
4892
  commitedSignature: string;
4883
- sessionDeadline: number;
4884
4893
  userDepositTx: string;
4885
4894
  depositVault: string;
4886
4895
  paymentBundle: {
@@ -4897,15 +4906,20 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
4897
4906
  tradeMakePaymentTx: string;
4898
4907
  state: string;
4899
4908
  lastUpdateMsg: string;
4909
+ affiliateFeeInBps: string;
4910
+ protocolFee: string;
4911
+ affiliateFee: string;
4900
4912
  }>;
4901
4913
  traceId: z.ZodString;
4902
4914
  }, "strip", z.ZodTypeAny, {
4903
4915
  data: {
4904
4916
  version: number;
4905
- deadline: number;
4906
4917
  tradeId: string;
4918
+ totalFee: string;
4907
4919
  minAmountOut: null;
4920
+ tradeTimeout: number;
4908
4921
  sessionId: string;
4922
+ scriptTimeout: number;
4909
4923
  solverAddress: string;
4910
4924
  fromToken: {
4911
4925
  address: string;
@@ -4943,7 +4957,6 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
4943
4957
  commitmentRetries: number;
4944
4958
  pmmFailureStats: Record<string, number>;
4945
4959
  commitedSignature: string;
4946
- sessionDeadline: number;
4947
4960
  userDepositTx: string;
4948
4961
  depositVault: string;
4949
4962
  paymentBundle: {
@@ -4960,15 +4973,20 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
4960
4973
  tradeMakePaymentTx: string;
4961
4974
  state: string;
4962
4975
  lastUpdateMsg: string;
4976
+ affiliateFeeInBps: string;
4977
+ protocolFee: string;
4978
+ affiliateFee: string;
4963
4979
  };
4964
4980
  traceId: string;
4965
4981
  }, {
4966
4982
  data: {
4967
4983
  version: number;
4968
- deadline: number;
4969
4984
  tradeId: string;
4985
+ totalFee: string;
4970
4986
  minAmountOut: null;
4987
+ tradeTimeout: number;
4971
4988
  sessionId: string;
4989
+ scriptTimeout: number;
4972
4990
  solverAddress: string;
4973
4991
  fromToken: {
4974
4992
  address: string;
@@ -5006,7 +5024,6 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
5006
5024
  commitmentRetries: number;
5007
5025
  pmmFailureStats: Record<string, number>;
5008
5026
  commitedSignature: string;
5009
- sessionDeadline: number;
5010
5027
  userDepositTx: string;
5011
5028
  depositVault: string;
5012
5029
  paymentBundle: {
@@ -5023,6 +5040,9 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
5023
5040
  tradeMakePaymentTx: string;
5024
5041
  state: string;
5025
5042
  lastUpdateMsg: string;
5043
+ affiliateFeeInBps: string;
5044
+ protocolFee: string;
5045
+ affiliateFee: string;
5026
5046
  };
5027
5047
  traceId: string;
5028
5048
  }>;
package/dist/index.js CHANGED
@@ -3703,7 +3703,6 @@ var TradeDetailResponseSchema = import_zod.z.object({
3703
3703
  amountAfterFees: import_zod.z.string(),
3704
3704
  fromUserAddress: import_zod.z.string(),
3705
3705
  userReceivingAddress: import_zod.z.string(),
3706
- deadline: import_zod.z.number(),
3707
3706
  protocolFeeInBps: import_zod.z.string(),
3708
3707
  protocolMpcPubkey: import_zod.z.string(),
3709
3708
  protocolMpcAddress: import_zod.z.string(),
@@ -3720,7 +3719,6 @@ var TradeDetailResponseSchema = import_zod.z.object({
3720
3719
  pmmFailureStats: import_zod.z.record(import_zod.z.number()),
3721
3720
  commitedSignature: import_zod.z.string(),
3722
3721
  minAmountOut: import_zod.z.null(),
3723
- sessionDeadline: import_zod.z.number(),
3724
3722
  userDepositTx: import_zod.z.string(),
3725
3723
  depositVault: import_zod.z.string(),
3726
3724
  paymentBundle: PaymentBundleSchema,
@@ -3730,7 +3728,13 @@ var TradeDetailResponseSchema = import_zod.z.object({
3730
3728
  tradeMakePaymentTx: import_zod.z.string(),
3731
3729
  state: import_zod.z.string(),
3732
3730
  lastUpdateMsg: import_zod.z.string(),
3733
- version: import_zod.z.number()
3731
+ version: import_zod.z.number(),
3732
+ scriptTimeout: import_zod.z.number(),
3733
+ affiliateFeeInBps: import_zod.z.string(),
3734
+ totalFee: import_zod.z.string(),
3735
+ protocolFee: import_zod.z.string(),
3736
+ affiliateFee: import_zod.z.string(),
3737
+ tradeTimeout: import_zod.z.number()
3734
3738
  }),
3735
3739
  traceId: import_zod.z.string()
3736
3740
  });
@@ -3769,7 +3773,8 @@ var SolverService = class {
3769
3773
  return SubmitSettlementResponseSchema.parse(response.data);
3770
3774
  } catch (error) {
3771
3775
  if (import_axios.default.isAxiosError(error)) {
3772
- throw new Error(`Failed to submit settlement transaction: ${error.message}`);
3776
+ const errorMessage = error.response?.data?.message || error.response?.data?.error || error.message;
3777
+ throw new Error(errorMessage);
3773
3778
  }
3774
3779
  if (error instanceof import_zod.z.ZodError) {
3775
3780
  throw new Error(`Invalid data: ${error.message}`);
@@ -3795,7 +3800,8 @@ var SolverService = class {
3795
3800
  return TradeDetailResponseSchema.parse(camelCaseData);
3796
3801
  } catch (error) {
3797
3802
  if (import_axios.default.isAxiosError(error)) {
3798
- throw new Error(`Failed to fetch trade details: ${error.message}`);
3803
+ const errorMessage = error.response?.data?.message || error.response?.data?.error || error.message;
3804
+ throw new Error(errorMessage);
3799
3805
  }
3800
3806
  if (error instanceof import_zod.z.ZodError) {
3801
3807
  throw new Error(`Invalid data: ${error.message}`);
@@ -3862,7 +3868,8 @@ var TokenService = class {
3862
3868
  return validatedResponse.data.tokens;
3863
3869
  } catch (error) {
3864
3870
  if (import_axios2.default.isAxiosError(error)) {
3865
- throw new Error(`Failed to fetch tokens: ${error.message}`);
3871
+ const errorMessage = error.response?.data?.message || error.response?.data?.error || error.message;
3872
+ throw new Error(errorMessage);
3866
3873
  }
3867
3874
  if (error instanceof import_zod3.z.ZodError) {
3868
3875
  throw new Error(`Invalid token data received: ${error.message}`);
package/dist/index.mjs CHANGED
@@ -3638,7 +3638,6 @@ var TradeDetailResponseSchema = z.object({
3638
3638
  amountAfterFees: z.string(),
3639
3639
  fromUserAddress: z.string(),
3640
3640
  userReceivingAddress: z.string(),
3641
- deadline: z.number(),
3642
3641
  protocolFeeInBps: z.string(),
3643
3642
  protocolMpcPubkey: z.string(),
3644
3643
  protocolMpcAddress: z.string(),
@@ -3655,7 +3654,6 @@ var TradeDetailResponseSchema = z.object({
3655
3654
  pmmFailureStats: z.record(z.number()),
3656
3655
  commitedSignature: z.string(),
3657
3656
  minAmountOut: z.null(),
3658
- sessionDeadline: z.number(),
3659
3657
  userDepositTx: z.string(),
3660
3658
  depositVault: z.string(),
3661
3659
  paymentBundle: PaymentBundleSchema,
@@ -3665,7 +3663,13 @@ var TradeDetailResponseSchema = z.object({
3665
3663
  tradeMakePaymentTx: z.string(),
3666
3664
  state: z.string(),
3667
3665
  lastUpdateMsg: z.string(),
3668
- version: z.number()
3666
+ version: z.number(),
3667
+ scriptTimeout: z.number(),
3668
+ affiliateFeeInBps: z.string(),
3669
+ totalFee: z.string(),
3670
+ protocolFee: z.string(),
3671
+ affiliateFee: z.string(),
3672
+ tradeTimeout: z.number()
3669
3673
  }),
3670
3674
  traceId: z.string()
3671
3675
  });
@@ -3704,7 +3708,8 @@ var SolverService = class {
3704
3708
  return SubmitSettlementResponseSchema.parse(response.data);
3705
3709
  } catch (error) {
3706
3710
  if (axios.isAxiosError(error)) {
3707
- throw new Error(`Failed to submit settlement transaction: ${error.message}`);
3711
+ const errorMessage = error.response?.data?.message || error.response?.data?.error || error.message;
3712
+ throw new Error(errorMessage);
3708
3713
  }
3709
3714
  if (error instanceof z.ZodError) {
3710
3715
  throw new Error(`Invalid data: ${error.message}`);
@@ -3730,7 +3735,8 @@ var SolverService = class {
3730
3735
  return TradeDetailResponseSchema.parse(camelCaseData);
3731
3736
  } catch (error) {
3732
3737
  if (axios.isAxiosError(error)) {
3733
- throw new Error(`Failed to fetch trade details: ${error.message}`);
3738
+ const errorMessage = error.response?.data?.message || error.response?.data?.error || error.message;
3739
+ throw new Error(errorMessage);
3734
3740
  }
3735
3741
  if (error instanceof z.ZodError) {
3736
3742
  throw new Error(`Invalid data: ${error.message}`);
@@ -3797,7 +3803,8 @@ var TokenService = class {
3797
3803
  return validatedResponse.data.tokens;
3798
3804
  } catch (error) {
3799
3805
  if (axios2.isAxiosError(error)) {
3800
- throw new Error(`Failed to fetch tokens: ${error.message}`);
3806
+ const errorMessage = error.response?.data?.message || error.response?.data?.error || error.message;
3807
+ throw new Error(errorMessage);
3801
3808
  }
3802
3809
  if (error instanceof z3.ZodError) {
3803
3810
  throw new Error(`Invalid token data received: ${error.message}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimex-xyz/market-maker-sdk",
3
- "version": "0.4.8",
3
+ "version": "0.4.9",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"