@1delta/margin-fetcher 0.0.82 → 0.0.84

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.js CHANGED
@@ -17547,14 +17547,44 @@ function meetsLiquidityThresholdsShort(pool, thresholds) {
17547
17547
  }
17548
17548
 
17549
17549
  // src/lending-pairs/computeLendingPairs.ts
17550
- var isEMode = (longData, shortData) => Boolean(longData.eMode) ? Number(longData.eMode?.category) > 0 && Number(longData.eMode?.category) === shortData.eMode?.category : false;
17550
+ function findMaxBorrowCollateralFactorRatio(lender, configsIn, configsOut) {
17551
+ let maxRatio = -Infinity;
17552
+ let result = { modeId: 0, eModeCategory: 0 };
17553
+ for (const modeIdStr of Object.keys(configsIn)) {
17554
+ const modeId = Number(modeIdStr);
17555
+ const dataIn = configsIn[modeId];
17556
+ const dataOut = configsOut[modeId];
17557
+ if (dataIn.debtDisabled || isAaveV32Type(lender) && dataOut.collateralDisabled) {
17558
+ continue;
17559
+ }
17560
+ if (dataOut.borrowFactor === 0) {
17561
+ continue;
17562
+ }
17563
+ const ratio = dataIn.borrowCollateralFactor / dataOut.borrowFactor;
17564
+ if (ratio > maxRatio) {
17565
+ maxRatio = ratio;
17566
+ result = {
17567
+ modeId,
17568
+ eModeCategory: dataIn.category
17569
+ // category comes from LenderConfigData
17570
+ };
17571
+ }
17572
+ }
17573
+ return result;
17574
+ }
17575
+ var isEMode = (lender, longData, shortData) => findMaxBorrowCollateralFactorRatio(
17576
+ lender,
17577
+ shortData?.config ?? {},
17578
+ longData?.config ?? {}
17579
+ );
17551
17580
  var intersection = (a0, a1) => {
17552
17581
  return a0.filter((a) => a1.includes(a));
17553
17582
  };
17554
17583
  var LENDER_MODE_NO_MODE2 = 0;
17555
17584
  var getMaxLeverage = (lender, longData, shortData) => {
17556
17585
  if (isAaveV3Type(lender)) {
17557
- const cf2 = isEMode(longData, shortData) ? longData.config[longData.eMode?.category ?? 0]?.borrowCollateralFactor : longData.config[LENDER_MODE_NO_MODE2]?.borrowCollateralFactor;
17586
+ const emode = isEMode(lender, longData, shortData).modeId;
17587
+ const cf2 = longData.config[emode ?? LENDER_MODE_NO_MODE2]?.borrowCollateralFactor;
17558
17588
  return 1 / (1 - cf2);
17559
17589
  }
17560
17590
  if (isInit(lender)) {
@@ -17955,6 +17985,11 @@ var thBill = "Theo Short Duration US Treasury Fund::THBILL";
17955
17985
  var ssuperusd = "SuperReturn sSuperUSD::SSUPERUSD";
17956
17986
  var hbhype = "hyperbeat x ether.fi HYPE::beHYPE";
17957
17987
  var hlp = "Wrapped HLP::WHLP";
17988
+ var yoeth = "Yield Optimizer ETH::YOETH";
17989
+ var yobtc = "Yield Optimizer BTC::YOBTC";
17990
+ var yousd = "Yield Optimizer USD::YOUSD";
17991
+ var yoeur = "Yield Optimizer EUR::yoEUR";
17992
+ var hwhlp = "Hyperwave HLP::hwHLP";
17958
17993
  var FeedData = {
17959
17994
  WSTETH: "https://eth-api.lido.fi/v1/protocol/steth/apr/sma",
17960
17995
  STMATIC: "https://polygon.lido.fi/api/stats",
@@ -17990,7 +18025,9 @@ var FeedData = {
17990
18025
  YEARN_KATANA: "https://katana-apr-service.vercel.app/api/vaults",
17991
18026
  SSUPERUSD: "https://www.superreturn.ai/api/trpc/cmc.getUSDCPrice,rewardBackend.getYield,rewardBackend.getTvlChange?batch=1&input=%7B%220%22%3A%7B%22json%22%3Anull%2C%22meta%22%3A%7B%22values%22%3A%5B%22undefined%22%5D%7D%7D%2C%221%22%3A%7B%22json%22%3Anull%2C%22meta%22%3A%7B%22values%22%3A%5B%22undefined%22%5D%7D%7D%2C%222%22%3A%7B%22json%22%3Anull%2C%22meta%22%3A%7B%22values%22%3A%5B%22undefined%22%5D%7D%7D%7D",
17992
18027
  HBHYPE: "https://api.hyperbeat.org/api/v1/staking?address=0xCeaD893b162D38e714D82d06a7fe0b0dc3c38E0b",
17993
- HLP: "https://api-ui.hyperliquid.xyz/info"
18028
+ HLP: "https://api-ui.hyperliquid.xyz/info",
18029
+ HWHLP: "https://api.hyperwavefi.xyz/stats/latest?asset=hwhlp_999",
18030
+ YO: "https://api.yo.xyz/api/v1/vault/stats"
17994
18031
  };
17995
18032
  function averageDataLastN(arr, n = 7) {
17996
18033
  const last = arr.slice(-n);
@@ -18193,6 +18230,23 @@ var fetchGeneralYields = async () => {
18193
18230
  }).then((r) => r.json());
18194
18231
  return Number(res?.rewards[0]?.apr ?? 0) * 100;
18195
18232
  });
18233
+ const yoPromise = safeFetch("YO", async () => {
18234
+ const res = await fetch(FeedData.YO, {
18235
+ method: "GET",
18236
+ headers: { Accept: "application/json" }
18237
+ }).then((r) => r.json());
18238
+ const datas = res?.data;
18239
+ const yoETH = datas.find((a) => a.id === "yoETH").yield?.["1d"];
18240
+ const yoBTC = datas.find((a) => a.id === "yoBTC").yield?.["1d"];
18241
+ const yoUSD = datas.find((a) => a.id === "yoUSD").yield?.["1d"];
18242
+ const yoEUR = datas.find((a) => a.id === "yoEUR").yield?.["1d"];
18243
+ return {
18244
+ [yoeth]: apyToAprPercent(yoETH),
18245
+ [yobtc]: apyToAprPercent(yoBTC),
18246
+ [yousd]: apyToAprPercent(yoUSD),
18247
+ [yoeur]: apyToAprPercent(yoEUR)
18248
+ };
18249
+ });
18196
18250
  const susdsPromise = safeFetch("SUSDS", async () => {
18197
18251
  const res = await fetch(FeedData.SUSDS, {
18198
18252
  method: "GET",
@@ -18248,6 +18302,13 @@ var fetchGeneralYields = async () => {
18248
18302
  }).then((r) => r.text());
18249
18303
  return Number(res) ?? 0;
18250
18304
  });
18305
+ const hwhlpPromise = safeFetch("HWHLP", async () => {
18306
+ const res = await fetch(FeedData.HWHLP, {
18307
+ method: "GET",
18308
+ headers: { Accept: "application/json" }
18309
+ }).then((r) => r.json());
18310
+ return Number(res.data?.last_annualized_apr ?? 0);
18311
+ });
18251
18312
  const csusdlPromise = safeFetch("CSUSDL", async () => {
18252
18313
  const res = await fetch(FeedData.MORPHO_VAULTS, {
18253
18314
  method: "POST",
@@ -18375,7 +18436,9 @@ var fetchGeneralYields = async () => {
18375
18436
  ssuperusdData,
18376
18437
  hbhypeData,
18377
18438
  pendleData,
18378
- hlpData
18439
+ hlpData,
18440
+ yoData,
18441
+ hwhlpData
18379
18442
  ] = await Promise.all([
18380
18443
  wstethPromise,
18381
18444
  ezethPromise,
@@ -18413,7 +18476,9 @@ var fetchGeneralYields = async () => {
18413
18476
  ssuperusdPromise,
18414
18477
  hbhypePromise,
18415
18478
  pendlePromise,
18416
- hlpPromise
18479
+ hlpPromise,
18480
+ yoPromise,
18481
+ hwhlpPromise
18417
18482
  ]);
18418
18483
  const data = {
18419
18484
  intrinsicYields: {
@@ -18451,11 +18516,13 @@ var fetchGeneralYields = async () => {
18451
18516
  [ssuperusd]: ssuperusdData,
18452
18517
  [hbhype]: hbhypeData,
18453
18518
  [hlp]: hlpData,
18519
+ [hwhlp]: hwhlpData,
18454
18520
  ...rtokensData,
18455
18521
  ...hypeData,
18456
18522
  ...angleData,
18457
18523
  ...yearnKatanaData,
18458
- ...pendleData
18524
+ ...pendleData,
18525
+ ...yoData
18459
18526
  },
18460
18527
  lenderRewards: {
18461
18528
  // '167000': {