valeo-idle
v0.2.8
Published
Automatic yield for AI agent wallets. One import. Zero config.
Maintainers
Readme
@valeo/idle
Automatic yield on idle USDC for Solana agent wallets. MVP: Drift spot deposits only — one import, defaults for everything else.
import { idle } from "@valeo/idle"
idle()Set SOLANA_PRIVATE_KEY (base58 or JSON byte array) and optional SOLANA_RPC. The background loop deposits excess USDC into Drift when you look idle, and pulls back toward a target wallet balance when your USDC token account changes.
Wait, that’s it?
Yes for wiring. You still need:
- A funded Solana wallet (SOL for fees).
- USDC in the wallet’s associated token account (mainnet mint
EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1vby default). - An RPC that can handle your polling + Drift account loads.
Usage
Recommended
import { idle } from "@valeo/idle"
idle()Auto-start (no code besides import)
IDLE_AUTO_START=true SOLANA_PRIVATE_KEY=... node agent.jsimport "@valeo/idle"Configuration
import { idle } from "@valeo/idle"
idle({
bufferAmount: 10_000_000, // $10 USDC (6 decimals) minimum in wallet
minDeposit: 5_000_000,
checkInterval: 30_000,
protocols: ["drift"],
maxAllocation: 0.9,
activityWithdrawAmount: 5_000_000, // extra target liquidity on ATA activity (optional)
rpc: process.env.SOLANA_RPC,
onDeposit: (amount, protocol) => {},
onWithdraw: (amount, reason) => {},
onYield: (earned) => {},
onError: (err) => {},
})idle() returns a singleton per wallet (keyed by public key), so multiple agents need different keys or separate processes.
CLI
Run without writing code:
npx valeo-idleUses env keys if set; otherwise offers ~/.config/solana/id.json, or prompts for a base58 secret or keypair path (masked input in TTY). Ctrl+C withdraws from Drift and prints a session summary.
npx valeo-idle --help
npx valeo-idle --keypair ~/.config/solana/id.json
npx valeo-idle --buffer 5.00 --rpc https://api.mainnet-beta.solana.com
npx valeo-idle --devnet --keypair ./test-wallet.json
SOLANA_PRIVATE_KEY=... npx valeo-idle --quietFlags: --key, --keypair, --rpc, --buffer (USD), --min-deposit (USD), --devnet, --quiet, --version.
MVP limitations (read this)
- Drift only — Kamino, Marginfi, and Marinade adapters are stubs for a later release.
- No cross-protocol rebalance — Optimizer always picks the enabled adapter (Drift).
- Activity detection is heuristic — “Idle” means no recent signatures on your wallet (~60s) and deposits pause while “active”. USDC ATA changes trigger a debounced withdraw toward
bufferAmount + activityWithdrawAmount. - Not true AMP pre-withdraw — Without v0.2 hooks into
@ampvaleo/amp-client, a transaction built only from the current wallet balance can still fail if you need more USDC than is liquid. Mitigation: raisebufferAmount/activityWithdrawAmount, or ensure spend size fits the buffer. - Silent degradation — RPC/Drift errors are swallowed unless you set
onError; your agent keeps working, possibly without yield.
Wallet env vars
Detection order: SOLANA_PRIVATE_KEY, AGENT_PRIVATE_KEY, WALLET_PRIVATE_KEY, PRIVATE_KEY, SOL_PRIVATE_KEY, then SOLANA_WALLET_PATH (JSON key file).
Scripts
| Command | Description |
| --------- | ------------------ |
| npm run build | tsc → dist/ + postbuild chmod dist/cli.js |
| npm test | Jest (unit tests) |
| npm run dev | tsx examples/basic.ts |
| node dist/cli.js --help | Local CLI smoke test |
Requirements
- Node 18+ (Drift’s published SDK may declare newer engines; overrides align
@solana/web3.jswith this package.)
License
Apache-2.0 (match Drift SDK; confirm for your org before publish).
