@owney/sdk 0.7.20 → 0.7.21-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,3 +1,4 @@
1
+ import { Hex } from 'viem';
1
2
  import { SIWXConfig } from '@reown/appkit-controllers';
2
3
 
3
4
  type ZyfaiRpcUrlsConfig = Partial<Record<(typeof SUPPORTED_CHAIN_IDS)[number], string>>;
@@ -8,6 +9,10 @@ interface OwneySDKConfig {
8
9
  * Example: { 8453: "https://...", 42161: "https://..." }
9
10
  */
10
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;
11
16
  /**
12
17
  * Optional override for the Owney routing API base URL used by all routing
13
18
  * calls (defaults to the OWNEY_ROUTING_API_BASE_URL env var, then the
@@ -54,7 +59,7 @@ type OwneySupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
54
59
  type OwneySupportedChains = (typeof SUPPORTED_CHAINS)[number];
55
60
  type OwneySupportedTokens = (typeof SUPPORTED_TOKENS)[number];
56
61
 
57
- type AgentId = "zyfai";
62
+ type AgentId = "zyfai" | "yieldseeker";
58
63
  type Asset = string;
59
64
  type AgentSupportedAsset = {
60
65
  readonly symbol: string;
@@ -211,6 +216,8 @@ interface OwneyPosition {
211
216
  pool?: string;
212
217
  asset: string;
213
218
  amount: string;
219
+ /** Smallest-unit amount when the provider exposes it alongside `amount`. */
220
+ amountRaw?: string;
214
221
  apy?: number;
215
222
  tvl?: number;
216
223
  /** Pool liquidity. Prepared slot — Zyfai will add this to its portfolio
@@ -241,10 +248,19 @@ interface OwneyPendingAllocation {
241
248
  since?: string;
242
249
  }
243
250
  interface AgentBalance {
251
+ /** Authoritative native balances per asset/network, including idle and invested funds. */
252
+ assetBalances?: OwneyToken[];
244
253
  smartWallet?: `0x${string}`;
245
254
  totalBalance: string;
246
255
  /** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
247
256
  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";
248
264
  tokens: OwneyToken[];
249
265
  /**
250
266
  * Per-protocol/pool positions when the agent's portfolio payload includes
@@ -259,10 +275,14 @@ interface OwneyBalances {
259
275
  /** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
260
276
  totalBalanceAsset: string;
261
277
  agentBalances: Record<AgentId, AgentBalance>;
262
- /** Omitted agents failed to load; they must not be interpreted as zero. */
263
- agentErrors?: Record<AgentId, string>;
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>>;
264
284
  /** Absolute provider cooldown deadlines (Unix milliseconds). */
265
- agentRetryAt?: Record<AgentId, number>;
285
+ agentRetryAt?: Partial<Record<AgentId, number>>;
266
286
  }
267
287
  interface AgentEarnings {
268
288
  smartWallet: `0x${string}`;
@@ -401,8 +421,15 @@ interface IAgent {
401
421
  readonly id: string;
402
422
  readonly supportedChainIds: readonly OwneySupportedChainId[];
403
423
  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";
404
431
  disconnect(): Promise<void>;
405
- activateAgent(state: ConnectionState, chainId: number): Promise<void>;
432
+ activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
406
433
  /**
407
434
  * Apply the organization's agent policy to this user's account.
408
435
  *
@@ -467,6 +494,8 @@ declare class OwneySDK {
467
494
  private orgAgentConfig;
468
495
  private orgAgentConfigPromise;
469
496
  private zyfaiRpcUrls?;
497
+ private yieldseekerApiBaseUrl?;
498
+ private yieldseekerSiweOrigin?;
470
499
  private routingApiBaseUrl?;
471
500
  private referralSource?;
472
501
  private cachedSponsoredCallback;
@@ -557,7 +586,7 @@ declare class OwneySDK {
557
586
  * If provided, ALL specified agents must support the chainId or the call
558
587
  * throws before activating any agent.
559
588
  */
560
- activateAgent(chainId: number, agentId?: AgentId[]): Promise<void>;
589
+ activateAgent(chainId: number, agentId?: AgentId[], asset?: OwneySupportedTokens): Promise<void>;
561
590
  /**
562
591
  * Activate agents ONE AT A TIME, each followed by its org policy.
563
592
  *
@@ -572,9 +601,9 @@ declare class OwneySDK {
572
601
  * at a time anyway.
573
602
  *
574
603
  * Every agent is attempted even if an earlier one fails, so one declined
575
- * signature can't deny the remaining agents their turn. The first failure is
576
- * rethrown (matching the previous `Promise.all` rejection) once all agents
577
- * have had a chance to activate.
604
+ * signature can't deny the remaining agents their turn. Once all agents have
605
+ * had a chance, a partial failure identifies the agents that still need a
606
+ * retry; if none activated, the original provider error is preserved.
578
607
  */
579
608
  private activateAgentsInTurn;
580
609
  /**
@@ -619,6 +648,7 @@ declare class OwneySDK {
619
648
  private depositWithFallback;
620
649
  private getMinDepositAmount;
621
650
  private splitDepositAmount;
651
+ private formatAgentName;
622
652
  private validateMinDepositAmount;
623
653
  /**
624
654
  * Whether the user already holds a non-zero balance with `agent` for the
@@ -729,7 +759,93 @@ declare class OwneySDK {
729
759
  getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
730
760
  }
731
761
 
732
- 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" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
762
+ type YieldseekerAuthDependencies = {
763
+ origin?: string;
764
+ now?: () => Date;
765
+ nonce?: () => string;
766
+ };
767
+
768
+ type YieldseekerFetch = typeof fetch;
769
+
770
+ type YieldseekerTransaction = {
771
+ from: `0x${string}`;
772
+ to: `0x${string}`;
773
+ data: `0x${string}`;
774
+ value: string;
775
+ chainId: number;
776
+ };
777
+
778
+ type YieldseekerAgentOptions = {
779
+ baseUrl?: string;
780
+ fetchFn?: YieldseekerFetch;
781
+ auth?: YieldseekerAuthDependencies;
782
+ /** Test seam for the wallet-submission/receipt boundary. */
783
+ transactionExecutor?: (state: ConnectionState, chainId: number, transaction: YieldseekerTransaction) => Promise<Hex>;
784
+ /** Test seam for transactions submitted outside transactionExecutor. */
785
+ unwindReceiptWaiter?: (state: ConnectionState, chainId: number, transactionHash: Hex) => Promise<void>;
786
+ };
787
+ declare class YieldseekerAgent implements IAgent {
788
+ readonly id = "yieldseeker";
789
+ readonly balanceComposition: "tokens-plus-positions";
790
+ readonly supportedChainIds: readonly [8453];
791
+ readonly supportedAssets: readonly [{
792
+ readonly chainId: 8453;
793
+ readonly chain: "BASE";
794
+ readonly assets: readonly [{
795
+ readonly symbol: "USDC";
796
+ readonly minDepositAmount: "10000000";
797
+ }, {
798
+ readonly symbol: "WETH";
799
+ readonly minDepositAmount: "1";
800
+ }];
801
+ }];
802
+ private readonly api;
803
+ private readonly auth;
804
+ private readonly transactionExecutor?;
805
+ private readonly unwindReceiptWaiter?;
806
+ private readonly agentContexts;
807
+ private readonly users;
808
+ private readonly pendingAgents;
809
+ constructor(owneyApiKey: string, options?: YieldseekerAgentOptions);
810
+ disconnect(): Promise<void>;
811
+ activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
812
+ deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
813
+ withdraw(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, amount?: string): Promise<AgentWithdrawResult>;
814
+ getBalances(state: ConnectionState, chainId: number): Promise<AgentBalance>;
815
+ getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
816
+ getAccountApy(state: ConnectionState, chainId: number, days: DailyApyDays, tokenSymbol?: string): Promise<AccountAgentApy>;
817
+ getHistory(state: ConnectionState, chainId: number, options?: HistoryFilters): Promise<OwneyAgentHistory>;
818
+ getUserProfile(state: ConnectionState, chainId: number): Promise<AgentUserProfile>;
819
+ getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
820
+ private userKey;
821
+ private contextKey;
822
+ private resolveUser;
823
+ private forgetUser;
824
+ private ensureAgent;
825
+ private findAgent;
826
+ private resolveAgent;
827
+ private loadPortfolio;
828
+ private loadPortfolioContext;
829
+ private deployAfterFunding;
830
+ private refreshSnapshotAfterMovement;
831
+ private agentPath;
832
+ private walletRequest;
833
+ private providerRequest;
834
+ private mapApiError;
835
+ private submitTransaction;
836
+ private waitForReceipt;
837
+ private assertTransaction;
838
+ private assertAgent;
839
+ private isOwneyAgent;
840
+ private assetForAgent;
841
+ private isTransactionHash;
842
+ private assertChain;
843
+ private assertOptionalChain;
844
+ private assertAsset;
845
+ private invalidResponse;
846
+ }
847
+
848
+ 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";
733
849
  declare class OwneyError extends Error {
734
850
  readonly code: OwneyErrorCode;
735
851
  readonly details?: Record<string, unknown>;
@@ -795,4 +911,4 @@ type OwneySIWXConfig = {
795
911
  */
796
912
  declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
797
913
 
798
- 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 };
914
+ 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 };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { Hex } from 'viem';
1
2
  import { SIWXConfig } from '@reown/appkit-controllers';
2
3
 
3
4
  type ZyfaiRpcUrlsConfig = Partial<Record<(typeof SUPPORTED_CHAIN_IDS)[number], string>>;
@@ -8,6 +9,10 @@ interface OwneySDKConfig {
8
9
  * Example: { 8453: "https://...", 42161: "https://..." }
9
10
  */
10
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;
11
16
  /**
12
17
  * Optional override for the Owney routing API base URL used by all routing
13
18
  * calls (defaults to the OWNEY_ROUTING_API_BASE_URL env var, then the
@@ -54,7 +59,7 @@ type OwneySupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
54
59
  type OwneySupportedChains = (typeof SUPPORTED_CHAINS)[number];
55
60
  type OwneySupportedTokens = (typeof SUPPORTED_TOKENS)[number];
56
61
 
57
- type AgentId = "zyfai";
62
+ type AgentId = "zyfai" | "yieldseeker";
58
63
  type Asset = string;
59
64
  type AgentSupportedAsset = {
60
65
  readonly symbol: string;
@@ -211,6 +216,8 @@ interface OwneyPosition {
211
216
  pool?: string;
212
217
  asset: string;
213
218
  amount: string;
219
+ /** Smallest-unit amount when the provider exposes it alongside `amount`. */
220
+ amountRaw?: string;
214
221
  apy?: number;
215
222
  tvl?: number;
216
223
  /** Pool liquidity. Prepared slot — Zyfai will add this to its portfolio
@@ -241,10 +248,19 @@ interface OwneyPendingAllocation {
241
248
  since?: string;
242
249
  }
243
250
  interface AgentBalance {
251
+ /** Authoritative native balances per asset/network, including idle and invested funds. */
252
+ assetBalances?: OwneyToken[];
244
253
  smartWallet?: `0x${string}`;
245
254
  totalBalance: string;
246
255
  /** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
247
256
  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";
248
264
  tokens: OwneyToken[];
249
265
  /**
250
266
  * Per-protocol/pool positions when the agent's portfolio payload includes
@@ -259,10 +275,14 @@ interface OwneyBalances {
259
275
  /** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
260
276
  totalBalanceAsset: string;
261
277
  agentBalances: Record<AgentId, AgentBalance>;
262
- /** Omitted agents failed to load; they must not be interpreted as zero. */
263
- agentErrors?: Record<AgentId, string>;
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>>;
264
284
  /** Absolute provider cooldown deadlines (Unix milliseconds). */
265
- agentRetryAt?: Record<AgentId, number>;
285
+ agentRetryAt?: Partial<Record<AgentId, number>>;
266
286
  }
267
287
  interface AgentEarnings {
268
288
  smartWallet: `0x${string}`;
@@ -401,8 +421,15 @@ interface IAgent {
401
421
  readonly id: string;
402
422
  readonly supportedChainIds: readonly OwneySupportedChainId[];
403
423
  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";
404
431
  disconnect(): Promise<void>;
405
- activateAgent(state: ConnectionState, chainId: number): Promise<void>;
432
+ activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
406
433
  /**
407
434
  * Apply the organization's agent policy to this user's account.
408
435
  *
@@ -467,6 +494,8 @@ declare class OwneySDK {
467
494
  private orgAgentConfig;
468
495
  private orgAgentConfigPromise;
469
496
  private zyfaiRpcUrls?;
497
+ private yieldseekerApiBaseUrl?;
498
+ private yieldseekerSiweOrigin?;
470
499
  private routingApiBaseUrl?;
471
500
  private referralSource?;
472
501
  private cachedSponsoredCallback;
@@ -557,7 +586,7 @@ declare class OwneySDK {
557
586
  * If provided, ALL specified agents must support the chainId or the call
558
587
  * throws before activating any agent.
559
588
  */
560
- activateAgent(chainId: number, agentId?: AgentId[]): Promise<void>;
589
+ activateAgent(chainId: number, agentId?: AgentId[], asset?: OwneySupportedTokens): Promise<void>;
561
590
  /**
562
591
  * Activate agents ONE AT A TIME, each followed by its org policy.
563
592
  *
@@ -572,9 +601,9 @@ declare class OwneySDK {
572
601
  * at a time anyway.
573
602
  *
574
603
  * Every agent is attempted even if an earlier one fails, so one declined
575
- * signature can't deny the remaining agents their turn. The first failure is
576
- * rethrown (matching the previous `Promise.all` rejection) once all agents
577
- * have had a chance to activate.
604
+ * signature can't deny the remaining agents their turn. Once all agents have
605
+ * had a chance, a partial failure identifies the agents that still need a
606
+ * retry; if none activated, the original provider error is preserved.
578
607
  */
579
608
  private activateAgentsInTurn;
580
609
  /**
@@ -619,6 +648,7 @@ declare class OwneySDK {
619
648
  private depositWithFallback;
620
649
  private getMinDepositAmount;
621
650
  private splitDepositAmount;
651
+ private formatAgentName;
622
652
  private validateMinDepositAmount;
623
653
  /**
624
654
  * Whether the user already holds a non-zero balance with `agent` for the
@@ -729,7 +759,93 @@ declare class OwneySDK {
729
759
  getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
730
760
  }
731
761
 
732
- 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" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
762
+ type YieldseekerAuthDependencies = {
763
+ origin?: string;
764
+ now?: () => Date;
765
+ nonce?: () => string;
766
+ };
767
+
768
+ type YieldseekerFetch = typeof fetch;
769
+
770
+ type YieldseekerTransaction = {
771
+ from: `0x${string}`;
772
+ to: `0x${string}`;
773
+ data: `0x${string}`;
774
+ value: string;
775
+ chainId: number;
776
+ };
777
+
778
+ type YieldseekerAgentOptions = {
779
+ baseUrl?: string;
780
+ fetchFn?: YieldseekerFetch;
781
+ auth?: YieldseekerAuthDependencies;
782
+ /** Test seam for the wallet-submission/receipt boundary. */
783
+ transactionExecutor?: (state: ConnectionState, chainId: number, transaction: YieldseekerTransaction) => Promise<Hex>;
784
+ /** Test seam for transactions submitted outside transactionExecutor. */
785
+ unwindReceiptWaiter?: (state: ConnectionState, chainId: number, transactionHash: Hex) => Promise<void>;
786
+ };
787
+ declare class YieldseekerAgent implements IAgent {
788
+ readonly id = "yieldseeker";
789
+ readonly balanceComposition: "tokens-plus-positions";
790
+ readonly supportedChainIds: readonly [8453];
791
+ readonly supportedAssets: readonly [{
792
+ readonly chainId: 8453;
793
+ readonly chain: "BASE";
794
+ readonly assets: readonly [{
795
+ readonly symbol: "USDC";
796
+ readonly minDepositAmount: "10000000";
797
+ }, {
798
+ readonly symbol: "WETH";
799
+ readonly minDepositAmount: "1";
800
+ }];
801
+ }];
802
+ private readonly api;
803
+ private readonly auth;
804
+ private readonly transactionExecutor?;
805
+ private readonly unwindReceiptWaiter?;
806
+ private readonly agentContexts;
807
+ private readonly users;
808
+ private readonly pendingAgents;
809
+ constructor(owneyApiKey: string, options?: YieldseekerAgentOptions);
810
+ disconnect(): Promise<void>;
811
+ activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
812
+ deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
813
+ withdraw(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, amount?: string): Promise<AgentWithdrawResult>;
814
+ getBalances(state: ConnectionState, chainId: number): Promise<AgentBalance>;
815
+ getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
816
+ getAccountApy(state: ConnectionState, chainId: number, days: DailyApyDays, tokenSymbol?: string): Promise<AccountAgentApy>;
817
+ getHistory(state: ConnectionState, chainId: number, options?: HistoryFilters): Promise<OwneyAgentHistory>;
818
+ getUserProfile(state: ConnectionState, chainId: number): Promise<AgentUserProfile>;
819
+ getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
820
+ private userKey;
821
+ private contextKey;
822
+ private resolveUser;
823
+ private forgetUser;
824
+ private ensureAgent;
825
+ private findAgent;
826
+ private resolveAgent;
827
+ private loadPortfolio;
828
+ private loadPortfolioContext;
829
+ private deployAfterFunding;
830
+ private refreshSnapshotAfterMovement;
831
+ private agentPath;
832
+ private walletRequest;
833
+ private providerRequest;
834
+ private mapApiError;
835
+ private submitTransaction;
836
+ private waitForReceipt;
837
+ private assertTransaction;
838
+ private assertAgent;
839
+ private isOwneyAgent;
840
+ private assetForAgent;
841
+ private isTransactionHash;
842
+ private assertChain;
843
+ private assertOptionalChain;
844
+ private assertAsset;
845
+ private invalidResponse;
846
+ }
847
+
848
+ 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";
733
849
  declare class OwneyError extends Error {
734
850
  readonly code: OwneyErrorCode;
735
851
  readonly details?: Record<string, unknown>;
@@ -795,4 +911,4 @@ type OwneySIWXConfig = {
795
911
  */
796
912
  declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
797
913
 
798
- 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 };
914
+ 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 };