Skip to content

Commit

Permalink
Merge branch 'master' into feat/101-add-supply-function
Browse files Browse the repository at this point in the history
  • Loading branch information
The-3D committed Sep 22, 2021
2 parents 5e37eeb + 1031915 commit 9c8112f
Show file tree
Hide file tree
Showing 42 changed files with 1,634 additions and 1,183 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: release-please
on:
push:
branches:
- main
- master
jobs:
release-please:
runs-on: ubuntu-latest
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ coverage
.coverage_cache
.coverage_contracts
coverage.json

177 changes: 177 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

75 changes: 0 additions & 75 deletions contracts/deployments/ATokensAndRatesHelper.sol

This file was deleted.

45 changes: 45 additions & 0 deletions contracts/deployments/RateOracleSetupHelper.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.7;

import {RateOracle} from '../mocks/oracle/RateOracle.sol';
import {Ownable} from '../dependencies/openzeppelin/contracts/Ownable.sol';

/**
* @title RateOracleSetupHelper
* @author Aave
* @notice Deployment helper to setup initial borrow rates of multiple assets in one transaction.
* @dev The RateOracle owner must transfer the ownership to RateOracleSetupHelper before calling to setOracleBorrowRates.
* @dev The RateOracleSetupHelper is an Ownable contract, so only the deployer or future owners can call this contract.
*/
contract RateOracleSetupHelper is Ownable {

/**
* @notice External function called by the owner account to set the initial borrow rates of the assets
* @param assets The addresses of the assets
* @param rates The interest rates of each asset
* @param oracle The address of the RateOracle contract
*/
function setOracleBorrowRates(
address[] calldata assets,
uint256[] calldata rates,
address oracle
) external onlyOwner {
require(assets.length == rates.length, 'Arrays not same length');

for (uint256 i = 0; i < assets.length; i++) {
// RateOracle owner must be this contract
RateOracle(oracle).setMarketBorrowRate(assets[i], rates[i]);
}
}

/**
* @notice External function called by the deployer account to give ownership of the RateOracle back to the corresponding owner address.
* @param oracle The address of the RateOracle contract
* @param admin The corresponding owner address
*/
function setOracleOwnership(address oracle, address admin) external onlyOwner {
require(admin != address(0), 'owner can not be zero');
require(RateOracle(oracle).owner() == address(this), 'helper is not owner');
RateOracle(oracle).transferOwnership(admin);
}
}
55 changes: 55 additions & 0 deletions contracts/deployments/ReservesSetupHelper.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.7;

import {PoolConfigurator} from '../protocol/pool/PoolConfigurator.sol';
import {Ownable} from '../dependencies/openzeppelin/contracts/Ownable.sol';

/**
* @title ReservesSetupHelper
* @author Aave
* @notice Deployment helper to setup the assets risk parameters at PoolConfigurator in batch.
* @dev The Pool admin or risk admin must transfer the ownership to ReservesSetupHelper before calling to setOracleBorrowRates.
* @dev The ReservesSetupHelper is an Ownable contract, so only the deployer or future owners can call this contract.
*/
contract ReservesSetupHelper is Ownable {
struct ConfigureReserveInput {
address asset;
uint256 baseLTV;
uint256 liquidationThreshold;
uint256 liquidationBonus;
uint256 reserveFactor;
uint256 borrowCap;
uint256 supplyCap;
bool stableBorrowingEnabled;
bool borrowingEnabled;
}

/**
* @notice External function called by the owner account to setup the assets risk parameters in batch.
* @param configurator The address of PoolConfigurator contract
* @param inputParams An array of ConfigureReserveInput struct that contains the assets and their risk parameters
*/
function configureReserves(
PoolConfigurator configurator,
ConfigureReserveInput[] calldata inputParams
) external onlyOwner {
for (uint256 i = 0; i < inputParams.length; i++) {
configurator.configureReserveAsCollateral(
inputParams[i].asset,
inputParams[i].baseLTV,
inputParams[i].liquidationThreshold,
inputParams[i].liquidationBonus
);

if (inputParams[i].borrowingEnabled) {
configurator.enableBorrowingOnReserve(
inputParams[i].asset,
inputParams[i].borrowCap,
inputParams[i].stableBorrowingEnabled
);
}
configurator.setSupplyCap(inputParams[i].asset, inputParams[i].supplyCap);
configurator.setReserveFactor(inputParams[i].asset, inputParams[i].reserveFactor);
}
}
}
54 changes: 0 additions & 54 deletions contracts/deployments/StableAndVariableTokensHelper.sol

This file was deleted.

7 changes: 7 additions & 0 deletions contracts/interfaces/IScaledBalanceToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,11 @@ interface IScaledBalanceToken {
* @return The scaled total supply
**/
function scaledTotalSupply() external view returns (uint256);

/**
* @notice Returns last index interest was accrued to the user's balance
* @param user The address of the user
* @return The last index interest was accrued to the user's balance
**/
function getPreviousIndex(address user) external view returns (uint256);
}
16 changes: 5 additions & 11 deletions contracts/misc/AaveProtocolDataProvider.sol
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,9 @@ contract AaveProtocolDataProvider {
.getConfiguration(asset);

(ltv, liquidationThreshold, liquidationBonus, decimals, reserveFactor) = configuration
.getParamsMemory();
.getParams();

(isActive, isFrozen, borrowingEnabled, stableBorrowRateEnabled, ) = configuration
.getFlagsMemory();
(isActive, isFrozen, borrowingEnabled, stableBorrowRateEnabled, ) = configuration.getFlags();

usageAsCollateralEnabled = liquidationThreshold > 0;
}
Expand All @@ -131,9 +130,7 @@ contract AaveProtocolDataProvider {
view
returns (uint256 borrowCap, uint256 supplyCap)
{
(borrowCap, supplyCap) = IPool(ADDRESSES_PROVIDER.getPool())
.getConfiguration(asset)
.getCapsMemory();
(borrowCap, supplyCap) = IPool(ADDRESSES_PROVIDER.getPool()).getConfiguration(asset).getCaps();
}

/**
Expand All @@ -142,9 +139,7 @@ contract AaveProtocolDataProvider {
* @return isPaused True if the pool is paused, false otherwise
**/
function getPaused(address asset) external view returns (bool isPaused) {
(, , , , isPaused) = IPool(ADDRESSES_PROVIDER.getPool())
.getConfiguration(asset)
.getFlagsMemory();
(, , , , isPaused) = IPool(ADDRESSES_PROVIDER.getPool()).getConfiguration(asset).getFlags();
}

/**
Expand All @@ -153,8 +148,7 @@ contract AaveProtocolDataProvider {
* @return The protocol fee on liquidation
**/
function getLiquidationProtocolFee(address asset) external view returns (uint256) {
return
IPool(ADDRESSES_PROVIDER.getPool()).getConfiguration(asset).getLiquidationProtocolFeeMemory();
return IPool(ADDRESSES_PROVIDER.getPool()).getConfiguration(asset).getLiquidationProtocolFee();
}

/**
Expand Down
Loading

0 comments on commit 9c8112f

Please sign in to comment.