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
+45-10Lines changed: 45 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -5,13 +5,14 @@ import { Steps } from 'nextra/components'
5
5
This guide explains how to integrate Express Relay as a protocol.
6
6
To integrate Express Relay as a protocol, you need to:
7
7
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.
10
10
11
11
## Update the Protocol's Contract
12
12
13
13
Express Relay requires the protocol's contract to permit Express Relay to access liquidation.
14
14
15
+
<Steps>
15
16
### Install the Express Relay SDK
16
17
17
18
Pyth provides a [Solidity SDK](https://www.npmjs.com/package/@pythnetwork/express-relay-sdk-solidity) to help you integrate Express Relay into your protocol.
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.
47
48
1. Implement the `IExpressRelayFeeReceiver` interface to receive funds from Express Relay.
48
49
49
-
#### Permit Express Relay Transactions
50
+
#### 1. Permit Express Relay Transactions
50
51
51
52
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.
53
54
1.`permissionId`: A unique identifier for the liquidation opportunity.
54
55
55
56
```solidity copy
@@ -69,7 +70,7 @@ require(
69
70
```
70
71
71
72
72
-
#### Set up Fee Receiver
73
+
#### 2. Set up Fee Receiver
73
74
74
75
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.
75
76
@@ -142,8 +143,8 @@ contract EasyLend is IExpressRelayFeeReceiver {
142
143
}
143
144
144
145
/**
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...
147
148
*
148
149
* @param permissionKey: permission key that was used for the auction
149
150
*/
@@ -155,5 +156,39 @@ contract EasyLend is IExpressRelayFeeReceiver {
155
156
156
157
}
157
158
```
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.
0 commit comments