sherlock-audit / 2024-09-symmio-v0-8-4-update-contest-judging

0 stars 0 forks source link

safdie - Inconsistent handling of rates signs leading to large shifts in `partyAAvailableBalance` or `partyBAvailableBalance` in `FundingRateFacetImpl.sol` #13

Open sherlock-admin4 opened 1 week ago

sherlock-admin4 commented 1 week ago

safdie

Medium

Inconsistent handling of rates signs leading to large shifts in partyAAvailableBalance or partyBAvailableBalance in FundingRateFacetImpl.sol

Summary

Inconsistent handling of rates signs in FundingRateFacetImpl.sol leading to large shifts in partyAAvailableBalance or partyBAvailableBalance.

Root Cause

In the chargeFundingRate function of the FundingRateFacetImpl contract, there is inconsistent handling of the signs of funding rates for Party A and Party B. Specifically, the code adjusts the openedPrice of quotes based on whether the funding rate is positive or negative, but this logic can lead to unintended consequences if not properly validated. https://github.com/sherlock-audit/2024-09-symmio-v0-8-4-update-contest/blob/main/protocol-core/contracts/facets/FundingRate/FundingRateFacetImpl.sol#L50-L70

Example scenario:

Funding rate calculation: If a positive funding rate is provided, the price is adjusted according to the position type. If a negative funding rate is provided, the opposite logic is applied, leading to potential confusion.

Inconsistent sign handling: For Party A in a long position, a positive funding rate increases the opened price, while a negative funding rate decreases it. Conversely, for Party B, the behavior is reversed. This inconsistency could lead to confusion and unintended financial implications.

Implications: If the logic is not clear or consistent, it could lead to unintended consequences, such as:

Internal pre-conditions

No response

External pre-conditions

No response

Attack Path

No response

Impact

Parties may unintentionally incur losses or receive unintended gains due to miscalculated funding rates based on inconsistent sign handling.

PoC

No response

Mitigation

No response