This guide covers the deployment of the Drift system, including environment configuration, database setup, and service orchestration.
Before deploying, ensure you have the following installed:
- Node.js: v18 or higher
- PostgreSQL: v14 or higher
- Redis: v6 or higher (required for BullMQ)
- Git: For version control
Create a .env file in the root directory. You can start by copying the example:
cp .env.example .env| Variable | Description | Default/Example |
|---|---|---|
PORT |
API Server Port | 3000 |
DATABASE_URL |
PostgreSQL Connection String | postgresql://user:pass@localhost:5432/drift |
REDIS_URL |
Redis Connection String | redis://localhost:6379 |
NODE_ENV |
Environment | development or production |
| Variable | Description | Example |
|---|---|---|
RPC_URL |
Monad Testnet RPC URL | https://testnet-rpc.monad.xyz/ |
PRIVATE_KEY |
Deployer/Bot Private Key | 0x... |
PIMLICO_API_KEY |
Bundler API Key (if using Pimlico) | pimlico_... |
CHAIN_ID |
Chain ID | 10143 (Monad) |
| Variable | Description |
|---|---|
SMART_ACCOUNT_FACTORY_ADDRESS |
Address of the deployed SmartAccountFactory |
DELEGATION_MANAGER_ADDRESS |
Address of the DelegationManager contract |
UNISWAP_V2_ROUTER |
Address of the Uniswap V2 Router |
USDC_ADDRESS |
Address of the USDC token |
WMON_ADDRESS |
Address of the Wrapped Monad token |
| Variable | Description | Default |
|---|---|---|
PRICE_SOURCE |
Price feed source | ROUTER or ORACLE |
| Variable | Description |
|---|---|
GROQ_API_KEY |
API Key for Groq (Llama 3.3) |
Initialize the database schema:
# Run migrations
npx prisma migrate deploy
# Generate Prisma client
npx prisma generateCompile the TypeScript code:
npm run buildDrift consists of three main services that should run concurrently.
Handles user requests, dashboard data, and webhooks.
npm run start:serverProcesses background jobs (AI analysis, rebalancing tasks).
npm run start:workerMonitors on-chain prices and triggers rebalancing checks.
npm run start:pollernpm run dev:allThis command will automatically:
- Clean the
distfolder. - Generate Prisma Client.
- Build the TypeScript project.
- Run database migrations.
- Start all services.
docker-compose up --buildThis will start:
- API Server:
http://localhost:4000 - Prisma Studio:
http://localhost:5555 - PostgreSQL: Port
5432 - Redis: Port
6379 - Worker & Poller: Background services
After deployment, verify the system is running correctly:
- Check Logs: Ensure
drift-polleris fetching prices anddrift-workeris ready to process jobs. - Test Rebalance: Manually trigger a rebalance or wait for the poller to detect drift.