@1delta/margin-fetcher 5.0.66 → 5.0.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -7972,6 +7972,22 @@ interface LiquidationTerms {
7972
7972
  * Aave-style escalation: the close factor rises to 1 once health falls below
7973
7973
  * this. Without it, `closeFactor: 0.5` understates the worst case.
7974
7974
  */
7975
+ /**
7976
+ * The health factor BELOW WHICH the position becomes liquidatable, when the
7977
+ * protocol's trigger is not the usual `HF < 1`.
7978
+ *
7979
+ * Added for Flying Tulip, whose `marginHfTargetBps = 12500` makes a position
7980
+ * liquidatable at **HF < 1.25** — `liquidateFlash` reverts above it. Every
7981
+ * consumer in this repo otherwise assumes `HF < 1 ⇒ liquidatable`, which
7982
+ * understates the danger zone by a quarter of a point of health on the side
7983
+ * that costs the borrower money.
7984
+ *
7985
+ * ABSENT means the ordinary `HF < 1`. Do not default it to 1 at the call
7986
+ * site — an explicit 1 and an absent field should read the same, and a
7987
+ * lender that has no health factor at all (Frankencoin's challenge game,
7988
+ * Teller's time-based default) must not acquire one by omission.
7989
+ */
7990
+ liquidationHealthFactor?: number;
7975
7991
  fullCloseBelowHealthFactor?: number;
7976
7992
  /**
7977
7993
  * `repay-to-target-hf` only: the health factor at or below which the
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { parseAbi, keccak256, encodeAbiParameters, formatEther, BaseError, erc20Abi, stringToHex, isAddress, pad, encodeFunctionData, formatUnits, getAddress, decodeFunctionResult, decodeAbiParameters, concat, parseAbiParameters, AbiEncodingLengthMismatchError, concatHex, toBytes, slice, hexToString, InvalidAddressError, boolToHex, integerRegex, numberToHex, bytesRegex, BytesSizeMismatchError, arrayRegex, UnsupportedPackedAbiType } from './chunk-JUYF2XLF.js';
2
2
  import './chunk-BYTNVMX7.js';
3
3
  import './chunk-PR4QN5HX.js';
4
- import { Lender, isExactly, isMidnight, isTerm, isTermMax, isTeller, isListaDao, isLiquityFamily, isRiver, isInverse, isCooler, isDssType, isCompoundV3Type, isFluid, isGearboxV3, isLlamaLend, isFrankencoin, isResupply, isCurvance, isTwyne, isFraxlend, isAaveV4Type, LIQUITY_FAMILY_LENDERS, isAaveType, isCompoundV3, isCompoundV2Type, isMultiMarket, isSiloV2Type, isSiloV3Type, isDolomite, isFlyingTulip, isMorphoType, isUsdd, isSky, hasCrossMarginRisk, isEulerType, isInit, isVenusType, isSumerType, AAVE_V3_LENDERS, AAVE_V2_LENDERS, isMorphoBlue, isAaveV2Type, isAaveV32Type, isAaveV3Type, isYLDR, isLista, hasSubAccounts, isTectonicType, isKineticType, isBenqiType } from '@1delta/lender-registry';
4
+ import { Lender, isExactly, isMidnight, isTerm, isTermMax, isTeller, isListaDao, isLiquityFamily, isRiver, isInverse, isCooler, isDssType, isCompoundV3Type, isFluid, isGearboxV3, isLlamaLend, isFrankencoin, isResupply, isCurvance, isFlyingTulip, isTwyne, isFraxlend, isAaveV4Type, LIQUITY_FAMILY_LENDERS, isAaveType, isCompoundV3, isCompoundV2Type, isMultiMarket, isSiloV2Type, isSiloV3Type, isDolomite, isMorphoType, isUsdd, isSky, hasCrossMarginRisk, isEulerType, isInit, isVenusType, isSumerType, AAVE_V3_LENDERS, AAVE_V2_LENDERS, isMorphoBlue, isAaveV2Type, isAaveV32Type, isAaveV3Type, isYLDR, isLista, hasSubAccounts, isTectonicType, isKineticType, isBenqiType } from '@1delta/lender-registry';
5
5
  export { hasCrossMarginRisk, isAaveType, isAaveV2Type, isAaveV32Type, isAaveV3Type, isCompoundV3, isCompoundV3Type, isInit, isMorphoType, isMultiMarket, isYLDR } from '@1delta/lender-registry';
6
6
  import { fetchTokenLists, fetchTokenList, aavePools, compoundV3Pools, initConfig, morphoPools, compoundV2Pools, eulerVaults, siloMarkets, siloV2LenderKey, siloMarketsV3, siloV3LenderKey, aaveV4Spokes, aaveV4SpokeLenderKey, fluidResolvers, gearboxResolvers, dolomiteConfigs, midnightConfig, termConfig, termMarketsByChain, exactlyConfig, flyingTulipLendersByChain, liquityLendersByChain, riverLendersByChain, inverseLendersByChain, coolerLendersByChain, llamaLendLendersByChain, usddLendersByChain, skyLendersByChain, frankencoinLendersByChain, resupplyLendersByChain, curvanceLendersByChain, fraxlendLendersByChain, twyneLendersByChain, tellerConfigByChain, tellerPoolsByChain, termMaxConfigByChain, aaveReserves, compoundV3Reserves, resolveTermApiBase, flyingTulipConfigFor, flyingTulipAssetsFor, liquityConfigFor, liquityBranchesByChain, riverConfigFor, riverChainData, termMaxApiBaseUrl, termMaxLenderKey, inverseConfigFor, inverseChainData, coolerConfigFor, llamaLendConfigFor, llamaLendChainData, llamaLendApiBaseUrl, resupplyConfigFor, fraxlendConfigFor, dssConfigFor, dssChainData, dssDebtToken, dssDebtJoin, frankencoinConfigFor, frankencoinChainData, aaveOracles, morphoTypeMarkets, resolveMidnightApiBase, llamaLendMarketByVault, getSiloV2MarketEntry, getSiloV3MarketEntry, dolomiteEmode, curvanceConfigFor, aaveTokens, morphoTypeVaults, listaCollateralProvider, eulerConfigs, gearboxMarketCompressor, gearboxMarketConfigurators, compoundV2TokenArray, gearboxV3LenderKey, midnightMarketsByChain, twyneConfigFor, twyneChainData, parseAaveV4SpokeLenderKey, fraxlendPairsFor, gearboxAccountCompressor, compoundV2Tokens, exactlyMarketsByChain, aaveOraclesConfig, compoundV2Oracles, compoundV2OraclesConfig, compoundV3OraclesData, compoundV3BaseData, compoundV2Reserves, aaveV4Oracles, morphoTypeOracles } from '@1delta/data-sdk';
7
7
  import lodash from 'lodash';
@@ -71624,6 +71624,28 @@ var TERM_PROFILES = [
71624
71624
  ]
71625
71625
  }
71626
71626
  }),
71627
+ P({
71628
+ id: "flyingTulip.crossMargin@v1",
71629
+ name: "Flying Tulip cross-margin account",
71630
+ family: "flyingTulip",
71631
+ supply: {
71632
+ description: "One cross-margin account per chain: every asset you deposit backs every asset you borrow, under a single global health check.",
71633
+ implications: [
71634
+ "The rate shown is interest only \u2014 borrowers pay it and it is shared pro rata with utilization. Flying Tulip also pays an FT token emission on deposits that is NOT included here, so the figure is a floor, not the whole return.",
71635
+ "A withdrawal is checked against the same health gate as a borrow: it must leave your account at a health factor of 1.50 or better, so a deposit that is backing debt is not freely withdrawable.",
71636
+ "While you hold any debt your account must keep a minimum equity in USD \u2014 $250 on Ethereum, $10 on Sonic \u2014 which can block a withdrawal that would take you under it."
71637
+ ]
71638
+ },
71639
+ borrow: {
71640
+ description: "Borrow any listed asset against your whole account. There is no per-market LTV: the requirement is charged on your debt as well as your collateral, so how much you can borrow depends on the PAIR.",
71641
+ implications: [
71642
+ "Liquidation starts at a health factor below 1.25, NOT below 1.0 \u2014 you are liquidatable a quarter of a point earlier than on an ordinary lending market.",
71643
+ "A new borrow must leave you at 1.50 or better, so a position opened at the limit sits only 0.25 of health above liquidation from the moment it opens.",
71644
+ "Your account must hold a minimum equity in USD for as long as any debt exists ($250 on Ethereum, $10 on Sonic).",
71645
+ "Repayment is never blocked and anyone may repay on your behalf \u2014 there is no cooldown, freeze or queue on the way out."
71646
+ ]
71647
+ }
71648
+ }),
71627
71649
  P({
71628
71650
  id: "twyne.credit-delegation@v1",
71629
71651
  name: "Twyne credit delegation",
@@ -76608,6 +76630,74 @@ var curvanceAdapter = {
76608
76630
  function numOrUndef(v) {
76609
76631
  return typeof v === "number" && Number.isFinite(v) ? v : void 0;
76610
76632
  }
76633
+ function numOrUndef2(v) {
76634
+ if (typeof v === "number" && Number.isFinite(v)) return v;
76635
+ if (typeof v === "string" && /^\d+$/.test(v)) return Number(v);
76636
+ return void 0;
76637
+ }
76638
+ function wadUsd(v) {
76639
+ const s = typeof v === "bigint" || typeof v === "number" ? String(v) : v;
76640
+ if (typeof s !== "string" || !/^\d+$/.test(s)) return void 0;
76641
+ const n = Number(BigInt(s) / 10n ** 14n) / 1e4;
76642
+ return Number.isFinite(n) && n > 0 ? n : void 0;
76643
+ }
76644
+ var flyingTulipAdapter = {
76645
+ id: "flying-tulip",
76646
+ matches: isFlyingTulip,
76647
+ profileId: () => "flyingTulip.crossMargin@v1",
76648
+ build: (input) => {
76649
+ const ft = input.market?.flyingTulip ?? {};
76650
+ const hfTargetBps = numOrUndef2(ft.hfTargetBps);
76651
+ numOrUndef2(ft.hfSafeBps);
76652
+ wadUsd(ft.minEquityUSDWad);
76653
+ const liqHf = hfTargetBps != null ? hfTargetBps / 1e4 : void 0;
76654
+ return {
76655
+ constraints: {
76656
+ // One account per address per chain, spanning every asset — there is
76657
+ // no per-market position and no id.
76658
+ positionModel: "account",
76659
+ positionIdMeaning: "the borrower address itself \u2014 one cross-margin account per chain covering every asset, with a single global health check",
76660
+ crossMargin: true
76661
+ // NOTE the USD equity floor ($250 Ethereum / $10 Sonic) has no
76662
+ // structured slot — `availability.minSize` is a DEBT floor in asset
76663
+ // units and this is an EQUITY floor in USD, so putting it there would
76664
+ // be read as the wrong gate on the wrong quantity. It is stated in the
76665
+ // profile prose instead, and the raw value stays on
76666
+ // `params.market.flyingTulip.minEquityUSDWad` for a caller that needs
76667
+ // to gate on it.
76668
+ },
76669
+ borrow: {
76670
+ debtShape: "accruing",
76671
+ // The HF >= 1.50 open gate likewise has no structured slot; it is in
76672
+ // the profile prose. `availability` here carries no minimum size —
76673
+ // Flying Tulip has none on the debt leg.
76674
+ exit: {
76675
+ // Repay is always open — `repayFor` is permissionless, so a third
76676
+ // party can rescue the account, and nothing gates or delays it.
76677
+ partialAllowed: true,
76678
+ cooldownSecs: void 0
76679
+ },
76680
+ ...liqHf != null ? {
76681
+ liquidation: {
76682
+ model: "partial",
76683
+ trigger: "price",
76684
+ // THE correction. Everything else in this repo may assume
76685
+ // `HF < 1 ⇒ liquidatable`; here the protocol reverts above
76686
+ // 1.25, so the position is liquidatable a quarter of a point
76687
+ // of health EARLIER than the default reading.
76688
+ liquidationHealthFactor: liqHf
76689
+ }
76690
+ } : {}
76691
+ },
76692
+ supply: {
76693
+ exit: {
76694
+ // A withdrawal is checked against the SAME open gate as a borrow
76695
+ // (HF >= 1.50) and against the equity floor.
76696
+ }
76697
+ }
76698
+ };
76699
+ }
76700
+ };
76611
76701
  var num16 = (v) => typeof v === "number" && Number.isFinite(v) ? v : void 0;
76612
76702
  var pct2 = (v) => `${(v * 100).toFixed(2)} %`;
76613
76703
  var twyneAdapter = {
@@ -76823,6 +76913,7 @@ var TERM_ADAPTERS = [
76823
76913
  frankencoinAdapter,
76824
76914
  resupplyAdapter,
76825
76915
  curvanceAdapter,
76916
+ flyingTulipAdapter,
76826
76917
  twyneAdapter,
76827
76918
  fraxlendAdapter,
76828
76919
  morphoBlueAdapter,