The Omni Account uses the aggregated balance of the user’s funds across all supported chains, taking into account any outstanding intents.

To get the aggregated portfolio of tokens:

const portfolio = rhinestoneAccount.getPortfolio()

To get the aggregated portfolio of testnet tokens:

const onTestnets = true
const portfolio = rhinestoneAccount.getPortfolio(onTestnets)

This will return the list of spendable tokens (i.e., not part of any pending transaction).

Max Spendable Amount

Often, you want to let the user spend the maximum possible amount of tokens for a transaction (e.g. deposit all available USDC into a savings vault).

While the getPortfolio util provides the total spendable balance, it doesn’t consider the execution fee, as it is chain-specific and depends on the transaction gas cost.

To get an estimate of the maximum amount of tokens you can spend on a given transaction, use getMaxSpendableAmount. In this case, we get the maximum spendable USDC amount on Base Sepolia:

const usdcAddress = getTokenAddress('USDC', baseSepolia.id)
const gasUnits = 200_000n

const tokenAmount = rhinestoneAccount.getMaxSpendableAmount(baseSepolia.id, usdcAddress, gasUnits)