@zyfai/sdk 0.1.17 → 0.1.18

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.
Files changed (2) hide show
  1. package/README.md +73 -9
  2. 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. **Execution API Key**: API key for the Execution API (Safe deployment, transactions, session keys)
29
- 2. **Data API Key** (optional): API key for the Data API (earnings, opportunities, analytics). If not provided, uses the Execution API key.
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 keys from [ZyFAI Dashboard](https://app.zyf.ai)**
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:**
@@ -56,6 +61,8 @@ const sdk = new ZyfaiSDK({
56
61
 
57
62
  **API Endpoints by Environment:**
58
63
 
64
+ The SDK uses a single API key for both Execution API and Data API:
65
+
59
66
  | Environment | Execution API | Data API |
60
67
  | ------------ | ---------------------------- | -------------------------------- |
61
68
  | `production` | `https://api.zyf.ai` | `https://defiapi.zyf.ai` |
@@ -174,9 +181,25 @@ new ZyfaiSDK(config: SDKConfig | string)
174
181
  **Parameters:**
175
182
 
176
183
  - `config`: Configuration object or API key string
177
- - `apiKey` (string): Your ZyFAI API key
178
- - `environment` ('production' | 'staging', optional): API environment (default: 'production')
179
- - `bundlerApiKey` (string, optional): Bundler API key for Safe deployment (required for deploySafe)
184
+ - If a string is provided, it's treated as the `apiKey`
185
+ - If an object is provided:
186
+ - `apiKey` (string): Your ZyFAI API key (required)
187
+ - `environment` ('production' | 'staging', optional): API environment (default: 'production')
188
+ - `bundlerApiKey` (string, optional): Bundler API key for Safe deployment (required for deploySafe)
189
+
190
+ **Examples:**
191
+
192
+ ```typescript
193
+ // Option 1: String initialization (API key only)
194
+ const sdk = new ZyfaiSDK("your-api-key");
195
+
196
+ // Option 2: Object initialization (full configuration)
197
+ const sdk = new ZyfaiSDK({
198
+ apiKey: "your-api-key",
199
+ bundlerApiKey: "your-bundler-api-key",
200
+ environment: "production",
201
+ });
202
+ ```
180
203
 
181
204
  #### Methods
182
205
 
@@ -266,6 +289,7 @@ Deploy a Safe smart wallet for a user.
266
289
  safeAddress: Address;
267
290
  txHash: string;
268
291
  status: "deployed" | "failed";
292
+ alreadyDeployed?: boolean; // True if the Safe was already deployed (no new deployment needed)
269
293
  }
270
294
  ```
271
295
 
@@ -449,11 +473,51 @@ console.log("Active wallet count:", wallets.count);
449
473
 
450
474
  #### Get Smart Wallets by EOA
451
475
 
476
+ Get the smart wallet address associated with an EOA address:
477
+
452
478
  ```typescript
453
479
  const result = await sdk.getSmartWalletByEOA("0xYourEOA...");
454
- console.log("Smart wallets:", result.smartWallets);
480
+ console.log("Smart Wallet:", result.smartWallet);
481
+ console.log("Chains:", result.chains);
482
+ console.log("EOA:", result.eoa);
483
+ ```
484
+
485
+ **Returns:**
486
+
487
+ ```typescript
488
+ {
489
+ success: boolean;
490
+ eoa: string;
491
+ smartWallet: Address | null;
492
+ chains: number[];
493
+ }
455
494
  ```
456
495
 
496
+ #### Get First Topup
497
+
498
+ Get information about the first deposit/topup for a wallet:
499
+
500
+ ```typescript
501
+ const firstTopup = await sdk.getFirstTopup(walletAddress, 8453);
502
+ console.log("First Topup Date:", firstTopup.date);
503
+ console.log("First Topup Amount:", firstTopup.amount);
504
+ console.log("Chain ID:", firstTopup.chainId);
505
+ ```
506
+
507
+ **Returns:**
508
+
509
+ ```typescript
510
+ {
511
+ success: boolean;
512
+ walletAddress: string;
513
+ date: string;
514
+ amount?: string;
515
+ chainId?: number;
516
+ }
517
+ ```
518
+
519
+ **Note**: Returns an error if the wallet has no deposits yet.
520
+
457
521
  #### Get Transaction History
458
522
 
459
523
  ```typescript
@@ -784,7 +848,7 @@ try {
784
848
  For running the examples, set up the following environment variables:
785
849
 
786
850
  ```bash
787
- # Required: API key for both Execution API and Data API
851
+ # Required: API key (used for both Execution API and Data API)
788
852
  ZYFAI_API_KEY=your-api-key
789
853
 
790
854
  # 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.17",
3
+ "version": "0.1.18",
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",