You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pages/express-relay/index.mdx
+8-3Lines changed: 8 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,10 +8,13 @@ import ContractIcon from "../../components/icons/ContractIcon";
8
8
9
9
Express Relay is a priority auction that enables protocols to eliminate maximal extractable value (MEV).
10
10
11
-
-**For Protocol Developers:** Express Relay’s auction primitive allows your protocol to prioritize access to permissionless operations, eliminating the extractive role of miners in ordering transactions.
12
-
A network of established searchers compete in the auctions, allowing you to avoid spending time and energy bootstrapping your own protocol-specific searcher network.
13
11
14
-
-**For Searchers:** Express Relay aggregates liquidation and other MEV opportunities across integrated DeFi protocols, providing easy and unified access.
12
+
13
+
-**For Protocol Developers:** Express Relay allows protocols to recapture MEV and access a network of searchers.
14
+
With Express Relay, protocols don't need to spend time and energy bootstrapping the protocol-specific searcher network.
15
+
16
+
-**For Searchers:** Express Relay provides easy and unified access by aggregating liquidation and other MEV opportunities across integrated DeFi protocols.
17
+
Searchers integrate once and gain access to all existing and future opportunities.
15
18
16
19
<Cards>
17
20
<Card
@@ -29,3 +32,5 @@ A network of established searchers compete in the auctions, allowing you to avoi
29
32
To learn more about Express Relay's design and how it eliminates MEV, please see [How Express Relay Works](/express-relay/how-express-relay-works).
Defi protocols can **permissionlessly** integrate with Express Relay to recapture MEV and access a network of searchers.
5
+
This guide will explain how DeFi protocols can integrate Express Relay.
6
6
7
7
Integrating with Express Relay involves two main steps:
8
8
9
-
- Update your defi protocol's contract to **permit** Express Relay transactions.
10
-
-Write a script to **expose** opportunities to searchers for auction.
9
+
-**Update** your DeFi protocol's contract.
10
+
-**Expose** opportunities to searchers for auction.
11
11
12
12
## Update your defi Protocol's Contract
13
13
14
-
To integrate with Express Relay, your protocol's contract must permit Express Relay to access opportunities.
14
+
To integrate with Express Relay, your protocol's contract must check if Express Relay has permissioned the current transaction.
15
15
16
16
<Steps>
17
17
### Install the Express Relay SDK
18
18
19
-
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.
19
+
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.
20
20
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.
21
21
22
22
<Tabsitems={['Hardhat', 'Foundry']}>
@@ -47,39 +47,40 @@ Then add the following line to `remappings.txt` file:
47
47
48
48
The following steps show how to modify your protocol's contract to permit Express Relay transactions and receive funds from Express Relay.
49
49
50
-
1.Utilize[`isPermissioned`](https://github.com/pyth-network/pyth-crosschain/blob/main/express_relay/sdk/solidity/IExpressRelay.sol#L10C14-L10C28) method from `IExpressRelay` interface to **permit** Express Relay transactions.
51
-
1. Implement the [`IExpressRelayFeeReceiver`](https://github.com/pyth-network/pyth-crosschain/blob/main/express_relay/sdk/solidity/IExpressRelayFeeReceiver.sol#L4) interface to **receive**funds from Express Relay.
50
+
1.Call[`isPermissioned`](https://github.com/pyth-network/pyth-crosschain/blob/main/express_relay/sdk/solidity/IExpressRelay.sol#L10C14-L10C28) method from `IExpressRelay` interface to **permit** Express Relay transactions.
51
+
1. Implement the [`IExpressRelayFeeReceiver`](https://github.com/pyth-network/pyth-crosschain/blob/main/express_relay/sdk/solidity/IExpressRelayFeeReceiver.sol#L4) interface to **receive**auction proceedings.
52
52
53
53
#### 1. Permit Express Relay Transactions
54
54
55
55
The `isPermissioned` function takes two arguments:
56
-
1.`protocolFeeReceiver`: The contract address that will receive the protocol fee from the winning searcher after a successful auction.
57
-
1.`permissionId`: A unique identifier of a vault or position eligible to expose as an opportunity.
56
+
1.`protocolFeeReceiver`: The address to receive the protocol's share of auction proceedings.
57
+
1.`permissionId`: A unique identifier for the opportunity.
The `permissionId` represents unique identifying information for the vault or position within a protocol.
76
-
It can be the vault address or the vault ID, concatenated into `bytes` format.
77
+
The `permissionId` represents unique identifying information of an opportunity.
78
+
For a liquidation opportunity, the vault address or ID could be concatenated into `bytes` format.
77
79
Consult [`Permissioning`](./how-express-relay-works/permissioning.mdx) for more information on generating permission IDs.
78
80
</Callout>
79
81
80
82
#### 2. Set up Fee Receiver
81
-
82
-
After a successful auction, the Express Relay calls the `receiveAuctionProceedings` function present in `IExpressRelayFeeReceiver` to send the portion of the fee paid by the winning searcher to the Protocol's contract
83
+
The Express Relay will call the `receiveAuctionProceedings` method present in `IExpressRelayFeeReceiver`. The call will transfer the protocol's share of the auction proceeding to the `protocolFeeReceiver` address.
The following code snippet shows a sample liquidation opportunity via Express Relay.
94
94
Note: The highlighted lines show the contract's relevant additions for Express Relay integration.
95
95
@@ -163,26 +163,26 @@ contract EasyLend is IExpressRelayFeeReceiver {
163
163
164
164
## Expose Opportunities to Searchers
165
165
166
-
Your defi protocol should fetch vaults and positions eligible as opportunites and expose them to Express Relay for auction.
166
+
DeFi protocols must fetch opportunities and expose them to Express Relay for auction.
167
167
168
-
The Express Relay auction server provides a **POST** method, `/v1/opportunities`, which accepts a JSON payload containing the details of the opportunity.
168
+
The Express Relay provides a **POST** method, [`/v1/opportunities`](https://per-staging.dourolabs.app/redoc#tag/opportunity/operation/post_opportunity), which accepts a JSON payload containing the details of the opportunity.
169
169
170
-
The JSON payload should contain liquidation opportunities in the following format:
170
+
The JSON payload should contain opportunities in the following format:
171
171
172
172
```json
173
173
{
174
-
"target_calldata": "0xdeadbeef", // Calldata to perform liquidation
174
+
"target_calldata": "0xdeadbeef", // Calldata to the execute opportunity
175
175
"chain_id": "op_sepolia",
176
-
"target_contract": "0xcA11bde05977b3631167028862bE2a173976CA11", // Protocol contract address to call for liquidation
177
-
"permission_key": "0xcafebabe", // Unique identifier for the liquidation opportunity
176
+
"target_contract": "0xcA11bde05977b3631167028862bE2a173976CA11", // Protocol contract address to call for
177
+
"permission_key": "0xcafebabe", // Unique identifier for the opportunity
178
178
"target_call_value": "1", // Value(in Wei) to send with to the Protocol contract.
@@ -196,7 +196,7 @@ The JSON payload should contain liquidation opportunities in the following forma
196
196
Each protocol integrated with Express Relay must evaluate every position's health using the latest Oracle prices before exposing them to Express Relay.
197
197
You can do this by indexing the chain, listening to protocol events, or querying open positions through an RPC provider.
198
198
199
-
Check the [`monitor.ts`](https://github.com/pyth-network/pyth-crosschain/blob/main/express_relay/examples/easy_lend/src/monitor.ts) script, which fetches liquidation 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.
199
+
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.
Copy file name to clipboardExpand all lines: pages/express-relay/integrate-as-searcher.mdx
+25-22Lines changed: 25 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -80,7 +80,7 @@ You can fetch historical opportunities by setting the `mode` parameter to `histo
80
80
81
81
</Tabs.Tab>
82
82
<Tabs.Tab>
83
-
Searchers can connect to the server via WebSocket 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`)
83
+
Searchers can connect to the server via WebSocket 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`).
84
84
Here is a sample JSON payload to subscribe to opportunities:
85
85
86
86
```bash copy
@@ -107,15 +107,13 @@ The server responds with opportunities in the following format:
107
107
"target_contract": "0xcA11bde05977b3631167028862bE2a173976CA11", // Protocol contract address to call for execution
108
108
"permission_key": "0xcafebabe", // Permission key required for the liquidation opportunity
109
109
"target_call_value": "1", // Value(in Wei) to send with to the Protocol contract.
@@ -132,9 +130,11 @@ The SDKs provide an easy way to construct a bid using the `OpportunityAdapter` c
132
130
The `OpportunityAdapter` contract handles asset transfers and ensures the opportunity is executed correctly.
133
131
134
132
You can learn more about the `OpportunityAdapter` contract and how to prepare your assets in the [Opportunity Adapter](./integrate-as-searcher/opportunity-adapter.mdx) section.
135
-
If you have already developed an in-house searcher contract there is no need to integrate using the Opportunity Adapter contract.
136
-
You can use our lower level APIs which allows higher flexibility for advanced users.
137
-
Please refer to the [custom contracts](./custom-contract) section for more details.
133
+
If you have already developed an in-house searcher contract, integrating using the Opportunity Adapter contract is unnecessary.
134
+
You can use our lower-level APIs, which allow higher flexibility for advanced users.
135
+
Please refer to the [custom contracts](./integrate-as-searcher/custom-contract.mdx) section for more details.
136
+
137
+
Here is an example of how to construct a bid using the SDKs:
0 commit comments