@1delta/data-sdk 0.0.52 → 0.0.53
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 +36 -0
- package/dist/index.mjs +32 -1
- package/dist/lending/midnight.d.ts +72 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -373,12 +373,43 @@ var resolveMidnightApiBase = (chainId) => {
|
|
|
373
373
|
const cfg = midnightConfig()?.[chainId]?.apiBaseUrl;
|
|
374
374
|
return (cfg && cfg.length > 0 ? cfg : "https://api.morpho.org/v0/midnight").replace(/\/+$/, "");
|
|
375
375
|
};
|
|
376
|
+
var TENOR_API_OVERRIDE_KEY = "__1delta_tenor_api_url__";
|
|
377
|
+
var setTenorApiUrl = (url) => {
|
|
378
|
+
globalThis[TENOR_API_OVERRIDE_KEY] = url && url.length > 0 ? url : void 0;
|
|
379
|
+
};
|
|
380
|
+
var tenorApiUrlOverride = () => globalThis[TENOR_API_OVERRIDE_KEY];
|
|
381
|
+
var resolveTenorApiUrl = (chainId) => {
|
|
382
|
+
const override = tenorApiUrlOverride();
|
|
383
|
+
if (override) return override.replace(/\/+$/, "");
|
|
384
|
+
const cfg = midnightConfig()?.[chainId]?.tenorApiUrl;
|
|
385
|
+
return (cfg && cfg.length > 0 ? cfg : "https://api.tenor.finance/graphql").replace(/\/+$/, "");
|
|
386
|
+
};
|
|
376
387
|
var midnightMarkets = () => getGlobalData2()?.midnightMarkets;
|
|
377
388
|
var midnightMarketsByChain = (chainId) => getGlobalData2()?.midnightMarkets?.[String(chainId)] ?? [];
|
|
378
389
|
var midnightMarketById = (chainId, marketId) => {
|
|
379
390
|
const lower = marketId.toLowerCase();
|
|
380
391
|
return midnightMarketsByChain(chainId).find((m) => m.marketId.toLowerCase() === lower);
|
|
381
392
|
};
|
|
393
|
+
var midnightMarketIsEnterable = (market, nowSec = Math.floor(Date.now() / 1e3)) => {
|
|
394
|
+
if (Number(market.maturity) <= nowSec) return false;
|
|
395
|
+
if (market.deprecatedAt && Number(market.deprecatedAt) <= nowSec) return false;
|
|
396
|
+
return market.gating?.enter === "open";
|
|
397
|
+
};
|
|
398
|
+
var midnightNotEnterableReason = (market, nowSec = Math.floor(Date.now() / 1e3)) => {
|
|
399
|
+
if (Number(market.maturity) <= nowSec) return "market has matured";
|
|
400
|
+
if (market.deprecatedAt && Number(market.deprecatedAt) <= nowSec)
|
|
401
|
+
return "market is deprecated \u2014 existing positions can still be repaid, exited and liquidated";
|
|
402
|
+
switch (market.gating?.enter) {
|
|
403
|
+
case "open":
|
|
404
|
+
return void 0;
|
|
405
|
+
case "allowlist":
|
|
406
|
+
return "permissioned market: taking offers is restricted to an allowlist";
|
|
407
|
+
case "unknown":
|
|
408
|
+
return `permissioned market: unrecognised enter gate ${market.gating.enterGate}`;
|
|
409
|
+
default:
|
|
410
|
+
return "market gating could not be resolved";
|
|
411
|
+
}
|
|
412
|
+
};
|
|
382
413
|
|
|
383
414
|
// src/lending/term.ts
|
|
384
415
|
var termConfig = () => getGlobalData2()?.termConfig;
|
|
@@ -1304,8 +1335,10 @@ exports.loadCachedJson = loadCachedJson;
|
|
|
1304
1335
|
exports.midnightApiBaseOverride = midnightApiBaseOverride;
|
|
1305
1336
|
exports.midnightConfig = midnightConfig;
|
|
1306
1337
|
exports.midnightMarketById = midnightMarketById;
|
|
1338
|
+
exports.midnightMarketIsEnterable = midnightMarketIsEnterable;
|
|
1307
1339
|
exports.midnightMarkets = midnightMarkets;
|
|
1308
1340
|
exports.midnightMarketsByChain = midnightMarketsByChain;
|
|
1341
|
+
exports.midnightNotEnterableReason = midnightNotEnterableReason;
|
|
1309
1342
|
exports.morphoBundler3 = morphoBundler3;
|
|
1310
1343
|
exports.morphoOracles = morphoOracles;
|
|
1311
1344
|
exports.morphoPools = morphoPools;
|
|
@@ -1320,6 +1353,7 @@ exports.parseSiloV2LenderKey = parseSiloV2LenderKey;
|
|
|
1320
1353
|
exports.parseSiloV3LenderKey = parseSiloV3LenderKey;
|
|
1321
1354
|
exports.parseTermMaxLenderKey = parseTermMaxLenderKey;
|
|
1322
1355
|
exports.resolveMidnightApiBase = resolveMidnightApiBase;
|
|
1356
|
+
exports.resolveTenorApiUrl = resolveTenorApiUrl;
|
|
1323
1357
|
exports.resolveTermApiBase = resolveTermApiBase;
|
|
1324
1358
|
exports.resolveTermOrderStoreBase = resolveTermOrderStoreBase;
|
|
1325
1359
|
exports.resupplyConfig = resupplyConfig;
|
|
@@ -1334,6 +1368,7 @@ exports.riverMarkets = riverMarkets;
|
|
|
1334
1368
|
exports.setMidnightApiBase = setMidnightApiBase;
|
|
1335
1369
|
exports.setRemoteCacheGithubToken = setRemoteCacheGithubToken;
|
|
1336
1370
|
exports.setRemoteCacheStore = setRemoteCacheStore;
|
|
1371
|
+
exports.setTenorApiUrl = setTenorApiUrl;
|
|
1337
1372
|
exports.setTermApiBase = setTermApiBase;
|
|
1338
1373
|
exports.setTermOrderStoreBase = setTermOrderStoreBase;
|
|
1339
1374
|
exports.siloMarkets = siloMarkets;
|
|
@@ -1352,6 +1387,7 @@ exports.tellerConfigByChain = tellerConfigByChain;
|
|
|
1352
1387
|
exports.tellerPoolByAddress = tellerPoolByAddress;
|
|
1353
1388
|
exports.tellerPools = tellerPools;
|
|
1354
1389
|
exports.tellerPoolsByChain = tellerPoolsByChain;
|
|
1390
|
+
exports.tenorApiUrlOverride = tenorApiUrlOverride;
|
|
1355
1391
|
exports.termApiBaseOverride = termApiBaseOverride;
|
|
1356
1392
|
exports.termConfig = termConfig;
|
|
1357
1393
|
exports.termMarketById = termMarketById;
|
package/dist/index.mjs
CHANGED
|
@@ -371,12 +371,43 @@ var resolveMidnightApiBase = (chainId) => {
|
|
|
371
371
|
const cfg = midnightConfig()?.[chainId]?.apiBaseUrl;
|
|
372
372
|
return (cfg && cfg.length > 0 ? cfg : "https://api.morpho.org/v0/midnight").replace(/\/+$/, "");
|
|
373
373
|
};
|
|
374
|
+
var TENOR_API_OVERRIDE_KEY = "__1delta_tenor_api_url__";
|
|
375
|
+
var setTenorApiUrl = (url) => {
|
|
376
|
+
globalThis[TENOR_API_OVERRIDE_KEY] = url && url.length > 0 ? url : void 0;
|
|
377
|
+
};
|
|
378
|
+
var tenorApiUrlOverride = () => globalThis[TENOR_API_OVERRIDE_KEY];
|
|
379
|
+
var resolveTenorApiUrl = (chainId) => {
|
|
380
|
+
const override = tenorApiUrlOverride();
|
|
381
|
+
if (override) return override.replace(/\/+$/, "");
|
|
382
|
+
const cfg = midnightConfig()?.[chainId]?.tenorApiUrl;
|
|
383
|
+
return (cfg && cfg.length > 0 ? cfg : "https://api.tenor.finance/graphql").replace(/\/+$/, "");
|
|
384
|
+
};
|
|
374
385
|
var midnightMarkets = () => getGlobalData2()?.midnightMarkets;
|
|
375
386
|
var midnightMarketsByChain = (chainId) => getGlobalData2()?.midnightMarkets?.[String(chainId)] ?? [];
|
|
376
387
|
var midnightMarketById = (chainId, marketId) => {
|
|
377
388
|
const lower = marketId.toLowerCase();
|
|
378
389
|
return midnightMarketsByChain(chainId).find((m) => m.marketId.toLowerCase() === lower);
|
|
379
390
|
};
|
|
391
|
+
var midnightMarketIsEnterable = (market, nowSec = Math.floor(Date.now() / 1e3)) => {
|
|
392
|
+
if (Number(market.maturity) <= nowSec) return false;
|
|
393
|
+
if (market.deprecatedAt && Number(market.deprecatedAt) <= nowSec) return false;
|
|
394
|
+
return market.gating?.enter === "open";
|
|
395
|
+
};
|
|
396
|
+
var midnightNotEnterableReason = (market, nowSec = Math.floor(Date.now() / 1e3)) => {
|
|
397
|
+
if (Number(market.maturity) <= nowSec) return "market has matured";
|
|
398
|
+
if (market.deprecatedAt && Number(market.deprecatedAt) <= nowSec)
|
|
399
|
+
return "market is deprecated \u2014 existing positions can still be repaid, exited and liquidated";
|
|
400
|
+
switch (market.gating?.enter) {
|
|
401
|
+
case "open":
|
|
402
|
+
return void 0;
|
|
403
|
+
case "allowlist":
|
|
404
|
+
return "permissioned market: taking offers is restricted to an allowlist";
|
|
405
|
+
case "unknown":
|
|
406
|
+
return `permissioned market: unrecognised enter gate ${market.gating.enterGate}`;
|
|
407
|
+
default:
|
|
408
|
+
return "market gating could not be resolved";
|
|
409
|
+
}
|
|
410
|
+
};
|
|
380
411
|
|
|
381
412
|
// src/lending/term.ts
|
|
382
413
|
var termConfig = () => getGlobalData2()?.termConfig;
|
|
@@ -1165,4 +1196,4 @@ async function fetchMainTokensMap() {
|
|
|
1165
1196
|
}
|
|
1166
1197
|
}
|
|
1167
1198
|
|
|
1168
|
-
export { COOLER_ETHEREUM_CONFIG, CURVANCE_MONAD_CONFIG, FRAXLEND_ETHEREUM_CONFIG, GEARBOX_ACCOUNT_COMPRESSOR_V310, REMOTE_CACHE_STORE_TTL_S, RESUPPLY_ETHEREUM_CONFIG, RemoteFetchError, aaveOracles, aaveOraclesConfig, aavePools, aaveReserves, aaveTokens, aaveV4Oracles, aaveV4Peripherals, aaveV4SpokeLenderKey, aaveV4Spokes, aaveWethGateway, assertTwyneKeysUnique, chainLogoURI, chains, clearRemoteCache, compoundV2Oracles, compoundV2OraclesConfig, compoundV2Pools, compoundV2Reserves, compoundV2TokenArray, compoundV2Tokens, compoundV3BaseData, compoundV3Bulker, compoundV3OraclesData, compoundV3Pools, compoundV3Reserves, coolerConfig, coolerConfigFor, coolerLendersByChain, curvanceConfig, curvanceConfigFor, curvanceLendersByChain, curvancePositionManager, curvancePositionManagersFor, dolomiteChains, dolomiteConfigs, dolomiteEmode, dolomiteMarketIdByToken, dssChainData, dssConfigFor, dssDebtJoin, dssDebtToken, dssMarketByIlk, eulerConfigs, eulerVaults, exactlyConfig, exactlyMarketByAddress, exactlyMarketByAsset, exactlyMarkets, exactlyMarketsByChain, fetchMainTokensMap, fetchRemoteJson, fetchTokenList, fetchTokenListFile, fetchTokenLists, findAaveV4PositionManager, fluidChains, fluidResolvers, fluidVaultEntries, fluidVaults, flyingTulipAssets, flyingTulipAssetsFor, flyingTulipConfig, flyingTulipConfigFor, flyingTulipLendersByChain, frankencoinChainData, frankencoinConfig, frankencoinConfigFor, frankencoinLendersByChain, frankencoinMarketByPosition, frankencoinMarkets, fraxlendConfig, fraxlendConfigFor, fraxlendLendersByChain, fraxlendPairKey, fraxlendPairsFor, gearboxAccountCompressor, gearboxAddressProviderV310, gearboxBotListV3, gearboxChains, gearboxMarketCompressor, gearboxMarketConfigurators, gearboxResolvers, gearboxV3LenderKey, getAaveV4GatewayAddresses, getAaveV4PositionManagers, getAaveV4SpokeAccess, getAaveV4SpokeEntry, getAaveV4SpokePeripherals, getChainEntries, getSiloV2MarketEntry, getSiloV3MarketEntry, initConfig, initializeChainData, initializeLenderData, inverseChainData, inverseConfig, inverseConfigFor, inverseLendersByChain, inverseMarketByAddress, inverseMarkets, isAaveV4OperationRestricted, isListaSmartLpAsset, liquityBranchByIndex, liquityBranchByTroveManager, liquityBranchesByChain, liquityConfig, liquityConfigFor, liquityLendersByChain, liquityMarkets, listaCollateralProvider, listaCollateralProviders, listaNativeProvider, listaSmartLpByCollateral, llamaLendApiBaseUrl, llamaLendChainData, llamaLendConfig, llamaLendConfigFor, llamaLendLenderKey, llamaLendLendersByChain, llamaLendLeverageZap, llamaLendMarketByController, llamaLendMarketByVault, llamaLendMarkets, llamaLendSupportsDelegation, llamaLendSupportsLeverage, loadCached, loadCachedJson, midnightApiBaseOverride, midnightConfig, midnightMarketById, midnightMarkets, midnightMarketsByChain, morphoBundler3, morphoOracles, morphoPools, morphoTypeMarkets, morphoTypeOracles, morphoTypeVaults, parseAaveV4SpokeLenderKey, parseFraxlendPairKey, parseGearboxV3LenderKey, parseLlamaLendLenderKey, parseSiloV2LenderKey, parseSiloV3LenderKey, parseTermMaxLenderKey, resolveMidnightApiBase, resolveTermApiBase, resolveTermOrderStoreBase, resupplyConfig, resupplyConfigFor, resupplyLendersByChain, riverChainData, riverConfig, riverConfigFor, riverLendersByChain, riverMarketByIndex, riverMarkets, setMidnightApiBase, setRemoteCacheGithubToken, setRemoteCacheStore, setTermApiBase, setTermOrderStoreBase, siloMarkets, siloMarketsV3, siloPeripherals, siloPeripheralsV3, siloV2LenderKey, siloV3LenderKey, skyChainData, skyConfig, skyConfigFor, skyLendersByChain, skyMarkets, tellerConfig, tellerConfigByChain, tellerPoolByAddress, tellerPools, tellerPoolsByChain, termApiBaseOverride, termConfig, termMarketById, termMarkets, termMarketsByChain, termMaxApiBaseUrl, termMaxChainIds, termMaxConfig, termMaxConfigByChain, termMaxLenderKey, termOrderStoreBaseOverride, twyneBaseKey, twyneBeaconFor, twyneChainData, twyneConfig, twyneConfigFor, twyneLendersByChain, twyneMarketByKey, twyneMarketFor, twyneMarketKey, twyneMarkets, twyneMarketsForIntermediateVault, twyneOperator, usddChainData, usddConfig, usddConfigFor, usddLendersByChain, usddMarketByIlk, usddMarkets };
|
|
1199
|
+
export { COOLER_ETHEREUM_CONFIG, CURVANCE_MONAD_CONFIG, FRAXLEND_ETHEREUM_CONFIG, GEARBOX_ACCOUNT_COMPRESSOR_V310, REMOTE_CACHE_STORE_TTL_S, RESUPPLY_ETHEREUM_CONFIG, RemoteFetchError, aaveOracles, aaveOraclesConfig, aavePools, aaveReserves, aaveTokens, aaveV4Oracles, aaveV4Peripherals, aaveV4SpokeLenderKey, aaveV4Spokes, aaveWethGateway, assertTwyneKeysUnique, chainLogoURI, chains, clearRemoteCache, compoundV2Oracles, compoundV2OraclesConfig, compoundV2Pools, compoundV2Reserves, compoundV2TokenArray, compoundV2Tokens, compoundV3BaseData, compoundV3Bulker, compoundV3OraclesData, compoundV3Pools, compoundV3Reserves, coolerConfig, coolerConfigFor, coolerLendersByChain, curvanceConfig, curvanceConfigFor, curvanceLendersByChain, curvancePositionManager, curvancePositionManagersFor, dolomiteChains, dolomiteConfigs, dolomiteEmode, dolomiteMarketIdByToken, dssChainData, dssConfigFor, dssDebtJoin, dssDebtToken, dssMarketByIlk, eulerConfigs, eulerVaults, exactlyConfig, exactlyMarketByAddress, exactlyMarketByAsset, exactlyMarkets, exactlyMarketsByChain, fetchMainTokensMap, fetchRemoteJson, fetchTokenList, fetchTokenListFile, fetchTokenLists, findAaveV4PositionManager, fluidChains, fluidResolvers, fluidVaultEntries, fluidVaults, flyingTulipAssets, flyingTulipAssetsFor, flyingTulipConfig, flyingTulipConfigFor, flyingTulipLendersByChain, frankencoinChainData, frankencoinConfig, frankencoinConfigFor, frankencoinLendersByChain, frankencoinMarketByPosition, frankencoinMarkets, fraxlendConfig, fraxlendConfigFor, fraxlendLendersByChain, fraxlendPairKey, fraxlendPairsFor, gearboxAccountCompressor, gearboxAddressProviderV310, gearboxBotListV3, gearboxChains, gearboxMarketCompressor, gearboxMarketConfigurators, gearboxResolvers, gearboxV3LenderKey, getAaveV4GatewayAddresses, getAaveV4PositionManagers, getAaveV4SpokeAccess, getAaveV4SpokeEntry, getAaveV4SpokePeripherals, getChainEntries, getSiloV2MarketEntry, getSiloV3MarketEntry, initConfig, initializeChainData, initializeLenderData, inverseChainData, inverseConfig, inverseConfigFor, inverseLendersByChain, inverseMarketByAddress, inverseMarkets, isAaveV4OperationRestricted, isListaSmartLpAsset, liquityBranchByIndex, liquityBranchByTroveManager, liquityBranchesByChain, liquityConfig, liquityConfigFor, liquityLendersByChain, liquityMarkets, listaCollateralProvider, listaCollateralProviders, listaNativeProvider, listaSmartLpByCollateral, llamaLendApiBaseUrl, llamaLendChainData, llamaLendConfig, llamaLendConfigFor, llamaLendLenderKey, llamaLendLendersByChain, llamaLendLeverageZap, llamaLendMarketByController, llamaLendMarketByVault, llamaLendMarkets, llamaLendSupportsDelegation, llamaLendSupportsLeverage, loadCached, loadCachedJson, midnightApiBaseOverride, midnightConfig, midnightMarketById, midnightMarketIsEnterable, midnightMarkets, midnightMarketsByChain, midnightNotEnterableReason, morphoBundler3, morphoOracles, morphoPools, morphoTypeMarkets, morphoTypeOracles, morphoTypeVaults, parseAaveV4SpokeLenderKey, parseFraxlendPairKey, parseGearboxV3LenderKey, parseLlamaLendLenderKey, parseSiloV2LenderKey, parseSiloV3LenderKey, parseTermMaxLenderKey, resolveMidnightApiBase, resolveTenorApiUrl, resolveTermApiBase, resolveTermOrderStoreBase, resupplyConfig, resupplyConfigFor, resupplyLendersByChain, riverChainData, riverConfig, riverConfigFor, riverLendersByChain, riverMarketByIndex, riverMarkets, setMidnightApiBase, setRemoteCacheGithubToken, setRemoteCacheStore, setTenorApiUrl, setTermApiBase, setTermOrderStoreBase, siloMarkets, siloMarketsV3, siloPeripherals, siloPeripheralsV3, siloV2LenderKey, siloV3LenderKey, skyChainData, skyConfig, skyConfigFor, skyLendersByChain, skyMarkets, tellerConfig, tellerConfigByChain, tellerPoolByAddress, tellerPools, tellerPoolsByChain, tenorApiUrlOverride, termApiBaseOverride, termConfig, termMarketById, termMarkets, termMarketsByChain, termMaxApiBaseUrl, termMaxChainIds, termMaxConfig, termMaxConfigByChain, termMaxLenderKey, termOrderStoreBaseOverride, twyneBaseKey, twyneBeaconFor, twyneChainData, twyneConfig, twyneConfigFor, twyneLendersByChain, twyneMarketByKey, twyneMarketFor, twyneMarketKey, twyneMarkets, twyneMarketsForIntermediateVault, twyneOperator, usddChainData, usddConfig, usddConfigFor, usddLendersByChain, usddMarketByIlk, usddMarkets };
|
|
@@ -11,6 +11,12 @@ export type MidnightConfigChain = {
|
|
|
11
11
|
setterRatifier?: string | null;
|
|
12
12
|
/** Midnight HTTP API base for book/quote/offer data (defaults to Morpho hosted). */
|
|
13
13
|
apiBaseUrl?: string | null;
|
|
14
|
+
/**
|
|
15
|
+
* Tenor GraphQL endpoint — the PRIMARY rung of the source ladder for the
|
|
16
|
+
* roster and for offers; `apiBaseUrl` (Morpho's hosted Midnight API) is the
|
|
17
|
+
* fallback. Keyless and CORS-open. See TENOR_PLAN.md §0.6.
|
|
18
|
+
*/
|
|
19
|
+
tenorApiUrl?: string | null;
|
|
14
20
|
};
|
|
15
21
|
export type MidnightConfigType = {
|
|
16
22
|
[chainId: string]: MidnightConfigChain;
|
|
@@ -24,6 +30,33 @@ export type MidnightCollateralParam = {
|
|
|
24
30
|
liquidationCursor: string;
|
|
25
31
|
oracle: string;
|
|
26
32
|
decimals: number;
|
|
33
|
+
/**
|
|
34
|
+
* When this leg is an ERC-4626 wrapper listed as collateral (the Tenor
|
|
35
|
+
* "vault-as-collateral" structure — a Vault-V2 allocating 100% to one Morpho
|
|
36
|
+
* Blue market, listed at ~98% LLTV alongside the real collateral), this is
|
|
37
|
+
* the vault's own address, i.e. `token`. Absent for a plain token leg.
|
|
38
|
+
*
|
|
39
|
+
* The point of carrying it explicitly rather than sniffing `asset()` is that
|
|
40
|
+
* routing INTO this leg is a different action (wrap the loan token into the
|
|
41
|
+
* vault, then supply the shares) and the row's risk story is different too —
|
|
42
|
+
* the collateral is itself a lending position. See TENOR_PLAN.md §P4.
|
|
43
|
+
*/
|
|
44
|
+
collateralVault?: string | null;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Who may enter (take offers on) / liquidate a market. Midnight markets can pin
|
|
48
|
+
* an `enterGate` / `liquidatorGate` contract; zero address = permissionless.
|
|
49
|
+
*
|
|
50
|
+
* `'unknown'` is a REAL value and must not collapse into `'open'`: a gate
|
|
51
|
+
* contract we do not recognise is not an open market, and quoting it as one
|
|
52
|
+
* emits calldata that reverts. Callers gate on `enter !== 'open'`, never on the
|
|
53
|
+
* address being non-zero, so an unrecognised gate fails safe.
|
|
54
|
+
*/
|
|
55
|
+
export type MidnightGating = {
|
|
56
|
+
enter: 'open' | 'allowlist' | 'unknown';
|
|
57
|
+
liquidator: 'open' | 'allowlist' | 'unknown';
|
|
58
|
+
enterGate: string;
|
|
59
|
+
liquidatorGate: string;
|
|
27
60
|
};
|
|
28
61
|
/** A Midnight market: full struct params needed to build calls + read state. */
|
|
29
62
|
export type MidnightMarketConfig = {
|
|
@@ -56,6 +89,28 @@ export type MidnightMarketConfig = {
|
|
|
56
89
|
continuousFee?: string;
|
|
57
90
|
/** Optional display label, e.g. "USDC / WETH — 2026-09-18". */
|
|
58
91
|
name?: string;
|
|
92
|
+
/**
|
|
93
|
+
* Midnight `market_family_id` — the ROLL SERIES this maturity belongs to.
|
|
94
|
+
* Every 4-week roll of "cbBTC/USDC" shares one family id, so this is what a
|
|
95
|
+
* renewal targets ("the September roll of that series"). Absent when the
|
|
96
|
+
* roster came from a source that does not publish it.
|
|
97
|
+
*/
|
|
98
|
+
marketFamilyId?: string;
|
|
99
|
+
/** Tenor's own series id (`tenorMarkets.id`) — the curated grouping. */
|
|
100
|
+
tenorSeriesId?: string;
|
|
101
|
+
/** Morpho's own curation flag from the Midnight API's `listed`. */
|
|
102
|
+
listed?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* ENTRY IS CLOSED, the market is not dead. Set when Tenor has deprecated the
|
|
105
|
+
* market or its series: no new positions, but existing ones still accrue,
|
|
106
|
+
* repay, exit and liquidate — so the market MUST stay in the roster or every
|
|
107
|
+
* holder's position reads as nothing. (Deprecated series still held ~$239k of
|
|
108
|
+
* live positions when this was written.) Mirrors the offboarded-but-nonempty
|
|
109
|
+
* rule used for Sky ilks: drop only when it is both closed AND empty.
|
|
110
|
+
*/
|
|
111
|
+
deprecatedAt?: string | null;
|
|
112
|
+
/** Enter/liquidator gating. Absent means "not resolved", not "open". */
|
|
113
|
+
gating?: MidnightGating;
|
|
59
114
|
};
|
|
60
115
|
export type MidnightMarketsType = {
|
|
61
116
|
[chainId: string]: MidnightMarketConfig[];
|
|
@@ -65,8 +120,25 @@ export declare const setMidnightApiBase: (url: string | undefined | null) => voi
|
|
|
65
120
|
export declare const midnightApiBaseOverride: () => string | undefined;
|
|
66
121
|
/** Resolve the Midnight API base for a chain: override → config → hosted default. */
|
|
67
122
|
export declare const resolveMidnightApiBase: (chainId: string) => string;
|
|
123
|
+
export declare const setTenorApiUrl: (url: string | undefined | null) => void;
|
|
124
|
+
export declare const tenorApiUrlOverride: () => string | undefined;
|
|
125
|
+
/** Resolve the Tenor GraphQL endpoint for a chain: override → config → hosted default. */
|
|
126
|
+
export declare const resolveTenorApiUrl: (chainId: string) => string;
|
|
68
127
|
export declare const midnightMarkets: () => MidnightMarketsType;
|
|
69
128
|
/** All Midnight market configs on a chain (empty array if none/unloaded). */
|
|
70
129
|
export declare const midnightMarketsByChain: (chainId: string | number) => MidnightMarketConfig[];
|
|
71
130
|
/** Look up one Midnight market config by its bytes32 id (case-insensitive). */
|
|
72
131
|
export declare const midnightMarketById: (chainId: string | number, marketId: string) => MidnightMarketConfig | undefined;
|
|
132
|
+
/**
|
|
133
|
+
* May a NEW position be opened here? Fails safe in both directions:
|
|
134
|
+
* - `gating` absent → unresolved, not "open" → refuse.
|
|
135
|
+
* - `gating.enter !== 'open'` → allowlisted or unrecognised → refuse.
|
|
136
|
+
* - `deprecatedAt` in the past → entry closed by Tenor (the market itself
|
|
137
|
+
* stays serviceable: repay / withdraw / exit / liquidate are unaffected).
|
|
138
|
+
*
|
|
139
|
+
* Never gate a REDUCING action on this — a user in a gated or deprecated market
|
|
140
|
+
* must always be able to get out.
|
|
141
|
+
*/
|
|
142
|
+
export declare const midnightMarketIsEnterable: (market: Pick<MidnightMarketConfig, "gating" | "deprecatedAt" | "maturity">, nowSec?: number) => boolean;
|
|
143
|
+
/** Human-readable reason a market refuses new positions, or `undefined` if it does not. */
|
|
144
|
+
export declare const midnightNotEnterableReason: (market: Pick<MidnightMarketConfig, "gating" | "deprecatedAt" | "maturity">, nowSec?: number) => string | undefined;
|