@defisaver/positions-sdk 2.1.151 → 2.1.152

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.
@@ -67,8 +67,13 @@ export function _getMorphoMidnightMarketData(provider, network, selectedMarket)
67
67
  supplyIncentives: [],
68
68
  borrowIncentives: [],
69
69
  };
70
+ // `collaterals` is the full on-chain set, so `i` is the index `prices` is keyed by. Hidden entries
71
+ // (curator vaults, the loan token itself) are skipped rather than filtered out beforehand, which would
72
+ // shift every later collateral onto the wrong price.
70
73
  const collateralSymbols = [];
71
74
  collaterals.forEach((coll, i) => {
75
+ if (coll.hidden)
76
+ return;
72
77
  const collInfo = getAssetInfoByAddress(coll.token, network);
73
78
  const collSym = wethToEth(collInfo.symbol);
74
79
  collateralSymbols.push(collSym);
@@ -131,8 +136,11 @@ export function _getMorphoMidnightAccountData(provider, network, account, select
131
136
  suppliedUsd: new Dec(credit).mul(loanTokenData.price).toString(),
132
137
  borrowedUsd: new Dec(debt).mul(loanTokenData.price).toString(),
133
138
  };
134
- // positionInfo.collateral is index-aligned with the market's collateral set (0 where unused).
139
+ // positionInfo.collateral is index-aligned with the market's full on-chain collateral set (0 where
140
+ // unused), so hidden entries are skipped in place rather than filtered out first.
135
141
  collaterals.forEach((coll, i) => {
142
+ if (coll.hidden)
143
+ return;
136
144
  const collInfo = getAssetInfoByAddress(coll.token, network);
137
145
  const collSym = wethToEth(collInfo.symbol);
138
146
  const rawAmount = positionInfo.collateral[i] ? positionInfo.collateral[i].toString() : '0';
@@ -212,6 +220,8 @@ export const _getMorphoMidnightAccountBalances = (provider, network, block, addr
212
220
  };
213
221
  const collateral = {};
214
222
  collaterals.forEach((coll, i) => {
223
+ if (coll.hidden)
224
+ return;
215
225
  const collInfo = getAssetInfoByAddress(coll.token, network);
216
226
  const rawAmount = positionInfo.collateral[i] ? positionInfo.collateral[i].toString() : '0';
217
227
  collateral[addressMapping ? collInfo.address.toLowerCase() : wethToEth(collInfo.symbol)] = assetAmountInEth(rawAmount, wethToEth(collInfo.symbol));
@@ -31,7 +31,49 @@ export declare enum MorphoMidnightVersions {
31
31
  MorphoMidnightTenorCbETHWETH_20261030_Base = "morphomidnighttenorcbethweth_20261030_base",
32
32
  MorphoMidnightTenorCbETHWETH_20261127_Base = "morphomidnighttenorcbethweth_20261127_base",
33
33
  MorphoMidnightTenorCbETHWETH_20261225_Base = "morphomidnighttenorcbethweth_20261225_base",
34
- MorphoMidnightTenorCbETHWETH_20270129_Base = "morphomidnighttenorcbethweth_20270129_base"
34
+ MorphoMidnightTenorCbETHWETH_20270129_Base = "morphomidnighttenorcbethweth_20270129_base",
35
+ MorphoMidnightWBTCUSDC_860_20260925_Eth = "morphomidnightwbtcusdc_860_20260925_eth",
36
+ MorphoMidnightWBTCUSDC_860_20261030_Eth = "morphomidnightwbtcusdc_860_20261030_eth",
37
+ MorphoMidnightWBTCUSDC_860_20261127_Eth = "morphomidnightwbtcusdc_860_20261127_eth",
38
+ MorphoMidnightWBTCUSDC_860_20261225_Eth = "morphomidnightwbtcusdc_860_20261225_eth",
39
+ MorphoMidnightWBTCUSDC_860_20270129_Eth = "morphomidnightwbtcusdc_860_20270129_eth",
40
+ MorphoMidnightWBTCUSDC_860_20270226_Eth = "morphomidnightwbtcusdc_860_20270226_eth",
41
+ MorphoMidnightWBTCUSDC_860_20270326_Eth = "morphomidnightwbtcusdc_860_20270326_eth",
42
+ MorphoMidnightCbBTCUSDC_860_20260925_Eth = "morphomidnightcbbtcusdc_860_20260925_eth",
43
+ MorphoMidnightCbBTCUSDC_860_20261030_Eth = "morphomidnightcbbtcusdc_860_20261030_eth",
44
+ MorphoMidnightCbBTCUSDC_860_20261127_Eth = "morphomidnightcbbtcusdc_860_20261127_eth",
45
+ MorphoMidnightCbBTCUSDC_860_20261225_Eth = "morphomidnightcbbtcusdc_860_20261225_eth",
46
+ MorphoMidnightCbBTCUSDC_860_20270129_Eth = "morphomidnightcbbtcusdc_860_20270129_eth",
47
+ MorphoMidnightCbBTCUSDC_860_20270226_Eth = "morphomidnightcbbtcusdc_860_20270226_eth",
48
+ MorphoMidnightCbBTCUSDC_860_20270326_Eth = "morphomidnightcbbtcusdc_860_20270326_eth",
49
+ MorphoMidnightTenorReUSDUSDC_20260925_Eth = "morphomidnighttenorreusdusdc_20260925_eth",
50
+ MorphoMidnightTenorReUSDUSDC_20261030_Eth = "morphomidnighttenorreusdusdc_20261030_eth",
51
+ MorphoMidnightTenorReUSDUSDC_20261127_Eth = "morphomidnighttenorreusdusdc_20261127_eth",
52
+ MorphoMidnightTenorReUSDUSDC_20261225_Eth = "morphomidnighttenorreusdusdc_20261225_eth",
53
+ MorphoMidnightTenorSiUSDUSDC_20260925_Eth = "morphomidnighttenorsiusdusdc_20260925_eth",
54
+ MorphoMidnightTenorSiUSDUSDC_20261030_Eth = "morphomidnighttenorsiusdusdc_20261030_eth",
55
+ MorphoMidnightTenorSiUSDUSDC_20261127_Eth = "morphomidnighttenorsiusdusdc_20261127_eth",
56
+ MorphoMidnightTenorSiUSDUSDC_20261225_Eth = "morphomidnighttenorsiusdusdc_20261225_eth",
57
+ MorphoMidnightTenorStrUSDUSDC_20260925_Eth = "morphomidnighttenorstrusdusdc_20260925_eth",
58
+ MorphoMidnightTenorStrUSDUSDC_20261030_Eth = "morphomidnighttenorstrusdusdc_20261030_eth",
59
+ MorphoMidnightTenorStrUSDUSDC_20261127_Eth = "morphomidnighttenorstrusdusdc_20261127_eth",
60
+ MorphoMidnightTenorStrUSDUSDC_20261225_Eth = "morphomidnighttenorstrusdusdc_20261225_eth",
61
+ MorphoMidnightTenorUSD3USDC_20260925_Eth = "morphomidnighttenorusd3usdc_20260925_eth",
62
+ MorphoMidnightTenorUSD3USDC_20261030_Eth = "morphomidnighttenorusd3usdc_20261030_eth",
63
+ MorphoMidnightTenorUSD3USDC_20261127_Eth = "morphomidnighttenorusd3usdc_20261127_eth",
64
+ MorphoMidnightTenorUSD3USDC_20261225_Eth = "morphomidnighttenorusd3usdc_20261225_eth",
65
+ MorphoMidnightTenorWETHUSDC_20260925_Eth = "morphomidnighttenorwethusdc_20260925_eth",
66
+ MorphoMidnightTenorWETHUSDC_20261030_Eth = "morphomidnighttenorwethusdc_20261030_eth",
67
+ MorphoMidnightTenorWETHUSDC_20261127_Eth = "morphomidnighttenorwethusdc_20261127_eth",
68
+ MorphoMidnightTenorWETHUSDC_20261225_Eth = "morphomidnighttenorwethusdc_20261225_eth",
69
+ MorphoMidnightTenorWsrUSDUSDC_20260925_Eth = "morphomidnighttenorwsrusdusdc_20260925_eth",
70
+ MorphoMidnightTenorWsrUSDUSDC_20261030_Eth = "morphomidnighttenorwsrusdusdc_20261030_eth",
71
+ MorphoMidnightTenorWsrUSDUSDC_20261127_Eth = "morphomidnighttenorwsrusdusdc_20261127_eth",
72
+ MorphoMidnightTenorWsrUSDUSDC_20261225_Eth = "morphomidnighttenorwsrusdusdc_20261225_eth",
73
+ MorphoMidnightTenorWstETHWETH_20260925_Eth = "morphomidnighttenorwstethweth_20260925_eth",
74
+ MorphoMidnightTenorWstETHWETH_20261030_Eth = "morphomidnighttenorwstethweth_20261030_eth",
75
+ MorphoMidnightTenorWstETHWETH_20261127_Eth = "morphomidnighttenorwstethweth_20261127_eth",
76
+ MorphoMidnightTenorWstETHWETH_20261225_Eth = "morphomidnighttenorwstethweth_20261225_eth"
35
77
  }
36
78
  export type MorphoMidnightCurator = 'Morpho' | 'Tenor';
37
79
  export interface MorphoMidnightCollateralParams {
@@ -39,6 +81,13 @@ export interface MorphoMidnightCollateralParams {
39
81
  lltv: number | string;
40
82
  liquidationCursor: number | string;
41
83
  oracle: EthAddress;
84
+ /**
85
+ * A collateral the market carries on-chain but the app never surfaces: a curator's own vault share
86
+ * token (Tenor's collateral vaults) or the loan token itself (Morpho's mainnet ladders list USDC at
87
+ * 98% next to the real collateral). It is not an asset the app deals in — nothing renders, prices or
88
+ * supplies it — but it stays in `collaterals` because the market id is the hash of the full set.
89
+ */
90
+ hidden?: boolean;
42
91
  }
43
92
  export interface MorphoMidnightMarketData {
44
93
  chainIds: NetworkNumber[];
@@ -48,11 +97,15 @@ export interface MorphoMidnightMarketData {
48
97
  value: MorphoMidnightVersions;
49
98
  midnight: EthAddress;
50
99
  loanToken: EthAddress;
51
- collaterals: MorphoMidnightCollateralParams[];
52
100
  /**
53
- * Tenor's curated markets list the curator's own vault share token next to the real collateral.
101
+ * Every collateral the market carries on-chain, in the chain's own order which is what the id is
102
+ * hashed from, so neither the set nor the order may be rearranged. Entries the app does not deal in
103
+ * are flagged `hidden` rather than kept in a second list: their on-chain position varies per market
104
+ * (Morpho's mainnet cbBTC ladder lists USDC first, its WBTC ladder second), so a separate list can
105
+ * only be re-joined by guessing, and every positional read — `MarketInfo.prices[i]`,
106
+ * `PositionInfo.collateral[i]`, the collateral index a supply call takes — indexes into *this* array.
54
107
  */
55
- hiddenCollaterals?: MorphoMidnightCollateralParams[];
108
+ collaterals: MorphoMidnightCollateralParams[];
56
109
  maturity: number;
57
110
  rcfThreshold: number | string;
58
111
  enterGate: EthAddress;
@@ -36,6 +36,51 @@ export var MorphoMidnightVersions;
36
36
  MorphoMidnightVersions["MorphoMidnightTenorCbETHWETH_20261127_Base"] = "morphomidnighttenorcbethweth_20261127_base";
37
37
  MorphoMidnightVersions["MorphoMidnightTenorCbETHWETH_20261225_Base"] = "morphomidnighttenorcbethweth_20261225_base";
38
38
  MorphoMidnightVersions["MorphoMidnightTenorCbETHWETH_20270129_Base"] = "morphomidnighttenorcbethweth_20270129_base";
39
+ // ETHEREUM
40
+ // Sourced from the official listing at https://markets.morpho.org/fixed?chains=1
41
+ MorphoMidnightVersions["MorphoMidnightWBTCUSDC_860_20260925_Eth"] = "morphomidnightwbtcusdc_860_20260925_eth";
42
+ MorphoMidnightVersions["MorphoMidnightWBTCUSDC_860_20261030_Eth"] = "morphomidnightwbtcusdc_860_20261030_eth";
43
+ MorphoMidnightVersions["MorphoMidnightWBTCUSDC_860_20261127_Eth"] = "morphomidnightwbtcusdc_860_20261127_eth";
44
+ MorphoMidnightVersions["MorphoMidnightWBTCUSDC_860_20261225_Eth"] = "morphomidnightwbtcusdc_860_20261225_eth";
45
+ MorphoMidnightVersions["MorphoMidnightWBTCUSDC_860_20270129_Eth"] = "morphomidnightwbtcusdc_860_20270129_eth";
46
+ MorphoMidnightVersions["MorphoMidnightWBTCUSDC_860_20270226_Eth"] = "morphomidnightwbtcusdc_860_20270226_eth";
47
+ MorphoMidnightVersions["MorphoMidnightWBTCUSDC_860_20270326_Eth"] = "morphomidnightwbtcusdc_860_20270326_eth";
48
+ MorphoMidnightVersions["MorphoMidnightCbBTCUSDC_860_20260925_Eth"] = "morphomidnightcbbtcusdc_860_20260925_eth";
49
+ MorphoMidnightVersions["MorphoMidnightCbBTCUSDC_860_20261030_Eth"] = "morphomidnightcbbtcusdc_860_20261030_eth";
50
+ MorphoMidnightVersions["MorphoMidnightCbBTCUSDC_860_20261127_Eth"] = "morphomidnightcbbtcusdc_860_20261127_eth";
51
+ MorphoMidnightVersions["MorphoMidnightCbBTCUSDC_860_20261225_Eth"] = "morphomidnightcbbtcusdc_860_20261225_eth";
52
+ MorphoMidnightVersions["MorphoMidnightCbBTCUSDC_860_20270129_Eth"] = "morphomidnightcbbtcusdc_860_20270129_eth";
53
+ MorphoMidnightVersions["MorphoMidnightCbBTCUSDC_860_20270226_Eth"] = "morphomidnightcbbtcusdc_860_20270226_eth";
54
+ MorphoMidnightVersions["MorphoMidnightCbBTCUSDC_860_20270326_Eth"] = "morphomidnightcbbtcusdc_860_20270326_eth";
55
+ // Tenor-hosted Midnight markets (same core, different order book)
56
+ MorphoMidnightVersions["MorphoMidnightTenorReUSDUSDC_20260925_Eth"] = "morphomidnighttenorreusdusdc_20260925_eth";
57
+ MorphoMidnightVersions["MorphoMidnightTenorReUSDUSDC_20261030_Eth"] = "morphomidnighttenorreusdusdc_20261030_eth";
58
+ MorphoMidnightVersions["MorphoMidnightTenorReUSDUSDC_20261127_Eth"] = "morphomidnighttenorreusdusdc_20261127_eth";
59
+ MorphoMidnightVersions["MorphoMidnightTenorReUSDUSDC_20261225_Eth"] = "morphomidnighttenorreusdusdc_20261225_eth";
60
+ MorphoMidnightVersions["MorphoMidnightTenorSiUSDUSDC_20260925_Eth"] = "morphomidnighttenorsiusdusdc_20260925_eth";
61
+ MorphoMidnightVersions["MorphoMidnightTenorSiUSDUSDC_20261030_Eth"] = "morphomidnighttenorsiusdusdc_20261030_eth";
62
+ MorphoMidnightVersions["MorphoMidnightTenorSiUSDUSDC_20261127_Eth"] = "morphomidnighttenorsiusdusdc_20261127_eth";
63
+ MorphoMidnightVersions["MorphoMidnightTenorSiUSDUSDC_20261225_Eth"] = "morphomidnighttenorsiusdusdc_20261225_eth";
64
+ MorphoMidnightVersions["MorphoMidnightTenorStrUSDUSDC_20260925_Eth"] = "morphomidnighttenorstrusdusdc_20260925_eth";
65
+ MorphoMidnightVersions["MorphoMidnightTenorStrUSDUSDC_20261030_Eth"] = "morphomidnighttenorstrusdusdc_20261030_eth";
66
+ MorphoMidnightVersions["MorphoMidnightTenorStrUSDUSDC_20261127_Eth"] = "morphomidnighttenorstrusdusdc_20261127_eth";
67
+ MorphoMidnightVersions["MorphoMidnightTenorStrUSDUSDC_20261225_Eth"] = "morphomidnighttenorstrusdusdc_20261225_eth";
68
+ MorphoMidnightVersions["MorphoMidnightTenorUSD3USDC_20260925_Eth"] = "morphomidnighttenorusd3usdc_20260925_eth";
69
+ MorphoMidnightVersions["MorphoMidnightTenorUSD3USDC_20261030_Eth"] = "morphomidnighttenorusd3usdc_20261030_eth";
70
+ MorphoMidnightVersions["MorphoMidnightTenorUSD3USDC_20261127_Eth"] = "morphomidnighttenorusd3usdc_20261127_eth";
71
+ MorphoMidnightVersions["MorphoMidnightTenorUSD3USDC_20261225_Eth"] = "morphomidnighttenorusd3usdc_20261225_eth";
72
+ MorphoMidnightVersions["MorphoMidnightTenorWETHUSDC_20260925_Eth"] = "morphomidnighttenorwethusdc_20260925_eth";
73
+ MorphoMidnightVersions["MorphoMidnightTenorWETHUSDC_20261030_Eth"] = "morphomidnighttenorwethusdc_20261030_eth";
74
+ MorphoMidnightVersions["MorphoMidnightTenorWETHUSDC_20261127_Eth"] = "morphomidnighttenorwethusdc_20261127_eth";
75
+ MorphoMidnightVersions["MorphoMidnightTenorWETHUSDC_20261225_Eth"] = "morphomidnighttenorwethusdc_20261225_eth";
76
+ MorphoMidnightVersions["MorphoMidnightTenorWsrUSDUSDC_20260925_Eth"] = "morphomidnighttenorwsrusdusdc_20260925_eth";
77
+ MorphoMidnightVersions["MorphoMidnightTenorWsrUSDUSDC_20261030_Eth"] = "morphomidnighttenorwsrusdusdc_20261030_eth";
78
+ MorphoMidnightVersions["MorphoMidnightTenorWsrUSDUSDC_20261127_Eth"] = "morphomidnighttenorwsrusdusdc_20261127_eth";
79
+ MorphoMidnightVersions["MorphoMidnightTenorWsrUSDUSDC_20261225_Eth"] = "morphomidnighttenorwsrusdusdc_20261225_eth";
80
+ MorphoMidnightVersions["MorphoMidnightTenorWstETHWETH_20260925_Eth"] = "morphomidnighttenorwstethweth_20260925_eth";
81
+ MorphoMidnightVersions["MorphoMidnightTenorWstETHWETH_20261030_Eth"] = "morphomidnighttenorwstethweth_20261030_eth";
82
+ MorphoMidnightVersions["MorphoMidnightTenorWstETHWETH_20261127_Eth"] = "morphomidnighttenorwstethweth_20261127_eth";
83
+ MorphoMidnightVersions["MorphoMidnightTenorWstETHWETH_20261225_Eth"] = "morphomidnighttenorwstethweth_20261225_eth";
39
84
  })(MorphoMidnightVersions || (MorphoMidnightVersions = {}));
40
85
  /**
41
86
  * How much weight `borrowRate` / `debtBase` / `debtInterest` carry on a given position. They fall back to
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defisaver/positions-sdk",
3
- "version": "2.1.151",
3
+ "version": "2.1.152",
4
4
  "description": "",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
@@ -9,7 +9,6 @@ import { ClaimType } from '../types/claiming';
9
9
  // Not decodable by name, since the error lives in CometRewards' ABI and we call through CompV3View.
10
10
  const NOT_SUPPORTED_ERROR_SIG = '0x9c58e3b6';
11
11
 
12
- // Only an actual on-chain revert counts - viem reports transport failures as ContractFunctionExecutionError too.
13
12
  const isMarketWithoutRewardsConfig = (err: unknown) => {
14
13
  if (!(err instanceof BaseError)) return false;
15
14
  const revert = err.walk((e) => e instanceof ContractFunctionRevertedError);
@@ -1128,6 +1128,10 @@ export const MorphoBlueView = {
1128
1128
  export const MidnightView = {
1129
1129
  "abi": [{"inputs":[{"internalType":"bytes32","name":"_id","type":"bytes32"}],"name":"getMarketInfo","outputs":[{"components":[{"internalType":"bytes32","name":"id","type":"bytes32"},{"internalType":"uint128","name":"totalUnits","type":"uint128"},{"internalType":"uint128","name":"lossFactor","type":"uint128"},{"internalType":"uint128","name":"withdrawable","type":"uint128"},{"internalType":"uint128","name":"continuousFeeCredit","type":"uint128"},{"internalType":"uint16[7]","name":"settlementFees","type":"uint16[7]"},{"internalType":"uint32","name":"continuousFee","type":"uint32"},{"internalType":"uint8","name":"tickSpacing","type":"uint8"},{"internalType":"uint256[]","name":"prices","type":"uint256[]"}],"internalType":"struct MidnightView.MarketInfo","name":"info","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_id","type":"bytes32"},{"internalType":"address","name":"_user","type":"address"}],"name":"getPositionInfo","outputs":[{"components":[{"internalType":"uint128","name":"credit","type":"uint128"},{"internalType":"uint128","name":"pendingFee","type":"uint128"},{"internalType":"uint128","name":"debt","type":"uint128"},{"internalType":"uint128","name":"collateralBitmap","type":"uint128"},{"internalType":"uint128[]","name":"collateral","type":"uint128[]"},{"internalType":"uint256","name":"ratio","type":"uint256"}],"internalType":"struct MidnightView.PositionInfo","name":"pos","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_id","type":"bytes32"},{"internalType":"address","name":"_user","type":"address"}],"name":"getRatio","outputs":[{"internalType":"uint256","name":"ratio","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"midnight","type":"address"},{"internalType":"address","name":"loanToken","type":"address"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"lltv","type":"uint256"},{"internalType":"uint256","name":"liquidationCursor","type":"uint256"},{"internalType":"address","name":"oracle","type":"address"}],"internalType":"struct CollateralParams[]","name":"collateralParams","type":"tuple[]"},{"internalType":"uint256","name":"maturity","type":"uint256"},{"internalType":"uint256","name":"rcfThreshold","type":"uint256"},{"internalType":"address","name":"enterGate","type":"address"},{"internalType":"address","name":"liquidatorGate","type":"address"}],"internalType":"struct Market","name":"_market","type":"tuple"}],"name":"toId","outputs":[{"internalType":"bytes32","name":"id","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_id","type":"bytes32"}],"name":"toMarket","outputs":[{"components":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"midnight","type":"address"},{"internalType":"address","name":"loanToken","type":"address"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"lltv","type":"uint256"},{"internalType":"uint256","name":"liquidationCursor","type":"uint256"},{"internalType":"address","name":"oracle","type":"address"}],"internalType":"struct CollateralParams[]","name":"collateralParams","type":"tuple[]"},{"internalType":"uint256","name":"maturity","type":"uint256"},{"internalType":"uint256","name":"rcfThreshold","type":"uint256"},{"internalType":"address","name":"enterGate","type":"address"},{"internalType":"address","name":"liquidatorGate","type":"address"}],"internalType":"struct Market","name":"market","type":"tuple"}],"stateMutability":"view","type":"function"}],
1130
1130
  "networks": {
1131
+ "1": {
1132
+ "address": "0xB64FBf011343961D9AC4A04b714414E35ebE6BE0",
1133
+ "createdBlock": 25938908,
1134
+ },
1131
1135
  "8453": {
1132
1136
  "address": "0x3aa272f329E8B562A3bA56Bb6979a44D23A28839",
1133
1137
  "createdBlock": 48932293,
@@ -8,7 +8,7 @@ import {
8
8
  MorphoMidnightParsedBook,
9
9
  NetworkNumber,
10
10
  } from '../../types';
11
- import { isTenorMidnightMarket, MIDNIGHT_BASE } from '../../markets/morphoMidnight';
11
+ import { isTenorMidnightMarket, midnightCoreAddress } from '../../markets/morphoMidnight';
12
12
  import type {
13
13
  MorphoMidnightBorrowQuote,
14
14
  MorphoMidnightPaybackQuote,
@@ -83,11 +83,15 @@ interface TenorOfferFill {
83
83
  /**
84
84
  * Tenor's offer JSON is flat (market fields live on the offer). Morpho's is nested, and that nested
85
85
  * shape is what the app encodes for `Midnight.take`. Map Tenor into that shape so recipes stay on one encoder.
86
+ *
87
+ * The core address is the one field Tenor's offer does not carry, so it is derived from the offer's own
88
+ * `chain_id` rather than the caller's network — an offer names the chain it was made on, and taking it
89
+ * against another chain's core would address a market that does not exist.
86
90
  */
87
91
  export const tenorOfferToApiOffer = (offer: TenorOffer) => ({
88
92
  market: {
89
93
  chain_id: offer.chain_id,
90
- midnight: MIDNIGHT_BASE,
94
+ midnight: midnightCoreAddress(Number(offer.chain_id) as NetworkNumber),
91
95
  loan_token: offer.loan_token_address,
92
96
  collaterals: offer.collaterals || [],
93
97
  maturity: offer.maturity,
@@ -19,6 +19,7 @@ export { CrvUsdMarkets } from './curveUsd';
19
19
  export { MorphoBlueMarkets, findMorphoBlueMarket } from './morphoBlue';
20
20
  export {
21
21
  MorphoMidnightMarkets, findMorphoMidnightMarket, isTenorMidnightMarket, morphoMidnightMarketCollateralParams,
22
+ morphoMidnightVisibleCollaterals,
22
23
  } from './morphoMidnight';
23
24
  export { LlamaLendMarkets } from './llamaLend';
24
25
  export { LiquityV2Markets, findLiquityV2MarketByAddress } from './liquityV2';