mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Added encoded parameter to reserve initialization
This commit is contained in:
parent
e33eb615d0
commit
77fab5d3bb
|
@ -27,6 +27,7 @@ interface IInitializableAToken {
|
||||||
IAaveIncentivesController incentivesController,
|
IAaveIncentivesController incentivesController,
|
||||||
uint8 aTokenDecimals,
|
uint8 aTokenDecimals,
|
||||||
string calldata aTokenName,
|
string calldata aTokenName,
|
||||||
string calldata aTokenSymbol
|
string calldata aTokenSymbol,
|
||||||
|
bytes calldata params
|
||||||
) external;
|
) external;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ interface IInitializableDebtToken {
|
||||||
IAaveIncentivesController incentivesController,
|
IAaveIncentivesController incentivesController,
|
||||||
uint8 debtTokenDecimals,
|
uint8 debtTokenDecimals,
|
||||||
string memory debtTokenName,
|
string memory debtTokenName,
|
||||||
string memory debtTokenSymbol
|
string memory debtTokenSymbol,
|
||||||
|
bytes calldata params
|
||||||
) external;
|
) external;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ interface ILendingPoolConfigurator {
|
||||||
string variableDebtTokenSymbol;
|
string variableDebtTokenSymbol;
|
||||||
string stableDebtTokenName;
|
string stableDebtTokenName;
|
||||||
string stableDebtTokenSymbol;
|
string stableDebtTokenSymbol;
|
||||||
|
bytes params;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct UpdateATokenInput {
|
struct UpdateATokenInput {
|
||||||
|
@ -28,6 +29,7 @@ interface ILendingPoolConfigurator {
|
||||||
string name;
|
string name;
|
||||||
string symbol;
|
string symbol;
|
||||||
address implementation;
|
address implementation;
|
||||||
|
bytes params;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct UpdateDebtTokenInput {
|
struct UpdateDebtTokenInput {
|
||||||
|
@ -36,6 +38,7 @@ interface ILendingPoolConfigurator {
|
||||||
string name;
|
string name;
|
||||||
string symbol;
|
string symbol;
|
||||||
address implementation;
|
address implementation;
|
||||||
|
bytes params;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -60,183 +60,186 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur
|
||||||
/**
|
/**
|
||||||
* @dev Initializes reserves in batch
|
* @dev Initializes reserves in batch
|
||||||
**/
|
**/
|
||||||
function batchInitReserve(InitReserveInput[] calldata inputParams) external onlyPoolAdmin {
|
function batchInitReserve(InitReserveInput[] calldata input) external onlyPoolAdmin {
|
||||||
ILendingPool cachedPool = pool;
|
ILendingPool cachedPool = pool;
|
||||||
for (uint256 i = 0; i < inputParams.length; i++) {
|
for (uint256 i = 0; i < input.length; i++) {
|
||||||
_initReserve(cachedPool, inputParams[i]);
|
_initReserve(cachedPool, input[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function _initReserve(ILendingPool pool, InitReserveInput calldata inputParams) internal {
|
function _initReserve(ILendingPool pool, InitReserveInput calldata input) internal {
|
||||||
address aTokenProxyAddress =
|
address aTokenProxyAddress =
|
||||||
_initTokenWithProxy(
|
_initTokenWithProxy(
|
||||||
inputParams.aTokenImpl,
|
input.aTokenImpl,
|
||||||
abi.encodeWithSelector(
|
abi.encodeWithSelector(
|
||||||
IInitializableAToken.initialize.selector,
|
IInitializableAToken.initialize.selector,
|
||||||
pool,
|
pool,
|
||||||
inputParams.treasury,
|
input.treasury,
|
||||||
inputParams.underlyingAsset,
|
input.underlyingAsset,
|
||||||
IAaveIncentivesController(inputParams.incentivesController),
|
IAaveIncentivesController(input.incentivesController),
|
||||||
inputParams.underlyingAssetDecimals,
|
input.underlyingAssetDecimals,
|
||||||
inputParams.aTokenName,
|
input.aTokenName,
|
||||||
inputParams.aTokenSymbol
|
input.aTokenSymbol,
|
||||||
|
input.params
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
address stableDebtTokenProxyAddress =
|
address stableDebtTokenProxyAddress =
|
||||||
_initTokenWithProxy(
|
_initTokenWithProxy(
|
||||||
inputParams.stableDebtTokenImpl,
|
input.stableDebtTokenImpl,
|
||||||
abi.encodeWithSelector(
|
abi.encodeWithSelector(
|
||||||
IInitializableDebtToken.initialize.selector,
|
IInitializableDebtToken.initialize.selector,
|
||||||
pool,
|
pool,
|
||||||
inputParams.underlyingAsset,
|
input.underlyingAsset,
|
||||||
IAaveIncentivesController(inputParams.incentivesController),
|
IAaveIncentivesController(input.incentivesController),
|
||||||
inputParams.underlyingAssetDecimals,
|
input.underlyingAssetDecimals,
|
||||||
inputParams.stableDebtTokenName,
|
input.stableDebtTokenName,
|
||||||
inputParams.stableDebtTokenSymbol
|
input.stableDebtTokenSymbol,
|
||||||
|
input.params
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
address variableDebtTokenProxyAddress =
|
address variableDebtTokenProxyAddress =
|
||||||
_initTokenWithProxy(
|
_initTokenWithProxy(
|
||||||
inputParams.variableDebtTokenImpl,
|
input.variableDebtTokenImpl,
|
||||||
abi.encodeWithSelector(
|
abi.encodeWithSelector(
|
||||||
IInitializableDebtToken.initialize.selector,
|
IInitializableDebtToken.initialize.selector,
|
||||||
pool,
|
pool,
|
||||||
inputParams.underlyingAsset,
|
input.underlyingAsset,
|
||||||
IAaveIncentivesController(inputParams.incentivesController),
|
IAaveIncentivesController(input.incentivesController),
|
||||||
inputParams.underlyingAssetDecimals,
|
input.underlyingAssetDecimals,
|
||||||
inputParams.variableDebtTokenName,
|
input.variableDebtTokenName,
|
||||||
inputParams.variableDebtTokenSymbol
|
input.variableDebtTokenSymbol,
|
||||||
|
input.params
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
pool.initReserve(
|
pool.initReserve(
|
||||||
inputParams.underlyingAsset,
|
input.underlyingAsset,
|
||||||
aTokenProxyAddress,
|
aTokenProxyAddress,
|
||||||
stableDebtTokenProxyAddress,
|
stableDebtTokenProxyAddress,
|
||||||
variableDebtTokenProxyAddress,
|
variableDebtTokenProxyAddress,
|
||||||
inputParams.interestRateStrategyAddress
|
input.interestRateStrategyAddress
|
||||||
);
|
);
|
||||||
|
|
||||||
DataTypes.ReserveConfigurationMap memory currentConfig =
|
DataTypes.ReserveConfigurationMap memory currentConfig =
|
||||||
pool.getConfiguration(inputParams.underlyingAsset);
|
pool.getConfiguration(input.underlyingAsset);
|
||||||
|
|
||||||
currentConfig.setDecimals(inputParams.underlyingAssetDecimals);
|
currentConfig.setDecimals(input.underlyingAssetDecimals);
|
||||||
|
|
||||||
currentConfig.setActive(true);
|
currentConfig.setActive(true);
|
||||||
currentConfig.setFrozen(false);
|
currentConfig.setFrozen(false);
|
||||||
|
|
||||||
pool.setConfiguration(inputParams.underlyingAsset, currentConfig.data);
|
pool.setConfiguration(input.underlyingAsset, currentConfig.data);
|
||||||
|
|
||||||
emit ReserveInitialized(
|
emit ReserveInitialized(
|
||||||
inputParams.underlyingAsset,
|
input.underlyingAsset,
|
||||||
aTokenProxyAddress,
|
aTokenProxyAddress,
|
||||||
stableDebtTokenProxyAddress,
|
stableDebtTokenProxyAddress,
|
||||||
variableDebtTokenProxyAddress,
|
variableDebtTokenProxyAddress,
|
||||||
inputParams.interestRateStrategyAddress
|
input.interestRateStrategyAddress
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Updates the aToken implementation for the reserve
|
* @dev Updates the aToken implementation for the reserve
|
||||||
**/
|
**/
|
||||||
function updateAToken(UpdateATokenInput calldata inputParams) external onlyPoolAdmin {
|
function updateAToken(UpdateATokenInput calldata input) external onlyPoolAdmin {
|
||||||
ILendingPool cachedPool = pool;
|
ILendingPool cachedPool = pool;
|
||||||
|
|
||||||
DataTypes.ReserveData memory reserveData = cachedPool.getReserveData(inputParams.asset);
|
DataTypes.ReserveData memory reserveData = cachedPool.getReserveData(input.asset);
|
||||||
|
|
||||||
DataTypes.ReserveConfigurationMap memory configuration =
|
(, , , uint256 decimals, ) = cachedPool.getConfiguration(input.asset).getParamsMemory();
|
||||||
cachedPool.getConfiguration(inputParams.asset);
|
|
||||||
|
|
||||||
(, , , uint256 decimals, ) = configuration.getParamsMemory();
|
bytes memory encodedCall = abi.encodeWithSelector(
|
||||||
|
IInitializableAToken.initialize.selector,
|
||||||
|
cachedPool,
|
||||||
|
input.treasury,
|
||||||
|
input.asset,
|
||||||
|
input.incentivesController,
|
||||||
|
decimals,
|
||||||
|
input.name,
|
||||||
|
input.symbol,
|
||||||
|
input.params
|
||||||
|
);
|
||||||
|
|
||||||
_upgradeTokenImplementation(
|
_upgradeTokenImplementation(
|
||||||
reserveData.aTokenAddress,
|
reserveData.aTokenAddress,
|
||||||
inputParams.implementation,
|
input.implementation,
|
||||||
abi.encodeWithSelector(
|
encodedCall
|
||||||
IInitializableAToken.initialize.selector,
|
|
||||||
cachedPool,
|
|
||||||
inputParams.treasury,
|
|
||||||
inputParams.asset,
|
|
||||||
inputParams.incentivesController,
|
|
||||||
decimals,
|
|
||||||
inputParams.name,
|
|
||||||
inputParams.symbol
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
emit ATokenUpgraded(inputParams.asset, reserveData.aTokenAddress, inputParams.implementation);
|
emit ATokenUpgraded(input.asset, reserveData.aTokenAddress, input.implementation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Updates the stable debt token implementation for the reserve
|
* @dev Updates the stable debt token implementation for the reserve
|
||||||
**/
|
**/
|
||||||
function updateStableDebtToken(UpdateDebtTokenInput calldata inputParams) external onlyPoolAdmin {
|
function updateStableDebtToken(UpdateDebtTokenInput calldata input) external onlyPoolAdmin {
|
||||||
ILendingPool cachedPool = pool;
|
ILendingPool cachedPool = pool;
|
||||||
|
|
||||||
DataTypes.ReserveData memory reserveData = cachedPool.getReserveData(inputParams.asset);
|
DataTypes.ReserveData memory reserveData = cachedPool.getReserveData(input.asset);
|
||||||
|
|
||||||
|
(, , , uint256 decimals, ) = cachedPool.getConfiguration(input.asset).getParamsMemory();
|
||||||
|
|
||||||
DataTypes.ReserveConfigurationMap memory configuration =
|
bytes memory encodedCall = abi.encodeWithSelector(
|
||||||
cachedPool.getConfiguration(inputParams.asset);
|
IInitializableDebtToken.initialize.selector,
|
||||||
|
cachedPool,
|
||||||
(, , , uint256 decimals, ) = configuration.getParamsMemory();
|
input.asset,
|
||||||
|
input.incentivesController,
|
||||||
|
decimals,
|
||||||
|
input.name,
|
||||||
|
input.symbol,
|
||||||
|
input.params
|
||||||
|
);
|
||||||
|
|
||||||
_upgradeTokenImplementation(
|
_upgradeTokenImplementation(
|
||||||
reserveData.stableDebtTokenAddress,
|
reserveData.stableDebtTokenAddress,
|
||||||
inputParams.implementation,
|
input.implementation,
|
||||||
abi.encodeWithSelector(
|
encodedCall
|
||||||
IInitializableDebtToken.initialize.selector,
|
|
||||||
cachedPool,
|
|
||||||
inputParams.asset,
|
|
||||||
inputParams.incentivesController,
|
|
||||||
decimals,
|
|
||||||
inputParams.name,
|
|
||||||
inputParams.symbol
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
emit StableDebtTokenUpgraded(
|
emit StableDebtTokenUpgraded(
|
||||||
inputParams.asset,
|
input.asset,
|
||||||
reserveData.stableDebtTokenAddress,
|
reserveData.stableDebtTokenAddress,
|
||||||
inputParams.implementation
|
input.implementation
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Updates the variable debt token implementation for the asset
|
* @dev Updates the variable debt token implementation for the asset
|
||||||
**/
|
**/
|
||||||
function updateVariableDebtToken(UpdateDebtTokenInput calldata inputParams)
|
function updateVariableDebtToken(UpdateDebtTokenInput calldata input)
|
||||||
external
|
external
|
||||||
onlyPoolAdmin
|
onlyPoolAdmin
|
||||||
{
|
{
|
||||||
ILendingPool cachedPool = pool;
|
ILendingPool cachedPool = pool;
|
||||||
|
|
||||||
DataTypes.ReserveData memory reserveData = cachedPool.getReserveData(inputParams.asset);
|
DataTypes.ReserveData memory reserveData = cachedPool.getReserveData(input.asset);
|
||||||
|
|
||||||
DataTypes.ReserveConfigurationMap memory configuration =
|
(, , , uint256 decimals, ) = cachedPool.getConfiguration(input.asset).getParamsMemory();
|
||||||
cachedPool.getConfiguration(inputParams.asset);
|
|
||||||
|
|
||||||
(, , , uint256 decimals, ) = configuration.getParamsMemory();
|
bytes memory encodedCall = abi.encodeWithSelector(
|
||||||
|
IInitializableDebtToken.initialize.selector,
|
||||||
|
cachedPool,
|
||||||
|
input.asset,
|
||||||
|
input.incentivesController,
|
||||||
|
decimals,
|
||||||
|
input.name,
|
||||||
|
input.symbol,
|
||||||
|
input.params
|
||||||
|
);
|
||||||
|
|
||||||
_upgradeTokenImplementation(
|
_upgradeTokenImplementation(
|
||||||
reserveData.variableDebtTokenAddress,
|
reserveData.variableDebtTokenAddress,
|
||||||
inputParams.implementation,
|
input.implementation,
|
||||||
abi.encodeWithSelector(
|
encodedCall
|
||||||
IInitializableDebtToken.initialize.selector,
|
|
||||||
cachedPool,
|
|
||||||
inputParams.asset,
|
|
||||||
inputParams.incentivesController,
|
|
||||||
decimals,
|
|
||||||
inputParams.name,
|
|
||||||
inputParams.symbol
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
emit VariableDebtTokenUpgraded(
|
emit VariableDebtTokenUpgraded(
|
||||||
inputParams.asset,
|
input.asset,
|
||||||
reserveData.variableDebtTokenAddress,
|
reserveData.variableDebtTokenAddress,
|
||||||
inputParams.implementation
|
input.implementation
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,8 @@ contract AToken is
|
||||||
IAaveIncentivesController incentivesController,
|
IAaveIncentivesController incentivesController,
|
||||||
uint8 aTokenDecimals,
|
uint8 aTokenDecimals,
|
||||||
string calldata aTokenName,
|
string calldata aTokenName,
|
||||||
string calldata aTokenSymbol
|
string calldata aTokenSymbol,
|
||||||
|
bytes calldata params
|
||||||
) external override initializer {
|
) external override initializer {
|
||||||
uint256 chainId;
|
uint256 chainId;
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,8 @@ contract StableDebtToken is IStableDebtToken, DebtTokenBase {
|
||||||
IAaveIncentivesController incentivesController,
|
IAaveIncentivesController incentivesController,
|
||||||
uint8 debtTokenDecimals,
|
uint8 debtTokenDecimals,
|
||||||
string memory debtTokenName,
|
string memory debtTokenName,
|
||||||
string memory debtTokenSymbol
|
string memory debtTokenSymbol,
|
||||||
|
bytes calldata params
|
||||||
) public override initializer {
|
) public override initializer {
|
||||||
_setName(debtTokenName);
|
_setName(debtTokenName);
|
||||||
_setSymbol(debtTokenSymbol);
|
_setSymbol(debtTokenSymbol);
|
||||||
|
|
|
@ -38,7 +38,8 @@ contract VariableDebtToken is DebtTokenBase, IVariableDebtToken {
|
||||||
IAaveIncentivesController incentivesController,
|
IAaveIncentivesController incentivesController,
|
||||||
uint8 debtTokenDecimals,
|
uint8 debtTokenDecimals,
|
||||||
string memory debtTokenName,
|
string memory debtTokenName,
|
||||||
string memory debtTokenSymbol
|
string memory debtTokenSymbol,
|
||||||
|
bytes calldata params
|
||||||
) public override initializer {
|
) public override initializer {
|
||||||
_setName(debtTokenName);
|
_setName(debtTokenName);
|
||||||
_setSymbol(debtTokenSymbol);
|
_setSymbol(debtTokenSymbol);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user