@1delta/margin-fetcher 0.0.32 → 0.0.34

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 (214) 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 -7
  5. package/dist/assets/index.d.ts.map +1 -1
  6. package/dist/assets/index.js +12 -25
  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 -3
  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 +3 -3
  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 +9 -12
  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 +3 -3
  78. package/dist/lending/user-data/aave-v3-type/userCallBuild.d.ts.map +1 -1
  79. package/dist/lending/user-data/aave-v3-type/userCallBuild.js +6 -8
  80. package/dist/lending/user-data/aave-v3-type/userCallParse.d.ts +1 -1
  81. package/dist/lending/user-data/aave-v3-type/userCallParse.d.ts.map +1 -1
  82. package/dist/lending/user-data/aave-v3-type/userCallParse.js +5 -5
  83. package/dist/lending/user-data/aave-v3-type/userCallParseYldr.d.ts +2 -2
  84. package/dist/lending/user-data/aave-v3-type/userCallParseYldr.d.ts.map +1 -1
  85. package/dist/lending/user-data/aave-v3-type/userCallParseYldr.js +15 -15
  86. package/dist/lending/user-data/abis.d.ts +1 -1
  87. package/dist/lending/user-data/abis.d.ts.map +1 -1
  88. package/dist/lending/user-data/compound-v3/userCallBuild.d.ts +2 -2
  89. package/dist/lending/user-data/compound-v3/userCallBuild.d.ts.map +1 -1
  90. package/dist/lending/user-data/compound-v3/userCallBuild.js +2 -2
  91. package/dist/lending/user-data/compound-v3/userCallParse.d.ts +1 -1
  92. package/dist/lending/user-data/compound-v3/userCallParse.d.ts.map +1 -1
  93. package/dist/lending/user-data/compound-v3/userCallParse.js +4 -4
  94. package/dist/lending/user-data/fetchUserData.d.ts +1 -0
  95. package/dist/lending/user-data/fetchUserData.d.ts.map +1 -1
  96. package/dist/lending/user-data/fetchUserData.js +6 -5
  97. package/dist/lending/user-data/init/userCallBuild.d.ts +2 -2
  98. package/dist/lending/user-data/init/userCallBuild.d.ts.map +1 -1
  99. package/dist/lending/user-data/init/userCallBuild.js +3 -3
  100. package/dist/lending/user-data/init/userCallParse.d.ts +1 -1
  101. package/dist/lending/user-data/init/userCallParse.d.ts.map +1 -1
  102. package/dist/lending/user-data/init/userCallParse.js +4 -4
  103. package/dist/lending/user-data/morpho/userCallBuild.d.ts +1 -1
  104. package/dist/lending/user-data/morpho/userCallBuild.d.ts.map +1 -1
  105. package/dist/lending/user-data/morpho/userCallBuild.js +6 -4
  106. package/dist/lending/user-data/morpho/userCallParse.d.ts +1 -1
  107. package/dist/lending/user-data/morpho/userCallParse.d.ts.map +1 -1
  108. package/dist/lending/user-data/morpho/userCallParse.js +5 -5
  109. package/dist/lending/user-data/types.d.ts +2 -0
  110. package/dist/lending/user-data/types.d.ts.map +1 -1
  111. package/dist/lending/user-data/types.js +7 -3
  112. package/dist/lending-pairs/computeLendingPairs.d.ts.map +1 -1
  113. package/dist/lending-pairs/computeLendingPairs.js +6 -6
  114. package/dist/prices/main-prices/addresses/api3.js +1 -1
  115. package/dist/prices/main-prices/addresses/chainlink.js +1 -1
  116. package/dist/prices/main-prices/fetchOracleData.d.ts +6 -0
  117. package/dist/prices/main-prices/fetchOracleData.d.ts.map +1 -1
  118. package/dist/prices/main-prices/fetchOracleData.js +78 -20
  119. package/dist/types/index.d.ts +8 -2
  120. package/dist/types/index.d.ts.map +1 -1
  121. package/dist/types/index.js +2 -2
  122. package/dist/utils/constants.js +1 -1
  123. package/dist/utils/index.d.ts +2 -3
  124. package/dist/utils/index.d.ts.map +1 -1
  125. package/dist/utils/index.js +11 -17
  126. package/dist/utils/parsing.d.ts +1 -1
  127. package/dist/utils/parsing.d.ts.map +1 -1
  128. package/dist/utils/parsing.js +9 -8
  129. package/dist/yields/index.d.ts.map +1 -1
  130. package/dist/yields/index.js +3 -2
  131. package/package.json +2 -2
  132. package/src/abis/oracle/UniV3.ts +63 -0
  133. package/src/assets/index.ts +26 -56
  134. package/src/assets/liquidityThresholds.ts +55 -43
  135. package/src/flash-liquidity/assets.ts +68 -44
  136. package/src/flash-liquidity/fetchLiquidity.ts +13 -14
  137. package/src/flash-liquidity/utils.ts +22 -16
  138. package/src/lending/aave-v2-type/misc.ts +7 -3
  139. package/src/lending/aave-v2-type/publicCallBuild.ts +28 -17
  140. package/src/lending/aave-v2-type/publicCallParse.ts +5 -5
  141. package/src/lending/aave-v3-type/publicCallBuild.ts +1 -1
  142. package/src/lending/aave-v3-type/publicCallParse.ts +4 -14
  143. package/src/lending/addresses/aave.ts +1 -1
  144. package/src/lending/addresses/aaveV2.ts +1 -1
  145. package/src/lending/addresses/aurelius.ts +1 -1
  146. package/src/lending/addresses/compoundV3.ts +5 -8
  147. package/src/lending/addresses/contracts.ts +1 -1
  148. package/src/lending/addresses/hana.ts +1 -1
  149. package/src/lending/addresses/init.ts +1 -1
  150. package/src/lending/addresses/lendle.ts +1 -1
  151. package/src/lending/addresses/meridian.ts +1 -1
  152. package/src/lending/addresses/takotako.ts +1 -1
  153. package/src/lending/compound-v3/publicCallBuild.ts +1 -1
  154. package/src/lending/compound-v3/publicCallParse.ts +3 -10
  155. package/src/lending/fetchLender.ts +1 -1
  156. package/src/lending/fetchLenderAll.ts +1 -1
  157. package/src/lending/fetchLenderExt.ts +1 -1
  158. package/src/lending/index.ts +1 -0
  159. package/src/lending/init/publicCallBuild.ts +1 -1
  160. package/src/lending/init/publicCallParse.ts +64 -48
  161. package/src/lending/meta/index.ts +124 -0
  162. package/src/lending/morpho/publicCallBuild.ts +0 -1
  163. package/src/lending/user-data/aave-v2-type/userCallBuild.ts +26 -32
  164. package/src/lending/user-data/aave-v2-type/userCallParse.ts +181 -122
  165. package/src/lending/user-data/aave-v3-type/userCallBuild.ts +18 -16
  166. package/src/lending/user-data/aave-v3-type/userCallParse.ts +7 -8
  167. package/src/lending/user-data/aave-v3-type/userCallParseYldr.ts +37 -34
  168. package/src/lending/user-data/abis.ts +1 -1
  169. package/src/lending/user-data/compound-v3/userCallBuild.ts +3 -2
  170. package/src/lending/user-data/compound-v3/userCallParse.ts +5 -11
  171. package/src/lending/user-data/fetchUserData.ts +9 -7
  172. package/src/lending/user-data/init/userCallBuild.ts +11 -7
  173. package/src/lending/user-data/init/userCallParse.ts +5 -5
  174. package/src/lending/user-data/morpho/userCallBuild.ts +7 -4
  175. package/src/lending/user-data/morpho/userCallParse.ts +7 -6
  176. package/src/lending/user-data/types.ts +8 -4
  177. package/src/lending-pairs/computeLendingPairs.ts +6 -12
  178. package/src/prices/main-prices/addresses/api3.ts +1 -1
  179. package/src/prices/main-prices/addresses/chainlink.ts +1 -1
  180. package/src/prices/main-prices/fetchOracleData.ts +117 -20
  181. package/src/types/index.ts +10 -4
  182. package/src/utils/constants.ts +1 -1
  183. package/src/utils/index.ts +18 -27
  184. package/src/utils/parsing.ts +37 -35
  185. package/src/yields/index.ts +3 -2
  186. package/test/flashLiquidity.test.ts +6 -6
  187. package/test/index.test.ts +1 -1
  188. package/test/lenderData.test.ts +9 -10
  189. package/test/lenderDataBasic.test.ts +1 -1
  190. package/test/mainPriceMB.test.ts +1 -1
  191. package/test/mainPrices.test.ts +14 -14
  192. package/test/morpho.test.ts +1 -1
  193. package/test/morphoPrice.test.ts +1 -1
  194. package/test/userData.test.ts +2 -1
  195. package/test/userDataAave.test.ts +1 -1
  196. package/test/userDataAaveMainnet.test.ts +10 -11
  197. package/test/userDataAll.test.ts +2 -1
  198. package/test/userDataCompound.test.ts +2 -1
  199. package/test/userDataMorpho.test.ts +2 -1
  200. package/test/userDataMorphoEthereum.test.ts +25 -26
  201. package/test/userDataMorphoKatana.test.ts +2 -1
  202. package/test/utils.ts +11 -1
  203. package/dist/lending/user-data/morpho/userCallParseNoDeploy.d.ts +0 -11
  204. package/dist/lending/user-data/morpho/userCallParseNoDeploy.d.ts.map +0 -1
  205. package/dist/lending/user-data/morpho/userCallParseNoDeploy.js +0 -112
  206. package/dist/prices/main-prices/addresses/aaveOracles.d.ts +0 -303
  207. package/dist/prices/main-prices/addresses/aaveOracles.d.ts.map +0 -1
  208. package/dist/prices/main-prices/addresses/aaveOracles.js +0 -302
  209. package/dist/prices/main-prices/addresses/morpho.d.ts +0 -11
  210. package/dist/prices/main-prices/addresses/morpho.d.ts.map +0 -1
  211. package/dist/prices/main-prices/addresses/morpho.js +0 -2554
  212. package/src/lending/user-data/morpho/userCallParseNoDeploy.ts +0 -168
  213. package/src/prices/main-prices/addresses/aaveOracles.ts +0 -302
  214. package/src/prices/main-prices/addresses/morpho.ts +0 -2563
@@ -1,9 +1,5 @@
1
- import {
2
- getAaveStyleProtocolTokenMap,
3
- getAaveTypePoolAddress,
4
- getAssetMeta,
5
- } from '../assets'
6
- import { AAVES_PER_CHAIN } from '../utils'
1
+ import { getAaveStyleProtocolTokenMap, getAaveTypePoolAddress } from '../assets'
2
+ import { getAavesForChain } from '../utils'
7
3
  import {
8
4
  RELEVANT_BALANCER_V2_FORKS,
9
5
  RELEVANT_BALANCER_V3_FORKS,
@@ -12,12 +8,12 @@ import {
12
8
  RELEVANT_UNISWAP_V4_FORKS,
13
9
  } from './assets'
14
10
  import { Call } from '../utils/multicall'
15
- import { MulticallRetryFunction } from '../types'
11
+ import { MulticallRetryFunction, TokenList } from '../types'
16
12
  import { FlashAbi } from '../abis/flashloan-united/flashAbi'
17
13
  import { FlashLiquiditiesOnChain, FlashLoanIds } from './types'
18
14
  import { FLASH_LOAN_IDS } from '@1delta/dex-registry'
19
15
  import { formatUnits, zeroAddress } from 'viem'
20
- import { AAVE_V2_LENDERS, AAVE_V3_LENDERS } from '@1delta/asset-registry'
16
+ import { AAVE_V2_LENDERS, AAVE_V3_LENDERS } from '@1delta/lender-registry'
21
17
  import _ from 'lodash'
22
18
  import { MULTICALL_ADDRESS } from '../utils/constants'
23
19
 
@@ -39,13 +35,16 @@ function getFlashLoanEnabled(data: bigint): boolean {
39
35
  export async function fetchFlashLiquidityForChain(
40
36
  chain: string,
41
37
  multicallRetry: MulticallRetryFunction,
38
+ list: TokenList = {},
42
39
  ) {
43
40
  let callLengths: { [l: string]: number } = {}
44
41
  let aaveAssets: { [l: string]: string[] } = {}
45
42
 
46
43
  let aaveCalls: Call[] = []
47
44
 
48
- const aaveProtocols = AAVES_PER_CHAIN[chain] ?? []
45
+ const aaves = getAavesForChain()
46
+
47
+ const aaveProtocols = aaves[chain] ?? []
49
48
 
50
49
  // we only ned to check aave flash liquidity for aave assets
51
50
  aaveProtocols.forEach((aaveFork) => {
@@ -205,7 +204,7 @@ export async function fetchFlashLiquidityForChain(
205
204
  currentOffset += callLen
206
205
 
207
206
  aaveAssets[aave].forEach((asset, i) => {
208
- const decimals = getAssetMeta(chain, asset)?.decimals
207
+ const decimals = list[asset]?.decimals
209
208
  const rawAmount = data[2 * i]
210
209
 
211
210
  const config = data[2 * i + 1]
@@ -237,7 +236,7 @@ export async function fetchFlashLiquidityForChain(
237
236
  currentOffset += callLen
238
237
 
239
238
  otherAssets.forEach((asset, i) => {
240
- const decimals = getAssetMeta(chain, asset)?.decimals
239
+ const decimals = list[asset]?.decimals
241
240
  const rawAmount = data[i]
242
241
  if (rawAmount > 0n) {
243
242
  if (!liquidity[asset]) liquidity[asset] = []
@@ -266,7 +265,7 @@ export async function fetchFlashLiquidityForChain(
266
265
  const rawAmount = data[i]
267
266
  if (rawAmount > 0n) {
268
267
  if (!liquidity[asset]) liquidity[asset] = []
269
- const decimals = getAssetMeta(chain, asset)?.decimals
268
+ const decimals = list[asset]?.decimals
270
269
  liquidity[asset].push({
271
270
  id: FLASH_LOAN_IDS[morpho.pool],
272
271
  name: morpho.pool,
@@ -289,7 +288,7 @@ export async function fetchFlashLiquidityForChain(
289
288
  currentOffset += callLen
290
289
 
291
290
  otherAssets.forEach((asset, i) => {
292
- const decimals = getAssetMeta(chain, asset)?.decimals
291
+ const decimals = list[asset]?.decimals
293
292
  const rawAmount = data[i]
294
293
  if (rawAmount > 0n) {
295
294
  if (!liquidity[asset]) liquidity[asset] = []
@@ -315,7 +314,7 @@ export async function fetchFlashLiquidityForChain(
315
314
  currentOffset += callLen
316
315
 
317
316
  otherAssets.forEach((asset, i) => {
318
- const decimals = getAssetMeta(chain, asset)?.decimals
317
+ const decimals = list[asset]?.decimals
319
318
  const rawAmount = data[i]
320
319
  if (rawAmount > 0n) {
321
320
  if (!liquidity[asset]) liquidity[asset] = []
@@ -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,15 +1,12 @@
1
- import {
2
- Chain,
3
- COMETS_PER_CHAIN_MAP,
4
- COMPOUND_BASE_TOKENS,
5
- Lender,
6
- } 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'
7
4
 
8
5
  export function getCompoundV3CometAddress(
9
6
  chainId: string,
10
7
  lender = Lender.COMPOUND_V3_USDCE,
11
8
  ): string | undefined {
12
- return COMETS_PER_CHAIN_MAP[chainId]?.[lender]
9
+ return compoundV3Pools()?.[chainId]?.[lender]
13
10
  }
14
11
 
15
12
  export function getCompoundV3CometRewardsAddress(chainId: string) {
@@ -49,5 +46,5 @@ export function getCompoundV3BaseAsset(
49
46
  lender: Lender | string,
50
47
  chainId: string,
51
48
  ) {
52
- return COMPOUND_BASE_TOKENS[lender]?.[chainId]
49
+ return compoundV3BaseData()?.[lender]?.[chainId]
53
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
+ }