API
buff.getPortfolio()
Read all token balances and USD values for a Buff wallet address.
Signature
types.ts
typescript
1async getPortfolio(address: string): Promise<Portfolio>23interface Portfolio {4 walletAddress: string5 balances: TokenBalance[]6 totalUsd: number // Total invested assets value7 pendingSol: number // SOL waiting for threshold8 pendingUsd: number // In USD9 solPriceUsd: number // Current SOL price10}1112interface TokenBalance {13 asset: SupportedAsset14 mint: string15 balance: string // Human-readable amount16 usdValue: number17}Example
portfolio.ts
typescript
1const portfolio = await buff.getPortfolio(buffWalletPubkey)23console.log("Wallet:", portfolio.walletAddress)4console.log("Total invested:", "$" + portfolio.totalUsd.toFixed(2))5console.log("Pending SOL:", portfolio.pendingSol.toFixed(6))6console.log("Pending USD:", "$" + portfolio.pendingUsd.toFixed(2))78for (const balance of portfolio.balances) {9 console.log(balance.asset + ":", balance.balance, "($" + balance.usdValue.toFixed(2) + ")")10}11// BTC: 0.00068 ($48.20)12// ETH: 0.015 ($31.50)Other Methods
methods.ts
typescript
1// Derive the Buff wallet address (server-side)2const buffWallet = await buff.deriveWallet(signature)3// "E71R6Ph2sS4eYJVSNLacorUtSDNK1rUixVswgFD5hCY3"45// Get accumulator state6const state = await buff.getAccumulator(buffWalletPubkey)7// { balanceSol: 0.034, balanceUsd: 5.10, thresholdReached: true, ... }89// Get available plans10const plans = await buff.getPlans()11// [{ tier: "seed", roundToUsd: 0.05, feePercent: 1.00 }, ...]1213// Get current asset prices14const prices = await buff.getPrices()15// { SOL: 150.00, BTC: 71000, ETH: 2100, ... }1617// Preview round-up without wrapping18const breakdown = await buff.calculateRoundUp(27.63)19// { roundUpUsd: 0.37, userInvestmentUsd: 0.3672, ... }Note
getPortfolio() now requires a wallet address parameter. Portfolio values are fetched from the Buff API with live USD prices. All calculations happen server-side.