Skip to content

Commit dc6e80f

Browse files
authored
refactor: rename basenet to base (aave-dao#147)
* refactor: rename basenet to base fix: rename basenet to base * fix: rename contract as well
1 parent f559d58 commit dc6e80f

27 files changed

Lines changed: 252 additions & 254 deletions

resources/configs-engine.svg

Lines changed: 1 addition & 1 deletion
Loading
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.0;
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';
9+
10+
/**
11+
* @dev Base smart contract for an Aave v3.0.1 configs update.
12+
* - !!!IMPORTANT!!! This payload inheriting AaveV3Payload 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)
26+
* @author BGD Labs
27+
*/
28+
abstract contract AaveV3Payload {
29+
using Address for address;
30+
31+
IEngine public immutable CONFIG_ENGINE;
32+
33+
constructor(IEngine engine) {
34+
CONFIG_ENGINE = engine;
35+
}
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+
}

src/v3-config-engine/AaveV3PayloadArbitrum.sol

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.0;
33

4-
import {AaveV3Arbitrum, AaveV3ArbitrumAssets} from 'aave-address-book/AaveV3Arbitrum.sol';
5-
import './AaveV3PayloadBase.sol';
4+
import {AaveV3Arbitrum} from 'aave-address-book/AaveV3Arbitrum.sol';
5+
import './AaveV3Payload.sol';
66

77
/**
88
* @dev Base smart contract for an Aave v3.0.1 (compatible with 3.0.0) listing on v3 Arbitrum.
99
* @author BGD Labs
1010
*/
11-
abstract contract AaveV3PayloadArbitrum is
12-
AaveV3PayloadBase(IEngine(AaveV3Arbitrum.LISTING_ENGINE))
13-
{
11+
abstract contract AaveV3PayloadArbitrum is AaveV3Payload(IEngine(AaveV3Arbitrum.LISTING_ENGINE)) {
1412
function getPoolContext() public pure override returns (IEngine.PoolContext memory) {
1513
return IEngine.PoolContext({networkName: 'Arbitrum', networkAbbreviation: 'Arb'});
1614
}

src/v3-config-engine/AaveV3PayloadAvalanche.sol

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.0;
33

4-
import {AaveV3Avalanche, AaveV3AvalancheAssets} from 'aave-address-book/AaveV3Avalanche.sol';
5-
import './AaveV3PayloadBase.sol';
4+
import {AaveV3Avalanche} from 'aave-address-book/AaveV3Avalanche.sol';
5+
import './AaveV3Payload.sol';
66

77
/**
88
* @dev Base smart contract for an Aave v3.0.1 (compatible with 3.0.0) listing on v3 Avalanche.
99
* @author BGD Labs
1010
*/
11-
abstract contract AaveV3PayloadAvalanche is
12-
AaveV3PayloadBase(IEngine(AaveV3Avalanche.LISTING_ENGINE))
13-
{
11+
abstract contract AaveV3PayloadAvalanche is AaveV3Payload(IEngine(AaveV3Avalanche.LISTING_ENGINE)) {
1412
function getPoolContext() public pure override returns (IEngine.PoolContext memory) {
1513
return IEngine.PoolContext({networkName: 'Avalanche', networkAbbreviation: 'Ava'});
1614
}
Lines changed: 6 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -1,169 +1,15 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.0;
33

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';
96

107
/**
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.
269
* @author BGD Labs
2710
*/
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'});
3514
}
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);
16915
}

0 commit comments

Comments
 (0)