@1delta/margin-fetcher 5.0.52 → 5.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 +111 -106
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import './chunk-BYTNVMX7.js';
|
|
|
3
3
|
import './chunk-PR4QN5HX.js';
|
|
4
4
|
import { Lender, isExactly, isMidnight, isTerm, isTermMax, isTeller, isListaDao, isLiquityFamily, isRiver, isInverse, isDssType, isCompoundV3Type, isFluid, isGearboxV3, isLlamaLend, isFrankencoin, isResupply, isCurvance, isTwyne, isFraxlend, LIQUITY_FAMILY_LENDERS, isAaveType, isCompoundV3, isMultiMarket, isSiloV2Type, isSiloV3Type, isDolomite, hasCrossMarginRisk, isEulerType, isAaveV4Type, isInit, isMorphoType, isCompoundV2Type, isVenusType, isSumerType, AAVE_V3_LENDERS, AAVE_V2_LENDERS, isMorphoBlue, isAaveV2Type, isAaveV32Type, isAaveV3Type, isUsdd, isSky, isYLDR, isLista, hasSubAccounts, isTectonicType, isKineticType, isBenqiType } from '@1delta/lender-registry';
|
|
5
5
|
export { hasCrossMarginRisk, isAaveType, isAaveV2Type, isAaveV32Type, isAaveV3Type, isCompoundV3, isCompoundV3Type, isInit, isMorphoType, isMultiMarket, isYLDR } from '@1delta/lender-registry';
|
|
6
|
-
import { fetchTokenLists, fetchTokenList, aavePools, compoundV3Pools, initConfig, morphoPools, compoundV2Pools, eulerVaults, siloMarkets, siloV2LenderKey, siloMarketsV3, siloV3LenderKey, aaveV4Spokes, aaveV4SpokeLenderKey, fluidResolvers, gearboxResolvers, dolomiteConfigs, midnightConfig, termConfig, termMarketsByChain, exactlyConfig, liquityLendersByChain, riverLendersByChain, inverseLendersByChain, llamaLendLendersByChain, usddLendersByChain, skyLendersByChain, frankencoinLendersByChain, resupplyLendersByChain, curvanceLendersByChain, fraxlendLendersByChain, tellerConfigByChain, tellerPoolsByChain, termMaxConfigByChain, aaveReserves, compoundV3Reserves, liquityConfigFor, liquityBranchesByChain, riverConfigFor, riverChainData, termMaxApiBaseUrl, termMaxLenderKey, inverseConfigFor, inverseChainData, llamaLendConfigFor, llamaLendChainData, llamaLendApiBaseUrl, resupplyConfigFor, fraxlendConfigFor, dssConfigFor, dssChainData, dssDebtToken, dssDebtJoin, frankencoinConfigFor, frankencoinChainData, aaveOracles, morphoTypeMarkets, resolveMidnightApiBase, resolveTermApiBase, llamaLendMarketByVault, getSiloV2MarketEntry, getSiloV3MarketEntry, dolomiteEmode, curvanceConfigFor, aaveTokens, morphoTypeVaults, listaCollateralProvider, eulerConfigs, gearboxMarketCompressor, gearboxMarketConfigurators, gearboxV3LenderKey, midnightMarketsByChain, twyneConfigFor, twyneChainData, parseAaveV4SpokeLenderKey, fraxlendPairsFor, gearboxAccountCompressor, compoundV2Tokens, exactlyMarketsByChain, aaveOraclesConfig, compoundV2Oracles, compoundV2TokenArray, compoundV2OraclesConfig, compoundV3OraclesData, compoundV3BaseData, compoundV2Reserves, aaveV4Oracles } from '@1delta/data-sdk';
|
|
6
|
+
import { fetchTokenLists, fetchTokenList, aavePools, compoundV3Pools, initConfig, morphoPools, compoundV2Pools, eulerVaults, siloMarkets, siloV2LenderKey, siloMarketsV3, siloV3LenderKey, aaveV4Spokes, aaveV4SpokeLenderKey, fluidResolvers, gearboxResolvers, dolomiteConfigs, midnightConfig, termConfig, termMarketsByChain, exactlyConfig, liquityLendersByChain, riverLendersByChain, inverseLendersByChain, llamaLendLendersByChain, usddLendersByChain, skyLendersByChain, frankencoinLendersByChain, resupplyLendersByChain, curvanceLendersByChain, fraxlendLendersByChain, twyneLendersByChain, tellerConfigByChain, tellerPoolsByChain, termMaxConfigByChain, aaveReserves, compoundV3Reserves, liquityConfigFor, liquityBranchesByChain, riverConfigFor, riverChainData, termMaxApiBaseUrl, termMaxLenderKey, inverseConfigFor, inverseChainData, llamaLendConfigFor, llamaLendChainData, llamaLendApiBaseUrl, resupplyConfigFor, fraxlendConfigFor, dssConfigFor, dssChainData, dssDebtToken, dssDebtJoin, frankencoinConfigFor, frankencoinChainData, aaveOracles, morphoTypeMarkets, resolveMidnightApiBase, resolveTermApiBase, llamaLendMarketByVault, getSiloV2MarketEntry, getSiloV3MarketEntry, dolomiteEmode, curvanceConfigFor, aaveTokens, morphoTypeVaults, listaCollateralProvider, eulerConfigs, gearboxMarketCompressor, gearboxMarketConfigurators, gearboxV3LenderKey, midnightMarketsByChain, twyneConfigFor, twyneChainData, parseAaveV4SpokeLenderKey, fraxlendPairsFor, gearboxAccountCompressor, compoundV2Tokens, exactlyMarketsByChain, aaveOraclesConfig, compoundV2Oracles, compoundV2TokenArray, compoundV2OraclesConfig, compoundV3OraclesData, compoundV3BaseData, compoundV2Reserves, aaveV4Oracles } from '@1delta/data-sdk';
|
|
7
7
|
import lodash from 'lodash';
|
|
8
8
|
import { Chain } from '@1delta/chain-registry';
|
|
9
9
|
import { multicallRetryUniversal, getEvmClient, getEvmChain, getEvmClientUniversal } from '@1delta/providers';
|
|
@@ -6439,6 +6439,9 @@ var getLendersForChain = (c) => {
|
|
|
6439
6439
|
for (const l of fraxlendLendersByChain(c)) {
|
|
6440
6440
|
lenders.push(l);
|
|
6441
6441
|
}
|
|
6442
|
+
for (const l of twyneLendersByChain(c)) {
|
|
6443
|
+
lenders.push(l);
|
|
6444
|
+
}
|
|
6442
6445
|
if (tellerConfigByChain(c)?.tellerV2 && tellerPoolsByChain(c).length > 0) {
|
|
6443
6446
|
lenders.push(Lender.TELLER);
|
|
6444
6447
|
}
|
|
@@ -55610,16 +55613,116 @@ var fetchGearboxV3Pools = async (chainId, multicallRetry, prices = {}, tokenList
|
|
|
55610
55613
|
return converter(raw) ?? {};
|
|
55611
55614
|
};
|
|
55612
55615
|
|
|
55616
|
+
// src/vaults/curatorName.ts
|
|
55617
|
+
var STOP_WORDS = /* @__PURE__ */ new Set([
|
|
55618
|
+
"vault",
|
|
55619
|
+
"vaults",
|
|
55620
|
+
"savings",
|
|
55621
|
+
"yield",
|
|
55622
|
+
"exclusive",
|
|
55623
|
+
"dao",
|
|
55624
|
+
"x",
|
|
55625
|
+
"pt",
|
|
55626
|
+
"prime",
|
|
55627
|
+
"staked",
|
|
55628
|
+
"core",
|
|
55629
|
+
"rwa",
|
|
55630
|
+
"lista",
|
|
55631
|
+
// protocol brand; a bare "Lista …" vault has no distinct curator
|
|
55632
|
+
"moolah"
|
|
55633
|
+
]);
|
|
55634
|
+
var ASSET_TOKENS = /* @__PURE__ */ new Set([
|
|
55635
|
+
"usdc",
|
|
55636
|
+
"usdt",
|
|
55637
|
+
"usd1",
|
|
55638
|
+
"usds",
|
|
55639
|
+
"dai",
|
|
55640
|
+
"usde",
|
|
55641
|
+
"susde",
|
|
55642
|
+
"lisusd",
|
|
55643
|
+
"gho",
|
|
55644
|
+
"frax",
|
|
55645
|
+
"pyusd",
|
|
55646
|
+
"rusd",
|
|
55647
|
+
"usr",
|
|
55648
|
+
"rlp",
|
|
55649
|
+
"eth",
|
|
55650
|
+
"weth",
|
|
55651
|
+
"wsteth",
|
|
55652
|
+
"reth",
|
|
55653
|
+
"steth",
|
|
55654
|
+
"cbeth",
|
|
55655
|
+
"weeth",
|
|
55656
|
+
"ezeth",
|
|
55657
|
+
"btc",
|
|
55658
|
+
"wbtc",
|
|
55659
|
+
"btcb",
|
|
55660
|
+
"cbbtc",
|
|
55661
|
+
"tbtc",
|
|
55662
|
+
"xaut",
|
|
55663
|
+
"xrp",
|
|
55664
|
+
"bnb",
|
|
55665
|
+
"wbnb",
|
|
55666
|
+
"sol",
|
|
55667
|
+
"op",
|
|
55668
|
+
"arb",
|
|
55669
|
+
"avax",
|
|
55670
|
+
"pol",
|
|
55671
|
+
"matic",
|
|
55672
|
+
"sei",
|
|
55673
|
+
"celo",
|
|
55674
|
+
"hype",
|
|
55675
|
+
"plume",
|
|
55676
|
+
"s"
|
|
55677
|
+
]);
|
|
55678
|
+
var isAssetToken = (tl, asset) => {
|
|
55679
|
+
if (asset && tl === asset || ASSET_TOKENS.has(tl) || tl.includes("usd")) {
|
|
55680
|
+
return true;
|
|
55681
|
+
}
|
|
55682
|
+
const unwrapped = tl.replace(/^(cb|wst|ws|w|st)/, "");
|
|
55683
|
+
return unwrapped !== tl && ASSET_TOKENS.has(unwrapped);
|
|
55684
|
+
};
|
|
55685
|
+
function curatorNameFromVaultName(name, assetSymbol) {
|
|
55686
|
+
if (!name) return void 0;
|
|
55687
|
+
if (/\b(test|testing|fake)\b/i.test(name)) return void 0;
|
|
55688
|
+
const by = /\bby\s+(.{2,})$/i.exec(name);
|
|
55689
|
+
if (by) {
|
|
55690
|
+
const suffix = by[1].trim().split(/\s+/).slice(0, 3).join(" ");
|
|
55691
|
+
if (suffix.length >= 2 && !isAssetToken(suffix.toLowerCase(), (assetSymbol ?? "").toLowerCase())) {
|
|
55692
|
+
return suffix;
|
|
55693
|
+
}
|
|
55694
|
+
}
|
|
55695
|
+
const cleaned = name.replace(/\([^)]*\)\s*$/, "").split(":")[0].trim();
|
|
55696
|
+
if (!cleaned) return void 0;
|
|
55697
|
+
const tokens = cleaned.split(/[\s/]+/).flatMap((t) => t.split("-")).filter(Boolean);
|
|
55698
|
+
const asset = (assetSymbol ?? "").toLowerCase();
|
|
55699
|
+
const out = [];
|
|
55700
|
+
let terminated = false;
|
|
55701
|
+
for (const tok of tokens) {
|
|
55702
|
+
const tl = tok.toLowerCase();
|
|
55703
|
+
if (STOP_WORDS.has(tl) || isAssetToken(tl, asset)) {
|
|
55704
|
+
terminated = true;
|
|
55705
|
+
break;
|
|
55706
|
+
}
|
|
55707
|
+
out.push(tok);
|
|
55708
|
+
if (out.length >= 3) break;
|
|
55709
|
+
}
|
|
55710
|
+
if (!terminated || out.length === tokens.length) return void 0;
|
|
55711
|
+
const curator = out.join(" ").trim();
|
|
55712
|
+
return curator.length >= 2 ? curator : void 0;
|
|
55713
|
+
}
|
|
55714
|
+
|
|
55613
55715
|
// src/vaults/morpho/fetchFromApi.ts
|
|
55614
55716
|
var MORPHO_SHARE_DECIMALS = 18;
|
|
55615
55717
|
var MORPHO_API_URL = "https://blue-api.morpho.org/graphql";
|
|
55616
55718
|
var PAGE_SIZE2 = 200;
|
|
55719
|
+
var MIN_TOTAL_ASSETS_USD = 100;
|
|
55617
55720
|
var vaultsQuery = (first, skip, chainId) => `
|
|
55618
55721
|
query GetVaults {
|
|
55619
55722
|
vaults(
|
|
55620
55723
|
first: ${first},
|
|
55621
55724
|
skip: ${skip},
|
|
55622
|
-
where: { chainId_in: [${chainId}],
|
|
55725
|
+
where: { chainId_in: [${chainId}], totalAssetsUsd_gte: ${MIN_TOTAL_ASSETS_USD} },
|
|
55623
55726
|
orderBy: TotalAssetsUsd,
|
|
55624
55727
|
orderDirection: Desc
|
|
55625
55728
|
) {
|
|
@@ -55738,6 +55841,7 @@ function parseVault2(v, chainId, prices, tokenList) {
|
|
|
55738
55841
|
const totalAssetsUsd = apiTotalAssetsUsd || totalAssetsFormatted * resolvedPriceUsd;
|
|
55739
55842
|
const curators = parseCurators(state.curators);
|
|
55740
55843
|
const primaryCurator = curators?.[0];
|
|
55844
|
+
const curatorName = primaryCurator?.name ?? curatorNameFromVaultName(v.name, v.asset?.symbol ?? assetMeta?.symbol);
|
|
55741
55845
|
return {
|
|
55742
55846
|
address,
|
|
55743
55847
|
underlying: assetAddr,
|
|
@@ -55745,7 +55849,7 @@ function parseVault2(v, chainId, prices, tokenList) {
|
|
|
55745
55849
|
name: v.name ?? "",
|
|
55746
55850
|
displayName: composeVaultDisplayName(
|
|
55747
55851
|
"Morpho",
|
|
55748
|
-
|
|
55852
|
+
curatorName,
|
|
55749
55853
|
assetMeta,
|
|
55750
55854
|
v.name ?? void 0
|
|
55751
55855
|
),
|
|
@@ -55758,11 +55862,13 @@ function parseVault2(v, chainId, prices, tokenList) {
|
|
|
55758
55862
|
depositRate: supplyRate + rewardsRate,
|
|
55759
55863
|
fee: Number(state.fee ?? 0) * 100,
|
|
55760
55864
|
timelock: Number(state.timelock ?? 0),
|
|
55865
|
+
// Since Aug-2026 `listed` means "listed in the Morpho app" (a far smaller
|
|
55866
|
+
// set than the old curated flag) — informational only, never a row filter.
|
|
55761
55867
|
whitelisted: v.whitelisted ?? true,
|
|
55762
55868
|
owner: state.owner?.toLowerCase() || void 0,
|
|
55763
55869
|
curator: state.curator?.toLowerCase() || void 0,
|
|
55764
55870
|
guardian: state.guardian?.toLowerCase() || void 0,
|
|
55765
|
-
curatorName
|
|
55871
|
+
curatorName,
|
|
55766
55872
|
curatorImage: primaryCurator?.image,
|
|
55767
55873
|
curators,
|
|
55768
55874
|
asset: assetMeta,
|
|
@@ -55774,7 +55880,7 @@ function parseVault2(v, chainId, prices, tokenList) {
|
|
|
55774
55880
|
liquidityUsd: liquidityUsd || liquidityFormatted * resolvedPriceUsd
|
|
55775
55881
|
};
|
|
55776
55882
|
}
|
|
55777
|
-
async function fetchMorphoVaultsFromApi(chainId, prices = {}, tokenList = {}, maxItems =
|
|
55883
|
+
async function fetchMorphoVaultsFromApi(chainId, prices = {}, tokenList = {}, maxItems = 1e3) {
|
|
55778
55884
|
const out = {};
|
|
55779
55885
|
let skip = 0;
|
|
55780
55886
|
while (skip < maxItems) {
|
|
@@ -56415,107 +56521,6 @@ var fetchMorphoVaults = async (chainId, multicallRetry, prices = {}, tokenList =
|
|
|
56415
56521
|
}
|
|
56416
56522
|
return fetchMorphoVaultsFromApi(chainId, prices, tokenList);
|
|
56417
56523
|
};
|
|
56418
|
-
|
|
56419
|
-
// src/vaults/curatorName.ts
|
|
56420
|
-
var STOP_WORDS = /* @__PURE__ */ new Set([
|
|
56421
|
-
"vault",
|
|
56422
|
-
"vaults",
|
|
56423
|
-
"savings",
|
|
56424
|
-
"yield",
|
|
56425
|
-
"exclusive",
|
|
56426
|
-
"dao",
|
|
56427
|
-
"x",
|
|
56428
|
-
"pt",
|
|
56429
|
-
"prime",
|
|
56430
|
-
"staked",
|
|
56431
|
-
"core",
|
|
56432
|
-
"rwa",
|
|
56433
|
-
"lista",
|
|
56434
|
-
// protocol brand; a bare "Lista …" vault has no distinct curator
|
|
56435
|
-
"moolah"
|
|
56436
|
-
]);
|
|
56437
|
-
var ASSET_TOKENS = /* @__PURE__ */ new Set([
|
|
56438
|
-
"usdc",
|
|
56439
|
-
"usdt",
|
|
56440
|
-
"usd1",
|
|
56441
|
-
"usds",
|
|
56442
|
-
"dai",
|
|
56443
|
-
"usde",
|
|
56444
|
-
"susde",
|
|
56445
|
-
"lisusd",
|
|
56446
|
-
"gho",
|
|
56447
|
-
"frax",
|
|
56448
|
-
"pyusd",
|
|
56449
|
-
"rusd",
|
|
56450
|
-
"usr",
|
|
56451
|
-
"rlp",
|
|
56452
|
-
"eth",
|
|
56453
|
-
"weth",
|
|
56454
|
-
"wsteth",
|
|
56455
|
-
"reth",
|
|
56456
|
-
"steth",
|
|
56457
|
-
"cbeth",
|
|
56458
|
-
"weeth",
|
|
56459
|
-
"ezeth",
|
|
56460
|
-
"btc",
|
|
56461
|
-
"wbtc",
|
|
56462
|
-
"btcb",
|
|
56463
|
-
"cbbtc",
|
|
56464
|
-
"tbtc",
|
|
56465
|
-
"xaut",
|
|
56466
|
-
"xrp",
|
|
56467
|
-
"bnb",
|
|
56468
|
-
"wbnb",
|
|
56469
|
-
"sol",
|
|
56470
|
-
"op",
|
|
56471
|
-
"arb",
|
|
56472
|
-
"avax",
|
|
56473
|
-
"pol",
|
|
56474
|
-
"matic",
|
|
56475
|
-
"sei",
|
|
56476
|
-
"celo",
|
|
56477
|
-
"hype",
|
|
56478
|
-
"plume",
|
|
56479
|
-
"s"
|
|
56480
|
-
]);
|
|
56481
|
-
var isAssetToken = (tl, asset) => {
|
|
56482
|
-
if (asset && tl === asset || ASSET_TOKENS.has(tl) || tl.includes("usd")) {
|
|
56483
|
-
return true;
|
|
56484
|
-
}
|
|
56485
|
-
const unwrapped = tl.replace(/^(cb|wst|ws|w|st)/, "");
|
|
56486
|
-
return unwrapped !== tl && ASSET_TOKENS.has(unwrapped);
|
|
56487
|
-
};
|
|
56488
|
-
function curatorNameFromVaultName(name, assetSymbol) {
|
|
56489
|
-
if (!name) return void 0;
|
|
56490
|
-
if (/\b(test|testing|fake)\b/i.test(name)) return void 0;
|
|
56491
|
-
const by = /\bby\s+(.{2,})$/i.exec(name);
|
|
56492
|
-
if (by) {
|
|
56493
|
-
const suffix = by[1].trim().split(/\s+/).slice(0, 3).join(" ");
|
|
56494
|
-
if (suffix.length >= 2 && !isAssetToken(suffix.toLowerCase(), (assetSymbol ?? "").toLowerCase())) {
|
|
56495
|
-
return suffix;
|
|
56496
|
-
}
|
|
56497
|
-
}
|
|
56498
|
-
const cleaned = name.replace(/\([^)]*\)\s*$/, "").split(":")[0].trim();
|
|
56499
|
-
if (!cleaned) return void 0;
|
|
56500
|
-
const tokens = cleaned.split(/[\s/]+/).flatMap((t) => t.split("-")).filter(Boolean);
|
|
56501
|
-
const asset = (assetSymbol ?? "").toLowerCase();
|
|
56502
|
-
const out = [];
|
|
56503
|
-
let terminated = false;
|
|
56504
|
-
for (const tok of tokens) {
|
|
56505
|
-
const tl = tok.toLowerCase();
|
|
56506
|
-
if (STOP_WORDS.has(tl) || isAssetToken(tl, asset)) {
|
|
56507
|
-
terminated = true;
|
|
56508
|
-
break;
|
|
56509
|
-
}
|
|
56510
|
-
out.push(tok);
|
|
56511
|
-
if (out.length >= 3) break;
|
|
56512
|
-
}
|
|
56513
|
-
if (!terminated || out.length === tokens.length) return void 0;
|
|
56514
|
-
const curator = out.join(" ").trim();
|
|
56515
|
-
return curator.length >= 2 ? curator : void 0;
|
|
56516
|
-
}
|
|
56517
|
-
|
|
56518
|
-
// src/vaults/morpho/fetchListaFromChain.ts
|
|
56519
56524
|
var { chunk: chunk6 } = lodash;
|
|
56520
56525
|
var LISTA_PROTOCOL = "LISTA_DAO";
|
|
56521
56526
|
var LISTA_LENS_ABI = parseAbi([
|