@1delta/margin-fetcher 5.0.30 → 5.0.32

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
@@ -25437,6 +25437,25 @@ function convertFraxlendPairsToResponse(raw, chainId, prices = {}, _additionalYi
25437
25437
  isActive: true,
25438
25438
  isFrozen: depositsHalted && borrowHalted
25439
25439
  };
25440
+ entry.params = {
25441
+ market: {
25442
+ lender: lenderKey,
25443
+ name: `${p.assetSymbol} / ${p.collateralSymbol}`,
25444
+ id: p.pair.toLowerCase(),
25445
+ loanAddress: p.asset,
25446
+ collateralAddress: p.collateral,
25447
+ loanDecimals: p.assetDecimals,
25448
+ collateralDecimals: p.collateralDecimals,
25449
+ /** RAW, on the pair's own 1e5 scale — and it is ALSO the liquidation
25450
+ * threshold, so there is no separate LT to publish. */
25451
+ lltv: p.maxLtv.toString(),
25452
+ oracle: p.oracle,
25453
+ irm: p.rateContract,
25454
+ /** Whether the NATIVE loop is available on this pair right now,
25455
+ * probed live. Gate any leverage UI on this. */
25456
+ leverageEnabled: p.leverageSwapperApproved
25457
+ }
25458
+ };
25440
25459
  entry.descriptor = {
25441
25460
  pair: p.pair.toLowerCase(),
25442
25461
  symbol: p.symbol,
@@ -63953,6 +63972,10 @@ function parseMarket2(m, chainId, prices, tokenList, apiAssets, decimalsOnChain,
63953
63972
  apiAssets,
63954
63973
  decimalsOnChain
63955
63974
  );
63975
+ const apiName = typeof m.name === "string" && m.name ? m.name : void 0;
63976
+ const assetSymbol = assetMeta.symbol ?? apiName;
63977
+ const assetName = assetMeta.name ?? apiName;
63978
+ const assetLogoURI = assetMeta.logoURI ?? (typeof m.icon === "string" && m.icon ? m.icon : void 0);
63956
63979
  const decimals = ptMeta.decimals;
63957
63980
  if (decimals === void 0) return null;
63958
63981
  const assetDecimals = assetMeta.decimals ?? decimals;
@@ -64002,13 +64025,13 @@ function parseMarket2(m, chainId, prices, tokenList, apiAssets, decimalsOnChain,
64002
64025
  // everything else downstream reads); synthesize a minimal one from
64003
64026
  // Pendle's metadata otherwise, so `stampVaultClassification` still has a
64004
64027
  // symbol to read for the stable/volatile call.
64005
- asset: tokenList[underlying.address] ?? (assetMeta.symbol || assetMeta.decimals !== void 0 ? {
64028
+ asset: tokenList[underlying.address] ?? (assetSymbol || assetMeta.decimals !== void 0 ? {
64006
64029
  chainId,
64007
64030
  address: underlying.address,
64008
- symbol: assetMeta.symbol,
64009
- name: assetMeta.name,
64031
+ symbol: assetSymbol,
64032
+ name: assetName,
64010
64033
  decimals: assetDecimals,
64011
- logoURI: assetMeta.logoURI
64034
+ logoURI: assetLogoURI
64012
64035
  } : void 0),
64013
64036
  priceUsd,
64014
64037
  ptPriceUsd,
@@ -68761,15 +68784,25 @@ var liquityAdapter = {
68761
68784
  description: "Charged when the Stability Pool is empty and the debt is redistributed across the branch\u2019s other troves. Materially worse than the Stability-Pool path."
68762
68785
  } : null
68763
68786
  ].filter(Boolean);
68787
+ const isCollateralRow = input.collateralActive !== false;
68764
68788
  return {
68765
- supply: {
68789
+ supply: isCollateralRow ? {
68790
+ role: "collateral",
68791
+ availability: { opensWith: "both-legs" },
68792
+ counterparty: { kind: "cdp", solvency: "overcollateralized" }
68793
+ } : {
68766
68794
  // The Stability Pool is an earn position, never collateral.
68767
68795
  role: "yield",
68768
68796
  exit: { mode: "instant", settlement: "sync", partialAllowed: true },
68797
+ availability: { opensWith: "standalone" },
68769
68798
  counterparty: { kind: "cdp", solvency: "overcollateralized" },
68770
68799
  principal: { protected: false, risks: ["bad-debt"] }
68771
68800
  },
68772
68801
  borrow: {
68802
+ // `openTrove` takes collateral, debt AND the interest rate together, so
68803
+ // a bare borrow has no trove to draw against. Reaches the debt row
68804
+ // only — the collateral row has no borrow side to refine.
68805
+ availability: { opensWith: "both-legs" },
68773
68806
  rate: {
68774
68807
  kind: "user-set",
68775
68808
  isLocked: false,
@@ -68862,59 +68895,75 @@ var riverAdapter = {
68862
68895
  id: "river",
68863
68896
  matches: isRiver,
68864
68897
  profileId: () => "river.cdp@v1",
68865
- build: () => ({
68866
- supply: {
68867
- role: "yield",
68868
- exit: { mode: "instant", settlement: "sync", partialAllowed: true },
68869
- counterparty: { kind: "cdp", solvency: "overcollateralized" },
68870
- principal: { protected: false, risks: ["bad-debt"] }
68871
- },
68872
- borrow: {
68873
- rate: { kind: "zero-interest", isLocked: true, compounding: "none" },
68874
- debtShape: "accruing",
68875
- exit: {
68876
- earlyRepay: "free",
68877
- atMaturityCost: "accrued",
68878
- lateBehaviour: "none",
68879
- partialAllowed: true
68898
+ build: (input) => {
68899
+ const isCollateralRow = input.collateralActive !== false;
68900
+ return {
68901
+ supply: isCollateralRow ? {
68902
+ role: "collateral",
68903
+ // The trove is the position; collateral cannot exist without
68904
+ // `minNetDebt` of debt behind it, so this side never opens alone.
68905
+ availability: { opensWith: "both-legs" },
68906
+ counterparty: { kind: "cdp", solvency: "overcollateralized" }
68907
+ } : {
68908
+ // The Stability Pool: an earn position, never collateral, and
68909
+ // openable on its own — `provideToSP` needs no trove.
68910
+ role: "yield",
68911
+ exit: { mode: "instant", settlement: "sync", partialAllowed: true },
68912
+ availability: { opensWith: "standalone" },
68913
+ counterparty: { kind: "cdp", solvency: "overcollateralized" },
68914
+ principal: { protected: false, risks: ["bad-debt"] }
68880
68915
  },
68881
- liquidation: {
68882
- trigger: "price",
68883
- seizure: "proportional",
68884
- redeemable: true,
68885
- redemption: {
68886
- // Not governance and not a liquidation: any holder of the stable can
68887
- // trigger it, without permission and without targeting anyone.
68888
- trigger: "permissionless-arbitrage",
68889
- // Permissionless does NOT mean constant: it only pays the redeemer
68890
- // while the stable trades under target, which is what makes it a peg
68891
- // defence rather than a standing claim on collateral.
68892
- driver: "below-peg",
68893
- // COLLATERAL-RATIO ordered, V1-style — NOT rate-ordered.
68894
- //
68895
- // This said `lowest-rate-first`, copied from the Liquity V2 shape,
68896
- // and it was wrong twice over: River is Prisma/V1 lineage, which
68897
- // redeems against the LOWEST-COLLATERALISED troves first, and River
68898
- // charges no interest at all (`rate.kind: 'zero-interest'` above), so
68899
- // the accompanying "raise your rate" advice pointed at a control that
68900
- // does not exist on this protocol. A borrower following it would have
68901
- // done nothing while sitting first in the real queue.
68902
- order: "lowest-collateral-ratio",
68903
- // Deliberately ABSENT rather than `usd-neutral`. The V1 mechanism
68904
- // sends collateral above the redeemed debt to a surplus balance that
68905
- // the borrower must CLAIM, so whether they end up whole depends on an
68906
- // action they may not know to take see `defence`.
68907
- defence: "Add collateral or repay to raise your collateral ratio and move behind other troves in the queue. If you are redeemed, claim the leftover collateral from the surplus balance \u2014 it is not returned automatically."
68908
- }
68916
+ borrow: {
68917
+ // Opening a trove takes collateral AND debt in one call, so a bare
68918
+ // borrow has no position to draw against. Only reaches the debt row —
68919
+ // the collateral row has no borrow side for the patch to refine.
68920
+ availability: { opensWith: "both-legs" },
68921
+ rate: { kind: "zero-interest", isLocked: true, compounding: "none" },
68922
+ debtShape: "accruing",
68923
+ exit: {
68924
+ earlyRepay: "free",
68925
+ atMaturityCost: "accrued",
68926
+ lateBehaviour: "none",
68927
+ partialAllowed: true
68928
+ },
68929
+ liquidation: {
68930
+ trigger: "price",
68931
+ seizure: "proportional",
68932
+ redeemable: true,
68933
+ redemption: {
68934
+ // Not governance and not a liquidation: any holder of the stable can
68935
+ // trigger it, without permission and without targeting anyone.
68936
+ trigger: "permissionless-arbitrage",
68937
+ // Permissionless does NOT mean constant: it only pays the redeemer
68938
+ // while the stable trades under target, which is what makes it a peg
68939
+ // defence rather than a standing claim on collateral.
68940
+ driver: "below-peg",
68941
+ // COLLATERAL-RATIO ordered, V1-styleNOT rate-ordered.
68942
+ //
68943
+ // This said `lowest-rate-first`, copied from the Liquity V2 shape,
68944
+ // and it was wrong twice over: River is Prisma/V1 lineage, which
68945
+ // redeems against the LOWEST-COLLATERALISED troves first, and River
68946
+ // charges no interest at all (`rate.kind: 'zero-interest'` above), so
68947
+ // the accompanying "raise your rate" advice pointed at a control that
68948
+ // does not exist on this protocol. A borrower following it would have
68949
+ // done nothing while sitting first in the real queue.
68950
+ order: "lowest-collateral-ratio",
68951
+ // Deliberately ABSENT rather than `usd-neutral`. The V1 mechanism
68952
+ // sends collateral above the redeemed debt to a surplus balance that
68953
+ // the borrower must CLAIM, so whether they end up whole depends on an
68954
+ // action they may not know to take — see `defence`.
68955
+ defence: "Add collateral or repay to raise your collateral ratio and move behind other troves in the queue. If you are redeemed, claim the leftover collateral from the surplus balance \u2014 it is not returned automatically."
68956
+ }
68957
+ },
68958
+ counterparty: { kind: "cdp", solvency: "overcollateralized" }
68909
68959
  },
68910
- counterparty: { kind: "cdp", solvency: "overcollateralized" }
68911
- },
68912
- constraints: {
68913
- // River troves are ADDRESS-keyed there is no id to discover.
68914
- positionModel: "account",
68915
- positionIdMeaning: "Troves are keyed by owner address; there is no id."
68916
- }
68917
- })
68960
+ constraints: {
68961
+ // River troves are ADDRESS-keyed — there is no id to discover.
68962
+ positionModel: "account",
68963
+ positionIdMeaning: "Troves are keyed by owner address; there is no id."
68964
+ }
68965
+ };
68966
+ }
68918
68967
  };
68919
68968
  var inverseAdapter = {
68920
68969
  id: "inverse",
@@ -69022,8 +69071,16 @@ var llamaLendAdapter = {
69022
69071
  const ll = input.market?.llamalend ?? {};
69023
69072
  const bandLtv = ll.bandLtv && typeof ll.bandLtv === "object" ? ll.bandLtv : void 0;
69024
69073
  const hardDiscount = typeof ll.liquidationDiscount === "number" ? ll.liquidationDiscount : void 0;
69074
+ const isCollateralRow = input.collateralActive !== false;
69025
69075
  return {
69076
+ supply: {
69077
+ availability: {
69078
+ opensWith: isCollateralRow ? "both-legs" : "standalone"
69079
+ }
69080
+ },
69026
69081
  borrow: {
69082
+ // `create_loan(collateral, debt, N)` — both legs plus the band count.
69083
+ availability: { opensWith: "both-legs" },
69027
69084
  debtShape: "accruing",
69028
69085
  liquidation: {
69029
69086
  model: "soft-band",