Skip to content

Commit 8ba8d67

Browse files
committed
Merge branch 'master' into docs/319-improve-emodelogic-configuratiorlogic
2 parents 2dd1551 + 86ef1b9 commit 8ba8d67

38 files changed

+663
-387
lines changed

contracts/deployments/ReservesSetupHelper.sol

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ contract ReservesSetupHelper is Ownable {
4242
);
4343

4444
if (inputParams[i].borrowingEnabled) {
45-
configurator.enableBorrowingOnReserve(
45+
configurator.setReserveBorrowing(inputParams[i].asset, true);
46+
47+
configurator.setBorrowCap(inputParams[i].asset, inputParams[i].borrowCap);
48+
configurator.setReserveStableRateBorrowing(
4649
inputParams[i].asset,
47-
inputParams[i].borrowCap,
4850
inputParams[i].stableBorrowingEnabled
4951
);
5052
}

contracts/interfaces/IPool.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ interface IPool {
100100
* @notice Emitted on swapBorrowRateMode()
101101
* @param reserve The address of the underlying asset of the reserve
102102
* @param user The address of the user swapping his rate mode
103-
* @param rateMode The rate mode that the user wants to swap to
103+
* @param rateMode The current interest rate mode of the position being swapped.
104104
**/
105105
event Swap(address indexed reserve, address indexed user, uint256 rateMode);
106106

@@ -591,10 +591,10 @@ interface IPool {
591591
function getReservesList() external view returns (address[] memory);
592592

593593
/**
594-
* @notice Returns the cached PoolAddressesProvider connected to this contract
594+
* @notice Returns the PoolAddressesProvider connected to this contract
595595
* @return The address of the PoolAddressesProvider
596596
**/
597-
function getAddressesProvider() external view returns (IPoolAddressesProvider);
597+
function ADDRESSES_PROVIDER() external view returns (IPoolAddressesProvider);
598598

599599
/**
600600
* @notice Updates the protocol fee on the bridging

contracts/interfaces/IPoolConfigurator.sol

Lines changed: 28 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,11 @@ interface IPoolConfigurator {
2626
);
2727

2828
/**
29-
* @notice Emitted when borrowing is enabled on a reserve
29+
* @notice Emitted when borrowing is enabled or disabled on a reserve
3030
* @param asset The address of the underlying asset of the reserve
31-
* @param stableRateEnabled True if stable rate borrowing is enabled, false otherwise
31+
* @param enabled True if borrowing is enabled, false otherwise
3232
**/
33-
event BorrowingEnabledOnReserve(address indexed asset, bool stableRateEnabled);
34-
35-
/**
36-
* @notice Emitted when borrowing is disabled on a reserve
37-
* @param asset The address of the underlying asset of the reserve
38-
**/
39-
event BorrowingDisabledOnReserve(address indexed asset);
33+
event ReserveBorrowing(address indexed asset, bool enabled);
4034

4135
/**
4236
* @notice Emitted when the collateralization risk parameters for the specified asset are updated.
@@ -53,52 +47,32 @@ interface IPoolConfigurator {
5347
);
5448

5549
/**
56-
* @notice Emitted when stable rate borrowing is enabled on a reserve
57-
* @param asset The address of the underlying asset of the reserve
58-
**/
59-
event StableRateEnabledOnReserve(address indexed asset);
60-
61-
/**
62-
* @notice Emitted when stable rate borrowing is disabled on a reserve
63-
* @param asset The address of the underlying asset of the reserve
64-
**/
65-
event StableRateDisabledOnReserve(address indexed asset);
66-
67-
/**
68-
* @notice Emitted when a reserve is activated
69-
* @param asset The address of the underlying asset of the reserve
70-
**/
71-
event ReserveActivated(address indexed asset);
72-
73-
/**
74-
* @notice Emitted when a reserve is deactivated
75-
* @param asset The address of the underlying asset of the reserve
76-
**/
77-
event ReserveDeactivated(address indexed asset);
78-
79-
/**
80-
* @notice Emitted when a reserve is frozen
50+
* @notice Emitted when stable rate borrowing state is changed on a reserve
8151
* @param asset The address of the underlying asset of the reserve
52+
* @param enabled True if stable rate borrowing is enabled, false otherwise
8253
**/
83-
event ReserveFrozen(address indexed asset);
54+
event ReserveStableRateBorrowing(address indexed asset, bool enabled);
8455

8556
/**
86-
* @notice Emitted when a reserve is unfrozen
57+
* @notice Emitted when a reserve is activated or deactivated
8758
* @param asset The address of the underlying asset of the reserve
59+
* @param active True if reserve is active, false otherwise
8860
**/
89-
event ReserveUnfrozen(address indexed asset);
61+
event ReserveActive(address indexed asset, bool active);
9062

9163
/**
92-
* @notice Emitted when a reserve is paused
64+
* @notice Emitted when a reserve is frozen or unfrozen
9365
* @param asset The address of the underlying asset of the reserve
66+
* @param frozen True if reserve is frozen, false otherwise
9467
**/
95-
event ReservePaused(address indexed asset);
68+
event ReserveFrozen(address indexed asset, bool frozen);
9669

9770
/**
98-
* @notice Emitted when a reserve is unpaused
71+
* @notice Emitted when a reserve is paused or unpaused
9972
* @param asset The address of the underlying asset of the reserve
73+
* @param paused True if reserve is paused, false otherwise
10074
**/
101-
event ReserveUnpaused(address indexed asset);
75+
event ReservePaused(address indexed asset, bool paused);
10276

10377
/**
10478
* @notice Emitted when a reserve is dropped
@@ -286,22 +260,11 @@ interface IPoolConfigurator {
286260
external;
287261

288262
/**
289-
* @notice Enables borrowing on a reserve
290-
* @param asset The address of the underlying asset of the reserve
291-
* @param borrowCap The borrow cap for this specific asset, in absolute units of tokens
292-
* @param stableBorrowRateEnabled True if stable borrow rate needs to be enabled by default on this reserve
293-
**/
294-
function enableBorrowingOnReserve(
295-
address asset,
296-
uint256 borrowCap,
297-
bool stableBorrowRateEnabled
298-
) external;
299-
300-
/**
301-
* @notice Disables borrowing on a reserve
263+
* @notice Configures borrowing on a reserve
302264
* @param asset The address of the underlying asset of the reserve
265+
* @param enabled True if borrowing needs to be enabled, false otherwise
303266
**/
304-
function disableBorrowingOnReserve(address asset) external;
267+
function setReserveBorrowing(address asset, bool enabled) external;
305268

306269
/**
307270
* @notice Configures the reserve collateralization parameters
@@ -320,41 +283,26 @@ interface IPoolConfigurator {
320283
) external;
321284

322285
/**
323-
* @notice Enable stable rate borrowing on a reserve
324-
* @param asset The address of the underlying asset of the reserve
325-
**/
326-
function enableReserveStableRate(address asset) external;
327-
328-
/**
329-
* @notice Disable stable rate borrowing on a reserve
330-
* @param asset The address of the underlying asset of the reserve
331-
**/
332-
function disableReserveStableRate(address asset) external;
333-
334-
/**
335-
* @notice Activates a reserve
336-
* @param asset The address of the underlying asset of the reserve
337-
**/
338-
function activateReserve(address asset) external;
339-
340-
/**
341-
* @notice Deactivates a reserve
286+
* @notice Enable or disable stable rate borrowing on a reserve
342287
* @param asset The address of the underlying asset of the reserve
288+
* @param enabled True if stable rate borrowing needs to be enabled, false otherwise
343289
**/
344-
function deactivateReserve(address asset) external;
290+
function setReserveStableRateBorrowing(address asset, bool enabled) external;
345291

346292
/**
347-
* @notice Freezes a reserve. A frozen reserve doesn't allow any new supply, borrow or rate swap
348-
* but allows repayments, liquidations, rate rebalances and withdrawals
293+
* @notice Activate or deactivate a reserve
349294
* @param asset The address of the underlying asset of the reserve
295+
* @param active True if the reserve needs to be active, false otherwise
350296
**/
351-
function freezeReserve(address asset) external;
297+
function setReserveActive(address asset, bool active) external;
352298

353299
/**
354-
* @notice Unfreezes a reserve
300+
* @notice Freeze or unfreeze a reserve. A frozen reserve doesn't allow any new supply, borrow
301+
* or rate swap but allows repayments, liquidations, rate rebalances and withdrawals
355302
* @param asset The address of the underlying asset of the reserve
303+
* @param freeze True if the reserve needs to be frozen, false otherwise
356304
**/
357-
function unfreezeReserve(address asset) external;
305+
function setReseveFreeze(address asset, bool freeze) external;
358306

359307
/**
360308
* @notice Sets the borrowable in isolation flag for the reserve

contracts/interfaces/NewChainlink.sol

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.0;
3+
4+
// 0x6Df09E975c830ECae5bd4eD9d90f3A95a4f88012
5+
// AAVE / USD 8 0x547a514d5e3769680Ce22B2361c10Ea13619e8a9
6+
7+
interface AggregatorInterface {
8+
function latestAnswer() external view returns (int256);
9+
10+
function latestTimestamp() external view returns (uint256);
11+
12+
function latestRound() external view returns (uint256);
13+
14+
function getAnswer(uint256 roundId) external view returns (int256);
15+
16+
function getTimestamp(uint256 roundId) external view returns (uint256);
17+
18+
event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 updatedAt);
19+
20+
event NewRound(uint256 indexed roundId, address indexed startedBy, uint256 startedAt);
21+
}
22+
23+
interface AggregatorV3Interface {
24+
function decimals() external view returns (uint8);
25+
26+
function description() external view returns (string memory);
27+
28+
function version() external view returns (uint256);
29+
30+
// getRoundData and latestRoundData should both raise "No data present"
31+
// if they do not have data to report, instead of returning unset values
32+
// which could be misinterpreted as actual reported values.
33+
function getRoundData(uint80 _roundId)
34+
external
35+
view
36+
returns (
37+
uint80 roundId,
38+
int256 answer,
39+
uint256 startedAt,
40+
uint256 updatedAt,
41+
uint80 answeredInRound
42+
);
43+
44+
function latestRoundData()
45+
external
46+
view
47+
returns (
48+
uint80 roundId,
49+
int256 answer,
50+
uint256 startedAt,
51+
uint256 updatedAt,
52+
uint80 answeredInRound
53+
);
54+
}
55+
56+
interface AggregatorV2V3Interface is AggregatorInterface, AggregatorV3Interface {}

contracts/mocks/flashloan/MockFlashLoanReceiver.sol

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import {MintableERC20} from '../tokens/MintableERC20.sol';
1010
contract MockFlashLoanReceiver is FlashLoanReceiverBase {
1111
using SafeERC20 for IERC20;
1212

13-
IPoolAddressesProvider internal _provider;
14-
1513
event ExecutedWithFail(address[] _assets, uint256[] _amounts, uint256[] _premiums);
1614
event ExecutedWithSuccess(address[] _assets, uint256[] _amounts, uint256[] _premiums);
1715

@@ -45,12 +43,9 @@ contract MockFlashLoanReceiver is FlashLoanReceiverBase {
4543
address[] memory assets,
4644
uint256[] memory amounts,
4745
uint256[] memory premiums,
48-
address initiator,
49-
bytes memory params
46+
address, // initiator
47+
bytes memory // params
5048
) public override returns (bool) {
51-
params;
52-
initiator;
53-
5449
if (_failExecution) {
5550
emit ExecutedWithFail(assets, amounts, premiums);
5651
return !_simulateEOA;

contracts/mocks/flashloan/MockSimpleFlashLoanReceiver.sol

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@ contract MockFlashLoanSimpleReceiver is FlashLoanSimpleReceiverBase {
1313
using SafeERC20 for IERC20;
1414
using SafeMath for uint256;
1515

16-
IPoolAddressesProvider internal _provider;
17-
18-
event ExecutedWithFail(address _asset, uint256 _amount, uint256 _premium);
19-
event ExecutedWithSuccess(address _asset, uint256 _amount, uint256 _premium);
16+
event ExecutedWithFail(address asset, uint256 amount, uint256 premium);
17+
event ExecutedWithSuccess(address asset, uint256 amount, uint256 premium);
2018

2119
bool _failExecution;
2220
uint256 _amountToApprove;
@@ -36,7 +34,7 @@ contract MockFlashLoanSimpleReceiver is FlashLoanSimpleReceiverBase {
3634
_simulateEOA = flag;
3735
}
3836

39-
function amountToApprove() public view returns (uint256) {
37+
function getAmountToApprove() public view returns (uint256) {
4038
return _amountToApprove;
4139
}
4240

@@ -48,12 +46,9 @@ contract MockFlashLoanSimpleReceiver is FlashLoanSimpleReceiverBase {
4846
address asset,
4947
uint256 amount,
5048
uint256 premium,
51-
address initiator,
52-
bytes memory params
49+
address, // initiator
50+
bytes memory // params
5351
) public override returns (bool) {
54-
params;
55-
initiator;
56-
5752
if (_failExecution) {
5853
emit ExecutedWithFail(asset, amount, premium);
5954
return !_simulateEOA;

contracts/mocks/helpers/MockPool.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ contract MockPool {
1515
_addressesProvider = provider;
1616
}
1717

18-
function addReserveToReservesList(address _reserve) external {
19-
_reserveList.push(_reserve);
18+
function addReserveToReservesList(address reserve) external {
19+
_reserveList.push(reserve);
2020
}
2121

2222
function getReservesList() external view returns (address[] memory) {

contracts/mocks/oracle/CLAggregators/MockAggregator.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ contract MockAggregator {
66

77
event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 timestamp);
88

9-
constructor(int256 _initialAnswer) {
10-
_latestAnswer = _initialAnswer;
11-
emit AnswerUpdated(_initialAnswer, 0, block.timestamp);
9+
constructor(int256 initialAnswer) {
10+
_latestAnswer = initialAnswer;
11+
emit AnswerUpdated(initialAnswer, 0, block.timestamp);
1212
}
1313

1414
function latestAnswer() external view returns (int256) {

contracts/mocks/oracle/PriceOracle.sol

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@ contract PriceOracle is IPriceOracle {
77
mapping(address => uint256) prices;
88
uint256 ethPriceUsd;
99

10-
event AssetPriceUpdated(address _asset, uint256 _price, uint256 timestamp);
11-
event EthPriceUpdated(uint256 _price, uint256 timestamp);
10+
event AssetPriceUpdated(address asset, uint256 price, uint256 timestamp);
11+
event EthPriceUpdated(uint256 price, uint256 timestamp);
1212

13-
function getAssetPrice(address _asset) external view override returns (uint256) {
14-
return prices[_asset];
13+
function getAssetPrice(address asset) external view override returns (uint256) {
14+
return prices[asset];
1515
}
1616

17-
function setAssetPrice(address _asset, uint256 _price) external override {
18-
prices[_asset] = _price;
19-
emit AssetPriceUpdated(_asset, _price, block.timestamp);
17+
function setAssetPrice(address asset, uint256 price) external override {
18+
prices[asset] = price;
19+
emit AssetPriceUpdated(asset, price, block.timestamp);
2020
}
2121

2222
function getEthUsdPrice() external view returns (uint256) {
2323
return ethPriceUsd;
2424
}
2525

26-
function setEthUsdPrice(uint256 _price) external {
27-
ethPriceUsd = _price;
28-
emit EthPriceUpdated(_price, block.timestamp);
26+
function setEthUsdPrice(uint256 price) external {
27+
ethPriceUsd = price;
28+
emit EthPriceUpdated(price, block.timestamp);
2929
}
3030
}

contracts/mocks/tests/FlashloanAttacker.sol

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,9 @@ contract FlashloanAttacker is FlashLoanSimpleReceiverBase {
4040
address asset,
4141
uint256 amount,
4242
uint256 premium,
43-
address initiator,
44-
bytes memory params
43+
address, // initiator
44+
bytes memory // params
4545
) public override returns (bool) {
46-
params;
47-
initiator;
48-
4946
MintableERC20 token = MintableERC20(asset);
5047
uint256 amountToReturn = amount.add(premium);
5148

0 commit comments

Comments
 (0)