@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
@@ -41,6 +41,9 @@ const fetchHubData = (viewContract, hubAddress) => __awaiter(void 0, void 0, voi
41
41
  const formatReserveAsset = (reserveAsset, hubAsset, reserveId, oracleDecimals, network) => __awaiter(void 0, void 0, void 0, function* () {
42
42
  var _a, _b, _c, _d, _e, _f;
43
43
  const assetInfo = getAssetInfoByAddress(reserveAsset.underlying, network);
44
+ // `@defisaver/tokens` returns a placeholder ('?', decimals NaN) when the underlying is not in the
45
+ // tokens package. Flag it so consumers can render it read-only instead of feeding NaN into amounts.
46
+ const isUnsupported = assetInfo.symbol === '?';
44
47
  const symbol = wethToEth(assetInfo.symbol);
45
48
  const hubInfo = getAaveV4HubByAddress(network, reserveAsset.hub);
46
49
  if (!hubInfo) {
@@ -87,10 +90,23 @@ const formatReserveAsset = (reserveAsset, hubAsset, reserveId, oracleDecimals, n
87
90
  const premiumMultiplier = totalDrawnShares.isZero() ? new Dec(1) : totalDrawnShares.add(totalPremiumShares).div(totalDrawnShares);
88
91
  const supplyApr = borrowApr.mul(hubUtilization).mul(premiumMultiplier).mul(new Dec(1).minus(liquidityFee));
89
92
  const utilization = hubUtilization.times(100).toString();
93
+ // For unsupported assets `symbol` is '?' (decimals NaN in `@defisaver/tokens`), so the
94
+ // symbol-based conversion would produce NaN. Fall back to the on-chain `decimals` so the reserve
95
+ // still shows correct amounts (and feeds correct USD/ratio/liquidation math) in read-only mode.
96
+ const toEth = (raw) => {
97
+ const rawStr = raw.toString();
98
+ if (isMaxUint(rawStr))
99
+ return rawStr;
100
+ if (isUnsupported)
101
+ return new Dec(rawStr || 0).div(new Dec(10).pow(reserveAsset.decimals)).toString();
102
+ return assetAmountInEth(rawStr, symbol);
103
+ };
90
104
  const hubLiquidityRaw = hubAsset.liquidity;
91
- const hubLiquidity = isMaxUint(hubLiquidityRaw.toString()) ? hubLiquidityRaw.toString() : assetAmountInEth(hubLiquidityRaw.toString(), symbol);
105
+ const hubLiquidity = toEth(hubLiquidityRaw.toString());
92
106
  return ({
93
107
  symbol,
108
+ decimals: reserveAsset.decimals,
109
+ isUnsupported,
94
110
  underlying: reserveAsset.underlying,
95
111
  hub: hubInfo.address,
96
112
  hubName: hubInfo === null || hubInfo === void 0 ? void 0 : hubInfo.label,
@@ -104,12 +120,12 @@ const formatReserveAsset = (reserveAsset, hubAsset, reserveId, oracleDecimals, n
104
120
  liquidationFee: new Dec(reserveAsset.liquidationFee).div(10000).toNumber(),
105
121
  maxLiquidationBonus: new Dec(reserveAsset.maxLiquidationBonus).div(10000).toNumber(),
106
122
  price: new Dec(reserveAsset.price).div(new Dec(10).pow(oracleDecimals)).toString(),
107
- totalSupplied: isMaxUint(totalSuppliedRaw.toString()) ? totalSuppliedRaw.toString() : assetAmountInEth(totalSuppliedRaw.toString(), symbol),
108
- totalDrawn: isMaxUint(totalDrawnRaw.toString()) ? totalDrawnRaw.toString() : assetAmountInEth(totalDrawnRaw.toString(), symbol),
109
- totalPremium: isMaxUint(totalPremiumRaw.toString()) ? totalPremiumRaw.toString() : assetAmountInEth(totalPremiumRaw.toString(), symbol),
110
- totalDebt: isMaxUint(totalDebtRaw.toString()) ? totalDebtRaw.toString() : assetAmountInEth(totalDebtRaw.toString(), symbol),
111
- supplyCap: isMaxUint(supplyCapRaw.toString()) ? supplyCapRaw.toString() : assetAmountInEth(supplyCapRaw.toString(), symbol),
112
- borrowCap: isMaxUint(borrowCapRaw.toString()) ? borrowCapRaw.toString() : assetAmountInEth(borrowCapRaw.toString(), symbol),
123
+ totalSupplied: toEth(totalSuppliedRaw.toString()),
124
+ totalDrawn: toEth(totalDrawnRaw.toString()),
125
+ totalPremium: toEth(totalPremiumRaw.toString()),
126
+ totalDebt: toEth(totalDebtRaw.toString()),
127
+ supplyCap: toEth(supplyCapRaw.toString()),
128
+ borrowCap: toEth(borrowCapRaw.toString()),
113
129
  spokeActive: reserveAsset.spokeActive,
114
130
  spokeHalted: reserveAsset.spokeHalted,
115
131
  drawnRate: drawnRate.toString(),
@@ -117,10 +133,10 @@ const formatReserveAsset = (reserveAsset, hubAsset, reserveId, oracleDecimals, n
117
133
  supplyRate: aprToApy(supplyApr.toString()),
118
134
  supplyIncentives,
119
135
  borrowIncentives,
120
- canBeBorrowed: reserveAsset.spokeActive && !reserveAsset.spokeHalted && !reserveAsset.paused && !reserveAsset.frozen && reserveAsset.borrowable,
121
- canBeSupplied: reserveAsset.spokeActive && !reserveAsset.spokeHalted && !reserveAsset.paused && !reserveAsset.frozen,
122
- canBeWithdrawn: reserveAsset.spokeActive && !reserveAsset.spokeHalted && !reserveAsset.paused,
123
- canBePayBacked: reserveAsset.spokeActive && !reserveAsset.spokeHalted && !reserveAsset.paused,
136
+ canBeBorrowed: !isUnsupported && reserveAsset.spokeActive && !reserveAsset.spokeHalted && !reserveAsset.paused && !reserveAsset.frozen && reserveAsset.borrowable,
137
+ canBeSupplied: !isUnsupported && reserveAsset.spokeActive && !reserveAsset.spokeHalted && !reserveAsset.paused && !reserveAsset.frozen,
138
+ canBeWithdrawn: !isUnsupported && reserveAsset.spokeActive && !reserveAsset.spokeHalted && !reserveAsset.paused,
139
+ canBePayBacked: !isUnsupported && reserveAsset.spokeActive && !reserveAsset.spokeHalted && !reserveAsset.paused,
124
140
  utilization,
125
141
  hubLiquidity,
126
142
  premiumMultiplier: premiumMultiplier.toString(),
@@ -163,17 +179,33 @@ export function _getAaveV4AccountData(provider_1, network_1, spokeData_1, addres
163
179
  const healthFactorFromContract = new Dec(loanData.healthFactor.toString());
164
180
  const healthFactor = isMaxUint(healthFactorFromContract.toString()) ? 'Infinity' : healthFactorFromContract.div(1e18).toString();
165
181
  const usedAssets = loanData.reserves.reduce((acc, usedReserveAsset) => {
166
- const identifier = `${wethToEth(getAssetInfoByAddress(usedReserveAsset.underlying, network).symbol)}-${+usedReserveAsset.reserveId.toString()}`;
182
+ var _a, _b, _c, _d;
183
+ const assetInfo = getAssetInfoByAddress(usedReserveAsset.underlying, network);
184
+ const isUnsupported = assetInfo.symbol === '?';
185
+ const symbol = wethToEth(assetInfo.symbol);
186
+ const identifier = `${symbol}-${+usedReserveAsset.reserveId.toString()}`;
167
187
  const reserveData = spokeData.assetsData[identifier];
168
- const price = reserveData.price;
169
- const supplied = isMaxUint(usedReserveAsset.supplied.toString()) ? usedReserveAsset.supplied.toString() : assetAmountInEth(usedReserveAsset.supplied.toString(), reserveData.symbol);
170
- const drawn = isMaxUint(usedReserveAsset.drawn.toString()) ? usedReserveAsset.drawn.toString() : assetAmountInEth(usedReserveAsset.drawn.toString(), reserveData.symbol);
171
- const premium = isMaxUint(usedReserveAsset.premium.toString()) ? usedReserveAsset.premium.toString() : assetAmountInEth(usedReserveAsset.premium.toString(), reserveData.symbol);
172
- const borrowed = isMaxUint(usedReserveAsset.totalDebt.toString()) ? usedReserveAsset.totalDebt.toString() : assetAmountInEth(usedReserveAsset.totalDebt.toString(), reserveData.symbol);
188
+ const price = (_a = reserveData === null || reserveData === void 0 ? void 0 : reserveData.price) !== null && _a !== void 0 ? _a : '0';
189
+ // For unsupported assets the symbol-based conversion yields NaN, so use the on-chain decimals
190
+ // from the reserve data instead. If the reserve is missing entirely we can't convert, so fall
191
+ // back to '0' and keep the entry read-only.
192
+ const toEth = (raw) => {
193
+ if (isMaxUint(raw))
194
+ return raw;
195
+ if (!reserveData)
196
+ return '0';
197
+ if (isUnsupported)
198
+ return new Dec(raw || 0).div(new Dec(10).pow(reserveData.decimals)).toString();
199
+ return assetAmountInEth(raw, reserveData.symbol);
200
+ };
201
+ const supplied = toEth(usedReserveAsset.supplied.toString());
202
+ const drawn = toEth(usedReserveAsset.drawn.toString());
203
+ const premium = toEth(usedReserveAsset.premium.toString());
204
+ const borrowed = toEth(usedReserveAsset.totalDebt.toString());
173
205
  acc[identifier] = {
174
- symbol: reserveData.symbol,
175
- hubName: reserveData.hubName,
176
- assetId: reserveData.assetId,
206
+ symbol: (_b = reserveData === null || reserveData === void 0 ? void 0 : reserveData.symbol) !== null && _b !== void 0 ? _b : symbol,
207
+ hubName: (_c = reserveData === null || reserveData === void 0 ? void 0 : reserveData.hubName) !== null && _c !== void 0 ? _c : '',
208
+ assetId: (_d = reserveData === null || reserveData === void 0 ? void 0 : reserveData.assetId) !== null && _d !== void 0 ? _d : 0,
177
209
  reserveId: +usedReserveAsset.reserveId.toString(),
178
210
  supplied,
179
211
  suppliedUsd: new Dec(supplied).mul(price).toString(),
@@ -187,6 +219,7 @@ export function _getAaveV4AccountData(provider_1, network_1, spokeData_1, addres
187
219
  isBorrowed: usedReserveAsset.isBorrowing,
188
220
  collateral: usedReserveAsset.isUsingAsCollateral,
189
221
  collateralFactor: new Dec(usedReserveAsset.collateralFactor).div(10000).toNumber(),
222
+ isUnsupported: isUnsupported || !reserveData,
190
223
  };
191
224
  return acc;
192
225
  }, {});
@@ -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[]>;
@@ -88,8 +88,8 @@ export function getUnclaimedRewardsForAllMarkets(provider, network, walletAddres
88
88
  return mapAaveRewardsToClaimableTokens(Object.values(totalUnclaimedPerRewardToken), marketAddress, walletAddress);
89
89
  });
90
90
  }
91
- export function getMeritUnclaimedRewards(account_1, network_1) {
92
- return __awaiter(this, arguments, void 0, function* (account, network, acceptMorpho = true) {
91
+ export function getMeritUnclaimedRewards(account, network) {
92
+ return __awaiter(this, void 0, void 0, function* () {
93
93
  let data;
94
94
  try {
95
95
  const res = yield fetch(`https://api-merkl.angle.money/v4/users/${account}/rewards?chainId=${network}`, { signal: AbortSignal.timeout(3000) });
@@ -103,8 +103,7 @@ export function getMeritUnclaimedRewards(account_1, network_1) {
103
103
  data.forEach((item) => {
104
104
  item.rewards.forEach(reward => {
105
105
  const { token, amount, claimed, proofs, } = reward;
106
- const isTokenMorpho = token.symbol === 'MORPHO';
107
- if (!token || !token.symbol || amount === '0' || (isTokenMorpho && !acceptMorpho))
106
+ if (!token || !token.symbol || amount === '0')
108
107
  return;
109
108
  const unclaimedAmount = new Dec(amount).minus(claimed || 0).toString();
110
109
  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, };
@@ -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, };
@@ -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 [{
@@ -1262,10 +1262,6 @@ export const SparkRewardsController = {
1262
1262
  }
1263
1263
  }
1264
1264
  };
1265
- export const MorphoDistributor = {
1266
- "abi": [{ "inputs": [{ "internalType": "address", "name": "initialOwner", "type": "address" }, { "internalType": "uint256", "name": "initialTimelock", "type": "uint256" }, { "internalType": "bytes32", "name": "initialRoot", "type": "bytes32" }, { "internalType": "bytes32", "name": "initialIpfsHash", "type": "bytes32" }], "stateMutability": "nonpayable", "type": "constructor" }, { "inputs": [], "name": "acceptRoot", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "account", "type": "address" }, { "internalType": "address", "name": "reward", "type": "address" }, { "internalType": "uint256", "name": "claimable", "type": "uint256" }, { "internalType": "bytes32[]", "name": "proof", "type": "bytes32[]" }], "name": "claim", "outputs": [{ "internalType": "uint256", "name": "amount", "type": "uint256" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "account", "type": "address" }, { "internalType": "address", "name": "reward", "type": "address" }], "name": "claimed", "outputs": [{ "internalType": "uint256", "name": "amount", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "ipfsHash", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "", "type": "address" }], "name": "isUpdater", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "owner", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "pendingRoot", "outputs": [{ "internalType": "bytes32", "name": "root", "type": "bytes32" }, { "internalType": "bytes32", "name": "ipfsHash", "type": "bytes32" }, { "internalType": "uint256", "name": "validAt", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "revokePendingRoot", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "root", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }], "name": "setOwner", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "newRoot", "type": "bytes32" }, { "internalType": "bytes32", "name": "newIpfsHash", "type": "bytes32" }], "name": "setRoot", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "updater", "type": "address" }, { "internalType": "bool", "name": "active", "type": "bool" }], "name": "setRootUpdater", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "newTimelock", "type": "uint256" }], "name": "setTimelock", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "newRoot", "type": "bytes32" }, { "internalType": "bytes32", "name": "newIpfsHash", "type": "bytes32" }], "name": "submitRoot", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "timelock", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }],
1267
- "networks": {}
1268
- };
1269
1265
  export const AaveRewardsController = {
1270
1266
  "abi": [{ "inputs": [{ "internalType": "address[]", "name": "assets", "type": "address[]" }, { "internalType": "address", "name": "user", "type": "address" }], "name": "getAllUserRewards", "outputs": [{ "internalType": "address[]", "name": "rewardsList", "type": "address[]" }, { "internalType": "uint256[]", "name": "unclaimedAmounts", "type": "uint256[]" }], "stateMutability": "view", "type": "function" }],
1271
1267
  "networks": {
@@ -56,4 +56,3 @@ export declare const getRewardsForMarket: (marketId: string, network?: NetworkNu
56
56
  supplyApy: string;
57
57
  borrowApy: string;
58
58
  }>;
59
- export declare const getMorphoUnderlyingSymbol: (_symbol: string) => string;
@@ -14,7 +14,7 @@ import { calculateNetApy } from '../../staking';
14
14
  import { LeverageType, NetworkNumber, } from '../../types/common';
15
15
  import { borrowOperations, SECONDS_PER_YEAR, WAD } from '../../constants';
16
16
  import { MorphoBlueViewContractViem } from '../../contracts';
17
- import { compareAddresses, LONGER_TIMEOUT, wethToEth } from '../../services/utils';
17
+ import { compareAddresses, LONGER_TIMEOUT } from '../../services/utils';
18
18
  import { getViemProvider } from '../../services/viem';
19
19
  export const getMorphoBlueAggregatedPositionData = ({ usedAssets, assetsData, marketInfo }) => {
20
20
  var _a, _b, _c, _d, _e, _f;
@@ -128,12 +128,13 @@ export const getApyAfterValuesEstimation = (selectedMarket, actions, provider, n
128
128
  const supplyRate = getSupplyRate(data[1].totalSupplyAssets.toString(), data[1].totalBorrowAssets.toString(), data[0].toString(), data[1].fee.toString());
129
129
  return { borrowRate, supplyRate };
130
130
  });
131
- const API_URL = 'https://blue-api.morpho.org/graphql';
131
+ const API_URL = 'https://api.morpho.org/graphql';
132
+ // Morpho Blue ACRM (Adaptive Curve IRM) always targets 90% utilization — protocol constant
133
+ const ACRM_TARGET_UTILIZATION = '900000000000000000';
132
134
  const MARKET_QUERY = `
133
- query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
134
- marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
135
+ query MarketByUniqueKey($marketId: String!, $chainId: Int!) {
136
+ marketById(marketId: $marketId, chainId: $chainId) {
135
137
  reallocatableLiquidityAssets
136
- targetBorrowUtilization
137
138
  loanAsset {
138
139
  address
139
140
  decimals
@@ -150,8 +151,8 @@ const MARKET_QUERY = `
150
151
  address
151
152
  name
152
153
  }
153
- allocationMarket {
154
- uniqueKey
154
+ withdrawMarket {
155
+ marketId
155
156
  loanAsset {
156
157
  address
157
158
  }
@@ -175,14 +176,14 @@ const MARKET_QUERY = `
175
176
  address
176
177
  }
177
178
  irmAddress
178
- lltv
179
+ lltv
179
180
  }
180
181
  }
181
182
  `;
182
183
  const REWARDS_QUERY = `
183
- query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
184
- marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
185
- uniqueKey
184
+ query MarketByUniqueKey($marketId: String!, $chainId: Int!) {
185
+ marketById(marketId: $marketId, chainId: $chainId) {
186
+ marketId
186
187
  state {
187
188
  rewards {
188
189
  amountPerSuppliedToken
@@ -211,17 +212,17 @@ export const getReallocatableLiquidity = (marketId_1, ...args_1) => __awaiter(vo
211
212
  headers: { 'Content-Type': 'application/json' },
212
213
  body: JSON.stringify({
213
214
  query: MARKET_QUERY,
214
- variables: { uniqueKey: marketId, chainId: network },
215
+ variables: { marketId, chainId: network },
215
216
  }),
216
217
  signal: AbortSignal.timeout(LONGER_TIMEOUT),
217
218
  });
218
219
  const data = yield response.json();
219
- const marketData = (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.marketByUniqueKey;
220
+ const marketData = (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.marketById;
220
221
  if (!marketData)
221
222
  throw new Error('Market data not found');
222
223
  return {
223
224
  reallocatableLiquidity: marketData.reallocatableLiquidityAssets,
224
- targetBorrowUtilization: marketData.targetBorrowUtilization,
225
+ targetBorrowUtilization: ACRM_TARGET_UTILIZATION,
225
226
  };
226
227
  }
227
228
  catch (error) {
@@ -273,12 +274,12 @@ export const getReallocation = (market_1, assetsData_1, amountToBorrow_1, ...arg
273
274
  headers: { 'Content-Type': 'application/json' },
274
275
  body: JSON.stringify({
275
276
  query: MARKET_QUERY,
276
- variables: { uniqueKey: marketId, chainId: network },
277
+ variables: { marketId, chainId: network },
277
278
  }),
278
279
  signal: AbortSignal.timeout(LONGER_TIMEOUT),
279
280
  });
280
281
  const data = yield response.json();
281
- const marketData = (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.marketByUniqueKey;
282
+ const marketData = (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.marketById;
282
283
  if (!marketData)
283
284
  throw new Error('Market data not found');
284
285
  const loanAssetInfo = getAssetInfoByAddress(loanToken, network);
@@ -288,9 +289,9 @@ export const getReallocation = (market_1, assetsData_1, amountToBorrow_1, ...arg
288
289
  const newTotalBorrowAssets = new Dec(totalBorrowWei).add(amountToBorrow).toString();
289
290
  const newUtil = new Dec(newTotalBorrowAssets).div(totalSupplyWei).toString();
290
291
  const newUtilScaled = new Dec(newUtil).mul(1e18).toString();
291
- if (new Dec(newUtilScaled).lt(marketData.targetBorrowUtilization))
292
+ if (new Dec(newUtilScaled).lt(ACRM_TARGET_UTILIZATION))
292
293
  return { vaults: [], withdrawals: [] };
293
- const liquidityToAllocate = getLiquidityToAllocate(amountToBorrow, totalBorrowWei, totalSupplyWei, marketData.targetBorrowUtilization, marketData.reallocatableLiquidityAssets);
294
+ const liquidityToAllocate = getLiquidityToAllocate(amountToBorrow, totalBorrowWei, totalSupplyWei, ACRM_TARGET_UTILIZATION, marketData.reallocatableLiquidityAssets);
294
295
  const vaultTotalAssets = marketData.publicAllocatorSharedLiquidity.reduce((acc, item) => {
295
296
  const vaultAddress = item.vault.address;
296
297
  acc[vaultAddress] = new Dec(acc[vaultAddress] || '0').add(item.assets).toString();
@@ -312,14 +313,14 @@ export const getReallocation = (market_1, assetsData_1, amountToBorrow_1, ...arg
312
313
  totalReallocated = new Dec(totalReallocated).add(amountToTake).toString();
313
314
  const withdrawal = [
314
315
  [
315
- item.allocationMarket.loanAsset.address,
316
- (_b = item.allocationMarket.collateralAsset) === null || _b === void 0 ? void 0 : _b.address,
317
- (_c = item.allocationMarket.oracle) === null || _c === void 0 ? void 0 : _c.address,
318
- item.allocationMarket.irmAddress,
319
- item.allocationMarket.lltv,
316
+ item.withdrawMarket.loanAsset.address,
317
+ (_b = item.withdrawMarket.collateralAsset) === null || _b === void 0 ? void 0 : _b.address,
318
+ (_c = item.withdrawMarket.oracle) === null || _c === void 0 ? void 0 : _c.address,
319
+ item.withdrawMarket.irmAddress,
320
+ item.withdrawMarket.lltv,
320
321
  ],
321
322
  amountToTake.toString(),
322
- item.allocationMarket.uniqueKey,
323
+ item.withdrawMarket.marketId,
323
324
  ];
324
325
  if (!withdrawalsPerVault[vaultAddress]) {
325
326
  withdrawalsPerVault[vaultAddress] = [];
@@ -346,11 +347,11 @@ export const getRewardsForMarket = (marketId_1, ...args_1) => __awaiter(void 0,
346
347
  headers: { 'Content-Type': 'application/json' },
347
348
  body: JSON.stringify({
348
349
  query: REWARDS_QUERY,
349
- variables: { uniqueKey: marketId, chainId: network },
350
+ variables: { marketId, chainId: network },
350
351
  }),
351
352
  });
352
353
  const data = yield response.json();
353
- const marketData = (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.marketByUniqueKey;
354
+ const marketData = (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.marketById;
354
355
  if (!marketData)
355
356
  throw new Error('Market data not found');
356
357
  const morphoAssetInfo = getAssetInfo('MORPHO');
@@ -359,8 +360,3 @@ export const getRewardsForMarket = (marketId_1, ...args_1) => __awaiter(void 0,
359
360
  const borrowAprPercent = new Dec(borrowApr).mul(100).toString();
360
361
  return { supplyApy: aprToApy(supplyAprPercent), borrowApy: aprToApy(borrowAprPercent) };
361
362
  });
362
- export const getMorphoUnderlyingSymbol = (_symbol) => {
363
- if (_symbol === 'MORPHO Legacy')
364
- return 'MORPHO';
365
- return wethToEth(_symbol);
366
- };
@@ -31,7 +31,6 @@ import { getUmbrellaData } from '../umbrella';
31
31
  import { getMeritUnclaimedRewards, getUnclaimedRewardsForAllMarkets } from '../claiming/aaveV3';
32
32
  import { getCompoundV3Rewards } from '../claiming/compV3';
33
33
  import { fetchSparkAirdropRewards, fetchSparkRewards } from '../claiming/spark';
34
- import { fetchMorphoBlueRewards } from '../claiming/morphoBlue';
35
34
  import { getKingRewards } from '../claiming/king';
36
35
  import { fetchEthenaAirdropRewards } from '../claiming/ethena';
37
36
  import { _getAaveV4AccountData, _getAaveV4SpokeData } from '../aaveV4';
@@ -39,7 +38,6 @@ export function getPortfolioData(provider_1, network_1, defaultProvider_1, addre
39
38
  return __awaiter(this, arguments, void 0, function* (provider, network, defaultProvider, addresses, isSim = false) {
40
39
  const isMainnet = network === NetworkNumber.Eth;
41
40
  const isFluidSupported = [NetworkNumber.Eth, NetworkNumber.Arb, NetworkNumber.Base, NetworkNumber.Plasma].includes(network);
42
- const isMorphoRewardsSupported = [NetworkNumber.Eth, NetworkNumber.Base].includes(network);
43
41
  const morphoMarkets = Object.values(MorphoBlueMarkets(network)).filter((market) => market.chainIds.includes(network));
44
42
  const compoundV3Markets = Object.values(CompoundMarkets(network)).filter((market) => market.chainIds.includes(network) && market.value !== CompoundVersions.CompoundV2);
45
43
  const sparkMarkets = Object.values(SparkMarkets(network)).filter((market) => market.chainIds.includes(network));
@@ -127,7 +125,6 @@ export function getPortfolioData(provider_1, network_1, defaultProvider_1, addre
127
125
  spark: {},
128
126
  spk: {},
129
127
  king: {},
130
- morpho: {},
131
128
  ethena: {},
132
129
  };
133
130
  }
@@ -337,30 +334,6 @@ export function getPortfolioData(provider_1, network_1, defaultProvider_1, addre
337
334
  rewardsData[address.toLowerCase()].aaveV3 = { error: `Error fetching Aave V3 rewards data for address ${address}`, data: null };
338
335
  }
339
336
  }))).flat(),
340
- // Batch Morpho Blue rewards
341
- (() => __awaiter(this, void 0, void 0, function* () {
342
- if (!isMorphoRewardsSupported)
343
- return;
344
- try {
345
- const morphoRewards = yield fetchMorphoBlueRewards(client, network, addresses);
346
- for (const address of addresses) {
347
- const lowerAddress = address.toLowerCase();
348
- rewardsData[lowerAddress].morpho = {
349
- error: '',
350
- data: morphoRewards[lowerAddress] || [],
351
- };
352
- }
353
- }
354
- catch (error) {
355
- console.error('Error fetching Morpho Blue rewards data in batch:', error);
356
- for (const address of addresses) {
357
- rewardsData[address.toLowerCase()].morpho = {
358
- error: 'Error fetching Morpho Blue rewards data in batch',
359
- data: null,
360
- };
361
- }
362
- }
363
- }))(),
364
337
  // Batch Spark Airdrop rewards
365
338
  (() => __awaiter(this, void 0, void 0, function* () {
366
339
  try {
@@ -74,6 +74,8 @@ export interface AaveV4ReserveAssetOnChain {
74
74
  }
75
75
  export interface AaveV4ReserveAssetData {
76
76
  symbol: string;
77
+ /** Underlying token decimals as reported on-chain (independent of `@defisaver/tokens`). */
78
+ decimals: number;
77
79
  underlying: EthAddress;
78
80
  hub: EthAddress;
79
81
  hubName: string;
@@ -119,6 +121,11 @@ export interface AaveV4ReserveAssetData {
119
121
  hubLiquidity: string;
120
122
  premiumMultiplier: string;
121
123
  liquidityFee: string;
124
+ /**
125
+ * True when the underlying token is missing from `@defisaver/tokens` (placeholder `?` asset).
126
+ * The reserve is kept for read-only display, but amounts are zeroed and all actions are disabled.
127
+ */
128
+ isUnsupported?: boolean;
122
129
  }
123
130
  export type AaveV4AssetsData = Record<string, AaveV4ReserveAssetData>;
124
131
  export interface AaveV4UsedReserveAsset {
@@ -138,6 +145,8 @@ export interface AaveV4UsedReserveAsset {
138
145
  isBorrowed: boolean;
139
146
  collateral: boolean;
140
147
  collateralFactor: number;
148
+ /** True when the underlying token is missing from `@defisaver/tokens` (placeholder `?` asset). */
149
+ isUnsupported?: boolean;
141
150
  }
142
151
  export interface AaveV4AggregatedPositionData {
143
152
  suppliedUsd: string;