@1delta/margin-fetcher 0.0.31 → 0.0.33

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 (210) hide show
  1. package/dist/abis/oracle/UniV3.d.ts +50 -0
  2. package/dist/abis/oracle/UniV3.d.ts.map +1 -0
  3. package/dist/abis/oracle/UniV3.js +63 -0
  4. package/dist/assets/index.d.ts +3 -8
  5. package/dist/assets/index.d.ts.map +1 -1
  6. package/dist/assets/index.js +12 -30
  7. package/dist/assets/liquidityThresholds.d.ts.map +1 -1
  8. package/dist/assets/liquidityThresholds.js +3 -3
  9. package/dist/flash-liquidity/assets.d.ts.map +1 -1
  10. package/dist/flash-liquidity/assets.js +22 -13
  11. package/dist/flash-liquidity/fetchLiquidity.d.ts +2 -2
  12. package/dist/flash-liquidity/fetchLiquidity.d.ts.map +1 -1
  13. package/dist/flash-liquidity/fetchLiquidity.js +11 -10
  14. package/dist/flash-liquidity/utils.d.ts +3 -2
  15. package/dist/flash-liquidity/utils.d.ts.map +1 -1
  16. package/dist/flash-liquidity/utils.js +5 -5
  17. package/dist/lending/aave-v2-type/misc.d.ts +1 -1
  18. package/dist/lending/aave-v2-type/misc.d.ts.map +1 -1
  19. package/dist/lending/aave-v2-type/misc.js +7 -3
  20. package/dist/lending/aave-v2-type/publicCallBuild.d.ts +1 -1
  21. package/dist/lending/aave-v2-type/publicCallBuild.d.ts.map +1 -1
  22. package/dist/lending/aave-v2-type/publicCallBuild.js +11 -11
  23. package/dist/lending/aave-v2-type/publicCallParse.d.ts +1 -1
  24. package/dist/lending/aave-v2-type/publicCallParse.d.ts.map +1 -1
  25. package/dist/lending/aave-v2-type/publicCallParse.js +5 -5
  26. package/dist/lending/aave-v3-type/publicCallBuild.d.ts +1 -1
  27. package/dist/lending/aave-v3-type/publicCallBuild.d.ts.map +1 -1
  28. package/dist/lending/aave-v3-type/publicCallBuild.js +1 -1
  29. package/dist/lending/aave-v3-type/publicCallParse.d.ts +1 -1
  30. package/dist/lending/aave-v3-type/publicCallParse.d.ts.map +1 -1
  31. package/dist/lending/aave-v3-type/publicCallParse.js +5 -14
  32. package/dist/lending/addresses/aave.js +1 -1
  33. package/dist/lending/addresses/aaveV2.js +1 -1
  34. package/dist/lending/addresses/aurelius.js +1 -1
  35. package/dist/lending/addresses/compoundV3.d.ts +1 -1
  36. package/dist/lending/addresses/compoundV3.d.ts.map +1 -1
  37. package/dist/lending/addresses/compoundV3.js +5 -4
  38. package/dist/lending/addresses/contracts.d.ts +1 -1
  39. package/dist/lending/addresses/contracts.d.ts.map +1 -1
  40. package/dist/lending/addresses/contracts.js +1 -1
  41. package/dist/lending/addresses/hana.js +1 -1
  42. package/dist/lending/addresses/init.js +1 -1
  43. package/dist/lending/addresses/lendle.js +1 -1
  44. package/dist/lending/addresses/meridian.js +1 -1
  45. package/dist/lending/addresses/takotako.js +1 -1
  46. package/dist/lending/compound-v3/publicCallBuild.d.ts +1 -1
  47. package/dist/lending/compound-v3/publicCallBuild.d.ts.map +1 -1
  48. package/dist/lending/compound-v3/publicCallParse.d.ts +1 -1
  49. package/dist/lending/compound-v3/publicCallParse.d.ts.map +1 -1
  50. package/dist/lending/compound-v3/publicCallParse.js +3 -9
  51. package/dist/lending/fetchLender.d.ts +1 -1
  52. package/dist/lending/fetchLender.d.ts.map +1 -1
  53. package/dist/lending/fetchLender.js +1 -1
  54. package/dist/lending/fetchLenderAll.d.ts +1 -1
  55. package/dist/lending/fetchLenderAll.d.ts.map +1 -1
  56. package/dist/lending/fetchLenderAll.js +1 -1
  57. package/dist/lending/fetchLenderExt.d.ts +1 -1
  58. package/dist/lending/fetchLenderExt.d.ts.map +1 -1
  59. package/dist/lending/index.d.ts +1 -0
  60. package/dist/lending/index.d.ts.map +1 -1
  61. package/dist/lending/index.js +1 -0
  62. package/dist/lending/init/publicCallBuild.d.ts +1 -1
  63. package/dist/lending/init/publicCallBuild.d.ts.map +1 -1
  64. package/dist/lending/init/publicCallParse.d.ts +4 -4
  65. package/dist/lending/init/publicCallParse.d.ts.map +1 -1
  66. package/dist/lending/init/publicCallParse.js +7 -7
  67. package/dist/lending/meta/index.d.ts +19 -0
  68. package/dist/lending/meta/index.d.ts.map +1 -0
  69. package/dist/lending/meta/index.js +83 -0
  70. package/dist/lending/morpho/publicCallBuild.d.ts.map +1 -1
  71. package/dist/lending/user-data/aave-v2-type/userCallBuild.d.ts +1 -1
  72. package/dist/lending/user-data/aave-v2-type/userCallBuild.d.ts.map +1 -1
  73. package/dist/lending/user-data/aave-v2-type/userCallBuild.js +1 -1
  74. package/dist/lending/user-data/aave-v2-type/userCallParse.d.ts +2 -2
  75. package/dist/lending/user-data/aave-v2-type/userCallParse.d.ts.map +1 -1
  76. package/dist/lending/user-data/aave-v2-type/userCallParse.js +44 -38
  77. package/dist/lending/user-data/aave-v3-type/userCallBuild.d.ts +1 -1
  78. package/dist/lending/user-data/aave-v3-type/userCallBuild.d.ts.map +1 -1
  79. package/dist/lending/user-data/aave-v3-type/userCallParse.d.ts +1 -1
  80. package/dist/lending/user-data/aave-v3-type/userCallParse.d.ts.map +1 -1
  81. package/dist/lending/user-data/aave-v3-type/userCallParse.js +5 -5
  82. package/dist/lending/user-data/aave-v3-type/userCallParseYldr.d.ts +2 -2
  83. package/dist/lending/user-data/aave-v3-type/userCallParseYldr.d.ts.map +1 -1
  84. package/dist/lending/user-data/aave-v3-type/userCallParseYldr.js +15 -15
  85. package/dist/lending/user-data/abis.d.ts +1 -1
  86. package/dist/lending/user-data/abis.d.ts.map +1 -1
  87. package/dist/lending/user-data/compound-v3/userCallBuild.d.ts +1 -1
  88. package/dist/lending/user-data/compound-v3/userCallBuild.d.ts.map +1 -1
  89. package/dist/lending/user-data/compound-v3/userCallParse.d.ts +1 -1
  90. package/dist/lending/user-data/compound-v3/userCallParse.d.ts.map +1 -1
  91. package/dist/lending/user-data/compound-v3/userCallParse.js +4 -4
  92. package/dist/lending/user-data/init/userCallBuild.d.ts +2 -2
  93. package/dist/lending/user-data/init/userCallBuild.d.ts.map +1 -1
  94. package/dist/lending/user-data/init/userCallBuild.js +3 -3
  95. package/dist/lending/user-data/init/userCallParse.d.ts +1 -1
  96. package/dist/lending/user-data/init/userCallParse.d.ts.map +1 -1
  97. package/dist/lending/user-data/init/userCallParse.js +4 -4
  98. package/dist/lending/user-data/morpho/userCallBuild.d.ts +1 -1
  99. package/dist/lending/user-data/morpho/userCallBuild.d.ts.map +1 -1
  100. package/dist/lending/user-data/morpho/userCallBuild.js +6 -4
  101. package/dist/lending/user-data/morpho/userCallParse.d.ts +1 -1
  102. package/dist/lending/user-data/morpho/userCallParse.d.ts.map +1 -1
  103. package/dist/lending/user-data/morpho/userCallParse.js +5 -5
  104. package/dist/lending/user-data/types.js +1 -1
  105. package/dist/lending-pairs/computeLendingPairs.d.ts.map +1 -1
  106. package/dist/lending-pairs/computeLendingPairs.js +6 -6
  107. package/dist/prices/defillama/index.d.ts.map +1 -1
  108. package/dist/prices/defillama/index.js +21 -0
  109. package/dist/prices/main-prices/addresses/api3.js +1 -1
  110. package/dist/prices/main-prices/addresses/chainlink.js +1 -1
  111. package/dist/prices/main-prices/fetchOracleData.d.ts +6 -0
  112. package/dist/prices/main-prices/fetchOracleData.d.ts.map +1 -1
  113. package/dist/prices/main-prices/fetchOracleData.js +80 -20
  114. package/dist/types/index.d.ts +8 -2
  115. package/dist/types/index.d.ts.map +1 -1
  116. package/dist/types/index.js +2 -2
  117. package/dist/utils/constants.js +1 -1
  118. package/dist/utils/index.d.ts +2 -2
  119. package/dist/utils/index.d.ts.map +1 -1
  120. package/dist/utils/index.js +29 -26
  121. package/dist/utils/parsing.d.ts +1 -1
  122. package/dist/utils/parsing.d.ts.map +1 -1
  123. package/dist/utils/parsing.js +9 -8
  124. package/dist/yields/index.d.ts.map +1 -1
  125. package/dist/yields/index.js +7 -3
  126. package/package.json +2 -2
  127. package/src/abis/oracle/UniV3.ts +63 -0
  128. package/src/assets/index.ts +26 -66
  129. package/src/assets/liquidityThresholds.ts +55 -43
  130. package/src/flash-liquidity/assets.ts +68 -44
  131. package/src/flash-liquidity/fetchLiquidity.ts +13 -14
  132. package/src/flash-liquidity/utils.ts +22 -16
  133. package/src/lending/aave-v2-type/misc.ts +7 -3
  134. package/src/lending/aave-v2-type/publicCallBuild.ts +28 -17
  135. package/src/lending/aave-v2-type/publicCallParse.ts +5 -5
  136. package/src/lending/aave-v3-type/publicCallBuild.ts +1 -1
  137. package/src/lending/aave-v3-type/publicCallParse.ts +4 -14
  138. package/src/lending/addresses/aave.ts +1 -1
  139. package/src/lending/addresses/aaveV2.ts +1 -1
  140. package/src/lending/addresses/aurelius.ts +1 -1
  141. package/src/lending/addresses/compoundV3.ts +5 -12
  142. package/src/lending/addresses/contracts.ts +1 -1
  143. package/src/lending/addresses/hana.ts +1 -1
  144. package/src/lending/addresses/init.ts +1 -1
  145. package/src/lending/addresses/lendle.ts +1 -1
  146. package/src/lending/addresses/meridian.ts +1 -1
  147. package/src/lending/addresses/takotako.ts +1 -1
  148. package/src/lending/compound-v3/publicCallBuild.ts +1 -1
  149. package/src/lending/compound-v3/publicCallParse.ts +3 -10
  150. package/src/lending/fetchLender.ts +1 -1
  151. package/src/lending/fetchLenderAll.ts +1 -1
  152. package/src/lending/fetchLenderExt.ts +1 -1
  153. package/src/lending/index.ts +1 -0
  154. package/src/lending/init/publicCallBuild.ts +1 -1
  155. package/src/lending/init/publicCallParse.ts +64 -48
  156. package/src/lending/meta/index.ts +124 -0
  157. package/src/lending/morpho/publicCallBuild.ts +0 -1
  158. package/src/lending/user-data/aave-v2-type/userCallBuild.ts +1 -1
  159. package/src/lending/user-data/aave-v2-type/userCallParse.ts +181 -122
  160. package/src/lending/user-data/aave-v3-type/userCallBuild.ts +1 -1
  161. package/src/lending/user-data/aave-v3-type/userCallParse.ts +7 -8
  162. package/src/lending/user-data/aave-v3-type/userCallParseYldr.ts +37 -34
  163. package/src/lending/user-data/abis.ts +1 -1
  164. package/src/lending/user-data/compound-v3/userCallBuild.ts +1 -1
  165. package/src/lending/user-data/compound-v3/userCallParse.ts +4 -6
  166. package/src/lending/user-data/fetchUserData.ts +1 -1
  167. package/src/lending/user-data/init/userCallBuild.ts +11 -7
  168. package/src/lending/user-data/init/userCallParse.ts +5 -5
  169. package/src/lending/user-data/morpho/userCallBuild.ts +7 -4
  170. package/src/lending/user-data/morpho/userCallParse.ts +8 -5
  171. package/src/lending/user-data/types.ts +1 -1
  172. package/src/lending-pairs/computeLendingPairs.ts +6 -12
  173. package/src/prices/defillama/index.ts +24 -0
  174. package/src/prices/main-prices/addresses/api3.ts +1 -1
  175. package/src/prices/main-prices/addresses/chainlink.ts +1 -1
  176. package/src/prices/main-prices/fetchOracleData.ts +118 -20
  177. package/src/types/index.ts +10 -4
  178. package/src/utils/constants.ts +1 -1
  179. package/src/utils/index.ts +48 -39
  180. package/src/utils/parsing.ts +37 -35
  181. package/src/yields/index.ts +7 -3
  182. package/test/flashLiquidity.test.ts +6 -6
  183. package/test/index.test.ts +1 -1
  184. package/test/lenderData.test.ts +10 -11
  185. package/test/lenderDataBasic.test.ts +1 -1
  186. package/test/mainPriceMB.test.ts +1 -1
  187. package/test/mainPrices.test.ts +16 -15
  188. package/test/morpho.test.ts +1 -1
  189. package/test/morphoPrice.test.ts +1 -1
  190. package/test/userData.test.ts +2 -1
  191. package/test/userDataAave.test.ts +1 -1
  192. package/test/userDataAaveMainnet.test.ts +1 -1
  193. package/test/userDataAll.test.ts +2 -1
  194. package/test/userDataCompound.test.ts +2 -1
  195. package/test/userDataMorpho.test.ts +2 -1
  196. package/test/userDataMorphoEthereum.test.ts +2 -1
  197. package/test/userDataMorphoKatana.test.ts +2 -1
  198. package/test/utils.ts +11 -1
  199. package/dist/lending/user-data/morpho/userCallParseNoDeploy.d.ts +0 -11
  200. package/dist/lending/user-data/morpho/userCallParseNoDeploy.d.ts.map +0 -1
  201. package/dist/lending/user-data/morpho/userCallParseNoDeploy.js +0 -112
  202. package/dist/prices/main-prices/addresses/aaveOracles.d.ts +0 -300
  203. package/dist/prices/main-prices/addresses/aaveOracles.d.ts.map +0 -1
  204. package/dist/prices/main-prices/addresses/aaveOracles.js +0 -299
  205. package/dist/prices/main-prices/addresses/morpho.d.ts +0 -11
  206. package/dist/prices/main-prices/addresses/morpho.d.ts.map +0 -1
  207. package/dist/prices/main-prices/addresses/morpho.js +0 -2554
  208. package/src/lending/user-data/morpho/userCallParseNoDeploy.ts +0 -168
  209. package/src/prices/main-prices/addresses/aaveOracles.ts +0 -299
  210. package/src/prices/main-prices/addresses/morpho.ts +0 -2563
@@ -1,22 +1,28 @@
1
- import { getAssetMeta, toGenericPriceKey } from "../assets";
2
- import { FlashLiquiditiesOnChain } from "./types";
1
+ import { toGenericPriceKey } from '../assets'
2
+ import { TokenList } from '../types'
3
+ import { FlashLiquiditiesOnChain } from './types'
3
4
 
4
- /**
5
+ /**
5
6
  * Add prices to get dollar flash liquidties
6
7
  * Ideal for de-based flash loans
7
8
  */
8
- export function attachPricesToFlashLiquidity(chainId: string, liq: FlashLiquiditiesOnChain, prices: { [k: string]: number }) {
9
+ export function attachPricesToFlashLiquidity(
10
+ chainId: string,
11
+ liq: FlashLiquiditiesOnChain,
12
+ prices: { [k: string]: number },
13
+ list: TokenList = {},
14
+ ) {
15
+ let liqCopy = { ...liq }
9
16
 
10
- let liqCopy = { ...liq }
17
+ Object.entries(liq).forEach(([asset, entry]) => {
18
+ const priceKey =
19
+ list[asset]?.assetGroup ?? toGenericPriceKey(asset, chainId)
20
+ const price = prices[priceKey] ?? 0
21
+ liqCopy[asset] = entry.map((e) => ({
22
+ ...e,
23
+ availableUSD: e.available * price,
24
+ }))
25
+ })
11
26
 
12
- Object.entries(liq).forEach(([asset, entry]) => {
13
- const priceKey = getAssetMeta(chainId, asset)?.assetGroup ?? toGenericPriceKey(asset, chainId)
14
- const price = prices[priceKey] ?? 0
15
- liqCopy[asset] = entry.map(e => ({
16
- ...e,
17
- availableUSD: e.available * price
18
- }))
19
- })
20
-
21
- return liqCopy
22
- }
27
+ return liqCopy
28
+ }
@@ -1,9 +1,13 @@
1
- import { Chain, WRAPPED_NATIVE_INFO } from "@1delta/asset-registry";
1
+ import { WRAPPED_NATIVE_INFO } from '@1delta/wnative'
2
+ import { Chain } from '@1delta/chain-registry'
2
3
 
3
- export const AURELIUS_REWARD_ASSETS = [WRAPPED_NATIVE_INFO[Chain.MANTLE], {
4
+ export const AURELIUS_REWARD_ASSETS = [
5
+ WRAPPED_NATIVE_INFO[Chain.MANTLE],
6
+ {
4
7
  chainId: Chain.MANTLE,
5
8
  address: '0x6e20E155819f0ee08d1291b0b9889b0e011b8224',
6
9
  decimals: 18,
7
10
  symbol: 'oAU',
8
11
  name: 'Aurelius Call Option Token',
9
- }]
12
+ },
13
+ ]
@@ -1,20 +1,28 @@
1
+ import { AURELIUS_REWARD_ASSETS } from './misc'
2
+ import {
3
+ getAaveAssets,
4
+ getAaveStyleProtocolTokenMap,
5
+ getAaveTypePoolDataProviderAddress,
6
+ } from '../../assets'
7
+ import { Lender } from '@1delta/lender-registry'
8
+ import { getAaveTypeIncentivesControllerAddress } from '../addresses'
1
9
 
2
- import { AURELIUS_REWARD_ASSETS } from "./misc";
3
- import { getAaveAssets, getAaveStyleProtocolTokenMap, getAaveTypePoolDataProviderAddress } from "../../assets";
4
- import { Lender } from "@1delta/asset-registry";
5
- import { getAaveTypeIncentivesControllerAddress } from "../addresses";
6
-
7
-
8
- export const buildAaveV2StyleLenderReserveCall = (chainId: string, lender: Lender) => {
10
+ export const buildAaveV2StyleLenderReserveCall = (
11
+ chainId: string,
12
+ lender: Lender,
13
+ ) => {
9
14
  const providerAddress = getAaveTypePoolDataProviderAddress(chainId, lender)
10
15
  const underlyingTokensArray = getAaveAssets(chainId, lender)
11
16
  switch (lender) {
12
17
  case Lender.AURELIUS: {
13
18
  const aaveprotocolTokens = getAaveStyleProtocolTokenMap(chainId, lender)
14
- const incentivesController = getAaveTypeIncentivesControllerAddress(chainId, lender)
15
- const [reward0, reward1] = AURELIUS_REWARD_ASSETS.map(t => t.address)
19
+ const incentivesController = getAaveTypeIncentivesControllerAddress(
20
+ chainId,
21
+ lender,
22
+ )
23
+ const [reward0, reward1] = AURELIUS_REWARD_ASSETS.map((t) => t.address)
16
24
  return [
17
- ...underlyingTokensArray.flatMap(asset => [
25
+ ...underlyingTokensArray.flatMap((asset) => [
18
26
  {
19
27
  address: providerAddress,
20
28
  name: 'getReserveData',
@@ -49,10 +57,13 @@ export const buildAaveV2StyleLenderReserveCall = (chainId: string, lender: Lende
49
57
  ]
50
58
  }
51
59
  case Lender.LENDLE: {
52
- const incentivesController = getAaveTypeIncentivesControllerAddress(chainId, lender)
60
+ const incentivesController = getAaveTypeIncentivesControllerAddress(
61
+ chainId,
62
+ lender,
63
+ )
53
64
  const aaveprotocolTokens = getAaveStyleProtocolTokenMap(chainId, lender)
54
65
  return [
55
- ...underlyingTokensArray.flatMap(asset => [
66
+ ...underlyingTokensArray.flatMap((asset) => [
56
67
  {
57
68
  address: providerAddress,
58
69
  name: 'getReserveData',
@@ -72,23 +83,23 @@ export const buildAaveV2StyleLenderReserveCall = (chainId: string, lender: Lende
72
83
  address: incentivesController,
73
84
  name: 'poolInfo',
74
85
  params: [aaveprotocolTokens[asset].vToken],
75
- }
86
+ },
76
87
  ]),
77
88
  {
78
89
  address: incentivesController,
79
90
  name: 'rewardsPerSecond',
80
- params: []
91
+ params: [],
81
92
  },
82
93
  {
83
94
  address: incentivesController,
84
95
  name: 'totalAllocPoint',
85
- params: []
96
+ params: [],
86
97
  },
87
98
  ]
88
99
  }
89
100
  default:
90
101
  return [
91
- ...underlyingTokensArray.flatMap(tk => [
102
+ ...underlyingTokensArray.flatMap((tk) => [
92
103
  {
93
104
  address: providerAddress,
94
105
  name: 'getReserveData',
@@ -102,4 +113,4 @@ export const buildAaveV2StyleLenderReserveCall = (chainId: string, lender: Lende
102
113
  ]),
103
114
  ]
104
115
  }
105
- }
116
+ }
@@ -1,6 +1,6 @@
1
1
 
2
- import { Lender } from "@1delta/asset-registry";
3
- import { getAaveAssets, getAssetMeta, LENDER_MODE_NO_MODE, toGenericPriceKey, toOracleKey } from "../../assets";
2
+ import { Lender } from "@1delta/lender-registry";
3
+ import { getAaveAssets, LENDER_MODE_NO_MODE, toGenericPriceKey, toOracleKey } from "../../assets";
4
4
  import { BPS, convertRateToApr, formatAaveRawApyToApr, parseRawAmount } from "../../utils/parsing";
5
5
  import {
6
6
  AaveV2GeneralPublicResponse,
@@ -41,7 +41,7 @@ export const getAaveV2ReservesDataConverter = (
41
41
  const [, emission0PerSecondDebt, ,] = data[i * 6 + 4]
42
42
  const [, emission1PerSecondDebt, ,] = data[i * 6 + 5]
43
43
 
44
- const assetMeta = tokenList[asset] ?? { ...getAssetMeta(chainId, asset), address: asset }
44
+ const assetMeta = tokenList[asset]
45
45
  const decimals = assetMeta?.decimals ?? 18
46
46
  const totalStableDebt = parseRawAmount(reserveData?.[AaveV2TypeGetReserveDataIndexes.totalStableDebt]?.toString(), decimals)
47
47
  const totalVariableDebt = parseRawAmount(reserveData?.[AaveV2TypeGetReserveDataIndexes.totalVariableDebt]?.toString(), decimals)
@@ -144,7 +144,7 @@ export const getAaveV2ReservesDataConverter = (
144
144
  const borrowRewards = Number(data?.[borrowRewardIndex]?.[AaveV2TypeIncentivesControllerPoolInfoIndexes.allocPoint].toString()) / totalAllocPoint * rewardsPerSecond
145
145
 
146
146
 
147
- const assetMeta = tokenList[asset] ?? { ...getAssetMeta(chainId, asset), address: asset }
147
+ const assetMeta = tokenList[asset]
148
148
  const decimals = assetMeta?.decimals ?? 18
149
149
 
150
150
  const totalStableDebt = parseRawAmount(reserveData?.[AaveV2TypeGetReserveDataIndexes.totalStableDebt]?.toString(), decimals)
@@ -231,7 +231,7 @@ export const getAaveV2ReservesDataConverter = (
231
231
  const reserveData = data[i * 2]
232
232
  const configData = data[i * 2 + 1]
233
233
 
234
- const assetMeta = tokenList[asset] ?? { ...getAssetMeta(chainId, asset), address: asset }
234
+ const assetMeta = tokenList[asset]
235
235
  const decimals = assetMeta?.decimals ?? 18
236
236
 
237
237
  const totalStableDebt = parseRawAmount(reserveData?.[AaveV2TypeGetReserveDataIndexes.totalStableDebt]?.toString(), decimals)
@@ -1,4 +1,4 @@
1
- import { Lender } from '@1delta/asset-registry'
1
+ import { Lender } from '@1delta/lender-registry'
2
2
  import { Call } from '../../utils/multicall'
3
3
  import {
4
4
  getAaveAssets,
@@ -8,10 +8,9 @@ import {
8
8
  import { AAVE_V3_EMODES } from './publicCallBuild'
9
9
  import { AdditionalYields } from '../../types'
10
10
  import { BPS, formatAaveRawApyToApr, parseRawAmount } from '../../utils/parsing'
11
- import { Lender } from '@1delta/asset-registry'
11
+ import { Lender } from '@1delta/lender-registry'
12
12
  import {
13
13
  getAaveAssets,
14
- getAssetMeta,
15
14
  LENDER_MODE_NO_MODE,
16
15
  toGenericPriceKey,
17
16
  toOracleKey,
@@ -85,10 +84,7 @@ export const getAaveV3ReservesDataConverter = (
85
84
  const debtCeiling = data[i * 6 + 4]
86
85
  const reserveEMode = data[i * 6 + 5]
87
86
 
88
- const assetMeta = tokenList[asset] ?? {
89
- ...getAssetMeta(chainId, asset),
90
- address: asset,
91
- }
87
+ const assetMeta = tokenList[asset]
92
88
 
93
89
  const decimals = assetMeta?.decimals ?? 18
94
90
 
@@ -281,10 +277,7 @@ export function parseYLDRCall(
281
277
  const reserveData = data[i * 2]
282
278
  const configData = data[i * 2 + 1]
283
279
 
284
- const assetMeta = tokenList[asset] ?? {
285
- ...getAssetMeta(chainId, asset),
286
- address: asset,
287
- }
280
+ const assetMeta = tokenList[asset]
288
281
  const decimals = assetMeta?.decimals ?? 18
289
282
 
290
283
  const totalVariableDebt = parseRawAmount(
@@ -445,10 +438,7 @@ function parseAave32(
445
438
  const reserveCaps = data[i * 5 + 3]
446
439
  const debtCeiling = data[i * 5 + 4]
447
440
 
448
- const assetMeta = tokenList[asset] ?? {
449
- ...getAssetMeta(chainId, asset),
450
- address: asset,
451
- }
441
+ const assetMeta = tokenList[asset]
452
442
 
453
443
  const decimals = assetMeta?.decimals ?? 18
454
444
  const totalDeposits = parseRawAmount(
@@ -1,4 +1,4 @@
1
- import { Chain } from "@1delta/asset-registry";
1
+ import { Chain } from "@1delta/chain-registry";
2
2
 
3
3
 
4
4
  export const addressesAaveCore = {
@@ -1,4 +1,4 @@
1
- import { Chain } from "@1delta/asset-registry";
1
+ import { Chain } from "@1delta/chain-registry";
2
2
 
3
3
 
4
4
  export const addressesAaveV2Core = {
@@ -1,4 +1,4 @@
1
- import { Chain } from "@1delta/asset-registry";
1
+ import { Chain } from "@1delta/chain-registry";
2
2
 
3
3
  export const addressesAureliusCore = {
4
4
  AaveOracle: {
@@ -1,16 +1,12 @@
1
- import {
2
- Chain,
3
- COMETS_PER_CHAIN_MAP,
4
- COMPOUND_BASE_TOKENS,
5
- Lender,
6
- SWAYLEND_BASE_TOKENS,
7
- } from '@1delta/asset-registry'
1
+ import { Chain } from '@1delta/chain-registry'
2
+ import { Lender } from '@1delta/lender-registry'
3
+ import { compoundV3BaseData, compoundV3Pools } from '@1delta/data-sdk'
8
4
 
9
5
  export function getCompoundV3CometAddress(
10
6
  chainId: string,
11
7
  lender = Lender.COMPOUND_V3_USDCE,
12
8
  ): string | undefined {
13
- return COMETS_PER_CHAIN_MAP[chainId]?.[lender]
9
+ return compoundV3Pools()?.[chainId]?.[lender]
14
10
  }
15
11
 
16
12
  export function getCompoundV3CometRewardsAddress(chainId: string) {
@@ -50,8 +46,5 @@ export function getCompoundV3BaseAsset(
50
46
  lender: Lender | string,
51
47
  chainId: string,
52
48
  ) {
53
- return (
54
- COMPOUND_BASE_TOKENS[lender]?.[chainId] ??
55
- SWAYLEND_BASE_TOKENS[lender]?.[chainId]
56
- )
49
+ return compoundV3BaseData()?.[lender]?.[chainId]
57
50
  }
@@ -5,7 +5,7 @@ import { addressesAureliusCore } from "./aurelius";
5
5
  import { addressesMeridianCore } from "./meridian";
6
6
  import { addressesTakoTakoCore } from "./takotako";
7
7
  import { zeroAddress } from "viem";
8
- import { Lender } from "@1delta/asset-registry";
8
+ import { Lender } from "@1delta/lender-registry";
9
9
 
10
10
  export function getAaveTypeOracleAddress(chainId: string, lender: Lender) {
11
11
  switch (lender) {
@@ -1,4 +1,4 @@
1
- import { Chain } from "@1delta/asset-registry";
1
+ import { Chain } from "@1delta/chain-registry";
2
2
 
3
3
  export const addressesHanaCore = {
4
4
  AaveOracle: {
@@ -1,4 +1,4 @@
1
- import { Chain } from "@1delta/asset-registry"
1
+ import { Chain } from "@1delta/chain-registry"
2
2
 
3
3
  export function getInitPosManagerAddress(chainId: string) {
4
4
  // @ts-ignore
@@ -1,4 +1,4 @@
1
- import { Chain } from "@1delta/asset-registry";
1
+ import { Chain } from "@1delta/chain-registry";
2
2
 
3
3
  export const addressesLendleCore = {
4
4
  AaveOracle: {
@@ -1,4 +1,4 @@
1
- import { Chain } from "@1delta/asset-registry";
1
+ import { Chain } from "@1delta/chain-registry";
2
2
 
3
3
  export const addressesMeridianCore = {
4
4
  AaveOracle: {
@@ -1,4 +1,4 @@
1
- import { Chain } from "@1delta/asset-registry";
1
+ import { Chain } from "@1delta/chain-registry";
2
2
 
3
3
 
4
4
  export const addressesTakoTakoCore = {
@@ -1,4 +1,4 @@
1
- import { Lender } from "@1delta/asset-registry"
1
+ import { Lender } from '@1delta/lender-registry'
2
2
  import { getCompoundV3Assets } from "../../assets"
3
3
  import { getCompoundV3BaseAsset, getCompoundV3CometAddress, getCompoundV3CometLens } from "../addresses/compoundV3"
4
4
  import { Call } from "../../utils/multicall"
@@ -1,11 +1,10 @@
1
- import { Lender } from '@1delta/asset-registry'
1
+ import { Lender } from '@1delta/lender-registry'
2
2
  import { AdditionalYields } from '../../types'
3
3
  import {
4
4
  CometInterestRateIndexes,
5
5
  CompoundV3GeneralPublicResponse,
6
6
  } from './types'
7
7
  import {
8
- getAssetMeta,
9
8
  getCompoundV3Assets,
10
9
  LENDER_MODE_NO_MODE,
11
10
  toGenericPriceKey,
@@ -44,10 +43,7 @@ export const getCompoundV3ReservesDataConverter = (
44
43
  const asset = tokensNoBase[i]
45
44
  const resultsAssetInfo = data[i * 2]
46
45
  const resultsTotals = data[i * 2 + 1]
47
- const assetMeta = tokenList[asset] ?? {
48
- ...getAssetMeta(chainId, asset),
49
- address: asset,
50
- }
46
+ const assetMeta = tokenList[asset]
51
47
  const decimals = assetMeta?.decimals ?? 18
52
48
  const totals = parseRawAmount(resultsTotals[0], decimals)
53
49
  const oracleKey =
@@ -103,10 +99,7 @@ export const getCompoundV3ReservesDataConverter = (
103
99
  }
104
100
  }
105
101
 
106
- const baseMeta = tokenList[baseAssetData.baseAsset] ?? {
107
- ...getAssetMeta(chainId, baseAssetData.baseAsset),
108
- address: baseAssetData.baseAsset,
109
- }
102
+ const baseMeta = tokenList[baseAssetData.baseAsset]
110
103
 
111
104
  // parse data for rewards calculation
112
105
  const decimals = baseMeta?.decimals ?? 18
@@ -34,7 +34,7 @@ import { getInitReservesDataConverter } from './init/publicCallParse'
34
34
  import { getCompoundV3ReservesDataConverter } from './compound-v3/publicCallParse'
35
35
  import { AavePoolLegacyAbi } from '../abis/aave-v3/AavePoolLegacy'
36
36
  import { AavePoolDataProviderLegacyAbi } from '../abis/aave-v3/AavePoolDataProviderLegacy'
37
- import { Chain, Lender } from '@1delta/asset-registry'
37
+ import { Lender } from '@1delta/lender-registry'
38
38
  import { Call } from 'viem'
39
39
  import { YLDRProtocolDataProviderAbi } from '../abis/aave-v2/YLDR'
40
40
  import { GenericTokenList } from './types'
@@ -1,5 +1,5 @@
1
1
  import { AdditionalYields, MulticallRetryFunction } from '../types'
2
- import { Lender } from '@1delta/asset-registry'
2
+ import { Lender } from '@1delta/lender-registry'
3
3
  import { getLenderPublicData } from './fetchLender'
4
4
  import { getLenderPublicDataViaApi } from './fetchLenderExt'
5
5
  import { GenericTokenList } from './types'
@@ -1,6 +1,6 @@
1
1
  import { isMorphoType, isMultiMarket } from '../utils'
2
2
  import { AdditionalYields } from '../types'
3
- import { Lender } from '@1delta/asset-registry'
3
+ import { Lender } from '@1delta/lender-registry'
4
4
  import { GenericTokenList } from './types'
5
5
  import { fetchMorphoMarkets } from './morpho/fetchPublic'
6
6
  import { convertMarketsToMorphoResponse } from './morpho/convertPublic'
@@ -3,3 +3,4 @@ export * from "./fetchLenderExt"
3
3
  export * from "./fetchLenderAll"
4
4
  export * from "./user-data"
5
5
  export * from "./types"
6
+ export * from "./meta"
@@ -1,4 +1,4 @@
1
- import { Lender } from "@1delta/asset-registry"
1
+ import { Lender } from '@1delta/lender-registry'
2
2
  import { Call } from "../../utils/multicall"
3
3
  import { getInitLensAddress } from "../addresses/init"
4
4
 
@@ -1,10 +1,10 @@
1
- import { InitGeneralPublicResponse } from "./types";
2
- import { AdditionalYields } from "../../types";
3
- import { INIT_MODES } from "./publicCallBuild";
4
- import { getAssetMeta, toGenericPriceKey, toOracleKey } from "../../assets";
5
- import { convertRateToApr, parseRawAmount } from "../../utils/parsing";
6
- import { Lender } from "@1delta/asset-registry";
7
- import { GenericTokenList } from "../types";
1
+ import { InitGeneralPublicResponse } from './types'
2
+ import { AdditionalYields } from '../../types'
3
+ import { INIT_MODES } from './publicCallBuild'
4
+ import { toGenericPriceKey, toOracleKey } from '../../assets'
5
+ import { convertRateToApr, parseRawAmount } from '../../utils/parsing'
6
+ import { Lender } from '@1delta/lender-registry'
7
+ import { GenericTokenList } from '../types'
8
8
 
9
9
  export const INIT_EMODE_LABELS: { [mode: number]: string } = {
10
10
  [1]: 'Default',
@@ -20,7 +20,7 @@ export const getInitReservesDataConverter = (
20
20
  chainId: string,
21
21
  prices: { [asset: string]: number },
22
22
  additionalYields: AdditionalYields,
23
- tokenList: GenericTokenList = {}
23
+ tokenList: GenericTokenList = {},
24
24
  ): [(data: any[]) => InitGeneralPublicResponse | undefined, number] => {
25
25
  const expectedNumberOfCalls = INIT_MODES.length
26
26
  return [
@@ -30,42 +30,55 @@ export const getInitReservesDataConverter = (
30
30
  }
31
31
  const modeOne = 0
32
32
  let result = Object.assign(
33
- {}, ...data[modeOne]?.map(
34
- (dat: any) => {
35
- const asset = dat?.underlying.toLowerCase()
36
- const meta = tokenList[asset] ?? { ...getAssetMeta(chainId, asset), address: asset }
37
- const totalDeposits = parseRawAmount(dat?.totalSupply.toString(), meta?.decimals)
38
- const totalDebt = parseRawAmount(dat?.totalDebt.toString(), meta.decimals)
39
- const oracleKey = toOracleKey(meta?.assetGroup!) ?? toGenericPriceKey(asset, chainId)
40
- const price = prices[oracleKey]
41
- const liquidity = Number(totalDeposits) - Number(totalDebt)
42
- return {
43
- [asset]: {
44
- poolId: asset,
45
- underlying: asset,
46
- asset: meta,
47
- borrowCap: parseRawAmount(dat?.borrowCap.toString(), meta.decimals),
48
- canBurn: Boolean(dat?.canBurn),
49
- canFlash: Boolean(dat?.canFlash),
50
- canMint: Boolean(dat?.canMint),
51
- canRepay: Boolean(dat?.canRepay),
52
- totalDeposits,
53
- totalDebt,
54
- totalDepositsUSD: price * Number(totalDeposits),
55
- totalDebtUSD: price * Number(totalDebt),
56
- totalLiquidity: liquidity,
57
- totalLiquidityUSD: liquidity * price,
58
- depositRate: convertRateToApr(Number(parseRawAmount(dat?.supplyRate.toString(), 18))),
59
- variableBorrowRate: convertRateToApr(Number(parseRawAmount(dat?.borrowRate.toString(), 18))),
60
- stableBorrowRate: 0,
61
- stakingYield: additionalYields.intrinsicYields[oracleKey] ?? 0,
62
- rewards: {},
63
- config: {},
64
- borrowingEnabled: totalDebt !== "0"
65
- }
66
- }
33
+ {},
34
+ ...data[modeOne]?.map((dat: any) => {
35
+ const asset = dat?.underlying.toLowerCase()
36
+ const meta = tokenList[asset]
37
+ const totalDeposits = parseRawAmount(
38
+ dat?.totalSupply.toString(),
39
+ meta?.decimals,
40
+ )
41
+ const totalDebt = parseRawAmount(
42
+ dat?.totalDebt.toString(),
43
+ meta.decimals,
44
+ )
45
+ const oracleKey =
46
+ toOracleKey(meta?.assetGroup!) ?? toGenericPriceKey(asset, chainId)
47
+ const price = prices[oracleKey]
48
+ const liquidity = Number(totalDeposits) - Number(totalDebt)
49
+ return {
50
+ [asset]: {
51
+ poolId: asset,
52
+ underlying: asset,
53
+ asset: meta,
54
+ borrowCap: parseRawAmount(
55
+ dat?.borrowCap.toString(),
56
+ meta.decimals,
57
+ ),
58
+ canBurn: Boolean(dat?.canBurn),
59
+ canFlash: Boolean(dat?.canFlash),
60
+ canMint: Boolean(dat?.canMint),
61
+ canRepay: Boolean(dat?.canRepay),
62
+ totalDeposits,
63
+ totalDebt,
64
+ totalDepositsUSD: price * Number(totalDeposits),
65
+ totalDebtUSD: price * Number(totalDebt),
66
+ totalLiquidity: liquidity,
67
+ totalLiquidityUSD: liquidity * price,
68
+ depositRate: convertRateToApr(
69
+ Number(parseRawAmount(dat?.supplyRate.toString(), 18)),
70
+ ),
71
+ variableBorrowRate: convertRateToApr(
72
+ Number(parseRawAmount(dat?.borrowRate.toString(), 18)),
73
+ ),
74
+ stableBorrowRate: 0,
75
+ stakingYield: additionalYields.intrinsicYields[oracleKey] ?? 0,
76
+ rewards: {},
77
+ config: {},
78
+ borrowingEnabled: totalDebt !== '0',
79
+ },
67
80
  }
68
- )
81
+ }),
69
82
  )
70
83
 
71
84
  let eModes: any = {}
@@ -79,15 +92,18 @@ export const getInitReservesDataConverter = (
79
92
  borrowCollateralFactor: cf,
80
93
  collateralFactor: cf,
81
94
  borrowFactor: parseRawAmount(multicallData.borrowFactor, 18),
82
- maxHealthAfterLiq: parseRawAmount(multicallData.maxHealthAfterLiq, 18),
95
+ maxHealthAfterLiq: parseRawAmount(
96
+ multicallData.maxHealthAfterLiq,
97
+ 18,
98
+ ),
83
99
  }
84
100
  if (!eModes[mode]) eModes[mode] = modeData
85
101
  result[asset].config[mode] = modeData
86
- });
87
- });
102
+ })
103
+ })
88
104
 
89
105
  return { data: result, eModes, chainId }
90
106
  },
91
- expectedNumberOfCalls
107
+ expectedNumberOfCalls,
92
108
  ]
93
- }
109
+ }