This repository has been archived by the owner on Jul 14, 2024. It is now read-only.
osmanozdemir1 - LibTWAPOracle::consult()
function should update prices before returning
#187
Labels
Non-Reward
This issue will not receive a payout
osmanozdemir1
high
LibTWAPOracle::consult()
function should update prices before returningSummary
LibTWAPOracle::getTwapPrice()
function is used to getDollarToken
price and the returned value is used in the major functions likemintDollar()
andredeemDollar()
in theLibUbiquityPool.sol
. However, this function returns average prices without updating.Vulnerability Detail
Down below, you can see the getTwapPrice(), and the consult() functions.
The
getTwapPrice()
function directly calls theconsult()
, and returns these values. However, the returned average prices in theconsult()
function is not up to date. It must update thetwapOracleStorage
first, and then return the average prices.Impact
The
getTwapPrice()
function is used ingetDollarPriceUsd()
function here, which meansgetDollarPriceUsd()
always returns stale prices. The returned value is used in the two most crucial functions:mintDollar
andredeemDollar
. All of these actions are performed with stale prices.Code Snippet
https://github.com/sherlock-audit/2023-12-ubiquity/blob/main/ubiquity-dollar/packages/contracts/src/dollar/libraries/LibTWAPOracle.sol#L111C1-L122C6
https://github.com/sherlock-audit/2023-12-ubiquity/blob/main/ubiquity-dollar/packages/contracts/src/dollar/libraries/LibTWAPOracle.sol#L159C1-L164C6
Tool used
Manual Review
Recommendation
Duplicate of #34
The text was updated successfully, but these errors were encountered: