Oracle Contract
Overview
The Oracle
contract serves as an intermediary for settling and liquidating orders on a decentralized trading platform. It interacts with other contracts to perform critical functions like settling trades and liquidating positions based on market data.
Contract Dependencies
- Owner: Address of the contract owner.
- Router: Address of the router contract.
- Dark Oracle: Address of the dark oracle forwarder. This address is authorized to forward prices and fill retail user's pending orders and liquidate user's positions that are under-collateralized.
- Treasury: Address of the treasury contract.
- Trading: Address of the trading contract.
Variables
- Requests Per Funding: The number of requests allowed per funding cycle.
- Cost Per Request: Cost associated with each oracle request (0.0006 ETH).
- Requests Since Funding: Counter for requests since the last funding.
Events
- Settlement Error: Emitted when there is an error in settling orders.
Constructor
- Initializes the contract with the owner's address.
Governance Methods
- setOwner: Assigns a new owner to the contract.
- setRouter: Sets the router and updates associated contract addresses.
- setParams: Configures parameters like requests per funding and cost per request.
Core Methods
- settleOrders: Processes settlement of multiple orders.
- liquidatePositions: Handles the liquidation of multiple positions.
- _tallyOracleRequests: Internally tracks and manages oracle request counts and funding.
Modifiers
- onlyOwner: Ensures that only the owner can call certain functions.
- onlyDarkOracle: Restricts access to functions to the dark oracle.