@1delta/margin-fetcher 0.0.82 → 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
|
-
|
|
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
|
|
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,10 @@ 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";
|
|
17958
17992
|
var FeedData = {
|
|
17959
17993
|
WSTETH: "https://eth-api.lido.fi/v1/protocol/steth/apr/sma",
|
|
17960
17994
|
STMATIC: "https://polygon.lido.fi/api/stats",
|
|
@@ -17990,7 +18024,8 @@ var FeedData = {
|
|
|
17990
18024
|
YEARN_KATANA: "https://katana-apr-service.vercel.app/api/vaults",
|
|
17991
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",
|
|
17992
18026
|
HBHYPE: "https://api.hyperbeat.org/api/v1/staking?address=0xCeaD893b162D38e714D82d06a7fe0b0dc3c38E0b",
|
|
17993
|
-
HLP: "https://api-ui.hyperliquid.xyz/info"
|
|
18027
|
+
HLP: "https://api-ui.hyperliquid.xyz/info",
|
|
18028
|
+
YO: "https://api.yo.xyz/api/v1/vault/stats"
|
|
17994
18029
|
};
|
|
17995
18030
|
function averageDataLastN(arr, n = 7) {
|
|
17996
18031
|
const last = arr.slice(-n);
|
|
@@ -18193,6 +18228,23 @@ var fetchGeneralYields = async () => {
|
|
|
18193
18228
|
}).then((r) => r.json());
|
|
18194
18229
|
return Number(res?.rewards[0]?.apr ?? 0) * 100;
|
|
18195
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
|
+
});
|
|
18196
18248
|
const susdsPromise = safeFetch("SUSDS", async () => {
|
|
18197
18249
|
const res = await fetch(FeedData.SUSDS, {
|
|
18198
18250
|
method: "GET",
|
|
@@ -18375,7 +18427,8 @@ var fetchGeneralYields = async () => {
|
|
|
18375
18427
|
ssuperusdData,
|
|
18376
18428
|
hbhypeData,
|
|
18377
18429
|
pendleData,
|
|
18378
|
-
hlpData
|
|
18430
|
+
hlpData,
|
|
18431
|
+
yoData
|
|
18379
18432
|
] = await Promise.all([
|
|
18380
18433
|
wstethPromise,
|
|
18381
18434
|
ezethPromise,
|
|
@@ -18413,7 +18466,8 @@ var fetchGeneralYields = async () => {
|
|
|
18413
18466
|
ssuperusdPromise,
|
|
18414
18467
|
hbhypePromise,
|
|
18415
18468
|
pendlePromise,
|
|
18416
|
-
hlpPromise
|
|
18469
|
+
hlpPromise,
|
|
18470
|
+
yoPromise
|
|
18417
18471
|
]);
|
|
18418
18472
|
const data = {
|
|
18419
18473
|
intrinsicYields: {
|
|
@@ -18455,7 +18509,8 @@ var fetchGeneralYields = async () => {
|
|
|
18455
18509
|
...hypeData,
|
|
18456
18510
|
...angleData,
|
|
18457
18511
|
...yearnKatanaData,
|
|
18458
|
-
...pendleData
|
|
18512
|
+
...pendleData,
|
|
18513
|
+
...yoData
|
|
18459
18514
|
},
|
|
18460
18515
|
lenderRewards: {
|
|
18461
18516
|
// '167000': {
|