@1delta/margin-fetcher 5.0.27 → 5.0.28

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
@@ -9,7 +9,7 @@ import { Chain } from '@1delta/chain-registry';
9
9
  import { multicallRetryUniversal, getEvmClient, getEvmChain, getEvmClientUniversal } from '@1delta/providers';
10
10
  import { LiquityTroveManagerAbi, LiquityActivePoolAbi, LiquityStabilityPoolAbi, LiquityPriceFeedAbi, LiquitySortedTrovesAbi, RiverTroveManagerAbi, RiverStabilityPoolAbi, TellerMarketRegistryAbi, TellerV2Abi, InverseMarketAbi, InverseOracleAbi, InverseDbrAbi, Erc20Abi, LlamaLendControllerAbi, LlamaLendControllerV1Abi, LlamaLendControllerV2Abi, LlamaLendVaultAbi, LlamaLendAmmAbi, MetaMorphoAbi, ExactlyPreviewerAbi, ExactlyAuditorAbi, LenderCommitmentGroupAbi, ResupplyRegistryAbi, ResupplyPairAbi, ResupplyUtilitiesAbi, ResupplyRewardHandlerAbi, ResupplyPairEmissionsAbi, ConvexPoolUtilAbi, FraxlendPairAbi, FrankencoinPositionAbi, FluidLendingResolverAbi, FluidVaultResolverAbi, FluidLiquidityResolverAbi, MoolahVaultAbi, UsddVatAbi, UsddJugAbi, UsddSpotAbi, MorphoLensAbi, AaveV4SpokeAbi, AaveV4OracleAbi, AaveV4HubAbi, DolomiteMarginAbi, GearboxMarketCompressorV310Abi, MorphoBlueAbi, MidnightAbi, TermRepoTokenAbi, TermRepoServicerAbi, TermRepoCollateralManagerAbi, LiquityTroveNFTAbi, LiquityCollSurplusPoolAbi, TellerCollateralManagerAbi, TermMaxViewerAbi, InverseEscrowAbi, CurvanceMarketManagerAbi, CurvanceCTokenAbi, GearboxCreditAccountCompressorV310Abi, UsddCdpManagerAbi, UsddProxyRegistryAbi, CurvanceProtocolReaderAbi, CurvanceCentralRegistryAbi, TermPriceConsumerAbi, CurvanceOracleManagerAbi, TermMaxOracleAggregatorV2Abi } from '@1delta/abis';
11
11
  export { MorphoLensAbi } from '@1delta/abis';
12
- import { prepareDebitDataMulticall, prepareLenderDebitMulticall, parseDebitDataResult, parseLenderDebitResult, getPermit2ContractAddress, getCompoundV3CometAddress as getCompoundV3CometAddress$1, getMorphoAddress, getAaveCollateralTokenAddress, getSiloHalfForUnderlying, bandLtvCurve, InitMarginAddresses, getLstAcceptedInputs } from '@1delta/calldata-sdk';
12
+ import { prepareDebitDataMulticall, prepareLenderDebitMulticall, parseDebitDataResult, parseLenderDebitResult, getPermit2ContractAddress, getLstAcceptedInputs, getCompoundV3CometAddress as getCompoundV3CometAddress$1, getMorphoAddress, getAaveCollateralTokenAddress, getSiloHalfForUnderlying, bandLtvCurve, InitMarginAddresses } from '@1delta/calldata-sdk';
13
13
  import { proxyNativeFetch } from '@1delta/proxy-fetch';
14
14
  import { BALANCER_V2_FORKS, BALANCER_V3_FORKS, UNISWAP_V4_FORKS, isFlashLoanSourceExcluded, FLASH_LOAN_IDS } from '@1delta/dex-registry';
15
15
 
@@ -64138,8 +64138,9 @@ function marketTags(sheet) {
64138
64138
  if (g) {
64139
64139
  if (g.mutability === "immutable") push(out, "immutable");
64140
64140
  if (g.mutability === "governed") {
64141
+ const contractEnforced = (g.timelockSecs ?? 0) > 0 && g.timelockSource === "on-chain";
64141
64142
  const isTimelockRoot = g.controllerKind === "TIMELOCK";
64142
- if (!isTimelockRoot) push(out, "no-timelock");
64143
+ if (contractEnforced) ; else if (!isTimelockRoot) push(out, "no-timelock");
64143
64144
  else if (!g.timelockSecs && !g.timelockUnknown) push(out, "no-timelock");
64144
64145
  if (g.controllerKind === "EOA") push(out, "eoa-controlled");
64145
64146
  }
@@ -64915,7 +64916,8 @@ var TERM_PROFILES = [
64915
64916
  "There is NO deposit or redemption before maturity \u2014 you enter and exit by TRADING on an AMM, so both legs move against you with size and need a slippage tolerance.",
64916
64917
  "The quoted liquidity is pool DEPTH, not idle cash waiting to be withdrawn.",
64917
64918
  "The rate is fixed at purchase. Selling early realizes whatever the market pays that block, which can be above or below your entry.",
64918
- "Buying gives up the underlying\u2019s own floating yield for the term \u2014 that is the trade, not an extra return on top."
64919
+ "Buying gives up the underlying\u2019s own floating yield for the term \u2014 that is the trade, not an extra return on top.",
64920
+ "Redemption is 1:1 in the underlying, so the fixed rate itself carries no credit risk \u2014 but you are paid in that underlying, and whatever risk it carries (a depeg, a failure of the protocol behind it) passes straight through to you."
64919
64921
  ]
64920
64922
  }
64921
64923
  }),
@@ -65561,6 +65563,11 @@ function buildTermSheet(input, opts = {}) {
65561
65563
  var LENDING_VAULT = {
65562
65564
  rateKind: "variable-curve",
65563
65565
  rateSource: "utilization-curve",
65566
+ // Structural, not curated: these vaults can only reach markets that require
65567
+ // collateral. A shortfall is possible (bad debt socializes to depositors, and
65568
+ // `principal.risks` carries that), but the loan book itself is collateralized
65569
+ // by construction — which is a different statement from Maple's or Native's.
65570
+ solvency: "overcollateralized",
65564
65571
  defaultExitMode: "instant-capped",
65565
65572
  priceRisk: "none",
65566
65573
  counterpartyKind: "vault-strategy",
@@ -65600,13 +65607,19 @@ var VAULT_PROVIDER_TRAITS = {
65600
65607
  },
65601
65608
  // The only provider that publishes a real debt accumulator on the row
65602
65609
  // (`totalBorrowed` / `expectedLiquidity`), so utilization is exact here.
65610
+ // Lends to leveraged credit accounts, which post collateral and carry a
65611
+ // health factor — collateralized, like the rest of this class.
65603
65612
  gearbox: { ...LENDING_VAULT, reportsGovernance: false },
65604
65613
  // A thin 4626 wrapper over an Aave v3 supply position: the rate IS the
65605
65614
  // reserve's supply curve. Publishes no liquidity field of its own.
65606
65615
  "aave-earn": {
65607
65616
  ...LENDING_VAULT,
65608
65617
  counterpartyKind: "pool",
65609
- reportsGovernance: false
65618
+ reportsGovernance: false,
65619
+ // The ONLY provider reporting `fee` as a fraction. Its own type documents
65620
+ // it (`0.1` = 10 %) while morpho / silo / euler-earn / termmax / yearn all
65621
+ // document percent.
65622
+ feeIsFraction: true
65610
65623
  },
65611
65624
  // The VAULT is perpetual and its rate floats with what the curator earns
65612
65625
  // rolling FT positions — it is NOT itself a fixed-term instrument, which
@@ -65631,6 +65644,10 @@ var VAULT_PROVIDER_TRAITS = {
65631
65644
  },
65632
65645
  lst: {
65633
65646
  rateKind: "variable-managed",
65647
+ // A pro-rata claim on real staked capital — fully backed, no borrower.
65648
+ // The residual risk is slashing and the exit queue, both of which the
65649
+ // exit terms and the profile state; neither is a solvency question.
65650
+ solvency: "overcollateralized",
65634
65651
  // Staking rewards are neither a curve nor a governance dial — the rate is
65635
65652
  // reconstructed from the share/asset ratio moving.
65636
65653
  rateSource: "derived",
@@ -65647,6 +65664,15 @@ var VAULT_PROVIDER_TRAITS = {
65647
65664
  // the TermMax FT promise reached by an AMM discount instead of a quote.
65648
65665
  pendle: {
65649
65666
  rateKind: "fixed-term",
65667
+ // A PT redeems 1:1 for the accounting asset at maturity — there is no
65668
+ // borrower, no leverage and no tranching on the Pendle side, so the
65669
+ // fixed-rate promise itself carries no credit risk.
65670
+ //
65671
+ // What it does NOT mean: the SY it redeems into is only as good as the
65672
+ // protocol behind it, and that risk passes straight through to the PT
65673
+ // holder. That is a property of the underlying, stated in the profile's
65674
+ // implications, not a defect in this classification.
65675
+ solvency: "overcollateralized",
65650
65676
  rateSource: "derived",
65651
65677
  rateWindow: { kind: "forward" },
65652
65678
  defaultExitMode: "market-sale",
@@ -65757,12 +65783,15 @@ function windowFromAprWindow(aprWindow) {
65757
65783
  var isNum2 = (v) => typeof v === "number" && Number.isFinite(v);
65758
65784
  var clamp012 = (v) => Math.max(0, Math.min(1, v));
65759
65785
  function buildRate2(input, t, maturity) {
65760
- const base = input.supplyRate ?? 0;
65786
+ const hasLegs = input.supplyRate != null || input.rewardsRate != null;
65787
+ const base = hasLegs ? input.supplyRate ?? 0 : input.totalRate ?? 0;
65761
65788
  const rewards = input.rewardsRate ?? 0;
65762
- const total = input.totalRate ?? base + rewards;
65789
+ const total = base + rewards;
65763
65790
  const isNav = input.navOracle != null || input.solvency === "nav-attested";
65764
65791
  const termIsBacked = maturity.kind === "fixed-date";
65765
- const kind = isNav ? "nav-accrual" : t.rateKind === "fixed-term" && !termIsBacked ? "variable-managed" : t.rateKind;
65792
+ const window = resolveRateWindow(input, t);
65793
+ const measured = window?.kind === "trailing" || input.yieldProfile === "volatile";
65794
+ const kind = isNav ? "nav-accrual" : measured && t.rateKind !== "fixed-term" ? "realized" : t.rateKind === "fixed-term" && !termIsBacked ? "variable-managed" : t.rateKind;
65766
65795
  const source = isNav ? "oracle" : t.rateSource;
65767
65796
  return {
65768
65797
  kind,
@@ -65782,7 +65811,7 @@ function buildRate2(input, t, maturity) {
65782
65811
  source,
65783
65812
  // A PT's discount is fixed at purchase; every other vault floats.
65784
65813
  isLocked: kind === "fixed-term" && termIsBacked,
65785
- window: resolveRateWindow(input, t)
65814
+ window
65786
65815
  };
65787
65816
  }
65788
65817
  function resolveRateWindow(input, t) {
@@ -65790,7 +65819,9 @@ function resolveRateWindow(input, t) {
65790
65819
  if (input.isForwardApr === false) return { kind: "trailing" };
65791
65820
  const fromAprWindow = windowFromAprWindow(input.aprWindow);
65792
65821
  if (fromAprWindow) return fromAprWindow;
65793
- return t.rateWindow;
65822
+ if (t.rateWindow) return t.rateWindow;
65823
+ if (input.yieldProfile === "volatile") return { kind: "trailing" };
65824
+ return void 0;
65794
65825
  }
65795
65826
  function buildMaturity2(input, now) {
65796
65827
  const expiry = input.expiry;
@@ -65814,10 +65845,12 @@ function buildFees2(input, t) {
65814
65845
  id: "performance",
65815
65846
  label: "Performance fee",
65816
65847
  when: "performance",
65817
- // Every provider that reports `fee` reports it as a PERCENT of yield.
65818
65848
  unit: "percent",
65819
65849
  basis: "yield",
65820
- value: input.fee,
65850
+ // Normalized to PERCENT here, because the providers disagree: `aave-earn`
65851
+ // publishes a fraction and the other five publish percent, so a uniform
65852
+ // read renders a 10 % curator cut as "0.1 %".
65853
+ value: t.feeIsFraction ? input.fee * 100 : input.fee,
65821
65854
  payee: "curator",
65822
65855
  mutable: true,
65823
65856
  description: "Taken from the yield the vault earns, not from your principal. The published rate is already net of it."
@@ -65990,11 +66023,11 @@ function buildCounterparty(input, t) {
65990
66023
  return {
65991
66024
  kind: t.counterpartyKind,
65992
66025
  address: input.address,
65993
- // Absent curation means we do not know, and the honest default is the
65994
- // structurally true one for an on-chain lending vault. `coverage` records
65995
- // which of the two it was, so a consumer can tell an asserted
65996
- // `overcollateralized` from an assumed one.
65997
- solvency: input.solvency ?? "overcollateralized",
66026
+ // Three tiers, most specific first: a CURATED per-vault classification, then
66027
+ // the provider's STRUCTURAL answer where one exists, then an assumption.
66028
+ // `coverage` records which tier answered, so a consumer can always tell an
66029
+ // asserted `overcollateralized` from an assumed one.
66030
+ solvency: input.solvency ?? t.solvency ?? "overcollateralized",
65998
66031
  socializedLoss: input.solvency === "tranched-junior" ? true : void 0,
65999
66032
  curator: input.curatorName ?? input.curator
66000
66033
  };
@@ -66032,7 +66065,10 @@ function buildGovernance(input, t) {
66032
66065
  // `0` is REAL on the providers that run no timelock pattern (Lista earn) —
66033
66066
  // it means no notice period, which is exactly what a holder needs told.
66034
66067
  timelockSecs: input.timelock,
66035
- timelockSource: "metadata",
66068
+ // Read off the VAULT, not inferred from a governance screen — and the vault
66069
+ // enforces the queue itself, which is why this delay stands even though the
66070
+ // controller above is an unscreened curator address.
66071
+ timelockSource: "on-chain",
66036
66072
  powers: ["set-caps", "change-fees", "pause-withdrawals"],
66037
66073
  roles: hasRole ? roles : void 0
66038
66074
  };
@@ -66092,6 +66128,7 @@ function buildCoverage2(sheet, input, t) {
66092
66128
  else if (!t.reportsPerformanceFee)
66093
66129
  pending.fees = "provider-publishes-no-fee-schedule";
66094
66130
  if (input.solvency) present.push("counterparty");
66131
+ else if (t.solvency) present.push("counterparty");
66095
66132
  else pending.counterparty = "solvency-not-curated-default-assumed";
66096
66133
  if (sheet.supply?.exit.liquidity) present.push("exitLiquidity");
66097
66134
  else pending.exitLiquidity = "provider-does-not-publish-liquidity";
@@ -66105,7 +66142,7 @@ function buildVaultTermSheet(input, opts = {}) {
66105
66142
  const now = opts.now ?? Math.floor(Date.now() / 1e3);
66106
66143
  const t = vaultTraits(input.provider) ?? FALLBACK_TRAITS;
66107
66144
  const maturity = buildMaturity2(input, now);
66108
- const fees = buildFees2(input);
66145
+ const fees = buildFees2(input, t);
66109
66146
  const supply = {
66110
66147
  // A vault share is never collateral IN the vault — it earns, full stop.
66111
66148
  // (It may be collateral somewhere else; that is the other market's sheet.)
@@ -66245,8 +66282,470 @@ function splitUid(uid) {
66245
66282
  return { venue, chainId, ref };
66246
66283
  }
66247
66284
 
66285
+ // src/earn/labels.ts
66286
+ var VENUE_KIND_LABELS = {
66287
+ lending: "Lending markets",
66288
+ vault: "Vaults"
66289
+ };
66290
+ var VENUE_KIND_DESCRIPTIONS = {
66291
+ lending: "Supply into a lending market. Same-block exit, bounded by liquidity.",
66292
+ vault: "Deposit into a yield vault. Exit terms vary per vault."
66293
+ };
66294
+ var EXIT_MODE_LABELS = {
66295
+ instant: "Instant",
66296
+ "instant-capped": "Instant (capped)",
66297
+ "instant-or-queued": "Instant or queue",
66298
+ "fee-or-queued": "Fee or queue",
66299
+ "fixed-cooldown": "Cooldown",
66300
+ queued: "Queued",
66301
+ "request-based": "Request",
66302
+ "market-sale": "Market sale",
66303
+ "at-maturity": "At maturity",
66304
+ "off-chain": "Off-chain",
66305
+ "dex-only": "DEX only"
66306
+ };
66307
+ var EXIT_MODE_DESCRIPTIONS = {
66308
+ instant: "Withdraw any time.",
66309
+ "instant-capped": "Withdraw up to the available liquidity.",
66310
+ "instant-or-queued": "Withdraw instantly, or queue for the rest.",
66311
+ "fee-or-queued": "Instant exit for a fee, or queue for free.",
66312
+ "fixed-cooldown": "Request, wait out a cooldown, then claim.",
66313
+ queued: "Withdrawals are queued.",
66314
+ "request-based": "Withdrawals need a request and a later claim.",
66315
+ "market-sale": "Exit by selling the position on a market.",
66316
+ "at-maturity": "Locked until maturity.",
66317
+ "off-chain": "Exit is settled off-chain.",
66318
+ "dex-only": "Exit only by selling on a DEX."
66319
+ };
66320
+ var ACTION_LABELS = {
66321
+ deposit: "Deposit",
66322
+ withdraw: "Withdraw",
66323
+ "request-withdraw": "Request withdrawal",
66324
+ claim: "Claim",
66325
+ cancel: "Cancel request"
66326
+ };
66327
+ var GATING_LABELS = {
66328
+ "allowlist-contract": "Permissioned",
66329
+ kyc: "KYC required",
66330
+ "cap-full": "Cap full",
66331
+ paused: "Paused",
66332
+ frozen: "Frozen",
66333
+ "collateral-only": "No yield",
66334
+ matured: "Matured"
66335
+ };
66336
+ var RATE_KIND_LABELS = {
66337
+ "variable-curve": "Variable (utilization)",
66338
+ "variable-managed": "Variable (managed)",
66339
+ "user-set": "Borrower-set",
66340
+ "fixed-term": "Fixed term",
66341
+ "fixed-open": "Fixed",
66342
+ "zero-interest": "Interest-free",
66343
+ prepaid: "Prepaid",
66344
+ "nav-accrual": "NAV accrual",
66345
+ none: "No rate"
66346
+ };
66347
+ var RATE_SOURCE_LABELS = {
66348
+ chain: "On-chain",
66349
+ api: "Protocol API",
66350
+ oracle: "Oracle",
66351
+ realized: "Realized"
66352
+ };
66353
+ var VENUE_BRANDS = {
66354
+ MORPHO_BLUE: "Morpho Blue",
66355
+ MORPHO_MIDNIGHT: "Morpho Midnight",
66356
+ FLUID: "Fluid",
66357
+ GEARBOX_V3: "Gearbox V3",
66358
+ AAVE_V4: "Aave V4",
66359
+ AAVE_V3: "Aave V3",
66360
+ AAVE_V2: "Aave V2",
66361
+ SKY: "Sky",
66362
+ USDD: "USDD",
66363
+ LIQUITY_V2: "Liquity V2",
66364
+ SILO_V2: "Silo V2",
66365
+ SILO_V3: "Silo V3",
66366
+ EXACTLY: "Exactly",
66367
+ TELLER: "Teller",
66368
+ TERM_FINANCE: "Term Finance",
66369
+ TERMMAX: "TermMax",
66370
+ LLAMALEND: "LlamaLend",
66371
+ CURVANCE: "Curvance",
66372
+ INVERSE: "Inverse",
66373
+ FRANKENCOIN: "Frankencoin",
66374
+ RIVER: "River",
66375
+ RESUPPLY: "Resupply",
66376
+ TANGENT: "Tangent",
66377
+ DOLOMITE: "Dolomite",
66378
+ LISTA_DAO: "Lista",
66379
+ FLUX_FINANCE: "Flux",
66380
+ COMPOUND_V2: "Compound V2",
66381
+ COMPOUND_V3: "Compound V3",
66382
+ EULER_V2: "Euler V2",
66383
+ INIT: "Init"
66384
+ };
66385
+ var VAULT_PROVIDER_BRANDS = {
66386
+ fluid: "Fluid",
66387
+ gearbox: "Gearbox",
66388
+ morpho: "Morpho",
66389
+ lista: "Lista",
66390
+ silo: "Silo",
66391
+ "euler-earn": "Euler",
66392
+ termmax: "TermMax",
66393
+ lst: "Liquid staking",
66394
+ savings: "Savings",
66395
+ lagoon: "Lagoon",
66396
+ "aave-earn": "Aave",
66397
+ upshift: "Upshift",
66398
+ yearn: "Yearn",
66399
+ hypercore: "HyperLiquid",
66400
+ gmx: "GMX",
66401
+ pendle: "Pendle"
66402
+ };
66403
+ function isInstanceSegment(seg) {
66404
+ if (/^\d+$/.test(seg)) return true;
66405
+ if (/^0X[0-9A-F]+$/i.test(seg)) return true;
66406
+ return seg.length >= 8 && /^[0-9A-F]+$/i.test(seg);
66407
+ }
66408
+ function venueBrand(venue) {
66409
+ if (venue.startsWith("vault.")) {
66410
+ const provider = venue.slice("vault.".length);
66411
+ return VAULT_PROVIDER_BRANDS[provider] ?? provider;
66412
+ }
66413
+ const segments = venue.split("_");
66414
+ const cut = segments.findIndex(isInstanceSegment);
66415
+ const family = (cut > 0 ? segments.slice(0, cut) : segments).join("_");
66416
+ if (VENUE_BRANDS[family]) return VENUE_BRANDS[family];
66417
+ let best;
66418
+ for (const key3 of Object.keys(VENUE_BRANDS)) {
66419
+ if (family.startsWith(key3) && (!best || key3.length > best.length))
66420
+ best = key3;
66421
+ }
66422
+ return best ? VENUE_BRANDS[best] : family;
66423
+ }
66424
+ var EARN_LABELS = {
66425
+ venueKind: VENUE_KIND_LABELS,
66426
+ exitMode: EXIT_MODE_LABELS,
66427
+ action: ACTION_LABELS,
66428
+ gating: GATING_LABELS,
66429
+ rateKind: RATE_KIND_LABELS,
66430
+ rateSource: RATE_SOURCE_LABELS
66431
+ };
66432
+ var EARN_DESCRIPTIONS = {
66433
+ venueKind: VENUE_KIND_DESCRIPTIONS,
66434
+ exitMode: EXIT_MODE_DESCRIPTIONS
66435
+ };
66436
+ function earnLabel(dimension, key3) {
66437
+ return EARN_LABELS[dimension][key3] ?? key3;
66438
+ }
66439
+ function earnDescription(dimension, key3) {
66440
+ return EARN_DESCRIPTIONS[dimension][key3];
66441
+ }
66442
+ function earnMarketLabel(input) {
66443
+ const asset = input.assetSymbol?.trim();
66444
+ if (!asset) return input.fallbackName ?? "";
66445
+ const collaterals = (input.collateralSymbols ?? []).map((c) => c?.trim()).filter((c) => !!c);
66446
+ const distinct = [...new Set(collaterals)];
66447
+ if (distinct.length === 1) return `${asset} \xB7 vs ${distinct[0]}`;
66448
+ return asset;
66449
+ }
66450
+ var SAME_BLOCK_EXIT_MODES = /* @__PURE__ */ new Set([
66451
+ "instant",
66452
+ "instant-capped"
66453
+ ]);
66454
+ function isIlliquid(input) {
66455
+ if (!input.exitMode || !SAME_BLOCK_EXIT_MODES.has(input.exitMode))
66456
+ return false;
66457
+ if (!input.tvlUsd || input.tvlUsd <= 0) return false;
66458
+ if (input.liquidityUsd === void 0) return false;
66459
+ return input.liquidityUsd <= 0;
66460
+ }
66461
+
66462
+ // src/earn/normalize.ts
66463
+ function num12(v) {
66464
+ if (v == null || v === "") return void 0;
66465
+ const n = typeof v === "number" ? v : Number(v);
66466
+ return Number.isFinite(n) ? n : void 0;
66467
+ }
66468
+ function str5(v) {
66469
+ if (typeof v === "string") return v.length > 0 ? v : void 0;
66470
+ if (typeof v === "number" && Number.isFinite(v)) return String(v);
66471
+ return void 0;
66472
+ }
66473
+ function addr2(v) {
66474
+ return str5(v)?.toLowerCase();
66475
+ }
66476
+ function yieldProfile(v) {
66477
+ return v === "yield-bearing" || v === "volatile" ? v : void 0;
66478
+ }
66479
+ function denomination(v) {
66480
+ return v === "stable" || v === "volatile" ? v : void 0;
66481
+ }
66482
+ function usdValue(formatted, priceUsd) {
66483
+ if (formatted === void 0 || priceUsd === void 0) return void 0;
66484
+ const v = formatted * priceUsd;
66485
+ return Number.isFinite(v) ? v : void 0;
66486
+ }
66487
+ function formatRaw(raw, decimals) {
66488
+ if (raw == null || raw === "") return void 0;
66489
+ let value;
66490
+ try {
66491
+ value = BigInt(raw);
66492
+ } catch {
66493
+ return void 0;
66494
+ }
66495
+ if (decimals <= 0) return Number(value);
66496
+ const base = 10n ** BigInt(decimals);
66497
+ const whole = value / base;
66498
+ const frac = value % base;
66499
+ const n = Number(whole) + Number(frac) / Number(base);
66500
+ return Number.isFinite(n) ? n : void 0;
66501
+ }
66502
+
66503
+ // src/earn/fromVault.ts
66504
+ var FRACTION_RATE_PROVIDERS = /* @__PURE__ */ new Set();
66505
+ var SDK_FRACTION_RATE_PROVIDERS = /* @__PURE__ */ new Set([
66506
+ "hypercore",
66507
+ "gmx"
66508
+ ]);
66509
+ var RATE_SOURCE = {
66510
+ morpho: "api",
66511
+ silo: "api",
66512
+ lagoon: "api",
66513
+ hypercore: "api",
66514
+ gmx: "api",
66515
+ upshift: "api",
66516
+ yearn: "api",
66517
+ "aave-earn": "api",
66518
+ pendle: "api",
66519
+ lista: "chain",
66520
+ fluid: "chain",
66521
+ gearbox: "chain",
66522
+ "euler-earn": "chain",
66523
+ termmax: "chain",
66524
+ lst: "chain",
66525
+ savings: "chain"
66526
+ };
66527
+ var RATE_KIND = {
66528
+ morpho: "variable-curve",
66529
+ lista: "variable-curve",
66530
+ silo: "variable-curve",
66531
+ "euler-earn": "variable-curve",
66532
+ fluid: "variable-curve",
66533
+ gearbox: "variable-curve",
66534
+ "aave-earn": "variable-curve",
66535
+ // The TermMax VAULT is a perpetual curated 4626 whose curator rolls
66536
+ // fixed-term FT positions — the vault itself has no maturity and no locked
66537
+ // rate. `fixed-term` here claimed both, producing a "fixed" rate with no date
66538
+ // attached to it. The LENDER `TERMMAX_*` is fixed-term; this is not.
66539
+ termmax: "variable-managed",
66540
+ // A PT's implied APY is locked in at purchase and realized only by holding
66541
+ // to maturity — the same promise TermMax's FT makes, reached by a different
66542
+ // mechanism (an AMM discount rather than a quoted curve).
66543
+ pendle: "fixed-term",
66544
+ savings: "variable-managed",
66545
+ lst: "variable-managed",
66546
+ lagoon: "variable-managed",
66547
+ upshift: "variable-managed",
66548
+ yearn: "variable-managed",
66549
+ hypercore: "realized",
66550
+ gmx: "realized"
66551
+ };
66552
+ function resolveExitMode2(provider, meta, tvl, liq) {
66553
+ const declared = str5(meta.withdrawalMode);
66554
+ if (declared) return declared;
66555
+ const fallback = vaultTraits(provider)?.defaultExitMode ?? "instant";
66556
+ if (fallback !== "instant-capped") return fallback;
66557
+ const total = num12(tvl?.totalAssetsFormatted) ?? num12(tvl?.totalAssetsUsd);
66558
+ const available = num12(liq?.liquidityFormatted) ?? num12(liq?.liquidityUsd);
66559
+ if (total === void 0 || available === void 0) return "instant-capped";
66560
+ if (total <= 0) return "instant";
66561
+ return available >= total ? "instant" : "instant-capped";
66562
+ }
66563
+ function earnMarketFromVault(row, chainId, opts = {}) {
66564
+ const provider = str5(row.provider);
66565
+ const address = str5(row.vaultAddress)?.toLowerCase();
66566
+ const underlying = str5(row.underlying)?.toLowerCase();
66567
+ if (!provider || !address || !underlying) return void 0;
66568
+ const meta = row.providerMeta ?? {};
66569
+ const info = row.vaultInfo ?? {};
66570
+ const rates = row.rates ?? {};
66571
+ const tvl = row.tvl ?? {};
66572
+ const liq = row.liquidity ?? {};
66573
+ const shareDecimals = num12(row.decimals) ?? 18;
66574
+ const assetDecimals = num12(row.assetDecimals) ?? num12(row.underlyingInfo?.asset?.decimals) ?? shareDecimals;
66575
+ const toPercent2 = (v) => ratePercent(v, provider, opts.fractionRateProviders);
66576
+ const rewards = toPercent2(rates.rewardsRate);
66577
+ const deposit = toPercent2(rates.depositRate);
66578
+ const base = toPercent2(rates.supplyRate) ?? (deposit !== void 0 && rewards !== void 0 ? deposit - rewards : deposit);
66579
+ const total = toPercent2(rates.totalRate) ?? deposit ?? sum(base, rewards) ?? 0;
66580
+ const rate = {
66581
+ total,
66582
+ base,
66583
+ rewards,
66584
+ // A vault has no separate intrinsic leg — whatever it pays IS the venue's
66585
+ // own yield. Leaving this undefined rendered an empty "Venue APR" on every
66586
+ // vault row, which read as "this vault pays nothing".
66587
+ marketOwn: total,
66588
+ // ...and for the same reason it can never be pass-through.
66589
+ passthrough: false,
66590
+ kind: resolveRateKind(provider, meta),
66591
+ source: RATE_SOURCE[provider] ?? "api",
66592
+ // The curator's cut. Dropped entirely until now, which left the earn row
66593
+ // unable to say why its net rate sits below the gross one — and left the
66594
+ // term sheet built from this row with no fee schedule at all.
66595
+ fee: toPercent2(rates.fee)
66596
+ };
66597
+ const maturity = resolveMaturity(meta);
66598
+ const availability = resolveAvailability(meta, maturity);
66599
+ const exitMode = resolveExitMode2(provider, meta, tvl, liq);
66600
+ const market = {
66601
+ earnUid: buildVaultEarnUid(provider, chainId, address),
66602
+ chainId,
66603
+ venue: vaultVenue(provider),
66604
+ venueKind: "vault",
66605
+ // Curator first (it names the actual operator), then the provider brand.
66606
+ brand: str5(row.curatorName) ?? venueBrand(vaultVenue(provider)),
66607
+ name: str5(info.name) ?? str5(row.displayName) ?? str5(row.name),
66608
+ ref: address,
66609
+ logoURI: str5(info.logoURI) ?? str5(row.underlyingInfo?.asset?.logoURI),
66610
+ asset: {
66611
+ address: underlying,
66612
+ symbol: str5(row.underlyingInfo?.asset?.symbol) ?? "",
66613
+ decimals: assetDecimals,
66614
+ assetGroup: str5(info.assetGroup),
66615
+ priceUsd: num12(row.underlyingInfo?.prices?.priceUsd)
66616
+ },
66617
+ // The vault IS a share token by construction; carry it so a withdraw in
66618
+ // share units can be built without a second lookup.
66619
+ shareToken: {
66620
+ address,
66621
+ symbol: str5(info.symbol) ?? str5(row.symbol) ?? "",
66622
+ decimals: shareDecimals
66623
+ },
66624
+ rate,
66625
+ // The vault origin reports RAW base units + a pre-formatted convenience
66626
+ // field. Carry both; fall back to formatting the raw amount ourselves so
66627
+ // `formatted` — the field consumers sort on — is never silently absent.
66628
+ tvl: amount(
66629
+ tvl.totalAssets,
66630
+ tvl.totalAssetsFormatted,
66631
+ tvl.totalAssetsUsd,
66632
+ assetDecimals
66633
+ ),
66634
+ liquidity: liq.liquidity != null || liq.liquidityUsd != null ? amount(
66635
+ liq.liquidity,
66636
+ liq.liquidityFormatted,
66637
+ liq.liquidityUsd,
66638
+ assetDecimals
66639
+ ) : void 0,
66640
+ depositCapacity: str5(meta.depositCapacity) ?? str5(meta.maxDeposit),
66641
+ maturity,
66642
+ exit: {
66643
+ mode: exitMode,
66644
+ settlement: str5(meta.redemptionType),
66645
+ cooldownSecs: num12(meta.withdrawalCooldownSeconds),
66646
+ feeBps: num12(meta.withdrawFeeBps)
66647
+ },
66648
+ availability,
66649
+ risk: {
66650
+ yieldProfile: yieldProfile(info.yieldProfile),
66651
+ denomination: denomination(info.denomination),
66652
+ // The curated trust classification, where one exists. Typed on `EarnRisk`
66653
+ // since the surface was written and never populated — a tranche's
66654
+ // first-loss position is the term most worth surfacing on a rate list.
66655
+ counterparty: str5(meta.solvency),
66656
+ score: num12(row.rating?.score),
66657
+ label: str5(row.rating?.level),
66658
+ illiquid: isIlliquid({
66659
+ exitMode,
66660
+ tvlUsd: num12(tvl.totalAssetsUsd),
66661
+ liquidityUsd: num12(liq.liquidityUsd)
66662
+ })
66663
+ },
66664
+ // Filled by `capabilities.ts` — kept required on the type so a normalizer
66665
+ // that forgets to stamp them is a compile error, not an empty CTA.
66666
+ capabilities: [],
66667
+ providerMeta: row.providerMeta
66668
+ };
66669
+ return market;
66670
+ }
66671
+ function ratePercent(value, provider, fractionProviders = FRACTION_RATE_PROVIDERS) {
66672
+ const n = num12(value);
66673
+ if (n === void 0) return void 0;
66674
+ return fractionProviders.has(provider) ? n * 100 : n;
66675
+ }
66676
+ function implausibleRatePercent(percent) {
66677
+ return !Number.isFinite(percent) || percent < 0 || percent > 1e4;
66678
+ }
66679
+ function resolveRateKind(provider, meta) {
66680
+ if (meta.navOracle || meta.solvency === "nav-attested") return "nav-accrual";
66681
+ return RATE_KIND[provider] ?? "variable-managed";
66682
+ }
66683
+ function resolveAvailability(meta, maturity) {
66684
+ const isMintable = meta.isMintable;
66685
+ const capacity = str5(meta.depositCapacity) ?? str5(meta.maxDeposit);
66686
+ const capFull = capacity === "0";
66687
+ let gating;
66688
+ let reason;
66689
+ if (isMatured(maturity)) {
66690
+ gating = "matured";
66691
+ reason = "This market has reached maturity";
66692
+ } else if (isMintable === false) {
66693
+ gating = "allowlist-contract";
66694
+ reason = "Deposits are permissioned for this vault";
66695
+ } else if (capFull) {
66696
+ gating = "cap-full";
66697
+ reason = "Deposit cap is full";
66698
+ } else if (meta.paused === true) {
66699
+ gating = "paused";
66700
+ reason = "Vault is paused";
66701
+ }
66702
+ return {
66703
+ canDeposit: gating === void 0,
66704
+ // Exits stay open under a deposit cap, a mint allowlist or a maturity —
66705
+ // every wind-down we have integrated (Lista, dTRINITY/Sonic) keeps the
66706
+ // door open outward, and a matured bond is precisely the case where the
66707
+ // holder still needs out. An explicit pause is the one thing that shuts
66708
+ // both.
66709
+ canWithdraw: meta.paused !== true,
66710
+ gating,
66711
+ reason
66712
+ };
66713
+ }
66714
+ function resolveMaturity(meta) {
66715
+ const expiry = num12(meta.expiry) ?? num12(meta.maturity);
66716
+ if (expiry === void 0 || expiry <= 0) return void 0;
66717
+ const nowSecs = Math.floor(Date.now() / 1e3);
66718
+ return {
66719
+ kind: "fixed-date",
66720
+ maturity: expiry,
66721
+ maturityIso: str5(meta.expiryIso) ?? new Date(expiry * 1e3).toISOString(),
66722
+ // A SNAPSHOT — a cached listing ages, so a countdown must be recomputed
66723
+ // from `maturity` rather than ticked down from this.
66724
+ secondsToMaturity: Math.max(expiry - nowSecs, 0),
66725
+ // A PT simply stops earning: it redeems for the underlying at par and
66726
+ // sits there. No penalty, no liquidation, no auto-roll.
66727
+ atMaturity: str5(meta.atMaturity) ?? "stops-earning"
66728
+ };
66729
+ }
66730
+ function isMatured(maturity) {
66731
+ if (!maturity?.maturity) return false;
66732
+ return maturity.maturity <= Math.floor(Date.now() / 1e3);
66733
+ }
66734
+ function amount(raw, formatted, usd, decimals) {
66735
+ const rawStr = raw != null ? String(raw) : void 0;
66736
+ return {
66737
+ raw: rawStr,
66738
+ formatted: num12(formatted) ?? formatRaw(rawStr, decimals),
66739
+ usd: num12(usd)
66740
+ };
66741
+ }
66742
+ function sum(a, b) {
66743
+ if (a === void 0 && b === void 0) return void 0;
66744
+ return (a ?? 0) + (b ?? 0);
66745
+ }
66746
+
66248
66747
  // src/terms/vault/input.ts
66249
- var num12 = (v) => {
66748
+ var num13 = (v) => {
66250
66749
  if (typeof v === "number") return Number.isFinite(v) ? v : void 0;
66251
66750
  if (typeof v === "string" && v.trim() !== "") {
66252
66751
  const n = Number(v);
@@ -66254,7 +66753,7 @@ var num12 = (v) => {
66254
66753
  }
66255
66754
  return void 0;
66256
66755
  };
66257
- var str5 = (v) => typeof v === "string" && v.trim() !== "" ? v : void 0;
66756
+ var str6 = (v) => typeof v === "string" && v.trim() !== "" ? v : void 0;
66258
66757
  var bool2 = (v) => typeof v === "boolean" ? v : void 0;
66259
66758
  var fromRaw = (raw, decimals) => {
66260
66759
  const s = raw == null ? void 0 : String(raw);
@@ -66262,69 +66761,86 @@ var fromRaw = (raw, decimals) => {
66262
66761
  const n = Number(s) / 10 ** decimals;
66263
66762
  return Number.isFinite(n) ? n : void 0;
66264
66763
  };
66764
+ function sdkRates(row, provider) {
66765
+ if (!SDK_FRACTION_RATE_PROVIDERS.has(provider)) {
66766
+ return {
66767
+ supplyRate: num13(row.supplyRate),
66768
+ rewardsRate: num13(row.rewardsRate),
66769
+ totalRate: num13(row.depositRate)
66770
+ };
66771
+ }
66772
+ const pct2 = (v) => {
66773
+ const n = num13(v);
66774
+ return n === void 0 ? void 0 : n * 100;
66775
+ };
66776
+ return {
66777
+ // GMX splits fee APY from incentive APR; HyperCore reports one number.
66778
+ supplyRate: pct2(row.baseApy ?? row.apr),
66779
+ rewardsRate: pct2(row.bonusApr),
66780
+ totalRate: pct2(row.apy ?? row.apr)
66781
+ };
66782
+ }
66265
66783
  function toVaultTermInput(vault, provider, chainId) {
66266
66784
  const row = vault;
66267
- const address = str5(row.address)?.toLowerCase();
66785
+ const address = str6(row.address)?.toLowerCase();
66268
66786
  if (!address) return void 0;
66269
- const assetDecimals = num12(row.assetDecimals) ?? num12(row.decimals);
66787
+ const assetDecimals = num13(row.assetDecimals) ?? num13(row.decimals);
66270
66788
  const asset = row.asset;
66271
66789
  return {
66272
66790
  provider,
66273
66791
  chainId,
66274
66792
  address,
66275
66793
  vaultUid: `vault.${provider}:${chainId}:${address}`,
66276
- name: str5(row.displayName) ?? str5(row.name),
66277
- brand: str5(row.brand),
66278
- curatorName: str5(row.curatorName),
66279
- description: str5(row.description),
66794
+ name: str6(row.displayName) ?? str6(row.name),
66795
+ brand: str6(row.brand),
66796
+ curatorName: str6(row.curatorName),
66797
+ description: str6(row.description),
66280
66798
  asset: {
66281
66799
  chainId,
66282
- address: str5(row.underlying)?.toLowerCase() ?? "",
66283
- symbol: str5(asset?.symbol),
66284
- name: str5(asset?.name),
66800
+ address: str6(row.underlying)?.toLowerCase() ?? "",
66801
+ symbol: str6(asset?.symbol),
66802
+ name: str6(asset?.name),
66285
66803
  decimals: assetDecimals,
66286
- assetGroup: str5(asset?.assetGroup),
66287
- logoURI: str5(asset?.logoURI)
66804
+ assetGroup: str6(asset?.assetGroup),
66805
+ logoURI: str6(asset?.logoURI)
66288
66806
  },
66289
- supplyRate: num12(row.supplyRate),
66290
- rewardsRate: num12(row.rewardsRate),
66291
- totalRate: num12(row.depositRate),
66807
+ ...sdkRates(row, provider),
66292
66808
  isForwardApr: bool2(row.isForwardApr),
66293
- aprWindow: str5(row.aprWindow),
66809
+ aprWindow: str6(row.aprWindow),
66294
66810
  // GMX / HyperCore / Pendle report USD only and set the token-denominated
66295
66811
  // fields to their USD figure — `totalAssetsFormatted` is the cross-provider
66296
66812
  // magnitude either way, so prefer it over re-deriving from raw.
66297
- totalAssets: num12(row.totalAssetsFormatted) ?? fromRaw(row.totalAssets, assetDecimals),
66298
- totalAssetsUsd: num12(row.totalAssetsUsd) ?? num12(row.tvlUsd),
66299
- liquidity: num12(row.liquidityFormatted) ?? fromRaw(row.liquidity, assetDecimals),
66300
- liquidityUsd: num12(row.liquidityUsd),
66301
- instantLiquidityRatio: num12(row.instantLiquidityRatio),
66813
+ totalAssets: num13(row.totalAssetsFormatted) ?? fromRaw(row.totalAssets, assetDecimals),
66814
+ totalAssetsUsd: num13(row.totalAssetsUsd) ?? num13(row.tvlUsd),
66815
+ liquidity: num13(row.liquidityFormatted) ?? fromRaw(row.liquidity, assetDecimals),
66816
+ liquidityUsd: num13(row.liquidityUsd),
66817
+ instantLiquidityRatio: num13(row.instantLiquidityRatio),
66302
66818
  totalBorrowed: fromRaw(row.totalBorrowed, assetDecimals),
66303
66819
  expectedLiquidity: fromRaw(row.expectedLiquidity, assetDecimals),
66304
- withdrawalMode: str5(row.withdrawalMode),
66305
- withdrawalCooldownSeconds: num12(row.withdrawalCooldownSeconds),
66306
- withdrawFeeBps: num12(row.withdrawFeeBps),
66307
- fee: num12(row.fee),
66308
- swapFeeRate: num12(row.feeRate),
66309
- redemptionDiscountBps: num12(row.redemptionDiscountBps),
66820
+ withdrawalMode: str6(row.withdrawalMode),
66821
+ withdrawalCooldownSeconds: num13(row.withdrawalCooldownSeconds),
66822
+ withdrawFeeBps: num13(row.withdrawFeeBps),
66823
+ fee: num13(row.fee),
66824
+ swapFeeRate: num13(row.feeRate),
66825
+ redemptionDiscountBps: num13(row.redemptionDiscountBps),
66310
66826
  instantRedeemEnabled: bool2(row.instantRedeemEnabled),
66311
66827
  isMintable: bool2(row.isMintable),
66312
- depositCapacity: str5(row.depositCapacity),
66313
- supplyCap: str5(row.supplyCap),
66828
+ depositCapacity: str6(row.depositCapacity),
66829
+ supplyCap: str6(row.supplyCap),
66314
66830
  paused: bool2(row.isPaused),
66315
66831
  depositsPaused: bool2(row.isDepositPaused),
66316
66832
  withdrawalsPaused: bool2(row.isWithdrawalPaused),
66317
66833
  isClosed: bool2(row.isClosed),
66318
66834
  whitelisted: bool2(row.whitelisted),
66319
- expiry: num12(row.expiry),
66320
- timelock: num12(row.timelock),
66321
- owner: str5(row.owner),
66322
- curator: str5(row.curator),
66323
- guardian: str5(row.guardian),
66324
- feeRecipient: str5(row.feeRecipient),
66325
- solvency: str5(row.solvency),
66326
- navOracle: str5(row.navOracle),
66327
- yieldProfile: str5(row.yieldProfile),
66835
+ expiry: num13(row.expiry),
66836
+ timelock: num13(row.timelock),
66837
+ owner: str6(row.owner),
66838
+ curator: str6(row.curator),
66839
+ guardian: str6(row.guardian),
66840
+ feeRecipient: str6(row.feeRecipient),
66841
+ solvency: str6(row.solvency),
66842
+ navOracle: str6(row.navOracle),
66843
+ yieldProfile: str6(row.yieldProfile),
66328
66844
  exposures: Array.isArray(row.exposures) ? row.exposures : void 0
66329
66845
  };
66330
66846
  }
@@ -66341,7 +66857,7 @@ function vaultTermInputFromEarnMarket(m) {
66341
66857
  name: m.name,
66342
66858
  brand: m.brand,
66343
66859
  curatorName: m.brand,
66344
- description: str5(meta.description),
66860
+ description: str6(meta.description),
66345
66861
  asset: {
66346
66862
  chainId: m.chainId,
66347
66863
  address: m.asset.address,
@@ -66354,46 +66870,56 @@ function vaultTermInputFromEarnMarket(m) {
66354
66870
  rewardsRate: m.rate.rewards,
66355
66871
  totalRate: m.rate.total,
66356
66872
  isForwardApr: bool2(meta.isForwardApr),
66357
- aprWindow: str5(meta.aprWindow),
66873
+ aprWindow: str6(meta.aprWindow),
66358
66874
  totalAssets: m.tvl.formatted,
66359
66875
  totalAssetsUsd: m.tvl.usd,
66360
66876
  liquidity: m.liquidity?.formatted,
66361
66877
  liquidityUsd: m.liquidity?.usd,
66362
- instantLiquidityRatio: num12(meta.instantLiquidityRatio),
66363
- totalBorrowed: num12(meta.totalBorrowed),
66364
- expectedLiquidity: num12(meta.expectedLiquidity),
66878
+ instantLiquidityRatio: num13(meta.instantLiquidityRatio),
66879
+ totalBorrowed: num13(meta.totalBorrowed),
66880
+ expectedLiquidity: num13(meta.expectedLiquidity),
66365
66881
  withdrawalMode: m.exit.mode,
66366
66882
  withdrawalCooldownSeconds: m.exit.cooldownSecs,
66367
66883
  withdrawFeeBps: m.exit.feeBps,
66368
66884
  fee: m.rate.fee,
66369
- swapFeeRate: num12(meta.feeRate),
66370
- redemptionDiscountBps: num12(meta.redemptionDiscountBps),
66885
+ swapFeeRate: num13(meta.feeRate),
66886
+ redemptionDiscountBps: num13(meta.redemptionDiscountBps),
66371
66887
  instantRedeemEnabled: bool2(meta.instantRedeemEnabled),
66372
66888
  // `canDeposit` already folds in the cap, the pause and the gate, so it is
66373
66889
  // the authoritative answer — but the REASON is what a disabled CTA renders,
66374
66890
  // and that only survives in the raw fields.
66375
66891
  isMintable: m.availability.canDeposit ? void 0 : false,
66376
66892
  depositCapacity: m.depositCapacity,
66377
- supplyCap: str5(meta.supplyCap),
66893
+ supplyCap: str6(meta.supplyCap),
66378
66894
  paused: m.availability.gating === "paused" ? true : void 0,
66379
66895
  withdrawalsPaused: m.availability.canWithdraw ? void 0 : true,
66380
66896
  isClosed: bool2(meta.isClosed),
66381
66897
  whitelisted: bool2(meta.whitelisted),
66382
66898
  expiry: m.maturity?.maturity,
66383
- timelock: num12(meta.timelock),
66384
- owner: str5(meta.owner),
66385
- curator: str5(meta.curator),
66386
- guardian: str5(meta.guardian),
66387
- feeRecipient: str5(meta.feeRecipient),
66899
+ timelock: num13(meta.timelock),
66900
+ owner: str6(meta.owner),
66901
+ curator: str6(meta.curator),
66902
+ guardian: str6(meta.guardian),
66903
+ feeRecipient: str6(meta.feeRecipient),
66388
66904
  solvency: m.risk?.counterparty,
66389
- navOracle: str5(meta.navOracle),
66905
+ navOracle: str6(meta.navOracle),
66390
66906
  yieldProfile: m.risk?.yieldProfile,
66391
66907
  exposures: m.refs?.exposures
66392
66908
  };
66393
66909
  }
66910
+ function originRates(rates) {
66911
+ const supply = num13(rates.supplyRate);
66912
+ const rewards = num13(rates.rewardsRate);
66913
+ const deposit = num13(rates.depositRate);
66914
+ return {
66915
+ supplyRate: supply ?? (deposit !== void 0 && rewards !== void 0 ? deposit - rewards : deposit),
66916
+ rewardsRate: rewards,
66917
+ totalRate: num13(rates.totalRate) ?? deposit
66918
+ };
66919
+ }
66394
66920
  function vaultTermInputFromSourceRow(row, chainId) {
66395
- const provider = str5(row.provider);
66396
- const address = str5(row.vaultAddress)?.toLowerCase();
66921
+ const provider = str6(row.provider);
66922
+ const address = str6(row.vaultAddress)?.toLowerCase();
66397
66923
  if (!provider || !address) return void 0;
66398
66924
  const meta = row.providerMeta ?? {};
66399
66925
  const rates = row.rates ?? {};
@@ -66401,60 +66927,58 @@ function vaultTermInputFromSourceRow(row, chainId) {
66401
66927
  const liq = row.liquidity ?? {};
66402
66928
  const info = row.vaultInfo ?? {};
66403
66929
  const assetInfo = row.underlyingInfo?.asset;
66404
- const assetDecimals = num12(row.assetDecimals) ?? num12(assetInfo?.decimals) ?? num12(row.decimals);
66930
+ const assetDecimals = num13(row.assetDecimals) ?? num13(assetInfo?.decimals) ?? num13(row.decimals);
66405
66931
  return {
66406
66932
  provider,
66407
66933
  chainId,
66408
66934
  address,
66409
66935
  vaultUid: `vault.${provider}:${chainId}:${address}`,
66410
- name: str5(info.name) ?? str5(row.displayName) ?? str5(row.name),
66411
- brand: str5(row.curatorName) ?? str5(meta.brand),
66412
- curatorName: str5(row.curatorName),
66413
- description: str5(meta.description),
66936
+ name: str6(info.name) ?? str6(row.displayName) ?? str6(row.name),
66937
+ brand: str6(row.curatorName) ?? str6(meta.brand),
66938
+ curatorName: str6(row.curatorName),
66939
+ description: str6(meta.description),
66414
66940
  asset: {
66415
66941
  chainId,
66416
- address: str5(row.underlying)?.toLowerCase() ?? "",
66417
- symbol: str5(assetInfo?.symbol),
66942
+ address: str6(row.underlying)?.toLowerCase() ?? "",
66943
+ symbol: str6(assetInfo?.symbol),
66418
66944
  decimals: assetDecimals,
66419
- assetGroup: str5(info.assetGroup),
66420
- logoURI: str5(assetInfo?.logoURI)
66945
+ assetGroup: str6(info.assetGroup),
66946
+ logoURI: str6(assetInfo?.logoURI)
66421
66947
  },
66422
- supplyRate: num12(rates.depositRate) ?? num12(rates.supplyRate),
66423
- rewardsRate: num12(rates.rewardsRate),
66424
- totalRate: num12(rates.totalRate),
66948
+ ...originRates(rates),
66425
66949
  isForwardApr: bool2(meta.isForwardApr),
66426
- aprWindow: str5(meta.aprWindow),
66427
- totalAssets: num12(tvl.totalAssetsFormatted) ?? fromRaw(tvl.totalAssets, assetDecimals),
66428
- totalAssetsUsd: num12(tvl.totalAssetsUsd),
66429
- liquidity: num12(liq.liquidityFormatted) ?? fromRaw(liq.liquidity, assetDecimals),
66430
- liquidityUsd: num12(liq.liquidityUsd),
66431
- instantLiquidityRatio: num12(meta.instantLiquidityRatio),
66950
+ aprWindow: str6(meta.aprWindow),
66951
+ totalAssets: num13(tvl.totalAssetsFormatted) ?? fromRaw(tvl.totalAssets, assetDecimals),
66952
+ totalAssetsUsd: num13(tvl.totalAssetsUsd),
66953
+ liquidity: num13(liq.liquidityFormatted) ?? fromRaw(liq.liquidity, assetDecimals),
66954
+ liquidityUsd: num13(liq.liquidityUsd),
66955
+ instantLiquidityRatio: num13(meta.instantLiquidityRatio),
66432
66956
  totalBorrowed: fromRaw(meta.totalBorrowed, assetDecimals),
66433
66957
  expectedLiquidity: fromRaw(meta.expectedLiquidity, assetDecimals),
66434
- withdrawalMode: str5(meta.withdrawalMode),
66435
- withdrawalCooldownSeconds: num12(meta.withdrawalCooldownSeconds),
66436
- withdrawFeeBps: num12(meta.withdrawFeeBps),
66437
- fee: num12(rates.fee),
66438
- swapFeeRate: num12(meta.feeRate),
66439
- redemptionDiscountBps: num12(meta.redemptionDiscountBps),
66958
+ withdrawalMode: str6(meta.withdrawalMode),
66959
+ withdrawalCooldownSeconds: num13(meta.withdrawalCooldownSeconds),
66960
+ withdrawFeeBps: num13(meta.withdrawFeeBps),
66961
+ fee: num13(rates.fee),
66962
+ swapFeeRate: num13(meta.feeRate),
66963
+ redemptionDiscountBps: num13(meta.redemptionDiscountBps),
66440
66964
  instantRedeemEnabled: bool2(meta.instantRedeemEnabled),
66441
66965
  isMintable: bool2(meta.isMintable),
66442
- depositCapacity: str5(meta.depositCapacity) ?? str5(meta.maxDeposit),
66443
- supplyCap: str5(meta.supplyCap),
66966
+ depositCapacity: str6(meta.depositCapacity) ?? str6(meta.maxDeposit),
66967
+ supplyCap: str6(meta.supplyCap),
66444
66968
  paused: bool2(meta.paused) ?? bool2(meta.isPaused),
66445
66969
  depositsPaused: bool2(meta.isDepositPaused),
66446
66970
  withdrawalsPaused: bool2(meta.isWithdrawalPaused),
66447
66971
  isClosed: bool2(meta.isClosed),
66448
66972
  whitelisted: bool2(meta.whitelisted),
66449
- expiry: num12(meta.expiry) ?? num12(meta.maturity),
66450
- timelock: num12(meta.timelock),
66451
- owner: str5(meta.owner),
66452
- curator: str5(meta.curator),
66453
- guardian: str5(meta.guardian),
66454
- feeRecipient: str5(meta.feeRecipient),
66455
- solvency: str5(meta.solvency),
66456
- navOracle: str5(meta.navOracle),
66457
- yieldProfile: str5(info.yieldProfile),
66973
+ expiry: num13(meta.expiry) ?? num13(meta.maturity),
66974
+ timelock: num13(meta.timelock),
66975
+ owner: str6(meta.owner),
66976
+ curator: str6(meta.curator),
66977
+ guardian: str6(meta.guardian),
66978
+ feeRecipient: str6(meta.feeRecipient),
66979
+ solvency: str6(meta.solvency),
66980
+ navOracle: str6(meta.navOracle),
66981
+ yieldProfile: str6(info.yieldProfile),
66458
66982
  exposures: Array.isArray(row.exposures) ? row.exposures : Array.isArray(meta.exposures) ? meta.exposures : void 0
66459
66983
  };
66460
66984
  }
@@ -67252,7 +67776,7 @@ async function fetchTokenBalances(chainId, account, tokens, options = {}) {
67252
67776
  }
67253
67777
 
67254
67778
  // src/terms/input.ts
67255
- var num13 = (v) => {
67779
+ var num14 = (v) => {
67256
67780
  if (v == null) return void 0;
67257
67781
  const n = typeof v === "string" ? Number(v) : v;
67258
67782
  return Number.isFinite(n) ? n : void 0;
@@ -67283,12 +67807,12 @@ function toTermSheetInput(row, ctx = {}) {
67283
67807
  {
67284
67808
  category: v?.category ?? k,
67285
67809
  label: v?.label,
67286
- borrowCollateralFactor: num13(v?.borrowCollateralFactor),
67287
- collateralFactor: num13(v?.collateralFactor),
67288
- borrowFactor: num13(v?.borrowFactor),
67289
- liquidationPenalty: num13(v?.liquidationPenalty),
67290
- closeFactor: num13(v?.closeFactor),
67291
- targetHealthFactor: num13(v?.targetHealthFactor),
67810
+ borrowCollateralFactor: num14(v?.borrowCollateralFactor),
67811
+ collateralFactor: num14(v?.collateralFactor),
67812
+ borrowFactor: num14(v?.borrowFactor),
67813
+ liquidationPenalty: num14(v?.liquidationPenalty),
67814
+ closeFactor: num14(v?.closeFactor),
67815
+ targetHealthFactor: num14(v?.targetHealthFactor),
67292
67816
  collateralDisabled: v?.collateralDisabled === true,
67293
67817
  debtDisabled: v?.debtDisabled === true
67294
67818
  }
@@ -67296,11 +67820,11 @@ function toTermSheetInput(row, ctx = {}) {
67296
67820
  ) : void 0;
67297
67821
  const rewards = pick2(row, "rewards")?.map((r) => ({
67298
67822
  asset: r?.asset,
67299
- depositRate: num13(r?.depositRate),
67300
- variableBorrowRate: num13(r?.variableBorrowRate),
67301
- stableBorrowRate: num13(r?.stableBorrowRate),
67823
+ depositRate: num14(r?.depositRate),
67824
+ variableBorrowRate: num14(r?.variableBorrowRate),
67825
+ stableBorrowRate: num14(r?.stableBorrowRate),
67302
67826
  kind: r?.kind,
67303
- endsAt: num13(r?.endsAt),
67827
+ endsAt: num14(r?.endsAt),
67304
67828
  claim: r?.claim
67305
67829
  }));
67306
67830
  return {
@@ -67313,29 +67837,29 @@ function toTermSheetInput(row, ctx = {}) {
67313
67837
  "underlyingInfo.asset"
67314
67838
  ),
67315
67839
  underlying: pick2(row, "underlying"),
67316
- decimals: num13(pick2(row, "decimals")),
67317
- depositRate: num13(pick2(row, "depositRate")),
67318
- variableBorrowRate: num13(pick2(row, "variableBorrowRate")),
67319
- stableBorrowRate: num13(pick2(row, "stableBorrowRate")),
67320
- intrinsicYield: num13(pick2(row, "intrinsicYield")),
67840
+ decimals: num14(pick2(row, "decimals")),
67841
+ depositRate: num14(pick2(row, "depositRate")),
67842
+ variableBorrowRate: num14(pick2(row, "variableBorrowRate")),
67843
+ stableBorrowRate: num14(pick2(row, "stableBorrowRate")),
67844
+ intrinsicYield: num14(pick2(row, "intrinsicYield")),
67321
67845
  rewards,
67322
67846
  rateModel: pick2(row, "rateModel"),
67323
- originationFee: num13(pick2(row, "originationFee")),
67324
- totalDeposits: num13(pick2(row, "totalDeposits")),
67325
- totalDebt: num13(pick2(row, "totalDebt")),
67326
- totalDebtStable: num13(pick2(row, "totalDebtStable")),
67327
- totalLiquidity: num13(pick2(row, "totalLiquidity")),
67328
- borrowLiquidity: num13(pick2(row, "borrowLiquidity")),
67329
- totalDepositsUsd: num13(pick2(row, "totalDepositsUSD", "totalDepositsUsd")),
67330
- totalDebtUsd: num13(pick2(row, "totalDebtUSD", "totalDebtUsd")),
67331
- totalLiquidityUsd: num13(pick2(row, "totalLiquidityUSD", "totalLiquidityUsd")),
67332
- utilization: num13(pick2(row, "utilization")),
67333
- irmTotalDeposits: num13(pick2(row, "irmTotalDeposits")),
67334
- irmTotalDebt: num13(pick2(row, "irmTotalDebt")),
67335
- lockupRatio: num13(pick2(row, "lockupRatio")),
67847
+ originationFee: num14(pick2(row, "originationFee")),
67848
+ totalDeposits: num14(pick2(row, "totalDeposits")),
67849
+ totalDebt: num14(pick2(row, "totalDebt")),
67850
+ totalDebtStable: num14(pick2(row, "totalDebtStable")),
67851
+ totalLiquidity: num14(pick2(row, "totalLiquidity")),
67852
+ borrowLiquidity: num14(pick2(row, "borrowLiquidity")),
67853
+ totalDepositsUsd: num14(pick2(row, "totalDepositsUSD", "totalDepositsUsd")),
67854
+ totalDebtUsd: num14(pick2(row, "totalDebtUSD", "totalDebtUsd")),
67855
+ totalLiquidityUsd: num14(pick2(row, "totalLiquidityUSD", "totalLiquidityUsd")),
67856
+ utilization: num14(pick2(row, "utilization")),
67857
+ irmTotalDeposits: num14(pick2(row, "irmTotalDeposits")),
67858
+ irmTotalDebt: num14(pick2(row, "irmTotalDebt")),
67859
+ lockupRatio: num14(pick2(row, "lockupRatio")),
67336
67860
  minBorrow: pick2(row, "minBorrow", "caps.minBorrow") ?? void 0,
67337
- supplyCap: num13(pick2(row, "supplyCap", "caps.supplyCap")),
67338
- borrowCap: num13(pick2(row, "borrowCap", "caps.borrowCap")),
67861
+ supplyCap: num14(pick2(row, "supplyCap", "caps.supplyCap")),
67862
+ borrowCap: num14(pick2(row, "borrowCap", "caps.borrowCap")),
67339
67863
  debtCeiling: pick2(row, "debtCeiling", "caps.debtCeiling"),
67340
67864
  isActive: pick2(row, "isActive", "flags.isActive"),
67341
67865
  isFrozen: pick2(row, "isFrozen", "flags.isFrozen"),
@@ -67361,8 +67885,8 @@ function toTermSheetInput(row, ctx = {}) {
67361
67885
  "flags.variableBorrowDisabled"
67362
67886
  ),
67363
67887
  config,
67364
- closeFactor: num13(pick2(row, "closeFactor")),
67365
- targetHealthFactor: num13(pick2(row, "targetHealthFactor")),
67888
+ closeFactor: num14(pick2(row, "closeFactor")),
67889
+ targetHealthFactor: num14(pick2(row, "targetHealthFactor")),
67366
67890
  fixedTerm: pick2(row, "fixedTerm") ?? ctx.fixedTerm,
67367
67891
  terms: pick2(row, "terms"),
67368
67892
  market: resolveMarketDescriptors(row, ctx.market)
@@ -69071,7 +69595,7 @@ function validateTermSheet(sheet) {
69071
69595
  if (g.powers?.length)
69072
69596
  fail("immutable-powers", "immutable governance must not carry powers");
69073
69597
  }
69074
- if (g.timelockSecs && g.controllerKind && g.controllerKind !== "TIMELOCK")
69598
+ if (g.timelockSecs && g.controllerKind && g.controllerKind !== "TIMELOCK" && g.timelockSource !== "on-chain")
69075
69599
  fail(
69076
69600
  "timelock-without-timelock-root",
69077
69601
  `timelockSecs set but controllerKind is ${g.controllerKind}`
@@ -69089,466 +69613,6 @@ function validateTermSheets(sheets) {
69089
69613
  return sheets.flatMap((s) => validateTermSheet(s));
69090
69614
  }
69091
69615
 
69092
- // src/earn/labels.ts
69093
- var VENUE_KIND_LABELS = {
69094
- lending: "Lending markets",
69095
- vault: "Vaults"
69096
- };
69097
- var VENUE_KIND_DESCRIPTIONS = {
69098
- lending: "Supply into a lending market. Same-block exit, bounded by liquidity.",
69099
- vault: "Deposit into a yield vault. Exit terms vary per vault."
69100
- };
69101
- var EXIT_MODE_LABELS = {
69102
- instant: "Instant",
69103
- "instant-capped": "Instant (capped)",
69104
- "instant-or-queued": "Instant or queue",
69105
- "fee-or-queued": "Fee or queue",
69106
- "fixed-cooldown": "Cooldown",
69107
- queued: "Queued",
69108
- "request-based": "Request",
69109
- "market-sale": "Market sale",
69110
- "at-maturity": "At maturity",
69111
- "off-chain": "Off-chain",
69112
- "dex-only": "DEX only"
69113
- };
69114
- var EXIT_MODE_DESCRIPTIONS = {
69115
- instant: "Withdraw any time.",
69116
- "instant-capped": "Withdraw up to the available liquidity.",
69117
- "instant-or-queued": "Withdraw instantly, or queue for the rest.",
69118
- "fee-or-queued": "Instant exit for a fee, or queue for free.",
69119
- "fixed-cooldown": "Request, wait out a cooldown, then claim.",
69120
- queued: "Withdrawals are queued.",
69121
- "request-based": "Withdrawals need a request and a later claim.",
69122
- "market-sale": "Exit by selling the position on a market.",
69123
- "at-maturity": "Locked until maturity.",
69124
- "off-chain": "Exit is settled off-chain.",
69125
- "dex-only": "Exit only by selling on a DEX."
69126
- };
69127
- var ACTION_LABELS = {
69128
- deposit: "Deposit",
69129
- withdraw: "Withdraw",
69130
- "request-withdraw": "Request withdrawal",
69131
- claim: "Claim",
69132
- cancel: "Cancel request"
69133
- };
69134
- var GATING_LABELS = {
69135
- "allowlist-contract": "Permissioned",
69136
- kyc: "KYC required",
69137
- "cap-full": "Cap full",
69138
- paused: "Paused",
69139
- frozen: "Frozen",
69140
- "collateral-only": "No yield",
69141
- matured: "Matured"
69142
- };
69143
- var RATE_KIND_LABELS = {
69144
- "variable-curve": "Variable (utilization)",
69145
- "variable-managed": "Variable (managed)",
69146
- "user-set": "Borrower-set",
69147
- "fixed-term": "Fixed term",
69148
- "fixed-open": "Fixed",
69149
- "zero-interest": "Interest-free",
69150
- prepaid: "Prepaid",
69151
- "nav-accrual": "NAV accrual",
69152
- none: "No rate"
69153
- };
69154
- var RATE_SOURCE_LABELS = {
69155
- chain: "On-chain",
69156
- api: "Protocol API",
69157
- oracle: "Oracle",
69158
- realized: "Realized"
69159
- };
69160
- var VENUE_BRANDS = {
69161
- MORPHO_BLUE: "Morpho Blue",
69162
- MORPHO_MIDNIGHT: "Morpho Midnight",
69163
- FLUID: "Fluid",
69164
- GEARBOX_V3: "Gearbox V3",
69165
- AAVE_V4: "Aave V4",
69166
- AAVE_V3: "Aave V3",
69167
- AAVE_V2: "Aave V2",
69168
- SKY: "Sky",
69169
- USDD: "USDD",
69170
- LIQUITY_V2: "Liquity V2",
69171
- SILO_V2: "Silo V2",
69172
- SILO_V3: "Silo V3",
69173
- EXACTLY: "Exactly",
69174
- TELLER: "Teller",
69175
- TERM_FINANCE: "Term Finance",
69176
- TERMMAX: "TermMax",
69177
- LLAMALEND: "LlamaLend",
69178
- CURVANCE: "Curvance",
69179
- INVERSE: "Inverse",
69180
- FRANKENCOIN: "Frankencoin",
69181
- RIVER: "River",
69182
- RESUPPLY: "Resupply",
69183
- TANGENT: "Tangent",
69184
- DOLOMITE: "Dolomite",
69185
- LISTA_DAO: "Lista",
69186
- FLUX_FINANCE: "Flux",
69187
- COMPOUND_V2: "Compound V2",
69188
- COMPOUND_V3: "Compound V3",
69189
- EULER_V2: "Euler V2",
69190
- INIT: "Init"
69191
- };
69192
- var VAULT_PROVIDER_BRANDS = {
69193
- fluid: "Fluid",
69194
- gearbox: "Gearbox",
69195
- morpho: "Morpho",
69196
- lista: "Lista",
69197
- silo: "Silo",
69198
- "euler-earn": "Euler",
69199
- termmax: "TermMax",
69200
- lst: "Liquid staking",
69201
- savings: "Savings",
69202
- lagoon: "Lagoon",
69203
- "aave-earn": "Aave",
69204
- upshift: "Upshift",
69205
- yearn: "Yearn",
69206
- hypercore: "HyperLiquid",
69207
- gmx: "GMX",
69208
- pendle: "Pendle"
69209
- };
69210
- function isInstanceSegment(seg) {
69211
- if (/^\d+$/.test(seg)) return true;
69212
- if (/^0X[0-9A-F]+$/i.test(seg)) return true;
69213
- return seg.length >= 8 && /^[0-9A-F]+$/i.test(seg);
69214
- }
69215
- function venueBrand(venue) {
69216
- if (venue.startsWith("vault.")) {
69217
- const provider = venue.slice("vault.".length);
69218
- return VAULT_PROVIDER_BRANDS[provider] ?? provider;
69219
- }
69220
- const segments = venue.split("_");
69221
- const cut = segments.findIndex(isInstanceSegment);
69222
- const family = (cut > 0 ? segments.slice(0, cut) : segments).join("_");
69223
- if (VENUE_BRANDS[family]) return VENUE_BRANDS[family];
69224
- let best;
69225
- for (const key3 of Object.keys(VENUE_BRANDS)) {
69226
- if (family.startsWith(key3) && (!best || key3.length > best.length))
69227
- best = key3;
69228
- }
69229
- return best ? VENUE_BRANDS[best] : family;
69230
- }
69231
- var EARN_LABELS = {
69232
- venueKind: VENUE_KIND_LABELS,
69233
- exitMode: EXIT_MODE_LABELS,
69234
- action: ACTION_LABELS,
69235
- gating: GATING_LABELS,
69236
- rateKind: RATE_KIND_LABELS,
69237
- rateSource: RATE_SOURCE_LABELS
69238
- };
69239
- var EARN_DESCRIPTIONS = {
69240
- venueKind: VENUE_KIND_DESCRIPTIONS,
69241
- exitMode: EXIT_MODE_DESCRIPTIONS
69242
- };
69243
- function earnLabel(dimension, key3) {
69244
- return EARN_LABELS[dimension][key3] ?? key3;
69245
- }
69246
- function earnDescription(dimension, key3) {
69247
- return EARN_DESCRIPTIONS[dimension][key3];
69248
- }
69249
- function earnMarketLabel(input) {
69250
- const asset = input.assetSymbol?.trim();
69251
- if (!asset) return input.fallbackName ?? "";
69252
- const collaterals = (input.collateralSymbols ?? []).map((c) => c?.trim()).filter((c) => !!c);
69253
- const distinct = [...new Set(collaterals)];
69254
- if (distinct.length === 1) return `${asset} \xB7 vs ${distinct[0]}`;
69255
- return asset;
69256
- }
69257
- var SAME_BLOCK_EXIT_MODES = /* @__PURE__ */ new Set([
69258
- "instant",
69259
- "instant-capped"
69260
- ]);
69261
- function isIlliquid(input) {
69262
- if (!input.exitMode || !SAME_BLOCK_EXIT_MODES.has(input.exitMode))
69263
- return false;
69264
- if (!input.tvlUsd || input.tvlUsd <= 0) return false;
69265
- if (input.liquidityUsd === void 0) return false;
69266
- return input.liquidityUsd <= 0;
69267
- }
69268
-
69269
- // src/earn/normalize.ts
69270
- function num14(v) {
69271
- if (v == null || v === "") return void 0;
69272
- const n = typeof v === "number" ? v : Number(v);
69273
- return Number.isFinite(n) ? n : void 0;
69274
- }
69275
- function str6(v) {
69276
- if (typeof v === "string") return v.length > 0 ? v : void 0;
69277
- if (typeof v === "number" && Number.isFinite(v)) return String(v);
69278
- return void 0;
69279
- }
69280
- function addr2(v) {
69281
- return str6(v)?.toLowerCase();
69282
- }
69283
- function yieldProfile(v) {
69284
- return v === "yield-bearing" || v === "volatile" ? v : void 0;
69285
- }
69286
- function denomination(v) {
69287
- return v === "stable" || v === "volatile" ? v : void 0;
69288
- }
69289
- function usdValue(formatted, priceUsd) {
69290
- if (formatted === void 0 || priceUsd === void 0) return void 0;
69291
- const v = formatted * priceUsd;
69292
- return Number.isFinite(v) ? v : void 0;
69293
- }
69294
- function formatRaw(raw, decimals) {
69295
- if (raw == null || raw === "") return void 0;
69296
- let value;
69297
- try {
69298
- value = BigInt(raw);
69299
- } catch {
69300
- return void 0;
69301
- }
69302
- if (decimals <= 0) return Number(value);
69303
- const base = 10n ** BigInt(decimals);
69304
- const whole = value / base;
69305
- const frac = value % base;
69306
- const n = Number(whole) + Number(frac) / Number(base);
69307
- return Number.isFinite(n) ? n : void 0;
69308
- }
69309
-
69310
- // src/earn/fromVault.ts
69311
- var FRACTION_RATE_PROVIDERS = /* @__PURE__ */ new Set();
69312
- var SDK_FRACTION_RATE_PROVIDERS = /* @__PURE__ */ new Set([
69313
- "hypercore",
69314
- "gmx"
69315
- ]);
69316
- var RATE_SOURCE = {
69317
- morpho: "api",
69318
- silo: "api",
69319
- lagoon: "api",
69320
- hypercore: "api",
69321
- gmx: "api",
69322
- upshift: "api",
69323
- yearn: "api",
69324
- "aave-earn": "api",
69325
- pendle: "api",
69326
- lista: "chain",
69327
- fluid: "chain",
69328
- gearbox: "chain",
69329
- "euler-earn": "chain",
69330
- termmax: "chain",
69331
- lst: "chain",
69332
- savings: "chain"
69333
- };
69334
- var RATE_KIND = {
69335
- morpho: "variable-curve",
69336
- lista: "variable-curve",
69337
- silo: "variable-curve",
69338
- "euler-earn": "variable-curve",
69339
- fluid: "variable-curve",
69340
- gearbox: "variable-curve",
69341
- "aave-earn": "variable-curve",
69342
- // The TermMax VAULT is a perpetual curated 4626 whose curator rolls
69343
- // fixed-term FT positions — the vault itself has no maturity and no locked
69344
- // rate. `fixed-term` here claimed both, producing a "fixed" rate with no date
69345
- // attached to it. The LENDER `TERMMAX_*` is fixed-term; this is not.
69346
- termmax: "variable-managed",
69347
- // A PT's implied APY is locked in at purchase and realized only by holding
69348
- // to maturity — the same promise TermMax's FT makes, reached by a different
69349
- // mechanism (an AMM discount rather than a quoted curve).
69350
- pendle: "fixed-term",
69351
- savings: "variable-managed",
69352
- lst: "variable-managed",
69353
- lagoon: "variable-managed",
69354
- upshift: "variable-managed",
69355
- yearn: "variable-managed",
69356
- hypercore: "realized",
69357
- gmx: "realized"
69358
- };
69359
- function resolveExitMode2(provider, meta, tvl, liq) {
69360
- const declared = str6(meta.withdrawalMode);
69361
- if (declared) return declared;
69362
- const fallback = vaultTraits(provider)?.defaultExitMode ?? "instant";
69363
- if (fallback !== "instant-capped") return fallback;
69364
- const total = num14(tvl?.totalAssetsFormatted) ?? num14(tvl?.totalAssetsUsd);
69365
- const available = num14(liq?.liquidityFormatted) ?? num14(liq?.liquidityUsd);
69366
- if (total === void 0 || available === void 0) return "instant-capped";
69367
- if (total <= 0) return "instant";
69368
- return available >= total ? "instant" : "instant-capped";
69369
- }
69370
- function earnMarketFromVault(row, chainId, opts = {}) {
69371
- const provider = str6(row.provider);
69372
- const address = str6(row.vaultAddress)?.toLowerCase();
69373
- const underlying = str6(row.underlying)?.toLowerCase();
69374
- if (!provider || !address || !underlying) return void 0;
69375
- const meta = row.providerMeta ?? {};
69376
- const info = row.vaultInfo ?? {};
69377
- const rates = row.rates ?? {};
69378
- const tvl = row.tvl ?? {};
69379
- const liq = row.liquidity ?? {};
69380
- const shareDecimals = num14(row.decimals) ?? 18;
69381
- const assetDecimals = num14(row.assetDecimals) ?? num14(row.underlyingInfo?.asset?.decimals) ?? shareDecimals;
69382
- const toPercent2 = (v) => ratePercent(v, provider, opts.fractionRateProviders);
69383
- const base = toPercent2(rates.depositRate ?? rates.supplyRate);
69384
- const rewards = toPercent2(rates.rewardsRate);
69385
- const total = toPercent2(rates.totalRate) ?? sum(base, rewards) ?? 0;
69386
- const rate = {
69387
- total,
69388
- base,
69389
- rewards,
69390
- // A vault has no separate intrinsic leg — whatever it pays IS the venue's
69391
- // own yield. Leaving this undefined rendered an empty "Venue APR" on every
69392
- // vault row, which read as "this vault pays nothing".
69393
- marketOwn: total,
69394
- // ...and for the same reason it can never be pass-through.
69395
- passthrough: false,
69396
- kind: resolveRateKind(provider, meta),
69397
- source: RATE_SOURCE[provider] ?? "api",
69398
- // The curator's cut. Dropped entirely until now, which left the earn row
69399
- // unable to say why its net rate sits below the gross one — and left the
69400
- // term sheet built from this row with no fee schedule at all.
69401
- fee: toPercent2(rates.fee)
69402
- };
69403
- const maturity = resolveMaturity(meta);
69404
- const availability = resolveAvailability(meta, maturity);
69405
- const exitMode = resolveExitMode2(provider, meta, tvl, liq);
69406
- return {
69407
- earnUid: buildVaultEarnUid(provider, chainId, address),
69408
- chainId,
69409
- venue: vaultVenue(provider),
69410
- venueKind: "vault",
69411
- // Curator first (it names the actual operator), then the provider brand.
69412
- brand: str6(row.curatorName) ?? venueBrand(vaultVenue(provider)),
69413
- name: str6(info.name) ?? str6(row.displayName) ?? str6(row.name),
69414
- ref: address,
69415
- logoURI: str6(info.logoURI) ?? str6(row.underlyingInfo?.asset?.logoURI),
69416
- asset: {
69417
- address: underlying,
69418
- symbol: str6(row.underlyingInfo?.asset?.symbol) ?? "",
69419
- decimals: assetDecimals,
69420
- assetGroup: str6(info.assetGroup),
69421
- priceUsd: num14(row.underlyingInfo?.prices?.priceUsd)
69422
- },
69423
- // The vault IS a share token by construction; carry it so a withdraw in
69424
- // share units can be built without a second lookup.
69425
- shareToken: {
69426
- address,
69427
- symbol: str6(info.symbol) ?? str6(row.symbol) ?? "",
69428
- decimals: shareDecimals
69429
- },
69430
- rate,
69431
- // The vault origin reports RAW base units + a pre-formatted convenience
69432
- // field. Carry both; fall back to formatting the raw amount ourselves so
69433
- // `formatted` — the field consumers sort on — is never silently absent.
69434
- tvl: amount(
69435
- tvl.totalAssets,
69436
- tvl.totalAssetsFormatted,
69437
- tvl.totalAssetsUsd,
69438
- assetDecimals
69439
- ),
69440
- liquidity: liq.liquidity != null || liq.liquidityUsd != null ? amount(
69441
- liq.liquidity,
69442
- liq.liquidityFormatted,
69443
- liq.liquidityUsd,
69444
- assetDecimals
69445
- ) : void 0,
69446
- depositCapacity: str6(meta.depositCapacity) ?? str6(meta.maxDeposit),
69447
- maturity,
69448
- exit: {
69449
- mode: exitMode,
69450
- settlement: str6(meta.redemptionType),
69451
- cooldownSecs: num14(meta.withdrawalCooldownSeconds),
69452
- feeBps: num14(meta.withdrawFeeBps)
69453
- },
69454
- availability,
69455
- risk: {
69456
- yieldProfile: yieldProfile(info.yieldProfile),
69457
- denomination: denomination(info.denomination),
69458
- // The curated trust classification, where one exists. Typed on `EarnRisk`
69459
- // since the surface was written and never populated — a tranche's
69460
- // first-loss position is the term most worth surfacing on a rate list.
69461
- counterparty: str6(meta.solvency),
69462
- score: num14(row.rating?.score),
69463
- label: str6(row.rating?.level),
69464
- illiquid: isIlliquid({
69465
- exitMode,
69466
- tvlUsd: num14(tvl.totalAssetsUsd),
69467
- liquidityUsd: num14(liq.liquidityUsd)
69468
- })
69469
- },
69470
- // Filled by `capabilities.ts` — kept required on the type so a normalizer
69471
- // that forgets to stamp them is a compile error, not an empty CTA.
69472
- capabilities: [],
69473
- providerMeta: row.providerMeta
69474
- };
69475
- }
69476
- function ratePercent(value, provider, fractionProviders = FRACTION_RATE_PROVIDERS) {
69477
- const n = num14(value);
69478
- if (n === void 0) return void 0;
69479
- return fractionProviders.has(provider) ? n * 100 : n;
69480
- }
69481
- function implausibleRatePercent(percent) {
69482
- return !Number.isFinite(percent) || percent < 0 || percent > 1e4;
69483
- }
69484
- function resolveRateKind(provider, meta) {
69485
- if (meta.navOracle || meta.solvency === "nav-attested") return "nav-accrual";
69486
- return RATE_KIND[provider] ?? "variable-managed";
69487
- }
69488
- function resolveAvailability(meta, maturity) {
69489
- const isMintable = meta.isMintable;
69490
- const capacity = str6(meta.depositCapacity) ?? str6(meta.maxDeposit);
69491
- const capFull = capacity === "0";
69492
- let gating;
69493
- let reason;
69494
- if (isMatured(maturity)) {
69495
- gating = "matured";
69496
- reason = "This market has reached maturity";
69497
- } else if (isMintable === false) {
69498
- gating = "allowlist-contract";
69499
- reason = "Deposits are permissioned for this vault";
69500
- } else if (capFull) {
69501
- gating = "cap-full";
69502
- reason = "Deposit cap is full";
69503
- } else if (meta.paused === true) {
69504
- gating = "paused";
69505
- reason = "Vault is paused";
69506
- }
69507
- return {
69508
- canDeposit: gating === void 0,
69509
- // Exits stay open under a deposit cap, a mint allowlist or a maturity —
69510
- // every wind-down we have integrated (Lista, dTRINITY/Sonic) keeps the
69511
- // door open outward, and a matured bond is precisely the case where the
69512
- // holder still needs out. An explicit pause is the one thing that shuts
69513
- // both.
69514
- canWithdraw: meta.paused !== true,
69515
- gating,
69516
- reason
69517
- };
69518
- }
69519
- function resolveMaturity(meta) {
69520
- const expiry = num14(meta.expiry) ?? num14(meta.maturity);
69521
- if (expiry === void 0 || expiry <= 0) return void 0;
69522
- const nowSecs = Math.floor(Date.now() / 1e3);
69523
- return {
69524
- kind: "fixed-date",
69525
- maturity: expiry,
69526
- maturityIso: str6(meta.expiryIso) ?? new Date(expiry * 1e3).toISOString(),
69527
- // A SNAPSHOT — a cached listing ages, so a countdown must be recomputed
69528
- // from `maturity` rather than ticked down from this.
69529
- secondsToMaturity: Math.max(expiry - nowSecs, 0),
69530
- // A PT simply stops earning: it redeems for the underlying at par and
69531
- // sits there. No penalty, no liquidation, no auto-roll.
69532
- atMaturity: str6(meta.atMaturity) ?? "stops-earning"
69533
- };
69534
- }
69535
- function isMatured(maturity) {
69536
- if (!maturity?.maturity) return false;
69537
- return maturity.maturity <= Math.floor(Date.now() / 1e3);
69538
- }
69539
- function amount(raw, formatted, usd, decimals) {
69540
- const rawStr = raw != null ? String(raw) : void 0;
69541
- return {
69542
- raw: rawStr,
69543
- formatted: num14(formatted) ?? formatRaw(rawStr, decimals),
69544
- usd: num14(usd)
69545
- };
69546
- }
69547
- function sum(a, b) {
69548
- if (a === void 0 && b === void 0) return void 0;
69549
- return (a ?? 0) + (b ?? 0);
69550
- }
69551
-
69552
69616
  // src/earn/fromPool.ts
69553
69617
  var FIXED_TERM_PREFIXES = [
69554
69618
  "EXACTLY",
@@ -69568,7 +69632,7 @@ var USER_SET_RATE_PREFIXES = [
69568
69632
  "EBISU"
69569
69633
  ];
69570
69634
  function earnMarketFromPool(row, fallbackChainId) {
69571
- const marketUid = str6(row.marketUid);
69635
+ const marketUid = str5(row.marketUid);
69572
69636
  if (!marketUid) return void 0;
69573
69637
  let earnUid;
69574
69638
  try {
@@ -69576,24 +69640,24 @@ function earnMarketFromPool(row, fallbackChainId) {
69576
69640
  } catch {
69577
69641
  return void 0;
69578
69642
  }
69579
- const chainId = str6(row.chainId) ?? fallbackChainId;
69580
- const venue = str6(row.lender) ?? str6(row.lenderKey);
69643
+ const chainId = str5(row.chainId) ?? fallbackChainId;
69644
+ const venue = str5(row.lender) ?? str5(row.lenderKey);
69581
69645
  if (!chainId || !venue) return void 0;
69582
69646
  const flags = row.flags ?? {};
69583
69647
  const assetInfo = row.underlyingInfo?.asset ?? row.asset ?? {};
69584
69648
  const underlying = addr2(assetInfo.address) ?? addr2(row.underlying) ?? addr2(row.poolId);
69585
69649
  if (!underlying) return void 0;
69586
- const decimals = num14(assetInfo.decimals) ?? num14(row.decimals) ?? 18;
69587
- const priceUsd = num14(row.underlyingInfo?.prices?.priceUsd) ?? num14(row.price);
69588
- const base = num14(row.depositRate);
69589
- const intrinsic = num14(row.intrinsicYield);
69650
+ const decimals = num12(assetInfo.decimals) ?? num12(row.decimals) ?? 18;
69651
+ const priceUsd = num12(row.underlyingInfo?.prices?.priceUsd) ?? num12(row.price);
69652
+ const base = num12(row.depositRate);
69653
+ const intrinsic = num12(row.intrinsicYield);
69590
69654
  const rewards = sumRewardAprs(row.rewards);
69591
69655
  const marketOwn = sum2(base, rewards);
69592
69656
  const rate = {
69593
69657
  // Prefer our own sum over the origin's `apr`, because `apr` is documented
69594
69658
  // as `depositRate + intrinsicYield` and therefore EXCLUDES incentives —
69595
69659
  // using it as the headline would under-report every incentivized market.
69596
- total: sum2(base, intrinsic, rewards) ?? num14(row.apr) ?? 0,
69660
+ total: sum2(base, intrinsic, rewards) ?? num12(row.apr) ?? 0,
69597
69661
  base,
69598
69662
  rewards,
69599
69663
  intrinsic,
@@ -69611,15 +69675,15 @@ function earnMarketFromPool(row, fallbackChainId) {
69611
69675
  // The family brand ('Morpho Blue'), not the per-market key. The specific
69612
69676
  // market identity survives on `name`.
69613
69677
  brand: venueBrand(venue),
69614
- name: str6(row.name),
69678
+ name: str5(row.name),
69615
69679
  // Never re-derived — the uid's third segment as the origin minted it.
69616
69680
  ref: marketUid.split(":")[2],
69617
- logoURI: str6(assetInfo.logoURI),
69681
+ logoURI: str5(assetInfo.logoURI),
69618
69682
  asset: {
69619
69683
  address: underlying,
69620
- symbol: str6(assetInfo.symbol) ?? "",
69684
+ symbol: str5(assetInfo.symbol) ?? "",
69621
69685
  decimals,
69622
- assetGroup: str6(row.underlyingInfo?.assetGroup) ?? str6(row.asset?.assetGroup),
69686
+ assetGroup: str5(row.underlyingInfo?.assetGroup) ?? str5(row.asset?.assetGroup),
69623
69687
  priceUsd
69624
69688
  },
69625
69689
  // A lending supply position is an aToken/cToken/eToken balance, but the
@@ -69640,7 +69704,7 @@ function earnMarketFromPool(row, fallbackChainId) {
69640
69704
  row.totalLiquidityUSD ?? row.totalLiquidityUsd
69641
69705
  ),
69642
69706
  depositCapacity: void 0,
69643
- utilization: num14(row.utilization),
69707
+ utilization: num12(row.utilization),
69644
69708
  // Lending withdrawals are same-block, bounded by available liquidity —
69645
69709
  // which is exactly `instant-capped`, not `instant`. A pool at 100 %
69646
69710
  // utilization cannot be exited, and calling that `instant` is the kind of
@@ -69648,12 +69712,12 @@ function earnMarketFromPool(row, fallbackChainId) {
69648
69712
  exit: { mode: "instant-capped", settlement: "sync" },
69649
69713
  availability,
69650
69714
  risk: {
69651
- score: num14(row.risk?.score),
69652
- label: str6(row.risk?.label),
69715
+ score: num12(row.risk?.score),
69716
+ label: str5(row.risk?.label),
69653
69717
  illiquid: isIlliquid({
69654
69718
  exitMode: "instant-capped",
69655
- tvlUsd: num14(row.totalDepositsUSD ?? row.totalDepositsUsd),
69656
- liquidityUsd: num14(row.totalLiquidityUSD ?? row.totalLiquidityUsd)
69719
+ tvlUsd: num12(row.totalDepositsUSD ?? row.totalDepositsUsd),
69720
+ liquidityUsd: num12(row.totalLiquidityUSD ?? row.totalLiquidityUsd)
69657
69721
  })
69658
69722
  },
69659
69723
  capabilities: [],
@@ -69708,9 +69772,9 @@ function resolveAvailability2(row, flags, totalRate) {
69708
69772
  };
69709
69773
  }
69710
69774
  function isSupplyCapFull(row) {
69711
- const cap = num14(row.caps?.supplyCap) ?? num14(row.supplyCap);
69775
+ const cap = num12(row.caps?.supplyCap) ?? num12(row.supplyCap);
69712
69776
  if (cap === void 0 || cap <= 0) return false;
69713
- const deposits = num14(row.totalDeposits);
69777
+ const deposits = num12(row.totalDeposits);
69714
69778
  if (deposits === void 0) return false;
69715
69779
  return deposits >= cap;
69716
69780
  }
@@ -69719,7 +69783,7 @@ function sumRewardAprs(rewards) {
69719
69783
  let total = 0;
69720
69784
  let seen = false;
69721
69785
  for (const r of rewards) {
69722
- const apr = num14(r?.depositRate);
69786
+ const apr = num12(r?.depositRate);
69723
69787
  if (apr === void 0) continue;
69724
69788
  total += apr;
69725
69789
  seen = true;
@@ -69727,14 +69791,12 @@ function sumRewardAprs(rewards) {
69727
69791
  return seen ? total : void 0;
69728
69792
  }
69729
69793
  function amount2(formatted, usd) {
69730
- return { formatted: num14(formatted), usd: num14(usd) };
69794
+ return { formatted: num12(formatted), usd: num12(usd) };
69731
69795
  }
69732
69796
  function sum2(...parts) {
69733
69797
  const present = parts.filter((p) => p !== void 0);
69734
69798
  return present.length ? present.reduce((a, b) => a + b, 0) : void 0;
69735
69799
  }
69736
-
69737
- // src/earn/capabilities.ts
69738
69800
  var ASYNC_EXIT_MODES = /* @__PURE__ */ new Set([
69739
69801
  "fixed-cooldown",
69740
69802
  "request-based",
@@ -69789,9 +69851,11 @@ function vaultCapabilities(row) {
69789
69851
  const caps = [];
69790
69852
  if (SWAP_ROUTED_PROVIDERS.has(provider)) return swapRoutedCapabilities(row);
69791
69853
  if (row.availability.canDeposit) {
69854
+ const inputs = depositInputs(row, provider);
69792
69855
  caps.push({
69793
69856
  action: "deposit",
69794
- requires: depositRequires(provider, meta),
69857
+ inputs,
69858
+ requires: depositRequires(provider, meta, inputs),
69795
69859
  // Phase 3 flips this to `true` once the `vault.*` venues are registered
69796
69860
  // with the conversion solver. Advertising it before the route can serve
69797
69861
  // it would be worse than the current gap — a client would build a zap
@@ -69803,13 +69867,14 @@ function vaultCapabilities(row) {
69803
69867
  const mode = row.exit.mode;
69804
69868
  const isAsync = ASYNC_PROVIDERS.has(provider) || ASYNC_EXIT_MODES.has(mode);
69805
69869
  if (!isAsync) {
69806
- caps.push({ action: "withdraw" });
69870
+ caps.push({ action: "withdraw", requires: withdrawRequires(provider) });
69807
69871
  return caps;
69808
69872
  }
69809
69873
  if (mode === "fee-or-queued" && meta.instantRedeemEnabled !== false) {
69810
69874
  caps.push({
69811
69875
  action: "withdraw",
69812
- feeBps: num14(meta.withdrawFeeBps) ?? row.exit.feeBps
69876
+ requires: withdrawRequires(provider),
69877
+ feeBps: num12(meta.withdrawFeeBps) ?? row.exit.feeBps
69813
69878
  });
69814
69879
  }
69815
69880
  caps.push({
@@ -69827,14 +69892,58 @@ function vaultCapabilities(row) {
69827
69892
  }
69828
69893
  return caps;
69829
69894
  }
69830
- function depositRequires(provider, meta) {
69895
+ function isBookPriced(provider) {
69896
+ const risk = vaultTraits(provider)?.priceRisk;
69897
+ return risk === "market-price" || risk === "may-be-impossible";
69898
+ }
69899
+ function swapRoutedProvidersArePriceConsistent() {
69900
+ return [...SWAP_ROUTED_PROVIDERS].filter((p) => !isBookPriced(p));
69901
+ }
69902
+ function depositInputs(row, provider) {
69903
+ if (provider !== "lst") return void 0;
69904
+ const share = row.shareToken?.address ?? row.ref;
69905
+ if (!share) return void 0;
69906
+ try {
69907
+ const accepted = getLstAcceptedInputs(row.chainId, share);
69908
+ if (!accepted?.length) return void 0;
69909
+ return accepted.map((a) => ({
69910
+ asset: String(a.asset),
69911
+ symbol: a.symbol,
69912
+ mode: a.mode,
69913
+ needs: a.needs,
69914
+ optional: a.optional
69915
+ }));
69916
+ } catch {
69917
+ return void 0;
69918
+ }
69919
+ }
69920
+ function isBoundNeed(need) {
69921
+ return /^min/i.test(need);
69922
+ }
69923
+ function depositRequires(provider, meta, inputs) {
69831
69924
  const requires = [];
69832
69925
  if (meta.delegation) requires.push("validator");
69833
69926
  if (provider === "gmx") requires.push("executionFee");
69927
+ if (isBookPriced(provider)) requires.push("slippage");
69928
+ if (inputs?.length) {
69929
+ const common = inputs[0].needs?.filter(
69930
+ (n) => inputs.every((i) => i.needs?.includes(n))
69931
+ );
69932
+ for (const n of common ?? []) if (!requires.includes(n)) requires.push(n);
69933
+ }
69934
+ return requires.length ? requires : void 0;
69935
+ }
69936
+ function withdrawRequires(provider) {
69937
+ const requires = [];
69938
+ if (isBookPriced(provider)) requires.push("slippage");
69939
+ if (provider === "gmx") requires.push("executionFee");
69834
69940
  return requires.length ? requires : void 0;
69835
69941
  }
69836
69942
  function requestRequires(provider) {
69837
- return provider === "gmx" ? ["executionFee"] : void 0;
69943
+ const requires = [];
69944
+ if (provider === "gmx") requires.push("executionFee");
69945
+ if (isBookPriced(provider)) requires.push("slippage");
69946
+ return requires.length ? requires : void 0;
69838
69947
  }
69839
69948
  function claimRequires(provider) {
69840
69949
  return void 0;
@@ -69844,6 +69953,6 @@ function supportsCancel(provider, meta) {
69844
69953
  return typeof meta.withdrawQueue === "string" && meta.withdrawQueue.length > 0;
69845
69954
  }
69846
69955
 
69847
- export { ApiBookSource, DEFAULT_MIDNIGHT_API, DEFAULT_OUTLIER_GUARD, DEFAULT_PROFILE_ID, DEFAULT_STALE_REJECT_SECONDS, DEFAULT_TERMMAX_API, EARN_DESCRIPTIONS, EARN_LABELS, EMPTY_BALANCE, EXACTLY_LENDER_KEY, FRACTION_RATE_PROVIDERS, GMX_API_HOSTS, GMX_READ_CONTRACTS, GMX_SUPPORTED_CHAINS, HYPERCORE_VAULT_REGISTRY, IDLE_MARKET_ID, INTERFACE_IDS, LAGOON_API_URL, LAGOON_CHAIN_IDS, MORPHO_LENS, MULTICALL_FAILURE, MaxParamThresholds, PASSTHROUGH_RATE_EPSILON, PENDLE_ASSETS_URL, PENDLE_CHAIN_IDS, PENDLE_MARKETS_URL, SDK_FRACTION_RATE_PROVIDERS, STABLECOIN_SYMBOLS, STCELO_MANAGER_ADDRESS, TELLER_CALLS_PER_BID, TERMMAX_CALLS_PER_ACCOUNT, DECIMAL_BASE as TERMMAX_DECIMAL_BASE, TERMMAX_LIQUIDATION_PENALTY, TERMMAX_LIQUIDATION_WINDOW_SECS, TERMMAX_LIQUIDATOR_BONUS, TERMMAX_PARTIAL_CLOSE_FACTOR, TERMMAX_PARTIAL_LIQUIDATION_THRESHOLD_USD, TERM_ADAPTERS, TERM_PROFILES, TERM_SHEET_SCHEMA_VERSION, TermMaxApiSource, TermSubgraphSource, UPSHIFT_CHAIN_IDS, UPSHIFT_VAULTS_URL, VAULT_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, buildLiquityUserCall, buildLoopResult, buildMorphoTypeCall, buildMorphoTypeUserCallWithLens, buildPortfolioTotals, buildSumerAccumulators, buildSummaries, buildTellerUserCall, buildTermMaxUserCall, buildTermSheet, buildTermSheetsForGroup, buildVaultEarnUid, buildVaultLookup, buildVaultTermSheet, calculateLeverage, calculateNetApr, calculateOverallNetApr, calculateWeightedAverage, classifyFreshness, classifyReliability, classifyVault, clearPendleMarketsCache, collectFeedObservations, computeBorrowDelta2 as computeBorrowDelta, computeCloseTradeDeltas, computeCollateralSwapDeltas, computeDebtSwapDeltas, computeDepositDelta2 as computeDepositDelta, computeEModeAnalysis, computeOpenTradeDeltas, computePostTradeMetrics, computeRepayDelta2 as computeRepayDelta, computeSumerBorrowDelta, computeSumerDepositDelta, computeSumerRepayDelta, computeSumerWaterfall, computeSumerWithdrawDelta, computeVaultApr, computeWithdrawDelta2 as computeWithdrawDelta, computeZapTradeDeltas, consensusReference, convertDssMarketsToResponse, convertExactlyMarketsToResponse, convertFrankencoinMarketsToResponse, convertFraxlendPairsToResponse, convertInverseMarketsToResponse, convertLenderUserDataResult, convertLiquityMarketsToResponse, convertLlamaLendMarketsToResponse, convertResupplyMarketsToResponse, convertRiverMarketsToResponse, convertTellerMarketsToResponse, convertTermMarketsToResponse, convertTermMaxMarketsToResponse, convertUsddMarketsToResponse, createMarketUid, createMidnightBookSource, createMulticallRpcCall, createRawRpcCalls, createTermBookSource, createTermMaxDataSource, decodeListaMarkets, decodeMarkets, decodePackedListaUserDataset, decodePackedMorphoUserDataset, deriveBorrowTags, deriveSupplyTags, detectInterfaceKinds, dssIlkBytes32, dssKeyParts, dssLenderKey, duration, earnDescription, earnLabel, earnMarketFromPool, earnMarketFromVault, earnMarketLabel, earnUidFromMarketUid, earnVenueKind, encodeBalanceFetcherCalldata, enrichTermSheet, enrichmentIndexFromRows, exactlyPairLtv, exactlyPenaltyRateToAprPercent, exactlyWadRateToPercent, feePhrase, feedKeyOf, feedStatKey, fetchDolomiteAccountNumbers, fetchDssMarkets, fetchEulerEarnVaults, fetchEulerEarnVaultsFromSubgraph, fetchEulerSubAccountIndexes, fetchExactlyMarkets, fetchFlashLiquidityForChain, fetchFluidFTokens, fetchFrankencoinMarkets, fetchFraxlendPairs, fetchGeneralYields, fetchGeneralYieldsByMarketUid, fetchGmxExecutionFees, fetchGmxTickerPrices, fetchGmxVaults, fetchHypercoreVaults, fetchInverseMarkets, fetchLagoonApiVaults, fetchLagoonVaults, fetchLiquityMarkets, fetchListaVaultsFromChain, fetchLlamaLendMarkets, fetchMorphoUserBalances, fetchMorphoUserPositionMarkets, fetchMorphoVaults, fetchMorphoVaultsFromApi, fetchMorphoVaultsFromChain, fetchOraclePrices, fetchPendleApiAssets, fetchPendleApiMarkets, fetchPendlePrices, fetchPendlePtMarkets, fetchResupplyMarkets, fetchRiverMarkets, fetchSiloVaults, fetchTellerMarkets, fetchTermMarkets, fetchTermMaxMarkets, fetchTokenBalances, fetchTokenMetadata, fetchUpshiftApiVaults, fetchUpshiftVaults, fetchUsddMarkets, fetchYearnApiVaults, fetchYearnVaults, filterActiveLenders, filterLendersByProtocol, finalizeInfo, findingsFor, formatRaw, frankencoinKeyParts, frankencoinLenderKey, fraxlendAssetPerCollateral, fraxlendKeyParts, fraxlendLenderKey, fuseLenderData, generateLendingPools, getAavesForChain, getAssetConfig, getBalanceForMarketUid, getBorrowCapacity, getCachedLiquityTroves, getCachedTellerBids, getCachedTermMaxDiscovery, getCachedTermMaxMarket, getCachedTermMaxMarkets, getCoreValidators, getFluidFTokensConverter, getGmxApiHost, getGmxReadContracts, getGmxUserPositions, getHealthFactor, getHypercoreUserPositions, getHypercoreVaultRegistry, getLenderAssets, getLenderPublicData, getLenderPublicDataAll, getLenderPublicDataViaApi, getLenderUserDataMulti, getLenderUserDataResult, getLendersForChain, getLstDelegation, getLstValidators, getLstWithdrawalRegistry, getLstWithdrawalRequests, getMaxAmountClose, getMaxAmountCollateralSwap, getMaxAmountDebtSwap, getMaxAmountOpen, getMergedUserData, getMorphoTypeMarketConverter, getReadFailurePolicy, getResolvedDolomiteAccountNumbers, getStCeloValidatorGroups, getSubAccountAddress, getSubAccountIndex, getTermProfile, getVaultPublicDataAll, getVaultWithdrawalRequests, hasCritical, hasEulerEarnVaultSubgraph, hasLagoonVaults, hasMorphoPositionIndex, hasMorphoUserApi, hasMorphoUserSubgraph, hasPendleMarkets, hasUpshiftVaults, hasYearnVaults, ilkToKeySegment, implausibleRatePercent, inverseKeyParts, inverseLenderKey, isFailedCall, isIlliquid, isLiveMarket as isLivePendleMarket, isStablecoinSymbol, isVaultVenue, isYearnV3, keySegmentToIlk, keysFromMaps, lenderApiOnly, lenderFamily, liquityCandidateTroveIds, liquityKeyParts, liquityLenderKey, llamaLendKeyParts, llamaLendLenderKey, mergeDeep, multicall3Abi2 as multicall3Abi, nanTo, needsLenderApproval, needsTokenApproval, noOpResult, normalizeToBytes, parseBalanceFetcherResult, parseEarnUid, parseMergedResult, parseMulticallRpcResponses, parseExpirySeconds as parsePendleExpirySeconds, parseRawRpcBatchResponses, parseRawRpcResponses, parseTermMaxLtv, parseTokenBalanceResult, pct, assetKey as pendleAssetKey, positivePart2 as positivePart, predictInverseEscrow, prepareLenderUserDataRpcCalls, prepareMergedMulticallParams, prepareMergedRpcCalls, prepareMulticallInputs, prepareTokenBalanceRpcCalls, priceGlvVaults, priceGmMarkets, probeAaveFeedTimestamps, pruneFeedStats, rankFindings, ratePercent, readVaultSharePrices, rejectOutliers as rejectPriceOutliers, resolveAdapter, resolveDerivation, resolveStCeloDepositGroup, resolveVaultProfileId, resupplyKeyParts, resupplyLenderKey, resupplyMarketLabel, riverKeyParts, riverLenderKey, selectAssetGroupPrices, shortDate, splitChainScopedAddress as splitPendleChainScopedAddress, stampCapabilities, stampVaultClassification, stampVaultTermSheets, supplyDescription, supplyFindings, supplyHeadline, tellerBpsToPercent, tellerImpliedLtv, tellerLenderKey, tellerPoolFromLenderKey, termLenderKey, termMaxApiBase, borrowNif as termMaxBorrowNif, curveApr as termMaxCurveApr, curveAprNumber as termMaxCurveAprNumber, daysToMaturity as termMaxDaysToMaturity, lendNif as termMaxLendNif, mintGtFeeRatio as termMaxMintGtFeeRatio, ratioToNumber as termMaxRatioToNumber, ratioToPercent as termMaxRatioToPercent, tickToAprNumber, tickToPrice, toDigest, toTermSheetInput, toVaultTermInput, tryParseEarnUid, unflattenLenderData, updateFeedStats, usdValue, usddIlkBytes32, usddKeyParts, usddLenderKey, validateTermSheet, validateTermSheets, validateUserData, vaultTermInputFromEarnMarket, vaultTermInputFromSourceRow, vaultTraits, vaultVenue, venueBrand };
69956
+ export { ApiBookSource, DEFAULT_MIDNIGHT_API, DEFAULT_OUTLIER_GUARD, DEFAULT_PROFILE_ID, DEFAULT_STALE_REJECT_SECONDS, DEFAULT_TERMMAX_API, EARN_DESCRIPTIONS, EARN_LABELS, EMPTY_BALANCE, EXACTLY_LENDER_KEY, FRACTION_RATE_PROVIDERS, GMX_API_HOSTS, GMX_READ_CONTRACTS, GMX_SUPPORTED_CHAINS, HYPERCORE_VAULT_REGISTRY, IDLE_MARKET_ID, INTERFACE_IDS, LAGOON_API_URL, LAGOON_CHAIN_IDS, MORPHO_LENS, MULTICALL_FAILURE, MaxParamThresholds, PASSTHROUGH_RATE_EPSILON, PENDLE_ASSETS_URL, PENDLE_CHAIN_IDS, PENDLE_MARKETS_URL, SDK_FRACTION_RATE_PROVIDERS, STABLECOIN_SYMBOLS, STCELO_MANAGER_ADDRESS, TELLER_CALLS_PER_BID, TERMMAX_CALLS_PER_ACCOUNT, DECIMAL_BASE as TERMMAX_DECIMAL_BASE, TERMMAX_LIQUIDATION_PENALTY, TERMMAX_LIQUIDATION_WINDOW_SECS, TERMMAX_LIQUIDATOR_BONUS, TERMMAX_PARTIAL_CLOSE_FACTOR, TERMMAX_PARTIAL_LIQUIDATION_THRESHOLD_USD, TERM_ADAPTERS, TERM_PROFILES, TERM_SHEET_SCHEMA_VERSION, TermMaxApiSource, TermSubgraphSource, UPSHIFT_CHAIN_IDS, UPSHIFT_VAULTS_URL, VAULT_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, buildLiquityUserCall, buildLoopResult, buildMorphoTypeCall, buildMorphoTypeUserCallWithLens, buildPortfolioTotals, buildSumerAccumulators, buildSummaries, buildTellerUserCall, buildTermMaxUserCall, buildTermSheet, buildTermSheetsForGroup, buildVaultEarnUid, buildVaultLookup, buildVaultTermSheet, calculateLeverage, calculateNetApr, calculateOverallNetApr, calculateWeightedAverage, classifyFreshness, classifyReliability, classifyVault, clearPendleMarketsCache, collectFeedObservations, computeBorrowDelta2 as computeBorrowDelta, computeCloseTradeDeltas, computeCollateralSwapDeltas, computeDebtSwapDeltas, computeDepositDelta2 as computeDepositDelta, computeEModeAnalysis, computeOpenTradeDeltas, computePostTradeMetrics, computeRepayDelta2 as computeRepayDelta, computeSumerBorrowDelta, computeSumerDepositDelta, computeSumerRepayDelta, computeSumerWaterfall, computeSumerWithdrawDelta, computeVaultApr, computeWithdrawDelta2 as computeWithdrawDelta, computeZapTradeDeltas, consensusReference, convertDssMarketsToResponse, convertExactlyMarketsToResponse, convertFrankencoinMarketsToResponse, convertFraxlendPairsToResponse, convertInverseMarketsToResponse, convertLenderUserDataResult, convertLiquityMarketsToResponse, convertLlamaLendMarketsToResponse, convertResupplyMarketsToResponse, convertRiverMarketsToResponse, convertTellerMarketsToResponse, convertTermMarketsToResponse, convertTermMaxMarketsToResponse, convertUsddMarketsToResponse, createMarketUid, createMidnightBookSource, createMulticallRpcCall, createRawRpcCalls, createTermBookSource, createTermMaxDataSource, decodeListaMarkets, decodeMarkets, decodePackedListaUserDataset, decodePackedMorphoUserDataset, deriveBorrowTags, deriveSupplyTags, detectInterfaceKinds, dssIlkBytes32, dssKeyParts, dssLenderKey, duration, earnDescription, earnLabel, earnMarketFromPool, earnMarketFromVault, earnMarketLabel, earnUidFromMarketUid, earnVenueKind, encodeBalanceFetcherCalldata, enrichTermSheet, enrichmentIndexFromRows, exactlyPairLtv, exactlyPenaltyRateToAprPercent, exactlyWadRateToPercent, feePhrase, feedKeyOf, feedStatKey, fetchDolomiteAccountNumbers, fetchDssMarkets, fetchEulerEarnVaults, fetchEulerEarnVaultsFromSubgraph, fetchEulerSubAccountIndexes, fetchExactlyMarkets, fetchFlashLiquidityForChain, fetchFluidFTokens, fetchFrankencoinMarkets, fetchFraxlendPairs, fetchGeneralYields, fetchGeneralYieldsByMarketUid, fetchGmxExecutionFees, fetchGmxTickerPrices, fetchGmxVaults, fetchHypercoreVaults, fetchInverseMarkets, fetchLagoonApiVaults, fetchLagoonVaults, fetchLiquityMarkets, fetchListaVaultsFromChain, fetchLlamaLendMarkets, fetchMorphoUserBalances, fetchMorphoUserPositionMarkets, fetchMorphoVaults, fetchMorphoVaultsFromApi, fetchMorphoVaultsFromChain, fetchOraclePrices, fetchPendleApiAssets, fetchPendleApiMarkets, fetchPendlePrices, fetchPendlePtMarkets, fetchResupplyMarkets, fetchRiverMarkets, fetchSiloVaults, fetchTellerMarkets, fetchTermMarkets, fetchTermMaxMarkets, fetchTokenBalances, fetchTokenMetadata, fetchUpshiftApiVaults, fetchUpshiftVaults, fetchUsddMarkets, fetchYearnApiVaults, fetchYearnVaults, filterActiveLenders, filterLendersByProtocol, finalizeInfo, findingsFor, formatRaw, frankencoinKeyParts, frankencoinLenderKey, fraxlendAssetPerCollateral, fraxlendKeyParts, fraxlendLenderKey, fuseLenderData, generateLendingPools, getAavesForChain, getAssetConfig, getBalanceForMarketUid, getBorrowCapacity, getCachedLiquityTroves, getCachedTellerBids, getCachedTermMaxDiscovery, getCachedTermMaxMarket, getCachedTermMaxMarkets, getCoreValidators, getFluidFTokensConverter, getGmxApiHost, getGmxReadContracts, getGmxUserPositions, getHealthFactor, getHypercoreUserPositions, getHypercoreVaultRegistry, getLenderAssets, getLenderPublicData, getLenderPublicDataAll, getLenderPublicDataViaApi, getLenderUserDataMulti, getLenderUserDataResult, getLendersForChain, getLstDelegation, getLstValidators, getLstWithdrawalRegistry, getLstWithdrawalRequests, getMaxAmountClose, getMaxAmountCollateralSwap, getMaxAmountDebtSwap, getMaxAmountOpen, getMergedUserData, getMorphoTypeMarketConverter, getReadFailurePolicy, getResolvedDolomiteAccountNumbers, getStCeloValidatorGroups, getSubAccountAddress, getSubAccountIndex, getTermProfile, getVaultPublicDataAll, getVaultWithdrawalRequests, hasCritical, hasEulerEarnVaultSubgraph, hasLagoonVaults, hasMorphoPositionIndex, hasMorphoUserApi, hasMorphoUserSubgraph, hasPendleMarkets, hasUpshiftVaults, hasYearnVaults, ilkToKeySegment, implausibleRatePercent, inverseKeyParts, inverseLenderKey, isBoundNeed, isFailedCall, isIlliquid, isLiveMarket as isLivePendleMarket, isStablecoinSymbol, isVaultVenue, isYearnV3, keySegmentToIlk, keysFromMaps, lenderApiOnly, lenderFamily, liquityCandidateTroveIds, liquityKeyParts, liquityLenderKey, llamaLendKeyParts, llamaLendLenderKey, mergeDeep, multicall3Abi2 as multicall3Abi, nanTo, needsLenderApproval, needsTokenApproval, noOpResult, normalizeToBytes, parseBalanceFetcherResult, parseEarnUid, parseMergedResult, parseMulticallRpcResponses, parseExpirySeconds as parsePendleExpirySeconds, parseRawRpcBatchResponses, parseRawRpcResponses, parseTermMaxLtv, parseTokenBalanceResult, pct, assetKey as pendleAssetKey, positivePart2 as positivePart, predictInverseEscrow, prepareLenderUserDataRpcCalls, prepareMergedMulticallParams, prepareMergedRpcCalls, prepareMulticallInputs, prepareTokenBalanceRpcCalls, priceGlvVaults, priceGmMarkets, probeAaveFeedTimestamps, pruneFeedStats, rankFindings, ratePercent, readVaultSharePrices, rejectOutliers as rejectPriceOutliers, resolveAdapter, resolveDerivation, resolveStCeloDepositGroup, resolveVaultProfileId, resupplyKeyParts, resupplyLenderKey, resupplyMarketLabel, riverKeyParts, riverLenderKey, selectAssetGroupPrices, shortDate, splitChainScopedAddress as splitPendleChainScopedAddress, stampCapabilities, stampVaultClassification, stampVaultTermSheets, 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, tryParseEarnUid, unflattenLenderData, updateFeedStats, usdValue, usddIlkBytes32, usddKeyParts, usddLenderKey, validateTermSheet, validateTermSheets, validateUserData, vaultTermInputFromEarnMarket, vaultTermInputFromSourceRow, vaultTraits, vaultVenue, venueBrand };
69848
69957
  //# sourceMappingURL=index.js.map
69849
69958
  //# sourceMappingURL=index.js.map