@1delta/margin-fetcher 0.0.229 → 0.0.230
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 +34 -42
- package/dist/index.js.map +1 -1
- package/dist/lending/public-data/silo-v2/convertPublic.d.ts.map +1 -1
- package/dist/lending/public-data/silo-v2/publicCallParse.d.ts.map +1 -1
- package/dist/lending/public-data/silo-v3/convertPublic.d.ts.map +1 -1
- package/dist/lending/public-data/silo-v3/publicCallParse.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -18772,11 +18772,11 @@ var getSiloV2ReservesDataConverter = (lender, chainId, prices, additionalYields,
|
|
|
18772
18772
|
const assetMeta = tokenList[tokenAddrLc];
|
|
18773
18773
|
const oracleKey = toOracleKey(assetMeta?.assetGroup ?? null) || toGenericPriceKey(tokenAddrLc, chainId);
|
|
18774
18774
|
const price = prices[oracleKey] ?? 0;
|
|
18775
|
-
const collateralLt = Number(other.lt) / 1e18;
|
|
18776
|
-
const collateralMaxLtv = Number(other.maxLtv) / 1e18;
|
|
18777
18775
|
const selfLt = Number(self.lt) / 1e18;
|
|
18778
|
-
const
|
|
18776
|
+
const selfMaxLtv = Number(self.maxLtv) / 1e18;
|
|
18777
|
+
const otherLt = Number(other.lt) / 1e18;
|
|
18779
18778
|
const collateralActive = selfLt > 0;
|
|
18779
|
+
const borrowingEnabled = otherLt > 0;
|
|
18780
18780
|
const marketUid = createMarketUid(chainId, lender, self.silo);
|
|
18781
18781
|
out[marketUid] = {
|
|
18782
18782
|
marketUid,
|
|
@@ -18819,11 +18819,11 @@ var getSiloV2ReservesDataConverter = (lender, chainId, prices, additionalYields,
|
|
|
18819
18819
|
config: {
|
|
18820
18820
|
0: {
|
|
18821
18821
|
category: 0,
|
|
18822
|
-
borrowCollateralFactor:
|
|
18823
|
-
collateralFactor:
|
|
18822
|
+
borrowCollateralFactor: selfMaxLtv,
|
|
18823
|
+
collateralFactor: selfLt,
|
|
18824
18824
|
borrowFactor: 1,
|
|
18825
|
-
collateralDisabled: !
|
|
18826
|
-
debtDisabled: !
|
|
18825
|
+
collateralDisabled: !collateralActive,
|
|
18826
|
+
debtDisabled: !borrowingEnabled
|
|
18827
18827
|
}
|
|
18828
18828
|
},
|
|
18829
18829
|
collateralActive,
|
|
@@ -18924,11 +18924,11 @@ var getSiloV3ReservesDataConverter = (lender, chainId, prices, additionalYields,
|
|
|
18924
18924
|
const assetMeta = tokenList[tokenAddrLc];
|
|
18925
18925
|
const oracleKey = toOracleKey(assetMeta?.assetGroup ?? null) || toGenericPriceKey(tokenAddrLc, chainId);
|
|
18926
18926
|
const price = prices[oracleKey] ?? 0;
|
|
18927
|
-
const collateralLt = Number(other.lt) / 1e18;
|
|
18928
|
-
const collateralMaxLtv = Number(other.maxLtv) / 1e18;
|
|
18929
18927
|
const selfLt = Number(self.lt) / 1e18;
|
|
18930
|
-
const
|
|
18928
|
+
const selfMaxLtv = Number(self.maxLtv) / 1e18;
|
|
18929
|
+
const otherLt = Number(other.lt) / 1e18;
|
|
18931
18930
|
const collateralActive = selfLt > 0;
|
|
18931
|
+
const borrowingEnabled = otherLt > 0;
|
|
18932
18932
|
const marketUid = createMarketUid(chainId, lender, self.silo);
|
|
18933
18933
|
out[marketUid] = {
|
|
18934
18934
|
marketUid,
|
|
@@ -18963,11 +18963,11 @@ var getSiloV3ReservesDataConverter = (lender, chainId, prices, additionalYields,
|
|
|
18963
18963
|
config: {
|
|
18964
18964
|
0: {
|
|
18965
18965
|
category: 0,
|
|
18966
|
-
borrowCollateralFactor:
|
|
18967
|
-
collateralFactor:
|
|
18966
|
+
borrowCollateralFactor: selfMaxLtv,
|
|
18967
|
+
collateralFactor: selfLt,
|
|
18968
18968
|
borrowFactor: 1,
|
|
18969
|
-
collateralDisabled: !
|
|
18970
|
-
debtDisabled: !
|
|
18969
|
+
collateralDisabled: !collateralActive,
|
|
18970
|
+
debtDisabled: !borrowingEnabled
|
|
18971
18971
|
}
|
|
18972
18972
|
},
|
|
18973
18973
|
collateralActive,
|
|
@@ -19424,21 +19424,20 @@ function convertSiloMarketsToPublicResponse(apiItems, chainId, prices, additiona
|
|
|
19424
19424
|
const totalDebt = safeNumber(api.borrowed);
|
|
19425
19425
|
const totalLiquidity = totalDeposits - totalDebt;
|
|
19426
19426
|
const utilization = totalDeposits > 0 ? totalDebt / totalDeposits : safeNumber(api.utilization);
|
|
19427
|
-
const variableBorrowRatePct = safeNumber(api.borrowRate)
|
|
19428
|
-
const depositRatePct = safeNumber(api.depositRate)
|
|
19427
|
+
const variableBorrowRatePct = safeNumber(api.borrowRate);
|
|
19428
|
+
const depositRatePct = safeNumber(api.depositRate);
|
|
19429
19429
|
const assetMeta = tokenList[tokenAddrLc];
|
|
19430
19430
|
const oracleKey = toOracleKey(assetMeta?.assetGroup ?? null) || toGenericPriceKey(tokenAddrLc, chainId);
|
|
19431
19431
|
const fallbackPrice = prices[oracleKey] ?? 0;
|
|
19432
19432
|
const totalDepositsUSD = api.supplyUsd != null && api.supplyUsd > 0 ? api.supplyUsd : totalDeposits * fallbackPrice;
|
|
19433
19433
|
const totalDebtUSD = api.borrowedUsd != null && api.borrowedUsd > 0 ? api.borrowedUsd : totalDebt * fallbackPrice;
|
|
19434
19434
|
const totalLiquidityUSD = Math.max(totalDepositsUSD - totalDebtUSD, 0);
|
|
19435
|
-
const
|
|
19436
|
-
const collateralMaxLtv = safeLtvOrFee(api, "maxLtv", other.maxLtv);
|
|
19435
|
+
const otherApi = sides[0].api === api ? apiSide1 : apiSide0;
|
|
19437
19436
|
const selfLt = bigintToLtv(api.lt ?? self.lt);
|
|
19438
|
-
const
|
|
19439
|
-
const
|
|
19440
|
-
const borrowingEnabled = (collateralLtFromApi || collateralLt) > 0;
|
|
19437
|
+
const selfMaxLtv = bigintToLtv(api.maxLtv ?? self.maxLtv);
|
|
19438
|
+
const otherLt = bigintToLtv(otherApi.lt ?? other.lt);
|
|
19441
19439
|
const collateralActive = selfLt > 0;
|
|
19440
|
+
const borrowingEnabled = otherLt > 0;
|
|
19442
19441
|
const siloAddrLc = self.silo.toLowerCase();
|
|
19443
19442
|
const marketUid = createMarketUid(chainId, lenderKey, siloAddrLc);
|
|
19444
19443
|
data[marketUid] = {
|
|
@@ -19476,11 +19475,11 @@ function convertSiloMarketsToPublicResponse(apiItems, chainId, prices, additiona
|
|
|
19476
19475
|
config: {
|
|
19477
19476
|
0: {
|
|
19478
19477
|
category: 0,
|
|
19479
|
-
borrowCollateralFactor:
|
|
19480
|
-
collateralFactor:
|
|
19478
|
+
borrowCollateralFactor: selfMaxLtv,
|
|
19479
|
+
collateralFactor: selfLt,
|
|
19481
19480
|
borrowFactor: 1,
|
|
19482
|
-
collateralDisabled: !
|
|
19483
|
-
debtDisabled: !
|
|
19481
|
+
collateralDisabled: !collateralActive,
|
|
19482
|
+
debtDisabled: !borrowingEnabled
|
|
19484
19483
|
}
|
|
19485
19484
|
},
|
|
19486
19485
|
collateralActive,
|
|
@@ -19529,9 +19528,6 @@ function bigintToLtv(v) {
|
|
|
19529
19528
|
return Number.isFinite(n) ? n / 1e18 : 0;
|
|
19530
19529
|
}
|
|
19531
19530
|
}
|
|
19532
|
-
function safeLtvOrFee(api, field5, fallback) {
|
|
19533
|
-
return bigintToLtv(api[field5] ?? fallback);
|
|
19534
|
-
}
|
|
19535
19531
|
|
|
19536
19532
|
// src/lending/public-data/silo-v3/convertPublic.ts
|
|
19537
19533
|
var ZERO_ADDRESS2 = "0x0000000000000000000000000000000000000000";
|
|
@@ -19564,21 +19560,20 @@ function convertSiloV3MarketsToPublicResponse(apiItems, chainId, prices, additio
|
|
|
19564
19560
|
const totalDebt = safeNumber2(api.borrowed);
|
|
19565
19561
|
const totalLiquidity = totalDeposits - totalDebt;
|
|
19566
19562
|
const utilization = totalDeposits > 0 ? totalDebt / totalDeposits : safeNumber2(api.utilization);
|
|
19567
|
-
const variableBorrowRatePct = safeNumber2(api.borrowRate)
|
|
19568
|
-
const depositRatePct = safeNumber2(api.depositRate)
|
|
19563
|
+
const variableBorrowRatePct = safeNumber2(api.borrowRate);
|
|
19564
|
+
const depositRatePct = safeNumber2(api.depositRate);
|
|
19569
19565
|
const assetMeta = tokenList[tokenAddrLc];
|
|
19570
19566
|
const oracleKey = toOracleKey(assetMeta?.assetGroup ?? null) || toGenericPriceKey(tokenAddrLc, chainId);
|
|
19571
19567
|
const fallbackPrice = prices[oracleKey] ?? 0;
|
|
19572
19568
|
const totalDepositsUSD = api.supplyUsd != null && api.supplyUsd > 0 ? api.supplyUsd : totalDeposits * fallbackPrice;
|
|
19573
19569
|
const totalDebtUSD = api.borrowedUsd != null && api.borrowedUsd > 0 ? api.borrowedUsd : totalDebt * fallbackPrice;
|
|
19574
19570
|
const totalLiquidityUSD = Math.max(totalDepositsUSD - totalDebtUSD, 0);
|
|
19575
|
-
const
|
|
19576
|
-
const collateralMaxLtv = safeLtvOrFee2(api, "maxLtv", other.maxLtv);
|
|
19571
|
+
const otherApi = sides[0].api === api ? apiSide1 : apiSide0;
|
|
19577
19572
|
const selfLt = bigintToLtv2(api.lt ?? self.lt);
|
|
19578
|
-
const
|
|
19579
|
-
const
|
|
19580
|
-
const borrowingEnabled = (collateralLtFromApi || collateralLt) > 0;
|
|
19573
|
+
const selfMaxLtv = bigintToLtv2(api.maxLtv ?? self.maxLtv);
|
|
19574
|
+
const otherLt = bigintToLtv2(otherApi.lt ?? other.lt);
|
|
19581
19575
|
const collateralActive = selfLt > 0;
|
|
19576
|
+
const borrowingEnabled = otherLt > 0;
|
|
19582
19577
|
const siloAddrLc = self.silo.toLowerCase();
|
|
19583
19578
|
const marketUid = createMarketUid(chainId, lenderKey, siloAddrLc);
|
|
19584
19579
|
data[marketUid] = {
|
|
@@ -19614,11 +19609,11 @@ function convertSiloV3MarketsToPublicResponse(apiItems, chainId, prices, additio
|
|
|
19614
19609
|
config: {
|
|
19615
19610
|
0: {
|
|
19616
19611
|
category: 0,
|
|
19617
|
-
borrowCollateralFactor:
|
|
19618
|
-
collateralFactor:
|
|
19612
|
+
borrowCollateralFactor: selfMaxLtv,
|
|
19613
|
+
collateralFactor: selfLt,
|
|
19619
19614
|
borrowFactor: 1,
|
|
19620
|
-
collateralDisabled: !
|
|
19621
|
-
debtDisabled: !
|
|
19615
|
+
collateralDisabled: !collateralActive,
|
|
19616
|
+
debtDisabled: !borrowingEnabled
|
|
19622
19617
|
}
|
|
19623
19618
|
},
|
|
19624
19619
|
collateralActive,
|
|
@@ -19667,9 +19662,6 @@ function bigintToLtv2(v) {
|
|
|
19667
19662
|
return Number.isFinite(n) ? n / 1e18 : 0;
|
|
19668
19663
|
}
|
|
19669
19664
|
}
|
|
19670
|
-
function safeLtvOrFee2(api, field5, fallback) {
|
|
19671
|
-
return bigintToLtv2(api[field5] ?? fallback);
|
|
19672
|
-
}
|
|
19673
19665
|
|
|
19674
19666
|
// src/lending/public-data/fetchLenderExt.ts
|
|
19675
19667
|
async function getLenderDataFromApi(lender, chainId, prices, additionalYields, includeUnlisted = false) {
|