@1delta/margin-fetcher 0.0.150 → 0.0.152

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.
@@ -1,6 +1,12 @@
1
1
  /** No specific configuration */
2
2
  export declare const LENDER_MODE_NO_MODE = 0;
3
- export declare function getAaveStyleProtocolTokenMap(chainId: string, lender: string): any;
3
+ export declare function getAaveStyleProtocolTokenMap(chainId: string, lender: string): {
4
+ [underlying: string]: {
5
+ aToken: string;
6
+ sToken: string;
7
+ vToken: string;
8
+ };
9
+ };
4
10
  export declare const getAaveAssets: (chainId: string | undefined, lendingProtocol: string | undefined) => string[];
5
11
  export declare const getCompoundV3Assets: (chainId: string | undefined, lendingProtocol: string | undefined) => string[];
6
12
  export declare function getAaveTypePoolDataProviderAddress(chainId: string, lender: string): string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/assets/index.ts"],"names":[],"mappings":"AAQA,gCAAgC;AAChC,eAAO,MAAM,mBAAmB,IAAI,CAAA;AAEpC,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAC9B,GAAG,CAChD;AAED,eAAO,MAAM,aAAa,GACxB,SAAS,MAAM,GAAG,SAAS,EAC3B,iBAAiB,MAAM,GAAG,SAAS,KAClC,MAAM,EAIR,CAAA;AAED,eAAO,MAAM,mBAAmB,GAC9B,SAAS,MAAM,GAAG,SAAS,EAC3B,iBAAiB,MAAM,GAAG,SAAS,KAClC,MAAM,EAIR,CAAA;AAED,wBAAgB,kCAAkC,CAChD,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,UAIf;AAED,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,MAAM,CAGR;AAED;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,GAAG,MAAM,WAEpC,CAAA;AAED,eAAO,MAAM,iBAAiB,GAAI,cAAc,MAAM,EAAE,SAAS,MAAM,WAEtE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/assets/index.ts"],"names":[],"mappings":"AAQA,gCAAgC;AAChC,eAAO,MAAM,mBAAmB,IAAI,CAAA;AAEpC,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;;;;;;EAE3E;AAED,eAAO,MAAM,aAAa,GACxB,SAAS,MAAM,GAAG,SAAS,EAC3B,iBAAiB,MAAM,GAAG,SAAS,KAClC,MAAM,EAIR,CAAA;AAED,eAAO,MAAM,mBAAmB,GAC9B,SAAS,MAAM,GAAG,SAAS,EAC3B,iBAAiB,MAAM,GAAG,SAAS,KAClC,MAAM,EAIR,CAAA;AAED,wBAAgB,kCAAkC,CAChD,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,UAIf;AAED,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,MAAM,CAGR;AAED;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,GAAG,MAAM,WAEpC,CAAA;AAED,eAAO,MAAM,iBAAiB,GAAI,cAAc,MAAM,EAAE,SAAS,MAAM,WAEtE,CAAA"}
package/dist/index.js CHANGED
@@ -6276,6 +6276,7 @@ function initializeLenderData({
6276
6276
  compoundV3BaseDataOverride,
6277
6277
  morphoPoolsOverride,
6278
6278
  compoundV2TokensOverride,
6279
+ compoundV2TokenArrayOverride,
6279
6280
  compoundV2PoolsOverride,
6280
6281
  initConfigOverride,
6281
6282
  aaveReservesOverride,
@@ -6293,6 +6294,7 @@ function initializeLenderData({
6293
6294
  if (morphoPoolsOverride) data.morphoPools = morphoPoolsOverride;
6294
6295
  if (compoundV3BaseDataOverride) data.compoundV3BaseData = compoundV3BaseDataOverride;
6295
6296
  if (compoundV2TokensOverride) data.compoundV2Tokens = compoundV2TokensOverride;
6297
+ if (compoundV2TokenArrayOverride) data.compoundV2TokenArray = compoundV2TokenArrayOverride;
6296
6298
  if (compoundV2PoolsOverride) data.compoundV2Pools = compoundV2PoolsOverride;
6297
6299
  if (initConfigOverride) data.initConfig = initConfigOverride;
6298
6300
  if (aaveReservesOverride) data.aaveReserves = aaveReservesOverride;
@@ -6315,6 +6317,7 @@ var morphoPools = () => getGlobalData2()?.morphoPools;
6315
6317
  var compoundV3BaseData = () => getGlobalData2()?.compoundV3BaseData;
6316
6318
  var compoundV2Pools = () => getGlobalData2()?.compoundV2Pools;
6317
6319
  var compoundV2Tokens = () => getGlobalData2()?.compoundV2Tokens;
6320
+ var compoundV2TokenArray = () => getGlobalData2()?.compoundV2TokenArray;
6318
6321
  var initConfig = () => getGlobalData2()?.initConfig;
6319
6322
  var { uniq } = lodash;
6320
6323
  var COMPOUND_V3_KEY = "COMPOUND_V3";
@@ -7737,6 +7740,20 @@ var addressesInitCore = {
7737
7740
  [Chain.MANTLE]: "0xDf75fF0452eDf4897B051A54b406eB384503Ac39"
7738
7741
  }
7739
7742
  };
7743
+ function getInitPools(chainId, lender) {
7744
+ const poolData = initConfig()?.[lender]?.[chainId]?.poolData;
7745
+ if (!poolData) return [];
7746
+ return Object.entries(poolData).map(([poolId, value]) => ({
7747
+ poolId,
7748
+ underlying: value.underlying
7749
+ }));
7750
+ }
7751
+ function getInitUnderlyingToPoolMap(chainId, lender) {
7752
+ return getInitPools(chainId, lender).reduce((map, { underlying, poolId }) => {
7753
+ map.set(underlying, poolId);
7754
+ return map;
7755
+ }, /* @__PURE__ */ new Map());
7756
+ }
7740
7757
 
7741
7758
  // src/lending/init/publicCallBuild.ts
7742
7759
  var INIT_MODES = [1, 2, 3, 4, 5, 6];
@@ -7982,6 +7999,7 @@ var getAaveV2ReservesDataConverter = (lender, chainId, prices, additionalYields,
7982
7999
  /** AAVE V2 style with rewards from state */
7983
8000
  default: {
7984
8001
  const assetsToQuery = getAaveAssets(chainId, lender);
8002
+ const aaveTokenMap = getAaveStyleProtocolTokenMap(chainId, lender);
7985
8003
  const expectedNumberOfCalls = assetsToQuery.length * 2;
7986
8004
  return [
7987
8005
  (data) => {
@@ -8077,6 +8095,19 @@ var getAaveV2ReservesDataConverter = (lender, chainId, prices, additionalYields,
8077
8095
  isActive: configData?.[8 /* isActive */],
8078
8096
  isFrozen: configData?.[9 /* isFrozen */]
8079
8097
  };
8098
+ const aaveTokens3 = aaveTokenMap[asset];
8099
+ if (!!aaveTokens3) {
8100
+ resultReserves[asset] = {
8101
+ ...resultReserves[asset],
8102
+ params: {
8103
+ metadata: {
8104
+ aToken: aaveTokens3.aToken,
8105
+ vToken: aaveTokens3.vToken,
8106
+ sToken: aaveTokens3.sToken
8107
+ }
8108
+ }
8109
+ };
8110
+ }
8080
8111
  }
8081
8112
  return {
8082
8113
  data: resultReserves,
@@ -8111,6 +8142,7 @@ var getAaveV3ReservesDataConverter = (lender, chainId, prices, additionalYields,
8111
8142
  const assetsToQuery = getAaveAssets(chainId, lender);
8112
8143
  const allModes = AAVE_V3_EMODES(chainId, lender);
8113
8144
  const expectedNumberOfCalls = assetsToQuery.length * 6 + allModes.length + 1;
8145
+ const aaveTokenMap = getAaveStyleProtocolTokenMap(chainId, lender);
8114
8146
  return [
8115
8147
  (data) => {
8116
8148
  if (data.length !== expectedNumberOfCalls) {
@@ -8221,6 +8253,19 @@ var getAaveV3ReservesDataConverter = (lender, chainId, prices, additionalYields,
8221
8253
  )
8222
8254
  )
8223
8255
  };
8256
+ const aaveTokens3 = aaveTokenMap[asset];
8257
+ if (!!aaveTokens3) {
8258
+ resultReserves[asset] = {
8259
+ ...resultReserves[asset],
8260
+ params: {
8261
+ metadata: {
8262
+ aToken: aaveTokens3.aToken,
8263
+ vToken: aaveTokens3.vToken,
8264
+ sToken: aaveTokens3.sToken
8265
+ }
8266
+ }
8267
+ };
8268
+ }
8224
8269
  }
8225
8270
  return {
8226
8271
  data: resultReserves,
@@ -8320,6 +8365,7 @@ function isReserveEnabledOnBitmap(bitmap, reserveIndex) {
8320
8365
  }
8321
8366
  function parseYLDRCall(chainId, lender, additionalYields, prices, tokenList) {
8322
8367
  const assetsToQuery = getAaveAssets(chainId, lender);
8368
+ const aaveTokenMap = getAaveStyleProtocolTokenMap(chainId, lender);
8323
8369
  const expectedNumberOfCalls = assetsToQuery.length * 2;
8324
8370
  return [
8325
8371
  (data) => {
@@ -8401,6 +8447,19 @@ function parseYLDRCall(chainId, lender, additionalYields, prices, tokenList) {
8401
8447
  isActive: configData?.[7 /* isActive */],
8402
8448
  isFrozen: configData?.[8 /* isFrozen */]
8403
8449
  };
8450
+ const aaveTokens3 = aaveTokenMap[asset];
8451
+ if (!!aaveTokens3) {
8452
+ resultReserves[asset] = {
8453
+ ...resultReserves[asset],
8454
+ params: {
8455
+ metadata: {
8456
+ aToken: aaveTokens3.aToken,
8457
+ vToken: aaveTokens3.vToken,
8458
+ sToken: aaveTokens3.sToken
8459
+ }
8460
+ }
8461
+ };
8462
+ }
8404
8463
  }
8405
8464
  return {
8406
8465
  data: resultReserves,
@@ -8413,6 +8472,7 @@ function parseYLDRCall(chainId, lender, additionalYields, prices, tokenList) {
8413
8472
  }
8414
8473
  function parseAave32(chainId, lender, prices, additionalYields, tokenList) {
8415
8474
  const assetsToQuery = getAaveAssets(chainId, lender);
8475
+ const aaveTokenMap = getAaveStyleProtocolTokenMap(chainId, lender);
8416
8476
  const allModes = AAVE_V3_EMODES(chainId, lender);
8417
8477
  const expectedNumberOfCalls = assetsToQuery.length * 5 + allModes.length * 3 + 2;
8418
8478
  return [
@@ -8534,6 +8594,19 @@ function parseAave32(chainId, lender, prices, additionalYields, tokenList) {
8534
8594
  )
8535
8595
  )
8536
8596
  };
8597
+ const aaveTokens3 = aaveTokenMap[asset];
8598
+ if (!!aaveTokens3) {
8599
+ resultReserves[asset] = {
8600
+ ...resultReserves[asset],
8601
+ params: {
8602
+ metadata: {
8603
+ aToken: aaveTokens3.aToken,
8604
+ vToken: aaveTokens3.vToken,
8605
+ sToken: aaveTokens3.sToken
8606
+ }
8607
+ }
8608
+ };
8609
+ }
8537
8610
  }
8538
8611
  return {
8539
8612
  data: resultReserves,
@@ -8555,6 +8628,7 @@ var INIT_EMODE_LABELS = {
8555
8628
  };
8556
8629
  var getInitReservesDataConverter = (lender, chainId, prices, additionalYields, tokenList = {}) => {
8557
8630
  const expectedNumberOfCalls = INIT_MODES.length;
8631
+ const underlyingToPoolMap = getInitUnderlyingToPoolMap(chainId, lender);
8558
8632
  return [
8559
8633
  (data) => {
8560
8634
  if (data.length !== expectedNumberOfCalls) {
@@ -8577,6 +8651,8 @@ var getInitReservesDataConverter = (lender, chainId, prices, additionalYields, t
8577
8651
  const oracleKey = toOracleKey(meta?.assetGroup) ?? toGenericPriceKey(asset, chainId);
8578
8652
  const price = prices[oracleKey];
8579
8653
  const liquidity = Number(totalDeposits) - Number(totalDebt);
8654
+ const poolId = underlyingToPoolMap.get(asset);
8655
+ const params = !!poolId ? { metadata: { poolId } } : void 0;
8580
8656
  return {
8581
8657
  [asset]: {
8582
8658
  poolId: asset,
@@ -8607,7 +8683,8 @@ var getInitReservesDataConverter = (lender, chainId, prices, additionalYields, t
8607
8683
  stakingYield: additionalYields.intrinsicYields[oracleKey] ?? 0,
8608
8684
  rewards: {},
8609
8685
  config: {},
8610
- borrowingEnabled: totalDebt !== "0"
8686
+ borrowingEnabled: totalDebt !== "0",
8687
+ params
8611
8688
  }
8612
8689
  };
8613
8690
  })
@@ -12078,12 +12155,12 @@ function getCompoundV2Comptroller(chainId, lender = Lender.VENUS) {
12078
12155
  function getCompoundV2CollateralTokens(chainId, lender = Lender.VENUS) {
12079
12156
  return compoundV2Tokens()?.[lender]?.[chainId];
12080
12157
  }
12081
- function getCompoundV2Reserves(chainId, lender = Lender.VENUS) {
12082
- return compoundV2Reserves()?.[lender]?.[chainId];
12083
- }
12084
12158
  function getCompoundV2Lens(chainId, lender) {
12085
12159
  return COMPOUND_V2_LENS[lender]?.[chainId];
12086
12160
  }
12161
+ function getCompoundV2Tokens(chainId, lender = Lender.VENUS) {
12162
+ return compoundV2TokenArray()?.[lender]?.[chainId];
12163
+ }
12087
12164
 
12088
12165
  // src/abis/compound-v2/VenusLensLegacy.ts
12089
12166
  var VenusLensLegacyAbi = [
@@ -12433,8 +12510,15 @@ function parseMoonwellMarket(input, token) {
12433
12510
  // src/lending/compound-v2/publicCallParse.ts
12434
12511
  var PRICE_DECIMALS = 18;
12435
12512
  var RESERVE_MANTISSA_DECIMALS = 18;
12436
- function convertSingleReserveEntry(opts) {
12437
- const { entryRaw, reader, asset, prices, additionalYields } = opts;
12513
+ function convertSingleEntry(opts) {
12514
+ const {
12515
+ entryRaw,
12516
+ reader,
12517
+ asset,
12518
+ prices,
12519
+ additionalYields,
12520
+ cToken
12521
+ } = opts;
12438
12522
  const decs = asset.decimals;
12439
12523
  const currentEntry = reader(entryRaw, asset);
12440
12524
  const borrowCollateralFactor = parseRawAmount(
@@ -12492,34 +12576,39 @@ function convertSingleReserveEntry(opts) {
12492
12576
  isActive: Boolean(currentEntry?.isListed) && !allPaused,
12493
12577
  isFrozen: pausedActions[0 /* MINT */] && pausedActions[2 /* BORROW */],
12494
12578
  rewards: {},
12495
- state: {
12496
- exchangeRateCurrent: exchangeRateRaw.toString(),
12497
- cTokenDecimals: Number(currentEntry?.cTokenDecimals?.toString())
12498
- },
12499
12579
  collateralActive,
12500
- borrowingEnabled
12580
+ borrowingEnabled,
12501
12581
  // borrowCap example left commented as in original:
12502
12582
  // borrowCap: parseRawAmount(currentEntry?.borrowCap?.toString(), decs),
12583
+ params: {
12584
+ metadata: {
12585
+ cToken,
12586
+ exchangeRate: exchangeRateRaw.toString(),
12587
+ cTokenDecimals: Number(currentEntry?.cTokenDecimals?.toString())
12588
+ }
12589
+ }
12503
12590
  };
12504
12591
  }
12505
- var getCompoundV2ReservesDataConverter = (lender, chainId, prices, additionalYields, tokenList = {}) => {
12506
- const assetsToQuery = getCompoundV2Reserves(chainId, lender);
12507
- const expectedNumberOfCalls = assetsToQuery.length;
12592
+ var getCompoundV2DataConverter = (lender, chainId, prices, additionalYields, tokenList = {}) => {
12593
+ const compoundV2Tokens2 = getCompoundV2Tokens(chainId, lender);
12594
+ const expectedNumberOfCalls = compoundV2Tokens2.length;
12508
12595
  const reader = getReader(lender);
12509
12596
  return [
12510
12597
  (data) => {
12511
12598
  if (data.length !== expectedNumberOfCalls) return void 0;
12512
12599
  const out = { data: {}, chainId };
12513
- for (let i = 0; i < assetsToQuery.length; i++) {
12514
- const poolId = assetsToQuery[i];
12600
+ for (let i = 0; i < compoundV2Tokens2.length; i++) {
12601
+ const { underlying, cToken } = compoundV2Tokens2[i];
12602
+ const poolId = underlying;
12515
12603
  const asset = tokenList[poolId];
12516
12604
  const entryRaw = data[i];
12517
- out.data[poolId] = convertSingleReserveEntry({
12605
+ out.data[poolId] = convertSingleEntry({
12518
12606
  entryRaw,
12519
12607
  reader,
12520
12608
  asset,
12521
12609
  prices,
12522
- additionalYields
12610
+ additionalYields,
12611
+ cToken
12523
12612
  });
12524
12613
  }
12525
12614
  return out;
@@ -13427,7 +13516,7 @@ function getLenderDataConverter(lender, chainId, prices, additionalYields, token
13427
13516
  );
13428
13517
  }
13429
13518
  if (isCompoundV2Type(lender))
13430
- return getCompoundV2ReservesDataConverter(
13519
+ return getCompoundV2DataConverter(
13431
13520
  lender,
13432
13521
  chainId,
13433
13522
  prices,
@@ -19447,6 +19536,7 @@ var compoundV3Reserves2 = baseUrl + "/data/compound-v3-reserves.json";
19447
19536
  var initConfig2 = baseUrl + "/data/init-config.json";
19448
19537
  var aaveTokens2 = baseUrl + "/data/aave-tokens.json";
19449
19538
  var compoundV2CTokens = baseUrl + "/data/compound-v2-c-tokens.json";
19539
+ var compoundV2TokenArray2 = baseUrl + "/data/compound-v2-tokens.json";
19450
19540
  var compoundV3Base = baseUrl + "/data/compound-v3-base-data.json";
19451
19541
  var baseUrlChains = "https://raw.githubusercontent.com/1delta-DAO/chains/main";
19452
19542
  var chains = baseUrlChains + "/data.json";
@@ -19468,6 +19558,7 @@ async function fetchLenderMetaFromDirAndInitialize() {
19468
19558
  initConfigOverride,
19469
19559
  aaveTokensOverride,
19470
19560
  compoundV2TokensOverride,
19561
+ compoundV2TokenArrayOverride,
19471
19562
  compoundV3BaseDataOverride,
19472
19563
  aaveOraclesOverride,
19473
19564
  morphoTypeOraclesOverride,
@@ -19481,6 +19572,7 @@ async function fetchLenderMetaFromDirAndInitialize() {
19481
19572
  compoundV3BaseDataOverride,
19482
19573
  morphoPoolsOverride,
19483
19574
  compoundV2TokensOverride,
19575
+ compoundV2TokenArrayOverride,
19484
19576
  compoundV2PoolsOverride,
19485
19577
  initConfigOverride,
19486
19578
  aaveReservesOverride,
@@ -19505,6 +19597,7 @@ async function fetchLenderMetaFromDir() {
19505
19597
  initConfig2,
19506
19598
  aaveTokens2,
19507
19599
  compoundV2CTokens,
19600
+ compoundV2TokenArray2,
19508
19601
  compoundV3Base,
19509
19602
  aaveOracles2,
19510
19603
  morphoTypeOracles2,
@@ -19523,6 +19616,7 @@ async function fetchLenderMetaFromDir() {
19523
19616
  initConfigOverride,
19524
19617
  aaveTokensOverride,
19525
19618
  compoundV2TokensOverride,
19619
+ compoundV2TokenArrayOverride,
19526
19620
  compoundV3BaseDataOverride,
19527
19621
  aaveOraclesOverride,
19528
19622
  morphoTypeOraclesOverride,
@@ -19541,6 +19635,7 @@ async function fetchLenderMetaFromDir() {
19541
19635
  initConfigOverride,
19542
19636
  aaveTokensOverride,
19543
19637
  compoundV2TokensOverride,
19638
+ compoundV2TokenArrayOverride,
19544
19639
  compoundV3BaseDataOverride,
19545
19640
  aaveOraclesOverride,
19546
19641
  morphoTypeOraclesOverride,