@defisaver/positions-sdk 2.1.160 → 2.1.161-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/portfolio/index.js +5 -3
- package/cjs/types/aave.d.ts +15 -2
- package/cjs/types/compound.d.ts +26 -2
- package/cjs/types/curveUsd.d.ts +9 -1
- package/cjs/types/llamaLend.d.ts +12 -1
- package/cjs/types/morphoBlue.d.ts +2 -0
- package/cjs/types/spark.d.ts +21 -1
- package/esm/portfolio/index.js +5 -3
- package/esm/types/aave.d.ts +15 -2
- package/esm/types/compound.d.ts +26 -2
- package/esm/types/curveUsd.d.ts +9 -1
- package/esm/types/llamaLend.d.ts +12 -1
- package/esm/types/morphoBlue.d.ts +2 -0
- package/esm/types/spark.d.ts +21 -1
- package/package.json +1 -1
- package/src/portfolio/index.ts +4 -2
- package/src/types/aave.ts +18 -1
- package/src/types/compound.ts +38 -2
- package/src/types/curveUsd.ts +17 -1
- package/src/types/llamaLend.ts +19 -1
- package/src/types/morphoBlue.ts +3 -0
- package/src/types/spark.ts +25 -1
package/cjs/portfolio/index.js
CHANGED
|
@@ -521,9 +521,11 @@ function getPortfolioData(provider_1, network_1, defaultProvider_1, addresses_1)
|
|
|
521
521
|
positions[address.toLowerCase()].spark[market.value] = { error: `Error fetching Spark account data for address ${address} on market ${market.value}`, data: null };
|
|
522
522
|
}
|
|
523
523
|
}))).flat(),
|
|
524
|
-
|
|
524
|
+
// flatMap, not map: each CDP's fetch has to be one of the awaited promises, or getPortfolioData can return
|
|
525
|
+
// before a vault's data lands and the vault is missing from the result.
|
|
526
|
+
...addresses.flatMap((address) => {
|
|
525
527
|
var _a;
|
|
526
|
-
return (_a = makerCdps[address.toLowerCase()])
|
|
528
|
+
return ((_a = makerCdps[address.toLowerCase()]) !== null && _a !== void 0 ? _a : []).map((cdpInfo) => __awaiter(this, void 0, void 0, function* () {
|
|
527
529
|
try {
|
|
528
530
|
const cdpData = yield (0, maker_1._getMakerCdpData)(client, network, cdpInfo);
|
|
529
531
|
if (cdpData) {
|
|
@@ -535,7 +537,7 @@ function getPortfolioData(provider_1, network_1, defaultProvider_1, addresses_1)
|
|
|
535
537
|
positions[address.toLowerCase()].maker[cdpInfo.id] = { error: `Error fetching Maker CDP data for address ${address} with ID ${cdpInfo.id}`, data: null };
|
|
536
538
|
}
|
|
537
539
|
}));
|
|
538
|
-
})
|
|
540
|
+
}),
|
|
539
541
|
...aaveV2Markets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
540
542
|
try {
|
|
541
543
|
const accData = yield (0, aaveV2_1._getAaveV2AccountData)(client, network, address, aaveV2MarketsData[market.value].assetsData, market);
|
package/cjs/types/aave.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IncentiveData, LeverageType, MMAssetData, MMPositionData, MMUsedAsset, NetworkNumber } from './common';
|
|
1
|
+
import { EthAddress, IncentiveData, LeverageType, MMAssetData, MMPositionData, MMUsedAsset, NetworkNumber } from './common';
|
|
2
2
|
export declare enum AaveVersions {
|
|
3
3
|
AaveV1 = "v1",
|
|
4
4
|
AaveV2 = "v2default",
|
|
@@ -84,6 +84,8 @@ export interface AaveV3AssetData extends AaveAssetData {
|
|
|
84
84
|
liquidationBonus: string;
|
|
85
85
|
supplyIncentives: IncentiveData[];
|
|
86
86
|
borrowIncentives: IncentiveData[];
|
|
87
|
+
aTokenAddress?: EthAddress;
|
|
88
|
+
vTokenAddress?: EthAddress;
|
|
87
89
|
}
|
|
88
90
|
export type EModeCategoriesData = Record<number, EModeCategoryData>;
|
|
89
91
|
export type AaveAssetsData<T> = {
|
|
@@ -121,7 +123,12 @@ export type AaveUsedAssets<T> = {
|
|
|
121
123
|
};
|
|
122
124
|
export type AaveV2UsedAssets = AaveUsedAssets<AaveV2UsedAsset>;
|
|
123
125
|
export type AaveV3UsedAssets = AaveUsedAssets<AaveV3UsedAsset>;
|
|
124
|
-
|
|
126
|
+
/**
|
|
127
|
+
* Fields aaveAnyGetAggregatedPositionData adds to every Aave V2/V3 position at runtime, on top of those declared
|
|
128
|
+
* below. Optional, so code that builds a position by hand keeps compiling.
|
|
129
|
+
*/
|
|
130
|
+
export type AavePositionAggregatedFields = Partial<Omit<AaveV3AggregatedPositionData, keyof MMPositionData | 'ratio' | 'collRatio' | 'safetyRatioWithLtvZeroFallback' | 'suppliedUsd' | 'borrowedUsd' | 'borrowLimitUsd' | 'suppliedCollateralUsd' | 'incentiveUsd' | 'totalInterestUsd'>>;
|
|
131
|
+
export interface AavePositionData extends MMPositionData, AavePositionAggregatedFields {
|
|
125
132
|
ratio: string;
|
|
126
133
|
minRatio: string;
|
|
127
134
|
collRatio: string;
|
|
@@ -138,6 +145,12 @@ export interface AavePositionData extends MMPositionData {
|
|
|
138
145
|
}
|
|
139
146
|
export interface AaveV2PositionData extends AavePositionData {
|
|
140
147
|
usedAssets: AaveV2UsedAssets;
|
|
148
|
+
eModeCategory?: number;
|
|
149
|
+
isInIsolationMode?: boolean;
|
|
150
|
+
isInSiloedMode?: boolean;
|
|
151
|
+
eModeCategories?: {
|
|
152
|
+
[key: number]: EModeCategoryDataMapping;
|
|
153
|
+
};
|
|
141
154
|
}
|
|
142
155
|
export interface AaveV3PositionData extends AavePositionData {
|
|
143
156
|
usedAssets: AaveV3UsedAssets;
|
package/cjs/types/compound.d.ts
CHANGED
|
@@ -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;
|
|
@@ -123,9 +135,21 @@ export interface CompoundPositionData extends MMPositionData {
|
|
|
123
135
|
isSubscribedToAutomation?: boolean;
|
|
124
136
|
automationResubscribeRequired?: boolean;
|
|
125
137
|
}
|
|
126
|
-
|
|
138
|
+
/**
|
|
139
|
+
* Fields getCompoundV2AggregatedData adds to every Compound V2 position at runtime — a subset of
|
|
140
|
+
* CompoundAggregatedPositionData. Optional, so code that builds a position by hand keeps compiling.
|
|
141
|
+
*/
|
|
142
|
+
export type CompoundV2PositionAggregatedFields = Partial<Pick<CompoundAggregatedPositionData, 'suppliedCollateralUsd' | 'liquidationLimitUsd' | 'leftToBorrowUsd' | 'collRatio' | 'leveragedType' | 'leveragedAsset' | 'liquidationPrice'>>;
|
|
143
|
+
/**
|
|
144
|
+
* Fields getCompoundV3AggregatedData adds to every Compound V3 position at runtime, on top of those declared in
|
|
145
|
+
* CompoundPositionData. Optional, so code that builds a position by hand keeps compiling.
|
|
146
|
+
*/
|
|
147
|
+
export type CompoundV3PositionAggregatedFields = Partial<Omit<CompoundAggregatedPositionData, keyof MMPositionData | 'ratio' | 'minRatio' | 'suppliedUsd' | 'borrowedUsd' | 'borrowLimitUsd' | 'incentiveUsd' | 'totalInterestUsd'>>;
|
|
148
|
+
export interface CompoundV2PositionData extends CompoundPositionData, CompoundV2PositionAggregatedFields {
|
|
127
149
|
usedAssets: CompoundV2UsedAssets;
|
|
150
|
+
borrowStableSupplyUnstable?: boolean;
|
|
128
151
|
}
|
|
129
|
-
export interface CompoundV3PositionData extends CompoundPositionData {
|
|
152
|
+
export interface CompoundV3PositionData extends CompoundPositionData, CompoundV3PositionAggregatedFields {
|
|
130
153
|
usedAssets: CompoundV3UsedAssets;
|
|
154
|
+
isAllowed?: boolean;
|
|
131
155
|
}
|
package/cjs/types/curveUsd.d.ts
CHANGED
|
@@ -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;
|
|
@@ -91,7 +92,8 @@ export interface CrvUSDUsedAsset {
|
|
|
91
92
|
export interface CrvUSDUsedAssets {
|
|
92
93
|
[key: string]: CrvUSDUsedAsset;
|
|
93
94
|
}
|
|
94
|
-
export
|
|
95
|
+
export type CrvUSDPositionAggregatedFields = Partial<Pick<CrvUSDAggregatedPositionData, 'borrowLimitUsd' | 'minAllowedRatio' | 'collFactor' | 'leveragedType' | 'leveragedAsset' | 'liquidationPrice'>>;
|
|
96
|
+
export interface CrvUSDUserData extends CrvUSDPositionAggregatedFields {
|
|
95
97
|
debtAmount: string;
|
|
96
98
|
health: string;
|
|
97
99
|
healthPercent: string;
|
|
@@ -113,4 +115,10 @@ export interface CrvUSDUserData {
|
|
|
113
115
|
collateralPrice: string;
|
|
114
116
|
collRatio: string;
|
|
115
117
|
exposure: string;
|
|
118
|
+
marketCollateralAmount?: bigint;
|
|
119
|
+
curveUsdCollateralAmount?: bigint;
|
|
120
|
+
N?: bigint;
|
|
121
|
+
bandRange?: readonly [bigint, bigint];
|
|
122
|
+
usersBands?: readonly [readonly bigint[], readonly bigint[]];
|
|
123
|
+
isInSoftLiquidation?: boolean;
|
|
116
124
|
}
|
package/cjs/types/llamaLend.d.ts
CHANGED
|
@@ -138,7 +138,8 @@ export interface LlamaLendUsedAsset {
|
|
|
138
138
|
export interface LlamaLendUsedAssets {
|
|
139
139
|
[key: string]: LlamaLendUsedAsset;
|
|
140
140
|
}
|
|
141
|
-
export
|
|
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
|
}
|
package/cjs/types/spark.d.ts
CHANGED
|
@@ -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;
|
|
@@ -100,7 +115,12 @@ export interface SparkAggregatedPositionData {
|
|
|
100
115
|
minHealthRatio: string;
|
|
101
116
|
exposure: string;
|
|
102
117
|
}
|
|
103
|
-
|
|
118
|
+
/**
|
|
119
|
+
* Fields sparkGetAggregatedPositionData adds to every Spark position at runtime, on top of those declared below.
|
|
120
|
+
* Optional, so code that builds a position by hand keeps compiling.
|
|
121
|
+
*/
|
|
122
|
+
export type SparkPositionAggregatedFields = Partial<Omit<SparkAggregatedPositionData, keyof MMPositionData | 'ratio' | 'collRatio' | 'suppliedUsd' | 'borrowedUsd' | 'borrowLimitUsd' | 'suppliedCollateralUsd' | 'incentiveUsd' | 'totalInterestUsd'>>;
|
|
123
|
+
export interface SparkPositionData extends MMPositionData, SparkPositionAggregatedFields {
|
|
104
124
|
ratio: string;
|
|
105
125
|
minRatio: string;
|
|
106
126
|
collRatio: string;
|
package/esm/portfolio/index.js
CHANGED
|
@@ -501,9 +501,11 @@ export function getPortfolioData(provider_1, network_1, defaultProvider_1, addre
|
|
|
501
501
|
positions[address.toLowerCase()].spark[market.value] = { error: `Error fetching Spark account data for address ${address} on market ${market.value}`, data: null };
|
|
502
502
|
}
|
|
503
503
|
}))).flat(),
|
|
504
|
-
|
|
504
|
+
// flatMap, not map: each CDP's fetch has to be one of the awaited promises, or getPortfolioData can return
|
|
505
|
+
// before a vault's data lands and the vault is missing from the result.
|
|
506
|
+
...addresses.flatMap((address) => {
|
|
505
507
|
var _a;
|
|
506
|
-
return (_a = makerCdps[address.toLowerCase()])
|
|
508
|
+
return ((_a = makerCdps[address.toLowerCase()]) !== null && _a !== void 0 ? _a : []).map((cdpInfo) => __awaiter(this, void 0, void 0, function* () {
|
|
507
509
|
try {
|
|
508
510
|
const cdpData = yield _getMakerCdpData(client, network, cdpInfo);
|
|
509
511
|
if (cdpData) {
|
|
@@ -515,7 +517,7 @@ export function getPortfolioData(provider_1, network_1, defaultProvider_1, addre
|
|
|
515
517
|
positions[address.toLowerCase()].maker[cdpInfo.id] = { error: `Error fetching Maker CDP data for address ${address} with ID ${cdpInfo.id}`, data: null };
|
|
516
518
|
}
|
|
517
519
|
}));
|
|
518
|
-
})
|
|
520
|
+
}),
|
|
519
521
|
...aaveV2Markets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
520
522
|
try {
|
|
521
523
|
const accData = yield _getAaveV2AccountData(client, network, address, aaveV2MarketsData[market.value].assetsData, market);
|
package/esm/types/aave.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IncentiveData, LeverageType, MMAssetData, MMPositionData, MMUsedAsset, NetworkNumber } from './common';
|
|
1
|
+
import { EthAddress, IncentiveData, LeverageType, MMAssetData, MMPositionData, MMUsedAsset, NetworkNumber } from './common';
|
|
2
2
|
export declare enum AaveVersions {
|
|
3
3
|
AaveV1 = "v1",
|
|
4
4
|
AaveV2 = "v2default",
|
|
@@ -84,6 +84,8 @@ export interface AaveV3AssetData extends AaveAssetData {
|
|
|
84
84
|
liquidationBonus: string;
|
|
85
85
|
supplyIncentives: IncentiveData[];
|
|
86
86
|
borrowIncentives: IncentiveData[];
|
|
87
|
+
aTokenAddress?: EthAddress;
|
|
88
|
+
vTokenAddress?: EthAddress;
|
|
87
89
|
}
|
|
88
90
|
export type EModeCategoriesData = Record<number, EModeCategoryData>;
|
|
89
91
|
export type AaveAssetsData<T> = {
|
|
@@ -121,7 +123,12 @@ export type AaveUsedAssets<T> = {
|
|
|
121
123
|
};
|
|
122
124
|
export type AaveV2UsedAssets = AaveUsedAssets<AaveV2UsedAsset>;
|
|
123
125
|
export type AaveV3UsedAssets = AaveUsedAssets<AaveV3UsedAsset>;
|
|
124
|
-
|
|
126
|
+
/**
|
|
127
|
+
* Fields aaveAnyGetAggregatedPositionData adds to every Aave V2/V3 position at runtime, on top of those declared
|
|
128
|
+
* below. Optional, so code that builds a position by hand keeps compiling.
|
|
129
|
+
*/
|
|
130
|
+
export type AavePositionAggregatedFields = Partial<Omit<AaveV3AggregatedPositionData, keyof MMPositionData | 'ratio' | 'collRatio' | 'safetyRatioWithLtvZeroFallback' | 'suppliedUsd' | 'borrowedUsd' | 'borrowLimitUsd' | 'suppliedCollateralUsd' | 'incentiveUsd' | 'totalInterestUsd'>>;
|
|
131
|
+
export interface AavePositionData extends MMPositionData, AavePositionAggregatedFields {
|
|
125
132
|
ratio: string;
|
|
126
133
|
minRatio: string;
|
|
127
134
|
collRatio: string;
|
|
@@ -138,6 +145,12 @@ export interface AavePositionData extends MMPositionData {
|
|
|
138
145
|
}
|
|
139
146
|
export interface AaveV2PositionData extends AavePositionData {
|
|
140
147
|
usedAssets: AaveV2UsedAssets;
|
|
148
|
+
eModeCategory?: number;
|
|
149
|
+
isInIsolationMode?: boolean;
|
|
150
|
+
isInSiloedMode?: boolean;
|
|
151
|
+
eModeCategories?: {
|
|
152
|
+
[key: number]: EModeCategoryDataMapping;
|
|
153
|
+
};
|
|
141
154
|
}
|
|
142
155
|
export interface AaveV3PositionData extends AavePositionData {
|
|
143
156
|
usedAssets: AaveV3UsedAssets;
|
package/esm/types/compound.d.ts
CHANGED
|
@@ -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;
|
|
@@ -123,9 +135,21 @@ export interface CompoundPositionData extends MMPositionData {
|
|
|
123
135
|
isSubscribedToAutomation?: boolean;
|
|
124
136
|
automationResubscribeRequired?: boolean;
|
|
125
137
|
}
|
|
126
|
-
|
|
138
|
+
/**
|
|
139
|
+
* Fields getCompoundV2AggregatedData adds to every Compound V2 position at runtime — a subset of
|
|
140
|
+
* CompoundAggregatedPositionData. Optional, so code that builds a position by hand keeps compiling.
|
|
141
|
+
*/
|
|
142
|
+
export type CompoundV2PositionAggregatedFields = Partial<Pick<CompoundAggregatedPositionData, 'suppliedCollateralUsd' | 'liquidationLimitUsd' | 'leftToBorrowUsd' | 'collRatio' | 'leveragedType' | 'leveragedAsset' | 'liquidationPrice'>>;
|
|
143
|
+
/**
|
|
144
|
+
* Fields getCompoundV3AggregatedData adds to every Compound V3 position at runtime, on top of those declared in
|
|
145
|
+
* CompoundPositionData. Optional, so code that builds a position by hand keeps compiling.
|
|
146
|
+
*/
|
|
147
|
+
export type CompoundV3PositionAggregatedFields = Partial<Omit<CompoundAggregatedPositionData, keyof MMPositionData | 'ratio' | 'minRatio' | 'suppliedUsd' | 'borrowedUsd' | 'borrowLimitUsd' | 'incentiveUsd' | 'totalInterestUsd'>>;
|
|
148
|
+
export interface CompoundV2PositionData extends CompoundPositionData, CompoundV2PositionAggregatedFields {
|
|
127
149
|
usedAssets: CompoundV2UsedAssets;
|
|
150
|
+
borrowStableSupplyUnstable?: boolean;
|
|
128
151
|
}
|
|
129
|
-
export interface CompoundV3PositionData extends CompoundPositionData {
|
|
152
|
+
export interface CompoundV3PositionData extends CompoundPositionData, CompoundV3PositionAggregatedFields {
|
|
130
153
|
usedAssets: CompoundV3UsedAssets;
|
|
154
|
+
isAllowed?: boolean;
|
|
131
155
|
}
|
package/esm/types/curveUsd.d.ts
CHANGED
|
@@ -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;
|
|
@@ -91,7 +92,8 @@ export interface CrvUSDUsedAsset {
|
|
|
91
92
|
export interface CrvUSDUsedAssets {
|
|
92
93
|
[key: string]: CrvUSDUsedAsset;
|
|
93
94
|
}
|
|
94
|
-
export
|
|
95
|
+
export type CrvUSDPositionAggregatedFields = Partial<Pick<CrvUSDAggregatedPositionData, 'borrowLimitUsd' | 'minAllowedRatio' | 'collFactor' | 'leveragedType' | 'leveragedAsset' | 'liquidationPrice'>>;
|
|
96
|
+
export interface CrvUSDUserData extends CrvUSDPositionAggregatedFields {
|
|
95
97
|
debtAmount: string;
|
|
96
98
|
health: string;
|
|
97
99
|
healthPercent: string;
|
|
@@ -113,4 +115,10 @@ export interface CrvUSDUserData {
|
|
|
113
115
|
collateralPrice: string;
|
|
114
116
|
collRatio: string;
|
|
115
117
|
exposure: string;
|
|
118
|
+
marketCollateralAmount?: bigint;
|
|
119
|
+
curveUsdCollateralAmount?: bigint;
|
|
120
|
+
N?: bigint;
|
|
121
|
+
bandRange?: readonly [bigint, bigint];
|
|
122
|
+
usersBands?: readonly [readonly bigint[], readonly bigint[]];
|
|
123
|
+
isInSoftLiquidation?: boolean;
|
|
116
124
|
}
|
package/esm/types/llamaLend.d.ts
CHANGED
|
@@ -138,7 +138,8 @@ export interface LlamaLendUsedAsset {
|
|
|
138
138
|
export interface LlamaLendUsedAssets {
|
|
139
139
|
[key: string]: LlamaLendUsedAsset;
|
|
140
140
|
}
|
|
141
|
-
export
|
|
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
|
}
|
package/esm/types/spark.d.ts
CHANGED
|
@@ -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;
|
|
@@ -100,7 +115,12 @@ export interface SparkAggregatedPositionData {
|
|
|
100
115
|
minHealthRatio: string;
|
|
101
116
|
exposure: string;
|
|
102
117
|
}
|
|
103
|
-
|
|
118
|
+
/**
|
|
119
|
+
* Fields sparkGetAggregatedPositionData adds to every Spark position at runtime, on top of those declared below.
|
|
120
|
+
* Optional, so code that builds a position by hand keeps compiling.
|
|
121
|
+
*/
|
|
122
|
+
export type SparkPositionAggregatedFields = Partial<Omit<SparkAggregatedPositionData, keyof MMPositionData | 'ratio' | 'collRatio' | 'suppliedUsd' | 'borrowedUsd' | 'borrowLimitUsd' | 'suppliedCollateralUsd' | 'incentiveUsd' | 'totalInterestUsd'>>;
|
|
123
|
+
export interface SparkPositionData extends MMPositionData, SparkPositionAggregatedFields {
|
|
104
124
|
ratio: string;
|
|
105
125
|
minRatio: string;
|
|
106
126
|
collRatio: string;
|
package/package.json
CHANGED
package/src/portfolio/index.ts
CHANGED
|
@@ -506,7 +506,9 @@ export async function getPortfolioData(provider: EthereumProvider, network: Netw
|
|
|
506
506
|
positions[address.toLowerCase() as EthAddress].spark[market.value] = { error: `Error fetching Spark account data for address ${address} on market ${market.value}`, data: null };
|
|
507
507
|
}
|
|
508
508
|
})).flat(),
|
|
509
|
-
|
|
509
|
+
// flatMap, not map: each CDP's fetch has to be one of the awaited promises, or getPortfolioData can return
|
|
510
|
+
// before a vault's data lands and the vault is missing from the result.
|
|
511
|
+
...addresses.flatMap((address) => (makerCdps[address.toLowerCase() as EthAddress] ?? []).map(async (cdpInfo) => {
|
|
510
512
|
try {
|
|
511
513
|
const cdpData = await _getMakerCdpData(client, network, cdpInfo);
|
|
512
514
|
if (cdpData) {
|
|
@@ -516,7 +518,7 @@ export async function getPortfolioData(provider: EthereumProvider, network: Netw
|
|
|
516
518
|
console.error(`Error fetching Maker CDP data for address ${address} with ID ${cdpInfo.id}:`, error);
|
|
517
519
|
positions[address.toLowerCase() as EthAddress].maker[cdpInfo.id] = { error: `Error fetching Maker CDP data for address ${address} with ID ${cdpInfo.id}`, data: null };
|
|
518
520
|
}
|
|
519
|
-
}))
|
|
521
|
+
})),
|
|
520
522
|
...aaveV2Markets.map((market) => addresses.map(async (address) => {
|
|
521
523
|
try {
|
|
522
524
|
const accData = await _getAaveV2AccountData(client, network, address, aaveV2MarketsData[market.value].assetsData, market);
|
package/src/types/aave.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
EthAddress,
|
|
2
3
|
IncentiveData,
|
|
3
4
|
LeverageType,
|
|
4
5
|
MMAssetData, MMPositionData, MMUsedAsset, NetworkNumber,
|
|
@@ -96,6 +97,9 @@ export interface AaveV3AssetData extends AaveAssetData {
|
|
|
96
97
|
liquidationBonus: string,
|
|
97
98
|
supplyIncentives: IncentiveData[];
|
|
98
99
|
borrowIncentives: IncentiveData[];
|
|
100
|
+
// Set by _getAaveV3MarketData. Optional, so objects built by hand still type-check.
|
|
101
|
+
aTokenAddress?: EthAddress,
|
|
102
|
+
vTokenAddress?: EthAddress,
|
|
99
103
|
}
|
|
100
104
|
|
|
101
105
|
export type EModeCategoriesData = Record<number, EModeCategoryData>;
|
|
@@ -137,7 +141,15 @@ export type AaveV2UsedAssets = AaveUsedAssets<AaveV2UsedAsset>;
|
|
|
137
141
|
|
|
138
142
|
export type AaveV3UsedAssets = AaveUsedAssets<AaveV3UsedAsset>;
|
|
139
143
|
|
|
140
|
-
|
|
144
|
+
/**
|
|
145
|
+
* Fields aaveAnyGetAggregatedPositionData adds to every Aave V2/V3 position at runtime, on top of those declared
|
|
146
|
+
* below. Optional, so code that builds a position by hand keeps compiling.
|
|
147
|
+
*/
|
|
148
|
+
export type AavePositionAggregatedFields = Partial<Omit<AaveV3AggregatedPositionData,
|
|
149
|
+
| keyof MMPositionData | 'ratio' | 'collRatio' | 'safetyRatioWithLtvZeroFallback' | 'suppliedUsd' | 'borrowedUsd'
|
|
150
|
+
| 'borrowLimitUsd' | 'suppliedCollateralUsd' | 'incentiveUsd' | 'totalInterestUsd'>>;
|
|
151
|
+
|
|
152
|
+
export interface AavePositionData extends MMPositionData, AavePositionAggregatedFields {
|
|
141
153
|
ratio: string,
|
|
142
154
|
minRatio: string,
|
|
143
155
|
collRatio: string,
|
|
@@ -156,6 +168,11 @@ export interface AavePositionData extends MMPositionData {
|
|
|
156
168
|
|
|
157
169
|
export interface AaveV2PositionData extends AavePositionData {
|
|
158
170
|
usedAssets: AaveV2UsedAssets,
|
|
171
|
+
// Always their empty values: _getAaveV2AccountData starts from Aave V3's EMPTY_AAVE_DATA, which carries them.
|
|
172
|
+
eModeCategory?: number,
|
|
173
|
+
isInIsolationMode?: boolean,
|
|
174
|
+
isInSiloedMode?: boolean,
|
|
175
|
+
eModeCategories?: { [key: number]: EModeCategoryDataMapping },
|
|
159
176
|
}
|
|
160
177
|
|
|
161
178
|
export interface AaveV3PositionData extends AavePositionData {
|
package/src/types/compound.ts
CHANGED
|
@@ -70,6 +70,8 @@ export interface CompoundAssetData extends MMAssetData {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
export interface CompoundV2AssetData extends CompoundAssetData {
|
|
73
|
+
// Set by _getCompoundV2MarketsData. Optional, so objects built by hand still type-check.
|
|
74
|
+
exchangeRate?: string,
|
|
73
75
|
}
|
|
74
76
|
export interface CompoundV3AssetData extends CompoundAssetData {
|
|
75
77
|
borrowCollateralFactor: string,
|
|
@@ -81,6 +83,20 @@ export interface CompoundV3AssetData extends CompoundAssetData {
|
|
|
81
83
|
supplyCap: string,
|
|
82
84
|
priceInBaseAsset: string,
|
|
83
85
|
canBeWithdrawn: boolean,
|
|
86
|
+
// The rest are set by formatMarketData and formatBaseData, which also spread in the view contract's raw asset
|
|
87
|
+
// data. Optional, so objects built by hand still type-check.
|
|
88
|
+
tokenAddr?: EthAddress,
|
|
89
|
+
// The base asset's only.
|
|
90
|
+
isBase?: boolean,
|
|
91
|
+
baseBorrowMin?: string,
|
|
92
|
+
baseTrackingBorrowRewardsSpeed?: string,
|
|
93
|
+
baseTrackingSupplyRewardsSpeed?: string,
|
|
94
|
+
borrowIndex?: string,
|
|
95
|
+
supplyIndex?: string,
|
|
96
|
+
trackingBorrowIndex?: string,
|
|
97
|
+
trackingSupplyIndex?: string,
|
|
98
|
+
rewardSupplySpeed?: string,
|
|
99
|
+
rewardBorrowSpeed?: string,
|
|
84
100
|
}
|
|
85
101
|
|
|
86
102
|
export interface CompoundAssetsData<T> {
|
|
@@ -141,10 +157,30 @@ export interface CompoundPositionData extends MMPositionData {
|
|
|
141
157
|
automationResubscribeRequired?: boolean,
|
|
142
158
|
}
|
|
143
159
|
|
|
144
|
-
|
|
160
|
+
/**
|
|
161
|
+
* Fields getCompoundV2AggregatedData adds to every Compound V2 position at runtime — a subset of
|
|
162
|
+
* CompoundAggregatedPositionData. Optional, so code that builds a position by hand keeps compiling.
|
|
163
|
+
*/
|
|
164
|
+
export type CompoundV2PositionAggregatedFields = Partial<Pick<CompoundAggregatedPositionData,
|
|
165
|
+
| 'suppliedCollateralUsd' | 'liquidationLimitUsd' | 'leftToBorrowUsd' | 'collRatio' | 'leveragedType'
|
|
166
|
+
| 'leveragedAsset' | 'liquidationPrice'>>;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Fields getCompoundV3AggregatedData adds to every Compound V3 position at runtime, on top of those declared in
|
|
170
|
+
* CompoundPositionData. Optional, so code that builds a position by hand keeps compiling.
|
|
171
|
+
*/
|
|
172
|
+
export type CompoundV3PositionAggregatedFields = Partial<Omit<CompoundAggregatedPositionData,
|
|
173
|
+
| keyof MMPositionData | 'ratio' | 'minRatio' | 'suppliedUsd' | 'borrowedUsd' | 'borrowLimitUsd' | 'incentiveUsd'
|
|
174
|
+
| 'totalInterestUsd'>>;
|
|
175
|
+
|
|
176
|
+
export interface CompoundV2PositionData extends CompoundPositionData, CompoundV2PositionAggregatedFields {
|
|
145
177
|
usedAssets: CompoundV2UsedAssets,
|
|
178
|
+
// Always false: _getCompoundV2AccountData starts from EMPTY_COMPOUND_DATA, which carries it.
|
|
179
|
+
borrowStableSupplyUnstable?: boolean,
|
|
146
180
|
}
|
|
147
181
|
|
|
148
|
-
export interface CompoundV3PositionData extends CompoundPositionData {
|
|
182
|
+
export interface CompoundV3PositionData extends CompoundPositionData, CompoundV3PositionAggregatedFields {
|
|
149
183
|
usedAssets: CompoundV3UsedAssets,
|
|
184
|
+
// Whether the user's smart wallet is allowed to manage the account on Comet (Comet.isAllowed).
|
|
185
|
+
isAllowed?: boolean,
|
|
150
186
|
}
|
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 {
|
|
@@ -101,7 +104,12 @@ export interface CrvUSDUsedAssets {
|
|
|
101
104
|
[key: string]: CrvUSDUsedAsset,
|
|
102
105
|
}
|
|
103
106
|
|
|
104
|
-
|
|
107
|
+
// Set by getCrvUsdAggregatedData, which _getCurveUsdUserData spreads in. Optional, so objects built by hand still
|
|
108
|
+
// type-check.
|
|
109
|
+
export type CrvUSDPositionAggregatedFields = Partial<Pick<CrvUSDAggregatedPositionData,
|
|
110
|
+
| 'borrowLimitUsd' | 'minAllowedRatio' | 'collFactor' | 'leveragedType' | 'leveragedAsset' | 'liquidationPrice'>>;
|
|
111
|
+
|
|
112
|
+
export interface CrvUSDUserData extends CrvUSDPositionAggregatedFields {
|
|
105
113
|
debtAmount: string,
|
|
106
114
|
health: string,
|
|
107
115
|
healthPercent: string,
|
|
@@ -123,4 +131,12 @@ export interface CrvUSDUserData {
|
|
|
123
131
|
collateralPrice: string,
|
|
124
132
|
collRatio: string,
|
|
125
133
|
exposure: string,
|
|
134
|
+
// Fields of crvUSDView's userData that _getCurveUsdUserData spreads in unconverted. Optional, so objects built by
|
|
135
|
+
// hand still type-check.
|
|
136
|
+
marketCollateralAmount?: bigint,
|
|
137
|
+
curveUsdCollateralAmount?: bigint,
|
|
138
|
+
N?: bigint,
|
|
139
|
+
bandRange?: readonly [bigint, bigint],
|
|
140
|
+
usersBands?: readonly [readonly bigint[], readonly bigint[]],
|
|
141
|
+
isInSoftLiquidation?: boolean,
|
|
126
142
|
}
|
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
|
@@ -236,6 +236,9 @@ export interface MorphoBluePositionData {
|
|
|
236
236
|
supplyShares: string,
|
|
237
237
|
borrowShares: string,
|
|
238
238
|
exposure: string,
|
|
239
|
+
// Set by getMorphoBlueAggregatedPositionData. Optional, so objects built by hand still type-check.
|
|
240
|
+
minCollRatio?: string,
|
|
241
|
+
collLiquidationRatio?: string,
|
|
239
242
|
}
|
|
240
243
|
|
|
241
244
|
export interface MorphoBlueEarnData {
|
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 {
|
|
@@ -115,7 +131,15 @@ export interface SparkAggregatedPositionData {
|
|
|
115
131
|
exposure: string,
|
|
116
132
|
}
|
|
117
133
|
|
|
118
|
-
|
|
134
|
+
/**
|
|
135
|
+
* Fields sparkGetAggregatedPositionData adds to every Spark position at runtime, on top of those declared below.
|
|
136
|
+
* Optional, so code that builds a position by hand keeps compiling.
|
|
137
|
+
*/
|
|
138
|
+
export type SparkPositionAggregatedFields = Partial<Omit<SparkAggregatedPositionData,
|
|
139
|
+
| keyof MMPositionData | 'ratio' | 'collRatio' | 'suppliedUsd' | 'borrowedUsd' | 'borrowLimitUsd'
|
|
140
|
+
| 'suppliedCollateralUsd' | 'incentiveUsd' | 'totalInterestUsd'>>;
|
|
141
|
+
|
|
142
|
+
export interface SparkPositionData extends MMPositionData, SparkPositionAggregatedFields {
|
|
119
143
|
ratio: string,
|
|
120
144
|
minRatio: string,
|
|
121
145
|
collRatio: string,
|