Skip to main content

Method Signature

agent.getPortfolio(params: GetPortfolioParams): Promise<AgentInfo>

Description

Retrieves comprehensive information about an agent including current status, deposits, withdrawals, and protocol configuration.

Parameters

wallet
Address
required
Smart account wallet address.
is_origin_wallet
boolean
default:"false"
Set to true if the wallet parameter is an origin wallet address instead of a smart account address.

Return Value

wallet
Address
Smart account wallet address.
status
AgentStatus
Current agent status. One of:
  • active - Agent is actively optimizing
  • deactivated - Agent has been stopped
  • deactivating - Agent is in the process of deactivating
  • activating - Agent is in the process of activating
  • activation_failed - Agent failed to activate
  • deactivated_fee_not_paid - Agent deactivated due to unpaid fees
deposits
Deposit[]
List of deposits made to the agent.
withdraws
Withdraw[]
List of withdrawals (optional).
activation_date
string
When the agent was activated.
selected_protocols
string[]
Protocols the agent is configured to use.
current_protocols
string[]
Protocols currently being used (optional).
current_token
string
Token currently being managed (optional).
eoa
Address
Origin wallet address (optional).

Example

import { GizaAgent, Chain } from '@giza/agent-sdk';

const giza = new GizaAgent({ chainId: Chain.BASE });

// Get portfolio by smart account address
const portfolio = await giza.agent.getPortfolio({
  wallet: smartAccountAddress,
});

console.log('Status:', portfolio.status);
console.log('Activation Date:', portfolio.activation_date);
console.log('Selected Protocols:', portfolio.selected_protocols);

// Calculate total deposits
const totalDeposits = portfolio.deposits.reduce(
  (sum, deposit) => sum + deposit.amount,
  0
);
console.log('Total Deposits:', totalDeposits);

// Get portfolio by origin wallet
const portfolioByOrigin = await giza.agent.getPortfolio({
  wallet: userWallet,
  is_origin_wallet: true,
});

Output

{
  wallet: '0xabc123...',
  status: 'active',
  deposits: [
    {
      amount: 1000000000, // 1000 USDC
      token_type: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
      date: '2024-01-15T12:00:00Z',
      tx_hash: '0x...'
    }
  ],
  withdraws: [],
  activation_date: '2024-01-15T12:00:00Z',
  selected_protocols: ['aave', 'compound', 'moonwell'],
  current_protocols: ['aave'],
  current_token: 'USDC',
  eoa: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e'
}

Error Handling

import { ValidationError, GizaAPIError } from '@giza/agent-sdk';

try {
  const portfolio = await giza.agent.getPortfolio({
    wallet: smartAccountAddress,
  });
} catch (error) {
  if (error instanceof ValidationError) {
    console.error('Invalid parameters:', error.message);
  } else if (error instanceof GizaAPIError) {
    console.error('Failed to get portfolio:', error.message);
  }
}

Next Steps