PriceOracleperforms two necessary functions for the SIREN protocol:
PriceOraclestores the settlement price at expiration for every Series' underlying asset. On every Friday at 8am UTC, an offchain bot process is scheduled to fetch and set the current price for every asset traded on the SIREN protocol. Since all
Series'expiration dates are aligned to Friday 8am UTC, this allows any expired Series to fetch the settlement price of the underlying token at expiration and use it along with the
Series'strike price to calculate the payouts for
PriceOraclegives all other protocol contracts a single place to access onchain price data. Currently we use only Chainlink's oracles, but other's like Uniswap V3 could easily be used. Contracts like the
PriceOracleto fetch the current price for the tokens they use. It simplifies the protocol when all other contracts need only have a single address with a known interface for fetching onchain prices.
addTokenPair](#addTokenPair) exist so that as [MinterAmm`s with new underlying tokens and price tokens are deployed, we can add the correct price oracles for these token pairs. If this function was callable by any address, than a malicious address could set their own malicious price oracle, and attack the protocol.
SeriesController](series-controller.md#overview) uses this price to compute the [payouts](glossary.md#option-payouts) for [option tokens](glossary.md#option-tokens). Only token pairs which have been previously added by an admin-only call to [addTokenPair` will execute successfully.
trueif a call to [
setSettlementPrice](#setSettlementPrice) has previously been executed and set the price to a non-zero value, otherwise it isfalse`
WBTCwas $34,000, then the value returned by
WBTCSeries would be
34_000 * 1e8. Only token pairs which have been previously added by an admin-only call to
addTokenPairwill execute successfully. The
PriceOraclefetches this price from an onchain oracle, which for now our all Chainlink Oracles.
SeriesControlleruses this function to ensure the expiration dates of each of its Series is aligned to Friday 8am UTC. The SIREN protocol uses a single date for each week's expiration dates in order to standardize the times at which its Series expire.
underlyingTokendenominated in units of
priceToken, and setting all previous unset settlement dates. This function is intended to be called immediately after every Friday 8am UTC for each of the
PriceOracle's token pairs, so that every Series that has their expiration date on that Frodau 8am UTC date will have the correct settlement date set. For now, an offchain bot process managed by the Siren team is scheduled to call this function for each token pair.
oracleas the price oracle to use for the given token pair of
priceToken. This function uses the
onlyOwnermodifier in order to prevent an malicious address from setting a malicious oracle for a given token pair. Once a token pair has been added with
getSettlementPricefunctions can be called with the given token pair.
PriceOracle's logic contract. The SIREN protocol's contracts use the EIP-1822 standard for implementing upgradeable contracts. This allows us to update vulnerable contracts and keep users' option tokens safe. When the SIREN protocol has reached a certain level of stability, we can remove these safety guards and ensure no one on the Siren team can swap out the smart contract functionality.
PriceOracle's function implementations