@1delta/margin-fetcher 5.0.23 → 5.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +283 -2
- package/dist/index.js +902 -236
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { parseAbi, keccak256, encodeAbiParameters, formatEther, BaseError, erc20Abi, stringToHex, isAddress, pad, encodeFunctionData, formatUnits, getAddress, decodeFunctionResult, decodeAbiParameters, concat, AbiEncodingLengthMismatchError, concatHex, toBytes, slice, hexToString, InvalidAddressError, boolToHex, integerRegex, numberToHex, bytesRegex, BytesSizeMismatchError, arrayRegex, UnsupportedPackedAbiType } from './chunk-YILYOOYB.js';
|
|
2
2
|
import './chunk-BYTNVMX7.js';
|
|
3
3
|
import './chunk-PR4QN5HX.js';
|
|
4
|
-
import { Lender, isExactly, isMidnight, isTerm, isTermMax, isTeller, isListaDao, isLiquityFamily, isRiver, isInverse, isDssType, isCompoundV3Type, isFluid, isGearboxV3, isLlamaLend, isFrankencoin, isResupply, isCurvance, LIQUITY_FAMILY_LENDERS, isAaveType, isCompoundV3, isMultiMarket, isSiloV2Type, isSiloV3Type, isDolomite, hasCrossMarginRisk, isEulerType, isAaveV4Type, isInit, isMorphoType, isCompoundV2Type, isVenusType, isSumerType, AAVE_V3_LENDERS, AAVE_V2_LENDERS, isAaveV2Type, isAaveV32Type, isAaveV3Type, isUsdd, isSky, isYLDR, isLista, hasSubAccounts, isTectonicType, isKineticType, isBenqiType } from '@1delta/lender-registry';
|
|
4
|
+
import { Lender, isExactly, isMidnight, isTerm, isTermMax, isTeller, isListaDao, isLiquityFamily, isRiver, isInverse, isDssType, isCompoundV3Type, isFluid, isGearboxV3, isLlamaLend, isFrankencoin, isResupply, isCurvance, isFraxlend, LIQUITY_FAMILY_LENDERS, isAaveType, isCompoundV3, isMultiMarket, isSiloV2Type, isSiloV3Type, isDolomite, hasCrossMarginRisk, isEulerType, isAaveV4Type, isInit, isMorphoType, isCompoundV2Type, isVenusType, isSumerType, AAVE_V3_LENDERS, AAVE_V2_LENDERS, isAaveV2Type, isAaveV32Type, isAaveV3Type, isUsdd, isSky, isYLDR, isLista, hasSubAccounts, isTectonicType, isKineticType, isBenqiType } from '@1delta/lender-registry';
|
|
5
5
|
export { hasCrossMarginRisk, isAaveType, isAaveV2Type, isAaveV32Type, isAaveV3Type, isCompoundV3, isCompoundV3Type, isInit, isMorphoType, isMultiMarket, isYLDR } from '@1delta/lender-registry';
|
|
6
|
-
import { fetchTokenLists, fetchTokenList, aavePools, compoundV3Pools, initConfig, morphoPools, compoundV2Pools, eulerVaults, siloMarkets, siloV2LenderKey, siloMarketsV3, siloV3LenderKey, aaveV4Spokes, aaveV4SpokeLenderKey, fluidResolvers, gearboxResolvers, dolomiteConfigs, midnightConfig, termConfig, termMarketsByChain, exactlyConfig, liquityLendersByChain, riverLendersByChain, inverseLendersByChain, llamaLendLendersByChain, usddLendersByChain, skyLendersByChain, frankencoinLendersByChain, resupplyLendersByChain, curvanceLendersByChain, tellerConfigByChain, tellerPoolsByChain, termMaxConfigByChain, aaveReserves, compoundV3Reserves, liquityConfigFor, liquityBranchesByChain, riverConfigFor, riverChainData, termMaxApiBaseUrl, termMaxLenderKey, inverseConfigFor, inverseChainData, llamaLendConfigFor, llamaLendChainData, llamaLendApiBaseUrl, resupplyConfigFor, dssConfigFor, dssChainData, dssDebtToken, dssDebtJoin, frankencoinConfigFor, frankencoinChainData, aaveOracles, morphoTypeMarkets, resolveMidnightApiBase, resolveTermApiBase, llamaLendMarketByVault, getSiloV2MarketEntry, getSiloV3MarketEntry, dolomiteEmode, curvanceConfigFor, aaveTokens, morphoTypeVaults, eulerConfigs, gearboxMarketCompressor, gearboxMarketConfigurators, gearboxV3LenderKey, midnightMarketsByChain, parseAaveV4SpokeLenderKey, gearboxAccountCompressor, compoundV2Tokens, exactlyMarketsByChain, aaveOraclesConfig, compoundV2Oracles, compoundV2TokenArray, compoundV2OraclesConfig, compoundV3OraclesData, compoundV3BaseData, compoundV2Reserves, aaveV4Oracles } from '@1delta/data-sdk';
|
|
6
|
+
import { fetchTokenLists, fetchTokenList, aavePools, compoundV3Pools, initConfig, morphoPools, compoundV2Pools, eulerVaults, siloMarkets, siloV2LenderKey, siloMarketsV3, siloV3LenderKey, aaveV4Spokes, aaveV4SpokeLenderKey, fluidResolvers, gearboxResolvers, dolomiteConfigs, midnightConfig, termConfig, termMarketsByChain, exactlyConfig, liquityLendersByChain, riverLendersByChain, inverseLendersByChain, llamaLendLendersByChain, usddLendersByChain, skyLendersByChain, frankencoinLendersByChain, resupplyLendersByChain, curvanceLendersByChain, tellerConfigByChain, tellerPoolsByChain, termMaxConfigByChain, aaveReserves, compoundV3Reserves, liquityConfigFor, liquityBranchesByChain, riverConfigFor, riverChainData, termMaxApiBaseUrl, termMaxLenderKey, inverseConfigFor, inverseChainData, llamaLendConfigFor, llamaLendChainData, llamaLendApiBaseUrl, resupplyConfigFor, fraxlendConfigFor, dssConfigFor, dssChainData, dssDebtToken, dssDebtJoin, frankencoinConfigFor, frankencoinChainData, aaveOracles, morphoTypeMarkets, resolveMidnightApiBase, resolveTermApiBase, llamaLendMarketByVault, getSiloV2MarketEntry, getSiloV3MarketEntry, dolomiteEmode, curvanceConfigFor, aaveTokens, morphoTypeVaults, eulerConfigs, gearboxMarketCompressor, gearboxMarketConfigurators, gearboxV3LenderKey, midnightMarketsByChain, parseAaveV4SpokeLenderKey, fraxlendPairsFor, gearboxAccountCompressor, compoundV2Tokens, exactlyMarketsByChain, aaveOraclesConfig, compoundV2Oracles, compoundV2TokenArray, compoundV2OraclesConfig, compoundV3OraclesData, compoundV3BaseData, compoundV2Reserves, aaveV4Oracles } from '@1delta/data-sdk';
|
|
7
7
|
import lodash from 'lodash';
|
|
8
8
|
import { Chain } from '@1delta/chain-registry';
|
|
9
9
|
import { multicallRetryUniversal, getEvmClient, getEvmChain, getEvmClientUniversal } from '@1delta/providers';
|
|
10
|
-
import { LiquityTroveManagerAbi, LiquityActivePoolAbi, LiquityStabilityPoolAbi, LiquityPriceFeedAbi, LiquitySortedTrovesAbi, RiverTroveManagerAbi, RiverStabilityPoolAbi, TellerMarketRegistryAbi, TellerV2Abi, InverseMarketAbi, InverseOracleAbi, InverseDbrAbi, Erc20Abi, LlamaLendControllerAbi, LlamaLendControllerV1Abi, LlamaLendControllerV2Abi, LlamaLendVaultAbi, LlamaLendAmmAbi, MetaMorphoAbi, ExactlyPreviewerAbi, ExactlyAuditorAbi, LenderCommitmentGroupAbi, ResupplyRegistryAbi, ResupplyPairAbi, ResupplyUtilitiesAbi, ResupplyRewardHandlerAbi, ResupplyPairEmissionsAbi, ConvexPoolUtilAbi, FrankencoinPositionAbi, FluidLendingResolverAbi, FluidVaultResolverAbi, FluidLiquidityResolverAbi, MoolahVaultAbi, UsddVatAbi, UsddJugAbi, UsddSpotAbi, MorphoLensAbi, AaveV4SpokeAbi, AaveV4OracleAbi, AaveV4HubAbi, DolomiteMarginAbi, GearboxMarketCompressorV310Abi, MorphoBlueAbi, MidnightAbi, TermRepoTokenAbi, TermRepoServicerAbi, TermRepoCollateralManagerAbi, LiquityTroveNFTAbi, LiquityCollSurplusPoolAbi, TellerCollateralManagerAbi, TermMaxViewerAbi, InverseEscrowAbi, CurvanceMarketManagerAbi, CurvanceCTokenAbi, GearboxCreditAccountCompressorV310Abi, UsddCdpManagerAbi, UsddProxyRegistryAbi, CurvanceProtocolReaderAbi, CurvanceCentralRegistryAbi, TermPriceConsumerAbi, CurvanceOracleManagerAbi, TermMaxOracleAggregatorV2Abi } from '@1delta/abis';
|
|
10
|
+
import { LiquityTroveManagerAbi, LiquityActivePoolAbi, LiquityStabilityPoolAbi, LiquityPriceFeedAbi, LiquitySortedTrovesAbi, RiverTroveManagerAbi, RiverStabilityPoolAbi, TellerMarketRegistryAbi, TellerV2Abi, InverseMarketAbi, InverseOracleAbi, InverseDbrAbi, Erc20Abi, LlamaLendControllerAbi, LlamaLendControllerV1Abi, LlamaLendControllerV2Abi, LlamaLendVaultAbi, LlamaLendAmmAbi, MetaMorphoAbi, ExactlyPreviewerAbi, ExactlyAuditorAbi, LenderCommitmentGroupAbi, ResupplyRegistryAbi, ResupplyPairAbi, ResupplyUtilitiesAbi, ResupplyRewardHandlerAbi, ResupplyPairEmissionsAbi, ConvexPoolUtilAbi, FraxlendPairAbi, FrankencoinPositionAbi, FluidLendingResolverAbi, FluidVaultResolverAbi, FluidLiquidityResolverAbi, MoolahVaultAbi, UsddVatAbi, UsddJugAbi, UsddSpotAbi, MorphoLensAbi, AaveV4SpokeAbi, AaveV4OracleAbi, AaveV4HubAbi, DolomiteMarginAbi, GearboxMarketCompressorV310Abi, MorphoBlueAbi, MidnightAbi, TermRepoTokenAbi, TermRepoServicerAbi, TermRepoCollateralManagerAbi, LiquityTroveNFTAbi, LiquityCollSurplusPoolAbi, TellerCollateralManagerAbi, TermMaxViewerAbi, InverseEscrowAbi, CurvanceMarketManagerAbi, CurvanceCTokenAbi, GearboxCreditAccountCompressorV310Abi, UsddCdpManagerAbi, UsddProxyRegistryAbi, CurvanceProtocolReaderAbi, CurvanceCentralRegistryAbi, TermPriceConsumerAbi, CurvanceOracleManagerAbi, TermMaxOracleAggregatorV2Abi } from '@1delta/abis';
|
|
11
11
|
export { MorphoLensAbi } from '@1delta/abis';
|
|
12
12
|
import { prepareDebitDataMulticall, prepareLenderDebitMulticall, parseDebitDataResult, parseLenderDebitResult, getPermit2ContractAddress, getCompoundV3CometAddress as getCompoundV3CometAddress$1, getMorphoAddress, getAaveCollateralTokenAddress, getSiloHalfForUnderlying, bandLtvCurve, InitMarginAddresses, getLstAcceptedInputs } from '@1delta/calldata-sdk';
|
|
13
13
|
import { proxyNativeFetch } from '@1delta/proxy-fetch';
|
|
@@ -11542,10 +11542,10 @@ var safeParseNumber = (value, decimals = 18) => safeParseUnits(toFixed(value, de
|
|
|
11542
11542
|
var safeParseUnits = (strValue, decimals = 18) => {
|
|
11543
11543
|
if (!/[-+]?[0-9]*\.?[0-9]+/.test(strValue))
|
|
11544
11544
|
throw Error(`invalid number: ${strValue}`);
|
|
11545
|
-
let [whole,
|
|
11546
|
-
|
|
11545
|
+
let [whole, dec2 = ""] = strValue.split(".");
|
|
11546
|
+
dec2 = dec2.slice(0, decimals);
|
|
11547
11547
|
return parseUnits(
|
|
11548
|
-
[whole || "0",
|
|
11548
|
+
[whole || "0", dec2].filter((v) => v.length > 0).join("."),
|
|
11549
11549
|
decimals
|
|
11550
11550
|
);
|
|
11551
11551
|
};
|
|
@@ -11555,12 +11555,12 @@ function rateToApy(rate) {
|
|
|
11555
11555
|
);
|
|
11556
11556
|
}
|
|
11557
11557
|
function parseLtv(ltv) {
|
|
11558
|
-
let
|
|
11558
|
+
let str6 = 0;
|
|
11559
11559
|
try {
|
|
11560
|
-
|
|
11560
|
+
str6 = Number(formatUnits(BigInt(ltv), 18));
|
|
11561
11561
|
} catch (e) {
|
|
11562
11562
|
}
|
|
11563
|
-
return
|
|
11563
|
+
return str6;
|
|
11564
11564
|
}
|
|
11565
11565
|
function liquidationPenaltyFromLltv(lltv) {
|
|
11566
11566
|
if (!lltv || lltv <= 0) return 0;
|
|
@@ -21918,7 +21918,7 @@ async function fetchTellerMarkets(chainId) {
|
|
|
21918
21918
|
} catch {
|
|
21919
21919
|
return { chainId, pools: [] };
|
|
21920
21920
|
}
|
|
21921
|
-
const
|
|
21921
|
+
const big18 = (i) => {
|
|
21922
21922
|
const r = results[i];
|
|
21923
21923
|
if (typeof r === "bigint") return r;
|
|
21924
21924
|
if (typeof r === "number") return BigInt(r);
|
|
@@ -21932,20 +21932,20 @@ async function fetchTellerMarkets(chainId) {
|
|
|
21932
21932
|
return null;
|
|
21933
21933
|
};
|
|
21934
21934
|
const num14 = (i) => {
|
|
21935
|
-
const b =
|
|
21935
|
+
const b = big18(i);
|
|
21936
21936
|
return b === null ? null : Number(b);
|
|
21937
21937
|
};
|
|
21938
21938
|
const pool0 = pools.map((config, i) => {
|
|
21939
21939
|
const base = i * READS_PER_POOL;
|
|
21940
21940
|
return {
|
|
21941
21941
|
config,
|
|
21942
|
-
available:
|
|
21943
|
-
committed:
|
|
21942
|
+
available: big18(base),
|
|
21943
|
+
committed: big18(base + 1),
|
|
21944
21944
|
minRateBps: num14(base + 2),
|
|
21945
|
-
collateralPerPrincipal:
|
|
21945
|
+
collateralPerPrincipal: big18(base + 3),
|
|
21946
21946
|
maxLoanDuration: num14(base + 4),
|
|
21947
|
-
marketId:
|
|
21948
|
-
totalAssets:
|
|
21947
|
+
marketId: big18(base + 5),
|
|
21948
|
+
totalAssets: big18(base + 6)
|
|
21949
21949
|
};
|
|
21950
21950
|
});
|
|
21951
21951
|
const attByMarket = /* @__PURE__ */ new Map();
|
|
@@ -22181,8 +22181,8 @@ var TermMaxApiSource = class {
|
|
|
22181
22181
|
const assetDecimals = /* @__PURE__ */ new Map();
|
|
22182
22182
|
for (const a of Array.isArray(data.assetConfigs) ? data.assetConfigs : []) {
|
|
22183
22183
|
const addr3 = lower(a?.contractAddress ?? a?.assetAddress);
|
|
22184
|
-
const
|
|
22185
|
-
if (addr3 && Number.isFinite(
|
|
22184
|
+
const dec2 = Number(a?.decimals ?? a?.assetDecimals);
|
|
22185
|
+
if (addr3 && Number.isFinite(dec2)) assetDecimals.set(addr3, dec2);
|
|
22186
22186
|
}
|
|
22187
22187
|
const markets = [];
|
|
22188
22188
|
for (const m of Array.isArray(data.markets) ? data.markets : []) {
|
|
@@ -22919,8 +22919,8 @@ async function fetchInverseMarkets(lender, chainId) {
|
|
|
22919
22919
|
// unlike the on-chain bps — normalize here, and fall back to the
|
|
22920
22920
|
// curated metadata value when the field is missing.
|
|
22921
22921
|
replenishmentIncentiveBps: (() => {
|
|
22922
|
-
const
|
|
22923
|
-
if (
|
|
22922
|
+
const dec2 = num14(m?.replenishmentIncentive);
|
|
22923
|
+
if (dec2 !== null) return Math.round(dec2 * 1e4);
|
|
22924
22924
|
const meta = Number(market.replenishmentIncentiveBps);
|
|
22925
22925
|
return Number.isFinite(meta) ? meta : null;
|
|
22926
22926
|
})()
|
|
@@ -23374,9 +23374,9 @@ async function fetchResupplyMarkets(lender, chainId) {
|
|
|
23374
23374
|
});
|
|
23375
23375
|
});
|
|
23376
23376
|
if (pending.length > 0) {
|
|
23377
|
-
let
|
|
23377
|
+
let dec2 = [];
|
|
23378
23378
|
try {
|
|
23379
|
-
|
|
23379
|
+
dec2 = await multicallRetryUniversal({
|
|
23380
23380
|
chain: chainId,
|
|
23381
23381
|
calls: pending.flatMap((p) => [
|
|
23382
23382
|
{ address: p.collateral, name: "decimals", params: [] },
|
|
@@ -23393,20 +23393,20 @@ async function fetchResupplyMarkets(lender, chainId) {
|
|
|
23393
23393
|
allowFailure: true
|
|
23394
23394
|
});
|
|
23395
23395
|
} catch {
|
|
23396
|
-
|
|
23396
|
+
dec2 = [];
|
|
23397
23397
|
}
|
|
23398
23398
|
const addr3 = (v) => typeof v === "string" && /^0x[0-9a-fA-F]{40}$/.test(v) && !/^0x0+$/.test(v) ? v : void 0;
|
|
23399
23399
|
const wrapped = pending.map((_3, i) => {
|
|
23400
|
-
const curve = addr3(
|
|
23401
|
-
const frax = addr3(
|
|
23400
|
+
const curve = addr3(dec2[i * 4 + 2]);
|
|
23401
|
+
const frax = addr3(dec2[i * 4 + 3]);
|
|
23402
23402
|
return {
|
|
23403
23403
|
token: curve ?? frax,
|
|
23404
23404
|
family: curve ? "curvelend" : frax ? "fraxlend" : void 0
|
|
23405
23405
|
};
|
|
23406
23406
|
});
|
|
23407
23407
|
pending.forEach((p, i) => {
|
|
23408
|
-
const cd = Number(
|
|
23409
|
-
const ud = Number(
|
|
23408
|
+
const cd = Number(dec2[i * 4]);
|
|
23409
|
+
const ud = Number(dec2[i * 4 + 1]);
|
|
23410
23410
|
const w = wrapped[i];
|
|
23411
23411
|
identityCache.set(identityKey(chainId, p.pair), {
|
|
23412
23412
|
pair: p.pair,
|
|
@@ -24028,6 +24028,191 @@ function allowlist(config) {
|
|
|
24028
24028
|
}
|
|
24029
24029
|
return new Set(config.marketAllowlist.map((m) => m.toLowerCase()));
|
|
24030
24030
|
}
|
|
24031
|
+
var PAIR_READS = 15;
|
|
24032
|
+
var big3 = (v) => {
|
|
24033
|
+
if (typeof v === "bigint") return v;
|
|
24034
|
+
if (typeof v === "number") return BigInt(v);
|
|
24035
|
+
if (typeof v === "string" && v !== "0x") {
|
|
24036
|
+
try {
|
|
24037
|
+
return BigInt(v);
|
|
24038
|
+
} catch {
|
|
24039
|
+
}
|
|
24040
|
+
}
|
|
24041
|
+
return 0n;
|
|
24042
|
+
};
|
|
24043
|
+
var bool = (v) => v === true;
|
|
24044
|
+
var str2 = (v, fallback) => typeof v === "string" && v.length > 0 ? v : fallback;
|
|
24045
|
+
var dec = (v, fallback = 18) => {
|
|
24046
|
+
const n = Number(v);
|
|
24047
|
+
return Number.isFinite(n) && n >= 0 && n <= 36 ? n : fallback;
|
|
24048
|
+
};
|
|
24049
|
+
async function fetchFraxlendPairs(lender, chainId) {
|
|
24050
|
+
const config = fraxlendConfigFor(lender, chainId);
|
|
24051
|
+
const roster = (config?.pairs ?? []).filter((p) => !!p?.address);
|
|
24052
|
+
if (roster.length === 0) return { lender, config, pairs: [] };
|
|
24053
|
+
const swapper = config?.leverageSwapper ?? void 0;
|
|
24054
|
+
const addresses = roster.map((p) => p.address);
|
|
24055
|
+
const calls = addresses.flatMap((pair) => [
|
|
24056
|
+
{ address: pair, name: "symbol", params: [] },
|
|
24057
|
+
{ address: pair, name: "decimals", params: [] },
|
|
24058
|
+
{ address: pair, name: "asset", params: [] },
|
|
24059
|
+
{ address: pair, name: "collateralContract", params: [] },
|
|
24060
|
+
{ address: pair, name: "maxLTV", params: [] },
|
|
24061
|
+
{ address: pair, name: "LTV_PRECISION", params: [] },
|
|
24062
|
+
{ address: pair, name: "EXCHANGE_PRECISION", params: [] },
|
|
24063
|
+
{ address: pair, name: "LIQ_PRECISION", params: [] },
|
|
24064
|
+
{ address: pair, name: "depositLimit", params: [] },
|
|
24065
|
+
{ address: pair, name: "borrowLimit", params: [] },
|
|
24066
|
+
// Post-accrual accounting AND post-accrual rate state in one call. This is
|
|
24067
|
+
// the read the whole converter is built on — `getPairAccounting` and
|
|
24068
|
+
// `currentRateInfo` are their stale counterparts.
|
|
24069
|
+
{ address: pair, name: "previewAddInterest", params: [] },
|
|
24070
|
+
{ address: pair, name: "totalCollateral", params: [] },
|
|
24071
|
+
{ address: pair, name: "exchangeRateInfo", params: [] },
|
|
24072
|
+
{ address: pair, name: "rateContract", params: [] },
|
|
24073
|
+
// THE leverage gate. Probed live, per pair, every refresh — the mapping is
|
|
24074
|
+
// owner-mutable both ways, so a cached answer eventually lies in whichever
|
|
24075
|
+
// direction hurts (advertising a loop that reverts `BadSwapper()`, or
|
|
24076
|
+
// hiding one that works).
|
|
24077
|
+
{
|
|
24078
|
+
address: pair,
|
|
24079
|
+
name: "swappers",
|
|
24080
|
+
params: [swapper ?? "0x0000000000000000000000000000000000000000"]
|
|
24081
|
+
}
|
|
24082
|
+
]);
|
|
24083
|
+
const res = await multicallRetryUniversal({
|
|
24084
|
+
chain: chainId,
|
|
24085
|
+
calls,
|
|
24086
|
+
abi: calls.map(() => FraxlendPairAbi),
|
|
24087
|
+
allowFailure: true
|
|
24088
|
+
});
|
|
24089
|
+
const pauseCalls = addresses.flatMap((pair) => [
|
|
24090
|
+
{ address: pair, name: "isRepayPaused", params: [] },
|
|
24091
|
+
{ address: pair, name: "isWithdrawPaused", params: [] },
|
|
24092
|
+
{ address: pair, name: "isLiquidatePaused", params: [] },
|
|
24093
|
+
{ address: pair, name: "isInterestPaused", params: [] }
|
|
24094
|
+
]);
|
|
24095
|
+
const pauseRes = await multicallRetryUniversal({
|
|
24096
|
+
chain: chainId,
|
|
24097
|
+
calls: pauseCalls,
|
|
24098
|
+
abi: pauseCalls.map(() => FraxlendPairAbi),
|
|
24099
|
+
allowFailure: true
|
|
24100
|
+
}).catch(() => []);
|
|
24101
|
+
const partials = [];
|
|
24102
|
+
addresses.forEach((pair, i) => {
|
|
24103
|
+
const s = res.slice(i * PAIR_READS, i * PAIR_READS + PAIR_READS);
|
|
24104
|
+
const [
|
|
24105
|
+
symbol,
|
|
24106
|
+
decimals,
|
|
24107
|
+
asset,
|
|
24108
|
+
collateral,
|
|
24109
|
+
maxLtv,
|
|
24110
|
+
ltvPrec,
|
|
24111
|
+
exPrec,
|
|
24112
|
+
liqPrec,
|
|
24113
|
+
depositLimit,
|
|
24114
|
+
borrowLimit,
|
|
24115
|
+
preview,
|
|
24116
|
+
totalCollateral,
|
|
24117
|
+
xrInfo,
|
|
24118
|
+
rateContract,
|
|
24119
|
+
swapperOk
|
|
24120
|
+
] = s;
|
|
24121
|
+
if (typeof asset !== "string" || typeof collateral !== "string") return;
|
|
24122
|
+
if (!preview || !xrInfo) return;
|
|
24123
|
+
const rateInfo = preview[3] ?? {};
|
|
24124
|
+
const totalAsset = preview[4] ?? {};
|
|
24125
|
+
const totalBorrow = preview[5] ?? {};
|
|
24126
|
+
const p = pauseRes.slice(i * 4, i * 4 + 4);
|
|
24127
|
+
partials.push({
|
|
24128
|
+
pair,
|
|
24129
|
+
symbol: str2(symbol, "FraxlendPair"),
|
|
24130
|
+
decimals: dec(decimals),
|
|
24131
|
+
asset: asset.toLowerCase(),
|
|
24132
|
+
collateral: collateral.toLowerCase(),
|
|
24133
|
+
maxLtv: big3(maxLtv),
|
|
24134
|
+
ltvPrecision: big3(ltvPrec) || 100000n,
|
|
24135
|
+
exchangePrecision: big3(exPrec) || 10n ** 18n,
|
|
24136
|
+
liqPrecision: big3(liqPrec) || 100000n,
|
|
24137
|
+
cleanLiquidationFee: 0n,
|
|
24138
|
+
dirtyLiquidationFee: 0n,
|
|
24139
|
+
protocolLiquidationFee: 0n,
|
|
24140
|
+
depositLimit: big3(depositLimit),
|
|
24141
|
+
borrowLimit: big3(borrowLimit),
|
|
24142
|
+
totalAssetAmount: big3(totalAsset.amount ?? totalAsset[0]),
|
|
24143
|
+
totalAssetShares: big3(totalAsset.shares ?? totalAsset[1]),
|
|
24144
|
+
totalBorrowAmount: big3(
|
|
24145
|
+
totalBorrow.amount ?? totalBorrow[0]
|
|
24146
|
+
),
|
|
24147
|
+
totalBorrowShares: big3(
|
|
24148
|
+
totalBorrow.shares ?? totalBorrow[1]
|
|
24149
|
+
),
|
|
24150
|
+
totalCollateral: big3(totalCollateral),
|
|
24151
|
+
oracle: str2(xrInfo[0], "").toLowerCase(),
|
|
24152
|
+
maxOracleDeviation: Number(xrInfo[1] ?? 0),
|
|
24153
|
+
exchangeRateLastTimestamp: big3(xrInfo[2]),
|
|
24154
|
+
lowExchangeRate: big3(xrInfo[3]),
|
|
24155
|
+
highExchangeRate: big3(xrInfo[4]),
|
|
24156
|
+
ratePerSec: big3(rateInfo.ratePerSec ?? rateInfo[3]),
|
|
24157
|
+
fullUtilizationRate: big3(
|
|
24158
|
+
rateInfo.fullUtilizationRate ?? rateInfo[4]
|
|
24159
|
+
),
|
|
24160
|
+
feeToProtocolRate: Number(
|
|
24161
|
+
rateInfo.feeToProtocolRate ?? rateInfo[1] ?? 0
|
|
24162
|
+
),
|
|
24163
|
+
rateLastTimestamp: big3(
|
|
24164
|
+
rateInfo.lastTimestamp ?? rateInfo[2]
|
|
24165
|
+
),
|
|
24166
|
+
rateContract: str2(rateContract, "").toLowerCase(),
|
|
24167
|
+
isRepayPaused: bool(p[0]),
|
|
24168
|
+
isWithdrawPaused: bool(p[1]),
|
|
24169
|
+
isLiquidatePaused: bool(p[2]),
|
|
24170
|
+
isInterestPaused: bool(p[3]),
|
|
24171
|
+
// Only meaningful when a swapper is configured; with none, the probe was
|
|
24172
|
+
// against the zero address and must never read as "leverage available".
|
|
24173
|
+
leverageSwapperApproved: !!swapper && bool(swapperOk),
|
|
24174
|
+
leverageSwapper: swapper
|
|
24175
|
+
});
|
|
24176
|
+
});
|
|
24177
|
+
if (partials.length === 0) return { lender, config, pairs: [] };
|
|
24178
|
+
const tokenSet = [
|
|
24179
|
+
...new Set(partials.flatMap((p) => [p.asset, p.collateral]))
|
|
24180
|
+
];
|
|
24181
|
+
const metaCalls = tokenSet.flatMap((t) => [
|
|
24182
|
+
{ address: t, name: "symbol", params: [] },
|
|
24183
|
+
{ address: t, name: "name", params: [] },
|
|
24184
|
+
{ address: t, name: "decimals", params: [] }
|
|
24185
|
+
]);
|
|
24186
|
+
const metaRes = await multicallRetryUniversal({
|
|
24187
|
+
chain: chainId,
|
|
24188
|
+
calls: metaCalls,
|
|
24189
|
+
abi: metaCalls.map(() => erc20Abi),
|
|
24190
|
+
allowFailure: true
|
|
24191
|
+
}).catch(() => []);
|
|
24192
|
+
const meta = /* @__PURE__ */ new Map();
|
|
24193
|
+
tokenSet.forEach((t, i) => {
|
|
24194
|
+
const [symbol, name, decimals] = metaRes.slice(i * 3, i * 3 + 3);
|
|
24195
|
+
meta.set(t, {
|
|
24196
|
+
symbol: str2(symbol, "?"),
|
|
24197
|
+
name: str2(name, "?"),
|
|
24198
|
+
decimals: dec(decimals)
|
|
24199
|
+
});
|
|
24200
|
+
});
|
|
24201
|
+
const pairs = partials.map((p) => {
|
|
24202
|
+
const a = meta.get(p.asset);
|
|
24203
|
+
const c = meta.get(p.collateral);
|
|
24204
|
+
return {
|
|
24205
|
+
...p,
|
|
24206
|
+
assetSymbol: a?.symbol ?? "?",
|
|
24207
|
+
assetName: a?.name ?? "?",
|
|
24208
|
+
assetDecimals: a?.decimals ?? 18,
|
|
24209
|
+
collateralSymbol: c?.symbol ?? "?",
|
|
24210
|
+
collateralName: c?.name ?? "?",
|
|
24211
|
+
collateralDecimals: c?.decimals ?? 18
|
|
24212
|
+
};
|
|
24213
|
+
});
|
|
24214
|
+
return { lender, config, pairs };
|
|
24215
|
+
}
|
|
24031
24216
|
|
|
24032
24217
|
// src/lending/public-data/inverse/convertPublic.ts
|
|
24033
24218
|
function inverseLenderKey(lender, market) {
|
|
@@ -24887,12 +25072,12 @@ function convertCurvanceMarketsToResponse(raw, chainId, prices = {}, _additional
|
|
|
24887
25072
|
const priceKey = toOracleKey(token?.assetGroup) || toGenericPriceKey(assetAddr, chainId);
|
|
24888
25073
|
const collPrice = t.assetPriceLower > 0n ? Number(t.assetPriceLower) / 1e18 : prices[priceKey] || 0;
|
|
24889
25074
|
const debtPrice = t.assetPrice > 0n ? Number(t.assetPrice) / 1e18 : prices[priceKey] || 0;
|
|
24890
|
-
const
|
|
24891
|
-
const totalDeposits = toFloat(t.totalAssets,
|
|
24892
|
-
const totalDebt = toFloat(t.debt,
|
|
24893
|
-
const liquidity = toFloat(t.liquidity,
|
|
25075
|
+
const dec2 = t.assetDecimals;
|
|
25076
|
+
const totalDeposits = toFloat(t.totalAssets, dec2);
|
|
25077
|
+
const totalDebt = toFloat(t.debt, dec2);
|
|
25078
|
+
const liquidity = toFloat(t.liquidity, dec2);
|
|
24894
25079
|
const borrowable = t.debtCap > 0n;
|
|
24895
|
-
const debtHeadroom = borrowable ? Math.max(toFloat(t.debtCap,
|
|
25080
|
+
const debtHeadroom = borrowable ? Math.max(toFloat(t.debtCap, dec2) - totalDebt, 0) : 0;
|
|
24896
25081
|
const borrowLiquidity = borrowable ? Math.min(liquidity, debtHeadroom) : 0;
|
|
24897
25082
|
const collateralActive = t.collRatio > 0n && t.collateralCap > 0n;
|
|
24898
25083
|
const ltv = Number(t.collRatio) / BPS2;
|
|
@@ -24912,7 +25097,7 @@ function convertCurvanceMarketsToResponse(raw, chainId, prices = {}, _additional
|
|
|
24912
25097
|
name: t.assetSymbol,
|
|
24913
25098
|
poolId: market.marketManager.toLowerCase(),
|
|
24914
25099
|
underlying: assetAddr,
|
|
24915
|
-
asset: currencyFor11(assetAddr,
|
|
25100
|
+
asset: currencyFor11(assetAddr, dec2, t.assetSymbol, t.assetName, tokens),
|
|
24916
25101
|
totalDeposits,
|
|
24917
25102
|
totalDebtStable: 0,
|
|
24918
25103
|
totalDebt,
|
|
@@ -24932,7 +25117,7 @@ function convertCurvanceMarketsToResponse(raw, chainId, prices = {}, _additional
|
|
|
24932
25117
|
rateModel: "curvance-dynamic",
|
|
24933
25118
|
intrinsicYield: 0,
|
|
24934
25119
|
rewards: void 0,
|
|
24935
|
-
decimals:
|
|
25120
|
+
decimals: dec2,
|
|
24936
25121
|
config: {
|
|
24937
25122
|
0: {
|
|
24938
25123
|
category: 0,
|
|
@@ -24965,7 +25150,7 @@ function convertCurvanceMarketsToResponse(raw, chainId, prices = {}, _additional
|
|
|
24965
25150
|
symbol: t.symbol,
|
|
24966
25151
|
assetSymbol: t.assetSymbol,
|
|
24967
25152
|
decimals: t.decimals,
|
|
24968
|
-
assetDecimals:
|
|
25153
|
+
assetDecimals: dec2,
|
|
24969
25154
|
/** THE borrowability gate — never `isBorrowable()`. */
|
|
24970
25155
|
borrowable,
|
|
24971
25156
|
debtCap: t.debtCap.toString(),
|
|
@@ -25081,6 +25266,230 @@ function resolvePositionManagers(cfg, marketManager) {
|
|
|
25081
25266
|
}
|
|
25082
25267
|
return void 0;
|
|
25083
25268
|
}
|
|
25269
|
+
|
|
25270
|
+
// src/lending/public-data/fraxlend/convertPublic.ts
|
|
25271
|
+
function fraxlendLenderKey(lender, chainId, pair) {
|
|
25272
|
+
return `${lender}_${chainId}_${pair.replace(/^0x/i, "").toUpperCase()}`;
|
|
25273
|
+
}
|
|
25274
|
+
function fraxlendKeyParts(key3) {
|
|
25275
|
+
if (!key3.startsWith("FRAXLEND_")) return void 0;
|
|
25276
|
+
const m = key3.slice("FRAXLEND_".length).match(/^(\d+)_([0-9A-Fa-f]{40})$/);
|
|
25277
|
+
if (!m) return void 0;
|
|
25278
|
+
return { lender: "FRAXLEND", chainId: m[1], pair: `0x${m[2].toLowerCase()}` };
|
|
25279
|
+
}
|
|
25280
|
+
var SECONDS_PER_YEAR11 = 31536e3;
|
|
25281
|
+
var ratePerSecToApr3 = (rate) => Number(rate) / 1e18 * SECONDS_PER_YEAR11 * 100;
|
|
25282
|
+
var toFloat2 = (raw, decimals) => Number(raw) / 10 ** decimals;
|
|
25283
|
+
var MAX_UINT = (1n << 256n) - 1n;
|
|
25284
|
+
function currencyFor12(address, decimals, symbol, name, tokens) {
|
|
25285
|
+
const lower3 = address.toLowerCase();
|
|
25286
|
+
return tokens[lower3] ?? { address: lower3, symbol, name, decimals };
|
|
25287
|
+
}
|
|
25288
|
+
function fraxlendAssetPerCollateral(p, which = "high") {
|
|
25289
|
+
const rate = which === "high" ? p.highExchangeRate : p.lowExchangeRate;
|
|
25290
|
+
if (rate === 0n) return 0;
|
|
25291
|
+
const base = Number(p.exchangePrecision) / Number(rate);
|
|
25292
|
+
return base * 10 ** (p.collateralDecimals - p.assetDecimals);
|
|
25293
|
+
}
|
|
25294
|
+
function convertFraxlendPairsToResponse(raw, chainId, prices = {}, _additionalYields = {
|
|
25295
|
+
intrinsicYields: {},
|
|
25296
|
+
lenderRewards: {},
|
|
25297
|
+
loaded: true
|
|
25298
|
+
}, tokens = {}) {
|
|
25299
|
+
const out = {};
|
|
25300
|
+
for (const p of raw?.pairs ?? []) {
|
|
25301
|
+
const lenderKey = fraxlendLenderKey(raw.lender, chainId, p.pair);
|
|
25302
|
+
const entry = { data: {} };
|
|
25303
|
+
const assetToken = tokens[p.asset];
|
|
25304
|
+
const collToken = tokens[p.collateral];
|
|
25305
|
+
const assetPriceKey = toOracleKey(assetToken?.assetGroup) || toGenericPriceKey(p.asset, chainId);
|
|
25306
|
+
const collPriceKey = toOracleKey(collToken?.assetGroup) || toGenericPriceKey(p.collateral, chainId);
|
|
25307
|
+
const assetPrice = prices[assetPriceKey] || 0;
|
|
25308
|
+
const assetPerColl = fraxlendAssetPerCollateral(p, "high");
|
|
25309
|
+
const collPrice = assetPerColl > 0 && assetPrice > 0 ? assetPerColl * assetPrice : prices[collPriceKey] || 0;
|
|
25310
|
+
const totalDeposits = toFloat2(p.totalAssetAmount, p.assetDecimals);
|
|
25311
|
+
const totalDebt = toFloat2(p.totalBorrowAmount, p.assetDecimals);
|
|
25312
|
+
const liquidity = Math.max(totalDeposits - totalDebt, 0);
|
|
25313
|
+
const totalCollateral = toFloat2(p.totalCollateral, p.collateralDecimals);
|
|
25314
|
+
const utilization = totalDeposits > 0 ? totalDebt / totalDeposits : 0;
|
|
25315
|
+
const borrowApr = ratePerSecToApr3(p.ratePerSec);
|
|
25316
|
+
const protocolCut = Math.min(Math.max(p.feeToProtocolRate / 1e5, 0), 1);
|
|
25317
|
+
const supplyApr = borrowApr * utilization * (1 - protocolCut);
|
|
25318
|
+
const ltv = p.ltvPrecision > 0n ? Number(p.maxLtv) / Number(p.ltvPrecision) : 0;
|
|
25319
|
+
const liquidationPenalty = p.liqPrecision > 0n && p.cleanLiquidationFee > 0n ? Number(p.cleanLiquidationFee) / Number(p.liqPrecision) : 0;
|
|
25320
|
+
const uncappedDeposit = p.depositLimit >= MAX_UINT / 2n;
|
|
25321
|
+
const uncappedBorrow = p.borrowLimit >= MAX_UINT / 2n;
|
|
25322
|
+
const depositHeadroom = uncappedDeposit ? Number.POSITIVE_INFINITY : Math.max(toFloat2(p.depositLimit, p.assetDecimals) - totalDeposits, 0);
|
|
25323
|
+
const borrowHeadroom = uncappedBorrow ? Number.POSITIVE_INFINITY : Math.max(toFloat2(p.borrowLimit, p.assetDecimals) - totalDebt, 0);
|
|
25324
|
+
const depositsHalted = depositHeadroom <= 0;
|
|
25325
|
+
const borrowHalted = borrowHeadroom <= 0;
|
|
25326
|
+
const borrowLiquidity = borrowHalted ? 0 : Math.min(liquidity, borrowHeadroom);
|
|
25327
|
+
const assetUid = createMarketUid(chainId, lenderKey, p.asset);
|
|
25328
|
+
entry.data[assetUid] = {
|
|
25329
|
+
marketUid: assetUid,
|
|
25330
|
+
name: p.assetSymbol,
|
|
25331
|
+
poolId: p.pair.toLowerCase(),
|
|
25332
|
+
underlying: p.asset,
|
|
25333
|
+
asset: currencyFor12(
|
|
25334
|
+
p.asset,
|
|
25335
|
+
p.assetDecimals,
|
|
25336
|
+
p.assetSymbol,
|
|
25337
|
+
p.assetName,
|
|
25338
|
+
tokens
|
|
25339
|
+
),
|
|
25340
|
+
totalDeposits,
|
|
25341
|
+
totalDebtStable: 0,
|
|
25342
|
+
totalDebt,
|
|
25343
|
+
totalLiquidity: liquidity,
|
|
25344
|
+
borrowLiquidity,
|
|
25345
|
+
totalLiquidityUSD: liquidity * assetPrice,
|
|
25346
|
+
borrowLiquidityUSD: borrowLiquidity * assetPrice,
|
|
25347
|
+
totalDepositsUSD: totalDeposits * assetPrice,
|
|
25348
|
+
totalDebtStableUSD: 0,
|
|
25349
|
+
totalDebtUSD: totalDebt * assetPrice,
|
|
25350
|
+
utilization,
|
|
25351
|
+
depositRate: supplyApr,
|
|
25352
|
+
variableBorrowRate: borrowApr,
|
|
25353
|
+
stableBorrowRate: 0,
|
|
25354
|
+
rateModel: "fraxlend-variable-v3",
|
|
25355
|
+
intrinsicYield: 0,
|
|
25356
|
+
rewards: void 0,
|
|
25357
|
+
decimals: p.assetDecimals,
|
|
25358
|
+
config: {
|
|
25359
|
+
0: {
|
|
25360
|
+
category: 0,
|
|
25361
|
+
// The asset can never be posted as collateral in its own pair.
|
|
25362
|
+
borrowCollateralFactor: 0,
|
|
25363
|
+
collateralFactor: 0,
|
|
25364
|
+
borrowFactor: 1,
|
|
25365
|
+
liquidationPenalty,
|
|
25366
|
+
closeFactor: 1,
|
|
25367
|
+
collateralDisabled: true,
|
|
25368
|
+
debtDisabled: borrowHalted
|
|
25369
|
+
}
|
|
25370
|
+
},
|
|
25371
|
+
closeFactor: 1,
|
|
25372
|
+
collateralActive: false,
|
|
25373
|
+
borrowingEnabled: !borrowHalted,
|
|
25374
|
+
depositsEnabled: !depositsHalted,
|
|
25375
|
+
hasStable: false,
|
|
25376
|
+
variableBorrowDisabled: borrowHalted,
|
|
25377
|
+
isActive: !(depositsHalted && borrowHalted),
|
|
25378
|
+
isFrozen: depositsHalted && borrowHalted
|
|
25379
|
+
};
|
|
25380
|
+
const collUid = createMarketUid(chainId, lenderKey, p.collateral);
|
|
25381
|
+
entry.data[collUid] = {
|
|
25382
|
+
marketUid: collUid,
|
|
25383
|
+
name: p.collateralSymbol,
|
|
25384
|
+
poolId: p.pair.toLowerCase(),
|
|
25385
|
+
underlying: p.collateral,
|
|
25386
|
+
asset: currencyFor12(
|
|
25387
|
+
p.collateral,
|
|
25388
|
+
p.collateralDecimals,
|
|
25389
|
+
p.collateralSymbol,
|
|
25390
|
+
p.collateralName,
|
|
25391
|
+
tokens
|
|
25392
|
+
),
|
|
25393
|
+
totalDeposits: totalCollateral,
|
|
25394
|
+
totalDebtStable: 0,
|
|
25395
|
+
totalDebt: 0,
|
|
25396
|
+
// Posted collateral is not lendable liquidity — it just sits there.
|
|
25397
|
+
totalLiquidity: 0,
|
|
25398
|
+
borrowLiquidity: 0,
|
|
25399
|
+
totalLiquidityUSD: 0,
|
|
25400
|
+
borrowLiquidityUSD: 0,
|
|
25401
|
+
totalDepositsUSD: totalCollateral * collPrice,
|
|
25402
|
+
totalDebtStableUSD: 0,
|
|
25403
|
+
totalDebtUSD: 0,
|
|
25404
|
+
utilization: 0,
|
|
25405
|
+
// Genuinely 0 %: there is no lender side on the collateral leg.
|
|
25406
|
+
depositRate: 0,
|
|
25407
|
+
variableBorrowRate: 0,
|
|
25408
|
+
stableBorrowRate: 0,
|
|
25409
|
+
rateModel: "fraxlend-variable-v3",
|
|
25410
|
+
intrinsicYield: 0,
|
|
25411
|
+
rewards: void 0,
|
|
25412
|
+
decimals: p.collateralDecimals,
|
|
25413
|
+
config: {
|
|
25414
|
+
0: {
|
|
25415
|
+
category: 0,
|
|
25416
|
+
borrowCollateralFactor: ltv,
|
|
25417
|
+
// Fraxlend has ONE ratio: `maxLTV` gates both opening and solvency,
|
|
25418
|
+
// so the liquidation threshold IS the LTV. Publishing anything
|
|
25419
|
+
// higher would invent a buffer the contract does not give.
|
|
25420
|
+
collateralFactor: ltv,
|
|
25421
|
+
borrowFactor: 1,
|
|
25422
|
+
liquidationPenalty,
|
|
25423
|
+
closeFactor: 1,
|
|
25424
|
+
collateralDisabled: false,
|
|
25425
|
+
debtDisabled: true
|
|
25426
|
+
}
|
|
25427
|
+
},
|
|
25428
|
+
closeFactor: 1,
|
|
25429
|
+
collateralActive: true,
|
|
25430
|
+
borrowingEnabled: false,
|
|
25431
|
+
depositsEnabled: !depositsHalted,
|
|
25432
|
+
hasStable: false,
|
|
25433
|
+
variableBorrowDisabled: true,
|
|
25434
|
+
isActive: true,
|
|
25435
|
+
isFrozen: depositsHalted && borrowHalted
|
|
25436
|
+
};
|
|
25437
|
+
entry.descriptor = {
|
|
25438
|
+
pair: p.pair.toLowerCase(),
|
|
25439
|
+
symbol: p.symbol,
|
|
25440
|
+
fTokenDecimals: p.decimals,
|
|
25441
|
+
asset: p.asset,
|
|
25442
|
+
collateral: p.collateral,
|
|
25443
|
+
assetDecimals: p.assetDecimals,
|
|
25444
|
+
collateralDecimals: p.collateralDecimals,
|
|
25445
|
+
/** RAW, with its scale, so a caller can reproduce the protocol's math. */
|
|
25446
|
+
maxLtvRaw: p.maxLtv.toString(),
|
|
25447
|
+
ltvPrecision: p.ltvPrecision.toString(),
|
|
25448
|
+
maxLtv: ltv,
|
|
25449
|
+
/** INVERTED (collateral-per-asset) and NOT decimal-normalised — see
|
|
25450
|
+
* `fraxlendAssetPerCollateral` before using these directly. */
|
|
25451
|
+
lowExchangeRate: p.lowExchangeRate.toString(),
|
|
25452
|
+
highExchangeRate: p.highExchangeRate.toString(),
|
|
25453
|
+
exchangePrecision: p.exchangePrecision.toString(),
|
|
25454
|
+
/** The inverted, decimal-corrected, ready-to-use forms. */
|
|
25455
|
+
assetPerCollateralHigh: fraxlendAssetPerCollateral(p, "high"),
|
|
25456
|
+
assetPerCollateralLow: fraxlendAssetPerCollateral(p, "low"),
|
|
25457
|
+
oracle: p.oracle,
|
|
25458
|
+
maxOracleDeviation: p.maxOracleDeviation,
|
|
25459
|
+
/** Can be DAYS stale on this protocol — surface it, do not hide it. */
|
|
25460
|
+
exchangeRateLastTimestamp: p.exchangeRateLastTimestamp.toString(),
|
|
25461
|
+
/** Borrow SHARES outstanding; convert with `toBorrowAmount`. */
|
|
25462
|
+
totalBorrowShares: p.totalBorrowShares.toString(),
|
|
25463
|
+
totalAssetShares: p.totalAssetShares.toString(),
|
|
25464
|
+
ratePerSecond: p.ratePerSec.toString(),
|
|
25465
|
+
/** The STATEFUL IRM term — needed to reproduce the rate offline. */
|
|
25466
|
+
fullUtilizationRate: p.fullUtilizationRate.toString(),
|
|
25467
|
+
feeToProtocolRate: p.feeToProtocolRate,
|
|
25468
|
+
/** `VariableInterestRateV3`; `getNewRate` is a view ⇒ exact
|
|
25469
|
+
* rate-at-depth with no modelling. */
|
|
25470
|
+
rateContract: p.rateContract,
|
|
25471
|
+
depositLimit: p.depositLimit.toString(),
|
|
25472
|
+
borrowLimit: p.borrowLimit.toString(),
|
|
25473
|
+
isRepayPaused: p.isRepayPaused,
|
|
25474
|
+
isWithdrawPaused: p.isWithdrawPaused,
|
|
25475
|
+
isLiquidatePaused: p.isLiquidatePaused,
|
|
25476
|
+
isInterestPaused: p.isInterestPaused,
|
|
25477
|
+
/**
|
|
25478
|
+
* Native looping availability, PROBED LIVE this refresh. `false` means
|
|
25479
|
+
* `leveragedPosition` reverts `BadSwapper()` on this pair — it does NOT
|
|
25480
|
+
* mean the protocol lacks the feature. Never cache across refreshes.
|
|
25481
|
+
*/
|
|
25482
|
+
leverageEnabled: p.leverageSwapperApproved,
|
|
25483
|
+
leverageSwapper: p.leverageSwapper,
|
|
25484
|
+
/** `path` for `leveragedPosition` / `repayAssetWithCollateral`. The
|
|
25485
|
+
* loop direction is asset->collateral; deleverage is the reverse. */
|
|
25486
|
+
leveragePath: [p.asset, p.collateral],
|
|
25487
|
+
deleveragePath: [p.collateral, p.asset]
|
|
25488
|
+
};
|
|
25489
|
+
out[lenderKey] = entry;
|
|
25490
|
+
}
|
|
25491
|
+
return out;
|
|
25492
|
+
}
|
|
25084
25493
|
var CORE_READS_PER_ILK = 3;
|
|
25085
25494
|
var DSS_CORE_ABI_PER_READ = [UsddVatAbi, UsddJugAbi, UsddSpotAbi];
|
|
25086
25495
|
var dssIlkBytes32 = (ilk) => stringToHex(ilk, { size: 32 });
|
|
@@ -25125,12 +25534,12 @@ async function fetchDssMarkets(lender, chainId) {
|
|
|
25125
25534
|
} catch {
|
|
25126
25535
|
return { lender, config, chainData, markets: [] };
|
|
25127
25536
|
}
|
|
25128
|
-
const
|
|
25537
|
+
const big18 = (v) => {
|
|
25129
25538
|
if (typeof v === "bigint") return v;
|
|
25130
25539
|
if (typeof v === "number") return BigInt(v);
|
|
25131
25540
|
return null;
|
|
25132
25541
|
};
|
|
25133
|
-
const field13 = (res, name, idx) =>
|
|
25542
|
+
const field13 = (res, name, idx) => big18(res?.[name] ?? res?.[idx]);
|
|
25134
25543
|
let cursor = 0;
|
|
25135
25544
|
const out = markets.map((market, i) => {
|
|
25136
25545
|
const base = cursor;
|
|
@@ -25147,7 +25556,7 @@ async function fetchDssMarkets(lender, chainId) {
|
|
|
25147
25556
|
dust: field13(vatIlk, "dust", 4),
|
|
25148
25557
|
duty: field13(jugIlk, "duty", 0),
|
|
25149
25558
|
mat: field13(spotIlk, "mat", 1),
|
|
25150
|
-
joinBalance: joinReadIndex[i] >= 0 ?
|
|
25559
|
+
joinBalance: joinReadIndex[i] >= 0 ? big18(results[joinReadIndex[i]]) : null
|
|
25151
25560
|
};
|
|
25152
25561
|
});
|
|
25153
25562
|
return { lender, config, chainData, markets: out };
|
|
@@ -25175,7 +25584,7 @@ var YEAR_SECONDS2 = 31536e3;
|
|
|
25175
25584
|
function toHuman4(raw, decimals) {
|
|
25176
25585
|
return Number(raw) / 10 ** decimals;
|
|
25177
25586
|
}
|
|
25178
|
-
function
|
|
25587
|
+
function currencyFor13(address, decimals, symbol, tokens) {
|
|
25179
25588
|
const lower3 = address.toLowerCase();
|
|
25180
25589
|
return tokens[lower3] ?? { address: lower3, symbol, name: symbol, decimals };
|
|
25181
25590
|
}
|
|
@@ -25227,7 +25636,7 @@ function convertDssMarketsToResponse(raw, chainId, prices = {}, _additionalYield
|
|
|
25227
25636
|
name: "Collateral " + collSymbol,
|
|
25228
25637
|
poolId: market.gemJoin?.toLowerCase(),
|
|
25229
25638
|
underlying: collAddr,
|
|
25230
|
-
asset:
|
|
25639
|
+
asset: currencyFor13(collAddr, collDecimals, collSymbol, tokens),
|
|
25231
25640
|
totalDeposits: totalColl,
|
|
25232
25641
|
totalDebtStable: 0,
|
|
25233
25642
|
totalDebt: 0,
|
|
@@ -25271,7 +25680,7 @@ function convertDssMarketsToResponse(raw, chainId, prices = {}, _additionalYield
|
|
|
25271
25680
|
name: debtSymbol,
|
|
25272
25681
|
poolId: cfg.vat.toLowerCase(),
|
|
25273
25682
|
underlying: debtAddr,
|
|
25274
|
-
asset:
|
|
25683
|
+
asset: currencyFor13(debtAddr, debtDecimals, debtSymbol, tokens),
|
|
25275
25684
|
totalDeposits: 0,
|
|
25276
25685
|
totalDebtStable: 0,
|
|
25277
25686
|
totalDebt,
|
|
@@ -25421,26 +25830,26 @@ async function fetchFrankencoinMarkets(lender, chainId) {
|
|
|
25421
25830
|
} catch {
|
|
25422
25831
|
return { lender, config, chainData, markets: [] };
|
|
25423
25832
|
}
|
|
25424
|
-
const
|
|
25833
|
+
const big18 = (v) => {
|
|
25425
25834
|
if (typeof v === "bigint") return v;
|
|
25426
25835
|
if (typeof v === "number") return BigInt(v);
|
|
25427
25836
|
return null;
|
|
25428
25837
|
};
|
|
25429
25838
|
const out = markets.map((market, i) => {
|
|
25430
25839
|
const base = i * READS_PER_MARKET3;
|
|
25431
|
-
const expiration =
|
|
25840
|
+
const expiration = big18(results[base + 7]);
|
|
25432
25841
|
return {
|
|
25433
25842
|
market,
|
|
25434
|
-
price:
|
|
25435
|
-
minted:
|
|
25436
|
-
availableForClones:
|
|
25437
|
-
annualInterestPPM:
|
|
25438
|
-
currentFeePPM:
|
|
25439
|
-
reserveContribution:
|
|
25440
|
-
challengedAmount:
|
|
25843
|
+
price: big18(results[base]),
|
|
25844
|
+
minted: big18(results[base + 1]),
|
|
25845
|
+
availableForClones: big18(results[base + 2]),
|
|
25846
|
+
annualInterestPPM: big18(results[base + 3]),
|
|
25847
|
+
currentFeePPM: big18(results[base + 4]),
|
|
25848
|
+
reserveContribution: big18(results[base + 5]),
|
|
25849
|
+
challengedAmount: big18(results[base + 6]),
|
|
25441
25850
|
expiration,
|
|
25442
25851
|
isClosed: typeof results[base + 8] === "boolean" ? results[base + 8] : null,
|
|
25443
|
-
collateralBalance:
|
|
25852
|
+
collateralBalance: big18(results[base + 9])
|
|
25444
25853
|
};
|
|
25445
25854
|
});
|
|
25446
25855
|
return { lender, config, chainData, markets: out };
|
|
@@ -25462,7 +25871,7 @@ function frankencoinKeyParts(key3) {
|
|
|
25462
25871
|
};
|
|
25463
25872
|
}
|
|
25464
25873
|
var PPM = 1e6;
|
|
25465
|
-
function
|
|
25874
|
+
function currencyFor14(address, decimals, symbol, tokens) {
|
|
25466
25875
|
const lower3 = address.toLowerCase();
|
|
25467
25876
|
return tokens[lower3] ?? { address: lower3, symbol, name: symbol, decimals };
|
|
25468
25877
|
}
|
|
@@ -25513,7 +25922,7 @@ function convertFrankencoinMarketsToResponse(raw, chainId, prices = {}, _additio
|
|
|
25513
25922
|
name: "Collateral " + collSymbol,
|
|
25514
25923
|
poolId: market.position.toLowerCase(),
|
|
25515
25924
|
underlying: collAddr,
|
|
25516
|
-
asset:
|
|
25925
|
+
asset: currencyFor14(collAddr, collDecimals, collSymbol, tokens),
|
|
25517
25926
|
totalDeposits: totalColl,
|
|
25518
25927
|
totalDebtStable: 0,
|
|
25519
25928
|
totalDebt: 0,
|
|
@@ -25560,7 +25969,7 @@ function convertFrankencoinMarketsToResponse(raw, chainId, prices = {}, _additio
|
|
|
25560
25969
|
name: debtSymbol,
|
|
25561
25970
|
poolId: cfg.mintingHub.toLowerCase(),
|
|
25562
25971
|
underlying: debtAddr,
|
|
25563
|
-
asset:
|
|
25972
|
+
asset: currencyFor14(debtAddr, debtDecimals, debtSymbol, tokens),
|
|
25564
25973
|
totalDeposits: 0,
|
|
25565
25974
|
totalDebtStable: 0,
|
|
25566
25975
|
totalDebt,
|
|
@@ -26284,6 +26693,7 @@ async function getLenderDataFromApi(lender, chainId, prices, additionalYields, i
|
|
|
26284
26693
|
if (isLlamaLend(lender)) return await fetchLlamaLendMarkets(lender, chainId);
|
|
26285
26694
|
if (isResupply(lender)) return await fetchResupplyMarkets(lender, chainId);
|
|
26286
26695
|
if (isCurvance(lender)) return await fetchCurvanceMarkets(lender, chainId);
|
|
26696
|
+
if (isFraxlend(lender)) return await fetchFraxlendPairs(lender, chainId);
|
|
26287
26697
|
if (isTermMax(lender)) return await fetchTermMaxMarkets(chainId);
|
|
26288
26698
|
if (isDssType(lender)) return await fetchDssMarkets(lender, chainId);
|
|
26289
26699
|
if (isFrankencoin(lender))
|
|
@@ -26373,6 +26783,14 @@ function convertLenderDataFromApi(lender, chainId, data, prices, additionalYield
|
|
|
26373
26783
|
additionalYields,
|
|
26374
26784
|
list
|
|
26375
26785
|
);
|
|
26786
|
+
if (isFraxlend(lender))
|
|
26787
|
+
return convertFraxlendPairsToResponse(
|
|
26788
|
+
data,
|
|
26789
|
+
chainId,
|
|
26790
|
+
prices,
|
|
26791
|
+
additionalYields,
|
|
26792
|
+
list
|
|
26793
|
+
);
|
|
26376
26794
|
if (isFrankencoin(lender))
|
|
26377
26795
|
return convertFrankencoinMarketsToResponse(
|
|
26378
26796
|
data,
|
|
@@ -26600,6 +27018,7 @@ function lenderApiOnly(lender, chainId) {
|
|
|
26600
27018
|
if (isTermMax(lender)) return true;
|
|
26601
27019
|
if (isResupply(lender)) return true;
|
|
26602
27020
|
if (isCurvance(lender)) return true;
|
|
27021
|
+
if (isFraxlend(lender)) return true;
|
|
26603
27022
|
if (isDssType(lender)) return true;
|
|
26604
27023
|
if (isFrankencoin(lender)) return true;
|
|
26605
27024
|
if (isLlamaLend(lender)) return true;
|
|
@@ -28122,6 +28541,17 @@ function __resetResupplyUserCaches() {
|
|
|
28122
28541
|
rosterCache3.clear();
|
|
28123
28542
|
discoveryCache2.clear();
|
|
28124
28543
|
}
|
|
28544
|
+
var FRAXLEND_CALLS_PER_PAIR = 4;
|
|
28545
|
+
var buildFraxlendUserCall = (chainId, lender, account) => {
|
|
28546
|
+
const pairs = fraxlendPairsFor(lender, chainId);
|
|
28547
|
+
if (pairs.length === 0) return [];
|
|
28548
|
+
return pairs.flatMap((p) => [
|
|
28549
|
+
{ address: p.address, name: "userCollateralBalance", params: [account] },
|
|
28550
|
+
{ address: p.address, name: "userBorrowShares", params: [account] },
|
|
28551
|
+
{ address: p.address, name: "balanceOf", params: [account] },
|
|
28552
|
+
{ address: p.address, name: "previewAddInterest", params: [] }
|
|
28553
|
+
]);
|
|
28554
|
+
};
|
|
28125
28555
|
var ROSTER_TTL_MS2 = 5 * 6e4;
|
|
28126
28556
|
var DISCOVERY_TTL_MS2 = 6e4;
|
|
28127
28557
|
var CURVANCE_MARKET_READS = 2;
|
|
@@ -28299,7 +28729,7 @@ var getCachedDssCdps = (lender, chainId, account) => {
|
|
|
28299
28729
|
if (!hit || Date.now() - hit.at > CACHE_TTL_MS2) return void 0;
|
|
28300
28730
|
return hit;
|
|
28301
28731
|
};
|
|
28302
|
-
var
|
|
28732
|
+
var big4 = (v) => {
|
|
28303
28733
|
try {
|
|
28304
28734
|
if (typeof v === "bigint") return v;
|
|
28305
28735
|
if (typeof v === "number" || typeof v === "string") return BigInt(v);
|
|
@@ -28330,7 +28760,7 @@ var buildDssUserCall = async (chainId, lender, account) => {
|
|
|
28330
28760
|
],
|
|
28331
28761
|
allowFailure: false
|
|
28332
28762
|
});
|
|
28333
|
-
owners.push({ owner: account, count:
|
|
28763
|
+
owners.push({ owner: account, count: big4(rawCount), cursor: big4(rawFirst) });
|
|
28334
28764
|
const proxy = String(rawProxy ?? zero2);
|
|
28335
28765
|
if (proxy.toLowerCase() !== zero2) {
|
|
28336
28766
|
const [pCount, pFirst] = await multicallRetryUniversal({
|
|
@@ -28342,7 +28772,7 @@ var buildDssUserCall = async (chainId, lender, account) => {
|
|
|
28342
28772
|
],
|
|
28343
28773
|
allowFailure: false
|
|
28344
28774
|
});
|
|
28345
|
-
owners.push({ owner: proxy, count:
|
|
28775
|
+
owners.push({ owner: proxy, count: big4(pCount), cursor: big4(pFirst) });
|
|
28346
28776
|
}
|
|
28347
28777
|
} catch {
|
|
28348
28778
|
return [];
|
|
@@ -28383,7 +28813,7 @@ var buildDssUserCall = async (chainId, lender, account) => {
|
|
|
28383
28813
|
if (curated.has(ilk)) {
|
|
28384
28814
|
cdps.push({ cdpId: cursor.toString(), urn: String(urn), ilk });
|
|
28385
28815
|
}
|
|
28386
|
-
cursor =
|
|
28816
|
+
cursor = big4(field6(link, "next", 1));
|
|
28387
28817
|
}
|
|
28388
28818
|
}
|
|
28389
28819
|
} catch {
|
|
@@ -28635,6 +29065,7 @@ async function buildUserCall(chainId, lender, account, params, getClient) {
|
|
|
28635
29065
|
if (isLlamaLend(lender))
|
|
28636
29066
|
return buildLlamaLendUserCall(chainId, lender, account);
|
|
28637
29067
|
if (isResupply(lender)) return buildResupplyUserCall(chainId, lender, account);
|
|
29068
|
+
if (isFraxlend(lender)) return buildFraxlendUserCall(chainId, lender, account);
|
|
28638
29069
|
if (isCurvance(lender)) return buildCurvanceUserCall(chainId, lender, account);
|
|
28639
29070
|
if (isDssType(lender)) return buildDssUserCall(chainId, lender, account);
|
|
28640
29071
|
if (isFrankencoin(lender))
|
|
@@ -31446,7 +31877,7 @@ var getExactlyUserDataConverter = (_lender, chainId, account, meta) => {
|
|
|
31446
31877
|
expected
|
|
31447
31878
|
];
|
|
31448
31879
|
};
|
|
31449
|
-
var
|
|
31880
|
+
var big5 = (v) => {
|
|
31450
31881
|
try {
|
|
31451
31882
|
if (typeof v === "bigint") return v;
|
|
31452
31883
|
if (typeof v === "number" || typeof v === "string") return BigInt(v);
|
|
@@ -31454,7 +31885,7 @@ var big4 = (v) => {
|
|
|
31454
31885
|
}
|
|
31455
31886
|
return 0n;
|
|
31456
31887
|
};
|
|
31457
|
-
var field7 = (res, name, idx) =>
|
|
31888
|
+
var field7 = (res, name, idx) => big5(res?.[name] ?? res?.[idx]);
|
|
31458
31889
|
var getLiquityUserDataConverter = (lender, chainId, account, meta) => {
|
|
31459
31890
|
const cfg = liquityConfigFor(lender, chainId);
|
|
31460
31891
|
const branches = liquityBranchesByChain(lender, chainId);
|
|
@@ -31575,11 +32006,11 @@ var getLiquityUserDataConverter = (lender, chainId, account, meta) => {
|
|
|
31575
32006
|
};
|
|
31576
32007
|
});
|
|
31577
32008
|
const spBase = troves.length * 2;
|
|
31578
|
-
const spDeposit =
|
|
31579
|
-
const spYield =
|
|
31580
|
-
const spCollGain =
|
|
31581
|
-
const spStashed =
|
|
31582
|
-
const collSurplus = branch.collSurplusPool ?
|
|
32009
|
+
const spDeposit = big5(slice2[spBase]);
|
|
32010
|
+
const spYield = big5(slice2[spBase + 1]);
|
|
32011
|
+
const spCollGain = big5(slice2[spBase + 2]);
|
|
32012
|
+
const spStashed = big5(slice2[spBase + 3]);
|
|
32013
|
+
const collSurplus = branch.collSurplusPool ? big5(slice2[spBase + 4]) : 0n;
|
|
31583
32014
|
const spStable = spDeposit + spYield;
|
|
31584
32015
|
const spColl = spCollGain + spStashed + collSurplus;
|
|
31585
32016
|
if (spStable > 0n || spColl > 0n) {
|
|
@@ -31658,7 +32089,7 @@ var getLiquityUserDataConverter = (lender, chainId, account, meta) => {
|
|
|
31658
32089
|
expected
|
|
31659
32090
|
];
|
|
31660
32091
|
};
|
|
31661
|
-
var
|
|
32092
|
+
var big6 = (v) => {
|
|
31662
32093
|
try {
|
|
31663
32094
|
if (typeof v === "bigint") return v;
|
|
31664
32095
|
if (typeof v === "number" || typeof v === "string") return BigInt(v);
|
|
@@ -31666,7 +32097,7 @@ var big5 = (v) => {
|
|
|
31666
32097
|
}
|
|
31667
32098
|
return 0n;
|
|
31668
32099
|
};
|
|
31669
|
-
var field8 = (res, name, idx) =>
|
|
32100
|
+
var field8 = (res, name, idx) => big6(res?.[name] ?? res?.[idx]);
|
|
31670
32101
|
var getRiverUserDataConverter = (lender, chainId, account, meta) => {
|
|
31671
32102
|
const cfg = riverConfigFor(lender, chainId);
|
|
31672
32103
|
const markets = riverChainData(lender, chainId)?.markets ?? [];
|
|
@@ -31678,13 +32109,13 @@ var getRiverUserDataConverter = (lender, chainId, account, meta) => {
|
|
|
31678
32109
|
const debtAddr = cfg.debtToken.toLowerCase();
|
|
31679
32110
|
const debtDecimals = cfg.debtDecimals ?? 18;
|
|
31680
32111
|
const out = {};
|
|
31681
|
-
const spDeposit =
|
|
32112
|
+
const spDeposit = big6(data[markets.length * RIVER_CALLS_PER_MARKET]);
|
|
31682
32113
|
markets.forEach((market, i) => {
|
|
31683
32114
|
const base = i * RIVER_CALLS_PER_MARKET;
|
|
31684
32115
|
const entire = data[base];
|
|
31685
32116
|
if (isFailedCall(entire) || isFailedCall(data[base + 1])) return;
|
|
31686
|
-
const status = Number(
|
|
31687
|
-
const surplus =
|
|
32117
|
+
const status = Number(big6(data[base + 1]));
|
|
32118
|
+
const surplus = big6(data[base + 2]);
|
|
31688
32119
|
const lenderKey = riverLenderKey(lender, chainId, market.index);
|
|
31689
32120
|
const metaMap = meta?.[lenderKey];
|
|
31690
32121
|
if (!metaMap) return;
|
|
@@ -31792,7 +32223,7 @@ var getRiverUserDataConverter = (lender, chainId, account, meta) => {
|
|
|
31792
32223
|
expected
|
|
31793
32224
|
];
|
|
31794
32225
|
};
|
|
31795
|
-
var
|
|
32226
|
+
var big7 = (v) => {
|
|
31796
32227
|
try {
|
|
31797
32228
|
if (typeof v === "bigint") return v;
|
|
31798
32229
|
if (typeof v === "number" || typeof v === "string") return BigInt(v);
|
|
@@ -31811,24 +32242,24 @@ var getInverseUserDataConverter = (lender, chainId, account, meta) => {
|
|
|
31811
32242
|
const dolaAddr = cfg.dola.toLowerCase();
|
|
31812
32243
|
const debtDecimals = cfg.debtDecimals ?? 18;
|
|
31813
32244
|
const tailBase = markets.length * INVERSE_CALLS_PER_MARKET;
|
|
31814
|
-
const dbrBalance =
|
|
31815
|
-
const dbrDeficit =
|
|
32245
|
+
const dbrBalance = big7(data[tailBase]);
|
|
32246
|
+
const dbrDeficit = big7(data[tailBase + 1]);
|
|
31816
32247
|
const dbrSignedRaw = data[tailBase + 2];
|
|
31817
|
-
const dbrSigned = isFailedCall(dbrSignedRaw) ? 0n :
|
|
32248
|
+
const dbrSigned = isFailedCall(dbrSignedRaw) ? 0n : big7(dbrSignedRaw);
|
|
31818
32249
|
const dbrTotalDebtRaw = data[tailBase + 3];
|
|
31819
|
-
const dbrTotalDebt = isFailedCall(dbrTotalDebtRaw) ? 0n :
|
|
32250
|
+
const dbrTotalDebt = isFailedCall(dbrTotalDebtRaw) ? 0n : big7(dbrTotalDebtRaw);
|
|
31820
32251
|
const dbrRunway = dbrTotalDebt > 0n ? dbrBalance * 31536000n / dbrTotalDebt : 0n;
|
|
31821
32252
|
const nowSec9 = BigInt(Math.floor(Date.now() / 1e3));
|
|
31822
32253
|
const out = {};
|
|
31823
32254
|
markets.forEach((market, i) => {
|
|
31824
32255
|
const base = i * INVERSE_CALLS_PER_MARKET;
|
|
31825
|
-
const escrowBal = isFailedCall(data[base]) ? 0n :
|
|
32256
|
+
const escrowBal = isFailedCall(data[base]) ? 0n : big7(data[base]);
|
|
31826
32257
|
const debtRaw = data[base + 1];
|
|
31827
32258
|
if (isFailedCall(debtRaw)) return;
|
|
31828
|
-
const debt =
|
|
32259
|
+
const debt = big7(debtRaw);
|
|
31829
32260
|
if (escrowBal === 0n && debt === 0n) return;
|
|
31830
|
-
const creditLimit = isFailedCall(data[base + 2]) ? 0n :
|
|
31831
|
-
const withdrawalLimit = isFailedCall(data[base + 3]) ? 0n :
|
|
32261
|
+
const creditLimit = isFailedCall(data[base + 2]) ? 0n : big7(data[base + 2]);
|
|
32262
|
+
const withdrawalLimit = isFailedCall(data[base + 3]) ? 0n : big7(data[base + 3]);
|
|
31832
32263
|
const lenderKey = inverseLenderKey(lender, market.address);
|
|
31833
32264
|
const metaMap = meta?.[lenderKey];
|
|
31834
32265
|
if (!metaMap) return;
|
|
@@ -31914,7 +32345,7 @@ var getInverseUserDataConverter = (lender, chainId, account, meta) => {
|
|
|
31914
32345
|
expected
|
|
31915
32346
|
];
|
|
31916
32347
|
};
|
|
31917
|
-
var
|
|
32348
|
+
var big8 = (v) => {
|
|
31918
32349
|
try {
|
|
31919
32350
|
if (typeof v === "bigint") return v;
|
|
31920
32351
|
if (typeof v === "number" || typeof v === "string") return BigInt(v);
|
|
@@ -31924,7 +32355,7 @@ var big7 = (v) => {
|
|
|
31924
32355
|
};
|
|
31925
32356
|
var arrAt = (v, i) => {
|
|
31926
32357
|
if (isFailedCall(v) || !Array.isArray(v)) return 0n;
|
|
31927
|
-
return
|
|
32358
|
+
return big8(v[i]);
|
|
31928
32359
|
};
|
|
31929
32360
|
var getLlamaLendUserDataConverter = (lender, chainId, account, meta) => {
|
|
31930
32361
|
const cfg = llamaLendConfigFor(lender, chainId);
|
|
@@ -31939,24 +32370,24 @@ var getLlamaLendUserDataConverter = (lender, chainId, account, meta) => {
|
|
|
31939
32370
|
const base = i * LLAMALEND_CALLS_PER_MARKET;
|
|
31940
32371
|
const stateRaw = data[base];
|
|
31941
32372
|
if (isFailedCall(stateRaw) || !Array.isArray(stateRaw)) return;
|
|
31942
|
-
const collateral =
|
|
31943
|
-
const bandBorrowed =
|
|
31944
|
-
const debt =
|
|
31945
|
-
const bandCount = Number(
|
|
32373
|
+
const collateral = big8(stateRaw[0]);
|
|
32374
|
+
const bandBorrowed = big8(stateRaw[1]);
|
|
32375
|
+
const debt = big8(stateRaw[2]);
|
|
32376
|
+
const bandCount = Number(big8(stateRaw[3]));
|
|
31946
32377
|
const vaultSharesRaw = data[base + 5];
|
|
31947
32378
|
const gaugeSharesRaw = data[base + 6];
|
|
31948
|
-
const vaultShares = isFailedCall(vaultSharesRaw) ? 0n :
|
|
31949
|
-
const gaugeShares = isFailedCall(gaugeSharesRaw) ? 0n :
|
|
32379
|
+
const vaultShares = isFailedCall(vaultSharesRaw) ? 0n : big8(vaultSharesRaw);
|
|
32380
|
+
const gaugeShares = isFailedCall(gaugeSharesRaw) ? 0n : big8(gaugeSharesRaw);
|
|
31950
32381
|
const lendShares = vaultShares + gaugeShares;
|
|
31951
32382
|
if (collateral === 0n && debt === 0n && bandBorrowed === 0n && lendShares === 0n)
|
|
31952
32383
|
return;
|
|
31953
32384
|
const healthRaw = data[base + 1];
|
|
31954
|
-
const health = isFailedCall(healthRaw) ? 0n :
|
|
32385
|
+
const health = isFailedCall(healthRaw) ? 0n : big8(healthRaw);
|
|
31955
32386
|
const pricesRaw = data[base + 2];
|
|
31956
32387
|
const priceUpper = arrAt(pricesRaw, 0);
|
|
31957
32388
|
const priceLower = arrAt(pricesRaw, 1);
|
|
31958
32389
|
const ticksRaw = data[base + 3];
|
|
31959
|
-
const bands = isFailedCall(ticksRaw) || !Array.isArray(ticksRaw) ? void 0 : [Number(
|
|
32390
|
+
const bands = isFailedCall(ticksRaw) || !Array.isArray(ticksRaw) ? void 0 : [Number(big8(ticksRaw[0])), Number(big8(ticksRaw[1]))];
|
|
31960
32391
|
const approvalRaw = data[base + 4];
|
|
31961
32392
|
const delegated = isFailedCall(approvalRaw) ? false : approvalRaw === true;
|
|
31962
32393
|
const lenderKey = llamaLendLenderKey(lender, market.controller);
|
|
@@ -31977,7 +32408,7 @@ var getLlamaLendUserDataConverter = (lender, chainId, account, meta) => {
|
|
|
31977
32408
|
const loanOracle = loanMeta ? getOraclePrice(loanMeta) : 0;
|
|
31978
32409
|
const loanHist = loanMeta?.price?.priceUsd24h ?? loanDisplay;
|
|
31979
32410
|
const shareToAssetRaw = data[base + 7];
|
|
31980
|
-
const shareToAsset = isFailedCall(shareToAssetRaw) ? 0n :
|
|
32411
|
+
const shareToAsset = isFailedCall(shareToAssetRaw) ? 0n : big8(shareToAssetRaw);
|
|
31981
32412
|
const lendAssets = shareToAsset === 0n ? 0n : lendShares * shareToAsset / 10n ** 18n;
|
|
31982
32413
|
const lendStr = parseRawAmount(lendAssets.toString(), loanDecimals);
|
|
31983
32414
|
const depositStr = parseRawAmount(
|
|
@@ -32066,7 +32497,7 @@ var getLlamaLendUserDataConverter = (lender, chainId, account, meta) => {
|
|
|
32066
32497
|
expected
|
|
32067
32498
|
];
|
|
32068
32499
|
};
|
|
32069
|
-
var
|
|
32500
|
+
var big9 = (v) => {
|
|
32070
32501
|
try {
|
|
32071
32502
|
if (typeof v === "bigint") return v;
|
|
32072
32503
|
if (typeof v === "number" || typeof v === "string") return BigInt(v);
|
|
@@ -32074,7 +32505,7 @@ var big8 = (v) => {
|
|
|
32074
32505
|
}
|
|
32075
32506
|
return 0n;
|
|
32076
32507
|
};
|
|
32077
|
-
var tupleAt = (v, i) => Array.isArray(v) ?
|
|
32508
|
+
var tupleAt = (v, i) => Array.isArray(v) ? big9(v[i]) : 0n;
|
|
32078
32509
|
var ONE4 = 10n ** 18n;
|
|
32079
32510
|
function sharesToAmount(shares, totalAmount, totalShares) {
|
|
32080
32511
|
if (totalShares === 0n || shares === 0n) return 0n;
|
|
@@ -32100,7 +32531,7 @@ var getResupplyUserDataConverter = (lender, chainId, account, meta) => {
|
|
|
32100
32531
|
if (isFailedCall(accounting) || !Array.isArray(accounting)) return;
|
|
32101
32532
|
const totalBorrowAmount = tupleAt(accounting, 1);
|
|
32102
32533
|
const totalBorrowShares = tupleAt(accounting, 2);
|
|
32103
|
-
const sharePrice = isFailedCall(data[base + 1]) ? 0n :
|
|
32534
|
+
const sharePrice = isFailedCall(data[base + 1]) ? 0n : big9(data[base + 1]);
|
|
32104
32535
|
const lenderKey = resupplyLenderKey(lender, chainId, pair);
|
|
32105
32536
|
const metaMap = meta?.[lenderKey];
|
|
32106
32537
|
if (!metaMap) return;
|
|
@@ -32198,8 +32629,161 @@ var getResupplyUserDataConverter = (lender, chainId, account, meta) => {
|
|
|
32198
32629
|
expected
|
|
32199
32630
|
];
|
|
32200
32631
|
};
|
|
32632
|
+
var big10 = (v) => {
|
|
32633
|
+
try {
|
|
32634
|
+
if (typeof v === "bigint") return v;
|
|
32635
|
+
if (typeof v === "number" || typeof v === "string") return BigInt(v);
|
|
32636
|
+
} catch {
|
|
32637
|
+
}
|
|
32638
|
+
return 0n;
|
|
32639
|
+
};
|
|
32640
|
+
function fraxlendToAmount(shares, totalAmount, totalShares, roundUp) {
|
|
32641
|
+
if (totalShares === 0n) return shares;
|
|
32642
|
+
let amount3 = shares * totalAmount / totalShares;
|
|
32643
|
+
if (roundUp && totalAmount > 0n && amount3 * totalShares / totalAmount < shares) {
|
|
32644
|
+
amount3 = amount3 + 1n;
|
|
32645
|
+
}
|
|
32646
|
+
return amount3;
|
|
32647
|
+
}
|
|
32648
|
+
var getFraxlendUserDataConverter = (lender, chainId, account, meta) => {
|
|
32649
|
+
const pairs = fraxlendPairsFor(lender, chainId);
|
|
32650
|
+
const expected = pairs.length * FRAXLEND_CALLS_PER_PAIR;
|
|
32651
|
+
return [
|
|
32652
|
+
(data) => {
|
|
32653
|
+
if (expected === 0) return void 0;
|
|
32654
|
+
if (!data || data.length < expected) return void 0;
|
|
32655
|
+
const out = {};
|
|
32656
|
+
pairs.forEach((pair, i) => {
|
|
32657
|
+
const base = i * FRAXLEND_CALLS_PER_PAIR;
|
|
32658
|
+
const collRaw = data[base];
|
|
32659
|
+
const sharesRaw = data[base + 1];
|
|
32660
|
+
const fTokenRaw = data[base + 2];
|
|
32661
|
+
const previewRaw = data[base + 3];
|
|
32662
|
+
if (isFailedCall(collRaw) || isFailedCall(sharesRaw)) return;
|
|
32663
|
+
const collateral = big10(collRaw);
|
|
32664
|
+
const borrowShares = big10(sharesRaw);
|
|
32665
|
+
const fTokenShares = isFailedCall(fTokenRaw) ? 0n : big10(fTokenRaw);
|
|
32666
|
+
if (collateral === 0n && borrowShares === 0n && fTokenShares === 0n)
|
|
32667
|
+
return;
|
|
32668
|
+
let totalBorrowAmount = 0n;
|
|
32669
|
+
let totalBorrowShares = 0n;
|
|
32670
|
+
let totalAssetAmount = 0n;
|
|
32671
|
+
let totalAssetShares = 0n;
|
|
32672
|
+
if (!isFailedCall(previewRaw) && previewRaw) {
|
|
32673
|
+
const ta = previewRaw[4];
|
|
32674
|
+
const tb = previewRaw[5];
|
|
32675
|
+
totalAssetAmount = big10(ta?.amount ?? ta?.[0]);
|
|
32676
|
+
totalAssetShares = big10(ta?.shares ?? ta?.[1]);
|
|
32677
|
+
totalBorrowAmount = big10(tb?.amount ?? tb?.[0]);
|
|
32678
|
+
totalBorrowShares = big10(tb?.shares ?? tb?.[1]);
|
|
32679
|
+
}
|
|
32680
|
+
const debt = fraxlendToAmount(
|
|
32681
|
+
borrowShares,
|
|
32682
|
+
totalBorrowAmount,
|
|
32683
|
+
totalBorrowShares,
|
|
32684
|
+
true
|
|
32685
|
+
);
|
|
32686
|
+
const fTokenAssets = fraxlendToAmount(
|
|
32687
|
+
fTokenShares,
|
|
32688
|
+
totalAssetAmount,
|
|
32689
|
+
totalAssetShares,
|
|
32690
|
+
false
|
|
32691
|
+
);
|
|
32692
|
+
const lenderKey = fraxlendLenderKey(lender, chainId, pair.address);
|
|
32693
|
+
const metaMap = meta?.[lenderKey];
|
|
32694
|
+
if (!metaMap) return;
|
|
32695
|
+
const uids = Object.keys(metaMap);
|
|
32696
|
+
const collUid = uids.find(
|
|
32697
|
+
(u) => metaMap[u]?.flags?.collateralActive === true
|
|
32698
|
+
);
|
|
32699
|
+
const loanUid = uids.find(
|
|
32700
|
+
(u) => metaMap[u]?.flags?.borrowingEnabled === true
|
|
32701
|
+
);
|
|
32702
|
+
if (!collUid || !loanUid || collUid === loanUid) return;
|
|
32703
|
+
const collMeta = metaMap[collUid];
|
|
32704
|
+
const loanMeta = metaMap[loanUid];
|
|
32705
|
+
const collAddr = collMeta?.underlying?.toLowerCase() ?? "";
|
|
32706
|
+
const loanAddr = loanMeta?.underlying?.toLowerCase() ?? "";
|
|
32707
|
+
const collDecimals = collMeta?.asset?.decimals ?? 18;
|
|
32708
|
+
const loanDecimals = loanMeta?.asset?.decimals ?? 18;
|
|
32709
|
+
const collDisplay = collMeta ? getDisplayPrice(collMeta) : 0;
|
|
32710
|
+
const collOracle = collMeta ? getOraclePrice(collMeta) : 0;
|
|
32711
|
+
const collHist = collMeta?.price?.priceUsd24h ?? collDisplay;
|
|
32712
|
+
const loanDisplay = loanMeta ? getDisplayPrice(loanMeta) : 0;
|
|
32713
|
+
const loanOracle = loanMeta ? getOraclePrice(loanMeta) : 0;
|
|
32714
|
+
const loanHist = loanMeta?.price?.priceUsd24h ?? loanDisplay;
|
|
32715
|
+
const fraxlendInfo = {
|
|
32716
|
+
borrowShares: borrowShares.toString(),
|
|
32717
|
+
totalBorrowAmount: totalBorrowAmount.toString(),
|
|
32718
|
+
totalBorrowShares: totalBorrowShares.toString(),
|
|
32719
|
+
fTokenShares: fTokenShares.toString(),
|
|
32720
|
+
fTokenAssets: fTokenAssets.toString()
|
|
32721
|
+
};
|
|
32722
|
+
const collStr = parseRawAmount(collateral.toString(), collDecimals);
|
|
32723
|
+
const collNum = Number(collStr);
|
|
32724
|
+
const debtStr = parseRawAmount(debt.toString(), loanDecimals);
|
|
32725
|
+
const debtNum = Number(debtStr);
|
|
32726
|
+
const supplyStr = parseRawAmount(fTokenAssets.toString(), loanDecimals);
|
|
32727
|
+
const supplyNum = Number(supplyStr);
|
|
32728
|
+
const lendingPositions = {
|
|
32729
|
+
"0": {
|
|
32730
|
+
[collUid]: {
|
|
32731
|
+
marketUid: collUid,
|
|
32732
|
+
underlying: collAddr,
|
|
32733
|
+
deposits: collStr,
|
|
32734
|
+
debt: "0",
|
|
32735
|
+
debtStable: "0",
|
|
32736
|
+
depositsUSD: collNum * collDisplay,
|
|
32737
|
+
debtUSD: 0,
|
|
32738
|
+
debtStableUSD: 0,
|
|
32739
|
+
depositsUSDOracle: collNum * collOracle,
|
|
32740
|
+
debtUSDOracle: 0,
|
|
32741
|
+
debtStableUSDOracle: 0,
|
|
32742
|
+
stableBorrowRate: "0",
|
|
32743
|
+
collateralEnabled: true,
|
|
32744
|
+
claimableRewards: 0
|
|
32745
|
+
},
|
|
32746
|
+
[loanUid]: {
|
|
32747
|
+
marketUid: loanUid,
|
|
32748
|
+
underlying: loanAddr,
|
|
32749
|
+
deposits: supplyStr,
|
|
32750
|
+
debt: debtStr,
|
|
32751
|
+
debtStable: "0",
|
|
32752
|
+
depositsUSD: supplyNum * loanDisplay,
|
|
32753
|
+
debtUSD: debtNum * loanDisplay,
|
|
32754
|
+
debtStableUSD: 0,
|
|
32755
|
+
depositsUSDOracle: supplyNum * loanOracle,
|
|
32756
|
+
debtUSDOracle: debtNum * loanOracle,
|
|
32757
|
+
debtStableUSDOracle: 0,
|
|
32758
|
+
stableBorrowRate: "0",
|
|
32759
|
+
// The asset leg is never collateral in its own pair.
|
|
32760
|
+
collateralEnabled: false,
|
|
32761
|
+
claimableRewards: 0,
|
|
32762
|
+
fraxlendInfo
|
|
32763
|
+
}
|
|
32764
|
+
}
|
|
32765
|
+
};
|
|
32766
|
+
const modes = { "0": 0 };
|
|
32767
|
+
const hist = {
|
|
32768
|
+
"0": {
|
|
32769
|
+
totalDeposits24h: collNum * collHist + supplyNum * loanHist,
|
|
32770
|
+
totalDebt24h: debtNum * loanHist
|
|
32771
|
+
}
|
|
32772
|
+
};
|
|
32773
|
+
const userData = createMultiAccountTypeUserState(
|
|
32774
|
+
{ chainId, account, lendingPositions, modes },
|
|
32775
|
+
metaMap,
|
|
32776
|
+
hist
|
|
32777
|
+
);
|
|
32778
|
+
if (userData && userData.data.length > 0) out[lenderKey] = userData;
|
|
32779
|
+
});
|
|
32780
|
+
return Object.keys(out).length > 0 ? out : void 0;
|
|
32781
|
+
},
|
|
32782
|
+
expected
|
|
32783
|
+
];
|
|
32784
|
+
};
|
|
32201
32785
|
var WAD13 = 10n ** 18n;
|
|
32202
|
-
var
|
|
32786
|
+
var big11 = (v) => {
|
|
32203
32787
|
try {
|
|
32204
32788
|
if (typeof v === "bigint") return v;
|
|
32205
32789
|
if (typeof v === "number" || typeof v === "string") return BigInt(v);
|
|
@@ -32207,7 +32791,7 @@ var big9 = (v) => {
|
|
|
32207
32791
|
}
|
|
32208
32792
|
return 0n;
|
|
32209
32793
|
};
|
|
32210
|
-
var tupleAt2 = (v, i) => Array.isArray(v) ?
|
|
32794
|
+
var tupleAt2 = (v, i) => Array.isArray(v) ? big11(v[i]) : 0n;
|
|
32211
32795
|
var HOLD_PERIOD_SECONDS = 1200n;
|
|
32212
32796
|
var getCurvanceUserDataConverter = (lender, chainId, account, meta) => {
|
|
32213
32797
|
const cfg = curvanceConfigFor(lender, chainId);
|
|
@@ -32230,7 +32814,7 @@ var getCurvanceUserDataConverter = (lender, chainId, account, meta) => {
|
|
|
32230
32814
|
const cooldownRaw = data[base];
|
|
32231
32815
|
const status = data[base + 1];
|
|
32232
32816
|
if (isFailedCall(status) || !Array.isArray(status)) continue;
|
|
32233
|
-
const cooldownTimestamp = isFailedCall(cooldownRaw) ? 0n :
|
|
32817
|
+
const cooldownTimestamp = isFailedCall(cooldownRaw) ? 0n : big11(cooldownRaw);
|
|
32234
32818
|
const holdPeriodEndsAt = cooldownTimestamp > 0n ? cooldownTimestamp + HOLD_PERIOD_SECONDS : 0n;
|
|
32235
32819
|
const holdPeriodActive = holdPeriodEndsAt > nowSeconds;
|
|
32236
32820
|
const lenderKey = curvanceLenderKey(lender, chainId, p.marketManager);
|
|
@@ -32252,10 +32836,10 @@ var getCurvanceUserDataConverter = (lender, chainId, account, meta) => {
|
|
|
32252
32836
|
let rows = 0;
|
|
32253
32837
|
p.activeTokens.forEach(({ cToken, asset }, i) => {
|
|
32254
32838
|
const tokenBase = base + CURVANCE_MARKET_READS + i * CURVANCE_READS_PER_TOKEN;
|
|
32255
|
-
const shares = isFailedCall(data[tokenBase]) ? 0n :
|
|
32256
|
-
const collateralShares = isFailedCall(data[tokenBase + 1]) ? 0n :
|
|
32257
|
-
const debtRaw = isFailedCall(data[tokenBase + 2]) ? 0n :
|
|
32258
|
-
const exchangeRate = isFailedCall(data[tokenBase + 3]) ? 0n :
|
|
32839
|
+
const shares = isFailedCall(data[tokenBase]) ? 0n : big11(data[tokenBase]);
|
|
32840
|
+
const collateralShares = isFailedCall(data[tokenBase + 1]) ? 0n : big11(data[tokenBase + 1]);
|
|
32841
|
+
const debtRaw = isFailedCall(data[tokenBase + 2]) ? 0n : big11(data[tokenBase + 2]);
|
|
32842
|
+
const exchangeRate = isFailedCall(data[tokenBase + 3]) ? 0n : big11(data[tokenBase + 3]);
|
|
32259
32843
|
info.tokens[cToken.toLowerCase()] = {
|
|
32260
32844
|
shares: shares.toString(),
|
|
32261
32845
|
collateralShares: collateralShares.toString(),
|
|
@@ -32315,7 +32899,7 @@ var getCurvanceUserDataConverter = (lender, chainId, account, meta) => {
|
|
|
32315
32899
|
];
|
|
32316
32900
|
};
|
|
32317
32901
|
var RAY5 = 10n ** 27n;
|
|
32318
|
-
var
|
|
32902
|
+
var big12 = (v) => {
|
|
32319
32903
|
try {
|
|
32320
32904
|
if (typeof v === "bigint") return v;
|
|
32321
32905
|
if (typeof v === "number" || typeof v === "string") return BigInt(v);
|
|
@@ -32323,7 +32907,7 @@ var big10 = (v) => {
|
|
|
32323
32907
|
}
|
|
32324
32908
|
return 0n;
|
|
32325
32909
|
};
|
|
32326
|
-
var field9 = (res, name, idx) =>
|
|
32910
|
+
var field9 = (res, name, idx) => big12(res?.[name] ?? res?.[idx]);
|
|
32327
32911
|
var getDssUserDataConverter = (lender, chainId, account, meta) => {
|
|
32328
32912
|
const cfg = dssConfigFor(lender, chainId);
|
|
32329
32913
|
const markets = dssChainData(lender, chainId)?.markets ?? [];
|
|
@@ -32438,7 +33022,7 @@ var getDssUserDataConverter = (lender, chainId, account, meta) => {
|
|
|
32438
33022
|
expected
|
|
32439
33023
|
];
|
|
32440
33024
|
};
|
|
32441
|
-
var
|
|
33025
|
+
var big13 = (v) => {
|
|
32442
33026
|
try {
|
|
32443
33027
|
if (typeof v === "bigint") return v;
|
|
32444
33028
|
if (typeof v === "number" || typeof v === "string") return BigInt(v);
|
|
@@ -32468,11 +33052,11 @@ var getFrankencoinUserDataConverter = (lender, chainId, account, meta) => {
|
|
|
32468
33052
|
const ownerRes = data[base];
|
|
32469
33053
|
if (isFailedCall(ownerRes)) return;
|
|
32470
33054
|
if (String(ownerRes).toLowerCase() !== lowerAccount) return;
|
|
32471
|
-
const minted =
|
|
32472
|
-
const price2 =
|
|
32473
|
-
const expiration =
|
|
32474
|
-
const challenged =
|
|
32475
|
-
const coll =
|
|
33055
|
+
const minted = big13(data[base + 1]);
|
|
33056
|
+
const price2 = big13(data[base + 2]);
|
|
33057
|
+
const expiration = big13(data[base + 3]);
|
|
33058
|
+
const challenged = big13(data[base + 4]);
|
|
33059
|
+
const coll = big13(data[base + 5]);
|
|
32476
33060
|
if (minted === 0n && coll === 0n) return;
|
|
32477
33061
|
const market = marketByOriginal.get(p.original);
|
|
32478
33062
|
if (!market) return;
|
|
@@ -32573,7 +33157,7 @@ var getFrankencoinUserDataConverter = (lender, chainId, account, meta) => {
|
|
|
32573
33157
|
|
|
32574
33158
|
// src/lending/user-data/teller/userCallParse.ts
|
|
32575
33159
|
var nowSec7 = () => Math.floor(Date.now() / 1e3);
|
|
32576
|
-
var
|
|
33160
|
+
var big14 = (v) => {
|
|
32577
33161
|
try {
|
|
32578
33162
|
if (typeof v === "bigint") return v;
|
|
32579
33163
|
if (typeof v === "number" || typeof v === "string") return BigInt(v);
|
|
@@ -32595,7 +33179,7 @@ var getTellerUserDataConverter = (_lender, chainId, account, meta) => {
|
|
|
32595
33179
|
const base = i * TELLER_CALLS_PER_BID;
|
|
32596
33180
|
const bidRes = data[base];
|
|
32597
33181
|
const owed = data[base + 1];
|
|
32598
|
-
const collAmount =
|
|
33182
|
+
const collAmount = big14(data[base + 2]);
|
|
32599
33183
|
const defaulted = !!data[base + 3];
|
|
32600
33184
|
if (isFailedCall(bidRes) || isFailedCall(owed) || !bidRes) return;
|
|
32601
33185
|
const pool = b.pool;
|
|
@@ -32616,17 +33200,17 @@ var getTellerUserDataConverter = (_lender, chainId, account, meta) => {
|
|
|
32616
33200
|
const collDisplay = collMeta ? getDisplayPrice(collMeta) : 0;
|
|
32617
33201
|
const collOracle = collMeta ? getOraclePrice(collMeta) : 0;
|
|
32618
33202
|
const collHist = collMeta?.price?.priceUsd24h ?? collDisplay;
|
|
32619
|
-
const owedPrincipal =
|
|
32620
|
-
const owedInterest =
|
|
33203
|
+
const owedPrincipal = big14(field10(owed, "principal", 0));
|
|
33204
|
+
const owedInterest = big14(field10(owed, "interest", 1));
|
|
32621
33205
|
const owedTotal = owedPrincipal + owedInterest;
|
|
32622
33206
|
if (owedTotal === 0n && collAmount === 0n) return;
|
|
32623
33207
|
const loanDetails = field10(bidRes, "loanDetails", 5);
|
|
32624
33208
|
const terms = field10(bidRes, "terms", 6);
|
|
32625
33209
|
const acceptedTs = Number(
|
|
32626
|
-
|
|
33210
|
+
big14(field10(loanDetails, "acceptedTimestamp", 4))
|
|
32627
33211
|
);
|
|
32628
|
-
const loanDuration = Number(
|
|
32629
|
-
const aprBps = Number(
|
|
33212
|
+
const loanDuration = Number(big14(field10(loanDetails, "loanDuration", 6)));
|
|
33213
|
+
const aprBps = Number(big14(field10(terms, "APR", 2)));
|
|
32630
33214
|
const maturity = acceptedTs > 0 ? acceptedTs + loanDuration : void 0;
|
|
32631
33215
|
const isMatured2 = defaulted || maturity !== void 0 && maturity < now;
|
|
32632
33216
|
const collStr = parseRawAmount(collAmount.toString(), collDecimals);
|
|
@@ -33007,6 +33591,8 @@ function getUserDataConverter(lender, chainId, account, params, meta) {
|
|
|
33007
33591
|
return getLlamaLendUserDataConverter(lender, chainId, account, meta);
|
|
33008
33592
|
if (isResupply(lender))
|
|
33009
33593
|
return getResupplyUserDataConverter(lender, chainId, account, meta);
|
|
33594
|
+
if (isFraxlend(lender))
|
|
33595
|
+
return getFraxlendUserDataConverter(lender, chainId, account, meta);
|
|
33010
33596
|
if (isCurvance(lender))
|
|
33011
33597
|
return getCurvanceUserDataConverter(lender, chainId, account, meta);
|
|
33012
33598
|
if (isDssType(lender))
|
|
@@ -37671,6 +38257,7 @@ var getAbi2 = (lender) => {
|
|
|
37671
38257
|
if (isDssType(lender)) return [...UsddVatAbi];
|
|
37672
38258
|
if (isFrankencoin(lender))
|
|
37673
38259
|
return [...FrankencoinPositionAbi, ...erc20Abi];
|
|
38260
|
+
if (isFraxlend(lender)) return [...FraxlendPairAbi];
|
|
37674
38261
|
if (isResupply(lender))
|
|
37675
38262
|
return [...ResupplyPairAbi, ...VAULT_CONVERT_ABI];
|
|
37676
38263
|
if (isCurvance(lender))
|
|
@@ -47021,7 +47608,7 @@ var DLEND_POOLS = [
|
|
|
47021
47608
|
}
|
|
47022
47609
|
];
|
|
47023
47610
|
var ZERO_ADDRESS5 = "0x0000000000000000000000000000000000000000";
|
|
47024
|
-
var
|
|
47611
|
+
var SECONDS_PER_YEAR12 = 31536e3;
|
|
47025
47612
|
var ABI = [
|
|
47026
47613
|
{
|
|
47027
47614
|
name: "getReservesList",
|
|
@@ -47162,7 +47749,7 @@ function rebateApr(params) {
|
|
|
47162
47749
|
if (nowSeconds >= Number(distributionEnd)) return 0;
|
|
47163
47750
|
if (emissionPerSecond <= 0n || balanceTotalSupply <= 0n) return 0;
|
|
47164
47751
|
if (!(rewardPrice > 0) || !(assetPrice > 0)) return 0;
|
|
47165
|
-
const rewardsPerYearUsd = scale(emissionPerSecond, rewardDecimals) *
|
|
47752
|
+
const rewardsPerYearUsd = scale(emissionPerSecond, rewardDecimals) * SECONDS_PER_YEAR12 * rewardPrice;
|
|
47166
47753
|
const baseUsd = scale(balanceTotalSupply, balanceDecimals) * assetPrice;
|
|
47167
47754
|
if (!(baseUsd > 0)) return 0;
|
|
47168
47755
|
return rewardsPerYearUsd / baseUsd * 100;
|
|
@@ -47350,7 +47937,7 @@ var dtrinityRebateRewardFetcher = {
|
|
|
47350
47937
|
return { byLender: merged };
|
|
47351
47938
|
}
|
|
47352
47939
|
};
|
|
47353
|
-
var
|
|
47940
|
+
var SECONDS_PER_YEAR13 = 31536e3;
|
|
47354
47941
|
var WAD14 = 10n ** 18n;
|
|
47355
47942
|
var ZERO2 = "0x0000000000000000000000000000000000000000";
|
|
47356
47943
|
var UNBOOSTED_FACTOR = 0.4;
|
|
@@ -47458,7 +48045,7 @@ function crvGaugeApr(params) {
|
|
|
47458
48045
|
return 0;
|
|
47459
48046
|
}
|
|
47460
48047
|
if (!(crvPriceUsd > 0) || !(assetPriceUsd > 0)) return 0;
|
|
47461
|
-
const crvPerYear = scale2(inflationRate, 18) * scale2(relativeWeight, 18) *
|
|
48048
|
+
const crvPerYear = scale2(inflationRate, 18) * scale2(relativeWeight, 18) * SECONDS_PER_YEAR13;
|
|
47462
48049
|
const stakedUsd = scale2(workingSupply, 18) * scale2(pricePerShare, 18) * assetPriceUsd;
|
|
47463
48050
|
if (!(stakedUsd > 0)) return 0;
|
|
47464
48051
|
return crvPerYear * crvPriceUsd / stakedUsd * 100 * UNBOOSTED_FACTOR;
|
|
@@ -47477,7 +48064,7 @@ function extraRewardApr(params) {
|
|
|
47477
48064
|
if (nowSeconds >= Number(periodFinish)) return 0;
|
|
47478
48065
|
if (rate <= 0n || totalSupply <= 0n) return 0;
|
|
47479
48066
|
if (!(rewardPriceUsd > 0) || !(assetPriceUsd > 0)) return 0;
|
|
47480
|
-
const rewardPerYearUsd = scale2(rate, rewardDecimals) *
|
|
48067
|
+
const rewardPerYearUsd = scale2(rate, rewardDecimals) * SECONDS_PER_YEAR13 * rewardPriceUsd;
|
|
47481
48068
|
const stakedUsd = scale2(totalSupply, 18) * scale2(pricePerShare, 18) * assetPriceUsd;
|
|
47482
48069
|
if (!(stakedUsd > 0)) return 0;
|
|
47483
48070
|
return rewardPerYearUsd / stakedUsd * 100;
|
|
@@ -47585,7 +48172,7 @@ async function fetchForChain(chainId, nowSeconds) {
|
|
|
47585
48172
|
abi: GAUGE_ABI,
|
|
47586
48173
|
allowFailure: true
|
|
47587
48174
|
});
|
|
47588
|
-
const
|
|
48175
|
+
const big18 = (v) => {
|
|
47589
48176
|
try {
|
|
47590
48177
|
if (typeof v === "bigint") return v;
|
|
47591
48178
|
if (typeof v === "string" && v !== "0x") return BigInt(v);
|
|
@@ -47599,15 +48186,15 @@ async function fetchForChain(chainId, nowSeconds) {
|
|
|
47599
48186
|
const b = i * STRIDE;
|
|
47600
48187
|
return {
|
|
47601
48188
|
market: m,
|
|
47602
|
-
inflationRate:
|
|
47603
|
-
workingSupply:
|
|
47604
|
-
totalSupply:
|
|
48189
|
+
inflationRate: big18(r1[b]),
|
|
48190
|
+
workingSupply: big18(r1[b + 1]),
|
|
48191
|
+
totalSupply: big18(r1[b + 2]),
|
|
47605
48192
|
isKilled: r1[b + 3] === true,
|
|
47606
|
-
rewardCount: Number(
|
|
47607
|
-
pricePerShare:
|
|
48193
|
+
rewardCount: Number(big18(r1[b + 4])),
|
|
48194
|
+
pricePerShare: big18(r1[b + 5]),
|
|
47608
48195
|
// Off L1 the child gauge's own rate is already market-scoped, so the
|
|
47609
48196
|
// weight is the identity.
|
|
47610
|
-
relativeWeight: isL1 ?
|
|
48197
|
+
relativeWeight: isL1 ? big18(r1[b + 6]) : WAD14
|
|
47611
48198
|
};
|
|
47612
48199
|
});
|
|
47613
48200
|
const tokenCalls = state.flatMap(
|
|
@@ -47700,7 +48287,7 @@ async function fetchForChain(chainId, nowSeconds) {
|
|
|
47700
48287
|
const decoded = decodeRewardData(data);
|
|
47701
48288
|
if (!decoded) continue;
|
|
47702
48289
|
const { periodFinish, rate } = decoded;
|
|
47703
|
-
const decimals = typeof decRaw === "number" ? decRaw : Number(
|
|
48290
|
+
const decimals = typeof decRaw === "number" ? decRaw : Number(big18(decRaw) || 18n);
|
|
47704
48291
|
const rewardPrice = priceOf(prices, chainId, token);
|
|
47705
48292
|
const apr = extraRewardApr({
|
|
47706
48293
|
rate,
|
|
@@ -48715,7 +49302,7 @@ function getDssCalls(chainId) {
|
|
|
48715
49302
|
return results;
|
|
48716
49303
|
}
|
|
48717
49304
|
var RAY8 = 1e27;
|
|
48718
|
-
var
|
|
49305
|
+
var big15 = (v) => {
|
|
48719
49306
|
try {
|
|
48720
49307
|
if (typeof v === "bigint") return v;
|
|
48721
49308
|
if (v == null || v === "0x") return 0n;
|
|
@@ -48727,16 +49314,16 @@ var big13 = (v) => {
|
|
|
48727
49314
|
var field12 = (res, name, idx) => {
|
|
48728
49315
|
const v = res?.[name];
|
|
48729
49316
|
if (typeof v === "bigint" || typeof v === "number" || typeof v === "string") {
|
|
48730
|
-
return
|
|
49317
|
+
return big15(v);
|
|
48731
49318
|
}
|
|
48732
|
-
return
|
|
49319
|
+
return big15(res?.[idx]);
|
|
48733
49320
|
};
|
|
48734
49321
|
function parseDssResults(data, meta, context) {
|
|
48735
49322
|
const { chainId } = context;
|
|
48736
49323
|
const key3 = dssLenderKey(meta.lender, chainId, meta.ilk);
|
|
48737
49324
|
const entries = [];
|
|
48738
49325
|
const spot = field12(data?.[0], "spot", 2);
|
|
48739
|
-
const mat =
|
|
49326
|
+
const mat = big15(meta.mat);
|
|
48740
49327
|
if (spot > 0n && mat > 0n) {
|
|
48741
49328
|
const collUSD = Number(spot) / RAY8 * (Number(mat) / RAY8);
|
|
48742
49329
|
if (collUSD > 0 && collUSD < 1e9) {
|
|
@@ -49105,13 +49692,13 @@ function getTermMaxCalls(chainId) {
|
|
|
49105
49692
|
function readUsdPrice(res) {
|
|
49106
49693
|
if (res == null || res === "0x") return void 0;
|
|
49107
49694
|
let raw;
|
|
49108
|
-
let
|
|
49695
|
+
let dec2;
|
|
49109
49696
|
if (Array.isArray(res)) {
|
|
49110
49697
|
raw = res[0];
|
|
49111
|
-
|
|
49698
|
+
dec2 = res[1];
|
|
49112
49699
|
} else if (typeof res === "object") {
|
|
49113
49700
|
raw = res.price;
|
|
49114
|
-
|
|
49701
|
+
dec2 = res.decimals;
|
|
49115
49702
|
} else {
|
|
49116
49703
|
return void 0;
|
|
49117
49704
|
}
|
|
@@ -49122,7 +49709,7 @@ function readUsdPrice(res) {
|
|
|
49122
49709
|
return void 0;
|
|
49123
49710
|
}
|
|
49124
49711
|
if (price2 <= 0n) return void 0;
|
|
49125
|
-
const decimals = Number(
|
|
49712
|
+
const decimals = Number(dec2);
|
|
49126
49713
|
if (!Number.isFinite(decimals) || decimals < 0 || decimals > 36) return void 0;
|
|
49127
49714
|
const usd = Number(price2) / 10 ** decimals;
|
|
49128
49715
|
return Number.isFinite(usd) && usd > 0 ? usd : void 0;
|
|
@@ -52656,13 +53243,13 @@ var fetchFluidFTokens = async (chainId, multicallRetry, prices = {}, tokenList =
|
|
|
52656
53243
|
multicallRetry
|
|
52657
53244
|
);
|
|
52658
53245
|
for (const f of Object.values(fTokens)) {
|
|
52659
|
-
const
|
|
52660
|
-
if (
|
|
53246
|
+
const dec2 = assetDec.get(f.underlying);
|
|
53247
|
+
if (dec2 == null || dec2 === f.decimals) continue;
|
|
52661
53248
|
const price2 = f.priceUsd ?? 0;
|
|
52662
|
-
f.decimals =
|
|
52663
|
-
f.totalAssetsFormatted = Number(parseRawAmount(f.totalAssets,
|
|
53249
|
+
f.decimals = dec2;
|
|
53250
|
+
f.totalAssetsFormatted = Number(parseRawAmount(f.totalAssets, dec2));
|
|
52664
53251
|
f.totalAssetsUsd = f.totalAssetsFormatted * price2;
|
|
52665
|
-
f.liquidityFormatted = Number(parseRawAmount(f.liquidity,
|
|
53252
|
+
f.liquidityFormatted = Number(parseRawAmount(f.liquidity, dec2));
|
|
52666
53253
|
f.liquidityUsd = f.liquidityFormatted * price2;
|
|
52667
53254
|
}
|
|
52668
53255
|
} catch {
|
|
@@ -52772,8 +53359,8 @@ function deriveConvertToAssets(totalAssetsRaw, totalSupplyRaw, shareDecimals) {
|
|
|
52772
53359
|
const ta = BigInt(totalAssetsRaw ?? 0);
|
|
52773
53360
|
const ts = BigInt(totalSupplyRaw ?? 0);
|
|
52774
53361
|
if (ts <= 0n) return "0";
|
|
52775
|
-
const
|
|
52776
|
-
const probe = 10n ** BigInt(
|
|
53362
|
+
const dec2 = Math.max(0, Math.round(Number(shareDecimals) || 0));
|
|
53363
|
+
const probe = 10n ** BigInt(dec2);
|
|
52777
53364
|
return (ta * probe / ts).toString();
|
|
52778
53365
|
} catch {
|
|
52779
53366
|
return "0";
|
|
@@ -54613,8 +55200,8 @@ function safeBigInt2(v) {
|
|
|
54613
55200
|
function rescaleExchangeRate(exchangeRate, shareDecimals) {
|
|
54614
55201
|
const r = safeBigInt2(exchangeRate);
|
|
54615
55202
|
if (r === 0n) return "0";
|
|
54616
|
-
const
|
|
54617
|
-
return (r * 10n ** BigInt(
|
|
55203
|
+
const dec2 = Math.max(0, Math.round(Number(shareDecimals) || 0));
|
|
55204
|
+
return (r * 10n ** BigInt(dec2) / 10n ** 18n).toString();
|
|
54618
55205
|
}
|
|
54619
55206
|
async function getJson3(url) {
|
|
54620
55207
|
const controller = new AbortController();
|
|
@@ -54759,7 +55346,7 @@ var num4 = (v) => {
|
|
|
54759
55346
|
const n = Number(v);
|
|
54760
55347
|
return Number.isFinite(n) ? n : 0;
|
|
54761
55348
|
};
|
|
54762
|
-
var
|
|
55349
|
+
var big16 = (v) => {
|
|
54763
55350
|
try {
|
|
54764
55351
|
if (v === void 0 || v === null || v === "") return "0";
|
|
54765
55352
|
const s = String(v);
|
|
@@ -54795,12 +55382,12 @@ async function fetchTermMaxVaultsFromApi(chainId, prices = {}, tokenList = {}, f
|
|
|
54795
55382
|
const assetEntry = tokenList[underlying];
|
|
54796
55383
|
const priceKey = toOracleKey(assetEntry?.assetGroup) || toGenericPriceKey(underlying, chainId);
|
|
54797
55384
|
const priceUsd = prices[priceKey];
|
|
54798
|
-
const totalAssets =
|
|
54799
|
-
const totalSupply =
|
|
55385
|
+
const totalAssets = big16(r.totalAssets);
|
|
55386
|
+
const totalSupply = big16(r.totalSupplyAmt);
|
|
54800
55387
|
const totalAssetsFormatted = Number(totalAssets) / scale3;
|
|
54801
55388
|
const supplyRate = num4(r.apr) * 100;
|
|
54802
55389
|
const rewardsRate = num4(r?.incentiveData?.TMX_APR) * 100;
|
|
54803
|
-
const rawLiquidity = BigInt(
|
|
55390
|
+
const rawLiquidity = BigInt(big16(r.redeemableAmt ?? r.idleFunds ?? "0"));
|
|
54804
55391
|
const totalAssetsBig = BigInt(totalAssets);
|
|
54805
55392
|
const liquidity = (rawLiquidity > totalAssetsBig ? totalAssetsBig : rawLiquidity).toString();
|
|
54806
55393
|
const liquidityFormatted = Number(liquidity) / scale3;
|
|
@@ -54836,7 +55423,7 @@ async function fetchTermMaxVaultsFromApi(chainId, prices = {}, tokenList = {}, f
|
|
|
54836
55423
|
liquidityUsd: priceUsd ? liquidityFormatted * priceUsd : 0,
|
|
54837
55424
|
version: r.version,
|
|
54838
55425
|
isPaused: r.isPaused === true || void 0,
|
|
54839
|
-
supplyCap: r.capacity ?
|
|
55426
|
+
supplyCap: r.capacity ? big16(r.capacity) : void 0,
|
|
54840
55427
|
basePool: r.poolAddress ? lower2(r.poolAddress) : void 0
|
|
54841
55428
|
};
|
|
54842
55429
|
}
|
|
@@ -54892,7 +55479,7 @@ var Erc20DecimalsBalanceAbi = [
|
|
|
54892
55479
|
|
|
54893
55480
|
// src/vaults/termmax/fetchFromChain.ts
|
|
54894
55481
|
var DECIMAL_BASE2 = 100000000n;
|
|
54895
|
-
var
|
|
55482
|
+
var big17 = (v) => {
|
|
54896
55483
|
if (v === void 0 || v === null || v === "0x") return 0n;
|
|
54897
55484
|
try {
|
|
54898
55485
|
return typeof v === "bigint" ? v : BigInt(v);
|
|
@@ -54904,7 +55491,7 @@ var num5 = (v) => {
|
|
|
54904
55491
|
const n = Number(v);
|
|
54905
55492
|
return Number.isFinite(n) ? n : void 0;
|
|
54906
55493
|
};
|
|
54907
|
-
var
|
|
55494
|
+
var str3 = (v) => typeof v === "string" && v.length > 0 ? v : void 0;
|
|
54908
55495
|
var addr = (v) => typeof v === "string" && /^0x[0-9a-fA-F]{40}$/.test(v) && !/^0x0{40}$/.test(v) ? v.toLowerCase() : void 0;
|
|
54909
55496
|
async function discoverVaultAddresses(chainId) {
|
|
54910
55497
|
const markets = await fetchTermMaxMarkets(chainId).catch(() => []);
|
|
@@ -54956,24 +55543,24 @@ var fetchTermMaxVaultsFromChain = async (chainId, multicallRetry, prices = {}, t
|
|
|
54956
55543
|
vaults.forEach((address, i) => {
|
|
54957
55544
|
const at = (k) => res[i * READS_PER_VAULT + VAULT_READS.indexOf(k)];
|
|
54958
55545
|
const asset = addr(at("asset"));
|
|
54959
|
-
const totalAssets =
|
|
55546
|
+
const totalAssets = big17(at("totalAssets"));
|
|
54960
55547
|
if (!asset || totalAssets === 0n) return;
|
|
54961
55548
|
rows.push({
|
|
54962
55549
|
address,
|
|
54963
|
-
name:
|
|
54964
|
-
symbol:
|
|
55550
|
+
name: str3(at("name")),
|
|
55551
|
+
symbol: str3(at("symbol")),
|
|
54965
55552
|
decimals: num5(at("decimals")) ?? 18,
|
|
54966
55553
|
asset,
|
|
54967
55554
|
totalAssets,
|
|
54968
|
-
totalSupply:
|
|
54969
|
-
annualizedInterest:
|
|
54970
|
-
accretingPrincipal:
|
|
54971
|
-
performanceFeeRate:
|
|
54972
|
-
aprRaw: at("apr") != null ?
|
|
55555
|
+
totalSupply: big17(at("totalSupply")),
|
|
55556
|
+
annualizedInterest: big17(at("annualizedInterest")),
|
|
55557
|
+
accretingPrincipal: big17(at("accretingPrincipal")),
|
|
55558
|
+
performanceFeeRate: big17(at("performanceFeeRate")),
|
|
55559
|
+
aprRaw: at("apr") != null ? big17(at("apr")) : void 0,
|
|
54973
55560
|
curator: addr(at("curator")),
|
|
54974
55561
|
guardian: addr(at("guardian")),
|
|
54975
55562
|
timelock: num5(at("timelock")),
|
|
54976
|
-
version:
|
|
55563
|
+
version: str3(at("getVersion"))
|
|
54977
55564
|
});
|
|
54978
55565
|
});
|
|
54979
55566
|
if (rows.length === 0) return {};
|
|
@@ -54990,7 +55577,7 @@ var fetchTermMaxVaultsFromChain = async (chainId, multicallRetry, prices = {}, t
|
|
|
54990
55577
|
const out = {};
|
|
54991
55578
|
rows.forEach((r, i) => {
|
|
54992
55579
|
const assetDecimals = num5(res2[i * 2]) ?? r.decimals;
|
|
54993
|
-
const idle =
|
|
55580
|
+
const idle = big17(res2[i * 2 + 1]);
|
|
54994
55581
|
const assetEntry = tokenList[r.asset];
|
|
54995
55582
|
const priceKey = toOracleKey(assetEntry?.assetGroup) || toGenericPriceKey(r.asset, chainId);
|
|
54996
55583
|
const priceUsd = prices[priceKey];
|
|
@@ -62541,23 +63128,23 @@ var priceGmMarkets = async (chainId, multicallRetry, markets, prices) => {
|
|
|
62541
63128
|
const indexMax = price(prices, m.indexToken)?.max;
|
|
62542
63129
|
if (Array.isArray(dsRes) && longMax != null && shortMax != null) {
|
|
62543
63130
|
const base = i * SLOTS;
|
|
62544
|
-
const
|
|
63131
|
+
const big18 = (j) => typeof dsRes[base + j] === "bigint" ? dsRes[base + j] : 0n;
|
|
62545
63132
|
const cap = computeDepositCapacityUsd(
|
|
62546
|
-
[info?.longTokenAmount, longMax,
|
|
62547
|
-
[info?.shortTokenAmount, shortMax,
|
|
63133
|
+
[info?.longTokenAmount, longMax, big18(0), big18(2)],
|
|
63134
|
+
[info?.shortTokenAmount, shortMax, big18(1), big18(3)]
|
|
62548
63135
|
);
|
|
62549
63136
|
if (cap != null) value.depositCapacityUsd = cap;
|
|
62550
63137
|
if (indexMax != null) {
|
|
62551
63138
|
const divisor = m.longToken.toLowerCase() === m.shortToken.toLowerCase() ? 2n : 1n;
|
|
62552
|
-
const reservedUsdLong = (
|
|
62553
|
-
const reservedUsdShort = (
|
|
63139
|
+
const reservedUsdLong = (big18(4) + big18(5)) / divisor * indexMax;
|
|
63140
|
+
const reservedUsdShort = (big18(6) + big18(7)) / divisor;
|
|
62554
63141
|
const liq = computeLiquidityUsd(
|
|
62555
63142
|
info?.longTokenUsd,
|
|
62556
63143
|
info?.shortTokenUsd,
|
|
62557
63144
|
reservedUsdLong,
|
|
62558
63145
|
reservedUsdShort,
|
|
62559
|
-
|
|
62560
|
-
|
|
63146
|
+
big18(8),
|
|
63147
|
+
big18(9)
|
|
62561
63148
|
);
|
|
62562
63149
|
if (liq != null)
|
|
62563
63150
|
value.liquidityUsd = Math.max(0, Math.min(liq, value.tvlUsd));
|
|
@@ -62756,21 +63343,21 @@ var fetchGmxExecutionFees = async (chainId, multicallRetry, gasPriceWei) => {
|
|
|
62756
63343
|
} catch {
|
|
62757
63344
|
return void 0;
|
|
62758
63345
|
}
|
|
62759
|
-
const
|
|
62760
|
-
const base =
|
|
62761
|
-
const mult =
|
|
63346
|
+
const big18 = (i) => typeof res[i] === "bigint" ? res[i] : 0n;
|
|
63347
|
+
const base = big18(0);
|
|
63348
|
+
const mult = big18(1);
|
|
62762
63349
|
if (base === 0n && mult === 0n) return void 0;
|
|
62763
63350
|
const PRECISION = 10n ** 30n;
|
|
62764
63351
|
const adjusted = (opGas) => base + opGas * mult / PRECISION;
|
|
62765
63352
|
const fee = (opGas) => (adjusted(opGas) * gasPriceWei).toString();
|
|
62766
|
-
const glvExtra =
|
|
63353
|
+
const glvExtra = big18(6) * GLV_NOMINAL_MARKET_COUNT;
|
|
62767
63354
|
return {
|
|
62768
63355
|
chainId,
|
|
62769
63356
|
gasPriceWei: gasPriceWei.toString(),
|
|
62770
|
-
deposit: fee(
|
|
62771
|
-
withdrawal: fee(
|
|
62772
|
-
glvDeposit: fee(
|
|
62773
|
-
glvWithdrawal: fee(
|
|
63357
|
+
deposit: fee(big18(2)),
|
|
63358
|
+
withdrawal: fee(big18(3)),
|
|
63359
|
+
glvDeposit: fee(big18(4) + glvExtra),
|
|
63360
|
+
glvWithdrawal: fee(big18(5) + glvExtra)
|
|
62774
63361
|
};
|
|
62775
63362
|
};
|
|
62776
63363
|
|
|
@@ -62923,7 +63510,7 @@ var fetchGmxVaults = async (chainId, multicallRetry, options) => {
|
|
|
62923
63510
|
// src/vaults/gmx/fetchUser.ts
|
|
62924
63511
|
var DEFAULT_CAP = 50;
|
|
62925
63512
|
var isBig = (v) => typeof v === "bigint";
|
|
62926
|
-
var
|
|
63513
|
+
var str4 = (v) => isBig(v) ? v.toString() : "0";
|
|
62927
63514
|
var getGmxUserPositions = async (chainId, account, multicallRetry, options) => {
|
|
62928
63515
|
const empty = {
|
|
62929
63516
|
chainId,
|
|
@@ -63051,11 +63638,11 @@ var getGmxUserPositions = async (chainId, account, multicallRetry, options) => {
|
|
|
63051
63638
|
market: a.market.toLowerCase(),
|
|
63052
63639
|
initialLongToken: a.initialLongToken.toLowerCase(),
|
|
63053
63640
|
initialShortToken: a.initialShortToken.toLowerCase(),
|
|
63054
|
-
initialLongTokenAmount:
|
|
63055
|
-
initialShortTokenAmount:
|
|
63056
|
-
minOut:
|
|
63057
|
-
executionFee:
|
|
63058
|
-
updatedAtTime:
|
|
63641
|
+
initialLongTokenAmount: str4(n.initialLongTokenAmount),
|
|
63642
|
+
initialShortTokenAmount: str4(n.initialShortTokenAmount),
|
|
63643
|
+
minOut: str4(n.minMarketTokens),
|
|
63644
|
+
executionFee: str4(n.executionFee),
|
|
63645
|
+
updatedAtTime: str4(n.updatedAtTime)
|
|
63059
63646
|
});
|
|
63060
63647
|
});
|
|
63061
63648
|
withdrawalKeys.forEach((key3, i) => {
|
|
@@ -63069,11 +63656,11 @@ var getGmxUserPositions = async (chainId, account, multicallRetry, options) => {
|
|
|
63069
63656
|
account: a.account.toLowerCase(),
|
|
63070
63657
|
receiver: a.receiver.toLowerCase(),
|
|
63071
63658
|
market: a.market.toLowerCase(),
|
|
63072
|
-
tokenAmount:
|
|
63073
|
-
minLongTokenAmount:
|
|
63074
|
-
minShortTokenAmount:
|
|
63075
|
-
executionFee:
|
|
63076
|
-
updatedAtTime:
|
|
63659
|
+
tokenAmount: str4(n.marketTokenAmount),
|
|
63660
|
+
minLongTokenAmount: str4(n.minLongTokenAmount),
|
|
63661
|
+
minShortTokenAmount: str4(n.minShortTokenAmount),
|
|
63662
|
+
executionFee: str4(n.executionFee),
|
|
63663
|
+
updatedAtTime: str4(n.updatedAtTime)
|
|
63077
63664
|
});
|
|
63078
63665
|
});
|
|
63079
63666
|
const glvDeposits = Array.isArray(glvRes[0]) ? glvRes[0] : [];
|
|
@@ -63090,11 +63677,11 @@ var getGmxUserPositions = async (chainId, account, multicallRetry, options) => {
|
|
|
63090
63677
|
glv: a.glv.toLowerCase(),
|
|
63091
63678
|
initialLongToken: a.initialLongToken.toLowerCase(),
|
|
63092
63679
|
initialShortToken: a.initialShortToken.toLowerCase(),
|
|
63093
|
-
initialLongTokenAmount:
|
|
63094
|
-
initialShortTokenAmount:
|
|
63095
|
-
minOut:
|
|
63096
|
-
executionFee:
|
|
63097
|
-
updatedAtTime:
|
|
63680
|
+
initialLongTokenAmount: str4(n.initialLongTokenAmount),
|
|
63681
|
+
initialShortTokenAmount: str4(n.initialShortTokenAmount),
|
|
63682
|
+
minOut: str4(n.minGlvTokens),
|
|
63683
|
+
executionFee: str4(n.executionFee),
|
|
63684
|
+
updatedAtTime: str4(n.updatedAtTime)
|
|
63098
63685
|
});
|
|
63099
63686
|
}
|
|
63100
63687
|
for (const w of glvWithdrawals) {
|
|
@@ -63107,11 +63694,11 @@ var getGmxUserPositions = async (chainId, account, multicallRetry, options) => {
|
|
|
63107
63694
|
receiver: a.receiver.toLowerCase(),
|
|
63108
63695
|
market: a.market.toLowerCase(),
|
|
63109
63696
|
glv: a.glv.toLowerCase(),
|
|
63110
|
-
tokenAmount:
|
|
63111
|
-
minLongTokenAmount:
|
|
63112
|
-
minShortTokenAmount:
|
|
63113
|
-
executionFee:
|
|
63114
|
-
updatedAtTime:
|
|
63697
|
+
tokenAmount: str4(n.glvTokenAmount),
|
|
63698
|
+
minLongTokenAmount: str4(n.minLongTokenAmount),
|
|
63699
|
+
minShortTokenAmount: str4(n.minShortTokenAmount),
|
|
63700
|
+
executionFee: str4(n.executionFee),
|
|
63701
|
+
updatedAtTime: str4(n.updatedAtTime)
|
|
63115
63702
|
});
|
|
63116
63703
|
}
|
|
63117
63704
|
return {
|
|
@@ -64953,6 +65540,27 @@ var TERM_PROFILES = [
|
|
|
64953
65540
|
]
|
|
64954
65541
|
}
|
|
64955
65542
|
}),
|
|
65543
|
+
P({
|
|
65544
|
+
id: "fraxlend.pair@v1",
|
|
65545
|
+
name: "Isolated variable-rate pair (single-ratio)",
|
|
65546
|
+
family: "pool",
|
|
65547
|
+
supply: {
|
|
65548
|
+
description: "An isolated two-asset pair. Deposits earn interest paid by the pair\u2019s borrowers at a utilization-driven rate, and the deposit is exposed to exactly ONE collateral asset rather than a whole pool\u2019s worth.",
|
|
65549
|
+
implications: [
|
|
65550
|
+
"Your yield is not fixed \u2014 it rises and falls with borrowing demand in this pair alone.",
|
|
65551
|
+
"Withdrawals are limited to the cash left unborrowed in the pair; at full utilization they are blocked until borrowers repay.",
|
|
65552
|
+
"Risk is confined to this one collateral asset, which cuts both ways \u2014 no cross-subsidy, but no diversification either."
|
|
65553
|
+
]
|
|
65554
|
+
},
|
|
65555
|
+
borrow: {
|
|
65556
|
+
description: "Borrow the pair\u2019s asset against its one collateral, at a utilization-driven rate. The debt accrues continuously and can be repaid at any time. The maximum LTV is ALSO the liquidation threshold.",
|
|
65557
|
+
implications: [
|
|
65558
|
+
"There is NO buffer between the borrow limit and liquidation \u2014 borrowing the maximum leaves the position immediately liquidatable on any adverse price move.",
|
|
65559
|
+
"The rate can change block to block, and it depends on how long the pair has sat at its current utilization, not only on the utilization itself.",
|
|
65560
|
+
"The collateral price only refreshes when someone interacts with the pair, so a quiet market can value your position off a days-old rate."
|
|
65561
|
+
]
|
|
65562
|
+
}
|
|
65563
|
+
}),
|
|
64956
65564
|
P({
|
|
64957
65565
|
id: "llamalend.soft@v1",
|
|
64958
65566
|
name: "Curve LlamaLend market",
|
|
@@ -65353,10 +65961,10 @@ function resolveMinDebt(input) {
|
|
|
65353
65961
|
];
|
|
65354
65962
|
for (const c of candidates) {
|
|
65355
65963
|
if (c == null) continue;
|
|
65356
|
-
const
|
|
65357
|
-
if (
|
|
65358
|
-
if (!/^\d+$/.test(
|
|
65359
|
-
return
|
|
65964
|
+
const str6 = String(c);
|
|
65965
|
+
if (str6 === "0" || str6 === "") continue;
|
|
65966
|
+
if (!/^\d+$/.test(str6)) continue;
|
|
65967
|
+
return str6;
|
|
65360
65968
|
}
|
|
65361
65969
|
return void 0;
|
|
65362
65970
|
}
|
|
@@ -65364,9 +65972,9 @@ function resolveMinCollateral(input) {
|
|
|
65364
65972
|
const m = input.market ?? {};
|
|
65365
65973
|
const raw = m.frankencoin?.minimumCollateral;
|
|
65366
65974
|
if (raw == null) return void 0;
|
|
65367
|
-
const
|
|
65368
|
-
if (
|
|
65369
|
-
return
|
|
65975
|
+
const str6 = String(raw);
|
|
65976
|
+
if (str6 === "0" || str6 === "" || !/^\d+$/.test(str6)) return void 0;
|
|
65977
|
+
return str6;
|
|
65370
65978
|
}
|
|
65371
65979
|
function capUtil(total, cap) {
|
|
65372
65980
|
if (!isNum(cap) || cap <= 0 || !isNum(total)) return void 0;
|
|
@@ -66821,9 +67429,9 @@ function minLoanInAssetUnits(minLoanUsdWad, priceUsdWad, decimals) {
|
|
|
66821
67429
|
if (floor == null || price2 == null || floor === 0n || price2 === 0n) {
|
|
66822
67430
|
return void 0;
|
|
66823
67431
|
}
|
|
66824
|
-
const
|
|
66825
|
-
if (!Number.isFinite(
|
|
66826
|
-
const scaled = floor * 10n ** BigInt(
|
|
67432
|
+
const dec2 = typeof decimals === "number" ? decimals : Number(decimals);
|
|
67433
|
+
if (!Number.isFinite(dec2) || dec2 < 0 || dec2 > 36) return void 0;
|
|
67434
|
+
const scaled = floor * 10n ** BigInt(dec2);
|
|
66827
67435
|
const units = (scaled + price2 - 1n) / price2;
|
|
66828
67436
|
return units > 0n ? units.toString() : void 0;
|
|
66829
67437
|
}
|
|
@@ -66916,6 +67524,23 @@ var curvanceAdapter = {
|
|
|
66916
67524
|
function numOrUndef(v) {
|
|
66917
67525
|
return typeof v === "number" && Number.isFinite(v) ? v : void 0;
|
|
66918
67526
|
}
|
|
67527
|
+
var fraxlendAdapter = {
|
|
67528
|
+
id: "fraxlend",
|
|
67529
|
+
matches: isFraxlend,
|
|
67530
|
+
profileId: () => "fraxlend.pair@v1",
|
|
67531
|
+
build: () => ({
|
|
67532
|
+
borrow: {
|
|
67533
|
+
debtShape: "accruing",
|
|
67534
|
+
liquidation: {
|
|
67535
|
+
model: "threshold",
|
|
67536
|
+
trigger: "price",
|
|
67537
|
+
// The whole reason this adapter exists: opening at the cap IS opening
|
|
67538
|
+
// at the liquidation point.
|
|
67539
|
+
noBuffer: true
|
|
67540
|
+
}
|
|
67541
|
+
}
|
|
67542
|
+
})
|
|
67543
|
+
};
|
|
66919
67544
|
|
|
66920
67545
|
// src/terms/adapters/index.ts
|
|
66921
67546
|
var TERM_ADAPTERS = [
|
|
@@ -66935,7 +67560,8 @@ var TERM_ADAPTERS = [
|
|
|
66935
67560
|
llamaLendAdapter,
|
|
66936
67561
|
frankencoinAdapter,
|
|
66937
67562
|
resupplyAdapter,
|
|
66938
|
-
curvanceAdapter
|
|
67563
|
+
curvanceAdapter,
|
|
67564
|
+
fraxlendAdapter
|
|
66939
67565
|
];
|
|
66940
67566
|
function resolveAdapter(lender) {
|
|
66941
67567
|
return TERM_ADAPTERS.find((a) => a.matches(lender));
|
|
@@ -67612,6 +68238,25 @@ function earnLabel(dimension, key3) {
|
|
|
67612
68238
|
function earnDescription(dimension, key3) {
|
|
67613
68239
|
return EARN_DESCRIPTIONS[dimension][key3];
|
|
67614
68240
|
}
|
|
68241
|
+
function earnMarketLabel(input) {
|
|
68242
|
+
const asset = input.assetSymbol?.trim();
|
|
68243
|
+
if (!asset) return input.fallbackName ?? "";
|
|
68244
|
+
const collaterals = (input.collateralSymbols ?? []).map((c) => c?.trim()).filter((c) => !!c);
|
|
68245
|
+
const distinct = [...new Set(collaterals)];
|
|
68246
|
+
if (distinct.length === 1) return `${asset} \xB7 vs ${distinct[0]}`;
|
|
68247
|
+
return asset;
|
|
68248
|
+
}
|
|
68249
|
+
var SAME_BLOCK_EXIT_MODES = /* @__PURE__ */ new Set([
|
|
68250
|
+
"instant",
|
|
68251
|
+
"instant-capped"
|
|
68252
|
+
]);
|
|
68253
|
+
function isIlliquid(input) {
|
|
68254
|
+
if (!input.exitMode || !SAME_BLOCK_EXIT_MODES.has(input.exitMode))
|
|
68255
|
+
return false;
|
|
68256
|
+
if (!input.tvlUsd || input.tvlUsd <= 0) return false;
|
|
68257
|
+
if (input.liquidityUsd === void 0) return false;
|
|
68258
|
+
return input.liquidityUsd <= 0;
|
|
68259
|
+
}
|
|
67615
68260
|
|
|
67616
68261
|
// src/earn/normalize.ts
|
|
67617
68262
|
function num13(v) {
|
|
@@ -67619,13 +68264,13 @@ function num13(v) {
|
|
|
67619
68264
|
const n = typeof v === "number" ? v : Number(v);
|
|
67620
68265
|
return Number.isFinite(n) ? n : void 0;
|
|
67621
68266
|
}
|
|
67622
|
-
function
|
|
68267
|
+
function str5(v) {
|
|
67623
68268
|
if (typeof v === "string") return v.length > 0 ? v : void 0;
|
|
67624
68269
|
if (typeof v === "number" && Number.isFinite(v)) return String(v);
|
|
67625
68270
|
return void 0;
|
|
67626
68271
|
}
|
|
67627
68272
|
function addr2(v) {
|
|
67628
|
-
return
|
|
68273
|
+
return str5(v)?.toLowerCase();
|
|
67629
68274
|
}
|
|
67630
68275
|
function yieldProfile(v) {
|
|
67631
68276
|
return v === "yield-bearing" || v === "volatile" ? v : void 0;
|
|
@@ -67708,9 +68353,9 @@ var DEFAULT_EXIT_MODE = {
|
|
|
67708
68353
|
pendle: "market-sale"
|
|
67709
68354
|
};
|
|
67710
68355
|
function earnMarketFromVault(row, chainId, opts = {}) {
|
|
67711
|
-
const provider =
|
|
67712
|
-
const address =
|
|
67713
|
-
const underlying =
|
|
68356
|
+
const provider = str5(row.provider);
|
|
68357
|
+
const address = str5(row.vaultAddress)?.toLowerCase();
|
|
68358
|
+
const underlying = str5(row.underlying)?.toLowerCase();
|
|
67714
68359
|
if (!provider || !address || !underlying) return void 0;
|
|
67715
68360
|
const meta = row.providerMeta ?? {};
|
|
67716
68361
|
const info = row.vaultInfo ?? {};
|
|
@@ -67727,6 +68372,12 @@ function earnMarketFromVault(row, chainId, opts = {}) {
|
|
|
67727
68372
|
total,
|
|
67728
68373
|
base,
|
|
67729
68374
|
rewards,
|
|
68375
|
+
// A vault has no separate intrinsic leg — whatever it pays IS the venue's
|
|
68376
|
+
// own yield. Leaving this undefined rendered an empty "Venue APR" on every
|
|
68377
|
+
// vault row, which read as "this vault pays nothing".
|
|
68378
|
+
marketOwn: total,
|
|
68379
|
+
// ...and for the same reason it can never be pass-through.
|
|
68380
|
+
passthrough: false,
|
|
67730
68381
|
kind: resolveRateKind(provider, meta),
|
|
67731
68382
|
source: RATE_SOURCE[provider] ?? "api"
|
|
67732
68383
|
};
|
|
@@ -67738,22 +68389,22 @@ function earnMarketFromVault(row, chainId, opts = {}) {
|
|
|
67738
68389
|
venue: vaultVenue(provider),
|
|
67739
68390
|
venueKind: "vault",
|
|
67740
68391
|
// Curator first (it names the actual operator), then the provider brand.
|
|
67741
|
-
brand:
|
|
67742
|
-
name:
|
|
68392
|
+
brand: str5(row.curatorName) ?? venueBrand(vaultVenue(provider)),
|
|
68393
|
+
name: str5(info.name) ?? str5(row.displayName) ?? str5(row.name),
|
|
67743
68394
|
ref: address,
|
|
67744
|
-
logoURI:
|
|
68395
|
+
logoURI: str5(info.logoURI) ?? str5(row.underlyingInfo?.asset?.logoURI),
|
|
67745
68396
|
asset: {
|
|
67746
68397
|
address: underlying,
|
|
67747
|
-
symbol:
|
|
68398
|
+
symbol: str5(row.underlyingInfo?.asset?.symbol) ?? "",
|
|
67748
68399
|
decimals: assetDecimals,
|
|
67749
|
-
assetGroup:
|
|
68400
|
+
assetGroup: str5(info.assetGroup),
|
|
67750
68401
|
priceUsd: num13(row.underlyingInfo?.prices?.priceUsd)
|
|
67751
68402
|
},
|
|
67752
68403
|
// The vault IS a share token by construction; carry it so a withdraw in
|
|
67753
68404
|
// share units can be built without a second lookup.
|
|
67754
68405
|
shareToken: {
|
|
67755
68406
|
address,
|
|
67756
|
-
symbol:
|
|
68407
|
+
symbol: str5(info.symbol) ?? str5(row.symbol) ?? "",
|
|
67757
68408
|
decimals: shareDecimals
|
|
67758
68409
|
},
|
|
67759
68410
|
rate,
|
|
@@ -67772,18 +68423,25 @@ function earnMarketFromVault(row, chainId, opts = {}) {
|
|
|
67772
68423
|
liq.liquidityUsd,
|
|
67773
68424
|
assetDecimals
|
|
67774
68425
|
) : void 0,
|
|
67775
|
-
depositCapacity:
|
|
68426
|
+
depositCapacity: str5(meta.depositCapacity) ?? str5(meta.maxDeposit),
|
|
67776
68427
|
maturity,
|
|
67777
68428
|
exit: {
|
|
67778
|
-
mode:
|
|
67779
|
-
settlement:
|
|
68429
|
+
mode: str5(meta.withdrawalMode) ?? DEFAULT_EXIT_MODE[provider] ?? "instant",
|
|
68430
|
+
settlement: str5(meta.redemptionType),
|
|
67780
68431
|
cooldownSecs: num13(meta.withdrawalCooldownSeconds),
|
|
67781
68432
|
feeBps: num13(meta.withdrawFeeBps)
|
|
67782
68433
|
},
|
|
67783
68434
|
availability,
|
|
67784
68435
|
risk: {
|
|
67785
68436
|
yieldProfile: yieldProfile(info.yieldProfile),
|
|
67786
|
-
denomination: denomination(info.denomination)
|
|
68437
|
+
denomination: denomination(info.denomination),
|
|
68438
|
+
score: num13(row.rating?.score),
|
|
68439
|
+
label: str5(row.rating?.level),
|
|
68440
|
+
illiquid: isIlliquid({
|
|
68441
|
+
exitMode: str5(meta.withdrawalMode) ?? DEFAULT_EXIT_MODE[provider] ?? "instant",
|
|
68442
|
+
tvlUsd: num13(tvl.totalAssetsUsd),
|
|
68443
|
+
liquidityUsd: num13(liq.liquidityUsd)
|
|
68444
|
+
})
|
|
67787
68445
|
},
|
|
67788
68446
|
// Filled by `capabilities.ts` — kept required on the type so a normalizer
|
|
67789
68447
|
// that forgets to stamp them is a compile error, not an empty CTA.
|
|
@@ -67807,7 +68465,7 @@ function resolveRateKind(provider, meta) {
|
|
|
67807
68465
|
}
|
|
67808
68466
|
function resolveAvailability(meta, maturity) {
|
|
67809
68467
|
const isMintable = meta.isMintable;
|
|
67810
|
-
const capacity =
|
|
68468
|
+
const capacity = str5(meta.depositCapacity) ?? str5(meta.maxDeposit);
|
|
67811
68469
|
const capFull = capacity === "0";
|
|
67812
68470
|
let gating;
|
|
67813
68471
|
let reason;
|
|
@@ -67843,13 +68501,13 @@ function resolveMaturity(meta) {
|
|
|
67843
68501
|
return {
|
|
67844
68502
|
kind: "fixed-date",
|
|
67845
68503
|
maturity: expiry,
|
|
67846
|
-
maturityIso:
|
|
68504
|
+
maturityIso: str5(meta.expiryIso) ?? new Date(expiry * 1e3).toISOString(),
|
|
67847
68505
|
// A SNAPSHOT — a cached listing ages, so a countdown must be recomputed
|
|
67848
68506
|
// from `maturity` rather than ticked down from this.
|
|
67849
68507
|
secondsToMaturity: Math.max(expiry - nowSecs, 0),
|
|
67850
68508
|
// A PT simply stops earning: it redeems for the underlying at par and
|
|
67851
68509
|
// sits there. No penalty, no liquidation, no auto-roll.
|
|
67852
|
-
atMaturity:
|
|
68510
|
+
atMaturity: str5(meta.atMaturity) ?? "stops-earning"
|
|
67853
68511
|
};
|
|
67854
68512
|
}
|
|
67855
68513
|
function isMatured(maturity) {
|
|
@@ -67888,7 +68546,7 @@ var USER_SET_RATE_PREFIXES = [
|
|
|
67888
68546
|
"EBISU"
|
|
67889
68547
|
];
|
|
67890
68548
|
function earnMarketFromPool(row, fallbackChainId) {
|
|
67891
|
-
const marketUid =
|
|
68549
|
+
const marketUid = str5(row.marketUid);
|
|
67892
68550
|
if (!marketUid) return void 0;
|
|
67893
68551
|
let earnUid;
|
|
67894
68552
|
try {
|
|
@@ -67896,8 +68554,8 @@ function earnMarketFromPool(row, fallbackChainId) {
|
|
|
67896
68554
|
} catch {
|
|
67897
68555
|
return void 0;
|
|
67898
68556
|
}
|
|
67899
|
-
const chainId =
|
|
67900
|
-
const venue =
|
|
68557
|
+
const chainId = str5(row.chainId) ?? fallbackChainId;
|
|
68558
|
+
const venue = str5(row.lender) ?? str5(row.lenderKey);
|
|
67901
68559
|
if (!chainId || !venue) return void 0;
|
|
67902
68560
|
const flags = row.flags ?? {};
|
|
67903
68561
|
const assetInfo = row.underlyingInfo?.asset ?? row.asset ?? {};
|
|
@@ -67931,15 +68589,15 @@ function earnMarketFromPool(row, fallbackChainId) {
|
|
|
67931
68589
|
// The family brand ('Morpho Blue'), not the per-market key. The specific
|
|
67932
68590
|
// market identity survives on `name`.
|
|
67933
68591
|
brand: venueBrand(venue),
|
|
67934
|
-
name:
|
|
68592
|
+
name: str5(row.name),
|
|
67935
68593
|
// Never re-derived — the uid's third segment as the origin minted it.
|
|
67936
68594
|
ref: marketUid.split(":")[2],
|
|
67937
|
-
logoURI:
|
|
68595
|
+
logoURI: str5(assetInfo.logoURI),
|
|
67938
68596
|
asset: {
|
|
67939
68597
|
address: underlying,
|
|
67940
|
-
symbol:
|
|
68598
|
+
symbol: str5(assetInfo.symbol) ?? "",
|
|
67941
68599
|
decimals,
|
|
67942
|
-
assetGroup:
|
|
68600
|
+
assetGroup: str5(row.underlyingInfo?.assetGroup) ?? str5(row.asset?.assetGroup),
|
|
67943
68601
|
priceUsd
|
|
67944
68602
|
},
|
|
67945
68603
|
// A lending supply position is an aToken/cToken/eToken balance, but the
|
|
@@ -67967,7 +68625,15 @@ function earnMarketFromPool(row, fallbackChainId) {
|
|
|
67967
68625
|
// small lie that produces a stuck user.
|
|
67968
68626
|
exit: { mode: "instant-capped", settlement: "sync" },
|
|
67969
68627
|
availability,
|
|
67970
|
-
risk:
|
|
68628
|
+
risk: {
|
|
68629
|
+
score: num13(row.risk?.score),
|
|
68630
|
+
label: str5(row.risk?.label),
|
|
68631
|
+
illiquid: isIlliquid({
|
|
68632
|
+
exitMode: "instant-capped",
|
|
68633
|
+
tvlUsd: num13(row.totalDepositsUSD ?? row.totalDepositsUsd),
|
|
68634
|
+
liquidityUsd: num13(row.totalLiquidityUSD ?? row.totalLiquidityUsd)
|
|
68635
|
+
})
|
|
68636
|
+
},
|
|
67971
68637
|
capabilities: [],
|
|
67972
68638
|
refs: {
|
|
67973
68639
|
marketUid,
|
|
@@ -68156,6 +68822,6 @@ function supportsCancel(provider, meta) {
|
|
|
68156
68822
|
return typeof meta.withdrawQueue === "string" && meta.withdrawQueue.length > 0;
|
|
68157
68823
|
}
|
|
68158
68824
|
|
|
68159
|
-
export { ApiBookSource, DEFAULT_MIDNIGHT_API, DEFAULT_OUTLIER_GUARD, DEFAULT_PROFILE_ID, DEFAULT_STALE_REJECT_SECONDS, DEFAULT_TERMMAX_API, EARN_DESCRIPTIONS, EARN_LABELS, EMPTY_BALANCE, EXACTLY_LENDER_KEY, FRACTION_RATE_PROVIDERS, 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, MULTICALL_FAILURE, MaxParamThresholds, PASSTHROUGH_RATE_EPSILON, PENDLE_ASSETS_URL, PENDLE_CHAIN_IDS, PENDLE_MARKETS_URL, SDK_FRACTION_RATE_PROVIDERS, STABLECOIN_SYMBOLS, STCELO_MANAGER_ADDRESS, TELLER_CALLS_PER_BID, TERMMAX_CALLS_PER_ACCOUNT, DECIMAL_BASE as TERMMAX_DECIMAL_BASE, TERMMAX_LIQUIDATION_PENALTY, TERMMAX_LIQUIDATION_WINDOW_SECS, TERMMAX_LIQUIDATOR_BONUS, TERMMAX_PARTIAL_CLOSE_FACTOR, TERMMAX_PARTIAL_LIQUIDATION_THRESHOLD_USD, TERM_ADAPTERS, TERM_PROFILES, TERM_SHEET_SCHEMA_VERSION, TermMaxApiSource, TermSubgraphSource, UPSHIFT_CHAIN_IDS, UPSHIFT_VAULTS_URL, VAULT_SHARE_PRICE_PROBE, VAULT_VENUE_PREFIX, VOLATILE_VAULT_OVERRIDES, YEARN_CHAIN_IDS, YEARN_YDAEMON_BASE, __resetResupplyUserCaches, accountDepositListKey, accountWithdrawalListKey, appendSnapshot, applyPositionDelta, attachImplications, attachPricesToFlashLiquidity, borrowDescription, borrowFindings, borrowHeadline, buildExposures2 as buildExposures, buildFluidFTokensCall, buildLiquityUserCall, buildLoopResult, buildMorphoTypeCall, buildMorphoTypeUserCallWithLens, buildPortfolioTotals, buildSumerAccumulators, buildSummaries, buildTellerUserCall, buildTermMaxUserCall, buildTermSheet, buildTermSheetsForGroup, buildVaultEarnUid, buildVaultLookup, calculateLeverage, calculateNetApr, calculateOverallNetApr, calculateWeightedAverage, classifyFreshness, classifyReliability, classifyVault, clearPendleMarketsCache, collectFeedObservations, 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, consensusReference, convertDssMarketsToResponse, convertExactlyMarketsToResponse, convertFrankencoinMarketsToResponse, convertInverseMarketsToResponse, convertLenderUserDataResult, convertLiquityMarketsToResponse, convertLlamaLendMarketsToResponse, convertResupplyMarketsToResponse, convertRiverMarketsToResponse, convertTellerMarketsToResponse, convertTermMarketsToResponse, convertTermMaxMarketsToResponse, convertUsddMarketsToResponse, createMarketUid, createMidnightBookSource, createMulticallRpcCall, createRawRpcCalls, createTermBookSource, createTermMaxDataSource, decodeListaMarkets, decodeMarkets, decodePackedListaUserDataset, decodePackedMorphoUserDataset, deriveBorrowTags, deriveSupplyTags, detectInterfaceKinds, dssIlkBytes32, dssKeyParts, dssLenderKey, duration, earnDescription, earnLabel, earnMarketFromPool, earnMarketFromVault, earnUidFromMarketUid, earnVenueKind, encodeBalanceFetcherCalldata, enrichTermSheet, enrichmentIndexFromRows, exactlyPairLtv, exactlyPenaltyRateToAprPercent, exactlyWadRateToPercent, feePhrase, feedKeyOf, feedStatKey, fetchDolomiteAccountNumbers, fetchDssMarkets, fetchEulerEarnVaults, fetchEulerEarnVaultsFromSubgraph, fetchEulerSubAccountIndexes, fetchExactlyMarkets, fetchFlashLiquidityForChain, fetchFluidFTokens, fetchFrankencoinMarkets, fetchGeneralYields, fetchGeneralYieldsByMarketUid, fetchGmxExecutionFees, fetchGmxTickerPrices, fetchGmxVaults, fetchHypercoreVaults, fetchInverseMarkets, fetchLagoonApiVaults, fetchLagoonVaults, fetchLiquityMarkets, fetchListaVaultsFromChain, fetchLlamaLendMarkets, fetchMorphoUserBalances, fetchMorphoUserPositionMarkets, fetchMorphoVaults, fetchMorphoVaultsFromApi, fetchMorphoVaultsFromChain, fetchOraclePrices, fetchPendleApiAssets, fetchPendleApiMarkets, fetchPendlePrices, fetchPendlePtMarkets, fetchResupplyMarkets, fetchRiverMarkets, fetchSiloVaults, fetchTellerMarkets, fetchTermMarkets, fetchTermMaxMarkets, fetchTokenBalances, fetchTokenMetadata, fetchUpshiftApiVaults, fetchUpshiftVaults, fetchUsddMarkets, fetchYearnApiVaults, fetchYearnVaults, filterActiveLenders, filterLendersByProtocol, finalizeInfo, findingsFor, formatRaw, frankencoinKeyParts, frankencoinLenderKey, fuseLenderData, generateLendingPools, getAavesForChain, getAssetConfig, getBalanceForMarketUid, getBorrowCapacity, getCachedLiquityTroves, getCachedTellerBids, getCachedTermMaxDiscovery, getCachedTermMaxMarket, getCachedTermMaxMarkets, 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, getReadFailurePolicy, getResolvedDolomiteAccountNumbers, getStCeloValidatorGroups, getSubAccountAddress, getSubAccountIndex, getTermProfile, getVaultPublicDataAll, getVaultWithdrawalRequests, hasCritical, hasEulerEarnVaultSubgraph, hasLagoonVaults, hasMorphoPositionIndex, hasMorphoUserApi, hasMorphoUserSubgraph, hasPendleMarkets, hasUpshiftVaults, hasYearnVaults, ilkToKeySegment, implausibleRatePercent, inverseKeyParts, inverseLenderKey, isFailedCall, isLiveMarket as isLivePendleMarket, isStablecoinSymbol, isVaultVenue, isYearnV3, keySegmentToIlk, keysFromMaps, lenderApiOnly, lenderFamily, liquityCandidateTroveIds, liquityKeyParts, liquityLenderKey, llamaLendKeyParts, llamaLendLenderKey, mergeDeep, multicall3Abi2 as multicall3Abi, nanTo, needsLenderApproval, needsTokenApproval, noOpResult, normalizeToBytes, parseBalanceFetcherResult, parseEarnUid, parseMergedResult, parseMulticallRpcResponses, parseExpirySeconds as parsePendleExpirySeconds, parseRawRpcBatchResponses, parseRawRpcResponses, parseTermMaxLtv, parseTokenBalanceResult, pct, assetKey as pendleAssetKey, positivePart2 as positivePart, predictInverseEscrow, prepareLenderUserDataRpcCalls, prepareMergedMulticallParams, prepareMergedRpcCalls, prepareMulticallInputs, prepareTokenBalanceRpcCalls, priceGlvVaults, priceGmMarkets, probeAaveFeedTimestamps, pruneFeedStats, rankFindings, ratePercent, readVaultSharePrices, rejectOutliers as rejectPriceOutliers, resolveAdapter, resolveDerivation, resolveStCeloDepositGroup, resupplyKeyParts, resupplyLenderKey, resupplyMarketLabel, riverKeyParts, riverLenderKey, selectAssetGroupPrices, shortDate, splitChainScopedAddress as splitPendleChainScopedAddress, stampCapabilities, stampVaultClassification, supplyDescription, supplyFindings, supplyHeadline, tellerBpsToPercent, tellerImpliedLtv, tellerLenderKey, tellerPoolFromLenderKey, termLenderKey, termMaxApiBase, borrowNif as termMaxBorrowNif, curveApr as termMaxCurveApr, curveAprNumber as termMaxCurveAprNumber, daysToMaturity as termMaxDaysToMaturity, lendNif as termMaxLendNif, mintGtFeeRatio as termMaxMintGtFeeRatio, ratioToNumber as termMaxRatioToNumber, ratioToPercent as termMaxRatioToPercent, tickToAprNumber, tickToPrice, toDigest, toTermSheetInput, tryParseEarnUid, unflattenLenderData, updateFeedStats, usdValue, usddIlkBytes32, usddKeyParts, usddLenderKey, validateTermSheet, validateTermSheets, validateUserData, vaultVenue, venueBrand };
|
|
68825
|
+
export { ApiBookSource, DEFAULT_MIDNIGHT_API, DEFAULT_OUTLIER_GUARD, DEFAULT_PROFILE_ID, DEFAULT_STALE_REJECT_SECONDS, DEFAULT_TERMMAX_API, EARN_DESCRIPTIONS, EARN_LABELS, EMPTY_BALANCE, EXACTLY_LENDER_KEY, FRACTION_RATE_PROVIDERS, 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, MULTICALL_FAILURE, MaxParamThresholds, PASSTHROUGH_RATE_EPSILON, PENDLE_ASSETS_URL, PENDLE_CHAIN_IDS, PENDLE_MARKETS_URL, SDK_FRACTION_RATE_PROVIDERS, STABLECOIN_SYMBOLS, STCELO_MANAGER_ADDRESS, TELLER_CALLS_PER_BID, TERMMAX_CALLS_PER_ACCOUNT, DECIMAL_BASE as TERMMAX_DECIMAL_BASE, TERMMAX_LIQUIDATION_PENALTY, TERMMAX_LIQUIDATION_WINDOW_SECS, TERMMAX_LIQUIDATOR_BONUS, TERMMAX_PARTIAL_CLOSE_FACTOR, TERMMAX_PARTIAL_LIQUIDATION_THRESHOLD_USD, TERM_ADAPTERS, TERM_PROFILES, TERM_SHEET_SCHEMA_VERSION, TermMaxApiSource, TermSubgraphSource, UPSHIFT_CHAIN_IDS, UPSHIFT_VAULTS_URL, VAULT_SHARE_PRICE_PROBE, VAULT_VENUE_PREFIX, VOLATILE_VAULT_OVERRIDES, YEARN_CHAIN_IDS, YEARN_YDAEMON_BASE, __resetResupplyUserCaches, accountDepositListKey, accountWithdrawalListKey, appendSnapshot, applyPositionDelta, attachImplications, attachPricesToFlashLiquidity, borrowDescription, borrowFindings, borrowHeadline, buildExposures2 as buildExposures, buildFluidFTokensCall, buildLiquityUserCall, buildLoopResult, buildMorphoTypeCall, buildMorphoTypeUserCallWithLens, buildPortfolioTotals, buildSumerAccumulators, buildSummaries, buildTellerUserCall, buildTermMaxUserCall, buildTermSheet, buildTermSheetsForGroup, buildVaultEarnUid, buildVaultLookup, calculateLeverage, calculateNetApr, calculateOverallNetApr, calculateWeightedAverage, classifyFreshness, classifyReliability, classifyVault, clearPendleMarketsCache, collectFeedObservations, 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, consensusReference, convertDssMarketsToResponse, convertExactlyMarketsToResponse, convertFrankencoinMarketsToResponse, convertFraxlendPairsToResponse, convertInverseMarketsToResponse, convertLenderUserDataResult, convertLiquityMarketsToResponse, convertLlamaLendMarketsToResponse, convertResupplyMarketsToResponse, convertRiverMarketsToResponse, convertTellerMarketsToResponse, convertTermMarketsToResponse, convertTermMaxMarketsToResponse, convertUsddMarketsToResponse, createMarketUid, createMidnightBookSource, createMulticallRpcCall, createRawRpcCalls, createTermBookSource, createTermMaxDataSource, decodeListaMarkets, decodeMarkets, decodePackedListaUserDataset, decodePackedMorphoUserDataset, deriveBorrowTags, deriveSupplyTags, detectInterfaceKinds, dssIlkBytes32, dssKeyParts, dssLenderKey, duration, earnDescription, earnLabel, earnMarketFromPool, earnMarketFromVault, earnMarketLabel, earnUidFromMarketUid, earnVenueKind, encodeBalanceFetcherCalldata, enrichTermSheet, enrichmentIndexFromRows, exactlyPairLtv, exactlyPenaltyRateToAprPercent, exactlyWadRateToPercent, feePhrase, feedKeyOf, feedStatKey, fetchDolomiteAccountNumbers, fetchDssMarkets, fetchEulerEarnVaults, fetchEulerEarnVaultsFromSubgraph, fetchEulerSubAccountIndexes, fetchExactlyMarkets, fetchFlashLiquidityForChain, fetchFluidFTokens, fetchFrankencoinMarkets, fetchFraxlendPairs, fetchGeneralYields, fetchGeneralYieldsByMarketUid, fetchGmxExecutionFees, fetchGmxTickerPrices, fetchGmxVaults, fetchHypercoreVaults, fetchInverseMarkets, fetchLagoonApiVaults, fetchLagoonVaults, fetchLiquityMarkets, fetchListaVaultsFromChain, fetchLlamaLendMarkets, fetchMorphoUserBalances, fetchMorphoUserPositionMarkets, fetchMorphoVaults, fetchMorphoVaultsFromApi, fetchMorphoVaultsFromChain, fetchOraclePrices, fetchPendleApiAssets, fetchPendleApiMarkets, fetchPendlePrices, fetchPendlePtMarkets, fetchResupplyMarkets, fetchRiverMarkets, fetchSiloVaults, fetchTellerMarkets, fetchTermMarkets, fetchTermMaxMarkets, fetchTokenBalances, fetchTokenMetadata, fetchUpshiftApiVaults, fetchUpshiftVaults, fetchUsddMarkets, fetchYearnApiVaults, fetchYearnVaults, filterActiveLenders, filterLendersByProtocol, finalizeInfo, findingsFor, formatRaw, frankencoinKeyParts, frankencoinLenderKey, fraxlendAssetPerCollateral, fraxlendKeyParts, fraxlendLenderKey, fuseLenderData, generateLendingPools, getAavesForChain, getAssetConfig, getBalanceForMarketUid, getBorrowCapacity, getCachedLiquityTroves, getCachedTellerBids, getCachedTermMaxDiscovery, getCachedTermMaxMarket, getCachedTermMaxMarkets, 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, getReadFailurePolicy, getResolvedDolomiteAccountNumbers, getStCeloValidatorGroups, getSubAccountAddress, getSubAccountIndex, getTermProfile, getVaultPublicDataAll, getVaultWithdrawalRequests, hasCritical, hasEulerEarnVaultSubgraph, hasLagoonVaults, hasMorphoPositionIndex, hasMorphoUserApi, hasMorphoUserSubgraph, hasPendleMarkets, hasUpshiftVaults, hasYearnVaults, ilkToKeySegment, implausibleRatePercent, inverseKeyParts, inverseLenderKey, isFailedCall, isIlliquid, isLiveMarket as isLivePendleMarket, isStablecoinSymbol, isVaultVenue, isYearnV3, keySegmentToIlk, keysFromMaps, lenderApiOnly, lenderFamily, liquityCandidateTroveIds, liquityKeyParts, liquityLenderKey, llamaLendKeyParts, llamaLendLenderKey, mergeDeep, multicall3Abi2 as multicall3Abi, nanTo, needsLenderApproval, needsTokenApproval, noOpResult, normalizeToBytes, parseBalanceFetcherResult, parseEarnUid, parseMergedResult, parseMulticallRpcResponses, parseExpirySeconds as parsePendleExpirySeconds, parseRawRpcBatchResponses, parseRawRpcResponses, parseTermMaxLtv, parseTokenBalanceResult, pct, assetKey as pendleAssetKey, positivePart2 as positivePart, predictInverseEscrow, prepareLenderUserDataRpcCalls, prepareMergedMulticallParams, prepareMergedRpcCalls, prepareMulticallInputs, prepareTokenBalanceRpcCalls, priceGlvVaults, priceGmMarkets, probeAaveFeedTimestamps, pruneFeedStats, rankFindings, ratePercent, readVaultSharePrices, rejectOutliers as rejectPriceOutliers, resolveAdapter, resolveDerivation, resolveStCeloDepositGroup, resupplyKeyParts, resupplyLenderKey, resupplyMarketLabel, riverKeyParts, riverLenderKey, selectAssetGroupPrices, shortDate, splitChainScopedAddress as splitPendleChainScopedAddress, stampCapabilities, stampVaultClassification, supplyDescription, supplyFindings, supplyHeadline, tellerBpsToPercent, tellerImpliedLtv, tellerLenderKey, tellerPoolFromLenderKey, termLenderKey, termMaxApiBase, borrowNif as termMaxBorrowNif, curveApr as termMaxCurveApr, curveAprNumber as termMaxCurveAprNumber, daysToMaturity as termMaxDaysToMaturity, lendNif as termMaxLendNif, mintGtFeeRatio as termMaxMintGtFeeRatio, ratioToNumber as termMaxRatioToNumber, ratioToPercent as termMaxRatioToPercent, tickToAprNumber, tickToPrice, toDigest, toTermSheetInput, tryParseEarnUid, unflattenLenderData, updateFeedStats, usdValue, usddIlkBytes32, usddKeyParts, usddLenderKey, validateTermSheet, validateTermSheets, validateUserData, vaultVenue, venueBrand };
|
|
68160
68826
|
//# sourceMappingURL=index.js.map
|
|
68161
68827
|
//# sourceMappingURL=index.js.map
|