Skip to content

Latest commit

 

History

History
44 lines (29 loc) · 1.17 KB

019.md

File metadata and controls

44 lines (29 loc) · 1.17 KB

Tame Foggy Pony

High

Not considering exponents when fetching price from Pyth causes issues

Summary

No response

Root Cause

Upon fetching a price from Pyth, we call the following code:

function currentValue() external view override returns (uint256) {
        IPyth.Price memory price = pythOracle.getPriceUnsafe(tokenId);
        require(price.publishTime < block.timestamp - noOlderThan, "Stale Price");
        return uint256(uint64(price.price));
    }

Pyth provides exponents so the price can be brought into the correct decimals. However, this is not done here, resulting in using different decimals for different assets.

Internal pre-conditions

No response

External pre-conditions

No response

Attack Path

  1. Price is fetched from Pyth when getting the exchange rate for tokens
  2. One asset has an exponent of 5 while another one has an exponent of 6
  3. This results in wrong exchange rate due to not considering the exponents

Impact

Wrong exchange rate calculation causing all kinds of serious issues across the protocol such as filling orders when they shouldn't be

PoC

No response

Mitigation

Consider the exponents