Skip to main content

getPortfolio

Get a detailed and accurate portfolio view for a user, including positions, balances by asset type, and session key status. This method provides more accurate data than getPositions, use it to display portfolio value in your UI.

Signature

getPortfolio(userAddress: string): Promise<PortfolioDetailedResponse>

Parameters

ParameterTypeRequiredDescription
userAddressstringUser's EOA address

Returns

Detailed portfolio data including positions and balances by asset type

Return Type

interface PortfolioDetailedResponse {
success: boolean;
userAddress: string;
portfolio: PortfolioDetailed;
}

interface PortfolioDetailed {
hasBalance?: boolean;
staleBalances?: string[];
hasActiveSessionKey?: boolean;
positions?: PositionSlot[];
portfolioByAssetType?: Record<string, {
balance: string;
decimals: number;
}>;
}

interface PositionSlot {
chain?: string;
protocol_id?: string;
protocol_name?: string;
protocol_icon?: string;
pool?: string;
token_id?: string;
token_symbol?: string;
token_icon?: string;
amount?: string;
underlyingAmount?: string;
pool_apy?: number;
pool_tvl?: number;
}

Example

const response = await sdk.getPortfolio("0xUser...");
const portfolio = response.portfolio;

// Check session key status
console.log("Has active session key:", portfolio.hasActiveSessionKey);

// View balances by asset type (USDC, WETH, etc.)
if (portfolio.portfolioByAssetType) {
Object.entries(portfolio.portfolioByAssetType).forEach(([asset, data]) => {
console.log(`${asset}: ${data.balance} (${data.decimals} decimals)`);
});
}

// List active yield-earning positions
portfolio.positions?.forEach(p => {
console.log(`${p.protocol_name} (${p.chain}): ${p.underlyingAmount} ${p.token_symbol} @ ${p.pool_apy}% APY`);
});

Notes

  • This method automatically resolves the smart wallet address from the EOA
  • If no smart wallet exists for the user, returns an empty portfolio
  • portfolioByAssetType provides balances grouped by token (e.g., USDC, WETH)
  • For legacy position data, see getPositions