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

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 = {
@@ -380,6 +387,32 @@ interface OwneySDKConfig {
380
387
  * `OWNEY_WITHDRAWAL_RESERVATION_DISABLED=1` in the environment acts as `"off"`.
381
388
  */
382
389
  withdrawalReservation?: "fail-open" | "fail-closed" | "off";
390
+ /**
391
+ * Hand Zyfai withdrawals and deposit registrations, with the user's Zyfai
392
+ * session, to the Owney routing API, which then sends them itself (default
393
+ * off). Only `true`, or a function that returns `true`, opts in.
394
+ *
395
+ * A function is called for each operation, at the moment it would first
396
+ * hand a withdrawal or a registration off, so an app can turn the handoff on
397
+ * or off in open tabs without a reload. A function that throws counts as
398
+ * off.
399
+ *
400
+ * Off, the SDK hands no new operation off, never sends the Zyfai session to
401
+ * Owney for it, and behaves as before. Turning it off never makes the
402
+ * browser send what the server may already hold: an operation this SDK
403
+ * instance already handed off keeps going through the server (its nudges,
404
+ * re-runs, retries and registration recovery). Recovery of a deposit handed
405
+ * off by an earlier page waits until it is on again.
406
+ */
407
+ zyfaiServerTasks?: boolean | (() => boolean);
408
+ /**
409
+ * Hand each signed cross-chain (Fusion+) order's secrets to the Owney
410
+ * routing API, which publishes them once 1inch is ready, so the swap
411
+ * completes even if the tab closes (default false). Only `true` opts in.
412
+ * Off, the secrets never leave the browser and swaps behave as before. On,
413
+ * the browser still publishes them too.
414
+ */
415
+ fusionSecretHandoff?: boolean;
383
416
  }
384
417
  interface ConnectionState {
385
418
  provider: any;
@@ -426,6 +459,44 @@ type OrgAgentConfig = {
426
459
  poolPolicy?: OrgPoolPolicy | null;
427
460
  };
428
461
 
462
+ /** Capability flag: this SDK can hand Zyfai withdrawals and deposit
463
+ * registrations to the server, and marks such legs with evidence `serverTask`.
464
+ * Older builds do not export this. */
465
+ declare const ZYFAI_SERVER_TASKS: 1;
466
+ /** A `zyfai_withdrawal` task that failed with one of these codes never sent
467
+ * the withdrawal to Zyfai. */
468
+ declare const ZYFAI_WITHDRAWAL_NOT_SENT_CODES: ReadonlySet<string>;
469
+ /** A `zyfai_deposit_registration` task that failed with one of these codes
470
+ * never registered the deposit with Zyfai, so the browser may register it. */
471
+ declare const ZYFAI_REGISTRATION_NOT_SENT_CODES: ReadonlySet<string>;
472
+ type ZyfaiTaskResult = {
473
+ providerWithdrawalId?: string;
474
+ providerDepositId?: string;
475
+ txHash?: string;
476
+ asyncPending?: true;
477
+ handedOff?: "reconciler";
478
+ lifecycle?: "failed";
479
+ };
480
+ /**
481
+ * - accepted: the server has a task for this leg (its state and code);
482
+ * - declined: the server proved no task was created (a 200 decline, or a 400,
483
+ * 401, 403, 404, 409 or 429; or `ZYFAI_SERVER_TASKS_OFF_CODE` without the
484
+ * opt-in);
485
+ * - unknown: anything else. The server may have a task.
486
+ */
487
+ type ZyfaiHandoffAnswer = {
488
+ type: "accepted";
489
+ taskId: string;
490
+ state: string;
491
+ code?: string;
492
+ result: ZyfaiTaskResult;
493
+ } | {
494
+ type: "declined";
495
+ code: string;
496
+ } | {
497
+ type: "unknown";
498
+ };
499
+
429
500
  type DepositCallback = (smartWalletAddress: string, chainId: number, amount: string) => Promise<`0x${string}`> | `0x${string}`;
430
501
  /**
431
502
  * Read access to the funding ledger, given to agents by the client so they can
@@ -466,6 +537,33 @@ interface IAgent {
466
537
  * rejected wallet request cannot happen after another leg has committed.
467
538
  */
468
539
  readonly withdrawalRequiresWalletApproval?: boolean;
540
+ /**
541
+ * Settles this agent's own wallet prompts (a login, a session key) so that a
542
+ * following `withdraw` needs none. A multi-agent withdrawal calls it before a
543
+ * wallet-approval agent's owner signature, so two prompts never overlap and
544
+ * this agent can start as soon as that signature was accepted. Never submits
545
+ * a withdrawal. A rejected prompt throws; other failures are left to `withdraw`.
546
+ */
547
+ prepareWithdrawal?(state: ConnectionState, chainId: number, token: OwneySupportedTokens): Promise<void>;
548
+ /**
549
+ * The adapter can hand its withdrawal to our server (part 4, Zyfai). Only
550
+ * such agents get the plan-time handoff and a `planned` withdraw context;
551
+ * every other agent keeps today's calls.
552
+ */
553
+ readonly supportsServerTasks?: true;
554
+ /**
555
+ * Hands a planned withdrawal leg to our server before an earlier
556
+ * wallet-approval leg is signed (`after`: those legs' keys). The server sends
557
+ * it once those legs are accepted. Never throws; never withdraws locally.
558
+ * `amount` is the leg's planned share, or "MAX". `beforeRequest` runs right
559
+ * before the request leaves (never when none is sent), so the caller can
560
+ * save the leg's server mark first.
561
+ */
562
+ handOffPlannedWithdrawal?(state: ConnectionState, chainId: number, token: OwneySupportedTokens, amount: string, ctx: {
563
+ operationId: string;
564
+ after: string[];
565
+ beforeRequest?: () => void;
566
+ }): Promise<ZyfaiHandoffAnswer>;
469
567
  disconnect(): Promise<void>;
470
568
  activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
471
569
  /**
@@ -481,8 +579,23 @@ interface IAgent {
481
579
  * unchanged rather than break the connect.
482
580
  */
483
581
  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>;
582
+ deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback, onProgress?: FundingProgress, onBeforeSubmission?: (evidence: FundingEvidence) => void | Promise<void>,
583
+ /** `operationId`: the funding ledger operation. Zyfai hands the deposit's
584
+ * registration to the server with it (only agents with
585
+ * `supportsServerTasks` get it; every other agent keeps today's call). */
586
+ context?: {
587
+ operationId?: string;
588
+ }): Promise<OwneyDepositResult>;
589
+ withdraw(state: ConnectionState, chainId: number, token: OwneySupportedTokens, amount?: string, onProgress?: FundingProgress, gasMode?: "auto" | "sponsored" | "paid", onBeforeSubmission?: FundingProgress, assertCurrent?: () => void,
590
+ /** `operationId`: the funding ledger operation (Yieldseeker opts in to the
591
+ * server-owned send of its sponsored userOp with it; Zyfai hands its
592
+ * withdrawal to the server with it). `planned`: the leg was handed to the
593
+ * server at plan time, so this call nudges that task (only for agents with
594
+ * `supportsServerTasks`). */
595
+ context?: {
596
+ operationId?: string;
597
+ planned?: true;
598
+ }): Promise<AgentWithdrawResult>;
486
599
  /** Read-only MAX proof at the owner payout block; never sends another withdrawal. */
487
600
  verifyWithdrawalCompletion?(state: ConnectionState, evidence: FundingEvidence): Promise<WithdrawalCompletion>;
488
601
  /** A newly observed pool allocation invalidates this asset's portfolio cache only. */
@@ -693,6 +806,10 @@ type DepositOptions = {
693
806
  assertSubmissionCurrent?: () => void;
694
807
  /** Resume only these already signed relayer bytes; never create a new authorization. */
695
808
  resumeTxHash?: `0x${string}`;
809
+ /** Resume only the saved signed batch of a deposit the server may be sending
810
+ * (its prepare got no answer, so no transaction hash is known); never create
811
+ * a new authorization. Check it first with `canResumePendingDeposit`. */
812
+ resumeSavedBatch?: true;
696
813
  onProgress?: FundingProgress;
697
814
  /** Awaited immediately before dispatch. Throwing prevents submission.
698
815
  * All legs of an atomic batch are checkpointed together. */
@@ -752,21 +869,68 @@ interface FundingEvidence {
752
869
  maxCompletion?: WithdrawalCompletionContext;
753
870
  maxCompletionCheck?: WithdrawalCompletion;
754
871
  intendedAmount: string;
872
+ /** A multi-agent withdrawal recorded this leg's planned amount (`intendedAmount`:
873
+ * the leg's share, or "MAX") before any agent was dispatched. A plan, not a
874
+ * submission: it never says the leg was sent. */
875
+ planned?: true;
876
+ /** The owner-authorized call of a wallet-approval withdrawal was accepted: the
877
+ * bundler accepted the signed userOp (`userOpHash`), the wallet returned a
878
+ * calls ID (`callsId`), or `eth_sendTransaction` returned a hash (`txHash`).
879
+ * Not confirmation: the call can still revert. */
880
+ ownerAuthorization?: "accepted";
755
881
  confirmedAmount?: string;
756
882
  /** Receipt delivery and fulfillment of a typed requested amount are separate facts. */
757
883
  amountCompletion?: "complete" | "shortfall";
758
884
  /** Verified difference between the typed request and the actual owner payout. */
759
885
  shortfallAmount?: string;
760
886
  txHash?: string;
887
+ /** Zyfai's id for this deposit, from its registration (1-128 chars); reads its placement status. */
888
+ providerDepositId?: string;
761
889
  /** Persisted before a sponsored EOA operation is sent. */
762
890
  userOpHash?: string;
763
891
  /** Lets recovery verify a consumed nonce even if a bundler forgets the operation. */
764
892
  userOperation?: UnsignedUserOperationEvidence;
765
893
  /** Base Account calls ID used to recover an uncertain wallet submission. */
766
894
  callsId?: string;
895
+ /** The server owns this sponsored Yieldseeker userOp's send (true), or may
896
+ * own it ("unknown": the opted-in send got no definitive answer). Either way
897
+ * the leg is never "not sent". Not acceptance, not confirmation. Never sent
898
+ * to the ledger. */
899
+ serverSubmit?: true | "unknown";
900
+ /** Zyfai server tasks. On a withdrawal leg: the server sends this withdrawal
901
+ * (true), or may send it ("unknown": the handoff got no definitive answer),
902
+ * so the browser never sends it. `false`: the server proved it has no task
903
+ * for this leg, so the browser sends it; it clears an earlier mark (a
904
+ * handoff checkpoint), and a merge must let it win over true and "unknown".
905
+ * On a deposit leg: the server registers this deposit. Not acceptance, not
906
+ * confirmation. Never sent to the ledger. */
907
+ serverTask?: true | "unknown" | false;
908
+ /** With `serverTask` on a Zyfai deposit leg: the client operation id of the
909
+ * server's registration task, so registration recovery can nudge that task
910
+ * after a reload. Not a secret. Never sent to the ledger. */
911
+ serverTaskOperationId?: string;
912
+ /** With `serverTask: "unknown"` on a Zyfai deposit leg: what the server
913
+ * answered to the registration handoff. "lost": no answer (the server may
914
+ * or may not have a task), so a later proof of no task lets the browser
915
+ * register it. "declined": the server declined it with a code that does not
916
+ * prove no task (e.g. ALREADY_REGISTERED), so the browser never registers
917
+ * it. Local only: never sent to the ledger. */
918
+ serverTaskCreate?: "declined" | "lost";
767
919
  /** Deposit execution was attempted, rather than only prepared. Not confirmation. */
768
920
  depositSubmission?: "started";
769
921
  depositAuthorization?: DepositAuthorizationReference;
922
+ /** The server accepted this sponsored deposit and sends it itself if the
923
+ * browser does not (true), or may have accepted it ("unknown": the prepare
924
+ * got no definitive answer, no hash is known yet). Either way it is never
925
+ * "not sent". Not confirmation. */
926
+ serverBroadcast?: true | "unknown";
927
+ /** With `serverBroadcast: "unknown"`: the deposit authorization's Permit2
928
+ * deadline (unix seconds). After it no deposit of that authorization can
929
+ * execute. */
930
+ authorizationDeadline?: number;
931
+ /** With `serverBroadcast`: the deposit authorization's Permit2 nonce
932
+ * (decimal); see `checkDepositAuthorization`. */
933
+ permit2Nonce?: string;
770
934
  blockNumber?: string;
771
935
  logIndexes?: number[];
772
936
  transferLogs?: {
@@ -777,13 +941,16 @@ interface FundingEvidence {
777
941
  withdrawalRequest?: {
778
942
  attempted: boolean;
779
943
  method?: "GET" | "POST";
780
- path?: "/users/withdraw" | "/users/partial-withdraw";
944
+ /** The route that answered. v1 paths appear only in evidence saved before @zyfai/sdk 0.10.0. */
945
+ path?: "/users/withdraw" | "/users/partial-withdraw" | "/users/withdraw/v2" | "/users/partial-withdraw/v2";
781
946
  elapsedMs?: number;
782
947
  /** Actual response status captured before the vendor replaces the HTTP error. */
783
948
  httpStatus?: number;
784
949
  failure?: "network" | "unauthorized" | "forbidden" | "rate-limited" | "insufficient-balance" | "session-key-missing" | "withdrawal-in-progress" | "other";
785
950
  /** When the provider accepted the request without a hash (ms since epoch). */
786
951
  acceptedAt?: number;
952
+ /** Zyfai's v2 withdrawal id, for the lifecycle lookup (1-128 chars). */
953
+ providerWithdrawalId?: string;
787
954
  };
788
955
  /** Where an on-chain payout search may start, for a hashless acceptance.
789
956
  * `fromBlock` is the chain head read just before the request (decimal string). */
@@ -795,6 +962,34 @@ interface FundingEvidence {
795
962
  delivery: FundingStage;
796
963
  }
797
964
  type FundingProgress = (evidence: FundingEvidence) => void;
965
+ /** The part of Zyfai's withdrawal lifecycle (`GET /users/withdrawals/{id}`) that Owney acts on. */
966
+ type ZyfaiWithdrawalLifecycle = {
967
+ status: string;
968
+ /** The synchronous payout leg has settled. */
969
+ syncSettled: boolean;
970
+ /** Hash of the synchronous payout transaction; present only when well formed. */
971
+ syncTxHash?: `0x${string}`;
972
+ /** Delayed (protocol-cooldown) redemption legs; empty when none or unreadable. */
973
+ asyncLegs: {
974
+ id: string;
975
+ status: string;
976
+ estimatedClaimAt?: string;
977
+ claimTxHash?: `0x${string}`;
978
+ }[];
979
+ /** Ids of delayed legs Zyfai reports as failed. */
980
+ failedAsyncIds: string[];
981
+ /** When the delayed part is expected to arrive; present only when a valid date. */
982
+ estimatedClaimAt?: string;
983
+ /** Zyfai recorded an error for this withdrawal. Its text is never carried. */
984
+ hasError: boolean;
985
+ };
986
+ /** The part of Zyfai's deposit status (`GET /users/deposits/{id}/v2`) that Owney acts on. */
987
+ type ZyfaiDepositPlacement = {
988
+ /** `handover_pending | credited | position_pending | positioned | recovered_to_eoa`. */
989
+ status: string;
990
+ /** `pending | positioned | skipped | failed`. */
991
+ positionOutcome?: string;
992
+ };
798
993
  interface AssetReadMetadata {
799
994
  chainId: number;
800
995
  asset: string;
@@ -906,6 +1101,19 @@ interface OwneyPendingAllocation {
906
1101
  /** ISO timestamp from Zyfai's `updatedAt`, when the payload carries one. */
907
1102
  since?: string;
908
1103
  }
1104
+ /**
1105
+ * A Zyfai delayed redemption in flight (`REQUESTED` or `CLAIMABLE`). Its funds
1106
+ * are in neither `positions` nor `tokens`; display-only, never added to a total.
1107
+ */
1108
+ interface OwneyPendingWithdrawal {
1109
+ id: string;
1110
+ status: string;
1111
+ chainId: number;
1112
+ /** Token symbol as Zyfai reports it. */
1113
+ asset: string;
1114
+ /** Redeemed amount in least units, as a decimal string. */
1115
+ amountRaw: string;
1116
+ }
909
1117
  interface AgentBalance {
910
1118
  readMetadata?: AssetReadMetadata[];
911
1119
  /** Authoritative native balances per asset/network, including idle and invested funds. */
@@ -929,7 +1137,23 @@ interface AgentBalance {
929
1137
  positions?: OwneyPosition[];
930
1138
  /** Funds received but not yet deployed. Omitted when nothing is pending. */
931
1139
  pendingAllocations?: OwneyPendingAllocation[];
1140
+ /** Zyfai only: delayed redemptions still in flight. Omitted when none. Never part of a total. */
1141
+ pendingWithdrawals?: OwneyPendingWithdrawal[];
1142
+ /**
1143
+ * Zyfai only: every delayed redemption Zyfai lists except FAILED, recently
1144
+ * CLAIMED ones included (Zyfai keeps them about a day). Present, possibly
1145
+ * empty, whenever Zyfai sent the list; absent when it did not. Empty means no
1146
+ * older delayed payout can be landing now. Never part of a total.
1147
+ */
1148
+ recentAsyncWithdrawals?: OwneyRecentAsyncWithdrawal[];
932
1149
  }
1150
+ /** A delayed Zyfai redemption by status, for telling a new payout from an older remainder. */
1151
+ type OwneyRecentAsyncWithdrawal = {
1152
+ id: string;
1153
+ status: string;
1154
+ chainId: number;
1155
+ asset: string;
1156
+ };
933
1157
  interface OwneyBalances {
934
1158
  totalBalance: string;
935
1159
  /** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
@@ -1039,7 +1263,14 @@ interface AgentHistoryPosition {
1039
1263
  protocol: string;
1040
1264
  pool?: string;
1041
1265
  tokenSymbol?: string;
1266
+ /** The position balance after the action (decimal string, token units). */
1042
1267
  amount?: string;
1268
+ /**
1269
+ * The amount the action actually moved (decimal string, token units), as
1270
+ * opposed to `amount`, the resulting position balance. Present only when the
1271
+ * provider reports it; withheld on withdrawals.
1272
+ */
1273
+ deltaAmount?: string;
1043
1274
  }
1044
1275
  interface AgentHistoryEntry {
1045
1276
  /** Stable provider/transfer identity, independent of row order. */
@@ -1168,6 +1399,9 @@ type WithdrawalPayoutScan = {
1168
1399
  candidates: WithdrawalPayoutCandidate[];
1169
1400
  /** Last block scanned (inclusive, decimal). Pass it back as the next `cursor`. */
1170
1401
  scannedTo: string;
1402
+ /** False when the call stopped at its request limit before the scan end (the
1403
+ * head minus the reorg margin), so more blocks are already waiting. */
1404
+ caughtUp: boolean;
1171
1405
  };
1172
1406
 
1173
1407
  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";
@@ -1345,12 +1579,20 @@ declare class OwneySDK {
1345
1579
  private readonly ledger;
1346
1580
  private readonly reservationMode;
1347
1581
  private readonly reservationTransport;
1582
+ /** The caller's Zyfai server tasks opt-in: `true`, a function read each
1583
+ * time a handoff would start (F-I2(iii)), or undefined (off). */
1584
+ private readonly zyfaiServerTasks;
1585
+ /** The caller opted in to the Fusion+ secret handoff (`fusionSecretHandoff: true`). */
1586
+ private readonly fusionSecretHandoff;
1348
1587
  private cachedSponsoredCallback;
1349
1588
  private cachedWethSponsoredCallback;
1350
1589
  private paymasterServiceUrl?;
1351
1590
  private cachedSponsoredCallsCallbacks;
1352
1591
  private readonly agentReads;
1353
1592
  private readonly depositFamilyReads;
1593
+ /** Movements (owner, chain, agent, token, tx hash) whose balance refresh this
1594
+ * session started: true when it armed the refresh, false when its deadline
1595
+ * had passed (it only dropped the cache and forced one snapshot read). */
1354
1596
  private readonly recoveredFundingReads;
1355
1597
  private fundingBalanceChecks;
1356
1598
  private readonly activationChecks;
@@ -1383,8 +1625,16 @@ declare class OwneySDK {
1383
1625
  /** Starts a swap's operation and opens it to the swap's inner deposit or
1384
1626
  * withdrawal. Never throws: reporting never blocks a swap. */
1385
1627
  private openSwapLedger;
1628
+ /**
1629
+ * Part 5: the swap's ledger identity, for the executor's Fusion+ secret
1630
+ * handoff. Only with the `fusionSecretHandoff` opt-in and an open operation;
1631
+ * otherwise undefined, and the executor sends nothing. Owner and token are
1632
+ * lowercased, as the ledger reports them.
1633
+ */
1634
+ private secretHandoffFor;
1386
1635
  private closeSwapLedger;
1387
- /** Reports one agent's withdrawal evidence as its leg. Never throws. */
1636
+ /** Reports one agent's withdrawal evidence as its leg (with `errorCode`, when
1637
+ * given). Never throws. */
1388
1638
  private ledgerWithdrawalLeg;
1389
1639
  /** Operation/leg/tx keys whose provider samples are already scheduled. */
1390
1640
  private readonly providerSampleKeys;
@@ -1584,6 +1834,24 @@ declare class OwneySDK {
1584
1834
  refreshBalance?: boolean;
1585
1835
  requireAmountMatch?: boolean;
1586
1836
  }): Promise<FundingEvidence>;
1837
+ private noteFundingRefresh;
1838
+ /**
1839
+ * Re-arms an agent's balance refresh after a confirmed deposit or withdrawal
1840
+ * the caller already verified (e.g. after a page reload, which loses the
1841
+ * refresh the SDK started in memory). Same refresh as receipt recovery
1842
+ * (`inspectFunding`), without a receipt read, and shared with it: once per
1843
+ * movement (`txHash`) in this SDK session, unless that recovery came after
1844
+ * its own deadline and so armed nothing. `until` bounds it (the agent caps
1845
+ * it further). Returns false when the agent has no such refresh or `until`
1846
+ * has passed; throws when not connected or on another chain. Never prompts.
1847
+ */
1848
+ refreshAgentBalanceAfterMovement(input: {
1849
+ agentId: AgentId;
1850
+ chainId: number;
1851
+ token: OwneySupportedTokens;
1852
+ txHash?: string;
1853
+ until: number;
1854
+ }): boolean;
1587
1855
  /**
1588
1856
  * Lists on-chain payout candidates for a withdrawal the provider accepted
1589
1857
  * without a hash: ERC-20 `Transfer` logs on the evidence's token that reach
@@ -1611,6 +1879,26 @@ declare class OwneySDK {
1611
1879
  /** Whether a foreground deposit can resume the same signed batch, never a
1612
1880
  * fresh authorization. The batch rail independently rechecks the exact plan. */
1613
1881
  canResumePendingDeposit(evidences: FundingEvidence[], amount: string): Promise<boolean>;
1882
+ /** Whether a Permit2 deposit authorization can still execute and whether it
1883
+ * did: `expired` when the finalized block is more than 300 s past
1884
+ * `deadline` (chain time), `used` when the owner's Permit2 nonce bit is set
1885
+ * at that block. Null when anything cannot be read. Never throws. */
1886
+ checkDepositAuthorization(input: {
1887
+ chainId: number;
1888
+ owner: string;
1889
+ token?: string;
1890
+ permit2Nonce: string;
1891
+ deadline: number;
1892
+ }): Promise<{
1893
+ expired: boolean;
1894
+ used: boolean;
1895
+ } | null>;
1896
+ /** Drops the saved signed body of a hashless deposit the server may have
1897
+ * been sending (`serverBroadcast` 'unknown'/true, no hash) once the app has
1898
+ * settled it another way: by the ledger's hash or its expired deadline.
1899
+ * Only the body with this Permit2 deadline and these exact shares is
1900
+ * dropped, so it never resumes or blocks a different deposit. Never throws. */
1901
+ discardSavedDepositBatch(evidences: FundingEvidence[]): Promise<boolean>;
1614
1902
  /** Validate signed journal membership, never just a caller-supplied family ID. */
1615
1903
  validateDepositReplacement(previous: FundingEvidence[], next: FundingEvidence[]): Promise<DepositReplacementValidation | undefined>;
1616
1904
  /** Optional post-payout display proof; receipt verification and the provider
@@ -1621,6 +1909,12 @@ declare class OwneySDK {
1621
1909
  /** History lookup for receipt recovery; adapters may not authenticate or sign here. */
1622
1910
  getFundingHistory(evidence: FundingEvidence, fromDate: string, options?: Pick<HistoryFilters, "cursor" | "toDate">): Promise<OwneyAgentHistory>;
1623
1911
  recoverDepositRegistration(evidence: FundingEvidence): Promise<FundingEvidence>;
1912
+ /** A Zyfai withdrawal's lifecycle by the id recorded on its evidence. Never signs,
1913
+ * prompts or authenticates; `null` when unavailable or not this wallet's Zyfai withdrawal. */
1914
+ getZyfaiWithdrawal(evidence: FundingEvidence): Promise<ZyfaiWithdrawalLifecycle | null>;
1915
+ /** A Zyfai deposit's placement status by the id recorded on its evidence. Never signs,
1916
+ * prompts or authenticates; `null` when unavailable or not this wallet's Zyfai deposit. */
1917
+ getZyfaiDeposit(evidence: FundingEvidence): Promise<ZyfaiDepositPlacement | null>;
1624
1918
  /** On-chain version and ownership status for this owner's Yieldseeker agent. */
1625
1919
  getYieldseekerWalletStatus(asset: OwneySupportedTokens): Promise<YieldseekerWalletStatus | null>;
1626
1920
  /** Deployment gate; an unavailable response keeps the current paid path. */
@@ -2057,6 +2351,13 @@ declare class OwneySDK {
2057
2351
  * hold this SDK does not know about is left to the server's expiry.
2058
2352
  */
2059
2353
  releaseWithdrawalReservation(operationId: string, reason: ReservationReleaseReason, agents?: ReservationAgent[]): Promise<void>;
2354
+ /**
2355
+ * Reports a withdrawal step the app closed as never sent (a reload before its
2356
+ * request was saved) as a failed ledger leg with `NOT_SUBMITTED`, so other
2357
+ * devices and later recovery stop treating it as in flight. Refuses any step
2358
+ * with a hash or a saved request. Never touches the hold; never throws.
2359
+ */
2360
+ reportWithdrawalNotSubmitted(operationId: string, evidence: FundingEvidence): Promise<void>;
2060
2361
  /**
2061
2362
  * Reports a withdrawal leg that was proven after its call ended (a hashless
2062
2363
  * Zyfai payout found on chain or in history) to the funding ledger, then
@@ -2067,6 +2368,15 @@ declare class OwneySDK {
2067
2368
  * the server re-verifies the hash. Never throws.
2068
2369
  */
2069
2370
  reportWithdrawalRecovery(operationId: string, evidence: FundingEvidence): Promise<void>;
2371
+ /**
2372
+ * Reports a deposit leg that the app's recovery verified on chain after its
2373
+ * call ended to the funding ledger. Only evidence whose transfer is confirmed
2374
+ * with a transaction hash is reported; anything else is ignored. The ledger
2375
+ * PATCHes the existing operation (creating it only on a 404) and the server
2376
+ * re-verifies the hash. Deposits hold no reservation, so nothing is released.
2377
+ * Never throws.
2378
+ */
2379
+ reportDepositRecovery(operationId: string, evidence: FundingEvidence): Promise<void>;
2070
2380
  private withdrawFromAgents;
2071
2381
  /** Read-only invalidation after new pool-deposit activity. Does not restart
2072
2382
  * funding reconciliation, bypass cooldowns, or authorize a transaction. */
@@ -2276,6 +2586,9 @@ declare class YieldseekerAgent implements IAgent {
2276
2586
  private readonly endpointReadFailures;
2277
2587
  private readonly reconcileUntil;
2278
2588
  private readonly allocationRefresh;
2589
+ /** Contexts whose next permitted snapshot read is forced once: a funding
2590
+ * invalidation with a tx hash (receipt recovery, a re-armed refresh). */
2591
+ private readonly forceNextSnapshot;
2279
2592
  private readonly activityRefreshUntil;
2280
2593
  private readonly snapshotMovements;
2281
2594
  private readonly movementEpochs;
@@ -2327,7 +2640,9 @@ declare class YieldseekerAgent implements IAgent {
2327
2640
  disconnect(): Promise<void>;
2328
2641
  activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
2329
2642
  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>;
2643
+ withdraw(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, amount?: string, onProgress?: FundingProgress, gasMode?: "auto" | "sponsored" | "paid", onBeforeSubmission?: FundingProgress, assertOperation?: () => void, submission?: {
2644
+ operationId?: string;
2645
+ }): Promise<AgentWithdrawResult>;
2331
2646
  private withdrawInternal;
2332
2647
  /** Fresh position amounts for withdrawal planning, net of reserved fees. */
2333
2648
  getWithdrawableBalance(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, minimumAmount?: bigint): Promise<bigint>;
@@ -2464,6 +2779,10 @@ declare class YieldseekerAgent implements IAgent {
2464
2779
  private snapshotMovement;
2465
2780
  private advancePortfolioVersion;
2466
2781
  private requestPortfolioSnapshot;
2782
+ private snapshotPath;
2783
+ /** True while `walletRequest` would refuse a read of `path`: this user's
2784
+ * rate-limit cooldown or that endpoint's outage cooldown. */
2785
+ private readCoolingDown;
2467
2786
  private portfolioSnapshot;
2468
2787
  private loadPortfolioContext;
2469
2788
  private loadActivityContext;
@@ -2610,6 +2929,24 @@ type StoredOrder = {
2610
2929
  amount: string;
2611
2930
  /** Epoch ms, for ordering recovery records. */
2612
2931
  createdAt: number;
2932
+ /**
2933
+ * A swap-deposit's deposit half, so a resume that finishes the swap can
2934
+ * record it (ROUT-625). `received` is the quote's guaranteed minimum. Absent
2935
+ * on plain swaps and on records written by an older SDK.
2936
+ */
2937
+ pendingDeposit?: {
2938
+ received: string;
2939
+ symbol: string;
2940
+ chainId: number;
2941
+ agentId?: string;
2942
+ operationId?: string;
2943
+ };
2944
+ /**
2945
+ * Our routing API accepted these secrets (part 5's opt-in handoff) and
2946
+ * publishes them itself once 1inch is ready. Informational: this browser
2947
+ * still publishes and resumes as before. Absent when no handoff was accepted.
2948
+ */
2949
+ serverSecrets?: true;
2613
2950
  };
2614
2951
  /**
2615
2952
  * Every unresolved stored order, newest first.
@@ -2617,6 +2954,13 @@ type StoredOrder = {
2617
2954
  */
2618
2955
  declare function listOrders(_now?: number): StoredOrder[];
2619
2956
 
2957
+ /**
2958
+ * Capability flag (part 5): this SDK can hand a signed Fusion+ order's secrets
2959
+ * to the routing API (`handoffSecrets`), which then publishes each one when
2960
+ * 1inch is ready, even if this tab is gone. Older builds do not export this.
2961
+ */
2962
+ declare const FUSION_SECRET_SERVER_PUBLISH: 1;
2963
+
2620
2964
  /**
2621
2965
  * Non-blocking funding ledger reporter.
2622
2966
  *
@@ -2642,6 +2986,8 @@ type LedgerLegReport = {
2642
2986
  userOpHash?: string;
2643
2987
  callsId?: string;
2644
2988
  orderHash?: string;
2989
+ /** The provider's own id for this leg's request (Zyfai's v2 withdrawal id). */
2990
+ providerRef?: string;
2645
2991
  confirmedAmountRaw?: string;
2646
2992
  blockNumber?: string;
2647
2993
  errorCode?: string;
@@ -2660,4 +3006,26 @@ type LedgerLegReport = {
2660
3006
  };
2661
3007
  };
2662
3008
 
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 };
3009
+ /** This SDK hands every Zyfai withdrawal request to the caller's
3010
+ * `onBeforeSubmission` before sending it, and a failed checkpoint stops it.
3011
+ * A caller that persisted nothing for a dead run can therefore conclude the
3012
+ * request was never sent. Older builds do not export this. */
3013
+ declare const ZYFAI_WITHDRAW_DISPATCH_CHECKPOINT: 1;
3014
+
3015
+ /** Capability flag: this SDK opts in to the server sending an accepted
3016
+ * sponsored deposit itself (prepare `serverBroadcast: true`) and reports such a
3017
+ * deposit as pending, never "not sent". Older builds do not export this. */
3018
+ declare const SPONSORED_DEPOSIT_SERVER_BROADCAST: 1;
3019
+
3020
+ /** Capability flag: this SDK opts in to the server sending its signed sponsored
3021
+ * Yieldseeker withdrawal userOp itself (`serverSubmit=1` on its own
3022
+ * `eth_sendUserOperation`) and reports such a leg as pending, never "not sent".
3023
+ * Older builds do not export this. */
3024
+ declare const YIELDSEEKER_WITHDRAW_SERVER_SUBMIT: 1;
3025
+
3026
+ /** Capability flag: this SDK has `reportDepositRecovery`, which reports a
3027
+ * deposit leg the app's recovery verified on chain to the funding ledger.
3028
+ * Older builds do not export this. */
3029
+ declare const FUNDING_DEPOSIT_RECOVERY_REPORT: 1;
3030
+
3031
+ 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, 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 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, SPONSORED_DEPOSIT_SERVER_BROADCAST, 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, YIELDSEEKER_WITHDRAW_SERVER_SUBMIT, YieldseekerAgent, type YieldseekerWalletStatus, ZYFAI_REGISTRATION_NOT_SENT_CODES, ZYFAI_SERVER_TASKS, ZYFAI_WITHDRAWAL_NOT_SENT_CODES, ZYFAI_WITHDRAW_DISPATCH_CHECKPOINT, type ZyfaiDepositPlacement, type ZyfaiRpcUrlsConfig, type ZyfaiWithdrawalLifecycle, clearWithdrawSwap, createOwneySIWX, listPendingDeposits, listOrders as listPendingSwaps, listWithdrawSwaps, saveWithdrawSwap, setOwneyDebug, subscribeWithdrawSwaps, updateWithdrawSwap };