Skip to content

Commit e24d4b6

Browse files
committed
Update docs
1 parent d172628 commit e24d4b6

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

pages/express-relay/integrate-as-protocol.mdx

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ Then add the following line to `remappings.txt` file:
4545

4646
### Modifying the Protocol's Contract
4747

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.
4949

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.
5151
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.
5252

53-
#### 1. Permit Express Relay Transactions
53+
#### 1. Verify Permissioning
5454

5555
The `isPermissioned` function takes two arguments:
5656
1. `protocolFeeReceiver`: The address to receive the protocol's share of auction proceedings.
@@ -80,7 +80,7 @@ require(
8080
</Callout>
8181

8282
#### 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.
8484

8585
```solidity copy
8686
interface IExpressRelayFeeReceiver {
@@ -145,7 +145,7 @@ contract EasyLend is IExpressRelayFeeReceiver {
145145
}
146146
147147
/**
148-
* @notice receiveAuctionProceedings function - receives the native token from the express relay
148+
* @notice receiveAuctionProceedings function - receives the native token from express relay
149149
* You can use the permission key to distribute the received funds to users who got liquidated, LPs, etc...
150150
*
151151
* @param permissionKey: permission key that was used for the auction
@@ -165,38 +165,39 @@ contract EasyLend is IExpressRelayFeeReceiver {
165165

166166
DeFi protocols must fetch opportunities and expose them to Express Relay for auction.
167167

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.
169169

170170
The JSON payload should contain opportunities in the following format:
171171

172172
```json
173173
{
174-
"target_calldata": "0xdeadbeef", // Calldata to the execute opportunity
174+
"target_calldata": "0xdeadbeef", // Calldata to execute the opportunity
175175
"chain_id": "op_sepolia",
176-
"target_contract": "0xcA11bde05977b3631167028862bE2a173976CA11", // Protocol contract address to call for
176+
"target_contract": "0xcA11bde05977b3631167028862bE2a173976CA11", // Protocol contract address to call
177177
"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
180180
{
181-
"amount": "1000",
182-
"token": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
181+
"amount": "900",
182+
"token": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599"
183183
}
184184
],
185-
"sell_tokens": [ // Tokens to S
185+
"buy_tokens": [ // Tokens the protocol will send in return
186186
{
187-
"amount": "900",
188-
"token": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599"
187+
"amount": "1000",
188+
"token": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
189189
}
190190
],
191191
"version": "v1" // Opportunity format version
192192
}
193193
```
194194

195195

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-
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.
198198

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.
200201

201202

202203
## Additional Resources
@@ -205,14 +206,17 @@ You may find these additional resources helpful for integrating Express Relay as
205206

206207
### Example Application
207208

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.
209211

210212
### Contract Address
211213

212214
The [Contract Address](./contract-addresses.mdx) page lists the addresses of Express Relay deployed on various networks.
213215

214216
### Error Codes
215217

218+
The [Error Codes](./error-codes.mdx) page lists the error codes returned by Express Relay.
219+
216220
### API Reference
217221

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

Comments
 (0)