@zyfai/sdk 0.1.17 → 0.1.19
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 +71 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,25 +25,30 @@ pnpm add @zyfai/sdk viem
|
|
|
25
25
|
|
|
26
26
|
## Prerequisites
|
|
27
27
|
|
|
28
|
-
1. **
|
|
29
|
-
2. **
|
|
30
|
-
3. **Bundler API Key**: Required for Safe deployment. Get it from:
|
|
28
|
+
1. **API Key**: Single API key for both Execution API (Safe deployment, transactions, session keys) and Data API (earnings, opportunities, analytics)
|
|
29
|
+
2. **Bundler API Key**: Required for Safe deployment. Get it from:
|
|
31
30
|
- [Pimlico](https://www.pimlico.io/) (Recommended)
|
|
32
31
|
|
|
33
|
-
**Get your API
|
|
32
|
+
**Get your API key from [ZyFAI Dashboard](https://app.zyf.ai)**
|
|
34
33
|
|
|
35
34
|
## Quick Start
|
|
36
35
|
|
|
37
36
|
### Initialize the SDK
|
|
38
37
|
|
|
38
|
+
The SDK can be initialized with either a configuration object or just the API key string:
|
|
39
|
+
|
|
39
40
|
```typescript
|
|
40
41
|
import { ZyfaiSDK } from "@zyfai/sdk";
|
|
41
42
|
|
|
43
|
+
// Option 1: Full configuration object
|
|
42
44
|
const sdk = new ZyfaiSDK({
|
|
43
45
|
apiKey: "your-api-key", // API key for both Execution API and Data API
|
|
44
46
|
bundlerApiKey: "your-bundler-api-key", // Required for Safe deployment
|
|
45
47
|
environment: "production", // or 'staging' (default: 'production')
|
|
46
48
|
});
|
|
49
|
+
|
|
50
|
+
// Option 2: Simple string initialization (API key only)
|
|
51
|
+
const sdk = new ZyfaiSDK("your-api-key");
|
|
47
52
|
```
|
|
48
53
|
|
|
49
54
|
**Configuration Options:**
|
|
@@ -54,13 +59,6 @@ const sdk = new ZyfaiSDK({
|
|
|
54
59
|
| `bundlerApiKey` | No\* | Pimlico API key for Safe deployment (\*required for `deploySafe`) |
|
|
55
60
|
| `environment` | No | `"production"` or `"staging"` (default: `"production"`) |
|
|
56
61
|
|
|
57
|
-
**API Endpoints by Environment:**
|
|
58
|
-
|
|
59
|
-
| Environment | Execution API | Data API |
|
|
60
|
-
| ------------ | ---------------------------- | -------------------------------- |
|
|
61
|
-
| `production` | `https://api.zyf.ai` | `https://defiapi.zyf.ai` |
|
|
62
|
-
| `staging` | `https://staging-api.zyf.ai` | `https://staging-defiapi.zyf.ai` |
|
|
63
|
-
|
|
64
62
|
### Connect Account
|
|
65
63
|
|
|
66
64
|
The SDK accepts either a private key or a modern wallet provider. **The SDK automatically authenticates the user via SIWE (Sign-In with Ethereum) when connecting.**
|
|
@@ -174,9 +172,25 @@ new ZyfaiSDK(config: SDKConfig | string)
|
|
|
174
172
|
**Parameters:**
|
|
175
173
|
|
|
176
174
|
- `config`: Configuration object or API key string
|
|
177
|
-
-
|
|
178
|
-
-
|
|
179
|
-
|
|
175
|
+
- If a string is provided, it's treated as the `apiKey`
|
|
176
|
+
- If an object is provided:
|
|
177
|
+
- `apiKey` (string): Your ZyFAI API key (required)
|
|
178
|
+
- `environment` ('production' | 'staging', optional): API environment (default: 'production')
|
|
179
|
+
- `bundlerApiKey` (string, optional): Bundler API key for Safe deployment (required for deploySafe)
|
|
180
|
+
|
|
181
|
+
**Examples:**
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
// Option 1: String initialization (API key only)
|
|
185
|
+
const sdk = new ZyfaiSDK("your-api-key");
|
|
186
|
+
|
|
187
|
+
// Option 2: Object initialization (full configuration)
|
|
188
|
+
const sdk = new ZyfaiSDK({
|
|
189
|
+
apiKey: "your-api-key",
|
|
190
|
+
bundlerApiKey: "your-bundler-api-key",
|
|
191
|
+
environment: "production",
|
|
192
|
+
});
|
|
193
|
+
```
|
|
180
194
|
|
|
181
195
|
#### Methods
|
|
182
196
|
|
|
@@ -266,6 +280,7 @@ Deploy a Safe smart wallet for a user.
|
|
|
266
280
|
safeAddress: Address;
|
|
267
281
|
txHash: string;
|
|
268
282
|
status: "deployed" | "failed";
|
|
283
|
+
alreadyDeployed?: boolean; // True if the Safe was already deployed (no new deployment needed)
|
|
269
284
|
}
|
|
270
285
|
```
|
|
271
286
|
|
|
@@ -449,11 +464,51 @@ console.log("Active wallet count:", wallets.count);
|
|
|
449
464
|
|
|
450
465
|
#### Get Smart Wallets by EOA
|
|
451
466
|
|
|
467
|
+
Get the smart wallet address associated with an EOA address:
|
|
468
|
+
|
|
452
469
|
```typescript
|
|
453
470
|
const result = await sdk.getSmartWalletByEOA("0xYourEOA...");
|
|
454
|
-
console.log("Smart
|
|
471
|
+
console.log("Smart Wallet:", result.smartWallet);
|
|
472
|
+
console.log("Chains:", result.chains);
|
|
473
|
+
console.log("EOA:", result.eoa);
|
|
455
474
|
```
|
|
456
475
|
|
|
476
|
+
**Returns:**
|
|
477
|
+
|
|
478
|
+
```typescript
|
|
479
|
+
{
|
|
480
|
+
success: boolean;
|
|
481
|
+
eoa: string;
|
|
482
|
+
smartWallet: Address | null;
|
|
483
|
+
chains: number[];
|
|
484
|
+
}
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
#### Get First Topup
|
|
488
|
+
|
|
489
|
+
Get information about the first deposit/topup for a wallet:
|
|
490
|
+
|
|
491
|
+
```typescript
|
|
492
|
+
const firstTopup = await sdk.getFirstTopup(walletAddress, 8453);
|
|
493
|
+
console.log("First Topup Date:", firstTopup.date);
|
|
494
|
+
console.log("First Topup Amount:", firstTopup.amount);
|
|
495
|
+
console.log("Chain ID:", firstTopup.chainId);
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
**Returns:**
|
|
499
|
+
|
|
500
|
+
```typescript
|
|
501
|
+
{
|
|
502
|
+
success: boolean;
|
|
503
|
+
walletAddress: string;
|
|
504
|
+
date: string;
|
|
505
|
+
amount?: string;
|
|
506
|
+
chainId?: number;
|
|
507
|
+
}
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
**Note**: Returns an error if the wallet has no deposits yet.
|
|
511
|
+
|
|
457
512
|
#### Get Transaction History
|
|
458
513
|
|
|
459
514
|
```typescript
|
|
@@ -784,7 +839,7 @@ try {
|
|
|
784
839
|
For running the examples, set up the following environment variables:
|
|
785
840
|
|
|
786
841
|
```bash
|
|
787
|
-
# Required: API key for both Execution API and Data API
|
|
842
|
+
# Required: API key (used for both Execution API and Data API)
|
|
788
843
|
ZYFAI_API_KEY=your-api-key
|
|
789
844
|
|
|
790
845
|
# Required for Safe deployment: Bundler API key (e.g., Pimlico)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zyfai/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
4
4
|
"description": "TypeScript SDK for ZyFAI Yield Optimization Engine - Deploy Safe smart wallets, manage session keys, and interact with DeFi protocols",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|