@gearbox-protocol/periphery-v3 1.7.0-next.30 → 1.7.0-next.32
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.
|
@@ -22,9 +22,11 @@ import {TokenCompressor} from "./TokenCompressor.sol";
|
|
|
22
22
|
// // EXCEPTIONS
|
|
23
23
|
// import "@gearbox-protocol/core-v3/contracts/interfaces/IExceptions.sol";
|
|
24
24
|
|
|
25
|
+
import {BaseParams} from "../types/BaseState.sol";
|
|
25
26
|
import {MarketData, CreditManagerData} from "../types/MarketData.sol";
|
|
26
27
|
import {TokenData} from "../types/TokenData.sol";
|
|
27
28
|
import {PoolState} from "../types/PoolState.sol";
|
|
29
|
+
import {PriceOracleState} from "../types/PriceOracleState.sol";
|
|
28
30
|
|
|
29
31
|
import {IMarketCompressor} from "../interfaces/IMarketCompressor.sol";
|
|
30
32
|
|
|
@@ -66,38 +68,74 @@ contract MarketCompressor is IMarketCompressor {
|
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
70
|
|
|
71
|
+
function getUpdatablePriceFeeds(MarketFilter memory filter)
|
|
72
|
+
external
|
|
73
|
+
view
|
|
74
|
+
returns (BaseParams[] memory updatablePriceFeeds)
|
|
75
|
+
{
|
|
76
|
+
address[] memory pools = _getPools(filter);
|
|
77
|
+
uint256 numPools = pools.length;
|
|
78
|
+
PriceOracleState[] memory poStates = new PriceOracleState[](numPools);
|
|
79
|
+
uint256 numUpdatable;
|
|
80
|
+
for (uint256 i; i < numPools; ++i) {
|
|
81
|
+
address[] memory tokens = _getTokens(pools[i]);
|
|
82
|
+
address priceOracle = _getPriceOracle(poolCompressor.getPoolState(pools[i]));
|
|
83
|
+
poStates[i] = priceOracleCompressor.getPriceOracleState(priceOracle, tokens);
|
|
84
|
+
for (uint256 j; j < poStates[i].priceFeedStructure.length; ++j) {
|
|
85
|
+
if (poStates[i].priceFeedStructure[j].updatable) ++numUpdatable;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
updatablePriceFeeds = new BaseParams[](numUpdatable);
|
|
90
|
+
uint256 k;
|
|
91
|
+
for (uint256 i; i < numPools; ++i) {
|
|
92
|
+
for (uint256 j; j < poStates[i].priceFeedStructure.length; ++j) {
|
|
93
|
+
if (poStates[i].priceFeedStructure[j].updatable) {
|
|
94
|
+
updatablePriceFeeds[k++] = poStates[i].priceFeedStructure[j].baseParams;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
69
100
|
function getMarketData(address pool) public view returns (MarketData memory result) {
|
|
101
|
+
result.acl = IPoolV3(pool).acl();
|
|
70
102
|
result.pool = poolCompressor.getPoolState(pool);
|
|
71
103
|
result.poolQuotaKeeper = poolCompressor.getPoolQuotaKeeperState(result.pool.poolQuotaKeeper);
|
|
72
104
|
result.rateKeeper = poolCompressor.getRateKeeperState(result.poolQuotaKeeper.rateKeeper);
|
|
73
105
|
result.interestRateModel = poolCompressor.getInterestModelState(result.pool.interestRateModel);
|
|
74
106
|
|
|
75
|
-
address
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
address[] memory underlyingAndTokens = new address[](tokens.length + 1);
|
|
80
|
-
result.tokens[0] = tokenCompressor.getTokenInfo(result.pool.underlying);
|
|
81
|
-
underlyingAndTokens[0] = result.pool.underlying;
|
|
82
|
-
|
|
83
|
-
for (uint256 i = 0; i < tokens.length; i++) {
|
|
84
|
-
result.tokens[i + 1] = tokenCompressor.getTokenInfo(tokens[i]);
|
|
85
|
-
underlyingAndTokens[i + 1] = tokens[i];
|
|
107
|
+
address[] memory tokens = _getTokens(pool);
|
|
108
|
+
result.tokens = new TokenData[](tokens.length);
|
|
109
|
+
for (uint256 i; i < tokens.length; i++) {
|
|
110
|
+
result.tokens[i] = tokenCompressor.getTokenInfo(tokens[i]);
|
|
86
111
|
}
|
|
87
112
|
|
|
88
113
|
// creditManager
|
|
89
|
-
|
|
90
114
|
uint256 len = result.pool.creditManagerDebtParams.length;
|
|
91
115
|
result.creditManagers = new CreditManagerData[](len);
|
|
92
116
|
for (uint256 i = 0; i < len; i++) {
|
|
93
117
|
result.creditManagers[i] =
|
|
94
118
|
poolCompressor.getCreditManagerData(result.pool.creditManagerDebtParams[i].creditManager);
|
|
95
119
|
}
|
|
96
|
-
|
|
97
|
-
|
|
120
|
+
|
|
121
|
+
address priceOracle = _getPriceOracle(result.pool);
|
|
122
|
+
result.priceOracleData = priceOracleCompressor.getPriceOracleState(priceOracle, tokens);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function _getTokens(address pool) internal view returns (address[] memory tokens) {
|
|
126
|
+
// under proper configuration, equivalent to price oracle's `getTokens`
|
|
127
|
+
address quotaKeeper = IPoolV3(pool).poolQuotaKeeper();
|
|
128
|
+
address[] memory quotedTokens = IPoolQuotaKeeperV3(quotaKeeper).quotedTokens();
|
|
129
|
+
uint256 numTokens = quotedTokens.length;
|
|
130
|
+
tokens = new address[](numTokens + 1);
|
|
131
|
+
tokens[0] = IPoolV3(pool).asset();
|
|
132
|
+
for (uint256 i; i < numTokens; ++i) {
|
|
133
|
+
tokens[i + 1] = quotedTokens[i];
|
|
134
|
+
}
|
|
98
135
|
}
|
|
99
136
|
|
|
100
137
|
function _getPriceOracle(PoolState memory ps) internal view returns (address) {
|
|
138
|
+
// TODO: read from market configurator instead once structure is known
|
|
101
139
|
if (ps.creditManagerDebtParams.length == 0) {
|
|
102
140
|
return address(0);
|
|
103
141
|
}
|
|
@@ -69,7 +69,7 @@ contract PriceFeedCompressor is IPriceFeedCompressor {
|
|
|
69
69
|
contractTypes[uint8(PriceFeedType.CURVE_CRYPTO_ORACLE)] = "PF_CURVE_CRYPTO_LP_ORACLE";
|
|
70
70
|
contractTypes[uint8(PriceFeedType.CURVE_USD_ORACLE)] = "PF_CURVE_USD_ORACLE";
|
|
71
71
|
contractTypes[uint8(PriceFeedType.ERC4626_VAULT_ORACLE)] = "PF_ERC4626_ORACLE";
|
|
72
|
-
contractTypes[uint8(PriceFeedType.WRAPPED_AAVE_V2_ORACLE)] = "
|
|
72
|
+
contractTypes[uint8(PriceFeedType.WRAPPED_AAVE_V2_ORACLE)] = "NOT_USED";
|
|
73
73
|
contractTypes[uint8(PriceFeedType.WSTETH_ORACLE)] = "PF_WSTETH_ORACLE";
|
|
74
74
|
contractTypes[uint8(PriceFeedType.YEARN_ORACLE)] = "PF_YEARN_ORACLE";
|
|
75
75
|
contractTypes[uint8(PriceFeedType.MELLOW_LRT_ORACLE)] = "PF_MELLOW_LRT_ORACLE";
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// (c) Gearbox Holdings, 2024
|
|
4
4
|
pragma solidity ^0.8.10;
|
|
5
5
|
|
|
6
|
+
import {BaseParams} from "../types/BaseState.sol";
|
|
6
7
|
import {MarketData} from "../types/MarketData.sol";
|
|
7
8
|
import {PoolState} from "../types/PoolState.sol";
|
|
8
9
|
import {IVersion} from "@gearbox-protocol/core-v3/contracts/interfaces/base/IVersion.sol";
|
|
@@ -15,4 +16,9 @@ interface IMarketCompressor is IVersion {
|
|
|
15
16
|
function getMarketData(address pool) external view returns (MarketData memory result);
|
|
16
17
|
|
|
17
18
|
function getMarkets(MarketFilter memory filter) external view returns (MarketData[] memory result);
|
|
19
|
+
|
|
20
|
+
function getUpdatablePriceFeeds(MarketFilter memory filter)
|
|
21
|
+
external
|
|
22
|
+
view
|
|
23
|
+
returns (BaseParams[] memory updatablePriceFeeds);
|
|
18
24
|
}
|
package/package.json
CHANGED