Oracles

[Note: code to be released]

Oracles provide attestation to the system to facilitate unlocking of funds when intended conditions are met. The oracle is currently run as a TEE based service with decentralized oracles being currently developed.

Implementation

The oracle implements the following oracle interface, expected by the CCD:

interface IFabriqOracle {
  // expected to return true if and only if the order has been filled 
  // correctly on its target chain
  function isFilled(bytes32 intentHash) external returns (bool);
  
  // called by the CCD when the order is first initialized
  // can be used to implement an optimistic oracle with a challenge period
  function initIntent(bytes32 intentHash) external;
}

The current oracle contract implementation:

import { AccessControl } from "@openzeppelin-contracts-4.9.6/access/AccessControl.sol";
import { IFabriqOracle } from "./interfaces/IFabriqOracle.sol";

contract PermissionedOracle is IFabriqOracle, AccessControl {
    bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR");
    mapping(bytes32 => bool) public filledOrders;

    constructor(
        address admin,
        address operator
    ) {
        _setupRole(DEFAULT_ADMIN_ROLE, admin);
        _setupRole(OPERATOR_ROLE, operator);
    }

    function isFilled(bytes32 intentHash) public view returns (bool) {
        return filledOrders[intentHash];
    }

    function update(bytes32 intentHash) public onlyRole(OPERATOR_ROLE) {
        filledOrders[intentHash] = true;
    }

    // not needed here because there is no challenge period
    function initIntent(bytes32) public pure {}
}

Last updated