@optimex-xyz/market-maker-sdk 0.6.0 → 0.6.2

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
@@ -6,70 +6,32 @@ A comprehensive guide for implementing Private Market Makers (PMMs) in the cross
6
6
 
7
7
  ## Table of Contents
8
8
 
9
- - [PMM API Integration Documentation](#pmm-api-integration-documentation)
10
- - [Table of Contents](#table-of-contents)
11
- - [1. Overview](#1-overview)
12
- - [1.1. Integration Flow](#11-integration-flow)
13
- - [2. Quick Start](#2-quick-start)
14
- - [2.1. API Environments](#21-api-environments)
9
+ - [PMM API Integration Documentation](#pmm-api-integration-documentation)
10
+ - [1. Overview](#1-overview)
11
+ - [2. Quick Start](#2-quick-start)
15
12
  - [3. PMM Backend APIs](#3-pmm-backend-apis)
16
- - [3.1. Endpoint: `/indicative-quote`](#31-endpoint-indicative-quote)
17
- - [Description](#description)
18
- - [Request Parameters](#request-parameters)
19
- - [Example Request](#example-request)
20
- - [Expected Response](#expected-response)
21
- - [Example Implementation](#example-implementation)
22
- - [3.2. Endpoint: `/commitment-quote`](#32-endpoint-commitment-quote)
23
- - [Description](#description-1)
24
- - [Request Parameters](#request-parameters-1)
25
- - [Example Request](#example-request-1)
26
- - [Expected Response](#expected-response-1)
27
- - [Example Implementation](#example-implementation-1)
28
- - [3.3. Endpoint: `/settlement-signature`](#33-endpoint-settlement-signature)
29
- - [Description](#description-2)
30
- - [Request Parameters](#request-parameters-2)
31
- - [Example Request](#example-request-2)
32
- - [Expected Response](#expected-response-2)
33
- - [Example Implementation](#example-implementation-2)
34
- - [3.4. Endpoint: `/ack-settlement`](#34-endpoint-ack-settlement)
35
- - [Description](#description-3)
36
- - [Request Parameters](#request-parameters-3)
37
- - [Example Request](#example-request-3)
38
- - [Expected Response](#expected-response-3)
39
- - [Example Implementation](#example-implementation-3)
40
- - [3.5. Endpoint: `/signal-payment`](#35-endpoint-signal-payment)
41
- - [Description](#description-4)
42
- - [Request Parameters](#request-parameters-4)
43
- - [Example Request](#example-request-4)
44
- - [Expected Response](#expected-response-4)
45
- - [Example Implementation](#example-implementation-4)
13
+ - [3.1. Endpoint: `/indicative-quote`](#31-endpoint-indicative-quote)
14
+ - [3.2. Endpoint: `/commitment-quote`](#32-endpoint-commitment-quote)
15
+ - [3.3. Endpoint: `/settlement-signature`](#33-endpoint-settlement-signature)
16
+ - [3.4. Endpoint: `/ack-settlement`](#34-endpoint-ack-settlement)
17
+ - [3.5. Endpoint: `/signal-payment`](#35-endpoint-signal-payment)
46
18
  - [4. Solver API Endpoints for PMMs](#4-solver-api-endpoints-for-pmms)
47
19
  - [4.1. Endpoint: `/v1/market-maker/tokens`](#41-endpoint-v1market-makertokens)
48
- - [Description](#description-5)
49
- - [Request Parameters](#request-parameters-5)
50
- - [Example Request](#example-request-5)
51
- - [Expected Response](#expected-response-5)
52
20
  - [4.2. Endpoint: `/v1/market-maker/submit-settlement-tx`](#42-endpoint-v1market-makersubmit-settlement-tx)
53
- - [Description](#description-6)
54
- - [Request Parameters](#request-parameters-6)
55
- - [Example Request](#example-request-6)
56
- - [Expected Response](#expected-response-6)
57
- - [Notes](#notes)
58
21
  - [4.3. Endpoint: `/v1/market-maker/trades/:tradeId`](#43-endpoint-v1market-makertradestradeid)
59
- - [Description](#description-7)
60
- - [Request Parameters](#request-parameters-7)
61
- - [Example Request](#example-request-7)
62
- - [Expected Response](#expected-response-7)
63
22
  - [5. PMM Making Payment](#5-pmm-making-payment)
64
23
  - [5.1. EVM](#51-evm)
65
24
  - [5.2. Bitcoin](#52-bitcoin)
66
-
67
25
  ## 1. Overview
68
26
 
69
- This documentation contains everything needed to integrate your PMM with the solver network. The integration requires implementing specific API endpoints in your PMM service and making calls to the solver backend APIs.
27
+ The PMM integration with Optimex involves bidirectional API communication:
28
+
29
+ 1. **PMM-Provided APIs**: Endpoints that PMMs must implement to receive requests from the Solver
30
+ 2. **Solver-Provided APIs**: Endpoints that the Solver provides for PMMs to call
70
31
 
71
32
  ### 1.1. Integration Flow
72
33
 
34
+
73
35
  ```mermaid
74
36
  sequenceDiagram
75
37
  participant User
@@ -104,23 +66,46 @@ sequenceDiagram
104
66
 
105
67
  ### 2.1. API Environments
106
68
 
107
- | Environment | Description |
108
- | ---------------- | -------------------------------------------------------------------- |
109
- | `dev` | Development environment with test networks and staging services |
110
- | `pre-production` | Pre-production environment with mainnet networks for testing before release |
69
+ | Environment | Description |
70
+ | ---------------- | -------------------------------------------------------------------- |
71
+ | `dev` | Development environment with test networks and staging services |
72
+ | `prelive` | Pre production environment with mainnet networks for testing before release |
111
73
  | `production` | Production environment with mainnet networks and production services |
112
74
 
113
- - Solver URLs: Each environment has dedicated API endpoints
75
+ <details>
76
+ <summary><strong>Development Contracts</strong></summary>
77
+
78
+ **Optimex L2 Testnet**
79
+ - **Signer**: [0xA89F5060B810F3b6027D7663880c43ee77A865C7](https://scan-testnet.optimex.xyz/address/0xA89F5060B810F3b6027D7663880c43ee77A865C7)
80
+ - **Router**: [0x193501E5F72a42DACCF8Eb1C4AB37561c213309D](https://scan-testnet.optimex.xyz/address/0x193501E5F72a42DACCF8Eb1C4AB37561c213309D)
114
81
 
115
- - RPC Endpoints: L2 RPC endpoints
82
+ **Ethereum Sepolia**
83
+ - **Payment**: [0x7387DcCfE2f1D5F80b4ECDF91eF58541517e90D2](https://sepolia.etherscan.io/address/0x7387DcCfE2f1D5F80b4ECDF91eF58541517e90D2)
84
+ - **ETHVault**: [0x17aD543010fc8E8065b85E203839C0CBEcdfC851](https://sepolia.etherscan.io/address/0x17aD543010fc8E8065b85E203839C0CBEcdfC851)
85
+ - **WETHVault**: [0x673Ac1489457F43F04403940cE425ae19a9D639B](https://sepolia.etherscan.io/address/0x673Ac1489457F43F04403940cE425ae19a9D639B)
86
+ - **USDCVault**: [0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238](https://sepolia.etherscan.io/address/0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238)
87
+ - **USDTVault**: [0x62179B12Ce75B81Fcb4a2B634aD92DDaeF728e9C](https://sepolia.etherscan.io/address/0x62179B12Ce75B81Fcb4a2B634aD92DDaeF728e9C)
88
+ - **WBTCVault**: [0x04D0C9a5bb122958D8A64049068FD8570dDfA3Dc](https://sepolia.etherscan.io/address/0x04D0C9a5bb122958D8A64049068FD8570dDfA3Dc)
89
+ </details>
116
90
 
117
- - Router Addresses: Smart contract addresses for routing transactions
91
+ <details>
92
+ <summary><strong>Production/Prelive Contracts</strong></summary>
118
93
 
119
- - **Note:** pre-production and production share the same router addresses
120
94
 
121
- - Payment Addresses: Addresses used for fee collection and settlement
95
+ **Optimex L2 Mainnet**
96
+ - **Signer**: [0xCF9786F123F1071023dB8049808C223e94c384be](https://scan.optimex.xyz/address/0xCF9786F123F1071023dB8049808C223e94c384be)
97
+ - **Router**: [0xcceAb862dD41f6691d81Cc016216Cd45d7BD6D4A](https://scan.optimex.xyz/address/0xcceAb862dD41f6691d81Cc016216Cd45d7BD6D4A)
122
98
 
123
- - **Note:** pre-production and production share the same payment addresses
99
+ **Ethereum Mainnet**
100
+ - **Payment**: [0x0A497AC4261E37FA4062762C23Cf3cB642C839b8](https://etherscan.io/address/0x0A497AC4261E37FA4062762C23Cf3cB642C839b8)
101
+ - **ETHVault**: [0xF7fedF4A250157010807E6eA60258E3B768149Ff](https://etherscan.io/address/0xF7fedF4A250157010807E6eA60258E3B768149Ff)
102
+ - **WETHVault**: [0xaD3f379AaED8Eca895209Af446F2e34f07145dbC](https://etherscan.io/address/0xaD3f379AaED8Eca895209Af446F2e34f07145dbC)
103
+ - **USDCVault**: [0x4463084C01ed22E8320D345b357721aE525Db93F](https://etherscan.io/address/0x4463084C01ed22E8320D345b357721aE525Db93F)
104
+ - **USDTVault**: [0x0712CAB9e52a37aFC6fA768b20cc9b07325314fB](https://etherscan.io/address/0x0712CAB9e52a37aFC6fA768b20cc9b07325314fB)
105
+ - **WBTCVault**: [0xCd6B5F600559104Ee19320B9F9C3b2c7672cb895](https://etherscan.io/address/0xCd6B5F600559104Ee19320B9F9C3b2c7672cb895)
106
+ </details>
107
+
108
+ > **Note**: The prelive and production environments use the same contract addresses. The difference is in the backend services and configuration that interact with these contracts.
124
109
 
125
110
  ## 3. PMM Backend APIs
126
111
 
@@ -165,7 +150,8 @@ GET /indicative-quote?from_token_id=ETH&to_token_id=BTC&amount=10000000000000000
165
150
  - `indicative_quote` (string): The indicative quote value, represented as a string. Should be treated as a BigInt in your implementation.
166
151
  - `error` (string): Error message, if any (empty if no error).
167
152
 
168
- #### Example Implementation
153
+ <details>
154
+ <summary><strong>Example Implementation</strong></summary>
169
155
 
170
156
  ```js
171
157
  async function getIndicativeQuote(req, res) {
@@ -216,6 +202,7 @@ async function getIndicativeQuote(req, res) {
216
202
  }
217
203
  }
218
204
  ```
205
+ </details>
219
206
 
220
207
  ### 3.2. Endpoint: `/commitment-quote`
221
208
 
@@ -262,7 +249,8 @@ GET /commitment-quote?session_id=12345&trade_id=0x3bfe2fc4889a98a39b31b348e7b212
262
249
  - `commitment_quote` (string): The committed quote value, represented as a string. Should be treated as a BigInt in your implementation.
263
250
  - `error` (string): Error message, if any (empty if no error).
264
251
 
265
- #### Example Implementation
252
+ <details>
253
+ <summary><strong>Example Implementation</strong></summary>
266
254
 
267
255
  ```js
268
256
  async function getCommitmentQuote(req, res) {
@@ -342,6 +330,7 @@ async function getCommitmentQuote(req, res) {
342
330
  }
343
331
  }
344
332
  ```
333
+ </details>
345
334
 
346
335
  ### 3.3. Endpoint: `/settlement-signature`
347
336
 
@@ -358,7 +347,6 @@ Returns a signature from the PMM to confirm the settlement quote, required to fi
358
347
  - `trade_deadline` (string): The UNIX timestamp (in seconds) by which the user expects to receive payment.
359
348
  - `script_deadline` (string): The UNIX timestamp (in seconds) after which the user can withdraw their deposit if not paid.
360
349
 
361
-
362
350
  #### Example Request
363
351
 
364
352
  ```
@@ -384,7 +372,8 @@ GET /settlement-signature?trade_id=0x3d09b8eb94466bffa126aeda68c8c0f330633a7d005
384
372
  - `deadline` (integer): The UNIX timestamp (in seconds) indicating the PMM's expected payment deadline.
385
373
  - `error` (string): Error message, if any (empty if no error).
386
374
 
387
- #### Example Implementation
375
+ <details>
376
+ <summary><strong>Example Implementation</strong></summary>
388
377
 
389
378
  ```js
390
379
  async function getSettlementSignature(req, res) {
@@ -447,6 +436,7 @@ async function getSettlementSignature(req, res) {
447
436
  }
448
437
  }
449
438
  ```
439
+ </details>
450
440
 
451
441
  ### 3.4. Endpoint: `/ack-settlement`
452
442
 
@@ -489,7 +479,8 @@ trade_id=0x024be4dae899989e0c3d9b4459e5811613bcd04016dc56529f16a19d2a7724c0&trad
489
479
  - `status` (string): Status of the acknowledgment (always `"acknowledged"`).
490
480
  - `error` (string): Error message, if any (empty if no error).
491
481
 
492
- #### Example Implementation
482
+ <details>
483
+ <summary><strong>Example Implementation</strong></summary>
493
484
 
494
485
  ```js
495
486
  async function ackSettlement(req, res) {
@@ -527,6 +518,7 @@ async function ackSettlement(req, res) {
527
518
  }
528
519
  }
529
520
  ```
521
+ </details>
530
522
 
531
523
  ### 3.5. Endpoint: `/signal-payment`
532
524
 
@@ -569,7 +561,8 @@ trade_id=0x3bfe2fc4889a98a39b31b348e7b212ea3f2bea63fd1ea2e0c8ba326433677328&tota
569
561
  - `status` (string): Status of the acknowledgment (always `"acknowledged"`).
570
562
  - `error` (string): Error message, if any (empty if no error).
571
563
 
572
- #### Example Implementation
564
+ <details>
565
+ <summary><strong>Example Implementation</strong></summary>
573
566
 
574
567
  ```js
575
568
  async function signalPayment(req, res) {
@@ -613,15 +606,14 @@ async function signalPayment(req, res) {
613
606
  }
614
607
  }
615
608
  ```
609
+ </details>
616
610
 
617
611
  ## 4. Solver API Endpoints for PMMs
618
612
 
619
-
620
613
  These API endpoints are provided by the Solver backend for PMMs to retrieve token information and submit settlement data.
621
614
 
622
615
  > **Note**: The base URL for the Solver API endpoints will be provided separately. All endpoint paths in this documentation should be appended to that base URL.
623
616
 
624
-
625
617
  ### 4.1. Endpoint: `/v1/market-maker/tokens`
626
618
 
627
619
  #### Description
@@ -641,7 +633,10 @@ GET /v1/market-maker/tokens
641
633
  #### Expected Response
642
634
 
643
635
  - **HTTP Status**: `200 OK`
644
- - **Response Body** (JSON):
636
+ - **Response Body**: JSON containing supported networks, tokens, and trading pairs
637
+
638
+ <details>
639
+ <summary><strong>View Example Response</strong></summary>
645
640
 
646
641
  ```json
647
642
  {
@@ -713,12 +708,12 @@ GET /v1/market-maker/tokens
713
708
  }
714
709
  }
715
710
  ```
711
+ </details>
716
712
 
717
713
  ### 4.2. Endpoint: `/v1/market-maker/submit-settlement-tx`
718
714
 
719
715
  #### Description
720
-
721
- Allows the PMM to submit the settlement transaction hash for one or more trades. This step is necessary to complete the trade settlement process.
716
+ Allows the PMM to submit settlement transaction hashes for trades. This endpoint is essential for completing the trade settlement process and must be called after making payments.
722
717
 
723
718
  #### Request Parameters
724
719
 
@@ -736,12 +731,44 @@ Allows the PMM to submit the settlement transaction hash for one or more trades.
736
731
  }
737
732
  ```
738
733
 
739
- - `trade_ids` (array of strings): An array of trade IDs associated with the settlement transaction.
740
- - `pmm_id` (string): The PMM's ID, which must match the one committed for the trade(s).
741
- - `settlement_tx` (string): The txHash of the settlement.
742
- - `signature` (string): The PMM's signature on the settlement transaction.
743
- - `start_index` (integer): The index indicating the starting point for settlement processing (used for batch settlements).
744
- - `signed_at` (integer): The UNIX timestamp (in seconds) when the PMM signed the settlement transaction.
734
+ - `trade_ids` (array of strings): Array of trade IDs included in this settlement transaction.
735
+ - `pmm_id` (string): Your PMM identifier, which must match what was used in the commitment phase.
736
+ - `signature` (string): Your cryptographic signature for this submission.
737
+ - `start_index` (integer): Starting position within batch settlements (typically 0 for single trades).
738
+ - `signed_at` (integer): UNIX timestamp (seconds) when you signed this submission.
739
+ - `settlement_tx` (string): Should be hex format with a `0x` prefix
740
+
741
+ - **For EVM Chains:**
742
+ - Use the transaction hash directly without additional encoding
743
+ - Example: `settlement_tx`: [0x7a87d2c423e13533b5ae0ecc5af900a7b697048103f4f6e32d19edde5e707355](https://etherscan.io/tx/0x7a87d2c423e13533b5ae0ecc5af900a7b697048103f4f6e32d19edde5e707355)
744
+
745
+ - **For Bitcoin or Solana:**
746
+ - Must encode raw_tx string using the `l2Encode` function
747
+ - Example raw_tx string: `3d83c7846d6e5b04279175a9592705a15373f3029b866d5224cc0744489fe403`
748
+ - After encoding
749
+ ```
750
+ "settlement_tx": "0x33643833633738343664366535623034323739313735613935393237303561313533373366333032396238363664353232346363303734343438396665343033"
751
+ ```
752
+
753
+ <details>
754
+ <summary><strong>Bitcoin l2Encode</strong></summary>
755
+
756
+ ```javascript
757
+ import { ethers, toUtf8Bytes, toUtf8String } from 'ethers'
758
+
759
+ export const l2Encode = (info: string) => {
760
+ // Helper function to ensure hex prefix
761
+ const ensureHexPrefix = (value: string) => {
762
+ return value.startsWith('0x') ? value : `0x${value}`
763
+ }
764
+
765
+ if (/^0x[0-9a-fA-F]*$/.test(info)) {
766
+ return info
767
+ }
768
+ return ensureHexPrefix(ethers.hexlify(toUtf8Bytes(info)))
769
+ }
770
+ ```
771
+ </details>
745
772
 
746
773
  #### Example Request
747
774
 
@@ -752,7 +779,7 @@ Content-Type: application/json
752
779
  {
753
780
  "trade_ids": ["0xabcdef123456...", "0x123456abcdef..."],
754
781
  "pmm_id": "pmm001",
755
- "settlement_tx": "0xRawTransactionData",
782
+ "settlement_tx": "0x33643833633738343664366535623034323739313735613935393237303561313533373366333032396238363664353232346363303734343438396665343033",
756
783
  "signature": "0xSignatureData",
757
784
  "start_index": 0,
758
785
  "signed_at": 1719158400
@@ -791,13 +818,92 @@ Returns detailed information about a specific trade by its trade ID. This endpoi
791
818
  #### Example Request
792
819
 
793
820
  ```
794
- GET /v1/market-maker/trades/0x650e2c921a85eb0b8831ff838d4d98c0a5cd2ede5c0cb6bb4a15969f51c75424
821
+ GET /v1/market-maker/trades/0xfc24b9bc1299b50896027cb4c85d041c911e062147ffaf7ae9c7e51b670086c2
795
822
  ```
796
823
 
797
824
  #### Expected Response
798
825
 
799
826
  - **HTTP Status**: `200 OK`
800
- - **Response Body** (JSON): See the detailed response format in the updated PMM Integration API Documentation.
827
+ - **Response Body**: JSON containing detailed trade information.
828
+
829
+ <details>
830
+ <summary><strong>View Example Response</strong></summary>
831
+
832
+ ```json
833
+ {
834
+ "code": 0,
835
+ "message": "",
836
+ "data": {
837
+ "trade_id": "0xfc24b9bc1299b50896027cb4c85d041c911e062147ffaf7ae9c7e51b670086c2",
838
+ "session_id": "0xa5c2aa8dbff701e1a05707212ce3fb824a6ddd970e5dff5e340d7422ce6bcd97",
839
+ "solver_address": "0xe291307c85f8f0c710180fea7cca25108782dee1",
840
+ "from_token": {
841
+ "token_id": "ETH",
842
+ "chain": "ethereum",
843
+ "address": "native",
844
+ "fee_in": true,
845
+ "fee_out": true
846
+ },
847
+ "to_token": {
848
+ "token_id": "BTC",
849
+ "chain": "bitcoin",
850
+ "address": "native",
851
+ "fee_in": false,
852
+ "fee_out": false
853
+ },
854
+ "amount_before_fees": "3250849775444909",
855
+ "amount_after_fees": "3244348075894020",
856
+ "from_user_address": "0x2997cb0850a0c92db99e6e8745ac83bfb93c10ac",
857
+ "user_receiving_address": "bc1p68q6hew27ljf4ghvlnwqz0fq32qg7tsgc7jr5levfy8r74p5k52qqphk07",
858
+ "script_timeout": 1745544704,
859
+ "protocol_fee_in_bps": "20",
860
+ "affiliate_fee_in_bps": "0",
861
+ "total_fee": "6501699550889",
862
+ "protocol_fee": "6501699550889",
863
+ "affiliate_fee": "0",
864
+ "mpc_asset_chain_pubkey": "0x03c36bcf548094cfc74ec1ea89fc5fe0304461653813cdaa98bc26e2d5221eba9b",
865
+ "best_indicative_quote": "4404",
866
+ "display_indicative_quote": "4404",
867
+ "pmm_finalists": [
868
+ {
869
+ "pmm_id": "pmm_test",
870
+ "pmm_receiving_address": "0xtestaddress"
871
+ }
872
+ ],
873
+ "settlement_quote": "5014",
874
+ "receiving_amount": "5014",
875
+ "selected_pmm": "kypseli",
876
+ "selected_pmm_receiving_address": "0xbee0225697a311af58096ce2f03a2b65f1702f00",
877
+ "selected_pmm_operator": "0x01c4f660ccdc4e5bdc5ee477ab0016dc424c473a",
878
+ "selected_pmm_sig_deadline": 1745472704,
879
+ "commitment_retries": 1,
880
+ "pmm_failure_stats": {},
881
+ "commited_signature": "0x842f32d384e6627755bdaa9285727c09731ed44e92555555c7d211fb3333a4c970b8a717ac79560be35fb2f22dc3fb2d80443e88234605fd353c12011fb8d8851c",
882
+ "min_amount_out": null,
883
+ "trade_timeout": 1745472704,
884
+ "user_deposit_tx": "0x202186375a3b8d55de4d8d1afb7f6a5bec8978cef3b705e6cb379729d03b16c7",
885
+ "deposit_vault": "0xf7fedf4a250157010807e6ea60258e3b768149ff",
886
+ "payment_bundle": {
887
+ "trade_ids": [
888
+ "0xfc24b9bc1299b50896027cb4c85d041c911e062147ffaf7ae9c7e51b670086c2"
889
+ ],
890
+ "settlement_tx": "3d83c7846d6e5b04279175a9592705a15373f3029b866d5224cc0744489fe403",
891
+ "signature": "0x479a5a89e7a871026b60307351ea650fc667890b25d3d02df7ed2e93f94db90d7c3f8dbd823220896b8ad49b13a90851199236e82a644ffbe99e53503929fe151b",
892
+ "start_index": 0,
893
+ "pmm_id": "kypseli",
894
+ "signed_at": 1745459448
895
+ },
896
+ "user_signature": "0xfe4d3288db2b7d6ebc273dad1e1c55ecf9af2991fb89cc3e52fc0956c13746a043195cc22ed3c38bfa67c81e7819b53095b4282c5ee1d0c23a955baa38d754821b",
897
+ "trade_submission_tx": "0x38dfc953a9d08d95d7218e993302f81180c4d1a9c85f84836f005770167b0133",
898
+ "trade_select_pmm_tx": "0xc68dbf08e5774edd87ae78076ae498ebc4e489ae905f34b13682198f6dbcc6c0",
899
+ "trade_make_payment_tx": "0x962a1d6cced99b1fa53450c50cf4f95cbf600dd25dcd145a98311d275ef22a38",
900
+ "state": "Done",
901
+ "last_update_msg": "Done. Changed at version 10",
902
+ "version": 10
903
+ }
904
+ }
905
+ ```
906
+ </details>
801
907
 
802
908
  ## 5. PMM Making Payment
803
909
 
@@ -805,8 +911,6 @@ GET /v1/market-maker/trades/0x650e2c921a85eb0b8831ff838d4d98c0a5cd2ede5c0cb6bb4a
805
911
 
806
912
  In case the target chain is EVM-based, the transaction should emit the event from the `l1 payment contract` with the correct values for pmmAmountOut and protocolFee.
807
913
 
808
- Example implementation:
809
-
810
914
  ```js
811
915
  const { ethers } = require('ethers');
812
916
 
@@ -863,8 +967,6 @@ async function makeEVMPayment(tradeId, toAddress, amount, token, protocolFeeAmou
863
967
 
864
968
  In case the target chain is Bitcoin, the transaction should have at least N + 1 outputs, with the first N outputs being the settlement UTXOs for trades, and one of them being the change UTXO for the user with the correct amount. The output N + 1 is the OP_RETURN output with the hash of tradeIds.
865
969
 
866
- Example implementation:
867
-
868
970
  ```js
869
971
  import * as bitcoin from 'bitcoinjs-lib'
870
972
  import { ECPairFactory } from 'ecpair'
package/dist/index.d.mts CHANGED
@@ -5203,14 +5203,14 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
5203
5203
  bestIndicativeQuote: z.ZodString;
5204
5204
  displayIndicativeQuote: z.ZodString;
5205
5205
  pmmFinalists: z.ZodArray<z.ZodObject<{
5206
- pmmId: z.ZodString;
5207
- pmmReceivingAddress: z.ZodString;
5206
+ pmmId: z.ZodDefault<z.ZodOptional<z.ZodString>>;
5207
+ pmmReceivingAddress: z.ZodDefault<z.ZodOptional<z.ZodString>>;
5208
5208
  }, "strip", z.ZodTypeAny, {
5209
5209
  pmmId: string;
5210
5210
  pmmReceivingAddress: string;
5211
5211
  }, {
5212
- pmmId: string;
5213
- pmmReceivingAddress: string;
5212
+ pmmId?: string | undefined;
5213
+ pmmReceivingAddress?: string | undefined;
5214
5214
  }>, "many">;
5215
5215
  settlementQuote: z.ZodString;
5216
5216
  receivingAmount: z.ZodString;
@@ -5225,26 +5225,26 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
5225
5225
  userDepositTx: z.ZodString;
5226
5226
  depositVault: z.ZodString;
5227
5227
  paymentBundle: z.ZodObject<{
5228
- tradeIds: z.ZodArray<z.ZodString, "many">;
5229
- settlementTx: z.ZodString;
5230
- signature: z.ZodString;
5231
- startIndex: z.ZodNumber;
5232
- pmmId: z.ZodString;
5233
- signedAt: z.ZodNumber;
5228
+ tradeIds: z.ZodNullable<z.ZodArray<z.ZodString, "many">>;
5229
+ settlementTx: z.ZodDefault<z.ZodOptional<z.ZodString>>;
5230
+ signature: z.ZodDefault<z.ZodOptional<z.ZodString>>;
5231
+ startIndex: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
5232
+ pmmId: z.ZodDefault<z.ZodOptional<z.ZodString>>;
5233
+ signedAt: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
5234
5234
  }, "strip", z.ZodTypeAny, {
5235
5235
  signature: string;
5236
- tradeIds: string[];
5236
+ tradeIds: string[] | null;
5237
5237
  signedAt: number;
5238
5238
  pmmId: string;
5239
5239
  settlementTx: string;
5240
5240
  startIndex: number;
5241
5241
  }, {
5242
- signature: string;
5243
- tradeIds: string[];
5244
- signedAt: number;
5245
- pmmId: string;
5246
- settlementTx: string;
5247
- startIndex: number;
5242
+ tradeIds: string[] | null;
5243
+ signature?: string | undefined;
5244
+ signedAt?: number | undefined;
5245
+ pmmId?: string | undefined;
5246
+ settlementTx?: string | undefined;
5247
+ startIndex?: number | undefined;
5248
5248
  }>;
5249
5249
  userSignature: z.ZodString;
5250
5250
  tradeSubmissionTx: z.ZodString;
@@ -5306,7 +5306,7 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
5306
5306
  depositVault: string;
5307
5307
  paymentBundle: {
5308
5308
  signature: string;
5309
- tradeIds: string[];
5309
+ tradeIds: string[] | null;
5310
5310
  signedAt: number;
5311
5311
  pmmId: string;
5312
5312
  settlementTx: string;
@@ -5353,8 +5353,8 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
5353
5353
  bestIndicativeQuote: string;
5354
5354
  displayIndicativeQuote: string;
5355
5355
  pmmFinalists: {
5356
- pmmId: string;
5357
- pmmReceivingAddress: string;
5356
+ pmmId?: string | undefined;
5357
+ pmmReceivingAddress?: string | undefined;
5358
5358
  }[];
5359
5359
  settlementQuote: string;
5360
5360
  receivingAmount: string;
@@ -5368,12 +5368,12 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
5368
5368
  userDepositTx: string;
5369
5369
  depositVault: string;
5370
5370
  paymentBundle: {
5371
- signature: string;
5372
- tradeIds: string[];
5373
- signedAt: number;
5374
- pmmId: string;
5375
- settlementTx: string;
5376
- startIndex: number;
5371
+ tradeIds: string[] | null;
5372
+ signature?: string | undefined;
5373
+ signedAt?: number | undefined;
5374
+ pmmId?: string | undefined;
5375
+ settlementTx?: string | undefined;
5376
+ startIndex?: number | undefined;
5377
5377
  };
5378
5378
  userSignature: string;
5379
5379
  tradeSubmissionTx: string;
@@ -5435,7 +5435,7 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
5435
5435
  depositVault: string;
5436
5436
  paymentBundle: {
5437
5437
  signature: string;
5438
- tradeIds: string[];
5438
+ tradeIds: string[] | null;
5439
5439
  signedAt: number;
5440
5440
  pmmId: string;
5441
5441
  settlementTx: string;
@@ -5485,8 +5485,8 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
5485
5485
  bestIndicativeQuote: string;
5486
5486
  displayIndicativeQuote: string;
5487
5487
  pmmFinalists: {
5488
- pmmId: string;
5489
- pmmReceivingAddress: string;
5488
+ pmmId?: string | undefined;
5489
+ pmmReceivingAddress?: string | undefined;
5490
5490
  }[];
5491
5491
  settlementQuote: string;
5492
5492
  receivingAmount: string;
@@ -5500,12 +5500,12 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
5500
5500
  userDepositTx: string;
5501
5501
  depositVault: string;
5502
5502
  paymentBundle: {
5503
- signature: string;
5504
- tradeIds: string[];
5505
- signedAt: number;
5506
- pmmId: string;
5507
- settlementTx: string;
5508
- startIndex: number;
5503
+ tradeIds: string[] | null;
5504
+ signature?: string | undefined;
5505
+ signedAt?: number | undefined;
5506
+ pmmId?: string | undefined;
5507
+ settlementTx?: string | undefined;
5508
+ startIndex?: number | undefined;
5509
5509
  };
5510
5510
  userSignature: string;
5511
5511
  tradeSubmissionTx: string;
package/dist/index.d.ts CHANGED
@@ -5203,14 +5203,14 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
5203
5203
  bestIndicativeQuote: z.ZodString;
5204
5204
  displayIndicativeQuote: z.ZodString;
5205
5205
  pmmFinalists: z.ZodArray<z.ZodObject<{
5206
- pmmId: z.ZodString;
5207
- pmmReceivingAddress: z.ZodString;
5206
+ pmmId: z.ZodDefault<z.ZodOptional<z.ZodString>>;
5207
+ pmmReceivingAddress: z.ZodDefault<z.ZodOptional<z.ZodString>>;
5208
5208
  }, "strip", z.ZodTypeAny, {
5209
5209
  pmmId: string;
5210
5210
  pmmReceivingAddress: string;
5211
5211
  }, {
5212
- pmmId: string;
5213
- pmmReceivingAddress: string;
5212
+ pmmId?: string | undefined;
5213
+ pmmReceivingAddress?: string | undefined;
5214
5214
  }>, "many">;
5215
5215
  settlementQuote: z.ZodString;
5216
5216
  receivingAmount: z.ZodString;
@@ -5225,26 +5225,26 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
5225
5225
  userDepositTx: z.ZodString;
5226
5226
  depositVault: z.ZodString;
5227
5227
  paymentBundle: z.ZodObject<{
5228
- tradeIds: z.ZodArray<z.ZodString, "many">;
5229
- settlementTx: z.ZodString;
5230
- signature: z.ZodString;
5231
- startIndex: z.ZodNumber;
5232
- pmmId: z.ZodString;
5233
- signedAt: z.ZodNumber;
5228
+ tradeIds: z.ZodNullable<z.ZodArray<z.ZodString, "many">>;
5229
+ settlementTx: z.ZodDefault<z.ZodOptional<z.ZodString>>;
5230
+ signature: z.ZodDefault<z.ZodOptional<z.ZodString>>;
5231
+ startIndex: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
5232
+ pmmId: z.ZodDefault<z.ZodOptional<z.ZodString>>;
5233
+ signedAt: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
5234
5234
  }, "strip", z.ZodTypeAny, {
5235
5235
  signature: string;
5236
- tradeIds: string[];
5236
+ tradeIds: string[] | null;
5237
5237
  signedAt: number;
5238
5238
  pmmId: string;
5239
5239
  settlementTx: string;
5240
5240
  startIndex: number;
5241
5241
  }, {
5242
- signature: string;
5243
- tradeIds: string[];
5244
- signedAt: number;
5245
- pmmId: string;
5246
- settlementTx: string;
5247
- startIndex: number;
5242
+ tradeIds: string[] | null;
5243
+ signature?: string | undefined;
5244
+ signedAt?: number | undefined;
5245
+ pmmId?: string | undefined;
5246
+ settlementTx?: string | undefined;
5247
+ startIndex?: number | undefined;
5248
5248
  }>;
5249
5249
  userSignature: z.ZodString;
5250
5250
  tradeSubmissionTx: z.ZodString;
@@ -5306,7 +5306,7 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
5306
5306
  depositVault: string;
5307
5307
  paymentBundle: {
5308
5308
  signature: string;
5309
- tradeIds: string[];
5309
+ tradeIds: string[] | null;
5310
5310
  signedAt: number;
5311
5311
  pmmId: string;
5312
5312
  settlementTx: string;
@@ -5353,8 +5353,8 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
5353
5353
  bestIndicativeQuote: string;
5354
5354
  displayIndicativeQuote: string;
5355
5355
  pmmFinalists: {
5356
- pmmId: string;
5357
- pmmReceivingAddress: string;
5356
+ pmmId?: string | undefined;
5357
+ pmmReceivingAddress?: string | undefined;
5358
5358
  }[];
5359
5359
  settlementQuote: string;
5360
5360
  receivingAmount: string;
@@ -5368,12 +5368,12 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
5368
5368
  userDepositTx: string;
5369
5369
  depositVault: string;
5370
5370
  paymentBundle: {
5371
- signature: string;
5372
- tradeIds: string[];
5373
- signedAt: number;
5374
- pmmId: string;
5375
- settlementTx: string;
5376
- startIndex: number;
5371
+ tradeIds: string[] | null;
5372
+ signature?: string | undefined;
5373
+ signedAt?: number | undefined;
5374
+ pmmId?: string | undefined;
5375
+ settlementTx?: string | undefined;
5376
+ startIndex?: number | undefined;
5377
5377
  };
5378
5378
  userSignature: string;
5379
5379
  tradeSubmissionTx: string;
@@ -5435,7 +5435,7 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
5435
5435
  depositVault: string;
5436
5436
  paymentBundle: {
5437
5437
  signature: string;
5438
- tradeIds: string[];
5438
+ tradeIds: string[] | null;
5439
5439
  signedAt: number;
5440
5440
  pmmId: string;
5441
5441
  settlementTx: string;
@@ -5485,8 +5485,8 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
5485
5485
  bestIndicativeQuote: string;
5486
5486
  displayIndicativeQuote: string;
5487
5487
  pmmFinalists: {
5488
- pmmId: string;
5489
- pmmReceivingAddress: string;
5488
+ pmmId?: string | undefined;
5489
+ pmmReceivingAddress?: string | undefined;
5490
5490
  }[];
5491
5491
  settlementQuote: string;
5492
5492
  receivingAmount: string;
@@ -5500,12 +5500,12 @@ declare const TradeDetailResponseSchema: z.ZodObject<{
5500
5500
  userDepositTx: string;
5501
5501
  depositVault: string;
5502
5502
  paymentBundle: {
5503
- signature: string;
5504
- tradeIds: string[];
5505
- signedAt: number;
5506
- pmmId: string;
5507
- settlementTx: string;
5508
- startIndex: number;
5503
+ tradeIds: string[] | null;
5504
+ signature?: string | undefined;
5505
+ signedAt?: number | undefined;
5506
+ pmmId?: string | undefined;
5507
+ settlementTx?: string | undefined;
5508
+ startIndex?: number | undefined;
5509
5509
  };
5510
5510
  userSignature: string;
5511
5511
  tradeSubmissionTx: string;
package/dist/index.js CHANGED
@@ -4034,16 +4034,16 @@ var TokenInfoSchema = import_zod.z.object({
4034
4034
  feeOut: import_zod.z.boolean()
4035
4035
  });
4036
4036
  var PMMFinalistSchema = import_zod.z.object({
4037
- pmmId: import_zod.z.string(),
4038
- pmmReceivingAddress: import_zod.z.string()
4037
+ pmmId: import_zod.z.string().optional().default(""),
4038
+ pmmReceivingAddress: import_zod.z.string().optional().default("")
4039
4039
  });
4040
4040
  var PaymentBundleSchema = import_zod.z.object({
4041
- tradeIds: import_zod.z.array(import_zod.z.string()),
4042
- settlementTx: import_zod.z.string(),
4043
- signature: import_zod.z.string(),
4044
- startIndex: import_zod.z.number(),
4045
- pmmId: import_zod.z.string(),
4046
- signedAt: import_zod.z.number()
4041
+ tradeIds: import_zod.z.array(import_zod.z.string()).nullable(),
4042
+ settlementTx: import_zod.z.string().optional().default(""),
4043
+ signature: import_zod.z.string().optional().default("0x"),
4044
+ startIndex: import_zod.z.number().optional().default(0),
4045
+ pmmId: import_zod.z.string().optional().default(""),
4046
+ signedAt: import_zod.z.number().optional().default(0)
4047
4047
  });
4048
4048
  var TradeDetailResponseSchema = import_zod.z.object({
4049
4049
  data: import_zod.z.object({
package/dist/index.mjs CHANGED
@@ -3969,16 +3969,16 @@ var TokenInfoSchema = z.object({
3969
3969
  feeOut: z.boolean()
3970
3970
  });
3971
3971
  var PMMFinalistSchema = z.object({
3972
- pmmId: z.string(),
3973
- pmmReceivingAddress: z.string()
3972
+ pmmId: z.string().optional().default(""),
3973
+ pmmReceivingAddress: z.string().optional().default("")
3974
3974
  });
3975
3975
  var PaymentBundleSchema = z.object({
3976
- tradeIds: z.array(z.string()),
3977
- settlementTx: z.string(),
3978
- signature: z.string(),
3979
- startIndex: z.number(),
3980
- pmmId: z.string(),
3981
- signedAt: z.number()
3976
+ tradeIds: z.array(z.string()).nullable(),
3977
+ settlementTx: z.string().optional().default(""),
3978
+ signature: z.string().optional().default("0x"),
3979
+ startIndex: z.number().optional().default(0),
3980
+ pmmId: z.string().optional().default(""),
3981
+ signedAt: z.number().optional().default(0)
3982
3982
  });
3983
3983
  var TradeDetailResponseSchema = z.object({
3984
3984
  data: z.object({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimex-xyz/market-maker-sdk",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -42,35 +42,35 @@
42
42
  "commit": "cz"
43
43
  },
44
44
  "dependencies": {
45
- "axios": "^1.8.3",
45
+ "axios": "^1.9.0",
46
46
  "bip174": "^3.0.0-rc.1",
47
47
  "bitcoinjs-lib": "^7.0.0-rc.0",
48
48
  "ecpair": "^3.0.0",
49
- "ethers": "^6.13.5",
49
+ "ethers": "^6.13.7",
50
50
  "tiny-secp256k1": "^2.2.3",
51
- "zod": "^3.24.2"
51
+ "zod": "^3.24.4"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@commitlint/cli": "^19.8.0",
55
55
  "@commitlint/config-conventional": "^19.8.0",
56
- "@eslint/js": "^9.22.0",
56
+ "@eslint/js": "^9.26.0",
57
57
  "@ianvs/prettier-plugin-sort-imports": "^4.4.1",
58
58
  "@typechain/ethers-v6": "^0.5.1",
59
- "@types/node": "^22.13.10",
60
- "@typescript-eslint/eslint-plugin": "^8.26.1",
61
- "@typescript-eslint/parser": "^8.26.1",
59
+ "@types/node": "^22.15.3",
60
+ "@typescript-eslint/eslint-plugin": "^8.31.1",
61
+ "@typescript-eslint/parser": "^8.31.1",
62
62
  "commitizen": "^4.3.1",
63
- "eslint": "^9.22.0",
64
- "eslint-config-prettier": "^10.1.1",
63
+ "eslint": "^9.26.0",
64
+ "eslint-config-prettier": "^10.1.2",
65
65
  "eslint-plugin-unused-imports": "^4.1.4",
66
66
  "globals": "^16.0.0",
67
- "lint-staged": "^15.5.0",
67
+ "lint-staged": "^15.5.1",
68
68
  "prettier": "^3.5.3",
69
- "simple-git-hooks": "^2.11.1",
69
+ "simple-git-hooks": "^2.13.0",
70
70
  "tsup": "^8.4.0",
71
71
  "typechain": "^8.3.2",
72
- "typescript": "^5.8.2",
73
- "typescript-eslint": "^8.26.1"
72
+ "typescript": "^5.8.3",
73
+ "typescript-eslint": "^8.31.1"
74
74
  },
75
75
  "simple-git-hooks": {
76
76
  "pre-commit": "npx lint-staged",