You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Express Relay gives one place stop for on-chain opportunities. Searchers can access opportunities from various DeFi protocols via a simple and unified interface.
5
+
Express Relay gives one place stop for on-chain opportunities. Searchers can access opportunities from various DeFi protocols via a simple and unified interface.
6
6
7
7
Searchers **bid** on opportunities exposed by the Express Relay server.
8
-
The server exposes different endpoints for interaction, which can be used directly via HTTP, WebSocket, or one of the SDKS for convenience.
8
+
The server exposes different endpoints for interaction, which can be used directly via HTTP, WebSocket, or one of the SDKs for convenience.
9
9
10
+
Searchers can integrate with the Express Relay server in three steps:
10
11
11
-
Searchers can integrate with the Express Relay server in two steps:
12
-
- Integrate with the auction server
13
-
- Integrate with the opportunity adapter _(OPTIONAL)_
12
+
1. Subscribe to new opportunities
13
+
2. Evaluating the opportunity and constructing the bid
14
+
3. Submitting the bid to the auction server
14
15
16
+
<Steps>
17
+
18
+
### Subscribe to new opportunities
15
19
20
+
Searchers can fetch available opportunities via HTTP or subscribe to them via WebSocket.
Opportunities are short-lived and will be executed in a matter of seconds. So it is possible for this endpoint to return an empty response.
77
+
78
+
You can fetch historical opportunities by setting the `mode` parameter to `historical`.
79
+
42
80
</Tabs.Tab>
43
81
<Tabs.Tab>
44
82
Searchers can connect to the server via WebSocket to reduce latency and subscribe to various events. The WebSocket endpoint relies at `/v1/ws`(e.g `wss://pyth-express-relay-mainnet.asymmetric.re/v1/ws`)
83
+
Here is a sample json payload to subscribe to opportunities:
45
84
46
-
```bash copy
85
+
```json copy
47
86
{
48
-
"id": "1",
49
-
"method": "subscribe", // Name of the server method to invoke
50
-
"params": {
51
-
"chain_ids": ["op_sepolia"]
52
-
}
87
+
"id": "1",
88
+
"method": "subscribe",
89
+
"params": {
90
+
"chain_ids": ["op_sepolia"]
91
+
}
53
92
}
54
93
```
55
94
56
95
Consult [`Websocket API reference`](./websocket-api-reference.mdx) for a complete list of methods and parameters.
96
+
57
97
</Tabs.Tab>
58
98
</Tabs>
59
99
60
100
The server responds with opportunities in the following format:
61
101
62
102
```json copy
63
103
{
64
-
"target_calldata": "0xdeadbeef", // Calldata to perform liquidation
65
-
"chain_id": "op_sepolia",
66
-
"target_contract": "0xcA11bde05977b3631167028862bE2a173976CA11", // Protocol contract address to call for liquidation
67
-
"permission_key": "0xcafebabe", // Unique identifier for the liquidation opportunity
68
-
"target_call_value": "1", // Value(in Wei) to send with to the Protocol contract.
69
-
"buy_tokens": [ // Tokens to buy (Collateral)
104
+
"target_calldata": "0xdeadbeef", // Calldata to execute the opportunity
105
+
"chain_id": "op_sepolia",
106
+
"target_contract": "0xcA11bde05977b3631167028862bE2a173976CA11", // Protocol contract address to call for execution
107
+
"permission_key": "0xcafebabe", // Permission key required for the liquidation opportunity
108
+
"target_call_value": "1", // Value(in Wei) to send with to the Protocol contract.
### Evaluating the opportunity and constructing the bid
85
128
129
+
Based on the opportunity details, mainly the sell tokens and buy tokens, searchers can evaluate the opportunity and construct a bid.
130
+
The SDKs provide an easy way to construct a bid using the `OpportunityAdapter` contract. The `OpportunityAdapter` contract handles asset transfers and ensures the opportunity is executed correctly.
131
+
132
+
You can learn more about the `OpportunityAdapter` contract and how to prepare your assets in the [Opportunity Adapter](./integrate-as-searcher/opportunity-adapter.mdx) section.
133
+
If you have already developed an in-house searcher contract there is no need to integrate using the Opportunity Adapter contract.
134
+
You can use our lower level APIs which allows higher flexibility for advanced users.
135
+
Please refer to the [custom contracts](./custom-contract) section for more details.
Searchers can submit bids through an HTTP POST call to the `/v1/bids` endpoint. This endpoint accepts a JSON payload containing the details of the bid.
95
200
96
201
```bash copy
97
-
{
202
+
curl -X POST https://pyth-express-relay-mainnet.asymmetric.re/v1/bids \
@@ -139,44 +247,7 @@ A successful response to a bid submission has the following schema:
139
247
```
140
248
141
249
Consult [`Websocket API reference`](./websocket-api-reference.mdx) for more details.
250
+
142
251
</Tabs.Tab>
143
252
</Tabs>
144
253
</Steps>
145
-
146
-
147
-
Searchers are **recommended** to source opportunities via the opportunity endpoints and construct transactions intended for the `OpportunityAdapter`.
148
-
However, searchers can use custom contracts to execute transactions if they prefer.
149
-
If searchers use custom contracts, they can still use the Express Relay server to source opportunities and craft bids based on the opportunity details.
150
-
151
-
Check the following example of a custom contract that executes liquidation transactions:
0 commit comments