@owney/sdk 0.6.0 → 0.6.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -31
- package/dist/index.cjs +12 -5
- package/dist/index.d.cts +24 -7
- package/dist/index.d.ts +24 -7
- package/dist/index.js +12 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -211,9 +211,9 @@ console.log(results.agentResult.zyfai.type); // "full"
|
|
|
211
211
|
|
|
212
212
|
Get the user's balances for a specific agent, or aggregated across all agents.
|
|
213
213
|
|
|
214
|
-
| Param | Type
|
|
215
|
-
| --------- |
|
|
216
|
-
| `agentId` | `"zyfai"` (optional)
|
|
214
|
+
| Param | Type | Description |
|
|
215
|
+
| --------- | -------------------- | ------------------------------------ |
|
|
216
|
+
| `agentId` | `"zyfai"` (optional) | Agent to query. Omit for all agents. |
|
|
217
217
|
|
|
218
218
|
Returns: `AgentBalance` (single agent) or `OwneyBalances` (all agents)
|
|
219
219
|
|
|
@@ -221,22 +221,25 @@ Returns: `AgentBalance` (single agent) or `OwneyBalances` (all agents)
|
|
|
221
221
|
// Single agent
|
|
222
222
|
const balance = await sdk.getBalances("zyfai");
|
|
223
223
|
console.log(balance.totalBalance); // "150.25"
|
|
224
|
+
console.log(balance.totalBalanceAsset); // "usdc" — unit of totalBalance
|
|
224
225
|
console.log(balance.smartWallet); // "0x..."
|
|
225
226
|
console.log(balance.tokens); // [{ chain: "BASE", chainId: 8453, asset: "USDC", amount: "150.25" }]
|
|
226
227
|
|
|
227
228
|
// All agents
|
|
228
229
|
const allBalances = await sdk.getBalances();
|
|
229
230
|
console.log(allBalances.totalBalance); // "150.25"
|
|
231
|
+
console.log(allBalances.totalBalanceAsset); // "usdc" — unit of totalBalance
|
|
230
232
|
console.log(allBalances.agentBalances.zyfai.totalBalance); // "150.25"
|
|
233
|
+
console.log(allBalances.agentBalances.zyfai.totalBalanceAsset); // "usdc"
|
|
231
234
|
```
|
|
232
235
|
|
|
233
236
|
### `getEarnings(agentId?)`
|
|
234
237
|
|
|
235
238
|
Get the user's on-chain earnings for a specific agent, or aggregated across all agents.
|
|
236
239
|
|
|
237
|
-
| Param | Type
|
|
238
|
-
| --------- |
|
|
239
|
-
| `agentId` | `"zyfai"` (optional)
|
|
240
|
+
| Param | Type | Description |
|
|
241
|
+
| --------- | -------------------- | ------------------------------------ |
|
|
242
|
+
| `agentId` | `"zyfai"` (optional) | Agent to query. Omit for all agents. |
|
|
240
243
|
|
|
241
244
|
Returns: `AgentEarnings` (single agent) or `OwneyEarnings` (all agents)
|
|
242
245
|
|
|
@@ -262,10 +265,10 @@ console.log(allEarnings.agentEarnings.zyfai.tokens); // per-chain, per-asset bre
|
|
|
262
265
|
|
|
263
266
|
Get the weighted APY for the user's account. When querying all agents, the total APY is a balance-weighted average.
|
|
264
267
|
|
|
265
|
-
| Param | Type
|
|
266
|
-
| --------- |
|
|
267
|
-
| `agentId` | `"zyfai"` (optional)
|
|
268
|
-
| `days` | `"7D" \| "14D" \| "30D"`
|
|
268
|
+
| Param | Type | Description |
|
|
269
|
+
| --------- | ------------------------ | ------------------------------------------------ |
|
|
270
|
+
| `agentId` | `"zyfai"` (optional) | Agent to query. Omit for balance-weighted total. |
|
|
271
|
+
| `days` | `"7D" \| "14D" \| "30D"` | Lookback period |
|
|
269
272
|
|
|
270
273
|
Returns: `AccountAgentApy` (single agent) or `OwneyAccountApy` (all agents)
|
|
271
274
|
|
|
@@ -297,13 +300,13 @@ Results are **cursor-paginated**. The first call (no `cursor`) anchors a stable
|
|
|
297
300
|
|
|
298
301
|
> **Per-chain filtering:** The Zyfai backend no longer accepts a `chainId` filter directly. The SDK performs a bounded internal drain (up to 5 backend round-trips per logical page) to fill the requested `limit` with entries matching the active chain. This is transparent to callers — the `getHistory` API is unchanged.
|
|
299
302
|
|
|
300
|
-
| Param | Type
|
|
301
|
-
| ------------------ |
|
|
302
|
-
| `agentId` | `"zyfai"` (optional)
|
|
303
|
-
| `filters.fromDate` | `string` (optional)
|
|
304
|
-
| `filters.toDate` | `string` (optional)
|
|
305
|
-
| `filters.limit` | `number` (optional)
|
|
306
|
-
| `filters.cursor` | `string` (optional)
|
|
303
|
+
| Param | Type | Description |
|
|
304
|
+
| ------------------ | -------------------- | ------------------------------------------------------- |
|
|
305
|
+
| `agentId` | `"zyfai"` (optional) | Agent to query. Omit for all agents. |
|
|
306
|
+
| `filters.fromDate` | `string` (optional) | Start date (`YYYY-MM-DD`) |
|
|
307
|
+
| `filters.toDate` | `string` (optional) | End date (`YYYY-MM-DD`) |
|
|
308
|
+
| `filters.limit` | `number` (optional) | Max entries returned per call. Defaults to `10`. |
|
|
309
|
+
| `filters.cursor` | `string` (optional) | Opaque cursor returned by a previous `getHistory` call. |
|
|
307
310
|
|
|
308
311
|
Returns: `OwneyAgentHistory`
|
|
309
312
|
|
|
@@ -350,9 +353,9 @@ do {
|
|
|
350
353
|
|
|
351
354
|
Get the user's profile for a specific agent, or all agents.
|
|
352
355
|
|
|
353
|
-
| Param | Type
|
|
354
|
-
| --------- |
|
|
355
|
-
| `agentId` | `"zyfai"` (optional)
|
|
356
|
+
| Param | Type | Description |
|
|
357
|
+
| --------- | -------------------- | ------------------------------------ |
|
|
358
|
+
| `agentId` | `"zyfai"` (optional) | Agent to query. Omit for all agents. |
|
|
356
359
|
|
|
357
360
|
Returns: `AgentUserProfile` (single agent) or `OwneyUserProfile` (all agents)
|
|
358
361
|
|
|
@@ -374,16 +377,16 @@ console.log(allProfiles.agentUserProfile.zyfai.smartWallet); // "0x..."
|
|
|
374
377
|
|
|
375
378
|
Get the agent's average APY performance over a time period. Does not require a wallet connection.
|
|
376
379
|
|
|
377
|
-
| Param | Type
|
|
378
|
-
| ------------- |
|
|
379
|
-
| `agentId` | `"zyfai"` (optional)
|
|
380
|
-
| `days` | `"7D" \| "14D" \| "30D"`
|
|
381
|
-
| `tokenSymbol` | `string` (optional)
|
|
382
|
-
| `chainId` | `number` (optional)
|
|
380
|
+
| Param | Type | Description |
|
|
381
|
+
| ------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------- |
|
|
382
|
+
| `agentId` | `"zyfai"` (optional) | Agent to query. Omit for all agents. |
|
|
383
|
+
| `days` | `"7D" \| "14D" \| "30D"` | Lookback period |
|
|
384
|
+
| `tokenSymbol` | `string` (optional) | Asset symbol (e.g. `"USDC"`). Scopes the upstream request to a specific asset when the agent's backend supports it. |
|
|
385
|
+
| `chainId` | `number` (optional) | Chain id. Typically paired with `tokenSymbol` for per-asset+chain APY. |
|
|
383
386
|
|
|
384
387
|
Returns: `AgentApy` (single agent) or `OwneyAgentApy` (all agents)
|
|
385
388
|
|
|
386
|
-
|
|
389
|
+
The agent populates `detailedApys.apyPerAsset` with a per-chain, per-token
|
|
387
390
|
breakdown when available. `tokenSymbol` / `chainId` only affect whether the
|
|
388
391
|
upstream query is scoped — the breakdown is built from whatever the agent
|
|
389
392
|
returns.
|
|
@@ -518,11 +521,13 @@ interface OwneyToken {
|
|
|
518
521
|
interface AgentBalance {
|
|
519
522
|
smartWallet?: `0x${string}`;
|
|
520
523
|
totalBalance: string;
|
|
524
|
+
totalBalanceAsset: string; // unit of totalBalance, currently always "usdc"
|
|
521
525
|
tokens: OwneyToken[];
|
|
522
526
|
}
|
|
523
527
|
|
|
524
528
|
interface OwneyBalances {
|
|
525
529
|
totalBalance: string;
|
|
530
|
+
totalBalanceAsset: string; // unit of totalBalance, currently always "usdc"
|
|
526
531
|
agentBalances: Record<AgentId, AgentBalance>;
|
|
527
532
|
}
|
|
528
533
|
|
|
@@ -627,7 +632,7 @@ interface OwneyAgentApy {
|
|
|
627
632
|
type DepositCallback = (
|
|
628
633
|
smartWalletAddress: string,
|
|
629
634
|
chainId: number,
|
|
630
|
-
amount: string
|
|
635
|
+
amount: string,
|
|
631
636
|
) => Promise<`0x${string}`> | `0x${string}`;
|
|
632
637
|
```
|
|
633
638
|
|
|
@@ -740,9 +745,9 @@ try {
|
|
|
740
745
|
|
|
741
746
|
**Recovery:** catch `InvalidHistoryCursorError`, clear your stored cursor, and refetch from page 1.
|
|
742
747
|
|
|
743
|
-
| Class
|
|
744
|
-
|
|
|
745
|
-
| `InvalidHistoryCursorError`
|
|
748
|
+
| Class | `code` | Extends |
|
|
749
|
+
| --------------------------- | ------------------ | ------- |
|
|
750
|
+
| `InvalidHistoryCursorError` | `"invalid_cursor"` | `Error` |
|
|
746
751
|
|
|
747
752
|
## License
|
|
748
753
|
|
package/dist/index.cjs
CHANGED
|
@@ -210,6 +210,7 @@ function mapBalances(raw, _chainId, smartWallet) {
|
|
|
210
210
|
return {
|
|
211
211
|
smartWallet,
|
|
212
212
|
totalBalance: String(totalBalance),
|
|
213
|
+
totalBalanceAsset: "usdc",
|
|
213
214
|
tokens,
|
|
214
215
|
positions
|
|
215
216
|
};
|
|
@@ -264,10 +265,15 @@ function mapWeightedApyByChain(raw) {
|
|
|
264
265
|
return Object.keys(out).length > 0 ? out : void 0;
|
|
265
266
|
}
|
|
266
267
|
function mapApyHistory(raw) {
|
|
268
|
+
const history = Object.entries(raw.history ?? {}).map(([date, entry]) => ({
|
|
269
|
+
date,
|
|
270
|
+
apy: sumTokenValues(entry.final_weighted_apy)
|
|
271
|
+
})).sort((a, b) => a.date.localeCompare(b.date));
|
|
267
272
|
return {
|
|
268
273
|
walletAddress: raw.walletAddress,
|
|
269
274
|
weightedApyAfterFee: raw.weightedApyAfterFee ? sumTokenValues(raw.weightedApyAfterFee) : void 0,
|
|
270
|
-
apyByChainAndAsset: mapWeightedApyByChain(raw.weightedApyAfterFeeByChain)
|
|
275
|
+
apyByChainAndAsset: mapWeightedApyByChain(raw.weightedApyAfterFeeByChain),
|
|
276
|
+
history
|
|
271
277
|
};
|
|
272
278
|
}
|
|
273
279
|
function splitOpportunity(opportunity) {
|
|
@@ -1875,6 +1881,7 @@ var OwneySDK = class {
|
|
|
1875
1881
|
}
|
|
1876
1882
|
return {
|
|
1877
1883
|
totalBalance: String(totalBalance),
|
|
1884
|
+
totalBalanceAsset: "usdc",
|
|
1878
1885
|
agentBalances: results
|
|
1879
1886
|
};
|
|
1880
1887
|
}
|
|
@@ -1982,17 +1989,17 @@ var OwneySDK = class {
|
|
|
1982
1989
|
* preserve the user's scroll position should keep using cursors from the
|
|
1983
1990
|
* original snapshot.
|
|
1984
1991
|
*
|
|
1985
|
-
* @param
|
|
1986
|
-
* @param
|
|
1992
|
+
* @param options.agentId - Optional. Agent to query. Omit for all active agents.
|
|
1993
|
+
* @param options.filters - Optional. Pagination + date filters.
|
|
1987
1994
|
* - `limit`: max entries per page (default 10)
|
|
1988
1995
|
* - `cursor`: opaque cursor returned by a previous call
|
|
1989
1996
|
* - `fromDate` / `toDate`: ISO 8601 date strings
|
|
1990
1997
|
* @returns {OwneyAgentHistory} `data` (up to `limit` entries), `hasMore`, `nextCursor`.
|
|
1991
1998
|
*/
|
|
1992
|
-
async getHistory(
|
|
1999
|
+
async getHistory(options) {
|
|
1993
2000
|
const state = this.requireState();
|
|
1994
2001
|
const chainId = this.requireChainId();
|
|
1995
|
-
const { agentId, filters } =
|
|
2002
|
+
const { agentId, filters } = options ?? {};
|
|
1996
2003
|
if (agentId) {
|
|
1997
2004
|
return this.getAgent(agentId).getHistory(state, chainId, filters);
|
|
1998
2005
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -61,6 +61,8 @@ interface OwneyPosition {
|
|
|
61
61
|
interface AgentBalance {
|
|
62
62
|
smartWallet?: `0x${string}`;
|
|
63
63
|
totalBalance: string;
|
|
64
|
+
/** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
|
|
65
|
+
totalBalanceAsset: string;
|
|
64
66
|
tokens: OwneyToken[];
|
|
65
67
|
/**
|
|
66
68
|
* Per-protocol/pool positions when the agent's portfolio payload includes
|
|
@@ -70,6 +72,8 @@ interface AgentBalance {
|
|
|
70
72
|
}
|
|
71
73
|
interface OwneyBalances {
|
|
72
74
|
totalBalance: string;
|
|
75
|
+
/** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
|
|
76
|
+
totalBalanceAsset: string;
|
|
73
77
|
agentBalances: Record<AgentId, AgentBalance>;
|
|
74
78
|
}
|
|
75
79
|
interface AgentEarnings {
|
|
@@ -82,11 +86,23 @@ interface OwneyEarnings {
|
|
|
82
86
|
agentEarnings: Record<AgentId, AgentEarnings>;
|
|
83
87
|
}
|
|
84
88
|
type ApyByChainAndAsset = Partial<Record<OwneySupportedChainId, Partial<Record<OwneySupportedTokens, number>>>>;
|
|
89
|
+
/** A single day's net APY for the connected account, as a percentage number. */
|
|
90
|
+
interface ApyHistoryPoint {
|
|
91
|
+
/** ISO date string for the day, e.g. "2026-06-20". */
|
|
92
|
+
date: string;
|
|
93
|
+
/** Net (after-fee) weighted APY for that day, summed across tokens. */
|
|
94
|
+
apy: number;
|
|
95
|
+
}
|
|
85
96
|
interface AccountAgentApy {
|
|
86
97
|
walletAddress: string;
|
|
87
98
|
weightedApyAfterFee?: number;
|
|
88
99
|
weightedApyAfterFeeDetails?: AgentApyDetails;
|
|
89
100
|
apyByChainAndAsset?: ApyByChainAndAsset;
|
|
101
|
+
/**
|
|
102
|
+
* Daily net-APY series for the requested window (7D/14D/30D), ascending by
|
|
103
|
+
* date. Empty when the provider returns no daily history.
|
|
104
|
+
*/
|
|
105
|
+
history?: ApyHistoryPoint[];
|
|
90
106
|
}
|
|
91
107
|
interface OwneyAccountApy {
|
|
92
108
|
totalApy: string;
|
|
@@ -232,6 +248,9 @@ type AccountApyOptions = {
|
|
|
232
248
|
agentId?: AgentId;
|
|
233
249
|
days: DailyApyDays;
|
|
234
250
|
};
|
|
251
|
+
type AllocationApyOptions = {
|
|
252
|
+
agentId?: AgentId;
|
|
253
|
+
};
|
|
235
254
|
type AgentsApyOptions = {
|
|
236
255
|
agentId?: AgentId;
|
|
237
256
|
days: DailyApyDays;
|
|
@@ -382,14 +401,14 @@ declare class OwneySDK {
|
|
|
382
401
|
* preserve the user's scroll position should keep using cursors from the
|
|
383
402
|
* original snapshot.
|
|
384
403
|
*
|
|
385
|
-
* @param
|
|
386
|
-
* @param
|
|
404
|
+
* @param options.agentId - Optional. Agent to query. Omit for all active agents.
|
|
405
|
+
* @param options.filters - Optional. Pagination + date filters.
|
|
387
406
|
* - `limit`: max entries per page (default 10)
|
|
388
407
|
* - `cursor`: opaque cursor returned by a previous call
|
|
389
408
|
* - `fromDate` / `toDate`: ISO 8601 date strings
|
|
390
409
|
* @returns {OwneyAgentHistory} `data` (up to `limit` entries), `hasMore`, `nextCursor`.
|
|
391
410
|
*/
|
|
392
|
-
getHistory(
|
|
411
|
+
getHistory(options?: HistoryOptions): Promise<OwneyAgentHistory>;
|
|
393
412
|
/**
|
|
394
413
|
* Get the user's profile for a specific agent, or all agents.
|
|
395
414
|
* @param agentId - Optional. Agent to query. Omit for all agents.
|
|
@@ -416,9 +435,7 @@ declare class OwneySDK {
|
|
|
416
435
|
* @param options.agentId - Optional. Scope to one agent. Omit to aggregate
|
|
417
436
|
* positions across all active agents.
|
|
418
437
|
*/
|
|
419
|
-
getAllocationApy({ agentId, }?:
|
|
420
|
-
agentId?: AgentId;
|
|
421
|
-
}): Promise<OwneyAllocationApy>;
|
|
438
|
+
getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
|
|
422
439
|
}
|
|
423
440
|
|
|
424
441
|
type OwneyErrorCode = "NOT_CONNECTED" | "NO_ACTIVE_CHAIN" | "WALLET_NO_ACCOUNTS" | "WALLET_ADDRESS_REQUIRED" | "AGENT_NOT_FOUND" | "AGENT_CHAIN_INCOMPATIBLE" | "AGENT_EMPTY_LIST" | "AGENT_DISABLED" | "CHAIN_UNSUPPORTED" | "CHAIN_NO_COMPATIBLE_AGENTS" | "ASSET_UNSUPPORTED" | "ASSET_NO_COMPATIBLE_AGENTS" | "DEPOSIT_AMOUNT_BELOW_MINIMUM" | "DEPOSIT_CALLBACK_REQUIRED" | "DEPOSIT_CALLBACK_INVALID" | "DEPOSIT_NO_PERMITTED_TOKENS" | "WITHDRAW_NO_PERMITTED_TOKENS" | "WITHDRAW_INSUFFICIENT_BALANCE" | "WITHDRAW_ALL_FAILED" | "WITHDRAW_PARTIAL_FAILURE" | "WITHDRAW_FAILED" | "API_ROUTING_ERROR" | "API_ROUTING_FAILED" | "API_SAIL_ERROR" | "API_SAIL_TIMEOUT" | "API_NO_AGENTS" | "SPONSOR_REQUEST_FAILED" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
|
|
@@ -464,4 +481,4 @@ type OwneySIWXConfig = {
|
|
|
464
481
|
*/
|
|
465
482
|
declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
|
|
466
483
|
|
|
467
|
-
export { AccountAgentApy, AccountApyOptions, AgentApy, AgentApyDetails, AgentBalance, AgentChainIncompatibleError, AgentEarnings, AgentHistoryEntry, AgentHistoryPosition, AgentId, AgentNotFoundError, AgentSupportedAsset, AgentSupportedAssets, AgentUserProfile, AgentWithdrawResult, AgentsApyOptions, AllocationAgentApy, ApyByChainAndAsset, Asset, ConnectionState, DailyApyDays, DepositCallback, DepositOptions, HistoryAction, HistoryFilters, HistoryOptions, HistoryTransaction, IAgent, InvalidHistoryCursorError, NotConnectedError, OwneyAccountApy, OwneyAgentApy, OwneyAgentHistory, OwneyAllocationApy, OwneyBalances, OwneyDepositResult, OwneyEarnings, OwneyError, OwneyErrorCode, OwneyMultiDepositResult, OwneyPosition, OwneySDK, OwneySDKConfig, OwneySIWXConfig, OwneySupportedChainId, OwneySupportedChains, OwneySupportedTokens, OwneyToken, OwneyUserProfile, OwneyWithdrawResult, RebalanceLog, WithdrawOptions, createOwneySIWX };
|
|
484
|
+
export { AccountAgentApy, AccountApyOptions, AgentApy, AgentApyDetails, AgentBalance, AgentChainIncompatibleError, AgentEarnings, AgentHistoryEntry, AgentHistoryPosition, AgentId, AgentNotFoundError, AgentSupportedAsset, AgentSupportedAssets, AgentUserProfile, AgentWithdrawResult, AgentsApyOptions, AllocationAgentApy, AllocationApyOptions, ApyByChainAndAsset, ApyHistoryPoint, Asset, ConnectionState, DailyApyDays, DepositCallback, DepositOptions, HistoryAction, HistoryFilters, HistoryOptions, HistoryTransaction, IAgent, InvalidHistoryCursorError, NotConnectedError, OwneyAccountApy, OwneyAgentApy, OwneyAgentHistory, OwneyAllocationApy, OwneyBalances, OwneyDepositResult, OwneyEarnings, OwneyError, OwneyErrorCode, OwneyMultiDepositResult, OwneyPosition, OwneySDK, OwneySDKConfig, OwneySIWXConfig, OwneySupportedChainId, OwneySupportedChains, OwneySupportedTokens, OwneyToken, OwneyUserProfile, OwneyWithdrawResult, RebalanceLog, WithdrawOptions, createOwneySIWX };
|
package/dist/index.d.ts
CHANGED
|
@@ -61,6 +61,8 @@ interface OwneyPosition {
|
|
|
61
61
|
interface AgentBalance {
|
|
62
62
|
smartWallet?: `0x${string}`;
|
|
63
63
|
totalBalance: string;
|
|
64
|
+
/** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
|
|
65
|
+
totalBalanceAsset: string;
|
|
64
66
|
tokens: OwneyToken[];
|
|
65
67
|
/**
|
|
66
68
|
* Per-protocol/pool positions when the agent's portfolio payload includes
|
|
@@ -70,6 +72,8 @@ interface AgentBalance {
|
|
|
70
72
|
}
|
|
71
73
|
interface OwneyBalances {
|
|
72
74
|
totalBalance: string;
|
|
75
|
+
/** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
|
|
76
|
+
totalBalanceAsset: string;
|
|
73
77
|
agentBalances: Record<AgentId, AgentBalance>;
|
|
74
78
|
}
|
|
75
79
|
interface AgentEarnings {
|
|
@@ -82,11 +86,23 @@ interface OwneyEarnings {
|
|
|
82
86
|
agentEarnings: Record<AgentId, AgentEarnings>;
|
|
83
87
|
}
|
|
84
88
|
type ApyByChainAndAsset = Partial<Record<OwneySupportedChainId, Partial<Record<OwneySupportedTokens, number>>>>;
|
|
89
|
+
/** A single day's net APY for the connected account, as a percentage number. */
|
|
90
|
+
interface ApyHistoryPoint {
|
|
91
|
+
/** ISO date string for the day, e.g. "2026-06-20". */
|
|
92
|
+
date: string;
|
|
93
|
+
/** Net (after-fee) weighted APY for that day, summed across tokens. */
|
|
94
|
+
apy: number;
|
|
95
|
+
}
|
|
85
96
|
interface AccountAgentApy {
|
|
86
97
|
walletAddress: string;
|
|
87
98
|
weightedApyAfterFee?: number;
|
|
88
99
|
weightedApyAfterFeeDetails?: AgentApyDetails;
|
|
89
100
|
apyByChainAndAsset?: ApyByChainAndAsset;
|
|
101
|
+
/**
|
|
102
|
+
* Daily net-APY series for the requested window (7D/14D/30D), ascending by
|
|
103
|
+
* date. Empty when the provider returns no daily history.
|
|
104
|
+
*/
|
|
105
|
+
history?: ApyHistoryPoint[];
|
|
90
106
|
}
|
|
91
107
|
interface OwneyAccountApy {
|
|
92
108
|
totalApy: string;
|
|
@@ -232,6 +248,9 @@ type AccountApyOptions = {
|
|
|
232
248
|
agentId?: AgentId;
|
|
233
249
|
days: DailyApyDays;
|
|
234
250
|
};
|
|
251
|
+
type AllocationApyOptions = {
|
|
252
|
+
agentId?: AgentId;
|
|
253
|
+
};
|
|
235
254
|
type AgentsApyOptions = {
|
|
236
255
|
agentId?: AgentId;
|
|
237
256
|
days: DailyApyDays;
|
|
@@ -382,14 +401,14 @@ declare class OwneySDK {
|
|
|
382
401
|
* preserve the user's scroll position should keep using cursors from the
|
|
383
402
|
* original snapshot.
|
|
384
403
|
*
|
|
385
|
-
* @param
|
|
386
|
-
* @param
|
|
404
|
+
* @param options.agentId - Optional. Agent to query. Omit for all active agents.
|
|
405
|
+
* @param options.filters - Optional. Pagination + date filters.
|
|
387
406
|
* - `limit`: max entries per page (default 10)
|
|
388
407
|
* - `cursor`: opaque cursor returned by a previous call
|
|
389
408
|
* - `fromDate` / `toDate`: ISO 8601 date strings
|
|
390
409
|
* @returns {OwneyAgentHistory} `data` (up to `limit` entries), `hasMore`, `nextCursor`.
|
|
391
410
|
*/
|
|
392
|
-
getHistory(
|
|
411
|
+
getHistory(options?: HistoryOptions): Promise<OwneyAgentHistory>;
|
|
393
412
|
/**
|
|
394
413
|
* Get the user's profile for a specific agent, or all agents.
|
|
395
414
|
* @param agentId - Optional. Agent to query. Omit for all agents.
|
|
@@ -416,9 +435,7 @@ declare class OwneySDK {
|
|
|
416
435
|
* @param options.agentId - Optional. Scope to one agent. Omit to aggregate
|
|
417
436
|
* positions across all active agents.
|
|
418
437
|
*/
|
|
419
|
-
getAllocationApy({ agentId, }?:
|
|
420
|
-
agentId?: AgentId;
|
|
421
|
-
}): Promise<OwneyAllocationApy>;
|
|
438
|
+
getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
|
|
422
439
|
}
|
|
423
440
|
|
|
424
441
|
type OwneyErrorCode = "NOT_CONNECTED" | "NO_ACTIVE_CHAIN" | "WALLET_NO_ACCOUNTS" | "WALLET_ADDRESS_REQUIRED" | "AGENT_NOT_FOUND" | "AGENT_CHAIN_INCOMPATIBLE" | "AGENT_EMPTY_LIST" | "AGENT_DISABLED" | "CHAIN_UNSUPPORTED" | "CHAIN_NO_COMPATIBLE_AGENTS" | "ASSET_UNSUPPORTED" | "ASSET_NO_COMPATIBLE_AGENTS" | "DEPOSIT_AMOUNT_BELOW_MINIMUM" | "DEPOSIT_CALLBACK_REQUIRED" | "DEPOSIT_CALLBACK_INVALID" | "DEPOSIT_NO_PERMITTED_TOKENS" | "WITHDRAW_NO_PERMITTED_TOKENS" | "WITHDRAW_INSUFFICIENT_BALANCE" | "WITHDRAW_ALL_FAILED" | "WITHDRAW_PARTIAL_FAILURE" | "WITHDRAW_FAILED" | "API_ROUTING_ERROR" | "API_ROUTING_FAILED" | "API_SAIL_ERROR" | "API_SAIL_TIMEOUT" | "API_NO_AGENTS" | "SPONSOR_REQUEST_FAILED" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
|
|
@@ -464,4 +481,4 @@ type OwneySIWXConfig = {
|
|
|
464
481
|
*/
|
|
465
482
|
declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
|
|
466
483
|
|
|
467
|
-
export { AccountAgentApy, AccountApyOptions, AgentApy, AgentApyDetails, AgentBalance, AgentChainIncompatibleError, AgentEarnings, AgentHistoryEntry, AgentHistoryPosition, AgentId, AgentNotFoundError, AgentSupportedAsset, AgentSupportedAssets, AgentUserProfile, AgentWithdrawResult, AgentsApyOptions, AllocationAgentApy, ApyByChainAndAsset, Asset, ConnectionState, DailyApyDays, DepositCallback, DepositOptions, HistoryAction, HistoryFilters, HistoryOptions, HistoryTransaction, IAgent, InvalidHistoryCursorError, NotConnectedError, OwneyAccountApy, OwneyAgentApy, OwneyAgentHistory, OwneyAllocationApy, OwneyBalances, OwneyDepositResult, OwneyEarnings, OwneyError, OwneyErrorCode, OwneyMultiDepositResult, OwneyPosition, OwneySDK, OwneySDKConfig, OwneySIWXConfig, OwneySupportedChainId, OwneySupportedChains, OwneySupportedTokens, OwneyToken, OwneyUserProfile, OwneyWithdrawResult, RebalanceLog, WithdrawOptions, createOwneySIWX };
|
|
484
|
+
export { AccountAgentApy, AccountApyOptions, AgentApy, AgentApyDetails, AgentBalance, AgentChainIncompatibleError, AgentEarnings, AgentHistoryEntry, AgentHistoryPosition, AgentId, AgentNotFoundError, AgentSupportedAsset, AgentSupportedAssets, AgentUserProfile, AgentWithdrawResult, AgentsApyOptions, AllocationAgentApy, AllocationApyOptions, ApyByChainAndAsset, ApyHistoryPoint, Asset, ConnectionState, DailyApyDays, DepositCallback, DepositOptions, HistoryAction, HistoryFilters, HistoryOptions, HistoryTransaction, IAgent, InvalidHistoryCursorError, NotConnectedError, OwneyAccountApy, OwneyAgentApy, OwneyAgentHistory, OwneyAllocationApy, OwneyBalances, OwneyDepositResult, OwneyEarnings, OwneyError, OwneyErrorCode, OwneyMultiDepositResult, OwneyPosition, OwneySDK, OwneySDKConfig, OwneySIWXConfig, OwneySupportedChainId, OwneySupportedChains, OwneySupportedTokens, OwneyToken, OwneyUserProfile, OwneyWithdrawResult, RebalanceLog, WithdrawOptions, createOwneySIWX };
|
package/dist/index.js
CHANGED
|
@@ -178,6 +178,7 @@ function mapBalances(raw, _chainId, smartWallet) {
|
|
|
178
178
|
return {
|
|
179
179
|
smartWallet,
|
|
180
180
|
totalBalance: String(totalBalance),
|
|
181
|
+
totalBalanceAsset: "usdc",
|
|
181
182
|
tokens,
|
|
182
183
|
positions
|
|
183
184
|
};
|
|
@@ -232,10 +233,15 @@ function mapWeightedApyByChain(raw) {
|
|
|
232
233
|
return Object.keys(out).length > 0 ? out : void 0;
|
|
233
234
|
}
|
|
234
235
|
function mapApyHistory(raw) {
|
|
236
|
+
const history = Object.entries(raw.history ?? {}).map(([date, entry]) => ({
|
|
237
|
+
date,
|
|
238
|
+
apy: sumTokenValues(entry.final_weighted_apy)
|
|
239
|
+
})).sort((a, b) => a.date.localeCompare(b.date));
|
|
235
240
|
return {
|
|
236
241
|
walletAddress: raw.walletAddress,
|
|
237
242
|
weightedApyAfterFee: raw.weightedApyAfterFee ? sumTokenValues(raw.weightedApyAfterFee) : void 0,
|
|
238
|
-
apyByChainAndAsset: mapWeightedApyByChain(raw.weightedApyAfterFeeByChain)
|
|
243
|
+
apyByChainAndAsset: mapWeightedApyByChain(raw.weightedApyAfterFeeByChain),
|
|
244
|
+
history
|
|
239
245
|
};
|
|
240
246
|
}
|
|
241
247
|
function splitOpportunity(opportunity) {
|
|
@@ -1847,6 +1853,7 @@ var OwneySDK = class {
|
|
|
1847
1853
|
}
|
|
1848
1854
|
return {
|
|
1849
1855
|
totalBalance: String(totalBalance),
|
|
1856
|
+
totalBalanceAsset: "usdc",
|
|
1850
1857
|
agentBalances: results
|
|
1851
1858
|
};
|
|
1852
1859
|
}
|
|
@@ -1954,17 +1961,17 @@ var OwneySDK = class {
|
|
|
1954
1961
|
* preserve the user's scroll position should keep using cursors from the
|
|
1955
1962
|
* original snapshot.
|
|
1956
1963
|
*
|
|
1957
|
-
* @param
|
|
1958
|
-
* @param
|
|
1964
|
+
* @param options.agentId - Optional. Agent to query. Omit for all active agents.
|
|
1965
|
+
* @param options.filters - Optional. Pagination + date filters.
|
|
1959
1966
|
* - `limit`: max entries per page (default 10)
|
|
1960
1967
|
* - `cursor`: opaque cursor returned by a previous call
|
|
1961
1968
|
* - `fromDate` / `toDate`: ISO 8601 date strings
|
|
1962
1969
|
* @returns {OwneyAgentHistory} `data` (up to `limit` entries), `hasMore`, `nextCursor`.
|
|
1963
1970
|
*/
|
|
1964
|
-
async getHistory(
|
|
1971
|
+
async getHistory(options) {
|
|
1965
1972
|
const state = this.requireState();
|
|
1966
1973
|
const chainId = this.requireChainId();
|
|
1967
|
-
const { agentId, filters } =
|
|
1974
|
+
const { agentId, filters } = options ?? {};
|
|
1968
1975
|
if (agentId) {
|
|
1969
1976
|
return this.getAgent(agentId).getHistory(state, chainId, filters);
|
|
1970
1977
|
}
|