@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.
- package/cjs/aaveV3/index.d.ts +2 -12
- package/cjs/aaveV3/sgho.d.ts +2 -16
- package/cjs/aaveV4/lend.d.ts +2 -43
- package/cjs/claiming/aaveV3.d.ts +2 -2
- package/cjs/claiming/ethena.d.ts +2 -1
- package/cjs/claiming/king.d.ts +2 -1
- package/cjs/claiming/spark.d.ts +2 -2
- package/cjs/fluid/index.d.ts +5 -49
- package/cjs/liquity/index.d.ts +2 -12
- package/cjs/liquityV2/index.d.ts +8 -23
- package/cjs/liquityV2/index.js +37 -19
- package/cjs/portfolio/index.d.ts +16 -8
- package/cjs/portfolio/index.js +458 -520
- package/cjs/portfolio/lendingProtocols.d.ts +184 -0
- package/cjs/portfolio/lendingProtocols.js +196 -0
- package/cjs/savings/index.d.ts +8 -2
- package/cjs/savings/index.js +33 -4
- package/cjs/types/aave.d.ts +98 -2
- package/cjs/types/aaveV4.d.ts +44 -0
- package/cjs/types/compound.d.ts +26 -2
- package/cjs/types/curveUsd.d.ts +9 -1
- package/cjs/types/fluid.d.ts +13 -0
- package/cjs/types/index.d.ts +1 -0
- package/cjs/types/index.js +1 -0
- package/cjs/types/liquity.d.ts +12 -0
- package/cjs/types/liquityV2.d.ts +24 -0
- package/cjs/types/llamaLend.d.ts +12 -1
- package/cjs/types/morphoBlue.d.ts +2 -0
- package/cjs/types/portfolio.d.ts +125 -5
- package/cjs/types/savings/index.d.ts +9 -1
- package/cjs/types/spark.d.ts +21 -1
- package/cjs/umbrella/index.d.ts +2 -3
- package/esm/aaveV3/index.d.ts +2 -12
- package/esm/aaveV3/sgho.d.ts +2 -16
- package/esm/aaveV4/lend.d.ts +2 -43
- package/esm/claiming/aaveV3.d.ts +2 -2
- package/esm/claiming/aaveV3.js +1 -1
- package/esm/claiming/ethena.d.ts +2 -1
- package/esm/claiming/king.d.ts +2 -1
- package/esm/claiming/spark.d.ts +2 -2
- package/esm/claiming/spark.js +1 -1
- package/esm/fluid/index.d.ts +5 -49
- package/esm/liquity/index.d.ts +2 -12
- package/esm/liquityV2/index.d.ts +8 -23
- package/esm/liquityV2/index.js +35 -18
- package/esm/portfolio/index.d.ts +16 -8
- package/esm/portfolio/index.js +458 -522
- package/esm/portfolio/lendingProtocols.d.ts +184 -0
- package/esm/portfolio/lendingProtocols.js +189 -0
- package/esm/savings/index.d.ts +8 -2
- package/esm/savings/index.js +31 -3
- package/esm/types/aave.d.ts +98 -2
- package/esm/types/aaveV4.d.ts +44 -0
- package/esm/types/compound.d.ts +26 -2
- package/esm/types/curveUsd.d.ts +9 -1
- package/esm/types/fluid.d.ts +13 -0
- package/esm/types/index.d.ts +1 -0
- package/esm/types/index.js +1 -0
- package/esm/types/liquity.d.ts +12 -0
- package/esm/types/liquityV2.d.ts +24 -0
- package/esm/types/llamaLend.d.ts +12 -1
- package/esm/types/morphoBlue.d.ts +2 -0
- package/esm/types/portfolio.d.ts +125 -5
- package/esm/types/savings/index.d.ts +9 -1
- package/esm/types/spark.d.ts +21 -1
- package/esm/umbrella/index.d.ts +2 -3
- package/package.json +1 -1
- package/src/aaveV3/index.ts +2 -1
- package/src/aaveV3/sgho.ts +2 -17
- package/src/aaveV4/lend.ts +2 -48
- package/src/claiming/aaveV3.ts +4 -2
- package/src/claiming/ethena.ts +5 -5
- package/src/claiming/king.ts +3 -3
- package/src/claiming/spark.ts +6 -4
- package/src/fluid/index.ts +4 -3
- package/src/liquity/index.ts +2 -2
- package/src/liquityV2/index.ts +48 -22
- package/src/portfolio/index.ts +306 -331
- package/src/portfolio/lendingProtocols.ts +281 -0
- package/src/savings/index.ts +41 -4
- package/src/types/aave.ts +104 -1
- package/src/types/aaveV4.ts +49 -0
- package/src/types/compound.ts +38 -2
- package/src/types/curveUsd.ts +17 -1
- package/src/types/fluid.ts +14 -0
- package/src/types/index.ts +1 -0
- package/src/types/liquity.ts +13 -1
- package/src/types/liquityV2.ts +26 -1
- package/src/types/llamaLend.ts +19 -1
- package/src/types/morphoBlue.ts +3 -0
- package/src/types/portfolio.ts +151 -5
- package/src/types/savings/index.ts +12 -1
- package/src/types/spark.ts +25 -1
- package/src/umbrella/index.ts +2 -1
package/src/types/curveUsd.ts
CHANGED
|
@@ -66,6 +66,9 @@ export interface CrvUSDGlobalMarketData {
|
|
|
66
66
|
leftToBorrow: string,
|
|
67
67
|
bands: BandData[],
|
|
68
68
|
loanDiscount: string;
|
|
69
|
+
// crvUSDView's globalData field that _getCurveUsdGlobalData spreads in unconverted. Optional, so objects built by
|
|
70
|
+
// hand still type-check.
|
|
71
|
+
A?: bigint,
|
|
69
72
|
}
|
|
70
73
|
|
|
71
74
|
export interface CrvUSDAggregatedPositionData {
|
|
@@ -105,7 +108,12 @@ export interface CrvUSDUsedAssets {
|
|
|
105
108
|
[key: string]: CrvUSDUsedAsset,
|
|
106
109
|
}
|
|
107
110
|
|
|
108
|
-
|
|
111
|
+
// Set by getCrvUsdAggregatedData, which _getCurveUsdUserData spreads in. Optional, so objects built by hand still
|
|
112
|
+
// type-check.
|
|
113
|
+
export type CrvUSDPositionAggregatedFields = Partial<Pick<CrvUSDAggregatedPositionData,
|
|
114
|
+
| 'borrowLimitUsd' | 'minAllowedRatio' | 'collFactor' | 'leveragedType' | 'leveragedAsset' | 'liquidationPrice'>>;
|
|
115
|
+
|
|
116
|
+
export interface CrvUSDUserData extends CrvUSDPositionAggregatedFields {
|
|
109
117
|
debtAmount: string,
|
|
110
118
|
health: string,
|
|
111
119
|
healthPercent: string,
|
|
@@ -130,4 +138,12 @@ export interface CrvUSDUserData {
|
|
|
130
138
|
netApy: string,
|
|
131
139
|
totalInterestUsd: string,
|
|
132
140
|
incentiveUsd: string,
|
|
141
|
+
// Fields of crvUSDView's userData that _getCurveUsdUserData spreads in unconverted. Optional, so objects built by
|
|
142
|
+
// hand still type-check.
|
|
143
|
+
marketCollateralAmount?: bigint,
|
|
144
|
+
curveUsdCollateralAmount?: bigint,
|
|
145
|
+
N?: bigint,
|
|
146
|
+
bandRange?: readonly [bigint, bigint],
|
|
147
|
+
usersBands?: readonly [readonly bigint[], readonly bigint[]],
|
|
148
|
+
isInSoftLiquidation?: boolean,
|
|
133
149
|
}
|
package/src/types/fluid.ts
CHANGED
|
@@ -488,3 +488,17 @@ export interface FluidFTokenDataStructOutput {
|
|
|
488
488
|
rewardsRate: bigint;
|
|
489
489
|
withdrawable: bigint;
|
|
490
490
|
}
|
|
491
|
+
|
|
492
|
+
/** One Fluid lending (fToken) deposit of an address, from getAllUserEarnPositionsWithFTokens and getFluidDepositData. */
|
|
493
|
+
export interface FluidEarnPositionData {
|
|
494
|
+
fTokenAddress: string | undefined,
|
|
495
|
+
fTokenSymbol: string,
|
|
496
|
+
decimals: string,
|
|
497
|
+
totalDeposited: string,
|
|
498
|
+
withdrawable: string,
|
|
499
|
+
apy: string,
|
|
500
|
+
depositRate: string,
|
|
501
|
+
withdrawRate: string,
|
|
502
|
+
deposited: string,
|
|
503
|
+
depositedShares: string,
|
|
504
|
+
}
|
package/src/types/index.ts
CHANGED
package/src/types/liquity.ts
CHANGED
|
@@ -35,4 +35,16 @@ export interface LiquityTroveInfo {
|
|
|
35
35
|
netApy: string,
|
|
36
36
|
totalInterestUsd: string,
|
|
37
37
|
incentiveUsd: string,
|
|
38
|
-
}
|
|
38
|
+
}
|
|
39
|
+
/** LQTY staking and the LUSD stability pool deposit of an address, from getLiquityStakingData. */
|
|
40
|
+
export interface LiquityStakingData {
|
|
41
|
+
totalLUSDDeposited: string,
|
|
42
|
+
totalLQTYStaked: string,
|
|
43
|
+
stakedLQTY: string,
|
|
44
|
+
stakedLUSDBalance: string,
|
|
45
|
+
rewardETH: string,
|
|
46
|
+
rewardLUSD: string,
|
|
47
|
+
stabilityRewardETH: string,
|
|
48
|
+
stabilityRewardLQTY: string,
|
|
49
|
+
showStakingBalances: boolean,
|
|
50
|
+
}
|
package/src/types/liquityV2.ts
CHANGED
|
@@ -133,4 +133,29 @@ export interface LiquityV2TroveData {
|
|
|
133
133
|
debtInFront: string,
|
|
134
134
|
lastInterestRateAdjTime: string,
|
|
135
135
|
exposure: string,
|
|
136
|
-
}
|
|
136
|
+
}
|
|
137
|
+
/** The stability pool deposit of an address in one market, from getLiquityV2Staking. */
|
|
138
|
+
export interface LiquityV2StakingData {
|
|
139
|
+
totalBOLDDeposited: string,
|
|
140
|
+
stakedBOLDBalance: string,
|
|
141
|
+
stabilityRewardColl: string,
|
|
142
|
+
stabilityRewardYield: string,
|
|
143
|
+
showStakingBalances: boolean,
|
|
144
|
+
debtTokenBalance: string,
|
|
145
|
+
stabilityPoolApy: string,
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** sBOLD, yBOLD and stYBOLD of an address, from getLiquitySAndYBold. */
|
|
149
|
+
export interface LiquityV2SBoldYBoldData {
|
|
150
|
+
spApy: string,
|
|
151
|
+
yBoldApy: string,
|
|
152
|
+
totalBoldDepositedSBold: string,
|
|
153
|
+
boldRateSBold: string,
|
|
154
|
+
maxWithdrawSBold: string,
|
|
155
|
+
totalBoldDepositedYBold: string,
|
|
156
|
+
boldRateYBold: string,
|
|
157
|
+
maxWithdrawYBold: string,
|
|
158
|
+
sBoldBalance: string,
|
|
159
|
+
yBoldBalance: string,
|
|
160
|
+
stYBoldBalance: string,
|
|
161
|
+
}
|
package/src/types/llamaLend.ts
CHANGED
|
@@ -141,7 +141,13 @@ export interface LlamaLendUsedAssets {
|
|
|
141
141
|
[key: string]: LlamaLendUsedAsset,
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
|
|
144
|
+
// Set by getLlamaLendAggregatedData, which _getLlamaLendUserData spreads in. Optional, so objects built by hand still
|
|
145
|
+
// type-check.
|
|
146
|
+
export type LlamaLendPositionAggregatedFields = Partial<Pick<LlamaLendAggregatedPositionData,
|
|
147
|
+
| 'borrowLimitUsd' | 'minAllowedRatio' | 'collFactor' | 'leveragedType' | 'leveragedAsset' | 'liquidationPrice'
|
|
148
|
+
| 'netApy' | 'incentiveUsd' | 'totalInterestUsd'>>;
|
|
149
|
+
|
|
150
|
+
export interface LlamaLendUserData extends LlamaLendPositionAggregatedFields {
|
|
145
151
|
debtAmount: string,
|
|
146
152
|
health: string,
|
|
147
153
|
healthPercent: string,
|
|
@@ -160,4 +166,16 @@ export interface LlamaLendUserData {
|
|
|
160
166
|
loanExists: boolean,
|
|
161
167
|
borrowRate?: string,
|
|
162
168
|
exposure: string,
|
|
169
|
+
// Fields of LlamaLendView's userData that _getLlamaLendUserData spreads in unconverted. Optional, so objects built
|
|
170
|
+
// by hand still type-check.
|
|
171
|
+
collateralPrice?: bigint,
|
|
172
|
+
marketCollateralAmount?: bigint,
|
|
173
|
+
debtTokenCollateralAmount?: bigint,
|
|
174
|
+
N?: bigint,
|
|
175
|
+
bandRange?: readonly [bigint, bigint],
|
|
176
|
+
usersBands?: readonly [readonly bigint[], readonly bigint[]],
|
|
177
|
+
collRatio?: bigint,
|
|
178
|
+
isInSoftLiquidation?: boolean,
|
|
179
|
+
debtTokenSuppliedShares?: bigint,
|
|
180
|
+
debtTokenSuppliedAssets?: bigint,
|
|
163
181
|
}
|
package/src/types/morphoBlue.ts
CHANGED
|
@@ -237,6 +237,9 @@ export interface MorphoBluePositionData {
|
|
|
237
237
|
supplyShares: string,
|
|
238
238
|
borrowShares: string,
|
|
239
239
|
exposure: string,
|
|
240
|
+
// Set by getMorphoBlueAggregatedPositionData. Optional, so objects built by hand still type-check.
|
|
241
|
+
minCollRatio?: string,
|
|
242
|
+
collLiquidationRatio?: string,
|
|
240
243
|
}
|
|
241
244
|
|
|
242
245
|
export interface MorphoBlueEarnData {
|
package/src/types/portfolio.ts
CHANGED
|
@@ -1,18 +1,31 @@
|
|
|
1
1
|
import {
|
|
2
|
-
AaveV2MarketData, AaveV2PositionData, AaveV3MarketData, AaveV3PositionData, AaveVersions,
|
|
2
|
+
AaveV2MarketData, AaveV2PositionData, AaveV3MarketData, AaveV3PositionData, AaveVersions, StakeAaveData, UmbrellaStakingData,
|
|
3
3
|
} from './aave';
|
|
4
4
|
import { AaveV4AccountData, AaveV4SpokeData, AaveV4SpokesType } from './aaveV4';
|
|
5
|
+
import {
|
|
6
|
+
AaveRewardsClaimableToken,
|
|
7
|
+
EthenaAirdropClaimableToken,
|
|
8
|
+
KingRewardsClaimableToken,
|
|
9
|
+
MerklRewardsClaimableToken,
|
|
10
|
+
SparkAirdropClaimableToken,
|
|
11
|
+
SparkRewardsClaimableToken,
|
|
12
|
+
UniswapAirdropClaimableToken,
|
|
13
|
+
} from './claiming';
|
|
5
14
|
import { EthAddress } from './common';
|
|
6
15
|
import {
|
|
7
16
|
CompoundV2MarketsData, CompoundV2PositionData, CompoundV3MarketsData, CompoundV3PositionData, CompoundVersions,
|
|
8
17
|
} from './compound';
|
|
9
18
|
import { CrvUSDGlobalMarketData, CrvUSDUserData, CrvUSDVersions } from './curveUsd';
|
|
10
|
-
import { FluidMarketData, FluidVaultData } from './fluid';
|
|
11
|
-
import { LiquityTroveInfo } from './liquity';
|
|
12
|
-
import {
|
|
19
|
+
import { FluidEarnPositionData, FluidMarketData, FluidVaultData } from './fluid';
|
|
20
|
+
import { LiquityStakingData, LiquityTroveInfo } from './liquity';
|
|
21
|
+
import {
|
|
22
|
+
LiquityV2MarketData, LiquityV2SBoldYBoldData, LiquityV2StakingData, LiquityV2TroveData, LiquityV2Versions,
|
|
23
|
+
} from './liquityV2';
|
|
13
24
|
import { LlamaLendGlobalMarketData, LlamaLendUserData, LlamaLendVersionsType } from './llamaLend';
|
|
14
25
|
import { CdpData, IlkInfo } from './maker';
|
|
15
|
-
import {
|
|
26
|
+
import {
|
|
27
|
+
MorphoBlueEarnData, MorphoBlueMarketInfo, MorphoBluePositionData, MorphoBlueVersions,
|
|
28
|
+
} from './morphoBlue';
|
|
16
29
|
import { MorphoMidnightMarketInfo, MorphoMidnightPositionData, MorphoMidnightVersions } from './morphoMidnight';
|
|
17
30
|
import { SparkMarketsData, SparkPositionData, SparkVersions } from './spark';
|
|
18
31
|
|
|
@@ -21,6 +34,35 @@ export interface PortfolioProtocolData<T> {
|
|
|
21
34
|
data: T | null,
|
|
22
35
|
}
|
|
23
36
|
|
|
37
|
+
/** A failed fetch of a protocol that, when it succeeds, getPortfolioData returns unwrapped rather than as `{ error, data }`. */
|
|
38
|
+
export interface PortfolioProtocolError {
|
|
39
|
+
error: string,
|
|
40
|
+
data: null,
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** What getPortfolioData reads besides markets. */
|
|
44
|
+
export interface PortfolioDataOptions {
|
|
45
|
+
/** positions (lending); default true. With false it comes back as {} and no lending position is read. */
|
|
46
|
+
positions?: boolean,
|
|
47
|
+
/** stakingPositions; default true. With false it comes back as {} and no staking source is read. */
|
|
48
|
+
staking?: boolean,
|
|
49
|
+
/** rewardsData; default true. With false it comes back as {} and no rewards source is read. */
|
|
50
|
+
rewards?: boolean,
|
|
51
|
+
/**
|
|
52
|
+
* Liquity V2 troves in positions[address].liquityV2; default false, as the DeFi Saver app reads them on its own.
|
|
53
|
+
* Mainnet only: elsewhere liquityV2 is {}. Needs positions.
|
|
54
|
+
*/
|
|
55
|
+
liquityV2?: boolean,
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** One Liquity V2 market's troves of an address, by trove id — with an error when the ids or any trove failed to load. */
|
|
59
|
+
export interface PortfolioLiquityV2Troves {
|
|
60
|
+
error: string,
|
|
61
|
+
data: {
|
|
62
|
+
[troveId: string]: LiquityV2TroveData;
|
|
63
|
+
},
|
|
64
|
+
}
|
|
65
|
+
|
|
24
66
|
export interface PortfolioPositionsDataForAddress {
|
|
25
67
|
aaveV3: {
|
|
26
68
|
[key in AaveVersions]?: PortfolioProtocolData<AaveV3PositionData>;
|
|
@@ -62,11 +104,71 @@ export interface PortfolioPositionsDataForAddress {
|
|
|
62
104
|
aaveV4: {
|
|
63
105
|
[key in AaveV4SpokesType]?: PortfolioProtocolData<AaveV4AccountData>;
|
|
64
106
|
};
|
|
107
|
+
/** Only with the liquityV2 option. Every trove the address holds, by market. */
|
|
108
|
+
liquityV2?: {
|
|
109
|
+
[key in LiquityV2Versions]?: PortfolioLiquityV2Troves;
|
|
110
|
+
};
|
|
65
111
|
}
|
|
66
112
|
|
|
67
113
|
export interface PortfolioPositionsData {
|
|
68
114
|
[key: EthAddress]: PortfolioPositionsDataForAddress;
|
|
69
115
|
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* The staking positions getPortfolioData returns for an address. The shapes are uneven, and the DeFi Saver app
|
|
119
|
+
* parses them as they are: a protocol read once per address comes back unwrapped on success, as
|
|
120
|
+
* `{ error, data: null }` on failure, and as {} (or Fluid's `{ error: '', data: {} }`) on a network it is not read on.
|
|
121
|
+
*/
|
|
122
|
+
export interface PortfolioStakingPositionsDataForAddress {
|
|
123
|
+
/** stkAAVE, stkGHO and sGHO; mainnet only. */
|
|
124
|
+
aaveV3: StakeAaveData | PortfolioProtocolError | {};
|
|
125
|
+
/** Morpho Blue supply without a borrow (Earn), by market; only markets with a deposit or an error. */
|
|
126
|
+
morphoBlue: {
|
|
127
|
+
[key in MorphoBlueVersions]?: PortfolioProtocolData<MorphoBlueEarnData>;
|
|
128
|
+
};
|
|
129
|
+
// Never filled; kept so the shape does not change under the app.
|
|
130
|
+
compoundV3: Record<string, never>;
|
|
131
|
+
spark: Record<string, never>;
|
|
132
|
+
aaveV2: Record<string, never>;
|
|
133
|
+
compoundV2: Record<string, never>;
|
|
134
|
+
/** LQTY staking and the LUSD stability pool; mainnet only. */
|
|
135
|
+
liquity: LiquityStakingData | PortfolioProtocolError | {};
|
|
136
|
+
/** Stability pool deposits, by market; mainnet only, legacy markets left out. */
|
|
137
|
+
liquityV2: {
|
|
138
|
+
[key in LiquityV2Versions]?: PortfolioProtocolData<LiquityV2StakingData>;
|
|
139
|
+
};
|
|
140
|
+
/** Fluid lending (fToken) deposits; `{ error: '', data: {} }` on a network without Fluid. */
|
|
141
|
+
fluid: FluidEarnPositionData[] | PortfolioProtocolError | { error: string, data: Record<string, never> };
|
|
142
|
+
/** Umbrella stakes; absent off mainnet. */
|
|
143
|
+
umbrella?: UmbrellaStakingData | PortfolioProtocolError;
|
|
144
|
+
/** sBOLD, yBOLD and stYBOLD; data is null off mainnet. */
|
|
145
|
+
liquityV2SBoldYBold: PortfolioProtocolData<LiquityV2SBoldYBoldData>;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// A Record rather than an interface: the app casts getPortfolioData's result to its own Record<string, …> type, and an
|
|
149
|
+
// interface with an address index signature is not comparable to one.
|
|
150
|
+
export type PortfolioStakingPositionsData = Record<EthAddress, PortfolioStakingPositionsDataForAddress>;
|
|
151
|
+
|
|
152
|
+
/** The claimable rewards getPortfolioData returns for an address. Off mainnet only Merkl and Aave V3 are read. */
|
|
153
|
+
export interface PortfolioRewardsDataForAddress {
|
|
154
|
+
merkl: PortfolioProtocolData<MerklRewardsClaimableToken[]>;
|
|
155
|
+
aaveV3: {
|
|
156
|
+
[key in AaveVersions]?: PortfolioProtocolData<AaveRewardsClaimableToken[]>;
|
|
157
|
+
};
|
|
158
|
+
spark: {
|
|
159
|
+
[key in SparkVersions]?: PortfolioProtocolData<SparkRewardsClaimableToken[]>;
|
|
160
|
+
};
|
|
161
|
+
/** The SPK airdrop. */
|
|
162
|
+
spk: PortfolioProtocolData<SparkAirdropClaimableToken[]>;
|
|
163
|
+
king: PortfolioProtocolData<KingRewardsClaimableToken[]>;
|
|
164
|
+
/** {} off mainnet. */
|
|
165
|
+
ethena: PortfolioProtocolData<EthenaAirdropClaimableToken[]> | {};
|
|
166
|
+
uniswap: PortfolioProtocolData<UniswapAirdropClaimableToken[]>;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export type PortfolioRewardsData = Record<EthAddress, PortfolioRewardsDataForAddress>;
|
|
170
|
+
|
|
171
|
+
/** The `markets` getPortfolioData returns: every market it read, by protocol, keyed by market or spoke. */
|
|
70
172
|
export interface PortfolioMarketsData {
|
|
71
173
|
morphoMarketsData: Record<string, MorphoBlueMarketInfo>;
|
|
72
174
|
morphoMidnightMarketsData: Record<string, MorphoMidnightMarketInfo>;
|
|
@@ -79,6 +181,50 @@ export interface PortfolioMarketsData {
|
|
|
79
181
|
llamaLendMarketsData: Record<string, LlamaLendGlobalMarketData>;
|
|
80
182
|
liquityV2MarketsData: Record<string, LiquityV2MarketData>;
|
|
81
183
|
aaveV4SpokesData: Record<string, AaveV4SpokeData>;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* The `markets` getShifterPortfolioData returns: the portfolio's markets, plus Fluid's and Maker's, which the shifter
|
|
188
|
+
* offers as destinations. Kept apart from PortfolioMarketsData, which getPortfolioData does not fill these into.
|
|
189
|
+
*/
|
|
190
|
+
export interface ShifterPortfolioMarketsData extends PortfolioMarketsData {
|
|
82
191
|
fluidMarketsData: Record<string, FluidMarketData>;
|
|
83
192
|
makerMarketsData: Record<string, IlkInfo>;
|
|
84
193
|
}
|
|
194
|
+
|
|
195
|
+
/** The markets that could not be read, by their key in PortfolioMarketsData, then by market or spoke: the error. */
|
|
196
|
+
export type PortfolioMarketsErrors = {
|
|
197
|
+
[key in keyof PortfolioMarketsData]?: Record<string, string>;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* What the portfolio fetch could not read and has no `{ error, data }` entry of its own to report it in. A key is
|
|
202
|
+
* present only when something under it failed; {} when everything was read.
|
|
203
|
+
*/
|
|
204
|
+
export interface PortfolioErrors {
|
|
205
|
+
/** Markets missing from `markets`; every position on such a market is an entry with an error. */
|
|
206
|
+
markets?: PortfolioMarketsErrors;
|
|
207
|
+
/** Addresses whose Maker vault list could not be read: their `maker` is {}, which would otherwise read as "no vaults". */
|
|
208
|
+
makerCdps?: Record<EthAddress, string>;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** getPortfolioMarketsData's result. */
|
|
212
|
+
export interface PortfolioMarketsResult {
|
|
213
|
+
/** Every market read; one that failed is missing and named in `errors`. */
|
|
214
|
+
markets: PortfolioMarketsData;
|
|
215
|
+
errors: PortfolioMarketsErrors;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** getPortfolioUserData's result: what is read per address. */
|
|
219
|
+
export interface PortfolioUserData {
|
|
220
|
+
positions: PortfolioPositionsData;
|
|
221
|
+
stakingPositions: PortfolioStakingPositionsData;
|
|
222
|
+
rewardsData: PortfolioRewardsData;
|
|
223
|
+
errors: Pick<PortfolioErrors, 'makerCdps'>;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** getPortfolioData's result. */
|
|
227
|
+
export interface PortfolioData extends Omit<PortfolioUserData, 'errors'> {
|
|
228
|
+
markets: PortfolioMarketsData;
|
|
229
|
+
errors: PortfolioErrors;
|
|
230
|
+
}
|
|
@@ -23,4 +23,15 @@ export interface SavingsVaultData {
|
|
|
23
23
|
optionType: string,
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
/** The key of every savings vault getSavingsData reads. */
|
|
27
|
+
export type SavingsVaultKey = MorphoVaultType | YearnVaultType | MakerDsrType | SkySavingsType | SparkSavingsVaultType | SummerVaultType | YearnV3VaultType;
|
|
28
|
+
|
|
29
|
+
export type SavingsData = Partial<Record<SavingsVaultKey, SavingsVaultData>>;
|
|
30
|
+
|
|
31
|
+
/** Why each vault that was read for a network came back without data. */
|
|
32
|
+
export type SavingsErrors = Partial<Record<SavingsVaultKey, string>>;
|
|
33
|
+
|
|
34
|
+
export interface SavingsDataWithErrors {
|
|
35
|
+
data: SavingsData,
|
|
36
|
+
errors: SavingsErrors,
|
|
37
|
+
}
|
package/src/types/spark.ts
CHANGED
|
@@ -57,6 +57,22 @@ export interface SparkAssetData extends MMAssetData {
|
|
|
57
57
|
eModeCategory: number,
|
|
58
58
|
liquidationBonus: string,
|
|
59
59
|
liquidationRatio: string,
|
|
60
|
+
// Set by _getSparkMarketsData. Optional, so objects built by hand still type-check.
|
|
61
|
+
debtCeilingForIsolationMode?: string,
|
|
62
|
+
isSiloed?: boolean,
|
|
63
|
+
isolationModeTotalDebt?: string,
|
|
64
|
+
isolationModeBorrowingEnabled?: boolean,
|
|
65
|
+
assetId?: number,
|
|
66
|
+
borrowRateStable?: string,
|
|
67
|
+
supplyCap?: string,
|
|
68
|
+
isInactive?: boolean,
|
|
69
|
+
isFrozen?: boolean,
|
|
70
|
+
isPaused?: boolean,
|
|
71
|
+
canBeWithdrawn?: boolean,
|
|
72
|
+
canBePayBacked?: boolean,
|
|
73
|
+
disabledStableBorrowing?: boolean,
|
|
74
|
+
isFlashLoanEnabled?: boolean,
|
|
75
|
+
aTokenAddress?: EthAddress,
|
|
60
76
|
}
|
|
61
77
|
|
|
62
78
|
export interface SparkAssetsData {
|
|
@@ -116,7 +132,15 @@ export interface SparkAggregatedPositionData {
|
|
|
116
132
|
exposure: string,
|
|
117
133
|
}
|
|
118
134
|
|
|
119
|
-
|
|
135
|
+
/**
|
|
136
|
+
* Fields sparkGetAggregatedPositionData adds to every Spark position at runtime, on top of those declared below.
|
|
137
|
+
* Optional, so code that builds a position by hand keeps compiling.
|
|
138
|
+
*/
|
|
139
|
+
export type SparkPositionAggregatedFields = Partial<Omit<SparkAggregatedPositionData,
|
|
140
|
+
| keyof MMPositionData | 'ratio' | 'collRatio' | 'suppliedUsd' | 'borrowedUsd' | 'borrowLimitUsd'
|
|
141
|
+
| 'suppliedCollateralUsd' | 'incentiveUsd' | 'totalInterestUsd'>>;
|
|
142
|
+
|
|
143
|
+
export interface SparkPositionData extends MMPositionData, SparkPositionAggregatedFields {
|
|
120
144
|
ratio: string,
|
|
121
145
|
minRatio: string,
|
|
122
146
|
collRatio: string,
|
package/src/umbrella/index.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Client } from 'viem';
|
|
2
2
|
import { AaveUmbrellaViewViem, AaveV3ViewContractViem } from '../contracts';
|
|
3
3
|
import { EthAddress, NetworkNumber } from '../types/common';
|
|
4
|
+
import { UmbrellaStakingData } from '../types/aave';
|
|
4
5
|
import { compareAddresses, convertHybridArraysToObjects, getEthAmountForDecimals } from '../services/utils';
|
|
5
6
|
import { findMatching, tokenEntries } from './umbrellaUtils';
|
|
6
7
|
|
|
7
8
|
const umbrella = '0xD400fc38ED4732893174325693a63C30ee3881a8';
|
|
8
9
|
const aaveOracle = '0x54586bE62E3c3580375aE3723C145253060Ca0C2';
|
|
9
10
|
|
|
10
|
-
export const getUmbrellaData = async (provider: Client, network: NetworkNumber, address: EthAddress) => {
|
|
11
|
+
export const getUmbrellaData = async (provider: Client, network: NetworkNumber, address: EthAddress): Promise<UmbrellaStakingData> => {
|
|
11
12
|
const umbrellaView = AaveUmbrellaViewViem(provider, network);
|
|
12
13
|
const aaveV3View = AaveV3ViewContractViem(provider, network);
|
|
13
14
|
const [tokensAggregatedData, additionalUmbrellaStakingData, userAggregatedData] = await Promise.all([
|