Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gas-optimization: remove unnecessary main.* calls #1025

Merged
merged 22 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ This release gives new RTokens being deployed the option to enable a variable ta

### Upgrade Steps

Upgrade BasketHandler
Upgrade BasketHandler and Distributor

Call `Distributor.cacheComponents()` if this is the first upgrade to a >=3.0.0 token.

### Core Protocol Contracts

Expand All @@ -17,6 +19,8 @@ New governance param added to `DeploymentParams`: `reweightable`
- Add immutable-after-init `reweightable` bool
- `Deployer`
- New boolean field `reweightable` added to `IDeployer.DeploymentParams`
- `Distributor`
- Minor gas-optimization

# 3.1.0 - Unreleased

Expand Down
18 changes: 9 additions & 9 deletions contracts/p1/Distributor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ contract DistributorP1 is ComponentP1, IDistributor {

IERC20 private rsr;
IERC20 private rToken;
address private furnace;
address private stRSR;
IFurnace private furnace;
IStRSR private stRSR;
address private rTokenTrader;
address private rsrTrader;

Expand Down Expand Up @@ -108,8 +108,8 @@ contract DistributorP1 is ComponentP1, IDistributor {
Transfer[] memory transfers = new Transfer[](destinations.length());
uint256 numTransfers;

address furnaceAddr = furnace; // gas-saver
address stRSRAddr = stRSR; // gas-saver
address furnaceAddr = address(furnace); // gas-saver
address stRSRAddr = address(stRSR); // gas-saver

bool accountRewards = false;

Expand Down Expand Up @@ -144,9 +144,9 @@ contract DistributorP1 is ComponentP1, IDistributor {
// Perform reward accounting
if (accountRewards) {
if (isRSR) {
main.stRSR().payoutRewards();
stRSR.payoutRewards();
} else {
main.furnace().melt();
furnace.melt();
}
}
}
Expand Down Expand Up @@ -176,7 +176,7 @@ contract DistributorP1 is ComponentP1, IDistributor {
function _setDistribution(address dest, RevenueShare memory share) internal {
require(dest != address(0), "dest cannot be zero");
require(
dest != furnace && dest != stRSR,
dest != address(furnace) && dest != address(stRSR),
"destination can not be furnace or strsr directly"
);
if (dest == FURNACE) require(share.rsrDist == 0, "Furnace must get 0% of RSR");
Expand Down Expand Up @@ -205,8 +205,8 @@ contract DistributorP1 is ComponentP1, IDistributor {
function cacheComponents() public {
rsr = main.rsr();
rToken = IERC20(address(main.rToken()));
furnace = address(main.furnace());
stRSR = address(main.stRSR());
furnace = main.furnace();
stRSR = main.stRSR();
rTokenTrader = address(main.rTokenTrader());
rsrTrader = address(main.rsrTrader());
}
Expand Down
Loading