This repository has been archived by the owner on Feb 18, 2024. It is now read-only.
WATCHPUG - _accumulateFunding()
maker will get the wrong amount of funding fee.
#139
Labels
Medium
A valid Medium severity issue
Reward
A payout will be made for this issue
Sponsor Confirmed
The sponsor acknowledged this issue is valid
Will Fix
The sponsor confirmed this issue will be fixed
WATCHPUG
high
_accumulateFunding()
maker will get the wrong amount of funding fee.Summary
Vulnerability Detail
The formula that calculates the amount of funding in
Version#_accumulateFunding()
on the maker side is incorrect. This leads to an incorrect distribution of funding between the minor and the maker's side.PoC
Given:
Then:
While the maker only matches for
1
of the major part and contributes to half of the total short side, it takes the entire funding.Impact
Code Snippet
https://github.com/sherlock-audit/2023-07-perennial/blob/main/perennial-v2/packages/perennial/contracts/types/Version.sol#L207-L215
Tool used
Manual Review
Recommendation
The correct formula to calculate the amount of funding belonging to the maker side should be:
The text was updated successfully, but these errors were encountered: