Skip to main content

Fund operations

deposit

Deposits funds into a specific agent, or splits the amount across all eligible agents.

  • If agentId is omitted: splits the amount equally across all eligible agents for the active chain and asset.
  • If agentId is provided: deposits into the specified agent.

Requires wallet connection: Yes

deposit(
params: DepositOptions
): Promise<OwneyDepositResult | OwneyMultiDepositResult>

Parameters

  • params: DepositOptions - Deposit parameters (See DepositOptions for details):
    • amount: string - Deposit amount in the token's smallest unit (for example "100000000" for 100 USDC with 6 decimals).
    • asset: Asset - The asset to deposit (See Asset for details).
    • agentId?: AgentId - Optional target agent (See AgentId for details).
    • depositCallback?: DepositCallback - Optional. Provide your own function to move funds to the agent smart wallet (See DepositCallback). If omitted, the SDK uses its built-in gasless deposit flow — EIP-3009 for USDC, Permit2 for WETH.
Gasless WETH requires a one-time approval

The first gasless WETH deposit needs a one-time Permit2 approval. The SDK triggers approvePermit2 automatically and retries, but that approval transaction is paid by the user. See Gasless deposits.

Returns

  • Promise<OwneyMultiDepositResult> if agentId is omitted. Contains agentResults keyed by agent ID.
  • Promise<OwneyDepositResult> if agentId is provided.

See OwneyDepositResult and OwneyMultiDepositResult for details.


withdraw

Withdraws funds from an agent.

  • If agentId is omitted: withdraws from all eligible agents on the active chain.
  • If agentId is provided: withdraws from the specified agent.
  • If amount is omitted: withdraws the full balance (from one or all agents, depending on agentId).
  • If amount is provided and agentId is omitted: splits the requested amount proportionally across eligible agents based on their per-asset balances.
  • If an agent withdrawal fails during a proportional split, its share is redistributed to the remaining not-yet-attempted agents where possible.

Requires wallet connection: Yes

withdraw(
params: WithdrawOptions
): Promise<OwneyWithdrawResult | AgentWithdrawResult>

Parameters

  • params: WithdrawOptions - Withdraw parameters (See WithdrawOptions for details):
    • asset: Asset - The asset to withdraw (See Asset for details).
    • amount?: string - Optional amount to withdraw in the token's smallest unit. If omitted, withdraws the full balance.
    • agentId?: AgentId - Optional agent ID (See AgentId for details). If omitted, withdraws from all eligible agents for the active chain and asset.

Returns

  • Promise<OwneyWithdrawResult> if agentId is omitted. Contains agentResult keyed by agent ID plus totalWithdrawn.
  • Promise<AgentWithdrawResult> if agentId is provided.

See OwneyWithdrawResult and AgentWithdrawResult for details.


approvePermit2

Grants the one-time Permit2 approval required for gasless WETH deposits on the active chain. This approves the sponsored WETH token so the SDK's Permit2-based deposit flow can move funds without the user paying gas on each deposit.

  • This is a user-paid transaction (the only gas the user pays in the gasless WETH flow).
  • It is only needed once per chain. The SDK calls it automatically on the first gasless WETH deposit if the approval is missing, then retries the deposit — so most integrations never call it directly. Call it explicitly if you want to front-load the approval in your own setup UX.
  • It waits for one confirmation before resolving.

Requires wallet connection: Yes

approvePermit2(
asset?: "WETH"
): Promise<`0x${string}`>

Parameters

  • asset?: "WETH" - The asset to approve. Defaults to "WETH" (the only sponsored token that requires a Permit2 approval).

Returns

  • A Promise resolving to the approval transaction hash (a 0x-prefixed hex string).

Related error: PERMIT2_APPROVAL_REQUIRED is raised when a gasless WETH deposit needs this approval and it could not be completed automatically.


ensureAutoSelectProtocols

Opts an asset into the agent's backend protocol auto-selection (allocation). Once enabled, the agent automatically distributes deposits of that asset across the best-yielding protocols it supports.

Requires wallet connection: Yes

ensureAutoSelectProtocols(
asset: "USDC" | "WETH",
agentId?: AgentId
): Promise<boolean>

Parameters

  • asset: "USDC" | "WETH" - The asset to enable auto-selection for.
  • agentId?: AgentId - Optional target agent. Defaults to "zyfai" (See AgentId).

Returns

  • Promise<boolean> - true if auto-selection is enabled; false if the agent does not support it for the given asset.