Skip to content

Commit 59b1992

Browse files
jayantkm30m
andauthored
Suggested edits (#360)
* edits * Move errors from notion --------- Co-authored-by: Amin Moghaddam <amin@pyth.network>
1 parent b0df6fb commit 59b1992

File tree

6 files changed

+94
-38
lines changed

6 files changed

+94
-38
lines changed

pages/express-relay/_meta.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
"href": "https://per-staging.dourolabs.app/docs/"
2929
},
3030
"contract-addresses": "Contract Addresses",
31-
"error-codes": "Error Codes",
32-
31+
"errors": "Error Codes",
3332
"examples": {
3433
"title": "Example Application ↗",
3534
"href": "https://github.com/pyth-network/pyth-crosschain/tree/main/express_relay/examples/easy_lend"
@@ -40,4 +39,4 @@
4039
},
4140

4241
"how-express-relay-works": "How Express Relay Works"
43-
}
42+
}

pages/express-relay/errors.mdx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Error Codes
2+
3+
The following table lists the error codes and their explanations for ExpressRelay and OpportunityAdapter contracts.
4+
They can be used to identify the cause of a failed transaction or bid.
5+
6+
## ExpressRelay
7+
8+
| Error | Selector | Explanation |
9+
| -------------------------------------------- | ------------ | ------------------------------------------------------------------------------------------- |
10+
| `Unauthorized()` | `0x82b42900` | This function is called by an unauthorized party. |
11+
| `InvalidMagicValue()` | `0x4ed848c1` | An upgrade was attempted to a contract that does not match the ExpressRelay specification. |
12+
| `InvalidPermission()` | `0x868a64de` | The provided permissionKey is invalid (too short). |
13+
| `InvalidFeeSplit()` | `0x0601f697` | The proposed fee split is invalid (fee is larger than feePrecision, 10\*\*18). |
14+
| `InvalidTargetContract()` | `0x5569851a` | The provided target contract is not allowed. (e.g. can not call the ExpressRelay contract). |
15+
| `DuplicateRelayerSubwallet()` | `0xb40d37c3` | The provided subwallet to add has already been added. |
16+
| `RelayerSubwalletNotFound()` | `0xac4d92b3` | The provided subwallet to delete does not exist in the store. |
17+
| `ExternalCallFailed(MulticallStatus status)` | `0x740d0306` | The external call failed with the following MulticallStatus output. |
18+
19+
## OpportunityAdapter
20+
21+
| Error | Selector | Explanation |
22+
| -------------------------------------- | ------------ | ---------------------------------------------------------------------------------------------------------------- |
23+
| `NotCalledByExpressRelay()` | `0xd5668c88` | The OpportunityAdapterFactory contract was not called by the ExpressRelay contract. |
24+
| `NotCalledByFactory()` | `0xb02436cc` | The OpportunityAdapter contract was not called by the OpportunityAdapterFactory contract. |
25+
| `AdapterOwnerMismatch()` | `0x446f3eeb` | The provided executor field does not match the owner of the called OpportunityAdapter contract. |
26+
| `InsufficientTokenReceived()` | `0x4af147aa` | The specified buyTokens were not received after calling the target contract. |
27+
| `InsufficientEthToSettleBid()` | `0x9caaa1d7` | The contract did not receive enough ETH to pay the specified bid. |
28+
| `InsufficientWethForTargetCallValue()` | `0x5e520cd4` | The contract did not receive enough Wrapped ETH to pay the targetCallValue to the targetContract. |
29+
| `TargetCallFailed(bytes returnData)` | `0xa932c97a` | The call to targetContract failed with the specified returnData. |
30+
| `DuplicateToken()` | `0x464e3f6a` | There is a duplicate token in either the sellTokens or buyTokens. |
31+
| `EthOrWethBalanceDecreased()` | `0x1979776d` | The ETH or WETH balance of the contract decreased as a result of the call to targetContract and the bid payment. |
32+
| `TargetContractNotAllowed()` | `0x9c86e59e` | The provided targetContract is not allowed. (e.g. can not call the Permit2 contract). |
33+
| `OnlyOwnerCanCall()` | `0x47a8ea58` | Only the owner of the contract can call this method. |
Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,44 @@
1-
# Design Overview
1+
# How Express Relay Works
2+
3+
Express Relay allows protocols to eliminate miner-extractable value (MEV).
4+
Many protocols generate MEV on a regular basis.
5+
For example, borrow-lending protocols provide bonuses to searchers for liquidating undercollateralized loans.
6+
Searchers compete for these bonuses by tipping the chain's miners or validators.
7+
The validators capture most of the value of the liquidation bonus via these tips, so the liquidation bonus is in essence a transfer of wealth from the protocol's users to the validators.
8+
9+
Express Relay solves the problem of MEV by providing protocol developers with an auction primitive that they can use to prioritize access to permissionless operations.
10+
Developers specify a set of operations in their protocol that must be accessed through Express Relay.
11+
Searchers then participate in an off-chain auction to access these operations.
12+
Their bids in the auction determine the priority of their transactions, i.e., the order in which their transactions will be executed.
13+
The winners transactions are forwarded to the blockchain, which both pays their bid and executes the operation.
14+
The profits of the auction are then split between the integrated protocol and other participants in Express Relay.
15+
16+
![](images/express_relay/express_relay_schematic.svg)
17+
18+
The diagram above shows how Express Relay changes the MEV landscape for a liquidation.
19+
In the status quo (left), Searchers tip miners in order to guarantee that their liquidation transaction lands on-chain.
20+
Their transaction directly interacts with the protocol exposing the liquidation opportunity, and the liquidation bonus flows back to the Searcher.
21+
With Express Relay (right), Searchers submit bids for their transaction to the Express Relay auction.
22+
The auction submits the winning bids to the blockchain, where the transactions are processed by the Express Relay Entrypoint before being forwarded on to the integrated protocol.
23+
The Express Relay Entrypoint collects payment from the Searchers and forwards a share of the revenue back to the integrated protocol.
24+
25+
FIXME: I think the diagram is wrong (specifically the liquidation bonus going back to express relay)
26+
27+
## Which protocols can use Express Relay?
28+
29+
Any protocol with permissionless and valuable operations can use Express Relay.
30+
These operations generate MEV, as the validators control which searchers can access them.
31+
Express Relay enables protocols to auction access instead, thereby ensuring the operation is competitively priced.
32+
Lending, perps, and derivatives protocols with liquidation mechanisms are clear candidates that can benefit from integration with Express Relay.
33+
34+
Aside from eliminating MEV, protocols that need a stable set of searchers may choose to use Express Relay.
35+
Express Relay provides access to a robust network of searchers who are already active in the Express Relay ecosystem.
36+
37+
## Participants in Express Relay
38+
39+
There are four types of participants in the Express Relay protocol:
40+
41+
- The Relayer runs the off-chain auction and forwards winning transactions onto the blockchain. There is a single Relayer chosen by the Pyth DAO.
42+
- Protocol developers integrate their protocol with Express Relay in order to eliminate MEV.
43+
- Searchers participate in auctions to access liquidations and other on-chain opportunities.
44+
- The Pyth DAO owns and governs the Express Relay system
Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
{
2-
"Auction": "auction",
3-
"Opportunities": "opportunities",
4-
"Permissioning": "permissioning",
5-
"Relayer": "relayer",
6-
"error codes": {
7-
"title": "Error Codes ↗",
8-
"href": "https://www.notion.so/pyth-network/Error-codes-explanation-c90c375eb9a4430494578a713a0d7e68?pvs=4"
9-
}
10-
}
2+
"auction": "Auction",
3+
"opportunities": "Opportunities",
4+
"permissioning": "Permissioning",
5+
"relayer": "Relayer"
6+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Relayer

pages/express-relay/index.mdx

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,16 @@
11
# Introduction
22

3-
Many protocols generate MEV on a regular basis. Borrow-lending protocols for example expose lucrative liquidation bonuses that searchers compete for on tips made to the chain's miners or validators. Most of the value in the liquidation opportunity is captured by the validators, so the liquidation bonus is in essence a transfer of wealth from the protocol to the validators.
3+
Express Relay is a priority auction that enables protocols to eliminate miner-extractable value (MEV).
44

5-
Express Relay enables protocols to recapture the MEV they currently leak to validators. By integrating with Express Relay, a protocol internalizes the auction for priority on its lucrative transactions (e.g. liquidations). It also taps into an existing set of searchers already integrated into and actively performing liquidations through Express Relay, reducing the need for the protocol to boostrap and maintain or incentivize its own set of liquidators.
5+
**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.
6+
A network of established searchers compete in the auctions, allowing you to avoid spending time and energy bootstrapping your own protocol-specific searcher network.
7+
Learn how to [Integrate with Express Relay as a protocol](/express-relay/integrate-as-protocol).
68

7-
![](images/express_relay/express_relay_schematic.svg)
9+
FIXME: This link above and the ones below should be big buttons
810

9-
## What is Express Relay?
11+
**For Searchers:** Express Relay aggregates liquidation and other MEV opportunities across integrated DeFi protocols, providing easy and unified access.
12+
Learn how to [Integrate with Express Relay as a searcher](/express-relay/integrate-as-searcher).
1013

11-
### How does Express Relay work?
14+
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).
1215

13-
Express Relay features an off-chain auction (run by a third-party entity, the "relayer") where searchers bid on priority rights to transact on a protocol position or opportunity. Once an auction is concluded, the relayer will forward the winning parties' transactions onto the blockchain, where they will pass through the Express Relay entrypoint smart contract before being processed at the end protocol. The entrypoint contract handles permissioning and disbursement of fees to the relevant entities in the system.
14-
15-
### Different types of actors in Express Relay
16-
17-
There are four imporant agents in the Express Relay pipeline:
18-
19-
- Relayer: runs the off-chain auction according to an agreement with the Pyth DAO and forwards winning transactions onto the blockchain
20-
- Protocol DAO/owner: integrates protocol with Express Relay in order to recapture leaked MEV, which can then be shared with protocol stakeholders
21-
- Searcher: participates in the Express Relay auction to capture value from lucrative opportunities such as liquidation bonuses
22-
- Pyth DAO: owner and governing authority of the Express Relay system, designates the relayer to run the off-chain components of the system
23-
24-
### Which protocols can integrate with Express Relay?
25-
26-
Protocols that currently leak MEV to validators because the validators control the ordering of lucrative transactions on the protocol can integrate with Express Relay. By doing so, such a protocol internalizes control over the ordering of these lucrative transactions, which means it does not need to surrender value to the validators.
27-
28-
Apart from recapturing MEV, protocols that are in need of a stable set of searchers that can p . Integrating with Express Relay gives a protocol access to the robust searcher network already active in the Express Relay ecosystem. This means
29-
30-
Lending, perps, and derivatives protocols that use liquidations are an obvious source of MEV and could benefit from integration with Express Relay. In addition,
31-
32-
## Links to other pages
16+
## Useful Links

0 commit comments

Comments
 (0)