@@ -21,7 +21,7 @@ import {PriceFeedCompressor} from "./PriceFeedCompressor.sol";
2121// // EXCEPTIONS
2222// import "@gearbox-protocol/core-v3/contracts/interfaces/IExceptions.sol";
2323
24- import {MarketData} from "../types/MarketData.sol " ;
24+ import {MarketData, TokenInfo } from "../types/MarketData.sol " ;
2525import {PoolState} from "../types/PoolState.sol " ;
2626
2727import {IMarketCompressor} from "../interfaces/IMarketCompressor.sol " ;
@@ -50,10 +50,14 @@ contract MarketCompressor is IMarketCompressor {
5050 ADDRESS_PROVIDER = addressProvider;
5151 addressProvider = addressProvider;
5252 poolCompressor = new PoolCompressorV3 ();
53- priceOracleCompressor = PriceFeedCompressor (priceOracleCompressorAddress);
53+ priceOracleCompressor = PriceFeedCompressor (
54+ priceOracleCompressorAddress
55+ );
5456 }
5557
56- function getMarkets (MarketFilter memory filter ) external view returns (MarketData[] memory result ) {
58+ function getMarkets (
59+ MarketFilter memory filter
60+ ) external view returns (MarketData[] memory result ) {
5761 address [] memory pools = _getPools (filter);
5862 result = new MarketData [](pools.length );
5963
@@ -62,36 +66,59 @@ contract MarketCompressor is IMarketCompressor {
6266 }
6367 }
6468
65- function getMarketData (address pool ) public view returns (MarketData memory result ) {
69+ function getMarketData (
70+ address pool
71+ ) public view returns (MarketData memory result ) {
6672 result.pool = poolCompressor.getPoolState (pool);
67- result.poolQuotaKeeper = poolCompressor.getPoolQuotaKeeperState (result.pool.poolQuotaKeeper);
68- result.rateKeeper = poolCompressor.getRateKeeperState (result.poolQuotaKeeper.rateKeeper);
69- result.interestRateModel = poolCompressor.getInterestRateModelState (result.pool.interestRateModel);
73+ result.poolQuotaKeeper = poolCompressor.getPoolQuotaKeeperState (
74+ result.pool.poolQuotaKeeper
75+ );
76+ result.rateKeeper = poolCompressor.getRateKeeperState (
77+ result.poolQuotaKeeper.rateKeeper
78+ );
79+ result.interestRateModel = poolCompressor.getInterestModelState (
80+ result.pool.interestRateModel
81+ );
7082
7183 address priceOracle = _getPriceOracle (result.pool);
72- address [] memory tokens = IPoolQuotaKeeperV3 (result.pool.poolQuotaKeeper).quotedTokens ();
84+ address [] memory tokens = IPoolQuotaKeeperV3 (
85+ result.pool.poolQuotaKeeper
86+ ).quotedTokens ();
7387
74- result.tokens = new address [](tokens.length + 1 );
75- result.tokens[0 ] = result.pool.underlying;
88+ // TODO: add token data
89+ result.tokens = new TokenInfo [](tokens.length + 1 );
90+ // result.tokens[0] = tokenCompressor.getTokenInfo(result.pool.underlying);
7691
77- for (uint256 i = 0 ; i < tokens.length ; i++ ) {
78- result.tokens[i + 1 ] = tokens[i];
79- }
92+ // for (uint256 i = 0; i < tokens.length; i++) {
93+ // result.tokens[i + 1] = tokenCompressor.getTokenInfo( tokens[i]) ;
94+ // }
8095 // How to query if no credit mangers are deployed?
81- result.priceOracleData = priceOracleCompressor.getPriceOracleState (priceOracle, result.tokens);
96+ // //
97+ // TODO: add local address[]
98+ // result.priceOracleData = priceOracleCompressor.getPriceOracleState(
99+ // priceOracle,
100+ // result.tokens
101+ // );
82102 }
83103
84- function _getPriceOracle (PoolState memory ps ) internal view returns (address ) {
104+ function _getPriceOracle (
105+ PoolState memory ps
106+ ) internal view returns (address ) {
85107 if (ps.creditManagerDebtParams.length == 0 ) {
86108 return address (0 );
87109 }
88110
89- return ICreditManagerV3 (ps.creditManagerDebtParams[0 ].creditManager).priceOracle ();
111+ return
112+ ICreditManagerV3 (ps.creditManagerDebtParams[0 ].creditManager)
113+ .priceOracle ();
90114 }
91115
92116 /// @dev Pools discovery
93- function _getPools (MarketFilter memory filter ) internal view returns (address [] memory pools ) {
94- address [] memory configurators = IAddressProviderV3_1 (ADDRESS_PROVIDER).marketConfigurators ();
117+ function _getPools (
118+ MarketFilter memory filter
119+ ) internal view returns (address [] memory pools ) {
120+ address [] memory configurators = IAddressProviderV3_1 (ADDRESS_PROVIDER)
121+ .marketConfigurators ();
95122
96123 // rough estimate of maximum number of credit pools
97124 uint256 max;
@@ -106,18 +133,24 @@ contract MarketCompressor is IMarketCompressor {
106133
107134 for (uint256 i; i < configurators.length ; ++ i) {
108135 if (filter.curators.length != 0 ) {
109- if (! filter.curators.contains (IMarketConfiguratorV3 (configurators[i]).owner ())) continue ;
136+ if (
137+ ! filter.curators.contains (
138+ IMarketConfiguratorV3 (configurators[i]).owner ()
139+ )
140+ ) continue ;
110141 }
111142
112- address [] memory poolsMC = IMarketConfiguratorV3 (configurators[i]).pools ();
143+ address [] memory poolsMC = IMarketConfiguratorV3 (configurators[i])
144+ .pools ();
113145 for (uint256 j; j < poolsMC.length ; ++ j) {
114146 address currentPool = poolsMC[j];
115147 if (filter.pools.length != 0 ) {
116148 if (! filter.pools.contains (currentPool)) continue ;
117149 }
118150
119151 if (filter.underlying != address (0 )) {
120- if (IPoolV3 (currentPool).asset () != filter.underlying) continue ;
152+ if (IPoolV3 (currentPool).asset () != filter.underlying)
153+ continue ;
121154 }
122155
123156 pools[num++ ] = currentPool;
0 commit comments