@bgd-labs/aave-address-book 1.1.1

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.
Files changed (115) hide show
  1. package/.gitmodules +4 -0
  2. package/CHANGELOG.md +56 -0
  3. package/LICENSE +7 -0
  4. package/README.md +94 -0
  5. package/addressbook_logo.png +0 -0
  6. package/dist/AaveAddressBook.d.ts +17 -0
  7. package/dist/AaveAddressBook.js +20 -0
  8. package/dist/AaveV2Avalanche.d.ts +9 -0
  9. package/dist/AaveV2Avalanche.js +12 -0
  10. package/dist/AaveV2Ethereum.d.ts +9 -0
  11. package/dist/AaveV2Ethereum.js +12 -0
  12. package/dist/AaveV2EthereumAMM.d.ts +9 -0
  13. package/dist/AaveV2EthereumAMM.js +12 -0
  14. package/dist/AaveV2EthereumArc.d.ts +9 -0
  15. package/dist/AaveV2EthereumArc.js +12 -0
  16. package/dist/AaveV2Fuji.d.ts +9 -0
  17. package/dist/AaveV2Fuji.js +12 -0
  18. package/dist/AaveV2Mumbai.d.ts +9 -0
  19. package/dist/AaveV2Mumbai.js +12 -0
  20. package/dist/AaveV2Polygon.d.ts +9 -0
  21. package/dist/AaveV2Polygon.js +12 -0
  22. package/dist/AaveV3Arbitrum.d.ts +9 -0
  23. package/dist/AaveV3Arbitrum.js +12 -0
  24. package/dist/AaveV3Avalanche.d.ts +9 -0
  25. package/dist/AaveV3Avalanche.js +12 -0
  26. package/dist/AaveV3Fantom.d.ts +9 -0
  27. package/dist/AaveV3Fantom.js +12 -0
  28. package/dist/AaveV3FantomTestnet.d.ts +9 -0
  29. package/dist/AaveV3FantomTestnet.js +12 -0
  30. package/dist/AaveV3Fuji.d.ts +9 -0
  31. package/dist/AaveV3Fuji.js +12 -0
  32. package/dist/AaveV3Harmony.d.ts +9 -0
  33. package/dist/AaveV3Harmony.js +12 -0
  34. package/dist/AaveV3Mumbai.d.ts +9 -0
  35. package/dist/AaveV3Mumbai.js +12 -0
  36. package/dist/AaveV3Optimism.d.ts +9 -0
  37. package/dist/AaveV3Optimism.js +12 -0
  38. package/dist/AaveV3OptimismKovan.d.ts +9 -0
  39. package/dist/AaveV3OptimismKovan.js +12 -0
  40. package/dist/AaveV3Polygon.d.ts +9 -0
  41. package/dist/AaveV3Polygon.js +12 -0
  42. package/foundry.toml +8 -0
  43. package/lib/forge-std/.github/workflows/tests.yml +27 -0
  44. package/lib/forge-std/.gitmodules +3 -0
  45. package/lib/forge-std/LICENSE-APACHE +203 -0
  46. package/lib/forge-std/LICENSE-MIT +25 -0
  47. package/lib/forge-std/README.md +246 -0
  48. package/lib/forge-std/lib/ds-test/LICENSE +674 -0
  49. package/lib/forge-std/lib/ds-test/Makefile +14 -0
  50. package/lib/forge-std/lib/ds-test/default.nix +4 -0
  51. package/lib/forge-std/lib/ds-test/demo/demo.sol +222 -0
  52. package/lib/forge-std/lib/ds-test/src/test.sol +469 -0
  53. package/lib/forge-std/src/Script.sol +39 -0
  54. package/lib/forge-std/src/StdJson.sol +118 -0
  55. package/lib/forge-std/src/Test.sol +1134 -0
  56. package/lib/forge-std/src/Vm.sol +231 -0
  57. package/lib/forge-std/src/console.sol +1533 -0
  58. package/lib/forge-std/src/console2.sol +1538 -0
  59. package/lib/forge-std/src/test/Script.t.sol +12 -0
  60. package/lib/forge-std/src/test/StdAssertions.t.sol +591 -0
  61. package/lib/forge-std/src/test/StdCheats.t.sol +282 -0
  62. package/lib/forge-std/src/test/StdError.t.sol +124 -0
  63. package/lib/forge-std/src/test/StdMath.t.sol +200 -0
  64. package/lib/forge-std/src/test/StdStorage.t.sol +321 -0
  65. package/lib/forge-std/src/test/fixtures/broadcast.log.json +187 -0
  66. package/package.json +39 -0
  67. package/src/AaveAddressBook.sol +28 -0
  68. package/src/AaveAddressBookV2.sol +143 -0
  69. package/src/AaveAddressBookV2Testnet.sol +74 -0
  70. package/src/AaveAddressBookV3.sol +166 -0
  71. package/src/AaveAddressBookV3Testnet.sol +120 -0
  72. package/src/AaveGovernanceV2.sol +549 -0
  73. package/src/AaveV2.sol +931 -0
  74. package/src/AaveV2Avalanche.sol +35 -0
  75. package/src/AaveV2Ethereum.sol +36 -0
  76. package/src/AaveV2EthereumAMM.sol +36 -0
  77. package/src/AaveV2EthereumArc.sol +36 -0
  78. package/src/AaveV2Fuji.sol +35 -0
  79. package/src/AaveV2Mumbai.sol +35 -0
  80. package/src/AaveV2Polygon.sol +35 -0
  81. package/src/AaveV3.sol +2406 -0
  82. package/src/AaveV3Arbitrum.sol +34 -0
  83. package/src/AaveV3Avalanche.sol +34 -0
  84. package/src/AaveV3Fantom.sol +34 -0
  85. package/src/AaveV3FantomTestnet.sol +34 -0
  86. package/src/AaveV3Fuji.sol +34 -0
  87. package/src/AaveV3Harmony.sol +34 -0
  88. package/src/AaveV3HarmonyTestnet.sol +34 -0
  89. package/src/AaveV3Mumbai.sol +34 -0
  90. package/src/AaveV3Optimism.sol +34 -0
  91. package/src/AaveV3OptimismKovan.sol +34 -0
  92. package/src/AaveV3Polygon.sol +34 -0
  93. package/src/Common.sol +9 -0
  94. package/src/test/AaveV2Ethereum.t.sol +72 -0
  95. package/src/test/AaveV2Misfits.t.sol +33 -0
  96. package/src/test/AaveV3Avalanche.t.sol +65 -0
  97. package/src/ts/AaveAddressBook.ts +17 -0
  98. package/src/ts/AaveV2Avalanche.ts +11 -0
  99. package/src/ts/AaveV2Ethereum.ts +12 -0
  100. package/src/ts/AaveV2EthereumAMM.ts +12 -0
  101. package/src/ts/AaveV2EthereumArc.ts +12 -0
  102. package/src/ts/AaveV2Fuji.ts +11 -0
  103. package/src/ts/AaveV2Mumbai.ts +11 -0
  104. package/src/ts/AaveV2Polygon.ts +11 -0
  105. package/src/ts/AaveV3Arbitrum.ts +12 -0
  106. package/src/ts/AaveV3Avalanche.ts +12 -0
  107. package/src/ts/AaveV3Fantom.ts +12 -0
  108. package/src/ts/AaveV3FantomTestnet.ts +12 -0
  109. package/src/ts/AaveV3Fuji.ts +12 -0
  110. package/src/ts/AaveV3Harmony.ts +12 -0
  111. package/src/ts/AaveV3Mumbai.ts +12 -0
  112. package/src/ts/AaveV3Optimism.ts +12 -0
  113. package/src/ts/AaveV3OptimismKovan.ts +12 -0
  114. package/src/ts/AaveV3Polygon.ts +12 -0
  115. package/tsconfig.json +101 -0
package/src/AaveV2.sol ADDED
@@ -0,0 +1,931 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity >=0.6.0;
3
+
4
+ library DataTypes {
5
+ // refer to the whitepaper, section 1.1 basic concepts for a formal description of these properties.
6
+ struct ReserveData {
7
+ //stores the reserve configuration
8
+ ReserveConfigurationMap configuration;
9
+ //the liquidity index. Expressed in ray
10
+ uint128 liquidityIndex;
11
+ //variable borrow index. Expressed in ray
12
+ uint128 variableBorrowIndex;
13
+ //the current supply rate. Expressed in ray
14
+ uint128 currentLiquidityRate;
15
+ //the current variable borrow rate. Expressed in ray
16
+ uint128 currentVariableBorrowRate;
17
+ //the current stable borrow rate. Expressed in ray
18
+ uint128 currentStableBorrowRate;
19
+ uint40 lastUpdateTimestamp;
20
+ //tokens addresses
21
+ address aTokenAddress;
22
+ address stableDebtTokenAddress;
23
+ address variableDebtTokenAddress;
24
+ //address of the interest rate strategy
25
+ address interestRateStrategyAddress;
26
+ //the id of the reserve. Represents the position in the list of the active reserves
27
+ uint8 id;
28
+ }
29
+
30
+ struct ReserveConfigurationMap {
31
+ //bit 0-15: LTV
32
+ //bit 16-31: Liq. threshold
33
+ //bit 32-47: Liq. bonus
34
+ //bit 48-55: Decimals
35
+ //bit 56: Reserve is active
36
+ //bit 57: reserve is frozen
37
+ //bit 58: borrowing is enabled
38
+ //bit 59: stable rate borrowing enabled
39
+ //bit 60-63: reserved
40
+ //bit 64-79: reserve factor
41
+ uint256 data;
42
+ }
43
+
44
+ struct UserConfigurationMap {
45
+ uint256 data;
46
+ }
47
+
48
+ enum InterestRateMode {
49
+ NONE,
50
+ STABLE,
51
+ VARIABLE
52
+ }
53
+ }
54
+
55
+ library ConfiguratorInputTypes {
56
+ struct InitReserveInput {
57
+ address aTokenImpl;
58
+ address stableDebtTokenImpl;
59
+ address variableDebtTokenImpl;
60
+ uint8 underlyingAssetDecimals;
61
+ address interestRateStrategyAddress;
62
+ address underlyingAsset;
63
+ address treasury;
64
+ address incentivesController;
65
+ string underlyingAssetName;
66
+ string aTokenName;
67
+ string aTokenSymbol;
68
+ string variableDebtTokenName;
69
+ string variableDebtTokenSymbol;
70
+ string stableDebtTokenName;
71
+ string stableDebtTokenSymbol;
72
+ bytes params;
73
+ }
74
+
75
+ struct UpdateATokenInput {
76
+ address asset;
77
+ address treasury;
78
+ address incentivesController;
79
+ string name;
80
+ string symbol;
81
+ address implementation;
82
+ bytes params;
83
+ }
84
+
85
+ struct UpdateDebtTokenInput {
86
+ address asset;
87
+ address incentivesController;
88
+ string name;
89
+ string symbol;
90
+ address implementation;
91
+ bytes params;
92
+ }
93
+ }
94
+
95
+ interface ILendingPoolAddressesProvider {
96
+ event MarketIdSet(string newMarketId);
97
+ event LendingPoolUpdated(address indexed newAddress);
98
+ event ConfigurationAdminUpdated(address indexed newAddress);
99
+ event EmergencyAdminUpdated(address indexed newAddress);
100
+ event LendingPoolConfiguratorUpdated(address indexed newAddress);
101
+ event LendingPoolCollateralManagerUpdated(address indexed newAddress);
102
+ event PriceOracleUpdated(address indexed newAddress);
103
+ event LendingRateOracleUpdated(address indexed newAddress);
104
+ event ProxyCreated(bytes32 id, address indexed newAddress);
105
+ event AddressSet(bytes32 id, address indexed newAddress, bool hasProxy);
106
+
107
+ function getMarketId() external view returns (string memory);
108
+
109
+ function setMarketId(string calldata marketId) external;
110
+
111
+ function setAddress(bytes32 id, address newAddress) external;
112
+
113
+ function setAddressAsProxy(bytes32 id, address impl) external;
114
+
115
+ function getAddress(bytes32 id) external view returns (address);
116
+
117
+ function getLendingPool() external view returns (address);
118
+
119
+ function setLendingPoolImpl(address pool) external;
120
+
121
+ function getLendingPoolConfigurator() external view returns (address);
122
+
123
+ function setLendingPoolConfiguratorImpl(address configurator) external;
124
+
125
+ function getLendingPoolCollateralManager() external view returns (address);
126
+
127
+ function setLendingPoolCollateralManager(address manager) external;
128
+
129
+ function getPoolAdmin() external view returns (address);
130
+
131
+ function setPoolAdmin(address admin) external;
132
+
133
+ function getEmergencyAdmin() external view returns (address);
134
+
135
+ function setEmergencyAdmin(address admin) external;
136
+
137
+ function getPriceOracle() external view returns (address);
138
+
139
+ function setPriceOracle(address priceOracle) external;
140
+
141
+ function getLendingRateOracle() external view returns (address);
142
+
143
+ function setLendingRateOracle(address lendingRateOracle) external;
144
+ }
145
+
146
+ interface ILendingPool {
147
+ /**
148
+ * @dev Emitted on deposit()
149
+ * @param reserve The address of the underlying asset of the reserve
150
+ * @param user The address initiating the deposit
151
+ * @param onBehalfOf The beneficiary of the deposit, receiving the aTokens
152
+ * @param amount The amount deposited
153
+ * @param referral The referral code used
154
+ **/
155
+ event Deposit(
156
+ address indexed reserve,
157
+ address user,
158
+ address indexed onBehalfOf,
159
+ uint256 amount,
160
+ uint16 indexed referral
161
+ );
162
+
163
+ /**
164
+ * @dev Emitted on withdraw()
165
+ * @param reserve The address of the underlyng asset being withdrawn
166
+ * @param user The address initiating the withdrawal, owner of aTokens
167
+ * @param to Address that will receive the underlying
168
+ * @param amount The amount to be withdrawn
169
+ **/
170
+ event Withdraw(
171
+ address indexed reserve,
172
+ address indexed user,
173
+ address indexed to,
174
+ uint256 amount
175
+ );
176
+
177
+ /**
178
+ * @dev Emitted on borrow() and flashLoan() when debt needs to be opened
179
+ * @param reserve The address of the underlying asset being borrowed
180
+ * @param user The address of the user initiating the borrow(), receiving the funds on borrow() or just
181
+ * initiator of the transaction on flashLoan()
182
+ * @param onBehalfOf The address that will be getting the debt
183
+ * @param amount The amount borrowed out
184
+ * @param borrowRateMode The rate mode: 1 for Stable, 2 for Variable
185
+ * @param borrowRate The numeric rate at which the user has borrowed
186
+ * @param referral The referral code used
187
+ **/
188
+ event Borrow(
189
+ address indexed reserve,
190
+ address user,
191
+ address indexed onBehalfOf,
192
+ uint256 amount,
193
+ uint256 borrowRateMode,
194
+ uint256 borrowRate,
195
+ uint16 indexed referral
196
+ );
197
+
198
+ /**
199
+ * @dev Emitted on repay()
200
+ * @param reserve The address of the underlying asset of the reserve
201
+ * @param user The beneficiary of the repayment, getting his debt reduced
202
+ * @param repayer The address of the user initiating the repay(), providing the funds
203
+ * @param amount The amount repaid
204
+ **/
205
+ event Repay(
206
+ address indexed reserve,
207
+ address indexed user,
208
+ address indexed repayer,
209
+ uint256 amount
210
+ );
211
+
212
+ /**
213
+ * @dev Emitted on swapBorrowRateMode()
214
+ * @param reserve The address of the underlying asset of the reserve
215
+ * @param user The address of the user swapping his rate mode
216
+ * @param rateMode The rate mode that the user wants to swap to
217
+ **/
218
+ event Swap(address indexed reserve, address indexed user, uint256 rateMode);
219
+
220
+ /**
221
+ * @dev Emitted on setUserUseReserveAsCollateral()
222
+ * @param reserve The address of the underlying asset of the reserve
223
+ * @param user The address of the user enabling the usage as collateral
224
+ **/
225
+ event ReserveUsedAsCollateralEnabled(
226
+ address indexed reserve,
227
+ address indexed user
228
+ );
229
+
230
+ /**
231
+ * @dev Emitted on setUserUseReserveAsCollateral()
232
+ * @param reserve The address of the underlying asset of the reserve
233
+ * @param user The address of the user enabling the usage as collateral
234
+ **/
235
+ event ReserveUsedAsCollateralDisabled(
236
+ address indexed reserve,
237
+ address indexed user
238
+ );
239
+
240
+ /**
241
+ * @dev Emitted on rebalanceStableBorrowRate()
242
+ * @param reserve The address of the underlying asset of the reserve
243
+ * @param user The address of the user for which the rebalance has been executed
244
+ **/
245
+ event RebalanceStableBorrowRate(
246
+ address indexed reserve,
247
+ address indexed user
248
+ );
249
+
250
+ /**
251
+ * @dev Emitted on flashLoan()
252
+ * @param target The address of the flash loan receiver contract
253
+ * @param initiator The address initiating the flash loan
254
+ * @param asset The address of the asset being flash borrowed
255
+ * @param amount The amount flash borrowed
256
+ * @param premium The fee flash borrowed
257
+ * @param referralCode The referral code used
258
+ **/
259
+ event FlashLoan(
260
+ address indexed target,
261
+ address indexed initiator,
262
+ address indexed asset,
263
+ uint256 amount,
264
+ uint256 premium,
265
+ uint16 referralCode
266
+ );
267
+
268
+ /**
269
+ * @dev Emitted when the pause is triggered.
270
+ */
271
+ event Paused();
272
+
273
+ /**
274
+ * @dev Emitted when the pause is lifted.
275
+ */
276
+ event Unpaused();
277
+
278
+ /**
279
+ * @dev Emitted when a borrower is liquidated. This event is emitted by the LendingPool via
280
+ * LendingPoolCollateral manager using a DELEGATECALL
281
+ * This allows to have the events in the generated ABI for LendingPool.
282
+ * @param collateralAsset The address of the underlying asset used as collateral, to receive as result of the liquidation
283
+ * @param debtAsset The address of the underlying borrowed asset to be repaid with the liquidation
284
+ * @param user The address of the borrower getting liquidated
285
+ * @param debtToCover The debt amount of borrowed `asset` the liquidator wants to cover
286
+ * @param liquidatedCollateralAmount The amount of collateral received by the liiquidator
287
+ * @param liquidator The address of the liquidator
288
+ * @param receiveAToken `true` if the liquidators wants to receive the collateral aTokens, `false` if he wants
289
+ * to receive the underlying collateral asset directly
290
+ **/
291
+ event LiquidationCall(
292
+ address indexed collateralAsset,
293
+ address indexed debtAsset,
294
+ address indexed user,
295
+ uint256 debtToCover,
296
+ uint256 liquidatedCollateralAmount,
297
+ address liquidator,
298
+ bool receiveAToken
299
+ );
300
+
301
+ /**
302
+ * @dev Emitted when the state of a reserve is updated. NOTE: This event is actually declared
303
+ * in the ReserveLogic library and emitted in the updateInterestRates() function. Since the function is internal,
304
+ * the event will actually be fired by the LendingPool contract. The event is therefore replicated here so it
305
+ * gets added to the LendingPool ABI
306
+ * @param reserve The address of the underlying asset of the reserve
307
+ * @param liquidityRate The new liquidity rate
308
+ * @param stableBorrowRate The new stable borrow rate
309
+ * @param variableBorrowRate The new variable borrow rate
310
+ * @param liquidityIndex The new liquidity index
311
+ * @param variableBorrowIndex The new variable borrow index
312
+ **/
313
+ event ReserveDataUpdated(
314
+ address indexed reserve,
315
+ uint256 liquidityRate,
316
+ uint256 stableBorrowRate,
317
+ uint256 variableBorrowRate,
318
+ uint256 liquidityIndex,
319
+ uint256 variableBorrowIndex
320
+ );
321
+
322
+ /**
323
+ * @dev Deposits an `amount` of underlying asset into the reserve, receiving in return overlying aTokens.
324
+ * - E.g. User deposits 100 USDC and gets in return 100 aUSDC
325
+ * @param asset The address of the underlying asset to deposit
326
+ * @param amount The amount to be deposited
327
+ * @param onBehalfOf The address that will receive the aTokens, same as msg.sender if the user
328
+ * wants to receive them on his own wallet, or a different address if the beneficiary of aTokens
329
+ * is a different wallet
330
+ * @param referralCode Code used to register the integrator originating the operation, for potential rewards.
331
+ * 0 if the action is executed directly by the user, without any middle-man
332
+ **/
333
+ function deposit(
334
+ address asset,
335
+ uint256 amount,
336
+ address onBehalfOf,
337
+ uint16 referralCode
338
+ ) external;
339
+
340
+ /**
341
+ * @dev Withdraws an `amount` of underlying asset from the reserve, burning the equivalent aTokens owned
342
+ * E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC
343
+ * @param asset The address of the underlying asset to withdraw
344
+ * @param amount The underlying amount to be withdrawn
345
+ * - Send the value type(uint256).max in order to withdraw the whole aToken balance
346
+ * @param to Address that will receive the underlying, same as msg.sender if the user
347
+ * wants to receive it on his own wallet, or a different address if the beneficiary is a
348
+ * different wallet
349
+ * @return The final amount withdrawn
350
+ **/
351
+ function withdraw(
352
+ address asset,
353
+ uint256 amount,
354
+ address to
355
+ ) external returns (uint256);
356
+
357
+ /**
358
+ * @dev Allows users to borrow a specific `amount` of the reserve underlying asset, provided that the borrower
359
+ * already deposited enough collateral, or he was given enough allowance by a credit delegator on the
360
+ * corresponding debt token (StableDebtToken or VariableDebtToken)
361
+ * - E.g. User borrows 100 USDC passing as `onBehalfOf` his own address, receiving the 100 USDC in his wallet
362
+ * and 100 stable/variable debt tokens, depending on the `interestRateMode`
363
+ * @param asset The address of the underlying asset to borrow
364
+ * @param amount The amount to be borrowed
365
+ * @param interestRateMode The interest rate mode at which the user wants to borrow: 1 for Stable, 2 for Variable
366
+ * @param referralCode Code used to register the integrator originating the operation, for potential rewards.
367
+ * 0 if the action is executed directly by the user, without any middle-man
368
+ * @param onBehalfOf Address of the user who will receive the debt. Should be the address of the borrower itself
369
+ * calling the function if he wants to borrow against his own collateral, or the address of the credit delegator
370
+ * if he has been given credit delegation allowance
371
+ **/
372
+ function borrow(
373
+ address asset,
374
+ uint256 amount,
375
+ uint256 interestRateMode,
376
+ uint16 referralCode,
377
+ address onBehalfOf
378
+ ) external;
379
+
380
+ /**
381
+ * @notice Repays a borrowed `amount` on a specific reserve, burning the equivalent debt tokens owned
382
+ * - E.g. User repays 100 USDC, burning 100 variable/stable debt tokens of the `onBehalfOf` address
383
+ * @param asset The address of the borrowed underlying asset previously borrowed
384
+ * @param amount The amount to repay
385
+ * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode`
386
+ * @param rateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable
387
+ * @param onBehalfOf Address of the user who will get his debt reduced/removed. Should be the address of the
388
+ * user calling the function if he wants to reduce/remove his own debt, or the address of any other
389
+ * other borrower whose debt should be removed
390
+ * @return The final amount repaid
391
+ **/
392
+ function repay(
393
+ address asset,
394
+ uint256 amount,
395
+ uint256 rateMode,
396
+ address onBehalfOf
397
+ ) external returns (uint256);
398
+
399
+ /**
400
+ * @dev Allows a borrower to swap his debt between stable and variable mode, or viceversa
401
+ * @param asset The address of the underlying asset borrowed
402
+ * @param rateMode The rate mode that the user wants to swap to
403
+ **/
404
+ function swapBorrowRateMode(address asset, uint256 rateMode) external;
405
+
406
+ /**
407
+ * @dev Rebalances the stable interest rate of a user to the current stable rate defined on the reserve.
408
+ * - Users can be rebalanced if the following conditions are satisfied:
409
+ * 1. Usage ratio is above 95%
410
+ * 2. the current deposit APY is below REBALANCE_UP_THRESHOLD * maxVariableBorrowRate, which means that too much has been
411
+ * borrowed at a stable rate and depositors are not earning enough
412
+ * @param asset The address of the underlying asset borrowed
413
+ * @param user The address of the user to be rebalanced
414
+ **/
415
+ function rebalanceStableBorrowRate(address asset, address user) external;
416
+
417
+ /**
418
+ * @dev Allows depositors to enable/disable a specific deposited asset as collateral
419
+ * @param asset The address of the underlying asset deposited
420
+ * @param useAsCollateral `true` if the user wants to use the deposit as collateral, `false` otherwise
421
+ **/
422
+ function setUserUseReserveAsCollateral(address asset, bool useAsCollateral)
423
+ external;
424
+
425
+ /**
426
+ * @dev Function to liquidate a non-healthy position collateral-wise, with Health Factor below 1
427
+ * - The caller (liquidator) covers `debtToCover` amount of debt of the user getting liquidated, and receives
428
+ * a proportionally amount of the `collateralAsset` plus a bonus to cover market risk
429
+ * @param collateralAsset The address of the underlying asset used as collateral, to receive as result of the liquidation
430
+ * @param debtAsset The address of the underlying borrowed asset to be repaid with the liquidation
431
+ * @param user The address of the borrower getting liquidated
432
+ * @param debtToCover The debt amount of borrowed `asset` the liquidator wants to cover
433
+ * @param receiveAToken `true` if the liquidators wants to receive the collateral aTokens, `false` if he wants
434
+ * to receive the underlying collateral asset directly
435
+ **/
436
+ function liquidationCall(
437
+ address collateralAsset,
438
+ address debtAsset,
439
+ address user,
440
+ uint256 debtToCover,
441
+ bool receiveAToken
442
+ ) external;
443
+
444
+ /**
445
+ * @dev Allows smartcontracts to access the liquidity of the pool within one transaction,
446
+ * as long as the amount taken plus a fee is returned.
447
+ * IMPORTANT There are security concerns for developers of flashloan receiver contracts that must be kept into consideration.
448
+ * For further details please visit https://developers.aave.com
449
+ * @param receiverAddress The address of the contract receiving the funds, implementing the IFlashLoanReceiver interface
450
+ * @param assets The addresses of the assets being flash-borrowed
451
+ * @param amounts The amounts amounts being flash-borrowed
452
+ * @param modes Types of the debt to open if the flash loan is not returned:
453
+ * 0 -> Don't open any debt, just revert if funds can't be transferred from the receiver
454
+ * 1 -> Open debt at stable rate for the value of the amount flash-borrowed to the `onBehalfOf` address
455
+ * 2 -> Open debt at variable rate for the value of the amount flash-borrowed to the `onBehalfOf` address
456
+ * @param onBehalfOf The address that will receive the debt in the case of using on `modes` 1 or 2
457
+ * @param params Variadic packed params to pass to the receiver as extra information
458
+ * @param referralCode Code used to register the integrator originating the operation, for potential rewards.
459
+ * 0 if the action is executed directly by the user, without any middle-man
460
+ **/
461
+ function flashLoan(
462
+ address receiverAddress,
463
+ address[] calldata assets,
464
+ uint256[] calldata amounts,
465
+ uint256[] calldata modes,
466
+ address onBehalfOf,
467
+ bytes calldata params,
468
+ uint16 referralCode
469
+ ) external;
470
+
471
+ /**
472
+ * @dev Returns the user account data across all the reserves
473
+ * @param user The address of the user
474
+ * @return totalCollateralETH the total collateral in ETH of the user
475
+ * @return totalDebtETH the total debt in ETH of the user
476
+ * @return availableBorrowsETH the borrowing power left of the user
477
+ * @return currentLiquidationThreshold the liquidation threshold of the user
478
+ * @return ltv the loan to value of the user
479
+ * @return healthFactor the current health factor of the user
480
+ **/
481
+ function getUserAccountData(address user)
482
+ external
483
+ view
484
+ returns (
485
+ uint256 totalCollateralETH,
486
+ uint256 totalDebtETH,
487
+ uint256 availableBorrowsETH,
488
+ uint256 currentLiquidationThreshold,
489
+ uint256 ltv,
490
+ uint256 healthFactor
491
+ );
492
+
493
+ function initReserve(
494
+ address reserve,
495
+ address aTokenAddress,
496
+ address stableDebtAddress,
497
+ address variableDebtAddress,
498
+ address interestRateStrategyAddress
499
+ ) external;
500
+
501
+ function setReserveInterestRateStrategyAddress(
502
+ address reserve,
503
+ address rateStrategyAddress
504
+ ) external;
505
+
506
+ function setConfiguration(address reserve, uint256 configuration) external;
507
+
508
+ /**
509
+ * @dev Returns the configuration of the reserve
510
+ * @param asset The address of the underlying asset of the reserve
511
+ * @return The configuration of the reserve
512
+ **/
513
+ function getConfiguration(address asset)
514
+ external
515
+ view
516
+ returns (DataTypes.ReserveConfigurationMap memory);
517
+
518
+ /**
519
+ * @dev Returns the configuration of the user across all the reserves
520
+ * @param user The user address
521
+ * @return The configuration of the user
522
+ **/
523
+ function getUserConfiguration(address user)
524
+ external
525
+ view
526
+ returns (DataTypes.UserConfigurationMap memory);
527
+
528
+ /**
529
+ * @dev Returns the normalized income normalized income of the reserve
530
+ * @param asset The address of the underlying asset of the reserve
531
+ * @return The reserve's normalized income
532
+ */
533
+ function getReserveNormalizedIncome(address asset)
534
+ external
535
+ view
536
+ returns (uint256);
537
+
538
+ /**
539
+ * @dev Returns the normalized variable debt per unit of asset
540
+ * @param asset The address of the underlying asset of the reserve
541
+ * @return The reserve normalized variable debt
542
+ */
543
+ function getReserveNormalizedVariableDebt(address asset)
544
+ external
545
+ view
546
+ returns (uint256);
547
+
548
+ /**
549
+ * @dev Returns the state and configuration of the reserve
550
+ * @param asset The address of the underlying asset of the reserve
551
+ * @return The state of the reserve
552
+ **/
553
+ function getReserveData(address asset)
554
+ external
555
+ view
556
+ returns (DataTypes.ReserveData memory);
557
+
558
+ function finalizeTransfer(
559
+ address asset,
560
+ address from,
561
+ address to,
562
+ uint256 amount,
563
+ uint256 balanceFromAfter,
564
+ uint256 balanceToBefore
565
+ ) external;
566
+
567
+ function getReservesList() external view returns (address[] memory);
568
+
569
+ function getAddressesProvider()
570
+ external
571
+ view
572
+ returns (ILendingPoolAddressesProvider);
573
+
574
+ function setPause(bool val) external;
575
+
576
+ function paused() external view returns (bool);
577
+ }
578
+
579
+ interface ILendingPoolConfigurator {
580
+ /**
581
+ * @dev Emitted when a reserve is initialized.
582
+ * @param asset The address of the underlying asset of the reserve
583
+ * @param aToken The address of the associated aToken contract
584
+ * @param stableDebtToken The address of the associated stable rate debt token
585
+ * @param variableDebtToken The address of the associated variable rate debt token
586
+ * @param interestRateStrategyAddress The address of the interest rate strategy for the reserve
587
+ **/
588
+ event ReserveInitialized(
589
+ address indexed asset,
590
+ address indexed aToken,
591
+ address stableDebtToken,
592
+ address variableDebtToken,
593
+ address interestRateStrategyAddress
594
+ );
595
+
596
+ /**
597
+ * @dev Emitted when borrowing is enabled on a reserve
598
+ * @param asset The address of the underlying asset of the reserve
599
+ * @param stableRateEnabled True if stable rate borrowing is enabled, false otherwise
600
+ **/
601
+ event BorrowingEnabledOnReserve(
602
+ address indexed asset,
603
+ bool stableRateEnabled
604
+ );
605
+
606
+ /**
607
+ * @dev Emitted when borrowing is disabled on a reserve
608
+ * @param asset The address of the underlying asset of the reserve
609
+ **/
610
+ event BorrowingDisabledOnReserve(address indexed asset);
611
+
612
+ /**
613
+ * @dev Emitted when the collateralization risk parameters for the specified asset are updated.
614
+ * @param asset The address of the underlying asset of the reserve
615
+ * @param ltv The loan to value of the asset when used as collateral
616
+ * @param liquidationThreshold The threshold at which loans using this asset as collateral will be considered undercollateralized
617
+ * @param liquidationBonus The bonus liquidators receive to liquidate this asset
618
+ **/
619
+ event CollateralConfigurationChanged(
620
+ address indexed asset,
621
+ uint256 ltv,
622
+ uint256 liquidationThreshold,
623
+ uint256 liquidationBonus
624
+ );
625
+
626
+ /**
627
+ * @dev Emitted when stable rate borrowing is enabled on a reserve
628
+ * @param asset The address of the underlying asset of the reserve
629
+ **/
630
+ event StableRateEnabledOnReserve(address indexed asset);
631
+
632
+ /**
633
+ * @dev Emitted when stable rate borrowing is disabled on a reserve
634
+ * @param asset The address of the underlying asset of the reserve
635
+ **/
636
+ event StableRateDisabledOnReserve(address indexed asset);
637
+
638
+ /**
639
+ * @dev Emitted when a reserve is activated
640
+ * @param asset The address of the underlying asset of the reserve
641
+ **/
642
+ event ReserveActivated(address indexed asset);
643
+
644
+ /**
645
+ * @dev Emitted when a reserve is deactivated
646
+ * @param asset The address of the underlying asset of the reserve
647
+ **/
648
+ event ReserveDeactivated(address indexed asset);
649
+
650
+ /**
651
+ * @dev Emitted when a reserve is frozen
652
+ * @param asset The address of the underlying asset of the reserve
653
+ **/
654
+ event ReserveFrozen(address indexed asset);
655
+
656
+ /**
657
+ * @dev Emitted when a reserve is unfrozen
658
+ * @param asset The address of the underlying asset of the reserve
659
+ **/
660
+ event ReserveUnfrozen(address indexed asset);
661
+
662
+ /**
663
+ * @dev Emitted when a reserve factor is updated
664
+ * @param asset The address of the underlying asset of the reserve
665
+ * @param factor The new reserve factor
666
+ **/
667
+ event ReserveFactorChanged(address indexed asset, uint256 factor);
668
+
669
+ /**
670
+ * @dev Emitted when the reserve decimals are updated
671
+ * @param asset The address of the underlying asset of the reserve
672
+ * @param decimals The new decimals
673
+ **/
674
+ event ReserveDecimalsChanged(address indexed asset, uint256 decimals);
675
+
676
+ /**
677
+ * @dev Emitted when a reserve interest strategy contract is updated
678
+ * @param asset The address of the underlying asset of the reserve
679
+ * @param strategy The new address of the interest strategy contract
680
+ **/
681
+ event ReserveInterestRateStrategyChanged(
682
+ address indexed asset,
683
+ address strategy
684
+ );
685
+
686
+ /**
687
+ * @dev Emitted when an aToken implementation is upgraded
688
+ * @param asset The address of the underlying asset of the reserve
689
+ * @param proxy The aToken proxy address
690
+ * @param implementation The new aToken implementation
691
+ **/
692
+ event ATokenUpgraded(
693
+ address indexed asset,
694
+ address indexed proxy,
695
+ address indexed implementation
696
+ );
697
+
698
+ /**
699
+ * @dev Emitted when the implementation of a stable debt token is upgraded
700
+ * @param asset The address of the underlying asset of the reserve
701
+ * @param proxy The stable debt token proxy address
702
+ * @param implementation The new aToken implementation
703
+ **/
704
+ event StableDebtTokenUpgraded(
705
+ address indexed asset,
706
+ address indexed proxy,
707
+ address indexed implementation
708
+ );
709
+
710
+ /**
711
+ * @dev Emitted when the implementation of a variable debt token is upgraded
712
+ * @param asset The address of the underlying asset of the reserve
713
+ * @param proxy The variable debt token proxy address
714
+ * @param implementation The new aToken implementation
715
+ **/
716
+ event VariableDebtTokenUpgraded(
717
+ address indexed asset,
718
+ address indexed proxy,
719
+ address indexed implementation
720
+ );
721
+
722
+ /**
723
+ * @dev Initializes a reserve
724
+ * @param aTokenImpl The address of the aToken contract implementation
725
+ * @param stableDebtTokenImpl The address of the stable debt token contract
726
+ * @param variableDebtTokenImpl The address of the variable debt token contract
727
+ * @param underlyingAssetDecimals The decimals of the reserve underlying asset
728
+ * @param interestRateStrategyAddress The address of the interest rate strategy contract for this reserve
729
+ **/
730
+ function initReserve(
731
+ address aTokenImpl,
732
+ address stableDebtTokenImpl,
733
+ address variableDebtTokenImpl,
734
+ uint8 underlyingAssetDecimals,
735
+ address interestRateStrategyAddress
736
+ ) external;
737
+
738
+ function batchInitReserve(
739
+ ConfiguratorInputTypes.InitReserveInput[] calldata input
740
+ ) external;
741
+
742
+ /**
743
+ * @dev Updates the aToken implementation for the reserve
744
+ * @param asset The address of the underlying asset of the reserve to be updated
745
+ * @param implementation The address of the new aToken implementation
746
+ **/
747
+ function updateAToken(address asset, address implementation) external;
748
+
749
+ /**
750
+ * @dev Updates the stable debt token implementation for the reserve
751
+ * @param asset The address of the underlying asset of the reserve to be updated
752
+ * @param implementation The address of the new aToken implementation
753
+ **/
754
+ function updateStableDebtToken(address asset, address implementation)
755
+ external;
756
+
757
+ /**
758
+ * @dev Updates the variable debt token implementation for the asset
759
+ * @param asset The address of the underlying asset of the reserve to be updated
760
+ * @param implementation The address of the new aToken implementation
761
+ **/
762
+ function updateVariableDebtToken(address asset, address implementation)
763
+ external;
764
+
765
+ /**
766
+ * @dev Enables borrowing on a reserve
767
+ * @param asset The address of the underlying asset of the reserve
768
+ * @param stableBorrowRateEnabled True if stable borrow rate needs to be enabled by default on this reserve
769
+ **/
770
+ function enableBorrowingOnReserve(address asset, bool stableBorrowRateEnabled)
771
+ external;
772
+
773
+ /**
774
+ * @dev Disables borrowing on a reserve
775
+ * @param asset The address of the underlying asset of the reserve
776
+ **/
777
+ function disableBorrowingOnReserve(address asset) external;
778
+
779
+ /**
780
+ * @dev Configures the reserve collateralization parameters
781
+ * all the values are expressed in percentages with two decimals of precision. A valid value is 10000, which means 100.00%
782
+ * @param asset The address of the underlying asset of the reserve
783
+ * @param ltv The loan to value of the asset when used as collateral
784
+ * @param liquidationThreshold The threshold at which loans using this asset as collateral will be considered undercollateralized
785
+ * @param liquidationBonus The bonus liquidators receive to liquidate this asset. The values is always above 100%. A value of 105%
786
+ * means the liquidator will receive a 5% bonus
787
+ **/
788
+ function configureReserveAsCollateral(
789
+ address asset,
790
+ uint256 ltv,
791
+ uint256 liquidationThreshold,
792
+ uint256 liquidationBonus
793
+ ) external;
794
+
795
+ /**
796
+ * @dev Enable stable rate borrowing on a reserve
797
+ * @param asset The address of the underlying asset of the reserve
798
+ **/
799
+ function enableReserveStableRate(address asset) external;
800
+
801
+ /**
802
+ * @dev Disable stable rate borrowing on a reserve
803
+ * @param asset The address of the underlying asset of the reserve
804
+ **/
805
+ function disableReserveStableRate(address asset) external;
806
+
807
+ /**
808
+ * @dev Activates a reserve
809
+ * @param asset The address of the underlying asset of the reserve
810
+ **/
811
+ function activateReserve(address asset) external;
812
+
813
+ /**
814
+ * @dev Deactivates a reserve
815
+ * @param asset The address of the underlying asset of the reserve
816
+ **/
817
+ function deactivateReserve(address asset) external;
818
+
819
+ /**
820
+ * @dev Freezes a reserve. A frozen reserve doesn't allow any new deposit, borrow or rate swap
821
+ * but allows repayments, liquidations, rate rebalances and withdrawals
822
+ * @param asset The address of the underlying asset of the reserve
823
+ **/
824
+ function freezeReserve(address asset) external;
825
+
826
+ /**
827
+ * @dev Unfreezes a reserve
828
+ * @param asset The address of the underlying asset of the reserve
829
+ **/
830
+ function unfreezeReserve(address asset) external;
831
+
832
+ /**
833
+ * @dev Updates the reserve factor of a reserve
834
+ * @param asset The address of the underlying asset of the reserve
835
+ * @param reserveFactor The new reserve factor of the reserve
836
+ **/
837
+ function setReserveFactor(address asset, uint256 reserveFactor) external;
838
+
839
+ /**
840
+ * @dev Sets the interest rate strategy of a reserve
841
+ * @param asset The address of the underlying asset of the reserve
842
+ * @param rateStrategyAddress The new address of the interest strategy contract
843
+ **/
844
+ function setReserveInterestRateStrategyAddress(
845
+ address asset,
846
+ address rateStrategyAddress
847
+ ) external;
848
+
849
+ /**
850
+ * @dev pauses or unpauses all the actions of the protocol, including aToken transfers
851
+ * @param val true if protocol needs to be paused, false otherwise
852
+ **/
853
+ function setPoolPause(bool val) external;
854
+ }
855
+
856
+ interface IAaveOracle {
857
+ event WethSet(address indexed weth);
858
+ event AssetSourceUpdated(address indexed asset, address indexed source);
859
+ event FallbackOracleUpdated(address indexed fallbackOracle);
860
+
861
+ /// @notice Returns the WETH address (reference asset of the oracle)
862
+ function WETH() external returns (address);
863
+
864
+ /// @notice External function called by the Aave governance to set or replace sources of assets
865
+ /// @param assets The addresses of the assets
866
+ /// @param sources The address of the source of each asset
867
+ function setAssetSources(
868
+ address[] calldata assets,
869
+ address[] calldata sources
870
+ ) external;
871
+
872
+ /// @notice Sets the fallbackOracle
873
+ /// - Callable only by the Aave governance
874
+ /// @param fallbackOracle The address of the fallbackOracle
875
+ function setFallbackOracle(address fallbackOracle) external;
876
+
877
+ /// @notice Gets an asset price by address
878
+ /// @param asset The asset address
879
+ function getAssetPrice(address asset) external view returns (uint256);
880
+
881
+ /// @notice Gets a list of prices from a list of assets addresses
882
+ /// @param assets The list of assets addresses
883
+ function getAssetsPrices(address[] calldata assets)
884
+ external
885
+ view
886
+ returns (uint256[] memory);
887
+
888
+ /// @notice Gets the address of the source for an asset address
889
+ /// @param asset The address of the asset
890
+ /// @return address The address of the source
891
+ function getSourceOfAsset(address asset) external view returns (address);
892
+
893
+ /// @notice Gets the address of the fallback oracle
894
+ /// @return address The addres of the fallback oracle
895
+ function getFallbackOracle() external view returns (address);
896
+ }
897
+
898
+ struct TokenData {
899
+ string symbol;
900
+ address tokenAddress;
901
+ }
902
+
903
+ // TODO: incomplete interface
904
+ interface IAaveProtocolDataProvider {
905
+ function getReserveConfigurationData(address asset)
906
+ external
907
+ view
908
+ returns (
909
+ uint256 decimals,
910
+ uint256 ltv,
911
+ uint256 liquidationThreshold,
912
+ uint256 liquidationBonus,
913
+ uint256 reserveFactor,
914
+ bool usageAsCollateralEnabled,
915
+ bool borrowingEnabled,
916
+ bool stableBorrowRateEnabled,
917
+ bool isActive,
918
+ bool isFrozen
919
+ );
920
+
921
+ function getAllReservesTokens() external view returns (TokenData[] memory);
922
+
923
+ function getReserveTokensAddresses(address asset)
924
+ external
925
+ view
926
+ returns (
927
+ address aTokenAddress,
928
+ address stableDebtTokenAddress,
929
+ address variableDebtTokenAddress
930
+ );
931
+ }