@@ -258,14 +258,15 @@ contract Comptroller is ComptrollerBase, ComptrollerInterface, ComptrollerErrorR
258
258
if (capConfig.controller != address (0 )) {
259
259
// We have a controller, so we're using Adrastia Prudentia
260
260
261
+ address underlyingToken = ICErc20 (cTokenAddress).underlying ();
262
+
261
263
// Get the supply cap from Adrastia Prudentia
262
- supplyCap = IHistoricalRates (capConfig.controller).getRateAt (cTokenAddress , capConfig.offset).current;
264
+ supplyCap = IHistoricalRates (capConfig.controller).getRateAt (underlyingToken , capConfig.offset).current;
263
265
264
266
// Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we
265
267
// must scale the supply cap to get the correct amount
266
268
267
269
int256 scaleByDecimals = 18 ;
268
- address underlyingToken = ICErc20 (cTokenAddress).underlying ();
269
270
// Not all ERC20s implement decimals(), so we use a staticcall and check the return data
270
271
(bool success , bytes memory data ) = underlyingToken.staticcall (abi.encodeWithSignature ("decimals() " ));
271
272
if (success && data.length == 32 ) {
@@ -514,14 +515,15 @@ contract Comptroller is ComptrollerBase, ComptrollerInterface, ComptrollerErrorR
514
515
if (capConfig.controller != address (0 )) {
515
516
// We have a controller, so we're using Adrastia Prudentia
516
517
518
+ address underlyingToken = ICErc20 (cToken).underlying ();
519
+
517
520
// Get the borrow cap from Adrastia Prudentia
518
- borrowCap = IHistoricalRates (capConfig.controller).getRateAt (cToken , capConfig.offset).current;
521
+ borrowCap = IHistoricalRates (capConfig.controller).getRateAt (underlyingToken , capConfig.offset).current;
519
522
520
523
// Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we
521
524
// must scale the supply cap to get the correct amount
522
525
523
526
int256 scaleByDecimals = 18 ;
524
- address underlyingToken = ICErc20 (cToken).underlying ();
525
527
// Not all ERC20s implement decimals(), so we use a staticcall and check the return data
526
528
(bool success , bytes memory data ) = underlyingToken.staticcall (abi.encodeWithSignature ("decimals() " ));
527
529
if (success && data.length == 32 ) {
0 commit comments