@1delta/margin-fetcher 0.0.282 → 0.0.283
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +77 -15
- package/dist/index.js.map +1 -1
- package/dist/lending/public-data/lista/listaBroker.d.ts +11 -2
- package/dist/lending/public-data/lista/listaBroker.d.ts.map +1 -1
- package/dist/lending/user-data/fetch-balances/e2e.d.ts.map +1 -1
- package/dist/lending/user-data/fetch-balances/prepare.d.ts +1 -1
- package/dist/lending/user-data/fetch-balances/prepare.d.ts.map +1 -1
- package/dist/lending/user-data/morpho/userCallBuild.d.ts +2 -2
- package/dist/lending/user-data/morpho/userCallBuild.d.ts.map +1 -1
- package/dist/vaults/classification.d.ts +11 -1
- package/dist/vaults/classification.d.ts.map +1 -1
- package/dist/vaults/gmx/types.d.ts +2 -1
- package/dist/vaults/gmx/types.d.ts.map +1 -1
- package/dist/vaults/hypercore/types.d.ts +2 -1
- package/dist/vaults/hypercore/types.d.ts.map +1 -1
- package/dist/vaults/lookup.d.ts +3 -0
- package/dist/vaults/lookup.d.ts.map +1 -1
- package/dist/vaults/lst/registry.d.ts.map +1 -1
- package/dist/yields/intrinsic/fetchers/lombard.d.ts +3 -0
- package/dist/yields/intrinsic/fetchers/lombard.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import './chunk-PR4QN5HX.js';
|
|
|
4
4
|
import { Lender, isAaveType, isCompoundV3, isMultiMarket, isSiloV2Type, isSiloV3Type, isDolomite, isAaveV4Type, isInit, isMorphoType, isCompoundV2Type, isVenusType, isSumerType, AAVE_V3_LENDERS, AAVE_V2_LENDERS, isAaveV2Type, isAaveV32Type, isAaveV3Type, isEulerType, isFluid, isGearboxV3, isYLDR, isCompoundV3Type, isLista, isTectonicType, isKineticType, isBenqiType } from '@1delta/lender-registry';
|
|
5
5
|
export { isAaveType, isAaveV2Type, isAaveV32Type, isAaveV3Type, isCompoundV3, isCompoundV3Type, isInit, isMorphoType, isMultiMarket, isYLDR } from '@1delta/lender-registry';
|
|
6
6
|
import lodash from 'lodash';
|
|
7
|
-
import {
|
|
7
|
+
import { getEvmClient, getEvmChain, getEvmClientUniversal, multicallRetryUniversal } from '@1delta/providers';
|
|
8
8
|
import { MetaMorphoAbi, FluidLendingResolverAbi, FluidVaultResolverAbi, MoolahVaultAbi, MorphoLensAbi, AaveV4SpokeAbi, AaveV4OracleAbi, AaveV4HubAbi, DolomiteMarginAbi, GearboxMarketCompressorV310Abi, MorphoBlueAbi, GearboxCreditAccountCompressorV310Abi } from '@1delta/abis';
|
|
9
9
|
export { MorphoLensAbi } from '@1delta/abis';
|
|
10
10
|
import { prepareDebitDataMulticall, prepareLenderDebitMulticall, parseDebitDataResult, parseLenderDebitResult, getPermit2ContractAddress, getCompoundV3CometAddress as getCompoundV3CometAddress$1, getMorphoAddress, getAaveCollateralTokenAddress, getSiloHalfForUnderlying, InitMarginAddresses, getLstAcceptedInputs } from '@1delta/calldata-sdk';
|
|
@@ -11221,7 +11221,7 @@ function earlyRepayPenalty(repayPrincipal, apr, end, nowSecs) {
|
|
|
11221
11221
|
const perRepay = ceilDiv(repayPrincipal * aprPerSecond(apr), RATE_SCALE);
|
|
11222
11222
|
return ceilDiv(perRepay * timeLeft, 2n);
|
|
11223
11223
|
}
|
|
11224
|
-
async function resolveListaBrokers(chainId, marketKeys) {
|
|
11224
|
+
async function resolveListaBrokers(chainId, marketKeys, getClient = getEvmClient) {
|
|
11225
11225
|
const moolah = morphoPools()?.LISTA_DAO?.[chainId];
|
|
11226
11226
|
const out = {};
|
|
11227
11227
|
if (!moolah || marketKeys.length === 0) return out;
|
|
@@ -11233,7 +11233,7 @@ async function resolveListaBrokers(chainId, marketKeys) {
|
|
|
11233
11233
|
}
|
|
11234
11234
|
if (missing.length > 0) {
|
|
11235
11235
|
try {
|
|
11236
|
-
const client =
|
|
11236
|
+
const client = getClient(chainId);
|
|
11237
11237
|
const results = await client.multicall({
|
|
11238
11238
|
allowFailure: true,
|
|
11239
11239
|
contracts: missing.map((id) => ({
|
|
@@ -11297,15 +11297,15 @@ async function fetchListaFixedTerms(chainId, marketKeys) {
|
|
|
11297
11297
|
function getCachedListaFixedTerms(chainId, marketKey) {
|
|
11298
11298
|
return FIXED_TERMS_CACHE[chainId]?.[toBytes32MarketId(marketKey)];
|
|
11299
11299
|
}
|
|
11300
|
-
async function fetchListaBrokerUserData(chainId, account, marketKeys, nowSecs = Math.floor(Date.now() / 1e3)) {
|
|
11301
|
-
const brokers = await resolveListaBrokers(chainId, marketKeys);
|
|
11300
|
+
async function fetchListaBrokerUserData(chainId, account, marketKeys, nowSecs = Math.floor(Date.now() / 1e3), getClient = getEvmClient) {
|
|
11301
|
+
const brokers = await resolveListaBrokers(chainId, marketKeys, getClient);
|
|
11302
11302
|
const ids = Object.keys(brokers);
|
|
11303
11303
|
const out = {};
|
|
11304
11304
|
const cacheKey2 = `${chainId}:${account.toLowerCase()}`;
|
|
11305
11305
|
BROKER_USER_CACHE[cacheKey2] = out;
|
|
11306
11306
|
if (ids.length === 0) return out;
|
|
11307
11307
|
try {
|
|
11308
|
-
const client =
|
|
11308
|
+
const client = getClient(chainId);
|
|
11309
11309
|
const contracts = ids.flatMap((id) => {
|
|
11310
11310
|
const address = brokers[id];
|
|
11311
11311
|
return [
|
|
@@ -11449,11 +11449,17 @@ var buildMorphoUserCallWithLens = (chainId, account, lender, marketsToQuery) =>
|
|
|
11449
11449
|
]
|
|
11450
11450
|
}));
|
|
11451
11451
|
};
|
|
11452
|
-
var buildMorphoTypeUserCallWithLens = (chainId, account, lender, marketsToQuery) => {
|
|
11453
|
-
return lender === Lender.MORPHO_BLUE ? buildMorphoUserCallWithLens(chainId, account, lender, marketsToQuery) : buildListaUserCallWithLens(chainId, account, lender, marketsToQuery);
|
|
11452
|
+
var buildMorphoTypeUserCallWithLens = (chainId, account, lender, marketsToQuery, getClient) => {
|
|
11453
|
+
return lender === Lender.MORPHO_BLUE ? buildMorphoUserCallWithLens(chainId, account, lender, marketsToQuery) : buildListaUserCallWithLens(chainId, account, lender, marketsToQuery, getClient);
|
|
11454
11454
|
};
|
|
11455
|
-
var buildListaUserCallWithLens = async (chainId, account, lender, marketsToQuery) => {
|
|
11456
|
-
await fetchListaBrokerUserData(
|
|
11455
|
+
var buildListaUserCallWithLens = async (chainId, account, lender, marketsToQuery, getClient) => {
|
|
11456
|
+
await fetchListaBrokerUserData(
|
|
11457
|
+
chainId,
|
|
11458
|
+
account,
|
|
11459
|
+
marketsToQuery,
|
|
11460
|
+
void 0,
|
|
11461
|
+
getClient
|
|
11462
|
+
).catch(() => ({}));
|
|
11457
11463
|
const marketSlices = chunk(marketsToQuery, 100);
|
|
11458
11464
|
return marketSlices.flatMap((marketsInChunk) => ({
|
|
11459
11465
|
address: MORPHO_LENS[chainId],
|
|
@@ -22379,13 +22385,19 @@ var buildDolomiteUserCall = async (chainId, _lender, account, accountNumbers) =>
|
|
|
22379
22385
|
};
|
|
22380
22386
|
|
|
22381
22387
|
// src/lending/user-data/fetch-balances/prepare.ts
|
|
22382
|
-
async function buildUserCall(chainId, lender, account, params) {
|
|
22388
|
+
async function buildUserCall(chainId, lender, account, params, getClient) {
|
|
22383
22389
|
if (isAaveV4Type(lender)) return buildAaveV4UserCall(chainId, lender, account);
|
|
22384
22390
|
if (isAaveV2Type(lender)) return buildAaveV2UserCall(chainId, lender, account);
|
|
22385
22391
|
if (isAaveV3Type(lender)) return buildAaveV3UserCall(chainId, lender, account);
|
|
22386
22392
|
if (isInit(lender)) return buildInitUserCall(chainId, lender, account);
|
|
22387
22393
|
if (isMorphoType(lender))
|
|
22388
|
-
return buildMorphoTypeUserCallWithLens(
|
|
22394
|
+
return buildMorphoTypeUserCallWithLens(
|
|
22395
|
+
chainId,
|
|
22396
|
+
account,
|
|
22397
|
+
lender,
|
|
22398
|
+
params,
|
|
22399
|
+
getClient
|
|
22400
|
+
);
|
|
22389
22401
|
if (isCompoundV3Type(lender))
|
|
22390
22402
|
return buildCompoundV3UserCall(chainId, lender, account);
|
|
22391
22403
|
if (isEulerType(lender))
|
|
@@ -29432,7 +29444,8 @@ var getLenderUserDataResult = async (chainId, queriesRaw, getEvmClient16, allowF
|
|
|
29432
29444
|
chainId,
|
|
29433
29445
|
query3.lender,
|
|
29434
29446
|
query3.account,
|
|
29435
|
-
query3.params
|
|
29447
|
+
query3.params,
|
|
29448
|
+
getEvmClient16
|
|
29436
29449
|
);
|
|
29437
29450
|
return callData.map((call) => ({ call, abi: call.abi ?? abi }));
|
|
29438
29451
|
})
|
|
@@ -38356,6 +38369,23 @@ var lombardLbtcFetcher = {
|
|
|
38356
38369
|
return { LBTC: Number.isFinite(frac) ? frac * 100 : 0 };
|
|
38357
38370
|
}
|
|
38358
38371
|
};
|
|
38372
|
+
var LOMBARD_VAULT_APY_URL = "https://mainnet.prod.lombard.finance/api/v1/analytics/vault/apy/history";
|
|
38373
|
+
var createLombardVaultFetcher = (wrapper, key) => ({
|
|
38374
|
+
label: `LOMBARD_VAULT:${wrapper}`,
|
|
38375
|
+
fetch: async () => {
|
|
38376
|
+
const url = `${LOMBARD_VAULT_APY_URL}?vault_wrapper=${wrapper}&interval=APY_INTERVAL_1M`;
|
|
38377
|
+
const res = await fetch(url, {
|
|
38378
|
+
headers: { accept: "application/json" }
|
|
38379
|
+
}).then((r) => r.json());
|
|
38380
|
+
const latest = Array.isArray(res?.snapshots) ? res.snapshots[0] : void 0;
|
|
38381
|
+
const frac = Number(latest?.total_apy);
|
|
38382
|
+
return { [key]: Number.isFinite(frac) ? frac * 100 : 0 };
|
|
38383
|
+
}
|
|
38384
|
+
});
|
|
38385
|
+
var lombardLbtcvFetcher = createLombardVaultFetcher(
|
|
38386
|
+
"VAULT_WRAPPER_BTCE",
|
|
38387
|
+
"LBTCv"
|
|
38388
|
+
);
|
|
38359
38389
|
var CHAIN_ID6 = "1284";
|
|
38360
38390
|
var STDOT = "0xbc7e02c4178a7df7d3e564323a5c359dc96c4db4";
|
|
38361
38391
|
var ONE_E185 = 10n ** 18n;
|
|
@@ -38988,6 +39018,31 @@ var LST_REGISTRY = {
|
|
|
38988
39018
|
withdrawalMode: "queued",
|
|
38989
39019
|
yieldFetcher: solvBtcPlusFetcher,
|
|
38990
39020
|
yieldKey: "BTC+"
|
|
39021
|
+
},
|
|
39022
|
+
{
|
|
39023
|
+
// Lombard LBTCv — Veda BoringVault DeFi vault over LBTC ("Bitcoin Earn",
|
|
39024
|
+
// Lombard API wrapper `VAULT_WRAPPER_BTCE`; 8-dec). Share price via the
|
|
39025
|
+
// Veda Accountant `getRate()` (8-dec, ≈1.024 BTC/LBTCv) — the accountant
|
|
39026
|
+
// (`0x2863…3dCE`) is reached through the vault hook's `accountant()`. APY
|
|
39027
|
+
// from the Lombard vault API. Redeems to LBTC (~3-day vault-share queue);
|
|
39028
|
+
// priced via WBTC (≈BTC). Not mintable here (Veda Teller; no builder).
|
|
39029
|
+
address: "0x5401b8620e5fb570064ca9114fd1e135fd77d57c",
|
|
39030
|
+
underlying: "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599",
|
|
39031
|
+
// WBTC (BTC price ref)
|
|
39032
|
+
symbol: "LBTCv",
|
|
39033
|
+
brand: "Lombard",
|
|
39034
|
+
decimals: 8,
|
|
39035
|
+
reader: "vedaAccountant",
|
|
39036
|
+
isErc4626: false,
|
|
39037
|
+
isRebasing: false,
|
|
39038
|
+
isMintable: false,
|
|
39039
|
+
isNativeUnderlying: false,
|
|
39040
|
+
withdrawalMode: "queued",
|
|
39041
|
+
readerExtras: {
|
|
39042
|
+
vedaAccountant: "0x28634d0c5edc67cf2450e74dea49b90a4ff93dce"
|
|
39043
|
+
},
|
|
39044
|
+
yieldFetcher: lombardLbtcvFetcher,
|
|
39045
|
+
yieldKey: "LBTCv"
|
|
38991
39046
|
}
|
|
38992
39047
|
],
|
|
38993
39048
|
"146": [
|
|
@@ -45638,11 +45693,15 @@ var classifyVault = (input) => {
|
|
|
45638
45693
|
return { yieldProfile, denomination };
|
|
45639
45694
|
};
|
|
45640
45695
|
var stampVaultClassification = (data, chainId, tokenList = {}) => {
|
|
45641
|
-
const stampBag = (bag, provider) => {
|
|
45696
|
+
const stampBag = (bag, provider, classify = true) => {
|
|
45642
45697
|
if (!bag) return;
|
|
45643
45698
|
for (const v of Object.values(bag)) {
|
|
45644
45699
|
const shareAsset = tokenList[v.address?.toLowerCase?.() ?? ""];
|
|
45645
45700
|
if (shareAsset) v.shareAsset = shareAsset;
|
|
45701
|
+
const longLogo = v.longToken != null ? tokenList[v.longToken.toLowerCase()]?.logoURI : void 0;
|
|
45702
|
+
const icon = v.shareAsset?.logoURI ?? v.asset?.logoURI ?? longLogo;
|
|
45703
|
+
if (icon) v.logoURI = icon;
|
|
45704
|
+
if (!classify) continue;
|
|
45646
45705
|
const c = classifyVault({
|
|
45647
45706
|
provider,
|
|
45648
45707
|
chainId,
|
|
@@ -45675,6 +45734,8 @@ var stampVaultClassification = (data, chainId, tokenList = {}) => {
|
|
|
45675
45734
|
stampBag(data.savings, "savings");
|
|
45676
45735
|
stampBag(data.lagoon, "lagoon");
|
|
45677
45736
|
stampBag(data.yearn, "yearn");
|
|
45737
|
+
stampBag(data.hypercore, "hypercore", false);
|
|
45738
|
+
stampBag(data.gmx, "gmx", false);
|
|
45678
45739
|
};
|
|
45679
45740
|
|
|
45680
45741
|
// src/vaults/gmx/registry.ts
|
|
@@ -46938,7 +46999,8 @@ function buildVaultLookup(data) {
|
|
|
46938
46999
|
denomination: v.denomination,
|
|
46939
47000
|
sharePriceRaw: v.sharePriceRaw,
|
|
46940
47001
|
sharePrice: v.sharePrice,
|
|
46941
|
-
sharePriceUSD: v.sharePriceUSD
|
|
47002
|
+
sharePriceUSD: v.sharePriceUSD,
|
|
47003
|
+
logoURI: v.logoURI
|
|
46942
47004
|
});
|
|
46943
47005
|
}
|
|
46944
47006
|
};
|