@owney/sdk 0.2.5
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 +584 -0
- package/dist/index.cjs +1465 -0
- package/dist/index.d.cts +322 -0
- package/dist/index.d.ts +322 -0
- package/dist/index.js +1435 -0
- package/package.json +30 -0
package/README.md
ADDED
|
@@ -0,0 +1,584 @@
|
|
|
1
|
+
# @owney/sdk
|
|
2
|
+
|
|
3
|
+
A TypeScript SDK for interacting with DeFi yield agents. Supports multiple agent backends (Zyfai, Sail) through a unified interface.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @owney/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { OwneySDK } from "@owney/sdk";
|
|
15
|
+
|
|
16
|
+
// Create the SDK instance
|
|
17
|
+
const sdk = new OwneySDK({ apiKey: "your-owney-api-key" });
|
|
18
|
+
|
|
19
|
+
// Connect with an EIP-1193 wallet provider
|
|
20
|
+
await sdk.connect(provider);
|
|
21
|
+
|
|
22
|
+
// Activate agents on Base (fetches agent keys on first call)
|
|
23
|
+
await sdk.activateAgent(8453);
|
|
24
|
+
|
|
25
|
+
// Get balances across all agents
|
|
26
|
+
const balances = await sdk.getBalances();
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## SDK Functions
|
|
30
|
+
|
|
31
|
+
### `new OwneySDK(config)`
|
|
32
|
+
|
|
33
|
+
Create a new SDK instance.
|
|
34
|
+
|
|
35
|
+
| Param | Type | Description |
|
|
36
|
+
|-------|------|-------------|
|
|
37
|
+
| `config.apiKey` | `string` | Your Owney API key, used to authenticate with the routing API and fetch agent-specific keys |
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { OwneySDK } from "@owney/sdk";
|
|
41
|
+
|
|
42
|
+
const sdk = new OwneySDK({ apiKey: "your-owney-api-key" });
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### `connect(provider)`
|
|
46
|
+
|
|
47
|
+
Establish connection state. Must be called before any wallet-dependent operation.
|
|
48
|
+
|
|
49
|
+
| Param | Type | Description |
|
|
50
|
+
|-------|------|-------------|
|
|
51
|
+
| `provider` | EIP-1193 provider | Wallet provider (e.g. MetaMask, WalletConnect) |
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
await sdk.connect(window.ethereum);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### `disconnect()`
|
|
58
|
+
|
|
59
|
+
Disconnect from all agents and clear connection state.
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
await sdk.disconnect();
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### `isConnected()`
|
|
66
|
+
|
|
67
|
+
Check if the SDK has an active connection.
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
if (sdk.isConnected()) {
|
|
71
|
+
// safe to call wallet-dependent methods
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### `getActiveChainId()`
|
|
76
|
+
|
|
77
|
+
Get the currently active chain ID, set by `activateAgent`.
|
|
78
|
+
|
|
79
|
+
Returns: `number | null`
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
const chainId = sdk.getActiveChainId();
|
|
83
|
+
if (chainId) {
|
|
84
|
+
console.log(`Active on chain ${chainId}`);
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### `activateAgent(chainId, agentId?)`
|
|
89
|
+
|
|
90
|
+
Activate the user's smart wallet for the specified agents, or all chain-compatible agents if omitted. Deploys the Safe contract and creates a session key if not already set up. Saves the chainId for use by all subsequent SDK calls.
|
|
91
|
+
|
|
92
|
+
| Param | Type | Description |
|
|
93
|
+
|-------|------|-------------|
|
|
94
|
+
| `chainId` | `number` | Target chain ID (e.g. `8453` for Base, `42161` for Arbitrum) |
|
|
95
|
+
| `agentId` | `AgentId[]` (optional) | Agents to activate. Omit to activate all agents that support the given chain. |
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
// Activate specific agents on Base
|
|
99
|
+
await sdk.activateAgent(8453, ["zyfai", "sail"]);
|
|
100
|
+
|
|
101
|
+
// Activate all agents that support Arbitrum
|
|
102
|
+
await sdk.activateAgent(42161);
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### `deposit(options)`
|
|
106
|
+
|
|
107
|
+
Deposit funds into a specific agent, or split equally across all agents if `agentId` is omitted. Validates that the asset is supported by the target agent(s) on the active chain. When splitting across agents, `depositCallback` is invoked once per agent with that agent's split amount and smart wallet address — expect multiple wallet prompts.
|
|
108
|
+
|
|
109
|
+
| Param | Type | Description |
|
|
110
|
+
|-------|------|-------------|
|
|
111
|
+
| `options.amount` | `string` | Amount in smallest unit (e.g. `"100000000"` for 100 USDC) |
|
|
112
|
+
| `options.asset` | `string` | Asset symbol (e.g. `"USDC"`) |
|
|
113
|
+
| `options.depositCallback` | `DepositCallback` | Callback that performs the token transfer and returns a tx hash |
|
|
114
|
+
| `options.agentId` | `AgentId` (optional) | Target agent. Omit to split equally across all agents. |
|
|
115
|
+
|
|
116
|
+
Returns: `OwneyDepositResult` (single agent) or `OwneyMultiDepositResult` (all agents)
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
// Deposit to a specific agent
|
|
120
|
+
const result = await sdk.deposit({
|
|
121
|
+
agentId: "zyfai",
|
|
122
|
+
amount: "100000000",
|
|
123
|
+
asset: "USDC",
|
|
124
|
+
depositCallback: async (smartWallet, chainId, amount) => {
|
|
125
|
+
const txHash = await transferTokens(smartWallet, amount);
|
|
126
|
+
return txHash;
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
console.log(result.txHash); // "0x..."
|
|
130
|
+
console.log(result.smartWallet); // "0x..."
|
|
131
|
+
console.log(result.amount); // "100000000"
|
|
132
|
+
|
|
133
|
+
// Split equally across all agents
|
|
134
|
+
const results = await sdk.deposit({
|
|
135
|
+
amount: "100000000",
|
|
136
|
+
asset: "USDC",
|
|
137
|
+
depositCallback: async (smartWallet, chainId, amount) => {
|
|
138
|
+
return await transferTokens(smartWallet, amount);
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
console.log(results.agentResults.zyfai.amount); // "50000000"
|
|
142
|
+
console.log(results.agentResults.sail.amount); // "50000000"
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### `withdraw(options)`
|
|
146
|
+
|
|
147
|
+
Withdraw funds from a specific agent, or all agents that support the active chain+asset if `agentId` is omitted. Validates that the asset is supported.
|
|
148
|
+
|
|
149
|
+
| Param | Type | Description |
|
|
150
|
+
|-------|------|-------------|
|
|
151
|
+
| `options.asset` | `string` | Asset symbol (e.g. `"USDC"`) |
|
|
152
|
+
| `options.amount` | `string` (optional) | Amount to withdraw. Omit for full withdrawal. |
|
|
153
|
+
| `options.agentId` | `AgentId` (optional) | Target agent. Omit to withdraw from all. |
|
|
154
|
+
|
|
155
|
+
Returns: `AgentWithdrawResult` (single agent) or `OwneyWithdrawResult` (all agents)
|
|
156
|
+
|
|
157
|
+
```typescript
|
|
158
|
+
// Partial withdrawal from one agent
|
|
159
|
+
const result = await sdk.withdraw({
|
|
160
|
+
asset: "USDC",
|
|
161
|
+
agentId: "zyfai",
|
|
162
|
+
amount: "50000000",
|
|
163
|
+
});
|
|
164
|
+
console.log(result.type); // "partial"
|
|
165
|
+
console.log(result.amount); // "50000000"
|
|
166
|
+
|
|
167
|
+
// Full withdrawal from all agents
|
|
168
|
+
const results = await sdk.withdraw({ asset: "USDC" });
|
|
169
|
+
console.log(results.agentResult.zyfai.type); // "full"
|
|
170
|
+
console.log(results.agentResult.sail.type); // "full"
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### `getBalances(agentId?)`
|
|
174
|
+
|
|
175
|
+
Get the user's balances for a specific agent, or aggregated across all agents.
|
|
176
|
+
|
|
177
|
+
| Param | Type | Description |
|
|
178
|
+
|-------|------|-------------|
|
|
179
|
+
| `agentId` | `"zyfai" \| "sail"` (optional) | Agent to query. Omit for all agents. |
|
|
180
|
+
|
|
181
|
+
Returns: `AgentBalance` (single agent) or `OwneyBalances` (all agents)
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
// Single agent
|
|
185
|
+
const balance = await sdk.getBalances("zyfai");
|
|
186
|
+
console.log(balance.totalBalance); // "150.25"
|
|
187
|
+
console.log(balance.smartWallet); // "0x..."
|
|
188
|
+
console.log(balance.tokens); // [{ chain: "BASE", chainId: 8453, asset: "USDC", amount: "150.25" }]
|
|
189
|
+
|
|
190
|
+
// All agents
|
|
191
|
+
const allBalances = await sdk.getBalances();
|
|
192
|
+
console.log(allBalances.totalBalance); // "300.50"
|
|
193
|
+
console.log(allBalances.agentBalances.zyfai.totalBalance); // "150.25"
|
|
194
|
+
console.log(allBalances.agentBalances.sail.totalBalance); // "150.25"
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### `getEarnings(agentId?)`
|
|
198
|
+
|
|
199
|
+
Get the user's on-chain earnings for a specific agent, or aggregated across all agents.
|
|
200
|
+
|
|
201
|
+
| Param | Type | Description |
|
|
202
|
+
|-------|------|-------------|
|
|
203
|
+
| `agentId` | `"zyfai" \| "sail"` (optional) | Agent to query. Omit for all agents. |
|
|
204
|
+
|
|
205
|
+
Returns: `AgentEarnings` (single agent) or `OwneyEarnings` (all agents)
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
// Single agent
|
|
209
|
+
const earnings = await sdk.getEarnings("zyfai");
|
|
210
|
+
console.log(earnings.smartWallet); // "0x..."
|
|
211
|
+
console.log(earnings.lifetimeEarnings); // 42.5
|
|
212
|
+
|
|
213
|
+
// All agents
|
|
214
|
+
const allEarnings = await sdk.getEarnings();
|
|
215
|
+
console.log(allEarnings.totalEarnings); // "85.0"
|
|
216
|
+
console.log(allEarnings.agentEarnings.zyfai.lifetimeEarnings); // 42.5
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### `getAccountApy({ agentId?, days })`
|
|
220
|
+
|
|
221
|
+
Get the weighted APY for the user's account. When querying all agents, the total APY is a balance-weighted average.
|
|
222
|
+
|
|
223
|
+
| Param | Type | Description |
|
|
224
|
+
|-------|------|-------------|
|
|
225
|
+
| `agentId` | `"zyfai" \| "sail"` (optional) | Agent to query. Omit for balance-weighted total. |
|
|
226
|
+
| `days` | `"7D" \| "14D" \| "30D"` | Lookback period |
|
|
227
|
+
|
|
228
|
+
Returns: `AccountAgentApy` (single agent) or `OwneyAccountApy` (all agents)
|
|
229
|
+
|
|
230
|
+
```typescript
|
|
231
|
+
// Single agent
|
|
232
|
+
const apy = await sdk.getAccountApy({ agentId: "zyfai", days: "30D" });
|
|
233
|
+
console.log(apy.walletAddress); // "0x..."
|
|
234
|
+
console.log(apy.weightedApyAfterFee); // 5.2
|
|
235
|
+
|
|
236
|
+
// All agents (balance-weighted)
|
|
237
|
+
const allApy = await sdk.getAccountApy({ days: "30D" });
|
|
238
|
+
console.log(allApy.totalApy); // "5.6"
|
|
239
|
+
console.log(allApy.agentApy.zyfai.weightedApyAfterFee); // 6.0
|
|
240
|
+
console.log(allApy.agentApy.sail.weightedApyAfterFee); // 4.0
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### `getHistory({ agentId?, filters? })`
|
|
244
|
+
|
|
245
|
+
Get transaction history for a specific agent, or all agents. When querying all agents, results are merged into a single list sorted by date (newest first). Each entry includes the originating `agent` and a `transactions` array with typed on-chain transaction details.
|
|
246
|
+
|
|
247
|
+
| Param | Type | Description |
|
|
248
|
+
|-------|------|-------------|
|
|
249
|
+
| `agentId` | `"zyfai" \| "sail"` (optional) | Agent to query. Omit for all agents. |
|
|
250
|
+
| `filters.fromDate` | `string` (optional) | Start date (`YYYY-MM-DD`) |
|
|
251
|
+
| `filters.toDate` | `string` (optional) | End date (`YYYY-MM-DD`) |
|
|
252
|
+
|
|
253
|
+
Returns: `OwneyAgentHistory`
|
|
254
|
+
|
|
255
|
+
```typescript
|
|
256
|
+
// Single agent with filters
|
|
257
|
+
const history = await sdk.getHistory({
|
|
258
|
+
agentId: "zyfai",
|
|
259
|
+
filters: { fromDate: "2025-01-01" },
|
|
260
|
+
});
|
|
261
|
+
console.log(history.total); // 42
|
|
262
|
+
console.log(history.data[0].agent); // "zyfai"
|
|
263
|
+
console.log(history.data[0].action); // "Rebalance"
|
|
264
|
+
console.log(history.data[0].date); // "2025-03-15T12:00:00Z"
|
|
265
|
+
console.log(history.data[0].transactions[0].txHashes); // ["0x..."]
|
|
266
|
+
console.log(history.data[0].transactions[0].amount); // "100.00"
|
|
267
|
+
console.log(history.data[0].transactions[0].tokenSymbol); // "USDC"
|
|
268
|
+
|
|
269
|
+
// Rebalance logs show fund movement between protocols
|
|
270
|
+
console.log(history.data[0].rebalanceLog[0].fromProtocol); // "Aave V3"
|
|
271
|
+
console.log(history.data[0].rebalanceLog[0].toProtocol); // "Morpho Blue"
|
|
272
|
+
console.log(history.data[0].rebalanceLog[0].tokenSymbol); // "USDC"
|
|
273
|
+
console.log(history.data[0].rebalanceLog[0].amount); // "100.00"
|
|
274
|
+
console.log(history.data[0].rebalanceLog[0].status); // "success"
|
|
275
|
+
|
|
276
|
+
// All agents (merged and sorted by date)
|
|
277
|
+
const allHistory = await sdk.getHistory();
|
|
278
|
+
console.log(allHistory.total); // 57
|
|
279
|
+
console.log(allHistory.data[0].agent); // "sail" (most recent entry)
|
|
280
|
+
console.log(allHistory.data[0].action); // "Rebalance"
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### `pauseAgent(agentId)`
|
|
284
|
+
|
|
285
|
+
Pause an agent's automated operations. The agent will stop rebalancing until resumed.
|
|
286
|
+
|
|
287
|
+
| Param | Type | Description |
|
|
288
|
+
|-------|------|-------------|
|
|
289
|
+
| `agentId` | `"zyfai" \| "sail"` | Agent to pause |
|
|
290
|
+
|
|
291
|
+
Returns: `OwneyAgentStatus`
|
|
292
|
+
|
|
293
|
+
```typescript
|
|
294
|
+
const status = await sdk.pauseAgent("zyfai");
|
|
295
|
+
console.log(status.success); // true
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### `resumeAgent(agentId)`
|
|
299
|
+
|
|
300
|
+
Resume an agent's automated operations.
|
|
301
|
+
|
|
302
|
+
| Param | Type | Description |
|
|
303
|
+
|-------|------|-------------|
|
|
304
|
+
| `agentId` | `"zyfai" \| "sail"` | Agent to resume |
|
|
305
|
+
|
|
306
|
+
Returns: `OwneyAgentStatus`
|
|
307
|
+
|
|
308
|
+
```typescript
|
|
309
|
+
const status = await sdk.resumeAgent("zyfai");
|
|
310
|
+
console.log(status.success); // true
|
|
311
|
+
console.log(status.protocols); // ["aave", "compound"]
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### `getUserProfile(agentId?)`
|
|
315
|
+
|
|
316
|
+
Get the user's profile for a specific agent, or all agents.
|
|
317
|
+
|
|
318
|
+
| Param | Type | Description |
|
|
319
|
+
|-------|------|-------------|
|
|
320
|
+
| `agentId` | `"zyfai" \| "sail"` (optional) | Agent to query. Omit for all agents. |
|
|
321
|
+
|
|
322
|
+
Returns: `AgentUserProfile` (single agent) or `OwneyUserProfile` (all agents)
|
|
323
|
+
|
|
324
|
+
```typescript
|
|
325
|
+
// Single agent
|
|
326
|
+
const profile = await sdk.getUserProfile("zyfai");
|
|
327
|
+
console.log(profile.address); // "0x..."
|
|
328
|
+
console.log(profile.smartWallet); // "0x..."
|
|
329
|
+
console.log(profile.chains); // [8453]
|
|
330
|
+
console.log(profile.hasActiveSessionKey); // true
|
|
331
|
+
console.log(profile.protocols); // ["aave", "compound"]
|
|
332
|
+
|
|
333
|
+
// All agents
|
|
334
|
+
const allProfiles = await sdk.getUserProfile();
|
|
335
|
+
console.log(allProfiles.agentUserProfile.zyfai.smartWallet); // "0x..."
|
|
336
|
+
console.log(allProfiles.agentUserProfile.sail.smartWallet); // "0x..."
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### `getAgentApy({ agentId?, days })`
|
|
340
|
+
|
|
341
|
+
Get the agent's average APY performance over a time period. Does not require a wallet connection.
|
|
342
|
+
|
|
343
|
+
| Param | Type | Description |
|
|
344
|
+
|-------|------|-------------|
|
|
345
|
+
| `agentId` | `"zyfai" \| "sail"` (optional) | Agent to query. Omit for all agents. |
|
|
346
|
+
| `days` | `"7D" \| "14D" \| "30D"` | Lookback period |
|
|
347
|
+
|
|
348
|
+
Returns: `AgentApy` (single agent) or `OwneyAgentApy` (all agents)
|
|
349
|
+
|
|
350
|
+
```typescript
|
|
351
|
+
// Single agent
|
|
352
|
+
const apy = await sdk.getAgentApy({ agentId: "zyfai", days: "30D" });
|
|
353
|
+
console.log(apy.averageApy); // 8.5
|
|
354
|
+
|
|
355
|
+
// All agents
|
|
356
|
+
const allApy = await sdk.getAgentApy({ days: "30D" });
|
|
357
|
+
console.log(allApy.agentApy.zyfai.averageApy); // 8.5
|
|
358
|
+
console.log(allApy.agentApy.sail.averageApy); // 6.2
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### `getAgentAllocation()`
|
|
362
|
+
|
|
363
|
+
Get the current fund allocation percentages across agents.
|
|
364
|
+
|
|
365
|
+
Returns: `OwneyAgentAllocation`
|
|
366
|
+
|
|
367
|
+
```typescript
|
|
368
|
+
const allocation = await sdk.getAgentAllocation();
|
|
369
|
+
console.log(allocation.agentAllocation); // { zyfai: 75, sail: 25 }
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
## Types
|
|
373
|
+
|
|
374
|
+
### Configuration
|
|
375
|
+
|
|
376
|
+
```typescript
|
|
377
|
+
type AgentId = "zyfai" | "sail";
|
|
378
|
+
type Asset = string;
|
|
379
|
+
type DailyApyDays = "7D" | "14D" | "30D";
|
|
380
|
+
type OwneySupportedChainId = 8453 | 42161;
|
|
381
|
+
type OwneySupportedChains = "BASE" | "ARBITRUM";
|
|
382
|
+
type OwneySupportedTokens = "USDC" | "USDT";
|
|
383
|
+
|
|
384
|
+
type AgentSupportedAssets = {
|
|
385
|
+
readonly chainId: number;
|
|
386
|
+
readonly chain?: string;
|
|
387
|
+
readonly assets: readonly string[];
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
interface OwneySDKConfig {
|
|
391
|
+
apiKey: string;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
interface ConnectionState {
|
|
395
|
+
provider: any;
|
|
396
|
+
walletAddress: `0x${string}`;
|
|
397
|
+
chainId: number | null;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
type HistoryFilters = {
|
|
401
|
+
fromDate?: string; // YYYY-MM-DD
|
|
402
|
+
toDate?: string; // YYYY-MM-DD
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
type HistoryOptions = {
|
|
406
|
+
agentId?: AgentId;
|
|
407
|
+
filters?: HistoryFilters;
|
|
408
|
+
};
|
|
409
|
+
|
|
410
|
+
type DepositOptions = {
|
|
411
|
+
amount: string;
|
|
412
|
+
asset: Asset;
|
|
413
|
+
depositCallback: DepositCallback;
|
|
414
|
+
agentId?: AgentId;
|
|
415
|
+
};
|
|
416
|
+
|
|
417
|
+
type WithdrawOptions = {
|
|
418
|
+
asset: Asset;
|
|
419
|
+
amount?: string;
|
|
420
|
+
agentId?: AgentId;
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
type AccountApyOptions = {
|
|
424
|
+
agentId?: AgentId;
|
|
425
|
+
days: DailyApyDays;
|
|
426
|
+
};
|
|
427
|
+
|
|
428
|
+
type AgentsApyOptions = {
|
|
429
|
+
agentId?: AgentId;
|
|
430
|
+
days: DailyApyDays;
|
|
431
|
+
};
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
### Response Types
|
|
435
|
+
|
|
436
|
+
```typescript
|
|
437
|
+
interface OwneyDepositResult {
|
|
438
|
+
txHash: string;
|
|
439
|
+
smartWallet: string;
|
|
440
|
+
amount: string;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
interface OwneyMultiDepositResult {
|
|
444
|
+
agentResults: Record<string, OwneyDepositResult>;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
interface AgentWithdrawResult {
|
|
448
|
+
txHash?: string;
|
|
449
|
+
type: "full" | "partial";
|
|
450
|
+
amount: string;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
interface OwneyWithdrawResult {
|
|
454
|
+
agentResult: Record<AgentId, AgentWithdrawResult>;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
interface OwneyToken {
|
|
458
|
+
chain: OwneySupportedChains;
|
|
459
|
+
chainId: OwneySupportedChainId;
|
|
460
|
+
asset: OwneySupportedTokens;
|
|
461
|
+
amount: string;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
interface AgentBalance {
|
|
465
|
+
smartWallet?: `0x${string}`;
|
|
466
|
+
totalBalance: string;
|
|
467
|
+
tokens: OwneyToken[];
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
interface OwneyBalances {
|
|
471
|
+
totalBalance: string;
|
|
472
|
+
agentBalances: Record<AgentId, AgentBalance>;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
interface AgentEarnings {
|
|
476
|
+
smartWallet: `0x${string}`;
|
|
477
|
+
lifetimeEarnings: number;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
interface OwneyEarnings {
|
|
481
|
+
totalEarnings: string;
|
|
482
|
+
agentEarnings: Record<AgentId, AgentEarnings>;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
interface AccountAgentApy {
|
|
486
|
+
walletAddress: string;
|
|
487
|
+
weightedApyAfterFee?: number;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
interface OwneyAccountApy {
|
|
491
|
+
totalApy: string;
|
|
492
|
+
agentApy: Record<AgentId, AccountAgentApy>;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
type HistoryAction = "Rebalance" | "Deposit" | "Top up" | "Withdraw" | "Earned";
|
|
496
|
+
|
|
497
|
+
interface HistoryTransaction {
|
|
498
|
+
txHashes: string[];
|
|
499
|
+
chainId?: number;
|
|
500
|
+
tokenSymbol?: string;
|
|
501
|
+
amount?: string;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
interface RebalanceLog {
|
|
505
|
+
fromProtocol: string;
|
|
506
|
+
toProtocol: string;
|
|
507
|
+
tokenSymbol: string;
|
|
508
|
+
amount: string;
|
|
509
|
+
status: "success" | "failed";
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
interface AgentHistoryEntry {
|
|
513
|
+
agent: AgentId;
|
|
514
|
+
action: HistoryAction;
|
|
515
|
+
date: string;
|
|
516
|
+
oldApy: string | null;
|
|
517
|
+
newApy: string | null;
|
|
518
|
+
transactions: HistoryTransaction[];
|
|
519
|
+
rebalanceLog: RebalanceLog[];
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
interface OwneyAgentHistory {
|
|
523
|
+
data: AgentHistoryEntry[];
|
|
524
|
+
total: number;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
interface OwneyAgentStatus {
|
|
528
|
+
success: boolean;
|
|
529
|
+
strategy?: string;
|
|
530
|
+
protocols?: string[];
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
interface AgentUserProfile {
|
|
534
|
+
address: string;
|
|
535
|
+
smartWallet: string;
|
|
536
|
+
chains: number[];
|
|
537
|
+
strategy?: string;
|
|
538
|
+
hasActiveSessionKey: boolean;
|
|
539
|
+
protocols: string[];
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
interface OwneyUserProfile {
|
|
543
|
+
agentUserProfile: Record<AgentId, AgentUserProfile>;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
interface AgentApy {
|
|
547
|
+
averageApy: number;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
interface OwneyAgentApy {
|
|
551
|
+
agentApy: Record<AgentId, AgentApy>;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
interface OwneyRouteResponse {
|
|
555
|
+
agent: AgentId;
|
|
556
|
+
chainId: number;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
interface OwneyAgentAllocation {
|
|
560
|
+
agentAllocation: Record<AgentId, number>;
|
|
561
|
+
}
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
### Callback Types
|
|
565
|
+
|
|
566
|
+
```typescript
|
|
567
|
+
type DepositCallback = (
|
|
568
|
+
smartWalletAddress: string,
|
|
569
|
+
chainId: number,
|
|
570
|
+
amount: string
|
|
571
|
+
) => Promise<`0x${string}`> | `0x${string}`;
|
|
572
|
+
```
|
|
573
|
+
|
|
574
|
+
### Error Classes
|
|
575
|
+
|
|
576
|
+
| Error | Thrown when |
|
|
577
|
+
|-------|------------|
|
|
578
|
+
| `NotConnectedError` | A wallet-dependent method is called before `connect()` |
|
|
579
|
+
| `AgentNotFoundError` | An unknown agent ID is passed (e.g. a typo) |
|
|
580
|
+
| `AgentChainIncompatibleError` | `activateAgent` is called with agents that don't support the given chain. Exposes `incompatibleAgents` and `connectedChainId` properties for programmatic handling. |
|
|
581
|
+
|
|
582
|
+
## License
|
|
583
|
+
|
|
584
|
+
MIT
|