-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathIOracleProvider.sol
30 lines (26 loc) · 1.72 KB
/
IOracleProvider.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.13;
import { OracleReceipt } from "../types/OracleReceipt.sol";
import { OracleVersion } from "../types/OracleVersion.sol";
import { IMarket } from "./IMarket.sol";
/// @dev OracleVersion Invariants
/// - Version are requested at a timestamp, the current timestamp is determined by the oracle
/// - The current timestamp may not be equal to block.timestamp, for example when batching timestamps
/// - Versions are allowed to "fail" and will be marked as .valid = false
/// - Invalid versions will always include the latest valid price as its price field
/// - Versions must be committed in order, i.e. all requested versions prior to latestVersion must be available
/// - Non-requested versions may be committed, but will not receive a settlement fee
/// - This is useful for immediately liquidating an account with a valid off-chain price in between orders
/// - Satisfying the above constraints, only versions more recent than the latest version may be committed
/// - Current must always be greater than Latest, never equal
interface IOracleProvider {
// sig: 0x652fafab
error OracleProviderUnauthorizedError();
event OracleProviderVersionRequested(uint256 indexed version, bool newPrice);
event OracleProviderVersionFulfilled(OracleVersion version);
function request(IMarket market, address account) external;
function status() external view returns (OracleVersion memory, uint256);
function latest() external view returns (OracleVersion memory);
function current() external view returns (uint256);
function at(uint256 timestamp) external view returns (OracleVersion memory, OracleReceipt memory);
}