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/integrate-as-protocol.mdx
+24-20Lines changed: 24 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,12 +45,12 @@ Then add the following line to `remappings.txt` file:
45
45
46
46
### Modifying the Protocol's Contract
47
47
48
-
The following steps show how to modify your protocol's contract to permit Express Relay transactions and receive funds from Express Relay.
48
+
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 proceedings.
49
49
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.
50
+
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.
51
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
-
#### 1. Permit Express Relay Transactions
53
+
#### 1. Verify Permissioning
54
54
55
55
The `isPermissioned` function takes two arguments:
56
56
1.`protocolFeeReceiver`: The address to receive the protocol's share of auction proceedings.
@@ -80,7 +80,7 @@ require(
80
80
</Callout>
81
81
82
82
#### 2. Set up Fee Receiver
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.
83
+
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.
84
84
85
85
```solidity copy
86
86
interface IExpressRelayFeeReceiver {
@@ -145,7 +145,7 @@ contract EasyLend is IExpressRelayFeeReceiver {
145
145
}
146
146
147
147
/**
148
-
* @notice receiveAuctionProceedings function - receives the native token from the express relay
148
+
* @notice receiveAuctionProceedings function - receives the native token from express relay
149
149
* You can use the permission key to distribute the received funds to users who got liquidated, LPs, etc...
150
150
*
151
151
* @param permissionKey: permission key that was used for the auction
@@ -165,38 +165,39 @@ contract EasyLend is IExpressRelayFeeReceiver {
165
165
166
166
DeFi protocols must fetch opportunities and expose them to Express Relay for auction.
167
167
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.
168
+
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
170
The JSON payload should contain opportunities in the following format:
171
171
172
172
```json
173
173
{
174
-
"target_calldata": "0xdeadbeef", // Calldata to the execute opportunity
174
+
"target_calldata": "0xdeadbeef", // Calldata to execute the opportunity
175
175
"chain_id": "op_sepolia",
176
-
"target_contract": "0xcA11bde05977b3631167028862bE2a173976CA11", // Protocol contract address to call for
176
+
"target_contract": "0xcA11bde05977b3631167028862bE2a173976CA11", // Protocol contract address to call
177
177
"permission_key": "0xcafebabe", // Unique identifier for the opportunity
178
-
"target_call_value": "1", // Value(in Wei) to send with to the Protocol contract.
179
-
"buy_tokens": [ // Tokens to buy
178
+
"target_call_value": "1", // Value(in Wei) to send to the protocol contract.
179
+
"sell_tokens": [ // Tokens the protocol expects to receive
Each protocol integrated with Express Relay must evaluate every position's health using the latest Oracle prices before exposing them to Express Relay.
197
-
You can do this by indexing the chain, listening to protocol events, or querying open positions through an RPC provider.
196
+
Each protocol integrated with Express Relay must actively monitor for new opportunities.
197
+
You can do this by indexing the chain, listening to protocol events, or querying protocol state 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 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,
200
+
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.
200
201
201
202
202
203
## Additional Resources
@@ -205,14 +206,17 @@ You may find these additional resources helpful for integrating Express Relay as
205
206
206
207
### Example Application
207
208
208
-
[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. This lending protocol contract is updated to permit Express Relay transactions.
209
+
[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.
210
+
This lending protocol contract is updated to use Express Relay.
209
211
210
212
### Contract Address
211
213
212
214
The [Contract Address](./contract-addresses.mdx) page lists the addresses of Express Relay deployed on various networks.
213
215
214
216
### Error Codes
215
217
218
+
The [Error Codes](./error-codes.mdx) page lists the error codes returned by Express Relay.
219
+
216
220
### API Reference
217
221
218
-
The [API Reference](https://per-staging.dourolabs.app/redoc/) provides detailed information on the Express Relay APIs for submitting opportunities.
222
+
The [API Reference](https://per-staging.dourolabs.app/redoc/) provides detailed information on Express Relay APIs for submitting opportunities.
0 commit comments