Skip to content

Commit e76882a

Browse files
authored
Merge pull request #320 from aave/docs/319-improve-emodelogic-configuratiorlogic
Improve emodelogic and configuratorlogic natspec
2 parents 86ef1b9 + 8ba8d67 commit e76882a

File tree

5 files changed

+54
-14
lines changed

5 files changed

+54
-14
lines changed

contracts/interfaces/IPoolConfigurator.sol

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,7 @@ interface IPoolConfigurator {
264264
* @param asset The address of the underlying asset of the reserve
265265
* @param enabled True if borrowing needs to be enabled, false otherwise
266266
**/
267-
function setReserveBorrowing(
268-
address asset,
269-
bool enabled
270-
) external;
267+
function setReserveBorrowing(address asset, bool enabled) external;
271268

272269
/**
273270
* @notice Configures the reserve collateralization parameters

contracts/protocol/libraries/logic/ConfiguratorLogic.sol

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ library ConfiguratorLogic {
4848
address indexed implementation
4949
);
5050

51+
/**
52+
* @notice Initialize a reserve by creating and initializing aToken, stable debt token and variable debt token
53+
* @dev Emits the `ReserveInitialized` event
54+
* @param pool The Pool in which the reserve will be initialized
55+
* @param input The needed parameters for the initialization
56+
*/
5157
function executeInitReserve(IPool pool, ConfiguratorInputTypes.InitReserveInput calldata input)
5258
public
5359
{
@@ -120,6 +126,12 @@ library ConfiguratorLogic {
120126
);
121127
}
122128

129+
/**
130+
* @notice Updates the aToken implementation and initializes it
131+
* @dev Emits the `ATokenUpgraded` event
132+
* @param cachedPool The Pool containing the reserve with the aToken
133+
* @param input The parameters needed for the initialize call
134+
*/
123135
function executeUpdateAToken(
124136
IPool cachedPool,
125137
ConfiguratorInputTypes.UpdateATokenInput calldata input
@@ -144,6 +156,12 @@ library ConfiguratorLogic {
144156
emit ATokenUpgraded(input.asset, reserveData.aTokenAddress, input.implementation);
145157
}
146158

159+
/**
160+
* @notice Updates the stable debt token implementation and initializes it
161+
* @dev Emits the `StableDebtTokenUpgraded` event
162+
* @param cachedPool The Pool containing the reserve with the stable debt token
163+
* @param input The parameters needed for the initialize call
164+
*/
147165
function executeUpdateStableDebtToken(
148166
IPool cachedPool,
149167
ConfiguratorInputTypes.UpdateDebtTokenInput calldata input
@@ -175,6 +193,12 @@ library ConfiguratorLogic {
175193
);
176194
}
177195

196+
/**
197+
* @notice Updates the variable debt token implementation and initializes it
198+
* @dev Emits the `VariableDebtTokenUpgraded` event
199+
* @param cachedPool The Pool containing the reserve with the variable debt token
200+
* @param input The parameters needed for the initialize call
201+
*/
178202
function executeUpdateVariableDebtToken(
179203
IPool cachedPool,
180204
ConfiguratorInputTypes.UpdateDebtTokenInput calldata input
@@ -206,6 +230,12 @@ library ConfiguratorLogic {
206230
);
207231
}
208232

233+
/**
234+
* @notice Creates a new proxy and initializes the implementation
235+
* @param implementation The address of the implementation
236+
* @param initParams The parameters that is passed to the implementation to initialize
237+
* @return The address of initialized proxy
238+
*/
209239
function _initTokenWithProxy(address implementation, bytes memory initParams)
210240
internal
211241
returns (address)
@@ -219,6 +249,13 @@ library ConfiguratorLogic {
219249
return address(proxy);
220250
}
221251

252+
/**
253+
* @notice Upgrades the implementation and makes call to the proxy
254+
* @dev In the current plementation the call is used to initialize the new implementation.
255+
* @param proxyAddress The address of the proxy
256+
* @param implementation The address of the new implementation
257+
* @param initParams The parameters to the call after the upgrade
258+
*/
222259
function _upgradeTokenImplementation(
223260
address proxyAddress,
224261
address implementation,

contracts/protocol/libraries/logic/EModeLogic.sol

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@ library EModeLogic {
3030
// See `IPool` for descriptions
3131
event UserEModeSet(address indexed user, uint8 categoryId);
3232

33+
/**
34+
* @notice Updates the user efficiency mode category
35+
* @dev Will revert if user is borrowing non-compatible asset or change will drop HF < HEALTH_FACTOR_LIQUIDATION_THRESHOLD
36+
* @dev Emits the `UserEModeSet` event
37+
* @param reserves The state of all the reserves
38+
* @param reservesList The list of the addresses of all the active reserves
39+
* @param eModeCategories The configuration of all the efficiency mode categories
40+
* @param usersEModeCategory The state of all users efficiency mode category
41+
* @param userConfig The user configuration mapping that tracks the supplied/borrowed assets
42+
* @param params The additional parameters needed to execute the setUserEMode function
43+
*/
3344
function executeSetUserEMode(
3445
mapping(address => DataTypes.ReserveData) storage reserves,
3546
mapping(uint256 => address) storage reservesList,

test-suites/configurator.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => {
326326

327327
it('Activates the ETH reserve for borrowing via risk admin', async () => {
328328
const { configurator, weth, helpersContract, riskAdmin } = testEnv;
329-
expect(
330-
await configurator.connect(riskAdmin.signer).setReserveBorrowing(weth.address, true)
331-
)
329+
expect(await configurator.connect(riskAdmin.signer).setReserveBorrowing(weth.address, true))
332330
.to.emit(configurator, 'ReserveBorrowing')
333331
.withArgs(weth.address, true);
334332

@@ -432,7 +430,9 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => {
432430
it('Disable stable borrow rate on the ETH reserve risk admin', async () => {
433431
const { configurator, helpersContract, weth, riskAdmin } = testEnv;
434432
expect(
435-
await configurator.connect(riskAdmin.signer).setReserveStableRateBorrowing(weth.address, false)
433+
await configurator
434+
.connect(riskAdmin.signer)
435+
.setReserveStableRateBorrowing(weth.address, false)
436436
)
437437
.to.emit(configurator, 'ReserveStableRateBorrowing')
438438
.withArgs(weth.address, false);

test-suites/interest-overflow.spec.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,7 @@ makeSuite('Interest Rate and Index Overflow', (testEnv) => {
134134
inputParams[i].liquidationThreshold,
135135
inputParams[i].liquidationBonus
136136
);
137-
await configurator
138-
.connect(poolAdmin.signer)
139-
.setReserveBorrowing(
140-
inputParams[i].asset,
141-
true
142-
);
137+
await configurator.connect(poolAdmin.signer).setReserveBorrowing(inputParams[i].asset, true);
143138

144139
await configurator
145140
.connect(poolAdmin.signer)

0 commit comments

Comments
 (0)