@owney/sdk 0.6.4 → 0.6.5-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -14,13 +14,71 @@ interface ConnectionState {
14
14
  walletAddress: `0x${string}`;
15
15
  chainId: number | null;
16
16
  }
17
- declare const SUPPORTED_TOKENS: readonly ["USDC", "USDT"];
17
+ declare const SUPPORTED_TOKENS: readonly ["USDC", "USDT", "WETH"];
18
18
  declare const SUPPORTED_CHAIN_IDS: readonly [8453, 42161];
19
19
  declare const SUPPORTED_CHAINS: readonly ["BASE", "ARBITRUM"];
20
20
  type OwneySupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
21
21
  type OwneySupportedChains = (typeof SUPPORTED_CHAINS)[number];
22
22
  type OwneySupportedTokens = (typeof SUPPORTED_TOKENS)[number];
23
23
 
24
+ type AgentId = "zyfai" | "sail";
25
+ type Asset = string;
26
+ type AgentSupportedAsset = {
27
+ readonly symbol: string;
28
+ readonly minDepositAmount: string;
29
+ };
30
+ type AgentSupportedAssets = {
31
+ readonly chainId: number;
32
+ readonly chain?: string;
33
+ readonly assets: readonly AgentSupportedAsset[];
34
+ };
35
+ type DailyApyDays = "7D" | "14D" | "30D";
36
+ type HistoryFilters = {
37
+ fromDate?: string;
38
+ toDate?: string;
39
+ /** Max entries returned per call. Defaults to 10. */
40
+ limit?: number;
41
+ /** Opaque cursor returned by a previous getHistory call. */
42
+ cursor?: string;
43
+ };
44
+ type HistoryOptions = {
45
+ agentId?: AgentId;
46
+ filters?: HistoryFilters;
47
+ };
48
+ type WithdrawOptions = {
49
+ asset: Asset;
50
+ amount?: string;
51
+ agentId?: AgentId;
52
+ };
53
+ type AccountApyOptions = {
54
+ agentId?: AgentId;
55
+ days: DailyApyDays;
56
+ };
57
+ type AllocationApyOptions = {
58
+ agentId?: AgentId;
59
+ };
60
+ type AgentsApyOptions = {
61
+ agentId?: AgentId;
62
+ days: DailyApyDays;
63
+ /**
64
+ * Optional asset symbol (e.g. "USDC", "WETH") to scope the APY to a
65
+ * specific asset+chain. Ignored by agents whose backends do not yet
66
+ * support per-asset APY.
67
+ */
68
+ tokenSymbol?: string;
69
+ /**
70
+ * Optional chain id for per-asset APY lookups. Typically paired with
71
+ * `tokenSymbol`.
72
+ */
73
+ chainId?: number;
74
+ };
75
+ type DepositOptions = {
76
+ amount: string;
77
+ asset: Asset;
78
+ depositCallback?: DepositCallback;
79
+ agentId?: AgentId;
80
+ };
81
+
24
82
  interface OwneyDepositResult {
25
83
  txHash: string;
26
84
  smartWallet: string;
@@ -195,13 +253,20 @@ interface IAgent {
195
253
  readonly supportedAssets: readonly AgentSupportedAssets[];
196
254
  disconnect(): Promise<void>;
197
255
  activateAgent(state: ConnectionState, chainId: number): Promise<void>;
198
- deposit(state: ConnectionState, chainId: number, amount: string, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
256
+ deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
199
257
  withdraw(state: ConnectionState, chainId: number, token: OwneySupportedTokens, amount?: string): Promise<AgentWithdrawResult>;
200
258
  getBalances(state: ConnectionState, chainId: number): Promise<AgentBalance>;
201
259
  getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
202
260
  getAccountApy(state: ConnectionState, chainId: number, days: DailyApyDays): Promise<AccountAgentApy>;
203
261
  getHistory(state: ConnectionState, chainId: number, options?: HistoryFilters): Promise<OwneyAgentHistory>;
204
262
  getUserProfile(state: ConnectionState, chainId: number): Promise<AgentUserProfile>;
263
+ /**
264
+ * Ensure the given asset uses backend protocol auto-selection
265
+ * (`autoSelectProtocols: true`). Optional capability — only agents whose
266
+ * backend models per-asset protocol selection implement it. Returns whether
267
+ * a write occurred (`false` = already enabled / not supported).
268
+ */
269
+ ensureAutoSelectProtocols?(state: ConnectionState, chainId: number, asset: "USDC" | "WETH"): Promise<boolean>;
205
270
  getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
206
271
  }
207
272
  /**
@@ -215,64 +280,6 @@ type AgentApyOptions = {
215
280
  chainId?: number;
216
281
  };
217
282
 
218
- type AgentId = "zyfai" | "sail";
219
- type Asset = string;
220
- type AgentSupportedAsset = {
221
- readonly symbol: string;
222
- readonly minDepositAmount: string;
223
- };
224
- type AgentSupportedAssets = {
225
- readonly chainId: number;
226
- readonly chain?: string;
227
- readonly assets: readonly AgentSupportedAsset[];
228
- };
229
- type DailyApyDays = "7D" | "14D" | "30D";
230
- type HistoryFilters = {
231
- fromDate?: string;
232
- toDate?: string;
233
- /** Max entries returned per call. Defaults to 10. */
234
- limit?: number;
235
- /** Opaque cursor returned by a previous getHistory call. */
236
- cursor?: string;
237
- };
238
- type HistoryOptions = {
239
- agentId?: AgentId;
240
- filters?: HistoryFilters;
241
- };
242
- type WithdrawOptions = {
243
- asset: Asset;
244
- amount?: string;
245
- agentId?: AgentId;
246
- };
247
- type AccountApyOptions = {
248
- agentId?: AgentId;
249
- days: DailyApyDays;
250
- };
251
- type AllocationApyOptions = {
252
- agentId?: AgentId;
253
- };
254
- type AgentsApyOptions = {
255
- agentId?: AgentId;
256
- days: DailyApyDays;
257
- /**
258
- * Optional asset symbol (e.g. "USDC", "WETH") to scope the APY to a
259
- * specific asset+chain. Ignored by agents whose backends do not yet
260
- * support per-asset APY.
261
- */
262
- tokenSymbol?: string;
263
- /**
264
- * Optional chain id for per-asset APY lookups. Typically paired with
265
- * `tokenSymbol`.
266
- */
267
- chainId?: number;
268
- };
269
- type DepositOptions = {
270
- amount: string;
271
- asset: Asset;
272
- depositCallback?: DepositCallback;
273
- agentId?: AgentId;
274
- };
275
-
276
283
  declare class OwneySDK {
277
284
  private agents;
278
285
  private activeAgents;
@@ -286,6 +293,7 @@ declare class OwneySDK {
286
293
  private apiKey;
287
294
  private zyfaiRpcUrls?;
288
295
  private cachedSponsoredCallback;
296
+ private cachedWethSponsoredCallback;
289
297
  private initializingAgentsPromise;
290
298
  constructor(config: OwneySDKConfig);
291
299
  /**
@@ -320,6 +328,13 @@ declare class OwneySDK {
320
328
  * `TransferWithAuthorization`, then POSTs to the sponsor API.
321
329
  */
322
330
  private getDefaultSponsoredCallback;
331
+ /**
332
+ * Lazily builds (and caches) the default Permit2 sponsored WETH deposit
333
+ * callback used when the caller omits `depositCallback` for a WETH
334
+ * deposit. Mirrors `getDefaultSponsoredCallback()` but signs a Permit2
335
+ * `PermitTransferFrom` instead of an EIP-3009 authorization.
336
+ */
337
+ private getDefaultWethSponsoredCallback;
323
338
  private getAgent;
324
339
  private getActiveAgents;
325
340
  private ensureAgentsInitialized;
@@ -348,6 +363,32 @@ declare class OwneySDK {
348
363
  * @returns {OwneyDepositResult} for a single agent, or {OwneyMultiDepositResult} with per-agent results
349
364
  */
350
365
  deposit(options: DepositOptions): Promise<OwneyDepositResult | OwneyMultiDepositResult>;
366
+ /**
367
+ * Invokes `agent.deposit` with the resolved sponsored callback, composing
368
+ * two independent auto-recovery mechanisms:
369
+ *
370
+ * 1. Missing Permit2 allowance: when the app did not supply its own
371
+ * callback and the attempt fails with `PERMIT2_APPROVAL_REQUIRED` on a
372
+ * WETH deposit, this is the wallet's first gasless WETH deposit. We send
373
+ * the one-time (user-paid) Permit2 approval via `approvePermit2()` and
374
+ * retry the SAME sponsored attempt once. Bounded to one approval attempt
375
+ * per call so a wallet/agent that keeps reporting the allowance as
376
+ * missing can't loop forever. If `approvePermit2()` itself throws (e.g.
377
+ * the user rejects the wallet prompt), that error propagates as-is —
378
+ * the user said no to a transaction, so we must not turn around and ask
379
+ * them to pay for a different one via the fallback below.
380
+ * 2. `shouldFallbackToUserPaid`: the SDK's own WETH sponsor path failed at
381
+ * the infrastructure layer in a provably safe-to-retry way, so we warn
382
+ * and retry once with `undefined`, falling through to a user-paid
383
+ * native deposit. This still applies after a successful Permit2
384
+ * approval retry (the retried sponsored attempt can itself hit a safe
385
+ * sponsor failure).
386
+ *
387
+ * Any other error — an app-supplied callback's own failure in particular —
388
+ * propagates unchanged. Scoped per agent invocation so one agent's failure
389
+ * doesn't force a retry of sibling agents in a multi-agent split.
390
+ */
391
+ private depositWithFallback;
351
392
  private getMinDepositAmount;
352
393
  private splitDepositAmount;
353
394
  private validateMinDepositAmount;
@@ -415,6 +456,23 @@ declare class OwneySDK {
415
456
  * @returns {AgentUserProfile} for a single agent, or {OwneyUserProfile} with per-agent profiles
416
457
  */
417
458
  getUserProfile(agentId?: AgentId): Promise<OwneyUserProfile | AgentUserProfile>;
459
+ /**
460
+ * Ensure the given asset uses backend protocol auto-selection for the active
461
+ * chain's account. No-op (returns false) for agents that don't support it.
462
+ * @param asset - "USDC" or "WETH".
463
+ * @param agentId - Agent to target. Defaults to "zyfai".
464
+ * @returns whether a profile write occurred.
465
+ */
466
+ ensureAutoSelectProtocols(asset: "USDC" | "WETH", agentId?: AgentId): Promise<boolean>;
467
+ /**
468
+ * One-time, user-paid approval of Permit2 on the sponsored WETH token for
469
+ * the active chain. Required once per wallet per chain before gasless WETH
470
+ * deposits; afterwards deposit() is signature-only. Resolves only after the
471
+ * approval transaction is mined (1 confirmation), so a subsequent deposit()
472
+ * will see the new allowance; throws if the transaction reverted.
473
+ * @returns the approval transaction hash.
474
+ */
475
+ approvePermit2(asset?: "WETH"): Promise<`0x${string}`>;
418
476
  /**
419
477
  * Get the agent's average APY performance over a time period. Does not require a wallet connection.
420
478
  * @param options - Contains agentId (optional) and days ("7D", "14D", or "30D")
@@ -438,7 +496,7 @@ declare class OwneySDK {
438
496
  getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
439
497
  }
440
498
 
441
- type OwneyErrorCode = "NOT_CONNECTED" | "NO_ACTIVE_CHAIN" | "WALLET_NO_ACCOUNTS" | "WALLET_ADDRESS_REQUIRED" | "AGENT_NOT_FOUND" | "AGENT_CHAIN_INCOMPATIBLE" | "AGENT_EMPTY_LIST" | "AGENT_DISABLED" | "CHAIN_UNSUPPORTED" | "CHAIN_NO_COMPATIBLE_AGENTS" | "ASSET_UNSUPPORTED" | "ASSET_NO_COMPATIBLE_AGENTS" | "DEPOSIT_AMOUNT_BELOW_MINIMUM" | "DEPOSIT_CALLBACK_REQUIRED" | "DEPOSIT_CALLBACK_INVALID" | "DEPOSIT_NO_PERMITTED_TOKENS" | "WITHDRAW_NO_PERMITTED_TOKENS" | "WITHDRAW_INSUFFICIENT_BALANCE" | "WITHDRAW_ALL_FAILED" | "WITHDRAW_PARTIAL_FAILURE" | "WITHDRAW_FAILED" | "API_ROUTING_ERROR" | "API_ROUTING_FAILED" | "API_SAIL_ERROR" | "API_SAIL_TIMEOUT" | "API_NO_AGENTS" | "SPONSOR_REQUEST_FAILED" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
499
+ type OwneyErrorCode = "NOT_CONNECTED" | "NO_ACTIVE_CHAIN" | "WALLET_NO_ACCOUNTS" | "WALLET_ADDRESS_REQUIRED" | "AGENT_NOT_FOUND" | "AGENT_CHAIN_INCOMPATIBLE" | "AGENT_EMPTY_LIST" | "AGENT_DISABLED" | "CHAIN_UNSUPPORTED" | "CHAIN_NO_COMPATIBLE_AGENTS" | "ASSET_UNSUPPORTED" | "ASSET_NO_COMPATIBLE_AGENTS" | "DEPOSIT_AMOUNT_BELOW_MINIMUM" | "DEPOSIT_CALLBACK_REQUIRED" | "DEPOSIT_CALLBACK_INVALID" | "DEPOSIT_NO_PERMITTED_TOKENS" | "WITHDRAW_NO_PERMITTED_TOKENS" | "WITHDRAW_INSUFFICIENT_BALANCE" | "WITHDRAW_ALL_FAILED" | "WITHDRAW_PARTIAL_FAILURE" | "WITHDRAW_FAILED" | "API_ROUTING_ERROR" | "API_ROUTING_FAILED" | "API_SAIL_ERROR" | "API_SAIL_TIMEOUT" | "API_NO_AGENTS" | "SPONSOR_REQUEST_FAILED" | "PERMIT2_APPROVAL_REQUIRED" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
442
500
  declare class OwneyError extends Error {
443
501
  readonly code: OwneyErrorCode;
444
502
  readonly details?: Record<string, unknown>;
package/dist/index.d.ts CHANGED
@@ -14,13 +14,71 @@ interface ConnectionState {
14
14
  walletAddress: `0x${string}`;
15
15
  chainId: number | null;
16
16
  }
17
- declare const SUPPORTED_TOKENS: readonly ["USDC", "USDT"];
17
+ declare const SUPPORTED_TOKENS: readonly ["USDC", "USDT", "WETH"];
18
18
  declare const SUPPORTED_CHAIN_IDS: readonly [8453, 42161];
19
19
  declare const SUPPORTED_CHAINS: readonly ["BASE", "ARBITRUM"];
20
20
  type OwneySupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
21
21
  type OwneySupportedChains = (typeof SUPPORTED_CHAINS)[number];
22
22
  type OwneySupportedTokens = (typeof SUPPORTED_TOKENS)[number];
23
23
 
24
+ type AgentId = "zyfai" | "sail";
25
+ type Asset = string;
26
+ type AgentSupportedAsset = {
27
+ readonly symbol: string;
28
+ readonly minDepositAmount: string;
29
+ };
30
+ type AgentSupportedAssets = {
31
+ readonly chainId: number;
32
+ readonly chain?: string;
33
+ readonly assets: readonly AgentSupportedAsset[];
34
+ };
35
+ type DailyApyDays = "7D" | "14D" | "30D";
36
+ type HistoryFilters = {
37
+ fromDate?: string;
38
+ toDate?: string;
39
+ /** Max entries returned per call. Defaults to 10. */
40
+ limit?: number;
41
+ /** Opaque cursor returned by a previous getHistory call. */
42
+ cursor?: string;
43
+ };
44
+ type HistoryOptions = {
45
+ agentId?: AgentId;
46
+ filters?: HistoryFilters;
47
+ };
48
+ type WithdrawOptions = {
49
+ asset: Asset;
50
+ amount?: string;
51
+ agentId?: AgentId;
52
+ };
53
+ type AccountApyOptions = {
54
+ agentId?: AgentId;
55
+ days: DailyApyDays;
56
+ };
57
+ type AllocationApyOptions = {
58
+ agentId?: AgentId;
59
+ };
60
+ type AgentsApyOptions = {
61
+ agentId?: AgentId;
62
+ days: DailyApyDays;
63
+ /**
64
+ * Optional asset symbol (e.g. "USDC", "WETH") to scope the APY to a
65
+ * specific asset+chain. Ignored by agents whose backends do not yet
66
+ * support per-asset APY.
67
+ */
68
+ tokenSymbol?: string;
69
+ /**
70
+ * Optional chain id for per-asset APY lookups. Typically paired with
71
+ * `tokenSymbol`.
72
+ */
73
+ chainId?: number;
74
+ };
75
+ type DepositOptions = {
76
+ amount: string;
77
+ asset: Asset;
78
+ depositCallback?: DepositCallback;
79
+ agentId?: AgentId;
80
+ };
81
+
24
82
  interface OwneyDepositResult {
25
83
  txHash: string;
26
84
  smartWallet: string;
@@ -195,13 +253,20 @@ interface IAgent {
195
253
  readonly supportedAssets: readonly AgentSupportedAssets[];
196
254
  disconnect(): Promise<void>;
197
255
  activateAgent(state: ConnectionState, chainId: number): Promise<void>;
198
- deposit(state: ConnectionState, chainId: number, amount: string, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
256
+ deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
199
257
  withdraw(state: ConnectionState, chainId: number, token: OwneySupportedTokens, amount?: string): Promise<AgentWithdrawResult>;
200
258
  getBalances(state: ConnectionState, chainId: number): Promise<AgentBalance>;
201
259
  getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
202
260
  getAccountApy(state: ConnectionState, chainId: number, days: DailyApyDays): Promise<AccountAgentApy>;
203
261
  getHistory(state: ConnectionState, chainId: number, options?: HistoryFilters): Promise<OwneyAgentHistory>;
204
262
  getUserProfile(state: ConnectionState, chainId: number): Promise<AgentUserProfile>;
263
+ /**
264
+ * Ensure the given asset uses backend protocol auto-selection
265
+ * (`autoSelectProtocols: true`). Optional capability — only agents whose
266
+ * backend models per-asset protocol selection implement it. Returns whether
267
+ * a write occurred (`false` = already enabled / not supported).
268
+ */
269
+ ensureAutoSelectProtocols?(state: ConnectionState, chainId: number, asset: "USDC" | "WETH"): Promise<boolean>;
205
270
  getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
206
271
  }
207
272
  /**
@@ -215,64 +280,6 @@ type AgentApyOptions = {
215
280
  chainId?: number;
216
281
  };
217
282
 
218
- type AgentId = "zyfai" | "sail";
219
- type Asset = string;
220
- type AgentSupportedAsset = {
221
- readonly symbol: string;
222
- readonly minDepositAmount: string;
223
- };
224
- type AgentSupportedAssets = {
225
- readonly chainId: number;
226
- readonly chain?: string;
227
- readonly assets: readonly AgentSupportedAsset[];
228
- };
229
- type DailyApyDays = "7D" | "14D" | "30D";
230
- type HistoryFilters = {
231
- fromDate?: string;
232
- toDate?: string;
233
- /** Max entries returned per call. Defaults to 10. */
234
- limit?: number;
235
- /** Opaque cursor returned by a previous getHistory call. */
236
- cursor?: string;
237
- };
238
- type HistoryOptions = {
239
- agentId?: AgentId;
240
- filters?: HistoryFilters;
241
- };
242
- type WithdrawOptions = {
243
- asset: Asset;
244
- amount?: string;
245
- agentId?: AgentId;
246
- };
247
- type AccountApyOptions = {
248
- agentId?: AgentId;
249
- days: DailyApyDays;
250
- };
251
- type AllocationApyOptions = {
252
- agentId?: AgentId;
253
- };
254
- type AgentsApyOptions = {
255
- agentId?: AgentId;
256
- days: DailyApyDays;
257
- /**
258
- * Optional asset symbol (e.g. "USDC", "WETH") to scope the APY to a
259
- * specific asset+chain. Ignored by agents whose backends do not yet
260
- * support per-asset APY.
261
- */
262
- tokenSymbol?: string;
263
- /**
264
- * Optional chain id for per-asset APY lookups. Typically paired with
265
- * `tokenSymbol`.
266
- */
267
- chainId?: number;
268
- };
269
- type DepositOptions = {
270
- amount: string;
271
- asset: Asset;
272
- depositCallback?: DepositCallback;
273
- agentId?: AgentId;
274
- };
275
-
276
283
  declare class OwneySDK {
277
284
  private agents;
278
285
  private activeAgents;
@@ -286,6 +293,7 @@ declare class OwneySDK {
286
293
  private apiKey;
287
294
  private zyfaiRpcUrls?;
288
295
  private cachedSponsoredCallback;
296
+ private cachedWethSponsoredCallback;
289
297
  private initializingAgentsPromise;
290
298
  constructor(config: OwneySDKConfig);
291
299
  /**
@@ -320,6 +328,13 @@ declare class OwneySDK {
320
328
  * `TransferWithAuthorization`, then POSTs to the sponsor API.
321
329
  */
322
330
  private getDefaultSponsoredCallback;
331
+ /**
332
+ * Lazily builds (and caches) the default Permit2 sponsored WETH deposit
333
+ * callback used when the caller omits `depositCallback` for a WETH
334
+ * deposit. Mirrors `getDefaultSponsoredCallback()` but signs a Permit2
335
+ * `PermitTransferFrom` instead of an EIP-3009 authorization.
336
+ */
337
+ private getDefaultWethSponsoredCallback;
323
338
  private getAgent;
324
339
  private getActiveAgents;
325
340
  private ensureAgentsInitialized;
@@ -348,6 +363,32 @@ declare class OwneySDK {
348
363
  * @returns {OwneyDepositResult} for a single agent, or {OwneyMultiDepositResult} with per-agent results
349
364
  */
350
365
  deposit(options: DepositOptions): Promise<OwneyDepositResult | OwneyMultiDepositResult>;
366
+ /**
367
+ * Invokes `agent.deposit` with the resolved sponsored callback, composing
368
+ * two independent auto-recovery mechanisms:
369
+ *
370
+ * 1. Missing Permit2 allowance: when the app did not supply its own
371
+ * callback and the attempt fails with `PERMIT2_APPROVAL_REQUIRED` on a
372
+ * WETH deposit, this is the wallet's first gasless WETH deposit. We send
373
+ * the one-time (user-paid) Permit2 approval via `approvePermit2()` and
374
+ * retry the SAME sponsored attempt once. Bounded to one approval attempt
375
+ * per call so a wallet/agent that keeps reporting the allowance as
376
+ * missing can't loop forever. If `approvePermit2()` itself throws (e.g.
377
+ * the user rejects the wallet prompt), that error propagates as-is —
378
+ * the user said no to a transaction, so we must not turn around and ask
379
+ * them to pay for a different one via the fallback below.
380
+ * 2. `shouldFallbackToUserPaid`: the SDK's own WETH sponsor path failed at
381
+ * the infrastructure layer in a provably safe-to-retry way, so we warn
382
+ * and retry once with `undefined`, falling through to a user-paid
383
+ * native deposit. This still applies after a successful Permit2
384
+ * approval retry (the retried sponsored attempt can itself hit a safe
385
+ * sponsor failure).
386
+ *
387
+ * Any other error — an app-supplied callback's own failure in particular —
388
+ * propagates unchanged. Scoped per agent invocation so one agent's failure
389
+ * doesn't force a retry of sibling agents in a multi-agent split.
390
+ */
391
+ private depositWithFallback;
351
392
  private getMinDepositAmount;
352
393
  private splitDepositAmount;
353
394
  private validateMinDepositAmount;
@@ -415,6 +456,23 @@ declare class OwneySDK {
415
456
  * @returns {AgentUserProfile} for a single agent, or {OwneyUserProfile} with per-agent profiles
416
457
  */
417
458
  getUserProfile(agentId?: AgentId): Promise<OwneyUserProfile | AgentUserProfile>;
459
+ /**
460
+ * Ensure the given asset uses backend protocol auto-selection for the active
461
+ * chain's account. No-op (returns false) for agents that don't support it.
462
+ * @param asset - "USDC" or "WETH".
463
+ * @param agentId - Agent to target. Defaults to "zyfai".
464
+ * @returns whether a profile write occurred.
465
+ */
466
+ ensureAutoSelectProtocols(asset: "USDC" | "WETH", agentId?: AgentId): Promise<boolean>;
467
+ /**
468
+ * One-time, user-paid approval of Permit2 on the sponsored WETH token for
469
+ * the active chain. Required once per wallet per chain before gasless WETH
470
+ * deposits; afterwards deposit() is signature-only. Resolves only after the
471
+ * approval transaction is mined (1 confirmation), so a subsequent deposit()
472
+ * will see the new allowance; throws if the transaction reverted.
473
+ * @returns the approval transaction hash.
474
+ */
475
+ approvePermit2(asset?: "WETH"): Promise<`0x${string}`>;
418
476
  /**
419
477
  * Get the agent's average APY performance over a time period. Does not require a wallet connection.
420
478
  * @param options - Contains agentId (optional) and days ("7D", "14D", or "30D")
@@ -438,7 +496,7 @@ declare class OwneySDK {
438
496
  getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
439
497
  }
440
498
 
441
- type OwneyErrorCode = "NOT_CONNECTED" | "NO_ACTIVE_CHAIN" | "WALLET_NO_ACCOUNTS" | "WALLET_ADDRESS_REQUIRED" | "AGENT_NOT_FOUND" | "AGENT_CHAIN_INCOMPATIBLE" | "AGENT_EMPTY_LIST" | "AGENT_DISABLED" | "CHAIN_UNSUPPORTED" | "CHAIN_NO_COMPATIBLE_AGENTS" | "ASSET_UNSUPPORTED" | "ASSET_NO_COMPATIBLE_AGENTS" | "DEPOSIT_AMOUNT_BELOW_MINIMUM" | "DEPOSIT_CALLBACK_REQUIRED" | "DEPOSIT_CALLBACK_INVALID" | "DEPOSIT_NO_PERMITTED_TOKENS" | "WITHDRAW_NO_PERMITTED_TOKENS" | "WITHDRAW_INSUFFICIENT_BALANCE" | "WITHDRAW_ALL_FAILED" | "WITHDRAW_PARTIAL_FAILURE" | "WITHDRAW_FAILED" | "API_ROUTING_ERROR" | "API_ROUTING_FAILED" | "API_SAIL_ERROR" | "API_SAIL_TIMEOUT" | "API_NO_AGENTS" | "SPONSOR_REQUEST_FAILED" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
499
+ type OwneyErrorCode = "NOT_CONNECTED" | "NO_ACTIVE_CHAIN" | "WALLET_NO_ACCOUNTS" | "WALLET_ADDRESS_REQUIRED" | "AGENT_NOT_FOUND" | "AGENT_CHAIN_INCOMPATIBLE" | "AGENT_EMPTY_LIST" | "AGENT_DISABLED" | "CHAIN_UNSUPPORTED" | "CHAIN_NO_COMPATIBLE_AGENTS" | "ASSET_UNSUPPORTED" | "ASSET_NO_COMPATIBLE_AGENTS" | "DEPOSIT_AMOUNT_BELOW_MINIMUM" | "DEPOSIT_CALLBACK_REQUIRED" | "DEPOSIT_CALLBACK_INVALID" | "DEPOSIT_NO_PERMITTED_TOKENS" | "WITHDRAW_NO_PERMITTED_TOKENS" | "WITHDRAW_INSUFFICIENT_BALANCE" | "WITHDRAW_ALL_FAILED" | "WITHDRAW_PARTIAL_FAILURE" | "WITHDRAW_FAILED" | "API_ROUTING_ERROR" | "API_ROUTING_FAILED" | "API_SAIL_ERROR" | "API_SAIL_TIMEOUT" | "API_NO_AGENTS" | "SPONSOR_REQUEST_FAILED" | "PERMIT2_APPROVAL_REQUIRED" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
442
500
  declare class OwneyError extends Error {
443
501
  readonly code: OwneyErrorCode;
444
502
  readonly details?: Record<string, unknown>;