When transfer, check pause at pool to save one external call.

This commit is contained in:
David Racero 2020-09-14 19:46:27 +02:00
parent 64066a14ec
commit 4ec61ee993
4 changed files with 9 additions and 11 deletions

View File

@ -387,6 +387,4 @@ interface ILendingPool {
function pause() external; function pause() external;
function unpause() external; function unpause() external;
function paused() external view returns (bool);
} }

View File

@ -888,6 +888,9 @@ contract LendingPool is VersionedInitializable, PausablePool, ILendingPool {
address user, address user,
uint256 amount uint256 amount
) external override view returns (bool) { ) external override view returns (bool) {
if (PausablePool.paused()) {
return false;
}
return return
GenericLogic.balanceDecreaseAllowed( GenericLogic.balanceDecreaseAllowed(
asset, asset,
@ -927,11 +930,4 @@ contract LendingPool is VersionedInitializable, PausablePool, ILendingPool {
function unpause() external override onlyLendingPoolConfigurator { function unpause() external override onlyLendingPoolConfigurator {
PausablePool._unpause(); PausablePool._unpause();
} }
/**
* @dev retrieve pause status
*/
function paused() public override(PausablePool, ILendingPool) view returns (bool) {
return PausablePool.paused();
}
} }

View File

@ -1,4 +1,6 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.8;
// import {Errors} from '../libraries/helpers/Errors.sol';
/** /**
* @dev Contract module which allows children to implement an emergency stop * @dev Contract module which allows children to implement an emergency stop
@ -44,6 +46,7 @@ contract PausablePool {
* - The contract must not be paused. * - The contract must not be paused.
*/ */
modifier whenNotPaused() { modifier whenNotPaused() {
// require(!_paused, Errors.IS_PAUSED);
require(!_paused, '54'); require(!_paused, '54');
_; _;
} }
@ -56,6 +59,7 @@ contract PausablePool {
* - The contract must be paused. * - The contract must be paused.
*/ */
modifier whenPaused() { modifier whenPaused() {
// require(_paused, Errors.NOT_PAUSED);
require(_paused, '55'); require(_paused, '55');
_; _;
} }

View File

@ -160,7 +160,7 @@ contract AToken is VersionedInitializable, ERC20, IAToken {
* @return true if the user can transfer amount, false otherwise * @return true if the user can transfer amount, false otherwise
**/ **/
function isTransferAllowed(address user, uint256 amount) public override view returns (bool) { function isTransferAllowed(address user, uint256 amount) public override view returns (bool) {
return !POOL.paused() && POOL.balanceDecreaseAllowed(UNDERLYING_ASSET_ADDRESS, user, amount); return POOL.balanceDecreaseAllowed(UNDERLYING_ASSET_ADDRESS, user, amount);
} }
/** /**