API
buff.getPortfolio()
Read all token balances and USD values from the Buff wallet.
Signature
types.ts
typescript
1async getPortfolio(): 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 decimals: number17 usdValue: number18}Example
portfolio.ts
typescript
1const portfolio = await buff.getPortfolio()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// Get the Buff wallet address2buff.getWalletAddress()3// "E71R6Ph2sS4eYJVSNLacorUtSDNK1rUixVswgFD5hCY3"45// Export private key (for Phantom import)6const key = buff.exportKey()7// Uint8Array(64)89// Get lifetime stats10const stats = buff.getStats()11// { totalRoundUps: 142, totalInvestedUsd: 48.20, ... }1213// Preview fees without wrapping14const preview = await buff.previewFees(27.63)15// { roundUpUsd: 0.37, userInvestmentUsd: 0.3672, ... }Note
Portfolio values are fetched in real-time from the Solana blockchain with live USD prices from CoinGecko. Prices are cached for 30 seconds.