The Oracle Lifecycle

Present Infrastructure

Currently the Oracle is a Rust-based crank that runs on a single machine and has an open websocket connection with Volmex, our data provider, for each underlying asset of interest. Every time a value is received, it is placed in a thread queue, and once a second, any new value received to that queue is sent via transaction to update the relevant Oracle state on chain via the update_oracle_data action on VolOracle contract:

#[derive(Accounts)]
#[instruction(name: String)]
pub struct UpdateOracleData<'info> {
    /// The oracle account that will be updated
    #[account(mut, seeds=[b"oracle", name.as_bytes().as_ref()], bump)]
    pub oracle: Account<'info, OracleAccount>,
    /// The admin account that is allowed to update the oracle admin account
    #[account(mut)]
    pub admin: Signer<'info>,
    /// The clock sysvar is required to get the current timestamp
    pub clock: Sysvar<'info, Clock>,
}

// Snippet of the update_oracle_data function signature to show the data signature
pub fn handle_update_oracle_data(
    ctx: Context<UpdateOracleData>,
    name: String,
    value: i32,
    implied: bool,
    timestamp: i64,
    time_window: String,
) -> Result<()> { /*..*/ }

Failure Modes

Notable failure modes are if we do not receive a value within 5 seconds from Volmex, the whole program panics and restarts, and warnings are sent to the developers if the program wallet drops below 0.5 SOL. There are also warnings if on-chain values are more than 3 minutes old for any Oracle.

If any on-chain values become more than 5 minutes old, the entire VolPerp contract shuts down and becomes unusable (specifically, creating new PositionRequests and the Liquidation Engine).

Future Considerations

As we evolve Imperial, we intend to offload our Oracle setup to an existing provider that deals with such matters or move to a federated and decentralized system where multiple sources can provide data. The current setup is too crude and too prone to error to be used long term and is a stop-gap measure while we test out product-market fit.

Last updated