@owney/sdk 0.7.16-beta.0 → 0.7.16-beta.2

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,17 +9,19 @@ 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;
11
14
  /**
12
- * Optional override for the Owney routing API base URL used by the sponsored
13
- * deposit callbacks (defaults to the OWNEY_ROUTING_API_BASE_URL env var, then
14
- * the production URL). Set this to point at a local/staging routing API,
15
+ * Optional override for the Owney routing API base URL used by all routing
16
+ * calls (defaults to the OWNEY_ROUTING_API_BASE_URL env var, then the
17
+ * production URL). Set this to point at a local/staging routing API,
15
18
  * e.g. "http://localhost:3000", when testing sponsor changes.
16
19
  */
17
20
  routingApiBaseUrl?: string;
18
21
  /**
19
22
  * Optional attribution tag forwarded to Zyfai's /auth/login when the SDK
20
- * authenticates (e.g. "delos"). Replaces the equivalent option on
21
- * `createOwneySIWX` for apps that don't use the AppKit SIWX modal.
23
+ * authenticates. Replaces the equivalent option on `createOwneySIWX`
24
+ * for apps that don't use the AppKit SIWX modal.
22
25
  */
23
26
  referralSource?: string;
24
27
  /**
@@ -54,7 +57,7 @@ type OwneySupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
54
57
  type OwneySupportedChains = (typeof SUPPORTED_CHAINS)[number];
55
58
  type OwneySupportedTokens = (typeof SUPPORTED_TOKENS)[number];
56
59
 
57
- type AgentId = "zyfai";
60
+ type AgentId = "zyfai" | "yieldseeker";
58
61
  type Asset = string;
59
62
  type AgentSupportedAsset = {
60
63
  readonly symbol: string;
@@ -65,6 +68,18 @@ type AgentSupportedAssets = {
65
68
  readonly chain?: string;
66
69
  readonly assets: readonly AgentSupportedAsset[];
67
70
  };
71
+ type AvailableAgent = {
72
+ id: AgentId;
73
+ isEnabled: boolean;
74
+ supportedChainIds: readonly number[];
75
+ supportedAssets: readonly AgentSupportedAssets[];
76
+ };
77
+ type AvailableAgentsOptions = {
78
+ chainId?: number;
79
+ asset?: Asset;
80
+ /** Disabled agents are omitted by default because they cannot accept funds. */
81
+ includeDisabled?: boolean;
82
+ };
68
83
  type DailyApyDays = "7D" | "14D" | "30D";
69
84
  type HistoryFilters = {
70
85
  fromDate?: string;
@@ -194,6 +209,8 @@ interface OwneyPosition {
194
209
  pool?: string;
195
210
  asset: string;
196
211
  amount: string;
212
+ /** Smallest-unit amount when the provider exposes it alongside `amount`. */
213
+ amountRaw?: string;
197
214
  apy?: number;
198
215
  tvl?: number;
199
216
  /** Pool liquidity. Prepared slot — Zyfai will add this to its portfolio
@@ -242,6 +259,12 @@ interface OwneyBalances {
242
259
  /** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
243
260
  totalBalanceAsset: string;
244
261
  agentBalances: Record<AgentId, AgentBalance>;
262
+ /**
263
+ * Per-agent read failures when an aggregate balance request returned only a
264
+ * partial result. Callers may display the successful balances, but funding
265
+ * operations must not interpret a missing agent as having a zero balance.
266
+ */
267
+ agentErrors?: Partial<Record<AgentId, string>>;
245
268
  }
246
269
  interface AgentEarnings {
247
270
  smartWallet: `0x${string}`;
@@ -275,6 +298,12 @@ interface OwneyAccountApy {
275
298
  totalApy: string;
276
299
  agentApy: Record<AgentId, AccountAgentApy>;
277
300
  apyByChainAndAsset: ApyByChainAndAsset;
301
+ /**
302
+ * Balance-weighted daily APY across the agents that returned a point for each
303
+ * date. The weights use the selected chain/asset balance when getAccountApy
304
+ * is asset-scoped, otherwise each agent's total balance.
305
+ */
306
+ history?: ApyHistoryPoint[];
278
307
  }
279
308
  interface AllocationAgentApy {
280
309
  /** Account-wide weighted APY for this agent, as a decimal string. */
@@ -373,8 +402,15 @@ interface IAgent {
373
402
  readonly id: string;
374
403
  readonly supportedChainIds: readonly OwneySupportedChainId[];
375
404
  readonly supportedAssets: readonly AgentSupportedAssets[];
405
+ /**
406
+ * Describes how `AgentBalance.tokens` relates to `positions`.
407
+ * Most adapters expose token totals that already include deployed positions.
408
+ * Providers such as Yieldseeker expose idle wallet tokens separately, so
409
+ * withdrawal planning must add matching position amounts.
410
+ */
411
+ readonly balanceComposition?: "tokens-include-positions" | "tokens-plus-positions";
376
412
  disconnect(): Promise<void>;
377
- activateAgent(state: ConnectionState, chainId: number): Promise<void>;
413
+ activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
378
414
  /**
379
415
  * Apply the organization's agent policy to this user's account.
380
416
  *
@@ -439,6 +475,7 @@ declare class OwneySDK {
439
475
  private orgAgentConfig;
440
476
  private orgAgentConfigPromise;
441
477
  private zyfaiRpcUrls?;
478
+ private yieldseekerApiBaseUrl?;
442
479
  private routingApiBaseUrl?;
443
480
  private referralSource?;
444
481
  private cachedSponsoredCallback;
@@ -511,6 +548,11 @@ declare class OwneySDK {
511
548
  private applyOrgPolicyTo;
512
549
  private ensureAgentsInitialized;
513
550
  private createAgent;
551
+ /**
552
+ * Discover the agents actually returned by routing for this organization.
553
+ * Consumers should use this instead of hardcoding a global agent roster.
554
+ */
555
+ getAvailableAgents(options?: AvailableAgentsOptions): Promise<AvailableAgent[]>;
514
556
  /**
515
557
  * Activate the user's smart wallet for the specified agents, or all chain-compatible agents if omitted.
516
558
  * Deploys the Safe contract and creates a session key if not already set up.
@@ -521,7 +563,7 @@ declare class OwneySDK {
521
563
  * If provided, ALL specified agents must support the chainId or the call
522
564
  * throws before activating any agent.
523
565
  */
524
- activateAgent(chainId: number, agentId?: AgentId[]): Promise<void>;
566
+ activateAgent(chainId: number, agentId?: AgentId[], asset?: OwneySupportedTokens): Promise<void>;
525
567
  /**
526
568
  * Activate agents ONE AT A TIME, each followed by its org policy.
527
569
  *
@@ -692,7 +734,92 @@ declare class OwneySDK {
692
734
  getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
693
735
  }
694
736
 
695
- 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_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" | "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";
737
+ type YieldseekerAuthDependencies = {
738
+ now?: () => Date;
739
+ nonce?: () => string;
740
+ };
741
+
742
+ type YieldseekerFetch = typeof fetch;
743
+
744
+ type YieldseekerTransaction = {
745
+ from: `0x${string}`;
746
+ to: `0x${string}`;
747
+ data: `0x${string}`;
748
+ value: string;
749
+ chainId: number;
750
+ };
751
+
752
+ type YieldseekerAgentOptions = {
753
+ baseUrl?: string;
754
+ fetchFn?: YieldseekerFetch;
755
+ auth?: YieldseekerAuthDependencies;
756
+ /** Test seam for the wallet-submission/receipt boundary. */
757
+ transactionExecutor?: (state: ConnectionState, chainId: number, transaction: YieldseekerTransaction) => Promise<Hex>;
758
+ /** Test seam for transactions submitted outside transactionExecutor. */
759
+ unwindReceiptWaiter?: (state: ConnectionState, chainId: number, transactionHash: Hex) => Promise<void>;
760
+ };
761
+ declare class YieldseekerAgent implements IAgent {
762
+ readonly id = "yieldseeker";
763
+ readonly balanceComposition: "tokens-plus-positions";
764
+ readonly supportedChainIds: readonly [8453];
765
+ readonly supportedAssets: readonly [{
766
+ readonly chainId: 8453;
767
+ readonly chain: "BASE";
768
+ readonly assets: readonly [{
769
+ readonly symbol: "USDC";
770
+ readonly minDepositAmount: "10000000";
771
+ }, {
772
+ readonly symbol: "WETH";
773
+ readonly minDepositAmount: "1";
774
+ }];
775
+ }];
776
+ private readonly api;
777
+ private readonly auth;
778
+ private readonly transactionExecutor?;
779
+ private readonly unwindReceiptWaiter?;
780
+ private readonly agentContexts;
781
+ private readonly users;
782
+ private readonly pendingAgents;
783
+ constructor(owneyApiKey: string, options?: YieldseekerAgentOptions);
784
+ disconnect(): Promise<void>;
785
+ activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
786
+ deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
787
+ withdraw(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, amount?: string): Promise<AgentWithdrawResult>;
788
+ getBalances(state: ConnectionState, chainId: number): Promise<AgentBalance>;
789
+ getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
790
+ getAccountApy(state: ConnectionState, chainId: number, days: DailyApyDays, tokenSymbol?: string): Promise<AccountAgentApy>;
791
+ getHistory(state: ConnectionState, chainId: number, options?: HistoryFilters): Promise<OwneyAgentHistory>;
792
+ getUserProfile(state: ConnectionState, chainId: number): Promise<AgentUserProfile>;
793
+ getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
794
+ private userKey;
795
+ private contextKey;
796
+ private resolveUser;
797
+ private forgetUser;
798
+ private ensureAgent;
799
+ private findAgent;
800
+ private resolveAgent;
801
+ private loadPortfolio;
802
+ private loadPortfolioContext;
803
+ private deployAfterFunding;
804
+ private refreshSnapshotAfterMovement;
805
+ private agentPath;
806
+ private walletRequest;
807
+ private providerRequest;
808
+ private mapApiError;
809
+ private submitTransaction;
810
+ private waitForReceipt;
811
+ private assertTransaction;
812
+ private assertAgent;
813
+ private isOwneyAgent;
814
+ private assetForAgent;
815
+ private isTransactionHash;
816
+ private assertChain;
817
+ private assertOptionalChain;
818
+ private assertAsset;
819
+ private invalidResponse;
820
+ }
821
+
822
+ 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_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" | "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";
696
823
  declare class OwneyError extends Error {
697
824
  readonly code: OwneyErrorCode;
698
825
  readonly details?: Record<string, unknown>;
@@ -758,4 +885,4 @@ type OwneySIWXConfig = {
758
885
  */
759
886
  declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
760
887
 
761
- 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 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 };
888
+ 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,17 +9,19 @@ 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;
11
14
  /**
12
- * Optional override for the Owney routing API base URL used by the sponsored
13
- * deposit callbacks (defaults to the OWNEY_ROUTING_API_BASE_URL env var, then
14
- * the production URL). Set this to point at a local/staging routing API,
15
+ * Optional override for the Owney routing API base URL used by all routing
16
+ * calls (defaults to the OWNEY_ROUTING_API_BASE_URL env var, then the
17
+ * production URL). Set this to point at a local/staging routing API,
15
18
  * e.g. "http://localhost:3000", when testing sponsor changes.
16
19
  */
17
20
  routingApiBaseUrl?: string;
18
21
  /**
19
22
  * Optional attribution tag forwarded to Zyfai's /auth/login when the SDK
20
- * authenticates (e.g. "delos"). Replaces the equivalent option on
21
- * `createOwneySIWX` for apps that don't use the AppKit SIWX modal.
23
+ * authenticates. Replaces the equivalent option on `createOwneySIWX`
24
+ * for apps that don't use the AppKit SIWX modal.
22
25
  */
23
26
  referralSource?: string;
24
27
  /**
@@ -54,7 +57,7 @@ type OwneySupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
54
57
  type OwneySupportedChains = (typeof SUPPORTED_CHAINS)[number];
55
58
  type OwneySupportedTokens = (typeof SUPPORTED_TOKENS)[number];
56
59
 
57
- type AgentId = "zyfai";
60
+ type AgentId = "zyfai" | "yieldseeker";
58
61
  type Asset = string;
59
62
  type AgentSupportedAsset = {
60
63
  readonly symbol: string;
@@ -65,6 +68,18 @@ type AgentSupportedAssets = {
65
68
  readonly chain?: string;
66
69
  readonly assets: readonly AgentSupportedAsset[];
67
70
  };
71
+ type AvailableAgent = {
72
+ id: AgentId;
73
+ isEnabled: boolean;
74
+ supportedChainIds: readonly number[];
75
+ supportedAssets: readonly AgentSupportedAssets[];
76
+ };
77
+ type AvailableAgentsOptions = {
78
+ chainId?: number;
79
+ asset?: Asset;
80
+ /** Disabled agents are omitted by default because they cannot accept funds. */
81
+ includeDisabled?: boolean;
82
+ };
68
83
  type DailyApyDays = "7D" | "14D" | "30D";
69
84
  type HistoryFilters = {
70
85
  fromDate?: string;
@@ -194,6 +209,8 @@ interface OwneyPosition {
194
209
  pool?: string;
195
210
  asset: string;
196
211
  amount: string;
212
+ /** Smallest-unit amount when the provider exposes it alongside `amount`. */
213
+ amountRaw?: string;
197
214
  apy?: number;
198
215
  tvl?: number;
199
216
  /** Pool liquidity. Prepared slot — Zyfai will add this to its portfolio
@@ -242,6 +259,12 @@ interface OwneyBalances {
242
259
  /** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
243
260
  totalBalanceAsset: string;
244
261
  agentBalances: Record<AgentId, AgentBalance>;
262
+ /**
263
+ * Per-agent read failures when an aggregate balance request returned only a
264
+ * partial result. Callers may display the successful balances, but funding
265
+ * operations must not interpret a missing agent as having a zero balance.
266
+ */
267
+ agentErrors?: Partial<Record<AgentId, string>>;
245
268
  }
246
269
  interface AgentEarnings {
247
270
  smartWallet: `0x${string}`;
@@ -275,6 +298,12 @@ interface OwneyAccountApy {
275
298
  totalApy: string;
276
299
  agentApy: Record<AgentId, AccountAgentApy>;
277
300
  apyByChainAndAsset: ApyByChainAndAsset;
301
+ /**
302
+ * Balance-weighted daily APY across the agents that returned a point for each
303
+ * date. The weights use the selected chain/asset balance when getAccountApy
304
+ * is asset-scoped, otherwise each agent's total balance.
305
+ */
306
+ history?: ApyHistoryPoint[];
278
307
  }
279
308
  interface AllocationAgentApy {
280
309
  /** Account-wide weighted APY for this agent, as a decimal string. */
@@ -373,8 +402,15 @@ interface IAgent {
373
402
  readonly id: string;
374
403
  readonly supportedChainIds: readonly OwneySupportedChainId[];
375
404
  readonly supportedAssets: readonly AgentSupportedAssets[];
405
+ /**
406
+ * Describes how `AgentBalance.tokens` relates to `positions`.
407
+ * Most adapters expose token totals that already include deployed positions.
408
+ * Providers such as Yieldseeker expose idle wallet tokens separately, so
409
+ * withdrawal planning must add matching position amounts.
410
+ */
411
+ readonly balanceComposition?: "tokens-include-positions" | "tokens-plus-positions";
376
412
  disconnect(): Promise<void>;
377
- activateAgent(state: ConnectionState, chainId: number): Promise<void>;
413
+ activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
378
414
  /**
379
415
  * Apply the organization's agent policy to this user's account.
380
416
  *
@@ -439,6 +475,7 @@ declare class OwneySDK {
439
475
  private orgAgentConfig;
440
476
  private orgAgentConfigPromise;
441
477
  private zyfaiRpcUrls?;
478
+ private yieldseekerApiBaseUrl?;
442
479
  private routingApiBaseUrl?;
443
480
  private referralSource?;
444
481
  private cachedSponsoredCallback;
@@ -511,6 +548,11 @@ declare class OwneySDK {
511
548
  private applyOrgPolicyTo;
512
549
  private ensureAgentsInitialized;
513
550
  private createAgent;
551
+ /**
552
+ * Discover the agents actually returned by routing for this organization.
553
+ * Consumers should use this instead of hardcoding a global agent roster.
554
+ */
555
+ getAvailableAgents(options?: AvailableAgentsOptions): Promise<AvailableAgent[]>;
514
556
  /**
515
557
  * Activate the user's smart wallet for the specified agents, or all chain-compatible agents if omitted.
516
558
  * Deploys the Safe contract and creates a session key if not already set up.
@@ -521,7 +563,7 @@ declare class OwneySDK {
521
563
  * If provided, ALL specified agents must support the chainId or the call
522
564
  * throws before activating any agent.
523
565
  */
524
- activateAgent(chainId: number, agentId?: AgentId[]): Promise<void>;
566
+ activateAgent(chainId: number, agentId?: AgentId[], asset?: OwneySupportedTokens): Promise<void>;
525
567
  /**
526
568
  * Activate agents ONE AT A TIME, each followed by its org policy.
527
569
  *
@@ -692,7 +734,92 @@ declare class OwneySDK {
692
734
  getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
693
735
  }
694
736
 
695
- 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_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" | "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";
737
+ type YieldseekerAuthDependencies = {
738
+ now?: () => Date;
739
+ nonce?: () => string;
740
+ };
741
+
742
+ type YieldseekerFetch = typeof fetch;
743
+
744
+ type YieldseekerTransaction = {
745
+ from: `0x${string}`;
746
+ to: `0x${string}`;
747
+ data: `0x${string}`;
748
+ value: string;
749
+ chainId: number;
750
+ };
751
+
752
+ type YieldseekerAgentOptions = {
753
+ baseUrl?: string;
754
+ fetchFn?: YieldseekerFetch;
755
+ auth?: YieldseekerAuthDependencies;
756
+ /** Test seam for the wallet-submission/receipt boundary. */
757
+ transactionExecutor?: (state: ConnectionState, chainId: number, transaction: YieldseekerTransaction) => Promise<Hex>;
758
+ /** Test seam for transactions submitted outside transactionExecutor. */
759
+ unwindReceiptWaiter?: (state: ConnectionState, chainId: number, transactionHash: Hex) => Promise<void>;
760
+ };
761
+ declare class YieldseekerAgent implements IAgent {
762
+ readonly id = "yieldseeker";
763
+ readonly balanceComposition: "tokens-plus-positions";
764
+ readonly supportedChainIds: readonly [8453];
765
+ readonly supportedAssets: readonly [{
766
+ readonly chainId: 8453;
767
+ readonly chain: "BASE";
768
+ readonly assets: readonly [{
769
+ readonly symbol: "USDC";
770
+ readonly minDepositAmount: "10000000";
771
+ }, {
772
+ readonly symbol: "WETH";
773
+ readonly minDepositAmount: "1";
774
+ }];
775
+ }];
776
+ private readonly api;
777
+ private readonly auth;
778
+ private readonly transactionExecutor?;
779
+ private readonly unwindReceiptWaiter?;
780
+ private readonly agentContexts;
781
+ private readonly users;
782
+ private readonly pendingAgents;
783
+ constructor(owneyApiKey: string, options?: YieldseekerAgentOptions);
784
+ disconnect(): Promise<void>;
785
+ activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
786
+ deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
787
+ withdraw(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, amount?: string): Promise<AgentWithdrawResult>;
788
+ getBalances(state: ConnectionState, chainId: number): Promise<AgentBalance>;
789
+ getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
790
+ getAccountApy(state: ConnectionState, chainId: number, days: DailyApyDays, tokenSymbol?: string): Promise<AccountAgentApy>;
791
+ getHistory(state: ConnectionState, chainId: number, options?: HistoryFilters): Promise<OwneyAgentHistory>;
792
+ getUserProfile(state: ConnectionState, chainId: number): Promise<AgentUserProfile>;
793
+ getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
794
+ private userKey;
795
+ private contextKey;
796
+ private resolveUser;
797
+ private forgetUser;
798
+ private ensureAgent;
799
+ private findAgent;
800
+ private resolveAgent;
801
+ private loadPortfolio;
802
+ private loadPortfolioContext;
803
+ private deployAfterFunding;
804
+ private refreshSnapshotAfterMovement;
805
+ private agentPath;
806
+ private walletRequest;
807
+ private providerRequest;
808
+ private mapApiError;
809
+ private submitTransaction;
810
+ private waitForReceipt;
811
+ private assertTransaction;
812
+ private assertAgent;
813
+ private isOwneyAgent;
814
+ private assetForAgent;
815
+ private isTransactionHash;
816
+ private assertChain;
817
+ private assertOptionalChain;
818
+ private assertAsset;
819
+ private invalidResponse;
820
+ }
821
+
822
+ 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_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" | "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";
696
823
  declare class OwneyError extends Error {
697
824
  readonly code: OwneyErrorCode;
698
825
  readonly details?: Record<string, unknown>;
@@ -758,4 +885,4 @@ type OwneySIWXConfig = {
758
885
  */
759
886
  declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
760
887
 
761
- 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 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 };
888
+ 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 };