Skip to content

Commit 7e39178

Browse files
authored
Merge pull request #14 from aave/feat/light-deployments
Enable light deployment of the protocol
2 parents 554a2ed + 12cda09 commit 7e39178

File tree

181 files changed

+20088
-1948
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

181 files changed

+20088
-1948
lines changed

contracts/adapters/BaseUniswapAdapter.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,6 @@ abstract contract BaseUniswapAdapter is FlashLoanReceiverBase, IBaseUniswapAdapt
386386
}
387387

388388
uint256 bestAmountOut;
389-
390389
try UNISWAP_ROUTER.getAmountsOut(finalAmountIn, simplePath) returns (
391390
uint256[] memory resultAmounts
392391
) {

contracts/deployments/ATokensAndRatesHelper.sol

Lines changed: 34 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,20 @@ contract ATokensAndRatesHelper is Ownable {
2020
address private poolConfigurator;
2121
event deployedContracts(address aToken, address strategy);
2222

23+
struct InitDeploymentInput {
24+
address asset;
25+
uint256[6] rates;
26+
}
27+
28+
struct ConfigureReserveInput {
29+
address asset;
30+
uint256 baseLTV;
31+
uint256 liquidationThreshold;
32+
uint256 liquidationBonus;
33+
uint256 reserveFactor;
34+
bool stableBorrowingEnabled;
35+
}
36+
2337
constructor(
2438
address payable _pool,
2539
address _addressesProvider,
@@ -30,90 +44,40 @@ contract ATokensAndRatesHelper is Ownable {
3044
poolConfigurator = _poolConfigurator;
3145
}
3246

33-
function initDeployment(
34-
address[] calldata assets,
35-
string[] calldata symbols,
36-
uint256[6][] calldata rates,
37-
address treasuryAddress,
38-
address incentivesController
39-
) external onlyOwner {
40-
require(assets.length == symbols.length, 't Arrays not same length');
41-
require(rates.length == symbols.length, 'r Arrays not same length');
42-
for (uint256 i = 0; i < assets.length; i++) {
47+
function initDeployment(InitDeploymentInput[] calldata inputParams) external onlyOwner {
48+
for (uint256 i = 0; i < inputParams.length; i++) {
4349
emit deployedContracts(
44-
address(
45-
new AToken(
46-
LendingPool(pool),
47-
assets[i],
48-
treasuryAddress,
49-
StringLib.concat('Aave interest bearing ', symbols[i]),
50-
StringLib.concat('a', symbols[i]),
51-
incentivesController
52-
)
53-
),
50+
address(new AToken()),
5451
address(
5552
new DefaultReserveInterestRateStrategy(
5653
LendingPoolAddressesProvider(addressesProvider),
57-
rates[i][0],
58-
rates[i][1],
59-
rates[i][2],
60-
rates[i][3],
61-
rates[i][4],
62-
rates[i][5]
54+
inputParams[i].rates[0],
55+
inputParams[i].rates[1],
56+
inputParams[i].rates[2],
57+
inputParams[i].rates[3],
58+
inputParams[i].rates[4],
59+
inputParams[i].rates[5]
6360
)
6461
)
6562
);
6663
}
6764
}
6865

69-
function initReserve(
70-
address[] calldata stables,
71-
address[] calldata variables,
72-
address[] calldata aTokens,
73-
address[] calldata strategies,
74-
uint8[] calldata reserveDecimals
75-
) external onlyOwner {
76-
require(variables.length == stables.length);
77-
require(aTokens.length == stables.length);
78-
require(strategies.length == stables.length);
79-
require(reserveDecimals.length == stables.length);
80-
81-
for (uint256 i = 0; i < stables.length; i++) {
82-
LendingPoolConfigurator(poolConfigurator).initReserve(
83-
aTokens[i],
84-
stables[i],
85-
variables[i],
86-
reserveDecimals[i],
87-
strategies[i]
88-
);
89-
}
90-
}
91-
92-
function configureReserves(
93-
address[] calldata assets,
94-
uint256[] calldata baseLTVs,
95-
uint256[] calldata liquidationThresholds,
96-
uint256[] calldata liquidationBonuses,
97-
uint256[] calldata reserveFactors,
98-
bool[] calldata stableBorrowingEnabled
99-
) external onlyOwner {
100-
require(baseLTVs.length == assets.length);
101-
require(liquidationThresholds.length == assets.length);
102-
require(liquidationBonuses.length == assets.length);
103-
require(stableBorrowingEnabled.length == assets.length);
104-
require(reserveFactors.length == assets.length);
105-
66+
function configureReserves(ConfigureReserveInput[] calldata inputParams) external onlyOwner {
10667
LendingPoolConfigurator configurator = LendingPoolConfigurator(poolConfigurator);
107-
for (uint256 i = 0; i < assets.length; i++) {
68+
for (uint256 i = 0; i < inputParams.length; i++) {
10869
configurator.configureReserveAsCollateral(
109-
assets[i],
110-
baseLTVs[i],
111-
liquidationThresholds[i],
112-
liquidationBonuses[i]
70+
inputParams[i].asset,
71+
inputParams[i].baseLTV,
72+
inputParams[i].liquidationThreshold,
73+
inputParams[i].liquidationBonus
11374
);
11475

115-
configurator.enableBorrowingOnReserve(assets[i], stableBorrowingEnabled[i]);
116-
configurator.setReserveFactor(assets[i], reserveFactors[i]);
76+
configurator.enableBorrowingOnReserve(
77+
inputParams[i].asset,
78+
inputParams[i].stableBorrowingEnabled
79+
);
80+
configurator.setReserveFactor(inputParams[i].asset, inputParams[i].reserveFactor);
11781
}
11882
}
11983
}

contracts/deployments/StableAndVariableTokensHelper.sol

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,11 @@ contract StableAndVariableTokensHelper is Ownable {
1818
addressesProvider = _addressesProvider;
1919
}
2020

21-
function initDeployment(
22-
address[] calldata tokens,
23-
string[] calldata symbols,
24-
address incentivesController
25-
) external onlyOwner {
21+
function initDeployment(address[] calldata tokens, string[] calldata symbols) external onlyOwner {
2622
require(tokens.length == symbols.length, 'Arrays not same length');
2723
require(pool != address(0), 'Pool can not be zero address');
2824
for (uint256 i = 0; i < tokens.length; i++) {
29-
emit deployedContracts(
30-
address(
31-
new StableDebtToken(
32-
pool,
33-
tokens[i],
34-
StringLib.concat('Aave stable debt bearing ', symbols[i]),
35-
StringLib.concat('stableDebt', symbols[i]),
36-
incentivesController
37-
)
38-
),
39-
address(
40-
new VariableDebtToken(
41-
pool,
42-
tokens[i],
43-
StringLib.concat('Aave variable debt bearing ', symbols[i]),
44-
StringLib.concat('variableDebt', symbols[i]),
45-
incentivesController
46-
)
47-
)
48-
);
25+
emit deployedContracts(address(new StableDebtToken()), address(new VariableDebtToken()));
4926
}
5027
}
5128

contracts/interfaces/IAToken.sol

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ pragma solidity 0.6.12;
33

44
import {IERC20} from '../dependencies/openzeppelin/contracts/IERC20.sol';
55
import {IScaledBalanceToken} from './IScaledBalanceToken.sol';
6+
import {IInitializableAToken} from './IInitializableAToken.sol';
7+
import {IAaveIncentivesController} from './IAaveIncentivesController.sol';
68

7-
interface IAToken is IERC20, IScaledBalanceToken {
9+
interface IAToken is IERC20, IScaledBalanceToken, IInitializableAToken {
810
/**
911
* @dev Emitted after the mint action
1012
* @param from The address performing the mint
@@ -80,9 +82,21 @@ interface IAToken is IERC20, IScaledBalanceToken {
8082
/**
8183
* @dev Transfers the underlying asset to `target`. Used by the LendingPool to transfer
8284
* assets in borrow(), withdraw() and flashLoan()
83-
* @param user The recipient of the aTokens
85+
* @param user The recipient of the underlying
8486
* @param amount The amount getting transferred
8587
* @return The amount transferred
8688
**/
8789
function transferUnderlyingTo(address user, uint256 amount) external returns (uint256);
90+
91+
/**
92+
* @dev Invoked to execute actions on the aToken side after a repayment.
93+
* @param user The user executing the repayment
94+
* @param amount The amount getting repaid
95+
**/
96+
function handleRepayment(address user, uint256 amount) external;
97+
98+
/**
99+
* @dev Returns the address of the incentives controller contract
100+
**/
101+
function getIncentivesController() external view returns (IAaveIncentivesController);
88102
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// SPDX-License-Identifier: agpl-3.0
2+
pragma solidity 0.6.12;
3+
4+
import {ILendingPool} from './ILendingPool.sol';
5+
import {IAaveIncentivesController} from './IAaveIncentivesController.sol';
6+
7+
/**
8+
* @title IInitializableAToken
9+
* @notice Interface for the initialize function on AToken
10+
* @author Aave
11+
**/
12+
interface IInitializableAToken {
13+
/**
14+
* @dev Emitted when an aToken is initialized
15+
* @param underlyingAsset The address of the underlying asset
16+
* @param pool The address of the associated lending pool
17+
* @param treasury The address of the treasury
18+
* @param incentivesController The address of the incentives controller for this aToken
19+
* @param aTokenDecimals the decimals of the underlying
20+
* @param aTokenName the name of the aToken
21+
* @param aTokenSymbol the symbol of the aToken
22+
* @param params A set of encoded parameters for additional initialization
23+
**/
24+
event Initialized(
25+
address indexed underlyingAsset,
26+
address indexed pool,
27+
address treasury,
28+
address incentivesController,
29+
uint8 aTokenDecimals,
30+
string aTokenName,
31+
string aTokenSymbol,
32+
bytes params
33+
);
34+
35+
/**
36+
* @dev Initializes the aToken
37+
* @param pool The address of the lending pool where this aToken will be used
38+
* @param treasury The address of the Aave treasury, receiving the fees on this aToken
39+
* @param underlyingAsset The address of the underlying asset of this aToken (E.g. WETH for aWETH)
40+
* @param incentivesController The smart contract managing potential incentives distribution
41+
* @param aTokenDecimals The decimals of the aToken, same as the underlying asset's
42+
* @param aTokenName The name of the aToken
43+
* @param aTokenSymbol The symbol of the aToken
44+
*/
45+
function initialize(
46+
ILendingPool pool,
47+
address treasury,
48+
address underlyingAsset,
49+
IAaveIncentivesController incentivesController,
50+
uint8 aTokenDecimals,
51+
string calldata aTokenName,
52+
string calldata aTokenSymbol,
53+
bytes calldata params
54+
) external;
55+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// SPDX-License-Identifier: agpl-3.0
2+
pragma solidity 0.6.12;
3+
4+
import {ILendingPool} from './ILendingPool.sol';
5+
import {IAaveIncentivesController} from './IAaveIncentivesController.sol';
6+
7+
/**
8+
* @title IInitializableDebtToken
9+
* @notice Interface for the initialize function common between debt tokens
10+
* @author Aave
11+
**/
12+
interface IInitializableDebtToken {
13+
/**
14+
* @dev Emitted when a debt token is initialized
15+
* @param underlyingAsset The address of the underlying asset
16+
* @param pool The address of the associated lending pool
17+
* @param incentivesController The address of the incentives controller for this aToken
18+
* @param debtTokenDecimals the decimals of the debt token
19+
* @param debtTokenName the name of the debt token
20+
* @param debtTokenSymbol the symbol of the debt token
21+
* @param params A set of encoded parameters for additional initialization
22+
**/
23+
event Initialized(
24+
address indexed underlyingAsset,
25+
address indexed pool,
26+
address incentivesController,
27+
uint8 debtTokenDecimals,
28+
string debtTokenName,
29+
string debtTokenSymbol,
30+
bytes params
31+
);
32+
33+
/**
34+
* @dev Initializes the debt token.
35+
* @param pool The address of the lending pool where this aToken will be used
36+
* @param underlyingAsset The address of the underlying asset of this aToken (E.g. WETH for aWETH)
37+
* @param incentivesController The smart contract managing potential incentives distribution
38+
* @param debtTokenDecimals The decimals of the debtToken, same as the underlying asset's
39+
* @param debtTokenName The name of the token
40+
* @param debtTokenSymbol The symbol of the token
41+
*/
42+
function initialize(
43+
ILendingPool pool,
44+
address underlyingAsset,
45+
IAaveIncentivesController incentivesController,
46+
uint8 debtTokenDecimals,
47+
string memory debtTokenName,
48+
string memory debtTokenSymbol,
49+
bytes calldata params
50+
) external;
51+
}

0 commit comments

Comments
 (0)