@owney/sdk 0.7.25-beta.4 → 0.7.25-beta.6
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 +72 -13
- package/dist/index.cjs +564 -180
- package/dist/index.d.cts +47 -6
- package/dist/index.d.ts +47 -6
- package/dist/index.js +505 -118
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,14 @@ 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
|
+
rpcUrls: {
|
|
20
|
+
1: "https://eth-mainnet.g.alchemy.com/v2/<key>",
|
|
21
|
+
8453: "https://base-mainnet.g.alchemy.com/v2/<key>",
|
|
22
|
+
42161: "https://arb-mainnet.g.alchemy.com/v2/<key>",
|
|
23
|
+
},
|
|
24
|
+
});
|
|
18
25
|
|
|
19
26
|
// Connect with an EIP-1193 wallet provider
|
|
20
27
|
await sdk.connect(provider);
|
|
@@ -35,33 +42,78 @@ Create a new SDK instance.
|
|
|
35
42
|
| Param | Type | Description |
|
|
36
43
|
| --------------------------------------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
|
|
37
44
|
| `config.apiKey` | `string` | Your Owney API key, used to authenticate with the routing API and fetch agent-specific keys |
|
|
38
|
-
| `config.
|
|
45
|
+
| `config.rpcUrls` | `{ 1?: string; 8453?: string; 42161?: string }` (optional) | Per-chain RPC overrides used by agent reads and transaction-receipt polling |
|
|
46
|
+
| `config.zyfaiRpcUrls` | Same as `rpcUrls` (deprecated) | Legacy Zyfai-only override; use `rpcUrls` for all application-owned reads |
|
|
39
47
|
|
|
40
48
|
```typescript
|
|
41
49
|
import { OwneySDK } from "@owney/sdk";
|
|
42
50
|
|
|
43
|
-
const sdk = new OwneySDK({
|
|
51
|
+
const sdk = new OwneySDK({
|
|
52
|
+
apiKey: "your-owney-api-key",
|
|
53
|
+
rpcUrls: {
|
|
54
|
+
1: "https://eth-mainnet.g.alchemy.com/v2/<key>",
|
|
55
|
+
8453: "https://base-mainnet.g.alchemy.com/v2/<key>",
|
|
56
|
+
42161: "https://arb-mainnet.g.alchemy.com/v2/<key>",
|
|
57
|
+
},
|
|
58
|
+
});
|
|
44
59
|
```
|
|
45
60
|
|
|
46
|
-
####
|
|
61
|
+
#### Dedicated RPC URLs
|
|
62
|
+
|
|
63
|
+
Use `rpcUrls` for application-owned chain reads and transaction-receipt
|
|
64
|
+
polling. The connected wallet provider remains responsible for accounts, chain
|
|
65
|
+
switching, signatures, and transaction submission.
|
|
66
|
+
|
|
67
|
+
`rpcUrls` is optional. The SDK resolves an endpoint independently for each
|
|
68
|
+
supported chain using this precedence:
|
|
47
69
|
|
|
48
|
-
|
|
70
|
+
1. The caller-provided `rpcUrls[chainId]`, when present and non-empty.
|
|
71
|
+
2. The Owney SDK default URL for that chain.
|
|
72
|
+
|
|
73
|
+
The SDK defaults are Owney-managed Alchemy endpoints embedded in the SDK. They
|
|
74
|
+
keep zero-configuration integrations working, but their capacity is shared by
|
|
75
|
+
every consumer that does not provide an override.
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
// Zero configuration: all supported chains use Owney SDK defaults.
|
|
79
|
+
const sdk = new OwneySDK({
|
|
80
|
+
apiKey: "your-owney-api-key",
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Overrides can be complete or partial:
|
|
49
85
|
|
|
50
86
|
```typescript
|
|
51
87
|
const sdk = new OwneySDK({
|
|
52
88
|
apiKey: "your-owney-api-key",
|
|
53
|
-
|
|
89
|
+
rpcUrls: {
|
|
90
|
+
// Ethereum and Arbitrum continue using Owney SDK defaults.
|
|
54
91
|
8453: "https://base-mainnet.g.alchemy.com/v2/<key>",
|
|
55
|
-
42161: "https://arb-mainnet.g.alchemy.com/v2/<key>",
|
|
56
92
|
},
|
|
57
93
|
});
|
|
58
94
|
```
|
|
59
95
|
|
|
96
|
+
The resolved URLs are shared across Owney-owned reads and agent integrations:
|
|
97
|
+
|
|
98
|
+
- Wagmi or application transports remain the consuming application's
|
|
99
|
+
responsibility; Owney mini-apps configure them from the same URL map.
|
|
100
|
+
- Zyfai receives the resolved Owney URL map, so its internal provider defaults
|
|
101
|
+
do not determine routing for Owney SDK consumers.
|
|
102
|
+
- Yieldseeker uses the resolved Base URL for transaction-receipt polling.
|
|
103
|
+
- Balance, allowance, module-state, and receipt reads use the resolved RPC.
|
|
104
|
+
- Account access, chain switching, signatures, approvals, and transaction
|
|
105
|
+
submission continue through the connected wallet provider.
|
|
106
|
+
|
|
60
107
|
Notes:
|
|
61
108
|
|
|
62
|
-
-
|
|
63
|
-
|
|
64
|
-
-
|
|
109
|
+
- Owney mini-apps should continue passing explicit environment-specific URLs,
|
|
110
|
+
even though the SDK defaults provide a fallback.
|
|
111
|
+
- Production SDK consumers should provide their own endpoints for quota
|
|
112
|
+
isolation, origin restrictions, and predictable capacity.
|
|
113
|
+
- Partial maps override only the supplied chains; missing chains retain Owney
|
|
114
|
+
SDK defaults.
|
|
115
|
+
- HTTP reads use bounded retries and honor provider `Retry-After` responses.
|
|
116
|
+
- `zyfaiRpcUrls` remains available for compatibility but applies only to Zyfai.
|
|
65
117
|
|
|
66
118
|
### `connect(provider)`
|
|
67
119
|
|
|
@@ -125,7 +177,7 @@ await sdk.activateAgent(42161);
|
|
|
125
177
|
|
|
126
178
|
### `deposit(options)`
|
|
127
179
|
|
|
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. Custom `depositCallback` implementations run once per final valid agent. The default Permit2 flow signs one recipient-bound batch authorization for every agent share.
|
|
180
|
+
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 and atomically bundles the maximum Permit2 approval with that batch in one sponsored transaction; later deposits need only the batch signature.
|
|
129
181
|
|
|
130
182
|
| Param | Type | Description |
|
|
131
183
|
| ------------------------- | -------------------- | --------------------------------------------------------------- |
|
|
@@ -439,8 +491,8 @@ console.log(usdcBaseApy.agentApy.zyfai.averageApy); // APY scoped to USDC on Bas
|
|
|
439
491
|
type AgentId = "zyfai";
|
|
440
492
|
type Asset = string;
|
|
441
493
|
type DailyApyDays = "7D" | "14D" | "30D";
|
|
442
|
-
type OwneySupportedChainId = 8453 | 42161;
|
|
443
|
-
type OwneySupportedChains = "BASE" | "ARBITRUM";
|
|
494
|
+
type OwneySupportedChainId = 1 | 8453 | 42161;
|
|
495
|
+
type OwneySupportedChains = "ETHEREUM" | "BASE" | "ARBITRUM";
|
|
444
496
|
type OwneySupportedTokens = "USDC" | "WETH";
|
|
445
497
|
|
|
446
498
|
type AgentSupportedAsset = {
|
|
@@ -457,7 +509,14 @@ type AgentSupportedAssets = {
|
|
|
457
509
|
|
|
458
510
|
interface OwneySDKConfig {
|
|
459
511
|
apiKey: string;
|
|
512
|
+
rpcUrls?: {
|
|
513
|
+
1?: string;
|
|
514
|
+
8453?: string;
|
|
515
|
+
42161?: string;
|
|
516
|
+
};
|
|
517
|
+
/** @deprecated Use rpcUrls. */
|
|
460
518
|
zyfaiRpcUrls?: {
|
|
519
|
+
1?: string;
|
|
461
520
|
8453?: string;
|
|
462
521
|
42161?: string;
|
|
463
522
|
};
|