@defisaver/positions-sdk 2.1.35 → 2.1.37
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/config/contracts.d.ts +42 -0
- package/cjs/config/contracts.js +4 -1
- package/cjs/contracts.d.ts +205 -0
- package/cjs/contracts.js +11 -2
- package/cjs/helpers/morphoBlueHelpers/index.js +66 -66
- package/cjs/savings/index.d.ts +3 -2
- package/cjs/savings/index.js +3 -1
- package/cjs/savings/morphoVaults/index.js +17 -17
- package/cjs/savings/skyOptions/options.js +1 -0
- package/cjs/savings/yearnV3Vaults/index.d.ts +7 -0
- package/cjs/savings/yearnV3Vaults/index.js +97 -0
- package/cjs/savings/yearnV3Vaults/options.d.ts +8 -0
- package/cjs/savings/yearnV3Vaults/options.js +53 -0
- package/cjs/types/savings/index.d.ts +3 -1
- package/cjs/types/savings/index.js +1 -0
- package/cjs/types/savings/sky.d.ts +1 -0
- package/cjs/types/savings/yearnV3Vaults.d.ts +16 -0
- package/cjs/types/savings/yearnV3Vaults.js +11 -0
- package/esm/config/contracts.d.ts +42 -0
- package/esm/config/contracts.js +3 -0
- package/esm/contracts.d.ts +205 -0
- package/esm/contracts.js +8 -0
- package/esm/helpers/morphoBlueHelpers/index.js +66 -66
- package/esm/savings/index.d.ts +3 -2
- package/esm/savings/index.js +2 -1
- package/esm/savings/morphoVaults/index.js +17 -17
- package/esm/savings/skyOptions/options.js +1 -0
- package/esm/savings/yearnV3Vaults/index.d.ts +7 -0
- package/esm/savings/yearnV3Vaults/index.js +56 -0
- package/esm/savings/yearnV3Vaults/options.d.ts +8 -0
- package/esm/savings/yearnV3Vaults/options.js +49 -0
- package/esm/types/savings/index.d.ts +3 -1
- package/esm/types/savings/index.js +1 -0
- package/esm/types/savings/sky.d.ts +1 -0
- package/esm/types/savings/yearnV3Vaults.d.ts +16 -0
- package/esm/types/savings/yearnV3Vaults.js +8 -0
- package/package.json +48 -48
- package/src/aaveV2/index.ts +240 -240
- package/src/aaveV3/index.ts +625 -625
- 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/ethena.ts +61 -61
- 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 +1295 -1292
- package/src/constants/index.ts +10 -10
- package/src/contracts.ts +171 -162
- 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 +1800 -1800
- 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 +49 -49
- package/src/liquity/index.ts +159 -159
- package/src/liquityV2/index.ts +703 -703
- package/src/llamaLend/index.ts +305 -305
- package/src/maker/index.ts +223 -223
- package/src/markets/aave/index.ts +118 -118
- package/src/markets/aave/marketAssets.ts +54 -54
- package/src/markets/compound/index.ts +243 -243
- 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 +2900 -2900
- 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 +971 -971
- package/src/markets/spark/index.ts +29 -29
- package/src/markets/spark/marketAssets.ts +12 -12
- package/src/moneymarket/moneymarketCommonService.ts +85 -85
- package/src/morphoBlue/index.ts +274 -274
- package/src/portfolio/index.ts +598 -598
- package/src/savings/index.ts +84 -82
- package/src/savings/makerDsr/index.ts +53 -53
- package/src/savings/makerDsr/options.ts +9 -9
- package/src/savings/morphoVaults/index.ts +80 -80
- package/src/savings/morphoVaults/options.ts +203 -203
- package/src/savings/skyOptions/index.ts +95 -95
- package/src/savings/skyOptions/options.ts +10 -9
- package/src/savings/sparkSavingsVaults/index.ts +60 -60
- package/src/savings/sparkSavingsVaults/options.ts +35 -35
- package/src/savings/yearnV3Vaults/index.ts +61 -0
- package/src/savings/yearnV3Vaults/options.ts +56 -0
- package/src/savings/yearnVaults/index.ts +73 -73
- package/src/savings/yearnVaults/options.ts +32 -32
- package/src/services/priceService.ts +278 -278
- 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 +186 -186
- package/src/types/aave.ts +196 -196
- package/src/types/claiming.ts +114 -114
- package/src/types/common.ts +107 -107
- package/src/types/compound.ts +144 -144
- package/src/types/curveUsd.ts +123 -123
- package/src/types/euler.ts +175 -175
- package/src/types/fluid.ts +483 -483
- package/src/types/index.ts +14 -14
- 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 +200 -200
- package/src/types/portfolio.ts +60 -60
- package/src/types/savings/index.ts +24 -22
- package/src/types/savings/makerDsr.ts +13 -13
- package/src/types/savings/morphoVaults.ts +33 -33
- package/src/types/savings/sky.ts +14 -13
- package/src/types/savings/sparkSavingsVaults.ts +15 -15
- package/src/types/savings/yearnV3Vaults.ts +18 -0
- package/src/types/savings/yearnVaults.ts +14 -14
- package/src/types/spark.ts +133 -133
- package/src/umbrella/index.ts +69 -69
- package/src/umbrella/umbrellaUtils.ts +29 -29
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);
|