safdie - Inconsistent handling of rates signs leading to large shifts in `partyAAvailableBalance` or `partyBAvailableBalance` in `FundingRateFacetImpl.sol` #13
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:
Incorrect balances being calculated.
Parties receiving or losing funds they did not intend to.
Potential disputes between parties regarding the calculation of funding rates.
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.
safdie
Medium
Inconsistent handling of rates signs leading to large shifts in
partyAAvailableBalance
orpartyBAvailableBalance
inFundingRateFacetImpl.sol
Summary
Inconsistent handling of rates signs in
FundingRateFacetImpl.sol
leading to large shifts inpartyAAvailableBalance
orpartyBAvailableBalance
.Root Cause
In the
chargeFundingRate
function of theFundingRateFacetImpl
contract, there is inconsistent handling of the signs of funding rates forParty A
andParty B
. Specifically, the code adjusts theopenedPrice
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-L70Example 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, forParty 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