@zyfai/sdk 0.2.6 → 0.2.7
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 +36 -11
- package/dist/index.d.mts +19 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +28 -0
- package/dist/index.mjs +28 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -466,8 +466,32 @@ 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
|
+
|
|
471
495
|
#### Get TVL & Volume
|
|
472
496
|
|
|
473
497
|
```typescript
|
|
@@ -653,26 +677,27 @@ All examples are available in the `examples/` directory:
|
|
|
653
677
|
7. **`get-protocols.ts`** - Fetch available protocols for a chain
|
|
654
678
|
8. **`get-positions.ts`** - Get active positions for a wallet
|
|
655
679
|
9. **`get-user-details.ts`** - Get authenticated user details
|
|
656
|
-
10. **`
|
|
657
|
-
11. **`get-
|
|
658
|
-
12. **`get-
|
|
659
|
-
13. **`get-
|
|
660
|
-
14. **`get-
|
|
680
|
+
10. **`pause-agent.ts`** - Pause agent by clearing all protocols
|
|
681
|
+
11. **`get-tvl-volume.ts`** - Get TVL and trading volume
|
|
682
|
+
12. **`get-active-wallets.ts`** - Get active wallets by chain
|
|
683
|
+
13. **`get-smart-wallets-by-eoa.ts`** - Get smart wallets by EOA
|
|
684
|
+
14. **`get-first-topup.ts`** - Get first deposit information
|
|
685
|
+
15. **`get-history.ts`** - Get transaction history
|
|
661
686
|
|
|
662
687
|
### Analytics & Earnings
|
|
663
688
|
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
689
|
+
16. **`get-onchain-earnings.ts`** - Get/calculate onchain earnings
|
|
690
|
+
17. **`get-daily-earnings.ts`** - Get daily earnings breakdown
|
|
691
|
+
18. **`get-apy-history.ts`** - Get daily APY history with weighted averages
|
|
667
692
|
|
|
668
693
|
### Opportunities & Rebalancing
|
|
669
694
|
|
|
670
|
-
|
|
671
|
-
|
|
695
|
+
19. **`get-opportunities.ts`** - Get conservative and aggressive yield opportunities
|
|
696
|
+
20. **`get-rebalance-info.ts`** - Get rebalance events and frequency tier
|
|
672
697
|
|
|
673
698
|
### Premium Features
|
|
674
699
|
|
|
675
|
-
|
|
700
|
+
21. **`get-debank-portfolio.ts`** - Get Debank multi-chain portfolio
|
|
676
701
|
|
|
677
702
|
### Quick Start: Run the End-to-End Example
|
|
678
703
|
|
package/dist/index.d.mts
CHANGED
|
@@ -510,6 +510,25 @@ declare class ZyfaiSDK {
|
|
|
510
510
|
* ```
|
|
511
511
|
*/
|
|
512
512
|
updateUserProfile(request: UpdateUserProfileRequest): Promise<UpdateUserProfileResponse>;
|
|
513
|
+
/**
|
|
514
|
+
* Pause the agent by clearing all protocols
|
|
515
|
+
* Sets the user's protocols to an empty array, effectively pausing automated operations
|
|
516
|
+
*
|
|
517
|
+
* @returns Response indicating success and updated user details
|
|
518
|
+
*
|
|
519
|
+
* @example
|
|
520
|
+
* ```typescript
|
|
521
|
+
* const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
|
|
522
|
+
*
|
|
523
|
+
* // Connect account first
|
|
524
|
+
* await sdk.connectAccount();
|
|
525
|
+
*
|
|
526
|
+
* // Pause the agent
|
|
527
|
+
* const result = await sdk.pauseAgent();
|
|
528
|
+
* console.log('Agent paused:', result.success);
|
|
529
|
+
* ```
|
|
530
|
+
*/
|
|
531
|
+
pauseAgent(): Promise<UpdateUserProfileResponse>;
|
|
513
532
|
/**
|
|
514
533
|
* Initialize user after Safe deployment
|
|
515
534
|
* This method is automatically called after deploySafe to initialize user state
|
package/dist/index.d.ts
CHANGED
|
@@ -510,6 +510,25 @@ declare class ZyfaiSDK {
|
|
|
510
510
|
* ```
|
|
511
511
|
*/
|
|
512
512
|
updateUserProfile(request: UpdateUserProfileRequest): Promise<UpdateUserProfileResponse>;
|
|
513
|
+
/**
|
|
514
|
+
* Pause the agent by clearing all protocols
|
|
515
|
+
* Sets the user's protocols to an empty array, effectively pausing automated operations
|
|
516
|
+
*
|
|
517
|
+
* @returns Response indicating success and updated user details
|
|
518
|
+
*
|
|
519
|
+
* @example
|
|
520
|
+
* ```typescript
|
|
521
|
+
* const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
|
|
522
|
+
*
|
|
523
|
+
* // Connect account first
|
|
524
|
+
* await sdk.connectAccount();
|
|
525
|
+
*
|
|
526
|
+
* // Pause the agent
|
|
527
|
+
* const result = await sdk.pauseAgent();
|
|
528
|
+
* console.log('Agent paused:', result.success);
|
|
529
|
+
* ```
|
|
530
|
+
*/
|
|
531
|
+
pauseAgent(): Promise<UpdateUserProfileResponse>;
|
|
513
532
|
/**
|
|
514
533
|
* Initialize user after Safe deployment
|
|
515
534
|
* This method is automatically called after deploySafe to initialize user state
|
package/dist/index.js
CHANGED
|
@@ -793,6 +793,34 @@ 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
|
+
}
|
|
796
824
|
/**
|
|
797
825
|
* Initialize user after Safe deployment
|
|
798
826
|
* This method is automatically called after deploySafe to initialize user state
|
package/dist/index.mjs
CHANGED
|
@@ -770,6 +770,34 @@ 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
|
+
}
|
|
773
801
|
/**
|
|
774
802
|
* Initialize user after Safe deployment
|
|
775
803
|
* 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.7",
|
|
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",
|