@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/README.md +33 -1
- package/dist/index.cjs +592 -163
- package/dist/index.d.cts +45 -6
- package/dist/index.d.ts +45 -6
- package/dist/index.js +591 -163
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -232,6 +232,8 @@ Returns: `AccountAgentApy` (single agent) or `OwneyAccountApy` (all agents)
|
|
|
232
232
|
const apy = await sdk.getAccountApy({ agentId: "zyfai", days: "30D" });
|
|
233
233
|
console.log(apy.walletAddress); // "0x..."
|
|
234
234
|
console.log(apy.weightedApyAfterFee); // 5.2
|
|
235
|
+
// Per chain + token breakdown, when the agent reports it
|
|
236
|
+
console.log(apy.weightedApyAfterFeeDetails?.apyPerAsset[8453]?.USDC); // 5.4
|
|
235
237
|
|
|
236
238
|
// All agents (balance-weighted)
|
|
237
239
|
const allApy = await sdk.getAccountApy({ days: "30D" });
|
|
@@ -336,7 +338,7 @@ console.log(allProfiles.agentUserProfile.zyfai.smartWallet); // "0x..."
|
|
|
336
338
|
console.log(allProfiles.agentUserProfile.sail.smartWallet); // "0x..."
|
|
337
339
|
```
|
|
338
340
|
|
|
339
|
-
### `getAgentApy({ agentId?, days })`
|
|
341
|
+
### `getAgentApy({ agentId?, days, tokenSymbol?, chainId? })`
|
|
340
342
|
|
|
341
343
|
Get the agent's average APY performance over a time period. Does not require a wallet connection.
|
|
342
344
|
|
|
@@ -344,18 +346,35 @@ Get the agent's average APY performance over a time period. Does not require a w
|
|
|
344
346
|
|-------|------|-------------|
|
|
345
347
|
| `agentId` | `"zyfai" \| "sail"` (optional) | Agent to query. Omit for all agents. |
|
|
346
348
|
| `days` | `"7D" \| "14D" \| "30D"` | Lookback period |
|
|
349
|
+
| `tokenSymbol` | `string` (optional) | Asset symbol (e.g. `"USDC"`, `"WETH"`). Scopes the upstream request to a specific asset when the agent's backend supports it. Zyfai forwards this; Sail currently ignores it at the API level. |
|
|
350
|
+
| `chainId` | `number` (optional) | Chain id. Typically paired with `tokenSymbol` for per-asset+chain APY. Zyfai forwards this; Sail currently ignores it at the API level. |
|
|
347
351
|
|
|
348
352
|
Returns: `AgentApy` (single agent) or `OwneyAgentApy` (all agents)
|
|
349
353
|
|
|
354
|
+
Both agents populate `detailedApys.apyPerAsset` with a per-chain, per-token
|
|
355
|
+
breakdown when available. `tokenSymbol` / `chainId` only affect whether the
|
|
356
|
+
upstream query is scoped — the breakdown is built from whatever the agent
|
|
357
|
+
returns.
|
|
358
|
+
|
|
350
359
|
```typescript
|
|
351
360
|
// Single agent
|
|
352
361
|
const apy = await sdk.getAgentApy({ agentId: "zyfai", days: "30D" });
|
|
353
362
|
console.log(apy.averageApy); // 8.5
|
|
363
|
+
console.log(apy.detailedApys?.apyPerAsset[8453]?.USDC); // 8.7
|
|
354
364
|
|
|
355
365
|
// All agents
|
|
356
366
|
const allApy = await sdk.getAgentApy({ days: "30D" });
|
|
357
367
|
console.log(allApy.agentApy.zyfai.averageApy); // 8.5
|
|
358
368
|
console.log(allApy.agentApy.sail.averageApy); // 6.2
|
|
369
|
+
console.log(allApy.agentApy.sail.detailedApys?.apyPerAsset[42161]?.USDT); // 6.4
|
|
370
|
+
|
|
371
|
+
// Scope the upstream query to USDC on Base (Zyfai-aware; Sail ignores the filter)
|
|
372
|
+
const usdcBaseApy = await sdk.getAgentApy({
|
|
373
|
+
days: "30D",
|
|
374
|
+
tokenSymbol: "USDC",
|
|
375
|
+
chainId: 8453,
|
|
376
|
+
});
|
|
377
|
+
console.log(usdcBaseApy.agentApy.zyfai.averageApy); // APY scoped to USDC on Base
|
|
359
378
|
```
|
|
360
379
|
|
|
361
380
|
### `getAgentAllocation()`
|
|
@@ -428,6 +447,8 @@ type AccountApyOptions = {
|
|
|
428
447
|
type AgentsApyOptions = {
|
|
429
448
|
agentId?: AgentId;
|
|
430
449
|
days: DailyApyDays;
|
|
450
|
+
tokenSymbol?: string; // e.g. "USDC", "WETH"
|
|
451
|
+
chainId?: number; // typically paired with tokenSymbol
|
|
431
452
|
};
|
|
432
453
|
```
|
|
433
454
|
|
|
@@ -485,6 +506,7 @@ interface OwneyEarnings {
|
|
|
485
506
|
interface AccountAgentApy {
|
|
486
507
|
walletAddress: string;
|
|
487
508
|
weightedApyAfterFee?: number;
|
|
509
|
+
weightedApyAfterFeeDetails?: AgentApyDetails;
|
|
488
510
|
}
|
|
489
511
|
|
|
490
512
|
interface OwneyAccountApy {
|
|
@@ -545,6 +567,16 @@ interface OwneyUserProfile {
|
|
|
545
567
|
|
|
546
568
|
interface AgentApy {
|
|
547
569
|
averageApy: number;
|
|
570
|
+
detailedApys?: AgentApyDetails;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
interface AgentApyDetails {
|
|
574
|
+
// Per-chain, per-token APY breakdown. Only populated for the chain/token
|
|
575
|
+
// pairs that appear in SupportedAssets — entries may be missing when the
|
|
576
|
+
// upstream agent doesn't report APY for a given chain or token.
|
|
577
|
+
apyPerAsset: Partial<
|
|
578
|
+
Record<OwneySupportedChainId, Partial<Record<OwneySupportedTokens, number>>>
|
|
579
|
+
>;
|
|
548
580
|
}
|
|
549
581
|
|
|
550
582
|
interface OwneyAgentApy {
|