@shift-defi/strategies 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,822 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.0;
3
+
4
+ import {IPoolAddressesProvider} from "./IPoolAddressesProvider.sol";
5
+ import {DataTypes} from "./DataTypes.sol";
6
+
7
+ /**
8
+ * @title IPool
9
+ * @author Aave
10
+ * @notice Defines the basic interface for an Aave Pool.
11
+ */
12
+ interface IPool {
13
+ /**
14
+ * @dev Emitted on supply()
15
+ * @param reserve The address of the underlying asset of the reserve
16
+ * @param user The address initiating the supply
17
+ * @param onBehalfOf The beneficiary of the supply, receiving the aTokens
18
+ * @param amount The amount supplied
19
+ * @param referralCode The referral code used
20
+ */
21
+ event Supply(
22
+ address indexed reserve,
23
+ address user,
24
+ address indexed onBehalfOf,
25
+ uint256 amount,
26
+ uint16 indexed referralCode
27
+ );
28
+
29
+ /**
30
+ * @dev Emitted on withdraw()
31
+ * @param reserve The address of the underlying asset being withdrawn
32
+ * @param user The address initiating the withdrawal, owner of aTokens
33
+ * @param to The address that will receive the underlying
34
+ * @param amount The amount to be withdrawn
35
+ */
36
+ event Withdraw(address indexed reserve, address indexed user, address indexed to, uint256 amount);
37
+
38
+ /**
39
+ * @dev Emitted on borrow() and flashLoan() when debt needs to be opened
40
+ * @param reserve The address of the underlying asset being borrowed
41
+ * @param user The address of the user initiating the borrow(), receiving the funds on borrow() or just
42
+ * initiator of the transaction on flashLoan()
43
+ * @param onBehalfOf The address that will be getting the debt
44
+ * @param amount The amount borrowed out
45
+ * @param interestRateMode The rate mode: 2 for Variable, 1 is deprecated (changed on v3.2.0)
46
+ * @param borrowRate The numeric rate at which the user has borrowed, expressed in ray
47
+ * @param referralCode The referral code used
48
+ */
49
+ event Borrow(
50
+ address indexed reserve,
51
+ address user,
52
+ address indexed onBehalfOf,
53
+ uint256 amount,
54
+ DataTypes.InterestRateMode interestRateMode,
55
+ uint256 borrowRate,
56
+ uint16 indexed referralCode
57
+ );
58
+
59
+ /**
60
+ * @dev Emitted on repay()
61
+ * @param reserve The address of the underlying asset of the reserve
62
+ * @param user The beneficiary of the repayment, getting his debt reduced
63
+ * @param repayer The address of the user initiating the repay(), providing the funds
64
+ * @param amount The amount repaid
65
+ * @param useATokens True if the repayment is done using aTokens, `false` if done with underlying asset directly
66
+ */
67
+ event Repay(
68
+ address indexed reserve,
69
+ address indexed user,
70
+ address indexed repayer,
71
+ uint256 amount,
72
+ bool useATokens
73
+ );
74
+
75
+ /**
76
+ * @dev Emitted on borrow(), repay() and liquidationCall() when using isolated assets
77
+ * @param asset The address of the underlying asset of the reserve
78
+ * @param totalDebt The total isolation mode debt for the reserve
79
+ */
80
+ event IsolationModeTotalDebtUpdated(address indexed asset, uint256 totalDebt);
81
+
82
+ /**
83
+ * @dev Emitted when the user selects a certain asset category for eMode
84
+ * @param user The address of the user
85
+ * @param categoryId The category id
86
+ */
87
+ event UserEModeSet(address indexed user, uint8 categoryId);
88
+
89
+ /**
90
+ * @dev Emitted on setUserUseReserveAsCollateral()
91
+ * @param reserve The address of the underlying asset of the reserve
92
+ * @param user The address of the user enabling the usage as collateral
93
+ */
94
+ event ReserveUsedAsCollateralEnabled(address indexed reserve, address indexed user);
95
+
96
+ /**
97
+ * @dev Emitted on setUserUseReserveAsCollateral()
98
+ * @param reserve The address of the underlying asset of the reserve
99
+ * @param user The address of the user enabling the usage as collateral
100
+ */
101
+ event ReserveUsedAsCollateralDisabled(address indexed reserve, address indexed user);
102
+
103
+ /**
104
+ * @dev Emitted on flashLoan()
105
+ * @param target The address of the flash loan receiver contract
106
+ * @param initiator The address initiating the flash loan
107
+ * @param asset The address of the asset being flash borrowed
108
+ * @param amount The amount flash borrowed
109
+ * @param interestRateMode The flashloan mode: 0 for regular flashloan,
110
+ * 1 for Stable (Deprecated on v3.2.0), 2 for Variable
111
+ * @param premium The fee flash borrowed
112
+ * @param referralCode The referral code used
113
+ */
114
+ event FlashLoan(
115
+ address indexed target,
116
+ address initiator,
117
+ address indexed asset,
118
+ uint256 amount,
119
+ DataTypes.InterestRateMode interestRateMode,
120
+ uint256 premium,
121
+ uint16 indexed referralCode
122
+ );
123
+
124
+ /**
125
+ * @dev Emitted when a borrower is liquidated.
126
+ * @param collateralAsset The address of the underlying asset used as collateral, to receive as result of the liquidation
127
+ * @param debtAsset The address of the underlying borrowed asset to be repaid with the liquidation
128
+ * @param user The address of the borrower getting liquidated
129
+ * @param debtToCover The debt amount of borrowed `asset` the liquidator wants to cover
130
+ * @param liquidatedCollateralAmount The amount of collateral received by the liquidator
131
+ * @param liquidator The address of the liquidator
132
+ * @param receiveAToken True if the liquidators wants to receive the collateral aTokens, `false` if he wants
133
+ * to receive the underlying collateral asset directly
134
+ */
135
+ event LiquidationCall(
136
+ address indexed collateralAsset,
137
+ address indexed debtAsset,
138
+ address indexed user,
139
+ uint256 debtToCover,
140
+ uint256 liquidatedCollateralAmount,
141
+ address liquidator,
142
+ bool receiveAToken
143
+ );
144
+
145
+ /**
146
+ * @dev Emitted when the state of a reserve is updated.
147
+ * @param reserve The address of the underlying asset of the reserve
148
+ * @param liquidityRate The next liquidity rate
149
+ * @param stableBorrowRate The next stable borrow rate @note deprecated on v3.2.0
150
+ * @param variableBorrowRate The next variable borrow rate
151
+ * @param liquidityIndex The next liquidity index
152
+ * @param variableBorrowIndex The next variable borrow index
153
+ */
154
+ event ReserveDataUpdated(
155
+ address indexed reserve,
156
+ uint256 liquidityRate,
157
+ uint256 stableBorrowRate,
158
+ uint256 variableBorrowRate,
159
+ uint256 liquidityIndex,
160
+ uint256 variableBorrowIndex
161
+ );
162
+
163
+ /**
164
+ * @dev Emitted when the deficit of a reserve is covered.
165
+ * @param reserve The address of the underlying asset of the reserve
166
+ * @param caller The caller that triggered the DeficitCovered event
167
+ * @param amountCovered The amount of deficit covered
168
+ */
169
+ event DeficitCovered(address indexed reserve, address caller, uint256 amountCovered);
170
+
171
+ /**
172
+ * @dev Emitted when the protocol treasury receives minted aTokens from the accrued interest.
173
+ * @param reserve The address of the reserve
174
+ * @param amountMinted The amount minted to the treasury
175
+ */
176
+ event MintedToTreasury(address indexed reserve, uint256 amountMinted);
177
+
178
+ /**
179
+ * @dev Emitted when deficit is realized on a liquidation.
180
+ * @param user The user address where the bad debt will be burned
181
+ * @param debtAsset The address of the underlying borrowed asset to be burned
182
+ * @param amountCreated The amount of deficit created
183
+ */
184
+ event DeficitCreated(address indexed user, address indexed debtAsset, uint256 amountCreated);
185
+
186
+ /**
187
+ * @dev Emitted when a position manager is approved by the user.
188
+ * @param user The user address
189
+ * @param positionManager The address of the position manager
190
+ */
191
+ event PositionManagerApproved(address indexed user, address indexed positionManager);
192
+
193
+ /**
194
+ * @dev Emitted when a position manager is revoked by the user.
195
+ * @param user The user address
196
+ * @param positionManager The address of the position manager
197
+ */
198
+ event PositionManagerRevoked(address indexed user, address indexed positionManager);
199
+
200
+ /**
201
+ * @notice Supplies an `amount` of underlying asset into the reserve, receiving in return overlying aTokens.
202
+ * - E.g. User supplies 100 USDC and gets in return 100 aUSDC
203
+ * @param asset The address of the underlying asset to supply
204
+ * @param amount The amount to be supplied
205
+ * @param onBehalfOf The address that will receive the aTokens, same as msg.sender if the user
206
+ * wants to receive them on his own wallet, or a different address if the beneficiary of aTokens
207
+ * is a different wallet
208
+ * @param referralCode Code used to register the integrator originating the operation, for potential rewards.
209
+ * 0 if the action is executed directly by the user, without any middle-man
210
+ */
211
+ function supply(address asset, uint256 amount, address onBehalfOf, uint16 referralCode) external;
212
+
213
+ /**
214
+ * @notice Supply with transfer approval of asset to be supplied done via permit function
215
+ * see: https://eips.ethereum.org/EIPS/eip-2612 and https://eips.ethereum.org/EIPS/eip-713
216
+ * @param asset The address of the underlying asset to supply
217
+ * @param amount The amount to be supplied
218
+ * @param onBehalfOf The address that will receive the aTokens, same as msg.sender if the user
219
+ * wants to receive them on his own wallet, or a different address if the beneficiary of aTokens
220
+ * is a different wallet
221
+ * @param deadline The deadline timestamp that the permit is valid
222
+ * @param referralCode Code used to register the integrator originating the operation, for potential rewards.
223
+ * 0 if the action is executed directly by the user, without any middle-man
224
+ * @param permitV The V parameter of ERC712 permit sig
225
+ * @param permitR The R parameter of ERC712 permit sig
226
+ * @param permitS The S parameter of ERC712 permit sig
227
+ */
228
+ function supplyWithPermit(
229
+ address asset,
230
+ uint256 amount,
231
+ address onBehalfOf,
232
+ uint16 referralCode,
233
+ uint256 deadline,
234
+ uint8 permitV,
235
+ bytes32 permitR,
236
+ bytes32 permitS
237
+ ) external;
238
+
239
+ /**
240
+ * @notice Withdraws an `amount` of underlying asset from the reserve, burning the equivalent aTokens owned
241
+ * E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC
242
+ * @param asset The address of the underlying asset to withdraw
243
+ * @param amount The underlying amount to be withdrawn
244
+ * - Send the value type(uint256).max in order to withdraw the whole aToken balance
245
+ * @param to The address that will receive the underlying, same as msg.sender if the user
246
+ * wants to receive it on his own wallet, or a different address if the beneficiary is a
247
+ * different wallet
248
+ * @return The final amount withdrawn
249
+ */
250
+ function withdraw(address asset, uint256 amount, address to) external returns (uint256);
251
+
252
+ /**
253
+ * @notice Allows users to borrow a specific `amount` of the reserve underlying asset, provided that the borrower
254
+ * already supplied enough collateral, or he was given enough allowance by a credit delegator on the VariableDebtToken
255
+ * - E.g. User borrows 100 USDC passing as `onBehalfOf` his own address, receiving the 100 USDC in his wallet
256
+ * and 100 variable debt tokens
257
+ * @param asset The address of the underlying asset to borrow
258
+ * @param amount The amount to be borrowed
259
+ * @param interestRateMode 2 for Variable, 1 is deprecated on v3.2.0
260
+ * @param referralCode The code used to register the integrator originating the operation, for potential rewards.
261
+ * 0 if the action is executed directly by the user, without any middle-man
262
+ * @param onBehalfOf The address of the user who will receive the debt. Should be the address of the borrower itself
263
+ * calling the function if he wants to borrow against his own collateral, or the address of the credit delegator
264
+ * if he has been given credit delegation allowance
265
+ */
266
+ function borrow(
267
+ address asset,
268
+ uint256 amount,
269
+ uint256 interestRateMode,
270
+ uint16 referralCode,
271
+ address onBehalfOf
272
+ ) external;
273
+
274
+ /**
275
+ * @notice Repays a borrowed `amount` on a specific reserve, burning the equivalent debt tokens owned
276
+ * - E.g. User repays 100 USDC, burning 100 variable debt tokens of the `onBehalfOf` address
277
+ * @param asset The address of the borrowed underlying asset previously borrowed
278
+ * @param amount The amount to repay
279
+ * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode`
280
+ * @param interestRateMode 2 for Variable, 1 is deprecated on v3.2.0
281
+ * @param onBehalfOf The address of the user who will get his debt reduced/removed. Should be the address of the
282
+ * user calling the function if he wants to reduce/remove his own debt, or the address of any other
283
+ * other borrower whose debt should be removed
284
+ * @return The final amount repaid
285
+ */
286
+ function repay(
287
+ address asset,
288
+ uint256 amount,
289
+ uint256 interestRateMode,
290
+ address onBehalfOf
291
+ ) external returns (uint256);
292
+
293
+ /**
294
+ * @notice Repay with transfer approval of asset to be repaid done via permit function
295
+ * see: https://eips.ethereum.org/EIPS/eip-2612 and https://eips.ethereum.org/EIPS/eip-713
296
+ * @param asset The address of the borrowed underlying asset previously borrowed
297
+ * @param amount The amount to repay
298
+ * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode`
299
+ * @param interestRateMode 2 for Variable, 1 is deprecated on v3.2.0
300
+ * @param onBehalfOf Address of the user who will get his debt reduced/removed. Should be the address of the
301
+ * user calling the function if he wants to reduce/remove his own debt, or the address of any other
302
+ * other borrower whose debt should be removed
303
+ * @param deadline The deadline timestamp that the permit is valid
304
+ * @param permitV The V parameter of ERC712 permit sig
305
+ * @param permitR The R parameter of ERC712 permit sig
306
+ * @param permitS The S parameter of ERC712 permit sig
307
+ * @return The final amount repaid
308
+ */
309
+ function repayWithPermit(
310
+ address asset,
311
+ uint256 amount,
312
+ uint256 interestRateMode,
313
+ address onBehalfOf,
314
+ uint256 deadline,
315
+ uint8 permitV,
316
+ bytes32 permitR,
317
+ bytes32 permitS
318
+ ) external returns (uint256);
319
+
320
+ /**
321
+ * @notice Repays a borrowed `amount` on a specific reserve using the reserve aTokens, burning the
322
+ * equivalent debt tokens
323
+ * - E.g. User repays 100 USDC using 100 aUSDC, burning 100 variable debt tokens
324
+ * @dev Passing uint256.max as amount will clean up any residual aToken dust balance, if the user aToken
325
+ * balance is not enough to cover the whole debt
326
+ * @param asset The address of the borrowed underlying asset previously borrowed
327
+ * @param amount The amount to repay
328
+ * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode`
329
+ * @param interestRateMode DEPRECATED in v3.2.0
330
+ * @return The final amount repaid
331
+ */
332
+ function repayWithATokens(address asset, uint256 amount, uint256 interestRateMode) external returns (uint256);
333
+
334
+ /**
335
+ * @notice Allows suppliers to enable/disable a specific supplied asset as collateral
336
+ * @param asset The address of the underlying asset supplied
337
+ * @param useAsCollateral True if the user wants to use the supply as collateral, false otherwise
338
+ */
339
+ function setUserUseReserveAsCollateral(address asset, bool useAsCollateral) external;
340
+
341
+ /**
342
+ * @notice Function to liquidate a non-healthy position collateral-wise, with Health Factor below 1
343
+ * - The caller (liquidator) covers `debtToCover` amount of debt of the user getting liquidated, and receives
344
+ * a proportionally amount of the `collateralAsset` plus a bonus to cover market risk
345
+ * @param collateralAsset The address of the underlying asset used as collateral, to receive as result of the liquidation
346
+ * @param debtAsset The address of the underlying borrowed asset to be repaid with the liquidation
347
+ * @param borrower The address of the borrower getting liquidated
348
+ * @param debtToCover The debt amount of borrowed `asset` the liquidator wants to cover
349
+ * @param receiveAToken True if the liquidators wants to receive the collateral aTokens, `false` if he wants
350
+ * to receive the underlying collateral asset directly
351
+ */
352
+ function liquidationCall(
353
+ address collateralAsset,
354
+ address debtAsset,
355
+ address borrower,
356
+ uint256 debtToCover,
357
+ bool receiveAToken
358
+ ) external;
359
+
360
+ /**
361
+ * @notice Allows smartcontracts to access the liquidity of the pool within one transaction,
362
+ * as long as the amount taken plus a fee is returned.
363
+ * @dev IMPORTANT There are security concerns for developers of flashloan receiver contracts that must be kept
364
+ * into consideration. For further details please visit https://docs.aave.com/developers/
365
+ * @param receiverAddress The address of the contract receiving the funds, implementing IFlashLoanReceiver interface
366
+ * @param assets The addresses of the assets being flash-borrowed
367
+ * @param amounts The amounts of the assets being flash-borrowed
368
+ * @param interestRateModes Types of the debt to open if the flash loan is not returned:
369
+ * 0 -> Don't open any debt, just revert if funds can't be transferred from the receiver
370
+ * 1 -> Deprecated on v3.2.0
371
+ * 2 -> Open debt at variable rate for the value of the amount flash-borrowed to the `onBehalfOf` address
372
+ * @param onBehalfOf The address that will receive the debt in the case of using 2 on `modes`
373
+ * @param params Variadic packed params to pass to the receiver as extra information
374
+ * @param referralCode The code used to register the integrator originating the operation, for potential rewards.
375
+ * 0 if the action is executed directly by the user, without any middle-man
376
+ */
377
+ function flashLoan(
378
+ address receiverAddress,
379
+ address[] calldata assets,
380
+ uint256[] calldata amounts,
381
+ uint256[] calldata interestRateModes,
382
+ address onBehalfOf,
383
+ bytes calldata params,
384
+ uint16 referralCode
385
+ ) external;
386
+
387
+ /**
388
+ * @notice Allows smartcontracts to access the liquidity of the pool within one transaction,
389
+ * as long as the amount taken plus a fee is returned.
390
+ * @dev IMPORTANT There are security concerns for developers of flashloan receiver contracts that must be kept
391
+ * into consideration. For further details please visit https://docs.aave.com/developers/
392
+ * @param receiverAddress The address of the contract receiving the funds, implementing IFlashLoanSimpleReceiver interface
393
+ * @param asset The address of the asset being flash-borrowed
394
+ * @param amount The amount of the asset being flash-borrowed
395
+ * @param params Variadic packed params to pass to the receiver as extra information
396
+ * @param referralCode The code used to register the integrator originating the operation, for potential rewards.
397
+ * 0 if the action is executed directly by the user, without any middle-man
398
+ */
399
+ function flashLoanSimple(
400
+ address receiverAddress,
401
+ address asset,
402
+ uint256 amount,
403
+ bytes calldata params,
404
+ uint16 referralCode
405
+ ) external;
406
+
407
+ /**
408
+ * @notice Returns the user account data across all the reserves
409
+ * @param user The address of the user
410
+ * @return totalCollateralBase The total collateral of the user in the base currency used by the price feed
411
+ * @return totalDebtBase The total debt of the user in the base currency used by the price feed
412
+ * @return availableBorrowsBase The borrowing power left of the user in the base currency used by the price feed
413
+ * @return currentLiquidationThreshold The liquidation threshold of the user
414
+ * @return ltv The loan to value of The user
415
+ * @return healthFactor The current health factor of the user
416
+ */
417
+ function getUserAccountData(
418
+ address user
419
+ )
420
+ external
421
+ view
422
+ returns (
423
+ uint256 totalCollateralBase,
424
+ uint256 totalDebtBase,
425
+ uint256 availableBorrowsBase,
426
+ uint256 currentLiquidationThreshold,
427
+ uint256 ltv,
428
+ uint256 healthFactor
429
+ );
430
+
431
+ /**
432
+ * @notice Initializes a reserve, activating it, assigning an aToken and debt tokens
433
+ * @dev Only callable by the PoolConfigurator contract
434
+ * @param asset The address of the underlying asset of the reserve
435
+ * @param aTokenAddress The address of the aToken that will be assigned to the reserve
436
+ * @param variableDebtAddress The address of the VariableDebtToken that will be assigned to the reserve
437
+ */
438
+ function initReserve(address asset, address aTokenAddress, address variableDebtAddress) external;
439
+
440
+ /**
441
+ * @notice Drop a reserve
442
+ * @dev Only callable by the PoolConfigurator contract
443
+ * @dev Does not reset eMode flags, which must be considered when reusing the same reserve id for a different reserve.
444
+ * @param asset The address of the underlying asset of the reserve
445
+ */
446
+ function dropReserve(address asset) external;
447
+
448
+ /**
449
+ * @notice Accumulates interest to all indexes of the reserve
450
+ * @dev Only callable by the PoolConfigurator contract
451
+ * @dev To be used when required by the configurator, for example when updating interest rates strategy data
452
+ * @param asset The address of the underlying asset of the reserve
453
+ */
454
+ function syncIndexesState(address asset) external;
455
+
456
+ /**
457
+ * @notice Updates interest rates on the reserve data
458
+ * @dev Only callable by the PoolConfigurator contract
459
+ * @dev To be used when required by the configurator, for example when updating interest rates strategy data
460
+ * @param asset The address of the underlying asset of the reserve
461
+ */
462
+ function syncRatesState(address asset) external;
463
+
464
+ /**
465
+ * @notice Sets the configuration bitmap of the reserve as a whole
466
+ * @dev Only callable by the PoolConfigurator contract
467
+ * @param asset The address of the underlying asset of the reserve
468
+ * @param configuration The new configuration bitmap
469
+ */
470
+ function setConfiguration(address asset, DataTypes.ReserveConfigurationMap calldata configuration) external;
471
+
472
+ /**
473
+ * @notice Returns the configuration of the reserve
474
+ * @param asset The address of the underlying asset of the reserve
475
+ * @return The configuration of the reserve
476
+ */
477
+ function getConfiguration(address asset) external view returns (DataTypes.ReserveConfigurationMap memory);
478
+
479
+ /**
480
+ * @notice Returns the configuration of the user across all the reserves
481
+ * @param user The user address
482
+ * @return The configuration of the user
483
+ */
484
+ function getUserConfiguration(address user) external view returns (DataTypes.UserConfigurationMap memory);
485
+
486
+ /**
487
+ * @notice Returns the normalized income of the reserve
488
+ * @param asset The address of the underlying asset of the reserve
489
+ * @return The reserve's normalized income
490
+ */
491
+ function getReserveNormalizedIncome(address asset) external view returns (uint256);
492
+
493
+ /**
494
+ * @notice Returns the normalized variable debt per unit of asset
495
+ * @dev WARNING: This function is intended to be used primarily by the protocol itself to get a
496
+ * "dynamic" variable index based on time, current stored index and virtual rate at the current
497
+ * moment (approx. a borrower would get if opening a position). This means that is always used in
498
+ * combination with variable debt supply/balances.
499
+ * If using this function externally, consider that is possible to have an increasing normalized
500
+ * variable debt that is not equivalent to how the variable debt index would be updated in storage
501
+ * (e.g. only updates with non-zero variable debt supply)
502
+ * @param asset The address of the underlying asset of the reserve
503
+ * @return The reserve normalized variable debt
504
+ */
505
+ function getReserveNormalizedVariableDebt(address asset) external view returns (uint256);
506
+
507
+ /**
508
+ * @notice Returns the state and configuration of the reserve
509
+ * @param asset The address of the underlying asset of the reserve
510
+ * @return The state and configuration data of the reserve
511
+ */
512
+ function getReserveData(address asset) external view returns (DataTypes.ReserveDataLegacy memory);
513
+
514
+ /**
515
+ * @notice Returns the virtual underlying balance of the reserve
516
+ * @param asset The address of the underlying asset of the reserve
517
+ * @return The reserve virtual underlying balance
518
+ */
519
+ function getVirtualUnderlyingBalance(address asset) external view returns (uint128);
520
+
521
+ /**
522
+ * @notice Validates and finalizes an aToken transfer
523
+ * @dev Only callable by the overlying aToken of the `asset`
524
+ * @param asset The address of the underlying asset of the aToken
525
+ * @param from The user from which the aTokens are transferred
526
+ * @param to The user receiving the aTokens
527
+ * @param scaledAmount The scaled amount being transferred/withdrawn
528
+ * @param scaledBalanceFromBefore The aToken scaled balance of the `from` user before the transfer
529
+ * @param scaledBalanceToBefore The aToken scaled balance of the `to` user before the transfer
530
+ */
531
+ function finalizeTransfer(
532
+ address asset,
533
+ address from,
534
+ address to,
535
+ uint256 scaledAmount,
536
+ uint256 scaledBalanceFromBefore,
537
+ uint256 scaledBalanceToBefore
538
+ ) external;
539
+
540
+ /**
541
+ * @notice Returns the list of the underlying assets of all the initialized reserves
542
+ * @dev It does not include dropped reserves
543
+ * @return The addresses of the underlying assets of the initialized reserves
544
+ */
545
+ function getReservesList() external view returns (address[] memory);
546
+
547
+ /**
548
+ * @notice Returns the number of initialized reserves
549
+ * @dev It includes dropped reserves
550
+ * @return The count
551
+ */
552
+ function getReservesCount() external view returns (uint256);
553
+
554
+ /**
555
+ * @notice Returns the address of the underlying asset of a reserve by the reserve id as stored in the DataTypes.ReserveData struct
556
+ * @param id The id of the reserve as stored in the DataTypes.ReserveData struct
557
+ * @return The address of the reserve associated with id
558
+ */
559
+ function getReserveAddressById(uint16 id) external view returns (address);
560
+
561
+ /**
562
+ * @notice Returns the PoolAddressesProvider connected to this contract
563
+ * @return The address of the PoolAddressesProvider
564
+ */
565
+ function ADDRESSES_PROVIDER() external view returns (IPoolAddressesProvider);
566
+
567
+ /**
568
+ * @notice Returns the ReserveInterestRateStrategy connected to all the reserves
569
+ * @return The address of the ReserveInterestRateStrategy contract
570
+ */
571
+ function RESERVE_INTEREST_RATE_STRATEGY() external view returns (address);
572
+
573
+ /**
574
+ * @notice Updates flash loan premium. All this premium is collected by the protocol treasury.
575
+ * @dev The premium is calculated on the total borrowed amount
576
+ * @dev Only callable by the PoolConfigurator contract
577
+ * @param flashLoanPremium The flash loan premium, expressed in bps
578
+ */
579
+ function updateFlashloanPremium(uint128 flashLoanPremium) external;
580
+
581
+ /**
582
+ * @notice Configures a new or alters an existing collateral configuration of an eMode.
583
+ * @dev In eMode, the protocol allows very high borrowing power to borrow assets of the same category.
584
+ * The category 0 is reserved as it's the default for volatile assets
585
+ * @param id The id of the category
586
+ * @param config The configuration of the category
587
+ */
588
+ function configureEModeCategory(uint8 id, DataTypes.EModeCategoryBaseConfiguration memory config) external;
589
+
590
+ /**
591
+ * @notice Replaces the current eMode collateralBitmap.
592
+ * @param id The id of the category
593
+ * @param collateralBitmap The collateralBitmap of the category
594
+ */
595
+ function configureEModeCategoryCollateralBitmap(uint8 id, uint128 collateralBitmap) external;
596
+
597
+ /**
598
+ * @notice Replaces the current eMode borrowableBitmap.
599
+ * @param id The id of the category
600
+ * @param borrowableBitmap The borrowableBitmap of the category
601
+ */
602
+ function configureEModeCategoryBorrowableBitmap(uint8 id, uint128 borrowableBitmap) external;
603
+
604
+ /**
605
+ * @notice Returns the data of an eMode category
606
+ * @dev DEPRECATED use independent getters instead
607
+ * @param id The id of the category
608
+ * @return The configuration data of the category
609
+ */
610
+ function getEModeCategoryData(uint8 id) external view returns (DataTypes.EModeCategoryLegacy memory);
611
+
612
+ /**
613
+ * @notice Returns the label of an eMode category
614
+ * @param id The id of the category
615
+ * @return The label of the category
616
+ */
617
+ function getEModeCategoryLabel(uint8 id) external view returns (string memory);
618
+
619
+ /**
620
+ * @notice Returns the collateral config of an eMode category
621
+ * @param id The id of the category
622
+ * @return The ltv,lt,lb of the category
623
+ */
624
+ function getEModeCategoryCollateralConfig(uint8 id) external view returns (DataTypes.CollateralConfig memory);
625
+
626
+ /**
627
+ * @notice Returns the collateralBitmap of an eMode category
628
+ * @param id The id of the category
629
+ * @return The collateralBitmap of the category
630
+ */
631
+ function getEModeCategoryCollateralBitmap(uint8 id) external view returns (uint128);
632
+
633
+ /**
634
+ * @notice Returns the borrowableBitmap of an eMode category
635
+ * @param id The id of the category
636
+ * @return The borrowableBitmap of the category
637
+ */
638
+ function getEModeCategoryBorrowableBitmap(uint8 id) external view returns (uint128);
639
+
640
+ /**
641
+ * @notice Allows a user to use the protocol in eMode
642
+ * @param categoryId The id of the category
643
+ */
644
+ function setUserEMode(uint8 categoryId) external;
645
+
646
+ /**
647
+ * @notice Returns the eMode the user is using
648
+ * @param user The address of the user
649
+ * @return The eMode id
650
+ */
651
+ function getUserEMode(address user) external view returns (uint256);
652
+
653
+ /**
654
+ * @notice Resets the isolation mode total debt of the given asset to zero
655
+ * @dev It requires the given asset has zero debt ceiling
656
+ * @param asset The address of the underlying asset to reset the isolationModeTotalDebt
657
+ */
658
+ function resetIsolationModeTotalDebt(address asset) external;
659
+
660
+ /**
661
+ * @notice Sets the liquidation grace period of the given asset
662
+ * @dev To enable a liquidation grace period, a timestamp in the future should be set,
663
+ * To disable a liquidation grace period, any timestamp in the past works, like 0
664
+ * @param asset The address of the underlying asset to set the liquidationGracePeriod
665
+ * @param until Timestamp when the liquidation grace period will end
666
+ **/
667
+ function setLiquidationGracePeriod(address asset, uint40 until) external;
668
+
669
+ /**
670
+ * @notice Returns the liquidation grace period of the given asset
671
+ * @param asset The address of the underlying asset
672
+ * @return Timestamp when the liquidation grace period will end
673
+ **/
674
+ function getLiquidationGracePeriod(address asset) external view returns (uint40);
675
+
676
+ /**
677
+ * @notice Returns the total fee on flash loans.
678
+ * @dev From v3.4 all flashloan fees will be send to the treasury.
679
+ * @return The total fee on flashloans
680
+ */
681
+ function FLASHLOAN_PREMIUM_TOTAL() external view returns (uint128);
682
+
683
+ /**
684
+ * @notice Returns the part of the flashloan fees sent to protocol
685
+ * @dev From v3.4 all flashloan fees will be send to the treasury and this value
686
+ * is always 100_00.
687
+ * @return The flashloan fee sent to the protocol treasury
688
+ */
689
+ function FLASHLOAN_PREMIUM_TO_PROTOCOL() external view returns (uint128);
690
+
691
+ /**
692
+ * @notice Returns the maximum number of reserves supported to be listed in this Pool
693
+ * @return The maximum number of reserves supported
694
+ */
695
+ function MAX_NUMBER_RESERVES() external view returns (uint16);
696
+
697
+ /**
698
+ * @notice Mints the assets accrued through the reserve factor to the treasury in the form of aTokens
699
+ * @param assets The list of reserves for which the minting needs to be executed
700
+ */
701
+ function mintToTreasury(address[] calldata assets) external;
702
+
703
+ /**
704
+ * @notice Rescue and transfer tokens locked in this contract
705
+ * @param token The address of the token
706
+ * @param to The address of the recipient
707
+ * @param amount The amount of token to transfer
708
+ */
709
+ function rescueTokens(address token, address to, uint256 amount) external;
710
+
711
+ /**
712
+ * @notice Supplies an `amount` of underlying asset into the reserve, receiving in return overlying aTokens.
713
+ * - E.g. User supplies 100 USDC and gets in return 100 aUSDC
714
+ * @dev Deprecated: Use the `supply` function instead
715
+ * @param asset The address of the underlying asset to supply
716
+ * @param amount The amount to be supplied
717
+ * @param onBehalfOf The address that will receive the aTokens, same as msg.sender if the user
718
+ * wants to receive them on his own wallet, or a different address if the beneficiary of aTokens
719
+ * is a different wallet
720
+ * @param referralCode Code used to register the integrator originating the operation, for potential rewards.
721
+ * 0 if the action is executed directly by the user, without any middle-man
722
+ */
723
+ function deposit(address asset, uint256 amount, address onBehalfOf, uint16 referralCode) external;
724
+
725
+ /**
726
+ * @notice It covers the deficit of a specified reserve by burning the equivalent aToken `amount` for assets
727
+ * @dev The deficit of a reserve can occur due to situations where borrowed assets are not repaid, leading to bad debt.
728
+ * @param asset The address of the underlying asset to cover the deficit.
729
+ * @param amount The amount to be covered, in aToken
730
+ * @return The amount of tokens burned
731
+ */
732
+ function eliminateReserveDeficit(address asset, uint256 amount) external returns (uint256);
733
+
734
+ /**
735
+ * @notice Approves or disapproves a position manager. This position manager will be able
736
+ * to call the `setUserUseReserveAsCollateralOnBehalfOf` and the
737
+ * `setUserEModeOnBehalfOf` function on behalf of the user.
738
+ * @param positionManager The address of the position manager
739
+ * @param approve True if the position manager should be approved, false otherwise
740
+ */
741
+ function approvePositionManager(address positionManager, bool approve) external;
742
+
743
+ /**
744
+ * @notice Renounces a position manager role for a given user.
745
+ * @param user The address of the user
746
+ */
747
+ function renouncePositionManagerRole(address user) external;
748
+
749
+ /**
750
+ * @notice Sets the use as collateral flag for the user on the specific reserve on behalf of the user.
751
+ * @param asset The address of the underlying asset of the reserve
752
+ * @param useAsCollateral True if the user wants to use the reserve as collateral, false otherwise
753
+ * @param onBehalfOf The address of the user
754
+ */
755
+ function setUserUseReserveAsCollateralOnBehalfOf(address asset, bool useAsCollateral, address onBehalfOf) external;
756
+
757
+ /**
758
+ * @notice Sets the eMode category for the user on the specific reserve on behalf of the user.
759
+ * @param categoryId The id of the category
760
+ * @param onBehalfOf The address of the user
761
+ */
762
+ function setUserEModeOnBehalfOf(uint8 categoryId, address onBehalfOf) external;
763
+
764
+ /*
765
+ * @notice Returns true if the `positionManager` address is approved to use the position manager role on behalf of the user.
766
+ * @param user The address of the user
767
+ * @param positionManager The address of the position manager
768
+ * @return True if the user is approved to use the position manager, false otherwise
769
+ */
770
+ function isApprovedPositionManager(address user, address positionManager) external view returns (bool);
771
+
772
+ /**
773
+ * @notice Returns the current deficit of a reserve.
774
+ * @param asset The address of the underlying asset of the reserve
775
+ * @return The current deficit of the reserve
776
+ */
777
+ function getReserveDeficit(address asset) external view returns (uint256);
778
+
779
+ /**
780
+ * @notice Returns the aToken address of a reserve.
781
+ * @param asset The address of the underlying asset of the reserve
782
+ * @return The address of the aToken
783
+ */
784
+ function getReserveAToken(address asset) external view returns (address);
785
+
786
+ /**
787
+ * @notice Returns the variableDebtToken address of a reserve.
788
+ * @param asset The address of the underlying asset of the reserve
789
+ * @return The address of the variableDebtToken
790
+ */
791
+ function getReserveVariableDebtToken(address asset) external view returns (address);
792
+
793
+ /**
794
+ * @notice Gets the address of the external FlashLoanLogic
795
+ */
796
+ function getFlashLoanLogic() external view returns (address);
797
+
798
+ /**
799
+ * @notice Gets the address of the external BorrowLogic
800
+ */
801
+ function getBorrowLogic() external view returns (address);
802
+
803
+ /**
804
+ * @notice Gets the address of the external EModeLogic
805
+ */
806
+ function getEModeLogic() external view returns (address);
807
+
808
+ /**
809
+ * @notice Gets the address of the external LiquidationLogic
810
+ */
811
+ function getLiquidationLogic() external view returns (address);
812
+
813
+ /**
814
+ * @notice Gets the address of the external PoolLogic
815
+ */
816
+ function getPoolLogic() external view returns (address);
817
+
818
+ /**
819
+ * @notice Gets the address of the external SupplyLogic
820
+ */
821
+ function getSupplyLogic() external view returns (address);
822
+ }