@owney/sdk 0.7.32-beta.5 → 0.7.33

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
@@ -1,5 +1,3 @@
1
- import * as viem from 'viem';
2
- import { Hex, Address } from 'viem';
3
1
  import { SIWXConfig } from '@reown/appkit-controllers';
4
2
 
5
3
  /**
@@ -222,9 +220,7 @@ type SwapOrderStatus = "pending" | "executed" | "expired" | "cancelled" | "refun
222
220
  * of the flow and the one place a user would otherwise think nothing is
223
221
  * happening.
224
222
  */
225
- type SwapStage = "withdrawing" | "withdrawn"
226
- /** Withdrawal incomplete or unconfirmed; no swap was submitted. */
227
- | "withdrawal-incomplete" | "swap-unknown" | "swap-partial" | "swap-not-started" | "quoting" | "wrapping" | "wrapped" | "approving" | "building" | "signing" | "swapping" | "swapped" | "depositing" | "refunding" | "refunded";
223
+ type SwapStage = "withdrawing" | "withdrawn" | "quoting" | "wrapping" | "wrapped" | "approving" | "building" | "signing" | "swapping" | "swapped" | "depositing" | "refunding" | "refunded";
228
224
  /**
229
225
  * Which way the funds travel, which decides what each side may be.
230
226
  *
@@ -250,95 +246,19 @@ type SwapQuoteParams = {
250
246
  direction?: SwapDirection;
251
247
  };
252
248
 
253
- type FundingOperationKind = "deposit" | "withdraw" | "swap_deposit" | "withdraw_swap";
254
- /** One leg of a ledger operation, as the API returns it. */
255
- type FundingOperationLeg = {
256
- /** e.g. `agent:zyfai`, `swap`, `approval`. */
257
- legKey: string;
258
- agentType: string | null;
259
- /** created | submitted | unknown | failed | confirmed */
260
- status: string;
261
- /** uint256 decimal string. */
262
- confirmedAmountRaw: string | null;
263
- /** bigint decimal string. */
264
- blockNumber: string | null;
265
- txHash: string | null;
266
- /** ISO. Kept as stored: a confirmed -> failed leg keeps its value, so key off `status`. */
267
- confirmedAt: string | null;
268
- /** Lowercase agent wallet the leg moved funds to or from; null when unknown. */
269
- agentWallet: string | null;
270
- /** ISO. First time the provider's proxied history listed this leg's tx hash (Yieldseeker). Never cleared. */
271
- providerIndexedAt: string | null;
272
- /**
273
- * ISO. When a proxied provider snapshot first showed this leg in net deposits
274
- * (Yieldseeker). Never cleared. Null means "not booked or undecidable", never
275
- * "definitely not booked".
276
- */
277
- providerBookedAt: string | null;
278
- /** The provider's own id for this leg (e.g. a withdrawal or deposit id), as stored; null when none. */
279
- providerRef: string | null;
280
- /**
281
- * The server stopped checking this in-flight leg (no outcome was proven).
282
- * Present only when true; a new fact reported for the leg reopens it.
283
- */
284
- closed?: true;
285
- };
286
- /** One ledger operation, as the API returns it. */
287
- type FundingOperationRow = {
288
- /** First 8 hex chars of the client operation id, lowercase. */
289
- reference: string;
290
- /** Present only for operations whose id the caller passed in `ids`. */
291
- clientOperationId?: string;
292
- kind: FundingOperationKind;
293
- /** created | submitted | unknown | failed | confirmed | partial */
294
- status: string;
295
- /** ISO. */
296
- createdAt: string;
297
- /** ISO. */
298
- settledAt: string | null;
299
- stuck: boolean;
300
- legs: FundingOperationLeg[];
301
- };
302
- /** The newest server-side provider snapshot sample at or before a time. */
303
- type ProviderSnapshotSample = {
304
- /** Signed decimal strings in the asset's base units, or null. */
305
- netDepositsRaw: string | null;
306
- cumulativeYieldRaw: string | null;
307
- totalValueRaw: string | null;
308
- /** ISO or null. */
309
- providerUpdatedAt: string | null;
310
- /** ISO. */
311
- observedAt: string;
312
- };
313
-
314
- type RpcUrlsConfig = Partial<Record<(typeof SUPPORTED_CHAIN_IDS)[number], string>>;
315
- /** @deprecated Use RpcUrlsConfig. */
316
- type ZyfaiRpcUrlsConfig = RpcUrlsConfig;
249
+ type ZyfaiRpcUrlsConfig = Partial<Record<(typeof SUPPORTED_CHAIN_IDS)[number], string>>;
317
250
  interface OwneySDKConfig {
318
251
  apiKey: string;
319
- /**
320
- * Optional per-chain RPC overrides used for application-owned reads and
321
- * transaction receipt polling. Missing chains use the Owney routing API's
322
- * read-only RPC proxy. No upstream RPC credentials are included in the SDK.
323
- * Wallet providers remain responsible for account access, chain switching,
324
- * signatures, and transaction submission.
325
- */
326
- rpcUrls?: RpcUrlsConfig;
327
252
  /**
328
253
  * Optional per-chain RPC overrides for Zyfai SDK network calls.
329
254
  * Example: { 8453: "https://...", 42161: "https://..." }
330
- * @deprecated Use rpcUrls so every agent shares the same read transport.
331
255
  */
332
256
  zyfaiRpcUrls?: ZyfaiRpcUrlsConfig;
333
- /** Optional Owney Yieldseeker proxy base URL override for integration tests. */
334
- yieldseekerApiBaseUrl?: string;
335
- /** Optional SIWE origin override. Defaults to the requesting browser origin. */
336
- yieldseekerSiweOrigin?: string;
337
257
  /**
338
258
  * Optional override for the Owney routing API base URL used by all routing
339
- * calls. RPC proxy requests use OWNEY_ROUTING_API_BASE_URL when this is
340
- * omitted; without either value, all rpcUrls must be configured.
341
- * Set this to a local/staging routing API when testing sponsor changes.
259
+ * calls (defaults to the OWNEY_ROUTING_API_BASE_URL env var, then the
260
+ * production URL). Set this to point at a local/staging routing API,
261
+ * e.g. "http://localhost:3000", when testing sponsor changes.
342
262
  */
343
263
  routingApiBaseUrl?: string;
344
264
  /**
@@ -347,13 +267,6 @@ interface OwneySDKConfig {
347
267
  * for apps that don't use the AppKit SIWX modal.
348
268
  */
349
269
  referralSource?: string;
350
- /**
351
- * Mini-app identifier (`web`, `base`, `ellipal` …) recorded on funding ledger
352
- * operations. Not `referralSource`, which is a Zyfai attribution tag. The
353
- * ledger records `unknown` when this is omitted. Lowercased before sending;
354
- * a value that is not 1-32 of `a-z 0-9 _ -` after that is left out.
355
- */
356
- appName?: string;
357
270
  /**
358
271
  * Turn on the SDK's debug logging (default false). Traces the decisions that
359
272
  * are otherwise invisible — notably how the organization's agent policy is
@@ -383,56 +296,11 @@ interface OwneySDKConfig {
383
296
  * unresolvable. Omit it and every rail behaves exactly as before.
384
297
  */
385
298
  paymasterServiceUrl?: string;
386
- /**
387
- * Cross-device withdrawal reservation (default `"fail-open"`). `withdraw()`
388
- * claims a hold on the owner's funds before any provider call; a hold held by
389
- * another device or app rejects with `WITHDRAW_IN_PROGRESS` /
390
- * `details.reason === "RESERVED_ELSEWHERE"`.
391
- * - `"fail-open"`: when the reservation API cannot answer (network error,
392
- * timeout, 5xx, 404, 429, ...) the withdrawal proceeds as before.
393
- * - `"fail-closed"`: it rejects with `WITHDRAW_RESERVATION_UNAVAILABLE`
394
- * before anything is submitted.
395
- * - `"off"`: never calls the reservation API.
396
- * `OWNEY_WITHDRAWAL_RESERVATION_DISABLED=1` in the environment acts as `"off"`.
397
- */
398
- withdrawalReservation?: "fail-open" | "fail-closed" | "off";
399
- /**
400
- * Hand Zyfai withdrawals and deposit registrations, with the user's Zyfai
401
- * session, to the Owney routing API, which then sends them itself (default
402
- * off). Only `true`, or a function that returns `true`, opts in.
403
- *
404
- * A function is called for each operation, at the moment it would first
405
- * hand a withdrawal or a registration off, so an app can turn the handoff on
406
- * or off in open tabs without a reload. A function that throws counts as
407
- * off.
408
- *
409
- * Off, the SDK hands no new operation off, never sends the Zyfai session to
410
- * Owney for it, and behaves as before. Turning it off never makes the
411
- * browser send what the server may already hold: an operation this SDK
412
- * instance already handed off keeps going through the server (its nudges,
413
- * re-runs, retries and registration recovery). Recovery of a deposit handed
414
- * off by an earlier page waits until it is on again.
415
- */
416
- zyfaiServerTasks?: boolean | (() => boolean);
417
- /**
418
- * Hand each signed cross-chain (Fusion+) order's secrets to the Owney
419
- * routing API, which publishes them once 1inch is ready, so the swap
420
- * completes even if the tab closes (default false). Only `true` opts in.
421
- * Off, the secrets never leave the browser and swaps behave as before. On,
422
- * the browser still publishes them too.
423
- */
424
- fusionSecretHandoff?: boolean;
425
299
  }
426
300
  interface ConnectionState {
427
301
  provider: any;
428
302
  walletAddress: `0x${string}`;
429
303
  chainId: number | null;
430
- /**
431
- * Reads under this state use a saved sign-in only: an agent never opens a
432
- * wallet prompt for them and fails instead. Set by the whole-portfolio reads
433
- * of an agent that is not active on the connection chain.
434
- */
435
- promptless?: boolean;
436
304
  }
437
305
  declare const SUPPORTED_TOKENS: readonly ["USDC", "WETH"];
438
306
  declare const SUPPORTED_CHAIN_IDS: readonly [8453, 42161, 1];
@@ -441,377 +309,7 @@ type OwneySupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
441
309
  type OwneySupportedChains = (typeof SUPPORTED_CHAINS)[number];
442
310
  type OwneySupportedTokens = (typeof SUPPORTED_TOKENS)[number];
443
311
 
444
- /** Capability flag: this SDK can hand Zyfai withdrawals and deposit
445
- * registrations to the server, and marks such legs with evidence `serverTask`.
446
- * Older builds do not export this. */
447
- declare const ZYFAI_SERVER_TASKS: 1;
448
- /** A `zyfai_withdrawal` task that failed with one of these codes never sent
449
- * the withdrawal to Zyfai. */
450
- declare const ZYFAI_WITHDRAWAL_NOT_SENT_CODES: ReadonlySet<string>;
451
- /** A `zyfai_deposit_registration` task that failed with one of these codes
452
- * never registered the deposit with Zyfai, so the browser may register it. */
453
- declare const ZYFAI_REGISTRATION_NOT_SENT_CODES: ReadonlySet<string>;
454
- type ZyfaiTaskResult = {
455
- providerWithdrawalId?: string;
456
- providerDepositId?: string;
457
- txHash?: string;
458
- asyncPending?: true;
459
- handedOff?: "reconciler";
460
- lifecycle?: "failed";
461
- };
462
- /**
463
- * - accepted: the server has a task for this leg (its state and code);
464
- * - declined: the server proved no task was created (a 200 decline, or a 400,
465
- * 401, 403, 404, 409 or 429; or `ZYFAI_SERVER_TASKS_OFF_CODE` without the
466
- * opt-in);
467
- * - unknown: anything else. The server may have a task.
468
- */
469
- type ZyfaiHandoffAnswer = {
470
- type: "accepted";
471
- taskId: string;
472
- state: string;
473
- code?: string;
474
- result: ZyfaiTaskResult;
475
- } | {
476
- type: "declined";
477
- code: string;
478
- } | {
479
- type: "unknown";
480
- };
481
-
482
- /**
483
- * One protocol's pool selection on one chain. `pools` holds Zyfai pool NAMES
484
- * verbatim — matched case-sensitively by customizeBatch, and an unrecognised
485
- * name makes Zyfai's rebalance engine skip the whole protocol, so these strings
486
- * must not be normalised anywhere.
487
- *
488
- * An empty array means "no usable pools on this chain".
489
- */
490
- type OrgPoolSelection = {
491
- protocolId: string;
492
- chainId: number;
493
- pools: string[];
494
- };
495
- /**
496
- * The partner's protocol/pool policy (ROUT-224). Sparse — only protocols they
497
- * narrowed appear. Optional so an older routing API, which does not return the
498
- * field, still parses; undefined and null both mean "change nothing".
499
- */
500
- type OrgPoolPolicy = {
501
- autoApproveProtocols: boolean;
502
- autoApprovePools: boolean;
503
- selections: OrgPoolSelection[];
504
- };
505
- /**
506
- * The organization's agent execution policy, or null when the partner has never
507
- * configured one — in which case the agents leave the user's profile alone.
508
- */
509
- type OrgAgentConfig = {
510
- splittingMode: "none" | "automatic" | "force";
511
- minSplits: number | null;
512
- poolPolicy?: OrgPoolPolicy | null;
513
- };
514
-
515
- /**
516
- * Pool policy: Owney's org-level protocol/pool policy -> Zyfai's two mismatched
517
- * write shapes.
518
- *
519
- * Zyfai splits "which protocols and pools may this user's funds sit in" across
520
- * two calls that do not share an axis:
521
- *
522
- * updateUserProfile({ protocols }) per ASSET, chain-agnostic
523
- * customizeBatch([{ protocolId, per (PROTOCOL, CHAIN), asset-agnostic
524
- * chainId, pools, autoselect }])
525
- *
526
- * `protocols` is an explicit ALLOW-LIST: a protocol left out of it is disabled
527
- * for that asset, on every chain, immediately. `customizeBatch` is the opposite
528
- * shape — one record per (protocol, chain) pair, asset-agnostic, and per
529
- * docs.zyf.ai it "creates or updates a record for the (user, protocol, chain)
530
- * combination"; "previous customizations for the same combination are
531
- * overwritten".
532
- *
533
- * That second property is the reason this file exists rather than a single
534
- * flat translation: customizeBatch overwrites only the combinations it is
535
- * GIVEN. The partner's stored policy (`OrgPoolPolicy.selections`) is sparse —
536
- * only the protocols they actually narrowed appear — but the payload we send
537
- * must be EXHAUSTIVE over every (protocol, chain) pair Zyfai offers this user.
538
- * If we only sent the narrowed pairs, a partner who restricts Morpho, saves,
539
- * then later re-ticks every pool box would never be able to undo it: nothing
540
- * in the (sparse) policy would tell us to send a record clearing it, and the
541
- * old restrictive record would stay live on the user's profile forever.
542
- *
543
- * Pure functions, kept out of the agent so the mapping is testable without a
544
- * Zyfai client. See splitting.ts for the same pattern on the other lever.
545
- */
546
-
547
- /** One selectable pool, with the figures the deposit-time Pools step shows. */
548
- type AvailablePool = {
549
- chainId: number;
550
- token: string;
551
- name: string;
552
- /** combined_apy (pool + rewards), already a percent. null when absent. */
553
- apy: number | null;
554
- /** TVL in USD. null when absent. See ZyfCustomizationPoolInfo: `tvl` is in
555
- * the pool's own token, `tvlUsd` is the dollar figure — only the latter is
556
- * safe to show with a currency symbol. */
557
- tvlUsd: number | null;
558
- /** Per-pool deep link (e.g. the Morpho vault page). null when absent. */
559
- link: string | null;
560
- };
561
- /** Public Zyfai strategies used by deposit-time pool customization. */
562
- type PoolSelectionStrategy = "aggressive" | "yieldmaxxing";
563
- /** One asset's explicit choice for a protocol on one chain. */
564
- type UserPoolSelection = {
565
- asset: "USDC" | "WETH";
566
- protocolId: string;
567
- chainId: number;
568
- /** Names enabled by the user for this asset/protocol/chain. */
569
- pools: string[];
570
- /** Every name shown for this asset/protocol/chain in the superset catalog. */
571
- availablePools: string[];
572
- };
573
- /** The complete saved draft for the asset/chain legs selected in the deposit. */
574
- type UserPoolSelectionRequest = {
575
- strategies: Array<{
576
- asset: "USDC" | "WETH";
577
- strategy: PoolSelectionStrategy;
578
- }>;
579
- selections: UserPoolSelection[];
580
- };
581
- /**
582
- * What a user's account currently has saved (ROUT-650): each asset's strategy,
583
- * plus the pool list of every protocol/chain pair frozen by an earlier Save.
584
- * Pairs Zyfai still autoselects are left out, so "no entry" means "default".
585
- */
586
- type SavedPoolSelection = {
587
- strategies: Array<{
588
- asset: "USDC" | "WETH";
589
- strategy: string;
590
- }>;
591
- pairs: Array<{
592
- protocolId: string;
593
- chainId: number;
594
- pools: string[];
595
- }>;
596
- };
597
- /** One protocol with its pools for the deposit asset — what the Pools step
598
- * renders: a protocol row that opens to a list of selectable pools. */
599
- type PoolCatalogProtocol = {
600
- protocolId: string;
601
- name: string;
602
- logo: string | null;
603
- pools: AvailablePool[];
604
- };
605
-
606
- type DepositCallback = (smartWalletAddress: string, chainId: number, amount: string) => Promise<`0x${string}`> | `0x${string}`;
607
- /**
608
- * Read access to the funding ledger, given to agents by the client so they can
609
- * hold earnings while a provider lags (spec B2). Both reads never throw:
610
- * null means "no ledger information", and callers then behave as before.
611
- */
612
- type AgentFundingLedgerAccess = {
613
- /** `sdk.listFundingOperations` for this owner; null when the owner is not the connected one or on failure. */
614
- listOperations(input: {
615
- owner: string;
616
- chainId: number;
617
- asset: string;
618
- since?: Date;
619
- }): Promise<FundingOperationRow[] | null>;
620
- /** The newest server provider-snapshot sample at or before `before`; null when none or on failure. */
621
- providerSnapshot?(input: {
622
- owner: string;
623
- chainId: number;
624
- asset: string;
625
- agentWallet: string;
626
- before: Date;
627
- }): Promise<ProviderSnapshotSample | null>;
628
- };
629
- interface IAgent {
630
- readonly id: string;
631
- readonly supportedChainIds: readonly OwneySupportedChainId[];
632
- readonly supportedAssets: readonly AgentSupportedAssets[];
633
- /**
634
- * Describes how `AgentBalance.tokens` relates to `positions`.
635
- * Most adapters expose token totals that already include deployed positions.
636
- * Providers such as Yieldseeker expose idle wallet tokens separately, so
637
- * withdrawal planning must add matching position amounts.
638
- */
639
- readonly balanceComposition?: "tokens-include-positions" | "tokens-plus-positions";
640
- /**
641
- * Whether a withdrawal requires an owner-approved wallet transaction.
642
- * Aggregate withdrawals run these agents before relayer-only agents so a
643
- * rejected wallet request cannot happen after another leg has committed.
644
- */
645
- readonly withdrawalRequiresWalletApproval?: boolean;
646
- /**
647
- * Settles this agent's own wallet prompts (a login, a session key) so that a
648
- * following `withdraw` needs none. A multi-agent withdrawal calls it before a
649
- * wallet-approval agent's owner signature, so two prompts never overlap and
650
- * this agent can start as soon as that signature was accepted. Never submits
651
- * a withdrawal. A rejected prompt throws; other failures are left to `withdraw`.
652
- */
653
- prepareWithdrawal?(state: ConnectionState, chainId: number, token: OwneySupportedTokens): Promise<void>;
654
- /**
655
- * The adapter can hand its withdrawal to our server (part 4, Zyfai). Only
656
- * such agents get the plan-time handoff and a `planned` withdraw context;
657
- * every other agent keeps today's calls.
658
- */
659
- readonly supportsServerTasks?: true;
660
- /**
661
- * Hands a planned withdrawal leg to our server before an earlier
662
- * wallet-approval leg is signed (`after`: those legs' keys). The server sends
663
- * it once those legs are accepted. Never throws; never withdraws locally.
664
- * `amount` is the leg's planned share, or "MAX". `beforeRequest` runs right
665
- * before the request leaves (never when none is sent), so the caller can
666
- * save the leg's server mark first.
667
- */
668
- handOffPlannedWithdrawal?(state: ConnectionState, chainId: number, token: OwneySupportedTokens, amount: string, ctx: {
669
- operationId: string;
670
- after: string[];
671
- beforeRequest?: () => void;
672
- }): Promise<ZyfaiHandoffAnswer>;
673
- disconnect(): Promise<void>;
674
- activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
675
- /**
676
- * Apply the organization's agent policy to this user's account.
677
- *
678
- * Optional: an agent that has no equivalent knob simply omits it, which is why
679
- * this is not part of `activateAgent`'s signature. Declared on the interface
680
- * rather than only on ZyfaiAgent so the contract stays agent-neutral — the
681
- * ticket asks for a design that can also cover Surf, which has no adapter yet.
682
- *
683
- * Implementations must be **non-fatal**: this runs during activation as a side
684
- * effect, so a failure has to leave the user connected and their profile
685
- * unchanged rather than break the connect.
686
- */
687
- applyOrgPolicy?(state: ConnectionState, chainId: number, policy: OrgAgentConfig): Promise<void>;
688
- /**
689
- * The deposit-time pool catalogue for one asset and strategy: protocols with
690
- * their selectable pools and figures. Optional — an agent with no pool
691
- * customization omits it. (ROUT-569)
692
- */
693
- getPoolCatalog?(params: {
694
- asset: string;
695
- strategy: "conservative" | "aggressive" | "yieldmaxxing";
696
- }): Promise<PoolCatalogProtocol[]>;
697
- /**
698
- * Apply a user's own pool selection to their account, driven by the
699
- * deposit-time Pools step. Optional, and non-fatal like `applyOrgPolicy`.
700
- * (ROUT-569)
701
- */
702
- setPoolSelection?(selection: UserPoolSelectionRequest): Promise<void>;
703
- /**
704
- * Read back what `setPoolSelection` saved, for the pairs and assets given,
705
- * so the Pools step can open on the user's own choices. Optional. (ROUT-650)
706
- */
707
- getPoolSelection?(state: ConnectionState, chainId: number, params: {
708
- pairs: Array<{
709
- protocolId: string;
710
- chainId: number;
711
- }>;
712
- assets: Array<"USDC" | "WETH">;
713
- }): Promise<SavedPoolSelection>;
714
- deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback, onProgress?: FundingProgress, onBeforeSubmission?: (evidence: FundingEvidence) => void | Promise<void>,
715
- /** `operationId`: the funding ledger operation. Zyfai hands the deposit's
716
- * registration to the server with it (only agents with
717
- * `supportsServerTasks` get it; every other agent keeps today's call). */
718
- context?: {
719
- operationId?: string;
720
- }): Promise<OwneyDepositResult>;
721
- withdraw(state: ConnectionState, chainId: number, token: OwneySupportedTokens, amount?: string, onProgress?: FundingProgress, gasMode?: "auto" | "sponsored" | "paid", onBeforeSubmission?: FundingProgress, assertCurrent?: () => void,
722
- /** `operationId`: the funding ledger operation (Yieldseeker opts in to the
723
- * server-owned send of its sponsored userOp with it; Zyfai hands its
724
- * withdrawal to the server with it). `planned`: the leg was handed to the
725
- * server at plan time, so this call nudges that task (only for agents with
726
- * `supportsServerTasks`). */
727
- context?: {
728
- operationId?: string;
729
- planned?: true;
730
- }): Promise<AgentWithdrawResult>;
731
- /** Read-only MAX proof at the owner payout block; never sends another withdrawal. */
732
- verifyWithdrawalCompletion?(state: ConnectionState, evidence: FundingEvidence): Promise<WithdrawalCompletion>;
733
- /** A newly observed pool allocation invalidates this asset's portfolio cache only. */
734
- invalidateAllocationRead?(state: ConnectionState, chainId: number, asset: OwneySupportedTokens): void;
735
- /** Invalidate only the confirmed asset. This hook must not sign or submit transactions. */
736
- invalidateFundingRead?(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, refreshUntil?: number, txHash?: string): void;
737
- /** End accelerated balance reads only for the exact snapshot the caller displayed. */
738
- endFundingBalanceRefresh?(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, read: AssetReadMetadata): boolean;
739
- getFundingHistory?(state: ConnectionState, chainId: number, options?: HistoryFilters): Promise<OwneyAgentHistory>;
740
- getFundingWallet?(state: ConnectionState, chainId: number, asset: OwneySupportedTokens): Promise<string>;
741
- /** Verify the displayed remaining balance after a receipt-confirmed payout.
742
- * Undefined means unknown; never substitute a failed read with zero. */
743
- verifyWithdrawalBalance?(state: ConnectionState, evidence: FundingEvidence, balance: AgentBalance): Promise<AssetReadMetadata | undefined>;
744
- /** Read-only chain proof when indexed withdrawal components are incomplete.
745
- * Returns raw owner-withdrawable units; unavailable proof must throw.
746
- * minimumAmount is the raw liquidity required from this agent for a typed
747
- * plan, so adapters can expand discovery when known positions fall short. */
748
- getWithdrawableBalance?(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, minimumAmount?: bigint): Promise<bigint>;
749
- /** Optional positive proof for a repeat deposit; unknown must fall back to portfolio validation. */
750
- hasExistingDepositFunds?(state: ConnectionState, chainId: number, asset: OwneySupportedTokens): Promise<true | undefined>;
751
- getBalances(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<AgentBalance>;
752
- /**
753
- * Whether this wallet can be read on `chainId` from a saved sign-in, with no
754
- * wallet prompt. Lets the whole-portfolio reads include an agent that does
755
- * not run on the connection chain (Yieldseeker on Base while the wallet is
756
- * on Arbitrum); agents without it are read only while active.
757
- */
758
- hasReadSession?(state: ConnectionState, chainId: number): boolean;
759
- getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
760
- /** Funding-ledger read access for earnings holds. Optional; without it an agent behaves as before. */
761
- setFundingLedgerAccess?(access: AgentFundingLedgerAccess | undefined): void;
762
- /**
763
- * A small, never-prompting read of the provider's earnings bookkeeping for a
764
- * `provider.sample` ledger event (Zyfai). Null when unavailable; never throws.
765
- */
766
- providerEarningsSample?(state: ConnectionState, chainId: number): Promise<Record<string, unknown> | null>;
767
- /**
768
- * Refresh the agent's earnings snapshot when its backend supports doing so.
769
- * Implementations own freshness and request-deduplication policy.
770
- */
771
- refreshEarnings?(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
772
- getAccountApy(state: ConnectionState, chainId: number, days: DailyApyDays,
773
- /**
774
- * Optional asset symbol ("USDC" / "WETH") scoping the daily series to a
775
- * single asset on the chain. Agents without per-asset positions ignore it.
776
- */
777
- tokenSymbol?: string,
778
- /**
779
- * Chain the series is scoped to, when that differs from the chain the
780
- * connection is on. `null` spans every chain the wallet held (ROUT-479);
781
- * omitted means `chainId`. Kept apart from `chainId` because that one
782
- * still resolves the wallet and must stay a real, connected chain.
783
- */
784
- scopeChainId?: number | null): Promise<AccountAgentApy>;
785
- /**
786
- * Daily cumulative earnings in token units, scoped to a chain/asset, using
787
- * the provider's earnings basis. Include an opening snapshot when available
788
- * so the "recent earnings" subline can difference the endpoints. (ROUT-452)
789
- */
790
- getDailyEarnings?(state: ConnectionState, chainId: number, days: LookbackDays, tokenSymbol?: string): Promise<AccountDailyEarnings>;
791
- getHistory(state: ConnectionState, chainId: number, options?: HistoryFilters): Promise<OwneyAgentHistory>;
792
- getUserProfile(state: ConnectionState, chainId: number): Promise<AgentUserProfile>;
793
- /**
794
- * Ensure the given asset uses backend protocol auto-selection
795
- * (`autoSelectProtocols: true`). Optional capability — only agents whose
796
- * backend models per-asset protocol selection implement it. Returns whether
797
- * a write occurred (`false` = already enabled / not supported).
798
- */
799
- ensureAutoSelectProtocols?(state: ConnectionState, chainId: number, asset: "USDC" | "WETH"): Promise<boolean>;
800
- supportsAgentApyPeriod?(days: DailyApyDays): boolean;
801
- getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
802
- }
803
- /**
804
- * Optional filters for per-agent APY lookups.
805
- * - `tokenSymbol` / `chainId` scope the APY to a specific asset+chain when
806
- * the underlying provider supports it (Zyfai). Agents whose backends do
807
- * not yet support per-asset APY will ignore these options.
808
- */
809
- type AgentApyOptions = {
810
- tokenSymbol?: string;
811
- chainId?: number;
812
- };
813
-
814
- type AgentId = "zyfai" | "yieldseeker";
312
+ type AgentId = "zyfai";
815
313
  type Asset = string;
816
314
  type AgentSupportedAsset = {
817
315
  readonly symbol: string;
@@ -828,6 +326,15 @@ type AvailableAgent = {
828
326
  supportedChainIds: readonly number[];
829
327
  supportedAssets: readonly AgentSupportedAssets[];
830
328
  };
329
+ type ActivateAgentOptions = {
330
+ /**
331
+ * Called once the chain and agents are registered, before any agent signs in
332
+ * or runs its setup. From then on reads such as `getBalances` are safe to
333
+ * start: each agent's reads wait on that agent's own sign-in, so they share
334
+ * the activation's one wallet prompt instead of waiting for all of setup.
335
+ */
336
+ onAgentsSelected?: () => void;
337
+ };
831
338
  type AvailableAgentsOptions = {
832
339
  chainId?: number;
833
340
  asset?: Asset;
@@ -860,7 +367,6 @@ type HistoryFilters = {
860
367
  tokenSymbol?: string;
861
368
  };
862
369
  type HistoryOptions = {
863
- chainId?: number;
864
370
  agentId?: AgentId;
865
371
  filters?: HistoryFilters;
866
372
  /**
@@ -874,54 +380,15 @@ type HistoryOptions = {
874
380
  chainIds?: OwneySupportedChainId[];
875
381
  };
876
382
  type WithdrawOptions = {
877
- /** Internal orchestration observation deadline; never retries a send. */
878
- observationDeadline?: number;
879
- assertCurrent?: () => void;
880
- /** Yieldseeker V2 only. "auto" requests sponsorship for a verified V2 wallet. */
881
- gasMode?: "auto" | "sponsored" | "paid";
882
- /** Exclude unresolved providers from aggregate withdrawals; direct agent requests are unchanged. */
883
- excludeAgentIds?: AgentId[];
884
- onProgress?: FundingProgress;
885
- /**
886
- * Durable pre-dispatch checkpoint for adapters with a recoverable operation ID.
887
- * Rejection prevents submission; progress observers remain non-fatal.
888
- */
889
- onBeforeSubmission?: FundingProgress;
890
383
  asset: Asset;
891
384
  amount?: string;
892
385
  agentId?: AgentId;
893
- /** Called after each agent returns; callback failures never change a financial result. */
894
- onAgentResult?: (agentId: AgentId, result: AgentWithdrawResult) => void;
895
- /** Funding ledger reference (a UUID). Defaults to a new random UUID; apps pass
896
- * their own so the app record and the ledger share one reference. It is also
897
- * the withdrawal reservation's operationId. */
898
- operationId?: string;
899
- /**
900
- * Groups this withdrawal with the others started by one user action (a
901
- * "withdraw all" sends one per asset). A UUID, recorded on the funding
902
- * ledger's operation; a value that is not a UUID is ignored.
903
- */
904
- batchId?: string;
905
- /**
906
- * Cross-device withdrawal reservation options.
907
- * - `override`: the `reference` from an overridable `RESERVED_ELSEWHERE`
908
- * error, sent after the user chose "Withdraw anyway".
909
- * - `supersedesOperationId`: an earlier operation of this SDK (for example
910
- * the sponsored attempt a paid retry replaces). Its hold is released when
911
- * this SDK still has that operation's holder token; otherwise ignored.
912
- */
913
- reservation?: WithdrawalReservationOptions;
914
386
  /**
915
387
  * Chain to withdraw from. Defaults to the chain `activateAgent` last set.
916
388
  * See `DepositOptions.chainId` — the same rules apply.
917
389
  */
918
390
  chainId?: number;
919
391
  };
920
- /** `WithdrawOptions.reservation`: see there. */
921
- type WithdrawalReservationOptions = {
922
- override?: string;
923
- supersedesOperationId?: string;
924
- };
925
392
  type AccountApyOptions = {
926
393
  agentId?: AgentId;
927
394
  days: LookbackDays;
@@ -987,33 +454,11 @@ type AgentsApyOptions = {
987
454
  chainId?: number;
988
455
  };
989
456
  type DepositOptions = {
990
- /** Optional synchronous foreground ownership fence for the default Permit2 rail.
991
- * Throw to stop preparation/dispatch and late journal writes after lease/session loss. */
992
- assertSubmissionCurrent?: () => void;
993
- /** Resume only these already signed relayer bytes; never create a new authorization. */
994
- resumeTxHash?: `0x${string}`;
995
- /** Resume only the saved signed batch of a deposit the server may be sending
996
- * (its prepare got no answer, so no transaction hash is known); never create
997
- * a new authorization. Check it first with `canResumePendingDeposit`. */
998
- resumeSavedBatch?: true;
999
- onProgress?: FundingProgress;
1000
- /** Awaited immediately before dispatch. Throwing prevents submission.
1001
- * All legs of an atomic batch are checkpointed together. */
1002
- onBeforeSubmission?: (evidence: FundingEvidence[]) => void | Promise<void>;
1003
457
  amount: string;
1004
458
  asset: Asset;
1005
459
  depositCallback?: DepositCallback;
1006
460
  agentId?: AgentId;
1007
461
  onApproved?: () => void;
1008
- /** Funding ledger reference (a UUID). Defaults to a new random UUID; apps pass
1009
- * their own so the app record and the ledger share one reference. */
1010
- operationId?: string;
1011
- /**
1012
- * Groups this deposit with the others started by one user action (a spread
1013
- * deposit sends one per position). A UUID, recorded on the funding ledger's
1014
- * operation; a value that is not a UUID is ignored.
1015
- */
1016
- batchId?: string;
1017
462
  /**
1018
463
  * Chain to deposit on. Defaults to the chain `activateAgent` last set, so
1019
464
  * omitting it behaves exactly as before.
@@ -1028,235 +473,151 @@ type DepositOptions = {
1028
473
  chainId?: number;
1029
474
  };
1030
475
 
1031
- type FundingStage = "pending" | "confirmed" | "unknown" | "failed" | "not-applicable";
1032
- /** Vault inventory retained before the MAX payout. No signatures or secrets. */
1033
- type WithdrawalCompletionContext = {
1034
- vaults: string[];
1035
- userId: string;
1036
- agentId: string;
1037
- inventoryComplete: boolean;
1038
- };
1039
- type WithdrawalCompletion = {
1040
- status: "complete" | "remaining" | "unavailable";
1041
- reason?: string;
1042
- checkedVaults?: number;
476
+ /**
477
+ * One protocol's pool selection on one chain. `pools` holds Zyfai pool NAMES
478
+ * verbatim — matched case-sensitively by customizeBatch, and an unrecognised
479
+ * name makes Zyfai's rebalance engine skip the whole protocol, so these strings
480
+ * must not be normalised anywhere.
481
+ *
482
+ * An empty array means "no usable pools on this chain".
483
+ */
484
+ type OrgPoolSelection = {
485
+ protocolId: string;
486
+ chainId: number;
487
+ pools: string[];
1043
488
  };
1044
- /** Hash-bound v0.6 recovery metadata. Deliberately excludes the owner signature. */
1045
- type UnsignedUserOperationEvidence = {
1046
- sender: string;
1047
- nonce: string;
1048
- initCode: string;
1049
- callData: string;
1050
- callGasLimit: string;
1051
- verificationGasLimit: string;
1052
- preVerificationGas: string;
1053
- maxFeePerGas: string;
1054
- maxPriorityFeePerGas: string;
1055
- paymasterAndData: string;
489
+ /**
490
+ * The partner's protocol/pool policy (ROUT-224). Sparse — only protocols they
491
+ * narrowed appear. Optional so an older routing API, which does not return the
492
+ * field, still parses; undefined and null both mean "change nothing".
493
+ */
494
+ type OrgPoolPolicy = {
495
+ autoApproveProtocols: boolean;
496
+ autoApprovePools: boolean;
497
+ selections: OrgPoolSelection[];
1056
498
  };
1057
- type DepositAuthorizationReference = {
1058
- authorizationId: `0x${string}`;
1059
- predecessorTxHash?: `0x${string}`;
499
+ /**
500
+ * The organization's agent execution policy, or null when the partner has never
501
+ * configured one — in which case the agents leave the user's profile alone.
502
+ */
503
+ type OrgAgentConfig = {
504
+ splittingMode: "none" | "automatic" | "force";
505
+ minSplits: number | null;
506
+ poolPolicy?: OrgPoolPolicy | null;
1060
507
  };
1061
- type DepositReplacementValidation = {
1062
- authorizationId: `0x${string}`;
1063
- predecessorTxHash: `0x${string}`;
1064
- replacementTxHash: `0x${string}`;
508
+
509
+ /**
510
+ * Pool policy: Owney's org-level protocol/pool policy -> Zyfai's two mismatched
511
+ * write shapes.
512
+ *
513
+ * Zyfai splits "which protocols and pools may this user's funds sit in" across
514
+ * two calls that do not share an axis:
515
+ *
516
+ * updateUserProfile({ protocols }) per ASSET, chain-agnostic
517
+ * customizeBatch([{ protocolId, per (PROTOCOL, CHAIN), asset-agnostic
518
+ * chainId, pools, autoselect }])
519
+ *
520
+ * `protocols` is an explicit ALLOW-LIST: a protocol left out of it is disabled
521
+ * for that asset, on every chain, immediately. `customizeBatch` is the opposite
522
+ * shape — one record per (protocol, chain) pair, asset-agnostic, and per
523
+ * docs.zyf.ai it "creates or updates a record for the (user, protocol, chain)
524
+ * combination"; "previous customizations for the same combination are
525
+ * overwritten".
526
+ *
527
+ * That second property is the reason this file exists rather than a single
528
+ * flat translation: customizeBatch overwrites only the combinations it is
529
+ * GIVEN. The partner's stored policy (`OrgPoolPolicy.selections`) is sparse —
530
+ * only the protocols they actually narrowed appear — but the payload we send
531
+ * must be EXHAUSTIVE over every (protocol, chain) pair Zyfai offers this user.
532
+ * If we only sent the narrowed pairs, a partner who restricts Morpho, saves,
533
+ * then later re-ticks every pool box would never be able to undo it: nothing
534
+ * in the (sparse) policy would tell us to send a record clearing it, and the
535
+ * old restrictive record would stay live on the user's profile forever.
536
+ *
537
+ * Pure functions, kept out of the agent so the mapping is testable without a
538
+ * Zyfai client. See splitting.ts for the same pattern on the other lever.
539
+ */
540
+
541
+ /** One selectable pool, with the figures the deposit-time Pools step shows. */
542
+ type AvailablePool = {
543
+ chainId: number;
544
+ token: string;
545
+ name: string;
546
+ /** combined_apy (pool + rewards), already a percent. null when absent. */
547
+ apy: number | null;
548
+ /** TVL in USD. null when absent. See ZyfCustomizationPoolInfo: `tvl` is in
549
+ * the pool's own token, `tvlUsd` is the dollar figure — only the latter is
550
+ * safe to show with a currency symbol. */
551
+ tvlUsd: number | null;
552
+ /** Per-pool deep link (e.g. the Morpho vault page). null when absent. */
553
+ link: string | null;
1065
554
  };
1066
- /** Evidence about one provider leg. Amounts are token base units, never USD. */
1067
- interface FundingEvidence {
1068
- agentId: AgentId;
555
+ /** Public Zyfai strategies used by deposit-time pool customization. */
556
+ type PoolSelectionStrategy = "aggressive" | "yieldmaxxing";
557
+ /** One asset's explicit choice for a protocol on one chain. */
558
+ type UserPoolSelection = {
559
+ asset: "USDC" | "WETH";
560
+ protocolId: string;
1069
561
  chainId: number;
1070
- token: OwneySupportedTokens;
1071
- walletAddress: string;
1072
- agentWallet?: string;
1073
- maxCompletion?: WithdrawalCompletionContext;
1074
- maxCompletionCheck?: WithdrawalCompletion;
1075
- intendedAmount: string;
1076
- /** A multi-agent withdrawal recorded this leg's planned amount (`intendedAmount`:
1077
- * the leg's share, or "MAX") before any agent was dispatched. A plan, not a
1078
- * submission: it never says the leg was sent. */
1079
- planned?: true;
1080
- /** The owner-authorized call of a wallet-approval withdrawal was accepted: the
1081
- * bundler accepted the signed userOp (`userOpHash`), the wallet returned a
1082
- * calls ID (`callsId`), or `eth_sendTransaction` returned a hash (`txHash`).
1083
- * Not confirmation: the call can still revert. */
1084
- ownerAuthorization?: "accepted";
1085
- confirmedAmount?: string;
1086
- /** Receipt delivery and fulfillment of a typed requested amount are separate facts. */
1087
- amountCompletion?: "complete" | "shortfall";
1088
- /** Verified difference between the typed request and the actual owner payout. */
1089
- shortfallAmount?: string;
1090
- txHash?: string;
1091
- /** Zyfai's id for this deposit, from its registration (1-128 chars); reads its placement status. */
1092
- providerDepositId?: string;
1093
- /** Persisted before a sponsored EOA operation is sent. */
1094
- userOpHash?: string;
1095
- /** Lets recovery verify a consumed nonce even if a bundler forgets the operation. */
1096
- userOperation?: UnsignedUserOperationEvidence;
1097
- /** Base Account calls ID used to recover an uncertain wallet submission. */
1098
- callsId?: string;
1099
- /** The server owns this sponsored Yieldseeker userOp's send (true), or may
1100
- * own it ("unknown": the opted-in send got no definitive answer). Either way
1101
- * the leg is never "not sent". Not acceptance, not confirmation. Never sent
1102
- * to the ledger. */
1103
- serverSubmit?: true | "unknown";
1104
- /** Zyfai server tasks. On a withdrawal leg: the server sends this withdrawal
1105
- * (true), or may send it ("unknown": the handoff got no definitive answer),
1106
- * so the browser never sends it. `false`: the server proved it has no task
1107
- * for this leg, so the browser sends it; it clears an earlier mark (a
1108
- * handoff checkpoint), and a merge must let it win over true and "unknown".
1109
- * On a deposit leg: the server registers this deposit. Not acceptance, not
1110
- * confirmation. Never sent to the ledger. */
1111
- serverTask?: true | "unknown" | false;
1112
- /** With `serverTask` on a Zyfai deposit leg: the client operation id of the
1113
- * server's registration task, so registration recovery can nudge that task
1114
- * after a reload. Not a secret. Never sent to the ledger. */
1115
- serverTaskOperationId?: string;
1116
- /** With `serverTask: "unknown"` on a Zyfai deposit leg: what the server
1117
- * answered to the registration handoff. "lost": no answer (the server may
1118
- * or may not have a task), so a later proof of no task lets the browser
1119
- * register it. "declined": the server declined it with a code that does not
1120
- * prove no task (e.g. ALREADY_REGISTERED), so the browser never registers
1121
- * it. Local only: never sent to the ledger. */
1122
- serverTaskCreate?: "declined" | "lost";
1123
- /** Deposit execution was attempted, rather than only prepared. Not confirmation. */
1124
- depositSubmission?: "started";
1125
- depositAuthorization?: DepositAuthorizationReference;
1126
- /** The server accepted this sponsored deposit and sends it itself if the
1127
- * browser does not (true), or may have accepted it ("unknown": the prepare
1128
- * got no definitive answer, no hash is known yet). Either way it is never
1129
- * "not sent". Not confirmation. */
1130
- serverBroadcast?: true | "unknown";
1131
- /** With `serverBroadcast: "unknown"`: the deposit authorization's Permit2
1132
- * deadline (unix seconds). After it no deposit of that authorization can
1133
- * execute. */
1134
- authorizationDeadline?: number;
1135
- /** With `serverBroadcast`: the deposit authorization's Permit2 nonce
1136
- * (decimal); see `checkDepositAuthorization`. */
1137
- permit2Nonce?: string;
1138
- blockNumber?: string;
1139
- logIndexes?: number[];
1140
- transferLogs?: {
1141
- logIndex: number;
1142
- amountRaw: string;
1143
- }[];
1144
- /** Sanitized execution-request evidence. Attempted does not prove server acceptance. */
1145
- withdrawalRequest?: {
1146
- attempted: boolean;
1147
- method?: "GET" | "POST";
1148
- /** The route that answered. v1 paths appear only in evidence saved before @zyfai/sdk 0.10.0. */
1149
- path?: "/users/withdraw" | "/users/partial-withdraw" | "/users/withdraw/v2" | "/users/partial-withdraw/v2";
1150
- elapsedMs?: number;
1151
- /** Actual response status captured before the vendor replaces the HTTP error. */
1152
- httpStatus?: number;
1153
- failure?: "network" | "unauthorized" | "forbidden" | "rate-limited" | "insufficient-balance" | "session-key-missing" | "withdrawal-in-progress" | "other";
1154
- /** When the provider accepted the request without a hash (ms since epoch). */
1155
- acceptedAt?: number;
1156
- /** Zyfai's v2 withdrawal id, for the lifecycle lookup (1-128 chars). */
1157
- providerWithdrawalId?: string;
1158
- };
1159
- /** Where an on-chain payout search may start, for a hashless acceptance.
1160
- * `fromBlock` is the chain head read just before the request (decimal string). */
1161
- payoutSearch?: {
1162
- fromBlock?: string;
1163
- };
1164
- transfer: FundingStage;
1165
- registration: FundingStage;
1166
- delivery: FundingStage;
1167
- }
1168
- type FundingProgress = (evidence: FundingEvidence) => void;
1169
- /** The part of Zyfai's withdrawal lifecycle (`GET /users/withdrawals/{id}`) that Owney acts on. */
1170
- type ZyfaiWithdrawalLifecycle = {
1171
- status: string;
1172
- /** The synchronous payout leg has settled. */
1173
- syncSettled: boolean;
1174
- /** Hash of the synchronous payout transaction; present only when well formed. */
1175
- syncTxHash?: `0x${string}`;
1176
- /** Delayed (protocol-cooldown) redemption legs; empty when none or unreadable. */
1177
- asyncLegs: {
1178
- id: string;
1179
- status: string;
1180
- estimatedClaimAt?: string;
1181
- claimTxHash?: `0x${string}`;
1182
- }[];
1183
- /** Ids of delayed legs Zyfai reports as failed. */
1184
- failedAsyncIds: string[];
1185
- /** When the delayed part is expected to arrive; present only when a valid date. */
1186
- estimatedClaimAt?: string;
1187
- /** Zyfai recorded an error for this withdrawal. Its text is never carried. */
1188
- hasError: boolean;
562
+ /** Names enabled by the user for this asset/protocol/chain. */
563
+ pools: string[];
564
+ /** Every name shown for this asset/protocol/chain in the superset catalog. */
565
+ availablePools: string[];
566
+ };
567
+ /** The complete saved draft for the asset/chain legs selected in the deposit. */
568
+ type UserPoolSelectionRequest = {
569
+ strategies: Array<{
570
+ asset: "USDC" | "WETH";
571
+ strategy: PoolSelectionStrategy;
572
+ }>;
573
+ selections: UserPoolSelection[];
574
+ };
575
+ /**
576
+ * What a user's account currently has saved (ROUT-650): each asset's strategy,
577
+ * plus the pool list of every protocol/chain pair frozen by an earlier Save.
578
+ * Pairs Zyfai still autoselects are left out, so "no entry" means "default".
579
+ */
580
+ type SavedPoolSelection = {
581
+ strategies: Array<{
582
+ asset: "USDC" | "WETH";
583
+ strategy: string;
584
+ }>;
585
+ pairs: Array<{
586
+ protocolId: string;
587
+ chainId: number;
588
+ pools: string[];
589
+ }>;
1189
590
  };
1190
- /** The part of Zyfai's deposit status (`GET /users/deposits/{id}/v2`) that Owney acts on. */
1191
- type ZyfaiDepositPlacement = {
1192
- /** `handover_pending | credited | position_pending | positioned | recovered_to_eoa`. */
1193
- status: string;
1194
- /** `pending | positioned | skipped | failed`. */
1195
- positionOutcome?: string;
591
+ /** One protocol with its pools for the deposit asset — what the Pools step
592
+ * renders: a protocol row that opens to a list of selectable pools. */
593
+ type PoolCatalogProtocol = {
594
+ protocolId: string;
595
+ name: string;
596
+ logo: string | null;
597
+ pools: AvailablePool[];
1196
598
  };
1197
- interface AssetReadMetadata {
1198
- chainId: number;
1199
- asset: string;
1200
- fetchedAt?: number;
1201
- /** When the underlying provider request started; preserved on cached reads. */
1202
- requestedAt?: number;
1203
- /** SDK cache generation, not an onchain block or provider timestamp. */
1204
- readVersion?: number;
1205
- providerUpdatedAt?: string;
1206
- snapshotId?: string;
1207
- blockNumber?: string;
1208
- netDepositsRaw?: string;
1209
- /** Display-only agreement with a post-payout read. Does not prove that
1210
- * provider accounting, history or allocations include the transaction. */
1211
- withdrawalCheck?: {
1212
- txHash: string;
1213
- blockNumber: string;
1214
- };
1215
- positionsStatus: "available" | "unavailable";
1216
- }
599
+
1217
600
  interface OwneyDepositResult {
1218
- evidence?: FundingEvidence;
1219
601
  txHash: string;
1220
602
  smartWallet: string;
1221
603
  amount: string;
1222
- /** Funding ledger reference for this deposit (quote it in support tickets). */
1223
- operationId?: string;
1224
604
  }
1225
605
  interface OwneyMultiDepositResult {
1226
606
  agentResults: Record<string, OwneyDepositResult>;
1227
- /** Funding ledger reference for this deposit (quote it in support tickets). */
1228
- operationId?: string;
1229
607
  }
1230
608
  interface AgentWithdrawResult {
1231
- evidence?: FundingEvidence;
1232
609
  txHash?: string;
1233
610
  type: "full" | "partial";
1234
- /** Owner payout or clearing all MAX positions still needs verification. */
1235
- completion?: "unverified";
1236
- /** Confirmed smallest-unit amount; "0" when no owner payout is verified.
1237
- * Legacy providers may return a sentinel such as "all" for a full request. */
611
+ /** Smallest-unit amount, or a provider sentinel such as "all" for a full request. */
1238
612
  amount: string;
1239
- /** Yieldseeker typed withdrawal fulfilled after an exactly verified fee
1240
- * deduction. Amount remains the confirmed net owner payout, and the gross
1241
- * amount must equal that payout plus the fee, all in token base units. */
1242
- feeAdjustment?: {
1243
- grossAmount: string;
1244
- feeAmount: string;
1245
- };
1246
- /** Funding ledger reference for this withdrawal (quote it in support tickets).
1247
- * Set on the result of a single-agent `withdraw()`, not on per-agent entries. */
1248
- operationId?: string;
1249
613
  }
1250
614
  interface OwneyWithdrawResult {
1251
615
  agentResult: Record<AgentId, AgentWithdrawResult>;
1252
616
  /**
1253
- * Sum of confirmed smallest-unit amounts; null while any returned leg's
1254
- * payout is not yet known, including typed requests accepted asynchronously.
1255
- * Evidence-less custom adapters retain their confirmed-amount contract.
617
+ * Sum of reported smallest-unit amounts; null when a full withdrawal's
618
+ * amount is not yet known. An accepted request is not proof of settlement.
1256
619
  */
1257
620
  totalWithdrawn: string | null;
1258
- /** Funding ledger reference for this withdrawal (quote it in support tickets). */
1259
- operationId?: string;
1260
621
  }
1261
622
  interface OwneyToken {
1262
623
  chain: OwneySupportedChains;
@@ -1272,10 +633,6 @@ interface OwneyPosition {
1272
633
  pool?: string;
1273
634
  asset: string;
1274
635
  amount: string;
1275
- /** Provider-native raw quantity; may represent vault shares, not the underlying asset. */
1276
- amountRaw?: string;
1277
- /** Withdrawable underlying asset amount in that asset's smallest units. */
1278
- withdrawableAmountRaw?: string;
1279
636
  apy?: number;
1280
637
  tvl?: number;
1281
638
  /** Pool liquidity. Prepared slot — Zyfai will add this to its portfolio
@@ -1305,34 +662,11 @@ interface OwneyPendingAllocation {
1305
662
  /** ISO timestamp from Zyfai's `updatedAt`, when the payload carries one. */
1306
663
  since?: string;
1307
664
  }
1308
- /**
1309
- * A Zyfai delayed redemption in flight (`REQUESTED` or `CLAIMABLE`). Its funds
1310
- * are in neither `positions` nor `tokens`; display-only, never added to a total.
1311
- */
1312
- interface OwneyPendingWithdrawal {
1313
- id: string;
1314
- status: string;
1315
- chainId: number;
1316
- /** Token symbol as Zyfai reports it. */
1317
- asset: string;
1318
- /** Redeemed amount in least units, as a decimal string. */
1319
- amountRaw: string;
1320
- }
1321
665
  interface AgentBalance {
1322
- readMetadata?: AssetReadMetadata[];
1323
- /** Authoritative native balances per asset/network, including idle and invested funds. */
1324
- assetBalances?: OwneyToken[];
1325
666
  smartWallet?: `0x${string}`;
1326
667
  totalBalance: string;
1327
668
  /** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
1328
669
  totalBalanceAsset: string;
1329
- /**
1330
- * Describes whether `tokens` already includes deployed `positions`.
1331
- * Consumers must add matching positions only for `tokens-plus-positions`;
1332
- * doing so for Zyfai would double-count, while omitting it for Yieldseeker
1333
- * makes its balance disappear as soon as idle funds enter a vault.
1334
- */
1335
- balanceComposition?: "tokens-include-positions" | "tokens-plus-positions";
1336
670
  tokens: OwneyToken[];
1337
671
  /**
1338
672
  * Per-protocol/pool positions when the agent's portfolio payload includes
@@ -1341,23 +675,7 @@ interface AgentBalance {
1341
675
  positions?: OwneyPosition[];
1342
676
  /** Funds received but not yet deployed. Omitted when nothing is pending. */
1343
677
  pendingAllocations?: OwneyPendingAllocation[];
1344
- /** Zyfai only: delayed redemptions still in flight. Omitted when none. Never part of a total. */
1345
- pendingWithdrawals?: OwneyPendingWithdrawal[];
1346
- /**
1347
- * Zyfai only: every delayed redemption Zyfai lists except FAILED, recently
1348
- * CLAIMED ones included (Zyfai keeps them about a day). Present, possibly
1349
- * empty, whenever Zyfai sent the list; absent when it did not. Empty means no
1350
- * older delayed payout can be landing now. Never part of a total.
1351
- */
1352
- recentAsyncWithdrawals?: OwneyRecentAsyncWithdrawal[];
1353
678
  }
1354
- /** A delayed Zyfai redemption by status, for telling a new payout from an older remainder. */
1355
- type OwneyRecentAsyncWithdrawal = {
1356
- id: string;
1357
- status: string;
1358
- chainId: number;
1359
- asset: string;
1360
- };
1361
679
  /**
1362
680
  * One position drained by `withdrawAll()` — a chain and asset pair.
1363
681
  *
@@ -1382,14 +700,10 @@ interface OwneyBalances {
1382
700
  /** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
1383
701
  totalBalanceAsset: string;
1384
702
  agentBalances: Record<AgentId, AgentBalance>;
1385
- /**
1386
- * Per-agent read failures when an aggregate balance request returned only a
1387
- * partial result. Callers may display the successful balances, but funding
1388
- * operations must not interpret a missing agent as having a zero balance.
1389
- */
1390
- agentErrors?: Partial<Record<AgentId, string>>;
703
+ /** Omitted agents failed to load; they must not be interpreted as zero. */
704
+ agentErrors?: Record<AgentId, string>;
1391
705
  /** Absolute provider cooldown deadlines (Unix milliseconds). */
1392
- agentRetryAt?: Partial<Record<AgentId, number>>;
706
+ agentRetryAt?: Record<AgentId, number>;
1393
707
  }
1394
708
  interface AgentEarnings {
1395
709
  smartWallet: `0x${string}`;
@@ -1399,10 +713,6 @@ interface AgentEarnings {
1399
713
  interface OwneyEarnings {
1400
714
  totalEarnings: string;
1401
715
  agentEarnings: Record<AgentId, AgentEarnings>;
1402
- /** Per-agent failures when an aggregate read returned a partial result. */
1403
- agentErrors?: Partial<Record<AgentId, string>>;
1404
- /** Absolute provider cooldown deadlines (Unix milliseconds). */
1405
- agentRetryAt?: Partial<Record<AgentId, number>>;
1406
716
  }
1407
717
  type ApyByChainAndAsset = Partial<Record<OwneySupportedChainId, Partial<Record<OwneySupportedTokens, number>>>>;
1408
718
  /** A single day's net APY for the connected account, as a percentage number. */
@@ -1480,15 +790,6 @@ interface OwneyAllocationApy {
1480
790
  }
1481
791
  type HistoryAction = "Rebalance" | "Deposit" | "Top up" | "Withdraw" | "Earned";
1482
792
  interface HistoryTransaction {
1483
- tokenAddress?: string;
1484
- agentWallet?: string;
1485
- logIndexes?: number[];
1486
- transferLogs?: {
1487
- logIndex: number;
1488
- amountRaw: string;
1489
- }[];
1490
- amountRaw?: string;
1491
- blockNumber?: string;
1492
793
  txHashes: string[];
1493
794
  chainId?: number;
1494
795
  tokenSymbol?: string;
@@ -1509,27 +810,14 @@ interface RebalanceLog {
1509
810
  tokenSymbol: string;
1510
811
  amount: string;
1511
812
  status: "success" | "failed";
1512
- /** Fee-net APY at execution time for the source leg, in percentage points. */
1513
- fromApy?: string;
1514
- /** Fee-net APY at execution time for the destination leg, in percentage points. */
1515
- toApy?: string;
1516
813
  }
1517
814
  interface AgentHistoryPosition {
1518
815
  protocol: string;
1519
816
  pool?: string;
1520
817
  tokenSymbol?: string;
1521
- /** The position balance after the action (decimal string, token units). */
1522
818
  amount?: string;
1523
- /**
1524
- * The amount the action actually moved (decimal string, token units), as
1525
- * opposed to `amount`, the resulting position balance. Present only when the
1526
- * provider reports it; withheld on withdrawals.
1527
- */
1528
- deltaAmount?: string;
1529
819
  }
1530
820
  interface AgentHistoryEntry {
1531
- /** Stable provider/transfer identity, independent of row order. */
1532
- id?: string;
1533
821
  agent: AgentId;
1534
822
  action: HistoryAction;
1535
823
  /**
@@ -1556,8 +844,6 @@ interface AgentHistoryEntry {
1556
844
  asyncRequest?: true;
1557
845
  }
1558
846
  interface OwneyAgentHistory {
1559
- agentErrors?: Partial<Record<AgentId, string>>;
1560
- agentRetryAt?: Partial<Record<AgentId, number>>;
1561
847
  data: AgentHistoryEntry[];
1562
848
  /** True iff a subsequent page exists; pair with `nextCursor`. */
1563
849
  hasMore: boolean;
@@ -1596,18 +882,17 @@ interface AgentApy {
1596
882
  detailedApys?: AgentApyDetails;
1597
883
  }
1598
884
  interface OwneyAgentApy {
1599
- /** Agents without data for the requested period are omitted. */
1600
- agentApy: Partial<Record<AgentId, AgentApy>>;
885
+ agentApy: Record<AgentId, AgentApy>;
1601
886
  }
1602
- /** One day's cumulative earnings for a single asset. */
887
+ /** One day's cumulative NET earnings for a single asset. */
1603
888
  interface DailyEarningsPoint {
1604
889
  /** ISO date string for the day, e.g. "2026-09-01". */
1605
890
  date: string;
1606
891
  /**
1607
- * Cumulative earnings in the asset's own units, using the provider's earnings
1608
- * basis. A provider may return lifetime totals or a running window total;
1609
- * difference the last and opening points to measure earnings over the window.
1610
- * Aggregate series normalize each component's opening value before summing.
892
+ * Earnings accumulated from the start of the returned series up to and
893
+ * including this day, net of the agent's performance fee, denominated in the
894
+ * asset's own units. A running total of daily deltas, so it measures the
895
+ * window — not the wallet's lifetime.
1611
896
  */
1612
897
  amount: number;
1613
898
  }
@@ -1616,9 +901,8 @@ interface AssetDailyEarnings {
1616
901
  /** Asset symbol, e.g. "USDC" / "WETH". */
1617
902
  asset: string;
1618
903
  /**
1619
- * Ascending by date, including an opening snapshot before the requested
1620
- * window when available. Provider gaps remain absent; aggregates carry the
1621
- * most recent cumulative value across dates reported by other providers.
904
+ * Ascending by date. Days the wallet held nothing of this asset are absent
905
+ * rather than zero — a zero would read as "earned nothing that day".
1622
906
  */
1623
907
  points: DailyEarningsPoint[];
1624
908
  }
@@ -1635,53 +919,107 @@ interface AccountDailyEarnings {
1635
919
  assets: AssetDailyEarnings[];
1636
920
  }
1637
921
 
1638
- type ReservationAgent = "zyfai" | "surfliquid" | "yieldseeker";
1639
- type WithdrawalReservationMode = "fail-open" | "fail-closed" | "off";
1640
- type ReservationReleaseReason = "confirmed" | "failed" | "not_submitted";
1641
- /** What the 409 tells the app. The holding operation's id and token are never returned. */
1642
- type WithdrawalReservationConflict = {
1643
- /** First 8 hex characters of the holding operation's id. */
1644
- reference: string;
1645
- ageSec: number;
1646
- expiresInSec: number;
1647
- agents: ReservationAgent[];
1648
- state: "preparing" | "dispatched";
1649
- /** True for an unproven hold: the app may resend with `override: reference`. */
1650
- overridable: boolean;
1651
- };
1652
-
922
+ type DepositCallback = (smartWalletAddress: string, chainId: number, amount: string) => Promise<`0x${string}`> | `0x${string}`;
923
+ interface IAgent {
924
+ readonly id: string;
925
+ readonly supportedChainIds: readonly OwneySupportedChainId[];
926
+ readonly supportedAssets: readonly AgentSupportedAssets[];
927
+ disconnect(): Promise<void>;
928
+ activateAgent(state: ConnectionState, chainId: number): Promise<void>;
929
+ /**
930
+ * Apply the organization's agent policy to this user's account.
931
+ *
932
+ * Optional: an agent that has no equivalent knob simply omits it, which is why
933
+ * this is not part of `activateAgent`'s signature. Declared on the interface
934
+ * rather than only on ZyfaiAgent so the contract stays agent-neutral — the
935
+ * ticket asks for a design that can also cover Surf, which has no adapter yet.
936
+ *
937
+ * Implementations must be **non-fatal**: this runs during activation as a side
938
+ * effect, so a failure has to leave the user connected and their profile
939
+ * unchanged rather than break the connect.
940
+ */
941
+ applyOrgPolicy?(state: ConnectionState, chainId: number, policy: OrgAgentConfig): Promise<void>;
942
+ /**
943
+ * The deposit-time pool catalogue for one asset and strategy: protocols with
944
+ * their selectable pools and figures. Optional — an agent with no pool
945
+ * customization omits it. (ROUT-569)
946
+ */
947
+ getPoolCatalog?(params: {
948
+ asset: string;
949
+ strategy: "conservative" | "aggressive" | "yieldmaxxing";
950
+ }): Promise<PoolCatalogProtocol[]>;
951
+ /**
952
+ * Apply a user's own pool selection to their account, driven by the
953
+ * deposit-time Pools step. Optional, and non-fatal like `applyOrgPolicy`.
954
+ * (ROUT-569)
955
+ */
956
+ setPoolSelection?(selection: UserPoolSelectionRequest): Promise<void>;
957
+ /**
958
+ * Read back what `setPoolSelection` saved, for the pairs and assets given,
959
+ * so the Pools step can open on the user's own choices. Optional. (ROUT-650)
960
+ */
961
+ getPoolSelection?(state: ConnectionState, chainId: number, params: {
962
+ pairs: Array<{
963
+ protocolId: string;
964
+ chainId: number;
965
+ }>;
966
+ assets: Array<"USDC" | "WETH">;
967
+ }): Promise<SavedPoolSelection>;
968
+ deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
969
+ withdraw(state: ConnectionState, chainId: number, token: OwneySupportedTokens, amount?: string): Promise<AgentWithdrawResult>;
970
+ getBalances(state: ConnectionState, chainId: number): Promise<AgentBalance>;
971
+ getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
972
+ /**
973
+ * Refresh the agent's earnings snapshot when its backend supports doing so.
974
+ * Implementations own freshness and request-deduplication policy.
975
+ */
976
+ refreshEarnings?(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
977
+ getAccountApy(state: ConnectionState, chainId: number, days: DailyApyDays,
978
+ /**
979
+ * Optional asset symbol ("USDC" / "WETH") scoping the daily series to a
980
+ * single asset on the chain. Agents without per-asset positions ignore it.
981
+ */
982
+ tokenSymbol?: string,
983
+ /**
984
+ * Chain the series is scoped to, when that differs from the chain the
985
+ * connection is on. `null` spans every chain the wallet held (ROUT-479);
986
+ * omitted means `chainId`. Kept apart from `chainId` because that one
987
+ * still resolves the wallet and must stay a real, connected chain.
988
+ */
989
+ scopeChainId?: number | null): Promise<AccountAgentApy>;
990
+ /**
991
+ * Daily cumulative NET earnings for the window, scoped to a chain/asset.
992
+ * Backs the "recent earnings" subline, whose figure must reconcile with the
993
+ * balance headline directly above it. (ROUT-452)
994
+ */
995
+ getDailyEarnings?(state: ConnectionState, chainId: number, days: LookbackDays, tokenSymbol?: string): Promise<AccountDailyEarnings>;
996
+ getHistory(state: ConnectionState, chainId: number, options?: HistoryFilters): Promise<OwneyAgentHistory>;
997
+ getUserProfile(state: ConnectionState, chainId: number): Promise<AgentUserProfile>;
998
+ /**
999
+ * Ensure the given asset uses backend protocol auto-selection
1000
+ * (`autoSelectProtocols: true`). Optional capability — only agents whose
1001
+ * backend models per-asset protocol selection implement it. Returns whether
1002
+ * a write occurred (`false` = already enabled / not supported).
1003
+ */
1004
+ ensureAutoSelectProtocols?(state: ConnectionState, chainId: number, asset: "USDC" | "WETH"): Promise<boolean>;
1005
+ getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
1006
+ }
1653
1007
  /**
1654
- * On-chain discovery of a hashless withdrawal's payout.
1655
- *
1656
- * Lists ERC-20 `Transfer` logs on the operation's token that reach the owner.
1657
- * The sender is never filtered: routed payouts hop through intermediaries.
1658
- * This only finds candidates; each one must still be proven with the receipt
1659
- * inspection (`inspectFunding(candidate, "withdraw", { requireAmountMatch: true })`).
1008
+ * Optional filters for per-agent APY lookups.
1009
+ * - `tokenSymbol` / `chainId` scope the APY to a specific asset+chain when
1010
+ * the underlying provider supports it (Zyfai). Agents whose backends do
1011
+ * not yet support per-asset APY will ignore these options.
1660
1012
  */
1661
- type WithdrawalPayoutCandidate = {
1662
- txHash: string;
1663
- /** Decimal block number. */
1664
- blockNumber: string;
1665
- logIndex: number;
1666
- /** Transferred amount in token base units. */
1667
- amountRaw: string;
1668
- };
1669
- type WithdrawalPayoutScan = {
1670
- candidates: WithdrawalPayoutCandidate[];
1671
- /** Last block scanned (inclusive, decimal). Pass it back as the next `cursor`. */
1672
- scannedTo: string;
1673
- /** False when the call stopped at its request limit before the scan end (the
1674
- * head minus the reorg margin), so more blocks are already waiting. */
1675
- caughtUp: boolean;
1013
+ type AgentApyOptions = {
1014
+ tokenSymbol?: string;
1015
+ chainId?: number;
1676
1016
  };
1677
1017
 
1678
- type OwneyErrorCode = "NOT_CONNECTED" | "NO_ACTIVE_CHAIN" | "WALLET_NO_ACCOUNTS" | "WALLET_ADDRESS_REQUIRED" | "WALLET_NOT_DEPLOYED" | "AGENT_NOT_FOUND" | "AGENT_CHAIN_INCOMPATIBLE" | "AGENT_EMPTY_LIST" | "AGENT_DISABLED" | "AGENT_ACTIVATION_PARTIAL_FAILURE" | "YIELDSEEKER_AGENT_MISSING" | "YIELDSEEKER_WALLET_UNVERIFIED" | "CHAIN_UNSUPPORTED" | "CHAIN_NO_COMPATIBLE_AGENTS" | "CHAIN_MISMATCH" | "ASSET_UNSUPPORTED" | "ASSET_NO_COMPATIBLE_AGENTS" | "DEPOSIT_BALANCE_UNAVAILABLE" | "DEPOSIT_PARTIAL_FAILURE" | "DEPOSIT_IN_PROGRESS" | "DEPOSIT_CHECKPOINT_FAILED" | "DEPOSIT_AMOUNT_BELOW_MINIMUM" | "DEPOSIT_INVALID_AMOUNT" | "DEPOSIT_CALLBACK_REQUIRED" | "DEPOSIT_CALLBACK_INVALID" | "DEPOSIT_NO_PERMITTED_TOKENS" | "DEPOSIT_INSUFFICIENT_BALANCE" | "WITHDRAW_IN_PROGRESS" | "WITHDRAW_NO_PERMITTED_TOKENS" | "WITHDRAW_BALANCE_UNAVAILABLE" | "WITHDRAW_INSUFFICIENT_BALANCE" | "WITHDRAW_ALL_FAILED" | "WITHDRAW_UNCONFIRMED" | "WITHDRAW_NOTHING_TO_WITHDRAW" | "WITHDRAW_PARTIAL_FAILURE" | "WITHDRAW_SWAP_INCOMPLETE" | "WITHDRAW_FAILED" | "WITHDRAW_INVALID_AMOUNT" | "WITHDRAW_RESERVATION_UNAVAILABLE" | "AGENT_RATE_LIMITED" | "API_ROUTING_ERROR" | "API_ROUTING_FAILED" | "API_NO_AGENTS" | "AGENT_API_ERROR" | "AGENT_AUTH_FAILED" | "AGENT_INVALID_RESPONSE" | "AGENT_TIMEOUT" | "AGENT_TRANSACTION_REVERTED" | "AGENT_APY_PERIOD_UNSUPPORTED" | "SPONSOR_REQUEST_FAILED" | "PERMIT2_APPROVAL_REQUIRED" | "SPONSORED_CALLS_UNSUPPORTED" | "SPONSORED_CALLS_NO_ID" | "SPONSORED_CALLS_NO_RECEIPT" | "SWAP_DISABLED" | "SWAP_RATE_LIMITED" | "SWAP_REQUEST_FAILED" | "SWAP_QUOTE_FAILED" | "SWAP_UNSUPPORTED_PAIR" | "SWAP_APPROVAL_REQUIRED" | "SWAP_BELOW_DEPOSIT_MINIMUM" | "SWAP_DEPOSIT_PENDING" | "SWAP_WALLET_PROMPT_TIMEOUT" | "SWAP_INSUFFICIENT_GAS" | "SWAP_NATIVE_UNSUPPORTED" | "SWAP_ORDER_EXPIRED" | "SWAP_ORDER_REFUNDED" | "SWAP_ORDER_CANCELLED" | "SWAP_ORDER_NOT_FOUND" | "WITHDRAW_ARRIVAL_TIMEOUT" | "WITHDRAW_SWAP_FAILED" | "BALANCE_ALL_FAILED" | "EARNINGS_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "POOL_CATALOG_UNSUPPORTED" | "POOL_SELECTION_UNSUPPORTED" | "VALIDATION_INVALID_DAYS";
1018
+ type OwneyErrorCode = "NOT_CONNECTED" | "NO_ACTIVE_CHAIN" | "WALLET_NO_ACCOUNTS" | "WALLET_ADDRESS_REQUIRED" | "WALLET_NOT_DEPLOYED" | "AGENT_NOT_FOUND" | "AGENT_CHAIN_INCOMPATIBLE" | "AGENT_EMPTY_LIST" | "AGENT_DISABLED" | "CHAIN_UNSUPPORTED" | "CHAIN_NO_COMPATIBLE_AGENTS" | "CHAIN_MISMATCH" | "ASSET_UNSUPPORTED" | "ASSET_NO_COMPATIBLE_AGENTS" | "DEPOSIT_BALANCE_UNAVAILABLE" | "DEPOSIT_PARTIAL_FAILURE" | "DEPOSIT_AMOUNT_BELOW_MINIMUM" | "DEPOSIT_CALLBACK_REQUIRED" | "DEPOSIT_CALLBACK_INVALID" | "DEPOSIT_NO_PERMITTED_TOKENS" | "DEPOSIT_INSUFFICIENT_BALANCE" | "WITHDRAW_NO_PERMITTED_TOKENS" | "WITHDRAW_INSUFFICIENT_BALANCE" | "WITHDRAW_ALL_FAILED" | "WITHDRAW_NOTHING_TO_WITHDRAW" | "WITHDRAW_PARTIAL_FAILURE" | "WITHDRAW_FAILED" | "AGENT_RATE_LIMITED" | "API_ROUTING_ERROR" | "API_ROUTING_FAILED" | "API_NO_AGENTS" | "SPONSOR_REQUEST_FAILED" | "PERMIT2_APPROVAL_REQUIRED" | "SPONSORED_CALLS_UNSUPPORTED" | "SPONSORED_CALLS_NO_ID" | "SPONSORED_CALLS_NO_RECEIPT" | "SWAP_DISABLED" | "SWAP_RATE_LIMITED" | "SWAP_REQUEST_FAILED" | "SWAP_QUOTE_FAILED" | "SWAP_UNSUPPORTED_PAIR" | "SWAP_APPROVAL_REQUIRED" | "SWAP_BELOW_DEPOSIT_MINIMUM" | "SWAP_DEPOSIT_PENDING" | "SWAP_WALLET_PROMPT_TIMEOUT" | "SWAP_INSUFFICIENT_GAS" | "SWAP_NATIVE_UNSUPPORTED" | "SWAP_ORDER_EXPIRED" | "SWAP_ORDER_REFUNDED" | "SWAP_ORDER_CANCELLED" | "SWAP_ORDER_NOT_FOUND" | "WITHDRAW_ARRIVAL_TIMEOUT" | "WITHDRAW_SWAP_FAILED" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "POOL_CATALOG_UNSUPPORTED" | "POOL_SELECTION_UNSUPPORTED" | "VALIDATION_INVALID_DAYS";
1679
1019
  declare class OwneyError extends Error {
1680
1020
  readonly code: OwneyErrorCode;
1681
1021
  readonly details?: Record<string, unknown>;
1682
1022
  readonly agentId?: string;
1683
- /** Funding ledger reference, set when a funding operation fails. */
1684
- operationId?: string;
1685
1023
  constructor(code: OwneyErrorCode, message: string, details?: Record<string, unknown>, agentId?: string);
1686
1024
  }
1687
1025
  declare class AgentNotFoundError extends OwneyError {
@@ -1702,41 +1040,41 @@ declare class AgentChainIncompatibleError extends OwneyError {
1702
1040
  }>, connectedChainId: number);
1703
1041
  }
1704
1042
 
1705
- /** Durable intent and evidence, including the gap before an order exists. */
1706
- type WithdrawalSwapRecovery = {
1707
- attemptId: string;
1708
- phase: "withdrawing" | "verifying" | "ready" | "submitted" | "incomplete";
1709
- baseline: string;
1710
- baselineBlock: string;
1711
- submittedAt: number;
1712
- deadline: number;
1713
- requested?: string;
1714
- agentId?: AgentId;
1715
- results?: Record<string, AgentWithdrawResult>;
1716
- evidence: Record<string, FundingEvidence>;
1717
- reason?: string;
1718
- };
1719
- /** Unknown and partial outcomes remain recoverable until settlement is verified. */
1720
- type WithdrawSwapStatus = "swapping" | "landed" | "refunded" | "unknown" | "refund-pending" | "partially-filled" | "withdrawal-pending" | "withdrawal-incomplete" | "ready" | "not-swapped";
1043
+ /**
1044
+ * Withdrawal swaps the user has walked away from, and how they ended.
1045
+ *
1046
+ * The deposit side has `swap.pending-deposit.ts` for the same shape of
1047
+ * problem, but the two are not symmetrical. A pending deposit is a JOB: the
1048
+ * money is in the wallet and an ordinary deposit finishes it. This is a
1049
+ * WATCH — the funds are in escrow, nothing the user does moves them along,
1050
+ * and the only question is where they ended up.
1051
+ *
1052
+ * That is the whole reason this exists. `withdrawAndSwap` used to hold the
1053
+ * screen for the entire escrow lifecycle, which on a slow mainnet fill is
1054
+ * minutes of a modal the user cannot leave (ROUT-242). Backgrounding it means
1055
+ * the outcome arrives after the UI that started it has gone, so the outcome
1056
+ * has to be written down somewhere the next render can find it.
1057
+ *
1058
+ * Only cross-chain swaps are recorded. A same-chain classic swap is one
1059
+ * transaction and resolves in seconds; a same-chain fusion order has no stored
1060
+ * preimages, so there would be nothing for a reloaded session to resume and
1061
+ * the record would sit at `swapping` for ever.
1062
+ *
1063
+ * Kept deliberately separate from the secret store. Secrets are retired the
1064
+ * moment an order reaches a verdict — that is a safety property, not a display
1065
+ * one — and the record has to outlive them so the user can still be told what
1066
+ * happened after they come back.
1067
+ */
1068
+ /**
1069
+ * `swapping` is the only non-terminal state. `unknown` is what a watch that
1070
+ * gave up looks like: we stopped polling before the order spoke, so the order
1071
+ * may well have filled. It is not a failure, and it must never be shown as
1072
+ * one.
1073
+ */
1074
+ type WithdrawSwapStatus = "swapping" | "landed" | "refunded" | "unknown";
1721
1075
  type WithdrawSwapRecord = {
1722
1076
  /** Identity. One record per Fusion+ order. */
1723
1077
  orderHash: string;
1724
- walletAddress?: string;
1725
- txHash?: string;
1726
- /**
1727
- * The funding-ledger operation of this withdrawal and swap, reused when it
1728
- * is continued or rechecked. Absent on records written by an older SDK.
1729
- */
1730
- operationId?: string;
1731
- /**
1732
- * The batch this withdrawal belongs to (see `WithdrawOptions.batchId`), kept
1733
- * so a continuation or recheck reports into the same batch. Absent when the
1734
- * withdrawal was not part of one.
1735
- */
1736
- batchId?: string;
1737
- recovery?: WithdrawalSwapRecovery;
1738
- spent?: string;
1739
- dismissed?: boolean;
1740
1078
  status: WithdrawSwapStatus;
1741
1079
  /**
1742
1080
  * What actually left the agent, smallest unit of the SOURCE asset.
@@ -1773,7 +1111,7 @@ declare function subscribeWithdrawSwaps(listener: () => void): () => void;
1773
1111
  * Not after the swap resolves: the point is to survive the gap between submit
1774
1112
  * and settle, which is exactly when the user closes the tab.
1775
1113
  */
1776
- declare function saveWithdrawSwap(record: WithdrawSwapRecord): boolean;
1114
+ declare function saveWithdrawSwap(record: WithdrawSwapRecord): void;
1777
1115
  /**
1778
1116
  * Move a record to its outcome.
1779
1117
  *
@@ -1787,8 +1125,8 @@ declare function saveWithdrawSwap(record: WithdrawSwapRecord): boolean;
1787
1125
  declare function updateWithdrawSwap(orderHash: string, patch: Partial<Omit<WithdrawSwapRecord, "orderHash">>): void;
1788
1126
  /** The user has read the outcome. Only they do this. */
1789
1127
  declare function clearWithdrawSwap(orderHash: string): void;
1790
- /** Visible records, newest first. Only verified terminal records expire by age. */
1791
- declare function listWithdrawSwaps(now?: number, includeDismissed?: boolean): WithdrawSwapRecord[];
1128
+ /** Every record, newest first, sweeping anything past MAX_AGE_MS. */
1129
+ declare function listWithdrawSwaps(now?: number): WithdrawSwapRecord[];
1792
1130
 
1793
1131
  /**
1794
1132
  * Swaps that landed but were never deposited.
@@ -1823,16 +1161,6 @@ type PendingDeposit = {
1823
1161
  agentId?: string;
1824
1162
  /** Epoch ms, for the sweep. */
1825
1163
  createdAt: number;
1826
- /**
1827
- * The swap's funding-ledger operation, so finishing the deposit reports into
1828
- * it. Absent on records written by an older SDK.
1829
- */
1830
- operationId?: string;
1831
- /**
1832
- * The user action's batch (see `DepositOptions.batchId`), so finishing the
1833
- * deposit later reports under it. Absent when the swap had none.
1834
- */
1835
- batchId?: string;
1836
1164
  };
1837
1165
  /** Every record, dismissed ones included, newest first. Sweeps as it goes. */
1838
1166
  declare function listPendingDeposits(now?: number): PendingDeposit[];
@@ -1847,97 +1175,22 @@ declare class OwneySDK {
1847
1175
  */
1848
1176
  private disabledAgents;
1849
1177
  private state;
1850
- private connectionRevision;
1851
- private disconnectingAgents;
1852
1178
  private apiKey;
1853
1179
  private orgAgentConfig;
1854
1180
  private orgAgentConfigPromise;
1855
- private rpcUrls?;
1856
1181
  private zyfaiRpcUrls?;
1857
- private yieldseekerApiBaseUrl?;
1858
- private yieldseekerSiweOrigin?;
1859
1182
  private userPoolCustomization;
1860
1183
  private routingApiBaseUrl?;
1861
1184
  private referralSource?;
1862
- private readonly ledger;
1863
- private readonly reservationMode;
1864
- private readonly reservationTransport;
1865
- /** The caller's Zyfai server tasks opt-in: `true`, a function read each
1866
- * time a handoff would start (F-I2(iii)), or undefined (off). */
1867
- private readonly zyfaiServerTasks;
1868
- /** The caller opted in to the Fusion+ secret handoff (`fusionSecretHandoff: true`). */
1869
- private readonly fusionSecretHandoff;
1870
1185
  private cachedSponsoredCallback;
1871
1186
  private cachedWethSponsoredCallback;
1872
1187
  private paymasterServiceUrl?;
1873
1188
  private cachedSponsoredCallsCallbacks;
1874
1189
  private readonly agentReads;
1875
- private readonly depositFamilyReads;
1876
- /** Movements (owner, chain, agent, token, tx hash) whose balance refresh this
1877
- * session started: true when it armed the refresh, false when its deadline
1878
- * had passed (it only dropped the cache and forced one snapshot read). */
1879
- private readonly recoveredFundingReads;
1880
- private fundingBalanceChecks;
1881
1190
  private readonly activationChecks;
1882
- private readonly withdrawalSubmissions;
1883
- private readonly withdrawalSwapSubmissions;
1884
1191
  private readAgent;
1885
1192
  private initializingAgentsPromise;
1886
1193
  constructor(config: OwneySDKConfig);
1887
- /** Finishes a funding-ledger operation on success and adds its reference to
1888
- * the result. The result object is copied, never mutated or replaced.
1889
- * `OK` replaces any failure code an earlier attempt of the same operation
1890
- * recorded (a resumed pending deposit, a continuation). */
1891
- private ledgerSucceeded;
1892
- /** Tags a failure with its funding-ledger reference and finishes the
1893
- * operation. The error is never wrapped or replaced. */
1894
- private ledgerFailed;
1895
- /**
1896
- * Swap operations running right now, by operationId. A deposit or withdrawal
1897
- * started with one of these ids is the inner half of that swap and joins its
1898
- * operation instead of starting its own (see `startLedger`).
1899
- */
1900
- private readonly openSwapLedgers;
1901
- /**
1902
- * Starts a funding-ledger operation, or joins the open swap operation with
1903
- * the same id. A joined call reports its legs into the swap's operation and
1904
- * leaves finishing to the swap, so the operation gets one outcome, sent on
1905
- * one ordered request chain.
1906
- */
1907
- private startLedger;
1908
- /** Starts a swap's operation and opens it to the swap's inner deposit or
1909
- * withdrawal. Never throws: reporting never blocks a swap. */
1910
- private openSwapLedger;
1911
- /**
1912
- * Part 5: the swap's ledger identity, for the executor's Fusion+ secret
1913
- * handoff. Only with the `fusionSecretHandoff` opt-in and an open operation;
1914
- * otherwise undefined, and the executor sends nothing. Owner and token are
1915
- * lowercased, as the ledger reports them.
1916
- */
1917
- private secretHandoffFor;
1918
- private closeSwapLedger;
1919
- /** Reports one agent's withdrawal evidence as its leg (with `errorCode`, when
1920
- * given). Never throws. */
1921
- private ledgerWithdrawalLeg;
1922
- /** Operation/leg/tx keys whose provider samples are already scheduled. */
1923
- private readonly providerSampleKeys;
1924
- /**
1925
- * For a confirmed leg of an operation this SDK reported, records the agent's
1926
- * own earnings bookkeeping as `provider.sample` events at confirmation, +5
1927
- * and +30 min (Zyfai; evidence for provider lag). Only agents that expose a
1928
- * never-prompting sample read take part. Fire-and-forget, never throws;
1929
- * a later sample is skipped once the wallet disconnects or changes.
1930
- */
1931
- private ledgerProviderSamples;
1932
- /**
1933
- * Funding-ledger read access handed to agents for earnings holds. Reads only
1934
- * for the connected owner; null otherwise and on any failure.
1935
- */
1936
- private agentLedgerAccess;
1937
- /** Reports the swap leg. Never throws: reporting never affects a swap. */
1938
- private ledgerSwap;
1939
- /** Reports the swap leg of a swap that threw, with any identifier it carried. */
1940
- private ledgerSwapFailed;
1941
1194
  /**
1942
1195
  * Establish connection state for all subsequent SDK calls.
1943
1196
  * Must be called once before any agent operation that requires a wallet.
@@ -1949,8 +1202,6 @@ declare class OwneySDK {
1949
1202
  * After calling this, `connect()` must be called again before using agent methods.
1950
1203
  */
1951
1204
  disconnect(): Promise<void>;
1952
- private clearConnectionState;
1953
- private disconnectAgents;
1954
1205
  private isAgentDisabled;
1955
1206
  /**
1956
1207
  * Check if the SDK has an active connection state.
@@ -1962,50 +1213,32 @@ declare class OwneySDK {
1962
1213
  * @returns The active chain ID, or `null` if `activateAgent` has not been called
1963
1214
  */
1964
1215
  getActiveChainId(): number | null;
1965
- /**
1966
- * The funding-ledger operations this app has for the connected wallet and
1967
- * `asset` (default chain: the active one). Never throws: resolves `null` when
1968
- * not connected, with no chain, when ledger reporting is disabled, or on any
1969
- * failure, which callers treat as "no ledger information".
1970
- *
1971
- * Full `clientOperationId`s come back only for ids passed in `ids`. The ids
1972
- * are trimmed and lowercased, non-uuid strings are dropped, and the first 50
1973
- * distinct ids (caller order) are sent; the rest are ignored.
1974
- */
1975
- listFundingOperations(opts: {
1976
- chainId?: number;
1977
- asset: string;
1978
- ids?: string[];
1979
- since?: Date;
1980
- }): Promise<FundingOperationRow[] | null>;
1981
1216
  private requireState;
1982
1217
  private requireChainId;
1983
1218
  private requireConnectedProvider;
1984
- private getPaidRpcClient;
1985
- /** Builds the default USDC batch callback for the connected wallet. */
1219
+ /**
1220
+ * Lazily builds (and caches) the default EIP-3009 sponsored deposit callback
1221
+ * used when the caller omits `depositCallback`. Wraps the connected EIP-1193
1222
+ * provider with viem `custom(provider)` to read token meta and sign the
1223
+ * `TransferWithAuthorization`, then POSTs to the sponsor API.
1224
+ */
1986
1225
  private getDefaultSponsoredCallback;
1987
- /** Builds the wallet-native sponsored calls callback for compatible paymasters. */
1226
+ /**
1227
+ * Lazily builds (and caches) the default Permit2 sponsored WETH deposit
1228
+ * callback used when the caller omits `depositCallback` for a WETH
1229
+ * deposit. Mirrors `getDefaultSponsoredCallback()` but signs a Permit2
1230
+ * `PermitTransferFrom` instead of an EIP-3009 authorization.
1231
+ */
1988
1232
  private getDefaultSponsoredCallsCallback;
1989
1233
  /**
1990
1234
  * Lazily builds (and caches) the default Permit2 sponsored WETH deposit
1991
1235
  * callback used when the caller omits `depositCallback` for a WETH deposit.
1992
1236
  * Mirrors `getDefaultSponsoredCallback()` but signs a Permit2
1993
- * single-use batch authorization instead of an EIP-3009 authorization.
1237
+ * `PermitTransferFrom` instead of an EIP-3009 authorization.
1994
1238
  */
1995
1239
  private getDefaultWethSponsoredCallback;
1996
1240
  private getAgent;
1997
- getActiveAgentIds(): AgentId[];
1998
1241
  private getActiveAgents;
1999
- /**
2000
- * Agents that do not run on the connection chain but can be read on their
2001
- * own from a saved sign-in: Yieldseeker, Base-only, while the wallet sits on
2002
- * Arbitrum or Ethereum. The whole-portfolio reads (ROUT-479) add them, under
2003
- * a promptless state; with no saved sign-in they are left out, as before.
2004
- */
2005
- private offChainPortfolioAgents;
2006
- /** Every agent a whole-portfolio read covers: the active ones on the
2007
- * connection chain, then the off-chain ones on their own chain. */
2008
- private portfolioReads;
2009
1242
  /**
2010
1243
  * Read the org's agent policy once and reuse it. fetchOrgAgentConfig never
2011
1244
  * throws — it degrades to null — so this cannot break activation.
@@ -2036,9 +1269,9 @@ declare class OwneySDK {
2036
1269
  * that support the given chainId (incompatible agents are silently skipped).
2037
1270
  * If provided, ALL specified agents must support the chainId or the call
2038
1271
  * throws before activating any agent.
1272
+ * @param options - Optional. `onAgentsSelected` fires once reads can start.
2039
1273
  */
2040
- activateAgent(chainId: number, agentId?: AgentId[], asset?: OwneySupportedTokens): Promise<void>;
2041
- private assertActivationSession;
1274
+ activateAgent(chainId: number, agentId?: AgentId[], options?: ActivateAgentOptions): Promise<void>;
2042
1275
  /**
2043
1276
  * Activate agents ONE AT A TIME, each followed by its org policy.
2044
1277
  *
@@ -2052,9 +1285,10 @@ declare class OwneySDK {
2052
1285
  * Serializing costs no real wall-clock: the user can only approve one prompt
2053
1286
  * at a time anyway.
2054
1287
  *
2055
- * Stop at the first failure so a canceled sign-in does not open another
2056
- * agent's wallet prompt. Report any earlier successes for diagnostics; the
2057
- * app discards the session when the complete sign-in does not succeed.
1288
+ * Every agent is attempted even if an earlier one fails, so one declined
1289
+ * signature can't deny the remaining agents their turn. The first failure is
1290
+ * rethrown (matching the previous `Promise.all` rejection) once all agents
1291
+ * have had a chance to activate.
2058
1292
  */
2059
1293
  private activateAgentsInTurn;
2060
1294
  /**
@@ -2065,8 +1299,7 @@ declare class OwneySDK {
2065
1299
  * @param options.asset - Asset symbol to deposit (e.g. "USDC")
2066
1300
  * @param options.depositCallback - Callback that performs the token transfer and returns a tx hash.
2067
1301
  * When agentId is omitted, this callback is invoked once per eligible agent with that agent's
2068
- * split amount and smart wallet address. Default sponsored deposits batch
2069
- * all shares into one signature; custom callbacks still run once per agent.
1302
+ * split amount and smart wallet address — expect multiple wallet prompts.
2070
1303
  * @param options.agentId - Optional explicit target. Otherwise split equally,
2071
1304
  * or fund remaining agents when a recovery deposit cannot meet every minimum.
2072
1305
  * @returns {OwneyDepositResult} for a single agent, or {OwneyMultiDepositResult} with per-agent results
@@ -2076,12 +1309,10 @@ declare class OwneySDK {
2076
1309
  * Invokes `agent.deposit` with the resolved sponsored callback, composing
2077
1310
  * two independent auto-recovery mechanisms:
2078
1311
  *
2079
- * 1. Missing Permit2 allowance outside the sponsored ERC-2612 path: when the
2080
- * app did not supply its own callback and the attempt fails with
2081
- * `PERMIT2_APPROVAL_REQUIRED`, this is the wallet's first Permit2 deposit
2082
- * for that token. Native Base/Arbitrum USDC uses gasless ERC-2612 approval in
2083
- * its sponsored deposit and never reaches this branch. Other tokens send
2084
- * the one-time user-paid Permit2 approval via `approvePermit2()` and
1312
+ * 1. Missing Permit2 allowance: when the app did not supply its own
1313
+ * callback and the attempt fails with `PERMIT2_APPROVAL_REQUIRED` on a
1314
+ * WETH deposit, this is the wallet's first gasless WETH deposit. We send
1315
+ * the one-time (user-paid) Permit2 approval via `approvePermit2()` and
2085
1316
  * retry the SAME sponsored attempt once. Bounded to one approval attempt
2086
1317
  * per call so a wallet/agent that keeps reporting the allowance as
2087
1318
  * missing can't loop forever. If `approvePermit2()` itself throws (e.g.
@@ -2102,7 +1333,6 @@ declare class OwneySDK {
2102
1333
  private depositWithFallback;
2103
1334
  private getMinDepositAmount;
2104
1335
  private splitDepositAmount;
2105
- private formatAgentName;
2106
1336
  private validateMinDepositAmount;
2107
1337
  /**
2108
1338
  * Whether the user already holds a non-zero balance with `agent` for the
@@ -2130,112 +1360,6 @@ declare class OwneySDK {
2130
1360
  private validateChainHasAgents;
2131
1361
  private validateAssetSupport;
2132
1362
  private getEligibleAgents;
2133
- /**
2134
- * Run owner-approved withdrawals before relayer-only withdrawals. Wallet
2135
- * approval is the only point at which the user can cancel the aggregate
2136
- * operation, so no relayer leg should commit before it has completed.
2137
- */
2138
- private orderAgentsForWithdrawal;
2139
- private isUserRejectedWithdrawal;
2140
- private captureReadScope;
2141
- /** Revalidate a saved transfer against the authenticated account and actual receipt. */
2142
- inspectFunding(evidence: FundingEvidence, direction: "deposit" | "withdraw", options?: {
2143
- balanceRefreshUntil?: number;
2144
- refreshBalance?: boolean;
2145
- requireAmountMatch?: boolean;
2146
- }): Promise<FundingEvidence>;
2147
- private noteFundingRefresh;
2148
- /**
2149
- * Re-arms an agent's balance refresh after a confirmed deposit or withdrawal
2150
- * the caller already verified (e.g. after a page reload, which loses the
2151
- * refresh the SDK started in memory). Same refresh as receipt recovery
2152
- * (`inspectFunding`), without a receipt read, and shared with it: once per
2153
- * movement (`txHash`) in this SDK session, unless that recovery came after
2154
- * its own deadline and so armed nothing. `until` bounds it (the agent caps
2155
- * it further). Returns false when the agent has no such refresh or `until`
2156
- * has passed; throws when not connected or on another chain. Never prompts.
2157
- */
2158
- refreshAgentBalanceAfterMovement(input: {
2159
- agentId: AgentId;
2160
- chainId: number;
2161
- token: OwneySupportedTokens;
2162
- txHash?: string;
2163
- until: number;
2164
- }): boolean;
2165
- /**
2166
- * Lists on-chain payout candidates for a withdrawal the provider accepted
2167
- * without a hash: ERC-20 `Transfer` logs on the evidence's token that reach
2168
- * the owner, from `max(fromBlock, cursor − 20)` to `latest − 3`, chunked.
2169
- * Discovery only: prove each candidate with
2170
- * `inspectFunding({ ...evidence, txHash }, "withdraw", { requireAmountMatch: true })`.
2171
- *
2172
- * `fromBlock` defaults to `evidence.payoutSearch.fromBlock`; without either
2173
- * (legacy records) the start is estimated from
2174
- * `withdrawalRequest.acceptedAt ?? submittedAt` minus 5 minutes. Pass the
2175
- * returned `scannedTo` back as `cursor` to scan only new blocks.
2176
- * Never prompts and never throws: null on any failure or scope mismatch.
2177
- */
2178
- findWithdrawalPayoutCandidates(evidence: FundingEvidence, opts?: {
2179
- fromBlock?: string;
2180
- cursor?: string;
2181
- submittedAt?: number;
2182
- }): Promise<WithdrawalPayoutScan | null>;
2183
- /** Resolve a saved sponsored-withdrawal ID without opening a wallet prompt. */
2184
- resolveSponsoredWithdrawalEvidence(evidence: FundingEvidence, options?: {
2185
- submittedAt?: number;
2186
- }): Promise<FundingEvidence>;
2187
- /** Recover an EIP-5792 deposit or payout using this account's exact batch ID. */
2188
- resolveWalletCallsFundingEvidence(evidence: FundingEvidence, direction: "deposit" | "withdraw"): Promise<FundingEvidence>;
2189
- /** Whether a foreground deposit can resume the same signed batch, never a
2190
- * fresh authorization. The batch rail independently rechecks the exact plan. */
2191
- canResumePendingDeposit(evidences: FundingEvidence[], amount: string): Promise<boolean>;
2192
- /** Whether a Permit2 deposit authorization can still execute and whether it
2193
- * did: `expired` when the finalized block is more than 300 s past
2194
- * `deadline` (chain time), `used` when the owner's Permit2 nonce bit is set
2195
- * at that block. Null when anything cannot be read. Never throws. */
2196
- checkDepositAuthorization(input: {
2197
- chainId: number;
2198
- owner: string;
2199
- token?: string;
2200
- permit2Nonce: string;
2201
- deadline: number;
2202
- }): Promise<{
2203
- expired: boolean;
2204
- used: boolean;
2205
- } | null>;
2206
- /** Drops the saved signed body of a hashless deposit the server may have
2207
- * been sending (`serverBroadcast` 'unknown'/true, no hash) once the app has
2208
- * settled it another way: by the ledger's hash or its expired deadline.
2209
- * Only the body with this Permit2 deadline and these exact shares is
2210
- * dropped, so it never resumes or blocks a different deposit. Never throws. */
2211
- discardSavedDepositBatch(evidences: FundingEvidence[]): Promise<boolean>;
2212
- /** Validate signed journal membership, never just a caller-supplied family ID. */
2213
- validateDepositReplacement(previous: FundingEvidence[], next: FundingEvidence[]): Promise<DepositReplacementValidation | undefined>;
2214
- /** Optional post-payout display proof; receipt verification and the provider
2215
- * adapter must agree before attaching it to this exact balance object. */
2216
- verifyWithdrawalBalance(evidence: FundingEvidence, balance: AgentBalance): Promise<AgentBalance>;
2217
- /** A display acknowledgement controls polling only; it never confirms a financial outcome. */
2218
- endFundingBalanceRefresh(evidence: FundingEvidence, read: AssetReadMetadata): boolean;
2219
- /** History lookup for receipt recovery; adapters may not authenticate or sign here. */
2220
- getFundingHistory(evidence: FundingEvidence, fromDate: string, options?: Pick<HistoryFilters, "cursor" | "toDate">): Promise<OwneyAgentHistory>;
2221
- recoverDepositRegistration(evidence: FundingEvidence): Promise<FundingEvidence>;
2222
- /** A Zyfai withdrawal's lifecycle by the id recorded on its evidence. Never signs,
2223
- * prompts or authenticates; `null` when unavailable or not this wallet's Zyfai withdrawal. */
2224
- getZyfaiWithdrawal(evidence: FundingEvidence): Promise<ZyfaiWithdrawalLifecycle | null>;
2225
- /** A Zyfai deposit's placement status by the id recorded on its evidence. Never signs,
2226
- * prompts or authenticates; `null` when unavailable or not this wallet's Zyfai deposit. */
2227
- getZyfaiDeposit(evidence: FundingEvidence): Promise<ZyfaiDepositPlacement | null>;
2228
- /** On-chain version and ownership status for this owner's Yieldseeker agent. */
2229
- getYieldseekerWalletStatus(asset: OwneySupportedTokens): Promise<YieldseekerWalletStatus | null>;
2230
- /** Deployment gate; an unavailable response keeps the current paid path. */
2231
- isYieldseekerWithdrawalSponsorshipAvailable(): Promise<boolean>;
2232
- isYieldseekerUpgradeSponsorshipAvailable(): Promise<boolean>;
2233
- private isYieldseekerSponsorshipAvailable;
2234
- /** Explicit V1-to-V2 upgrade, confirmed on chain before returning. */
2235
- upgradeYieldseekerWallet(asset: OwneySupportedTokens, gasMode?: "paid" | "sponsored"): Promise<{
2236
- txHash: viem.Hex;
2237
- status: YieldseekerWalletStatus;
2238
- }>;
2239
1363
  /** Lazily built so an app that never swaps pays nothing for it. */
2240
1364
  private swapApiClient?;
2241
1365
  private swapApi;
@@ -2296,11 +1420,29 @@ declare class OwneySDK {
2296
1420
  /** How much of `token` the wallet has already approved Permit2 to move. */
2297
1421
  private readTokenPermit2Allowance;
2298
1422
  /**
2299
- * Finish any user-paid Permit2 approval before measuring the deposit.
2300
- * Wallets can charge approval gas in the received token (ROUT-242/544).
2301
- * Cap the result at the swap arrival to preserve pre-existing wallet funds.
2302
- * Native Base/Arbitrum USDC uses sponsored ERC-2612; configured paymaster
2303
- * wallet calls also cover approval without spending the received tokens.
1423
+ * How much of a landed swap to actually deposit.
1424
+ *
1425
+ * The swap reports what ARRIVED, and the deposit used to be handed that
1426
+ * figure directly. It is the entire arrival, so there is no slack: anything
1427
+ * that spends the target asset between the two fails the deposit outright.
1428
+ *
1429
+ * Something does. A first WETH deposit needs a one-time Permit2 approval,
1430
+ * and that approval is a transaction. A wallet holding no native gas token -
1431
+ * the normal state of someone who just swapped everything INTO WETH - pays
1432
+ * for it out of the WETH. The deposit then asked for ~2e12 wei more than was
1433
+ * left and refused with DEPOSIT_INSUFFICIENT_BALANCE, under a wrapper saying
1434
+ * the funds were safe but unadded (ROUT-242).
1435
+ *
1436
+ * So the approval happens here, before the amount is settled, and the amount
1437
+ * comes from a read taken after it. Two things this deliberately is not:
1438
+ *
1439
+ * - It is not a balance sweep. `received` is a DELTA over the pre-swap
1440
+ * balance, so a wallet already holding WETH reads far above it; depositing
1441
+ * the balance would move funds the user never offered. The arrival is the
1442
+ * ceiling and the balance is only ever allowed to lower it.
1443
+ * - It does not touch USDC, which moves on signed typed data and so spends
1444
+ * nothing of the user's in between, nor a paymaster-configured client,
1445
+ * where the sponsor covers the transfer and Permit2 never applies.
2304
1446
  */
2305
1447
  private settleSwapDepositAmount;
2306
1448
  /**
@@ -2397,12 +1539,11 @@ declare class OwneySDK {
2397
1539
  * Every order is attempted even if an earlier one throws: they are unrelated
2398
1540
  * escrows, and one ending badly must not abandon the next one's secrets.
2399
1541
  * `unfinished` is not a verdict — the order may still settle, so unless the
2400
- * provider has confirmed full settlement or refund, its preimages are kept.
1542
+ * chain has said refunded or cancelled its preimages are kept.
2401
1543
  */
2402
1544
  resumePendingSwaps(options?: {
2403
1545
  onStage?: (orderHash: string, stage: SwapStage) => void;
2404
1546
  timeoutMs?: number;
2405
- orderHash?: string;
2406
1547
  }): Promise<{
2407
1548
  orderHash: string;
2408
1549
  status: "completed" | "unfinished";
@@ -2520,17 +1661,6 @@ declare class OwneySDK {
2520
1661
  /** Percent, classic rail only. Fusion+ prices through its auction. */
2521
1662
  slippage?: number;
2522
1663
  onSwapProgress?: (stage: SwapStage) => void;
2523
- /** Destination balance baseline, read after the swap and before deposit preparation. */
2524
- onBeforeDeposit?: () => Promise<void>;
2525
- onDepositProgress?: FundingProgress;
2526
- onBeforeDepositSubmission?: DepositOptions["onBeforeSubmission"];
2527
- /** Stop a stale foreground attempt before it prepares or sends another transaction. */
2528
- assertCurrent?: () => void;
2529
- /** Funding-ledger reference for this swap and its deposit. Generated when omitted. */
2530
- operationId?: string;
2531
- /** Groups this swap and deposit with the others started by one user action
2532
- * (see `DepositOptions.batchId`). Saved on the pending deposit record. */
2533
- batchId?: string;
2534
1664
  }): Promise<{
2535
1665
  swap: {
2536
1666
  received: string;
@@ -2544,24 +1674,6 @@ declare class OwneySDK {
2544
1674
  * want this one; `swap.received` stays what it says it is.
2545
1675
  */
2546
1676
  deposited: string;
2547
- /** Funding-ledger reference shared by the swap and its deposit. */
2548
- operationId?: string;
2549
- }>;
2550
- /** Read-only confirmation of a saved pre-swap withdrawal. Never withdraws or swaps. */
2551
- recheckWithdrawalSwap(id: string): Promise<WithdrawSwapRecord>;
2552
- /** Explicit foreground continuation: spends verified payouts, never withdraws again. */
2553
- continueWithdrawalSwap(id: string, callbacks?: Pick<Parameters<OwneySDK["withdrawAndSwap"]>[0], "onSwapProgress" | "onOrderSubmitted" | "onWithdrawalProgress" | "assertCurrent">): Promise<{
2554
- withdraw: OwneyWithdrawResult | AgentWithdrawResult;
2555
- /** What actually arrived in the wallet, smallest unit of the agent's asset. */
2556
- withdrawn: string;
2557
- swap: {
2558
- received: string;
2559
- spent?: string;
2560
- orderHash?: string;
2561
- txHash?: string;
2562
- };
2563
- /** Funding-ledger reference shared by the withdrawal and the swap. */
2564
- operationId?: string;
2565
1677
  }>;
2566
1678
  /**
2567
1679
  * Withdraw from an agent and swap the proceeds into whatever the user wants
@@ -2575,9 +1687,10 @@ declare class OwneySDK {
2575
1687
  * Quoting before the tokens land would size the swap against a balance that
2576
1688
  * is not there yet.
2577
1689
  *
2578
- * Wait for each participating agent's owner payout and size one swap from
2579
- * their confirmed net amounts. A first wallet increase cannot establish
2580
- * that every payout arrived. Failed or incomplete withdrawals stop here.
1690
+ * The swap is therefore sized from the MEASURED arrival, exactly as the
1691
+ * deposit path sizes its deposit from the measured swap output. On a full
1692
+ * withdrawal there is no other number available — "MAX" has no figure until
1693
+ * the agent picks one.
2581
1694
  *
2582
1695
  * **Failure here is not symmetrical with the deposit path.** A failed
2583
1696
  * deposit-swap leaves the user holding what they started with. A failed
@@ -2597,7 +1710,6 @@ declare class OwneySDK {
2597
1710
  to: {
2598
1711
  chainId: number;
2599
1712
  symbol: string;
2600
- decimals?: number;
2601
1713
  };
2602
1714
  /** Human units ("10.5"). Omit to withdraw the full agent balance. */
2603
1715
  amount?: string;
@@ -2605,8 +1717,6 @@ declare class OwneySDK {
2605
1717
  /** Percent, classic rail only. Fusion+ prices through its auction. */
2606
1718
  slippage?: number;
2607
1719
  onSwapProgress?: (stage: SwapStage) => void;
2608
- /** Receipt evidence for the existing funding/recovery tracker. */
2609
- onWithdrawalProgress?: FundingProgress;
2610
1720
  /**
2611
1721
  * Fires once the order is with the relayer, before the watch.
2612
1722
  *
@@ -2632,38 +1742,18 @@ declare class OwneySDK {
2632
1742
  withdrawn: string;
2633
1743
  /** Smallest unit of the destination — the auction's start, not its floor. */
2634
1744
  expected: string;
2635
- spent?: string;
2636
- durable?: boolean;
2637
1745
  }) => void;
2638
1746
  /** How long to wait for the withdrawal to land before giving up on the swap. */
2639
1747
  arrivalTimeoutMs?: number;
2640
- /** UI ownership fence, checked before each financial continuation. */
2641
- assertCurrent?: () => void;
2642
- /** Used only by explicit continueWithdrawalSwap; it never sends another withdrawal. */
2643
- recoveryId?: string;
2644
- /**
2645
- * Funding-ledger reference for this withdrawal and swap. Generated when
2646
- * omitted; a continuation reuses the one saved on its record.
2647
- */
2648
- operationId?: string;
2649
- /**
2650
- * Groups this withdrawal with the others started by one user action (see
2651
- * `WithdrawOptions.batchId`). Saved on the record, so a continuation
2652
- * reports into the same batch.
2653
- */
2654
- batchId?: string;
2655
1748
  }): Promise<{
2656
1749
  withdraw: OwneyWithdrawResult | AgentWithdrawResult;
2657
1750
  /** What actually arrived in the wallet, smallest unit of the agent's asset. */
2658
1751
  withdrawn: string;
2659
1752
  swap: {
2660
1753
  received: string;
2661
- spent?: string;
2662
1754
  orderHash?: string;
2663
1755
  txHash?: string;
2664
1756
  };
2665
- /** Funding-ledger reference shared by the withdrawal and the swap. */
2666
- operationId?: string;
2667
1757
  }>;
2668
1758
  /**
2669
1759
  * Withdraw funds from a specific agent, or all agents that support the active chain+asset if agentId is omitted.
@@ -2675,67 +1765,6 @@ declare class OwneySDK {
2675
1765
  * @returns {AgentWithdrawResult} for a single agent, or {OwneyWithdrawResult} with per-agent results
2676
1766
  */
2677
1767
  withdraw(options: WithdrawOptions): Promise<OwneyWithdrawResult | AgentWithdrawResult>;
2678
- /**
2679
- * Claims the cross-device hold for every agent in the plan. Returns the hold,
2680
- * or undefined when the reservation is off or the API is unavailable and the
2681
- * mode is fail-open. Throws only before anything is submitted:
2682
- * - `WITHDRAW_IN_PROGRESS` / `RESERVED_ELSEWHERE` on a 409;
2683
- * - `WITHDRAW_RESERVATION_UNAVAILABLE` when unavailable and fail-closed.
2684
- */
2685
- private reserveWithdrawal;
2686
- /**
2687
- * The cached Yieldseeker SIWE proof, when Yieldseeker is active for this
2688
- * SDK. Cache only: never prompts. Yieldseeker signs on Base, so a claim on
2689
- * another chain falls back to the Base proof (the server checks the
2690
- * signature, the address and its age, not the chain).
2691
- */
2692
- private peekReservationProof;
2693
- /**
2694
- * Releases or keeps each agent's hold when `withdraw()` ends. Never throws.
2695
- * - unattempted agents: `not_submitted`;
2696
- * - `confirmed` / definitively `failed` legs: released;
2697
- * - pending/unknown legs (Zyfai's hashless acknowledgement): kept;
2698
- * - a throw without submission evidence: `not_submitted`;
2699
- * - Zyfai "withdrawal already in progress": kept, dispatch `provider_in_progress`.
2700
- */
2701
- private settleWithdrawalReservation;
2702
- /**
2703
- * Releases a withdrawal reservation this browser still holds (the holder
2704
- * token is kept per operationId). Use it when the app learns the outcome of a
2705
- * kept hold, for example a Zyfai payout that arrived later. Never throws; a
2706
- * hold this SDK does not know about is left to the server's expiry.
2707
- */
2708
- releaseWithdrawalReservation(operationId: string, reason: ReservationReleaseReason, agents?: ReservationAgent[]): Promise<void>;
2709
- /**
2710
- * Reports a withdrawal step the app closed as never sent (a reload before its
2711
- * request was saved) as a failed ledger leg with `NOT_SUBMITTED`, so other
2712
- * devices and later recovery stop treating it as in flight. Refuses any step
2713
- * with a hash or a saved request. Never touches the hold; never throws.
2714
- */
2715
- reportWithdrawalNotSubmitted(operationId: string, evidence: FundingEvidence): Promise<void>;
2716
- /**
2717
- * Reports a withdrawal leg that was proven after its call ended (a hashless
2718
- * Zyfai payout found on chain or in history) to the funding ledger, then
2719
- * releases the withdrawal reservation this browser holds, as a fallback to
2720
- * the server's own release. Only evidence with a hash whose transfer and
2721
- * delivery are both confirmed is reported; anything else is ignored.
2722
- * The ledger PATCHes the existing operation (creating it only on a 404) and
2723
- * the server re-verifies the hash. Never throws.
2724
- */
2725
- reportWithdrawalRecovery(operationId: string, evidence: FundingEvidence): Promise<void>;
2726
- /**
2727
- * Reports a deposit leg that the app's recovery verified on chain after its
2728
- * call ended to the funding ledger. Only evidence whose transfer is confirmed
2729
- * with a transaction hash is reported; anything else is ignored. The ledger
2730
- * PATCHes the existing operation (creating it only on a 404) and the server
2731
- * re-verifies the hash. Deposits hold no reservation, so nothing is released.
2732
- * Never throws.
2733
- */
2734
- reportDepositRecovery(operationId: string, evidence: FundingEvidence): Promise<void>;
2735
- private withdrawFromAgents;
2736
- /** Read-only invalidation after new pool-deposit activity. Does not restart
2737
- * funding reconciliation, bypass cooldowns, or authorize a transaction. */
2738
- invalidateAllocationRead(scope: Pick<FundingEvidence, "agentId" | "walletAddress" | "chainId" | "token">): boolean;
2739
1768
  /**
2740
1769
  * Get the user's balances for a specific agent, or aggregated across all agents.
2741
1770
  * @param agentId - Optional. Agent to query. Omit for aggregated balances.
@@ -2754,13 +1783,7 @@ declare class OwneySDK {
2754
1783
  * @returns {OwneyWithdrawAllResult} one leg per position attempted.
2755
1784
  */
2756
1785
  withdrawAll(): Promise<OwneyWithdrawAllResult>;
2757
- getBalances(agentId?: AgentId, options?: {
2758
- chainId?: number;
2759
- asset?: OwneySupportedTokens;
2760
- }): Promise<OwneyBalances | AgentBalance>;
2761
- private readBalances;
2762
- /** Preserve failure objects for withdrawal recovery without changing public balance results. */
2763
- private readAggregatedBalances;
1786
+ getBalances(agentId?: AgentId): Promise<OwneyBalances | AgentBalance>;
2764
1787
  /**
2765
1788
  * Get the user's on-chain earnings for a specific agent, or aggregated across all agents.
2766
1789
  * @param agentId - Optional. Agent to query. Omit for aggregated earnings.
@@ -2772,7 +1795,6 @@ declare class OwneySDK {
2772
1795
  * Agents without a refresh capability fall back to their current snapshot.
2773
1796
  */
2774
1797
  refreshEarnings(agentId?: AgentId): Promise<OwneyEarnings | AgentEarnings>;
2775
- private aggregateEarnings;
2776
1798
  /**
2777
1799
  * Get the weighted APY for the user's account over a time period.
2778
1800
  * When querying all agents, the total APY is a balance-weighted average.
@@ -2782,8 +1804,10 @@ declare class OwneySDK {
2782
1804
  * @returns {AccountAgentApy} for a single agent, or {OwneyAccountApy} with totalApy and per-agent breakdown
2783
1805
  */
2784
1806
  /**
2785
- * Daily cumulative earnings in the selected asset's units, backing the
2786
- * "recent earnings" subline. Each adapter uses its provider's earnings basis.
1807
+ * Daily cumulative NET earnings for the selected chain/asset, backing the
1808
+ * "recent earnings" subline. Net is computed as Zyfai's own
1809
+ * `lifetime + unrealized + current x 0.9`, so the figure reconciles with the
1810
+ * balance headline rather than reading ~11% high. (ROUT-452)
2787
1811
  *
2788
1812
  * Unlike getAccountApy this does NOT blend across agents: earnings are
2789
1813
  * summed, not weighted, and an agent that fails to report must not silently
@@ -2857,17 +1881,14 @@ declare class OwneySDK {
2857
1881
  */
2858
1882
  ensureAutoSelectProtocols(asset: "USDC" | "WETH", agentId?: AgentId): Promise<boolean>;
2859
1883
  /**
2860
- * User-paid approval of Permit2 on the selected token for the active chain.
2861
- * Grants the maximum ERC20 allowance so later deposits do not require another
2862
- * approval. Resolves after one confirmation so the subsequent deposit attempt
2863
- * sees the new allowance. Deposit retries pass their captured chain id so a
2864
- * concurrent activation cannot redirect the approval to another network.
2865
- *
2866
- * @param requiredAmount Raw base-unit amount the pending deposit must cover.
2867
- * @param expectedChainId Chain captured by the deposit that requested approval.
1884
+ * One-time, user-paid approval of Permit2 on the sponsored WETH token for
1885
+ * the active chain. Required once per wallet per chain before gasless WETH
1886
+ * deposits; afterwards deposit() is signature-only. Resolves only after the
1887
+ * approval transaction is mined (1 confirmation), so a subsequent deposit()
1888
+ * will see the new allowance; throws if the transaction reverted.
2868
1889
  * @returns the approval transaction hash.
2869
1890
  */
2870
- approvePermit2(asset?: OwneySupportedTokens, requiredAmount?: bigint, expectedChainId?: OwneySupportedChainId, assertCurrent?: () => void): Promise<`0x${string}`>;
1891
+ approvePermit2(asset?: "WETH"): Promise<`0x${string}`>;
2871
1892
  /**
2872
1893
  * Get the agent's average APY performance over a time period. Does not require a wallet connection.
2873
1894
  * @param options - Contains agentId (optional) and days ("7D", "14D", or "30D")
@@ -2891,377 +1912,6 @@ declare class OwneySDK {
2891
1912
  getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
2892
1913
  }
2893
1914
 
2894
- type YieldseekerAuthToken = {
2895
- message: string;
2896
- signature: Hex;
2897
- };
2898
- type YieldseekerAuthDependencies = {
2899
- origin?: string;
2900
- now?: () => Date;
2901
- nonce?: () => string;
2902
- };
2903
-
2904
- type YieldseekerFetch = typeof fetch;
2905
-
2906
- type YieldseekerTransaction = {
2907
- from: `0x${string}`;
2908
- to: `0x${string}`;
2909
- data: `0x${string}`;
2910
- value: string;
2911
- chainId: number;
2912
- };
2913
-
2914
- type YieldseekerWalletStatus = {
2915
- agentWallet: Address;
2916
- owner: Address;
2917
- ownerPath: "eoa" | "smart";
2918
- asset: Address;
2919
- implementation: Address;
2920
- version: "v1" | "v2" | "unknown";
2921
- upgradeAvailable: boolean;
2922
- /** The factory, owner, base asset, and provider wallet mapping all agree. */
2923
- verified: boolean;
2924
- };
2925
-
2926
- type YieldseekerAgentOptions = {
2927
- baseUrl?: string;
2928
- routingApiBaseUrl?: string;
2929
- fetchFn?: YieldseekerFetch;
2930
- auth?: YieldseekerAuthDependencies;
2931
- /** Dedicated read transport; Base is used for receipt polling. */
2932
- rpcUrls?: RpcUrlsConfig;
2933
- /** Test seam for the wallet-submission/receipt boundary. */
2934
- transactionExecutor?: (state: ConnectionState, chainId: number, transaction: YieldseekerTransaction, onReceipt?: (receipt: viem.TransactionReceipt) => void) => Promise<Hex>;
2935
- /** Test seam for transactions submitted outside transactionExecutor. */
2936
- unwindReceiptWaiter?: (state: ConnectionState, chainId: number, transactionHash: Hex) => Promise<void>;
2937
- };
2938
- declare class YieldseekerAgent implements IAgent {
2939
- readonly id = "yieldseeker";
2940
- readonly balanceComposition: "tokens-plus-positions";
2941
- readonly withdrawalRequiresWalletApproval = true;
2942
- readonly supportedChainIds: readonly [8453];
2943
- readonly supportedAssets: readonly [{
2944
- readonly chainId: 8453;
2945
- readonly chain: "BASE";
2946
- readonly assets: readonly [{
2947
- readonly symbol: "USDC";
2948
- readonly minDepositAmount: "10000000";
2949
- }, {
2950
- readonly symbol: "WETH";
2951
- readonly minDepositAmount: "1";
2952
- }];
2953
- }];
2954
- private readonly api;
2955
- private readonly auth;
2956
- private readonly rpcUrls?;
2957
- private readonly owneyApiKey;
2958
- private readonly routingApiBaseUrl?;
2959
- private receiptClient?;
2960
- private readonly withdrawalVersionCache;
2961
- private readonly pendingWalletStatus;
2962
- /** Lowercase Agent Wallet -> when this instance's deploy request succeeded. */
2963
- private readonly recentDeployments;
2964
- private readonly pendingUpgrades;
2965
- private readonly transactionExecutor?;
2966
- private readonly unwindReceiptWaiter?;
2967
- private readonly agentContexts;
2968
- private readonly walletContexts;
2969
- private readonly agentAccountReads;
2970
- private readonly reportedAccounts;
2971
- private readonly missingSlots;
2972
- private readonly freshListReads;
2973
- private readonly knownContextKeys;
2974
- private readonly pendingSlotInvalidations;
2975
- private readonly balanceContexts;
2976
- private readonly balanceVaults;
2977
- private readonly users;
2978
- private readonly pendingAgents;
2979
- private readonly pendingWalletContexts;
2980
- private readonly readCache;
2981
- private readonly pendingReads;
2982
- private readGeneration;
2983
- private readonly portfolioVersions;
2984
- private readonly liquidityVersions;
2985
- private readonly snapshotFailures;
2986
- private readonly standardReadFailures;
2987
- private readonly endpointReadFailures;
2988
- private readonly reconcileUntil;
2989
- private readonly allocationRefresh;
2990
- /** Contexts whose next permitted snapshot read is forced once: a funding
2991
- * invalidation with a tx hash (receipt recovery, a re-armed refresh). */
2992
- private readonly forceNextSnapshot;
2993
- private readonly activityRefreshUntil;
2994
- private readonly snapshotMovements;
2995
- private readonly movementEpochs;
2996
- private readonly settlementChecks;
2997
- private ledgerAccess?;
2998
- private readonly ledgerReads;
2999
- /** contextKey -> movements this instance started settling (by tx hash) and how they refresh:
3000
- * awaiting the ledger, refreshed when ready (ledger), or on the timed backoff (legacy). */
3001
- private readonly localMovements;
3002
- /** contextKey -> tx hash -> refresh-when-ready state of a ledger movement. */
3003
- private readonly refreshPlans;
3004
- /** contextKey -> the agent's ledger movements from the latest ledger read. */
3005
- private readonly ledgerMovementCache;
3006
- /** Contexts whose next snapshot request is a refresh-when-ready force. */
3007
- private readonly readyForces;
3008
- private readonly serverBaselines;
3009
- private readonly snapshotHistory;
3010
- /** contextKey -> the history key its refresh plans persist forced times under. */
3011
- private readonly planHistoryKeys;
3012
- /** A ledger read slower than this counts as "no ledger information" for that read. */
3013
- private ledgerBudgetMs;
3014
- /** slotKey -> the last successful ledger rows and when they arrived. */
3015
- private readonly lastLedgerRows;
3016
- private readonly vaultOptions;
3017
- private readonly pendingVaultOptions;
3018
- private readonly assetApyStats;
3019
- private readonly pendingAssetApyStats;
3020
- constructor(owneyApiKey: string, options?: YieldseekerAgentOptions);
3021
- private getReceiptClient;
3022
- /** Reads the actual proxy implementation; Yieldseeker's API walletType is not a version check. */
3023
- getWalletStatus(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, useCachedV2?: boolean): Promise<YieldseekerWalletStatus | null>;
3024
- /** Reads (or reuses the 15-minute verified V2 hint for) this exact context's wallet. */
3025
- private readWalletStatus;
3026
- /**
3027
- * Deposits go only to a wallet whose identity is verified on chain (factory
3028
- * mapping, owner, base asset, FACTORY). The API key is public, so the wallet
3029
- * the provider API returned is not trusted on its own. V1 wallets still
3030
- * accept deposits: only identity is required, not the V2 implementation.
3031
- * A failed read fails closed (reason UNAVAILABLE): an unverified wallet never
3032
- * receives funds. Session changes keep their own NOT_CONNECTED error.
3033
- */
3034
- private assertDepositWalletVerified;
3035
- private rememberWalletStatus;
3036
- /** Explicit owner action. This never runs as a side effect of withdrawal. */
3037
- upgradeWallet(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, gasMode?: "paid" | "sponsored"): Promise<{
3038
- txHash: Hex;
3039
- status: YieldseekerWalletStatus;
3040
- }>;
3041
- disconnect(): Promise<void>;
3042
- activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
3043
- deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback, onProgress?: FundingProgress, onBeforeSubmission?: (evidence: FundingEvidence) => void | Promise<void>): Promise<OwneyDepositResult>;
3044
- withdraw(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, amount?: string, onProgress?: FundingProgress, gasMode?: "auto" | "sponsored" | "paid", onBeforeSubmission?: FundingProgress, assertOperation?: () => void, submission?: {
3045
- operationId?: string;
3046
- }): Promise<AgentWithdrawResult>;
3047
- private withdrawInternal;
3048
- /** Fresh position amounts for withdrawal planning, net of reserved fees. */
3049
- getWithdrawableBalance(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, minimumAmount?: bigint): Promise<bigint>;
3050
- /**
3051
- * The cached SIWE proof, decoded, for the withdrawal reservation claim's
3052
- * owner proof. Only a proof already in the cache: this never prompts the
3053
- * wallet and never throws. Never log the result.
3054
- */
3055
- peekReservationProof(state: ConnectionState, chainId: number): YieldseekerAuthToken | undefined;
3056
- /** Recheck MAX without re-unwinding, paying out, or requesting a signature. */
3057
- verifyWithdrawalCompletion(state: ConnectionState, evidence: FundingEvidence): Promise<WithdrawalCompletion>;
3058
- private readVaultShares;
3059
- private validateWithdrawalPositions;
3060
- private withdrawalVaultHints;
3061
- private readWithdrawalPositions;
3062
- private resolveWithdrawalLiquidity;
3063
- hasReadSession(state: ConnectionState, chainId: number): boolean;
3064
- getBalances(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<AgentBalance>;
3065
- verifyWithdrawalBalance(state: ConnectionState, evidence: FundingEvidence, balance: AgentBalance): Promise<AssetReadMetadata | undefined>;
3066
- invalidateAllocationRead(state: ConnectionState, chainId: number, asset: OwneySupportedTokens): void;
3067
- invalidateFundingRead(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, refreshUntil?: number, txHash?: string): void;
3068
- endFundingBalanceRefresh(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, read: AssetReadMetadata): boolean;
3069
- getFundingWallet(state: ConnectionState, chainId: number, asset: OwneySupportedTokens): Promise<string>;
3070
- hasExistingDepositFunds(state: ConnectionState, chainId: number, asset: OwneySupportedTokens): Promise<true | undefined>;
3071
- getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
3072
- getAccountApy(state: ConnectionState, chainId: number, days: DailyApyDays, tokenSymbol?: string,
3073
- /** The chart's chain filter (ROUT-479); null is every chain. */
3074
- scopeChainId?: number | null): Promise<AccountAgentApy>;
3075
- getDailyEarnings(state: ConnectionState, chainId: number, days: LookbackDays, tokenSymbol?: string): Promise<AccountDailyEarnings>;
3076
- getHistory(state: ConnectionState, chainId: number, options?: HistoryFilters): Promise<OwneyAgentHistory>;
3077
- getUserProfile(state: ConnectionState, chainId: number): Promise<AgentUserProfile>;
3078
- getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
3079
- supportsAgentApyPeriod(days: DailyApyDays): boolean;
3080
- private loadAssetApyStats;
3081
- private loadVaultOptions;
3082
- private userKey;
3083
- /** One deposit/withdraw slot: owner, chain and asset. */
3084
- private slotKey;
3085
- /**
3086
- * One agent's portfolio state. Includes the agentId so duplicate or renamed
3087
- * agents for the same asset never share caches, versions or settlement.
3088
- */
3089
- private contextKey;
3090
- /**
3091
- * Context keys an asset-only call applies to: the selected agent when known,
3092
- * else every agent of the slot seen this session.
3093
- */
3094
- private slotContextKeys;
3095
- /**
3096
- * Apply an asset-only invalidation. Before any agent of the slot resolves,
3097
- * queue it so the first resolved agents still see it (as the slot-keyed
3098
- * state did before contexts were keyed by agentId).
3099
- */
3100
- private invalidateSlot;
3101
- /** Record the selected agent for a slot; queued invalidations are now settled. */
3102
- private selectContext;
3103
- private assertSession;
3104
- private cachedRead;
3105
- private agentListKey;
3106
- private listAgents;
3107
- /**
3108
- * The routing API's stored accounts for owner+chain, read once per session.
3109
- * Resolves null when unavailable (callers keep name matching) and never
3110
- * rejects. A failure is retried after a short window.
3111
- */
3112
- private agentAccounts;
3113
- /** Yieldseeker accounts for one slot (returned addresses are compared lowercase). */
3114
- private slotAccounts;
3115
- private agentFits;
3116
- /**
3117
- * The listed agent of the slot whose resolved wallet is in the
3118
- * highest-priority set of `priorities` (index 0 first). Hinted agentIds are
3119
- * resolved first and a hinted top-priority match ends the search; then other
3120
- * listed agents, at most YIELDSEEKER_WALLET_MATCH_LIMIT wallets in total.
3121
- */
3122
- private agentWithWallet;
3123
- /**
3124
- * chooseAgent, re-reading a cached list once (bypassing its cache) when the
3125
- * verified agent is missing. A slot still missing after that re-read is
3126
- * remembered for the list cache window, so later reads fail from the cached
3127
- * list without another re-read.
3128
- */
3129
- private chooseAgentRefreshing;
3130
- private isSlotMissing;
3131
- /**
3132
- * The agent that serves deposits and withdrawals for a slot (Ruling 23):
3133
- * 1. the listed fitting agent whose wallet is the verified account's wallet,
3134
- * whatever its name; the stored agentId is only a hint;
3135
- * 2. else a listed fitting agent whose wallet is a superseded account's wallet;
3136
- * 3. else the fitting agent named "owney" (first use, migration, or a
3137
- * verified wallet that is not a fitting listed agent);
3138
- * 4. else, with a verified account, throw YIELDSEEKER_AGENT_MISSING (never
3139
- * create); without one, undefined (the caller may create).
3140
- * Steps 1 and 2 share one search of at most YIELDSEEKER_WALLET_MATCH_LIMIT
3141
- * wallet reads. The account report then records the selected wallet; the
3142
- * server marks it superseded when it differs from the verified wallet.
3143
- */
3144
- private chooseAgent;
3145
- private isAgentMissing;
3146
- private agentMissing;
3147
- /**
3148
- * Fire-and-forget: record which agent serves this slot. Never awaited on the
3149
- * funds path and never throws; once per agent wallet and deployment state
3150
- * per session.
3151
- */
3152
- private reportAccount;
3153
- private contextForAgent;
3154
- private resolveUser;
3155
- private forgetUser;
3156
- private ensureAgent;
3157
- private findAgent;
3158
- private resolveAgent;
3159
- /** Create the slot's agent. Only reached when no stored or named agent matched. */
3160
- private createAgent;
3161
- /**
3162
- * The routing create lock refused the create: another tab or app owns or is
3163
- * creating this slot's agent. Re-read the accounts and the list (bypassing
3164
- * their caches) and select that agent, once more after 2 s if needed. A
3165
- * verified account is matched by wallet; otherwise the returned agentId is
3166
- * used. Never creates again.
3167
- */
3168
- private adoptConflictingAgent;
3169
- private loadPortfolio;
3170
- private loadActivityPortfolio;
3171
- private resolvePortfolioContexts;
3172
- private portfolioVersion;
3173
- /** Snapshot cache lifetime: the settlement backoff while a movement is being
3174
- * checked, otherwise the routine non-forced cadence. */
3175
- private portfolioCacheMs;
3176
- /** A pending movement inside its ten-minute window. */
3177
- private settlementWindow;
3178
- /** A pending movement inside its ten-minute window forces snapshots, unless
3179
- * every movement being settled is refreshed when ready through the ledger. */
3180
- private settling;
3181
- /** Start a new forced-check schedule, or keep the active one. */
3182
- private beginSettlement;
3183
- private snapshotMovement;
3184
- private advancePortfolioVersion;
3185
- private requestPortfolioSnapshot;
3186
- private snapshotPath;
3187
- /** True while `walletRequest` would refuse a read of `path`: this user's
3188
- * rate-limit cooldown or that endpoint's outage cooldown. */
3189
- private readCoolingDown;
3190
- private portfolioSnapshot;
3191
- private loadPortfolioContext;
3192
- private loadActivityContext;
3193
- private loadPortfolioParts;
3194
- private deployAgent;
3195
- setFundingLedgerAccess(access: AgentFundingLedgerAccess | undefined): void;
3196
- private historyKey;
3197
- /** Funding-ledger rows for this slot, cached 15 s. Never throws: null on any failure. */
3198
- private readLedger;
3199
- /**
3200
- * A ledger read within the read budget. On a timeout or failure, the last
3201
- * successful rows are reused if at most 60 s old (no hold flicker); older
3202
- * means null, i.e. today's behaviour.
3203
- */
3204
- private readLedgerBudgeted;
3205
- private ledgerMovementsFor;
3206
- /** Track a movement this instance is settling. With ledger access and a tx
3207
- * hash it awaits the ledger; otherwise it keeps the timed backoff. */
3208
- private trackLocalMovement;
3209
- /** Timed (legacy) entries end with their ten-minute window; ledger ones after the one-hour index window. */
3210
- private pruneLocalMovements;
3211
- private hasAwaitingMovement;
3212
- /** Every movement being settled here is (or may yet be) refreshed when ready through the ledger. */
3213
- private deferredToLedger;
3214
- /** A null ledger sends every local movement back to the timed backoff; a
3215
- * listed tx hash is refreshed when ready; an unlisted one after the grace too. */
3216
- private resolveLocalMovements;
3217
- /**
3218
- * Refresh when ready, before a portfolio read: read the ledger (cached) when
3219
- * an earnings read asks for it or a movement is being tracked, update each
3220
- * recent movement's plan, poll the provider's history (non-forced, 15 s
3221
- * cache) for un-indexed tx hashes, and mark the next snapshot as forced when
3222
- * a plan is due. Never throws.
3223
- */
3224
- private prepareLedgerRefresh;
3225
- /** Apply one ledger read to local movements and refresh plans. False when the ledger is unavailable. */
3226
- private applyLedgerRows;
3227
- private updateRefreshPlans;
3228
- /** Non-forced provider history read (15 s cache) to learn when a tx hash is indexed. */
3229
- private pollIndexing;
3230
- /** The forced snapshot about to be requested counts for every plan that is
3231
- * due. False (do not force) when none is. */
3232
- private noteReadyForce;
3233
- private recordSnapshotHistory;
3234
- private localHistory;
3235
- /** After a snapshot: if this SDK's own history shows every recent ledger
3236
- * movement in net deposits, no plan needs (more) forcing. */
3237
- private checkLocalBooking;
3238
- /** The newest server sample observed at or before `cutoff`, cached. Null when none or on failure. */
3239
- private serverBaseline;
3240
- /**
3241
- * Earnings hold (spec B2): while a recent ledger movement is not booked by
3242
- * the provider, report the last good `cumulativeYieldBase`. The balance is
3243
- * untouched. Any missing input (no ledger, no baseline) or failure returns
3244
- * the provider's value. Never throws.
3245
- */
3246
- private applyEarningsHold;
3247
- private refreshSnapshotAfterMovement;
3248
- private agentPath;
3249
- private walletRequest;
3250
- private providerRequest;
3251
- private mapApiError;
3252
- private submitTransaction;
3253
- private waitForReceipt;
3254
- private assertTransaction;
3255
- private assertAgent;
3256
- private isOwneyAgent;
3257
- private assetForAgent;
3258
- private isTransactionHash;
3259
- private assertChain;
3260
- private assertOptionalChain;
3261
- private assertAsset;
3262
- private invalidResponse;
3263
- }
3264
-
3265
1915
  declare class InvalidHistoryCursorError extends Error {
3266
1916
  readonly code: "invalid_cursor";
3267
1917
  constructor(message: string);
@@ -3303,6 +1953,23 @@ type OwneySIWXConfig = {
3303
1953
  */
3304
1954
  declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
3305
1955
 
1956
+ /**
1957
+ * Ask the wallet ITSELF to switch networks, over WalletConnect.
1958
+ *
1959
+ * WalletConnect's provider answers `wallet_switchEthereumChain` locally when
1960
+ * the chain was approved at connect time: it moves its own default chain and
1961
+ * reports success without telling the wallet. MetaMask mobile then stays on
1962
+ * its network, keeps reporting it, and every guard downstream fails with
1963
+ * CHAIN_MISMATCH — after a swap, with the user's funds already moved (ROUT-727).
1964
+ * Sending the request through the session client reaches the wallet, which
1965
+ * shows a real "switch network" prompt; the client also deep-links the wallet
1966
+ * app open on mobile.
1967
+ *
1968
+ * Returns false when `provider` is not a WalletConnect session, so the caller
1969
+ * can fall back to an ordinary switch.
1970
+ */
1971
+ declare function switchWalletConnectChain(provider: unknown, chainId: number, timeoutMs?: number): Promise<boolean>;
1972
+
3306
1973
  /**
3307
1974
  * Persists cross-chain swap secrets so an in-flight order survives a reload.
3308
1975
  *
@@ -3321,7 +1988,6 @@ declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
3321
1988
  */
3322
1989
  type StoredOrder = {
3323
1990
  orderHash: string;
3324
- walletAddress?: string;
3325
1991
  /** Preimages, one per fill. Index matters — fill N needs secret N. */
3326
1992
  secrets: string[];
3327
1993
  /** Chain the funds left from, so a resumed session can report it. */
@@ -3331,107 +1997,13 @@ type StoredOrder = {
3331
1997
  dstSymbol: string;
3332
1998
  dstChainId: number;
3333
1999
  amount: string;
3334
- /** Epoch ms, for ordering recovery records. */
2000
+ /** Epoch ms. Used to drop orders far past any plausible timelock. */
3335
2001
  createdAt: number;
3336
- /**
3337
- * A swap-deposit's deposit half, so a resume that finishes the swap can
3338
- * record it (ROUT-625). `received` is the quote's guaranteed minimum. Absent
3339
- * on plain swaps and on records written by an older SDK.
3340
- */
3341
- pendingDeposit?: {
3342
- received: string;
3343
- symbol: string;
3344
- chainId: number;
3345
- agentId?: string;
3346
- operationId?: string;
3347
- /** The user action's batch (see `DepositOptions.batchId`), carried to the recorded pending deposit. */
3348
- batchId?: string;
3349
- };
3350
- /**
3351
- * Our routing API accepted these secrets (part 5's opt-in handoff) and
3352
- * publishes them itself once 1inch is ready. Informational: this browser
3353
- * still publishes and resumes as before. Absent when no handoff was accepted.
3354
- */
3355
- serverSecrets?: true;
3356
2002
  };
3357
2003
  /**
3358
- * Every unresolved stored order, newest first.
2004
+ * Every stored order, newest first, dropping anything past MAX_AGE_MS.
3359
2005
  * Used on mount to resume orders the user left in flight.
3360
2006
  */
3361
- declare function listOrders(_now?: number): StoredOrder[];
3362
-
3363
- /**
3364
- * Capability flag (part 5): this SDK can hand a signed Fusion+ order's secrets
3365
- * to the routing API (`handoffSecrets`), which then publishes each one when
3366
- * 1inch is ready, even if this tab is gone. Older builds do not export this.
3367
- */
3368
- declare const FUSION_SECRET_SERVER_PUBLISH: 1;
3369
-
3370
- /**
3371
- * Non-blocking funding ledger reporter.
3372
- *
3373
- * Reports each funding operation (deposit / withdraw / swap) to the routing
3374
- * API's `/api/v1/funding/operations` endpoints so support can reconstruct what
3375
- * happened. Hard rule: reporting NEVER blocks or fails a funding action.
3376
- *
3377
- * - `start()` / `leg()` / `finish()` are synchronous and never throw.
3378
- * - Requests run on a per-operation promise chain, create first.
3379
- * - Every error is swallowed (visible only with debug logging on).
3380
- */
3381
- /** Set by tsup's `define`; "dev" when running from source. */
3382
- declare const SDK_VERSION: string;
3383
- type LedgerLegReport = {
3384
- legKey: string;
3385
- legKind: "agent" | "swap" | "approval";
3386
- agentType?: string;
3387
- agentWallet?: string;
3388
- rail?: string;
3389
- amountRaw?: string;
3390
- status?: "created" | "submitted" | "unknown" | "failed" | "confirmed";
3391
- txHash?: string;
3392
- userOpHash?: string;
3393
- callsId?: string;
3394
- orderHash?: string;
3395
- /** The provider's own id for this leg's request (Zyfai's v2 withdrawal id). */
3396
- providerRef?: string;
3397
- confirmedAmountRaw?: string;
3398
- blockNumber?: string;
3399
- errorCode?: string;
3400
- swap?: {
3401
- rail: "swap_classic" | "swap_fusion" | "swap_fusion_plus";
3402
- srcChainId: number;
3403
- dstChainId: number;
3404
- srcToken: string;
3405
- dstToken: string;
3406
- srcAmountRaw: string;
3407
- quotedDstAmountRaw?: string;
3408
- receivedDstAmountRaw?: string;
3409
- feeBps?: number;
3410
- feeBpsSource?: "measured" | "stated";
3411
- feeToken?: string;
3412
- };
3413
- };
3414
-
3415
- /** This SDK hands every Zyfai withdrawal request to the caller's
3416
- * `onBeforeSubmission` before sending it, and a failed checkpoint stops it.
3417
- * A caller that persisted nothing for a dead run can therefore conclude the
3418
- * request was never sent. Older builds do not export this. */
3419
- declare const ZYFAI_WITHDRAW_DISPATCH_CHECKPOINT: 1;
3420
-
3421
- /** Capability flag: this SDK opts in to the server sending an accepted
3422
- * sponsored deposit itself (prepare `serverBroadcast: true`) and reports such a
3423
- * deposit as pending, never "not sent". Older builds do not export this. */
3424
- declare const SPONSORED_DEPOSIT_SERVER_BROADCAST: 1;
3425
-
3426
- /** Capability flag: this SDK opts in to the server sending its signed sponsored
3427
- * Yieldseeker withdrawal userOp itself (`serverSubmit=1` on its own
3428
- * `eth_sendUserOperation`) and reports such a leg as pending, never "not sent".
3429
- * Older builds do not export this. */
3430
- declare const YIELDSEEKER_WITHDRAW_SERVER_SUBMIT: 1;
3431
-
3432
- /** Capability flag: this SDK has `reportDepositRecovery`, which reports a
3433
- * deposit leg the app's recovery verified on chain to the funding ledger.
3434
- * Older builds do not export this. */
3435
- declare const FUNDING_DEPOSIT_RECOVERY_REPORT: 1;
2007
+ declare function listOrders(now?: number): StoredOrder[];
3436
2008
 
3437
- export { type AccountAgentApy, type AccountApyOptions, type AccountDailyEarnings, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentFundingLedgerAccess, type AgentHistoryEntry, type AgentHistoryPosition, type AgentId, AgentNotFoundError, type AgentSupportedAsset, type AgentSupportedAssets, type AgentUserProfile, type AgentWithdrawResult, type AgentsApyOptions, type AllocationAgentApy, type AllocationApyOptions, type ApyByChainAndAsset, type ApyCoverage, type ApyHistoryPoint, type Asset, type AssetDailyEarnings, type AssetReadMetadata, type AvailableAgent, type AvailableAgentsOptions, type AvailablePool, type ConnectionState, type DailyApyDays, type DailyEarningsOptions, type DailyEarningsPoint, type DepositAuthorizationReference, type DepositCallback, type DepositOptions, type DepositReplacementValidation, FUNDING_DEPOSIT_RECOVERY_REPORT, FUSION_SECRET_SERVER_PUBLISH, type FundingEvidence, type FundingOperationKind, type FundingOperationLeg, type FundingOperationRow, type FundingProgress, type FundingStage, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, type LedgerLegReport, type LookbackDays, NotConnectedError, type OrgPoolPolicy, type OrgPoolSelection, 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 OwneyWithdrawAllLeg, type OwneyWithdrawAllResult, type OwneyWithdrawResult, type PendingDeposit, type PoolCatalogProtocol, type PoolSelectionStrategy, type ProviderSnapshotSample, type RebalanceLog, type ReservationAgent, type ReservationReleaseReason, type RpcUrlsConfig, SDK_VERSION, SPONSORED_DEPOSIT_SERVER_BROADCAST, type SavedPoolSelection, type SwapChainTokens, type SwapDirection, type SwapOrderStatus, type SwapQuote, type SwapQuoteParams, type SwapRail, type SwapStage, type SwapTokenInfo, type SwapTokenSearchResult, type UnsignedUserOperationEvidence, type UserPoolSelection, type UserPoolSelectionRequest, type WithdrawOptions, type WithdrawSwapRecord, type WithdrawSwapStatus, type WithdrawalCompletion, type WithdrawalCompletionContext, type WithdrawalPayoutCandidate, type WithdrawalPayoutScan, type WithdrawalReservationConflict, type WithdrawalReservationMode, type WithdrawalReservationOptions, type WithdrawalSwapRecovery, YIELDSEEKER_WITHDRAW_SERVER_SUBMIT, YieldseekerAgent, type YieldseekerWalletStatus, ZYFAI_REGISTRATION_NOT_SENT_CODES, ZYFAI_SERVER_TASKS, ZYFAI_WITHDRAWAL_NOT_SENT_CODES, ZYFAI_WITHDRAW_DISPATCH_CHECKPOINT, type ZyfaiDepositPlacement, type ZyfaiRpcUrlsConfig, type ZyfaiWithdrawalLifecycle, clearWithdrawSwap, createOwneySIWX, listPendingDeposits, listOrders as listPendingSwaps, listWithdrawSwaps, saveWithdrawSwap, setOwneyDebug, subscribeWithdrawSwaps, updateWithdrawSwap };
2009
+ export { type AccountAgentApy, type AccountApyOptions, type AccountDailyEarnings, type ActivateAgentOptions, 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 ApyCoverage, type ApyHistoryPoint, type Asset, type AssetDailyEarnings, type AvailableAgent, type AvailableAgentsOptions, type AvailablePool, 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 OrgPoolPolicy, type OrgPoolSelection, 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 OwneyWithdrawAllLeg, type OwneyWithdrawAllResult, type OwneyWithdrawResult, type PendingDeposit, type PoolCatalogProtocol, type PoolSelectionStrategy, type RebalanceLog, type SavedPoolSelection, type SwapChainTokens, type SwapDirection, type SwapOrderStatus, type SwapQuote, type SwapQuoteParams, type SwapRail, type SwapStage, type SwapTokenInfo, type SwapTokenSearchResult, type UserPoolSelection, type UserPoolSelectionRequest, type WithdrawOptions, type WithdrawSwapRecord, type WithdrawSwapStatus, clearWithdrawSwap, createOwneySIWX, listPendingDeposits, listOrders as listPendingSwaps, listWithdrawSwaps, saveWithdrawSwap, setOwneyDebug, subscribeWithdrawSwaps, switchWalletConnectChain, updateWithdrawSwap };