@owney/sdk 0.7.17-beta.1 → 0.7.17-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,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}`;
@@ -296,6 +316,12 @@ interface OwneyAccountApy {
296
316
  totalApy: string;
297
317
  agentApy: Record<AgentId, AccountAgentApy>;
298
318
  apyByChainAndAsset: ApyByChainAndAsset;
319
+ /**
320
+ * Balance-weighted daily APY across the agents that returned a point for each
321
+ * date. The weights use the selected chain/asset balance when getAccountApy
322
+ * is asset-scoped, otherwise each agent's total balance.
323
+ */
324
+ history?: ApyHistoryPoint[];
299
325
  }
300
326
  interface AllocationAgentApy {
301
327
  /** Account-wide weighted APY for this agent, as a decimal string. */
@@ -394,8 +420,15 @@ interface IAgent {
394
420
  readonly id: string;
395
421
  readonly supportedChainIds: readonly OwneySupportedChainId[];
396
422
  readonly supportedAssets: readonly AgentSupportedAssets[];
423
+ /**
424
+ * Describes how `AgentBalance.tokens` relates to `positions`.
425
+ * Most adapters expose token totals that already include deployed positions.
426
+ * Providers such as Yieldseeker expose idle wallet tokens separately, so
427
+ * withdrawal planning must add matching position amounts.
428
+ */
429
+ readonly balanceComposition?: "tokens-include-positions" | "tokens-plus-positions";
397
430
  disconnect(): Promise<void>;
398
- activateAgent(state: ConnectionState, chainId: number): Promise<void>;
431
+ activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
399
432
  /**
400
433
  * Apply the organization's agent policy to this user's account.
401
434
  *
@@ -460,6 +493,8 @@ declare class OwneySDK {
460
493
  private orgAgentConfig;
461
494
  private orgAgentConfigPromise;
462
495
  private zyfaiRpcUrls?;
496
+ private yieldseekerApiBaseUrl?;
497
+ private yieldseekerSiweOrigin?;
463
498
  private routingApiBaseUrl?;
464
499
  private referralSource?;
465
500
  private cachedSponsoredCallback;
@@ -550,7 +585,7 @@ declare class OwneySDK {
550
585
  * If provided, ALL specified agents must support the chainId or the call
551
586
  * throws before activating any agent.
552
587
  */
553
- activateAgent(chainId: number, agentId?: AgentId[]): Promise<void>;
588
+ activateAgent(chainId: number, agentId?: AgentId[], asset?: OwneySupportedTokens): Promise<void>;
554
589
  /**
555
590
  * Activate agents ONE AT A TIME, each followed by its org policy.
556
591
  *
@@ -565,9 +600,9 @@ declare class OwneySDK {
565
600
  * at a time anyway.
566
601
  *
567
602
  * Every agent is attempted even if an earlier one fails, so one declined
568
- * signature can't deny the remaining agents their turn. The first failure is
569
- * rethrown (matching the previous `Promise.all` rejection) once all agents
570
- * have had a chance to activate.
603
+ * signature can't deny the remaining agents their turn. Once all agents have
604
+ * had a chance, a partial failure identifies the agents that still need a
605
+ * retry; if none activated, the original provider error is preserved.
571
606
  */
572
607
  private activateAgentsInTurn;
573
608
  /**
@@ -612,6 +647,7 @@ declare class OwneySDK {
612
647
  private depositWithFallback;
613
648
  private getMinDepositAmount;
614
649
  private splitDepositAmount;
650
+ private formatAgentName;
615
651
  private validateMinDepositAmount;
616
652
  /**
617
653
  * Whether the user already holds a non-zero balance with `agent` for the
@@ -722,7 +758,93 @@ declare class OwneySDK {
722
758
  getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
723
759
  }
724
760
 
725
- 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";
761
+ type YieldseekerAuthDependencies = {
762
+ origin?: string;
763
+ now?: () => Date;
764
+ nonce?: () => string;
765
+ };
766
+
767
+ type YieldseekerFetch = typeof fetch;
768
+
769
+ type YieldseekerTransaction = {
770
+ from: `0x${string}`;
771
+ to: `0x${string}`;
772
+ data: `0x${string}`;
773
+ value: string;
774
+ chainId: number;
775
+ };
776
+
777
+ type YieldseekerAgentOptions = {
778
+ baseUrl?: string;
779
+ fetchFn?: YieldseekerFetch;
780
+ auth?: YieldseekerAuthDependencies;
781
+ /** Test seam for the wallet-submission/receipt boundary. */
782
+ transactionExecutor?: (state: ConnectionState, chainId: number, transaction: YieldseekerTransaction) => Promise<Hex>;
783
+ /** Test seam for transactions submitted outside transactionExecutor. */
784
+ unwindReceiptWaiter?: (state: ConnectionState, chainId: number, transactionHash: Hex) => Promise<void>;
785
+ };
786
+ declare class YieldseekerAgent implements IAgent {
787
+ readonly id = "yieldseeker";
788
+ readonly balanceComposition: "tokens-plus-positions";
789
+ readonly supportedChainIds: readonly [8453];
790
+ readonly supportedAssets: readonly [{
791
+ readonly chainId: 8453;
792
+ readonly chain: "BASE";
793
+ readonly assets: readonly [{
794
+ readonly symbol: "USDC";
795
+ readonly minDepositAmount: "10000000";
796
+ }, {
797
+ readonly symbol: "WETH";
798
+ readonly minDepositAmount: "1";
799
+ }];
800
+ }];
801
+ private readonly api;
802
+ private readonly auth;
803
+ private readonly transactionExecutor?;
804
+ private readonly unwindReceiptWaiter?;
805
+ private readonly agentContexts;
806
+ private readonly users;
807
+ private readonly pendingAgents;
808
+ constructor(owneyApiKey: string, options?: YieldseekerAgentOptions);
809
+ disconnect(): Promise<void>;
810
+ activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
811
+ deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
812
+ withdraw(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, amount?: string): Promise<AgentWithdrawResult>;
813
+ getBalances(state: ConnectionState, chainId: number): Promise<AgentBalance>;
814
+ getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
815
+ getAccountApy(state: ConnectionState, chainId: number, days: DailyApyDays, tokenSymbol?: string): Promise<AccountAgentApy>;
816
+ getHistory(state: ConnectionState, chainId: number, options?: HistoryFilters): Promise<OwneyAgentHistory>;
817
+ getUserProfile(state: ConnectionState, chainId: number): Promise<AgentUserProfile>;
818
+ getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
819
+ private userKey;
820
+ private contextKey;
821
+ private resolveUser;
822
+ private forgetUser;
823
+ private ensureAgent;
824
+ private findAgent;
825
+ private resolveAgent;
826
+ private loadPortfolio;
827
+ private loadPortfolioContext;
828
+ private deployAfterFunding;
829
+ private refreshSnapshotAfterMovement;
830
+ private agentPath;
831
+ private walletRequest;
832
+ private providerRequest;
833
+ private mapApiError;
834
+ private submitTransaction;
835
+ private waitForReceipt;
836
+ private assertTransaction;
837
+ private assertAgent;
838
+ private isOwneyAgent;
839
+ private assetForAgent;
840
+ private isTransactionHash;
841
+ private assertChain;
842
+ private assertOptionalChain;
843
+ private assertAsset;
844
+ private invalidResponse;
845
+ }
846
+
847
+ 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";
726
848
  declare class OwneyError extends Error {
727
849
  readonly code: OwneyErrorCode;
728
850
  readonly details?: Record<string, unknown>;
@@ -788,4 +910,4 @@ type OwneySIWXConfig = {
788
910
  */
789
911
  declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
790
912
 
791
- 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 };
913
+ 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}`;
@@ -296,6 +316,12 @@ interface OwneyAccountApy {
296
316
  totalApy: string;
297
317
  agentApy: Record<AgentId, AccountAgentApy>;
298
318
  apyByChainAndAsset: ApyByChainAndAsset;
319
+ /**
320
+ * Balance-weighted daily APY across the agents that returned a point for each
321
+ * date. The weights use the selected chain/asset balance when getAccountApy
322
+ * is asset-scoped, otherwise each agent's total balance.
323
+ */
324
+ history?: ApyHistoryPoint[];
299
325
  }
300
326
  interface AllocationAgentApy {
301
327
  /** Account-wide weighted APY for this agent, as a decimal string. */
@@ -394,8 +420,15 @@ interface IAgent {
394
420
  readonly id: string;
395
421
  readonly supportedChainIds: readonly OwneySupportedChainId[];
396
422
  readonly supportedAssets: readonly AgentSupportedAssets[];
423
+ /**
424
+ * Describes how `AgentBalance.tokens` relates to `positions`.
425
+ * Most adapters expose token totals that already include deployed positions.
426
+ * Providers such as Yieldseeker expose idle wallet tokens separately, so
427
+ * withdrawal planning must add matching position amounts.
428
+ */
429
+ readonly balanceComposition?: "tokens-include-positions" | "tokens-plus-positions";
397
430
  disconnect(): Promise<void>;
398
- activateAgent(state: ConnectionState, chainId: number): Promise<void>;
431
+ activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
399
432
  /**
400
433
  * Apply the organization's agent policy to this user's account.
401
434
  *
@@ -460,6 +493,8 @@ declare class OwneySDK {
460
493
  private orgAgentConfig;
461
494
  private orgAgentConfigPromise;
462
495
  private zyfaiRpcUrls?;
496
+ private yieldseekerApiBaseUrl?;
497
+ private yieldseekerSiweOrigin?;
463
498
  private routingApiBaseUrl?;
464
499
  private referralSource?;
465
500
  private cachedSponsoredCallback;
@@ -550,7 +585,7 @@ declare class OwneySDK {
550
585
  * If provided, ALL specified agents must support the chainId or the call
551
586
  * throws before activating any agent.
552
587
  */
553
- activateAgent(chainId: number, agentId?: AgentId[]): Promise<void>;
588
+ activateAgent(chainId: number, agentId?: AgentId[], asset?: OwneySupportedTokens): Promise<void>;
554
589
  /**
555
590
  * Activate agents ONE AT A TIME, each followed by its org policy.
556
591
  *
@@ -565,9 +600,9 @@ declare class OwneySDK {
565
600
  * at a time anyway.
566
601
  *
567
602
  * Every agent is attempted even if an earlier one fails, so one declined
568
- * signature can't deny the remaining agents their turn. The first failure is
569
- * rethrown (matching the previous `Promise.all` rejection) once all agents
570
- * have had a chance to activate.
603
+ * signature can't deny the remaining agents their turn. Once all agents have
604
+ * had a chance, a partial failure identifies the agents that still need a
605
+ * retry; if none activated, the original provider error is preserved.
571
606
  */
572
607
  private activateAgentsInTurn;
573
608
  /**
@@ -612,6 +647,7 @@ declare class OwneySDK {
612
647
  private depositWithFallback;
613
648
  private getMinDepositAmount;
614
649
  private splitDepositAmount;
650
+ private formatAgentName;
615
651
  private validateMinDepositAmount;
616
652
  /**
617
653
  * Whether the user already holds a non-zero balance with `agent` for the
@@ -722,7 +758,93 @@ declare class OwneySDK {
722
758
  getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
723
759
  }
724
760
 
725
- 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";
761
+ type YieldseekerAuthDependencies = {
762
+ origin?: string;
763
+ now?: () => Date;
764
+ nonce?: () => string;
765
+ };
766
+
767
+ type YieldseekerFetch = typeof fetch;
768
+
769
+ type YieldseekerTransaction = {
770
+ from: `0x${string}`;
771
+ to: `0x${string}`;
772
+ data: `0x${string}`;
773
+ value: string;
774
+ chainId: number;
775
+ };
776
+
777
+ type YieldseekerAgentOptions = {
778
+ baseUrl?: string;
779
+ fetchFn?: YieldseekerFetch;
780
+ auth?: YieldseekerAuthDependencies;
781
+ /** Test seam for the wallet-submission/receipt boundary. */
782
+ transactionExecutor?: (state: ConnectionState, chainId: number, transaction: YieldseekerTransaction) => Promise<Hex>;
783
+ /** Test seam for transactions submitted outside transactionExecutor. */
784
+ unwindReceiptWaiter?: (state: ConnectionState, chainId: number, transactionHash: Hex) => Promise<void>;
785
+ };
786
+ declare class YieldseekerAgent implements IAgent {
787
+ readonly id = "yieldseeker";
788
+ readonly balanceComposition: "tokens-plus-positions";
789
+ readonly supportedChainIds: readonly [8453];
790
+ readonly supportedAssets: readonly [{
791
+ readonly chainId: 8453;
792
+ readonly chain: "BASE";
793
+ readonly assets: readonly [{
794
+ readonly symbol: "USDC";
795
+ readonly minDepositAmount: "10000000";
796
+ }, {
797
+ readonly symbol: "WETH";
798
+ readonly minDepositAmount: "1";
799
+ }];
800
+ }];
801
+ private readonly api;
802
+ private readonly auth;
803
+ private readonly transactionExecutor?;
804
+ private readonly unwindReceiptWaiter?;
805
+ private readonly agentContexts;
806
+ private readonly users;
807
+ private readonly pendingAgents;
808
+ constructor(owneyApiKey: string, options?: YieldseekerAgentOptions);
809
+ disconnect(): Promise<void>;
810
+ activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
811
+ deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
812
+ withdraw(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, amount?: string): Promise<AgentWithdrawResult>;
813
+ getBalances(state: ConnectionState, chainId: number): Promise<AgentBalance>;
814
+ getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
815
+ getAccountApy(state: ConnectionState, chainId: number, days: DailyApyDays, tokenSymbol?: string): Promise<AccountAgentApy>;
816
+ getHistory(state: ConnectionState, chainId: number, options?: HistoryFilters): Promise<OwneyAgentHistory>;
817
+ getUserProfile(state: ConnectionState, chainId: number): Promise<AgentUserProfile>;
818
+ getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
819
+ private userKey;
820
+ private contextKey;
821
+ private resolveUser;
822
+ private forgetUser;
823
+ private ensureAgent;
824
+ private findAgent;
825
+ private resolveAgent;
826
+ private loadPortfolio;
827
+ private loadPortfolioContext;
828
+ private deployAfterFunding;
829
+ private refreshSnapshotAfterMovement;
830
+ private agentPath;
831
+ private walletRequest;
832
+ private providerRequest;
833
+ private mapApiError;
834
+ private submitTransaction;
835
+ private waitForReceipt;
836
+ private assertTransaction;
837
+ private assertAgent;
838
+ private isOwneyAgent;
839
+ private assetForAgent;
840
+ private isTransactionHash;
841
+ private assertChain;
842
+ private assertOptionalChain;
843
+ private assertAsset;
844
+ private invalidResponse;
845
+ }
846
+
847
+ 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";
726
848
  declare class OwneyError extends Error {
727
849
  readonly code: OwneyErrorCode;
728
850
  readonly details?: Record<string, unknown>;
@@ -788,4 +910,4 @@ type OwneySIWXConfig = {
788
910
  */
789
911
  declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
790
912
 
791
- 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 };
913
+ 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 };