Skip to content

add svm docs #481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions components/AddressSvmTable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { StyledTd } from "./Table";

const AddressSvmTable = ({
entries,
explorer,
}: {
entries: { name: string; value: string; link?: boolean }[];
explorer: string;
}) => {
return (
<table>
<tbody>
{entries.map(({ name, value, link }) => {
const component = (
<code
className={
"nx-border-black nx-border-opacity-[0.04] nx-bg-opacity-[0.03] nx-bg-black nx-break-words nx-rounded-md nx-border nx-py-0.5 nx-px-[.25em] nx-text-[.9em] dark:nx-border-white/10 dark:nx-bg-white/10 "
}
>
{value}
</code>
);
const addLink = explorer.includes("$ADDRESS") && link;
return (
<tr key={name}>
<StyledTd>{name}</StyledTd>
<StyledTd>
{addLink ? (
<a
href={explorer.replace("$ADDRESS", value)}
className={
"nx-text-primary-600 nx-underline nx-decoration-from-font [text-underline-position:from-font]"
}
target={"_blank"}
>
{component}
</a>
) : (
component
)}
</StyledTd>
</tr>
);
})}
</tbody>
</table>
);
};

export default AddressSvmTable;
2 changes: 1 addition & 1 deletion pages/express-relay/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"errors": "Error Codes",
"examples": {
"title": "Example Application ↗",
"href": "https://github.com/pyth-network/pyth-examples/tree/main/express-relay/easy_lend",
"href": "https://github.com/pyth-network/pyth-examples/tree/6cea7c9602c7949c6dacc94aec44c0fe78ccb128/express-relay/easy_lend",
"newWindow": true
},
"-- Understand Express Relay": {
Expand Down
4 changes: 4 additions & 0 deletions pages/express-relay/contract-addresses/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"evm": "EVM",
"svm": "SVM"
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Tabs } from "nextra/components";
import AddressTable from "../../components/AddressTable";
import AddressTable from "../../../components/AddressTable";

Express Relay is currently deployed on the following networks:
Express Relay is currently deployed on the following EVM networks:

<Tabs items={['Mainnet', 'Testnet']}>

Expand Down
70 changes: 70 additions & 0 deletions pages/express-relay/contract-addresses/svm.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { Tabs } from "nextra/components";
import AddressSvmTable from "../../../components/AddressSvmTable";

Express Relay is currently deployed on the following SVM networks:

<Tabs items={['Testing']}>

<Tabs.Tab>
Auction Server endpoint: https://per-staging.dourolabs.app/

### Solana

**Network Details:**

<AddressSvmTable
explorer={"https://solscan.io/account/$ADDRESS"}
entries={[
{
name: "Express Relay Program",
value: "PytERJFhAKuNNuaiXkApLfWzwNwSNDACpigT3LwQfou",
link: true,
},
{
name: "Limo Limit Order Program",
value: "LiMoM9rMhrdYrfzUCxQppvxCSG1FcrUK9G8uLq4A1GF",
link: true,
},
{
name: "Chain Id",
value: "development-solana",
link: false,
},
{
name: "Public RPC",
value: "https://api.mainnet-beta.solana.com",
link: false,
},
{
name: "Limo Global Order Config",
value: "TeStcUQMmECYEtdeXo9cXpktQWaGe4bhJ7zxAUMzB2X",
link: true,
},
{
name: "Testing Frontend",
value: "https://limo.kamino-webapp.pages.dev/swap",
link: false,
},
]}
/>

This list contains the addresses of the commonly used assets present in opportunities on `development-solana`:

<AddressSvmTable
explorer={"https://solscan.io/account/$ADDRESS"}
entries={[
{
name: "WSOL",
value: "So11111111111111111111111111111111111111112",
link: true,
},
{
name: "USDC",
value: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
link: true,
},
]}
/>

</Tabs.Tab>
</Tabs>
4 changes: 4 additions & 0 deletions pages/express-relay/errors/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"evm": "EVM",
"svm": "SVM"
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Error Codes
# EVM Error Codes

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.
The following table lists the error codes and their explanations for [`ExpressRelay`](https://github.com/pyth-network/per/blob/fccac65b00cff1cfe5c278b333a582fe66bda0f8/contracts/evm/src/express-relay/ExpressRelay.sol) and [`OpportunityAdapter`](https://github.com/pyth-network/per/blob/fccac65b00cff1cfe5c278b333a582fe66bda0f8/contracts/evm/src/opportunity-adapter/OpportunityAdapter.sol) contracts.
They can be used to identify the cause of a failed transaction or bid.

## ExpressRelay
Expand Down
17 changes: 17 additions & 0 deletions pages/express-relay/errors/svm.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# SVM Error Codes

The following table lists the error codes and their explanations for the [`ExpressRelay`](https://github.com/pyth-network/per/tree/fccac65b00cff1cfe5c278b333a582fe66bda0f8/contracts/svm/programs/express_relay) programs.
They can be used to identify the cause of a failed transaction or bid.

## ExpressRelay

| Error | Explanation |
| ----------------------------- | ------------------------------------------------------------------------------------------- |
| `FeeSplitLargerThanPrecision` | The proposed fee split is invalid (split is larger than `FEE_SPLIT_PRECISION`, 10000) |
| `FeesHigherThanBid` | The fees to pay out exceed the value of the bid amount. |
| `DeadlinePassed` | The bid is no longer valid, as the Unix time deadline has passed. |
| `InvalidCPISubmitBid` | The `SubmitBid` instruction should not be called via CPI. |
| `MissingPermission` | The transaction is missing a `SubmitBid` instruction with the matching permission key. |
| `MultiplePermissions` | The transaction should not contain more than one `SubmitBid` instruction. |
| `InsufficientSearcherFunds` | The searcher lacks the funds to pay the specified bid amount. |
| `InsufficientRent` | The fees splits received by different parties must be sufficient to cover the account rent. |
2 changes: 1 addition & 1 deletion pages/express-relay/how-express-relay-works/auction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ A relayer selected by governance serves as the auctioneer and determines the auc

Thus, the Express Relay auction is analogous to a sealed-bid auction, i.e., participants in the auction will not have the contents of their bid disclosed publicly unless they win the auction and are forwarded on-chain.

The forwarded subset of transactions is submitted on-chain and first processed by the [`ExpressRelay`](https://github.com/pyth-network/per/blob/main/contracts/src/express-relay/ExpressRelay.sol) contract before individual searchers' submissions are routed to their corresponding `targetContract`s.
The forwarded subset of transactions is submitted on-chain and first processed by the [`ExpressRelay`](https://github.com/pyth-network/per/blob/fccac65b00cff1cfe5c278b333a582fe66bda0f8/contracts/evm/src/express-relay/ExpressRelay.sol) contract before individual searchers' submissions are routed to their corresponding `targetContract`s.

Generally, the auction server expects bids to execute successfully on-chain. Falback bids are also forwarded in case of execution failures for the predicted winners.

Expand Down
2 changes: 1 addition & 1 deletion pages/express-relay/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ To learn more about Express Relay, refer to the following resources:
<Card
icon={<CodeIcon />}
title="Example Protocol Integration"
href="https://github.com/pyth-network/pyth-examples/tree/main/express-relay/easy_lend"
href="https://github.com/pyth-network/pyth-examples/tree/6cea7c9602c7949c6dacc94aec44c0fe78ccb128/express-relay/easy_lend"
/>
</Cards>
18 changes: 9 additions & 9 deletions pages/express-relay/integrate-as-protocol.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ To integrate with Express Relay, your protocol's contract must check if Express
### Install the Express Relay SDK

Pyth provides a [Solidity SDK](https://www.npmjs.com/package/@pythnetwork/express-relay-sdk-solidity) to help developers integrate Express Relay into their DeFi protocol.
The SDK exposes [`IExpressRelay`](https://github.com/pyth-network/pyth-crosschain/blob/main/express_relay/sdk/solidity/IExpressRelay.sol) and [`IExpressRelayFeeReceiver`](https://github.com/pyth-network/pyth-crosschain/blob/main/express_relay/sdk/solidity/IExpressRelayFeeReceiver.sol) interfaces to interact with Express Relay.
The SDK exposes [`IExpressRelay`](https://github.com/pyth-network/per/blob/8e311d3dce7a54865ff98b25e57c6af2dd984d1f/sdk/solidity/IExpressRelay.sol) and [`IExpressRelayFeeReceiver`](https://github.com/pyth-network/per/blob/8e311d3dce7a54865ff98b25e57c6af2dd984d1f/sdk/solidity/IExpressRelayFeeReceiver.sol) interfaces to interact with Express Relay.

<Tabs items={['Hardhat', 'Foundry']}>
<Tabs.Tab>
Expand Down Expand Up @@ -49,8 +49,8 @@ Then add the following line to `remappings.txt` file:

The following steps show how to modify your protocol's contract to verify if the current transaction is permissioned by Express Relay and to receive the auction proceeds.

1. Call the [`isPermissioned`](https://github.com/pyth-network/pyth-crosschain/blob/main/express_relay/sdk/solidity/IExpressRelay.sol#L10C14-L10C28) method from `IExpressRelay` interface to make sure the current transaction is permissioned by Express Relay.
1. Implement the [`IExpressRelayFeeReceiver`](https://github.com/pyth-network/pyth-crosschain/blob/main/express_relay/sdk/solidity/IExpressRelayFeeReceiver.sol#L4) interface to **receive** auction proceeds.
1. Call the [`isPermissioned`](https://github.com/pyth-network/per/blob/8e311d3dce7a54865ff98b25e57c6af2dd984d1f/sdk/solidity/IExpressRelay.sol#L10C14-L10C28) method from `IExpressRelay` interface to make sure the current transaction is permissioned by Express Relay.
1. Implement the [`IExpressRelayFeeReceiver`](https://github.com/pyth-network/per/blob/8e311d3dce7a54865ff98b25e57c6af2dd984d1f/sdk/solidity/IExpressRelayFeeReceiver.sol#L4) interface to **receive** auction proceeds.

#### 1. Verify Permissioning

Expand All @@ -64,7 +64,7 @@ import "@pythnetwork/express-relay-sdk-solidity/IExpressRelay.sol";

// Express Relay contract address on Optimism Sepolia
//
// Check https://docs.pyth.network/express-relay/contract-addresses
// Check https://docs.pyth.network/express-relay/contract-addresses/evm
// for the address deployed on other networks
address expressRelay = 0xD6e417287b875A3932c1Ff5dcB26D4D2C8b90B40;

Expand Down Expand Up @@ -211,25 +211,25 @@ The JSON payload should contain opportunities in the following format:
Each protocol integrated with Express Relay must actively monitor for new opportunities.
Protocols can do this by indexing the chain, listening to protocol events, or querying protocol state through an RPC provider.

Check the [`monitor.ts`](https://github.com/pyth-network/pyth-crosschain/blob/main/express_relay/examples/easy_lend/src/monitor.ts) script,
which fetches opportunities for the below-mentioned [Easy Lend](https://github.com/pyth-network/pyth-crosschain/tree/main/express_relay/examples/easy_lend) example and exposes them to Express Relay for auction.
Check the [`monitor.ts`](https://github.com/pyth-network/per/blob/8e311d3dce7a54865ff98b25e57c6af2dd984d1f/examples/easy_lend/src/monitor.ts) script,
which fetches opportunities for the below-mentioned [Easy Lend](https://github.com/pyth-network/per/tree/8e311d3dce7a54865ff98b25e57c6af2dd984d1f/examples/easy_lend) example and exposes them to Express Relay for auction.

## Additional Resources

You may find these additional resources helpful for integrating Express Relay as a protocol.

### Example Application

[Easy Lend](https://github.com/pyth-network/pyth-crosschain/tree/main/express_relay/examples/easy_lend) is a dummy lending protocol contract that allows users to borrow and lend assets.
[Easy Lend](https://github.com/pyth-network/per/tree/8e311d3dce7a54865ff98b25e57c6af2dd984d1f/examples/easy_lend) is a dummy lending protocol contract that allows users to borrow and lend assets.
This lending protocol contract is updated to use Express Relay.

### Contract Address

The [Contract Address](./contract-addresses.mdx) page lists the addresses of Express Relay deployed on various networks.
The [EVM](./contract-addresses/evm.mdx) and [SVM](./contract-addresses/svm.mdx) Contract Addresses pages list the addresses of Express Relay deployed on various networks.

### Error Codes

The [Error Codes](./errors.mdx) page lists the error codes returned by Express Relay.
The [EVM](./errors/evm.mdx) and [SVM](./errors/svm.mdx) Error Codes pages list the error codes returned by Express Relay.

### API Reference

Expand Down
Loading
Loading