@zyfai/sdk 0.2.6 → 0.2.8

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
@@ -466,8 +466,80 @@ The SDK provides access to various analytics and data endpoints:
466
466
  const user = await sdk.getUserDetails();
467
467
  console.log("Smart Wallet:", user.user.smartWallet);
468
468
  console.log("Active Chains:", user.user.chains);
469
+ console.log("Active Protocols:", user.user.protocols);
469
470
  ```
470
471
 
472
+ #### Pause Agent
473
+
474
+ Pause the agent by clearing all protocols. This effectively stops automated operations:
475
+
476
+ ```typescript
477
+ // Pause the agent (clears all protocols)
478
+ const result = await sdk.pauseAgent();
479
+
480
+ if (result.success) {
481
+ console.log("Agent paused successfully");
482
+ console.log("User ID:", result.userId);
483
+ }
484
+
485
+ // Verify the agent is paused
486
+ const userDetails = await sdk.getUserDetails();
487
+ console.log("Active protocols:", userDetails.user.protocols.length); // Should be 0
488
+ ```
489
+
490
+ **Note**:
491
+ - User must be authenticated (automatically done via `connectAccount()`)
492
+ - This sets the user's protocols to an empty array
493
+ - To resume operations, call `updateUserProfile()` with the desired protocols
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
+
471
543
  #### Get TVL & Volume
472
544
 
473
545
  ```typescript
@@ -653,26 +725,27 @@ All examples are available in the `examples/` directory:
653
725
  7. **`get-protocols.ts`** - Fetch available protocols for a chain
654
726
  8. **`get-positions.ts`** - Get active positions for a wallet
655
727
  9. **`get-user-details.ts`** - Get authenticated user details
656
- 10. **`get-tvl-volume.ts`** - Get TVL and trading volume
657
- 11. **`get-active-wallets.ts`** - Get active wallets by chain
658
- 12. **`get-smart-wallets-by-eoa.ts`** - Get smart wallets by EOA
659
- 13. **`get-first-topup.ts`** - Get first deposit information
660
- 14. **`get-history.ts`** - Get transaction history
728
+ 10. **`pause-agent.ts`** - Pause agent by clearing all protocols
729
+ 11. **`get-tvl-volume.ts`** - Get TVL and trading volume
730
+ 12. **`get-active-wallets.ts`** - Get active wallets by chain
731
+ 13. **`get-smart-wallets-by-eoa.ts`** - Get smart wallets by EOA
732
+ 14. **`get-first-topup.ts`** - Get first deposit information
733
+ 15. **`get-history.ts`** - Get transaction history
661
734
 
662
735
  ### Analytics & Earnings
663
736
 
664
- 15. **`get-onchain-earnings.ts`** - Get/calculate onchain earnings
665
- 16. **`get-daily-earnings.ts`** - Get daily earnings breakdown
666
- 17. **`get-apy-history.ts`** - Get daily APY history with weighted averages
737
+ 16. **`get-onchain-earnings.ts`** - Get/calculate onchain earnings
738
+ 17. **`get-daily-earnings.ts`** - Get daily earnings breakdown
739
+ 18. **`get-apy-history.ts`** - Get daily APY history with weighted averages
667
740
 
668
741
  ### Opportunities & Rebalancing
669
742
 
670
- 18. **`get-opportunities.ts`** - Get conservative and aggressive yield opportunities
671
- 19. **`get-rebalance-info.ts`** - Get rebalance events and frequency tier
743
+ 19. **`get-opportunities.ts`** - Get conservative and aggressive yield opportunities
744
+ 20. **`get-rebalance-info.ts`** - Get rebalance events and frequency tier
672
745
 
673
746
  ### Premium Features
674
747
 
675
- 20. **`get-debank-portfolio.ts`** - Get Debank multi-chain portfolio
748
+ 21. **`get-debank-portfolio.ts`** - Get Debank multi-chain portfolio
676
749
 
677
750
  ### Quick Start: Run the End-to-End Example
678
751
 
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;
@@ -510,6 +515,84 @@ declare class ZyfaiSDK {
510
515
  * ```
511
516
  */
512
517
  updateUserProfile(request: UpdateUserProfileRequest): Promise<UpdateUserProfileResponse>;
518
+ /**
519
+ * Pause the agent by clearing all protocols
520
+ * Sets the user's protocols to an empty array, effectively pausing automated operations
521
+ *
522
+ * @returns Response indicating success and updated user details
523
+ *
524
+ * @example
525
+ * ```typescript
526
+ * const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
527
+ *
528
+ * // Connect account first
529
+ * await sdk.connectAccount();
530
+ *
531
+ * // Pause the agent
532
+ * const result = await sdk.pauseAgent();
533
+ * console.log('Agent paused:', result.success);
534
+ * ```
535
+ */
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>;
513
596
  /**
514
597
  * Initialize user after Safe deployment
515
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;
@@ -510,6 +515,84 @@ declare class ZyfaiSDK {
510
515
  * ```
511
516
  */
512
517
  updateUserProfile(request: UpdateUserProfileRequest): Promise<UpdateUserProfileResponse>;
518
+ /**
519
+ * Pause the agent by clearing all protocols
520
+ * Sets the user's protocols to an empty array, effectively pausing automated operations
521
+ *
522
+ * @returns Response indicating success and updated user details
523
+ *
524
+ * @example
525
+ * ```typescript
526
+ * const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
527
+ *
528
+ * // Connect account first
529
+ * await sdk.connectAccount();
530
+ *
531
+ * // Pause the agent
532
+ * const result = await sdk.pauseAgent();
533
+ * console.log('Agent paused:', result.success);
534
+ * ```
535
+ */
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>;
513
596
  /**
514
597
  * Initialize user after Safe deployment
515
598
  * This method is automatically called after deploySafe to initialize user state
package/dist/index.js CHANGED
@@ -793,6 +793,124 @@ var ZyfaiSDK = class {
793
793
  );
794
794
  }
795
795
  }
796
+ /**
797
+ * Pause the agent by clearing all protocols
798
+ * Sets the user's protocols to an empty array, effectively pausing automated operations
799
+ *
800
+ * @returns Response indicating success and updated user details
801
+ *
802
+ * @example
803
+ * ```typescript
804
+ * const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
805
+ *
806
+ * // Connect account first
807
+ * await sdk.connectAccount();
808
+ *
809
+ * // Pause the agent
810
+ * const result = await sdk.pauseAgent();
811
+ * console.log('Agent paused:', result.success);
812
+ * ```
813
+ */
814
+ async pauseAgent() {
815
+ try {
816
+ const response = await this.updateUserProfile({
817
+ protocols: []
818
+ });
819
+ return response;
820
+ } catch (error) {
821
+ throw new Error(`Failed to pause agent: ${error.message}`);
822
+ }
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 = 3) {
844
+ try {
845
+ const response = await this.updateUserProfile({
846
+ splitting: true,
847
+ minSplits
848
+ });
849
+ return response;
850
+ } catch (error) {
851
+ throw new Error(`Failed to enable splitting: ${error.message}`);
852
+ }
853
+ }
854
+ /**
855
+ * Disable splitting for the user's account
856
+ * When disabled, deposits will not be split across multiple protocols
857
+ *
858
+ * @returns Response indicating success and updated user details
859
+ *
860
+ * @example
861
+ * ```typescript
862
+ * const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
863
+ *
864
+ * // Connect account first
865
+ * await sdk.connectAccount(privateKey, chainId);
866
+ *
867
+ * // Disable splitting
868
+ * const result = await sdk.disableSplitting();
869
+ * console.log('Splitting disabled:', result.success);
870
+ * ```
871
+ */
872
+ async disableSplitting() {
873
+ try {
874
+ const response = await this.updateUserProfile({
875
+ splitting: false
876
+ });
877
+ return response;
878
+ } catch (error) {
879
+ throw new Error(`Failed to disable splitting: ${error.message}`);
880
+ }
881
+ }
882
+ /**
883
+ * Update the minimum number of splits for the user's account
884
+ * This controls across how many protocols deposits should be distributed
885
+ *
886
+ * @param minSplits - Minimum number of protocols to split across
887
+ * @returns Response indicating success and updated user details
888
+ *
889
+ * @example
890
+ * ```typescript
891
+ * const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
892
+ *
893
+ * // Connect account first
894
+ * await sdk.connectAccount(privateKey, chainId);
895
+ *
896
+ * // Update minimum splits to 5
897
+ * const result = await sdk.updateMinSplits(5);
898
+ * console.log('Min splits updated:', result.success);
899
+ * ```
900
+ */
901
+ async updateMinSplits(minSplits) {
902
+ try {
903
+ if (minSplits < 1) {
904
+ throw new Error("minSplits must be at least 1");
905
+ }
906
+ const response = await this.updateUserProfile({
907
+ minSplits
908
+ });
909
+ return response;
910
+ } catch (error) {
911
+ throw new Error(`Failed to update min splits: ${error.message}`);
912
+ }
913
+ }
796
914
  /**
797
915
  * Initialize user after Safe deployment
798
916
  * This method is automatically called after deploySafe to initialize user state
package/dist/index.mjs CHANGED
@@ -770,6 +770,124 @@ var ZyfaiSDK = class {
770
770
  );
771
771
  }
772
772
  }
773
+ /**
774
+ * Pause the agent by clearing all protocols
775
+ * Sets the user's protocols to an empty array, effectively pausing automated operations
776
+ *
777
+ * @returns Response indicating success and updated user details
778
+ *
779
+ * @example
780
+ * ```typescript
781
+ * const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
782
+ *
783
+ * // Connect account first
784
+ * await sdk.connectAccount();
785
+ *
786
+ * // Pause the agent
787
+ * const result = await sdk.pauseAgent();
788
+ * console.log('Agent paused:', result.success);
789
+ * ```
790
+ */
791
+ async pauseAgent() {
792
+ try {
793
+ const response = await this.updateUserProfile({
794
+ protocols: []
795
+ });
796
+ return response;
797
+ } catch (error) {
798
+ throw new Error(`Failed to pause agent: ${error.message}`);
799
+ }
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 = 3) {
821
+ try {
822
+ const response = await this.updateUserProfile({
823
+ splitting: true,
824
+ minSplits
825
+ });
826
+ return response;
827
+ } catch (error) {
828
+ throw new Error(`Failed to enable splitting: ${error.message}`);
829
+ }
830
+ }
831
+ /**
832
+ * Disable splitting for the user's account
833
+ * When disabled, deposits will not be split across multiple protocols
834
+ *
835
+ * @returns Response indicating success and updated user details
836
+ *
837
+ * @example
838
+ * ```typescript
839
+ * const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
840
+ *
841
+ * // Connect account first
842
+ * await sdk.connectAccount(privateKey, chainId);
843
+ *
844
+ * // Disable splitting
845
+ * const result = await sdk.disableSplitting();
846
+ * console.log('Splitting disabled:', result.success);
847
+ * ```
848
+ */
849
+ async disableSplitting() {
850
+ try {
851
+ const response = await this.updateUserProfile({
852
+ splitting: false
853
+ });
854
+ return response;
855
+ } catch (error) {
856
+ throw new Error(`Failed to disable splitting: ${error.message}`);
857
+ }
858
+ }
859
+ /**
860
+ * Update the minimum number of splits for the user's account
861
+ * This controls across how many protocols deposits should be distributed
862
+ *
863
+ * @param minSplits - Minimum number of protocols to split across
864
+ * @returns Response indicating success and updated user details
865
+ *
866
+ * @example
867
+ * ```typescript
868
+ * const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
869
+ *
870
+ * // Connect account first
871
+ * await sdk.connectAccount(privateKey, chainId);
872
+ *
873
+ * // Update minimum splits to 5
874
+ * const result = await sdk.updateMinSplits(5);
875
+ * console.log('Min splits updated:', result.success);
876
+ * ```
877
+ */
878
+ async updateMinSplits(minSplits) {
879
+ try {
880
+ if (minSplits < 1) {
881
+ throw new Error("minSplits must be at least 1");
882
+ }
883
+ const response = await this.updateUserProfile({
884
+ minSplits
885
+ });
886
+ return response;
887
+ } catch (error) {
888
+ throw new Error(`Failed to update min splits: ${error.message}`);
889
+ }
890
+ }
773
891
  /**
774
892
  * Initialize user after Safe deployment
775
893
  * This method is automatically called after deploySafe to initialize user state
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyfai/sdk",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
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",