@defisaver/positions-sdk 2.1.150-cirbtc-dev → 2.1.151-midnight-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.
Files changed (38) hide show
  1. package/cjs/claiming/compV3.js +0 -1
  2. package/cjs/config/contracts.d.ts +4 -0
  3. package/cjs/config/contracts.js +4 -0
  4. package/cjs/helpers/morphoMidnightHelpers/tenor.d.ts +6 -2
  5. package/cjs/helpers/morphoMidnightHelpers/tenor.js +5 -1
  6. package/cjs/markets/index.d.ts +1 -1
  7. package/cjs/markets/index.js +2 -1
  8. package/cjs/markets/morphoBlue/index.js +122 -122
  9. package/cjs/markets/morphoMidnight/index.d.ts +44 -10
  10. package/cjs/markets/morphoMidnight/index.js +380 -59
  11. package/cjs/morphoMidnight/index.js +11 -1
  12. package/cjs/portfolio/index.js +3 -27
  13. package/cjs/types/morphoMidnight.d.ts +35 -4
  14. package/cjs/types/morphoMidnight.js +23 -0
  15. package/esm/claiming/compV3.js +0 -1
  16. package/esm/config/contracts.d.ts +4 -0
  17. package/esm/config/contracts.js +4 -0
  18. package/esm/helpers/morphoMidnightHelpers/tenor.d.ts +6 -2
  19. package/esm/helpers/morphoMidnightHelpers/tenor.js +6 -2
  20. package/esm/markets/index.d.ts +1 -1
  21. package/esm/markets/index.js +1 -1
  22. package/esm/markets/morphoBlue/index.js +122 -122
  23. package/esm/markets/morphoMidnight/index.d.ts +44 -10
  24. package/esm/markets/morphoMidnight/index.js +356 -58
  25. package/esm/morphoMidnight/index.js +11 -1
  26. package/esm/portfolio/index.js +4 -28
  27. package/esm/types/morphoMidnight.d.ts +35 -4
  28. package/esm/types/morphoMidnight.js +23 -0
  29. package/package.json +1 -1
  30. package/src/claiming/compV3.ts +0 -1
  31. package/src/config/contracts.ts +4 -0
  32. package/src/helpers/morphoMidnightHelpers/tenor.ts +6 -2
  33. package/src/markets/index.ts +1 -0
  34. package/src/markets/morphoBlue/index.ts +122 -122
  35. package/src/markets/morphoMidnight/index.ts +446 -60
  36. package/src/morphoMidnight/index.ts +8 -1
  37. package/src/portfolio/index.ts +3 -27
  38. package/src/types/morphoMidnight.ts +37 -3
@@ -78,8 +78,13 @@ function _getMorphoMidnightMarketData(provider, network, selectedMarket) {
78
78
  supplyIncentives: [],
79
79
  borrowIncentives: [],
80
80
  };
81
+ // `collaterals` is the full on-chain set, so `i` is the index `prices` is keyed by. Hidden entries
82
+ // (curator vaults, the loan token itself) are skipped rather than filtered out beforehand, which would
83
+ // shift every later collateral onto the wrong price.
81
84
  const collateralSymbols = [];
82
85
  collaterals.forEach((coll, i) => {
86
+ if (coll.hidden)
87
+ return;
83
88
  const collInfo = (0, tokens_1.getAssetInfoByAddress)(coll.token, network);
84
89
  const collSym = (0, utils_1.wethToEth)(collInfo.symbol);
85
90
  collateralSymbols.push(collSym);
@@ -142,8 +147,11 @@ function _getMorphoMidnightAccountData(provider, network, account, selectedMarke
142
147
  suppliedUsd: new decimal_js_1.default(credit).mul(loanTokenData.price).toString(),
143
148
  borrowedUsd: new decimal_js_1.default(debt).mul(loanTokenData.price).toString(),
144
149
  };
145
- // positionInfo.collateral is index-aligned with the market's collateral set (0 where unused).
150
+ // positionInfo.collateral is index-aligned with the market's full on-chain collateral set (0 where
151
+ // unused), so hidden entries are skipped in place rather than filtered out first.
146
152
  collaterals.forEach((coll, i) => {
153
+ if (coll.hidden)
154
+ return;
147
155
  const collInfo = (0, tokens_1.getAssetInfoByAddress)(coll.token, network);
148
156
  const collSym = (0, utils_1.wethToEth)(collInfo.symbol);
149
157
  const rawAmount = positionInfo.collateral[i] ? positionInfo.collateral[i].toString() : '0';
@@ -223,6 +231,8 @@ const _getMorphoMidnightAccountBalances = (provider, network, block, addressMapp
223
231
  };
224
232
  const collateral = {};
225
233
  collaterals.forEach((coll, i) => {
234
+ if (coll.hidden)
235
+ return;
226
236
  const collInfo = (0, tokens_1.getAssetInfoByAddress)(coll.token, network);
227
237
  const rawAmount = positionInfo.collateral[i] ? positionInfo.collateral[i].toString() : '0';
228
238
  collateral[addressMapping ? collInfo.address.toLowerCase() : (0, utils_1.wethToEth)(collInfo.symbol)] = (0, tokens_1.assetAmountInEth)(rawAmount, (0, utils_1.wethToEth)(collInfo.symbol));
@@ -127,7 +127,6 @@ function getPortfolioData(provider_1, network_1, defaultProvider_1, addresses_1)
127
127
  stakingPositions[address.toLowerCase()] = {
128
128
  aaveV3: {},
129
129
  morphoBlue: {},
130
- morphoMidnight: {},
131
130
  compoundV3: {},
132
131
  spark: {},
133
132
  aaveV2: {},
@@ -495,32 +494,9 @@ function getPortfolioData(provider_1, network_1, defaultProvider_1, addresses_1)
495
494
  }))).flat(),
496
495
  ...morphoMidnightMarkets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
497
496
  try {
498
- const [accDataPromise, earnDataPromise] = yield Promise.allSettled([
499
- (0, morphoMidnight_1._getMorphoMidnightAccountData)(client, network, address, market, morphoMidnightMarketsData[market.value]),
500
- (0, morphoMidnight_1.getMorphoMidnightEarn)(client, network, address, market, morphoMidnightMarketsData[market.value]),
501
- ]);
502
- if (accDataPromise.status === 'rejected') {
503
- console.error(`Error fetching MorphoMidnight account data for address ${address} on market ${market.value}:`, accDataPromise.reason);
504
- positions[address.toLowerCase()].morphoMidnight[market.value] = { error: `Error fetching MorphoMidnight account data for address ${address} on market ${market.value}`, data: null };
505
- }
506
- if (earnDataPromise.status === 'rejected') {
507
- console.error(`Error fetching MorphoMidnight account data for address ${address} on market ${market.value}:`, earnDataPromise.reason);
508
- positions[address.toLowerCase()].morphoMidnight[market.value] = { error: `Error fetching MorphoMidnight account data for address ${address} on market ${market.value}`, data: null };
509
- }
510
- if (accDataPromise.status !== 'rejected') {
511
- const accData = accDataPromise.value;
512
- if (new decimal_js_1.default(accData.suppliedUsd).gt(0))
513
- positions[address.toLowerCase()].morphoMidnight[market.value] = { error: '', data: accData };
514
- }
515
- if (earnDataPromise.status !== 'rejected') {
516
- const earnData = earnDataPromise.value;
517
- if (earnData && new decimal_js_1.default(earnData.amount).gt(0)) {
518
- stakingPositions[address.toLowerCase()].morphoMidnight[market.value] = {
519
- error: '',
520
- data: earnData,
521
- };
522
- }
523
- }
497
+ const accData = yield (0, morphoMidnight_1._getMorphoMidnightAccountData)(client, network, address, market, morphoMidnightMarketsData[market.value]);
498
+ if (new decimal_js_1.default(accData.suppliedUsd).gt(0))
499
+ positions[address.toLowerCase()].morphoMidnight[market.value] = { error: '', data: accData };
524
500
  }
525
501
  catch (error) {
526
502
  console.error(`Error fetching MorphoMidnight account data for address ${address} on market ${market.value}:`, error);
@@ -31,7 +31,27 @@ 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
+ MorphoMidnightTenorWETHUSDC_20260925_Eth = "morphomidnighttenorwethusdc_20260925_eth",
50
+ MorphoMidnightTenorStrUSDUSDC_20260925_Eth = "morphomidnighttenorstrusdusdc_20260925_eth",
51
+ MorphoMidnightTenorWsrUSDUSDC_20260925_Eth = "morphomidnighttenorwsrusdusdc_20260925_eth",
52
+ MorphoMidnightTenorUSD3USDC_20260925_Eth = "morphomidnighttenorusd3usdc_20260925_eth",
53
+ MorphoMidnightTenorReUSDUSDC_20260925_Eth = "morphomidnighttenorreusdusdc_20260925_eth",
54
+ MorphoMidnightTenorSiUSDUSDC_20260925_Eth = "morphomidnighttenorsiusdusdc_20260925_eth"
35
55
  }
36
56
  export type MorphoMidnightCurator = 'Morpho' | 'Tenor';
37
57
  export interface MorphoMidnightCollateralParams {
@@ -39,6 +59,13 @@ export interface MorphoMidnightCollateralParams {
39
59
  lltv: number | string;
40
60
  liquidationCursor: number | string;
41
61
  oracle: EthAddress;
62
+ /**
63
+ * A collateral the market carries on-chain but the app never surfaces: a curator's own vault share
64
+ * token (Tenor's collateral vaults) or the loan token itself (Morpho's mainnet ladders list USDC at
65
+ * 98% next to the real collateral). It is not an asset the app deals in — nothing renders, prices or
66
+ * supplies it — but it stays in `collaterals` because the market id is the hash of the full set.
67
+ */
68
+ hidden?: boolean;
42
69
  }
43
70
  export interface MorphoMidnightMarketData {
44
71
  chainIds: NetworkNumber[];
@@ -48,11 +75,15 @@ export interface MorphoMidnightMarketData {
48
75
  value: MorphoMidnightVersions;
49
76
  midnight: EthAddress;
50
77
  loanToken: EthAddress;
51
- collaterals: MorphoMidnightCollateralParams[];
52
78
  /**
53
- * Tenor's curated markets list the curator's own vault share token next to the real collateral.
79
+ * Every collateral the market carries on-chain, in the chain's own order which is what the id is
80
+ * hashed from, so neither the set nor the order may be rearranged. Entries the app does not deal in
81
+ * are flagged `hidden` rather than kept in a second list: their on-chain position varies per market
82
+ * (Morpho's mainnet cbBTC ladder lists USDC first, its WBTC ladder second), so a separate list can
83
+ * only be re-joined by guessing, and every positional read — `MarketInfo.prices[i]`,
84
+ * `PositionInfo.collateral[i]`, the collateral index a supply call takes — indexes into *this* array.
54
85
  */
55
- hiddenCollaterals?: MorphoMidnightCollateralParams[];
86
+ collaterals: MorphoMidnightCollateralParams[];
56
87
  maturity: number;
57
88
  rcfThreshold: number | string;
58
89
  enterGate: EthAddress;
@@ -39,6 +39,29 @@ var MorphoMidnightVersions;
39
39
  MorphoMidnightVersions["MorphoMidnightTenorCbETHWETH_20261127_Base"] = "morphomidnighttenorcbethweth_20261127_base";
40
40
  MorphoMidnightVersions["MorphoMidnightTenorCbETHWETH_20261225_Base"] = "morphomidnighttenorcbethweth_20261225_base";
41
41
  MorphoMidnightVersions["MorphoMidnightTenorCbETHWETH_20270129_Base"] = "morphomidnighttenorcbethweth_20270129_base";
42
+ // ETHEREUM
43
+ // Sourced from the official listing at https://markets.morpho.org/fixed?chains=1
44
+ MorphoMidnightVersions["MorphoMidnightWBTCUSDC_860_20260925_Eth"] = "morphomidnightwbtcusdc_860_20260925_eth";
45
+ MorphoMidnightVersions["MorphoMidnightWBTCUSDC_860_20261030_Eth"] = "morphomidnightwbtcusdc_860_20261030_eth";
46
+ MorphoMidnightVersions["MorphoMidnightWBTCUSDC_860_20261127_Eth"] = "morphomidnightwbtcusdc_860_20261127_eth";
47
+ MorphoMidnightVersions["MorphoMidnightWBTCUSDC_860_20261225_Eth"] = "morphomidnightwbtcusdc_860_20261225_eth";
48
+ MorphoMidnightVersions["MorphoMidnightWBTCUSDC_860_20270129_Eth"] = "morphomidnightwbtcusdc_860_20270129_eth";
49
+ MorphoMidnightVersions["MorphoMidnightWBTCUSDC_860_20270226_Eth"] = "morphomidnightwbtcusdc_860_20270226_eth";
50
+ MorphoMidnightVersions["MorphoMidnightWBTCUSDC_860_20270326_Eth"] = "morphomidnightwbtcusdc_860_20270326_eth";
51
+ MorphoMidnightVersions["MorphoMidnightCbBTCUSDC_860_20260925_Eth"] = "morphomidnightcbbtcusdc_860_20260925_eth";
52
+ MorphoMidnightVersions["MorphoMidnightCbBTCUSDC_860_20261030_Eth"] = "morphomidnightcbbtcusdc_860_20261030_eth";
53
+ MorphoMidnightVersions["MorphoMidnightCbBTCUSDC_860_20261127_Eth"] = "morphomidnightcbbtcusdc_860_20261127_eth";
54
+ MorphoMidnightVersions["MorphoMidnightCbBTCUSDC_860_20261225_Eth"] = "morphomidnightcbbtcusdc_860_20261225_eth";
55
+ MorphoMidnightVersions["MorphoMidnightCbBTCUSDC_860_20270129_Eth"] = "morphomidnightcbbtcusdc_860_20270129_eth";
56
+ MorphoMidnightVersions["MorphoMidnightCbBTCUSDC_860_20270226_Eth"] = "morphomidnightcbbtcusdc_860_20270226_eth";
57
+ MorphoMidnightVersions["MorphoMidnightCbBTCUSDC_860_20270326_Eth"] = "morphomidnightcbbtcusdc_860_20270326_eth";
58
+ // Tenor-hosted Midnight markets (same core, different order book)
59
+ MorphoMidnightVersions["MorphoMidnightTenorWETHUSDC_20260925_Eth"] = "morphomidnighttenorwethusdc_20260925_eth";
60
+ MorphoMidnightVersions["MorphoMidnightTenorStrUSDUSDC_20260925_Eth"] = "morphomidnighttenorstrusdusdc_20260925_eth";
61
+ MorphoMidnightVersions["MorphoMidnightTenorWsrUSDUSDC_20260925_Eth"] = "morphomidnighttenorwsrusdusdc_20260925_eth";
62
+ MorphoMidnightVersions["MorphoMidnightTenorUSD3USDC_20260925_Eth"] = "morphomidnighttenorusd3usdc_20260925_eth";
63
+ MorphoMidnightVersions["MorphoMidnightTenorReUSDUSDC_20260925_Eth"] = "morphomidnighttenorreusdusdc_20260925_eth";
64
+ MorphoMidnightVersions["MorphoMidnightTenorSiUSDUSDC_20260925_Eth"] = "morphomidnighttenorsiusdusdc_20260925_eth";
42
65
  })(MorphoMidnightVersions || (exports.MorphoMidnightVersions = MorphoMidnightVersions = {}));
43
66
  /**
44
67
  * How much weight `borrowRate` / `debtBase` / `debtInterest` carry on a given position. They fall back to
@@ -15,7 +15,6 @@ import { ClaimType } from '../types/claiming';
15
15
  // `rewardConfig` set - such a market never accrues COMP, so there is nothing to claim.
16
16
  // Not decodable by name, since the error lives in CometRewards' ABI and we call through CompV3View.
17
17
  const NOT_SUPPORTED_ERROR_SIG = '0x9c58e3b6';
18
- // Only an actual on-chain revert counts - viem reports transport failures as ContractFunctionExecutionError too.
19
18
  const isMarketWithoutRewardsConfig = (err) => {
20
19
  var _a;
21
20
  if (!(err instanceof BaseError))
@@ -89746,6 +89746,10 @@ export declare const MidnightView: {
89746
89746
  readonly type: "function";
89747
89747
  }];
89748
89748
  readonly networks: {
89749
+ readonly "1": {
89750
+ readonly address: "0xB64FBf011343961D9AC4A04b714414E35ebE6BE0";
89751
+ readonly createdBlock: 25938908;
89752
+ };
89749
89753
  readonly "8453": {
89750
89754
  readonly address: "0x3aa272f329E8B562A3bA56Bb6979a44D23A28839";
89751
89755
  readonly createdBlock: 48932293;
@@ -1126,6 +1126,10 @@ export const MorphoBlueView = {
1126
1126
  export const MidnightView = {
1127
1127
  "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" }],
1128
1128
  "networks": {
1129
+ "1": {
1130
+ "address": "0xB64FBf011343961D9AC4A04b714414E35ebE6BE0",
1131
+ "createdBlock": 25938908,
1132
+ },
1129
1133
  "8453": {
1130
1134
  "address": "0x3aa272f329E8B562A3bA56Bb6979a44D23A28839",
1131
1135
  "createdBlock": 48932293,
@@ -41,11 +41,15 @@ interface TenorOfferFill {
41
41
  /**
42
42
  * Tenor's offer JSON is flat (market fields live on the offer). Morpho's is nested, and that nested
43
43
  * shape is what the app encodes for `Midnight.take`. Map Tenor into that shape so recipes stay on one encoder.
44
+ *
45
+ * The core address is the one field Tenor's offer does not carry, so it is derived from the offer's own
46
+ * `chain_id` rather than the caller's network — an offer names the chain it was made on, and taking it
47
+ * against another chain's core would address a market that does not exist.
44
48
  */
45
49
  export declare const tenorOfferToApiOffer: (offer: TenorOffer) => {
46
50
  market: {
47
51
  chain_id: string | number;
48
- midnight: "0xAdedD8ab6dE832766Fedf0FaC4992E5C4D3EA18A";
52
+ midnight: "0xAdedD8ab6dE832766Fedf0FaC4992E5C4D3EA18A" | "0x471686c42792F93528B000beF54bC10E3aa2045f";
49
53
  loan_token: string;
50
54
  collaterals: TenorOfferCollateral[];
51
55
  maturity: string | number;
@@ -73,7 +77,7 @@ export declare const tenorOfferFillToApiFill: (fill: TenorOfferFill) => {
73
77
  offer: {
74
78
  market: {
75
79
  chain_id: string | number;
76
- midnight: "0xAdedD8ab6dE832766Fedf0FaC4992E5C4D3EA18A";
80
+ midnight: "0xAdedD8ab6dE832766Fedf0FaC4992E5C4D3EA18A" | "0x471686c42792F93528B000beF54bC10E3aa2045f";
77
81
  loan_token: string;
78
82
  collaterals: TenorOfferCollateral[];
79
83
  maturity: string | number;
@@ -11,7 +11,7 @@ import Dec from 'decimal.js';
11
11
  import { assetAmountInEth, getAssetInfoByAddress } from '@defisaver/tokens';
12
12
  import { ZERO_ADDRESS, ZERO_BYTES32 } from '../../constants';
13
13
  import { NetworkNumber, } from '../../types';
14
- import { isTenorMidnightMarket, MIDNIGHT_BASE } from '../../markets/morphoMidnight';
14
+ import { isTenorMidnightMarket, midnightCoreAddress } from '../../markets/morphoMidnight';
15
15
  import { buildMidnightParsedBook, midnightApyFromPrice, midnightBoundPrice, midnightTimeToMaturityDays, } from './rate';
16
16
  // Notion doc by Rajko: https://app.notion.com/p/defisaver/Tenor-API-3ba0be682adc80dfad35c81a9a4cb442
17
17
  const TENOR_QUOTES_URL = 'https://router.tenor.finance/v1/quotes';
@@ -26,11 +26,15 @@ const tenorFillPrice = (assets, units) => (new Dec(units).lte(0) ? '0' : new Dec
26
26
  /**
27
27
  * Tenor's offer JSON is flat (market fields live on the offer). Morpho's is nested, and that nested
28
28
  * shape is what the app encodes for `Midnight.take`. Map Tenor into that shape so recipes stay on one encoder.
29
+ *
30
+ * The core address is the one field Tenor's offer does not carry, so it is derived from the offer's own
31
+ * `chain_id` rather than the caller's network — an offer names the chain it was made on, and taking it
32
+ * against another chain's core would address a market that does not exist.
29
33
  */
30
34
  export const tenorOfferToApiOffer = (offer) => ({
31
35
  market: {
32
36
  chain_id: offer.chain_id,
33
- midnight: MIDNIGHT_BASE,
37
+ midnight: midnightCoreAddress(Number(offer.chain_id)),
34
38
  loan_token: offer.loan_token_address,
35
39
  collaterals: offer.collaterals || [],
36
40
  maturity: offer.maturity,
@@ -3,7 +3,7 @@ export { CompoundMarkets, compoundV2CollateralAssets, v3ETHCollAssets, v3USDbCCo
3
3
  export { SparkMarkets } from './spark';
4
4
  export { CrvUsdMarkets } from './curveUsd';
5
5
  export { MorphoBlueMarkets, findMorphoBlueMarket } from './morphoBlue';
6
- export { MorphoMidnightMarkets, findMorphoMidnightMarket, isTenorMidnightMarket, morphoMidnightMarketCollateralParams, } from './morphoMidnight';
6
+ export { MorphoMidnightMarkets, findMorphoMidnightMarket, isTenorMidnightMarket, morphoMidnightMarketCollateralParams, morphoMidnightVisibleCollaterals, } from './morphoMidnight';
7
7
  export { LlamaLendMarkets } from './llamaLend';
8
8
  export { LiquityV2Markets, findLiquityV2MarketByAddress } from './liquityV2';
9
9
  export { FluidMarkets, getFluidVersionsDataForNetwork, getFluidMarketInfoById, getFTokenAddress, getFluidMarketInfoByAddress, } from './fluid';
@@ -3,7 +3,7 @@ export { CompoundMarkets, compoundV2CollateralAssets, v3ETHCollAssets, v3USDbCCo
3
3
  export { SparkMarkets } from './spark';
4
4
  export { CrvUsdMarkets } from './curveUsd';
5
5
  export { MorphoBlueMarkets, findMorphoBlueMarket } from './morphoBlue';
6
- export { MorphoMidnightMarkets, findMorphoMidnightMarket, isTenorMidnightMarket, morphoMidnightMarketCollateralParams, } from './morphoMidnight';
6
+ export { MorphoMidnightMarkets, findMorphoMidnightMarket, isTenorMidnightMarket, morphoMidnightMarketCollateralParams, morphoMidnightVisibleCollaterals, } from './morphoMidnight';
7
7
  export { LlamaLendMarkets } from './llamaLend';
8
8
  export { LiquityV2Markets, findLiquityV2MarketByAddress } from './liquityV2';
9
9
  export { FluidMarkets, getFluidVersionsDataForNetwork, getFluidMarketInfoById, getFTokenAddress, getFluidMarketInfoByAddress, } from './fluid';