@owney/sdk 0.7.17-beta.0 → 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;
@@ -186,11 +191,16 @@ interface OwneyMultiDepositResult {
186
191
  interface AgentWithdrawResult {
187
192
  txHash?: string;
188
193
  type: "full" | "partial";
194
+ /** Smallest-unit amount, or a provider sentinel such as "all" for a full request. */
189
195
  amount: string;
190
196
  }
191
197
  interface OwneyWithdrawResult {
192
198
  agentResult: Record<AgentId, AgentWithdrawResult>;
193
- totalWithdrawn: string;
199
+ /**
200
+ * Sum of reported smallest-unit amounts; null when a full withdrawal's
201
+ * amount is not yet known. An accepted request is not proof of settlement.
202
+ */
203
+ totalWithdrawn: string | null;
194
204
  }
195
205
  interface OwneyToken {
196
206
  chain: OwneySupportedChains;
@@ -206,6 +216,8 @@ interface OwneyPosition {
206
216
  pool?: string;
207
217
  asset: string;
208
218
  amount: string;
219
+ /** Smallest-unit amount when the provider exposes it alongside `amount`. */
220
+ amountRaw?: string;
209
221
  apy?: number;
210
222
  tvl?: number;
211
223
  /** Pool liquidity. Prepared slot — Zyfai will add this to its portfolio
@@ -236,10 +248,19 @@ interface OwneyPendingAllocation {
236
248
  since?: string;
237
249
  }
238
250
  interface AgentBalance {
251
+ /** Authoritative native balances per asset/network, including idle and invested funds. */
252
+ assetBalances?: OwneyToken[];
239
253
  smartWallet?: `0x${string}`;
240
254
  totalBalance: string;
241
255
  /** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
242
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";
243
264
  tokens: OwneyToken[];
244
265
  /**
245
266
  * Per-protocol/pool positions when the agent's portfolio payload includes
@@ -254,6 +275,14 @@ interface OwneyBalances {
254
275
  /** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
255
276
  totalBalanceAsset: string;
256
277
  agentBalances: Record<AgentId, AgentBalance>;
278
+ /**
279
+ * Per-agent read failures when an aggregate balance request returned only a
280
+ * partial result. Callers may display the successful balances, but funding
281
+ * operations must not interpret a missing agent as having a zero balance.
282
+ */
283
+ agentErrors?: Partial<Record<AgentId, string>>;
284
+ /** Absolute provider cooldown deadlines (Unix milliseconds). */
285
+ agentRetryAt?: Partial<Record<AgentId, number>>;
257
286
  }
258
287
  interface AgentEarnings {
259
288
  smartWallet: `0x${string}`;
@@ -287,6 +316,12 @@ interface OwneyAccountApy {
287
316
  totalApy: string;
288
317
  agentApy: Record<AgentId, AccountAgentApy>;
289
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[];
290
325
  }
291
326
  interface AllocationAgentApy {
292
327
  /** Account-wide weighted APY for this agent, as a decimal string. */
@@ -385,8 +420,15 @@ interface IAgent {
385
420
  readonly id: string;
386
421
  readonly supportedChainIds: readonly OwneySupportedChainId[];
387
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";
388
430
  disconnect(): Promise<void>;
389
- activateAgent(state: ConnectionState, chainId: number): Promise<void>;
431
+ activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
390
432
  /**
391
433
  * Apply the organization's agent policy to this user's account.
392
434
  *
@@ -451,6 +493,8 @@ declare class OwneySDK {
451
493
  private orgAgentConfig;
452
494
  private orgAgentConfigPromise;
453
495
  private zyfaiRpcUrls?;
496
+ private yieldseekerApiBaseUrl?;
497
+ private yieldseekerSiweOrigin?;
454
498
  private routingApiBaseUrl?;
455
499
  private referralSource?;
456
500
  private cachedSponsoredCallback;
@@ -541,7 +585,7 @@ declare class OwneySDK {
541
585
  * If provided, ALL specified agents must support the chainId or the call
542
586
  * throws before activating any agent.
543
587
  */
544
- activateAgent(chainId: number, agentId?: AgentId[]): Promise<void>;
588
+ activateAgent(chainId: number, agentId?: AgentId[], asset?: OwneySupportedTokens): Promise<void>;
545
589
  /**
546
590
  * Activate agents ONE AT A TIME, each followed by its org policy.
547
591
  *
@@ -556,9 +600,9 @@ declare class OwneySDK {
556
600
  * at a time anyway.
557
601
  *
558
602
  * Every agent is attempted even if an earlier one fails, so one declined
559
- * signature can't deny the remaining agents their turn. The first failure is
560
- * rethrown (matching the previous `Promise.all` rejection) once all agents
561
- * 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.
562
606
  */
563
607
  private activateAgentsInTurn;
564
608
  /**
@@ -603,6 +647,7 @@ declare class OwneySDK {
603
647
  private depositWithFallback;
604
648
  private getMinDepositAmount;
605
649
  private splitDepositAmount;
650
+ private formatAgentName;
606
651
  private validateMinDepositAmount;
607
652
  /**
608
653
  * Whether the user already holds a non-zero balance with `agent` for the
@@ -713,7 +758,93 @@ declare class OwneySDK {
713
758
  getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
714
759
  }
715
760
 
716
- 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";
717
848
  declare class OwneyError extends Error {
718
849
  readonly code: OwneyErrorCode;
719
850
  readonly details?: Record<string, unknown>;
@@ -779,4 +910,4 @@ type OwneySIWXConfig = {
779
910
  */
780
911
  declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
781
912
 
782
- 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;
@@ -186,11 +191,16 @@ interface OwneyMultiDepositResult {
186
191
  interface AgentWithdrawResult {
187
192
  txHash?: string;
188
193
  type: "full" | "partial";
194
+ /** Smallest-unit amount, or a provider sentinel such as "all" for a full request. */
189
195
  amount: string;
190
196
  }
191
197
  interface OwneyWithdrawResult {
192
198
  agentResult: Record<AgentId, AgentWithdrawResult>;
193
- totalWithdrawn: string;
199
+ /**
200
+ * Sum of reported smallest-unit amounts; null when a full withdrawal's
201
+ * amount is not yet known. An accepted request is not proof of settlement.
202
+ */
203
+ totalWithdrawn: string | null;
194
204
  }
195
205
  interface OwneyToken {
196
206
  chain: OwneySupportedChains;
@@ -206,6 +216,8 @@ interface OwneyPosition {
206
216
  pool?: string;
207
217
  asset: string;
208
218
  amount: string;
219
+ /** Smallest-unit amount when the provider exposes it alongside `amount`. */
220
+ amountRaw?: string;
209
221
  apy?: number;
210
222
  tvl?: number;
211
223
  /** Pool liquidity. Prepared slot — Zyfai will add this to its portfolio
@@ -236,10 +248,19 @@ interface OwneyPendingAllocation {
236
248
  since?: string;
237
249
  }
238
250
  interface AgentBalance {
251
+ /** Authoritative native balances per asset/network, including idle and invested funds. */
252
+ assetBalances?: OwneyToken[];
239
253
  smartWallet?: `0x${string}`;
240
254
  totalBalance: string;
241
255
  /** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
242
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";
243
264
  tokens: OwneyToken[];
244
265
  /**
245
266
  * Per-protocol/pool positions when the agent's portfolio payload includes
@@ -254,6 +275,14 @@ interface OwneyBalances {
254
275
  /** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
255
276
  totalBalanceAsset: string;
256
277
  agentBalances: Record<AgentId, AgentBalance>;
278
+ /**
279
+ * Per-agent read failures when an aggregate balance request returned only a
280
+ * partial result. Callers may display the successful balances, but funding
281
+ * operations must not interpret a missing agent as having a zero balance.
282
+ */
283
+ agentErrors?: Partial<Record<AgentId, string>>;
284
+ /** Absolute provider cooldown deadlines (Unix milliseconds). */
285
+ agentRetryAt?: Partial<Record<AgentId, number>>;
257
286
  }
258
287
  interface AgentEarnings {
259
288
  smartWallet: `0x${string}`;
@@ -287,6 +316,12 @@ interface OwneyAccountApy {
287
316
  totalApy: string;
288
317
  agentApy: Record<AgentId, AccountAgentApy>;
289
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[];
290
325
  }
291
326
  interface AllocationAgentApy {
292
327
  /** Account-wide weighted APY for this agent, as a decimal string. */
@@ -385,8 +420,15 @@ interface IAgent {
385
420
  readonly id: string;
386
421
  readonly supportedChainIds: readonly OwneySupportedChainId[];
387
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";
388
430
  disconnect(): Promise<void>;
389
- activateAgent(state: ConnectionState, chainId: number): Promise<void>;
431
+ activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
390
432
  /**
391
433
  * Apply the organization's agent policy to this user's account.
392
434
  *
@@ -451,6 +493,8 @@ declare class OwneySDK {
451
493
  private orgAgentConfig;
452
494
  private orgAgentConfigPromise;
453
495
  private zyfaiRpcUrls?;
496
+ private yieldseekerApiBaseUrl?;
497
+ private yieldseekerSiweOrigin?;
454
498
  private routingApiBaseUrl?;
455
499
  private referralSource?;
456
500
  private cachedSponsoredCallback;
@@ -541,7 +585,7 @@ declare class OwneySDK {
541
585
  * If provided, ALL specified agents must support the chainId or the call
542
586
  * throws before activating any agent.
543
587
  */
544
- activateAgent(chainId: number, agentId?: AgentId[]): Promise<void>;
588
+ activateAgent(chainId: number, agentId?: AgentId[], asset?: OwneySupportedTokens): Promise<void>;
545
589
  /**
546
590
  * Activate agents ONE AT A TIME, each followed by its org policy.
547
591
  *
@@ -556,9 +600,9 @@ declare class OwneySDK {
556
600
  * at a time anyway.
557
601
  *
558
602
  * Every agent is attempted even if an earlier one fails, so one declined
559
- * signature can't deny the remaining agents their turn. The first failure is
560
- * rethrown (matching the previous `Promise.all` rejection) once all agents
561
- * 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.
562
606
  */
563
607
  private activateAgentsInTurn;
564
608
  /**
@@ -603,6 +647,7 @@ declare class OwneySDK {
603
647
  private depositWithFallback;
604
648
  private getMinDepositAmount;
605
649
  private splitDepositAmount;
650
+ private formatAgentName;
606
651
  private validateMinDepositAmount;
607
652
  /**
608
653
  * Whether the user already holds a non-zero balance with `agent` for the
@@ -713,7 +758,93 @@ declare class OwneySDK {
713
758
  getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
714
759
  }
715
760
 
716
- 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";
717
848
  declare class OwneyError extends Error {
718
849
  readonly code: OwneyErrorCode;
719
850
  readonly details?: Record<string, unknown>;
@@ -779,4 +910,4 @@ type OwneySIWXConfig = {
779
910
  */
780
911
  declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
781
912
 
782
- 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 };