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

Locking logic in Rebalancers can be changed to avoid SSTOREs. #140

Open
code423n4 opened this issue Dec 19, 2021 · 0 comments
Open

Locking logic in Rebalancers can be changed to avoid SSTOREs. #140

code423n4 opened this issue Dec 19, 2021 · 0 comments
Labels
bug Something isn't working G (Gas Optimization)

Comments

@code423n4
Copy link
Contributor

Handle

p4st13r4

Vulnerability details

Impact

If a rebalance is done in more than one transaction, locking the basket at each transaction can be avoided.

Proof of Concept

Tools Used

Editor

Recommended Mitigation Steps

(a) Implement lock() method in RebalanceManager.solRebalanceManagerV2.solRebalanceManagerV3.sol as:

    function lock() external onlyRebalanceManager {
        basket.singleCall(
            address(basket),
            abi.encodeWithSelector(basket.setLock.selector, _block),
            0
        );
    }

Effectively making lockBasketData not needed.RebalanceManager.solRebalanceManagerV2.sol will need a new constructor argument uint256 _lockTime and a new state variable uint256 public lockTime.

(b) In RebalanceManager.solRebalanceManagerV2.solRebalanceManagerV3.sol remove the line lockBasketData(block.number + 30) at the beginning of rebalance method.

(c) On rebalance method first line in RebalanceManager.solRebalanceManagerV2.sol add require(basket.getLock(), "REQUIRE_LOCK") (as in contracts/basket/contracts/callManagers/RebalanceManagerV3.sol)

When performing a rebalance:

(d) Call RebalanceManager.lock().

(e) Perform the rebalance using the rebalance() method.

@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Dec 19, 2021
code423n4 added a commit that referenced this issue Dec 19, 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 G (Gas Optimization)
Projects
None yet
Development

No branches or pull requests

1 participant