Skip to main content

Method Signature

agent.updateProtocols(wallet: Address, protocols: string[]): Promise<void>

Description

Updates the list of protocols that an agent can use for yield optimization. This allows you to add or remove protocols after the agent has been activated.

Parameters

wallet
Address
required
Smart account wallet address.
protocols
string[]
required
Array of protocol names to use. Must include at least one protocol.Example: ["aave", "compound", "moonwell"]

Return Value

Returns Promise<void> - resolves when the protocols are successfully updated.

Example

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

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

// Update protocols for an active agent
await giza.agent.updateProtocols(
  smartAccountAddress,
  ['aave', 'compound', 'morpho']
);

console.log('Protocols updated successfully');

Error Handling

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

try {
  await giza.agent.updateProtocols(
    smartAccountAddress,
    ['aave', 'compound']
  );
} catch (error) {
  if (error instanceof ValidationError) {
    console.error('Invalid parameters:', error.message);
  } else if (error instanceof GizaAPIError) {
    console.error('Failed to update protocols:', error.message);
  }
}

Common Errors

ErrorCauseSolution
ValidationError: wallet address is requiredMissing wallet parameterProvide a valid wallet address
ValidationError: At least one protocol must be providedEmpty protocols arrayProvide at least one protocol
ValidationError: wallet address must be a valid Ethereum addressInvalid address formatEnsure address starts with 0x and has 40 hex characters

Next Steps