@@ -567,16 +567,6 @@ contract ChainlinkOEVWrapperIntegrationTest is
567567 for (uint256 i = 0 ; i < wrappers.length ; i++ ) {
568568 ChainlinkOEVWrapper wrapper = wrappers[i];
569569
570- if (
571- keccak256 (abi.encodePacked (oracleConfigs[i].symbol)) ==
572- keccak256 (abi.encodePacked ("cbETH " ))
573- ) {
574- console2.log (
575- "Skipping cbETH wrapper due to borrow liquidity issues "
576- );
577- continue ;
578- }
579-
580570 // Get the collateral mToken
581571 string memory mTokenKey = string (
582572 abi.encodePacked ("MOONWELL_ " , oracleConfigs[i].symbol)
@@ -653,25 +643,20 @@ contract ChainlinkOEVWrapperIntegrationTest is
653643 ChainlinkOEVWrapper wrapper ,
654644 address mTokenCollateralAddr
655645 ) internal view returns (uint256 collateralAmount , uint256 borrowAmount ) {
656- (, int256 currentPrice , , , ) = wrapper.latestRoundData ();
657- require (currentPrice > 0 , "invalid price " );
658-
659- address underlying = MErc20 (mTokenCollateralAddr).underlying ();
660- (bool success , bytes memory data ) = underlying.staticcall (
661- abi.encodeWithSignature ("decimals() " )
646+ // Use oracle's getUnderlyingPrice which normalizes all prices to USD
647+ ChainlinkOracle oracle = ChainlinkOracle (address (comptroller.oracle ()));
648+ uint256 priceInUSD = oracle.getUnderlyingPrice (
649+ MToken (mTokenCollateralAddr)
662650 );
663- require (success && data.length >= 32 , "decimals() call failed " );
664- uint8 decimals = abi.decode (data, (uint8 ));
651+ require (priceInUSD > 0 , "invalid price " );
665652
666653 (bool isListed , uint256 collateralFactorMantissa ) = comptroller.markets (
667654 mTokenCollateralAddr
668655 );
669656 require (isListed, "market not listed " );
670657 uint256 collateralFactorBps = (collateralFactorMantissa * 10000 ) / 1e18 ;
671658
672- collateralAmount =
673- (10_000 * 10 ** decimals * 1e8 ) /
674- uint256 (currentPrice);
659+ collateralAmount = (10_000 * 1e18 * 1e18 ) / priceInUSD;
675660 borrowAmount =
676661 ((10_000 * collateralFactorBps * 70 ) / (10000 * 100 )) *
677662 1e6 ;
0 commit comments