From 39baadf75113d1403fea95833db0ddd305a91510 Mon Sep 17 00:00:00 2001 From: Amin Moghaddam Date: Fri, 9 May 2025 11:18:25 -0700 Subject: [PATCH 1/4] fix(per): Update per endpoint --- pages/express-relay/_meta.json | 2 +- pages/express-relay/contract-addresses/svm.mdx | 2 +- .../express-relay/integrate-as-protocol/swaps.mdx | 4 ++-- pages/express-relay/integrate-as-searcher/svm.mdx | 14 +++++++------- pages/express-relay/websocket-api-reference.mdx | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/pages/express-relay/_meta.json b/pages/express-relay/_meta.json index 681c4da6..d6a8d6d5 100644 --- a/pages/express-relay/_meta.json +++ b/pages/express-relay/_meta.json @@ -25,7 +25,7 @@ "api-reference": { "title": "HTTP API Reference ↗", - "href": "https://pyth-express-relay-mainnet.asymmetric.re/docs", + "href": "https://per-mainnet.dourolabs.app/docs", "newWindow": true }, "websocket-api-reference": "Websocket API Reference", diff --git a/pages/express-relay/contract-addresses/svm.mdx b/pages/express-relay/contract-addresses/svm.mdx index d982367a..3344a3e6 100644 --- a/pages/express-relay/contract-addresses/svm.mdx +++ b/pages/express-relay/contract-addresses/svm.mdx @@ -11,7 +11,7 @@ Express Relay is currently deployed on the following SVM environments: -Auction Server endpoint: https://pyth-express-relay-mainnet.asymmetric.re/ +Auction Server endpoint: https://per-mainnet.dourolabs.app/ ### Prod diff --git a/pages/express-relay/integrate-as-protocol/swaps.mdx b/pages/express-relay/integrate-as-protocol/swaps.mdx index 0c8d78bf..725b279f 100644 --- a/pages/express-relay/integrate-as-protocol/swaps.mdx +++ b/pages/express-relay/integrate-as-protocol/swaps.mdx @@ -15,7 +15,7 @@ You can install the SDK via npm or yarn. You can invoke the SDK client as below: import { Client } from "@pythnetwork/express-relay-js"; const client = new Client( - { baseUrl: "https://pyth-express-relay-mainnet.asymmetric.re" }, + { baseUrl: "https://per-mainnet.dourolabs.app" }, undefined // Default WebSocket options ); ``` @@ -79,4 +79,4 @@ The [SVM](../errors/svm.mdx) Error Codes page lists the error codes returned by ### API Reference -The [API Reference](https://pyth-express-relay-mainnet.asymmetric.re/docs) provides detailed information on Express Relay APIs. +The [API Reference](https://per-mainnet.dourolabs.app/docs) provides detailed information on Express Relay APIs. diff --git a/pages/express-relay/integrate-as-searcher/svm.mdx b/pages/express-relay/integrate-as-searcher/svm.mdx index ac897d59..eede2352 100644 --- a/pages/express-relay/integrate-as-searcher/svm.mdx +++ b/pages/express-relay/integrate-as-searcher/svm.mdx @@ -25,7 +25,7 @@ const handleOpportunity = async (opportunity: Opportunity) => { }; const client = new Client( - { baseUrl: "https://pyth-express-relay-mainnet.asymmetric.re" }, + { baseUrl: "https://per-mainnet.dourolabs.app" }, undefined, // Default WebSocket options handleOpportunity ); @@ -53,7 +53,7 @@ async def opportunity_callback(opportunity: Opportunity): # Implement your opportunity handler here client = ExpressRelayClient( - "https://pyth-express-relay-mainnet.asymmetric.re", + "https://per-mainnet.dourolabs.app", None, opportunity_callback, None, @@ -70,18 +70,18 @@ if __name__ == "__main__": -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. +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. ```bash copy curl -X 'GET' \ - 'https://pyth-express-relay-mainnet.asymmetric.re/v1/opportunities?chain_id=solana&mode=live' + 'https://per-mainnet.dourolabs.app/v1/opportunities?chain_id=solana&mode=live' ``` Opportunities are short-lived and could be executed in a matter of seconds. So, the above endpoint could return an empty response. -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`). +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`). Here is a sample JSON payload to subscribe to opportunities: ```bash copy @@ -289,10 +289,10 @@ def opportunity_callback(opportunity: Opportunity): -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. +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. ```bash copy -curl -X POST https://pyth-express-relay-mainnet.asymmetric.re/v1/bids \ +curl -X POST https://per-mainnet.dourolabs.app/v1/bids \ -H "Content-Type: application/json" \ -d '{ "chain_id": "solana", diff --git a/pages/express-relay/websocket-api-reference.mdx b/pages/express-relay/websocket-api-reference.mdx index bc81e796..8912016f 100644 --- a/pages/express-relay/websocket-api-reference.mdx +++ b/pages/express-relay/websocket-api-reference.mdx @@ -3,7 +3,7 @@ import { Tabs } from "nextra/components"; # WebSocket API Reference 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`). +The WebSocket endpoint lives at `/v1/ws`(e.g `wss://per-mainnet.dourolabs.app/v1/ws`). ## General format @@ -60,7 +60,7 @@ After a successful subscription, you will receive new opportunities for the sele } ``` -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). +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). To unsubscribe from a list of chains, you can send the following message: From 073a8b14ab34206047ef990246bc6ad7e18b4a84 Mon Sep 17 00:00:00 2001 From: Amin Moghaddam Date: Fri, 9 May 2025 11:23:09 -0700 Subject: [PATCH 2/4] fix(per): Remove unnecessary nesting --- .../svm.mdx => contract-addresses.mdx} | 2 +- .../{errors/svm.mdx => errors.mdx} | 0 pages/express-relay/integrate-as-protocol.mdx | 83 ++++++++++++++++++- .../integrate-as-protocol/_meta.json | 3 - .../integrate-as-protocol/swaps.mdx | 82 ------------------ 5 files changed, 81 insertions(+), 89 deletions(-) rename pages/express-relay/{contract-addresses/svm.mdx => contract-addresses.mdx} (97%) rename pages/express-relay/{errors/svm.mdx => errors.mdx} (100%) delete mode 100644 pages/express-relay/integrate-as-protocol/_meta.json delete mode 100644 pages/express-relay/integrate-as-protocol/swaps.mdx diff --git a/pages/express-relay/contract-addresses/svm.mdx b/pages/express-relay/contract-addresses.mdx similarity index 97% rename from pages/express-relay/contract-addresses/svm.mdx rename to pages/express-relay/contract-addresses.mdx index 3344a3e6..ce25fbb3 100644 --- a/pages/express-relay/contract-addresses/svm.mdx +++ b/pages/express-relay/contract-addresses.mdx @@ -3,7 +3,7 @@ title: SVM --- import { Tabs, Callout } from "nextra/components"; -import AddressSvmTable from "../../../components/AddressSvmTable"; +import AddressSvmTable from "../../components/AddressSvmTable"; # SVM Contract Addresses diff --git a/pages/express-relay/errors/svm.mdx b/pages/express-relay/errors.mdx similarity index 100% rename from pages/express-relay/errors/svm.mdx rename to pages/express-relay/errors.mdx diff --git a/pages/express-relay/integrate-as-protocol.mdx b/pages/express-relay/integrate-as-protocol.mdx index a2e4aa40..2023ecbe 100644 --- a/pages/express-relay/integrate-as-protocol.mdx +++ b/pages/express-relay/integrate-as-protocol.mdx @@ -1,5 +1,82 @@ -# How to Integrate Express Relay as a Protocol +import { Callout, Tabs, Steps } from "nextra/components"; -This section covers how to integrate Express Relay for your use case. Please see the relevant section below for the use case of interest. +# How to Integrate Express Relay Swaps -- [Swaps](integrate-as-protocol/swaps) +This guide will explain how frontends can integrate Express Relay to empower swapping. + + + ### Install the Express Relay SDK + + Pyth provides a [Typescript SDK](https://www.npmjs.com/package/@pythnetwork/express-relay-js) to help developers integrate Express Relay into their frontends. + + You can install the SDK via npm or yarn. You can invoke the SDK client as below: + + ```typescript + import { Client } from "@pythnetwork/express-relay-js"; + + const client = new Client( + { baseUrl: "https://per-mainnet.dourolabs.app" }, + undefined // Default WebSocket options + ); + ``` + + ### Request a Quote + + 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. + + 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: + + ```typescript + const userWallet = new PublicKey(""); + + const quoteRequest = { + chainId: "solana", + inputTokenMint: new PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"), // USDC mint + outputTokenMint: new PublicKey("So11111111111111111111111111111111111111112"), // WSOL mint + specifiedTokenAmount: { + side: "input", + amount: 100_000_000, + }, + userWallet, + }; + + const quote = await client.getQuote(quoteRequest); + ``` + + `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`. + + ### Submit User Signature to the Express Relay Server + + 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. + + 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. + + ```typescript + const submitQuote = { + chainId: "solana", + referenceId: quote.referenceId, + userSignature: signature, + }; + + const txSubmitted = await client.submitQuote(submitQuote); + ``` + + `submitQuote` returns the fully signed transaction that the server submitted to the RPC node. + + + +## Additional Resources + +You may find these additional resources helpful for integrating Express Relay as a frontend. + +### Contract Addresses + +The [SVM](../contract-addresses/svm.mdx) Contract Addresses page lists the relevant addresses for Express Relay integration. + +### Error Codes + +The [SVM](../errors/svm.mdx) Error Codes page lists the error codes returned by Express Relay. + +### API Reference + +The [API Reference](https://per-mainnet.dourolabs.app/docs) provides detailed information on Express Relay APIs. diff --git a/pages/express-relay/integrate-as-protocol/_meta.json b/pages/express-relay/integrate-as-protocol/_meta.json deleted file mode 100644 index c20e21be..00000000 --- a/pages/express-relay/integrate-as-protocol/_meta.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "swaps": "Swaps" -} diff --git a/pages/express-relay/integrate-as-protocol/swaps.mdx b/pages/express-relay/integrate-as-protocol/swaps.mdx deleted file mode 100644 index 725b279f..00000000 --- a/pages/express-relay/integrate-as-protocol/swaps.mdx +++ /dev/null @@ -1,82 +0,0 @@ -import { Callout, Tabs, Steps } from "nextra/components"; - -# How to Integrate Express Relay Swaps - -This guide will explain how frontends can integrate Express Relay to empower swapping. - - -### Install the Express Relay SDK - -Pyth provides a [Typescript SDK](https://www.npmjs.com/package/@pythnetwork/express-relay-js) to help developers integrate Express Relay into their frontends. - -You can install the SDK via npm or yarn. You can invoke the SDK client as below: - -```typescript -import { Client } from "@pythnetwork/express-relay-js"; - -const client = new Client( - { baseUrl: "https://per-mainnet.dourolabs.app" }, - undefined // Default WebSocket options -); -``` - -### Request a Quote - -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. - -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: - -```typescript -const userWallet = new PublicKey(""); - -const quoteRequest = { - chainId: "solana", - inputTokenMint: new PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"), // USDC mint - outputTokenMint: new PublicKey("So11111111111111111111111111111111111111112"), // WSOL mint - specifiedTokenAmount: { - side: "input", - amount: 100_000_000, - }, - userWallet, -}; - -const quote = await client.getQuote(quoteRequest); -``` - -`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`. - -### Submit User Signature to the Express Relay Server - -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. - -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. - -```typescript -const submitQuote = { - chainId: "solana", - referenceId: quote.referenceId, - userSignature: signature, -}; - -const txSubmitted = await client.submitQuote(submitQuote); -``` - -`submitQuote` returns the fully signed transaction that the server submitted to the RPC node. - - - -## Additional Resources - -You may find these additional resources helpful for integrating Express Relay as a frontend. - -### Contract Addresses - -The [SVM](../contract-addresses/svm.mdx) Contract Addresses page lists the relevant addresses for Express Relay integration. - -### Error Codes - -The [SVM](../errors/svm.mdx) Error Codes page lists the error codes returned by Express Relay. - -### API Reference - -The [API Reference](https://per-mainnet.dourolabs.app/docs) provides detailed information on Express Relay APIs. From 2d40187e56055be115538de467899dfdd8696d78 Mon Sep 17 00:00:00 2001 From: Amin Moghaddam Date: Fri, 9 May 2025 11:26:45 -0700 Subject: [PATCH 3/4] fix --- pages/express-relay/integrate-as-protocol.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pages/express-relay/integrate-as-protocol.mdx b/pages/express-relay/integrate-as-protocol.mdx index 2023ecbe..35f2eb55 100644 --- a/pages/express-relay/integrate-as-protocol.mdx +++ b/pages/express-relay/integrate-as-protocol.mdx @@ -1,4 +1,4 @@ -import { Callout, Tabs, Steps } from "nextra/components"; +import { Steps } from "nextra/components"; # How to Integrate Express Relay Swaps @@ -71,11 +71,11 @@ You may find these additional resources helpful for integrating Express Relay as ### Contract Addresses -The [SVM](../contract-addresses/svm.mdx) Contract Addresses page lists the relevant addresses for Express Relay integration. +The [SVM](./contract-addresses.mdx) Contract Addresses page lists the relevant addresses for Express Relay integration. ### Error Codes -The [SVM](../errors/svm.mdx) Error Codes page lists the error codes returned by Express Relay. +The [SVM](./errors.mdx) Error Codes page lists the error codes returned by Express Relay. ### API Reference From f43f1fcd82fc76f2d5247fe0afe9391cb709ef90 Mon Sep 17 00:00:00 2001 From: Amin Moghaddam Date: Fri, 9 May 2025 11:29:24 -0700 Subject: [PATCH 4/4] improv --- pages/express-relay/integrate-as-searcher/svm.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/express-relay/integrate-as-searcher/svm.mdx b/pages/express-relay/integrate-as-searcher/svm.mdx index eede2352..ed43246a 100644 --- a/pages/express-relay/integrate-as-searcher/svm.mdx +++ b/pages/express-relay/integrate-as-searcher/svm.mdx @@ -2,7 +2,7 @@ import { Callout, Tabs, Steps } from "nextra/components"; # SVM Searcher Integration -SVM Express Relay searchers fulfill opportunities representing limit orders on the [Limo](https://solscan.io/account/LiMoM9rMhrdYrfzUCxQppvxCSG1FcrUK9G8uLq4A1GF) program. +SVM Express Relay searchers fulfill market order opportunities as well as limit orders on the [Limo](https://solscan.io/account/LiMoM9rMhrdYrfzUCxQppvxCSG1FcrUK9G8uLq4A1GF) program.