@optimex-xyz/market-maker-sdk 0.6.1 → 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 +177 -99
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -6,73 +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
|
-
- [
|
|
11
|
-
- [
|
|
12
|
-
- [1.1. Integration Flow](#11-integration-flow)
|
|
13
|
-
- [2. Quick Start](#2-quick-start)
|
|
14
|
-
- [2.1. API Environments](#21-api-environments)
|
|
15
|
-
- [Development Environment](#development-environment)
|
|
16
|
-
- [Pre-production Environment](#pre-production-environment)
|
|
17
|
-
- [Production Environment](#production-environment)
|
|
9
|
+
- [PMM API Integration Documentation](#pmm-api-integration-documentation)
|
|
10
|
+
- [1. Overview](#1-overview)
|
|
11
|
+
- [2. Quick Start](#2-quick-start)
|
|
18
12
|
- [3. PMM Backend APIs](#3-pmm-backend-apis)
|
|
19
|
-
- [3.1. Endpoint: `/indicative-quote`](#31-endpoint-indicative-quote)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
- [Example Implementation](#example-implementation)
|
|
25
|
-
- [3.2. Endpoint: `/commitment-quote`](#32-endpoint-commitment-quote)
|
|
26
|
-
- [Description](#description-1)
|
|
27
|
-
- [Request Parameters](#request-parameters-1)
|
|
28
|
-
- [Example Request](#example-request-1)
|
|
29
|
-
- [Expected Response](#expected-response-1)
|
|
30
|
-
- [Example Implementation](#example-implementation-1)
|
|
31
|
-
- [3.3. Endpoint: `/settlement-signature`](#33-endpoint-settlement-signature)
|
|
32
|
-
- [Description](#description-2)
|
|
33
|
-
- [Request Parameters](#request-parameters-2)
|
|
34
|
-
- [Example Request](#example-request-2)
|
|
35
|
-
- [Expected Response](#expected-response-2)
|
|
36
|
-
- [Example Implementation](#example-implementation-2)
|
|
37
|
-
- [3.4. Endpoint: `/ack-settlement`](#34-endpoint-ack-settlement)
|
|
38
|
-
- [Description](#description-3)
|
|
39
|
-
- [Request Parameters](#request-parameters-3)
|
|
40
|
-
- [Example Request](#example-request-3)
|
|
41
|
-
- [Expected Response](#expected-response-3)
|
|
42
|
-
- [Example Implementation](#example-implementation-3)
|
|
43
|
-
- [3.5. Endpoint: `/signal-payment`](#35-endpoint-signal-payment)
|
|
44
|
-
- [Description](#description-4)
|
|
45
|
-
- [Request Parameters](#request-parameters-4)
|
|
46
|
-
- [Example Request](#example-request-4)
|
|
47
|
-
- [Expected Response](#expected-response-4)
|
|
48
|
-
- [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)
|
|
49
18
|
- [4. Solver API Endpoints for PMMs](#4-solver-api-endpoints-for-pmms)
|
|
50
19
|
- [4.1. Endpoint: `/v1/market-maker/tokens`](#41-endpoint-v1market-makertokens)
|
|
51
|
-
- [Description](#description-5)
|
|
52
|
-
- [Request Parameters](#request-parameters-5)
|
|
53
|
-
- [Example Request](#example-request-5)
|
|
54
|
-
- [Expected Response](#expected-response-5)
|
|
55
20
|
- [4.2. Endpoint: `/v1/market-maker/submit-settlement-tx`](#42-endpoint-v1market-makersubmit-settlement-tx)
|
|
56
|
-
- [Description](#description-6)
|
|
57
|
-
- [Request Parameters](#request-parameters-6)
|
|
58
|
-
- [Example Request](#example-request-6)
|
|
59
|
-
- [Expected Response](#expected-response-6)
|
|
60
|
-
- [Notes](#notes)
|
|
61
21
|
- [4.3. Endpoint: `/v1/market-maker/trades/:tradeId`](#43-endpoint-v1market-makertradestradeid)
|
|
62
|
-
- [Description](#description-7)
|
|
63
|
-
- [Request Parameters](#request-parameters-7)
|
|
64
|
-
- [Example Request](#example-request-7)
|
|
65
|
-
- [Expected Response](#expected-response-7)
|
|
66
22
|
- [5. PMM Making Payment](#5-pmm-making-payment)
|
|
67
23
|
- [5.1. EVM](#51-evm)
|
|
68
24
|
- [5.2. Bitcoin](#52-bitcoin)
|
|
69
|
-
|
|
70
25
|
## 1. Overview
|
|
71
26
|
|
|
72
|
-
|
|
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
|
|
73
31
|
|
|
74
32
|
### 1.1. Integration Flow
|
|
75
33
|
|
|
34
|
+
|
|
76
35
|
```mermaid
|
|
77
36
|
sequenceDiagram
|
|
78
37
|
participant User
|
|
@@ -110,41 +69,43 @@ sequenceDiagram
|
|
|
110
69
|
| Environment | Description |
|
|
111
70
|
| ---------------- | -------------------------------------------------------------------- |
|
|
112
71
|
| `dev` | Development environment with test networks and staging services |
|
|
113
|
-
| `prelive` | Pre
|
|
72
|
+
| `prelive` | Pre production environment with mainnet networks for testing before release |
|
|
114
73
|
| `production` | Production environment with mainnet networks and production services |
|
|
115
74
|
|
|
116
|
-
|
|
117
|
-
Development
|
|
75
|
+
<details>
|
|
76
|
+
<summary><strong>Development Contracts</strong></summary>
|
|
118
77
|
|
|
119
|
-
|
|
120
|
-
- **
|
|
121
|
-
- **
|
|
122
|
-
- **ETHVault**: 0x17aD543010fc8E8065b85E203839C0CBEcdfC851
|
|
123
|
-
- **WETHVault**: 0x673Ac1489457F43F04403940cE425ae19a9D639B
|
|
124
|
-
- **USDTVault**: 0x62179B12Ce75B81Fcb4a2B634aD92DDaeF728e9C
|
|
125
|
-
- **WBTCVault**: 0x04D0C9a5bb122958D8A64049068FD8570dDfA3Dc
|
|
78
|
+
**Optimex L2 Testnet**
|
|
79
|
+
- **Signer**: [0xA89F5060B810F3b6027D7663880c43ee77A865C7](https://scan-testnet.optimex.xyz/address/0xA89F5060B810F3b6027D7663880c43ee77A865C7)
|
|
80
|
+
- **Router**: [0x193501E5F72a42DACCF8Eb1C4AB37561c213309D](https://scan-testnet.optimex.xyz/address/0x193501E5F72a42DACCF8Eb1C4AB37561c213309D)
|
|
126
81
|
|
|
127
|
-
|
|
128
|
-
|
|
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>
|
|
129
90
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
- **Payment**: [0x0A497AC4261E37FA4062762C23Cf3cB642C839b8](https://etherscan.io/address/0x0A497AC4261E37FA4062762C23Cf3cB642C839b8)
|
|
133
|
-
- **ETHVault**: [0xF7fedF4A250157010807E6eA60258E3B768149Ff](https://etherscan.io/address/0xF7fedF4A250157010807E6eA60258E3B768149Ff)
|
|
134
|
-
- **WETHVault**: [0xaD3f379AaED8Eca895209Af446F2e34f07145dbC](https://etherscan.io/address/0xaD3f379AaED8Eca895209Af446F2e34f07145dbC)
|
|
135
|
-
- **USDTVault**: [0x0712CAB9e52a37aFC6fA768b20cc9b07325314fB](https://etherscan.io/address/0x0712CAB9e52a37aFC6fA768b20cc9b07325314fB)
|
|
136
|
-
- **WBTCVault**: [0xCd6B5F600559104Ee19320B9F9C3b2c7672cb895](https://etherscan.io/address/0xCd6B5F600559104Ee19320B9F9C3b2c7672cb895)
|
|
91
|
+
<details>
|
|
92
|
+
<summary><strong>Production/Prelive Contracts</strong></summary>
|
|
137
93
|
|
|
138
|
-
#### Production Environment
|
|
139
|
-
Production environment with mainnet networks and production services
|
|
140
94
|
|
|
95
|
+
**Optimex L2 Mainnet**
|
|
141
96
|
- **Signer**: [0xCF9786F123F1071023dB8049808C223e94c384be](https://scan.optimex.xyz/address/0xCF9786F123F1071023dB8049808C223e94c384be)
|
|
142
97
|
- **Router**: [0xcceAb862dD41f6691d81Cc016216Cd45d7BD6D4A](https://scan.optimex.xyz/address/0xcceAb862dD41f6691d81Cc016216Cd45d7BD6D4A)
|
|
98
|
+
|
|
99
|
+
**Ethereum Mainnet**
|
|
143
100
|
- **Payment**: [0x0A497AC4261E37FA4062762C23Cf3cB642C839b8](https://etherscan.io/address/0x0A497AC4261E37FA4062762C23Cf3cB642C839b8)
|
|
144
101
|
- **ETHVault**: [0xF7fedF4A250157010807E6eA60258E3B768149Ff](https://etherscan.io/address/0xF7fedF4A250157010807E6eA60258E3B768149Ff)
|
|
145
102
|
- **WETHVault**: [0xaD3f379AaED8Eca895209Af446F2e34f07145dbC](https://etherscan.io/address/0xaD3f379AaED8Eca895209Af446F2e34f07145dbC)
|
|
103
|
+
- **USDCVault**: [0x4463084C01ed22E8320D345b357721aE525Db93F](https://etherscan.io/address/0x4463084C01ed22E8320D345b357721aE525Db93F)
|
|
146
104
|
- **USDTVault**: [0x0712CAB9e52a37aFC6fA768b20cc9b07325314fB](https://etherscan.io/address/0x0712CAB9e52a37aFC6fA768b20cc9b07325314fB)
|
|
147
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.
|
|
148
109
|
|
|
149
110
|
## 3. PMM Backend APIs
|
|
150
111
|
|
|
@@ -189,7 +150,8 @@ GET /indicative-quote?from_token_id=ETH&to_token_id=BTC&amount=10000000000000000
|
|
|
189
150
|
- `indicative_quote` (string): The indicative quote value, represented as a string. Should be treated as a BigInt in your implementation.
|
|
190
151
|
- `error` (string): Error message, if any (empty if no error).
|
|
191
152
|
|
|
192
|
-
|
|
153
|
+
<details>
|
|
154
|
+
<summary><strong>Example Implementation</strong></summary>
|
|
193
155
|
|
|
194
156
|
```js
|
|
195
157
|
async function getIndicativeQuote(req, res) {
|
|
@@ -240,6 +202,7 @@ async function getIndicativeQuote(req, res) {
|
|
|
240
202
|
}
|
|
241
203
|
}
|
|
242
204
|
```
|
|
205
|
+
</details>
|
|
243
206
|
|
|
244
207
|
### 3.2. Endpoint: `/commitment-quote`
|
|
245
208
|
|
|
@@ -286,7 +249,8 @@ GET /commitment-quote?session_id=12345&trade_id=0x3bfe2fc4889a98a39b31b348e7b212
|
|
|
286
249
|
- `commitment_quote` (string): The committed quote value, represented as a string. Should be treated as a BigInt in your implementation.
|
|
287
250
|
- `error` (string): Error message, if any (empty if no error).
|
|
288
251
|
|
|
289
|
-
|
|
252
|
+
<details>
|
|
253
|
+
<summary><strong>Example Implementation</strong></summary>
|
|
290
254
|
|
|
291
255
|
```js
|
|
292
256
|
async function getCommitmentQuote(req, res) {
|
|
@@ -366,6 +330,7 @@ async function getCommitmentQuote(req, res) {
|
|
|
366
330
|
}
|
|
367
331
|
}
|
|
368
332
|
```
|
|
333
|
+
</details>
|
|
369
334
|
|
|
370
335
|
### 3.3. Endpoint: `/settlement-signature`
|
|
371
336
|
|
|
@@ -382,7 +347,6 @@ Returns a signature from the PMM to confirm the settlement quote, required to fi
|
|
|
382
347
|
- `trade_deadline` (string): The UNIX timestamp (in seconds) by which the user expects to receive payment.
|
|
383
348
|
- `script_deadline` (string): The UNIX timestamp (in seconds) after which the user can withdraw their deposit if not paid.
|
|
384
349
|
|
|
385
|
-
|
|
386
350
|
#### Example Request
|
|
387
351
|
|
|
388
352
|
```
|
|
@@ -408,7 +372,8 @@ GET /settlement-signature?trade_id=0x3d09b8eb94466bffa126aeda68c8c0f330633a7d005
|
|
|
408
372
|
- `deadline` (integer): The UNIX timestamp (in seconds) indicating the PMM's expected payment deadline.
|
|
409
373
|
- `error` (string): Error message, if any (empty if no error).
|
|
410
374
|
|
|
411
|
-
|
|
375
|
+
<details>
|
|
376
|
+
<summary><strong>Example Implementation</strong></summary>
|
|
412
377
|
|
|
413
378
|
```js
|
|
414
379
|
async function getSettlementSignature(req, res) {
|
|
@@ -471,6 +436,7 @@ async function getSettlementSignature(req, res) {
|
|
|
471
436
|
}
|
|
472
437
|
}
|
|
473
438
|
```
|
|
439
|
+
</details>
|
|
474
440
|
|
|
475
441
|
### 3.4. Endpoint: `/ack-settlement`
|
|
476
442
|
|
|
@@ -513,7 +479,8 @@ trade_id=0x024be4dae899989e0c3d9b4459e5811613bcd04016dc56529f16a19d2a7724c0&trad
|
|
|
513
479
|
- `status` (string): Status of the acknowledgment (always `"acknowledged"`).
|
|
514
480
|
- `error` (string): Error message, if any (empty if no error).
|
|
515
481
|
|
|
516
|
-
|
|
482
|
+
<details>
|
|
483
|
+
<summary><strong>Example Implementation</strong></summary>
|
|
517
484
|
|
|
518
485
|
```js
|
|
519
486
|
async function ackSettlement(req, res) {
|
|
@@ -551,6 +518,7 @@ async function ackSettlement(req, res) {
|
|
|
551
518
|
}
|
|
552
519
|
}
|
|
553
520
|
```
|
|
521
|
+
</details>
|
|
554
522
|
|
|
555
523
|
### 3.5. Endpoint: `/signal-payment`
|
|
556
524
|
|
|
@@ -593,7 +561,8 @@ trade_id=0x3bfe2fc4889a98a39b31b348e7b212ea3f2bea63fd1ea2e0c8ba326433677328&tota
|
|
|
593
561
|
- `status` (string): Status of the acknowledgment (always `"acknowledged"`).
|
|
594
562
|
- `error` (string): Error message, if any (empty if no error).
|
|
595
563
|
|
|
596
|
-
|
|
564
|
+
<details>
|
|
565
|
+
<summary><strong>Example Implementation</strong></summary>
|
|
597
566
|
|
|
598
567
|
```js
|
|
599
568
|
async function signalPayment(req, res) {
|
|
@@ -637,15 +606,14 @@ async function signalPayment(req, res) {
|
|
|
637
606
|
}
|
|
638
607
|
}
|
|
639
608
|
```
|
|
609
|
+
</details>
|
|
640
610
|
|
|
641
611
|
## 4. Solver API Endpoints for PMMs
|
|
642
612
|
|
|
643
|
-
|
|
644
613
|
These API endpoints are provided by the Solver backend for PMMs to retrieve token information and submit settlement data.
|
|
645
614
|
|
|
646
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.
|
|
647
616
|
|
|
648
|
-
|
|
649
617
|
### 4.1. Endpoint: `/v1/market-maker/tokens`
|
|
650
618
|
|
|
651
619
|
#### Description
|
|
@@ -665,7 +633,10 @@ GET /v1/market-maker/tokens
|
|
|
665
633
|
#### Expected Response
|
|
666
634
|
|
|
667
635
|
- **HTTP Status**: `200 OK`
|
|
668
|
-
- **Response Body
|
|
636
|
+
- **Response Body**: JSON containing supported networks, tokens, and trading pairs
|
|
637
|
+
|
|
638
|
+
<details>
|
|
639
|
+
<summary><strong>View Example Response</strong></summary>
|
|
669
640
|
|
|
670
641
|
```json
|
|
671
642
|
{
|
|
@@ -737,12 +708,12 @@ GET /v1/market-maker/tokens
|
|
|
737
708
|
}
|
|
738
709
|
}
|
|
739
710
|
```
|
|
711
|
+
</details>
|
|
740
712
|
|
|
741
713
|
### 4.2. Endpoint: `/v1/market-maker/submit-settlement-tx`
|
|
742
714
|
|
|
743
715
|
#### Description
|
|
744
|
-
|
|
745
|
-
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.
|
|
746
717
|
|
|
747
718
|
#### Request Parameters
|
|
748
719
|
|
|
@@ -760,12 +731,44 @@ Allows the PMM to submit the settlement transaction hash for one or more trades.
|
|
|
760
731
|
}
|
|
761
732
|
```
|
|
762
733
|
|
|
763
|
-
- `trade_ids` (array of strings):
|
|
764
|
-
- `pmm_id` (string):
|
|
765
|
-
- `
|
|
766
|
-
- `
|
|
767
|
-
- `
|
|
768
|
-
- `
|
|
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>
|
|
769
772
|
|
|
770
773
|
#### Example Request
|
|
771
774
|
|
|
@@ -776,7 +779,7 @@ Content-Type: application/json
|
|
|
776
779
|
{
|
|
777
780
|
"trade_ids": ["0xabcdef123456...", "0x123456abcdef..."],
|
|
778
781
|
"pmm_id": "pmm001",
|
|
779
|
-
"settlement_tx": "
|
|
782
|
+
"settlement_tx": "0x33643833633738343664366535623034323739313735613935393237303561313533373366333032396238363664353232346363303734343438396665343033",
|
|
780
783
|
"signature": "0xSignatureData",
|
|
781
784
|
"start_index": 0,
|
|
782
785
|
"signed_at": 1719158400
|
|
@@ -815,13 +818,92 @@ Returns detailed information about a specific trade by its trade ID. This endpoi
|
|
|
815
818
|
#### Example Request
|
|
816
819
|
|
|
817
820
|
```
|
|
818
|
-
GET /v1/market-maker/trades/
|
|
821
|
+
GET /v1/market-maker/trades/0xfc24b9bc1299b50896027cb4c85d041c911e062147ffaf7ae9c7e51b670086c2
|
|
819
822
|
```
|
|
820
823
|
|
|
821
824
|
#### Expected Response
|
|
822
825
|
|
|
823
826
|
- **HTTP Status**: `200 OK`
|
|
824
|
-
- **Response Body
|
|
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>
|
|
825
907
|
|
|
826
908
|
## 5. PMM Making Payment
|
|
827
909
|
|
|
@@ -829,8 +911,6 @@ GET /v1/market-maker/trades/0x650e2c921a85eb0b8831ff838d4d98c0a5cd2ede5c0cb6bb4a
|
|
|
829
911
|
|
|
830
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.
|
|
831
913
|
|
|
832
|
-
Example implementation:
|
|
833
|
-
|
|
834
914
|
```js
|
|
835
915
|
const { ethers } = require('ethers');
|
|
836
916
|
|
|
@@ -887,8 +967,6 @@ async function makeEVMPayment(tradeId, toAddress, amount, token, protocolFeeAmou
|
|
|
887
967
|
|
|
888
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.
|
|
889
969
|
|
|
890
|
-
Example implementation:
|
|
891
|
-
|
|
892
970
|
```js
|
|
893
971
|
import * as bitcoin from 'bitcoinjs-lib'
|
|
894
972
|
import { ECPairFactory } from 'ecpair'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@optimex-xyz/market-maker-sdk",
|
|
3
|
-
"version": "0.6.
|
|
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.
|
|
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.
|
|
49
|
+
"ethers": "^6.13.7",
|
|
50
50
|
"tiny-secp256k1": "^2.2.3",
|
|
51
|
-
"zod": "^3.24.
|
|
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.
|
|
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.
|
|
60
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
61
|
-
"@typescript-eslint/parser": "^8.
|
|
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.
|
|
64
|
-
"eslint-config-prettier": "^10.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.
|
|
67
|
+
"lint-staged": "^15.5.1",
|
|
68
68
|
"prettier": "^3.5.3",
|
|
69
|
-
"simple-git-hooks": "^2.
|
|
69
|
+
"simple-git-hooks": "^2.13.0",
|
|
70
70
|
"tsup": "^8.4.0",
|
|
71
71
|
"typechain": "^8.3.2",
|
|
72
|
-
"typescript": "^5.8.
|
|
73
|
-
"typescript-eslint": "^8.
|
|
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",
|