@owney/sdk 0.2.5 → 0.2.7

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
@@ -29,8 +29,18 @@ interface IAgent {
29
29
  pause(state: ConnectionState, chainId: number): Promise<OwneyAgentStatus>;
30
30
  resume(state: ConnectionState, chainId: number): Promise<OwneyAgentStatus>;
31
31
  getUserProfile(state: ConnectionState, chainId: number): Promise<AgentUserProfile>;
32
- getAgentApy(days: DailyApyDays): Promise<AgentApy>;
32
+ getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
33
33
  }
34
+ /**
35
+ * Optional filters for per-agent APY lookups.
36
+ * - `tokenSymbol` / `chainId` scope the APY to a specific asset+chain when
37
+ * the underlying provider supports it (Zyfai). Agents whose backends do
38
+ * not yet support per-asset APY (Sail) will ignore these options.
39
+ */
40
+ type AgentApyOptions = {
41
+ tokenSymbol?: string;
42
+ chainId?: number;
43
+ };
34
44
 
35
45
  type AgentId = "zyfai" | "sail";
36
46
  type Asset = string;
@@ -60,6 +70,17 @@ type AccountApyOptions = {
60
70
  type AgentsApyOptions = {
61
71
  agentId?: AgentId;
62
72
  days: DailyApyDays;
73
+ /**
74
+ * Optional asset symbol (e.g. "USDC", "WETH") to scope the APY to a
75
+ * specific asset+chain. Ignored by agents whose backends do not yet
76
+ * support per-asset APY.
77
+ */
78
+ tokenSymbol?: string;
79
+ /**
80
+ * Optional chain id for per-asset APY lookups. Typically paired with
81
+ * `tokenSymbol`.
82
+ */
83
+ chainId?: number;
63
84
  };
64
85
  type DepositOptions = {
65
86
  amount: string;
@@ -110,6 +131,7 @@ interface OwneyEarnings {
110
131
  interface AccountAgentApy {
111
132
  walletAddress: string;
112
133
  weightedApyAfterFee?: number;
134
+ weightedApyAfterFeeDetails?: AgentApyDetails;
113
135
  }
114
136
  interface OwneyAccountApy {
115
137
  totalApy: string;
@@ -158,8 +180,12 @@ interface AgentUserProfile {
158
180
  interface OwneyUserProfile {
159
181
  agentUserProfile: Record<AgentId, AgentUserProfile>;
160
182
  }
183
+ interface AgentApyDetails {
184
+ apyPerAsset: Partial<Record<OwneySupportedChainId, Partial<Record<OwneySupportedTokens, number>>>>;
185
+ }
161
186
  interface AgentApy {
162
187
  averageApy: number;
188
+ detailedApys?: AgentApyDetails;
163
189
  }
164
190
  interface OwneyAgentApy {
165
191
  agentApy: Record<AgentId, AgentApy>;
@@ -177,6 +203,7 @@ declare class OwneySDK {
177
203
  private activeAgents;
178
204
  private state;
179
205
  private apiKey;
206
+ private initializingAgentsPromise;
180
207
  constructor(config: OwneySDKConfig);
181
208
  /**
182
209
  * Establish connection state for all subsequent SDK calls.
@@ -203,6 +230,7 @@ declare class OwneySDK {
203
230
  private requireChainId;
204
231
  private getAgent;
205
232
  private getActiveAgents;
233
+ private ensureAgentsInitialized;
206
234
  /**
207
235
  * Activate the user's smart wallet for the specified agents, or all chain-compatible agents if omitted.
208
236
  * Deploys the Safe contract and creates a session key if not already set up.
@@ -291,9 +319,14 @@ declare class OwneySDK {
291
319
  * @param options - Contains agentId (optional) and days ("7D", "14D", or "30D")
292
320
  * @param options.agentId - Optional. Agent to query. Omit for all agents.
293
321
  * @param options.days - Lookback period: "7D", "14D", or "30D"
322
+ * @param options.tokenSymbol - Optional asset symbol ("USDC" / "WETH") to
323
+ * scope the APY to a specific asset+chain. Agents whose backends do not
324
+ * support per-asset APY (currently Sail) ignore this.
325
+ * @param options.chainId - Optional chain id for per-asset APY lookups.
326
+ * Typically paired with `tokenSymbol`.
294
327
  * @returns {AgentApy} for a single agent, or {OwneyAgentApy} with per-agent APY
295
328
  */
296
- getAgentApy({ agentId, days, }: AgentsApyOptions): Promise<OwneyAgentApy | AgentApy>;
329
+ getAgentApy({ agentId, days, tokenSymbol, chainId, }: AgentsApyOptions): Promise<OwneyAgentApy | AgentApy>;
297
330
  /**
298
331
  * Get the current fund allocation percentages across agents.
299
332
  * @returns Object with agent names as keys and allocation percentages as values
@@ -301,13 +334,19 @@ declare class OwneySDK {
301
334
  getAgentAllocation(): Promise<OwneyAgentAllocation>;
302
335
  }
303
336
 
304
- declare class AgentNotFoundError extends Error {
337
+ type OwneyErrorCode = "NOT_CONNECTED" | "NO_ACTIVE_CHAIN" | "WALLET_NO_ACCOUNTS" | "WALLET_ADDRESS_REQUIRED" | "AGENT_NOT_FOUND" | "AGENT_CHAIN_INCOMPATIBLE" | "AGENT_EMPTY_LIST" | "CHAIN_UNSUPPORTED" | "CHAIN_NO_COMPATIBLE_AGENTS" | "ASSET_UNSUPPORTED" | "ASSET_NO_COMPATIBLE_AGENTS" | "DEPOSIT_AMOUNT_TOO_SMALL" | "DEPOSIT_CALLBACK_REQUIRED" | "DEPOSIT_CALLBACK_INVALID" | "DEPOSIT_NO_PERMITTED_TOKENS" | "WITHDRAW_NO_PERMITTED_TOKENS" | "API_ROUTING_ERROR" | "API_ROUTING_FAILED" | "API_SAIL_ERROR" | "API_SAIL_TIMEOUT" | "API_NO_AGENTS" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
338
+ declare class OwneyError extends Error {
339
+ readonly code: OwneyErrorCode;
340
+ readonly details?: Record<string, unknown>;
341
+ constructor(code: OwneyErrorCode, message: string, details?: Record<string, unknown>);
342
+ }
343
+ declare class AgentNotFoundError extends OwneyError {
305
344
  constructor(agentId: string, available: string[]);
306
345
  }
307
- declare class NotConnectedError extends Error {
346
+ declare class NotConnectedError extends OwneyError {
308
347
  constructor();
309
348
  }
310
- declare class AgentChainIncompatibleError extends Error {
349
+ declare class AgentChainIncompatibleError extends OwneyError {
311
350
  readonly incompatibleAgents: Array<{
312
351
  agentId: string;
313
352
  supportedChainIds: readonly number[];
@@ -319,4 +358,4 @@ declare class AgentChainIncompatibleError extends Error {
319
358
  }>, connectedChainId: number);
320
359
  }
321
360
 
322
- export { AccountAgentApy, AccountApyOptions, AgentApy, AgentBalance, AgentChainIncompatibleError, AgentEarnings, AgentHistoryEntry, AgentId, AgentNotFoundError, AgentSupportedAssets, AgentUserProfile, AgentWithdrawResult, AgentsApyOptions, Asset, ConnectionState, DailyApyDays, DepositCallback, DepositOptions, HistoryAction, HistoryFilters, HistoryOptions, HistoryTransaction, IAgent, NotConnectedError, OwneyAccountApy, OwneyAgentAllocation, OwneyAgentApy, OwneyAgentHistory, OwneyAgentStatus, OwneyBalances, OwneyDepositResult, OwneyEarnings, OwneyMultiDepositResult, OwneyRouteResponse, OwneySDK, OwneySDKConfig, OwneyToken, OwneyUserProfile, OwneyWithdrawResult, RebalanceLog, WithdrawOptions };
361
+ export { AccountAgentApy, AccountApyOptions, AgentApy, AgentApyDetails, AgentBalance, AgentChainIncompatibleError, AgentEarnings, AgentHistoryEntry, AgentId, AgentNotFoundError, AgentSupportedAssets, AgentUserProfile, AgentWithdrawResult, AgentsApyOptions, Asset, ConnectionState, DailyApyDays, DepositCallback, DepositOptions, HistoryAction, HistoryFilters, HistoryOptions, HistoryTransaction, IAgent, NotConnectedError, OwneyAccountApy, OwneyAgentAllocation, OwneyAgentApy, OwneyAgentHistory, OwneyAgentStatus, OwneyBalances, OwneyDepositResult, OwneyEarnings, OwneyError, OwneyErrorCode, OwneyMultiDepositResult, OwneyRouteResponse, OwneySDK, OwneySDKConfig, OwneyToken, OwneyUserProfile, OwneyWithdrawResult, RebalanceLog, WithdrawOptions };
package/dist/index.d.ts CHANGED
@@ -29,8 +29,18 @@ interface IAgent {
29
29
  pause(state: ConnectionState, chainId: number): Promise<OwneyAgentStatus>;
30
30
  resume(state: ConnectionState, chainId: number): Promise<OwneyAgentStatus>;
31
31
  getUserProfile(state: ConnectionState, chainId: number): Promise<AgentUserProfile>;
32
- getAgentApy(days: DailyApyDays): Promise<AgentApy>;
32
+ getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
33
33
  }
34
+ /**
35
+ * Optional filters for per-agent APY lookups.
36
+ * - `tokenSymbol` / `chainId` scope the APY to a specific asset+chain when
37
+ * the underlying provider supports it (Zyfai). Agents whose backends do
38
+ * not yet support per-asset APY (Sail) will ignore these options.
39
+ */
40
+ type AgentApyOptions = {
41
+ tokenSymbol?: string;
42
+ chainId?: number;
43
+ };
34
44
 
35
45
  type AgentId = "zyfai" | "sail";
36
46
  type Asset = string;
@@ -60,6 +70,17 @@ type AccountApyOptions = {
60
70
  type AgentsApyOptions = {
61
71
  agentId?: AgentId;
62
72
  days: DailyApyDays;
73
+ /**
74
+ * Optional asset symbol (e.g. "USDC", "WETH") to scope the APY to a
75
+ * specific asset+chain. Ignored by agents whose backends do not yet
76
+ * support per-asset APY.
77
+ */
78
+ tokenSymbol?: string;
79
+ /**
80
+ * Optional chain id for per-asset APY lookups. Typically paired with
81
+ * `tokenSymbol`.
82
+ */
83
+ chainId?: number;
63
84
  };
64
85
  type DepositOptions = {
65
86
  amount: string;
@@ -110,6 +131,7 @@ interface OwneyEarnings {
110
131
  interface AccountAgentApy {
111
132
  walletAddress: string;
112
133
  weightedApyAfterFee?: number;
134
+ weightedApyAfterFeeDetails?: AgentApyDetails;
113
135
  }
114
136
  interface OwneyAccountApy {
115
137
  totalApy: string;
@@ -158,8 +180,12 @@ interface AgentUserProfile {
158
180
  interface OwneyUserProfile {
159
181
  agentUserProfile: Record<AgentId, AgentUserProfile>;
160
182
  }
183
+ interface AgentApyDetails {
184
+ apyPerAsset: Partial<Record<OwneySupportedChainId, Partial<Record<OwneySupportedTokens, number>>>>;
185
+ }
161
186
  interface AgentApy {
162
187
  averageApy: number;
188
+ detailedApys?: AgentApyDetails;
163
189
  }
164
190
  interface OwneyAgentApy {
165
191
  agentApy: Record<AgentId, AgentApy>;
@@ -177,6 +203,7 @@ declare class OwneySDK {
177
203
  private activeAgents;
178
204
  private state;
179
205
  private apiKey;
206
+ private initializingAgentsPromise;
180
207
  constructor(config: OwneySDKConfig);
181
208
  /**
182
209
  * Establish connection state for all subsequent SDK calls.
@@ -203,6 +230,7 @@ declare class OwneySDK {
203
230
  private requireChainId;
204
231
  private getAgent;
205
232
  private getActiveAgents;
233
+ private ensureAgentsInitialized;
206
234
  /**
207
235
  * Activate the user's smart wallet for the specified agents, or all chain-compatible agents if omitted.
208
236
  * Deploys the Safe contract and creates a session key if not already set up.
@@ -291,9 +319,14 @@ declare class OwneySDK {
291
319
  * @param options - Contains agentId (optional) and days ("7D", "14D", or "30D")
292
320
  * @param options.agentId - Optional. Agent to query. Omit for all agents.
293
321
  * @param options.days - Lookback period: "7D", "14D", or "30D"
322
+ * @param options.tokenSymbol - Optional asset symbol ("USDC" / "WETH") to
323
+ * scope the APY to a specific asset+chain. Agents whose backends do not
324
+ * support per-asset APY (currently Sail) ignore this.
325
+ * @param options.chainId - Optional chain id for per-asset APY lookups.
326
+ * Typically paired with `tokenSymbol`.
294
327
  * @returns {AgentApy} for a single agent, or {OwneyAgentApy} with per-agent APY
295
328
  */
296
- getAgentApy({ agentId, days, }: AgentsApyOptions): Promise<OwneyAgentApy | AgentApy>;
329
+ getAgentApy({ agentId, days, tokenSymbol, chainId, }: AgentsApyOptions): Promise<OwneyAgentApy | AgentApy>;
297
330
  /**
298
331
  * Get the current fund allocation percentages across agents.
299
332
  * @returns Object with agent names as keys and allocation percentages as values
@@ -301,13 +334,19 @@ declare class OwneySDK {
301
334
  getAgentAllocation(): Promise<OwneyAgentAllocation>;
302
335
  }
303
336
 
304
- declare class AgentNotFoundError extends Error {
337
+ type OwneyErrorCode = "NOT_CONNECTED" | "NO_ACTIVE_CHAIN" | "WALLET_NO_ACCOUNTS" | "WALLET_ADDRESS_REQUIRED" | "AGENT_NOT_FOUND" | "AGENT_CHAIN_INCOMPATIBLE" | "AGENT_EMPTY_LIST" | "CHAIN_UNSUPPORTED" | "CHAIN_NO_COMPATIBLE_AGENTS" | "ASSET_UNSUPPORTED" | "ASSET_NO_COMPATIBLE_AGENTS" | "DEPOSIT_AMOUNT_TOO_SMALL" | "DEPOSIT_CALLBACK_REQUIRED" | "DEPOSIT_CALLBACK_INVALID" | "DEPOSIT_NO_PERMITTED_TOKENS" | "WITHDRAW_NO_PERMITTED_TOKENS" | "API_ROUTING_ERROR" | "API_ROUTING_FAILED" | "API_SAIL_ERROR" | "API_SAIL_TIMEOUT" | "API_NO_AGENTS" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
338
+ declare class OwneyError extends Error {
339
+ readonly code: OwneyErrorCode;
340
+ readonly details?: Record<string, unknown>;
341
+ constructor(code: OwneyErrorCode, message: string, details?: Record<string, unknown>);
342
+ }
343
+ declare class AgentNotFoundError extends OwneyError {
305
344
  constructor(agentId: string, available: string[]);
306
345
  }
307
- declare class NotConnectedError extends Error {
346
+ declare class NotConnectedError extends OwneyError {
308
347
  constructor();
309
348
  }
310
- declare class AgentChainIncompatibleError extends Error {
349
+ declare class AgentChainIncompatibleError extends OwneyError {
311
350
  readonly incompatibleAgents: Array<{
312
351
  agentId: string;
313
352
  supportedChainIds: readonly number[];
@@ -319,4 +358,4 @@ declare class AgentChainIncompatibleError extends Error {
319
358
  }>, connectedChainId: number);
320
359
  }
321
360
 
322
- export { AccountAgentApy, AccountApyOptions, AgentApy, AgentBalance, AgentChainIncompatibleError, AgentEarnings, AgentHistoryEntry, AgentId, AgentNotFoundError, AgentSupportedAssets, AgentUserProfile, AgentWithdrawResult, AgentsApyOptions, Asset, ConnectionState, DailyApyDays, DepositCallback, DepositOptions, HistoryAction, HistoryFilters, HistoryOptions, HistoryTransaction, IAgent, NotConnectedError, OwneyAccountApy, OwneyAgentAllocation, OwneyAgentApy, OwneyAgentHistory, OwneyAgentStatus, OwneyBalances, OwneyDepositResult, OwneyEarnings, OwneyMultiDepositResult, OwneyRouteResponse, OwneySDK, OwneySDKConfig, OwneyToken, OwneyUserProfile, OwneyWithdrawResult, RebalanceLog, WithdrawOptions };
361
+ export { AccountAgentApy, AccountApyOptions, AgentApy, AgentApyDetails, AgentBalance, AgentChainIncompatibleError, AgentEarnings, AgentHistoryEntry, AgentId, AgentNotFoundError, AgentSupportedAssets, AgentUserProfile, AgentWithdrawResult, AgentsApyOptions, Asset, ConnectionState, DailyApyDays, DepositCallback, DepositOptions, HistoryAction, HistoryFilters, HistoryOptions, HistoryTransaction, IAgent, NotConnectedError, OwneyAccountApy, OwneyAgentAllocation, OwneyAgentApy, OwneyAgentHistory, OwneyAgentStatus, OwneyBalances, OwneyDepositResult, OwneyEarnings, OwneyError, OwneyErrorCode, OwneyMultiDepositResult, OwneyRouteResponse, OwneySDK, OwneySDKConfig, OwneyToken, OwneyUserProfile, OwneyWithdrawResult, RebalanceLog, WithdrawOptions };