Skip to content

Commit b650d77

Browse files
committed
update README.md
1 parent 0896528 commit b650d77

File tree

1 file changed

+52
-29
lines changed

1 file changed

+52
-29
lines changed

README.md

Lines changed: 52 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,48 @@
33
Self hosted API gateway to easily interact with Drift V2 Protocol
44

55
## Table of Contents
6-
7-
1. [Introduction](#introduction)
8-
2. [Installation](#installation)
9-
3. [Usage](#usage)
10-
- [Delegated Signing Mode](#delegated-signing-mode)
11-
- [Sub-account Switching](#sub-account-switching)
12-
4. [API Examples](#api-examples)
13-
- [HTTP API](#http-api)
14-
- [`GET` Markets](#get-markets)
15-
- [`GET` MarketInfo](#get-market-info)
16-
- [`GET` Orderbook](#get-orderbook)
17-
- [`GET` Orders](#get-orders)
18-
- [`GET` Positions](#get-positions)
19-
- [`GET` Perp Position Info](#get-position-info-perps-only)
20-
- [`GET` Transaction Events](#get-transaction-events)
21-
- [`GET` SOL Balance](#get-sol-balance)
22-
- [`POST` Place Orders](#place-orders)
23-
- [`PATCH` Modify Orders](#modify-orders)
24-
- [`DELETE` Cancel Orders](#cancel-orders)
25-
- [`PUT` Atomic Cancel/Modify/Place Orders](#atomic-cancelmodifyplace-orders)
26-
- [Websocket API](#websocket-api)
27-
- [Subscribing](#subscribing)
28-
- [Event Payloads](#event-payloads)
6+
1. [Build & Run](#build--run)
7+
- [From Source](#from-source)
8+
- [From Docker](#from-docker)
9+
2. [Usage](#usage)
10+
- [Environment Variables](#environment-variables)
11+
- [Delegated Signing Mode](#delegated-signing-mode)
12+
- [Sub-account Switching](#sub-account-switching)
13+
3. [API Examples](#api-examples)
14+
- [HTTP API](#http-api)
15+
- [`GET` Market Info](#get-market-info)
16+
- [`GET` Orderbook](#get-orderbook)
17+
- [`GET` Orders](#get-orders)
18+
- [`GET` Positions](#get-positions)
19+
- [`GET` Perp Position Info](#get-position-info-perps-only)
20+
- [`GET` Transaction Events](#get-transaction-events)
21+
- [`GET` SOL Balance](#get-sol-balance)
22+
- [`POST` Place Orders](#place-orders)
23+
- [`PATCH` Modify Orders](#modify-orders)
24+
- [`DELETE` Cancel Orders](#cancel-orders)
25+
- [`PUT` Atomic Cancel/Modify/Place Orders](#atomic-cancelmodifyplace-orders)
26+
- [Websocket API](#websocket-api)
27+
- [Subscribing](#subscribing)
28+
- [Event Payloads](#event-payloads)
2929

3030
## Build & Run
3131

3232
⚠️ Before starting, ensure a Drift _user_ account is initialized e.g. via the drift app at https://beta.drift.trade (devnet) or https://app.drift.trade
3333

34+
### From Source
35+
36+
Build:
37+
3438
supports rust <= 1.76.0
3539

3640
```bash
37-
# build
41+
# make a release build from source
3842
cargo build --release
43+
```
44+
45+
Run:
3946

47+
```bash
4048
# configure the gateway signing key
4149
export DRIFT_GATEWAY_KEY=</PATH/TO/KEY.json | seedBase58>
4250

@@ -49,15 +57,32 @@ drift-gateway --dev https://api.devnet.solana.com
4957
drift-gateway https://rpc-provider.example.com
5058
```
5159

52-
with docker
60+
### From Docker
61+
62+
Build the Docker image:
5363

5464
```bash
5565
docker build -f Dockerfile . -t drift-gateway
66+
```
67+
68+
Run the image:
69+
70+
```bash
5671
docker run -e DRIFT_GATEWAY_KEY=<BASE58_SEED> -p 8080:8080 drift-gateway https://api.mainnet-beta.solana.com --host 0.0.0.0
5772
```
5873

5974
## Usage
6075

76+
⚠️ Before starting, ensure a Drift _user_ account is initialized e.g. via the drift app at https://beta.drift.trade (devnet) or https://app.drift.trade
77+
78+
### Environment Variables
79+
80+
These runtime environment variables are required:
81+
82+
| Variable | Description | Example Value |
83+
|---------------------|-------------------------------------------|------------------------------|
84+
| `DRIFT_GATEWAY_KEY` | Path to your key file or seed in Base58. Transactions will be signed with this keypair | `</PATH/TO/KEY.json>` or `seedBase58` |
85+
6186
```bash
6287
Usage: drift-gateway <rpc_host> [--dev] [--host <host>] [--port <port>] [--delegate <delegate>] [--emulate <emulate>]
6388

@@ -332,7 +357,7 @@ get extended position info for perps positions
332357
$ curl localhost:8080/v2/positionInfo/0
333358
```
334359

335-
note:
360+
note:
336361
- `unrealizedPnL` is based on the oracle price at time of query
337362
- `unsettledPnl` does not include unsettled funding amounts
338363

@@ -403,9 +428,7 @@ A response for a transaction that was found, but doesn't contain any events for
403428
```
404429

405430
### Get SOL balance
406-
407-
Return the SOL balance of the transaction signer
408-
431+
Return the on-chain SOL balance of the transaction signer (`DRIFT_GATEWAY_KEY`)
409432
```bash
410433
$ curl localhost:8080/v2/balance
411434
```

0 commit comments

Comments
 (0)