@owney/sdk 0.7.32-beta.1 → 0.7.32-beta.11

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
@@ -275,6 +275,13 @@ type FundingOperationLeg = {
275
275
  * "definitely not booked".
276
276
  */
277
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;
278
285
  };
279
286
  /** One ledger operation, as the API returns it. */
280
287
  type FundingOperationRow = {
@@ -356,6 +363,15 @@ interface OwneySDKConfig {
356
363
  * already-deployed app: set `globalThis.__OWNEY_DEBUG__ = true` in devtools.
357
364
  */
358
365
  debug?: boolean;
366
+ /**
367
+ * When true, the organization's pool policy is NOT applied on connect, so a
368
+ * user's own deposit-time pool selection (ROUT-569) is never overwritten by
369
+ * the org-level one on their next reconnect. Splitting and the rest of the
370
+ * org policy still apply. Turn this on in apps that expose the deposit-time
371
+ * Pools step (the spread flow); leave it off where the partner dashboard's
372
+ * pool customization is the source of truth.
373
+ */
374
+ userPoolCustomization?: boolean;
359
375
  /**
360
376
  * Absolute URL of an ERC-7677 paymaster service. When set, deposits go out as
361
377
  * an EIP-5792 `wallet_sendCalls` with `capabilities.paymasterService`, so a
@@ -380,11 +396,45 @@ interface OwneySDKConfig {
380
396
  * `OWNEY_WITHDRAWAL_RESERVATION_DISABLED=1` in the environment acts as `"off"`.
381
397
  */
382
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;
383
425
  }
384
426
  interface ConnectionState {
385
427
  provider: any;
386
428
  walletAddress: `0x${string}`;
387
429
  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, and by every read
434
+ * of an agent that did not sign in this session (it failed while another
435
+ * agent signed in, or the user cancelled its sign-in).
436
+ */
437
+ promptless?: boolean;
388
438
  }
389
439
  declare const SUPPORTED_TOKENS: readonly ["USDC", "WETH"];
390
440
  declare const SUPPORTED_CHAIN_IDS: readonly [8453, 42161, 1];
@@ -393,6 +443,44 @@ type OwneySupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
393
443
  type OwneySupportedChains = (typeof SUPPORTED_CHAINS)[number];
394
444
  type OwneySupportedTokens = (typeof SUPPORTED_TOKENS)[number];
395
445
 
446
+ /** Capability flag: this SDK can hand Zyfai withdrawals and deposit
447
+ * registrations to the server, and marks such legs with evidence `serverTask`.
448
+ * Older builds do not export this. */
449
+ declare const ZYFAI_SERVER_TASKS: 1;
450
+ /** A `zyfai_withdrawal` task that failed with one of these codes never sent
451
+ * the withdrawal to Zyfai. */
452
+ declare const ZYFAI_WITHDRAWAL_NOT_SENT_CODES: ReadonlySet<string>;
453
+ /** A `zyfai_deposit_registration` task that failed with one of these codes
454
+ * never registered the deposit with Zyfai, so the browser may register it. */
455
+ declare const ZYFAI_REGISTRATION_NOT_SENT_CODES: ReadonlySet<string>;
456
+ type ZyfaiTaskResult = {
457
+ providerWithdrawalId?: string;
458
+ providerDepositId?: string;
459
+ txHash?: string;
460
+ asyncPending?: true;
461
+ handedOff?: "reconciler";
462
+ lifecycle?: "failed";
463
+ };
464
+ /**
465
+ * - accepted: the server has a task for this leg (its state and code);
466
+ * - declined: the server proved no task was created (a 200 decline, or a 400,
467
+ * 401, 403, 404, 409 or 429; or `ZYFAI_SERVER_TASKS_OFF_CODE` without the
468
+ * opt-in);
469
+ * - unknown: anything else. The server may have a task.
470
+ */
471
+ type ZyfaiHandoffAnswer = {
472
+ type: "accepted";
473
+ taskId: string;
474
+ state: string;
475
+ code?: string;
476
+ result: ZyfaiTaskResult;
477
+ } | {
478
+ type: "declined";
479
+ code: string;
480
+ } | {
481
+ type: "unknown";
482
+ };
483
+
396
484
  /**
397
485
  * One protocol's pool selection on one chain. `pools` holds Zyfai pool NAMES
398
486
  * verbatim — matched case-sensitively by customizeBatch, and an unrecognised
@@ -426,6 +514,119 @@ type OrgAgentConfig = {
426
514
  poolPolicy?: OrgPoolPolicy | null;
427
515
  };
428
516
 
517
+ /**
518
+ * Pool policy: Owney's org-level protocol/pool policy -> Zyfai's two mismatched
519
+ * write shapes.
520
+ *
521
+ * Zyfai splits "which protocols and pools may this user's funds sit in" across
522
+ * two calls that do not share an axis:
523
+ *
524
+ * updateUserProfile({ protocols }) per ASSET, chain-agnostic
525
+ * customizeBatch([{ protocolId, per (PROTOCOL, CHAIN), asset-agnostic
526
+ * chainId, pools, autoselect }])
527
+ *
528
+ * `protocols` is an explicit ALLOW-LIST: a protocol left out of it is disabled
529
+ * for that asset, on every chain, immediately. `customizeBatch` is the opposite
530
+ * shape — one record per (protocol, chain) pair, asset-agnostic, and per
531
+ * docs.zyf.ai it "creates or updates a record for the (user, protocol, chain)
532
+ * combination"; "previous customizations for the same combination are
533
+ * overwritten".
534
+ *
535
+ * That second property is the reason this file exists rather than a single
536
+ * flat translation: customizeBatch overwrites only the combinations it is
537
+ * GIVEN. The partner's stored policy (`OrgPoolPolicy.selections`) is sparse —
538
+ * only the protocols they actually narrowed appear — but the payload we send
539
+ * must be EXHAUSTIVE over every (protocol, chain) pair Zyfai offers this user.
540
+ * If we only sent the narrowed pairs, a partner who restricts Morpho, saves,
541
+ * then later re-ticks every pool box would never be able to undo it: nothing
542
+ * in the (sparse) policy would tell us to send a record clearing it, and the
543
+ * old restrictive record would stay live on the user's profile forever.
544
+ *
545
+ * Pure functions, kept out of the agent so the mapping is testable without a
546
+ * Zyfai client. See splitting.ts for the same pattern on the other lever.
547
+ */
548
+
549
+ /** One selectable pool, with the figures the deposit-time Pools step shows. */
550
+ type AvailablePool = {
551
+ chainId: number;
552
+ token: string;
553
+ name: string;
554
+ /** combined_apy (pool + rewards), already a percent. null when absent. */
555
+ apy: number | null;
556
+ /** TVL in USD. null when absent. See ZyfCustomizationPoolInfo: `tvl` is in
557
+ * the pool's own token, `tvlUsd` is the dollar figure — only the latter is
558
+ * safe to show with a currency symbol. */
559
+ tvlUsd: number | null;
560
+ /** Per-pool deep link (e.g. the Morpho vault page). null when absent. */
561
+ link: string | null;
562
+ /**
563
+ * The pool's on-chain vault address. Yieldseeker identifies its pools by it.
564
+ * Zyfai identifies its pools by name and sends no address, so for Zyfai it is
565
+ * read from the pool's link where that names a vault (Morpho and Euler
566
+ * vaults) and is unset otherwise. It is how the same vault offered by two
567
+ * agents is recognised.
568
+ */
569
+ address?: string;
570
+ };
571
+ /** Public Zyfai strategies used by deposit-time pool customization. */
572
+ type PoolSelectionStrategy = "aggressive" | "yieldmaxxing";
573
+ /** One asset's explicit choice for a protocol on one chain. */
574
+ type UserPoolSelection = {
575
+ asset: "USDC" | "WETH";
576
+ protocolId: string;
577
+ chainId: number;
578
+ /**
579
+ * Names enabled by the user for this asset/protocol/chain. Empty, with
580
+ * `availablePools` not empty, means the user chose none of them.
581
+ */
582
+ pools: string[];
583
+ /** Every name shown for this asset/protocol/chain in the superset catalog. */
584
+ availablePools: string[];
585
+ };
586
+ /**
587
+ * The complete saved draft for the asset/chain legs selected in the deposit.
588
+ *
589
+ * Every agent keeps at least one pool (2026-11-11): a request whose every
590
+ * entry for an asset and chain has empty `pools` (with pools shown) is
591
+ * refused with POOL_SELECTION_REQUIRED before anything is written, unless
592
+ * (Zyfai) a protocol the request does not touch keeps a pool there. A "none
593
+ * chosen" saved before that rule is still read back as none. Entries that
594
+ * showed nothing (`availablePools` empty) change nothing.
595
+ */
596
+ type UserPoolSelectionRequest = {
597
+ strategies: Array<{
598
+ asset: "USDC" | "WETH";
599
+ strategy: PoolSelectionStrategy;
600
+ }>;
601
+ selections: UserPoolSelection[];
602
+ };
603
+ /**
604
+ * What a user's account currently has saved (ROUT-650): each asset's strategy,
605
+ * plus the pool list of every protocol/chain pair frozen by an earlier Save.
606
+ * Pairs Zyfai still autoselects are left out, so "no entry" means "default"
607
+ * (nothing saved). A pair that is present with empty `pools` means none
608
+ * chosen: the user picked none of that pair's pools.
609
+ */
610
+ type SavedPoolSelection = {
611
+ strategies: Array<{
612
+ asset: "USDC" | "WETH";
613
+ strategy: string;
614
+ }>;
615
+ pairs: Array<{
616
+ protocolId: string;
617
+ chainId: number;
618
+ pools: string[];
619
+ }>;
620
+ };
621
+ /** One protocol with its pools for the deposit asset — what the Pools step
622
+ * renders: a protocol row that opens to a list of selectable pools. */
623
+ type PoolCatalogProtocol = {
624
+ protocolId: string;
625
+ name: string;
626
+ logo: string | null;
627
+ pools: AvailablePool[];
628
+ };
629
+
429
630
  type DepositCallback = (smartWalletAddress: string, chainId: number, amount: string) => Promise<`0x${string}`> | `0x${string}`;
430
631
  /**
431
632
  * Read access to the funding ledger, given to agents by the client so they can
@@ -449,6 +650,23 @@ type AgentFundingLedgerAccess = {
449
650
  before: Date;
450
651
  }): Promise<ProviderSnapshotSample | null>;
451
652
  };
653
+ /**
654
+ * What an agent did with a confirmed-deposit notice (`IAgent.depositConfirmed`).
655
+ * `attempts` counts the provider calls made. `allocated` is set when the agent
656
+ * checked whether the deposit was put to work; `allocatesAfter` (ISO) is when
657
+ * the provider will act on it at the earliest, when it said so.
658
+ */
659
+ type DepositNotice = {
660
+ notified: true;
661
+ attempts?: number;
662
+ allocated?: boolean;
663
+ reason?: string;
664
+ allocatesAfter?: string;
665
+ } | {
666
+ notified: false;
667
+ reason: string;
668
+ attempts?: number;
669
+ };
452
670
  interface IAgent {
453
671
  readonly id: string;
454
672
  readonly supportedChainIds: readonly OwneySupportedChainId[];
@@ -466,8 +684,48 @@ interface IAgent {
466
684
  * rejected wallet request cannot happen after another leg has committed.
467
685
  */
468
686
  readonly withdrawalRequiresWalletApproval?: boolean;
687
+ /**
688
+ * Settles this agent's own wallet prompts (a login, a session key) so that a
689
+ * following `withdraw` needs none. A multi-agent withdrawal calls it before a
690
+ * wallet-approval agent's owner signature, so two prompts never overlap and
691
+ * this agent can start as soon as that signature was accepted. Never submits
692
+ * a withdrawal. A rejected prompt throws; other failures are left to `withdraw`.
693
+ */
694
+ prepareWithdrawal?(state: ConnectionState, chainId: number, token: OwneySupportedTokens): Promise<void>;
695
+ /**
696
+ * The adapter can hand its withdrawal to our server (part 4, Zyfai). Only
697
+ * such agents get the plan-time handoff and a `planned` withdraw context;
698
+ * every other agent keeps today's calls.
699
+ */
700
+ readonly supportsServerTasks?: true;
701
+ /**
702
+ * Hands a planned withdrawal leg to our server before an earlier
703
+ * wallet-approval leg is signed (`after`: those legs' keys). The server sends
704
+ * it once those legs are accepted. Never throws; never withdraws locally.
705
+ * `amount` is the leg's planned share, or "MAX". `beforeRequest` runs right
706
+ * before the request leaves (never when none is sent), so the caller can
707
+ * save the leg's server mark first.
708
+ */
709
+ handOffPlannedWithdrawal?(state: ConnectionState, chainId: number, token: OwneySupportedTokens, amount: string, ctx: {
710
+ operationId: string;
711
+ after: string[];
712
+ beforeRequest?: () => void;
713
+ }): Promise<ZyfaiHandoffAnswer>;
469
714
  disconnect(): Promise<void>;
715
+ /**
716
+ * Ready the user's account for every asset the agent supports on `chainId`,
717
+ * `asset` first. A failure the provider says will not go away (the user can
718
+ * never have this agent) carries `details.permanent: true`, and the client
719
+ * then refuses the whole connect (`AGENT_ACTIVATION_BLOCKED`).
720
+ */
470
721
  activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
722
+ /**
723
+ * True when the provider reported this session that the user cannot have an
724
+ * agent for this chain and asset (Yieldseeker's active-agent limit). Callers
725
+ * leave the slot out of deposits. Optional: an agent without such a limit
726
+ * omits it.
727
+ */
728
+ isSlotUnavailable?(state: ConnectionState, chainId: number, asset: OwneySupportedTokens): boolean;
471
729
  /**
472
730
  * Apply the organization's agent policy to this user's account.
473
731
  *
@@ -481,12 +739,72 @@ interface IAgent {
481
739
  * unchanged rather than break the connect.
482
740
  */
483
741
  applyOrgPolicy?(state: ConnectionState, chainId: number, policy: OrgAgentConfig): Promise<void>;
484
- deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback, onProgress?: FundingProgress, onBeforeSubmission?: (evidence: FundingEvidence) => void | Promise<void>): Promise<OwneyDepositResult>;
485
- withdraw(state: ConnectionState, chainId: number, token: OwneySupportedTokens, amount?: string, onProgress?: FundingProgress, gasMode?: "auto" | "sponsored" | "paid", onBeforeSubmission?: FundingProgress, assertCurrent?: () => void): Promise<AgentWithdrawResult>;
742
+ /**
743
+ * The deposit-time pool catalogue for one asset and strategy: protocols with
744
+ * their selectable pools and figures. Optional — an agent with no pool
745
+ * customization omits it. (ROUT-569)
746
+ */
747
+ getPoolCatalog?(params: {
748
+ asset: string;
749
+ strategy: "conservative" | "aggressive" | "yieldmaxxing";
750
+ }): Promise<PoolCatalogProtocol[]>;
751
+ /**
752
+ * Apply a user's own pool selection to their account, driven by the
753
+ * deposit-time Pools step. Optional. A failure throws, and the caller
754
+ * must not start the deposit. A save must also reach money already
755
+ * invested: Zyfai rebalances on its own, Yieldseeker is told with
756
+ * `deposit-made`. Every agent keeps at least one pool: a selection that
757
+ * would leave the agent with no pool for an asset on a chain it offers pools
758
+ * for throws POOL_SELECTION_REQUIRED before anything is written.
759
+ * `state` is the client's connection, or undefined when there is none; an
760
+ * agent that signs in per call (Yieldseeker) needs it, and one that is
761
+ * already connected (Zyfai) ignores it. (ROUT-569)
762
+ */
763
+ setPoolSelection?(selection: UserPoolSelectionRequest, state?: ConnectionState): Promise<void>;
764
+ /**
765
+ * Read back what `setPoolSelection` saved, for the pairs and assets given,
766
+ * so the Pools step can open on the user's own choices. Optional. (ROUT-650)
767
+ */
768
+ getPoolSelection?(state: ConnectionState, chainId: number, params: {
769
+ pairs: Array<{
770
+ protocolId: string;
771
+ chainId: number;
772
+ }>;
773
+ assets: Array<"USDC" | "WETH">;
774
+ }): Promise<SavedPoolSelection>;
775
+ deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback, onProgress?: FundingProgress, onBeforeSubmission?: (evidence: FundingEvidence) => void | Promise<void>,
776
+ /** `operationId`: the funding ledger operation. Zyfai hands the deposit's
777
+ * registration to the server with it (only agents with
778
+ * `supportsServerTasks` get it; every other agent keeps today's call). */
779
+ context?: {
780
+ operationId?: string;
781
+ }): Promise<OwneyDepositResult>;
782
+ withdraw(state: ConnectionState, chainId: number, token: OwneySupportedTokens, amount?: string, onProgress?: FundingProgress, gasMode?: "auto" | "sponsored" | "paid", onBeforeSubmission?: FundingProgress, assertCurrent?: () => void,
783
+ /** `operationId`: the funding ledger operation (Yieldseeker opts in to the
784
+ * server-owned send of its sponsored userOp with it; Zyfai hands its
785
+ * withdrawal to the server with it). `planned`: the leg was handed to the
786
+ * server at plan time, so this call nudges that task (only for agents with
787
+ * `supportsServerTasks`). */
788
+ context?: {
789
+ operationId?: string;
790
+ planned?: true;
791
+ }): Promise<AgentWithdrawResult>;
486
792
  /** Read-only MAX proof at the owner payout block; never sends another withdrawal. */
487
793
  verifyWithdrawalCompletion?(state: ConnectionState, evidence: FundingEvidence): Promise<WithdrawalCompletion>;
488
794
  /** A newly observed pool allocation invalidates this asset's portfolio cache only. */
489
795
  invalidateAllocationRead?(state: ConnectionState, chainId: number, asset: OwneySupportedTokens): void;
796
+ /**
797
+ * A deposit into this agent just confirmed on-chain. An agent whose provider
798
+ * can act on a deposit at once tells it here (Yieldseeker then allocates it
799
+ * instead of waiting for its next scheduled check). The client calls it once
800
+ * per confirmed transfer, in the background: it must never prompt the wallet
801
+ * and never throw. Agents without it rely on their provider's own discovery.
802
+ * An agent that calls its provider more than once, or checks the outcome,
803
+ * reports each call through `onNotice` and resolves with the final outcome.
804
+ */
805
+ depositConfirmed?(state: ConnectionState, chainId: number, evidence: FundingEvidence, onNotice?: (notice: DepositNotice & {
806
+ attempt: number;
807
+ }) => void): Promise<DepositNotice>;
490
808
  /** Invalidate only the confirmed asset. This hook must not sign or submit transactions. */
491
809
  invalidateFundingRead?(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, refreshUntil?: number, txHash?: string): void;
492
810
  /** End accelerated balance reads only for the exact snapshot the caller displayed. */
@@ -504,9 +822,38 @@ interface IAgent {
504
822
  /** Optional positive proof for a repeat deposit; unknown must fall back to portfolio validation. */
505
823
  hasExistingDepositFunds?(state: ConnectionState, chainId: number, asset: OwneySupportedTokens): Promise<true | undefined>;
506
824
  getBalances(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<AgentBalance>;
825
+ /**
826
+ * Whether this wallet can be read on `chainId` from a saved sign-in, with no
827
+ * wallet prompt. Lets the whole-portfolio reads include an agent that does
828
+ * not run on the connection chain (Yieldseeker on Base while the wallet is
829
+ * on Arbitrum); agents without it are read only while active.
830
+ */
831
+ hasReadSession?(state: ConnectionState, chainId: number): boolean;
507
832
  getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
508
833
  /** Funding-ledger read access for earnings holds. Optional; without it an agent behaves as before. */
509
834
  setFundingLedgerAccess?(access: AgentFundingLedgerAccess | undefined): void;
835
+ /**
836
+ * Called each time the agent maps a provider refusal for a wallet whose
837
+ * account was not created through Owney (AGENT_ACCOUNT_NOT_OWNEY). Optional.
838
+ */
839
+ setAccountRefusedListener?(listener: (() => void) | undefined): void;
840
+ /**
841
+ * May this wallet's account use Owney with this agent? Run at connect for
842
+ * every agent about to activate, before any agent activates or is read.
843
+ * Throws a permanent OwneyError (`details.permanent: true`) when it never
844
+ * can, any other error when it cannot tell now. It may sign in; it must not
845
+ * create agents or read balances. Optional; without it the agent is not
846
+ * checked.
847
+ */
848
+ checkAccount?(state: ConnectionState, chainId: number): Promise<void>;
849
+ /**
850
+ * Would this agent ask the wallet to sign in for this wallet and chain right
851
+ * now? Read from what it has saved; it never prompts and never calls the
852
+ * network. Connect counts the sign-ins it will ask for from this
853
+ * (`OwneySDK.onSignInProgress`). Optional; without it the agent is counted
854
+ * as not needing one.
855
+ */
856
+ needsSignIn?(state: ConnectionState, chainId: number): boolean;
510
857
  /**
511
858
  * A small, never-prompting read of the provider's earnings bookkeeping for a
512
859
  * `provider.sample` ledger event (Zyfai). Null when unavailable; never throws.
@@ -522,7 +869,14 @@ interface IAgent {
522
869
  * Optional asset symbol ("USDC" / "WETH") scoping the daily series to a
523
870
  * single asset on the chain. Agents without per-asset positions ignore it.
524
871
  */
525
- tokenSymbol?: string): Promise<AccountAgentApy>;
872
+ tokenSymbol?: string,
873
+ /**
874
+ * Chain the series is scoped to, when that differs from the chain the
875
+ * connection is on. `null` spans every chain the wallet held (ROUT-479);
876
+ * omitted means `chainId`. Kept apart from `chainId` because that one
877
+ * still resolves the wallet and must stay a real, connected chain.
878
+ */
879
+ scopeChainId?: number | null): Promise<AccountAgentApy>;
526
880
  /**
527
881
  * Daily cumulative earnings in token units, scoped to a chain/asset, using
528
882
  * the provider's earnings basis. Include an opening snapshot when available
@@ -569,11 +923,46 @@ type AvailableAgent = {
569
923
  supportedChainIds: readonly number[];
570
924
  supportedAssets: readonly AgentSupportedAssets[];
571
925
  };
926
+ type ActivateAgentOptions = {
927
+ /** Limits agent setup to what this asset needs. Omit for every asset. */
928
+ asset?: OwneySupportedTokens;
929
+ /**
930
+ * Called once the chain and agents are registered and every agent's account
931
+ * check has passed (an agent's check may sign it in), before any agent runs
932
+ * its setup. Not called when a check fails. From then on reads such as
933
+ * `getBalances` are safe to start: each agent's reads wait on that agent's
934
+ * own sign-in, so they share the activation's one wallet prompt instead of
935
+ * waiting for all of setup.
936
+ */
937
+ onAgentsSelected?: () => void;
938
+ };
939
+ /**
940
+ * One step of the sign-ins a connect asks for (`OwneySDK.onSignInProgress`).
941
+ * The plan is the agents whose `needsSignIn` said yes when the connect began:
942
+ * `total`. `"waiting"` comes right before the step that signs an agent in,
943
+ * `"signed"` when it returns, and `"finished"` once: right after the last
944
+ * planned sign-in, or when the connect ends before that (cancelled, failed, or
945
+ * the wallet changed).
946
+ */
947
+ type SignInProgress = {
948
+ state: "waiting" | "signed" | "finished";
949
+ /** Sign-ins this connect asks for. */
950
+ total: number;
951
+ /** Sign-ins finished so far. */
952
+ done: number;
953
+ /** The agent this step is for; absent on `"finished"`. */
954
+ agentId?: AgentId;
955
+ };
572
956
  type AvailableAgentsOptions = {
573
957
  chainId?: number;
574
958
  asset?: Asset;
575
- /** Disabled agents are omitted by default because they cannot accept funds. */
959
+ /** Disabled agents are omitted by default because they cannot accept funds.
960
+ * Listing them also lists unavailable agents: both may still hold funds. */
576
961
  includeDisabled?: boolean;
962
+ /** Agents unavailable on `chainId` and `asset` this session are omitted by
963
+ * default because they get no deposits: their provider has no agent for the
964
+ * slot. See `OwneySDK.getUnavailableAgentIds`. */
965
+ includeUnavailable?: boolean;
577
966
  };
578
967
  /**
579
968
  * A lookback window for any "last N days" read — the APY series, the daily
@@ -604,6 +993,15 @@ type HistoryOptions = {
604
993
  chainId?: number;
605
994
  agentId?: AgentId;
606
995
  filters?: HistoryFilters;
996
+ /**
997
+ * Chains to read, instead of the one `activateAgent` last set (ROUT-479).
998
+ *
999
+ * Each chain pages independently and the results merge into one
1000
+ * chronological list, with every entry stamped with the chain it came from.
1001
+ * Omit for the single-chain behaviour, which stays the default: fanning out
1002
+ * by default would multiply every existing caller's request count.
1003
+ */
1004
+ chainIds?: OwneySupportedChainId[];
607
1005
  };
608
1006
  type WithdrawOptions = {
609
1007
  /** Internal orchestration observation deadline; never retries a send. */
@@ -628,6 +1026,12 @@ type WithdrawOptions = {
628
1026
  * their own so the app record and the ledger share one reference. It is also
629
1027
  * the withdrawal reservation's operationId. */
630
1028
  operationId?: string;
1029
+ /**
1030
+ * Groups this withdrawal with the others started by one user action (a
1031
+ * "withdraw all" sends one per asset). A UUID, recorded on the funding
1032
+ * ledger's operation; a value that is not a UUID is ignored.
1033
+ */
1034
+ batchId?: string;
631
1035
  /**
632
1036
  * Cross-device withdrawal reservation options.
633
1037
  * - `override`: the `reference` from an overridable `RESERVED_ELSEWHERE`
@@ -637,6 +1041,11 @@ type WithdrawOptions = {
637
1041
  * this SDK still has that operation's holder token; otherwise ignored.
638
1042
  */
639
1043
  reservation?: WithdrawalReservationOptions;
1044
+ /**
1045
+ * Chain to withdraw from. Defaults to the chain `activateAgent` last set.
1046
+ * See `DepositOptions.chainId` — the same rules apply.
1047
+ */
1048
+ chainId?: number;
640
1049
  };
641
1050
  /** `WithdrawOptions.reservation`: see there. */
642
1051
  type WithdrawalReservationOptions = {
@@ -646,6 +1055,18 @@ type WithdrawalReservationOptions = {
646
1055
  type AccountApyOptions = {
647
1056
  agentId?: AgentId;
648
1057
  days: LookbackDays;
1058
+ /**
1059
+ * Chain to scope the daily series to, instead of the one `activateAgent`
1060
+ * last set (ROUT-479).
1061
+ *
1062
+ * `"all"` blends every chain the wallet held that day, which is what the
1063
+ * chart's "All chains" filter asks for. Unlike the history and earnings
1064
+ * reads this needs no fan-out: the provider's daily-APY payload is already
1065
+ * wallet-wide and names each position's chain, so the scope is a filter over
1066
+ * one response rather than several calls. Omit for the active chain, which
1067
+ * stays the default.
1068
+ */
1069
+ chainId?: OwneySupportedChainId | "all";
649
1070
  /**
650
1071
  * Optional asset symbol (e.g. "USDC", "WETH") to scope the daily APY series
651
1072
  * to a specific asset on the active chain. Without it the series blends every
@@ -663,6 +1084,14 @@ type AccountApyOptions = {
663
1084
  type DailyEarningsOptions = {
664
1085
  agentId?: AgentId;
665
1086
  days: LookbackDays;
1087
+ /**
1088
+ * Chains to read, instead of the one `activateAgent` last set (ROUT-479).
1089
+ *
1090
+ * The same asset is summed across them — USDC on Base and USDC on Arbitrum
1091
+ * are the same unit. Different assets stay apart, as they already do within
1092
+ * one chain. Omit for the single-chain behaviour, which stays the default.
1093
+ */
1094
+ chainIds?: OwneySupportedChainId[];
666
1095
  /**
667
1096
  * Optional asset symbol (e.g. "USDC", "WETH") scoping the series to one
668
1097
  * asset on the active chain.
@@ -693,6 +1122,10 @@ type DepositOptions = {
693
1122
  assertSubmissionCurrent?: () => void;
694
1123
  /** Resume only these already signed relayer bytes; never create a new authorization. */
695
1124
  resumeTxHash?: `0x${string}`;
1125
+ /** Resume only the saved signed batch of a deposit the server may be sending
1126
+ * (its prepare got no answer, so no transaction hash is known); never create
1127
+ * a new authorization. Check it first with `canResumePendingDeposit`. */
1128
+ resumeSavedBatch?: true;
696
1129
  onProgress?: FundingProgress;
697
1130
  /** Awaited immediately before dispatch. Throwing prevents submission.
698
1131
  * All legs of an atomic batch are checkpointed together. */
@@ -701,10 +1134,39 @@ type DepositOptions = {
701
1134
  asset: Asset;
702
1135
  depositCallback?: DepositCallback;
703
1136
  agentId?: AgentId;
1137
+ /**
1138
+ * Agents that must receive nothing from this deposit. The rest split the
1139
+ * whole amount, and only their minimums apply; an excluded agent is not read,
1140
+ * not prioritized as unfunded and not reported on.
1141
+ *
1142
+ * Throws `ALL_AGENTS_EXCLUDED` (before anything is read or sent) when no
1143
+ * agent is left, or when `agentId` itself is listed. Unknown ids are ignored.
1144
+ * Ignored by `resumeTxHash` and `resumeSavedBatch`: a signed batch is already
1145
+ * committed to its wallets and must be finished as signed.
1146
+ */
1147
+ excludeAgentIds?: AgentId[];
704
1148
  onApproved?: () => void;
705
1149
  /** Funding ledger reference (a UUID). Defaults to a new random UUID; apps pass
706
1150
  * their own so the app record and the ledger share one reference. */
707
1151
  operationId?: string;
1152
+ /**
1153
+ * Groups this deposit with the others started by one user action (a spread
1154
+ * deposit sends one per position). A UUID, recorded on the funding ledger's
1155
+ * operation; a value that is not a UUID is ignored.
1156
+ */
1157
+ batchId?: string;
1158
+ /**
1159
+ * Chain to deposit on. Defaults to the chain `activateAgent` last set, so
1160
+ * omitting it behaves exactly as before.
1161
+ *
1162
+ * Pass it to fund several chains in a row without re-activating between
1163
+ * them (ROUT-245's spread strategies). It selects the target; it does not
1164
+ * replace activation, which is what populates `activeAgents`, and it does
1165
+ * not remove the wallet's network switch — the default deposit callbacks
1166
+ * still put the wallet on this chain before signing, since a deposit
1167
+ * signature is EIP-712 with the chain in its domain.
1168
+ */
1169
+ chainId?: number;
708
1170
  };
709
1171
 
710
1172
  type FundingStage = "pending" | "confirmed" | "unknown" | "failed" | "not-applicable";
@@ -752,21 +1214,68 @@ interface FundingEvidence {
752
1214
  maxCompletion?: WithdrawalCompletionContext;
753
1215
  maxCompletionCheck?: WithdrawalCompletion;
754
1216
  intendedAmount: string;
1217
+ /** A multi-agent withdrawal recorded this leg's planned amount (`intendedAmount`:
1218
+ * the leg's share, or "MAX") before any agent was dispatched. A plan, not a
1219
+ * submission: it never says the leg was sent. */
1220
+ planned?: true;
1221
+ /** The owner-authorized call of a wallet-approval withdrawal was accepted: the
1222
+ * bundler accepted the signed userOp (`userOpHash`), the wallet returned a
1223
+ * calls ID (`callsId`), or `eth_sendTransaction` returned a hash (`txHash`).
1224
+ * Not confirmation: the call can still revert. */
1225
+ ownerAuthorization?: "accepted";
755
1226
  confirmedAmount?: string;
756
1227
  /** Receipt delivery and fulfillment of a typed requested amount are separate facts. */
757
1228
  amountCompletion?: "complete" | "shortfall";
758
1229
  /** Verified difference between the typed request and the actual owner payout. */
759
1230
  shortfallAmount?: string;
760
1231
  txHash?: string;
1232
+ /** Zyfai's id for this deposit, from its registration (1-128 chars); reads its placement status. */
1233
+ providerDepositId?: string;
761
1234
  /** Persisted before a sponsored EOA operation is sent. */
762
1235
  userOpHash?: string;
763
1236
  /** Lets recovery verify a consumed nonce even if a bundler forgets the operation. */
764
1237
  userOperation?: UnsignedUserOperationEvidence;
765
1238
  /** Base Account calls ID used to recover an uncertain wallet submission. */
766
1239
  callsId?: string;
1240
+ /** The server owns this sponsored Yieldseeker userOp's send (true), or may
1241
+ * own it ("unknown": the opted-in send got no definitive answer). Either way
1242
+ * the leg is never "not sent". Not acceptance, not confirmation. Never sent
1243
+ * to the ledger. */
1244
+ serverSubmit?: true | "unknown";
1245
+ /** Zyfai server tasks. On a withdrawal leg: the server sends this withdrawal
1246
+ * (true), or may send it ("unknown": the handoff got no definitive answer),
1247
+ * so the browser never sends it. `false`: the server proved it has no task
1248
+ * for this leg, so the browser sends it; it clears an earlier mark (a
1249
+ * handoff checkpoint), and a merge must let it win over true and "unknown".
1250
+ * On a deposit leg: the server registers this deposit. Not acceptance, not
1251
+ * confirmation. Never sent to the ledger. */
1252
+ serverTask?: true | "unknown" | false;
1253
+ /** With `serverTask` on a Zyfai deposit leg: the client operation id of the
1254
+ * server's registration task, so registration recovery can nudge that task
1255
+ * after a reload. Not a secret. Never sent to the ledger. */
1256
+ serverTaskOperationId?: string;
1257
+ /** With `serverTask: "unknown"` on a Zyfai deposit leg: what the server
1258
+ * answered to the registration handoff. "lost": no answer (the server may
1259
+ * or may not have a task), so a later proof of no task lets the browser
1260
+ * register it. "declined": the server declined it with a code that does not
1261
+ * prove no task (e.g. ALREADY_REGISTERED), so the browser never registers
1262
+ * it. Local only: never sent to the ledger. */
1263
+ serverTaskCreate?: "declined" | "lost";
767
1264
  /** Deposit execution was attempted, rather than only prepared. Not confirmation. */
768
1265
  depositSubmission?: "started";
769
1266
  depositAuthorization?: DepositAuthorizationReference;
1267
+ /** The server accepted this sponsored deposit and sends it itself if the
1268
+ * browser does not (true), or may have accepted it ("unknown": the prepare
1269
+ * got no definitive answer, no hash is known yet). Either way it is never
1270
+ * "not sent". Not confirmation. */
1271
+ serverBroadcast?: true | "unknown";
1272
+ /** With `serverBroadcast: "unknown"`: the deposit authorization's Permit2
1273
+ * deadline (unix seconds). After it no deposit of that authorization can
1274
+ * execute. */
1275
+ authorizationDeadline?: number;
1276
+ /** With `serverBroadcast`: the deposit authorization's Permit2 nonce
1277
+ * (decimal); see `checkDepositAuthorization`. */
1278
+ permit2Nonce?: string;
770
1279
  blockNumber?: string;
771
1280
  logIndexes?: number[];
772
1281
  transferLogs?: {
@@ -777,13 +1286,16 @@ interface FundingEvidence {
777
1286
  withdrawalRequest?: {
778
1287
  attempted: boolean;
779
1288
  method?: "GET" | "POST";
780
- path?: "/users/withdraw" | "/users/partial-withdraw";
1289
+ /** The route that answered. v1 paths appear only in evidence saved before @zyfai/sdk 0.10.0. */
1290
+ path?: "/users/withdraw" | "/users/partial-withdraw" | "/users/withdraw/v2" | "/users/partial-withdraw/v2";
781
1291
  elapsedMs?: number;
782
1292
  /** Actual response status captured before the vendor replaces the HTTP error. */
783
1293
  httpStatus?: number;
784
1294
  failure?: "network" | "unauthorized" | "forbidden" | "rate-limited" | "insufficient-balance" | "session-key-missing" | "withdrawal-in-progress" | "other";
785
1295
  /** When the provider accepted the request without a hash (ms since epoch). */
786
1296
  acceptedAt?: number;
1297
+ /** Zyfai's v2 withdrawal id, for the lifecycle lookup (1-128 chars). */
1298
+ providerWithdrawalId?: string;
787
1299
  };
788
1300
  /** Where an on-chain payout search may start, for a hashless acceptance.
789
1301
  * `fromBlock` is the chain head read just before the request (decimal string). */
@@ -795,6 +1307,34 @@ interface FundingEvidence {
795
1307
  delivery: FundingStage;
796
1308
  }
797
1309
  type FundingProgress = (evidence: FundingEvidence) => void;
1310
+ /** The part of Zyfai's withdrawal lifecycle (`GET /users/withdrawals/{id}`) that Owney acts on. */
1311
+ type ZyfaiWithdrawalLifecycle = {
1312
+ status: string;
1313
+ /** The synchronous payout leg has settled. */
1314
+ syncSettled: boolean;
1315
+ /** Hash of the synchronous payout transaction; present only when well formed. */
1316
+ syncTxHash?: `0x${string}`;
1317
+ /** Delayed (protocol-cooldown) redemption legs; empty when none or unreadable. */
1318
+ asyncLegs: {
1319
+ id: string;
1320
+ status: string;
1321
+ estimatedClaimAt?: string;
1322
+ claimTxHash?: `0x${string}`;
1323
+ }[];
1324
+ /** Ids of delayed legs Zyfai reports as failed. */
1325
+ failedAsyncIds: string[];
1326
+ /** When the delayed part is expected to arrive; present only when a valid date. */
1327
+ estimatedClaimAt?: string;
1328
+ /** Zyfai recorded an error for this withdrawal. Its text is never carried. */
1329
+ hasError: boolean;
1330
+ };
1331
+ /** The part of Zyfai's deposit status (`GET /users/deposits/{id}/v2`) that Owney acts on. */
1332
+ type ZyfaiDepositPlacement = {
1333
+ /** `handover_pending | credited | position_pending | positioned | recovered_to_eoa`. */
1334
+ status: string;
1335
+ /** `pending | positioned | skipped | failed`. */
1336
+ positionOutcome?: string;
1337
+ };
798
1338
  interface AssetReadMetadata {
799
1339
  chainId: number;
800
1340
  asset: string;
@@ -906,6 +1446,19 @@ interface OwneyPendingAllocation {
906
1446
  /** ISO timestamp from Zyfai's `updatedAt`, when the payload carries one. */
907
1447
  since?: string;
908
1448
  }
1449
+ /**
1450
+ * A Zyfai delayed redemption in flight (`REQUESTED` or `CLAIMABLE`). Its funds
1451
+ * are in neither `positions` nor `tokens`; display-only, never added to a total.
1452
+ */
1453
+ interface OwneyPendingWithdrawal {
1454
+ id: string;
1455
+ status: string;
1456
+ chainId: number;
1457
+ /** Token symbol as Zyfai reports it. */
1458
+ asset: string;
1459
+ /** Redeemed amount in least units, as a decimal string. */
1460
+ amountRaw: string;
1461
+ }
909
1462
  interface AgentBalance {
910
1463
  readMetadata?: AssetReadMetadata[];
911
1464
  /** Authoritative native balances per asset/network, including idle and invested funds. */
@@ -929,6 +1482,41 @@ interface AgentBalance {
929
1482
  positions?: OwneyPosition[];
930
1483
  /** Funds received but not yet deployed. Omitted when nothing is pending. */
931
1484
  pendingAllocations?: OwneyPendingAllocation[];
1485
+ /** Zyfai only: delayed redemptions still in flight. Omitted when none. Never part of a total. */
1486
+ pendingWithdrawals?: OwneyPendingWithdrawal[];
1487
+ /**
1488
+ * Zyfai only: every delayed redemption Zyfai lists except FAILED, recently
1489
+ * CLAIMED ones included (Zyfai keeps them about a day). Present, possibly
1490
+ * empty, whenever Zyfai sent the list; absent when it did not. Empty means no
1491
+ * older delayed payout can be landing now. Never part of a total.
1492
+ */
1493
+ recentAsyncWithdrawals?: OwneyRecentAsyncWithdrawal[];
1494
+ }
1495
+ /** A delayed Zyfai redemption by status, for telling a new payout from an older remainder. */
1496
+ type OwneyRecentAsyncWithdrawal = {
1497
+ id: string;
1498
+ status: string;
1499
+ chainId: number;
1500
+ asset: string;
1501
+ };
1502
+ /**
1503
+ * One position drained by `withdrawAll()` — a chain and asset pair.
1504
+ *
1505
+ * Carries either a result or an error, never both: a leg that failed while
1506
+ * others succeeded is the normal case, not an exception, and the caller needs
1507
+ * to name the ones that did not arrive.
1508
+ */
1509
+ interface OwneyWithdrawAllLeg {
1510
+ chainId: OwneySupportedChainId;
1511
+ asset: OwneySupportedTokens;
1512
+ /** What the position held when the sweep started. */
1513
+ amount: string;
1514
+ result?: OwneyWithdrawResult | AgentWithdrawResult;
1515
+ error?: string;
1516
+ }
1517
+ interface OwneyWithdrawAllResult {
1518
+ /** Every position attempted, in the order it was attempted. */
1519
+ legs: OwneyWithdrawAllLeg[];
932
1520
  }
933
1521
  interface OwneyBalances {
934
1522
  totalBalance: string;
@@ -958,17 +1546,61 @@ interface OwneyEarnings {
958
1546
  agentRetryAt?: Partial<Record<AgentId, number>>;
959
1547
  }
960
1548
  type ApyByChainAndAsset = Partial<Record<OwneySupportedChainId, Partial<Record<OwneySupportedTokens, number>>>>;
1549
+ /** One external reward program contributing percentage points to a day. */
1550
+ interface ApyIncentive {
1551
+ source: "merkl";
1552
+ agentId: AgentId;
1553
+ opportunityId: string;
1554
+ /** All on-chain campaigns represented by the opportunity APR that day. */
1555
+ campaignIds: string[];
1556
+ /** Source APR before portfolio weighting, expressed as a percentage. */
1557
+ apr: number;
1558
+ /** Percentage points to add to this point's native/provider `apy`. */
1559
+ apyContribution: number;
1560
+ }
961
1561
  /** A single day's net APY for the connected account, as a percentage number. */
962
1562
  interface ApyHistoryPoint {
963
1563
  /** ISO date string for the day, e.g. "2026-06-20". */
964
1564
  date: string;
965
- /** Net (after-fee) weighted APY for that day, summed across tokens. */
1565
+ /** Native/provider net APY. External incentives are deliberately excluded. */
966
1566
  apy: number;
967
1567
  /** Balance on this date, in the explicitly named unit; never today's balance. */
968
1568
  historicalBalance?: {
969
1569
  amount: number;
970
1570
  unit: string;
971
1571
  };
1572
+ /** Best-effort external rewards. Absent when none apply or cannot be read. */
1573
+ incentives?: ApyIncentive[];
1574
+ }
1575
+ /**
1576
+ * What the APY chart's chain/asset menus are allowed to offer, and how far
1577
+ * back each option reaches (ROUT-479).
1578
+ *
1579
+ * An option only earns a place if some day in the window held a real position
1580
+ * on it — a balance and a rate. Listing anything else would offer a filter
1581
+ * that draws a blank chart. `days` is what the menu prints beside each row,
1582
+ * and the legs genuinely differ: a wallet can hold USDC for a fortnight and
1583
+ * WETH for three days.
1584
+ */
1585
+ interface ApyCoverage {
1586
+ chains: {
1587
+ chainId: number;
1588
+ days: number;
1589
+ }[];
1590
+ /** Legs whose `tokenSymbol` the provider left unset are absent — they cannot
1591
+ * be named, so they cannot be picked. Their chain still counts. */
1592
+ assets: {
1593
+ asset: string;
1594
+ days: number;
1595
+ }[];
1596
+ /** Each asset on each chain, for a menu that offers the two together
1597
+ * (ROUT-647). The lists above cannot say this: USDC on Base and WETH on
1598
+ * Arbitrum put both chains and both assets in them, and no WETH on Base. */
1599
+ pairs: {
1600
+ chainId: number;
1601
+ asset: string;
1602
+ days: number;
1603
+ }[];
972
1604
  }
973
1605
  interface AccountAgentApy {
974
1606
  walletAddress: string;
@@ -980,6 +1612,8 @@ interface AccountAgentApy {
980
1612
  * date. Empty when the provider returns no daily history.
981
1613
  */
982
1614
  history?: ApyHistoryPoint[];
1615
+ /** Which chains/assets this history can be filtered down to. */
1616
+ coverage?: ApyCoverage;
983
1617
  }
984
1618
  interface OwneyAccountApy {
985
1619
  totalApy: string;
@@ -1039,19 +1673,42 @@ interface AgentHistoryPosition {
1039
1673
  protocol: string;
1040
1674
  pool?: string;
1041
1675
  tokenSymbol?: string;
1676
+ /** The position balance after the action (decimal string, token units). */
1042
1677
  amount?: string;
1678
+ /**
1679
+ * The amount the action actually moved (decimal string, token units), as
1680
+ * opposed to `amount`, the resulting position balance. Present only when the
1681
+ * provider reports it; withheld on withdrawals.
1682
+ */
1683
+ deltaAmount?: string;
1043
1684
  }
1044
1685
  interface AgentHistoryEntry {
1045
1686
  /** Stable provider/transfer identity, independent of row order. */
1046
1687
  id?: string;
1047
1688
  agent: AgentId;
1048
1689
  action: HistoryAction;
1690
+ /**
1691
+ * Chain this entry came from, stamped by the history fan-out (ROUT-479).
1692
+ *
1693
+ * Absent on a single-chain read, where the caller already knows the chain.
1694
+ * The entry has no chain of its own otherwise: `transactions[].chainId` is
1695
+ * optional and missing whenever the indexer has not attached the transfer,
1696
+ * so a row cannot be labelled from it reliably.
1697
+ */
1698
+ chainId?: OwneySupportedChainId;
1049
1699
  date: string;
1050
1700
  oldApy: string | null;
1051
1701
  newApy: string | null;
1052
1702
  transactions: HistoryTransaction[];
1053
1703
  rebalanceLog: RebalanceLog[];
1054
1704
  positions?: AgentHistoryPosition[];
1705
+ /**
1706
+ * Set on a `Withdraw` that was only requested from an async vault
1707
+ * (ROUT-624). The vault pays out in batches later, so the funds have not
1708
+ * reached the wallet yet and `transactions[0].amount` is the amount
1709
+ * requested.
1710
+ */
1711
+ asyncRequest?: true;
1055
1712
  }
1056
1713
  interface OwneyAgentHistory {
1057
1714
  agentErrors?: Partial<Record<AgentId, string>>;
@@ -1168,9 +1825,12 @@ type WithdrawalPayoutScan = {
1168
1825
  candidates: WithdrawalPayoutCandidate[];
1169
1826
  /** Last block scanned (inclusive, decimal). Pass it back as the next `cursor`. */
1170
1827
  scannedTo: string;
1828
+ /** False when the call stopped at its request limit before the scan end (the
1829
+ * head minus the reorg margin), so more blocks are already waiting. */
1830
+ caughtUp: boolean;
1171
1831
  };
1172
1832
 
1173
- 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_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" | "WITHDRAW_ARRIVAL_TIMEOUT" | "WITHDRAW_SWAP_FAILED" | "BALANCE_ALL_FAILED" | "EARNINGS_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
1833
+ 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" | "AGENT_ACTIVATION_BLOCKED" | "AGENT_ACCOUNT_NOT_OWNEY" | "YIELDSEEKER_AGENT_MISSING" | "YIELDSEEKER_AGENT_CLOSED" | "YIELDSEEKER_SLOT_UNAVAILABLE" | "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" | "ALL_AGENTS_EXCLUDED" | "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" | "POOL_SELECTION_NOT_APPLIED" | "POOL_SELECTION_RULE_LIMIT" | "POOL_SELECTION_REQUIRED" | "VALIDATION_INVALID_DAYS";
1174
1834
  declare class OwneyError extends Error {
1175
1835
  readonly code: OwneyErrorCode;
1176
1836
  readonly details?: Record<string, unknown>;
@@ -1223,6 +1883,12 @@ type WithdrawSwapRecord = {
1223
1883
  * is continued or rechecked. Absent on records written by an older SDK.
1224
1884
  */
1225
1885
  operationId?: string;
1886
+ /**
1887
+ * The batch this withdrawal belongs to (see `WithdrawOptions.batchId`), kept
1888
+ * so a continuation or recheck reports into the same batch. Absent when the
1889
+ * withdrawal was not part of one.
1890
+ */
1891
+ batchId?: string;
1226
1892
  recovery?: WithdrawalSwapRecovery;
1227
1893
  spent?: string;
1228
1894
  dismissed?: boolean;
@@ -1317,6 +1983,11 @@ type PendingDeposit = {
1317
1983
  * it. Absent on records written by an older SDK.
1318
1984
  */
1319
1985
  operationId?: string;
1986
+ /**
1987
+ * The user action's batch (see `DepositOptions.batchId`), so finishing the
1988
+ * deposit later reports under it. Absent when the swap had none.
1989
+ */
1990
+ batchId?: string;
1320
1991
  };
1321
1992
  /** Every record, dismissed ones included, newest first. Sweeps as it goes. */
1322
1993
  declare function listPendingDeposits(now?: number): PendingDeposit[];
@@ -1330,6 +2001,16 @@ declare class OwneySDK {
1330
2001
  * withdraw, but they are excluded from new deposits / activations.
1331
2002
  */
1332
2003
  private disabledAgents;
2004
+ private readonly accountRefusedListeners;
2005
+ private readonly signInProgressListeners;
2006
+ /**
2007
+ * Agents whose sign-in the user cancelled this session (the wallet rejected
2008
+ * the prompt), keyed by chain. Until the app ends the session they are read
2009
+ * from a saved sign-in only (`readStateFor`), so no read reopens the prompt
2010
+ * the user cancelled. A later successful activation of the agent removes
2011
+ * it, and `disconnect()` or a different wallet's `connect()` clears the map.
2012
+ */
2013
+ private declinedSignIns;
1333
2014
  private state;
1334
2015
  private connectionRevision;
1335
2016
  private disconnectingAgents;
@@ -1340,18 +2021,29 @@ declare class OwneySDK {
1340
2021
  private zyfaiRpcUrls?;
1341
2022
  private yieldseekerApiBaseUrl?;
1342
2023
  private yieldseekerSiweOrigin?;
2024
+ private userPoolCustomization;
1343
2025
  private routingApiBaseUrl?;
1344
2026
  private referralSource?;
1345
2027
  private readonly ledger;
1346
2028
  private readonly reservationMode;
1347
2029
  private readonly reservationTransport;
2030
+ /** The caller's Zyfai server tasks opt-in: `true`, a function read each
2031
+ * time a handoff would start (F-I2(iii)), or undefined (off). */
2032
+ private readonly zyfaiServerTasks;
2033
+ /** The caller opted in to the Fusion+ secret handoff (`fusionSecretHandoff: true`). */
2034
+ private readonly fusionSecretHandoff;
1348
2035
  private cachedSponsoredCallback;
1349
2036
  private cachedWethSponsoredCallback;
1350
2037
  private paymasterServiceUrl?;
1351
2038
  private cachedSponsoredCallsCallbacks;
1352
2039
  private readonly agentReads;
1353
2040
  private readonly depositFamilyReads;
2041
+ /** Movements (owner, chain, agent, token, tx hash) whose balance refresh this
2042
+ * session started: true when it armed the refresh, false when its deadline
2043
+ * had passed (it only dropped the cache and forced one snapshot read). */
1354
2044
  private readonly recoveredFundingReads;
2045
+ /** Confirmed deposits already announced to their agent (`depositConfirmed`), bounded. */
2046
+ private readonly announcedDeposits;
1355
2047
  private fundingBalanceChecks;
1356
2048
  private readonly activationChecks;
1357
2049
  private readonly withdrawalSubmissions;
@@ -1383,8 +2075,16 @@ declare class OwneySDK {
1383
2075
  /** Starts a swap's operation and opens it to the swap's inner deposit or
1384
2076
  * withdrawal. Never throws: reporting never blocks a swap. */
1385
2077
  private openSwapLedger;
2078
+ /**
2079
+ * Part 5: the swap's ledger identity, for the executor's Fusion+ secret
2080
+ * handoff. Only with the `fusionSecretHandoff` opt-in and an open operation;
2081
+ * otherwise undefined, and the executor sends nothing. Owner and token are
2082
+ * lowercased, as the ledger reports them.
2083
+ */
2084
+ private secretHandoffFor;
1386
2085
  private closeSwapLedger;
1387
- /** Reports one agent's withdrawal evidence as its leg. Never throws. */
2086
+ /** Reports one agent's withdrawal evidence as its leg (with `errorCode`, when
2087
+ * given). Never throws. */
1388
2088
  private ledgerWithdrawalLeg;
1389
2089
  /** Operation/leg/tx keys whose provider samples are already scheduled. */
1390
2090
  private readonly providerSampleKeys;
@@ -1396,6 +2096,29 @@ declare class OwneySDK {
1396
2096
  * a later sample is skipped once the wallet disconnects or changes.
1397
2097
  */
1398
2098
  private ledgerProviderSamples;
2099
+ /**
2100
+ * Listens for an agent refusing the connected wallet because its provider
2101
+ * account was not created through Owney (`AGENT_ACCOUNT_NOT_OWNEY`). Fires
2102
+ * each time an agent maps such a refusal. Returns the unsubscribe function.
2103
+ */
2104
+ onAccountRefused(listener: (agentId: AgentId) => void): () => void;
2105
+ /**
2106
+ * Listens for the sign-ins a connect asks for (`SignInProgress`): which
2107
+ * agents will ask the wallet to sign in, and each one as it starts and ends,
2108
+ * then `"finished"` after the last one (or when the connect ends first).
2109
+ * Nothing is sent when no agent needs a sign-in. Returns the unsubscribe
2110
+ * function.
2111
+ */
2112
+ onSignInProgress(listener: (progress: SignInProgress) => void): () => void;
2113
+ /**
2114
+ * The sign-ins this connect asks for: the agents whose `needsSignIn` says
2115
+ * yes now (one that throws counts as no). Each is announced at its first
2116
+ * step (its account check, or its activation when it has none) and counted
2117
+ * once.
2118
+ */
2119
+ private planSignIns;
2120
+ /** Wires the optional hooks the SDK offers an agent. */
2121
+ private attachAgentHooks;
1399
2122
  /**
1400
2123
  * Funding-ledger read access handed to agents for earnings holds. Reads only
1401
2124
  * for the connected owner; null otherwise and on any failure.
@@ -1419,6 +2142,33 @@ declare class OwneySDK {
1419
2142
  private clearConnectionState;
1420
2143
  private disconnectAgents;
1421
2144
  private isAgentDisabled;
2145
+ /**
2146
+ * True when `id` takes no new deposits on this chain and asset this
2147
+ * session: its adapter reports no agent for the slot.
2148
+ */
2149
+ private isAgentUnavailable;
2150
+ /**
2151
+ * The agents that take no new deposits on this chain and asset this
2152
+ * session, so the app can show them as unavailable: each agent whose
2153
+ * provider has no agent for this slot. They stay withdrawable.
2154
+ */
2155
+ getUnavailableAgentIds(chainId: number, asset?: string): AgentId[];
2156
+ /**
2157
+ * The adapter reports no agent for this chain and asset this session (see
2158
+ * `IAgent.isSlotUnavailable`): there is nothing there to withdraw, so a
2159
+ * withdrawal without an explicit agent leaves it out instead of failing its
2160
+ * leg.
2161
+ */
2162
+ private hasNoAgentForSlot;
2163
+ /**
2164
+ * The state an agent's reads use. An agent whose sign-in the user cancelled
2165
+ * on the connection chain this session is read from a saved sign-in only,
2166
+ * as `offChainPortfolioAgents` reads: a read that would need a wallet
2167
+ * prompt fails for that agent instead of reopening the prompt the user
2168
+ * cancelled. A later successful activation of the agent, or `disconnect()`,
2169
+ * lifts it.
2170
+ */
2171
+ private readStateFor;
1422
2172
  /**
1423
2173
  * Check if the SDK has an active connection state.
1424
2174
  * @returns `true` if `connect()` has been called and `disconnect()` has not
@@ -1463,6 +2213,18 @@ declare class OwneySDK {
1463
2213
  private getAgent;
1464
2214
  getActiveAgentIds(): AgentId[];
1465
2215
  private getActiveAgents;
2216
+ /**
2217
+ * Agents that do not run on the connection chain but can be read on their
2218
+ * own from a saved sign-in: Yieldseeker, Base-only, while the wallet sits on
2219
+ * Arbitrum or Ethereum. The whole-portfolio reads (ROUT-479) add them, under
2220
+ * a promptless state; with no saved sign-in they are left out, as before.
2221
+ */
2222
+ private offChainPortfolioAgents;
2223
+ /** Every agent a whole-portfolio read covers: the active ones on the
2224
+ * connection chain, then the off-chain ones on their own chain. */
2225
+ private portfolioReads;
2226
+ /** The active agents, each with the state its reads use (`readStateFor`). */
2227
+ private activeReads;
1466
2228
  /**
1467
2229
  * Read the org's agent policy once and reuse it. fetchOrgAgentConfig never
1468
2230
  * throws — it degrades to null — so this cannot break activation.
@@ -1493,8 +2255,18 @@ declare class OwneySDK {
1493
2255
  * that support the given chainId (incompatible agents are silently skipped).
1494
2256
  * If provided, ALL specified agents must support the chainId or the call
1495
2257
  * throws before activating any agent.
1496
- */
1497
- activateAgent(chainId: number, agentId?: AgentId[], asset?: OwneySupportedTokens): Promise<void>;
2258
+ * @param options - Optional. `asset` limits setup to that asset;
2259
+ * `onAgentsSelected` fires once reads can start: after every agent's
2260
+ * account check (`checkAccount`) passed, before any agent activates.
2261
+ * @throws Activation stops at the first agent that fails, and the caller
2262
+ * should end the session. `AGENT_ACTIVATION_PARTIAL_FAILURE` when an
2263
+ * earlier agent activated; `walletRejected` in its details means the user
2264
+ * rejected a signature. `AGENT_ACTIVATION_BLOCKED` when the agent can
2265
+ * never be readied (`details.permanent`). Otherwise the agent's own error
2266
+ * is thrown as is. Until it signs in, an agent whose signature the user
2267
+ * rejected is read from a saved sign-in only and opens no prompt.
2268
+ */
2269
+ activateAgent(chainId: number, agentId?: AgentId[], options?: ActivateAgentOptions): Promise<void>;
1498
2270
  private assertActivationSession;
1499
2271
  /**
1500
2272
  * Activate agents ONE AT A TIME, each followed by its org policy.
@@ -1509,11 +2281,22 @@ declare class OwneySDK {
1509
2281
  * Serializing costs no real wall-clock: the user can only approve one prompt
1510
2282
  * at a time anyway.
1511
2283
  *
1512
- * Stop at the first failure so a canceled sign-in does not open another
1513
- * agent's wallet prompt. Report any earlier successes for diagnostics; the
1514
- * app discards the session when the complete sign-in does not succeed.
2284
+ * Stop at the first failure (2026-11-06): a connect needs every agent, so
2285
+ * no later agent's wallet prompt opens for a sign-in that already failed.
2286
+ * When an earlier agent activated, the partial failure reports it, and
2287
+ * `walletRejected` tells the app the user canceled; the app ends the
2288
+ * session either way. When none activated, the agent's own error is thrown.
2289
+ * A failure the provider marks `permanent` is thrown as
2290
+ * `AGENT_ACTIVATION_BLOCKED`.
2291
+ *
2292
+ * Account check first (2026-11-13): every agent's `checkAccount` runs, in
2293
+ * turn, before `onAgentsSelected` and before any agent activates, so a
2294
+ * wallet one agent can never serve signs in nowhere else, gets nothing
2295
+ * created and is not read. A failed check stops the connect like a failed
2296
+ * activation, with nothing activated.
1515
2297
  */
1516
2298
  private activateAgentsInTurn;
2299
+ private activatePlannedAgents;
1517
2300
  /**
1518
2301
  * Deposit into a specific agent, or distribute across all eligible agents.
1519
2302
  * Validates that the asset is supported and amount meets minimums for the target agent(s).
@@ -1526,6 +2309,10 @@ declare class OwneySDK {
1526
2309
  * all shares into one signature; custom callbacks still run once per agent.
1527
2310
  * @param options.agentId - Optional explicit target. Otherwise split equally,
1528
2311
  * or fund remaining agents when a recovery deposit cannot meet every minimum.
2312
+ * @param options.excludeAgentIds - Agents that must receive nothing. The rest
2313
+ * split the whole amount under their own minimums. Throws
2314
+ * `ALL_AGENTS_EXCLUDED` when none is left or `agentId` is listed. Ignored
2315
+ * when resuming a signed batch.
1529
2316
  * @returns {OwneyDepositResult} for a single agent, or {OwneyMultiDepositResult} with per-agent results
1530
2317
  */
1531
2318
  deposit(options: DepositOptions): Promise<OwneyDepositResult | OwneyMultiDepositResult>;
@@ -1557,6 +2344,13 @@ declare class OwneySDK {
1557
2344
  * doesn't force a retry of sibling agents in a multi-agent split.
1558
2345
  */
1559
2346
  private depositWithFallback;
2347
+ /**
2348
+ * Refuses a new deposit that `excludeAgentIds` leaves with nobody to fund:
2349
+ * the explicit `agentId` is listed, or every agent that can take this asset
2350
+ * on this chain (and is not disabled) is. A no-op without a list, so a deposit
2351
+ * without exclusions is exactly as it was. Reads no provider.
2352
+ */
2353
+ private assertDepositAgentsRemain;
1560
2354
  private getMinDepositAmount;
1561
2355
  private splitDepositAmount;
1562
2356
  private formatAgentName;
@@ -1568,7 +2362,30 @@ declare class OwneySDK {
1568
2362
  * false, so the minimum is enforced as today.
1569
2363
  */
1570
2364
  private hasExistingBalance;
2365
+ /**
2366
+ * Guard an explicitly requested chain against one agent's own list.
2367
+ *
2368
+ * Only reachable when the caller passes `chainId` — the activated chain has
2369
+ * already been checked by `activateAgent`. Kept separate from
2370
+ * `validateAssetSupport` so "this agent is not on Ethereum" does not arrive
2371
+ * worded as "this agent does not support USDC".
2372
+ */
2373
+ private validateChainSupport;
2374
+ /**
2375
+ * Guard an explicitly requested chain before a fan-out.
2376
+ *
2377
+ * Without this the split simply produces no agents, and the caller is told
2378
+ * their amount "cannot activate every eligible agent" against a combined
2379
+ * minimum of 0 — an error about the amount when the chain is at fault.
2380
+ */
2381
+ private validateChainHasAgents;
1571
2382
  private validateAssetSupport;
2383
+ /**
2384
+ * The agents that support this asset on this chain. `excludeDisabled` is for
2385
+ * new deposits: it also leaves out the agents unavailable for this slot this
2386
+ * session (see `getUnavailableAgentIds`). Without it, withdrawals and deposit
2387
+ * recovery still see every agent that may hold funds.
2388
+ */
1572
2389
  private getEligibleAgents;
1573
2390
  /**
1574
2391
  * Run owner-approved withdrawals before relayer-only withdrawals. Wallet
@@ -1576,6 +2393,11 @@ declare class OwneySDK {
1576
2393
  * operation, so no relayer leg should commit before it has completed.
1577
2394
  */
1578
2395
  private orderAgentsForWithdrawal;
2396
+ /**
2397
+ * The user cancelled a wallet prompt, for any agent: see isWalletRejection.
2398
+ * That includes an agent error that kept the rejection only as text in
2399
+ * `details.cause`.
2400
+ */
1579
2401
  private isUserRejectedWithdrawal;
1580
2402
  private captureReadScope;
1581
2403
  /** Revalidate a saved transfer against the authenticated account and actual receipt. */
@@ -1584,6 +2406,37 @@ declare class OwneySDK {
1584
2406
  refreshBalance?: boolean;
1585
2407
  requireAmountMatch?: boolean;
1586
2408
  }): Promise<FundingEvidence>;
2409
+ /**
2410
+ * Tells the agent, once per confirmed deposit transfer, that its deposit
2411
+ * landed (`IAgent.depositConfirmed`), and records the outcome on the
2412
+ * deposit's ledger operation when there is one. In the background: never
2413
+ * throws and never delays the deposit. A missed notice only leaves the
2414
+ * provider on its own schedule.
2415
+ *
2416
+ * An agent that reports its provider calls (`onNotice`) gets one
2417
+ * `provider.deposit_notified` event per call and a final
2418
+ * `provider.deposit_allocation` with the outcome (allocated or why not).
2419
+ * Otherwise the outcome is the one `provider.deposit_notified`.
2420
+ */
2421
+ private announceDepositConfirmed;
2422
+ private noteFundingRefresh;
2423
+ /**
2424
+ * Re-arms an agent's balance refresh after a confirmed deposit or withdrawal
2425
+ * the caller already verified (e.g. after a page reload, which loses the
2426
+ * refresh the SDK started in memory). Same refresh as receipt recovery
2427
+ * (`inspectFunding`), without a receipt read, and shared with it: once per
2428
+ * movement (`txHash`) in this SDK session, unless that recovery came after
2429
+ * its own deadline and so armed nothing. `until` bounds it (the agent caps
2430
+ * it further). Returns false when the agent has no such refresh or `until`
2431
+ * has passed; throws when not connected or on another chain. Never prompts.
2432
+ */
2433
+ refreshAgentBalanceAfterMovement(input: {
2434
+ agentId: AgentId;
2435
+ chainId: number;
2436
+ token: OwneySupportedTokens;
2437
+ txHash?: string;
2438
+ until: number;
2439
+ }): boolean;
1587
2440
  /**
1588
2441
  * Lists on-chain payout candidates for a withdrawal the provider accepted
1589
2442
  * without a hash: ERC-20 `Transfer` logs on the evidence's token that reach
@@ -1611,6 +2464,26 @@ declare class OwneySDK {
1611
2464
  /** Whether a foreground deposit can resume the same signed batch, never a
1612
2465
  * fresh authorization. The batch rail independently rechecks the exact plan. */
1613
2466
  canResumePendingDeposit(evidences: FundingEvidence[], amount: string): Promise<boolean>;
2467
+ /** Whether a Permit2 deposit authorization can still execute and whether it
2468
+ * did: `expired` when the finalized block is more than 300 s past
2469
+ * `deadline` (chain time), `used` when the owner's Permit2 nonce bit is set
2470
+ * at that block. Null when anything cannot be read. Never throws. */
2471
+ checkDepositAuthorization(input: {
2472
+ chainId: number;
2473
+ owner: string;
2474
+ token?: string;
2475
+ permit2Nonce: string;
2476
+ deadline: number;
2477
+ }): Promise<{
2478
+ expired: boolean;
2479
+ used: boolean;
2480
+ } | null>;
2481
+ /** Drops the saved signed body of a hashless deposit the server may have
2482
+ * been sending (`serverBroadcast` 'unknown'/true, no hash) once the app has
2483
+ * settled it another way: by the ledger's hash or its expired deadline.
2484
+ * Only the body with this Permit2 deadline and these exact shares is
2485
+ * dropped, so it never resumes or blocks a different deposit. Never throws. */
2486
+ discardSavedDepositBatch(evidences: FundingEvidence[]): Promise<boolean>;
1614
2487
  /** Validate signed journal membership, never just a caller-supplied family ID. */
1615
2488
  validateDepositReplacement(previous: FundingEvidence[], next: FundingEvidence[]): Promise<DepositReplacementValidation | undefined>;
1616
2489
  /** Optional post-payout display proof; receipt verification and the provider
@@ -1621,6 +2494,12 @@ declare class OwneySDK {
1621
2494
  /** History lookup for receipt recovery; adapters may not authenticate or sign here. */
1622
2495
  getFundingHistory(evidence: FundingEvidence, fromDate: string, options?: Pick<HistoryFilters, "cursor" | "toDate">): Promise<OwneyAgentHistory>;
1623
2496
  recoverDepositRegistration(evidence: FundingEvidence): Promise<FundingEvidence>;
2497
+ /** A Zyfai withdrawal's lifecycle by the id recorded on its evidence. Never signs,
2498
+ * prompts or authenticates; `null` when unavailable or not this wallet's Zyfai withdrawal. */
2499
+ getZyfaiWithdrawal(evidence: FundingEvidence): Promise<ZyfaiWithdrawalLifecycle | null>;
2500
+ /** A Zyfai deposit's placement status by the id recorded on its evidence. Never signs,
2501
+ * prompts or authenticates; `null` when unavailable or not this wallet's Zyfai deposit. */
2502
+ getZyfaiDeposit(evidence: FundingEvidence): Promise<ZyfaiDepositPlacement | null>;
1624
2503
  /** On-chain version and ownership status for this owner's Yieldseeker agent. */
1625
2504
  getYieldseekerWalletStatus(asset: OwneySupportedTokens): Promise<YieldseekerWalletStatus | null>;
1626
2505
  /** Deployment gate; an unavailable response keeps the current paid path. */
@@ -1676,6 +2555,18 @@ declare class OwneySDK {
1676
2555
  * would strand funds we might have been able to move.
1677
2556
  */
1678
2557
  /** ERC20 balance of the connected wallet, read through the wallet's own node. */
2558
+ /**
2559
+ * A read client pinned to `chainId`, over HTTP rather than the wallet.
2560
+ *
2561
+ * The swap rail has read this way from the start, and the reason is written
2562
+ * out at `buildSwapDeps`: a provider-backed client reads from whatever chain
2563
+ * the WALLET is on, which after a cross-chain swap is the source chain, not
2564
+ * the one the funds landed on. The deposit's own reads did not, so a Permit2
2565
+ * check for WETH on Arbitrum went to Base — where that address is not a
2566
+ * contract at all, so viem got "0x" back and threw "The contract function
2567
+ * 'allowance' returned no data".
2568
+ */
2569
+ private chainReader;
1679
2570
  private readTokenBalance;
1680
2571
  /** How much of `token` the wallet has already approved Permit2 to move. */
1681
2572
  private readTokenPermit2Allowance;
@@ -1687,12 +2578,36 @@ declare class OwneySDK {
1687
2578
  * wallet calls also cover approval without spending the received tokens.
1688
2579
  */
1689
2580
  private settleSwapDepositAmount;
2581
+ /**
2582
+ * Deposit a swap's output, retrying once at the balance the deposit saw.
2583
+ *
2584
+ * `settleSwapDepositAmount` approves and THEN reads, but the read and the
2585
+ * deposit's own pre-check can disagree: the approval is confirmed through
2586
+ * the wallet's node, the read goes to a pinned RPC, and gas paid in WETH
2587
+ * (MetaMask offers this to a wallet with no ETH) can land after either.
2588
+ * ROUT-618 failed that way with the settle step in place.
2589
+ *
2590
+ * The pre-check reports the balance it saw, and that is the authority, so
2591
+ * a shortfall is retried once at that figure. Only a small one: a node that
2592
+ * has not caught up can read near zero, and depositing that would leave the
2593
+ * rest of the swap stranded behind a "success".
2594
+ */
2595
+ private depositSwapOutput;
1690
2596
  private walletSeesBalance;
1691
2597
  /**
1692
2598
  * Runs a quoted swap. A named seam rather than an inline `executeSwap` call
1693
2599
  * so the deposit half of `swapAndDeposit` can be exercised on its own.
1694
2600
  */
1695
2601
  private runSwap;
2602
+ /**
2603
+ * Throws SWAP_INSUFFICIENT_GAS when the wallet cannot pay for this swap.
2604
+ *
2605
+ * Only the classic rail is ever refused: it is the one where the user sends
2606
+ * the transactions. Call it on a preview quote to warn BEFORE a withdrawal
2607
+ * moves anything — `withdrawAndSwap` repeats it on its own quote, but by
2608
+ * then the funds have already left the agent (ROUT-622).
2609
+ */
2610
+ checkSwapGas(quote: SwapQuote): Promise<void>;
1696
2611
  /**
1697
2612
  * The half of the swap deps that only ever talks to the routing API.
1698
2613
  *
@@ -1739,8 +2654,19 @@ declare class OwneySDK {
1739
2654
  * second half of `swapAndDeposit` on its own. Cleared only once the deposit
1740
2655
  * has actually gone through — a failure here leaves the record in place so it
1741
2656
  * can be offered again rather than silently dropped.
2657
+ *
2658
+ * The record does not remember `excludeAgentIds`, on purpose: the caller must
2659
+ * pass the CURRENT list, because the user's choice may have changed since the
2660
+ * swap (a deposit reads it fresh each time). Without it, a record with no
2661
+ * `agentId` splits across every eligible agent. When the list leaves nobody to
2662
+ * fund (or names the record's own agent) it throws `ALL_AGENTS_EXCLUDED`
2663
+ * before the wallet is touched and keeps the record.
2664
+ *
2665
+ * @param options.excludeAgentIds - See `DepositOptions.excludeAgentIds`.
1742
2666
  */
1743
- completePendingDeposit(id: string): Promise<OwneyDepositResult | OwneyMultiDepositResult>;
2667
+ completePendingDeposit(id: string, options?: {
2668
+ excludeAgentIds?: AgentId[];
2669
+ }): Promise<OwneyDepositResult | OwneyMultiDepositResult>;
1744
2670
  /**
1745
2671
  * Pick up cross-chain swaps a previous session left in flight.
1746
2672
  *
@@ -1877,6 +2803,13 @@ declare class OwneySDK {
1877
2803
  symbol: string;
1878
2804
  };
1879
2805
  agentId?: AgentId;
2806
+ /**
2807
+ * Agents the deposit must not fund (see `DepositOptions.excludeAgentIds`).
2808
+ * Checked before the quote, so a swap that could not end in a deposit never
2809
+ * starts. Not stored on a pending deposit: whoever finishes one later
2810
+ * passes the then-current list to `completePendingDeposit(id, options)`.
2811
+ */
2812
+ excludeAgentIds?: AgentId[];
1880
2813
  /** Percent, classic rail only. Fusion+ prices through its auction. */
1881
2814
  slippage?: number;
1882
2815
  onSwapProgress?: (stage: SwapStage) => void;
@@ -1888,6 +2821,9 @@ declare class OwneySDK {
1888
2821
  assertCurrent?: () => void;
1889
2822
  /** Funding-ledger reference for this swap and its deposit. Generated when omitted. */
1890
2823
  operationId?: string;
2824
+ /** Groups this swap and deposit with the others started by one user action
2825
+ * (see `DepositOptions.batchId`). Saved on the pending deposit record. */
2826
+ batchId?: string;
1891
2827
  }): Promise<{
1892
2828
  swap: {
1893
2829
  received: string;
@@ -2003,6 +2939,12 @@ declare class OwneySDK {
2003
2939
  * omitted; a continuation reuses the one saved on its record.
2004
2940
  */
2005
2941
  operationId?: string;
2942
+ /**
2943
+ * Groups this withdrawal with the others started by one user action (see
2944
+ * `WithdrawOptions.batchId`). Saved on the record, so a continuation
2945
+ * reports into the same batch.
2946
+ */
2947
+ batchId?: string;
2006
2948
  }): Promise<{
2007
2949
  withdraw: OwneyWithdrawResult | AgentWithdrawResult;
2008
2950
  /** What actually arrived in the wallet, smallest unit of the agent's asset. */
@@ -2057,6 +2999,13 @@ declare class OwneySDK {
2057
2999
  * hold this SDK does not know about is left to the server's expiry.
2058
3000
  */
2059
3001
  releaseWithdrawalReservation(operationId: string, reason: ReservationReleaseReason, agents?: ReservationAgent[]): Promise<void>;
3002
+ /**
3003
+ * Reports a withdrawal step the app closed as never sent (a reload before its
3004
+ * request was saved) as a failed ledger leg with `NOT_SUBMITTED`, so other
3005
+ * devices and later recovery stop treating it as in flight. Refuses any step
3006
+ * with a hash or a saved request. Never touches the hold; never throws.
3007
+ */
3008
+ reportWithdrawalNotSubmitted(operationId: string, evidence: FundingEvidence): Promise<void>;
2060
3009
  /**
2061
3010
  * Reports a withdrawal leg that was proven after its call ended (a hashless
2062
3011
  * Zyfai payout found on chain or in history) to the funding ledger, then
@@ -2067,6 +3016,15 @@ declare class OwneySDK {
2067
3016
  * the server re-verifies the hash. Never throws.
2068
3017
  */
2069
3018
  reportWithdrawalRecovery(operationId: string, evidence: FundingEvidence): Promise<void>;
3019
+ /**
3020
+ * Reports a deposit leg that the app's recovery verified on chain after its
3021
+ * call ended to the funding ledger. Only evidence whose transfer is confirmed
3022
+ * with a transaction hash is reported; anything else is ignored. The ledger
3023
+ * PATCHes the existing operation (creating it only on a 404) and the server
3024
+ * re-verifies the hash. Deposits hold no reservation, so nothing is released.
3025
+ * Never throws.
3026
+ */
3027
+ reportDepositRecovery(operationId: string, evidence: FundingEvidence): Promise<void>;
2070
3028
  private withdrawFromAgents;
2071
3029
  /** Read-only invalidation after new pool-deposit activity. Does not restart
2072
3030
  * funding reconciliation, bypass cooldowns, or authorize a transaction. */
@@ -2076,10 +3034,24 @@ declare class OwneySDK {
2076
3034
  * @param agentId - Optional. Agent to query. Omit for aggregated balances.
2077
3035
  * @returns {AgentBalance} for a single agent, or {OwneyBalances} with totalBalance and per-agent breakdown
2078
3036
  */
3037
+ /**
3038
+ * Withdraw every position the wallet holds, across chains and assets.
3039
+ *
3040
+ * `withdraw()` drains one asset on one chain, so this is N of those. It
3041
+ * deliberately does not stop at the first failure: the funds in the other
3042
+ * positions are just as withdrawable, and someone who asked for everything
3043
+ * is better served by three of four than by none. Each leg reports its own
3044
+ * outcome so the caller can name the ones that did not arrive; only a total
3045
+ * failure throws.
3046
+ *
3047
+ * @returns {OwneyWithdrawAllResult} one leg per position attempted.
3048
+ */
3049
+ withdrawAll(): Promise<OwneyWithdrawAllResult>;
2079
3050
  getBalances(agentId?: AgentId, options?: {
2080
3051
  chainId?: number;
2081
3052
  asset?: OwneySupportedTokens;
2082
3053
  }): Promise<OwneyBalances | AgentBalance>;
3054
+ private readBalances;
2083
3055
  /** Preserve failure objects for withdrawal recovery without changing public balance results. */
2084
3056
  private readAggregatedBalances;
2085
3057
  /**
@@ -2111,8 +3083,47 @@ declare class OwneySDK {
2111
3083
  * subtract from the total. Without an agentId the series is the sum of the
2112
3084
  * agents that answered.
2113
3085
  */
2114
- getDailyEarnings({ agentId, days, tokenSymbol, }: DailyEarningsOptions): Promise<AccountDailyEarnings>;
2115
- getAccountApy({ agentId, days, tokenSymbol, }: AccountApyOptions): Promise<OwneyAccountApy | AccountAgentApy>;
3086
+ getDailyEarnings({ agentId, days, tokenSymbol, chainIds, }: DailyEarningsOptions): Promise<AccountDailyEarnings>;
3087
+ /**
3088
+ * The deposit-time pool catalogue (ROUT-569): every protocol with its
3089
+ * selectable pools (name, APY, TVL, link) for `asset` under `strategy`.
3090
+ * Defaults to the zyfai agent, the only one with pool customization today.
3091
+ */
3092
+ getPoolCatalog(params: {
3093
+ asset: OwneySupportedTokens;
3094
+ strategy: "conservative" | "aggressive" | "yieldmaxxing";
3095
+ agentId?: AgentId;
3096
+ }): Promise<PoolCatalogProtocol[]>;
3097
+ /**
3098
+ * Apply a user's deposit-time pool selection to their account (ROUT-569).
3099
+ * The request carries explicit pool choices plus the resulting strategy for
3100
+ * each asset reviewed in the deposit flow.
3101
+ */
3102
+ setPoolSelection(params: {
3103
+ selection: UserPoolSelectionRequest;
3104
+ agentId?: AgentId;
3105
+ }): Promise<void>;
3106
+ /**
3107
+ * The pool selection saved on the user's account (ROUT-650), so the Pools
3108
+ * step can show what applies now rather than the defaults. `pairs` and
3109
+ * `assets` say which protocol/chain lists and strategies to read.
3110
+ */
3111
+ getPoolSelection(params: {
3112
+ pairs: Array<{
3113
+ protocolId: string;
3114
+ chainId: number;
3115
+ }>;
3116
+ assets: Array<"USDC" | "WETH">;
3117
+ agentId?: AgentId;
3118
+ }): Promise<SavedPoolSelection>;
3119
+ /**
3120
+ * The agents a person can customize pools for: registered, enabled, and
3121
+ * able to list a pool catalogue. Waits for agent initialization, so an agent
3122
+ * the organization disabled is known and left out.
3123
+ */
3124
+ getPoolCustomizationAgents(): Promise<AgentId[]>;
3125
+ getAccountApy({ agentId, days, tokenSymbol, chainId: scope, }: AccountApyOptions): Promise<OwneyAccountApy | AccountAgentApy>;
3126
+ private enrichApyHistory;
2116
3127
  /**
2117
3128
  * Get transaction history for a specific agent, or all agents.
2118
3129
  *
@@ -2256,8 +3267,14 @@ declare class YieldseekerAgent implements IAgent {
2256
3267
  private readonly agentContexts;
2257
3268
  private readonly walletContexts;
2258
3269
  private readonly agentAccountReads;
3270
+ private readonly sessionAgents;
2259
3271
  private readonly reportedAccounts;
2260
3272
  private readonly missingSlots;
3273
+ private readonly rethrownSlotFailures;
3274
+ private readonly closedSlots;
3275
+ private readonly pendingReopens;
3276
+ private readonly unavailableSlots;
3277
+ private readonly pendingReactivates;
2261
3278
  private readonly freshListReads;
2262
3279
  private readonly knownContextKeys;
2263
3280
  private readonly pendingSlotInvalidations;
@@ -2276,11 +3293,15 @@ declare class YieldseekerAgent implements IAgent {
2276
3293
  private readonly endpointReadFailures;
2277
3294
  private readonly reconcileUntil;
2278
3295
  private readonly allocationRefresh;
3296
+ /** Contexts whose next permitted snapshot read is forced once: a funding
3297
+ * invalidation with a tx hash (receipt recovery, a re-armed refresh). */
3298
+ private readonly forceNextSnapshot;
2279
3299
  private readonly activityRefreshUntil;
2280
3300
  private readonly snapshotMovements;
2281
3301
  private readonly movementEpochs;
2282
3302
  private readonly settlementChecks;
2283
3303
  private ledgerAccess?;
3304
+ private accountRefusedListener?;
2284
3305
  private readonly ledgerReads;
2285
3306
  /** contextKey -> movements this instance started settling (by tx hash) and how they refresh:
2286
3307
  * awaiting the ledger, refreshed when ready (ledger), or on the timed backoff (legacy). */
@@ -2299,6 +3320,7 @@ declare class YieldseekerAgent implements IAgent {
2299
3320
  private ledgerBudgetMs;
2300
3321
  /** slotKey -> the last successful ledger rows and when they arrived. */
2301
3322
  private readonly lastLedgerRows;
3323
+ /** Keyed by `vaultOptionsKey`: each asset's usable list and its full list are cached apart. */
2302
3324
  private readonly vaultOptions;
2303
3325
  private readonly pendingVaultOptions;
2304
3326
  private readonly assetApyStats;
@@ -2309,6 +3331,33 @@ declare class YieldseekerAgent implements IAgent {
2309
3331
  getWalletStatus(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, useCachedV2?: boolean): Promise<YieldseekerWalletStatus | null>;
2310
3332
  /** Reads (or reuses the 15-minute verified V2 hint for) this exact context's wallet. */
2311
3333
  private readWalletStatus;
3334
+ /**
3335
+ * Deposits go only to an agent Yieldseeker still has open. The session caches
3336
+ * the selected agent, so a tab left open can hold one Yieldseeker has since
3337
+ * closed (deactivated). This reads the agent wallet fresh from Yieldseeker,
3338
+ * bypassing the cached wallet contexts, and:
3339
+ * - open, same wallet address: returns the context to deposit with;
3340
+ * - closed (`deactivatedDate` set): reactivates it, re-reads the wallet, and
3341
+ * continues only when it is now open with the same address. Only the
3342
+ * verified record's agent is reopened: any other closed agent (a
3343
+ * superseded-wallet match, or the agent this session created or adopted
3344
+ * before its record exists, also when the accounts could not be read)
3345
+ * refuses without a request;
3346
+ * - anything else refuses with nothing sent, before any progress event,
3347
+ * signature or callback. Every refusal carries `notSubmitted` and
3348
+ * `safeToFallback: false`, so no paid fallback runs.
3349
+ * A slot recorded unavailable (the active-agent limit) refuses at once with
3350
+ * no request. The reactivate goes through reactivateSlot, which shares one
3351
+ * request per slot and remembers a failure for the list-cache window, so
3352
+ * repeated deposits do not repeat it. A failed wallet read fails closed
3353
+ * (YIELDSEEKER_WALLET_UNVERIFIED, reason UNAVAILABLE), like the on-chain
3354
+ * gate. A reactivate that fails keeps its error code
3355
+ * (YIELDSEEKER_AGENT_CLOSED, or the mapped API error for a transient
3356
+ * failure). At the limit the slot is also recorded unavailable for the
3357
+ * session (see isSlotUnavailable). Session changes keep their own
3358
+ * NOT_CONNECTED error.
3359
+ */
3360
+ private assertAgentOpen;
2312
3361
  /**
2313
3362
  * Deposits go only to a wallet whose identity is verified on chain (factory
2314
3363
  * mapping, owner, base asset, FACTORY). The API key is public, so the wallet
@@ -2325,9 +3374,39 @@ declare class YieldseekerAgent implements IAgent {
2325
3374
  status: YieldseekerWalletStatus;
2326
3375
  }>;
2327
3376
  disconnect(): Promise<void>;
3377
+ /**
3378
+ * Whether connecting now would ask the wallet to sign in: no reusable saved
3379
+ * sign-in for this wallet and chain. Never prompts; reads only what is saved.
3380
+ */
3381
+ needsSignIn(state: ConnectionState, chainId: number): boolean;
3382
+ /**
3383
+ * The connect's account check (2026-11-13), run before any agent activates:
3384
+ * sign in (a saved sign-in, else login-with-wallet, else POST /users for a
3385
+ * wallet with no account, which is Owney's by definition), then ask Owney's
3386
+ * routing whether the account was created through Owney. Refused:
3387
+ * AGENT_ACCOUNT_NOT_OWNEY, permanent, and the listener is told. Cannot tell
3388
+ * yet: the Retry-After is waited once when it is 30 s or less, otherwise a
3389
+ * temporary failure. Lists, creates and reads no agent.
3390
+ */
3391
+ checkAccount(state: ConnectionState, chainId: number): Promise<void>;
3392
+ /**
3393
+ * Ready every asset's agent, `asset` first: a missing one is created and a
3394
+ * closed one reopened (2026-11-06). A slot Yieldseeker will never let the
3395
+ * user have (the agent limit, closed for good, missing with no way to
3396
+ * reopen) is rethrown with `details.permanent`, which refuses the connect.
3397
+ * A temporary failure (an API error or timeout) on another asset does not:
3398
+ * that slot answers again where it is needed. On the selected asset every
3399
+ * failure is thrown as before, without readying the rest, so a failed
3400
+ * sign-in never opens a second prompt.
3401
+ */
2328
3402
  activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
3403
+ /** The same failure, marked as one that will not go away this session. */
3404
+ private permanentFailure;
3405
+ isSlotUnavailable(state: ConnectionState, chainId: number, asset: OwneySupportedTokens): boolean;
2329
3406
  deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback, onProgress?: FundingProgress, onBeforeSubmission?: (evidence: FundingEvidence) => void | Promise<void>): Promise<OwneyDepositResult>;
2330
- withdraw(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, amount?: string, onProgress?: FundingProgress, gasMode?: "auto" | "sponsored" | "paid", onBeforeSubmission?: FundingProgress, assertOperation?: () => void): Promise<AgentWithdrawResult>;
3407
+ withdraw(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, amount?: string, onProgress?: FundingProgress, gasMode?: "auto" | "sponsored" | "paid", onBeforeSubmission?: FundingProgress, assertOperation?: () => void, submission?: {
3408
+ operationId?: string;
3409
+ }): Promise<AgentWithdrawResult>;
2331
3410
  private withdrawInternal;
2332
3411
  /** Fresh position amounts for withdrawal planning, net of reserved fees. */
2333
3412
  getWithdrawableBalance(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, minimumAmount?: bigint): Promise<bigint>;
@@ -2344,22 +3423,164 @@ declare class YieldseekerAgent implements IAgent {
2344
3423
  private withdrawalVaultHints;
2345
3424
  private readWithdrawalPositions;
2346
3425
  private resolveWithdrawalLiquidity;
3426
+ hasReadSession(state: ConnectionState, chainId: number): boolean;
2347
3427
  getBalances(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<AgentBalance>;
2348
3428
  verifyWithdrawalBalance(state: ConnectionState, evidence: FundingEvidence, balance: AgentBalance): Promise<AssetReadMetadata | undefined>;
2349
3429
  invalidateAllocationRead(state: ConnectionState, chainId: number, asset: OwneySupportedTokens): void;
2350
3430
  invalidateFundingRead(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, refreshUntil?: number, txHash?: string): void;
2351
3431
  endFundingBalanceRefresh(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, read: AssetReadMetadata): boolean;
3432
+ /**
3433
+ * Tells Yieldseeker a deposit landed (`deposit-made`), so the agent allocates
3434
+ * it now instead of on its next 30-minute check, and confirms it did.
3435
+ * Yieldseeker decides whether anything moves (the funding minimum, a
3436
+ * deployed agent, no manual withdrawal in the last hour), and its answer
3437
+ * (`{}`) does not say, so a minute after each notice the agent reads its
3438
+ * wallet: the deposit has gone into a vault when less than its amount is
3439
+ * left idle. While it has not, Yieldseeker is told again, up to
3440
+ * DEPOSIT_NOTICE_ATTEMPTS calls in all; a failed call (network, server, rate
3441
+ * limit) is sent again after a wait. Within an hour of a withdrawal it is
3442
+ * told once, since nothing can move yet. Uses the agent this session already
3443
+ * knows for the asset and the saved sign-in only: never prompts, never
3444
+ * throws. Each call is reported through `onNotice`.
3445
+ */
3446
+ depositConfirmed(state: ConnectionState, chainId: number, evidence: FundingEvidence, onNotice?: (notice: DepositNotice & {
3447
+ attempt: number;
3448
+ }) => void): Promise<DepositNotice>;
3449
+ /** One `deposit-made` call. A failure that may pass on its own carries the wait before the next try. */
3450
+ private sendDepositNotice;
3451
+ /**
3452
+ * Tells Yieldseeker (`deposit-made`) after a pool save, so the agent runs
3453
+ * now and rebalances money already in a vault the list no longer allows.
3454
+ * Up to DEPOSIT_NOTICE_ATTEMPTS calls in all, waiting between them only
3455
+ * after a failure that may pass; stops when the session ends. Never throws.
3456
+ */
3457
+ private rebalanceAfterPoolSave;
3458
+ /**
3459
+ * When Yieldseeker may move funds again after this agent wallet's last
3460
+ * confirmed withdrawal, if that is still ahead; null when there was none in
3461
+ * the last hour or the ledger cannot say.
3462
+ */
3463
+ private withdrawalCooldownEnd;
3464
+ /**
3465
+ * The agent wallet's base-asset balance and the platform fee Yieldseeker has
3466
+ * not collected from it, read at one block for a balance read. Cached
3467
+ * briefly per agent wallet and dropped by funding and allocation
3468
+ * invalidations. Null when any read fails or is slow: the snapshot's
3469
+ * amounts are used instead.
3470
+ */
3471
+ private readLiveWallet;
3472
+ private readWalletFunds;
3473
+ /** The agent wallet's idle base asset; null when the read fails. */
3474
+ private readIdleBalance;
2352
3475
  getFundingWallet(state: ConnectionState, chainId: number, asset: OwneySupportedTokens): Promise<string>;
2353
3476
  hasExistingDepositFunds(state: ConnectionState, chainId: number, asset: OwneySupportedTokens): Promise<true | undefined>;
2354
3477
  getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
2355
- getAccountApy(state: ConnectionState, chainId: number, days: DailyApyDays, tokenSymbol?: string): Promise<AccountAgentApy>;
3478
+ getAccountApy(state: ConnectionState, chainId: number, days: DailyApyDays, tokenSymbol?: string,
3479
+ /** The chart's chain filter (ROUT-479); null is every chain. */
3480
+ scopeChainId?: number | null): Promise<AccountAgentApy>;
2356
3481
  getDailyEarnings(state: ConnectionState, chainId: number, days: LookbackDays, tokenSymbol?: string): Promise<AccountDailyEarnings>;
2357
3482
  getHistory(state: ConnectionState, chainId: number, options?: HistoryFilters): Promise<OwneyAgentHistory>;
2358
3483
  getUserProfile(state: ConnectionState, chainId: number): Promise<AgentUserProfile>;
2359
3484
  getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
2360
3485
  supportsAgentApyPeriod(days: DailyApyDays): boolean;
2361
3486
  private loadAssetApyStats;
3487
+ /**
3488
+ * The deposit-time Pools step's catalogue: every vault Yieldseeker lists
3489
+ * for a new agent on `asset` on Base, grouped by provider (the provider is
3490
+ * both `protocolId` and `name`). Nothing is filtered on our side, on
3491
+ * liquidity, size or provider. `strategy` is accepted for the IAgent
3492
+ * contract and ignored.
3493
+ */
3494
+ getPoolCatalog(params: {
3495
+ asset: string;
3496
+ strategy?: "conservative" | "aggressive" | "yieldmaxxing";
3497
+ }): Promise<PoolCatalogProtocol[]>;
3498
+ /**
3499
+ * The asset's vaults on Base. By default only those a new agent can use:
3500
+ * Yieldseeker leaves out the ones it has disabled (40acres and Moonwell
3501
+ * among them), gated or can't use, so the picker follows its list
3502
+ * (2026-11-04). `includeUnavailable` adds those back, for anything about
3503
+ * money an agent may still hold in one: withdrawals and activity.
3504
+ */
2362
3505
  private loadVaultOptions;
3506
+ /**
3507
+ * Save the user's Yieldseeker picks as the agent's managed vault list, then
3508
+ * read the rules back before any money moves. Each asset has its own agent,
3509
+ * so each is saved on its own. `pools` and `availablePools` hold vault
3510
+ * addresses.
3511
+ *
3512
+ * - Only Base entries are ours. An asset with no picks whose entries showed
3513
+ * no vault is skipped and nothing is sent.
3514
+ * - None picked (vaults shown) for any asset: every agent keeps at least one
3515
+ * pool (2026-11-11), so the whole save throws POOL_SELECTION_REQUIRED
3516
+ * before anything is written, for any asset.
3517
+ * - Some vaults picked: the managed list names them. Saving it again
3518
+ * replaces it, so there is only ever one.
3519
+ * - Every vault picked: the managed list is deleted, and no allow-list may
3520
+ * remain, so vaults Yieldseeker adds later are allowed too.
3521
+ * - A free-text allow-list we saved before the managed list existed is
3522
+ * deleted once the new state is written. A failed delete does not fail the
3523
+ * save; it is debug-logged, and the read-back decides.
3524
+ * - A read-back that differs puts the previous managed list back (or deletes
3525
+ * the one just created) and throws POOL_SELECTION_NOT_APPLIED. If putting
3526
+ * it back fails too, that is still the error thrown. An old free-text list
3527
+ * already deleted is not put back.
3528
+ * - An agent already holding the most active memories, none of them ours,
3529
+ * throws POOL_SELECTION_RULE_LIMIT before anything is written.
3530
+ *
3531
+ * Always Base, whichever chain the wallet is connected on.
3532
+ */
3533
+ setPoolSelection(selection: UserPoolSelectionRequest, state?: ConnectionState): Promise<void>;
3534
+ private savePoolPicks;
3535
+ /**
3536
+ * Delete the free-text allow-lists we saved before the managed list existed.
3537
+ * Never throws: a list left behind is caught by the read-back. Logs no
3538
+ * sign-in token.
3539
+ */
3540
+ private deleteLegacyPoolMemories;
3541
+ /**
3542
+ * `<address> (<name>)` for each pick, under the prefix. An unnamed address
3543
+ * has no brackets. There is always at least one pick (setPoolSelection
3544
+ * refuses a save with none).
3545
+ */
3546
+ private poolMemoryContent;
3547
+ /** Undo a failed save of the managed list. Never throws: the caller reports the save's own failure. */
3548
+ private restorePoolMemory;
3549
+ /**
3550
+ * What the user's Yieldseeker agents currently allow, as `SavedPoolSelection`
3551
+ * pairs: the allowed vault addresses under the provider each belongs to, for
3552
+ * the vaults a new agent can use. An agent with no allow-list adds nothing,
3553
+ * and no pairs at all means every shown vault is on. Reads never create an
3554
+ * agent, and always read Base. A read that fails throws, because "no
3555
+ * allow-list" would wrongly mean "everything".
3556
+ *
3557
+ * An allow-list naming none of the listed vaults (the saved "none", or vaults
3558
+ * Yieldseeker has since stopped listing) leaves the agent nowhere to go, so
3559
+ * it reports none chosen for its asset: a pair with empty `pools` for every
3560
+ * provider listing vaults for it. With no vault listed at all there is
3561
+ * nothing to name that by, and it throws: the rules still restrict the agent.
3562
+ *
3563
+ * `pairs` is accepted for the contract but does not trim the answer: cutting
3564
+ * a real allow-list down to the pairs asked about could leave none, and none
3565
+ * reads as every vault on.
3566
+ */
3567
+ getPoolSelection(state: ConnectionState, _chainId: number, params: {
3568
+ pairs: Array<{
3569
+ protocolId: string;
3570
+ chainId: number;
3571
+ }>;
3572
+ assets: Array<"USDC" | "WETH">;
3573
+ }): Promise<SavedPoolSelection>;
3574
+ /**
3575
+ * The allow-list in the agent's rules: every `allowedVaultAddresses` on an
3576
+ * `ignored_vault` user rule. Undefined when no rule has one, which allows
3577
+ * every vault; an empty list allows none. A response that does not have the
3578
+ * expected shape throws rather than reading as no allow-list.
3579
+ */
3580
+ private readAllowList;
3581
+ private listMemories;
3582
+ /** A memory call for an agent, on Base whichever chain the wallet is on. */
3583
+ private memoryRequest;
2363
3584
  private userKey;
2364
3585
  /** One deposit/withdraw slot: owner, chain and asset. */
2365
3586
  private slotKey;
@@ -2387,8 +3608,9 @@ declare class YieldseekerAgent implements IAgent {
2387
3608
  private listAgents;
2388
3609
  /**
2389
3610
  * The routing API's stored accounts for owner+chain, read once per session.
2390
- * Resolves null when unavailable (callers keep name matching) and never
2391
- * rejects. A failure is retried after a short window.
3611
+ * Resolves null when unavailable and never rejects; callers then refuse
3612
+ * (AGENT_ACCOUNTS_UNAVAILABLE) and create nothing. A failure is not kept:
3613
+ * concurrent callers share the in-flight read, and the next call reads again.
2392
3614
  */
2393
3615
  private agentAccounts;
2394
3616
  /** Yieldseeker accounts for one slot (returned addresses are compared lowercase). */
@@ -2399,25 +3621,87 @@ declare class YieldseekerAgent implements IAgent {
2399
3621
  * highest-priority set of `priorities` (index 0 first). Hinted agentIds are
2400
3622
  * resolved first and a hinted top-priority match ends the search; then other
2401
3623
  * listed agents, at most YIELDSEEKER_WALLET_MATCH_LIMIT wallets in total.
3624
+ * A candidate whose wallet shows it closed (deactivated) never ranks, and its
3625
+ * agentId is added to `closed`.
2402
3626
  */
2403
3627
  private agentWithWallet;
2404
3628
  /**
2405
3629
  * chooseAgent, re-reading a cached list once (bypassing its cache) when the
2406
- * verified agent is missing. A slot still missing after that re-read is
2407
- * remembered for the list cache window, so later reads fail from the cached
2408
- * list without another re-read.
3630
+ * verified agent is missing. Still missing, Yieldseeker may have closed
3631
+ * (deactivated) it: the verified record's agent is reactivated and selected
3632
+ * from a fresh list, by the verified wallet only (never created). A slot
3633
+ * that still fails is remembered with its error for the list cache window,
3634
+ * so later reads fail without another re-read or reactivate. A slot
3635
+ * Yieldseeker will not reopen because of its active-agent limit throws
3636
+ * YIELDSEEKER_SLOT_UNAVAILABLE, here and for the rest of the session, with
3637
+ * no request.
2409
3638
  */
2410
3639
  private chooseAgentRefreshing;
2411
- private isSlotMissing;
3640
+ private throwIfSlotUnavailable;
3641
+ /**
3642
+ * Rethrow the error a slot's lookup failed with while the slot is still
3643
+ * marked, or for the session when Yieldseeker will never reopen its agent.
3644
+ * A remembered rate limit is rethrown with the time left on its marker as
3645
+ * its retry delay (`retryAfterSeconds`): no new attempt is made before then,
3646
+ * so a caller that waits it out retries once instead of every few seconds.
3647
+ */
3648
+ private throwIfSlotMissing;
3649
+ /**
3650
+ * Remember a slot's failed lookup or reactivate for the list-cache window.
3651
+ * A sign-in failure is not remembered (the wallet's rejection,
3652
+ * AGENT_AUTH_FAILED, NOT_CONNECTED): it says nothing about the slot, and
3653
+ * remembered it would refuse the next sign-in, even one the user starts,
3654
+ * with no request for the whole window.
3655
+ */
3656
+ private rememberMissingSlot;
3657
+ /**
3658
+ * Reactivate the slot's verified agent, then read the list bypassing its
3659
+ * cache, with a read sent after the reactivate answered. Concurrent lookups
3660
+ * of one slot share one reopen. Resolves to the fresh list. At the
3661
+ * active-agent limit the slot is recorded unavailable and this throws
3662
+ * YIELDSEEKER_SLOT_UNAVAILABLE.
3663
+ */
3664
+ private reopenAgent;
3665
+ /**
3666
+ * The one way to reactivate a slot's agent, for the slot lookup (reopenAgent)
3667
+ * and the pre-deposit check (assertAgentOpen), so a slot costs at most one
3668
+ * reactivate per list-cache window:
3669
+ * - a slot recorded unavailable (the limit) answers "limit" with no request;
3670
+ * - concurrent callers share one request;
3671
+ * - a failed reactivate (closed code, rate limit, timeout, 5xx...) is
3672
+ * remembered as the slot's failure for the list-cache window (missingSlots)
3673
+ * and rethrown to later callers with no request; a closed code
3674
+ * (closedSlots) for the session; a sign-in failure is not remembered;
3675
+ * - the limit is recorded in unavailableSlots only while the session is
3676
+ * unchanged, so a disconnect during the request is not undone by its late
3677
+ * answer.
3678
+ */
3679
+ private reactivateSlot;
3680
+ /**
3681
+ * Ask Yieldseeker to reopen a closed (deactivated) agent, with the user's
3682
+ * Yieldseeker sign-in. AGENT_NOT_DEACTIVATED (already open, e.g. reopened
3683
+ * by another tab) counts as reopened; the active-agent limit is an outcome,
3684
+ * not an error. An agent that cannot come back throws
3685
+ * YIELDSEEKER_AGENT_CLOSED; any other failure (rate limit, timeout, network,
3686
+ * 5xx, an unknown code) throws the mapped API error.
3687
+ */
3688
+ private reactivateAgent;
3689
+ /** Drop the cached and in-flight wallet contexts of one agent, in every slot. */
3690
+ private forgetAgentWallet;
2412
3691
  /**
2413
3692
  * The agent that serves deposits and withdrawals for a slot (Ruling 23):
2414
3693
  * 1. the listed fitting agent whose wallet is the verified account's wallet,
2415
3694
  * whatever its name; the stored agentId is only a hint;
2416
3695
  * 2. else a listed fitting agent whose wallet is a superseded account's wallet;
2417
- * 3. else the fitting agent named "owney" (first use, migration, or a
2418
- * verified wallet that is not a fitting listed agent);
2419
- * 4. else, with a verified account, throw YIELDSEEKER_AGENT_MISSING (never
2420
- * create); without one, undefined (the caller may create).
3696
+ * 3. else, with a verified account, throw YIELDSEEKER_AGENT_MISSING (never
3697
+ * create);
3698
+ * 4. else, with no record at all, the listed agent this session created or
3699
+ * adopted for the slot (sessionAgents); without one, undefined (the
3700
+ * caller creates an agent named "owney"). An agent is never picked by
3701
+ * its name: only our records, and this session's own create, say which
3702
+ * agents are Owney's.
3703
+ * Without the account records (`null`: the read failed) nothing can be
3704
+ * known, so the call is refused and nothing is created.
2421
3705
  * Steps 1 and 2 share one search of at most YIELDSEEKER_WALLET_MATCH_LIMIT
2422
3706
  * wallet reads. The account report then records the selected wallet; the
2423
3707
  * server marks it superseded when it differs from the verified wallet.
@@ -2425,6 +3709,19 @@ declare class YieldseekerAgent implements IAgent {
2425
3709
  private chooseAgent;
2426
3710
  private isAgentMissing;
2427
3711
  private agentMissing;
3712
+ private slotUnavailable;
3713
+ /** The slot has no usable agent: missing, at Yieldseeker's agent limit, or closed for good. */
3714
+ private isSlotEmpty;
3715
+ /**
3716
+ * The slot's lookup failed through the missing-agent / reopen path and was
3717
+ * remembered with this very error, even a transient one (429, 5xx, timeout),
3718
+ * or with the copy of it a remembered rate limit is rethrown as. Compares
3719
+ * the remembered error, not its expiry, so it holds however long the rest
3720
+ * of the read takes.
3721
+ */
3722
+ private isMarkedSlotFailure;
3723
+ /** providerCode is absent when Yieldseeker named none (the agent stayed closed after a reopen). */
3724
+ private agentClosed;
2428
3725
  /**
2429
3726
  * Fire-and-forget: record which agent serves this slot. Never awaited on the
2430
3727
  * funds path and never throws; once per agent wallet and deployment state
@@ -2437,7 +3734,12 @@ declare class YieldseekerAgent implements IAgent {
2437
3734
  private ensureAgent;
2438
3735
  private findAgent;
2439
3736
  private resolveAgent;
2440
- /** Create the slot's agent. Only reached when no stored or named agent matched. */
3737
+ /**
3738
+ * Create the slot's agent, named "owney". Only reached when the slot has no
3739
+ * account record and no agent this session made; the created agent is
3740
+ * remembered for the session (sessionAgents) so reads select it before its
3741
+ * record exists.
3742
+ */
2441
3743
  private createAgent;
2442
3744
  /**
2443
3745
  * The routing create lock refused the create: another tab or app owns or is
@@ -2464,11 +3766,16 @@ declare class YieldseekerAgent implements IAgent {
2464
3766
  private snapshotMovement;
2465
3767
  private advancePortfolioVersion;
2466
3768
  private requestPortfolioSnapshot;
3769
+ private snapshotPath;
3770
+ /** True while `walletRequest` would refuse a read of `path`: this user's
3771
+ * rate-limit cooldown or that endpoint's outage cooldown. */
3772
+ private readCoolingDown;
2467
3773
  private portfolioSnapshot;
2468
3774
  private loadPortfolioContext;
2469
3775
  private loadActivityContext;
2470
3776
  private loadPortfolioParts;
2471
3777
  private deployAgent;
3778
+ setAccountRefusedListener(listener: (() => void) | undefined): void;
2472
3779
  setFundingLedgerAccess(access: AgentFundingLedgerAccess | undefined): void;
2473
3780
  private historyKey;
2474
3781
  /** Funding-ledger rows for this slot, cached 15 s. Never throws: null on any failure. */
@@ -2525,12 +3832,19 @@ declare class YieldseekerAgent implements IAgent {
2525
3832
  private agentPath;
2526
3833
  private walletRequest;
2527
3834
  private providerRequest;
3835
+ /**
3836
+ * mapApiError for a request that may have opened the Yieldseeker sign-in
3837
+ * prompt (providerRequest signs when no sign-in is saved, and again when
3838
+ * Yieldseeker refuses one). The wallet's rejection, the user cancelling that
3839
+ * prompt, is returned unchanged: the client and the app must see the user's
3840
+ * cancel (no further prompt, no retry), never a provider failure.
3841
+ */
3842
+ private mapRequestFailure;
2528
3843
  private mapApiError;
2529
3844
  private submitTransaction;
2530
3845
  private waitForReceipt;
2531
3846
  private assertTransaction;
2532
3847
  private assertAgent;
2533
- private isOwneyAgent;
2534
3848
  private assetForAgent;
2535
3849
  private isTransactionHash;
2536
3850
  private assertChain;
@@ -2580,6 +3894,23 @@ type OwneySIWXConfig = {
2580
3894
  */
2581
3895
  declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
2582
3896
 
3897
+ /**
3898
+ * Ask the wallet ITSELF to switch networks, over WalletConnect.
3899
+ *
3900
+ * WalletConnect's provider answers `wallet_switchEthereumChain` locally when
3901
+ * the chain was approved at connect time: it moves its own default chain and
3902
+ * reports success without telling the wallet. MetaMask mobile then stays on
3903
+ * its network, keeps reporting it, and every guard downstream fails with
3904
+ * CHAIN_MISMATCH — after a swap, with the user's funds already moved (ROUT-727).
3905
+ * Sending the request through the session client reaches the wallet, which
3906
+ * shows a real "switch network" prompt; the client also deep-links the wallet
3907
+ * app open on mobile.
3908
+ *
3909
+ * Returns false when `provider` is not a WalletConnect session, so the caller
3910
+ * can fall back to an ordinary switch.
3911
+ */
3912
+ declare function switchWalletConnectChain(provider: unknown, chainId: number, timeoutMs?: number): Promise<boolean>;
3913
+
2583
3914
  /**
2584
3915
  * Persists cross-chain swap secrets so an in-flight order survives a reload.
2585
3916
  *
@@ -2610,6 +3941,26 @@ type StoredOrder = {
2610
3941
  amount: string;
2611
3942
  /** Epoch ms, for ordering recovery records. */
2612
3943
  createdAt: number;
3944
+ /**
3945
+ * A swap-deposit's deposit half, so a resume that finishes the swap can
3946
+ * record it (ROUT-625). `received` is the quote's guaranteed minimum. Absent
3947
+ * on plain swaps and on records written by an older SDK.
3948
+ */
3949
+ pendingDeposit?: {
3950
+ received: string;
3951
+ symbol: string;
3952
+ chainId: number;
3953
+ agentId?: string;
3954
+ operationId?: string;
3955
+ /** The user action's batch (see `DepositOptions.batchId`), carried to the recorded pending deposit. */
3956
+ batchId?: string;
3957
+ };
3958
+ /**
3959
+ * Our routing API accepted these secrets (part 5's opt-in handoff) and
3960
+ * publishes them itself once 1inch is ready. Informational: this browser
3961
+ * still publishes and resumes as before. Absent when no handoff was accepted.
3962
+ */
3963
+ serverSecrets?: true;
2613
3964
  };
2614
3965
  /**
2615
3966
  * Every unresolved stored order, newest first.
@@ -2617,6 +3968,13 @@ type StoredOrder = {
2617
3968
  */
2618
3969
  declare function listOrders(_now?: number): StoredOrder[];
2619
3970
 
3971
+ /**
3972
+ * Capability flag (part 5): this SDK can hand a signed Fusion+ order's secrets
3973
+ * to the routing API (`handoffSecrets`), which then publishes each one when
3974
+ * 1inch is ready, even if this tab is gone. Older builds do not export this.
3975
+ */
3976
+ declare const FUSION_SECRET_SERVER_PUBLISH: 1;
3977
+
2620
3978
  /**
2621
3979
  * Non-blocking funding ledger reporter.
2622
3980
  *
@@ -2642,6 +4000,8 @@ type LedgerLegReport = {
2642
4000
  userOpHash?: string;
2643
4001
  callsId?: string;
2644
4002
  orderHash?: string;
4003
+ /** The provider's own id for this leg's request (Zyfai's v2 withdrawal id). */
4004
+ providerRef?: string;
2645
4005
  confirmedAmountRaw?: string;
2646
4006
  blockNumber?: string;
2647
4007
  errorCode?: string;
@@ -2660,4 +4020,26 @@ type LedgerLegReport = {
2660
4020
  };
2661
4021
  };
2662
4022
 
2663
- 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 ApyHistoryPoint, type Asset, type AssetDailyEarnings, type AssetReadMetadata, type AvailableAgent, type AvailableAgentsOptions, type ConnectionState, type DailyApyDays, type DailyEarningsOptions, type DailyEarningsPoint, type DepositAuthorizationReference, type DepositCallback, type DepositOptions, type DepositReplacementValidation, 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 OwneyAccountApy, type OwneyAgentApy, type OwneyAgentHistory, type OwneyAllocationApy, type OwneyBalances, type OwneyDepositResult, type OwneyEarnings, OwneyError, type OwneyErrorCode, type OwneyMultiDepositResult, type OwneyPosition, OwneySDK, type OwneySDKConfig, type OwneySIWXConfig, type OwneySupportedChainId, type OwneySupportedChains, type OwneySupportedTokens, type OwneyToken, type OwneyUserProfile, type OwneyWithdrawResult, type PendingDeposit, type ProviderSnapshotSample, type RebalanceLog, type ReservationAgent, type ReservationReleaseReason, type RpcUrlsConfig, SDK_VERSION, type SwapChainTokens, type SwapDirection, type SwapOrderStatus, type SwapQuote, type SwapQuoteParams, type SwapRail, type SwapStage, type SwapTokenInfo, type SwapTokenSearchResult, type UnsignedUserOperationEvidence, type WithdrawOptions, type WithdrawSwapRecord, type WithdrawSwapStatus, type WithdrawalCompletion, type WithdrawalCompletionContext, type WithdrawalPayoutCandidate, type WithdrawalPayoutScan, type WithdrawalReservationConflict, type WithdrawalReservationMode, type WithdrawalReservationOptions, type WithdrawalSwapRecovery, YieldseekerAgent, type YieldseekerWalletStatus, type ZyfaiRpcUrlsConfig, clearWithdrawSwap, createOwneySIWX, listPendingDeposits, listOrders as listPendingSwaps, listWithdrawSwaps, saveWithdrawSwap, setOwneyDebug, subscribeWithdrawSwaps, updateWithdrawSwap };
4023
+ /** This SDK hands every Zyfai withdrawal request to the caller's
4024
+ * `onBeforeSubmission` before sending it, and a failed checkpoint stops it.
4025
+ * A caller that persisted nothing for a dead run can therefore conclude the
4026
+ * request was never sent. Older builds do not export this. */
4027
+ declare const ZYFAI_WITHDRAW_DISPATCH_CHECKPOINT: 1;
4028
+
4029
+ /** Capability flag: this SDK opts in to the server sending an accepted
4030
+ * sponsored deposit itself (prepare `serverBroadcast: true`) and reports such a
4031
+ * deposit as pending, never "not sent". Older builds do not export this. */
4032
+ declare const SPONSORED_DEPOSIT_SERVER_BROADCAST: 1;
4033
+
4034
+ /** Capability flag: this SDK opts in to the server sending its signed sponsored
4035
+ * Yieldseeker withdrawal userOp itself (`serverSubmit=1` on its own
4036
+ * `eth_sendUserOperation`) and reports such a leg as pending, never "not sent".
4037
+ * Older builds do not export this. */
4038
+ declare const YIELDSEEKER_WITHDRAW_SERVER_SUBMIT: 1;
4039
+
4040
+ /** Capability flag: this SDK has `reportDepositRecovery`, which reports a
4041
+ * deposit leg the app's recovery verified on chain to the funding ledger.
4042
+ * Older builds do not export this. */
4043
+ declare const FUNDING_DEPOSIT_RECOVERY_REPORT: 1;
4044
+
4045
+ export { type AccountAgentApy, type AccountApyOptions, type AccountDailyEarnings, type ActivateAgentOptions, 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 ApyIncentive, 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 SignInProgress, 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, switchWalletConnectChain, updateWithdrawSwap };