@1delta/margin-fetcher 0.0.9 → 0.0.10

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.
Files changed (103) hide show
  1. package/dist/abis/morpho/blue.d.ts +76 -0
  2. package/dist/abis/morpho/blue.d.ts.map +1 -0
  3. package/dist/abis/morpho/blue.js +99 -0
  4. package/dist/abis/morpho/lens.d.ts +16 -0
  5. package/dist/abis/morpho/lens.d.ts.map +1 -0
  6. package/dist/abis/morpho/lens.js +31 -0
  7. package/dist/flash-liquidity/index.d.ts +1 -0
  8. package/dist/flash-liquidity/index.d.ts.map +1 -1
  9. package/dist/flash-liquidity/index.js +1 -0
  10. package/dist/flash-liquidity/utils.d.ts +11 -0
  11. package/dist/flash-liquidity/utils.d.ts.map +1 -0
  12. package/dist/flash-liquidity/utils.js +17 -0
  13. package/dist/lending/aave-v2-type/publicCallParse.d.ts +2 -1
  14. package/dist/lending/aave-v2-type/publicCallParse.d.ts.map +1 -1
  15. package/dist/lending/aave-v2-type/publicCallParse.js +7 -4
  16. package/dist/lending/aave-v3-type/publicCallParse.d.ts +3 -2
  17. package/dist/lending/aave-v3-type/publicCallParse.d.ts.map +1 -1
  18. package/dist/lending/aave-v3-type/publicCallParse.js +11 -8
  19. package/dist/lending/aave-v3-type/types.d.ts +2 -0
  20. package/dist/lending/aave-v3-type/types.d.ts.map +1 -1
  21. package/dist/lending/compound-v3/publicCallParse.d.ts +2 -1
  22. package/dist/lending/compound-v3/publicCallParse.d.ts.map +1 -1
  23. package/dist/lending/compound-v3/publicCallParse.js +3 -2
  24. package/dist/lending/compound-v3/types.d.ts +2 -0
  25. package/dist/lending/compound-v3/types.d.ts.map +1 -1
  26. package/dist/lending/fetchLender.d.ts +2 -1
  27. package/dist/lending/fetchLender.d.ts.map +1 -1
  28. package/dist/lending/fetchLender.js +12 -8
  29. package/dist/lending/fetchLenderAll.d.ts +8 -0
  30. package/dist/lending/fetchLenderAll.d.ts.map +1 -0
  31. package/dist/lending/fetchLenderAll.js +12 -0
  32. package/dist/lending/fetchLenderExt.d.ts +8 -0
  33. package/dist/lending/fetchLenderExt.d.ts.map +1 -0
  34. package/dist/lending/fetchLenderExt.js +28 -0
  35. package/dist/lending/index.d.ts +1 -0
  36. package/dist/lending/index.d.ts.map +1 -1
  37. package/dist/lending/index.js +1 -0
  38. package/dist/lending/init/publicCallParse.d.ts +2 -1
  39. package/dist/lending/init/publicCallParse.d.ts.map +1 -1
  40. package/dist/lending/init/publicCallParse.js +3 -2
  41. package/dist/lending/init/types.d.ts +2 -0
  42. package/dist/lending/init/types.d.ts.map +1 -1
  43. package/dist/lending/morpho/convertPublic.d.ts +9 -0
  44. package/dist/lending/morpho/convertPublic.d.ts.map +1 -0
  45. package/dist/lending/morpho/convertPublic.js +115 -0
  46. package/dist/lending/morpho/fetchPublic.d.ts +3 -0
  47. package/dist/lending/morpho/fetchPublic.d.ts.map +1 -0
  48. package/dist/lending/morpho/fetchPublic.js +72 -0
  49. package/dist/lending/morpho/publicCallBuild.d.ts +8 -0
  50. package/dist/lending/morpho/publicCallBuild.d.ts.map +1 -0
  51. package/dist/lending/morpho/publicCallBuild.js +6 -0
  52. package/dist/lending/morpho/types.d.ts +106 -0
  53. package/dist/lending/morpho/types.d.ts.map +1 -0
  54. package/dist/lending/morpho/types.js +1 -0
  55. package/dist/lending/types/index.d.ts +18 -0
  56. package/dist/lending/types/index.d.ts.map +1 -0
  57. package/dist/lending/types/index.js +1 -0
  58. package/dist/lending/user-data/aave-v2-type/userCallParse.js +1 -1
  59. package/dist/lending/user-data/morpho/decoder.d.ts +21 -0
  60. package/dist/lending/user-data/morpho/decoder.d.ts.map +1 -0
  61. package/dist/lending/user-data/morpho/decoder.js +52 -0
  62. package/dist/lending/user-data/morpho/morphoLib.d.ts +5 -0
  63. package/dist/lending/user-data/morpho/morphoLib.d.ts.map +1 -0
  64. package/dist/lending/user-data/morpho/morphoLib.js +21 -0
  65. package/dist/lending/user-data/morpho/types.d.ts +12 -0
  66. package/dist/lending/user-data/morpho/types.d.ts.map +1 -0
  67. package/dist/lending/user-data/morpho/types.js +13 -0
  68. package/dist/lending/user-data/morpho/userCallBuild.d.ts +6 -0
  69. package/dist/lending/user-data/morpho/userCallBuild.d.ts.map +1 -0
  70. package/dist/lending/user-data/morpho/userCallBuild.js +36 -0
  71. package/dist/lending/user-data/morpho/userCallParse.d.ts +11 -0
  72. package/dist/lending/user-data/morpho/userCallParse.d.ts.map +1 -0
  73. package/dist/lending/user-data/morpho/userCallParse.js +99 -0
  74. package/dist/lending/user-data/morpho/userCallParseNoDeploy.d.ts +11 -0
  75. package/dist/lending/user-data/morpho/userCallParseNoDeploy.d.ts.map +1 -0
  76. package/dist/lending/user-data/morpho/userCallParseNoDeploy.js +112 -0
  77. package/dist/lending-pairs/computeLendingPairs.d.ts +2 -0
  78. package/dist/lending-pairs/computeLendingPairs.d.ts.map +1 -1
  79. package/dist/lending-pairs/computeLendingPairs.js +57 -30
  80. package/dist/prices/main-prices/fetchOracleData.d.ts +0 -1
  81. package/dist/prices/main-prices/fetchOracleData.d.ts.map +1 -1
  82. package/dist/prices/main-prices/fetchOracleData.js +86 -55
  83. package/dist/utils/index.d.ts +2 -0
  84. package/dist/utils/index.d.ts.map +1 -1
  85. package/dist/utils/index.js +41 -16
  86. package/package.json +1 -1
  87. package/src/flash-liquidity/index.ts +2 -1
  88. package/src/flash-liquidity/utils.ts +22 -0
  89. package/src/lending/aave-v2-type/publicCallParse.ts +9 -4
  90. package/src/lending/aave-v3-type/publicCallParse.ts +13 -8
  91. package/src/lending/aave-v3-type/types.ts +2 -0
  92. package/src/lending/compound-v3/publicCallParse.ts +5 -2
  93. package/src/lending/compound-v3/types.ts +2 -0
  94. package/src/lending/fetchLender.ts +23 -17
  95. package/src/lending/index.ts +2 -1
  96. package/src/lending/init/publicCallParse.ts +5 -2
  97. package/src/lending/init/types.ts +3 -0
  98. package/src/lending/types/index.ts +16 -0
  99. package/src/lending/user-data/aave-v2-type/userCallParse.ts +1 -1
  100. package/src/lending-pairs/computeLendingPairs.ts +417 -315
  101. package/src/prices/main-prices/fetchOracleData.ts +187 -109
  102. package/src/utils/index.ts +90 -58
  103. package/test/index.test.ts +15 -7
@@ -0,0 +1,76 @@
1
+ export declare const MorphoBlueAbi: readonly [{
2
+ readonly inputs: readonly [{
3
+ readonly internalType: "Id";
4
+ readonly name: "";
5
+ readonly type: "bytes32";
6
+ }, {
7
+ readonly internalType: "address";
8
+ readonly name: "";
9
+ readonly type: "address";
10
+ }];
11
+ readonly name: "position";
12
+ readonly outputs: readonly [{
13
+ readonly internalType: "uint256";
14
+ readonly name: "supplyShares";
15
+ readonly type: "uint256";
16
+ }, {
17
+ readonly internalType: "uint128";
18
+ readonly name: "borrowShares";
19
+ readonly type: "uint128";
20
+ }, {
21
+ readonly internalType: "uint128";
22
+ readonly name: "collateral";
23
+ readonly type: "uint128";
24
+ }];
25
+ readonly stateMutability: "view";
26
+ readonly type: "function";
27
+ }, {
28
+ readonly inputs: readonly [{
29
+ readonly internalType: "bytes32[]";
30
+ readonly name: "slots";
31
+ readonly type: "bytes32[]";
32
+ }];
33
+ readonly name: "extSloads";
34
+ readonly outputs: readonly [{
35
+ readonly internalType: "bytes32[]";
36
+ readonly name: "res";
37
+ readonly type: "bytes32[]";
38
+ }];
39
+ readonly stateMutability: "view";
40
+ readonly type: "function";
41
+ }, {
42
+ readonly inputs: readonly [{
43
+ readonly internalType: "Id";
44
+ readonly name: "";
45
+ readonly type: "bytes32";
46
+ }];
47
+ readonly name: "market";
48
+ readonly outputs: readonly [{
49
+ readonly internalType: "uint128";
50
+ readonly name: "totalSupplyAssets";
51
+ readonly type: "uint128";
52
+ }, {
53
+ readonly internalType: "uint128";
54
+ readonly name: "totalSupplyShares";
55
+ readonly type: "uint128";
56
+ }, {
57
+ readonly internalType: "uint128";
58
+ readonly name: "totalBorrowAssets";
59
+ readonly type: "uint128";
60
+ }, {
61
+ readonly internalType: "uint128";
62
+ readonly name: "totalBorrowShares";
63
+ readonly type: "uint128";
64
+ }, {
65
+ readonly internalType: "uint128";
66
+ readonly name: "lastUpdate";
67
+ readonly type: "uint128";
68
+ }, {
69
+ readonly internalType: "uint128";
70
+ readonly name: "fee";
71
+ readonly type: "uint128";
72
+ }];
73
+ readonly stateMutability: "view";
74
+ readonly type: "function";
75
+ }];
76
+ //# sourceMappingURL=blue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blue.d.ts","sourceRoot":"","sources":["../../../src/abis/morpho/blue.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkGhB,CAAA"}
@@ -0,0 +1,99 @@
1
+ export const MorphoBlueAbi = [
2
+ {
3
+ "inputs": [
4
+ {
5
+ "internalType": "Id",
6
+ "name": "",
7
+ "type": "bytes32"
8
+ },
9
+ {
10
+ "internalType": "address",
11
+ "name": "",
12
+ "type": "address"
13
+ }
14
+ ],
15
+ "name": "position",
16
+ "outputs": [
17
+ {
18
+ "internalType": "uint256",
19
+ "name": "supplyShares",
20
+ "type": "uint256"
21
+ },
22
+ {
23
+ "internalType": "uint128",
24
+ "name": "borrowShares",
25
+ "type": "uint128"
26
+ },
27
+ {
28
+ "internalType": "uint128",
29
+ "name": "collateral",
30
+ "type": "uint128"
31
+ }
32
+ ],
33
+ "stateMutability": "view",
34
+ "type": "function"
35
+ },
36
+ {
37
+ "inputs": [
38
+ {
39
+ "internalType": "bytes32[]",
40
+ "name": "slots",
41
+ "type": "bytes32[]"
42
+ }
43
+ ],
44
+ "name": "extSloads",
45
+ "outputs": [
46
+ {
47
+ "internalType": "bytes32[]",
48
+ "name": "res",
49
+ "type": "bytes32[]"
50
+ }
51
+ ],
52
+ "stateMutability": "view",
53
+ "type": "function"
54
+ },
55
+ {
56
+ "inputs": [
57
+ {
58
+ "internalType": "Id",
59
+ "name": "",
60
+ "type": "bytes32"
61
+ }
62
+ ],
63
+ "name": "market",
64
+ "outputs": [
65
+ {
66
+ "internalType": "uint128",
67
+ "name": "totalSupplyAssets",
68
+ "type": "uint128"
69
+ },
70
+ {
71
+ "internalType": "uint128",
72
+ "name": "totalSupplyShares",
73
+ "type": "uint128"
74
+ },
75
+ {
76
+ "internalType": "uint128",
77
+ "name": "totalBorrowAssets",
78
+ "type": "uint128"
79
+ },
80
+ {
81
+ "internalType": "uint128",
82
+ "name": "totalBorrowShares",
83
+ "type": "uint128"
84
+ },
85
+ {
86
+ "internalType": "uint128",
87
+ "name": "lastUpdate",
88
+ "type": "uint128"
89
+ },
90
+ {
91
+ "internalType": "uint128",
92
+ "name": "fee",
93
+ "type": "uint128"
94
+ }
95
+ ],
96
+ "stateMutability": "view",
97
+ "type": "function"
98
+ },
99
+ ];
@@ -0,0 +1,16 @@
1
+ export declare const MorphoLensAbi: {
2
+ inputs: {
3
+ internalType: string;
4
+ name: string;
5
+ type: string;
6
+ }[];
7
+ name: string;
8
+ outputs: {
9
+ internalType: string;
10
+ name: string;
11
+ type: string;
12
+ }[];
13
+ stateMutability: string;
14
+ type: string;
15
+ }[];
16
+ //# sourceMappingURL=lens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lens.d.ts","sourceRoot":"","sources":["../../../src/abis/morpho/lens.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;GA8BzB,CAAA"}
@@ -0,0 +1,31 @@
1
+ export const MorphoLensAbi = [
2
+ {
3
+ "inputs": [
4
+ {
5
+ "internalType": "bytes32[]",
6
+ "name": "marketsIds",
7
+ "type": "bytes32[]"
8
+ },
9
+ {
10
+ "internalType": "address",
11
+ "name": "user",
12
+ "type": "address"
13
+ },
14
+ {
15
+ "internalType": "address",
16
+ "name": "morpho",
17
+ "type": "address"
18
+ }
19
+ ],
20
+ "name": "getUserDataCompact",
21
+ "outputs": [
22
+ {
23
+ "internalType": "bytes",
24
+ "name": "data",
25
+ "type": "bytes"
26
+ }
27
+ ],
28
+ "stateMutability": "view",
29
+ "type": "function"
30
+ }
31
+ ];
@@ -1,2 +1,3 @@
1
1
  export * from "./fetchLiquidity";
2
+ export * from "./utils";
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/flash-liquidity/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/flash-liquidity/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,SAAS,CAAA"}
@@ -1 +1,2 @@
1
1
  export * from "./fetchLiquidity";
2
+ export * from "./utils";
@@ -0,0 +1,11 @@
1
+ import { FlashLiquiditiesOnChain } from "./types";
2
+ /**
3
+ * Add prices to get dollar flash liquidties
4
+ * Ideal for de-based flash loans
5
+ */
6
+ export declare function attachPricesToFlashLiquidity(chainId: string, liq: FlashLiquiditiesOnChain, prices: {
7
+ [k: string]: number;
8
+ }): {
9
+ [asset: string]: import("./types").FlashLoanLiquidityForAsset[];
10
+ };
11
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/flash-liquidity/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAElD;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,uBAAuB,EAAE,MAAM,EAAE;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE;;EAc1H"}
@@ -0,0 +1,17 @@
1
+ import { getAssetMeta, toGenericPriceKey } from "../assets";
2
+ /**
3
+ * Add prices to get dollar flash liquidties
4
+ * Ideal for de-based flash loans
5
+ */
6
+ export function attachPricesToFlashLiquidity(chainId, liq, prices) {
7
+ let liqCopy = { ...liq };
8
+ Object.entries(liq).forEach(([asset, entry]) => {
9
+ const priceKey = getAssetMeta(chainId, asset)?.assetGroup ?? toGenericPriceKey(asset, chainId);
10
+ const price = prices[priceKey] ?? 0;
11
+ liqCopy[asset] = entry.map(e => ({
12
+ ...e,
13
+ availableUSD: e.available * price
14
+ }));
15
+ });
16
+ return liqCopy;
17
+ }
@@ -1,7 +1,8 @@
1
1
  import { Lender } from "@1delta/asset-registry";
2
2
  import { AaveV2GeneralPublicResponse } from "./types";
3
3
  import { AdditionalYields } from "../../types";
4
+ import { GenericTokenList } from "../types";
4
5
  export declare const getAaveV2ReservesDataConverter: (lender: Lender, chainId: string, prices: {
5
6
  [asset: string]: number;
6
- }, additionalYields: AdditionalYields) => [(data: any[]) => AaveV2GeneralPublicResponse | undefined, number];
7
+ }, additionalYields: AdditionalYields, tokenList?: GenericTokenList) => [(data: any[]) => AaveV2GeneralPublicResponse | undefined, number];
7
8
  //# sourceMappingURL=publicCallParse.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"publicCallParse.d.ts","sourceRoot":"","sources":["../../../src/lending/aave-v2-type/publicCallParse.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAGhD,OAAO,EACL,2BAA2B,EAI5B,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,eAAO,MAAM,8BAA8B,GACzC,QAAQ,MAAM,EACd,SAAS,MAAM,EACf,QAAQ;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,EACnC,kBAAkB,gBAAgB,KACjC,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,2BAA2B,GAAG,SAAS,EAAE,MAAM,CA0RnE,CAAA"}
1
+ {"version":3,"file":"publicCallParse.d.ts","sourceRoot":"","sources":["../../../src/lending/aave-v2-type/publicCallParse.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAGhD,OAAO,EACL,2BAA2B,EAI5B,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,eAAO,MAAM,8BAA8B,GACzC,QAAQ,MAAM,EACd,SAAS,MAAM,EACf,QAAQ;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,EACnC,kBAAkB,gBAAgB,EAClC,YAAW,gBAAqB,KAC/B,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,2BAA2B,GAAG,SAAS,EAAE,MAAM,CA6RnE,CAAA"}
@@ -2,7 +2,7 @@ import { Lender } from "@1delta/asset-registry";
2
2
  import { getAaveAssets, getAssetMeta, LENDER_MODE_NO_MODE, toGenericPriceKey, toOracleKey } from "../../assets";
3
3
  import { BPS, convertRateToApr, formatAaveRawApyToApr, parseRawAmount } from "../../utils/parsing";
4
4
  import { AaveV2TypeGetReserveConfigurationData, AaveV2TypeGetReserveDataIndexes, AaveV2TypeIncentivesControllerPoolInfoIndexes } from "./types";
5
- export const getAaveV2ReservesDataConverter = (lender, chainId, prices, additionalYields) => {
5
+ export const getAaveV2ReservesDataConverter = (lender, chainId, prices, additionalYields, tokenList = {}) => {
6
6
  switch (lender) {
7
7
  case Lender.AURELIUS: {
8
8
  const assetsToQuery = getAaveAssets(chainId, lender);
@@ -21,7 +21,7 @@ export const getAaveV2ReservesDataConverter = (lender, chainId, prices, addition
21
21
  const [, emission1PerSecondCollateral, ,] = data[i * 6 + 3];
22
22
  const [, emission0PerSecondDebt, ,] = data[i * 6 + 4];
23
23
  const [, emission1PerSecondDebt, ,] = data[i * 6 + 5];
24
- const assetMeta = getAssetMeta(chainId, asset);
24
+ const assetMeta = tokenList[asset] ?? { ...getAssetMeta(chainId, asset), address: asset };
25
25
  const decimals = assetMeta?.decimals ?? 18;
26
26
  const totalStableDebt = parseRawAmount(reserveData?.[AaveV2TypeGetReserveDataIndexes.totalStableDebt]?.toString(), decimals);
27
27
  const totalVariableDebt = parseRawAmount(reserveData?.[AaveV2TypeGetReserveDataIndexes.totalVariableDebt]?.toString(), decimals);
@@ -34,6 +34,7 @@ export const getAaveV2ReservesDataConverter = (lender, chainId, prices, addition
34
34
  resultReserves[asset] = {
35
35
  poolId: asset,
36
36
  underlying: asset,
37
+ asset: assetMeta,
37
38
  // token amounts
38
39
  totalDeposits: totalAToken,
39
40
  totalDebtStable: totalStableDebt,
@@ -110,7 +111,7 @@ export const getAaveV2ReservesDataConverter = (lender, chainId, prices, addition
110
111
  const borrowRewardIndex = i * 4 + 3;
111
112
  const collateralRewards = Number(data?.[collateralRewardIndex]?.[AaveV2TypeIncentivesControllerPoolInfoIndexes.allocPoint].toString()) / totalAllocPoint * rewardsPerSecond;
112
113
  const borrowRewards = Number(data?.[borrowRewardIndex]?.[AaveV2TypeIncentivesControllerPoolInfoIndexes.allocPoint].toString()) / totalAllocPoint * rewardsPerSecond;
113
- const assetMeta = getAssetMeta(chainId, asset);
114
+ const assetMeta = tokenList[asset] ?? { ...getAssetMeta(chainId, asset), address: asset };
114
115
  const decimals = assetMeta?.decimals ?? 18;
115
116
  const totalStableDebt = parseRawAmount(reserveData?.[AaveV2TypeGetReserveDataIndexes.totalStableDebt]?.toString(), decimals);
116
117
  const totalVariableDebt = parseRawAmount(reserveData?.[AaveV2TypeGetReserveDataIndexes.totalVariableDebt]?.toString(), decimals);
@@ -123,6 +124,7 @@ export const getAaveV2ReservesDataConverter = (lender, chainId, prices, addition
123
124
  resultReserves[asset] = {
124
125
  poolId: asset,
125
126
  underlying: asset,
127
+ asset: assetMeta,
126
128
  // token amounts
127
129
  totalDeposits: totalAToken,
128
130
  totalDebtStable: totalStableDebt,
@@ -187,7 +189,7 @@ export const getAaveV2ReservesDataConverter = (lender, chainId, prices, addition
187
189
  const asset = assetsToQuery[i];
188
190
  const reserveData = data[i * 2];
189
191
  const configData = data[i * 2 + 1];
190
- const assetMeta = getAssetMeta(chainId, asset);
192
+ const assetMeta = tokenList[asset] ?? { ...getAssetMeta(chainId, asset), address: asset };
191
193
  const decimals = assetMeta?.decimals ?? 18;
192
194
  const totalStableDebt = parseRawAmount(reserveData?.[AaveV2TypeGetReserveDataIndexes.totalStableDebt]?.toString(), decimals);
193
195
  const totalVariableDebt = parseRawAmount(reserveData?.[AaveV2TypeGetReserveDataIndexes.totalVariableDebt]?.toString(), decimals);
@@ -200,6 +202,7 @@ export const getAaveV2ReservesDataConverter = (lender, chainId, prices, addition
200
202
  resultReserves[asset] = {
201
203
  poolId: asset,
202
204
  underlying: asset,
205
+ asset: assetMeta,
203
206
  // token amounts
204
207
  totalDeposits: totalAToken,
205
208
  totalDebtStable: totalStableDebt,
@@ -1,8 +1,9 @@
1
1
  import { AaveV3GeneralPublicResponse } from "./types";
2
2
  import { AdditionalYields } from "../../types";
3
3
  import { Lender } from "@1delta/asset-registry";
4
+ import { GenericTokenList } from "../types";
4
5
  export declare const getAaveV3ReservesDataConverter: (lender: Lender, chainId: string, prices: {
5
6
  [asset: string]: number;
6
- }, additionalYields: AdditionalYields) => [(data: any[]) => AaveV3GeneralPublicResponse | undefined, number];
7
- export declare function parseYLDRCall(chainId: string, lender: Lender, additionalYields: any, prices: any): [(data: any[]) => any | undefined, number];
7
+ }, additionalYields: AdditionalYields, tokenList?: GenericTokenList) => [(data: any[]) => AaveV3GeneralPublicResponse | undefined, number];
8
+ export declare function parseYLDRCall(chainId: string, lender: Lender, additionalYields: any, prices: any, tokenList: any): [(data: any[]) => any | undefined, number];
8
9
  //# sourceMappingURL=publicCallParse.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"publicCallParse.d.ts","sourceRoot":"","sources":["../../../src/lending/aave-v3-type/publicCallParse.ts"],"names":[],"mappings":"AACA,OAAO,EACL,2BAA2B,EAK5B,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,gBAA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AE,SAAS,EAAE,GAAG,GAAG,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,GAAG,SAAS,EAAE,MAAM,CAAC,CAgF7J"}
@@ -3,12 +3,12 @@ import { AAVE_V3_EMODES } from "./publicCallBuild";
3
3
  import { BPS, formatAaveRawApyToApr, parseRawAmount } from "../../utils/parsing";
4
4
  import { Lender } from "@1delta/asset-registry";
5
5
  import { getAaveAssets, getAssetMeta, LENDER_MODE_NO_MODE, toGenericPriceKey, toOracleKey } from "../../assets";
6
- export const getAaveV3ReservesDataConverter = (lender, chainId, prices, additionalYields) => {
6
+ export const getAaveV3ReservesDataConverter = (lender, chainId, prices, additionalYields, tokenList = {}) => {
7
7
  if (lender.includes("AAVE_V3"))
8
- return parseAave32(chainId, lender, prices, additionalYields);
8
+ return parseAave32(chainId, lender, prices, additionalYields, tokenList);
9
9
  switch (lender) {
10
10
  /** AAVE V3 style with rewards from state */
11
- case Lender.YLDR: return parseYLDRCall(chainId, lender, additionalYields, prices);
11
+ case Lender.YLDR: return parseYLDRCall(chainId, lender, additionalYields, prices, tokenList);
12
12
  default: {
13
13
  const assetsToQuery = getAaveAssets(chainId, lender);
14
14
  const expectedNumberOfCalls = assetsToQuery.length * 6 + AAVE_V3_EMODES.length + 1;
@@ -41,7 +41,7 @@ export const getAaveV3ReservesDataConverter = (lender, chainId, prices, addition
41
41
  const reserveCaps = data[i * 6 + 3];
42
42
  const debtCeiling = data[i * 6 + 4];
43
43
  const reserveEMode = data[i * 6 + 5];
44
- const assetMeta = getAssetMeta(chainId, asset);
44
+ const assetMeta = tokenList[asset] ?? { ...getAssetMeta(chainId, asset), address: asset };
45
45
  const decimals = assetMeta?.decimals ?? 18;
46
46
  const totalDeposits = parseRawAmount(reserveData?.[AaveV3GetReservesIndexes.totalAToken]?.toString(), decimals);
47
47
  const totalDebtStable = parseRawAmount(reserveData?.[AaveV3GetReservesIndexes.totalStableDebt]?.toString(), decimals);
@@ -51,6 +51,7 @@ export const getAaveV3ReservesDataConverter = (lender, chainId, prices, addition
51
51
  resultReserves[asset] = {
52
52
  poolId: asset,
53
53
  underlying: asset,
54
+ asset: assetMeta,
54
55
  // raw amounts
55
56
  totalDeposits,
56
57
  totalDebtStable,
@@ -126,7 +127,7 @@ const populateEModes = (borrowCollateralFactor, collateralFactor) => {
126
127
  function isReserveEnabledOnBitmap(bitmap, reserveIndex) {
127
128
  return ((bitmap >> BigInt(reserveIndex)) & 1n) !== 0n;
128
129
  }
129
- export function parseYLDRCall(chainId, lender, additionalYields, prices) {
130
+ export function parseYLDRCall(chainId, lender, additionalYields, prices, tokenList) {
130
131
  const assetsToQuery = getAaveAssets(chainId, lender);
131
132
  const expectedNumberOfCalls = assetsToQuery.length * 2;
132
133
  return [
@@ -139,7 +140,7 @@ export function parseYLDRCall(chainId, lender, additionalYields, prices) {
139
140
  const asset = assetsToQuery[i];
140
141
  const reserveData = data[i * 2];
141
142
  const configData = data[i * 2 + 1];
142
- const assetMeta = getAssetMeta(chainId, asset);
143
+ const assetMeta = tokenList[asset] ?? { ...getAssetMeta(chainId, asset), address: asset };
143
144
  const decimals = assetMeta?.decimals ?? 18;
144
145
  const totalVariableDebt = parseRawAmount(reserveData?.[YLDRTypeGetReserveDataIndexes.totalVariableDebt]?.toString(), decimals);
145
146
  const totalAToken = parseRawAmount(reserveData?.[YLDRTypeGetReserveDataIndexes.totalYToken]?.toString(), decimals);
@@ -151,6 +152,7 @@ export function parseYLDRCall(chainId, lender, additionalYields, prices) {
151
152
  resultReserves[asset] = {
152
153
  poolId: asset,
153
154
  underlying: asset,
155
+ asset: assetMeta,
154
156
  // token amounts
155
157
  totalDeposits: totalAToken,
156
158
  totalDebtStable: 0,
@@ -196,7 +198,7 @@ export function parseYLDRCall(chainId, lender, additionalYields, prices) {
196
198
  expectedNumberOfCalls,
197
199
  ];
198
200
  }
199
- function parseAave32(chainId, lender, prices, additionalYields) {
201
+ function parseAave32(chainId, lender, prices, additionalYields, tokenList) {
200
202
  const assetsToQuery = getAaveAssets(chainId, lender);
201
203
  const expectedNumberOfCalls = assetsToQuery.length * 5 + AAVE_V3_EMODES.length * 3 + 2;
202
204
  return [
@@ -234,7 +236,7 @@ function parseAave32(chainId, lender, prices, additionalYields) {
234
236
  // const siloedBorrowing = data[i * 5 + 2]
235
237
  const reserveCaps = data[i * 5 + 3];
236
238
  const debtCeiling = data[i * 5 + 4];
237
- const assetMeta = getAssetMeta(chainId, asset);
239
+ const assetMeta = tokenList[asset] ?? { ...getAssetMeta(chainId, asset), address: asset };
238
240
  const decimals = assetMeta?.decimals ?? 18;
239
241
  const totalDeposits = parseRawAmount(reserveData?.[AaveV3GetReservesIndexes.totalAToken]?.toString(), decimals);
240
242
  const totalDebtStable = parseRawAmount(reserveData?.[AaveV3GetReservesIndexes.totalStableDebt]?.toString(), decimals);
@@ -244,6 +246,7 @@ function parseAave32(chainId, lender, prices, additionalYields) {
244
246
  resultReserves[asset] = {
245
247
  poolId: asset,
246
248
  underlying: asset,
249
+ asset: assetMeta,
247
250
  // raw amounts
248
251
  totalDeposits,
249
252
  totalDebtStable,
@@ -1,3 +1,4 @@
1
+ import { GenericCurrency } from "../types";
1
2
  export interface BaseYields {
2
3
  variableBorrowRate: number;
3
4
  stableBorrowRate: number;
@@ -69,6 +70,7 @@ export declare enum AaveV3GetEModeCategoryDataIndexes {
69
70
  export interface AaveV3GeneralPublicResponse {
70
71
  data: {
71
72
  [tokenSymbol: string]: {
73
+ asset: GenericCurrency;
72
74
  totalDeposits: number;
73
75
  totalDebtStable: number;
74
76
  totalDebt: number;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lending/aave-v3-type/types.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,UAAU;IAEzB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,gBAAgB,EAAE,MAAM,CAAA;IAExB,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,MAAM,UAAU,GAAG;IAAE,CAAC,QA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,CAAA;IACD,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE;QACN,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAA;KAC1B,CAAA;CACF;AAED,oBAAY,6BAA6B;IACvC,oBAAoB,IAAI;IACxB,iBAAiB,IAAA;IACjB,mBAAmB,IAAA;IACnB,mBAAmB,IAAA;IACnB,kBAAkB,IAAA;IAClB,gBAAgB,IAAA;IAChB,aAAa,IAAA;IACb,qBAAqB,IAAA;IACrB,wBAAwB,IAAA;CACzB;AAED,oBAAY,6BAA6B;IACvC,oBAAoB,IAAI;IACxB,mBAAmB,IAAA;IACnB,kBAAkB,IAAA;IAClB,aAAa,IAAA;IACb,wBAAwB,IAAA;CACzB;AAID,oBAAY,6BAA6B;IACvC,uBAAuB,IAAI;IAC3B,WAAW,IAAA;IACX,iBAAiB,IAAA;IACjB,aAAa,IAAA;IACb,kBAAkB,IAAA;IAClB,cAAc,IAAA;IACd,mBAAmB,IAAA;IACnB,mBAAmB,IAAA;CACpB;AACD,oBAAY,mCAAmC;IAC7C,QAAQ,IAAI;IACZ,GAAG,IAAA;IACH,oBAAoB,IAAA;IACpB,gBAAgB,IAAA;IAChB,aAAa,IAAA;IACb,wBAAwB,IAAA;IACxB,gBAAgB,IAAA;IAChB,QAAQ,IAAA;IACR,QAAQ,IAAA;CACT"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lending/aave-v3-type/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAG1C,MAAM,WAAW,UAAU;IAEzB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,gBAAgB,EAAE,MAAM,CAAA;IAExB,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,MAAM,UAAU,GAAG;IAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAAA;CAAE,CAAA;AAG3D,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,MAAM,C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,EAAE,MAAM,GAAG,SAAS,CAAA;KAC1B,CAAA;CACF;AAED,oBAAY,6BAA6B;IACvC,oBAAoB,IAAI;IACxB,iBAAiB,IAAA;IACjB,mBAAmB,IAAA;IACnB,mBAAmB,IAAA;IACnB,kBAAkB,IAAA;IAClB,gBAAgB,IAAA;IAChB,aAAa,IAAA;IACb,qBAAqB,IAAA;IACrB,wBAAwB,IAAA;CACzB;AAED,oBAAY,6BAA6B;IACvC,oBAAoB,IAAI;IACxB,mBAAmB,IAAA;IACnB,kBAAkB,IAAA;IAClB,aAAa,IAAA;IACb,wBAAwB,IAAA;CACzB;AAID,oBAAY,6BAA6B;IACvC,uBAAuB,IAAI;IAC3B,WAAW,IAAA;IACX,iBAAiB,IAAA;IACjB,aAAa,IAAA;IACb,kBAAkB,IAAA;IAClB,cAAc,IAAA;IACd,mBAAmB,IAAA;IACnB,mBAAmB,IAAA;CACpB;AACD,oBAAY,mCAAmC;IAC7C,QAAQ,IAAI;IACZ,GAAG,IAAA;IACH,oBAAoB,IAAA;IACpB,gBAAgB,IAAA;IAChB,aAAa,IAAA;IACb,wBAAwB,IAAA;IACxB,gBAAgB,IAAA;IAChB,QAAQ,IAAA;IACR,QAAQ,IAAA;CACT"}
@@ -1,7 +1,8 @@
1
1
  import { Lender } from "@1delta/asset-registry";
2
2
  import { AdditionalYields } from "../../types";
3
3
  import { CompoundV3GeneralPublicResponse } from "./types";
4
+ import { GenericTokenList } from "../types";
4
5
  export declare const getCompoundV3ReservesDataConverter: (lender: Lender, chainId: string, prices: {
5
6
  [asset: string]: number;
6
- }, additionalYields: AdditionalYields) => [(data: any[]) => CompoundV3GeneralPublicResponse | undefined, number];
7
+ }, additionalYields: AdditionalYields, tokenList?: GenericTokenList) => [(data: any[]) => CompoundV3GeneralPublicResponse | undefined, number];
7
8
  //# sourceMappingURL=publicCallParse.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"publicCallParse.d.ts","sourceRoot":"","sources":["../../../src/lending/compound-v3/publicCallParse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAA4B,+BAA+B,EAAE,MAAM,SAAS,CAAA;AASnF,eAAO,MAAM,kCAAkC,GAC7C,QAAQ,MAAM,EACd,SAAS,MAAM,EACf,QAAQ;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,EACnC,kBAAkB,gBAAgB,KACjC,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,+BAA+B,GAAG,SAAS,EAAE,MAAM,CA6HvE,CAAA"}
1
+ {"version":3,"file":"publicCallParse.d.ts","sourceRoot":"","sources":["../../../src/lending/compound-v3/publicCallParse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAA4B,+BAA+B,EAAE,MAAM,SAAS,CAAA;AAInF,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAM3C,eAAO,MAAM,kCAAkC,GAC7C,QAAQ,MAAM,EACd,SAAS,MAAM,EACf,QAAQ;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,EACnC,kBAAkB,gBAAgB,EAClC,YAAW,gBAAqB,KAC/B,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,+BAA+B,GAAG,SAAS,EAAE,MAAM,CA8HvE,CAAA"}
@@ -5,7 +5,7 @@ import { calculateRateForCompound, parseRawAmount } from "../../utils/parsing";
5
5
  const COMET_RISK_DECIMALS = 18;
6
6
  const SECONDS_PER_DAY = 3600 * 24;
7
7
  const DAYS_IN_YEAR = 365;
8
- export const getCompoundV3ReservesDataConverter = (lender, chainId, prices, additionalYields) => {
8
+ export const getCompoundV3ReservesDataConverter = (lender, chainId, prices, additionalYields, tokenList = {}) => {
9
9
  const assetsToQuery = getCompoundV3Assets(chainId, lender);
10
10
  const baseAssetData = getCompoundV3BaseAsset(lender, chainId);
11
11
  const tokensNoBase = assetsToQuery.filter(a => a !== baseAssetData.baseAsset);
@@ -21,13 +21,14 @@ export const getCompoundV3ReservesDataConverter = (lender, chainId, prices, addi
21
21
  const asset = tokensNoBase[i];
22
22
  const resultsAssetInfo = data[i * 2];
23
23
  const resultsTotals = data[i * 2 + 1];
24
- const assetMeta = getAssetMeta(chainId, asset);
24
+ const assetMeta = tokenList[asset] ?? { ...getAssetMeta(chainId, asset), address: asset };
25
25
  const decimals = assetMeta?.decimals ?? 18;
26
26
  const totals = parseRawAmount(resultsTotals[0], decimals);
27
27
  const oracleKey = toOracleKey(assetMeta?.assetGroup) ?? toGenericPriceKey(asset, chainId);
28
28
  result[asset] = {
29
29
  poolId: asset,
30
30
  underlying: asset,
31
+ asset: assetMeta,
31
32
  config: {
32
33
  [LENDER_MODE_NO_MODE]: {
33
34
  category: LENDER_MODE_NO_MODE,
@@ -1,4 +1,5 @@
1
1
  import { RewardsMap } from "../aave-v3-type/types";
2
+ import { GenericCurrency } from "../types";
2
3
  export declare enum CometInterestRateIndexes {
3
4
  borrowRate = 0,
4
5
  supplyRate = 1,
@@ -7,6 +8,7 @@ export declare enum CometInterestRateIndexes {
7
8
  export interface CompoundV3GeneralPublicResponse {
8
9
  data: {
9
10
  [tokenSymbol: string]: {
11
+ asset: GenericCurrency;
10
12
  config: {
11
13
  [0]: {
12
14
  category: 0;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lending/compound-v3/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAInD,oBAAY,wBAAwB;IAClC,UAAU,IAAI;IACd,UAAU,IAAI;IACd,WAAW,IAAI;CAChB;AAED,MAAM,WAAW,+BAA+B;IAC9C,IAAI,EAAE;QACJ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AAW,EAAE,MAAM,CAAC;YAEpB,WAAW,EAAE,MAAM,CAAC;YAEpB,SAAS,EAAE,MAAM,CAAC;YAElB,aAAa,EAAE,MAAM,CAAC;YAGtB,OAAO,CAAC,EAAE,UAAU,CAAA;SACrB,CAAA;KACF,CAAC;IACF,OAAO,EAAE,MAAM,CAAC;CACjB"}
@@ -1,8 +1,9 @@
1
1
  import { AdditionalYields, MulticallRetryFunction } from '../types';
2
2
  import { Lender } from '@1delta/asset-registry';
3
+ import { GenericTokenList } from './types';
3
4
  export declare const getLenderPublicData: (chainId: string, lenders: Lender[], prices: {
4
5
  [asset: string]: number;
5
- }, additionalYields: AdditionalYields, multicallRetry: MulticallRetryFunction) => Promise<{
6
+ }, additionalYields: AdditionalYields, multicallRetry: MulticallRetryFunction, tokenList?: () => Promise<GenericTokenList>) => Promise<{
6
7
  [lender: string]: any;
7
8
  }>;
8
9
  //# sourceMappingURL=fetchLender.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetchLender.d.ts","sourceRoot":"","sources":["../../src/lending/fetchLender.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAWnE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAyD/C,eAAO,MAAM,mBAAmB,GAC9B,SAAS,MAAM,EACf,SAAS,MAAM,EAAE,EACjB,QAAQ;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,EACnC,kBAAkB,gBAAgB,EAClC,gBAAgB,sBAAsB,KACrC,OAAO,CAAC;IAAE,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CA2CnC,CAAA"}
1
+ {"version":3,"file":"fetchLender.d.ts","sourceRoot":"","sources":["../../src/lending/fetchLender.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAWnE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAG/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAwD1C,eAAO,MAAM,mBAAmB,GAC9B,SAAS,MAAM,EACf,SAAS,MAAM,EAAE,EACjB,QAAQ;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,EACnC,kBAAkB,gBAAgB,EAClC,gBAAgB,sBAAsB,EACtC,YAAW,MAAM,OAAO,CAAC,gBAAgB,CAA6B,KACrE,OAAO,CAAC;IAAE,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CA8CnC,CAAA"}
@@ -34,14 +34,14 @@ function buildLenderCall(chainId, lender) {
34
34
  return buildInitStyleLenderReserveCall(chainId, lender);
35
35
  return buildCompoundV3StyleLenderReserveCall(chainId, lender);
36
36
  }
37
- function getLenderDataConverter(lender, chainId, prices, additionalYields) {
37
+ function getLenderDataConverter(lender, chainId, prices, additionalYields, tokenList = {}) {
38
38
  if (isAaveV2Type(lender))
39
- return getAaveV2ReservesDataConverter(lender, chainId, prices, additionalYields);
39
+ return getAaveV2ReservesDataConverter(lender, chainId, prices, additionalYields, tokenList);
40
40
  if (isAaveV3Type(lender))
41
- return getAaveV3ReservesDataConverter(lender, chainId, prices, additionalYields);
41
+ return getAaveV3ReservesDataConverter(lender, chainId, prices, additionalYields, tokenList);
42
42
  if (isInit(lender))
43
- return getInitReservesDataConverter(lender, chainId, prices, additionalYields);
44
- return getCompoundV3ReservesDataConverter(lender, chainId, prices, additionalYields);
43
+ return getInitReservesDataConverter(lender, chainId, prices, additionalYields, tokenList);
44
+ return getCompoundV3ReservesDataConverter(lender, chainId, prices, additionalYields, tokenList);
45
45
  }
46
46
  const getAbi = (lender) => {
47
47
  if (isAaveV2Type(lender))
@@ -75,7 +75,7 @@ const getAbi = (lender) => {
75
75
  return InitLensAbi;
76
76
  return [];
77
77
  };
78
- export const getLenderPublicData = async (chainId, lenders, prices, additionalYields, multicallRetry) => {
78
+ export const getLenderPublicData = async (chainId, lenders, prices, additionalYields, multicallRetry, tokenList = async () => { return {}; }) => {
79
79
  let calls = [];
80
80
  for (const lender of lenders) {
81
81
  const abi = getAbi(lender);
@@ -84,12 +84,16 @@ export const getLenderPublicData = async (chainId, lenders, prices, additionalYi
84
84
  // @ts-ignore
85
85
  calls = [...calls, ...mappedCalls];
86
86
  }
87
- const rawResults = await multicallRetry(chainId, calls.map((call) => call.call), calls.map((call) => call.abi));
87
+ /** fetch list and on-chainData */
88
+ const [rawResults, list] = await Promise.all([
89
+ multicallRetry(chainId, calls.map((call) => call.call), calls.map((call) => call.abi)),
90
+ await tokenList(),
91
+ ]);
88
92
  const invalidLenders = [];
89
93
  const lenderData = {};
90
94
  let currentSlice = 0;
91
95
  for (const lender of lenders) {
92
- const [converter, sliceLength] = getLenderDataConverter(lender, chainId, prices, additionalYields);
96
+ const [converter, sliceLength] = getLenderDataConverter(lender, chainId, prices, additionalYields, list);
93
97
  const data = rawResults.slice(currentSlice, currentSlice + sliceLength);
94
98
  const convertedData = converter(data);
95
99
  if (!convertedData) {
@@ -0,0 +1,8 @@
1
+ import { AdditionalYields, MulticallRetryFunction } from '../types';
2
+ import { Lender } from '@1delta/asset-registry';
3
+ export declare const getLenderPublicDataAll: (chainId: string, lenders: Lender[], prices: {
4
+ [asset: string]: number;
5
+ }, additionalYields: AdditionalYields, multicallRetry: MulticallRetryFunction) => Promise<{
6
+ [lender: string]: any;
7
+ }>;
8
+ //# sourceMappingURL=fetchLenderAll.d.ts.map