Forkchoice Ethereum Mainnet

Address Contract Partially Verified

Address 0x914D5Cb27cb30E80BdE8215ff577eD63Eb986B79
Balance 0 ETH
Nonce 1
Code Size 5574 bytes
Last Active
Indexed Transactions 1 (24,604,11724,604,117)
Gas Used (indexed) 38,980
External Etherscan · Sourcify

Contract Bytecode

5574 bytes
0x608060405234801561001057600080fd5b50600436106101425760003560e01c8063972e8c5d116100b8578063b58a0d741161007c578063b58a0d74146102f7578063ca15c8731461030a578063cfed246b1461031d578063d547741f146103a1578063e1a45218146103b4578063fd45a433146103bd57600080fd5b8063972e8c5d1461027b578063a2011b3f146102a0578063a217fddf146102c7578063aa5fd449146102cf578063abbb9f4c146102e257600080fd5b80632f2ff15d1161010a5780632f2ff15d146101f157806336568abe1461020457806357ab54f7146102175780635cdb595c1461022a5780639010d07c1461023d57806391d148541461026857600080fd5b806301ffc9a714610147578063196c74a51461016f57806320f3a5db14610184578063215373fa146101ad578063248a9ca3146101c0575b600080fd5b61015a61015536600461113a565b6103d0565b60405190151581526020015b60405180910390f35b61018261017d36600461117d565b6103fb565b005b60025461019a90640100000000900461ffff1681565b60405161ffff9091168152602001610166565b6101826101bb3660046111aa565b61049c565b6101e36101ce3660046111c5565b60009081526020819052604090206001015490565b604051908152602001610166565b6101826101ff3660046111f5565b61056f565b6101826102123660046111f5565b61059a565b610182610225366004611221565b61061d565b610182610238366004611297565b6106ad565b61025061024b366004611303565b610766565b6040516001600160a01b039091168152602001610166565b61015a6102763660046111f5565b610785565b60025461028b9063ffffffff1681565b60405163ffffffff9091168152602001610166565b6101e37f61c92169ef077349011ff0b1383c894d86c5f0b41d986366b58a6cf31e93beda81565b6101e3600081565b6101826102dd366004611325565b6107ae565b6101e360008051602061157183398151915281565b61018261030536600461134f565b6109d4565b6101e36103183660046111c5565b610aa2565b61036961032b366004611379565b6003602052600090815260409020805460019091015467ffffffffffffffff811690600160401b810463ffffffff1690600160601b900461ffff1684565b6040805194855267ffffffffffffffff909316602085015263ffffffff9091169183019190915261ffff166060820152608001610166565b6101826103af3660046111f5565b610ab9565b6101e361271081565b6101826103cb366004611325565b610adf565b60006001600160e01b03198216635a05180f60e01b14806103f557506103f582610e5a565b92915050565b6000805160206115718339815191526104148133610e8f565b8163ffffffff1660000361043b57604051631888d4c760e21b815260040160405180910390fd5b6002546040805163ffffffff928316815291841660208301527f3fdb7674318aa62db5d098c12d253baa6768047363f86331c154f8902fb89767910160405180910390a1506002805463ffffffff191663ffffffff92909216919091179055565b6000805160206115718339815191526104b58133610e8f565b8161ffff166000036104da57604051633a33aa1d60e11b815260040160405180910390fd5b6127108261ffff161061050057604051633a33aa1d60e11b815260040160405180910390fd5b6002546040805161ffff6401000000009093048316815291841660208301527fe68a6f52a776b223053026f9d13d328f41a7ee2c014ddeb7e53fd2b87f60a1ee910160405180910390a1506002805461ffff9092166401000000000265ffff0000000019909216919091179055565b60008281526020819052604090206001015461058b8133610e8f565b6105958383610ef3565b505050565b6001600160a01b038116331461060f5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b6106198282610f15565b5050565b6000805160206115718339815191526106368133610e8f565b6001600160a01b038316600081815260036020908152604091829020600101805463ffffffff60401b1916600160401b63ffffffff88169081029190911790915591519182527f8a407b7e7bb510f122f7c83d0b6254ab915109ec409fdf2288ccf1b69c30cc2391015b60405180910390a2505050565b7f61c92169ef077349011ff0b1383c894d86c5f0b41d986366b58a6cf31e93beda6106d88133610e8f565b8382146106fb576040516001621398b960e31b0319815260040160405180910390fd5b60005b8481101561075e5761074e86868381811061071b5761071b611394565b90506020020160208101906107309190611379565b85858481811061074257610742611394565b905060200201356107ae565b610757816113c0565b90506106fe565b505050505050565b600082815260016020526040812061077e9083610f37565b9392505050565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b7f61c92169ef077349011ff0b1383c894d86c5f0b41d986366b58a6cf31e93beda6107d98133610e8f565b6001600160a01b0383166108005760405163e6c4247b60e01b815260040160405180910390fd5b81600003610821576040516313a8ad7d60e11b815260040160405180910390fd5b6001600160a01b038316600090815260036020526040812060018101544292600160401b90910463ffffffff1690036108c25760025460018201805463ffffffff60401b191663ffffffff928316600160401b9081029190911791829055604051910490911681526001600160a01b038616907f8a407b7e7bb510f122f7c83d0b6254ab915109ec409fdf2288ccf1b69c30cc239060200160405180910390a25b6001810154600160601b900461ffff1660000361094c5760025460018201805461ffff60601b191664010000000090920461ffff908116600160601b9081029390931791829055604051929091041681526001600160a01b038616907f0cc0dbc1f717cd95222d6eccb53dbf4b15dffca5e2666d93ccbe37c3249a3dbc9060200160405180910390a25b805460018201805486845567ffffffffffffffff19811667ffffffffffffffff8681169182179093556040805185815293909216602084018190529183018890526060830152906001600160a01b038816907fe1835c6d053ab96fb521e0b87fcdb281ca989d57558df21dde4f093b50e8a20e9060800160405180910390a250505050505050565b6000805160206115718339815191526109ed8133610e8f565b8161ffff16600003610a1257604051633a33aa1d60e11b815260040160405180910390fd5b6127108261ffff1610610a3857604051633a33aa1d60e11b815260040160405180910390fd5b6001600160a01b038316600081815260036020908152604091829020600101805461ffff60601b1916600160601b61ffff88169081029190911790915591519182527f0cc0dbc1f717cd95222d6eccb53dbf4b15dffca5e2666d93ccbe37c3249a3dbc91016106a0565b60008181526001602052604081206103f590610f43565b600082815260208190526040902060010154610ad58133610e8f565b6105958383610f15565b6001600160a01b03821660008181526003602052604090205490610b165760405163e6c4247b60e01b815260040160405180910390fd5b80600003610b37576040516313a8ad7d60e11b815260040160405180910390fd5b6001600160a01b0383166000908152600360205260409020600101544290610b769063ffffffff600160401b8204169067ffffffffffffffff166113d9565b67ffffffffffffffff161015610b9f57604051630cd5fa0760e11b815260040160405180910390fd5b6001600160a01b038316600090815260036020526040812060010154600160601b900461ffff1690612710610bd483856113fa565b610bde9190611419565b90506000838511610bf857610bf3858561143b565b610c02565b610c02848661143b565b90508181111561075e57604051630df22a0f60e21b815260040160405180910390fd5b610c2f8282610785565b610619576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055610c653390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600061077e836001600160a01b038416610f4d565b60606000610ccd8360026113fa565b610cd890600261144e565b67ffffffffffffffff811115610cf057610cf0611461565b6040519080825280601f01601f191660200182016040528015610d1a576020820181803683370190505b509050600360fc1b81600081518110610d3557610d35611394565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110610d6457610d64611394565b60200101906001600160f81b031916908160001a9053506000610d888460026113fa565b610d9390600161144e565b90505b6001811115610e0b576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110610dc757610dc7611394565b1a60f81b828281518110610ddd57610ddd611394565b60200101906001600160f81b031916908160001a90535060049490941c93610e0481611477565b9050610d96565b50831561077e5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610606565b60006001600160e01b03198216637965db0b60e01b14806103f557506301ffc9a760e01b6001600160e01b03198316146103f5565b610e998282610785565b61061957610eb1816001600160a01b03166014610cbe565b610ebc836020610cbe565b604051602001610ecd9291906114b2565b60408051601f198184030181529082905262461bcd60e51b825261060691600401611527565b610efd8282610c25565b60008281526001602052604090206105959082610ca9565b610f1f8282610f9c565b60008281526001602052604090206105959082611001565b600061077e8383611016565b60006103f5825490565b6000818152600183016020526040812054610f94575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556103f5565b5060006103f5565b610fa68282610785565b15610619576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600061077e836001600160a01b038416611040565b600082600001828154811061102d5761102d611394565b9060005260206000200154905092915050565b6000818152600183016020526040812054801561112957600061106460018361143b565b85549091506000906110789060019061143b565b90508181146110dd57600086600001828154811061109857611098611394565b90600052602060002001549050808760000184815481106110bb576110bb611394565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806110ee576110ee61155a565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506103f5565b60009150506103f5565b5092915050565b60006020828403121561114c57600080fd5b81356001600160e01b03198116811461077e57600080fd5b803563ffffffff8116811461117857600080fd5b919050565b60006020828403121561118f57600080fd5b61077e82611164565b803561ffff8116811461117857600080fd5b6000602082840312156111bc57600080fd5b61077e82611198565b6000602082840312156111d757600080fd5b5035919050565b80356001600160a01b038116811461117857600080fd5b6000806040838503121561120857600080fd5b82359150611218602084016111de565b90509250929050565b6000806040838503121561123457600080fd5b61123d836111de565b915061121860208401611164565b60008083601f84011261125d57600080fd5b50813567ffffffffffffffff81111561127557600080fd5b6020830191508360208260051b850101111561129057600080fd5b9250929050565b600080600080604085870312156112ad57600080fd5b843567ffffffffffffffff808211156112c557600080fd5b6112d18883890161124b565b909650945060208701359150808211156112ea57600080fd5b506112f78782880161124b565b95989497509550505050565b6000806040838503121561131657600080fd5b50508035926020909101359150565b6000806040838503121561133857600080fd5b611341836111de565b946020939093013593505050565b6000806040838503121561136257600080fd5b61136b836111de565b915061121860208401611198565b60006020828403121561138b57600080fd5b61077e826111de565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016113d2576113d26113aa565b5060010190565b67ffffffffffffffff818116838216019080821115611133576111336113aa565b6000816000190483118215151615611414576114146113aa565b500290565b60008261143657634e487b7160e01b600052601260045260246000fd5b500490565b818103818111156103f5576103f56113aa565b808201808211156103f5576103f56113aa565b634e487b7160e01b600052604160045260246000fd5b600081611486576114866113aa565b506000190190565b60005b838110156114a9578181015183820152602001611491565b50506000910152565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516114ea81601785016020880161148e565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161151b81602884016020880161148e565b01602801949350505050565b602081526000825180602084015261154681604085016020870161148e565b601f01601f19169190910160400192915050565b634e487b7160e01b600052603160045260246000fdfef45c97b23e2beeefda80e1ce5cb3e234aa7b6888ad5cbabb75bfd654dd8e102da26469706673582212206edddf49c712834a79fe59a4e003f6de46559d401742616690f19a0c3e50240c64736f6c63430008100033

Verified Source Code Partial Match

Compiler: v0.8.16+commit.07a7930e EVM: london Optimization: Yes (200 runs)
OndoSanityCheckOracle.sol 270 lines
/**SPDX-License-Identifier: BUSL-1.1
      ▄▄█████████▄
   ╓██▀└ ,╓▄▄▄, '▀██▄
  ██▀ ▄██▀▀╙╙▀▀██▄ └██µ           ,,       ,,      ,     ,,,            ,,,
 ██ ,██¬ ▄████▄  ▀█▄ ╙█▄      ▄███▀▀███▄   ███▄    ██  ███▀▀▀███▄    ▄███▀▀███,
██  ██ ╒█▀'   ╙█▌ ╙█▌ ██     ▐██      ███  █████,  ██  ██▌    └██▌  ██▌     └██▌
██ ▐█▌ ██      ╟█  █▌ ╟█     ██▌      ▐██  ██ └███ ██  ██▌     ╟██ j██       ╟██
╟█  ██ ╙██    ▄█▀ ▐█▌ ██     ╙██      ██▌  ██   ╙████  ██▌    ▄██▀  ██▌     ,██▀
 ██ "██, ╙▀▀███████████⌐      ╙████████▀   ██     ╙██  ███████▀▀     ╙███████▀`
  ██▄ ╙▀██▄▄▄▄▄,,,                ¬─                                    '─¬
   ╙▀██▄ '╙╙╙▀▀▀▀▀▀▀▀
      ╙▀▀██████R⌐
 */
pragma solidity 0.8.16;

import "contracts/globalMarkets/tokenManager/sanityCheckOracle/IOndoSanityCheckOracle.sol";
import "contracts/external/openzeppelin/contracts/access/AccessControlEnumerable.sol";

/**
 * @title  OndoSanityCheckOracle
 * @author Ondo Finance
 * @notice This contract is used to post and validate prices to be referenced as a sanity check when
 *         minting and redeeming tokens. Prices are only valid if they are within some bps-based
 *         deviation from the posted price and are not stale.
 */
contract OndoSanityCheckOracle is
  IOndoSanityCheckOracle,
  AccessControlEnumerable
{
  /// Basis points denominator (10,000 = 100%)
  uint256 public constant BPS_DENOMINATOR = 10_000;
  /// Role for posting prices
  bytes32 public constant SETTER_ROLE = keccak256("SETTER_ROLE");
  /// Role for configuring oracle parameters
  bytes32 public constant CONFIGURER_ROLE = keccak256("CONFIGURER_ROLE");

  /**
   * @notice Struct to store price data for a token
   * @param  price               The price of the token in USD with 18 decimals
   * @param  lastUpdated         Unix timestamp of when the price was last updated
   * @param  maxTimeDelay        Number of seconds before the price is considered stale
   * @param  allowedDeviationBps Allowed deviation from posted price in basis points
   */
  struct PriceData {
    uint256 price;
    uint64 lastUpdated;
    uint32 maxTimeDelay;
    uint16 allowedDeviationBps;
  }

  /// How long a price remains valid for in seconds. Can be overridden on a per-token basis
  uint32 public defaultMaxTimeDelay;

  /// The default allowed deviation in basis points. Can be overridden on a per-token basis
  uint16 public defaultDeviationBps;

  /// Mapping of token address to price data
  mapping(address => PriceData) public prices;

  /**
   * @notice Emitted when a new price is posted for a token
   * @param  token           The address of the token
   * @param  lastPricePosted The last price posted for the token in USD with 18 decimals
   * @param  lastUpdated     The last time the price was updated
   * @param  newPrice        The new price of the token in USD with 18 decimals
   * @param  updateAt        The timestamp when the price was updated
   */
  event PricePosted(
    address indexed token,
    uint256 lastPricePosted,
    uint256 lastUpdated,
    uint256 newPrice,
    uint256 updateAt
  );

  /**
   * @notice Emitted when the allowed deviation is set for a token
   * @param  token               The address of the token
   * @param  allowedDeviationBps The allowed deviation in basis points
   */
  event AllowedDeviationSet(address indexed token, uint16 allowedDeviationBps);

  /**
   * @notice Emitted when the default allowed deviation is set
   * @param  oldDeviationBps The old allowed deviation in basis points
   * @param  newDeviationBps The new allowed deviation in basis points
   */
  event DefaultAllowedDeviationSet(
    uint16 oldDeviationBps,
    uint16 newDeviationBps
  );

  /**
   * @notice Emitted when the maximum time before a price is considered stale is set
   * @param token           The address of the token
   * @param maxTimeDelay    The maximum time before a price is considered stale
   */
  event MaxTimeDelaySet(address indexed token, uint256 maxTimeDelay);

  /**
   * @notice Emitted when the default maximum time before a price is considered stale is set
   * @param  oldMaxTimeDelay The old maximum time before a price is considered stale
   * @param  newMaxTimeDelay The new maximum time before a price is considered stale
   */
  event DefaultMaxTimeDelaySet(uint32 oldMaxTimeDelay, uint32 newMaxTimeDelay);

  /// Error thrown when an address is invalid (zero address)
  error InvalidAddress();
  /// Error thrown when trying to validate a price that hasn't been set
  error PriceNotSet();
  /// Error thrown when deviation bps is invalid (0 or >= 10,000)
  error InvalidDeviationBps();
  /// Error thrown when maximum time delay is invalid (0)
  error InvalidMaxTimeDelay();
  /// Error thrown when the price deviates too much from the posted price
  error PriceOutOfRange();
  /// Error thrown when the posted price is stale
  error StalePrice();
  /// Error thrown when array lengths don't match
  error LengthMismatch();

  /**
   * @param admin                   The admin address that is initialized with all roles
   * @param _defaultDeviationBps    The default allowed deviation in basis points
   * @param _defaultMaxTimeDelay    The default maximum time before a price is considered stale
   */
  constructor(
    address admin,
    uint16 _defaultDeviationBps,
    uint32 _defaultMaxTimeDelay
  ) {
    if (admin == address(0)) revert InvalidAddress();

    _grantRole(DEFAULT_ADMIN_ROLE, admin);
    _grantRole(SETTER_ROLE, admin);
    _grantRole(CONFIGURER_ROLE, admin);

    setDefaultAllowedDeviationBps(_defaultDeviationBps);
    setDefaultMaxTimeDelay(_defaultMaxTimeDelay);
  }

  /**
   * @notice Checks if a price is valid for a token
   * @param  token The address of the token
   * @param  price The price to check
   * @dev    Reverts if the price is not valid
   */
  function validatePrice(address token, uint256 price) external view override {
    uint256 postedPrice = prices[token].price;

    if (token == address(0)) revert InvalidAddress();
    if (postedPrice == 0) revert PriceNotSet();
    if (
      prices[token].lastUpdated + prices[token].maxTimeDelay < block.timestamp
    ) revert StalePrice();

    uint16 bps = prices[token].allowedDeviationBps;
    uint256 allowedDiff = (postedPrice * bps) / BPS_DENOMINATOR;
    uint256 diff = price > postedPrice
      ? price - postedPrice
      : postedPrice - price;

    if (diff > allowedDiff) revert PriceOutOfRange();
  }

  /**
   * @notice Posts a price for a token
   * @param  token The address of the token
   * @param  price The price of the token in USD with 18 decimals
   */
  function postPrice(
    address token,
    uint256 price
  ) public onlyRole(SETTER_ROLE) {
    if (token == address(0)) revert InvalidAddress();
    if (price == 0) revert PriceNotSet();
    uint64 timestamp = uint64(block.timestamp);

    PriceData storage priceData = prices[token];
    if (priceData.maxTimeDelay == 0) {
      priceData.maxTimeDelay = defaultMaxTimeDelay;
      emit MaxTimeDelaySet(token, priceData.maxTimeDelay);
    }

    if (priceData.allowedDeviationBps == 0) {
      priceData.allowedDeviationBps = defaultDeviationBps;
      emit AllowedDeviationSet(token, priceData.allowedDeviationBps);
    }

    uint256 lastPostedPrice = priceData.price;
    uint64 lastUpdated = priceData.lastUpdated;
    priceData.price = price;
    priceData.lastUpdated = timestamp;

    emit PricePosted(token, lastPostedPrice, lastUpdated, price, timestamp);
  }

  /**
   * @notice Posts prices for multiple tokens
   * @param  tokens      The addresses of the tokens
   * @param  tokenPrices The prices of the tokens in USD with 18 decimals
   */
  function postPrices(
    address[] calldata tokens,
    uint256[] calldata tokenPrices
  ) external onlyRole(SETTER_ROLE) {
    if (tokens.length != tokenPrices.length) revert LengthMismatch();
    for (uint256 i = 0; i < tokens.length; ++i) {
      postPrice(tokens[i], tokenPrices[i]);
    }
  }

  /**
   * @notice Sets the allowed deviation in basis points for a token
   * @param  token The address of the token
   * @param  bps   The allowed deviation in basis points
   */
  function setAllowedDeviationBps(
    address token,
    uint16 bps
  ) external onlyRole(CONFIGURER_ROLE) {
    if (bps == 0) revert InvalidDeviationBps();
    if (bps >= BPS_DENOMINATOR) revert InvalidDeviationBps();

    prices[token].allowedDeviationBps = bps;
    emit AllowedDeviationSet(token, bps);
  }

  /**
   * @notice Sets the default allowed deviation in basis points
   * @param  bps The allowed deviation in basis points
   * @dev    This does not affect deviation for tokens that have already been posted
   */
  function setDefaultAllowedDeviationBps(
    uint16 bps
  ) public onlyRole(CONFIGURER_ROLE) {
    if (bps == 0) revert InvalidDeviationBps();
    if (bps >= BPS_DENOMINATOR) revert InvalidDeviationBps();

    emit DefaultAllowedDeviationSet(defaultDeviationBps, bps);
    defaultDeviationBps = bps;
  }

  /**
   * @notice Sets the maximum time before a price is considered stale
   * @param  token           The address of the token
   * @param  maxTimeDelay    The maximum time before a price is considered stale
   */
  function setMaxTimeDelay(
    address token,
    uint32 maxTimeDelay
  ) external onlyRole(CONFIGURER_ROLE) {
    prices[token].maxTimeDelay = maxTimeDelay;
    emit MaxTimeDelaySet(token, maxTimeDelay);
  }

  /**
   * @notice Sets the default maximum time before a price is considered stale
   * @param  maxTimeDelay The maximum time before a price is considered stale
   * @dev    This does not affect time delay for tokens that have already been posted
   */
  function setDefaultMaxTimeDelay(
    uint32 maxTimeDelay
  ) public onlyRole(CONFIGURER_ROLE) {
    if (maxTimeDelay == 0) revert InvalidMaxTimeDelay();

    emit DefaultMaxTimeDelaySet(defaultMaxTimeDelay, maxTimeDelay);
    defaultMaxTimeDelay = maxTimeDelay;
  }
}
IOndoSanityCheckOracle.sol 26 lines
/**SPDX-License-Identifier: BUSL-1.1

      ▄▄█████████▄
   ╓██▀└ ,╓▄▄▄, '▀██▄
  ██▀ ▄██▀▀╙╙▀▀██▄ └██µ           ,,       ,,      ,     ,,,            ,,,
 ██ ,██¬ ▄████▄  ▀█▄ ╙█▄      ▄███▀▀███▄   ███▄    ██  ███▀▀▀███▄    ▄███▀▀███,
██  ██ ╒█▀'   ╙█▌ ╙█▌ ██     ▐██      ███  █████,  ██  ██▌    └██▌  ██▌     └██▌
██ ▐█▌ ██      ╟█  █▌ ╟█     ██▌      ▐██  ██ └███ ██  ██▌     ╟██ j██       ╟██
╟█  ██ ╙██    ▄█▀ ▐█▌ ██     ╙██      ██▌  ██   ╙████  ██▌    ▄██▀  ██▌     ,██▀
 ██ "██, ╙▀▀███████████⌐      ╙████████▀   ██     ╙██  ███████▀▀     ╙███████▀`
  ██▄ ╙▀██▄▄▄▄▄,,,                ¬─                                    '─¬
   ╙▀██▄ '╙╙╙▀▀▀▀▀▀▀▀
      ╙▀▀██████R⌐

 */

pragma solidity 0.8.16;

/**
 * @title  IOndoSanityCheckOracle
 * @author Ondo Finance
 * @notice Interface for validating prices with the sanity check oracle
 */
interface IOndoSanityCheckOracle {
  function validatePrice(address token, uint256 price) external view;
}
AccessControlEnumerable.sol 91 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol)

pragma solidity ^0.8.0;

import "contracts/external/openzeppelin/contracts/access/IAccessControlEnumerable.sol";
import "contracts/external/openzeppelin/contracts/access/AccessControl.sol";
import "contracts/external/openzeppelin/contracts/utils/EnumerableSet.sol";

/**
 * @dev Extension of {AccessControl} that allows enumerating the members of each role.
 */
abstract contract AccessControlEnumerable is
  IAccessControlEnumerable,
  AccessControl
{
  using EnumerableSet for EnumerableSet.AddressSet;

  mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers;

  /**
   * @dev See {IERC165-supportsInterface}.
   */
  function supportsInterface(bytes4 interfaceId)
    public
    view
    virtual
    override
    returns (bool)
  {
    return
      interfaceId == type(IAccessControlEnumerable).interfaceId ||
      super.supportsInterface(interfaceId);
  }

  /**
   * @dev Returns one of the accounts that have `role`. `index` must be a
   * value between 0 and {getRoleMemberCount}, non-inclusive.
   *
   * Role bearers are not sorted in any particular way, and their ordering may
   * change at any point.
   *
   * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
   * you perform all queries on the same block. See the following
   * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
   * for more information.
   */
  function getRoleMember(bytes32 role, uint256 index)
    public
    view
    virtual
    override
    returns (address)
  {
    return _roleMembers[role].at(index);
  }

  /**
   * @dev Returns the number of accounts that have `role`. Can be used
   * together with {getRoleMember} to enumerate all bearers of a role.
   */
  function getRoleMemberCount(bytes32 role)
    public
    view
    virtual
    override
    returns (uint256)
  {
    return _roleMembers[role].length();
  }

  /**
   * @dev Overload {_grantRole} to track enumerable memberships
   */
  function _grantRole(bytes32 role, address account) internal virtual override {
    super._grantRole(role, account);
    _roleMembers[role].add(account);
  }

  /**
   * @dev Overload {_revokeRole} to track enumerable memberships
   */
  function _revokeRole(bytes32 role, address account)
    internal
    virtual
    override
  {
    super._revokeRole(role, account);
    _roleMembers[role].remove(account);
  }
}
IAccessControlEnumerable.sol 34 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)

pragma solidity ^0.8.0;

import "contracts/external/openzeppelin/contracts/access/IAccessControl.sol";

/**
 * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.
 */
interface IAccessControlEnumerable is IAccessControl {
  /**
   * @dev Returns one of the accounts that have `role`. `index` must be a
   * value between 0 and {getRoleMemberCount}, non-inclusive.
   *
   * Role bearers are not sorted in any particular way, and their ordering may
   * change at any point.
   *
   * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
   * you perform all queries on the same block. See the following
   * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
   * for more information.
   */
  function getRoleMember(bytes32 role, uint256 index)
    external
    view
    returns (address);

  /**
   * @dev Returns the number of accounts that have `role`. Can be used
   * together with {getRoleMember} to enumerate all bearers of a role.
   */
  function getRoleMemberCount(bytes32 role) external view returns (uint256);
}
AccessControl.sol 256 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "contracts/external/openzeppelin/contracts/access/IAccessControl.sol";
import "contracts/external/openzeppelin/contracts/utils/Context.sol";
import "contracts/external/openzeppelin/contracts/utils/Strings.sol";
import "contracts/external/openzeppelin/contracts/utils/ERC165.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
  struct RoleData {
    mapping(address => bool) members;
    bytes32 adminRole;
  }

  mapping(bytes32 => RoleData) private _roles;

  bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

  /**
   * @dev Modifier that checks that an account has a specific role. Reverts
   * with a standardized message including the required role.
   *
   * The format of the revert reason is given by the following regular expression:
   *
   *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
   *
   * _Available since v4.1._
   */
  modifier onlyRole(bytes32 role) {
    _checkRole(role, _msgSender());
    _;
  }

  /**
   * @dev See {IERC165-supportsInterface}.
   */
  function supportsInterface(bytes4 interfaceId)
    public
    view
    virtual
    override
    returns (bool)
  {
    return
      interfaceId == type(IAccessControl).interfaceId ||
      super.supportsInterface(interfaceId);
  }

  /**
   * @dev Returns `true` if `account` has been granted `role`.
   */
  function hasRole(bytes32 role, address account)
    public
    view
    virtual
    override
    returns (bool)
  {
    return _roles[role].members[account];
  }

  /**
   * @dev Revert with a standard message if `account` is missing `role`.
   *
   * The format of the revert reason is given by the following regular expression:
   *
   *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
   */
  function _checkRole(bytes32 role, address account) internal view virtual {
    if (!hasRole(role, account)) {
      revert(
        string(
          abi.encodePacked(
            "AccessControl: account ",
            Strings.toHexString(uint160(account), 20),
            " is missing role ",
            Strings.toHexString(uint256(role), 32)
          )
        )
      );
    }
  }

  /**
   * @dev Returns the admin role that controls `role`. See {grantRole} and
   * {revokeRole}.
   *
   * To change a role's admin, use {_setRoleAdmin}.
   */
  function getRoleAdmin(bytes32 role)
    public
    view
    virtual
    override
    returns (bytes32)
  {
    return _roles[role].adminRole;
  }

  /**
   * @dev Grants `role` to `account`.
   *
   * If `account` had not been already granted `role`, emits a {RoleGranted}
   * event.
   *
   * Requirements:
   *
   * - the caller must have ``role``'s admin role.
   */
  function grantRole(bytes32 role, address account)
    public
    virtual
    override
    onlyRole(getRoleAdmin(role))
  {
    _grantRole(role, account);
  }

  /**
   * @dev Revokes `role` from `account`.
   *
   * If `account` had been granted `role`, emits a {RoleRevoked} event.
   *
   * Requirements:
   *
   * - the caller must have ``role``'s admin role.
   */
  function revokeRole(bytes32 role, address account)
    public
    virtual
    override
    onlyRole(getRoleAdmin(role))
  {
    _revokeRole(role, account);
  }

  /**
   * @dev Revokes `role` from the calling account.
   *
   * Roles are often managed via {grantRole} and {revokeRole}: this function's
   * purpose is to provide a mechanism for accounts to lose their privileges
   * if they are compromised (such as when a trusted device is misplaced).
   *
   * If the calling account had been revoked `role`, emits a {RoleRevoked}
   * event.
   *
   * Requirements:
   *
   * - the caller must be `account`.
   */
  function renounceRole(bytes32 role, address account) public virtual override {
    require(
      account == _msgSender(),
      "AccessControl: can only renounce roles for self"
    );

    _revokeRole(role, account);
  }

  /**
   * @dev Grants `role` to `account`.
   *
   * If `account` had not been already granted `role`, emits a {RoleGranted}
   * event. Note that unlike {grantRole}, this function doesn't perform any
   * checks on the calling account.
   *
   * [WARNING]
   * ====
   * This function should only be called from the constructor when setting
   * up the initial roles for the system.
   *
   * Using this function in any other way is effectively circumventing the admin
   * system imposed by {AccessControl}.
   * ====
   *
   * NOTE: This function is deprecated in favor of {_grantRole}.
   */
  function _setupRole(bytes32 role, address account) internal virtual {
    _grantRole(role, account);
  }

  /**
   * @dev Sets `adminRole` as ``role``'s admin role.
   *
   * Emits a {RoleAdminChanged} event.
   */
  function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
    bytes32 previousAdminRole = getRoleAdmin(role);
    _roles[role].adminRole = adminRole;
    emit RoleAdminChanged(role, previousAdminRole, adminRole);
  }

  /**
   * @dev Grants `role` to `account`.
   *
   * Internal function without access restriction.
   */
  function _grantRole(bytes32 role, address account) internal virtual {
    if (!hasRole(role, account)) {
      _roles[role].members[account] = true;
      emit RoleGranted(role, account, _msgSender());
    }
  }

  /**
   * @dev Revokes `role` from `account`.
   *
   * Internal function without access restriction.
   */
  function _revokeRole(bytes32 role, address account) internal virtual {
    if (hasRole(role, account)) {
      _roles[role].members[account] = false;
      emit RoleRevoked(role, account, _msgSender());
    }
  }
}
EnumerableSet.sol 403 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/structs/EnumerableSet.sol)

pragma solidity ^0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 */
library EnumerableSet {
  // To implement this library for multiple types with as little code
  // repetition as possible, we write it in terms of a generic Set type with
  // bytes32 values.
  // The Set implementation uses private functions, and user-facing
  // implementations (such as AddressSet) are just wrappers around the
  // underlying Set.
  // This means that we can only create new EnumerableSets for types that fit
  // in bytes32.

  struct Set {
    // Storage of set values
    bytes32[] _values;
    // Position of the value in the `values` array, plus 1 because index 0
    // means a value is not in the set.
    mapping(bytes32 => uint256) _indexes;
  }

  /**
   * @dev Add a value to a set. O(1).
   *
   * Returns true if the value was added to the set, that is if it was not
   * already present.
   */
  function _add(Set storage set, bytes32 value) private returns (bool) {
    if (!_contains(set, value)) {
      set._values.push(value);
      // The value is stored at length-1, but we add 1 to all indexes
      // and use 0 as a sentinel value
      set._indexes[value] = set._values.length;
      return true;
    } else {
      return false;
    }
  }

  /**
   * @dev Removes a value from a set. O(1).
   *
   * Returns true if the value was removed from the set, that is if it was
   * present.
   */
  function _remove(Set storage set, bytes32 value) private returns (bool) {
    // We read and store the value's index to prevent multiple reads from the same storage slot
    uint256 valueIndex = set._indexes[value];

    if (valueIndex != 0) {
      // Equivalent to contains(set, value)
      // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
      // the array, and then remove the last element (sometimes called as 'swap and pop').
      // This modifies the order of the array, as noted in {at}.

      uint256 toDeleteIndex = valueIndex - 1;
      uint256 lastIndex = set._values.length - 1;

      if (lastIndex != toDeleteIndex) {
        bytes32 lastvalue = set._values[lastIndex];

        // Move the last value to the index where the value to delete is
        set._values[toDeleteIndex] = lastvalue;
        // Update the index for the moved value
        set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex
      }

      // Delete the slot where the moved value was stored
      set._values.pop();

      // Delete the index for the deleted slot
      delete set._indexes[value];

      return true;
    } else {
      return false;
    }
  }

  /**
   * @dev Returns true if the value is in the set. O(1).
   */
  function _contains(Set storage set, bytes32 value)
    private
    view
    returns (bool)
  {
    return set._indexes[value] != 0;
  }

  /**
   * @dev Returns the number of values on the set. O(1).
   */
  function _length(Set storage set) private view returns (uint256) {
    return set._values.length;
  }

  /**
   * @dev Returns the value stored at position `index` in the set. O(1).
   *
   * Note that there are no guarantees on the ordering of values inside the
   * array, and it may change when more values are added or removed.
   *
   * Requirements:
   *
   * - `index` must be strictly less than {length}.
   */
  function _at(Set storage set, uint256 index) private view returns (bytes32) {
    return set._values[index];
  }

  /**
   * @dev Return the entire set in an array
   *
   * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
   * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
   * this function has an unbounded cost, and using it as part of a state-changing function may render the function
   * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
   */
  function _values(Set storage set) private view returns (bytes32[] memory) {
    return set._values;
  }

  // Bytes32Set

  struct Bytes32Set {
    Set _inner;
  }

  /**
   * @dev Add a value to a set. O(1).
   *
   * Returns true if the value was added to the set, that is if it was not
   * already present.
   */
  function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
    return _add(set._inner, value);
  }

  /**
   * @dev Removes a value from a set. O(1).
   *
   * Returns true if the value was removed from the set, that is if it was
   * present.
   */
  function remove(Bytes32Set storage set, bytes32 value)
    internal
    returns (bool)
  {
    return _remove(set._inner, value);
  }

  /**
   * @dev Returns true if the value is in the set. O(1).
   */
  function contains(Bytes32Set storage set, bytes32 value)
    internal
    view
    returns (bool)
  {
    return _contains(set._inner, value);
  }

  /**
   * @dev Returns the number of values in the set. O(1).
   */
  function length(Bytes32Set storage set) internal view returns (uint256) {
    return _length(set._inner);
  }

  /**
   * @dev Returns the value stored at position `index` in the set. O(1).
   *
   * Note that there are no guarantees on the ordering of values inside the
   * array, and it may change when more values are added or removed.
   *
   * Requirements:
   *
   * - `index` must be strictly less than {length}.
   */
  function at(Bytes32Set storage set, uint256 index)
    internal
    view
    returns (bytes32)
  {
    return _at(set._inner, index);
  }

  /**
   * @dev Return the entire set in an array
   *
   * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
   * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
   * this function has an unbounded cost, and using it as part of a state-changing function may render the function
   * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
   */
  function values(Bytes32Set storage set)
    internal
    view
    returns (bytes32[] memory)
  {
    return _values(set._inner);
  }

  // AddressSet

  struct AddressSet {
    Set _inner;
  }

  /**
   * @dev Add a value to a set. O(1).
   *
   * Returns true if the value was added to the set, that is if it was not
   * already present.
   */
  function add(AddressSet storage set, address value) internal returns (bool) {
    return _add(set._inner, bytes32(uint256(uint160(value))));
  }

  /**
   * @dev Removes a value from a set. O(1).
   *
   * Returns true if the value was removed from the set, that is if it was
   * present.
   */
  function remove(AddressSet storage set, address value)
    internal
    returns (bool)
  {
    return _remove(set._inner, bytes32(uint256(uint160(value))));
  }

  /**
   * @dev Returns true if the value is in the set. O(1).
   */
  function contains(AddressSet storage set, address value)
    internal
    view
    returns (bool)
  {
    return _contains(set._inner, bytes32(uint256(uint160(value))));
  }

  /**
   * @dev Returns the number of values in the set. O(1).
   */
  function length(AddressSet storage set) internal view returns (uint256) {
    return _length(set._inner);
  }

  /**
   * @dev Returns the value stored at position `index` in the set. O(1).
   *
   * Note that there are no guarantees on the ordering of values inside the
   * array, and it may change when more values are added or removed.
   *
   * Requirements:
   *
   * - `index` must be strictly less than {length}.
   */
  function at(AddressSet storage set, uint256 index)
    internal
    view
    returns (address)
  {
    return address(uint160(uint256(_at(set._inner, index))));
  }

  /**
   * @dev Return the entire set in an array
   *
   * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
   * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
   * this function has an unbounded cost, and using it as part of a state-changing function may render the function
   * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
   */
  function values(AddressSet storage set)
    internal
    view
    returns (address[] memory)
  {
    bytes32[] memory store = _values(set._inner);
    address[] memory result;

    assembly {
      result := store
    }

    return result;
  }

  // UintSet

  struct UintSet {
    Set _inner;
  }

  /**
   * @dev Add a value to a set. O(1).
   *
   * Returns true if the value was added to the set, that is if it was not
   * already present.
   */
  function add(UintSet storage set, uint256 value) internal returns (bool) {
    return _add(set._inner, bytes32(value));
  }

  /**
   * @dev Removes a value from a set. O(1).
   *
   * Returns true if the value was removed from the set, that is if it was
   * present.
   */
  function remove(UintSet storage set, uint256 value) internal returns (bool) {
    return _remove(set._inner, bytes32(value));
  }

  /**
   * @dev Returns true if the value is in the set. O(1).
   */
  function contains(UintSet storage set, uint256 value)
    internal
    view
    returns (bool)
  {
    return _contains(set._inner, bytes32(value));
  }

  /**
   * @dev Returns the number of values on the set. O(1).
   */
  function length(UintSet storage set) internal view returns (uint256) {
    return _length(set._inner);
  }

  /**
   * @dev Returns the value stored at position `index` in the set. O(1).
   *
   * Note that there are no guarantees on the ordering of values inside the
   * array, and it may change when more values are added or removed.
   *
   * Requirements:
   *
   * - `index` must be strictly less than {length}.
   */
  function at(UintSet storage set, uint256 index)
    internal
    view
    returns (uint256)
  {
    return uint256(_at(set._inner, index));
  }

  /**
   * @dev Return the entire set in an array
   *
   * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
   * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
   * this function has an unbounded cost, and using it as part of a state-changing function may render the function
   * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
   */
  function values(UintSet storage set)
    internal
    view
    returns (uint256[] memory)
  {
    bytes32[] memory store = _values(set._inner);
    uint256[] memory result;

    assembly {
      result := store
    }

    return result;
  }
}
IAccessControl.sol 100 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
  /**
   * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
   *
   * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
   * {RoleAdminChanged} not being emitted signaling this.
   *
   * _Available since v3.1._
   */
  event RoleAdminChanged(
    bytes32 indexed role,
    bytes32 indexed previousAdminRole,
    bytes32 indexed newAdminRole
  );

  /**
   * @dev Emitted when `account` is granted `role`.
   *
   * `sender` is the account that originated the contract call, an admin role
   * bearer except when using {AccessControl-_setupRole}.
   */
  event RoleGranted(
    bytes32 indexed role,
    address indexed account,
    address indexed sender
  );

  /**
   * @dev Emitted when `account` is revoked `role`.
   *
   * `sender` is the account that originated the contract call:
   *   - if using `revokeRole`, it is the admin role bearer
   *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
   */
  event RoleRevoked(
    bytes32 indexed role,
    address indexed account,
    address indexed sender
  );

  /**
   * @dev Returns `true` if `account` has been granted `role`.
   */
  function hasRole(bytes32 role, address account) external view returns (bool);

  /**
   * @dev Returns the admin role that controls `role`. See {grantRole} and
   * {revokeRole}.
   *
   * To change a role's admin, use {AccessControl-_setRoleAdmin}.
   */
  function getRoleAdmin(bytes32 role) external view returns (bytes32);

  /**
   * @dev Grants `role` to `account`.
   *
   * If `account` had not been already granted `role`, emits a {RoleGranted}
   * event.
   *
   * Requirements:
   *
   * - the caller must have ``role``'s admin role.
   */
  function grantRole(bytes32 role, address account) external;

  /**
   * @dev Revokes `role` from `account`.
   *
   * If `account` had been granted `role`, emits a {RoleRevoked} event.
   *
   * Requirements:
   *
   * - the caller must have ``role``'s admin role.
   */
  function revokeRole(bytes32 role, address account) external;

  /**
   * @dev Revokes `role` from the calling account.
   *
   * Roles are often managed via {grantRole} and {revokeRole}: this function's
   * purpose is to provide a mechanism for accounts to lose their privileges
   * if they are compromised (such as when a trusted device is misplaced).
   *
   * If the calling account had been granted `role`, emits a {RoleRevoked}
   * event.
   *
   * Requirements:
   *
   * - the caller must be `account`.
   */
  function renounceRole(bytes32 role, address account) external;
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
  function _msgSender() internal view virtual returns (address) {
    return msg.sender;
  }

  function _msgData() internal view virtual returns (bytes calldata) {
    return msg.data;
  }
}
Strings.sol 71 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
  bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";

  /**
   * @dev Converts a `uint256` to its ASCII `string` decimal representation.
   */
  function toString(uint256 value) internal pure returns (string memory) {
    // Inspired by OraclizeAPI's implementation - MIT licence
    // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

    if (value == 0) {
      return "0";
    }
    uint256 temp = value;
    uint256 digits;
    while (temp != 0) {
      digits++;
      temp /= 10;
    }
    bytes memory buffer = new bytes(digits);
    while (value != 0) {
      digits -= 1;
      buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
      value /= 10;
    }
    return string(buffer);
  }

  /**
   * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
   */
  function toHexString(uint256 value) internal pure returns (string memory) {
    if (value == 0) {
      return "0x00";
    }
    uint256 temp = value;
    uint256 length = 0;
    while (temp != 0) {
      length++;
      temp >>= 8;
    }
    return toHexString(value, length);
  }

  /**
   * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
   */
  function toHexString(uint256 value, uint256 length)
    internal
    pure
    returns (string memory)
  {
    bytes memory buffer = new bytes(2 * length + 2);
    buffer[0] = "0";
    buffer[1] = "x";
    for (uint256 i = 2 * length + 1; i > 1; --i) {
      buffer[i] = _HEX_SYMBOLS[value & 0xf];
      value >>= 4;
    }
    require(value == 0, "Strings: hex length insufficient");
    return string(buffer);
  }
}
ERC165.sol 35 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "contracts/external/openzeppelin/contracts/utils/IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
  /**
   * @dev See {IERC165-supportsInterface}.
   */
  function supportsInterface(bytes4 interfaceId)
    public
    view
    virtual
    override
    returns (bool)
  {
    return interfaceId == type(IERC165).interfaceId;
  }
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
  /**
   * @dev Returns true if this contract implements the interface defined by
   * `interfaceId`. See the corresponding
   * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
   * to learn more about how these ids are created.
   *
   * This function call must use less than 30 000 gas.
   */
  function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

Read Contract

BPS_DENOMINATOR 0xe1a45218 → uint256
CONFIGURER_ROLE 0xabbb9f4c → bytes32
DEFAULT_ADMIN_ROLE 0xa217fddf → bytes32
SETTER_ROLE 0xa2011b3f → bytes32
defaultDeviationBps 0x20f3a5db → uint16
defaultMaxTimeDelay 0x972e8c5d → uint32
getRoleAdmin 0x248a9ca3 → bytes32
getRoleMember 0x9010d07c → address
getRoleMemberCount 0xca15c873 → uint256
hasRole 0x91d14854 → bool
prices 0xcfed246b → uint256, uint64, uint32, uint16
supportsInterface 0x01ffc9a7 → bool
validatePrice 0xfd45a433

Write Contract 9 functions

These functions modify contract state and require a wallet transaction to execute.

grantRole 0x2f2ff15d
bytes32 role
address account
postPrice 0xaa5fd449
address token
uint256 price
postPrices 0x5cdb595c
address[] tokens
uint256[] tokenPrices
renounceRole 0x36568abe
bytes32 role
address account
revokeRole 0xd547741f
bytes32 role
address account
setAllowedDeviationBps 0xb58a0d74
address token
uint16 bps
setDefaultAllowedDeviationBps 0x215373fa
uint16 bps
setDefaultMaxTimeDelay 0x196c74a5
uint32 maxTimeDelay
setMaxTimeDelay 0x57ab54f7
address token
uint32 maxTimeDelay

Top Interactions

AddressTxnsSentReceived
0x61eAc1F1...9536 1 1

Recent Transactions

CSV
|
Hash Method Block Age From/To Value Txn Fee Type
0xe1ac135b...9906fe 0x5cdb595c 24,604,117 IN 0x61eAc1F1...9536 0 ETH 0.000001280252 ETH EIP-1559