@owney/sdk 0.7.21-beta.3 → 0.7.22-beta.1

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,4 +1,3 @@
1
- import { Hex } from 'viem';
2
1
  import { SIWXConfig } from '@reown/appkit-controllers';
3
2
 
4
3
  type ZyfaiRpcUrlsConfig = Partial<Record<(typeof SUPPORTED_CHAIN_IDS)[number], string>>;
@@ -9,10 +8,6 @@ interface OwneySDKConfig {
9
8
  * Example: { 8453: "https://...", 42161: "https://..." }
10
9
  */
11
10
  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;
16
11
  /**
17
12
  * Optional override for the Owney routing API base URL used by all routing
18
13
  * calls (defaults to the OWNEY_ROUTING_API_BASE_URL env var, then the
@@ -59,7 +54,7 @@ type OwneySupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
59
54
  type OwneySupportedChains = (typeof SUPPORTED_CHAINS)[number];
60
55
  type OwneySupportedTokens = (typeof SUPPORTED_TOKENS)[number];
61
56
 
62
- type AgentId = "zyfai" | "yieldseeker";
57
+ type AgentId = "zyfai" | "surfliquid";
63
58
  type Asset = string;
64
59
  type AgentSupportedAsset = {
65
60
  readonly symbol: string;
@@ -187,6 +182,12 @@ interface OwneyDepositResult {
187
182
  }
188
183
  interface OwneyMultiDepositResult {
189
184
  agentResults: Record<string, OwneyDepositResult>;
185
+ /**
186
+ * Per-agent failure messages for agents that errored during a diversified
187
+ * deposit. Present only when at least one (but not all) agents failed —
188
+ * the deposit is partial, not total. Omitted when every agent succeeded.
189
+ */
190
+ agentErrors?: Record<string, string>;
190
191
  }
191
192
  interface AgentWithdrawResult {
192
193
  txHash?: string;
@@ -216,8 +217,6 @@ interface OwneyPosition {
216
217
  pool?: string;
217
218
  asset: string;
218
219
  amount: string;
219
- /** Smallest-unit amount when the provider exposes it alongside `amount`. */
220
- amountRaw?: string;
221
220
  apy?: number;
222
221
  tvl?: number;
223
222
  /** Pool liquidity. Prepared slot — Zyfai will add this to its portfolio
@@ -248,19 +247,10 @@ interface OwneyPendingAllocation {
248
247
  since?: string;
249
248
  }
250
249
  interface AgentBalance {
251
- /** Authoritative native balances per asset/network, including idle and invested funds. */
252
- assetBalances?: OwneyToken[];
253
250
  smartWallet?: `0x${string}`;
254
251
  totalBalance: string;
255
252
  /** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
256
253
  totalBalanceAsset: string;
257
- /**
258
- * Describes whether `tokens` already includes deployed `positions`.
259
- * Consumers must add matching positions only for `tokens-plus-positions`;
260
- * doing so for Zyfai would double-count, while omitting it for Yieldseeker
261
- * makes its balance disappear as soon as idle funds enter a vault.
262
- */
263
- balanceComposition?: "tokens-include-positions" | "tokens-plus-positions";
264
254
  tokens: OwneyToken[];
265
255
  /**
266
256
  * Per-protocol/pool positions when the agent's portfolio payload includes
@@ -275,14 +265,10 @@ interface OwneyBalances {
275
265
  /** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
276
266
  totalBalanceAsset: string;
277
267
  agentBalances: Record<AgentId, AgentBalance>;
278
- /**
279
- * Per-agent read failures when an aggregate balance request returned only a
280
- * partial result. Callers may display the successful balances, but funding
281
- * operations must not interpret a missing agent as having a zero balance.
282
- */
283
- agentErrors?: Partial<Record<AgentId, string>>;
268
+ /** Omitted agents failed to load; they must not be interpreted as zero. */
269
+ agentErrors?: Record<AgentId, string>;
284
270
  /** Absolute provider cooldown deadlines (Unix milliseconds). */
285
- agentRetryAt?: Partial<Record<AgentId, number>>;
271
+ agentRetryAt?: Record<AgentId, number>;
286
272
  }
287
273
  interface AgentEarnings {
288
274
  smartWallet: `0x${string}`;
@@ -421,15 +407,8 @@ interface IAgent {
421
407
  readonly id: string;
422
408
  readonly supportedChainIds: readonly OwneySupportedChainId[];
423
409
  readonly supportedAssets: readonly AgentSupportedAssets[];
424
- /**
425
- * Describes how `AgentBalance.tokens` relates to `positions`.
426
- * Most adapters expose token totals that already include deployed positions.
427
- * Providers such as Yieldseeker expose idle wallet tokens separately, so
428
- * withdrawal planning must add matching position amounts.
429
- */
430
- readonly balanceComposition?: "tokens-include-positions" | "tokens-plus-positions";
431
410
  disconnect(): Promise<void>;
432
- activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
411
+ activateAgent(state: ConnectionState, chainId: number): Promise<void>;
433
412
  /**
434
413
  * Apply the organization's agent policy to this user's account.
435
414
  *
@@ -494,8 +473,6 @@ declare class OwneySDK {
494
473
  private orgAgentConfig;
495
474
  private orgAgentConfigPromise;
496
475
  private zyfaiRpcUrls?;
497
- private yieldseekerApiBaseUrl?;
498
- private yieldseekerSiweOrigin?;
499
476
  private routingApiBaseUrl?;
500
477
  private referralSource?;
501
478
  private cachedSponsoredCallback;
@@ -586,8 +563,7 @@ declare class OwneySDK {
586
563
  * If provided, ALL specified agents must support the chainId or the call
587
564
  * throws before activating any agent.
588
565
  */
589
- activateAgent(chainId: number, agentId?: AgentId[], asset?: OwneySupportedTokens): Promise<void>;
590
- private assertActivationSession;
566
+ activateAgent(chainId: number, agentId?: AgentId[]): Promise<void>;
591
567
  /**
592
568
  * Activate agents ONE AT A TIME, each followed by its org policy.
593
569
  *
@@ -602,9 +578,9 @@ declare class OwneySDK {
602
578
  * at a time anyway.
603
579
  *
604
580
  * Every agent is attempted even if an earlier one fails, so one declined
605
- * signature can't deny the remaining agents their turn. Once all agents have
606
- * had a chance, a partial failure identifies the agents that still need a
607
- * retry; if none activated, the original provider error is preserved.
581
+ * signature can't deny the remaining agents their turn. The first failure is
582
+ * rethrown (matching the previous `Promise.all` rejection) once all agents
583
+ * have had a chance to activate.
608
584
  */
609
585
  private activateAgentsInTurn;
610
586
  /**
@@ -649,7 +625,6 @@ declare class OwneySDK {
649
625
  private depositWithFallback;
650
626
  private getMinDepositAmount;
651
627
  private splitDepositAmount;
652
- private formatAgentName;
653
628
  private validateMinDepositAmount;
654
629
  /**
655
630
  * Whether the user already holds a non-zero balance with `agent` for the
@@ -660,6 +635,17 @@ declare class OwneySDK {
660
635
  private hasExistingBalance;
661
636
  private validateAssetSupport;
662
637
  private getEligibleAgents;
638
+ /**
639
+ * Agent ids the routing API provisioned for this org that support the given
640
+ * chain + asset, ordered by preference ({@link AGENT_ELIGIBILITY_ORDER},
641
+ * surfliquid first). Returns `[]` when the org has no compatible agent — never
642
+ * throws on an empty org. Loads agent keys on first call (apiKey only, no
643
+ * wallet), so the UI can resolve which agent to use before the user connects.
644
+ *
645
+ * This is the source of truth for agent availability: an agent appears here
646
+ * iff the routing API returned its key. No per-app feature flags.
647
+ */
648
+ getEligibleAgentIds(chainId: number, asset: string): Promise<AgentId[]>;
663
649
  /**
664
650
  * Withdraw funds from a specific agent, or all agents that support the active chain+asset if agentId is omitted.
665
651
  * Validates that the asset is supported by the target agent(s) on the active chain.
@@ -760,93 +746,7 @@ declare class OwneySDK {
760
746
  getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
761
747
  }
762
748
 
763
- type YieldseekerAuthDependencies = {
764
- origin?: string;
765
- now?: () => Date;
766
- nonce?: () => string;
767
- };
768
-
769
- type YieldseekerFetch = typeof fetch;
770
-
771
- type YieldseekerTransaction = {
772
- from: `0x${string}`;
773
- to: `0x${string}`;
774
- data: `0x${string}`;
775
- value: string;
776
- chainId: number;
777
- };
778
-
779
- type YieldseekerAgentOptions = {
780
- baseUrl?: string;
781
- fetchFn?: YieldseekerFetch;
782
- auth?: YieldseekerAuthDependencies;
783
- /** Test seam for the wallet-submission/receipt boundary. */
784
- transactionExecutor?: (state: ConnectionState, chainId: number, transaction: YieldseekerTransaction) => Promise<Hex>;
785
- /** Test seam for transactions submitted outside transactionExecutor. */
786
- unwindReceiptWaiter?: (state: ConnectionState, chainId: number, transactionHash: Hex) => Promise<void>;
787
- };
788
- declare class YieldseekerAgent implements IAgent {
789
- readonly id = "yieldseeker";
790
- readonly balanceComposition: "tokens-plus-positions";
791
- readonly supportedChainIds: readonly [8453];
792
- readonly supportedAssets: readonly [{
793
- readonly chainId: 8453;
794
- readonly chain: "BASE";
795
- readonly assets: readonly [{
796
- readonly symbol: "USDC";
797
- readonly minDepositAmount: "10000000";
798
- }, {
799
- readonly symbol: "WETH";
800
- readonly minDepositAmount: "1";
801
- }];
802
- }];
803
- private readonly api;
804
- private readonly auth;
805
- private readonly transactionExecutor?;
806
- private readonly unwindReceiptWaiter?;
807
- private readonly agentContexts;
808
- private readonly users;
809
- private readonly pendingAgents;
810
- constructor(owneyApiKey: string, options?: YieldseekerAgentOptions);
811
- disconnect(): Promise<void>;
812
- activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
813
- deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
814
- withdraw(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, amount?: string): Promise<AgentWithdrawResult>;
815
- getBalances(state: ConnectionState, chainId: number): Promise<AgentBalance>;
816
- getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
817
- getAccountApy(state: ConnectionState, chainId: number, days: DailyApyDays, tokenSymbol?: string): Promise<AccountAgentApy>;
818
- getHistory(state: ConnectionState, chainId: number, options?: HistoryFilters): Promise<OwneyAgentHistory>;
819
- getUserProfile(state: ConnectionState, chainId: number): Promise<AgentUserProfile>;
820
- getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
821
- private userKey;
822
- private contextKey;
823
- private resolveUser;
824
- private forgetUser;
825
- private ensureAgent;
826
- private findAgent;
827
- private resolveAgent;
828
- private loadPortfolio;
829
- private loadPortfolioContext;
830
- private deployAfterFunding;
831
- private refreshSnapshotAfterMovement;
832
- private agentPath;
833
- private walletRequest;
834
- private providerRequest;
835
- private mapApiError;
836
- private submitTransaction;
837
- private waitForReceipt;
838
- private assertTransaction;
839
- private assertAgent;
840
- private isOwneyAgent;
841
- private assetForAgent;
842
- private isTransactionHash;
843
- private assertChain;
844
- private assertOptionalChain;
845
- private assertAsset;
846
- private invalidResponse;
847
- }
848
-
849
- 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";
749
+ 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_ALL_FAILED" | "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" | "SURF_UNAVAILABLE" | "SPONSORSHIP_UNAVAILABLE" | "USER_REJECTED" | "OPERATION_PENDING" | "VAULT_NOT_SPONSORABLE" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
850
750
  declare class OwneyError extends Error {
851
751
  readonly code: OwneyErrorCode;
852
752
  readonly details?: Record<string, unknown>;
@@ -912,4 +812,4 @@ type OwneySIWXConfig = {
912
812
  */
913
813
  declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
914
814
 
915
- export { type AccountAgentApy, type AccountApyOptions, 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 AvailableAgent, type AvailableAgentsOptions, type ConnectionState, type DailyApyDays, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, 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 };
815
+ export { type AccountAgentApy, type AccountApyOptions, 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 AvailableAgent, type AvailableAgentsOptions, type ConnectionState, type DailyApyDays, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, 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, createOwneySIWX, setOwneyDebug };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { Hex } from 'viem';
2
1
  import { SIWXConfig } from '@reown/appkit-controllers';
3
2
 
4
3
  type ZyfaiRpcUrlsConfig = Partial<Record<(typeof SUPPORTED_CHAIN_IDS)[number], string>>;
@@ -9,10 +8,6 @@ interface OwneySDKConfig {
9
8
  * Example: { 8453: "https://...", 42161: "https://..." }
10
9
  */
11
10
  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;
16
11
  /**
17
12
  * Optional override for the Owney routing API base URL used by all routing
18
13
  * calls (defaults to the OWNEY_ROUTING_API_BASE_URL env var, then the
@@ -59,7 +54,7 @@ type OwneySupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
59
54
  type OwneySupportedChains = (typeof SUPPORTED_CHAINS)[number];
60
55
  type OwneySupportedTokens = (typeof SUPPORTED_TOKENS)[number];
61
56
 
62
- type AgentId = "zyfai" | "yieldseeker";
57
+ type AgentId = "zyfai" | "surfliquid";
63
58
  type Asset = string;
64
59
  type AgentSupportedAsset = {
65
60
  readonly symbol: string;
@@ -187,6 +182,12 @@ interface OwneyDepositResult {
187
182
  }
188
183
  interface OwneyMultiDepositResult {
189
184
  agentResults: Record<string, OwneyDepositResult>;
185
+ /**
186
+ * Per-agent failure messages for agents that errored during a diversified
187
+ * deposit. Present only when at least one (but not all) agents failed —
188
+ * the deposit is partial, not total. Omitted when every agent succeeded.
189
+ */
190
+ agentErrors?: Record<string, string>;
190
191
  }
191
192
  interface AgentWithdrawResult {
192
193
  txHash?: string;
@@ -216,8 +217,6 @@ interface OwneyPosition {
216
217
  pool?: string;
217
218
  asset: string;
218
219
  amount: string;
219
- /** Smallest-unit amount when the provider exposes it alongside `amount`. */
220
- amountRaw?: string;
221
220
  apy?: number;
222
221
  tvl?: number;
223
222
  /** Pool liquidity. Prepared slot — Zyfai will add this to its portfolio
@@ -248,19 +247,10 @@ interface OwneyPendingAllocation {
248
247
  since?: string;
249
248
  }
250
249
  interface AgentBalance {
251
- /** Authoritative native balances per asset/network, including idle and invested funds. */
252
- assetBalances?: OwneyToken[];
253
250
  smartWallet?: `0x${string}`;
254
251
  totalBalance: string;
255
252
  /** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
256
253
  totalBalanceAsset: string;
257
- /**
258
- * Describes whether `tokens` already includes deployed `positions`.
259
- * Consumers must add matching positions only for `tokens-plus-positions`;
260
- * doing so for Zyfai would double-count, while omitting it for Yieldseeker
261
- * makes its balance disappear as soon as idle funds enter a vault.
262
- */
263
- balanceComposition?: "tokens-include-positions" | "tokens-plus-positions";
264
254
  tokens: OwneyToken[];
265
255
  /**
266
256
  * Per-protocol/pool positions when the agent's portfolio payload includes
@@ -275,14 +265,10 @@ interface OwneyBalances {
275
265
  /** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
276
266
  totalBalanceAsset: string;
277
267
  agentBalances: Record<AgentId, AgentBalance>;
278
- /**
279
- * Per-agent read failures when an aggregate balance request returned only a
280
- * partial result. Callers may display the successful balances, but funding
281
- * operations must not interpret a missing agent as having a zero balance.
282
- */
283
- agentErrors?: Partial<Record<AgentId, string>>;
268
+ /** Omitted agents failed to load; they must not be interpreted as zero. */
269
+ agentErrors?: Record<AgentId, string>;
284
270
  /** Absolute provider cooldown deadlines (Unix milliseconds). */
285
- agentRetryAt?: Partial<Record<AgentId, number>>;
271
+ agentRetryAt?: Record<AgentId, number>;
286
272
  }
287
273
  interface AgentEarnings {
288
274
  smartWallet: `0x${string}`;
@@ -421,15 +407,8 @@ interface IAgent {
421
407
  readonly id: string;
422
408
  readonly supportedChainIds: readonly OwneySupportedChainId[];
423
409
  readonly supportedAssets: readonly AgentSupportedAssets[];
424
- /**
425
- * Describes how `AgentBalance.tokens` relates to `positions`.
426
- * Most adapters expose token totals that already include deployed positions.
427
- * Providers such as Yieldseeker expose idle wallet tokens separately, so
428
- * withdrawal planning must add matching position amounts.
429
- */
430
- readonly balanceComposition?: "tokens-include-positions" | "tokens-plus-positions";
431
410
  disconnect(): Promise<void>;
432
- activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
411
+ activateAgent(state: ConnectionState, chainId: number): Promise<void>;
433
412
  /**
434
413
  * Apply the organization's agent policy to this user's account.
435
414
  *
@@ -494,8 +473,6 @@ declare class OwneySDK {
494
473
  private orgAgentConfig;
495
474
  private orgAgentConfigPromise;
496
475
  private zyfaiRpcUrls?;
497
- private yieldseekerApiBaseUrl?;
498
- private yieldseekerSiweOrigin?;
499
476
  private routingApiBaseUrl?;
500
477
  private referralSource?;
501
478
  private cachedSponsoredCallback;
@@ -586,8 +563,7 @@ declare class OwneySDK {
586
563
  * If provided, ALL specified agents must support the chainId or the call
587
564
  * throws before activating any agent.
588
565
  */
589
- activateAgent(chainId: number, agentId?: AgentId[], asset?: OwneySupportedTokens): Promise<void>;
590
- private assertActivationSession;
566
+ activateAgent(chainId: number, agentId?: AgentId[]): Promise<void>;
591
567
  /**
592
568
  * Activate agents ONE AT A TIME, each followed by its org policy.
593
569
  *
@@ -602,9 +578,9 @@ declare class OwneySDK {
602
578
  * at a time anyway.
603
579
  *
604
580
  * Every agent is attempted even if an earlier one fails, so one declined
605
- * signature can't deny the remaining agents their turn. Once all agents have
606
- * had a chance, a partial failure identifies the agents that still need a
607
- * retry; if none activated, the original provider error is preserved.
581
+ * signature can't deny the remaining agents their turn. The first failure is
582
+ * rethrown (matching the previous `Promise.all` rejection) once all agents
583
+ * have had a chance to activate.
608
584
  */
609
585
  private activateAgentsInTurn;
610
586
  /**
@@ -649,7 +625,6 @@ declare class OwneySDK {
649
625
  private depositWithFallback;
650
626
  private getMinDepositAmount;
651
627
  private splitDepositAmount;
652
- private formatAgentName;
653
628
  private validateMinDepositAmount;
654
629
  /**
655
630
  * Whether the user already holds a non-zero balance with `agent` for the
@@ -660,6 +635,17 @@ declare class OwneySDK {
660
635
  private hasExistingBalance;
661
636
  private validateAssetSupport;
662
637
  private getEligibleAgents;
638
+ /**
639
+ * Agent ids the routing API provisioned for this org that support the given
640
+ * chain + asset, ordered by preference ({@link AGENT_ELIGIBILITY_ORDER},
641
+ * surfliquid first). Returns `[]` when the org has no compatible agent — never
642
+ * throws on an empty org. Loads agent keys on first call (apiKey only, no
643
+ * wallet), so the UI can resolve which agent to use before the user connects.
644
+ *
645
+ * This is the source of truth for agent availability: an agent appears here
646
+ * iff the routing API returned its key. No per-app feature flags.
647
+ */
648
+ getEligibleAgentIds(chainId: number, asset: string): Promise<AgentId[]>;
663
649
  /**
664
650
  * Withdraw funds from a specific agent, or all agents that support the active chain+asset if agentId is omitted.
665
651
  * Validates that the asset is supported by the target agent(s) on the active chain.
@@ -760,93 +746,7 @@ declare class OwneySDK {
760
746
  getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
761
747
  }
762
748
 
763
- type YieldseekerAuthDependencies = {
764
- origin?: string;
765
- now?: () => Date;
766
- nonce?: () => string;
767
- };
768
-
769
- type YieldseekerFetch = typeof fetch;
770
-
771
- type YieldseekerTransaction = {
772
- from: `0x${string}`;
773
- to: `0x${string}`;
774
- data: `0x${string}`;
775
- value: string;
776
- chainId: number;
777
- };
778
-
779
- type YieldseekerAgentOptions = {
780
- baseUrl?: string;
781
- fetchFn?: YieldseekerFetch;
782
- auth?: YieldseekerAuthDependencies;
783
- /** Test seam for the wallet-submission/receipt boundary. */
784
- transactionExecutor?: (state: ConnectionState, chainId: number, transaction: YieldseekerTransaction) => Promise<Hex>;
785
- /** Test seam for transactions submitted outside transactionExecutor. */
786
- unwindReceiptWaiter?: (state: ConnectionState, chainId: number, transactionHash: Hex) => Promise<void>;
787
- };
788
- declare class YieldseekerAgent implements IAgent {
789
- readonly id = "yieldseeker";
790
- readonly balanceComposition: "tokens-plus-positions";
791
- readonly supportedChainIds: readonly [8453];
792
- readonly supportedAssets: readonly [{
793
- readonly chainId: 8453;
794
- readonly chain: "BASE";
795
- readonly assets: readonly [{
796
- readonly symbol: "USDC";
797
- readonly minDepositAmount: "10000000";
798
- }, {
799
- readonly symbol: "WETH";
800
- readonly minDepositAmount: "1";
801
- }];
802
- }];
803
- private readonly api;
804
- private readonly auth;
805
- private readonly transactionExecutor?;
806
- private readonly unwindReceiptWaiter?;
807
- private readonly agentContexts;
808
- private readonly users;
809
- private readonly pendingAgents;
810
- constructor(owneyApiKey: string, options?: YieldseekerAgentOptions);
811
- disconnect(): Promise<void>;
812
- activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
813
- deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
814
- withdraw(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, amount?: string): Promise<AgentWithdrawResult>;
815
- getBalances(state: ConnectionState, chainId: number): Promise<AgentBalance>;
816
- getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
817
- getAccountApy(state: ConnectionState, chainId: number, days: DailyApyDays, tokenSymbol?: string): Promise<AccountAgentApy>;
818
- getHistory(state: ConnectionState, chainId: number, options?: HistoryFilters): Promise<OwneyAgentHistory>;
819
- getUserProfile(state: ConnectionState, chainId: number): Promise<AgentUserProfile>;
820
- getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
821
- private userKey;
822
- private contextKey;
823
- private resolveUser;
824
- private forgetUser;
825
- private ensureAgent;
826
- private findAgent;
827
- private resolveAgent;
828
- private loadPortfolio;
829
- private loadPortfolioContext;
830
- private deployAfterFunding;
831
- private refreshSnapshotAfterMovement;
832
- private agentPath;
833
- private walletRequest;
834
- private providerRequest;
835
- private mapApiError;
836
- private submitTransaction;
837
- private waitForReceipt;
838
- private assertTransaction;
839
- private assertAgent;
840
- private isOwneyAgent;
841
- private assetForAgent;
842
- private isTransactionHash;
843
- private assertChain;
844
- private assertOptionalChain;
845
- private assertAsset;
846
- private invalidResponse;
847
- }
848
-
849
- 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";
749
+ 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_ALL_FAILED" | "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" | "SURF_UNAVAILABLE" | "SPONSORSHIP_UNAVAILABLE" | "USER_REJECTED" | "OPERATION_PENDING" | "VAULT_NOT_SPONSORABLE" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
850
750
  declare class OwneyError extends Error {
851
751
  readonly code: OwneyErrorCode;
852
752
  readonly details?: Record<string, unknown>;
@@ -912,4 +812,4 @@ type OwneySIWXConfig = {
912
812
  */
913
813
  declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
914
814
 
915
- export { type AccountAgentApy, type AccountApyOptions, 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 AvailableAgent, type AvailableAgentsOptions, type ConnectionState, type DailyApyDays, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, 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 };
815
+ export { type AccountAgentApy, type AccountApyOptions, 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 AvailableAgent, type AvailableAgentsOptions, type ConnectionState, type DailyApyDays, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, 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, createOwneySIWX, setOwneyDebug };