Skip to content

Commit 0e4d456

Browse files
committed
updated guide
1 parent 8cb8c04 commit 0e4d456

File tree

1 file changed

+45
-10
lines changed

1 file changed

+45
-10
lines changed

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

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ import { Steps } from 'nextra/components'
55
This guide explains how to integrate Express Relay as a protocol.
66
To integrate Express Relay as a protocol, you need to:
77

8-
1. Update the protocol's contract to permission Express Relay transactions.
9-
2. Write a script to post liquidatable positions/vaults to Searchers for auction.
8+
- Update the protocol's contract to **permission** Express Relay transactions.
9+
- Write a script to **expose** liquidation opportunities to Searchers for auction.
1010

1111
## Update the Protocol's Contract
1212

1313
Express Relay requires the protocol's contract to permit Express Relay to access liquidation.
1414

15+
<Steps>
1516
### Install the Express Relay SDK
1617

1718
Pyth provides a [Solidity SDK](https://www.npmjs.com/package/@pythnetwork/express-relay-sdk-solidity) to help you integrate Express Relay into your protocol.
@@ -35,21 +36,21 @@ npm install @pythnetwork/express-relay-sdk-solidity
3536

3637
Then add the following line to `remappings.txt` file:
3738

38-
```bash copy
39+
```text copy
3940
@pythnetwork/express-relay-sdk-solidity/=node_modules/@pythnetwork/express-relay-sdk-solidity
4041
```
4142

4243
### Modifying the Protocol's Contract
4344

44-
The protocol's contract needs to be updated to:
45+
The protocol's contract should be updated to:
4546

46-
1. Consume `isPermissioned` method from `IExpressRelay` interface to Permit Express Relay transactions.
47+
1. Utilize `isPermissioned` method from `IExpressRelay` interface to **permit** Express Relay transactions.
4748
1. Implement the `IExpressRelayFeeReceiver` interface to receive funds from Express Relay.
4849

49-
#### Permit Express Relay Transactions
50+
#### 1. Permit Express Relay Transactions
5051

5152
The `isPermissioned` function takes two arguments:
52-
1. `protocolFeeReceiver`: The address of the protocol's contract. If the protocol's contract is the contract that receives fees from the Express Relay server, this should be the address of that contract. (IS IT WORTH MENTIONING HERE????)
53+
1. `protocolFeeReceiver`: The address of the protocol's contract.
5354
1. `permissionId`: A unique identifier for the liquidation opportunity.
5455

5556
```solidity copy
@@ -69,7 +70,7 @@ require(
6970
```
7071

7172

72-
#### Set up Fee Receiver
73+
#### 2. Set up Fee Receiver
7374

7475
The `IExpressRelayFeeReceiver` interface requires the protocol's contract to implement the `receiveAuctionProceedings` function. The Express Relay server calls this function to send funds to the protocol's contract.
7576

@@ -142,8 +143,8 @@ contract EasyLend is IExpressRelayFeeReceiver {
142143
}
143144
144145
/**
145-
* @notice receiveAuctionProceedings function - receives native token from the express relay
146-
* You can use permission key to distribute the received funds to users who got liquidated, LPs, etc...
146+
* @notice receiveAuctionProceedings function - receives the native token from the express relay
147+
* You can use the permission key to distribute the received funds to users who got liquidated, LPs, etc...
147148
*
148149
* @param permissionKey: permission key that was used for the auction
149150
*/
@@ -155,5 +156,39 @@ contract EasyLend is IExpressRelayFeeReceiver {
155156
156157
}
157158
```
159+
</Steps>
160+
161+
162+
## Expose Liquidation Opportunities to Searchers
163+
164+
Protocols must fetch liquidation opportunities like vaults and positions eligible for liquidation and expose them to Express Relay for auction.
165+
166+
The Express Relay auction server provides a POST method, `/v1/opportunities`, which accepts a JSON payload containing the details of the liquidation opportunity.
167+
168+
The JSON payload should contain liquidation opportunities in the following format:
169+
170+
```json
171+
{
172+
"target_calldata": "0xdeadbeef", // Calldata to perform liquidation
173+
"chain_id": "op_sepolia",
174+
"target_contract": "0xcA11bde05977b3631167028862bE2a173976CA11", // Protocol contract address to call for liquidation
175+
"permission_key": "0xcafebabe", // Unique identifier for the liquidation opportunity
176+
"target_call_value": "1", // Value(in Wei) to send with to the protocol contract.
177+
"buy_tokens": [ // Tokens to buy (Collateral)
178+
{
179+
"amount": "1000",
180+
"token": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
181+
}
182+
],
183+
"sell_tokens": [ // Tokens to sell (Oustadaing Debt)
184+
{
185+
"amount": "900",
186+
"token": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599"
187+
}
188+
],
189+
"version": "v1" // Opportunity format version
190+
}
191+
```
158192

159193

194+
TODO: Include a callout to give more info about permission ID

0 commit comments

Comments
 (0)