Skip to content

Commit 0b87c00

Browse files
committed
fix: rename getters and move to IHubBase, rename error (#865)
1 parent 11071ef commit 0b87c00

26 files changed

+145
-150
lines changed

snapshots/Hub.Operations.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"refreshPremium": "103280",
88
"remove: full": "77252",
99
"remove: partial": "83769",
10-
"reportDeficit": "121619",
10+
"reportDeficit": "121597",
1111
"restore: full": "100313",
1212
"restore: partial": "113945",
1313
"transferShares": "79049"
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
2-
"borrow: first": "226295",
3-
"borrow: second action, same reserve": "206816",
4-
"liquidationCall: full": "311530",
5-
"liquidationCall: partial": "331508",
6-
"permitReserve + repay (multicall)": "266194",
2+
"borrow: first": "226273",
3+
"borrow: second action, same reserve": "206794",
4+
"liquidationCall: full": "311508",
5+
"liquidationCall: partial": "331486",
6+
"permitReserve + repay (multicall)": "266172",
77
"permitReserve + supply (multicall)": "144267",
88
"permitReserve + supply + enable collateral (multicall)": "178228",
99
"repay: full": "158136",
10-
"repay: partial": "210026",
10+
"repay: partial": "210004",
1111
"setUserPositionManagerWithSig: disable": "44882",
1212
"setUserPositionManagerWithSig: enable": "68905",
1313
"supply + enable collateral (multicall)": "156170",
@@ -17,16 +17,16 @@
1717
"supply: second action, same reserve": "105173",
1818
"updateUserDynamicConfig: 1 collateral": "73802",
1919
"updateUserDynamicConfig: 2 collaterals": "88662",
20-
"updateUserRiskPremium: 1 borrow": "162232",
21-
"updateUserRiskPremium: 2 borrows": "235601",
20+
"updateUserRiskPremium: 1 borrow": "162210",
21+
"updateUserRiskPremium: 2 borrows": "235557",
2222
"usingAsCollateral: 0 borrows, enable": "58976",
23-
"usingAsCollateral: 1 borrow, disable": "172491",
23+
"usingAsCollateral: 1 borrow, disable": "172469",
2424
"usingAsCollateral: 1 borrow, enable": "32298",
25-
"usingAsCollateral: 2 borrows, disable": "259197",
25+
"usingAsCollateral: 2 borrows, disable": "259153",
2626
"usingAsCollateral: 2 borrows, enable": "41876",
2727
"withdraw: 0 borrows, full": "129936",
2828
"withdraw: 0 borrows, partial": "136271",
29-
"withdraw: 1 borrow, partial": "228386",
30-
"withdraw: 2 borrows, partial": "315081",
29+
"withdraw: 1 borrow, partial": "228364",
30+
"withdraw: 2 borrows, partial": "315037",
3131
"withdraw: non collateral": "127837"
3232
}

snapshots/Spoke.Operations.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
2-
"borrow: first": "251795",
3-
"borrow: second action, same reserve": "215216",
4-
"liquidationCall: full": "320146",
5-
"liquidationCall: partial": "340124",
6-
"permitReserve + repay (multicall)": "274810",
2+
"borrow: first": "251773",
3+
"borrow: second action, same reserve": "215194",
4+
"liquidationCall: full": "320124",
5+
"liquidationCall: partial": "340102",
6+
"permitReserve + repay (multicall)": "274788",
77
"permitReserve + supply (multicall)": "144267",
88
"permitReserve + supply + enable collateral (multicall)": "178228",
99
"repay: full": "152352",
10-
"repay: partial": "218642",
10+
"repay: partial": "218620",
1111
"setUserPositionManagerWithSig: disable": "44882",
1212
"setUserPositionManagerWithSig: enable": "68905",
1313
"supply + enable collateral (multicall)": "156170",
@@ -17,16 +17,16 @@
1717
"supply: second action, same reserve": "105173",
1818
"updateUserDynamicConfig: 1 collateral": "73802",
1919
"updateUserDynamicConfig: 2 collaterals": "88662",
20-
"updateUserRiskPremium: 1 borrow": "179032",
21-
"updateUserRiskPremium: 2 borrows": "269201",
20+
"updateUserRiskPremium: 1 borrow": "179010",
21+
"updateUserRiskPremium: 2 borrows": "269157",
2222
"usingAsCollateral: 0 borrows, enable": "58976",
23-
"usingAsCollateral: 1 borrow, disable": "189291",
23+
"usingAsCollateral: 1 borrow, disable": "189269",
2424
"usingAsCollateral: 1 borrow, enable": "32298",
25-
"usingAsCollateral: 2 borrows, disable": "292797",
25+
"usingAsCollateral: 2 borrows, disable": "292753",
2626
"usingAsCollateral: 2 borrows, enable": "41876",
2727
"withdraw: 0 borrows, full": "129936",
2828
"withdraw: 0 borrows, partial": "136271",
29-
"withdraw: 1 borrow, partial": "245186",
30-
"withdraw: 2 borrows, partial": "348681",
29+
"withdraw: 1 borrow, partial": "245164",
30+
"withdraw: 2 borrows, partial": "348637",
3131
"withdraw: non collateral": "127837"
3232
}

src/hub/AssetInterestRateStrategy.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ contract AssetInterestRateStrategy is IAssetInterestRateStrategy {
7575
}
7676

7777
/// @inheritdoc IAssetInterestRateStrategy
78-
function getBaseVariableBorrowRate(uint256 assetId) external view override returns (uint256) {
78+
function getBaseVariableBorrowRate(uint256 assetId) external view returns (uint256) {
7979
return _interestRateData[assetId].baseVariableBorrowRate;
8080
}
8181

@@ -90,7 +90,7 @@ contract AssetInterestRateStrategy is IAssetInterestRateStrategy {
9090
}
9191

9292
/// @inheritdoc IAssetInterestRateStrategy
93-
function getMaxVariableBorrowRate(uint256 assetId) external view override returns (uint256) {
93+
function getMaxVariableBorrowRate(uint256 assetId) external view returns (uint256) {
9494
return
9595
_interestRateData[assetId].baseVariableBorrowRate +
9696
_interestRateData[assetId].variableRateSlope1 +
@@ -104,7 +104,7 @@ contract AssetInterestRateStrategy is IAssetInterestRateStrategy {
104104
uint256 drawn,
105105
uint256 /* deficit */,
106106
uint256 swept
107-
) external view virtual override returns (uint256) {
107+
) external view returns (uint256) {
108108
InterestRateData memory rateData = _interestRateData[assetId];
109109
require(rateData.optimalUsageRatio > 0, InterestRateDataNotSet(assetId));
110110

src/hub/Hub.sol

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ contract Hub is IHub, AccessManaged {
420420
}
421421

422422
/// @inheritdoc IHub
423-
function getAssetCount() external view override returns (uint256) {
423+
function getAssetCount() external view returns (uint256) {
424424
return _assetCount;
425425
}
426426

@@ -522,6 +522,16 @@ contract Hub is IHub, AccessManaged {
522522
return (asset.premiumShares, asset.premiumOffset, asset.realizedPremium);
523523
}
524524

525+
/// @inheritdoc IHubBase
526+
function getAssetLiquidity(uint256 assetId) external view returns (uint256) {
527+
return _assets[assetId].liquidity;
528+
}
529+
530+
/// @inheritdoc IHubBase
531+
function getAssetDeficit(uint256 assetId) external view returns (uint256) {
532+
return _assets[assetId].deficit;
533+
}
534+
525535
/// @inheritdoc IHub
526536
function getAsset(uint256 assetId) external view returns (Asset memory) {
527537
return _assets[assetId];
@@ -540,17 +550,7 @@ contract Hub is IHub, AccessManaged {
540550
}
541551

542552
/// @inheritdoc IHub
543-
function getLiquidity(uint256 assetId) external view returns (uint256) {
544-
return _assets[assetId].liquidity;
545-
}
546-
547-
/// @inheritdoc IHub
548-
function getAssetDeficit(uint256 assetId) external view returns (uint256) {
549-
return _assets[assetId].deficit;
550-
}
551-
552-
/// @inheritdoc IHub
553-
function getSwept(uint256 assetId) external view override returns (uint256) {
553+
function getAssetSwept(uint256 assetId) external view returns (uint256) {
554554
return _assets[assetId].swept;
555555
}
556556

@@ -609,6 +609,11 @@ contract Hub is IHub, AccessManaged {
609609
return (spokeData.premiumShares, spokeData.premiumOffset, spokeData.realizedPremium);
610610
}
611611

612+
/// @inheritdoc IHubBase
613+
function getSpokeDeficit(uint256 assetId, address spoke) external view returns (uint256) {
614+
return _spokes[assetId][spoke].deficit;
615+
}
616+
612617
/// @inheritdoc IHub
613618
function isSpokeListed(uint256 assetId, address spoke) external view returns (bool) {
614619
return _assetToSpokes[assetId].contains(spoke);
@@ -633,11 +638,6 @@ contract Hub is IHub, AccessManaged {
633638
return SpokeConfig(spokeData.active, spokeData.addCap, spokeData.drawCap);
634639
}
635640

636-
/// @inheritdoc IHub
637-
function getSpokeDeficit(uint256 assetId, address spoke) external view returns (uint256) {
638-
return _spokes[assetId][spoke].deficit;
639-
}
640-
641641
/// @notice Adds a new spoke to an asset with default feeReceiver configuration (maximum add cap, zero draw cap).
642642
/// @dev Emits `AddSpoke` and `UpdateSpokeConfig` events.
643643
function _addFeeReceiver(uint256 assetId, address feeReceiver) internal {
@@ -721,6 +721,7 @@ contract Hub is IHub, AccessManaged {
721721
return spoke.realizedPremium + accruedPremium;
722722
}
723723

724+
/// @dev Spoke with maximum cap have unlimited add capacity.
724725
function _validateAdd(
725726
Asset storage asset,
726727
SpokeData storage spoke,

src/hub/HubConfigurator.sol

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ contract HubConfigurator is Ownable2Step, IHubConfigurator {
2626
address feeReceiver,
2727
address irStrategy,
2828
bytes calldata irData
29-
) external override onlyOwner returns (uint256) {
29+
) external onlyOwner returns (uint256) {
3030
return
3131
IHub(hub).addAsset(
3232
underlying,
@@ -45,7 +45,7 @@ contract HubConfigurator is Ownable2Step, IHubConfigurator {
4545
address feeReceiver,
4646
address irStrategy,
4747
bytes calldata irData
48-
) external override onlyOwner returns (uint256) {
48+
) external onlyOwner returns (uint256) {
4949
return IHub(hub).addAsset(underlying, decimals, feeReceiver, irStrategy, irData);
5050
}
5151

@@ -54,19 +54,15 @@ contract HubConfigurator is Ownable2Step, IHubConfigurator {
5454
address hub,
5555
uint256 assetId,
5656
uint256 liquidityFee
57-
) external override onlyOwner {
57+
) external onlyOwner {
5858
IHub targetHub = IHub(hub);
5959
IHub.AssetConfig memory config = targetHub.getAssetConfig(assetId);
6060
config.liquidityFee = liquidityFee.toUint16();
6161
targetHub.updateAssetConfig(assetId, config, new bytes(0));
6262
}
6363

6464
/// @inheritdoc IHubConfigurator
65-
function updateFeeReceiver(
66-
address hub,
67-
uint256 assetId,
68-
address feeReceiver
69-
) external override onlyOwner {
65+
function updateFeeReceiver(address hub, uint256 assetId, address feeReceiver) external onlyOwner {
7066
IHub targetHub = IHub(hub);
7167
IHub.AssetConfig memory config = targetHub.getAssetConfig(assetId);
7268
config.feeReceiver = feeReceiver;
@@ -79,7 +75,7 @@ contract HubConfigurator is Ownable2Step, IHubConfigurator {
7975
uint256 assetId,
8076
uint256 liquidityFee,
8177
address feeReceiver
82-
) external override onlyOwner {
78+
) external onlyOwner {
8379
IHub targetHub = IHub(hub);
8480
IHub.AssetConfig memory config = targetHub.getAssetConfig(assetId);
8581
config.liquidityFee = liquidityFee.toUint16();
@@ -93,7 +89,7 @@ contract HubConfigurator is Ownable2Step, IHubConfigurator {
9389
uint256 assetId,
9490
address irStrategy,
9591
bytes calldata irData
96-
) external override onlyOwner {
92+
) external onlyOwner {
9793
IHub targetHub = IHub(hub);
9894
IHub.AssetConfig memory config = targetHub.getAssetConfig(assetId);
9995
config.irStrategy = irStrategy;
@@ -105,15 +101,15 @@ contract HubConfigurator is Ownable2Step, IHubConfigurator {
105101
address hub,
106102
uint256 assetId,
107103
address reinvestmentController
108-
) external override onlyOwner {
104+
) external onlyOwner {
109105
IHub targetHub = IHub(hub);
110106
IHub.AssetConfig memory config = targetHub.getAssetConfig(assetId);
111107
config.reinvestmentController = reinvestmentController;
112108
targetHub.updateAssetConfig(assetId, config, new bytes(0));
113109
}
114110

115111
/// @inheritdoc IHubConfigurator
116-
function freezeAsset(address hub, uint256 assetId) external override onlyOwner {
112+
function freezeAsset(address hub, uint256 assetId) external onlyOwner {
117113
IHub targetHub = IHub(hub);
118114
uint256 spokesCount = targetHub.getSpokeCount(assetId);
119115
for (uint256 i = 0; i < spokesCount; ++i) {
@@ -123,7 +119,7 @@ contract HubConfigurator is Ownable2Step, IHubConfigurator {
123119
}
124120

125121
/// @inheritdoc IHubConfigurator
126-
function pauseAsset(address hub, uint256 assetId) external override onlyOwner {
122+
function pauseAsset(address hub, uint256 assetId) external onlyOwner {
127123
IHub targetHub = IHub(hub);
128124
uint256 spokesCount = targetHub.getSpokeCount(assetId);
129125
for (uint256 i = 0; i < spokesCount; ++i) {
@@ -163,7 +159,7 @@ contract HubConfigurator is Ownable2Step, IHubConfigurator {
163159
uint256 assetId,
164160
address spoke,
165161
bool active
166-
) external override onlyOwner {
162+
) external onlyOwner {
167163
IHub targetHub = IHub(hub);
168164
IHub.SpokeConfig memory config = targetHub.getSpokeConfig(assetId, spoke);
169165
config.active = active;
@@ -176,7 +172,7 @@ contract HubConfigurator is Ownable2Step, IHubConfigurator {
176172
uint256 assetId,
177173
address spoke,
178174
uint256 addCap
179-
) external override onlyOwner {
175+
) external onlyOwner {
180176
IHub targetHub = IHub(hub);
181177
IHub.SpokeConfig memory config = targetHub.getSpokeConfig(assetId, spoke);
182178
config.addCap = addCap.toUint56();
@@ -189,7 +185,7 @@ contract HubConfigurator is Ownable2Step, IHubConfigurator {
189185
uint256 assetId,
190186
address spoke,
191187
uint256 drawCap
192-
) external override onlyOwner {
188+
) external onlyOwner {
193189
IHub targetHub = IHub(hub);
194190
IHub.SpokeConfig memory config = targetHub.getSpokeConfig(assetId, spoke);
195191
config.drawCap = drawCap.toUint56();
@@ -203,12 +199,12 @@ contract HubConfigurator is Ownable2Step, IHubConfigurator {
203199
address spoke,
204200
uint256 addCap,
205201
uint256 drawCap
206-
) external override onlyOwner {
202+
) external onlyOwner {
207203
_updateSpokeCaps(IHub(hub), assetId, spoke, addCap, drawCap);
208204
}
209205

210206
/// @inheritdoc IHubConfigurator
211-
function pauseSpoke(address hub, address spoke) external override onlyOwner {
207+
function pauseSpoke(address hub, address spoke) external onlyOwner {
212208
IHub targetHub = IHub(hub);
213209
uint256 assetCount = targetHub.getAssetCount();
214210
for (uint256 assetId = 0; assetId < assetCount; ++assetId) {
@@ -221,7 +217,7 @@ contract HubConfigurator is Ownable2Step, IHubConfigurator {
221217
}
222218

223219
/// @inheritdoc IHubConfigurator
224-
function freezeSpoke(address hub, address spoke) external override onlyOwner {
220+
function freezeSpoke(address hub, address spoke) external onlyOwner {
225221
IHub targetHub = IHub(hub);
226222
uint256 assetCount = targetHub.getAssetCount();
227223
for (uint256 assetId = 0; assetId < assetCount; ++assetId) {
@@ -236,7 +232,7 @@ contract HubConfigurator is Ownable2Step, IHubConfigurator {
236232
address hub,
237233
uint256 assetId,
238234
bytes calldata irData
239-
) external override onlyOwner {
235+
) external onlyOwner {
240236
IHub(hub).setInterestRateData(assetId, irData);
241237
}
242238

src/hub/interfaces/IHub.sol

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -313,20 +313,10 @@ interface IHub is IHubBase, IAccessManaged {
313313
/// @return The asset configuration struct.
314314
function getAssetConfig(uint256 assetId) external view returns (AssetConfig memory);
315315

316-
/// @notice Returns the amount of available liquidity for the specified asset.
317-
/// @param assetId The identifier of the asset.
318-
/// @return The amount of available liquidity.
319-
function getLiquidity(uint256 assetId) external view returns (uint256);
320-
321-
/// @notice Returns the amount of deficit of the specified asset.
322-
/// @param assetId The identifier of the asset.
323-
/// @return The amount of deficit.
324-
function getAssetDeficit(uint256 assetId) external view returns (uint256);
325-
326316
/// @notice Returns the amount of liquidity swept by the reinvestment controller for the specified asset.
327317
/// @param assetId The identifier of the asset.
328318
/// @return The amount of liquidity swept.
329-
function getSwept(uint256 assetId) external view returns (uint256);
319+
function getAssetSwept(uint256 assetId) external view returns (uint256);
330320

331321
/// @notice Calculates the current drawn index for the specified asset.
332322
/// @param assetId The identifier of the asset.
@@ -370,12 +360,6 @@ interface IHub is IHubBase, IAccessManaged {
370360
address spoke
371361
) external view returns (SpokeConfig memory);
372362

373-
/// @notice Returns the amount of a given spoke's deficit for the specified asset.
374-
/// @param assetId The identifier of the asset.
375-
/// @param spoke The address of the spoke.
376-
/// @return The amount of deficit.
377-
function getSpokeDeficit(uint256 assetId, address spoke) external view returns (uint256);
378-
379363
/// @notice Returns the maximum allowed number of decimals for the underlying asset.
380364
/// @return The maximum number of decimals (inclusive).
381365
function MAX_ALLOWED_UNDERLYING_DECIMALS() external view returns (uint8);

0 commit comments

Comments
 (0)