v0.1.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 TypeScript SDK 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.

  • 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
  • Auto-invest via Jupiter — swap when threshold is reached
  • Works in browser and Node.js — no native dependencies

Quick Install

$npm install @buff/sdkCopy

5-Line Integration

app.ts
typescript
1import { Buff } from "@buff/sdk"
2
3const buff = await Buff.init({
4 platformId: "your-platform-id",
5 signMessage: (msg) => wallet.signMessage(msg),
6 plan: "sprout",
7 investInto: "BTC",
8})
9
10// Wrap any transaction — Buff adds round-up instructions
11const { transaction, breakdown } = await buff.wrap(tx, userPubkey, {
12 txValueUsd: 27.63
13})
14
15// breakdown.roundUpUsd = $0.37 (rounds $27.63 → $28.00)
16// breakdown.userInvestmentUsd = $0.3672
17// 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
3. Spare change accumulatesRound-ups collect in user's Buff wallet
4. Threshold hitWhen $5+ accumulated, auto-swap via Jupiter into target asset
5. Portfolio growsUser can view holdings or export wallet to Phantom

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.

Architecture

architecture
bash
@buff/sdk
├── buff.ts Main class — init, wrap, checkAndInvest
├── config.ts Plans, token mints, network configs
├── fee.ts Round-up calculation (fixed-point math)
├── wallet.ts Deterministic wallet from signature
├── price.ts CoinGecko price API with caching
├── accumulator.ts Balance tracking + threshold
├── swap.ts Jupiter DEX execution + retries
├── portfolio.ts Token balance reader
├── persistence.ts localStorage / memory adapters
├── events.ts Typed event emitter
└── errors.ts BuffPriceError, BuffSwapError, etc.