On-chain (programs/): - driftbear_custom_adaptor (1,058 lines, deployed devnet) - drift_vaults (15,243 lines) - raydium_clmm (20,909 lines) - drift_rs_sdk (55,940 lines) - ctoken_market_program + mock (673 lines) New TypeScript modules (ported from 19 plugins): - JIT maker (sniper+shotgun from jit-proxy) - Filler bot (DLOB fills from keeper-bots-v2) - FloatingMaker (slot-based from keeper-bots-v2) - Executor upgrades (tx simulation, Jito bundles, ALTs) - Event stream (WebSocket + Yellowstone gRPC) - DLOB orderbook + price impact + funding TWAP - Ranger Data API (funding arbs, liquidation signals) - Ranger SOR (full API: quotes, withdraw, deposit collateral) - Sanctum LST (swap, APY, best LST selection) - Lulo lending aggregator - Pyth oracle cross-validation - Helius DAS API + smart priority fees - Flash Trade, Orca, Meteora, deBridge venue clients - Voltr vault strategy client - Drift insurance fund staking - Adaptor CPI client for on-chain program - Raydium LP strategy All wired into strategy engine runCycle(): - 11 data sources called every cycle - 3 background execution modules (JIT, Filler, FloatingMaker) - Multi-venue funding rate comparison - Lending yield optimizer across protocols - LP yield scanning (Orca + Meteora) - Auto-deploy idle capital to best lending protocol - Pyth oracle cross-validation - Realistic backtest mode (0.30% round-trip costs) Tests: 20/20 suites, 181/181 pass Build: zero TypeScript errors Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
59 lines
1.5 KiB
Markdown
59 lines
1.5 KiB
Markdown
# Simple Oracle Limit Maker
|
|
|
|
**⚠️ FOR EDUCATIONAL PURPOSES ONLY - NOT FOR PRODUCTION USE ⚠️**
|
|
|
|
A simplified market maker demonstrating Drift Protocol's TypeScript SDK with basic spread and inventory management.
|
|
|
|
## Strategy
|
|
|
|
- **Spread**: Places bid/ask orders around oracle price
|
|
- **Inventory Skewing**: Adjusts quotes based on position (widen away from inventory)
|
|
- **P&L Tracking**: FIFO matching for realized profit calculation
|
|
|
|
## Configuration
|
|
|
|
Edit `config.ts` to customize:
|
|
|
|
```typescript
|
|
export const MM_CONFIG = {
|
|
TARGET_MARKET: 'BTC', // Market to trade
|
|
ORDER_SIZE: 0.001, // BTC per order
|
|
MAX_POSITION: 0.01, // Position limit
|
|
BASE_SPREAD_BPS: 2, // Base spread (2 bps)
|
|
MAX_SKEW_BPS: 10, // Max position skew
|
|
DEBOUNCE_MS: 500, // Oracle update throttle
|
|
ORACLE_CHANGE_THRESHOLD_BPS: 5, // Min change to update
|
|
};
|
|
```
|
|
|
|
## Setup
|
|
|
|
Create `.env` file:
|
|
|
|
```bash
|
|
# Use either private key or keypair file path
|
|
PRIVATE_KEY=your_drift_wallet_private_key
|
|
KEYPAIR_PATH=~/.config/solana/my-keypair.json
|
|
RPC_ENDPOINT="https://mainnet.helius-rpc.com/?api-key=..."
|
|
```
|
|
|
|
```bash
|
|
bun install
|
|
bun run src/index.ts
|
|
```
|
|
|
|
## Disclaimers
|
|
|
|
- Educational code only, not production ready
|
|
- No kill switches or advanced risk management
|
|
- Non-atomic order replacement (cancel → place)
|
|
- May leave partial positions during errors
|
|
- No comprehensive monitoring or alerts
|
|
|
|
## Structure
|
|
|
|
- `src/maker.ts` - Core market making logic and order management
|
|
- `src/config.ts` - Configuration parameters
|
|
- `src/utils.ts` - Logging utilities
|
|
- `src/index.ts` - Entry point with graceful shutdown
|