morpho-contracts-helper 0.0.13 → 0.0.14

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.
@@ -9,6 +9,21 @@ struct MarketParams {
9
9
  uint256 lltv;
10
10
  }
11
11
 
12
+ interface IChainlinkAggregator {
13
+ function decimals() external view returns (uint8);
14
+
15
+ function latestRoundData()
16
+ external
17
+ view
18
+ returns (
19
+ uint80 roundId,
20
+ int256 answer,
21
+ uint256 startedAt,
22
+ uint256 updatedAt,
23
+ uint80 answeredInRound
24
+ );
25
+ }
26
+
12
27
  interface IERC20Metadata {
13
28
  function name() external view returns (string memory);
14
29
  function symbol() external view returns (string memory);
@@ -50,6 +65,13 @@ contract MorphoMarketDataFetcher {
50
65
  uint256 userAllowance;
51
66
  }
52
67
 
68
+ struct MockOracleInfo {
69
+ address oracleAddress;
70
+ uint256 price;
71
+ string symbol;
72
+ uint8 decimals;
73
+ }
74
+
53
75
  struct OracleInfo {
54
76
  address oracleAddress;
55
77
  address baseFeed1;
@@ -62,6 +84,8 @@ contract MorphoMarketDataFetcher {
62
84
  address quoteVaultConversionSample;
63
85
  uint256 scaleFactor;
64
86
  uint256 currentPrice;
87
+ MockOracleInfo baseFeed;
88
+ MockOracleInfo quoteFeed;
65
89
  }
66
90
 
67
91
  struct MarketData {
@@ -118,6 +142,32 @@ contract MorphoMarketDataFetcher {
118
142
  try IMorphoChainlinkOracleV2(oracle).SCALE_FACTOR() returns (uint256 s) { data.oracle.scaleFactor = s; } catch {}
119
143
  try IMorphoChainlinkOracleV2(oracle).price() returns (uint256 p) { data.oracle.currentPrice = p; } catch {}
120
144
  }
145
+
146
+ if (data.oracle.baseFeed1 != address(0)) {
147
+ data.oracle.baseFeed.oracleAddress = data.oracle.baseFeed1;
148
+
149
+ try IChainlinkAggregator(data.oracle.baseFeed1).latestRoundData() returns (
150
+ uint80, int256 answer, uint256, uint256, uint80
151
+ ) {
152
+ data.oracle.baseFeed.price = answer > 0 ? uint256(answer) : 0;
153
+ } catch {}
154
+
155
+ try IChainlinkAggregator(data.oracle.baseFeed1).decimals() returns (uint8 _dec) { data.oracle.baseFeed.decimals = _dec; } catch {}
156
+ try IERC20Metadata(data.oracle.baseFeed1).symbol() returns (string memory _sym) { data.oracle.baseFeed.symbol = _sym; } catch {}
157
+ }
158
+
159
+ if (data.oracle.quoteFeed1 != address(0)) {
160
+ data.oracle.quoteFeed.oracleAddress = data.oracle.quoteFeed1;
161
+
162
+ try IChainlinkAggregator(data.oracle.quoteFeed1).latestRoundData() returns (
163
+ uint80, int256 answer, uint256, uint256, uint80
164
+ ) {
165
+ data.oracle.quoteFeed.price = answer > 0 ? uint256(answer) : 0;
166
+ } catch {}
167
+
168
+ try IChainlinkAggregator(data.oracle.quoteFeed1).decimals() returns (uint8 _dec) { data.oracle.quoteFeed.decimals = _dec; } catch {}
169
+ try IERC20Metadata(data.oracle.quoteFeed1).symbol() returns (string memory _sym) { data.oracle.quoteFeed.symbol = _sym; } catch {}
170
+ }
121
171
 
122
172
  if (morphoAddress != address(0) && marketId != bytes32(0)) {
123
173
  address deadAddress = 0x000000000000000000000000000000000000dEaD;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "morpho-contracts-helper",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "description": "",
5
5
  "main": "dist/src/index",
6
6
  "types": "dist/src/index",