Oracle Module
Last updated
Last updated
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:
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.