|
1 | 1 | // SPDX-License-Identifier: MIT |
2 | 2 | pragma solidity ^0.8.0; |
3 | 3 |
|
4 | | -import {Address} from 'solidity-utils/contracts/oz-common/Address.sol'; |
5 | | -import {WadRayMath} from 'aave-v3-core/contracts/protocol/libraries/math/WadRayMath.sol'; |
6 | | -import {IAaveV3ConfigEngine as IEngine} from './IAaveV3ConfigEngine.sol'; |
7 | | -import {IV3RateStrategyFactory as Rates} from './IV3RateStrategyFactory.sol'; |
8 | | -import {EngineFlags} from './EngineFlags.sol'; |
| 4 | +import {AaveV3Base} from 'aave-address-book/AaveV3Base.sol'; |
| 5 | +import './AaveV3Payload.sol'; |
9 | 6 |
|
10 | 7 | /** |
11 | | - * @dev Base smart contract for an Aave v3.0.1 configs update. |
12 | | - * - !!!IMPORTANT!!! This payload inheriting AaveV3PayloadBase MUST BE STATELESS always |
13 | | - * - Assumes this contract has the right permissions |
14 | | - * - Connected to a IAaveV3ConfigEngine engine contact, which abstract the complexities of |
15 | | - * interaction with the Aave protocol. |
16 | | - * - At the moment covering: |
17 | | - * - Listings of new assets on the pool. |
18 | | - * - Listings of new assets on the pool with custom token impl. |
19 | | - * - Updates of caps (supply cap, borrow cap). |
20 | | - * - Updates of price feeds |
21 | | - * - Updates of interest rate strategies |
22 | | - * - Updates of borrow parameters (flashloanable, stableRateModeEnabled, borrowableInIsolation, withSiloedBorrowing, reserveFactor) |
23 | | - * - Updates of collateral parameters (ltv, liq threshold, liq bonus, liq protocol fee, debt ceiling) |
24 | | - * - Updates of emode category parameters (ltv, liq threshold, liq bonus, price source, label) |
25 | | - * - Updates of emode category of assets (e-mode id) |
| 8 | + * @dev Base smart contract for an Aave v3.0.2 (compatible with 3.0.0) listing on v3 Base. |
26 | 9 | * @author BGD Labs |
27 | 10 | */ |
28 | | -abstract contract AaveV3PayloadBase { |
29 | | - using Address for address; |
30 | | - |
31 | | - IEngine public immutable CONFIG_ENGINE; |
32 | | - |
33 | | - constructor(IEngine engine) { |
34 | | - CONFIG_ENGINE = engine; |
| 11 | +abstract contract AaveV3PayloadBase is AaveV3Payload(IEngine(AaveV3Base.LISTING_ENGINE)) { |
| 12 | + function getPoolContext() public pure override returns (IEngine.PoolContext memory) { |
| 13 | + return IEngine.PoolContext({networkName: 'Base', networkAbbreviation: 'Bas'}); |
35 | 14 | } |
36 | | - |
37 | | - /// @dev to be overriden on the child if any extra logic is needed pre-listing |
38 | | - function _preExecute() internal virtual {} |
39 | | - |
40 | | - /// @dev to be overriden on the child if any extra logic is needed post-listing |
41 | | - function _postExecute() internal virtual {} |
42 | | - |
43 | | - function execute() external { |
44 | | - _preExecute(); |
45 | | - |
46 | | - IEngine.EModeCategoryUpdate[] memory eModeCategories = eModeCategoriesUpdates(); |
47 | | - IEngine.Listing[] memory listings = newListings(); |
48 | | - IEngine.ListingWithCustomImpl[] memory listingsCustom = newListingsCustom(); |
49 | | - IEngine.CollateralUpdate[] memory collaterals = collateralsUpdates(); |
50 | | - IEngine.BorrowUpdate[] memory borrows = borrowsUpdates(); |
51 | | - IEngine.RateStrategyUpdate[] memory rates = rateStrategiesUpdates(); |
52 | | - IEngine.PriceFeedUpdate[] memory priceFeeds = priceFeedsUpdates(); |
53 | | - IEngine.AssetEModeUpdate[] memory assetsEMode = assetsEModeUpdates(); |
54 | | - IEngine.CapsUpdate[] memory caps = capsUpdates(); |
55 | | - |
56 | | - if (eModeCategories.length != 0) { |
57 | | - address(CONFIG_ENGINE).functionDelegateCall( |
58 | | - abi.encodeWithSelector(CONFIG_ENGINE.updateEModeCategories.selector, eModeCategories) |
59 | | - ); |
60 | | - } |
61 | | - |
62 | | - if (listings.length != 0) { |
63 | | - address(CONFIG_ENGINE).functionDelegateCall( |
64 | | - abi.encodeWithSelector(CONFIG_ENGINE.listAssets.selector, getPoolContext(), listings) |
65 | | - ); |
66 | | - } |
67 | | - |
68 | | - if (listingsCustom.length != 0) { |
69 | | - address(CONFIG_ENGINE).functionDelegateCall( |
70 | | - abi.encodeWithSelector( |
71 | | - CONFIG_ENGINE.listAssetsCustom.selector, |
72 | | - getPoolContext(), |
73 | | - listingsCustom |
74 | | - ) |
75 | | - ); |
76 | | - } |
77 | | - |
78 | | - if (borrows.length != 0) { |
79 | | - address(CONFIG_ENGINE).functionDelegateCall( |
80 | | - abi.encodeWithSelector(CONFIG_ENGINE.updateBorrowSide.selector, borrows) |
81 | | - ); |
82 | | - } |
83 | | - |
84 | | - if (collaterals.length != 0) { |
85 | | - address(CONFIG_ENGINE).functionDelegateCall( |
86 | | - abi.encodeWithSelector(CONFIG_ENGINE.updateCollateralSide.selector, collaterals) |
87 | | - ); |
88 | | - } |
89 | | - |
90 | | - if (rates.length != 0) { |
91 | | - address(CONFIG_ENGINE).functionDelegateCall( |
92 | | - abi.encodeWithSelector(CONFIG_ENGINE.updateRateStrategies.selector, rates) |
93 | | - ); |
94 | | - } |
95 | | - |
96 | | - if (priceFeeds.length != 0) { |
97 | | - address(CONFIG_ENGINE).functionDelegateCall( |
98 | | - abi.encodeWithSelector(CONFIG_ENGINE.updatePriceFeeds.selector, priceFeeds) |
99 | | - ); |
100 | | - } |
101 | | - |
102 | | - if (assetsEMode.length != 0) { |
103 | | - address(CONFIG_ENGINE).functionDelegateCall( |
104 | | - abi.encodeWithSelector(CONFIG_ENGINE.updateAssetsEMode.selector, assetsEMode) |
105 | | - ); |
106 | | - } |
107 | | - |
108 | | - if (caps.length != 0) { |
109 | | - address(CONFIG_ENGINE).functionDelegateCall( |
110 | | - abi.encodeWithSelector(CONFIG_ENGINE.updateCaps.selector, caps) |
111 | | - ); |
112 | | - } |
113 | | - |
114 | | - _postExecute(); |
115 | | - } |
116 | | - |
117 | | - /** @dev Converts basis points to RAY units |
118 | | - * e.g. 10_00 (10.00%) will return 100000000000000000000000000 |
119 | | - */ |
120 | | - function _bpsToRay(uint256 amount) internal pure returns (uint256) { |
121 | | - return (amount * WadRayMath.RAY) / 10_000; |
122 | | - } |
123 | | - |
124 | | - /// @dev to be defined in the child with a list of new assets to list |
125 | | - function newListings() public view virtual returns (IEngine.Listing[] memory) {} |
126 | | - |
127 | | - /// @dev to be defined in the child with a list of new assets to list (with custom a/v/s tokens implementations) |
128 | | - function newListingsCustom() |
129 | | - public |
130 | | - view |
131 | | - virtual |
132 | | - returns (IEngine.ListingWithCustomImpl[] memory) |
133 | | - {} |
134 | | - |
135 | | - /// @dev to be defined in the child with a list of caps to update |
136 | | - function capsUpdates() public view virtual returns (IEngine.CapsUpdate[] memory) {} |
137 | | - |
138 | | - /// @dev to be defined in the child with a list of collaterals' params to update |
139 | | - function collateralsUpdates() public view virtual returns (IEngine.CollateralUpdate[] memory) {} |
140 | | - |
141 | | - /// @dev to be defined in the child with a list of borrows' params to update |
142 | | - function borrowsUpdates() public view virtual returns (IEngine.BorrowUpdate[] memory) {} |
143 | | - |
144 | | - /// @dev to be defined in the child with a list of priceFeeds to update |
145 | | - function priceFeedsUpdates() public view virtual returns (IEngine.PriceFeedUpdate[] memory) {} |
146 | | - |
147 | | - /// @dev to be defined in the child with a list of eMode categories to update |
148 | | - function eModeCategoriesUpdates() |
149 | | - public |
150 | | - view |
151 | | - virtual |
152 | | - returns (IEngine.EModeCategoryUpdate[] memory) |
153 | | - {} |
154 | | - |
155 | | - /// @dev to be defined in the child with a list of assets for which eMode categories to update |
156 | | - function assetsEModeUpdates() public view virtual returns (IEngine.AssetEModeUpdate[] memory) {} |
157 | | - |
158 | | - /// @dev to be defined in the child with a list of set of parameters of rate strategies |
159 | | - function rateStrategiesUpdates() |
160 | | - public |
161 | | - view |
162 | | - virtual |
163 | | - returns (IEngine.RateStrategyUpdate[] memory) |
164 | | - {} |
165 | | - |
166 | | - /// @dev the lack of support for immutable strings kinds of forces for this |
167 | | - /// Besides that, it can actually be useful being able to change the naming, but remote |
168 | | - function getPoolContext() public view virtual returns (IEngine.PoolContext memory); |
169 | 15 | } |
0 commit comments