Optivault is an intelligent, non-custodial yield aggregator on the Solana blockchain where you can deposit your assets, select a personalized risk profile, and let an automated AI Agent dynamically rebalance your portfolio.
| Feature | Description |
|---|---|
| 🏦 Personalized Vaults | Define your time horizon and set your risk appetite (Conservative, Balanced, Aggressive). |
| 🤖 AI-Driven Rebalancing | An off-chain analyzer continuously monitors protocol APYs, liquidity, and risk metrics. |
| 🔒 On-chain Security | Funds are secured on-chain via our Rust-based Anchor program in user-specific PDAs. |
| ⚡ Automated Execution | The AI agent automatically fires signed rebalance transactions to capture the highest safe yields. |
| 🌐 Zero-Friction UI | A seamless Next.js frontend with robust wallet integration for tracking performance and allocations. |
Optivault/
├── 📁 agent/ # Off-chain AI Rebalancer
│ ├── 📁 src/ # Node.js Agent logic
│ │ ├── analyzer.ts # Rebalance decision engine
│ │ ├── config.ts # Protocol configurations
│ │ ├── executor.ts # Transaction execution
│ │ ├── monitor.ts # APY and liquidity monitoring
│ │ └── index.ts # Agent entry point
│ └── package.json
├── 📁 app/ # Frontend UI
│ ├── 📁 src/
│ │ ├── 📁 app/ # Next.js App Router pages
│ │ │ ├── 📁 activity/ # Activity log page
│ │ │ ├── 📁 api/ # API routes (agent-events)
│ │ │ ├── 📁 dashboard/ # AI Yield dashboard
│ │ │ ├── 📁 settings/ # User settings page
│ │ │ └── 📁 setup/ # Vault setup wizard
│ │ ├── 📁 components/ # UI components (Dashboard, Setup, Layout)
│ │ ├── 📁 hooks/ # Custom Solana hooks
│ │ └── 📁 lib/ # Utility functions & Anchor IDL
│ └── package.json
├── 📁 assets/ # Project assets (banners)
└── 📁 optivault/ # Smart Contract
├── 📁 programs/optivault/ # Anchor Program
│ └── 📁 src/
│ ├── 📁 instructions/ # Deposit, Withdraw, Rebalance logic
│ ├── 📁 state/ # PDA states
│ ├── errors.rs # Custom program errors
│ └── lib.rs # Program entry point
└── Anchor.toml # Anchor workspace config
Core Anchor program managing user deposits, risk profiles, and rebalancing constraints.
| Function | Access | Description |
|---|---|---|
initialize(risk_level, time_horizon) |
User | Initialize a new user vault with specific risk settings |
deposit(amount) |
User | Deposit tokens into the user's vault PDA |
withdraw(amount) |
User | Withdraw tokens from the vault |
rebalance(target_protocol, amount) |
Authorized Agent | AI agent executes optimal yield routing based on risk profile |
- State Management: Stores
risk_levelandtime_horizonon-chain. - Security: Strict access controls ensuring only authorized agent can rebalance, while only the user can withdraw.
| Tool | Purpose |
|---|---|
| Solana | High-performance blockchain |
| Anchor | Solana smart contract framework |
| Rust | Smart contract language |
| Tool | Purpose |
|---|---|
| Next.js | React framework for web applications |
| Tailwind CSS | Utility-first styling |
| @solana/wallet-adapter | Wallet connection UI |
| Tool | Purpose |
|---|---|
| Node.js | Runtime environment |
| TypeScript | Type-safe execution |
| @solana/web3.js | On-chain interactions |
Make sure you have the following installed:
- Node.js v18+
- Yarn / npm
- Rust & Solana CLI
- Anchor CLI (
avm)
cd optivaultInstall dependencies:
yarn installBuild the Anchor program:
anchor buildDeploy to localnet or devnet:
anchor deploycd appInstall dependencies:
npm installStart the development server:
npm run devOpen your browser and navigate to http://localhost:3000 🎉
cd agentInstall dependencies:
npm installConfigure environment variables:
Create a .env file in agent/ and add your RPC URL and agent keypair config:
cp .env.example .envStart the monitoring and execution agent:
npm start1. User connects wallet and initializes a Vault via the UI
↓ (Risk level and time horizon stored in PDA)
2. User deposits assets into our Smart Contract
↓ (Funds secured in a protocol-controlled vault)
3. Off-chain AI Agent constantly monitors DeFi protocols (Kamino, MarginFi)
↓ (Analyzes APY, Liquidity, checks against user risk profile)
4. Agent computes the optimal allocation for yield
↓ (Simulates potential improvements)
5. Agent triggers the `rebalance` instruction on-chain
↓ (Smart Contract verifies agent signature and executes transfer)
6. User's portfolio grows automatically
- Non-Custodial Design: The AI Agent can only rebalance funds across approved protocols; it cannot withdraw user funds.
- On-Chain Risk Enforcement: The Anchor program enforces limits preventing aggressive moves for conservative profiles.
- PDA Architecture: User balances are securely isolated using Program Derived Addresses.
| Level | Strategy | Allowed Protocols |
|---|---|---|
| 🟢 Conservative | Low volatility, steady reliable yield | Kamino, MarginFi |
| 🟡 Balanced | Moderate risk over medium timeframe | Kamino, MarginFi, Drift |
| 🔴 Aggressive | High yield optimization, frequent moves | All supported protocols |
Track: DeFi
Live Demo: https://youtu.be/Vd4qzwGsE5Q?si=KsDypV-n02ij8hMD
Video Presentation: https://youtu.be/DMi268AB3aY?si=xYL6Bn2lyHC5qDah
Made with 🩵 by the Optivault Team · Built for the Solana Ecosystem.

