@1delta/margin-fetcher 0.0.329 → 0.0.331
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 +64 -21
- package/dist/index.js.map +1 -1
- package/dist/lending/public-data/liquity/convertPublic.d.ts +13 -6
- package/dist/lending/public-data/liquity/convertPublic.d.ts.map +1 -1
- package/dist/lending/public-data/river/convertPublic.d.ts +10 -4
- package/dist/lending/public-data/river/convertPublic.d.ts.map +1 -1
- package/dist/lending/user-data/exactly/userCallParse.d.ts.map +1 -1
- package/dist/lending/user-data/liquity/userCallParse.d.ts +1 -1
- package/dist/lending/user-data/river/userCallParse.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import './chunk-BYTNVMX7.js';
|
|
|
3
3
|
import './chunk-PR4QN5HX.js';
|
|
4
4
|
import { Lender, LIQUITY_FAMILY_LENDERS, isAaveType, isCompoundV3, isMultiMarket, isSiloV2Type, isSiloV3Type, isDolomite, isEulerType, isAaveV4Type, isInit, isMorphoType, isCompoundV2Type, isVenusType, isSumerType, AAVE_V3_LENDERS, AAVE_V2_LENDERS, isAaveV2Type, isAaveV32Type, isAaveV3Type, isFluid, isGearboxV3, isMidnight, isTerm, isExactly, isLiquityFamily, isRiver, isYLDR, isCompoundV3Type, isLista, isTectonicType, isKineticType, isBenqiType } from '@1delta/lender-registry';
|
|
5
5
|
export { isAaveType, isAaveV2Type, isAaveV32Type, isAaveV3Type, isCompoundV3, isCompoundV3Type, isInit, isMorphoType, isMultiMarket, isYLDR } from '@1delta/lender-registry';
|
|
6
|
-
import { fetchTokenLists, fetchTokenList, aavePools, compoundV3Pools, initConfig, morphoPools, compoundV2Pools, eulerVaults, siloMarkets, siloV2LenderKey, siloMarketsV3, siloV3LenderKey, aaveV4Spokes, aaveV4SpokeLenderKey, fluidResolvers, gearboxResolvers, dolomiteConfigs, midnightConfig, exactlyConfig, liquityLendersByChain, riverLendersByChain, aaveReserves, compoundV3Reserves,
|
|
6
|
+
import { fetchTokenLists, fetchTokenList, aavePools, compoundV3Pools, initConfig, morphoPools, compoundV2Pools, eulerVaults, siloMarkets, siloV2LenderKey, siloMarketsV3, siloV3LenderKey, aaveV4Spokes, aaveV4SpokeLenderKey, fluidResolvers, gearboxResolvers, dolomiteConfigs, midnightConfig, termConfig, termMarketsByChain, exactlyConfig, liquityLendersByChain, riverLendersByChain, aaveReserves, compoundV3Reserves, liquityConfigFor, liquityBranchesByChain, riverConfigFor, riverChainData, morphoTypeMarkets, resolveMidnightApiBase, resolveTermApiBase, getSiloV2MarketEntry, getSiloV3MarketEntry, dolomiteEmode, aaveTokens, morphoTypeVaults, eulerConfigs, gearboxMarketCompressor, gearboxMarketConfigurators, gearboxV3LenderKey, midnightMarketsByChain, parseAaveV4SpokeLenderKey, gearboxAccountCompressor, compoundV2Tokens, aaveOracles, aaveOraclesConfig, compoundV2Oracles, compoundV2TokenArray, compoundV2OraclesConfig, compoundV3OraclesData, compoundV3BaseData, compoundV2Reserves, aaveV4Oracles } from '@1delta/data-sdk';
|
|
7
7
|
import lodash from 'lodash';
|
|
8
8
|
import { getEvmClient, multicallRetryUniversal, getEvmChain, getEvmClientUniversal } from '@1delta/providers';
|
|
9
9
|
import { LiquityTroveManagerAbi, LiquityActivePoolAbi, LiquityStabilityPoolAbi, LiquityPriceFeedAbi, LiquitySortedTrovesAbi, RiverTroveManagerAbi, RiverStabilityPoolAbi, MetaMorphoAbi, ExactlyPreviewerAbi, ExactlyAuditorAbi, FluidLendingResolverAbi, FluidVaultResolverAbi, FluidLiquidityResolverAbi, MoolahVaultAbi, MorphoLensAbi, AaveV4SpokeAbi, AaveV4OracleAbi, AaveV4HubAbi, DolomiteMarginAbi, GearboxMarketCompressorV310Abi, MorphoBlueAbi, MidnightAbi, TermRepoTokenAbi, TermRepoServicerAbi, TermRepoCollateralManagerAbi, LiquityTroveNFTAbi, LiquityCollSurplusPoolAbi, GearboxCreditAccountCompressorV310Abi } from '@1delta/abis';
|
|
@@ -7504,6 +7504,9 @@ var getLendersForChain = (c) => {
|
|
|
7504
7504
|
if (midnightConfig()?.[c]?.midnight) {
|
|
7505
7505
|
lenders.push(Lender.MORPHO_MIDNIGHT);
|
|
7506
7506
|
}
|
|
7507
|
+
if (termConfig()?.[c]?.termController && termMarketsByChain(c).length > 0) {
|
|
7508
|
+
lenders.push(Lender.TERM_FINANCE);
|
|
7509
|
+
}
|
|
7507
7510
|
if (exactlyConfig()?.[c]?.previewer) {
|
|
7508
7511
|
lenders.push(Lender.EXACTLY);
|
|
7509
7512
|
}
|
|
@@ -22098,15 +22101,16 @@ async function fetchLiquityMarkets(lender, chainId) {
|
|
|
22098
22101
|
});
|
|
22099
22102
|
return { lender, config, branches: out };
|
|
22100
22103
|
}
|
|
22101
|
-
function liquityLenderKey(lender, collIndex) {
|
|
22102
|
-
return `${lender}_${collIndex}`;
|
|
22104
|
+
function liquityLenderKey(lender, chainId, collIndex) {
|
|
22105
|
+
return `${lender}_${chainId}_${collIndex}`;
|
|
22103
22106
|
}
|
|
22104
22107
|
function liquityKeyParts(key) {
|
|
22105
|
-
const base = LIQUITY_FAMILY_LENDERS.find((b) => key.startsWith(b));
|
|
22108
|
+
const base = LIQUITY_FAMILY_LENDERS.find((b) => key.startsWith(b + "_"));
|
|
22106
22109
|
if (!base) return void 0;
|
|
22107
22110
|
const suffix = key.slice(base.length + 1);
|
|
22108
|
-
|
|
22109
|
-
|
|
22111
|
+
const m = suffix.match(/^(\d+)_(\d+)$/);
|
|
22112
|
+
if (!m) return void 0;
|
|
22113
|
+
return { lender: base, chainId: m[1], collIndex: Number(m[2]) };
|
|
22110
22114
|
}
|
|
22111
22115
|
var WAD6 = 1e18;
|
|
22112
22116
|
function toHuman2(raw, decimals) {
|
|
@@ -22133,7 +22137,7 @@ function convertLiquityMarketsToResponse(raw, chainId, prices = {}, _additionalY
|
|
|
22133
22137
|
const spYieldSplit = cfg.spYieldSplit ? Number(cfg.spYieldSplit) / WAD6 : 0.75;
|
|
22134
22138
|
for (const b of raw.branches ?? []) {
|
|
22135
22139
|
const branch = b.branch;
|
|
22136
|
-
const lenderKey = liquityLenderKey(raw.lender, branch.collIndex);
|
|
22140
|
+
const lenderKey = liquityLenderKey(raw.lender, chainId, branch.collIndex);
|
|
22137
22141
|
const collAddr = branch.collToken.toLowerCase();
|
|
22138
22142
|
const collDecimals = branch.collDecimals;
|
|
22139
22143
|
const collToken = tokens[collAddr];
|
|
@@ -22368,14 +22372,15 @@ async function fetchRiverMarkets(lender, chainId) {
|
|
|
22368
22372
|
}
|
|
22369
22373
|
|
|
22370
22374
|
// src/lending/public-data/river/convertPublic.ts
|
|
22371
|
-
function riverLenderKey(lender, index) {
|
|
22372
|
-
return `${lender}_${index}`;
|
|
22375
|
+
function riverLenderKey(lender, chainId, index) {
|
|
22376
|
+
return `${lender}_${chainId}_${index}`;
|
|
22373
22377
|
}
|
|
22374
22378
|
function riverKeyParts(key) {
|
|
22375
22379
|
if (!key.startsWith("RIVER_")) return void 0;
|
|
22376
22380
|
const suffix = key.slice("RIVER_".length);
|
|
22377
|
-
|
|
22378
|
-
|
|
22381
|
+
const m = suffix.match(/^(\d+)_(\d+)$/);
|
|
22382
|
+
if (!m) return void 0;
|
|
22383
|
+
return { lender: "RIVER", chainId: m[1], index: Number(m[2]) };
|
|
22379
22384
|
}
|
|
22380
22385
|
var WAD7 = 1e18;
|
|
22381
22386
|
function toHuman3(raw, decimals) {
|
|
@@ -22403,7 +22408,7 @@ function convertRiverMarketsToResponse(raw, chainId, prices = {}, _additionalYie
|
|
|
22403
22408
|
const spDeposits = raw.spDeposits !== null ? toHuman3(raw.spDeposits, debtDecimals) : 0;
|
|
22404
22409
|
for (const m of raw.markets ?? []) {
|
|
22405
22410
|
const market = m.market;
|
|
22406
|
-
const lenderKey = riverLenderKey(raw.lender, market.index);
|
|
22411
|
+
const lenderKey = riverLenderKey(raw.lender, chainId, market.index);
|
|
22407
22412
|
const collAddr = market.collToken.toLowerCase();
|
|
22408
22413
|
const collDecimals = market.collDecimals;
|
|
22409
22414
|
const collToken = tokens[collAddr];
|
|
@@ -26908,13 +26913,19 @@ var getExactlyUserDataConverter = (_lender, chainId, account, meta) => {
|
|
|
26908
26913
|
const loanDisplayPrice = loanMeta ? getDisplayPrice(loanMeta) : 0;
|
|
26909
26914
|
const loanOraclePrice = loanMeta ? getOraclePrice(loanMeta) : 0;
|
|
26910
26915
|
const loanPriceHist = loanMeta?.price?.priceUsd24h ?? loanDisplayPrice;
|
|
26916
|
+
const fixedDebtUnits = sumPreview(m.fixedBorrowPositions);
|
|
26911
26917
|
const depositUnits = m.floatingDepositAssets + sumPreview(m.fixedDepositPositions);
|
|
26912
|
-
const debtUnits = m.floatingBorrowAssets +
|
|
26918
|
+
const debtUnits = m.floatingBorrowAssets + fixedDebtUnits;
|
|
26913
26919
|
if (depositUnits === 0n && debtUnits === 0n) continue;
|
|
26914
26920
|
const depositsStr = parseRawAmount(depositUnits.toString(), decimals);
|
|
26915
26921
|
const depositsNum = Number(depositsStr);
|
|
26916
26922
|
const debtStr = parseRawAmount(debtUnits.toString(), decimals);
|
|
26917
26923
|
const debtNum = Number(debtStr);
|
|
26924
|
+
const floatingDebtStr = parseRawAmount(
|
|
26925
|
+
m.floatingBorrowAssets.toString(),
|
|
26926
|
+
decimals
|
|
26927
|
+
);
|
|
26928
|
+
const fixedDebtStr = parseRawAmount(fixedDebtUnits.toString(), decimals);
|
|
26918
26929
|
const fixedPositions = [
|
|
26919
26930
|
...toDetail(m.fixedDepositPositions, "deposit", now),
|
|
26920
26931
|
...toDetail(m.fixedBorrowPositions, "borrow", now)
|
|
@@ -26925,14 +26936,14 @@ var getExactlyUserDataConverter = (_lender, chainId, account, meta) => {
|
|
|
26925
26936
|
marketUid: loanUid,
|
|
26926
26937
|
underlying: assetAddr,
|
|
26927
26938
|
deposits: depositsStr,
|
|
26928
|
-
debt:
|
|
26929
|
-
debtStable:
|
|
26939
|
+
debt: floatingDebtStr,
|
|
26940
|
+
debtStable: fixedDebtStr,
|
|
26930
26941
|
depositsUSD: depositsNum * loanDisplayPrice,
|
|
26931
|
-
debtUSD:
|
|
26932
|
-
debtStableUSD:
|
|
26942
|
+
debtUSD: Number(floatingDebtStr) * loanDisplayPrice,
|
|
26943
|
+
debtStableUSD: Number(fixedDebtStr) * loanDisplayPrice,
|
|
26933
26944
|
depositsUSDOracle: depositsNum * loanOraclePrice,
|
|
26934
|
-
debtUSDOracle:
|
|
26935
|
-
debtStableUSDOracle:
|
|
26945
|
+
debtUSDOracle: Number(floatingDebtStr) * loanOraclePrice,
|
|
26946
|
+
debtStableUSDOracle: Number(fixedDebtStr) * loanOraclePrice,
|
|
26936
26947
|
stableBorrowRate: "0",
|
|
26937
26948
|
collateralEnabled: m.isCollateral,
|
|
26938
26949
|
claimableRewards: 0,
|
|
@@ -26940,6 +26951,38 @@ var getExactlyUserDataConverter = (_lender, chainId, account, meta) => {
|
|
|
26940
26951
|
// multi-account state builder mutates posData in place).
|
|
26941
26952
|
fixedPositions: fixedPositions.length > 0 ? fixedPositions : void 0
|
|
26942
26953
|
};
|
|
26954
|
+
for (const p of m.fixedBorrowPositions) {
|
|
26955
|
+
const maturity = Number(p.maturity);
|
|
26956
|
+
const trancheStr = parseRawAmount(p.previewValue.toString(), decimals);
|
|
26957
|
+
posData[`${loanUid}#${maturity}`] = {
|
|
26958
|
+
marketUid: loanUid,
|
|
26959
|
+
underlying: assetAddr,
|
|
26960
|
+
loanId: String(maturity),
|
|
26961
|
+
deposits: "0",
|
|
26962
|
+
debt: "0",
|
|
26963
|
+
debtStable: trancheStr,
|
|
26964
|
+
depositsUSD: 0,
|
|
26965
|
+
debtUSD: 0,
|
|
26966
|
+
debtStableUSD: Number(trancheStr) * loanDisplayPrice,
|
|
26967
|
+
depositsUSDOracle: 0,
|
|
26968
|
+
debtUSDOracle: 0,
|
|
26969
|
+
debtStableUSDOracle: Number(trancheStr) * loanOraclePrice,
|
|
26970
|
+
collateralEnabled: false,
|
|
26971
|
+
claimableRewards: 0,
|
|
26972
|
+
term: {
|
|
26973
|
+
loanId: String(maturity),
|
|
26974
|
+
termId: maturity,
|
|
26975
|
+
isDynamic: false,
|
|
26976
|
+
debt: trancheStr,
|
|
26977
|
+
maturity,
|
|
26978
|
+
accruedInterest: parseRawAmount(
|
|
26979
|
+
p.position.fee.toString(),
|
|
26980
|
+
decimals
|
|
26981
|
+
),
|
|
26982
|
+
isMatured: maturity < now
|
|
26983
|
+
}
|
|
26984
|
+
};
|
|
26985
|
+
}
|
|
26943
26986
|
if (debtUnits > 0n) {
|
|
26944
26987
|
for (const c of markets) {
|
|
26945
26988
|
if (c.market.toLowerCase() === m.market.toLowerCase()) continue;
|
|
@@ -27027,7 +27070,7 @@ var getLiquityUserDataConverter = (lender, chainId, account, meta) => {
|
|
|
27027
27070
|
const callCount = liquityBranchCallCount(branch, troves.length);
|
|
27028
27071
|
const slice = data.slice(cursor, cursor + callCount);
|
|
27029
27072
|
cursor += callCount;
|
|
27030
|
-
const lenderKey = liquityLenderKey(lender, branch.collIndex);
|
|
27073
|
+
const lenderKey = liquityLenderKey(lender, chainId, branch.collIndex);
|
|
27031
27074
|
const metaMap = meta?.[lenderKey];
|
|
27032
27075
|
if (!metaMap) return;
|
|
27033
27076
|
const collAddr = branch.collToken.toLowerCase();
|
|
@@ -27234,7 +27277,7 @@ var getRiverUserDataConverter = (lender, chainId, account, meta) => {
|
|
|
27234
27277
|
const entire = data[base];
|
|
27235
27278
|
const status = Number(big2(data[base + 1]));
|
|
27236
27279
|
const surplus = big2(data[base + 2]);
|
|
27237
|
-
const lenderKey = riverLenderKey(lender, market.index);
|
|
27280
|
+
const lenderKey = riverLenderKey(lender, chainId, market.index);
|
|
27238
27281
|
const metaMap = meta?.[lenderKey];
|
|
27239
27282
|
if (!metaMap) return;
|
|
27240
27283
|
const collAddr = market.collToken.toLowerCase();
|