@1delta/margin-fetcher 0.0.150 → 0.0.151

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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";
@@ -7982,6 +7985,7 @@ var getAaveV2ReservesDataConverter = (lender, chainId, prices, additionalYields,
7982
7985
  /** AAVE V2 style with rewards from state */
7983
7986
  default: {
7984
7987
  const assetsToQuery = getAaveAssets(chainId, lender);
7988
+ const aaveTokenMap = getAaveStyleProtocolTokenMap(chainId, lender);
7985
7989
  const expectedNumberOfCalls = assetsToQuery.length * 2;
7986
7990
  return [
7987
7991
  (data) => {
@@ -8077,6 +8081,19 @@ var getAaveV2ReservesDataConverter = (lender, chainId, prices, additionalYields,
8077
8081
  isActive: configData?.[8 /* isActive */],
8078
8082
  isFrozen: configData?.[9 /* isFrozen */]
8079
8083
  };
8084
+ const aaveTokens3 = aaveTokenMap[asset];
8085
+ if (!!aaveTokens3) {
8086
+ resultReserves[asset] = {
8087
+ ...resultReserves[asset],
8088
+ params: {
8089
+ metadata: {
8090
+ aToken: aaveTokens3.aToken,
8091
+ vToken: aaveTokens3.vToken,
8092
+ sToken: aaveTokens3.sToken
8093
+ }
8094
+ }
8095
+ };
8096
+ }
8080
8097
  }
8081
8098
  return {
8082
8099
  data: resultReserves,
@@ -8111,6 +8128,7 @@ var getAaveV3ReservesDataConverter = (lender, chainId, prices, additionalYields,
8111
8128
  const assetsToQuery = getAaveAssets(chainId, lender);
8112
8129
  const allModes = AAVE_V3_EMODES(chainId, lender);
8113
8130
  const expectedNumberOfCalls = assetsToQuery.length * 6 + allModes.length + 1;
8131
+ const aaveTokenMap = getAaveStyleProtocolTokenMap(chainId, lender);
8114
8132
  return [
8115
8133
  (data) => {
8116
8134
  if (data.length !== expectedNumberOfCalls) {
@@ -8221,6 +8239,19 @@ var getAaveV3ReservesDataConverter = (lender, chainId, prices, additionalYields,
8221
8239
  )
8222
8240
  )
8223
8241
  };
8242
+ const aaveTokens3 = aaveTokenMap[asset];
8243
+ if (!!aaveTokens3) {
8244
+ resultReserves[asset] = {
8245
+ ...resultReserves[asset],
8246
+ params: {
8247
+ metadata: {
8248
+ aToken: aaveTokens3.aToken,
8249
+ vToken: aaveTokens3.vToken,
8250
+ sToken: aaveTokens3.sToken
8251
+ }
8252
+ }
8253
+ };
8254
+ }
8224
8255
  }
8225
8256
  return {
8226
8257
  data: resultReserves,
@@ -8320,6 +8351,7 @@ function isReserveEnabledOnBitmap(bitmap, reserveIndex) {
8320
8351
  }
8321
8352
  function parseYLDRCall(chainId, lender, additionalYields, prices, tokenList) {
8322
8353
  const assetsToQuery = getAaveAssets(chainId, lender);
8354
+ const aaveTokenMap = getAaveStyleProtocolTokenMap(chainId, lender);
8323
8355
  const expectedNumberOfCalls = assetsToQuery.length * 2;
8324
8356
  return [
8325
8357
  (data) => {
@@ -8401,6 +8433,19 @@ function parseYLDRCall(chainId, lender, additionalYields, prices, tokenList) {
8401
8433
  isActive: configData?.[7 /* isActive */],
8402
8434
  isFrozen: configData?.[8 /* isFrozen */]
8403
8435
  };
8436
+ const aaveTokens3 = aaveTokenMap[asset];
8437
+ if (!!aaveTokens3) {
8438
+ resultReserves[asset] = {
8439
+ ...resultReserves[asset],
8440
+ params: {
8441
+ metadata: {
8442
+ aToken: aaveTokens3.aToken,
8443
+ vToken: aaveTokens3.vToken,
8444
+ sToken: aaveTokens3.sToken
8445
+ }
8446
+ }
8447
+ };
8448
+ }
8404
8449
  }
8405
8450
  return {
8406
8451
  data: resultReserves,
@@ -8413,6 +8458,7 @@ function parseYLDRCall(chainId, lender, additionalYields, prices, tokenList) {
8413
8458
  }
8414
8459
  function parseAave32(chainId, lender, prices, additionalYields, tokenList) {
8415
8460
  const assetsToQuery = getAaveAssets(chainId, lender);
8461
+ const aaveTokenMap = getAaveStyleProtocolTokenMap(chainId, lender);
8416
8462
  const allModes = AAVE_V3_EMODES(chainId, lender);
8417
8463
  const expectedNumberOfCalls = assetsToQuery.length * 5 + allModes.length * 3 + 2;
8418
8464
  return [
@@ -8534,6 +8580,19 @@ function parseAave32(chainId, lender, prices, additionalYields, tokenList) {
8534
8580
  )
8535
8581
  )
8536
8582
  };
8583
+ const aaveTokens3 = aaveTokenMap[asset];
8584
+ if (!!aaveTokens3) {
8585
+ resultReserves[asset] = {
8586
+ ...resultReserves[asset],
8587
+ params: {
8588
+ metadata: {
8589
+ aToken: aaveTokens3.aToken,
8590
+ vToken: aaveTokens3.vToken,
8591
+ sToken: aaveTokens3.sToken
8592
+ }
8593
+ }
8594
+ };
8595
+ }
8537
8596
  }
8538
8597
  return {
8539
8598
  data: resultReserves,
@@ -12078,12 +12137,12 @@ function getCompoundV2Comptroller(chainId, lender = Lender.VENUS) {
12078
12137
  function getCompoundV2CollateralTokens(chainId, lender = Lender.VENUS) {
12079
12138
  return compoundV2Tokens()?.[lender]?.[chainId];
12080
12139
  }
12081
- function getCompoundV2Reserves(chainId, lender = Lender.VENUS) {
12082
- return compoundV2Reserves()?.[lender]?.[chainId];
12083
- }
12084
12140
  function getCompoundV2Lens(chainId, lender) {
12085
12141
  return COMPOUND_V2_LENS[lender]?.[chainId];
12086
12142
  }
12143
+ function getCompoundV2Tokens(chainId, lender = Lender.VENUS) {
12144
+ return compoundV2TokenArray()?.[lender]?.[chainId];
12145
+ }
12087
12146
 
12088
12147
  // src/abis/compound-v2/VenusLensLegacy.ts
12089
12148
  var VenusLensLegacyAbi = [
@@ -12433,8 +12492,15 @@ function parseMoonwellMarket(input, token) {
12433
12492
  // src/lending/compound-v2/publicCallParse.ts
12434
12493
  var PRICE_DECIMALS = 18;
12435
12494
  var RESERVE_MANTISSA_DECIMALS = 18;
12436
- function convertSingleReserveEntry(opts) {
12437
- const { entryRaw, reader, asset, prices, additionalYields } = opts;
12495
+ function convertSingleEntry(opts) {
12496
+ const {
12497
+ entryRaw,
12498
+ reader,
12499
+ asset,
12500
+ prices,
12501
+ additionalYields,
12502
+ cToken
12503
+ } = opts;
12438
12504
  const decs = asset.decimals;
12439
12505
  const currentEntry = reader(entryRaw, asset);
12440
12506
  const borrowCollateralFactor = parseRawAmount(
@@ -12492,34 +12558,39 @@ function convertSingleReserveEntry(opts) {
12492
12558
  isActive: Boolean(currentEntry?.isListed) && !allPaused,
12493
12559
  isFrozen: pausedActions[0 /* MINT */] && pausedActions[2 /* BORROW */],
12494
12560
  rewards: {},
12495
- state: {
12496
- exchangeRateCurrent: exchangeRateRaw.toString(),
12497
- cTokenDecimals: Number(currentEntry?.cTokenDecimals?.toString())
12498
- },
12499
12561
  collateralActive,
12500
- borrowingEnabled
12562
+ borrowingEnabled,
12501
12563
  // borrowCap example left commented as in original:
12502
12564
  // borrowCap: parseRawAmount(currentEntry?.borrowCap?.toString(), decs),
12565
+ params: {
12566
+ metadata: {
12567
+ cToken,
12568
+ exchangeRate: exchangeRateRaw.toString(),
12569
+ cTokenDecimals: Number(currentEntry?.cTokenDecimals?.toString())
12570
+ }
12571
+ }
12503
12572
  };
12504
12573
  }
12505
- var getCompoundV2ReservesDataConverter = (lender, chainId, prices, additionalYields, tokenList = {}) => {
12506
- const assetsToQuery = getCompoundV2Reserves(chainId, lender);
12507
- const expectedNumberOfCalls = assetsToQuery.length;
12574
+ var getCompoundV2DataConverter = (lender, chainId, prices, additionalYields, tokenList = {}) => {
12575
+ const compoundV2Tokens2 = getCompoundV2Tokens(chainId, lender);
12576
+ const expectedNumberOfCalls = compoundV2Tokens2.length;
12508
12577
  const reader = getReader(lender);
12509
12578
  return [
12510
12579
  (data) => {
12511
12580
  if (data.length !== expectedNumberOfCalls) return void 0;
12512
12581
  const out = { data: {}, chainId };
12513
- for (let i = 0; i < assetsToQuery.length; i++) {
12514
- const poolId = assetsToQuery[i];
12582
+ for (let i = 0; i < compoundV2Tokens2.length; i++) {
12583
+ const { underlying, cToken } = compoundV2Tokens2[i];
12584
+ const poolId = underlying;
12515
12585
  const asset = tokenList[poolId];
12516
12586
  const entryRaw = data[i];
12517
- out.data[poolId] = convertSingleReserveEntry({
12587
+ out.data[poolId] = convertSingleEntry({
12518
12588
  entryRaw,
12519
12589
  reader,
12520
12590
  asset,
12521
12591
  prices,
12522
- additionalYields
12592
+ additionalYields,
12593
+ cToken
12523
12594
  });
12524
12595
  }
12525
12596
  return out;
@@ -13427,7 +13498,7 @@ function getLenderDataConverter(lender, chainId, prices, additionalYields, token
13427
13498
  );
13428
13499
  }
13429
13500
  if (isCompoundV2Type(lender))
13430
- return getCompoundV2ReservesDataConverter(
13501
+ return getCompoundV2DataConverter(
13431
13502
  lender,
13432
13503
  chainId,
13433
13504
  prices,
@@ -19447,6 +19518,7 @@ var compoundV3Reserves2 = baseUrl + "/data/compound-v3-reserves.json";
19447
19518
  var initConfig2 = baseUrl + "/data/init-config.json";
19448
19519
  var aaveTokens2 = baseUrl + "/data/aave-tokens.json";
19449
19520
  var compoundV2CTokens = baseUrl + "/data/compound-v2-c-tokens.json";
19521
+ var compoundV2TokenArray2 = baseUrl + "/data/compound-v2-tokens.json";
19450
19522
  var compoundV3Base = baseUrl + "/data/compound-v3-base-data.json";
19451
19523
  var baseUrlChains = "https://raw.githubusercontent.com/1delta-DAO/chains/main";
19452
19524
  var chains = baseUrlChains + "/data.json";
@@ -19468,6 +19540,7 @@ async function fetchLenderMetaFromDirAndInitialize() {
19468
19540
  initConfigOverride,
19469
19541
  aaveTokensOverride,
19470
19542
  compoundV2TokensOverride,
19543
+ compoundV2TokenArrayOverride,
19471
19544
  compoundV3BaseDataOverride,
19472
19545
  aaveOraclesOverride,
19473
19546
  morphoTypeOraclesOverride,
@@ -19481,6 +19554,7 @@ async function fetchLenderMetaFromDirAndInitialize() {
19481
19554
  compoundV3BaseDataOverride,
19482
19555
  morphoPoolsOverride,
19483
19556
  compoundV2TokensOverride,
19557
+ compoundV2TokenArrayOverride,
19484
19558
  compoundV2PoolsOverride,
19485
19559
  initConfigOverride,
19486
19560
  aaveReservesOverride,
@@ -19505,6 +19579,7 @@ async function fetchLenderMetaFromDir() {
19505
19579
  initConfig2,
19506
19580
  aaveTokens2,
19507
19581
  compoundV2CTokens,
19582
+ compoundV2TokenArray2,
19508
19583
  compoundV3Base,
19509
19584
  aaveOracles2,
19510
19585
  morphoTypeOracles2,
@@ -19523,6 +19598,7 @@ async function fetchLenderMetaFromDir() {
19523
19598
  initConfigOverride,
19524
19599
  aaveTokensOverride,
19525
19600
  compoundV2TokensOverride,
19601
+ compoundV2TokenArrayOverride,
19526
19602
  compoundV3BaseDataOverride,
19527
19603
  aaveOraclesOverride,
19528
19604
  morphoTypeOraclesOverride,
@@ -19541,6 +19617,7 @@ async function fetchLenderMetaFromDir() {
19541
19617
  initConfigOverride,
19542
19618
  aaveTokensOverride,
19543
19619
  compoundV2TokensOverride,
19620
+ compoundV2TokenArrayOverride,
19544
19621
  compoundV3BaseDataOverride,
19545
19622
  aaveOraclesOverride,
19546
19623
  morphoTypeOraclesOverride,