# Incorrect price representation

BondOracleAdapter.latestRoundData returned TWAP price in PriceX96 format instead of 18-decimal Chainlink format, corrupting all downstream asset valuations.

- Payout: Audit contest
- Severity: high
- Program: Plaza Finance
- Found by: 0x23r0
- Disclosed: 2024-12-16
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-12-plaza-finance-judging/issues/1016
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-12-plaza-finance%3AH-11
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:high tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:oracle-manipulation

**Target:** BondOracleAdapter oracle contract (Uniswap V3 TWAP)
**Root cause:** latestRoundData computes getPriceX96FromSqrtPriceX96(sqrtTwapX96) and returns it directly without scaling to 18-decimal fixed-point, so the value is ~1e18x larger than a Chainlink-style price.
**Steps:**
1. Call `BondOracleAdapter.latestRoundData()`; observe returned int256 equals raw priceX96 (e.g. 24408239790603697707980053009065971527 for USDC/WETH pool 0x45dda9cb7c25131df268515131f647d726f50608).
2. Compare to expected 18-decimal price (~3245959692053023671448 ≈ 3245.95 USDC/WETH).
3. Convert via `FullMath.mulDiv(10**(18+decimals1-decimals0), FixedPoint96.Q96, priceX96)` to see correct value.
4. Feed the raw return into any consumer expecting 18-decimal price; all valuations are off by orders of magnitude.
**How found:** Code review of the oracle adapter: noticed the return value of getPriceX96FromSqrtPriceX96 was passed straight through without decimal normalization, then verified numerically against a real pool's slot0 sqrtPriceX96.
**Insight:** When auditing oracle adapters, always check the unit/decimals contract of the return value against the consumer's expectation (Chainlink 8/18 decimals); PriceX96 outputs from TickMath/FullMath are a common source of silent scale mismatches.

## Proof of concept (copied exactly from the original report)

**PoC computing priceX96 from sqrtPriceX96**

```
Contract Address: 0x45dda9cb7c25131df268515131f647d726f50608
Function: slot0()
Output: sqrtPriceX96 = 1390618563380010078436460929963734

Step 2: Calculate priceX96 from sqrtPriceX96
Function: getPriceX96FromSqrtPriceX96

function getPriceX96FromSqrtPriceX96(sqrtPriceX96) {
  return FullMath.mulDiv(sqrtPriceX96, sqrtPriceX96, FixedPoint96.Q96);
}
Output: 24408239790603697707980053009065971527
```

**PoC converting priceX96 to 18-decimal price**

```
FullMath.mulDiv(10 ** (18 + decimals1 - decimals0), FixedPoint96.Q96, priceX96)
Output: 3245959692053023671448
```

