Open sherlock-admin2 opened 3 months ago
2 comment(s) were left on this issue during the judging contest.
panprog commented:
valid medium, it influences the rebalance process only in very rare edge cases
takarez commented:
the reason for it should have been said.
The protocol team fixed this issue in the following PRs/commits: https://github.com/equilibria-xyz/perennial-v2/pull/299
The Lead Senior Watson signed off on the fix.
bin2chen
medium
_loadContext() uses the wrong pendingGlobal.
Summary
StrategyLib._loadContext()
is using the incorrectpendingGlobal
, causingcurrentPosition
,minPosition
, andmaxPosition
to be incorrect, leading to incorrect rebalance operation.Vulnerability Detail
In
StrategyLib._loadContext()
, there is a need to computecurrentPosition
,minPosition
, andmaxPosition
. The code as follows:The code above
pendingGlobal = registration.market.pendings(address(this));
is wrong It takes the address(this)'spendingLocal
. The correct approach is to usependingGlobal = registration.market.pending();
.Impact
Since
pendingGlobal
is wrong,currentPosition
,minPosition
andmaxPosition
are all wrong. affects subsequent rebalance calculations, such astarget.position
etc. rebalance does not work properlyCode Snippet
https://github.com/sherlock-audit/2024-02-perennial-v2-3/blob/main/perennial-v2/packages/perennial-vault/contracts/lib/StrategyLib.sol#L200
Tool used
Manual Review
Recommendation