@zyfai/sdk 0.2.10 → 0.2.11

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
@@ -996,6 +996,51 @@ declare class ZyfaiSDK {
996
996
  * ```
997
997
  */
998
998
  getAggressiveOpportunities(chainId?: number): Promise<OpportunitiesResponse>;
999
+ /**
1000
+ * Get active conservative opportunities (status = "live") with risk and utilization data
1001
+ * Returns pool info, liquidity depth (true if > 1M), utilization rate, stability metrics, avg APY, and collateral
1002
+ *
1003
+ * @param chainId - Optional chain ID filter
1004
+ * @returns Active conservative opportunities with risk data
1005
+ *
1006
+ * @example
1007
+ * ```typescript
1008
+ * const opps = await sdk.getActiveConservativeOppsRisk(8453);
1009
+ * console.log(JSON.stringify(opps, null, 2));
1010
+ * ```
1011
+ */
1012
+ getActiveConservativeOppsRisk(chainId?: number): Promise<any>;
1013
+ /**
1014
+ * Get active aggressive opportunities (status = "live") with risk and utilization data
1015
+ * Returns pool info, liquidity depth (true if > 1M), utilization rate, stability metrics, avg APY, and collateral
1016
+ *
1017
+ * @param chainId - Optional chain ID filter
1018
+ * @returns Active aggressive opportunities with risk data
1019
+ *
1020
+ * @example
1021
+ * ```typescript
1022
+ * const opps = await sdk.getActiveAggressiveOppsRisk(8453);
1023
+ * console.log(JSON.stringify(opps, null, 2));
1024
+ * ```
1025
+ */
1026
+ getActiveAggressiveOppsRisk(chainId?: number): Promise<any>;
1027
+ /**
1028
+ * Get conservative pool status with derived health, risk, APY trend, and yield consistency
1029
+ * Builds on getActiveConservativeOppsRisk and computes higher-level status indicators
1030
+ *
1031
+ * @param chainId - Optional chain ID filter
1032
+ * @returns Conservative pools with status data
1033
+ */
1034
+ getConservativePoolStatus(chainId?: number): Promise<any>;
1035
+ /**
1036
+ * Get aggressive pool status with derived health, risk, APY trend, and yield consistency
1037
+ * Builds on getActiveAggressiveOppsRisk and computes higher-level status indicators
1038
+ *
1039
+ * @param chainId - Optional chain ID filter
1040
+ * @returns Aggressive pools with status data
1041
+ */
1042
+ getAggressivePoolStatus(chainId?: number): Promise<any>;
1043
+ private derivePoolStatus;
999
1044
  /**
1000
1045
  * Get daily APY history with weighted average for a wallet
1001
1046
  *
package/dist/index.d.ts CHANGED
@@ -996,6 +996,51 @@ declare class ZyfaiSDK {
996
996
  * ```
997
997
  */
998
998
  getAggressiveOpportunities(chainId?: number): Promise<OpportunitiesResponse>;
999
+ /**
1000
+ * Get active conservative opportunities (status = "live") with risk and utilization data
1001
+ * Returns pool info, liquidity depth (true if > 1M), utilization rate, stability metrics, avg APY, and collateral
1002
+ *
1003
+ * @param chainId - Optional chain ID filter
1004
+ * @returns Active conservative opportunities with risk data
1005
+ *
1006
+ * @example
1007
+ * ```typescript
1008
+ * const opps = await sdk.getActiveConservativeOppsRisk(8453);
1009
+ * console.log(JSON.stringify(opps, null, 2));
1010
+ * ```
1011
+ */
1012
+ getActiveConservativeOppsRisk(chainId?: number): Promise<any>;
1013
+ /**
1014
+ * Get active aggressive opportunities (status = "live") with risk and utilization data
1015
+ * Returns pool info, liquidity depth (true if > 1M), utilization rate, stability metrics, avg APY, and collateral
1016
+ *
1017
+ * @param chainId - Optional chain ID filter
1018
+ * @returns Active aggressive opportunities with risk data
1019
+ *
1020
+ * @example
1021
+ * ```typescript
1022
+ * const opps = await sdk.getActiveAggressiveOppsRisk(8453);
1023
+ * console.log(JSON.stringify(opps, null, 2));
1024
+ * ```
1025
+ */
1026
+ getActiveAggressiveOppsRisk(chainId?: number): Promise<any>;
1027
+ /**
1028
+ * Get conservative pool status with derived health, risk, APY trend, and yield consistency
1029
+ * Builds on getActiveConservativeOppsRisk and computes higher-level status indicators
1030
+ *
1031
+ * @param chainId - Optional chain ID filter
1032
+ * @returns Conservative pools with status data
1033
+ */
1034
+ getConservativePoolStatus(chainId?: number): Promise<any>;
1035
+ /**
1036
+ * Get aggressive pool status with derived health, risk, APY trend, and yield consistency
1037
+ * Builds on getActiveAggressiveOppsRisk and computes higher-level status indicators
1038
+ *
1039
+ * @param chainId - Optional chain ID filter
1040
+ * @returns Aggressive pools with status data
1041
+ */
1042
+ getAggressivePoolStatus(chainId?: number): Promise<any>;
1043
+ private derivePoolStatus;
999
1044
  /**
1000
1045
  * Get daily APY history with weighted average for a wallet
1001
1046
  *
package/dist/index.js CHANGED
@@ -2249,6 +2249,156 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2249
2249
  );
2250
2250
  }
2251
2251
  }
2252
+ /**
2253
+ * Get active conservative opportunities (status = "live") with risk and utilization data
2254
+ * Returns pool info, liquidity depth (true if > 1M), utilization rate, stability metrics, avg APY, and collateral
2255
+ *
2256
+ * @param chainId - Optional chain ID filter
2257
+ * @returns Active conservative opportunities with risk data
2258
+ *
2259
+ * @example
2260
+ * ```typescript
2261
+ * const opps = await sdk.getActiveConservativeOppsRisk(8453);
2262
+ * console.log(JSON.stringify(opps, null, 2));
2263
+ * ```
2264
+ */
2265
+ async getActiveConservativeOppsRisk(chainId) {
2266
+ try {
2267
+ const response = await this.httpClient.dataGet(
2268
+ DATA_ENDPOINTS.OPPORTUNITIES_SAFE(chainId)
2269
+ );
2270
+ const data = response.data || response || [];
2271
+ const active = Array.isArray(data) ? data.filter((o) => o.status === "live").map((o) => {
2272
+ const tvl = o.tvl || 0;
2273
+ const liquidity = o.liquidity || 0;
2274
+ const utilizationRate = tvl > 0 ? (tvl - liquidity) / tvl : 0;
2275
+ return {
2276
+ poolName: o.pool_name,
2277
+ protocolName: o.protocol_name,
2278
+ chainId: o.chain_id,
2279
+ liquidityDepth: liquidity > 1e7 ? "deep" : liquidity > 1e6 ? "moderate" : "shallow",
2280
+ utilizationRate: Math.round(utilizationRate * 1e4) / 100,
2281
+ tvlStability: o.isTvlStable ?? null,
2282
+ apyStability: o.isApyStable30Days ?? null,
2283
+ tvlApyCombinedRisk: o.isApyTvlStable ?? null,
2284
+ avgCombinedApy7d: o.averageCombinedApy7Days ?? null,
2285
+ avgCombinedApy15d: o.averageCombinedApy15Days ?? null,
2286
+ avgCombinedApy30d: o.averageCombinedApy30Days ?? null,
2287
+ collateralSymbols: o.collateral_symbols || []
2288
+ };
2289
+ }) : [];
2290
+ return active;
2291
+ } catch (error) {
2292
+ throw new Error(
2293
+ `Failed to get active conservative opportunities risk: ${error.message}`
2294
+ );
2295
+ }
2296
+ }
2297
+ /**
2298
+ * Get active aggressive opportunities (status = "live") with risk and utilization data
2299
+ * Returns pool info, liquidity depth (true if > 1M), utilization rate, stability metrics, avg APY, and collateral
2300
+ *
2301
+ * @param chainId - Optional chain ID filter
2302
+ * @returns Active aggressive opportunities with risk data
2303
+ *
2304
+ * @example
2305
+ * ```typescript
2306
+ * const opps = await sdk.getActiveAggressiveOppsRisk(8453);
2307
+ * console.log(JSON.stringify(opps, null, 2));
2308
+ * ```
2309
+ */
2310
+ async getActiveAggressiveOppsRisk(chainId) {
2311
+ try {
2312
+ const response = await this.httpClient.dataGet(
2313
+ DATA_ENDPOINTS.OPPORTUNITIES_DEGEN(chainId)
2314
+ );
2315
+ const data = response.data || response || [];
2316
+ const active = Array.isArray(data) ? data.filter((o) => o.status === "live").map((o) => {
2317
+ const tvl = o.tvl || 0;
2318
+ const liquidity = o.liquidity || 0;
2319
+ const utilizationRate = tvl > 0 ? (tvl - liquidity) / tvl : 0;
2320
+ return {
2321
+ poolName: o.pool_name,
2322
+ protocolName: o.protocol_name,
2323
+ chainId: o.chain_id,
2324
+ liquidityDepth: liquidity > 1e7 ? "deep" : liquidity > 1e6 ? "moderate" : "shallow",
2325
+ utilizationRate: Math.round(utilizationRate * 1e4) / 100,
2326
+ tvlStability: o.isTvlStable ?? null,
2327
+ apyStability: o.isApyStable30Days ?? null,
2328
+ tvlApyCombinedRisk: o.isApyTvlStable ?? null,
2329
+ avgCombinedApy7d: o.averageCombinedApy7Days ?? null,
2330
+ avgCombinedApy15d: o.averageCombinedApy15Days ?? null,
2331
+ avgCombinedApy30d: o.averageCombinedApy30Days ?? null,
2332
+ collateralSymbols: o.collateral_symbols || []
2333
+ };
2334
+ }) : [];
2335
+ return active;
2336
+ } catch (error) {
2337
+ throw new Error(
2338
+ `Failed to get active aggressive opportunities risk: ${error.message}`
2339
+ );
2340
+ }
2341
+ }
2342
+ /**
2343
+ * Get conservative pool status with derived health, risk, APY trend, and yield consistency
2344
+ * Builds on getActiveConservativeOppsRisk and computes higher-level status indicators
2345
+ *
2346
+ * @param chainId - Optional chain ID filter
2347
+ * @returns Conservative pools with status data
2348
+ */
2349
+ async getConservativePoolStatus(chainId) {
2350
+ const pools = await this.getActiveConservativeOppsRisk(chainId);
2351
+ return pools.map((p) => this.derivePoolStatus(p));
2352
+ }
2353
+ /**
2354
+ * Get aggressive pool status with derived health, risk, APY trend, and yield consistency
2355
+ * Builds on getActiveAggressiveOppsRisk and computes higher-level status indicators
2356
+ *
2357
+ * @param chainId - Optional chain ID filter
2358
+ * @returns Aggressive pools with status data
2359
+ */
2360
+ async getAggressivePoolStatus(chainId) {
2361
+ const pools = await this.getActiveAggressiveOppsRisk(chainId);
2362
+ return pools.map((p) => this.derivePoolStatus(p));
2363
+ }
2364
+ derivePoolStatus(p) {
2365
+ let riskSignals = 0;
2366
+ if (p.tvlStability === false) riskSignals++;
2367
+ if (p.apyStability === false) riskSignals++;
2368
+ if (p.tvlApyCombinedRisk === false) riskSignals++;
2369
+ if (p.liquidityDepth === "shallow") riskSignals++;
2370
+ if (p.utilizationRate > 90) riskSignals++;
2371
+ const riskLevel = riskSignals >= 3 ? "high" : riskSignals >= 1 ? "medium" : "low";
2372
+ const stabilityScore = (p.tvlStability === true ? 1 : 0) + (p.apyStability === true ? 1 : 0) + (p.tvlApyCombinedRisk === true ? 1 : 0);
2373
+ const liquidityBonus = p.liquidityDepth === "deep" ? 1 : p.liquidityDepth === "moderate" ? 0.5 : 0;
2374
+ const healthTotal = stabilityScore + liquidityBonus;
2375
+ const healthScore = healthTotal >= 3 ? "healthy" : healthTotal >= 1.5 ? "moderate" : "risky";
2376
+ const apy7d = p.avgCombinedApy7d;
2377
+ const apy30d = p.avgCombinedApy30d;
2378
+ let apyTrend = "stable";
2379
+ if (apy7d != null && apy30d != null && apy30d !== 0) {
2380
+ const change = (apy7d - apy30d) / apy30d;
2381
+ if (change > 0.1) apyTrend = "rising";
2382
+ else if (change < -0.1) apyTrend = "falling";
2383
+ }
2384
+ let yieldConsistency = "consistent";
2385
+ if (apy7d != null && apy30d != null && apy30d !== 0) {
2386
+ const spread = Math.abs(apy7d - apy30d) / apy30d;
2387
+ if (spread > 0.3) yieldConsistency = "volatile";
2388
+ else if (spread > 0.1) yieldConsistency = "mixed";
2389
+ }
2390
+ return {
2391
+ poolName: p.poolName,
2392
+ protocolName: p.protocolName,
2393
+ chainId: p.chainId,
2394
+ healthScore,
2395
+ riskLevel,
2396
+ apyTrend,
2397
+ yieldConsistency,
2398
+ liquidityDepth: p.liquidityDepth,
2399
+ avgCombinedApy7d: p.avgCombinedApy7d
2400
+ };
2401
+ }
2252
2402
  // ============================================================================
2253
2403
  // APY History Methods (Data API v2)
2254
2404
  // ============================================================================
package/dist/index.mjs CHANGED
@@ -2227,6 +2227,156 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2227
2227
  );
2228
2228
  }
2229
2229
  }
2230
+ /**
2231
+ * Get active conservative opportunities (status = "live") with risk and utilization data
2232
+ * Returns pool info, liquidity depth (true if > 1M), utilization rate, stability metrics, avg APY, and collateral
2233
+ *
2234
+ * @param chainId - Optional chain ID filter
2235
+ * @returns Active conservative opportunities with risk data
2236
+ *
2237
+ * @example
2238
+ * ```typescript
2239
+ * const opps = await sdk.getActiveConservativeOppsRisk(8453);
2240
+ * console.log(JSON.stringify(opps, null, 2));
2241
+ * ```
2242
+ */
2243
+ async getActiveConservativeOppsRisk(chainId) {
2244
+ try {
2245
+ const response = await this.httpClient.dataGet(
2246
+ DATA_ENDPOINTS.OPPORTUNITIES_SAFE(chainId)
2247
+ );
2248
+ const data = response.data || response || [];
2249
+ const active = Array.isArray(data) ? data.filter((o) => o.status === "live").map((o) => {
2250
+ const tvl = o.tvl || 0;
2251
+ const liquidity = o.liquidity || 0;
2252
+ const utilizationRate = tvl > 0 ? (tvl - liquidity) / tvl : 0;
2253
+ return {
2254
+ poolName: o.pool_name,
2255
+ protocolName: o.protocol_name,
2256
+ chainId: o.chain_id,
2257
+ liquidityDepth: liquidity > 1e7 ? "deep" : liquidity > 1e6 ? "moderate" : "shallow",
2258
+ utilizationRate: Math.round(utilizationRate * 1e4) / 100,
2259
+ tvlStability: o.isTvlStable ?? null,
2260
+ apyStability: o.isApyStable30Days ?? null,
2261
+ tvlApyCombinedRisk: o.isApyTvlStable ?? null,
2262
+ avgCombinedApy7d: o.averageCombinedApy7Days ?? null,
2263
+ avgCombinedApy15d: o.averageCombinedApy15Days ?? null,
2264
+ avgCombinedApy30d: o.averageCombinedApy30Days ?? null,
2265
+ collateralSymbols: o.collateral_symbols || []
2266
+ };
2267
+ }) : [];
2268
+ return active;
2269
+ } catch (error) {
2270
+ throw new Error(
2271
+ `Failed to get active conservative opportunities risk: ${error.message}`
2272
+ );
2273
+ }
2274
+ }
2275
+ /**
2276
+ * Get active aggressive opportunities (status = "live") with risk and utilization data
2277
+ * Returns pool info, liquidity depth (true if > 1M), utilization rate, stability metrics, avg APY, and collateral
2278
+ *
2279
+ * @param chainId - Optional chain ID filter
2280
+ * @returns Active aggressive opportunities with risk data
2281
+ *
2282
+ * @example
2283
+ * ```typescript
2284
+ * const opps = await sdk.getActiveAggressiveOppsRisk(8453);
2285
+ * console.log(JSON.stringify(opps, null, 2));
2286
+ * ```
2287
+ */
2288
+ async getActiveAggressiveOppsRisk(chainId) {
2289
+ try {
2290
+ const response = await this.httpClient.dataGet(
2291
+ DATA_ENDPOINTS.OPPORTUNITIES_DEGEN(chainId)
2292
+ );
2293
+ const data = response.data || response || [];
2294
+ const active = Array.isArray(data) ? data.filter((o) => o.status === "live").map((o) => {
2295
+ const tvl = o.tvl || 0;
2296
+ const liquidity = o.liquidity || 0;
2297
+ const utilizationRate = tvl > 0 ? (tvl - liquidity) / tvl : 0;
2298
+ return {
2299
+ poolName: o.pool_name,
2300
+ protocolName: o.protocol_name,
2301
+ chainId: o.chain_id,
2302
+ liquidityDepth: liquidity > 1e7 ? "deep" : liquidity > 1e6 ? "moderate" : "shallow",
2303
+ utilizationRate: Math.round(utilizationRate * 1e4) / 100,
2304
+ tvlStability: o.isTvlStable ?? null,
2305
+ apyStability: o.isApyStable30Days ?? null,
2306
+ tvlApyCombinedRisk: o.isApyTvlStable ?? null,
2307
+ avgCombinedApy7d: o.averageCombinedApy7Days ?? null,
2308
+ avgCombinedApy15d: o.averageCombinedApy15Days ?? null,
2309
+ avgCombinedApy30d: o.averageCombinedApy30Days ?? null,
2310
+ collateralSymbols: o.collateral_symbols || []
2311
+ };
2312
+ }) : [];
2313
+ return active;
2314
+ } catch (error) {
2315
+ throw new Error(
2316
+ `Failed to get active aggressive opportunities risk: ${error.message}`
2317
+ );
2318
+ }
2319
+ }
2320
+ /**
2321
+ * Get conservative pool status with derived health, risk, APY trend, and yield consistency
2322
+ * Builds on getActiveConservativeOppsRisk and computes higher-level status indicators
2323
+ *
2324
+ * @param chainId - Optional chain ID filter
2325
+ * @returns Conservative pools with status data
2326
+ */
2327
+ async getConservativePoolStatus(chainId) {
2328
+ const pools = await this.getActiveConservativeOppsRisk(chainId);
2329
+ return pools.map((p) => this.derivePoolStatus(p));
2330
+ }
2331
+ /**
2332
+ * Get aggressive pool status with derived health, risk, APY trend, and yield consistency
2333
+ * Builds on getActiveAggressiveOppsRisk and computes higher-level status indicators
2334
+ *
2335
+ * @param chainId - Optional chain ID filter
2336
+ * @returns Aggressive pools with status data
2337
+ */
2338
+ async getAggressivePoolStatus(chainId) {
2339
+ const pools = await this.getActiveAggressiveOppsRisk(chainId);
2340
+ return pools.map((p) => this.derivePoolStatus(p));
2341
+ }
2342
+ derivePoolStatus(p) {
2343
+ let riskSignals = 0;
2344
+ if (p.tvlStability === false) riskSignals++;
2345
+ if (p.apyStability === false) riskSignals++;
2346
+ if (p.tvlApyCombinedRisk === false) riskSignals++;
2347
+ if (p.liquidityDepth === "shallow") riskSignals++;
2348
+ if (p.utilizationRate > 90) riskSignals++;
2349
+ const riskLevel = riskSignals >= 3 ? "high" : riskSignals >= 1 ? "medium" : "low";
2350
+ const stabilityScore = (p.tvlStability === true ? 1 : 0) + (p.apyStability === true ? 1 : 0) + (p.tvlApyCombinedRisk === true ? 1 : 0);
2351
+ const liquidityBonus = p.liquidityDepth === "deep" ? 1 : p.liquidityDepth === "moderate" ? 0.5 : 0;
2352
+ const healthTotal = stabilityScore + liquidityBonus;
2353
+ const healthScore = healthTotal >= 3 ? "healthy" : healthTotal >= 1.5 ? "moderate" : "risky";
2354
+ const apy7d = p.avgCombinedApy7d;
2355
+ const apy30d = p.avgCombinedApy30d;
2356
+ let apyTrend = "stable";
2357
+ if (apy7d != null && apy30d != null && apy30d !== 0) {
2358
+ const change = (apy7d - apy30d) / apy30d;
2359
+ if (change > 0.1) apyTrend = "rising";
2360
+ else if (change < -0.1) apyTrend = "falling";
2361
+ }
2362
+ let yieldConsistency = "consistent";
2363
+ if (apy7d != null && apy30d != null && apy30d !== 0) {
2364
+ const spread = Math.abs(apy7d - apy30d) / apy30d;
2365
+ if (spread > 0.3) yieldConsistency = "volatile";
2366
+ else if (spread > 0.1) yieldConsistency = "mixed";
2367
+ }
2368
+ return {
2369
+ poolName: p.poolName,
2370
+ protocolName: p.protocolName,
2371
+ chainId: p.chainId,
2372
+ healthScore,
2373
+ riskLevel,
2374
+ apyTrend,
2375
+ yieldConsistency,
2376
+ liquidityDepth: p.liquidityDepth,
2377
+ avgCombinedApy7d: p.avgCombinedApy7d
2378
+ };
2379
+ }
2230
2380
  // ============================================================================
2231
2381
  // APY History Methods (Data API v2)
2232
2382
  // ============================================================================
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyfai/sdk",
3
- "version": "0.2.10",
3
+ "version": "0.2.11",
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",