@optimex-xyz/market-maker-sdk 0.6.1 → 0.7.0-dev-f98f06c
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 +182 -100
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -0
- package/dist/index.mjs +8 -0
- 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
|
|
|
@@ -162,7 +123,11 @@ Provides an indicative quote for the given token pair and trade amount. The quot
|
|
|
162
123
|
- **Query Parameters**:
|
|
163
124
|
- `from_token_id` (string): The ID of the source token.
|
|
164
125
|
- `to_token_id` (string): The ID of the destination token.
|
|
165
|
-
- `amount` (string): The amount of the source token to be traded, represented as a string in base 10 to accommodate large numbers.
|
|
126
|
+
- `amount` (string): The amount of the source token to be traded, represented as a string in base 10 to accommodate large numbers.
|
|
127
|
+
- `session_id` (string, optional): A unique identifier for the session.
|
|
128
|
+
- `deposited` (boolean, optional): Whether the deposit has been confirmed. This allows the PMM to decide the returned quote.
|
|
129
|
+
- `trade_timeout` (string, optional): The deadline when user is expected to receive tokens from PMM in UNIX timestamp. We expect the trade to be completed before this timeout. But if not, some actions can still be taken.
|
|
130
|
+
- `script_timeout` (string, optional): The hard timeout for the trade, UNIX timestamp. After this timeout, the trade will not be processed further.
|
|
166
131
|
|
|
167
132
|
#### Example Request
|
|
168
133
|
|
|
@@ -189,7 +154,8 @@ GET /indicative-quote?from_token_id=ETH&to_token_id=BTC&amount=10000000000000000
|
|
|
189
154
|
- `indicative_quote` (string): The indicative quote value, represented as a string. Should be treated as a BigInt in your implementation.
|
|
190
155
|
- `error` (string): Error message, if any (empty if no error).
|
|
191
156
|
|
|
192
|
-
|
|
157
|
+
<details>
|
|
158
|
+
<summary><strong>Example Implementation</strong></summary>
|
|
193
159
|
|
|
194
160
|
```js
|
|
195
161
|
async function getIndicativeQuote(req, res) {
|
|
@@ -240,6 +206,7 @@ async function getIndicativeQuote(req, res) {
|
|
|
240
206
|
}
|
|
241
207
|
}
|
|
242
208
|
```
|
|
209
|
+
</details>
|
|
243
210
|
|
|
244
211
|
### 3.2. Endpoint: `/commitment-quote`
|
|
245
212
|
|
|
@@ -286,7 +253,8 @@ GET /commitment-quote?session_id=12345&trade_id=0x3bfe2fc4889a98a39b31b348e7b212
|
|
|
286
253
|
- `commitment_quote` (string): The committed quote value, represented as a string. Should be treated as a BigInt in your implementation.
|
|
287
254
|
- `error` (string): Error message, if any (empty if no error).
|
|
288
255
|
|
|
289
|
-
|
|
256
|
+
<details>
|
|
257
|
+
<summary><strong>Example Implementation</strong></summary>
|
|
290
258
|
|
|
291
259
|
```js
|
|
292
260
|
async function getCommitmentQuote(req, res) {
|
|
@@ -366,6 +334,7 @@ async function getCommitmentQuote(req, res) {
|
|
|
366
334
|
}
|
|
367
335
|
}
|
|
368
336
|
```
|
|
337
|
+
</details>
|
|
369
338
|
|
|
370
339
|
### 3.3. Endpoint: `/settlement-signature`
|
|
371
340
|
|
|
@@ -382,7 +351,6 @@ Returns a signature from the PMM to confirm the settlement quote, required to fi
|
|
|
382
351
|
- `trade_deadline` (string): The UNIX timestamp (in seconds) by which the user expects to receive payment.
|
|
383
352
|
- `script_deadline` (string): The UNIX timestamp (in seconds) after which the user can withdraw their deposit if not paid.
|
|
384
353
|
|
|
385
|
-
|
|
386
354
|
#### Example Request
|
|
387
355
|
|
|
388
356
|
```
|
|
@@ -408,7 +376,8 @@ GET /settlement-signature?trade_id=0x3d09b8eb94466bffa126aeda68c8c0f330633a7d005
|
|
|
408
376
|
- `deadline` (integer): The UNIX timestamp (in seconds) indicating the PMM's expected payment deadline.
|
|
409
377
|
- `error` (string): Error message, if any (empty if no error).
|
|
410
378
|
|
|
411
|
-
|
|
379
|
+
<details>
|
|
380
|
+
<summary><strong>Example Implementation</strong></summary>
|
|
412
381
|
|
|
413
382
|
```js
|
|
414
383
|
async function getSettlementSignature(req, res) {
|
|
@@ -471,6 +440,7 @@ async function getSettlementSignature(req, res) {
|
|
|
471
440
|
}
|
|
472
441
|
}
|
|
473
442
|
```
|
|
443
|
+
</details>
|
|
474
444
|
|
|
475
445
|
### 3.4. Endpoint: `/ack-settlement`
|
|
476
446
|
|
|
@@ -513,7 +483,8 @@ trade_id=0x024be4dae899989e0c3d9b4459e5811613bcd04016dc56529f16a19d2a7724c0&trad
|
|
|
513
483
|
- `status` (string): Status of the acknowledgment (always `"acknowledged"`).
|
|
514
484
|
- `error` (string): Error message, if any (empty if no error).
|
|
515
485
|
|
|
516
|
-
|
|
486
|
+
<details>
|
|
487
|
+
<summary><strong>Example Implementation</strong></summary>
|
|
517
488
|
|
|
518
489
|
```js
|
|
519
490
|
async function ackSettlement(req, res) {
|
|
@@ -551,6 +522,7 @@ async function ackSettlement(req, res) {
|
|
|
551
522
|
}
|
|
552
523
|
}
|
|
553
524
|
```
|
|
525
|
+
</details>
|
|
554
526
|
|
|
555
527
|
### 3.5. Endpoint: `/signal-payment`
|
|
556
528
|
|
|
@@ -593,7 +565,8 @@ trade_id=0x3bfe2fc4889a98a39b31b348e7b212ea3f2bea63fd1ea2e0c8ba326433677328&tota
|
|
|
593
565
|
- `status` (string): Status of the acknowledgment (always `"acknowledged"`).
|
|
594
566
|
- `error` (string): Error message, if any (empty if no error).
|
|
595
567
|
|
|
596
|
-
|
|
568
|
+
<details>
|
|
569
|
+
<summary><strong>Example Implementation</strong></summary>
|
|
597
570
|
|
|
598
571
|
```js
|
|
599
572
|
async function signalPayment(req, res) {
|
|
@@ -637,15 +610,14 @@ async function signalPayment(req, res) {
|
|
|
637
610
|
}
|
|
638
611
|
}
|
|
639
612
|
```
|
|
613
|
+
</details>
|
|
640
614
|
|
|
641
615
|
## 4. Solver API Endpoints for PMMs
|
|
642
616
|
|
|
643
|
-
|
|
644
617
|
These API endpoints are provided by the Solver backend for PMMs to retrieve token information and submit settlement data.
|
|
645
618
|
|
|
646
619
|
> **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
620
|
|
|
648
|
-
|
|
649
621
|
### 4.1. Endpoint: `/v1/market-maker/tokens`
|
|
650
622
|
|
|
651
623
|
#### Description
|
|
@@ -665,7 +637,10 @@ GET /v1/market-maker/tokens
|
|
|
665
637
|
#### Expected Response
|
|
666
638
|
|
|
667
639
|
- **HTTP Status**: `200 OK`
|
|
668
|
-
- **Response Body
|
|
640
|
+
- **Response Body**: JSON containing supported networks, tokens, and trading pairs
|
|
641
|
+
|
|
642
|
+
<details>
|
|
643
|
+
<summary><strong>View Example Response</strong></summary>
|
|
669
644
|
|
|
670
645
|
```json
|
|
671
646
|
{
|
|
@@ -737,12 +712,12 @@ GET /v1/market-maker/tokens
|
|
|
737
712
|
}
|
|
738
713
|
}
|
|
739
714
|
```
|
|
715
|
+
</details>
|
|
740
716
|
|
|
741
717
|
### 4.2. Endpoint: `/v1/market-maker/submit-settlement-tx`
|
|
742
718
|
|
|
743
719
|
#### 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.
|
|
720
|
+
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
721
|
|
|
747
722
|
#### Request Parameters
|
|
748
723
|
|
|
@@ -760,12 +735,44 @@ Allows the PMM to submit the settlement transaction hash for one or more trades.
|
|
|
760
735
|
}
|
|
761
736
|
```
|
|
762
737
|
|
|
763
|
-
- `trade_ids` (array of strings):
|
|
764
|
-
- `pmm_id` (string):
|
|
765
|
-
- `
|
|
766
|
-
- `
|
|
767
|
-
- `
|
|
768
|
-
- `
|
|
738
|
+
- `trade_ids` (array of strings): Array of trade IDs included in this settlement transaction.
|
|
739
|
+
- `pmm_id` (string): Your PMM identifier, which must match what was used in the commitment phase.
|
|
740
|
+
- `signature` (string): Your cryptographic signature for this submission.
|
|
741
|
+
- `start_index` (integer): Starting position within batch settlements (typically 0 for single trades).
|
|
742
|
+
- `signed_at` (integer): UNIX timestamp (seconds) when you signed this submission.
|
|
743
|
+
- `settlement_tx` (string): Should be hex format with a `0x` prefix
|
|
744
|
+
|
|
745
|
+
- **For EVM Chains:**
|
|
746
|
+
- Use the transaction hash directly without additional encoding
|
|
747
|
+
- Example: `settlement_tx`: [0x7a87d2c423e13533b5ae0ecc5af900a7b697048103f4f6e32d19edde5e707355](https://etherscan.io/tx/0x7a87d2c423e13533b5ae0ecc5af900a7b697048103f4f6e32d19edde5e707355)
|
|
748
|
+
|
|
749
|
+
- **For Bitcoin or Solana:**
|
|
750
|
+
- Must encode raw_tx string using the `l2Encode` function
|
|
751
|
+
- Example raw_tx string: `3d83c7846d6e5b04279175a9592705a15373f3029b866d5224cc0744489fe403`
|
|
752
|
+
- After encoding
|
|
753
|
+
```
|
|
754
|
+
"settlement_tx": "0x33643833633738343664366535623034323739313735613935393237303561313533373366333032396238363664353232346363303734343438396665343033"
|
|
755
|
+
```
|
|
756
|
+
|
|
757
|
+
<details>
|
|
758
|
+
<summary><strong>Bitcoin l2Encode</strong></summary>
|
|
759
|
+
|
|
760
|
+
```javascript
|
|
761
|
+
import { ethers, toUtf8Bytes, toUtf8String } from 'ethers'
|
|
762
|
+
|
|
763
|
+
export const l2Encode = (info: string) => {
|
|
764
|
+
// Helper function to ensure hex prefix
|
|
765
|
+
const ensureHexPrefix = (value: string) => {
|
|
766
|
+
return value.startsWith('0x') ? value : `0x${value}`
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
if (/^0x[0-9a-fA-F]*$/.test(info)) {
|
|
770
|
+
return info
|
|
771
|
+
}
|
|
772
|
+
return ensureHexPrefix(ethers.hexlify(toUtf8Bytes(info)))
|
|
773
|
+
}
|
|
774
|
+
```
|
|
775
|
+
</details>
|
|
769
776
|
|
|
770
777
|
#### Example Request
|
|
771
778
|
|
|
@@ -776,7 +783,7 @@ Content-Type: application/json
|
|
|
776
783
|
{
|
|
777
784
|
"trade_ids": ["0xabcdef123456...", "0x123456abcdef..."],
|
|
778
785
|
"pmm_id": "pmm001",
|
|
779
|
-
"settlement_tx": "
|
|
786
|
+
"settlement_tx": "0x33643833633738343664366535623034323739313735613935393237303561313533373366333032396238363664353232346363303734343438396665343033",
|
|
780
787
|
"signature": "0xSignatureData",
|
|
781
788
|
"start_index": 0,
|
|
782
789
|
"signed_at": 1719158400
|
|
@@ -815,13 +822,92 @@ Returns detailed information about a specific trade by its trade ID. This endpoi
|
|
|
815
822
|
#### Example Request
|
|
816
823
|
|
|
817
824
|
```
|
|
818
|
-
GET /v1/market-maker/trades/
|
|
825
|
+
GET /v1/market-maker/trades/0xfc24b9bc1299b50896027cb4c85d041c911e062147ffaf7ae9c7e51b670086c2
|
|
819
826
|
```
|
|
820
827
|
|
|
821
828
|
#### Expected Response
|
|
822
829
|
|
|
823
830
|
- **HTTP Status**: `200 OK`
|
|
824
|
-
- **Response Body
|
|
831
|
+
- **Response Body**: JSON containing detailed trade information.
|
|
832
|
+
|
|
833
|
+
<details>
|
|
834
|
+
<summary><strong>View Example Response</strong></summary>
|
|
835
|
+
|
|
836
|
+
```json
|
|
837
|
+
{
|
|
838
|
+
"code": 0,
|
|
839
|
+
"message": "",
|
|
840
|
+
"data": {
|
|
841
|
+
"trade_id": "0xfc24b9bc1299b50896027cb4c85d041c911e062147ffaf7ae9c7e51b670086c2",
|
|
842
|
+
"session_id": "0xa5c2aa8dbff701e1a05707212ce3fb824a6ddd970e5dff5e340d7422ce6bcd97",
|
|
843
|
+
"solver_address": "0xe291307c85f8f0c710180fea7cca25108782dee1",
|
|
844
|
+
"from_token": {
|
|
845
|
+
"token_id": "ETH",
|
|
846
|
+
"chain": "ethereum",
|
|
847
|
+
"address": "native",
|
|
848
|
+
"fee_in": true,
|
|
849
|
+
"fee_out": true
|
|
850
|
+
},
|
|
851
|
+
"to_token": {
|
|
852
|
+
"token_id": "BTC",
|
|
853
|
+
"chain": "bitcoin",
|
|
854
|
+
"address": "native",
|
|
855
|
+
"fee_in": false,
|
|
856
|
+
"fee_out": false
|
|
857
|
+
},
|
|
858
|
+
"amount_before_fees": "3250849775444909",
|
|
859
|
+
"amount_after_fees": "3244348075894020",
|
|
860
|
+
"from_user_address": "0x2997cb0850a0c92db99e6e8745ac83bfb93c10ac",
|
|
861
|
+
"user_receiving_address": "bc1p68q6hew27ljf4ghvlnwqz0fq32qg7tsgc7jr5levfy8r74p5k52qqphk07",
|
|
862
|
+
"script_timeout": 1745544704,
|
|
863
|
+
"protocol_fee_in_bps": "20",
|
|
864
|
+
"affiliate_fee_in_bps": "0",
|
|
865
|
+
"total_fee": "6501699550889",
|
|
866
|
+
"protocol_fee": "6501699550889",
|
|
867
|
+
"affiliate_fee": "0",
|
|
868
|
+
"mpc_asset_chain_pubkey": "0x03c36bcf548094cfc74ec1ea89fc5fe0304461653813cdaa98bc26e2d5221eba9b",
|
|
869
|
+
"best_indicative_quote": "4404",
|
|
870
|
+
"display_indicative_quote": "4404",
|
|
871
|
+
"pmm_finalists": [
|
|
872
|
+
{
|
|
873
|
+
"pmm_id": "pmm_test",
|
|
874
|
+
"pmm_receiving_address": "0xtestaddress"
|
|
875
|
+
}
|
|
876
|
+
],
|
|
877
|
+
"settlement_quote": "5014",
|
|
878
|
+
"receiving_amount": "5014",
|
|
879
|
+
"selected_pmm": "kypseli",
|
|
880
|
+
"selected_pmm_receiving_address": "0xbee0225697a311af58096ce2f03a2b65f1702f00",
|
|
881
|
+
"selected_pmm_operator": "0x01c4f660ccdc4e5bdc5ee477ab0016dc424c473a",
|
|
882
|
+
"selected_pmm_sig_deadline": 1745472704,
|
|
883
|
+
"commitment_retries": 1,
|
|
884
|
+
"pmm_failure_stats": {},
|
|
885
|
+
"commited_signature": "0x842f32d384e6627755bdaa9285727c09731ed44e92555555c7d211fb3333a4c970b8a717ac79560be35fb2f22dc3fb2d80443e88234605fd353c12011fb8d8851c",
|
|
886
|
+
"min_amount_out": null,
|
|
887
|
+
"trade_timeout": 1745472704,
|
|
888
|
+
"user_deposit_tx": "0x202186375a3b8d55de4d8d1afb7f6a5bec8978cef3b705e6cb379729d03b16c7",
|
|
889
|
+
"deposit_vault": "0xf7fedf4a250157010807e6ea60258e3b768149ff",
|
|
890
|
+
"payment_bundle": {
|
|
891
|
+
"trade_ids": [
|
|
892
|
+
"0xfc24b9bc1299b50896027cb4c85d041c911e062147ffaf7ae9c7e51b670086c2"
|
|
893
|
+
],
|
|
894
|
+
"settlement_tx": "3d83c7846d6e5b04279175a9592705a15373f3029b866d5224cc0744489fe403",
|
|
895
|
+
"signature": "0x479a5a89e7a871026b60307351ea650fc667890b25d3d02df7ed2e93f94db90d7c3f8dbd823220896b8ad49b13a90851199236e82a644ffbe99e53503929fe151b",
|
|
896
|
+
"start_index": 0,
|
|
897
|
+
"pmm_id": "kypseli",
|
|
898
|
+
"signed_at": 1745459448
|
|
899
|
+
},
|
|
900
|
+
"user_signature": "0xfe4d3288db2b7d6ebc273dad1e1c55ecf9af2991fb89cc3e52fc0956c13746a043195cc22ed3c38bfa67c81e7819b53095b4282c5ee1d0c23a955baa38d754821b",
|
|
901
|
+
"trade_submission_tx": "0x38dfc953a9d08d95d7218e993302f81180c4d1a9c85f84836f005770167b0133",
|
|
902
|
+
"trade_select_pmm_tx": "0xc68dbf08e5774edd87ae78076ae498ebc4e489ae905f34b13682198f6dbcc6c0",
|
|
903
|
+
"trade_make_payment_tx": "0x962a1d6cced99b1fa53450c50cf4f95cbf600dd25dcd145a98311d275ef22a38",
|
|
904
|
+
"state": "Done",
|
|
905
|
+
"last_update_msg": "Done. Changed at version 10",
|
|
906
|
+
"version": 10
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
```
|
|
910
|
+
</details>
|
|
825
911
|
|
|
826
912
|
## 5. PMM Making Payment
|
|
827
913
|
|
|
@@ -829,8 +915,6 @@ GET /v1/market-maker/trades/0x650e2c921a85eb0b8831ff838d4d98c0a5cd2ede5c0cb6bb4a
|
|
|
829
915
|
|
|
830
916
|
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
917
|
|
|
832
|
-
Example implementation:
|
|
833
|
-
|
|
834
918
|
```js
|
|
835
919
|
const { ethers } = require('ethers');
|
|
836
920
|
|
|
@@ -887,8 +971,6 @@ async function makeEVMPayment(tradeId, toAddress, amount, token, protocolFeeAmou
|
|
|
887
971
|
|
|
888
972
|
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
973
|
|
|
890
|
-
Example implementation:
|
|
891
|
-
|
|
892
974
|
```js
|
|
893
975
|
import * as bitcoin from 'bitcoinjs-lib'
|
|
894
976
|
import { ECPairFactory } from 'ecpair'
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DeferredTopicFilter, EventFragment, EventLog, TransactionRequest, Typed, ContractTransactionResponse, FunctionFragment, ContractTransaction, LogDescription, BaseContract, ContractRunner, Interface, AddressLike, BigNumberish, BytesLike, Result, Listener, ContractMethod, Provider, Signer as Signer$1, Wallet, TypedDataDomain } from 'ethers';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
|
-
type Environment = 'dev' | 'prelive' | 'production';
|
|
4
|
+
type Environment = 'dev' | 'prelive' | 'production' | 'staging';
|
|
5
5
|
interface EnvironmentConfig {
|
|
6
6
|
backendUrl: string;
|
|
7
7
|
rpcUrl: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DeferredTopicFilter, EventFragment, EventLog, TransactionRequest, Typed, ContractTransactionResponse, FunctionFragment, ContractTransaction, LogDescription, BaseContract, ContractRunner, Interface, AddressLike, BigNumberish, BytesLike, Result, Listener, ContractMethod, Provider, Signer as Signer$1, Wallet, TypedDataDomain } from 'ethers';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
|
-
type Environment = 'dev' | 'prelive' | 'production';
|
|
4
|
+
type Environment = 'dev' | 'prelive' | 'production' | 'staging';
|
|
5
5
|
interface EnvironmentConfig {
|
|
6
6
|
backendUrl: string;
|
|
7
7
|
rpcUrl: string;
|
package/dist/index.js
CHANGED
|
@@ -72,6 +72,14 @@ module.exports = __toCommonJS(index_exports);
|
|
|
72
72
|
// src/config/config.ts
|
|
73
73
|
var environments = {
|
|
74
74
|
dev: {
|
|
75
|
+
backendUrl: "https://api-dev.bitdex.xyz",
|
|
76
|
+
rpcUrl: "https://rpc-bitfi-p00c4t1rul.t.conduit.xyz",
|
|
77
|
+
routerAddress: "0x193501E5F72a42DACCF8Eb1C4AB37561c213309D",
|
|
78
|
+
paymentAddressMap: {
|
|
79
|
+
ethereum_sepolia: "0x7387DcCfE2f1D5F80b4ECDF91eF58541517e90D2"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
staging: {
|
|
75
83
|
backendUrl: "https://api-stg.bitdex.xyz",
|
|
76
84
|
rpcUrl: "https://rpc-bitfi-p00c4t1rul.t.conduit.xyz",
|
|
77
85
|
routerAddress: "0x193501E5F72a42DACCF8Eb1C4AB37561c213309D",
|
package/dist/index.mjs
CHANGED
|
@@ -7,6 +7,14 @@ var __export = (target, all) => {
|
|
|
7
7
|
// src/config/config.ts
|
|
8
8
|
var environments = {
|
|
9
9
|
dev: {
|
|
10
|
+
backendUrl: "https://api-dev.bitdex.xyz",
|
|
11
|
+
rpcUrl: "https://rpc-bitfi-p00c4t1rul.t.conduit.xyz",
|
|
12
|
+
routerAddress: "0x193501E5F72a42DACCF8Eb1C4AB37561c213309D",
|
|
13
|
+
paymentAddressMap: {
|
|
14
|
+
ethereum_sepolia: "0x7387DcCfE2f1D5F80b4ECDF91eF58541517e90D2"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
staging: {
|
|
10
18
|
backendUrl: "https://api-stg.bitdex.xyz",
|
|
11
19
|
rpcUrl: "https://rpc-bitfi-p00c4t1rul.t.conduit.xyz",
|
|
12
20
|
routerAddress: "0x193501E5F72a42DACCF8Eb1C4AB37561c213309D",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@optimex-xyz/market-maker-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0-dev-f98f06c",
|
|
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",
|