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.mdx similarity index 95% rename from pages/express-relay/contract-addresses/svm.mdx rename to pages/express-relay/contract-addresses.mdx index d982367a..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 @@ -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/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..35f2eb55 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 { 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.mdx) Contract Addresses page lists the relevant addresses for Express Relay integration. + +### Error Codes + +The [SVM](./errors.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 0c8d78bf..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://pyth-express-relay-mainnet.asymmetric.re" }, - 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://pyth-express-relay-mainnet.asymmetric.re/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..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. @@ -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: