@1delta/margin-fetcher 5.0.66 → 5.0.68
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 +28 -1
- package/dist/index.js +772 -120
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { parseAbi, keccak256, encodeAbiParameters, formatEther, BaseError, erc20Abi, stringToHex, isAddress, pad, encodeFunctionData, formatUnits, getAddress, decodeFunctionResult, decodeAbiParameters, concat, parseAbiParameters, AbiEncodingLengthMismatchError, concatHex, toBytes, slice, hexToString, InvalidAddressError, boolToHex, integerRegex, numberToHex, bytesRegex, BytesSizeMismatchError, arrayRegex, UnsupportedPackedAbiType } from './chunk-JUYF2XLF.js';
|
|
2
2
|
import './chunk-BYTNVMX7.js';
|
|
3
3
|
import './chunk-PR4QN5HX.js';
|
|
4
|
-
import { Lender, isExactly, isMidnight, isTerm, isTermMax, isTeller, isListaDao, isLiquityFamily, isRiver, isInverse, isCooler, isDssType, isCompoundV3Type, isFluid, isGearboxV3, isLlamaLend, isFrankencoin, isResupply, isCurvance, isTwyne, isFraxlend, isAaveV4Type, LIQUITY_FAMILY_LENDERS, isAaveType, isCompoundV3, isCompoundV2Type, isMultiMarket, isSiloV2Type, isSiloV3Type, isDolomite,
|
|
4
|
+
import { Lender, isExactly, isMidnight, isTerm, isTermMax, isTeller, isListaDao, isLiquityFamily, isRiver, isInverse, isCooler, isDssType, isCompoundV3Type, isFluid, isGearboxV3, isLlamaLend, isFrankencoin, isResupply, isCurvance, isFlyingTulip, isTwyne, isFraxlend, isAaveV4Type, LIQUITY_FAMILY_LENDERS, isAaveType, isCompoundV3, isCompoundV2Type, isMultiMarket, isSiloV2Type, isSiloV3Type, isDolomite, isMorphoType, isUsdd, isSky, hasCrossMarginRisk, isEulerType, isInit, isVenusType, isSumerType, AAVE_V3_LENDERS, AAVE_V2_LENDERS, isMorphoBlue, isAaveV2Type, isAaveV32Type, isAaveV3Type, isYLDR, isLista, hasSubAccounts, isTectonicType, isKineticType, isBenqiType } from '@1delta/lender-registry';
|
|
5
5
|
export { hasCrossMarginRisk, isAaveType, isAaveV2Type, isAaveV32Type, isAaveV3Type, isCompoundV3, isCompoundV3Type, isInit, isMorphoType, isMultiMarket, isYLDR } from '@1delta/lender-registry';
|
|
6
6
|
import { fetchTokenLists, fetchTokenList, aavePools, compoundV3Pools, initConfig, morphoPools, compoundV2Pools, eulerVaults, siloMarkets, siloV2LenderKey, siloMarketsV3, siloV3LenderKey, aaveV4Spokes, aaveV4SpokeLenderKey, fluidResolvers, gearboxResolvers, dolomiteConfigs, midnightConfig, termConfig, termMarketsByChain, exactlyConfig, flyingTulipLendersByChain, liquityLendersByChain, riverLendersByChain, inverseLendersByChain, coolerLendersByChain, llamaLendLendersByChain, usddLendersByChain, skyLendersByChain, frankencoinLendersByChain, resupplyLendersByChain, curvanceLendersByChain, fraxlendLendersByChain, twyneLendersByChain, tellerConfigByChain, tellerPoolsByChain, termMaxConfigByChain, aaveReserves, compoundV3Reserves, resolveTermApiBase, flyingTulipConfigFor, flyingTulipAssetsFor, liquityConfigFor, liquityBranchesByChain, riverConfigFor, riverChainData, termMaxApiBaseUrl, termMaxLenderKey, inverseConfigFor, inverseChainData, coolerConfigFor, llamaLendConfigFor, llamaLendChainData, llamaLendApiBaseUrl, resupplyConfigFor, fraxlendConfigFor, dssConfigFor, dssChainData, dssDebtToken, dssDebtJoin, frankencoinConfigFor, frankencoinChainData, aaveOracles, morphoTypeMarkets, resolveMidnightApiBase, llamaLendMarketByVault, getSiloV2MarketEntry, getSiloV3MarketEntry, dolomiteEmode, curvanceConfigFor, aaveTokens, morphoTypeVaults, listaCollateralProvider, eulerConfigs, gearboxMarketCompressor, gearboxMarketConfigurators, compoundV2TokenArray, gearboxV3LenderKey, midnightMarketsByChain, twyneConfigFor, twyneChainData, parseAaveV4SpokeLenderKey, fraxlendPairsFor, gearboxAccountCompressor, compoundV2Tokens, exactlyMarketsByChain, aaveOraclesConfig, compoundV2Oracles, compoundV2OraclesConfig, compoundV3OraclesData, compoundV3BaseData, compoundV2Reserves, aaveV4Oracles, morphoTypeOracles } from '@1delta/data-sdk';
|
|
7
7
|
import lodash from 'lodash';
|
|
@@ -9,7 +9,7 @@ import { Chain } from '@1delta/chain-registry';
|
|
|
9
9
|
import { multicallRetryUniversal, getEvmClient, getEvmChain, getEvmClientUniversal } from '@1delta/providers';
|
|
10
10
|
import { LiquityTroveManagerAbi, LiquityActivePoolAbi, LiquityStabilityPoolAbi, LiquityPriceFeedAbi, LiquitySortedTrovesAbi, RiverTroveManagerAbi, RiverStabilityPoolAbi, TellerMarketRegistryAbi, TellerV2Abi, InverseMarketAbi, InverseOracleAbi, InverseDbrAbi, Erc20Abi, CoolerMonoAbi, CoolerLtvOracleAbi, LlamaLendControllerAbi, LlamaLendControllerV1Abi, LlamaLendControllerV2Abi, LlamaLendVaultAbi, LlamaLendAmmAbi, TwyneCollateralVaultAbi, MetaMorphoAbi, FluidDexResolverAbi, ExactlyPreviewerAbi, ExactlyAuditorAbi, FlyingTulipLendingLensAbi, LenderCommitmentGroupAbi, ResupplyRegistryAbi, ResupplyPairAbi, ResupplyUtilitiesAbi, ResupplyRewardHandlerAbi, ResupplyPairEmissionsAbi, ConvexPoolUtilAbi, FraxlendPairAbi, FraxlendLeverAbi, FrankencoinPositionAbi, FluidLendingResolverAbi, FluidVaultResolverAbi, FluidLiquidityResolverAbi, MoolahVaultAbi, UsddVatAbi, UsddJugAbi, UsddSpotAbi, MorphoLensAbi, AaveV4SpokeAbi, AaveV4OracleAbi, AaveV4HubAbi, DolomiteMarginAbi, GearboxMarketCompressorV310Abi, MorphoBlueAbi, MidnightAbi, TermRepoTokenAbi, TermRepoServicerAbi, TermRepoCollateralManagerAbi, LiquityTroveNFTAbi, LiquityCollSurplusPoolAbi, TellerCollateralManagerAbi, TermMaxViewerAbi, InverseEscrowAbi, CurvanceMarketManagerAbi, CurvanceCTokenAbi, GearboxCreditAccountCompressorV310Abi, TwyneVaultManagerAbi, TwyneCollateralVaultFactoryAbi, AaveV2V3Abi, TwyneATokenWrapperAbi, UsddCdpManagerAbi, UsddProxyRegistryAbi, CurvanceProtocolReaderAbi, CurvanceCentralRegistryAbi, TermPriceConsumerAbi, CurvanceOracleManagerAbi, TermMaxOracleAggregatorV2Abi } from '@1delta/abis';
|
|
11
11
|
export { MorphoLensAbi } from '@1delta/abis';
|
|
12
|
-
import { prepareDebitDataMulticall, prepareLenderDebitMulticall, parseDebitDataResult, parseLenderDebitResult, getPermit2ContractAddress, getLstAcceptedInputs, getCompoundV3CometAddress as getCompoundV3CometAddress$1, getMorphoAddress, getAaveCollateralTokenAddress, getSiloHalfForUnderlying, findSavingsWithdrawEntry, bandLtvCurve, InitMarginAddresses, ignoresReceiver, buildLstWithdrawRequest, SAVINGS_RECEIVER_CAPABILITY } from '@1delta/calldata-sdk';
|
|
12
|
+
import { prepareDebitDataMulticall, prepareLenderDebitMulticall, parseDebitDataResult, parseLenderDebitResult, getPermit2ContractAddress, getLstAcceptedInputs, getCompoundV2Comptroller as getCompoundV2Comptroller$1, getCompoundV3CometAddress as getCompoundV3CometAddress$1, getMorphoAddress, FLUID_VAULT_FACTORY, getAaveStyleLenderTokenAddress, LendingMode, getAaveCollateralTokenAddress, getSiloHalfForUnderlying, findSavingsWithdrawEntry, bandLtvCurve, InitMarginAddresses, ignoresReceiver, buildLstWithdrawRequest, SAVINGS_RECEIVER_CAPABILITY } 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
|
|
|
@@ -23499,7 +23499,7 @@ async function fetchTellerMarkets(chainId) {
|
|
|
23499
23499
|
} catch {
|
|
23500
23500
|
return { chainId, pools: [] };
|
|
23501
23501
|
}
|
|
23502
|
-
const
|
|
23502
|
+
const big24 = (i) => {
|
|
23503
23503
|
const r = results[i];
|
|
23504
23504
|
if (typeof r === "bigint") return r;
|
|
23505
23505
|
if (typeof r === "number") return BigInt(r);
|
|
@@ -23513,20 +23513,20 @@ async function fetchTellerMarkets(chainId) {
|
|
|
23513
23513
|
return null;
|
|
23514
23514
|
};
|
|
23515
23515
|
const num19 = (i) => {
|
|
23516
|
-
const b =
|
|
23516
|
+
const b = big24(i);
|
|
23517
23517
|
return b === null ? null : Number(b);
|
|
23518
23518
|
};
|
|
23519
23519
|
const pool0 = pools.map((config, i) => {
|
|
23520
23520
|
const base = i * READS_PER_POOL;
|
|
23521
23521
|
return {
|
|
23522
23522
|
config,
|
|
23523
|
-
available:
|
|
23524
|
-
committed:
|
|
23523
|
+
available: big24(base),
|
|
23524
|
+
committed: big24(base + 1),
|
|
23525
23525
|
minRateBps: num19(base + 2),
|
|
23526
|
-
collateralPerPrincipal:
|
|
23526
|
+
collateralPerPrincipal: big24(base + 3),
|
|
23527
23527
|
maxLoanDuration: num19(base + 4),
|
|
23528
|
-
marketId:
|
|
23529
|
-
totalAssets:
|
|
23528
|
+
marketId: big24(base + 5),
|
|
23529
|
+
totalAssets: big24(base + 6)
|
|
23530
23530
|
};
|
|
23531
23531
|
});
|
|
23532
23532
|
const attByMarket = /* @__PURE__ */ new Map();
|
|
@@ -28139,12 +28139,12 @@ async function fetchDssMarkets(lender, chainId) {
|
|
|
28139
28139
|
} catch {
|
|
28140
28140
|
return { lender, config, chainData, markets: [] };
|
|
28141
28141
|
}
|
|
28142
|
-
const
|
|
28142
|
+
const big24 = (v) => {
|
|
28143
28143
|
if (typeof v === "bigint") return v;
|
|
28144
28144
|
if (typeof v === "number") return BigInt(v);
|
|
28145
28145
|
return null;
|
|
28146
28146
|
};
|
|
28147
|
-
const field13 = (res, name, idx) =>
|
|
28147
|
+
const field13 = (res, name, idx) => big24(res?.[name] ?? res?.[idx]);
|
|
28148
28148
|
let cursor = 0;
|
|
28149
28149
|
const out = markets.map((market, i) => {
|
|
28150
28150
|
const base = cursor;
|
|
@@ -28161,7 +28161,7 @@ async function fetchDssMarkets(lender, chainId) {
|
|
|
28161
28161
|
dust: field13(vatIlk, "dust", 4),
|
|
28162
28162
|
duty: field13(jugIlk, "duty", 0),
|
|
28163
28163
|
mat: field13(spotIlk, "mat", 1),
|
|
28164
|
-
joinBalance: joinReadIndex[i] >= 0 ?
|
|
28164
|
+
joinBalance: joinReadIndex[i] >= 0 ? big24(results[joinReadIndex[i]]) : null
|
|
28165
28165
|
};
|
|
28166
28166
|
});
|
|
28167
28167
|
return { lender, config, chainData, markets: out };
|
|
@@ -28435,26 +28435,26 @@ async function fetchFrankencoinMarkets(lender, chainId) {
|
|
|
28435
28435
|
} catch {
|
|
28436
28436
|
return { lender, config, chainData, markets: [] };
|
|
28437
28437
|
}
|
|
28438
|
-
const
|
|
28438
|
+
const big24 = (v) => {
|
|
28439
28439
|
if (typeof v === "bigint") return v;
|
|
28440
28440
|
if (typeof v === "number") return BigInt(v);
|
|
28441
28441
|
return null;
|
|
28442
28442
|
};
|
|
28443
28443
|
const out = markets.map((market, i) => {
|
|
28444
28444
|
const base = i * READS_PER_MARKET3;
|
|
28445
|
-
const expiration =
|
|
28445
|
+
const expiration = big24(results[base + 7]);
|
|
28446
28446
|
return {
|
|
28447
28447
|
market,
|
|
28448
|
-
price:
|
|
28449
|
-
minted:
|
|
28450
|
-
availableForClones:
|
|
28451
|
-
annualInterestPPM:
|
|
28452
|
-
currentFeePPM:
|
|
28453
|
-
reserveContribution:
|
|
28454
|
-
challengedAmount:
|
|
28448
|
+
price: big24(results[base]),
|
|
28449
|
+
minted: big24(results[base + 1]),
|
|
28450
|
+
availableForClones: big24(results[base + 2]),
|
|
28451
|
+
annualInterestPPM: big24(results[base + 3]),
|
|
28452
|
+
currentFeePPM: big24(results[base + 4]),
|
|
28453
|
+
reserveContribution: big24(results[base + 5]),
|
|
28454
|
+
challengedAmount: big24(results[base + 6]),
|
|
28455
28455
|
expiration,
|
|
28456
28456
|
isClosed: typeof results[base + 8] === "boolean" ? results[base + 8] : null,
|
|
28457
|
-
collateralBalance:
|
|
28457
|
+
collateralBalance: big24(results[base + 9])
|
|
28458
28458
|
};
|
|
28459
28459
|
});
|
|
28460
28460
|
return { lender, config, chainData, markets: out };
|
|
@@ -32354,6 +32354,14 @@ function buildTellerDataPhase(proto, kept, _account) {
|
|
|
32354
32354
|
}
|
|
32355
32355
|
return calls;
|
|
32356
32356
|
}
|
|
32357
|
+
var FLYING_TULIP_USER_CALLS = 1;
|
|
32358
|
+
var buildFlyingTulipUserCall = (chainId, lender, account) => {
|
|
32359
|
+
const cfg = flyingTulipConfigFor(lender, chainId);
|
|
32360
|
+
if (!cfg?.lendingLens) return [];
|
|
32361
|
+
return [
|
|
32362
|
+
{ address: cfg.lendingLens, name: "userPortfolio", params: [account] }
|
|
32363
|
+
];
|
|
32364
|
+
};
|
|
32357
32365
|
var TERMMAX_MARKETS_PER_CALL = 180;
|
|
32358
32366
|
var CACHE_TTL_MS4 = 5 * 6e4;
|
|
32359
32367
|
var discoveryCache8 = /* @__PURE__ */ new Map();
|
|
@@ -32434,6 +32442,8 @@ async function buildUserCall(chainId, lender, account, params, getClient) {
|
|
|
32434
32442
|
if (isTermMax(lender)) return buildTermMaxUserCall(chainId, lender, account);
|
|
32435
32443
|
if (isInverse(lender)) return buildInverseUserCall(chainId, lender, account);
|
|
32436
32444
|
if (isCooler(lender)) return buildCoolerUserCall(chainId, lender, account);
|
|
32445
|
+
if (isFlyingTulip(lender))
|
|
32446
|
+
return buildFlyingTulipUserCall(chainId, lender, account);
|
|
32437
32447
|
if (isLlamaLend(lender))
|
|
32438
32448
|
return buildLlamaLendUserCall(chainId, lender, account);
|
|
32439
32449
|
if (isResupply(lender)) return buildResupplyUserCall(chainId, lender, account);
|
|
@@ -35871,6 +35881,131 @@ var getCoolerUserDataConverter = (lender, chainId, account, meta) => {
|
|
|
35871
35881
|
expected
|
|
35872
35882
|
];
|
|
35873
35883
|
};
|
|
35884
|
+
var big12 = (v) => {
|
|
35885
|
+
try {
|
|
35886
|
+
if (typeof v === "bigint") return v;
|
|
35887
|
+
if (typeof v === "number" || typeof v === "string") return BigInt(v);
|
|
35888
|
+
} catch {
|
|
35889
|
+
}
|
|
35890
|
+
return 0n;
|
|
35891
|
+
};
|
|
35892
|
+
var getFlyingTulipUserDataConverter = (lender, chainId, account, meta) => {
|
|
35893
|
+
const cfg = flyingTulipConfigFor(lender, chainId);
|
|
35894
|
+
const roster = flyingTulipAssetsFor(lender, chainId);
|
|
35895
|
+
const expected = cfg?.lendingLens ? FLYING_TULIP_USER_CALLS : 0;
|
|
35896
|
+
const decimalsOf = (asset) => roster?.assets.find((a) => a.address.toLowerCase() === asset.toLowerCase())?.decimals ?? 18;
|
|
35897
|
+
return [
|
|
35898
|
+
(data) => {
|
|
35899
|
+
if (!cfg || expected === 0 || !meta) return void 0;
|
|
35900
|
+
if (!data || data.length < expected) return void 0;
|
|
35901
|
+
const raw = data[0];
|
|
35902
|
+
if (isFailedCall(raw)) return void 0;
|
|
35903
|
+
const p = Array.isArray(raw) ? {
|
|
35904
|
+
collAssets: raw[0],
|
|
35905
|
+
collAvail: raw[1],
|
|
35906
|
+
collHold: raw[2],
|
|
35907
|
+
debtAssets: raw[3],
|
|
35908
|
+
debtUnitsNow: raw[4],
|
|
35909
|
+
equityUSDWad: raw[5],
|
|
35910
|
+
maintUSDWad: raw[6],
|
|
35911
|
+
hfBps: raw[7]
|
|
35912
|
+
} : raw;
|
|
35913
|
+
if (!p || !Array.isArray(p.collAssets) || !Array.isArray(p.debtAssets))
|
|
35914
|
+
return void 0;
|
|
35915
|
+
const info = {
|
|
35916
|
+
equityUSDWad: big12(p.equityUSDWad).toString(),
|
|
35917
|
+
maintUSDWad: big12(p.maintUSDWad).toString(),
|
|
35918
|
+
hfBps: Number(p.hfBps ?? 0)
|
|
35919
|
+
};
|
|
35920
|
+
const rows = {};
|
|
35921
|
+
let any = false;
|
|
35922
|
+
let deposits24h = 0;
|
|
35923
|
+
let debt24h = 0;
|
|
35924
|
+
for (let i = 0; i < p.collAssets.length; i++) {
|
|
35925
|
+
const asset = String(p.collAssets[i]).toLowerCase();
|
|
35926
|
+
const amount4 = big12(p.collAvail?.[i]) + big12(p.collHold?.[i]);
|
|
35927
|
+
if (amount4 === 0n) continue;
|
|
35928
|
+
const uid = createMarketUid(chainId, lender, asset);
|
|
35929
|
+
const m = meta[uid];
|
|
35930
|
+
const dec2 = decimalsOf(asset);
|
|
35931
|
+
const amtStr = parseRawAmount(amount4.toString(), dec2);
|
|
35932
|
+
const amtNum = Number(amtStr);
|
|
35933
|
+
const display = m ? getDisplayPrice(m) : 0;
|
|
35934
|
+
const oracle = m ? getOraclePrice(m) : 0;
|
|
35935
|
+
deposits24h += amtNum * (m?.price?.priceUsd24h ?? display);
|
|
35936
|
+
any = true;
|
|
35937
|
+
rows[uid] = {
|
|
35938
|
+
marketUid: uid,
|
|
35939
|
+
underlying: asset,
|
|
35940
|
+
deposits: amtStr,
|
|
35941
|
+
debt: "0",
|
|
35942
|
+
debtStable: "0",
|
|
35943
|
+
depositsUSD: amtNum * display,
|
|
35944
|
+
debtUSD: 0,
|
|
35945
|
+
debtStableUSD: 0,
|
|
35946
|
+
depositsUSDOracle: amtNum * oracle,
|
|
35947
|
+
debtUSDOracle: 0,
|
|
35948
|
+
debtStableUSDOracle: 0,
|
|
35949
|
+
stableBorrowRate: "0",
|
|
35950
|
+
collateralEnabled: true,
|
|
35951
|
+
claimableRewards: 0,
|
|
35952
|
+
flyingTulipInfo: info
|
|
35953
|
+
};
|
|
35954
|
+
}
|
|
35955
|
+
for (let i = 0; i < p.debtAssets.length; i++) {
|
|
35956
|
+
const asset = String(p.debtAssets[i]).toLowerCase();
|
|
35957
|
+
const amount4 = big12(p.debtUnitsNow?.[i]);
|
|
35958
|
+
if (amount4 === 0n) continue;
|
|
35959
|
+
const uid = createMarketUid(chainId, lender, asset);
|
|
35960
|
+
const m = meta[uid];
|
|
35961
|
+
const dec2 = decimalsOf(asset);
|
|
35962
|
+
const amtStr = parseRawAmount(amount4.toString(), dec2);
|
|
35963
|
+
const amtNum = Number(amtStr);
|
|
35964
|
+
const display = m ? getDisplayPrice(m) : 0;
|
|
35965
|
+
const oracle = m ? getOraclePrice(m) : 0;
|
|
35966
|
+
debt24h += amtNum * (m?.price?.priceUsd24h ?? display);
|
|
35967
|
+
any = true;
|
|
35968
|
+
const existing = rows[uid];
|
|
35969
|
+
if (existing) {
|
|
35970
|
+
existing.debt = amtStr;
|
|
35971
|
+
existing.debtUSD = amtNum * display;
|
|
35972
|
+
existing.debtUSDOracle = amtNum * oracle;
|
|
35973
|
+
} else {
|
|
35974
|
+
rows[uid] = {
|
|
35975
|
+
marketUid: uid,
|
|
35976
|
+
underlying: asset,
|
|
35977
|
+
deposits: "0",
|
|
35978
|
+
debt: amtStr,
|
|
35979
|
+
debtStable: "0",
|
|
35980
|
+
depositsUSD: 0,
|
|
35981
|
+
debtUSD: amtNum * display,
|
|
35982
|
+
debtStableUSD: 0,
|
|
35983
|
+
depositsUSDOracle: 0,
|
|
35984
|
+
debtUSDOracle: amtNum * oracle,
|
|
35985
|
+
debtStableUSDOracle: 0,
|
|
35986
|
+
stableBorrowRate: "0",
|
|
35987
|
+
collateralEnabled: false,
|
|
35988
|
+
claimableRewards: 0,
|
|
35989
|
+
flyingTulipInfo: info
|
|
35990
|
+
};
|
|
35991
|
+
}
|
|
35992
|
+
}
|
|
35993
|
+
if (!any) return void 0;
|
|
35994
|
+
const lendingPositions = { "0": rows };
|
|
35995
|
+
const modes = { "0": 0 };
|
|
35996
|
+
const hist = {
|
|
35997
|
+
"0": { totalDeposits24h: deposits24h, totalDebt24h: debt24h }
|
|
35998
|
+
};
|
|
35999
|
+
const userData = createMultiAccountTypeUserState(
|
|
36000
|
+
{ chainId, account, lendingPositions, modes },
|
|
36001
|
+
meta,
|
|
36002
|
+
hist
|
|
36003
|
+
);
|
|
36004
|
+
return userData && userData.data.length > 0 ? userData : void 0;
|
|
36005
|
+
},
|
|
36006
|
+
expected
|
|
36007
|
+
];
|
|
36008
|
+
};
|
|
35874
36009
|
var statesFromSlice2 = (data, marketCount) => {
|
|
35875
36010
|
const out = /* @__PURE__ */ new Map();
|
|
35876
36011
|
for (let i = 0; i < marketCount; i++) {
|
|
@@ -35885,18 +36020,18 @@ var statesFromSlice2 = (data, marketCount) => {
|
|
|
35885
36020
|
const healthRaw = data[base + 1];
|
|
35886
36021
|
const pricesRaw = data[base + 2];
|
|
35887
36022
|
out.set(i, {
|
|
35888
|
-
collateral:
|
|
35889
|
-
bandBorrowed:
|
|
35890
|
-
debt:
|
|
35891
|
-
bandCount: Number(
|
|
35892
|
-
health: isFailedCall(healthRaw) ? 0n :
|
|
36023
|
+
collateral: big13(stateRaw[0]),
|
|
36024
|
+
bandBorrowed: big13(stateRaw[1]),
|
|
36025
|
+
debt: big13(stateRaw[2]),
|
|
36026
|
+
bandCount: Number(big13(stateRaw[3])),
|
|
36027
|
+
health: isFailedCall(healthRaw) ? 0n : big13(healthRaw),
|
|
35893
36028
|
priceUpper: arrAt(pricesRaw, 0),
|
|
35894
36029
|
priceLower: arrAt(pricesRaw, 1),
|
|
35895
|
-
bands: isFailedCall(ticksRaw) || !Array.isArray(ticksRaw) ? void 0 : [Number(
|
|
36030
|
+
bands: isFailedCall(ticksRaw) || !Array.isArray(ticksRaw) ? void 0 : [Number(big13(ticksRaw[0])), Number(big13(ticksRaw[1]))],
|
|
35896
36031
|
delegated: isFailedCall(approvalRaw) ? false : approvalRaw === true,
|
|
35897
|
-
vaultShares: isFailedCall(vaultSharesRaw) ? 0n :
|
|
35898
|
-
gaugeShares: isFailedCall(gaugeSharesRaw) ? 0n :
|
|
35899
|
-
shareToAsset: isFailedCall(shareToAssetRaw) ? 0n :
|
|
36032
|
+
vaultShares: isFailedCall(vaultSharesRaw) ? 0n : big13(vaultSharesRaw),
|
|
36033
|
+
gaugeShares: isFailedCall(gaugeSharesRaw) ? 0n : big13(gaugeSharesRaw),
|
|
36034
|
+
shareToAsset: isFailedCall(shareToAssetRaw) ? 0n : big13(shareToAssetRaw)
|
|
35900
36035
|
});
|
|
35901
36036
|
}
|
|
35902
36037
|
return out;
|
|
@@ -35925,7 +36060,7 @@ var statesFromLens = (rows) => {
|
|
|
35925
36060
|
}
|
|
35926
36061
|
return out;
|
|
35927
36062
|
};
|
|
35928
|
-
var
|
|
36063
|
+
var big13 = (v) => {
|
|
35929
36064
|
try {
|
|
35930
36065
|
if (typeof v === "bigint") return v;
|
|
35931
36066
|
if (typeof v === "number" || typeof v === "string") return BigInt(v);
|
|
@@ -35935,7 +36070,7 @@ var big12 = (v) => {
|
|
|
35935
36070
|
};
|
|
35936
36071
|
var arrAt = (v, i) => {
|
|
35937
36072
|
if (isFailedCall(v) || !Array.isArray(v)) return 0n;
|
|
35938
|
-
return
|
|
36073
|
+
return big13(v[i]);
|
|
35939
36074
|
};
|
|
35940
36075
|
var getLlamaLendUserDataConverter = (lender, chainId, account, meta) => {
|
|
35941
36076
|
const cfg = llamaLendConfigFor(lender, chainId);
|
|
@@ -36074,7 +36209,7 @@ var getLlamaLendUserDataConverter = (lender, chainId, account, meta) => {
|
|
|
36074
36209
|
expected
|
|
36075
36210
|
];
|
|
36076
36211
|
};
|
|
36077
|
-
var
|
|
36212
|
+
var big14 = (v) => {
|
|
36078
36213
|
try {
|
|
36079
36214
|
if (typeof v === "bigint") return v;
|
|
36080
36215
|
if (typeof v === "number" || typeof v === "string") return BigInt(v);
|
|
@@ -36082,7 +36217,7 @@ var big13 = (v) => {
|
|
|
36082
36217
|
}
|
|
36083
36218
|
return 0n;
|
|
36084
36219
|
};
|
|
36085
|
-
var tupleAt = (v, i) => Array.isArray(v) ?
|
|
36220
|
+
var tupleAt = (v, i) => Array.isArray(v) ? big14(v[i]) : 0n;
|
|
36086
36221
|
var ONE4 = 10n ** 18n;
|
|
36087
36222
|
function sharesToAmount(shares, totalAmount, totalShares) {
|
|
36088
36223
|
if (totalShares === 0n || shares === 0n) return 0n;
|
|
@@ -36108,7 +36243,7 @@ var getResupplyUserDataConverter = (lender, chainId, account, meta) => {
|
|
|
36108
36243
|
if (isFailedCall(accounting) || !Array.isArray(accounting)) return;
|
|
36109
36244
|
const totalBorrowAmount = tupleAt(accounting, 1);
|
|
36110
36245
|
const totalBorrowShares = tupleAt(accounting, 2);
|
|
36111
|
-
const sharePrice = isFailedCall(data[base + 1]) ? 0n :
|
|
36246
|
+
const sharePrice = isFailedCall(data[base + 1]) ? 0n : big14(data[base + 1]);
|
|
36112
36247
|
const lenderKey = resupplyLenderKey(lender, chainId, pair);
|
|
36113
36248
|
const metaMap = meta?.[lenderKey];
|
|
36114
36249
|
if (!metaMap) return;
|
|
@@ -36206,7 +36341,7 @@ var getResupplyUserDataConverter = (lender, chainId, account, meta) => {
|
|
|
36206
36341
|
expected
|
|
36207
36342
|
];
|
|
36208
36343
|
};
|
|
36209
|
-
var
|
|
36344
|
+
var big15 = (v) => {
|
|
36210
36345
|
try {
|
|
36211
36346
|
if (typeof v === "bigint") return v;
|
|
36212
36347
|
if (typeof v === "number" || typeof v === "string") return BigInt(v);
|
|
@@ -36241,9 +36376,9 @@ var getFraxlendUserDataConverter = (lender, chainId, account, meta) => {
|
|
|
36241
36376
|
const fTokenRaw = data[base + 2];
|
|
36242
36377
|
const previewRaw = data[base + 3];
|
|
36243
36378
|
if (isFailedCall(collRaw) || isFailedCall(sharesRaw)) return;
|
|
36244
|
-
const collateral =
|
|
36245
|
-
const borrowShares =
|
|
36246
|
-
const fTokenShares = isFailedCall(fTokenRaw) ? 0n :
|
|
36379
|
+
const collateral = big15(collRaw);
|
|
36380
|
+
const borrowShares = big15(sharesRaw);
|
|
36381
|
+
const fTokenShares = isFailedCall(fTokenRaw) ? 0n : big15(fTokenRaw);
|
|
36247
36382
|
if (collateral === 0n && borrowShares === 0n && fTokenShares === 0n)
|
|
36248
36383
|
return;
|
|
36249
36384
|
let totalBorrowAmount = 0n;
|
|
@@ -36253,10 +36388,10 @@ var getFraxlendUserDataConverter = (lender, chainId, account, meta) => {
|
|
|
36253
36388
|
if (!isFailedCall(previewRaw) && previewRaw) {
|
|
36254
36389
|
const ta = previewRaw[4];
|
|
36255
36390
|
const tb = previewRaw[5];
|
|
36256
|
-
totalAssetAmount =
|
|
36257
|
-
totalAssetShares =
|
|
36258
|
-
totalBorrowAmount =
|
|
36259
|
-
totalBorrowShares =
|
|
36391
|
+
totalAssetAmount = big15(ta?.amount ?? ta?.[0]);
|
|
36392
|
+
totalAssetShares = big15(ta?.shares ?? ta?.[1]);
|
|
36393
|
+
totalBorrowAmount = big15(tb?.amount ?? tb?.[0]);
|
|
36394
|
+
totalBorrowShares = big15(tb?.shares ?? tb?.[1]);
|
|
36260
36395
|
}
|
|
36261
36396
|
const debt = fraxlendToAmount(
|
|
36262
36397
|
borrowShares,
|
|
@@ -36366,7 +36501,7 @@ var getFraxlendUserDataConverter = (lender, chainId, account, meta) => {
|
|
|
36366
36501
|
];
|
|
36367
36502
|
};
|
|
36368
36503
|
var WAD14 = 10n ** 18n;
|
|
36369
|
-
var
|
|
36504
|
+
var big16 = (v) => {
|
|
36370
36505
|
try {
|
|
36371
36506
|
if (typeof v === "bigint") return v;
|
|
36372
36507
|
if (typeof v === "number" || typeof v === "string") return BigInt(v);
|
|
@@ -36374,7 +36509,7 @@ var big15 = (v) => {
|
|
|
36374
36509
|
}
|
|
36375
36510
|
return 0n;
|
|
36376
36511
|
};
|
|
36377
|
-
var tupleAt2 = (v, i) => Array.isArray(v) ?
|
|
36512
|
+
var tupleAt2 = (v, i) => Array.isArray(v) ? big16(v[i]) : 0n;
|
|
36378
36513
|
var HOLD_PERIOD_SECONDS = 1200n;
|
|
36379
36514
|
var getCurvanceUserDataConverter = (lender, chainId, account, meta) => {
|
|
36380
36515
|
const cfg = curvanceConfigFor(lender, chainId);
|
|
@@ -36397,7 +36532,7 @@ var getCurvanceUserDataConverter = (lender, chainId, account, meta) => {
|
|
|
36397
36532
|
const cooldownRaw = data[base];
|
|
36398
36533
|
const status = data[base + 1];
|
|
36399
36534
|
if (isFailedCall(status) || !Array.isArray(status)) continue;
|
|
36400
|
-
const cooldownTimestamp = isFailedCall(cooldownRaw) ? 0n :
|
|
36535
|
+
const cooldownTimestamp = isFailedCall(cooldownRaw) ? 0n : big16(cooldownRaw);
|
|
36401
36536
|
const holdPeriodEndsAt = cooldownTimestamp > 0n ? cooldownTimestamp + HOLD_PERIOD_SECONDS : 0n;
|
|
36402
36537
|
const holdPeriodActive = holdPeriodEndsAt > nowSeconds;
|
|
36403
36538
|
const lenderKey = curvanceLenderKey(lender, chainId, p.marketManager);
|
|
@@ -36419,10 +36554,10 @@ var getCurvanceUserDataConverter = (lender, chainId, account, meta) => {
|
|
|
36419
36554
|
let rows = 0;
|
|
36420
36555
|
p.activeTokens.forEach(({ cToken, asset }, i) => {
|
|
36421
36556
|
const tokenBase = base + CURVANCE_MARKET_READS + i * CURVANCE_READS_PER_TOKEN;
|
|
36422
|
-
const shares = isFailedCall(data[tokenBase]) ? 0n :
|
|
36423
|
-
const collateralShares = isFailedCall(data[tokenBase + 1]) ? 0n :
|
|
36424
|
-
const debtRaw = isFailedCall(data[tokenBase + 2]) ? 0n :
|
|
36425
|
-
const exchangeRate = isFailedCall(data[tokenBase + 3]) ? 0n :
|
|
36557
|
+
const shares = isFailedCall(data[tokenBase]) ? 0n : big16(data[tokenBase]);
|
|
36558
|
+
const collateralShares = isFailedCall(data[tokenBase + 1]) ? 0n : big16(data[tokenBase + 1]);
|
|
36559
|
+
const debtRaw = isFailedCall(data[tokenBase + 2]) ? 0n : big16(data[tokenBase + 2]);
|
|
36560
|
+
const exchangeRate = isFailedCall(data[tokenBase + 3]) ? 0n : big16(data[tokenBase + 3]);
|
|
36426
36561
|
info.tokens[cToken.toLowerCase()] = {
|
|
36427
36562
|
shares: shares.toString(),
|
|
36428
36563
|
collateralShares: collateralShares.toString(),
|
|
@@ -36482,7 +36617,7 @@ var getCurvanceUserDataConverter = (lender, chainId, account, meta) => {
|
|
|
36482
36617
|
];
|
|
36483
36618
|
};
|
|
36484
36619
|
var WAD15 = 10n ** 18n;
|
|
36485
|
-
var
|
|
36620
|
+
var big17 = (v) => {
|
|
36486
36621
|
try {
|
|
36487
36622
|
if (typeof v === "bigint") return v;
|
|
36488
36623
|
if (typeof v === "number" || typeof v === "string") return BigInt(v);
|
|
@@ -36504,13 +36639,13 @@ var getTwyneUserDataConverter = (lender, chainId, account, meta) => {
|
|
|
36504
36639
|
const base = i * TWYNE_READS_PER_VAULT;
|
|
36505
36640
|
const totalRaw = data[base];
|
|
36506
36641
|
if (isFailedCall(totalRaw)) return;
|
|
36507
|
-
const total =
|
|
36508
|
-
const reserved = isFailedCall(data[base + 1]) ? 0n :
|
|
36509
|
-
const debt = isFailedCall(data[base + 2]) ? 0n :
|
|
36510
|
-
const liqLtv = isFailedCall(data[base + 3]) ? 0n :
|
|
36642
|
+
const total = big17(totalRaw);
|
|
36643
|
+
const reserved = isFailedCall(data[base + 1]) ? 0n : big17(data[base + 1]);
|
|
36644
|
+
const debt = isFailedCall(data[base + 2]) ? 0n : big17(data[base + 2]);
|
|
36645
|
+
const liqLtv = isFailedCall(data[base + 3]) ? 0n : big17(data[base + 3]);
|
|
36511
36646
|
const canLiquidate = isFailedCall(data[base + 4]) ? false : Boolean(data[base + 4]);
|
|
36512
36647
|
const extLiquidated = isFailedCall(data[base + 5]) ? false : Boolean(data[base + 5]);
|
|
36513
|
-
const releasable = isFailedCall(data[base + 6]) ? 0n :
|
|
36648
|
+
const releasable = isFailedCall(data[base + 6]) ? 0n : big17(data[base + 6]);
|
|
36514
36649
|
const scale3 = ref.collateralToUnderlying ?? WAD15;
|
|
36515
36650
|
const userCollateral = total > reserved ? total - reserved : 0n;
|
|
36516
36651
|
if (userCollateral === 0n && debt === 0n) return;
|
|
@@ -36626,7 +36761,7 @@ var getTwyneUserDataConverter = (lender, chainId, account, meta) => {
|
|
|
36626
36761
|
];
|
|
36627
36762
|
};
|
|
36628
36763
|
var RAY7 = 10n ** 27n;
|
|
36629
|
-
var
|
|
36764
|
+
var big18 = (v) => {
|
|
36630
36765
|
try {
|
|
36631
36766
|
if (typeof v === "bigint") return v;
|
|
36632
36767
|
if (typeof v === "number" || typeof v === "string") return BigInt(v);
|
|
@@ -36634,7 +36769,7 @@ var big17 = (v) => {
|
|
|
36634
36769
|
}
|
|
36635
36770
|
return 0n;
|
|
36636
36771
|
};
|
|
36637
|
-
var field9 = (res, name, idx) =>
|
|
36772
|
+
var field9 = (res, name, idx) => big18(res?.[name] ?? res?.[idx]);
|
|
36638
36773
|
var getDssUserDataConverter = (lender, chainId, account, meta) => {
|
|
36639
36774
|
const cfg = dssConfigFor(lender, chainId);
|
|
36640
36775
|
const markets = dssChainData(lender, chainId)?.markets ?? [];
|
|
@@ -36749,7 +36884,7 @@ var getDssUserDataConverter = (lender, chainId, account, meta) => {
|
|
|
36749
36884
|
expected
|
|
36750
36885
|
];
|
|
36751
36886
|
};
|
|
36752
|
-
var
|
|
36887
|
+
var big19 = (v) => {
|
|
36753
36888
|
try {
|
|
36754
36889
|
if (typeof v === "bigint") return v;
|
|
36755
36890
|
if (typeof v === "number" || typeof v === "string") return BigInt(v);
|
|
@@ -36779,11 +36914,11 @@ var getFrankencoinUserDataConverter = (lender, chainId, account, meta) => {
|
|
|
36779
36914
|
const ownerRes = data[base];
|
|
36780
36915
|
if (isFailedCall(ownerRes)) return;
|
|
36781
36916
|
if (String(ownerRes).toLowerCase() !== lowerAccount) return;
|
|
36782
|
-
const minted =
|
|
36783
|
-
const price2 =
|
|
36784
|
-
const expiration =
|
|
36785
|
-
const challenged =
|
|
36786
|
-
const coll =
|
|
36917
|
+
const minted = big19(data[base + 1]);
|
|
36918
|
+
const price2 = big19(data[base + 2]);
|
|
36919
|
+
const expiration = big19(data[base + 3]);
|
|
36920
|
+
const challenged = big19(data[base + 4]);
|
|
36921
|
+
const coll = big19(data[base + 5]);
|
|
36787
36922
|
if (minted === 0n && coll === 0n) return;
|
|
36788
36923
|
const market = marketByOriginal.get(p.original);
|
|
36789
36924
|
if (!market) return;
|
|
@@ -36884,7 +37019,7 @@ var getFrankencoinUserDataConverter = (lender, chainId, account, meta) => {
|
|
|
36884
37019
|
|
|
36885
37020
|
// src/lending/user-data/teller/userCallParse.ts
|
|
36886
37021
|
var nowSec7 = () => Math.floor(Date.now() / 1e3);
|
|
36887
|
-
var
|
|
37022
|
+
var big20 = (v) => {
|
|
36888
37023
|
try {
|
|
36889
37024
|
if (typeof v === "bigint") return v;
|
|
36890
37025
|
if (typeof v === "number" || typeof v === "string") return BigInt(v);
|
|
@@ -36906,7 +37041,7 @@ var getTellerUserDataConverter = (_lender, chainId, account, meta) => {
|
|
|
36906
37041
|
const base = i * TELLER_CALLS_PER_BID;
|
|
36907
37042
|
const bidRes = data[base];
|
|
36908
37043
|
const owed = data[base + 1];
|
|
36909
|
-
const collAmount =
|
|
37044
|
+
const collAmount = big20(data[base + 2]);
|
|
36910
37045
|
const defaulted = !!data[base + 3];
|
|
36911
37046
|
if (isFailedCall(bidRes) || isFailedCall(owed) || !bidRes) return;
|
|
36912
37047
|
const pool = b.pool;
|
|
@@ -36927,17 +37062,17 @@ var getTellerUserDataConverter = (_lender, chainId, account, meta) => {
|
|
|
36927
37062
|
const collDisplay = collMeta ? getDisplayPrice(collMeta) : 0;
|
|
36928
37063
|
const collOracle = collMeta ? getOraclePrice(collMeta) : 0;
|
|
36929
37064
|
const collHist = collMeta?.price?.priceUsd24h ?? collDisplay;
|
|
36930
|
-
const owedPrincipal =
|
|
36931
|
-
const owedInterest =
|
|
37065
|
+
const owedPrincipal = big20(field10(owed, "principal", 0));
|
|
37066
|
+
const owedInterest = big20(field10(owed, "interest", 1));
|
|
36932
37067
|
const owedTotal = owedPrincipal + owedInterest;
|
|
36933
37068
|
if (owedTotal === 0n && collAmount === 0n) return;
|
|
36934
37069
|
const loanDetails = field10(bidRes, "loanDetails", 5);
|
|
36935
37070
|
const terms = field10(bidRes, "terms", 6);
|
|
36936
37071
|
const acceptedTs = Number(
|
|
36937
|
-
|
|
37072
|
+
big20(field10(loanDetails, "acceptedTimestamp", 4))
|
|
36938
37073
|
);
|
|
36939
|
-
const loanDuration = Number(
|
|
36940
|
-
const aprBps = Number(
|
|
37074
|
+
const loanDuration = Number(big20(field10(loanDetails, "loanDuration", 6)));
|
|
37075
|
+
const aprBps = Number(big20(field10(terms, "APR", 2)));
|
|
36941
37076
|
const maturity = acceptedTs > 0 ? acceptedTs + loanDuration : void 0;
|
|
36942
37077
|
const isMatured2 = defaulted || maturity !== void 0 && maturity < now;
|
|
36943
37078
|
const collStr = parseRawAmount(collAmount.toString(), collDecimals);
|
|
@@ -37334,6 +37469,13 @@ function getUserDataConverter(lender, chainId, account, params, meta) {
|
|
|
37334
37469
|
return getInverseUserDataConverter(lender, chainId, account, meta);
|
|
37335
37470
|
if (isCooler(lender))
|
|
37336
37471
|
return getCoolerUserDataConverter(lender, chainId, account, meta?.[lender]);
|
|
37472
|
+
if (isFlyingTulip(lender))
|
|
37473
|
+
return getFlyingTulipUserDataConverter(
|
|
37474
|
+
lender,
|
|
37475
|
+
chainId,
|
|
37476
|
+
account,
|
|
37477
|
+
meta?.[lender]
|
|
37478
|
+
);
|
|
37337
37479
|
if (isLlamaLend(lender))
|
|
37338
37480
|
return getLlamaLendUserDataConverter(lender, chainId, account, meta);
|
|
37339
37481
|
if (isResupply(lender))
|
|
@@ -42012,6 +42154,7 @@ var getAbi2 = (lender) => {
|
|
|
42012
42154
|
if (isInverse(lender))
|
|
42013
42155
|
return [...InverseMarketAbi, ...InverseEscrowAbi, ...InverseDbrAbi];
|
|
42014
42156
|
if (isCooler(lender)) return [...CoolerMonoAbi];
|
|
42157
|
+
if (isFlyingTulip(lender)) return [...FlyingTulipLendingLensAbi];
|
|
42015
42158
|
if (isLlamaLend(lender))
|
|
42016
42159
|
return [...LlamaLendControllerAbi, ...LlamaLendAmmAbi];
|
|
42017
42160
|
if (isDssType(lender)) return [...UsddVatAbi];
|
|
@@ -42480,7 +42623,11 @@ function toSiloShares(entry, amount4, chainId, lender, tokenAddress) {
|
|
|
42480
42623
|
return amount4;
|
|
42481
42624
|
}
|
|
42482
42625
|
}
|
|
42483
|
-
function resolveDebitDataKey(chainId, lender, tokenAddress, cToken, isProtected) {
|
|
42626
|
+
function resolveDebitDataKey(chainId, lender, tokenAddress, cToken, isProtected, isBorrow, mode) {
|
|
42627
|
+
if (isVenusType(lender) && isBorrow) {
|
|
42628
|
+
const comptroller = getCompoundV2Comptroller$1(chainId, lender);
|
|
42629
|
+
if (comptroller) return comptroller.toLowerCase();
|
|
42630
|
+
}
|
|
42484
42631
|
if (isCompoundV2Type(lender) || isVenusType(lender)) {
|
|
42485
42632
|
if (cToken) return cToken.toLowerCase();
|
|
42486
42633
|
const tokenMap = getCompoundV2CollateralTokens(chainId, lender);
|
|
@@ -42500,20 +42647,39 @@ function resolveDebitDataKey(chainId, lender, tokenAddress, cToken, isProtected)
|
|
|
42500
42647
|
);
|
|
42501
42648
|
if (comet) return comet;
|
|
42502
42649
|
}
|
|
42650
|
+
if (isFluid(lender)) {
|
|
42651
|
+
return FLUID_VAULT_FACTORY.toLowerCase();
|
|
42652
|
+
}
|
|
42503
42653
|
if (isAaveType(lender)) {
|
|
42504
|
-
|
|
42505
|
-
|
|
42654
|
+
if (isBorrow) {
|
|
42655
|
+
try {
|
|
42656
|
+
const debtToken = getAaveStyleLenderTokenAddress(
|
|
42657
|
+
chainId,
|
|
42658
|
+
tokenAddress,
|
|
42659
|
+
lender,
|
|
42660
|
+
mode ?? LendingMode.VARIABLE
|
|
42661
|
+
);
|
|
42662
|
+
if (debtToken) return debtToken.toLowerCase();
|
|
42663
|
+
} catch {
|
|
42664
|
+
}
|
|
42665
|
+
}
|
|
42666
|
+
try {
|
|
42667
|
+
const aToken = getAaveCollateralTokenAddress(chainId, lender, tokenAddress);
|
|
42668
|
+
if (aToken) return aToken;
|
|
42669
|
+
} catch {
|
|
42670
|
+
}
|
|
42506
42671
|
}
|
|
42507
42672
|
if (isSiloV2Type(lender) || isSiloV3Type(lender)) {
|
|
42508
42673
|
const half = getSiloHalfForUnderlying(chainId, lender, tokenAddress);
|
|
42509
42674
|
if (half) {
|
|
42675
|
+
if (isBorrow) return half.debtShareToken.toLowerCase();
|
|
42510
42676
|
return isProtected ? half.protectedShareToken.toLowerCase() : half.collateralShareToken.toLowerCase();
|
|
42511
42677
|
}
|
|
42512
42678
|
}
|
|
42513
42679
|
return tokenAddress.toLowerCase();
|
|
42514
42680
|
}
|
|
42515
42681
|
function needsLenderApproval(params) {
|
|
42516
|
-
const { lender, lenderDebitData, tokenAddress, amount: amount4, chainId, cToken, isProtected } = params;
|
|
42682
|
+
const { lender, lenderDebitData, tokenAddress, amount: amount4, chainId, cToken, isProtected, isBorrow, mode } = params;
|
|
42517
42683
|
if (!lenderDebitData) return true;
|
|
42518
42684
|
if (isAaveV4Type(lender)) {
|
|
42519
42685
|
const key4 = (params.aaveV4Spoke ?? tokenAddress).toLowerCase();
|
|
@@ -42526,9 +42692,15 @@ function needsLenderApproval(params) {
|
|
|
42526
42692
|
if (!entry2 || entry2.amount === void 0) return true;
|
|
42527
42693
|
return entry2.amount === 0n;
|
|
42528
42694
|
}
|
|
42529
|
-
const key3 = resolveDebitDataKey(chainId, lender, tokenAddress, cToken, isProtected);
|
|
42695
|
+
const key3 = resolveDebitDataKey(chainId, lender, tokenAddress, cToken, isProtected, isBorrow, mode);
|
|
42530
42696
|
const entry = lenderDebitData[key3];
|
|
42531
42697
|
if (!entry || entry.amount === void 0) return true;
|
|
42698
|
+
if (isVenusType(lender) && isBorrow) {
|
|
42699
|
+
return entry.amount === 0n;
|
|
42700
|
+
}
|
|
42701
|
+
if (isFluid(lender)) {
|
|
42702
|
+
return entry.amount === 0n;
|
|
42703
|
+
}
|
|
42532
42704
|
if (isCompoundV2Type(lender) || isVenusType(lender)) {
|
|
42533
42705
|
const requiredShares = toCompoundV2Shares(entry, amount4);
|
|
42534
42706
|
return entry.amount < requiredShares;
|
|
@@ -47928,8 +48100,8 @@ var MAX_RPC_TRIES6 = 2;
|
|
|
47928
48100
|
var ONCHAIN_DEADLINE_MS2 = 12e3;
|
|
47929
48101
|
var CURVE_SAVINGS_YIELD_URL = "https://prices.curve.finance/v1/crvusd/savings/yield";
|
|
47930
48102
|
var SCRVUSD_KEY = "SCRVUSD";
|
|
47931
|
-
var SCRVUSD_GROUP_KEY = "Savings crvUSD::
|
|
47932
|
-
var
|
|
48103
|
+
var SCRVUSD_GROUP_KEY = "Savings crvUSD::scrvUSD";
|
|
48104
|
+
var SCRVUSD_GROUP_KEY_UPPER = "Savings crvUSD::SCRVUSD";
|
|
47933
48105
|
var SCRVUSD_GROUP_KEY_BASE = "Superbridge Bridged scrvUSD::SCRVUSD";
|
|
47934
48106
|
var CONVERT_TO_ASSETS_ABI4 = [
|
|
47935
48107
|
{
|
|
@@ -48004,7 +48176,7 @@ var scrvusdFetcher = {
|
|
|
48004
48176
|
return {
|
|
48005
48177
|
[SCRVUSD_KEY]: apr,
|
|
48006
48178
|
[SCRVUSD_GROUP_KEY]: apr,
|
|
48007
|
-
[
|
|
48179
|
+
[SCRVUSD_GROUP_KEY_UPPER]: apr,
|
|
48008
48180
|
[SCRVUSD_GROUP_KEY_BASE]: apr
|
|
48009
48181
|
};
|
|
48010
48182
|
}
|
|
@@ -49671,6 +49843,333 @@ var BITWAY_ENTRIES = {
|
|
|
49671
49843
|
)
|
|
49672
49844
|
};
|
|
49673
49845
|
|
|
49846
|
+
// src/yields/intrinsic/fetchers/vesper.ts
|
|
49847
|
+
var vesperYieldKey = (chainId, poolAddress) => `VESPER::${chainId}::${poolAddress.toLowerCase()}`;
|
|
49848
|
+
var VESPER_API_HOSTS = {
|
|
49849
|
+
"1": "https://api.vesper.finance",
|
|
49850
|
+
"8453": "https://api-base.vesper.finance",
|
|
49851
|
+
"10": "https://api-optimism.vesper.finance"
|
|
49852
|
+
};
|
|
49853
|
+
var DEFILLAMA_POOLS = {
|
|
49854
|
+
// Ethereum
|
|
49855
|
+
[vesperYieldKey("1", "0xca7c607c590ad16007ccbbba9d26f4df656a36c2")]: "4208b678-e7cc-4060-9c74-88554e8ca81e",
|
|
49856
|
+
// vamsETH 0 %
|
|
49857
|
+
[vesperYieldKey("1", "0x4c73f025a1947ec770327b9956fc61f535f72c22")]: "3987099a-9165-47a3-a92f-df14e8d60e45",
|
|
49858
|
+
// vamsUSD 0.21 %
|
|
49859
|
+
[vesperYieldKey("1", "0x4dbe3f01abe271d3e65432c74851625a8c30aa7b")]: "9b473092-6f2d-4fe6-af5a-f746b77ef5a0",
|
|
49860
|
+
// vaSTETH 1.41 %
|
|
49861
|
+
[vesperYieldKey("1", "0xd1c117319b3595fbc39b471ab1fd485629eb05f2")]: "359dd5cd-67a6-4f6a-83db-1edb301637e7",
|
|
49862
|
+
// vaETH — 9.11 % (see divergence note)
|
|
49863
|
+
[vesperYieldKey("1", "0xa8b607aa09b6a2e306f93e74c282fb13f6a80452")]: "eb342dc8-8d50-4300-8e92-c8d88e026c94",
|
|
49864
|
+
// vaUSDC 3.16 %
|
|
49865
|
+
[vesperYieldKey("1", "0x0538c8bac84e95a9df8ac10aad17dbe81b9e36ee")]: "d07783c3-bd68-4e38-927f-762fcb349dfc",
|
|
49866
|
+
// vaDAI 0.03 %
|
|
49867
|
+
// Base
|
|
49868
|
+
[vesperYieldKey("8453", "0x913ece180df83a2b81a4976f83ca88543a0c51b8")]: "e2b9cdfc-e605-4e5b-9feb-512729addac7",
|
|
49869
|
+
// vamsETH 0.06 %
|
|
49870
|
+
[vesperYieldKey("8453", "0x82562507429876486b60af4f32390ef0947b3d13")]: "aba92dbe-f256-4be3-8fd5-21d6b51bd69c",
|
|
49871
|
+
// vaETH 0.12 %
|
|
49872
|
+
// Optimism
|
|
49873
|
+
[vesperYieldKey("10", "0xdd63ae655b388cd782681b7821be37fdb6d0e78d")]: "fec05017-ea81-417b-ae8b-20a86e4b23a7",
|
|
49874
|
+
// vawstETH 0 %
|
|
49875
|
+
[vesperYieldKey("10", "0x539505dde2b9771debe0898a84441c5e7fdf6bc0")]: "4d94e177-4162-4b30-b72b-f7a77ed0573a",
|
|
49876
|
+
// vaUSDC 0.03 %
|
|
49877
|
+
[vesperYieldKey("10", "0xccf3d1acf799bae67f6e354d685295557cf64761")]: "43e149fc-a0d8-4680-8bb5-8ba12f09e94a"
|
|
49878
|
+
// vaETH 0.6 %
|
|
49879
|
+
};
|
|
49880
|
+
var fetchChainRates = async (chainId, host) => {
|
|
49881
|
+
const res = await fetch(`${host}/pools?stages=prod`, {
|
|
49882
|
+
headers: { accept: "application/json" },
|
|
49883
|
+
signal: AbortSignal.timeout(8e3)
|
|
49884
|
+
});
|
|
49885
|
+
if (!res.ok) throw new Error(`Vesper HTTP ${res.status} (${host})`);
|
|
49886
|
+
const pools = await res.json();
|
|
49887
|
+
if (!Array.isArray(pools)) throw new Error(`Vesper: non-array (${host})`);
|
|
49888
|
+
const out = {};
|
|
49889
|
+
for (const p of pools) {
|
|
49890
|
+
if (!p?.address) continue;
|
|
49891
|
+
const rate = p.actualRates?.["30"] ?? p.actualRates?.["14"];
|
|
49892
|
+
if (typeof rate !== "number" || !Number.isFinite(rate)) continue;
|
|
49893
|
+
out[vesperYieldKey(chainId, p.address)] = rate;
|
|
49894
|
+
}
|
|
49895
|
+
return out;
|
|
49896
|
+
};
|
|
49897
|
+
var vesperFetcher = {
|
|
49898
|
+
label: "VESPER",
|
|
49899
|
+
fetch: async () => {
|
|
49900
|
+
const legs = await Promise.allSettled(
|
|
49901
|
+
Object.entries(VESPER_API_HOSTS).map(
|
|
49902
|
+
([chainId, host]) => fetchChainRates(chainId, host)
|
|
49903
|
+
)
|
|
49904
|
+
);
|
|
49905
|
+
const out = {};
|
|
49906
|
+
for (const leg of legs) {
|
|
49907
|
+
if (leg.status === "fulfilled") Object.assign(out, leg.value);
|
|
49908
|
+
}
|
|
49909
|
+
const missing = Object.entries(DEFILLAMA_POOLS).filter(
|
|
49910
|
+
([key3]) => out[key3] === void 0
|
|
49911
|
+
);
|
|
49912
|
+
if (missing.length > 0) {
|
|
49913
|
+
const fills = await Promise.allSettled(
|
|
49914
|
+
missing.map(async ([key3, poolId]) => {
|
|
49915
|
+
const apy = await fetchDefiLlamaApy(poolId);
|
|
49916
|
+
return [key3, apyToAprPercent(apy)];
|
|
49917
|
+
})
|
|
49918
|
+
);
|
|
49919
|
+
for (const f of fills) {
|
|
49920
|
+
if (f.status === "fulfilled") out[f.value[0]] = f.value[1];
|
|
49921
|
+
}
|
|
49922
|
+
}
|
|
49923
|
+
if (Object.keys(out).length === 0) {
|
|
49924
|
+
throw new Error("Vesper: no rates from any API host or DefiLlama");
|
|
49925
|
+
}
|
|
49926
|
+
return out;
|
|
49927
|
+
}
|
|
49928
|
+
};
|
|
49929
|
+
|
|
49930
|
+
// src/vaults/savings/registryVesper.ts
|
|
49931
|
+
var VESPER_ENTRIES = {
|
|
49932
|
+
"1": [
|
|
49933
|
+
{
|
|
49934
|
+
// vamsETH — the largest Vesper pool. NB **msETH IS DEPEGGED**:
|
|
49935
|
+
// CoinGecko and DefiLlama both price it ~0.675 of ETH (conf 0.99,
|
|
49936
|
+
// 2026-08-27) while Vesper's own API prices it AT PAR — so Vesper's
|
|
49937
|
+
// "$34.7M" headline is really ~$23M at market. Our price feed
|
|
49938
|
+
// carries the market price, so the row's USD columns are honest;
|
|
49939
|
+
// the DESCRIPTION is the only place the depeg itself can be said
|
|
49940
|
+
// (the wiTRY lira rule: `supplyRate` is asset-denominated and no
|
|
49941
|
+
// numeric field can flag a broken peg).
|
|
49942
|
+
reader: "vesper-pool",
|
|
49943
|
+
address: "0xca7c607c590ad16007ccbbba9d26f4df656a36c2",
|
|
49944
|
+
underlying: "0x64351fc9810adad17a690e4e1717df5e7e085160",
|
|
49945
|
+
// msETH
|
|
49946
|
+
symbol: "vamsETH",
|
|
49947
|
+
brand: "Vesper",
|
|
49948
|
+
description: "Vesper's msETH Grow pool: msETH (Metronome's ETH-pegged synth, from Vesper's sister protocol) is lent through Morpho and StakeDAO strategies, and the share price accrues what they earn net of a 0.5% fee on yield. The rate is the realized trailing-30-day figure and is earned in msETH \u2014 which has traded MATERIALLY BELOW its ETH peg (about a third below at integration), so the position's ETH value depends on that discount as much as on the rate. Deposit and single-transaction withdrawal, both strictly for the calling wallet.",
|
|
49949
|
+
decimals: 18,
|
|
49950
|
+
isRebasing: false,
|
|
49951
|
+
isMintable: true,
|
|
49952
|
+
withdrawalMode: "instant",
|
|
49953
|
+
yieldFetcher: vesperFetcher,
|
|
49954
|
+
yieldKey: vesperYieldKey(
|
|
49955
|
+
"1",
|
|
49956
|
+
"0xca7c607c590ad16007ccbbba9d26f4df656a36c2"
|
|
49957
|
+
)
|
|
49958
|
+
},
|
|
49959
|
+
{
|
|
49960
|
+
// vamsUSD — the USD-synth sibling of vamsETH, and **msUSD IS
|
|
49961
|
+
// DEPEGGED harder in ranking terms**: ~$0.674 on CoinGecko and
|
|
49962
|
+
// DefiLlama (conf 0.99, 2026-08-27) against Vesper's own par
|
|
49963
|
+
// pricing — ~$21.5M at market, not "$31.9M". See the vamsETH note.
|
|
49964
|
+
reader: "vesper-pool",
|
|
49965
|
+
address: "0x4c73f025a1947ec770327b9956fc61f535f72c22",
|
|
49966
|
+
underlying: "0xab5eb14c09d416f0ac63661e57edb7aecdb9befa",
|
|
49967
|
+
// msUSD
|
|
49968
|
+
symbol: "vamsUSD",
|
|
49969
|
+
brand: "Vesper",
|
|
49970
|
+
description: "Vesper's msUSD Grow pool: msUSD (Metronome's USD-pegged synth) is lent through Morpho and StakeDAO strategies, and the share price accrues what they earn net of a 0.5% fee on yield. The rate is the realized trailing-30-day figure and is earned in msUSD \u2014 which has traded MATERIALLY BELOW its dollar peg (around $0.67 at integration), so the position's dollar value depends on that discount as much as on the rate. Deposit and single-transaction withdrawal, both strictly for the calling wallet.",
|
|
49971
|
+
decimals: 18,
|
|
49972
|
+
isRebasing: false,
|
|
49973
|
+
isMintable: true,
|
|
49974
|
+
withdrawalMode: "instant",
|
|
49975
|
+
yieldFetcher: vesperFetcher,
|
|
49976
|
+
yieldKey: vesperYieldKey(
|
|
49977
|
+
"1",
|
|
49978
|
+
"0x4c73f025a1947ec770327b9956fc61f535f72c22"
|
|
49979
|
+
)
|
|
49980
|
+
},
|
|
49981
|
+
{
|
|
49982
|
+
// vaSTETH — ~$14.3M. NB the underlying stETH REBASES, and the rebase
|
|
49983
|
+
// accrues to the pool's balance, i.e. INTO pricePerShare — so the
|
|
49984
|
+
// pool's realized rate (~1.6 %) is the TOTAL stETH-denominated
|
|
49985
|
+
// return including the staking rebase, not a spread on top of it.
|
|
49986
|
+
// Holding raw stETH paid more when this was written; the row states
|
|
49987
|
+
// the basis so the comparison is at least possible.
|
|
49988
|
+
reader: "vesper-pool",
|
|
49989
|
+
address: "0x4dbe3f01abe271d3e65432c74851625a8c30aa7b",
|
|
49990
|
+
underlying: "0xae7ab96520de3a18e5e111b5eaab095312d7fe84",
|
|
49991
|
+
// stETH
|
|
49992
|
+
symbol: "vaSTETH",
|
|
49993
|
+
brand: "Vesper",
|
|
49994
|
+
description: "Vesper's stETH Grow pool: stETH is deployed as collateral in Aave-based borrow strategies and the share price accrues the result. Because stETH rebases into the pool, the published realized rate is the pool's TOTAL stETH-denominated return \u2014 including the staking rebase, not on top of it \u2014 and has trailed plain stETH's own yield. Deposit and single-transaction withdrawal, both strictly for the calling wallet.",
|
|
49995
|
+
decimals: 18,
|
|
49996
|
+
isRebasing: false,
|
|
49997
|
+
isMintable: true,
|
|
49998
|
+
withdrawalMode: "instant",
|
|
49999
|
+
yieldFetcher: vesperFetcher,
|
|
50000
|
+
yieldKey: vesperYieldKey(
|
|
50001
|
+
"1",
|
|
50002
|
+
"0x4dbe3f01abe271d3e65432c74851625a8c30aa7b"
|
|
50003
|
+
)
|
|
50004
|
+
},
|
|
50005
|
+
{
|
|
50006
|
+
// vaETH — ~$4.2M. `token()` is WETH; the payable no-arg `deposit()`
|
|
50007
|
+
// exists but is not routed.
|
|
50008
|
+
reader: "vesper-pool",
|
|
50009
|
+
address: "0xd1c117319b3595fbc39b471ab1fd485629eb05f2",
|
|
50010
|
+
underlying: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
|
|
50011
|
+
// WETH
|
|
50012
|
+
symbol: "vaETH",
|
|
50013
|
+
brand: "Vesper",
|
|
50014
|
+
description: "Vesper's ETH Grow pool: WETH is routed through lending strategies (Morpho, Compound V3 and others) and the share price accrues what they earn net of a 1% fee on yield. The published rate is the realized trailing-30-day figure. Deposit (in WETH) and single-transaction withdrawal, both strictly for the calling wallet.",
|
|
50015
|
+
decimals: 18,
|
|
50016
|
+
isRebasing: false,
|
|
50017
|
+
isMintable: true,
|
|
50018
|
+
withdrawalMode: "instant",
|
|
50019
|
+
yieldFetcher: vesperFetcher,
|
|
50020
|
+
yieldKey: vesperYieldKey(
|
|
50021
|
+
"1",
|
|
50022
|
+
"0xd1c117319b3595fbc39b471ab1fd485629eb05f2"
|
|
50023
|
+
)
|
|
50024
|
+
},
|
|
50025
|
+
{
|
|
50026
|
+
// vaUSDC — ~$509k. 18-dec shares over 6-dec USDC (every v5 share is
|
|
50027
|
+
// 18-dec regardless of the underlying).
|
|
50028
|
+
reader: "vesper-pool",
|
|
50029
|
+
address: "0xa8b607aa09b6a2e306f93e74c282fb13f6a80452",
|
|
50030
|
+
underlying: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
|
50031
|
+
// USDC
|
|
50032
|
+
symbol: "vaUSDC",
|
|
50033
|
+
brand: "Vesper",
|
|
50034
|
+
decimals: 18,
|
|
50035
|
+
underlyingDecimals: 6,
|
|
50036
|
+
description: "Vesper's USDC Grow pool: USDC is routed through Morpho and Convex lending strategies and the share price accrues what they earn net of a 2% fee on yield. The published rate is the realized trailing-30-day figure. Deposit and single-transaction withdrawal, both strictly for the calling wallet.",
|
|
50037
|
+
isRebasing: false,
|
|
50038
|
+
isMintable: true,
|
|
50039
|
+
withdrawalMode: "instant",
|
|
50040
|
+
yieldFetcher: vesperFetcher,
|
|
50041
|
+
yieldKey: vesperYieldKey(
|
|
50042
|
+
"1",
|
|
50043
|
+
"0xa8b607aa09b6a2e306f93e74c282fb13f6a80452"
|
|
50044
|
+
)
|
|
50045
|
+
},
|
|
50046
|
+
{
|
|
50047
|
+
// vaDAI — ~$151k, a single Yearn V3 strategy.
|
|
50048
|
+
reader: "vesper-pool",
|
|
50049
|
+
address: "0x0538c8bac84e95a9df8ac10aad17dbe81b9e36ee",
|
|
50050
|
+
underlying: "0x6b175474e89094c44da98b954eedeac495271d0f",
|
|
50051
|
+
// DAI
|
|
50052
|
+
symbol: "vaDAI",
|
|
50053
|
+
brand: "Vesper",
|
|
50054
|
+
description: "Vesper's DAI Grow pool: DAI is deposited into a Yearn V3 strategy and the share price accrues what it earns net of a 2% fee on yield. The published rate is the realized trailing-30-day figure. Deposit and single-transaction withdrawal, both strictly for the calling wallet.",
|
|
50055
|
+
decimals: 18,
|
|
50056
|
+
isRebasing: false,
|
|
50057
|
+
isMintable: true,
|
|
50058
|
+
withdrawalMode: "instant",
|
|
50059
|
+
yieldFetcher: vesperFetcher,
|
|
50060
|
+
yieldKey: vesperYieldKey(
|
|
50061
|
+
"1",
|
|
50062
|
+
"0x0538c8bac84e95a9df8ac10aad17dbe81b9e36ee"
|
|
50063
|
+
)
|
|
50064
|
+
}
|
|
50065
|
+
],
|
|
50066
|
+
"8453": [
|
|
50067
|
+
{
|
|
50068
|
+
// vamsETH (Base) — 94 % of Vesper's Base book. Independent
|
|
50069
|
+
// deployment and independent msETH token from Ethereum's, but the
|
|
50070
|
+
// SAME depegged synth economics — and the price feed keys both
|
|
50071
|
+
// chains' msETH by one group, so the row prices at the market
|
|
50072
|
+
// discount either way. See the chain-1 vamsETH note.
|
|
50073
|
+
reader: "vesper-pool",
|
|
50074
|
+
address: "0x913ece180df83a2b81a4976f83ca88543a0c51b8",
|
|
50075
|
+
underlying: "0x7ba6f01772924a82d9626c126347a28299e98c98",
|
|
50076
|
+
// msETH (Base)
|
|
50077
|
+
symbol: "vamsETH",
|
|
50078
|
+
brand: "Vesper",
|
|
50079
|
+
description: "Vesper's msETH Grow pool on Base: msETH (Metronome's ETH-pegged synth, a chain-local deployment) is lent through Morpho strategies and the share price accrues what they earn net of a 0.5% fee on yield. The rate is the realized trailing-30-day figure and is earned in msETH \u2014 which has traded MATERIALLY BELOW its ETH peg (about a third below at integration), so the position's ETH value depends on that discount as much as on the rate. Deposit and single-transaction withdrawal, both strictly for the calling wallet.",
|
|
50080
|
+
decimals: 18,
|
|
50081
|
+
isRebasing: false,
|
|
50082
|
+
isMintable: true,
|
|
50083
|
+
withdrawalMode: "instant",
|
|
50084
|
+
yieldFetcher: vesperFetcher,
|
|
50085
|
+
yieldKey: vesperYieldKey(
|
|
50086
|
+
"8453",
|
|
50087
|
+
"0x913ece180df83a2b81a4976f83ca88543a0c51b8"
|
|
50088
|
+
)
|
|
50089
|
+
},
|
|
50090
|
+
{
|
|
50091
|
+
// vaETH (Base) — ~$490k over Base WETH.
|
|
50092
|
+
reader: "vesper-pool",
|
|
50093
|
+
address: "0x82562507429876486b60af4f32390ef0947b3d13",
|
|
50094
|
+
underlying: "0x4200000000000000000000000000000000000006",
|
|
50095
|
+
// WETH
|
|
50096
|
+
symbol: "vaETH",
|
|
50097
|
+
brand: "Vesper",
|
|
50098
|
+
description: "Vesper's ETH Grow pool on Base: WETH is routed through lending strategies and the share price accrues what they earn net of a 2% fee on yield. The published rate is the realized trailing-30-day figure. Deposit (in WETH) and single-transaction withdrawal, both strictly for the calling wallet.",
|
|
50099
|
+
decimals: 18,
|
|
50100
|
+
isRebasing: false,
|
|
50101
|
+
isMintable: true,
|
|
50102
|
+
withdrawalMode: "instant",
|
|
50103
|
+
yieldFetcher: vesperFetcher,
|
|
50104
|
+
yieldKey: vesperYieldKey(
|
|
50105
|
+
"8453",
|
|
50106
|
+
"0x82562507429876486b60af4f32390ef0947b3d13"
|
|
50107
|
+
)
|
|
50108
|
+
}
|
|
50109
|
+
],
|
|
50110
|
+
"10": [
|
|
50111
|
+
{
|
|
50112
|
+
// vawstETH (Optimism) — ~$1.5M, the largest OP pool.
|
|
50113
|
+
reader: "vesper-pool",
|
|
50114
|
+
address: "0xdd63ae655b388cd782681b7821be37fdb6d0e78d",
|
|
50115
|
+
underlying: "0x1f32b1c2345538c0c6f582fcb022739c4a194ebb",
|
|
50116
|
+
// wstETH
|
|
50117
|
+
symbol: "vawstETH",
|
|
50118
|
+
brand: "Vesper",
|
|
50119
|
+
description: "Vesper's wstETH Grow pool on Optimism: wstETH is deployed through Aave-based strategies and the share price accrues what they earn net of a 2% fee on yield, denominated in wstETH (on top of wstETH's own embedded staking yield). The published rate is the realized trailing-30-day figure. Deposit and single-transaction withdrawal, both strictly for the calling wallet.",
|
|
50120
|
+
decimals: 18,
|
|
50121
|
+
isRebasing: false,
|
|
50122
|
+
isMintable: true,
|
|
50123
|
+
withdrawalMode: "instant",
|
|
50124
|
+
yieldFetcher: vesperFetcher,
|
|
50125
|
+
yieldKey: vesperYieldKey(
|
|
50126
|
+
"10",
|
|
50127
|
+
"0xdd63ae655b388cd782681b7821be37fdb6d0e78d"
|
|
50128
|
+
)
|
|
50129
|
+
},
|
|
50130
|
+
{
|
|
50131
|
+
// vaUSDC (Optimism) — ~$938k. NB the underlying is BRIDGED USDC.e
|
|
50132
|
+
// (0x7f5c…), not native OP USDC.
|
|
50133
|
+
reader: "vesper-pool",
|
|
50134
|
+
address: "0x539505dde2b9771debe0898a84441c5e7fdf6bc0",
|
|
50135
|
+
underlying: "0x7f5c764cbc14f9669b88837ca1490cca17c31607",
|
|
50136
|
+
// USDC.e
|
|
50137
|
+
symbol: "vaUSDC",
|
|
50138
|
+
brand: "Vesper",
|
|
50139
|
+
decimals: 18,
|
|
50140
|
+
underlyingDecimals: 6,
|
|
50141
|
+
description: "Vesper's USDC Grow pool on Optimism, over bridged USDC.e: deposits are routed through lending strategies and the share price accrues what they earn net of a 2% fee on yield. The published rate is the realized trailing-30-day figure. Deposit and single-transaction withdrawal, both strictly for the calling wallet.",
|
|
50142
|
+
isRebasing: false,
|
|
50143
|
+
isMintable: true,
|
|
50144
|
+
withdrawalMode: "instant",
|
|
50145
|
+
yieldFetcher: vesperFetcher,
|
|
50146
|
+
yieldKey: vesperYieldKey(
|
|
50147
|
+
"10",
|
|
50148
|
+
"0x539505dde2b9771debe0898a84441c5e7fdf6bc0"
|
|
50149
|
+
)
|
|
50150
|
+
},
|
|
50151
|
+
{
|
|
50152
|
+
// vaETH (Optimism) — ~$380k over OP WETH.
|
|
50153
|
+
reader: "vesper-pool",
|
|
50154
|
+
address: "0xccf3d1acf799bae67f6e354d685295557cf64761",
|
|
50155
|
+
underlying: "0x4200000000000000000000000000000000000006",
|
|
50156
|
+
// WETH
|
|
50157
|
+
symbol: "vaETH",
|
|
50158
|
+
brand: "Vesper",
|
|
50159
|
+
description: "Vesper's ETH Grow pool on Optimism: WETH is routed through lending strategies and the share price accrues what they earn net of a 2% fee on yield. The published rate is the realized trailing-30-day figure. Deposit (in WETH) and single-transaction withdrawal, both strictly for the calling wallet.",
|
|
50160
|
+
decimals: 18,
|
|
50161
|
+
isRebasing: false,
|
|
50162
|
+
isMintable: true,
|
|
50163
|
+
withdrawalMode: "instant",
|
|
50164
|
+
yieldFetcher: vesperFetcher,
|
|
50165
|
+
yieldKey: vesperYieldKey(
|
|
50166
|
+
"10",
|
|
50167
|
+
"0xccf3d1acf799bae67f6e354d685295557cf64761"
|
|
50168
|
+
)
|
|
50169
|
+
}
|
|
50170
|
+
]
|
|
50171
|
+
};
|
|
50172
|
+
|
|
49674
50173
|
// src/vaults/savings/registry.ts
|
|
49675
50174
|
var stUsdGroup = {
|
|
49676
50175
|
base: {
|
|
@@ -51096,6 +51595,9 @@ var SINGLE_CHAIN_ENTRIES = {
|
|
|
51096
51595
|
// and XDC (`0x3d8eadb7…`) tokens are bare bridged ERC-20s whose
|
|
51097
51596
|
// `asset()` and `totalAssets()` revert, and together they hold ~188k
|
|
51098
51597
|
// shares — 1.2 % of supply. Not registered: there is no vault there.
|
|
51598
|
+
// They do share the asset though, and store it under two OTHER group
|
|
51599
|
+
// spellings, so `scrvusdFetcher` emits all three and a GROUP_ALIAS
|
|
51600
|
+
// folds them into the canonical `Savings crvUSD::scrvUSD`.
|
|
51099
51601
|
//
|
|
51100
51602
|
// Instant and free, verified on-chain 2026-08-26: `maxDeposit` is
|
|
51101
51603
|
// `uint256.max`, `maxRedeem(holder)` equals the holder's balance to
|
|
@@ -51535,6 +52037,10 @@ var SAVINGS_REGISTRY = (() => {
|
|
|
51535
52037
|
if (!out[chainId]) out[chainId] = [];
|
|
51536
52038
|
out[chainId].push(...entries);
|
|
51537
52039
|
}
|
|
52040
|
+
for (const [chainId, entries] of Object.entries(VESPER_ENTRIES)) {
|
|
52041
|
+
if (!out[chainId]) out[chainId] = [];
|
|
52042
|
+
out[chainId].push(...entries);
|
|
52043
|
+
}
|
|
51538
52044
|
return out;
|
|
51539
52045
|
})();
|
|
51540
52046
|
var savingsBalanceKind = (chainId, address) => {
|
|
@@ -53290,7 +53796,7 @@ async function fetchForChain(chainId, nowSeconds) {
|
|
|
53290
53796
|
abi: GAUGE_ABI,
|
|
53291
53797
|
allowFailure: true
|
|
53292
53798
|
});
|
|
53293
|
-
const
|
|
53799
|
+
const big24 = (v) => {
|
|
53294
53800
|
try {
|
|
53295
53801
|
if (typeof v === "bigint") return v;
|
|
53296
53802
|
if (typeof v === "string" && v !== "0x") return BigInt(v);
|
|
@@ -53304,15 +53810,15 @@ async function fetchForChain(chainId, nowSeconds) {
|
|
|
53304
53810
|
const b = i * STRIDE;
|
|
53305
53811
|
return {
|
|
53306
53812
|
market: m,
|
|
53307
|
-
inflationRate:
|
|
53308
|
-
workingSupply:
|
|
53309
|
-
totalSupply:
|
|
53813
|
+
inflationRate: big24(r1[b]),
|
|
53814
|
+
workingSupply: big24(r1[b + 1]),
|
|
53815
|
+
totalSupply: big24(r1[b + 2]),
|
|
53310
53816
|
isKilled: r1[b + 3] === true,
|
|
53311
|
-
rewardCount: Number(
|
|
53312
|
-
pricePerShare:
|
|
53817
|
+
rewardCount: Number(big24(r1[b + 4])),
|
|
53818
|
+
pricePerShare: big24(r1[b + 5]),
|
|
53313
53819
|
// Off L1 the child gauge's own rate is already market-scoped, so the
|
|
53314
53820
|
// weight is the identity.
|
|
53315
|
-
relativeWeight: isL1 ?
|
|
53821
|
+
relativeWeight: isL1 ? big24(r1[b + 6]) : WAD16
|
|
53316
53822
|
};
|
|
53317
53823
|
});
|
|
53318
53824
|
const tokenCalls = state.flatMap(
|
|
@@ -53405,7 +53911,7 @@ async function fetchForChain(chainId, nowSeconds) {
|
|
|
53405
53911
|
const decoded = decodeRewardData(data);
|
|
53406
53912
|
if (!decoded) continue;
|
|
53407
53913
|
const { periodFinish, rate } = decoded;
|
|
53408
|
-
const decimals = typeof decRaw === "number" ? decRaw : Number(
|
|
53914
|
+
const decimals = typeof decRaw === "number" ? decRaw : Number(big24(decRaw) || 18n);
|
|
53409
53915
|
const rewardPrice = priceOf(prices, chainId, token);
|
|
53410
53916
|
const apr = extraRewardApr({
|
|
53411
53917
|
rate,
|
|
@@ -54464,7 +54970,7 @@ function getDssCalls(chainId) {
|
|
|
54464
54970
|
return results;
|
|
54465
54971
|
}
|
|
54466
54972
|
var RAY10 = 1e27;
|
|
54467
|
-
var
|
|
54973
|
+
var big21 = (v) => {
|
|
54468
54974
|
try {
|
|
54469
54975
|
if (typeof v === "bigint") return v;
|
|
54470
54976
|
if (v == null || v === "0x") return 0n;
|
|
@@ -54476,16 +54982,16 @@ var big20 = (v) => {
|
|
|
54476
54982
|
var field12 = (res, name, idx) => {
|
|
54477
54983
|
const v = res?.[name];
|
|
54478
54984
|
if (typeof v === "bigint" || typeof v === "number" || typeof v === "string") {
|
|
54479
|
-
return
|
|
54985
|
+
return big21(v);
|
|
54480
54986
|
}
|
|
54481
|
-
return
|
|
54987
|
+
return big21(res?.[idx]);
|
|
54482
54988
|
};
|
|
54483
54989
|
function parseDssResults(data, meta, context) {
|
|
54484
54990
|
const { chainId } = context;
|
|
54485
54991
|
const key3 = dssLenderKey(meta.lender, chainId, meta.ilk);
|
|
54486
54992
|
const entries = [];
|
|
54487
54993
|
const spot = field12(data?.[0], "spot", 2);
|
|
54488
|
-
const mat =
|
|
54994
|
+
const mat = big21(meta.mat);
|
|
54489
54995
|
if (spot > 0n && mat > 0n) {
|
|
54490
54996
|
const collUSD = Number(spot) / RAY10 * (Number(mat) / RAY10);
|
|
54491
54997
|
if (collUSD > 0 && collUSD < 1e9) {
|
|
@@ -60932,7 +61438,7 @@ var num4 = (v) => {
|
|
|
60932
61438
|
const n = Number(v);
|
|
60933
61439
|
return Number.isFinite(n) ? n : 0;
|
|
60934
61440
|
};
|
|
60935
|
-
var
|
|
61441
|
+
var big22 = (v) => {
|
|
60936
61442
|
try {
|
|
60937
61443
|
if (v === void 0 || v === null || v === "") return "0";
|
|
60938
61444
|
const s = String(v);
|
|
@@ -60968,12 +61474,12 @@ async function fetchTermMaxVaultsFromApi(chainId, prices = {}, tokenList = {}, f
|
|
|
60968
61474
|
const assetEntry = tokenList[underlying];
|
|
60969
61475
|
const priceKey = toOracleKey(assetEntry?.assetGroup) || toGenericPriceKey(underlying, chainId);
|
|
60970
61476
|
const priceUsd = prices[priceKey];
|
|
60971
|
-
const totalAssets =
|
|
60972
|
-
const totalSupply =
|
|
61477
|
+
const totalAssets = big22(r.totalAssets);
|
|
61478
|
+
const totalSupply = big22(r.totalSupplyAmt);
|
|
60973
61479
|
const totalAssetsFormatted = Number(totalAssets) / scale3;
|
|
60974
61480
|
const supplyRate = num4(r.apr) * 100;
|
|
60975
61481
|
const rewardsRate = num4(r?.incentiveData?.TMX_APR) * 100;
|
|
60976
|
-
const rawLiquidity = BigInt(
|
|
61482
|
+
const rawLiquidity = BigInt(big22(r.redeemableAmt ?? r.idleFunds ?? "0"));
|
|
60977
61483
|
const totalAssetsBig = BigInt(totalAssets);
|
|
60978
61484
|
const liquidity = (rawLiquidity > totalAssetsBig ? totalAssetsBig : rawLiquidity).toString();
|
|
60979
61485
|
const liquidityFormatted = Number(liquidity) / scale3;
|
|
@@ -61009,7 +61515,7 @@ async function fetchTermMaxVaultsFromApi(chainId, prices = {}, tokenList = {}, f
|
|
|
61009
61515
|
liquidityUsd: priceUsd ? liquidityFormatted * priceUsd : 0,
|
|
61010
61516
|
version: r.version,
|
|
61011
61517
|
isPaused: r.isPaused === true || void 0,
|
|
61012
|
-
supplyCap: r.capacity ?
|
|
61518
|
+
supplyCap: r.capacity ? big22(r.capacity) : void 0,
|
|
61013
61519
|
basePool: r.poolAddress ? lower3(r.poolAddress) : void 0
|
|
61014
61520
|
};
|
|
61015
61521
|
}
|
|
@@ -61065,7 +61571,7 @@ var Erc20DecimalsBalanceAbi = [
|
|
|
61065
61571
|
|
|
61066
61572
|
// src/vaults/termmax/fetchFromChain.ts
|
|
61067
61573
|
var DECIMAL_BASE2 = 100000000n;
|
|
61068
|
-
var
|
|
61574
|
+
var big23 = (v) => {
|
|
61069
61575
|
if (v === void 0 || v === null || v === "0x") return 0n;
|
|
61070
61576
|
try {
|
|
61071
61577
|
return typeof v === "bigint" ? v : BigInt(v);
|
|
@@ -61129,7 +61635,7 @@ var fetchTermMaxVaultsFromChain = async (chainId, multicallRetry, prices = {}, t
|
|
|
61129
61635
|
vaults.forEach((address, i) => {
|
|
61130
61636
|
const at = (k) => res[i * READS_PER_VAULT + VAULT_READS.indexOf(k)];
|
|
61131
61637
|
const asset = addr(at("asset"));
|
|
61132
|
-
const totalAssets =
|
|
61638
|
+
const totalAssets = big23(at("totalAssets"));
|
|
61133
61639
|
if (!asset || totalAssets === 0n) return;
|
|
61134
61640
|
rows.push({
|
|
61135
61641
|
address,
|
|
@@ -61138,11 +61644,11 @@ var fetchTermMaxVaultsFromChain = async (chainId, multicallRetry, prices = {}, t
|
|
|
61138
61644
|
decimals: num5(at("decimals")) ?? 18,
|
|
61139
61645
|
asset,
|
|
61140
61646
|
totalAssets,
|
|
61141
|
-
totalSupply:
|
|
61142
|
-
annualizedInterest:
|
|
61143
|
-
accretingPrincipal:
|
|
61144
|
-
performanceFeeRate:
|
|
61145
|
-
aprRaw: at("apr") != null ?
|
|
61647
|
+
totalSupply: big23(at("totalSupply")),
|
|
61648
|
+
annualizedInterest: big23(at("annualizedInterest")),
|
|
61649
|
+
accretingPrincipal: big23(at("accretingPrincipal")),
|
|
61650
|
+
performanceFeeRate: big23(at("performanceFeeRate")),
|
|
61651
|
+
aprRaw: at("apr") != null ? big23(at("apr")) : void 0,
|
|
61146
61652
|
curator: addr(at("curator")),
|
|
61147
61653
|
guardian: addr(at("guardian")),
|
|
61148
61654
|
timelock: num5(at("timelock")),
|
|
@@ -61163,7 +61669,7 @@ var fetchTermMaxVaultsFromChain = async (chainId, multicallRetry, prices = {}, t
|
|
|
61163
61669
|
const out = {};
|
|
61164
61670
|
rows.forEach((r, i) => {
|
|
61165
61671
|
const assetDecimals = num5(res2[i * 2]) ?? r.decimals;
|
|
61166
|
-
const idle =
|
|
61672
|
+
const idle = big23(res2[i * 2 + 1]);
|
|
61167
61673
|
const assetEntry = tokenList[r.asset];
|
|
61168
61674
|
const priceKey = toOracleKey(assetEntry?.assetGroup) || toGenericPriceKey(r.asset, chainId);
|
|
61169
61675
|
const priceUsd = prices[priceKey];
|
|
@@ -67086,6 +67592,31 @@ var NativeWithdrawQueueReadAbi = [
|
|
|
67086
67592
|
}
|
|
67087
67593
|
];
|
|
67088
67594
|
|
|
67595
|
+
// src/vaults/savings/abis/vesper.ts
|
|
67596
|
+
var VesperPoolReadAbi = [
|
|
67597
|
+
{
|
|
67598
|
+
name: "pricePerShare",
|
|
67599
|
+
type: "function",
|
|
67600
|
+
stateMutability: "view",
|
|
67601
|
+
inputs: [],
|
|
67602
|
+
outputs: [{ type: "uint256" }]
|
|
67603
|
+
},
|
|
67604
|
+
{
|
|
67605
|
+
name: "totalValue",
|
|
67606
|
+
type: "function",
|
|
67607
|
+
stateMutability: "view",
|
|
67608
|
+
inputs: [],
|
|
67609
|
+
outputs: [{ type: "uint256" }]
|
|
67610
|
+
},
|
|
67611
|
+
{
|
|
67612
|
+
name: "totalSupply",
|
|
67613
|
+
type: "function",
|
|
67614
|
+
stateMutability: "view",
|
|
67615
|
+
inputs: [],
|
|
67616
|
+
outputs: [{ type: "uint256" }]
|
|
67617
|
+
}
|
|
67618
|
+
];
|
|
67619
|
+
|
|
67089
67620
|
// src/vaults/savings/abis/bitway.ts
|
|
67090
67621
|
var BitwayVaultReadAbi = [
|
|
67091
67622
|
{
|
|
@@ -67567,6 +68098,34 @@ var readerNativeWnlp = (entry) => {
|
|
|
67567
68098
|
};
|
|
67568
68099
|
};
|
|
67569
68100
|
|
|
68101
|
+
// src/vaults/savings/readers/vesperPool.ts
|
|
68102
|
+
var readerVesperPool = (entry) => {
|
|
68103
|
+
const underlyingUnit = 10n ** BigInt(entry.underlyingDecimals ?? entry.decimals);
|
|
68104
|
+
return {
|
|
68105
|
+
calls: [
|
|
68106
|
+
{ address: entry.address, name: "totalValue", params: [] },
|
|
68107
|
+
{ address: entry.address, name: "totalSupply", params: [] },
|
|
68108
|
+
{ address: entry.address, name: "pricePerShare", params: [] }
|
|
68109
|
+
],
|
|
68110
|
+
abis: [VesperPoolReadAbi, VesperPoolReadAbi, VesperPoolReadAbi],
|
|
68111
|
+
parse: ([value, supply, pps]) => {
|
|
68112
|
+
const totalAssets = toBigInt15(value);
|
|
68113
|
+
const totalSupply = toBigInt15(supply);
|
|
68114
|
+
const pricePerShare = toBigInt15(pps);
|
|
68115
|
+
if (totalAssets === void 0 || totalSupply === void 0) {
|
|
68116
|
+
return void 0;
|
|
68117
|
+
}
|
|
68118
|
+
if (pricePerShare === void 0 || pricePerShare <= 0n) return void 0;
|
|
68119
|
+
const exchangeRate = pricePerShare * ONE_E1814 / underlyingUnit;
|
|
68120
|
+
return {
|
|
68121
|
+
totalAssets,
|
|
68122
|
+
totalSupply,
|
|
68123
|
+
exchangeRate
|
|
68124
|
+
};
|
|
68125
|
+
}
|
|
68126
|
+
};
|
|
68127
|
+
};
|
|
68128
|
+
|
|
67570
68129
|
// src/vaults/savings/readers/wrenNav.ts
|
|
67571
68130
|
var readerWrenNav = (entry) => {
|
|
67572
68131
|
const shareUnit = 10n ** BigInt(entry.decimals);
|
|
@@ -67666,6 +68225,8 @@ var buildReader2 = (entry) => {
|
|
|
67666
68225
|
return readerYieldBasisLt(entry);
|
|
67667
68226
|
case "wren-nav":
|
|
67668
68227
|
return readerWrenNav(entry);
|
|
68228
|
+
case "vesper-pool":
|
|
68229
|
+
return readerVesperPool(entry);
|
|
67669
68230
|
case "erc4626-cooldown":
|
|
67670
68231
|
return readerErc4626Cooldown(entry);
|
|
67671
68232
|
case "erc4626-idle":
|
|
@@ -69581,23 +70142,23 @@ var priceGmMarkets = async (chainId, multicallRetry, markets, prices) => {
|
|
|
69581
70142
|
const indexMax = price(prices, m.indexToken)?.max;
|
|
69582
70143
|
if (Array.isArray(dsRes) && longMax != null && shortMax != null) {
|
|
69583
70144
|
const base = i * SLOTS;
|
|
69584
|
-
const
|
|
70145
|
+
const big24 = (j) => typeof dsRes[base + j] === "bigint" ? dsRes[base + j] : 0n;
|
|
69585
70146
|
const cap = computeDepositCapacityUsd(
|
|
69586
|
-
[info?.longTokenAmount, longMax,
|
|
69587
|
-
[info?.shortTokenAmount, shortMax,
|
|
70147
|
+
[info?.longTokenAmount, longMax, big24(0), big24(2)],
|
|
70148
|
+
[info?.shortTokenAmount, shortMax, big24(1), big24(3)]
|
|
69588
70149
|
);
|
|
69589
70150
|
if (cap != null) value.depositCapacityUsd = cap;
|
|
69590
70151
|
if (indexMax != null) {
|
|
69591
70152
|
const divisor = m.longToken.toLowerCase() === m.shortToken.toLowerCase() ? 2n : 1n;
|
|
69592
|
-
const reservedUsdLong = (
|
|
69593
|
-
const reservedUsdShort = (
|
|
70153
|
+
const reservedUsdLong = (big24(4) + big24(5)) / divisor * indexMax;
|
|
70154
|
+
const reservedUsdShort = (big24(6) + big24(7)) / divisor;
|
|
69594
70155
|
const liq = computeLiquidityUsd(
|
|
69595
70156
|
info?.longTokenUsd,
|
|
69596
70157
|
info?.shortTokenUsd,
|
|
69597
70158
|
reservedUsdLong,
|
|
69598
70159
|
reservedUsdShort,
|
|
69599
|
-
|
|
69600
|
-
|
|
70160
|
+
big24(8),
|
|
70161
|
+
big24(9)
|
|
69601
70162
|
);
|
|
69602
70163
|
if (liq != null)
|
|
69603
70164
|
value.liquidityUsd = Math.max(0, Math.min(liq, value.tvlUsd));
|
|
@@ -69796,21 +70357,21 @@ var fetchGmxExecutionFees = async (chainId, multicallRetry, gasPriceWei) => {
|
|
|
69796
70357
|
} catch {
|
|
69797
70358
|
return void 0;
|
|
69798
70359
|
}
|
|
69799
|
-
const
|
|
69800
|
-
const base =
|
|
69801
|
-
const mult =
|
|
70360
|
+
const big24 = (i) => typeof res[i] === "bigint" ? res[i] : 0n;
|
|
70361
|
+
const base = big24(0);
|
|
70362
|
+
const mult = big24(1);
|
|
69802
70363
|
if (base === 0n && mult === 0n) return void 0;
|
|
69803
70364
|
const PRECISION = 10n ** 30n;
|
|
69804
70365
|
const adjusted = (opGas) => base + opGas * mult / PRECISION;
|
|
69805
70366
|
const fee = (opGas) => (adjusted(opGas) * gasPriceWei).toString();
|
|
69806
|
-
const glvExtra =
|
|
70367
|
+
const glvExtra = big24(6) * GLV_NOMINAL_MARKET_COUNT;
|
|
69807
70368
|
return {
|
|
69808
70369
|
chainId,
|
|
69809
70370
|
gasPriceWei: gasPriceWei.toString(),
|
|
69810
|
-
deposit: fee(
|
|
69811
|
-
withdrawal: fee(
|
|
69812
|
-
glvDeposit: fee(
|
|
69813
|
-
glvWithdrawal: fee(
|
|
70371
|
+
deposit: fee(big24(2)),
|
|
70372
|
+
withdrawal: fee(big24(3)),
|
|
70373
|
+
glvDeposit: fee(big24(4) + glvExtra),
|
|
70374
|
+
glvWithdrawal: fee(big24(5) + glvExtra)
|
|
69814
70375
|
};
|
|
69815
70376
|
};
|
|
69816
70377
|
|
|
@@ -71624,6 +72185,28 @@ var TERM_PROFILES = [
|
|
|
71624
72185
|
]
|
|
71625
72186
|
}
|
|
71626
72187
|
}),
|
|
72188
|
+
P({
|
|
72189
|
+
id: "flyingTulip.crossMargin@v1",
|
|
72190
|
+
name: "Flying Tulip cross-margin account",
|
|
72191
|
+
family: "flyingTulip",
|
|
72192
|
+
supply: {
|
|
72193
|
+
description: "One cross-margin account per chain: every asset you deposit backs every asset you borrow, under a single global health check.",
|
|
72194
|
+
implications: [
|
|
72195
|
+
"The rate shown is interest only \u2014 borrowers pay it and it is shared pro rata with utilization. Flying Tulip also pays an FT token emission on deposits that is NOT included here, so the figure is a floor, not the whole return.",
|
|
72196
|
+
"A withdrawal is checked against the same health gate as a borrow: it must leave your account at a health factor of 1.50 or better, so a deposit that is backing debt is not freely withdrawable.",
|
|
72197
|
+
"While you hold any debt your account must keep a minimum equity in USD \u2014 $250 on Ethereum, $10 on Sonic \u2014 which can block a withdrawal that would take you under it."
|
|
72198
|
+
]
|
|
72199
|
+
},
|
|
72200
|
+
borrow: {
|
|
72201
|
+
description: "Borrow any listed asset against your whole account. There is no per-market LTV: the requirement is charged on your debt as well as your collateral, so how much you can borrow depends on the PAIR.",
|
|
72202
|
+
implications: [
|
|
72203
|
+
"Liquidation starts at a health factor below 1.25, NOT below 1.0 \u2014 you are liquidatable a quarter of a point earlier than on an ordinary lending market.",
|
|
72204
|
+
"A new borrow must leave you at 1.50 or better, so a position opened at the limit sits only 0.25 of health above liquidation from the moment it opens.",
|
|
72205
|
+
"Your account must hold a minimum equity in USD for as long as any debt exists ($250 on Ethereum, $10 on Sonic).",
|
|
72206
|
+
"Repayment is never blocked and anyone may repay on your behalf \u2014 there is no cooldown, freeze or queue on the way out."
|
|
72207
|
+
]
|
|
72208
|
+
}
|
|
72209
|
+
}),
|
|
71627
72210
|
P({
|
|
71628
72211
|
id: "twyne.credit-delegation@v1",
|
|
71629
72212
|
name: "Twyne credit delegation",
|
|
@@ -76608,6 +77191,74 @@ var curvanceAdapter = {
|
|
|
76608
77191
|
function numOrUndef(v) {
|
|
76609
77192
|
return typeof v === "number" && Number.isFinite(v) ? v : void 0;
|
|
76610
77193
|
}
|
|
77194
|
+
function numOrUndef2(v) {
|
|
77195
|
+
if (typeof v === "number" && Number.isFinite(v)) return v;
|
|
77196
|
+
if (typeof v === "string" && /^\d+$/.test(v)) return Number(v);
|
|
77197
|
+
return void 0;
|
|
77198
|
+
}
|
|
77199
|
+
function wadUsd(v) {
|
|
77200
|
+
const s = typeof v === "bigint" || typeof v === "number" ? String(v) : v;
|
|
77201
|
+
if (typeof s !== "string" || !/^\d+$/.test(s)) return void 0;
|
|
77202
|
+
const n = Number(BigInt(s) / 10n ** 14n) / 1e4;
|
|
77203
|
+
return Number.isFinite(n) && n > 0 ? n : void 0;
|
|
77204
|
+
}
|
|
77205
|
+
var flyingTulipAdapter = {
|
|
77206
|
+
id: "flying-tulip",
|
|
77207
|
+
matches: isFlyingTulip,
|
|
77208
|
+
profileId: () => "flyingTulip.crossMargin@v1",
|
|
77209
|
+
build: (input) => {
|
|
77210
|
+
const ft = input.market?.flyingTulip ?? {};
|
|
77211
|
+
const hfTargetBps = numOrUndef2(ft.hfTargetBps);
|
|
77212
|
+
numOrUndef2(ft.hfSafeBps);
|
|
77213
|
+
wadUsd(ft.minEquityUSDWad);
|
|
77214
|
+
const liqHf = hfTargetBps != null ? hfTargetBps / 1e4 : void 0;
|
|
77215
|
+
return {
|
|
77216
|
+
constraints: {
|
|
77217
|
+
// One account per address per chain, spanning every asset — there is
|
|
77218
|
+
// no per-market position and no id.
|
|
77219
|
+
positionModel: "account",
|
|
77220
|
+
positionIdMeaning: "the borrower address itself \u2014 one cross-margin account per chain covering every asset, with a single global health check",
|
|
77221
|
+
crossMargin: true
|
|
77222
|
+
// NOTE the USD equity floor ($250 Ethereum / $10 Sonic) has no
|
|
77223
|
+
// structured slot — `availability.minSize` is a DEBT floor in asset
|
|
77224
|
+
// units and this is an EQUITY floor in USD, so putting it there would
|
|
77225
|
+
// be read as the wrong gate on the wrong quantity. It is stated in the
|
|
77226
|
+
// profile prose instead, and the raw value stays on
|
|
77227
|
+
// `params.market.flyingTulip.minEquityUSDWad` for a caller that needs
|
|
77228
|
+
// to gate on it.
|
|
77229
|
+
},
|
|
77230
|
+
borrow: {
|
|
77231
|
+
debtShape: "accruing",
|
|
77232
|
+
// The HF >= 1.50 open gate likewise has no structured slot; it is in
|
|
77233
|
+
// the profile prose. `availability` here carries no minimum size —
|
|
77234
|
+
// Flying Tulip has none on the debt leg.
|
|
77235
|
+
exit: {
|
|
77236
|
+
// Repay is always open — `repayFor` is permissionless, so a third
|
|
77237
|
+
// party can rescue the account, and nothing gates or delays it.
|
|
77238
|
+
partialAllowed: true,
|
|
77239
|
+
cooldownSecs: void 0
|
|
77240
|
+
},
|
|
77241
|
+
...liqHf != null ? {
|
|
77242
|
+
liquidation: {
|
|
77243
|
+
model: "partial",
|
|
77244
|
+
trigger: "price",
|
|
77245
|
+
// THE correction. Everything else in this repo may assume
|
|
77246
|
+
// `HF < 1 ⇒ liquidatable`; here the protocol reverts above
|
|
77247
|
+
// 1.25, so the position is liquidatable a quarter of a point
|
|
77248
|
+
// of health EARLIER than the default reading.
|
|
77249
|
+
liquidationHealthFactor: liqHf
|
|
77250
|
+
}
|
|
77251
|
+
} : {}
|
|
77252
|
+
},
|
|
77253
|
+
supply: {
|
|
77254
|
+
exit: {
|
|
77255
|
+
// A withdrawal is checked against the SAME open gate as a borrow
|
|
77256
|
+
// (HF >= 1.50) and against the equity floor.
|
|
77257
|
+
}
|
|
77258
|
+
}
|
|
77259
|
+
};
|
|
77260
|
+
}
|
|
77261
|
+
};
|
|
76611
77262
|
var num16 = (v) => typeof v === "number" && Number.isFinite(v) ? v : void 0;
|
|
76612
77263
|
var pct2 = (v) => `${(v * 100).toFixed(2)} %`;
|
|
76613
77264
|
var twyneAdapter = {
|
|
@@ -76823,6 +77474,7 @@ var TERM_ADAPTERS = [
|
|
|
76823
77474
|
frankencoinAdapter,
|
|
76824
77475
|
resupplyAdapter,
|
|
76825
77476
|
curvanceAdapter,
|
|
77477
|
+
flyingTulipAdapter,
|
|
76826
77478
|
twyneAdapter,
|
|
76827
77479
|
fraxlendAdapter,
|
|
76828
77480
|
morphoBlueAdapter,
|