@1delta/margin-fetcher 5.0.145 → 5.0.149
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 +12 -6
- package/dist/index.js +416 -45
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ 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, 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, 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
14
|
import { BALANCER_V2_FORKS, BALANCER_V3_FORKS, UNISWAP_V4_FORKS, isFlashLoanSourceExcluded, FLASH_LOAN_IDS } from '@1delta/dex-registry';
|
|
15
15
|
import { getNativeDecimals, getWrappedNativeAddressSafe, isNativeWrapOneToOne } from '@1delta/wnative';
|
|
@@ -29654,6 +29654,8 @@ function convertAlchemixMarketsToResponse(raw, chainId, prices = {}, additionalY
|
|
|
29654
29654
|
const mytRate = alchemixMytRate(m);
|
|
29655
29655
|
const mytPrice = priceOfAddr(myt2) || (mytRate != null && underlyingPrice > 0 ? mytRate * underlyingPrice : 0);
|
|
29656
29656
|
const debtPrice = underlyingPrice;
|
|
29657
|
+
const debtMarketPrice = priceOfAddr(debt);
|
|
29658
|
+
const debtSaleRatio = debtMarketPrice > 0 && debtPrice > 0 ? Math.min(1, debtMarketPrice / debtPrice) : 1;
|
|
29657
29659
|
const ltv = 1e18 / Number(m.minimumCollateralization);
|
|
29658
29660
|
const liqLtv = 1e18 / Number(m.collateralizationLowerBound);
|
|
29659
29661
|
const liqPenalty = m.liquidatorFee / BPS3 * Math.max(0, 1 / liqLtv - 1);
|
|
@@ -29757,7 +29759,14 @@ function convertAlchemixMarketsToResponse(raw, chainId, prices = {}, additionalY
|
|
|
29757
29759
|
category: 0,
|
|
29758
29760
|
borrowCollateralFactor: 0,
|
|
29759
29761
|
collateralFactor: 0,
|
|
29760
|
-
|
|
29762
|
+
// Borrow capacity weighs the debt at what it sells for (face /
|
|
29763
|
+
// market ≥ 1), so a loop's ceiling `1 / (1 − cf / bf)` is one that
|
|
29764
|
+
// can be built: at alUSD 0.956 that is 7.16×, not the 10× face LTV
|
|
29765
|
+
// implies (2026-11-03: a 7.8× open reverted the LTV check).
|
|
29766
|
+
// Liquidation weighs it at FACE, as the Alchemist does — the Venus
|
|
29767
|
+
// e-mode split of the two weights.
|
|
29768
|
+
borrowFactor: 1 / debtSaleRatio,
|
|
29769
|
+
liquidationBorrowFactor: 1,
|
|
29761
29770
|
liquidationPenalty: liqPenalty,
|
|
29762
29771
|
closeFactor: 1,
|
|
29763
29772
|
collateralDisabled: true,
|
|
@@ -57411,6 +57420,123 @@ var SUPERFORM_ENTRIES = (() => {
|
|
|
57411
57420
|
}
|
|
57412
57421
|
return out;
|
|
57413
57422
|
})();
|
|
57423
|
+
var HISTORY_URL2 = "https://api.ipor.io/v2/fusion/vault-history";
|
|
57424
|
+
var TIMEOUT_MS5 = 1e4;
|
|
57425
|
+
var MIN_WINDOW_SECONDS2 = 7 * 86400;
|
|
57426
|
+
var SECONDS_PER_YEAR16 = 365 * 86400;
|
|
57427
|
+
var iporFusionYieldKey = (chainId, vault) => `IPOR Fusion::${chainId}::${vault.toLowerCase()}`;
|
|
57428
|
+
var realizedAprFromHistory = (points) => {
|
|
57429
|
+
const usable = points.map((p) => ({
|
|
57430
|
+
t: p.blockTimestamp ? Date.parse(p.blockTimestamp) / 1e3 : NaN,
|
|
57431
|
+
r: Number(p.assetsToSharesRatio)
|
|
57432
|
+
})).filter((p) => Number.isFinite(p.t) && Number.isFinite(p.r) && p.r > 0).sort((a, b) => a.t - b.t);
|
|
57433
|
+
if (usable.length < 2) return void 0;
|
|
57434
|
+
const first = usable[0];
|
|
57435
|
+
const last = usable[usable.length - 1];
|
|
57436
|
+
const dt = last.t - first.t;
|
|
57437
|
+
if (dt < MIN_WINDOW_SECONDS2) return void 0;
|
|
57438
|
+
return (last.r / first.r - 1) * (SECONDS_PER_YEAR16 / dt) * 100;
|
|
57439
|
+
};
|
|
57440
|
+
var fetchHistory = async (chainId, vault) => {
|
|
57441
|
+
const res = await fetch(`${HISTORY_URL2}/${chainId}/${vault}-30d`, {
|
|
57442
|
+
headers: { Accept: "application/json" },
|
|
57443
|
+
signal: AbortSignal.timeout(TIMEOUT_MS5)
|
|
57444
|
+
});
|
|
57445
|
+
if (!res.ok) throw new Error(`ipor-fusion ${vault} \u2192 HTTP ${res.status}`);
|
|
57446
|
+
const body = await res.json();
|
|
57447
|
+
if (!Array.isArray(body?.history))
|
|
57448
|
+
throw new Error(`ipor-fusion ${vault}: no history[]`);
|
|
57449
|
+
return body.history;
|
|
57450
|
+
};
|
|
57451
|
+
var iporFusionFetcher = {
|
|
57452
|
+
label: "IPOR Fusion",
|
|
57453
|
+
fetch: async () => {
|
|
57454
|
+
const out = {};
|
|
57455
|
+
const results = await Promise.allSettled(
|
|
57456
|
+
IPOR_FUSION_VAULTS.map(async (v) => {
|
|
57457
|
+
const apr = realizedAprFromHistory(
|
|
57458
|
+
await fetchHistory(v.chainId, v.vault)
|
|
57459
|
+
);
|
|
57460
|
+
if (apr !== void 0) out[iporFusionYieldKey(v.chainId, v.vault)] = apr;
|
|
57461
|
+
})
|
|
57462
|
+
);
|
|
57463
|
+
const failed = results.filter((r) => r.status === "rejected");
|
|
57464
|
+
if (failed.length > 0)
|
|
57465
|
+
console.warn(
|
|
57466
|
+
`[ipor-fusion] ${failed.length}/${results.length} vault histories failed:`,
|
|
57467
|
+
failed[0].reason
|
|
57468
|
+
);
|
|
57469
|
+
return out;
|
|
57470
|
+
}
|
|
57471
|
+
};
|
|
57472
|
+
|
|
57473
|
+
// src/vaults/savings/registryIporFusion.ts
|
|
57474
|
+
var exitProse = (v, asset) => {
|
|
57475
|
+
const instant = v.instantFuses ? "Instant withdrawals first pull the money out of the lending markets, so they are bounded by those markets' liquidity." : `Instant withdrawals are paid only from idle ${asset}, a few percent of the vault at most, less a fee.`;
|
|
57476
|
+
if (v.withdrawWindowSeconds === 0)
|
|
57477
|
+
return `${instant} There is no queued exit on this vault.`;
|
|
57478
|
+
const window = v.withdrawWindowSeconds % 86400 === 0 ? `${v.withdrawWindowSeconds / 86400 === 1 ? "24 hours" : `${v.withdrawWindowSeconds / 86400} days`}` : `${Math.round(v.withdrawWindowSeconds / 3600)} hours`;
|
|
57479
|
+
return `${instant} Or request a withdrawal: the fee is taken at request, and IPOR's operator must release it and you must claim within ${window} of asking, or it lapses.`;
|
|
57480
|
+
};
|
|
57481
|
+
var IPOR_FUSION_PROSE = {
|
|
57482
|
+
"1:0xb9e806e8f2d94c015ffefa90cd24ecce18f1663c": `Measured in WETH: posts wstETH in a Liquity V2 trove, borrows BOLD and earns on it in Curve and Uniswap V4 pools. The debt is in dollars, so the share price moves with ETH as well as the carry, and the trove can be liquidated or redeemed.`,
|
|
57483
|
+
"1:0xb8a451107a9f87fde481d4d686247d6e43ed715e": `An stETH loop: stETH is collateral on Spark, Aave and Morpho with WETH borrowed against it, about nine times over. A borrow rate above the staking yield or an stETH depeg cuts the share price, and the loans can be liquidated.`,
|
|
57484
|
+
"1:0xb0f56bb0bf13ee05fef8cd2d8df5ffdfcac7a74f": `TAU's infiniFi vault: USDC becomes staked siUSD held as Morpho collateral, set up to borrow and loop for infiniFi points. It earns siUSD's rate, with the borrow cost and liquidation risk whenever it is levered.`,
|
|
57485
|
+
"1:0xf8f226da66244f89e70c5b5d1a5c5b0d505eb1d8": `A USDC vault holding wsBTCD, a Bitcoin-backed dollar, as Morpho collateral and BORROWING WBTC against it \u2014 short Bitcoin: the share price falls when BTC rises, and the loan can be liquidated.`,
|
|
57486
|
+
"1:0x7659fc26bf3a63e8133bbecb7e16acd48ee8e292": `Measured in WBTC: posts WBTC on Morpho, borrows USDC and deposits it into another Fusion vault (Bitcoin Dollar USDC). The debt is in dollars, so the share price moves with BTC as well as the carry, and the loan can be liquidated.`,
|
|
57487
|
+
"1:0xe9385eff3f937fcb0f0085da9a3f53d6c2b4fb5f": `A Reservoir srUSD loop: wsrUSD is Morpho collateral with USDC borrowed against it, about five times over. A USDC rate above srUSD's or an srUSD/rUSD depeg cuts the share price, and the loan can be liquidated.`,
|
|
57488
|
+
"8453:0x17d0f109ee895bad0b68aa104aa72bd0b003ad8e": `A WETH lending optimizer on Base: supplies lending markets (Euler today) and moves between them for the best rate, with no borrowing.`,
|
|
57489
|
+
"8453:0xe883426b4fc84a7f5cc86415cabbef43e73a4cc8": `TAU's cbETH loop on Base: cbETH is collateral on Aave, Morpho and Euler with WETH borrowed against it, about nine times over. A borrow rate above the staking yield or a cbETH depeg cuts the share price, and the loans can be liquidated.`,
|
|
57490
|
+
"8453:0x7872893e528fe2c0829e405960db5b742112aa97": `Harvest's Autopilot WETH vault on Base: WETH is spread across Harvest's lending vaults for the best supply rate, with no borrowing.`,
|
|
57491
|
+
"8453:0x5900c3b72458f12967dc1bef35b92d271f5cdbc1": `A cbETH loop on Base measured in WETH: cbETH is collateral on Aave, Morpho and Euler with WETH borrowed, about six times over. A borrow rate above the staking yield or a cbETH depeg cuts the share price; loans can be liquidated.`,
|
|
57492
|
+
"8453:0xd46a3c2d958d0a2cb098d48c48dc19fe3a710f37": `A USDC lending optimizer on Base: supplies Morpho markets and moves between them for the best rate, with no borrowing.`,
|
|
57493
|
+
"8453:0x0d877dc7c8fa3ad980dfdb18b48ec9f8768359c4": `Harvest's Autopilot USDC vault on Base: USDC is spread across Harvest's lending vaults for the best supply rate, with no borrowing.`
|
|
57494
|
+
};
|
|
57495
|
+
var IPOR_FUSION_ASSET = {
|
|
57496
|
+
"1:0xb9e806e8f2d94c015ffefa90cd24ecce18f1663c": "WETH",
|
|
57497
|
+
"1:0xb8a451107a9f87fde481d4d686247d6e43ed715e": "stETH",
|
|
57498
|
+
"1:0xb0f56bb0bf13ee05fef8cd2d8df5ffdfcac7a74f": "USDC",
|
|
57499
|
+
"1:0x7659fc26bf3a63e8133bbecb7e16acd48ee8e292": "WBTC",
|
|
57500
|
+
"1:0xe9385eff3f937fcb0f0085da9a3f53d6c2b4fb5f": "rUSD",
|
|
57501
|
+
"8453:0xe883426b4fc84a7f5cc86415cabbef43e73a4cc8": "cbETH",
|
|
57502
|
+
"8453:0x5900c3b72458f12967dc1bef35b92d271f5cdbc1": "WETH"
|
|
57503
|
+
};
|
|
57504
|
+
IPOR_FUSION_VAULTS.filter(
|
|
57505
|
+
(v) => v.strategy !== "lending"
|
|
57506
|
+
).map((v) => `${v.chainId}-${v.vault}`);
|
|
57507
|
+
var toEntry2 = (v) => ({
|
|
57508
|
+
reader: "ipor-fusion",
|
|
57509
|
+
address: v.vault,
|
|
57510
|
+
underlying: v.underlying,
|
|
57511
|
+
symbol: v.symbol,
|
|
57512
|
+
label: v.name,
|
|
57513
|
+
brand: v.brand,
|
|
57514
|
+
description: IPOR_FUSION_PROSE[`${v.chainId}:${v.vault}`] ? `${IPOR_FUSION_PROSE[`${v.chainId}:${v.vault}`]} ${exitProse(v, IPOR_FUSION_ASSET[`${v.chainId}:${v.vault}`] ?? "cash")}` : "",
|
|
57515
|
+
decimals: v.decimals,
|
|
57516
|
+
underlyingDecimals: v.underlyingDecimals,
|
|
57517
|
+
isRebasing: false,
|
|
57518
|
+
isMintable: true,
|
|
57519
|
+
// A zero withdraw window (both Autopilot vaults) makes every request
|
|
57520
|
+
// unclaimable: those rows have the instant leg only.
|
|
57521
|
+
withdrawalMode: v.withdrawWindowSeconds === 0 ? "instant-capped" : "fee-or-queued",
|
|
57522
|
+
feeScheduleCheckedAt: "2026-10-30",
|
|
57523
|
+
iporFusion: {
|
|
57524
|
+
accessManager: v.accessManager,
|
|
57525
|
+
withdrawManager: v.withdrawManager,
|
|
57526
|
+
instantFuses: v.instantFuses
|
|
57527
|
+
},
|
|
57528
|
+
withdrawQueue: v.withdrawManager,
|
|
57529
|
+
yieldFetcher: iporFusionFetcher,
|
|
57530
|
+
yieldKey: iporFusionYieldKey(v.chainId, v.vault)
|
|
57531
|
+
});
|
|
57532
|
+
var IPOR_FUSION_ENTRIES = (() => {
|
|
57533
|
+
const out = {};
|
|
57534
|
+
for (const v of IPOR_FUSION_VAULTS) {
|
|
57535
|
+
if (!out[v.chainId]) out[v.chainId] = [];
|
|
57536
|
+
out[v.chainId].push(toEntry2(v));
|
|
57537
|
+
}
|
|
57538
|
+
return out;
|
|
57539
|
+
})();
|
|
57414
57540
|
var L2SD_YIELD_KEYS = {
|
|
57415
57541
|
limUSD: "limUSD::LIMUSD",
|
|
57416
57542
|
haHYPE: "haHYPE::haHYPE",
|
|
@@ -57850,7 +57976,7 @@ var L2SD_ENTRIES = {
|
|
|
57850
57976
|
|
|
57851
57977
|
// src/yields/intrinsic/fetchers/royco.ts
|
|
57852
57978
|
var ROYCO_POOLS_URL = "https://vault.api.royco.org/api/v1/defillama/pools";
|
|
57853
|
-
var
|
|
57979
|
+
var TIMEOUT_MS6 = 8e3;
|
|
57854
57980
|
var ROY_ST_APYUSD_KEY = "Royco Senior Tranche apyUSD::ROY-ST-apyUSD";
|
|
57855
57981
|
var ROY_JT_APYUSD_KEY = "Royco Junior Tranche apyUSD::ROY-JT-apyUSD";
|
|
57856
57982
|
var ROYCO_POOLS = {
|
|
@@ -57874,7 +58000,7 @@ var roycoFetcher = {
|
|
|
57874
58000
|
fetch: async () => {
|
|
57875
58001
|
const res = await fetch(ROYCO_POOLS_URL, {
|
|
57876
58002
|
headers: { accept: "application/json" },
|
|
57877
|
-
signal: AbortSignal.timeout(
|
|
58003
|
+
signal: AbortSignal.timeout(TIMEOUT_MS6)
|
|
57878
58004
|
});
|
|
57879
58005
|
if (!res.ok) throw new Error(`Royco pools HTTP ${res.status}`);
|
|
57880
58006
|
const data = await res.json();
|
|
@@ -59408,7 +59534,7 @@ var ROWS = [
|
|
|
59408
59534
|
)
|
|
59409
59535
|
}
|
|
59410
59536
|
];
|
|
59411
|
-
var
|
|
59537
|
+
var toEntry3 = (r) => ({
|
|
59412
59538
|
reader: "alchemix-transmuter",
|
|
59413
59539
|
address: r.transmuter,
|
|
59414
59540
|
underlying: r.alAsset,
|
|
@@ -59438,7 +59564,7 @@ var toEntry2 = (r) => ({
|
|
|
59438
59564
|
alchemixTransmuter: r.cfg
|
|
59439
59565
|
});
|
|
59440
59566
|
var ALCHEMIX_TRANSMUTER_ENTRIES = ROWS.reduce((out, r) => {
|
|
59441
|
-
(out[r.chainId] ??= []).push(
|
|
59567
|
+
(out[r.chainId] ??= []).push(toEntry3(r));
|
|
59442
59568
|
return out;
|
|
59443
59569
|
}, {});
|
|
59444
59570
|
var CHAIN_ID19 = "1";
|
|
@@ -63567,6 +63693,10 @@ var SAVINGS_REGISTRY = (() => {
|
|
|
63567
63693
|
if (!out[chainId]) out[chainId] = [];
|
|
63568
63694
|
out[chainId].push(...entries);
|
|
63569
63695
|
}
|
|
63696
|
+
for (const [chainId, entries] of Object.entries(IPOR_FUSION_ENTRIES)) {
|
|
63697
|
+
if (!out[chainId]) out[chainId] = [];
|
|
63698
|
+
out[chainId].push(...entries);
|
|
63699
|
+
}
|
|
63570
63700
|
for (const [chainId, entries] of Object.entries(LLAMA_GAP_ENTRIES)) {
|
|
63571
63701
|
if (!out[chainId]) out[chainId] = [];
|
|
63572
63702
|
out[chainId].push(...entries);
|
|
@@ -65706,7 +65836,7 @@ var exponentTrancheFetcher = {
|
|
|
65706
65836
|
|
|
65707
65837
|
// src/yields/intrinsic/fetchers/loopscaleVaultShares.ts
|
|
65708
65838
|
var LOOPSCALE_VAULTS_INFO = "https://tars.loopscale.com/v1/markets/lending_vaults/info";
|
|
65709
|
-
var
|
|
65839
|
+
var SECONDS_PER_YEAR17 = 31536e3;
|
|
65710
65840
|
var CBPS = 1e6;
|
|
65711
65841
|
var MAX_PLAUSIBLE_APR_PERCENT = 50;
|
|
65712
65842
|
var LOOPSCALE_SHARE_ROSTER = [
|
|
@@ -65723,7 +65853,7 @@ function loopscaleShareApr(v, nowSec9 = Math.floor(Date.now() / 1e3)) {
|
|
|
65723
65853
|
const tvlRaw = n(s.tokenBalance) + n(s.externalYieldAmount) + n(s.currentDeployedAmount) + n(s.outstandingInterestAmount);
|
|
65724
65854
|
if (!(tvlRaw > 0)) return void 0;
|
|
65725
65855
|
const extApr = n(v.vaultStrategy?.externalYieldInfo?.apy) / CBPS;
|
|
65726
|
-
const gross = (n(s.interestPerSecond) *
|
|
65856
|
+
const gross = (n(s.interestPerSecond) * SECONDS_PER_YEAR17 + extApr * n(s.externalYieldAmount)) / tvlRaw * 100;
|
|
65727
65857
|
const net = gross * (1 - n(s.interestFee) / CBPS);
|
|
65728
65858
|
const principal = s.principalMint ?? v.vault?.principalMint;
|
|
65729
65859
|
let stream = 0;
|
|
@@ -65732,7 +65862,7 @@ function loopscaleShareApr(v, nowSec9 = Math.floor(Date.now() / 1e3)) {
|
|
|
65732
65862
|
const start = n(r.rewardStartTime);
|
|
65733
65863
|
const end = n(r.rewardEndTime);
|
|
65734
65864
|
if (!(nowSec9 >= start && nowSec9 <= end)) continue;
|
|
65735
|
-
stream += n(r.emissionsPerSecond) *
|
|
65865
|
+
stream += n(r.emissionsPerSecond) * SECONDS_PER_YEAR17 / tvlRaw * 100;
|
|
65736
65866
|
}
|
|
65737
65867
|
const apr = net + stream;
|
|
65738
65868
|
if (!Number.isFinite(apr) || apr < 0 || apr > MAX_PLAUSIBLE_APR_PERCENT)
|
|
@@ -66295,7 +66425,7 @@ function distressedEntries(chainId, tokenList, raw, usdPrices) {
|
|
|
66295
66425
|
var PENDLE_PT_PRICES_URL = "https://api-v2.pendle.finance/core/v1/prices/assets?type=PT";
|
|
66296
66426
|
var PENDLE_PRICE_KEY = "PENDLE";
|
|
66297
66427
|
var CACHE_MS = 6e4;
|
|
66298
|
-
var
|
|
66428
|
+
var TIMEOUT_MS7 = 1e4;
|
|
66299
66429
|
var cached = {
|
|
66300
66430
|
at: 0,
|
|
66301
66431
|
prices: Promise.resolve(null)
|
|
@@ -66306,7 +66436,7 @@ function fetchPendlePtPricesRaw() {
|
|
|
66306
66436
|
const prices = (async () => {
|
|
66307
66437
|
try {
|
|
66308
66438
|
const res = await fetch(PENDLE_PT_PRICES_URL, {
|
|
66309
|
-
signal: AbortSignal.timeout(
|
|
66439
|
+
signal: AbortSignal.timeout(TIMEOUT_MS7)
|
|
66310
66440
|
});
|
|
66311
66441
|
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
66312
66442
|
const data = await res.json();
|
|
@@ -66348,9 +66478,9 @@ function fetchPendleUnderlyingPricesRaw() {
|
|
|
66348
66478
|
const prices = (async () => {
|
|
66349
66479
|
try {
|
|
66350
66480
|
const [mRes, pRes] = await Promise.all([
|
|
66351
|
-
fetch(PENDLE_MARKETS_URL, { signal: AbortSignal.timeout(
|
|
66481
|
+
fetch(PENDLE_MARKETS_URL, { signal: AbortSignal.timeout(TIMEOUT_MS7) }),
|
|
66352
66482
|
fetch(PENDLE_ALL_PRICES_URL, {
|
|
66353
|
-
signal: AbortSignal.timeout(
|
|
66483
|
+
signal: AbortSignal.timeout(TIMEOUT_MS7)
|
|
66354
66484
|
})
|
|
66355
66485
|
]);
|
|
66356
66486
|
if (!mRes.ok) throw new Error(`markets HTTP ${mRes.status}`);
|
|
@@ -66517,7 +66647,7 @@ function fetchPendleAssetPricesRaw() {
|
|
|
66517
66647
|
const prices = (async () => {
|
|
66518
66648
|
try {
|
|
66519
66649
|
const res = await fetch(PENDLE_ALL_PRICES_URL, {
|
|
66520
|
-
signal: AbortSignal.timeout(
|
|
66650
|
+
signal: AbortSignal.timeout(TIMEOUT_MS7)
|
|
66521
66651
|
});
|
|
66522
66652
|
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
66523
66653
|
const data = await res.json();
|
|
@@ -67982,7 +68112,7 @@ var DLEND_POOLS = [
|
|
|
67982
68112
|
}
|
|
67983
68113
|
];
|
|
67984
68114
|
var ZERO_ADDRESS8 = "0x0000000000000000000000000000000000000000";
|
|
67985
|
-
var
|
|
68115
|
+
var SECONDS_PER_YEAR18 = 31536e3;
|
|
67986
68116
|
var ABI2 = [
|
|
67987
68117
|
{
|
|
67988
68118
|
name: "getReservesList",
|
|
@@ -68123,7 +68253,7 @@ function rebateApr(params) {
|
|
|
68123
68253
|
if (nowSeconds2 >= Number(distributionEnd)) return 0;
|
|
68124
68254
|
if (emissionPerSecond <= 0n || balanceTotalSupply <= 0n) return 0;
|
|
68125
68255
|
if (!(rewardPrice > 0) || !(assetPrice > 0)) return 0;
|
|
68126
|
-
const rewardsPerYearUsd = scale(emissionPerSecond, rewardDecimals) *
|
|
68256
|
+
const rewardsPerYearUsd = scale(emissionPerSecond, rewardDecimals) * SECONDS_PER_YEAR18 * rewardPrice;
|
|
68127
68257
|
const baseUsd = scale(balanceTotalSupply, balanceDecimals) * assetPrice;
|
|
68128
68258
|
if (!(baseUsd > 0)) return 0;
|
|
68129
68259
|
return rewardsPerYearUsd / baseUsd * 100;
|
|
@@ -68311,7 +68441,7 @@ var dtrinityRebateRewardFetcher = {
|
|
|
68311
68441
|
return { byLender: merged };
|
|
68312
68442
|
}
|
|
68313
68443
|
};
|
|
68314
|
-
var
|
|
68444
|
+
var SECONDS_PER_YEAR19 = 31536e3;
|
|
68315
68445
|
var MAX_EPOCH_AGE_SECONDS = 7 * 86400;
|
|
68316
68446
|
var EPOCH_LOOKBACK = 8;
|
|
68317
68447
|
var FT_DECIMALS = 18;
|
|
@@ -68396,7 +68526,7 @@ function ftEmissionApr(params) {
|
|
|
68396
68526
|
const ftUsd = Number(ft) / 10 ** FT_DECIMALS * ftPriceUsd;
|
|
68397
68527
|
const usdSeconds = Number(supplyTime) / 10 ** assetDecimals * assetPriceUsd;
|
|
68398
68528
|
if (!(usdSeconds > 0)) return 0;
|
|
68399
|
-
return ftUsd / usdSeconds *
|
|
68529
|
+
return ftUsd / usdSeconds * SECONDS_PER_YEAR19 * 100;
|
|
68400
68530
|
}
|
|
68401
68531
|
async function rosterFor(chainId) {
|
|
68402
68532
|
const fromMeta = flyingTulipAssetsFor(LENDER2, chainId)?.assets ?? [];
|
|
@@ -68833,7 +68963,7 @@ var listaEmissionRewardFetcher = {
|
|
|
68833
68963
|
return { byLender: merged };
|
|
68834
68964
|
}
|
|
68835
68965
|
};
|
|
68836
|
-
var
|
|
68966
|
+
var SECONDS_PER_YEAR20 = 31536e3;
|
|
68837
68967
|
var WAD17 = 10n ** 18n;
|
|
68838
68968
|
var ZERO6 = "0x0000000000000000000000000000000000000000";
|
|
68839
68969
|
var UNBOOSTED_FACTOR = 0.4;
|
|
@@ -68941,7 +69071,7 @@ function crvGaugeApr(params) {
|
|
|
68941
69071
|
return 0;
|
|
68942
69072
|
}
|
|
68943
69073
|
if (!(crvPriceUsd > 0) || !(assetPriceUsd > 0)) return 0;
|
|
68944
|
-
const crvPerYear = scale2(inflationRate, 18) * scale2(relativeWeight, 18) *
|
|
69074
|
+
const crvPerYear = scale2(inflationRate, 18) * scale2(relativeWeight, 18) * SECONDS_PER_YEAR20;
|
|
68945
69075
|
const stakedUsd = scale2(workingSupply, 18) * scale2(pricePerShare, 18) * assetPriceUsd;
|
|
68946
69076
|
if (!(stakedUsd > 0)) return 0;
|
|
68947
69077
|
return crvPerYear * crvPriceUsd / stakedUsd * 100 * UNBOOSTED_FACTOR;
|
|
@@ -68960,7 +69090,7 @@ function extraRewardApr(params) {
|
|
|
68960
69090
|
if (nowSeconds2 >= Number(periodFinish)) return 0;
|
|
68961
69091
|
if (rate <= 0n || totalSupply <= 0n) return 0;
|
|
68962
69092
|
if (!(rewardPriceUsd > 0) || !(assetPriceUsd > 0)) return 0;
|
|
68963
|
-
const rewardPerYearUsd = scale2(rate, rewardDecimals) *
|
|
69093
|
+
const rewardPerYearUsd = scale2(rate, rewardDecimals) * SECONDS_PER_YEAR20 * rewardPriceUsd;
|
|
68964
69094
|
const stakedUsd = scale2(totalSupply, 18) * scale2(pricePerShare, 18) * assetPriceUsd;
|
|
68965
69095
|
if (!(stakedUsd > 0)) return 0;
|
|
68966
69096
|
return rewardPerYearUsd / stakedUsd * 100;
|
|
@@ -70023,7 +70153,7 @@ async function markClaimSupport2(account, rewards, opts) {
|
|
|
70023
70153
|
}
|
|
70024
70154
|
var MERKL_API = "https://api.merkl.xyz/v4";
|
|
70025
70155
|
var MERKL_DISTRIBUTOR = "0x3ef3d8ba38ebe18db133cec108f4d14ce00dd9ae";
|
|
70026
|
-
var
|
|
70156
|
+
var TIMEOUT_MS8 = 8e3;
|
|
70027
70157
|
var OPP_CONCURRENCY = 8;
|
|
70028
70158
|
var ROOT_ABI = [
|
|
70029
70159
|
{
|
|
@@ -70046,7 +70176,7 @@ function fetchOpportunity(id, f) {
|
|
|
70046
70176
|
let p = oppCache2.get(id);
|
|
70047
70177
|
if (!p) {
|
|
70048
70178
|
p = f(`${MERKL_API}/opportunities/${id}`, {
|
|
70049
|
-
signal: AbortSignal.timeout(
|
|
70179
|
+
signal: AbortSignal.timeout(TIMEOUT_MS8)
|
|
70050
70180
|
}).then((r) => r.ok ? r.json() : void 0).catch(() => void 0);
|
|
70051
70181
|
p.then((o) => {
|
|
70052
70182
|
if (!o) oppCache2.delete(id);
|
|
@@ -70077,7 +70207,7 @@ async function fetchMerklUserRewards(account, chainIds, resolve, opts = {}) {
|
|
|
70077
70207
|
try {
|
|
70078
70208
|
const q = chainIds.map((c) => `chainId=${encodeURIComponent(c)}`).join("&");
|
|
70079
70209
|
const res = await f(`${MERKL_API}/users/${account}/rewards?${q}`, {
|
|
70080
|
-
signal: AbortSignal.timeout(
|
|
70210
|
+
signal: AbortSignal.timeout(TIMEOUT_MS8)
|
|
70081
70211
|
});
|
|
70082
70212
|
if (!res.ok) throw new Error(`Merkl API ${res.status}`);
|
|
70083
70213
|
const json = await res.json();
|
|
@@ -78335,7 +78465,7 @@ function computeSiloUtilization(vaultId, totalAssetsFormatted, positionsByVault,
|
|
|
78335
78465
|
}
|
|
78336
78466
|
var clamp012 = (n) => !Number.isFinite(n) ? 0 : n < 0 ? 0 : n > 1 ? 1 : n;
|
|
78337
78467
|
var PERFORMANCE_FEE_SCALE = 1e16;
|
|
78338
|
-
var
|
|
78468
|
+
var SECONDS_PER_YEAR21 = 31536e3;
|
|
78339
78469
|
function buildVaultRewards(vaultId, totalAssetsUsd, programsByShareToken, priceOf2, nowSeconds2) {
|
|
78340
78470
|
const programs = programsByShareToken.get(vaultId) ?? [];
|
|
78341
78471
|
const rewards = [];
|
|
@@ -78351,7 +78481,7 @@ function buildVaultRewards(vaultId, totalAssetsUsd, programsByShareToken, priceO
|
|
|
78351
78481
|
const tokenPrice = tokenAddress ? priceOf2(tokenAddress) : 0;
|
|
78352
78482
|
let apr;
|
|
78353
78483
|
if (tokenPrice > 0 && totalAssetsUsd > 0) {
|
|
78354
|
-
const annualTokens = emission / 10 ** tokenDecimals *
|
|
78484
|
+
const annualTokens = emission / 10 ** tokenDecimals * SECONDS_PER_YEAR21;
|
|
78355
78485
|
apr = annualTokens * tokenPrice / totalAssetsUsd * 100;
|
|
78356
78486
|
rewardsRate += apr;
|
|
78357
78487
|
} else {
|
|
@@ -86868,6 +86998,110 @@ var SuperformStrategyConfigAbi = [
|
|
|
86868
86998
|
}
|
|
86869
86999
|
];
|
|
86870
87000
|
|
|
87001
|
+
// src/vaults/savings/abis/iporFusion.ts
|
|
87002
|
+
var PlasmaVaultReadAbi = [
|
|
87003
|
+
{
|
|
87004
|
+
name: "totalSupply",
|
|
87005
|
+
type: "function",
|
|
87006
|
+
stateMutability: "view",
|
|
87007
|
+
inputs: [],
|
|
87008
|
+
outputs: [{ type: "uint256" }]
|
|
87009
|
+
},
|
|
87010
|
+
{
|
|
87011
|
+
name: "maxDeposit",
|
|
87012
|
+
type: "function",
|
|
87013
|
+
stateMutability: "view",
|
|
87014
|
+
inputs: [{ type: "address", name: "receiver" }],
|
|
87015
|
+
outputs: [{ type: "uint256" }]
|
|
87016
|
+
},
|
|
87017
|
+
{
|
|
87018
|
+
name: "previewDeposit",
|
|
87019
|
+
type: "function",
|
|
87020
|
+
stateMutability: "view",
|
|
87021
|
+
inputs: [{ type: "uint256", name: "assets" }],
|
|
87022
|
+
outputs: [{ type: "uint256" }]
|
|
87023
|
+
},
|
|
87024
|
+
{
|
|
87025
|
+
name: "convertToShares",
|
|
87026
|
+
type: "function",
|
|
87027
|
+
stateMutability: "view",
|
|
87028
|
+
inputs: [{ type: "uint256", name: "assets" }],
|
|
87029
|
+
outputs: [{ type: "uint256" }]
|
|
87030
|
+
},
|
|
87031
|
+
{
|
|
87032
|
+
name: "getPerformanceFeeData",
|
|
87033
|
+
type: "function",
|
|
87034
|
+
stateMutability: "view",
|
|
87035
|
+
inputs: [],
|
|
87036
|
+
outputs: [
|
|
87037
|
+
{ type: "address", name: "feeAccount" },
|
|
87038
|
+
{ type: "uint16", name: "feeInPercentage" }
|
|
87039
|
+
]
|
|
87040
|
+
},
|
|
87041
|
+
{
|
|
87042
|
+
name: "getManagementFeeData",
|
|
87043
|
+
type: "function",
|
|
87044
|
+
stateMutability: "view",
|
|
87045
|
+
inputs: [],
|
|
87046
|
+
outputs: [
|
|
87047
|
+
{ type: "address", name: "feeAccount" },
|
|
87048
|
+
{ type: "uint16", name: "feeInPercentage" },
|
|
87049
|
+
{ type: "uint32", name: "lastUpdateTimestamp" }
|
|
87050
|
+
]
|
|
87051
|
+
}
|
|
87052
|
+
];
|
|
87053
|
+
var FusionAccessManagerReadAbi = [
|
|
87054
|
+
{
|
|
87055
|
+
name: "getTargetFunctionRole",
|
|
87056
|
+
type: "function",
|
|
87057
|
+
stateMutability: "view",
|
|
87058
|
+
inputs: [
|
|
87059
|
+
{ type: "address", name: "target" },
|
|
87060
|
+
{ type: "bytes4", name: "selector" }
|
|
87061
|
+
],
|
|
87062
|
+
outputs: [{ type: "uint64" }]
|
|
87063
|
+
},
|
|
87064
|
+
{
|
|
87065
|
+
name: "isTargetClosed",
|
|
87066
|
+
type: "function",
|
|
87067
|
+
stateMutability: "view",
|
|
87068
|
+
inputs: [{ type: "address", name: "target" }],
|
|
87069
|
+
outputs: [{ type: "bool" }]
|
|
87070
|
+
}
|
|
87071
|
+
];
|
|
87072
|
+
var FusionWithdrawManagerReadAbi = [
|
|
87073
|
+
{
|
|
87074
|
+
name: "getWithdrawFee",
|
|
87075
|
+
type: "function",
|
|
87076
|
+
stateMutability: "view",
|
|
87077
|
+
inputs: [],
|
|
87078
|
+
outputs: [{ type: "uint256" }]
|
|
87079
|
+
},
|
|
87080
|
+
{
|
|
87081
|
+
name: "getRequestFee",
|
|
87082
|
+
type: "function",
|
|
87083
|
+
stateMutability: "view",
|
|
87084
|
+
inputs: [],
|
|
87085
|
+
outputs: [{ type: "uint256" }]
|
|
87086
|
+
},
|
|
87087
|
+
{
|
|
87088
|
+
name: "getSharesToRelease",
|
|
87089
|
+
type: "function",
|
|
87090
|
+
stateMutability: "view",
|
|
87091
|
+
inputs: [],
|
|
87092
|
+
outputs: [{ type: "uint256" }]
|
|
87093
|
+
}
|
|
87094
|
+
];
|
|
87095
|
+
var FusionBalanceOfAbi = [
|
|
87096
|
+
{
|
|
87097
|
+
name: "balanceOf",
|
|
87098
|
+
type: "function",
|
|
87099
|
+
stateMutability: "view",
|
|
87100
|
+
inputs: [{ type: "address", name: "account" }],
|
|
87101
|
+
outputs: [{ type: "uint256" }]
|
|
87102
|
+
}
|
|
87103
|
+
];
|
|
87104
|
+
|
|
86871
87105
|
// src/vaults/savings/abis/ember.ts
|
|
86872
87106
|
var EmberMaxDepositAbi = [
|
|
86873
87107
|
{
|
|
@@ -87849,7 +88083,7 @@ var readerHyperbeatVault = (entry2) => {
|
|
|
87849
88083
|
|
|
87850
88084
|
// src/vaults/savings/readers/listaRwaPool.ts
|
|
87851
88085
|
var PERIOD_SECONDS = 7n * 86400n;
|
|
87852
|
-
var
|
|
88086
|
+
var SECONDS_PER_YEAR22 = 365n * 86400n;
|
|
87853
88087
|
var readerListaRwaPool = (entry2) => {
|
|
87854
88088
|
const shareUnit = 10n ** BigInt(entry2.decimals);
|
|
87855
88089
|
const underlyingUnit = 10n ** BigInt(entry2.underlyingDecimals ?? entry2.decimals);
|
|
@@ -87882,7 +88116,7 @@ var readerListaRwaPool = (entry2) => {
|
|
|
87882
88116
|
const rewards = toBigInt16(periodRewards);
|
|
87883
88117
|
const supplyRate = rewards !== void 0 && rewards > 0n && totalAssets > 0n ? (
|
|
87884
88118
|
// percent, nominal: rewards per period → per year ÷ TVL.
|
|
87885
|
-
Number(rewards *
|
|
88119
|
+
Number(rewards * SECONDS_PER_YEAR22 * 1000000n / PERIOD_SECONDS) / Number(totalAssets) / 1e4
|
|
87886
88120
|
) : void 0;
|
|
87887
88121
|
return {
|
|
87888
88122
|
totalAssets,
|
|
@@ -88627,8 +88861,117 @@ var readerSuperformVault = (entry2) => {
|
|
|
88627
88861
|
};
|
|
88628
88862
|
};
|
|
88629
88863
|
|
|
88630
|
-
// src/vaults/savings/readers/
|
|
88864
|
+
// src/vaults/savings/readers/iporFusion.ts
|
|
88631
88865
|
var NEUTRAL_PROBE4 = "0x000000000000000000000000000000000000dead";
|
|
88866
|
+
var DEPOSIT_SELECTOR = "0x6e553f65";
|
|
88867
|
+
var PUBLIC_ROLE = 2n ** 64n - 1n;
|
|
88868
|
+
var WAD18 = 10n ** 18n;
|
|
88869
|
+
var readerIporFusion = (entry2) => {
|
|
88870
|
+
const cfg = entry2.iporFusion;
|
|
88871
|
+
const shareUnit = 10n ** BigInt(entry2.decimals);
|
|
88872
|
+
const underlyingUnit = 10n ** BigInt(entry2.underlyingDecimals ?? entry2.decimals);
|
|
88873
|
+
const v = entry2.address;
|
|
88874
|
+
const am = cfg?.accessManager;
|
|
88875
|
+
const wm = cfg?.withdrawManager;
|
|
88876
|
+
return {
|
|
88877
|
+
calls: [
|
|
88878
|
+
{ address: v, name: "totalAssets", params: [] },
|
|
88879
|
+
{ address: v, name: "totalSupply", params: [] },
|
|
88880
|
+
{ address: v, name: "convertToAssets", params: [shareUnit] },
|
|
88881
|
+
{ address: v, name: "maxDeposit", params: [NEUTRAL_PROBE4] },
|
|
88882
|
+
{ address: v, name: "previewDeposit", params: [underlyingUnit] },
|
|
88883
|
+
{ address: v, name: "convertToShares", params: [underlyingUnit] },
|
|
88884
|
+
{ address: v, name: "getPerformanceFeeData", params: [] },
|
|
88885
|
+
{ address: v, name: "getManagementFeeData", params: [] },
|
|
88886
|
+
{ address: entry2.underlying, name: "balanceOf", params: [v] },
|
|
88887
|
+
...am ? [
|
|
88888
|
+
{
|
|
88889
|
+
address: am,
|
|
88890
|
+
name: "getTargetFunctionRole",
|
|
88891
|
+
params: [v, DEPOSIT_SELECTOR]
|
|
88892
|
+
},
|
|
88893
|
+
{ address: am, name: "isTargetClosed", params: [v] }
|
|
88894
|
+
] : [],
|
|
88895
|
+
...wm ? [
|
|
88896
|
+
{ address: wm, name: "getWithdrawFee", params: [] },
|
|
88897
|
+
{ address: wm, name: "getRequestFee", params: [] },
|
|
88898
|
+
{ address: wm, name: "getSharesToRelease", params: [] }
|
|
88899
|
+
] : []
|
|
88900
|
+
],
|
|
88901
|
+
abis: [
|
|
88902
|
+
Erc4626ReadAbi2,
|
|
88903
|
+
PlasmaVaultReadAbi,
|
|
88904
|
+
Erc4626ReadAbi2,
|
|
88905
|
+
PlasmaVaultReadAbi,
|
|
88906
|
+
PlasmaVaultReadAbi,
|
|
88907
|
+
PlasmaVaultReadAbi,
|
|
88908
|
+
PlasmaVaultReadAbi,
|
|
88909
|
+
PlasmaVaultReadAbi,
|
|
88910
|
+
FusionBalanceOfAbi,
|
|
88911
|
+
...am ? [FusionAccessManagerReadAbi, FusionAccessManagerReadAbi] : [],
|
|
88912
|
+
...wm ? [
|
|
88913
|
+
FusionWithdrawManagerReadAbi,
|
|
88914
|
+
FusionWithdrawManagerReadAbi,
|
|
88915
|
+
FusionWithdrawManagerReadAbi
|
|
88916
|
+
] : []
|
|
88917
|
+
],
|
|
88918
|
+
parse: (slice2) => {
|
|
88919
|
+
const [assets, supply, rate, maxDep, preview, conv, perf, mgmt, idle] = slice2;
|
|
88920
|
+
let i = 9;
|
|
88921
|
+
const role = am ? slice2[i++] : void 0;
|
|
88922
|
+
const closed = am ? slice2[i++] : void 0;
|
|
88923
|
+
const wFee = wm ? toBigInt16(slice2[i++]) : void 0;
|
|
88924
|
+
const rFee = wm ? toBigInt16(slice2[i++]) : void 0;
|
|
88925
|
+
const toRelease = wm ? toBigInt16(slice2[i++]) : void 0;
|
|
88926
|
+
const totalAssets = toBigInt16(assets);
|
|
88927
|
+
const totalSupply = toBigInt16(supply);
|
|
88928
|
+
const convertToAssetsRaw = toBigInt16(rate);
|
|
88929
|
+
if (totalAssets === void 0 || totalSupply === void 0 || convertToAssetsRaw === void 0)
|
|
88930
|
+
return void 0;
|
|
88931
|
+
const previewShares = toBigInt16(preview);
|
|
88932
|
+
const convShares = toBigInt16(conv);
|
|
88933
|
+
const depositFeeBps = previewShares !== void 0 && convShares !== void 0 && convShares > 0n ? (
|
|
88934
|
+
// Nearest bp: the fee is minted from the shares, so the ratio lands
|
|
88935
|
+
// a hair under its nominal value (0.2 % reads 19.99 bps).
|
|
88936
|
+
Number(
|
|
88937
|
+
((convShares - previewShares) * 10000n + convShares / 2n) / convShares
|
|
88938
|
+
)
|
|
88939
|
+
) : void 0;
|
|
88940
|
+
const feeBps = (cell) => {
|
|
88941
|
+
const raw = Array.isArray(cell) ? cell[1] : cell?.feeInPercentage;
|
|
88942
|
+
const b = toBigInt16(raw);
|
|
88943
|
+
return b !== void 0 ? Number(b) : void 0;
|
|
88944
|
+
};
|
|
88945
|
+
const performanceFeeBps = feeBps(perf);
|
|
88946
|
+
const managementFeeBps = feeBps(mgmt);
|
|
88947
|
+
const roleId = toBigInt16(role);
|
|
88948
|
+
const gated = roleId !== void 0 && roleId !== PUBLIC_ROLE || closed === true;
|
|
88949
|
+
const maxDeposit = toBigInt16(maxDep);
|
|
88950
|
+
const depositCapacity = gated ? 0n : maxDeposit !== void 0 && maxDeposit < totalAssets * 1000000n ? maxDeposit : void 0;
|
|
88951
|
+
const idleRaw = toBigInt16(idle);
|
|
88952
|
+
const reserved = toRelease !== void 0 && toRelease > 0n && totalSupply > 0n ? toRelease * totalAssets / totalSupply : 0n;
|
|
88953
|
+
const instantRedeemCapacity = cfg?.instantFuses ? totalAssets : idleRaw !== void 0 ? idleRaw > reserved ? idleRaw - reserved : 0n : void 0;
|
|
88954
|
+
return {
|
|
88955
|
+
totalAssets,
|
|
88956
|
+
totalSupply,
|
|
88957
|
+
exchangeRate: convertToAssetsRaw * ONE_E1823 / underlyingUnit,
|
|
88958
|
+
// Raw shares one WHOLE underlying mints, NET of the deposit fee.
|
|
88959
|
+
...previewShares !== void 0 ? { convertToShares: previewShares } : {},
|
|
88960
|
+
...depositFeeBps !== void 0 ? { depositFeeBps } : {},
|
|
88961
|
+
...performanceFeeBps !== void 0 ? { performanceFeeBps } : {},
|
|
88962
|
+
...managementFeeBps !== void 0 ? { managementFeeBps } : {},
|
|
88963
|
+
...wFee !== void 0 ? { withdrawFeeBps: Number(wFee * 10000n / WAD18) } : {},
|
|
88964
|
+
...rFee !== void 0 ? { queuedFeeBps: Number(rFee * 10000n / WAD18) } : {},
|
|
88965
|
+
...instantRedeemCapacity !== void 0 ? { instantRedeemCapacity } : {},
|
|
88966
|
+
...depositCapacity !== void 0 ? { depositCapacity } : {},
|
|
88967
|
+
...closed === true ? { paused: true } : {}
|
|
88968
|
+
};
|
|
88969
|
+
}
|
|
88970
|
+
};
|
|
88971
|
+
};
|
|
88972
|
+
|
|
88973
|
+
// src/vaults/savings/readers/emberVault.ts
|
|
88974
|
+
var NEUTRAL_PROBE5 = "0x000000000000000000000000000000000000dead";
|
|
88632
88975
|
var readerEmberVault = (entry2) => {
|
|
88633
88976
|
const shareUnit = 10n ** BigInt(entry2.decimals);
|
|
88634
88977
|
const underlyingUnit = 10n ** BigInt(entry2.underlyingDecimals ?? entry2.decimals);
|
|
@@ -88637,7 +88980,7 @@ var readerEmberVault = (entry2) => {
|
|
|
88637
88980
|
{ address: entry2.address, name: "totalAssets", params: [] },
|
|
88638
88981
|
{ address: entry2.address, name: "totalSupply", params: [] },
|
|
88639
88982
|
{ address: entry2.address, name: "convertToAssets", params: [shareUnit] },
|
|
88640
|
-
{ address: entry2.address, name: "maxDeposit", params: [
|
|
88983
|
+
{ address: entry2.address, name: "maxDeposit", params: [NEUTRAL_PROBE5] },
|
|
88641
88984
|
{ address: entry2.address, name: "pauseStatus", params: [] }
|
|
88642
88985
|
],
|
|
88643
88986
|
abis: [
|
|
@@ -89264,7 +89607,7 @@ var readerUnitasXgld = (entry2) => {
|
|
|
89264
89607
|
};
|
|
89265
89608
|
|
|
89266
89609
|
// src/vaults/savings/readers/roycoTranche.ts
|
|
89267
|
-
var
|
|
89610
|
+
var NEUTRAL_PROBE6 = "0x000000000000000000000000000000000000dead";
|
|
89268
89611
|
var ASSET_CLAIMS = {
|
|
89269
89612
|
name: "claims",
|
|
89270
89613
|
type: "tuple",
|
|
@@ -89367,7 +89710,7 @@ var readerRoycoTranche = (entry2) => {
|
|
|
89367
89710
|
{ address: entry2.address, name: "totalAssets", params: [] },
|
|
89368
89711
|
{ address: entry2.address, name: "totalSupply", params: [] },
|
|
89369
89712
|
{ address: entry2.address, name: "convertToAssets", params: [shareUnit] },
|
|
89370
|
-
{ address: entry2.address, name: "maxDeposit", params: [
|
|
89713
|
+
{ address: entry2.address, name: "maxDeposit", params: [NEUTRAL_PROBE6] },
|
|
89371
89714
|
{ address: entry2.address, name: "paused", params: [] },
|
|
89372
89715
|
...entryPoint ? [
|
|
89373
89716
|
{
|
|
@@ -89806,7 +90149,7 @@ var readerAccountableVault = (entry2) => {
|
|
|
89806
90149
|
};
|
|
89807
90150
|
|
|
89808
90151
|
// src/vaults/savings/readers/alchemixTransmuter.ts
|
|
89809
|
-
var
|
|
90152
|
+
var SECONDS_PER_YEAR23 = 31536e3;
|
|
89810
90153
|
var UNCAPPED_FLOOR = 2n ** 200n;
|
|
89811
90154
|
var pow10 = (n) => 10n ** BigInt(n);
|
|
89812
90155
|
var readerAlchemixTransmuter = (entry2) => {
|
|
@@ -89882,7 +90225,7 @@ var readerAlchemixTransmuter = (entry2) => {
|
|
|
89882
90225
|
const price1e18 = out !== void 0 && out > 0n ? out * ONE_E1823 * pow10(18 - cfg.underlyingDecimals) / q.unit : void 0;
|
|
89883
90226
|
const marketDiscountBps = price1e18 !== void 0 ? Number((price1e18 - ONE_E1823) * 100000n / ONE_E1823) / 10 : void 0;
|
|
89884
90227
|
const tf = transmutationFee !== void 0 ? Number(transmutationFee) / 1e4 : 0;
|
|
89885
|
-
const supplyRate = price1e18 !== void 0 && termSeconds > 0 ? ((1 - tf) / (Number(price1e18) / 1e18) - 1) * (
|
|
90228
|
+
const supplyRate = price1e18 !== void 0 && termSeconds > 0 ? ((1 - tf) / (Number(price1e18) / 1e18) - 1) * (SECONDS_PER_YEAR23 / termSeconds) * 100 : void 0;
|
|
89886
90229
|
const exitFeeBps = exitFee !== void 0 ? Number(exitFee) : void 0;
|
|
89887
90230
|
const exitRoutes = [
|
|
89888
90231
|
{
|
|
@@ -89927,7 +90270,7 @@ var readerAlchemixTransmuter = (entry2) => {
|
|
|
89927
90270
|
};
|
|
89928
90271
|
|
|
89929
90272
|
// src/vaults/savings/readers/gapSweep.ts
|
|
89930
|
-
var
|
|
90273
|
+
var NEUTRAL_PROBE7 = "0x000000000000000000000000000000000000dead";
|
|
89931
90274
|
var MAX_UINT256 = 2n ** 256n - 1n;
|
|
89932
90275
|
var readerUsdaiStaked = (entry2) => {
|
|
89933
90276
|
const a = entry2.address;
|
|
@@ -89977,7 +90320,7 @@ var readerYuzuIlp = (entry2) => {
|
|
|
89977
90320
|
{ address: entry2.address, name: "totalAssets", params: [] },
|
|
89978
90321
|
{ address: entry2.address, name: "totalSupply", params: [] },
|
|
89979
90322
|
{ address: entry2.address, name: "convertToAssets", params: [shareUnit] },
|
|
89980
|
-
{ address: entry2.address, name: "maxDeposit", params: [
|
|
90323
|
+
{ address: entry2.address, name: "maxDeposit", params: [NEUTRAL_PROBE7] },
|
|
89981
90324
|
{ address: entry2.address, name: "paused", params: [] }
|
|
89982
90325
|
],
|
|
89983
90326
|
abis: [
|
|
@@ -90090,6 +90433,8 @@ var buildReader2 = (entry2) => {
|
|
|
90090
90433
|
return readerErc4626CooldownInstantFee(entry2);
|
|
90091
90434
|
case "superform-supervault":
|
|
90092
90435
|
return readerSuperformVault(entry2);
|
|
90436
|
+
case "ipor-fusion":
|
|
90437
|
+
return readerIporFusion(entry2);
|
|
90093
90438
|
case "ember-vault":
|
|
90094
90439
|
return readerEmberVault(entry2);
|
|
90095
90440
|
case "mellow-core":
|
|
@@ -90384,7 +90729,10 @@ var fetchSavingsVaults = async (chainId, multicallRetry, prices = {}, tokenList
|
|
|
90384
90729
|
// opposite and correctly falls through to `false`.
|
|
90385
90730
|
entry2.reader === "bitfi-vault" || // SuperVaults ARE 4626 on the deposit side and 7540 on the exit, the
|
|
90386
90731
|
// Lagoon / yoETH shape. NB `previewRedeem` reverts — see the reader.
|
|
90387
|
-
entry2.reader === "superform-supervault" || //
|
|
90732
|
+
entry2.reader === "superform-supervault" || // IPOR Fusion PlasmaVaults are conforming 4626 on every leg; the
|
|
90733
|
+
// bespoke reader exists for the WithdrawManager's fees and the
|
|
90734
|
+
// idle-cash cap, not because the standard surface is missing.
|
|
90735
|
+
entry2.reader === "ipor-fusion" || // Ember vaults are conforming 4626 VIEWS (`asset`, `totalAssets`,
|
|
90388
90736
|
// `convertToAssets`) and deposit; `redeem`/`withdraw` revert
|
|
90389
90737
|
// `UseRedeemShares()`, which the savings kind routes around.
|
|
90390
90738
|
entry2.reader === "ember-vault" || // sBOLD and the Alchemix MYTs (Morpho Vault V2) are conforming 4626 on
|
|
@@ -92335,8 +92683,31 @@ var VOLATILE_VAULT_OVERRIDES = /* @__PURE__ */ new Set([
|
|
|
92335
92683
|
// CarryTradeUSDTRYLeverage
|
|
92336
92684
|
"1-0x827ce7e8e35861d9ac7fe002755767b695a5594a",
|
|
92337
92685
|
// StockMarketTRBasisTrade
|
|
92338
|
-
"1-0x99351baed3d8ab544ccb08af96a105910fda71e7"
|
|
92686
|
+
"1-0x99351baed3d8ab544ccb08af96a105910fda71e7",
|
|
92339
92687
|
// aFXArbUSDTRY
|
|
92688
|
+
// IPOR Fusion loops and carries — the share price is collateral at an
|
|
92689
|
+
// oracle mark minus debt, levered 5–9× on the loops, and on the carries the
|
|
92690
|
+
// debt sits in a different currency than the vault (dollars against ETH or
|
|
92691
|
+
// BTC, WBTC against a dollar). Max 30-day drawdown measured 2026-10-30 was
|
|
92692
|
+
// 0.35 %; the risk is the mark, the liquidation and the depeg, not the
|
|
92693
|
+
// window. The four lending optimizers stay yield-bearing. Pinned by
|
|
92694
|
+
// `iporFusion.test.ts` against `IPOR_FUSION_VOLATILE_KEYS`.
|
|
92695
|
+
"1-0xb9e806e8f2d94c015ffefa90cd24ecce18f1663c",
|
|
92696
|
+
// rETHLPC
|
|
92697
|
+
"1-0xb8a451107a9f87fde481d4d686247d6e43ed715e",
|
|
92698
|
+
// fusnstETH
|
|
92699
|
+
"1-0xb0f56bb0bf13ee05fef8cd2d8df5ffdfcac7a74f",
|
|
92700
|
+
// $TAUSIUSD
|
|
92701
|
+
"1-0xf8f226da66244f89e70c5b5d1a5c5b0d505eb1d8",
|
|
92702
|
+
// bdUSD
|
|
92703
|
+
"1-0x7659fc26bf3a63e8133bbecb7e16acd48ee8e292",
|
|
92704
|
+
// BTCdc
|
|
92705
|
+
"1-0xe9385eff3f937fcb0f0085da9a3f53d6c2b4fb5f",
|
|
92706
|
+
// ipsrUSDfusion
|
|
92707
|
+
"8453-0xe883426b4fc84a7f5cc86415cabbef43e73a4cc8",
|
|
92708
|
+
// TAUCBETH
|
|
92709
|
+
"8453-0x5900c3b72458f12967dc1bef35b92d271f5cdbc1"
|
|
92710
|
+
// CSCBETHLL
|
|
92340
92711
|
]);
|
|
92341
92712
|
var STABLECOIN_SYMBOLS = /* @__PURE__ */ new Set([
|
|
92342
92713
|
// USD majors
|
|
@@ -104888,7 +105259,7 @@ function earnPositionTotals(items) {
|
|
|
104888
105259
|
|
|
104889
105260
|
// src/boros/api.ts
|
|
104890
105261
|
var BOROS_API_BASE = "https://api.boros.finance/open-api";
|
|
104891
|
-
var
|
|
105262
|
+
var TIMEOUT_MS9 = 8e3;
|
|
104892
105263
|
var BorosApiError = class extends Error {
|
|
104893
105264
|
constructor(message2, status, errorCode) {
|
|
104894
105265
|
super(message2);
|
|
@@ -104906,7 +105277,7 @@ async function borosApi(path, init, fetchImpl = fetch) {
|
|
|
104906
105277
|
...init?.body !== void 0 ? { "content-type": "application/json" } : {}
|
|
104907
105278
|
},
|
|
104908
105279
|
body: init?.body !== void 0 ? JSON.stringify(init.body) : void 0,
|
|
104909
|
-
signal: AbortSignal.timeout(
|
|
105280
|
+
signal: AbortSignal.timeout(TIMEOUT_MS9)
|
|
104910
105281
|
});
|
|
104911
105282
|
const text = await res.text();
|
|
104912
105283
|
let json;
|
|
@@ -105440,8 +105811,8 @@ async function fetchBorosAccount(account, fetchImpl) {
|
|
|
105440
105811
|
}
|
|
105441
105812
|
|
|
105442
105813
|
// src/boros/margin.ts
|
|
105443
|
-
var
|
|
105444
|
-
var ttmYears = (m, ttmSec) => Math.max(ttmSec ?? m.timeToMaturitySec, m.margin.tThreshSec) /
|
|
105814
|
+
var SECONDS_PER_YEAR24 = 365 * 24 * 3600;
|
|
105815
|
+
var ttmYears = (m, ttmSec) => Math.max(ttmSec ?? m.timeToMaturitySec, m.margin.tThreshSec) / SECONDS_PER_YEAR24;
|
|
105445
105816
|
function borosInitialMargin(m, size, ratePct, ttmSec) {
|
|
105446
105817
|
const r = Math.max(Math.abs(ratePct) / 100, m.margin.rateFloor);
|
|
105447
105818
|
return Math.abs(size) * r * m.margin.kIM * ttmYears(m, ttmSec);
|
|
@@ -105451,7 +105822,7 @@ function borosMaintenanceMargin(m, size, markPct, ttmSec) {
|
|
|
105451
105822
|
return Math.abs(size) * r * m.margin.kMM * ttmYears(m, ttmSec);
|
|
105452
105823
|
}
|
|
105453
105824
|
function borosTakerFee(m, size) {
|
|
105454
|
-
return Math.abs(size) * m.fees.takerFee * m.timeToMaturitySec /
|
|
105825
|
+
return Math.abs(size) * m.fees.takerFee * m.timeToMaturitySec / SECONDS_PER_YEAR24;
|
|
105455
105826
|
}
|
|
105456
105827
|
function walkBorosBook(levels, size) {
|
|
105457
105828
|
let left = size;
|
|
@@ -105473,7 +105844,7 @@ function walkBorosBook(levels, size) {
|
|
|
105473
105844
|
};
|
|
105474
105845
|
}
|
|
105475
105846
|
function borosRateMoveToLiquidation(m, size, equity, markPct) {
|
|
105476
|
-
const ttm = m.timeToMaturitySec /
|
|
105847
|
+
const ttm = m.timeToMaturitySec / SECONDS_PER_YEAR24;
|
|
105477
105848
|
if (!(Math.abs(size) > 0) || !(ttm > 0)) return null;
|
|
105478
105849
|
const mm = borosMaintenanceMargin(m, size, markPct);
|
|
105479
105850
|
const slack = equity - mm;
|
|
@@ -105565,7 +105936,7 @@ function quoteBorosHedgeLeg(p) {
|
|
|
105565
105936
|
const fixed = fill.avgAprPct;
|
|
105566
105937
|
const floating = m.rates.floatingApr;
|
|
105567
105938
|
const takerFee = borosTakerFee(m, size);
|
|
105568
|
-
const ttmYears2 = m.timeToMaturitySec /
|
|
105939
|
+
const ttmYears2 = m.timeToMaturitySec / SECONDS_PER_YEAR24;
|
|
105569
105940
|
const settleAprPct = m.fees.settleFee != null ? m.fees.settleFee * 100 : null;
|
|
105570
105941
|
const allIn = ttmYears2 > 0 ? takerFee / size / ttmYears2 * 100 + (settleAprPct ?? 0) : null;
|
|
105571
105942
|
const rateForMargin = fixed ?? m.rates.markApr ?? 0;
|