@1delta/margin-fetcher 0.0.278 → 0.0.279
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/README.md +104 -0
- package/dist/abis/compound-v2/Comptroller.d.ts +20 -0
- package/dist/abis/compound-v2/Comptroller.d.ts.map +1 -1
- package/dist/ccip-VFYF2C5F.js +5 -0
- package/dist/{ccip-XQNAHYUN.js.map → ccip-VFYF2C5F.js.map} +1 -1
- package/dist/{chunk-H6U3H7VY.js → chunk-Z3MGRQJR.js} +11 -6
- package/dist/chunk-Z3MGRQJR.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +948 -75
- package/dist/index.js.map +1 -1
- package/dist/lending/public-data/aave-v2-type/publicCallParse.d.ts.map +1 -1
- package/dist/lending/public-data/aave-v3-type/publicCallParse.d.ts.map +1 -1
- package/dist/lending/public-data/aave-v4-type/fetcher/normalize.d.ts +16 -0
- package/dist/lending/public-data/aave-v4-type/fetcher/normalize.d.ts.map +1 -1
- package/dist/lending/public-data/compound-v2/convert/benqi.d.ts +3 -0
- package/dist/lending/public-data/compound-v2/convert/benqi.d.ts.map +1 -1
- package/dist/lending/public-data/compound-v2/convert/kinetic.d.ts +3 -0
- package/dist/lending/public-data/compound-v2/convert/kinetic.d.ts.map +1 -1
- package/dist/lending/public-data/compound-v2/convert/risk.d.ts +3 -0
- package/dist/lending/public-data/compound-v2/convert/risk.d.ts.map +1 -0
- package/dist/lending/public-data/compound-v2/convert/standard.d.ts +5 -0
- package/dist/lending/public-data/compound-v2/convert/standard.d.ts.map +1 -1
- package/dist/lending/public-data/compound-v2/convert/sumer.d.ts +1 -0
- package/dist/lending/public-data/compound-v2/convert/sumer.d.ts.map +1 -1
- package/dist/lending/public-data/compound-v2/convert/takara.d.ts +3 -0
- package/dist/lending/public-data/compound-v2/convert/takara.d.ts.map +1 -1
- package/dist/lending/public-data/compound-v2/convert/tectonic.d.ts +3 -0
- package/dist/lending/public-data/compound-v2/convert/tectonic.d.ts.map +1 -1
- package/dist/lending/public-data/compound-v2/publicCallBuild.d.ts.map +1 -1
- package/dist/lending/public-data/compound-v2/publicCallParse.d.ts.map +1 -1
- package/dist/lending/public-data/compound-v3/publicCallBuild.d.ts.map +1 -1
- package/dist/lending/public-data/compound-v3/publicCallParse.d.ts.map +1 -1
- package/dist/lending/public-data/dolomite/emodeConfig.d.ts +2 -0
- package/dist/lending/public-data/dolomite/emodeConfig.d.ts.map +1 -1
- package/dist/lending/public-data/dolomite/fetchFromSubgraph.d.ts.map +1 -1
- package/dist/lending/public-data/dolomite/publicCallParse.d.ts.map +1 -1
- package/dist/lending/public-data/euler/fetcher/normalize.d.ts +7 -0
- package/dist/lending/public-data/euler/fetcher/normalize.d.ts.map +1 -1
- package/dist/lending/public-data/euler/publicCallParse.d.ts.map +1 -1
- package/dist/lending/public-data/gearbox/publicCallParse.d.ts.map +1 -1
- package/dist/lending/public-data/init/publicCallParse.d.ts.map +1 -1
- package/dist/lending/public-data/lista/getMarketsFromChain.d.ts.map +1 -1
- package/dist/lending/public-data/lista/listaBroker.d.ts +65 -0
- package/dist/lending/public-data/lista/listaBroker.d.ts.map +1 -0
- package/dist/lending/public-data/lista/publicCallBuild.d.ts.map +1 -1
- package/dist/lending/public-data/morpho/convertPublic.d.ts.map +1 -1
- package/dist/lending/public-data/morpho/getMarketsFromChain.d.ts.map +1 -1
- package/dist/lending/public-data/morpho/utils/parsers.d.ts +8 -0
- package/dist/lending/public-data/morpho/utils/parsers.d.ts.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/dist/lending/user-data/morpho/userCallBuild.d.ts +2 -2
- package/dist/lending/user-data/morpho/userCallBuild.d.ts.map +1 -1
- package/dist/lending/user-data/morpho/userCallParse.d.ts +10 -1
- package/dist/lending/user-data/morpho/userCallParse.d.ts.map +1 -1
- package/dist/lending/user-data/utils/types.d.ts +10 -0
- package/dist/lending/user-data/utils/types.d.ts.map +1 -1
- package/dist/types/apiReturnType.d.ts +38 -0
- package/dist/types/apiReturnType.d.ts.map +1 -1
- package/dist/types/lender/morpho-types.d.ts +17 -2
- package/dist/types/lender/morpho-types.d.ts.map +1 -1
- package/dist/types/lenderTypes.d.ts +66 -0
- package/dist/types/lenderTypes.d.ts.map +1 -1
- package/dist/vaults/lst/celoValidatorGroups.d.ts +40 -0
- package/dist/vaults/lst/celoValidatorGroups.d.ts.map +1 -0
- package/dist/vaults/lst/fetchPublic.d.ts +7 -1
- package/dist/vaults/lst/fetchPublic.d.ts.map +1 -1
- package/dist/vaults/lst/index.d.ts +2 -0
- package/dist/vaults/lst/index.d.ts.map +1 -1
- package/dist/vaults/lst/types.d.ts +12 -0
- package/dist/vaults/lst/types.d.ts.map +1 -1
- package/dist/vaults/lst/validators.d.ts +65 -0
- package/dist/vaults/lst/validators.d.ts.map +1 -0
- package/package.json +5 -5
- package/dist/ccip-XQNAHYUN.js +0 -5
- package/dist/chunk-H6U3H7VY.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { parseAbi, keccak256, encodeAbiParameters, formatEther, BaseError, encodeFunctionData, formatUnits, decodeFunctionResult, decodeAbiParameters, AbiEncodingLengthMismatchError, concatHex, pad,
|
|
1
|
+
import { parseAbi, keccak256, encodeAbiParameters, formatEther, BaseError, encodeFunctionData, formatUnits, isAddress, getAddress, decodeFunctionResult, decodeAbiParameters, AbiEncodingLengthMismatchError, concatHex, pad, InvalidAddressError, stringToHex, boolToHex, integerRegex, numberToHex, bytesRegex, BytesSizeMismatchError, arrayRegex, UnsupportedPackedAbiType } from './chunk-Z3MGRQJR.js';
|
|
2
2
|
import './chunk-BYTNVMX7.js';
|
|
3
3
|
import './chunk-PR4QN5HX.js';
|
|
4
4
|
import { Lender, isAaveType, isCompoundV3, isMultiMarket, isSiloV2Type, isSiloV3Type, isDolomite, isAaveV4Type, isInit, isMorphoType, isCompoundV2Type, isVenusType, isSumerType, AAVE_V3_LENDERS, AAVE_V2_LENDERS, isAaveV2Type, isAaveV32Type, isAaveV3Type, isEulerType, isFluid, isGearboxV3, isYLDR, isCompoundV3Type, isLista, isTectonicType, isKineticType, isBenqiType } from '@1delta/lender-registry';
|
|
@@ -8057,6 +8057,11 @@ var buildCompoundV3StyleLenderReserveCall = (chainId, lender) => {
|
|
|
8057
8057
|
name: "getCometInterest",
|
|
8058
8058
|
params: [cometContractAddress]
|
|
8059
8059
|
};
|
|
8060
|
+
const callStoreFrontPriceFactor = {
|
|
8061
|
+
address: cometContractAddress,
|
|
8062
|
+
name: "storeFrontPriceFactor",
|
|
8063
|
+
params: []
|
|
8064
|
+
};
|
|
8060
8065
|
const calls = [
|
|
8061
8066
|
...callsAssetInfoAndTotals,
|
|
8062
8067
|
callSupplyRewards,
|
|
@@ -8066,7 +8071,8 @@ var buildCompoundV3StyleLenderReserveCall = (chainId, lender) => {
|
|
|
8066
8071
|
callSupply,
|
|
8067
8072
|
callBorrow,
|
|
8068
8073
|
// supply / borrow
|
|
8069
|
-
callInterest
|
|
8074
|
+
callInterest,
|
|
8075
|
+
callStoreFrontPriceFactor
|
|
8070
8076
|
];
|
|
8071
8077
|
return calls;
|
|
8072
8078
|
};
|
|
@@ -8359,10 +8365,18 @@ var getAaveV2ReservesDataConverter = (lender, chainId, prices, additionalYields,
|
|
|
8359
8365
|
configData?.[2 /* liquidationThreshold */].toString()
|
|
8360
8366
|
) / BPS,
|
|
8361
8367
|
borrowFactor: 1,
|
|
8368
|
+
liquidationPenalty: (() => {
|
|
8369
|
+
const lb = Number(
|
|
8370
|
+
configData?.[3 /* liquidationBonus */].toString()
|
|
8371
|
+
);
|
|
8372
|
+
return Number.isFinite(lb) && lb > 0 ? lb / BPS - 1 : 0;
|
|
8373
|
+
})(),
|
|
8374
|
+
closeFactor: 0.5,
|
|
8362
8375
|
collateralDisabled: !collateralActive,
|
|
8363
8376
|
debtDisabled: !borrowingEnabled
|
|
8364
8377
|
}
|
|
8365
8378
|
},
|
|
8379
|
+
closeFactor: 0.5,
|
|
8366
8380
|
liquidationBonus: Number(
|
|
8367
8381
|
configData?.[3 /* liquidationBonus */].toString()
|
|
8368
8382
|
) / BPS,
|
|
@@ -8443,7 +8457,8 @@ var getAaveV3ReservesDataConverter = (lender, chainId, prices, additionalYields,
|
|
|
8443
8457
|
label: rawCfg.label,
|
|
8444
8458
|
borrowCollateralFactor: rawCfg.ltv / BPS,
|
|
8445
8459
|
collateralFactor: rawCfg.liquidationThreshold / BPS,
|
|
8446
|
-
borrowFactor: 1
|
|
8460
|
+
borrowFactor: 1,
|
|
8461
|
+
liquidationBonus: rawCfg.liquidationBonus
|
|
8447
8462
|
};
|
|
8448
8463
|
}
|
|
8449
8464
|
});
|
|
@@ -8517,11 +8532,15 @@ var getAaveV3ReservesDataConverter = (lender, chainId, prices, additionalYields,
|
|
|
8517
8532
|
rewards: []
|
|
8518
8533
|
};
|
|
8519
8534
|
const eModeCategory = Number(reserveEMode?.toString());
|
|
8535
|
+
const baseLiquidationBonus = Number(
|
|
8536
|
+
configData?.[3 /* liquidationBonus */]?.toString()
|
|
8537
|
+
);
|
|
8520
8538
|
resultReserves[marketUid] = {
|
|
8521
8539
|
...resultReserves[marketUid],
|
|
8522
8540
|
decimals: Number(
|
|
8523
8541
|
configData?.[0 /* decimals */]
|
|
8524
8542
|
),
|
|
8543
|
+
closeFactor: 0.5,
|
|
8525
8544
|
config: populateEModes(
|
|
8526
8545
|
Number(configData?.[1 /* ltv */]) / BPS,
|
|
8527
8546
|
Number(
|
|
@@ -8531,7 +8550,8 @@ var getAaveV3ReservesDataConverter = (lender, chainId, prices, additionalYields,
|
|
|
8531
8550
|
eModeConfigs,
|
|
8532
8551
|
allModes,
|
|
8533
8552
|
usageAsCollateralEnabled,
|
|
8534
|
-
borrowingEnabled
|
|
8553
|
+
borrowingEnabled,
|
|
8554
|
+
baseLiquidationBonus
|
|
8535
8555
|
),
|
|
8536
8556
|
// flags
|
|
8537
8557
|
collateralActive: usageAsCollateralEnabled,
|
|
@@ -8584,7 +8604,9 @@ var getAaveV3ReservesDataConverter = (lender, chainId, prices, additionalYields,
|
|
|
8584
8604
|
}
|
|
8585
8605
|
}
|
|
8586
8606
|
};
|
|
8587
|
-
var
|
|
8607
|
+
var toLiquidationPenalty = (liquidationBonus) => Number.isFinite(liquidationBonus) && liquidationBonus > 0 ? liquidationBonus / BPS - 1 : 0;
|
|
8608
|
+
var populateEModes = (borrowCollateralFactor, collateralFactor, eModeCategory, eModeConfigs, allModes, usageAsCollateralEnabled, borrowingEnabled, baseLiquidationBonus) => {
|
|
8609
|
+
const basePenalty = toLiquidationPenalty(baseLiquidationBonus);
|
|
8588
8610
|
let data = {};
|
|
8589
8611
|
allModes.forEach((e) => {
|
|
8590
8612
|
if (e === 0)
|
|
@@ -8594,6 +8616,8 @@ var populateEModes = (borrowCollateralFactor, collateralFactor, eModeCategory, e
|
|
|
8594
8616
|
borrowCollateralFactor,
|
|
8595
8617
|
collateralFactor,
|
|
8596
8618
|
borrowFactor: 1,
|
|
8619
|
+
liquidationPenalty: basePenalty,
|
|
8620
|
+
closeFactor: 0.5,
|
|
8597
8621
|
collateralDisabled: !usageAsCollateralEnabled,
|
|
8598
8622
|
debtDisabled: !borrowingEnabled
|
|
8599
8623
|
};
|
|
@@ -8605,6 +8629,10 @@ var populateEModes = (borrowCollateralFactor, collateralFactor, eModeCategory, e
|
|
|
8605
8629
|
borrowCollateralFactor: eModeConfigs[e]?.borrowCollateralFactor ?? 0,
|
|
8606
8630
|
collateralFactor: eModeConfigs[e]?.collateralFactor ?? 0,
|
|
8607
8631
|
borrowFactor: 1,
|
|
8632
|
+
liquidationPenalty: toLiquidationPenalty(
|
|
8633
|
+
eModeConfigs[e]?.liquidationBonus
|
|
8634
|
+
),
|
|
8635
|
+
closeFactor: 0.5,
|
|
8608
8636
|
collateralDisabled: !usageAsCollateralEnabled,
|
|
8609
8637
|
debtDisabled: !borrowingEnabled
|
|
8610
8638
|
};
|
|
@@ -8615,6 +8643,8 @@ var populateEModes = (borrowCollateralFactor, collateralFactor, eModeCategory, e
|
|
|
8615
8643
|
borrowCollateralFactor,
|
|
8616
8644
|
collateralFactor,
|
|
8617
8645
|
borrowFactor: 1,
|
|
8646
|
+
liquidationPenalty: basePenalty,
|
|
8647
|
+
closeFactor: 0.5,
|
|
8618
8648
|
collateralDisabled: false,
|
|
8619
8649
|
debtDisabled: true
|
|
8620
8650
|
};
|
|
@@ -8623,7 +8653,8 @@ var populateEModes = (borrowCollateralFactor, collateralFactor, eModeCategory, e
|
|
|
8623
8653
|
});
|
|
8624
8654
|
return data;
|
|
8625
8655
|
};
|
|
8626
|
-
var populateEModes32 = (borrowCollateralFactor, collateralFactor, collateralBitmap, debtBitmap, assetIndex, eModeConfigs, allModes, usageAsCollateralEnabled, borrowingEnabled) => {
|
|
8656
|
+
var populateEModes32 = (borrowCollateralFactor, collateralFactor, collateralBitmap, debtBitmap, assetIndex, eModeConfigs, allModes, usageAsCollateralEnabled, borrowingEnabled, baseLiquidationBonus) => {
|
|
8657
|
+
const basePenalty = toLiquidationPenalty(baseLiquidationBonus);
|
|
8627
8658
|
let data = {};
|
|
8628
8659
|
allModes.forEach((e) => {
|
|
8629
8660
|
if (e === 0)
|
|
@@ -8633,6 +8664,8 @@ var populateEModes32 = (borrowCollateralFactor, collateralFactor, collateralBitm
|
|
|
8633
8664
|
borrowCollateralFactor,
|
|
8634
8665
|
collateralFactor,
|
|
8635
8666
|
borrowFactor: 1,
|
|
8667
|
+
liquidationPenalty: basePenalty,
|
|
8668
|
+
closeFactor: 0.5,
|
|
8636
8669
|
collateralDisabled: !usageAsCollateralEnabled,
|
|
8637
8670
|
debtDisabled: !borrowingEnabled
|
|
8638
8671
|
};
|
|
@@ -8645,12 +8678,18 @@ var populateEModes32 = (borrowCollateralFactor, collateralFactor, collateralBitm
|
|
|
8645
8678
|
data[e].borrowFactor = 1;
|
|
8646
8679
|
data[e].collateralFactor = collateralFactor;
|
|
8647
8680
|
data[e].borrowCollateralFactor = borrowCollateralFactor;
|
|
8681
|
+
data[e].liquidationPenalty = basePenalty;
|
|
8682
|
+
data[e].closeFactor = 0.5;
|
|
8648
8683
|
data[e].debtDisabled = !!eModeConfigs[e];
|
|
8649
8684
|
if (eModeConfigs[e]) {
|
|
8650
8685
|
data[e].category = e;
|
|
8651
8686
|
data[e].borrowCollateralFactor = eModeConfigs[e]?.borrowCollateralFactor ?? 0;
|
|
8652
8687
|
data[e].collateralFactor = eModeConfigs[e]?.collateralFactor ?? 0;
|
|
8653
8688
|
data[e].borrowFactor = 1;
|
|
8689
|
+
data[e].liquidationPenalty = toLiquidationPenalty(
|
|
8690
|
+
eModeConfigs[e]?.liquidationBonus
|
|
8691
|
+
);
|
|
8692
|
+
data[e].closeFactor = 0.5;
|
|
8654
8693
|
data[e].collateralDisabled = !isReserveEnabledOnBitmap(
|
|
8655
8694
|
collateralBitmap[e],
|
|
8656
8695
|
assetIndex
|
|
@@ -8752,10 +8791,17 @@ function parseYLDRCall(chainId, lender, additionalYields, prices, tokenList) {
|
|
|
8752
8791
|
configData?.[2 /* liquidationThreshold */]?.toString()
|
|
8753
8792
|
) / BPS,
|
|
8754
8793
|
borrowFactor: 1,
|
|
8794
|
+
liquidationPenalty: toLiquidationPenalty(
|
|
8795
|
+
Number(
|
|
8796
|
+
configData?.[3 /* liquidationBonus */]?.toString()
|
|
8797
|
+
)
|
|
8798
|
+
),
|
|
8799
|
+
closeFactor: 0.5,
|
|
8755
8800
|
collateralDisabled: !usageAsCollateralEnabled,
|
|
8756
8801
|
debtDisabled: !borrowingEnabled
|
|
8757
8802
|
}
|
|
8758
8803
|
},
|
|
8804
|
+
closeFactor: 0.5,
|
|
8759
8805
|
liquidationBonus: Number(
|
|
8760
8806
|
configData?.[3 /* liquidationBonus */]?.toString()
|
|
8761
8807
|
) / BPS,
|
|
@@ -8818,7 +8864,8 @@ function parseAave32(chainId, lender, prices, additionalYields, tokenList) {
|
|
|
8818
8864
|
label: rawCfg.label,
|
|
8819
8865
|
borrowCollateralFactor: rawCfg.ltv / BPS,
|
|
8820
8866
|
collateralFactor: rawCfg.liquidationThreshold / BPS,
|
|
8821
|
-
borrowFactor: 1
|
|
8867
|
+
borrowFactor: 1,
|
|
8868
|
+
liquidationBonus: rawCfg.liquidationBonus
|
|
8822
8869
|
};
|
|
8823
8870
|
debtBitmap[mode] = emodeDataResult[3 * index + 1];
|
|
8824
8871
|
collateralBitmap[mode] = emodeDataResult[3 * index + 2];
|
|
@@ -8896,11 +8943,15 @@ function parseAave32(chainId, lender, prices, additionalYields, tokenList) {
|
|
|
8896
8943
|
const assetIndex = lowerReservesList.indexOf(asset);
|
|
8897
8944
|
const usageAsCollateralEnabled = configData?.[5 /* usageAsCollateralEnabled */];
|
|
8898
8945
|
const borrowingEnabled = configData?.[6 /* borrowingEnabled */];
|
|
8946
|
+
const baseLiquidationBonus = Number(
|
|
8947
|
+
configData?.[3 /* liquidationBonus */]?.toString()
|
|
8948
|
+
);
|
|
8899
8949
|
resultReserves[marketUid] = {
|
|
8900
8950
|
...resultReserves[marketUid],
|
|
8901
8951
|
decimals: Number(
|
|
8902
8952
|
configData?.[0 /* decimals */]
|
|
8903
8953
|
),
|
|
8954
|
+
closeFactor: 0.5,
|
|
8904
8955
|
config: populateEModes32(
|
|
8905
8956
|
Number(configData?.[1 /* ltv */]) / BPS,
|
|
8906
8957
|
Number(
|
|
@@ -8912,7 +8963,8 @@ function parseAave32(chainId, lender, prices, additionalYields, tokenList) {
|
|
|
8912
8963
|
eModeConfigs,
|
|
8913
8964
|
allModes,
|
|
8914
8965
|
usageAsCollateralEnabled,
|
|
8915
|
-
borrowingEnabled
|
|
8966
|
+
borrowingEnabled,
|
|
8967
|
+
baseLiquidationBonus
|
|
8916
8968
|
),
|
|
8917
8969
|
// flags
|
|
8918
8970
|
collateralActive: usageAsCollateralEnabled,
|
|
@@ -8968,6 +9020,7 @@ function parseAave32(chainId, lender, prices, additionalYields, tokenList) {
|
|
|
8968
9020
|
var INIT_POOL_NAME_OVERRIDES = {
|
|
8969
9021
|
"0x592c91ac727da556dc90ddf5630e1901efcd0c92": "Init FBTC Isolated"
|
|
8970
9022
|
};
|
|
9023
|
+
var INIT_DEFAULT_LIQUIDATION_PENALTY = 0.05;
|
|
8971
9024
|
var INIT_EMODE_LABELS = {
|
|
8972
9025
|
[1]: "Default",
|
|
8973
9026
|
[2]: "Blue Chip Volatile",
|
|
@@ -9041,6 +9094,7 @@ var getInitReservesDataConverter = (lender, chainId, prices, additionalYields, t
|
|
|
9041
9094
|
intrinsicYield: additionalYields?.intrinsicYields?.[oracleKey] ?? 0,
|
|
9042
9095
|
rewards: [],
|
|
9043
9096
|
config: {},
|
|
9097
|
+
closeFactor: 1,
|
|
9044
9098
|
borrowingEnabled: totalDebt !== "0",
|
|
9045
9099
|
depositsEnabled: true,
|
|
9046
9100
|
params
|
|
@@ -9063,7 +9117,9 @@ var getInitReservesDataConverter = (lender, chainId, prices, additionalYields, t
|
|
|
9063
9117
|
parseRawAmount(multicallData.maxHealthAfterLiq, 18)
|
|
9064
9118
|
),
|
|
9065
9119
|
debtDisabled: false,
|
|
9066
|
-
collateralDisabled: false
|
|
9120
|
+
collateralDisabled: false,
|
|
9121
|
+
liquidationPenalty: INIT_DEFAULT_LIQUIDATION_PENALTY,
|
|
9122
|
+
closeFactor: 1
|
|
9067
9123
|
};
|
|
9068
9124
|
if (!eModes[mode]) eModes[mode] = modeData;
|
|
9069
9125
|
result[asset].config[mode] = modeData;
|
|
@@ -9079,8 +9135,10 @@ var getInitReservesDataConverter = (lender, chainId, prices, additionalYields, t
|
|
|
9079
9135
|
collateralDisabled: true,
|
|
9080
9136
|
collateralFactor: 0,
|
|
9081
9137
|
borrowCollateralFactor: 0,
|
|
9082
|
-
borrowFactor: 3402823669209385e5
|
|
9138
|
+
borrowFactor: 3402823669209385e5,
|
|
9083
9139
|
// disabled flag
|
|
9140
|
+
liquidationPenalty: 0,
|
|
9141
|
+
closeFactor: 1
|
|
9084
9142
|
};
|
|
9085
9143
|
}
|
|
9086
9144
|
});
|
|
@@ -9112,12 +9170,14 @@ var getCompoundV3ReservesDataConverter = (lender, chainId, prices, additionalYie
|
|
|
9112
9170
|
(a) => a !== baseAssetData.baseAsset
|
|
9113
9171
|
);
|
|
9114
9172
|
const baseLength = tokensNoBase.length * 2;
|
|
9115
|
-
const expectedNumberOfCalls = baseLength +
|
|
9173
|
+
const expectedNumberOfCalls = baseLength + 7;
|
|
9116
9174
|
return [
|
|
9117
9175
|
(data) => {
|
|
9118
9176
|
if (data.length !== expectedNumberOfCalls) {
|
|
9119
9177
|
return void 0;
|
|
9120
9178
|
}
|
|
9179
|
+
const rawStoreFront = data[baseLength + 6];
|
|
9180
|
+
const storeFrontPriceFactor = rawStoreFront === void 0 || rawStoreFront === "0x" ? 0 : Number(parseRawAmount(rawStoreFront.toString(), COMET_RISK_DECIMALS));
|
|
9121
9181
|
let result = {};
|
|
9122
9182
|
for (let i = 0; i < tokensNoBase.length; i++) {
|
|
9123
9183
|
const asset = tokensNoBase[i];
|
|
@@ -9129,6 +9189,16 @@ var getCompoundV3ReservesDataConverter = (lender, chainId, prices, additionalYie
|
|
|
9129
9189
|
const oracleKey = toOracleKey(assetMeta?.assetGroup) ?? toGenericPriceKey(asset, chainId);
|
|
9130
9190
|
const totalUsd = Number(totals) * (prices[oracleKey] ?? 0);
|
|
9131
9191
|
const marketUid = createMarketUid(chainId, lender, asset);
|
|
9192
|
+
const liquidationFactor = Number(
|
|
9193
|
+
parseRawAmount(
|
|
9194
|
+
resultsAssetInfo.liquidationFactor.toString(),
|
|
9195
|
+
COMET_RISK_DECIMALS
|
|
9196
|
+
)
|
|
9197
|
+
);
|
|
9198
|
+
const liquidationPenalty = Math.max(
|
|
9199
|
+
storeFrontPriceFactor * (1 - liquidationFactor),
|
|
9200
|
+
0
|
|
9201
|
+
);
|
|
9132
9202
|
result[asset] = {
|
|
9133
9203
|
marketUid,
|
|
9134
9204
|
name: "Collateral " + (assetMeta?.symbol ?? ""),
|
|
@@ -9148,10 +9218,14 @@ var getCompoundV3ReservesDataConverter = (lender, chainId, prices, additionalYie
|
|
|
9148
9218
|
COMET_RISK_DECIMALS
|
|
9149
9219
|
),
|
|
9150
9220
|
borrowFactor: 1,
|
|
9221
|
+
liquidationPenalty,
|
|
9222
|
+
closeFactor: 1,
|
|
9151
9223
|
collateralDisabled: false,
|
|
9152
9224
|
debtDisabled: true
|
|
9153
9225
|
}
|
|
9154
9226
|
},
|
|
9227
|
+
// Comet absorbs the entire account on liquidation → full close factor.
|
|
9228
|
+
closeFactor: 1,
|
|
9155
9229
|
supplyCap: parseRawAmount(
|
|
9156
9230
|
resultsAssetInfo.supplyCap.toString(),
|
|
9157
9231
|
decimals2
|
|
@@ -9224,11 +9298,16 @@ var getCompoundV3ReservesDataConverter = (lender, chainId, prices, additionalYie
|
|
|
9224
9298
|
borrowCollateralFactor: 0,
|
|
9225
9299
|
collateralFactor: 0,
|
|
9226
9300
|
borrowFactor: 1,
|
|
9301
|
+
// base asset is the borrowable, never seized as collateral
|
|
9302
|
+
liquidationPenalty: 0,
|
|
9303
|
+
closeFactor: 1,
|
|
9227
9304
|
// base asset: borrowable, no collateral
|
|
9228
9305
|
collateralDisabled: true,
|
|
9229
9306
|
debtDisabled: false
|
|
9230
9307
|
}
|
|
9231
9308
|
},
|
|
9309
|
+
// Comet absorbs the entire account on liquidation → full close factor.
|
|
9310
|
+
closeFactor: 1,
|
|
9232
9311
|
// interest rates
|
|
9233
9312
|
variableBorrowRate: Number(resultsInterest[0 /* borrowRate */]) / SECONDS_PER_YEAR / 10,
|
|
9234
9313
|
depositRate: Number(resultsInterest[1 /* supplyRate */]) / SECONDS_PER_YEAR / 10,
|
|
@@ -11098,6 +11177,237 @@ var YLDRProtocolDataProviderAbi = [
|
|
|
11098
11177
|
]
|
|
11099
11178
|
}
|
|
11100
11179
|
];
|
|
11180
|
+
var RATE_SCALE = 10n ** 27n;
|
|
11181
|
+
var SECONDS_PER_YEAR2 = 365n * 24n * 60n * 60n;
|
|
11182
|
+
var moolahBrokersAbi = parseAbi([
|
|
11183
|
+
"function brokers(bytes32 id) view returns (address)"
|
|
11184
|
+
]);
|
|
11185
|
+
var brokerAbi = parseAbi([
|
|
11186
|
+
"function getFixedTerms() view returns (uint256[3][])",
|
|
11187
|
+
"function userFixedPositions(address user) view returns (uint256[8][])",
|
|
11188
|
+
"function userDynamicPosition(address user) view returns (uint256[2])",
|
|
11189
|
+
"function getUserTotalDebt(address user) view returns (uint256)"
|
|
11190
|
+
]);
|
|
11191
|
+
var BROKER_CACHE = {};
|
|
11192
|
+
var FIXED_TERMS_CACHE = {};
|
|
11193
|
+
var BROKER_USER_CACHE = {};
|
|
11194
|
+
function toBytes32MarketId(key) {
|
|
11195
|
+
const raw = key.startsWith("LISTA_DAO_") ? "0x" + key.slice("LISTA_DAO_".length) : key;
|
|
11196
|
+
return raw.toLowerCase();
|
|
11197
|
+
}
|
|
11198
|
+
function ceilDiv(a, b) {
|
|
11199
|
+
if (b === 0n) return 0n;
|
|
11200
|
+
return (a + b - 1n) / b;
|
|
11201
|
+
}
|
|
11202
|
+
function aprFractionFromRaw(apr) {
|
|
11203
|
+
if (apr <= RATE_SCALE) return 0;
|
|
11204
|
+
return Number(apr - RATE_SCALE) / Number(RATE_SCALE);
|
|
11205
|
+
}
|
|
11206
|
+
function aprPerSecond(apr) {
|
|
11207
|
+
if (apr <= RATE_SCALE) return 0n;
|
|
11208
|
+
return ceilDiv(apr - RATE_SCALE, SECONDS_PER_YEAR2);
|
|
11209
|
+
}
|
|
11210
|
+
function accruedInterest(outstanding, apr, start, end, lastRepaidTime, interestRepaid, nowSecs) {
|
|
11211
|
+
const cap = nowSecs > end ? end : nowSecs;
|
|
11212
|
+
const from = lastRepaidTime > end ? end : lastRepaidTime;
|
|
11213
|
+
if (outstanding === 0n || cap <= from) return 0n;
|
|
11214
|
+
const timeElapsed = cap - from;
|
|
11215
|
+
const gross = ceilDiv(outstanding * aprPerSecond(apr) * timeElapsed, RATE_SCALE);
|
|
11216
|
+
return gross > interestRepaid ? gross - interestRepaid : 0n;
|
|
11217
|
+
}
|
|
11218
|
+
function earlyRepayPenalty(repayPrincipal, apr, end, nowSecs) {
|
|
11219
|
+
if (repayPrincipal === 0n || nowSecs >= end) return 0n;
|
|
11220
|
+
const timeLeft = end - nowSecs;
|
|
11221
|
+
const perRepay = ceilDiv(repayPrincipal * aprPerSecond(apr), RATE_SCALE);
|
|
11222
|
+
return ceilDiv(perRepay * timeLeft, 2n);
|
|
11223
|
+
}
|
|
11224
|
+
async function resolveListaBrokers(chainId, marketKeys) {
|
|
11225
|
+
const moolah = morphoPools()?.LISTA_DAO?.[chainId];
|
|
11226
|
+
const out = {};
|
|
11227
|
+
if (!moolah || marketKeys.length === 0) return out;
|
|
11228
|
+
const cache = BROKER_CACHE[chainId] ??= {};
|
|
11229
|
+
const missing = [];
|
|
11230
|
+
for (const key of marketKeys) {
|
|
11231
|
+
const id = toBytes32MarketId(key);
|
|
11232
|
+
if (cache[id] === void 0) missing.push(id);
|
|
11233
|
+
}
|
|
11234
|
+
if (missing.length > 0) {
|
|
11235
|
+
try {
|
|
11236
|
+
const client = getEvmClient(chainId);
|
|
11237
|
+
const results = await client.multicall({
|
|
11238
|
+
allowFailure: true,
|
|
11239
|
+
contracts: missing.map((id) => ({
|
|
11240
|
+
abi: moolahBrokersAbi,
|
|
11241
|
+
address: moolah,
|
|
11242
|
+
functionName: "brokers",
|
|
11243
|
+
args: [id]
|
|
11244
|
+
}))
|
|
11245
|
+
});
|
|
11246
|
+
results.forEach((r, i) => {
|
|
11247
|
+
const id = missing[i];
|
|
11248
|
+
const addr = r.status === "success" && r.result ? r.result : zeroAddress;
|
|
11249
|
+
cache[id] = addr.toLowerCase();
|
|
11250
|
+
});
|
|
11251
|
+
} catch {
|
|
11252
|
+
}
|
|
11253
|
+
}
|
|
11254
|
+
for (const key of marketKeys) {
|
|
11255
|
+
const id = toBytes32MarketId(key);
|
|
11256
|
+
const broker = cache[id];
|
|
11257
|
+
if (broker && broker !== zeroAddress) out[id] = broker;
|
|
11258
|
+
}
|
|
11259
|
+
return out;
|
|
11260
|
+
}
|
|
11261
|
+
async function fetchListaFixedTerms(chainId, marketKeys) {
|
|
11262
|
+
const brokers = await resolveListaBrokers(chainId, marketKeys);
|
|
11263
|
+
const ids = Object.keys(brokers);
|
|
11264
|
+
const out = {};
|
|
11265
|
+
if (ids.length === 0) return out;
|
|
11266
|
+
try {
|
|
11267
|
+
const client = getEvmClient(chainId);
|
|
11268
|
+
const results = await client.multicall({
|
|
11269
|
+
allowFailure: true,
|
|
11270
|
+
contracts: ids.map((id) => ({
|
|
11271
|
+
abi: brokerAbi,
|
|
11272
|
+
address: brokers[id],
|
|
11273
|
+
functionName: "getFixedTerms",
|
|
11274
|
+
args: []
|
|
11275
|
+
}))
|
|
11276
|
+
});
|
|
11277
|
+
const cache = FIXED_TERMS_CACHE[chainId] ??= {};
|
|
11278
|
+
results.forEach((r, i) => {
|
|
11279
|
+
const id = ids[i];
|
|
11280
|
+
if (r.status !== "success" || !r.result) return;
|
|
11281
|
+
const terms = r.result.map((t) => {
|
|
11282
|
+
const durationSecs = Number(t[1]);
|
|
11283
|
+
return {
|
|
11284
|
+
termId: Number(t[0]),
|
|
11285
|
+
durationSecs,
|
|
11286
|
+
durationDays: durationSecs / 86400,
|
|
11287
|
+
aprFraction: aprFractionFromRaw(t[2])
|
|
11288
|
+
};
|
|
11289
|
+
});
|
|
11290
|
+
out[id] = terms;
|
|
11291
|
+
cache[id] = terms;
|
|
11292
|
+
});
|
|
11293
|
+
} catch {
|
|
11294
|
+
}
|
|
11295
|
+
return out;
|
|
11296
|
+
}
|
|
11297
|
+
function getCachedListaFixedTerms(chainId, marketKey) {
|
|
11298
|
+
return FIXED_TERMS_CACHE[chainId]?.[toBytes32MarketId(marketKey)];
|
|
11299
|
+
}
|
|
11300
|
+
async function fetchListaBrokerUserData(chainId, account, marketKeys, nowSecs = Math.floor(Date.now() / 1e3)) {
|
|
11301
|
+
const brokers = await resolveListaBrokers(chainId, marketKeys);
|
|
11302
|
+
const ids = Object.keys(brokers);
|
|
11303
|
+
const out = {};
|
|
11304
|
+
const cacheKey2 = `${chainId}:${account.toLowerCase()}`;
|
|
11305
|
+
BROKER_USER_CACHE[cacheKey2] = out;
|
|
11306
|
+
if (ids.length === 0) return out;
|
|
11307
|
+
try {
|
|
11308
|
+
const client = getEvmClient(chainId);
|
|
11309
|
+
const contracts = ids.flatMap((id) => {
|
|
11310
|
+
const address = brokers[id];
|
|
11311
|
+
return [
|
|
11312
|
+
{
|
|
11313
|
+
abi: brokerAbi,
|
|
11314
|
+
address,
|
|
11315
|
+
functionName: "userFixedPositions",
|
|
11316
|
+
args: [account]
|
|
11317
|
+
},
|
|
11318
|
+
{
|
|
11319
|
+
abi: brokerAbi,
|
|
11320
|
+
address,
|
|
11321
|
+
functionName: "userDynamicPosition",
|
|
11322
|
+
args: [account]
|
|
11323
|
+
},
|
|
11324
|
+
{
|
|
11325
|
+
abi: brokerAbi,
|
|
11326
|
+
address,
|
|
11327
|
+
functionName: "getUserTotalDebt",
|
|
11328
|
+
args: [account]
|
|
11329
|
+
},
|
|
11330
|
+
{
|
|
11331
|
+
abi: brokerAbi,
|
|
11332
|
+
address,
|
|
11333
|
+
functionName: "getFixedTerms",
|
|
11334
|
+
args: []
|
|
11335
|
+
}
|
|
11336
|
+
];
|
|
11337
|
+
});
|
|
11338
|
+
const results = await client.multicall({ allowFailure: true, contracts });
|
|
11339
|
+
const now = BigInt(nowSecs);
|
|
11340
|
+
ids.forEach((id, marketIdx) => {
|
|
11341
|
+
const base = marketIdx * 4;
|
|
11342
|
+
const fixedRes = results[base];
|
|
11343
|
+
const dynRes = results[base + 1];
|
|
11344
|
+
const debtRes = results[base + 2];
|
|
11345
|
+
const termsRes = results[base + 3];
|
|
11346
|
+
const termIdByDays = {};
|
|
11347
|
+
if (termsRes?.status === "success" && termsRes.result) {
|
|
11348
|
+
for (const t of termsRes.result) {
|
|
11349
|
+
termIdByDays[Math.round(Number(t[1]) / 86400)] = Number(t[0]);
|
|
11350
|
+
}
|
|
11351
|
+
}
|
|
11352
|
+
const fixedLoans = [];
|
|
11353
|
+
if (fixedRes?.status === "success" && fixedRes.result) {
|
|
11354
|
+
for (const p of fixedRes.result) {
|
|
11355
|
+
const principal = p[1];
|
|
11356
|
+
const apr = p[2];
|
|
11357
|
+
const start = p[3];
|
|
11358
|
+
const end = p[4];
|
|
11359
|
+
const lastRepaidTime = p[5];
|
|
11360
|
+
const interestRepaid = p[6];
|
|
11361
|
+
const principalRepaid = p[7];
|
|
11362
|
+
const outstanding = principal > principalRepaid ? principal - principalRepaid : 0n;
|
|
11363
|
+
const termDays = Math.round((Number(end) - Number(start)) / 86400);
|
|
11364
|
+
fixedLoans.push({
|
|
11365
|
+
posId: p[0].toString(),
|
|
11366
|
+
termId: termIdByDays[termDays],
|
|
11367
|
+
principal: principal.toString(),
|
|
11368
|
+
outstanding: outstanding.toString(),
|
|
11369
|
+
aprFraction: aprFractionFromRaw(apr),
|
|
11370
|
+
start: Number(start),
|
|
11371
|
+
end: Number(end),
|
|
11372
|
+
termDays,
|
|
11373
|
+
accruedInterest: accruedInterest(
|
|
11374
|
+
outstanding,
|
|
11375
|
+
apr,
|
|
11376
|
+
start,
|
|
11377
|
+
end,
|
|
11378
|
+
lastRepaidTime,
|
|
11379
|
+
interestRepaid,
|
|
11380
|
+
now
|
|
11381
|
+
).toString(),
|
|
11382
|
+
earlyRepayPenalty: earlyRepayPenalty(
|
|
11383
|
+
outstanding,
|
|
11384
|
+
apr,
|
|
11385
|
+
end,
|
|
11386
|
+
now
|
|
11387
|
+
).toString(),
|
|
11388
|
+
isMatured: now >= end
|
|
11389
|
+
});
|
|
11390
|
+
}
|
|
11391
|
+
}
|
|
11392
|
+
let dynamic;
|
|
11393
|
+
if (dynRes?.status === "success" && dynRes.result) {
|
|
11394
|
+
const d = dynRes.result;
|
|
11395
|
+
if (d[0] > 0n || d[1] > 0n) {
|
|
11396
|
+
dynamic = { principal: d[0].toString(), normalizedDebt: d[1].toString() };
|
|
11397
|
+
}
|
|
11398
|
+
}
|
|
11399
|
+
const totalDebt = debtRes?.status === "success" && debtRes.result != null ? debtRes.result.toString() : "0";
|
|
11400
|
+
if (fixedLoans.length > 0 || dynamic || totalDebt !== "0") {
|
|
11401
|
+
out[id] = { totalDebt, dynamic, fixedLoans };
|
|
11402
|
+
}
|
|
11403
|
+
});
|
|
11404
|
+
} catch {
|
|
11405
|
+
}
|
|
11406
|
+
return out;
|
|
11407
|
+
}
|
|
11408
|
+
function getCachedListaBrokerUserData(chainId, account, marketKey) {
|
|
11409
|
+
return BROKER_USER_CACHE[`${chainId}:${account.toLowerCase()}`]?.[toBytes32MarketId(marketKey)];
|
|
11410
|
+
}
|
|
11101
11411
|
var { chunk } = lodash;
|
|
11102
11412
|
var MORPHO_LENS = {
|
|
11103
11413
|
[Chain.HEMI_NETWORK]: "0x1170Ef5B1A7f9c4F0ce34Ddf66CC0e6090Fd107E",
|
|
@@ -11142,7 +11452,8 @@ var buildMorphoUserCallWithLens = (chainId, account, lender, marketsToQuery) =>
|
|
|
11142
11452
|
var buildMorphoTypeUserCallWithLens = (chainId, account, lender, marketsToQuery) => {
|
|
11143
11453
|
return lender === Lender.MORPHO_BLUE ? buildMorphoUserCallWithLens(chainId, account, lender, marketsToQuery) : buildListaUserCallWithLens(chainId, account, lender, marketsToQuery);
|
|
11144
11454
|
};
|
|
11145
|
-
var buildListaUserCallWithLens = (chainId, account, lender, marketsToQuery) => {
|
|
11455
|
+
var buildListaUserCallWithLens = async (chainId, account, lender, marketsToQuery) => {
|
|
11456
|
+
await fetchListaBrokerUserData(chainId, account, marketsToQuery).catch(() => ({}));
|
|
11146
11457
|
const marketSlices = chunk(marketsToQuery, 100);
|
|
11147
11458
|
return marketSlices.flatMap((marketsInChunk) => ({
|
|
11148
11459
|
address: MORPHO_LENS[chainId],
|
|
@@ -11158,9 +11469,9 @@ var buildListaUserCallWithLens = (chainId, account, lender, marketsToQuery) => {
|
|
|
11158
11469
|
var safeDivide = (a, b) => {
|
|
11159
11470
|
return a === 0 || isNaN(a) ? 0 : b !== 0 ? a / b : Infinity;
|
|
11160
11471
|
};
|
|
11161
|
-
var
|
|
11472
|
+
var SECONDS_PER_YEAR3 = 31536e3;
|
|
11162
11473
|
var apyToApr2 = (apy) => {
|
|
11163
|
-
return ((apy + 1) ** (1 /
|
|
11474
|
+
return ((apy + 1) ** (1 / SECONDS_PER_YEAR3) - 1) * SECONDS_PER_YEAR3;
|
|
11164
11475
|
};
|
|
11165
11476
|
|
|
11166
11477
|
// src/lending/user-data/utils/oraclePrice.ts
|
|
@@ -12292,7 +12603,7 @@ function divideAccrualsToAprs(aprs, nav, deposits, debt) {
|
|
|
12292
12603
|
}
|
|
12293
12604
|
|
|
12294
12605
|
// src/lending/public-data/morpho/utils/parsers.ts
|
|
12295
|
-
var
|
|
12606
|
+
var SECONDS_PER_YEAR4 = 31556952n;
|
|
12296
12607
|
var toFixed = (x, decimals) => new Intl.NumberFormat("en-US", {
|
|
12297
12608
|
style: "decimal",
|
|
12298
12609
|
useGrouping: false,
|
|
@@ -12312,7 +12623,7 @@ var safeParseUnits = (strValue, decimals = 18) => {
|
|
|
12312
12623
|
};
|
|
12313
12624
|
function rateToApy(rate) {
|
|
12314
12625
|
return safeParseNumber(
|
|
12315
|
-
Math.expm1(+formatEther(BigInt(rate) *
|
|
12626
|
+
Math.expm1(+formatEther(BigInt(rate) * SECONDS_PER_YEAR4))
|
|
12316
12627
|
);
|
|
12317
12628
|
}
|
|
12318
12629
|
function parseLtv(ltv) {
|
|
@@ -12323,6 +12634,11 @@ function parseLtv(ltv) {
|
|
|
12323
12634
|
}
|
|
12324
12635
|
return str2;
|
|
12325
12636
|
}
|
|
12637
|
+
function liquidationPenaltyFromLltv(lltv) {
|
|
12638
|
+
if (!lltv || lltv <= 0) return 0;
|
|
12639
|
+
const lif = Math.min(1.15, 1 / (0.3 * lltv + 0.7));
|
|
12640
|
+
return lif - 1;
|
|
12641
|
+
}
|
|
12326
12642
|
function formatNr(n, d) {
|
|
12327
12643
|
return Number(formatUnits(BigInt(n ?? 0), d));
|
|
12328
12644
|
}
|
|
@@ -12350,6 +12666,8 @@ function convertMarketsToMorphoResponse(response, chainId, additionalYields = {
|
|
|
12350
12666
|
if (collateralAsset && collateralAsset.symbol && loanAsset && loanAsset.symbol && oracleAddress && oracleAddress !== zeroAddress) {
|
|
12351
12667
|
const m = "MORPHO_BLUE_" + uniqueKey.slice(2).toUpperCase();
|
|
12352
12668
|
if (!data[m]) data[m] = { data: {} };
|
|
12669
|
+
const ltv = parseLtv(lltv);
|
|
12670
|
+
const liquidationPenalty = liquidationPenaltyFromLltv(ltv);
|
|
12353
12671
|
const loanRewards = [];
|
|
12354
12672
|
state.rewards?.forEach((reward) => {
|
|
12355
12673
|
loanRewards.push({
|
|
@@ -12394,10 +12712,13 @@ function convertMarketsToMorphoResponse(response, chainId, additionalYields = {
|
|
|
12394
12712
|
borrowCollateralFactor: 0,
|
|
12395
12713
|
collateralFactor: 0,
|
|
12396
12714
|
borrowFactor: 1,
|
|
12715
|
+
liquidationPenalty,
|
|
12716
|
+
closeFactor: 1,
|
|
12397
12717
|
collateralDisabled: true,
|
|
12398
12718
|
debtDisabled: false
|
|
12399
12719
|
}
|
|
12400
12720
|
},
|
|
12721
|
+
closeFactor: 1,
|
|
12401
12722
|
collateralActive: false,
|
|
12402
12723
|
borrowingEnabled: true,
|
|
12403
12724
|
depositsEnabled: true,
|
|
@@ -12405,7 +12726,6 @@ function convertMarketsToMorphoResponse(response, chainId, additionalYields = {
|
|
|
12405
12726
|
isActive: true,
|
|
12406
12727
|
isFrozen: false
|
|
12407
12728
|
};
|
|
12408
|
-
const ltv = parseLtv(lltv);
|
|
12409
12729
|
const collateralAssetAddress = collateralAsset.address.toLowerCase();
|
|
12410
12730
|
const metaCollateral = tokens[collateralAssetAddress] ?? collateralAsset;
|
|
12411
12731
|
const collateralMarketUid = createMarketUid(
|
|
@@ -12451,10 +12771,13 @@ function convertMarketsToMorphoResponse(response, chainId, additionalYields = {
|
|
|
12451
12771
|
borrowCollateralFactor: ltv,
|
|
12452
12772
|
collateralFactor: ltv,
|
|
12453
12773
|
borrowFactor: 1,
|
|
12774
|
+
liquidationPenalty,
|
|
12775
|
+
closeFactor: 1,
|
|
12454
12776
|
collateralDisabled: false,
|
|
12455
12777
|
debtDisabled: true
|
|
12456
12778
|
}
|
|
12457
12779
|
},
|
|
12780
|
+
closeFactor: 1,
|
|
12458
12781
|
collateralActive: true,
|
|
12459
12782
|
borrowingEnabled: false,
|
|
12460
12783
|
depositsEnabled: true,
|
|
@@ -12993,10 +13316,10 @@ var MathLib;
|
|
|
12993
13316
|
const DEFAULT_RATE_CAP = 634195839675291n;
|
|
12994
13317
|
const CURVE_STEEPNESS = 4000000000000000000n;
|
|
12995
13318
|
const TARGET_UTILIZATION = 900000000000000000n;
|
|
12996
|
-
const INITIAL_RATE_AT_TARGET = 40000000000000000n /
|
|
12997
|
-
const ADJUSTMENT_SPEED = 50000000000000000000n /
|
|
12998
|
-
const MIN_RATE_AT_TARGET = 1000000000000000n /
|
|
12999
|
-
const MAX_RATE_AT_TARGET = 2000000000000000000n /
|
|
13319
|
+
const INITIAL_RATE_AT_TARGET = 40000000000000000n / SECONDS_PER_YEAR4;
|
|
13320
|
+
const ADJUSTMENT_SPEED = 50000000000000000000n / SECONDS_PER_YEAR4;
|
|
13321
|
+
const MIN_RATE_AT_TARGET = 1000000000000000n / SECONDS_PER_YEAR4;
|
|
13322
|
+
const MAX_RATE_AT_TARGET = 2000000000000000000n / SECONDS_PER_YEAR4;
|
|
13000
13323
|
const LN_2_INT = 693147180559945309n;
|
|
13001
13324
|
const LN_WEI_INT = -41446531673892822312n;
|
|
13002
13325
|
const WEXP_UPPER_BOUND = 93859467695000404319n;
|
|
@@ -13063,6 +13386,8 @@ function getListaMarketDataConverter(lender, chainId, prices, additionalYields =
|
|
|
13063
13386
|
loaded: true
|
|
13064
13387
|
}, tokens = {}, marketsOverride) {
|
|
13065
13388
|
const markets = marketsOverride ?? morphoTypeMarkets()?.LISTA_DAO?.[chainId] ?? [];
|
|
13389
|
+
if (markets.length > 0) void fetchListaFixedTerms(chainId, markets).catch(() => {
|
|
13390
|
+
});
|
|
13066
13391
|
return [
|
|
13067
13392
|
(rData) => {
|
|
13068
13393
|
let decoded = [];
|
|
@@ -13091,6 +13416,8 @@ function getListaMarketDataConverter(lender, chainId, prices, additionalYields =
|
|
|
13091
13416
|
if (collateralToken && loanToken && oracle && oracle !== zeroAddress) {
|
|
13092
13417
|
const m = "LISTA_DAO_" + uniqueKey.slice(2).toUpperCase();
|
|
13093
13418
|
if (!data[m]) data[m] = { data: {} };
|
|
13419
|
+
const ltv = parseLtv(lltv);
|
|
13420
|
+
const liquidationPenalty = liquidationPenaltyFromLltv(ltv);
|
|
13094
13421
|
const loanRewards = [];
|
|
13095
13422
|
const loanTokenAddress = loanToken.toLowerCase();
|
|
13096
13423
|
const collateralAssetAddress = collateralToken.toLowerCase();
|
|
@@ -13135,6 +13462,9 @@ function getListaMarketDataConverter(lender, chainId, prices, additionalYields =
|
|
|
13135
13462
|
}
|
|
13136
13463
|
const borrowApr = apyToApr2(Number(formatEther(borrowApy))) * 100;
|
|
13137
13464
|
const depositApr = apyToApr2(Number(formatEther(supplyApy))) * 100;
|
|
13465
|
+
const fixedTermsForMarket = broker && broker !== zeroAddress ? getCachedListaFixedTerms(chainId, uniqueKey) : void 0;
|
|
13466
|
+
const hasFixedTerms = (fixedTermsForMarket?.length ?? 0) > 0;
|
|
13467
|
+
const fixedBorrowRate = hasFixedTerms ? Math.min(...fixedTermsForMarket.map((t) => t.aprFraction)) * 100 : 0;
|
|
13138
13468
|
const loanMarketUid = createMarketUid(chainId, m, loanTokenAddress);
|
|
13139
13469
|
data[m].data[loanMarketUid] = {
|
|
13140
13470
|
marketUid: loanMarketUid,
|
|
@@ -13156,7 +13486,8 @@ function getListaMarketDataConverter(lender, chainId, prices, additionalYields =
|
|
|
13156
13486
|
utilization: Number(utilization) / 1e18,
|
|
13157
13487
|
depositRate: depositApr,
|
|
13158
13488
|
variableBorrowRate: borrowApr,
|
|
13159
|
-
|
|
13489
|
+
// best available fixed-term borrow rate (percent); 0 when not a brokered market
|
|
13490
|
+
stableBorrowRate: fixedBorrowRate,
|
|
13160
13491
|
intrinsicYield: additionalYields?.intrinsicYields?.[meta?.assetGroup] ?? 0,
|
|
13161
13492
|
rewards: loanRewards.length > 0 ? loanRewards : void 0,
|
|
13162
13493
|
decimals: loanDecimals,
|
|
@@ -13166,18 +13497,26 @@ function getListaMarketDataConverter(lender, chainId, prices, additionalYields =
|
|
|
13166
13497
|
borrowCollateralFactor: 0,
|
|
13167
13498
|
collateralFactor: 0,
|
|
13168
13499
|
borrowFactor: 1,
|
|
13500
|
+
liquidationPenalty,
|
|
13501
|
+
closeFactor: 1,
|
|
13169
13502
|
collateralDisabled: true,
|
|
13170
13503
|
debtDisabled: false
|
|
13171
13504
|
}
|
|
13172
13505
|
},
|
|
13506
|
+
closeFactor: 1,
|
|
13173
13507
|
collateralActive: false,
|
|
13174
13508
|
borrowingEnabled: true,
|
|
13175
13509
|
depositsEnabled: true,
|
|
13176
|
-
|
|
13510
|
+
// a fixed-term (stable) borrow rate is available on brokered markets
|
|
13511
|
+
hasStable: hasFixedTerms,
|
|
13512
|
+
// brokered markets are fixed-term only on the borrow side: there is no composable
|
|
13513
|
+
// variable borrow (the variableBorrowRate is informational — the dynamic/matured-loan
|
|
13514
|
+
// rate). Supply yield (depositRate) is still variable. Consumers must borrow via the
|
|
13515
|
+
// broker (termId / stableBorrowRate / fixedTerms), not as a regular variable market.
|
|
13516
|
+
variableBorrowDisabled: hasFixedTerms,
|
|
13177
13517
|
isActive: true,
|
|
13178
13518
|
isFrozen: false
|
|
13179
13519
|
};
|
|
13180
|
-
const ltv = parseLtv(lltv);
|
|
13181
13520
|
const metaCollateral = tokens[collateralAssetAddress] ?? collateralAsset;
|
|
13182
13521
|
const collateralMarketUid = createMarketUid(
|
|
13183
13522
|
chainId,
|
|
@@ -13214,10 +13553,13 @@ function getListaMarketDataConverter(lender, chainId, prices, additionalYields =
|
|
|
13214
13553
|
borrowCollateralFactor: ltv,
|
|
13215
13554
|
collateralFactor: ltv,
|
|
13216
13555
|
borrowFactor: 1,
|
|
13556
|
+
liquidationPenalty,
|
|
13557
|
+
closeFactor: 1,
|
|
13217
13558
|
collateralDisabled: false,
|
|
13218
13559
|
debtDisabled: true
|
|
13219
13560
|
}
|
|
13220
13561
|
},
|
|
13562
|
+
closeFactor: 1,
|
|
13221
13563
|
collateralActive: true,
|
|
13222
13564
|
borrowingEnabled: false,
|
|
13223
13565
|
depositsEnabled: true,
|
|
@@ -13244,7 +13586,9 @@ function getListaMarketDataConverter(lender, chainId, prices, additionalYields =
|
|
|
13244
13586
|
fee: state.fee.toString(),
|
|
13245
13587
|
rateAtTarget: state.rateAtTarget.toString(),
|
|
13246
13588
|
rateCap: rateCap?.toString() ?? "0",
|
|
13247
|
-
rateFloor: rateFloor?.toString() ?? "0"
|
|
13589
|
+
rateFloor: rateFloor?.toString() ?? "0",
|
|
13590
|
+
// fixed-term menu for brokered markets (warm via fetchListaFixedTerms)
|
|
13591
|
+
fixedTerms: fixedTermsForMarket
|
|
13248
13592
|
}
|
|
13249
13593
|
};
|
|
13250
13594
|
data[m].chainId = chainId;
|
|
@@ -13311,6 +13655,8 @@ function getMorphoMarketDataConverter(lender, chainId, prices, additionalYields
|
|
|
13311
13655
|
if (collateralToken && loanToken && oracle && collateralToken !== zeroAddress && loanToken !== zeroAddress) {
|
|
13312
13656
|
const m = "MORPHO_BLUE_" + uniqueKey.slice(2).toUpperCase();
|
|
13313
13657
|
if (!data[m]) data[m] = { data: {} };
|
|
13658
|
+
const ltv = parseLtv(lltv);
|
|
13659
|
+
const liquidationPenalty = liquidationPenaltyFromLltv(ltv);
|
|
13314
13660
|
const loanRewards = [];
|
|
13315
13661
|
const loanAsset = tokens[loanToken.toLowerCase()];
|
|
13316
13662
|
const collateralAsset = tokens[collateralToken.toLowerCase()];
|
|
@@ -13386,10 +13732,13 @@ function getMorphoMarketDataConverter(lender, chainId, prices, additionalYields
|
|
|
13386
13732
|
borrowCollateralFactor: 0,
|
|
13387
13733
|
collateralFactor: 0,
|
|
13388
13734
|
borrowFactor: 1,
|
|
13735
|
+
liquidationPenalty,
|
|
13736
|
+
closeFactor: 1,
|
|
13389
13737
|
collateralDisabled: true,
|
|
13390
13738
|
debtDisabled: false
|
|
13391
13739
|
}
|
|
13392
13740
|
},
|
|
13741
|
+
closeFactor: 1,
|
|
13393
13742
|
collateralActive: false,
|
|
13394
13743
|
borrowingEnabled: true,
|
|
13395
13744
|
depositsEnabled: true,
|
|
@@ -13397,7 +13746,6 @@ function getMorphoMarketDataConverter(lender, chainId, prices, additionalYields
|
|
|
13397
13746
|
isActive: true,
|
|
13398
13747
|
isFrozen: false
|
|
13399
13748
|
};
|
|
13400
|
-
const ltv = parseLtv(lltv);
|
|
13401
13749
|
const collateralAssetAddress = (collateralAsset?.address ?? collateralToken).toLowerCase();
|
|
13402
13750
|
const metaCollateral = tokens[collateralAssetAddress] ?? collateralAsset;
|
|
13403
13751
|
const collateralMarketUid = createMarketUid(
|
|
@@ -13435,10 +13783,13 @@ function getMorphoMarketDataConverter(lender, chainId, prices, additionalYields
|
|
|
13435
13783
|
borrowCollateralFactor: ltv,
|
|
13436
13784
|
collateralFactor: ltv,
|
|
13437
13785
|
borrowFactor: 1,
|
|
13786
|
+
liquidationPenalty,
|
|
13787
|
+
closeFactor: 1,
|
|
13438
13788
|
collateralDisabled: false,
|
|
13439
13789
|
debtDisabled: true
|
|
13440
13790
|
}
|
|
13441
13791
|
},
|
|
13792
|
+
closeFactor: 1,
|
|
13442
13793
|
collateralActive: true,
|
|
13443
13794
|
borrowingEnabled: false,
|
|
13444
13795
|
depositsEnabled: true,
|
|
@@ -15634,6 +15985,43 @@ var SegmentLensAbi = [
|
|
|
15634
15985
|
}
|
|
15635
15986
|
];
|
|
15636
15987
|
|
|
15988
|
+
// src/abis/compound-v2/Comptroller.ts
|
|
15989
|
+
var ComptrollerAbi = [
|
|
15990
|
+
{
|
|
15991
|
+
inputs: [
|
|
15992
|
+
{
|
|
15993
|
+
internalType: "address",
|
|
15994
|
+
name: "account",
|
|
15995
|
+
type: "address"
|
|
15996
|
+
}
|
|
15997
|
+
],
|
|
15998
|
+
name: "getAssetsIn",
|
|
15999
|
+
outputs: [
|
|
16000
|
+
{
|
|
16001
|
+
internalType: "contract CToken[]",
|
|
16002
|
+
name: "",
|
|
16003
|
+
type: "address[]"
|
|
16004
|
+
}
|
|
16005
|
+
],
|
|
16006
|
+
stateMutability: "view",
|
|
16007
|
+
type: "function"
|
|
16008
|
+
},
|
|
16009
|
+
{
|
|
16010
|
+
inputs: [],
|
|
16011
|
+
name: "closeFactorMantissa",
|
|
16012
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
16013
|
+
stateMutability: "view",
|
|
16014
|
+
type: "function"
|
|
16015
|
+
},
|
|
16016
|
+
{
|
|
16017
|
+
inputs: [],
|
|
16018
|
+
name: "liquidationIncentiveMantissa",
|
|
16019
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
16020
|
+
stateMutability: "view",
|
|
16021
|
+
type: "function"
|
|
16022
|
+
}
|
|
16023
|
+
];
|
|
16024
|
+
|
|
15637
16025
|
// src/lending/public-data/compound-v2/publicCallBuild.ts
|
|
15638
16026
|
var buildCompoundV2StyleLenderReserveCall = (chainId, lender) => {
|
|
15639
16027
|
if (lender === Lender.TAKARA) {
|
|
@@ -15697,6 +16085,22 @@ var buildCompoundV2StyleLenderReserveCall = (chainId, lender) => {
|
|
|
15697
16085
|
});
|
|
15698
16086
|
}
|
|
15699
16087
|
}
|
|
16088
|
+
return calls;
|
|
16089
|
+
}
|
|
16090
|
+
const stdComptroller = getCompoundV2Comptroller(chainId, lender);
|
|
16091
|
+
if (stdComptroller) {
|
|
16092
|
+
calls.push({
|
|
16093
|
+
abi: ComptrollerAbi,
|
|
16094
|
+
address: stdComptroller,
|
|
16095
|
+
name: "closeFactorMantissa",
|
|
16096
|
+
params: []
|
|
16097
|
+
});
|
|
16098
|
+
calls.push({
|
|
16099
|
+
abi: ComptrollerAbi,
|
|
16100
|
+
address: stdComptroller,
|
|
16101
|
+
name: "liquidationIncentiveMantissa",
|
|
16102
|
+
params: []
|
|
16103
|
+
});
|
|
15700
16104
|
}
|
|
15701
16105
|
return calls;
|
|
15702
16106
|
};
|
|
@@ -16122,6 +16526,10 @@ function getKineticRates(info, chainId) {
|
|
|
16122
16526
|
var PRICE_DECIMALS = 18;
|
|
16123
16527
|
var RESERVE_MANTISSA_DECIMALS = 18;
|
|
16124
16528
|
|
|
16529
|
+
// src/lending/public-data/compound-v2/convert/risk.ts
|
|
16530
|
+
var DEFAULT_CLOSE_FACTOR = 0.5;
|
|
16531
|
+
var DEFAULT_LIQUIDATION_PENALTY = 0.08;
|
|
16532
|
+
|
|
16125
16533
|
// src/lending/public-data/compound-v2/convert/standard.ts
|
|
16126
16534
|
var COMPOUND_V2_NAME_OVERRIDES = {
|
|
16127
16535
|
"0xccf4429db6322d5c611ee964527d42e5d685dd6a": "Compound"
|
|
@@ -16143,6 +16551,21 @@ function convertSingleEntry(opts) {
|
|
|
16143
16551
|
currentEntry?.collateralFactorMantissa?.toString(),
|
|
16144
16552
|
RESERVE_MANTISSA_DECIMALS
|
|
16145
16553
|
);
|
|
16554
|
+
const perMarketIncentive = currentEntry?.liquidationIncentiveMantissa;
|
|
16555
|
+
let liquidationPenalty;
|
|
16556
|
+
if (perMarketIncentive !== void 0 && Number(perMarketIncentive) > 0) {
|
|
16557
|
+
liquidationPenalty = Math.max(
|
|
16558
|
+
Number(
|
|
16559
|
+
parseRawAmount(perMarketIncentive.toString(), RESERVE_MANTISSA_DECIMALS)
|
|
16560
|
+
) - 1,
|
|
16561
|
+
0
|
|
16562
|
+
);
|
|
16563
|
+
} else if (opts.liquidationPenalty !== void 0) {
|
|
16564
|
+
liquidationPenalty = opts.liquidationPenalty;
|
|
16565
|
+
} else {
|
|
16566
|
+
liquidationPenalty = DEFAULT_LIQUIDATION_PENALTY;
|
|
16567
|
+
}
|
|
16568
|
+
const closeFactor = opts.closeFactor ?? DEFAULT_CLOSE_FACTOR;
|
|
16146
16569
|
const exchangeRateRaw = currentEntry?.exchangeRateCurrent ?? 0;
|
|
16147
16570
|
const exchangeRateCurrent = parseRawAmount(
|
|
16148
16571
|
exchangeRateRaw?.toString(),
|
|
@@ -16189,10 +16612,13 @@ function convertSingleEntry(opts) {
|
|
|
16189
16612
|
borrowCollateralFactor: Number(borrowCollateralFactor),
|
|
16190
16613
|
collateralFactor: Number(borrowCollateralFactor),
|
|
16191
16614
|
borrowFactor: 1,
|
|
16615
|
+
liquidationPenalty,
|
|
16616
|
+
closeFactor,
|
|
16192
16617
|
collateralDisabled: !collateralActive,
|
|
16193
16618
|
debtDisabled: !borrowingEnabled
|
|
16194
16619
|
}
|
|
16195
16620
|
},
|
|
16621
|
+
closeFactor,
|
|
16196
16622
|
hasStable: false,
|
|
16197
16623
|
underlying: asset.address,
|
|
16198
16624
|
isActive: Boolean(currentEntry?.isListed) && !allPaused,
|
|
@@ -16253,6 +16679,15 @@ function convertSumerEntry(opts) {
|
|
|
16253
16679
|
RESERVE_MANTISSA_DECIMALS
|
|
16254
16680
|
)
|
|
16255
16681
|
);
|
|
16682
|
+
const incentiveToPenalty = (raw) => {
|
|
16683
|
+
const mantissa = Number(parseRawAmount(raw.toString(), PRICE_DECIMALS));
|
|
16684
|
+
if (!mantissa) return DEFAULT_LIQUIDATION_PENALTY;
|
|
16685
|
+
return Math.max(mantissa - 1, 0);
|
|
16686
|
+
};
|
|
16687
|
+
const homoPenalty = incentiveToPenalty(currentEntry.homoLiquidationIncentive);
|
|
16688
|
+
const heteroPenalty = incentiveToPenalty(
|
|
16689
|
+
currentEntry.heteroLiquidationIncentive
|
|
16690
|
+
);
|
|
16256
16691
|
const config = {};
|
|
16257
16692
|
for (let gId = 0; gId < SUMER_GROUP_COUNT; gId++) {
|
|
16258
16693
|
const isOwnGroup = gId === groupId;
|
|
@@ -16262,6 +16697,8 @@ function convertSumerEntry(opts) {
|
|
|
16262
16697
|
borrowCollateralFactor: cf,
|
|
16263
16698
|
collateralFactor: cf,
|
|
16264
16699
|
borrowFactor: 1,
|
|
16700
|
+
liquidationPenalty: isOwnGroup ? homoPenalty : heteroPenalty,
|
|
16701
|
+
closeFactor: DEFAULT_CLOSE_FACTOR,
|
|
16265
16702
|
collateralDisabled: !collateralActive,
|
|
16266
16703
|
debtDisabled: !borrowingEnabled
|
|
16267
16704
|
};
|
|
@@ -16287,6 +16724,7 @@ function convertSumerEntry(opts) {
|
|
|
16287
16724
|
utilization: computeUtilization(totalSupplyUnderlying, totalDebt),
|
|
16288
16725
|
stakingYield: additionalYields?.intrinsicYields?.[asset.assetGroup] ?? 0,
|
|
16289
16726
|
config,
|
|
16727
|
+
closeFactor: DEFAULT_CLOSE_FACTOR,
|
|
16290
16728
|
hasStable: false,
|
|
16291
16729
|
underlying: asset.address,
|
|
16292
16730
|
isActive: Boolean(currentEntry.isListed),
|
|
@@ -16362,10 +16800,13 @@ function convertTakaraEntry(opts) {
|
|
|
16362
16800
|
borrowCollateralFactor: collateralFactor,
|
|
16363
16801
|
collateralFactor,
|
|
16364
16802
|
borrowFactor: 1,
|
|
16803
|
+
liquidationPenalty: DEFAULT_LIQUIDATION_PENALTY,
|
|
16804
|
+
closeFactor: DEFAULT_CLOSE_FACTOR,
|
|
16365
16805
|
collateralDisabled: false,
|
|
16366
16806
|
debtDisabled: false
|
|
16367
16807
|
}
|
|
16368
16808
|
},
|
|
16809
|
+
closeFactor: DEFAULT_CLOSE_FACTOR,
|
|
16369
16810
|
hasStable: false,
|
|
16370
16811
|
underlying: asset.address,
|
|
16371
16812
|
isActive: info.isListed,
|
|
@@ -16394,6 +16835,12 @@ function convertTectonicEntry(opts) {
|
|
|
16394
16835
|
const collateralFactor = Number(
|
|
16395
16836
|
parseRawAmount(info.collateralFactor.toString(), RESERVE_MANTISSA_DECIMALS)
|
|
16396
16837
|
);
|
|
16838
|
+
const liquidationPenalty = Math.max(
|
|
16839
|
+
Number(
|
|
16840
|
+
parseRawAmount(info.liquidationPenalty.toString(), PRICE_DECIMALS)
|
|
16841
|
+
) - 1,
|
|
16842
|
+
0
|
|
16843
|
+
);
|
|
16397
16844
|
const exchangeRateCurrent = Number(
|
|
16398
16845
|
parseRawAmount(info.exchangeRate.toString(), PRICE_DECIMALS)
|
|
16399
16846
|
);
|
|
@@ -16430,10 +16877,13 @@ function convertTectonicEntry(opts) {
|
|
|
16430
16877
|
borrowCollateralFactor: collateralFactor,
|
|
16431
16878
|
collateralFactor,
|
|
16432
16879
|
borrowFactor: 1,
|
|
16880
|
+
liquidationPenalty,
|
|
16881
|
+
closeFactor: DEFAULT_CLOSE_FACTOR,
|
|
16433
16882
|
collateralDisabled: !info.asCollateralEnabled,
|
|
16434
16883
|
debtDisabled: false
|
|
16435
16884
|
}
|
|
16436
16885
|
},
|
|
16886
|
+
closeFactor: DEFAULT_CLOSE_FACTOR,
|
|
16437
16887
|
hasStable: false,
|
|
16438
16888
|
underlying: asset.address,
|
|
16439
16889
|
isActive: info.asCollateralEnabled,
|
|
@@ -16597,10 +17047,13 @@ function convertBenqiEntry(opts) {
|
|
|
16597
17047
|
borrowCollateralFactor: collateralFactor,
|
|
16598
17048
|
collateralFactor,
|
|
16599
17049
|
borrowFactor: 1,
|
|
17050
|
+
liquidationPenalty: DEFAULT_LIQUIDATION_PENALTY,
|
|
17051
|
+
closeFactor: DEFAULT_CLOSE_FACTOR,
|
|
16600
17052
|
collateralDisabled: !collateralActive,
|
|
16601
17053
|
debtDisabled: !borrowingEnabled
|
|
16602
17054
|
}
|
|
16603
17055
|
},
|
|
17056
|
+
closeFactor: DEFAULT_CLOSE_FACTOR,
|
|
16604
17057
|
hasStable: false,
|
|
16605
17058
|
underlying: asset.address,
|
|
16606
17059
|
isActive: !parsed.mintPaused || !parsed.borrowPaused,
|
|
@@ -16668,10 +17121,13 @@ function convertKineticEntry(opts) {
|
|
|
16668
17121
|
borrowCollateralFactor: collateralFactor,
|
|
16669
17122
|
collateralFactor,
|
|
16670
17123
|
borrowFactor: 1,
|
|
17124
|
+
liquidationPenalty: DEFAULT_LIQUIDATION_PENALTY,
|
|
17125
|
+
closeFactor: DEFAULT_CLOSE_FACTOR,
|
|
16671
17126
|
collateralDisabled: !collateralActive,
|
|
16672
17127
|
debtDisabled: !borrowingEnabled
|
|
16673
17128
|
}
|
|
16674
17129
|
},
|
|
17130
|
+
closeFactor: DEFAULT_CLOSE_FACTOR,
|
|
16675
17131
|
hasStable: false,
|
|
16676
17132
|
underlying: asset.address,
|
|
16677
17133
|
isActive: !parsed.mintPaused || !parsed.borrowPaused,
|
|
@@ -16826,6 +17282,14 @@ function readCreamV2CTokenMetadata(meta, token) {
|
|
|
16826
17282
|
}
|
|
16827
17283
|
|
|
16828
17284
|
// src/lending/public-data/compound-v2/publicCallParse.ts
|
|
17285
|
+
var parseMantissaWad = (raw) => {
|
|
17286
|
+
if (raw === void 0 || raw === null || raw === "0x") return void 0;
|
|
17287
|
+
try {
|
|
17288
|
+
return Number(raw) / 1e18;
|
|
17289
|
+
} catch {
|
|
17290
|
+
return void 0;
|
|
17291
|
+
}
|
|
17292
|
+
};
|
|
16829
17293
|
var getCompoundV2DataConverter = (lender, chainId, prices, additionalYields, tokenList = {}) => {
|
|
16830
17294
|
if (lender === Lender.TAKARA) {
|
|
16831
17295
|
return [
|
|
@@ -16943,7 +17407,9 @@ var getCompoundV2DataConverter = (lender, chainId, prices, additionalYields, tok
|
|
|
16943
17407
|
const compoundV2Tokens2 = getCompoundV2Tokens(chainId, lender);
|
|
16944
17408
|
const tokenCount = compoundV2Tokens2.length;
|
|
16945
17409
|
const isSumer = isSumerType(lender);
|
|
16946
|
-
const
|
|
17410
|
+
const stdComptroller = isSumer ? void 0 : getCompoundV2Comptroller(chainId, lender);
|
|
17411
|
+
const stdComptrollerCalls = stdComptroller ? 2 : 0;
|
|
17412
|
+
const expectedNumberOfCalls = isSumer ? tokenCount + SUMER_GROUP_COUNT : tokenCount + stdComptrollerCalls;
|
|
16947
17413
|
const reader = getReader(lender, chainId);
|
|
16948
17414
|
return [
|
|
16949
17415
|
(data) => {
|
|
@@ -16972,6 +17438,14 @@ var getCompoundV2DataConverter = (lender, chainId, prices, additionalYields, tok
|
|
|
16972
17438
|
}
|
|
16973
17439
|
return out;
|
|
16974
17440
|
}
|
|
17441
|
+
let globalCloseFactor;
|
|
17442
|
+
let globalLiquidationPenalty;
|
|
17443
|
+
if (stdComptrollerCalls === 2) {
|
|
17444
|
+
const closeFactorMantissa = parseMantissaWad(data[tokenCount]);
|
|
17445
|
+
const incentiveMantissa = parseMantissaWad(data[tokenCount + 1]);
|
|
17446
|
+
globalCloseFactor = closeFactorMantissa;
|
|
17447
|
+
globalLiquidationPenalty = incentiveMantissa !== void 0 ? Math.max(incentiveMantissa - 1, 0) : void 0;
|
|
17448
|
+
}
|
|
16975
17449
|
for (let i = 0; i < tokenCount; i++) {
|
|
16976
17450
|
const { underlying, cToken } = compoundV2Tokens2[i];
|
|
16977
17451
|
if (!cToken || !underlying) continue;
|
|
@@ -16986,7 +17460,9 @@ var getCompoundV2DataConverter = (lender, chainId, prices, additionalYields, tok
|
|
|
16986
17460
|
lender,
|
|
16987
17461
|
prices,
|
|
16988
17462
|
additionalYields,
|
|
16989
|
-
cToken
|
|
17463
|
+
cToken,
|
|
17464
|
+
closeFactor: globalCloseFactor,
|
|
17465
|
+
liquidationPenalty: globalLiquidationPenalty
|
|
16990
17466
|
});
|
|
16991
17467
|
out.data[entry.marketUid] = entry;
|
|
16992
17468
|
}
|
|
@@ -18176,6 +18652,8 @@ function buildReverseLTVIndex(cluster) {
|
|
|
18176
18652
|
}
|
|
18177
18653
|
function buildTokenConfig(vaultAddr, reverseLTV, borrowVaults, vaultData) {
|
|
18178
18654
|
const config = {};
|
|
18655
|
+
const ownInfo = findInfo(vaultAddr, vaultData);
|
|
18656
|
+
const liquidationPenalty = ownInfo ? ltvToNumber(ownInfo.maxLiquidationDiscount) : 0;
|
|
18179
18657
|
const reverseEntries = reverseLTV.get(vaultAddr) ?? [];
|
|
18180
18658
|
for (const { borrowVault, ltv } of reverseEntries) {
|
|
18181
18659
|
if (!borrowVaults.has(borrowVault)) continue;
|
|
@@ -18185,6 +18663,8 @@ function buildTokenConfig(vaultAddr, reverseLTV, borrowVaults, vaultData) {
|
|
|
18185
18663
|
borrowCollateralFactor: ltvToNumber(ltv.borrowLTV),
|
|
18186
18664
|
collateralFactor: ltvToNumber(ltv.liquidationLTV),
|
|
18187
18665
|
borrowFactor: 1,
|
|
18666
|
+
liquidationPenalty,
|
|
18667
|
+
closeFactor: 1,
|
|
18188
18668
|
collateralDisabled: false,
|
|
18189
18669
|
debtDisabled: true
|
|
18190
18670
|
};
|
|
@@ -18197,6 +18677,8 @@ function buildTokenConfig(vaultAddr, reverseLTV, borrowVaults, vaultData) {
|
|
|
18197
18677
|
borrowCollateralFactor: 0,
|
|
18198
18678
|
collateralFactor: 0,
|
|
18199
18679
|
borrowFactor: 1,
|
|
18680
|
+
liquidationPenalty,
|
|
18681
|
+
closeFactor: 1,
|
|
18200
18682
|
debtDisabled: false,
|
|
18201
18683
|
collateralDisabled: true
|
|
18202
18684
|
};
|
|
@@ -18433,6 +18915,9 @@ var getEulerV2ReservesDataConverter = (lender, chainId, prices, additionalYields
|
|
|
18433
18915
|
decimals: entry.decimals,
|
|
18434
18916
|
// config (keyed by counterparty vault address)
|
|
18435
18917
|
config: entry.config,
|
|
18918
|
+
// Euler liquidation is bounded by a discount curve rather than a
|
|
18919
|
+
// fixed close factor — a position can be fully liquidated.
|
|
18920
|
+
closeFactor: 1,
|
|
18436
18921
|
// flags
|
|
18437
18922
|
collateralActive: entry.collateralActive,
|
|
18438
18923
|
borrowingEnabled: entry.borrowingEnabled,
|
|
@@ -18671,6 +19156,8 @@ function normalizeAaveV4(spokeDataList, chainId, spokeLenderKeyArg, prices, addi
|
|
|
18671
19156
|
const depositRate = variableBorrowRate * hubUtilization * (1 - feeRate);
|
|
18672
19157
|
const collateralRiskBps = reserve.config.collateralRisk || reserve.reserve.collateralRisk || 0;
|
|
18673
19158
|
const riskPremiumThresholdBps = reserve.spokeBinding?.riskPremiumThreshold ?? 0;
|
|
19159
|
+
const targetHealthFactorRaw = spokeData.liquidationConfig?.targetHealthFactor ?? 0n;
|
|
19160
|
+
const targetHealthFactor = targetHealthFactorRaw > 0n ? Number(targetHealthFactorRaw) / 1e18 : void 0;
|
|
18674
19161
|
const config = {};
|
|
18675
19162
|
for (const [keyStr, dynCfg] of Object.entries(reserve.dynamicConfigs)) {
|
|
18676
19163
|
config[keyStr] = {
|
|
@@ -18679,6 +19166,13 @@ function normalizeAaveV4(spokeDataList, chainId, spokeLenderKeyArg, prices, addi
|
|
|
18679
19166
|
borrowCollateralFactor: dynCfg.collateralFactor / BPS,
|
|
18680
19167
|
collateralFactor: dynCfg.collateralFactor / BPS,
|
|
18681
19168
|
borrowFactor: 1,
|
|
19169
|
+
// `maxLiquidationBonus` is in PERCENTAGE_FACTOR units (BPS) where
|
|
19170
|
+
// 10000 == par (0% bonus); the on-chain validator requires it to be
|
|
19171
|
+
// >= PERCENTAGE_FACTOR (README: "bonus ≥ 100% (= ≥ 0% bonus)"). Same
|
|
19172
|
+
// semantics as V3's `liquidationBonus`, so penalty = bps/BPS - 1.
|
|
19173
|
+
liquidationPenalty: Number.isFinite(dynCfg.maxLiquidationBonus) && dynCfg.maxLiquidationBonus > 0 ? dynCfg.maxLiquidationBonus / BPS - 1 : 0,
|
|
19174
|
+
closeFactor: 0.5,
|
|
19175
|
+
targetHealthFactor,
|
|
18682
19176
|
// _validateSetUsingAsCollateral: !paused && !frozen (frozen blocks enabling)
|
|
18683
19177
|
collateralDisabled: dynCfg.collateralFactor === 0 || reserve.config.paused || reserve.config.frozen,
|
|
18684
19178
|
// _validateBorrow: !paused && !frozen && borrowable
|
|
@@ -18692,6 +19186,9 @@ function normalizeAaveV4(spokeDataList, chainId, spokeLenderKeyArg, prices, addi
|
|
|
18692
19186
|
borrowCollateralFactor: 0,
|
|
18693
19187
|
collateralFactor: 0,
|
|
18694
19188
|
borrowFactor: 1,
|
|
19189
|
+
liquidationPenalty: 0,
|
|
19190
|
+
closeFactor: 0.5,
|
|
19191
|
+
targetHealthFactor,
|
|
18695
19192
|
collateralDisabled: true,
|
|
18696
19193
|
debtDisabled: !reserve.config.borrowable || reserve.config.paused || reserve.config.frozen
|
|
18697
19194
|
};
|
|
@@ -18755,6 +19252,8 @@ function normalizeAaveV4(spokeDataList, chainId, spokeLenderKeyArg, prices, addi
|
|
|
18755
19252
|
borrowCap,
|
|
18756
19253
|
supplyCap,
|
|
18757
19254
|
debtCeiling: 0,
|
|
19255
|
+
closeFactor: 0.5,
|
|
19256
|
+
targetHealthFactor,
|
|
18758
19257
|
spokeActive,
|
|
18759
19258
|
spokeHalted,
|
|
18760
19259
|
params: {
|
|
@@ -19151,7 +19650,7 @@ function buildSiloV2LenderReserveCall(_chainId, lender) {
|
|
|
19151
19650
|
// src/lending/public-data/silo-v2/irmRates.ts
|
|
19152
19651
|
var DP = 1e18;
|
|
19153
19652
|
var WAD = 1e18;
|
|
19154
|
-
var
|
|
19653
|
+
var SECONDS_PER_YEAR5 = 365 * 24 * 3600;
|
|
19155
19654
|
function toBigIntSafe(val) {
|
|
19156
19655
|
if (typeof val === "bigint") return val;
|
|
19157
19656
|
if (val == null || val === "0x") return 0n;
|
|
@@ -19212,7 +19711,7 @@ function calculateBorrowRate(utilization, params) {
|
|
|
19212
19711
|
let riEff = Math.max(ri, rlin);
|
|
19213
19712
|
riEff = Math.max(riEff + ki * (u - uopt) * T, rlin);
|
|
19214
19713
|
const rcurPerSecond = Math.max(riEff + rp, rlin);
|
|
19215
|
-
const rcurAnnual = rcurPerSecond *
|
|
19714
|
+
const rcurAnnual = rcurPerSecond * SECONDS_PER_YEAR5;
|
|
19216
19715
|
return Math.min(Math.max(rcurAnnual * 100, 0), 1e4);
|
|
19217
19716
|
}
|
|
19218
19717
|
function calculateSiloRates(utilization, params) {
|
|
@@ -19275,6 +19774,7 @@ var getSiloV2ReservesDataConverter = (lender, chainId, prices, additionalYields,
|
|
|
19275
19774
|
const selfLt = Number(self.lt) / 1e18;
|
|
19276
19775
|
const selfMaxLtv = Number(self.maxLtv) / 1e18;
|
|
19277
19776
|
const otherLt = Number(other.lt) / 1e18;
|
|
19777
|
+
const selfLiquidationPenalty = Number(self.liquidationFee ?? 0) / 1e18;
|
|
19278
19778
|
const collateralActive = selfLt > 0;
|
|
19279
19779
|
const borrowingEnabled = otherLt > 0;
|
|
19280
19780
|
const marketUid = createMarketUid(chainId, lender, self.silo);
|
|
@@ -19322,10 +19822,13 @@ var getSiloV2ReservesDataConverter = (lender, chainId, prices, additionalYields,
|
|
|
19322
19822
|
borrowCollateralFactor: selfMaxLtv,
|
|
19323
19823
|
collateralFactor: selfLt,
|
|
19324
19824
|
borrowFactor: 1,
|
|
19825
|
+
liquidationPenalty: selfLiquidationPenalty,
|
|
19826
|
+
closeFactor: 1,
|
|
19325
19827
|
collateralDisabled: !collateralActive,
|
|
19326
19828
|
debtDisabled: !borrowingEnabled
|
|
19327
19829
|
}
|
|
19328
19830
|
},
|
|
19831
|
+
closeFactor: 1,
|
|
19329
19832
|
collateralActive,
|
|
19330
19833
|
borrowingEnabled,
|
|
19331
19834
|
depositsEnabled: true,
|
|
@@ -19443,6 +19946,7 @@ var getSiloV3ReservesDataConverter = (lender, chainId, prices, additionalYields,
|
|
|
19443
19946
|
const selfLt = Number(self.lt) / 1e18;
|
|
19444
19947
|
const selfMaxLtv = Number(self.maxLtv) / 1e18;
|
|
19445
19948
|
const otherLt = Number(other.lt) / 1e18;
|
|
19949
|
+
const selfLiquidationPenalty = Number(self.liquidationFee ?? 0) / 1e18;
|
|
19446
19950
|
const collateralActive = selfLt > 0;
|
|
19447
19951
|
const borrowingEnabled = otherLt > 0;
|
|
19448
19952
|
const marketUid = createMarketUid(chainId, lender, self.silo);
|
|
@@ -19482,10 +19986,13 @@ var getSiloV3ReservesDataConverter = (lender, chainId, prices, additionalYields,
|
|
|
19482
19986
|
borrowCollateralFactor: selfMaxLtv,
|
|
19483
19987
|
collateralFactor: selfLt,
|
|
19484
19988
|
borrowFactor: 1,
|
|
19989
|
+
liquidationPenalty: selfLiquidationPenalty,
|
|
19990
|
+
closeFactor: 1,
|
|
19485
19991
|
collateralDisabled: !collateralActive,
|
|
19486
19992
|
debtDisabled: !borrowingEnabled
|
|
19487
19993
|
}
|
|
19488
19994
|
},
|
|
19995
|
+
closeFactor: 1,
|
|
19489
19996
|
collateralActive,
|
|
19490
19997
|
borrowingEnabled,
|
|
19491
19998
|
depositsEnabled: true,
|
|
@@ -19651,11 +20158,14 @@ function parseVault(vault, chainId, prices, additionalYields, tokenList) {
|
|
|
19651
20158
|
borrowCollateralFactor: ltv,
|
|
19652
20159
|
collateralFactor: liquidationThreshold,
|
|
19653
20160
|
borrowFactor: 1,
|
|
20161
|
+
liquidationPenalty,
|
|
20162
|
+
closeFactor: 1,
|
|
19654
20163
|
collateralDisabled: false,
|
|
19655
20164
|
debtDisabled: true
|
|
19656
20165
|
}
|
|
19657
20166
|
},
|
|
19658
20167
|
liquidationBonus: liquidationPenalty,
|
|
20168
|
+
closeFactor: 1,
|
|
19659
20169
|
collateralActive: true,
|
|
19660
20170
|
borrowingEnabled: false,
|
|
19661
20171
|
depositsEnabled: true,
|
|
@@ -19693,11 +20203,14 @@ function parseVault(vault, chainId, prices, additionalYields, tokenList) {
|
|
|
19693
20203
|
borrowCollateralFactor: 0,
|
|
19694
20204
|
collateralFactor: 0,
|
|
19695
20205
|
borrowFactor: 1,
|
|
20206
|
+
liquidationPenalty: 0,
|
|
20207
|
+
closeFactor: 1,
|
|
19696
20208
|
collateralDisabled: true,
|
|
19697
20209
|
debtDisabled: false
|
|
19698
20210
|
}
|
|
19699
20211
|
},
|
|
19700
20212
|
liquidationBonus: 0,
|
|
20213
|
+
closeFactor: 1,
|
|
19701
20214
|
collateralActive: false,
|
|
19702
20215
|
borrowingEnabled: true,
|
|
19703
20216
|
depositsEnabled: false,
|
|
@@ -19775,6 +20288,7 @@ var buildDolomiteCall = (chainId, _lender) => {
|
|
|
19775
20288
|
|
|
19776
20289
|
// src/lending/public-data/dolomite/emodeConfig.ts
|
|
19777
20290
|
var DISABLED_BORROW_FACTOR = 3402823669209385e5;
|
|
20291
|
+
var BASE_LIQUIDATION_PENALTY = 0.05;
|
|
19778
20292
|
var dolomiteFactors = (p, R) => ({
|
|
19779
20293
|
collateralFactor: 1 / (1 + p),
|
|
19780
20294
|
borrowCollateralFactor: 1 / ((1 + R) * (1 + p)),
|
|
@@ -19789,7 +20303,9 @@ function buildDolomiteConfigs(marketId, marginPremium, R, isClosing, emode) {
|
|
|
19789
20303
|
label: "Cross-margin",
|
|
19790
20304
|
...base,
|
|
19791
20305
|
debtDisabled: isClosing,
|
|
19792
|
-
collateralDisabled: borrowOnly
|
|
20306
|
+
collateralDisabled: borrowOnly,
|
|
20307
|
+
liquidationPenalty: BASE_LIQUIDATION_PENALTY,
|
|
20308
|
+
closeFactor: 1
|
|
19793
20309
|
}
|
|
19794
20310
|
};
|
|
19795
20311
|
if (!emode?.categories) return configs;
|
|
@@ -19802,7 +20318,9 @@ function buildDolomiteConfigs(marketId, marginPremium, R, isClosing, emode) {
|
|
|
19802
20318
|
label: cat,
|
|
19803
20319
|
...f,
|
|
19804
20320
|
debtDisabled: isClosing,
|
|
19805
|
-
collateralDisabled: borrowOnly
|
|
20321
|
+
collateralDisabled: borrowOnly,
|
|
20322
|
+
liquidationPenalty: param.liquidationRewardOverride,
|
|
20323
|
+
closeFactor: 1
|
|
19806
20324
|
};
|
|
19807
20325
|
} else {
|
|
19808
20326
|
configs[cat] = {
|
|
@@ -19812,7 +20330,9 @@ function buildDolomiteConfigs(marketId, marginPremium, R, isClosing, emode) {
|
|
|
19812
20330
|
borrowCollateralFactor: 0,
|
|
19813
20331
|
borrowFactor: DISABLED_BORROW_FACTOR,
|
|
19814
20332
|
debtDisabled: true,
|
|
19815
|
-
collateralDisabled: true
|
|
20333
|
+
collateralDisabled: true,
|
|
20334
|
+
liquidationPenalty: 0,
|
|
20335
|
+
closeFactor: 1
|
|
19816
20336
|
};
|
|
19817
20337
|
}
|
|
19818
20338
|
}
|
|
@@ -19831,7 +20351,7 @@ function resolveDolomiteMode(heldMarketIds, emode) {
|
|
|
19831
20351
|
|
|
19832
20352
|
// src/lending/public-data/dolomite/publicCallParse.ts
|
|
19833
20353
|
var BASE = 10n ** 18n;
|
|
19834
|
-
var
|
|
20354
|
+
var SECONDS_PER_YEAR6 = 31536e3;
|
|
19835
20355
|
var MARKET_STRIDE = DOLOMITE_MARKET_FNS.length;
|
|
19836
20356
|
var GLOBAL_COUNT = DOLOMITE_GLOBAL_FNS.length;
|
|
19837
20357
|
var toBig = (v) => {
|
|
@@ -19875,7 +20395,7 @@ var getDolomitePublicDataConverter = (lender, chainId, _prices, additionalYields
|
|
|
19875
20395
|
const borrowRatePerSec = Number(
|
|
19876
20396
|
parseRawAmount(toBig(data[base + 6 /* interestRate */]?.value), 18)
|
|
19877
20397
|
);
|
|
19878
|
-
const variableBorrowRate = borrowRatePerSec *
|
|
20398
|
+
const variableBorrowRate = borrowRatePerSec * SECONDS_PER_YEAR6 * 100;
|
|
19879
20399
|
const util = Number(totalDeposits) > 0 ? Number(totalDebt) / Number(totalDeposits) : 0;
|
|
19880
20400
|
const depositRate = variableBorrowRate * util * earningsRate;
|
|
19881
20401
|
const p = Number(
|
|
@@ -19909,6 +20429,7 @@ var getDolomitePublicDataConverter = (lender, chainId, _prices, additionalYields
|
|
|
19909
20429
|
intrinsicYield: additionalYields?.intrinsicYields?.[underlying] ?? 0,
|
|
19910
20430
|
rewards: [],
|
|
19911
20431
|
config,
|
|
20432
|
+
closeFactor: 1,
|
|
19912
20433
|
borrowingEnabled: !isClosing,
|
|
19913
20434
|
depositsEnabled: !isClosing
|
|
19914
20435
|
};
|
|
@@ -20021,6 +20542,8 @@ var getGearboxV3PublicDataConverter = (_lender, chainId, prices, additionalYield
|
|
|
20021
20542
|
);
|
|
20022
20543
|
const totalDepositsCm = availableToBorrow + totalDebtCm;
|
|
20023
20544
|
const borrowRate = scaleGearboxRate(pool.baseInterestRate);
|
|
20545
|
+
const liquidationDiscount = Number(manager.liquidationDiscount ?? 0);
|
|
20546
|
+
const liquidationPenalty = liquidationDiscount > 0 ? (BPS - liquidationDiscount) / BPS : 0.04;
|
|
20024
20547
|
const data2 = {};
|
|
20025
20548
|
const loanMarketUid = createMarketUid(chainId, lender, underlying);
|
|
20026
20549
|
data2[loanMarketUid] = {
|
|
@@ -20053,10 +20576,13 @@ var getGearboxV3PublicDataConverter = (_lender, chainId, prices, additionalYield
|
|
|
20053
20576
|
collateralFactor: 0,
|
|
20054
20577
|
borrowFactor: 1,
|
|
20055
20578
|
collateralDisabled: true,
|
|
20056
|
-
debtDisabled: false
|
|
20579
|
+
debtDisabled: false,
|
|
20580
|
+
liquidationPenalty,
|
|
20581
|
+
closeFactor: 1
|
|
20057
20582
|
}
|
|
20058
20583
|
},
|
|
20059
|
-
liquidationBonus:
|
|
20584
|
+
liquidationBonus: liquidationPenalty,
|
|
20585
|
+
closeFactor: 1,
|
|
20060
20586
|
collateralActive: false,
|
|
20061
20587
|
borrowingEnabled: true,
|
|
20062
20588
|
depositsEnabled: false,
|
|
@@ -20109,10 +20635,13 @@ var getGearboxV3PublicDataConverter = (_lender, chainId, prices, additionalYield
|
|
|
20109
20635
|
collateralFactor: lt,
|
|
20110
20636
|
borrowFactor: 1,
|
|
20111
20637
|
collateralDisabled: false,
|
|
20112
|
-
debtDisabled: true
|
|
20638
|
+
debtDisabled: true,
|
|
20639
|
+
liquidationPenalty,
|
|
20640
|
+
closeFactor: 1
|
|
20113
20641
|
}
|
|
20114
20642
|
},
|
|
20115
|
-
liquidationBonus:
|
|
20643
|
+
liquidationBonus: liquidationPenalty,
|
|
20644
|
+
closeFactor: 1,
|
|
20116
20645
|
collateralActive: true,
|
|
20117
20646
|
borrowingEnabled: false,
|
|
20118
20647
|
depositsEnabled: false,
|
|
@@ -20621,6 +21150,9 @@ function convertSiloMarketsToPublicResponse(apiItems, chainId, prices, additiona
|
|
|
20621
21150
|
const selfLt = bigintToLtv(api.lt ?? self.lt);
|
|
20622
21151
|
const selfMaxLtv = bigintToLtv(api.maxLtv ?? self.maxLtv);
|
|
20623
21152
|
const otherLt = bigintToLtv(otherApi.lt ?? other.lt);
|
|
21153
|
+
const selfLiquidationPenalty = bigintToLtv(
|
|
21154
|
+
api.liquidationFee ?? self.liquidationFee
|
|
21155
|
+
);
|
|
20624
21156
|
const collateralActive = selfLt > 0;
|
|
20625
21157
|
const borrowingEnabled = otherLt > 0;
|
|
20626
21158
|
const siloAddrLc = self.silo.toLowerCase();
|
|
@@ -20663,10 +21195,13 @@ function convertSiloMarketsToPublicResponse(apiItems, chainId, prices, additiona
|
|
|
20663
21195
|
borrowCollateralFactor: selfMaxLtv,
|
|
20664
21196
|
collateralFactor: selfLt,
|
|
20665
21197
|
borrowFactor: 1,
|
|
21198
|
+
liquidationPenalty: selfLiquidationPenalty,
|
|
21199
|
+
closeFactor: 1,
|
|
20666
21200
|
collateralDisabled: !collateralActive,
|
|
20667
21201
|
debtDisabled: !borrowingEnabled
|
|
20668
21202
|
}
|
|
20669
21203
|
},
|
|
21204
|
+
closeFactor: 1,
|
|
20670
21205
|
collateralActive,
|
|
20671
21206
|
borrowingEnabled,
|
|
20672
21207
|
depositsEnabled: true,
|
|
@@ -20757,6 +21292,9 @@ function convertSiloV3MarketsToPublicResponse(apiItems, chainId, prices, additio
|
|
|
20757
21292
|
const selfLt = bigintToLtv2(api.lt ?? self.lt);
|
|
20758
21293
|
const selfMaxLtv = bigintToLtv2(api.maxLtv ?? self.maxLtv);
|
|
20759
21294
|
const otherLt = bigintToLtv2(otherApi.lt ?? other.lt);
|
|
21295
|
+
const selfLiquidationPenalty = bigintToLtv2(
|
|
21296
|
+
api.liquidationFee ?? self.liquidationFee
|
|
21297
|
+
);
|
|
20760
21298
|
const collateralActive = selfLt > 0;
|
|
20761
21299
|
const borrowingEnabled = otherLt > 0;
|
|
20762
21300
|
const siloAddrLc = self.silo.toLowerCase();
|
|
@@ -20797,10 +21335,13 @@ function convertSiloV3MarketsToPublicResponse(apiItems, chainId, prices, additio
|
|
|
20797
21335
|
borrowCollateralFactor: selfMaxLtv,
|
|
20798
21336
|
collateralFactor: selfLt,
|
|
20799
21337
|
borrowFactor: 1,
|
|
21338
|
+
liquidationPenalty: selfLiquidationPenalty,
|
|
21339
|
+
closeFactor: 1,
|
|
20800
21340
|
collateralDisabled: !collateralActive,
|
|
20801
21341
|
debtDisabled: !borrowingEnabled
|
|
20802
21342
|
}
|
|
20803
21343
|
},
|
|
21344
|
+
closeFactor: 1,
|
|
20804
21345
|
collateralActive,
|
|
20805
21346
|
borrowingEnabled,
|
|
20806
21347
|
depositsEnabled: true,
|
|
@@ -20968,6 +21509,7 @@ function convertDolomiteSubgraphMarkets(raw, chainId, prices, additionalYields,
|
|
|
20968
21509
|
intrinsicYield: additionalYields?.intrinsicYields?.[underlying] ?? 0,
|
|
20969
21510
|
rewards: [],
|
|
20970
21511
|
config,
|
|
21512
|
+
closeFactor: 1,
|
|
20971
21513
|
borrowingEnabled: !isClosing,
|
|
20972
21514
|
depositsEnabled: !isClosing
|
|
20973
21515
|
};
|
|
@@ -22486,6 +23028,7 @@ function decodePackedListaUserDataset(hex, marketsCount) {
|
|
|
22486
23028
|
balances
|
|
22487
23029
|
};
|
|
22488
23030
|
}
|
|
23031
|
+
var LISTA_DYNAMIC_LOAN_ID = (2n ** 128n - 1n).toString();
|
|
22489
23032
|
var CHUNK_SIZE = 100;
|
|
22490
23033
|
function createLenderKey(lender, marketId) {
|
|
22491
23034
|
if (marketId.startsWith(lender)) return marketId;
|
|
@@ -22627,11 +23170,17 @@ var getListaUserDataConverterWithlens = (lender, chainId, account, markets, meta
|
|
|
22627
23170
|
const marketId = markets[mapMarketToChunk(balanceData2.index, i)];
|
|
22628
23171
|
marketsHandled.push(marketId);
|
|
22629
23172
|
const lenderKey = createLenderKey(lender, marketId);
|
|
23173
|
+
const brokerData = getCachedListaBrokerUserData(
|
|
23174
|
+
chainId,
|
|
23175
|
+
account,
|
|
23176
|
+
marketId
|
|
23177
|
+
);
|
|
22630
23178
|
const { dataForMarket, addedDebt, addedDeposits } = createMorphoEntryFromMarketWithLens(
|
|
22631
23179
|
balanceData2,
|
|
22632
23180
|
metaMap?.[lenderKey],
|
|
22633
23181
|
chainId,
|
|
22634
|
-
lenderKey
|
|
23182
|
+
lenderKey,
|
|
23183
|
+
brokerData
|
|
22635
23184
|
);
|
|
22636
23185
|
const payload = {
|
|
22637
23186
|
chainId,
|
|
@@ -22669,7 +23218,7 @@ var getListaUserDataConverterWithlens = (lender, chainId, account, markets, meta
|
|
|
22669
23218
|
expectedNumberOfCalls
|
|
22670
23219
|
];
|
|
22671
23220
|
};
|
|
22672
|
-
function createMorphoEntryFromMarketWithLens(balanceInfo, metaMap, chainId, lenderKey) {
|
|
23221
|
+
function createMorphoEntryFromMarketWithLens(balanceInfo, metaMap, chainId, lenderKey, brokerData) {
|
|
22673
23222
|
const morphoPair = metaMap;
|
|
22674
23223
|
const _assets = Object.entries(
|
|
22675
23224
|
morphoPair ?? {}
|
|
@@ -22749,13 +23298,75 @@ function createMorphoEntryFromMarketWithLens(balanceInfo, metaMap, chainId, lend
|
|
|
22749
23298
|
collateralEnabled: true,
|
|
22750
23299
|
claimableRewards: 0
|
|
22751
23300
|
};
|
|
23301
|
+
const loanMarketUid = dataForLoanAsset.marketUid;
|
|
23302
|
+
const loanDecimals = loanAsset?.decimals ?? 18;
|
|
23303
|
+
const termPositions = {};
|
|
23304
|
+
let aggregateDebtToken = borrowDec;
|
|
23305
|
+
if (brokerData) {
|
|
23306
|
+
const mkTermPosition = (key, debtToken, term) => {
|
|
23307
|
+
termPositions[key] = {
|
|
23308
|
+
marketUid: loanMarketUid,
|
|
23309
|
+
underlying: loanAddress,
|
|
23310
|
+
loanId: term.loanId,
|
|
23311
|
+
deposits: "0",
|
|
23312
|
+
// fixed loans sit in the stable slot, the dynamic loan in the variable slot
|
|
23313
|
+
debt: term.isDynamic ? debtToken : "0",
|
|
23314
|
+
debtStable: term.isDynamic ? "0" : debtToken,
|
|
23315
|
+
depositsUSD: 0,
|
|
23316
|
+
debtUSD: term.isDynamic ? Number(debtToken) * priceLoan : 0,
|
|
23317
|
+
debtStableUSD: term.isDynamic ? 0 : Number(debtToken) * priceLoan,
|
|
23318
|
+
depositsUSDOracle: 0,
|
|
23319
|
+
debtUSDOracle: term.isDynamic ? Number(debtToken) * oraclePriceLoan : 0,
|
|
23320
|
+
debtStableUSDOracle: term.isDynamic ? 0 : Number(debtToken) * oraclePriceLoan,
|
|
23321
|
+
collateralEnabled: false,
|
|
23322
|
+
claimableRewards: 0,
|
|
23323
|
+
term
|
|
23324
|
+
};
|
|
23325
|
+
};
|
|
23326
|
+
let sumFixedRaw = 0n;
|
|
23327
|
+
for (const loan of brokerData.fixedLoans) {
|
|
23328
|
+
const trancheRaw = BigInt(loan.outstanding) + BigInt(loan.accruedInterest);
|
|
23329
|
+
sumFixedRaw += trancheRaw;
|
|
23330
|
+
const trancheToken = parseRawAmount(trancheRaw.toString(), loanDecimals);
|
|
23331
|
+
mkTermPosition(`${loanMarketUid}#${loan.posId}`, trancheToken, {
|
|
23332
|
+
loanId: loan.posId,
|
|
23333
|
+
termId: loan.termId,
|
|
23334
|
+
debt: trancheToken,
|
|
23335
|
+
aprFraction: loan.aprFraction,
|
|
23336
|
+
maturity: loan.end,
|
|
23337
|
+
termDays: loan.termDays,
|
|
23338
|
+
accruedInterest: parseRawAmount(loan.accruedInterest, loanDecimals),
|
|
23339
|
+
earlyRepayPenalty: parseRawAmount(loan.earlyRepayPenalty, loanDecimals),
|
|
23340
|
+
isMatured: loan.isMatured
|
|
23341
|
+
});
|
|
23342
|
+
}
|
|
23343
|
+
const totalRaw = BigInt(brokerData.totalDebt);
|
|
23344
|
+
const dynRaw = totalRaw > sumFixedRaw ? totalRaw - sumFixedRaw : 0n;
|
|
23345
|
+
const dynToken = parseRawAmount(dynRaw.toString(), loanDecimals);
|
|
23346
|
+
const fixedToken = parseRawAmount(sumFixedRaw.toString(), loanDecimals);
|
|
23347
|
+
dataForLoanAsset.debt = dynToken;
|
|
23348
|
+
dataForLoanAsset.debtUSD = Number(dynToken) * priceLoan;
|
|
23349
|
+
dataForLoanAsset.debtUSDOracle = Number(dynToken) * oraclePriceLoan;
|
|
23350
|
+
dataForLoanAsset.debtStable = fixedToken;
|
|
23351
|
+
dataForLoanAsset.debtStableUSD = Number(fixedToken) * priceLoan;
|
|
23352
|
+
dataForLoanAsset.debtStableUSDOracle = Number(fixedToken) * oraclePriceLoan;
|
|
23353
|
+
aggregateDebtToken = parseRawAmount(totalRaw.toString(), loanDecimals);
|
|
23354
|
+
if (dynRaw > 0n) {
|
|
23355
|
+
mkTermPosition(`${loanMarketUid}#dynamic`, dynToken, {
|
|
23356
|
+
loanId: LISTA_DYNAMIC_LOAN_ID,
|
|
23357
|
+
isDynamic: true,
|
|
23358
|
+
debt: dynToken
|
|
23359
|
+
});
|
|
23360
|
+
}
|
|
23361
|
+
}
|
|
22752
23362
|
return {
|
|
22753
23363
|
dataForMarket: {
|
|
22754
23364
|
[loanKey]: dataForLoanAsset,
|
|
22755
|
-
[collateralKey]: dataForCollateralAsset
|
|
23365
|
+
[collateralKey]: dataForCollateralAsset,
|
|
23366
|
+
...termPositions
|
|
22756
23367
|
},
|
|
22757
23368
|
addedDeposits: Number(loanDepositNumber) * priceHistLoan + Number(collateralDec) * priceHist,
|
|
22758
|
-
addedDebt: Number(
|
|
23369
|
+
addedDebt: Number(aggregateDebtToken) * priceHistLoan
|
|
22759
23370
|
};
|
|
22760
23371
|
}
|
|
22761
23372
|
|
|
@@ -24184,9 +24795,9 @@ var MULTICALL_ADDRESS = {
|
|
|
24184
24795
|
// src/utils/multicall.ts
|
|
24185
24796
|
var { isArray } = lodash;
|
|
24186
24797
|
var maxRetries = 3;
|
|
24187
|
-
var multicallViemAbiArray = async (chainId, abi, calls,
|
|
24798
|
+
var multicallViemAbiArray = async (chainId, abi, calls, getEvmClient16, retry = true, providerId = 0, retries = maxRetries, allowFailure = true, batchSize = MULTICALL_DEFAULT_BATCH_SIZE, logs = false) => {
|
|
24188
24799
|
try {
|
|
24189
|
-
const provider =
|
|
24800
|
+
const provider = getEvmClient16(chainId, providerId);
|
|
24190
24801
|
const abiIsArray = isArray(abi[0]);
|
|
24191
24802
|
const returnData = await provider.multicall({
|
|
24192
24803
|
allowFailure,
|
|
@@ -24212,7 +24823,7 @@ var multicallViemAbiArray = async (chainId, abi, calls, getEvmClient14, retry =
|
|
|
24212
24823
|
chainId,
|
|
24213
24824
|
abi,
|
|
24214
24825
|
calls,
|
|
24215
|
-
|
|
24826
|
+
getEvmClient16,
|
|
24216
24827
|
retry,
|
|
24217
24828
|
providerId,
|
|
24218
24829
|
retries,
|
|
@@ -28540,29 +29151,6 @@ var YLDRAbi = [
|
|
|
28540
29151
|
}
|
|
28541
29152
|
];
|
|
28542
29153
|
|
|
28543
|
-
// src/abis/compound-v2/Comptroller.ts
|
|
28544
|
-
var ComptrollerAbi = [
|
|
28545
|
-
{
|
|
28546
|
-
inputs: [
|
|
28547
|
-
{
|
|
28548
|
-
internalType: "address",
|
|
28549
|
-
name: "account",
|
|
28550
|
-
type: "address"
|
|
28551
|
-
}
|
|
28552
|
-
],
|
|
28553
|
-
name: "getAssetsIn",
|
|
28554
|
-
outputs: [
|
|
28555
|
-
{
|
|
28556
|
-
internalType: "contract CToken[]",
|
|
28557
|
-
name: "",
|
|
28558
|
-
type: "address[]"
|
|
28559
|
-
}
|
|
28560
|
-
],
|
|
28561
|
-
stateMutability: "view",
|
|
28562
|
-
type: "function"
|
|
28563
|
-
}
|
|
28564
|
-
];
|
|
28565
|
-
|
|
28566
29154
|
// src/abis/compound-v2/CollateralToken.ts
|
|
28567
29155
|
var CompoundV2CollateralToken = [
|
|
28568
29156
|
{
|
|
@@ -28835,7 +29423,7 @@ function unflattenLenderData(pools) {
|
|
|
28835
29423
|
}
|
|
28836
29424
|
return result;
|
|
28837
29425
|
}
|
|
28838
|
-
var getLenderUserDataResult = async (chainId, queriesRaw,
|
|
29426
|
+
var getLenderUserDataResult = async (chainId, queriesRaw, getEvmClient16, allowFailure = true, batchSize = MULTICALL_DEFAULT_BATCH_SIZE, retries = 3, logs = false) => {
|
|
28839
29427
|
const queries = organizeUserQueries(queriesRaw);
|
|
28840
29428
|
const builtCalls = await Promise.all(
|
|
28841
29429
|
queries.map(async (query3) => {
|
|
@@ -28854,7 +29442,7 @@ var getLenderUserDataResult = async (chainId, queriesRaw, getEvmClient14, allowF
|
|
|
28854
29442
|
chainId,
|
|
28855
29443
|
calls.map((call) => call.abi),
|
|
28856
29444
|
calls.map((call) => call.call),
|
|
28857
|
-
|
|
29445
|
+
getEvmClient16,
|
|
28858
29446
|
true,
|
|
28859
29447
|
0,
|
|
28860
29448
|
retries,
|
|
@@ -40478,6 +41066,273 @@ var resolveYieldApr = async (entries) => {
|
|
|
40478
41066
|
}
|
|
40479
41067
|
return apr;
|
|
40480
41068
|
};
|
|
41069
|
+
var VALIDATOR_SET = "0x0000000000000000000000000000000000001000";
|
|
41070
|
+
var CANDIDATE_HUB = "0x0000000000000000000000000000000000001005";
|
|
41071
|
+
var GET_VALIDATORS_ABI = [
|
|
41072
|
+
{
|
|
41073
|
+
name: "getValidators",
|
|
41074
|
+
type: "function",
|
|
41075
|
+
stateMutability: "view",
|
|
41076
|
+
inputs: [],
|
|
41077
|
+
outputs: [{ type: "address[]" }]
|
|
41078
|
+
}
|
|
41079
|
+
];
|
|
41080
|
+
var GET_CANDIDATES_ABI = [
|
|
41081
|
+
{
|
|
41082
|
+
name: "getCandidates",
|
|
41083
|
+
type: "function",
|
|
41084
|
+
stateMutability: "view",
|
|
41085
|
+
inputs: [],
|
|
41086
|
+
outputs: [{ type: "address[]" }]
|
|
41087
|
+
}
|
|
41088
|
+
];
|
|
41089
|
+
var getCoreValidators = async (maxRpcTries = 4) => {
|
|
41090
|
+
let lastErr;
|
|
41091
|
+
for (let rpcId = 0; rpcId < maxRpcTries; rpcId++) {
|
|
41092
|
+
try {
|
|
41093
|
+
const client = getEvmClient(Chain.CORE_BLOCKCHAIN_MAINNET, rpcId);
|
|
41094
|
+
const [validators, candidates] = await Promise.all([
|
|
41095
|
+
client.readContract({
|
|
41096
|
+
address: VALIDATOR_SET,
|
|
41097
|
+
abi: GET_VALIDATORS_ABI,
|
|
41098
|
+
functionName: "getValidators"
|
|
41099
|
+
}),
|
|
41100
|
+
client.readContract({
|
|
41101
|
+
address: CANDIDATE_HUB,
|
|
41102
|
+
abi: GET_CANDIDATES_ABI,
|
|
41103
|
+
functionName: "getCandidates"
|
|
41104
|
+
})
|
|
41105
|
+
]);
|
|
41106
|
+
return {
|
|
41107
|
+
validators: [...validators],
|
|
41108
|
+
candidates: [...candidates]
|
|
41109
|
+
};
|
|
41110
|
+
} catch (e) {
|
|
41111
|
+
lastErr = e;
|
|
41112
|
+
}
|
|
41113
|
+
}
|
|
41114
|
+
throw new Error(
|
|
41115
|
+
`getCoreValidators: all Core RPCs failed (${String(lastErr)})`
|
|
41116
|
+
);
|
|
41117
|
+
};
|
|
41118
|
+
var REGISTRY = "0x000000000000000000000000000000000000ce10";
|
|
41119
|
+
var STCELO_MANAGER = "0x0239b96d10a434a56cc9e09383077a0490cf9398";
|
|
41120
|
+
var REGISTRY_ABI = [
|
|
41121
|
+
{
|
|
41122
|
+
name: "getAddressForString",
|
|
41123
|
+
type: "function",
|
|
41124
|
+
stateMutability: "view",
|
|
41125
|
+
inputs: [{ type: "string", name: "identifier" }],
|
|
41126
|
+
outputs: [{ type: "address" }]
|
|
41127
|
+
}
|
|
41128
|
+
];
|
|
41129
|
+
var ELECTION_ABI = [
|
|
41130
|
+
{
|
|
41131
|
+
name: "getEligibleValidatorGroups",
|
|
41132
|
+
type: "function",
|
|
41133
|
+
stateMutability: "view",
|
|
41134
|
+
inputs: [],
|
|
41135
|
+
outputs: [{ type: "address[]" }]
|
|
41136
|
+
}
|
|
41137
|
+
];
|
|
41138
|
+
var MANAGER_ABI = [
|
|
41139
|
+
{
|
|
41140
|
+
name: "groupHealth",
|
|
41141
|
+
type: "function",
|
|
41142
|
+
stateMutability: "view",
|
|
41143
|
+
inputs: [],
|
|
41144
|
+
outputs: [{ type: "address" }]
|
|
41145
|
+
},
|
|
41146
|
+
{
|
|
41147
|
+
name: "getReceivableVotesForGroup",
|
|
41148
|
+
type: "function",
|
|
41149
|
+
stateMutability: "view",
|
|
41150
|
+
inputs: [{ type: "address", name: "group" }],
|
|
41151
|
+
outputs: [{ type: "uint256" }]
|
|
41152
|
+
},
|
|
41153
|
+
{
|
|
41154
|
+
name: "getAddressStrategy",
|
|
41155
|
+
type: "function",
|
|
41156
|
+
stateMutability: "view",
|
|
41157
|
+
inputs: [{ type: "address", name: "accountAddress" }],
|
|
41158
|
+
outputs: [{ type: "address" }]
|
|
41159
|
+
}
|
|
41160
|
+
];
|
|
41161
|
+
var GROUP_HEALTH_ABI = [
|
|
41162
|
+
{
|
|
41163
|
+
name: "isGroupValid",
|
|
41164
|
+
type: "function",
|
|
41165
|
+
stateMutability: "view",
|
|
41166
|
+
inputs: [{ type: "address", name: "group" }],
|
|
41167
|
+
outputs: [{ type: "bool" }]
|
|
41168
|
+
}
|
|
41169
|
+
];
|
|
41170
|
+
var getStCeloValidatorGroups = async (maxRpcTries = 4) => {
|
|
41171
|
+
let lastErr;
|
|
41172
|
+
for (let rpcId = 0; rpcId < maxRpcTries; rpcId++) {
|
|
41173
|
+
try {
|
|
41174
|
+
const client = getEvmClient(Chain.CELO_MAINNET, rpcId);
|
|
41175
|
+
const [electionAddr, groupHealthAddr] = await Promise.all([
|
|
41176
|
+
client.readContract({
|
|
41177
|
+
address: REGISTRY,
|
|
41178
|
+
abi: REGISTRY_ABI,
|
|
41179
|
+
functionName: "getAddressForString",
|
|
41180
|
+
args: ["Election"]
|
|
41181
|
+
}),
|
|
41182
|
+
client.readContract({
|
|
41183
|
+
address: STCELO_MANAGER,
|
|
41184
|
+
abi: MANAGER_ABI,
|
|
41185
|
+
functionName: "groupHealth"
|
|
41186
|
+
})
|
|
41187
|
+
]);
|
|
41188
|
+
const eligible = await client.readContract({
|
|
41189
|
+
address: electionAddr,
|
|
41190
|
+
abi: ELECTION_ABI,
|
|
41191
|
+
functionName: "getEligibleValidatorGroups"
|
|
41192
|
+
});
|
|
41193
|
+
if (eligible.length === 0) return [];
|
|
41194
|
+
const [healthFlags, capacities] = await Promise.all([
|
|
41195
|
+
client.multicall({
|
|
41196
|
+
allowFailure: true,
|
|
41197
|
+
contracts: eligible.map((group) => ({
|
|
41198
|
+
address: groupHealthAddr,
|
|
41199
|
+
abi: GROUP_HEALTH_ABI,
|
|
41200
|
+
functionName: "isGroupValid",
|
|
41201
|
+
args: [group]
|
|
41202
|
+
}))
|
|
41203
|
+
}),
|
|
41204
|
+
client.multicall({
|
|
41205
|
+
allowFailure: true,
|
|
41206
|
+
contracts: eligible.map((group) => ({
|
|
41207
|
+
address: STCELO_MANAGER,
|
|
41208
|
+
abi: MANAGER_ABI,
|
|
41209
|
+
functionName: "getReceivableVotesForGroup",
|
|
41210
|
+
args: [group]
|
|
41211
|
+
}))
|
|
41212
|
+
})
|
|
41213
|
+
]);
|
|
41214
|
+
return eligible.map((group, i) => ({
|
|
41215
|
+
group,
|
|
41216
|
+
isValid: healthFlags[i].status === "success" && healthFlags[i].result === true,
|
|
41217
|
+
receivableVotes: capacities[i].status === "success" ? capacities[i].result : 0n
|
|
41218
|
+
})).filter((g) => g.isValid && g.receivableVotes > 0n).sort((a, b) => b.receivableVotes > a.receivableVotes ? 1 : -1).map((g) => ({
|
|
41219
|
+
group: g.group,
|
|
41220
|
+
receivableVotes: g.receivableVotes.toString()
|
|
41221
|
+
}));
|
|
41222
|
+
} catch (e) {
|
|
41223
|
+
lastErr = e;
|
|
41224
|
+
}
|
|
41225
|
+
}
|
|
41226
|
+
throw new Error(
|
|
41227
|
+
`getStCeloValidatorGroups: all Celo RPCs failed (${String(lastErr)})`
|
|
41228
|
+
);
|
|
41229
|
+
};
|
|
41230
|
+
var STCELO_MANAGER_ADDRESS = "0x0239b96d10a434a56cc9e09383077a0490cf9398";
|
|
41231
|
+
var resolveStCeloDepositGroup = async (user, requestedGroup, maxRpcTries = 4) => {
|
|
41232
|
+
if (requestedGroup !== void 0) {
|
|
41233
|
+
if (!isAddress(requestedGroup))
|
|
41234
|
+
throw new Error(
|
|
41235
|
+
`stCELO validatorGroup must be an address, got ${requestedGroup}`
|
|
41236
|
+
);
|
|
41237
|
+
return getAddress(requestedGroup) === zeroAddress ? void 0 : getAddress(requestedGroup);
|
|
41238
|
+
}
|
|
41239
|
+
for (let rpcId = 0; rpcId < maxRpcTries; rpcId++) {
|
|
41240
|
+
try {
|
|
41241
|
+
const client = getEvmClient(Chain.CELO_MAINNET, rpcId);
|
|
41242
|
+
const current = await client.readContract({
|
|
41243
|
+
address: STCELO_MANAGER_ADDRESS,
|
|
41244
|
+
abi: MANAGER_ABI,
|
|
41245
|
+
functionName: "getAddressStrategy",
|
|
41246
|
+
args: [user]
|
|
41247
|
+
});
|
|
41248
|
+
if (current && getAddress(current) !== zeroAddress) return void 0;
|
|
41249
|
+
const groups = await getStCeloValidatorGroups(maxRpcTries);
|
|
41250
|
+
return groups[0]?.group;
|
|
41251
|
+
} catch (e) {
|
|
41252
|
+
}
|
|
41253
|
+
}
|
|
41254
|
+
return void 0;
|
|
41255
|
+
};
|
|
41256
|
+
|
|
41257
|
+
// src/vaults/lst/validators.ts
|
|
41258
|
+
var LST_DELEGATION = {
|
|
41259
|
+
// Core DAO — stCORE `Earn.mint(validator)`: the validator is mandatory.
|
|
41260
|
+
"1116": {
|
|
41261
|
+
"0xb3a8f0f0da9ffc65318aa39e55079796093029ad": {
|
|
41262
|
+
required: true,
|
|
41263
|
+
kind: "validator",
|
|
41264
|
+
optionKey: "validator",
|
|
41265
|
+
default: null,
|
|
41266
|
+
source: "endpoint"
|
|
41267
|
+
}
|
|
41268
|
+
},
|
|
41269
|
+
// Celo — StakedCelo: optional from the integrator's view (the server
|
|
41270
|
+
// auto-resolves a valid group when omitted), but the on-chain default
|
|
41271
|
+
// strategy reverts, so a group must ultimately be chosen.
|
|
41272
|
+
"42220": {
|
|
41273
|
+
"0xc668583dcbdc9ae6fa3ce46462758188adfdfc24": {
|
|
41274
|
+
required: false,
|
|
41275
|
+
kind: "validatorGroup",
|
|
41276
|
+
optionKey: "validatorGroup",
|
|
41277
|
+
default: "auto",
|
|
41278
|
+
source: "endpoint"
|
|
41279
|
+
}
|
|
41280
|
+
},
|
|
41281
|
+
// Solv (Ethereum) — SolvBTC / xSolvBTC / BTC+ require an off-chain poolId
|
|
41282
|
+
// (published in Solv's docs), so no on-chain list is returned.
|
|
41283
|
+
"1": {
|
|
41284
|
+
"0x7a56e1c57c7475ccf742a1832b028f0456652f97": {
|
|
41285
|
+
required: true,
|
|
41286
|
+
kind: "pool",
|
|
41287
|
+
optionKey: "poolId",
|
|
41288
|
+
default: null,
|
|
41289
|
+
source: "offchain"
|
|
41290
|
+
},
|
|
41291
|
+
"0xd9d920aa40f578ab794426f5c90f6c731d159def": {
|
|
41292
|
+
required: true,
|
|
41293
|
+
kind: "pool",
|
|
41294
|
+
optionKey: "poolId",
|
|
41295
|
+
default: null,
|
|
41296
|
+
source: "offchain"
|
|
41297
|
+
},
|
|
41298
|
+
"0xcea2daf93617b97504e05affc5bcf9b3922d3034": {
|
|
41299
|
+
required: true,
|
|
41300
|
+
kind: "pool",
|
|
41301
|
+
optionKey: "poolId",
|
|
41302
|
+
default: null,
|
|
41303
|
+
source: "offchain"
|
|
41304
|
+
}
|
|
41305
|
+
}
|
|
41306
|
+
};
|
|
41307
|
+
var getLstDelegation = (chainId, shareToken) => LST_DELEGATION[chainId]?.[shareToken.toLowerCase()];
|
|
41308
|
+
var getLstValidators = async (chainId, shareToken) => {
|
|
41309
|
+
const d = getLstDelegation(chainId, shareToken);
|
|
41310
|
+
if (!d || d.source !== "endpoint") return [];
|
|
41311
|
+
try {
|
|
41312
|
+
if (d.kind === "validatorGroup" && chainId === "42220") {
|
|
41313
|
+
const groups = await getStCeloValidatorGroups();
|
|
41314
|
+
return groups.map((g, i) => ({
|
|
41315
|
+
id: g.group,
|
|
41316
|
+
status: "active",
|
|
41317
|
+
selectable: true,
|
|
41318
|
+
recommended: i === 0,
|
|
41319
|
+
receivableVotes: g.receivableVotes
|
|
41320
|
+
}));
|
|
41321
|
+
}
|
|
41322
|
+
if (d.kind === "validator" && chainId === "1116") {
|
|
41323
|
+
const { validators } = await getCoreValidators();
|
|
41324
|
+
return validators.map((v, i) => ({
|
|
41325
|
+
id: v,
|
|
41326
|
+
status: "active",
|
|
41327
|
+
selectable: true,
|
|
41328
|
+
recommended: i === 0
|
|
41329
|
+
}));
|
|
41330
|
+
}
|
|
41331
|
+
} catch {
|
|
41332
|
+
return [];
|
|
41333
|
+
}
|
|
41334
|
+
return [];
|
|
41335
|
+
};
|
|
40481
41336
|
|
|
40482
41337
|
// src/vaults/lst/fetchPublic.ts
|
|
40483
41338
|
var ONE_E188 = 10n ** 18n;
|
|
@@ -40497,7 +41352,7 @@ var resolveAcceptedInputs = (chainId, shareToken, entry) => {
|
|
|
40497
41352
|
}
|
|
40498
41353
|
];
|
|
40499
41354
|
};
|
|
40500
|
-
var fetchLstShareTokens = async (chainId, multicallRetry, prices = {}, tokenList = {}) => {
|
|
41355
|
+
var fetchLstShareTokens = async (chainId, multicallRetry, prices = {}, tokenList = {}, opts = {}) => {
|
|
40501
41356
|
const entries = getLstRegistry(chainId);
|
|
40502
41357
|
if (entries.length === 0) return {};
|
|
40503
41358
|
const readers = entries.map(buildReader);
|
|
@@ -40525,8 +41380,22 @@ var fetchLstShareTokens = async (chainId, multicallRetry, prices = {}, tokenList
|
|
|
40525
41380
|
g.abis.push(allAbis[i]);
|
|
40526
41381
|
g.positions.push(i);
|
|
40527
41382
|
}
|
|
41383
|
+
const delegationByAddress = /* @__PURE__ */ new Map();
|
|
41384
|
+
const validatorJobs = [];
|
|
41385
|
+
for (const e of entries) {
|
|
41386
|
+
const d = getLstDelegation(chainId, e.address);
|
|
41387
|
+
if (!d) continue;
|
|
41388
|
+
delegationByAddress.set(e.address.toLowerCase(), d);
|
|
41389
|
+
if (opts.includeValidators && d.source === "endpoint") {
|
|
41390
|
+
validatorJobs.push(
|
|
41391
|
+
getLstValidators(chainId, e.address).then((v) => [e.address.toLowerCase(), v]).catch(
|
|
41392
|
+
() => [e.address.toLowerCase(), []]
|
|
41393
|
+
)
|
|
41394
|
+
);
|
|
41395
|
+
}
|
|
41396
|
+
}
|
|
40528
41397
|
const chainEntries = Object.entries(groups);
|
|
40529
|
-
const [perChainResults, aprByAddress, idleResults] = await Promise.all([
|
|
41398
|
+
const [perChainResults, aprByAddress, idleResults, validatorEntries] = await Promise.all([
|
|
40530
41399
|
chainEntries.length > 0 ? Promise.all(
|
|
40531
41400
|
chainEntries.map(async ([chain, { calls, abis }]) => ({
|
|
40532
41401
|
chain,
|
|
@@ -40543,8 +41412,10 @@ var fetchLstShareTokens = async (chainId, multicallRetry, prices = {}, tokenList
|
|
|
40543
41412
|
calls: idleCalls,
|
|
40544
41413
|
abi: idleAbis,
|
|
40545
41414
|
allowFailure: true
|
|
40546
|
-
}) : Promise.resolve([])
|
|
41415
|
+
}) : Promise.resolve([]),
|
|
41416
|
+
Promise.all(validatorJobs)
|
|
40547
41417
|
]);
|
|
41418
|
+
const validatorsByAddress = new Map(validatorEntries);
|
|
40548
41419
|
const idleByAddress = /* @__PURE__ */ new Map();
|
|
40549
41420
|
idleEntries.forEach((e, i) => {
|
|
40550
41421
|
const bal = toBigInt10(idleResults[i]);
|
|
@@ -40624,6 +41495,8 @@ var fetchLstShareTokens = async (chainId, multicallRetry, prices = {}, tokenList
|
|
|
40624
41495
|
mintContract: entry.mintContract?.toLowerCase(),
|
|
40625
41496
|
mintInputAsset: entry.mintInputAsset === void 0 ? void 0 : entry.mintInputAsset === "native" ? "native" : entry.mintInputAsset.toLowerCase(),
|
|
40626
41497
|
acceptedInputs: resolveAcceptedInputs(chainId, addressLc, entry),
|
|
41498
|
+
delegation: delegationByAddress.get(addressLc),
|
|
41499
|
+
validators: validatorsByAddress.get(addressLc),
|
|
40627
41500
|
withdrawalMode: entry.withdrawalMode,
|
|
40628
41501
|
withdrawalCooldownSeconds: entry.withdrawalCooldownSeconds,
|
|
40629
41502
|
asset,
|
|
@@ -46794,6 +47667,6 @@ async function fetchTokenBalances(chainId, account, tokens, options = {}) {
|
|
|
46794
47667
|
return parseTokenBalanceResult(rawResult, prepared.query);
|
|
46795
47668
|
}
|
|
46796
47669
|
|
|
46797
|
-
export { EMPTY_BALANCE, GMX_API_HOSTS, GMX_READ_CONTRACTS, GMX_SUPPORTED_CHAINS, HYPERCORE_VAULT_REGISTRY, IDLE_MARKET_ID, INTERFACE_IDS, LAGOON_API_URL, LAGOON_CHAIN_IDS, MORPHO_LENS, MaxParamThresholds, STABLECOIN_SYMBOLS, VAULT_SHARE_PRICE_PROBE, VOLATILE_VAULT_OVERRIDES, YEARN_CHAIN_IDS, YEARN_YDAEMON_BASE, accountDepositListKey, accountWithdrawalListKey, appendSnapshot, applyPositionDelta, attachPricesToFlashLiquidity, buildFluidFTokensCall, buildLoopResult, buildMorphoTypeCall, buildMorphoTypeUserCallWithLens, buildPortfolioTotals, buildSumerAccumulators, buildSummaries, buildVaultLookup, calculateLeverage, calculateNetApr, calculateOverallNetApr, calculateWeightedAverage, classifyVault, computeBorrowDelta2 as computeBorrowDelta, computeCloseTradeDeltas, computeCollateralSwapDeltas, computeDebtSwapDeltas, computeDepositDelta2 as computeDepositDelta, computeEModeAnalysis, computeOpenTradeDeltas, computePostTradeMetrics, computeRepayDelta2 as computeRepayDelta, computeSumerBorrowDelta, computeSumerDepositDelta, computeSumerRepayDelta, computeSumerWaterfall, computeSumerWithdrawDelta, computeVaultApr, computeWithdrawDelta2 as computeWithdrawDelta, computeZapTradeDeltas, convertLenderUserDataResult, createMarketUid, createMulticallRpcCall, createRawRpcCalls, decodeListaMarkets, decodeMarkets, decodePackedListaUserDataset, decodePackedMorphoUserDataset, detectInterfaceKinds, encodeBalanceFetcherCalldata, fetchDolomiteAccountNumbers, fetchEulerEarnVaults, fetchEulerEarnVaultsFromSubgraph, fetchEulerSubAccountIndexes, fetchFlashLiquidityForChain, fetchFluidFTokens, fetchGeneralYields, fetchGeneralYieldsByMarketUid, fetchGmxExecutionFees, fetchGmxTickerPrices, fetchGmxVaults, fetchHypercoreVaults, fetchLagoonApiVaults, fetchLagoonVaults, fetchListaVaultsFromChain, fetchMorphoUserBalances, fetchMorphoUserPositionMarkets, fetchMorphoVaults, fetchMorphoVaultsFromApi, fetchMorphoVaultsFromChain, fetchOraclePrices, fetchPendlePrices, fetchSiloVaults, fetchTokenBalances, fetchTokenMetadata, fetchYearnApiVaults, fetchYearnVaults, filterActiveLenders, filterLendersByProtocol, fuseLenderData, generateLendingPools, getAavesForChain, getAssetConfig, getBalanceForMarketUid, getBorrowCapacity, getFluidFTokensConverter, getGmxApiHost, getGmxReadContracts, getGmxUserPositions, getHealthFactor, getHypercoreUserPositions, getHypercoreVaultRegistry, getLenderAssets, getLenderPublicData, getLenderPublicDataAll, getLenderPublicDataViaApi, getLenderUserDataMulti, getLenderUserDataResult, getLendersForChain, getLstWithdrawalRegistry, getLstWithdrawalRequests, getMaxAmountClose, getMaxAmountCollateralSwap, getMaxAmountDebtSwap, getMaxAmountOpen, getMergedUserData, getMorphoTypeMarketConverter, getResolvedDolomiteAccountNumbers, getSubAccountAddress, getSubAccountIndex, getVaultPublicDataAll, getVaultWithdrawalRequests, hasEulerEarnVaultSubgraph, hasLagoonVaults, hasMorphoPositionIndex, hasMorphoUserApi, hasMorphoUserSubgraph, hasYearnVaults, isStablecoinSymbol, isYearnV3, keysFromMaps, multicall3Abi, nanTo, needsLenderApproval, needsTokenApproval, noOpResult, normalizeToBytes, parseBalanceFetcherResult, parseMergedResult, parseMulticallRpcResponses, parseRawRpcBatchResponses, parseRawRpcResponses, parseTokenBalanceResult, positivePart2 as positivePart, prepareLenderUserDataRpcCalls, prepareMergedMulticallParams, prepareMergedRpcCalls, prepareMulticallInputs, prepareTokenBalanceRpcCalls, priceGlvVaults, priceGmMarkets, readVaultSharePrices, selectAssetGroupPrices, stampVaultClassification, unflattenLenderData };
|
|
47670
|
+
export { EMPTY_BALANCE, GMX_API_HOSTS, GMX_READ_CONTRACTS, GMX_SUPPORTED_CHAINS, HYPERCORE_VAULT_REGISTRY, IDLE_MARKET_ID, INTERFACE_IDS, LAGOON_API_URL, LAGOON_CHAIN_IDS, MORPHO_LENS, MaxParamThresholds, STABLECOIN_SYMBOLS, STCELO_MANAGER_ADDRESS, VAULT_SHARE_PRICE_PROBE, VOLATILE_VAULT_OVERRIDES, YEARN_CHAIN_IDS, YEARN_YDAEMON_BASE, accountDepositListKey, accountWithdrawalListKey, appendSnapshot, applyPositionDelta, attachPricesToFlashLiquidity, buildFluidFTokensCall, buildLoopResult, buildMorphoTypeCall, buildMorphoTypeUserCallWithLens, buildPortfolioTotals, buildSumerAccumulators, buildSummaries, buildVaultLookup, calculateLeverage, calculateNetApr, calculateOverallNetApr, calculateWeightedAverage, classifyVault, computeBorrowDelta2 as computeBorrowDelta, computeCloseTradeDeltas, computeCollateralSwapDeltas, computeDebtSwapDeltas, computeDepositDelta2 as computeDepositDelta, computeEModeAnalysis, computeOpenTradeDeltas, computePostTradeMetrics, computeRepayDelta2 as computeRepayDelta, computeSumerBorrowDelta, computeSumerDepositDelta, computeSumerRepayDelta, computeSumerWaterfall, computeSumerWithdrawDelta, computeVaultApr, computeWithdrawDelta2 as computeWithdrawDelta, computeZapTradeDeltas, convertLenderUserDataResult, createMarketUid, createMulticallRpcCall, createRawRpcCalls, decodeListaMarkets, decodeMarkets, decodePackedListaUserDataset, decodePackedMorphoUserDataset, detectInterfaceKinds, encodeBalanceFetcherCalldata, fetchDolomiteAccountNumbers, fetchEulerEarnVaults, fetchEulerEarnVaultsFromSubgraph, fetchEulerSubAccountIndexes, fetchFlashLiquidityForChain, fetchFluidFTokens, fetchGeneralYields, fetchGeneralYieldsByMarketUid, fetchGmxExecutionFees, fetchGmxTickerPrices, fetchGmxVaults, fetchHypercoreVaults, fetchLagoonApiVaults, fetchLagoonVaults, fetchListaVaultsFromChain, fetchMorphoUserBalances, fetchMorphoUserPositionMarkets, fetchMorphoVaults, fetchMorphoVaultsFromApi, fetchMorphoVaultsFromChain, fetchOraclePrices, fetchPendlePrices, fetchSiloVaults, fetchTokenBalances, fetchTokenMetadata, fetchYearnApiVaults, fetchYearnVaults, filterActiveLenders, filterLendersByProtocol, fuseLenderData, generateLendingPools, getAavesForChain, getAssetConfig, getBalanceForMarketUid, getBorrowCapacity, getCoreValidators, getFluidFTokensConverter, getGmxApiHost, getGmxReadContracts, getGmxUserPositions, getHealthFactor, getHypercoreUserPositions, getHypercoreVaultRegistry, getLenderAssets, getLenderPublicData, getLenderPublicDataAll, getLenderPublicDataViaApi, getLenderUserDataMulti, getLenderUserDataResult, getLendersForChain, getLstDelegation, getLstValidators, getLstWithdrawalRegistry, getLstWithdrawalRequests, getMaxAmountClose, getMaxAmountCollateralSwap, getMaxAmountDebtSwap, getMaxAmountOpen, getMergedUserData, getMorphoTypeMarketConverter, getResolvedDolomiteAccountNumbers, getStCeloValidatorGroups, getSubAccountAddress, getSubAccountIndex, getVaultPublicDataAll, getVaultWithdrawalRequests, hasEulerEarnVaultSubgraph, hasLagoonVaults, hasMorphoPositionIndex, hasMorphoUserApi, hasMorphoUserSubgraph, hasYearnVaults, isStablecoinSymbol, isYearnV3, keysFromMaps, multicall3Abi, nanTo, needsLenderApproval, needsTokenApproval, noOpResult, normalizeToBytes, parseBalanceFetcherResult, parseMergedResult, parseMulticallRpcResponses, parseRawRpcBatchResponses, parseRawRpcResponses, parseTokenBalanceResult, positivePart2 as positivePart, prepareLenderUserDataRpcCalls, prepareMergedMulticallParams, prepareMergedRpcCalls, prepareMulticallInputs, prepareTokenBalanceRpcCalls, priceGlvVaults, priceGmMarkets, readVaultSharePrices, resolveStCeloDepositGroup, selectAssetGroupPrices, stampVaultClassification, unflattenLenderData };
|
|
46798
47671
|
//# sourceMappingURL=index.js.map
|
|
46799
47672
|
//# sourceMappingURL=index.js.map
|