@zyfai/sdk 0.1.29 → 0.1.31

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
@@ -596,25 +596,14 @@ degenStrats.data.forEach((s) => {
596
596
  });
597
597
  ```
598
598
 
599
- ### 11. Rebalancing
599
+ ### 11. APY Per Strategy
600
600
 
601
- #### Get Rebalance Info
601
+ #### Get APY Per Strategy
602
602
 
603
603
  ```typescript
604
604
  // Get same-chain rebalances
605
- const rebalances = await sdk.getRebalanceInfo(false);
606
- console.log("Rebalance events:", rebalances.count);
607
-
608
- // Get cross-chain rebalances
609
- const crossChain = await sdk.getRebalanceInfo(true);
610
- ```
611
-
612
- #### Get Rebalance Frequency
613
-
614
- ```typescript
615
- const frequency = await sdk.getRebalanceFrequency(walletAddress);
616
- console.log("Tier:", frequency.tier);
617
- console.log("Max rebalances/day:", frequency.frequency);
605
+ const apyPerStrategy = await sdk.getAPYPerStrategy(false, "7D", "safe");
606
+ console.log("APY per strategy:", apyPerStrategy.data);
618
607
  ```
619
608
 
620
609
  ### 12. SDK API Key Management
package/dist/index.d.mts CHANGED
@@ -157,6 +157,27 @@ interface TVLResponse {
157
157
  byChain?: Record<number, number>;
158
158
  breakdown?: TVLBreakdown[];
159
159
  }
160
+ interface APYPerStrategy {
161
+ id: string;
162
+ timestamp: string;
163
+ amount: number;
164
+ fee_threshold: number;
165
+ days: number;
166
+ chain_id: number;
167
+ is_cross_chain: boolean;
168
+ average_apy: number;
169
+ average_apy_with_rzfi: number;
170
+ total_rebalances: number;
171
+ created_at: string;
172
+ strategy: string;
173
+ average_apy_without_fee: number;
174
+ average_apy_with_rzfi_without_fee: number;
175
+ }
176
+ interface APYPerStrategyResponse {
177
+ success: boolean;
178
+ count: number;
179
+ data: APYPerStrategy[];
180
+ }
160
181
  interface VolumeResponse {
161
182
  success: boolean;
162
183
  volumeInUSD: string;
@@ -309,23 +330,6 @@ interface DailyApyHistoryResponse {
309
330
  requestedDays?: number;
310
331
  averageWeightedApy?: number;
311
332
  }
312
- interface RebalanceInfo {
313
- id: string;
314
- timestamp: string;
315
- fromProtocol?: string;
316
- toProtocol?: string;
317
- fromPool?: string;
318
- toPool?: string;
319
- amount?: string;
320
- isCrossChain: boolean;
321
- fromChainId?: number;
322
- toChainId?: number;
323
- }
324
- interface RebalanceInfoResponse {
325
- success: boolean;
326
- data: RebalanceInfo[];
327
- count: number;
328
- }
329
333
  interface RebalanceFrequencyResponse {
330
334
  success: boolean;
331
335
  walletAddress: string;
@@ -668,6 +672,21 @@ declare class ZyfaiSDK {
668
672
  * ```
669
673
  */
670
674
  getTVL(): Promise<TVLResponse>;
675
+ /**
676
+ * Get APY per strategy for a specific chain
677
+ *
678
+ * @param crossChain - Whether to get cross-chain APY (true = omni account, false = simple account)
679
+ * @param days - Time period: "7D", "14D", or "30D"
680
+ * @param strategyType - Strategy type: "safe" or "degen"
681
+ * @returns APY per strategy for a specific chain
682
+ *
683
+ * @example
684
+ * ```typescript
685
+ * const apyPerStrategy = await sdk.getAPYPerStrategy(false, 7, "safe");
686
+ * console.log("APY per strategy per chain:", apyPerStrategy.data);
687
+ * ```
688
+ */
689
+ getAPYPerStrategy(crossChain?: boolean, days?: number, strategy?: string): Promise<APYPerStrategyResponse>;
671
690
  /**
672
691
  * Get total volume across all Zyfai accounts
673
692
  *
@@ -836,21 +855,6 @@ declare class ZyfaiSDK {
836
855
  * ```
837
856
  */
838
857
  getDailyApyHistory(walletAddress: string, days?: "7D" | "14D" | "30D"): Promise<DailyApyHistoryResponse>;
839
- /**
840
- * Get rebalance information
841
- * Shows yield generated by rebalancing strategies
842
- *
843
- * @param isCrossChain - Filter by cross-chain or same-chain rebalances
844
- * @returns List of rebalance events
845
- *
846
- * @example
847
- * ```typescript
848
- * // Get same-chain rebalance info
849
- * const rebalances = await sdk.getRebalanceInfo(false);
850
- * console.log("Rebalance count:", rebalances.count);
851
- * ```
852
- */
853
- getRebalanceInfo(isCrossChain?: boolean): Promise<RebalanceInfoResponse>;
854
858
  /**
855
859
  * Get rebalance frequency/tier for a wallet
856
860
  * Determines how often the wallet can be rebalanced based on tier
@@ -868,4 +872,4 @@ declare class ZyfaiSDK {
868
872
  getRebalanceFrequency(walletAddress: string): Promise<RebalanceFrequencyResponse>;
869
873
  }
870
874
 
871
- export { type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type ChainConfig, type ChainPortfolio, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DeploySafeResponse, type DepositResponse, type ERC7739Context, type ERC7739Data, type FirstTopupResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type PolicyData, type Pool, type PortfolioToken, type Position, type PositionSlot, type PositionsResponse, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type RebalanceInfo, type RebalanceInfoResponse, type SDKConfig, type Session, type SessionKeyResponse, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedChainId, type TVLResponse, type UserDetails, type UserDetailsResponse, type VolumeResponse, type WithdrawResponse, ZyfaiSDK, getChainConfig, getDefaultTokenAddress, getSupportedChainIds, isSupportedChain };
875
+ export { type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type ChainConfig, type ChainPortfolio, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DeploySafeResponse, type DepositResponse, type ERC7739Context, type ERC7739Data, type FirstTopupResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type PolicyData, type Pool, type PortfolioToken, type Position, type PositionSlot, type PositionsResponse, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type SDKConfig, type Session, type SessionKeyResponse, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedChainId, type TVLResponse, type UserDetails, type UserDetailsResponse, type VolumeResponse, type WithdrawResponse, ZyfaiSDK, getChainConfig, getDefaultTokenAddress, getSupportedChainIds, isSupportedChain };
package/dist/index.d.ts CHANGED
@@ -157,6 +157,27 @@ interface TVLResponse {
157
157
  byChain?: Record<number, number>;
158
158
  breakdown?: TVLBreakdown[];
159
159
  }
160
+ interface APYPerStrategy {
161
+ id: string;
162
+ timestamp: string;
163
+ amount: number;
164
+ fee_threshold: number;
165
+ days: number;
166
+ chain_id: number;
167
+ is_cross_chain: boolean;
168
+ average_apy: number;
169
+ average_apy_with_rzfi: number;
170
+ total_rebalances: number;
171
+ created_at: string;
172
+ strategy: string;
173
+ average_apy_without_fee: number;
174
+ average_apy_with_rzfi_without_fee: number;
175
+ }
176
+ interface APYPerStrategyResponse {
177
+ success: boolean;
178
+ count: number;
179
+ data: APYPerStrategy[];
180
+ }
160
181
  interface VolumeResponse {
161
182
  success: boolean;
162
183
  volumeInUSD: string;
@@ -309,23 +330,6 @@ interface DailyApyHistoryResponse {
309
330
  requestedDays?: number;
310
331
  averageWeightedApy?: number;
311
332
  }
312
- interface RebalanceInfo {
313
- id: string;
314
- timestamp: string;
315
- fromProtocol?: string;
316
- toProtocol?: string;
317
- fromPool?: string;
318
- toPool?: string;
319
- amount?: string;
320
- isCrossChain: boolean;
321
- fromChainId?: number;
322
- toChainId?: number;
323
- }
324
- interface RebalanceInfoResponse {
325
- success: boolean;
326
- data: RebalanceInfo[];
327
- count: number;
328
- }
329
333
  interface RebalanceFrequencyResponse {
330
334
  success: boolean;
331
335
  walletAddress: string;
@@ -668,6 +672,21 @@ declare class ZyfaiSDK {
668
672
  * ```
669
673
  */
670
674
  getTVL(): Promise<TVLResponse>;
675
+ /**
676
+ * Get APY per strategy for a specific chain
677
+ *
678
+ * @param crossChain - Whether to get cross-chain APY (true = omni account, false = simple account)
679
+ * @param days - Time period: "7D", "14D", or "30D"
680
+ * @param strategyType - Strategy type: "safe" or "degen"
681
+ * @returns APY per strategy for a specific chain
682
+ *
683
+ * @example
684
+ * ```typescript
685
+ * const apyPerStrategy = await sdk.getAPYPerStrategy(false, 7, "safe");
686
+ * console.log("APY per strategy per chain:", apyPerStrategy.data);
687
+ * ```
688
+ */
689
+ getAPYPerStrategy(crossChain?: boolean, days?: number, strategy?: string): Promise<APYPerStrategyResponse>;
671
690
  /**
672
691
  * Get total volume across all Zyfai accounts
673
692
  *
@@ -836,21 +855,6 @@ declare class ZyfaiSDK {
836
855
  * ```
837
856
  */
838
857
  getDailyApyHistory(walletAddress: string, days?: "7D" | "14D" | "30D"): Promise<DailyApyHistoryResponse>;
839
- /**
840
- * Get rebalance information
841
- * Shows yield generated by rebalancing strategies
842
- *
843
- * @param isCrossChain - Filter by cross-chain or same-chain rebalances
844
- * @returns List of rebalance events
845
- *
846
- * @example
847
- * ```typescript
848
- * // Get same-chain rebalance info
849
- * const rebalances = await sdk.getRebalanceInfo(false);
850
- * console.log("Rebalance count:", rebalances.count);
851
- * ```
852
- */
853
- getRebalanceInfo(isCrossChain?: boolean): Promise<RebalanceInfoResponse>;
854
858
  /**
855
859
  * Get rebalance frequency/tier for a wallet
856
860
  * Determines how often the wallet can be rebalanced based on tier
@@ -868,4 +872,4 @@ declare class ZyfaiSDK {
868
872
  getRebalanceFrequency(walletAddress: string): Promise<RebalanceFrequencyResponse>;
869
873
  }
870
874
 
871
- export { type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type ChainConfig, type ChainPortfolio, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DeploySafeResponse, type DepositResponse, type ERC7739Context, type ERC7739Data, type FirstTopupResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type PolicyData, type Pool, type PortfolioToken, type Position, type PositionSlot, type PositionsResponse, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type RebalanceInfo, type RebalanceInfoResponse, type SDKConfig, type Session, type SessionKeyResponse, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedChainId, type TVLResponse, type UserDetails, type UserDetailsResponse, type VolumeResponse, type WithdrawResponse, ZyfaiSDK, getChainConfig, getDefaultTokenAddress, getSupportedChainIds, isSupportedChain };
875
+ export { type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type ChainConfig, type ChainPortfolio, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DeploySafeResponse, type DepositResponse, type ERC7739Context, type ERC7739Data, type FirstTopupResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type PolicyData, type Pool, type PortfolioToken, type Position, type PositionSlot, type PositionsResponse, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type SDKConfig, type Session, type SessionKeyResponse, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedChainId, type TVLResponse, type UserDetails, type UserDetailsResponse, type VolumeResponse, type WithdrawResponse, ZyfaiSDK, getChainConfig, getDefaultTokenAddress, getSupportedChainIds, isSupportedChain };
package/dist/index.js CHANGED
@@ -92,7 +92,9 @@ var DATA_ENDPOINTS = {
92
92
  // APY History
93
93
  DAILY_APY_HISTORY_WEIGHTED: (walletAddress, days) => `/daily-apy-history/weighted/${walletAddress}${days ? `?days=${days}` : ""}`,
94
94
  // Rebalance
95
- REBALANCE_INFO: (isCrossChain) => isCrossChain !== void 0 ? `/rebalance/rebalance-info?isCrossChain=${isCrossChain}` : "/rebalance/rebalance-info"
95
+ REBALANCE_INFO: (isCrossChain) => isCrossChain !== void 0 ? `/rebalance/rebalance-info?isCrossChain=${isCrossChain}` : "/rebalance/rebalance-info",
96
+ // APY Per Strategy
97
+ APY_PER_STRATEGY: (isCrossChain = false, days = 7, strategy = "safe") => `/rebalance/rebalance-info?isCrossChain=${isCrossChain}&days=${days}&strategy=${strategy}`
96
98
  };
97
99
 
98
100
  // src/utils/http-client.ts
@@ -1612,6 +1614,37 @@ var ZyfaiSDK = class {
1612
1614
  throw new Error(`Failed to get TVL: ${error.message}`);
1613
1615
  }
1614
1616
  }
1617
+ // ============================================================================
1618
+ // APY Per Strategy Methods
1619
+ // ============================================================================
1620
+ /**
1621
+ * Get APY per strategy for a specific chain
1622
+ *
1623
+ * @param crossChain - Whether to get cross-chain APY (true = omni account, false = simple account)
1624
+ * @param days - Time period: "7D", "14D", or "30D"
1625
+ * @param strategyType - Strategy type: "safe" or "degen"
1626
+ * @returns APY per strategy for a specific chain
1627
+ *
1628
+ * @example
1629
+ * ```typescript
1630
+ * const apyPerStrategy = await sdk.getAPYPerStrategy(false, 7, "safe");
1631
+ * console.log("APY per strategy per chain:", apyPerStrategy.data);
1632
+ * ```
1633
+ */
1634
+ async getAPYPerStrategy(crossChain = false, days = 7, strategy = "safe") {
1635
+ try {
1636
+ const response = await this.httpClient.dataGet(DATA_ENDPOINTS.APY_PER_STRATEGY(crossChain, days, strategy));
1637
+ return {
1638
+ success: true,
1639
+ count: response.count || 0,
1640
+ data: response.data || []
1641
+ };
1642
+ } catch (error) {
1643
+ throw new Error(
1644
+ `Failed to get APY per strategy: ${error.message}`
1645
+ );
1646
+ }
1647
+ }
1615
1648
  /**
1616
1649
  * Get total volume across all Zyfai accounts
1617
1650
  *
@@ -2070,48 +2103,6 @@ var ZyfaiSDK = class {
2070
2103
  // ============================================================================
2071
2104
  // Rebalance Methods
2072
2105
  // ============================================================================
2073
- /**
2074
- * Get rebalance information
2075
- * Shows yield generated by rebalancing strategies
2076
- *
2077
- * @param isCrossChain - Filter by cross-chain or same-chain rebalances
2078
- * @returns List of rebalance events
2079
- *
2080
- * @example
2081
- * ```typescript
2082
- * // Get same-chain rebalance info
2083
- * const rebalances = await sdk.getRebalanceInfo(false);
2084
- * console.log("Rebalance count:", rebalances.count);
2085
- * ```
2086
- */
2087
- async getRebalanceInfo(isCrossChain) {
2088
- try {
2089
- const response = await this.httpClient.dataGet(
2090
- DATA_ENDPOINTS.REBALANCE_INFO(isCrossChain)
2091
- );
2092
- const data = response.data || response || [];
2093
- return {
2094
- success: true,
2095
- data: Array.isArray(data) ? data.map((r) => ({
2096
- id: r.id,
2097
- timestamp: r.timestamp || r.created_at,
2098
- fromProtocol: r.from_protocol || r.fromProtocol,
2099
- toProtocol: r.to_protocol || r.toProtocol,
2100
- fromPool: r.from_pool || r.fromPool,
2101
- toPool: r.to_pool || r.toPool,
2102
- amount: r.amount,
2103
- isCrossChain: r.is_cross_chain ?? r.isCrossChain ?? false,
2104
- fromChainId: r.from_chain_id || r.fromChainId,
2105
- toChainId: r.to_chain_id || r.toChainId
2106
- })) : [],
2107
- count: data.length
2108
- };
2109
- } catch (error) {
2110
- throw new Error(
2111
- `Failed to get rebalance info: ${error.message}`
2112
- );
2113
- }
2114
- }
2115
2106
  /**
2116
2107
  * Get rebalance frequency/tier for a wallet
2117
2108
  * Determines how often the wallet can be rebalanced based on tier
package/dist/index.mjs CHANGED
@@ -51,7 +51,9 @@ var DATA_ENDPOINTS = {
51
51
  // APY History
52
52
  DAILY_APY_HISTORY_WEIGHTED: (walletAddress, days) => `/daily-apy-history/weighted/${walletAddress}${days ? `?days=${days}` : ""}`,
53
53
  // Rebalance
54
- REBALANCE_INFO: (isCrossChain) => isCrossChain !== void 0 ? `/rebalance/rebalance-info?isCrossChain=${isCrossChain}` : "/rebalance/rebalance-info"
54
+ REBALANCE_INFO: (isCrossChain) => isCrossChain !== void 0 ? `/rebalance/rebalance-info?isCrossChain=${isCrossChain}` : "/rebalance/rebalance-info",
55
+ // APY Per Strategy
56
+ APY_PER_STRATEGY: (isCrossChain = false, days = 7, strategy = "safe") => `/rebalance/rebalance-info?isCrossChain=${isCrossChain}&days=${days}&strategy=${strategy}`
55
57
  };
56
58
 
57
59
  // src/utils/http-client.ts
@@ -1589,6 +1591,37 @@ var ZyfaiSDK = class {
1589
1591
  throw new Error(`Failed to get TVL: ${error.message}`);
1590
1592
  }
1591
1593
  }
1594
+ // ============================================================================
1595
+ // APY Per Strategy Methods
1596
+ // ============================================================================
1597
+ /**
1598
+ * Get APY per strategy for a specific chain
1599
+ *
1600
+ * @param crossChain - Whether to get cross-chain APY (true = omni account, false = simple account)
1601
+ * @param days - Time period: "7D", "14D", or "30D"
1602
+ * @param strategyType - Strategy type: "safe" or "degen"
1603
+ * @returns APY per strategy for a specific chain
1604
+ *
1605
+ * @example
1606
+ * ```typescript
1607
+ * const apyPerStrategy = await sdk.getAPYPerStrategy(false, 7, "safe");
1608
+ * console.log("APY per strategy per chain:", apyPerStrategy.data);
1609
+ * ```
1610
+ */
1611
+ async getAPYPerStrategy(crossChain = false, days = 7, strategy = "safe") {
1612
+ try {
1613
+ const response = await this.httpClient.dataGet(DATA_ENDPOINTS.APY_PER_STRATEGY(crossChain, days, strategy));
1614
+ return {
1615
+ success: true,
1616
+ count: response.count || 0,
1617
+ data: response.data || []
1618
+ };
1619
+ } catch (error) {
1620
+ throw new Error(
1621
+ `Failed to get APY per strategy: ${error.message}`
1622
+ );
1623
+ }
1624
+ }
1592
1625
  /**
1593
1626
  * Get total volume across all Zyfai accounts
1594
1627
  *
@@ -2047,48 +2080,6 @@ var ZyfaiSDK = class {
2047
2080
  // ============================================================================
2048
2081
  // Rebalance Methods
2049
2082
  // ============================================================================
2050
- /**
2051
- * Get rebalance information
2052
- * Shows yield generated by rebalancing strategies
2053
- *
2054
- * @param isCrossChain - Filter by cross-chain or same-chain rebalances
2055
- * @returns List of rebalance events
2056
- *
2057
- * @example
2058
- * ```typescript
2059
- * // Get same-chain rebalance info
2060
- * const rebalances = await sdk.getRebalanceInfo(false);
2061
- * console.log("Rebalance count:", rebalances.count);
2062
- * ```
2063
- */
2064
- async getRebalanceInfo(isCrossChain) {
2065
- try {
2066
- const response = await this.httpClient.dataGet(
2067
- DATA_ENDPOINTS.REBALANCE_INFO(isCrossChain)
2068
- );
2069
- const data = response.data || response || [];
2070
- return {
2071
- success: true,
2072
- data: Array.isArray(data) ? data.map((r) => ({
2073
- id: r.id,
2074
- timestamp: r.timestamp || r.created_at,
2075
- fromProtocol: r.from_protocol || r.fromProtocol,
2076
- toProtocol: r.to_protocol || r.toProtocol,
2077
- fromPool: r.from_pool || r.fromPool,
2078
- toPool: r.to_pool || r.toPool,
2079
- amount: r.amount,
2080
- isCrossChain: r.is_cross_chain ?? r.isCrossChain ?? false,
2081
- fromChainId: r.from_chain_id || r.fromChainId,
2082
- toChainId: r.to_chain_id || r.toChainId
2083
- })) : [],
2084
- count: data.length
2085
- };
2086
- } catch (error) {
2087
- throw new Error(
2088
- `Failed to get rebalance info: ${error.message}`
2089
- );
2090
- }
2091
- }
2092
2083
  /**
2093
2084
  * Get rebalance frequency/tier for a wallet
2094
2085
  * Determines how often the wallet can be rebalanced based on tier
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyfai/sdk",
3
- "version": "0.1.29",
3
+ "version": "0.1.31",
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",