Skip to content

Commit 078f9f0

Browse files
committed
WIP-searcher-guide-refactor
1 parent 84d8831 commit 078f9f0

File tree

2 files changed

+43
-25
lines changed

2 files changed

+43
-25
lines changed

pages/express-relay/errors.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Error Codes
22

3-
The following table lists the error codes and their explanations for ExpressRelay and OpportunityAdapter contracts.
3+
The following table lists the error codes and their explanations for [`ExpressRelay`](https://github.com/pyth-network/per/blob/main/contracts/src/express-relay/ExpressRelay.sol) and [`OpportunityAdapter`](https://github.com/pyth-network/per/blob/main/contracts/src/opportunity-adapter/OpportunityAdapter.sol) contracts.
44
They can be used to identify the cause of a failed transaction or bid.
55

66
## ExpressRelay

pages/express-relay/websocket-api-reference.mdx

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
# Websocket API Reference
1+
import { Tabs } from "nextra/components";
22

3-
You can connect to the server via websocket in order 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`)
3+
# WebSocket API Reference
4+
5+
Searchers can connect to the server via WebSocket to reduce latency and subscribe to various events.
6+
The WebSocket endpoint lives at `/v1/ws`(e.g `wss://pyth-express-relay-mainnet.asymmetric.re/v1/ws`).
47

58
## General format
69

7-
Each request sent to the server via websocket should be in the following json format:
10+
Each request sent to the server via WebSocket should be in the following JSON format:
811

9-
```json
12+
```json copy
1013
{
11-
"id": "...", // used for uniquely identifying the responses to requests
14+
"id": "...", // used for uniquely identifying the response to this request
1215
"method": "...", // name of the server method to invoke
1316
"params": {...} // parameters necessary for the method
1417
}
@@ -24,7 +27,7 @@ The server responds using the same `id` specified in the request:
2427
}
2528
```
2629

27-
In case of error, `status` field will be `error` and the error message will be available in the `result` field as a string:
30+
In case of error, the `status` field will be `error`, and the error message will be available in the `result` field as a string:
2831

2932
```json
3033
{
@@ -36,7 +39,7 @@ In case of error, `status` field will be `error` and the error message will be a
3639

3740
## Subscribing to opportunities
3841

39-
To subscribe to opportunities you can send a request with the `chain_ids` parameter which specifies the chains as an array.
42+
To subscribe to opportunities, you can send a request using the `chain_ids` parameter, which specifies the chains as an array.
4043

4144
```json
4245
{
@@ -48,7 +51,7 @@ To subscribe to opportunities you can send a request with the `chain_ids` parame
4851
}
4952
```
5053

51-
After a successful subscription you will receive the new opportunities for the selected chains via the websocket in the following format:
54+
After a successful subscription, you will receive new opportunities for the selected chains via the WebSocket in the following format:
5255

5356
```json
5457
{
@@ -57,11 +60,11 @@ After a successful subscription you will receive the new opportunities for the s
5760
}
5861
```
5962

60-
The schema for the opportunity is similar to what’s returned in the [http requests](https://pyth-express-relay-mainnet.asymmetric.re/docs/#/liquidation/get_opportunities)
63+
The schema for the opportunity is similar to what’s returned in the [HTTP requests](https://pyth-express-relay-mainnet.asymmetric.re/redoc#tag/opportunity/operation/get_opportunities)
6164

62-
In order to unsubscribe from a list of chains you can send the following message:
65+
To unsubscribe from a list of chains, you can send the following message:
6366

64-
```json
67+
```json copy
6568
{
6669
"id": "1",
6770
"method": "unsubscribe",
@@ -73,9 +76,10 @@ In order to unsubscribe from a list of chains you can send the following message
7376

7477
## Submitting bids
7578

76-
In addition to the http methods, you can submit your bids via websocket in order to avoid additional network round-trips and get notified about changes to your bid status. Here is an example json payload for submitting a new bid
79+
In addition to the HTTP methods, you can submit your bids via WebSocket in order to avoid additional network round trips and get notified about changes to your bid status.
80+
Here is an example JSON payload for submitting a new bid:
7781

78-
```json
82+
```json copy
7983
{
8084
"id": "1",
8185
"method": "post_bid",
@@ -85,30 +89,33 @@ In addition to the http methods, you can submit your bids via websocket in order
8589
"calldata": "0xdeadbeef",
8690
"chain_id": "sepolia",
8791
"contract": "0xcA11bde05977b3631167028862bE2a173976CA11",
88-
"permission_key": "0xdeadbeefcafe"
92+
"permission_key": "0xcafebabe"
8993
}
9094
}
9195
}
9296
```
9397

94-
A successful response to bid submission has the following schema:
98+
A successful response to a bid submission has the following schema:
9599

96100
```json
97101
{
98-
"id": "1", // websocket request id
102+
"id": "1", // WebSocket request id
99103
"status": "success",
100104
"result": {
101-
"id": "beedbeed-b346-4fa1-8fab-2541a9e1872d", //bid id
105+
"id": "beedbeed-b346-4fa1-8fab-2541a9e1872d", // bid id
102106
"status": "OK"
103107
}
104108
}
105109
```
106110

107-
From this point you will receive notifications about the bid status updates in JSON format. We share four examples below, one for each of the status options (”pending”, “submitted”, “lost”, “won”):
111+
After submitting your bid via WebSocket, you will receive notifications about the bid status updates in JSON format.
112+
Refer to the four examples below, one for each of the status options (`pending`, `submitted`, `lost`, `won`):
108113

114+
<Tabs items={[`pending`, `submitted`, `lost`, `won`]}>
115+
<Tabs.Tab>
109116
```json
110117
// pending
111-
// The temporary state which means the auction for this bid is pending
118+
// The temporary state, which means the auction for this bid is pending
112119
{
113120
"type": "bid_status_update",
114121
"status": {
@@ -118,10 +125,13 @@ From this point you will receive notifications about the bid status updates in J
118125
}
119126
}
120127
}
121-
128+
```
129+
</Tabs.Tab>
130+
<Tabs.Tab>
131+
```json
122132
// submitted
123133
// The bid is submitted to the chain, which is placed at the given index of the transaction with the given hash
124-
// This state is temporary and will be updated to either lost or won after conclusion of the auction
134+
// This state is temporary and will be updated to either lost or won after the conclusion of the auction
125135
{
126136
"type": "bid_status_update",
127137
"status": {
@@ -136,7 +146,10 @@ From this point you will receive notifications about the bid status updates in J
136146
}
137147
}
138148
}
139-
149+
```
150+
</Tabs.Tab>
151+
<Tabs.Tab>
152+
```json
140153
// lost
141154
// The bid lost the auction, which is concluded with the transaction with the given hash and index
142155
// The result will be None if the auction was concluded off-chain and no auction was submitted to the chain
@@ -153,7 +166,10 @@ From this point you will receive notifications about the bid status updates in J
153166
}
154167
}
155168
}
156-
169+
```
170+
</Tabs.Tab>
171+
<Tabs.Tab>
172+
```json
157173
// won
158174
// The bid won the auction, which is concluded with the transaction with the given hash and index
159175
{
@@ -171,9 +187,11 @@ From this point you will receive notifications about the bid status updates in J
171187
}
172188
}
173189
```
190+
</Tabs.Tab>
191+
</Tabs>
174192

175193
## Connection Persistence
176194

177-
The websocket server responds to ping messages according to websocket standards.
195+
The WebSocket server responds to ping messages according to WebSocket standards.
178196

179197
Additionally, the server periodically sends a ping message to the client to ensure the connection is still active and expects a pong in return.

0 commit comments

Comments
 (0)