@owney/sdk 0.6.0-beta.0 → 0.6.0-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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @owney/sdk
2
2
 
3
- A TypeScript SDK for interacting with DeFi yield agents. Supports multiple agent backends (Zyfai, Sail) through a unified interface.
3
+ A TypeScript SDK for interacting with DeFi yield agents. Supports multiple agents through a unified interface.
4
4
 
5
5
  ## Installation
6
6
 
@@ -117,7 +117,7 @@ Activate the user's smart wallet for the specified agents, or all chain-compatib
117
117
 
118
118
  ```typescript
119
119
  // Activate specific agents on Base
120
- await sdk.activateAgent(8453, ["zyfai", "sail"]);
120
+ await sdk.activateAgent(8453, ["zyfai"]);
121
121
 
122
122
  // Activate all agents that support Arbitrum
123
123
  await sdk.activateAgent(42161);
@@ -159,8 +159,7 @@ const results = await sdk.deposit({
159
159
  return await transferTokens(smartWallet, amount);
160
160
  },
161
161
  });
162
- console.log(results.agentResults.zyfai.amount); // "50000000"
163
- console.log(results.agentResults.sail.amount); // "50000000"
162
+ console.log(results.agentResults.zyfai.amount); // "100000000"
164
163
  ```
165
164
 
166
165
  ### `withdraw(options)`
@@ -199,15 +198,13 @@ console.log(result.type); // "partial"
199
198
  console.log(result.amount); // "50000000"
200
199
 
201
200
  // Partial withdrawal split proportionally across all agents
202
- // e.g. zyfai=$5, sail=$2, amount=$4 → zyfai withdraws $3, sail withdraws $1
201
+ // e.g. zyfai=$5, amount=$4 -> zyfai withdraws $4
203
202
  const split = await sdk.withdraw({ asset: "USDC", amount: "4000000" });
204
- console.log(split.agentResult.zyfai.amount); // "3000000"
205
- console.log(split.agentResult.sail.amount); // "1000000"
203
+ console.log(split.agentResult.zyfai.amount); // "4000000"
206
204
 
207
205
  // Full withdrawal from all agents
208
206
  const results = await sdk.withdraw({ asset: "USDC" });
209
207
  console.log(results.agentResult.zyfai.type); // "full"
210
- console.log(results.agentResult.sail.type); // "full"
211
208
  ```
212
209
 
213
210
  ### `getBalances(agentId?)`
@@ -216,7 +213,7 @@ Get the user's balances for a specific agent, or aggregated across all agents.
216
213
 
217
214
  | Param | Type | Description |
218
215
  | --------- | ------------------------------ | ------------------------------------ |
219
- | `agentId` | `"zyfai" \| "sail"` (optional) | Agent to query. Omit for all agents. |
216
+ | `agentId` | `"zyfai"` (optional) | Agent to query. Omit for all agents. |
220
217
 
221
218
  Returns: `AgentBalance` (single agent) or `OwneyBalances` (all agents)
222
219
 
@@ -229,9 +226,8 @@ console.log(balance.tokens); // [{ chain: "BASE", chainId: 8453, asset: "USDC",
229
226
 
230
227
  // All agents
231
228
  const allBalances = await sdk.getBalances();
232
- console.log(allBalances.totalBalance); // "300.50"
229
+ console.log(allBalances.totalBalance); // "150.25"
233
230
  console.log(allBalances.agentBalances.zyfai.totalBalance); // "150.25"
234
- console.log(allBalances.agentBalances.sail.totalBalance); // "150.25"
235
231
  ```
236
232
 
237
233
  ### `getEarnings(agentId?)`
@@ -240,7 +236,7 @@ Get the user's on-chain earnings for a specific agent, or aggregated across all
240
236
 
241
237
  | Param | Type | Description |
242
238
  | --------- | ------------------------------ | ------------------------------------ |
243
- | `agentId` | `"zyfai" \| "sail"` (optional) | Agent to query. Omit for all agents. |
239
+ | `agentId` | `"zyfai"` (optional) | Agent to query. Omit for all agents. |
244
240
 
245
241
  Returns: `AgentEarnings` (single agent) or `OwneyEarnings` (all agents)
246
242
 
@@ -268,7 +264,7 @@ Get the weighted APY for the user's account. When querying all agents, the total
268
264
 
269
265
  | Param | Type | Description |
270
266
  | --------- | ------------------------------ | ------------------------------------------------ |
271
- | `agentId` | `"zyfai" \| "sail"` (optional) | Agent to query. Omit for balance-weighted total. |
267
+ | `agentId` | `"zyfai"` (optional) | Agent to query. Omit for balance-weighted total. |
272
268
  | `days` | `"7D" \| "14D" \| "30D"` | Lookback period |
273
269
 
274
270
  Returns: `AccountAgentApy` (single agent) or `OwneyAccountApy` (all agents)
@@ -287,7 +283,6 @@ console.log(apy.apyByChainAndAsset?.[8453]?.USDC); // 5.4
287
283
  const allApy = await sdk.getAccountApy({ days: "30D" });
288
284
  console.log(allApy.totalApy); // "5.6"
289
285
  console.log(allApy.agentApy.zyfai.weightedApyAfterFee); // 6.0
290
- console.log(allApy.agentApy.sail.weightedApyAfterFee); // 4.0
291
286
  // Per (chain, asset), balance-weighted across all agents.
292
287
  // Cells with 0/missing APY for a given agent are excluded from that cell.
293
288
  console.log(allApy.apyByChainAndAsset[8453]?.USDC); // 5.3
@@ -304,7 +299,7 @@ Results are **cursor-paginated**. The first call (no `cursor`) anchors a stable
304
299
 
305
300
  | Param | Type | Description |
306
301
  | ------------------ | ------------------------------ | -------------------------------------------------------- |
307
- | `agentId` | `"zyfai" \| "sail"` (optional) | Agent to query. Omit for all agents. |
302
+ | `agentId` | `"zyfai"` (optional) | Agent to query. Omit for all agents. |
308
303
  | `filters.fromDate` | `string` (optional) | Start date (`YYYY-MM-DD`) |
309
304
  | `filters.toDate` | `string` (optional) | End date (`YYYY-MM-DD`) |
310
305
  | `filters.limit` | `number` (optional) | Max entries returned per call. Defaults to `10`. |
@@ -336,7 +331,7 @@ console.log(history.data[0].rebalanceLog[0].status); // "success"
336
331
  // All agents (merged and sorted by date)
337
332
  const allHistory = await sdk.getHistory();
338
333
  console.log(allHistory.hasMore); // true | false
339
- console.log(allHistory.data[0].agent); // "sail" (most recent entry)
334
+ console.log(allHistory.data[0].agent); // "zyfai" (most recent entry)
340
335
  console.log(allHistory.data[0].action); // "Rebalance"
341
336
 
342
337
  // Paginate through all history (per-chain, anchored to a single snapshot)
@@ -351,44 +346,13 @@ do {
351
346
  } while (cursor);
352
347
  ```
353
348
 
354
- ### `pauseAgent(agentId)`
355
-
356
- Pause an agent's automated operations. The agent will stop rebalancing until resumed.
357
-
358
- | Param | Type | Description |
359
- | --------- | ------------------- | -------------- |
360
- | `agentId` | `"zyfai" \| "sail"` | Agent to pause |
361
-
362
- Returns: `OwneyAgentStatus`
363
-
364
- ```typescript
365
- const status = await sdk.pauseAgent("zyfai");
366
- console.log(status.success); // true
367
- ```
368
-
369
- ### `resumeAgent(agentId)`
370
-
371
- Resume an agent's automated operations.
372
-
373
- | Param | Type | Description |
374
- | --------- | ------------------- | --------------- |
375
- | `agentId` | `"zyfai" \| "sail"` | Agent to resume |
376
-
377
- Returns: `OwneyAgentStatus`
378
-
379
- ```typescript
380
- const status = await sdk.resumeAgent("zyfai");
381
- console.log(status.success); // true
382
- console.log(status.protocols); // ["aave", "compound"]
383
- ```
384
-
385
349
  ### `getUserProfile(agentId?)`
386
350
 
387
351
  Get the user's profile for a specific agent, or all agents.
388
352
 
389
353
  | Param | Type | Description |
390
354
  | --------- | ------------------------------ | ------------------------------------ |
391
- | `agentId` | `"zyfai" \| "sail"` (optional) | Agent to query. Omit for all agents. |
355
+ | `agentId` | `"zyfai"` (optional) | Agent to query. Omit for all agents. |
392
356
 
393
357
  Returns: `AgentUserProfile` (single agent) or `OwneyUserProfile` (all agents)
394
358
 
@@ -404,7 +368,6 @@ console.log(profile.protocols); // ["aave", "compound"]
404
368
  // All agents
405
369
  const allProfiles = await sdk.getUserProfile();
406
370
  console.log(allProfiles.agentUserProfile.zyfai.smartWallet); // "0x..."
407
- console.log(allProfiles.agentUserProfile.sail.smartWallet); // "0x..."
408
371
  ```
409
372
 
410
373
  ### `getAgentApy({ agentId?, days, tokenSymbol?, chainId? })`
@@ -413,14 +376,14 @@ Get the agent's average APY performance over a time period. Does not require a w
413
376
 
414
377
  | Param | Type | Description |
415
378
  | ------------- | ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
416
- | `agentId` | `"zyfai" \| "sail"` (optional) | Agent to query. Omit for all agents. |
379
+ | `agentId` | `"zyfai"` (optional) | Agent to query. Omit for all agents. |
417
380
  | `days` | `"7D" \| "14D" \| "30D"` | Lookback period |
418
- | `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. |
419
- | `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. |
381
+ | `tokenSymbol` | `string` (optional) | Asset symbol (e.g. `"USDC"`). Scopes the upstream request to a specific asset when the agent's backend supports it. |
382
+ | `chainId` | `number` (optional) | Chain id. Typically paired with `tokenSymbol` for per-asset+chain APY. |
420
383
 
421
384
  Returns: `AgentApy` (single agent) or `OwneyAgentApy` (all agents)
422
385
 
423
- Both agents populate `detailedApys.apyPerAsset` with a per-chain, per-token
386
+ The agent populates `detailedApys.apyPerAsset` with a per-chain, per-token
424
387
  breakdown when available. `tokenSymbol` / `chainId` only affect whether the
425
388
  upstream query is scoped — the breakdown is built from whatever the agent
426
389
  returns.
@@ -434,10 +397,8 @@ console.log(apy.detailedApys?.apyPerAsset[8453]?.USDC); // 8.7
434
397
  // All agents
435
398
  const allApy = await sdk.getAgentApy({ days: "30D" });
436
399
  console.log(allApy.agentApy.zyfai.averageApy); // 8.5
437
- console.log(allApy.agentApy.sail.averageApy); // 6.2
438
- console.log(allApy.agentApy.sail.detailedApys?.apyPerAsset[42161]?.USDT); // 6.4
439
400
 
440
- // Scope the upstream query to USDC on Base (Zyfai-aware; Sail ignores the filter)
401
+ // Scope the upstream query to USDC on Base
441
402
  const usdcBaseApy = await sdk.getAgentApy({
442
403
  days: "30D",
443
404
  tokenSymbol: "USDC",
@@ -454,7 +415,7 @@ Returns: `OwneyAgentAllocation`
454
415
 
455
416
  ```typescript
456
417
  const allocation = await sdk.getAgentAllocation();
457
- console.log(allocation.agentAllocation); // { zyfai: 75, sail: 25 }
418
+ console.log(allocation.agentAllocation); // { zyfai: 100 }
458
419
  ```
459
420
 
460
421
  ## Types
@@ -462,7 +423,7 @@ console.log(allocation.agentAllocation); // { zyfai: 75, sail: 25 }
462
423
  ### Configuration
463
424
 
464
425
  ```typescript
465
- type AgentId = "zyfai" | "sail";
426
+ type AgentId = "zyfai";
466
427
  type Asset = string;
467
428
  type DailyApyDays = "7D" | "14D" | "30D";
468
429
  type OwneySupportedChainId = 8453 | 42161;
@@ -639,12 +600,6 @@ interface OwneyAgentHistory {
639
600
  nextCursor?: string;
640
601
  }
641
602
 
642
- interface OwneyAgentStatus {
643
- success: boolean;
644
- strategy?: string;
645
- protocols?: string[];
646
- }
647
-
648
603
  interface AgentUserProfile {
649
604
  address: string;
650
605
  smartWallet: string;
@@ -738,7 +693,7 @@ type OwneyErrorCode =
738
693
  | "ASSET_NO_COMPATIBLE_AGENTS" // No agents support the asset on the active chain
739
694
  // Deposit
740
695
  | "DEPOSIT_AMOUNT_BELOW_MINIMUM" // Amount below an agent's required minimum deposit for the chain+asset
741
- | "DEPOSIT_CALLBACK_REQUIRED" // Sail agent requires a depositCallback
696
+ | "DEPOSIT_CALLBACK_REQUIRED" // Agent requires a depositCallback
742
697
  | "DEPOSIT_CALLBACK_INVALID" // depositCallback didn't return a tx hash
743
698
  | "DEPOSIT_NO_PERMITTED_TOKENS" // No permitted tokens available for deposit
744
699
  // Withdraw
@@ -750,8 +705,6 @@ type OwneyErrorCode =
750
705
  // API
751
706
  | "API_ROUTING_ERROR" // Routing API returned a non-OK HTTP status
752
707
  | "API_ROUTING_FAILED" // Routing API returned { success: false }
753
- | "API_SAIL_ERROR" // Sail API returned a non-OK HTTP status
754
- | "API_SAIL_TIMEOUT" // Sail API request timed out
755
708
  | "API_NO_AGENTS" // No supported agents returned by routing API
756
709
  // Aggregation
757
710
  | "BALANCE_ALL_FAILED" // All agents failed to return balances