@owney/sdk 0.6.1-beta.0 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -31
- package/dist/index.cjs +7 -10
- package/dist/index.d.cts +12 -19
- package/dist/index.d.ts +12 -19
- package/dist/index.js +7 -10
- 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,15 +265,10 @@ function mapWeightedApyByChain(raw) {
|
|
|
264
265
|
return Object.keys(out).length > 0 ? out : void 0;
|
|
265
266
|
}
|
|
266
267
|
function mapApyHistory(raw) {
|
|
267
|
-
const history = Object.entries(raw.history ?? {}).map(([date, entry]) => ({
|
|
268
|
-
date,
|
|
269
|
-
apy: sumTokenValues(entry.weighted_apy_after_fee)
|
|
270
|
-
})).sort((a, b) => a.date.localeCompare(b.date));
|
|
271
268
|
return {
|
|
272
269
|
walletAddress: raw.walletAddress,
|
|
273
270
|
weightedApyAfterFee: raw.weightedApyAfterFee ? sumTokenValues(raw.weightedApyAfterFee) : void 0,
|
|
274
|
-
apyByChainAndAsset: mapWeightedApyByChain(raw.weightedApyAfterFeeByChain)
|
|
275
|
-
history
|
|
271
|
+
apyByChainAndAsset: mapWeightedApyByChain(raw.weightedApyAfterFeeByChain)
|
|
276
272
|
};
|
|
277
273
|
}
|
|
278
274
|
function splitOpportunity(opportunity) {
|
|
@@ -1880,6 +1876,7 @@ var OwneySDK = class {
|
|
|
1880
1876
|
}
|
|
1881
1877
|
return {
|
|
1882
1878
|
totalBalance: String(totalBalance),
|
|
1879
|
+
totalBalanceAsset: "usdc",
|
|
1883
1880
|
agentBalances: results
|
|
1884
1881
|
};
|
|
1885
1882
|
}
|
|
@@ -1987,17 +1984,17 @@ var OwneySDK = class {
|
|
|
1987
1984
|
* preserve the user's scroll position should keep using cursors from the
|
|
1988
1985
|
* original snapshot.
|
|
1989
1986
|
*
|
|
1990
|
-
* @param
|
|
1991
|
-
* @param
|
|
1987
|
+
* @param options.agentId - Optional. Agent to query. Omit for all active agents.
|
|
1988
|
+
* @param options.filters - Optional. Pagination + date filters.
|
|
1992
1989
|
* - `limit`: max entries per page (default 10)
|
|
1993
1990
|
* - `cursor`: opaque cursor returned by a previous call
|
|
1994
1991
|
* - `fromDate` / `toDate`: ISO 8601 date strings
|
|
1995
1992
|
* @returns {OwneyAgentHistory} `data` (up to `limit` entries), `hasMore`, `nextCursor`.
|
|
1996
1993
|
*/
|
|
1997
|
-
async getHistory(
|
|
1994
|
+
async getHistory(options) {
|
|
1998
1995
|
const state = this.requireState();
|
|
1999
1996
|
const chainId = this.requireChainId();
|
|
2000
|
-
const { agentId, filters } =
|
|
1997
|
+
const { agentId, filters } = options ?? {};
|
|
2001
1998
|
if (agentId) {
|
|
2002
1999
|
return this.getAgent(agentId).getHistory(state, chainId, filters);
|
|
2003
2000
|
}
|
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,23 +86,11 @@ interface OwneyEarnings {
|
|
|
82
86
|
agentEarnings: Record<AgentId, AgentEarnings>;
|
|
83
87
|
}
|
|
84
88
|
type ApyByChainAndAsset = Partial<Record<OwneySupportedChainId, Partial<Record<OwneySupportedTokens, number>>>>;
|
|
85
|
-
/** A single day's net APY for the connected account, as a percentage number. */
|
|
86
|
-
interface ApyHistoryPoint {
|
|
87
|
-
/** ISO date string for the day, e.g. "2026-06-20". */
|
|
88
|
-
date: string;
|
|
89
|
-
/** Net (after-fee) weighted APY for that day, summed across tokens. */
|
|
90
|
-
apy: number;
|
|
91
|
-
}
|
|
92
89
|
interface AccountAgentApy {
|
|
93
90
|
walletAddress: string;
|
|
94
91
|
weightedApyAfterFee?: number;
|
|
95
92
|
weightedApyAfterFeeDetails?: AgentApyDetails;
|
|
96
93
|
apyByChainAndAsset?: ApyByChainAndAsset;
|
|
97
|
-
/**
|
|
98
|
-
* Daily net-APY series for the requested window (7D/14D/30D), ascending by
|
|
99
|
-
* date. Empty when the provider returns no daily history.
|
|
100
|
-
*/
|
|
101
|
-
history?: ApyHistoryPoint[];
|
|
102
94
|
}
|
|
103
95
|
interface OwneyAccountApy {
|
|
104
96
|
totalApy: string;
|
|
@@ -244,6 +236,9 @@ type AccountApyOptions = {
|
|
|
244
236
|
agentId?: AgentId;
|
|
245
237
|
days: DailyApyDays;
|
|
246
238
|
};
|
|
239
|
+
type AllocationApyOptions = {
|
|
240
|
+
agentId?: AgentId;
|
|
241
|
+
};
|
|
247
242
|
type AgentsApyOptions = {
|
|
248
243
|
agentId?: AgentId;
|
|
249
244
|
days: DailyApyDays;
|
|
@@ -394,14 +389,14 @@ declare class OwneySDK {
|
|
|
394
389
|
* preserve the user's scroll position should keep using cursors from the
|
|
395
390
|
* original snapshot.
|
|
396
391
|
*
|
|
397
|
-
* @param
|
|
398
|
-
* @param
|
|
392
|
+
* @param options.agentId - Optional. Agent to query. Omit for all active agents.
|
|
393
|
+
* @param options.filters - Optional. Pagination + date filters.
|
|
399
394
|
* - `limit`: max entries per page (default 10)
|
|
400
395
|
* - `cursor`: opaque cursor returned by a previous call
|
|
401
396
|
* - `fromDate` / `toDate`: ISO 8601 date strings
|
|
402
397
|
* @returns {OwneyAgentHistory} `data` (up to `limit` entries), `hasMore`, `nextCursor`.
|
|
403
398
|
*/
|
|
404
|
-
getHistory(
|
|
399
|
+
getHistory(options?: HistoryOptions): Promise<OwneyAgentHistory>;
|
|
405
400
|
/**
|
|
406
401
|
* Get the user's profile for a specific agent, or all agents.
|
|
407
402
|
* @param agentId - Optional. Agent to query. Omit for all agents.
|
|
@@ -428,9 +423,7 @@ declare class OwneySDK {
|
|
|
428
423
|
* @param options.agentId - Optional. Scope to one agent. Omit to aggregate
|
|
429
424
|
* positions across all active agents.
|
|
430
425
|
*/
|
|
431
|
-
getAllocationApy({ agentId, }?:
|
|
432
|
-
agentId?: AgentId;
|
|
433
|
-
}): Promise<OwneyAllocationApy>;
|
|
426
|
+
getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
|
|
434
427
|
}
|
|
435
428
|
|
|
436
429
|
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 +469,4 @@ type OwneySIWXConfig = {
|
|
|
476
469
|
*/
|
|
477
470
|
declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
|
|
478
471
|
|
|
479
|
-
export { AccountAgentApy, AccountApyOptions, AgentApy, AgentApyDetails, AgentBalance, AgentChainIncompatibleError, AgentEarnings, AgentHistoryEntry, AgentHistoryPosition, AgentId, AgentNotFoundError, AgentSupportedAsset, AgentSupportedAssets, AgentUserProfile, AgentWithdrawResult, AgentsApyOptions, AllocationAgentApy,
|
|
472
|
+
export { AccountAgentApy, AccountApyOptions, AgentApy, AgentApyDetails, AgentBalance, AgentChainIncompatibleError, AgentEarnings, AgentHistoryEntry, AgentHistoryPosition, AgentId, AgentNotFoundError, AgentSupportedAsset, AgentSupportedAssets, AgentUserProfile, AgentWithdrawResult, AgentsApyOptions, AllocationAgentApy, AllocationApyOptions, 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 };
|
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,23 +86,11 @@ interface OwneyEarnings {
|
|
|
82
86
|
agentEarnings: Record<AgentId, AgentEarnings>;
|
|
83
87
|
}
|
|
84
88
|
type ApyByChainAndAsset = Partial<Record<OwneySupportedChainId, Partial<Record<OwneySupportedTokens, number>>>>;
|
|
85
|
-
/** A single day's net APY for the connected account, as a percentage number. */
|
|
86
|
-
interface ApyHistoryPoint {
|
|
87
|
-
/** ISO date string for the day, e.g. "2026-06-20". */
|
|
88
|
-
date: string;
|
|
89
|
-
/** Net (after-fee) weighted APY for that day, summed across tokens. */
|
|
90
|
-
apy: number;
|
|
91
|
-
}
|
|
92
89
|
interface AccountAgentApy {
|
|
93
90
|
walletAddress: string;
|
|
94
91
|
weightedApyAfterFee?: number;
|
|
95
92
|
weightedApyAfterFeeDetails?: AgentApyDetails;
|
|
96
93
|
apyByChainAndAsset?: ApyByChainAndAsset;
|
|
97
|
-
/**
|
|
98
|
-
* Daily net-APY series for the requested window (7D/14D/30D), ascending by
|
|
99
|
-
* date. Empty when the provider returns no daily history.
|
|
100
|
-
*/
|
|
101
|
-
history?: ApyHistoryPoint[];
|
|
102
94
|
}
|
|
103
95
|
interface OwneyAccountApy {
|
|
104
96
|
totalApy: string;
|
|
@@ -244,6 +236,9 @@ type AccountApyOptions = {
|
|
|
244
236
|
agentId?: AgentId;
|
|
245
237
|
days: DailyApyDays;
|
|
246
238
|
};
|
|
239
|
+
type AllocationApyOptions = {
|
|
240
|
+
agentId?: AgentId;
|
|
241
|
+
};
|
|
247
242
|
type AgentsApyOptions = {
|
|
248
243
|
agentId?: AgentId;
|
|
249
244
|
days: DailyApyDays;
|
|
@@ -394,14 +389,14 @@ declare class OwneySDK {
|
|
|
394
389
|
* preserve the user's scroll position should keep using cursors from the
|
|
395
390
|
* original snapshot.
|
|
396
391
|
*
|
|
397
|
-
* @param
|
|
398
|
-
* @param
|
|
392
|
+
* @param options.agentId - Optional. Agent to query. Omit for all active agents.
|
|
393
|
+
* @param options.filters - Optional. Pagination + date filters.
|
|
399
394
|
* - `limit`: max entries per page (default 10)
|
|
400
395
|
* - `cursor`: opaque cursor returned by a previous call
|
|
401
396
|
* - `fromDate` / `toDate`: ISO 8601 date strings
|
|
402
397
|
* @returns {OwneyAgentHistory} `data` (up to `limit` entries), `hasMore`, `nextCursor`.
|
|
403
398
|
*/
|
|
404
|
-
getHistory(
|
|
399
|
+
getHistory(options?: HistoryOptions): Promise<OwneyAgentHistory>;
|
|
405
400
|
/**
|
|
406
401
|
* Get the user's profile for a specific agent, or all agents.
|
|
407
402
|
* @param agentId - Optional. Agent to query. Omit for all agents.
|
|
@@ -428,9 +423,7 @@ declare class OwneySDK {
|
|
|
428
423
|
* @param options.agentId - Optional. Scope to one agent. Omit to aggregate
|
|
429
424
|
* positions across all active agents.
|
|
430
425
|
*/
|
|
431
|
-
getAllocationApy({ agentId, }?:
|
|
432
|
-
agentId?: AgentId;
|
|
433
|
-
}): Promise<OwneyAllocationApy>;
|
|
426
|
+
getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
|
|
434
427
|
}
|
|
435
428
|
|
|
436
429
|
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 +469,4 @@ type OwneySIWXConfig = {
|
|
|
476
469
|
*/
|
|
477
470
|
declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
|
|
478
471
|
|
|
479
|
-
export { AccountAgentApy, AccountApyOptions, AgentApy, AgentApyDetails, AgentBalance, AgentChainIncompatibleError, AgentEarnings, AgentHistoryEntry, AgentHistoryPosition, AgentId, AgentNotFoundError, AgentSupportedAsset, AgentSupportedAssets, AgentUserProfile, AgentWithdrawResult, AgentsApyOptions, AllocationAgentApy,
|
|
472
|
+
export { AccountAgentApy, AccountApyOptions, AgentApy, AgentApyDetails, AgentBalance, AgentChainIncompatibleError, AgentEarnings, AgentHistoryEntry, AgentHistoryPosition, AgentId, AgentNotFoundError, AgentSupportedAsset, AgentSupportedAssets, AgentUserProfile, AgentWithdrawResult, AgentsApyOptions, AllocationAgentApy, AllocationApyOptions, 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 };
|
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,15 +233,10 @@ function mapWeightedApyByChain(raw) {
|
|
|
232
233
|
return Object.keys(out).length > 0 ? out : void 0;
|
|
233
234
|
}
|
|
234
235
|
function mapApyHistory(raw) {
|
|
235
|
-
const history = Object.entries(raw.history ?? {}).map(([date, entry]) => ({
|
|
236
|
-
date,
|
|
237
|
-
apy: sumTokenValues(entry.weighted_apy_after_fee)
|
|
238
|
-
})).sort((a, b) => a.date.localeCompare(b.date));
|
|
239
236
|
return {
|
|
240
237
|
walletAddress: raw.walletAddress,
|
|
241
238
|
weightedApyAfterFee: raw.weightedApyAfterFee ? sumTokenValues(raw.weightedApyAfterFee) : void 0,
|
|
242
|
-
apyByChainAndAsset: mapWeightedApyByChain(raw.weightedApyAfterFeeByChain)
|
|
243
|
-
history
|
|
239
|
+
apyByChainAndAsset: mapWeightedApyByChain(raw.weightedApyAfterFeeByChain)
|
|
244
240
|
};
|
|
245
241
|
}
|
|
246
242
|
function splitOpportunity(opportunity) {
|
|
@@ -1852,6 +1848,7 @@ var OwneySDK = class {
|
|
|
1852
1848
|
}
|
|
1853
1849
|
return {
|
|
1854
1850
|
totalBalance: String(totalBalance),
|
|
1851
|
+
totalBalanceAsset: "usdc",
|
|
1855
1852
|
agentBalances: results
|
|
1856
1853
|
};
|
|
1857
1854
|
}
|
|
@@ -1959,17 +1956,17 @@ var OwneySDK = class {
|
|
|
1959
1956
|
* preserve the user's scroll position should keep using cursors from the
|
|
1960
1957
|
* original snapshot.
|
|
1961
1958
|
*
|
|
1962
|
-
* @param
|
|
1963
|
-
* @param
|
|
1959
|
+
* @param options.agentId - Optional. Agent to query. Omit for all active agents.
|
|
1960
|
+
* @param options.filters - Optional. Pagination + date filters.
|
|
1964
1961
|
* - `limit`: max entries per page (default 10)
|
|
1965
1962
|
* - `cursor`: opaque cursor returned by a previous call
|
|
1966
1963
|
* - `fromDate` / `toDate`: ISO 8601 date strings
|
|
1967
1964
|
* @returns {OwneyAgentHistory} `data` (up to `limit` entries), `hasMore`, `nextCursor`.
|
|
1968
1965
|
*/
|
|
1969
|
-
async getHistory(
|
|
1966
|
+
async getHistory(options) {
|
|
1970
1967
|
const state = this.requireState();
|
|
1971
1968
|
const chainId = this.requireChainId();
|
|
1972
|
-
const { agentId, filters } =
|
|
1969
|
+
const { agentId, filters } = options ?? {};
|
|
1973
1970
|
if (agentId) {
|
|
1974
1971
|
return this.getAgent(agentId).getHistory(state, chainId, filters);
|
|
1975
1972
|
}
|