> For the complete documentation index, see [llms.txt](https://tech.usual.money/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tech.usual.money/smart-contracts/utility-contracts/usd0a/debtuscc-oracle.md).

# DebtUSCC Oracle

### High-Level Overview <a href="#high-level-overview" id="high-level-overview"></a>

The DebtUSCCOracle contract is a proxy oracle that provides Chainlink-compatible price data for DebtUSCC tokens. Unlike a standard oracle wrapper, this contract returns the USCC/USD price from the time of the last deposit in the ReverseGateway contract, ensuring price consistency for all outstanding DebtUSCC tokens.

### Contract Summary <a href="#contract-summary" id="contract-summary"></a>

The contract provides a Chainlink-compatible aggregator interface that:

* Integrates with the ReverseGateway to track deposit timing
* Returns the USCC/USD price from the oracle round captured during the last deposit
* Maintains price consistency for all outstanding DebtUSCC tokens

### Key Functionality <a href="#key-functionality" id="key-functionality"></a>

#### latestRoundData <a href="#latestrounddata" id="latestrounddata"></a>

Returns the USCC/USD price data based on the last ReverseGateway deposit:

* **If no deposits exist** (nextOrderId == 1): Returns the latest price from the USCC/USD feed
* **If deposits exist**: Returns the price from the USCC/USD feed at the roundId captured during the last deposit

This design ensures that all outstanding DebtUSCC tokens are priced consistently at the same price point (the price when they were minted), maintaining accounting integrity and preventing price inconsistencies.

#### getRoundData <a href="#getrounddata" id="getrounddata"></a>

Not supported - reverts with `NotSupported` error. Only `latestRoundData` is available.

### Integration with ReverseGateway <a href="#integration-with-reversegateway" id="integration-with-reversegateway"></a>

The contract queries the ReverseGateway contract to:

1. Get the next order ID to determine if any deposits have occurred
2. Retrieve the roundId from the last order (if deposits exist)
3. Use that roundId to fetch the historical USCC/USD price from the oracle

This integration ensures that the DebtUSCC oracle price reflects the price at which the debt tokens were minted, maintaining consistency with the single deposit constraint in ReverseGateway.

### Constants <a href="#constants" id="constants"></a>

* **PRICE\_FEED\_DECIMALS**: 8 (standard Chainlink decimals)

### Immutable Variables <a href="#immutable-variables" id="immutable-variables"></a>

* **USCC\_USD\_FEED**: The underlying USCC/USD Chainlink price feed aggregator
* **REVERSE\_GATEWAY**: The ReverseGateway contract address

### Use Case <a href="#use-case" id="use-case"></a>

The DebtUSCCOracle is used by the protocol to price DebtUSCC tokens. By returning the price from the time of the last deposit, the oracle ensures that all outstanding DebtUSCC tokens maintain a consistent price point, which is critical for:

* Maintaining accounting accuracy
* Ensuring USD0a price stability
* Aligning with the single deposit constraint in ReverseGateway


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://tech.usual.money/smart-contracts/utility-contracts/usd0a/debtuscc-oracle.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
