@owney/sdk 0.7.25-beta.0 → 0.7.25-beta.3

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,155 +1,6 @@
1
+ import { Hex } from 'viem';
1
2
  import { SIWXConfig } from '@reown/appkit-controllers';
2
3
 
3
- /**
4
- * Swap-to-yield types (ROUT-242).
5
- *
6
- * The SDK never talks to 1inch directly — the API key is a paid credential and
7
- * lives in the routing API. Everything here describes the routing API's
8
- * `/api/v1/swap/*` contract.
9
- */
10
- /**
11
- * Which rail a swap rides, decided server-side from the chains.
12
- *
13
- * `classic` — same chain. One atomic transaction: it either completes or
14
- * nothing moved.
15
- *
16
- * `fusion-plus` — crossing chains. The user's funds sit in an escrow while a
17
- * resolver fills the other side, so the order has a lifecycle and can end in
18
- * `expired` → `refunding` → `refunded` without ever depositing.
19
- */
20
- type SwapRail = "classic" | "fusion-plus";
21
- type SwapTokenInfo = {
22
- readonly symbol: string;
23
- readonly address: string;
24
- readonly decimals: number;
25
- /** Native asset (ETH). A swap SOURCE only — never a deposit target. */
26
- readonly isNative?: true;
27
- };
28
- type SwapChainTokens = {
29
- readonly chainId: number;
30
- /** What the user may pay with. */
31
- readonly sources: readonly SwapTokenInfo[];
32
- /** What a swap may resolve into — what Owney actually deposits. */
33
- readonly depositTargets: readonly SwapTokenInfo[];
34
- };
35
- type SwapQuote = {
36
- rail: SwapRail;
37
- src: {
38
- chainId: number;
39
- symbol: string;
40
- address: string;
41
- amount: string;
42
- };
43
- dst: {
44
- chainId: number;
45
- symbol: string;
46
- address: string;
47
- amount: string;
48
- };
49
- /**
50
- * Worst-case output once the Dutch auction has fully decayed. Gate minimum
51
- * deposit checks on THIS, not `dst.amount` — a fill at auction end that lands
52
- * under the agent's floor would leave the user swapped but not deposited.
53
- */
54
- dstAmountMin: string;
55
- /** Cross-chain only. Per-order escrow schedule in seconds, set by 1inch. */
56
- timeLocks?: Record<string, number>;
57
- /**
58
- * Cross-chain only. How many preimages to mint before building an order.
59
- * Building with the wrong number produces escrows the user's secrets cannot
60
- * unlock, stranding the swap until its cancellation timelock.
61
- */
62
- secretsCount?: number;
63
- /**
64
- * Cross-chain only. The contract the source token must be approved to (the
65
- * 1inch Limit Order Protocol) before a resolver can fill the order.
66
- *
67
- * Absent on the classic rail, where the router address arrives with the swap
68
- * calldata instead.
69
- */
70
- spender?: string;
71
- /**
72
- * True only for a cross-chain swap FROM native ETH, which needs an on-chain
73
- * order creation carrying the full amount as msg.value. The user's funds
74
- * leave the wallet before any fill, so the UI must say so. ERC-20 sources are
75
- * signature-only after their one-time approval.
76
- */
77
- requiresOnchainOrder: boolean;
78
- /**
79
- * What the swap costs, as the provider reports it on this quote.
80
- *
81
- * Surfaced rather than derived: a fee the UI computes from its own constant
82
- * drifts from the one actually charged the moment the two disagree, and they
83
- * did — the integrator fee was configured on our side for days while the
84
- * provider had it switched off, so the real charge was zero.
85
- *
86
- * Cross-chain only. The classic rail reports no breakdown.
87
- */
88
- feeInfo?: {
89
- /** Owney's cut. Absent until a fee receiver is configured. */
90
- integratorFee?: {
91
- receiver: string;
92
- bps: number;
93
- share: number;
94
- };
95
- /** The filler's cut, charged either way. */
96
- resolverFee?: {
97
- receiver: string;
98
- bps: number;
99
- };
100
- };
101
- /**
102
- * Owney's cut in basis points, for display.
103
- *
104
- * Distinct from `feeInfo`, which is what the provider measured on this
105
- * quote. When the provider applies the fee at settlement it reports nothing
106
- * here, and this carries the agreed figure instead so the UI can still name
107
- * one. Stated, not verified.
108
- */
109
- integratorFeeBps?: number;
110
- };
111
- /**
112
- * Terminal states are `executed`, `expired`, `cancelled` and `refunded`.
113
- * `refunding` is the window the returning-funds screen renders: the order has
114
- * failed and the money is on its way back, but is not back yet.
115
- */
116
- type SwapOrderStatus = "pending" | "executed" | "expired" | "cancelled" | "refunding" | "refunded" | "unpublished";
117
- /**
118
- * Stage reported to the UI while a swap runs, in either direction.
119
- *
120
- * `withdrawing` and `withdrawn` belong to the withdrawal path only: the
121
- * withdrawal is acknowledged by the agent long before the tokens appear in the
122
- * wallet, and the swap cannot start until they have. That wait is a visible
123
- * stage rather than dead time inside "quoting", because it is the longest part
124
- * of the flow and the one place a user would otherwise think nothing is
125
- * happening.
126
- */
127
- type SwapStage = "withdrawing" | "withdrawn" | "quoting" | "approving" | "signing" | "swapping" | "swapped" | "depositing" | "refunding" | "refunded";
128
- /**
129
- * Which way the funds travel, which decides what each side may be.
130
- *
131
- * On a `deposit` the source is any wallet asset and the destination must be
132
- * depositable. On a `withdraw` that reverses, and the destination widens to
133
- * anything the wallet can receive — native ETH and USDT included. The routing
134
- * API enforces both, so this has to be stated rather than inferred.
135
- */
136
- type SwapDirection = "deposit" | "withdraw";
137
- type SwapQuoteParams = {
138
- /** Asset being spent: a wallet asset on a deposit, an Owney asset on a withdrawal. */
139
- from: {
140
- chainId: number;
141
- symbol: string;
142
- amount: string;
143
- };
144
- /** Asset being received: a deposit target on a deposit, any wallet asset on a withdrawal. */
145
- to: {
146
- chainId: number;
147
- symbol: string;
148
- };
149
- /** Defaults to `deposit`. */
150
- direction?: SwapDirection;
151
- };
152
-
153
4
  type ZyfaiRpcUrlsConfig = Partial<Record<(typeof SUPPORTED_CHAIN_IDS)[number], string>>;
154
5
  interface OwneySDKConfig {
155
6
  apiKey: string;
@@ -158,6 +9,10 @@ interface OwneySDKConfig {
158
9
  * Example: { 8453: "https://...", 42161: "https://..." }
159
10
  */
160
11
  zyfaiRpcUrls?: ZyfaiRpcUrlsConfig;
12
+ /** Optional Owney Yieldseeker proxy base URL override for integration tests. */
13
+ yieldseekerApiBaseUrl?: string;
14
+ /** Optional SIWE origin override. Defaults to the requesting browser origin. */
15
+ yieldseekerSiweOrigin?: string;
161
16
  /**
162
17
  * Optional override for the Owney routing API base URL used by all routing
163
18
  * calls (defaults to the OWNEY_ROUTING_API_BASE_URL env var, then the
@@ -204,7 +59,7 @@ type OwneySupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
204
59
  type OwneySupportedChains = (typeof SUPPORTED_CHAINS)[number];
205
60
  type OwneySupportedTokens = (typeof SUPPORTED_TOKENS)[number];
206
61
 
207
- type AgentId = "zyfai";
62
+ type AgentId = "zyfai" | "yieldseeker";
208
63
  type Asset = string;
209
64
  type AgentSupportedAsset = {
210
65
  readonly symbol: string;
@@ -382,6 +237,8 @@ interface OwneyPosition {
382
237
  pool?: string;
383
238
  asset: string;
384
239
  amount: string;
240
+ /** Smallest-unit amount when the provider exposes it alongside `amount`. */
241
+ amountRaw?: string;
385
242
  apy?: number;
386
243
  tvl?: number;
387
244
  /** Pool liquidity. Prepared slot — Zyfai will add this to its portfolio
@@ -412,10 +269,19 @@ interface OwneyPendingAllocation {
412
269
  since?: string;
413
270
  }
414
271
  interface AgentBalance {
272
+ /** Authoritative native balances per asset/network, including idle and invested funds. */
273
+ assetBalances?: OwneyToken[];
415
274
  smartWallet?: `0x${string}`;
416
275
  totalBalance: string;
417
276
  /** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
418
277
  totalBalanceAsset: string;
278
+ /**
279
+ * Describes whether `tokens` already includes deployed `positions`.
280
+ * Consumers must add matching positions only for `tokens-plus-positions`;
281
+ * doing so for Zyfai would double-count, while omitting it for Yieldseeker
282
+ * makes its balance disappear as soon as idle funds enter a vault.
283
+ */
284
+ balanceComposition?: "tokens-include-positions" | "tokens-plus-positions";
419
285
  tokens: OwneyToken[];
420
286
  /**
421
287
  * Per-protocol/pool positions when the agent's portfolio payload includes
@@ -430,10 +296,14 @@ interface OwneyBalances {
430
296
  /** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
431
297
  totalBalanceAsset: string;
432
298
  agentBalances: Record<AgentId, AgentBalance>;
433
- /** Omitted agents failed to load; they must not be interpreted as zero. */
434
- agentErrors?: Record<AgentId, string>;
299
+ /**
300
+ * Per-agent read failures when an aggregate balance request returned only a
301
+ * partial result. Callers may display the successful balances, but funding
302
+ * operations must not interpret a missing agent as having a zero balance.
303
+ */
304
+ agentErrors?: Partial<Record<AgentId, string>>;
435
305
  /** Absolute provider cooldown deadlines (Unix milliseconds). */
436
- agentRetryAt?: Record<AgentId, number>;
306
+ agentRetryAt?: Partial<Record<AgentId, number>>;
437
307
  }
438
308
  interface AgentEarnings {
439
309
  smartWallet: `0x${string}`;
@@ -606,8 +476,15 @@ interface IAgent {
606
476
  readonly id: string;
607
477
  readonly supportedChainIds: readonly OwneySupportedChainId[];
608
478
  readonly supportedAssets: readonly AgentSupportedAssets[];
479
+ /**
480
+ * Describes how `AgentBalance.tokens` relates to `positions`.
481
+ * Most adapters expose token totals that already include deployed positions.
482
+ * Providers such as Yieldseeker expose idle wallet tokens separately, so
483
+ * withdrawal planning must add matching position amounts.
484
+ */
485
+ readonly balanceComposition?: "tokens-include-positions" | "tokens-plus-positions";
609
486
  disconnect(): Promise<void>;
610
- activateAgent(state: ConnectionState, chainId: number): Promise<void>;
487
+ activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
611
488
  /**
612
489
  * Apply the organization's agent policy to this user's account.
613
490
  *
@@ -678,6 +555,8 @@ declare class OwneySDK {
678
555
  private orgAgentConfig;
679
556
  private orgAgentConfigPromise;
680
557
  private zyfaiRpcUrls?;
558
+ private yieldseekerApiBaseUrl?;
559
+ private yieldseekerSiweOrigin?;
681
560
  private routingApiBaseUrl?;
682
561
  private referralSource?;
683
562
  private cachedSponsoredCallback;
@@ -714,25 +593,15 @@ declare class OwneySDK {
714
593
  private requireState;
715
594
  private requireChainId;
716
595
  private requireConnectedProvider;
717
- /**
718
- * Lazily builds (and caches) the default EIP-3009 sponsored deposit callback
719
- * used when the caller omits `depositCallback`. Wraps the connected EIP-1193
720
- * provider with viem `custom(provider)` to read token meta and sign the
721
- * `TransferWithAuthorization`, then POSTs to the sponsor API.
722
- */
596
+ /** Builds the default USDC batch callback for the connected wallet. */
723
597
  private getDefaultSponsoredCallback;
724
- /**
725
- * Lazily builds (and caches) the default Permit2 sponsored WETH deposit
726
- * callback used when the caller omits `depositCallback` for a WETH
727
- * deposit. Mirrors `getDefaultSponsoredCallback()` but signs a Permit2
728
- * `PermitTransferFrom` instead of an EIP-3009 authorization.
729
- */
598
+ /** Builds the wallet-native sponsored calls callback for compatible paymasters. */
730
599
  private getDefaultSponsoredCallsCallback;
731
600
  /**
732
601
  * Lazily builds (and caches) the default Permit2 sponsored WETH deposit
733
602
  * callback used when the caller omits `depositCallback` for a WETH deposit.
734
603
  * Mirrors `getDefaultSponsoredCallback()` but signs a Permit2
735
- * `PermitTransferFrom` instead of an EIP-3009 authorization.
604
+ * single-use batch authorization instead of an EIP-3009 authorization.
736
605
  */
737
606
  private getDefaultWethSponsoredCallback;
738
607
  private getAgent;
@@ -768,7 +637,8 @@ declare class OwneySDK {
768
637
  * If provided, ALL specified agents must support the chainId or the call
769
638
  * throws before activating any agent.
770
639
  */
771
- activateAgent(chainId: number, agentId?: AgentId[]): Promise<void>;
640
+ activateAgent(chainId: number, agentId?: AgentId[], asset?: OwneySupportedTokens): Promise<void>;
641
+ private assertActivationSession;
772
642
  /**
773
643
  * Activate agents ONE AT A TIME, each followed by its org policy.
774
644
  *
@@ -782,10 +652,9 @@ declare class OwneySDK {
782
652
  * Serializing costs no real wall-clock: the user can only approve one prompt
783
653
  * at a time anyway.
784
654
  *
785
- * Every agent is attempted even if an earlier one fails, so one declined
786
- * signature can't deny the remaining agents their turn. The first failure is
787
- * rethrown (matching the previous `Promise.all` rejection) once all agents
788
- * have had a chance to activate.
655
+ * Stop at the first failure so a canceled sign-in does not open another
656
+ * agent's wallet prompt. Report any earlier successes for diagnostics; the
657
+ * app discards the session when the complete sign-in does not succeed.
789
658
  */
790
659
  private activateAgentsInTurn;
791
660
  /**
@@ -796,7 +665,8 @@ declare class OwneySDK {
796
665
  * @param options.asset - Asset symbol to deposit (e.g. "USDC")
797
666
  * @param options.depositCallback - Callback that performs the token transfer and returns a tx hash.
798
667
  * When agentId is omitted, this callback is invoked once per eligible agent with that agent's
799
- * split amount and smart wallet address — expect multiple wallet prompts.
668
+ * split amount and smart wallet address. Default sponsored deposits batch
669
+ * all shares into one signature; custom callbacks still run once per agent.
800
670
  * @param options.agentId - Optional explicit target. Otherwise split equally,
801
671
  * or fund remaining agents when a recovery deposit cannot meet every minimum.
802
672
  * @returns {OwneyDepositResult} for a single agent, or {OwneyMultiDepositResult} with per-agent results
@@ -808,7 +678,7 @@ declare class OwneySDK {
808
678
  *
809
679
  * 1. Missing Permit2 allowance: when the app did not supply its own
810
680
  * callback and the attempt fails with `PERMIT2_APPROVAL_REQUIRED` on a
811
- * WETH deposit, this is the wallet's first gasless WETH deposit. We send
681
+ * token deposit, this is the wallet's first Permit2 deposit for that token. We send
812
682
  * the one-time (user-paid) Permit2 approval via `approvePermit2()` and
813
683
  * retry the SAME sponsored attempt once. Bounded to one approval attempt
814
684
  * per call so a wallet/agent that keeps reporting the allowance as
@@ -830,6 +700,7 @@ declare class OwneySDK {
830
700
  private depositWithFallback;
831
701
  private getMinDepositAmount;
832
702
  private splitDepositAmount;
703
+ private formatAgentName;
833
704
  private validateMinDepositAmount;
834
705
  /**
835
706
  * Whether the user already holds a non-zero balance with `agent` for the
@@ -840,137 +711,6 @@ declare class OwneySDK {
840
711
  private hasExistingBalance;
841
712
  private validateAssetSupport;
842
713
  private getEligibleAgents;
843
- /** Lazily built so an app that never swaps pays nothing for it. */
844
- private swapApiClient?;
845
- private swapApi;
846
- /**
847
- * Put the wallet on `chainId`, or fail with something actionable.
848
- *
849
- * Reuses the same guard the deposit rail uses, which re-reads the chain after
850
- * switching — some wallets resolve wallet_switchEthereumChain before the
851
- * network has actually changed.
852
- */
853
- private ensureSwapChain;
854
- /**
855
- * Binds the executor's abstract deps to this client's wallet.
856
- *
857
- * Kept as a builder rather than baked into the executor so the whole swap
858
- * flow stays testable without a provider — the executor never imports viem.
859
- */
860
- private buildSwapDeps;
861
- /**
862
- * Assets the user may pay with, and what each chain deposits into.
863
- *
864
- * The source list is deliberately wider than the deposit list: it includes
865
- * native ETH and USDT, which Owney never holds but users often do.
866
- */
867
- getSwapTokens(): Promise<{
868
- chains: SwapChainTokens[];
869
- }>;
870
- /**
871
- * Price a swap without committing to it.
872
- *
873
- * `dstAmountMin` is the number to validate against a deposit minimum —
874
- * `dst.amount` is an estimate that a decaying auction or slippage can undercut,
875
- * and a swap landing below the floor leaves the user swapped but not
876
- * deposited.
877
- */
878
- getSwapQuote(params: SwapQuoteParams): Promise<SwapQuote>;
879
- /**
880
- * Swap an asset the user holds into a deposit asset, then deposit it.
881
- *
882
- * Kept separate from `deposit()` rather than bolted on as an option: the
883
- * return shape differs, the staging callback is meaningless on the plain
884
- * path, and integrators who never swap should not have to reason about any
885
- * of it.
886
- *
887
- * The deposit runs on the MEASURED arrival, not the quote. A quote is an
888
- * estimate, so depositing the quoted figure would either strand dust or try
889
- * to move funds that never came.
890
- *
891
- * Failure modes differ in a way callers must respect. A same-chain swap is
892
- * atomic — if it fails, nothing moved. A cross-chain swap escrows the user's
893
- * funds first, so SWAP_ORDER_EXPIRED / REFUNDED / CANCELLED all mean the
894
- * money left the wallet. Only the former can honestly say "nothing has left
895
- * your wallet".
896
- */
897
- swapAndDeposit(options: {
898
- from: {
899
- chainId: number;
900
- symbol: string;
901
- amount: string;
902
- };
903
- /** Deposit target. Defaults to the active chain's asset when omitted. */
904
- to: {
905
- chainId: number;
906
- symbol: string;
907
- };
908
- agentId?: AgentId;
909
- /** Percent, classic rail only. Fusion+ prices through its auction. */
910
- slippage?: number;
911
- onSwapProgress?: (stage: SwapStage) => void;
912
- }): Promise<{
913
- swap: {
914
- received: string;
915
- orderHash?: string;
916
- txHash?: string;
917
- };
918
- deposit: OwneyDepositResult | OwneyMultiDepositResult;
919
- }>;
920
- /**
921
- * Withdraw from an agent and swap the proceeds into whatever the user wants
922
- * to hold, delivered to their own wallet.
923
- *
924
- * The mirror of `swapAndDeposit()`, with one structural difference that
925
- * drives the whole implementation: a deposit swap starts from funds already
926
- * sitting in the wallet, but a withdrawal has to wait for them. The agent's
927
- * provider acknowledges a withdrawal and *then* queues the on-chain transfer
928
- * to the EOA, so `withdraw()` resolving means "accepted", not "arrived".
929
- * Quoting before the tokens land would size the swap against a balance that
930
- * is not there yet.
931
- *
932
- * The swap is therefore sized from the MEASURED arrival, exactly as the
933
- * deposit path sizes its deposit from the measured swap output. On a full
934
- * withdrawal there is no other number available — "MAX" has no figure until
935
- * the agent picks one.
936
- *
937
- * **Failure here is not symmetrical with the deposit path.** A failed
938
- * deposit-swap leaves the user holding what they started with. A failed
939
- * withdrawal-swap leaves them holding the AGENT'S asset in their own wallet:
940
- * the money is out, safe, and in the wrong denomination. Both
941
- * `WITHDRAW_ARRIVAL_TIMEOUT` and `WITHDRAW_SWAP_FAILED` carry `withdrawn` for
942
- * that reason — the UI has to tell the user where their money actually is,
943
- * and must never present either as a lost withdrawal.
944
- */
945
- withdrawAndSwap(options: {
946
- /** The agent's asset. Must be on the active chain. */
947
- from: {
948
- chainId: number;
949
- symbol: string;
950
- };
951
- /** What to deliver to the wallet. Any swappable asset, including native ETH. */
952
- to: {
953
- chainId: number;
954
- symbol: string;
955
- };
956
- /** Human units ("10.5"). Omit to withdraw the full agent balance. */
957
- amount?: string;
958
- agentId?: AgentId;
959
- /** Percent, classic rail only. Fusion+ prices through its auction. */
960
- slippage?: number;
961
- onSwapProgress?: (stage: SwapStage) => void;
962
- /** How long to wait for the withdrawal to land before giving up on the swap. */
963
- arrivalTimeoutMs?: number;
964
- }): Promise<{
965
- withdraw: OwneyWithdrawResult | AgentWithdrawResult;
966
- /** What actually arrived in the wallet, smallest unit of the agent's asset. */
967
- withdrawn: string;
968
- swap: {
969
- received: string;
970
- orderHash?: string;
971
- txHash?: string;
972
- };
973
- }>;
974
714
  /**
975
715
  * Withdraw funds from a specific agent, or all agents that support the active chain+asset if agentId is omitted.
976
716
  * Validates that the asset is supported by the target agent(s) on the active chain.
@@ -1052,14 +792,15 @@ declare class OwneySDK {
1052
792
  */
1053
793
  ensureAutoSelectProtocols(asset: "USDC" | "WETH", agentId?: AgentId): Promise<boolean>;
1054
794
  /**
1055
- * One-time, user-paid approval of Permit2 on the sponsored WETH token for
1056
- * the active chain. Required once per wallet per chain before gasless WETH
1057
- * deposits; afterwards deposit() is signature-only. Resolves only after the
1058
- * approval transaction is mined (1 confirmation), so a subsequent deposit()
1059
- * will see the new allowance; throws if the transaction reverted.
795
+ * User-paid approval of Permit2 on the selected token for the active chain.
796
+ * Grants the maximum ERC20 allowance so later deposits do not require another
797
+ * approval. Resolves after one confirmation so the subsequent deposit attempt
798
+ * sees the new allowance.
799
+ *
800
+ * @param requiredAmount Raw base-unit amount the pending deposit must cover.
1060
801
  * @returns the approval transaction hash.
1061
802
  */
1062
- approvePermit2(asset?: "WETH"): Promise<`0x${string}`>;
803
+ approvePermit2(asset?: OwneySupportedTokens, requiredAmount?: bigint): Promise<`0x${string}`>;
1063
804
  /**
1064
805
  * Get the agent's average APY performance over a time period. Does not require a wallet connection.
1065
806
  * @param options - Contains agentId (optional) and days ("7D", "14D", or "30D")
@@ -1083,7 +824,96 @@ declare class OwneySDK {
1083
824
  getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
1084
825
  }
1085
826
 
1086
- 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_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_ORDER_EXPIRED" | "SWAP_ORDER_REFUNDED" | "SWAP_ORDER_CANCELLED" | "WITHDRAW_ARRIVAL_TIMEOUT" | "WITHDRAW_SWAP_FAILED" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
827
+ type YieldseekerAuthDependencies = {
828
+ origin?: string;
829
+ now?: () => Date;
830
+ nonce?: () => string;
831
+ };
832
+
833
+ type YieldseekerFetch = typeof fetch;
834
+
835
+ type YieldseekerTransaction = {
836
+ from: `0x${string}`;
837
+ to: `0x${string}`;
838
+ data: `0x${string}`;
839
+ value: string;
840
+ chainId: number;
841
+ };
842
+
843
+ type YieldseekerAgentOptions = {
844
+ baseUrl?: string;
845
+ fetchFn?: YieldseekerFetch;
846
+ auth?: YieldseekerAuthDependencies;
847
+ /** Test seam for the wallet-submission/receipt boundary. */
848
+ transactionExecutor?: (state: ConnectionState, chainId: number, transaction: YieldseekerTransaction) => Promise<Hex>;
849
+ /** Test seam for transactions submitted outside transactionExecutor. */
850
+ unwindReceiptWaiter?: (state: ConnectionState, chainId: number, transactionHash: Hex) => Promise<void>;
851
+ };
852
+ declare class YieldseekerAgent implements IAgent {
853
+ readonly id = "yieldseeker";
854
+ readonly balanceComposition: "tokens-plus-positions";
855
+ readonly supportedChainIds: readonly [8453];
856
+ readonly supportedAssets: readonly [{
857
+ readonly chainId: 8453;
858
+ readonly chain: "BASE";
859
+ readonly assets: readonly [{
860
+ readonly symbol: "USDC";
861
+ readonly minDepositAmount: "10000000";
862
+ }, {
863
+ readonly symbol: "WETH";
864
+ readonly minDepositAmount: "1";
865
+ }];
866
+ }];
867
+ private readonly api;
868
+ private readonly auth;
869
+ private readonly transactionExecutor?;
870
+ private readonly unwindReceiptWaiter?;
871
+ private readonly agentContexts;
872
+ private readonly users;
873
+ private readonly pendingAgents;
874
+ private readonly yieldOptions;
875
+ private readonly pendingYieldOptions;
876
+ constructor(owneyApiKey: string, options?: YieldseekerAgentOptions);
877
+ disconnect(): Promise<void>;
878
+ activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
879
+ deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
880
+ withdraw(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, amount?: string): Promise<AgentWithdrawResult>;
881
+ getBalances(state: ConnectionState, chainId: number): Promise<AgentBalance>;
882
+ getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
883
+ getAccountApy(state: ConnectionState, chainId: number, days: DailyApyDays, tokenSymbol?: string): Promise<AccountAgentApy>;
884
+ getHistory(state: ConnectionState, chainId: number, options?: HistoryFilters): Promise<OwneyAgentHistory>;
885
+ getUserProfile(state: ConnectionState, chainId: number): Promise<AgentUserProfile>;
886
+ getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
887
+ private loadYieldOptions;
888
+ private userKey;
889
+ private contextKey;
890
+ private resolveUser;
891
+ private forgetUser;
892
+ private ensureAgent;
893
+ private findAgent;
894
+ private resolveAgent;
895
+ private loadPortfolio;
896
+ private loadPortfolioContext;
897
+ private deployAgent;
898
+ private refreshSnapshotAfterMovement;
899
+ private agentPath;
900
+ private walletRequest;
901
+ private providerRequest;
902
+ private mapApiError;
903
+ private submitTransaction;
904
+ private waitForReceipt;
905
+ private assertTransaction;
906
+ private assertAgent;
907
+ private isOwneyAgent;
908
+ private assetForAgent;
909
+ private isTransactionHash;
910
+ private assertChain;
911
+ private assertOptionalChain;
912
+ private assertAsset;
913
+ private invalidResponse;
914
+ }
915
+
916
+ 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_AMOUNT_BELOW_MINIMUM" | "DEPOSIT_CALLBACK_REQUIRED" | "DEPOSIT_CALLBACK_INVALID" | "DEPOSIT_NO_PERMITTED_TOKENS" | "DEPOSIT_INSUFFICIENT_BALANCE" | "WITHDRAW_NO_PERMITTED_TOKENS" | "WITHDRAW_BALANCE_UNAVAILABLE" | "WITHDRAW_INSUFFICIENT_BALANCE" | "WITHDRAW_ALL_FAILED" | "WITHDRAW_PARTIAL_FAILURE" | "WITHDRAW_FAILED" | "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" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
1087
917
  declare class OwneyError extends Error {
1088
918
  readonly code: OwneyErrorCode;
1089
919
  readonly details?: Record<string, unknown>;
@@ -1149,40 +979,4 @@ type OwneySIWXConfig = {
1149
979
  */
1150
980
  declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
1151
981
 
1152
- /**
1153
- * Persists cross-chain swap secrets so an in-flight order survives a reload.
1154
- *
1155
- * This is not a convenience. A Fusion+ order is only completable by whoever
1156
- * holds the secret preimages: the resolver deploys escrows, then waits for the
1157
- * secret before it can claim and release funds to the user. Lose the secrets
1158
- * mid-order and the swap cannot complete — the user waits out the cancellation
1159
- * timelock for a refund instead.
1160
- *
1161
- * That matters here because the UI explicitly tells the user "you can safely
1162
- * close this window", so surviving a reload is a requirement, not a nicety.
1163
- *
1164
- * Trade-off: the same one `zyfai.auth-cache` makes. Secrets in `localStorage`
1165
- * are exposed to XSS, but they are single-use, worthless once the order
1166
- * settles, and only ever unlock funds back to the user's own wallet.
1167
- */
1168
- type StoredOrder = {
1169
- orderHash: string;
1170
- /** Preimages, one per fill. Index matters — fill N needs secret N. */
1171
- secrets: string[];
1172
- /** Chain the funds left from, so a resumed session can report it. */
1173
- srcChainId: number;
1174
- /** For the resumed UI: what the user was paying with and expecting. */
1175
- srcSymbol: string;
1176
- dstSymbol: string;
1177
- dstChainId: number;
1178
- amount: string;
1179
- /** Epoch ms. Used to drop orders far past any plausible timelock. */
1180
- createdAt: number;
1181
- };
1182
- /**
1183
- * Every stored order, newest first, dropping anything past MAX_AGE_MS.
1184
- * Used on mount to resume orders the user left in flight.
1185
- */
1186
- declare function listOrders(now?: number): StoredOrder[];
1187
-
1188
- export { type AccountAgentApy, type AccountApyOptions, type AccountDailyEarnings, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentHistoryEntry, type AgentHistoryPosition, type AgentId, AgentNotFoundError, type AgentSupportedAsset, type AgentSupportedAssets, type AgentUserProfile, type AgentWithdrawResult, type AgentsApyOptions, type AllocationAgentApy, type AllocationApyOptions, type ApyByChainAndAsset, type ApyHistoryPoint, type Asset, type AssetDailyEarnings, type AvailableAgent, type AvailableAgentsOptions, type ConnectionState, type DailyApyDays, type DailyEarningsOptions, type DailyEarningsPoint, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, type LookbackDays, NotConnectedError, type OwneyAccountApy, type OwneyAgentApy, type OwneyAgentHistory, type OwneyAllocationApy, type OwneyBalances, type OwneyDepositResult, type OwneyEarnings, OwneyError, type OwneyErrorCode, type OwneyMultiDepositResult, type OwneyPosition, OwneySDK, type OwneySDKConfig, type OwneySIWXConfig, type OwneySupportedChainId, type OwneySupportedChains, type OwneySupportedTokens, type OwneyToken, type OwneyUserProfile, type OwneyWithdrawResult, type RebalanceLog, type SwapChainTokens, type SwapDirection, type SwapOrderStatus, type SwapQuote, type SwapQuoteParams, type SwapRail, type SwapStage, type SwapTokenInfo, type WithdrawOptions, createOwneySIWX, listOrders as listPendingSwaps, setOwneyDebug };
982
+ export { type AccountAgentApy, type AccountApyOptions, type AccountDailyEarnings, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentHistoryEntry, type AgentHistoryPosition, type AgentId, AgentNotFoundError, type AgentSupportedAsset, type AgentSupportedAssets, type AgentUserProfile, type AgentWithdrawResult, type AgentsApyOptions, type AllocationAgentApy, type AllocationApyOptions, type ApyByChainAndAsset, type ApyHistoryPoint, type Asset, type AssetDailyEarnings, type AvailableAgent, type AvailableAgentsOptions, type ConnectionState, type DailyApyDays, type DailyEarningsOptions, type DailyEarningsPoint, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, type LookbackDays, NotConnectedError, type OwneyAccountApy, type OwneyAgentApy, type OwneyAgentHistory, type OwneyAllocationApy, type OwneyBalances, type OwneyDepositResult, type OwneyEarnings, OwneyError, type OwneyErrorCode, type OwneyMultiDepositResult, type OwneyPosition, OwneySDK, type OwneySDKConfig, type OwneySIWXConfig, type OwneySupportedChainId, type OwneySupportedChains, type OwneySupportedTokens, type OwneyToken, type OwneyUserProfile, type OwneyWithdrawResult, type RebalanceLog, type WithdrawOptions, YieldseekerAgent, createOwneySIWX, setOwneyDebug };