Fund operations
deposit
Deposits funds into an agent. By default, funds will be distributed across agents to diversify both risks and returns.
- If
agentIdis omitted: deposits the funds across agents. - If
agentIdis provided: deposits into the specified agent. - Only agents that support the active chain and asset are used when
agentIdis omitted.
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",
depositCallback: async (smartWalletAddress, chainId, amount) => {
// Transfer token to the provided smart wallet and return tx hash.
return transferToSmartWallet(smartWalletAddress, chainId, asset, amount);
},
});
{
"agentResults": {
"zyfai": {
"txHash": "0x...",
"smartWallet": "0x...",
"amount": "50000000",
},
"sail": {
"txHash": "0x...",
"smartWallet": "0x...",
"amount": "50000000",
}
}
}
Parameters
params: DepositOptions— Deposit parameters (SeeDepositOptionsfor details):amount: string— Deposit amount in the token’s smallest unit (e.g. "100000000" for 100 USDC with 6 decimals).asset: Asset— The asset to deposit (SeeAssetfor details).depositCallback: DepositCallback— Callback that performs the token transfer and returns a tx hash (SeeDepositCallbackfor details). IfagentIdis omitted, this callback is called once per eligible agent split.agentId?: AgentId— Optional agent ID (SeeAgentIdfor details). If omitted, distributes equally across all eligible agents.
Returns
Promise<OwneyMultiDepositResult>ifagentIdis omitted. ContainsagentResultskeyed by agent ID.Promise<OwneyDepositResult>ifagentIdis provided.
See OwneyDepositResult and OwneyMultiDepositResult for details.
withdraw
Withdraws funds from an agent.
- 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",
},
"sail": {
"txHash": "0x...",
"type": "full",
"amount": "50000000",
}
}
}
Parameters
params: WithdrawOptions— Withdraw parameters (SeeWithdrawOptionsfor details):
Returns
Promise<OwneyWithdrawResult>ifagentIdis omitted. ContainsagentResultkeyed by agent ID.Promise<AgentWithdrawResult>ifagentIdis provided.
See OwneyWithdrawResult and AgentWithdrawResult for details.