@owney/sdk 0.7.28-beta.3 → 0.7.32-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 +93 -19
- package/dist/chunk-YBMCUL5D.js +544 -0
- package/dist/index.cjs +14846 -3750
- package/dist/index.d.cts +1237 -477
- package/dist/index.d.ts +1237 -477
- package/dist/index.js +14267 -3726
- package/dist/token-batch-family-EKOLMSTD.js +26 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -14,12 +14,15 @@ npm install @owney/sdk
|
|
|
14
14
|
import { OwneySDK } from "@owney/sdk";
|
|
15
15
|
|
|
16
16
|
// Create the SDK instance
|
|
17
|
-
const sdk = new OwneySDK({
|
|
17
|
+
const sdk = new OwneySDK({
|
|
18
|
+
apiKey: "your-owney-api-key",
|
|
19
|
+
routingApiBaseUrl: "https://your-routing-api.example",
|
|
20
|
+
});
|
|
18
21
|
|
|
19
22
|
// Connect with an EIP-1193 wallet provider
|
|
20
23
|
await sdk.connect(provider);
|
|
21
24
|
|
|
22
|
-
// Activate agents on Base (
|
|
25
|
+
// Activate agents on Base (creates and initializes provider wallets as needed)
|
|
23
26
|
await sdk.activateAgent(8453);
|
|
24
27
|
|
|
25
28
|
// Get balances across all agents
|
|
@@ -32,36 +35,79 @@ const balances = await sdk.getBalances();
|
|
|
32
35
|
|
|
33
36
|
Create a new SDK instance.
|
|
34
37
|
|
|
35
|
-
| Param
|
|
36
|
-
|
|
|
37
|
-
| `config.apiKey`
|
|
38
|
-
| `config.
|
|
38
|
+
| Param | Type | Description |
|
|
39
|
+
| --------------------------------------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
|
|
40
|
+
| `config.apiKey` | `string` | Your Owney API key, used to authenticate with the routing API and fetch agent-specific keys |
|
|
41
|
+
| `config.routingApiBaseUrl` | `string` (optional) | Routing API URL; required for proxy reads unless the SDK build has `OWNEY_ROUTING_API_BASE_URL` or all `rpcUrls` are set |
|
|
42
|
+
| `config.rpcUrls` | `{ 1?: string; 8453?: string; 42161?: string }` (optional) | Per-chain RPC overrides used by agent reads and transaction-receipt polling |
|
|
43
|
+
| `config.zyfaiRpcUrls` | Same as `rpcUrls` (deprecated) | Legacy Zyfai-only override; use `rpcUrls` for all application-owned reads |
|
|
39
44
|
|
|
40
45
|
```typescript
|
|
41
46
|
import { OwneySDK } from "@owney/sdk";
|
|
42
47
|
|
|
43
|
-
const sdk = new OwneySDK({
|
|
48
|
+
const sdk = new OwneySDK({
|
|
49
|
+
apiKey: "your-owney-api-key",
|
|
50
|
+
routingApiBaseUrl: "https://your-routing-api.example",
|
|
51
|
+
});
|
|
44
52
|
```
|
|
45
53
|
|
|
46
|
-
####
|
|
54
|
+
#### Dedicated RPC URLs
|
|
55
|
+
|
|
56
|
+
Use `rpcUrls` for application-owned chain reads and transaction-receipt
|
|
57
|
+
polling. The connected wallet provider remains responsible for accounts, chain
|
|
58
|
+
switching, signatures, and transaction submission.
|
|
47
59
|
|
|
48
|
-
|
|
60
|
+
`rpcUrls` is optional. The SDK resolves an endpoint independently for each
|
|
61
|
+
supported chain using this precedence:
|
|
62
|
+
|
|
63
|
+
1. The caller-provided `rpcUrls[chainId]`, when present and non-empty.
|
|
64
|
+
2. The Owney routing API read-only RPC proxy for that chain.
|
|
65
|
+
|
|
66
|
+
The Alchemy credential stays on the routing API server. The SDK sends its
|
|
67
|
+
existing organization key to the proxy for per-organization rate limiting.
|
|
68
|
+
The proxy base URL must be provided through `routingApiBaseUrl` or the SDK
|
|
69
|
+
build's `OWNEY_ROUTING_API_BASE_URL`; there is no hardcoded production fallback.
|
|
49
70
|
|
|
50
71
|
```typescript
|
|
72
|
+
// All supported chains use the Owney routing API proxy.
|
|
51
73
|
const sdk = new OwneySDK({
|
|
52
74
|
apiKey: "your-owney-api-key",
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
75
|
+
routingApiBaseUrl: "https://your-routing-api.example",
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Overrides can be complete or partial:
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
const sdk = new OwneySDK({
|
|
83
|
+
apiKey: "your-owney-api-key",
|
|
84
|
+
routingApiBaseUrl: "https://your-routing-api.example",
|
|
85
|
+
rpcUrls: {
|
|
86
|
+
// Ethereum and Arbitrum continue using the routing API proxy.
|
|
87
|
+
8453: "https://your-own-rpc.example/rpc",
|
|
56
88
|
},
|
|
57
89
|
});
|
|
58
90
|
```
|
|
59
91
|
|
|
92
|
+
The resolved URLs are shared across Owney-owned reads and agent integrations:
|
|
93
|
+
|
|
94
|
+
- Wagmi or application transports remain the consuming application's
|
|
95
|
+
responsibility; Owney mini-apps configure them from the same URL map.
|
|
96
|
+
- Zyfai receives the resolved Owney URL map, so its internal provider defaults
|
|
97
|
+
do not determine routing for Owney SDK consumers.
|
|
98
|
+
- Yieldseeker uses the resolved Base URL for transaction-receipt polling.
|
|
99
|
+
- Balance, allowance, module-state, and receipt reads use the resolved RPC.
|
|
100
|
+
- Account access, chain switching, signatures, approvals, and transaction
|
|
101
|
+
submission continue through the connected wallet provider.
|
|
102
|
+
|
|
60
103
|
Notes:
|
|
61
104
|
|
|
62
|
-
-
|
|
63
|
-
-
|
|
64
|
-
-
|
|
105
|
+
- Owney mini-apps pass the same routing API proxy URLs to Wagmi and the SDK.
|
|
106
|
+
- SDK consumers may override endpoints if they operate their own RPC provider.
|
|
107
|
+
- Partial maps override only the supplied chains; missing chains use Owney's
|
|
108
|
+
routing API proxy.
|
|
109
|
+
- HTTP reads use bounded retries and honor provider `Retry-After` responses.
|
|
110
|
+
- `zyfaiRpcUrls` remains available for compatibility but applies only to Zyfai.
|
|
65
111
|
|
|
66
112
|
### `connect(provider)`
|
|
67
113
|
|
|
@@ -108,7 +154,7 @@ if (chainId) {
|
|
|
108
154
|
|
|
109
155
|
### `activateAgent(chainId, agentId?)`
|
|
110
156
|
|
|
111
|
-
Activate the user's smart wallet for the specified agents, or all chain-compatible agents if omitted.
|
|
157
|
+
Activate the user's smart wallet for the specified agents, or all chain-compatible agents if omitted. Activation performs each provider's required setup before deposits are allowed. For Yieldseeker, this creates the user and agent when needed and calls the agent `/deploy` endpoint before any funding transfer. Saves the chainId for use by all subsequent SDK calls.
|
|
112
158
|
|
|
113
159
|
| Param | Type | Description |
|
|
114
160
|
| --------- | ---------------------- | ----------------------------------------------------------------------------- |
|
|
@@ -125,7 +171,7 @@ await sdk.activateAgent(42161);
|
|
|
125
171
|
|
|
126
172
|
### `deposit(options)`
|
|
127
173
|
|
|
128
|
-
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, and per-agent minimum deposit amounts (defined per chain+asset on `agent.supportedAssets[].assets[].minDepositAmount`) are taken into account.
|
|
174
|
+
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, and per-agent minimum deposit amounts (defined per chain+asset on `agent.supportedAssets[].assets[].minDepositAmount`) are taken into account. Custom `depositCallback` implementations run once per final valid agent. The default Permit2 flow signs one recipient-bound batch authorization for every agent share. On the first Base USDC deposit, the SDK first requests an ERC-2612 signature; the relayer then submits the Permit2 approval and deposit as two sponsored transactions. Later deposits need only the batch signature.
|
|
129
175
|
|
|
130
176
|
| Param | Type | Description |
|
|
131
177
|
| ------------------------- | -------------------- | --------------------------------------------------------------- |
|
|
@@ -134,6 +180,13 @@ Deposit funds into a specific agent, or split equally across all agents if `agen
|
|
|
134
180
|
| `options.depositCallback` | `DepositCallback` | Callback that performs the token transfer and returns a tx hash |
|
|
135
181
|
| `options.agentId` | `AgentId` (optional) | Target agent. Omit to split equally across all agents. |
|
|
136
182
|
|
|
183
|
+
Zyfai's native transfer path uses `sendDeposit()`. It returns after the token
|
|
184
|
+
transfer confirms and the deposit is registered, while balance credit may still
|
|
185
|
+
be queued. Balance reads reflect subsequent credit and allocation; the deposit
|
|
186
|
+
call does not wait for `waitForDepositCredit()`.
|
|
187
|
+
A successful deposit result confirms the transfer; it does not guarantee that
|
|
188
|
+
the funds are already credited or earning yield.
|
|
189
|
+
|
|
137
190
|
Returns: `OwneyDepositResult` (single agent) or `OwneyMultiDepositResult` (all agents)
|
|
138
191
|
|
|
139
192
|
```typescript
|
|
@@ -218,6 +271,10 @@ Balances are shown after any applicable performance fees have been deducted.
|
|
|
218
271
|
|
|
219
272
|
Returns: `AgentBalance` (single agent) or `OwneyBalances` (all agents)
|
|
220
273
|
|
|
274
|
+
Aggregate reads keep successful agents when another agent fails. The response
|
|
275
|
+
includes `agentErrors` and, for rate limits, absolute `agentRetryAt` deadlines.
|
|
276
|
+
The SDK throws `BALANCE_ALL_FAILED` when every active agent fails.
|
|
277
|
+
|
|
221
278
|
```typescript
|
|
222
279
|
// Single agent
|
|
223
280
|
const balance = await sdk.getBalances("zyfai");
|
|
@@ -245,6 +302,10 @@ Earnings are shown after any applicable performance fees have been deducted.
|
|
|
245
302
|
|
|
246
303
|
Returns: `AgentEarnings` (single agent) or `OwneyEarnings` (all agents)
|
|
247
304
|
|
|
305
|
+
Aggregate reads keep successful agents when another agent fails. The response
|
|
306
|
+
includes `agentErrors` and, for rate limits, absolute `agentRetryAt` deadlines.
|
|
307
|
+
The SDK throws `EARNINGS_ALL_FAILED` when every active agent fails.
|
|
308
|
+
|
|
248
309
|
```typescript
|
|
249
310
|
// Single agent
|
|
250
311
|
const earnings = await sdk.getEarnings("zyfai");
|
|
@@ -274,6 +335,9 @@ snapshot is less than one hour old, the SDK returns it without recalculating.
|
|
|
274
335
|
|
|
275
336
|
Returns: `AgentEarnings` (single agent) or `OwneyEarnings` (all agents)
|
|
276
337
|
|
|
338
|
+
Aggregate refreshes use the same partial-result and all-failed behavior as
|
|
339
|
+
`getEarnings()`.
|
|
340
|
+
|
|
277
341
|
```typescript
|
|
278
342
|
// Single agent
|
|
279
343
|
const refreshed = await sdk.refreshEarnings("zyfai");
|
|
@@ -439,8 +503,8 @@ console.log(usdcBaseApy.agentApy.zyfai.averageApy); // APY scoped to USDC on Bas
|
|
|
439
503
|
type AgentId = "zyfai";
|
|
440
504
|
type Asset = string;
|
|
441
505
|
type DailyApyDays = "7D" | "14D" | "30D";
|
|
442
|
-
type OwneySupportedChainId = 8453 | 42161;
|
|
443
|
-
type OwneySupportedChains = "BASE" | "ARBITRUM";
|
|
506
|
+
type OwneySupportedChainId = 1 | 8453 | 42161;
|
|
507
|
+
type OwneySupportedChains = "ETHEREUM" | "BASE" | "ARBITRUM";
|
|
444
508
|
type OwneySupportedTokens = "USDC" | "WETH";
|
|
445
509
|
|
|
446
510
|
type AgentSupportedAsset = {
|
|
@@ -457,7 +521,14 @@ type AgentSupportedAssets = {
|
|
|
457
521
|
|
|
458
522
|
interface OwneySDKConfig {
|
|
459
523
|
apiKey: string;
|
|
524
|
+
rpcUrls?: {
|
|
525
|
+
1?: string;
|
|
526
|
+
8453?: string;
|
|
527
|
+
42161?: string;
|
|
528
|
+
};
|
|
529
|
+
/** @deprecated Use rpcUrls. */
|
|
460
530
|
zyfaiRpcUrls?: {
|
|
531
|
+
1?: string;
|
|
461
532
|
8453?: string;
|
|
462
533
|
42161?: string;
|
|
463
534
|
};
|
|
@@ -572,12 +643,14 @@ interface AccountAgentApy {
|
|
|
572
643
|
weightedApyAfterFee?: number;
|
|
573
644
|
weightedApyAfterFeeDetails?: AgentApyDetails;
|
|
574
645
|
apyByChainAndAsset?: ApyByChainAndAsset;
|
|
646
|
+
history?: ApyHistoryPoint[];
|
|
575
647
|
}
|
|
576
648
|
|
|
577
649
|
interface OwneyAccountApy {
|
|
578
650
|
totalApy: string;
|
|
579
651
|
agentApy: Record<AgentId, AccountAgentApy>;
|
|
580
652
|
apyByChainAndAsset: ApyByChainAndAsset;
|
|
653
|
+
history?: ApyHistoryPoint[]; // balance-weighted aggregate daily series
|
|
581
654
|
}
|
|
582
655
|
|
|
583
656
|
type HistoryAction = "Rebalance" | "Deposit" | "Top up" | "Withdraw" | "Earned";
|
|
@@ -719,6 +792,7 @@ type OwneyErrorCode =
|
|
|
719
792
|
| "API_NO_AGENTS" // No supported agents returned by routing API
|
|
720
793
|
// Aggregation
|
|
721
794
|
| "BALANCE_ALL_FAILED" // All agents failed to return balances
|
|
795
|
+
| "EARNINGS_ALL_FAILED" // All agents failed to return earnings
|
|
722
796
|
| "ALLOCATION_ALL_FAILED" // All agents failed to return allocation data
|
|
723
797
|
// Validation
|
|
724
798
|
| "VALIDATION_INVALID_DAYS"; // Invalid days value (expected "7D", "14D", or "30D")
|