@owney/sdk 0.7.25-beta.8 → 0.7.25
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 +26 -74
- package/dist/index.cjs +698 -3255
- package/dist/index.d.cts +181 -354
- package/dist/index.d.ts +181 -354
- package/dist/index.js +694 -3270
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -14,15 +14,12 @@ npm install @owney/sdk
|
|
|
14
14
|
import { OwneySDK } from "@owney/sdk";
|
|
15
15
|
|
|
16
16
|
// Create the SDK instance
|
|
17
|
-
const sdk = new OwneySDK({
|
|
18
|
-
apiKey: "your-owney-api-key",
|
|
19
|
-
routingApiBaseUrl: "https://your-routing-api.example",
|
|
20
|
-
});
|
|
17
|
+
const sdk = new OwneySDK({ apiKey: "your-owney-api-key" });
|
|
21
18
|
|
|
22
19
|
// Connect with an EIP-1193 wallet provider
|
|
23
20
|
await sdk.connect(provider);
|
|
24
21
|
|
|
25
|
-
// Activate agents on Base (
|
|
22
|
+
// Activate agents on Base (fetches agent keys on first call)
|
|
26
23
|
await sdk.activateAgent(8453);
|
|
27
24
|
|
|
28
25
|
// Get balances across all agents
|
|
@@ -35,79 +32,36 @@ const balances = await sdk.getBalances();
|
|
|
35
32
|
|
|
36
33
|
Create a new SDK instance.
|
|
37
34
|
|
|
38
|
-
| Param
|
|
39
|
-
|
|
|
40
|
-
| `config.apiKey`
|
|
41
|
-
| `config.
|
|
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 |
|
|
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
|
+
| `config.zyfaiRpcUrls` | `{ 8453?: string; 42161?: string }` (optional) | Per-chain RPC URL overrides used by Zyfai SDK network calls |
|
|
44
39
|
|
|
45
40
|
```typescript
|
|
46
41
|
import { OwneySDK } from "@owney/sdk";
|
|
47
42
|
|
|
48
|
-
const sdk = new OwneySDK({
|
|
49
|
-
apiKey: "your-owney-api-key",
|
|
50
|
-
routingApiBaseUrl: "https://your-routing-api.example",
|
|
51
|
-
});
|
|
43
|
+
const sdk = new OwneySDK({ apiKey: "your-owney-api-key" });
|
|
52
44
|
```
|
|
53
45
|
|
|
54
|
-
####
|
|
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.
|
|
59
|
-
|
|
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.
|
|
70
|
-
|
|
71
|
-
```typescript
|
|
72
|
-
// All supported chains use the Owney routing API proxy.
|
|
73
|
-
const sdk = new OwneySDK({
|
|
74
|
-
apiKey: "your-owney-api-key",
|
|
75
|
-
routingApiBaseUrl: "https://your-routing-api.example",
|
|
76
|
-
});
|
|
77
|
-
```
|
|
46
|
+
#### Custom Zyfai RPC URLs
|
|
78
47
|
|
|
79
|
-
|
|
48
|
+
Use `zyfaiRpcUrls` to override Zyfai SDK RPC endpoints (for example, to avoid public endpoint rate limits).
|
|
80
49
|
|
|
81
50
|
```typescript
|
|
82
51
|
const sdk = new OwneySDK({
|
|
83
52
|
apiKey: "your-owney-api-key",
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
8453: "https://your-own-rpc.example/rpc",
|
|
53
|
+
zyfaiRpcUrls: {
|
|
54
|
+
8453: "https://base-mainnet.g.alchemy.com/v2/<key>",
|
|
55
|
+
42161: "https://arb-mainnet.g.alchemy.com/v2/<key>",
|
|
88
56
|
},
|
|
89
57
|
});
|
|
90
58
|
```
|
|
91
59
|
|
|
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
|
-
|
|
103
60
|
Notes:
|
|
104
61
|
|
|
105
|
-
-
|
|
106
|
-
-
|
|
107
|
-
-
|
|
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.
|
|
62
|
+
- These overrides are used by Zyfai SDK flows only.
|
|
63
|
+
- If omitted, Zyfai SDK uses its default RPC endpoints.
|
|
64
|
+
- Other app-level RPC clients (for example, direct viem calls outside Zyfai) are configured separately.
|
|
111
65
|
|
|
112
66
|
### `connect(provider)`
|
|
113
67
|
|
|
@@ -154,7 +108,7 @@ if (chainId) {
|
|
|
154
108
|
|
|
155
109
|
### `activateAgent(chainId, agentId?)`
|
|
156
110
|
|
|
157
|
-
Activate the user's smart wallet for the specified agents, or all chain-compatible agents if omitted.
|
|
111
|
+
Activate the user's smart wallet for the specified agents, or all chain-compatible agents if omitted. Smart wallets are pre-deployed by the underlying providers, so activation only performs authentication and profile syncing — no deploy or session-key signatures. Saves the chainId for use by all subsequent SDK calls.
|
|
158
112
|
|
|
159
113
|
| Param | Type | Description |
|
|
160
114
|
| --------- | ---------------------- | ----------------------------------------------------------------------------- |
|
|
@@ -171,7 +125,7 @@ await sdk.activateAgent(42161);
|
|
|
171
125
|
|
|
172
126
|
### `deposit(options)`
|
|
173
127
|
|
|
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.
|
|
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. When splitting across agents, `depositCallback` is invoked once per final valid agent with that agent's split amount and smart wallet address — expect multiple wallet prompts.
|
|
175
129
|
|
|
176
130
|
| Param | Type | Description |
|
|
177
131
|
| ------------------------- | -------------------- | --------------------------------------------------------------- |
|
|
@@ -180,6 +134,13 @@ Deposit funds into a specific agent, or split equally across all agents if `agen
|
|
|
180
134
|
| `options.depositCallback` | `DepositCallback` | Callback that performs the token transfer and returns a tx hash |
|
|
181
135
|
| `options.agentId` | `AgentId` (optional) | Target agent. Omit to split equally across all agents. |
|
|
182
136
|
|
|
137
|
+
Zyfai's native transfer path uses `sendDeposit()`. It returns after the token
|
|
138
|
+
transfer confirms and the deposit is registered, while balance credit may still
|
|
139
|
+
be queued. Balance reads reflect subsequent credit and allocation; the deposit
|
|
140
|
+
call does not wait for `waitForDepositCredit()`.
|
|
141
|
+
A successful deposit result confirms the transfer; it does not guarantee that
|
|
142
|
+
the funds are already credited or earning yield.
|
|
143
|
+
|
|
183
144
|
Returns: `OwneyDepositResult` (single agent) or `OwneyMultiDepositResult` (all agents)
|
|
184
145
|
|
|
185
146
|
```typescript
|
|
@@ -485,8 +446,8 @@ console.log(usdcBaseApy.agentApy.zyfai.averageApy); // APY scoped to USDC on Bas
|
|
|
485
446
|
type AgentId = "zyfai";
|
|
486
447
|
type Asset = string;
|
|
487
448
|
type DailyApyDays = "7D" | "14D" | "30D";
|
|
488
|
-
type OwneySupportedChainId =
|
|
489
|
-
type OwneySupportedChains = "
|
|
449
|
+
type OwneySupportedChainId = 8453 | 42161;
|
|
450
|
+
type OwneySupportedChains = "BASE" | "ARBITRUM";
|
|
490
451
|
type OwneySupportedTokens = "USDC" | "WETH";
|
|
491
452
|
|
|
492
453
|
type AgentSupportedAsset = {
|
|
@@ -503,14 +464,7 @@ type AgentSupportedAssets = {
|
|
|
503
464
|
|
|
504
465
|
interface OwneySDKConfig {
|
|
505
466
|
apiKey: string;
|
|
506
|
-
rpcUrls?: {
|
|
507
|
-
1?: string;
|
|
508
|
-
8453?: string;
|
|
509
|
-
42161?: string;
|
|
510
|
-
};
|
|
511
|
-
/** @deprecated Use rpcUrls. */
|
|
512
467
|
zyfaiRpcUrls?: {
|
|
513
|
-
1?: string;
|
|
514
468
|
8453?: string;
|
|
515
469
|
42161?: string;
|
|
516
470
|
};
|
|
@@ -625,14 +579,12 @@ interface AccountAgentApy {
|
|
|
625
579
|
weightedApyAfterFee?: number;
|
|
626
580
|
weightedApyAfterFeeDetails?: AgentApyDetails;
|
|
627
581
|
apyByChainAndAsset?: ApyByChainAndAsset;
|
|
628
|
-
history?: ApyHistoryPoint[];
|
|
629
582
|
}
|
|
630
583
|
|
|
631
584
|
interface OwneyAccountApy {
|
|
632
585
|
totalApy: string;
|
|
633
586
|
agentApy: Record<AgentId, AccountAgentApy>;
|
|
634
587
|
apyByChainAndAsset: ApyByChainAndAsset;
|
|
635
|
-
history?: ApyHistoryPoint[]; // balance-weighted aggregate daily series
|
|
636
588
|
}
|
|
637
589
|
|
|
638
590
|
type HistoryAction = "Rebalance" | "Deposit" | "Top up" | "Withdraw" | "Earned";
|