@1delta/margin-fetcher 5.0.55 → 5.0.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -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, isTwyne, isFraxlend, LIQUITY_FAMILY_LENDERS, isAaveType, isCompoundV3, isMultiMarket, isSiloV2Type, isSiloV3Type, isDolomite, hasCrossMarginRisk, isEulerType, isAaveV4Type, isInit, isMorphoType, isCompoundV2Type, isVenusType, isSumerType, AAVE_V3_LENDERS, AAVE_V2_LENDERS, isMorphoBlue, 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, isCooler, isDssType, isCompoundV3Type, isFluid, isGearboxV3, isLlamaLend, isFrankencoin, isResupply, isCurvance, isTwyne, isFraxlend, LIQUITY_FAMILY_LENDERS, isAaveType, isCompoundV3, isMultiMarket, isSiloV2Type, isSiloV3Type, isDolomite, hasCrossMarginRisk, isEulerType, isAaveV4Type, isInit, isMorphoType, isCompoundV2Type, isVenusType, isSumerType, AAVE_V3_LENDERS, AAVE_V2_LENDERS, isMorphoBlue, 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, fraxlendLendersByChain, twyneLendersByChain, 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, listaCollateralProvider, eulerConfigs, gearboxMarketCompressor, gearboxMarketConfigurators, gearboxV3LenderKey, midnightMarketsByChain, twyneConfigFor, twyneChainData, parseAaveV4SpokeLenderKey, fraxlendPairsFor, 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, coolerLendersByChain, llamaLendLendersByChain, usddLendersByChain, skyLendersByChain, frankencoinLendersByChain, resupplyLendersByChain, curvanceLendersByChain, fraxlendLendersByChain, twyneLendersByChain, tellerConfigByChain, tellerPoolsByChain, termMaxConfigByChain, aaveReserves, compoundV3Reserves, liquityConfigFor, liquityBranchesByChain, riverConfigFor, riverChainData, termMaxApiBaseUrl, termMaxLenderKey, inverseConfigFor, inverseChainData, coolerConfigFor, llamaLendConfigFor, llamaLendChainData, llamaLendApiBaseUrl, resupplyConfigFor, fraxlendConfigFor, dssConfigFor, dssChainData, dssDebtToken, dssDebtJoin, frankencoinConfigFor, frankencoinChainData, aaveOracles, morphoTypeMarkets, resolveMidnightApiBase, resolveTermApiBase, llamaLendMarketByVault, getSiloV2MarketEntry, getSiloV3MarketEntry, dolomiteEmode, curvanceConfigFor, aaveTokens, morphoTypeVaults, listaCollateralProvider, eulerConfigs, gearboxMarketCompressor, gearboxMarketConfigurators, gearboxV3LenderKey, midnightMarketsByChain, twyneConfigFor, twyneChainData, 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, FluidDexResolverAbi, ExactlyPreviewerAbi, ExactlyAuditorAbi, LenderCommitmentGroupAbi, ResupplyRegistryAbi, ResupplyPairAbi, ResupplyUtilitiesAbi, ResupplyRewardHandlerAbi, ResupplyPairEmissionsAbi, ConvexPoolUtilAbi, FraxlendPairAbi, FraxlendLeverAbi, 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, TwyneCollateralVaultAbi, GearboxCreditAccountCompressorV310Abi, TwyneVaultManagerAbi, TwyneCollateralVaultFactoryAbi, AaveV2V3Abi, TwyneATokenWrapperAbi, 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, CoolerMonoAbi, CoolerLtvOracleAbi, LlamaLendControllerAbi, LlamaLendControllerV1Abi, LlamaLendControllerV2Abi, LlamaLendVaultAbi, LlamaLendAmmAbi, TwyneCollateralVaultAbi, MetaMorphoAbi, FluidDexResolverAbi, ExactlyPreviewerAbi, ExactlyAuditorAbi, LenderCommitmentGroupAbi, ResupplyRegistryAbi, ResupplyPairAbi, ResupplyUtilitiesAbi, ResupplyRewardHandlerAbi, ResupplyPairEmissionsAbi, ConvexPoolUtilAbi, FraxlendPairAbi, FraxlendLeverAbi, 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, TwyneVaultManagerAbi, TwyneCollateralVaultFactoryAbi, AaveV2V3Abi, TwyneATokenWrapperAbi, 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, getLstAcceptedInputs, getCompoundV3CometAddress as getCompoundV3CometAddress$1, getMorphoAddress, getAaveCollateralTokenAddress, getSiloHalfForUnderlying, findSavingsWithdrawEntry, bandLtvCurve, InitMarginAddresses } from '@1delta/calldata-sdk';
13
13
  import { proxyNativeFetch } from '@1delta/proxy-fetch';
@@ -6418,6 +6418,9 @@ var getLendersForChain = (c) => {
6418
6418
  for (const l of inverseLendersByChain(c)) {
6419
6419
  lenders.push(l);
6420
6420
  }
6421
+ for (const l of coolerLendersByChain(c)) {
6422
+ lenders.push(l);
6423
+ }
6421
6424
  for (const l of llamaLendLendersByChain(c)) {
6422
6425
  lenders.push(l);
6423
6426
  }
@@ -22379,7 +22382,7 @@ async function fetchTellerMarkets(chainId) {
22379
22382
  } catch {
22380
22383
  return { chainId, pools: [] };
22381
22384
  }
22382
- const big20 = (i) => {
22385
+ const big22 = (i) => {
22383
22386
  const r = results[i];
22384
22387
  if (typeof r === "bigint") return r;
22385
22388
  if (typeof r === "number") return BigInt(r);
@@ -22393,20 +22396,20 @@ async function fetchTellerMarkets(chainId) {
22393
22396
  return null;
22394
22397
  };
22395
22398
  const num18 = (i) => {
22396
- const b = big20(i);
22399
+ const b = big22(i);
22397
22400
  return b === null ? null : Number(b);
22398
22401
  };
22399
22402
  const pool0 = pools.map((config, i) => {
22400
22403
  const base = i * READS_PER_POOL;
22401
22404
  return {
22402
22405
  config,
22403
- available: big20(base),
22404
- committed: big20(base + 1),
22406
+ available: big22(base),
22407
+ committed: big22(base + 1),
22405
22408
  minRateBps: num18(base + 2),
22406
- collateralPerPrincipal: big20(base + 3),
22409
+ collateralPerPrincipal: big22(base + 3),
22407
22410
  maxLoanDuration: num18(base + 4),
22408
- marketId: big20(base + 5),
22409
- totalAssets: big20(base + 6)
22411
+ marketId: big22(base + 5),
22412
+ totalAssets: big22(base + 6)
22410
22413
  };
22411
22414
  });
22412
22415
  const attByMarket = /* @__PURE__ */ new Map();
@@ -23479,6 +23482,107 @@ function num(api, key3) {
23479
23482
  const v = api?.[key3];
23480
23483
  return typeof v === "number" && Number.isFinite(v) ? v : null;
23481
23484
  }
23485
+ var SUSDS_MAX_WITHDRAW_ABI = [
23486
+ {
23487
+ name: "maxWithdraw",
23488
+ type: "function",
23489
+ stateMutability: "view",
23490
+ inputs: [{ name: "owner", type: "address" }],
23491
+ outputs: [{ type: "uint256" }]
23492
+ }
23493
+ ];
23494
+ var COOLER_PUBLIC_READ_ABI = [
23495
+ ...CoolerMonoAbi,
23496
+ ...CoolerLtvOracleAbi,
23497
+ ...SUSDS_MAX_WITHDRAW_ABI
23498
+ ];
23499
+ var big = (v) => {
23500
+ try {
23501
+ if (typeof v === "bigint") return v;
23502
+ if (typeof v === "number") return BigInt(v);
23503
+ if (typeof v === "string" && /^(0x[0-9a-fA-F]+|\d+)$/.test(v))
23504
+ return BigInt(v);
23505
+ } catch {
23506
+ }
23507
+ return null;
23508
+ };
23509
+ async function fetchCoolerMarkets(lender, chainId) {
23510
+ const config = coolerConfigFor(lender, chainId);
23511
+ const empty = {
23512
+ lender,
23513
+ config,
23514
+ totalCollateral: null,
23515
+ totalDebt: null,
23516
+ interestRateWad: null,
23517
+ oltvPrice: null,
23518
+ lltvPrice: null,
23519
+ minDebtRequired: null,
23520
+ borrowsPaused: null,
23521
+ liquidationsPaused: null,
23522
+ debtToken: null,
23523
+ collateralToken: null,
23524
+ drip: null,
23525
+ liquidationLtvPremiumBps: null,
23526
+ susdsHeadroom: null,
23527
+ source: "none"
23528
+ };
23529
+ if (!config?.monoCooler) return empty;
23530
+ const mc = config.monoCooler;
23531
+ const calls = [
23532
+ { address: mc, name: "totalCollateral", params: [] },
23533
+ { address: mc, name: "totalDebt", params: [] },
23534
+ { address: mc, name: "interestRateWad", params: [] },
23535
+ { address: mc, name: "loanToValues", params: [] },
23536
+ { address: mc, name: "minDebtRequired", params: [] },
23537
+ { address: mc, name: "borrowsPaused", params: [] },
23538
+ { address: mc, name: "liquidationsPaused", params: [] },
23539
+ { address: mc, name: "debtToken", params: [] },
23540
+ { address: mc, name: "collateralToken", params: [] },
23541
+ { address: config.ltvOracle, name: "originationLtvData", params: [] },
23542
+ { address: config.ltvOracle, name: "liquidationLtvPremiumBps", params: [] },
23543
+ { address: config.susds, name: "maxWithdraw", params: [config.treasury] }
23544
+ ];
23545
+ try {
23546
+ const results = await multicallRetryUniversal({
23547
+ chain: chainId,
23548
+ calls,
23549
+ abi: COOLER_PUBLIC_READ_ABI,
23550
+ allowFailure: true
23551
+ });
23552
+ const ltvs = results[3];
23553
+ const oltvPrice = Array.isArray(ltvs) ? big(ltvs[0]) : null;
23554
+ const lltvPrice = Array.isArray(ltvs) ? big(ltvs[1]) : null;
23555
+ const dripRaw = results[9];
23556
+ let drip = null;
23557
+ if (Array.isArray(dripRaw) && dripRaw.length >= 5) {
23558
+ const [startingValue, startTime, targetValue, targetTime, slope] = dripRaw.map(big);
23559
+ if (startingValue !== null && startTime !== null && targetValue !== null && targetTime !== null && slope !== null) {
23560
+ drip = { startingValue, startTime, targetValue, targetTime, slope };
23561
+ }
23562
+ }
23563
+ const premium = big(results[10]);
23564
+ return {
23565
+ lender,
23566
+ config,
23567
+ totalCollateral: big(results[0]),
23568
+ totalDebt: big(results[1]),
23569
+ interestRateWad: big(results[2]),
23570
+ oltvPrice,
23571
+ lltvPrice,
23572
+ minDebtRequired: big(results[4]),
23573
+ borrowsPaused: typeof results[5] === "boolean" ? results[5] : null,
23574
+ liquidationsPaused: typeof results[6] === "boolean" ? results[6] : null,
23575
+ debtToken: typeof results[7] === "string" && results[7].startsWith("0x") ? results[7] : null,
23576
+ collateralToken: typeof results[8] === "string" && results[8].startsWith("0x") ? results[8] : null,
23577
+ drip,
23578
+ liquidationLtvPremiumBps: premium !== null ? Number(premium) : null,
23579
+ susdsHeadroom: big(results[11]),
23580
+ source: "chain"
23581
+ };
23582
+ } catch {
23583
+ return empty;
23584
+ }
23585
+ }
23482
23586
  var DEFAULT_BANDS = 10;
23483
23587
  var LLAMALEND_READ_ABI = [
23484
23588
  ...LlamaLendControllerAbi,
@@ -23772,7 +23876,7 @@ var STATE_READS = 14;
23772
23876
  var ONE = 10n ** 18n;
23773
23877
  var identityCache = /* @__PURE__ */ new Map();
23774
23878
  var identityKey = (chainId, pair) => `${chainId}:${pair.toLowerCase()}`;
23775
- var big = (v) => {
23879
+ var big2 = (v) => {
23776
23880
  if (typeof v === "bigint") return v;
23777
23881
  if (typeof v === "number") return BigInt(v);
23778
23882
  return null;
@@ -23981,28 +24085,28 @@ async function fetchResupplyMarkets(lender, chainId) {
23981
24085
  const accounting = results[base + 5];
23982
24086
  const rateInfo = results[base + 6];
23983
24087
  const exchangeInfo = results[base + 7];
23984
- const tuple = (v, idx) => Array.isArray(v) ? big(v[idx]) : null;
24088
+ const tuple = (v, idx) => Array.isArray(v) ? big2(v[idx]) : null;
23985
24089
  return {
23986
24090
  identity,
23987
- maxLTV: big(results[base]),
23988
- borrowLimit: big(results[base + 1]),
23989
- liquidationFee: big(results[base + 2]),
23990
- mintFee: big(results[base + 3]),
23991
- minimumBorrowAmount: big(results[base + 4]),
24091
+ maxLTV: big2(results[base]),
24092
+ borrowLimit: big2(results[base + 1]),
24093
+ liquidationFee: big2(results[base + 2]),
24094
+ mintFee: big2(results[base + 3]),
24095
+ minimumBorrowAmount: big2(results[base + 4]),
23992
24096
  totalBorrowAmount: tuple(accounting, 1),
23993
24097
  totalBorrowShares: tuple(accounting, 2),
23994
24098
  totalCollateral: tuple(accounting, 3),
23995
24099
  ratePerSec: tuple(rateInfo, 1),
23996
24100
  exchangeRate: tuple(exchangeInfo, 2),
23997
- collateralPrice: big(results[base + 8]),
24101
+ collateralPrice: big2(results[base + 8]),
23998
24102
  // Indices follow the PUSH ORDER above exactly: the two reward reads sit
23999
24103
  // at +9/+10, BEFORE the lens block, so the lens reads are +11/+12.
24000
24104
  // (Getting this wrong is silent — it produced a 3-billion-percent APR
24001
24105
  // before the numbers were checked against a hand computation.)
24002
- convexPid: big(results[base + 9]),
24003
- rsupWeight: pairEmissions ? big(results[base + 10]) : null,
24004
- liveRatePerSec: utilities ? big(results[base + 11]) : null,
24005
- underlyingSupplyRatePerSec: utilities ? big(results[base + 12]) : null,
24106
+ convexPid: big2(results[base + 9]),
24107
+ rsupWeight: pairEmissions ? big2(results[base + 10]) : null,
24108
+ liveRatePerSec: utilities ? big2(results[base + 11]) : null,
24109
+ underlyingSupplyRatePerSec: utilities ? big2(results[base + 12]) : null,
24006
24110
  collateralRewards: []
24007
24111
  };
24008
24112
  });
@@ -24060,9 +24164,9 @@ async function readRewardContext(chainId, registry, utilities) {
24060
24164
  ],
24061
24165
  allowFailure: true
24062
24166
  });
24063
- const periodFinish = big(stream[0]);
24064
- const rewardRate = big(stream[1]);
24065
- const totalWeight = big(stream[2]);
24167
+ const periodFinish = big2(stream[0]);
24168
+ const rewardRate = big2(stream[1]);
24169
+ const totalWeight = big2(stream[2]);
24066
24170
  if (periodFinish === null || rewardRate === null || totalWeight === null || totalWeight === 0n) {
24067
24171
  return { pairEmissions, convexPoolUtil };
24068
24172
  }
@@ -24131,7 +24235,7 @@ function getCurvanceAssetRoster(chainId, lender) {
24131
24235
  // src/lending/public-data/curvance/fetchPublic.ts
24132
24236
  var FALLBACK_TOKEN_READS = 12;
24133
24237
  var zero = "0x0000000000000000000000000000000000000000";
24134
- var big2 = (v) => {
24238
+ var big3 = (v) => {
24135
24239
  if (typeof v === "bigint") return v;
24136
24240
  if (typeof v === "number") return BigInt(v);
24137
24241
  if (typeof v === "string" && v !== "0x") {
@@ -24246,41 +24350,41 @@ async function fetchViaReader(lender, chainId, config) {
24246
24350
  assetSymbol: str(t?.asset?.symbol, "?"),
24247
24351
  assetName: str(t?.asset?.name, "?"),
24248
24352
  assetDecimals: num3(t?.asset?.decimals, 18),
24249
- collRatio: big2(t?.collRatio),
24250
- collReqSoft: big2(t?.collReqSoft),
24251
- collReqHard: big2(t?.collReqHard),
24252
- liqIncBase: big2(t?.liqIncBase),
24253
- liqIncCurve: big2(t?.liqIncCurve),
24254
- closeFactorBase: big2(t?.closeFactorBase),
24255
- maxLeverage: big2(t?.maxLeverage),
24256
- collateralCap: big2(t?.collateralCap),
24257
- debtCap: big2(t?.debtCap),
24353
+ collRatio: big3(t?.collRatio),
24354
+ collReqSoft: big3(t?.collReqSoft),
24355
+ collReqHard: big3(t?.collReqHard),
24356
+ liqIncBase: big3(t?.liqIncBase),
24357
+ liqIncCurve: big3(t?.liqIncCurve),
24358
+ closeFactorBase: big3(t?.closeFactorBase),
24359
+ maxLeverage: big3(t?.maxLeverage),
24360
+ collateralCap: big3(t?.collateralCap),
24361
+ debtCap: big3(t?.debtCap),
24258
24362
  mintPaused: !!t?.mintPaused,
24259
24363
  collateralizationPaused: !!t?.collateralizationPaused,
24260
24364
  borrowPaused: !!t?.borrowPaused,
24261
24365
  redeemPaused: !!t?.redeemPaused,
24262
- totalAssets: big2(d?.totalAssets),
24263
- totalSupply: big2(d?.totalSupply),
24264
- exchangeRate: big2(d?.exchangeRate),
24265
- collateral: big2(d?.collateral),
24266
- debt: big2(d?.debt),
24267
- liquidity: big2(d?.liquidity),
24268
- assetPrice: big2(d?.assetPrice),
24269
- assetPriceLower: big2(d?.assetPriceLower),
24270
- borrowRate: big2(d?.borrowRate),
24271
- predictedBorrowRate: big2(d?.predictedBorrowRate),
24272
- supplyRate: big2(d?.supplyRate),
24273
- utilizationRate: big2(d?.utilizationRate),
24274
- interestFee: big2(t?.interestFee),
24275
- irmTargetRate: big2(t?.irmTargetRate),
24276
- irmMaxRate: big2(t?.irmMaxRate),
24277
- irmTargetUtilization: big2(t?.irmTargetUtilization)
24366
+ totalAssets: big3(d?.totalAssets),
24367
+ totalSupply: big3(d?.totalSupply),
24368
+ exchangeRate: big3(d?.exchangeRate),
24369
+ collateral: big3(d?.collateral),
24370
+ debt: big3(d?.debt),
24371
+ liquidity: big3(d?.liquidity),
24372
+ assetPrice: big3(d?.assetPrice),
24373
+ assetPriceLower: big3(d?.assetPriceLower),
24374
+ borrowRate: big3(d?.borrowRate),
24375
+ predictedBorrowRate: big3(d?.predictedBorrowRate),
24376
+ supplyRate: big3(d?.supplyRate),
24377
+ utilizationRate: big3(d?.utilizationRate),
24378
+ interestFee: big3(t?.interestFee),
24379
+ irmTargetRate: big3(t?.irmTargetRate),
24380
+ irmMaxRate: big3(t?.irmMaxRate),
24381
+ irmTargetUtilization: big3(t?.irmTargetUtilization)
24278
24382
  });
24279
24383
  }
24280
24384
  if (tokens.length === 0) continue;
24281
24385
  markets.push({
24282
24386
  marketManager,
24283
- cooldownLength: big2(m?.cooldownLength),
24387
+ cooldownLength: big3(m?.cooldownLength),
24284
24388
  // Filled in below — one batched round for every market at once.
24285
24389
  minLoanSizeUsdWad: 0n,
24286
24390
  tokens
@@ -24341,7 +24445,7 @@ async function fetchViaMulticall(lender, chainId, config) {
24341
24445
  const pairs = [];
24342
24446
  managers.forEach((mm, i) => {
24343
24447
  const toks = listed[i * 2];
24344
- const redeemPaused = big2(listed[i * 2 + 1]) === 2n;
24448
+ const redeemPaused = big3(listed[i * 2 + 1]) === 2n;
24345
24449
  if (!Array.isArray(toks)) return;
24346
24450
  for (const t of toks) {
24347
24451
  if (typeof t === "string" && t.startsWith("0x")) {
@@ -24427,9 +24531,9 @@ async function fetchViaMulticall(lender, chainId, config) {
24427
24531
  const paused = results[base + 4];
24428
24532
  const asset = results[base + 7];
24429
24533
  if (!Array.isArray(coll) || typeof asset !== "string") return;
24430
- const tuple = (v, idx) => Array.isArray(v) ? big2(v[idx]) : 0n;
24431
- const held = big2(results[base + 10]);
24432
- const debt = big2(results[base + 9]);
24534
+ const tuple = (v, idx) => Array.isArray(v) ? big3(v[idx]) : 0n;
24535
+ const held = big3(results[base + 10]);
24536
+ const debt = big3(results[base + 9]);
24433
24537
  const token = {
24434
24538
  cToken: p.cToken,
24435
24539
  symbol: str(results[base + 5], "c?"),
@@ -24446,13 +24550,13 @@ async function fetchViaMulticall(lender, chainId, config) {
24446
24550
  liqIncCurve: tuple(liq, 1),
24447
24551
  closeFactorBase: tuple(liq, 4),
24448
24552
  maxLeverage: 0n,
24449
- collateralCap: big2(results[base + 2]),
24450
- debtCap: big2(results[base + 3]),
24553
+ collateralCap: big3(results[base + 2]),
24554
+ debtCap: big3(results[base + 3]),
24451
24555
  mintPaused: Array.isArray(paused) ? !!paused[0] : false,
24452
24556
  collateralizationPaused: Array.isArray(paused) ? !!paused[1] : false,
24453
24557
  borrowPaused: Array.isArray(paused) ? !!paused[2] : false,
24454
24558
  redeemPaused: p.redeemPaused,
24455
- totalAssets: big2(results[base + 8]),
24559
+ totalAssets: big3(results[base + 8]),
24456
24560
  totalSupply: 0n,
24457
24561
  exchangeRate: 0n,
24458
24562
  collateral: 0n,
@@ -24466,7 +24570,7 @@ async function fetchViaMulticall(lender, chainId, config) {
24466
24570
  predictedBorrowRate: 0n,
24467
24571
  supplyRate: 0n,
24468
24572
  utilizationRate: held + debt > 0n ? debt * 10n ** 18n / (held + debt) : 0n,
24469
- interestFee: big2(results[base + 11]),
24573
+ interestFee: big3(results[base + 11]),
24470
24574
  irmTargetRate: 0n,
24471
24575
  irmMaxRate: 0n,
24472
24576
  irmTargetUtilization: 0n
@@ -24553,7 +24657,7 @@ var ERC20_ABI = [
24553
24657
  ];
24554
24658
  var RAY4 = 1e27;
24555
24659
  var ok = (v) => v !== void 0 && v !== null && v !== "0x";
24556
- var big3 = (v) => {
24660
+ var big4 = (v) => {
24557
24661
  if (typeof v === "bigint") return v;
24558
24662
  if (typeof v === "number") return BigInt(v);
24559
24663
  if (typeof v === "string" && /^(0x[0-9a-fA-F]+|\d+)$/.test(v)) return BigInt(v);
@@ -24661,10 +24765,10 @@ async function fetchTwyneMarkets(lender, chainId) {
24661
24765
  const pendingDebtBalances = [];
24662
24766
  markets.forEach((m, i) => {
24663
24767
  const c = i * 8;
24664
- const creditTotalAssets = big3(creditReads[c]);
24665
- const creditTotalBorrows = big3(creditReads[c + 1]);
24666
- const creditCash = big3(creditReads[c + 2]);
24667
- const creditRateSpy = big3(creditReads[c + 3]);
24768
+ const creditTotalAssets = big4(creditReads[c]);
24769
+ const creditTotalBorrows = big4(creditReads[c + 1]);
24770
+ const creditCash = big4(creditReads[c + 2]);
24771
+ const creditRateSpy = big4(creditReads[c + 3]);
24668
24772
  if (creditTotalAssets === void 0 || creditCash === void 0 || creditRateSpy === void 0) return;
24669
24773
  const aaveIdx = aaveMarkets.indexOf(m);
24670
24774
  const eulerIdx = eulerMarkets.indexOf(m);
@@ -24683,21 +24787,21 @@ async function fetchTwyneMarkets(lender, chainId) {
24683
24787
  if (ok(debtReserve) && debtReserve?.currentVariableBorrowRate !== void 0)
24684
24788
  externalBorrowRate = Number(debtReserve.currentVariableBorrowRate) / RAY4;
24685
24789
  if (ok(debtReserve)) {
24686
- const virtual = big3(debtReserve.virtualUnderlyingBalance);
24790
+ const virtual = big4(debtReserve.virtualUnderlyingBalance);
24687
24791
  if (virtual !== void 0 && virtual > 0n) externalBorrowLiquidity = virtual;
24688
24792
  else if (typeof debtReserve.aTokenAddress === "string")
24689
24793
  debtAToken = debtReserve.aTokenAddress;
24690
24794
  }
24691
24795
  } else if (eulerIdx >= 0) {
24692
24796
  const e = eulerIdx * 7;
24693
- externalLiqLtv = big3(eulerReads[e]);
24694
- const spy = big3(eulerReads[e + 1]);
24797
+ externalLiqLtv = big4(eulerReads[e]);
24798
+ const spy = big4(eulerReads[e + 1]);
24695
24799
  if (spy !== void 0) externalBorrowRate = Number(spy) / RAY4 * 31536e3;
24696
- externalBorrowLiquidity = big3(eulerReads[e + 2]);
24697
- const collSpy = big3(eulerReads[e + 3]);
24698
- const collAssets = big3(eulerReads[e + 4]);
24699
- const collBorrows = big3(eulerReads[e + 5]);
24700
- const collFeeBps = big3(eulerReads[e + 6]) ?? 0n;
24800
+ externalBorrowLiquidity = big4(eulerReads[e + 2]);
24801
+ const collSpy = big4(eulerReads[e + 3]);
24802
+ const collAssets = big4(eulerReads[e + 4]);
24803
+ const collBorrows = big4(eulerReads[e + 5]);
24804
+ const collFeeBps = big4(eulerReads[e + 6]) ?? 0n;
24701
24805
  if (collSpy !== void 0 && collAssets && collAssets > 0n) {
24702
24806
  const util = Number(collBorrows ?? 0n) / Number(collAssets);
24703
24807
  externalSupplyRate = Number(collSpy) / RAY4 * 31536e3 * util * (1 - Number(collFeeBps) / 1e4);
@@ -24705,7 +24809,7 @@ async function fetchTwyneMarkets(lender, chainId) {
24705
24809
  }
24706
24810
  const s = i * 3;
24707
24811
  if (externalBorrowLiquidity === void 0 && !debtAToken) {
24708
- externalBorrowLiquidity = big3(scaleReads[s + 2]);
24812
+ externalBorrowLiquidity = big4(scaleReads[s + 2]);
24709
24813
  }
24710
24814
  if (debtAToken) pendingDebtBalances.push({ index: out.length, token: m.targetAsset, holder: debtAToken });
24711
24815
  out.push({
@@ -24714,19 +24818,19 @@ async function fetchTwyneMarkets(lender, chainId) {
24714
24818
  creditTotalBorrows: creditTotalBorrows ?? 0n,
24715
24819
  creditCash,
24716
24820
  creditRateSpy,
24717
- creditDepositCapacity: big3(creditReads[c + 7]),
24821
+ creditDepositCapacity: big4(creditReads[c + 7]),
24718
24822
  creditDecimals: Number(creditReads[c + 4] ?? 18),
24719
24823
  creditSymbol: typeof creditReads[c + 5] === "string" ? creditReads[c + 5] : void 0,
24720
24824
  creditIrm: typeof creditReads[c + 6] === "string" ? creditReads[c + 6].toLowerCase() : m.creditIrm,
24721
24825
  externalLiqLtv,
24722
- maxTwyneLiqLtv: big3(bounds[i * 2]) ?? (m.maxTwyneLiqLTV !== void 0 ? BigInt(m.maxTwyneLiqLTV) : void 0),
24723
- externalLiqBuffer: big3(bounds[i * 2 + 1]) ?? (m.externalLiqBuffer !== void 0 ? BigInt(m.externalLiqBuffer) : void 0),
24826
+ maxTwyneLiqLtv: big4(bounds[i * 2]) ?? (m.maxTwyneLiqLTV !== void 0 ? BigInt(m.maxTwyneLiqLTV) : void 0),
24827
+ externalLiqBuffer: big4(bounds[i * 2 + 1]) ?? (m.externalLiqBuffer !== void 0 ? BigInt(m.externalLiqBuffer) : void 0),
24724
24828
  externalSupplyRate,
24725
24829
  externalBorrowRate,
24726
24830
  externalBorrowLiquidity,
24727
24831
  collateralDecimals: Number(scaleReads[s] ?? 18),
24728
24832
  targetDecimals: Number(scaleReads[s + 1] ?? 18),
24729
- collateralToUnderlying: big3(wrapperReads[i]),
24833
+ collateralToUnderlying: big4(wrapperReads[i]),
24730
24834
  // Computed HERE, never read from the roster: a stored flag goes stale,
24731
24835
  // and two of the three live PT markets have already matured.
24732
24836
  collateralMatured: !!m.collateralMaturity && m.collateralMaturity <= nowSec9,
@@ -24745,7 +24849,7 @@ async function fetchTwyneMarkets(lender, chainId) {
24745
24849
  allowFailure: true
24746
24850
  });
24747
24851
  pendingDebtBalances.forEach((p, i) => {
24748
- const v = big3(balances[i]);
24852
+ const v = big4(balances[i]);
24749
24853
  if (v !== void 0 && out[p.index]) out[p.index].externalBorrowLiquidity = v;
24750
24854
  });
24751
24855
  }
@@ -24753,7 +24857,7 @@ async function fetchTwyneMarkets(lender, chainId) {
24753
24857
  return { lender, chainId, config, markets: out };
24754
24858
  }
24755
24859
  var PAIR_READS = 15;
24756
- var big4 = (v) => {
24860
+ var big5 = (v) => {
24757
24861
  if (typeof v === "bigint") return v;
24758
24862
  if (typeof v === "number") return BigInt(v);
24759
24863
  if (typeof v === "string" && v !== "0x") {
@@ -24860,41 +24964,41 @@ async function fetchFraxlendPairs(lender, chainId) {
24860
24964
  decimals: dec(decimals),
24861
24965
  asset: asset.toLowerCase(),
24862
24966
  collateral: collateral.toLowerCase(),
24863
- maxLtv: big4(maxLtv),
24864
- ltvPrecision: big4(ltvPrec) || 100000n,
24865
- exchangePrecision: big4(exPrec) || 10n ** 18n,
24866
- liqPrecision: big4(liqPrec) || 100000n,
24967
+ maxLtv: big5(maxLtv),
24968
+ ltvPrecision: big5(ltvPrec) || 100000n,
24969
+ exchangePrecision: big5(exPrec) || 10n ** 18n,
24970
+ liqPrecision: big5(liqPrec) || 100000n,
24867
24971
  cleanLiquidationFee: 0n,
24868
24972
  dirtyLiquidationFee: 0n,
24869
24973
  protocolLiquidationFee: 0n,
24870
- depositLimit: big4(depositLimit),
24871
- borrowLimit: big4(borrowLimit),
24872
- totalAssetAmount: big4(
24974
+ depositLimit: big5(depositLimit),
24975
+ borrowLimit: big5(borrowLimit),
24976
+ totalAssetAmount: big5(
24873
24977
  totalAsset.amount ?? totalAsset[0]
24874
24978
  ),
24875
- totalAssetShares: big4(
24979
+ totalAssetShares: big5(
24876
24980
  totalAsset.shares ?? totalAsset[1]
24877
24981
  ),
24878
- totalBorrowAmount: big4(
24982
+ totalBorrowAmount: big5(
24879
24983
  totalBorrow.amount ?? totalBorrow[0]
24880
24984
  ),
24881
- totalBorrowShares: big4(
24985
+ totalBorrowShares: big5(
24882
24986
  totalBorrow.shares ?? totalBorrow[1]
24883
24987
  ),
24884
- totalCollateral: big4(totalCollateral),
24988
+ totalCollateral: big5(totalCollateral),
24885
24989
  oracle: str2(xrInfo[0], "").toLowerCase(),
24886
24990
  maxOracleDeviation: Number(xrInfo[1] ?? 0),
24887
- exchangeRateLastTimestamp: big4(xrInfo[2]),
24888
- lowExchangeRate: big4(xrInfo[3]),
24889
- highExchangeRate: big4(xrInfo[4]),
24890
- ratePerSec: big4(rateInfo.ratePerSec ?? rateInfo[3]),
24891
- fullUtilizationRate: big4(
24991
+ exchangeRateLastTimestamp: big5(xrInfo[2]),
24992
+ lowExchangeRate: big5(xrInfo[3]),
24993
+ highExchangeRate: big5(xrInfo[4]),
24994
+ ratePerSec: big5(rateInfo.ratePerSec ?? rateInfo[3]),
24995
+ fullUtilizationRate: big5(
24892
24996
  rateInfo.fullUtilizationRate ?? rateInfo[4]
24893
24997
  ),
24894
24998
  feeToProtocolRate: Number(
24895
24999
  rateInfo.feeToProtocolRate ?? rateInfo[1] ?? 0
24896
25000
  ),
24897
- rateLastTimestamp: big4(
25001
+ rateLastTimestamp: big5(
24898
25002
  rateInfo.lastTimestamp ?? rateInfo[2]
24899
25003
  ),
24900
25004
  rateContract: str2(rateContract, "").toLowerCase(),
@@ -25138,6 +25242,197 @@ function convertInverseMarketsToResponse(raw, chainId, prices = {}, _additionalY
25138
25242
  return out;
25139
25243
  }
25140
25244
 
25245
+ // src/lending/public-data/cooler/convertPublic.ts
25246
+ var WAD9 = 1e18;
25247
+ var clamp01 = (v) => Math.max(0, Math.min(1, v));
25248
+ var wadToNumber = (v) => v !== null ? Number(v) / WAD9 : 0;
25249
+ function currencyFor9(address, decimals, symbol, tokens) {
25250
+ const lower4 = address.toLowerCase();
25251
+ return tokens[lower4] ?? { address: lower4, symbol, name: symbol, decimals };
25252
+ }
25253
+ function convertCoolerMarketsToResponse(raw, chainId, prices = {}, _additionalYields = {
25254
+ intrinsicYields: {},
25255
+ lenderRewards: {},
25256
+ loaded: true
25257
+ }, tokens = {}) {
25258
+ const out = {};
25259
+ const cfg = raw?.config;
25260
+ if (!cfg || raw.source === "none") return out;
25261
+ const lenderKey = raw.lender;
25262
+ const collAddr = (raw.collateralToken ?? cfg.gohm).toLowerCase();
25263
+ const debtAddr = (raw.debtToken ?? cfg.usds).toLowerCase();
25264
+ const collToken = tokens[collAddr];
25265
+ const debtToken = tokens[debtAddr];
25266
+ const collSymbol = collToken?.symbol ?? "gOHM";
25267
+ const debtSymbol = debtToken?.symbol ?? "USDS";
25268
+ const collDecimals = collToken?.decimals ?? 18;
25269
+ const debtDecimals = debtToken?.decimals ?? cfg.debtDecimals ?? 18;
25270
+ const collPriceKey = toOracleKey(collToken?.assetGroup) || toGenericPriceKey(collAddr, chainId);
25271
+ const collPrice = prices[collPriceKey] ?? 0;
25272
+ const debtPriceKey = toOracleKey(debtToken?.assetGroup) || toGenericPriceKey(debtAddr, chainId);
25273
+ const debtPrice = prices[debtPriceKey] || 1;
25274
+ const borrowAprPct = wadToNumber(raw.interestRateWad) * 100;
25275
+ const totalCollateral = wadToNumber(raw.totalCollateral);
25276
+ const totalDebt = wadToNumber(raw.totalDebt);
25277
+ const oltvPrice = wadToNumber(raw.oltvPrice);
25278
+ const lltvPrice = wadToNumber(raw.lltvPrice);
25279
+ const minDebt = wadToNumber(raw.minDebtRequired);
25280
+ const borrowsPaused = raw.borrowsPaused ?? false;
25281
+ const liquidationsPaused = raw.liquidationsPaused ?? false;
25282
+ const borrowCollateralFactor = collPrice > 0 ? clamp01(oltvPrice / collPrice) : 0;
25283
+ const collateralFactor = collPrice > 0 ? clamp01(lltvPrice / collPrice) : 0;
25284
+ let borrowLiquidity = wadToNumber(raw.susdsHeadroom);
25285
+ if (borrowsPaused) borrowLiquidity = 0;
25286
+ const entry = { data: {} };
25287
+ const collUid = createMarketUid(chainId, lenderKey, collAddr);
25288
+ entry.data[collUid] = {
25289
+ marketUid: collUid,
25290
+ name: "Collateral " + collSymbol,
25291
+ poolId: cfg.monoCooler.toLowerCase(),
25292
+ underlying: collAddr,
25293
+ asset: currencyFor9(collAddr, collDecimals, collSymbol, tokens),
25294
+ totalDeposits: totalCollateral,
25295
+ totalDebtStable: 0,
25296
+ totalDebt: 0,
25297
+ totalLiquidity: totalCollateral,
25298
+ borrowLiquidity: 0,
25299
+ totalLiquidityUSD: totalCollateral * collPrice,
25300
+ borrowLiquidityUSD: 0,
25301
+ totalDepositsUSD: totalCollateral * collPrice,
25302
+ totalDebtStableUSD: 0,
25303
+ totalDebtUSD: 0,
25304
+ utilization: 0,
25305
+ depositRate: 0,
25306
+ variableBorrowRate: 0,
25307
+ stableBorrowRate: 0,
25308
+ // gOHM staking emissions are ZERO today — never hardcode a carry here.
25309
+ intrinsicYield: _additionalYields?.intrinsicYields?.[collToken?.assetGroup] ?? 0,
25310
+ rewards: void 0,
25311
+ decimals: collDecimals,
25312
+ config: {
25313
+ 0: {
25314
+ category: 0,
25315
+ borrowCollateralFactor,
25316
+ collateralFactor,
25317
+ borrowFactor: 1,
25318
+ // Seized collateral is unstaked and BURNED — no liquidator bonus.
25319
+ liquidationPenalty: 0,
25320
+ closeFactor: 1,
25321
+ collateralDisabled: false,
25322
+ debtDisabled: true
25323
+ }
25324
+ },
25325
+ closeFactor: 1,
25326
+ collateralActive: true,
25327
+ borrowingEnabled: false,
25328
+ depositsEnabled: true,
25329
+ hasStable: false,
25330
+ isActive: true,
25331
+ isFrozen: false
25332
+ };
25333
+ const loanUid = createMarketUid(chainId, lenderKey, debtAddr);
25334
+ entry.data[loanUid] = {
25335
+ marketUid: loanUid,
25336
+ name: debtSymbol,
25337
+ poolId: cfg.monoCooler.toLowerCase(),
25338
+ underlying: debtAddr,
25339
+ asset: currencyFor9(debtAddr, debtDecimals, debtSymbol, tokens),
25340
+ totalDeposits: 0,
25341
+ totalDebtStable: 0,
25342
+ totalDebt,
25343
+ totalLiquidity: borrowLiquidity,
25344
+ borrowLiquidity,
25345
+ totalLiquidityUSD: borrowLiquidity * debtPrice,
25346
+ borrowLiquidityUSD: borrowLiquidity * debtPrice,
25347
+ totalDepositsUSD: 0,
25348
+ totalDebtStableUSD: 0,
25349
+ totalDebtUSD: totalDebt * debtPrice,
25350
+ utilization: 0,
25351
+ depositRate: 0,
25352
+ // Protocol-set, continuously compounded on-chain; reported nominally.
25353
+ variableBorrowRate: borrowAprPct,
25354
+ stableBorrowRate: 0,
25355
+ rateModel: "protocolSet",
25356
+ intrinsicYield: 0,
25357
+ rewards: void 0,
25358
+ decimals: debtDecimals,
25359
+ config: {
25360
+ 0: {
25361
+ category: 0,
25362
+ borrowCollateralFactor: 0,
25363
+ collateralFactor: 0,
25364
+ borrowFactor: 1,
25365
+ liquidationPenalty: 0,
25366
+ closeFactor: 1,
25367
+ collateralDisabled: true,
25368
+ debtDisabled: borrowsPaused
25369
+ }
25370
+ },
25371
+ closeFactor: 1,
25372
+ collateralActive: false,
25373
+ borrowingEnabled: !borrowsPaused,
25374
+ depositsEnabled: false,
25375
+ hasStable: false,
25376
+ variableBorrowDisabled: borrowsPaused,
25377
+ isActive: true,
25378
+ isFrozen: false
25379
+ };
25380
+ entry.params = {
25381
+ market: {
25382
+ lender: lenderKey,
25383
+ name: `${debtSymbol} / ${collSymbol}`,
25384
+ loanDecimals: debtDecimals,
25385
+ collateralDecimals: collDecimals,
25386
+ // The MonoCooler contract doubles as the market id.
25387
+ id: cfg.monoCooler.toLowerCase(),
25388
+ lltv: String(collateralFactor),
25389
+ oracle: cfg.ltvOracle,
25390
+ irm: zeroAddress,
25391
+ collateralAddress: collAddr,
25392
+ loanAddress: debtAddr,
25393
+ // --- Cooler descriptor (live snapshot; consumed by calldata builders
25394
+ // + worker-api resolvers + the term-sheet adapter) ---
25395
+ cooler: {
25396
+ monoCooler: cfg.monoCooler,
25397
+ /** Debt-token units, human string. Gates borrows AND partial repays:
25398
+ * any action leaving 0 < debt < minDebt reverts (full repay fine). */
25399
+ minDebt: String(minDebt),
25400
+ /** THE PROTOCOL TRUTH: LTVs are PRICES (debt per gOHM token), not
25401
+ * ratios — the fractional factors above are display-only. */
25402
+ oltvPrice: String(oltvPrice),
25403
+ lltvPrice: String(lltvPrice),
25404
+ /** Per-year continuously-compounded rate, raw wad string. */
25405
+ interestRateWad: raw.interestRateWad !== null ? raw.interestRateWad.toString() : void 0,
25406
+ /** The oracle's OLTV drip schedule — future OLTV in closed form. */
25407
+ drip: raw.drip ? {
25408
+ startingValue: raw.drip.startingValue.toString(),
25409
+ startTime: raw.drip.startTime.toString(),
25410
+ targetValue: raw.drip.targetValue.toString(),
25411
+ targetTime: raw.drip.targetTime.toString(),
25412
+ slope: raw.drip.slope.toString()
25413
+ } : void 0,
25414
+ /** LLTV = OLTV × (1 + premiumBps / 1e4); raisable to at most 333. */
25415
+ liquidationLtvPremiumBps: raw.liquidationLtvPremiumBps ?? void 0,
25416
+ borrowsPaused,
25417
+ liquidationsPaused,
25418
+ addresses: {
25419
+ monoCooler: cfg.monoCooler,
25420
+ ltvOracle: cfg.ltvOracle,
25421
+ treasuryBorrower: cfg.treasuryBorrower,
25422
+ treasury: cfg.treasury,
25423
+ susds: cfg.susds,
25424
+ gohm: cfg.gohm,
25425
+ /** The LIVE debt token — governance-swappable, never pin USDS. */
25426
+ debtToken: debtAddr
25427
+ }
25428
+ }
25429
+ }
25430
+ };
25431
+ entry.chainId = chainId;
25432
+ out[lenderKey] = entry;
25433
+ return out;
25434
+ }
25435
+
25141
25436
  // src/lending/public-data/llamalend/convertPublic.ts
25142
25437
  function llamaLendLenderKey(lender, controller) {
25143
25438
  return `${lender}_${controller.replace(/^0x/i, "").toUpperCase()}`;
@@ -25148,7 +25443,7 @@ function llamaLendKeyParts(key3) {
25148
25443
  if (!/^[0-9A-F]{40}$/.test(suffix)) return void 0;
25149
25444
  return { lender: "LLAMALEND", controller: "0x" + suffix.toLowerCase() };
25150
25445
  }
25151
- function currencyFor9(address, decimals, symbol, tokens) {
25446
+ function currencyFor10(address, decimals, symbol, tokens) {
25152
25447
  const lower4 = address.toLowerCase();
25153
25448
  return tokens[lower4] ?? { address: lower4, symbol, name: symbol, decimals };
25154
25449
  }
@@ -25211,7 +25506,7 @@ function convertLlamaLendMarketsToResponse(raw, chainId, prices = {}, additional
25211
25506
  name: "Collateral " + collSymbol,
25212
25507
  poolId: market.controller.toLowerCase(),
25213
25508
  underlying: collAddr,
25214
- asset: currencyFor9(collAddr, collDecimals, collSymbol, tokens),
25509
+ asset: currencyFor10(collAddr, collDecimals, collSymbol, tokens),
25215
25510
  // Collateral lives inside the LLAMMA spread over bands; there is no
25216
25511
  // single market-level balance worth reporting, and the number the UI
25217
25512
  // needs is the borrowed side anyway.
@@ -25259,7 +25554,7 @@ function convertLlamaLendMarketsToResponse(raw, chainId, prices = {}, additional
25259
25554
  name: loanSymbol,
25260
25555
  poolId: market.controller.toLowerCase(),
25261
25556
  underlying: loanAddr,
25262
- asset: currencyFor9(loanAddr, loanDecimals, loanSymbol, tokens),
25557
+ asset: currencyFor10(loanAddr, loanDecimals, loanSymbol, tokens),
25263
25558
  totalDeposits,
25264
25559
  totalDebtStable: 0,
25265
25560
  totalDebt,
@@ -25497,7 +25792,7 @@ function resupplyKeyParts(key3) {
25497
25792
  var SECONDS_PER_YEAR9 = 31536e3;
25498
25793
  var LTV_PRECISION = 1e5;
25499
25794
  var ONE2 = 10n ** 18n;
25500
- function currencyFor10(address, decimals, symbol, tokens) {
25795
+ function currencyFor11(address, decimals, symbol, tokens) {
25501
25796
  const lower4 = address.toLowerCase();
25502
25797
  return tokens[lower4] ?? { address: lower4, symbol, name: symbol, decimals };
25503
25798
  }
@@ -25608,7 +25903,7 @@ function convertResupplyMarketsToResponse(raw, chainId, prices = {}, _additional
25608
25903
  name: "Collateral " + collSymbol,
25609
25904
  poolId: id.pair.toLowerCase(),
25610
25905
  underlying: collAddr,
25611
- asset: currencyFor10(collAddr, collDecimals, collSymbol, tokens),
25906
+ asset: currencyFor11(collAddr, collDecimals, collSymbol, tokens),
25612
25907
  totalDeposits: totalColl,
25613
25908
  totalDebtStable: 0,
25614
25909
  totalDebt: 0,
@@ -25661,7 +25956,7 @@ function convertResupplyMarketsToResponse(raw, chainId, prices = {}, _additional
25661
25956
  name: debtSymbol,
25662
25957
  poolId: id.pair.toLowerCase(),
25663
25958
  underlying: debtAddr,
25664
- asset: currencyFor10(debtAddr, debtDecimals, debtSymbol, tokens),
25959
+ asset: currencyFor11(debtAddr, debtDecimals, debtSymbol, tokens),
25665
25960
  totalDeposits: 0,
25666
25961
  totalDebtStable: 0,
25667
25962
  totalDebt,
@@ -25790,7 +26085,7 @@ var BPS2 = 1e4;
25790
26085
  function ratePerSecToApr2(rate) {
25791
26086
  return Number(rate) / 1e18 * SECONDS_PER_YEAR10 * 100;
25792
26087
  }
25793
- function currencyFor11(address, decimals, symbol, name, tokens) {
26088
+ function currencyFor12(address, decimals, symbol, name, tokens) {
25794
26089
  const lower4 = address.toLowerCase();
25795
26090
  return tokens[lower4] ?? { address: lower4, symbol, name, decimals };
25796
26091
  }
@@ -25845,7 +26140,7 @@ function convertCurvanceMarketsToResponse(raw, chainId, prices = {}, _additional
25845
26140
  name: t.assetSymbol,
25846
26141
  poolId: market.marketManager.toLowerCase(),
25847
26142
  underlying: assetAddr,
25848
- asset: currencyFor11(assetAddr, dec2, t.assetSymbol, t.assetName, tokens),
26143
+ asset: currencyFor12(assetAddr, dec2, t.assetSymbol, t.assetName, tokens),
25849
26144
  totalDeposits,
25850
26145
  totalDebtStable: 0,
25851
26146
  totalDebt,
@@ -26017,7 +26312,19 @@ function resolvePositionManagers(cfg, marketManager) {
26017
26312
 
26018
26313
  // src/lending/public-data/twyne/convertPublic.ts
26019
26314
  function twyneLenderKey(lender, chainId, intermediateVault, targetAsset) {
26020
- return `${lender}_${chainId}_${intermediateVault.replace(/^0x/i, "").toUpperCase()}_${targetAsset.replace(/^0x/i, "").toUpperCase()}`;
26315
+ const family = String(lender).toUpperCase().split("_")[0];
26316
+ return `${family}_${chainId}_${intermediateVault.replace(/^0x/i, "").toUpperCase()}_${targetAsset.replace(/^0x/i, "").toUpperCase()}`;
26317
+ }
26318
+ function twyneKeyParts(key3) {
26319
+ if (!key3?.startsWith("TWYNE_")) return void 0;
26320
+ const m = key3.slice("TWYNE_".length).match(/^(\d+)_([0-9A-Fa-f]{40})_([0-9A-Fa-f]{40})$/);
26321
+ if (!m) return void 0;
26322
+ return {
26323
+ lender: "TWYNE",
26324
+ chainId: m[1],
26325
+ intermediateVault: `0x${m[2].toLowerCase()}`,
26326
+ targetAsset: `0x${m[3].toLowerCase()}`
26327
+ };
26021
26328
  }
26022
26329
  var SECONDS_PER_YEAR11 = 31536e3;
26023
26330
  var BPS3 = 1e4;
@@ -26026,7 +26333,7 @@ var toFloat2 = (v, dec2) => v === void 0 ? 0 : Number(v) / 10 ** dec2;
26026
26333
  function spyToApr(spy) {
26027
26334
  return Number(spy) / RAY5 * SECONDS_PER_YEAR11 * 100;
26028
26335
  }
26029
- function currencyFor12(address, decimals, symbol, tokens) {
26336
+ function currencyFor13(address, decimals, symbol, tokens) {
26030
26337
  const lower4 = address.toLowerCase();
26031
26338
  return tokens[lower4] ?? { address: lower4, symbol, name: symbol, decimals };
26032
26339
  }
@@ -26060,7 +26367,7 @@ function convertTwyneMarketsToResponse(raw, chainId, prices = {}, _additionalYie
26060
26367
  name: m.symbol ?? collToken?.symbol ?? "collateral",
26061
26368
  poolId: m.intermediateVault.toLowerCase(),
26062
26369
  underlying: collAddr,
26063
- asset: currencyFor12(collAddr, row.collateralDecimals, m.symbol ?? "", tokens),
26370
+ asset: currencyFor13(collAddr, row.collateralDecimals, m.symbol ?? "", tokens),
26064
26371
  totalDeposits: creditTotal,
26065
26372
  totalDebtStable: 0,
26066
26373
  totalDebt: 0,
@@ -26144,7 +26451,7 @@ function convertTwyneMarketsToResponse(raw, chainId, prices = {}, _additionalYie
26144
26451
  name: debtToken?.symbol ?? "debt",
26145
26452
  poolId: m.intermediateVault.toLowerCase(),
26146
26453
  underlying: debtAddr,
26147
- asset: currencyFor12(debtAddr, row.targetDecimals, debtToken?.symbol ?? "", tokens),
26454
+ asset: currencyFor13(debtAddr, row.targetDecimals, debtToken?.symbol ?? "", tokens),
26148
26455
  // Borrower aggregates are NOT readable without an event replay — see the
26149
26456
  // header. Zero here means "not measured", and the descriptor says so.
26150
26457
  totalDeposits: 0,
@@ -26192,7 +26499,13 @@ function convertTwyneMarketsToResponse(raw, chainId, prices = {}, _additionalYie
26192
26499
  entry.params = {
26193
26500
  market: {
26194
26501
  lender: lenderKey,
26195
- name: m.name ?? `${m.symbol ?? "?"} / ${m.vaultType === "AAVE_V3" ? "Aave V3" : "Euler V2"}`,
26502
+ // COLLATERAL / DEBT, then the venue a Twyne market is a PAIR, and the
26503
+ // collateral alone does not name one: the Euler eWETH credit vault backs
26504
+ // three markets (USDC, USDT, WBTC), which a collateral-only label
26505
+ // renders as three identical rows. The roster carries this string; the
26506
+ // fallback exists for a roster row published before the label did, and
26507
+ // must not silently degrade to the ambiguous form.
26508
+ name: m.name ?? `${m.symbol ?? "?"} / ${debtToken?.symbol ?? "?"} \xB7 ${m.vaultType === "AAVE_V3" ? "Aave V3" : "Euler V2"}`,
26196
26509
  loanDecimals: row.targetDecimals,
26197
26510
  collateralDecimals: row.collateralDecimals,
26198
26511
  id: m.intermediateVault.toLowerCase(),
@@ -26277,7 +26590,7 @@ var SECONDS_PER_YEAR12 = 31536e3;
26277
26590
  var ratePerSecToApr3 = (rate) => Number(rate) / 1e18 * SECONDS_PER_YEAR12 * 100;
26278
26591
  var toFloat3 = (raw, decimals) => Number(raw) / 10 ** decimals;
26279
26592
  var MAX_UINT = (1n << 256n) - 1n;
26280
- function currencyFor13(address, decimals, symbol, name, tokens) {
26593
+ function currencyFor14(address, decimals, symbol, name, tokens) {
26281
26594
  const lower4 = address.toLowerCase();
26282
26595
  return tokens[lower4] ?? { address: lower4, symbol, name, decimals };
26283
26596
  }
@@ -26326,7 +26639,7 @@ function convertFraxlendPairsToResponse(raw, chainId, prices = {}, _additionalYi
26326
26639
  name: p.assetSymbol,
26327
26640
  poolId: p.pair.toLowerCase(),
26328
26641
  underlying: p.asset,
26329
- asset: currencyFor13(
26642
+ asset: currencyFor14(
26330
26643
  p.asset,
26331
26644
  p.assetDecimals,
26332
26645
  p.assetSymbol,
@@ -26379,7 +26692,7 @@ function convertFraxlendPairsToResponse(raw, chainId, prices = {}, _additionalYi
26379
26692
  name: p.collateralSymbol,
26380
26693
  poolId: p.pair.toLowerCase(),
26381
26694
  underlying: p.collateral,
26382
- asset: currencyFor13(
26695
+ asset: currencyFor14(
26383
26696
  p.collateral,
26384
26697
  p.collateralDecimals,
26385
26698
  p.collateralSymbol,
@@ -26549,12 +26862,12 @@ async function fetchDssMarkets(lender, chainId) {
26549
26862
  } catch {
26550
26863
  return { lender, config, chainData, markets: [] };
26551
26864
  }
26552
- const big20 = (v) => {
26865
+ const big22 = (v) => {
26553
26866
  if (typeof v === "bigint") return v;
26554
26867
  if (typeof v === "number") return BigInt(v);
26555
26868
  return null;
26556
26869
  };
26557
- const field13 = (res, name, idx) => big20(res?.[name] ?? res?.[idx]);
26870
+ const field13 = (res, name, idx) => big22(res?.[name] ?? res?.[idx]);
26558
26871
  let cursor = 0;
26559
26872
  const out = markets.map((market, i) => {
26560
26873
  const base = cursor;
@@ -26571,7 +26884,7 @@ async function fetchDssMarkets(lender, chainId) {
26571
26884
  dust: field13(vatIlk, "dust", 4),
26572
26885
  duty: field13(jugIlk, "duty", 0),
26573
26886
  mat: field13(spotIlk, "mat", 1),
26574
- joinBalance: joinReadIndex[i] >= 0 ? big20(results[joinReadIndex[i]]) : null
26887
+ joinBalance: joinReadIndex[i] >= 0 ? big22(results[joinReadIndex[i]]) : null
26575
26888
  };
26576
26889
  });
26577
26890
  return { lender, config, chainData, markets: out };
@@ -26592,14 +26905,14 @@ function dssKeyParts(key3) {
26592
26905
  if (!m) return void 0;
26593
26906
  return { lender: m[1], chainId: m[2], ilk: keySegmentToIlk(m[3]) };
26594
26907
  }
26595
- var WAD10 = 1e18;
26908
+ var WAD11 = 1e18;
26596
26909
  var RAY6 = 1e27;
26597
26910
  var RAD = 1e45;
26598
26911
  var YEAR_SECONDS2 = 31536e3;
26599
26912
  function toHuman4(raw, decimals) {
26600
26913
  return Number(raw) / 10 ** decimals;
26601
26914
  }
26602
- function currencyFor14(address, decimals, symbol, tokens) {
26915
+ function currencyFor15(address, decimals, symbol, tokens) {
26603
26916
  const lower4 = address.toLowerCase();
26604
26917
  return tokens[lower4] ?? { address: lower4, symbol, name: symbol, decimals };
26605
26918
  }
@@ -26636,7 +26949,7 @@ function convertDssMarketsToResponse(raw, chainId, prices = {}, _additionalYield
26636
26949
  const totalColl = m.joinBalance !== null ? toHuman4(m.joinBalance, collDecimals) : 0;
26637
26950
  const mat = m.mat !== null ? Number(m.mat) / RAY6 : Number(market.mat) / RAY6 || 1.5;
26638
26951
  const ltv = mat > 0 ? 1 / mat : 0;
26639
- const chop = market.chop ? Number(market.chop) / WAD10 : 0;
26952
+ const chop = market.chop ? Number(market.chop) / WAD11 : 0;
26640
26953
  const liqPenalty = chop > 1 ? chop - 1 : 0;
26641
26954
  const duty = m.duty !== null ? m.duty : BigInt(market.duty ?? 0);
26642
26955
  const borrowApr = duty > BigInt(1e27) ? Number(duty - BigInt(10) ** BigInt(27)) / RAY6 * YEAR_SECONDS2 * 100 : 0;
@@ -26651,7 +26964,7 @@ function convertDssMarketsToResponse(raw, chainId, prices = {}, _additionalYield
26651
26964
  name: "Collateral " + collSymbol,
26652
26965
  poolId: market.gemJoin?.toLowerCase(),
26653
26966
  underlying: collAddr,
26654
- asset: currencyFor14(collAddr, collDecimals, collSymbol, tokens),
26967
+ asset: currencyFor15(collAddr, collDecimals, collSymbol, tokens),
26655
26968
  totalDeposits: totalColl,
26656
26969
  totalDebtStable: 0,
26657
26970
  totalDebt: 0,
@@ -26695,7 +27008,7 @@ function convertDssMarketsToResponse(raw, chainId, prices = {}, _additionalYield
26695
27008
  name: debtSymbol,
26696
27009
  poolId: cfg.vat.toLowerCase(),
26697
27010
  underlying: debtAddr,
26698
- asset: currencyFor14(debtAddr, debtDecimals, debtSymbol, tokens),
27011
+ asset: currencyFor15(debtAddr, debtDecimals, debtSymbol, tokens),
26699
27012
  totalDeposits: 0,
26700
27013
  totalDebtStable: 0,
26701
27014
  totalDebt,
@@ -26845,26 +27158,26 @@ async function fetchFrankencoinMarkets(lender, chainId) {
26845
27158
  } catch {
26846
27159
  return { lender, config, chainData, markets: [] };
26847
27160
  }
26848
- const big20 = (v) => {
27161
+ const big22 = (v) => {
26849
27162
  if (typeof v === "bigint") return v;
26850
27163
  if (typeof v === "number") return BigInt(v);
26851
27164
  return null;
26852
27165
  };
26853
27166
  const out = markets.map((market, i) => {
26854
27167
  const base = i * READS_PER_MARKET3;
26855
- const expiration = big20(results[base + 7]);
27168
+ const expiration = big22(results[base + 7]);
26856
27169
  return {
26857
27170
  market,
26858
- price: big20(results[base]),
26859
- minted: big20(results[base + 1]),
26860
- availableForClones: big20(results[base + 2]),
26861
- annualInterestPPM: big20(results[base + 3]),
26862
- currentFeePPM: big20(results[base + 4]),
26863
- reserveContribution: big20(results[base + 5]),
26864
- challengedAmount: big20(results[base + 6]),
27171
+ price: big22(results[base]),
27172
+ minted: big22(results[base + 1]),
27173
+ availableForClones: big22(results[base + 2]),
27174
+ annualInterestPPM: big22(results[base + 3]),
27175
+ currentFeePPM: big22(results[base + 4]),
27176
+ reserveContribution: big22(results[base + 5]),
27177
+ challengedAmount: big22(results[base + 6]),
26865
27178
  expiration,
26866
27179
  isClosed: typeof results[base + 8] === "boolean" ? results[base + 8] : null,
26867
- collateralBalance: big20(results[base + 9])
27180
+ collateralBalance: big22(results[base + 9])
26868
27181
  };
26869
27182
  });
26870
27183
  return { lender, config, chainData, markets: out };
@@ -26886,7 +27199,7 @@ function frankencoinKeyParts(key3) {
26886
27199
  };
26887
27200
  }
26888
27201
  var PPM = 1e6;
26889
- function currencyFor15(address, decimals, symbol, tokens) {
27202
+ function currencyFor16(address, decimals, symbol, tokens) {
26890
27203
  const lower4 = address.toLowerCase();
26891
27204
  return tokens[lower4] ?? { address: lower4, symbol, name: symbol, decimals };
26892
27205
  }
@@ -26937,7 +27250,7 @@ function convertFrankencoinMarketsToResponse(raw, chainId, prices = {}, _additio
26937
27250
  name: "Collateral " + collSymbol,
26938
27251
  poolId: market.position.toLowerCase(),
26939
27252
  underlying: collAddr,
26940
- asset: currencyFor15(collAddr, collDecimals, collSymbol, tokens),
27253
+ asset: currencyFor16(collAddr, collDecimals, collSymbol, tokens),
26941
27254
  totalDeposits: totalColl,
26942
27255
  totalDebtStable: 0,
26943
27256
  totalDebt: 0,
@@ -26984,7 +27297,7 @@ function convertFrankencoinMarketsToResponse(raw, chainId, prices = {}, _additio
26984
27297
  name: debtSymbol,
26985
27298
  poolId: cfg.mintingHub.toLowerCase(),
26986
27299
  underlying: debtAddr,
26987
- asset: currencyFor15(debtAddr, debtDecimals, debtSymbol, tokens),
27300
+ asset: currencyFor16(debtAddr, debtDecimals, debtSymbol, tokens),
26988
27301
  totalDeposits: 0,
26989
27302
  totalDebtStable: 0,
26990
27303
  totalDebt,
@@ -27705,6 +28018,7 @@ async function getLenderDataFromApi(lender, chainId, prices, additionalYields, i
27705
28018
  if (isRiver(lender)) return await fetchRiverMarkets(lender, chainId);
27706
28019
  if (isTeller(lender)) return await fetchTellerMarkets(chainId);
27707
28020
  if (isInverse(lender)) return await fetchInverseMarkets(lender, chainId);
28021
+ if (isCooler(lender)) return await fetchCoolerMarkets(lender, chainId);
27708
28022
  if (isLlamaLend(lender)) return await fetchLlamaLendMarkets(lender, chainId);
27709
28023
  if (isResupply(lender)) return await fetchResupplyMarkets(lender, chainId);
27710
28024
  if (isCurvance(lender)) return await fetchCurvanceMarkets(lender, chainId);
@@ -27775,6 +28089,14 @@ function convertLenderDataFromApi(lender, chainId, data, prices, additionalYield
27775
28089
  additionalYields,
27776
28090
  list
27777
28091
  );
28092
+ if (isCooler(lender))
28093
+ return convertCoolerMarketsToResponse(
28094
+ data,
28095
+ chainId,
28096
+ prices,
28097
+ additionalYields,
28098
+ list
28099
+ )[lender] ?? {};
27778
28100
  if (isLlamaLend(lender))
27779
28101
  return convertLlamaLendMarketsToResponse(
27780
28102
  data,
@@ -28039,6 +28361,7 @@ function lenderApiOnly(lender, chainId) {
28039
28361
  if (isRiver(lender)) return true;
28040
28362
  if (isTeller(lender)) return true;
28041
28363
  if (isInverse(lender)) return true;
28364
+ if (isCooler(lender)) return true;
28042
28365
  if (isTermMax(lender)) return true;
28043
28366
  if (isResupply(lender)) return true;
28044
28367
  if (isCurvance(lender)) return true;
@@ -29571,6 +29894,14 @@ var buildInverseUserCall = (chainId, lender, account) => {
29571
29894
  );
29572
29895
  return calls;
29573
29896
  };
29897
+ var COOLER_USER_CALLS = 1;
29898
+ var buildCoolerUserCall = (chainId, lender, account) => {
29899
+ const cfg = coolerConfigFor(lender, chainId);
29900
+ if (!cfg?.monoCooler) return [];
29901
+ return [
29902
+ { address: cfg.monoCooler, name: "accountPosition", params: [account] }
29903
+ ];
29904
+ };
29574
29905
  var RESUPPLY_CALLS_PER_PAIR = 2;
29575
29906
  var ONE3 = 10n ** 18n;
29576
29907
  var ROSTER_TTL_MS = 5 * 6e4;
@@ -29864,7 +30195,7 @@ var buildCurvanceUserCall = async (chainId, lender, account) => {
29864
30195
  ]);
29865
30196
  };
29866
30197
  var DISCOVERY_TTL_MS3 = 6e4;
29867
- var TWYNE_READS_PER_VAULT = 9;
30198
+ var TWYNE_READS_PER_VAULT = 7;
29868
30199
  var discoveryCache4 = /* @__PURE__ */ new Map();
29869
30200
  var discoveryKey3 = (chainId, lender, account) => `${chainId}:${lender}:${account.toLowerCase()}`;
29870
30201
  function getCachedTwyneDiscovery(chainId, lender, account) {
@@ -29906,9 +30237,15 @@ async function discover(chainId, lender, account) {
29906
30237
  abi: TwyneCollateralVaultAbi,
29907
30238
  allowFailure: true
29908
30239
  });
29909
- const known = new Set(
29910
- (twyneChainData(lender, chainId)?.markets ?? []).map(
29911
- (m) => `${lower2(m.intermediateVault)}|${lower2(m.targetAsset)}`
30240
+ const queried = twyneKeyParts(lender);
30241
+ const known = new Map(
30242
+ (twyneChainData(lender, chainId)?.markets ?? []).filter(
30243
+ (m) => !queried || lower2(m.intermediateVault) === lower2(queried.intermediateVault) && lower2(m.targetAsset) === lower2(queried.targetAsset)
30244
+ ).map(
30245
+ (m) => [
30246
+ `${lower2(m.intermediateVault)}|${lower2(m.targetAsset)}`,
30247
+ m.collateralAsset
30248
+ ]
29912
30249
  )
29913
30250
  );
29914
30251
  const vaults = [];
@@ -29918,9 +30255,40 @@ async function discover(chainId, lender, account) {
29918
30255
  const owner = refs[i * 3 + 2];
29919
30256
  if (!isAddress2(iv) || !isAddress2(target)) return;
29920
30257
  if (isAddress2(owner) && lower2(owner) !== lower2(account)) return;
29921
- if (!known.has(`${lower2(iv)}|${lower2(target)}`)) return;
29922
- vaults.push({ vault, intermediateVault: lower2(iv), targetAsset: lower2(target) });
30258
+ const marketKey2 = `${lower2(iv)}|${lower2(target)}`;
30259
+ if (!known.has(marketKey2)) return;
30260
+ vaults.push({
30261
+ vault,
30262
+ intermediateVault: lower2(iv),
30263
+ targetAsset: lower2(target),
30264
+ collateralAsset: known.get(marketKey2)
30265
+ });
29923
30266
  });
30267
+ const receipts = [
30268
+ ...new Set(vaults.map((v) => v.collateralAsset).filter((a) => !!a))
30269
+ ];
30270
+ if (receipts.length > 0) {
30271
+ const scales = await multicallRetryUniversal({
30272
+ chain: chainId,
30273
+ calls: receipts.map((address) => ({
30274
+ address,
30275
+ name: "convertToAssets",
30276
+ args: [10n ** 18n]
30277
+ })),
30278
+ abi: TwyneATokenWrapperAbi,
30279
+ allowFailure: true
30280
+ });
30281
+ const byReceipt = /* @__PURE__ */ new Map();
30282
+ receipts.forEach((address, i) => {
30283
+ const v = scales[i];
30284
+ const scale3 = typeof v === "bigint" ? v : typeof v === "string" && /^\d+$/.test(v) ? BigInt(v) : void 0;
30285
+ if (scale3 && scale3 > 0n) byReceipt.set(lower2(address), scale3);
30286
+ });
30287
+ for (const v of vaults) {
30288
+ const scale3 = v.collateralAsset ? byReceipt.get(lower2(v.collateralAsset)) : void 0;
30289
+ if (scale3) v.collateralToUnderlying = scale3;
30290
+ }
30291
+ }
29924
30292
  const result = { vaults, at: Date.now() };
29925
30293
  discoveryCache4.set(key3, result);
29926
30294
  return result;
@@ -29935,9 +30303,7 @@ async function buildTwyneUserCall(chainId, lender, account) {
29935
30303
  { address: vault, name: "twyneLiqLTV", args: [] },
29936
30304
  { address: vault, name: "canLiquidate", args: [] },
29937
30305
  { address: vault, name: "isExternallyLiquidated", args: [] },
29938
- { address: vault, name: "canRebalance", args: [] },
29939
- { address: vault, name: "asset", args: [] },
29940
- { address: vault, name: "convertToAssets", args: [10n ** 18n] }
30306
+ { address: vault, name: "canRebalance", args: [] }
29941
30307
  ]);
29942
30308
  }
29943
30309
  var DSS_CALLS_PER_CDP = 1;
@@ -29950,7 +30316,7 @@ var getCachedDssCdps = (lender, chainId, account) => {
29950
30316
  if (!hit || Date.now() - hit.at > CACHE_TTL_MS2) return void 0;
29951
30317
  return hit;
29952
30318
  };
29953
- var big5 = (v) => {
30319
+ var big6 = (v) => {
29954
30320
  try {
29955
30321
  if (typeof v === "bigint") return v;
29956
30322
  if (typeof v === "number" || typeof v === "string") return BigInt(v);
@@ -29981,7 +30347,7 @@ var buildDssUserCall = async (chainId, lender, account) => {
29981
30347
  ],
29982
30348
  allowFailure: false
29983
30349
  });
29984
- owners.push({ owner: account, count: big5(rawCount), cursor: big5(rawFirst) });
30350
+ owners.push({ owner: account, count: big6(rawCount), cursor: big6(rawFirst) });
29985
30351
  const proxy = String(rawProxy ?? zero2);
29986
30352
  if (proxy.toLowerCase() !== zero2) {
29987
30353
  const [pCount, pFirst] = await multicallRetryUniversal({
@@ -29993,7 +30359,7 @@ var buildDssUserCall = async (chainId, lender, account) => {
29993
30359
  ],
29994
30360
  allowFailure: false
29995
30361
  });
29996
- owners.push({ owner: proxy, count: big5(pCount), cursor: big5(pFirst) });
30362
+ owners.push({ owner: proxy, count: big6(pCount), cursor: big6(pFirst) });
29997
30363
  }
29998
30364
  } catch {
29999
30365
  return [];
@@ -30034,7 +30400,7 @@ var buildDssUserCall = async (chainId, lender, account) => {
30034
30400
  if (curated.has(ilk)) {
30035
30401
  cdps.push({ cdpId: cursor.toString(), urn: String(urn), ilk });
30036
30402
  }
30037
- cursor = big5(field6(link, "next", 1));
30403
+ cursor = big6(field6(link, "next", 1));
30038
30404
  }
30039
30405
  }
30040
30406
  } catch {
@@ -30283,6 +30649,7 @@ async function buildUserCall(chainId, lender, account, params, getClient) {
30283
30649
  if (isTeller(lender)) return buildTellerUserCall(chainId, lender, account);
30284
30650
  if (isTermMax(lender)) return buildTermMaxUserCall(chainId, lender, account);
30285
30651
  if (isInverse(lender)) return buildInverseUserCall(chainId, lender, account);
30652
+ if (isCooler(lender)) return buildCoolerUserCall(chainId, lender, account);
30286
30653
  if (isLlamaLend(lender))
30287
30654
  return buildLlamaLendUserCall(chainId, lender, account);
30288
30655
  if (isResupply(lender)) return buildResupplyUserCall(chainId, lender, account);
@@ -32837,7 +33204,7 @@ var getMidnightUserDataConverter = (_lender, chainId, account, meta) => {
32837
33204
  totalCalls
32838
33205
  ];
32839
33206
  };
32840
- var WAD11 = 1000000000000000000n;
33207
+ var WAD12 = 1000000000000000000n;
32841
33208
  function toBigInt12(v) {
32842
33209
  if (v === void 0 || v === null || v === "0x") return 0n;
32843
33210
  if (typeof v === "bigint") return v;
@@ -32879,8 +33246,8 @@ var getTermUserDataConverter = (_lender, chainId, account, meta) => {
32879
33246
  const debtStr = parseRawAmount(debtUnits.toString(), market.loanDecimals);
32880
33247
  const debtNum = Number(debtStr);
32881
33248
  const repoBalance = toBigInt12(balanceResult);
32882
- const redemptionValue = toBigInt12(redemptionResult) || toBigInt12(market.redemptionValue) || WAD11;
32883
- const lentUnits = repoBalance * redemptionValue / WAD11;
33249
+ const redemptionValue = toBigInt12(redemptionResult) || toBigInt12(market.redemptionValue) || WAD12;
33250
+ const lentUnits = repoBalance * redemptionValue / WAD12;
32884
33251
  const depositsStr = parseRawAmount(lentUnits.toString(), market.loanDecimals);
32885
33252
  const depositsNum = Number(depositsStr);
32886
33253
  const posData = {};
@@ -32958,7 +33325,7 @@ var getTermUserDataConverter = (_lender, chainId, account, meta) => {
32958
33325
  };
32959
33326
  var nowSec6 = () => Math.floor(Date.now() / 1e3);
32960
33327
  var DAY_SECONDS = 86400n;
32961
- var WAD12 = 10n ** 18n;
33328
+ var WAD13 = 10n ** 18n;
32962
33329
  function sumPreview(positions) {
32963
33330
  return positions.reduce((acc, p) => acc + p.previewValue, 0n);
32964
33331
  }
@@ -32982,7 +33349,7 @@ function toDetail(positions, kind, now, penaltyRate, penaltyApr) {
32982
33349
  ...kind === "borrow" ? {
32983
33350
  ...overdue ? { latePenalty: excess.toString() } : { earlyRepayDiscount: gap.toString() },
32984
33351
  // face × penaltyRate × 1 day — what another day of being late adds.
32985
- latePenaltyPerDay: (face * penaltyRate * DAY_SECONDS / WAD12).toString(),
33352
+ latePenaltyPerDay: (face * penaltyRate * DAY_SECONDS / WAD13).toString(),
32986
33353
  latePenaltyApr: penaltyApr
32987
33354
  } : {
32988
33355
  ...overdue ? {} : { earlyExitCost: gap.toString() },
@@ -33111,7 +33478,7 @@ var getExactlyUserDataConverter = (_lender, chainId, account, meta) => {
33111
33478
  latePenalty: penalty,
33112
33479
  /** further penalty per day overdue — linear on face */
33113
33480
  latePenaltyPerDay: parseRawAmount(
33114
- (face * m.penaltyRate * DAY_SECONDS / WAD12).toString(),
33481
+ (face * m.penaltyRate * DAY_SECONDS / WAD13).toString(),
33115
33482
  decimals
33116
33483
  ),
33117
33484
  latePenaltyApr: penaltyApr,
@@ -33142,7 +33509,7 @@ var getExactlyUserDataConverter = (_lender, chainId, account, meta) => {
33142
33509
  expected
33143
33510
  ];
33144
33511
  };
33145
- var big6 = (v) => {
33512
+ var big7 = (v) => {
33146
33513
  try {
33147
33514
  if (typeof v === "bigint") return v;
33148
33515
  if (typeof v === "number" || typeof v === "string") return BigInt(v);
@@ -33150,7 +33517,7 @@ var big6 = (v) => {
33150
33517
  }
33151
33518
  return 0n;
33152
33519
  };
33153
- var field7 = (res, name, idx) => big6(res?.[name] ?? res?.[idx]);
33520
+ var field7 = (res, name, idx) => big7(res?.[name] ?? res?.[idx]);
33154
33521
  var getLiquityUserDataConverter = (lender, chainId, account, meta) => {
33155
33522
  const cfg = liquityConfigFor(lender, chainId);
33156
33523
  const branches = liquityBranchesByChain(lender, chainId);
@@ -33271,11 +33638,11 @@ var getLiquityUserDataConverter = (lender, chainId, account, meta) => {
33271
33638
  };
33272
33639
  });
33273
33640
  const spBase = troves.length * 2;
33274
- const spDeposit = big6(slice2[spBase]);
33275
- const spYield = big6(slice2[spBase + 1]);
33276
- const spCollGain = big6(slice2[spBase + 2]);
33277
- const spStashed = big6(slice2[spBase + 3]);
33278
- const collSurplus = branch.collSurplusPool ? big6(slice2[spBase + 4]) : 0n;
33641
+ const spDeposit = big7(slice2[spBase]);
33642
+ const spYield = big7(slice2[spBase + 1]);
33643
+ const spCollGain = big7(slice2[spBase + 2]);
33644
+ const spStashed = big7(slice2[spBase + 3]);
33645
+ const collSurplus = branch.collSurplusPool ? big7(slice2[spBase + 4]) : 0n;
33279
33646
  const spStable = spDeposit + spYield;
33280
33647
  const spColl = spCollGain + spStashed + collSurplus;
33281
33648
  if (spStable > 0n || spColl > 0n) {
@@ -33354,7 +33721,7 @@ var getLiquityUserDataConverter = (lender, chainId, account, meta) => {
33354
33721
  expected
33355
33722
  ];
33356
33723
  };
33357
- var big7 = (v) => {
33724
+ var big8 = (v) => {
33358
33725
  try {
33359
33726
  if (typeof v === "bigint") return v;
33360
33727
  if (typeof v === "number" || typeof v === "string") return BigInt(v);
@@ -33362,7 +33729,7 @@ var big7 = (v) => {
33362
33729
  }
33363
33730
  return 0n;
33364
33731
  };
33365
- var field8 = (res, name, idx) => big7(res?.[name] ?? res?.[idx]);
33732
+ var field8 = (res, name, idx) => big8(res?.[name] ?? res?.[idx]);
33366
33733
  var getRiverUserDataConverter = (lender, chainId, account, meta) => {
33367
33734
  const cfg = riverConfigFor(lender, chainId);
33368
33735
  const markets = riverChainData(lender, chainId)?.markets ?? [];
@@ -33374,13 +33741,13 @@ var getRiverUserDataConverter = (lender, chainId, account, meta) => {
33374
33741
  const debtAddr = cfg.debtToken.toLowerCase();
33375
33742
  const debtDecimals = cfg.debtDecimals ?? 18;
33376
33743
  const out = {};
33377
- const spDeposit = big7(data[markets.length * RIVER_CALLS_PER_MARKET]);
33744
+ const spDeposit = big8(data[markets.length * RIVER_CALLS_PER_MARKET]);
33378
33745
  markets.forEach((market, i) => {
33379
33746
  const base = i * RIVER_CALLS_PER_MARKET;
33380
33747
  const entire = data[base];
33381
33748
  if (isFailedCall(entire) || isFailedCall(data[base + 1])) return;
33382
- const status = Number(big7(data[base + 1]));
33383
- const surplus = big7(data[base + 2]);
33749
+ const status = Number(big8(data[base + 1]));
33750
+ const surplus = big8(data[base + 2]);
33384
33751
  const lenderKey = riverLenderKey(lender, chainId, market.index);
33385
33752
  const metaMap = meta?.[lenderKey];
33386
33753
  if (!metaMap) return;
@@ -33488,7 +33855,7 @@ var getRiverUserDataConverter = (lender, chainId, account, meta) => {
33488
33855
  expected
33489
33856
  ];
33490
33857
  };
33491
- var big8 = (v) => {
33858
+ var big9 = (v) => {
33492
33859
  try {
33493
33860
  if (typeof v === "bigint") return v;
33494
33861
  if (typeof v === "number" || typeof v === "string") return BigInt(v);
@@ -33507,24 +33874,24 @@ var getInverseUserDataConverter = (lender, chainId, account, meta) => {
33507
33874
  const dolaAddr = cfg.dola.toLowerCase();
33508
33875
  const debtDecimals = cfg.debtDecimals ?? 18;
33509
33876
  const tailBase = markets.length * INVERSE_CALLS_PER_MARKET;
33510
- const dbrBalance = big8(data[tailBase]);
33511
- const dbrDeficit = big8(data[tailBase + 1]);
33877
+ const dbrBalance = big9(data[tailBase]);
33878
+ const dbrDeficit = big9(data[tailBase + 1]);
33512
33879
  const dbrSignedRaw = data[tailBase + 2];
33513
- const dbrSigned = isFailedCall(dbrSignedRaw) ? 0n : big8(dbrSignedRaw);
33880
+ const dbrSigned = isFailedCall(dbrSignedRaw) ? 0n : big9(dbrSignedRaw);
33514
33881
  const dbrTotalDebtRaw = data[tailBase + 3];
33515
- const dbrTotalDebt = isFailedCall(dbrTotalDebtRaw) ? 0n : big8(dbrTotalDebtRaw);
33882
+ const dbrTotalDebt = isFailedCall(dbrTotalDebtRaw) ? 0n : big9(dbrTotalDebtRaw);
33516
33883
  const dbrRunway = dbrTotalDebt > 0n ? dbrBalance * 31536000n / dbrTotalDebt : 0n;
33517
33884
  const nowSec9 = BigInt(Math.floor(Date.now() / 1e3));
33518
33885
  const out = {};
33519
33886
  markets.forEach((market, i) => {
33520
33887
  const base = i * INVERSE_CALLS_PER_MARKET;
33521
- const escrowBal = isFailedCall(data[base]) ? 0n : big8(data[base]);
33888
+ const escrowBal = isFailedCall(data[base]) ? 0n : big9(data[base]);
33522
33889
  const debtRaw = data[base + 1];
33523
33890
  if (isFailedCall(debtRaw)) return;
33524
- const debt = big8(debtRaw);
33891
+ const debt = big9(debtRaw);
33525
33892
  if (escrowBal === 0n && debt === 0n) return;
33526
- const creditLimit = isFailedCall(data[base + 2]) ? 0n : big8(data[base + 2]);
33527
- const withdrawalLimit = isFailedCall(data[base + 3]) ? 0n : big8(data[base + 3]);
33893
+ const creditLimit = isFailedCall(data[base + 2]) ? 0n : big9(data[base + 2]);
33894
+ const withdrawalLimit = isFailedCall(data[base + 3]) ? 0n : big9(data[base + 3]);
33528
33895
  const lenderKey = inverseLenderKey(lender, market.address);
33529
33896
  const metaMap = meta?.[lenderKey];
33530
33897
  if (!metaMap) return;
@@ -33610,7 +33977,118 @@ var getInverseUserDataConverter = (lender, chainId, account, meta) => {
33610
33977
  expected
33611
33978
  ];
33612
33979
  };
33613
- var big9 = (v) => {
33980
+ var big10 = (v) => {
33981
+ try {
33982
+ if (typeof v === "bigint") return v;
33983
+ if (typeof v === "number" || typeof v === "string") return BigInt(v);
33984
+ } catch {
33985
+ }
33986
+ return 0n;
33987
+ };
33988
+ var getCoolerUserDataConverter = (lender, chainId, account, meta) => {
33989
+ const cfg = coolerConfigFor(lender, chainId);
33990
+ const expected = cfg?.monoCooler ? COOLER_USER_CALLS : 0;
33991
+ return [
33992
+ (data) => {
33993
+ if (!cfg || expected === 0 || !meta) return void 0;
33994
+ if (!data || data.length < expected) return void 0;
33995
+ const raw = data[0];
33996
+ if (isFailedCall(raw)) return void 0;
33997
+ const pos = Array.isArray(raw) ? {
33998
+ collateral: raw[0],
33999
+ currentDebt: raw[1],
34000
+ maxOriginationDebtAmount: raw[2],
34001
+ liquidationDebtAmount: raw[3],
34002
+ healthFactor: raw[4],
34003
+ currentLtv: raw[5],
34004
+ totalDelegated: raw[6]
34005
+ } : raw;
34006
+ if (pos === null || typeof pos !== "object") return void 0;
34007
+ const collateral = big10(pos.collateral);
34008
+ const debt = big10(pos.currentDebt);
34009
+ if (collateral === 0n && debt === 0n) return void 0;
34010
+ const collAddr = cfg.gohm.toLowerCase();
34011
+ const collUid = createMarketUid(chainId, lender, collAddr);
34012
+ let loanUid = createMarketUid(chainId, lender, cfg.usds.toLowerCase());
34013
+ if (!meta[loanUid]) {
34014
+ const other = Object.keys(meta).find((k) => k !== collUid);
34015
+ if (other) loanUid = other;
34016
+ }
34017
+ const collMeta = meta[collUid];
34018
+ const loanMeta = meta[loanUid];
34019
+ const collDisplay = collMeta ? getDisplayPrice(collMeta) : 0;
34020
+ const collOracle = collMeta ? getOraclePrice(collMeta) : 0;
34021
+ const collHist = collMeta?.price?.priceUsd24h ?? collDisplay;
34022
+ const loanDisplay = loanMeta ? getDisplayPrice(loanMeta) : 0;
34023
+ const loanOracle = loanMeta ? getOraclePrice(loanMeta) : 0;
34024
+ const loanHist = loanMeta?.price?.priceUsd24h ?? loanDisplay;
34025
+ const coolerInfo = {
34026
+ healthFactor: big10(pos.healthFactor).toString(),
34027
+ currentLtv: big10(pos.currentLtv).toString(),
34028
+ totalDelegated: big10(pos.totalDelegated).toString(),
34029
+ maxOriginationDebtAmount: big10(pos.maxOriginationDebtAmount).toString(),
34030
+ liquidationDebtAmount: big10(pos.liquidationDebtAmount).toString()
34031
+ };
34032
+ const collStr = parseRawAmount(collateral.toString(), 18);
34033
+ const collNum = Number(collStr);
34034
+ const debtStr = parseRawAmount(debt.toString(), 18);
34035
+ const debtNum = Number(debtStr);
34036
+ const loanUnderlying = loanMeta?.asset?.address ?? cfg.usds.toLowerCase();
34037
+ const lendingPositions = {
34038
+ "0": {
34039
+ [collUid]: {
34040
+ marketUid: collUid,
34041
+ underlying: collAddr,
34042
+ deposits: collStr,
34043
+ debt: "0",
34044
+ debtStable: "0",
34045
+ depositsUSD: collNum * collDisplay,
34046
+ debtUSD: 0,
34047
+ debtStableUSD: 0,
34048
+ depositsUSDOracle: collNum * collOracle,
34049
+ debtUSDOracle: 0,
34050
+ debtStableUSDOracle: 0,
34051
+ stableBorrowRate: "0",
34052
+ collateralEnabled: true,
34053
+ claimableRewards: 0
34054
+ },
34055
+ [loanUid]: {
34056
+ marketUid: loanUid,
34057
+ underlying: loanUnderlying,
34058
+ deposits: "0",
34059
+ debt: debtStr,
34060
+ debtStable: "0",
34061
+ depositsUSD: 0,
34062
+ debtUSD: debtNum * loanDisplay,
34063
+ debtStableUSD: 0,
34064
+ depositsUSDOracle: 0,
34065
+ debtUSDOracle: debtNum * loanOracle,
34066
+ debtStableUSDOracle: 0,
34067
+ stableBorrowRate: "0",
34068
+ collateralEnabled: false,
34069
+ claimableRewards: 0,
34070
+ coolerInfo
34071
+ }
34072
+ }
34073
+ };
34074
+ const modes = { "0": 0 };
34075
+ const hist = {
34076
+ "0": {
34077
+ totalDeposits24h: collNum * collHist,
34078
+ totalDebt24h: debtNum * loanHist
34079
+ }
34080
+ };
34081
+ const userData = createMultiAccountTypeUserState(
34082
+ { chainId, account, lendingPositions, modes },
34083
+ meta,
34084
+ hist
34085
+ );
34086
+ return userData && userData.data.length > 0 ? userData : void 0;
34087
+ },
34088
+ expected
34089
+ ];
34090
+ };
34091
+ var big11 = (v) => {
33614
34092
  try {
33615
34093
  if (typeof v === "bigint") return v;
33616
34094
  if (typeof v === "number" || typeof v === "string") return BigInt(v);
@@ -33620,7 +34098,7 @@ var big9 = (v) => {
33620
34098
  };
33621
34099
  var arrAt = (v, i) => {
33622
34100
  if (isFailedCall(v) || !Array.isArray(v)) return 0n;
33623
- return big9(v[i]);
34101
+ return big11(v[i]);
33624
34102
  };
33625
34103
  var getLlamaLendUserDataConverter = (lender, chainId, account, meta) => {
33626
34104
  const cfg = llamaLendConfigFor(lender, chainId);
@@ -33635,24 +34113,24 @@ var getLlamaLendUserDataConverter = (lender, chainId, account, meta) => {
33635
34113
  const base = i * LLAMALEND_CALLS_PER_MARKET;
33636
34114
  const stateRaw = data[base];
33637
34115
  if (isFailedCall(stateRaw) || !Array.isArray(stateRaw)) return;
33638
- const collateral = big9(stateRaw[0]);
33639
- const bandBorrowed = big9(stateRaw[1]);
33640
- const debt = big9(stateRaw[2]);
33641
- const bandCount = Number(big9(stateRaw[3]));
34116
+ const collateral = big11(stateRaw[0]);
34117
+ const bandBorrowed = big11(stateRaw[1]);
34118
+ const debt = big11(stateRaw[2]);
34119
+ const bandCount = Number(big11(stateRaw[3]));
33642
34120
  const vaultSharesRaw = data[base + 5];
33643
34121
  const gaugeSharesRaw = data[base + 6];
33644
- const vaultShares = isFailedCall(vaultSharesRaw) ? 0n : big9(vaultSharesRaw);
33645
- const gaugeShares = isFailedCall(gaugeSharesRaw) ? 0n : big9(gaugeSharesRaw);
34122
+ const vaultShares = isFailedCall(vaultSharesRaw) ? 0n : big11(vaultSharesRaw);
34123
+ const gaugeShares = isFailedCall(gaugeSharesRaw) ? 0n : big11(gaugeSharesRaw);
33646
34124
  const lendShares = vaultShares + gaugeShares;
33647
34125
  if (collateral === 0n && debt === 0n && bandBorrowed === 0n && lendShares === 0n)
33648
34126
  return;
33649
34127
  const healthRaw = data[base + 1];
33650
- const health = isFailedCall(healthRaw) ? 0n : big9(healthRaw);
34128
+ const health = isFailedCall(healthRaw) ? 0n : big11(healthRaw);
33651
34129
  const pricesRaw = data[base + 2];
33652
34130
  const priceUpper = arrAt(pricesRaw, 0);
33653
34131
  const priceLower = arrAt(pricesRaw, 1);
33654
34132
  const ticksRaw = data[base + 3];
33655
- const bands = isFailedCall(ticksRaw) || !Array.isArray(ticksRaw) ? void 0 : [Number(big9(ticksRaw[0])), Number(big9(ticksRaw[1]))];
34133
+ const bands = isFailedCall(ticksRaw) || !Array.isArray(ticksRaw) ? void 0 : [Number(big11(ticksRaw[0])), Number(big11(ticksRaw[1]))];
33656
34134
  const approvalRaw = data[base + 4];
33657
34135
  const delegated = isFailedCall(approvalRaw) ? false : approvalRaw === true;
33658
34136
  const lenderKey = llamaLendLenderKey(lender, market.controller);
@@ -33673,7 +34151,7 @@ var getLlamaLendUserDataConverter = (lender, chainId, account, meta) => {
33673
34151
  const loanOracle = loanMeta ? getOraclePrice(loanMeta) : 0;
33674
34152
  const loanHist = loanMeta?.price?.priceUsd24h ?? loanDisplay;
33675
34153
  const shareToAssetRaw = data[base + 7];
33676
- const shareToAsset = isFailedCall(shareToAssetRaw) ? 0n : big9(shareToAssetRaw);
34154
+ const shareToAsset = isFailedCall(shareToAssetRaw) ? 0n : big11(shareToAssetRaw);
33677
34155
  const lendAssets = shareToAsset === 0n ? 0n : lendShares * shareToAsset / 10n ** 18n;
33678
34156
  const lendStr = parseRawAmount(lendAssets.toString(), loanDecimals);
33679
34157
  const depositStr = parseRawAmount(
@@ -33762,7 +34240,7 @@ var getLlamaLendUserDataConverter = (lender, chainId, account, meta) => {
33762
34240
  expected
33763
34241
  ];
33764
34242
  };
33765
- var big10 = (v) => {
34243
+ var big12 = (v) => {
33766
34244
  try {
33767
34245
  if (typeof v === "bigint") return v;
33768
34246
  if (typeof v === "number" || typeof v === "string") return BigInt(v);
@@ -33770,7 +34248,7 @@ var big10 = (v) => {
33770
34248
  }
33771
34249
  return 0n;
33772
34250
  };
33773
- var tupleAt = (v, i) => Array.isArray(v) ? big10(v[i]) : 0n;
34251
+ var tupleAt = (v, i) => Array.isArray(v) ? big12(v[i]) : 0n;
33774
34252
  var ONE4 = 10n ** 18n;
33775
34253
  function sharesToAmount(shares, totalAmount, totalShares) {
33776
34254
  if (totalShares === 0n || shares === 0n) return 0n;
@@ -33796,7 +34274,7 @@ var getResupplyUserDataConverter = (lender, chainId, account, meta) => {
33796
34274
  if (isFailedCall(accounting) || !Array.isArray(accounting)) return;
33797
34275
  const totalBorrowAmount = tupleAt(accounting, 1);
33798
34276
  const totalBorrowShares = tupleAt(accounting, 2);
33799
- const sharePrice = isFailedCall(data[base + 1]) ? 0n : big10(data[base + 1]);
34277
+ const sharePrice = isFailedCall(data[base + 1]) ? 0n : big12(data[base + 1]);
33800
34278
  const lenderKey = resupplyLenderKey(lender, chainId, pair);
33801
34279
  const metaMap = meta?.[lenderKey];
33802
34280
  if (!metaMap) return;
@@ -33894,7 +34372,7 @@ var getResupplyUserDataConverter = (lender, chainId, account, meta) => {
33894
34372
  expected
33895
34373
  ];
33896
34374
  };
33897
- var big11 = (v) => {
34375
+ var big13 = (v) => {
33898
34376
  try {
33899
34377
  if (typeof v === "bigint") return v;
33900
34378
  if (typeof v === "number" || typeof v === "string") return BigInt(v);
@@ -33925,9 +34403,9 @@ var getFraxlendUserDataConverter = (lender, chainId, account, meta) => {
33925
34403
  const fTokenRaw = data[base + 2];
33926
34404
  const previewRaw = data[base + 3];
33927
34405
  if (isFailedCall(collRaw) || isFailedCall(sharesRaw)) return;
33928
- const collateral = big11(collRaw);
33929
- const borrowShares = big11(sharesRaw);
33930
- const fTokenShares = isFailedCall(fTokenRaw) ? 0n : big11(fTokenRaw);
34406
+ const collateral = big13(collRaw);
34407
+ const borrowShares = big13(sharesRaw);
34408
+ const fTokenShares = isFailedCall(fTokenRaw) ? 0n : big13(fTokenRaw);
33931
34409
  if (collateral === 0n && borrowShares === 0n && fTokenShares === 0n)
33932
34410
  return;
33933
34411
  let totalBorrowAmount = 0n;
@@ -33937,10 +34415,10 @@ var getFraxlendUserDataConverter = (lender, chainId, account, meta) => {
33937
34415
  if (!isFailedCall(previewRaw) && previewRaw) {
33938
34416
  const ta = previewRaw[4];
33939
34417
  const tb = previewRaw[5];
33940
- totalAssetAmount = big11(ta?.amount ?? ta?.[0]);
33941
- totalAssetShares = big11(ta?.shares ?? ta?.[1]);
33942
- totalBorrowAmount = big11(tb?.amount ?? tb?.[0]);
33943
- totalBorrowShares = big11(tb?.shares ?? tb?.[1]);
34418
+ totalAssetAmount = big13(ta?.amount ?? ta?.[0]);
34419
+ totalAssetShares = big13(ta?.shares ?? ta?.[1]);
34420
+ totalBorrowAmount = big13(tb?.amount ?? tb?.[0]);
34421
+ totalBorrowShares = big13(tb?.shares ?? tb?.[1]);
33944
34422
  }
33945
34423
  const debt = fraxlendToAmount(
33946
34424
  borrowShares,
@@ -34047,8 +34525,8 @@ var getFraxlendUserDataConverter = (lender, chainId, account, meta) => {
34047
34525
  expected
34048
34526
  ];
34049
34527
  };
34050
- var WAD13 = 10n ** 18n;
34051
- var big12 = (v) => {
34528
+ var WAD14 = 10n ** 18n;
34529
+ var big14 = (v) => {
34052
34530
  try {
34053
34531
  if (typeof v === "bigint") return v;
34054
34532
  if (typeof v === "number" || typeof v === "string") return BigInt(v);
@@ -34056,7 +34534,7 @@ var big12 = (v) => {
34056
34534
  }
34057
34535
  return 0n;
34058
34536
  };
34059
- var tupleAt2 = (v, i) => Array.isArray(v) ? big12(v[i]) : 0n;
34537
+ var tupleAt2 = (v, i) => Array.isArray(v) ? big14(v[i]) : 0n;
34060
34538
  var HOLD_PERIOD_SECONDS = 1200n;
34061
34539
  var getCurvanceUserDataConverter = (lender, chainId, account, meta) => {
34062
34540
  const cfg = curvanceConfigFor(lender, chainId);
@@ -34079,7 +34557,7 @@ var getCurvanceUserDataConverter = (lender, chainId, account, meta) => {
34079
34557
  const cooldownRaw = data[base];
34080
34558
  const status = data[base + 1];
34081
34559
  if (isFailedCall(status) || !Array.isArray(status)) continue;
34082
- const cooldownTimestamp = isFailedCall(cooldownRaw) ? 0n : big12(cooldownRaw);
34560
+ const cooldownTimestamp = isFailedCall(cooldownRaw) ? 0n : big14(cooldownRaw);
34083
34561
  const holdPeriodEndsAt = cooldownTimestamp > 0n ? cooldownTimestamp + HOLD_PERIOD_SECONDS : 0n;
34084
34562
  const holdPeriodActive = holdPeriodEndsAt > nowSeconds;
34085
34563
  const lenderKey = curvanceLenderKey(lender, chainId, p.marketManager);
@@ -34101,10 +34579,10 @@ var getCurvanceUserDataConverter = (lender, chainId, account, meta) => {
34101
34579
  let rows = 0;
34102
34580
  p.activeTokens.forEach(({ cToken, asset }, i) => {
34103
34581
  const tokenBase = base + CURVANCE_MARKET_READS + i * CURVANCE_READS_PER_TOKEN;
34104
- const shares = isFailedCall(data[tokenBase]) ? 0n : big12(data[tokenBase]);
34105
- const collateralShares = isFailedCall(data[tokenBase + 1]) ? 0n : big12(data[tokenBase + 1]);
34106
- const debtRaw = isFailedCall(data[tokenBase + 2]) ? 0n : big12(data[tokenBase + 2]);
34107
- const exchangeRate = isFailedCall(data[tokenBase + 3]) ? 0n : big12(data[tokenBase + 3]);
34582
+ const shares = isFailedCall(data[tokenBase]) ? 0n : big14(data[tokenBase]);
34583
+ const collateralShares = isFailedCall(data[tokenBase + 1]) ? 0n : big14(data[tokenBase + 1]);
34584
+ const debtRaw = isFailedCall(data[tokenBase + 2]) ? 0n : big14(data[tokenBase + 2]);
34585
+ const exchangeRate = isFailedCall(data[tokenBase + 3]) ? 0n : big14(data[tokenBase + 3]);
34108
34586
  info.tokens[cToken.toLowerCase()] = {
34109
34587
  shares: shares.toString(),
34110
34588
  collateralShares: collateralShares.toString(),
@@ -34118,7 +34596,7 @@ var getCurvanceUserDataConverter = (lender, chainId, account, meta) => {
34118
34596
  const display = getDisplayPrice(rowMeta);
34119
34597
  const oracle = getOraclePrice(rowMeta);
34120
34598
  const histPrice = rowMeta.price?.priceUsd24h ?? display;
34121
- const toUnderlying = (s) => exchangeRate > 0n ? s * exchangeRate / WAD13 : s;
34599
+ const toUnderlying = (s) => exchangeRate > 0n ? s * exchangeRate / WAD14 : s;
34122
34600
  const depositsRaw = toUnderlying(collateralShares);
34123
34601
  const depositsStr = parseRawAmount(
34124
34602
  depositsRaw.toString(),
@@ -34163,8 +34641,8 @@ var getCurvanceUserDataConverter = (lender, chainId, account, meta) => {
34163
34641
  expected
34164
34642
  ];
34165
34643
  };
34166
- var WAD14 = 10n ** 18n;
34167
- var big13 = (v) => {
34644
+ var WAD15 = 10n ** 18n;
34645
+ var big15 = (v) => {
34168
34646
  try {
34169
34647
  if (typeof v === "bigint") return v;
34170
34648
  if (typeof v === "number" || typeof v === "string") return BigInt(v);
@@ -34186,14 +34664,14 @@ var getTwyneUserDataConverter = (lender, chainId, account, meta) => {
34186
34664
  const base = i * TWYNE_READS_PER_VAULT;
34187
34665
  const totalRaw = data[base];
34188
34666
  if (isFailedCall(totalRaw)) return;
34189
- const total = big13(totalRaw);
34190
- const reserved = isFailedCall(data[base + 1]) ? 0n : big13(data[base + 1]);
34191
- const debt = isFailedCall(data[base + 2]) ? 0n : big13(data[base + 2]);
34192
- const liqLtv = isFailedCall(data[base + 3]) ? 0n : big13(data[base + 3]);
34667
+ const total = big15(totalRaw);
34668
+ const reserved = isFailedCall(data[base + 1]) ? 0n : big15(data[base + 1]);
34669
+ const debt = isFailedCall(data[base + 2]) ? 0n : big15(data[base + 2]);
34670
+ const liqLtv = isFailedCall(data[base + 3]) ? 0n : big15(data[base + 3]);
34193
34671
  const canLiquidate = isFailedCall(data[base + 4]) ? false : Boolean(data[base + 4]);
34194
34672
  const extLiquidated = isFailedCall(data[base + 5]) ? false : Boolean(data[base + 5]);
34195
- const releasable = isFailedCall(data[base + 6]) ? 0n : big13(data[base + 6]);
34196
- const scale3 = isFailedCall(data[base + 8]) ? WAD14 : big13(data[base + 8]) || WAD14;
34673
+ const releasable = isFailedCall(data[base + 6]) ? 0n : big15(data[base + 6]);
34674
+ const scale3 = ref.collateralToUnderlying ?? WAD15;
34197
34675
  const userCollateral = total > reserved ? total - reserved : 0n;
34198
34676
  if (userCollateral === 0n && debt === 0n) return;
34199
34677
  const market = markets.find(
@@ -34209,7 +34687,7 @@ var getTwyneUserDataConverter = (lender, chainId, account, meta) => {
34209
34687
  });
34210
34688
  }
34211
34689
  byMarket.get(lenderKey).rows.push({
34212
- coll: userCollateral * scale3 / WAD14,
34690
+ coll: userCollateral * scale3 / WAD15,
34213
34691
  debt,
34214
34692
  info: {
34215
34693
  collateralVault: ref.vault,
@@ -34308,7 +34786,7 @@ var getTwyneUserDataConverter = (lender, chainId, account, meta) => {
34308
34786
  ];
34309
34787
  };
34310
34788
  var RAY7 = 10n ** 27n;
34311
- var big14 = (v) => {
34789
+ var big16 = (v) => {
34312
34790
  try {
34313
34791
  if (typeof v === "bigint") return v;
34314
34792
  if (typeof v === "number" || typeof v === "string") return BigInt(v);
@@ -34316,7 +34794,7 @@ var big14 = (v) => {
34316
34794
  }
34317
34795
  return 0n;
34318
34796
  };
34319
- var field9 = (res, name, idx) => big14(res?.[name] ?? res?.[idx]);
34797
+ var field9 = (res, name, idx) => big16(res?.[name] ?? res?.[idx]);
34320
34798
  var getDssUserDataConverter = (lender, chainId, account, meta) => {
34321
34799
  const cfg = dssConfigFor(lender, chainId);
34322
34800
  const markets = dssChainData(lender, chainId)?.markets ?? [];
@@ -34431,7 +34909,7 @@ var getDssUserDataConverter = (lender, chainId, account, meta) => {
34431
34909
  expected
34432
34910
  ];
34433
34911
  };
34434
- var big15 = (v) => {
34912
+ var big17 = (v) => {
34435
34913
  try {
34436
34914
  if (typeof v === "bigint") return v;
34437
34915
  if (typeof v === "number" || typeof v === "string") return BigInt(v);
@@ -34461,11 +34939,11 @@ var getFrankencoinUserDataConverter = (lender, chainId, account, meta) => {
34461
34939
  const ownerRes = data[base];
34462
34940
  if (isFailedCall(ownerRes)) return;
34463
34941
  if (String(ownerRes).toLowerCase() !== lowerAccount) return;
34464
- const minted = big15(data[base + 1]);
34465
- const price2 = big15(data[base + 2]);
34466
- const expiration = big15(data[base + 3]);
34467
- const challenged = big15(data[base + 4]);
34468
- const coll = big15(data[base + 5]);
34942
+ const minted = big17(data[base + 1]);
34943
+ const price2 = big17(data[base + 2]);
34944
+ const expiration = big17(data[base + 3]);
34945
+ const challenged = big17(data[base + 4]);
34946
+ const coll = big17(data[base + 5]);
34469
34947
  if (minted === 0n && coll === 0n) return;
34470
34948
  const market = marketByOriginal.get(p.original);
34471
34949
  if (!market) return;
@@ -34566,7 +35044,7 @@ var getFrankencoinUserDataConverter = (lender, chainId, account, meta) => {
34566
35044
 
34567
35045
  // src/lending/user-data/teller/userCallParse.ts
34568
35046
  var nowSec7 = () => Math.floor(Date.now() / 1e3);
34569
- var big16 = (v) => {
35047
+ var big18 = (v) => {
34570
35048
  try {
34571
35049
  if (typeof v === "bigint") return v;
34572
35050
  if (typeof v === "number" || typeof v === "string") return BigInt(v);
@@ -34588,7 +35066,7 @@ var getTellerUserDataConverter = (_lender, chainId, account, meta) => {
34588
35066
  const base = i * TELLER_CALLS_PER_BID;
34589
35067
  const bidRes = data[base];
34590
35068
  const owed = data[base + 1];
34591
- const collAmount = big16(data[base + 2]);
35069
+ const collAmount = big18(data[base + 2]);
34592
35070
  const defaulted = !!data[base + 3];
34593
35071
  if (isFailedCall(bidRes) || isFailedCall(owed) || !bidRes) return;
34594
35072
  const pool = b.pool;
@@ -34609,17 +35087,17 @@ var getTellerUserDataConverter = (_lender, chainId, account, meta) => {
34609
35087
  const collDisplay = collMeta ? getDisplayPrice(collMeta) : 0;
34610
35088
  const collOracle = collMeta ? getOraclePrice(collMeta) : 0;
34611
35089
  const collHist = collMeta?.price?.priceUsd24h ?? collDisplay;
34612
- const owedPrincipal = big16(field10(owed, "principal", 0));
34613
- const owedInterest = big16(field10(owed, "interest", 1));
35090
+ const owedPrincipal = big18(field10(owed, "principal", 0));
35091
+ const owedInterest = big18(field10(owed, "interest", 1));
34614
35092
  const owedTotal = owedPrincipal + owedInterest;
34615
35093
  if (owedTotal === 0n && collAmount === 0n) return;
34616
35094
  const loanDetails = field10(bidRes, "loanDetails", 5);
34617
35095
  const terms = field10(bidRes, "terms", 6);
34618
35096
  const acceptedTs = Number(
34619
- big16(field10(loanDetails, "acceptedTimestamp", 4))
35097
+ big18(field10(loanDetails, "acceptedTimestamp", 4))
34620
35098
  );
34621
- const loanDuration = Number(big16(field10(loanDetails, "loanDuration", 6)));
34622
- const aprBps = Number(big16(field10(terms, "APR", 2)));
35099
+ const loanDuration = Number(big18(field10(loanDetails, "loanDuration", 6)));
35100
+ const aprBps = Number(big18(field10(terms, "APR", 2)));
34623
35101
  const maturity = acceptedTs > 0 ? acceptedTs + loanDuration : void 0;
34624
35102
  const isMatured2 = defaulted || maturity !== void 0 && maturity < now;
34625
35103
  const collStr = parseRawAmount(collAmount.toString(), collDecimals);
@@ -34996,6 +35474,8 @@ function getUserDataConverter(lender, chainId, account, params, meta) {
34996
35474
  return getTermMaxUserDataConverter(lender, chainId, account, meta);
34997
35475
  if (isInverse(lender))
34998
35476
  return getInverseUserDataConverter(lender, chainId, account, meta);
35477
+ if (isCooler(lender))
35478
+ return getCoolerUserDataConverter(lender, chainId, account, meta?.[lender]);
34999
35479
  if (isLlamaLend(lender))
35000
35480
  return getLlamaLendUserDataConverter(lender, chainId, account, meta);
35001
35481
  if (isResupply(lender))
@@ -39618,6 +40098,16 @@ var VAULT_CONVERT_ABI = [
39618
40098
  outputs: [{ type: "uint256" }]
39619
40099
  }
39620
40100
  ];
40101
+ var TWYNE_USER_ABI = [
40102
+ ...TwyneCollateralVaultAbi,
40103
+ {
40104
+ name: "convertToAssets",
40105
+ type: "function",
40106
+ stateMutability: "view",
40107
+ inputs: [{ name: "shares", type: "uint256" }],
40108
+ outputs: [{ type: "uint256" }]
40109
+ }
40110
+ ];
39621
40111
  var getAbi2 = (lender) => {
39622
40112
  if (isAaveV4Type(lender)) return [...AaveV4SpokeAbi];
39623
40113
  if (isAaveV2Type(lender))
@@ -39663,6 +40153,7 @@ var getAbi2 = (lender) => {
39663
40153
  if (isTermMax(lender)) return [...TermMaxViewerAbi];
39664
40154
  if (isInverse(lender))
39665
40155
  return [...InverseMarketAbi, ...InverseEscrowAbi, ...InverseDbrAbi];
40156
+ if (isCooler(lender)) return [...CoolerMonoAbi];
39666
40157
  if (isLlamaLend(lender))
39667
40158
  return [...LlamaLendControllerAbi, ...LlamaLendAmmAbi];
39668
40159
  if (isDssType(lender)) return [...UsddVatAbi];
@@ -39673,7 +40164,7 @@ var getAbi2 = (lender) => {
39673
40164
  return [...ResupplyPairAbi, ...VAULT_CONVERT_ABI];
39674
40165
  if (isCurvance(lender))
39675
40166
  return [...CurvanceMarketManagerAbi, ...CurvanceCTokenAbi];
39676
- if (isTwyne(lender)) return [...TwyneCollateralVaultAbi];
40167
+ if (isTwyne(lender)) return TWYNE_USER_ABI;
39677
40168
  if (isInit(lender)) return InitLensAbi;
39678
40169
  if (isEulerType(lender)) return accountLensAbi;
39679
40170
  if (isCompoundV2Type(lender))
@@ -46810,6 +47301,192 @@ var NATIVE_WNLP_ENTRIES = Object.fromEntries(
46810
47301
  )
46811
47302
  ])
46812
47303
  );
47304
+ var REWARD_RATE_ABI = [
47305
+ {
47306
+ name: "getCurrentRewardRate",
47307
+ type: "function",
47308
+ stateMutability: "view",
47309
+ inputs: [{ type: "address", name: "token" }],
47310
+ outputs: [{ type: "uint256" }]
47311
+ }
47312
+ ];
47313
+ var BITWAY_LEGS = [
47314
+ // Absolute Return 0x5C4a6903…
47315
+ {
47316
+ share: "0xccafb706225331aedfec75b5347d462b98ed2fd2",
47317
+ // bwUSDT
47318
+ vault: "0x5c4a6903732532eeb3ae0803e062d8ae25d52bd1",
47319
+ token: "0x55d398326f99059ff775485246999027b3197955"
47320
+ // USDT
47321
+ },
47322
+ {
47323
+ share: "0xaa3d2534b4b87a2859e28c223f18265244ffffb7",
47324
+ // bwU
47325
+ vault: "0x5c4a6903732532eeb3ae0803e062d8ae25d52bd1",
47326
+ token: "0xce24439f2d9c6a2289f741120fe202248b666666"
47327
+ // U
47328
+ },
47329
+ {
47330
+ share: "0x82356c921422a2202e0f96dfccc352598ca8ef71",
47331
+ // bwBTW
47332
+ vault: "0x5c4a6903732532eeb3ae0803e062d8ae25d52bd1",
47333
+ token: "0x444045b0ee1ee319a660a5e3d604ca0ffa35acaa"
47334
+ // BTW
47335
+ },
47336
+ // Core Alpha 0xb82E3206…
47337
+ {
47338
+ share: "0x73af543d809c8d3414e5b92b3aa2c25b182ba3a1",
47339
+ // BTWUSDT
47340
+ vault: "0xb82e32062c773c7748776c06fdb11b92edae3b63",
47341
+ token: "0x55d398326f99059ff775485246999027b3197955"
47342
+ // USDT
47343
+ },
47344
+ {
47345
+ share: "0xb5c3617d4f077851cc6c7fae558d32e9782307f9",
47346
+ // BTWUSD1
47347
+ vault: "0xb82e32062c773c7748776c06fdb11b92edae3b63",
47348
+ token: "0x8d0d000ee44948fc98c9b98a4fa4921476f08b0d"
47349
+ // USD1
47350
+ },
47351
+ {
47352
+ share: "0x4effb6bce5cad64d7162c7f7f15f557221b106d5",
47353
+ // BTWU
47354
+ vault: "0xb82e32062c773c7748776c06fdb11b92edae3b63",
47355
+ token: "0xce24439f2d9c6a2289f741120fe202248b666666"
47356
+ // U
47357
+ }
47358
+ ];
47359
+ var bitwayYieldKey = (share) => `bitway::${Chain.BNB_SMART_CHAIN_MAINNET}::${share.toLowerCase()}`;
47360
+ var bitwayFetcher = {
47361
+ label: "BITWAY_EARN",
47362
+ fetch: async () => {
47363
+ const rates = await multicallRetryUniversal({
47364
+ chain: Chain.BNB_SMART_CHAIN_MAINNET,
47365
+ abi: REWARD_RATE_ABI,
47366
+ calls: BITWAY_LEGS.map(({ vault, token }) => ({
47367
+ address: vault,
47368
+ name: "getCurrentRewardRate",
47369
+ params: [token]
47370
+ })),
47371
+ allowFailure: true
47372
+ });
47373
+ const out = {};
47374
+ BITWAY_LEGS.forEach(({ share }, i) => {
47375
+ const raw = rates[i];
47376
+ if (typeof raw !== "bigint") return;
47377
+ const apr = Number(raw) / 100;
47378
+ if (Number.isFinite(apr) && apr >= 0 && apr <= 1e3) {
47379
+ out[bitwayYieldKey(share)] = apr;
47380
+ }
47381
+ });
47382
+ if (Object.keys(out).length === 0) {
47383
+ throw new Error("Bitway: no leg returned a readable reward rate");
47384
+ }
47385
+ return out;
47386
+ }
47387
+ };
47388
+
47389
+ // src/vaults/savings/registryBitway.ts
47390
+ var BITWAY_LEGS2 = [
47391
+ [
47392
+ "bwUSDT",
47393
+ "Absolute Return USDT",
47394
+ "0xccafb706225331aedfec75b5347d462b98ed2fd2",
47395
+ "0x55d398326f99059ff775485246999027b3197955",
47396
+ "USDT",
47397
+ "0x5c4a6903732532eeb3ae0803e062d8ae25d52bd1",
47398
+ "0x2b8464ffb2b77de64cfefdeb00ad925576f157cb",
47399
+ "the Absolute Return strategy (0.5% instant-exit fee)"
47400
+ ],
47401
+ [
47402
+ "bwU",
47403
+ "Absolute Return U",
47404
+ "0xaa3d2534b4b87a2859e28c223f18265244ffffb7",
47405
+ "0xce24439f2d9c6a2289f741120fe202248b666666",
47406
+ "U",
47407
+ "0x5c4a6903732532eeb3ae0803e062d8ae25d52bd1",
47408
+ "0x2b8464ffb2b77de64cfefdeb00ad925576f157cb",
47409
+ "the Absolute Return strategy (0.5% instant-exit fee)"
47410
+ ],
47411
+ [
47412
+ "bwBTW",
47413
+ "Absolute Return BTW",
47414
+ "0x82356c921422a2202e0f96dfccc352598ca8ef71",
47415
+ "0x444045b0ee1ee319a660a5e3d604ca0ffa35acaa",
47416
+ "BTW",
47417
+ "0x5c4a6903732532eeb3ae0803e062d8ae25d52bd1",
47418
+ "0x2b8464ffb2b77de64cfefdeb00ad925576f157cb",
47419
+ "the Absolute Return strategy (0.5% instant-exit fee). The rate is denominated in BTW, Bitway's own volatile token \u2014 not in dollars"
47420
+ ],
47421
+ [
47422
+ "BTWUSDT",
47423
+ "Core Alpha USDT",
47424
+ "0x73af543d809c8d3414e5b92b3aa2c25b182ba3a1",
47425
+ "0x55d398326f99059ff775485246999027b3197955",
47426
+ "USDT",
47427
+ "0xb82e32062c773c7748776c06fdb11b92edae3b63",
47428
+ "0xfc8e6b1ab1a4c37724f8bc797730afa8d01d04ef",
47429
+ "the Core Alpha strategy (no instant-exit fee live; ~1M per-user stake cap)"
47430
+ ],
47431
+ [
47432
+ "BTWUSD1",
47433
+ "Core Alpha USD1",
47434
+ "0xb5c3617d4f077851cc6c7fae558d32e9782307f9",
47435
+ "0x8d0d000ee44948fc98c9b98a4fa4921476f08b0d",
47436
+ "USD1",
47437
+ "0xb82e32062c773c7748776c06fdb11b92edae3b63",
47438
+ "0xfc8e6b1ab1a4c37724f8bc797730afa8d01d04ef",
47439
+ "the Core Alpha strategy (no instant-exit fee live; ~1M per-user stake cap)"
47440
+ ],
47441
+ [
47442
+ "BTWU",
47443
+ "Core Alpha U",
47444
+ "0x4effb6bce5cad64d7162c7f7f15f557221b106d5",
47445
+ "0xce24439f2d9c6a2289f741120fe202248b666666",
47446
+ "U",
47447
+ "0xb82e32062c773c7748776c06fdb11b92edae3b63",
47448
+ "0xfc8e6b1ab1a4c37724f8bc797730afa8d01d04ef",
47449
+ "the Core Alpha strategy (no instant-exit fee live; ~1M per-user stake cap)"
47450
+ ]
47451
+ ];
47452
+ var BITWAY_ENTRIES = {
47453
+ [Chain.BNB_SMART_CHAIN_MAINNET]: BITWAY_LEGS2.map(
47454
+ ([
47455
+ symbol,
47456
+ label,
47457
+ address,
47458
+ underlying,
47459
+ underlyingSymbol,
47460
+ stakingVault,
47461
+ withdrawVault,
47462
+ strategyNote
47463
+ ]) => ({
47464
+ reader: "bitway-vault",
47465
+ address,
47466
+ underlying,
47467
+ symbol,
47468
+ label,
47469
+ brand: "Bitway",
47470
+ description: `${symbol} is the receipt for ${underlyingSymbol} staked into Bitway Earn's ${strategyNote}. Capital runs market-neutral trading in CEX/custodian accounts; yield settles at a fixed admin-set rate with no on-chain solvency invariant. Exit: free 7-day queue (payout frozen at the request-time rate) or an instant withdrawal capped by a small on-chain buffer. Withdrawal rights stay with the staking address \u2014 a transferee of the receipt token cannot exit.`,
47471
+ decimals: 18,
47472
+ underlyingDecimals: 18,
47473
+ isRebasing: false,
47474
+ isMintable: true,
47475
+ mintContract: stakingVault,
47476
+ accrual: "linear",
47477
+ withdrawalMode: "fee-or-queued",
47478
+ withdrawalCooldownSeconds: 604800,
47479
+ withdrawQueue: withdrawVault,
47480
+ // The instant leg pays from the staking vault's own token balance;
47481
+ // the reader treats `priceOracle` as "where the rate lives" (the
47482
+ // two-arg convertToAssets) — both are the parent vault.
47483
+ inventoryContract: stakingVault,
47484
+ priceOracle: stakingVault,
47485
+ yieldFetcher: bitwayFetcher,
47486
+ yieldKey: bitwayYieldKey(address)
47487
+ })
47488
+ )
47489
+ };
46813
47490
 
46814
47491
  // src/vaults/savings/registry.ts
46815
47492
  var stUsdGroup = {
@@ -47900,7 +48577,15 @@ var SINGLE_CHAIN_ENTRIES = {
47900
48577
  underlying: "0x09d4214c03d01f49544c0448dbe3a27f768f2b34",
47901
48578
  symbol: "wsrUSD",
47902
48579
  brand: "Reservoir",
47903
- description: "rUSD is Reservoir's asset-backed stablecoin; srUSD accrues the Reservoir savings rate funded by the protocol's RWA and credit portfolios, and wsrUSD is its non-rebasing wrapper. Instant exit, subject to PSM liquidity.",
48580
+ // NB: NOT a wrapper of srUSD despite the name verified on-chain
48581
+ // 2026-08-19 (see RESERVOIR.md): a second-generation Savingcoin
48582
+ // directly over rUSD with its own governance-set accumulator.
48583
+ // Deposits burn rUSD and exits mint it, so the vault custodies
48584
+ // nothing and there is no on-chain solvency invariant (the
48585
+ // CreditEnforcer's covenant minimums are zeroed and its adapters
48586
+ // removed). Exit to rUSD is instant/unlimited; par exit to USDC is
48587
+ // bounded by live USDC-PSM inventory (~0.1% of the book).
48588
+ description: "rUSD is Reservoir's asset-backed stablecoin; wsrUSD accrues the Reservoir savings rate (governance-set, funded by the protocol's RWA and credit portfolios) directly on rUSD \u2014 reserves are managed off-chain with no on-chain solvency invariant. Exit to rUSD is instant; converting onward to USDC at par depends on the PSM's live inventory, a small fraction of the book.",
47904
48589
  decimals: 18,
47905
48590
  isRebasing: false,
47906
48591
  isMintable: true,
@@ -48469,6 +49154,10 @@ var SAVINGS_REGISTRY = (() => {
48469
49154
  if (!out[chainId]) out[chainId] = [];
48470
49155
  out[chainId].push(...entries);
48471
49156
  }
49157
+ for (const [chainId, entries] of Object.entries(BITWAY_ENTRIES)) {
49158
+ if (!out[chainId]) out[chainId] = [];
49159
+ out[chainId].push(...entries);
49160
+ }
48472
49161
  return out;
48473
49162
  })();
48474
49163
  var savingsBalanceKind = (chainId, address) => {
@@ -49998,7 +50687,7 @@ var dtrinityRebateRewardFetcher = {
49998
50687
  }
49999
50688
  };
50000
50689
  var SECONDS_PER_YEAR14 = 31536e3;
50001
- var WAD15 = 10n ** 18n;
50690
+ var WAD16 = 10n ** 18n;
50002
50691
  var ZERO2 = "0x0000000000000000000000000000000000000000";
50003
50692
  var UNBOOSTED_FACTOR = 0.4;
50004
50693
  var MAX_BOOST = 2.5;
@@ -50216,7 +50905,7 @@ async function fetchForChain(chainId, nowSeconds) {
50216
50905
  { address: m.gauge, name: "totalSupply", params: [] },
50217
50906
  { address: m.gauge, name: "is_killed", params: [] },
50218
50907
  { address: m.gauge, name: "reward_count", params: [] },
50219
- { address: m.vault, name: "convertToAssets", params: [WAD15] },
50908
+ { address: m.vault, name: "convertToAssets", params: [WAD16] },
50220
50909
  isL1 ? {
50221
50910
  address: GAUGE_CONTROLLER,
50222
50911
  name: "gauge_relative_weight",
@@ -50232,7 +50921,7 @@ async function fetchForChain(chainId, nowSeconds) {
50232
50921
  abi: GAUGE_ABI,
50233
50922
  allowFailure: true
50234
50923
  });
50235
- const big20 = (v) => {
50924
+ const big22 = (v) => {
50236
50925
  try {
50237
50926
  if (typeof v === "bigint") return v;
50238
50927
  if (typeof v === "string" && v !== "0x") return BigInt(v);
@@ -50246,15 +50935,15 @@ async function fetchForChain(chainId, nowSeconds) {
50246
50935
  const b = i * STRIDE;
50247
50936
  return {
50248
50937
  market: m,
50249
- inflationRate: big20(r1[b]),
50250
- workingSupply: big20(r1[b + 1]),
50251
- totalSupply: big20(r1[b + 2]),
50938
+ inflationRate: big22(r1[b]),
50939
+ workingSupply: big22(r1[b + 1]),
50940
+ totalSupply: big22(r1[b + 2]),
50252
50941
  isKilled: r1[b + 3] === true,
50253
- rewardCount: Number(big20(r1[b + 4])),
50254
- pricePerShare: big20(r1[b + 5]),
50942
+ rewardCount: Number(big22(r1[b + 4])),
50943
+ pricePerShare: big22(r1[b + 5]),
50255
50944
  // Off L1 the child gauge's own rate is already market-scoped, so the
50256
50945
  // weight is the identity.
50257
- relativeWeight: isL1 ? big20(r1[b + 6]) : WAD15
50946
+ relativeWeight: isL1 ? big22(r1[b + 6]) : WAD16
50258
50947
  };
50259
50948
  });
50260
50949
  const tokenCalls = state.flatMap(
@@ -50347,7 +51036,7 @@ async function fetchForChain(chainId, nowSeconds) {
50347
51036
  const decoded = decodeRewardData(data);
50348
51037
  if (!decoded) continue;
50349
51038
  const { periodFinish, rate } = decoded;
50350
- const decimals = typeof decRaw === "number" ? decRaw : Number(big20(decRaw) || 18n);
51039
+ const decimals = typeof decRaw === "number" ? decRaw : Number(big22(decRaw) || 18n);
50351
51040
  const rewardPrice = priceOf(prices, chainId, token);
50352
51041
  const apr = extraRewardApr({
50353
51042
  rate,
@@ -51362,7 +52051,7 @@ function getDssCalls(chainId) {
51362
52051
  return results;
51363
52052
  }
51364
52053
  var RAY10 = 1e27;
51365
- var big17 = (v) => {
52054
+ var big19 = (v) => {
51366
52055
  try {
51367
52056
  if (typeof v === "bigint") return v;
51368
52057
  if (v == null || v === "0x") return 0n;
@@ -51374,16 +52063,16 @@ var big17 = (v) => {
51374
52063
  var field12 = (res, name, idx) => {
51375
52064
  const v = res?.[name];
51376
52065
  if (typeof v === "bigint" || typeof v === "number" || typeof v === "string") {
51377
- return big17(v);
52066
+ return big19(v);
51378
52067
  }
51379
- return big17(res?.[idx]);
52068
+ return big19(res?.[idx]);
51380
52069
  };
51381
52070
  function parseDssResults(data, meta, context) {
51382
52071
  const { chainId } = context;
51383
52072
  const key3 = dssLenderKey(meta.lender, chainId, meta.ilk);
51384
52073
  const entries = [];
51385
52074
  const spot = field12(data?.[0], "spot", 2);
51386
- const mat = big17(meta.mat);
52075
+ const mat = big19(meta.mat);
51387
52076
  if (spot > 0n && mat > 0n) {
51388
52077
  const collUSD = Number(spot) / RAY10 * (Number(mat) / RAY10);
51389
52078
  if (collUSD > 0 && collUSD < 1e9) {
@@ -57655,7 +58344,7 @@ var num4 = (v) => {
57655
58344
  const n = Number(v);
57656
58345
  return Number.isFinite(n) ? n : 0;
57657
58346
  };
57658
- var big18 = (v) => {
58347
+ var big20 = (v) => {
57659
58348
  try {
57660
58349
  if (v === void 0 || v === null || v === "") return "0";
57661
58350
  const s = String(v);
@@ -57691,12 +58380,12 @@ async function fetchTermMaxVaultsFromApi(chainId, prices = {}, tokenList = {}, f
57691
58380
  const assetEntry = tokenList[underlying];
57692
58381
  const priceKey = toOracleKey(assetEntry?.assetGroup) || toGenericPriceKey(underlying, chainId);
57693
58382
  const priceUsd = prices[priceKey];
57694
- const totalAssets = big18(r.totalAssets);
57695
- const totalSupply = big18(r.totalSupplyAmt);
58383
+ const totalAssets = big20(r.totalAssets);
58384
+ const totalSupply = big20(r.totalSupplyAmt);
57696
58385
  const totalAssetsFormatted = Number(totalAssets) / scale3;
57697
58386
  const supplyRate = num4(r.apr) * 100;
57698
58387
  const rewardsRate = num4(r?.incentiveData?.TMX_APR) * 100;
57699
- const rawLiquidity = BigInt(big18(r.redeemableAmt ?? r.idleFunds ?? "0"));
58388
+ const rawLiquidity = BigInt(big20(r.redeemableAmt ?? r.idleFunds ?? "0"));
57700
58389
  const totalAssetsBig = BigInt(totalAssets);
57701
58390
  const liquidity = (rawLiquidity > totalAssetsBig ? totalAssetsBig : rawLiquidity).toString();
57702
58391
  const liquidityFormatted = Number(liquidity) / scale3;
@@ -57732,7 +58421,7 @@ async function fetchTermMaxVaultsFromApi(chainId, prices = {}, tokenList = {}, f
57732
58421
  liquidityUsd: priceUsd ? liquidityFormatted * priceUsd : 0,
57733
58422
  version: r.version,
57734
58423
  isPaused: r.isPaused === true || void 0,
57735
- supplyCap: r.capacity ? big18(r.capacity) : void 0,
58424
+ supplyCap: r.capacity ? big20(r.capacity) : void 0,
57736
58425
  basePool: r.poolAddress ? lower3(r.poolAddress) : void 0
57737
58426
  };
57738
58427
  }
@@ -57788,7 +58477,7 @@ var Erc20DecimalsBalanceAbi = [
57788
58477
 
57789
58478
  // src/vaults/termmax/fetchFromChain.ts
57790
58479
  var DECIMAL_BASE2 = 100000000n;
57791
- var big19 = (v) => {
58480
+ var big21 = (v) => {
57792
58481
  if (v === void 0 || v === null || v === "0x") return 0n;
57793
58482
  try {
57794
58483
  return typeof v === "bigint" ? v : BigInt(v);
@@ -57852,7 +58541,7 @@ var fetchTermMaxVaultsFromChain = async (chainId, multicallRetry, prices = {}, t
57852
58541
  vaults.forEach((address, i) => {
57853
58542
  const at = (k) => res[i * READS_PER_VAULT + VAULT_READS.indexOf(k)];
57854
58543
  const asset = addr(at("asset"));
57855
- const totalAssets = big19(at("totalAssets"));
58544
+ const totalAssets = big21(at("totalAssets"));
57856
58545
  if (!asset || totalAssets === 0n) return;
57857
58546
  rows.push({
57858
58547
  address,
@@ -57861,11 +58550,11 @@ var fetchTermMaxVaultsFromChain = async (chainId, multicallRetry, prices = {}, t
57861
58550
  decimals: num5(at("decimals")) ?? 18,
57862
58551
  asset,
57863
58552
  totalAssets,
57864
- totalSupply: big19(at("totalSupply")),
57865
- annualizedInterest: big19(at("annualizedInterest")),
57866
- accretingPrincipal: big19(at("accretingPrincipal")),
57867
- performanceFeeRate: big19(at("performanceFeeRate")),
57868
- aprRaw: at("apr") != null ? big19(at("apr")) : void 0,
58553
+ totalSupply: big21(at("totalSupply")),
58554
+ annualizedInterest: big21(at("annualizedInterest")),
58555
+ accretingPrincipal: big21(at("accretingPrincipal")),
58556
+ performanceFeeRate: big21(at("performanceFeeRate")),
58557
+ aprRaw: at("apr") != null ? big21(at("apr")) : void 0,
57869
58558
  curator: addr(at("curator")),
57870
58559
  guardian: addr(at("guardian")),
57871
58560
  timelock: num5(at("timelock")),
@@ -57886,7 +58575,7 @@ var fetchTermMaxVaultsFromChain = async (chainId, multicallRetry, prices = {}, t
57886
58575
  const out = {};
57887
58576
  rows.forEach((r, i) => {
57888
58577
  const assetDecimals = num5(res2[i * 2]) ?? r.decimals;
57889
- const idle = big19(res2[i * 2 + 1]);
58578
+ const idle = big21(res2[i * 2 + 1]);
57890
58579
  const assetEntry = tokenList[r.asset];
57891
58580
  const priceKey = toOracleKey(assetEntry?.assetGroup) || toGenericPriceKey(r.asset, chainId);
57892
58581
  const priceUsd = prices[priceKey];
@@ -63393,6 +64082,45 @@ var NativeWithdrawQueueReadAbi = [
63393
64082
  }
63394
64083
  ];
63395
64084
 
64085
+ // src/vaults/savings/abis/bitway.ts
64086
+ var BitwayVaultReadAbi = [
64087
+ {
64088
+ name: "convertToAssets",
64089
+ type: "function",
64090
+ stateMutability: "view",
64091
+ inputs: [{ type: "uint256" }, { type: "address", name: "token" }],
64092
+ outputs: [{ type: "uint256" }]
64093
+ },
64094
+ {
64095
+ name: "getTVL",
64096
+ type: "function",
64097
+ stateMutability: "view",
64098
+ inputs: [{ type: "address", name: "token" }],
64099
+ outputs: [{ type: "uint256" }]
64100
+ },
64101
+ {
64102
+ name: "getContractBalance",
64103
+ type: "function",
64104
+ stateMutability: "view",
64105
+ inputs: [{ type: "address", name: "token" }],
64106
+ outputs: [{ type: "uint256" }]
64107
+ },
64108
+ {
64109
+ name: "getCurrentRewardRate",
64110
+ type: "function",
64111
+ stateMutability: "view",
64112
+ inputs: [{ type: "address", name: "token" }],
64113
+ outputs: [{ type: "uint256" }]
64114
+ },
64115
+ {
64116
+ name: "WAITING_TIME",
64117
+ type: "function",
64118
+ stateMutability: "view",
64119
+ inputs: [],
64120
+ outputs: [{ type: "uint256" }]
64121
+ }
64122
+ ];
64123
+
63396
64124
  // src/vaults/savings/abis/frankencoin.ts
63397
64125
  var FrankencoinSavingsReadAbi = [
63398
64126
  {
@@ -63607,6 +64335,65 @@ var readerErc4626WithdrawLimit = (entry) => {
63607
64335
  };
63608
64336
  };
63609
64337
 
64338
+ // src/vaults/savings/readers/bitwayVault.ts
64339
+ var BITWAY_PENALTY_BPS = {
64340
+ // Absolute Return
64341
+ "0x5c4a6903732532eeb3ae0803e062d8ae25d52bd1": 50,
64342
+ // Core Alpha
64343
+ "0xb82e32062c773c7748776c06fdb11b92edae3b63": 0
64344
+ };
64345
+ var readerBitwayVault = (entry) => {
64346
+ const { address, underlying, priceOracle } = entry;
64347
+ const vault = priceOracle ?? entry.mintContract ?? address;
64348
+ const shareUnit = 10n ** BigInt(entry.decimals);
64349
+ const underlyingUnit = 10n ** BigInt(entry.underlyingDecimals ?? entry.decimals);
64350
+ const penaltyBps = BITWAY_PENALTY_BPS[vault.toLowerCase()];
64351
+ return {
64352
+ calls: [
64353
+ { address, name: "totalSupply", params: [] },
64354
+ {
64355
+ address: vault,
64356
+ name: "convertToAssets",
64357
+ params: [ONE_E1813, underlying]
64358
+ },
64359
+ { address: vault, name: "getContractBalance", params: [underlying] },
64360
+ { address: vault, name: "WAITING_TIME", params: [] }
64361
+ ],
64362
+ abis: [
64363
+ TotalSupplyAbi2,
64364
+ BitwayVaultReadAbi,
64365
+ BitwayVaultReadAbi,
64366
+ BitwayVaultReadAbi
64367
+ ],
64368
+ parse: ([supply, rate, buffer, waitingTime]) => {
64369
+ const totalSupply = toBigInt16(supply);
64370
+ const exchangeRate = toBigInt16(rate);
64371
+ if (totalSupply === void 0 || exchangeRate === void 0 || exchangeRate === 0n) {
64372
+ return void 0;
64373
+ }
64374
+ const capacity = toBigInt16(buffer);
64375
+ const wait = toBigInt16(waitingTime);
64376
+ return {
64377
+ // totalSupply is in raw share units; convert to raw underlying.
64378
+ // (Every live leg is 18/18-dec — BSC stables are 18-dec — but the
64379
+ // rescale keeps a future 6-dec listing honest.)
64380
+ totalAssets: totalSupply * exchangeRate * underlyingUnit / (shareUnit * ONE_E1813),
64381
+ totalSupply,
64382
+ exchangeRate,
64383
+ withdrawFeeBps: penaltyBps,
64384
+ // The flash flag has no getter either (`flashNotEnable`, packed
64385
+ // storage — enabled on both vaults live). A drained buffer already
64386
+ // zeroes the instant leg's reported liquidity, which is the same
64387
+ // caller-visible outcome as a disabled flash path.
64388
+ instantRedeemEnabled: penaltyBps !== void 0 ? true : void 0,
64389
+ instantRedeemCapacity: capacity,
64390
+ withdrawalCooldownSeconds: wait !== void 0 && wait <= 366n * 86400n ? Number(wait) : void 0,
64391
+ withdrawQueue: entry.withdrawQueue
64392
+ };
64393
+ }
64394
+ };
64395
+ };
64396
+
63610
64397
  // src/vaults/savings/readers/frankencoinSavings.ts
63611
64398
  var readerFrankencoinSavings = (entry) => ({
63612
64399
  calls: [
@@ -63866,6 +64653,8 @@ var buildReader2 = (entry) => {
63866
64653
  return readerFrankencoinSavings(entry);
63867
64654
  case "hyperbeat-vault":
63868
64655
  return readerHyperbeatVault(entry);
64656
+ case "bitway-vault":
64657
+ return readerBitwayVault(entry);
63869
64658
  case "yieldbasis-lt":
63870
64659
  return readerYieldBasisLt(entry);
63871
64660
  case "wren-nav":
@@ -65723,23 +66512,23 @@ var priceGmMarkets = async (chainId, multicallRetry, markets, prices) => {
65723
66512
  const indexMax = price(prices, m.indexToken)?.max;
65724
66513
  if (Array.isArray(dsRes) && longMax != null && shortMax != null) {
65725
66514
  const base = i * SLOTS;
65726
- const big20 = (j) => typeof dsRes[base + j] === "bigint" ? dsRes[base + j] : 0n;
66515
+ const big22 = (j) => typeof dsRes[base + j] === "bigint" ? dsRes[base + j] : 0n;
65727
66516
  const cap = computeDepositCapacityUsd(
65728
- [info?.longTokenAmount, longMax, big20(0), big20(2)],
65729
- [info?.shortTokenAmount, shortMax, big20(1), big20(3)]
66517
+ [info?.longTokenAmount, longMax, big22(0), big22(2)],
66518
+ [info?.shortTokenAmount, shortMax, big22(1), big22(3)]
65730
66519
  );
65731
66520
  if (cap != null) value.depositCapacityUsd = cap;
65732
66521
  if (indexMax != null) {
65733
66522
  const divisor = m.longToken.toLowerCase() === m.shortToken.toLowerCase() ? 2n : 1n;
65734
- const reservedUsdLong = (big20(4) + big20(5)) / divisor * indexMax;
65735
- const reservedUsdShort = (big20(6) + big20(7)) / divisor;
66523
+ const reservedUsdLong = (big22(4) + big22(5)) / divisor * indexMax;
66524
+ const reservedUsdShort = (big22(6) + big22(7)) / divisor;
65736
66525
  const liq = computeLiquidityUsd(
65737
66526
  info?.longTokenUsd,
65738
66527
  info?.shortTokenUsd,
65739
66528
  reservedUsdLong,
65740
66529
  reservedUsdShort,
65741
- big20(8),
65742
- big20(9)
66530
+ big22(8),
66531
+ big22(9)
65743
66532
  );
65744
66533
  if (liq != null)
65745
66534
  value.liquidityUsd = Math.max(0, Math.min(liq, value.tvlUsd));
@@ -65938,21 +66727,21 @@ var fetchGmxExecutionFees = async (chainId, multicallRetry, gasPriceWei) => {
65938
66727
  } catch {
65939
66728
  return void 0;
65940
66729
  }
65941
- const big20 = (i) => typeof res[i] === "bigint" ? res[i] : 0n;
65942
- const base = big20(0);
65943
- const mult = big20(1);
66730
+ const big22 = (i) => typeof res[i] === "bigint" ? res[i] : 0n;
66731
+ const base = big22(0);
66732
+ const mult = big22(1);
65944
66733
  if (base === 0n && mult === 0n) return void 0;
65945
66734
  const PRECISION = 10n ** 30n;
65946
66735
  const adjusted = (opGas) => base + opGas * mult / PRECISION;
65947
66736
  const fee = (opGas) => (adjusted(opGas) * gasPriceWei).toString();
65948
- const glvExtra = big20(6) * GLV_NOMINAL_MARKET_COUNT;
66737
+ const glvExtra = big22(6) * GLV_NOMINAL_MARKET_COUNT;
65949
66738
  return {
65950
66739
  chainId,
65951
66740
  gasPriceWei: gasPriceWei.toString(),
65952
- deposit: fee(big20(2)),
65953
- withdrawal: fee(big20(3)),
65954
- glvDeposit: fee(big20(4) + glvExtra),
65955
- glvWithdrawal: fee(big20(5) + glvExtra)
66741
+ deposit: fee(big22(2)),
66742
+ withdrawal: fee(big22(3)),
66743
+ glvDeposit: fee(big22(4) + glvExtra),
66744
+ glvWithdrawal: fee(big22(5) + glvExtra)
65956
66745
  };
65957
66746
  };
65958
66747
 
@@ -67610,6 +68399,27 @@ var TERM_PROFILES = [
67610
68399
  ]
67611
68400
  }
67612
68401
  }),
68402
+ P({
68403
+ id: "cooler.mono@v1",
68404
+ name: "Olympus Cooler V2 (MonoCooler)",
68405
+ family: "cooler",
68406
+ supply: {
68407
+ description: "gOHM collateral on a treasury-backed CDP. It earns nothing here \u2014 gOHM staking emissions are currently zero \u2014 and it backs only your own debt.",
68408
+ implications: [
68409
+ "Your counterparty is the Olympus treasury itself: there are no external lenders, and collateral seized in a liquidation is unstaked and BURNED."
68410
+ ]
68411
+ },
68412
+ borrow: {
68413
+ description: "A perpetual treasury CDP at a fixed protocol-set rate \u2014 0.5 % effective today, governance-settable with a hard 10 % cap. There is NO price-based liquidation: the LTV is a debt-per-gOHM PRICE that only ratchets up, and the sole trigger is your accruing debt outrunning that ratchet (LLTV = OLTV \xD7 1.01).",
68414
+ implications: [
68415
+ "No market price enters the solvency math: liquidation happens only if your compounding debt crosses the up-only governance LTV ratchet, never because the gOHM price moved. A max-borrowed account needs roughly two years of a frozen ratchet to cross.",
68416
+ "If liquidated, your gOHM is unstaked and BURNED \u2014 there is no auction and no external lender to make whole; the counterparty is the Olympus treasury.",
68417
+ "There is a 1,000 USDS minimum debt: it gates borrows AND partial repays \u2014 any action leaving a debt below it reverts (a full repay is always fine).",
68418
+ "The position is perpetual \u2014 no maturity, no expiry.",
68419
+ "The debt token itself is governance-swappable (a new treasury borrower can replace USDS), so read it live rather than assuming USDS."
68420
+ ]
68421
+ }
68422
+ }),
67613
68423
  P({
67614
68424
  id: "dss.cdp@v1",
67615
68425
  name: "Maker-style (dss) CDP ilk",
@@ -67896,7 +68706,7 @@ var TERM_SHEET_SCHEMA_VERSION = 1;
67896
68706
 
67897
68707
  // src/terms/buildTermSheet.ts
67898
68708
  var isNum = (v) => typeof v === "number" && Number.isFinite(v);
67899
- var clamp01 = (v) => Math.max(0, Math.min(1, v));
68709
+ var clamp012 = (v) => Math.max(0, Math.min(1, v));
67900
68710
  function assetRef(input) {
67901
68711
  const a = input.asset ?? {};
67902
68712
  return {
@@ -68083,6 +68893,9 @@ function resolveMinDebt(input) {
68083
68893
  m.river?.minNetDebt,
68084
68894
  // Inverse FiRM.
68085
68895
  m.inverse?.minDebt,
68896
+ // Cooler (Olympus V2) — `minDebtRequired`, 1,000 USDS. Gates borrows AND
68897
+ // partial repays: any action leaving 0 < debt < minDebt reverts.
68898
+ m.cooler?.minDebt,
68086
68899
  // dss (Sky / the USDD fork): `dust` IS the per-vault debt floor.
68087
68900
  m.dss?.dust ?? m.usdd?.dust,
68088
68901
  // Gearbox credit facade.
@@ -68109,7 +68922,7 @@ function resolveMinCollateral(input) {
68109
68922
  }
68110
68923
  function capUtil(total, cap) {
68111
68924
  if (!isNum(cap) || cap <= 0 || !isNum(total)) return void 0;
68112
- return clamp01(total / cap);
68925
+ return clamp012(total / cap);
68113
68926
  }
68114
68927
  function buildAvailability(input, side) {
68115
68928
  const frozen = input.isFrozen === true;
@@ -68148,7 +68961,7 @@ function buildUtilization(input) {
68148
68961
  if (!isNum(input.utilization)) return void 0;
68149
68962
  const shared = isNum(input.irmTotalDeposits) && isNum(input.irmTotalDebt);
68150
68963
  return {
68151
- utilization: clamp01(input.utilization),
68964
+ utilization: clamp012(input.utilization),
68152
68965
  basis: shared ? "pool" : "market",
68153
68966
  irmTotalDeposits: input.irmTotalDeposits,
68154
68967
  irmTotalDebt: input.irmTotalDebt,
@@ -68288,7 +69101,7 @@ function buildSupply(input, now, siblings) {
68288
69101
  const liquidity = isNum(input.totalLiquidity) ? {
68289
69102
  assets: input.totalLiquidity,
68290
69103
  assetsUsd: input.totalLiquidityUsd,
68291
- ratio: isNum(input.totalDeposits) && input.totalDeposits > 0 ? clamp01(input.totalLiquidity / input.totalDeposits) : void 0
69104
+ ratio: isNum(input.totalDeposits) && input.totalDeposits > 0 ? clamp012(input.totalLiquidity / input.totalDeposits) : void 0
68292
69105
  } : void 0;
68293
69106
  const supply = {
68294
69107
  role: canBeCollateral ? earns ? "both" : "collateral" : "yield",
@@ -68699,7 +69512,7 @@ function windowFromAprWindow(aprWindow) {
68699
69512
 
68700
69513
  // src/terms/vault/build.ts
68701
69514
  var isNum2 = (v) => typeof v === "number" && Number.isFinite(v);
68702
- var clamp012 = (v) => Math.max(0, Math.min(1, v));
69515
+ var clamp013 = (v) => Math.max(0, Math.min(1, v));
68703
69516
  function buildRate2(input, t, maturity) {
68704
69517
  const hasLegs = input.supplyRate != null || input.rewardsRate != null;
68705
69518
  const base = hasLegs ? input.supplyRate ?? 0 : input.totalRate ?? 0;
@@ -68876,7 +69689,7 @@ function settlementFor(mode, priceRisk) {
68876
69689
  function buildExit(input, t, fees) {
68877
69690
  const mode = resolveExitMode(input, t);
68878
69691
  const priceRisk = resolvePriceRisk(input, t);
68879
- const ratio = input.instantLiquidityRatio ?? (isNum2(input.liquidity) && isNum2(input.totalAssets) && input.totalAssets > 0 ? clamp012(input.liquidity / input.totalAssets) : void 0);
69692
+ const ratio = input.instantLiquidityRatio ?? (isNum2(input.liquidity) && isNum2(input.totalAssets) && input.totalAssets > 0 ? clamp013(input.liquidity / input.totalAssets) : void 0);
68880
69693
  return {
68881
69694
  mode,
68882
69695
  settlement: settlementFor(mode, priceRisk),
@@ -69034,7 +69847,7 @@ function buildUtilization2(input, t) {
69034
69847
  const total = input.expectedLiquidity;
69035
69848
  if (!isNum2(borrowed) || !isNum2(total) || total <= 0) return void 0;
69036
69849
  return {
69037
- utilization: clamp012(borrowed / total),
69850
+ utilization: clamp013(borrowed / total),
69038
69851
  // The ratio is the underlying pool's, not this share token's.
69039
69852
  basis: "pool",
69040
69853
  irmTotalDeposits: total,
@@ -71126,6 +71939,10 @@ var ROW_DESCRIPTOR_KEYS = [
71126
71939
  "river",
71127
71940
  "teller",
71128
71941
  "inverse",
71942
+ // Cooler: the price-LTV ratchet, the drip schedule and the minDebt gate —
71943
+ // the descriptor is the only carrier of the protocol truth (the fractional
71944
+ // factors on the row are display-only).
71945
+ "cooler",
71129
71946
  "exactly",
71130
71947
  "usdd",
71131
71948
  "dss",
@@ -72035,6 +72852,68 @@ var inverseAdapter = {
72035
72852
  }
72036
72853
  })
72037
72854
  };
72855
+ var coolerAdapter = {
72856
+ id: "cooler",
72857
+ matches: isCooler,
72858
+ profileId: () => "cooler.mono@v1",
72859
+ build: (input) => {
72860
+ const c = input.market?.cooler ?? {};
72861
+ return {
72862
+ // The "oracle" is a governance drip schedule, not a price feed — the
72863
+ // solvency path uses no market price at all.
72864
+ oracle: { kind: "none" },
72865
+ supply: {
72866
+ role: "collateral",
72867
+ availability: { opensWith: "both-legs" },
72868
+ counterparty: { kind: "cdp", solvency: "overcollateralized" }
72869
+ },
72870
+ borrow: {
72871
+ rate: {
72872
+ // Governance-set with no curve — the dss/USDD shape.
72873
+ kind: "variable-managed",
72874
+ source: "governance",
72875
+ isLocked: false,
72876
+ /** MAX_INTEREST_RATE — a hard 10 % cap enforced by code. */
72877
+ maxApr: 10
72878
+ },
72879
+ debtShape: "accruing",
72880
+ maturity: { kind: "perpetual" },
72881
+ exit: {
72882
+ earlyRepay: "free",
72883
+ atMaturityCost: "accrued",
72884
+ lateBehaviour: "none",
72885
+ partialAllowed: true,
72886
+ // Over-repay CLAMPS on MonoCooler — a full close is always safe.
72887
+ overRepayReverts: false
72888
+ },
72889
+ liquidation: {
72890
+ // The trigger is TIME, never price: debt compounding at ~0.5 %/yr
72891
+ // against an up-only OLTV ratchet (LLTV = OLTV × 1.01). Never apply
72892
+ // "HF < 1 at spot price ⇒ liquidatable" copy here.
72893
+ trigger: "time",
72894
+ model: "repay-seize",
72895
+ // Seized gOHM is unstaked and BURNED — nobody receives it.
72896
+ seizure: "full-collateral",
72897
+ badDebt: "protocol-absorbed",
72898
+ permissioned: false
72899
+ },
72900
+ counterparty: {
72901
+ kind: "cdp",
72902
+ solvency: "overcollateralized",
72903
+ address: typeof c.addresses?.treasury === "string" ? c.addresses.treasury : void 0
72904
+ },
72905
+ availability: {
72906
+ requires: ["token-approval"]
72907
+ }
72908
+ },
72909
+ constraints: {
72910
+ crossMargin: false,
72911
+ positionModel: "account",
72912
+ positionIdMeaning: "One position per address on the monolithic MonoCooler book \u2014 the account address is the position key."
72913
+ }
72914
+ };
72915
+ }
72916
+ };
72038
72917
  var dssAdapter = {
72039
72918
  id: "dss",
72040
72919
  matches: isDssType,
@@ -72667,6 +73546,7 @@ var TERM_ADAPTERS = [
72667
73546
  liquityAdapter,
72668
73547
  riverAdapter,
72669
73548
  inverseAdapter,
73549
+ coolerAdapter,
72670
73550
  dssAdapter,
72671
73551
  compoundV3Adapter,
72672
73552
  fluidAdapter,
@@ -73442,7 +74322,8 @@ var NON_4626_DEPOSIT_KINDS = /* @__PURE__ */ new Set([
73442
74322
  "yieldbasis",
73443
74323
  "wren",
73444
74324
  "hyperbeat",
73445
- "native-wnlp"
74325
+ "native-wnlp",
74326
+ "bitway"
73446
74327
  ]);
73447
74328
  function acceptsVaultZap(row, provider) {
73448
74329
  if (ZAP_EXCLUDED_PROVIDERS.has(provider)) return false;
@@ -73803,6 +74684,6 @@ function earnPositionTotals(items) {
73803
74684
  };
73804
74685
  }
73805
74686
 
73806
- 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, SPECTRA_NETWORKS, SPECTRA_RATE_MAX_PERCENT, SPECTRA_RATE_MIN_PERCENT, 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_PROVIDERS, VAULT_PROVIDER_PROFILE, VAULT_PROVIDER_TRAITS, 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, buildLendingPositionUid, buildLiquityUserCall, buildLoopResult, buildMorphoTypeCall, buildMorphoTypeUserCallWithLens, buildPortfolioTotals, buildSumerAccumulators, buildSummaries, buildTellerUserCall, buildTermMaxUserCall, buildTermSheet, buildTermSheetsForGroup, buildVaultEarnUid, buildVaultLookup, buildVaultTermSheet, calculateLeverage, calculateNetApr, calculateOverallNetApr, calculateWeightedAverage, classifyFreshness, classifyReliability, classifyVault, clearPendleMarketsCache, clearSpectraMarketsCache, collateralSymbolsByVenue, 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, dexResolverFor, disambiguateEarnNames, dssIlkBytes32, dssKeyParts, dssLenderKey, duration, earnDescription, earnLabel, earnMarketFromPool, earnMarketFromVault, earnMarketLabel, earnPositionFromLenderEntry, earnPositionFromVaultBalance, earnPositionTotals, earnRowSubtitle, earnUidFromMarketUid, earnVaultTerms, earnVenueKind, encodeBalanceFetcherCalldata, enrichTermSheet, enrichmentIndexFromRows, exactlyPairLtv, exactlyPenaltyRateToAprPercent, exactlyWadRateToPercent, feePhrase, feedKeyOf, feedStatKey, fetchDolomiteAccountNumbers, fetchDssMarkets, fetchEulerEarnVaults, fetchEulerEarnVaultsFromSubgraph, fetchEulerSubAccountIndexes, fetchExactlyMarkets, fetchFlashLiquidityForChain, fetchFluidDexState, 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, fetchSpectraApiMarkets, fetchSpectraPtMarkets, 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, getCachedFluidDexState, 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, hasSpectraMarkets, hasUpshiftVaults, hasYearnVaults, ilkToKeySegment, implausibleRatePercent, inverseKeyParts, inverseLenderKey, isBoundNeed, isFailedCall, isIlliquid, isLendingPosition, isLiveMarket as isLivePendleMarket, isLiveSpectraMarket, isSecondaryMarketOnly, isStablecoinSymbol, isVaultPosition, 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, parseCurveFee as parseSpectraCurveFee, parsePtRate as parseSpectraPtRate, parseTermMaxLtv, parseTokenBalanceResult, pct, assetKey as pendleAssetKey, pickPool as pickSpectraPool, positivePart2 as positivePart, predictInverseEscrow, prepareLenderUserDataRpcCalls, prepareMergedMulticallParams, prepareMergedRpcCalls, prepareMulticallInputs, prepareTokenBalanceRpcCalls, priceGlvVaults, priceGmMarkets, probeAaveFeedTimestamps, pruneFeedStats, rankFindings, ratePercent, readVaultSharePrices, rejectOutliers as rejectPriceOutliers, resolveAdapter, resolveDerivation, resolveEarnIdentity, resolveModeConfig, resolveStCeloDepositGroup, resolveVaultProfileId, resupplyKeyParts, resupplyLenderKey, resupplyMarketLabel, riverKeyParts, riverLenderKey, sanePercent as saneSpectraPercent, savingsAddresses, savingsBalanceKind, secondaryMarketVault, selectAssetGroupPrices, shortDate, spectraAddress, spectraNetwork, spectraPoolsUrl, splitChainScopedAddress as splitPendleChainScopedAddress, stampCapabilities, stampEarnSubtitles, stampVaultClassification, stampVaultTermSheets, stripLeadingBrand, supplyDescription, supplyFindings, supplyHeadline, swapRoutedProvidersArePriceConsistent, 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, toVaultTermInput, trancheFromCounterparty, tryParseEarnUid, unflattenLenderData, updateFeedStats, usdValue, usddIlkBytes32, usddKeyParts, usddLenderKey, validateTermSheet, validateTermSheets, validateUserData, vaultSharesToAssets, vaultTermInputFromEarnMarket, vaultTermInputFromSourceRow, vaultTraits, vaultVenue, venueBrand, venueBrandKey, withMaturityLabel, withTrancheLabel };
74687
+ 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, SPECTRA_NETWORKS, SPECTRA_RATE_MAX_PERCENT, SPECTRA_RATE_MIN_PERCENT, 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_PROVIDERS, VAULT_PROVIDER_PROFILE, VAULT_PROVIDER_TRAITS, 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, buildLendingPositionUid, buildLiquityUserCall, buildLoopResult, buildMorphoTypeCall, buildMorphoTypeUserCallWithLens, buildPortfolioTotals, buildSumerAccumulators, buildSummaries, buildTellerUserCall, buildTermMaxUserCall, buildTermSheet, buildTermSheetsForGroup, buildVaultEarnUid, buildVaultLookup, buildVaultTermSheet, calculateLeverage, calculateNetApr, calculateOverallNetApr, calculateWeightedAverage, classifyFreshness, classifyReliability, classifyVault, clearPendleMarketsCache, clearSpectraMarketsCache, collateralSymbolsByVenue, 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, convertCoolerMarketsToResponse, 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, dexResolverFor, disambiguateEarnNames, dssIlkBytes32, dssKeyParts, dssLenderKey, duration, earnDescription, earnLabel, earnMarketFromPool, earnMarketFromVault, earnMarketLabel, earnPositionFromLenderEntry, earnPositionFromVaultBalance, earnPositionTotals, earnRowSubtitle, earnUidFromMarketUid, earnVaultTerms, earnVenueKind, encodeBalanceFetcherCalldata, enrichTermSheet, enrichmentIndexFromRows, exactlyPairLtv, exactlyPenaltyRateToAprPercent, exactlyWadRateToPercent, feePhrase, feedKeyOf, feedStatKey, fetchCoolerMarkets, fetchDolomiteAccountNumbers, fetchDssMarkets, fetchEulerEarnVaults, fetchEulerEarnVaultsFromSubgraph, fetchEulerSubAccountIndexes, fetchExactlyMarkets, fetchFlashLiquidityForChain, fetchFluidDexState, 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, fetchSpectraApiMarkets, fetchSpectraPtMarkets, 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, getCachedFluidDexState, 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, hasSpectraMarkets, hasUpshiftVaults, hasYearnVaults, ilkToKeySegment, implausibleRatePercent, inverseKeyParts, inverseLenderKey, isBoundNeed, isFailedCall, isIlliquid, isLendingPosition, isLiveMarket as isLivePendleMarket, isLiveSpectraMarket, isSecondaryMarketOnly, isStablecoinSymbol, isVaultPosition, 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, parseCurveFee as parseSpectraCurveFee, parsePtRate as parseSpectraPtRate, parseTermMaxLtv, parseTokenBalanceResult, pct, assetKey as pendleAssetKey, pickPool as pickSpectraPool, positivePart2 as positivePart, predictInverseEscrow, prepareLenderUserDataRpcCalls, prepareMergedMulticallParams, prepareMergedRpcCalls, prepareMulticallInputs, prepareTokenBalanceRpcCalls, priceGlvVaults, priceGmMarkets, probeAaveFeedTimestamps, pruneFeedStats, rankFindings, ratePercent, readVaultSharePrices, rejectOutliers as rejectPriceOutliers, resolveAdapter, resolveDerivation, resolveEarnIdentity, resolveModeConfig, resolveStCeloDepositGroup, resolveVaultProfileId, resupplyKeyParts, resupplyLenderKey, resupplyMarketLabel, riverKeyParts, riverLenderKey, sanePercent as saneSpectraPercent, savingsAddresses, savingsBalanceKind, secondaryMarketVault, selectAssetGroupPrices, shortDate, spectraAddress, spectraNetwork, spectraPoolsUrl, splitChainScopedAddress as splitPendleChainScopedAddress, stampCapabilities, stampEarnSubtitles, stampVaultClassification, stampVaultTermSheets, stripLeadingBrand, supplyDescription, supplyFindings, supplyHeadline, swapRoutedProvidersArePriceConsistent, 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, toVaultTermInput, trancheFromCounterparty, tryParseEarnUid, unflattenLenderData, updateFeedStats, usdValue, usddIlkBytes32, usddKeyParts, usddLenderKey, validateTermSheet, validateTermSheets, validateUserData, vaultSharesToAssets, vaultTermInputFromEarnMarket, vaultTermInputFromSourceRow, vaultTraits, vaultVenue, venueBrand, venueBrandKey, withMaturityLabel, withTrancheLabel };
73807
74688
  //# sourceMappingURL=index.js.map
73808
74689
  //# sourceMappingURL=index.js.map