@continuumdao/ctm-mpc-defi 0.2.34 → 0.2.35

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.
Files changed (83) hide show
  1. package/dist/agent/catalog.cjs +712 -44
  2. package/dist/agent/catalog.cjs.map +1 -1
  3. package/dist/agent/catalog.d.ts +1630 -244
  4. package/dist/agent/catalog.js +678 -45
  5. package/dist/agent/catalog.js.map +1 -1
  6. package/dist/agent/skills/aave-v4/SKILL.md +19 -4
  7. package/dist/agent/skills/aerodrome/SKILL.md +2 -2
  8. package/dist/agent/skills/compound-v3/SKILL.md +2 -2
  9. package/dist/agent/skills/curve-dao/SKILL.md +14 -0
  10. package/dist/agent/skills/ethena/SKILL.md +3 -1
  11. package/dist/agent/skills/euler-v2/SKILL.md +1 -1
  12. package/dist/agent/skills/gmx/SKILL.md +1 -1
  13. package/dist/agent/skills/hyperliquid/SKILL.md +7 -5
  14. package/dist/agent/skills/lido/SKILL.md +3 -0
  15. package/dist/agent/skills/maple-syrup/SKILL.md +35 -3
  16. package/dist/agent/skills/morpho/SKILL.md +1 -1
  17. package/dist/agent/skills/sky/SKILL.md +2 -0
  18. package/dist/agent/skills/yield-compare/SKILL.md +78 -0
  19. package/dist/index.cjs +129 -29
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.js +129 -27
  22. package/dist/index.js.map +1 -1
  23. package/dist/protocols/evm/aave-v4/index.cjs +170 -0
  24. package/dist/protocols/evm/aave-v4/index.cjs.map +1 -1
  25. package/dist/protocols/evm/aave-v4/index.d.ts +59 -1
  26. package/dist/protocols/evm/aave-v4/index.js +164 -1
  27. package/dist/protocols/evm/aave-v4/index.js.map +1 -1
  28. package/dist/protocols/evm/aerodrome/index.cjs +1308 -901
  29. package/dist/protocols/evm/aerodrome/index.cjs.map +1 -1
  30. package/dist/protocols/evm/aerodrome/index.d.ts +69 -2
  31. package/dist/protocols/evm/aerodrome/index.js +1217 -807
  32. package/dist/protocols/evm/aerodrome/index.js.map +1 -1
  33. package/dist/protocols/evm/compound-v3/index.cjs +82 -6
  34. package/dist/protocols/evm/compound-v3/index.cjs.map +1 -1
  35. package/dist/protocols/evm/compound-v3/index.d.ts +89 -1
  36. package/dist/protocols/evm/compound-v3/index.js +80 -7
  37. package/dist/protocols/evm/compound-v3/index.js.map +1 -1
  38. package/dist/protocols/evm/curve-dao/index.cjs +447 -18
  39. package/dist/protocols/evm/curve-dao/index.cjs.map +1 -1
  40. package/dist/protocols/evm/curve-dao/index.d.ts +108 -1
  41. package/dist/protocols/evm/curve-dao/index.js +440 -19
  42. package/dist/protocols/evm/curve-dao/index.js.map +1 -1
  43. package/dist/protocols/evm/ethena/index.cjs +89 -0
  44. package/dist/protocols/evm/ethena/index.cjs.map +1 -1
  45. package/dist/protocols/evm/ethena/index.d.ts +17 -1
  46. package/dist/protocols/evm/ethena/index.js +89 -2
  47. package/dist/protocols/evm/ethena/index.js.map +1 -1
  48. package/dist/protocols/evm/euler-v2/index.cjs +29 -0
  49. package/dist/protocols/evm/euler-v2/index.cjs.map +1 -1
  50. package/dist/protocols/evm/euler-v2/index.d.ts +21 -1
  51. package/dist/protocols/evm/euler-v2/index.js +29 -1
  52. package/dist/protocols/evm/euler-v2/index.js.map +1 -1
  53. package/dist/protocols/evm/gmx/index.cjs +83 -1
  54. package/dist/protocols/evm/gmx/index.cjs.map +1 -1
  55. package/dist/protocols/evm/gmx/index.d.ts +22 -2
  56. package/dist/protocols/evm/gmx/index.js +80 -2
  57. package/dist/protocols/evm/gmx/index.js.map +1 -1
  58. package/dist/protocols/evm/hyperliquid/index.cjs +67 -11
  59. package/dist/protocols/evm/hyperliquid/index.cjs.map +1 -1
  60. package/dist/protocols/evm/hyperliquid/index.d.ts +39 -2
  61. package/dist/protocols/evm/hyperliquid/index.js +64 -12
  62. package/dist/protocols/evm/hyperliquid/index.js.map +1 -1
  63. package/dist/protocols/evm/lido/index.cjs +13 -0
  64. package/dist/protocols/evm/lido/index.cjs.map +1 -1
  65. package/dist/protocols/evm/lido/index.d.ts +9 -1
  66. package/dist/protocols/evm/lido/index.js +13 -1
  67. package/dist/protocols/evm/lido/index.js.map +1 -1
  68. package/dist/protocols/evm/maple/index.cjs +129 -1
  69. package/dist/protocols/evm/maple/index.cjs.map +1 -1
  70. package/dist/protocols/evm/maple/index.d.ts +45 -1
  71. package/dist/protocols/evm/maple/index.js +124 -3
  72. package/dist/protocols/evm/maple/index.js.map +1 -1
  73. package/dist/protocols/evm/morpho/index.cjs +34 -7
  74. package/dist/protocols/evm/morpho/index.cjs.map +1 -1
  75. package/dist/protocols/evm/morpho/index.d.ts +23 -1
  76. package/dist/protocols/evm/morpho/index.js +34 -8
  77. package/dist/protocols/evm/morpho/index.js.map +1 -1
  78. package/dist/protocols/evm/sky/index.cjs +52 -0
  79. package/dist/protocols/evm/sky/index.cjs.map +1 -1
  80. package/dist/protocols/evm/sky/index.d.ts +16 -1
  81. package/dist/protocols/evm/sky/index.js +50 -1
  82. package/dist/protocols/evm/sky/index.js.map +1 -1
  83. package/package.json +1 -1
@@ -305,6 +305,77 @@ function formatGmxLeverageBps(value) {
305
305
  if (!Number.isFinite(x) || x <= 0) return null;
306
306
  return `${x.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 })}\xD7`;
307
307
  }
308
+ var GMX_FLOAT_DECIMALS = 30;
309
+ var SECONDS_PER_HOUR = 3600;
310
+ var HOURS_PER_YEAR = 24 * 365;
311
+ function asGmxBigint(value) {
312
+ if (value == null) return null;
313
+ try {
314
+ return typeof value === "bigint" ? value : BigInt(String(value));
315
+ } catch {
316
+ return null;
317
+ }
318
+ }
319
+ function gmxFloatFactorToNumber(value) {
320
+ const n = asGmxBigint(value);
321
+ if (n == null) return null;
322
+ const negative = n < 0n;
323
+ const abs = negative ? -n : n;
324
+ const whole = abs / 10n ** BigInt(GMX_FLOAT_DECIMALS);
325
+ const frac = abs % 10n ** BigInt(GMX_FLOAT_DECIMALS);
326
+ const parsed = Number(`${whole}.${frac.toString().padStart(GMX_FLOAT_DECIMALS, "0")}`);
327
+ if (!Number.isFinite(parsed)) return null;
328
+ return negative ? -parsed : parsed;
329
+ }
330
+ function formatRatePercentLabel(fraction) {
331
+ const pct = fraction * 100;
332
+ if (!Number.isFinite(pct)) return null;
333
+ const abs = Math.abs(pct);
334
+ const maxDigits = abs >= 1 ? 2 : abs >= 0.01 ? 4 : 6;
335
+ return `${pct.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: maxDigits })}%`;
336
+ }
337
+ function formatGmxFactorPerSecondPercentLabels(factorPerSecond) {
338
+ const perSecond = gmxFloatFactorToNumber(factorPerSecond);
339
+ if (perSecond == null) return { hourlyPercentLabel: null, aprPercentLabel: null };
340
+ const hourly = perSecond * SECONDS_PER_HOUR;
341
+ return {
342
+ hourlyPercentLabel: formatRatePercentLabel(hourly),
343
+ aprPercentLabel: formatRatePercentLabel(hourly * HOURS_PER_YEAR)
344
+ };
345
+ }
346
+ var EMPTY_GMX_FUNDING_QUOTE = {
347
+ fundingFactorPerSecond: null,
348
+ longsPayShorts: null,
349
+ fundingHourlyPercentLabel: null,
350
+ fundingAprPercentLabel: null,
351
+ borrowingFactorPerSecondForLongs: null,
352
+ borrowingFactorPerSecondForShorts: null,
353
+ borrowingHourlyPercentLongLabel: null,
354
+ borrowingHourlyPercentShortLabel: null
355
+ };
356
+ function stringifyGmxFactor(value) {
357
+ const n = asGmxBigint(value);
358
+ return n == null ? null : n.toString();
359
+ }
360
+ function gmxFundingFromMarketInfo(info) {
361
+ if (!info) return { ...EMPTY_GMX_FUNDING_QUOTE };
362
+ const fundingLabels = formatGmxFactorPerSecondPercentLabels(info.fundingFactorPerSecond);
363
+ const borrowLong = formatGmxFactorPerSecondPercentLabels(info.borrowingFactorPerSecondForLongs);
364
+ const borrowShort = formatGmxFactorPerSecondPercentLabels(
365
+ info.borrowingFactorPerSecondForShorts
366
+ );
367
+ const longsPayShorts = info.longsPayShorts;
368
+ return {
369
+ fundingFactorPerSecond: stringifyGmxFactor(info.fundingFactorPerSecond),
370
+ longsPayShorts: typeof longsPayShorts === "boolean" ? longsPayShorts : null,
371
+ fundingHourlyPercentLabel: fundingLabels.hourlyPercentLabel,
372
+ fundingAprPercentLabel: fundingLabels.aprPercentLabel,
373
+ borrowingFactorPerSecondForLongs: stringifyGmxFactor(info.borrowingFactorPerSecondForLongs),
374
+ borrowingFactorPerSecondForShorts: stringifyGmxFactor(info.borrowingFactorPerSecondForShorts),
375
+ borrowingHourlyPercentLongLabel: borrowLong.hourlyPercentLabel,
376
+ borrowingHourlyPercentShortLabel: borrowShort.hourlyPercentLabel
377
+ };
378
+ }
308
379
  var require3 = module$1.createRequire(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))));
309
380
  var { hydrateMarketInfo, getMarketAddressByName } = require3("@gmx-io/sdk/utils/markets");
310
381
  var GMX_DEFAULT_MIN_COLLATERAL_USD = 10n * 10n ** 30n;
@@ -2121,6 +2192,12 @@ async function gmxFetchMarketPrices(args) {
2121
2192
  indexPerCollateral = mark != null && collateralPrice != null ? formatIndexPerCollateral(mark, collateralPrice) : null;
2122
2193
  } catch {
2123
2194
  }
2195
+ let funding = { ...EMPTY_GMX_FUNDING_QUOTE };
2196
+ try {
2197
+ const market = await resolveGmxMarketBySymbol(args.chainId, symbol);
2198
+ if (market) funding = gmxFundingFromMarketInfo(market);
2199
+ } catch {
2200
+ }
2124
2201
  return {
2125
2202
  symbol,
2126
2203
  indexLabel: indexLabelFromMarketSymbol(symbol),
@@ -2128,7 +2205,8 @@ async function gmxFetchMarketPrices(args) {
2128
2205
  indexMarkUsd,
2129
2206
  collateralUsd,
2130
2207
  indexPerCollateral,
2131
- fetchedAtMs: Date.now()
2208
+ fetchedAtMs: Date.now(),
2209
+ ...funding
2132
2210
  };
2133
2211
  }
2134
2212
  function gmxOhlcvWindowFromCandles(candles) {
@@ -2279,6 +2357,7 @@ var gmxProtocolModule = {
2279
2357
  };
2280
2358
  registerProtocolModule(gmxProtocolModule);
2281
2359
 
2360
+ exports.EMPTY_GMX_FUNDING_QUOTE = EMPTY_GMX_FUNDING_QUOTE;
2282
2361
  exports.GMX_NATIVE_GAS_SYMBOL_BY_CHAIN = GMX_NATIVE_GAS_SYMBOL_BY_CHAIN;
2283
2362
  exports.GMX_OHLCV_TIMEFRAMES = GMX_OHLCV_TIMEFRAMES;
2284
2363
  exports.GMX_PROTOCOL_ID = GMX_PROTOCOL_ID;
@@ -2295,6 +2374,7 @@ exports.buildEvmMultisignBodyGmxLimitIncreaseBatch = buildEvmMultisignBodyGmxLim
2295
2374
  exports.buildEvmMultisignBodyGmxStakeGmxBatch = buildEvmMultisignBodyGmxStakeGmxBatch;
2296
2375
  exports.buildEvmMultisignBodyGmxUnstakeGmxBatch = buildEvmMultisignBodyGmxUnstakeGmxBatch;
2297
2376
  exports.buildGmxTpslEntries = buildGmxTpslEntries;
2377
+ exports.formatGmxFactorPerSecondPercentLabels = formatGmxFactorPerSecondPercentLabels;
2298
2378
  exports.formatGmxLeverageBps = formatGmxLeverageBps;
2299
2379
  exports.formatGmxTokenAmountHuman = formatGmxTokenAmountHuman;
2300
2380
  exports.formatGmxUsd30 = formatGmxUsd30;
@@ -2325,8 +2405,10 @@ exports.gmxFetchPositionsForExecutor = gmxFetchPositionsForExecutor;
2325
2405
  exports.gmxFetchStakingPower = gmxFetchStakingPower;
2326
2406
  exports.gmxFetchTokens = gmxFetchTokens;
2327
2407
  exports.gmxFindWrappedNativeToken = gmxFindWrappedNativeToken;
2408
+ exports.gmxFloatFactorToNumber = gmxFloatFactorToNumber;
2328
2409
  exports.gmxFormatApyPercent = gmxFormatApyPercent;
2329
2410
  exports.gmxFormatPositionsForDisplay = gmxFormatPositionsForDisplay;
2411
+ exports.gmxFundingFromMarketInfo = gmxFundingFromMarketInfo;
2330
2412
  exports.gmxGmxTokenAddress = gmxGmxTokenAddress;
2331
2413
  exports.gmxIsCloseSizeWithinPosition = gmxIsCloseSizeWithinPosition;
2332
2414
  exports.gmxIsCollateralTokenSupported = gmxIsCollateralTokenSupported;