Skip to content

Commit 89dbda2

Browse files
authored
fix(express-relay): Update endpoint and simplify nestings (#693)
* fix(per): Update per endpoint * fix(per): Remove unnecessary nesting
1 parent 3c0ff56 commit 89dbda2

File tree

8 files changed

+93
-101
lines changed

8 files changed

+93
-101
lines changed

pages/express-relay/_meta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
"api-reference": {
2727
"title": "HTTP API Reference ↗",
28-
"href": "https://pyth-express-relay-mainnet.asymmetric.re/docs",
28+
"href": "https://per-mainnet.dourolabs.app/docs",
2929
"newWindow": true
3030
},
3131
"websocket-api-reference": "Websocket API Reference",

pages/express-relay/contract-addresses/svm.mdx renamed to pages/express-relay/contract-addresses.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ title: SVM
33
---
44

55
import { Tabs, Callout } from "nextra/components";
6-
import AddressSvmTable from "../../../components/AddressSvmTable";
6+
import AddressSvmTable from "../../components/AddressSvmTable";
77

88
# SVM Contract Addresses
99

1010
Express Relay is currently deployed on the following SVM environments:
1111

1212
<Tabs items={['Prod (Solana Mainnet-Beta)', 'Testing (Solana Mainnet-Beta)']}>
1313
<Tabs.Tab>
14-
Auction Server endpoint: https://pyth-express-relay-mainnet.asymmetric.re/
14+
Auction Server endpoint: https://per-mainnet.dourolabs.app/
1515

1616
### Prod
1717

File renamed without changes.
Lines changed: 80 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,82 @@
1-
# How to Integrate Express Relay as a Protocol
1+
import { Steps } from "nextra/components";
22

3-
This section covers how to integrate Express Relay for your use case. Please see the relevant section below for the use case of interest.
3+
# How to Integrate Express Relay Swaps
44

5-
- [Swaps](integrate-as-protocol/swaps)
5+
This guide will explain how frontends can integrate Express Relay to empower swapping.
6+
7+
<Steps>
8+
### Install the Express Relay SDK
9+
10+
Pyth provides a [Typescript SDK](https://www.npmjs.com/package/@pythnetwork/express-relay-js) to help developers integrate Express Relay into their frontends.
11+
12+
You can install the SDK via npm or yarn. You can invoke the SDK client as below:
13+
14+
```typescript
15+
import { Client } from "@pythnetwork/express-relay-js";
16+
17+
const client = new Client(
18+
{ baseUrl: "https://per-mainnet.dourolabs.app" },
19+
undefined // Default WebSocket options
20+
);
21+
```
22+
23+
### Request a Quote
24+
25+
You can request a quote by calling the [`getQuote`](https://github.com/pyth-network/per/blob/281de989db887aaf568fed39315a76acc16548fa/sdk/js/src/index.ts#L501-L506) SDK method.
26+
27+
The example below shows how you can construct a quote request for a USDC -> WSOL swap, with 100 USDC provided as input by the user:
28+
29+
```typescript
30+
const userWallet = new PublicKey("<INPUT USER PUBKEY>");
31+
32+
const quoteRequest = {
33+
chainId: "solana",
34+
inputTokenMint: new PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"), // USDC mint
35+
outputTokenMint: new PublicKey("So11111111111111111111111111111111111111112"), // WSOL mint
36+
specifiedTokenAmount: {
37+
side: "input",
38+
amount: 100_000_000,
39+
},
40+
userWallet,
41+
};
42+
43+
const quote = await client.getQuote(quoteRequest);
44+
```
45+
46+
`quote` contains the full details, including the amount the searcher is quoting and the transaction that the user needs to sign. It also contains an `expirationTime`; after this time, the transaction will no longer succeed on chain, so you should request a new quote a few seconds before the `expirationTime`.
47+
48+
### Submit User Signature to the Express Relay Server
49+
50+
Once you show the quote to the user, the user should sign the transaction if they wish to engage in the swap. The frontend can pass this signature along to the Express Relay server, which will handle aggregating all the required signatures for the transaction and submitting it to the RPC node.
51+
52+
Below is an example showing how the frontend can submit the signed quote transaction to the server using the [`submitQuote`](https://github.com/pyth-network/per/blob/358eedc1f9072cdfc3418fba309697580f2474f9/sdk/js/src/index.ts#L537-L542) method. The response from the `getQuote` method includes a field called `referenceId`, which the frontend should use in its submission of the user signature.
53+
54+
```typescript
55+
const submitQuote = {
56+
chainId: "solana",
57+
referenceId: quote.referenceId,
58+
userSignature: signature,
59+
};
60+
61+
const txSubmitted = await client.submitQuote(submitQuote);
62+
```
63+
64+
`submitQuote` returns the fully signed transaction that the server submitted to the RPC node.
65+
66+
</Steps>
67+
68+
## Additional Resources
69+
70+
You may find these additional resources helpful for integrating Express Relay as a frontend.
71+
72+
### Contract Addresses
73+
74+
The [SVM](./contract-addresses.mdx) Contract Addresses page lists the relevant addresses for Express Relay integration.
75+
76+
### Error Codes
77+
78+
The [SVM](./errors.mdx) Error Codes page lists the error codes returned by Express Relay.
79+
80+
### API Reference
81+
82+
The [API Reference](https://per-mainnet.dourolabs.app/docs) provides detailed information on Express Relay APIs.

pages/express-relay/integrate-as-protocol/_meta.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

pages/express-relay/integrate-as-protocol/swaps.mdx

Lines changed: 0 additions & 82 deletions
This file was deleted.

pages/express-relay/integrate-as-searcher/svm.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Callout, Tabs, Steps } from "nextra/components";
22

33
# SVM Searcher Integration
44

5-
SVM Express Relay searchers fulfill opportunities representing limit orders on the [Limo](https://solscan.io/account/LiMoM9rMhrdYrfzUCxQppvxCSG1FcrUK9G8uLq4A1GF) program.
5+
SVM Express Relay searchers fulfill market order opportunities as well as limit orders on the [Limo](https://solscan.io/account/LiMoM9rMhrdYrfzUCxQppvxCSG1FcrUK9G8uLq4A1GF) program.
66

77
<Steps>
88

@@ -25,7 +25,7 @@ const handleOpportunity = async (opportunity: Opportunity) => {
2525
};
2626

2727
const client = new Client(
28-
{ baseUrl: "https://pyth-express-relay-mainnet.asymmetric.re" },
28+
{ baseUrl: "https://per-mainnet.dourolabs.app" },
2929
undefined, // Default WebSocket options
3030
handleOpportunity
3131
);
@@ -53,7 +53,7 @@ async def opportunity_callback(opportunity: Opportunity):
5353
# Implement your opportunity handler here
5454

5555
client = ExpressRelayClient(
56-
"https://pyth-express-relay-mainnet.asymmetric.re",
56+
"https://per-mainnet.dourolabs.app",
5757
None,
5858
opportunity_callback,
5959
None,
@@ -70,18 +70,18 @@ if __name__ == "__main__":
7070

7171
</Tabs.Tab>
7272
<Tabs.Tab>
73-
Searchers can request opportunities through an HTTP **GET** call to the [`/v1/opportunities`](https://pyth-express-relay-mainnet.asymmetric.re/docs#tag/opportunity/operation/get_opportunities) endpoint.
73+
Searchers can request opportunities through an HTTP **GET** call to the [`/v1/opportunities`](https://per-mainnet.dourolabs.app/docs#tag/opportunity/operation/get_opportunities) endpoint.
7474

7575
```bash copy
7676
curl -X 'GET' \
77-
'https://pyth-express-relay-mainnet.asymmetric.re/v1/opportunities?chain_id=solana&mode=live'
77+
'https://per-mainnet.dourolabs.app/v1/opportunities?chain_id=solana&mode=live'
7878
```
7979

8080
Opportunities are short-lived and could be executed in a matter of seconds. So, the above endpoint could return an empty response.
8181

8282
</Tabs.Tab>
8383
<Tabs.Tab>
84-
Searchers can connect to the server via WebSocket to reduce latency and subscribe to various events. The WebSocket endpoint lives at `/v1/ws`(e.g `wss://pyth-express-relay-mainnet.asymmetric.re/v1/ws`).
84+
Searchers can connect to the server via WebSocket to reduce latency and subscribe to various events. The WebSocket endpoint lives at `/v1/ws`(e.g `wss://per-mainnet.dourolabs.app/v1/ws`).
8585
Here is a sample JSON payload to subscribe to opportunities:
8686

8787
```bash copy
@@ -289,10 +289,10 @@ def opportunity_callback(opportunity: Opportunity):
289289

290290
</Tabs.Tab>
291291
<Tabs.Tab>
292-
Searchers can submit bids through an HTTP POST call to the [`/v1/bids`](https://pyth-express-relay-mainnet.asymmetric.re/docs#tag/bid/operation/bid) endpoint. This endpoint accepts a JSON payload containing the details of the bid.
292+
Searchers can submit bids through an HTTP POST call to the [`/v1/bids`](https://per-mainnet.dourolabs.app/docs#tag/bid/operation/bid) endpoint. This endpoint accepts a JSON payload containing the details of the bid.
293293

294294
```bash copy
295-
curl -X POST https://pyth-express-relay-mainnet.asymmetric.re/v1/bids \
295+
curl -X POST https://per-mainnet.dourolabs.app/v1/bids \
296296
-H "Content-Type: application/json" \
297297
-d '{
298298
"chain_id": "solana",

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Tabs } from "nextra/components";
33
# WebSocket API Reference
44

55
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`).
6+
The WebSocket endpoint lives at `/v1/ws`(e.g `wss://per-mainnet.dourolabs.app/v1/ws`).
77

88
## General format
99

@@ -60,7 +60,7 @@ After a successful subscription, you will receive new opportunities for the sele
6060
}
6161
```
6262

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

6565
To unsubscribe from a list of chains, you can send the following message:
6666

0 commit comments

Comments
 (0)