@defisaver/positions-sdk 2.1.161-portfolio-api-1-dev → 2.1.161-portfolio-api-3-dev

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 (193) hide show
  1. package/cjs/aaveV2/index.js +2 -0
  2. package/cjs/aaveV3/index.d.ts +41 -12
  3. package/cjs/aaveV3/index.js +237 -2
  4. package/cjs/aaveV3/sgho.d.ts +2 -16
  5. package/cjs/aaveV4/lend.d.ts +2 -43
  6. package/cjs/claiming/aaveV3.d.ts +2 -2
  7. package/cjs/claiming/ethena.d.ts +2 -1
  8. package/cjs/claiming/king.d.ts +2 -1
  9. package/cjs/claiming/spark.d.ts +2 -2
  10. package/cjs/curveUsd/index.d.ts +5 -2
  11. package/cjs/curveUsd/index.js +30 -15
  12. package/cjs/fluid/index.d.ts +10 -49
  13. package/cjs/fluid/index.js +36 -1
  14. package/cjs/helpers/aaveHelpers/index.d.ts +9 -1
  15. package/cjs/helpers/aaveHelpers/index.js +26 -6
  16. package/cjs/helpers/aaveV4Helpers/index.js +1 -0
  17. package/cjs/helpers/compoundHelpers/index.js +2 -0
  18. package/cjs/helpers/curveUsdHelpers/index.d.ts +3 -1
  19. package/cjs/helpers/curveUsdHelpers/index.js +15 -2
  20. package/cjs/helpers/fluidHelpers/index.js +1 -0
  21. package/cjs/helpers/liquityV2Helpers/index.js +1 -0
  22. package/cjs/helpers/llamaLendHelpers/index.js +1 -0
  23. package/cjs/helpers/makerHelpers/index.d.ts +1 -1
  24. package/cjs/helpers/makerHelpers/index.js +2 -2
  25. package/cjs/helpers/morphoBlueHelpers/index.js +2 -0
  26. package/cjs/helpers/morphoMidnightHelpers/index.js +2 -0
  27. package/cjs/helpers/sparkHelpers/index.js +1 -0
  28. package/cjs/liquity/index.d.ts +2 -12
  29. package/cjs/liquity/index.js +15 -2
  30. package/cjs/liquityV2/index.d.ts +8 -23
  31. package/cjs/liquityV2/index.js +37 -19
  32. package/cjs/maker/index.d.ts +7 -2
  33. package/cjs/maker/index.js +44 -12
  34. package/cjs/markets/index.d.ts +1 -0
  35. package/cjs/markets/index.js +3 -1
  36. package/cjs/markets/maker/index.d.ts +1 -0
  37. package/cjs/markets/maker/index.js +13 -0
  38. package/cjs/moneymarket/moneymarketCommonService.d.ts +9 -0
  39. package/cjs/moneymarket/moneymarketCommonService.js +13 -1
  40. package/cjs/portfolio/index.d.ts +17 -5
  41. package/cjs/portfolio/index.js +583 -381
  42. package/cjs/portfolio/lendingProtocols.d.ts +184 -0
  43. package/cjs/portfolio/lendingProtocols.js +196 -0
  44. package/cjs/savings/index.d.ts +8 -2
  45. package/cjs/savings/index.js +37 -5
  46. package/cjs/savings/morphoVaults/index.d.ts +1 -1
  47. package/cjs/savings/morphoVaults/index.js +56 -18
  48. package/cjs/savings/morphoVaults/options.d.ts +2 -0
  49. package/cjs/savings/morphoVaults/options.js +61 -1
  50. package/cjs/spark/index.js +1 -0
  51. package/cjs/staking/staking.d.ts +20 -0
  52. package/cjs/staking/staking.js +19 -1
  53. package/cjs/types/aave.d.ts +86 -0
  54. package/cjs/types/aaveV4.d.ts +45 -0
  55. package/cjs/types/compound.d.ts +2 -0
  56. package/cjs/types/curveUsd.d.ts +6 -0
  57. package/cjs/types/fluid.d.ts +14 -0
  58. package/cjs/types/index.d.ts +1 -0
  59. package/cjs/types/index.js +1 -0
  60. package/cjs/types/liquity.d.ts +16 -0
  61. package/cjs/types/liquityV2.d.ts +26 -0
  62. package/cjs/types/maker.d.ts +4 -0
  63. package/cjs/types/morphoBlue.d.ts +2 -0
  64. package/cjs/types/morphoMidnight.d.ts +1 -0
  65. package/cjs/types/portfolio.d.ts +127 -6
  66. package/cjs/types/savings/index.d.ts +9 -1
  67. package/cjs/types/savings/morphoVaults.d.ts +10 -2
  68. package/cjs/types/savings/morphoVaults.js +9 -1
  69. package/cjs/types/spark.d.ts +2 -0
  70. package/cjs/umbrella/index.d.ts +2 -3
  71. package/esm/aaveV2/index.js +2 -0
  72. package/esm/aaveV3/index.d.ts +41 -12
  73. package/esm/aaveV3/index.js +231 -2
  74. package/esm/aaveV3/sgho.d.ts +2 -16
  75. package/esm/aaveV4/lend.d.ts +2 -43
  76. package/esm/claiming/aaveV3.d.ts +2 -2
  77. package/esm/claiming/aaveV3.js +1 -1
  78. package/esm/claiming/ethena.d.ts +2 -1
  79. package/esm/claiming/king.d.ts +2 -1
  80. package/esm/claiming/spark.d.ts +2 -2
  81. package/esm/claiming/spark.js +1 -1
  82. package/esm/curveUsd/index.d.ts +5 -2
  83. package/esm/curveUsd/index.js +30 -15
  84. package/esm/fluid/index.d.ts +10 -49
  85. package/esm/fluid/index.js +33 -0
  86. package/esm/helpers/aaveHelpers/index.d.ts +9 -1
  87. package/esm/helpers/aaveHelpers/index.js +23 -5
  88. package/esm/helpers/aaveV4Helpers/index.js +1 -0
  89. package/esm/helpers/compoundHelpers/index.js +2 -0
  90. package/esm/helpers/curveUsdHelpers/index.d.ts +3 -1
  91. package/esm/helpers/curveUsdHelpers/index.js +16 -3
  92. package/esm/helpers/fluidHelpers/index.js +1 -0
  93. package/esm/helpers/liquityV2Helpers/index.js +1 -0
  94. package/esm/helpers/llamaLendHelpers/index.js +2 -1
  95. package/esm/helpers/makerHelpers/index.d.ts +1 -1
  96. package/esm/helpers/makerHelpers/index.js +2 -2
  97. package/esm/helpers/morphoBlueHelpers/index.js +2 -0
  98. package/esm/helpers/morphoMidnightHelpers/index.js +2 -0
  99. package/esm/helpers/sparkHelpers/index.js +1 -0
  100. package/esm/liquity/index.d.ts +2 -12
  101. package/esm/liquity/index.js +16 -3
  102. package/esm/liquityV2/index.d.ts +8 -23
  103. package/esm/liquityV2/index.js +35 -18
  104. package/esm/maker/index.d.ts +7 -2
  105. package/esm/maker/index.js +44 -14
  106. package/esm/markets/index.d.ts +1 -0
  107. package/esm/markets/index.js +1 -0
  108. package/esm/markets/maker/index.d.ts +1 -0
  109. package/esm/markets/maker/index.js +10 -0
  110. package/esm/moneymarket/moneymarketCommonService.d.ts +9 -0
  111. package/esm/moneymarket/moneymarketCommonService.js +11 -0
  112. package/esm/portfolio/index.d.ts +17 -5
  113. package/esm/portfolio/index.js +584 -385
  114. package/esm/portfolio/lendingProtocols.d.ts +184 -0
  115. package/esm/portfolio/lendingProtocols.js +189 -0
  116. package/esm/savings/index.d.ts +8 -2
  117. package/esm/savings/index.js +35 -4
  118. package/esm/savings/morphoVaults/index.d.ts +1 -1
  119. package/esm/savings/morphoVaults/index.js +57 -19
  120. package/esm/savings/morphoVaults/options.d.ts +2 -0
  121. package/esm/savings/morphoVaults/options.js +61 -1
  122. package/esm/spark/index.js +1 -0
  123. package/esm/staking/staking.d.ts +20 -0
  124. package/esm/staking/staking.js +17 -0
  125. package/esm/types/aave.d.ts +86 -0
  126. package/esm/types/aaveV4.d.ts +45 -0
  127. package/esm/types/compound.d.ts +2 -0
  128. package/esm/types/curveUsd.d.ts +6 -0
  129. package/esm/types/fluid.d.ts +14 -0
  130. package/esm/types/index.d.ts +1 -0
  131. package/esm/types/index.js +1 -0
  132. package/esm/types/liquity.d.ts +16 -0
  133. package/esm/types/liquityV2.d.ts +26 -0
  134. package/esm/types/maker.d.ts +4 -0
  135. package/esm/types/morphoBlue.d.ts +2 -0
  136. package/esm/types/morphoMidnight.d.ts +1 -0
  137. package/esm/types/portfolio.d.ts +127 -6
  138. package/esm/types/savings/index.d.ts +9 -1
  139. package/esm/types/savings/morphoVaults.d.ts +10 -2
  140. package/esm/types/savings/morphoVaults.js +8 -0
  141. package/esm/types/spark.d.ts +2 -0
  142. package/esm/umbrella/index.d.ts +2 -3
  143. package/package.json +3 -2
  144. package/src/aaveV2/index.ts +2 -0
  145. package/src/aaveV3/index.ts +293 -2
  146. package/src/aaveV3/sgho.ts +2 -17
  147. package/src/aaveV4/lend.ts +2 -48
  148. package/src/claiming/aaveV3.ts +4 -2
  149. package/src/claiming/ethena.ts +5 -5
  150. package/src/claiming/king.ts +3 -3
  151. package/src/claiming/spark.ts +6 -4
  152. package/src/curveUsd/index.ts +33 -16
  153. package/src/fluid/index.ts +44 -3
  154. package/src/helpers/aaveHelpers/index.ts +27 -7
  155. package/src/helpers/aaveV4Helpers/index.ts +1 -0
  156. package/src/helpers/compoundHelpers/index.ts +2 -0
  157. package/src/helpers/curveUsdHelpers/index.ts +23 -3
  158. package/src/helpers/fluidHelpers/index.ts +1 -0
  159. package/src/helpers/liquityV2Helpers/index.ts +1 -0
  160. package/src/helpers/llamaLendHelpers/index.ts +2 -1
  161. package/src/helpers/makerHelpers/index.ts +2 -1
  162. package/src/helpers/morphoBlueHelpers/index.ts +2 -0
  163. package/src/helpers/morphoMidnightHelpers/index.ts +2 -0
  164. package/src/helpers/sparkHelpers/index.ts +1 -0
  165. package/src/liquity/index.ts +19 -5
  166. package/src/liquityV2/index.ts +48 -22
  167. package/src/maker/index.ts +77 -30
  168. package/src/markets/index.ts +2 -1
  169. package/src/markets/maker/index.ts +10 -0
  170. package/src/moneymarket/moneymarketCommonService.ts +15 -0
  171. package/src/portfolio/index.ts +477 -248
  172. package/src/portfolio/lendingProtocols.ts +281 -0
  173. package/src/savings/index.ts +45 -5
  174. package/src/savings/morphoVaults/index.ts +73 -21
  175. package/src/savings/morphoVaults/options.ts +67 -1
  176. package/src/spark/index.ts +1 -0
  177. package/src/staking/staking.ts +28 -0
  178. package/src/types/aave.ts +90 -0
  179. package/src/types/aaveV4.ts +50 -0
  180. package/src/types/compound.ts +2 -0
  181. package/src/types/curveUsd.ts +7 -0
  182. package/src/types/fluid.ts +15 -0
  183. package/src/types/index.ts +2 -1
  184. package/src/types/liquity.ts +19 -1
  185. package/src/types/liquityV2.ts +28 -1
  186. package/src/types/maker.ts +6 -0
  187. package/src/types/morphoBlue.ts +2 -0
  188. package/src/types/morphoMidnight.ts +1 -0
  189. package/src/types/portfolio.ts +153 -7
  190. package/src/types/savings/index.ts +12 -1
  191. package/src/types/savings/morphoVaults.ts +11 -1
  192. package/src/types/spark.ts +2 -0
  193. package/src/umbrella/index.ts +2 -1
@@ -1,20 +1,47 @@
1
- import { AaveV2MarketData, AaveV2PositionData, AaveV3MarketData, AaveV3PositionData, AaveVersions } from './aave';
1
+ import { AaveV2MarketData, AaveV2PositionData, AaveV3MarketData, AaveV3PositionData, AaveVersions, StakeAaveData, UmbrellaStakingData } from './aave';
2
2
  import { AaveV4AccountData, AaveV4SpokeData, AaveV4SpokesType } from './aaveV4';
3
+ import { AaveRewardsClaimableToken, EthenaAirdropClaimableToken, KingRewardsClaimableToken, MerklRewardsClaimableToken, SparkAirdropClaimableToken, SparkRewardsClaimableToken, UniswapAirdropClaimableToken } from './claiming';
3
4
  import { EthAddress } from './common';
4
5
  import { CompoundV2MarketsData, CompoundV2PositionData, CompoundV3MarketsData, CompoundV3PositionData, CompoundVersions } from './compound';
5
6
  import { CrvUSDGlobalMarketData, CrvUSDUserData, CrvUSDVersions } from './curveUsd';
6
- import { FluidVaultData } from './fluid';
7
- import { LiquityTroveInfo } from './liquity';
8
- import { LiquityV2MarketData } from './liquityV2';
7
+ import { FluidEarnPositionData, FluidMarketData, FluidVaultData } from './fluid';
8
+ import { LiquityStakingData, LiquityTroveInfo } from './liquity';
9
+ import { LiquityV2MarketData, LiquityV2SBoldYBoldData, LiquityV2StakingData, LiquityV2TroveData, LiquityV2Versions } from './liquityV2';
9
10
  import { LlamaLendGlobalMarketData, LlamaLendUserData, LlamaLendVersionsType } from './llamaLend';
10
- import { CdpData } from './maker';
11
- import { MorphoBlueMarketInfo, MorphoBluePositionData, MorphoBlueVersions } from './morphoBlue';
11
+ import { CdpData, IlkInfo } from './maker';
12
+ import { MorphoBlueEarnData, MorphoBlueMarketInfo, MorphoBluePositionData, MorphoBlueVersions } from './morphoBlue';
12
13
  import { MorphoMidnightMarketInfo, MorphoMidnightPositionData, MorphoMidnightVersions } from './morphoMidnight';
13
14
  import { SparkMarketsData, SparkPositionData, SparkVersions } from './spark';
14
15
  export interface PortfolioProtocolData<T> {
15
16
  error: string;
16
17
  data: T | null;
17
18
  }
19
+ /** A failed fetch of a protocol that, when it succeeds, getPortfolioData returns unwrapped rather than as `{ error, data }`. */
20
+ export interface PortfolioProtocolError {
21
+ error: string;
22
+ data: null;
23
+ }
24
+ /** What getPortfolioData reads besides markets. */
25
+ export interface PortfolioDataOptions {
26
+ /** positions (lending); default true. With false it comes back as {} and no lending position is read. */
27
+ positions?: boolean;
28
+ /** stakingPositions; default true. With false it comes back as {} and no staking source is read. */
29
+ staking?: boolean;
30
+ /** rewardsData; default true. With false it comes back as {} and no rewards source is read. */
31
+ rewards?: boolean;
32
+ /**
33
+ * Liquity V2 troves in positions[address].liquityV2; default false, as the DeFi Saver app reads them on its own.
34
+ * Mainnet only: elsewhere liquityV2 is {}. Needs positions.
35
+ */
36
+ liquityV2?: boolean;
37
+ }
38
+ /** One Liquity V2 market's troves of an address, by trove id — with an error when the ids or any trove failed to load. */
39
+ export interface PortfolioLiquityV2Troves {
40
+ error: string;
41
+ data: {
42
+ [troveId: string]: LiquityV2TroveData;
43
+ };
44
+ }
18
45
  export interface PortfolioPositionsDataForAddress {
19
46
  aaveV3: {
20
47
  [key in AaveVersions]?: PortfolioProtocolData<AaveV3PositionData>;
@@ -56,10 +83,64 @@ export interface PortfolioPositionsDataForAddress {
56
83
  aaveV4: {
57
84
  [key in AaveV4SpokesType]?: PortfolioProtocolData<AaveV4AccountData>;
58
85
  };
86
+ /** Only with the liquityV2 option. Every trove the address holds, by market. */
87
+ liquityV2?: {
88
+ [key in LiquityV2Versions]?: PortfolioLiquityV2Troves;
89
+ };
59
90
  }
60
91
  export interface PortfolioPositionsData {
61
92
  [key: EthAddress]: PortfolioPositionsDataForAddress;
62
93
  }
94
+ /**
95
+ * The staking positions getPortfolioData returns for an address. The shapes are uneven, and the DeFi Saver app
96
+ * parses them as they are: a protocol read once per address comes back unwrapped on success, as
97
+ * `{ error, data: null }` on failure, and as {} (or Fluid's `{ error: '', data: {} }`) on a network it is not read on.
98
+ */
99
+ export interface PortfolioStakingPositionsDataForAddress {
100
+ /** stkAAVE, stkGHO and sGHO; mainnet only. */
101
+ aaveV3: StakeAaveData | PortfolioProtocolError | {};
102
+ /** Morpho Blue supply without a borrow (Earn), by market; only markets with a deposit or an error. */
103
+ morphoBlue: {
104
+ [key in MorphoBlueVersions]?: PortfolioProtocolData<MorphoBlueEarnData>;
105
+ };
106
+ compoundV3: Record<string, never>;
107
+ spark: Record<string, never>;
108
+ aaveV2: Record<string, never>;
109
+ compoundV2: Record<string, never>;
110
+ /** LQTY staking and the LUSD stability pool; mainnet only. */
111
+ liquity: LiquityStakingData | PortfolioProtocolError | {};
112
+ /** Stability pool deposits, by market; mainnet only, legacy markets left out. */
113
+ liquityV2: {
114
+ [key in LiquityV2Versions]?: PortfolioProtocolData<LiquityV2StakingData>;
115
+ };
116
+ /** Fluid lending (fToken) deposits; `{ error: '', data: {} }` on a network without Fluid. */
117
+ fluid: FluidEarnPositionData[] | PortfolioProtocolError | {
118
+ error: string;
119
+ data: Record<string, never>;
120
+ };
121
+ /** Umbrella stakes; absent off mainnet. */
122
+ umbrella?: UmbrellaStakingData | PortfolioProtocolError;
123
+ /** sBOLD, yBOLD and stYBOLD; data is null off mainnet. */
124
+ liquityV2SBoldYBold: PortfolioProtocolData<LiquityV2SBoldYBoldData>;
125
+ }
126
+ export type PortfolioStakingPositionsData = Record<EthAddress, PortfolioStakingPositionsDataForAddress>;
127
+ /** The claimable rewards getPortfolioData returns for an address. Off mainnet only Merkl and Aave V3 are read. */
128
+ export interface PortfolioRewardsDataForAddress {
129
+ merkl: PortfolioProtocolData<MerklRewardsClaimableToken[]>;
130
+ aaveV3: {
131
+ [key in AaveVersions]?: PortfolioProtocolData<AaveRewardsClaimableToken[]>;
132
+ };
133
+ spark: {
134
+ [key in SparkVersions]?: PortfolioProtocolData<SparkRewardsClaimableToken[]>;
135
+ };
136
+ /** The SPK airdrop. */
137
+ spk: PortfolioProtocolData<SparkAirdropClaimableToken[]>;
138
+ king: PortfolioProtocolData<KingRewardsClaimableToken[]>;
139
+ /** {} off mainnet. */
140
+ ethena: PortfolioProtocolData<EthenaAirdropClaimableToken[]> | {};
141
+ uniswap: PortfolioProtocolData<UniswapAirdropClaimableToken[]>;
142
+ }
143
+ export type PortfolioRewardsData = Record<EthAddress, PortfolioRewardsDataForAddress>;
63
144
  /** The `markets` getPortfolioData returns: every market it read, by protocol, keyed by market or spoke. */
64
145
  export interface PortfolioMarketsData {
65
146
  morphoMarketsData: Record<string, MorphoBlueMarketInfo>;
@@ -74,3 +155,43 @@ export interface PortfolioMarketsData {
74
155
  liquityV2MarketsData: Record<string, LiquityV2MarketData>;
75
156
  aaveV4SpokesData: Record<string, AaveV4SpokeData>;
76
157
  }
158
+ /**
159
+ * The `markets` getShifterPortfolioData returns: the portfolio's markets, plus Fluid's and Maker's, which the shifter
160
+ * offers as destinations. Kept apart from PortfolioMarketsData, which getPortfolioData does not fill these into.
161
+ */
162
+ export interface ShifterPortfolioMarketsData extends PortfolioMarketsData {
163
+ fluidMarketsData: Record<string, FluidMarketData>;
164
+ makerMarketsData: Record<string, IlkInfo>;
165
+ }
166
+ /** The markets that could not be read, by their key in PortfolioMarketsData, then by market or spoke: the error. */
167
+ export type PortfolioMarketsErrors = {
168
+ [key in keyof PortfolioMarketsData]?: Record<string, string>;
169
+ };
170
+ /**
171
+ * What the portfolio fetch could not read and has no `{ error, data }` entry of its own to report it in. A key is
172
+ * present only when something under it failed; {} when everything was read.
173
+ */
174
+ export interface PortfolioErrors {
175
+ /** Markets missing from `markets`; every position on such a market is an entry with an error. */
176
+ markets?: PortfolioMarketsErrors;
177
+ /** Addresses whose Maker vault list could not be read: their `maker` is {}, which would otherwise read as "no vaults". */
178
+ makerCdps?: Record<EthAddress, string>;
179
+ }
180
+ /** getPortfolioMarketsData's result. */
181
+ export interface PortfolioMarketsResult {
182
+ /** Every market read; one that failed is missing and named in `errors`. */
183
+ markets: PortfolioMarketsData;
184
+ errors: PortfolioMarketsErrors;
185
+ }
186
+ /** getPortfolioUserData's result: what is read per address. */
187
+ export interface PortfolioUserData {
188
+ positions: PortfolioPositionsData;
189
+ stakingPositions: PortfolioStakingPositionsData;
190
+ rewardsData: PortfolioRewardsData;
191
+ errors: Pick<PortfolioErrors, 'makerCdps'>;
192
+ }
193
+ /** getPortfolioData's result. */
194
+ export interface PortfolioData extends Omit<PortfolioUserData, 'errors'> {
195
+ markets: PortfolioMarketsData;
196
+ errors: PortfolioErrors;
197
+ }
@@ -20,4 +20,12 @@ export interface SavingsVaultData {
20
20
  asset: string;
21
21
  optionType: string;
22
22
  }
23
- export type SavingsData = Partial<Record<MorphoVaultType | YearnVaultType | MakerDsrType | SkySavingsType | SparkSavingsVaultType | SummerVaultType | YearnV3VaultType, SavingsVaultData>>;
23
+ /** The key of every savings vault getSavingsData reads. */
24
+ export type SavingsVaultKey = MorphoVaultType | YearnVaultType | MakerDsrType | SkySavingsType | SparkSavingsVaultType | SummerVaultType | YearnV3VaultType;
25
+ export type SavingsData = Partial<Record<SavingsVaultKey, SavingsVaultData>>;
26
+ /** Why each vault that was read for a network came back without data. */
27
+ export type SavingsErrors = Partial<Record<SavingsVaultKey, string>>;
28
+ export interface SavingsDataWithErrors {
29
+ data: SavingsData;
30
+ errors: SavingsErrors;
31
+ }
@@ -1,4 +1,4 @@
1
- import { EthAddress } from '../common';
1
+ import { EthAddress, NetworkNumber } from '../common';
2
2
  export declare enum MorphoVaultType {
3
3
  MorphoVaultFlagshipEth = "morpho_vault_flagship_eth",
4
4
  MorphoVaultGauntletUSDCCore = "morpho_vault_gauntlet_usdc_core",
@@ -17,13 +17,21 @@ export declare enum MorphoVaultType {
17
17
  MorphoVaultSteakhousePYUSD = "morpho_vault_steakhouse_pyusd",
18
18
  MorphoVaultSmokehouseUSDT = "morpho_vault_smokehouse_usdt",
19
19
  MorphoVaultSmokehouseUSDC = "morpho_vault_smokehouse_usdc",
20
- MorphoVaultSmokehouseDAI = "morpho_vault_smokehouse_dai"
20
+ MorphoVaultSmokehouseDAI = "morpho_vault_smokehouse_dai",
21
+ MorphoVaultGauntletUSDGPremium = "morpho_vault_gauntlet_usdg_premium",
22
+ MorphoVaultSteakhouseUSDGPro = "morpho_vault_steakhouse_usdg_pro"
23
+ }
24
+ export declare enum MorphoVaultVersion {
25
+ V1 = 1,
26
+ V2 = 2
21
27
  }
22
28
  export interface MorphoVault {
23
29
  type: MorphoVaultType;
24
30
  name: string;
25
31
  address: EthAddress;
26
32
  asset: string;
33
+ network: NetworkNumber;
34
+ version: MorphoVaultVersion;
27
35
  deploymentBlock: number;
28
36
  isLegacy: boolean;
29
37
  }
@@ -20,4 +20,12 @@ export var MorphoVaultType;
20
20
  MorphoVaultType["MorphoVaultSmokehouseUSDT"] = "morpho_vault_smokehouse_usdt";
21
21
  MorphoVaultType["MorphoVaultSmokehouseUSDC"] = "morpho_vault_smokehouse_usdc";
22
22
  MorphoVaultType["MorphoVaultSmokehouseDAI"] = "morpho_vault_smokehouse_dai";
23
+ // Vault V2
24
+ MorphoVaultType["MorphoVaultGauntletUSDGPremium"] = "morpho_vault_gauntlet_usdg_premium";
25
+ MorphoVaultType["MorphoVaultSteakhouseUSDGPro"] = "morpho_vault_steakhouse_usdg_pro";
23
26
  })(MorphoVaultType || (MorphoVaultType = {}));
27
+ export var MorphoVaultVersion;
28
+ (function (MorphoVaultVersion) {
29
+ MorphoVaultVersion[MorphoVaultVersion["V1"] = 1] = "V1";
30
+ MorphoVaultVersion[MorphoVaultVersion["V2"] = 2] = "V2";
31
+ })(MorphoVaultVersion || (MorphoVaultVersion = {}));
@@ -100,6 +100,7 @@ export interface SparkAggregatedPositionData {
100
100
  leftToBorrowUsd: string;
101
101
  ratio: string;
102
102
  collRatio: string;
103
+ safetyRatio: string;
103
104
  netApy: string;
104
105
  incentiveUsd: string;
105
106
  totalInterestUsd: string;
@@ -124,6 +125,7 @@ export interface SparkPositionData extends MMPositionData, SparkPositionAggregat
124
125
  ratio: string;
125
126
  minRatio: string;
126
127
  collRatio: string;
128
+ safetyRatio?: string;
127
129
  suppliedUsd: string;
128
130
  borrowedUsd: string;
129
131
  borrowLimitUsd: string;
@@ -1,5 +1,4 @@
1
1
  import { Client } from 'viem';
2
2
  import { EthAddress, NetworkNumber } from '../types/common';
3
- export declare const getUmbrellaData: (provider: Client, network: NetworkNumber, address: EthAddress) => Promise<{
4
- [k: string]: any;
5
- }>;
3
+ import { UmbrellaStakingData } from '../types/aave';
4
+ export declare const getUmbrellaData: (provider: Client, network: NetworkNumber, address: EthAddress) => Promise<UmbrellaStakingData>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defisaver/positions-sdk",
3
- "version": "2.1.161-portfolio-api-1-dev",
3
+ "version": "2.1.161-portfolio-api-3-dev",
4
4
  "description": "",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
@@ -18,7 +18,8 @@
18
18
  "version-bump": "git commit -am \"Version bump to $(npm version patch | cut -c 2-)\""
19
19
  },
20
20
  "keywords": [],
21
- "author": "",
21
+ "author": "DeFi Saver",
22
+ "repository": "https://github.com/defisaver/defisaver-positions-sdk",
22
23
  "license": "ISC",
23
24
  "dependencies": {
24
25
  "@defisaver/tokens": "^1.7.45",
@@ -210,6 +210,8 @@ export const _getAaveV2AccountData = async (provider: Client, network: NetworkNu
210
210
  payload.collRatio = payload.borrowedUsd && payload.borrowedUsd !== '0'
211
211
  ? new Dec(payload.suppliedCollateralUsd).div(payload.borrowedUsd).mul(100).toString()
212
212
  : '0';
213
+ // Aave v2 has no LTV-0 fallback (AaveV3View only), so its safety ratio is the plain ratio.
214
+ payload.safetyRatio = payload.ratio;
213
215
 
214
216
  // Calculate borrow limits per asset
215
217
  Object.values(payload.usedAssets).forEach((item) => {
@@ -6,6 +6,7 @@ import {
6
6
  AaveIncentivesControllerViem,
7
7
  AaveV3ViewContractViem,
8
8
  createViemContractFromConfigFunc,
9
+ getConfigContractAbi,
9
10
  StkAAVEViem,
10
11
  } from '../contracts';
11
12
  import { aaveAnyGetAggregatedPositionData, aaveV3IsInIsolationMode, aaveV3IsInSiloedMode } from '../helpers/aaveHelpers';
@@ -30,6 +31,7 @@ import {
30
31
  EModeCategoriesData,
31
32
  EModeCategoryData,
32
33
  EModeCategoryDataMapping,
34
+ StakeAaveData,
33
35
  } from '../types';
34
36
  import {
35
37
  Blockish,
@@ -61,7 +63,10 @@ export const aaveV3EmodeCategoriesMapping = (extractedState: any, usedAssets: Aa
61
63
  ...extractedState, usedAssets, eModeCategory: e.id,
62
64
  });
63
65
  const willStayOverCollateralized = new Dec(afterEnteringCategory.ratio === 'NaN' ? '0' : afterEnteringCategory.ratio).eq(0) || new Dec(afterEnteringCategory.ratio).gt(afterEnteringCategory.liqPercent);
64
- const enteringTerms = [borrowingOnlyFromCategory, willStayOverCollateralized];
66
+ const collateralOnlyFromCategory = e.id === 0 || !e.isolated
67
+ ? true
68
+ : !usedAssetsValues.filter(u => u.isSupplied && u.collateral && !e.collateralAssets.includes(u.symbol)).length;
69
+ const enteringTerms = [borrowingOnlyFromCategory, willStayOverCollateralized, collateralOnlyFromCategory];
65
70
  categoriesMapping[e.id] = {
66
71
  enteringTerms,
67
72
  canEnterCategory: !enteringTerms.includes(false),
@@ -118,6 +123,7 @@ export async function _getAaveV3MarketData(provider: Client, network: NetworkNum
118
123
  borrowableBitmap: eModesInfo[i].borrowableBitmap.toString(),
119
124
  collateralBitmap: eModesInfo[i].collateralBitmap.toString(),
120
125
  ltvzeroBitmap: eModesInfo[i].ltvzeroBitmap.toString(),
126
+ isolated: eModesInfo[i].isolated ?? false,
121
127
  borrowAssets: [],
122
128
  collateralAssets: [],
123
129
  ltvZeroAssets: [],
@@ -345,6 +351,7 @@ export async function _getAaveV3MarketData(provider: Client, network: NetworkNum
345
351
  collateralAssets: assetsData.map((a) => a.symbol),
346
352
  borrowAssets: assetsData.map((a) => a.symbol),
347
353
  ltvZeroAssets: [],
354
+ isolated: false,
348
355
  };
349
356
 
350
357
  return { assetsData: payload, eModeCategoriesData };
@@ -430,6 +437,290 @@ export const _getAaveV3AccountBalances = async (provider: Client, network: Netwo
430
437
 
431
438
  export const getAaveV3AccountBalances = async (provider: EthereumProvider, network: NetworkNumber, block: Blockish, addressMapping: boolean, address: EthAddress): Promise<PositionBalances> => _getAaveV3AccountBalances(getViemProvider(provider, network), network, block, addressMapping, address);
432
439
 
440
+ /**
441
+ * Historical net-balance helpers that bypass the AaveV3View contract.
442
+ *
443
+ * The View contract (and therefore `getAaveV3AccountData` / `getAaveV3AccountBalances`) can only be
444
+ * queried from its deployment block onwards, so it cannot read balances for positions older than that.
445
+ * The aTokens/debt tokens, the ProtocolDataProvider and the Aave price oracle all exist from Aave v3
446
+ * launch, so reading `balanceOf` on those tokens + the oracle price directly reaches much further back
447
+ * and costs ~1 multicall per point. Used to build a position balance-history chart.
448
+ */
449
+
450
+ // matches morphoVaults' batchSize; stays under the 500k portfolio discovery allows on simulation fork RPCs
451
+ const HISTORICAL_MULTICALL_BATCH_SIZE = 250_000;
452
+
453
+ // Minimal Aave price oracle ABI (getAssetPrice returns the asset price in the market base currency).
454
+ const AAVE_ORACLE_ABI = [
455
+ {
456
+ inputs: [{ internalType: 'address', name: 'asset', type: 'address' }],
457
+ name: 'getAssetPrice',
458
+ outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
459
+ stateMutability: 'view',
460
+ type: 'function',
461
+ },
462
+ ] as const;
463
+
464
+ export interface AaveV3ReserveTokenAddresses {
465
+ [symbol: string]: {
466
+ symbol: string,
467
+ underlyingAddress: EthAddress,
468
+ aTokenAddress: EthAddress,
469
+ stableDebtTokenAddress: EthAddress,
470
+ variableDebtTokenAddress: EthAddress,
471
+ };
472
+ }
473
+
474
+ export interface AaveV3HistoricalBalance {
475
+ block: number,
476
+ suppliedUsd: string,
477
+ borrowedUsd: string,
478
+ netUsd: string,
479
+ }
480
+
481
+ /**
482
+ * Fetches the aToken / stable-debt / variable-debt token addresses for every asset in the market.
483
+ * These are effectively immutable per reserve, so fetch once and reuse across all history points.
484
+ */
485
+ export const _getAaveV3ReserveTokenAddresses = async (provider: Client, network: NetworkNumber, market: AaveMarketInfo): Promise<AaveV3ReserveTokenAddresses> => {
486
+ const symbols = market.assets;
487
+ const underlyingAddresses = symbols.map((a: string) => getAssetInfo(getWrappedNativeAssetFromUnwrapped(a), network).address as EthAddress);
488
+ // @ts-ignore market.protocolData is a valid config key at runtime
489
+ const dataProviderAbi = getConfigContractAbi(market.protocolData, network);
490
+
491
+ const contracts = underlyingAddresses.map((underlying) => ({
492
+ address: market.protocolDataAddress as EthAddress,
493
+ abi: dataProviderAbi,
494
+ functionName: 'getReserveTokensAddresses',
495
+ args: [underlying],
496
+ }));
497
+
498
+ // @ts-ignore
499
+ const results = await provider.multicall({ contracts, allowFailure: true, batchSize: HISTORICAL_MULTICALL_BATCH_SIZE });
500
+
501
+ const mapping: AaveV3ReserveTokenAddresses = {};
502
+ results.forEach((res: any, i: number) => {
503
+ if (res.status !== 'success' || !res.result) return;
504
+ // outputs order: [aTokenAddress, stableDebtTokenAddress, variableDebtTokenAddress]
505
+ const [aTokenAddress, stableDebtTokenAddress, variableDebtTokenAddress] = res.result as [EthAddress, EthAddress, EthAddress];
506
+ mapping[symbols[i]] = {
507
+ symbol: symbols[i],
508
+ underlyingAddress: underlyingAddresses[i],
509
+ aTokenAddress,
510
+ stableDebtTokenAddress,
511
+ variableDebtTokenAddress,
512
+ };
513
+ });
514
+
515
+ return mapping;
516
+ };
517
+
518
+ export const getAaveV3ReserveTokenAddresses = async (provider: EthereumProvider, network: NetworkNumber, market: AaveMarketInfo): Promise<AaveV3ReserveTokenAddresses> => _getAaveV3ReserveTokenAddresses(getViemProvider(provider, network, { batch: { multicall: true } }), network, market);
519
+
520
+ /**
521
+ * Resolves the price oracle the market's addresses provider points at (at `block`, or latest).
522
+ * Aave can rotate the oracle over time, so a caller hoisting one address across many historical
523
+ * points must resolve it at both ends of its block range and only reuse it when the two agree —
524
+ * otherwise leave `oracleAddress` unset on _getAaveV3HistoricalBalance and it resolves per block.
525
+ */
526
+ export const _getAaveV3OracleAddress = async (provider: Client, network: NetworkNumber, market: AaveMarketInfo, block: Blockish = 'latest'): Promise<EthAddress> => {
527
+ // @ts-ignore market.provider is a valid config key at runtime
528
+ const providerAbi = getConfigContractAbi(market.provider, network);
529
+ // @ts-ignore readContract exists on the public client returned by getViemProvider
530
+ const oracleAddress = await provider.readContract({
531
+ address: market.providerAddress as EthAddress,
532
+ abi: providerAbi as any,
533
+ functionName: 'getPriceOracle',
534
+ ...setViemBlockNumber(block),
535
+ });
536
+ if (!oracleAddress) throw new Error(`AaveV3 oracle unavailable at block ${block}`);
537
+ return oracleAddress as EthAddress;
538
+ };
539
+
540
+ export const getAaveV3OracleAddress = async (provider: EthereumProvider, network: NetworkNumber, market: AaveMarketInfo, block: Blockish = 'latest'): Promise<EthAddress> => _getAaveV3OracleAddress(getViemProvider(provider, network, { batch: { multicall: true } }), network, market, block);
541
+
542
+ type AaveV3ReserveTokenEntry = AaveV3ReserveTokenAddresses[string];
543
+ type AaveV3ActiveHistoricalAsset = AaveV3ReserveTokenEntry & { supplied: string, debt: string };
544
+ // raw getAssetPrice multicall result per asset symbol
545
+ type AaveV3PriceResultsBySymbol = Record<string, any>;
546
+
547
+ // supply = aToken.balanceOf, debt = variableDebtToken.balanceOf + stableDebtToken.balanceOf — three reads per reserve
548
+ const getHistoricalBalanceContracts = (entries: AaveV3ReserveTokenEntry[], address: EthAddress) => {
549
+ const erc20Abi = getConfigContractAbi('Erc20');
550
+ return entries.flatMap((e) => ([
551
+ {
552
+ address: e.aTokenAddress, abi: erc20Abi, functionName: 'balanceOf', args: [address],
553
+ },
554
+ {
555
+ address: e.variableDebtTokenAddress, abi: erc20Abi, functionName: 'balanceOf', args: [address],
556
+ },
557
+ {
558
+ address: e.stableDebtTokenAddress, abi: erc20Abi, functionName: 'balanceOf', args: [address],
559
+ },
560
+ ]));
561
+ };
562
+
563
+ const getAssetPriceContract = (oracle: EthAddress, underlyingAddress: EthAddress) => ({
564
+ address: oracle,
565
+ abi: AAVE_ORACLE_ABI,
566
+ functionName: 'getAssetPrice',
567
+ args: [underlyingAddress],
568
+ });
569
+
570
+ /**
571
+ * Pairs each reserve with its three balance reads and keeps the assets the wallet actually held.
572
+ * Throws when every read failed — a totally failed fetch must not masquerade as a real $0 balance,
573
+ * so the caller can distinguish "fetch failed" (gap) from "position was empty" (genuine 0).
574
+ */
575
+ const toActiveHistoricalAssets = (entries: AaveV3ReserveTokenEntry[], balanceResults: any[], block: number): AaveV3ActiveHistoricalAsset[] => {
576
+ const anyBalanceRead = balanceResults.some((r) => r?.status === 'success');
577
+ if (!anyBalanceRead) throw new Error(`AaveV3 historical balance: all balance reads failed at block ${block}`);
578
+
579
+ return entries.map((e, i) => {
580
+ const supplyRes = balanceResults[i * 3];
581
+ const varDebtRes = balanceResults[(i * 3) + 1];
582
+ const stableDebtRes = balanceResults[(i * 3) + 2];
583
+ const supplied = supplyRes?.status === 'success' ? (supplyRes.result as bigint).toString() : '0';
584
+ const varDebt = varDebtRes?.status === 'success' ? (varDebtRes.result as bigint).toString() : '0';
585
+ const stableDebt = stableDebtRes?.status === 'success' ? (stableDebtRes.result as bigint).toString() : '0';
586
+ const debt = new Dec(varDebt).add(stableDebt).toString();
587
+ return { ...e, supplied, debt };
588
+ }).filter((a) => a.supplied !== '0' || a.debt !== '0');
589
+ };
590
+
591
+ /**
592
+ * Sums the active assets into the point's USD totals. Throws when every price read failed — the
593
+ * oracle couldn't serve this block (pruned state, or a hoisted oracle that wasn't deployed yet back
594
+ * then), and totalling it up anyway would return a fake near-$0 balance. A single asset's price
595
+ * failure still just skips that asset, matching the live data path.
596
+ */
597
+ const sumHistoricalUsd = (activeAssets: AaveV3ActiveHistoricalAsset[], priceResBySymbol: AaveV3PriceResultsBySymbol, block: number): AaveV3HistoricalBalance => {
598
+ const anyPriceRead = activeAssets.some((a) => priceResBySymbol[a.symbol]?.status === 'success');
599
+ if (!anyPriceRead) throw new Error(`AaveV3 historical balance: all price reads failed at block ${block}`);
600
+
601
+ let suppliedUsd = new Dec(0);
602
+ let borrowedUsd = new Dec(0);
603
+ activeAssets.forEach((a) => {
604
+ const priceRes = priceResBySymbol[a.symbol];
605
+ if (priceRes?.status !== 'success') return;
606
+ const priceUsd = new Dec((priceRes.result as bigint).toString()).div(1e8); // Aave v3 base currency is USD with 8 decimals
607
+ if (a.supplied !== '0') suppliedUsd = suppliedUsd.add(new Dec(assetAmountInEth(a.supplied, a.symbol)).mul(priceUsd));
608
+ if (a.debt !== '0') borrowedUsd = borrowedUsd.add(new Dec(assetAmountInEth(a.debt, a.symbol)).mul(priceUsd));
609
+ });
610
+
611
+ return {
612
+ block,
613
+ suppliedUsd: suppliedUsd.toString(),
614
+ borrowedUsd: borrowedUsd.toString(),
615
+ netUsd: suppliedUsd.minus(borrowedUsd).toString(),
616
+ };
617
+ };
618
+
619
+ /**
620
+ * Fast path, ONE multicall: balances plus a price read for every reserve through the caller-hoisted
621
+ * oracle. Prices are read for all reserves because which assets are active isn't known until the
622
+ * balances come back — extra reads inside an already-paid multicall are nearly free.
623
+ */
624
+ const fetchHistoricalPointWithOracle = async (provider: Client, entries: AaveV3ReserveTokenEntry[], address: EthAddress, block: number, oracleAddress: EthAddress) => {
625
+ const balanceContracts = getHistoricalBalanceContracts(entries, address);
626
+ const priceContracts = entries.map((e) => getAssetPriceContract(oracleAddress, e.underlyingAddress));
627
+
628
+ // @ts-ignore
629
+ const results = await provider.multicall({
630
+ contracts: [...balanceContracts, ...priceContracts], allowFailure: true, blockNumber: BigInt(block), batchSize: HISTORICAL_MULTICALL_BATCH_SIZE,
631
+ });
632
+
633
+ const activeAssets = toActiveHistoricalAssets(entries, results.slice(0, balanceContracts.length), block);
634
+ const priceResBySymbol: AaveV3PriceResultsBySymbol = {};
635
+ results.slice(balanceContracts.length).forEach((res: any, i: number) => {
636
+ priceResBySymbol[entries[i].symbol] = res;
637
+ });
638
+ return { activeAssets, priceResBySymbol };
639
+ };
640
+
641
+ /**
642
+ * Fallback path, TWO multicalls: balances plus getPriceOracle (resolving the oracle that was active
643
+ * AT the block — Aave can rotate it over time), then prices for just the active assets. The oracle
644
+ * read has no fallback: if it fails (bad archive node, rate limit, ...) the failure must surface
645
+ * rather than silently returning $0 — the caller renders a gap instead of a misleading zero.
646
+ */
647
+ const fetchHistoricalPointResolvingOracle = async (provider: Client, network: NetworkNumber, market: AaveMarketInfo, entries: AaveV3ReserveTokenEntry[], address: EthAddress, block: number) => {
648
+ const balanceContracts = getHistoricalBalanceContracts(entries, address);
649
+ // @ts-ignore market.provider is a valid config key at runtime
650
+ const providerAbi = getConfigContractAbi(market.provider, network);
651
+ const oracleContract = {
652
+ address: market.providerAddress as EthAddress,
653
+ abi: providerAbi,
654
+ functionName: 'getPriceOracle',
655
+ };
656
+ const blockNumber = BigInt(block);
657
+
658
+ // @ts-ignore
659
+ const results = await provider.multicall({
660
+ contracts: [...balanceContracts, oracleContract], allowFailure: true, blockNumber, batchSize: HISTORICAL_MULTICALL_BATCH_SIZE,
661
+ });
662
+ const oracleRes = results[balanceContracts.length];
663
+ if (oracleRes?.status !== 'success' || !oracleRes.result) throw new Error(`AaveV3 historical balance: oracle unavailable at block ${block}`);
664
+
665
+ const activeAssets = toActiveHistoricalAssets(entries, results.slice(0, balanceContracts.length), block);
666
+ if (!activeAssets.length) return { activeAssets, priceResBySymbol: {} };
667
+
668
+ const priceContracts = activeAssets.map((a) => getAssetPriceContract(oracleRes.result as EthAddress, a.underlyingAddress));
669
+ // @ts-ignore
670
+ const priceResults = await provider.multicall({
671
+ contracts: priceContracts, allowFailure: true, blockNumber, batchSize: HISTORICAL_MULTICALL_BATCH_SIZE,
672
+ });
673
+ const priceResBySymbol: AaveV3PriceResultsBySymbol = {};
674
+ priceResults.forEach((res: any, i: number) => {
675
+ priceResBySymbol[activeAssets[i].symbol] = res;
676
+ });
677
+ return { activeAssets, priceResBySymbol };
678
+ };
679
+
680
+ /**
681
+ * Computes a user's Aave v3 net USD balance (supplied collateral - borrowed debt) at a historical block,
682
+ * without touching the AaveV3View contract. Pass `reserveTokens` (from getAaveV3ReserveTokenAddresses)
683
+ * to avoid refetching token addresses for every point, and `oracleAddress` (from getAaveV3OracleAddress,
684
+ * verified identical at both ends of the sampled range) to collapse the point into a single multicall —
685
+ * with it the balances and all prices ride one request; without it the oracle is resolved at the block
686
+ * inside the balance multicall and the active assets are priced in a second one.
687
+ */
688
+ export const _getAaveV3HistoricalBalance = async (
689
+ provider: Client,
690
+ network: NetworkNumber,
691
+ market: AaveMarketInfo,
692
+ address: EthAddress,
693
+ block: number,
694
+ reserveTokens?: AaveV3ReserveTokenAddresses,
695
+ oracleAddress?: EthAddress,
696
+ ): Promise<AaveV3HistoricalBalance> => {
697
+ const empty: AaveV3HistoricalBalance = {
698
+ block, suppliedUsd: '0', borrowedUsd: '0', netUsd: '0',
699
+ };
700
+ if (!address) return empty;
701
+
702
+ const tokens = reserveTokens || await _getAaveV3ReserveTokenAddresses(provider, network, market);
703
+ const entries = Object.values(tokens);
704
+ if (!entries.length) return empty;
705
+
706
+ const { activeAssets, priceResBySymbol } = oracleAddress
707
+ ? await fetchHistoricalPointWithOracle(provider, entries, address, block, oracleAddress)
708
+ : await fetchHistoricalPointResolvingOracle(provider, network, market, entries, address, block);
709
+
710
+ if (!activeAssets.length) return empty;
711
+ return sumHistoricalUsd(activeAssets, priceResBySymbol, block);
712
+ };
713
+
714
+ export const getAaveV3HistoricalBalance = async (
715
+ provider: EthereumProvider,
716
+ network: NetworkNumber,
717
+ market: AaveMarketInfo,
718
+ address: EthAddress,
719
+ block: number,
720
+ reserveTokens?: AaveV3ReserveTokenAddresses,
721
+ oracleAddress?: EthAddress,
722
+ ): Promise<AaveV3HistoricalBalance> => _getAaveV3HistoricalBalance(getViemProvider(provider, network, { batch: { multicall: true } }), network, market, address, block, reserveTokens, oracleAddress);
723
+
433
724
  export const _getAaveV3AccountData = async (provider: Client, network: NetworkNumber, address: EthAddress, extractedState: any, blockNumber: 'latest' | number = 'latest'): Promise<AaveV3PositionData> => {
434
725
  const {
435
726
  selectedMarket: market, assetsData, eModeCategoriesData,
@@ -608,7 +899,7 @@ export const fetchYearlyMeritApyForStakingGho = async () => {
608
899
  }
609
900
  };
610
901
 
611
- export const getStakeAaveData = async (provider: Client, network: NetworkNumber, address: EthAddress) => {
902
+ export const getStakeAaveData = async (provider: Client, network: NetworkNumber, address: EthAddress): Promise<StakeAaveData> => {
612
903
  const stkGhoAddress = getAssetInfo('stkGHO').address as HexString;
613
904
  const stkAaveAddress = getAssetInfo('stkAAVE').address as HexString;
614
905
 
@@ -1,25 +1,10 @@
1
1
  import Dec from 'decimal.js';
2
2
  import { EthAddress, NetworkNumber } from '../types/common';
3
+ import { SghoData } from '../types/aave';
3
4
  import { DEFAULT_TIMEOUT } from '../services/utils';
4
5
  import { ZERO_ADDRESS } from '../constants';
5
6
 
6
- export interface SghoUserData {
7
- shares: string;
8
- balance: string;
9
- maxDeposit: string;
10
- maxWithdraw: string;
11
- underlyingBalance: string;
12
- }
13
-
14
- export interface SghoData {
15
- totalAssets: string;
16
- totalSupply: string;
17
- supplyCap: string;
18
- /** Target savings rate as an APY percent (e.g. "4.25" for 4.25%). */
19
- targetRate: string;
20
- paused: boolean;
21
- user: SghoUserData;
22
- }
7
+ export type { SghoData, SghoUserData } from '../types/aave';
23
8
 
24
9
  const EMPTY_SGHO_DATA: SghoData = {
25
10
  totalAssets: '0',