@1delta/margin-fetcher 5.0.149 → 5.0.151
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.d.ts +242 -2
- package/dist/index.js +1783 -324
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -9,10 +9,10 @@ import { Chain, isEvmChainId, isRetiredChain, isSvmChainId } from '@1delta/chain
|
|
|
9
9
|
import { multicallRetryUniversal, getEvmClient, getEvmClientWithCustomRpcsUniversal, LIST_OVERRIDES, getEvmChain, createMulticallRetryUniversal, getEvmClientUniversal } from '@1delta/providers';
|
|
10
10
|
import { LiquityTroveManagerAbi, LiquityActivePoolAbi, LiquityStabilityPoolAbi, LiquityPriceFeedAbi, LiquitySortedTrovesAbi, RiverTroveManagerAbi, RiverStabilityPoolAbi, TellerMarketRegistryAbi, TellerV2Abi, InverseMarketAbi, InverseOracleAbi, InverseDbrAbi, CurveTricryptoOracleAbi, Erc20Abi, CoolerMonoAbi, CoolerLtvOracleAbi, LlamaLendControllerAbi, LlamaLendControllerV1Abi, LlamaLendControllerV2Abi, LlamaLendVaultAbi, LlamaLendAmmAbi, TwyneCollateralVaultAbi, MetaMorphoAbi, FluidDexResolverAbi, ExactlyPreviewerAbi, ExactlyAuditorAbi, FlyingTulipLendingLensAbi, LiquityMultiTroveGetterAbi, LenderCommitmentGroupAbi, ResupplyRegistryAbi, ResupplyPairAbi, ResupplyUtilitiesAbi, ResupplyRewardHandlerAbi, ResupplyPairEmissionsAbi, ConvexPoolUtilAbi, FraxlendPairAbi, FraxlendLeverAbi, RipeMissionControlAbi, RipeLedgerAbi, RipeVaultBookAbi, RipePriceDeskAbi, RipeVaultAbi, RipeCreditEngineAbi, FrankencoinPositionAbi, FluidLendingResolverAbi, FluidVaultResolverAbi, FluidLiquidityResolverAbi, MoolahVaultAbi, UsddVatAbi, UsddJugAbi, UsddSpotAbi, MorphoLensAbi, AaveV4SpokeAbi, AaveV4OracleAbi, AaveV4HubAbi, DolomiteMarginAbi, GearboxMarketCompressorV310Abi, MorphoBlueAbi, MidnightAbi, TermRepoTokenAbi, TermRepoServicerAbi, TermRepoCollateralManagerAbi, LiquityTroveNFTAbi, LiquityCollSurplusPoolAbi, TellerCollateralManagerAbi, TermMaxViewerAbi, InverseEscrowAbi, AlchemixAlchemistAbi, FlexTroveManagerAbi, CurvanceMarketManagerAbi, CurvanceCTokenAbi, GearboxCreditAccountCompressorV310Abi, RipeHqAbi, TwyneVaultManagerAbi, TwyneCollateralVaultFactoryAbi, AaveV2V3Abi, TwyneATokenWrapperAbi, AlchemixPositionNftAbi, UsddCdpManagerAbi, UsddProxyRegistryAbi, CurvanceProtocolReaderAbi, CurvanceCentralRegistryAbi, TermPriceConsumerAbi, CurvanceOracleManagerAbi, FlexPriceOracleAbi, TermMaxOracleAggregatorV2Abi, AlchemixTransmuterAbi, FlexSortedTrovesAbi, FlexTokenizedStrategyAbi } from '@1delta/abis';
|
|
11
11
|
export { MorphoLensAbi } from '@1delta/abis';
|
|
12
|
-
import { NEST_SAVINGS_VAULTS, NEST_PREDICATE_PROXY, NEST_USDC, SUPERFORM_SUPERVAULTS, IPOR_FUSION_VAULTS, ROYCO_TRANCHES, STRATA_META_TRANCHES, MIDAS_VAULTS, MORINI_FXARB, EMBER_VAULTS, USDAI_STAKED, MAKINA_MACHINES, YUZU_VAULTS, CONCRETE_VAULTS, MELLOW_VAULTS, AERA_VAULTS, EVA_VAULTS, prepareDebitDataMulticall, prepareLenderDebitMulticall, parseDebitDataResult, parseLenderDebitResult, getPermit2ContractAddress, getLstAcceptedInputs, savingsVerbRequires, savingsSupportsVerb, getCompoundV2Comptroller as getCompoundV2Comptroller$1, getCompoundV3CometAddress as getCompoundV3CometAddress$1, getMorphoAddress, FLUID_VAULT_FACTORY, getAaveStyleLenderTokenAddress, LendingMode, getAaveCollateralTokenAddress, getSiloHalfForUnderlying, findSavingsWithdrawEntry, bandLtvCurve, InitMarginAddresses, ignoresReceiver, buildLstWithdrawRequest, savingsReceiverCapability } from '@1delta/calldata-sdk';
|
|
12
|
+
import { NEST_SAVINGS_VAULTS, NEST_PREDICATE_PROXY, NEST_USDC, SUPERFORM_SUPERVAULTS, IPOR_FUSION_VAULTS, MEZZANINE_TRANCHES, ROYCO_TRANCHES, STRATA_META_TRANCHES, MIDAS_VAULTS, MORINI_FXARB, EMBER_VAULTS, USDAI_STAKED, MAKINA_MACHINES, YUZU_VAULTS, CONCRETE_VAULTS, MELLOW_VAULTS, AERA_VAULTS, EVA_VAULTS, prepareDebitDataMulticall, prepareLenderDebitMulticall, parseDebitDataResult, parseLenderDebitResult, getPermit2ContractAddress, getLstAcceptedInputs, savingsVerbRequires, savingsSupportsVerb, getCompoundV2Comptroller as getCompoundV2Comptroller$1, getCompoundV3CometAddress as getCompoundV3CometAddress$1, getMorphoAddress, FLUID_VAULT_FACTORY, getAaveStyleLenderTokenAddress, LendingMode, getAaveCollateralTokenAddress, getSiloHalfForUnderlying, findSavingsWithdrawEntry, bandLtvCurve, InitMarginAddresses, ignoresReceiver, buildLstWithdrawRequest, savingsReceiverCapability } from '@1delta/calldata-sdk';
|
|
13
13
|
import { proxyNativeFetch } from '@1delta/proxy-fetch';
|
|
14
|
+
import { getNativeDecimals, getWrappedNativeAddressSafe, isNativeWrapOneToOne, WRAPPED_NATIVE_INFO } from '@1delta/wnative';
|
|
14
15
|
import { BALANCER_V2_FORKS, BALANCER_V3_FORKS, UNISWAP_V4_FORKS, isFlashLoanSourceExcluded, FLASH_LOAN_IDS } from '@1delta/dex-registry';
|
|
15
|
-
import { getNativeDecimals, getWrappedNativeAddressSafe, isNativeWrapOneToOne } from '@1delta/wnative';
|
|
16
16
|
|
|
17
17
|
// src/abis/aave-v2/ProtocolDataProvider.ts
|
|
18
18
|
var ProtocolDataProviderAbi = [
|
|
@@ -24810,34 +24810,15 @@ function buildRateQueue(input) {
|
|
|
24810
24810
|
}
|
|
24811
24811
|
const full = [...merged.entries()].sort((a, b) => a[0] - b[0]).map(([apr, raw]) => ({ apr, raw, assets: Number(raw) / scale3 }));
|
|
24812
24812
|
const totalDebt = full.reduce((t, l) => t + l.assets, 0);
|
|
24813
|
-
const
|
|
24814
|
-
|
|
24815
|
-
|
|
24816
|
-
|
|
24817
|
-
|
|
24818
|
-
|
|
24819
|
-
|
|
24820
|
-
|
|
24821
|
-
|
|
24822
|
-
cum += l.assets;
|
|
24823
|
-
if (cum >= target * (1 - 1e-9)) {
|
|
24824
|
-
crossing = l.apr;
|
|
24825
|
-
break;
|
|
24826
|
-
}
|
|
24827
|
-
}
|
|
24828
|
-
apr = stepAbove(crossing);
|
|
24829
|
-
}
|
|
24830
|
-
apr = Math.min(Math.max(apr, min), max);
|
|
24831
|
-
const debtAhead = debtAheadOf(full, apr);
|
|
24832
|
-
picks.push({
|
|
24833
|
-
id: p.id,
|
|
24834
|
-
apr,
|
|
24835
|
-
debtAhead,
|
|
24836
|
-
share: totalDebt > 0 ? debtAhead / totalDebt : 0,
|
|
24837
|
-
upfrontFeePct: input.upfrontFeePct(apr)
|
|
24838
|
-
});
|
|
24839
|
-
}
|
|
24840
|
-
}
|
|
24813
|
+
const fill = input.idleRaw != null ? { idle: Number(input.idleRaw) / scale3 } : void 0;
|
|
24814
|
+
const picks = input.closed ? [] : pickRates({
|
|
24815
|
+
levels: full,
|
|
24816
|
+
totalDebt,
|
|
24817
|
+
min,
|
|
24818
|
+
max,
|
|
24819
|
+
fill,
|
|
24820
|
+
upfrontFeePct: input.upfrontFeePct
|
|
24821
|
+
});
|
|
24841
24822
|
return {
|
|
24842
24823
|
levels: compressLevels(full, input.maxLevels ?? RATE_QUEUE_MAX_LEVELS),
|
|
24843
24824
|
totalDebt,
|
|
@@ -24846,9 +24827,68 @@ function buildRateQueue(input) {
|
|
|
24846
24827
|
picks,
|
|
24847
24828
|
...picks.length ? { recommended: pressure.level === "high" ? "protected" : "balanced" } : {},
|
|
24848
24829
|
pressure,
|
|
24849
|
-
complete: input.complete ?? true
|
|
24830
|
+
complete: input.complete ?? true,
|
|
24831
|
+
...fill ? { fill } : {}
|
|
24850
24832
|
};
|
|
24851
24833
|
}
|
|
24834
|
+
function fillCapacityAt(levels, idle, apr) {
|
|
24835
|
+
let t = idle;
|
|
24836
|
+
for (const l of levels) if (l.apr < apr - 1e-9) t += l.assets;
|
|
24837
|
+
return t;
|
|
24838
|
+
}
|
|
24839
|
+
function pickRates(q) {
|
|
24840
|
+
const { levels, totalDebt, min, max, fill } = q;
|
|
24841
|
+
const size = Math.max(0, q.size ?? 0);
|
|
24842
|
+
const clamp = (r) => Math.min(Math.max(r, min), max);
|
|
24843
|
+
const floorTaken = levels.some((l) => l.apr <= min + 1e-9);
|
|
24844
|
+
const candidates = [
|
|
24845
|
+
.../* @__PURE__ */ new Set([
|
|
24846
|
+
...floorTaken ? [] : [min],
|
|
24847
|
+
...levels.map((l) => clamp(stepAbove(l.apr)))
|
|
24848
|
+
])
|
|
24849
|
+
].sort((a, b) => a - b);
|
|
24850
|
+
const at2 = (apr) => {
|
|
24851
|
+
const capacity = fill ? fillCapacityAt(levels, fill.idle, apr) : void 0;
|
|
24852
|
+
const redeemed = fill ? Math.max(0, size - fill.idle) : 0;
|
|
24853
|
+
const debtAhead = Math.max(0, debtAheadOf(levels, apr) - redeemed);
|
|
24854
|
+
const total = totalDebt - redeemed;
|
|
24855
|
+
return {
|
|
24856
|
+
capacity,
|
|
24857
|
+
debtAhead,
|
|
24858
|
+
share: total > 0 ? debtAhead / total : 0,
|
|
24859
|
+
fills: capacity == null || capacity >= size * (1 - 1e-9)
|
|
24860
|
+
};
|
|
24861
|
+
};
|
|
24862
|
+
const out = [];
|
|
24863
|
+
for (const p of USER_SET_RATE_PICKS) {
|
|
24864
|
+
const fillable = candidates.filter((c) => at2(c).fills);
|
|
24865
|
+
if (!fillable.length) continue;
|
|
24866
|
+
const apr = totalDebt > 0 ? fillable.find((c) => at2(c).share >= p.share * (1 - 1e-9)) ?? fillable[fillable.length - 1] : fillable[0];
|
|
24867
|
+
const a = at2(apr);
|
|
24868
|
+
out.push({
|
|
24869
|
+
id: p.id,
|
|
24870
|
+
apr,
|
|
24871
|
+
debtAhead: a.debtAhead,
|
|
24872
|
+
share: a.share,
|
|
24873
|
+
upfrontFeePct: q.upfrontFeePct(apr),
|
|
24874
|
+
...a.capacity != null ? { capacity: a.capacity } : {}
|
|
24875
|
+
});
|
|
24876
|
+
}
|
|
24877
|
+
return out;
|
|
24878
|
+
}
|
|
24879
|
+
function resolveRatePicks(q, size) {
|
|
24880
|
+
const fee = q.picks[0]?.upfrontFeePct ?? 0;
|
|
24881
|
+
if (!q.picks.length) return [];
|
|
24882
|
+
return pickRates({
|
|
24883
|
+
levels: q.levels,
|
|
24884
|
+
totalDebt: q.totalDebt,
|
|
24885
|
+
min: q.min,
|
|
24886
|
+
max: q.max,
|
|
24887
|
+
fill: q.fill,
|
|
24888
|
+
upfrontFeePct: () => fee,
|
|
24889
|
+
size
|
|
24890
|
+
});
|
|
24891
|
+
}
|
|
24852
24892
|
function compressLevels(full, cap) {
|
|
24853
24893
|
const toLevel = (apr2, raw2, assets2) => ({
|
|
24854
24894
|
apr: apr2,
|
|
@@ -25483,7 +25523,7 @@ async function fetchTellerMarkets(chainId, multicallRetry = multicallRetryUniver
|
|
|
25483
25523
|
}
|
|
25484
25524
|
return null;
|
|
25485
25525
|
};
|
|
25486
|
-
const
|
|
25526
|
+
const num24 = (i) => {
|
|
25487
25527
|
const b = big32(i);
|
|
25488
25528
|
return b === null ? null : Number(b);
|
|
25489
25529
|
};
|
|
@@ -25493,9 +25533,9 @@ async function fetchTellerMarkets(chainId, multicallRetry = multicallRetryUniver
|
|
|
25493
25533
|
config,
|
|
25494
25534
|
available: big32(base),
|
|
25495
25535
|
committed: big32(base + 1),
|
|
25496
|
-
minRateBps:
|
|
25536
|
+
minRateBps: num24(base + 2),
|
|
25497
25537
|
collateralPerPrincipal: big32(base + 3),
|
|
25498
|
-
maxLoanDuration:
|
|
25538
|
+
maxLoanDuration: num24(base + 4),
|
|
25499
25539
|
marketId: big32(base + 5),
|
|
25500
25540
|
totalAssets: big32(base + 6)
|
|
25501
25541
|
};
|
|
@@ -26693,20 +26733,20 @@ async function fetchInverseMarkets(lender, chainId, multicallRetry = multicallRe
|
|
|
26693
26733
|
if (Object.keys(byAddr).length > 0) {
|
|
26694
26734
|
const rows = markets.map((market) => {
|
|
26695
26735
|
const m = byAddr[market.address.toLowerCase()];
|
|
26696
|
-
const
|
|
26736
|
+
const num24 = (v) => typeof v === "number" && Number.isFinite(v) ? v : null;
|
|
26697
26737
|
return {
|
|
26698
26738
|
market,
|
|
26699
|
-
totalDebt:
|
|
26700
|
-
dolaLiquidity:
|
|
26701
|
-
leftToBorrow:
|
|
26702
|
-
price:
|
|
26739
|
+
totalDebt: num24(m?.totalDebt),
|
|
26740
|
+
dolaLiquidity: num24(m?.dolaLiquidity),
|
|
26741
|
+
leftToBorrow: num24(m?.leftToBorrow),
|
|
26742
|
+
price: num24(m?.price),
|
|
26703
26743
|
borrowPaused: typeof m?.borrowPaused === "boolean" ? m.borrowPaused : null,
|
|
26704
|
-
dailyBorrows:
|
|
26744
|
+
dailyBorrows: num24(m?.dailyBorrows),
|
|
26705
26745
|
// The API serves it as a DECIMAL (`replenishmentIncentive: 0.1`),
|
|
26706
26746
|
// unlike the on-chain bps — normalize here, and fall back to the
|
|
26707
26747
|
// curated metadata value when the field is missing.
|
|
26708
26748
|
replenishmentIncentiveBps: (() => {
|
|
26709
|
-
const dec2 =
|
|
26749
|
+
const dec2 = num24(m?.replenishmentIncentive);
|
|
26710
26750
|
if (dec2 !== null) return Math.round(dec2 * 1e4);
|
|
26711
26751
|
const meta = Number(market.replenishmentIncentiveBps);
|
|
26712
26752
|
return Number.isFinite(meta) ? meta : null;
|
|
@@ -26715,7 +26755,7 @@ async function fetchInverseMarkets(lender, chainId, multicallRetry = multicallRe
|
|
|
26715
26755
|
escrowYieldApy: (() => {
|
|
26716
26756
|
const escrow = String(m?.escrowImplementation ?? "").toLowerCase();
|
|
26717
26757
|
if (!escrow || escrow === SIMPLE_ESCROW) return null;
|
|
26718
|
-
const apy = (
|
|
26758
|
+
const apy = (num24(m?.supplyApy) ?? 0) + (num24(m?.extraApy) ?? 0);
|
|
26719
26759
|
return apy > 0 ? apy : null;
|
|
26720
26760
|
})()
|
|
26721
26761
|
};
|
|
@@ -30189,7 +30229,9 @@ function convertFlexMarketsToResponse(raw, chainId, prices = {}, additionalYield
|
|
|
30189
30229
|
pressure: lenderLiquidityPressure(
|
|
30190
30230
|
lenderAssets > 0 ? 1 - idle / lenderAssets : null
|
|
30191
30231
|
),
|
|
30192
|
-
upfrontFeePct: (apr) => (avgRate > 0 ? avgRate * 100 : apr) * upfrontYears
|
|
30232
|
+
upfrontFeePct: (apr) => (avgRate > 0 ? avgRate * 100 : apr) * upfrontYears,
|
|
30233
|
+
// a Flex borrow fills from idle, then from troves below its rate
|
|
30234
|
+
idleRaw: m.lenderIdle
|
|
30193
30235
|
}) : void 0;
|
|
30194
30236
|
const recommendedPick = queue?.picks.find((p) => p.id === queue.recommended);
|
|
30195
30237
|
const rateParameter = {
|
|
@@ -33599,12 +33641,18 @@ function organizeUserQueries(queries) {
|
|
|
33599
33641
|
// key discovers every Alchemist on the chain in ONE balanceOf round (and
|
|
33600
33642
|
// one tokenOfOwnerByIndex round), where per-market queries paid both
|
|
33601
33643
|
// rounds once per Alchemist.
|
|
33602
|
-
byFamily(isAlchemix, Lender.ALCHEMIX)
|
|
33644
|
+
byFamily(isAlchemix, Lender.ALCHEMIX),
|
|
33645
|
+
// Fluid: per-vault keys `FLUID_<chainId>_<vaultId>` all build the SAME
|
|
33646
|
+
// `VaultResolver.positionsByUser(account)`, which walks every vault on the
|
|
33647
|
+
// chain — so N vault keys issued N copies of the heaviest call in the
|
|
33648
|
+
// batch (176 extra on Ethereum, 94 on Arbitrum, 2026-11-04). The converter
|
|
33649
|
+
// already reads the whole meta map and emits one entry per vault.
|
|
33650
|
+
byFamily(isFluid, Lender.FLUID)
|
|
33603
33651
|
];
|
|
33604
33652
|
if (morphos.length === 0 && gearbox.length === 0 && midnight.length === 0 && term.length === 0 && exactly.length === 0 && liquity.length === 0 && river.length === 0 && teller.length === 0 && termMax.length === 0 && usdd.length === 0 && sky.length === 0 && frankencoin.length === 0 && llamaLend.length === 0 && siloV2.length === 0 && siloV3.length === 0 && familyGroups.every(([g]) => g.length === 0))
|
|
33605
33653
|
return queries;
|
|
33606
33654
|
const others = queries.filter(
|
|
33607
|
-
(q) => !isMorphoType(q.lender) && !isGearboxV3(q.lender) && !isMidnight(q.lender) && !isTerm(q.lender) && !isExactly(q.lender) && !isLiquityFamily(q.lender) && !isRiver(q.lender) && !isTeller(q.lender) && !isTermMax(q.lender) && !isDssType(q.lender) && !isFrankencoin(q.lender) && !isLlamaLend(q.lender) && !isSiloV2Type(q.lender) && !isSiloV3Type(q.lender) && !isResupply(q.lender) && !isInverse(q.lender) && !isFraxlend(q.lender) && !isCurvance(q.lender) && !isFlex(q.lender) && !isAlchemix(q.lender)
|
|
33655
|
+
(q) => !isMorphoType(q.lender) && !isGearboxV3(q.lender) && !isMidnight(q.lender) && !isTerm(q.lender) && !isExactly(q.lender) && !isLiquityFamily(q.lender) && !isRiver(q.lender) && !isTeller(q.lender) && !isTermMax(q.lender) && !isDssType(q.lender) && !isFrankencoin(q.lender) && !isLlamaLend(q.lender) && !isSiloV2Type(q.lender) && !isSiloV3Type(q.lender) && !isResupply(q.lender) && !isInverse(q.lender) && !isFraxlend(q.lender) && !isCurvance(q.lender) && !isFlex(q.lender) && !isAlchemix(q.lender) && !isFluid(q.lender)
|
|
33608
33656
|
);
|
|
33609
33657
|
const morphoBlue = morphos.filter((q) => q.lender.startsWith("MORPHO_BLUE"));
|
|
33610
33658
|
const moolah = morphos.filter((q) => q.lender.startsWith("LISTA_DAO"));
|
|
@@ -34665,6 +34713,76 @@ var buildEulerUserCall = async (chainId, lender, account, subAccountIndexes) =>
|
|
|
34665
34713
|
params: [evcAddress, getSubAccountAddress(account, i)]
|
|
34666
34714
|
}));
|
|
34667
34715
|
};
|
|
34716
|
+
var AAVE_V4_LENS_WORDS = 4;
|
|
34717
|
+
var AAVE_V4_LENS_CHAINS = /* @__PURE__ */ new Set([
|
|
34718
|
+
Chain.ETHEREUM_MAINNET
|
|
34719
|
+
]);
|
|
34720
|
+
var spokeEntryOf = (chainId, lender) => {
|
|
34721
|
+
const parsed = parseAaveV4SpokeLenderKey(lender);
|
|
34722
|
+
if (!parsed) return void 0;
|
|
34723
|
+
return aaveV4Spokes()?.[chainId]?.[parsed.spokeAddrLower];
|
|
34724
|
+
};
|
|
34725
|
+
var isAddress2 = (a) => typeof a === "string" && /^0x[0-9a-fA-F]{40}$/.test(a);
|
|
34726
|
+
var usesAaveV4Lens = (chainId, lender) => {
|
|
34727
|
+
if (!AAVE_V4_LENS_CHAINS.has(chainId)) return false;
|
|
34728
|
+
if (getPositionLensFor(chainId, LENS_FAMILY.AAVE_V4) === void 0)
|
|
34729
|
+
return false;
|
|
34730
|
+
const entry2 = spokeEntryOf(chainId, lender);
|
|
34731
|
+
if (!entry2 || !isAddress2(entry2.spoke)) return false;
|
|
34732
|
+
const reserves = entry2.reserves ?? [];
|
|
34733
|
+
if (reserves.length === 0) return false;
|
|
34734
|
+
return reserves.every((r) => {
|
|
34735
|
+
try {
|
|
34736
|
+
return BigInt(r.reserveId) >= 0n;
|
|
34737
|
+
} catch {
|
|
34738
|
+
return false;
|
|
34739
|
+
}
|
|
34740
|
+
});
|
|
34741
|
+
};
|
|
34742
|
+
var buildAaveV4LensCall = (chainId, lender, account) => {
|
|
34743
|
+
const lens = getPositionLensFor(chainId, LENS_FAMILY.AAVE_V4);
|
|
34744
|
+
const entry2 = spokeEntryOf(chainId, lender);
|
|
34745
|
+
if (!lens || !entry2 || !isAddress2(entry2.spoke)) return [];
|
|
34746
|
+
const ids = (entry2.reserves ?? []).map((r) => BigInt(r.reserveId));
|
|
34747
|
+
const payload = encodeAbiParameters(
|
|
34748
|
+
parseAbiParameters("address, uint256[]"),
|
|
34749
|
+
[entry2.spoke, ids]
|
|
34750
|
+
);
|
|
34751
|
+
return [
|
|
34752
|
+
{
|
|
34753
|
+
address: lens,
|
|
34754
|
+
name: "getUserData",
|
|
34755
|
+
params: [[{ family: LENS_FAMILY.AAVE_V4, payload }], account],
|
|
34756
|
+
abi: PositionLensAbi
|
|
34757
|
+
}
|
|
34758
|
+
];
|
|
34759
|
+
};
|
|
34760
|
+
var rebuildAaveV4Data = (blobs, reserveCount) => {
|
|
34761
|
+
if (isFailedCall(blobs) || !Array.isArray(blobs) || blobs.length !== 1) {
|
|
34762
|
+
return void 0;
|
|
34763
|
+
}
|
|
34764
|
+
let rows;
|
|
34765
|
+
try {
|
|
34766
|
+
rows = decodeLensRows(blobs[0], AAVE_V4_LENS_WORDS, 0, 1).rows;
|
|
34767
|
+
} catch {
|
|
34768
|
+
return void 0;
|
|
34769
|
+
}
|
|
34770
|
+
const out = [];
|
|
34771
|
+
for (let i = 0; i < reserveCount; i++)
|
|
34772
|
+
out.push(0n, [0n, 0n], [false, false], { dynamicConfigKey: 0 });
|
|
34773
|
+
for (const r of rows) {
|
|
34774
|
+
if (r.index >= reserveCount) return void 0;
|
|
34775
|
+
const [supplied, drawn, premium, configKey] = r.words;
|
|
34776
|
+
const base = r.index * USER_CALLS_PER_RESERVE;
|
|
34777
|
+
out[base] = supplied;
|
|
34778
|
+
out[base + 1] = [drawn, premium];
|
|
34779
|
+
out[base + 2] = [(r.flags & 1) === 1, drawn + premium > 0n];
|
|
34780
|
+
out[base + 3] = { dynamicConfigKey: Number(configKey) };
|
|
34781
|
+
}
|
|
34782
|
+
return out;
|
|
34783
|
+
};
|
|
34784
|
+
|
|
34785
|
+
// src/lending/user-data/aave-v4-type/userCallBuild.ts
|
|
34668
34786
|
var USER_CALLS_PER_RESERVE = 4;
|
|
34669
34787
|
function resolveSpokeEntry2(chainId, lender) {
|
|
34670
34788
|
const parsed = parseAaveV4SpokeLenderKey(lender);
|
|
@@ -34672,6 +34790,8 @@ function resolveSpokeEntry2(chainId, lender) {
|
|
|
34672
34790
|
return aaveV4Spokes()?.[chainId]?.[parsed.spokeAddrLower];
|
|
34673
34791
|
}
|
|
34674
34792
|
var buildAaveV4UserCall = (chainId, lender, account) => {
|
|
34793
|
+
if (usesAaveV4Lens(chainId, lender))
|
|
34794
|
+
return buildAaveV4LensCall(chainId, lender, account);
|
|
34675
34795
|
const spokeEntry = resolveSpokeEntry2(chainId, lender);
|
|
34676
34796
|
if (!spokeEntry) return [];
|
|
34677
34797
|
const spokeAddr = spokeEntry.spoke;
|
|
@@ -35473,11 +35593,11 @@ function buildDataPhaseCalls(branches, perBranch, account) {
|
|
|
35473
35593
|
|
|
35474
35594
|
// src/lending/user-data/river/lens.ts
|
|
35475
35595
|
var usesRiverLens = (chainId) => getPositionLensFor(chainId, LENS_FAMILY.RIVER) !== void 0;
|
|
35476
|
-
var
|
|
35596
|
+
var isAddress3 = (v) => typeof v === "string" && /^0x[0-9a-fA-F]{40}$/.test(v);
|
|
35477
35597
|
var buildRiverLensCall = (chainId, cfg, markets, account) => {
|
|
35478
35598
|
const lens = getPositionLensFor(chainId, LENS_FAMILY.RIVER);
|
|
35479
35599
|
if (!lens) return [];
|
|
35480
|
-
if (!
|
|
35600
|
+
if (!isAddress3(cfg.xapp) || markets.some((m) => !isAddress3(m.troveManager))) {
|
|
35481
35601
|
return [];
|
|
35482
35602
|
}
|
|
35483
35603
|
const payload = encodeAbiParameters(
|
|
@@ -36351,11 +36471,11 @@ function __resetResupplyUserCaches() {
|
|
|
36351
36471
|
|
|
36352
36472
|
// src/lending/user-data/fraxlend/lens.ts
|
|
36353
36473
|
var usesFraxlendLens = (chainId) => getPositionLensFor(chainId, LENS_FAMILY.FRAXLEND) !== void 0;
|
|
36354
|
-
var
|
|
36474
|
+
var isAddress4 = (v) => typeof v === "string" && /^0x[0-9a-fA-F]{40}$/.test(v);
|
|
36355
36475
|
var buildFraxlendLensCall = (chainId, pairs, account) => {
|
|
36356
36476
|
const lens = getPositionLensFor(chainId, LENS_FAMILY.FRAXLEND);
|
|
36357
36477
|
if (!lens) return [];
|
|
36358
|
-
if (pairs.some((p) => !
|
|
36478
|
+
if (pairs.some((p) => !isAddress4(p.address))) return [];
|
|
36359
36479
|
const payload = encodeAbiParameters(parseAbiParameters("address[]"), [
|
|
36360
36480
|
pairs.map((p) => p.address)
|
|
36361
36481
|
]);
|
|
@@ -36606,7 +36726,7 @@ function getCachedTwyneDiscovery(chainId, lender, account, opts) {
|
|
|
36606
36726
|
);
|
|
36607
36727
|
}
|
|
36608
36728
|
var lower2 = (a) => String(a).toLowerCase();
|
|
36609
|
-
var
|
|
36729
|
+
var isAddress5 = (v) => typeof v === "string" && /^0x[0-9a-fA-F]{40}$/.test(v);
|
|
36610
36730
|
async function discover3(chainId, lender, account, opts) {
|
|
36611
36731
|
const key5 = discoveryKey4(chainId, lender, account, blockKey(opts));
|
|
36612
36732
|
const cached2 = discoveryCache6.get(key5);
|
|
@@ -36629,7 +36749,7 @@ async function discover3(chainId, lender, account, opts) {
|
|
|
36629
36749
|
},
|
|
36630
36750
|
opts
|
|
36631
36751
|
);
|
|
36632
|
-
const created = Array.isArray(listRaw) ? listRaw.filter(
|
|
36752
|
+
const created = Array.isArray(listRaw) ? listRaw.filter(isAddress5).map(lower2) : [];
|
|
36633
36753
|
if (created.length === 0) {
|
|
36634
36754
|
discoveryCache6.set(key5, empty2);
|
|
36635
36755
|
return empty2;
|
|
@@ -36663,8 +36783,8 @@ async function discover3(chainId, lender, account, opts) {
|
|
|
36663
36783
|
const iv = refs[i * 3];
|
|
36664
36784
|
const target = refs[i * 3 + 1];
|
|
36665
36785
|
const owner = refs[i * 3 + 2];
|
|
36666
|
-
if (!
|
|
36667
|
-
if (
|
|
36786
|
+
if (!isAddress5(iv) || !isAddress5(target)) return;
|
|
36787
|
+
if (isAddress5(owner) && lower2(owner) !== lower2(account)) return;
|
|
36668
36788
|
const marketKey2 = `${lower2(iv)}|${lower2(target)}`;
|
|
36669
36789
|
if (!known.has(marketKey2)) return;
|
|
36670
36790
|
vaults.push({
|
|
@@ -38775,12 +38895,15 @@ var getAaveV4UserDataConverter = (lender, chainId, account, meta) => {
|
|
|
38775
38895
|
const spokeAddrLc = spokeAddr.toLowerCase();
|
|
38776
38896
|
const reserves = spokeEntry.reserves ?? [];
|
|
38777
38897
|
const flatMeta = meta ?? {};
|
|
38778
|
-
const
|
|
38898
|
+
const viaLens = usesAaveV4Lens(chainId, lender);
|
|
38899
|
+
const expectedNumberOfCalls = viaLens ? 1 : reserves.length * USER_CALLS_PER_RESERVE;
|
|
38779
38900
|
return [
|
|
38780
|
-
(
|
|
38781
|
-
if (
|
|
38901
|
+
(raw) => {
|
|
38902
|
+
if (raw.length !== expectedNumberOfCalls) {
|
|
38782
38903
|
return void 0;
|
|
38783
38904
|
}
|
|
38905
|
+
const data = viaLens ? rebuildAaveV4Data(raw[0], reserves.length) : raw;
|
|
38906
|
+
if (!data) throw new Error(`${lender}: PositionLens blob unusable`);
|
|
38784
38907
|
const lendingPositions = {};
|
|
38785
38908
|
let totalDeposits24h = 0;
|
|
38786
38909
|
let totalDebt24h = 0;
|
|
@@ -57537,6 +57660,46 @@ var IPOR_FUSION_ENTRIES = (() => {
|
|
|
57537
57660
|
}
|
|
57538
57661
|
return out;
|
|
57539
57662
|
})();
|
|
57663
|
+
var COMMON = "Mezzanine's Hastra Optimizer, which loops Hastra PRIME and AUTO through Morpho and Kamino. The curator reports its NAV through RedStone each weekly epoch, so the rate is one epoch's result and can swing, or turn negative, from week to week. MZUSD not staked in a tranche earns nothing and its yield goes to the tranches: about half of all MZUSD sat unstaked in one Safe at listing, roughly doubling both rates, which fall if it is staked or redeemed.";
|
|
57664
|
+
var MEZZANINE_PROSE = {
|
|
57665
|
+
senior: `The SENIOR tranche of ${COMMON} It takes losses only after the junior tranche is gone.`,
|
|
57666
|
+
junior: `The JUNIOR, FIRST-LOSS tranche of ${COMMON} It takes every loss first, for a yield premium that grows as this tranche shrinks against the senior.`
|
|
57667
|
+
};
|
|
57668
|
+
var toEntry3 = (t) => ({
|
|
57669
|
+
reader: "mezzanine-tranche",
|
|
57670
|
+
address: t.address,
|
|
57671
|
+
// The deposit asset, not `asset()`: see the reader.
|
|
57672
|
+
underlying: t.depositAsset,
|
|
57673
|
+
symbol: t.symbol,
|
|
57674
|
+
brand: "Mezzanine",
|
|
57675
|
+
description: MEZZANINE_PROSE[t.tranche],
|
|
57676
|
+
decimals: 21,
|
|
57677
|
+
underlyingDecimals: 6,
|
|
57678
|
+
isRebasing: false,
|
|
57679
|
+
isMintable: true,
|
|
57680
|
+
withdrawalMode: "request-based",
|
|
57681
|
+
withdrawQueue: t.address,
|
|
57682
|
+
solvency: t.tranche === "senior" ? "tranched-senior" : "tranched-junior",
|
|
57683
|
+
// Not read by the reader: it publishes the row's NAV attestation, so the
|
|
57684
|
+
// sheet says the price is reported and the senior's principal is not safe.
|
|
57685
|
+
priceOracle: t.navOracle,
|
|
57686
|
+
feeScheduleCheckedAt: "2026-11-05",
|
|
57687
|
+
mezzanine: {
|
|
57688
|
+
issuanceVault: t.issuanceVault,
|
|
57689
|
+
mzusd: t.mzusd,
|
|
57690
|
+
reservoir: t.reservoir,
|
|
57691
|
+
allowlist: t.allowlist,
|
|
57692
|
+
pauseManager: t.pauseManager
|
|
57693
|
+
}
|
|
57694
|
+
});
|
|
57695
|
+
var MEZZANINE_ENTRIES = (() => {
|
|
57696
|
+
const out = {};
|
|
57697
|
+
for (const t of MEZZANINE_TRANCHES) {
|
|
57698
|
+
if (!out[t.chainId]) out[t.chainId] = [];
|
|
57699
|
+
out[t.chainId].push(toEntry3(t));
|
|
57700
|
+
}
|
|
57701
|
+
return out;
|
|
57702
|
+
})();
|
|
57540
57703
|
var L2SD_YIELD_KEYS = {
|
|
57541
57704
|
limUSD: "limUSD::LIMUSD",
|
|
57542
57705
|
haHYPE: "haHYPE::haHYPE",
|
|
@@ -59534,7 +59697,7 @@ var ROWS = [
|
|
|
59534
59697
|
)
|
|
59535
59698
|
}
|
|
59536
59699
|
];
|
|
59537
|
-
var
|
|
59700
|
+
var toEntry4 = (r) => ({
|
|
59538
59701
|
reader: "alchemix-transmuter",
|
|
59539
59702
|
address: r.transmuter,
|
|
59540
59703
|
underlying: r.alAsset,
|
|
@@ -59564,7 +59727,7 @@ var toEntry3 = (r) => ({
|
|
|
59564
59727
|
alchemixTransmuter: r.cfg
|
|
59565
59728
|
});
|
|
59566
59729
|
var ALCHEMIX_TRANSMUTER_ENTRIES = ROWS.reduce((out, r) => {
|
|
59567
|
-
(out[r.chainId] ??= []).push(
|
|
59730
|
+
(out[r.chainId] ??= []).push(toEntry4(r));
|
|
59568
59731
|
return out;
|
|
59569
59732
|
}, {});
|
|
59570
59733
|
var CHAIN_ID19 = "1";
|
|
@@ -63697,6 +63860,10 @@ var SAVINGS_REGISTRY = (() => {
|
|
|
63697
63860
|
if (!out[chainId]) out[chainId] = [];
|
|
63698
63861
|
out[chainId].push(...entries);
|
|
63699
63862
|
}
|
|
63863
|
+
for (const [chainId, entries] of Object.entries(MEZZANINE_ENTRIES)) {
|
|
63864
|
+
if (!out[chainId]) out[chainId] = [];
|
|
63865
|
+
out[chainId].push(...entries);
|
|
63866
|
+
}
|
|
63700
63867
|
for (const [chainId, entries] of Object.entries(LLAMA_GAP_ENTRIES)) {
|
|
63701
63868
|
if (!out[chainId]) out[chainId] = [];
|
|
63702
63869
|
out[chainId].push(...entries);
|
|
@@ -67579,6 +67746,7 @@ async function fetchIntrinsicYields() {
|
|
|
67579
67746
|
return intrinsicYields;
|
|
67580
67747
|
}
|
|
67581
67748
|
var MERKL_API_BASE = "https://api.merkl.xyz/v4";
|
|
67749
|
+
var MERKL_PAGE_TIMEOUT_MS = 15e3;
|
|
67582
67750
|
async function fetchMerklOpportunities(protocolId, chainId) {
|
|
67583
67751
|
const all = [];
|
|
67584
67752
|
let page = 0;
|
|
@@ -67590,7 +67758,10 @@ async function fetchMerklOpportunities(protocolId, chainId) {
|
|
|
67590
67758
|
page: String(page)
|
|
67591
67759
|
});
|
|
67592
67760
|
if (chainId) params.set("chainId", chainId);
|
|
67593
|
-
const res = await fetch(`${MERKL_API_BASE}/opportunities?${params}
|
|
67761
|
+
const res = await fetch(`${MERKL_API_BASE}/opportunities?${params}`, {
|
|
67762
|
+
// Per page: an unanswered page is a failed sweep, never a wait.
|
|
67763
|
+
signal: AbortSignal.timeout(MERKL_PAGE_TIMEOUT_MS)
|
|
67764
|
+
});
|
|
67594
67765
|
if (!res.ok)
|
|
67595
67766
|
throw new Error(`Merkl API ${res.status} for chain ${chainId ?? "all"}`);
|
|
67596
67767
|
const batch = await res.json();
|
|
@@ -67600,6 +67771,7 @@ async function fetchMerklOpportunities(protocolId, chainId) {
|
|
|
67600
67771
|
}
|
|
67601
67772
|
return all;
|
|
67602
67773
|
}
|
|
67774
|
+
var isGatedMerklCampaign = (opp) => (opp.identifier ?? "").length > 42 || /\busers only\b/i.test(opp.name ?? "");
|
|
67603
67775
|
function emptyReward() {
|
|
67604
67776
|
return {
|
|
67605
67777
|
distribution: "merkle",
|
|
@@ -67883,6 +68055,22 @@ var morphoCollateralMerklRewardFetcher = createMerklRewardFetcher({
|
|
|
67883
68055
|
};
|
|
67884
68056
|
}
|
|
67885
68057
|
});
|
|
68058
|
+
function resolveAlchemixDebt(opp) {
|
|
68059
|
+
if (opp.type !== "ALCHEMIX_V3_DEBT") return void 0;
|
|
68060
|
+
const alchemist = (opp.explorerAddress ?? opp.identifier)?.toLowerCase();
|
|
68061
|
+
const debt = opp.tokens?.length === 1 ? opp.tokens[0].address : void 0;
|
|
68062
|
+
if (!alchemist || !/^0x[0-9a-f]{40}$/.test(alchemist) || !debt) return void 0;
|
|
68063
|
+
return {
|
|
68064
|
+
asset: debt.toLowerCase(),
|
|
68065
|
+
lender: alchemixMarketKey(opp.chainId, alchemist),
|
|
68066
|
+
bucket: "borrow"
|
|
68067
|
+
};
|
|
68068
|
+
}
|
|
68069
|
+
var alchemixMerklRewardFetcher = createMerklRewardFetcher({
|
|
68070
|
+
merklProtocolId: "alchemix",
|
|
68071
|
+
lenderKey: "ALCHEMIX",
|
|
68072
|
+
resolveAsset: resolveAlchemixDebt
|
|
68073
|
+
});
|
|
67886
68074
|
var RATE_CONFIGS = {
|
|
67887
68075
|
aave: {
|
|
67888
68076
|
merklProtocolId: "aave",
|
|
@@ -67900,14 +68088,16 @@ var RATE_CONFIGS = {
|
|
|
67900
68088
|
keyByReserveToken: true
|
|
67901
68089
|
},
|
|
67902
68090
|
dolomite: { merklProtocolId: "dolomite", lenderKey: "DOLOMITE" },
|
|
67903
|
-
euler: { merklProtocolId: "euler", lenderKey: "EULER_V2" }
|
|
68091
|
+
euler: { merklProtocolId: "euler", lenderKey: "EULER_V2" },
|
|
68092
|
+
alchemix: { merklProtocolId: "alchemix", lenderKey: "ALCHEMIX" }
|
|
67904
68093
|
};
|
|
67905
68094
|
var RATE_RESOLVERS = {
|
|
67906
68095
|
aave: resolveAaveOpp,
|
|
67907
68096
|
neverland: resolveAaveV3ReserveToken,
|
|
67908
68097
|
layerbank: resolveAaveV3ReserveToken,
|
|
67909
68098
|
dolomite: resolveDolomiteAsset,
|
|
67910
|
-
euler: resolveEulerOpp
|
|
68099
|
+
euler: resolveEulerOpp,
|
|
68100
|
+
alchemix: resolveAlchemixDebt
|
|
67911
68101
|
};
|
|
67912
68102
|
function resolveAaveOpp(opp) {
|
|
67913
68103
|
const explorer = opp.explorerAddress?.toLowerCase();
|
|
@@ -68104,6 +68294,159 @@ function fTokenStreamsFromOpportunities(opps, chainId) {
|
|
|
68104
68294
|
}
|
|
68105
68295
|
return out;
|
|
68106
68296
|
}
|
|
68297
|
+
var CAMPAIGN_TIMEOUT_MS = 1e4;
|
|
68298
|
+
var isConditional = (opp) => isGatedMerklCampaign(opp) || /\brequired\b/i.test(opp.name ?? "");
|
|
68299
|
+
function rewardedHubAssets(opp, campaigns, nowSec9 = Math.floor(Date.now() / 1e3)) {
|
|
68300
|
+
const borrowing = opp.type === "AAVE_V4_HUB_NET_BORROWING";
|
|
68301
|
+
const out = /* @__PURE__ */ new Map();
|
|
68302
|
+
for (const c of campaigns) {
|
|
68303
|
+
const start = Number(c.startTimestamp ?? 0);
|
|
68304
|
+
const end = Number(c.endTimestamp ?? Infinity);
|
|
68305
|
+
if (!(start <= nowSec9 && nowSec9 < end)) continue;
|
|
68306
|
+
for (const h of c.params?.hubs ?? []) {
|
|
68307
|
+
const hub = h.hubAddress?.toLowerCase();
|
|
68308
|
+
if (!hub) continue;
|
|
68309
|
+
const ids = borrowing ? h.borrowAssetIds : h.lendingAssetIds ?? h.supplyAssetIds;
|
|
68310
|
+
const set = out.get(hub) ?? /* @__PURE__ */ new Set();
|
|
68311
|
+
for (const id of ids ?? []) if (Number.isFinite(Number(id))) set.add(Number(id));
|
|
68312
|
+
out.set(hub, set);
|
|
68313
|
+
}
|
|
68314
|
+
}
|
|
68315
|
+
return out;
|
|
68316
|
+
}
|
|
68317
|
+
function hubResolutions(opp, hubs) {
|
|
68318
|
+
const spokes = aaveV4Spokes()?.[String(opp.chainId)] ?? {};
|
|
68319
|
+
const bucket = opp.type === "AAVE_V4_HUB_NET_BORROWING" ? "borrow" : "deposit";
|
|
68320
|
+
const out = [];
|
|
68321
|
+
for (const entry2 of Object.values(spokes)) {
|
|
68322
|
+
for (const r of entry2.reserves ?? []) {
|
|
68323
|
+
const ids = hubs.get(r.hub?.toLowerCase());
|
|
68324
|
+
if (!ids?.has(Number(r.assetId))) continue;
|
|
68325
|
+
out.push({
|
|
68326
|
+
// The RESERVE ID, not the underlying: a spoke can list one asset twice
|
|
68327
|
+
// through two hubs (USDG Pendle / Maple SyrupUSDG hold USDG on hubs
|
|
68328
|
+
// 0xCca852Bc AND 0x62d63197), and keyed by underlying both campaigns
|
|
68329
|
+
// land on both reserves (10.5 % instead of 5.5 % and 5.0 %). V4 market
|
|
68330
|
+
// uids end in the reserve id, so `flattenLenderRewards` turns this into
|
|
68331
|
+
// the reserve's own uid and the consumer's by-marketUid join hits it.
|
|
68332
|
+
asset: String(r.reserveId),
|
|
68333
|
+
lender: aaveV4SpokeLenderKey(entry2.spoke),
|
|
68334
|
+
bucket,
|
|
68335
|
+
keyBy: "lender"
|
|
68336
|
+
});
|
|
68337
|
+
}
|
|
68338
|
+
}
|
|
68339
|
+
return out;
|
|
68340
|
+
}
|
|
68341
|
+
async function fetchCampaigns(oppId) {
|
|
68342
|
+
const res = await fetch(`${MERKL_API_BASE}/opportunities/${oppId}/campaigns`, {
|
|
68343
|
+
signal: AbortSignal.timeout(CAMPAIGN_TIMEOUT_MS)
|
|
68344
|
+
});
|
|
68345
|
+
if (!res.ok) throw new Error(`Merkl campaigns ${res.status} for ${oppId}`);
|
|
68346
|
+
const body = await res.json();
|
|
68347
|
+
return (Array.isArray(body) ? body : body?.campaigns) ?? [];
|
|
68348
|
+
}
|
|
68349
|
+
var aaveV4HubMerklRewardFetcher = {
|
|
68350
|
+
label: "MERKL_AAVE_V4_HUB",
|
|
68351
|
+
fetch: async () => {
|
|
68352
|
+
const opps = (await fetchMerklOpportunities("aave")).filter(
|
|
68353
|
+
(o) => o.type?.startsWith("AAVE_V4_HUB_") && o.apr > 0 && !isConditional(o)
|
|
68354
|
+
);
|
|
68355
|
+
const resolved2 = /* @__PURE__ */ new Map();
|
|
68356
|
+
await Promise.all(
|
|
68357
|
+
opps.map(async (opp) => {
|
|
68358
|
+
try {
|
|
68359
|
+
const hubs = rewardedHubAssets(opp, await fetchCampaigns(String(opp.id)));
|
|
68360
|
+
resolved2.set(opp, hubResolutions(opp, hubs));
|
|
68361
|
+
} catch (e) {
|
|
68362
|
+
console.warn(`Merkl: Aave V4 hub campaign ${opp.id} skipped:`, e);
|
|
68363
|
+
}
|
|
68364
|
+
})
|
|
68365
|
+
);
|
|
68366
|
+
return collectMerklRewards([[...resolved2.keys()]], {
|
|
68367
|
+
merklProtocolId: "aave",
|
|
68368
|
+
lenderKey: "AAVE_V4",
|
|
68369
|
+
resolveAsset: (opp) => resolved2.get(opp) ?? []
|
|
68370
|
+
});
|
|
68371
|
+
}
|
|
68372
|
+
};
|
|
68373
|
+
var MARKET_MANAGER_ABI = [
|
|
68374
|
+
{
|
|
68375
|
+
name: "marketManager",
|
|
68376
|
+
type: "function",
|
|
68377
|
+
stateMutability: "view",
|
|
68378
|
+
inputs: [],
|
|
68379
|
+
outputs: [{ type: "address" }]
|
|
68380
|
+
}
|
|
68381
|
+
];
|
|
68382
|
+
var ADDRESS = /^0x[0-9a-fA-F]{40}$/;
|
|
68383
|
+
function curvanceCampaignTokens(opp) {
|
|
68384
|
+
const cToken = opp.explorerAddress?.toLowerCase();
|
|
68385
|
+
if (!cToken || !ADDRESS.test(cToken)) return void 0;
|
|
68386
|
+
const underlying = opp.tokens?.find(
|
|
68387
|
+
(t) => t.address?.toLowerCase() !== cToken
|
|
68388
|
+
)?.address;
|
|
68389
|
+
if (!underlying) return void 0;
|
|
68390
|
+
return { cToken, underlying: underlying.toLowerCase() };
|
|
68391
|
+
}
|
|
68392
|
+
function collectCurvanceRewards(opps, managerOf) {
|
|
68393
|
+
return collectMerklRewards([opps], {
|
|
68394
|
+
merklProtocolId: "curvance",
|
|
68395
|
+
lenderKey: "CURVANCE",
|
|
68396
|
+
resolveAsset: (opp) => {
|
|
68397
|
+
if (opp.action !== "LEND" || isGatedMerklCampaign(opp)) return void 0;
|
|
68398
|
+
const t = curvanceCampaignTokens(opp);
|
|
68399
|
+
if (!t) return void 0;
|
|
68400
|
+
const manager = managerOf(String(opp.chainId), t.cToken);
|
|
68401
|
+
if (!manager) return void 0;
|
|
68402
|
+
return {
|
|
68403
|
+
asset: t.underlying,
|
|
68404
|
+
lender: curvanceLenderKey("CURVANCE", opp.chainId, manager),
|
|
68405
|
+
bucket: "deposit"
|
|
68406
|
+
};
|
|
68407
|
+
}
|
|
68408
|
+
});
|
|
68409
|
+
}
|
|
68410
|
+
var curvanceMerklRewardFetcher = {
|
|
68411
|
+
label: "MERKL_CURVANCE",
|
|
68412
|
+
fetch: async () => {
|
|
68413
|
+
const opps = (await fetchMerklOpportunities("curvance")).filter(
|
|
68414
|
+
(o) => o.apr > 0
|
|
68415
|
+
);
|
|
68416
|
+
const byChain = /* @__PURE__ */ new Map();
|
|
68417
|
+
for (const o of opps) {
|
|
68418
|
+
const t = curvanceCampaignTokens(o);
|
|
68419
|
+
if (!t) continue;
|
|
68420
|
+
const list = byChain.get(String(o.chainId)) ?? [];
|
|
68421
|
+
if (!list.includes(t.cToken)) list.push(t.cToken);
|
|
68422
|
+
byChain.set(String(o.chainId), list);
|
|
68423
|
+
}
|
|
68424
|
+
const managers = /* @__PURE__ */ new Map();
|
|
68425
|
+
await Promise.all(
|
|
68426
|
+
[...byChain].map(async ([chainId, cTokens]) => {
|
|
68427
|
+
const res = await multicallRetryUniversal({
|
|
68428
|
+
chain: chainId,
|
|
68429
|
+
calls: cTokens.map((address) => ({
|
|
68430
|
+
address,
|
|
68431
|
+
name: "marketManager",
|
|
68432
|
+
params: []
|
|
68433
|
+
})),
|
|
68434
|
+
abi: MARKET_MANAGER_ABI,
|
|
68435
|
+
allowFailure: true
|
|
68436
|
+
});
|
|
68437
|
+
cTokens.forEach((cToken, i) => {
|
|
68438
|
+
const m = res?.[i];
|
|
68439
|
+
if (typeof m === "string" && ADDRESS.test(m))
|
|
68440
|
+
managers.set(`${chainId}:${cToken}`, m.toLowerCase());
|
|
68441
|
+
});
|
|
68442
|
+
})
|
|
68443
|
+
);
|
|
68444
|
+
return collectCurvanceRewards(
|
|
68445
|
+
opps,
|
|
68446
|
+
(chainId, cToken) => managers.get(`${chainId}:${cToken}`)
|
|
68447
|
+
);
|
|
68448
|
+
}
|
|
68449
|
+
};
|
|
68107
68450
|
var DLEND_POOLS = [
|
|
68108
68451
|
{
|
|
68109
68452
|
chainId: Chain.ETHEREUM_MAINNET,
|
|
@@ -69422,7 +69765,10 @@ var rewardFetchers = [
|
|
|
69422
69765
|
dtrinityRebateRewardFetcher,
|
|
69423
69766
|
llamaLendGaugeRewardFetcher,
|
|
69424
69767
|
flyingTulipFtRewardFetcher,
|
|
69425
|
-
listaEmissionRewardFetcher
|
|
69768
|
+
listaEmissionRewardFetcher,
|
|
69769
|
+
alchemixMerklRewardFetcher,
|
|
69770
|
+
curvanceMerklRewardFetcher,
|
|
69771
|
+
aaveV4HubMerklRewardFetcher
|
|
69426
69772
|
];
|
|
69427
69773
|
function mergeReserveTokenRewards(target, source) {
|
|
69428
69774
|
for (const [chainId, byToken] of Object.entries(source)) {
|
|
@@ -72275,38 +72621,84 @@ function getCompoundV2Calls(chainId) {
|
|
|
72275
72621
|
function parseCompoundV2Results(data, meta, context) {
|
|
72276
72622
|
const { chainId, tokenList, usdPrices } = context;
|
|
72277
72623
|
const entries = [];
|
|
72278
|
-
|
|
72624
|
+
const usdOf = (asset) => {
|
|
72625
|
+
const lc2 = asset.toLowerCase();
|
|
72626
|
+
const key5 = tokenList?.[lc2]?.assetGroup ?? `${chainId}-${lc2}`;
|
|
72627
|
+
return usdPrices[key5] ?? usdPrices[lc2];
|
|
72628
|
+
};
|
|
72629
|
+
const decimalsOf2 = (asset) => tokenList?.[asset.toLowerCase()]?.decimals ?? 18;
|
|
72630
|
+
const raw = data.map((r, i) => {
|
|
72631
|
+
const q = meta[i];
|
|
72632
|
+
if (!q || r === void 0 || r === null || r === "0x") return void 0;
|
|
72633
|
+
try {
|
|
72634
|
+
return BigInt(r.toString());
|
|
72635
|
+
} catch {
|
|
72636
|
+
return void 0;
|
|
72637
|
+
}
|
|
72638
|
+
});
|
|
72639
|
+
const scalingOverride = meta[0]?.scalingDecimalsOverride ?? detectFixedScaling(meta, raw, tokenList);
|
|
72640
|
+
const baseOverride = meta[0]?.baseAssetOverride ?? detectNativeBase(chainId, meta, raw, scalingOverride, decimalsOf2, usdOf);
|
|
72641
|
+
raw.forEach((rawResult, index) => {
|
|
72279
72642
|
const queryMeta = meta[index];
|
|
72280
|
-
if (!queryMeta || rawResult === void 0
|
|
72643
|
+
if (!queryMeta || rawResult === void 0) return;
|
|
72281
72644
|
try {
|
|
72282
72645
|
const underlyingLc = queryMeta.underlying.toLowerCase();
|
|
72283
|
-
const
|
|
72284
|
-
const
|
|
72285
|
-
const rawPriceNum = Number(
|
|
72286
|
-
formatUnits(BigInt(rawResult.toString()), scalingDecimals)
|
|
72287
|
-
);
|
|
72646
|
+
const scalingDecimals = scalingOverride ?? 36 - decimalsOf2(underlyingLc);
|
|
72647
|
+
const rawPriceNum = Number(formatUnits(rawResult, scalingDecimals));
|
|
72288
72648
|
if (isNaN(rawPriceNum) || rawPriceNum === 0) return;
|
|
72289
72649
|
let baseAssetUSD = 1;
|
|
72290
|
-
if (
|
|
72291
|
-
const
|
|
72292
|
-
|
|
72293
|
-
baseAssetUSD =
|
|
72650
|
+
if (baseOverride) {
|
|
72651
|
+
const b = usdOf(baseOverride);
|
|
72652
|
+
if (!(b > 0)) return;
|
|
72653
|
+
baseAssetUSD = b;
|
|
72294
72654
|
}
|
|
72295
72655
|
const priceUSD = rawPriceNum * baseAssetUSD;
|
|
72296
|
-
const isBaseAsset =
|
|
72656
|
+
const isBaseAsset = baseOverride && underlyingLc === baseOverride.toLowerCase();
|
|
72297
72657
|
entries.push({
|
|
72298
72658
|
asset: underlyingLc,
|
|
72299
72659
|
price: rawPriceNum,
|
|
72300
72660
|
priceUSD,
|
|
72301
72661
|
marketUid: createMarketUid(chainId, queryMeta.lender, queryMeta.cToken),
|
|
72302
72662
|
staticBase: isBaseAsset || void 0,
|
|
72303
|
-
baseAsset:
|
|
72663
|
+
baseAsset: baseOverride
|
|
72304
72664
|
});
|
|
72305
72665
|
} catch {
|
|
72306
72666
|
}
|
|
72307
72667
|
});
|
|
72308
72668
|
return entries;
|
|
72309
72669
|
}
|
|
72670
|
+
var isUsdStable = (t) => t?.props?.stablecoin?.base === "USD" || ["USDC", "USDT", "USDC.E", "USDT0", "DAI"].includes(
|
|
72671
|
+
String(t?.symbol ?? "").toUpperCase()
|
|
72672
|
+
);
|
|
72673
|
+
function detectFixedScaling(meta, raw, tokenList) {
|
|
72674
|
+
let votes = 0;
|
|
72675
|
+
for (let i = 0; i < meta.length; i++) {
|
|
72676
|
+
const r = raw[i];
|
|
72677
|
+
const t = tokenList?.[meta[i].underlying.toLowerCase()];
|
|
72678
|
+
if (r === void 0 || !isUsdStable(t) || !(t.decimals < 18)) continue;
|
|
72679
|
+
const standard = Number(formatUnits(r, 36 - t.decimals));
|
|
72680
|
+
const at18 = Number(formatUnits(r, 18));
|
|
72681
|
+
if (standard < 1e-6 && at18 > 0.5 && at18 < 2) votes++;
|
|
72682
|
+
else return void 0;
|
|
72683
|
+
}
|
|
72684
|
+
return votes > 0 ? 18 : void 0;
|
|
72685
|
+
}
|
|
72686
|
+
function detectNativeBase(chainId, meta, raw, scaling, decimalsOf2, usdOf) {
|
|
72687
|
+
const NATIVE = "0x0000000000000000000000000000000000000000";
|
|
72688
|
+
const wrapped = WRAPPED_NATIVE_INFO[chainId]?.address?.toLowerCase();
|
|
72689
|
+
for (let i = 0; i < meta.length; i++) {
|
|
72690
|
+
const u = meta[i].underlying.toLowerCase();
|
|
72691
|
+
if (u !== NATIVE && u !== wrapped) continue;
|
|
72692
|
+
const r = raw[i];
|
|
72693
|
+
if (r === void 0) continue;
|
|
72694
|
+
const price2 = Number(formatUnits(r, scaling ?? 36 - decimalsOf2(u)));
|
|
72695
|
+
const nativeUSD = usdOf(u) ?? usdOf(NATIVE) ?? (wrapped ? usdOf(wrapped) : void 0);
|
|
72696
|
+
if (!(nativeUSD > 0)) continue;
|
|
72697
|
+
if (price2 > 0.95 && price2 < 1.05 && (nativeUSD > 3 || nativeUSD < 0.33))
|
|
72698
|
+
return u;
|
|
72699
|
+
}
|
|
72700
|
+
return void 0;
|
|
72701
|
+
}
|
|
72310
72702
|
function getCompoundV2Abi() {
|
|
72311
72703
|
return CompoundV2OracleAbi;
|
|
72312
72704
|
}
|
|
@@ -72644,15 +73036,44 @@ var priceLensAbi = [
|
|
|
72644
73036
|
var MAX_VIRTUAL_ADDRESS = 65535;
|
|
72645
73037
|
var MAX_SANE_PRICE_USD = 1e7;
|
|
72646
73038
|
var MIN_SANE_PRICE_USD = 1e-9;
|
|
73039
|
+
var MAX_SANE_STABLE_USD = 10;
|
|
72647
73040
|
var EULER_EXCLUDED_VAULT_ORACLES = /* @__PURE__ */ new Set([
|
|
72648
73041
|
// Sonic msUSD — FixedRateOracle 0x3E35E10E…: rate 1e6 (1e-12 USD)
|
|
72649
73042
|
"146:0x657cdc99dc15448e680ee39a4bd76bb0d5fcdc6d",
|
|
72650
73043
|
// Sonic msUSD — FixedRateOracle 0x6Bfd6ABb…: rate 1 (1e-18 USD)
|
|
72651
73044
|
"146:0xfc4f0376c364aafd178e16dace3a4441b90a65fa"
|
|
72652
73045
|
]);
|
|
72653
|
-
|
|
73046
|
+
var USD_UNIT_OF_ACCOUNT = 840;
|
|
73047
|
+
function unitOfAccountKind(addr6) {
|
|
72654
73048
|
const numeric = parseInt(addr6, 16);
|
|
72655
|
-
|
|
73049
|
+
if (numeric === USD_UNIT_OF_ACCOUNT) return "usd";
|
|
73050
|
+
if (numeric <= MAX_VIRTUAL_ADDRESS) return void 0;
|
|
73051
|
+
return "token";
|
|
73052
|
+
}
|
|
73053
|
+
var VAULT_DISAGREEMENT_FACTOR = 10;
|
|
73054
|
+
var MIN_AGREEING_VAULTS = 3;
|
|
73055
|
+
function dropDisagreeingVaults(entries) {
|
|
73056
|
+
const byAsset = /* @__PURE__ */ new Map();
|
|
73057
|
+
for (const e of entries) {
|
|
73058
|
+
const list = byAsset.get(e.asset);
|
|
73059
|
+
if (list) list.push(e.priceUSD);
|
|
73060
|
+
else byAsset.set(e.asset, [e.priceUSD]);
|
|
73061
|
+
}
|
|
73062
|
+
const ref = /* @__PURE__ */ new Map();
|
|
73063
|
+
for (const [asset, prices] of byAsset) {
|
|
73064
|
+
if (prices.length < MIN_AGREEING_VAULTS) continue;
|
|
73065
|
+
const sorted = [...prices].sort((a, b) => a - b);
|
|
73066
|
+
const mid = sorted[Math.floor(sorted.length / 2)];
|
|
73067
|
+
const agreeing = prices.filter(
|
|
73068
|
+
(p) => p <= mid * 1.05 && p >= mid / 1.05
|
|
73069
|
+
).length;
|
|
73070
|
+
if (agreeing >= MIN_AGREEING_VAULTS) ref.set(asset, mid);
|
|
73071
|
+
}
|
|
73072
|
+
return entries.filter((e) => {
|
|
73073
|
+
const r = ref.get(e.asset);
|
|
73074
|
+
if (r === void 0) return true;
|
|
73075
|
+
return e.priceUSD <= r * VAULT_DISAGREEMENT_FACTOR && e.priceUSD >= r / VAULT_DISAGREEMENT_FACTOR;
|
|
73076
|
+
});
|
|
72656
73077
|
}
|
|
72657
73078
|
var PRICE_LENS_ADDRESS = "0x6392892f3C57c658d2c748fc64c6fe57680E889F";
|
|
72658
73079
|
var PRICE_LENS_CHAINS = [
|
|
@@ -72751,7 +73172,9 @@ function parseEulerV2Results(data, meta, context) {
|
|
|
72751
73172
|
if (isNaN(priceInUoA) || priceInUoA === 0) return;
|
|
72752
73173
|
let priceUSD;
|
|
72753
73174
|
let derivation;
|
|
72754
|
-
|
|
73175
|
+
const unitKind = unitOfAccountKind(unitOfAccount);
|
|
73176
|
+
if (unitKind === void 0) return;
|
|
73177
|
+
if (unitKind === "usd") {
|
|
72755
73178
|
priceUSD = priceInUoA;
|
|
72756
73179
|
derivation = "direct";
|
|
72757
73180
|
} else {
|
|
@@ -72763,6 +73186,8 @@ function parseEulerV2Results(data, meta, context) {
|
|
|
72763
73186
|
if (isNaN(priceUSD) || priceUSD === 0) return;
|
|
72764
73187
|
if (priceUSD > MAX_SANE_PRICE_USD) return;
|
|
72765
73188
|
if (priceUSD < MIN_SANE_PRICE_USD) return;
|
|
73189
|
+
if (priceUSD > MAX_SANE_STABLE_USD && context.tokenList?.[asset]?.props?.stablecoin?.base === "USD")
|
|
73190
|
+
return;
|
|
72766
73191
|
entries.push({
|
|
72767
73192
|
asset,
|
|
72768
73193
|
price: priceInUoA,
|
|
@@ -72777,7 +73202,7 @@ function parseEulerV2Results(data, meta, context) {
|
|
|
72777
73202
|
} catch {
|
|
72778
73203
|
}
|
|
72779
73204
|
});
|
|
72780
|
-
return entries;
|
|
73205
|
+
return dropDisagreeingVaults(entries);
|
|
72781
73206
|
}
|
|
72782
73207
|
function getEulerV2Abi() {
|
|
72783
73208
|
return eulerCombinedAbi;
|
|
@@ -72873,6 +73298,35 @@ var aaveV4Fetcher = {
|
|
|
72873
73298
|
parse: parseAaveV4Results,
|
|
72874
73299
|
getAbi: getAaveV4Abi
|
|
72875
73300
|
};
|
|
73301
|
+
|
|
73302
|
+
// src/prices/oracle-prices/fetchers/siloPricing.ts
|
|
73303
|
+
var MIN_INDEXER_USD = 1;
|
|
73304
|
+
function indexerUnitUsd(amount5, usd) {
|
|
73305
|
+
if (!(amount5 > 0) || !(usd >= MIN_INDEXER_USD)) return 0;
|
|
73306
|
+
const p = usd / amount5;
|
|
73307
|
+
return Number.isFinite(p) ? p : 0;
|
|
73308
|
+
}
|
|
73309
|
+
function staticSideUsd(ownUSD, partnerUSD, partner) {
|
|
73310
|
+
if (ownUSD > 0) return ownUSD;
|
|
73311
|
+
if (!(partnerUSD > 0)) return 0;
|
|
73312
|
+
if (partner.static) return partnerUSD;
|
|
73313
|
+
const q = partner.quoteInOwn;
|
|
73314
|
+
if (q === void 0 || !(q > 0)) return 0;
|
|
73315
|
+
const p = partnerUSD / q;
|
|
73316
|
+
return Number.isFinite(p) ? p : 0;
|
|
73317
|
+
}
|
|
73318
|
+
var MAX_SILO_DEVIATION = 10;
|
|
73319
|
+
function dropFarFromDirect(entries, shared, tokenList) {
|
|
73320
|
+
return entries.filter((e) => {
|
|
73321
|
+
const lc2 = e.asset.toLowerCase();
|
|
73322
|
+
const ref = shared[tokenList[lc2]?.assetGroup ?? ""] ?? shared[lc2];
|
|
73323
|
+
if (!(ref > 0)) return true;
|
|
73324
|
+
const r = e.priceUSD / ref;
|
|
73325
|
+
return r <= MAX_SILO_DEVIATION && r >= 1 / MAX_SILO_DEVIATION;
|
|
73326
|
+
});
|
|
73327
|
+
}
|
|
73328
|
+
|
|
73329
|
+
// src/prices/oracle-prices/fetchers/siloV2.ts
|
|
72876
73330
|
var SiloOracleAbi = [
|
|
72877
73331
|
{
|
|
72878
73332
|
inputs: [
|
|
@@ -72898,6 +73352,17 @@ function lookupUSD(context, asset) {
|
|
|
72898
73352
|
const groupKey = context.tokenList?.[lc2]?.assetGroup ?? `${context.chainId}-${lc2}`;
|
|
72899
73353
|
return context.usdPrices[groupKey] ?? context.usdPrices[lc2] ?? 0;
|
|
72900
73354
|
}
|
|
73355
|
+
function partnerQuoteIn(data, meta, partnerOracle, partnerToken, ownToken) {
|
|
73356
|
+
const qIdx = meta.callIndexMap[`${partnerOracle}:${partnerToken}`];
|
|
73357
|
+
const qtIdx = meta.quoteTokenIndexMap[partnerOracle];
|
|
73358
|
+
if (qIdx === void 0 || qtIdx === void 0) return void 0;
|
|
73359
|
+
const raw = data[qIdx];
|
|
73360
|
+
const qt = data[qtIdx];
|
|
73361
|
+
if (!raw || raw === "0x" || !qt || qt === "0x") return void 0;
|
|
73362
|
+
if (qt.toLowerCase() !== ownToken) return void 0;
|
|
73363
|
+
const q = Number(BigInt(raw.toString())) / 1e18;
|
|
73364
|
+
return Number.isFinite(q) && q > 0 ? q : void 0;
|
|
73365
|
+
}
|
|
72901
73366
|
function getSiloV2Calls(chainId) {
|
|
72902
73367
|
const allMarkets = siloMarkets()?.[chainId];
|
|
72903
73368
|
if (!allMarkets || allMarkets.length === 0) return [];
|
|
@@ -72939,6 +73404,7 @@ function getSiloV2Calls(chainId) {
|
|
|
72939
73404
|
lenderKey,
|
|
72940
73405
|
oracle: ZERO_ADDRESS9,
|
|
72941
73406
|
partnerToken: partnerLc,
|
|
73407
|
+
partnerOracle: isStatic[1 - i] ? ZERO_ADDRESS9 : partner.solvencyOracle.toLowerCase(),
|
|
72942
73408
|
isStatic: true
|
|
72943
73409
|
});
|
|
72944
73410
|
continue;
|
|
@@ -72993,7 +73459,20 @@ function parseSiloV2Results(data, meta, context) {
|
|
|
72993
73459
|
if (entry2.isStatic) {
|
|
72994
73460
|
const ownUSD = lookupUSD(context, entry2.token);
|
|
72995
73461
|
const partnerUSD = lookupUSD(context, entry2.partnerToken);
|
|
72996
|
-
priceUSD =
|
|
73462
|
+
priceUSD = staticSideUsd(
|
|
73463
|
+
ownUSD,
|
|
73464
|
+
partnerUSD,
|
|
73465
|
+
!entry2.partnerOracle || entry2.partnerOracle === ZERO_ADDRESS9 ? { static: true } : {
|
|
73466
|
+
static: false,
|
|
73467
|
+
quoteInOwn: partnerQuoteIn(
|
|
73468
|
+
data,
|
|
73469
|
+
meta,
|
|
73470
|
+
entry2.partnerOracle,
|
|
73471
|
+
entry2.partnerToken,
|
|
73472
|
+
entry2.token
|
|
73473
|
+
)
|
|
73474
|
+
}
|
|
73475
|
+
);
|
|
72997
73476
|
if (!priceUSD) continue;
|
|
72998
73477
|
rawPrice = 1;
|
|
72999
73478
|
} else {
|
|
@@ -73067,6 +73546,17 @@ function lookupUSD2(context, asset) {
|
|
|
73067
73546
|
const groupKey = context.tokenList?.[lc2]?.assetGroup ?? `${context.chainId}-${lc2}`;
|
|
73068
73547
|
return context.usdPrices[groupKey] ?? context.usdPrices[lc2] ?? 0;
|
|
73069
73548
|
}
|
|
73549
|
+
function partnerQuoteIn2(data, meta, partnerOracle, partnerToken, ownToken) {
|
|
73550
|
+
const qIdx = meta.callIndexMap[`${partnerOracle}:${partnerToken}`];
|
|
73551
|
+
const qtIdx = meta.quoteTokenIndexMap[partnerOracle];
|
|
73552
|
+
if (qIdx === void 0 || qtIdx === void 0) return void 0;
|
|
73553
|
+
const raw = data[qIdx];
|
|
73554
|
+
const qt = data[qtIdx];
|
|
73555
|
+
if (!raw || raw === "0x" || !qt || qt === "0x") return void 0;
|
|
73556
|
+
if (qt.toLowerCase() !== ownToken) return void 0;
|
|
73557
|
+
const q = Number(BigInt(raw.toString())) / 1e18;
|
|
73558
|
+
return Number.isFinite(q) && q > 0 ? q : void 0;
|
|
73559
|
+
}
|
|
73070
73560
|
function getSiloV3Calls(chainId) {
|
|
73071
73561
|
const allMarkets = siloMarketsV3()?.[chainId];
|
|
73072
73562
|
if (!allMarkets || allMarkets.length === 0) return [];
|
|
@@ -73108,6 +73598,7 @@ function getSiloV3Calls(chainId) {
|
|
|
73108
73598
|
lenderKey,
|
|
73109
73599
|
oracle: ZERO_ADDRESS10,
|
|
73110
73600
|
partnerToken: partnerLc,
|
|
73601
|
+
partnerOracle: isStatic[1 - i] ? ZERO_ADDRESS10 : partner.solvencyOracle.toLowerCase(),
|
|
73111
73602
|
isStatic: true
|
|
73112
73603
|
});
|
|
73113
73604
|
continue;
|
|
@@ -73162,7 +73653,20 @@ function parseSiloV3Results(data, meta, context) {
|
|
|
73162
73653
|
if (entry2.isStatic) {
|
|
73163
73654
|
const ownUSD = lookupUSD2(context, entry2.token);
|
|
73164
73655
|
const partnerUSD = lookupUSD2(context, entry2.partnerToken);
|
|
73165
|
-
priceUSD =
|
|
73656
|
+
priceUSD = staticSideUsd(
|
|
73657
|
+
ownUSD,
|
|
73658
|
+
partnerUSD,
|
|
73659
|
+
!entry2.partnerOracle || entry2.partnerOracle === ZERO_ADDRESS10 ? { static: true } : {
|
|
73660
|
+
static: false,
|
|
73661
|
+
quoteInOwn: partnerQuoteIn2(
|
|
73662
|
+
data,
|
|
73663
|
+
meta,
|
|
73664
|
+
entry2.partnerOracle,
|
|
73665
|
+
entry2.partnerToken,
|
|
73666
|
+
entry2.token
|
|
73667
|
+
)
|
|
73668
|
+
}
|
|
73669
|
+
);
|
|
73166
73670
|
if (!priceUSD) continue;
|
|
73167
73671
|
rawPrice = 1;
|
|
73168
73672
|
} else {
|
|
@@ -73427,9 +73931,14 @@ async function fetchSiloV2GraphQLMarkets(chainId) {
|
|
|
73427
73931
|
async function fetchSiloV2GraphQLPrices(chainId, basePrices = {}, tokenList = {}) {
|
|
73428
73932
|
const items = await fetchSiloV2GraphQLMarkets(chainId);
|
|
73429
73933
|
if (items == null) return null;
|
|
73430
|
-
const
|
|
73431
|
-
|
|
73432
|
-
|
|
73934
|
+
const selfDerived = buildSelfDerivedUsdMap(
|
|
73935
|
+
chainId,
|
|
73936
|
+
items,
|
|
73937
|
+
basePrices,
|
|
73938
|
+
tokenList
|
|
73939
|
+
);
|
|
73940
|
+
const parse = (usdPrices) => parseSiloV2GraphQLResults(items, { chainId, usdPrices, tokenList });
|
|
73941
|
+
const entries = parse(selfDerived);
|
|
73433
73942
|
if (entries.length === 0) {
|
|
73434
73943
|
if (items.length > 0)
|
|
73435
73944
|
console.warn(
|
|
@@ -73437,7 +73946,20 @@ async function fetchSiloV2GraphQLPrices(chainId, basePrices = {}, tokenList = {}
|
|
|
73437
73946
|
);
|
|
73438
73947
|
return null;
|
|
73439
73948
|
}
|
|
73440
|
-
return
|
|
73949
|
+
return {
|
|
73950
|
+
entries,
|
|
73951
|
+
reprice: (shared) => {
|
|
73952
|
+
const merged = { ...selfDerived };
|
|
73953
|
+
for (const [k, px] of Object.entries(shared))
|
|
73954
|
+
if (Number.isFinite(px) && px > 0) merged[k] = px;
|
|
73955
|
+
const repriced = parse(merged);
|
|
73956
|
+
return dropFarFromDirect(
|
|
73957
|
+
repriced.length ? repriced : entries,
|
|
73958
|
+
shared,
|
|
73959
|
+
tokenList
|
|
73960
|
+
);
|
|
73961
|
+
}
|
|
73962
|
+
};
|
|
73441
73963
|
}
|
|
73442
73964
|
function buildSelfDerivedUsdMap(chainId, items, basePrices, tokenList) {
|
|
73443
73965
|
const map = {};
|
|
@@ -73454,15 +73976,15 @@ function buildSelfDerivedUsdMap(chainId, items, basePrices, tokenList) {
|
|
|
73454
73976
|
if (!tokenLc) continue;
|
|
73455
73977
|
const supply = safeNumber3(market.supply);
|
|
73456
73978
|
const supplyUsd = market.supplyUsd != null ? Number(market.supplyUsd) : 0;
|
|
73457
|
-
|
|
73458
|
-
|
|
73979
|
+
const fromSupply = indexerUnitUsd(supply, supplyUsd);
|
|
73980
|
+
if (fromSupply > 0) {
|
|
73981
|
+
set(tokenLc, fromSupply);
|
|
73459
73982
|
continue;
|
|
73460
73983
|
}
|
|
73461
73984
|
const borrowed = safeNumber3(market.borrowed);
|
|
73462
73985
|
const borrowedUsd = market.borrowedUsd != null ? Number(market.borrowedUsd) : 0;
|
|
73463
|
-
|
|
73464
|
-
|
|
73465
|
-
}
|
|
73986
|
+
const fromBorrowed = indexerUnitUsd(borrowed, borrowedUsd);
|
|
73987
|
+
if (fromBorrowed > 0) set(tokenLc, fromBorrowed);
|
|
73466
73988
|
}
|
|
73467
73989
|
}
|
|
73468
73990
|
for (const [k, v] of Object.entries(basePrices)) {
|
|
@@ -73495,10 +74017,20 @@ function parseSiloV2GraphQLResults(items, context) {
|
|
|
73495
74017
|
if (!registryEntry) continue;
|
|
73496
74018
|
const [apiSide0, apiSide1] = item.market1.index === 0 ? [item.market1, item.market2] : [item.market2, item.market1];
|
|
73497
74019
|
const sideTuples = [
|
|
73498
|
-
{
|
|
73499
|
-
|
|
74020
|
+
{
|
|
74021
|
+
api: apiSide0,
|
|
74022
|
+
otherApi: apiSide1,
|
|
74023
|
+
self: registryEntry.silo0,
|
|
74024
|
+
other: registryEntry.silo1
|
|
74025
|
+
},
|
|
74026
|
+
{
|
|
74027
|
+
api: apiSide1,
|
|
74028
|
+
otherApi: apiSide0,
|
|
74029
|
+
self: registryEntry.silo1,
|
|
74030
|
+
other: registryEntry.silo0
|
|
74031
|
+
}
|
|
73500
74032
|
];
|
|
73501
|
-
for (const { api: side2, self, other } of sideTuples) {
|
|
74033
|
+
for (const { api: side2, otherApi, self, other } of sideTuples) {
|
|
73502
74034
|
const tokenLc = (side2.inputTokenId ?? side2.inputToken?.id ?? self.token).toLowerCase();
|
|
73503
74035
|
if (!tokenLc) continue;
|
|
73504
74036
|
const partnerTokenLc = other.token.toLowerCase();
|
|
@@ -73514,16 +74046,24 @@ function parseSiloV2GraphQLResults(items, context) {
|
|
|
73514
74046
|
const supplyUsdNum = side2.supplyUsd != null ? Number(side2.supplyUsd) : 0;
|
|
73515
74047
|
const borrowedNum = safeNumber3(side2.borrowed);
|
|
73516
74048
|
const borrowedUsdNum = side2.borrowedUsd != null ? Number(side2.borrowedUsd) : 0;
|
|
73517
|
-
|
|
73518
|
-
|
|
74049
|
+
const fromSupply = indexerUnitUsd(supplyNum, supplyUsdNum);
|
|
74050
|
+
const fromBorrowed = indexerUnitUsd(borrowedNum, borrowedUsdNum);
|
|
74051
|
+
if (fromSupply > 0) {
|
|
74052
|
+
priceUSD = fromSupply;
|
|
73519
74053
|
rawPrice = isStatic ? 1 : priceUSD;
|
|
73520
|
-
} else if (
|
|
73521
|
-
priceUSD =
|
|
74054
|
+
} else if (fromBorrowed > 0) {
|
|
74055
|
+
priceUSD = fromBorrowed;
|
|
73522
74056
|
rawPrice = isStatic ? 1 : priceUSD;
|
|
73523
74057
|
} else if (isStatic) {
|
|
73524
74058
|
const ownUSD = lookupUSD3(context, tokenLc);
|
|
73525
74059
|
const partnerUSD = partnerTokenLc ? lookupUSD3(context, partnerTokenLc) : 0;
|
|
73526
|
-
|
|
74060
|
+
const partnerOracle = (otherApi?.solvencyOracleAddress ?? otherApi?.solvencyOracle?.id ?? other.solvencyOracle ?? ZERO_ADDRESS13).toLowerCase();
|
|
74061
|
+
const partnerQuote = (otherApi?.solvencyOracle?.quoteTokenId ?? "").toLowerCase() === tokenLc ? Number(otherApi?.solvencyOracle?.quote) : void 0;
|
|
74062
|
+
priceUSD = staticSideUsd(
|
|
74063
|
+
ownUSD,
|
|
74064
|
+
partnerUSD,
|
|
74065
|
+
!partnerOracle || partnerOracle === ZERO_ADDRESS13 ? { static: true } : { static: false, quoteInOwn: partnerQuote }
|
|
74066
|
+
);
|
|
73527
74067
|
if (!priceUSD) continue;
|
|
73528
74068
|
rawPrice = 1;
|
|
73529
74069
|
} else {
|
|
@@ -73571,9 +74111,14 @@ async function fetchSiloV3GraphQLMarkets(chainId) {
|
|
|
73571
74111
|
async function fetchSiloV3GraphQLPrices(chainId, basePrices = {}, tokenList = {}) {
|
|
73572
74112
|
const items = await fetchSiloV3GraphQLMarkets(chainId);
|
|
73573
74113
|
if (items == null) return null;
|
|
73574
|
-
const
|
|
73575
|
-
|
|
73576
|
-
|
|
74114
|
+
const selfDerived = buildSelfDerivedUsdMap2(
|
|
74115
|
+
chainId,
|
|
74116
|
+
items,
|
|
74117
|
+
basePrices,
|
|
74118
|
+
tokenList
|
|
74119
|
+
);
|
|
74120
|
+
const parse = (usdPrices) => parseSiloV3GraphQLResults(items, { chainId, usdPrices, tokenList });
|
|
74121
|
+
const entries = parse(selfDerived);
|
|
73577
74122
|
if (entries.length === 0) {
|
|
73578
74123
|
if (items.length > 0)
|
|
73579
74124
|
console.warn(
|
|
@@ -73581,7 +74126,20 @@ async function fetchSiloV3GraphQLPrices(chainId, basePrices = {}, tokenList = {}
|
|
|
73581
74126
|
);
|
|
73582
74127
|
return null;
|
|
73583
74128
|
}
|
|
73584
|
-
return
|
|
74129
|
+
return {
|
|
74130
|
+
entries,
|
|
74131
|
+
reprice: (shared) => {
|
|
74132
|
+
const merged = { ...selfDerived };
|
|
74133
|
+
for (const [k, px] of Object.entries(shared))
|
|
74134
|
+
if (Number.isFinite(px) && px > 0) merged[k] = px;
|
|
74135
|
+
const repriced = parse(merged);
|
|
74136
|
+
return dropFarFromDirect(
|
|
74137
|
+
repriced.length ? repriced : entries,
|
|
74138
|
+
shared,
|
|
74139
|
+
tokenList
|
|
74140
|
+
);
|
|
74141
|
+
}
|
|
74142
|
+
};
|
|
73585
74143
|
}
|
|
73586
74144
|
function buildSelfDerivedUsdMap2(chainId, items, basePrices, tokenList) {
|
|
73587
74145
|
const map = {};
|
|
@@ -73598,15 +74156,15 @@ function buildSelfDerivedUsdMap2(chainId, items, basePrices, tokenList) {
|
|
|
73598
74156
|
if (!tokenLc) continue;
|
|
73599
74157
|
const supply = safeNumber4(market.supply);
|
|
73600
74158
|
const supplyUsd = market.supplyUsd != null ? Number(market.supplyUsd) : 0;
|
|
73601
|
-
|
|
73602
|
-
|
|
74159
|
+
const fromSupply = indexerUnitUsd(supply, supplyUsd);
|
|
74160
|
+
if (fromSupply > 0) {
|
|
74161
|
+
set(tokenLc, fromSupply);
|
|
73603
74162
|
continue;
|
|
73604
74163
|
}
|
|
73605
74164
|
const borrowed = safeNumber4(market.borrowed);
|
|
73606
74165
|
const borrowedUsd = market.borrowedUsd != null ? Number(market.borrowedUsd) : 0;
|
|
73607
|
-
|
|
73608
|
-
|
|
73609
|
-
}
|
|
74166
|
+
const fromBorrowed = indexerUnitUsd(borrowed, borrowedUsd);
|
|
74167
|
+
if (fromBorrowed > 0) set(tokenLc, fromBorrowed);
|
|
73610
74168
|
}
|
|
73611
74169
|
}
|
|
73612
74170
|
for (const [k, v] of Object.entries(basePrices)) {
|
|
@@ -73639,10 +74197,20 @@ function parseSiloV3GraphQLResults(items, context) {
|
|
|
73639
74197
|
if (!registryEntry) continue;
|
|
73640
74198
|
const [apiSide0, apiSide1] = item.market1.index === 0 ? [item.market1, item.market2] : [item.market2, item.market1];
|
|
73641
74199
|
const sideTuples = [
|
|
73642
|
-
{
|
|
73643
|
-
|
|
74200
|
+
{
|
|
74201
|
+
api: apiSide0,
|
|
74202
|
+
otherApi: apiSide1,
|
|
74203
|
+
self: registryEntry.silo0,
|
|
74204
|
+
other: registryEntry.silo1
|
|
74205
|
+
},
|
|
74206
|
+
{
|
|
74207
|
+
api: apiSide1,
|
|
74208
|
+
otherApi: apiSide0,
|
|
74209
|
+
self: registryEntry.silo1,
|
|
74210
|
+
other: registryEntry.silo0
|
|
74211
|
+
}
|
|
73644
74212
|
];
|
|
73645
|
-
for (const { api: side2, self, other } of sideTuples) {
|
|
74213
|
+
for (const { api: side2, otherApi, self, other } of sideTuples) {
|
|
73646
74214
|
const tokenLc = (side2.inputTokenId ?? side2.inputToken?.id ?? self.token).toLowerCase();
|
|
73647
74215
|
if (!tokenLc) continue;
|
|
73648
74216
|
const partnerTokenLc = other.token.toLowerCase();
|
|
@@ -73658,16 +74226,24 @@ function parseSiloV3GraphQLResults(items, context) {
|
|
|
73658
74226
|
const supplyUsdNum = side2.supplyUsd != null ? Number(side2.supplyUsd) : 0;
|
|
73659
74227
|
const borrowedNum = safeNumber4(side2.borrowed);
|
|
73660
74228
|
const borrowedUsdNum = side2.borrowedUsd != null ? Number(side2.borrowedUsd) : 0;
|
|
73661
|
-
|
|
73662
|
-
|
|
74229
|
+
const fromSupply = indexerUnitUsd(supplyNum, supplyUsdNum);
|
|
74230
|
+
const fromBorrowed = indexerUnitUsd(borrowedNum, borrowedUsdNum);
|
|
74231
|
+
if (fromSupply > 0) {
|
|
74232
|
+
priceUSD = fromSupply;
|
|
73663
74233
|
rawPrice = isStatic ? 1 : priceUSD;
|
|
73664
|
-
} else if (
|
|
73665
|
-
priceUSD =
|
|
74234
|
+
} else if (fromBorrowed > 0) {
|
|
74235
|
+
priceUSD = fromBorrowed;
|
|
73666
74236
|
rawPrice = isStatic ? 1 : priceUSD;
|
|
73667
74237
|
} else if (isStatic) {
|
|
73668
74238
|
const ownUSD = lookupUSD4(context, tokenLc);
|
|
73669
74239
|
const partnerUSD = partnerTokenLc ? lookupUSD4(context, partnerTokenLc) : 0;
|
|
73670
|
-
|
|
74240
|
+
const partnerOracle = (otherApi?.solvencyOracleAddress ?? otherApi?.solvencyOracle?.id ?? other.solvencyOracle ?? ZERO_ADDRESS13).toLowerCase();
|
|
74241
|
+
const partnerQuote = (otherApi?.solvencyOracle?.quoteTokenId ?? "").toLowerCase() === tokenLc ? Number(otherApi?.solvencyOracle?.quote) : void 0;
|
|
74242
|
+
priceUSD = staticSideUsd(
|
|
74243
|
+
ownUSD,
|
|
74244
|
+
partnerUSD,
|
|
74245
|
+
!partnerOracle || partnerOracle === ZERO_ADDRESS13 ? { static: true } : { static: false, quoteInOwn: partnerQuote }
|
|
74246
|
+
);
|
|
73671
74247
|
if (!priceUSD) continue;
|
|
73672
74248
|
rawPrice = 1;
|
|
73673
74249
|
} else {
|
|
@@ -74264,6 +74840,57 @@ function resolveDerivation(entry2, groupDefault) {
|
|
|
74264
74840
|
if (entry2.baseAsset && !entry2.staticBase) return "quoted";
|
|
74265
74841
|
return groupDefault ?? "direct";
|
|
74266
74842
|
}
|
|
74843
|
+
var BASE_AGREEMENT_TOLERANCE = 0.05;
|
|
74844
|
+
var BasePriceBook = class {
|
|
74845
|
+
/** `usdPrices` is mutated in place; its initial keys are caller overrides. */
|
|
74846
|
+
constructor(usdPrices) {
|
|
74847
|
+
this.usdPrices = usdPrices;
|
|
74848
|
+
for (const [k, v] of Object.entries(usdPrices))
|
|
74849
|
+
if (v > 0 && Number.isFinite(v))
|
|
74850
|
+
this.candidates.set(k, [
|
|
74851
|
+
{ priceUSD: v, protocol: "BASE_PRICES", derived: false, order: -1 }
|
|
74852
|
+
]);
|
|
74853
|
+
}
|
|
74854
|
+
usdPrices;
|
|
74855
|
+
candidates = /* @__PURE__ */ new Map();
|
|
74856
|
+
order = 0;
|
|
74857
|
+
seed(groupKey, asset, priceUSD, derivation, lender) {
|
|
74858
|
+
if (!(priceUSD > 0) || !Number.isFinite(priceUSD)) return;
|
|
74859
|
+
const c = {
|
|
74860
|
+
priceUSD,
|
|
74861
|
+
protocol: protocolOfLender(lender),
|
|
74862
|
+
derived: derivation === "derived",
|
|
74863
|
+
order: this.order++
|
|
74864
|
+
};
|
|
74865
|
+
for (const key5 of groupKey === asset ? [asset] : [groupKey, asset]) {
|
|
74866
|
+
const list = this.candidates.get(key5);
|
|
74867
|
+
if (list) list.push(c);
|
|
74868
|
+
else this.candidates.set(key5, [c]);
|
|
74869
|
+
this.usdPrices[key5] = resolveBase(this.candidates.get(key5));
|
|
74870
|
+
}
|
|
74871
|
+
}
|
|
74872
|
+
};
|
|
74873
|
+
function resolveBase(all) {
|
|
74874
|
+
const primary = all.filter((c) => !c.derived);
|
|
74875
|
+
const pool = primary.length ? primary : all;
|
|
74876
|
+
let best = pool[0];
|
|
74877
|
+
let bestSupport = -1;
|
|
74878
|
+
for (const c of pool) {
|
|
74879
|
+
const protocols = /* @__PURE__ */ new Set();
|
|
74880
|
+
for (const o of pool)
|
|
74881
|
+
if (Math.abs(o.priceUSD / c.priceUSD - 1) <= BASE_AGREEMENT_TOLERANCE)
|
|
74882
|
+
protocols.add(o.protocol);
|
|
74883
|
+
const support = protocols.size;
|
|
74884
|
+
if (support > bestSupport || support === bestSupport && c.order < best.order) {
|
|
74885
|
+
best = c;
|
|
74886
|
+
bestSupport = support;
|
|
74887
|
+
}
|
|
74888
|
+
}
|
|
74889
|
+
return best.priceUSD;
|
|
74890
|
+
}
|
|
74891
|
+
function protocolOfLender(lender) {
|
|
74892
|
+
return lender.split("_")[0].toUpperCase();
|
|
74893
|
+
}
|
|
74267
74894
|
function countFailures(data, offset, count) {
|
|
74268
74895
|
let failures = 0;
|
|
74269
74896
|
for (let i = offset; i < offset + count; i++) {
|
|
@@ -75254,6 +75881,14 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
|
|
|
75254
75881
|
}
|
|
75255
75882
|
}
|
|
75256
75883
|
const usdPrices = { ...basePrices };
|
|
75884
|
+
const basePrices_ = new BasePriceBook(usdPrices);
|
|
75885
|
+
const seedUsdPrice = (asset, priceUSD, derivation, lender) => basePrices_.seed(
|
|
75886
|
+
tokenList[asset]?.assetGroup ?? `${chainId}-${asset}`,
|
|
75887
|
+
asset,
|
|
75888
|
+
priceUSD,
|
|
75889
|
+
derivation,
|
|
75890
|
+
lender
|
|
75891
|
+
);
|
|
75257
75892
|
const parseTrackers = (group, data, updatePrices = true, filter) => {
|
|
75258
75893
|
const trackers = filter ? group.trackers.filter(filter) : group.trackers;
|
|
75259
75894
|
for (const tracker of trackers) {
|
|
@@ -75279,11 +75914,13 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
|
|
|
75279
75914
|
}
|
|
75280
75915
|
entry2.derivation = resolveDerivation(entry2, group.derivation);
|
|
75281
75916
|
chainResult[lender].push(entry2);
|
|
75282
|
-
if (updatePrices)
|
|
75283
|
-
|
|
75284
|
-
|
|
75285
|
-
|
|
75286
|
-
|
|
75917
|
+
if (updatePrices)
|
|
75918
|
+
seedUsdPrice(
|
|
75919
|
+
entry2.asset,
|
|
75920
|
+
entry2.priceUSD,
|
|
75921
|
+
entry2.derivation,
|
|
75922
|
+
lender
|
|
75923
|
+
);
|
|
75287
75924
|
}
|
|
75288
75925
|
} catch (e) {
|
|
75289
75926
|
diag2.parseError = e instanceof Error ? e.message : String(e);
|
|
@@ -75327,16 +75964,16 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
|
|
|
75327
75964
|
lender: "SILO_V2 (GraphQL)",
|
|
75328
75965
|
callCount: 0,
|
|
75329
75966
|
failedCalls: 0,
|
|
75330
|
-
parsedEntries:
|
|
75967
|
+
parsedEntries: 0
|
|
75331
75968
|
};
|
|
75332
|
-
|
|
75969
|
+
const entries = siloV2GqlEntries.reprice(usdPrices);
|
|
75970
|
+
diag2.parsedEntries = entries.length;
|
|
75971
|
+
for (const entry2 of entries) {
|
|
75333
75972
|
const lender = entry2.targetLender ?? "SILO_V2";
|
|
75334
75973
|
if (!chainResult[lender]) chainResult[lender] = [];
|
|
75335
75974
|
entry2.derivation = resolveDerivation(entry2, "derived");
|
|
75336
75975
|
chainResult[lender].push(entry2);
|
|
75337
|
-
|
|
75338
|
-
usdPrices[oracleKey] = entry2.priceUSD;
|
|
75339
|
-
usdPrices[entry2.asset] = entry2.priceUSD;
|
|
75976
|
+
seedUsdPrice(entry2.asset, entry2.priceUSD, entry2.derivation, lender);
|
|
75340
75977
|
}
|
|
75341
75978
|
trackerDiags.push(diag2);
|
|
75342
75979
|
} else {
|
|
@@ -75347,16 +75984,16 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
|
|
|
75347
75984
|
lender: "SILO_V3 (GraphQL)",
|
|
75348
75985
|
callCount: 0,
|
|
75349
75986
|
failedCalls: 0,
|
|
75350
|
-
parsedEntries:
|
|
75987
|
+
parsedEntries: 0
|
|
75351
75988
|
};
|
|
75352
|
-
|
|
75989
|
+
const entries = siloV3GqlEntries.reprice(usdPrices);
|
|
75990
|
+
diag2.parsedEntries = entries.length;
|
|
75991
|
+
for (const entry2 of entries) {
|
|
75353
75992
|
const lender = entry2.targetLender ?? "SILO_V3";
|
|
75354
75993
|
if (!chainResult[lender]) chainResult[lender] = [];
|
|
75355
75994
|
entry2.derivation = resolveDerivation(entry2, "derived");
|
|
75356
75995
|
chainResult[lender].push(entry2);
|
|
75357
|
-
|
|
75358
|
-
usdPrices[oracleKey] = entry2.priceUSD;
|
|
75359
|
-
usdPrices[entry2.asset] = entry2.priceUSD;
|
|
75996
|
+
seedUsdPrice(entry2.asset, entry2.priceUSD, entry2.derivation, lender);
|
|
75360
75997
|
}
|
|
75361
75998
|
trackerDiags.push(diag2);
|
|
75362
75999
|
} else {
|
|
@@ -75406,10 +76043,12 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
|
|
|
75406
76043
|
}
|
|
75407
76044
|
if (useMorphoHybrid) {
|
|
75408
76045
|
for (const entry2 of morphoGqlEntries) {
|
|
75409
|
-
|
|
75410
|
-
|
|
75411
|
-
|
|
75412
|
-
|
|
76046
|
+
seedUsdPrice(
|
|
76047
|
+
entry2.asset,
|
|
76048
|
+
entry2.priceUSD,
|
|
76049
|
+
"derived",
|
|
76050
|
+
entry2.targetLender ?? "MORPHO_BLUE"
|
|
76051
|
+
);
|
|
75413
76052
|
}
|
|
75414
76053
|
parseTrackers(morphoGroup, morphoData.results, false);
|
|
75415
76054
|
const onChainKeys = /* @__PURE__ */ new Set();
|
|
@@ -77968,6 +78607,51 @@ function parseVault3(entry2, results, chainId, prices, tokenList, marketIds, rat
|
|
|
77968
78607
|
};
|
|
77969
78608
|
}
|
|
77970
78609
|
|
|
78610
|
+
// src/vaults/morpho/merklFallback.ts
|
|
78611
|
+
var VAULT_TYPES = /* @__PURE__ */ new Set(["ERC20LOGPROCESSOR", "MORPHOVAULT"]);
|
|
78612
|
+
function openVaultCampaigns(opps, chainId) {
|
|
78613
|
+
const out = /* @__PURE__ */ new Map();
|
|
78614
|
+
for (const opp of opps) {
|
|
78615
|
+
if (String(opp.chainId) !== chainId) continue;
|
|
78616
|
+
if (!VAULT_TYPES.has(opp.type) || opp.action !== "LEND") continue;
|
|
78617
|
+
if (!(opp.apr > 0) || isGatedMerklCampaign(opp)) continue;
|
|
78618
|
+
const vault = opp.explorerAddress?.toLowerCase();
|
|
78619
|
+
if (!vault) continue;
|
|
78620
|
+
const list = out.get(vault) ?? [];
|
|
78621
|
+
list.push(opp);
|
|
78622
|
+
out.set(vault, list);
|
|
78623
|
+
}
|
|
78624
|
+
return out;
|
|
78625
|
+
}
|
|
78626
|
+
function applyMerklVaultRewards(vaults, campaigns) {
|
|
78627
|
+
for (const [address, vault] of Object.entries(vaults)) {
|
|
78628
|
+
if (vault.rewardsRate > 0 || vault.rewardStreams?.length) continue;
|
|
78629
|
+
const opps = campaigns.get(address.toLowerCase());
|
|
78630
|
+
if (!opps?.length) continue;
|
|
78631
|
+
const streams = opps.flatMap(
|
|
78632
|
+
(opp) => buildMerklStreams(opp, "deposit", opp.apr, merklSourceRef(opp, "morpho"))
|
|
78633
|
+
);
|
|
78634
|
+
const rewardsRate = opps.reduce((s, o) => s + o.apr, 0);
|
|
78635
|
+
vault.rewardsRate = rewardsRate;
|
|
78636
|
+
vault.depositRate = vault.supplyRate + rewardsRate;
|
|
78637
|
+
vault.rewardStreams = streams;
|
|
78638
|
+
}
|
|
78639
|
+
return vaults;
|
|
78640
|
+
}
|
|
78641
|
+
async function withMerklVaultRewards(vaults, chainId) {
|
|
78642
|
+
const needs = Object.values(vaults).some(
|
|
78643
|
+
(v) => !(v.rewardsRate > 0) && !v.rewardStreams?.length
|
|
78644
|
+
);
|
|
78645
|
+
if (!needs) return vaults;
|
|
78646
|
+
try {
|
|
78647
|
+
const opps = await fetchMerklOpportunities("morpho", chainId);
|
|
78648
|
+
return applyMerklVaultRewards(vaults, openVaultCampaigns(opps, chainId));
|
|
78649
|
+
} catch (e) {
|
|
78650
|
+
console.warn(`Morpho vaults ${chainId}: Merkl fallback skipped:`, e);
|
|
78651
|
+
return vaults;
|
|
78652
|
+
}
|
|
78653
|
+
}
|
|
78654
|
+
|
|
77971
78655
|
// src/vaults/morpho/rateSanity.ts
|
|
77972
78656
|
var IMPLAUSIBLE_APR_PERCENT = 100;
|
|
77973
78657
|
var PINNED_LIQUIDITY_FRACTION = 1e-3;
|
|
@@ -78002,7 +78686,7 @@ var fetchMorphoVaults = async (chainId, multicallRetry, prices = {}, tokenList =
|
|
|
78002
78686
|
prices,
|
|
78003
78687
|
tokenList
|
|
78004
78688
|
) : await fetchMorphoVaultsFromApi(chainId, prices, tokenList);
|
|
78005
|
-
return dropUnrealizableRates(vaults);
|
|
78689
|
+
return dropUnrealizableRates(await withMerklVaultRewards(vaults, chainId));
|
|
78006
78690
|
};
|
|
78007
78691
|
var { chunk: chunk5 } = lodash;
|
|
78008
78692
|
var LISTA_PROTOCOL = "LISTA_DAO";
|
|
@@ -83325,6 +84009,132 @@ var readerStrataCooldown = {
|
|
|
83325
84009
|
}
|
|
83326
84010
|
};
|
|
83327
84011
|
|
|
84012
|
+
// src/vaults/lst/withdrawals/abis/mezzanine.ts
|
|
84013
|
+
var MezzanineQueueReadAbi = [
|
|
84014
|
+
{
|
|
84015
|
+
name: "getUserEpochInfo",
|
|
84016
|
+
type: "function",
|
|
84017
|
+
stateMutability: "view",
|
|
84018
|
+
inputs: [
|
|
84019
|
+
{ name: "user", type: "address" },
|
|
84020
|
+
{ name: "epochId", type: "uint256" }
|
|
84021
|
+
],
|
|
84022
|
+
outputs: [
|
|
84023
|
+
{ name: "pendingShares", type: "uint256" },
|
|
84024
|
+
{ name: "claimableAssets", type: "uint256" }
|
|
84025
|
+
]
|
|
84026
|
+
},
|
|
84027
|
+
{
|
|
84028
|
+
name: "convertToAssets",
|
|
84029
|
+
type: "function",
|
|
84030
|
+
stateMutability: "view",
|
|
84031
|
+
inputs: [{ name: "shares", type: "uint256" }],
|
|
84032
|
+
outputs: [{ name: "", type: "uint256" }]
|
|
84033
|
+
}
|
|
84034
|
+
];
|
|
84035
|
+
var MezzanineEpochReadAbi = [
|
|
84036
|
+
{
|
|
84037
|
+
name: "currentEpochId",
|
|
84038
|
+
type: "function",
|
|
84039
|
+
stateMutability: "view",
|
|
84040
|
+
inputs: [],
|
|
84041
|
+
outputs: [{ name: "", type: "uint256" }]
|
|
84042
|
+
},
|
|
84043
|
+
{
|
|
84044
|
+
name: "epochStart",
|
|
84045
|
+
type: "function",
|
|
84046
|
+
stateMutability: "view",
|
|
84047
|
+
inputs: [],
|
|
84048
|
+
outputs: [{ name: "", type: "uint256" }]
|
|
84049
|
+
},
|
|
84050
|
+
{
|
|
84051
|
+
name: "epochDuration",
|
|
84052
|
+
type: "function",
|
|
84053
|
+
stateMutability: "view",
|
|
84054
|
+
inputs: [],
|
|
84055
|
+
outputs: [{ name: "", type: "uint256" }]
|
|
84056
|
+
}
|
|
84057
|
+
];
|
|
84058
|
+
|
|
84059
|
+
// src/vaults/lst/withdrawals/readers/mezzanine.ts
|
|
84060
|
+
var MAX_DELAY_EPOCHS = 30n;
|
|
84061
|
+
var LOOKBACK_EPOCHS = 104n;
|
|
84062
|
+
var ONE_SHARE3 = 10n ** 21n;
|
|
84063
|
+
var readerMezzanineEpoch = {
|
|
84064
|
+
fetch: async (user, multicallRetry, chainId, entry2) => {
|
|
84065
|
+
const tranche = entry2.withdrawalContract;
|
|
84066
|
+
const vault = entry2.secondaryWithdrawalContract;
|
|
84067
|
+
const mzusd = entry2.escrowToken;
|
|
84068
|
+
if (!tranche || !vault) return [];
|
|
84069
|
+
const clock = await multicallRetry({
|
|
84070
|
+
chain: chainId,
|
|
84071
|
+
calls: [
|
|
84072
|
+
{ address: vault, name: "currentEpochId", params: [] },
|
|
84073
|
+
{ address: vault, name: "epochStart", params: [] },
|
|
84074
|
+
{ address: vault, name: "epochDuration", params: [] },
|
|
84075
|
+
{ address: tranche, name: "convertToAssets", params: [ONE_SHARE3] }
|
|
84076
|
+
],
|
|
84077
|
+
abi: [
|
|
84078
|
+
MezzanineEpochReadAbi,
|
|
84079
|
+
MezzanineEpochReadAbi,
|
|
84080
|
+
MezzanineEpochReadAbi,
|
|
84081
|
+
MezzanineQueueReadAbi
|
|
84082
|
+
]
|
|
84083
|
+
});
|
|
84084
|
+
const current = toBigInt15(clock[0]);
|
|
84085
|
+
const epochStart = toBigInt15(clock[1]);
|
|
84086
|
+
const epochDuration = toBigInt15(clock[2]);
|
|
84087
|
+
const perShare = toBigInt15(clock[3]);
|
|
84088
|
+
if (current === void 0) return [];
|
|
84089
|
+
const first = current > LOOKBACK_EPOCHS ? current - LOOKBACK_EPOCHS : 1n;
|
|
84090
|
+
const epochs = [];
|
|
84091
|
+
for (let e = first; e <= current + MAX_DELAY_EPOCHS; e++) epochs.push(e);
|
|
84092
|
+
const res = await multicallRetry({
|
|
84093
|
+
chain: chainId,
|
|
84094
|
+
calls: epochs.map((e) => ({
|
|
84095
|
+
address: tranche,
|
|
84096
|
+
name: "getUserEpochInfo",
|
|
84097
|
+
params: [user, e]
|
|
84098
|
+
})),
|
|
84099
|
+
abi: epochs.map(() => MezzanineQueueReadAbi)
|
|
84100
|
+
});
|
|
84101
|
+
const out = [];
|
|
84102
|
+
epochs.forEach((epoch, i) => {
|
|
84103
|
+
const cell = res[i];
|
|
84104
|
+
if (!Array.isArray(cell)) return;
|
|
84105
|
+
const pendingShares = toBigInt15(cell[0]);
|
|
84106
|
+
const claimable = toBigInt15(cell[1]);
|
|
84107
|
+
if (!pendingShares) return;
|
|
84108
|
+
const finalized = claimable !== void 0 && claimable > 0n;
|
|
84109
|
+
const base = {
|
|
84110
|
+
lst: entry2.lst,
|
|
84111
|
+
brand: entry2.brand,
|
|
84112
|
+
symbol: entry2.symbol,
|
|
84113
|
+
requestId: epoch.toString(),
|
|
84114
|
+
shares: pendingShares.toString(),
|
|
84115
|
+
withdrawQueue: tranche,
|
|
84116
|
+
...mzusd ? { claimToken: mzusd } : {}
|
|
84117
|
+
};
|
|
84118
|
+
if (finalized) {
|
|
84119
|
+
out.push({
|
|
84120
|
+
...base,
|
|
84121
|
+
amountUnderlying: claimable.toString(),
|
|
84122
|
+
status: "claimable"
|
|
84123
|
+
});
|
|
84124
|
+
return;
|
|
84125
|
+
}
|
|
84126
|
+
const readyAt = epochStart !== void 0 && epochDuration !== void 0 && epoch >= current ? Number(epochStart + (epoch - current + 1n) * epochDuration) : void 0;
|
|
84127
|
+
out.push({
|
|
84128
|
+
...base,
|
|
84129
|
+
amountUnderlying: (pendingShares * (perShare ?? 0n) / ONE_SHARE3).toString(),
|
|
84130
|
+
status: "pending",
|
|
84131
|
+
...readyAt !== void 0 ? { readyAt } : {}
|
|
84132
|
+
});
|
|
84133
|
+
});
|
|
84134
|
+
return out;
|
|
84135
|
+
}
|
|
84136
|
+
};
|
|
84137
|
+
|
|
83328
84138
|
// src/vaults/lst/withdrawals/abis/etherfi.ts
|
|
83329
84139
|
var EtherFiWithdrawRequestAbi = [
|
|
83330
84140
|
{
|
|
@@ -85003,6 +85813,8 @@ var buildWithdrawalReader = (entry2) => {
|
|
|
85003
85813
|
return readerSusd3Cooldown;
|
|
85004
85814
|
case "strataCooldown":
|
|
85005
85815
|
return readerStrataCooldown;
|
|
85816
|
+
case "mezzanineEpoch":
|
|
85817
|
+
return readerMezzanineEpoch;
|
|
85006
85818
|
case "swellNft":
|
|
85007
85819
|
return readerSwell;
|
|
85008
85820
|
case "stakeWiseSubgraph":
|
|
@@ -85216,6 +86028,18 @@ var LST_WITHDRAWAL_REGISTRY = {
|
|
|
85216
86028
|
symbol: "apyUSD",
|
|
85217
86029
|
reader: "unverified"
|
|
85218
86030
|
},
|
|
86031
|
+
// Mezzanine tranches — ONE entry per TRANCHE: requests are tranche-local.
|
|
86032
|
+
// `withdrawalContract` is the tranche, `secondaryWithdrawalContract` the
|
|
86033
|
+
// IssuanceVault holding the epoch clock, `escrowToken` the MZUSD a claim pays.
|
|
86034
|
+
...MEZZANINE_TRANCHES.filter((t) => t.chainId === "1").map((t) => ({
|
|
86035
|
+
lst: t.address,
|
|
86036
|
+
brand: "Mezzanine",
|
|
86037
|
+
symbol: t.symbol,
|
|
86038
|
+
reader: "mezzanineEpoch",
|
|
86039
|
+
withdrawalContract: t.address,
|
|
86040
|
+
secondaryWithdrawalContract: t.issuanceVault,
|
|
86041
|
+
escrowToken: t.mzusd
|
|
86042
|
+
})),
|
|
85219
86043
|
// Strata tranche markets — ONE entry per market (not per tranche):
|
|
85220
86044
|
// both tranches escrow into the same two per-market ICooldown
|
|
85221
86045
|
// contracts keyed by (escrowToken, user) with no tranche
|
|
@@ -87102,6 +87926,163 @@ var FusionBalanceOfAbi = [
|
|
|
87102
87926
|
}
|
|
87103
87927
|
];
|
|
87104
87928
|
|
|
87929
|
+
// src/vaults/savings/abis/mezzanine.ts
|
|
87930
|
+
var MezzanineTrancheReadAbi = [
|
|
87931
|
+
{
|
|
87932
|
+
name: "totalAssets",
|
|
87933
|
+
type: "function",
|
|
87934
|
+
stateMutability: "view",
|
|
87935
|
+
inputs: [],
|
|
87936
|
+
outputs: [{ name: "", type: "uint256" }]
|
|
87937
|
+
},
|
|
87938
|
+
{
|
|
87939
|
+
name: "totalSupply",
|
|
87940
|
+
type: "function",
|
|
87941
|
+
stateMutability: "view",
|
|
87942
|
+
inputs: [],
|
|
87943
|
+
outputs: [{ name: "", type: "uint256" }]
|
|
87944
|
+
},
|
|
87945
|
+
{
|
|
87946
|
+
name: "convertToAssets",
|
|
87947
|
+
type: "function",
|
|
87948
|
+
stateMutability: "view",
|
|
87949
|
+
inputs: [{ name: "shares", type: "uint256" }],
|
|
87950
|
+
outputs: [{ name: "", type: "uint256" }]
|
|
87951
|
+
},
|
|
87952
|
+
{
|
|
87953
|
+
name: "maxDeposit",
|
|
87954
|
+
type: "function",
|
|
87955
|
+
stateMutability: "view",
|
|
87956
|
+
inputs: [{ name: "receiver", type: "address" }],
|
|
87957
|
+
outputs: [{ name: "", type: "uint256" }]
|
|
87958
|
+
},
|
|
87959
|
+
{
|
|
87960
|
+
name: "yieldStreamingAmount",
|
|
87961
|
+
type: "function",
|
|
87962
|
+
stateMutability: "view",
|
|
87963
|
+
inputs: [],
|
|
87964
|
+
outputs: [{ name: "", type: "uint256" }]
|
|
87965
|
+
},
|
|
87966
|
+
{
|
|
87967
|
+
name: "yieldStreamStart",
|
|
87968
|
+
type: "function",
|
|
87969
|
+
stateMutability: "view",
|
|
87970
|
+
inputs: [],
|
|
87971
|
+
outputs: [{ name: "", type: "uint48" }]
|
|
87972
|
+
},
|
|
87973
|
+
{
|
|
87974
|
+
name: "yieldStreamEnd",
|
|
87975
|
+
type: "function",
|
|
87976
|
+
stateMutability: "view",
|
|
87977
|
+
inputs: [],
|
|
87978
|
+
outputs: [{ name: "", type: "uint48" }]
|
|
87979
|
+
},
|
|
87980
|
+
{
|
|
87981
|
+
name: "unstakeDelayEpochs",
|
|
87982
|
+
type: "function",
|
|
87983
|
+
stateMutability: "view",
|
|
87984
|
+
inputs: [],
|
|
87985
|
+
outputs: [{ name: "", type: "uint256" }]
|
|
87986
|
+
},
|
|
87987
|
+
{
|
|
87988
|
+
name: "unstakeYieldReductionBps",
|
|
87989
|
+
type: "function",
|
|
87990
|
+
stateMutability: "view",
|
|
87991
|
+
inputs: [],
|
|
87992
|
+
outputs: [{ name: "", type: "uint256" }]
|
|
87993
|
+
},
|
|
87994
|
+
{
|
|
87995
|
+
name: "directWithdrawEnabled",
|
|
87996
|
+
type: "function",
|
|
87997
|
+
stateMutability: "view",
|
|
87998
|
+
inputs: [],
|
|
87999
|
+
outputs: [{ name: "", type: "bool" }]
|
|
88000
|
+
}
|
|
88001
|
+
];
|
|
88002
|
+
var MezzanineVaultReadAbi = [
|
|
88003
|
+
{
|
|
88004
|
+
name: "epochStart",
|
|
88005
|
+
type: "function",
|
|
88006
|
+
stateMutability: "view",
|
|
88007
|
+
inputs: [],
|
|
88008
|
+
outputs: [{ name: "", type: "uint256" }]
|
|
88009
|
+
},
|
|
88010
|
+
{
|
|
88011
|
+
name: "epochDuration",
|
|
88012
|
+
type: "function",
|
|
88013
|
+
stateMutability: "view",
|
|
88014
|
+
inputs: [],
|
|
88015
|
+
outputs: [{ name: "", type: "uint256" }]
|
|
88016
|
+
},
|
|
88017
|
+
{
|
|
88018
|
+
name: "currentEpochId",
|
|
88019
|
+
type: "function",
|
|
88020
|
+
stateMutability: "view",
|
|
88021
|
+
inputs: [],
|
|
88022
|
+
outputs: [{ name: "", type: "uint256" }]
|
|
88023
|
+
},
|
|
88024
|
+
{
|
|
88025
|
+
name: "performanceFeeBps",
|
|
88026
|
+
type: "function",
|
|
88027
|
+
stateMutability: "view",
|
|
88028
|
+
inputs: [],
|
|
88029
|
+
outputs: [{ name: "", type: "uint16" }]
|
|
88030
|
+
},
|
|
88031
|
+
{
|
|
88032
|
+
name: "protocolFeeBps",
|
|
88033
|
+
type: "function",
|
|
88034
|
+
stateMutability: "view",
|
|
88035
|
+
inputs: [],
|
|
88036
|
+
outputs: [{ name: "", type: "uint16" }]
|
|
88037
|
+
}
|
|
88038
|
+
];
|
|
88039
|
+
var MezzanineBaseReadAbi = [
|
|
88040
|
+
{
|
|
88041
|
+
name: "withdrawalFeeBps",
|
|
88042
|
+
type: "function",
|
|
88043
|
+
stateMutability: "view",
|
|
88044
|
+
inputs: [],
|
|
88045
|
+
outputs: [{ name: "", type: "uint256" }]
|
|
88046
|
+
},
|
|
88047
|
+
{
|
|
88048
|
+
name: "getRemainingRedemptionCap",
|
|
88049
|
+
type: "function",
|
|
88050
|
+
stateMutability: "view",
|
|
88051
|
+
inputs: [],
|
|
88052
|
+
outputs: [{ name: "", type: "uint256" }]
|
|
88053
|
+
}
|
|
88054
|
+
];
|
|
88055
|
+
var MezzanineAllowlistReadAbi = [
|
|
88056
|
+
{
|
|
88057
|
+
name: "verifyAccount",
|
|
88058
|
+
type: "function",
|
|
88059
|
+
stateMutability: "view",
|
|
88060
|
+
inputs: [{ name: "account", type: "address" }],
|
|
88061
|
+
outputs: [{ name: "", type: "bool" }]
|
|
88062
|
+
}
|
|
88063
|
+
];
|
|
88064
|
+
var MezzaninePauseReadAbi = [
|
|
88065
|
+
{
|
|
88066
|
+
name: "isPaused",
|
|
88067
|
+
type: "function",
|
|
88068
|
+
stateMutability: "view",
|
|
88069
|
+
inputs: [
|
|
88070
|
+
{ name: "target", type: "address" },
|
|
88071
|
+
{ name: "category", type: "uint8" }
|
|
88072
|
+
],
|
|
88073
|
+
outputs: [{ name: "", type: "bool" }]
|
|
88074
|
+
}
|
|
88075
|
+
];
|
|
88076
|
+
var MezzanineTokenReadAbi = [
|
|
88077
|
+
{
|
|
88078
|
+
name: "balanceOf",
|
|
88079
|
+
type: "function",
|
|
88080
|
+
stateMutability: "view",
|
|
88081
|
+
inputs: [{ name: "account", type: "address" }],
|
|
88082
|
+
outputs: [{ name: "", type: "uint256" }]
|
|
88083
|
+
}
|
|
88084
|
+
];
|
|
88085
|
+
|
|
87105
88086
|
// src/vaults/savings/abis/ember.ts
|
|
87106
88087
|
var EmberMaxDepositAbi = [
|
|
87107
88088
|
{
|
|
@@ -87973,10 +88954,10 @@ var readerZerobaseVault = (entry2) => {
|
|
|
87973
88954
|
const wait = toBigInt16(waitingTime);
|
|
87974
88955
|
let supplyRate;
|
|
87975
88956
|
if (Array.isArray(rewardRate) && rewardRate.length === 2) {
|
|
87976
|
-
const
|
|
88957
|
+
const num24 = toBigInt16(rewardRate[0]);
|
|
87977
88958
|
const base = toBigInt16(rewardRate[1]);
|
|
87978
|
-
if (
|
|
87979
|
-
supplyRate = Number(
|
|
88959
|
+
if (num24 !== void 0 && base !== void 0 && base > 0n && num24 < base)
|
|
88960
|
+
supplyRate = Number(num24) * 100 / Number(base);
|
|
87980
88961
|
}
|
|
87981
88962
|
return {
|
|
87982
88963
|
// Share and underlying decimals match on every deployment (6/6, or
|
|
@@ -88767,7 +89748,7 @@ var readerWrenNav = (entry2) => {
|
|
|
88767
89748
|
};
|
|
88768
89749
|
|
|
88769
89750
|
// src/vaults/savings/readers/yieldBasisLt.ts
|
|
88770
|
-
var
|
|
89751
|
+
var ONE_SHARE4 = ONE_E1823;
|
|
88771
89752
|
var readerYieldBasisLt = (entry2) => {
|
|
88772
89753
|
const underlyingUnit = 10n ** BigInt(entry2.underlyingDecimals ?? entry2.decimals);
|
|
88773
89754
|
const amm = entry2.capacityContract ?? entry2.address;
|
|
@@ -88775,7 +89756,7 @@ var readerYieldBasisLt = (entry2) => {
|
|
|
88775
89756
|
calls: [
|
|
88776
89757
|
{ address: entry2.address, name: "totalSupply", params: [] },
|
|
88777
89758
|
{ address: entry2.address, name: "pricePerShare", params: [] },
|
|
88778
|
-
{ address: entry2.address, name: "preview_withdraw", params: [
|
|
89759
|
+
{ address: entry2.address, name: "preview_withdraw", params: [ONE_SHARE4] },
|
|
88779
89760
|
{ address: amm, name: "max_debt", params: [] },
|
|
88780
89761
|
{ address: amm, name: "value_oracle", params: [] }
|
|
88781
89762
|
],
|
|
@@ -88794,7 +89775,7 @@ var readerYieldBasisLt = (entry2) => {
|
|
|
88794
89775
|
return void 0;
|
|
88795
89776
|
}
|
|
88796
89777
|
if (totalSupply === 0n || redeemRaw === 0n) return void 0;
|
|
88797
|
-
const totalAssets = totalSupply * redeemRaw /
|
|
89778
|
+
const totalAssets = totalSupply * redeemRaw / ONE_SHARE4;
|
|
88798
89779
|
const exchangeRate = redeemRaw * ONE_E1823 / underlyingUnit;
|
|
88799
89780
|
const equity = Array.isArray(valueOracle) ? toBigInt16(valueOracle[1]) : toBigInt16(valueOracle?.value);
|
|
88800
89781
|
const cap = toBigInt16(maxDebt);
|
|
@@ -88970,8 +89951,198 @@ var readerIporFusion = (entry2) => {
|
|
|
88970
89951
|
};
|
|
88971
89952
|
};
|
|
88972
89953
|
|
|
88973
|
-
// src/vaults/savings/readers/
|
|
89954
|
+
// src/vaults/savings/readers/mezzanine.ts
|
|
88974
89955
|
var NEUTRAL_PROBE5 = "0x000000000000000000000000000000000000dead";
|
|
89956
|
+
var PAUSE_DEPOSITS = 0;
|
|
89957
|
+
var PAUSE_WITHDRAWALS = 1;
|
|
89958
|
+
var BASE_SCALE = 10n ** 12n;
|
|
89959
|
+
var SECONDS_PER_YEAR23 = 31536e3;
|
|
89960
|
+
var mezzanineStreamRate = (args) => {
|
|
89961
|
+
const { amount: amount5, start, end, totalAssets, epochDuration, now } = args;
|
|
89962
|
+
const period = end - start;
|
|
89963
|
+
if (period <= 0 || totalAssets <= 0n) return void 0;
|
|
89964
|
+
if (now >= end + epochDuration) return void 0;
|
|
89965
|
+
const perAsset = Number(amount5 * 1000000000000n / totalAssets) / 1e12;
|
|
89966
|
+
return perAsset / period * SECONDS_PER_YEAR23 * 100;
|
|
89967
|
+
};
|
|
89968
|
+
var mezzanineExitWait = (args) => {
|
|
89969
|
+
const { epochStart, epochDuration, delayEpochs, now } = args;
|
|
89970
|
+
const remainder = Math.max(0, epochStart + epochDuration - now);
|
|
89971
|
+
return remainder + delayEpochs * epochDuration;
|
|
89972
|
+
};
|
|
89973
|
+
var exitDescription = (args) => {
|
|
89974
|
+
const { delayEpochs, yieldCutBps, capacity } = args;
|
|
89975
|
+
const epochs = `${delayEpochs} weekly epoch${delayEpochs === 1 ? "" : "s"}`;
|
|
89976
|
+
const cut = yieldCutBps / 100;
|
|
89977
|
+
return `Settles after ${epochs}, once Mezzanine's automation applies the NAV report and finalizes the epoch; a late report delays it. Queued shares stay in the loss waterfall, and ${cut} % of the yield they earn while queued is forfeited. The claim pays MZUSD, which redeems 1:1 for wYLDS only while the vault holds idle wYLDS` + (capacity !== void 0 ? ` (${(Number(capacity) / 1e6).toLocaleString("en-US", { maximumFractionDigits: 0 })} right now)` : "") + `; the curator has to move it there. wYLDS turns into USDC through Hastra's own redemption.`;
|
|
89978
|
+
};
|
|
89979
|
+
var readerMezzanine = (entry2) => {
|
|
89980
|
+
const cfg = entry2.mezzanine;
|
|
89981
|
+
const t = entry2.address;
|
|
89982
|
+
const shareUnit = 10n ** BigInt(entry2.decimals);
|
|
89983
|
+
const vault = cfg?.issuanceVault ?? "";
|
|
89984
|
+
const mzusd = cfg?.mzusd ?? "";
|
|
89985
|
+
const tranche = (name, params = []) => ({
|
|
89986
|
+
address: t,
|
|
89987
|
+
name,
|
|
89988
|
+
params
|
|
89989
|
+
});
|
|
89990
|
+
const onVault = (name) => ({ address: vault, name, params: [] });
|
|
89991
|
+
const onBase = (name) => ({ address: mzusd, name, params: [] });
|
|
89992
|
+
return {
|
|
89993
|
+
calls: [
|
|
89994
|
+
tranche("totalAssets"),
|
|
89995
|
+
tranche("totalSupply"),
|
|
89996
|
+
tranche("convertToAssets", [shareUnit]),
|
|
89997
|
+
tranche("maxDeposit", [NEUTRAL_PROBE5]),
|
|
89998
|
+
tranche("yieldStreamingAmount"),
|
|
89999
|
+
tranche("yieldStreamStart"),
|
|
90000
|
+
tranche("yieldStreamEnd"),
|
|
90001
|
+
tranche("unstakeDelayEpochs"),
|
|
90002
|
+
tranche("unstakeYieldReductionBps"),
|
|
90003
|
+
tranche("directWithdrawEnabled"),
|
|
90004
|
+
onVault("epochStart"),
|
|
90005
|
+
onVault("epochDuration"),
|
|
90006
|
+
onVault("performanceFeeBps"),
|
|
90007
|
+
onVault("protocolFeeBps"),
|
|
90008
|
+
onBase("withdrawalFeeBps"),
|
|
90009
|
+
onBase("getRemainingRedemptionCap"),
|
|
90010
|
+
{ address: entry2.underlying, name: "balanceOf", params: [vault] },
|
|
90011
|
+
{
|
|
90012
|
+
address: entry2.underlying,
|
|
90013
|
+
name: "balanceOf",
|
|
90014
|
+
params: [cfg?.reservoir ?? ""]
|
|
90015
|
+
},
|
|
90016
|
+
{
|
|
90017
|
+
address: cfg?.allowlist ?? "",
|
|
90018
|
+
name: "verifyAccount",
|
|
90019
|
+
params: [NEUTRAL_PROBE5]
|
|
90020
|
+
},
|
|
90021
|
+
{
|
|
90022
|
+
address: cfg?.pauseManager ?? "",
|
|
90023
|
+
name: "isPaused",
|
|
90024
|
+
params: [mzusd, PAUSE_DEPOSITS]
|
|
90025
|
+
},
|
|
90026
|
+
{
|
|
90027
|
+
address: cfg?.pauseManager ?? "",
|
|
90028
|
+
name: "isPaused",
|
|
90029
|
+
params: [t, PAUSE_WITHDRAWALS]
|
|
90030
|
+
}
|
|
90031
|
+
],
|
|
90032
|
+
abis: [
|
|
90033
|
+
...Array(10).fill(MezzanineTrancheReadAbi),
|
|
90034
|
+
...Array(4).fill(MezzanineVaultReadAbi),
|
|
90035
|
+
...Array(2).fill(MezzanineBaseReadAbi),
|
|
90036
|
+
MezzanineTokenReadAbi,
|
|
90037
|
+
MezzanineTokenReadAbi,
|
|
90038
|
+
MezzanineAllowlistReadAbi,
|
|
90039
|
+
MezzaninePauseReadAbi,
|
|
90040
|
+
MezzaninePauseReadAbi
|
|
90041
|
+
],
|
|
90042
|
+
parse: (slice2) => {
|
|
90043
|
+
const [
|
|
90044
|
+
assets,
|
|
90045
|
+
supply,
|
|
90046
|
+
perShare,
|
|
90047
|
+
maxDep,
|
|
90048
|
+
streamAmount,
|
|
90049
|
+
streamStart,
|
|
90050
|
+
streamEnd,
|
|
90051
|
+
delay,
|
|
90052
|
+
yieldCut,
|
|
90053
|
+
direct,
|
|
90054
|
+
epochStartRaw,
|
|
90055
|
+
epochDurationRaw,
|
|
90056
|
+
perfFee,
|
|
90057
|
+
protocolFee,
|
|
90058
|
+
baseFee,
|
|
90059
|
+
redemptionCap,
|
|
90060
|
+
vaultIdle,
|
|
90061
|
+
reservoirIdle,
|
|
90062
|
+
allowed,
|
|
90063
|
+
depositsPaused,
|
|
90064
|
+
withdrawalsPaused
|
|
90065
|
+
] = slice2;
|
|
90066
|
+
const trancheAssets = toBigInt16(assets);
|
|
90067
|
+
const totalSupply = toBigInt16(supply);
|
|
90068
|
+
const assetsPerShare = toBigInt16(perShare);
|
|
90069
|
+
if (trancheAssets === void 0 || totalSupply === void 0 || assetsPerShare === void 0 || direct === true)
|
|
90070
|
+
return void 0;
|
|
90071
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
90072
|
+
const epochStart = toBigInt16(epochStartRaw);
|
|
90073
|
+
const epochDuration = toBigInt16(epochDurationRaw);
|
|
90074
|
+
const delayEpochs = toBigInt16(delay);
|
|
90075
|
+
const yieldCutBps = toBigInt16(yieldCut);
|
|
90076
|
+
const amount5 = toBigInt16(streamAmount);
|
|
90077
|
+
const start = toBigInt16(streamStart);
|
|
90078
|
+
const end = toBigInt16(streamEnd);
|
|
90079
|
+
const supplyRate = amount5 !== void 0 && start !== void 0 && end !== void 0 && epochDuration !== void 0 ? mezzanineStreamRate({
|
|
90080
|
+
amount: amount5,
|
|
90081
|
+
start: Number(start),
|
|
90082
|
+
end: Number(end),
|
|
90083
|
+
totalAssets: trancheAssets,
|
|
90084
|
+
epochDuration: Number(epochDuration),
|
|
90085
|
+
now
|
|
90086
|
+
}) : void 0;
|
|
90087
|
+
const wait = epochStart !== void 0 && epochDuration !== void 0 && delayEpochs !== void 0 ? mezzanineExitWait({
|
|
90088
|
+
epochStart: Number(epochStart),
|
|
90089
|
+
epochDuration: Number(epochDuration),
|
|
90090
|
+
delayEpochs: Number(delayEpochs),
|
|
90091
|
+
now
|
|
90092
|
+
}) : void 0;
|
|
90093
|
+
const vaultBalance = toBigInt16(vaultIdle);
|
|
90094
|
+
const reservoirBalance = toBigInt16(reservoirIdle);
|
|
90095
|
+
const cap = toBigInt16(redemptionCap);
|
|
90096
|
+
const held = vaultBalance !== void 0 && reservoirBalance !== void 0 ? vaultBalance + reservoirBalance : void 0;
|
|
90097
|
+
const capacity = held !== void 0 && cap !== void 0 ? held < cap ? held : cap : held;
|
|
90098
|
+
const exitFeeBps = toBigInt16(baseFee);
|
|
90099
|
+
const route = {
|
|
90100
|
+
id: "queued",
|
|
90101
|
+
kind: "queued",
|
|
90102
|
+
label: delayEpochs !== void 0 ? `${delayEpochs}-epoch queue` : "Epoch queue",
|
|
90103
|
+
settlement: "async",
|
|
90104
|
+
...exitFeeBps !== void 0 ? { feeBps: Number(exitFeeBps) } : {},
|
|
90105
|
+
...wait !== void 0 ? { waitSeconds: wait } : {},
|
|
90106
|
+
...capacity !== void 0 ? {
|
|
90107
|
+
capacity: capacity.toString(),
|
|
90108
|
+
capacityFormatted: Number(capacity) / 1e6
|
|
90109
|
+
} : {},
|
|
90110
|
+
selfOnly: true,
|
|
90111
|
+
description: exitDescription({
|
|
90112
|
+
delayEpochs: Number(delayEpochs ?? 1n),
|
|
90113
|
+
yieldCutBps: Number(yieldCutBps ?? 0n),
|
|
90114
|
+
capacity
|
|
90115
|
+
})
|
|
90116
|
+
};
|
|
90117
|
+
const perf = toBigInt16(perfFee);
|
|
90118
|
+
const protocol = toBigInt16(protocolFee);
|
|
90119
|
+
const maxDeposit = toBigInt16(maxDep);
|
|
90120
|
+
const closed = allowed === false || depositsPaused === true;
|
|
90121
|
+
const depositCapacity = closed ? 0n : maxDeposit !== void 0 && maxDeposit < 2n ** 255n ? maxDeposit / BASE_SCALE : void 0;
|
|
90122
|
+
return {
|
|
90123
|
+
// The virtual NAV: balance less the unstreamed yield and the assets
|
|
90124
|
+
// reserved for finalized requests, the base of `pricePerShare`.
|
|
90125
|
+
totalAssets: trancheAssets / BASE_SCALE,
|
|
90126
|
+
totalSupply,
|
|
90127
|
+
// MZUSD wei per share IS the 1e18-scaled deposit-asset rate, because
|
|
90128
|
+
// one MZUSD is one deposit-asset unit of notional. No further scaling.
|
|
90129
|
+
exchangeRate: assetsPerShare,
|
|
90130
|
+
...supplyRate !== void 0 ? { supplyRate } : {},
|
|
90131
|
+
exitRoutes: [route],
|
|
90132
|
+
...wait !== void 0 ? { withdrawalCooldownSeconds: wait } : {},
|
|
90133
|
+
...perf !== void 0 && protocol !== void 0 ? { performanceFeeBps: Number(perf + protocol) } : {},
|
|
90134
|
+
...exitFeeBps !== void 0 ? { queuedFeeBps: Number(exitFeeBps) } : {},
|
|
90135
|
+
depositFeeBps: 0,
|
|
90136
|
+
managementFeeBps: 0,
|
|
90137
|
+
...depositCapacity !== void 0 ? { depositCapacity } : {},
|
|
90138
|
+
...withdrawalsPaused === true ? { exitPaused: true } : {}
|
|
90139
|
+
};
|
|
90140
|
+
}
|
|
90141
|
+
};
|
|
90142
|
+
};
|
|
90143
|
+
|
|
90144
|
+
// src/vaults/savings/readers/emberVault.ts
|
|
90145
|
+
var NEUTRAL_PROBE6 = "0x000000000000000000000000000000000000dead";
|
|
88975
90146
|
var readerEmberVault = (entry2) => {
|
|
88976
90147
|
const shareUnit = 10n ** BigInt(entry2.decimals);
|
|
88977
90148
|
const underlyingUnit = 10n ** BigInt(entry2.underlyingDecimals ?? entry2.decimals);
|
|
@@ -88980,7 +90151,7 @@ var readerEmberVault = (entry2) => {
|
|
|
88980
90151
|
{ address: entry2.address, name: "totalAssets", params: [] },
|
|
88981
90152
|
{ address: entry2.address, name: "totalSupply", params: [] },
|
|
88982
90153
|
{ address: entry2.address, name: "convertToAssets", params: [shareUnit] },
|
|
88983
|
-
{ address: entry2.address, name: "maxDeposit", params: [
|
|
90154
|
+
{ address: entry2.address, name: "maxDeposit", params: [NEUTRAL_PROBE6] },
|
|
88984
90155
|
{ address: entry2.address, name: "pauseStatus", params: [] }
|
|
88985
90156
|
],
|
|
88986
90157
|
abis: [
|
|
@@ -89607,7 +90778,7 @@ var readerUnitasXgld = (entry2) => {
|
|
|
89607
90778
|
};
|
|
89608
90779
|
|
|
89609
90780
|
// src/vaults/savings/readers/roycoTranche.ts
|
|
89610
|
-
var
|
|
90781
|
+
var NEUTRAL_PROBE7 = "0x000000000000000000000000000000000000dead";
|
|
89611
90782
|
var ASSET_CLAIMS = {
|
|
89612
90783
|
name: "claims",
|
|
89613
90784
|
type: "tuple",
|
|
@@ -89710,7 +90881,7 @@ var readerRoycoTranche = (entry2) => {
|
|
|
89710
90881
|
{ address: entry2.address, name: "totalAssets", params: [] },
|
|
89711
90882
|
{ address: entry2.address, name: "totalSupply", params: [] },
|
|
89712
90883
|
{ address: entry2.address, name: "convertToAssets", params: [shareUnit] },
|
|
89713
|
-
{ address: entry2.address, name: "maxDeposit", params: [
|
|
90884
|
+
{ address: entry2.address, name: "maxDeposit", params: [NEUTRAL_PROBE7] },
|
|
89714
90885
|
{ address: entry2.address, name: "paused", params: [] },
|
|
89715
90886
|
...entryPoint ? [
|
|
89716
90887
|
{
|
|
@@ -90149,7 +91320,7 @@ var readerAccountableVault = (entry2) => {
|
|
|
90149
91320
|
};
|
|
90150
91321
|
|
|
90151
91322
|
// src/vaults/savings/readers/alchemixTransmuter.ts
|
|
90152
|
-
var
|
|
91323
|
+
var SECONDS_PER_YEAR24 = 31536e3;
|
|
90153
91324
|
var UNCAPPED_FLOOR = 2n ** 200n;
|
|
90154
91325
|
var pow10 = (n) => 10n ** BigInt(n);
|
|
90155
91326
|
var readerAlchemixTransmuter = (entry2) => {
|
|
@@ -90225,7 +91396,7 @@ var readerAlchemixTransmuter = (entry2) => {
|
|
|
90225
91396
|
const price1e18 = out !== void 0 && out > 0n ? out * ONE_E1823 * pow10(18 - cfg.underlyingDecimals) / q.unit : void 0;
|
|
90226
91397
|
const marketDiscountBps = price1e18 !== void 0 ? Number((price1e18 - ONE_E1823) * 100000n / ONE_E1823) / 10 : void 0;
|
|
90227
91398
|
const tf = transmutationFee !== void 0 ? Number(transmutationFee) / 1e4 : 0;
|
|
90228
|
-
const supplyRate = price1e18 !== void 0 && termSeconds > 0 ? ((1 - tf) / (Number(price1e18) / 1e18) - 1) * (
|
|
91399
|
+
const supplyRate = price1e18 !== void 0 && termSeconds > 0 ? ((1 - tf) / (Number(price1e18) / 1e18) - 1) * (SECONDS_PER_YEAR24 / termSeconds) * 100 : void 0;
|
|
90229
91400
|
const exitFeeBps = exitFee !== void 0 ? Number(exitFee) : void 0;
|
|
90230
91401
|
const exitRoutes = [
|
|
90231
91402
|
{
|
|
@@ -90270,7 +91441,7 @@ var readerAlchemixTransmuter = (entry2) => {
|
|
|
90270
91441
|
};
|
|
90271
91442
|
|
|
90272
91443
|
// src/vaults/savings/readers/gapSweep.ts
|
|
90273
|
-
var
|
|
91444
|
+
var NEUTRAL_PROBE8 = "0x000000000000000000000000000000000000dead";
|
|
90274
91445
|
var MAX_UINT256 = 2n ** 256n - 1n;
|
|
90275
91446
|
var readerUsdaiStaked = (entry2) => {
|
|
90276
91447
|
const a = entry2.address;
|
|
@@ -90320,7 +91491,7 @@ var readerYuzuIlp = (entry2) => {
|
|
|
90320
91491
|
{ address: entry2.address, name: "totalAssets", params: [] },
|
|
90321
91492
|
{ address: entry2.address, name: "totalSupply", params: [] },
|
|
90322
91493
|
{ address: entry2.address, name: "convertToAssets", params: [shareUnit] },
|
|
90323
|
-
{ address: entry2.address, name: "maxDeposit", params: [
|
|
91494
|
+
{ address: entry2.address, name: "maxDeposit", params: [NEUTRAL_PROBE8] },
|
|
90324
91495
|
{ address: entry2.address, name: "paused", params: [] }
|
|
90325
91496
|
],
|
|
90326
91497
|
abis: [
|
|
@@ -90435,6 +91606,8 @@ var buildReader2 = (entry2) => {
|
|
|
90435
91606
|
return readerSuperformVault(entry2);
|
|
90436
91607
|
case "ipor-fusion":
|
|
90437
91608
|
return readerIporFusion(entry2);
|
|
91609
|
+
case "mezzanine-tranche":
|
|
91610
|
+
return readerMezzanine(entry2);
|
|
90438
91611
|
case "ember-vault":
|
|
90439
91612
|
return readerEmberVault(entry2);
|
|
90440
91613
|
case "mellow-core":
|
|
@@ -90832,7 +92005,7 @@ var fetchSavingsVaults = async (chainId, multicallRetry, prices = {}, tokenList
|
|
|
90832
92005
|
// Only the NAV-oracle reader's entries publish their share price from a
|
|
90833
92006
|
// feed; on every other entry `priceOracle` is unset, so this stays absent
|
|
90834
92007
|
// rather than pointing at an unrelated contract.
|
|
90835
|
-
navOracle: entry2.reader === "nav-oracle" || entry2.reader === "inverter-oracle" ? entry2.priceOracle?.toLowerCase() : void 0,
|
|
92008
|
+
navOracle: entry2.reader === "nav-oracle" || entry2.reader === "inverter-oracle" || entry2.reader === "mezzanine-tranche" ? entry2.priceOracle?.toLowerCase() : void 0,
|
|
90836
92009
|
asset,
|
|
90837
92010
|
priceUsd,
|
|
90838
92011
|
totalAssetsFormatted,
|
|
@@ -92685,6 +93858,10 @@ var VOLATILE_VAULT_OVERRIDES = /* @__PURE__ */ new Set([
|
|
|
92685
93858
|
// StockMarketTRBasisTrade
|
|
92686
93859
|
"1-0x99351baed3d8ab544ccb08af96a105910fda71e7",
|
|
92687
93860
|
// aFXArbUSDTRY
|
|
93861
|
+
// Mezzanine's junior tranche: first loss on a levered loop, and paid a rate
|
|
93862
|
+
// that one NAV report can triple. Pinned in `mezzanine.test.ts`.
|
|
93863
|
+
"1-0x6f5d94dc0c8bbf052abf024259d087da45ad96a1",
|
|
93864
|
+
// mjHastra
|
|
92688
93865
|
// IPOR Fusion loops and carries — the share price is collateral at an
|
|
92689
93866
|
// oracle mark minus debt, levered 5–9× on the loops, and on the carries the
|
|
92690
93867
|
// debt sits in a different currency than the vault (dollars against ETH or
|
|
@@ -94723,6 +95900,281 @@ function buildVaultLookup(data) {
|
|
|
94723
95900
|
return map;
|
|
94724
95901
|
}
|
|
94725
95902
|
|
|
95903
|
+
// src/terms/choices.ts
|
|
95904
|
+
function buildPositionChoices(b) {
|
|
95905
|
+
const out = [
|
|
95906
|
+
modeChoice(b),
|
|
95907
|
+
termChoice(b),
|
|
95908
|
+
parameterChoice(b),
|
|
95909
|
+
rateChoice(b)
|
|
95910
|
+
].filter((c) => c != null);
|
|
95911
|
+
return out.length ? out : void 0;
|
|
95912
|
+
}
|
|
95913
|
+
var STANCES = ["cheapest", "balanced", "protected"];
|
|
95914
|
+
var num15 = (v) => typeof v === "number" && Number.isFinite(v) ? v : void 0;
|
|
95915
|
+
function rateChoice(b) {
|
|
95916
|
+
const us = b.rate.userSet;
|
|
95917
|
+
if (!us?.required || us.min == null || us.max == null) return void 0;
|
|
95918
|
+
const presets = (us.picks ?? []).map((p) => ({
|
|
95919
|
+
id: p.id,
|
|
95920
|
+
value: p.apr,
|
|
95921
|
+
effects: rateEffectsAfterFill(p)
|
|
95922
|
+
}));
|
|
95923
|
+
const fills = presets.some((p) => p.effects.capacity != null);
|
|
95924
|
+
return {
|
|
95925
|
+
id: "rate",
|
|
95926
|
+
kind: "interest-rate",
|
|
95927
|
+
param: { name: "interestRate", encoding: "wad-fraction" },
|
|
95928
|
+
unit: "percent-apr",
|
|
95929
|
+
domain: { min: us.min, max: us.max, step: 0.01 },
|
|
95930
|
+
...us.default != null ? { default: us.default } : {},
|
|
95931
|
+
moves: fills ? ["cost", "capacity", "protection"] : ["cost", "protection"],
|
|
95932
|
+
...presets.length ? { presets } : {},
|
|
95933
|
+
...us.recommended ? { recommended: us.recommended } : {},
|
|
95934
|
+
ladder: { pricing: "queue" },
|
|
95935
|
+
lock: {
|
|
95936
|
+
adjustable: us.adjustable,
|
|
95937
|
+
...us.adjustmentCooldownSecs ? { cooldownSecs: us.adjustmentCooldownSecs } : {},
|
|
95938
|
+
cost: us.adjustable ? "upfront-fee-again" : "close-and-reopen"
|
|
95939
|
+
},
|
|
95940
|
+
...us.pressure ? { pressure: us.pressure } : {},
|
|
95941
|
+
// where the rate decides the fill, the picks move with the size
|
|
95942
|
+
...fills ? { dependsOn: ["size"] } : {}
|
|
95943
|
+
};
|
|
95944
|
+
}
|
|
95945
|
+
function parameterChoice(b) {
|
|
95946
|
+
const liq = b.liquidation;
|
|
95947
|
+
const op = liq.openParameter;
|
|
95948
|
+
if (!op || op.dimension !== "collateralFactor") return void 0;
|
|
95949
|
+
const range2 = "min" in op.domain ? op.domain : void 0;
|
|
95950
|
+
const lock = {
|
|
95951
|
+
adjustable: !op.immutableAfterOpen,
|
|
95952
|
+
...op.adjustCooldownSeconds ? { cooldownSecs: op.adjustCooldownSeconds } : {},
|
|
95953
|
+
cost: op.immutableAfterOpen ? "close-and-reopen" : "none"
|
|
95954
|
+
};
|
|
95955
|
+
if (op.kind === "llamalend-bands") {
|
|
95956
|
+
const curve = liq.bandLtv ?? {};
|
|
95957
|
+
const lo = range2?.min ?? 4;
|
|
95958
|
+
const hi = range2?.max ?? 50;
|
|
95959
|
+
return {
|
|
95960
|
+
id: "bands",
|
|
95961
|
+
kind: "llamalend-bands",
|
|
95962
|
+
param: { name: "bands", encoding: "integer" },
|
|
95963
|
+
unit: "count",
|
|
95964
|
+
domain: { min: lo, max: hi, step: 1 },
|
|
95965
|
+
default: op.default,
|
|
95966
|
+
moves: ["capacity", "protection"],
|
|
95967
|
+
presets: bandPresets(liq, op.default, lo, hi),
|
|
95968
|
+
recommended: "balanced",
|
|
95969
|
+
// without the curve there is nothing to draw a ladder from
|
|
95970
|
+
...Object.keys(curve).length ? { ladder: { pricing: "parameter" } } : {},
|
|
95971
|
+
lock
|
|
95972
|
+
};
|
|
95973
|
+
}
|
|
95974
|
+
if (!range2) return void 0;
|
|
95975
|
+
const mid = Math.round((range2.min + range2.max) / 2 * 1e4) / 1e4;
|
|
95976
|
+
const values = {
|
|
95977
|
+
cheapest: range2.max,
|
|
95978
|
+
balanced: mid,
|
|
95979
|
+
protected: range2.min
|
|
95980
|
+
};
|
|
95981
|
+
return {
|
|
95982
|
+
id: "liqLtv",
|
|
95983
|
+
kind: op.kind,
|
|
95984
|
+
param: { name: "liqLtv", encoding: "fraction" },
|
|
95985
|
+
unit: "percent-ltv",
|
|
95986
|
+
domain: { min: range2.min * 100, max: range2.max * 100, step: 0.01 },
|
|
95987
|
+
default: op.default * 100,
|
|
95988
|
+
moves: ["capacity", "protection"],
|
|
95989
|
+
presets: STANCES.map((id) => ({
|
|
95990
|
+
id,
|
|
95991
|
+
value: values[id] * 100,
|
|
95992
|
+
effects: { maxLtv: values[id] }
|
|
95993
|
+
})),
|
|
95994
|
+
lock
|
|
95995
|
+
};
|
|
95996
|
+
}
|
|
95997
|
+
function termChoice(b) {
|
|
95998
|
+
const menu = b.rate.menu;
|
|
95999
|
+
if (!menu || menu.length < 2) return void 0;
|
|
96000
|
+
const options = menu.map((m) => ({
|
|
96001
|
+
value: m.termId,
|
|
96002
|
+
label: `${Math.round(m.durationDays)} d`,
|
|
96003
|
+
effects: {
|
|
96004
|
+
aprPct: m.apr,
|
|
96005
|
+
...m.available != null ? { capacity: m.available } : {}
|
|
96006
|
+
}
|
|
96007
|
+
}));
|
|
96008
|
+
return {
|
|
96009
|
+
id: "term",
|
|
96010
|
+
kind: "term",
|
|
96011
|
+
param: { name: "termId", encoding: "id" },
|
|
96012
|
+
unit: "id",
|
|
96013
|
+
domain: { values: options.map((o) => o.value) },
|
|
96014
|
+
moves: options.some((o) => o.effects.capacity != null) ? ["cost", "capacity"] : ["cost"],
|
|
96015
|
+
options,
|
|
96016
|
+
lock: { adjustable: false, cost: "close-and-reopen" }
|
|
96017
|
+
};
|
|
96018
|
+
}
|
|
96019
|
+
function modeChoice(b) {
|
|
96020
|
+
const modes = (b.modes ?? []).filter(
|
|
96021
|
+
(m) => m.entry == null || m.entry === "user-selected"
|
|
96022
|
+
);
|
|
96023
|
+
if (modes.length < 2) return void 0;
|
|
96024
|
+
const options = modes.map((m) => {
|
|
96025
|
+
const maxLtv = num15(m.liquidation?.ltv);
|
|
96026
|
+
return {
|
|
96027
|
+
value: m.modeId,
|
|
96028
|
+
...m.label ? { label: m.label } : {},
|
|
96029
|
+
effects: maxLtv != null ? { maxLtv } : {}
|
|
96030
|
+
};
|
|
96031
|
+
});
|
|
96032
|
+
const def = modes.find((m) => m.isDefault)?.modeId;
|
|
96033
|
+
return {
|
|
96034
|
+
id: "mode",
|
|
96035
|
+
kind: "e-mode",
|
|
96036
|
+
param: { name: "modeId", encoding: "id" },
|
|
96037
|
+
unit: "id",
|
|
96038
|
+
domain: { values: options.map((o) => o.value) },
|
|
96039
|
+
...def != null ? { default: def } : {},
|
|
96040
|
+
moves: ["capacity"],
|
|
96041
|
+
options,
|
|
96042
|
+
lock: { adjustable: true, cost: "none" }
|
|
96043
|
+
};
|
|
96044
|
+
}
|
|
96045
|
+
var bandEffects = (liq, n) => {
|
|
96046
|
+
const maxLtv = num15(liq.bandLtv?.[String(n)]);
|
|
96047
|
+
const a = num15(liq.ammA);
|
|
96048
|
+
return {
|
|
96049
|
+
...maxLtv != null ? { maxLtv } : {},
|
|
96050
|
+
...a != null && a > 1 ? { rangeWidth: 1 - ((a - 1) / a) ** n } : {}
|
|
96051
|
+
};
|
|
96052
|
+
};
|
|
96053
|
+
function bandsForStance(curve, def, stance, ltv, lo = 4, hi = 50) {
|
|
96054
|
+
const fits = (n) => {
|
|
96055
|
+
if (ltv == null || !curve || !Object.keys(curve).length) return true;
|
|
96056
|
+
const max = num15(curve[String(n)]);
|
|
96057
|
+
return max != null && max >= ltv;
|
|
96058
|
+
};
|
|
96059
|
+
const domain = [];
|
|
96060
|
+
for (let n = lo; n <= hi; n++) if (fits(n)) domain.push(n);
|
|
96061
|
+
if (!domain.length) return lo;
|
|
96062
|
+
if (stance === "cheapest") return domain[0];
|
|
96063
|
+
if (stance === "protected") return domain[domain.length - 1];
|
|
96064
|
+
return domain.includes(def) ? def : domain[domain.length - 1];
|
|
96065
|
+
}
|
|
96066
|
+
function bandPresets(liq, def, lo, hi, ltv) {
|
|
96067
|
+
return STANCES.map((id) => {
|
|
96068
|
+
const n = bandsForStance(liq.bandLtv, def, id, ltv, lo, hi);
|
|
96069
|
+
return { id, value: n, effects: bandEffects(liq, n) };
|
|
96070
|
+
});
|
|
96071
|
+
}
|
|
96072
|
+
function parameterLadder(b) {
|
|
96073
|
+
const liq = b.liquidation;
|
|
96074
|
+
return Object.entries(liq.bandLtv ?? {}).map(([k, maxLtv]) => {
|
|
96075
|
+
const value = Number(k);
|
|
96076
|
+
return { value, maxLtv, ...bandEffects(liq, value) };
|
|
96077
|
+
}).sort((x, y) => x.value - y.value);
|
|
96078
|
+
}
|
|
96079
|
+
var rateEffects = (q, apr) => {
|
|
96080
|
+
const total = q.totalDebt;
|
|
96081
|
+
const assets = debtAheadOf(q.levels, apr);
|
|
96082
|
+
return {
|
|
96083
|
+
aprPct: apr,
|
|
96084
|
+
...q.picks[0] ? { upfrontFeePct: q.picks[0].upfrontFeePct } : {},
|
|
96085
|
+
ahead: { assets, share: total > 0 ? assets / total : 0 },
|
|
96086
|
+
...q.fill ? { capacity: fillCapacityAt(q.levels, q.fill.idle, apr) } : {}
|
|
96087
|
+
};
|
|
96088
|
+
};
|
|
96089
|
+
function resolveChoices(b, req, queue) {
|
|
96090
|
+
const size = Math.max(0, req.size ?? 0);
|
|
96091
|
+
const choices = (buildPositionChoices(b) ?? []).map((c) => ({ ...c }));
|
|
96092
|
+
const selected = {};
|
|
96093
|
+
const warnings = [];
|
|
96094
|
+
const outcome = {};
|
|
96095
|
+
for (const c of choices) {
|
|
96096
|
+
if (c.id === "rate" && queue) {
|
|
96097
|
+
const picks = resolveRatePicks(queue, size);
|
|
96098
|
+
const presets = picks.map((p) => ({
|
|
96099
|
+
id: p.id,
|
|
96100
|
+
value: p.apr,
|
|
96101
|
+
effects: rateEffectsAfterFill(p)
|
|
96102
|
+
}));
|
|
96103
|
+
c.presets = presets.length ? presets : void 0;
|
|
96104
|
+
if (queue.recommended) c.recommended = queue.recommended;
|
|
96105
|
+
c.pressure = queue.pressure;
|
|
96106
|
+
}
|
|
96107
|
+
if (c.id === "bands" && req.ltv != null && "min" in c.domain)
|
|
96108
|
+
c.presets = bandPresets(
|
|
96109
|
+
b.liquidation,
|
|
96110
|
+
Number(c.default),
|
|
96111
|
+
c.domain.min,
|
|
96112
|
+
c.domain.max,
|
|
96113
|
+
req.ltv
|
|
96114
|
+
);
|
|
96115
|
+
const value = req.selected?.[c.id] ?? (req.stance ? resolveStance(c, req.stance) : void 0) ?? c.presets?.find((p) => p.id === c.recommended)?.value ?? c.default;
|
|
96116
|
+
if (value == null) continue;
|
|
96117
|
+
selected[c.id] = value;
|
|
96118
|
+
const effects = c.id === "rate" && queue ? rateEffects(queue, Number(value)) : c.id === "bands" ? bandEffects(b.liquidation, Number(value)) : [...c.presets ?? [], ...c.options ?? []].find(
|
|
96119
|
+
(o) => o.value === value
|
|
96120
|
+
)?.effects ?? {};
|
|
96121
|
+
if (effects.aprPct != null) outcome.aprPct = effects.aprPct;
|
|
96122
|
+
if (effects.upfrontFeePct != null)
|
|
96123
|
+
outcome.upfrontFeePct = effects.upfrontFeePct;
|
|
96124
|
+
if (effects.ahead) outcome.ahead = effects.ahead;
|
|
96125
|
+
if (effects.rangeWidth != null) outcome.rangeWidth = effects.rangeWidth;
|
|
96126
|
+
if (effects.maxLtv != null)
|
|
96127
|
+
outcome.maxLtv = Math.min(outcome.maxLtv ?? 1, effects.maxLtv);
|
|
96128
|
+
if (effects.capacity != null)
|
|
96129
|
+
outcome.capacity = Math.min(
|
|
96130
|
+
outcome.capacity ?? Infinity,
|
|
96131
|
+
effects.capacity
|
|
96132
|
+
);
|
|
96133
|
+
if (effects.capacity != null && size > effects.capacity * (1 + 1e-9))
|
|
96134
|
+
warnings.push({ code: "EXCEEDS_CAPACITY", blocking: true, choice: c.id });
|
|
96135
|
+
if (req.ltv != null && effects.maxLtv != null && req.ltv > effects.maxLtv + 1e-9)
|
|
96136
|
+
warnings.push({ code: "LTV_ABOVE_MAX", blocking: true, choice: c.id });
|
|
96137
|
+
if (c.id === "rate" && effects.ahead?.assets === 0 && queue?.totalDebt)
|
|
96138
|
+
warnings.push({ code: "NOTHING_AHEAD", blocking: false, choice: c.id });
|
|
96139
|
+
}
|
|
96140
|
+
return { choices, selected, outcome, warnings };
|
|
96141
|
+
}
|
|
96142
|
+
var rateEffectsAfterFill = (p) => ({
|
|
96143
|
+
aprPct: p.apr,
|
|
96144
|
+
upfrontFeePct: p.upfrontFeePct,
|
|
96145
|
+
ahead: { assets: p.debtAhead, share: p.share },
|
|
96146
|
+
...p.capacity != null ? { capacity: p.capacity } : {}
|
|
96147
|
+
});
|
|
96148
|
+
function resolveStance(c, stance) {
|
|
96149
|
+
const want = STANCES.indexOf(stance);
|
|
96150
|
+
for (let i = want; i >= 0; i--) {
|
|
96151
|
+
const p = c.presets?.find((x) => x.id === STANCES[i]);
|
|
96152
|
+
if (p) return p.value;
|
|
96153
|
+
}
|
|
96154
|
+
return c.presets?.[0]?.value ?? c.default;
|
|
96155
|
+
}
|
|
96156
|
+
function encodeChoiceValue(c, value) {
|
|
96157
|
+
switch (c.param.encoding) {
|
|
96158
|
+
case "wad-fraction":
|
|
96159
|
+
return (BigInt(Math.round(Number(value) * 1e6)) * 10n ** 10n).toString();
|
|
96160
|
+
case "fraction":
|
|
96161
|
+
return String(Number(value) / 100);
|
|
96162
|
+
default:
|
|
96163
|
+
return String(value);
|
|
96164
|
+
}
|
|
96165
|
+
}
|
|
96166
|
+
function digestChoices(choices) {
|
|
96167
|
+
if (!choices?.length) return void 0;
|
|
96168
|
+
return choices.map((c) => ({
|
|
96169
|
+
id: c.id,
|
|
96170
|
+
param: c.param,
|
|
96171
|
+
unit: c.unit,
|
|
96172
|
+
...c.default != null ? { default: c.default } : {},
|
|
96173
|
+
...c.recommended ? { recommended: c.recommended } : {},
|
|
96174
|
+
...c.presets?.length ? { presets: c.presets.map((p) => ({ id: p.id, value: p.value })) } : {}
|
|
96175
|
+
}));
|
|
96176
|
+
}
|
|
96177
|
+
|
|
94726
96178
|
// src/terms/tags.ts
|
|
94727
96179
|
var push = (set, ...tags) => {
|
|
94728
96180
|
for (const t of tags) set.add(t);
|
|
@@ -96354,7 +97806,8 @@ function rewardTerms(input, side2) {
|
|
|
96354
97806
|
return out.length ? out : void 0;
|
|
96355
97807
|
}
|
|
96356
97808
|
function buildRate(input, side2) {
|
|
96357
|
-
const
|
|
97809
|
+
const rowKind = rateKindOf(input);
|
|
97810
|
+
const kind = side2 === "supply" && rowKind === "user-set" ? "variable-curve" : rowKind;
|
|
96358
97811
|
const rewards = rewardTerms(input, side2);
|
|
96359
97812
|
const priceableRewards = (rewards ?? []).filter((r) => !r.indicative).reduce((s, r) => s + r.apr, 0);
|
|
96360
97813
|
const menuBest = input.terms?.length ? Math.min(...input.terms.map((t) => t.apr)) : void 0;
|
|
@@ -96531,7 +97984,8 @@ function buildAvailability(input, side2) {
|
|
|
96531
97984
|
const total = side2 === "supply" ? input.totalDeposits : input.totalDebt;
|
|
96532
97985
|
const capUtilization = capUtil(total, cap);
|
|
96533
97986
|
const capFull = capUtilization != null && capUtilization >= 1;
|
|
96534
|
-
const
|
|
97987
|
+
const queuePicks = input.market?.flex?.queue?.picks;
|
|
97988
|
+
const noLiquidity = side2 === "borrow" && isNum(input.borrowLiquidity) && input.borrowLiquidity <= 0 && !queuePicks?.some((p) => (p.capacity ?? 0) > 0);
|
|
96535
97989
|
const canOpen = enabled && !frozen && !inactive && !capFull && !noLiquidity;
|
|
96536
97990
|
let blockedBy;
|
|
96537
97991
|
if (!canOpen) {
|
|
@@ -96811,6 +98265,9 @@ function finalizeInfo(sheet) {
|
|
|
96811
98265
|
implications: sheet.borrow.info.implications,
|
|
96812
98266
|
tags: deriveBorrowTags(sheet.borrow, market)
|
|
96813
98267
|
};
|
|
98268
|
+
const choices = buildPositionChoices(sheet.borrow);
|
|
98269
|
+
if (choices) sheet.borrow.choices = choices;
|
|
98270
|
+
else delete sheet.borrow.choices;
|
|
96814
98271
|
}
|
|
96815
98272
|
return sheet;
|
|
96816
98273
|
}
|
|
@@ -98294,7 +99751,7 @@ function resolveEarnIdentity(venue, brand, publishedProtocol) {
|
|
|
98294
99751
|
}
|
|
98295
99752
|
return { protocol: { key: key5, name: protocolName }, curator: { name } };
|
|
98296
99753
|
}
|
|
98297
|
-
function
|
|
99754
|
+
function num16(v) {
|
|
98298
99755
|
if (v == null || v === "") return void 0;
|
|
98299
99756
|
const n = typeof v === "number" ? v : Number(v);
|
|
98300
99757
|
return Number.isFinite(n) ? n : void 0;
|
|
@@ -98394,8 +99851,8 @@ function resolveExitMode2(provider, meta, tvl, liq) {
|
|
|
98394
99851
|
if (declared) return declared;
|
|
98395
99852
|
const fallback = vaultTraits(provider)?.defaultExitMode ?? "instant";
|
|
98396
99853
|
if (fallback !== "instant-capped") return fallback;
|
|
98397
|
-
const total =
|
|
98398
|
-
const available =
|
|
99854
|
+
const total = num16(tvl?.totalAssetsFormatted) ?? num16(tvl?.totalAssetsUsd);
|
|
99855
|
+
const available = num16(liq?.liquidityFormatted) ?? num16(liq?.liquidityUsd);
|
|
98399
99856
|
if (total === void 0 || available === void 0) return "instant-capped";
|
|
98400
99857
|
if (total <= 0) return "instant";
|
|
98401
99858
|
return available >= total ? "instant" : "instant-capped";
|
|
@@ -98433,8 +99890,8 @@ function earnMarketFromVault(row, chainId, opts = {}) {
|
|
|
98433
99890
|
const rates = row.rates ?? {};
|
|
98434
99891
|
const tvl = row.tvl ?? {};
|
|
98435
99892
|
const liq = row.liquidity ?? {};
|
|
98436
|
-
const shareDecimals =
|
|
98437
|
-
const assetDecimals =
|
|
99893
|
+
const shareDecimals = num16(row.decimals) ?? 18;
|
|
99894
|
+
const assetDecimals = num16(row.assetDecimals) ?? num16(row.underlyingInfo?.asset?.decimals) ?? shareDecimals;
|
|
98438
99895
|
const rateUnavailable = isRateSourceUnavailable(str6(meta.rateSource));
|
|
98439
99896
|
const toPercent2 = (v) => rateUnavailable ? void 0 : ratePercent(v, provider, opts.fractionRateProviders);
|
|
98440
99897
|
const rewards = toPercent2(rates.rewardsRate);
|
|
@@ -98524,7 +99981,7 @@ function earnMarketFromVault(row, chainId, opts = {}) {
|
|
|
98524
99981
|
symbol: str6(row.underlyingInfo?.asset?.symbol) ?? "",
|
|
98525
99982
|
decimals: assetDecimals,
|
|
98526
99983
|
assetGroup: str6(info.assetGroup),
|
|
98527
|
-
priceUsd:
|
|
99984
|
+
priceUsd: num16(row.underlyingInfo?.prices?.priceUsd)
|
|
98528
99985
|
},
|
|
98529
99986
|
// The vault IS a share token by construction; carry it so a withdraw in
|
|
98530
99987
|
// share units can be built without a second lookup.
|
|
@@ -98554,8 +100011,8 @@ function earnMarketFromVault(row, chainId, opts = {}) {
|
|
|
98554
100011
|
exit: {
|
|
98555
100012
|
mode: exitMode,
|
|
98556
100013
|
settlement: str6(meta.redemptionType),
|
|
98557
|
-
cooldownSecs:
|
|
98558
|
-
feeBps:
|
|
100014
|
+
cooldownSecs: num16(meta.withdrawalCooldownSeconds),
|
|
100015
|
+
feeBps: num16(meta.withdrawFeeBps),
|
|
98559
100016
|
// Passed through, never re-derived: the earn row and the vault row must
|
|
98560
100017
|
// not disagree about what the legs out are.
|
|
98561
100018
|
routes: Array.isArray(meta.exitRoutes) ? meta.exitRoutes : void 0
|
|
@@ -98568,12 +100025,12 @@ function earnMarketFromVault(row, chainId, opts = {}) {
|
|
|
98568
100025
|
// since the surface was written and never populated — a tranche's
|
|
98569
100026
|
// first-loss position is the term most worth surfacing on a rate list.
|
|
98570
100027
|
counterparty: str6(meta.solvency),
|
|
98571
|
-
score:
|
|
100028
|
+
score: num16(row.rating?.score),
|
|
98572
100029
|
label: str6(row.rating?.level),
|
|
98573
100030
|
illiquid: isIlliquid({
|
|
98574
100031
|
exitMode,
|
|
98575
|
-
tvlUsd:
|
|
98576
|
-
liquidityUsd:
|
|
100032
|
+
tvlUsd: num16(tvl.totalAssetsUsd),
|
|
100033
|
+
liquidityUsd: num16(liq.liquidityUsd)
|
|
98577
100034
|
})
|
|
98578
100035
|
},
|
|
98579
100036
|
// Filled by `capabilities.ts` — kept required on the type so a normalizer
|
|
@@ -98585,7 +100042,7 @@ function earnMarketFromVault(row, chainId, opts = {}) {
|
|
|
98585
100042
|
return market;
|
|
98586
100043
|
}
|
|
98587
100044
|
function ratePercent(value, provider, fractionProviders = FRACTION_RATE_PROVIDERS) {
|
|
98588
|
-
const n =
|
|
100045
|
+
const n = num16(value);
|
|
98589
100046
|
if (n === void 0) return void 0;
|
|
98590
100047
|
return fractionProviders.has(provider) ? n * 100 : n;
|
|
98591
100048
|
}
|
|
@@ -98594,7 +100051,7 @@ function implausibleRatePercent(percent) {
|
|
|
98594
100051
|
}
|
|
98595
100052
|
function resolveRateKind(provider, meta) {
|
|
98596
100053
|
if (meta.navOracle || meta.solvency === "nav-attested") return "nav-accrual";
|
|
98597
|
-
if (meta.rateBasis === "entry-discount" && ((
|
|
100054
|
+
if (meta.rateBasis === "entry-discount" && ((num16(meta.termSeconds) ?? 0) > 0 || (num16(meta.expiry) ?? 0) > 0))
|
|
98598
100055
|
return "fixed-term";
|
|
98599
100056
|
return RATE_KIND[provider] ?? "variable-managed";
|
|
98600
100057
|
}
|
|
@@ -98647,9 +100104,9 @@ function vaultDisplayName(row, info) {
|
|
|
98647
100104
|
return str6(row.name) ?? str6(info.name) ?? str6(row.displayName) ?? str6(share?.name) ?? str6(share?.symbol) ?? str6(info.symbol) ?? str6(row.symbol);
|
|
98648
100105
|
}
|
|
98649
100106
|
function resolveMaturity(meta) {
|
|
98650
|
-
const expiry =
|
|
100107
|
+
const expiry = num16(meta.expiry) ?? num16(meta.maturity);
|
|
98651
100108
|
if (expiry === void 0 || expiry <= 0) {
|
|
98652
|
-
const term =
|
|
100109
|
+
const term = num16(meta.termSeconds);
|
|
98653
100110
|
if (term !== void 0 && term > 0)
|
|
98654
100111
|
return {
|
|
98655
100112
|
kind: "rolling-duration",
|
|
@@ -98697,8 +100154,8 @@ function amount3(raw, formatted, usd, decimals) {
|
|
|
98697
100154
|
const rawStr = raw != null ? String(raw) : void 0;
|
|
98698
100155
|
return {
|
|
98699
100156
|
raw: rawStr,
|
|
98700
|
-
formatted:
|
|
98701
|
-
usd:
|
|
100157
|
+
formatted: num16(formatted) ?? formatRaw(rawStr, decimals),
|
|
100158
|
+
usd: num16(usd)
|
|
98702
100159
|
};
|
|
98703
100160
|
}
|
|
98704
100161
|
function withCuratorEntity(id, entity) {
|
|
@@ -98745,7 +100202,7 @@ function managedVaultCuration(provider, chainId, address) {
|
|
|
98745
100202
|
}
|
|
98746
100203
|
|
|
98747
100204
|
// src/terms/vault/input.ts
|
|
98748
|
-
var
|
|
100205
|
+
var num17 = (v) => {
|
|
98749
100206
|
if (typeof v === "number") return Number.isFinite(v) ? v : void 0;
|
|
98750
100207
|
if (typeof v === "string" && v.trim() !== "") {
|
|
98751
100208
|
const n = Number(v);
|
|
@@ -98776,13 +100233,13 @@ var fromRaw = (raw, decimals) => {
|
|
|
98776
100233
|
function sdkRates(row, provider) {
|
|
98777
100234
|
if (!SDK_FRACTION_RATE_PROVIDERS.has(provider)) {
|
|
98778
100235
|
return {
|
|
98779
|
-
supplyRate:
|
|
98780
|
-
rewardsRate:
|
|
98781
|
-
totalRate:
|
|
100236
|
+
supplyRate: num17(row.supplyRate),
|
|
100237
|
+
rewardsRate: num17(row.rewardsRate),
|
|
100238
|
+
totalRate: num17(row.depositRate)
|
|
98782
100239
|
};
|
|
98783
100240
|
}
|
|
98784
100241
|
const pct5 = (v) => {
|
|
98785
|
-
const n =
|
|
100242
|
+
const n = num17(v);
|
|
98786
100243
|
return n === void 0 ? void 0 : n * 100;
|
|
98787
100244
|
};
|
|
98788
100245
|
return {
|
|
@@ -98796,7 +100253,7 @@ function toVaultTermInput(vault, provider, chainId) {
|
|
|
98796
100253
|
const row = vault;
|
|
98797
100254
|
const address = str7(row.address)?.toLowerCase();
|
|
98798
100255
|
if (!address) return void 0;
|
|
98799
|
-
const assetDecimals =
|
|
100256
|
+
const assetDecimals = num17(row.assetDecimals) ?? num17(row.decimals);
|
|
98800
100257
|
const asset = row.asset;
|
|
98801
100258
|
return {
|
|
98802
100259
|
provider,
|
|
@@ -98822,25 +100279,25 @@ function toVaultTermInput(vault, provider, chainId) {
|
|
|
98822
100279
|
// GMX / HyperCore / Pendle report USD only and set the token-denominated
|
|
98823
100280
|
// fields to their USD figure — `totalAssetsFormatted` is the cross-provider
|
|
98824
100281
|
// magnitude either way, so prefer it over re-deriving from raw.
|
|
98825
|
-
totalAssets:
|
|
98826
|
-
totalAssetsUsd:
|
|
98827
|
-
liquidity:
|
|
98828
|
-
liquidityUsd:
|
|
98829
|
-
instantLiquidityRatio:
|
|
100282
|
+
totalAssets: num17(row.totalAssetsFormatted) ?? fromRaw(row.totalAssets, assetDecimals),
|
|
100283
|
+
totalAssetsUsd: num17(row.totalAssetsUsd) ?? num17(row.tvlUsd),
|
|
100284
|
+
liquidity: num17(row.liquidityFormatted) ?? fromRaw(row.liquidity, assetDecimals),
|
|
100285
|
+
liquidityUsd: num17(row.liquidityUsd),
|
|
100286
|
+
instantLiquidityRatio: num17(row.instantLiquidityRatio),
|
|
98830
100287
|
totalBorrowed: fromRaw(row.totalBorrowed, assetDecimals),
|
|
98831
100288
|
expectedLiquidity: fromRaw(row.expectedLiquidity, assetDecimals),
|
|
98832
100289
|
withdrawalMode: str7(row.withdrawalMode),
|
|
98833
|
-
withdrawalCooldownSeconds:
|
|
98834
|
-
withdrawFeeBps:
|
|
98835
|
-
depositFeeBps:
|
|
100290
|
+
withdrawalCooldownSeconds: num17(row.withdrawalCooldownSeconds),
|
|
100291
|
+
withdrawFeeBps: num17(row.withdrawFeeBps),
|
|
100292
|
+
depositFeeBps: num17(row.depositFeeBps),
|
|
98836
100293
|
feeScheduleComplete: bool5(row.feeScheduleComplete),
|
|
98837
100294
|
exitRoutes: routes(row.exitRoutes),
|
|
98838
|
-
fee:
|
|
98839
|
-
managementFee:
|
|
98840
|
-
swapFeeRate:
|
|
98841
|
-
redemptionDiscountBps:
|
|
100295
|
+
fee: num17(row.fee),
|
|
100296
|
+
managementFee: num17(row.managementFee),
|
|
100297
|
+
swapFeeRate: num17(row.feeRate),
|
|
100298
|
+
redemptionDiscountBps: num17(row.redemptionDiscountBps),
|
|
98842
100299
|
instantRedeemEnabled: bool5(row.instantRedeemEnabled),
|
|
98843
|
-
yieldWarmupSeconds:
|
|
100300
|
+
yieldWarmupSeconds: num17(row.yieldWarmupSeconds),
|
|
98844
100301
|
accrual: str7(row.accrual),
|
|
98845
100302
|
needsDepositApproval: bool5(row.needsDepositApproval),
|
|
98846
100303
|
isMintable: bool5(row.isMintable),
|
|
@@ -98851,10 +100308,10 @@ function toVaultTermInput(vault, provider, chainId) {
|
|
|
98851
100308
|
withdrawalsPaused: bool5(row.isWithdrawalPaused),
|
|
98852
100309
|
isClosed: bool5(row.isClosed),
|
|
98853
100310
|
whitelisted: bool5(row.whitelisted),
|
|
98854
|
-
expiry:
|
|
98855
|
-
termSeconds:
|
|
100311
|
+
expiry: num17(row.expiry),
|
|
100312
|
+
termSeconds: num17(row.termSeconds),
|
|
98856
100313
|
rateBasis: str7(row.rateBasis),
|
|
98857
|
-
timelock:
|
|
100314
|
+
timelock: num17(row.timelock),
|
|
98858
100315
|
allocators: strArray(row.allocators),
|
|
98859
100316
|
owner: str7(row.owner),
|
|
98860
100317
|
curator: str7(row.curator),
|
|
@@ -98931,19 +100388,19 @@ function vaultTermInputFromEarnMarket(m) {
|
|
|
98931
100388
|
totalAssetsUsd: m.tvl.usd,
|
|
98932
100389
|
liquidity: m.liquidity?.formatted,
|
|
98933
100390
|
liquidityUsd: m.liquidity?.usd,
|
|
98934
|
-
instantLiquidityRatio:
|
|
98935
|
-
totalBorrowed:
|
|
98936
|
-
expectedLiquidity:
|
|
100391
|
+
instantLiquidityRatio: num17(meta.instantLiquidityRatio),
|
|
100392
|
+
totalBorrowed: num17(meta.totalBorrowed),
|
|
100393
|
+
expectedLiquidity: num17(meta.expectedLiquidity),
|
|
98937
100394
|
withdrawalMode: m.exit.mode,
|
|
98938
100395
|
withdrawalCooldownSeconds: m.exit.cooldownSecs,
|
|
98939
100396
|
withdrawFeeBps: m.exit.feeBps,
|
|
98940
100397
|
exitRoutes: routes(m.exit.routes),
|
|
98941
100398
|
fee: m.rate.fee,
|
|
98942
|
-
managementFee:
|
|
98943
|
-
swapFeeRate:
|
|
98944
|
-
redemptionDiscountBps:
|
|
100399
|
+
managementFee: num17(meta.managementFee),
|
|
100400
|
+
swapFeeRate: num17(meta.feeRate),
|
|
100401
|
+
redemptionDiscountBps: num17(meta.redemptionDiscountBps),
|
|
98945
100402
|
instantRedeemEnabled: bool5(meta.instantRedeemEnabled),
|
|
98946
|
-
yieldWarmupSeconds:
|
|
100403
|
+
yieldWarmupSeconds: num17(meta.yieldWarmupSeconds) ?? curated.yieldWarmupSeconds,
|
|
98947
100404
|
accrual: str7(meta.accrual) ?? curated.accrual,
|
|
98948
100405
|
needsDepositApproval: bool5(meta.needsDepositApproval) ?? curated.needsDepositApproval,
|
|
98949
100406
|
// `canDeposit` already folds in the cap, the pause and the gate, so it is
|
|
@@ -98957,9 +100414,9 @@ function vaultTermInputFromEarnMarket(m) {
|
|
|
98957
100414
|
isClosed: bool5(meta.isClosed),
|
|
98958
100415
|
whitelisted: bool5(meta.whitelisted),
|
|
98959
100416
|
expiry: m.maturity?.maturity ?? curated.expiry,
|
|
98960
|
-
termSeconds: (m.maturity?.kind === "rolling-duration" ? m.maturity.maxDurationSecs : void 0) ??
|
|
100417
|
+
termSeconds: (m.maturity?.kind === "rolling-duration" ? m.maturity.maxDurationSecs : void 0) ?? num17(meta.termSeconds) ?? curated.termSeconds,
|
|
98961
100418
|
rateBasis: str7(meta.rateBasis) ?? curated.rateBasis,
|
|
98962
|
-
timelock:
|
|
100419
|
+
timelock: num17(meta.timelock),
|
|
98963
100420
|
allocators: strArray(meta.allocators),
|
|
98964
100421
|
owner: str7(meta.owner),
|
|
98965
100422
|
curator: str7(meta.curator),
|
|
@@ -98972,13 +100429,13 @@ function vaultTermInputFromEarnMarket(m) {
|
|
|
98972
100429
|
};
|
|
98973
100430
|
}
|
|
98974
100431
|
function originRates(rates) {
|
|
98975
|
-
const supply =
|
|
98976
|
-
const rewards =
|
|
98977
|
-
const deposit =
|
|
100432
|
+
const supply = num17(rates.supplyRate);
|
|
100433
|
+
const rewards = num17(rates.rewardsRate);
|
|
100434
|
+
const deposit = num17(rates.depositRate);
|
|
98978
100435
|
return {
|
|
98979
100436
|
supplyRate: supply ?? (deposit !== void 0 && rewards !== void 0 ? deposit - rewards : deposit),
|
|
98980
100437
|
rewardsRate: rewards,
|
|
98981
|
-
totalRate:
|
|
100438
|
+
totalRate: num17(rates.totalRate) ?? deposit
|
|
98982
100439
|
};
|
|
98983
100440
|
}
|
|
98984
100441
|
function vaultTermInputFromSourceRow(row, chainId) {
|
|
@@ -98991,7 +100448,7 @@ function vaultTermInputFromSourceRow(row, chainId) {
|
|
|
98991
100448
|
const liq = row.liquidity ?? {};
|
|
98992
100449
|
const info = row.vaultInfo ?? {};
|
|
98993
100450
|
const assetInfo = row.underlyingInfo?.asset;
|
|
98994
|
-
const assetDecimals =
|
|
100451
|
+
const assetDecimals = num17(row.assetDecimals) ?? num17(assetInfo?.decimals) ?? num17(row.decimals);
|
|
98995
100452
|
const curated = savingsCuration(provider, chainId, address, {
|
|
98996
100453
|
brand: str7(row.curatorName) ?? str7(meta.brand),
|
|
98997
100454
|
name: str7(info.name) ?? str7(row.displayName) ?? str7(row.name)
|
|
@@ -99016,23 +100473,23 @@ function vaultTermInputFromSourceRow(row, chainId) {
|
|
|
99016
100473
|
...originRates(rates),
|
|
99017
100474
|
isForwardApr: bool5(meta.isForwardApr),
|
|
99018
100475
|
aprWindow: str7(meta.aprWindow),
|
|
99019
|
-
totalAssets:
|
|
99020
|
-
totalAssetsUsd:
|
|
99021
|
-
liquidity:
|
|
99022
|
-
liquidityUsd:
|
|
99023
|
-
instantLiquidityRatio:
|
|
100476
|
+
totalAssets: num17(tvl.totalAssetsFormatted) ?? fromRaw(tvl.totalAssets, assetDecimals),
|
|
100477
|
+
totalAssetsUsd: num17(tvl.totalAssetsUsd),
|
|
100478
|
+
liquidity: num17(liq.liquidityFormatted) ?? fromRaw(liq.liquidity, assetDecimals),
|
|
100479
|
+
liquidityUsd: num17(liq.liquidityUsd),
|
|
100480
|
+
instantLiquidityRatio: num17(meta.instantLiquidityRatio),
|
|
99024
100481
|
totalBorrowed: fromRaw(meta.totalBorrowed, assetDecimals),
|
|
99025
100482
|
expectedLiquidity: fromRaw(meta.expectedLiquidity, assetDecimals),
|
|
99026
100483
|
withdrawalMode: str7(meta.withdrawalMode),
|
|
99027
|
-
withdrawalCooldownSeconds:
|
|
99028
|
-
withdrawFeeBps:
|
|
100484
|
+
withdrawalCooldownSeconds: num17(meta.withdrawalCooldownSeconds),
|
|
100485
|
+
withdrawFeeBps: num17(meta.withdrawFeeBps),
|
|
99029
100486
|
exitRoutes: routes(meta.exitRoutes),
|
|
99030
|
-
fee:
|
|
99031
|
-
managementFee:
|
|
99032
|
-
swapFeeRate:
|
|
99033
|
-
redemptionDiscountBps:
|
|
100487
|
+
fee: num17(rates.fee),
|
|
100488
|
+
managementFee: num17(meta.managementFee),
|
|
100489
|
+
swapFeeRate: num17(meta.feeRate),
|
|
100490
|
+
redemptionDiscountBps: num17(meta.redemptionDiscountBps),
|
|
99034
100491
|
instantRedeemEnabled: bool5(meta.instantRedeemEnabled),
|
|
99035
|
-
yieldWarmupSeconds:
|
|
100492
|
+
yieldWarmupSeconds: num17(meta.yieldWarmupSeconds) ?? curated.yieldWarmupSeconds,
|
|
99036
100493
|
accrual: str7(meta.accrual) ?? curated.accrual,
|
|
99037
100494
|
needsDepositApproval: bool5(meta.needsDepositApproval) ?? curated.needsDepositApproval,
|
|
99038
100495
|
isMintable: bool5(meta.isMintable),
|
|
@@ -99043,10 +100500,10 @@ function vaultTermInputFromSourceRow(row, chainId) {
|
|
|
99043
100500
|
withdrawalsPaused: bool5(meta.isWithdrawalPaused),
|
|
99044
100501
|
isClosed: bool5(meta.isClosed),
|
|
99045
100502
|
whitelisted: bool5(meta.whitelisted),
|
|
99046
|
-
expiry:
|
|
99047
|
-
termSeconds:
|
|
100503
|
+
expiry: num17(meta.expiry) ?? num17(meta.maturity) ?? curated.expiry,
|
|
100504
|
+
termSeconds: num17(meta.termSeconds) ?? curated.termSeconds,
|
|
99048
100505
|
rateBasis: str7(meta.rateBasis) ?? curated.rateBasis,
|
|
99049
|
-
timelock:
|
|
100506
|
+
timelock: num17(meta.timelock),
|
|
99050
100507
|
allocators: strArray(meta.allocators),
|
|
99051
100508
|
owner: str7(meta.owner),
|
|
99052
100509
|
curator: str7(meta.curator),
|
|
@@ -99873,7 +101330,7 @@ async function fetchTokenBalances(chainId, account, tokens, options = {}) {
|
|
|
99873
101330
|
}
|
|
99874
101331
|
|
|
99875
101332
|
// src/terms/input.ts
|
|
99876
|
-
var
|
|
101333
|
+
var num18 = (v) => {
|
|
99877
101334
|
if (v == null) return void 0;
|
|
99878
101335
|
const n = typeof v === "string" ? Number(v) : v;
|
|
99879
101336
|
return Number.isFinite(n) ? n : void 0;
|
|
@@ -99904,20 +101361,20 @@ function toTermSheetInput(row, ctx = {}) {
|
|
|
99904
101361
|
{
|
|
99905
101362
|
category: v?.category ?? k,
|
|
99906
101363
|
label: v?.label,
|
|
99907
|
-
borrowCollateralFactor:
|
|
99908
|
-
collateralFactor:
|
|
99909
|
-
borrowFactor:
|
|
99910
|
-
liquidationPenalty:
|
|
99911
|
-
closeFactor:
|
|
99912
|
-
targetHealthFactor:
|
|
101364
|
+
borrowCollateralFactor: num18(v?.borrowCollateralFactor),
|
|
101365
|
+
collateralFactor: num18(v?.collateralFactor),
|
|
101366
|
+
borrowFactor: num18(v?.borrowFactor),
|
|
101367
|
+
liquidationPenalty: num18(v?.liquidationPenalty),
|
|
101368
|
+
closeFactor: num18(v?.closeFactor),
|
|
101369
|
+
targetHealthFactor: num18(v?.targetHealthFactor),
|
|
99913
101370
|
collateralDisabled: v?.collateralDisabled === true,
|
|
99914
101371
|
debtDisabled: v?.debtDisabled === true,
|
|
99915
101372
|
// the mode-level position fields (UNIFIED_API_AUDIT §11) — set
|
|
99916
101373
|
// only where the row carries them, so EVM inputs are unchanged
|
|
99917
|
-
...v?.liquidationBorrowFactor != null ? { liquidationBorrowFactor:
|
|
99918
|
-
...v?.debtCapacity != null ? { debtCapacity:
|
|
99919
|
-
...v?.collateralDebtCapacity != null ? { collateralDebtCapacity:
|
|
99920
|
-
...v?.maxCollateralAssets != null ? { maxCollateralAssets:
|
|
101374
|
+
...v?.liquidationBorrowFactor != null ? { liquidationBorrowFactor: num18(v.liquidationBorrowFactor) } : {},
|
|
101375
|
+
...v?.debtCapacity != null ? { debtCapacity: num18(v.debtCapacity) } : {},
|
|
101376
|
+
...v?.collateralDebtCapacity != null ? { collateralDebtCapacity: num18(v.collateralDebtCapacity) } : {},
|
|
101377
|
+
...v?.maxCollateralAssets != null ? { maxCollateralAssets: num18(v.maxCollateralAssets) } : {},
|
|
99921
101378
|
...v?.exclusiveCollateral != null ? { exclusiveCollateral: v.exclusiveCollateral === true } : {},
|
|
99922
101379
|
...v?.openParameter ? { openParameter: v.openParameter } : {}
|
|
99923
101380
|
}
|
|
@@ -99925,11 +101382,11 @@ function toTermSheetInput(row, ctx = {}) {
|
|
|
99925
101382
|
) : void 0;
|
|
99926
101383
|
const rewards = pick2(row, "rewards")?.map((r) => ({
|
|
99927
101384
|
asset: r?.asset,
|
|
99928
|
-
depositRate:
|
|
99929
|
-
variableBorrowRate:
|
|
99930
|
-
stableBorrowRate:
|
|
101385
|
+
depositRate: num18(r?.depositRate),
|
|
101386
|
+
variableBorrowRate: num18(r?.variableBorrowRate),
|
|
101387
|
+
stableBorrowRate: num18(r?.stableBorrowRate),
|
|
99931
101388
|
kind: r?.kind,
|
|
99932
|
-
endsAt:
|
|
101389
|
+
endsAt: num18(r?.endsAt),
|
|
99933
101390
|
claim: r?.claim
|
|
99934
101391
|
}));
|
|
99935
101392
|
return {
|
|
@@ -99943,29 +101400,29 @@ function toTermSheetInput(row, ctx = {}) {
|
|
|
99943
101400
|
(v) => !!v && typeof v === "object"
|
|
99944
101401
|
),
|
|
99945
101402
|
underlying: pick2(row, "underlying"),
|
|
99946
|
-
decimals:
|
|
99947
|
-
depositRate:
|
|
99948
|
-
variableBorrowRate:
|
|
99949
|
-
stableBorrowRate:
|
|
99950
|
-
intrinsicYield:
|
|
101403
|
+
decimals: num18(pick2(row, "decimals")),
|
|
101404
|
+
depositRate: num18(pick2(row, "depositRate")),
|
|
101405
|
+
variableBorrowRate: num18(pick2(row, "variableBorrowRate")),
|
|
101406
|
+
stableBorrowRate: num18(pick2(row, "stableBorrowRate")),
|
|
101407
|
+
intrinsicYield: num18(pick2(row, "intrinsicYield")),
|
|
99951
101408
|
rewards,
|
|
99952
101409
|
rateModel: pick2(row, "rateModel"),
|
|
99953
|
-
originationFee:
|
|
99954
|
-
totalDeposits:
|
|
99955
|
-
totalDebt:
|
|
99956
|
-
totalDebtStable:
|
|
99957
|
-
totalLiquidity:
|
|
99958
|
-
borrowLiquidity:
|
|
99959
|
-
totalDepositsUsd:
|
|
99960
|
-
totalDebtUsd:
|
|
99961
|
-
totalLiquidityUsd:
|
|
99962
|
-
utilization:
|
|
99963
|
-
irmTotalDeposits:
|
|
99964
|
-
irmTotalDebt:
|
|
99965
|
-
lockupRatio:
|
|
101410
|
+
originationFee: num18(pick2(row, "originationFee")),
|
|
101411
|
+
totalDeposits: num18(pick2(row, "totalDeposits")),
|
|
101412
|
+
totalDebt: num18(pick2(row, "totalDebt")),
|
|
101413
|
+
totalDebtStable: num18(pick2(row, "totalDebtStable")),
|
|
101414
|
+
totalLiquidity: num18(pick2(row, "totalLiquidity")),
|
|
101415
|
+
borrowLiquidity: num18(pick2(row, "borrowLiquidity")),
|
|
101416
|
+
totalDepositsUsd: num18(pick2(row, "totalDepositsUSD", "totalDepositsUsd")),
|
|
101417
|
+
totalDebtUsd: num18(pick2(row, "totalDebtUSD", "totalDebtUsd")),
|
|
101418
|
+
totalLiquidityUsd: num18(pick2(row, "totalLiquidityUSD", "totalLiquidityUsd")),
|
|
101419
|
+
utilization: num18(pick2(row, "utilization")),
|
|
101420
|
+
irmTotalDeposits: num18(pick2(row, "irmTotalDeposits")),
|
|
101421
|
+
irmTotalDebt: num18(pick2(row, "irmTotalDebt")),
|
|
101422
|
+
lockupRatio: num18(pick2(row, "lockupRatio")),
|
|
99966
101423
|
minBorrow: pick2(row, "minBorrow", "caps.minBorrow") ?? void 0,
|
|
99967
|
-
supplyCap:
|
|
99968
|
-
borrowCap:
|
|
101424
|
+
supplyCap: num18(pick2(row, "supplyCap", "caps.supplyCap")),
|
|
101425
|
+
borrowCap: num18(pick2(row, "borrowCap", "caps.borrowCap")),
|
|
99969
101426
|
debtCeiling: pick2(row, "debtCeiling", "caps.debtCeiling"),
|
|
99970
101427
|
isActive: pick2(row, "isActive", "flags.isActive"),
|
|
99971
101428
|
isFrozen: pick2(row, "isFrozen", "flags.isFrozen"),
|
|
@@ -100002,8 +101459,8 @@ function toTermSheetInput(row, ctx = {}) {
|
|
|
100002
101459
|
// builder's `?? 1`, so Aave and Compound V2 published "the whole debt can
|
|
100003
101460
|
// be repaid in one liquidation" against a real close factor of 0.5, and
|
|
100004
101461
|
// Aave V4's `targetHealthFactor` vanished entirely.
|
|
100005
|
-
closeFactor:
|
|
100006
|
-
targetHealthFactor:
|
|
101462
|
+
closeFactor: num18(pick2(row, "closeFactor", "caps.closeFactor")),
|
|
101463
|
+
targetHealthFactor: num18(
|
|
100007
101464
|
pick2(row, "targetHealthFactor", "caps.targetHealthFactor")
|
|
100008
101465
|
),
|
|
100009
101466
|
fixedTerm: pick2(row, "fixedTerm") ?? ctx.fixedTerm,
|
|
@@ -101164,7 +102621,7 @@ var ripeAdapter = {
|
|
|
101164
102621
|
};
|
|
101165
102622
|
}
|
|
101166
102623
|
};
|
|
101167
|
-
var
|
|
102624
|
+
var num19 = (v) => typeof v === "number" && Number.isFinite(v) ? v : void 0;
|
|
101168
102625
|
var alchemixAdapter = {
|
|
101169
102626
|
id: "alchemix",
|
|
101170
102627
|
matches: isAlchemix,
|
|
@@ -101172,8 +102629,8 @@ var alchemixAdapter = {
|
|
|
101172
102629
|
build: (input) => {
|
|
101173
102630
|
const a = input.market?.alchemix ?? {};
|
|
101174
102631
|
const isCollateralRow = input.collateralActive !== false;
|
|
101175
|
-
const protocolFeeBps =
|
|
101176
|
-
const liquidatorFeeBps =
|
|
102632
|
+
const protocolFeeBps = num19(a.protocolFeeBps);
|
|
102633
|
+
const liquidatorFeeBps = num19(a.liquidatorFeeBps);
|
|
101177
102634
|
const fees2 = [];
|
|
101178
102635
|
if (protocolFeeBps != null)
|
|
101179
102636
|
fees2.push({
|
|
@@ -101213,7 +102670,7 @@ var alchemixAdapter = {
|
|
|
101213
102670
|
if (cap > 0) capUtilization = Math.min(1, Number(a.totalDeposited) / cap);
|
|
101214
102671
|
}
|
|
101215
102672
|
const capFull = capUtilization != null && capUtilization >= 1;
|
|
101216
|
-
const termSecs =
|
|
102673
|
+
const termSecs = num19(a.transmuterQueue?.termSeconds);
|
|
101217
102674
|
return {
|
|
101218
102675
|
oracle: {
|
|
101219
102676
|
// Not a market price feed: collateral is valued at the MYT's OWN share
|
|
@@ -101306,9 +102763,9 @@ var alchemixAdapter = {
|
|
|
101306
102763
|
alchemix: {
|
|
101307
102764
|
debtValuation: "face",
|
|
101308
102765
|
redemptionFeeBps: protocolFeeBps,
|
|
101309
|
-
redemptionRatePerYear:
|
|
102766
|
+
redemptionRatePerYear: num19(a.redemptionRatePerYear),
|
|
101310
102767
|
transmuterTermSecs: termSecs,
|
|
101311
|
-
transmuterTermBlocks:
|
|
102768
|
+
transmuterTermBlocks: num19(a.transmuterQueue?.termBlocks)
|
|
101312
102769
|
}
|
|
101313
102770
|
}
|
|
101314
102771
|
},
|
|
@@ -101325,7 +102782,7 @@ var alchemixAdapter = {
|
|
|
101325
102782
|
};
|
|
101326
102783
|
}
|
|
101327
102784
|
};
|
|
101328
|
-
var
|
|
102785
|
+
var num20 = (v) => typeof v === "number" && Number.isFinite(v) ? v : void 0;
|
|
101329
102786
|
var flexAdapter = {
|
|
101330
102787
|
id: "flex",
|
|
101331
102788
|
matches: isFlex,
|
|
@@ -101333,18 +102790,18 @@ var flexAdapter = {
|
|
|
101333
102790
|
build: (input) => {
|
|
101334
102791
|
const f = input.market?.flex ?? {};
|
|
101335
102792
|
const isCollateralRow = input.collateralActive !== false;
|
|
101336
|
-
const minApr =
|
|
101337
|
-
const maxApr =
|
|
101338
|
-
const minFee =
|
|
101339
|
-
const maxFee =
|
|
101340
|
-
const repayCooldown =
|
|
102793
|
+
const minApr = num20(f.minAnnualInterestRate) != null ? f.minAnnualInterestRate * 100 : void 0;
|
|
102794
|
+
const maxApr = num20(f.maxAnnualInterestRate) != null ? f.maxAnnualInterestRate * 100 : void 0;
|
|
102795
|
+
const minFee = num20(f.minLiquidationFee);
|
|
102796
|
+
const maxFee = num20(f.maxLiquidationFee);
|
|
102797
|
+
const repayCooldown = num20(f.repayCooldown);
|
|
101341
102798
|
const decimals = input.asset?.decimals ?? input.decimals;
|
|
101342
|
-
const minDebt =
|
|
101343
|
-
const perfFeeBps =
|
|
101344
|
-
const idle =
|
|
102799
|
+
const minDebt = num20(f.minDebt) != null && decimals != null ? parseUnits(String(f.minDebt), decimals).toString() : void 0;
|
|
102800
|
+
const perfFeeBps = num20(f.performanceFeeBps);
|
|
102801
|
+
const idle = num20(f.idleLiquidity);
|
|
101345
102802
|
const borrowFees = [];
|
|
101346
|
-
const upfrontPct =
|
|
101347
|
-
if (upfrontPct != null &&
|
|
102803
|
+
const upfrontPct = num20(input.originationFee) ?? (num20(f.averageInterestRate) != null && num20(f.upfrontInterestPeriod) ? f.averageInterestRate * (f.upfrontInterestPeriod / 31536e3) * 100 : void 0);
|
|
102804
|
+
if (upfrontPct != null && num20(f.upfrontInterestPeriod))
|
|
101348
102805
|
borrowFees.push({
|
|
101349
102806
|
id: "origination",
|
|
101350
102807
|
label: "Upfront fee",
|
|
@@ -101407,7 +102864,7 @@ var flexAdapter = {
|
|
|
101407
102864
|
default: input.variableBorrowRate,
|
|
101408
102865
|
adjustable: true,
|
|
101409
102866
|
adjustmentCostNote: "Changing the rate again within the adjustment cooldown re-charges the upfront fee.",
|
|
101410
|
-
adjustmentCooldownSecs:
|
|
102867
|
+
adjustmentCooldownSecs: num20(f.interestRateAdjCooldown),
|
|
101411
102868
|
...queueUserSetFields(f.queue)
|
|
101412
102869
|
}
|
|
101413
102870
|
},
|
|
@@ -101606,6 +103063,7 @@ var llamaLendAdapter = {
|
|
|
101606
103063
|
] : void 0,
|
|
101607
103064
|
bandLtv,
|
|
101608
103065
|
defaultBands: typeof ll.defaultBands === "number" ? ll.defaultBands : void 0,
|
|
103066
|
+
ammA: Number(ll.ammA) > 1 ? Number(ll.ammA) : void 0,
|
|
101609
103067
|
/**
|
|
101610
103068
|
* The band count as an editable TERM, not just a curve to read.
|
|
101611
103069
|
*
|
|
@@ -101989,7 +103447,7 @@ var flyingTulipAdapter = {
|
|
|
101989
103447
|
};
|
|
101990
103448
|
}
|
|
101991
103449
|
};
|
|
101992
|
-
var
|
|
103450
|
+
var num21 = (v) => typeof v === "number" && Number.isFinite(v) ? v : void 0;
|
|
101993
103451
|
var pct2 = (v) => `${(v * 100).toFixed(2)} %`;
|
|
101994
103452
|
var twyneAdapter = {
|
|
101995
103453
|
id: "twyne",
|
|
@@ -101997,13 +103455,13 @@ var twyneAdapter = {
|
|
|
101997
103455
|
profileId: () => "twyne.credit-delegation@v1",
|
|
101998
103456
|
build: (input) => {
|
|
101999
103457
|
const tw = input.market?.twyne ?? {};
|
|
102000
|
-
const floorLtv =
|
|
102001
|
-
const maxLtv =
|
|
102002
|
-
const externalLiqLtv =
|
|
102003
|
-
const creditApr =
|
|
102004
|
-
const maturity =
|
|
103458
|
+
const floorLtv = num21(tw.floorLtv);
|
|
103459
|
+
const maxLtv = num21(tw.maxLtv);
|
|
103460
|
+
const externalLiqLtv = num21(tw.externalLiqLtv);
|
|
103461
|
+
const creditApr = num21(tw.creditApr);
|
|
103462
|
+
const maturity = num21(tw.collateralMaturity);
|
|
102005
103463
|
const matured = tw.collateralMatured === true;
|
|
102006
|
-
const creditAvailable =
|
|
103464
|
+
const creditAvailable = num21(tw.creditAvailable);
|
|
102007
103465
|
const vaultType = typeof tw.vaultType === "string" ? tw.vaultType : void 0;
|
|
102008
103466
|
const externalName = vaultType === "AAVE_V3" ? "Aave V3" : vaultType === "EULER_V2" ? "Euler V2" : "the external market";
|
|
102009
103467
|
const creditExhausted = creditAvailable != null && creditAvailable <= 0;
|
|
@@ -102178,7 +103636,7 @@ var aaveV4Adapter = {
|
|
|
102178
103636
|
build: (input) => {
|
|
102179
103637
|
const target = input.targetHealthFactor;
|
|
102180
103638
|
const desc = input.market?.aaveV4 ?? {};
|
|
102181
|
-
const maxBonusHf =
|
|
103639
|
+
const maxBonusHf = num22(desc.healthFactorForMaxBonus);
|
|
102182
103640
|
return {
|
|
102183
103641
|
borrow: {
|
|
102184
103642
|
liquidation: {
|
|
@@ -102192,7 +103650,7 @@ var aaveV4Adapter = {
|
|
|
102192
103650
|
};
|
|
102193
103651
|
}
|
|
102194
103652
|
};
|
|
102195
|
-
function
|
|
103653
|
+
function num22(v) {
|
|
102196
103654
|
if (v == null) return void 0;
|
|
102197
103655
|
const n = typeof v === "string" ? Number(v) : v;
|
|
102198
103656
|
return Number.isFinite(n) && n > 0 ? n : void 0;
|
|
@@ -103455,7 +104913,8 @@ function toDigest(sheet) {
|
|
|
103455
104913
|
(p) => p.id === sheet.borrow.rate.userSet.recommended
|
|
103456
104914
|
)?.apr
|
|
103457
104915
|
}
|
|
103458
|
-
} : {}
|
|
104916
|
+
} : {},
|
|
104917
|
+
...sheet.borrow.choices ? { choices: digestChoices(sheet.borrow.choices) } : {}
|
|
103459
104918
|
} : void 0,
|
|
103460
104919
|
swap: sheet.swap ? {
|
|
103461
104920
|
kind: sheet.swap.kind,
|
|
@@ -104061,17 +105520,17 @@ function earnMarketFromPool(row, fallbackChainId, venueCollaterals) {
|
|
|
104061
105520
|
const assetInfo = row.underlyingInfo?.asset ?? row.asset ?? {};
|
|
104062
105521
|
const underlying = addr5(assetInfo.address, chainId) ?? addr5(row.underlying, chainId) ?? addr5(row.poolId, chainId);
|
|
104063
105522
|
if (!underlying) return void 0;
|
|
104064
|
-
const decimals =
|
|
104065
|
-
const priceUsd =
|
|
104066
|
-
const base =
|
|
104067
|
-
const intrinsic =
|
|
105523
|
+
const decimals = num16(assetInfo.decimals) ?? num16(row.decimals) ?? 18;
|
|
105524
|
+
const priceUsd = num16(row.underlyingInfo?.prices?.priceUsd) ?? num16(row.price);
|
|
105525
|
+
const base = num16(row.depositRate);
|
|
105526
|
+
const intrinsic = num16(row.intrinsicYield);
|
|
104068
105527
|
const rewards = sumRewardAprs(row.rewards);
|
|
104069
105528
|
const marketOwn = sum2(base, rewards);
|
|
104070
105529
|
const rate = {
|
|
104071
105530
|
// Prefer our own sum over the origin's `apr`, because `apr` is documented
|
|
104072
105531
|
// as `depositRate + intrinsicYield` and therefore EXCLUDES incentives —
|
|
104073
105532
|
// using it as the headline would under-report every incentivized market.
|
|
104074
|
-
total: sum2(base, intrinsic, rewards) ??
|
|
105533
|
+
total: sum2(base, intrinsic, rewards) ?? num16(row.apr) ?? 0,
|
|
104075
105534
|
base,
|
|
104076
105535
|
rewards,
|
|
104077
105536
|
intrinsic,
|
|
@@ -104139,7 +105598,7 @@ function earnMarketFromPool(row, fallbackChainId, venueCollaterals) {
|
|
|
104139
105598
|
row.totalLiquidityUSD ?? row.totalLiquidityUsd
|
|
104140
105599
|
),
|
|
104141
105600
|
depositCapacity: void 0,
|
|
104142
|
-
utilization:
|
|
105601
|
+
utilization: num16(row.utilization),
|
|
104143
105602
|
// Lending withdrawals are same-block, bounded by available liquidity —
|
|
104144
105603
|
// which is exactly `instant-capped`, not `instant`. A pool at 100 %
|
|
104145
105604
|
// utilization cannot be exited, and calling that `instant` is the kind of
|
|
@@ -104147,12 +105606,12 @@ function earnMarketFromPool(row, fallbackChainId, venueCollaterals) {
|
|
|
104147
105606
|
exit: { mode: "instant-capped", settlement: "sync" },
|
|
104148
105607
|
availability: availability2,
|
|
104149
105608
|
risk: {
|
|
104150
|
-
score:
|
|
105609
|
+
score: num16(row.risk?.score),
|
|
104151
105610
|
label: str6(row.risk?.label),
|
|
104152
105611
|
illiquid: isIlliquid({
|
|
104153
105612
|
exitMode: "instant-capped",
|
|
104154
|
-
tvlUsd:
|
|
104155
|
-
liquidityUsd:
|
|
105613
|
+
tvlUsd: num16(row.totalDepositsUSD ?? row.totalDepositsUsd),
|
|
105614
|
+
liquidityUsd: num16(row.totalLiquidityUSD ?? row.totalLiquidityUsd)
|
|
104156
105615
|
})
|
|
104157
105616
|
},
|
|
104158
105617
|
...basket ? { basket } : {},
|
|
@@ -104218,9 +105677,9 @@ function resolveAvailability2(row, flags, totalRate) {
|
|
|
104218
105677
|
};
|
|
104219
105678
|
}
|
|
104220
105679
|
function isSupplyCapFull(row) {
|
|
104221
|
-
const cap =
|
|
105680
|
+
const cap = num16(row.caps?.supplyCap) ?? num16(row.supplyCap);
|
|
104222
105681
|
if (cap === void 0 || cap <= 0) return false;
|
|
104223
|
-
const deposits =
|
|
105682
|
+
const deposits = num16(row.totalDeposits);
|
|
104224
105683
|
if (deposits === void 0) return false;
|
|
104225
105684
|
return deposits >= cap;
|
|
104226
105685
|
}
|
|
@@ -104229,7 +105688,7 @@ function sumRewardAprs(rewards) {
|
|
|
104229
105688
|
let total = 0;
|
|
104230
105689
|
let seen = false;
|
|
104231
105690
|
for (const r of rewards) {
|
|
104232
|
-
const apr =
|
|
105691
|
+
const apr = num16(r?.depositRate);
|
|
104233
105692
|
if (apr === void 0) continue;
|
|
104234
105693
|
total += apr;
|
|
104235
105694
|
seen = true;
|
|
@@ -104237,7 +105696,7 @@ function sumRewardAprs(rewards) {
|
|
|
104237
105696
|
return seen ? total : void 0;
|
|
104238
105697
|
}
|
|
104239
105698
|
function amount4(formatted, usd) {
|
|
104240
|
-
return { formatted:
|
|
105699
|
+
return { formatted: num16(formatted), usd: num16(usd) };
|
|
104241
105700
|
}
|
|
104242
105701
|
function sum2(...parts) {
|
|
104243
105702
|
const present = parts.filter((p) => p !== void 0);
|
|
@@ -104927,7 +106386,7 @@ function vaultCapabilities(row) {
|
|
|
104927
106386
|
caps.push({
|
|
104928
106387
|
action: "withdraw",
|
|
104929
106388
|
requires: withdrawRequires(provider),
|
|
104930
|
-
feeBps:
|
|
106389
|
+
feeBps: num16(meta.withdrawFeeBps) ?? row.exit.feeBps,
|
|
104931
106390
|
// a fee-paying single-token exit: pays the vault's token only
|
|
104932
106391
|
acceptsNative: false
|
|
104933
106392
|
});
|
|
@@ -105071,7 +106530,7 @@ function legEarnUid(marketUid) {
|
|
|
105071
106530
|
if (isVaultVenue(parts[0])) return void 0;
|
|
105072
106531
|
return marketUid;
|
|
105073
106532
|
}
|
|
105074
|
-
function
|
|
106533
|
+
function num23(v) {
|
|
105075
106534
|
const n = typeof v === "number" ? v : Number(v);
|
|
105076
106535
|
return Number.isFinite(n) ? n : 0;
|
|
105077
106536
|
}
|
|
@@ -105098,10 +106557,10 @@ function legAsset(pos) {
|
|
|
105098
106557
|
};
|
|
105099
106558
|
}
|
|
105100
106559
|
function toLeg(pos) {
|
|
105101
|
-
const depositsUsd =
|
|
105102
|
-
const debtUsd =
|
|
105103
|
-
const hasSupply = depositsUsd !== 0 ||
|
|
105104
|
-
const hasDebt = debtUsd !== 0 ||
|
|
106560
|
+
const depositsUsd = num23(pos.depositsUSD);
|
|
106561
|
+
const debtUsd = num23(pos.debtUSD) + num23(pos.debtStableUSD);
|
|
106562
|
+
const hasSupply = depositsUsd !== 0 || num23(pos.deposits) !== 0;
|
|
106563
|
+
const hasDebt = debtUsd !== 0 || num23(pos.debt) !== 0 || num23(pos.debtStable) !== 0;
|
|
105105
106564
|
return {
|
|
105106
106565
|
earnUid: legEarnUid(pos.marketUid),
|
|
105107
106566
|
marketUid: pos.marketUid,
|
|
@@ -105146,12 +106605,12 @@ function earnPositionFromLenderEntry(entry2) {
|
|
|
105146
106605
|
(s) => s.legs.some((l) => l.side !== "none") || s.netUsd !== 0
|
|
105147
106606
|
);
|
|
105148
106607
|
const crossMargin = active.length <= 1;
|
|
105149
|
-
const suppliedUsd =
|
|
105150
|
-
const borrowedUsd =
|
|
106608
|
+
const suppliedUsd = num23(entry2.balanceData?.deposits);
|
|
106609
|
+
const borrowedUsd = num23(entry2.balanceData?.debt);
|
|
105151
106610
|
const aprBreakdown = {
|
|
105152
|
-
market:
|
|
105153
|
-
rewards:
|
|
105154
|
-
intrinsic:
|
|
106611
|
+
market: num23(entry2.aprData?.apr),
|
|
106612
|
+
rewards: num23(entry2.aprData?.rewardApr),
|
|
106613
|
+
intrinsic: num23(entry2.aprData?.intrinsicApr)
|
|
105155
106614
|
};
|
|
105156
106615
|
return {
|
|
105157
106616
|
positionUid: buildLendingPositionUid(entry2.lender, entry2.chainId),
|
|
@@ -105165,15 +106624,15 @@ function earnPositionFromLenderEntry(entry2) {
|
|
|
105165
106624
|
...entry2.lenderInfo?.logoUri ? { logoURI: entry2.lenderInfo.logoUri } : {},
|
|
105166
106625
|
suppliedUsd,
|
|
105167
106626
|
borrowedUsd,
|
|
105168
|
-
netUsd:
|
|
106627
|
+
netUsd: num23(entry2.balanceData?.nav),
|
|
105169
106628
|
apr: aprBreakdown.market + aprBreakdown.rewards + aprBreakdown.intrinsic,
|
|
105170
106629
|
aprBreakdown,
|
|
105171
|
-
depositApr:
|
|
105172
|
-
borrowApr:
|
|
106630
|
+
depositApr: num23(entry2.aprData?.depositApr),
|
|
106631
|
+
borrowApr: num23(entry2.aprData?.borrowApr),
|
|
105173
106632
|
// Only a cross-margin account HAS one health factor. Publishing the first
|
|
105174
106633
|
// sub-account's as the row's would be a number about a different position.
|
|
105175
106634
|
health: crossMargin ? active[0]?.health ?? null : null,
|
|
105176
|
-
leverage:
|
|
106635
|
+
leverage: num23(entry2.leverage),
|
|
105177
106636
|
crossMargin,
|
|
105178
106637
|
legs: subAccounts.flatMap((s) => s.legs),
|
|
105179
106638
|
subAccounts: active,
|
|
@@ -105811,8 +107270,8 @@ async function fetchBorosAccount(account, fetchImpl) {
|
|
|
105811
107270
|
}
|
|
105812
107271
|
|
|
105813
107272
|
// src/boros/margin.ts
|
|
105814
|
-
var
|
|
105815
|
-
var ttmYears = (m, ttmSec) => Math.max(ttmSec ?? m.timeToMaturitySec, m.margin.tThreshSec) /
|
|
107273
|
+
var SECONDS_PER_YEAR25 = 365 * 24 * 3600;
|
|
107274
|
+
var ttmYears = (m, ttmSec) => Math.max(ttmSec ?? m.timeToMaturitySec, m.margin.tThreshSec) / SECONDS_PER_YEAR25;
|
|
105816
107275
|
function borosInitialMargin(m, size, ratePct, ttmSec) {
|
|
105817
107276
|
const r = Math.max(Math.abs(ratePct) / 100, m.margin.rateFloor);
|
|
105818
107277
|
return Math.abs(size) * r * m.margin.kIM * ttmYears(m, ttmSec);
|
|
@@ -105822,7 +107281,7 @@ function borosMaintenanceMargin(m, size, markPct, ttmSec) {
|
|
|
105822
107281
|
return Math.abs(size) * r * m.margin.kMM * ttmYears(m, ttmSec);
|
|
105823
107282
|
}
|
|
105824
107283
|
function borosTakerFee(m, size) {
|
|
105825
|
-
return Math.abs(size) * m.fees.takerFee * m.timeToMaturitySec /
|
|
107284
|
+
return Math.abs(size) * m.fees.takerFee * m.timeToMaturitySec / SECONDS_PER_YEAR25;
|
|
105826
107285
|
}
|
|
105827
107286
|
function walkBorosBook(levels, size) {
|
|
105828
107287
|
let left = size;
|
|
@@ -105844,7 +107303,7 @@ function walkBorosBook(levels, size) {
|
|
|
105844
107303
|
};
|
|
105845
107304
|
}
|
|
105846
107305
|
function borosRateMoveToLiquidation(m, size, equity, markPct) {
|
|
105847
|
-
const ttm = m.timeToMaturitySec /
|
|
107306
|
+
const ttm = m.timeToMaturitySec / SECONDS_PER_YEAR25;
|
|
105848
107307
|
if (!(Math.abs(size) > 0) || !(ttm > 0)) return null;
|
|
105849
107308
|
const mm = borosMaintenanceMargin(m, size, markPct);
|
|
105850
107309
|
const slack = equity - mm;
|
|
@@ -105936,7 +107395,7 @@ function quoteBorosHedgeLeg(p) {
|
|
|
105936
107395
|
const fixed = fill.avgAprPct;
|
|
105937
107396
|
const floating = m.rates.floatingApr;
|
|
105938
107397
|
const takerFee = borosTakerFee(m, size);
|
|
105939
|
-
const ttmYears2 = m.timeToMaturitySec /
|
|
107398
|
+
const ttmYears2 = m.timeToMaturitySec / SECONDS_PER_YEAR25;
|
|
105940
107399
|
const settleAprPct = m.fees.settleFee != null ? m.fees.settleFee * 100 : null;
|
|
105941
107400
|
const allIn = ttmYears2 > 0 ? takerFee / size / ttmYears2 * 100 + (settleAprPct ?? 0) : null;
|
|
105942
107401
|
const rateForMargin = fixed ?? m.rates.markApr ?? 0;
|
|
@@ -106089,11 +107548,11 @@ function buildFundingHedgeTerms(i) {
|
|
|
106089
107548
|
};
|
|
106090
107549
|
}
|
|
106091
107550
|
function basisBlock(b) {
|
|
106092
|
-
const
|
|
106093
|
-
const meanGapApr =
|
|
106094
|
-
const trackingErrorApr =
|
|
106095
|
-
const correlation =
|
|
106096
|
-
const beta =
|
|
107551
|
+
const num24 = (x) => x != null && Number.isFinite(x) ? x : void 0;
|
|
107552
|
+
const meanGapApr = num24(b.meanGap);
|
|
107553
|
+
const trackingErrorApr = num24(b.trackingError);
|
|
107554
|
+
const correlation = num24(b.correlation);
|
|
107555
|
+
const beta = num24(b.beta);
|
|
106097
107556
|
const parts = [];
|
|
106098
107557
|
if (meanGapApr != null)
|
|
106099
107558
|
parts.push(
|
|
@@ -106158,6 +107617,6 @@ function hedgeImplications(h, p) {
|
|
|
106158
107617
|
return out;
|
|
106159
107618
|
}
|
|
106160
107619
|
|
|
106161
|
-
export { ALCHEMIX_BLOCK_SECONDS, ApiBookSource, BOROS_API_BASE, BOROS_GOVERNANCE, BOROS_MIN_CASH_USD, BOROS_PROFILE_ID, BorosApiError, DEFAULT_CONSENSUS_DEMOTION, DEFAULT_MIDNIGHT_API, DEFAULT_OUTLIER_GUARD, DEFAULT_PROFILE_ID, DEFAULT_STALE_REJECT_SECONDS, DEFAULT_TERMMAX_API, DEFAULT_TERM_ORDER_STORE, DOLOMITE_ISO_ID_PREFIX, EARN_DESCRIPTIONS, EARN_LABELS, EARN_RATE_SOURCE_BY_PROVIDER, EMPTY_BALANCE, EXACTLY_LENDER_KEY, EXPONENT_MATURED_REASON, FIXED_YIELD_EARN_VENUE_PREFIXES, FLYING_TULIP_LENDER_KEY, FRACTION_RATE_PROVIDERS, FUNDING_EXPOSURE_PROFILES, FUNDING_HEDGE_REFERENCE_USD, GMX_API_HOSTS, GMX_READ_CONTRACTS, GMX_SUPPORTED_CHAINS, HYPERCORE_VAULT_REGISTRY, IDLE_MARKET_ID, INTERFACE_IDS, LAGOON_API_URL, LAGOON_CHAIN_IDS, MORPHO_LENS, MULTICALL_FAILURE, MaxParamThresholds, NON_EVM_VAULT_PROVIDERS, PASSTHROUGH_RATE_EPSILON, PENDLE_ASSETS_URL, PENDLE_CHAIN_IDS, PENDLE_MARKETS_URL2 as PENDLE_MARKETS_URL, PREFIX_LENDERS, RATE_QUEUE_MAX_LEVELS, RATE_QUEUE_STEP, REFLECT_TRANCHE_SIDES, RIPE_LENDER_KEY, SDK_FRACTION_RATE_PROVIDERS, SPECTRA_NETWORKS, SPECTRA_RATE_MAX_PERCENT, SPECTRA_RATE_MIN_PERCENT, STABLECOIN_SYMBOLS, STCELO_MANAGER_ADDRESS, SVM_EARN_MINT_BUILDERS, SVM_EARN_VAULT_BUILDERS, SVM_SAVINGS_CURATION, SVM_VAULT_PROVIDERS, TELLER_CALLS_PER_BID, DECIMAL_BASE as TERMMAX_DECIMAL_BASE, TERMMAX_LIQUIDATION_PENALTY, TERMMAX_LIQUIDATION_WINDOW_SECS, TERMMAX_LIQUIDATOR_BONUS, TERMMAX_MARKETS_PER_CALL, TERMMAX_PARTIAL_CLOSE_FACTOR, TERMMAX_PARTIAL_LIQUIDATION_THRESHOLD_USD, TERM_ADAPTERS, TERM_PROFILES, TERM_SHEET_SCHEMA_VERSION, TermMaxApiSource, TermSubgraphSource, UPSHIFT_CHAIN_IDS, UPSHIFT_VAULTS_URL, USER_REWARD_SOURCES, USER_SET_RATE_PICKS, VAULT_PROVIDERS, VAULT_PROVIDER_PROFILE, VAULT_PROVIDER_TRAITS, VAULT_SHARE_PRICE_PROBE, VAULT_VENUE_PREFIX, VENUS_CORE_POOL_ID, VOLATILE_VAULT_OVERRIDES, VenusEModeAbi, YEARN_CHAIN_IDS, YEARN_YDAEMON_BASE, __resetResupplyUserCaches, accountDepositListKey, accountWithdrawalListKey, alchemixLenderKey, alchemixMytRate, alchemixRedemptionPace, appendSnapshot, applyEarnSanity, applyPositionDelta, attachImplications, attachPricesToFlashLiquidity, blockNumberFromTag, borosApi, borosInitialMargin, borosMaintenanceMargin, borosRateMoveToLiquidation, borosSideTerms, borosTakerFee, borrowDescription, borrowFindings, borrowHeadline, buildBorosTermSheet, buildExposures2 as buildExposures, buildFluidFTokensCall, buildFundingHedgeTerms, buildLendingPositionUid, buildLiquityUserCall, buildLoopResult, buildMorphoTypeCall, buildMorphoTypeUserCallWithLens, buildPortfolioTotals, buildQueriesFromMeta, buildRateQueue, buildSumerAccumulators, buildSummaries, buildTellerUserCall, buildTermMaxUserCall, buildTermSheet, buildTermSheetsForGroup, buildVaultEarnUid, buildVaultLookup, buildVaultTermSheet, calculateLeverage, calculateNetApr, calculateOverallNetApr, calculateWeightedAverage, classifyFreshness, classifyReliability, classifyVault, clearPendleMarketsCache, clearSpectraMarketsCache, collateralSymbolsByVenue, collectFeedObservations, computeBorrowDelta2 as computeBorrowDelta, computeCloseTradeDeltas, computeCollateralSwapDeltas, computeDebtSwapDeltas, computeDepositDelta2 as computeDepositDelta, computeEModeAnalysis, computeOpenTradeDeltas, computePostTradeMetrics, computeRepayDelta2 as computeRepayDelta, computeSumerBorrowDelta, computeSumerDepositDelta, computeSumerRepayDelta, computeSumerWaterfall, computeSumerWithdrawDelta, computeVaultApr, computeWithdrawDelta2 as computeWithdrawDelta, computeZapTradeDeltas, consensusReference, convertAlchemixMarketsToResponse, convertBorosCandle, convertBorosMarket, convertCoolerMarketsToResponse, convertDssMarketsToResponse, convertExactlyMarketsToResponse, convertFlexMarketsToResponse, convertFlyingTulipMarketsToResponse, convertFrankencoinMarketsToResponse, convertFraxlendPairsToResponse, convertInverseMarketsToResponse, convertLenderUserDataResult, convertLiquityMarketsToResponse, convertLlamaLendMarketsToResponse, convertResupplyMarketsToResponse, convertRipeMarketsToResponse, convertRiverMarketsToResponse, convertTellerMarketsToResponse, convertTermMarketsToResponse, convertTermMaxMarketsToResponse, convertUsddMarketsToResponse, createMarketUid, createMidnightBookSource, createMultiAccountTypeUserState, createMulticallRpcCall, createRawRpcCalls, createTermBookSource, createTermMaxDataSource, debtAheadOf, decodeListaMarkets, decodeMarkets, decodePackedListaUserDataset, decodePackedMorphoUserDataset, deriveBorrowTags, deriveSupplyTags, deriveSwapTags, detectInterfaceKinds, dexResolverFor, disambiguateEarnNames, disambiguateOrderBookNames, discoverFlexTroves, dolomiteVaultAddress, dssIlkBytes32, dssKeyParts, dssLenderKey, duration, earnDescription, earnLabel, earnMarketFromPool, earnMarketFromVault, earnMarketLabel, earnPositionFromLenderEntry, earnPositionFromVaultBalance, earnPositionTotals, earnRateAtMaturity, earnRowFundingProfile, earnRowSubtitle, earnUidFromMarketUid, earnVaultTerms, earnVenueKind, emitterCoverage, encodeBalanceFetcherCalldata, enrichTermSheet, enrichmentIndexFromRows, enumerateEmitters, exactlyPairLtv, exactlyPenaltyRateToAprPercent, exactlyWadRateToPercent, exponentTrancheDescription, feePhrase, feedKeyOf, feedStatKey, fetchAaveIncentivesUserRewards, fetchAlchemixMarkets, fetchBorosAccount, fetchBorosCollaterals, fetchBorosMarket, fetchBorosMarketById, fetchBorosMarkets, fetchBorosOrderBook, fetchBorosRateHistory, fetchCoolerMarkets, fetchDolomiteAccountNumbers, fetchDolomiteSubAccounts, fetchDssMarkets, fetchEulerEarnVaults, fetchEulerEarnVaultsFromSubgraph, fetchEulerSubAccountIndexes, fetchExactlyMarkets, fetchFlashLiquidityForChain, fetchFlexMarkets, fetchFluidDexState, fetchFluidFTokens, fetchFlyingTulipMarkets, fetchFlyingTulipUserRewards, fetchFrankencoinMarkets, fetchFraxlendPairs, fetchGeneralYields, fetchGeneralYieldsByMarketUid, fetchGmxExecutionFees, fetchGmxTickerPrices, fetchGmxVaults, fetchHypercoreVaults, fetchInverseMarkets, fetchLagoonApiVaults, fetchLagoonVaults, fetchLenderRewards, fetchLenderRewardsByMarketUid, fetchLiquityMarkets, fetchListaMarketEmissions, fetchListaUserRewards, fetchListaVaultEmissions, fetchListaVaultsFromChain, fetchLlamaLendMarkets, fetchMerklUserRewards, fetchMorphoUserBalances, fetchMorphoUserPositionMarkets, fetchMorphoVaults, fetchMorphoVaultsFromApi, fetchMorphoVaultsFromChain, fetchOraclePrices, fetchPendleApiAssets, fetchPendleApiMarkets, fetchPendlePrices, fetchPendlePtMarkets, fetchResupplyMarkets, fetchRipeMarkets, fetchRiverMarkets, fetchSiloVaults, fetchSpectraApiMarkets, fetchSpectraPtMarkets, fetchTellerMarkets, fetchTermMarkets, fetchTermMaxMarkets, fetchTermStoreOrders, fetchTokenBalances, fetchTokenMetadata, fetchUpshiftApiVaults, fetchUpshiftVaults, fetchUsddMarkets, fetchUserRewards, fetchUsualRewardsClaimData, fetchYearnApiVaults, fetchYearnVaults, fillableRemaining, filterActiveLenders, filterLenderMeta, filterLendersByProtocol, finalizeInfo, findingsFor, flexAverageRate, flexLenderApr, flexLenderKey, flexMarketIndex, formatRaw, frankencoinKeyParts, frankencoinLenderKey, fraxlendAssetPerCollateral, fraxlendKeyParts, fraxlendLenderKey, fundingExposureOf, fundingSymbolBase, fuseLenderData, generateLendingPools, getAavesForChain, getAssetConfig, getBalanceForMarketUid, getBorrowCapacity, getCachedFluidDexState, getCachedLiquityTroves, getCachedTellerBids, getCachedTermMaxDiscovery, getCachedTermMaxMarket, getCachedTermMaxMarkets, getCoreValidators, getFluidFTokensConverter, getGmxApiHost, getGmxReadContracts, getGmxUserPositions, getHealthFactor, getHypercoreUserPositions, getHypercoreVaultRegistry, getLenderAssets, getLenderPublicData, getLenderPublicDataAll, getLenderPublicDataViaApi, getLenderUserDataMulti, getLenderUserDataResult, getLendersForChain, getLstDelegation, getLstValidators, getLstWithdrawalRegistry, getLstWithdrawalRequests, getMaxAmountClose, getMaxAmountCollateralSwap, getMaxAmountDebtSwap, getMaxAmountOpen, getMergedUserData, getMidnightChainBooks, getMorphoTypeMarketConverter, getReadFailurePolicy, getResolvedDolomiteAccountNumbers, getResolvedDolomiteSubAccounts, getStCeloValidatorGroups, getSubAccountAddress, getSubAccountIndex, getTermProfile, getVaultPublicDataAll, getVaultWithdrawalRequests, getVenusEModeSetup, hasCritical, hasEulerEarnVaultSubgraph, hasLagoonVaults, hasMorphoPositionIndex, hasMorphoUserApi, hasMorphoUserSubgraph, hasPendleMarkets, hasSpectraMarkets, hasUpshiftVaults, hasYearnVaults, ilkToKeySegment, implausibleRatePercent, injectLenderInfoIntoEntries, inverseKeyParts, inverseLenderKey, isBoundNeed, isFailedCall, isFixedYieldEarnRow, isIlliquid, isLenderVenueKey, isLendingPosition, isLiveMarket as isLivePendleMarket, isLiveSpectraMarket, isMaturedTerm, isOrderBookCollateralLeg, isOrderBookLendRow, isPrincipalTokenSymbol, isRollingBookLendRow, isSecondaryMarketOnly, isStablecoinSymbol, isSyntheticQuoteUnit, isUnearnableEarnRate, isUnrealizableEarnRate, isVaultPosition, isVaultVenue, isYearnV3, keySegmentToIlk, keysFromMaps, lenderApiOnly, lenderFamily, lenderLiquidityPressure, liquityCandidateTroveIds, liquityKeyParts, liquityLenderKey, listaEmissionRewardFetcher, listaLoginMessage, llamaLendKeyParts, llamaLendLenderKey, marketKeysOf, meetsLiquidityFloor, mergeDeep, multicall3Abi2 as multicall3Abi, nanTo, needsLenderApproval, needsTokenApproval, noOpResult, normalizeToBytes, organizeUserQueries, parseBalanceFetcherResult, parseDolomiteSubAccountId, parseEarnUid, parseLenderKey, parseMergedResult, parseMulticallRpcResponses, parseExpirySeconds as parsePendleExpirySeconds, parseRawRpcBatchResponses, parseRawRpcResponses, parseCurveFee as parseSpectraCurveFee, parsePtRate as parseSpectraPtRate, parseTermMaxLtv, parseTokenBalanceResult, pct, pegPressure, assetKey as pendleAssetKey, pickPool as pickSpectraPool, positivePart2 as positivePart, predictInverseEscrow, prepareLenderUserDataRpcCalls, prepareMergedMulticallParams, prepareMergedRpcCalls, prepareMulticallInputs, prepareTokenBalanceRpcCalls, priceGlvVaults, priceGmMarkets, probeAaveFeedTimestamps, protocolConsensus, protocolOf, pruneFeedStats, quoteBorosHedgeLeg, rankBorosHedgeMarkets, rankFindings, ratePercent, readLstPauseState, readTransmuterLots, readUserPositions, readVaultSharePrices, reflectTrancheDescription, rejectOutliers as rejectPriceOutliers, repairImpossibleTvl, resolveAdapter, resolveDerivation, resolveDolomiteRowIdentity, resolveEarnIdentity, resolveMerklOpportunityMarkets, resolveModeConfig, resolveStCeloDepositGroup, resolveVaultProfileId, resupplyKeyParts, resupplyLenderKey, resupplyMarketLabel, riverKeyParts, riverLenderKey, sanePercent as saneSpectraPercent, savingsAddresses, savingsBalanceKind, secondaryMarketVault, selectAssetGroupPrices, selectUsualRewardEntry, setMysticApiKey, shortDate, spectraAddress, spectraNetwork, spectraPoolsUrl, splitChainScopedAddress as splitPendleChainScopedAddress, stampCapabilities, stampEarnSubtitles, stampOrderBookLendRow, stampRollingBookLendRow, stampVaultClassification, stampVaultTermSheets, stripLeadingBrand, subAccountsOf, supplyDescription, supplyFindings, supplyHeadline, svmEarnBuildability, svmEarnBuilderKey, svmSavingsCuration, swapRoutedProvidersArePriceConsistent, swapSideDescription, swapSideHeadline, swapSideImplications, tellerBpsToPercent, tellerImpliedLtv, tellerLenderKey, tellerPoolFromLenderKey, termApiBaseUrl, termLenderKey, termMaxApiBase, borrowNif as termMaxBorrowNif, curveApr as termMaxCurveApr, curveAprNumber as termMaxCurveAprNumber, daysToMaturity as termMaxDaysToMaturity, lendNif as termMaxLendNif, mintGtFeeRatio as termMaxMintGtFeeRatio, ratioToNumber as termMaxRatioToNumber, ratioToPercent as termMaxRatioToPercent, termOfferRateToAprPct, termOrderStoreBaseUrl, tickToAprNumber, tickToPrice, toDigest, toDolomiteSubAccountId, toTermFillNow, toTermSheetInput, toVaultTermInput, trancheFromCounterparty, tryParseEarnUid, unflattenLenderData, updateFeedStats, usdValue, usddIlkBytes32, usddKeyParts, usddLenderKey, validateTermSheet, validateTermSheets, validateUserData, vaultSharesToAssets, vaultTermInputFromEarnMarket, vaultTermInputFromSourceRow, vaultTraits, vaultVenue, venueBrand, venueBrandKey, walkBorosBook, withMaturityLabel, withTrancheLabel };
|
|
107620
|
+
export { ALCHEMIX_BLOCK_SECONDS, ApiBookSource, BOROS_API_BASE, BOROS_GOVERNANCE, BOROS_MIN_CASH_USD, BOROS_PROFILE_ID, BorosApiError, DEFAULT_CONSENSUS_DEMOTION, DEFAULT_MIDNIGHT_API, DEFAULT_OUTLIER_GUARD, DEFAULT_PROFILE_ID, DEFAULT_STALE_REJECT_SECONDS, DEFAULT_TERMMAX_API, DEFAULT_TERM_ORDER_STORE, DOLOMITE_ISO_ID_PREFIX, EARN_DESCRIPTIONS, EARN_LABELS, EARN_RATE_SOURCE_BY_PROVIDER, EMPTY_BALANCE, EXACTLY_LENDER_KEY, EXPONENT_MATURED_REASON, FIXED_YIELD_EARN_VENUE_PREFIXES, FLYING_TULIP_LENDER_KEY, FRACTION_RATE_PROVIDERS, FUNDING_EXPOSURE_PROFILES, FUNDING_HEDGE_REFERENCE_USD, GMX_API_HOSTS, GMX_READ_CONTRACTS, GMX_SUPPORTED_CHAINS, HYPERCORE_VAULT_REGISTRY, IDLE_MARKET_ID, INTERFACE_IDS, LAGOON_API_URL, LAGOON_CHAIN_IDS, MORPHO_LENS, MULTICALL_FAILURE, MaxParamThresholds, NON_EVM_VAULT_PROVIDERS, PASSTHROUGH_RATE_EPSILON, PENDLE_ASSETS_URL, PENDLE_CHAIN_IDS, PENDLE_MARKETS_URL2 as PENDLE_MARKETS_URL, PREFIX_LENDERS, RATE_QUEUE_MAX_LEVELS, RATE_QUEUE_STEP, REFLECT_TRANCHE_SIDES, RIPE_LENDER_KEY, SDK_FRACTION_RATE_PROVIDERS, SPECTRA_NETWORKS, SPECTRA_RATE_MAX_PERCENT, SPECTRA_RATE_MIN_PERCENT, STABLECOIN_SYMBOLS, STCELO_MANAGER_ADDRESS, SVM_EARN_MINT_BUILDERS, SVM_EARN_VAULT_BUILDERS, SVM_SAVINGS_CURATION, SVM_VAULT_PROVIDERS, TELLER_CALLS_PER_BID, DECIMAL_BASE as TERMMAX_DECIMAL_BASE, TERMMAX_LIQUIDATION_PENALTY, TERMMAX_LIQUIDATION_WINDOW_SECS, TERMMAX_LIQUIDATOR_BONUS, TERMMAX_MARKETS_PER_CALL, TERMMAX_PARTIAL_CLOSE_FACTOR, TERMMAX_PARTIAL_LIQUIDATION_THRESHOLD_USD, TERM_ADAPTERS, TERM_PROFILES, TERM_SHEET_SCHEMA_VERSION, TermMaxApiSource, TermSubgraphSource, UPSHIFT_CHAIN_IDS, UPSHIFT_VAULTS_URL, USER_REWARD_SOURCES, USER_SET_RATE_PICKS, VAULT_PROVIDERS, VAULT_PROVIDER_PROFILE, VAULT_PROVIDER_TRAITS, VAULT_SHARE_PRICE_PROBE, VAULT_VENUE_PREFIX, VENUS_CORE_POOL_ID, VOLATILE_VAULT_OVERRIDES, VenusEModeAbi, YEARN_CHAIN_IDS, YEARN_YDAEMON_BASE, __resetResupplyUserCaches, accountDepositListKey, accountWithdrawalListKey, alchemixLenderKey, alchemixMytRate, alchemixRedemptionPace, appendSnapshot, applyEarnSanity, applyPositionDelta, attachImplications, attachPricesToFlashLiquidity, bandsForStance, blockNumberFromTag, borosApi, borosInitialMargin, borosMaintenanceMargin, borosRateMoveToLiquidation, borosSideTerms, borosTakerFee, borrowDescription, borrowFindings, borrowHeadline, buildBorosTermSheet, buildExposures2 as buildExposures, buildFluidFTokensCall, buildFundingHedgeTerms, buildLendingPositionUid, buildLiquityUserCall, buildLoopResult, buildMorphoTypeCall, buildMorphoTypeUserCallWithLens, buildPortfolioTotals, buildPositionChoices, buildQueriesFromMeta, buildRateQueue, buildSumerAccumulators, buildSummaries, buildTellerUserCall, buildTermMaxUserCall, buildTermSheet, buildTermSheetsForGroup, buildVaultEarnUid, buildVaultLookup, buildVaultTermSheet, calculateLeverage, calculateNetApr, calculateOverallNetApr, calculateWeightedAverage, classifyFreshness, classifyReliability, classifyVault, clearPendleMarketsCache, clearSpectraMarketsCache, collateralSymbolsByVenue, collectFeedObservations, computeBorrowDelta2 as computeBorrowDelta, computeCloseTradeDeltas, computeCollateralSwapDeltas, computeDebtSwapDeltas, computeDepositDelta2 as computeDepositDelta, computeEModeAnalysis, computeOpenTradeDeltas, computePostTradeMetrics, computeRepayDelta2 as computeRepayDelta, computeSumerBorrowDelta, computeSumerDepositDelta, computeSumerRepayDelta, computeSumerWaterfall, computeSumerWithdrawDelta, computeVaultApr, computeWithdrawDelta2 as computeWithdrawDelta, computeZapTradeDeltas, consensusReference, convertAlchemixMarketsToResponse, convertBorosCandle, convertBorosMarket, convertCoolerMarketsToResponse, convertDssMarketsToResponse, convertExactlyMarketsToResponse, convertFlexMarketsToResponse, convertFlyingTulipMarketsToResponse, convertFrankencoinMarketsToResponse, convertFraxlendPairsToResponse, convertInverseMarketsToResponse, convertLenderUserDataResult, convertLiquityMarketsToResponse, convertLlamaLendMarketsToResponse, convertResupplyMarketsToResponse, convertRipeMarketsToResponse, convertRiverMarketsToResponse, convertTellerMarketsToResponse, convertTermMarketsToResponse, convertTermMaxMarketsToResponse, convertUsddMarketsToResponse, createMarketUid, createMidnightBookSource, createMultiAccountTypeUserState, createMulticallRpcCall, createRawRpcCalls, createTermBookSource, createTermMaxDataSource, debtAheadOf, decodeListaMarkets, decodeMarkets, decodePackedListaUserDataset, decodePackedMorphoUserDataset, deriveBorrowTags, deriveSupplyTags, deriveSwapTags, detectInterfaceKinds, dexResolverFor, digestChoices, disambiguateEarnNames, disambiguateOrderBookNames, discoverFlexTroves, dolomiteVaultAddress, dssIlkBytes32, dssKeyParts, dssLenderKey, duration, earnDescription, earnLabel, earnMarketFromPool, earnMarketFromVault, earnMarketLabel, earnPositionFromLenderEntry, earnPositionFromVaultBalance, earnPositionTotals, earnRateAtMaturity, earnRowFundingProfile, earnRowSubtitle, earnUidFromMarketUid, earnVaultTerms, earnVenueKind, emitterCoverage, encodeBalanceFetcherCalldata, encodeChoiceValue, enrichTermSheet, enrichmentIndexFromRows, enumerateEmitters, exactlyPairLtv, exactlyPenaltyRateToAprPercent, exactlyWadRateToPercent, exponentTrancheDescription, feePhrase, feedKeyOf, feedStatKey, fetchAaveIncentivesUserRewards, fetchAlchemixMarkets, fetchBorosAccount, fetchBorosCollaterals, fetchBorosMarket, fetchBorosMarketById, fetchBorosMarkets, fetchBorosOrderBook, fetchBorosRateHistory, fetchCoolerMarkets, fetchDolomiteAccountNumbers, fetchDolomiteSubAccounts, fetchDssMarkets, fetchEulerEarnVaults, fetchEulerEarnVaultsFromSubgraph, fetchEulerSubAccountIndexes, fetchExactlyMarkets, fetchFlashLiquidityForChain, fetchFlexMarkets, fetchFluidDexState, fetchFluidFTokens, fetchFlyingTulipMarkets, fetchFlyingTulipUserRewards, fetchFrankencoinMarkets, fetchFraxlendPairs, fetchGeneralYields, fetchGeneralYieldsByMarketUid, fetchGmxExecutionFees, fetchGmxTickerPrices, fetchGmxVaults, fetchHypercoreVaults, fetchInverseMarkets, fetchLagoonApiVaults, fetchLagoonVaults, fetchLenderRewards, fetchLenderRewardsByMarketUid, fetchLiquityMarkets, fetchListaMarketEmissions, fetchListaUserRewards, fetchListaVaultEmissions, fetchListaVaultsFromChain, fetchLlamaLendMarkets, fetchMerklUserRewards, fetchMorphoUserBalances, fetchMorphoUserPositionMarkets, fetchMorphoVaults, fetchMorphoVaultsFromApi, fetchMorphoVaultsFromChain, fetchOraclePrices, fetchPendleApiAssets, fetchPendleApiMarkets, fetchPendlePrices, fetchPendlePtMarkets, fetchResupplyMarkets, fetchRipeMarkets, fetchRiverMarkets, fetchSiloVaults, fetchSpectraApiMarkets, fetchSpectraPtMarkets, fetchTellerMarkets, fetchTermMarkets, fetchTermMaxMarkets, fetchTermStoreOrders, fetchTokenBalances, fetchTokenMetadata, fetchUpshiftApiVaults, fetchUpshiftVaults, fetchUsddMarkets, fetchUserRewards, fetchUsualRewardsClaimData, fetchYearnApiVaults, fetchYearnVaults, fillCapacityAt, fillableRemaining, filterActiveLenders, filterLenderMeta, filterLendersByProtocol, finalizeInfo, findingsFor, flexAverageRate, flexLenderApr, flexLenderKey, flexMarketIndex, formatRaw, frankencoinKeyParts, frankencoinLenderKey, fraxlendAssetPerCollateral, fraxlendKeyParts, fraxlendLenderKey, fundingExposureOf, fundingSymbolBase, fuseLenderData, generateLendingPools, getAavesForChain, getAssetConfig, getBalanceForMarketUid, getBorrowCapacity, getCachedFluidDexState, getCachedLiquityTroves, getCachedTellerBids, getCachedTermMaxDiscovery, getCachedTermMaxMarket, getCachedTermMaxMarkets, getCoreValidators, getFluidFTokensConverter, getGmxApiHost, getGmxReadContracts, getGmxUserPositions, getHealthFactor, getHypercoreUserPositions, getHypercoreVaultRegistry, getLenderAssets, getLenderPublicData, getLenderPublicDataAll, getLenderPublicDataViaApi, getLenderUserDataMulti, getLenderUserDataResult, getLendersForChain, getLstDelegation, getLstValidators, getLstWithdrawalRegistry, getLstWithdrawalRequests, getMaxAmountClose, getMaxAmountCollateralSwap, getMaxAmountDebtSwap, getMaxAmountOpen, getMergedUserData, getMidnightChainBooks, getMorphoTypeMarketConverter, getReadFailurePolicy, getResolvedDolomiteAccountNumbers, getResolvedDolomiteSubAccounts, getStCeloValidatorGroups, getSubAccountAddress, getSubAccountIndex, getTermProfile, getVaultPublicDataAll, getVaultWithdrawalRequests, getVenusEModeSetup, hasCritical, hasEulerEarnVaultSubgraph, hasLagoonVaults, hasMorphoPositionIndex, hasMorphoUserApi, hasMorphoUserSubgraph, hasPendleMarkets, hasSpectraMarkets, hasUpshiftVaults, hasYearnVaults, ilkToKeySegment, implausibleRatePercent, injectLenderInfoIntoEntries, inverseKeyParts, inverseLenderKey, isBoundNeed, isFailedCall, isFixedYieldEarnRow, isIlliquid, isLenderVenueKey, isLendingPosition, isLiveMarket as isLivePendleMarket, isLiveSpectraMarket, isMaturedTerm, isOrderBookCollateralLeg, isOrderBookLendRow, isPrincipalTokenSymbol, isRollingBookLendRow, isSecondaryMarketOnly, isStablecoinSymbol, isSyntheticQuoteUnit, isUnearnableEarnRate, isUnrealizableEarnRate, isVaultPosition, isVaultVenue, isYearnV3, keySegmentToIlk, keysFromMaps, lenderApiOnly, lenderFamily, lenderLiquidityPressure, liquityCandidateTroveIds, liquityKeyParts, liquityLenderKey, listaEmissionRewardFetcher, listaLoginMessage, llamaLendKeyParts, llamaLendLenderKey, marketKeysOf, meetsLiquidityFloor, mergeDeep, multicall3Abi2 as multicall3Abi, nanTo, needsLenderApproval, needsTokenApproval, noOpResult, normalizeToBytes, organizeUserQueries, parameterLadder, parseBalanceFetcherResult, parseDolomiteSubAccountId, parseEarnUid, parseLenderKey, parseMergedResult, parseMulticallRpcResponses, parseExpirySeconds as parsePendleExpirySeconds, parseRawRpcBatchResponses, parseRawRpcResponses, parseCurveFee as parseSpectraCurveFee, parsePtRate as parseSpectraPtRate, parseTermMaxLtv, parseTokenBalanceResult, pct, pegPressure, assetKey as pendleAssetKey, pickRates, pickPool as pickSpectraPool, positivePart2 as positivePart, predictInverseEscrow, prepareLenderUserDataRpcCalls, prepareMergedMulticallParams, prepareMergedRpcCalls, prepareMulticallInputs, prepareTokenBalanceRpcCalls, priceGlvVaults, priceGmMarkets, probeAaveFeedTimestamps, protocolConsensus, protocolOf, pruneFeedStats, quoteBorosHedgeLeg, rankBorosHedgeMarkets, rankFindings, ratePercent, readLstPauseState, readTransmuterLots, readUserPositions, readVaultSharePrices, reflectTrancheDescription, rejectOutliers as rejectPriceOutliers, repairImpossibleTvl, resolveAdapter, resolveChoices, resolveDerivation, resolveDolomiteRowIdentity, resolveEarnIdentity, resolveMerklOpportunityMarkets, resolveModeConfig, resolveRatePicks, resolveStCeloDepositGroup, resolveStance, resolveVaultProfileId, resupplyKeyParts, resupplyLenderKey, resupplyMarketLabel, riverKeyParts, riverLenderKey, sanePercent as saneSpectraPercent, savingsAddresses, savingsBalanceKind, secondaryMarketVault, selectAssetGroupPrices, selectUsualRewardEntry, setMysticApiKey, shortDate, spectraAddress, spectraNetwork, spectraPoolsUrl, splitChainScopedAddress as splitPendleChainScopedAddress, stampCapabilities, stampEarnSubtitles, stampOrderBookLendRow, stampRollingBookLendRow, stampVaultClassification, stampVaultTermSheets, stripLeadingBrand, subAccountsOf, supplyDescription, supplyFindings, supplyHeadline, svmEarnBuildability, svmEarnBuilderKey, svmSavingsCuration, swapRoutedProvidersArePriceConsistent, swapSideDescription, swapSideHeadline, swapSideImplications, tellerBpsToPercent, tellerImpliedLtv, tellerLenderKey, tellerPoolFromLenderKey, termApiBaseUrl, termLenderKey, termMaxApiBase, borrowNif as termMaxBorrowNif, curveApr as termMaxCurveApr, curveAprNumber as termMaxCurveAprNumber, daysToMaturity as termMaxDaysToMaturity, lendNif as termMaxLendNif, mintGtFeeRatio as termMaxMintGtFeeRatio, ratioToNumber as termMaxRatioToNumber, ratioToPercent as termMaxRatioToPercent, termOfferRateToAprPct, termOrderStoreBaseUrl, tickToAprNumber, tickToPrice, toDigest, toDolomiteSubAccountId, toTermFillNow, toTermSheetInput, toVaultTermInput, trancheFromCounterparty, tryParseEarnUid, unflattenLenderData, updateFeedStats, usdValue, usddIlkBytes32, usddKeyParts, usddLenderKey, validateTermSheet, validateTermSheets, validateUserData, vaultSharesToAssets, vaultTermInputFromEarnMarket, vaultTermInputFromSourceRow, vaultTraits, vaultVenue, venueBrand, venueBrandKey, walkBorosBook, withMaturityLabel, withTrancheLabel };
|
|
106162
107621
|
//# sourceMappingURL=index.js.map
|
|
106163
107622
|
//# sourceMappingURL=index.js.map
|