A TypeScript monorepo for building multiple bots with shared utilities and services.
ts-bots/
├── packages/
│ ├── shared/ # Shared utilities, GraphQL client, config
│ └── loom/ # Loom bot
├── package.json # Root package with workspace configuration
├── tsconfig.json # Root TypeScript configuration
└── README.md # This file
-
Install dependencies:
npm install
-
Build all packages:
npm run build
-
Run the loom bot in development:
MODE=openai npm run loom
-
Copy the example environment file:
cp env.example .env
-
Update the
.envfile with your API configuration.
Required for OpenAI mode:
- RPC_URL, PRIVATE_KEY, CHAIN_ID
- SAPIENCE_API
- OPENAI_API_KEY
- OPENAI_MODE_INTERVAL (optional, default 60)
npm run build- Build all packagesnpm run dev- Start development mode for all packagesnpm run lint- Lint all packagesnpm run format- Format code with Prettiernpm run type-check- Type check all packages
The @ts-bots/shared package provides:
- GraphQL Client: Easy-to-use GraphQL service
- API Client: Axios-based REST API client
- Configuration: Environment-based configuration management
- Utilities: Common utilities like retry logic, logging, and delays
Set environment variables in Railway project:
- MODE=openai
- RPC_URL, PRIVATE_KEY, CHAIN_ID
- SAPIENCE_API
- OPENAI_API_KEY
- OPENAI_MODE_INTERVAL (optional, default 60)
- CONCENTRATION_RANGE, DEVIATION_THRESHOLD, DEFAULT_COLLATERAL_AMOUNT (as desired)
Build command:
npm ci && npm run buildStart command:
MODE=openai node packages/loom/dist/index.jsAt startup, the app prints a configuration summary for the selected mode.
- Create a new directory in
packages/ - Copy the structure from
packages/loom/ - Update the package name in
package.json - Import and use utilities from
@ts-bots/shared