Unexpected revert at the delegateMgCvg and delegateVeCvg when delegation removal
Summary
Token owners can't remove a percentage of the mgCvG delegation from a specified address _to via the delegateMgCvg function when the _to address has maxTokenIdsDelegated delegations. The only way to remove delegation is to clean all associated with _tokenId delegatees. The same issue at the delegateVeCvg function but the impact is less because veCVG can be delegated only to one address.
Vulnerability Detail
The LockingPositionDelegate.delegateMgCvg and LockingPositionDelegate.delegateVeCvg functions allow the token owner to delegate and undelegate to the selected address. If the number of delegations to the address reaches the maxTokenIdsDelegated value, no more delegations can be performed at this address. Due to the fact that the checks are in inappropriate places, they also prevent the cancellation of delegation from such addresses.
Impact
The delegateMgCvg and delegateVeCvg functions do not work as expected during the normal usage.
pontifex
medium
Unexpected revert at the
delegateMgCvg
anddelegateVeCvg
when delegation removalSummary
Token owners can't remove a percentage of the mgCvG delegation from a specified address
_to
via thedelegateMgCvg
function when the_to
address hasmaxTokenIdsDelegated
delegations. The only way to remove delegation is to clean all associated with_tokenId
delegatees. The same issue at thedelegateVeCvg
function but the impact is less because veCVG can be delegated only to one address.Vulnerability Detail
The
LockingPositionDelegate.delegateMgCvg
andLockingPositionDelegate.delegateVeCvg
functions allow the token owner to delegate and undelegate to the selected address. If the number of delegations to the address reaches themaxTokenIdsDelegated
value, no more delegations can be performed at this address. Due to the fact that the checks are in inappropriate places, they also prevent the cancellation of delegation from such addresses.Impact
The
delegateMgCvg
anddelegateVeCvg
functions do not work as expected during the normal usage.Code Snippet
https://github.com/sherlock-audit/2023-11-convergence/blob/e894be3e36614a385cf409dc7e278d5b8f16d6f2/sherlock-cvg/contracts/Locking/LockingPositionDelegate.sol#L285 https://github.com/sherlock-audit/2023-11-convergence/blob/e894be3e36614a385cf409dc7e278d5b8f16d6f2/sherlock-cvg/contracts/Locking/LockingPositionDelegate.sol#L249
Tool used
Manual Review
Recommendation
Consider using this check only for a new delegatee.
delegateMgCvg
:delegateVeCvg
:Duplicate of #142