Skip to main content

resumeAgent

Resumes the agent's automated operations by automatically restoring the protocol list. The SDK fetches all available protocols and filters them based on the user's current chains and strategy.

Signature

resumeAgent(): Promise<UpdateUserProfileResponse>

Returns

A Promise that resolves to an UpdateUserProfileResponse containing the updated user configuration.

Return Type

interface UpdateUserProfileResponse {
success: boolean;
userId: string;
smartWallet?: Address;
chains?: number[];
strategy?: string;
protocols?: string[];
autoSelectProtocols?: boolean;
omniAccount?: boolean;
autocompounding?: boolean;
agentName?: string;
crosschainStrategy?: boolean;
executorProxy?: boolean;
splitting?: boolean;
minSplits?: number;
customization?: Record<string, any>;
}

Example

await sdk.connectAccount(privateKey, chainId);

// Resume the agent
// This automatically identifies and registers protocols matching the user's strategy
const result = await sdk.resumeAgent();

if (result.success) {
console.log("Agent resumed successfully");

// Verify active protocols
const userDetails = await sdk.getUserDetails();
console.log("Active protocols:", userDetails.protocols);
}

How it Works

The resumeAgent method performs the following logic internally:

  1. Fetches User Profile: Retrieves the user's current chains and strategy (e.g., conservative).
  2. Discovery: Fetches the complete list of supported protocols from the Zyfai infrastructure.
  3. Filtering: Matches protocols that:
    • Operate on at least one of the user's active chains.
    • Support the user's selected strategy.
  4. Registration: Updates the user profile with the discovered protocolIds, re-enabling automated yield optimization.

Notes

  • Requires SIWE authentication (via connectAccount()).
  • This is the inverse of pauseAgent().
  • If no protocols match the current strategy/chain combination, the protocol list will remain empty.
  • To manually specify protocols, use updateUserProfile() instead.