@defisaver/positions-sdk 2.1.168 → 2.1.169-portfolio-api-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 (94) hide show
  1. package/cjs/aaveV3/index.d.ts +2 -12
  2. package/cjs/aaveV3/sgho.d.ts +2 -16
  3. package/cjs/aaveV4/lend.d.ts +2 -43
  4. package/cjs/claiming/aaveV3.d.ts +2 -2
  5. package/cjs/claiming/ethena.d.ts +2 -1
  6. package/cjs/claiming/king.d.ts +2 -1
  7. package/cjs/claiming/spark.d.ts +2 -2
  8. package/cjs/fluid/index.d.ts +5 -49
  9. package/cjs/liquity/index.d.ts +2 -12
  10. package/cjs/liquityV2/index.d.ts +8 -23
  11. package/cjs/liquityV2/index.js +37 -19
  12. package/cjs/portfolio/index.d.ts +16 -8
  13. package/cjs/portfolio/index.js +458 -520
  14. package/cjs/portfolio/lendingProtocols.d.ts +184 -0
  15. package/cjs/portfolio/lendingProtocols.js +196 -0
  16. package/cjs/savings/index.d.ts +8 -2
  17. package/cjs/savings/index.js +33 -4
  18. package/cjs/types/aave.d.ts +98 -2
  19. package/cjs/types/aaveV4.d.ts +44 -0
  20. package/cjs/types/compound.d.ts +26 -2
  21. package/cjs/types/curveUsd.d.ts +9 -1
  22. package/cjs/types/fluid.d.ts +13 -0
  23. package/cjs/types/index.d.ts +1 -0
  24. package/cjs/types/index.js +1 -0
  25. package/cjs/types/liquity.d.ts +12 -0
  26. package/cjs/types/liquityV2.d.ts +24 -0
  27. package/cjs/types/llamaLend.d.ts +12 -1
  28. package/cjs/types/morphoBlue.d.ts +2 -0
  29. package/cjs/types/portfolio.d.ts +125 -5
  30. package/cjs/types/savings/index.d.ts +9 -1
  31. package/cjs/types/spark.d.ts +21 -1
  32. package/cjs/umbrella/index.d.ts +2 -3
  33. package/esm/aaveV3/index.d.ts +2 -12
  34. package/esm/aaveV3/sgho.d.ts +2 -16
  35. package/esm/aaveV4/lend.d.ts +2 -43
  36. package/esm/claiming/aaveV3.d.ts +2 -2
  37. package/esm/claiming/aaveV3.js +1 -1
  38. package/esm/claiming/ethena.d.ts +2 -1
  39. package/esm/claiming/king.d.ts +2 -1
  40. package/esm/claiming/spark.d.ts +2 -2
  41. package/esm/claiming/spark.js +1 -1
  42. package/esm/fluid/index.d.ts +5 -49
  43. package/esm/liquity/index.d.ts +2 -12
  44. package/esm/liquityV2/index.d.ts +8 -23
  45. package/esm/liquityV2/index.js +35 -18
  46. package/esm/portfolio/index.d.ts +16 -8
  47. package/esm/portfolio/index.js +458 -522
  48. package/esm/portfolio/lendingProtocols.d.ts +184 -0
  49. package/esm/portfolio/lendingProtocols.js +189 -0
  50. package/esm/savings/index.d.ts +8 -2
  51. package/esm/savings/index.js +31 -3
  52. package/esm/types/aave.d.ts +98 -2
  53. package/esm/types/aaveV4.d.ts +44 -0
  54. package/esm/types/compound.d.ts +26 -2
  55. package/esm/types/curveUsd.d.ts +9 -1
  56. package/esm/types/fluid.d.ts +13 -0
  57. package/esm/types/index.d.ts +1 -0
  58. package/esm/types/index.js +1 -0
  59. package/esm/types/liquity.d.ts +12 -0
  60. package/esm/types/liquityV2.d.ts +24 -0
  61. package/esm/types/llamaLend.d.ts +12 -1
  62. package/esm/types/morphoBlue.d.ts +2 -0
  63. package/esm/types/portfolio.d.ts +125 -5
  64. package/esm/types/savings/index.d.ts +9 -1
  65. package/esm/types/spark.d.ts +21 -1
  66. package/esm/umbrella/index.d.ts +2 -3
  67. package/package.json +1 -1
  68. package/src/aaveV3/index.ts +2 -1
  69. package/src/aaveV3/sgho.ts +2 -17
  70. package/src/aaveV4/lend.ts +2 -48
  71. package/src/claiming/aaveV3.ts +4 -2
  72. package/src/claiming/ethena.ts +5 -5
  73. package/src/claiming/king.ts +3 -3
  74. package/src/claiming/spark.ts +6 -4
  75. package/src/fluid/index.ts +4 -3
  76. package/src/liquity/index.ts +2 -2
  77. package/src/liquityV2/index.ts +48 -22
  78. package/src/portfolio/index.ts +306 -331
  79. package/src/portfolio/lendingProtocols.ts +281 -0
  80. package/src/savings/index.ts +41 -4
  81. package/src/types/aave.ts +104 -1
  82. package/src/types/aaveV4.ts +49 -0
  83. package/src/types/compound.ts +38 -2
  84. package/src/types/curveUsd.ts +17 -1
  85. package/src/types/fluid.ts +14 -0
  86. package/src/types/index.ts +1 -0
  87. package/src/types/liquity.ts +13 -1
  88. package/src/types/liquityV2.ts +26 -1
  89. package/src/types/llamaLend.ts +19 -1
  90. package/src/types/morphoBlue.ts +3 -0
  91. package/src/types/portfolio.ts +151 -5
  92. package/src/types/savings/index.ts +12 -1
  93. package/src/types/spark.ts +25 -1
  94. package/src/umbrella/index.ts +2 -1
@@ -191,3 +191,47 @@ export interface AaveV4AccountData extends AaveV4AggregatedPositionData {
191
191
  healthFactor: string;
192
192
  riskPremiumBps: number;
193
193
  }
194
+ /** One Aave V4 tokenized spoke (Lend vault) as the view contract returns it for a user. */
195
+ export interface AaveV4TokenizationSpokeData {
196
+ underlyingAsset: EthAddress;
197
+ assetId: string;
198
+ decimals: number;
199
+ spoke: EthAddress;
200
+ spokeActive: boolean;
201
+ spokeHalted: boolean;
202
+ spokeDepositCap: string;
203
+ spokeTotalAssets: string;
204
+ spokeTotalShares: string;
205
+ hub: EthAddress;
206
+ hubLiquidity: string;
207
+ hubDrawnRate: string;
208
+ convertToShares: string;
209
+ convertToAssets: string;
210
+ user: EthAddress;
211
+ userSuppliedAssets: string;
212
+ userSuppliedShares: string;
213
+ }
214
+ /** Parsed tokenization spoke data with human-readable supplied amounts for display */
215
+ export interface AaveV4TokenizationSpokeDataParsed {
216
+ vaultAddress: EthAddress;
217
+ key: string | null;
218
+ symbol: string;
219
+ hubKey: string;
220
+ spokeActive: boolean;
221
+ spokeHalted: boolean;
222
+ /** Deposit cap in asset units (wei string) */
223
+ spokeDepositCap: string;
224
+ /** Total assets currently in spoke in asset units (wei string) */
225
+ spokeTotalAssets: string;
226
+ /** Available hub liquidity in asset units (wei string) */
227
+ hubLiquidity: string;
228
+ /** The conversion rate from assets to shares expressed in asset units. */
229
+ convertToShares: string;
230
+ userSuppliedAssetsEth: string;
231
+ userSuppliedSharesEth: string;
232
+ userSuppliedAssets: string;
233
+ userSuppliedShares: string;
234
+ underlyingAsset: EthAddress;
235
+ spoke: EthAddress;
236
+ decimals: number;
237
+ }
@@ -52,6 +52,7 @@ export interface CompoundAssetData extends MMAssetData {
52
52
  sortIndex?: number;
53
53
  }
54
54
  export interface CompoundV2AssetData extends CompoundAssetData {
55
+ exchangeRate?: string;
55
56
  }
56
57
  export interface CompoundV3AssetData extends CompoundAssetData {
57
58
  borrowCollateralFactor: string;
@@ -63,6 +64,17 @@ export interface CompoundV3AssetData extends CompoundAssetData {
63
64
  supplyCap: string;
64
65
  priceInBaseAsset: string;
65
66
  canBeWithdrawn: boolean;
67
+ tokenAddr?: EthAddress;
68
+ isBase?: boolean;
69
+ baseBorrowMin?: string;
70
+ baseTrackingBorrowRewardsSpeed?: string;
71
+ baseTrackingSupplyRewardsSpeed?: string;
72
+ borrowIndex?: string;
73
+ supplyIndex?: string;
74
+ trackingBorrowIndex?: string;
75
+ trackingSupplyIndex?: string;
76
+ rewardSupplySpeed?: string;
77
+ rewardBorrowSpeed?: string;
66
78
  }
67
79
  export interface CompoundAssetsData<T> {
68
80
  [token: string]: T;
@@ -125,9 +137,21 @@ export interface CompoundPositionData extends MMPositionData {
125
137
  isSubscribedToAutomation?: boolean;
126
138
  automationResubscribeRequired?: boolean;
127
139
  }
128
- export interface CompoundV2PositionData extends CompoundPositionData {
140
+ /**
141
+ * Fields getCompoundV2AggregatedData adds to every Compound V2 position at runtime — a subset of
142
+ * CompoundAggregatedPositionData. Optional, so code that builds a position by hand keeps compiling.
143
+ */
144
+ export type CompoundV2PositionAggregatedFields = Partial<Pick<CompoundAggregatedPositionData, 'suppliedCollateralUsd' | 'liquidationLimitUsd' | 'leftToBorrowUsd' | 'collRatio' | 'leveragedType' | 'leveragedAsset' | 'liquidationPrice'>>;
145
+ /**
146
+ * Fields getCompoundV3AggregatedData adds to every Compound V3 position at runtime, on top of those declared in
147
+ * CompoundPositionData. Optional, so code that builds a position by hand keeps compiling.
148
+ */
149
+ export type CompoundV3PositionAggregatedFields = Partial<Omit<CompoundAggregatedPositionData, keyof MMPositionData | 'ratio' | 'minRatio' | 'suppliedUsd' | 'borrowedUsd' | 'borrowLimitUsd' | 'incentiveUsd' | 'totalInterestUsd'>>;
150
+ export interface CompoundV2PositionData extends CompoundPositionData, CompoundV2PositionAggregatedFields {
129
151
  usedAssets: CompoundV2UsedAssets;
152
+ borrowStableSupplyUnstable?: boolean;
130
153
  }
131
- export interface CompoundV3PositionData extends CompoundPositionData {
154
+ export interface CompoundV3PositionData extends CompoundPositionData, CompoundV3PositionAggregatedFields {
132
155
  usedAssets: CompoundV3UsedAssets;
156
+ isAllowed?: boolean;
133
157
  }
@@ -60,6 +60,7 @@ export interface CrvUSDGlobalMarketData {
60
60
  leftToBorrow: string;
61
61
  bands: BandData[];
62
62
  loanDiscount: string;
63
+ A?: bigint;
63
64
  }
64
65
  export interface CrvUSDAggregatedPositionData {
65
66
  ratio: string;
@@ -94,7 +95,8 @@ export interface CrvUSDUsedAsset {
94
95
  export interface CrvUSDUsedAssets {
95
96
  [key: string]: CrvUSDUsedAsset;
96
97
  }
97
- export interface CrvUSDUserData {
98
+ export type CrvUSDPositionAggregatedFields = Partial<Pick<CrvUSDAggregatedPositionData, 'borrowLimitUsd' | 'minAllowedRatio' | 'collFactor' | 'leveragedType' | 'leveragedAsset' | 'liquidationPrice'>>;
99
+ export interface CrvUSDUserData extends CrvUSDPositionAggregatedFields {
98
100
  debtAmount: string;
99
101
  health: string;
100
102
  healthPercent: string;
@@ -119,4 +121,10 @@ export interface CrvUSDUserData {
119
121
  netApy: string;
120
122
  totalInterestUsd: string;
121
123
  incentiveUsd: string;
124
+ marketCollateralAmount?: bigint;
125
+ curveUsdCollateralAmount?: bigint;
126
+ N?: bigint;
127
+ bandRange?: readonly [bigint, bigint];
128
+ usersBands?: readonly [readonly bigint[], readonly bigint[]];
129
+ isInSoftLiquidation?: boolean;
122
130
  }
@@ -459,3 +459,16 @@ export interface FluidFTokenDataStructOutput {
459
459
  rewardsRate: bigint;
460
460
  withdrawable: bigint;
461
461
  }
462
+ /** One Fluid lending (fToken) deposit of an address, from getAllUserEarnPositionsWithFTokens and getFluidDepositData. */
463
+ export interface FluidEarnPositionData {
464
+ fTokenAddress: string | undefined;
465
+ fTokenSymbol: string;
466
+ decimals: string;
467
+ totalDeposited: string;
468
+ withdrawable: string;
469
+ apy: string;
470
+ depositRate: string;
471
+ withdrawRate: string;
472
+ deposited: string;
473
+ depositedShares: string;
474
+ }
@@ -15,4 +15,5 @@ export * from './merkl';
15
15
  export * from './savings';
16
16
  export * from './common';
17
17
  export * from './aaveV4';
18
+ export * from './claiming';
18
19
  export * from './lendingSummary';
@@ -15,4 +15,5 @@ export * from './merkl';
15
15
  export * from './savings';
16
16
  export * from './common';
17
17
  export * from './aaveV4';
18
+ export * from './claiming';
18
19
  export * from './lendingSummary';
@@ -32,3 +32,15 @@ export interface LiquityTroveInfo {
32
32
  totalInterestUsd: string;
33
33
  incentiveUsd: string;
34
34
  }
35
+ /** LQTY staking and the LUSD stability pool deposit of an address, from getLiquityStakingData. */
36
+ export interface LiquityStakingData {
37
+ totalLUSDDeposited: string;
38
+ totalLQTYStaked: string;
39
+ stakedLQTY: string;
40
+ stakedLUSDBalance: string;
41
+ rewardETH: string;
42
+ rewardLUSD: string;
43
+ stabilityRewardETH: string;
44
+ stabilityRewardLQTY: string;
45
+ showStakingBalances: boolean;
46
+ }
@@ -123,3 +123,27 @@ export interface LiquityV2TroveData {
123
123
  lastInterestRateAdjTime: string;
124
124
  exposure: string;
125
125
  }
126
+ /** The stability pool deposit of an address in one market, from getLiquityV2Staking. */
127
+ export interface LiquityV2StakingData {
128
+ totalBOLDDeposited: string;
129
+ stakedBOLDBalance: string;
130
+ stabilityRewardColl: string;
131
+ stabilityRewardYield: string;
132
+ showStakingBalances: boolean;
133
+ debtTokenBalance: string;
134
+ stabilityPoolApy: string;
135
+ }
136
+ /** sBOLD, yBOLD and stYBOLD of an address, from getLiquitySAndYBold. */
137
+ export interface LiquityV2SBoldYBoldData {
138
+ spApy: string;
139
+ yBoldApy: string;
140
+ totalBoldDepositedSBold: string;
141
+ boldRateSBold: string;
142
+ maxWithdrawSBold: string;
143
+ totalBoldDepositedYBold: string;
144
+ boldRateYBold: string;
145
+ maxWithdrawYBold: string;
146
+ sBoldBalance: string;
147
+ yBoldBalance: string;
148
+ stYBoldBalance: string;
149
+ }
@@ -138,7 +138,8 @@ export interface LlamaLendUsedAsset {
138
138
  export interface LlamaLendUsedAssets {
139
139
  [key: string]: LlamaLendUsedAsset;
140
140
  }
141
- export interface LlamaLendUserData {
141
+ export type LlamaLendPositionAggregatedFields = Partial<Pick<LlamaLendAggregatedPositionData, 'borrowLimitUsd' | 'minAllowedRatio' | 'collFactor' | 'leveragedType' | 'leveragedAsset' | 'liquidationPrice' | 'netApy' | 'incentiveUsd' | 'totalInterestUsd'>>;
142
+ export interface LlamaLendUserData extends LlamaLendPositionAggregatedFields {
142
143
  debtAmount: string;
143
144
  health: string;
144
145
  healthPercent: string;
@@ -157,4 +158,14 @@ export interface LlamaLendUserData {
157
158
  loanExists: boolean;
158
159
  borrowRate?: string;
159
160
  exposure: string;
161
+ collateralPrice?: bigint;
162
+ marketCollateralAmount?: bigint;
163
+ debtTokenCollateralAmount?: bigint;
164
+ N?: bigint;
165
+ bandRange?: readonly [bigint, bigint];
166
+ usersBands?: readonly [readonly bigint[], readonly bigint[]];
167
+ collRatio?: bigint;
168
+ isInSoftLiquidation?: boolean;
169
+ debtTokenSuppliedShares?: bigint;
170
+ debtTokenSuppliedAssets?: bigint;
160
171
  }
@@ -215,6 +215,8 @@ export interface MorphoBluePositionData {
215
215
  supplyShares: string;
216
216
  borrowShares: string;
217
217
  exposure: string;
218
+ minCollRatio?: string;
219
+ collLiquidationRatio?: string;
218
220
  }
219
221
  export interface MorphoBlueEarnData {
220
222
  apy: string;
@@ -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 { FluidMarketData, 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
11
  import { CdpData, IlkInfo } from './maker';
11
- import { MorphoBlueMarketInfo, MorphoBluePositionData, MorphoBlueVersions } from './morphoBlue';
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,65 @@ 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>;
144
+ /** The `markets` getPortfolioData returns: every market it read, by protocol, keyed by market or spoke. */
63
145
  export interface PortfolioMarketsData {
64
146
  morphoMarketsData: Record<string, MorphoBlueMarketInfo>;
65
147
  morphoMidnightMarketsData: Record<string, MorphoMidnightMarketInfo>;
@@ -72,6 +154,44 @@ export interface PortfolioMarketsData {
72
154
  llamaLendMarketsData: Record<string, LlamaLendGlobalMarketData>;
73
155
  liquityV2MarketsData: Record<string, LiquityV2MarketData>;
74
156
  aaveV4SpokesData: Record<string, AaveV4SpokeData>;
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 {
75
163
  fluidMarketsData: Record<string, FluidMarketData>;
76
164
  makerMarketsData: Record<string, IlkInfo>;
77
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
+ }
@@ -46,6 +46,21 @@ export interface SparkAssetData extends MMAssetData {
46
46
  eModeCategory: number;
47
47
  liquidationBonus: string;
48
48
  liquidationRatio: string;
49
+ debtCeilingForIsolationMode?: string;
50
+ isSiloed?: boolean;
51
+ isolationModeTotalDebt?: string;
52
+ isolationModeBorrowingEnabled?: boolean;
53
+ assetId?: number;
54
+ borrowRateStable?: string;
55
+ supplyCap?: string;
56
+ isInactive?: boolean;
57
+ isFrozen?: boolean;
58
+ isPaused?: boolean;
59
+ canBeWithdrawn?: boolean;
60
+ canBePayBacked?: boolean;
61
+ disabledStableBorrowing?: boolean;
62
+ isFlashLoanEnabled?: boolean;
63
+ aTokenAddress?: EthAddress;
49
64
  }
50
65
  export interface SparkAssetsData {
51
66
  [token: string]: SparkAssetData;
@@ -101,7 +116,12 @@ export interface SparkAggregatedPositionData {
101
116
  minHealthRatio: string;
102
117
  exposure: string;
103
118
  }
104
- export interface SparkPositionData extends MMPositionData {
119
+ /**
120
+ * Fields sparkGetAggregatedPositionData adds to every Spark position at runtime, on top of those declared below.
121
+ * Optional, so code that builds a position by hand keeps compiling.
122
+ */
123
+ export type SparkPositionAggregatedFields = Partial<Omit<SparkAggregatedPositionData, keyof MMPositionData | 'ratio' | 'collRatio' | 'suppliedUsd' | 'borrowedUsd' | 'borrowLimitUsd' | 'suppliedCollateralUsd' | 'incentiveUsd' | 'totalInterestUsd'>>;
124
+ export interface SparkPositionData extends MMPositionData, SparkPositionAggregatedFields {
105
125
  ratio: string;
106
126
  minRatio: string;
107
127
  collRatio: 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.168",
3
+ "version": "2.1.169-portfolio-api-dev",
4
4
  "description": "",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
@@ -31,6 +31,7 @@ import {
31
31
  EModeCategoriesData,
32
32
  EModeCategoryData,
33
33
  EModeCategoryDataMapping,
34
+ StakeAaveData,
34
35
  } from '../types';
35
36
  import {
36
37
  Blockish,
@@ -852,7 +853,7 @@ export const fetchYearlyMeritApyForStakingGho = async () => {
852
853
  }
853
854
  };
854
855
 
855
- export const getStakeAaveData = async (provider: Client, network: NetworkNumber, address: EthAddress) => {
856
+ export const getStakeAaveData = async (provider: Client, network: NetworkNumber, address: EthAddress): Promise<StakeAaveData> => {
856
857
  const stkGhoAddress = getAssetInfo('stkGHO').address as HexString;
857
858
  const stkAaveAddress = getAssetInfo('stkAAVE').address as HexString;
858
859
 
@@ -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',
@@ -7,26 +7,9 @@ import {
7
7
  EthereumProvider,
8
8
  NetworkNumber,
9
9
  } from '../types/common';
10
+ import { AaveV4TokenizationSpokeDataParsed } from '../types/aaveV4';
10
11
 
11
- export interface AaveV4TokenizationSpokeData {
12
- underlyingAsset: EthAddress;
13
- assetId: string;
14
- decimals: number;
15
- spoke: EthAddress;
16
- spokeActive: boolean;
17
- spokeHalted: boolean;
18
- spokeDepositCap: string;
19
- spokeTotalAssets: string;
20
- spokeTotalShares: string;
21
- hub: EthAddress;
22
- hubLiquidity: string;
23
- hubDrawnRate: string;
24
- convertToShares: string;
25
- convertToAssets: string;
26
- user: EthAddress;
27
- userSuppliedAssets: string;
28
- userSuppliedShares: string;
29
- }
12
+ export type { AaveV4TokenizationSpokeData, AaveV4TokenizationSpokeDataParsed } from '../types/aaveV4';
30
13
 
31
14
  export const AAVE_V4_TOKENIZED_SPOKES: Record<string, EthAddress> = {
32
15
  EURC_CORE: '0x6D9e2Cdd61CaF69af99b275704B6e272C41c6718',
@@ -102,34 +85,6 @@ export const aaveV4GetTokenizedVaultAddress = (
102
85
  return AAVE_V4_TOKENIZED_SPOKES[key];
103
86
  };
104
87
 
105
- /** Parsed tokenization spoke data with human-readable supplied amounts for display */
106
- export interface AaveV4TokenizationSpokeDataParsed {
107
- vaultAddress: EthAddress;
108
- key: string | null;
109
- symbol: string;
110
- hubKey: string;
111
- // ---- Spoke ----
112
- spokeActive: boolean;
113
- spokeHalted: boolean;
114
- /** Deposit cap in asset units (wei string) */
115
- spokeDepositCap: string;
116
- /** Total assets currently in spoke in asset units (wei string) */
117
- spokeTotalAssets: string;
118
- // ---- Hub ----
119
- /** Available hub liquidity in asset units (wei string) */
120
- hubLiquidity: string;
121
- /** The conversion rate from assets to shares expressed in asset units. */
122
- convertToShares: string;
123
- // ---- User ----
124
- userSuppliedAssetsEth: string;
125
- userSuppliedSharesEth: string;
126
- userSuppliedAssets: string;
127
- userSuppliedShares: string;
128
- underlyingAsset: EthAddress;
129
- spoke: EthAddress;
130
- decimals: number;
131
- }
132
-
133
88
  const AAVE_V4_TOKENIZED_SPOKE_ADDRESS_TO_KEY: Record<string, string> = Object.entries(
134
89
  AAVE_V4_TOKENIZED_SPOKES,
135
90
  ).reduce((acc, [k, v]) => {
@@ -189,4 +144,3 @@ export async function getAaveV4TokenizationSpokesData(
189
144
  }).filter(item => item != null);
190
145
  }
191
146
 
192
-
@@ -1,7 +1,9 @@
1
1
  import { Client } from 'viem';
2
2
  import Dec from 'decimal.js';
3
3
  import { EthAddress, NetworkNumber } from '../types';
4
- import { ClaimableToken, ClaimType, MerklRewardsClaimableToken } from '../types/claiming';
4
+ import {
5
+ AaveRewardsClaimableToken, ClaimableToken, ClaimType, MerklRewardsClaimableToken,
6
+ } from '../types/claiming';
5
7
  import {
6
8
  AaveIncentiveDataProviderV3ContractViem,
7
9
  AaveRewardsControllerViem,
@@ -37,7 +39,7 @@ export async function getUnclaimedRewardsForAllMarkets(
37
39
  network: NetworkNumber,
38
40
  walletAddress: EthAddress,
39
41
  marketAddress: EthAddress,
40
- ): Promise<ClaimableToken[]> {
42
+ ): Promise<AaveRewardsClaimableToken[]> {
41
43
  const contract = AaveIncentiveDataProviderV3ContractViem(provider, network);
42
44
  const tokensData = await contract.read.getUserReservesIncentivesData([marketAddress, walletAddress]);
43
45
  const allTokensDataArrays = tokensData.reduce((acc: any[], val) => {
@@ -2,7 +2,7 @@ import { getAssetInfo } from '@defisaver/tokens';
2
2
  import Dec from 'decimal.js';
3
3
  import { getAddress } from 'viem';
4
4
  import { EthAddress } from '../types/common';
5
- import { ClaimType } from '../types/claiming';
5
+ import { ClaimType, EthenaAirdropClaimableToken } from '../types/claiming';
6
6
  import { getEthAmountForDecimals } from '../services/utils';
7
7
 
8
8
  export const fetchEthenaAirdropReward = async (address: EthAddress) => {
@@ -23,11 +23,11 @@ export const fetchEthenaAirdropReward = async (address: EthAddress) => {
23
23
  }
24
24
  };
25
25
 
26
- export const fetchEthenaAirdropRewards = async (walletAddresses: EthAddress[]): Promise<Record<string, any[]>> => {
26
+ export const fetchEthenaAirdropRewards = async (walletAddresses: EthAddress[]): Promise<Record<string, EthenaAirdropClaimableToken[]>> => {
27
27
  const apiDataPromises = walletAddresses.map(address => fetchEthenaAirdropReward(address));
28
28
  const apiDataArray = await Promise.all(apiDataPromises);
29
29
 
30
- const results: Record<string, any[]> = {};
30
+ const results: Record<string, EthenaAirdropClaimableToken[]> = {};
31
31
  for (let i = 0; i < walletAddresses.length; i++) {
32
32
  const walletAddress = walletAddresses[i];
33
33
  const data = apiDataArray[i];
@@ -36,7 +36,7 @@ export const fetchEthenaAirdropRewards = async (walletAddresses: EthAddress[]):
36
36
  continue;
37
37
  }
38
38
 
39
- const processedRewards = [];
39
+ const processedRewards: EthenaAirdropClaimableToken[] = [];
40
40
  const assetInfo = getAssetInfo('sENA');
41
41
 
42
42
  const amount = getEthAmountForDecimals(data.events[0].awardAmount, assetInfo.decimals);
@@ -47,7 +47,7 @@ export const fetchEthenaAirdropRewards = async (walletAddresses: EthAddress[]):
47
47
  underlyingSymbol: assetInfo.symbol,
48
48
  amount,
49
49
  claimType: ClaimType.ETHENA_AIRDROP,
50
- tokenAddress: assetInfo.address,
50
+ tokenAddress: assetInfo.address as EthAddress,
51
51
  walletAddress,
52
52
  label: 'Ethena Airdrop',
53
53
  });