forked from bgd-labs/protocol-v3.2-pdp-patch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPool.sol.patch
152 lines (142 loc) · 5.03 KB
/
Pool.sol.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
Index: Pool.sol
===================================================================
--- Pool.sol
+++ Pool.sol
@@ -39,8 +39,11 @@
using ReserveLogic for DataTypes.ReserveData;
IPoolAddressesProvider public immutable ADDRESSES_PROVIDER;
+ // @notice The name used to fetch the UMBRELLA contract
+ bytes32 public constant UMBRELLA = "UMBRELLA";
+
/**
* @dev Only pool configurator can call functions marked by this modifier.
*/
modifier onlyPoolConfigurator() {
@@ -63,8 +66,19 @@
_onlyBridge();
_;
}
+ /**
+ * @dev Only the umbrella contract can call functions marked by this modifier.
+ */
+ modifier onlyUmbrella() {
+ require(
+ ADDRESSES_PROVIDER.getAddress(UMBRELLA) == msg.sender,
+ Errors.CALLER_NOT_UMBRELLA
+ );
+ _;
+ }
+
function _onlyPoolConfigurator() internal view virtual {
require(
ADDRESSES_PROVIDER.getPoolConfigurator() == msg.sender,
Errors.CALLER_NOT_POOL_CONFIGURATOR
@@ -450,15 +464,8 @@
PoolLogic.executeMintToTreasury(_reserves, assets);
}
/// @inheritdoc IPool
- function getReserveDataExtended(
- address asset
- ) external view returns (DataTypes.ReserveData memory) {
- return _reserves[asset];
- }
-
- /// @inheritdoc IPool
function getReserveData(
address asset
)
external
@@ -466,9 +473,9 @@
virtual
override
returns (DataTypes.ReserveDataLegacy memory)
{
- DataTypes.ReserveData memory reserve = _reserves[asset];
+ DataTypes.ReserveData storage reserve = _reserves[asset];
DataTypes.ReserveDataLegacy memory res;
res.configuration = reserve.configuration;
res.liquidityIndex = reserve.liquidityIndex;
@@ -484,9 +491,9 @@
res.unbacked = reserve.unbacked;
res.isolationModeTotalDebt = reserve.isolationModeTotalDebt;
// This is a temporary workaround for integrations that are broken by Aave 3.2
// While the new pool data provider is backward compatible, some integrations hard-code an old implementation
- // To allow them to unlock the funds, the pool address provider is setting a stable debt token, so balanceOf() and totalSupply() will return zero instead of reverting
+ // To allow them to not have any infrastructural blocker, a mock must be configured in the Aave Pool Addresses Provider, returning zero on all required view methods, instead of reverting
res.stableDebtTokenAddress = ADDRESSES_PROVIDER.getAddress(
bytes32("MOCK_STABLE_DEBT")
);
return res;
@@ -793,9 +800,9 @@
/// @inheritdoc IPool
function configureEModeCategory(
uint8 id,
- DataTypes.EModeCategoryBaseConfiguration memory category
+ DataTypes.EModeCategoryBaseConfiguration calldata category
) external virtual override onlyPoolConfigurator {
// category 0 is reserved for volatile heterogeneous assets and it's always disabled
require(id != 0, Errors.EMODE_CATEGORY_RESERVED);
_eModeCategories[id].ltv = category.ltv;
@@ -834,9 +841,9 @@
virtual
override
returns (DataTypes.EModeCategoryLegacy memory)
{
- DataTypes.EModeCategory memory category = _eModeCategories[id];
+ DataTypes.EModeCategory storage category = _eModeCategories[id];
return
DataTypes.EModeCategoryLegacy({
ltv: category.ltv,
liquidationThreshold: category.liquidationThreshold,
@@ -911,9 +918,9 @@
/// @inheritdoc IPool
function getLiquidationGracePeriod(
address asset
- ) external virtual override returns (uint40) {
+ ) external view virtual override returns (uint40) {
return _reserves[asset].liquidationGracePeriodUntil;
}
/// @inheritdoc IPool
@@ -958,8 +965,44 @@
);
}
/// @inheritdoc IPool
+ function eliminateReserveDeficit(
+ address asset,
+ uint256 amount
+ ) external override onlyUmbrella {
+ LiquidationLogic.executeEliminateDeficit(
+ _reserves,
+ _usersConfig[msg.sender],
+ DataTypes.ExecuteEliminateDeficitParams({
+ asset: asset,
+ amount: amount
+ })
+ );
+ }
+
+ /// @inheritdoc IPool
+ function getReserveDeficit(
+ address asset
+ ) external view virtual returns (uint256) {
+ return _reserves[asset].deficit;
+ }
+
+ /// @inheritdoc IPool
+ function getReserveAToken(
+ address asset
+ ) external view virtual returns (address) {
+ return _reserves[asset].aTokenAddress;
+ }
+
+ /// @inheritdoc IPool
+ function getReserveVariableDebtToken(
+ address asset
+ ) external view virtual returns (address) {
+ return _reserves[asset].variableDebtTokenAddress;
+ }
+
+ /// @inheritdoc IPool
function getFlashLoanLogic() external pure returns (address) {
return address(FlashLoanLogic);
}