|
| 1 | +import { Callout, Tabs, Steps } from 'nextra/components' |
| 2 | + |
1 | 3 | # How to Integrate Express Relay as a Searcher
|
2 | 4 |
|
3 |
| -By integrating with Express Relay, searchers are able to access opportunities from various DeFi protocols via a simple and unified interface. |
4 |
| -Opportunities and searcher bids are communicated via the Express Relay server. |
5 |
| -The server exposes different endpoints for interaction which can be used directly via HTTP and WebSocket or via one of the SDKS for convenience. |
| 5 | +Express Relay gives one place stop for on-chain opportunities. Searchers can access opportunities from various DeFi protocols via a simple and unified interface. |
| 6 | + |
| 7 | +Searchers **bid** on opportunities exposed by the Express Relay server. |
| 8 | +The server exposes different endpoints for interaction, which can be used directly via HTTP, WebSocket, or one of the SDKS for convenience. |
| 9 | + |
| 10 | + |
| 11 | +(TODO:) |
| 12 | +Searchers can integrate with the Express Relay server in two ways: |
| 13 | +- [Integrate with the auction server](./integrate-as-searcher/auction-server) |
| 14 | +- [Integrate with the opportunity adapter](./integrate-as-searcher/opportunity-adapter) |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | +## Integrate with the auction server |
| 20 | + |
| 21 | +Defi protocols integrated with Express Relay expose liquidation opportunities via the auction server. |
| 22 | +Searchers can access these opportunities by querying the server directly or subscribing to WebSocket updates. |
| 23 | + |
| 24 | +To integrate with the auction server, follow these steps: |
| 25 | +1. Fetch opportunities from the auction server. |
| 26 | +1. Submit bids on opportunities to the auction server. |
| 27 | + |
| 28 | +<Steps> |
| 29 | + |
| 30 | +### Fetch opportunities from the auction server |
| 31 | + |
| 32 | +Searchers can request via HTTP or subscribe to WebSocket updates to fetch opportunities from the auction server. |
| 33 | + |
| 34 | +<Tabs items={['HTTP', 'Websocket']}> |
| 35 | + |
| 36 | +<Tabs.Tab> |
| 37 | +Searchers can request opportunities through an HTTP GET call to the `/v1/opportunities` endpoint. |
| 38 | + |
| 39 | +```bash copy |
| 40 | +curl -X 'GET' \ |
| 41 | + 'https://per-staging.dourolabs.app/v1/opportunities?chain_id=op_sepolia&mode=live&permission_key=0xdeadbeef&from_time=2024-05-23T21%3A26%3A57.329954Z' |
| 42 | +``` |
| 43 | +</Tabs.Tab> |
| 44 | +<Tabs.Tab> |
| 45 | +Searchers can connect to the server via WebSocket to reduce latency and subscribe to various events. The WebSocket endpoint relies at `/v1/ws`(e.g `wss://pyth-express-relay-mainnet.asymmetric.re/v1/ws`) |
| 46 | + |
| 47 | +```bash copy |
| 48 | +{ |
| 49 | + "id": "1", |
| 50 | + "method": "subscribe", |
| 51 | + "params": { |
| 52 | + "chain_ids": ["op_sepolia"] |
| 53 | + } |
| 54 | +} |
| 55 | +``` |
| 56 | +</Tabs.Tab> |
| 57 | +</Tabs> |
| 58 | + |
| 59 | +The server responds with opportunities in the following format: |
6 | 60 |
|
7 |
| -The integration consists of 2 main steps: |
| 61 | +```json copy |
| 62 | +{ |
| 63 | + "target_calldata": "0xdeadbeef", // Calldata to perform liquidation |
| 64 | + "chain_id": "op_sepolia", |
| 65 | + "target_contract": "0xcA11bde05977b3631167028862bE2a173976CA11", // Protocol contract address to call for liquidation |
| 66 | + "permission_key": "0xcafebabe", // Unique identifier for the liquidation opportunity |
| 67 | + "target_call_value": "1", // Value(in Wei) to send with to the Protocol contract. |
| 68 | + "buy_tokens": [ // Tokens to buy (Collateral) |
| 69 | + { |
| 70 | + "amount": "1000", |
| 71 | + "token": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" |
| 72 | + } |
| 73 | + ], |
| 74 | + "sell_tokens": [ // Tokens to sell (Oustadaing Debt) |
| 75 | + { |
| 76 | + "amount": "900", |
| 77 | + "token": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599" |
| 78 | + } |
| 79 | + ], |
| 80 | + "version": "v1" // Opportunity format version |
| 81 | +} |
| 82 | +``` |
| 83 | +</Steps> |
8 | 84 |
|
9 |
| -- Integrate your searcher service with the [auction server](./integrate-as-searcher/auction-server) |
10 |
| -- \[Optional\] Use [OpportunityAdapter](./integrate-as-searcher/opportunity-adapter) and setup a wallet with the necessary tokens and approvals |
11 | 85 |
|
12 |
| -You can also find a list of relevant contract addresses [here](./contract-addresses). |
| 86 | +### Submit bids on opportunities to the auction server. |
0 commit comments