@defisaver/positions-sdk 2.1.1 → 2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/cjs/aaveV2/index.js +1 -0
  2. package/cjs/aaveV3/index.d.ts +12 -0
  3. package/cjs/aaveV3/index.js +93 -1
  4. package/cjs/claiming/aaveV3.d.ts +5 -0
  5. package/cjs/claiming/aaveV3.js +139 -0
  6. package/cjs/claiming/compV3.d.ts +15 -0
  7. package/cjs/claiming/compV3.js +34 -0
  8. package/cjs/claiming/index.d.ts +6 -0
  9. package/cjs/claiming/index.js +46 -0
  10. package/cjs/claiming/king.d.ts +4 -0
  11. package/cjs/claiming/king.js +72 -0
  12. package/cjs/claiming/morphoBlue.d.ts +5 -0
  13. package/cjs/claiming/morphoBlue.js +113 -0
  14. package/cjs/claiming/spark.d.ts +6 -0
  15. package/cjs/claiming/spark.js +188 -0
  16. package/cjs/config/contracts.d.ts +2681 -0
  17. package/cjs/config/contracts.js +103 -2
  18. package/cjs/constants/index.d.ts +4 -0
  19. package/cjs/constants/index.js +6 -2
  20. package/cjs/contracts.d.ts +3027 -23
  21. package/cjs/contracts.js +10 -1
  22. package/cjs/helpers/aaveHelpers/index.d.ts +4 -0
  23. package/cjs/helpers/aaveHelpers/index.js +25 -8
  24. package/cjs/helpers/morphoBlueHelpers/index.d.ts +1 -0
  25. package/cjs/helpers/morphoBlueHelpers/index.js +7 -1
  26. package/cjs/index.d.ts +2 -1
  27. package/cjs/index.js +3 -1
  28. package/cjs/liquity/index.d.ts +11 -0
  29. package/cjs/liquity/index.js +39 -1
  30. package/cjs/liquityV2/index.d.ts +35 -0
  31. package/cjs/liquityV2/index.js +142 -1
  32. package/cjs/morphoBlue/index.d.ts +5 -0
  33. package/cjs/morphoBlue/index.js +35 -0
  34. package/cjs/portfolio/index.d.ts +6 -1
  35. package/cjs/portfolio/index.js +293 -10
  36. package/cjs/services/utils.d.ts +5 -0
  37. package/cjs/services/utils.js +33 -1
  38. package/cjs/services/viem.d.ts +12 -12
  39. package/cjs/spark/index.js +1 -0
  40. package/cjs/staking/eligibility.d.ts +4 -2
  41. package/cjs/staking/eligibility.js +3 -4
  42. package/cjs/staking/staking.d.ts +2 -1
  43. package/cjs/staking/staking.js +3 -3
  44. package/cjs/types/claiming.d.ts +93 -0
  45. package/cjs/types/claiming.js +27 -0
  46. package/cjs/types/common.d.ts +1 -1
  47. package/cjs/types/common.js +1 -1
  48. package/cjs/umbrella/index.d.ts +5 -0
  49. package/cjs/umbrella/index.js +50 -0
  50. package/cjs/umbrella/umbrellaUtils.d.ts +22 -0
  51. package/cjs/umbrella/umbrellaUtils.js +34 -0
  52. package/esm/aaveV2/index.js +1 -0
  53. package/esm/aaveV3/index.d.ts +12 -0
  54. package/esm/aaveV3/index.js +91 -1
  55. package/esm/claiming/aaveV3.d.ts +5 -0
  56. package/esm/claiming/aaveV3.js +132 -0
  57. package/esm/claiming/compV3.d.ts +15 -0
  58. package/esm/claiming/compV3.js +30 -0
  59. package/esm/claiming/index.d.ts +6 -0
  60. package/esm/claiming/index.js +6 -0
  61. package/esm/claiming/king.d.ts +4 -0
  62. package/esm/claiming/king.js +64 -0
  63. package/esm/claiming/morphoBlue.d.ts +5 -0
  64. package/esm/claiming/morphoBlue.js +105 -0
  65. package/esm/claiming/spark.d.ts +6 -0
  66. package/esm/claiming/spark.js +179 -0
  67. package/esm/config/contracts.d.ts +2681 -0
  68. package/esm/config/contracts.js +102 -1
  69. package/esm/constants/index.d.ts +4 -0
  70. package/esm/constants/index.js +5 -1
  71. package/esm/contracts.d.ts +3027 -23
  72. package/esm/contracts.js +9 -0
  73. package/esm/helpers/aaveHelpers/index.d.ts +4 -0
  74. package/esm/helpers/aaveHelpers/index.js +23 -7
  75. package/esm/helpers/morphoBlueHelpers/index.d.ts +1 -0
  76. package/esm/helpers/morphoBlueHelpers/index.js +6 -1
  77. package/esm/index.d.ts +2 -1
  78. package/esm/index.js +2 -1
  79. package/esm/liquity/index.d.ts +11 -0
  80. package/esm/liquity/index.js +38 -1
  81. package/esm/liquityV2/index.d.ts +35 -0
  82. package/esm/liquityV2/index.js +142 -3
  83. package/esm/morphoBlue/index.d.ts +5 -0
  84. package/esm/morphoBlue/index.js +35 -1
  85. package/esm/portfolio/index.d.ts +6 -1
  86. package/esm/portfolio/index.js +298 -15
  87. package/esm/services/utils.d.ts +5 -0
  88. package/esm/services/utils.js +31 -0
  89. package/esm/services/viem.d.ts +12 -12
  90. package/esm/spark/index.js +1 -0
  91. package/esm/staking/eligibility.d.ts +4 -2
  92. package/esm/staking/eligibility.js +3 -4
  93. package/esm/staking/staking.d.ts +2 -1
  94. package/esm/staking/staking.js +3 -3
  95. package/esm/types/claiming.d.ts +93 -0
  96. package/esm/types/claiming.js +24 -0
  97. package/esm/types/common.d.ts +1 -1
  98. package/esm/types/common.js +1 -1
  99. package/esm/umbrella/index.d.ts +5 -0
  100. package/esm/umbrella/index.js +46 -0
  101. package/esm/umbrella/umbrellaUtils.d.ts +22 -0
  102. package/esm/umbrella/umbrellaUtils.js +28 -0
  103. package/package.json +1 -1
  104. package/src/aaveV2/index.ts +2 -1
  105. package/src/aaveV3/index.ts +100 -2
  106. package/src/claiming/aaveV3.ts +155 -0
  107. package/src/claiming/compV3.ts +23 -0
  108. package/src/claiming/index.ts +13 -0
  109. package/src/claiming/king.ts +66 -0
  110. package/src/claiming/morphoBlue.ts +119 -0
  111. package/src/claiming/spark.ts +226 -0
  112. package/src/config/contracts.ts +104 -4
  113. package/src/constants/index.ts +5 -1
  114. package/src/contracts.ts +14 -1
  115. package/src/helpers/aaveHelpers/index.ts +24 -7
  116. package/src/helpers/morphoBlueHelpers/index.ts +7 -2
  117. package/src/index.ts +2 -0
  118. package/src/liquity/index.ts +57 -2
  119. package/src/liquityV2/index.ts +244 -4
  120. package/src/morphoBlue/index.ts +40 -2
  121. package/src/portfolio/index.ts +300 -15
  122. package/src/services/utils.ts +37 -1
  123. package/src/spark/index.ts +2 -1
  124. package/src/staking/eligibility.ts +3 -4
  125. package/src/staking/staking.ts +4 -4
  126. package/src/types/claiming.ts +109 -0
  127. package/src/types/common.ts +1 -1
  128. package/src/umbrella/index.ts +70 -0
  129. package/src/umbrella/umbrellaUtils.ts +30 -0
@@ -0,0 +1,93 @@
1
+ import { EthAddress } from './common';
2
+ export declare enum ClaimType {
3
+ /** Rewards from AAVE - various tokens & aTokens (supplied to protocol) */
4
+ AAVE_REWARDS = "AAVE_REWARDS",
5
+ /** Merit rewards from AAVE (various tokens) */
6
+ AAVE_MERIT_REWARDS = "AAVE_MERIT_REWARDS",
7
+ /** Rewards from Compound V3 (only in COMP) */
8
+ COMPOUND_V3_COMP = "COMPOUND_V3_COMP",
9
+ /** Rewards from Spark (wstETH only for now) */
10
+ SPARK_REWARDS = "SPARK_REWARDS",
11
+ /** Rewards from Morpho */
12
+ MORPHO = "MORPHO",
13
+ /** Rewards from King (prev LTR^2 - received for weETH holding) */
14
+ KING_REWARDS = "KING_REWARDS",
15
+ /** Spark Airdrop */
16
+ SPARK_AIRDROP = "SPARK_AIRDROP",
17
+ /** Spark Airdrop */
18
+ SPARK_WST_ETH_REWARDS = "SPARK_WST_ETH_REWARDS"
19
+ }
20
+ type _ClaimableTokenPartial = {
21
+ symbol: string;
22
+ underlyingSymbol: string;
23
+ tokenAddress: EthAddress;
24
+ amount: string;
25
+ walletAddress: EthAddress;
26
+ label: string;
27
+ };
28
+ export type AaveRewardsClaimableToken = _ClaimableTokenPartial & {
29
+ claimType: ClaimType.AAVE_REWARDS;
30
+ additionalClaimFields: {
31
+ marketAddress: EthAddress;
32
+ aTokenAddresses: string[];
33
+ isAaveToken: boolean;
34
+ };
35
+ };
36
+ export type AaveMeritRewardsClaimableToken = _ClaimableTokenPartial & {
37
+ claimType: ClaimType.AAVE_MERIT_REWARDS;
38
+ additionalClaimFields: {
39
+ accumulated: string;
40
+ proof: string[];
41
+ decimals: string;
42
+ unclaimed: string;
43
+ };
44
+ };
45
+ export type SparkRewardsClaimableToken = _ClaimableTokenPartial & {
46
+ claimType: ClaimType.SPARK_REWARDS;
47
+ additionalClaimFields: {
48
+ sparkAssetAddresses: string[];
49
+ };
50
+ };
51
+ export type KingRewardsClaimableToken = _ClaimableTokenPartial & {
52
+ claimType: ClaimType.KING_REWARDS;
53
+ additionalClaimFields: {
54
+ allRewardsAmount: string;
55
+ merkleRoot: string;
56
+ merkleProofs: string[];
57
+ };
58
+ };
59
+ export type MorphoClaimableToken = _ClaimableTokenPartial & {
60
+ claimType: ClaimType.MORPHO;
61
+ additionalClaimFields: {
62
+ originalAmount: string;
63
+ merkleProofs: string[];
64
+ distributor: EthAddress;
65
+ isLegacy: boolean;
66
+ txData: string;
67
+ };
68
+ };
69
+ export type CompoundV3CompClaimableToken = _ClaimableTokenPartial & {
70
+ claimType: ClaimType.COMPOUND_V3_COMP;
71
+ additionalClaimFields: {
72
+ marketAddress: EthAddress;
73
+ };
74
+ };
75
+ export declare enum SparkAirdropType {
76
+ SPARK_IGNITION = "spark-ignition",
77
+ PRE_FARMING_AND_SOCIAL = "pre-farming-and-social"
78
+ }
79
+ export type SparkAirdropClaimableToken = _ClaimableTokenPartial & {
80
+ claimType: ClaimType.SPARK_AIRDROP;
81
+ additionalClaimFields: {
82
+ merkleRoot: string;
83
+ merkleProofs: string[];
84
+ epoch: number;
85
+ rewardType: SparkAirdropType;
86
+ allRewardsAmount: string;
87
+ };
88
+ };
89
+ export type SparkWstEthRewardsClaimableToken = _ClaimableTokenPartial & {
90
+ claimType: ClaimType.SPARK_WST_ETH_REWARDS;
91
+ };
92
+ export type ClaimableToken = AaveRewardsClaimableToken | AaveMeritRewardsClaimableToken | CompoundV3CompClaimableToken | MorphoClaimableToken | SparkRewardsClaimableToken | KingRewardsClaimableToken | SparkAirdropClaimableToken | SparkWstEthRewardsClaimableToken;
93
+ export {};
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SparkAirdropType = exports.ClaimType = void 0;
4
+ var ClaimType;
5
+ (function (ClaimType) {
6
+ /** Rewards from AAVE - various tokens & aTokens (supplied to protocol) */
7
+ ClaimType["AAVE_REWARDS"] = "AAVE_REWARDS";
8
+ /** Merit rewards from AAVE (various tokens) */
9
+ ClaimType["AAVE_MERIT_REWARDS"] = "AAVE_MERIT_REWARDS";
10
+ /** Rewards from Compound V3 (only in COMP) */
11
+ ClaimType["COMPOUND_V3_COMP"] = "COMPOUND_V3_COMP";
12
+ /** Rewards from Spark (wstETH only for now) */
13
+ ClaimType["SPARK_REWARDS"] = "SPARK_REWARDS";
14
+ /** Rewards from Morpho */
15
+ ClaimType["MORPHO"] = "MORPHO";
16
+ /** Rewards from King (prev LTR^2 - received for weETH holding) */
17
+ ClaimType["KING_REWARDS"] = "KING_REWARDS";
18
+ /** Spark Airdrop */
19
+ ClaimType["SPARK_AIRDROP"] = "SPARK_AIRDROP";
20
+ /** Spark Airdrop */
21
+ ClaimType["SPARK_WST_ETH_REWARDS"] = "SPARK_WST_ETH_REWARDS";
22
+ })(ClaimType || (exports.ClaimType = ClaimType = {}));
23
+ var SparkAirdropType;
24
+ (function (SparkAirdropType) {
25
+ SparkAirdropType["SPARK_IGNITION"] = "spark-ignition";
26
+ SparkAirdropType["PRE_FARMING_AND_SOCIAL"] = "pre-farming-and-social";
27
+ })(SparkAirdropType || (exports.SparkAirdropType = SparkAirdropType = {}));
@@ -3,7 +3,7 @@ export declare enum IncentiveKind {
3
3
  Reward = "reward"
4
4
  }
5
5
  export declare enum IncentiveEligibilityId {
6
- AaveV3EthenaLiquidLeverage = "0x8772bb231f3af13ead41d7ecf6abd60f5f716ec8BORROW_BL",
6
+ AaveV3EthenaLiquidLeverage = "0x7361e6f04060154e0268a8402b073cbf97e11ae3BORROW_BL",
7
7
  AaveV3ArbitrumEthSupply = "0x5d16261c6715a653248269861bbacf68a9774cde",
8
8
  AaveV3ArbitrumETHLSBorrow = "0x0c84331e39d6658Cd6e6b9ba04736cC4c4734351"
9
9
  }
@@ -8,7 +8,7 @@ var IncentiveKind;
8
8
  })(IncentiveKind || (exports.IncentiveKind = IncentiveKind = {}));
9
9
  var IncentiveEligibilityId;
10
10
  (function (IncentiveEligibilityId) {
11
- IncentiveEligibilityId["AaveV3EthenaLiquidLeverage"] = "0x8772bb231f3af13ead41d7ecf6abd60f5f716ec8BORROW_BL";
11
+ IncentiveEligibilityId["AaveV3EthenaLiquidLeverage"] = "0x7361e6f04060154e0268a8402b073cbf97e11ae3BORROW_BL";
12
12
  IncentiveEligibilityId["AaveV3ArbitrumEthSupply"] = "0x5d16261c6715a653248269861bbacf68a9774cde";
13
13
  IncentiveEligibilityId["AaveV3ArbitrumETHLSBorrow"] = "0x0c84331e39d6658Cd6e6b9ba04736cC4c4734351";
14
14
  })(IncentiveEligibilityId || (exports.IncentiveEligibilityId = IncentiveEligibilityId = {}));
@@ -0,0 +1,5 @@
1
+ import { Client } from 'viem';
2
+ import { EthAddress, NetworkNumber } from '../types/common';
3
+ export declare const getUmbrellaData: (provider: Client, network: NetworkNumber, address: EthAddress) => Promise<{
4
+ [k: string]: any;
5
+ }>;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getUmbrellaData = void 0;
13
+ const contracts_1 = require("../contracts");
14
+ const utils_1 = require("../services/utils");
15
+ const umbrellaUtils_1 = require("./umbrellaUtils");
16
+ const umbrella = '0xD400fc38ED4732893174325693a63C30ee3881a8';
17
+ const aaveOracle = '0x54586bE62E3c3580375aE3723C145253060Ca0C2';
18
+ const getUmbrellaData = (provider, network, address) => __awaiter(void 0, void 0, void 0, function* () {
19
+ const umbrellaView = (0, contracts_1.AaveUmbrellaViewViem)(provider, network);
20
+ const aaveV3View = (0, contracts_1.AaveV3ViewContractViem)(provider, network);
21
+ const [tokensAggregatedData, additionalUmbrellaStakingData, userAggregatedData] = yield Promise.all([
22
+ umbrellaView.read.getTokensAggregatedData([umbrella, aaveOracle]),
23
+ aaveV3View.read.getAdditionalUmbrellaStakingData([umbrella, address]),
24
+ umbrellaView.read.getUserAggregatedData([umbrella, address]),
25
+ ]);
26
+ return Object.fromEntries(umbrellaUtils_1.tokenEntries.map(([symbol, tokenAddr]) => {
27
+ // @ts-ignore
28
+ const fromTokens = (0, utils_1.convertHybridArraysToObjects)((0, umbrellaUtils_1.findMatching)(tokensAggregatedData, tokenAddr));
29
+ // @ts-ignore
30
+ const fromUser = (0, utils_1.convertHybridArraysToObjects)((0, umbrellaUtils_1.findMatching)(userAggregatedData, tokenAddr));
31
+ // @ts-ignore
32
+ const fromAdditionalData = (0, utils_1.convertHybridArraysToObjects)((0, umbrellaUtils_1.findMatching)(additionalUmbrellaStakingData, tokenAddr));
33
+ const data = Object.assign(Object.assign(Object.assign(Object.assign({}, fromTokens), fromUser), fromAdditionalData), { account: {
34
+ stakeUserBalance: (fromUser === null || fromUser === void 0 ? void 0 : fromUser.stakeUserBalance) || '0',
35
+ rewardsTokenUserData: (0, utils_1.convertHybridArraysToObjects)(fromUser === null || fromUser === void 0 ? void 0 : fromUser.rewardsTokenUserData) || [],
36
+ userCooldownAmount: (fromAdditionalData === null || fromAdditionalData === void 0 ? void 0 : fromAdditionalData.userCooldownAmount) || '0',
37
+ userEndOfCooldown: (fromAdditionalData === null || fromAdditionalData === void 0 ? void 0 : fromAdditionalData.userEndOfCooldown) || '0',
38
+ userWithdrawalWindow: (fromAdditionalData === null || fromAdditionalData === void 0 ? void 0 : fromAdditionalData.userWithdrawalWindow) || '0',
39
+ } });
40
+ const stakeTokenData = data.stakeTokenData;
41
+ return [symbol, Object.assign(Object.assign({}, data), { stakeTokenData: Object.assign(Object.assign({}, stakeTokenData), { price: (0, utils_1.getEthAmountForDecimals)(stakeTokenData.price, 8) }), stkTokenToWaTokenRate: (0, utils_1.getEthAmountForDecimals)(data.stkTokenToWaTokenRate, stakeTokenData.decimals), waTokenToATokenRate: (0, utils_1.getEthAmountForDecimals)(data.waTokenToATokenRate, stakeTokenData.decimals), totalShares: (0, utils_1.getEthAmountForDecimals)(data.totalShares, stakeTokenData.decimals), totalAssets: (0, utils_1.getEthAmountForDecimals)(data.totalAssets, stakeTokenData.decimals), targetLiquidity: (0, utils_1.getEthAmountForDecimals)(data.targetLiquidity, stakeTokenData.decimals), rewardsTokenData: data.rewardsTokenData.map((tokenData) => (Object.assign(Object.assign({}, tokenData), { rewardTokenData: Object.assign(Object.assign({}, tokenData.rewardTokenData), { price: (0, utils_1.getEthAmountForDecimals)(tokenData.rewardTokenData.price, 8) }) }))), rewardsEmissionRates: data.rewardsEmissionRates.map((rate, i) => {
42
+ const tokenData = data.rewardsTokenData[i].rewardTokenData;
43
+ return (0, utils_1.getEthAmountForDecimals)(rate, tokenData.decimals);
44
+ }), account: Object.assign(Object.assign({}, data.account), { stakeUserBalance: (0, utils_1.getEthAmountForDecimals)(data.account.stakeUserBalance, stakeTokenData.decimals), userCooldownAmount: (0, utils_1.getEthAmountForDecimals)(data.account.userCooldownAmount, stakeTokenData.decimals), rewardsTokenUserData: data.account.rewardsTokenUserData.map((reward) => {
45
+ const tokenData = data.rewardsTokenData.find((tknData) => (0, utils_1.compareAddresses)(tknData.rewardTokenData.token, reward.reward));
46
+ return (Object.assign(Object.assign({}, reward), { currentReward: (0, utils_1.getEthAmountForDecimals)(reward.currentReward, tokenData.rewardTokenData.decimals) }));
47
+ }) }) })];
48
+ }));
49
+ });
50
+ exports.getUmbrellaData = getUmbrellaData;
@@ -0,0 +1,22 @@
1
+ export declare enum UmbrellaStaking {
2
+ UmbrellaGHO = "UmbrellaGHO",
3
+ UmbrellaUSDC = "UmbrellaUSDC",
4
+ UmbrellaUSDT = "UmbrellaUSDT",
5
+ UmbrellaETH = "UmbrellaETH"
6
+ }
7
+ export declare const tokenMapping: {
8
+ readonly UmbrellaUSDC: "0x6bf183243FdD1e306ad2C4450BC7dcf6f0bf8Aa6";
9
+ readonly UmbrellaUSDT: "0xA484Ab92fe32B143AEE7019fC1502b1dAA522D31";
10
+ readonly UmbrellaETH: "0xaAFD07D53A7365D3e9fb6F3a3B09EC19676B73Ce";
11
+ readonly UmbrellaGHO: "0x4f827A63755855cDf3e8f3bcD20265C833f15033";
12
+ };
13
+ export declare const normalize: (addr?: string) => string;
14
+ export declare const tokenEntries: string[][];
15
+ export declare const extractAddress: (item?: {
16
+ stakeToken?: string;
17
+ stkToken?: string;
18
+ stakeTokenData?: {
19
+ token?: string;
20
+ };
21
+ }) => string;
22
+ export declare const findMatching: (dataset: any[], targetAddr: string) => any;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findMatching = exports.extractAddress = exports.tokenEntries = exports.normalize = exports.tokenMapping = exports.UmbrellaStaking = void 0;
4
+ var UmbrellaStaking;
5
+ (function (UmbrellaStaking) {
6
+ UmbrellaStaking["UmbrellaGHO"] = "UmbrellaGHO";
7
+ UmbrellaStaking["UmbrellaUSDC"] = "UmbrellaUSDC";
8
+ UmbrellaStaking["UmbrellaUSDT"] = "UmbrellaUSDT";
9
+ UmbrellaStaking["UmbrellaETH"] = "UmbrellaETH";
10
+ })(UmbrellaStaking || (exports.UmbrellaStaking = UmbrellaStaking = {}));
11
+ exports.tokenMapping = {
12
+ [UmbrellaStaking.UmbrellaUSDC]: '0x6bf183243FdD1e306ad2C4450BC7dcf6f0bf8Aa6',
13
+ [UmbrellaStaking.UmbrellaUSDT]: '0xA484Ab92fe32B143AEE7019fC1502b1dAA522D31',
14
+ [UmbrellaStaking.UmbrellaETH]: '0xaAFD07D53A7365D3e9fb6F3a3B09EC19676B73Ce',
15
+ [UmbrellaStaking.UmbrellaGHO]: '0x4f827A63755855cDf3e8f3bcD20265C833f15033',
16
+ };
17
+ // ----- chat gpt code for result mapping ---------
18
+ const normalize = (addr) => { var _a, _b; return (_b = (_a = addr === null || addr === void 0 ? void 0 : addr.toLowerCase) === null || _a === void 0 ? void 0 : _a.call(addr)) !== null && _b !== void 0 ? _b : ''; };
19
+ exports.normalize = normalize;
20
+ exports.tokenEntries = Object.entries(exports.tokenMapping).map(([symbol, address]) => [
21
+ symbol,
22
+ (0, exports.normalize)(address),
23
+ ]);
24
+ // 👇 Define how to extract the token address from each source type
25
+ const extractAddress = (item) => {
26
+ var _a;
27
+ return (0, exports.normalize)((item === null || item === void 0 ? void 0 : item.stakeToken)
28
+ || (item === null || item === void 0 ? void 0 : item.stkToken)
29
+ || ((_a = item === null || item === void 0 ? void 0 : item.stakeTokenData) === null || _a === void 0 ? void 0 : _a.token));
30
+ };
31
+ exports.extractAddress = extractAddress;
32
+ // 👇 Utility to find the matching object in a dataset
33
+ const findMatching = (dataset, targetAddr) => dataset.find((item) => (0, exports.extractAddress)(item) === targetAddr);
34
+ exports.findMatching = findMatching;
@@ -97,6 +97,7 @@ export const _getAaveV2AccountBalances = (provider, network, block, addressMappi
97
97
  const marketAddress = market.providerAddress;
98
98
  // @ts-ignore
99
99
  const protocolDataProviderContract = createViemContractFromConfigFunc(market.protocolData, market.protocolDataAddress)(provider, network);
100
+ // @ts-ignore
100
101
  const reserveTokens = yield protocolDataProviderContract.read.getAllReservesTokens(setViemBlockNumber(block));
101
102
  const symbols = reserveTokens.map(({ symbol }) => symbol);
102
103
  const _addresses = reserveTokens.map(({ tokenAddress }) => tokenAddress);
@@ -34,4 +34,16 @@ export declare const getAaveV3AccountBalances: (provider: EthereumProvider, netw
34
34
  export declare const _getAaveV3AccountData: (provider: Client, network: NetworkNumber, address: EthAddress, extractedState: any, blockNumber?: "latest" | number) => Promise<AaveV3PositionData>;
35
35
  export declare const getAaveV3AccountData: (provider: EthereumProvider, network: NetworkNumber, address: EthAddress, extractedState: any, blockNumber?: "latest" | number) => Promise<AaveV3PositionData>;
36
36
  export declare const getAaveV3FullPositionData: (provider: EthereumProvider, network: NetworkNumber, address: EthAddress, market: AaveMarketInfo) => Promise<AaveV3PositionData>;
37
+ export declare const REWARDABLE_ASSETS: readonly ["0x028171bCA77440897B824Ca71D1c56caC55b68A3", "0x6C3c78838c761c6Ac7bE9F59fe808ea2A6E4379d", "0xD37EE7e4f452C6638c96536e68090De8cBcdb583", "0x279AF5b99540c1A3A7E3CDd326e19659401eF99e", "0xBcca60bB61934080951369a648Fb03DF4F96263C", "0x619beb58998eD2278e08620f97007e1116D5D25b", "0x3Ed3B47Dd13EC9a98b44e6204A523E766B225811", "0x531842cEbbdD378f8ee36D171d6cC9C4fcf475Ec", "0x9ff58f4fFB29fA2266Ab25e75e2A8b3503311656", "0x9c39809Dec7F95F5e0713634a4D0701329B3b4d2", "0x030bA81f1c18d280636F32af80b9AAd02Cf0854e", "0xF63B34710400CAd3e044cFfDcAb00a0f32E33eCf", "0xa06bC25B5805d5F8d82847D191Cb4Af5A3e873E0", "0x0b8f12b1788BFdE65Aa1ca52E3e9F3Ba401be16D", "0x6C5024Cd4F8A59110119C56f8933403A539555EB", "0xdC6a3Ab17299D9C2A412B0e0a4C1f55446AE0817", "0x5165d24277cD063F5ac44Efd447B27025e888f37", "0x7EbD09022Be45AD993BAA1CEc61166Fcc8644d97", "0xF256CC7847E919FAc9B808cC216cAc87CCF2f47a", "0xfAFEDF95E21184E3d880bd56D4806c4b8d31c69A", "0xB9D7CB55f463405CDfBe4E90a6D2Df01C2B92BF1", "0x5BdB050A92CADcCfCDcCCBFC17204a1C9cC0Ab73", "0xc713e5E149D5D0715DcD1c156a020976e7E56B88", "0xba728eAd5e496BE00DCF66F650b6d7758eCB50f8", "0x101cc05f4A51C0319f570d5E146a8C625198e636", "0x01C0eb1f8c6F1C1bF74ae028697ce7AA2a8b0E92", "0xc9BC48c72154ef3e5425641a3c747242112a46AF", "0xB5385132EE8321977FfF44b60cDE9fE9AB0B4e6b", "0x272F97b7a56a387aE942350bBC7Df5700f8a4576", "0x13210D4Fe0d5402bd7Ecbc4B5bC5cFcA3b71adB0", "0x2e8f4bdbe3d47d7d7de490437aea9915d930f1a3", "0xfdb93b3b10936cf81fa59a02a7523b6e2149b2b7", "0xA361718326c15715591c299427c62086F69923D9", "0xbA429f7011c9fa04cDd46a2Da24dc0FF0aC6099c", "0xd4937682df3C8aEF4FE912A96A74121C0829E664", "0xfE8F19B17fFeF0fDbfe2671F248903055AFAA8Ca", "0x683923dB55Fead99A79Fa01A27EeC3cB19679cC3", "0xC2e10006AccAb7B45D9184FcF5b7EC7763f5BaAe", "0x8dAE6Cb04688C62d939ed9B68d32Bc62e49970b1", "0x00ad8eBF64F141f1C81e9f8f792d3d1631c6c684", "0x6F634c6135D2EBD550000ac92F494F9CB8183dAe", "0x4dDff5885a67E4EffeC55875a3977D7E60F82ae0"];
38
+ export declare const fetchYearlyMeritApyForStakingGho: () => Promise<string>;
39
+ export declare const getStakeAaveData: (provider: Client, network: NetworkNumber, address: EthAddress) => Promise<{
40
+ activatedCooldown: string;
41
+ activatedCooldownAmount: string;
42
+ stkAaveRewardsBalance: string;
43
+ aaveRewardsBalance: string;
44
+ stkAaveBalance: string;
45
+ stkGhoBalance: string;
46
+ ghoMeritApy: string;
47
+ stkAaveApy: string;
48
+ }>;
37
49
  export { getMeritCampaigns, getMerkleCampaigns, };
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { assetAmountInEth, assetAmountInWei, getAssetInfo } from '@defisaver/tokens';
11
11
  import Dec from 'decimal.js';
12
- import { AaveIncentiveDataProviderV3ContractViem, AaveV3ViewContractViem, createViemContractFromConfigFunc, } from '../contracts';
12
+ import { AaveIncentiveDataProviderV3ContractViem, AaveIncentivesControllerViem, AaveV3ViewContractViem, createViemContractFromConfigFunc, StkAAVEViem, } from '../contracts';
13
13
  import { aaveAnyGetAggregatedPositionData, aaveV3IsInIsolationMode, aaveV3IsInSiloedMode } from '../helpers/aaveHelpers';
14
14
  import { AAVE_V3 } from '../markets/aave';
15
15
  import { aprToApy, calculateBorrowingAssetLimit } from '../moneymarket';
@@ -19,6 +19,7 @@ import { IncentiveKind, NetworkNumber, } from '../types/common';
19
19
  import { getViemProvider, setViemBlockNumber } from '../services/viem';
20
20
  import { getMeritCampaigns } from './merit';
21
21
  import { getAaveUnderlyingSymbol, getMerkleCampaigns } from './merkl';
22
+ import { SECONDS_PER_YEAR } from '../constants';
22
23
  export const aaveV3EmodeCategoriesMapping = (extractedState, usedAssets) => {
23
24
  const { eModeCategoriesData } = extractedState;
24
25
  const usedAssetsValues = Object.values(usedAssets);
@@ -321,6 +322,7 @@ export const _getAaveV3AccountBalances = (provider, network, block, addressMappi
321
322
  const marketAddress = market.providerAddress;
322
323
  // @ts-ignore
323
324
  const protocolDataProviderContract = createViemContractFromConfigFunc(market.protocolData, market.protocolDataAddress)(provider, network);
325
+ // @ts-ignore
324
326
  const reserveTokens = yield protocolDataProviderContract.read.getAllReservesTokens(setViemBlockNumber(block));
325
327
  const symbols = reserveTokens.map(({ symbol }) => symbol);
326
328
  const _addresses = reserveTokens.map(({ tokenAddress }) => tokenAddress);
@@ -420,4 +422,92 @@ export const getAaveV3FullPositionData = (provider, network, address, market) =>
420
422
  const positionData = yield getAaveV3AccountData(provider, network, address, { assetsData: marketData.assetsData, selectedMarket: market, eModeCategoriesData: marketData.eModeCategoriesData });
421
423
  return positionData;
422
424
  });
425
+ // aTokens eligible for AAVE rewards
426
+ export const REWARDABLE_ASSETS = [
427
+ '0x028171bCA77440897B824Ca71D1c56caC55b68A3', // DAI
428
+ '0x6C3c78838c761c6Ac7bE9F59fe808ea2A6E4379d',
429
+ '0xD37EE7e4f452C6638c96536e68090De8cBcdb583', // GUSD
430
+ '0x279AF5b99540c1A3A7E3CDd326e19659401eF99e',
431
+ '0xBcca60bB61934080951369a648Fb03DF4F96263C', // USDC
432
+ '0x619beb58998eD2278e08620f97007e1116D5D25b',
433
+ '0x3Ed3B47Dd13EC9a98b44e6204A523E766B225811', // USDT
434
+ '0x531842cEbbdD378f8ee36D171d6cC9C4fcf475Ec',
435
+ '0x9ff58f4fFB29fA2266Ab25e75e2A8b3503311656', // WBTC
436
+ '0x9c39809Dec7F95F5e0713634a4D0701329B3b4d2',
437
+ '0x030bA81f1c18d280636F32af80b9AAd02Cf0854e', // WETH
438
+ '0xF63B34710400CAd3e044cFfDcAb00a0f32E33eCf',
439
+ '0xa06bC25B5805d5F8d82847D191Cb4Af5A3e873E0', // LINK
440
+ '0x0b8f12b1788BFdE65Aa1ca52E3e9F3Ba401be16D',
441
+ '0x6C5024Cd4F8A59110119C56f8933403A539555EB', // SUSD
442
+ '0xdC6a3Ab17299D9C2A412B0e0a4C1f55446AE0817',
443
+ '0x5165d24277cD063F5ac44Efd447B27025e888f37', // YFI
444
+ '0x7EbD09022Be45AD993BAA1CEc61166Fcc8644d97',
445
+ '0xF256CC7847E919FAc9B808cC216cAc87CCF2f47a', // xSUSHI
446
+ '0xfAFEDF95E21184E3d880bd56D4806c4b8d31c69A',
447
+ '0xB9D7CB55f463405CDfBe4E90a6D2Df01C2B92BF1', // UNI
448
+ '0x5BdB050A92CADcCfCDcCCBFC17204a1C9cC0Ab73',
449
+ '0xc713e5E149D5D0715DcD1c156a020976e7E56B88', // MKR
450
+ '0xba728eAd5e496BE00DCF66F650b6d7758eCB50f8',
451
+ '0x101cc05f4A51C0319f570d5E146a8C625198e636', // TUSD
452
+ '0x01C0eb1f8c6F1C1bF74ae028697ce7AA2a8b0E92',
453
+ '0xc9BC48c72154ef3e5425641a3c747242112a46AF', // RAI
454
+ '0xB5385132EE8321977FfF44b60cDE9fE9AB0B4e6b',
455
+ '0x272F97b7a56a387aE942350bBC7Df5700f8a4576', // BAL
456
+ '0x13210D4Fe0d5402bd7Ecbc4B5bC5cFcA3b71adB0',
457
+ '0x2e8f4bdbe3d47d7d7de490437aea9915d930f1a3', // USDP
458
+ '0xfdb93b3b10936cf81fa59a02a7523b6e2149b2b7',
459
+ '0xA361718326c15715591c299427c62086F69923D9', // BUSD
460
+ '0xbA429f7011c9fa04cDd46a2Da24dc0FF0aC6099c',
461
+ '0xd4937682df3C8aEF4FE912A96A74121C0829E664', // FRAX
462
+ '0xfE8F19B17fFeF0fDbfe2671F248903055AFAA8Ca',
463
+ '0x683923dB55Fead99A79Fa01A27EeC3cB19679cC3', // FEI
464
+ '0xC2e10006AccAb7B45D9184FcF5b7EC7763f5BaAe',
465
+ '0x8dAE6Cb04688C62d939ed9B68d32Bc62e49970b1', // CRV
466
+ '0x00ad8eBF64F141f1C81e9f8f792d3d1631c6c684',
467
+ '0x6F634c6135D2EBD550000ac92F494F9CB8183dAe', // DPI
468
+ '0x4dDff5885a67E4EffeC55875a3977D7E60F82ae0',
469
+ ];
470
+ export const fetchYearlyMeritApyForStakingGho = () => __awaiter(void 0, void 0, void 0, function* () {
471
+ var _a, _b;
472
+ try {
473
+ const response = yield fetch('https://apps.aavechan.com/api/merit/aprs', { signal: AbortSignal.timeout(5000) });
474
+ const data = yield response.json();
475
+ const apr = ((_b = (_a = data === null || data === void 0 ? void 0 : data.currentAPR) === null || _a === void 0 ? void 0 : _a.actionsAPR) === null || _b === void 0 ? void 0 : _b['ethereum-stkgho']) || '0';
476
+ const apy = aprToApy(apr);
477
+ const apyWithDFSBonus = new Dec(apy).mul(1.05).toString(); // 5% bonus for DFS users
478
+ return apyWithDFSBonus;
479
+ }
480
+ catch (e) {
481
+ const message = 'External API Failure: Failed to fetch yearly merit APY for staking GHO';
482
+ console.error(message, e);
483
+ return '0';
484
+ }
485
+ });
486
+ export const getStakeAaveData = (provider, network, address) => __awaiter(void 0, void 0, void 0, function* () {
487
+ const stkGhoAddress = getAssetInfo('stkGHO').address;
488
+ const stkAaveAddress = getAssetInfo('stkAAVE').address;
489
+ const AaveIncentivesController = AaveIncentivesControllerViem(provider, network);
490
+ const stkAAVE = StkAAVEViem(provider, network);
491
+ const stkGHO = createViemContractFromConfigFunc('Erc20', stkGhoAddress)(provider, network);
492
+ const [aaveRewardsBalance, emissionsPerSecond, stkAAVEBalance, stkAAVETotalSupply, stkGHOBalance, ghoMeritApy] = yield Promise.all([
493
+ AaveIncentivesController.read.getRewardsBalance([REWARDABLE_ASSETS, address]),
494
+ stkAAVE.read.assets([stkAaveAddress]),
495
+ stkAAVE.read.balanceOf([address]),
496
+ stkAAVE.read.totalSupply(),
497
+ stkGHO.read.balanceOf([address]),
498
+ fetchYearlyMeritApyForStakingGho(),
499
+ ]);
500
+ const stkAaveApy = new Dec(assetAmountInEth(emissionsPerSecond[0].toString(), 'GHO') || 0).mul(SECONDS_PER_YEAR).mul(100).div(assetAmountInEth(stkAAVETotalSupply.toString(), 'stkAAVE'))
501
+ .toString();
502
+ return {
503
+ activatedCooldown: '0',
504
+ activatedCooldownAmount: '0',
505
+ stkAaveRewardsBalance: '0',
506
+ aaveRewardsBalance: assetAmountInEth(aaveRewardsBalance.toString(), 'AAVE'),
507
+ stkAaveBalance: assetAmountInEth(stkAAVEBalance.toString(), 'stkAAVE'),
508
+ stkGhoBalance: assetAmountInEth(stkGHOBalance.toString(), 'GHO'),
509
+ ghoMeritApy,
510
+ stkAaveApy,
511
+ };
512
+ });
423
513
  export { getMeritCampaigns, getMerkleCampaigns, };
@@ -0,0 +1,5 @@
1
+ import { Client } from 'viem';
2
+ import { EthAddress, NetworkNumber } from '../types/common';
3
+ import { ClaimableToken } from '../types/claiming';
4
+ export declare function getUnclaimedRewardsForAllMarkets(provider: Client, network: NetworkNumber, walletAddress: EthAddress, marketAddress: EthAddress): Promise<ClaimableToken[]>;
5
+ export declare function getMeritUnclaimedRewards(account: EthAddress, network: NetworkNumber, acceptMorpho?: boolean): Promise<ClaimableToken[]>;
@@ -0,0 +1,132 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import Dec from 'decimal.js';
11
+ import { ClaimType } from '../types/claiming';
12
+ import { AaveIncentiveDataProviderV3ContractViem, AaveRewardsControllerViem, } from '../contracts';
13
+ import { compareAddresses, getEthAmountForDecimals } from '../services/utils';
14
+ import { getAaveUnderlyingSymbol } from '../helpers/aaveHelpers';
15
+ const mapAaveRewardsToClaimableTokens = (aaveRewards, marketAddress, walletAddress) => aaveRewards.map(reward => ({
16
+ symbol: reward.symbol,
17
+ amount: reward.amount,
18
+ claimType: ClaimType.AAVE_REWARDS,
19
+ tokenAddress: reward.rewardTokenAddress,
20
+ underlyingSymbol: reward.underlyingAsset,
21
+ walletAddress,
22
+ label: 'AAVE Rewards',
23
+ additionalClaimFields: {
24
+ marketAddress,
25
+ aTokenAddresses: reward.aTokenAddresses,
26
+ isAaveToken: reward.symbol.startsWith('a'),
27
+ },
28
+ }));
29
+ export function getUnclaimedRewardsForAllMarkets(provider, network, walletAddress, marketAddress) {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ const contract = AaveIncentiveDataProviderV3ContractViem(provider, network);
32
+ const tokensData = yield contract.read.getUserReservesIncentivesData([marketAddress, walletAddress]);
33
+ const allTokensDataArrays = tokensData.reduce((acc, val) => {
34
+ acc.push(val.aTokenIncentivesUserData.userRewardsInformation);
35
+ acc.push(val.vTokenIncentivesUserData.userRewardsInformation);
36
+ return acc;
37
+ }, []);
38
+ const allATokens = tokensData.reduce((acc, val) => {
39
+ acc.push(val.aTokenIncentivesUserData.tokenAddress);
40
+ acc.push(val.vTokenIncentivesUserData.tokenAddress);
41
+ return acc;
42
+ }, []);
43
+ // array of rewards for each market (aToken/vToken)
44
+ // reward can be any token like wstETH, but also aToken like aWETH
45
+ const aaveRewardsController = AaveRewardsControllerViem(provider, network);
46
+ const rewardsPerAAsset = yield Promise.all(allATokens.map((token) => aaveRewardsController.read.getAllUserRewards([[token], walletAddress])));
47
+ // match amounts to token symbol, parse decimal amounts
48
+ const rewardsPerAAssetWithInfo = rewardsPerAAsset.map((rewardForAAsset, aaIndex) => {
49
+ const rewardsList = rewardForAAsset[0];
50
+ const amounts = rewardForAAsset[1];
51
+ const rewardsDataArraysForAAsset = allTokensDataArrays[aaIndex];
52
+ const aTokenAddress = allATokens[aaIndex];
53
+ return rewardsList.map((rewardTokenAddress, rewardIndex) => {
54
+ var _a, _b;
55
+ const dataArrIndex = rewardsDataArraysForAAsset.findIndex((arr) => compareAddresses(arr.rewardTokenAddress, rewardTokenAddress));
56
+ const amountWei = amounts[rewardIndex];
57
+ const amount = getEthAmountForDecimals(amountWei.toString(), (_a = rewardsDataArraysForAAsset[dataArrIndex]) === null || _a === void 0 ? void 0 : _a.rewardTokenDecimals);
58
+ const symbol = ((_b = rewardsDataArraysForAAsset[dataArrIndex]) === null || _b === void 0 ? void 0 : _b.rewardTokenSymbol) || '';
59
+ const underlyingAsset = getAaveUnderlyingSymbol(symbol);
60
+ return ({
61
+ amount,
62
+ symbol,
63
+ underlyingAsset,
64
+ rewardTokenAddress,
65
+ aTokenAddress,
66
+ });
67
+ });
68
+ });
69
+ // sum all unclaimed rewards of all markets per each token
70
+ // (e.g. how much awstETH is claimable in total from both aUSDC and awstETH markets)
71
+ const totalUnclaimedPerRewardToken = {};
72
+ rewardsPerAAssetWithInfo
73
+ .flat()
74
+ .forEach(({ amount, symbol, underlyingAsset, rewardTokenAddress, aTokenAddress, }) => {
75
+ if (+amount > 0) {
76
+ if (!totalUnclaimedPerRewardToken[symbol]) {
77
+ totalUnclaimedPerRewardToken[symbol] = {
78
+ amount, symbol, underlyingAsset, rewardTokenAddress, aTokenAddresses: [aTokenAddress],
79
+ };
80
+ }
81
+ else {
82
+ totalUnclaimedPerRewardToken[symbol].amount =
83
+ new Dec(totalUnclaimedPerRewardToken[symbol].amount).add(amount).toString();
84
+ totalUnclaimedPerRewardToken[symbol].aTokenAddresses.push(aTokenAddress);
85
+ }
86
+ }
87
+ }, []);
88
+ return mapAaveRewardsToClaimableTokens(Object.values(totalUnclaimedPerRewardToken), marketAddress, walletAddress);
89
+ });
90
+ }
91
+ export function getMeritUnclaimedRewards(account_1, network_1) {
92
+ return __awaiter(this, arguments, void 0, function* (account, network, acceptMorpho = true) {
93
+ let data;
94
+ try {
95
+ const res = yield fetch(`https://api.merkl.xyz/v4/users/${account}/rewards?chainId=${network}`, { signal: AbortSignal.timeout(3000) });
96
+ data = yield res.json();
97
+ }
98
+ catch (error) {
99
+ console.error('External API Failure: Aave Merit', error);
100
+ data = [];
101
+ }
102
+ const claimableTokens = [];
103
+ data.forEach((item) => {
104
+ item.rewards.forEach(reward => {
105
+ const { token, amount, claimed, proofs, } = reward;
106
+ const isTokenMorpho = token.symbol === 'MORPHO';
107
+ if (!token || !token.symbol || amount === '0' || (isTokenMorpho && !acceptMorpho))
108
+ return;
109
+ const unclaimedAmount = new Dec(amount).minus(claimed || 0).toString();
110
+ if (unclaimedAmount === '0')
111
+ return;
112
+ const unclaimed = getEthAmountForDecimals(unclaimedAmount, token.decimals);
113
+ claimableTokens.push({
114
+ claimType: ClaimType.AAVE_MERIT_REWARDS,
115
+ amount: unclaimed,
116
+ symbol: token.symbol,
117
+ tokenAddress: token.address,
118
+ walletAddress: account,
119
+ label: 'AAVE Merit Rewards',
120
+ underlyingSymbol: getAaveUnderlyingSymbol(token.symbol),
121
+ additionalClaimFields: {
122
+ accumulated: amount,
123
+ proof: proofs,
124
+ decimals: token.decimals,
125
+ unclaimed: unclaimedAmount,
126
+ },
127
+ });
128
+ });
129
+ });
130
+ return claimableTokens;
131
+ });
132
+ }
@@ -0,0 +1,15 @@
1
+ import { Client } from 'viem';
2
+ import { EthAddress, NetworkNumber } from '../types/common';
3
+ import { ClaimType } from '../types/claiming';
4
+ export declare const getCompoundV3Rewards: (provider: Client, network: NetworkNumber, user: EthAddress, market: any) => Promise<{
5
+ symbol: string;
6
+ underlyingSymbol: string;
7
+ tokenAddress: `0x${string}`;
8
+ amount: string;
9
+ walletAddress: `0x${string}`;
10
+ label: string;
11
+ claimType: ClaimType;
12
+ additionalClaimFields: {
13
+ marketAddress: any;
14
+ };
15
+ }[]>;
@@ -0,0 +1,30 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { assetAmountInEth, getAssetInfoByAddress } from '@defisaver/tokens';
11
+ import { CompV3ViewContractViem } from '../contracts';
12
+ import { ClaimType } from '../types/claiming';
13
+ export const getCompoundV3Rewards = (provider, network, user, market) => __awaiter(void 0, void 0, void 0, function* () {
14
+ const compV3View = CompV3ViewContractViem(provider, network);
15
+ const rewards = yield compV3View.read.getRewardsOwed([market, user]);
16
+ if (!rewards || rewards.owed.toString() === '0' || getAssetInfoByAddress(rewards.token, network).symbol !== 'COMP')
17
+ return [];
18
+ return [{
19
+ symbol: 'COMP',
20
+ underlyingSymbol: 'COMP',
21
+ tokenAddress: rewards.token,
22
+ amount: assetAmountInEth(rewards.owed.toString() || 0, 'COMP'),
23
+ walletAddress: user,
24
+ label: 'Compound V3',
25
+ claimType: ClaimType.COMPOUND_V3_COMP,
26
+ additionalClaimFields: {
27
+ marketAddress: market,
28
+ },
29
+ }];
30
+ });
@@ -0,0 +1,6 @@
1
+ import * as aaveV3Claim from './aaveV3';
2
+ import * as compV3Claim from './compV3';
3
+ import * as kingV3Claim from './king';
4
+ import * as morphoBlueClaim from './morphoBlue';
5
+ import * as sparkClaim from './spark';
6
+ export { aaveV3Claim, compV3Claim, kingV3Claim, morphoBlueClaim, sparkClaim, };
@@ -0,0 +1,6 @@
1
+ import * as aaveV3Claim from './aaveV3';
2
+ import * as compV3Claim from './compV3';
3
+ import * as kingV3Claim from './king';
4
+ import * as morphoBlueClaim from './morphoBlue';
5
+ import * as sparkClaim from './spark';
6
+ export { aaveV3Claim, compV3Claim, kingV3Claim, morphoBlueClaim, sparkClaim, };
@@ -0,0 +1,4 @@
1
+ import { Client } from 'viem';
2
+ import { EthAddress, NetworkNumber } from '../types/common';
3
+ export declare const fetchKingRewards: (walletAddress: EthAddress) => Promise<any>;
4
+ export declare const getKingRewards: (provider: Client, network: NetworkNumber, walletAddresses: EthAddress[]) => Promise<Record<string, any[]>>;