Fund operations
deposit
Deposits funds into a specific agent, or splits the amount across all eligible agents.
To pay with another wallet asset or deposit across chains, use swapAndDeposit.
To let the user choose pools, save their pool selection before starting the deposit.
- If
agentIdis omitted: splits the amount equally across all eligible agents for the active chain and asset. - If
agentIdis provided: deposits into the specified agent.
Requires wallet connection: Yes
- Signature
- Example
- Example Output
deposit(
params: DepositOptions
): Promise<OwneyDepositResult | OwneyMultiDepositResult>
// Deposit 100 USDC split across all eligible agents on Base.
const depositResults = await owney.deposit({
amount: "100000000", // 100 USDC with 6 decimals
asset: "USDC",
});
{
"agentResults": {
"zyfai": {
"txHash": "0x...",
"smartWallet": "0x...",
"amount": "100000000"
}
}
}
Parameters
params: DepositOptions- Deposit parameters (SeeDepositOptionsfor 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 (SeeAssetfor details).agentId?: AgentId- Optional target agent (SeeAgentIdfor details).depositCallback?: DepositCallback- Optional. Provide your own function to move funds to the agent smart wallet (SeeDepositCallback). If omitted, the SDK uses its built-in gasless deposit flow — EIP-3009 for USDC, Permit2 for WETH.
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>ifagentIdis omitted. ContainsagentResultskeyed by agent ID.Promise<OwneyDepositResult>ifagentIdis provided.
See OwneyDepositResult and OwneyMultiDepositResult for details.
Minimum balances
Agents require a minimum asset balance when opening a new position. Ethereum has higher asset-specific minimums because agent operations on Ethereum are more expensive.
- On Base and Arbitrum, the minimum balance is the equivalent of $10 in the deposited asset.
- On Ethereum Mainnet, the minimum balance is the equivalent of $10,000 in the deposited asset.
Once the user has a qualifying balance, smaller top-ups may be allowed.
If a deposit does not meet the required minimum balance, deposit() throws DEPOSIT_AMOUNT_BELOW_MINIMUM.
withdraw
Withdraws funds from an agent.
To receive another asset or receive funds on another chain, use withdrawAndSwap.
- If
agentIdis omitted: withdraws from all eligible agents on the active chain. - If
agentIdis provided: withdraws from the specified agent. - If
amountis omitted: withdraws the full balance (from one or all agents, depending onagentId). - If
amountis provided andagentIdis 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
- Signature
- Example
- Example Output
withdraw(
params: WithdrawOptions
): Promise<OwneyWithdrawResult | AgentWithdrawResult>
// Withdraw full USDC balance across all eligible agents.
const withdrawAll = await owney.withdraw({
asset: "USDC",
});
{
"agentResult": {
"zyfai": {
"txHash": "0x...",
"type": "full",
"amount": "50000000"
}
},
"totalWithdrawn": "50000000"
}
Parameters
params: WithdrawOptions- Withdraw parameters (SeeWithdrawOptionsfor details):asset: Asset- The asset to withdraw (SeeAssetfor details).amount?: string- Optional amount to withdraw in the token's smallest unit. If omitted, withdraws the full balance.agentId?: AgentId- Optional agent ID (SeeAgentIdfor details). If omitted, withdraws from all eligible agents for the active chain and asset.
Returns
Promise<OwneyWithdrawResult>ifagentIdis omitted. ContainsagentResultkeyed by agent ID plustotalWithdrawn.Promise<AgentWithdrawResult>ifagentIdis 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
- Signature
- Example
approvePermit2(
asset?: "WETH"
): Promise<`0x${string}`>
// Pre-approve Permit2 for WETH on the active chain.
const txHash = await owney.approvePermit2("WETH");
Parameters
asset?: "WETH"- The asset to approve. Defaults to"WETH"(the only sponsored token that requires a Permit2 approval).
Returns
- A
Promiseresolving to the approval transaction hash (a0x-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.
For explicit user choices, use Pool customization instead.
Requires wallet connection: Yes
- Signature
- Example
ensureAutoSelectProtocols(
asset: "USDC" | "WETH",
agentId?: AgentId
): Promise<boolean>
// Enable protocol auto-selection for WETH on the default agent (zyfai).
const enabled = await owney.ensureAutoSelectProtocols("WETH");
Parameters
asset: "USDC" | "WETH"- The asset to enable auto-selection for.agentId?: AgentId- Optional target agent. Defaults to"zyfai"(SeeAgentId).
Returns
Promise<boolean>-trueif auto-selection is enabled;falseif the agent does not support it for the given asset.