@defisaver/positions-sdk 2.1.150 → 2.1.151-midnight-1-dev

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.
@@ -71,8 +71,12 @@ export async function _getMorphoMidnightMarketData(provider: Client, network: Ne
71
71
  borrowIncentives: [],
72
72
  };
73
73
 
74
+ // `collaterals` is the full on-chain set, so `i` is the index `prices` is keyed by. Hidden entries
75
+ // (curator vaults, the loan token itself) are skipped rather than filtered out beforehand, which would
76
+ // shift every later collateral onto the wrong price.
74
77
  const collateralSymbols: string[] = [];
75
78
  collaterals.forEach((coll, i) => {
79
+ if (coll.hidden) return;
76
80
  const collInfo = getAssetInfoByAddress(coll.token, network);
77
81
  const collSym = wethToEth(collInfo.symbol);
78
82
  collateralSymbols.push(collSym);
@@ -138,8 +142,10 @@ export async function _getMorphoMidnightAccountData(provider: Client, network: N
138
142
  borrowedUsd: new Dec(debt).mul(loanTokenData.price).toString(),
139
143
  };
140
144
 
141
- // positionInfo.collateral is index-aligned with the market's collateral set (0 where unused).
145
+ // positionInfo.collateral is index-aligned with the market's full on-chain collateral set (0 where
146
+ // unused), so hidden entries are skipped in place rather than filtered out first.
142
147
  collaterals.forEach((coll, i) => {
148
+ if (coll.hidden) return;
143
149
  const collInfo = getAssetInfoByAddress(coll.token, network);
144
150
  const collSym = wethToEth(collInfo.symbol);
145
151
  const rawAmount = positionInfo.collateral[i] ? positionInfo.collateral[i].toString() : '0';
@@ -228,6 +234,7 @@ export const _getMorphoMidnightAccountBalances = async (provider: Client, networ
228
234
 
229
235
  const collateral: Record<string, string> = {};
230
236
  collaterals.forEach((coll, i) => {
237
+ if (coll.hidden) return;
231
238
  const collInfo = getAssetInfoByAddress(coll.token, network);
232
239
  const rawAmount = positionInfo.collateral[i] ? positionInfo.collateral[i].toString() : '0';
233
240
  collateral[addressMapping ? collInfo.address.toLowerCase() : wethToEth(collInfo.symbol)] = assetAmountInEth(rawAmount, wethToEth(collInfo.symbol));
@@ -39,6 +39,51 @@ export enum MorphoMidnightVersions {
39
39
  MorphoMidnightTenorCbETHWETH_20261127_Base = 'morphomidnighttenorcbethweth_20261127_base',
40
40
  MorphoMidnightTenorCbETHWETH_20261225_Base = 'morphomidnighttenorcbethweth_20261225_base',
41
41
  MorphoMidnightTenorCbETHWETH_20270129_Base = 'morphomidnighttenorcbethweth_20270129_base',
42
+ // ETHEREUM
43
+ // Sourced from the official listing at https://markets.morpho.org/fixed?chains=1
44
+ MorphoMidnightWBTCUSDC_860_20260925_Eth = 'morphomidnightwbtcusdc_860_20260925_eth',
45
+ MorphoMidnightWBTCUSDC_860_20261030_Eth = 'morphomidnightwbtcusdc_860_20261030_eth',
46
+ MorphoMidnightWBTCUSDC_860_20261127_Eth = 'morphomidnightwbtcusdc_860_20261127_eth',
47
+ MorphoMidnightWBTCUSDC_860_20261225_Eth = 'morphomidnightwbtcusdc_860_20261225_eth',
48
+ MorphoMidnightWBTCUSDC_860_20270129_Eth = 'morphomidnightwbtcusdc_860_20270129_eth',
49
+ MorphoMidnightWBTCUSDC_860_20270226_Eth = 'morphomidnightwbtcusdc_860_20270226_eth',
50
+ MorphoMidnightWBTCUSDC_860_20270326_Eth = 'morphomidnightwbtcusdc_860_20270326_eth',
51
+ MorphoMidnightCbBTCUSDC_860_20260925_Eth = 'morphomidnightcbbtcusdc_860_20260925_eth',
52
+ MorphoMidnightCbBTCUSDC_860_20261030_Eth = 'morphomidnightcbbtcusdc_860_20261030_eth',
53
+ MorphoMidnightCbBTCUSDC_860_20261127_Eth = 'morphomidnightcbbtcusdc_860_20261127_eth',
54
+ MorphoMidnightCbBTCUSDC_860_20261225_Eth = 'morphomidnightcbbtcusdc_860_20261225_eth',
55
+ MorphoMidnightCbBTCUSDC_860_20270129_Eth = 'morphomidnightcbbtcusdc_860_20270129_eth',
56
+ MorphoMidnightCbBTCUSDC_860_20270226_Eth = 'morphomidnightcbbtcusdc_860_20270226_eth',
57
+ MorphoMidnightCbBTCUSDC_860_20270326_Eth = 'morphomidnightcbbtcusdc_860_20270326_eth',
58
+ // Tenor-hosted Midnight markets (same core, different order book)
59
+ MorphoMidnightTenorReUSDUSDC_20260925_Eth = 'morphomidnighttenorreusdusdc_20260925_eth',
60
+ MorphoMidnightTenorReUSDUSDC_20261030_Eth = 'morphomidnighttenorreusdusdc_20261030_eth',
61
+ MorphoMidnightTenorReUSDUSDC_20261127_Eth = 'morphomidnighttenorreusdusdc_20261127_eth',
62
+ MorphoMidnightTenorReUSDUSDC_20261225_Eth = 'morphomidnighttenorreusdusdc_20261225_eth',
63
+ MorphoMidnightTenorSiUSDUSDC_20260925_Eth = 'morphomidnighttenorsiusdusdc_20260925_eth',
64
+ MorphoMidnightTenorSiUSDUSDC_20261030_Eth = 'morphomidnighttenorsiusdusdc_20261030_eth',
65
+ MorphoMidnightTenorSiUSDUSDC_20261127_Eth = 'morphomidnighttenorsiusdusdc_20261127_eth',
66
+ MorphoMidnightTenorSiUSDUSDC_20261225_Eth = 'morphomidnighttenorsiusdusdc_20261225_eth',
67
+ MorphoMidnightTenorStrUSDUSDC_20260925_Eth = 'morphomidnighttenorstrusdusdc_20260925_eth',
68
+ MorphoMidnightTenorStrUSDUSDC_20261030_Eth = 'morphomidnighttenorstrusdusdc_20261030_eth',
69
+ MorphoMidnightTenorStrUSDUSDC_20261127_Eth = 'morphomidnighttenorstrusdusdc_20261127_eth',
70
+ MorphoMidnightTenorStrUSDUSDC_20261225_Eth = 'morphomidnighttenorstrusdusdc_20261225_eth',
71
+ MorphoMidnightTenorUSD3USDC_20260925_Eth = 'morphomidnighttenorusd3usdc_20260925_eth',
72
+ MorphoMidnightTenorUSD3USDC_20261030_Eth = 'morphomidnighttenorusd3usdc_20261030_eth',
73
+ MorphoMidnightTenorUSD3USDC_20261127_Eth = 'morphomidnighttenorusd3usdc_20261127_eth',
74
+ MorphoMidnightTenorUSD3USDC_20261225_Eth = 'morphomidnighttenorusd3usdc_20261225_eth',
75
+ MorphoMidnightTenorWETHUSDC_20260925_Eth = 'morphomidnighttenorwethusdc_20260925_eth',
76
+ MorphoMidnightTenorWETHUSDC_20261030_Eth = 'morphomidnighttenorwethusdc_20261030_eth',
77
+ MorphoMidnightTenorWETHUSDC_20261127_Eth = 'morphomidnighttenorwethusdc_20261127_eth',
78
+ MorphoMidnightTenorWETHUSDC_20261225_Eth = 'morphomidnighttenorwethusdc_20261225_eth',
79
+ MorphoMidnightTenorWsrUSDUSDC_20260925_Eth = 'morphomidnighttenorwsrusdusdc_20260925_eth',
80
+ MorphoMidnightTenorWsrUSDUSDC_20261030_Eth = 'morphomidnighttenorwsrusdusdc_20261030_eth',
81
+ MorphoMidnightTenorWsrUSDUSDC_20261127_Eth = 'morphomidnighttenorwsrusdusdc_20261127_eth',
82
+ MorphoMidnightTenorWsrUSDUSDC_20261225_Eth = 'morphomidnighttenorwsrusdusdc_20261225_eth',
83
+ MorphoMidnightTenorWstETHWETH_20260925_Eth = 'morphomidnighttenorwstethweth_20260925_eth',
84
+ MorphoMidnightTenorWstETHWETH_20261030_Eth = 'morphomidnighttenorwstethweth_20261030_eth',
85
+ MorphoMidnightTenorWstETHWETH_20261127_Eth = 'morphomidnighttenorwstethweth_20261127_eth',
86
+ MorphoMidnightTenorWstETHWETH_20261225_Eth = 'morphomidnighttenorwstethweth_20261225_eth',
42
87
  }
43
88
 
44
89
  export type MorphoMidnightCurator = 'Morpho' | 'Tenor';
@@ -48,6 +93,13 @@ export interface MorphoMidnightCollateralParams {
48
93
  lltv: number | string,
49
94
  liquidationCursor: number | string,
50
95
  oracle: EthAddress,
96
+ /**
97
+ * A collateral the market carries on-chain but the app never surfaces: a curator's own vault share
98
+ * token (Tenor's collateral vaults) or the loan token itself (Morpho's mainnet ladders list USDC at
99
+ * 98% next to the real collateral). It is not an asset the app deals in — nothing renders, prices or
100
+ * supplies it — but it stays in `collaterals` because the market id is the hash of the full set.
101
+ */
102
+ hidden?: boolean,
51
103
  }
52
104
 
53
105
  export interface MorphoMidnightMarketData {
@@ -58,11 +110,15 @@ export interface MorphoMidnightMarketData {
58
110
  value: MorphoMidnightVersions,
59
111
  midnight: EthAddress,
60
112
  loanToken: EthAddress,
61
- collaterals: MorphoMidnightCollateralParams[],
62
113
  /**
63
- * Tenor's curated markets list the curator's own vault share token next to the real collateral.
114
+ * Every collateral the market carries on-chain, in the chain's own order which is what the id is
115
+ * hashed from, so neither the set nor the order may be rearranged. Entries the app does not deal in
116
+ * are flagged `hidden` rather than kept in a second list: their on-chain position varies per market
117
+ * (Morpho's mainnet cbBTC ladder lists USDC first, its WBTC ladder second), so a separate list can
118
+ * only be re-joined by guessing, and every positional read — `MarketInfo.prices[i]`,
119
+ * `PositionInfo.collateral[i]`, the collateral index a supply call takes — indexes into *this* array.
64
120
  */
65
- hiddenCollaterals?: MorphoMidnightCollateralParams[],
121
+ collaterals: MorphoMidnightCollateralParams[],
66
122
  maturity: number, // unix timestamp (seconds)
67
123
  rcfThreshold: number | string,
68
124
  enterGate: EthAddress,