SDK
Python SDK
Full Buff SDK for Python — same features as the TypeScript SDK.
Install
$
pip install buff-sdkCopyQuick Start
main.py
typescript
1from buff import calculate_round_up, calculate_fees, derive_wallet, PriceService23# Calculate a round-up4round_up, rounded_to, skipped, capped = calculate_round_up(27.63, 0.50)5print(f"Round-up: ${round_up}") # $0.3767# Full fee breakdown with real SOL price8price_service = PriceService()9sol_price = price_service.get_sol_price()10breakdown = calculate_fees(27.63, sol_price, 0.50)11print(f"Investing: ${breakdown.user_investment_usd}")1213# Derive Buff wallet (same as TypeScript SDK)14signature = wallet.sign_message(b"Buff Portfolio Wallet v1")15keypair = derive_wallet(signature)16print(f"Buff wallet: {keypair.pubkey()}")Modules
| Module | Purpose |
|---|---|
| buff.fee | calculate_round_up(), calculate_fees() — fixed-point math |
| buff.wallet | derive_wallet() — SHA-256 + Solana keypair from signature |
| buff.config | PLAN_TIERS, token mints, RPC URLs, fee tiers |
| buff.price | PriceService — CoinGecko with TTL caching |
| buff.swap | get_swap_quote() — Jupiter integration via httpx |
| buff.portfolio | get_portfolio() — read onchain token balances |
| buff.events | BuffEventEmitter — on/off/emit |
| buff.errors | BuffError, BuffPriceError, BuffSwapError, etc. |
Note
The Python SDK produces the same deterministic wallet as the TypeScript SDK — same signature input always generates the same Buff wallet across languages.