v1.0.0

Buff SDK

Round up every Solana transaction and auto-invest the spare change into crypto assets. Like Acorns, but onchain.

What is Buff?

Buff is a thin TypeScript API client that integrates into any Solana application. When your users make a transaction, Buff rounds up the total value to the nearest increment and invests the spare change into crypto assets like BTC, ETH, or SOL. All fee logic and swap execution happens server-side.

  • Round up every transaction — users build portfolios passively
  • Four plan tiers — from $0.05 to $1.00 round-up increments
  • Non-custodial — deterministic wallet derived from user's signature via API
  • Auto-invest via Jupiter — server-side swaps when threshold is reached
  • Works in browser and Node.js — thin API client, no native dependencies

Quick Install

$npm install buff-protocol-sdkCopy

5-Line Integration

app.ts
typescript
1import { Buff } from "buff-protocol-sdk"
2
3const buff = new Buff({
4 apiKey: "your-api-key",
5 plan: "sprout",
6 investInto: "BTC",
7})
8
9// Get wrap instructions — Buff calculates round-up server-side
10const { instructions, breakdown } = await buff.getWrapInstructions(
11 27.63, userPubkey, buffWalletPubkey
12)
13
14// breakdown.roundUpUsd = $0.37 (rounds $27.63 → $28.00)
15// breakdown.userInvestmentUsd = $0.3672
16// breakdown.buffFeeUsd = $0.0028

How It Works

StepWhat happens
1. User transactsSwap, mint, stake — any Solana action
2. Buff rounds upTotal tx value rounded to nearest plan increment (server-side calculation)
3. Spare change accumulatesRound-ups collect in user's Buff wallet
4. Threshold hitWhen $5+ accumulated, server builds swap transactions via Jupiter
5. Portfolio growsUser can view holdings via getPortfolio(address)

Plan Tiers

PlanRounds toBuff FeeExample ($1.52 tx)
Seed$0.051.00%$1.52 → $1.55 = $0.03
Sprout$0.100.75%$1.52 → $1.60 = $0.08
Tree$0.500.50%$1.52 → $2.00 = $0.48
Forest$1.000.25%$1.52 → $2.00 = $0.48
Note
Exact dollar amounts (e.g. $2.00 with $0.50 increment) are skipped entirely — no charge, no round-up. The ceiling is $1.00 max per transaction. All fee calculations happen server-side — the treasury address is never exposed to the client.

Architecture

architecture
bash
buff-protocol-sdk (thin API client)
├── buff.ts Main class — constructor, config, API calls
├── auth.ts API key or wallet signature auth
├── roundup.ts calculateRoundUp → server-side breakdown
├── wrap.ts getWrapInstructions → transfer instructions
├── portfolio.ts getPortfolio(address) → token balances
├── accumulator.ts getAccumulator(address) → balance + threshold
├── swap.ts getSwapQuote, buildSwap, executeSwap
├── wallet.ts deriveWallet(signature) → server-side derivation
├── plans.ts getPlans, getPrices
├── agent.ts registerAgent, API key auth for agents
└── errors.ts BuffApiError, BuffAuthError, etc.