@1delta/margin-fetcher 0.0.81 → 0.0.83

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)) {
@@ -17649,7 +17679,8 @@ function generateLendingPairs(lenderData, prices, histPrices) {
17649
17679
  eMode: long.eMode?.category ?? 0,
17650
17680
  longTotalDepositsUSD: long.totalDepositsUSD,
17651
17681
  longTotalDebtUSD: long.totalDebtUSD,
17652
- longTotalLiquidityUSD: long.totalLiquidityUSD,
17682
+ // if the asset cannot be borrowed, liquidity is not a pparameter for longing
17683
+ longTotalLiquidityUSD: long.borrowingEnabled ? long.totalLiquidityUSD : 1e10,
17653
17684
  shortTotalDepositsUSD: short.totalDepositsUSD,
17654
17685
  shortTotalDebtUSD: short.totalDebtUSD,
17655
17686
  shortTotalLiquidityUSD: short.totalLiquidityUSD,
@@ -17953,6 +17984,11 @@ var jitoSol = "Jito Staked SOL::JitoSOL";
17953
17984
  var thBill = "Theo Short Duration US Treasury Fund::THBILL";
17954
17985
  var ssuperusd = "SuperReturn sSuperUSD::SSUPERUSD";
17955
17986
  var hbhype = "hyperbeat x ether.fi HYPE::beHYPE";
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";
17956
17992
  var FeedData = {
17957
17993
  WSTETH: "https://eth-api.lido.fi/v1/protocol/steth/apr/sma",
17958
17994
  STMATIC: "https://polygon.lido.fi/api/stats",
@@ -17987,7 +18023,9 @@ var FeedData = {
17987
18023
  THBILL: "https://thbill-api.theo.xyz/snapshots",
17988
18024
  YEARN_KATANA: "https://katana-apr-service.vercel.app/api/vaults",
17989
18025
  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",
17990
- HBHYPE: "https://api.hyperbeat.org/api/v1/staking?address=0xCeaD893b162D38e714D82d06a7fe0b0dc3c38E0b"
18026
+ HBHYPE: "https://api.hyperbeat.org/api/v1/staking?address=0xCeaD893b162D38e714D82d06a7fe0b0dc3c38E0b",
18027
+ HLP: "https://api-ui.hyperliquid.xyz/info",
18028
+ YO: "https://api.yo.xyz/api/v1/vault/stats"
17991
18029
  };
17992
18030
  function averageDataLastN(arr, n = 7) {
17993
18031
  const last = arr.slice(-n);
@@ -18190,6 +18228,23 @@ var fetchGeneralYields = async () => {
18190
18228
  }).then((r) => r.json());
18191
18229
  return Number(res?.rewards[0]?.apr ?? 0) * 100;
18192
18230
  });
18231
+ const yoPromise = safeFetch("YO", async () => {
18232
+ const res = await fetch(FeedData.YO, {
18233
+ method: "GET",
18234
+ headers: { Accept: "application/json" }
18235
+ }).then((r) => r.json());
18236
+ const datas = res?.data;
18237
+ const yoETH = datas.find((a) => a.id === "yoETH").yield?.["1d"];
18238
+ const yoBTC = datas.find((a) => a.id === "yoBTC").yield?.["1d"];
18239
+ const yoUSD = datas.find((a) => a.id === "yoUSD").yield?.["1d"];
18240
+ const yoEUR = datas.find((a) => a.id === "yoEUR").yield?.["1d"];
18241
+ return {
18242
+ [yoeth]: apyToAprPercent(yoETH),
18243
+ [yobtc]: apyToAprPercent(yoBTC),
18244
+ [yousd]: apyToAprPercent(yoUSD),
18245
+ [yoeur]: apyToAprPercent(yoEUR)
18246
+ };
18247
+ });
18193
18248
  const susdsPromise = safeFetch("SUSDS", async () => {
18194
18249
  const res = await fetch(FeedData.SUSDS, {
18195
18250
  method: "GET",
@@ -18259,6 +18314,22 @@ var fetchGeneralYields = async () => {
18259
18314
  const vba = res?.data?.vaultByAddress;
18260
18315
  return apyToAprPercent(vba.state.apy ?? 0) * 100 + (vba?.asset?.yield.apr ?? 0) * 100;
18261
18316
  });
18317
+ const hlpPromise = safeFetch("HLP", async () => {
18318
+ const res = await fetch(FeedData.HLP, {
18319
+ method: "POST",
18320
+ headers: {
18321
+ Accept: "application/json",
18322
+ "Content-Type": "application/json"
18323
+ // <-- required
18324
+ },
18325
+ body: JSON.stringify({
18326
+ type: "vaultDetails",
18327
+ vaultAddress: "0xdfc24b077bc1425ad1dea75bcb6f8158e10df303"
18328
+ })
18329
+ }).then((r) => r.json());
18330
+ const apr = (res?.apr ?? 0) * 100;
18331
+ return apr;
18332
+ });
18262
18333
  const rtokensPromise = safeFetch("RTOKENS", async () => {
18263
18334
  const res = await fetch(FeedData.RTOKENS).then((r) => r.json());
18264
18335
  const data2 = res.rtokens["8453"];
@@ -18355,7 +18426,9 @@ var fetchGeneralYields = async () => {
18355
18426
  yearnKatanaData,
18356
18427
  ssuperusdData,
18357
18428
  hbhypeData,
18358
- pendleData
18429
+ pendleData,
18430
+ hlpData,
18431
+ yoData
18359
18432
  ] = await Promise.all([
18360
18433
  wstethPromise,
18361
18434
  ezethPromise,
@@ -18392,7 +18465,9 @@ var fetchGeneralYields = async () => {
18392
18465
  yearnKatanaPromise,
18393
18466
  ssuperusdPromise,
18394
18467
  hbhypePromise,
18395
- pendlePromise
18468
+ pendlePromise,
18469
+ hlpPromise,
18470
+ yoPromise
18396
18471
  ]);
18397
18472
  const data = {
18398
18473
  intrinsicYields: {
@@ -18429,11 +18504,13 @@ var fetchGeneralYields = async () => {
18429
18504
  [thBill]: thBillData,
18430
18505
  [ssuperusd]: ssuperusdData,
18431
18506
  [hbhype]: hbhypeData,
18507
+ [hlp]: hlpData,
18432
18508
  ...rtokensData,
18433
18509
  ...hypeData,
18434
18510
  ...angleData,
18435
18511
  ...yearnKatanaData,
18436
- ...pendleData
18512
+ ...pendleData,
18513
+ ...yoData
18437
18514
  },
18438
18515
  lenderRewards: {
18439
18516
  // '167000': {