@defisaver/positions-sdk 2.1.52 → 2.1.53-aave-v4

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 (201) hide show
  1. package/.mocharc.json +4 -4
  2. package/.nvmrc +1 -1
  3. package/README.md +64 -64
  4. package/cjs/aaveV4/index.d.ts +7 -0
  5. package/cjs/aaveV4/index.js +174 -0
  6. package/cjs/config/contracts.d.ts +1277 -0
  7. package/cjs/config/contracts.js +9 -0
  8. package/cjs/contracts.d.ts +23120 -0
  9. package/cjs/contracts.js +2 -1
  10. package/cjs/fluid/index.d.ts +6 -6
  11. package/cjs/helpers/aaveHelpers/index.d.ts +2 -2
  12. package/cjs/helpers/aaveHelpers/index.js +16 -5
  13. package/cjs/helpers/aaveV4Helpers/index.d.ts +13 -0
  14. package/cjs/helpers/aaveV4Helpers/index.js +117 -0
  15. package/cjs/helpers/compoundHelpers/index.js +15 -18
  16. package/cjs/helpers/eulerHelpers/index.d.ts +2 -2
  17. package/cjs/helpers/eulerHelpers/index.js +21 -13
  18. package/cjs/helpers/fluidHelpers/index.js +16 -5
  19. package/cjs/helpers/index.d.ts +1 -0
  20. package/cjs/helpers/index.js +2 -1
  21. package/cjs/helpers/morphoBlueHelpers/index.js +81 -71
  22. package/cjs/helpers/sparkHelpers/index.d.ts +2 -2
  23. package/cjs/helpers/sparkHelpers/index.js +15 -5
  24. package/cjs/index.d.ts +2 -1
  25. package/cjs/index.js +3 -1
  26. package/cjs/markets/aaveV4/index.d.ts +13 -0
  27. package/cjs/markets/aaveV4/index.js +39 -0
  28. package/cjs/markets/index.d.ts +1 -0
  29. package/cjs/markets/index.js +3 -1
  30. package/cjs/moneymarket/moneymarketCommonService.d.ts +3 -3
  31. package/cjs/moneymarket/moneymarketCommonService.js +9 -9
  32. package/cjs/portfolio/index.js +20 -0
  33. package/cjs/savings/morphoVaults/index.js +17 -17
  34. package/cjs/types/aave.d.ts +3 -3
  35. package/cjs/types/aaveV4.d.ts +137 -0
  36. package/cjs/types/aaveV4.js +11 -0
  37. package/cjs/types/common.d.ts +7 -0
  38. package/cjs/types/common.js +9 -1
  39. package/cjs/types/compound.d.ts +3 -3
  40. package/cjs/types/curveUsd.d.ts +2 -2
  41. package/cjs/types/euler.d.ts +3 -3
  42. package/cjs/types/fluid.d.ts +3 -3
  43. package/cjs/types/index.d.ts +2 -0
  44. package/cjs/types/index.js +2 -0
  45. package/cjs/types/liquityV2.d.ts +3 -3
  46. package/cjs/types/llamaLend.d.ts +2 -2
  47. package/cjs/types/morphoBlue.d.ts +5 -5
  48. package/cjs/types/portfolio.d.ts +4 -0
  49. package/cjs/types/spark.d.ts +3 -3
  50. package/esm/aaveV4/index.d.ts +7 -0
  51. package/esm/aaveV4/index.js +165 -0
  52. package/esm/config/contracts.d.ts +1277 -0
  53. package/esm/config/contracts.js +8 -0
  54. package/esm/contracts.d.ts +23120 -0
  55. package/esm/contracts.js +1 -0
  56. package/esm/fluid/index.d.ts +6 -6
  57. package/esm/helpers/aaveHelpers/index.d.ts +2 -2
  58. package/esm/helpers/aaveHelpers/index.js +16 -5
  59. package/esm/helpers/aaveV4Helpers/index.d.ts +13 -0
  60. package/esm/helpers/aaveV4Helpers/index.js +108 -0
  61. package/esm/helpers/compoundHelpers/index.js +16 -19
  62. package/esm/helpers/eulerHelpers/index.d.ts +2 -2
  63. package/esm/helpers/eulerHelpers/index.js +21 -13
  64. package/esm/helpers/fluidHelpers/index.js +16 -5
  65. package/esm/helpers/index.d.ts +1 -0
  66. package/esm/helpers/index.js +1 -0
  67. package/esm/helpers/morphoBlueHelpers/index.js +82 -72
  68. package/esm/helpers/sparkHelpers/index.d.ts +2 -2
  69. package/esm/helpers/sparkHelpers/index.js +16 -6
  70. package/esm/index.d.ts +2 -1
  71. package/esm/index.js +2 -1
  72. package/esm/markets/aaveV4/index.d.ts +13 -0
  73. package/esm/markets/aaveV4/index.js +29 -0
  74. package/esm/markets/index.d.ts +1 -0
  75. package/esm/markets/index.js +1 -0
  76. package/esm/moneymarket/moneymarketCommonService.d.ts +3 -3
  77. package/esm/moneymarket/moneymarketCommonService.js +9 -9
  78. package/esm/portfolio/index.js +21 -1
  79. package/esm/savings/morphoVaults/index.js +17 -17
  80. package/esm/types/aave.d.ts +3 -3
  81. package/esm/types/aaveV4.d.ts +137 -0
  82. package/esm/types/aaveV4.js +8 -0
  83. package/esm/types/common.d.ts +7 -0
  84. package/esm/types/common.js +8 -0
  85. package/esm/types/compound.d.ts +3 -3
  86. package/esm/types/curveUsd.d.ts +2 -2
  87. package/esm/types/euler.d.ts +3 -3
  88. package/esm/types/fluid.d.ts +3 -3
  89. package/esm/types/fluid.js +1 -1
  90. package/esm/types/index.d.ts +2 -0
  91. package/esm/types/index.js +2 -0
  92. package/esm/types/liquityV2.d.ts +3 -3
  93. package/esm/types/llamaLend.d.ts +2 -2
  94. package/esm/types/morphoBlue.d.ts +5 -5
  95. package/esm/types/portfolio.d.ts +4 -0
  96. package/esm/types/spark.d.ts +3 -3
  97. package/package.json +48 -48
  98. package/src/aaveV2/index.ts +240 -240
  99. package/src/aaveV3/index.ts +635 -635
  100. package/src/aaveV3/merit.ts +97 -97
  101. package/src/aaveV3/merkl.ts +74 -74
  102. package/src/aaveV4/index.ts +176 -0
  103. package/src/claiming/aaveV3.ts +154 -154
  104. package/src/claiming/compV3.ts +22 -22
  105. package/src/claiming/ethena.ts +61 -61
  106. package/src/claiming/index.ts +12 -12
  107. package/src/claiming/king.ts +66 -66
  108. package/src/claiming/morphoBlue.ts +118 -118
  109. package/src/claiming/spark.ts +225 -225
  110. package/src/compoundV2/index.ts +244 -244
  111. package/src/compoundV3/index.ts +274 -274
  112. package/src/config/contracts.ts +1328 -1320
  113. package/src/constants/index.ts +10 -10
  114. package/src/contracts.ts +174 -172
  115. package/src/curveUsd/index.ts +254 -254
  116. package/src/eulerV2/index.ts +324 -324
  117. package/src/exchange/index.ts +25 -25
  118. package/src/fluid/index.ts +1800 -1800
  119. package/src/helpers/aaveHelpers/index.ts +202 -191
  120. package/src/helpers/aaveV4Helpers/index.ts +128 -0
  121. package/src/helpers/compoundHelpers/index.ts +276 -283
  122. package/src/helpers/curveUsdHelpers/index.ts +40 -40
  123. package/src/helpers/eulerHelpers/index.ts +229 -222
  124. package/src/helpers/fluidHelpers/index.ts +335 -326
  125. package/src/helpers/index.ts +11 -10
  126. package/src/helpers/liquityV2Helpers/index.ts +82 -82
  127. package/src/helpers/llamaLendHelpers/index.ts +53 -53
  128. package/src/helpers/makerHelpers/index.ts +52 -52
  129. package/src/helpers/morphoBlueHelpers/index.ts +405 -396
  130. package/src/helpers/sparkHelpers/index.ts +169 -158
  131. package/src/index.ts +51 -49
  132. package/src/liquity/index.ts +159 -159
  133. package/src/liquityV2/index.ts +703 -703
  134. package/src/llamaLend/index.ts +305 -305
  135. package/src/maker/index.ts +223 -223
  136. package/src/markets/aave/index.ts +118 -118
  137. package/src/markets/aave/marketAssets.ts +54 -54
  138. package/src/markets/aaveV4/index.ts +42 -0
  139. package/src/markets/compound/index.ts +243 -243
  140. package/src/markets/compound/marketsAssets.ts +97 -97
  141. package/src/markets/curveUsd/index.ts +69 -69
  142. package/src/markets/euler/index.ts +26 -26
  143. package/src/markets/fluid/index.ts +2900 -2900
  144. package/src/markets/index.ts +26 -25
  145. package/src/markets/liquityV2/index.ts +102 -102
  146. package/src/markets/llamaLend/contractAddresses.ts +141 -141
  147. package/src/markets/llamaLend/index.ts +235 -235
  148. package/src/markets/morphoBlue/index.ts +988 -988
  149. package/src/markets/spark/index.ts +29 -29
  150. package/src/markets/spark/marketAssets.ts +12 -12
  151. package/src/moneymarket/moneymarketCommonService.ts +84 -85
  152. package/src/morphoBlue/index.ts +274 -274
  153. package/src/portfolio/index.ts +606 -586
  154. package/src/savings/index.ts +95 -95
  155. package/src/savings/makerDsr/index.ts +53 -53
  156. package/src/savings/makerDsr/options.ts +9 -9
  157. package/src/savings/morphoVaults/index.ts +80 -80
  158. package/src/savings/morphoVaults/options.ts +193 -193
  159. package/src/savings/skyOptions/index.ts +95 -95
  160. package/src/savings/skyOptions/options.ts +10 -10
  161. package/src/savings/sparkSavingsVaults/index.ts +60 -60
  162. package/src/savings/sparkSavingsVaults/options.ts +35 -35
  163. package/src/savings/yearnV3Vaults/index.ts +61 -61
  164. package/src/savings/yearnV3Vaults/options.ts +55 -55
  165. package/src/savings/yearnVaults/index.ts +73 -73
  166. package/src/savings/yearnVaults/options.ts +32 -32
  167. package/src/services/priceService.ts +278 -278
  168. package/src/services/utils.ts +115 -115
  169. package/src/services/viem.ts +57 -57
  170. package/src/setup.ts +8 -8
  171. package/src/spark/index.ts +459 -459
  172. package/src/staking/eligibility.ts +53 -53
  173. package/src/staking/index.ts +1 -1
  174. package/src/staking/staking.ts +192 -192
  175. package/src/types/aave.ts +199 -198
  176. package/src/types/aaveV4.ts +153 -0
  177. package/src/types/claiming.ts +114 -114
  178. package/src/types/common.ts +115 -107
  179. package/src/types/compound.ts +145 -144
  180. package/src/types/curveUsd.ts +123 -123
  181. package/src/types/euler.ts +176 -175
  182. package/src/types/fluid.ts +485 -483
  183. package/src/types/index.ts +17 -15
  184. package/src/types/liquity.ts +30 -30
  185. package/src/types/liquityV2.ts +128 -126
  186. package/src/types/llamaLend.ts +161 -159
  187. package/src/types/maker.ts +63 -63
  188. package/src/types/merit.ts +1 -1
  189. package/src/types/merkl.ts +70 -70
  190. package/src/types/morphoBlue.ts +202 -202
  191. package/src/types/portfolio.ts +64 -60
  192. package/src/types/savings/index.ts +23 -23
  193. package/src/types/savings/makerDsr.ts +13 -13
  194. package/src/types/savings/morphoVaults.ts +32 -32
  195. package/src/types/savings/sky.ts +14 -14
  196. package/src/types/savings/sparkSavingsVaults.ts +15 -15
  197. package/src/types/savings/yearnV3Vaults.ts +17 -17
  198. package/src/types/savings/yearnVaults.ts +14 -14
  199. package/src/types/spark.ts +135 -134
  200. package/src/umbrella/index.ts +69 -69
  201. package/src/umbrella/umbrellaUtils.ts +29 -29
package/esm/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import './setup';
2
2
  import * as fluid from './fluid';
3
+ import * as aaveV4 from './aaveV4';
3
4
  import * as aaveV3 from './aaveV3';
4
5
  import * as aaveV2 from './aaveV2';
5
6
  import * as compoundV3 from './compoundV3';
@@ -21,4 +22,4 @@ import * as portfolio from './portfolio';
21
22
  import * as claiming from './claiming';
22
23
  import * as savings from './savings';
23
24
  export * from './types';
24
- export { aaveV2, aaveV3, compoundV2, compoundV3, spark, curveUsd, liquity, liquityV2, maker, exchange, staking, moneymarket, markets, helpers, morphoBlue, llamaLend, eulerV2, fluid, portfolio, claiming, savings, };
25
+ export { aaveV2, aaveV3, aaveV4, compoundV2, compoundV3, spark, curveUsd, liquity, liquityV2, maker, exchange, staking, moneymarket, markets, helpers, morphoBlue, llamaLend, eulerV2, fluid, portfolio, claiming, savings, };
package/esm/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import './setup';
2
2
  import * as fluid from './fluid';
3
+ import * as aaveV4 from './aaveV4';
3
4
  import * as aaveV3 from './aaveV3';
4
5
  import * as aaveV2 from './aaveV2';
5
6
  import * as compoundV3 from './compoundV3';
@@ -21,4 +22,4 @@ import * as portfolio from './portfolio';
21
22
  import * as claiming from './claiming';
22
23
  import * as savings from './savings';
23
24
  export * from './types';
24
- export { aaveV2, aaveV3, compoundV2, compoundV3, spark, curveUsd, liquity, liquityV2, maker, exchange, staking, moneymarket, markets, helpers, morphoBlue, llamaLend, eulerV2, fluid, portfolio, claiming, savings, };
25
+ export { aaveV2, aaveV3, aaveV4, compoundV2, compoundV3, spark, curveUsd, liquity, liquityV2, maker, exchange, staking, moneymarket, markets, helpers, morphoBlue, llamaLend, eulerV2, fluid, portfolio, claiming, savings, };
@@ -0,0 +1,13 @@
1
+ import { AaveV4HubInfo, AaveV4HubsType, AaveV4SpokeInfo, AaveV4SpokesType } from '../../types';
2
+ import { NetworkNumber } from '../../types/common';
3
+ export declare const AAVE_V4_CORE_SPOKE: (networkId: NetworkNumber) => AaveV4SpokeInfo;
4
+ export declare const AaveV4Spokes: (networkId: NetworkNumber) => {
5
+ readonly aave_v4_core_spoke: AaveV4SpokeInfo;
6
+ };
7
+ export declare const getAaveV4SpokeTypeInfo: (type: AaveV4SpokesType, network?: NetworkNumber) => AaveV4SpokeInfo;
8
+ export declare const AAVE_V4_CORE_HUB: (networkId: NetworkNumber) => AaveV4HubInfo;
9
+ export declare const AaveV4Hubs: (networkId: NetworkNumber) => {
10
+ readonly aave_v4_core_hub: AaveV4HubInfo;
11
+ };
12
+ export declare const getAaveV4HubTypeInfo: (type: AaveV4HubsType, network?: NetworkNumber) => AaveV4HubInfo;
13
+ export declare const getAaveV4HubByAddress: (networkId: NetworkNumber, address: string) => AaveV4HubInfo | undefined;
@@ -0,0 +1,29 @@
1
+ import { AaveV4HubsType, AaveV4SpokesType, } from '../../types';
2
+ import { NetworkNumber } from '../../types/common';
3
+ // SPOKES
4
+ export const AAVE_V4_CORE_SPOKE = (networkId) => ({
5
+ chainIds: [NetworkNumber.Eth],
6
+ label: 'Core Spoke',
7
+ value: AaveV4SpokesType.AaveV4CoreSpoke,
8
+ url: 'core',
9
+ address: '0xBa97c5E52cd5BC3D7950Ae70779F8FfE92d40CdC',
10
+ hubs: [
11
+ '0xaD905aD5EA5B98cD50AE40Cfe368344686a21366',
12
+ ],
13
+ });
14
+ export const AaveV4Spokes = (networkId) => ({
15
+ [AaveV4SpokesType.AaveV4CoreSpoke]: AAVE_V4_CORE_SPOKE(networkId),
16
+ });
17
+ export const getAaveV4SpokeTypeInfo = (type, network) => (Object.assign({}, AaveV4Spokes(network !== null && network !== void 0 ? network : NetworkNumber.Eth))[type]);
18
+ // HUBS
19
+ export const AAVE_V4_CORE_HUB = (networkId) => ({
20
+ chainIds: [NetworkNumber.Eth],
21
+ label: 'Core Hub',
22
+ value: AaveV4HubsType.AaveV4CoreHub,
23
+ address: '0xaD905aD5EA5B98cD50AE40Cfe368344686a21366',
24
+ });
25
+ export const AaveV4Hubs = (networkId) => ({
26
+ [AaveV4HubsType.AaveV4CoreHub]: AAVE_V4_CORE_HUB(networkId),
27
+ });
28
+ export const getAaveV4HubTypeInfo = (type, network) => (Object.assign({}, AaveV4Hubs(network !== null && network !== void 0 ? network : NetworkNumber.Eth))[type]);
29
+ export const getAaveV4HubByAddress = (networkId, address) => Object.values(AaveV4Hubs(networkId)).find(hub => hub.address.toLowerCase() === address.toLowerCase());
@@ -7,3 +7,4 @@ export { LlamaLendMarkets } from './llamaLend';
7
7
  export { LiquityV2Markets, findLiquityV2MarketByAddress } from './liquityV2';
8
8
  export { EulerV2Markets } from './euler';
9
9
  export { FluidMarkets, getFluidVersionsDataForNetwork, getFluidMarketInfoById, getFTokenAddress, getFluidMarketInfoByAddress, } from './fluid';
10
+ export { AaveV4Spokes } from './aaveV4';
@@ -7,3 +7,4 @@ export { LlamaLendMarkets } from './llamaLend';
7
7
  export { LiquityV2Markets, findLiquityV2MarketByAddress } from './liquityV2';
8
8
  export { EulerV2Markets } from './euler';
9
9
  export { FluidMarkets, getFluidVersionsDataForNetwork, getFluidMarketInfoById, getFTokenAddress, getFluidMarketInfoByAddress, } from './fluid';
10
+ export { AaveV4Spokes } from './aaveV4';
@@ -1,12 +1,12 @@
1
- import { MMUsedAssets } from '../types/common';
1
+ import { LeverageType, MMUsedAssets } from '../types/common';
2
2
  export declare const getAssetsTotal: (assets: object, filter: any, transform: any) => any;
3
3
  export declare const calcLongLiqPrice: (assetPrice: string, borrowedUsd: string, borrowLimitUsd: string) => string;
4
4
  export declare const calcShortLiqPrice: (assetPrice: string, borrowedUsd: string, borrowLimitUsd: string) => string;
5
- export declare const calcLeverageLiqPrice: (leverageType: string, assetPrice: string, borrowedUsd: string, borrowLimitUsd: string) => string;
5
+ export declare const calcLeverageLiqPrice: (leverageType: LeverageType, assetPrice: string, borrowedUsd: string, borrowLimitUsd: string) => string;
6
6
  export declare const calculateBorrowingAssetLimit: (assetBorrowedUsd: string, borrowLimitUsd: string) => string;
7
7
  export declare const STABLE_ASSETS: string[];
8
8
  export declare const isLeveragedPos: (usedAssets: MMUsedAssets, dustLimit?: number) => {
9
- leveragedType: string;
9
+ leveragedType: LeverageType;
10
10
  leveragedAsset: string;
11
11
  };
12
12
  export declare const aprToApy: (interest: string | number, frequency?: number) => string;
@@ -1,5 +1,6 @@
1
1
  import Dec from 'decimal.js';
2
2
  import { BLOCKS_IN_A_YEAR } from '../constants';
3
+ import { LeverageType } from '../types/common';
3
4
  export const getAssetsTotal = (assets, filter, transform) => Object.values(assets)
4
5
  .filter(filter)
5
6
  .map(transform)
@@ -8,9 +9,9 @@ export const getAssetsTotal = (assets, filter, transform) => Object.values(asset
8
9
  export const calcLongLiqPrice = (assetPrice, borrowedUsd, borrowLimitUsd) => new Dec(assetPrice).mul(borrowedUsd).div(borrowLimitUsd).toString();
9
10
  export const calcShortLiqPrice = (assetPrice, borrowedUsd, borrowLimitUsd) => new Dec(assetPrice).div(borrowedUsd).mul(borrowLimitUsd).toString();
10
11
  export const calcLeverageLiqPrice = (leverageType, assetPrice, borrowedUsd, borrowLimitUsd) => {
11
- if (leverageType === 'short')
12
+ if (leverageType === LeverageType.Short || leverageType === LeverageType.VolatilePairReverse)
12
13
  return calcShortLiqPrice(assetPrice, borrowedUsd, borrowLimitUsd);
13
- if (leverageType === 'long' || leverageType === 'lsd-leverage')
14
+ if (leverageType === LeverageType.Long || leverageType === LeverageType.VolatilePair)
14
15
  return calcLongLiqPrice(assetPrice, borrowedUsd, borrowLimitUsd);
15
16
  console.error('invalid leverageType', leverageType);
16
17
  return '0';
@@ -47,28 +48,27 @@ export const isLeveragedPos = (usedAssets, dustLimit = 5) => {
47
48
  });
48
49
  const isLong = borrowStable > 0 && borrowUnstable === 0 && supplyUnstable === 1 && supplyStable === 0;
49
50
  const isShort = supplyStable > 0 && supplyUnstable === 0 && borrowUnstable === 1 && borrowStable === 0;
50
- // lsd -> liquid staking derivative
51
- const isLsdLeveraged = supplyUnstable === 1 && borrowUnstable === 1 && shortAsset === 'ETH' && ['stETH', 'wstETH', 'cbETH', 'rETH', 'ezETH', 'weETH'].includes(longAsset);
51
+ const isVolatilePair = supplyUnstable === 1 && borrowUnstable === 1 && supplyStable === 0 && borrowStable === 0;
52
52
  if (isLong) {
53
53
  return {
54
- leveragedType: 'long',
54
+ leveragedType: LeverageType.Long,
55
55
  leveragedAsset: longAsset,
56
56
  };
57
57
  }
58
58
  if (isShort) {
59
59
  return {
60
- leveragedType: 'short',
60
+ leveragedType: LeverageType.Short,
61
61
  leveragedAsset: shortAsset,
62
62
  };
63
63
  }
64
- if (isLsdLeveraged) {
64
+ if (isVolatilePair) {
65
65
  return {
66
- leveragedType: 'lsd-leverage',
66
+ leveragedType: LeverageType.VolatilePair,
67
67
  leveragedAsset: longAsset,
68
68
  };
69
69
  }
70
70
  return {
71
- leveragedType: '',
71
+ leveragedType: LeverageType.None,
72
72
  leveragedAsset: '',
73
73
  };
74
74
  };
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import Dec from 'decimal.js';
11
11
  import { NetworkNumber } from '../types/common';
12
- import { AaveMarkets, CompoundMarkets, CrvUsdMarkets, EulerV2Markets, LiquityV2Markets, LlamaLendMarkets, MorphoBlueMarkets, SparkMarkets, } from '../markets';
12
+ import { AaveMarkets, AaveV4Spokes, CompoundMarkets, CrvUsdMarkets, EulerV2Markets, LiquityV2Markets, LlamaLendMarkets, MorphoBlueMarkets, SparkMarkets, } from '../markets';
13
13
  import { _getMorphoBlueAccountData, _getMorphoBlueMarketData, getMorphoEarn } from '../morphoBlue';
14
14
  import { AaveVersions, CompoundVersions, } from '../types';
15
15
  import { _getCompoundV3AccountData, _getCompoundV3MarketsData } from '../compoundV3';
@@ -34,6 +34,7 @@ import { fetchSparkAirdropRewards, fetchSparkRewards } from '../claiming/spark';
34
34
  import { fetchMorphoBlueRewards } from '../claiming/morphoBlue';
35
35
  import { getKingRewards } from '../claiming/king';
36
36
  import { fetchEthenaAirdropRewards } from '../claiming/ethena';
37
+ import { _getAaveV4AccountData, _getAaveV4SpokeData } from '../aaveV4';
37
38
  export function getPortfolioData(provider_1, network_1, defaultProvider_1, addresses_1) {
38
39
  return __awaiter(this, arguments, void 0, function* (provider, network, defaultProvider, addresses, isSim = false) {
39
40
  const isMainnet = network === NetworkNumber.Eth;
@@ -50,6 +51,7 @@ export function getPortfolioData(provider_1, network_1, defaultProvider_1, addre
50
51
  const llamaLendMarkets = [NetworkNumber.Eth, NetworkNumber.Arb].includes(network) ? Object.values(LlamaLendMarkets(network)).filter((market) => market.chainIds.includes(network)) : [];
51
52
  const liquityV2Markets = [NetworkNumber.Eth].includes(network) ? Object.values(LiquityV2Markets(network)) : [];
52
53
  const liquityV2MarketsStaking = [NetworkNumber.Eth].includes(network) ? Object.values(LiquityV2Markets(network)).filter(market => !market.isLegacy) : [];
54
+ const aaveV4Spokes = Object.values(AaveV4Spokes(network)).filter((market) => market.chainIds.includes(network));
53
55
  const args = [network, { batch: { multicall: { batchSize: isSim ? 500000 : 2500000 } } }];
54
56
  const client = getViemProvider(provider, ...args);
55
57
  const defaultClient = getViemProvider(defaultProvider, ...args);
@@ -64,6 +66,7 @@ export function getPortfolioData(provider_1, network_1, defaultProvider_1, addre
64
66
  const crvUsdMarketsData = {};
65
67
  const llamaLendMarketsData = {};
66
68
  const liquityV2MarketsData = {};
69
+ const aaveV4SpokesData = {};
67
70
  const markets = {
68
71
  morphoMarketsData,
69
72
  compoundV3MarketsData,
@@ -75,6 +78,7 @@ export function getPortfolioData(provider_1, network_1, defaultProvider_1, addre
75
78
  crvUsdMarketsData,
76
79
  llamaLendMarketsData,
77
80
  liquityV2MarketsData,
81
+ aaveV4SpokesData,
78
82
  };
79
83
  const positions = {};
80
84
  const stakingPositions = {};
@@ -83,6 +87,7 @@ export function getPortfolioData(provider_1, network_1, defaultProvider_1, addre
83
87
  for (const address of allAddresses) {
84
88
  positions[address.toLowerCase()] = {
85
89
  aaveV3: {},
90
+ aaveV4: {},
86
91
  morphoBlue: {},
87
92
  compoundV3: {},
88
93
  spark: {},
@@ -148,6 +153,10 @@ export function getPortfolioData(provider_1, network_1, defaultProvider_1, addre
148
153
  const marketData = yield _getAaveV3MarketData(client, network, market);
149
154
  aaveV3MarketsData[market.value] = marketData;
150
155
  })),
156
+ ...aaveV4Spokes.map((spoke) => __awaiter(this, void 0, void 0, function* () {
157
+ const spokeData = yield _getAaveV4SpokeData(client, network, spoke);
158
+ aaveV4SpokesData[spoke.value] = spokeData;
159
+ })),
151
160
  ...aaveV2Markets.map((market) => __awaiter(this, void 0, void 0, function* () {
152
161
  const marketData = yield _getAaveV2MarketsData(client, network, market);
153
162
  aaveV2MarketsData[market.value] = marketData;
@@ -417,6 +426,17 @@ export function getPortfolioData(provider_1, network_1, defaultProvider_1, addre
417
426
  positions[address.toLowerCase()].aaveV3[market.value] = { error: `Error fetching AaveV3 account data for address ${address} on market ${market.value}`, data: null };
418
427
  }
419
428
  }))).flat(),
429
+ ...aaveV4Spokes.map((spoke) => allAddresses.map((address) => __awaiter(this, void 0, void 0, function* () {
430
+ try {
431
+ const accData = yield _getAaveV4AccountData(client, network, aaveV4SpokesData[spoke.value], address);
432
+ if (new Dec(accData.suppliedUsd).gt(0))
433
+ positions[address.toLowerCase()].aaveV4[spoke.value] = { error: '', data: accData };
434
+ }
435
+ catch (error) {
436
+ console.error(`Error fetching AaveV4 account data for address ${address} on spoke ${spoke.value}:`, error);
437
+ positions[address.toLowerCase()].aaveV4[spoke.value] = { error: `Error fetching AaveV4 account data for address ${address} on spoke ${spoke.value}`, data: null };
438
+ }
439
+ }))).flat(),
420
440
  ...morphoMarkets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
421
441
  try {
422
442
  const [accDataPromise, earnDataPromise] = yield Promise.allSettled([
@@ -14,23 +14,23 @@ import * as morphoVaultsOptions from './options';
14
14
  import { getViemProvider } from '../../services/viem';
15
15
  import { getMorphoVaultContractViem } from '../../contracts';
16
16
  export { morphoVaultsOptions, };
17
- const vaultDataQuery = (vaultAddress) => `query vaultByAddress {
18
- vaultByAddress(chainId: 1, address: "${vaultAddress}") {
19
- id,
20
- dailyApy,
21
- dailyApys {
22
- apy, netApy
23
- },
24
- monthlyApys {
25
- apy, netApy
26
- },
27
- liquidity {
28
- underlying, usd,
29
- },
30
- asset {
31
- priceUsd
32
- }
33
- }
17
+ const vaultDataQuery = (vaultAddress) => `query vaultByAddress {
18
+ vaultByAddress(chainId: 1, address: "${vaultAddress}") {
19
+ id,
20
+ dailyApy,
21
+ dailyApys {
22
+ apy, netApy
23
+ },
24
+ monthlyApys {
25
+ apy, netApy
26
+ },
27
+ liquidity {
28
+ underlying, usd,
29
+ },
30
+ asset {
31
+ priceUsd
32
+ }
33
+ }
34
34
  }`;
35
35
  const MORPHO_BLUE_API = 'https://blue-api.morpho.org/graphql';
36
36
  export const _getMorphoVaultData = (provider, network, morphoVault, accounts) => __awaiter(void 0, void 0, void 0, function* () {
@@ -1,4 +1,4 @@
1
- import { IncentiveData, MMAssetData, MMPositionData, MMUsedAsset, NetworkNumber } from './common';
1
+ import { IncentiveData, LeverageType, MMAssetData, MMPositionData, MMUsedAsset, NetworkNumber } from './common';
2
2
  export declare enum AaveVersions {
3
3
  AaveV1 = "v1",
4
4
  AaveV2 = "v2default",
@@ -161,14 +161,14 @@ export interface AaveV3AggregatedPositionData {
161
161
  totalInterestUsd: string;
162
162
  liqRatio: string;
163
163
  liqPercent: string;
164
- leveragedType: string;
164
+ leveragedType: LeverageType;
165
165
  leveragedAsset?: string;
166
- leveragedLsdAssetRatio?: string;
167
166
  liquidationPrice?: string;
168
167
  minCollRatio?: string;
169
168
  collLiquidationRatio?: string;
170
169
  healthRatio?: string;
171
170
  minHealthRatio?: string;
171
+ currentVolatilePairRatio?: string;
172
172
  }
173
173
  export interface AaveHelperCommon {
174
174
  usedAssets: any;
@@ -0,0 +1,137 @@
1
+ import { EthAddress, IncentiveData, LeverageType, NetworkNumber } from './common';
2
+ export declare enum AaveV4SpokesType {
3
+ AaveV4CoreSpoke = "aave_v4_core_spoke"
4
+ }
5
+ export declare enum AaveV4HubsType {
6
+ AaveV4CoreHub = "aave_v4_core_hub"
7
+ }
8
+ export interface AaveV4SpokeInfo {
9
+ chainIds: NetworkNumber[];
10
+ label: string;
11
+ value: AaveV4SpokesType;
12
+ url: string;
13
+ address: EthAddress;
14
+ hubs: EthAddress[];
15
+ }
16
+ export interface AaveV4HubInfo {
17
+ chainIds: NetworkNumber[];
18
+ label: string;
19
+ value: AaveV4HubsType;
20
+ address: EthAddress;
21
+ }
22
+ export interface AaveV4HubAssetOnChainData {
23
+ assetId: number;
24
+ drawnRate: bigint;
25
+ }
26
+ export interface AaveV4HubOnChainData {
27
+ assets: Record<number, AaveV4HubAssetOnChainData>;
28
+ }
29
+ export interface AaveV4ReserveAssetOnChain {
30
+ underlying: EthAddress;
31
+ hub: EthAddress;
32
+ assetId: number;
33
+ decimals: number;
34
+ paused: boolean;
35
+ frozen: boolean;
36
+ borrowable: boolean;
37
+ collateralRisk: number;
38
+ collateralFactor: number;
39
+ maxLiquidationBonus: number;
40
+ liquidationFee: number;
41
+ price: bigint;
42
+ totalSupplied: bigint;
43
+ totalDrawn: bigint;
44
+ totalPremium: bigint;
45
+ totalDebt: bigint;
46
+ supplyCap: bigint;
47
+ borrowCap: bigint;
48
+ deficitRay: bigint;
49
+ spokeActive: boolean;
50
+ spokePaused: boolean;
51
+ }
52
+ export interface AaveV4ReserveAssetData {
53
+ symbol: string;
54
+ underlying: EthAddress;
55
+ hub: EthAddress;
56
+ hubName: string;
57
+ assetId: number;
58
+ reserveId: number;
59
+ paused: boolean;
60
+ frozen: boolean;
61
+ borrowable: boolean;
62
+ collateralRisk: number;
63
+ collateralFactor: number;
64
+ liquidationFee: number;
65
+ price: string;
66
+ totalSupplied: string;
67
+ totalDrawn: string;
68
+ totalPremium: string;
69
+ totalDebt: string;
70
+ supplyCap: string;
71
+ borrowCap: string;
72
+ spokeActive: boolean;
73
+ spokePaused: boolean;
74
+ drawnRate: string;
75
+ supplyRate: string;
76
+ supplyIncentives: IncentiveData[];
77
+ borrowIncentives: IncentiveData[];
78
+ canBeBorrowed: boolean;
79
+ canBeSupplied: boolean;
80
+ canBeWithdrawn: boolean;
81
+ canBePayBacked: boolean;
82
+ utilization: string;
83
+ }
84
+ export type AaveV4AssetsData = Record<string, AaveV4ReserveAssetData>;
85
+ export interface AaveV4SpokeData {
86
+ assetsData: AaveV4AssetsData;
87
+ oracle: EthAddress;
88
+ oracleDecimals: number;
89
+ address: EthAddress;
90
+ }
91
+ export interface AaveV4UsedReserveAsset {
92
+ symbol: string;
93
+ hubName: string;
94
+ assetId: number;
95
+ reserveId: number;
96
+ supplied: string;
97
+ suppliedUsd: string;
98
+ drawn: string;
99
+ drawnUsd: string;
100
+ premium: string;
101
+ premiumUsd: string;
102
+ borrowed: string;
103
+ borrowedUsd: string;
104
+ isSupplied: boolean;
105
+ isBorrowed: boolean;
106
+ collateral: boolean;
107
+ collateralFactor: number;
108
+ }
109
+ export interface AaveV4AggregatedPositionData {
110
+ suppliedUsd: string;
111
+ suppliedCollateralUsd: string;
112
+ borrowLimitUsd: string;
113
+ liquidationLimitUsd: string;
114
+ borrowedUsd: string;
115
+ drawnUsd: string;
116
+ premiumUsd: string;
117
+ leftToBorrowUsd: string;
118
+ ratio: string;
119
+ collRatio: string;
120
+ liqRatio: string;
121
+ liqPercent: string;
122
+ leveragedType: LeverageType;
123
+ leveragedAsset: string;
124
+ liquidationPrice: string;
125
+ minCollRatio: string;
126
+ collLiquidationRatio: string;
127
+ minHealthRatio: string;
128
+ netApy: string;
129
+ incentiveUsd: string;
130
+ totalInterestUsd: string;
131
+ currentVolatilePairRatio?: string;
132
+ }
133
+ export type AaveV4UsedReserveAssets = Record<string, AaveV4UsedReserveAsset>;
134
+ export interface AaveV4AccountData extends AaveV4AggregatedPositionData {
135
+ usedAssets: AaveV4UsedReserveAssets;
136
+ healthFactor: string;
137
+ }
@@ -0,0 +1,8 @@
1
+ export var AaveV4SpokesType;
2
+ (function (AaveV4SpokesType) {
3
+ AaveV4SpokesType["AaveV4CoreSpoke"] = "aave_v4_core_spoke";
4
+ })(AaveV4SpokesType || (AaveV4SpokesType = {}));
5
+ export var AaveV4HubsType;
6
+ (function (AaveV4HubsType) {
7
+ AaveV4HubsType["AaveV4CoreHub"] = "aave_v4_core_hub";
8
+ })(AaveV4HubsType || (AaveV4HubsType = {}));
@@ -8,6 +8,13 @@ export declare enum IncentiveEligibilityId {
8
8
  AaveV3ArbitrumETHLSBorrow = "0x0c84331e39d6658Cd6e6b9ba04736cC4c4734351",
9
9
  AaveV3EthenaLiquidLeveragePlasma = "0x67264783f1e9a2af8627a235853057a6fc975bd2BORROW_BL"
10
10
  }
11
+ export declare enum LeverageType {
12
+ Long = "long",
13
+ Short = "short",
14
+ VolatilePair = "volatile-pair",
15
+ VolatilePairReverse = "volatile-pair-reverse",
16
+ None = ""
17
+ }
11
18
  export interface IncentiveData {
12
19
  token: string;
13
20
  apy: string;
@@ -10,6 +10,14 @@ export var IncentiveEligibilityId;
10
10
  IncentiveEligibilityId["AaveV3ArbitrumETHLSBorrow"] = "0x0c84331e39d6658Cd6e6b9ba04736cC4c4734351";
11
11
  IncentiveEligibilityId["AaveV3EthenaLiquidLeveragePlasma"] = "0x67264783f1e9a2af8627a235853057a6fc975bd2BORROW_BL";
12
12
  })(IncentiveEligibilityId || (IncentiveEligibilityId = {}));
13
+ export var LeverageType;
14
+ (function (LeverageType) {
15
+ LeverageType["Long"] = "long";
16
+ LeverageType["Short"] = "short";
17
+ LeverageType["VolatilePair"] = "volatile-pair";
18
+ LeverageType["VolatilePairReverse"] = "volatile-pair-reverse";
19
+ LeverageType["None"] = "";
20
+ })(LeverageType || (LeverageType = {}));
13
21
  export var NetworkNumber;
14
22
  (function (NetworkNumber) {
15
23
  NetworkNumber[NetworkNumber["Eth"] = 1] = "Eth";
@@ -1,4 +1,4 @@
1
- import { EthAddress, MMAssetData, MMPositionData, MMUsedAsset, NetworkNumber } from './common';
1
+ import { EthAddress, LeverageType, MMAssetData, MMPositionData, MMUsedAsset, NetworkNumber } from './common';
2
2
  export declare enum CompoundVersions {
3
3
  'CompoundV2' = "v2",
4
4
  'CompoundV3USDC' = "v3-USDC",
@@ -94,9 +94,9 @@ export interface CompoundAggregatedPositionData {
94
94
  totalInterestUsd: string;
95
95
  liqRatio: string;
96
96
  liqPercent: string;
97
- leveragedType: string;
97
+ leveragedType: LeverageType;
98
98
  leveragedAsset?: string;
99
- leveragedLsdAssetRatio?: string;
99
+ currentVolatilePairRatio?: string;
100
100
  liquidationPrice?: string;
101
101
  minRatio: string;
102
102
  debtTooLow: boolean;
@@ -1,4 +1,4 @@
1
- import { EthAddress, NetworkNumber } from './common';
1
+ import { EthAddress, LeverageType, NetworkNumber } from './common';
2
2
  export declare enum CrvUSDVersions {
3
3
  'crvUSDwstETH' = "wstETH",
4
4
  'crvUSDWBTC' = "WBTC",
@@ -71,7 +71,7 @@ export interface CrvUSDAggregatedPositionData {
71
71
  borrowLimitUsd: string;
72
72
  minAllowedRatio: number;
73
73
  collFactor: string;
74
- leveragedType: string;
74
+ leveragedType: LeverageType;
75
75
  leveragedAsset?: string;
76
76
  liquidationPrice?: string;
77
77
  }
@@ -1,4 +1,4 @@
1
- import { EthAddress, IncentiveData, MMPositionData, NetworkNumber } from './common';
1
+ import { EthAddress, IncentiveData, LeverageType, MMPositionData, NetworkNumber } from './common';
2
2
  export declare enum EulerV2Versions {
3
3
  eUSDC2 = "eUSDC-2",
4
4
  eWETH2 = "eWETH-2"
@@ -141,9 +141,9 @@ export interface EulerV2AggregatedPositionData {
141
141
  totalInterestUsd: string;
142
142
  liqRatio: string;
143
143
  liqPercent: string;
144
- leveragedType: string;
144
+ leveragedType: LeverageType;
145
145
  leveragedAsset?: string;
146
- leveragedLsdAssetRatio?: string;
146
+ currentVolatilePairRatio?: string;
147
147
  liquidationPrice?: string;
148
148
  minRatio: string;
149
149
  minDebt: string;
@@ -1,4 +1,4 @@
1
- import { EthAddress, IncentiveData, NetworkNumber } from './common';
1
+ import { EthAddress, IncentiveData, LeverageType, NetworkNumber } from './common';
2
2
  export interface FluidMarketInfo {
3
3
  chainIds: number[];
4
4
  label: string;
@@ -323,10 +323,10 @@ export interface FluidAggregatedVaultData {
323
323
  collRatio: string;
324
324
  minRatio: string;
325
325
  totalInterestUsd: string;
326
- leveragedType?: string;
326
+ leveragedType?: LeverageType;
327
327
  leveragedAsset?: string;
328
328
  liquidationPrice?: string;
329
- leveragedLsdAssetRatio?: string;
329
+ currentVolatilePairRatio?: string;
330
330
  minCollRatio?: string;
331
331
  collLiquidationRatio?: string;
332
332
  }
@@ -1,4 +1,4 @@
1
- import { NetworkNumber } from './common';
1
+ import { NetworkNumber, } from './common';
2
2
  export var FluidMainnetVersion;
3
3
  (function (FluidMainnetVersion) {
4
4
  FluidMainnetVersion["FLUID_ETH_USDC_1"] = "FLUID_ETH_USDC_1";
@@ -13,3 +13,5 @@ export * from './portfolio';
13
13
  export * from './merit';
14
14
  export * from './merkl';
15
15
  export * from './savings';
16
+ export * from './common';
17
+ export * from './aaveV4';
@@ -13,3 +13,5 @@ export * from './portfolio';
13
13
  export * from './merit';
14
14
  export * from './merkl';
15
15
  export * from './savings';
16
+ export * from './common';
17
+ export * from './aaveV4';
@@ -1,4 +1,4 @@
1
- import { EthAddress, IncentiveData, NetworkNumber } from './common';
1
+ import { EthAddress, IncentiveData, LeverageType, NetworkNumber } from './common';
2
2
  export declare enum LiquityV2Versions {
3
3
  LiquityV2Eth = "liquityv2eth",
4
4
  LiquityV2WstEth = "liquityv2wsteth",
@@ -88,7 +88,7 @@ export interface LiquityV2AggregatedTroveData {
88
88
  netApy: string;
89
89
  incentiveUsd: string;
90
90
  totalInterestUsd: string;
91
- leveragedType: string;
91
+ leveragedType: LeverageType;
92
92
  leveragedAsset: string;
93
93
  liquidationPrice: string;
94
94
  ratio: string;
@@ -110,7 +110,7 @@ export interface LiquityV2TroveData {
110
110
  totalInterestUsd: string;
111
111
  interestBatchManager: EthAddress;
112
112
  troveStatus: string;
113
- leveragedType: string;
113
+ leveragedType: LeverageType;
114
114
  leveragedAsset: string;
115
115
  liquidationPrice: string;
116
116
  debtInFront: string;
@@ -1,4 +1,4 @@
1
- import { EthAddress, IncentiveData, NetworkNumber } from './common';
1
+ import { EthAddress, IncentiveData, LeverageType, NetworkNumber } from './common';
2
2
  import { BandData, UserBandData } from './curveUsd';
3
3
  export declare enum LLVersionsEth {
4
4
  LLWstethCrvusd = "llamaLendwstETHcrvUSD",
@@ -112,7 +112,7 @@ export interface LlamaLendAggregatedPositionData {
112
112
  borrowLimitUsd: string;
113
113
  minAllowedRatio: number;
114
114
  collFactor: string;
115
- leveragedType: string;
115
+ leveragedType: LeverageType;
116
116
  leveragedAsset?: string;
117
117
  liquidationPrice?: string;
118
118
  netApy: string;
@@ -1,4 +1,4 @@
1
- import { EthAddress, IncentiveData, MMUsedAssets, NetworkNumber } from './common';
1
+ import { EthAddress, IncentiveData, LeverageType, MMUsedAssets, NetworkNumber } from './common';
2
2
  export declare enum MorphoBlueVersions {
3
3
  MorphoBlueWstEthUSDC = "morphobluewstethusdc",// wstETH/USDC
4
4
  MorphoBlueSDAIUSDC = "morphobluesdaiusdc",// sDAI/USDC
@@ -121,9 +121,9 @@ export interface MorphoBlueAggregatedPositionData {
121
121
  totalInterestUsd: string;
122
122
  ltv: string;
123
123
  ratio: string;
124
- leveragedType: string;
124
+ leveragedType: LeverageType;
125
125
  leveragedAsset?: string;
126
- leveragedLsdAssetRatio?: string;
126
+ currentVolatilePairRatio?: string;
127
127
  liquidationPrice?: string;
128
128
  minCollRatio?: string;
129
129
  collLiquidationRatio?: string;
@@ -142,9 +142,9 @@ export interface MorphoBluePositionData {
142
142
  totalInterestUsd: string;
143
143
  ltv: string;
144
144
  ratio: string;
145
- leveragedType: string;
145
+ leveragedType: LeverageType;
146
146
  leveragedAsset?: string;
147
- leveragedLsdAssetRatio?: string;
147
+ currentVolatilePairRatio?: string;
148
148
  liquidationPrice?: string;
149
149
  supplyShares: string;
150
150
  borrowShares: string;
@@ -1,4 +1,5 @@
1
1
  import { AaveV2PositionData, AaveV3PositionData, AaveVersions } from './aave';
2
+ import { AaveV4AccountData, AaveV4SpokesType } from './aaveV4';
2
3
  import { EthAddress } from './common';
3
4
  import { CompoundV2PositionData, CompoundV3PositionData, CompoundVersions } from './compound';
4
5
  import { CrvUSDUserData, CrvUSDVersions } from './curveUsd';
@@ -51,6 +52,9 @@ export interface PortfolioPositionsDataForAddress {
51
52
  [key: string]: FluidVaultData;
52
53
  };
53
54
  };
55
+ aaveV4: {
56
+ [key in AaveV4SpokesType]?: PortfolioProtocolData<AaveV4AccountData>;
57
+ };
54
58
  }
55
59
  export interface PortfolioPositionsData {
56
60
  [key: EthAddress]: PortfolioPositionsDataForAddress;