@defisaver/positions-sdk 2.1.11 → 2.1.13
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/.mocharc.json +4 -4
- package/.nvmrc +1 -1
- package/README.md +64 -64
- package/cjs/aaveV3/index.js +1 -1
- package/cjs/contracts.d.ts +100947 -134653
- package/cjs/helpers/morphoBlueHelpers/index.js +66 -66
- package/cjs/markets/aave/marketAssets.js +1 -1
- package/cjs/services/viem.d.ts +2 -3254
- package/cjs/staking/staking.d.ts +1 -1
- package/cjs/staking/staking.js +17 -14
- package/esm/aaveV3/index.js +1 -1
- package/esm/contracts.d.ts +100947 -134653
- package/esm/helpers/morphoBlueHelpers/index.js +66 -66
- package/esm/markets/aave/marketAssets.js +1 -1
- package/esm/services/viem.d.ts +2 -3254
- package/esm/staking/staking.d.ts +1 -1
- package/esm/staking/staking.js +17 -14
- package/package.json +47 -47
- package/src/aaveV2/index.ts +240 -240
- package/src/aaveV3/index.ts +614 -614
- package/src/aaveV3/merit.ts +97 -97
- package/src/aaveV3/merkl.ts +74 -74
- package/src/claiming/aaveV3.ts +154 -154
- package/src/claiming/compV3.ts +22 -22
- package/src/claiming/index.ts +12 -12
- package/src/claiming/king.ts +66 -66
- package/src/claiming/morphoBlue.ts +118 -118
- package/src/claiming/spark.ts +225 -225
- package/src/compoundV2/index.ts +244 -244
- package/src/compoundV3/index.ts +274 -274
- package/src/config/contracts.ts +1251 -1251
- package/src/constants/index.ts +10 -10
- package/src/contracts.ts +120 -120
- package/src/curveUsd/index.ts +254 -254
- package/src/eulerV2/index.ts +324 -324
- package/src/exchange/index.ts +25 -25
- package/src/fluid/index.ts +1668 -1668
- package/src/helpers/aaveHelpers/index.ts +187 -187
- package/src/helpers/compoundHelpers/index.ts +283 -283
- package/src/helpers/curveUsdHelpers/index.ts +40 -40
- package/src/helpers/eulerHelpers/index.ts +222 -222
- package/src/helpers/fluidHelpers/index.ts +326 -326
- package/src/helpers/index.ts +10 -10
- package/src/helpers/liquityV2Helpers/index.ts +82 -82
- package/src/helpers/llamaLendHelpers/index.ts +53 -53
- package/src/helpers/makerHelpers/index.ts +52 -52
- package/src/helpers/morphoBlueHelpers/index.ts +396 -396
- package/src/helpers/sparkHelpers/index.ts +158 -158
- package/src/index.ts +47 -47
- package/src/liquity/index.ts +159 -159
- package/src/liquityV2/index.ts +657 -657
- package/src/llamaLend/index.ts +305 -305
- package/src/maker/index.ts +223 -223
- package/src/markets/aave/index.ts +116 -116
- package/src/markets/aave/marketAssets.ts +54 -54
- package/src/markets/compound/index.ts +238 -238
- package/src/markets/compound/marketsAssets.ts +97 -97
- package/src/markets/curveUsd/index.ts +69 -69
- package/src/markets/euler/index.ts +26 -26
- package/src/markets/fluid/index.ts +2460 -2460
- package/src/markets/index.ts +25 -25
- package/src/markets/liquityV2/index.ts +102 -102
- package/src/markets/llamaLend/contractAddresses.ts +141 -141
- package/src/markets/llamaLend/index.ts +235 -235
- package/src/markets/morphoBlue/index.ts +895 -895
- package/src/markets/spark/index.ts +29 -29
- package/src/markets/spark/marketAssets.ts +12 -12
- package/src/moneymarket/moneymarketCommonService.ts +80 -80
- package/src/morphoBlue/index.ts +274 -274
- package/src/portfolio/index.ts +570 -570
- package/src/services/priceService.ts +159 -159
- package/src/services/utils.ts +115 -115
- package/src/services/viem.ts +34 -34
- package/src/setup.ts +8 -8
- package/src/spark/index.ts +456 -456
- package/src/staking/eligibility.ts +53 -53
- package/src/staking/index.ts +1 -1
- package/src/staking/staking.ts +177 -172
- package/src/types/aave.ts +189 -189
- package/src/types/claiming.ts +109 -109
- package/src/types/common.ts +107 -107
- package/src/types/compound.ts +136 -136
- package/src/types/curveUsd.ts +123 -123
- package/src/types/euler.ts +175 -175
- package/src/types/fluid.ts +452 -452
- package/src/types/index.ts +13 -13
- package/src/types/liquity.ts +30 -30
- package/src/types/liquityV2.ts +126 -126
- package/src/types/llamaLend.ts +159 -159
- package/src/types/maker.ts +63 -63
- package/src/types/merit.ts +1 -1
- package/src/types/merkl.ts +70 -70
- package/src/types/morphoBlue.ts +194 -194
- package/src/types/portfolio.ts +60 -60
- package/src/types/spark.ts +133 -133
- package/src/umbrella/index.ts +69 -69
- package/src/umbrella/umbrellaUtils.ts +29 -29
package/src/types/portfolio.ts
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
import { AaveV2PositionData, AaveV3PositionData, AaveVersions } from './aave';
|
|
2
|
-
import { EthAddress } from './common';
|
|
3
|
-
import { CompoundV2PositionData, CompoundV3PositionData, CompoundVersions } from './compound';
|
|
4
|
-
import { CrvUSDUserData, CrvUSDVersions } from './curveUsd';
|
|
5
|
-
import { EulerV2PositionData, EulerV2Versions } from './euler';
|
|
6
|
-
import { FluidVaultData } from './fluid';
|
|
7
|
-
import { LiquityTroveInfo } from './liquity';
|
|
8
|
-
import { LiquityV2TroveData, LiquityV2Versions } from './liquityV2';
|
|
9
|
-
import { LlamaLendUserData, LlamaLendVersionsType } from './llamaLend';
|
|
10
|
-
import { CdpData } from './maker';
|
|
11
|
-
import { MorphoBluePositionData, MorphoBlueVersions } from './morphoBlue';
|
|
12
|
-
import { SparkPositionData, SparkVersions } from './spark';
|
|
13
|
-
|
|
14
|
-
export interface PortfolioProtocolData<T> {
|
|
15
|
-
error: string,
|
|
16
|
-
data: T | null,
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface PortfolioPositionsDataForAddress {
|
|
20
|
-
aaveV3: {
|
|
21
|
-
[key in AaveVersions]?: PortfolioProtocolData<AaveV3PositionData>;
|
|
22
|
-
};
|
|
23
|
-
morphoBlue: {
|
|
24
|
-
[key in MorphoBlueVersions]?: PortfolioProtocolData<MorphoBluePositionData>;
|
|
25
|
-
};
|
|
26
|
-
compoundV3: {
|
|
27
|
-
[key in CompoundVersions]?: PortfolioProtocolData<CompoundV3PositionData>;
|
|
28
|
-
};
|
|
29
|
-
spark: {
|
|
30
|
-
[key in SparkVersions]?: PortfolioProtocolData<SparkPositionData>;
|
|
31
|
-
};
|
|
32
|
-
eulerV2: {
|
|
33
|
-
[key in EulerV2Versions]?: Record<EthAddress, PortfolioProtocolData<EulerV2PositionData>>;
|
|
34
|
-
};
|
|
35
|
-
maker: {
|
|
36
|
-
[key: string]: PortfolioProtocolData<CdpData>;
|
|
37
|
-
};
|
|
38
|
-
aaveV2: {
|
|
39
|
-
[key in AaveVersions]?: PortfolioProtocolData<AaveV2PositionData>;
|
|
40
|
-
};
|
|
41
|
-
compoundV2: {
|
|
42
|
-
[key in CompoundVersions]?: PortfolioProtocolData<CompoundV2PositionData>;
|
|
43
|
-
};
|
|
44
|
-
liquity: PortfolioProtocolData<LiquityTroveInfo> | {};
|
|
45
|
-
crvUsd: {
|
|
46
|
-
[key in CrvUSDVersions]?: PortfolioProtocolData<CrvUSDUserData>;
|
|
47
|
-
};
|
|
48
|
-
llamaLend: {
|
|
49
|
-
[key in LlamaLendVersionsType]?: PortfolioProtocolData<LlamaLendUserData>;
|
|
50
|
-
};
|
|
51
|
-
fluid: {
|
|
52
|
-
error: string;
|
|
53
|
-
data: {
|
|
54
|
-
[key: string]: FluidVaultData;
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export interface PortfolioPositionsData {
|
|
60
|
-
[key: EthAddress]: PortfolioPositionsDataForAddress;
|
|
1
|
+
import { AaveV2PositionData, AaveV3PositionData, AaveVersions } from './aave';
|
|
2
|
+
import { EthAddress } from './common';
|
|
3
|
+
import { CompoundV2PositionData, CompoundV3PositionData, CompoundVersions } from './compound';
|
|
4
|
+
import { CrvUSDUserData, CrvUSDVersions } from './curveUsd';
|
|
5
|
+
import { EulerV2PositionData, EulerV2Versions } from './euler';
|
|
6
|
+
import { FluidVaultData } from './fluid';
|
|
7
|
+
import { LiquityTroveInfo } from './liquity';
|
|
8
|
+
import { LiquityV2TroveData, LiquityV2Versions } from './liquityV2';
|
|
9
|
+
import { LlamaLendUserData, LlamaLendVersionsType } from './llamaLend';
|
|
10
|
+
import { CdpData } from './maker';
|
|
11
|
+
import { MorphoBluePositionData, MorphoBlueVersions } from './morphoBlue';
|
|
12
|
+
import { SparkPositionData, SparkVersions } from './spark';
|
|
13
|
+
|
|
14
|
+
export interface PortfolioProtocolData<T> {
|
|
15
|
+
error: string,
|
|
16
|
+
data: T | null,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface PortfolioPositionsDataForAddress {
|
|
20
|
+
aaveV3: {
|
|
21
|
+
[key in AaveVersions]?: PortfolioProtocolData<AaveV3PositionData>;
|
|
22
|
+
};
|
|
23
|
+
morphoBlue: {
|
|
24
|
+
[key in MorphoBlueVersions]?: PortfolioProtocolData<MorphoBluePositionData>;
|
|
25
|
+
};
|
|
26
|
+
compoundV3: {
|
|
27
|
+
[key in CompoundVersions]?: PortfolioProtocolData<CompoundV3PositionData>;
|
|
28
|
+
};
|
|
29
|
+
spark: {
|
|
30
|
+
[key in SparkVersions]?: PortfolioProtocolData<SparkPositionData>;
|
|
31
|
+
};
|
|
32
|
+
eulerV2: {
|
|
33
|
+
[key in EulerV2Versions]?: Record<EthAddress, PortfolioProtocolData<EulerV2PositionData>>;
|
|
34
|
+
};
|
|
35
|
+
maker: {
|
|
36
|
+
[key: string]: PortfolioProtocolData<CdpData>;
|
|
37
|
+
};
|
|
38
|
+
aaveV2: {
|
|
39
|
+
[key in AaveVersions]?: PortfolioProtocolData<AaveV2PositionData>;
|
|
40
|
+
};
|
|
41
|
+
compoundV2: {
|
|
42
|
+
[key in CompoundVersions]?: PortfolioProtocolData<CompoundV2PositionData>;
|
|
43
|
+
};
|
|
44
|
+
liquity: PortfolioProtocolData<LiquityTroveInfo> | {};
|
|
45
|
+
crvUsd: {
|
|
46
|
+
[key in CrvUSDVersions]?: PortfolioProtocolData<CrvUSDUserData>;
|
|
47
|
+
};
|
|
48
|
+
llamaLend: {
|
|
49
|
+
[key in LlamaLendVersionsType]?: PortfolioProtocolData<LlamaLendUserData>;
|
|
50
|
+
};
|
|
51
|
+
fluid: {
|
|
52
|
+
error: string;
|
|
53
|
+
data: {
|
|
54
|
+
[key: string]: FluidVaultData;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface PortfolioPositionsData {
|
|
60
|
+
[key: EthAddress]: PortfolioPositionsDataForAddress;
|
|
61
61
|
}
|
package/src/types/spark.ts
CHANGED
|
@@ -1,133 +1,133 @@
|
|
|
1
|
-
import { EModeCategoriesData } from './aave';
|
|
2
|
-
import {
|
|
3
|
-
EthAddress,
|
|
4
|
-
IncentiveData,
|
|
5
|
-
MMAssetData, MMPositionData, MMUsedAsset, NetworkNumber,
|
|
6
|
-
} from './common';
|
|
7
|
-
|
|
8
|
-
export enum SparkVersions {
|
|
9
|
-
SparkV1 = 'v1default',
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface SparkEModeCategoryData {
|
|
13
|
-
label: string,
|
|
14
|
-
liquidationBonus: string,
|
|
15
|
-
liquidationRatio: string,
|
|
16
|
-
collateralFactor: string,
|
|
17
|
-
priceSource: string,
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface SparkEModeCategoryDataMapping {
|
|
21
|
-
enteringTerms: boolean[],
|
|
22
|
-
canEnterCategory: boolean,
|
|
23
|
-
id: number,
|
|
24
|
-
enabledData: {
|
|
25
|
-
ratio: string,
|
|
26
|
-
liqRatio: string,
|
|
27
|
-
liqPercent: string,
|
|
28
|
-
collRatio: string,
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface SparkMarketData {
|
|
33
|
-
chainIds: NetworkNumber[],
|
|
34
|
-
label: string,
|
|
35
|
-
shortLabel: string,
|
|
36
|
-
url: string,
|
|
37
|
-
value: SparkVersions,
|
|
38
|
-
assets: readonly string[],
|
|
39
|
-
provider: '' | 'SparkPoolAddressesProvider',
|
|
40
|
-
providerAddress: EthAddress,
|
|
41
|
-
lendingPool: 'SparkLendingPool',
|
|
42
|
-
lendingPoolAddress: EthAddress,
|
|
43
|
-
protocolData: '' | 'SparkProtocolDataProvider',
|
|
44
|
-
protocolDataAddress: EthAddress,
|
|
45
|
-
subVersionLabel?: string
|
|
46
|
-
// icon: Function,
|
|
47
|
-
protocolName: string,
|
|
48
|
-
disabled?: boolean,
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export interface SparkAssetData extends MMAssetData {
|
|
52
|
-
totalBorrowVar: string,
|
|
53
|
-
sortIndex?: number,
|
|
54
|
-
usageAsCollateralEnabled: boolean,
|
|
55
|
-
isIsolated: boolean,
|
|
56
|
-
eModeCategory: number,
|
|
57
|
-
liquidationRatio: string,
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export interface SparkAssetsData {
|
|
61
|
-
[token: string]: SparkAssetData,
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export type SparkMarketsData = { assetsData: SparkAssetsData, eModeCategoriesData: EModeCategoriesData };
|
|
65
|
-
|
|
66
|
-
export interface SparkUsedAsset extends MMUsedAsset {
|
|
67
|
-
stableBorrowRate: string,
|
|
68
|
-
borrowedStable: string,
|
|
69
|
-
borrowedVariable: string,
|
|
70
|
-
borrowedUsdStable: string,
|
|
71
|
-
borrowedUsdVariable: string,
|
|
72
|
-
stableLimit: string,
|
|
73
|
-
variableLimit: string,
|
|
74
|
-
limit: string,
|
|
75
|
-
eModeCategory: number,
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export interface SparkUsedAssets {
|
|
79
|
-
[token: string]: SparkUsedAsset,
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export interface SparkHelperCommon {
|
|
83
|
-
usedAssets: SparkUsedAssets,
|
|
84
|
-
eModeCategory: number,
|
|
85
|
-
eModeCategoriesData?: EModeCategoriesData,
|
|
86
|
-
assetsData: SparkAssetsData,
|
|
87
|
-
selectedMarket?: SparkMarketData,
|
|
88
|
-
network?: NetworkNumber,
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export interface SparkAggregatedPositionData {
|
|
92
|
-
suppliedUsd: string,
|
|
93
|
-
suppliedCollateralUsd: string,
|
|
94
|
-
borrowedUsd: string,
|
|
95
|
-
borrowLimitUsd: string,
|
|
96
|
-
liquidationLimitUsd: string,
|
|
97
|
-
leftToBorrowUsd: string,
|
|
98
|
-
ratio: string,
|
|
99
|
-
collRatio: string,
|
|
100
|
-
netApy: string,
|
|
101
|
-
incentiveUsd: string,
|
|
102
|
-
totalInterestUsd: string,
|
|
103
|
-
liqRatio: string,
|
|
104
|
-
liqPercent: string,
|
|
105
|
-
leveragedType: string,
|
|
106
|
-
leveragedAsset?: string,
|
|
107
|
-
leveragedLsdAssetRatio?: string,
|
|
108
|
-
liquidationPrice?: string,
|
|
109
|
-
minCollRatio: string,
|
|
110
|
-
collLiquidationRatio: string,
|
|
111
|
-
healthRatio: string;
|
|
112
|
-
minHealthRatio: string;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export interface SparkPositionData extends MMPositionData {
|
|
116
|
-
ratio: string,
|
|
117
|
-
minRatio: string,
|
|
118
|
-
collRatio: string,
|
|
119
|
-
suppliedUsd: string,
|
|
120
|
-
borrowedUsd: string,
|
|
121
|
-
borrowLimitUsd: string,
|
|
122
|
-
suppliedCollateralUsd: string,
|
|
123
|
-
incentiveUsd: string,
|
|
124
|
-
totalInterestUsd: string,
|
|
125
|
-
isSubscribedToAutomation?: boolean,
|
|
126
|
-
automationResubscribeRequired?: boolean,
|
|
127
|
-
totalSupplied: string,
|
|
128
|
-
usedAssets: SparkUsedAssets,
|
|
129
|
-
eModeCategory: number,
|
|
130
|
-
isInIsolationMode: boolean,
|
|
131
|
-
isInSiloedMode: boolean,
|
|
132
|
-
eModeCategories: { [key: number]: SparkEModeCategoryDataMapping },
|
|
133
|
-
}
|
|
1
|
+
import { EModeCategoriesData } from './aave';
|
|
2
|
+
import {
|
|
3
|
+
EthAddress,
|
|
4
|
+
IncentiveData,
|
|
5
|
+
MMAssetData, MMPositionData, MMUsedAsset, NetworkNumber,
|
|
6
|
+
} from './common';
|
|
7
|
+
|
|
8
|
+
export enum SparkVersions {
|
|
9
|
+
SparkV1 = 'v1default',
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface SparkEModeCategoryData {
|
|
13
|
+
label: string,
|
|
14
|
+
liquidationBonus: string,
|
|
15
|
+
liquidationRatio: string,
|
|
16
|
+
collateralFactor: string,
|
|
17
|
+
priceSource: string,
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface SparkEModeCategoryDataMapping {
|
|
21
|
+
enteringTerms: boolean[],
|
|
22
|
+
canEnterCategory: boolean,
|
|
23
|
+
id: number,
|
|
24
|
+
enabledData: {
|
|
25
|
+
ratio: string,
|
|
26
|
+
liqRatio: string,
|
|
27
|
+
liqPercent: string,
|
|
28
|
+
collRatio: string,
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface SparkMarketData {
|
|
33
|
+
chainIds: NetworkNumber[],
|
|
34
|
+
label: string,
|
|
35
|
+
shortLabel: string,
|
|
36
|
+
url: string,
|
|
37
|
+
value: SparkVersions,
|
|
38
|
+
assets: readonly string[],
|
|
39
|
+
provider: '' | 'SparkPoolAddressesProvider',
|
|
40
|
+
providerAddress: EthAddress,
|
|
41
|
+
lendingPool: 'SparkLendingPool',
|
|
42
|
+
lendingPoolAddress: EthAddress,
|
|
43
|
+
protocolData: '' | 'SparkProtocolDataProvider',
|
|
44
|
+
protocolDataAddress: EthAddress,
|
|
45
|
+
subVersionLabel?: string
|
|
46
|
+
// icon: Function,
|
|
47
|
+
protocolName: string,
|
|
48
|
+
disabled?: boolean,
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface SparkAssetData extends MMAssetData {
|
|
52
|
+
totalBorrowVar: string,
|
|
53
|
+
sortIndex?: number,
|
|
54
|
+
usageAsCollateralEnabled: boolean,
|
|
55
|
+
isIsolated: boolean,
|
|
56
|
+
eModeCategory: number,
|
|
57
|
+
liquidationRatio: string,
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface SparkAssetsData {
|
|
61
|
+
[token: string]: SparkAssetData,
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type SparkMarketsData = { assetsData: SparkAssetsData, eModeCategoriesData: EModeCategoriesData };
|
|
65
|
+
|
|
66
|
+
export interface SparkUsedAsset extends MMUsedAsset {
|
|
67
|
+
stableBorrowRate: string,
|
|
68
|
+
borrowedStable: string,
|
|
69
|
+
borrowedVariable: string,
|
|
70
|
+
borrowedUsdStable: string,
|
|
71
|
+
borrowedUsdVariable: string,
|
|
72
|
+
stableLimit: string,
|
|
73
|
+
variableLimit: string,
|
|
74
|
+
limit: string,
|
|
75
|
+
eModeCategory: number,
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface SparkUsedAssets {
|
|
79
|
+
[token: string]: SparkUsedAsset,
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface SparkHelperCommon {
|
|
83
|
+
usedAssets: SparkUsedAssets,
|
|
84
|
+
eModeCategory: number,
|
|
85
|
+
eModeCategoriesData?: EModeCategoriesData,
|
|
86
|
+
assetsData: SparkAssetsData,
|
|
87
|
+
selectedMarket?: SparkMarketData,
|
|
88
|
+
network?: NetworkNumber,
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface SparkAggregatedPositionData {
|
|
92
|
+
suppliedUsd: string,
|
|
93
|
+
suppliedCollateralUsd: string,
|
|
94
|
+
borrowedUsd: string,
|
|
95
|
+
borrowLimitUsd: string,
|
|
96
|
+
liquidationLimitUsd: string,
|
|
97
|
+
leftToBorrowUsd: string,
|
|
98
|
+
ratio: string,
|
|
99
|
+
collRatio: string,
|
|
100
|
+
netApy: string,
|
|
101
|
+
incentiveUsd: string,
|
|
102
|
+
totalInterestUsd: string,
|
|
103
|
+
liqRatio: string,
|
|
104
|
+
liqPercent: string,
|
|
105
|
+
leveragedType: string,
|
|
106
|
+
leveragedAsset?: string,
|
|
107
|
+
leveragedLsdAssetRatio?: string,
|
|
108
|
+
liquidationPrice?: string,
|
|
109
|
+
minCollRatio: string,
|
|
110
|
+
collLiquidationRatio: string,
|
|
111
|
+
healthRatio: string;
|
|
112
|
+
minHealthRatio: string;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface SparkPositionData extends MMPositionData {
|
|
116
|
+
ratio: string,
|
|
117
|
+
minRatio: string,
|
|
118
|
+
collRatio: string,
|
|
119
|
+
suppliedUsd: string,
|
|
120
|
+
borrowedUsd: string,
|
|
121
|
+
borrowLimitUsd: string,
|
|
122
|
+
suppliedCollateralUsd: string,
|
|
123
|
+
incentiveUsd: string,
|
|
124
|
+
totalInterestUsd: string,
|
|
125
|
+
isSubscribedToAutomation?: boolean,
|
|
126
|
+
automationResubscribeRequired?: boolean,
|
|
127
|
+
totalSupplied: string,
|
|
128
|
+
usedAssets: SparkUsedAssets,
|
|
129
|
+
eModeCategory: number,
|
|
130
|
+
isInIsolationMode: boolean,
|
|
131
|
+
isInSiloedMode: boolean,
|
|
132
|
+
eModeCategories: { [key: number]: SparkEModeCategoryDataMapping },
|
|
133
|
+
}
|
package/src/umbrella/index.ts
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
import { Client } from 'viem';
|
|
2
|
-
import { AaveUmbrellaViewViem, AaveV3ViewContractViem } from '../contracts';
|
|
3
|
-
import { EthAddress, NetworkNumber } from '../types/common';
|
|
4
|
-
import { compareAddresses, convertHybridArraysToObjects, getEthAmountForDecimals } from '../services/utils';
|
|
5
|
-
import { findMatching, tokenEntries } from './umbrellaUtils';
|
|
6
|
-
|
|
7
|
-
const umbrella = '0xD400fc38ED4732893174325693a63C30ee3881a8';
|
|
8
|
-
const aaveOracle = '0x54586bE62E3c3580375aE3723C145253060Ca0C2';
|
|
9
|
-
|
|
10
|
-
export const getUmbrellaData = async (provider: Client, network: NetworkNumber, address: EthAddress) => {
|
|
11
|
-
const umbrellaView = AaveUmbrellaViewViem(provider, network);
|
|
12
|
-
const aaveV3View = AaveV3ViewContractViem(provider, network);
|
|
13
|
-
const [tokensAggregatedData, additionalUmbrellaStakingData, userAggregatedData] = await Promise.all([
|
|
14
|
-
umbrellaView.read.getTokensAggregatedData([umbrella, aaveOracle]),
|
|
15
|
-
aaveV3View.read.getAdditionalUmbrellaStakingData([umbrella, address]),
|
|
16
|
-
umbrellaView.read.getUserAggregatedData([umbrella, address]),
|
|
17
|
-
]);
|
|
18
|
-
|
|
19
|
-
return Object.fromEntries(
|
|
20
|
-
tokenEntries.map(([symbol, tokenAddr]) => {
|
|
21
|
-
// @ts-ignore
|
|
22
|
-
const fromTokens = convertHybridArraysToObjects(findMatching(tokensAggregatedData, tokenAddr));
|
|
23
|
-
// @ts-ignore
|
|
24
|
-
const fromUser = convertHybridArraysToObjects(findMatching(userAggregatedData, tokenAddr));
|
|
25
|
-
// @ts-ignore
|
|
26
|
-
const fromAdditionalData = convertHybridArraysToObjects(findMatching(additionalUmbrellaStakingData, tokenAddr));
|
|
27
|
-
const data = {
|
|
28
|
-
...fromTokens,
|
|
29
|
-
...fromUser,
|
|
30
|
-
...fromAdditionalData,
|
|
31
|
-
account: {
|
|
32
|
-
stakeUserBalance: fromUser?.stakeUserBalance || '0',
|
|
33
|
-
rewardsTokenUserData: convertHybridArraysToObjects(fromUser?.rewardsTokenUserData) || [],
|
|
34
|
-
userCooldownAmount: fromAdditionalData?.userCooldownAmount || '0',
|
|
35
|
-
userEndOfCooldown: fromAdditionalData?.userEndOfCooldown || '0',
|
|
36
|
-
userWithdrawalWindow: fromAdditionalData?.userWithdrawalWindow || '0',
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const stakeTokenData = data.stakeTokenData;
|
|
41
|
-
|
|
42
|
-
return [symbol, {
|
|
43
|
-
...data,
|
|
44
|
-
stakeTokenData: { ...stakeTokenData, price: getEthAmountForDecimals(stakeTokenData.price, 8) },
|
|
45
|
-
stkTokenToWaTokenRate: getEthAmountForDecimals(data.stkTokenToWaTokenRate, stakeTokenData.decimals),
|
|
46
|
-
waTokenToATokenRate: getEthAmountForDecimals(data.waTokenToATokenRate, stakeTokenData.decimals),
|
|
47
|
-
totalShares: getEthAmountForDecimals(data.totalShares, stakeTokenData.decimals),
|
|
48
|
-
totalAssets: getEthAmountForDecimals(data.totalAssets, stakeTokenData.decimals),
|
|
49
|
-
targetLiquidity: getEthAmountForDecimals(data.targetLiquidity, stakeTokenData.decimals),
|
|
50
|
-
rewardsTokenData: data.rewardsTokenData.map((tokenData: { rewardTokenData: { price: string | number; }; }) => ({ ...tokenData, rewardTokenData: { ...tokenData.rewardTokenData, price: getEthAmountForDecimals(tokenData.rewardTokenData.price, 8) } })),
|
|
51
|
-
rewardsEmissionRates: data.rewardsEmissionRates.map((rate: string, i: number) => {
|
|
52
|
-
const tokenData = data.rewardsTokenData[i].rewardTokenData;
|
|
53
|
-
return getEthAmountForDecimals(rate, tokenData.decimals);
|
|
54
|
-
}),
|
|
55
|
-
account: {
|
|
56
|
-
...data.account,
|
|
57
|
-
stakeUserBalance: getEthAmountForDecimals(data.account.stakeUserBalance, stakeTokenData.decimals),
|
|
58
|
-
userCooldownAmount: getEthAmountForDecimals(data.account.userCooldownAmount, stakeTokenData.decimals),
|
|
59
|
-
rewardsTokenUserData: data.account.rewardsTokenUserData.map((reward: any) => {
|
|
60
|
-
const tokenData = data.rewardsTokenData.find((tknData: { rewardTokenData: { token: string | undefined; }; }) => compareAddresses(tknData.rewardTokenData.token, reward.reward));
|
|
61
|
-
return ({
|
|
62
|
-
...reward,
|
|
63
|
-
currentReward: getEthAmountForDecimals(reward.currentReward, tokenData.rewardTokenData.decimals),
|
|
64
|
-
});
|
|
65
|
-
}),
|
|
66
|
-
},
|
|
67
|
-
}];
|
|
68
|
-
}),
|
|
69
|
-
);
|
|
1
|
+
import { Client } from 'viem';
|
|
2
|
+
import { AaveUmbrellaViewViem, AaveV3ViewContractViem } from '../contracts';
|
|
3
|
+
import { EthAddress, NetworkNumber } from '../types/common';
|
|
4
|
+
import { compareAddresses, convertHybridArraysToObjects, getEthAmountForDecimals } from '../services/utils';
|
|
5
|
+
import { findMatching, tokenEntries } from './umbrellaUtils';
|
|
6
|
+
|
|
7
|
+
const umbrella = '0xD400fc38ED4732893174325693a63C30ee3881a8';
|
|
8
|
+
const aaveOracle = '0x54586bE62E3c3580375aE3723C145253060Ca0C2';
|
|
9
|
+
|
|
10
|
+
export const getUmbrellaData = async (provider: Client, network: NetworkNumber, address: EthAddress) => {
|
|
11
|
+
const umbrellaView = AaveUmbrellaViewViem(provider, network);
|
|
12
|
+
const aaveV3View = AaveV3ViewContractViem(provider, network);
|
|
13
|
+
const [tokensAggregatedData, additionalUmbrellaStakingData, userAggregatedData] = await Promise.all([
|
|
14
|
+
umbrellaView.read.getTokensAggregatedData([umbrella, aaveOracle]),
|
|
15
|
+
aaveV3View.read.getAdditionalUmbrellaStakingData([umbrella, address]),
|
|
16
|
+
umbrellaView.read.getUserAggregatedData([umbrella, address]),
|
|
17
|
+
]);
|
|
18
|
+
|
|
19
|
+
return Object.fromEntries(
|
|
20
|
+
tokenEntries.map(([symbol, tokenAddr]) => {
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
const fromTokens = convertHybridArraysToObjects(findMatching(tokensAggregatedData, tokenAddr));
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
const fromUser = convertHybridArraysToObjects(findMatching(userAggregatedData, tokenAddr));
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
const fromAdditionalData = convertHybridArraysToObjects(findMatching(additionalUmbrellaStakingData, tokenAddr));
|
|
27
|
+
const data = {
|
|
28
|
+
...fromTokens,
|
|
29
|
+
...fromUser,
|
|
30
|
+
...fromAdditionalData,
|
|
31
|
+
account: {
|
|
32
|
+
stakeUserBalance: fromUser?.stakeUserBalance || '0',
|
|
33
|
+
rewardsTokenUserData: convertHybridArraysToObjects(fromUser?.rewardsTokenUserData) || [],
|
|
34
|
+
userCooldownAmount: fromAdditionalData?.userCooldownAmount || '0',
|
|
35
|
+
userEndOfCooldown: fromAdditionalData?.userEndOfCooldown || '0',
|
|
36
|
+
userWithdrawalWindow: fromAdditionalData?.userWithdrawalWindow || '0',
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const stakeTokenData = data.stakeTokenData;
|
|
41
|
+
|
|
42
|
+
return [symbol, {
|
|
43
|
+
...data,
|
|
44
|
+
stakeTokenData: { ...stakeTokenData, price: getEthAmountForDecimals(stakeTokenData.price, 8) },
|
|
45
|
+
stkTokenToWaTokenRate: getEthAmountForDecimals(data.stkTokenToWaTokenRate, stakeTokenData.decimals),
|
|
46
|
+
waTokenToATokenRate: getEthAmountForDecimals(data.waTokenToATokenRate, stakeTokenData.decimals),
|
|
47
|
+
totalShares: getEthAmountForDecimals(data.totalShares, stakeTokenData.decimals),
|
|
48
|
+
totalAssets: getEthAmountForDecimals(data.totalAssets, stakeTokenData.decimals),
|
|
49
|
+
targetLiquidity: getEthAmountForDecimals(data.targetLiquidity, stakeTokenData.decimals),
|
|
50
|
+
rewardsTokenData: data.rewardsTokenData.map((tokenData: { rewardTokenData: { price: string | number; }; }) => ({ ...tokenData, rewardTokenData: { ...tokenData.rewardTokenData, price: getEthAmountForDecimals(tokenData.rewardTokenData.price, 8) } })),
|
|
51
|
+
rewardsEmissionRates: data.rewardsEmissionRates.map((rate: string, i: number) => {
|
|
52
|
+
const tokenData = data.rewardsTokenData[i].rewardTokenData;
|
|
53
|
+
return getEthAmountForDecimals(rate, tokenData.decimals);
|
|
54
|
+
}),
|
|
55
|
+
account: {
|
|
56
|
+
...data.account,
|
|
57
|
+
stakeUserBalance: getEthAmountForDecimals(data.account.stakeUserBalance, stakeTokenData.decimals),
|
|
58
|
+
userCooldownAmount: getEthAmountForDecimals(data.account.userCooldownAmount, stakeTokenData.decimals),
|
|
59
|
+
rewardsTokenUserData: data.account.rewardsTokenUserData.map((reward: any) => {
|
|
60
|
+
const tokenData = data.rewardsTokenData.find((tknData: { rewardTokenData: { token: string | undefined; }; }) => compareAddresses(tknData.rewardTokenData.token, reward.reward));
|
|
61
|
+
return ({
|
|
62
|
+
...reward,
|
|
63
|
+
currentReward: getEthAmountForDecimals(reward.currentReward, tokenData.rewardTokenData.decimals),
|
|
64
|
+
});
|
|
65
|
+
}),
|
|
66
|
+
},
|
|
67
|
+
}];
|
|
68
|
+
}),
|
|
69
|
+
);
|
|
70
70
|
};
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
export enum UmbrellaStaking {
|
|
2
|
-
UmbrellaGHO = 'UmbrellaGHO',
|
|
3
|
-
UmbrellaUSDC = 'UmbrellaUSDC',
|
|
4
|
-
UmbrellaUSDT = 'UmbrellaUSDT',
|
|
5
|
-
UmbrellaETH = 'UmbrellaETH',
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export const tokenMapping = {
|
|
9
|
-
[UmbrellaStaking.UmbrellaUSDC]: '0x6bf183243FdD1e306ad2C4450BC7dcf6f0bf8Aa6',
|
|
10
|
-
[UmbrellaStaking.UmbrellaUSDT]: '0xA484Ab92fe32B143AEE7019fC1502b1dAA522D31',
|
|
11
|
-
[UmbrellaStaking.UmbrellaETH]: '0xaAFD07D53A7365D3e9fb6F3a3B09EC19676B73Ce',
|
|
12
|
-
[UmbrellaStaking.UmbrellaGHO]: '0x4f827A63755855cDf3e8f3bcD20265C833f15033',
|
|
13
|
-
} as const;
|
|
14
|
-
|
|
15
|
-
// ----- chat gpt code for result mapping ---------
|
|
16
|
-
export const normalize = (addr?: string) => addr?.toLowerCase?.() ?? '';
|
|
17
|
-
|
|
18
|
-
export const tokenEntries = Object.entries(tokenMapping).map(([symbol, address]) => [
|
|
19
|
-
symbol,
|
|
20
|
-
normalize(address),
|
|
21
|
-
]);
|
|
22
|
-
|
|
23
|
-
// 👇 Define how to extract the token address from each source type
|
|
24
|
-
export const extractAddress = (item?: { stakeToken?: string, stkToken?: string, stakeTokenData?: { token?: string } }): string => normalize(item?.stakeToken
|
|
25
|
-
|| item?.stkToken
|
|
26
|
-
|| item?.stakeTokenData?.token,
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
// 👇 Utility to find the matching object in a dataset
|
|
1
|
+
export enum UmbrellaStaking {
|
|
2
|
+
UmbrellaGHO = 'UmbrellaGHO',
|
|
3
|
+
UmbrellaUSDC = 'UmbrellaUSDC',
|
|
4
|
+
UmbrellaUSDT = 'UmbrellaUSDT',
|
|
5
|
+
UmbrellaETH = 'UmbrellaETH',
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const tokenMapping = {
|
|
9
|
+
[UmbrellaStaking.UmbrellaUSDC]: '0x6bf183243FdD1e306ad2C4450BC7dcf6f0bf8Aa6',
|
|
10
|
+
[UmbrellaStaking.UmbrellaUSDT]: '0xA484Ab92fe32B143AEE7019fC1502b1dAA522D31',
|
|
11
|
+
[UmbrellaStaking.UmbrellaETH]: '0xaAFD07D53A7365D3e9fb6F3a3B09EC19676B73Ce',
|
|
12
|
+
[UmbrellaStaking.UmbrellaGHO]: '0x4f827A63755855cDf3e8f3bcD20265C833f15033',
|
|
13
|
+
} as const;
|
|
14
|
+
|
|
15
|
+
// ----- chat gpt code for result mapping ---------
|
|
16
|
+
export const normalize = (addr?: string) => addr?.toLowerCase?.() ?? '';
|
|
17
|
+
|
|
18
|
+
export const tokenEntries = Object.entries(tokenMapping).map(([symbol, address]) => [
|
|
19
|
+
symbol,
|
|
20
|
+
normalize(address),
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
// 👇 Define how to extract the token address from each source type
|
|
24
|
+
export const extractAddress = (item?: { stakeToken?: string, stkToken?: string, stakeTokenData?: { token?: string } }): string => normalize(item?.stakeToken
|
|
25
|
+
|| item?.stkToken
|
|
26
|
+
|| item?.stakeTokenData?.token,
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
// 👇 Utility to find the matching object in a dataset
|
|
30
30
|
export const findMatching = (dataset: any[], targetAddr: string) => dataset.find((item) => extractAddress(item) === targetAddr);
|