@zyfai/sdk 0.2.7 → 0.2.9

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 CHANGED
@@ -492,6 +492,54 @@ console.log("Active protocols:", userDetails.user.protocols.length); // Should b
492
492
  - This sets the user's protocols to an empty array
493
493
  - To resume operations, call `updateUserProfile()` with the desired protocols
494
494
 
495
+ #### Splitting Management
496
+
497
+ Control how deposits are split across multiple protocols for diversification.
498
+
499
+ **Enable Splitting:**
500
+
501
+ ```typescript
502
+ // Enable splitting with minimum 3 protocols
503
+ const result = await sdk.enableSplitting(3);
504
+
505
+ if (result.success) {
506
+ console.log("Splitting enabled with min splits: 3");
507
+ }
508
+
509
+ // Verify splitting is enabled
510
+ const userDetails = await sdk.getUserDetails();
511
+ console.log("Splitting enabled:", userDetails.user.splitting); // true
512
+ console.log("Min splits:", userDetails.user.minSplits); // 3
513
+ ```
514
+
515
+ **Disable Splitting:**
516
+
517
+ ```typescript
518
+ // Disable splitting
519
+ const result = await sdk.disableSplitting();
520
+
521
+ if (result.success) {
522
+ console.log("Splitting disabled");
523
+ }
524
+ ```
525
+
526
+ **Update Minimum Splits:**
527
+
528
+ ```typescript
529
+ // Update minimum number of protocols to split across
530
+ const result = await sdk.updateMinSplits(5);
531
+
532
+ if (result.success) {
533
+ console.log("Minimum splits updated to 5");
534
+ }
535
+ ```
536
+
537
+ **Note**:
538
+ - User must be authenticated (automatically done via `connectAccount()`)
539
+ - When splitting is enabled, deposits are distributed across multiple protocols based on `minSplits`
540
+ - `minSplits` must be at least 1
541
+ - Splitting helps with diversification and risk management
542
+
495
543
  #### Get TVL & Volume
496
544
 
497
545
  ```typescript
package/dist/index.d.mts CHANGED
@@ -28,6 +28,9 @@ interface UpdateUserProfileRequest {
28
28
  chains?: number[];
29
29
  protocols?: string[];
30
30
  autoSelectProtocols?: boolean;
31
+ customization?: Record<string, string[]>;
32
+ splitting?: boolean;
33
+ minSplits?: number;
31
34
  }
32
35
  /** @internal */
33
36
  interface UpdateUserProfileResponse {
@@ -141,6 +144,8 @@ interface UserDetails {
141
144
  crosschainStrategy?: boolean;
142
145
  agentName?: string;
143
146
  customization?: Record<string, string[]>;
147
+ splitting?: boolean;
148
+ minSplits?: number;
144
149
  }
145
150
  interface UserDetailsResponse {
146
151
  success: boolean;
@@ -529,6 +534,65 @@ declare class ZyfaiSDK {
529
534
  * ```
530
535
  */
531
536
  pauseAgent(): Promise<UpdateUserProfileResponse>;
537
+ /**
538
+ * Enable splitting for the user's account
539
+ * When enabled, deposits are split across multiple protocols based on minSplits setting
540
+ *
541
+ * @param minSplits - Optional minimum number of protocols to split across (default: 3)
542
+ * @returns Response indicating success and updated user details
543
+ *
544
+ * @example
545
+ * ```typescript
546
+ * const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
547
+ *
548
+ * // Connect account first
549
+ * await sdk.connectAccount(privateKey, chainId);
550
+ *
551
+ * // Enable splitting with minimum 3 protocols
552
+ * const result = await sdk.enableSplitting(3);
553
+ * console.log('Splitting enabled:', result.success);
554
+ * ```
555
+ */
556
+ enableSplitting(minSplits?: number): Promise<UpdateUserProfileResponse>;
557
+ /**
558
+ * Disable splitting for the user's account
559
+ * When disabled, deposits will not be split across multiple protocols
560
+ *
561
+ * @returns Response indicating success and updated user details
562
+ *
563
+ * @example
564
+ * ```typescript
565
+ * const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
566
+ *
567
+ * // Connect account first
568
+ * await sdk.connectAccount(privateKey, chainId);
569
+ *
570
+ * // Disable splitting
571
+ * const result = await sdk.disableSplitting();
572
+ * console.log('Splitting disabled:', result.success);
573
+ * ```
574
+ */
575
+ disableSplitting(): Promise<UpdateUserProfileResponse>;
576
+ /**
577
+ * Update the minimum number of splits for the user's account
578
+ * This controls across how many protocols deposits should be distributed
579
+ *
580
+ * @param minSplits - Minimum number of protocols to split across
581
+ * @returns Response indicating success and updated user details
582
+ *
583
+ * @example
584
+ * ```typescript
585
+ * const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
586
+ *
587
+ * // Connect account first
588
+ * await sdk.connectAccount(privateKey, chainId);
589
+ *
590
+ * // Update minimum splits to 5
591
+ * const result = await sdk.updateMinSplits(5);
592
+ * console.log('Min splits updated:', result.success);
593
+ * ```
594
+ */
595
+ updateMinSplits(minSplits: number): Promise<UpdateUserProfileResponse>;
532
596
  /**
533
597
  * Initialize user after Safe deployment
534
598
  * This method is automatically called after deploySafe to initialize user state
package/dist/index.d.ts CHANGED
@@ -28,6 +28,9 @@ interface UpdateUserProfileRequest {
28
28
  chains?: number[];
29
29
  protocols?: string[];
30
30
  autoSelectProtocols?: boolean;
31
+ customization?: Record<string, string[]>;
32
+ splitting?: boolean;
33
+ minSplits?: number;
31
34
  }
32
35
  /** @internal */
33
36
  interface UpdateUserProfileResponse {
@@ -141,6 +144,8 @@ interface UserDetails {
141
144
  crosschainStrategy?: boolean;
142
145
  agentName?: string;
143
146
  customization?: Record<string, string[]>;
147
+ splitting?: boolean;
148
+ minSplits?: number;
144
149
  }
145
150
  interface UserDetailsResponse {
146
151
  success: boolean;
@@ -529,6 +534,65 @@ declare class ZyfaiSDK {
529
534
  * ```
530
535
  */
531
536
  pauseAgent(): Promise<UpdateUserProfileResponse>;
537
+ /**
538
+ * Enable splitting for the user's account
539
+ * When enabled, deposits are split across multiple protocols based on minSplits setting
540
+ *
541
+ * @param minSplits - Optional minimum number of protocols to split across (default: 3)
542
+ * @returns Response indicating success and updated user details
543
+ *
544
+ * @example
545
+ * ```typescript
546
+ * const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
547
+ *
548
+ * // Connect account first
549
+ * await sdk.connectAccount(privateKey, chainId);
550
+ *
551
+ * // Enable splitting with minimum 3 protocols
552
+ * const result = await sdk.enableSplitting(3);
553
+ * console.log('Splitting enabled:', result.success);
554
+ * ```
555
+ */
556
+ enableSplitting(minSplits?: number): Promise<UpdateUserProfileResponse>;
557
+ /**
558
+ * Disable splitting for the user's account
559
+ * When disabled, deposits will not be split across multiple protocols
560
+ *
561
+ * @returns Response indicating success and updated user details
562
+ *
563
+ * @example
564
+ * ```typescript
565
+ * const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
566
+ *
567
+ * // Connect account first
568
+ * await sdk.connectAccount(privateKey, chainId);
569
+ *
570
+ * // Disable splitting
571
+ * const result = await sdk.disableSplitting();
572
+ * console.log('Splitting disabled:', result.success);
573
+ * ```
574
+ */
575
+ disableSplitting(): Promise<UpdateUserProfileResponse>;
576
+ /**
577
+ * Update the minimum number of splits for the user's account
578
+ * This controls across how many protocols deposits should be distributed
579
+ *
580
+ * @param minSplits - Minimum number of protocols to split across
581
+ * @returns Response indicating success and updated user details
582
+ *
583
+ * @example
584
+ * ```typescript
585
+ * const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
586
+ *
587
+ * // Connect account first
588
+ * await sdk.connectAccount(privateKey, chainId);
589
+ *
590
+ * // Update minimum splits to 5
591
+ * const result = await sdk.updateMinSplits(5);
592
+ * console.log('Min splits updated:', result.success);
593
+ * ```
594
+ */
595
+ updateMinSplits(minSplits: number): Promise<UpdateUserProfileResponse>;
532
596
  /**
533
597
  * Initialize user after Safe deployment
534
598
  * This method is automatically called after deploySafe to initialize user state
package/dist/index.js CHANGED
@@ -821,6 +821,99 @@ var ZyfaiSDK = class {
821
821
  throw new Error(`Failed to pause agent: ${error.message}`);
822
822
  }
823
823
  }
824
+ /**
825
+ * Enable splitting for the user's account
826
+ * When enabled, deposits are split across multiple protocols based on minSplits setting
827
+ *
828
+ * @param minSplits - Optional minimum number of protocols to split across (default: 3)
829
+ * @returns Response indicating success and updated user details
830
+ *
831
+ * @example
832
+ * ```typescript
833
+ * const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
834
+ *
835
+ * // Connect account first
836
+ * await sdk.connectAccount(privateKey, chainId);
837
+ *
838
+ * // Enable splitting with minimum 3 protocols
839
+ * const result = await sdk.enableSplitting(3);
840
+ * console.log('Splitting enabled:', result.success);
841
+ * ```
842
+ */
843
+ async enableSplitting(minSplits = 1) {
844
+ if (minSplits > 4) {
845
+ throw new Error("minSplits cannot exceed 4");
846
+ }
847
+ try {
848
+ const response = await this.updateUserProfile({
849
+ splitting: true,
850
+ minSplits
851
+ });
852
+ return response;
853
+ } catch (error) {
854
+ throw new Error(`Failed to enable splitting: ${error.message}`);
855
+ }
856
+ }
857
+ /**
858
+ * Disable splitting for the user's account
859
+ * When disabled, deposits will not be split across multiple protocols
860
+ *
861
+ * @returns Response indicating success and updated user details
862
+ *
863
+ * @example
864
+ * ```typescript
865
+ * const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
866
+ *
867
+ * // Connect account first
868
+ * await sdk.connectAccount(privateKey, chainId);
869
+ *
870
+ * // Disable splitting
871
+ * const result = await sdk.disableSplitting();
872
+ * console.log('Splitting disabled:', result.success);
873
+ * ```
874
+ */
875
+ async disableSplitting() {
876
+ try {
877
+ const response = await this.updateUserProfile({
878
+ splitting: false
879
+ });
880
+ return response;
881
+ } catch (error) {
882
+ throw new Error(`Failed to disable splitting: ${error.message}`);
883
+ }
884
+ }
885
+ /**
886
+ * Update the minimum number of splits for the user's account
887
+ * This controls across how many protocols deposits should be distributed
888
+ *
889
+ * @param minSplits - Minimum number of protocols to split across
890
+ * @returns Response indicating success and updated user details
891
+ *
892
+ * @example
893
+ * ```typescript
894
+ * const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
895
+ *
896
+ * // Connect account first
897
+ * await sdk.connectAccount(privateKey, chainId);
898
+ *
899
+ * // Update minimum splits to 5
900
+ * const result = await sdk.updateMinSplits(5);
901
+ * console.log('Min splits updated:', result.success);
902
+ * ```
903
+ */
904
+ async updateMinSplits(minSplits) {
905
+ try {
906
+ if (minSplits < 1) {
907
+ throw new Error("minSplits must be at least 1");
908
+ }
909
+ const response = await this.updateUserProfile({
910
+ minSplits
911
+ });
912
+ return response;
913
+ } catch (error) {
914
+ throw new Error(`Failed to update min splits: ${error.message}`);
915
+ }
916
+ }
824
917
  /**
825
918
  * Initialize user after Safe deployment
826
919
  * This method is automatically called after deploySafe to initialize user state
@@ -1647,7 +1740,9 @@ var ZyfaiSDK = class {
1647
1740
  omniAccount: convertedResponse.omniAccount,
1648
1741
  crosschainStrategy: convertedResponse.crosschainStrategy,
1649
1742
  agentName: convertedResponse.agentName,
1650
- customization: convertedResponse.customization
1743
+ customization: convertedResponse.customization,
1744
+ splitting: convertedResponse.splitting,
1745
+ minSplits: convertedResponse.minSplits
1651
1746
  }
1652
1747
  };
1653
1748
  } catch (error) {
package/dist/index.mjs CHANGED
@@ -798,6 +798,99 @@ var ZyfaiSDK = class {
798
798
  throw new Error(`Failed to pause agent: ${error.message}`);
799
799
  }
800
800
  }
801
+ /**
802
+ * Enable splitting for the user's account
803
+ * When enabled, deposits are split across multiple protocols based on minSplits setting
804
+ *
805
+ * @param minSplits - Optional minimum number of protocols to split across (default: 3)
806
+ * @returns Response indicating success and updated user details
807
+ *
808
+ * @example
809
+ * ```typescript
810
+ * const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
811
+ *
812
+ * // Connect account first
813
+ * await sdk.connectAccount(privateKey, chainId);
814
+ *
815
+ * // Enable splitting with minimum 3 protocols
816
+ * const result = await sdk.enableSplitting(3);
817
+ * console.log('Splitting enabled:', result.success);
818
+ * ```
819
+ */
820
+ async enableSplitting(minSplits = 1) {
821
+ if (minSplits > 4) {
822
+ throw new Error("minSplits cannot exceed 4");
823
+ }
824
+ try {
825
+ const response = await this.updateUserProfile({
826
+ splitting: true,
827
+ minSplits
828
+ });
829
+ return response;
830
+ } catch (error) {
831
+ throw new Error(`Failed to enable splitting: ${error.message}`);
832
+ }
833
+ }
834
+ /**
835
+ * Disable splitting for the user's account
836
+ * When disabled, deposits will not be split across multiple protocols
837
+ *
838
+ * @returns Response indicating success and updated user details
839
+ *
840
+ * @example
841
+ * ```typescript
842
+ * const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
843
+ *
844
+ * // Connect account first
845
+ * await sdk.connectAccount(privateKey, chainId);
846
+ *
847
+ * // Disable splitting
848
+ * const result = await sdk.disableSplitting();
849
+ * console.log('Splitting disabled:', result.success);
850
+ * ```
851
+ */
852
+ async disableSplitting() {
853
+ try {
854
+ const response = await this.updateUserProfile({
855
+ splitting: false
856
+ });
857
+ return response;
858
+ } catch (error) {
859
+ throw new Error(`Failed to disable splitting: ${error.message}`);
860
+ }
861
+ }
862
+ /**
863
+ * Update the minimum number of splits for the user's account
864
+ * This controls across how many protocols deposits should be distributed
865
+ *
866
+ * @param minSplits - Minimum number of protocols to split across
867
+ * @returns Response indicating success and updated user details
868
+ *
869
+ * @example
870
+ * ```typescript
871
+ * const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
872
+ *
873
+ * // Connect account first
874
+ * await sdk.connectAccount(privateKey, chainId);
875
+ *
876
+ * // Update minimum splits to 5
877
+ * const result = await sdk.updateMinSplits(5);
878
+ * console.log('Min splits updated:', result.success);
879
+ * ```
880
+ */
881
+ async updateMinSplits(minSplits) {
882
+ try {
883
+ if (minSplits < 1) {
884
+ throw new Error("minSplits must be at least 1");
885
+ }
886
+ const response = await this.updateUserProfile({
887
+ minSplits
888
+ });
889
+ return response;
890
+ } catch (error) {
891
+ throw new Error(`Failed to update min splits: ${error.message}`);
892
+ }
893
+ }
801
894
  /**
802
895
  * Initialize user after Safe deployment
803
896
  * This method is automatically called after deploySafe to initialize user state
@@ -1624,7 +1717,9 @@ var ZyfaiSDK = class {
1624
1717
  omniAccount: convertedResponse.omniAccount,
1625
1718
  crosschainStrategy: convertedResponse.crosschainStrategy,
1626
1719
  agentName: convertedResponse.agentName,
1627
- customization: convertedResponse.customization
1720
+ customization: convertedResponse.customization,
1721
+ splitting: convertedResponse.splitting,
1722
+ minSplits: convertedResponse.minSplits
1628
1723
  }
1629
1724
  };
1630
1725
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyfai/sdk",
3
- "version": "0.2.7",
3
+ "version": "0.2.9",
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",