@owney/sdk 0.6.0 → 0.6.2-beta.0
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 +2 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +2 -0
- 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
|
};
|
|
@@ -1875,6 +1876,7 @@ var OwneySDK = class {
|
|
|
1875
1876
|
}
|
|
1876
1877
|
return {
|
|
1877
1878
|
totalBalance: String(totalBalance),
|
|
1879
|
+
totalBalanceAsset: "usdc",
|
|
1878
1880
|
agentBalances: results
|
|
1879
1881
|
};
|
|
1880
1882
|
}
|
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 {
|
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 {
|
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
|
};
|
|
@@ -1847,6 +1848,7 @@ var OwneySDK = class {
|
|
|
1847
1848
|
}
|
|
1848
1849
|
return {
|
|
1849
1850
|
totalBalance: String(totalBalance),
|
|
1851
|
+
totalBalanceAsset: "usdc",
|
|
1850
1852
|
agentBalances: results
|
|
1851
1853
|
};
|
|
1852
1854
|
}
|