Conditional DCA Protocol: Execute trades on specific market conditions, not just fixed schedules
🚀 Cross-Chain Funding · 🎯 Condition-Based Execution · 🔊 Voice Alerts · ⚡ Sub-Second Speed
SmartDCA is a next-generation decentralized dollar-cost averaging protocol built on Solana. Unlike traditional DCA tools that buy on fixed schedules, SmartDCA allows you to set specific market conditions that trigger your trades automatically.
Key Innovation: Instead of "buy $50 of SOL every Monday", you can set "buy $50 of SOL only when it drops 5% in 24 hours" or "buy $100 of JUP when RSI falls below 30".
Demo Video: https://www.youtube.com/watch?v=s5o6E8Wc0GE
All configuration values are centralized in src/lib/config.ts, including:
- API endpoints (Jupiter, LI.FI)
- Token addresses and decimals
- Swap parameters (slippage, fees)
- Bridge configuration
- Strategy limits and defaults
- Error messages
This makes it easy to adjust behavior without hunting through multiple files.
User (Any Chain)
│
▼
LI.FI Bridge ──── bridges USDC to Solana
│
▼
Anchor Escrow PDA ◄──── Helius Webhook monitors price
│ │
│ condition met?
│ YES ▼
└──────────► Jupiter CPI (swap USDC → token)
│
▼
ElevenLabs voice alert
- Price Drop: Execute when token drops X% in 24h
- RSI-Based: Buy when RSI falls below threshold
- Weekly Comparison: Execute if price is below last week's price
- Non-Custodial: Your funds remain in your control
- Anchor Program: Battle-tested Solana smart contract framework
- PDA Escrow: Program-derived account security
- Sub-Second Execution: Leverages Solana's 400ms block times
- Jupiter Routing: Best price execution across all liquidity
- Atomic Operations: Either succeeds completely or fails safely
- Multi-Chain Support: Deposit from Ethereum, Base, Polygon, etc.
- LI.FI Integration: Seamless cross-chain bridging
- USDC Conversion: Automatic token conversion on Solana
- Voice Alerts: Natural ElevenLabs TTS notifications
- Dashboard: Real-time strategy monitoring
- Web3 Integration: Wallet connection with RainbowKit
- Framework: Next.js 16 with App Router
- UI Components: shadcn/ui + Tailwind CSS
- Styling: Custom gradient system with backdrop blur
- State Management: React Query for data fetching
- Wallets: RainbowKit + Solana wallet adapters
- Framework: Anchor 0.30.1
- Language: Rust (Edition 2021)
- Program ID:
4uH1ZvU29XFzRCEk4S7dNT29gUWMPU3gHaZQdhiacxhF(Devnet) - Token Standard: SPL Token (USDC)
- Oracles: Helius/Pyth price feeds
- DEX Aggregation: Jupiter API
- Cross-Chain: LI.FI SDK
- Voice Synthesis: ElevenLabs
- Database: Supabase (for off-chain data)
- Node.js 18+
- Solana CLI
- Yarn package manager
- Clone the repository
git clone https://github.com/your-username/smart-dca.git
cd smart-dca- Install dependencies
# Install frontend dependencies
npm install
# Install Rust/Anchor dependencies
cd smart-dca
yarn install- Set up environment variables
cp .env.example .env.local
# Fill in your API keys and wallet paths- Configure Solana wallet
solana-keygen new --outfile ~/.config/solana/id.jsonStart the development server:
npm run devOpen http://localhost:3000 to see the landing page.
Start the Anchor program:
cd smart-dca
anchor localnetSmartDCA/
├── src/
│ ├── app/ # Next.js App Router
│ │ ├── api/ # API routes
│ │ ├── create/ # Strategy creation page
│ │ ├── dashboard/ # User dashboard
│ │ └── strategy/ # Strategy management
│ ├── components/ # React components
│ │ ├── ui/ # shadcn/ui components
│ │ ├── layout/ # Layout components
│ │ └── voice/ # Voice alert components
│ ├── hooks/ # Custom React hooks
│ ├── lib/ # Utility functions
│ └── types/ # TypeScript definitions
├── smart-dca/ # Anchor program
│ ├── programs/
│ │ └── smart-dca/ # Rust program source
│ ├── tests/ # Program tests
│ └ migrations/ # Database migrations
├── components.json # shadcn/ui configuration
├── tailwind.config.js # Tailwind CSS configuration
└── package.json # Project dependencies
npm run test # Run Jest tests
npm run test:watch # Run tests in watch modecd smart-dca
anchor test # Run all program tests
anchor test -- --grep "initialize" # Run specific testsnpm run test:integration # End-to-end testingnpm run build
npm run start# Deploy to Devnet
anchor deploy --provider.cluster devnet
# Deploy to Mainnet (when ready)
anchor deploy --provider.cluster mainnet-betaCreate a .env.local file with:
# Supabase
NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_key
# ElevenLabs
ELEVENLABS_API_KEY=your_elevenlabs_key
# LI.FI
LIFI_API_KEY=your_lifi_api_key
# Jupiter
JUPITER_PRICE_API=https://lite-api.jup.ag/price/v3
JUPITER_SWAP_API=https://lite-api.jup.ag/swap/v1
# Application
NEXT_PUBLIC_APP_URL=http://localhost:3000
NEXT_PUBLIC_SOLANA_NETWORK=devnet
# LI.FI Bridge
LIFI_API=https://li.quest/v1POST /api/strategies- Create new strategyGET /api/strategies- Get user strategiesPUT /api/strategies/:id- Update strategyDELETE /api/strategies/:id- Delete strategyGET /api/strategies/:id/history- Get trade history
Available at /api/graphql for complex queries.
Creates a new escrow account and stores the DCA strategy.
Accounts Required:
owner(signer)escrow_account(PDA, init)usdc_token_accounttoken_programsystem_programrent
Transfers USDC from owner to escrow.
Executes trade when condition is met.
Pauses or resumes strategy.
interface EscrowAccount {
owner: PublicKey;
usdc_token_account: PublicKey;
total_deposited: u64;
balance: u64;
condition: StrategyCondition;
last_executed_at: i64;
execution_count: u64;
is_active: bool;
bump: u8;
}
interface StrategyCondition {
condition_type: ConditionType;
threshold_bps: u64;
trade_amount_usdc: u64;
output_mint: PublicKey;
min_output_amount: u64;
}- Color Palette: Solana purple and green gradients
- Typography: Modern font with proper hierarchy
- Animations: Smooth transitions and micro-interactions
- Responsive: Mobile-first design approach
- ElevenLabs Integration: Natural-speech synthesis
- Custom Voice Profiles: Configurable alert voices
- Real-time Notifications: Immediate trade execution feedback
- Strategy Overview: Active/paused strategies status
- Performance Analytics: ROI and execution metrics
- Trade History: Complete audit trail
- Condition Builder: Visual strategy creation
- Formal Verification: Critical functions verified
- Access Control: Owner-only operations
- Reentrancy Protection: Solidity-style guards
- Overflow Protection: Rust type safety
- Input Validation: Client and server-side validation
- XSS Protection: React's built-in protections
- CSRF Protection: Next.js security features
- Secure Storage: Encrypted wallet management
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
- Rust: Follow Rust official style
- TypeScript: Use ESLint configuration
- CSS: Follow Tailwind conventions
- Mainnet deployment
- Mobile app (React Native)
- Advanced condition types
- Strategy templates
- Mobile notifications
- Advanced analytics
- Multi-strategy management
- Social features
- Institutional features
- API for third-party integrations
- Advanced trading conditions
- Portfolio management tools
This project is licensed under the MIT License - see the LICENSE file for details.
- Solana for the fast blockchain
- Anchor for the excellent framework
- Jupiter for the DEX aggregation
- RainbowKit for the wallet integration
- ElevenLabs for the voice synthesis