@owney/sdk 0.7.25-beta.10 → 0.7.25-beta.12

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.ts CHANGED
@@ -70,7 +70,283 @@ type OwneySupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
70
70
  type OwneySupportedChains = (typeof SUPPORTED_CHAINS)[number];
71
71
  type OwneySupportedTokens = (typeof SUPPORTED_TOKENS)[number];
72
72
 
73
+ /**
74
+ * One protocol's pool selection on one chain. `pools` holds Zyfai pool NAMES
75
+ * verbatim — matched case-sensitively by customizeBatch, and an unrecognised
76
+ * name makes Zyfai's rebalance engine skip the whole protocol, so these strings
77
+ * must not be normalised anywhere.
78
+ *
79
+ * An empty array means "no usable pools on this chain".
80
+ */
81
+ type OrgPoolSelection = {
82
+ protocolId: string;
83
+ chainId: number;
84
+ pools: string[];
85
+ };
86
+ /**
87
+ * The partner's protocol/pool policy (ROUT-224). Sparse — only protocols they
88
+ * narrowed appear. Optional so an older routing API, which does not return the
89
+ * field, still parses; undefined and null both mean "change nothing".
90
+ */
91
+ type OrgPoolPolicy = {
92
+ autoApproveProtocols: boolean;
93
+ autoApprovePools: boolean;
94
+ selections: OrgPoolSelection[];
95
+ };
96
+ /**
97
+ * The organization's agent execution policy, or null when the partner has never
98
+ * configured one — in which case the agents leave the user's profile alone.
99
+ */
100
+ type OrgAgentConfig = {
101
+ splittingMode: "none" | "automatic" | "force";
102
+ minSplits: number | null;
103
+ poolPolicy?: OrgPoolPolicy | null;
104
+ };
105
+
106
+ type DepositCallback = (smartWalletAddress: string, chainId: number, amount: string) => Promise<`0x${string}`> | `0x${string}`;
107
+ interface IAgent {
108
+ readonly id: string;
109
+ readonly supportedChainIds: readonly OwneySupportedChainId[];
110
+ readonly supportedAssets: readonly AgentSupportedAssets[];
111
+ /**
112
+ * Describes how `AgentBalance.tokens` relates to `positions`.
113
+ * Most adapters expose token totals that already include deployed positions.
114
+ * Providers such as Yieldseeker expose idle wallet tokens separately, so
115
+ * withdrawal planning must add matching position amounts.
116
+ */
117
+ readonly balanceComposition?: "tokens-include-positions" | "tokens-plus-positions";
118
+ /**
119
+ * Whether a withdrawal requires an owner-approved wallet transaction.
120
+ * Aggregate withdrawals run these agents before relayer-only agents so a
121
+ * rejected wallet request cannot happen after another leg has committed.
122
+ */
123
+ readonly withdrawalRequiresWalletApproval?: boolean;
124
+ disconnect(): Promise<void>;
125
+ activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
126
+ /**
127
+ * Apply the organization's agent policy to this user's account.
128
+ *
129
+ * Optional: an agent that has no equivalent knob simply omits it, which is why
130
+ * this is not part of `activateAgent`'s signature. Declared on the interface
131
+ * rather than only on ZyfaiAgent so the contract stays agent-neutral — the
132
+ * ticket asks for a design that can also cover Surf, which has no adapter yet.
133
+ *
134
+ * Implementations must be **non-fatal**: this runs during activation as a side
135
+ * effect, so a failure has to leave the user connected and their profile
136
+ * unchanged rather than break the connect.
137
+ */
138
+ applyOrgPolicy?(state: ConnectionState, chainId: number, policy: OrgAgentConfig): Promise<void>;
139
+ deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback, onProgress?: FundingProgress): Promise<OwneyDepositResult>;
140
+ withdraw(state: ConnectionState, chainId: number, token: OwneySupportedTokens, amount?: string, onProgress?: FundingProgress): Promise<AgentWithdrawResult>;
141
+ /** Invalidate only the confirmed asset. This hook must not sign or submit transactions. */
142
+ invalidateFundingRead?(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, refreshUntil?: number): void;
143
+ /** End accelerated balance reads only for the exact snapshot the caller displayed. */
144
+ endFundingBalanceRefresh?(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, read: AssetReadMetadata): boolean;
145
+ getFundingHistory?(state: ConnectionState, chainId: number, options?: HistoryFilters): Promise<OwneyAgentHistory>;
146
+ getFundingWallet?(state: ConnectionState, chainId: number, asset: OwneySupportedTokens): Promise<string>;
147
+ getBalances(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<AgentBalance>;
148
+ getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
149
+ /**
150
+ * Refresh the agent's earnings snapshot when its backend supports doing so.
151
+ * Implementations own freshness and request-deduplication policy.
152
+ */
153
+ refreshEarnings?(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
154
+ getAccountApy(state: ConnectionState, chainId: number, days: DailyApyDays,
155
+ /**
156
+ * Optional asset symbol ("USDC" / "WETH") scoping the daily series to a
157
+ * single asset on the chain. Agents without per-asset positions ignore it.
158
+ */
159
+ tokenSymbol?: string): Promise<AccountAgentApy>;
160
+ /**
161
+ * Daily cumulative NET earnings for the window, scoped to a chain/asset.
162
+ * Backs the "recent earnings" subline, whose figure must reconcile with the
163
+ * balance headline directly above it. (ROUT-452)
164
+ */
165
+ getDailyEarnings?(state: ConnectionState, chainId: number, days: LookbackDays, tokenSymbol?: string): Promise<AccountDailyEarnings>;
166
+ getHistory(state: ConnectionState, chainId: number, options?: HistoryFilters): Promise<OwneyAgentHistory>;
167
+ getUserProfile(state: ConnectionState, chainId: number): Promise<AgentUserProfile>;
168
+ /**
169
+ * Ensure the given asset uses backend protocol auto-selection
170
+ * (`autoSelectProtocols: true`). Optional capability — only agents whose
171
+ * backend models per-asset protocol selection implement it. Returns whether
172
+ * a write occurred (`false` = already enabled / not supported).
173
+ */
174
+ ensureAutoSelectProtocols?(state: ConnectionState, chainId: number, asset: "USDC" | "WETH"): Promise<boolean>;
175
+ getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
176
+ }
177
+ /**
178
+ * Optional filters for per-agent APY lookups.
179
+ * - `tokenSymbol` / `chainId` scope the APY to a specific asset+chain when
180
+ * the underlying provider supports it (Zyfai). Agents whose backends do
181
+ * not yet support per-asset APY will ignore these options.
182
+ */
183
+ type AgentApyOptions = {
184
+ tokenSymbol?: string;
185
+ chainId?: number;
186
+ };
187
+
188
+ type AgentId = "zyfai" | "yieldseeker";
189
+ type Asset = string;
190
+ type AgentSupportedAsset = {
191
+ readonly symbol: string;
192
+ readonly minDepositAmount: string;
193
+ };
194
+ type AgentSupportedAssets = {
195
+ readonly chainId: number;
196
+ readonly chain?: string;
197
+ readonly assets: readonly AgentSupportedAsset[];
198
+ };
199
+ type AvailableAgent = {
200
+ id: AgentId;
201
+ isEnabled: boolean;
202
+ supportedChainIds: readonly number[];
203
+ supportedAssets: readonly AgentSupportedAssets[];
204
+ };
205
+ type AvailableAgentsOptions = {
206
+ chainId?: number;
207
+ asset?: Asset;
208
+ /** Disabled agents are omitted by default because they cannot accept funds. */
209
+ includeDisabled?: boolean;
210
+ };
211
+ /**
212
+ * A lookback window for any "last N days" read — the APY series, the daily
213
+ * earnings series. Named for the window itself, so nothing borrows the APY's
214
+ * name to ask for something else.
215
+ */
216
+ type LookbackDays = "7D" | "14D" | "30D";
217
+ /** Kept so existing callers keep compiling. Prefer `LookbackDays`. */
218
+ type DailyApyDays = LookbackDays;
219
+ type HistoryFilters = {
220
+ fromDate?: string;
221
+ toDate?: string;
222
+ /** Max entries returned per call. Defaults to 10. */
223
+ limit?: number;
224
+ /** Opaque cursor returned by a previous getHistory call. */
225
+ cursor?: string;
226
+ /**
227
+ * Optional asset symbol (e.g. "USDC", "WETH") to scope the history to a
228
+ * single asset. Without it the page blends every asset on the chain, so a
229
+ * consumer showing one asset at a time has to filter client-side — and a
230
+ * page whose entries all belong to the *other* asset then renders empty
231
+ * even though matching entries exist further back. Agents whose backends
232
+ * cannot filter by asset ignore this and return the whole chain's history.
233
+ */
234
+ tokenSymbol?: string;
235
+ };
236
+ type HistoryOptions = {
237
+ chainId?: number;
238
+ agentId?: AgentId;
239
+ filters?: HistoryFilters;
240
+ };
241
+ type WithdrawOptions = {
242
+ /** Exclude unresolved providers from aggregate withdrawals; direct agent requests are unchanged. */
243
+ excludeAgentIds?: AgentId[];
244
+ onProgress?: FundingProgress;
245
+ asset: Asset;
246
+ amount?: string;
247
+ agentId?: AgentId;
248
+ /** Called after each agent returns; callback failures never change a financial result. */
249
+ onAgentResult?: (agentId: AgentId, result: AgentWithdrawResult) => void;
250
+ };
251
+ type AccountApyOptions = {
252
+ agentId?: AgentId;
253
+ days: LookbackDays;
254
+ /**
255
+ * Optional asset symbol (e.g. "USDC", "WETH") to scope the daily APY series
256
+ * to a specific asset on the active chain. Without it the series blends every
257
+ * position on the chain, so two assets sharing a chain (USDC and WETH on
258
+ * Base/Arbitrum) would render one merged line. Agents whose backends do not
259
+ * expose per-asset positions ignore this. (ROUT-186)
260
+ */
261
+ tokenSymbol?: string;
262
+ };
263
+ /**
264
+ * Options for the daily earnings series. Same shape as `AccountApyOptions` and
265
+ * deliberately its own type: the two reads answer different questions and are
266
+ * free to diverge.
267
+ */
268
+ type DailyEarningsOptions = {
269
+ agentId?: AgentId;
270
+ days: LookbackDays;
271
+ /**
272
+ * Optional asset symbol (e.g. "USDC", "WETH") scoping the series to one
273
+ * asset on the active chain.
274
+ */
275
+ tokenSymbol?: string;
276
+ };
277
+ type AllocationApyOptions = {
278
+ agentId?: AgentId;
279
+ };
280
+ type AgentsApyOptions = {
281
+ agentId?: AgentId;
282
+ days: DailyApyDays;
283
+ /**
284
+ * Optional asset symbol (e.g. "USDC", "WETH") to scope the APY to a
285
+ * specific asset+chain. Ignored by agents whose backends do not yet
286
+ * support per-asset APY.
287
+ */
288
+ tokenSymbol?: string;
289
+ /**
290
+ * Optional chain id for per-asset APY lookups. Typically paired with
291
+ * `tokenSymbol`.
292
+ */
293
+ chainId?: number;
294
+ };
295
+ type DepositOptions = {
296
+ onProgress?: FundingProgress;
297
+ amount: string;
298
+ asset: Asset;
299
+ depositCallback?: DepositCallback;
300
+ agentId?: AgentId;
301
+ onApproved?: () => void;
302
+ };
303
+
304
+ type FundingStage = "pending" | "confirmed" | "unknown" | "failed" | "not-applicable";
305
+ /** Evidence about one provider leg. Amounts are token base units, never USD. */
306
+ interface FundingEvidence {
307
+ agentId: AgentId;
308
+ chainId: number;
309
+ token: OwneySupportedTokens;
310
+ walletAddress: string;
311
+ agentWallet?: string;
312
+ intendedAmount: string;
313
+ confirmedAmount?: string;
314
+ txHash?: string;
315
+ blockNumber?: string;
316
+ logIndexes?: number[];
317
+ transferLogs?: {
318
+ logIndex: number;
319
+ amountRaw: string;
320
+ }[];
321
+ /** Sanitized execution-request evidence. Attempted does not prove server acceptance. */
322
+ withdrawalRequest?: {
323
+ attempted: boolean;
324
+ method?: "GET" | "POST";
325
+ path?: "/users/withdraw" | "/users/partial-withdraw";
326
+ elapsedMs?: number;
327
+ failure?: "network" | "unauthorized" | "forbidden" | "rate-limited" | "other";
328
+ };
329
+ transfer: FundingStage;
330
+ registration: FundingStage;
331
+ delivery: FundingStage;
332
+ }
333
+ type FundingProgress = (evidence: FundingEvidence) => void;
334
+ interface AssetReadMetadata {
335
+ chainId: number;
336
+ asset: string;
337
+ fetchedAt?: number;
338
+ /** When the underlying provider request started; preserved on cached reads. */
339
+ requestedAt?: number;
340
+ /** SDK cache generation, not an onchain block or provider timestamp. */
341
+ readVersion?: number;
342
+ providerUpdatedAt?: string;
343
+ snapshotId?: string;
344
+ blockNumber?: string;
345
+ netDepositsRaw?: string;
346
+ positionsStatus: "available" | "unavailable";
347
+ }
73
348
  interface OwneyDepositResult {
349
+ evidence?: FundingEvidence;
74
350
  txHash: string;
75
351
  smartWallet: string;
76
352
  amount: string;
@@ -79,6 +355,7 @@ interface OwneyMultiDepositResult {
79
355
  agentResults: Record<string, OwneyDepositResult>;
80
356
  }
81
357
  interface AgentWithdrawResult {
358
+ evidence?: FundingEvidence;
82
359
  txHash?: string;
83
360
  type: "full" | "partial";
84
361
  /** Smallest-unit amount, or a provider sentinel such as "all" for a full request. */
@@ -140,6 +417,7 @@ interface OwneyPendingAllocation {
140
417
  since?: string;
141
418
  }
142
419
  interface AgentBalance {
420
+ readMetadata?: AssetReadMetadata[];
143
421
  /** Authoritative native balances per asset/network, including idle and invested funds. */
144
422
  assetBalances?: OwneyToken[];
145
423
  smartWallet?: `0x${string}`;
@@ -233,6 +511,15 @@ interface OwneyAllocationApy {
233
511
  }
234
512
  type HistoryAction = "Rebalance" | "Deposit" | "Top up" | "Withdraw" | "Earned";
235
513
  interface HistoryTransaction {
514
+ tokenAddress?: string;
515
+ agentWallet?: string;
516
+ logIndexes?: number[];
517
+ transferLogs?: {
518
+ logIndex: number;
519
+ amountRaw: string;
520
+ }[];
521
+ amountRaw?: string;
522
+ blockNumber?: string;
236
523
  txHashes: string[];
237
524
  chainId?: number;
238
525
  tokenSymbol?: string;
@@ -261,6 +548,8 @@ interface AgentHistoryPosition {
261
548
  amount?: string;
262
549
  }
263
550
  interface AgentHistoryEntry {
551
+ /** Stable provider/transfer identity, independent of row order. */
552
+ id?: string;
264
553
  agent: AgentId;
265
554
  action: HistoryAction;
266
555
  date: string;
@@ -271,6 +560,8 @@ interface AgentHistoryEntry {
271
560
  positions?: AgentHistoryPosition[];
272
561
  }
273
562
  interface OwneyAgentHistory {
563
+ agentErrors?: Partial<Record<AgentId, string>>;
564
+ agentRetryAt?: Partial<Record<AgentId, number>>;
274
565
  data: AgentHistoryEntry[];
275
566
  /** True iff a subsequent page exists; pair with `nextCursor`. */
276
567
  hasMore: boolean;
@@ -346,226 +637,6 @@ interface AccountDailyEarnings {
346
637
  assets: AssetDailyEarnings[];
347
638
  }
348
639
 
349
- type AgentId = "zyfai" | "yieldseeker";
350
- type Asset = string;
351
- type AgentSupportedAsset = {
352
- readonly symbol: string;
353
- readonly minDepositAmount: string;
354
- };
355
- type AgentSupportedAssets = {
356
- readonly chainId: number;
357
- readonly chain?: string;
358
- readonly assets: readonly AgentSupportedAsset[];
359
- };
360
- type AvailableAgent = {
361
- id: AgentId;
362
- isEnabled: boolean;
363
- supportedChainIds: readonly number[];
364
- supportedAssets: readonly AgentSupportedAssets[];
365
- };
366
- type AvailableAgentsOptions = {
367
- chainId?: number;
368
- asset?: Asset;
369
- /** Disabled agents are omitted by default because they cannot accept funds. */
370
- includeDisabled?: boolean;
371
- };
372
- /**
373
- * A lookback window for any "last N days" read — the APY series, the daily
374
- * earnings series. Named for the window itself, so nothing borrows the APY's
375
- * name to ask for something else.
376
- */
377
- type LookbackDays = "7D" | "14D" | "30D";
378
- /** Kept so existing callers keep compiling. Prefer `LookbackDays`. */
379
- type DailyApyDays = LookbackDays;
380
- type HistoryFilters = {
381
- fromDate?: string;
382
- toDate?: string;
383
- /** Max entries returned per call. Defaults to 10. */
384
- limit?: number;
385
- /** Opaque cursor returned by a previous getHistory call. */
386
- cursor?: string;
387
- /**
388
- * Optional asset symbol (e.g. "USDC", "WETH") to scope the history to a
389
- * single asset. Without it the page blends every asset on the chain, so a
390
- * consumer showing one asset at a time has to filter client-side — and a
391
- * page whose entries all belong to the *other* asset then renders empty
392
- * even though matching entries exist further back. Agents whose backends
393
- * cannot filter by asset ignore this and return the whole chain's history.
394
- */
395
- tokenSymbol?: string;
396
- };
397
- type HistoryOptions = {
398
- agentId?: AgentId;
399
- filters?: HistoryFilters;
400
- };
401
- type WithdrawOptions = {
402
- asset: Asset;
403
- amount?: string;
404
- agentId?: AgentId;
405
- /** Called after each agent returns; callback failures never change a financial result. */
406
- onAgentResult?: (agentId: AgentId, result: AgentWithdrawResult) => void;
407
- };
408
- type AccountApyOptions = {
409
- agentId?: AgentId;
410
- days: LookbackDays;
411
- /**
412
- * Optional asset symbol (e.g. "USDC", "WETH") to scope the daily APY series
413
- * to a specific asset on the active chain. Without it the series blends every
414
- * position on the chain, so two assets sharing a chain (USDC and WETH on
415
- * Base/Arbitrum) would render one merged line. Agents whose backends do not
416
- * expose per-asset positions ignore this. (ROUT-186)
417
- */
418
- tokenSymbol?: string;
419
- };
420
- /**
421
- * Options for the daily earnings series. Same shape as `AccountApyOptions` and
422
- * deliberately its own type: the two reads answer different questions and are
423
- * free to diverge.
424
- */
425
- type DailyEarningsOptions = {
426
- agentId?: AgentId;
427
- days: LookbackDays;
428
- /**
429
- * Optional asset symbol (e.g. "USDC", "WETH") scoping the series to one
430
- * asset on the active chain.
431
- */
432
- tokenSymbol?: string;
433
- };
434
- type AllocationApyOptions = {
435
- agentId?: AgentId;
436
- };
437
- type AgentsApyOptions = {
438
- agentId?: AgentId;
439
- days: DailyApyDays;
440
- /**
441
- * Optional asset symbol (e.g. "USDC", "WETH") to scope the APY to a
442
- * specific asset+chain. Ignored by agents whose backends do not yet
443
- * support per-asset APY.
444
- */
445
- tokenSymbol?: string;
446
- /**
447
- * Optional chain id for per-asset APY lookups. Typically paired with
448
- * `tokenSymbol`.
449
- */
450
- chainId?: number;
451
- };
452
- type DepositOptions = {
453
- amount: string;
454
- asset: Asset;
455
- depositCallback?: DepositCallback;
456
- agentId?: AgentId;
457
- onApproved?: () => void;
458
- };
459
-
460
- /**
461
- * One protocol's pool selection on one chain. `pools` holds Zyfai pool NAMES
462
- * verbatim — matched case-sensitively by customizeBatch, and an unrecognised
463
- * name makes Zyfai's rebalance engine skip the whole protocol, so these strings
464
- * must not be normalised anywhere.
465
- *
466
- * An empty array means "no usable pools on this chain".
467
- */
468
- type OrgPoolSelection = {
469
- protocolId: string;
470
- chainId: number;
471
- pools: string[];
472
- };
473
- /**
474
- * The partner's protocol/pool policy (ROUT-224). Sparse — only protocols they
475
- * narrowed appear. Optional so an older routing API, which does not return the
476
- * field, still parses; undefined and null both mean "change nothing".
477
- */
478
- type OrgPoolPolicy = {
479
- autoApproveProtocols: boolean;
480
- autoApprovePools: boolean;
481
- selections: OrgPoolSelection[];
482
- };
483
- /**
484
- * The organization's agent execution policy, or null when the partner has never
485
- * configured one — in which case the agents leave the user's profile alone.
486
- */
487
- type OrgAgentConfig = {
488
- splittingMode: "none" | "automatic" | "force";
489
- minSplits: number | null;
490
- poolPolicy?: OrgPoolPolicy | null;
491
- };
492
-
493
- type DepositCallback = (smartWalletAddress: string, chainId: number, amount: string) => Promise<`0x${string}`> | `0x${string}`;
494
- interface IAgent {
495
- readonly id: string;
496
- readonly supportedChainIds: readonly OwneySupportedChainId[];
497
- readonly supportedAssets: readonly AgentSupportedAssets[];
498
- /**
499
- * Describes how `AgentBalance.tokens` relates to `positions`.
500
- * Most adapters expose token totals that already include deployed positions.
501
- * Providers such as Yieldseeker expose idle wallet tokens separately, so
502
- * withdrawal planning must add matching position amounts.
503
- */
504
- readonly balanceComposition?: "tokens-include-positions" | "tokens-plus-positions";
505
- /**
506
- * Whether a withdrawal requires an owner-approved wallet transaction.
507
- * Aggregate withdrawals run these agents before relayer-only agents so a
508
- * rejected wallet request cannot happen after another leg has committed.
509
- */
510
- readonly withdrawalRequiresWalletApproval?: boolean;
511
- disconnect(): Promise<void>;
512
- activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
513
- /**
514
- * Apply the organization's agent policy to this user's account.
515
- *
516
- * Optional: an agent that has no equivalent knob simply omits it, which is why
517
- * this is not part of `activateAgent`'s signature. Declared on the interface
518
- * rather than only on ZyfaiAgent so the contract stays agent-neutral — the
519
- * ticket asks for a design that can also cover Surf, which has no adapter yet.
520
- *
521
- * Implementations must be **non-fatal**: this runs during activation as a side
522
- * effect, so a failure has to leave the user connected and their profile
523
- * unchanged rather than break the connect.
524
- */
525
- applyOrgPolicy?(state: ConnectionState, chainId: number, policy: OrgAgentConfig): Promise<void>;
526
- deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
527
- withdraw(state: ConnectionState, chainId: number, token: OwneySupportedTokens, amount?: string): Promise<AgentWithdrawResult>;
528
- getBalances(state: ConnectionState, chainId: number): Promise<AgentBalance>;
529
- getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
530
- /**
531
- * Refresh the agent's earnings snapshot when its backend supports doing so.
532
- * Implementations own freshness and request-deduplication policy.
533
- */
534
- refreshEarnings?(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
535
- getAccountApy(state: ConnectionState, chainId: number, days: DailyApyDays,
536
- /**
537
- * Optional asset symbol ("USDC" / "WETH") scoping the daily series to a
538
- * single asset on the chain. Agents without per-asset positions ignore it.
539
- */
540
- tokenSymbol?: string): Promise<AccountAgentApy>;
541
- /**
542
- * Daily cumulative NET earnings for the window, scoped to a chain/asset.
543
- * Backs the "recent earnings" subline, whose figure must reconcile with the
544
- * balance headline directly above it. (ROUT-452)
545
- */
546
- getDailyEarnings?(state: ConnectionState, chainId: number, days: LookbackDays, tokenSymbol?: string): Promise<AccountDailyEarnings>;
547
- getHistory(state: ConnectionState, chainId: number, options?: HistoryFilters): Promise<OwneyAgentHistory>;
548
- getUserProfile(state: ConnectionState, chainId: number): Promise<AgentUserProfile>;
549
- /**
550
- * Ensure the given asset uses backend protocol auto-selection
551
- * (`autoSelectProtocols: true`). Optional capability — only agents whose
552
- * backend models per-asset protocol selection implement it. Returns whether
553
- * a write occurred (`false` = already enabled / not supported).
554
- */
555
- ensureAutoSelectProtocols?(state: ConnectionState, chainId: number, asset: "USDC" | "WETH"): Promise<boolean>;
556
- getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
557
- }
558
- /**
559
- * Optional filters for per-agent APY lookups.
560
- * - `tokenSymbol` / `chainId` scope the APY to a specific asset+chain when
561
- * the underlying provider supports it (Zyfai). Agents whose backends do
562
- * not yet support per-asset APY will ignore these options.
563
- */
564
- type AgentApyOptions = {
565
- tokenSymbol?: string;
566
- chainId?: number;
567
- };
568
-
569
640
  declare class OwneySDK {
570
641
  private agents;
571
642
  private activeAgents;
@@ -590,6 +661,7 @@ declare class OwneySDK {
590
661
  private paymasterServiceUrl?;
591
662
  private cachedSponsoredCallsCallbacks;
592
663
  private readonly agentReads;
664
+ private readonly recoveredFundingReads;
593
665
  private readonly activationChecks;
594
666
  private readAgent;
595
667
  private initializingAgentsPromise;
@@ -632,6 +704,7 @@ declare class OwneySDK {
632
704
  */
633
705
  private getDefaultWethSponsoredCallback;
634
706
  private getAgent;
707
+ getActiveAgentIds(): AgentId[];
635
708
  private getActiveAgents;
636
709
  /**
637
710
  * Read the org's agent policy once and reuse it. fetchOrgAgentConfig never
@@ -747,6 +820,17 @@ declare class OwneySDK {
747
820
  */
748
821
  private orderAgentsForWithdrawal;
749
822
  private isUserRejectedWithdrawal;
823
+ private captureReadScope;
824
+ /** Revalidate a saved transfer against the authenticated account and actual receipt. */
825
+ inspectFunding(evidence: FundingEvidence, direction: "deposit" | "withdraw", options?: {
826
+ balanceRefreshUntil?: number;
827
+ refreshBalance?: boolean;
828
+ }): Promise<FundingEvidence>;
829
+ /** A display acknowledgement controls polling only; it never confirms a financial outcome. */
830
+ endFundingBalanceRefresh(evidence: FundingEvidence, read: AssetReadMetadata): boolean;
831
+ /** History lookup for receipt recovery; adapters may not authenticate or sign here. */
832
+ getFundingHistory(evidence: FundingEvidence, fromDate: string, options?: Pick<HistoryFilters, "cursor" | "toDate">): Promise<OwneyAgentHistory>;
833
+ recoverDepositRegistration(evidence: FundingEvidence): Promise<FundingEvidence>;
750
834
  /**
751
835
  * Withdraw funds from a specific agent, or all agents that support the active chain+asset if agentId is omitted.
752
836
  * Validates that the asset is supported by the target agent(s) on the active chain.
@@ -757,12 +841,16 @@ declare class OwneySDK {
757
841
  * @returns {AgentWithdrawResult} for a single agent, or {OwneyWithdrawResult} with per-agent results
758
842
  */
759
843
  withdraw(options: WithdrawOptions): Promise<OwneyWithdrawResult | AgentWithdrawResult>;
844
+ private withdrawFromAgents;
760
845
  /**
761
846
  * Get the user's balances for a specific agent, or aggregated across all agents.
762
847
  * @param agentId - Optional. Agent to query. Omit for aggregated balances.
763
848
  * @returns {AgentBalance} for a single agent, or {OwneyBalances} with totalBalance and per-agent breakdown
764
849
  */
765
- getBalances(agentId?: AgentId): Promise<OwneyBalances | AgentBalance>;
850
+ getBalances(agentId?: AgentId, options?: {
851
+ chainId?: number;
852
+ asset?: OwneySupportedTokens;
853
+ }): Promise<OwneyBalances | AgentBalance>;
766
854
  /**
767
855
  * Get the user's on-chain earnings for a specific agent, or aggregated across all agents.
768
856
  * @param agentId - Optional. Agent to query. Omit for aggregated earnings.
@@ -932,9 +1020,13 @@ declare class YieldseekerAgent implements IAgent {
932
1020
  private getReceiptClient;
933
1021
  disconnect(): Promise<void>;
934
1022
  activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
935
- deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
936
- withdraw(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, amount?: string): Promise<AgentWithdrawResult>;
937
- getBalances(state: ConnectionState, chainId: number): Promise<AgentBalance>;
1023
+ deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback, onProgress?: FundingProgress): Promise<OwneyDepositResult>;
1024
+ withdraw(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, amount?: string, onProgress?: FundingProgress): Promise<AgentWithdrawResult>;
1025
+ private withdrawInternal;
1026
+ getBalances(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<AgentBalance>;
1027
+ invalidateFundingRead(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, refreshUntil?: number): void;
1028
+ endFundingBalanceRefresh(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, read: AssetReadMetadata): boolean;
1029
+ getFundingWallet(state: ConnectionState, chainId: number, asset: OwneySupportedTokens): Promise<string>;
938
1030
  getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
939
1031
  getAccountApy(state: ConnectionState, chainId: number, days: DailyApyDays, tokenSymbol?: string): Promise<AccountAgentApy>;
940
1032
  getHistory(state: ConnectionState, chainId: number, options?: HistoryFilters): Promise<OwneyAgentHistory>;
@@ -1050,4 +1142,4 @@ type OwneySIWXConfig = {
1050
1142
  */
1051
1143
  declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
1052
1144
 
1053
- export { type AccountAgentApy, type AccountApyOptions, type AccountDailyEarnings, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentHistoryEntry, type AgentHistoryPosition, type AgentId, AgentNotFoundError, type AgentSupportedAsset, type AgentSupportedAssets, type AgentUserProfile, type AgentWithdrawResult, type AgentsApyOptions, type AllocationAgentApy, type AllocationApyOptions, type ApyByChainAndAsset, type ApyHistoryPoint, type Asset, type AssetDailyEarnings, type AvailableAgent, type AvailableAgentsOptions, type ConnectionState, type DailyApyDays, type DailyEarningsOptions, type DailyEarningsPoint, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, type LookbackDays, NotConnectedError, type OwneyAccountApy, type OwneyAgentApy, type OwneyAgentHistory, type OwneyAllocationApy, type OwneyBalances, type OwneyDepositResult, type OwneyEarnings, OwneyError, type OwneyErrorCode, type OwneyMultiDepositResult, type OwneyPosition, OwneySDK, type OwneySDKConfig, type OwneySIWXConfig, type OwneySupportedChainId, type OwneySupportedChains, type OwneySupportedTokens, type OwneyToken, type OwneyUserProfile, type OwneyWithdrawResult, type RebalanceLog, type RpcUrlsConfig, type WithdrawOptions, YieldseekerAgent, type ZyfaiRpcUrlsConfig, createOwneySIWX, setOwneyDebug };
1145
+ export { type AccountAgentApy, type AccountApyOptions, type AccountDailyEarnings, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentHistoryEntry, type AgentHistoryPosition, type AgentId, AgentNotFoundError, type AgentSupportedAsset, type AgentSupportedAssets, type AgentUserProfile, type AgentWithdrawResult, type AgentsApyOptions, type AllocationAgentApy, type AllocationApyOptions, type ApyByChainAndAsset, type ApyHistoryPoint, type Asset, type AssetDailyEarnings, type AssetReadMetadata, type AvailableAgent, type AvailableAgentsOptions, type ConnectionState, type DailyApyDays, type DailyEarningsOptions, type DailyEarningsPoint, type DepositCallback, type DepositOptions, type FundingEvidence, type FundingProgress, type FundingStage, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, type LookbackDays, NotConnectedError, type OwneyAccountApy, type OwneyAgentApy, type OwneyAgentHistory, type OwneyAllocationApy, type OwneyBalances, type OwneyDepositResult, type OwneyEarnings, OwneyError, type OwneyErrorCode, type OwneyMultiDepositResult, type OwneyPosition, OwneySDK, type OwneySDKConfig, type OwneySIWXConfig, type OwneySupportedChainId, type OwneySupportedChains, type OwneySupportedTokens, type OwneyToken, type OwneyUserProfile, type OwneyWithdrawResult, type RebalanceLog, type RpcUrlsConfig, type WithdrawOptions, YieldseekerAgent, type ZyfaiRpcUrlsConfig, createOwneySIWX, setOwneyDebug };