Buff Round-Up Investing for OpenClaw
Buff tracks your agent's transaction costs and calculates how much spare change could be invested. By default, Buff only calculates and records round-ups — actual investment execution is opt-in and requires explicit configuration.
What This Skill Does
- Calculates round-ups: "$4.73 transaction → $5.00 = $0.27 spare change"
- Tracks accumulated spare change over time
- Optionally invests when the user enables auto-invest and the threshold is reached
This skill does NOT:
- Move funds without explicit opt-in
- Access any wallet keys unless the user provides
BUFF_AGENT_SEED - Make payments on your behalf (x402 is disabled by default)
Setup
1. Install
npm install buff-protocol-sdk @solana/web3.js
The SDK is open source on GitHub and published on npm.
2. Configure
Set environment variables. Only BUFF_AGENT_SEED is sensitive — treat it like a private key.
# Required: 32-byte hex seed (generate one below)
BUFF_AGENT_SEED=your-32-byte-hex-seed
# Optional: customize behavior (defaults shown)
BUFF_PLAN=sprout # seed|sprout|tree|forest
BUFF_INVEST_INTO=BTC # BTC|ETH|SOL|USDC
BUFF_THRESHOLD=5 # USD threshold before swap
Generate a seed:
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
3. Initialize
import { Buff } from "buff-protocol-sdk"
const buff = await Buff.init({
agentSeed: process.env.BUFF_AGENT_SEED,
platformId: "openclaw-agent",
agentId: process.env.OPENCLAW_AGENT_ID || "my-agent",
source: "agent",
plan: process.env.BUFF_PLAN || "sprout",
investInto: process.env.BUFF_INVEST_INTO || "BTC",
investThreshold: Number(process.env.BUFF_THRESHOLD) || 5,
})
Usage
Record a round-up (calculation only, no funds moved):
const { breakdown } = await buff.wrapAmount({
txValueUsd: 4.73,
source: "agent",
memo: "API call",
})
console.log("Round-up: $" + breakdown.roundUpUsd)
// Sprout plan: $4.73 → $4.80 = $0.07 recorded
Check accumulated total:
const stats = buff.getStats()
console.log("Total round-ups:", stats.totalRoundUps)
console.log("Accumulated: $" + stats.totalInvestedUsd)
View portfolio:
const portfolio = await buff.getPortfolio()
console.log("Pending SOL:", portfolio.pendingSol)
console.log("Invested:", portfolio.totalUsd, "USD")
Opt-in: Execute investment (only when explicitly called):
// Only call this if you want to actually swap SOL → BTC/ETH via Jupiter
const { swaps } = await buff.checkAndInvest()
if (swaps.length > 0) {
console.log("Invested:", swaps.map(s => s.asset).join(", "))
}
Plan Tiers
| Plan | Rounds to | Fee | Description |
|---|---|---|---|
| Seed | $0.05 | 1% | Smallest round-ups |
| Sprout | $0.10 | 0.75% | Default, balanced |
| Tree | $0.50 | 0.5% | Moderate round-ups |
| Forest | $1.00 | 0.25% | Maximum round-ups |
Security
- The
BUFF_AGENT_SEEDis used to derive a deterministic Solana keypair. Never share it. - The derived wallet only holds accumulated round-up SOL — keep it funded with small amounts.
- No funds are moved without calling
checkAndInvest()explicitly. - All code is open source — audit it yourself.
- The SDK connects to public Solana RPC and Jupiter API — no proprietary backends.
Dashboard
Monitor your agent's portfolio at: https://sow-beryl.vercel.app/dashboard
- Use the "Monitor" tab
- Enter your agent's public key (not the seed)
- View portfolio, activity, and allocation (read-only)