Skip to content
This repository has been archived by the owner on Jul 14, 2024. It is now read-only.

the-first-elder - PRICES FROM TWAP ORACLE CAN BECOME STALE #84

Closed
sherlock-admin2 opened this issue Jan 10, 2024 · 2 comments
Closed

the-first-elder - PRICES FROM TWAP ORACLE CAN BECOME STALE #84

sherlock-admin2 opened this issue Jan 10, 2024 · 2 comments
Labels
Non-Reward This issue will not receive a payout

Comments

@sherlock-admin2
Copy link
Contributor

sherlock-admin2 commented Jan 10, 2024

the-first-elder

medium

PRICES FROM TWAP ORACLE CAN BECOME STALE

Summary

The Time-Weighted Average Price (TWAP) oracle is susceptible to providing stale prices due to a lack of validation in the update function regarding the timeliness of price updates.

Vulnerability Detail

The issue arises from the absence of validation in the update function, which fails to ensure that the TWAP prices are updated within a reasonable timeframe. This becomes problematic when the trading volume for a particular security fluctuates throughout the day, causing the TWAP price to inaccurately reflect the current market conditions at the time of execution.

For instance, if a security experiences low trading volume early in the day, the TWAP price may be skewed towards the opening price. Subsequently, when the volume increases later in the day, the TWAP price might be higher than the actual market price, leading to suboptimal execution prices for traders.

Moreover, in scenarios with very low trading volume, the TWAP price might remain relatively unchanged throughout the day. This can result in orders being executed at prices that do not accurately represent the current market conditions, potentially signaling misleading information to vigilant traders monitoring the market.

Impact

The vulnerability introduces the risk of executing orders at prices that are not reflective of the true market conditions, impacting the effectiveness and accuracy of the TWAP oracle.

Code Snippet

https://github.com/sherlock-audit/2023-12-ubiquity/blob/main/ubiquity-dollar/packages/contracts/src/dollar/libraries/LibTWAPOracle.sol#L68

Tool used

Manual Review

Recommendation

It is crucial to implement validation checks within the update function to ensure that the TWAP prices are updated within a reasonable timeframe. This adjustment will enhance the accuracy of the TWAP oracle, particularly in situations where trading volumes fluctuate. Careful consideration of market dynamics should be taken into account to optimize the functionality of the TWAP oracle and mitigate potential risks associated with stale prices

Duplicate of #34

@github-actions github-actions bot added the Excluded Excluded by the judge without consulting the protocol or the senior label Jan 14, 2024
@sherlock-admin2
Copy link
Contributor Author

1 comment(s) were left on this issue during the judging contest.

auditsea commented:

The issue describes about TWAP can be manipulated because update function can be called anytime and by anyone, thus TWAP period can be as short as 1 block. It seems like a valid issue but after caeful consideration, it's noticed that the TWAP issue does not come from its period but the logic itself is incorrect, thus marking this as Invalid

@github-actions github-actions bot added Medium A valid Medium severity issue Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label and removed Excluded Excluded by the judge without consulting the protocol or the senior labels Jan 16, 2024
@sherlock-admin2
Copy link
Contributor Author

1 comment(s) were left on this issue during the judging contest.

auditsea commented:

The issue describes about TWAP can be manipulated because update function can be called anytime and by anyone, thus TWAP period can be as short as 1 block. It seems like a valid issue but after caeful consideration, it's noticed that the TWAP issue does not come from its period but the logic itself is incorrect, thus marking this as Invalid

@sherlock-admin2 sherlock-admin2 changed the title Vast Aegean Porcupine - PRICES FROM TWAP ORACLE CAN BECOME STALE the-first-elder - PRICES FROM TWAP ORACLE CAN BECOME STALE Jan 24, 2024
@sherlock-admin2 sherlock-admin2 added the Reward A payout will be made for this issue label Jan 24, 2024
@Czar102 Czar102 removed the Medium A valid Medium severity issue label Feb 19, 2024
@sherlock-admin sherlock-admin added Non-Reward This issue will not receive a payout and removed Reward A payout will be made for this issue labels Feb 19, 2024
@sherlock-admin2 sherlock-admin2 removed the Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label label Feb 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Non-Reward This issue will not receive a payout
Projects
None yet
Development

No branches or pull requests

3 participants