@zyfai/sdk 0.2.7 → 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 +48 -0
- package/dist/index.d.mts +64 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.js +90 -0
- package/dist/index.mjs +90 -0
- package/package.json +1 -1
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,96 @@ 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 = 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
|
+
}
|
|
824
914
|
/**
|
|
825
915
|
* Initialize user after Safe deployment
|
|
826
916
|
* This method is automatically called after deploySafe to initialize user state
|
package/dist/index.mjs
CHANGED
|
@@ -798,6 +798,96 @@ 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 = 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
|
+
}
|
|
801
891
|
/**
|
|
802
892
|
* Initialize user after Safe deployment
|
|
803
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.
|
|
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",
|