sherlock-audit / 2023-06-Index-judging

6 stars 2 forks source link

qandisa - Auction can never be unlocked early #69

Closed sherlock-admin closed 1 year ago

sherlock-admin commented 1 year ago

qandisa

medium

Auction can never be unlocked early

Summary

A locked SetToken can never be unlocked early because raiseTargetPercentage must be > 0 when set in setRaiseTargetPercentage() but _canUnlockEarly() requires it to be == 0 to pass.

Vulnerability Detail

The raiseTargetPercentage variable is set in the setRaiseTargetPercentage() function. The variable must be >0

require(_raiseTargetPercentage > 0, "Target percentage must be greater than 0");

Looking at unlock() function we see that _canUnlockEarly() only return True if raiseTargetPercentage == 0

return _allTargetsMet(_setToken) && _isQuoteAssetExcessOrAtTarget(_setToken) && rebalance.raiseTargetPercentage == 0;

This will never be due to the constraint in `setRaiseTargetPercentaged().

Impact

Locking a SetToken limits much of the functionality of the token. Redeeming/issuing, changing the manager etc. are all blocked. If this can not be unlocked even when a re-balancing event has been completed the SetToken is locked for the entire duration. If the duration of the auction was set to be very long with the intention to close it when the re-balancing is completed they will now instead be completely locked for that entire duration

The unlock() can also serve as a general safety feature where Index can force an auction to close early and unlock the SetToken by meeting all the targets themselves and then unlocking the SetToken, this is currently not possible.

Code Snippet

https://github.com/sherlock-audit/2023-06-Index/blob/main/index-protocol/contracts/protocol/modules/v1/AuctionRebalanceModuleV1.sol#L391

https://github.com/sherlock-audit/2023-06-Index/blob/main/index-protocol/contracts/protocol/modules/v1/AuctionRebalanceModuleV1.sol#L1201

https://github.com/sherlock-audit/2023-06-Index/blob/main/index-protocol/contracts/protocol/modules/v1/AuctionRebalanceModuleV1.sol#L421

Tool used

Manual Review

Recommendation

Require that raiseTargetPercentage >= 0 or remove the requirement that raiseTargetPercentage == 0 when unlocking early.

Duplicate of #38