@owney/sdk 0.7.27-beta.1 → 0.7.28-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,5 +1,3 @@
1
- import * as viem from 'viem';
2
- import { Address, Hex } from 'viem';
3
1
  import { SIWXConfig } from '@reown/appkit-controllers';
4
2
 
5
3
  /**
@@ -222,9 +220,7 @@ type SwapOrderStatus = "pending" | "executed" | "expired" | "cancelled" | "refun
222
220
  * of the flow and the one place a user would otherwise think nothing is
223
221
  * happening.
224
222
  */
225
- type SwapStage = "withdrawing" | "withdrawn"
226
- /** Withdrawal incomplete or unconfirmed; no swap was submitted. */
227
- | "withdrawal-incomplete" | "quoting" | "wrapping" | "wrapped" | "approving" | "building" | "signing" | "swapping" | "swapped" | "depositing" | "refunding" | "refunded";
223
+ type SwapStage = "withdrawing" | "withdrawn" | "quoting" | "wrapping" | "wrapped" | "approving" | "signing" | "swapping" | "swapped" | "depositing" | "refunding" | "refunded";
228
224
  /**
229
225
  * Which way the funds travel, which decides what each side may be.
230
226
  *
@@ -250,34 +246,19 @@ type SwapQuoteParams = {
250
246
  direction?: SwapDirection;
251
247
  };
252
248
 
253
- type RpcUrlsConfig = Partial<Record<(typeof SUPPORTED_CHAIN_IDS)[number], string>>;
254
- /** @deprecated Use RpcUrlsConfig. */
255
- type ZyfaiRpcUrlsConfig = RpcUrlsConfig;
249
+ type ZyfaiRpcUrlsConfig = Partial<Record<(typeof SUPPORTED_CHAIN_IDS)[number], string>>;
256
250
  interface OwneySDKConfig {
257
251
  apiKey: string;
258
- /**
259
- * Optional per-chain RPC overrides used for application-owned reads and
260
- * transaction receipt polling. Missing chains use the Owney routing API's
261
- * read-only RPC proxy. No upstream RPC credentials are included in the SDK.
262
- * Wallet providers remain responsible for account access, chain switching,
263
- * signatures, and transaction submission.
264
- */
265
- rpcUrls?: RpcUrlsConfig;
266
252
  /**
267
253
  * Optional per-chain RPC overrides for Zyfai SDK network calls.
268
254
  * Example: { 8453: "https://...", 42161: "https://..." }
269
- * @deprecated Use rpcUrls so every agent shares the same read transport.
270
255
  */
271
256
  zyfaiRpcUrls?: ZyfaiRpcUrlsConfig;
272
- /** Optional Owney Yieldseeker proxy base URL override for integration tests. */
273
- yieldseekerApiBaseUrl?: string;
274
- /** Optional SIWE origin override. Defaults to the requesting browser origin. */
275
- yieldseekerSiweOrigin?: string;
276
257
  /**
277
258
  * Optional override for the Owney routing API base URL used by all routing
278
- * calls. RPC proxy requests use OWNEY_ROUTING_API_BASE_URL when this is
279
- * omitted; without either value, all rpcUrls must be configured.
280
- * Set this to a local/staging routing API when testing sponsor changes.
259
+ * calls (defaults to the OWNEY_ROUTING_API_BASE_URL env var, then the
260
+ * production URL). Set this to point at a local/staging routing API,
261
+ * e.g. "http://localhost:3000", when testing sponsor changes.
281
262
  */
282
263
  routingApiBaseUrl?: string;
283
264
  /**
@@ -319,134 +300,7 @@ type OwneySupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
319
300
  type OwneySupportedChains = (typeof SUPPORTED_CHAINS)[number];
320
301
  type OwneySupportedTokens = (typeof SUPPORTED_TOKENS)[number];
321
302
 
322
- /**
323
- * One protocol's pool selection on one chain. `pools` holds Zyfai pool NAMES
324
- * verbatim — matched case-sensitively by customizeBatch, and an unrecognised
325
- * name makes Zyfai's rebalance engine skip the whole protocol, so these strings
326
- * must not be normalised anywhere.
327
- *
328
- * An empty array means "no usable pools on this chain".
329
- */
330
- type OrgPoolSelection = {
331
- protocolId: string;
332
- chainId: number;
333
- pools: string[];
334
- };
335
- /**
336
- * The partner's protocol/pool policy (ROUT-224). Sparse — only protocols they
337
- * narrowed appear. Optional so an older routing API, which does not return the
338
- * field, still parses; undefined and null both mean "change nothing".
339
- */
340
- type OrgPoolPolicy = {
341
- autoApproveProtocols: boolean;
342
- autoApprovePools: boolean;
343
- selections: OrgPoolSelection[];
344
- };
345
- /**
346
- * The organization's agent execution policy, or null when the partner has never
347
- * configured one — in which case the agents leave the user's profile alone.
348
- */
349
- type OrgAgentConfig = {
350
- splittingMode: "none" | "automatic" | "force";
351
- minSplits: number | null;
352
- poolPolicy?: OrgPoolPolicy | null;
353
- };
354
-
355
- type DepositCallback = (smartWalletAddress: string, chainId: number, amount: string) => Promise<`0x${string}`> | `0x${string}`;
356
- interface IAgent {
357
- readonly id: string;
358
- readonly supportedChainIds: readonly OwneySupportedChainId[];
359
- readonly supportedAssets: readonly AgentSupportedAssets[];
360
- /**
361
- * Describes how `AgentBalance.tokens` relates to `positions`.
362
- * Most adapters expose token totals that already include deployed positions.
363
- * Providers such as Yieldseeker expose idle wallet tokens separately, so
364
- * withdrawal planning must add matching position amounts.
365
- */
366
- readonly balanceComposition?: "tokens-include-positions" | "tokens-plus-positions";
367
- /**
368
- * Whether a withdrawal requires an owner-approved wallet transaction.
369
- * Aggregate withdrawals run these agents before relayer-only agents so a
370
- * rejected wallet request cannot happen after another leg has committed.
371
- */
372
- readonly withdrawalRequiresWalletApproval?: boolean;
373
- disconnect(): Promise<void>;
374
- activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
375
- /**
376
- * Apply the organization's agent policy to this user's account.
377
- *
378
- * Optional: an agent that has no equivalent knob simply omits it, which is why
379
- * this is not part of `activateAgent`'s signature. Declared on the interface
380
- * rather than only on ZyfaiAgent so the contract stays agent-neutral — the
381
- * ticket asks for a design that can also cover Surf, which has no adapter yet.
382
- *
383
- * Implementations must be **non-fatal**: this runs during activation as a side
384
- * effect, so a failure has to leave the user connected and their profile
385
- * unchanged rather than break the connect.
386
- */
387
- applyOrgPolicy?(state: ConnectionState, chainId: number, policy: OrgAgentConfig): Promise<void>;
388
- deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback, onProgress?: FundingProgress, onBeforeSubmission?: (evidence: FundingEvidence) => void | Promise<void>): Promise<OwneyDepositResult>;
389
- withdraw(state: ConnectionState, chainId: number, token: OwneySupportedTokens, amount?: string, onProgress?: FundingProgress, gasMode?: "auto" | "sponsored" | "paid", onBeforeSubmission?: FundingProgress): Promise<AgentWithdrawResult>;
390
- /** A newly observed pool allocation invalidates this asset's portfolio cache only. */
391
- invalidateAllocationRead?(state: ConnectionState, chainId: number, asset: OwneySupportedTokens): void;
392
- /** Invalidate only the confirmed asset. This hook must not sign or submit transactions. */
393
- invalidateFundingRead?(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, refreshUntil?: number): void;
394
- /** End accelerated balance reads only for the exact snapshot the caller displayed. */
395
- endFundingBalanceRefresh?(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, read: AssetReadMetadata): boolean;
396
- getFundingHistory?(state: ConnectionState, chainId: number, options?: HistoryFilters): Promise<OwneyAgentHistory>;
397
- getFundingWallet?(state: ConnectionState, chainId: number, asset: OwneySupportedTokens): Promise<string>;
398
- /** Verify the displayed remaining balance after a receipt-confirmed payout.
399
- * Undefined means unknown; never substitute a failed read with zero. */
400
- verifyWithdrawalBalance?(state: ConnectionState, evidence: FundingEvidence, balance: AgentBalance): Promise<AssetReadMetadata | undefined>;
401
- /** Read-only chain proof when indexed withdrawal components are incomplete.
402
- * Returns raw owner-withdrawable units; unavailable proof must throw.
403
- * minimumAmount is the raw liquidity required from this agent for a typed
404
- * plan, so adapters can expand discovery when known positions fall short. */
405
- getWithdrawableBalance?(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, minimumAmount?: bigint): Promise<bigint>;
406
- /** Optional positive proof for a repeat deposit; unknown must fall back to portfolio validation. */
407
- hasExistingDepositFunds?(state: ConnectionState, chainId: number, asset: OwneySupportedTokens): Promise<true | undefined>;
408
- getBalances(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<AgentBalance>;
409
- getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
410
- /**
411
- * Refresh the agent's earnings snapshot when its backend supports doing so.
412
- * Implementations own freshness and request-deduplication policy.
413
- */
414
- refreshEarnings?(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
415
- getAccountApy(state: ConnectionState, chainId: number, days: DailyApyDays,
416
- /**
417
- * Optional asset symbol ("USDC" / "WETH") scoping the daily series to a
418
- * single asset on the chain. Agents without per-asset positions ignore it.
419
- */
420
- tokenSymbol?: string): Promise<AccountAgentApy>;
421
- /**
422
- * Daily cumulative earnings in token units, scoped to a chain/asset, using
423
- * the provider's earnings basis. Include an opening snapshot when available
424
- * so the "recent earnings" subline can difference the endpoints. (ROUT-452)
425
- */
426
- getDailyEarnings?(state: ConnectionState, chainId: number, days: LookbackDays, tokenSymbol?: string): Promise<AccountDailyEarnings>;
427
- getHistory(state: ConnectionState, chainId: number, options?: HistoryFilters): Promise<OwneyAgentHistory>;
428
- getUserProfile(state: ConnectionState, chainId: number): Promise<AgentUserProfile>;
429
- /**
430
- * Ensure the given asset uses backend protocol auto-selection
431
- * (`autoSelectProtocols: true`). Optional capability — only agents whose
432
- * backend models per-asset protocol selection implement it. Returns whether
433
- * a write occurred (`false` = already enabled / not supported).
434
- */
435
- ensureAutoSelectProtocols?(state: ConnectionState, chainId: number, asset: "USDC" | "WETH"): Promise<boolean>;
436
- getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
437
- }
438
- /**
439
- * Optional filters for per-agent APY lookups.
440
- * - `tokenSymbol` / `chainId` scope the APY to a specific asset+chain when
441
- * the underlying provider supports it (Zyfai). Agents whose backends do
442
- * not yet support per-asset APY will ignore these options.
443
- */
444
- type AgentApyOptions = {
445
- tokenSymbol?: string;
446
- chainId?: number;
447
- };
448
-
449
- type AgentId = "zyfai" | "yieldseeker";
303
+ type AgentId = "zyfai";
450
304
  type Asset = string;
451
305
  type AgentSupportedAsset = {
452
306
  readonly symbol: string;
@@ -495,26 +349,27 @@ type HistoryFilters = {
495
349
  tokenSymbol?: string;
496
350
  };
497
351
  type HistoryOptions = {
498
- chainId?: number;
499
352
  agentId?: AgentId;
500
353
  filters?: HistoryFilters;
501
- };
502
- type WithdrawOptions = {
503
- /** Yieldseeker V2 only. "auto" requests sponsorship for a verified V2 wallet. */
504
- gasMode?: "auto" | "sponsored" | "paid";
505
- /** Exclude unresolved providers from aggregate withdrawals; direct agent requests are unchanged. */
506
- excludeAgentIds?: AgentId[];
507
- onProgress?: FundingProgress;
508
354
  /**
509
- * Durable pre-dispatch checkpoint for adapters with a recoverable operation ID.
510
- * Rejection prevents submission; progress observers remain non-fatal.
355
+ * Chains to read, instead of the one `activateAgent` last set (ROUT-479).
356
+ *
357
+ * Each chain pages independently and the results merge into one
358
+ * chronological list, with every entry stamped with the chain it came from.
359
+ * Omit for the single-chain behaviour, which stays the default: fanning out
360
+ * by default would multiply every existing caller's request count.
511
361
  */
512
- onBeforeSubmission?: FundingProgress;
362
+ chainIds?: OwneySupportedChainId[];
363
+ };
364
+ type WithdrawOptions = {
513
365
  asset: Asset;
514
366
  amount?: string;
515
367
  agentId?: AgentId;
516
- /** Called after each agent returns; callback failures never change a financial result. */
517
- onAgentResult?: (agentId: AgentId, result: AgentWithdrawResult) => void;
368
+ /**
369
+ * Chain to withdraw from. Defaults to the chain `activateAgent` last set.
370
+ * See `DepositOptions.chainId` — the same rules apply.
371
+ */
372
+ chainId?: number;
518
373
  };
519
374
  type AccountApyOptions = {
520
375
  agentId?: AgentId;
@@ -536,6 +391,14 @@ type AccountApyOptions = {
536
391
  type DailyEarningsOptions = {
537
392
  agentId?: AgentId;
538
393
  days: LookbackDays;
394
+ /**
395
+ * Chains to read, instead of the one `activateAgent` last set (ROUT-479).
396
+ *
397
+ * The same asset is summed across them — USDC on Base and USDC on Arbitrum
398
+ * are the same unit. Different assets stay apart, as they already do within
399
+ * one chain. Omit for the single-chain behaviour, which stays the default.
400
+ */
401
+ chainIds?: OwneySupportedChainId[];
539
402
  /**
540
403
  * Optional asset symbol (e.g. "USDC", "WETH") scoping the series to one
541
404
  * asset on the active chain.
@@ -561,98 +424,59 @@ type AgentsApyOptions = {
561
424
  chainId?: number;
562
425
  };
563
426
  type DepositOptions = {
564
- /** Resume only these already signed relayer bytes; never create a new authorization. */
565
- resumeTxHash?: `0x${string}`;
566
- onProgress?: FundingProgress;
567
- /** Awaited immediately before dispatch. Throwing prevents submission.
568
- * All legs of an atomic batch are checkpointed together. */
569
- onBeforeSubmission?: (evidence: FundingEvidence[]) => void | Promise<void>;
570
427
  amount: string;
571
428
  asset: Asset;
572
429
  depositCallback?: DepositCallback;
573
430
  agentId?: AgentId;
574
431
  onApproved?: () => void;
432
+ /**
433
+ * Chain to deposit on. Defaults to the chain `activateAgent` last set, so
434
+ * omitting it behaves exactly as before.
435
+ *
436
+ * Pass it to fund several chains in a row without re-activating between
437
+ * them (ROUT-245's spread strategies). It selects the target; it does not
438
+ * replace activation, which is what populates `activeAgents`, and it does
439
+ * not remove the wallet's network switch — the default deposit callbacks
440
+ * still put the wallet on this chain before signing, since a deposit
441
+ * signature is EIP-712 with the chain in its domain.
442
+ */
443
+ chainId?: number;
575
444
  };
576
445
 
577
- type FundingStage = "pending" | "confirmed" | "unknown" | "failed" | "not-applicable";
578
- /** Hash-bound v0.6 recovery metadata. Deliberately excludes the owner signature. */
579
- type UnsignedUserOperationEvidence = {
580
- sender: string;
581
- nonce: string;
582
- initCode: string;
583
- callData: string;
584
- callGasLimit: string;
585
- verificationGasLimit: string;
586
- preVerificationGas: string;
587
- maxFeePerGas: string;
588
- maxPriorityFeePerGas: string;
589
- paymasterAndData: string;
590
- };
591
- /** Evidence about one provider leg. Amounts are token base units, never USD. */
592
- interface FundingEvidence {
593
- agentId: AgentId;
594
- chainId: number;
595
- token: OwneySupportedTokens;
596
- walletAddress: string;
597
- agentWallet?: string;
598
- intendedAmount: string;
599
- confirmedAmount?: string;
600
- /** Receipt delivery and fulfillment of a typed requested amount are separate facts. */
601
- amountCompletion?: "complete" | "shortfall";
602
- /** Verified difference between the typed request and the actual owner payout. */
603
- shortfallAmount?: string;
604
- txHash?: string;
605
- /** Persisted before a sponsored EOA operation is sent. */
606
- userOpHash?: string;
607
- /** Lets recovery verify a consumed nonce even if a bundler forgets the operation. */
608
- userOperation?: UnsignedUserOperationEvidence;
609
- /** Base Account calls ID used to recover an uncertain wallet submission. */
610
- callsId?: string;
611
- /** Deposit execution was attempted, rather than only prepared. Not confirmation. */
612
- depositSubmission?: "started";
613
- blockNumber?: string;
614
- logIndexes?: number[];
615
- transferLogs?: {
616
- logIndex: number;
617
- amountRaw: string;
618
- }[];
619
- /** Sanitized execution-request evidence. Attempted does not prove server acceptance. */
620
- withdrawalRequest?: {
621
- attempted: boolean;
622
- method?: "GET" | "POST";
623
- path?: "/users/withdraw" | "/users/partial-withdraw";
624
- elapsedMs?: number;
625
- /** Actual response status captured before the vendor replaces the HTTP error. */
626
- httpStatus?: number;
627
- failure?: "network" | "unauthorized" | "forbidden" | "rate-limited" | "insufficient-balance" | "session-key-missing" | "withdrawal-in-progress" | "other";
628
- };
629
- transfer: FundingStage;
630
- registration: FundingStage;
631
- delivery: FundingStage;
632
- }
633
- type FundingProgress = (evidence: FundingEvidence) => void;
634
- interface AssetReadMetadata {
446
+ /**
447
+ * One protocol's pool selection on one chain. `pools` holds Zyfai pool NAMES
448
+ * verbatim — matched case-sensitively by customizeBatch, and an unrecognised
449
+ * name makes Zyfai's rebalance engine skip the whole protocol, so these strings
450
+ * must not be normalised anywhere.
451
+ *
452
+ * An empty array means "no usable pools on this chain".
453
+ */
454
+ type OrgPoolSelection = {
455
+ protocolId: string;
635
456
  chainId: number;
636
- asset: string;
637
- fetchedAt?: number;
638
- /** When the underlying provider request started; preserved on cached reads. */
639
- requestedAt?: number;
640
- /** SDK cache generation, not an onchain block or provider timestamp. */
641
- readVersion?: number;
642
- providerUpdatedAt?: string;
643
- snapshotId?: string;
644
- blockNumber?: string;
645
- netDepositsRaw?: string;
646
- /** Display-only agreement with a post-payout read. Does not prove that
647
- * provider accounting, history or allocations include the transaction. */
648
- withdrawalCheck?: {
649
- txHash: string;
650
- blockNumber: string;
651
- };
652
- positionsStatus: "available" | "unavailable";
653
- }
457
+ pools: string[];
458
+ };
459
+ /**
460
+ * The partner's protocol/pool policy (ROUT-224). Sparse — only protocols they
461
+ * narrowed appear. Optional so an older routing API, which does not return the
462
+ * field, still parses; undefined and null both mean "change nothing".
463
+ */
464
+ type OrgPoolPolicy = {
465
+ autoApproveProtocols: boolean;
466
+ autoApprovePools: boolean;
467
+ selections: OrgPoolSelection[];
468
+ };
469
+ /**
470
+ * The organization's agent execution policy, or null when the partner has never
471
+ * configured one — in which case the agents leave the user's profile alone.
472
+ */
473
+ type OrgAgentConfig = {
474
+ splittingMode: "none" | "automatic" | "force";
475
+ minSplits: number | null;
476
+ poolPolicy?: OrgPoolPolicy | null;
477
+ };
478
+
654
479
  interface OwneyDepositResult {
655
- evidence?: FundingEvidence;
656
480
  txHash: string;
657
481
  smartWallet: string;
658
482
  amount: string;
@@ -661,28 +485,16 @@ interface OwneyMultiDepositResult {
661
485
  agentResults: Record<string, OwneyDepositResult>;
662
486
  }
663
487
  interface AgentWithdrawResult {
664
- evidence?: FundingEvidence;
665
488
  txHash?: string;
666
489
  type: "full" | "partial";
667
- /** Owner payout or clearing all MAX positions still needs verification. */
668
- completion?: "unverified";
669
- /** Confirmed smallest-unit amount; "0" when no owner payout is verified.
670
- * Legacy providers may return a sentinel such as "all" for a full request. */
490
+ /** Smallest-unit amount, or a provider sentinel such as "all" for a full request. */
671
491
  amount: string;
672
- /** Yieldseeker typed withdrawal fulfilled after an exactly verified fee
673
- * deduction. Amount remains the confirmed net owner payout, and the gross
674
- * amount must equal that payout plus the fee, all in token base units. */
675
- feeAdjustment?: {
676
- grossAmount: string;
677
- feeAmount: string;
678
- };
679
492
  }
680
493
  interface OwneyWithdrawResult {
681
494
  agentResult: Record<AgentId, AgentWithdrawResult>;
682
495
  /**
683
- * Sum of confirmed smallest-unit amounts; null while any returned leg's
684
- * payout is not yet known, including typed requests accepted asynchronously.
685
- * Evidence-less custom adapters retain their confirmed-amount contract.
496
+ * Sum of reported smallest-unit amounts; null when a full withdrawal's
497
+ * amount is not yet known. An accepted request is not proof of settlement.
686
498
  */
687
499
  totalWithdrawn: string | null;
688
500
  }
@@ -700,10 +512,6 @@ interface OwneyPosition {
700
512
  pool?: string;
701
513
  asset: string;
702
514
  amount: string;
703
- /** Provider-native raw quantity; may represent vault shares, not the underlying asset. */
704
- amountRaw?: string;
705
- /** Withdrawable underlying asset amount in that asset's smallest units. */
706
- withdrawableAmountRaw?: string;
707
515
  apy?: number;
708
516
  tvl?: number;
709
517
  /** Pool liquidity. Prepared slot — Zyfai will add this to its portfolio
@@ -734,20 +542,10 @@ interface OwneyPendingAllocation {
734
542
  since?: string;
735
543
  }
736
544
  interface AgentBalance {
737
- readMetadata?: AssetReadMetadata[];
738
- /** Authoritative native balances per asset/network, including idle and invested funds. */
739
- assetBalances?: OwneyToken[];
740
545
  smartWallet?: `0x${string}`;
741
546
  totalBalance: string;
742
547
  /** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
743
548
  totalBalanceAsset: string;
744
- /**
745
- * Describes whether `tokens` already includes deployed `positions`.
746
- * Consumers must add matching positions only for `tokens-plus-positions`;
747
- * doing so for Zyfai would double-count, while omitting it for Yieldseeker
748
- * makes its balance disappear as soon as idle funds enter a vault.
749
- */
750
- balanceComposition?: "tokens-include-positions" | "tokens-plus-positions";
751
549
  tokens: OwneyToken[];
752
550
  /**
753
551
  * Per-protocol/pool positions when the agent's portfolio payload includes
@@ -757,19 +555,34 @@ interface AgentBalance {
757
555
  /** Funds received but not yet deployed. Omitted when nothing is pending. */
758
556
  pendingAllocations?: OwneyPendingAllocation[];
759
557
  }
558
+ /**
559
+ * One position drained by `withdrawAll()` — a chain and asset pair.
560
+ *
561
+ * Carries either a result or an error, never both: a leg that failed while
562
+ * others succeeded is the normal case, not an exception, and the caller needs
563
+ * to name the ones that did not arrive.
564
+ */
565
+ interface OwneyWithdrawAllLeg {
566
+ chainId: OwneySupportedChainId;
567
+ asset: OwneySupportedTokens;
568
+ /** What the position held when the sweep started. */
569
+ amount: string;
570
+ result?: OwneyWithdrawResult | AgentWithdrawResult;
571
+ error?: string;
572
+ }
573
+ interface OwneyWithdrawAllResult {
574
+ /** Every position attempted, in the order it was attempted. */
575
+ legs: OwneyWithdrawAllLeg[];
576
+ }
760
577
  interface OwneyBalances {
761
578
  totalBalance: string;
762
579
  /** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
763
580
  totalBalanceAsset: string;
764
581
  agentBalances: Record<AgentId, AgentBalance>;
765
- /**
766
- * Per-agent read failures when an aggregate balance request returned only a
767
- * partial result. Callers may display the successful balances, but funding
768
- * operations must not interpret a missing agent as having a zero balance.
769
- */
770
- agentErrors?: Partial<Record<AgentId, string>>;
582
+ /** Omitted agents failed to load; they must not be interpreted as zero. */
583
+ agentErrors?: Record<AgentId, string>;
771
584
  /** Absolute provider cooldown deadlines (Unix milliseconds). */
772
- agentRetryAt?: Partial<Record<AgentId, number>>;
585
+ agentRetryAt?: Record<AgentId, number>;
773
586
  }
774
587
  interface AgentEarnings {
775
588
  smartWallet: `0x${string}`;
@@ -779,10 +592,6 @@ interface AgentEarnings {
779
592
  interface OwneyEarnings {
780
593
  totalEarnings: string;
781
594
  agentEarnings: Record<AgentId, AgentEarnings>;
782
- /** Per-agent failures when an aggregate read returned a partial result. */
783
- agentErrors?: Partial<Record<AgentId, string>>;
784
- /** Absolute provider cooldown deadlines (Unix milliseconds). */
785
- agentRetryAt?: Partial<Record<AgentId, number>>;
786
595
  }
787
596
  type ApyByChainAndAsset = Partial<Record<OwneySupportedChainId, Partial<Record<OwneySupportedTokens, number>>>>;
788
597
  /** A single day's net APY for the connected account, as a percentage number. */
@@ -828,15 +637,6 @@ interface OwneyAllocationApy {
828
637
  }
829
638
  type HistoryAction = "Rebalance" | "Deposit" | "Top up" | "Withdraw" | "Earned";
830
639
  interface HistoryTransaction {
831
- tokenAddress?: string;
832
- agentWallet?: string;
833
- logIndexes?: number[];
834
- transferLogs?: {
835
- logIndex: number;
836
- amountRaw: string;
837
- }[];
838
- amountRaw?: string;
839
- blockNumber?: string;
840
640
  txHashes: string[];
841
641
  chainId?: number;
842
642
  tokenSymbol?: string;
@@ -865,10 +665,17 @@ interface AgentHistoryPosition {
865
665
  amount?: string;
866
666
  }
867
667
  interface AgentHistoryEntry {
868
- /** Stable provider/transfer identity, independent of row order. */
869
- id?: string;
870
668
  agent: AgentId;
871
669
  action: HistoryAction;
670
+ /**
671
+ * Chain this entry came from, stamped by the history fan-out (ROUT-479).
672
+ *
673
+ * Absent on a single-chain read, where the caller already knows the chain.
674
+ * The entry has no chain of its own otherwise: `transactions[].chainId` is
675
+ * optional and missing whenever the indexer has not attached the transfer,
676
+ * so a row cannot be labelled from it reliably.
677
+ */
678
+ chainId?: OwneySupportedChainId;
872
679
  date: string;
873
680
  oldApy: string | null;
874
681
  newApy: string | null;
@@ -877,8 +684,6 @@ interface AgentHistoryEntry {
877
684
  positions?: AgentHistoryPosition[];
878
685
  }
879
686
  interface OwneyAgentHistory {
880
- agentErrors?: Partial<Record<AgentId, string>>;
881
- agentRetryAt?: Partial<Record<AgentId, number>>;
882
687
  data: AgentHistoryEntry[];
883
688
  /** True iff a subsequent page exists; pair with `nextCursor`. */
884
689
  hasMore: boolean;
@@ -919,15 +724,15 @@ interface AgentApy {
919
724
  interface OwneyAgentApy {
920
725
  agentApy: Record<AgentId, AgentApy>;
921
726
  }
922
- /** One day's cumulative earnings for a single asset. */
727
+ /** One day's cumulative NET earnings for a single asset. */
923
728
  interface DailyEarningsPoint {
924
729
  /** ISO date string for the day, e.g. "2026-09-01". */
925
730
  date: string;
926
731
  /**
927
- * Cumulative earnings in the asset's own units, using the provider's earnings
928
- * basis. A provider may return lifetime totals or a running window total;
929
- * difference the last and opening points to measure earnings over the window.
930
- * Aggregate series normalize each component's opening value before summing.
732
+ * Earnings accumulated from the start of the returned series up to and
733
+ * including this day, net of the agent's performance fee, denominated in the
734
+ * asset's own units. A running total of daily deltas, so it measures the
735
+ * window — not the wallet's lifetime.
931
736
  */
932
737
  amount: number;
933
738
  }
@@ -936,9 +741,8 @@ interface AssetDailyEarnings {
936
741
  /** Asset symbol, e.g. "USDC" / "WETH". */
937
742
  asset: string;
938
743
  /**
939
- * Ascending by date, including an opening snapshot before the requested
940
- * window when available. Provider gaps remain absent; aggregates carry the
941
- * most recent cumulative value across dates reported by other providers.
744
+ * Ascending by date. Days the wallet held nothing of this asset are absent
745
+ * rather than zero — a zero would read as "earned nothing that day".
942
746
  */
943
747
  points: DailyEarningsPoint[];
944
748
  }
@@ -955,7 +759,70 @@ interface AccountDailyEarnings {
955
759
  assets: AssetDailyEarnings[];
956
760
  }
957
761
 
958
- 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" | "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" | "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" | "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";
762
+ type DepositCallback = (smartWalletAddress: string, chainId: number, amount: string) => Promise<`0x${string}`> | `0x${string}`;
763
+ interface IAgent {
764
+ readonly id: string;
765
+ readonly supportedChainIds: readonly OwneySupportedChainId[];
766
+ readonly supportedAssets: readonly AgentSupportedAssets[];
767
+ disconnect(): Promise<void>;
768
+ activateAgent(state: ConnectionState, chainId: number): Promise<void>;
769
+ /**
770
+ * Apply the organization's agent policy to this user's account.
771
+ *
772
+ * Optional: an agent that has no equivalent knob simply omits it, which is why
773
+ * this is not part of `activateAgent`'s signature. Declared on the interface
774
+ * rather than only on ZyfaiAgent so the contract stays agent-neutral — the
775
+ * ticket asks for a design that can also cover Surf, which has no adapter yet.
776
+ *
777
+ * Implementations must be **non-fatal**: this runs during activation as a side
778
+ * effect, so a failure has to leave the user connected and their profile
779
+ * unchanged rather than break the connect.
780
+ */
781
+ applyOrgPolicy?(state: ConnectionState, chainId: number, policy: OrgAgentConfig): Promise<void>;
782
+ deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
783
+ withdraw(state: ConnectionState, chainId: number, token: OwneySupportedTokens, amount?: string): Promise<AgentWithdrawResult>;
784
+ getBalances(state: ConnectionState, chainId: number): Promise<AgentBalance>;
785
+ getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
786
+ /**
787
+ * Refresh the agent's earnings snapshot when its backend supports doing so.
788
+ * Implementations own freshness and request-deduplication policy.
789
+ */
790
+ refreshEarnings?(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
791
+ getAccountApy(state: ConnectionState, chainId: number, days: DailyApyDays,
792
+ /**
793
+ * Optional asset symbol ("USDC" / "WETH") scoping the daily series to a
794
+ * single asset on the chain. Agents without per-asset positions ignore it.
795
+ */
796
+ tokenSymbol?: string): Promise<AccountAgentApy>;
797
+ /**
798
+ * Daily cumulative NET earnings for the window, scoped to a chain/asset.
799
+ * Backs the "recent earnings" subline, whose figure must reconcile with the
800
+ * balance headline directly above it. (ROUT-452)
801
+ */
802
+ getDailyEarnings?(state: ConnectionState, chainId: number, days: LookbackDays, tokenSymbol?: string): Promise<AccountDailyEarnings>;
803
+ getHistory(state: ConnectionState, chainId: number, options?: HistoryFilters): Promise<OwneyAgentHistory>;
804
+ getUserProfile(state: ConnectionState, chainId: number): Promise<AgentUserProfile>;
805
+ /**
806
+ * Ensure the given asset uses backend protocol auto-selection
807
+ * (`autoSelectProtocols: true`). Optional capability — only agents whose
808
+ * backend models per-asset protocol selection implement it. Returns whether
809
+ * a write occurred (`false` = already enabled / not supported).
810
+ */
811
+ ensureAutoSelectProtocols?(state: ConnectionState, chainId: number, asset: "USDC" | "WETH"): Promise<boolean>;
812
+ getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
813
+ }
814
+ /**
815
+ * Optional filters for per-agent APY lookups.
816
+ * - `tokenSymbol` / `chainId` scope the APY to a specific asset+chain when
817
+ * the underlying provider supports it (Zyfai). Agents whose backends do
818
+ * not yet support per-asset APY will ignore these options.
819
+ */
820
+ type AgentApyOptions = {
821
+ tokenSymbol?: string;
822
+ chainId?: number;
823
+ };
824
+
825
+ type OwneyErrorCode = "NOT_CONNECTED" | "NO_ACTIVE_CHAIN" | "WALLET_NO_ACCOUNTS" | "WALLET_ADDRESS_REQUIRED" | "WALLET_NOT_DEPLOYED" | "AGENT_NOT_FOUND" | "AGENT_CHAIN_INCOMPATIBLE" | "AGENT_EMPTY_LIST" | "AGENT_DISABLED" | "CHAIN_UNSUPPORTED" | "CHAIN_NO_COMPATIBLE_AGENTS" | "CHAIN_MISMATCH" | "ASSET_UNSUPPORTED" | "ASSET_NO_COMPATIBLE_AGENTS" | "DEPOSIT_BALANCE_UNAVAILABLE" | "DEPOSIT_PARTIAL_FAILURE" | "DEPOSIT_AMOUNT_BELOW_MINIMUM" | "DEPOSIT_CALLBACK_REQUIRED" | "DEPOSIT_CALLBACK_INVALID" | "DEPOSIT_NO_PERMITTED_TOKENS" | "DEPOSIT_INSUFFICIENT_BALANCE" | "WITHDRAW_NO_PERMITTED_TOKENS" | "WITHDRAW_INSUFFICIENT_BALANCE" | "WITHDRAW_ALL_FAILED" | "WITHDRAW_NOTHING_TO_WITHDRAW" | "WITHDRAW_PARTIAL_FAILURE" | "WITHDRAW_FAILED" | "AGENT_RATE_LIMITED" | "API_ROUTING_ERROR" | "API_ROUTING_FAILED" | "API_NO_AGENTS" | "SPONSOR_REQUEST_FAILED" | "PERMIT2_APPROVAL_REQUIRED" | "SPONSORED_CALLS_UNSUPPORTED" | "SPONSORED_CALLS_NO_ID" | "SPONSORED_CALLS_NO_RECEIPT" | "SWAP_DISABLED" | "SWAP_RATE_LIMITED" | "SWAP_REQUEST_FAILED" | "SWAP_QUOTE_FAILED" | "SWAP_UNSUPPORTED_PAIR" | "SWAP_APPROVAL_REQUIRED" | "SWAP_BELOW_DEPOSIT_MINIMUM" | "SWAP_DEPOSIT_PENDING" | "SWAP_WALLET_PROMPT_TIMEOUT" | "SWAP_INSUFFICIENT_GAS" | "SWAP_NATIVE_UNSUPPORTED" | "SWAP_ORDER_EXPIRED" | "SWAP_ORDER_REFUNDED" | "SWAP_ORDER_CANCELLED" | "WITHDRAW_ARRIVAL_TIMEOUT" | "WITHDRAW_SWAP_FAILED" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
959
826
  declare class OwneyError extends Error {
960
827
  readonly code: OwneyErrorCode;
961
828
  readonly details?: Record<string, unknown>;
@@ -1115,15 +982,10 @@ declare class OwneySDK {
1115
982
  */
1116
983
  private disabledAgents;
1117
984
  private state;
1118
- private connectionRevision;
1119
- private disconnectingAgents;
1120
985
  private apiKey;
1121
986
  private orgAgentConfig;
1122
987
  private orgAgentConfigPromise;
1123
- private rpcUrls?;
1124
988
  private zyfaiRpcUrls?;
1125
- private yieldseekerApiBaseUrl?;
1126
- private yieldseekerSiweOrigin?;
1127
989
  private routingApiBaseUrl?;
1128
990
  private referralSource?;
1129
991
  private cachedSponsoredCallback;
@@ -1131,11 +993,7 @@ declare class OwneySDK {
1131
993
  private paymasterServiceUrl?;
1132
994
  private cachedSponsoredCallsCallbacks;
1133
995
  private readonly agentReads;
1134
- private readonly recoveredFundingReads;
1135
- private fundingBalanceChecks;
1136
996
  private readonly activationChecks;
1137
- private readonly withdrawalSubmissions;
1138
- private readonly withdrawalSwapSubmissions;
1139
997
  private readAgent;
1140
998
  private initializingAgentsPromise;
1141
999
  constructor(config: OwneySDKConfig);
@@ -1150,8 +1008,6 @@ declare class OwneySDK {
1150
1008
  * After calling this, `connect()` must be called again before using agent methods.
1151
1009
  */
1152
1010
  disconnect(): Promise<void>;
1153
- private clearConnectionState;
1154
- private disconnectAgents;
1155
1011
  private isAgentDisabled;
1156
1012
  /**
1157
1013
  * Check if the SDK has an active connection state.
@@ -1166,20 +1022,28 @@ declare class OwneySDK {
1166
1022
  private requireState;
1167
1023
  private requireChainId;
1168
1024
  private requireConnectedProvider;
1169
- private getPaidRpcClient;
1170
- /** Builds the default USDC batch callback for the connected wallet. */
1025
+ /**
1026
+ * Lazily builds (and caches) the default EIP-3009 sponsored deposit callback
1027
+ * used when the caller omits `depositCallback`. Wraps the connected EIP-1193
1028
+ * provider with viem `custom(provider)` to read token meta and sign the
1029
+ * `TransferWithAuthorization`, then POSTs to the sponsor API.
1030
+ */
1171
1031
  private getDefaultSponsoredCallback;
1172
- /** Builds the wallet-native sponsored calls callback for compatible paymasters. */
1032
+ /**
1033
+ * Lazily builds (and caches) the default Permit2 sponsored WETH deposit
1034
+ * callback used when the caller omits `depositCallback` for a WETH
1035
+ * deposit. Mirrors `getDefaultSponsoredCallback()` but signs a Permit2
1036
+ * `PermitTransferFrom` instead of an EIP-3009 authorization.
1037
+ */
1173
1038
  private getDefaultSponsoredCallsCallback;
1174
1039
  /**
1175
1040
  * Lazily builds (and caches) the default Permit2 sponsored WETH deposit
1176
1041
  * callback used when the caller omits `depositCallback` for a WETH deposit.
1177
1042
  * Mirrors `getDefaultSponsoredCallback()` but signs a Permit2
1178
- * single-use batch authorization instead of an EIP-3009 authorization.
1043
+ * `PermitTransferFrom` instead of an EIP-3009 authorization.
1179
1044
  */
1180
1045
  private getDefaultWethSponsoredCallback;
1181
1046
  private getAgent;
1182
- getActiveAgentIds(): AgentId[];
1183
1047
  private getActiveAgents;
1184
1048
  /**
1185
1049
  * Read the org's agent policy once and reuse it. fetchOrgAgentConfig never
@@ -1212,8 +1076,7 @@ declare class OwneySDK {
1212
1076
  * If provided, ALL specified agents must support the chainId or the call
1213
1077
  * throws before activating any agent.
1214
1078
  */
1215
- activateAgent(chainId: number, agentId?: AgentId[], asset?: OwneySupportedTokens): Promise<void>;
1216
- private assertActivationSession;
1079
+ activateAgent(chainId: number, agentId?: AgentId[]): Promise<void>;
1217
1080
  /**
1218
1081
  * Activate agents ONE AT A TIME, each followed by its org policy.
1219
1082
  *
@@ -1227,9 +1090,10 @@ declare class OwneySDK {
1227
1090
  * Serializing costs no real wall-clock: the user can only approve one prompt
1228
1091
  * at a time anyway.
1229
1092
  *
1230
- * Stop at the first failure so a canceled sign-in does not open another
1231
- * agent's wallet prompt. Report any earlier successes for diagnostics; the
1232
- * app discards the session when the complete sign-in does not succeed.
1093
+ * Every agent is attempted even if an earlier one fails, so one declined
1094
+ * signature can't deny the remaining agents their turn. The first failure is
1095
+ * rethrown (matching the previous `Promise.all` rejection) once all agents
1096
+ * have had a chance to activate.
1233
1097
  */
1234
1098
  private activateAgentsInTurn;
1235
1099
  /**
@@ -1240,8 +1104,7 @@ declare class OwneySDK {
1240
1104
  * @param options.asset - Asset symbol to deposit (e.g. "USDC")
1241
1105
  * @param options.depositCallback - Callback that performs the token transfer and returns a tx hash.
1242
1106
  * When agentId is omitted, this callback is invoked once per eligible agent with that agent's
1243
- * split amount and smart wallet address. Default sponsored deposits batch
1244
- * all shares into one signature; custom callbacks still run once per agent.
1107
+ * split amount and smart wallet address — expect multiple wallet prompts.
1245
1108
  * @param options.agentId - Optional explicit target. Otherwise split equally,
1246
1109
  * or fund remaining agents when a recovery deposit cannot meet every minimum.
1247
1110
  * @returns {OwneyDepositResult} for a single agent, or {OwneyMultiDepositResult} with per-agent results
@@ -1251,12 +1114,10 @@ declare class OwneySDK {
1251
1114
  * Invokes `agent.deposit` with the resolved sponsored callback, composing
1252
1115
  * two independent auto-recovery mechanisms:
1253
1116
  *
1254
- * 1. Missing Permit2 allowance outside the atomic Base-USDC path: when the
1255
- * app did not supply its own callback and the attempt fails with
1256
- * `PERMIT2_APPROVAL_REQUIRED`, this is the wallet's first Permit2 deposit
1257
- * for that token. Base USDC bundles a gasless ERC-2612 approval inside
1258
- * its sponsored deposit and never reaches this branch. Other tokens send
1259
- * the one-time user-paid Permit2 approval via `approvePermit2()` and
1117
+ * 1. Missing Permit2 allowance: when the app did not supply its own
1118
+ * callback and the attempt fails with `PERMIT2_APPROVAL_REQUIRED` on a
1119
+ * WETH deposit, this is the wallet's first gasless WETH deposit. We send
1120
+ * the one-time (user-paid) Permit2 approval via `approvePermit2()` and
1260
1121
  * retry the SAME sponsored attempt once. Bounded to one approval attempt
1261
1122
  * per call so a wallet/agent that keeps reporting the allowance as
1262
1123
  * missing can't loop forever. If `approvePermit2()` itself throws (e.g.
@@ -1277,7 +1138,6 @@ declare class OwneySDK {
1277
1138
  private depositWithFallback;
1278
1139
  private getMinDepositAmount;
1279
1140
  private splitDepositAmount;
1280
- private formatAgentName;
1281
1141
  private validateMinDepositAmount;
1282
1142
  /**
1283
1143
  * Whether the user already holds a non-zero balance with `agent` for the
@@ -1286,50 +1146,25 @@ declare class OwneySDK {
1286
1146
  * false, so the minimum is enforced as today.
1287
1147
  */
1288
1148
  private hasExistingBalance;
1149
+ /**
1150
+ * Guard an explicitly requested chain against one agent's own list.
1151
+ *
1152
+ * Only reachable when the caller passes `chainId` — the activated chain has
1153
+ * already been checked by `activateAgent`. Kept separate from
1154
+ * `validateAssetSupport` so "this agent is not on Ethereum" does not arrive
1155
+ * worded as "this agent does not support USDC".
1156
+ */
1157
+ private validateChainSupport;
1158
+ /**
1159
+ * Guard an explicitly requested chain before a fan-out.
1160
+ *
1161
+ * Without this the split simply produces no agents, and the caller is told
1162
+ * their amount "cannot activate every eligible agent" against a combined
1163
+ * minimum of 0 — an error about the amount when the chain is at fault.
1164
+ */
1165
+ private validateChainHasAgents;
1289
1166
  private validateAssetSupport;
1290
1167
  private getEligibleAgents;
1291
- /**
1292
- * Run owner-approved withdrawals before relayer-only withdrawals. Wallet
1293
- * approval is the only point at which the user can cancel the aggregate
1294
- * operation, so no relayer leg should commit before it has completed.
1295
- */
1296
- private orderAgentsForWithdrawal;
1297
- private isUserRejectedWithdrawal;
1298
- private captureReadScope;
1299
- /** Revalidate a saved transfer against the authenticated account and actual receipt. */
1300
- inspectFunding(evidence: FundingEvidence, direction: "deposit" | "withdraw", options?: {
1301
- balanceRefreshUntil?: number;
1302
- refreshBalance?: boolean;
1303
- requireAmountMatch?: boolean;
1304
- }): Promise<FundingEvidence>;
1305
- /** Resolve a saved sponsored-withdrawal ID without opening a wallet prompt. */
1306
- resolveSponsoredWithdrawalEvidence(evidence: FundingEvidence, options?: {
1307
- submittedAt?: number;
1308
- }): Promise<FundingEvidence>;
1309
- /** Recover an EIP-5792 deposit or payout using this account's exact batch ID. */
1310
- resolveWalletCallsFundingEvidence(evidence: FundingEvidence, direction: "deposit" | "withdraw"): Promise<FundingEvidence>;
1311
- /** Whether a foreground deposit can resume the same signed batch, never a
1312
- * fresh authorization. The batch rail independently rechecks the exact plan. */
1313
- canResumePendingDeposit(evidences: FundingEvidence[], amount: string): Promise<boolean>;
1314
- /** Optional post-payout display proof; receipt verification and the provider
1315
- * adapter must agree before attaching it to this exact balance object. */
1316
- verifyWithdrawalBalance(evidence: FundingEvidence, balance: AgentBalance): Promise<AgentBalance>;
1317
- /** A display acknowledgement controls polling only; it never confirms a financial outcome. */
1318
- endFundingBalanceRefresh(evidence: FundingEvidence, read: AssetReadMetadata): boolean;
1319
- /** History lookup for receipt recovery; adapters may not authenticate or sign here. */
1320
- getFundingHistory(evidence: FundingEvidence, fromDate: string, options?: Pick<HistoryFilters, "cursor" | "toDate">): Promise<OwneyAgentHistory>;
1321
- recoverDepositRegistration(evidence: FundingEvidence): Promise<FundingEvidence>;
1322
- /** On-chain version and ownership status for this owner's Yieldseeker agent. */
1323
- getYieldseekerWalletStatus(asset: OwneySupportedTokens): Promise<YieldseekerWalletStatus | null>;
1324
- /** Deployment gate; an unavailable response keeps the current paid path. */
1325
- isYieldseekerWithdrawalSponsorshipAvailable(): Promise<boolean>;
1326
- isYieldseekerUpgradeSponsorshipAvailable(): Promise<boolean>;
1327
- private isYieldseekerSponsorshipAvailable;
1328
- /** Explicit V1-to-V2 upgrade, confirmed on chain before returning. */
1329
- upgradeYieldseekerWallet(asset: OwneySupportedTokens, gasMode?: "paid" | "sponsored"): Promise<{
1330
- txHash: viem.Hex;
1331
- status: YieldseekerWalletStatus;
1332
- }>;
1333
1168
  /** Lazily built so an app that never swaps pays nothing for it. */
1334
1169
  private swapApiClient?;
1335
1170
  private swapApi;
@@ -1374,6 +1209,18 @@ declare class OwneySDK {
1374
1209
  * would strand funds we might have been able to move.
1375
1210
  */
1376
1211
  /** ERC20 balance of the connected wallet, read through the wallet's own node. */
1212
+ /**
1213
+ * A read client pinned to `chainId`, over HTTP rather than the wallet.
1214
+ *
1215
+ * The swap rail has read this way from the start, and the reason is written
1216
+ * out at `buildSwapDeps`: a provider-backed client reads from whatever chain
1217
+ * the WALLET is on, which after a cross-chain swap is the source chain, not
1218
+ * the one the funds landed on. The deposit's own reads did not, so a Permit2
1219
+ * check for WETH on Arbitrum went to Base — where that address is not a
1220
+ * contract at all, so viem got "0x" back and threw "The contract function
1221
+ * 'allowance' returned no data".
1222
+ */
1223
+ private chainReader;
1377
1224
  private readTokenBalance;
1378
1225
  /** How much of `token` the wallet has already approved Permit2 to move. */
1379
1226
  private readTokenPermit2Allowance;
@@ -1621,9 +1468,10 @@ declare class OwneySDK {
1621
1468
  * Quoting before the tokens land would size the swap against a balance that
1622
1469
  * is not there yet.
1623
1470
  *
1624
- * Wait for each participating agent's owner payout and size one swap from
1625
- * their confirmed net amounts. A first wallet increase cannot establish
1626
- * that every payout arrived. Failed or incomplete withdrawals stop here.
1471
+ * The swap is therefore sized from the MEASURED arrival, exactly as the
1472
+ * deposit path sizes its deposit from the measured swap output. On a full
1473
+ * withdrawal there is no other number available — "MAX" has no figure until
1474
+ * the agent picks one.
1627
1475
  *
1628
1476
  * **Failure here is not symmetrical with the deposit path.** A failed
1629
1477
  * deposit-swap leaves the user holding what they started with. A failed
@@ -1650,8 +1498,6 @@ declare class OwneySDK {
1650
1498
  /** Percent, classic rail only. Fusion+ prices through its auction. */
1651
1499
  slippage?: number;
1652
1500
  onSwapProgress?: (stage: SwapStage) => void;
1653
- /** Receipt evidence for the existing funding/recovery tracker. */
1654
- onWithdrawalProgress?: FundingProgress;
1655
1501
  /**
1656
1502
  * Fires once the order is with the relayer, before the watch.
1657
1503
  *
@@ -1700,21 +1546,25 @@ declare class OwneySDK {
1700
1546
  * @returns {AgentWithdrawResult} for a single agent, or {OwneyWithdrawResult} with per-agent results
1701
1547
  */
1702
1548
  withdraw(options: WithdrawOptions): Promise<OwneyWithdrawResult | AgentWithdrawResult>;
1703
- private withdrawFromAgents;
1704
- /** Read-only invalidation after new pool-deposit activity. Does not restart
1705
- * funding reconciliation, bypass cooldowns, or authorize a transaction. */
1706
- invalidateAllocationRead(scope: Pick<FundingEvidence, "agentId" | "walletAddress" | "chainId" | "token">): boolean;
1707
1549
  /**
1708
1550
  * Get the user's balances for a specific agent, or aggregated across all agents.
1709
1551
  * @param agentId - Optional. Agent to query. Omit for aggregated balances.
1710
1552
  * @returns {AgentBalance} for a single agent, or {OwneyBalances} with totalBalance and per-agent breakdown
1711
1553
  */
1712
- getBalances(agentId?: AgentId, options?: {
1713
- chainId?: number;
1714
- asset?: OwneySupportedTokens;
1715
- }): Promise<OwneyBalances | AgentBalance>;
1716
- /** Preserve failure objects for withdrawal recovery without changing public balance results. */
1717
- private readAggregatedBalances;
1554
+ /**
1555
+ * Withdraw every position the wallet holds, across chains and assets.
1556
+ *
1557
+ * `withdraw()` drains one asset on one chain, so this is N of those. It
1558
+ * deliberately does not stop at the first failure: the funds in the other
1559
+ * positions are just as withdrawable, and someone who asked for everything
1560
+ * is better served by three of four than by none. Each leg reports its own
1561
+ * outcome so the caller can name the ones that did not arrive; only a total
1562
+ * failure throws.
1563
+ *
1564
+ * @returns {OwneyWithdrawAllResult} one leg per position attempted.
1565
+ */
1566
+ withdrawAll(): Promise<OwneyWithdrawAllResult>;
1567
+ getBalances(agentId?: AgentId): Promise<OwneyBalances | AgentBalance>;
1718
1568
  /**
1719
1569
  * Get the user's on-chain earnings for a specific agent, or aggregated across all agents.
1720
1570
  * @param agentId - Optional. Agent to query. Omit for aggregated earnings.
@@ -1726,7 +1576,6 @@ declare class OwneySDK {
1726
1576
  * Agents without a refresh capability fall back to their current snapshot.
1727
1577
  */
1728
1578
  refreshEarnings(agentId?: AgentId): Promise<OwneyEarnings | AgentEarnings>;
1729
- private aggregateEarnings;
1730
1579
  /**
1731
1580
  * Get the weighted APY for the user's account over a time period.
1732
1581
  * When querying all agents, the total APY is a balance-weighted average.
@@ -1736,15 +1585,17 @@ declare class OwneySDK {
1736
1585
  * @returns {AccountAgentApy} for a single agent, or {OwneyAccountApy} with totalApy and per-agent breakdown
1737
1586
  */
1738
1587
  /**
1739
- * Daily cumulative earnings in the selected asset's units, backing the
1740
- * "recent earnings" subline. Each adapter uses its provider's earnings basis.
1588
+ * Daily cumulative NET earnings for the selected chain/asset, backing the
1589
+ * "recent earnings" subline. Net is computed as Zyfai's own
1590
+ * `lifetime + unrealized + current x 0.9`, so the figure reconciles with the
1591
+ * balance headline rather than reading ~11% high. (ROUT-452)
1741
1592
  *
1742
1593
  * Unlike getAccountApy this does NOT blend across agents: earnings are
1743
1594
  * summed, not weighted, and an agent that fails to report must not silently
1744
1595
  * subtract from the total. Without an agentId the series is the sum of the
1745
1596
  * agents that answered.
1746
1597
  */
1747
- getDailyEarnings({ agentId, days, tokenSymbol, }: DailyEarningsOptions): Promise<AccountDailyEarnings>;
1598
+ getDailyEarnings({ agentId, days, tokenSymbol, chainIds, }: DailyEarningsOptions): Promise<AccountDailyEarnings>;
1748
1599
  getAccountApy({ agentId, days, tokenSymbol, }: AccountApyOptions): Promise<OwneyAccountApy | AccountAgentApy>;
1749
1600
  /**
1750
1601
  * Get transaction history for a specific agent, or all agents.
@@ -1779,17 +1630,14 @@ declare class OwneySDK {
1779
1630
  */
1780
1631
  ensureAutoSelectProtocols(asset: "USDC" | "WETH", agentId?: AgentId): Promise<boolean>;
1781
1632
  /**
1782
- * User-paid approval of Permit2 on the selected token for the active chain.
1783
- * Grants the maximum ERC20 allowance so later deposits do not require another
1784
- * approval. Resolves after one confirmation so the subsequent deposit attempt
1785
- * sees the new allowance. Deposit retries pass their captured chain id so a
1786
- * concurrent activation cannot redirect the approval to another network.
1787
- *
1788
- * @param requiredAmount Raw base-unit amount the pending deposit must cover.
1789
- * @param expectedChainId Chain captured by the deposit that requested approval.
1633
+ * One-time, user-paid approval of Permit2 on the sponsored WETH token for
1634
+ * the active chain. Required once per wallet per chain before gasless WETH
1635
+ * deposits; afterwards deposit() is signature-only. Resolves only after the
1636
+ * approval transaction is mined (1 confirmation), so a subsequent deposit()
1637
+ * will see the new allowance; throws if the transaction reverted.
1790
1638
  * @returns the approval transaction hash.
1791
1639
  */
1792
- approvePermit2(asset?: OwneySupportedTokens, requiredAmount?: bigint, expectedChainId?: OwneySupportedChainId): Promise<`0x${string}`>;
1640
+ approvePermit2(asset?: "WETH"): Promise<`0x${string}`>;
1793
1641
  /**
1794
1642
  * Get the agent's average APY performance over a time period. Does not require a wallet connection.
1795
1643
  * @param options - Contains agentId (optional) and days ("7D", "14D", or "30D")
@@ -1813,170 +1661,6 @@ declare class OwneySDK {
1813
1661
  getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
1814
1662
  }
1815
1663
 
1816
- type YieldseekerAuthDependencies = {
1817
- origin?: string;
1818
- now?: () => Date;
1819
- nonce?: () => string;
1820
- };
1821
-
1822
- type YieldseekerFetch = typeof fetch;
1823
-
1824
- type YieldseekerTransaction = {
1825
- from: `0x${string}`;
1826
- to: `0x${string}`;
1827
- data: `0x${string}`;
1828
- value: string;
1829
- chainId: number;
1830
- };
1831
-
1832
- type YieldseekerWalletStatus = {
1833
- agentWallet: Address;
1834
- owner: Address;
1835
- ownerPath: "eoa" | "smart";
1836
- asset: Address;
1837
- implementation: Address;
1838
- version: "v1" | "v2" | "unknown";
1839
- upgradeAvailable: boolean;
1840
- /** The factory, owner, base asset, and provider wallet mapping all agree. */
1841
- verified: boolean;
1842
- };
1843
-
1844
- type YieldseekerAgentOptions = {
1845
- baseUrl?: string;
1846
- routingApiBaseUrl?: string;
1847
- fetchFn?: YieldseekerFetch;
1848
- auth?: YieldseekerAuthDependencies;
1849
- /** Dedicated read transport; Base is used for receipt polling. */
1850
- rpcUrls?: RpcUrlsConfig;
1851
- /** Test seam for the wallet-submission/receipt boundary. */
1852
- transactionExecutor?: (state: ConnectionState, chainId: number, transaction: YieldseekerTransaction, onReceipt?: (receipt: viem.TransactionReceipt) => void) => Promise<Hex>;
1853
- /** Test seam for transactions submitted outside transactionExecutor. */
1854
- unwindReceiptWaiter?: (state: ConnectionState, chainId: number, transactionHash: Hex) => Promise<void>;
1855
- };
1856
- declare class YieldseekerAgent implements IAgent {
1857
- readonly id = "yieldseeker";
1858
- readonly balanceComposition: "tokens-plus-positions";
1859
- readonly withdrawalRequiresWalletApproval = true;
1860
- readonly supportedChainIds: readonly [8453];
1861
- readonly supportedAssets: readonly [{
1862
- readonly chainId: 8453;
1863
- readonly chain: "BASE";
1864
- readonly assets: readonly [{
1865
- readonly symbol: "USDC";
1866
- readonly minDepositAmount: "10000000";
1867
- }, {
1868
- readonly symbol: "WETH";
1869
- readonly minDepositAmount: "1";
1870
- }];
1871
- }];
1872
- private readonly api;
1873
- private readonly auth;
1874
- private readonly rpcUrls?;
1875
- private readonly owneyApiKey;
1876
- private readonly routingApiBaseUrl?;
1877
- private receiptClient?;
1878
- private readonly withdrawalVersionCache;
1879
- private readonly pendingUpgrades;
1880
- private readonly transactionExecutor?;
1881
- private readonly unwindReceiptWaiter?;
1882
- private readonly agentContexts;
1883
- private readonly balanceContexts;
1884
- private readonly balanceVaults;
1885
- private readonly users;
1886
- private readonly pendingAgents;
1887
- private readonly pendingWalletContexts;
1888
- private readonly readCache;
1889
- private readonly pendingReads;
1890
- private readGeneration;
1891
- private readonly portfolioVersions;
1892
- private readonly snapshotFailures;
1893
- private readonly standardReadFailures;
1894
- private readonly reconcileUntil;
1895
- private readonly allocationRefresh;
1896
- private readonly activityRefreshUntil;
1897
- private readonly snapshotMovements;
1898
- private readonly movementEpochs;
1899
- private readonly yieldOptions;
1900
- private readonly pendingYieldOptions;
1901
- constructor(owneyApiKey: string, options?: YieldseekerAgentOptions);
1902
- private getReceiptClient;
1903
- /** Reads the actual proxy implementation; Yieldseeker's API walletType is not a version check. */
1904
- getWalletStatus(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, useCachedV2?: boolean): Promise<YieldseekerWalletStatus | null>;
1905
- private rememberWalletStatus;
1906
- /** Explicit owner action. This never runs as a side effect of withdrawal. */
1907
- upgradeWallet(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, gasMode?: "paid" | "sponsored"): Promise<{
1908
- txHash: Hex;
1909
- status: YieldseekerWalletStatus;
1910
- }>;
1911
- disconnect(): Promise<void>;
1912
- activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
1913
- deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback, onProgress?: FundingProgress, onBeforeSubmission?: (evidence: FundingEvidence) => void | Promise<void>): Promise<OwneyDepositResult>;
1914
- withdraw(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, amount?: string, onProgress?: FundingProgress, gasMode?: "auto" | "sponsored" | "paid", onBeforeSubmission?: FundingProgress): Promise<AgentWithdrawResult>;
1915
- private withdrawInternal;
1916
- /** Fresh position amounts for withdrawal planning, net of reserved fees. */
1917
- getWithdrawableBalance(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, minimumAmount?: bigint): Promise<bigint>;
1918
- private readVaultShares;
1919
- private validateWithdrawalPositions;
1920
- private withdrawalVaultHints;
1921
- private readWithdrawalPositions;
1922
- private resolveWithdrawalLiquidity;
1923
- getBalances(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<AgentBalance>;
1924
- verifyWithdrawalBalance(state: ConnectionState, evidence: FundingEvidence, balance: AgentBalance): Promise<AssetReadMetadata | undefined>;
1925
- invalidateAllocationRead(state: ConnectionState, chainId: number, asset: OwneySupportedTokens): void;
1926
- invalidateFundingRead(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, refreshUntil?: number): void;
1927
- endFundingBalanceRefresh(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, read: AssetReadMetadata): boolean;
1928
- getFundingWallet(state: ConnectionState, chainId: number, asset: OwneySupportedTokens): Promise<string>;
1929
- hasExistingDepositFunds(state: ConnectionState, chainId: number, asset: OwneySupportedTokens): Promise<true | undefined>;
1930
- getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
1931
- getAccountApy(state: ConnectionState, chainId: number, days: DailyApyDays, tokenSymbol?: string): Promise<AccountAgentApy>;
1932
- getDailyEarnings(state: ConnectionState, chainId: number, days: LookbackDays, tokenSymbol?: string): Promise<AccountDailyEarnings>;
1933
- getHistory(state: ConnectionState, chainId: number, options?: HistoryFilters): Promise<OwneyAgentHistory>;
1934
- getUserProfile(state: ConnectionState, chainId: number): Promise<AgentUserProfile>;
1935
- getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
1936
- private loadYieldOptions;
1937
- private userKey;
1938
- private contextKey;
1939
- private assertSession;
1940
- private cachedRead;
1941
- private agentListKey;
1942
- private listAgents;
1943
- private contextForAgent;
1944
- private resolveUser;
1945
- private forgetUser;
1946
- private ensureAgent;
1947
- private findAgent;
1948
- private resolveAgent;
1949
- private loadPortfolio;
1950
- private loadActivityPortfolio;
1951
- private resolvePortfolioContexts;
1952
- private portfolioVersion;
1953
- private portfolioCacheMs;
1954
- private snapshotMovement;
1955
- private advancePortfolioVersion;
1956
- private requestPortfolioSnapshot;
1957
- private portfolioSnapshot;
1958
- private loadPortfolioContext;
1959
- private loadActivityContext;
1960
- private loadPortfolioParts;
1961
- private deployAgent;
1962
- private refreshSnapshotAfterMovement;
1963
- private agentPath;
1964
- private walletRequest;
1965
- private providerRequest;
1966
- private mapApiError;
1967
- private submitTransaction;
1968
- private waitForReceipt;
1969
- private assertTransaction;
1970
- private assertAgent;
1971
- private isOwneyAgent;
1972
- private assetForAgent;
1973
- private isTransactionHash;
1974
- private assertChain;
1975
- private assertOptionalChain;
1976
- private assertAsset;
1977
- private invalidResponse;
1978
- }
1979
-
1980
1664
  declare class InvalidHistoryCursorError extends Error {
1981
1665
  readonly code: "invalid_cursor";
1982
1666
  constructor(message: string);
@@ -2054,4 +1738,4 @@ type StoredOrder = {
2054
1738
  */
2055
1739
  declare function listOrders(now?: number): StoredOrder[];
2056
1740
 
2057
- export { type AccountAgentApy, type AccountApyOptions, type AccountDailyEarnings, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentHistoryEntry, type AgentHistoryPosition, type AgentId, AgentNotFoundError, type AgentSupportedAsset, type AgentSupportedAssets, type AgentUserProfile, type AgentWithdrawResult, type AgentsApyOptions, type AllocationAgentApy, type AllocationApyOptions, type ApyByChainAndAsset, type ApyHistoryPoint, type Asset, type AssetDailyEarnings, type AssetReadMetadata, type AvailableAgent, type AvailableAgentsOptions, type ConnectionState, type DailyApyDays, type DailyEarningsOptions, type DailyEarningsPoint, type DepositCallback, type DepositOptions, type FundingEvidence, type FundingProgress, type FundingStage, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, type LookbackDays, NotConnectedError, type OwneyAccountApy, type OwneyAgentApy, type OwneyAgentHistory, type OwneyAllocationApy, type OwneyBalances, type OwneyDepositResult, type OwneyEarnings, OwneyError, type OwneyErrorCode, type OwneyMultiDepositResult, type OwneyPosition, OwneySDK, type OwneySDKConfig, type OwneySIWXConfig, type OwneySupportedChainId, type OwneySupportedChains, type OwneySupportedTokens, type OwneyToken, type OwneyUserProfile, type OwneyWithdrawResult, type PendingDeposit, type RebalanceLog, type RpcUrlsConfig, 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, YieldseekerAgent, type YieldseekerWalletStatus, type ZyfaiRpcUrlsConfig, clearWithdrawSwap, createOwneySIWX, listPendingDeposits, listOrders as listPendingSwaps, listWithdrawSwaps, saveWithdrawSwap, setOwneyDebug, subscribeWithdrawSwaps, updateWithdrawSwap };
1741
+ export { type AccountAgentApy, type AccountApyOptions, type AccountDailyEarnings, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentHistoryEntry, type AgentHistoryPosition, type AgentId, AgentNotFoundError, type AgentSupportedAsset, type AgentSupportedAssets, type AgentUserProfile, type AgentWithdrawResult, type AgentsApyOptions, type AllocationAgentApy, type AllocationApyOptions, type ApyByChainAndAsset, type ApyHistoryPoint, type Asset, type AssetDailyEarnings, type AvailableAgent, type AvailableAgentsOptions, type ConnectionState, type DailyApyDays, type DailyEarningsOptions, type DailyEarningsPoint, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, type LookbackDays, NotConnectedError, type OwneyAccountApy, type OwneyAgentApy, type OwneyAgentHistory, type OwneyAllocationApy, type OwneyBalances, type OwneyDepositResult, type OwneyEarnings, OwneyError, type OwneyErrorCode, type OwneyMultiDepositResult, type OwneyPosition, OwneySDK, type OwneySDKConfig, type OwneySIWXConfig, type OwneySupportedChainId, type OwneySupportedChains, type OwneySupportedTokens, type OwneyToken, type OwneyUserProfile, type OwneyWithdrawAllLeg, type OwneyWithdrawAllResult, type OwneyWithdrawResult, type PendingDeposit, type RebalanceLog, type SwapChainTokens, type SwapDirection, type SwapOrderStatus, type SwapQuote, type SwapQuoteParams, type SwapRail, type SwapStage, type SwapTokenInfo, type SwapTokenSearchResult, type WithdrawOptions, type WithdrawSwapRecord, type WithdrawSwapStatus, clearWithdrawSwap, createOwneySIWX, listPendingDeposits, listOrders as listPendingSwaps, listWithdrawSwaps, saveWithdrawSwap, setOwneyDebug, subscribeWithdrawSwaps, updateWithdrawSwap };