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

Multiple Unused variables #180

Closed
code423n4 opened this issue Feb 2, 2022 · 2 comments
Closed

Multiple Unused variables #180

code423n4 opened this issue Feb 2, 2022 · 2 comments
Labels
bug Something isn't working duplicate This issue or pull request already exists G (Gas Optimization) sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue

Comments

@code423n4
Copy link
Contributor

Handle

SolidityScan

Vulnerability details

Description

Multiple variables were found to be declared but never used throughout the smart contract code. Having unused variables declared and unused cost unnecessary gas.

Impact

Smart Contracts are required to have effective Gas usage as they cost real money. Therefore each and every function and variable declaration should be monitored for ways to save Gas to make the code Gas efficient.

PoC

The below variables were defined but never used and hence can be removed.
https://github.com/code-423n4/2022-01-notional/blob/main/contracts/global/StorageLayoutV1.sol#16
liquidationEnabledState

https://github.com/code-423n4/2022-01-notional/blob/main/contracts/global/StorageLayoutV1.sol#18
hasInitialized

https://github.com/code-423n4/2022-01-notional/blob/main/contracts/global/StorageLayoutV1.sol#28
rollbackRouterImplementation

https://github.com/code-423n4/2022-01-notional/blob/main/contracts/global/StorageLayoutV1.sol#33
nTokenWhitelist

https://github.com/code-423n4/2022-01-notional/blob/main/contracts/global/StorageLayoutV1.sol#36
nTokenAllowance

https://github.com/code-423n4/2022-01-notional/blob/main/contracts/global/StorageLayoutV1.sol#40
globalTransferOperator

https://github.com/code-423n4/2022-01-notional/blob/main/contracts/global/StorageLayoutV1.sol#43
accountAuthorizedTransferOperator

https://github.com/code-423n4/2022-01-notional/blob/main/contracts/global/StorageLayoutV1.sol#46
authorizedCallbackContract

https://github.com/code-423n4/2022-01-notional/blob/main/contracts/global/StorageLayoutV1.sol#50
tokenAddressToCurrencyId

https://github.com/code-423n4/2022-01-notional/blob/main/contracts/global/StorageLayoutV2.sol#L15
pendingOwner

https://github.com/code-423n4/2022-01-notional/blob/main/contracts/global/LibStorage.sol#L14 NUM_NTOKEN_MARKET_FACTORS

https://github.com/code-423n4/2022-01-notional/blob/main/contracts/global/LibStorage.sol#L17
MAX_PORTFOLIO_ASSETS

https://github.com/code-423n4/2022-01-notional/blob/main/contracts/utils/EIP1271Wallet.sol#L20
ETH_PRECISION

https://github.com/code-423n4/2022-01-notional/blob/main/contracts/TreasuryManager.sol#L35
refundGasPrice

Recommended Mitigation Steps

Do not initialize and declare the variables that have no use. Delete them if they are not meant to be used anywhere.

@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Feb 2, 2022
code423n4 added a commit that referenced this issue Feb 2, 2022
@jeffywu jeffywu added the sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue label Feb 6, 2022
@jeffywu
Copy link
Collaborator

jeffywu commented Feb 6, 2022

Variables used in other code not in scope.

@pauliax
Copy link
Collaborator

pauliax commented Feb 15, 2022

Well, the issue mentions many legit variables that cannot be safely removed, but some of them can, so I will include this issue together with others: #204

@pauliax pauliax closed this as completed Feb 15, 2022
@pauliax pauliax added the duplicate This issue or pull request already exists label Feb 15, 2022
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 disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue
Projects
None yet
Development

No branches or pull requests

3 participants