QA Report #131
Labels
bug
Something isn't working
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
sponsor disputed
Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue
Lines of code
https://github.com/code-423n4/2022-02-hubble/blob/main/contracts/AMM.sol#L354
https://github.com/code-423n4/2022-02-hubble/blob/main/contracts/AMM.sol#L392
https://github.com/code-423n4/2022-02-hubble/blob/main/contracts/AMM.sol#L656-L704
Vulnerability details
Impact
The
getTwapPrice()
is used by thesettleFunding()
function to calculate the premium and subsequently the new funding rate. The_calcTwap()
function will use the latest reserve snapshot if this snapshot is earlier than thebaseTimestamp
. As a result, if there are no changes on the underlying positions within theAMM
, then the_addReserveSnapshot()
function will never be called to update the price data. Over time, if theAMM
is not being actively used, the funding rate can end up being drastically different to what it should be.Proof of Concept
Tools Used
Manual code review.
Recommended Mitigation Steps
Consider calling
_addReserveSnapshot()
insettleFunding()
to ensure the most up to date price is being used before calculatingpremium
.The text was updated successfully, but these errors were encountered: