> For the complete documentation index, see [llms.txt](https://docs.valantis.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.valantis.xyz/amms-and-vaults/design-space/modules/oracle.md).

# Oracle Module

<figure><img src="https://986147118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1hNJeG4CApeBcE2NlR61%2Fuploads%2Fgit-blob-219971c405f4ed807ea792890d5c3242c229f1b4%2FOracle%20Module%20Fig.%201_V2%20(1).jpg?alt=media" alt=""><figcaption><p>Oracle Module in context</p></figcaption></figure>

The Oracle Module enables the pool to checkpoint relevant data and state updates after each swap is concluded. Primitives such as TWAP price oracles or volatility oracles can be implemented as Oracle Modules. Oracle Modules implement the following interface:

```solidity
interface ISovereignOracle {
    function pool() external view returns (address);

    function writeOracleUpdate(
        bool isZeroToOne,
        uint256 amountInUsed,
        uint256 fee,
        uint256 amountOut
    ) external;
}
```

`writeOracleUpdate` contains the following inputs:

* `isZeroToOne` Direction of the swap
* `amountInUsed` total input token amount that has been transferred from the user.
* `fee` swap fee charged to the user.
* `amountOut` output token amount transferred to the user.

The Oracle Module is optional and only settable once by the `poolManager`. Once added to a pool, the Oracle Module cannot be removed or changed. This is to ensure that third-party protocols relying on this pool’s oracle can be made sure that the structure of this oracle’s functionality remains immutable.

Sovereign Oracle cannot be set in case reserves are stored outside of the pool (`sovereignVault` is not `pool`).

Developers wishing to rely on the Sovereign Oracle need to carefully understand the assumptions and risks inherent to all other modules in the pool. For example, a faulty or malicious `verifierModule` could censor swaps (thus preventing oracle updates), and a faulty or malicious Liquidity Module could provide inaccurate price data. Reliance on oracles must always be carefully assessed in the context of all its pool dependencies.
