@zyfai/sdk 0.1.16 → 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.
- package/README.md +73 -9
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -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. **
|
|
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:**
|
|
@@ -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
|
-
-
|
|
178
|
-
-
|
|
179
|
-
|
|
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
|
|
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/dist/index.js
CHANGED
|
@@ -475,7 +475,7 @@ var getSafeAccount = async (config) => {
|
|
|
475
475
|
});
|
|
476
476
|
const saltHex = (0, import_viem3.fromHex)((0, import_viem3.toHex)(effectiveSalt), "bigint");
|
|
477
477
|
const signer = {
|
|
478
|
-
...owner
|
|
478
|
+
...owner,
|
|
479
479
|
address: signerAddress,
|
|
480
480
|
// Override with the signer address at top level
|
|
481
481
|
signMessage: async (message) => {
|
|
@@ -497,7 +497,7 @@ var getSafeAccount = async (config) => {
|
|
|
497
497
|
const safeAccount = await (0, import_accounts.toSafeSmartAccount)({
|
|
498
498
|
client: publicClient,
|
|
499
499
|
owners: [signer],
|
|
500
|
-
// Pass the
|
|
500
|
+
// Pass the owner object with address and signMessage capability
|
|
501
501
|
version: "1.4.1",
|
|
502
502
|
entryPoint: {
|
|
503
503
|
address: import_account_abstraction.entryPoint07Address,
|
package/dist/index.mjs
CHANGED
|
@@ -455,7 +455,7 @@ var getSafeAccount = async (config) => {
|
|
|
455
455
|
});
|
|
456
456
|
const saltHex = fromHex(toHex(effectiveSalt), "bigint");
|
|
457
457
|
const signer = {
|
|
458
|
-
...owner
|
|
458
|
+
...owner,
|
|
459
459
|
address: signerAddress,
|
|
460
460
|
// Override with the signer address at top level
|
|
461
461
|
signMessage: async (message) => {
|
|
@@ -477,7 +477,7 @@ var getSafeAccount = async (config) => {
|
|
|
477
477
|
const safeAccount = await toSafeSmartAccount({
|
|
478
478
|
client: publicClient,
|
|
479
479
|
owners: [signer],
|
|
480
|
-
// Pass the
|
|
480
|
+
// Pass the owner object with address and signMessage capability
|
|
481
481
|
version: "1.4.1",
|
|
482
482
|
entryPoint: {
|
|
483
483
|
address: entryPoint07Address,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zyfai/sdk",
|
|
3
|
-
"version": "0.1.
|
|
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",
|