Lazy OKX DCA - Automated Dollar Cost Averaging
Automated DCA strategy powered by OKX OnchainOS DEX API. Execute scheduled token purchases across 20+ chains with optimal routing through 500+ DEXs.
When to Use
Apply this skill when:
-
Setting up automated token purchases (DCA) via OKX
-
Finding optimal swap rates across OKX DEXs
-
Monitoring token prices and execution history
-
Managing portfolio accumulation strategies
Prerequisites
- Install OKX OnchainOS Skills
npx skills add okx/onchainos-skills
- Get OKX API Credentials
Visit OKX OnchainOS Developer Portal:
-
Connect your OKX Wallet
-
Navigate to API Key management
-
Create a new API Key
-
Save the following credentials:
-
OK-ACCESS-KEY (API Key)
-
OK-ACCESS-SECRET (Secret Key)
-
OK-ACCESS-PASSPHRASE (Passphrase)
- Configure Environment Variables
Add credentials to your OpenClaw config:
Via openclaw.json (recommended):
Edit ~/.openclaw/openclaw.json :
{ "skills": { "entries": { "lazy-okx-dca": { "env": { "OKX_API_KEY": "your-api-key", "OKX_SECRET_KEY": "your-secret-key", "OKX_PASSPHRASE": "your-passphrase", "WALLET_PRIVATE_KEY": "your-wallet-private-key" } } } } }
Via .env file:
Create .env in project directory:
OKX_API_KEY=your-api-key OKX_SECRET_KEY=your-secret-key OKX_PASSPHRASE=your-passphrase WALLET_PRIVATE_KEY=your-wallet-private-key
Via shell profile:
Add to ~/.zshrc or ~/.bashrc :
export OKX_API_KEY="your-api-key" export OKX_SECRET_KEY="your-secret-key" export OKX_PASSPHRASE="your-passphrase" export WALLET_PRIVATE_KEY="your-wallet-private-key"
Run source ~/.zshrc to apply changes.
- Verify Installation
Restart OpenClaw and test:
"What's the current price of ETH?"
OKX Capabilities
Feature Description
Multi-chain Ethereum, Polygon, Arbitrum, Optimism, Solana, Sui, TON, X-Layer, 20+ chains
DEX Aggregation Routes across 500+ DEXs for optimal pricing
Best Price Real-time comparison with smart order splitting
Low Slippage Intelligent routing minimizes price impact
Supported Chains
Chain Status Popular Tokens
Ethereum Supported ETH, USDC, USDT
Polygon Supported MATIC, USDC
Arbitrum Supported ETH, USDC
Optimism Supported ETH, USDC
Solana Supported SOL, USDC
Base Supported ETH, USDC
X-Layer Supported OKB, USDC
Sui Supported SUI
TON Supported TON
See OKX OnchainOS Docs for full list.
Usage Patterns
Single Purchase
"Buy 100 USDC worth of ETH with 0.5% slippage"
Setup DCA Schedule
"Set up weekly DCA: buy 50 USDC of BTC every Monday at 10am"
Query Best Rate
"Show me the best rate for swapping 1 ETH to USDC across all DEXs"
View History
"Show my recent DCA transactions"
Environment Variables
Required
Variable Description Source
OKX_API_KEY
OKX API key OKX OnchainOS
OKX_SECRET_KEY
OKX API secret Same as above
OKX_PASSPHRASE
OKX API passphrase Same as above
WALLET_PRIVATE_KEY
Wallet private key for signing Your wallet export
Optional
Variable Default Description
DCA_DEFAULT_AMOUNT
100
Default DCA amount (USDC)
DCA_DEFAULT_TOKEN
ETH
Default purchase token
DCA_DEFAULT_SLIPPAGE
0.005
Default slippage (0.5%)
DCA_DEFAULT_CHAIN
eth
Default blockchain
Workflow
- Receive DCA instruction ↓
- Query OKX DEX API for optimal quote ↓
- Display price estimate + slippage + fees ↓
- Wait for user confirmation ↓
- Construct transaction data ↓
- Sign and broadcast (requires private key) ↓
- Log transaction ↓
- Wait for on-chain confirmation
Security Notes
-
Private key storage: Keys stored locally only, never uploaded
-
Test first: Use small amounts for initial testing (e.g., 1 USDC)
-
Slippage settings: Increase during high volatility to avoid failed transactions
-
Gas fees: Be aware of on-chain gas costs for small transactions
-
Dedicated wallet: Use a separate wallet for DCA operations
DCA Psychology Tips
-
Cost averaging: Buy less at highs, more at lows, lowering average cost
-
Emotional stability: No need to watch markets, avoid FOMO and panic selling
-
Long-term focus: Time in market beats timing the market
-
Automation: Discipline matters more than timing