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

Use short reason strings can save gas #48

Closed
code423n4 opened this issue Dec 8, 2021 · 2 comments
Closed

Use short reason strings can save gas #48

code423n4 opened this issue Dec 8, 2021 · 2 comments
Labels
bug Something isn't working duplicate This issue or pull request already exists G (Gas Optimization) sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")

Comments

@code423n4
Copy link
Contributor

Handle

WatchPug

Vulnerability details

Every reason string takes at least 32 bytes.

Use short reason strings that fits in 32 bytes or it will become more expensive.

Instances include:

https://github.com/maple-labs/maple-proxy-factory/blob/ee5f6beaf857c1b900cf74bcfdc4250a5189482a/contracts/MapleProxyFactory.sol#L33-L33

require(fromVersion_ != toVersion_,                              "MPF:DUP:CANNOT_OVERWRITE_INITIALIZER");

https://github.com/maple-labs/maple-proxy-factory/blob/ee5f6beaf857c1b900cf74bcfdc4250a5189482a/contracts/MapleProxyFactory.sol#L42-L42

require(fromVersion_ != toVersion_,                             "MPF:EUP:CANNOT_OVERWRITE_INITIALIZER");

https://github.com/maple-labs/liquidations/blob/bb09e17b1fac1126ce7734e58c3133be06162590/contracts/SushiswapStrategy.sol#L53-L53

require(IERC20Like(collateralAsset_).balanceOf(address(this)) == swapAmount_, "SushiswapStrategy:WRONG_COLLATERAL_AMT");

https://github.com/maple-labs/liquidations/blob/bb09e17b1fac1126ce7734e58c3133be06162590/contracts/SushiswapStrategy.sol#L74-L74

require(ERC20Helper.transfer(fundsAsset_, profitDestination_, IERC20Like(fundsAsset_).balanceOf(address(this)) - minReturnAmount_), "SushiswapStrategy:PROFIT_TRANSFER");

https://github.com/maple-labs/liquidations/blob/bb09e17b1fac1126ce7734e58c3133be06162590/contracts/UniswapV2Strategy.sol#L53-L53

require(IERC20Like(collateralAsset_).balanceOf(address(this)) == swapAmount_, "UniswapV2Strategy:WRONG_COLLATERAL_AMT");

https://github.com/maple-labs/liquidations/blob/bb09e17b1fac1126ce7734e58c3133be06162590/contracts/UniswapV2Strategy.sol#L74-L74

require(ERC20Helper.transfer(fundsAsset_, profitDestination_, IERC20Like(fundsAsset_).balanceOf(address(this)) - minReturnAmount_), "UniswapV2Strategy:PROFIT_TRANSFER");
@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Dec 8, 2021
code423n4 added a commit that referenced this issue Dec 8, 2021
@deluca-mike
Copy link
Collaborator

Duplicate of #3 and #40

@deluca-mike deluca-mike added duplicate This issue or pull request already exists sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") labels Dec 9, 2021
@pauliax
Copy link
Collaborator

pauliax commented Dec 15, 2021

A duplicate of #3

@pauliax pauliax closed this as completed Dec 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists G (Gas Optimization) sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Projects
None yet
Development

No branches or pull requests

3 participants