@zyfai/sdk 0.2.16 → 0.2.18

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/dist/index.d.mts CHANGED
@@ -192,8 +192,8 @@ interface APYPerStrategy {
192
192
  total_rebalances: number;
193
193
  created_at: string;
194
194
  strategy: string;
195
- average_apy_without_fee: number;
196
- average_apy_with_rzfi_without_fee: number;
195
+ average_apy_with_fee: number;
196
+ average_apy_with_rzfi_with_fee: number;
197
197
  }
198
198
  interface APYPerStrategyResponse {
199
199
  success: boolean;
@@ -350,7 +350,8 @@ interface DailyApyHistoryResponse {
350
350
  history: Record<string, DailyApyEntry>;
351
351
  totalDays: number;
352
352
  requestedDays?: number;
353
- averageWeightedApy?: number;
353
+ weightedApyWithRzfiAfterFee?: number;
354
+ weightedApyAfterFee?: number;
354
355
  }
355
356
  interface RebalanceFrequencyResponse {
356
357
  success: boolean;
@@ -577,6 +578,25 @@ declare class ZyfaiSDK {
577
578
  * ```
578
579
  */
579
580
  pauseAgent(): Promise<UpdateUserProfileResponse>;
581
+ /**
582
+ * Pause the agent by clearing all protocols
583
+ * Sets the user's protocols to an empty array, effectively pausing automated operations
584
+ *
585
+ * @returns Response indicating success and updated user details
586
+ *
587
+ * @example
588
+ * ```typescript
589
+ * const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
590
+ *
591
+ * // Connect account first
592
+ * await sdk.connectAccount();
593
+ *
594
+ * // Pause the agent
595
+ * const result = await sdk.pauseAgent();
596
+ * console.log('Agent paused:', result.success);
597
+ * ```
598
+ */
599
+ resumeAgent(): Promise<UpdateUserProfileResponse>;
580
600
  /**
581
601
  * Enable splitting for the user's account
582
602
  * When enabled, deposits are split across multiple protocols based on minSplits setting
@@ -1144,32 +1164,6 @@ declare class ZyfaiSDK {
1144
1164
  * ```
1145
1165
  */
1146
1166
  getSdkKeyTVL(): Promise<SdkKeyTVLResponse>;
1147
- /**
1148
- * Get the best yield opportunity for a registered wallet.
1149
- *
1150
- * Returns the highest-APY opportunity available based on the wallet's strategy
1151
- * and enabled protocols. This reflects what the rebalance engine would select.
1152
- *
1153
- * @param walletAddress - The smart wallet address (must be registered)
1154
- * @param chainId - The chain ID to check opportunities on
1155
- * @returns Best opportunity details with comparison to current position
1156
- *
1157
- * @example
1158
- * ```typescript
1159
- * const result = await sdk.getBestOpportunity(walletAddress, 8453);
1160
- *
1161
- * console.log("Current position:", result.currentPosition);
1162
- * console.log("Best opportunity:", result.bestOpportunity);
1163
- * console.log("Should rebalance:", result.shouldRebalance);
1164
- * console.log("APY improvement:", result.apyImprovement);
1165
- *
1166
- * // List all available opportunities
1167
- * result.allOpportunities?.forEach(opp => {
1168
- * console.log(`${opp.protocol} - ${opp.pool}: ${opp.apy}%`);
1169
- * });
1170
- * ```
1171
- */
1172
- getBestOpportunity(walletAddress: Address, chainId: SupportedChainId): Promise<BestOpportunityResponse>;
1173
1167
  /**
1174
1168
  * Configure protocol and pool customizations in batch.
1175
1169
  *
package/dist/index.d.ts CHANGED
@@ -192,8 +192,8 @@ interface APYPerStrategy {
192
192
  total_rebalances: number;
193
193
  created_at: string;
194
194
  strategy: string;
195
- average_apy_without_fee: number;
196
- average_apy_with_rzfi_without_fee: number;
195
+ average_apy_with_fee: number;
196
+ average_apy_with_rzfi_with_fee: number;
197
197
  }
198
198
  interface APYPerStrategyResponse {
199
199
  success: boolean;
@@ -350,7 +350,8 @@ interface DailyApyHistoryResponse {
350
350
  history: Record<string, DailyApyEntry>;
351
351
  totalDays: number;
352
352
  requestedDays?: number;
353
- averageWeightedApy?: number;
353
+ weightedApyWithRzfiAfterFee?: number;
354
+ weightedApyAfterFee?: number;
354
355
  }
355
356
  interface RebalanceFrequencyResponse {
356
357
  success: boolean;
@@ -577,6 +578,25 @@ declare class ZyfaiSDK {
577
578
  * ```
578
579
  */
579
580
  pauseAgent(): Promise<UpdateUserProfileResponse>;
581
+ /**
582
+ * Pause the agent by clearing all protocols
583
+ * Sets the user's protocols to an empty array, effectively pausing automated operations
584
+ *
585
+ * @returns Response indicating success and updated user details
586
+ *
587
+ * @example
588
+ * ```typescript
589
+ * const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
590
+ *
591
+ * // Connect account first
592
+ * await sdk.connectAccount();
593
+ *
594
+ * // Pause the agent
595
+ * const result = await sdk.pauseAgent();
596
+ * console.log('Agent paused:', result.success);
597
+ * ```
598
+ */
599
+ resumeAgent(): Promise<UpdateUserProfileResponse>;
580
600
  /**
581
601
  * Enable splitting for the user's account
582
602
  * When enabled, deposits are split across multiple protocols based on minSplits setting
@@ -1144,32 +1164,6 @@ declare class ZyfaiSDK {
1144
1164
  * ```
1145
1165
  */
1146
1166
  getSdkKeyTVL(): Promise<SdkKeyTVLResponse>;
1147
- /**
1148
- * Get the best yield opportunity for a registered wallet.
1149
- *
1150
- * Returns the highest-APY opportunity available based on the wallet's strategy
1151
- * and enabled protocols. This reflects what the rebalance engine would select.
1152
- *
1153
- * @param walletAddress - The smart wallet address (must be registered)
1154
- * @param chainId - The chain ID to check opportunities on
1155
- * @returns Best opportunity details with comparison to current position
1156
- *
1157
- * @example
1158
- * ```typescript
1159
- * const result = await sdk.getBestOpportunity(walletAddress, 8453);
1160
- *
1161
- * console.log("Current position:", result.currentPosition);
1162
- * console.log("Best opportunity:", result.bestOpportunity);
1163
- * console.log("Should rebalance:", result.shouldRebalance);
1164
- * console.log("APY improvement:", result.apyImprovement);
1165
- *
1166
- * // List all available opportunities
1167
- * result.allOpportunities?.forEach(opp => {
1168
- * console.log(`${opp.protocol} - ${opp.pool}: ${opp.apy}%`);
1169
- * });
1170
- * ```
1171
- */
1172
- getBestOpportunity(walletAddress: Address, chainId: SupportedChainId): Promise<BestOpportunityResponse>;
1173
1167
  /**
1174
1168
  * Configure protocol and pool customizations in batch.
1175
1169
  *
package/dist/index.js CHANGED
@@ -62,7 +62,7 @@ var ENDPOINTS = {
62
62
  SESSION_KEYS_CONFIG: "/session-keys/config",
63
63
  SESSION_KEYS_ADD: "/session-keys/add",
64
64
  // Protocols
65
- PROTOCOLS: (chainId) => `/protocols?chainId=${chainId}`,
65
+ PROTOCOLS: (chainId) => chainId ? `/protocols?chainId=${chainId}` : "/protocols",
66
66
  // Data (v1)
67
67
  DATA_POSITION: (walletAddress) => `/data/position?walletAddress=${walletAddress}`,
68
68
  DATA_HISTORY: (walletAddress, chainId) => `/data/history?walletAddress=${walletAddress}&chainId=${chainId}`,
@@ -75,8 +75,6 @@ var ENDPOINTS = {
75
75
  // SDK Keys
76
76
  SDK_ALLOWED_WALLETS: "/data/sdk-allowed-wallets",
77
77
  SDK_TVL: "/data/sdk-tvl",
78
- // Best Opportunity
79
- BEST_OPPORTUNITY: (walletAddress, chainId) => `/data/best-opportunity?walletAddress=${walletAddress}&chainId=${chainId}`,
80
78
  // Agent Identity Registry
81
79
  AGENT_TOKEN_URI: "/users/me/agent-token-uri",
82
80
  // Customization
@@ -846,6 +844,54 @@ var _ZyfaiSDK = class _ZyfaiSDK {
846
844
  throw new Error(`Failed to pause agent: ${error.message}`);
847
845
  }
848
846
  }
847
+ /**
848
+ * Pause the agent by clearing all protocols
849
+ * Sets the user's protocols to an empty array, effectively pausing automated operations
850
+ *
851
+ * @returns Response indicating success and updated user details
852
+ *
853
+ * @example
854
+ * ```typescript
855
+ * const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
856
+ *
857
+ * // Connect account first
858
+ * await sdk.connectAccount();
859
+ *
860
+ * // Pause the agent
861
+ * const result = await sdk.pauseAgent();
862
+ * console.log('Agent paused:', result.success);
863
+ * ```
864
+ */
865
+ async resumeAgent() {
866
+ try {
867
+ const userDetails = await this.getUserDetails();
868
+ const userChains = userDetails.user.chains;
869
+ const strategy = userDetails.user.strategy || "safe_strategy";
870
+ const convertedStrategy = toInternalStrategy(strategy);
871
+ const chains = userChains && userChains.length > 0 ? userChains : [8453, 42161];
872
+ const allProtocols = await this.httpClient.get(
873
+ ENDPOINTS.PROTOCOLS()
874
+ );
875
+ const filteredProtocolIds = allProtocols.filter((protocol) => {
876
+ const hasMatchingChain = protocol.chains.some(
877
+ (chain) => chains.includes(chain)
878
+ );
879
+ if (!hasMatchingChain) {
880
+ return false;
881
+ }
882
+ if (convertedStrategy === "degen_strategy") {
883
+ return protocol.strategies?.includes("safe_strategy") || protocol.strategies?.includes("degen_strategy");
884
+ }
885
+ return protocol.strategies?.includes("safe_strategy");
886
+ }).map((protocol) => protocol.id);
887
+ const response = await this.updateUserProfile({
888
+ protocols: filteredProtocolIds
889
+ });
890
+ return response;
891
+ } catch (error) {
892
+ throw new Error(`Failed to resume agent: ${error.message}`);
893
+ }
894
+ }
849
895
  /**
850
896
  * Enable splitting for the user's account
851
897
  * When enabled, deposits are split across multiple protocols based on minSplits setting
@@ -2449,7 +2495,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2449
2495
  history: data.history || {},
2450
2496
  totalDays: data.total_days || data.totalDays || 0,
2451
2497
  requestedDays: data.requested_days || data.requestedDays,
2452
- averageWeightedApy: data.average_final_weighted_apy_after_fee || data.averageWeightedApy || 0
2498
+ weightedApyWithRzfiAfterFee: data.average_final_weighted_apy_after_fee_with_rzfi,
2499
+ weightedApyAfterFee: data.average_final_weighted_apy_after_fee
2453
2500
  };
2454
2501
  } catch (error) {
2455
2502
  throw new Error(
@@ -2565,43 +2612,6 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2565
2612
  );
2566
2613
  }
2567
2614
  }
2568
- /**
2569
- * Get the best yield opportunity for a registered wallet.
2570
- *
2571
- * Returns the highest-APY opportunity available based on the wallet's strategy
2572
- * and enabled protocols. This reflects what the rebalance engine would select.
2573
- *
2574
- * @param walletAddress - The smart wallet address (must be registered)
2575
- * @param chainId - The chain ID to check opportunities on
2576
- * @returns Best opportunity details with comparison to current position
2577
- *
2578
- * @example
2579
- * ```typescript
2580
- * const result = await sdk.getBestOpportunity(walletAddress, 8453);
2581
- *
2582
- * console.log("Current position:", result.currentPosition);
2583
- * console.log("Best opportunity:", result.bestOpportunity);
2584
- * console.log("Should rebalance:", result.shouldRebalance);
2585
- * console.log("APY improvement:", result.apyImprovement);
2586
- *
2587
- * // List all available opportunities
2588
- * result.allOpportunities?.forEach(opp => {
2589
- * console.log(`${opp.protocol} - ${opp.pool}: ${opp.apy}%`);
2590
- * });
2591
- * ```
2592
- */
2593
- async getBestOpportunity(walletAddress, chainId) {
2594
- try {
2595
- const response = await this.httpClient.get(
2596
- ENDPOINTS.BEST_OPPORTUNITY(walletAddress, chainId)
2597
- );
2598
- return response;
2599
- } catch (error) {
2600
- throw new Error(
2601
- `Failed to get best opportunity: ${error.message}`
2602
- );
2603
- }
2604
- }
2605
2615
  // ============================================================================
2606
2616
  // Protocol/Pool Customization
2607
2617
  // ============================================================================
package/dist/index.mjs CHANGED
@@ -21,7 +21,7 @@ var ENDPOINTS = {
21
21
  SESSION_KEYS_CONFIG: "/session-keys/config",
22
22
  SESSION_KEYS_ADD: "/session-keys/add",
23
23
  // Protocols
24
- PROTOCOLS: (chainId) => `/protocols?chainId=${chainId}`,
24
+ PROTOCOLS: (chainId) => chainId ? `/protocols?chainId=${chainId}` : "/protocols",
25
25
  // Data (v1)
26
26
  DATA_POSITION: (walletAddress) => `/data/position?walletAddress=${walletAddress}`,
27
27
  DATA_HISTORY: (walletAddress, chainId) => `/data/history?walletAddress=${walletAddress}&chainId=${chainId}`,
@@ -34,8 +34,6 @@ var ENDPOINTS = {
34
34
  // SDK Keys
35
35
  SDK_ALLOWED_WALLETS: "/data/sdk-allowed-wallets",
36
36
  SDK_TVL: "/data/sdk-tvl",
37
- // Best Opportunity
38
- BEST_OPPORTUNITY: (walletAddress, chainId) => `/data/best-opportunity?walletAddress=${walletAddress}&chainId=${chainId}`,
39
37
  // Agent Identity Registry
40
38
  AGENT_TOKEN_URI: "/users/me/agent-token-uri",
41
39
  // Customization
@@ -824,6 +822,54 @@ var _ZyfaiSDK = class _ZyfaiSDK {
824
822
  throw new Error(`Failed to pause agent: ${error.message}`);
825
823
  }
826
824
  }
825
+ /**
826
+ * Pause the agent by clearing all protocols
827
+ * Sets the user's protocols to an empty array, effectively pausing automated operations
828
+ *
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();
837
+ *
838
+ * // Pause the agent
839
+ * const result = await sdk.pauseAgent();
840
+ * console.log('Agent paused:', result.success);
841
+ * ```
842
+ */
843
+ async resumeAgent() {
844
+ try {
845
+ const userDetails = await this.getUserDetails();
846
+ const userChains = userDetails.user.chains;
847
+ const strategy = userDetails.user.strategy || "safe_strategy";
848
+ const convertedStrategy = toInternalStrategy(strategy);
849
+ const chains = userChains && userChains.length > 0 ? userChains : [8453, 42161];
850
+ const allProtocols = await this.httpClient.get(
851
+ ENDPOINTS.PROTOCOLS()
852
+ );
853
+ const filteredProtocolIds = allProtocols.filter((protocol) => {
854
+ const hasMatchingChain = protocol.chains.some(
855
+ (chain) => chains.includes(chain)
856
+ );
857
+ if (!hasMatchingChain) {
858
+ return false;
859
+ }
860
+ if (convertedStrategy === "degen_strategy") {
861
+ return protocol.strategies?.includes("safe_strategy") || protocol.strategies?.includes("degen_strategy");
862
+ }
863
+ return protocol.strategies?.includes("safe_strategy");
864
+ }).map((protocol) => protocol.id);
865
+ const response = await this.updateUserProfile({
866
+ protocols: filteredProtocolIds
867
+ });
868
+ return response;
869
+ } catch (error) {
870
+ throw new Error(`Failed to resume agent: ${error.message}`);
871
+ }
872
+ }
827
873
  /**
828
874
  * Enable splitting for the user's account
829
875
  * When enabled, deposits are split across multiple protocols based on minSplits setting
@@ -2427,7 +2473,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2427
2473
  history: data.history || {},
2428
2474
  totalDays: data.total_days || data.totalDays || 0,
2429
2475
  requestedDays: data.requested_days || data.requestedDays,
2430
- averageWeightedApy: data.average_final_weighted_apy_after_fee || data.averageWeightedApy || 0
2476
+ weightedApyWithRzfiAfterFee: data.average_final_weighted_apy_after_fee_with_rzfi,
2477
+ weightedApyAfterFee: data.average_final_weighted_apy_after_fee
2431
2478
  };
2432
2479
  } catch (error) {
2433
2480
  throw new Error(
@@ -2543,43 +2590,6 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2543
2590
  );
2544
2591
  }
2545
2592
  }
2546
- /**
2547
- * Get the best yield opportunity for a registered wallet.
2548
- *
2549
- * Returns the highest-APY opportunity available based on the wallet's strategy
2550
- * and enabled protocols. This reflects what the rebalance engine would select.
2551
- *
2552
- * @param walletAddress - The smart wallet address (must be registered)
2553
- * @param chainId - The chain ID to check opportunities on
2554
- * @returns Best opportunity details with comparison to current position
2555
- *
2556
- * @example
2557
- * ```typescript
2558
- * const result = await sdk.getBestOpportunity(walletAddress, 8453);
2559
- *
2560
- * console.log("Current position:", result.currentPosition);
2561
- * console.log("Best opportunity:", result.bestOpportunity);
2562
- * console.log("Should rebalance:", result.shouldRebalance);
2563
- * console.log("APY improvement:", result.apyImprovement);
2564
- *
2565
- * // List all available opportunities
2566
- * result.allOpportunities?.forEach(opp => {
2567
- * console.log(`${opp.protocol} - ${opp.pool}: ${opp.apy}%`);
2568
- * });
2569
- * ```
2570
- */
2571
- async getBestOpportunity(walletAddress, chainId) {
2572
- try {
2573
- const response = await this.httpClient.get(
2574
- ENDPOINTS.BEST_OPPORTUNITY(walletAddress, chainId)
2575
- );
2576
- return response;
2577
- } catch (error) {
2578
- throw new Error(
2579
- `Failed to get best opportunity: ${error.message}`
2580
- );
2581
- }
2582
- }
2583
2593
  // ============================================================================
2584
2594
  // Protocol/Pool Customization
2585
2595
  // ============================================================================
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyfai/sdk",
3
- "version": "0.2.16",
3
+ "version": "0.2.18",
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",