@defisaver/positions-sdk 2.1.104 → 2.1.106-sgho-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.
Files changed (53) hide show
  1. package/cjs/aaveV3/index.d.ts +3 -0
  2. package/cjs/aaveV3/index.js +7 -2
  3. package/cjs/aaveV3/sgho.d.ts +18 -0
  4. package/cjs/aaveV3/sgho.js +95 -0
  5. package/cjs/aaveV4/index.js +53 -20
  6. package/cjs/claiming/aaveV3.d.ts +1 -1
  7. package/cjs/claiming/aaveV3.js +3 -4
  8. package/cjs/claiming/index.d.ts +1 -2
  9. package/cjs/claiming/index.js +1 -3
  10. package/cjs/config/contracts.d.ts +0 -214
  11. package/cjs/config/contracts.js +1 -6
  12. package/cjs/helpers/morphoBlueHelpers/index.d.ts +0 -1
  13. package/cjs/helpers/morphoBlueHelpers/index.js +27 -32
  14. package/cjs/portfolio/index.js +0 -27
  15. package/cjs/types/aaveV4.d.ts +9 -0
  16. package/cjs/types/claiming.d.ts +1 -13
  17. package/cjs/types/claiming.js +0 -2
  18. package/cjs/types/morphoBlue.d.ts +2 -3
  19. package/esm/aaveV3/index.d.ts +3 -0
  20. package/esm/aaveV3/index.js +5 -1
  21. package/esm/aaveV3/sgho.d.ts +18 -0
  22. package/esm/aaveV3/sgho.js +88 -0
  23. package/esm/aaveV4/index.js +53 -20
  24. package/esm/claiming/aaveV3.d.ts +1 -1
  25. package/esm/claiming/aaveV3.js +3 -4
  26. package/esm/claiming/index.d.ts +1 -2
  27. package/esm/claiming/index.js +1 -2
  28. package/esm/config/contracts.d.ts +0 -214
  29. package/esm/config/contracts.js +0 -4
  30. package/esm/helpers/morphoBlueHelpers/index.d.ts +0 -1
  31. package/esm/helpers/morphoBlueHelpers/index.js +27 -31
  32. package/esm/portfolio/index.js +0 -27
  33. package/esm/types/aaveV4.d.ts +9 -0
  34. package/esm/types/claiming.d.ts +1 -13
  35. package/esm/types/claiming.js +0 -2
  36. package/esm/types/morphoBlue.d.ts +2 -3
  37. package/package.json +2 -2
  38. package/src/aaveV3/index.ts +7 -1
  39. package/src/aaveV3/sgho.ts +100 -0
  40. package/src/aaveV4/index.ts +48 -20
  41. package/src/claiming/aaveV3.ts +2 -3
  42. package/src/claiming/index.ts +0 -2
  43. package/src/config/contracts.ts +0 -4
  44. package/src/helpers/morphoBlueHelpers/index.ts +29 -32
  45. package/src/portfolio/index.ts +0 -25
  46. package/src/types/aaveV4.ts +9 -0
  47. package/src/types/claiming.ts +0 -15
  48. package/src/types/morphoBlue.ts +2 -3
  49. package/cjs/claiming/morphoBlue.d.ts +0 -5
  50. package/cjs/claiming/morphoBlue.js +0 -113
  51. package/esm/claiming/morphoBlue.d.ts +0 -5
  52. package/esm/claiming/morphoBlue.js +0 -105
  53. package/src/claiming/morphoBlue.ts +0 -119
@@ -46,5 +46,8 @@ export declare const getStakeAaveData: (provider: Client, network: NetworkNumber
46
46
  stkGhoBalance: string;
47
47
  ghoMeritApy: string;
48
48
  stkAaveApy: string;
49
+ sgho: import("./sgho").SghoData;
49
50
  }>;
50
51
  export { getMeritCampaigns, getMerkleCampaigns, };
52
+ export { getSghoData } from './sgho';
53
+ export type { SghoData, SghoUserData } from './sgho';
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.getMerkleCampaigns = exports.getMeritCampaigns = exports.getStakeAaveData = exports.fetchYearlyMeritApyForStakingGho = exports.REWARDABLE_ASSETS = exports.getAaveV3FullPositionData = exports.getAaveV3AccountData = exports._getAaveV3AccountData = exports.getAaveV3AccountBalances = exports._getAaveV3AccountBalances = exports.EMPTY_AAVE_DATA = exports.aaveV3EmodeCategoriesMapping = void 0;
15
+ exports.getSghoData = exports.getMerkleCampaigns = exports.getMeritCampaigns = exports.getStakeAaveData = exports.fetchYearlyMeritApyForStakingGho = exports.REWARDABLE_ASSETS = exports.getAaveV3FullPositionData = exports.getAaveV3AccountData = exports._getAaveV3AccountData = exports.getAaveV3AccountBalances = exports._getAaveV3AccountBalances = exports.EMPTY_AAVE_DATA = exports.aaveV3EmodeCategoriesMapping = void 0;
16
16
  exports._getAaveV3MarketData = _getAaveV3MarketData;
17
17
  exports.getAaveV3MarketData = getAaveV3MarketData;
18
18
  const tokens_1 = require("@defisaver/tokens");
@@ -29,6 +29,7 @@ const merit_1 = require("./merit");
29
29
  Object.defineProperty(exports, "getMeritCampaigns", { enumerable: true, get: function () { return merit_1.getMeritCampaigns; } });
30
30
  const merkl_1 = require("./merkl");
31
31
  Object.defineProperty(exports, "getMerkleCampaigns", { enumerable: true, get: function () { return merkl_1.getMerkleCampaigns; } });
32
+ const sgho_1 = require("./sgho");
32
33
  const constants_1 = require("../constants");
33
34
  const aaveV3EmodeCategoriesMapping = (extractedState, usedAssets) => {
34
35
  const { eModeCategoriesData } = extractedState;
@@ -519,13 +520,14 @@ const getStakeAaveData = (provider, network, address) => __awaiter(void 0, void
519
520
  const AaveIncentivesController = (0, contracts_1.AaveIncentivesControllerViem)(provider, network);
520
521
  const stkAAVE = (0, contracts_1.StkAAVEViem)(provider, network);
521
522
  const stkGHO = (0, contracts_1.createViemContractFromConfigFunc)('Erc20', stkGhoAddress)(provider, network);
522
- const [aaveRewardsBalance, emissionsPerSecond, stkAAVEBalance, stkAAVETotalSupply, stkGHOBalance, ghoMeritApy] = yield Promise.all([
523
+ const [aaveRewardsBalance, emissionsPerSecond, stkAAVEBalance, stkAAVETotalSupply, stkGHOBalance, ghoMeritApy, sgho] = yield Promise.all([
523
524
  AaveIncentivesController.read.getRewardsBalance([exports.REWARDABLE_ASSETS, address]),
524
525
  stkAAVE.read.assets([stkAaveAddress]),
525
526
  stkAAVE.read.balanceOf([address]),
526
527
  stkAAVE.read.totalSupply(),
527
528
  stkGHO.read.balanceOf([address]),
528
529
  (0, exports.fetchYearlyMeritApyForStakingGho)(),
530
+ (0, sgho_1.getSghoData)(network, address),
529
531
  ]);
530
532
  const stkAaveApy = new decimal_js_1.default((0, tokens_1.assetAmountInEth)(emissionsPerSecond[0].toString(), 'GHO') || 0).mul(constants_1.SECONDS_PER_YEAR).mul(100).div((0, tokens_1.assetAmountInEth)(stkAAVETotalSupply.toString(), 'stkAAVE'))
531
533
  .toString();
@@ -538,6 +540,9 @@ const getStakeAaveData = (provider, network, address) => __awaiter(void 0, void
538
540
  stkGhoBalance: (0, tokens_1.assetAmountInEth)(stkGHOBalance.toString(), 'GHO'),
539
541
  ghoMeritApy,
540
542
  stkAaveApy,
543
+ sgho,
541
544
  };
542
545
  });
543
546
  exports.getStakeAaveData = getStakeAaveData;
547
+ var sgho_2 = require("./sgho");
548
+ Object.defineProperty(exports, "getSghoData", { enumerable: true, get: function () { return sgho_2.getSghoData; } });
@@ -0,0 +1,18 @@
1
+ import { EthAddress, NetworkNumber } from '../types/common';
2
+ export interface SghoUserData {
3
+ shares: string;
4
+ balance: string;
5
+ maxDeposit: string;
6
+ maxWithdraw: string;
7
+ underlyingBalance: string;
8
+ }
9
+ export interface SghoData {
10
+ totalAssets: string;
11
+ totalSupply: string;
12
+ supplyCap: string;
13
+ /** Target savings rate as an APY percent (e.g. "4.25" for 4.25%). */
14
+ targetRate: string;
15
+ paused: boolean;
16
+ user: SghoUserData;
17
+ }
18
+ export declare const getSghoData: (network: NetworkNumber, address?: EthAddress) => Promise<SghoData>;
@@ -0,0 +1,95 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.getSghoData = void 0;
16
+ const decimal_js_1 = __importDefault(require("decimal.js"));
17
+ const common_1 = require("../types/common");
18
+ const utils_1 = require("../services/utils");
19
+ const constants_1 = require("../constants");
20
+ const EMPTY_SGHO_DATA = {
21
+ totalAssets: '0',
22
+ totalSupply: '0',
23
+ supplyCap: '0',
24
+ targetRate: '0',
25
+ paused: false,
26
+ user: {
27
+ shares: '0',
28
+ balance: '0',
29
+ maxDeposit: '0',
30
+ maxWithdraw: '0',
31
+ underlyingBalance: '0',
32
+ },
33
+ };
34
+ const SGHO_VAULT_QUERY = `query SghoVault($request: SghoVaultRequest!) {
35
+ value: sghoVault(request: $request) {
36
+ totalAssets { amount { value } }
37
+ totalSupply { value }
38
+ supplyCap { amount { value } }
39
+ targetRate { value }
40
+ paused
41
+ user {
42
+ shares { amount { value } }
43
+ balance { amount { value } }
44
+ maxDeposit { amount { value } }
45
+ maxWithdraw { amount { value } }
46
+ underlyingBalance { amount { value } }
47
+ }
48
+ }
49
+ }`;
50
+ const tokenAmountValue = (entry) => { var _a, _b; return ((_b = (_a = entry === null || entry === void 0 ? void 0 : entry.amount) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.toString()) || '0'; };
51
+ const decimalValue = (entry) => { var _a; return ((_a = entry === null || entry === void 0 ? void 0 : entry.value) === null || _a === void 0 ? void 0 : _a.toString()) || '0'; };
52
+ // Aave returns the rate as a ratio (e.g. 0.0425); consumers display/compound it as a percent (4.25).
53
+ const percentValue = (entry) => ((entry === null || entry === void 0 ? void 0 : entry.value) != null ? new decimal_js_1.default(entry.value).mul(100).toString() : '0');
54
+ const getSghoData = (network_1, ...args_1) => __awaiter(void 0, [network_1, ...args_1], void 0, function* (network, address = constants_1.ZERO_ADDRESS) {
55
+ var _a, _b, _c, _d, _e, _f;
56
+ if (network !== common_1.NetworkNumber.Eth)
57
+ return EMPTY_SGHO_DATA;
58
+ try {
59
+ const res = yield fetch('https://api.v3.aave.com/graphql', {
60
+ method: 'POST',
61
+ headers: { 'Content-Type': 'application/json' },
62
+ body: JSON.stringify({
63
+ operationName: 'SghoVault',
64
+ query: SGHO_VAULT_QUERY,
65
+ variables: { request: { chainId: 1, user: address } },
66
+ }),
67
+ signal: AbortSignal.timeout(utils_1.DEFAULT_TIMEOUT),
68
+ });
69
+ if (!res.ok)
70
+ throw new Error(`Aave SghoVault request failed: ${res.status}`);
71
+ const body = yield res.json();
72
+ const data = (_a = body === null || body === void 0 ? void 0 : body.data) === null || _a === void 0 ? void 0 : _a.value;
73
+ if (!data)
74
+ throw new Error('Aave SghoVault response missing data');
75
+ return {
76
+ totalAssets: tokenAmountValue(data.totalAssets),
77
+ totalSupply: decimalValue(data.totalSupply),
78
+ supplyCap: tokenAmountValue(data.supplyCap),
79
+ targetRate: percentValue(data.targetRate),
80
+ paused: !!data.paused,
81
+ user: {
82
+ shares: tokenAmountValue((_b = data === null || data === void 0 ? void 0 : data.user) === null || _b === void 0 ? void 0 : _b.shares),
83
+ balance: tokenAmountValue((_c = data === null || data === void 0 ? void 0 : data.user) === null || _c === void 0 ? void 0 : _c.balance),
84
+ maxDeposit: tokenAmountValue((_d = data === null || data === void 0 ? void 0 : data.user) === null || _d === void 0 ? void 0 : _d.maxDeposit),
85
+ maxWithdraw: tokenAmountValue((_e = data === null || data === void 0 ? void 0 : data.user) === null || _e === void 0 ? void 0 : _e.maxWithdraw),
86
+ underlyingBalance: tokenAmountValue((_f = data === null || data === void 0 ? void 0 : data.user) === null || _f === void 0 ? void 0 : _f.underlyingBalance),
87
+ },
88
+ };
89
+ }
90
+ catch (e) {
91
+ console.error('External API Failure: Failed to fetch Aave sGHO vault data', e);
92
+ return EMPTY_SGHO_DATA;
93
+ }
94
+ });
95
+ exports.getSghoData = getSghoData;
@@ -86,6 +86,9 @@ const fetchHubData = (viewContract, hubAddress) => __awaiter(void 0, void 0, voi
86
86
  const formatReserveAsset = (reserveAsset, hubAsset, reserveId, oracleDecimals, network) => __awaiter(void 0, void 0, void 0, function* () {
87
87
  var _a, _b, _c, _d, _e, _f;
88
88
  const assetInfo = (0, tokens_1.getAssetInfoByAddress)(reserveAsset.underlying, network);
89
+ // `@defisaver/tokens` returns a placeholder ('?', decimals NaN) when the underlying is not in the
90
+ // tokens package. Flag it so consumers can render it read-only instead of feeding NaN into amounts.
91
+ const isUnsupported = assetInfo.symbol === '?';
89
92
  const symbol = (0, utils_1.wethToEth)(assetInfo.symbol);
90
93
  const hubInfo = (0, aaveV4_1.getAaveV4HubByAddress)(network, reserveAsset.hub);
91
94
  if (!hubInfo) {
@@ -132,10 +135,23 @@ const formatReserveAsset = (reserveAsset, hubAsset, reserveId, oracleDecimals, n
132
135
  const premiumMultiplier = totalDrawnShares.isZero() ? new decimal_js_1.default(1) : totalDrawnShares.add(totalPremiumShares).div(totalDrawnShares);
133
136
  const supplyApr = borrowApr.mul(hubUtilization).mul(premiumMultiplier).mul(new decimal_js_1.default(1).minus(liquidityFee));
134
137
  const utilization = hubUtilization.times(100).toString();
138
+ // For unsupported assets `symbol` is '?' (decimals NaN in `@defisaver/tokens`), so the
139
+ // symbol-based conversion would produce NaN. Fall back to the on-chain `decimals` so the reserve
140
+ // still shows correct amounts (and feeds correct USD/ratio/liquidation math) in read-only mode.
141
+ const toEth = (raw) => {
142
+ const rawStr = raw.toString();
143
+ if ((0, utils_1.isMaxUint)(rawStr))
144
+ return rawStr;
145
+ if (isUnsupported)
146
+ return new decimal_js_1.default(rawStr || 0).div(new decimal_js_1.default(10).pow(reserveAsset.decimals)).toString();
147
+ return (0, tokens_1.assetAmountInEth)(rawStr, symbol);
148
+ };
135
149
  const hubLiquidityRaw = hubAsset.liquidity;
136
- const hubLiquidity = (0, utils_1.isMaxUint)(hubLiquidityRaw.toString()) ? hubLiquidityRaw.toString() : (0, tokens_1.assetAmountInEth)(hubLiquidityRaw.toString(), symbol);
150
+ const hubLiquidity = toEth(hubLiquidityRaw.toString());
137
151
  return ({
138
152
  symbol,
153
+ decimals: reserveAsset.decimals,
154
+ isUnsupported,
139
155
  underlying: reserveAsset.underlying,
140
156
  hub: hubInfo.address,
141
157
  hubName: hubInfo === null || hubInfo === void 0 ? void 0 : hubInfo.label,
@@ -149,12 +165,12 @@ const formatReserveAsset = (reserveAsset, hubAsset, reserveId, oracleDecimals, n
149
165
  liquidationFee: new decimal_js_1.default(reserveAsset.liquidationFee).div(10000).toNumber(),
150
166
  maxLiquidationBonus: new decimal_js_1.default(reserveAsset.maxLiquidationBonus).div(10000).toNumber(),
151
167
  price: new decimal_js_1.default(reserveAsset.price).div(new decimal_js_1.default(10).pow(oracleDecimals)).toString(),
152
- totalSupplied: (0, utils_1.isMaxUint)(totalSuppliedRaw.toString()) ? totalSuppliedRaw.toString() : (0, tokens_1.assetAmountInEth)(totalSuppliedRaw.toString(), symbol),
153
- totalDrawn: (0, utils_1.isMaxUint)(totalDrawnRaw.toString()) ? totalDrawnRaw.toString() : (0, tokens_1.assetAmountInEth)(totalDrawnRaw.toString(), symbol),
154
- totalPremium: (0, utils_1.isMaxUint)(totalPremiumRaw.toString()) ? totalPremiumRaw.toString() : (0, tokens_1.assetAmountInEth)(totalPremiumRaw.toString(), symbol),
155
- totalDebt: (0, utils_1.isMaxUint)(totalDebtRaw.toString()) ? totalDebtRaw.toString() : (0, tokens_1.assetAmountInEth)(totalDebtRaw.toString(), symbol),
156
- supplyCap: (0, utils_1.isMaxUint)(supplyCapRaw.toString()) ? supplyCapRaw.toString() : (0, tokens_1.assetAmountInEth)(supplyCapRaw.toString(), symbol),
157
- borrowCap: (0, utils_1.isMaxUint)(borrowCapRaw.toString()) ? borrowCapRaw.toString() : (0, tokens_1.assetAmountInEth)(borrowCapRaw.toString(), symbol),
168
+ totalSupplied: toEth(totalSuppliedRaw.toString()),
169
+ totalDrawn: toEth(totalDrawnRaw.toString()),
170
+ totalPremium: toEth(totalPremiumRaw.toString()),
171
+ totalDebt: toEth(totalDebtRaw.toString()),
172
+ supplyCap: toEth(supplyCapRaw.toString()),
173
+ borrowCap: toEth(borrowCapRaw.toString()),
158
174
  spokeActive: reserveAsset.spokeActive,
159
175
  spokeHalted: reserveAsset.spokeHalted,
160
176
  drawnRate: drawnRate.toString(),
@@ -162,10 +178,10 @@ const formatReserveAsset = (reserveAsset, hubAsset, reserveId, oracleDecimals, n
162
178
  supplyRate: (0, moneymarket_1.aprToApy)(supplyApr.toString()),
163
179
  supplyIncentives,
164
180
  borrowIncentives,
165
- canBeBorrowed: reserveAsset.spokeActive && !reserveAsset.spokeHalted && !reserveAsset.paused && !reserveAsset.frozen && reserveAsset.borrowable,
166
- canBeSupplied: reserveAsset.spokeActive && !reserveAsset.spokeHalted && !reserveAsset.paused && !reserveAsset.frozen,
167
- canBeWithdrawn: reserveAsset.spokeActive && !reserveAsset.spokeHalted && !reserveAsset.paused,
168
- canBePayBacked: reserveAsset.spokeActive && !reserveAsset.spokeHalted && !reserveAsset.paused,
181
+ canBeBorrowed: !isUnsupported && reserveAsset.spokeActive && !reserveAsset.spokeHalted && !reserveAsset.paused && !reserveAsset.frozen && reserveAsset.borrowable,
182
+ canBeSupplied: !isUnsupported && reserveAsset.spokeActive && !reserveAsset.spokeHalted && !reserveAsset.paused && !reserveAsset.frozen,
183
+ canBeWithdrawn: !isUnsupported && reserveAsset.spokeActive && !reserveAsset.spokeHalted && !reserveAsset.paused,
184
+ canBePayBacked: !isUnsupported && reserveAsset.spokeActive && !reserveAsset.spokeHalted && !reserveAsset.paused,
169
185
  utilization,
170
186
  hubLiquidity,
171
187
  premiumMultiplier: premiumMultiplier.toString(),
@@ -208,17 +224,33 @@ function _getAaveV4AccountData(provider_1, network_1, spokeData_1, address_1) {
208
224
  const healthFactorFromContract = new decimal_js_1.default(loanData.healthFactor.toString());
209
225
  const healthFactor = (0, utils_1.isMaxUint)(healthFactorFromContract.toString()) ? 'Infinity' : healthFactorFromContract.div(1e18).toString();
210
226
  const usedAssets = loanData.reserves.reduce((acc, usedReserveAsset) => {
211
- const identifier = `${(0, utils_1.wethToEth)((0, tokens_1.getAssetInfoByAddress)(usedReserveAsset.underlying, network).symbol)}-${+usedReserveAsset.reserveId.toString()}`;
227
+ var _a, _b, _c, _d;
228
+ const assetInfo = (0, tokens_1.getAssetInfoByAddress)(usedReserveAsset.underlying, network);
229
+ const isUnsupported = assetInfo.symbol === '?';
230
+ const symbol = (0, utils_1.wethToEth)(assetInfo.symbol);
231
+ const identifier = `${symbol}-${+usedReserveAsset.reserveId.toString()}`;
212
232
  const reserveData = spokeData.assetsData[identifier];
213
- const price = reserveData.price;
214
- const supplied = (0, utils_1.isMaxUint)(usedReserveAsset.supplied.toString()) ? usedReserveAsset.supplied.toString() : (0, tokens_1.assetAmountInEth)(usedReserveAsset.supplied.toString(), reserveData.symbol);
215
- const drawn = (0, utils_1.isMaxUint)(usedReserveAsset.drawn.toString()) ? usedReserveAsset.drawn.toString() : (0, tokens_1.assetAmountInEth)(usedReserveAsset.drawn.toString(), reserveData.symbol);
216
- const premium = (0, utils_1.isMaxUint)(usedReserveAsset.premium.toString()) ? usedReserveAsset.premium.toString() : (0, tokens_1.assetAmountInEth)(usedReserveAsset.premium.toString(), reserveData.symbol);
217
- const borrowed = (0, utils_1.isMaxUint)(usedReserveAsset.totalDebt.toString()) ? usedReserveAsset.totalDebt.toString() : (0, tokens_1.assetAmountInEth)(usedReserveAsset.totalDebt.toString(), reserveData.symbol);
233
+ const price = (_a = reserveData === null || reserveData === void 0 ? void 0 : reserveData.price) !== null && _a !== void 0 ? _a : '0';
234
+ // For unsupported assets the symbol-based conversion yields NaN, so use the on-chain decimals
235
+ // from the reserve data instead. If the reserve is missing entirely we can't convert, so fall
236
+ // back to '0' and keep the entry read-only.
237
+ const toEth = (raw) => {
238
+ if ((0, utils_1.isMaxUint)(raw))
239
+ return raw;
240
+ if (!reserveData)
241
+ return '0';
242
+ if (isUnsupported)
243
+ return new decimal_js_1.default(raw || 0).div(new decimal_js_1.default(10).pow(reserveData.decimals)).toString();
244
+ return (0, tokens_1.assetAmountInEth)(raw, reserveData.symbol);
245
+ };
246
+ const supplied = toEth(usedReserveAsset.supplied.toString());
247
+ const drawn = toEth(usedReserveAsset.drawn.toString());
248
+ const premium = toEth(usedReserveAsset.premium.toString());
249
+ const borrowed = toEth(usedReserveAsset.totalDebt.toString());
218
250
  acc[identifier] = {
219
- symbol: reserveData.symbol,
220
- hubName: reserveData.hubName,
221
- assetId: reserveData.assetId,
251
+ symbol: (_b = reserveData === null || reserveData === void 0 ? void 0 : reserveData.symbol) !== null && _b !== void 0 ? _b : symbol,
252
+ hubName: (_c = reserveData === null || reserveData === void 0 ? void 0 : reserveData.hubName) !== null && _c !== void 0 ? _c : '',
253
+ assetId: (_d = reserveData === null || reserveData === void 0 ? void 0 : reserveData.assetId) !== null && _d !== void 0 ? _d : 0,
222
254
  reserveId: +usedReserveAsset.reserveId.toString(),
223
255
  supplied,
224
256
  suppliedUsd: new decimal_js_1.default(supplied).mul(price).toString(),
@@ -232,6 +264,7 @@ function _getAaveV4AccountData(provider_1, network_1, spokeData_1, address_1) {
232
264
  isBorrowed: usedReserveAsset.isBorrowing,
233
265
  collateral: usedReserveAsset.isUsingAsCollateral,
234
266
  collateralFactor: new decimal_js_1.default(usedReserveAsset.collateralFactor).div(10000).toNumber(),
267
+ isUnsupported: isUnsupported || !reserveData,
235
268
  };
236
269
  return acc;
237
270
  }, {});
@@ -2,4 +2,4 @@ import { Client } from 'viem';
2
2
  import { EthAddress, NetworkNumber } from '../types/common';
3
3
  import { ClaimableToken } from '../types/claiming';
4
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[]>;
5
+ export declare function getMeritUnclaimedRewards(account: EthAddress, network: NetworkNumber): Promise<ClaimableToken[]>;
@@ -95,8 +95,8 @@ function getUnclaimedRewardsForAllMarkets(provider, network, walletAddress, mark
95
95
  return mapAaveRewardsToClaimableTokens(Object.values(totalUnclaimedPerRewardToken), marketAddress, walletAddress);
96
96
  });
97
97
  }
98
- function getMeritUnclaimedRewards(account_1, network_1) {
99
- return __awaiter(this, arguments, void 0, function* (account, network, acceptMorpho = true) {
98
+ function getMeritUnclaimedRewards(account, network) {
99
+ return __awaiter(this, void 0, void 0, function* () {
100
100
  let data;
101
101
  try {
102
102
  const res = yield fetch(`https://api-merkl.angle.money/v4/users/${account}/rewards?chainId=${network}`, { signal: AbortSignal.timeout(3000) });
@@ -110,8 +110,7 @@ function getMeritUnclaimedRewards(account_1, network_1) {
110
110
  data.forEach((item) => {
111
111
  item.rewards.forEach(reward => {
112
112
  const { token, amount, claimed, proofs, } = reward;
113
- const isTokenMorpho = token.symbol === 'MORPHO';
114
- if (!token || !token.symbol || amount === '0' || (isTokenMorpho && !acceptMorpho))
113
+ if (!token || !token.symbol || amount === '0')
115
114
  return;
116
115
  const unclaimedAmount = new decimal_js_1.default(amount).minus(claimed || 0).toString();
117
116
  if (unclaimedAmount === '0')
@@ -1,6 +1,5 @@
1
1
  import * as aaveV3Claim from './aaveV3';
2
2
  import * as compV3Claim from './compV3';
3
3
  import * as kingV3Claim from './king';
4
- import * as morphoBlueClaim from './morphoBlue';
5
4
  import * as sparkClaim from './spark';
6
- export { aaveV3Claim, compV3Claim, kingV3Claim, morphoBlueClaim, sparkClaim, };
5
+ export { aaveV3Claim, compV3Claim, kingV3Claim, sparkClaim, };
@@ -33,14 +33,12 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.sparkClaim = exports.morphoBlueClaim = exports.kingV3Claim = exports.compV3Claim = exports.aaveV3Claim = void 0;
36
+ exports.sparkClaim = exports.kingV3Claim = exports.compV3Claim = exports.aaveV3Claim = void 0;
37
37
  const aaveV3Claim = __importStar(require("./aaveV3"));
38
38
  exports.aaveV3Claim = aaveV3Claim;
39
39
  const compV3Claim = __importStar(require("./compV3"));
40
40
  exports.compV3Claim = compV3Claim;
41
41
  const kingV3Claim = __importStar(require("./king"));
42
42
  exports.kingV3Claim = kingV3Claim;
43
- const morphoBlueClaim = __importStar(require("./morphoBlue"));
44
- exports.morphoBlueClaim = morphoBlueClaim;
45
43
  const sparkClaim = __importStar(require("./spark"));
46
44
  exports.sparkClaim = sparkClaim;
@@ -96912,220 +96912,6 @@ export declare const SparkRewardsController: {
96912
96912
  };
96913
96913
  };
96914
96914
  };
96915
- export declare const MorphoDistributor: {
96916
- readonly abi: readonly [{
96917
- readonly inputs: readonly [{
96918
- readonly internalType: "address";
96919
- readonly name: "initialOwner";
96920
- readonly type: "address";
96921
- }, {
96922
- readonly internalType: "uint256";
96923
- readonly name: "initialTimelock";
96924
- readonly type: "uint256";
96925
- }, {
96926
- readonly internalType: "bytes32";
96927
- readonly name: "initialRoot";
96928
- readonly type: "bytes32";
96929
- }, {
96930
- readonly internalType: "bytes32";
96931
- readonly name: "initialIpfsHash";
96932
- readonly type: "bytes32";
96933
- }];
96934
- readonly stateMutability: "nonpayable";
96935
- readonly type: "constructor";
96936
- }, {
96937
- readonly inputs: readonly [];
96938
- readonly name: "acceptRoot";
96939
- readonly outputs: readonly [];
96940
- readonly stateMutability: "nonpayable";
96941
- readonly type: "function";
96942
- }, {
96943
- readonly inputs: readonly [{
96944
- readonly internalType: "address";
96945
- readonly name: "account";
96946
- readonly type: "address";
96947
- }, {
96948
- readonly internalType: "address";
96949
- readonly name: "reward";
96950
- readonly type: "address";
96951
- }, {
96952
- readonly internalType: "uint256";
96953
- readonly name: "claimable";
96954
- readonly type: "uint256";
96955
- }, {
96956
- readonly internalType: "bytes32[]";
96957
- readonly name: "proof";
96958
- readonly type: "bytes32[]";
96959
- }];
96960
- readonly name: "claim";
96961
- readonly outputs: readonly [{
96962
- readonly internalType: "uint256";
96963
- readonly name: "amount";
96964
- readonly type: "uint256";
96965
- }];
96966
- readonly stateMutability: "nonpayable";
96967
- readonly type: "function";
96968
- }, {
96969
- readonly inputs: readonly [{
96970
- readonly internalType: "address";
96971
- readonly name: "account";
96972
- readonly type: "address";
96973
- }, {
96974
- readonly internalType: "address";
96975
- readonly name: "reward";
96976
- readonly type: "address";
96977
- }];
96978
- readonly name: "claimed";
96979
- readonly outputs: readonly [{
96980
- readonly internalType: "uint256";
96981
- readonly name: "amount";
96982
- readonly type: "uint256";
96983
- }];
96984
- readonly stateMutability: "view";
96985
- readonly type: "function";
96986
- }, {
96987
- readonly inputs: readonly [];
96988
- readonly name: "ipfsHash";
96989
- readonly outputs: readonly [{
96990
- readonly internalType: "bytes32";
96991
- readonly name: "";
96992
- readonly type: "bytes32";
96993
- }];
96994
- readonly stateMutability: "view";
96995
- readonly type: "function";
96996
- }, {
96997
- readonly inputs: readonly [{
96998
- readonly internalType: "address";
96999
- readonly name: "";
97000
- readonly type: "address";
97001
- }];
97002
- readonly name: "isUpdater";
97003
- readonly outputs: readonly [{
97004
- readonly internalType: "bool";
97005
- readonly name: "";
97006
- readonly type: "bool";
97007
- }];
97008
- readonly stateMutability: "view";
97009
- readonly type: "function";
97010
- }, {
97011
- readonly inputs: readonly [];
97012
- readonly name: "owner";
97013
- readonly outputs: readonly [{
97014
- readonly internalType: "address";
97015
- readonly name: "";
97016
- readonly type: "address";
97017
- }];
97018
- readonly stateMutability: "view";
97019
- readonly type: "function";
97020
- }, {
97021
- readonly inputs: readonly [];
97022
- readonly name: "pendingRoot";
97023
- readonly outputs: readonly [{
97024
- readonly internalType: "bytes32";
97025
- readonly name: "root";
97026
- readonly type: "bytes32";
97027
- }, {
97028
- readonly internalType: "bytes32";
97029
- readonly name: "ipfsHash";
97030
- readonly type: "bytes32";
97031
- }, {
97032
- readonly internalType: "uint256";
97033
- readonly name: "validAt";
97034
- readonly type: "uint256";
97035
- }];
97036
- readonly stateMutability: "view";
97037
- readonly type: "function";
97038
- }, {
97039
- readonly inputs: readonly [];
97040
- readonly name: "revokePendingRoot";
97041
- readonly outputs: readonly [];
97042
- readonly stateMutability: "nonpayable";
97043
- readonly type: "function";
97044
- }, {
97045
- readonly inputs: readonly [];
97046
- readonly name: "root";
97047
- readonly outputs: readonly [{
97048
- readonly internalType: "bytes32";
97049
- readonly name: "";
97050
- readonly type: "bytes32";
97051
- }];
97052
- readonly stateMutability: "view";
97053
- readonly type: "function";
97054
- }, {
97055
- readonly inputs: readonly [{
97056
- readonly internalType: "address";
97057
- readonly name: "newOwner";
97058
- readonly type: "address";
97059
- }];
97060
- readonly name: "setOwner";
97061
- readonly outputs: readonly [];
97062
- readonly stateMutability: "nonpayable";
97063
- readonly type: "function";
97064
- }, {
97065
- readonly inputs: readonly [{
97066
- readonly internalType: "bytes32";
97067
- readonly name: "newRoot";
97068
- readonly type: "bytes32";
97069
- }, {
97070
- readonly internalType: "bytes32";
97071
- readonly name: "newIpfsHash";
97072
- readonly type: "bytes32";
97073
- }];
97074
- readonly name: "setRoot";
97075
- readonly outputs: readonly [];
97076
- readonly stateMutability: "nonpayable";
97077
- readonly type: "function";
97078
- }, {
97079
- readonly inputs: readonly [{
97080
- readonly internalType: "address";
97081
- readonly name: "updater";
97082
- readonly type: "address";
97083
- }, {
97084
- readonly internalType: "bool";
97085
- readonly name: "active";
97086
- readonly type: "bool";
97087
- }];
97088
- readonly name: "setRootUpdater";
97089
- readonly outputs: readonly [];
97090
- readonly stateMutability: "nonpayable";
97091
- readonly type: "function";
97092
- }, {
97093
- readonly inputs: readonly [{
97094
- readonly internalType: "uint256";
97095
- readonly name: "newTimelock";
97096
- readonly type: "uint256";
97097
- }];
97098
- readonly name: "setTimelock";
97099
- readonly outputs: readonly [];
97100
- readonly stateMutability: "nonpayable";
97101
- readonly type: "function";
97102
- }, {
97103
- readonly inputs: readonly [{
97104
- readonly internalType: "bytes32";
97105
- readonly name: "newRoot";
97106
- readonly type: "bytes32";
97107
- }, {
97108
- readonly internalType: "bytes32";
97109
- readonly name: "newIpfsHash";
97110
- readonly type: "bytes32";
97111
- }];
97112
- readonly name: "submitRoot";
97113
- readonly outputs: readonly [];
97114
- readonly stateMutability: "nonpayable";
97115
- readonly type: "function";
97116
- }, {
97117
- readonly inputs: readonly [];
97118
- readonly name: "timelock";
97119
- readonly outputs: readonly [{
97120
- readonly internalType: "uint256";
97121
- readonly name: "";
97122
- readonly type: "uint256";
97123
- }];
97124
- readonly stateMutability: "view";
97125
- readonly type: "function";
97126
- }];
97127
- readonly networks: {};
97128
- };
97129
96915
  export declare const AaveRewardsController: {
97130
96916
  readonly abi: readonly [{
97131
96917
  readonly inputs: readonly [{