@owney/sdk 0.6.1-beta.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 +7 -5
- package/dist/index.d.cts +12 -7
- package/dist/index.d.ts +12 -7
- package/dist/index.js +7 -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
|
};
|
|
@@ -266,7 +267,7 @@ function mapWeightedApyByChain(raw) {
|
|
|
266
267
|
function mapApyHistory(raw) {
|
|
267
268
|
const history = Object.entries(raw.history ?? {}).map(([date, entry]) => ({
|
|
268
269
|
date,
|
|
269
|
-
apy: sumTokenValues(entry.
|
|
270
|
+
apy: sumTokenValues(entry.final_weighted_apy)
|
|
270
271
|
})).sort((a, b) => a.date.localeCompare(b.date));
|
|
271
272
|
return {
|
|
272
273
|
walletAddress: raw.walletAddress,
|
|
@@ -1880,6 +1881,7 @@ var OwneySDK = class {
|
|
|
1880
1881
|
}
|
|
1881
1882
|
return {
|
|
1882
1883
|
totalBalance: String(totalBalance),
|
|
1884
|
+
totalBalanceAsset: "usdc",
|
|
1883
1885
|
agentBalances: results
|
|
1884
1886
|
};
|
|
1885
1887
|
}
|
|
@@ -1987,17 +1989,17 @@ var OwneySDK = class {
|
|
|
1987
1989
|
* preserve the user's scroll position should keep using cursors from the
|
|
1988
1990
|
* original snapshot.
|
|
1989
1991
|
*
|
|
1990
|
-
* @param
|
|
1991
|
-
* @param
|
|
1992
|
+
* @param options.agentId - Optional. Agent to query. Omit for all active agents.
|
|
1993
|
+
* @param options.filters - Optional. Pagination + date filters.
|
|
1992
1994
|
* - `limit`: max entries per page (default 10)
|
|
1993
1995
|
* - `cursor`: opaque cursor returned by a previous call
|
|
1994
1996
|
* - `fromDate` / `toDate`: ISO 8601 date strings
|
|
1995
1997
|
* @returns {OwneyAgentHistory} `data` (up to `limit` entries), `hasMore`, `nextCursor`.
|
|
1996
1998
|
*/
|
|
1997
|
-
async getHistory(
|
|
1999
|
+
async getHistory(options) {
|
|
1998
2000
|
const state = this.requireState();
|
|
1999
2001
|
const chainId = this.requireChainId();
|
|
2000
|
-
const { agentId, filters } =
|
|
2002
|
+
const { agentId, filters } = options ?? {};
|
|
2001
2003
|
if (agentId) {
|
|
2002
2004
|
return this.getAgent(agentId).getHistory(state, chainId, filters);
|
|
2003
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 {
|
|
@@ -244,6 +248,9 @@ type AccountApyOptions = {
|
|
|
244
248
|
agentId?: AgentId;
|
|
245
249
|
days: DailyApyDays;
|
|
246
250
|
};
|
|
251
|
+
type AllocationApyOptions = {
|
|
252
|
+
agentId?: AgentId;
|
|
253
|
+
};
|
|
247
254
|
type AgentsApyOptions = {
|
|
248
255
|
agentId?: AgentId;
|
|
249
256
|
days: DailyApyDays;
|
|
@@ -394,14 +401,14 @@ declare class OwneySDK {
|
|
|
394
401
|
* preserve the user's scroll position should keep using cursors from the
|
|
395
402
|
* original snapshot.
|
|
396
403
|
*
|
|
397
|
-
* @param
|
|
398
|
-
* @param
|
|
404
|
+
* @param options.agentId - Optional. Agent to query. Omit for all active agents.
|
|
405
|
+
* @param options.filters - Optional. Pagination + date filters.
|
|
399
406
|
* - `limit`: max entries per page (default 10)
|
|
400
407
|
* - `cursor`: opaque cursor returned by a previous call
|
|
401
408
|
* - `fromDate` / `toDate`: ISO 8601 date strings
|
|
402
409
|
* @returns {OwneyAgentHistory} `data` (up to `limit` entries), `hasMore`, `nextCursor`.
|
|
403
410
|
*/
|
|
404
|
-
getHistory(
|
|
411
|
+
getHistory(options?: HistoryOptions): Promise<OwneyAgentHistory>;
|
|
405
412
|
/**
|
|
406
413
|
* Get the user's profile for a specific agent, or all agents.
|
|
407
414
|
* @param agentId - Optional. Agent to query. Omit for all agents.
|
|
@@ -428,9 +435,7 @@ declare class OwneySDK {
|
|
|
428
435
|
* @param options.agentId - Optional. Scope to one agent. Omit to aggregate
|
|
429
436
|
* positions across all active agents.
|
|
430
437
|
*/
|
|
431
|
-
getAllocationApy({ agentId, }?:
|
|
432
|
-
agentId?: AgentId;
|
|
433
|
-
}): Promise<OwneyAllocationApy>;
|
|
438
|
+
getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
|
|
434
439
|
}
|
|
435
440
|
|
|
436
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";
|
|
@@ -476,4 +481,4 @@ type OwneySIWXConfig = {
|
|
|
476
481
|
*/
|
|
477
482
|
declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
|
|
478
483
|
|
|
479
|
-
export { AccountAgentApy, AccountApyOptions, AgentApy, AgentApyDetails, AgentBalance, AgentChainIncompatibleError, AgentEarnings, AgentHistoryEntry, AgentHistoryPosition, AgentId, AgentNotFoundError, AgentSupportedAsset, AgentSupportedAssets, AgentUserProfile, AgentWithdrawResult, AgentsApyOptions, AllocationAgentApy, 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 };
|
|
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 {
|
|
@@ -244,6 +248,9 @@ type AccountApyOptions = {
|
|
|
244
248
|
agentId?: AgentId;
|
|
245
249
|
days: DailyApyDays;
|
|
246
250
|
};
|
|
251
|
+
type AllocationApyOptions = {
|
|
252
|
+
agentId?: AgentId;
|
|
253
|
+
};
|
|
247
254
|
type AgentsApyOptions = {
|
|
248
255
|
agentId?: AgentId;
|
|
249
256
|
days: DailyApyDays;
|
|
@@ -394,14 +401,14 @@ declare class OwneySDK {
|
|
|
394
401
|
* preserve the user's scroll position should keep using cursors from the
|
|
395
402
|
* original snapshot.
|
|
396
403
|
*
|
|
397
|
-
* @param
|
|
398
|
-
* @param
|
|
404
|
+
* @param options.agentId - Optional. Agent to query. Omit for all active agents.
|
|
405
|
+
* @param options.filters - Optional. Pagination + date filters.
|
|
399
406
|
* - `limit`: max entries per page (default 10)
|
|
400
407
|
* - `cursor`: opaque cursor returned by a previous call
|
|
401
408
|
* - `fromDate` / `toDate`: ISO 8601 date strings
|
|
402
409
|
* @returns {OwneyAgentHistory} `data` (up to `limit` entries), `hasMore`, `nextCursor`.
|
|
403
410
|
*/
|
|
404
|
-
getHistory(
|
|
411
|
+
getHistory(options?: HistoryOptions): Promise<OwneyAgentHistory>;
|
|
405
412
|
/**
|
|
406
413
|
* Get the user's profile for a specific agent, or all agents.
|
|
407
414
|
* @param agentId - Optional. Agent to query. Omit for all agents.
|
|
@@ -428,9 +435,7 @@ declare class OwneySDK {
|
|
|
428
435
|
* @param options.agentId - Optional. Scope to one agent. Omit to aggregate
|
|
429
436
|
* positions across all active agents.
|
|
430
437
|
*/
|
|
431
|
-
getAllocationApy({ agentId, }?:
|
|
432
|
-
agentId?: AgentId;
|
|
433
|
-
}): Promise<OwneyAllocationApy>;
|
|
438
|
+
getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
|
|
434
439
|
}
|
|
435
440
|
|
|
436
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";
|
|
@@ -476,4 +481,4 @@ type OwneySIWXConfig = {
|
|
|
476
481
|
*/
|
|
477
482
|
declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
|
|
478
483
|
|
|
479
|
-
export { AccountAgentApy, AccountApyOptions, AgentApy, AgentApyDetails, AgentBalance, AgentChainIncompatibleError, AgentEarnings, AgentHistoryEntry, AgentHistoryPosition, AgentId, AgentNotFoundError, AgentSupportedAsset, AgentSupportedAssets, AgentUserProfile, AgentWithdrawResult, AgentsApyOptions, AllocationAgentApy, 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 };
|
|
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
|
};
|
|
@@ -234,7 +235,7 @@ function mapWeightedApyByChain(raw) {
|
|
|
234
235
|
function mapApyHistory(raw) {
|
|
235
236
|
const history = Object.entries(raw.history ?? {}).map(([date, entry]) => ({
|
|
236
237
|
date,
|
|
237
|
-
apy: sumTokenValues(entry.
|
|
238
|
+
apy: sumTokenValues(entry.final_weighted_apy)
|
|
238
239
|
})).sort((a, b) => a.date.localeCompare(b.date));
|
|
239
240
|
return {
|
|
240
241
|
walletAddress: raw.walletAddress,
|
|
@@ -1852,6 +1853,7 @@ var OwneySDK = class {
|
|
|
1852
1853
|
}
|
|
1853
1854
|
return {
|
|
1854
1855
|
totalBalance: String(totalBalance),
|
|
1856
|
+
totalBalanceAsset: "usdc",
|
|
1855
1857
|
agentBalances: results
|
|
1856
1858
|
};
|
|
1857
1859
|
}
|
|
@@ -1959,17 +1961,17 @@ var OwneySDK = class {
|
|
|
1959
1961
|
* preserve the user's scroll position should keep using cursors from the
|
|
1960
1962
|
* original snapshot.
|
|
1961
1963
|
*
|
|
1962
|
-
* @param
|
|
1963
|
-
* @param
|
|
1964
|
+
* @param options.agentId - Optional. Agent to query. Omit for all active agents.
|
|
1965
|
+
* @param options.filters - Optional. Pagination + date filters.
|
|
1964
1966
|
* - `limit`: max entries per page (default 10)
|
|
1965
1967
|
* - `cursor`: opaque cursor returned by a previous call
|
|
1966
1968
|
* - `fromDate` / `toDate`: ISO 8601 date strings
|
|
1967
1969
|
* @returns {OwneyAgentHistory} `data` (up to `limit` entries), `hasMore`, `nextCursor`.
|
|
1968
1970
|
*/
|
|
1969
|
-
async getHistory(
|
|
1971
|
+
async getHistory(options) {
|
|
1970
1972
|
const state = this.requireState();
|
|
1971
1973
|
const chainId = this.requireChainId();
|
|
1972
|
-
const { agentId, filters } =
|
|
1974
|
+
const { agentId, filters } = options ?? {};
|
|
1973
1975
|
if (agentId) {
|
|
1974
1976
|
return this.getAgent(agentId).getHistory(state, chainId, filters);
|
|
1975
1977
|
}
|