@1delta/margin-fetcher 0.0.70 → 0.0.72
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
|
@@ -8763,22 +8763,39 @@ var getInitReservesDataConverter = (lender, chainId, prices, additionalYields, t
|
|
|
8763
8763
|
INIT_MODES.forEach((mode, index) => {
|
|
8764
8764
|
data[index]?.forEach((multicallData) => {
|
|
8765
8765
|
const asset = multicallData?.underlying.toLowerCase();
|
|
8766
|
-
const cf = parseRawAmount(multicallData.collateralFactor, 18);
|
|
8766
|
+
const cf = Number(parseRawAmount(multicallData.collateralFactor, 18));
|
|
8767
8767
|
const modeData = {
|
|
8768
8768
|
category: mode,
|
|
8769
8769
|
label: INIT_EMODE_LABELS[mode],
|
|
8770
8770
|
borrowCollateralFactor: cf,
|
|
8771
8771
|
collateralFactor: cf,
|
|
8772
|
-
borrowFactor:
|
|
8773
|
-
|
|
8774
|
-
|
|
8775
|
-
|
|
8772
|
+
borrowFactor: Number(
|
|
8773
|
+
parseRawAmount(multicallData.borrowFactor, 18)
|
|
8774
|
+
),
|
|
8775
|
+
maxHealthAfterLiq: Number(
|
|
8776
|
+
parseRawAmount(multicallData.maxHealthAfterLiq, 18)
|
|
8776
8777
|
)
|
|
8777
8778
|
};
|
|
8778
8779
|
if (!eModes[mode]) eModes[mode] = modeData;
|
|
8779
8780
|
result[asset].config[mode] = modeData;
|
|
8780
8781
|
});
|
|
8781
8782
|
});
|
|
8783
|
+
Object.entries(eModes).forEach(([modeId, data2]) => {
|
|
8784
|
+
Object.entries(result)?.forEach(([key, _2]) => {
|
|
8785
|
+
if (!result[key].config[modeId]) {
|
|
8786
|
+
let mode = {
|
|
8787
|
+
...data2,
|
|
8788
|
+
debtDisabled: true,
|
|
8789
|
+
collateralDisabled: true,
|
|
8790
|
+
collateralFactor: 0,
|
|
8791
|
+
borrowCollateralFactor: 0,
|
|
8792
|
+
borrowFactor: 3402823669209385e5
|
|
8793
|
+
// disabled flag
|
|
8794
|
+
};
|
|
8795
|
+
result[key].config[modeId] = mode;
|
|
8796
|
+
}
|
|
8797
|
+
});
|
|
8798
|
+
});
|
|
8782
8799
|
return { data: result, eModes, chainId };
|
|
8783
8800
|
},
|
|
8784
8801
|
expectedNumberOfCalls
|
|
@@ -16714,12 +16731,10 @@ var getInitUserDataConverter = (lender, chainId, account, prices, pricesHist, le
|
|
|
16714
16731
|
return void 0;
|
|
16715
16732
|
}
|
|
16716
16733
|
const [data] = _data;
|
|
16717
|
-
const indexes = data[0 /* posMeta */].map(
|
|
16718
|
-
|
|
16719
|
-
|
|
16720
|
-
|
|
16721
|
-
).filter((a) => a.e.owner.toLowerCase() === validOwner).map((a) => a.i);
|
|
16722
|
-
const assets = getLenderAssets(chainId, lender);
|
|
16734
|
+
const indexes = data[0 /* posMeta */].map((e, i) => {
|
|
16735
|
+
return { e, i };
|
|
16736
|
+
}).filter((a) => a.e.owner.toLowerCase() === validOwner).map((a) => a.i);
|
|
16737
|
+
const assets = Object.keys(lenderData);
|
|
16723
16738
|
let histData = {};
|
|
16724
16739
|
const result = Object.assign(
|
|
16725
16740
|
{},
|
|
@@ -16729,20 +16744,33 @@ var getInitUserDataConverter = (lender, chainId, account, prices, pricesHist, le
|
|
|
16729
16744
|
const id = entry.posId.toString();
|
|
16730
16745
|
const collatData = Object.assign(
|
|
16731
16746
|
{},
|
|
16732
|
-
...data[1 /* collaterals */][index].map(
|
|
16733
|
-
|
|
16734
|
-
|
|
16735
|
-
|
|
16736
|
-
|
|
16737
|
-
|
|
16747
|
+
...data[1 /* collaterals */][index].map(
|
|
16748
|
+
(c) => {
|
|
16749
|
+
const asset = c.underlying.toLowerCase();
|
|
16750
|
+
const decimals = lenderData[asset].asset?.decimals ?? 18;
|
|
16751
|
+
const depositsRaw = c.amount.toString();
|
|
16752
|
+
return {
|
|
16753
|
+
[asset]: {
|
|
16754
|
+
deposits: parseRawAmount(depositsRaw, decimals),
|
|
16755
|
+
depositsRaw
|
|
16756
|
+
}
|
|
16757
|
+
};
|
|
16758
|
+
}
|
|
16759
|
+
)
|
|
16738
16760
|
);
|
|
16739
16761
|
const debtData = Object.assign(
|
|
16740
16762
|
{},
|
|
16741
|
-
...data[2 /* debts */][index].map(
|
|
16742
|
-
|
|
16743
|
-
|
|
16744
|
-
|
|
16745
|
-
|
|
16763
|
+
...data[2 /* debts */][index].map(
|
|
16764
|
+
(c) => {
|
|
16765
|
+
const asset = c.underlying.toLowerCase();
|
|
16766
|
+
const decimals = lenderData[asset]?.asset?.decimals ?? 18;
|
|
16767
|
+
return {
|
|
16768
|
+
[asset]: {
|
|
16769
|
+
debt: parseRawAmount(c.amount.toString(), decimals)
|
|
16770
|
+
}
|
|
16771
|
+
};
|
|
16772
|
+
}
|
|
16773
|
+
)
|
|
16746
16774
|
);
|
|
16747
16775
|
return {
|
|
16748
16776
|
[id]: {
|
|
@@ -16753,10 +16781,11 @@ var getInitUserDataConverter = (lender, chainId, account, prices, pricesHist, le
|
|
|
16753
16781
|
const ams = toOracleKey(lenderData[a]?.asset?.assetGroup);
|
|
16754
16782
|
const price = prices[ams] ?? 1;
|
|
16755
16783
|
const priceHist = pricesHist?.[ams] ?? price;
|
|
16756
|
-
if (!histData[id])
|
|
16757
|
-
|
|
16758
|
-
|
|
16759
|
-
|
|
16784
|
+
if (!histData[id])
|
|
16785
|
+
histData[id] = {
|
|
16786
|
+
totalDebt24h: 0,
|
|
16787
|
+
totalDeposits24h: 0
|
|
16788
|
+
};
|
|
16760
16789
|
const debt = debtData[a]?.debt ?? 0;
|
|
16761
16790
|
const deposits = collatData[a]?.deposits ?? 0;
|
|
16762
16791
|
const depositsRaw = collatData[a]?.depositsRaw ?? "0";
|