@zyfai/sdk 0.1.27 → 0.1.28
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/LICENSE +1 -1
- package/README.md +7 -7
- package/dist/index.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +5 -5
- package/dist/index.mjs +5 -5
- package/package.json +2 -2
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Zyfai SDK
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@zyfai/sdk)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
|
|
6
|
-
TypeScript SDK for interacting with the
|
|
6
|
+
TypeScript SDK for interacting with the Zyfai Yield Optimization Engine. This SDK provides easy-to-use methods for deploying Safe smart wallets, managing DeFi positions, and optimizing yield across multiple protocols.
|
|
7
7
|
|
|
8
8
|
You can generate an api key from here: https://sdk.zyf.ai/
|
|
9
9
|
|
|
@@ -29,7 +29,7 @@ pnpm add @zyfai/sdk viem
|
|
|
29
29
|
|
|
30
30
|
1. **API Key**: Single API key for both Execution API (Safe deployment, transactions, session keys) and Data API (earnings, opportunities, analytics)
|
|
31
31
|
|
|
32
|
-
**Get your API key from [
|
|
32
|
+
**Get your API key from [Zyfai Dashboard](https://sdk.zyf.ai)**
|
|
33
33
|
|
|
34
34
|
## Quick Start
|
|
35
35
|
|
|
@@ -167,7 +167,7 @@ new ZyfaiSDK(config: SDKConfig | string)
|
|
|
167
167
|
- `config`: Configuration object or API key string
|
|
168
168
|
- If a string is provided, it's treated as the `apiKey`
|
|
169
169
|
- If an object is provided:
|
|
170
|
-
- `apiKey` (string): Your
|
|
170
|
+
- `apiKey` (string): Your Zyfai API key (required)
|
|
171
171
|
- `environment` ('production' | 'staging', optional): API environment (default: 'production')
|
|
172
172
|
- `rpcUrls` (object, optional): Custom RPC URLs per chain to avoid rate limiting (optional, only needed for local operations like `getSmartWalletAddress`)
|
|
173
173
|
- `8453` (string, optional): Base Mainnet RPC URL
|
|
@@ -319,7 +319,7 @@ Session keys enable delegated transaction execution without exposing the main pr
|
|
|
319
319
|
|
|
320
320
|
#### Simple Usage (Recommended)
|
|
321
321
|
|
|
322
|
-
The SDK automatically fetches optimal session configuration from
|
|
322
|
+
The SDK automatically fetches optimal session configuration from Zyfai API:
|
|
323
323
|
|
|
324
324
|
```typescript
|
|
325
325
|
// SDK automatically:
|
|
@@ -375,7 +375,7 @@ if (result.success) {
|
|
|
375
375
|
|
|
376
376
|
- Amount must be in least decimal units. For USDC (6 decimals): 1 USDC = 1000000
|
|
377
377
|
- Token address is automatically selected based on chain (USDC for Base/Arbitrum, USDT for Plasma)
|
|
378
|
-
- The SDK automatically authenticates via SIWE before logging the deposit with
|
|
378
|
+
- The SDK automatically authenticates via SIWE before logging the deposit with Zyfai's API, so no extra steps are required on your end once the transfer confirms
|
|
379
379
|
|
|
380
380
|
### 5. Withdraw Funds
|
|
381
381
|
|
|
@@ -902,7 +902,7 @@ If `withdrawFunds` returns without a `txHash`, the withdrawal is being processed
|
|
|
902
902
|
|
|
903
903
|
### Data API CORS Errors
|
|
904
904
|
|
|
905
|
-
Some Data API endpoints may require server-side CORS configuration. If you see CORS errors for endpoints like `onchain-earnings`, `calculate-onchain-earnings`, or `opportunities`, contact
|
|
905
|
+
Some Data API endpoints may require server-side CORS configuration. If you see CORS errors for endpoints like `onchain-earnings`, `calculate-onchain-earnings`, or `opportunities`, contact Zyfai support to ensure your origin is whitelisted.
|
|
906
906
|
|
|
907
907
|
## Contributing
|
|
908
908
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Chain, PublicClient } from 'viem';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Zyfai SDK Types
|
|
5
5
|
*/
|
|
6
6
|
type Address = `0x${string}`;
|
|
7
7
|
type Hex = `0x${string}`;
|
|
@@ -404,7 +404,7 @@ declare const isSupportedChain: (chainId: number) => chainId is SupportedChainId
|
|
|
404
404
|
declare const getSupportedChainIds: () => SupportedChainId[];
|
|
405
405
|
|
|
406
406
|
/**
|
|
407
|
-
*
|
|
407
|
+
* Zyfai SDK Main Class
|
|
408
408
|
*/
|
|
409
409
|
|
|
410
410
|
declare class ZyfaiSDK {
|
|
@@ -515,7 +515,7 @@ declare class ZyfaiSDK {
|
|
|
515
515
|
*/
|
|
516
516
|
deploySafe(userAddress: string, chainId: SupportedChainId): Promise<DeploySafeResponse>;
|
|
517
517
|
/**
|
|
518
|
-
* Create session key with auto-fetched configuration from
|
|
518
|
+
* Create session key with auto-fetched configuration from Zyfai API
|
|
519
519
|
* This is the simplified method that automatically fetches session configuration
|
|
520
520
|
*
|
|
521
521
|
* @param userAddress - User's EOA or Safe address
|
|
@@ -544,7 +544,7 @@ declare class ZyfaiSDK {
|
|
|
544
544
|
*/
|
|
545
545
|
private updateUserProtocols;
|
|
546
546
|
/**
|
|
547
|
-
* Activate session key via
|
|
547
|
+
* Activate session key via Zyfai API
|
|
548
548
|
*/
|
|
549
549
|
private activateSessionKey;
|
|
550
550
|
/**
|
|
@@ -577,7 +577,7 @@ declare class ZyfaiSDK {
|
|
|
577
577
|
depositFunds(userAddress: string, chainId: SupportedChainId, amount: string): Promise<DepositResponse>;
|
|
578
578
|
/**
|
|
579
579
|
* Withdraw funds from Safe smart wallet
|
|
580
|
-
* Initiates a withdrawal request to the
|
|
580
|
+
* Initiates a withdrawal request to the Zyfai API
|
|
581
581
|
* Note: The withdrawal is processed asynchronously, so txHash may not be immediately available
|
|
582
582
|
* Funds are always withdrawn to the Safe owner's address (userAddress)
|
|
583
583
|
*
|
|
@@ -649,7 +649,7 @@ declare class ZyfaiSDK {
|
|
|
649
649
|
*/
|
|
650
650
|
getUserDetails(): Promise<UserDetailsResponse>;
|
|
651
651
|
/**
|
|
652
|
-
* Get total value locked (TVL) across all
|
|
652
|
+
* Get total value locked (TVL) across all Zyfai accounts
|
|
653
653
|
*
|
|
654
654
|
* @returns Total TVL in USD and breakdown by chain
|
|
655
655
|
*
|
|
@@ -661,7 +661,7 @@ declare class ZyfaiSDK {
|
|
|
661
661
|
*/
|
|
662
662
|
getTVL(): Promise<TVLResponse>;
|
|
663
663
|
/**
|
|
664
|
-
* Get total volume across all
|
|
664
|
+
* Get total volume across all Zyfai accounts
|
|
665
665
|
*
|
|
666
666
|
* @returns Total volume in USD
|
|
667
667
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Chain, PublicClient } from 'viem';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Zyfai SDK Types
|
|
5
5
|
*/
|
|
6
6
|
type Address = `0x${string}`;
|
|
7
7
|
type Hex = `0x${string}`;
|
|
@@ -404,7 +404,7 @@ declare const isSupportedChain: (chainId: number) => chainId is SupportedChainId
|
|
|
404
404
|
declare const getSupportedChainIds: () => SupportedChainId[];
|
|
405
405
|
|
|
406
406
|
/**
|
|
407
|
-
*
|
|
407
|
+
* Zyfai SDK Main Class
|
|
408
408
|
*/
|
|
409
409
|
|
|
410
410
|
declare class ZyfaiSDK {
|
|
@@ -515,7 +515,7 @@ declare class ZyfaiSDK {
|
|
|
515
515
|
*/
|
|
516
516
|
deploySafe(userAddress: string, chainId: SupportedChainId): Promise<DeploySafeResponse>;
|
|
517
517
|
/**
|
|
518
|
-
* Create session key with auto-fetched configuration from
|
|
518
|
+
* Create session key with auto-fetched configuration from Zyfai API
|
|
519
519
|
* This is the simplified method that automatically fetches session configuration
|
|
520
520
|
*
|
|
521
521
|
* @param userAddress - User's EOA or Safe address
|
|
@@ -544,7 +544,7 @@ declare class ZyfaiSDK {
|
|
|
544
544
|
*/
|
|
545
545
|
private updateUserProtocols;
|
|
546
546
|
/**
|
|
547
|
-
* Activate session key via
|
|
547
|
+
* Activate session key via Zyfai API
|
|
548
548
|
*/
|
|
549
549
|
private activateSessionKey;
|
|
550
550
|
/**
|
|
@@ -577,7 +577,7 @@ declare class ZyfaiSDK {
|
|
|
577
577
|
depositFunds(userAddress: string, chainId: SupportedChainId, amount: string): Promise<DepositResponse>;
|
|
578
578
|
/**
|
|
579
579
|
* Withdraw funds from Safe smart wallet
|
|
580
|
-
* Initiates a withdrawal request to the
|
|
580
|
+
* Initiates a withdrawal request to the Zyfai API
|
|
581
581
|
* Note: The withdrawal is processed asynchronously, so txHash may not be immediately available
|
|
582
582
|
* Funds are always withdrawn to the Safe owner's address (userAddress)
|
|
583
583
|
*
|
|
@@ -649,7 +649,7 @@ declare class ZyfaiSDK {
|
|
|
649
649
|
*/
|
|
650
650
|
getUserDetails(): Promise<UserDetailsResponse>;
|
|
651
651
|
/**
|
|
652
|
-
* Get total value locked (TVL) across all
|
|
652
|
+
* Get total value locked (TVL) across all Zyfai accounts
|
|
653
653
|
*
|
|
654
654
|
* @returns Total TVL in USD and breakdown by chain
|
|
655
655
|
*
|
|
@@ -661,7 +661,7 @@ declare class ZyfaiSDK {
|
|
|
661
661
|
*/
|
|
662
662
|
getTVL(): Promise<TVLResponse>;
|
|
663
663
|
/**
|
|
664
|
-
* Get total volume across all
|
|
664
|
+
* Get total volume across all Zyfai accounts
|
|
665
665
|
*
|
|
666
666
|
* @returns Total volume in USD
|
|
667
667
|
*
|
package/dist/index.js
CHANGED
|
@@ -1095,7 +1095,7 @@ var ZyfaiSDK = class {
|
|
|
1095
1095
|
}
|
|
1096
1096
|
}
|
|
1097
1097
|
/**
|
|
1098
|
-
* Create session key with auto-fetched configuration from
|
|
1098
|
+
* Create session key with auto-fetched configuration from Zyfai API
|
|
1099
1099
|
* This is the simplified method that automatically fetches session configuration
|
|
1100
1100
|
*
|
|
1101
1101
|
* @param userAddress - User's EOA or Safe address
|
|
@@ -1266,7 +1266,7 @@ var ZyfaiSDK = class {
|
|
|
1266
1266
|
}
|
|
1267
1267
|
}
|
|
1268
1268
|
/**
|
|
1269
|
-
* Activate session key via
|
|
1269
|
+
* Activate session key via Zyfai API
|
|
1270
1270
|
*/
|
|
1271
1271
|
async activateSessionKey(signer, signature, sessionNonces) {
|
|
1272
1272
|
const nonces = this.normalizeSessionNonces(sessionNonces);
|
|
@@ -1377,7 +1377,7 @@ var ZyfaiSDK = class {
|
|
|
1377
1377
|
}
|
|
1378
1378
|
/**
|
|
1379
1379
|
* Withdraw funds from Safe smart wallet
|
|
1380
|
-
* Initiates a withdrawal request to the
|
|
1380
|
+
* Initiates a withdrawal request to the Zyfai API
|
|
1381
1381
|
* Note: The withdrawal is processed asynchronously, so txHash may not be immediately available
|
|
1382
1382
|
* Funds are always withdrawn to the Safe owner's address (userAddress)
|
|
1383
1383
|
*
|
|
@@ -1598,7 +1598,7 @@ var ZyfaiSDK = class {
|
|
|
1598
1598
|
// TVL & Volume Methods
|
|
1599
1599
|
// ============================================================================
|
|
1600
1600
|
/**
|
|
1601
|
-
* Get total value locked (TVL) across all
|
|
1601
|
+
* Get total value locked (TVL) across all Zyfai accounts
|
|
1602
1602
|
*
|
|
1603
1603
|
* @returns Total TVL in USD and breakdown by chain
|
|
1604
1604
|
*
|
|
@@ -1629,7 +1629,7 @@ var ZyfaiSDK = class {
|
|
|
1629
1629
|
}
|
|
1630
1630
|
}
|
|
1631
1631
|
/**
|
|
1632
|
-
* Get total volume across all
|
|
1632
|
+
* Get total volume across all Zyfai accounts
|
|
1633
1633
|
*
|
|
1634
1634
|
* @returns Total volume in USD
|
|
1635
1635
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -1072,7 +1072,7 @@ var ZyfaiSDK = class {
|
|
|
1072
1072
|
}
|
|
1073
1073
|
}
|
|
1074
1074
|
/**
|
|
1075
|
-
* Create session key with auto-fetched configuration from
|
|
1075
|
+
* Create session key with auto-fetched configuration from Zyfai API
|
|
1076
1076
|
* This is the simplified method that automatically fetches session configuration
|
|
1077
1077
|
*
|
|
1078
1078
|
* @param userAddress - User's EOA or Safe address
|
|
@@ -1243,7 +1243,7 @@ var ZyfaiSDK = class {
|
|
|
1243
1243
|
}
|
|
1244
1244
|
}
|
|
1245
1245
|
/**
|
|
1246
|
-
* Activate session key via
|
|
1246
|
+
* Activate session key via Zyfai API
|
|
1247
1247
|
*/
|
|
1248
1248
|
async activateSessionKey(signer, signature, sessionNonces) {
|
|
1249
1249
|
const nonces = this.normalizeSessionNonces(sessionNonces);
|
|
@@ -1354,7 +1354,7 @@ var ZyfaiSDK = class {
|
|
|
1354
1354
|
}
|
|
1355
1355
|
/**
|
|
1356
1356
|
* Withdraw funds from Safe smart wallet
|
|
1357
|
-
* Initiates a withdrawal request to the
|
|
1357
|
+
* Initiates a withdrawal request to the Zyfai API
|
|
1358
1358
|
* Note: The withdrawal is processed asynchronously, so txHash may not be immediately available
|
|
1359
1359
|
* Funds are always withdrawn to the Safe owner's address (userAddress)
|
|
1360
1360
|
*
|
|
@@ -1575,7 +1575,7 @@ var ZyfaiSDK = class {
|
|
|
1575
1575
|
// TVL & Volume Methods
|
|
1576
1576
|
// ============================================================================
|
|
1577
1577
|
/**
|
|
1578
|
-
* Get total value locked (TVL) across all
|
|
1578
|
+
* Get total value locked (TVL) across all Zyfai accounts
|
|
1579
1579
|
*
|
|
1580
1580
|
* @returns Total TVL in USD and breakdown by chain
|
|
1581
1581
|
*
|
|
@@ -1606,7 +1606,7 @@ var ZyfaiSDK = class {
|
|
|
1606
1606
|
}
|
|
1607
1607
|
}
|
|
1608
1608
|
/**
|
|
1609
|
-
* Get total volume across all
|
|
1609
|
+
* Get total volume across all Zyfai accounts
|
|
1610
1610
|
*
|
|
1611
1611
|
* @returns Total volume in USD
|
|
1612
1612
|
*
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zyfai/sdk",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "TypeScript SDK for
|
|
3
|
+
"version": "0.1.28",
|
|
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",
|
|
7
7
|
"types": "dist/index.d.ts",
|