@gearbox-protocol/periphery-v3 1.7.0-next.4 → 1.7.0-next.5
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.
|
@@ -30,7 +30,7 @@ interface ImplementsPriceFeedType {
|
|
|
30
30
|
/// - it does not implement `getTokens`
|
|
31
31
|
/// - it only allows to fetch staleness period of a currently active price feed
|
|
32
32
|
interface IPriceOracleV3Legacy {
|
|
33
|
-
/// @dev Older signature for fetching main and reserve feeds
|
|
33
|
+
/// @dev Older signature for fetching main and reserve feeds, reverts if price feed is not set
|
|
34
34
|
function priceFeedsRaw(address token, bool reserve) external view returns (address);
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -90,9 +90,6 @@ contract PriceFeedCompressor is IVersion, Ownable {
|
|
|
90
90
|
/// - `priceFeedTree` is a set of nodes in a tree-like structure that contains detailed info of both feeds
|
|
91
91
|
/// from `priceFeedMap` and their underlying feeds, in case former are nested, which can help to determine
|
|
92
92
|
/// what underlying feeds should be updated to query the nested one.
|
|
93
|
-
/// @dev `priceFeedTree` can have duplicate entries since a price feed can both be in `priceFeedMap` for one or
|
|
94
|
-
/// more (token, reserve) pairs, and serve as an underlying feed in one or more nested feeds.
|
|
95
|
-
/// If there are two identical nodes in the tree, then subtrees of these nodes are also identical.
|
|
96
93
|
function getPriceFeeds(address priceOracle)
|
|
97
94
|
external
|
|
98
95
|
view
|
|
@@ -138,6 +135,10 @@ contract PriceFeedCompressor is IVersion, Ownable {
|
|
|
138
135
|
for (uint256 i; i < priceFeedMapSize; ++i) {
|
|
139
136
|
offset = _loadPriceFeedTree(priceFeedMap[i].priceFeed, priceFeedTree, offset);
|
|
140
137
|
}
|
|
138
|
+
// trim array to its actual size in case there were duplicates
|
|
139
|
+
assembly {
|
|
140
|
+
mstore(priceFeedTree, offset)
|
|
141
|
+
}
|
|
141
142
|
}
|
|
142
143
|
|
|
143
144
|
// --------- //
|
|
@@ -155,9 +156,12 @@ contract PriceFeedCompressor is IVersion, Ownable {
|
|
|
155
156
|
/// @dev Returns `token`'s price feed in the price oracle
|
|
156
157
|
function _getPriceFeed(address priceOracle, address token, bool reserve) internal view returns (address, uint32) {
|
|
157
158
|
if (IPriceOracleV3(priceOracle).version() < 3_10) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
159
|
+
try IPriceOracleV3Legacy(priceOracle).priceFeedsRaw(token, reserve) returns (address priceFeed) {
|
|
160
|
+
// legacy oracle does not allow to fetch staleness period of a non-active feed
|
|
161
|
+
return (priceFeed, 0);
|
|
162
|
+
} catch {
|
|
163
|
+
return (address(0), 0);
|
|
164
|
+
}
|
|
161
165
|
}
|
|
162
166
|
PriceFeedParams memory params = reserve
|
|
163
167
|
? IPriceOracleV3(priceOracle).reservePriceFeedParams(token)
|
|
@@ -180,6 +184,12 @@ contract PriceFeedCompressor is IVersion, Ownable {
|
|
|
180
184
|
view
|
|
181
185
|
returns (uint256)
|
|
182
186
|
{
|
|
187
|
+
// duplicates are possible since price feed can be in `priceFeedMap` for more than one (token, reserve) pair
|
|
188
|
+
// or serve as an underlying in more than one nested feed, and the whole subtree can be skipped in this case
|
|
189
|
+
for (uint256 i; i < offset; ++i) {
|
|
190
|
+
if (priceFeedTree[i].priceFeed == priceFeed) return offset;
|
|
191
|
+
}
|
|
192
|
+
|
|
183
193
|
PriceFeedTreeNode memory node = _getPriceFeedTreeNode(priceFeed);
|
|
184
194
|
priceFeedTree[offset++] = node;
|
|
185
195
|
for (uint256 i; i < node.underlyingFeeds.length; ++i) {
|
package/package.json
CHANGED