Skip to content

Commit a208c28

Browse files
committed
perf: slight gas improvements
1 parent 27ddd8b commit a208c28

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

contracts/libs/LibHub.sol

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,27 @@ library LibHub {
2727
event FinishUpdate(uint256 id);
2828

2929
function finishUpdate(uint256 id) internal {
30-
AppStorage storage s = LibAppStorage.diamondStorage();
31-
HubInfo storage hubInfo = s.hubs[id];
30+
HubInfo storage hubInfo = LibAppStorage.diamondStorage().hubs[id];
31+
3232
require(block.timestamp > hubInfo.endTime, "Still updating");
3333

3434
if (hubInfo.targetRefundRatio != 0) {
35-
s.hubs[id].refundRatio = hubInfo.targetRefundRatio;
36-
s.hubs[id].targetRefundRatio = 0;
35+
hubInfo.refundRatio = hubInfo.targetRefundRatio;
36+
hubInfo.targetRefundRatio = 0;
3737
}
3838

3939
if (hubInfo.reconfigure) {
4040
ICurve(hubInfo.curve).finishReconfigure(id);
41-
s.hubs[id].reconfigure = false;
41+
hubInfo.reconfigure = false;
4242
}
4343
if (hubInfo.targetCurve != address(0)) {
44-
s.hubs[id].curve = hubInfo.targetCurve;
45-
s.hubs[id].targetCurve = address(0);
44+
hubInfo.curve = hubInfo.targetCurve;
45+
hubInfo.targetCurve = address(0);
4646
}
4747

48-
s.hubs[id].updating = false;
49-
s.hubs[id].startTime = 0;
50-
s.hubs[id].endTime = 0;
48+
hubInfo.updating = false;
49+
hubInfo.startTime = 0;
50+
hubInfo.endTime = 0;
5151

5252
emit FinishUpdate(id);
5353
}
@@ -57,20 +57,21 @@ library LibHub {
5757
view
5858
returns (HubInfo memory hubInfo)
5959
{
60-
AppStorage storage s = LibAppStorage.diamondStorage();
61-
hubInfo.active = s.hubs[id].active;
62-
hubInfo.owner = s.hubs[id].owner;
63-
hubInfo.vault = s.hubs[id].vault;
64-
hubInfo.asset = s.hubs[id].asset;
65-
hubInfo.curve = s.hubs[id].curve;
66-
hubInfo.refundRatio = s.hubs[id].refundRatio;
67-
hubInfo.updating = s.hubs[id].updating;
68-
hubInfo.startTime = s.hubs[id].startTime;
69-
hubInfo.endTime = s.hubs[id].endTime;
70-
hubInfo.endCooldown = s.hubs[id].endCooldown;
71-
hubInfo.reconfigure = s.hubs[id].reconfigure;
72-
hubInfo.targetCurve = s.hubs[id].targetCurve;
73-
hubInfo.targetRefundRatio = s.hubs[id].targetRefundRatio;
60+
HubInfo storage sHubInfo = LibAppStorage.diamondStorage().hubs[id];
61+
62+
hubInfo.active = sHubInfo.active;
63+
hubInfo.owner = sHubInfo.owner;
64+
hubInfo.vault = sHubInfo.vault;
65+
hubInfo.asset = sHubInfo.asset;
66+
hubInfo.curve = sHubInfo.curve;
67+
hubInfo.refundRatio = sHubInfo.refundRatio;
68+
hubInfo.updating = sHubInfo.updating;
69+
hubInfo.startTime = sHubInfo.startTime;
70+
hubInfo.endTime = sHubInfo.endTime;
71+
hubInfo.endCooldown = sHubInfo.endCooldown;
72+
hubInfo.reconfigure = sHubInfo.reconfigure;
73+
hubInfo.targetCurve = sHubInfo.targetCurve;
74+
hubInfo.targetRefundRatio = sHubInfo.targetRefundRatio;
7475
}
7576

7677
function count() internal view returns (uint256) {

0 commit comments

Comments
 (0)