Address Contract Verified
Address
0x6750d55753C1D33bED4E69D103471899a5844E40
Balance
0 ETH
Nonce
1
Code Size
6001 bytes
Creator
0x629a099c...9797 at tx 0x2d2add33...ffefcb
Indexed Transactions
0
Contract Bytecode
6001 bytes
0x608060405234801561000f575f80fd5b506004361061018f575f3560e01c80636e757234116100dd578063a217fddf11610088578063cfed246b11610063578063cfed246b14610498578063d547741f1461052d578063ee8f525e14610540575f80fd5b8063a217fddf14610443578063c55dae631461044a578063ceb2097114610471575f80fd5b80638f613419116100b85780638f613419146103c25780638fb5a482146103ed57806391d148541461040d575f80fd5b80636e757234146103465780637b3132d2146103905780637f4c9b60146103a3575f80fd5b80632f2ff15d1161013d57806341976e091161011857806341976e09146102a15780635b4481d5146103205780636c90659e14610333575f80fd5b80632f2ff15d1461026c578063313ce5671461027f57806336568abe1461028e575f80fd5b8063224dc0fe1161016d578063224dc0fe146101f1578063248a9ca31461022357806324ea54f414610245575f80fd5b806301ffc9a714610193578063084fa38f146101bb57806316345f18146101d0575b5f80fd5b6101a66101a13660046112a5565b610553565b60405190151581526020015b60405180910390f35b6101ce6101c93660046112cc565b610589565b005b6101e36101de366004611351565b610652565b6040519081526020016101b2565b6102046101ff36600461136a565b61069e565b604080516001600160a01b0390931683526020830191909152016101b2565b6101e3610231366004611392565b5f9081526020819052604090206001015490565b6101e37f55435dd261a4b9b3364963f7738a7a662ad9c84396d64be3365284bb7f0a504181565b6101ce61027a3660046113a9565b6106be565b604051601281526020016101b2565b6101ce61029c3660046113a9565b6106e7565b6102f46102af366004611351565b6001600160a01b03165f9081526001602081905260409091208054918101546002820154600390920154600160a01b90930467ffffffffffffffff9081169491169290565b6040805167ffffffffffffffff95861681529490931660208501529183015260608201526080016101b2565b6101ce61032e366004611412565b610778565b6101ce610341366004611479565b6108ef565b61037b610354366004611351565b6001600160a01b03165f908152600460209081526040808320546003909252909120549091565b604080519283526020830191909152016101b2565b6101ce61039e3660046114c0565b61092a565b6103ad6201518081565b60405163ffffffff90911681526020016101b2565b6103d56103d036600461136a565b610b4f565b6040516001600160a01b0390911681526020016101b2565b6104006103fb3660046114f9565b610c24565b6040516101b29190611538565b6101a661041b3660046113a9565b5f918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b6101e35f81565b6103d57f0000000000000000000000000e1f78ea866f9185ad5b9e8f9fb158430a7c4c6381565b6101e37f80a586cc4ecf40a390b370be075aa38ab3cc512c5c1a7bc1007974dbdf2663c781565b6104ed6104a6366004611351565b600160208190525f918252604090912080549181015460028201546003909201546001600160a01b0384169367ffffffffffffffff600160a01b9091048116939216919085565b604080516001600160a01b0396909616865267ffffffffffffffff948516602087015292909316918401919091526060830152608082015260a0016101b2565b6101ce61053b3660046113a9565b610d67565b6103ad61054e366004611351565b610d8b565b5f6001600160e01b03198216637965db0b60e01b148061058357506301ffc9a760e01b6001600160e01b03198316145b92915050565b7f80a586cc4ecf40a390b370be075aa38ab3cc512c5c1a7bc1007974dbdf2663c76105b381610dc1565b815f5b8181101561064b575f8585838181106105d1576105d16115bb565b6105e79260206060909202019081019150611351565b90505f8686848181106105fc576105fc6115bb565b905060600201602001602081019061061491906115cf565b90505f878785818110610629576106296115bb565b90506060020160400135905061064083838361092a565b5050506001016105b6565b5050505050565b5f61065c82610dce565b506001600160a01b0381165f908152600160205260408120600201549081900361069957604051637294708f60e11b815260040160405180910390fd5b919050565b5f806106aa8484610b4f565b91506106b582610652565b90509250929050565b5f828152602081905260409020600101546106d881610dc1565b6106e28383610e57565b505050565b6001600160a01b038116331461076a5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b6107748282610ef3565b5050565b7f55435dd261a4b9b3364963f7738a7a662ad9c84396d64be3365284bb7f0a50416107a281610dc1565b838281146107c357604051637afcf20960e11b815260040160405180910390fd5b5f5b818110156108e6578484828181106107df576107df6115bb565b90506020020160208101906107f491906115e8565b60025f898985818110610809576108096115bb565b905060200201602081019061081e9190611351565b6001600160a01b0316815260208101919091526040015f20805463ffffffff191663ffffffff92909216919091179055868682818110610860576108606115bb565b90506020020160208101906108759190611351565b6001600160a01b03167f665da418a6bfa2bcf085ba9da3a58244bc4981b6441ab18e3711529d18f42d508686848181106108b1576108b16115bb565b90506020020160208101906108c691906115e8565b60405163ffffffff909116815260200160405180910390a26001016107c5565b50505050505050565b7f55435dd261a4b9b3364963f7738a7a662ad9c84396d64be3365284bb7f0a504161091981610dc1565b610924848484610f70565b50505050565b7f80a586cc4ecf40a390b370be075aa38ab3cc512c5c1a7bc1007974dbdf2663c761095481610dc1565b6001600160a01b0384165f9081526001602052604090205467ffffffffffffffff600160a01b9091048116908416811015806109995750428467ffffffffffffffff16115b156109b757604051636283e6bd60e11b815260040160405180910390fd5b6109c18584611006565b5f60015f876001600160a01b03166001600160a01b031681526020019081526020015f206002015490506040518060a00160405280876001600160a01b031681526020018667ffffffffffffffff1681526020018367ffffffffffffffff1681526020018581526020018281525060015f886001600160a01b03166001600160a01b031681526020019081526020015f205f820151815f015f6101000a8154816001600160a01b0302191690836001600160a01b031602179055506020820151815f0160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055506040820151816001015f6101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055506060820151816002015560808201518160030155905050856001600160a01b03167fa37f5896069016d986b7df061fd496afd61a67fd3a5a53328d355bbae7e26d2f8686604051610b3f92919067ffffffffffffffff929092168252602082015260400190565b60405180910390a2505050505050565b5f816001600160a01b0316836001600160a01b031603610b8257604051635baa885360e11b815260040160405180910390fd5b7f0000000000000000000000000e1f78ea866f9185ad5b9e8f9fb158430a7c4c636001600160a01b0390811690841614801581610bf157507f0000000000000000000000000e1f78ea866f9185ad5b9e8f9fb158430a7c4c636001600160a01b0316836001600160a01b031614155b15610c0f57604051635baa885360e11b815260040160405180910390fd5b80610c1a5783610c1c565b825b949350505050565b6060815f8167ffffffffffffffff811115610c4157610c4161160b565b604051908082528060200260200182016040528015610c9857816020015b6040805160a0810182525f808252602080830182905292820181905260608201819052608082015282525f19909201910181610c5f5790505b5090505f5b82811015610d5e5760015f878784818110610cba57610cba6115bb565b9050602002016020810190610ccf9190611351565b6001600160a01b03908116825260208083019390935260409182015f20825160a0810184528154928316815267ffffffffffffffff600160a01b909304831694810194909452600181015490911691830191909152600281015460608301526003015460808201528251839083908110610d4b57610d4b6115bb565b6020908102919091010152600101610c9d565b50949350505050565b5f82815260208190526040902060010154610d8181610dc1565b6106e28383610ef3565b6001600160a01b0381165f9081526002602052604081205463ffffffff168015610db55780610dba565b620151805b9392505050565b610dcb813361107e565b50565b5f610dd882610d8b565b905063ffffffff8082161015610774576001600160a01b0382165f90815260016020526040902054600160a01b900467ffffffffffffffff16428111801590610e39575063ffffffff8216610e3767ffffffffffffffff831642611633565b115b156106e2576040516328771d9160e01b815260040160405180910390fd5b5f828152602081815260408083206001600160a01b038516845290915290205460ff16610774575f828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055610eaf3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b5f828152602081815260408083206001600160a01b038516845290915290205460ff1615610774575f828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b801580610f7b575081155b80610f8557508082115b15610fa35760405163d79b63b760e01b815260040160405180910390fd5b6001600160a01b0383165f818152600360209081526040808320859055600482529182902085905581518581529081018490527ff1a949df32e1d006144f660992671a6bfc2ca9680731c85642dc1fe59576ddff910160405180910390a2505050565b6001600160a01b0382165f90815260046020908152604080832054600390925290912054811580611035575080155b156110535760405163d79b63b760e01b815260040160405180910390fd5b8183108061106057508083115b156109245760405163416562bb60e11b815260040160405180910390fd5b5f828152602081815260408083206001600160a01b038516845290915290205460ff16610774576110ae816110f0565b6110b9836020611102565b6040516020016110ca92919061165d565b60408051601f198184030181529082905262461bcd60e51b8252610761916004016116c7565b60606105836001600160a01b03831660145b60605f6111108360026116fc565b61111b906002611713565b67ffffffffffffffff8111156111335761113361160b565b6040519080825280601f01601f19166020018201604052801561115d576020820181803683370190505b509050600360fc1b815f81518110611177576111776115bb565b60200101906001600160f81b03191690815f1a905350600f60fb1b816001815181106111a5576111a56115bb565b60200101906001600160f81b03191690815f1a9053505f6111c78460026116fc565b6111d2906001611713565b90505b6001811115611256577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110611213576112136115bb565b1a60f81b828281518110611229576112296115bb565b60200101906001600160f81b03191690815f1a90535060049490941c9361124f81611726565b90506111d5565b508315610dba5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610761565b5f602082840312156112b5575f80fd5b81356001600160e01b031981168114610dba575f80fd5b5f80602083850312156112dd575f80fd5b823567ffffffffffffffff808211156112f4575f80fd5b818501915085601f830112611307575f80fd5b813581811115611315575f80fd5b866020606083028501011115611329575f80fd5b60209290920196919550909350505050565b80356001600160a01b0381168114610699575f80fd5b5f60208284031215611361575f80fd5b610dba8261133b565b5f806040838503121561137b575f80fd5b6113848361133b565b91506106b56020840161133b565b5f602082840312156113a2575f80fd5b5035919050565b5f80604083850312156113ba575f80fd5b823591506106b56020840161133b565b5f8083601f8401126113da575f80fd5b50813567ffffffffffffffff8111156113f1575f80fd5b6020830191508360208260051b850101111561140b575f80fd5b9250929050565b5f805f8060408587031215611425575f80fd5b843567ffffffffffffffff8082111561143c575f80fd5b611448888389016113ca565b90965094506020870135915080821115611460575f80fd5b5061146d878288016113ca565b95989497509550505050565b5f805f6060848603121561148b575f80fd5b6114948461133b565b95602085013595506040909401359392505050565b803567ffffffffffffffff81168114610699575f80fd5b5f805f606084860312156114d2575f80fd5b6114db8461133b565b92506114e9602085016114a9565b9150604084013590509250925092565b5f806020838503121561150a575f80fd5b823567ffffffffffffffff811115611520575f80fd5b61152c858286016113ca565b90969095509350505050565b602080825282518282018190525f919060409081850190868401855b828110156115ae57815180516001600160a01b031685528681015167ffffffffffffffff90811688870152868201511686860152606080820151908601526080908101519085015260a09093019290850190600101611554565b5091979650505050505050565b634e487b7160e01b5f52603260045260245ffd5b5f602082840312156115df575f80fd5b610dba826114a9565b5f602082840312156115f8575f80fd5b813563ffffffff81168114610dba575f80fd5b634e487b7160e01b5f52604160045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b818103818111156105835761058361161f565b5f81518060208401855e5f93019283525090919050565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081525f61168e6017830185611646565b7f206973206d697373696e6720726f6c652000000000000000000000000000000081526116be6011820185611646565b95945050505050565b602081525f82518060208401528060208501604085015e5f604082850101526040601f19601f83011684010191505092915050565b80820281158282048414176105835761058361161f565b808201808211156105835761058361161f565b5f816117345761173461161f565b505f19019056fea264697066735822122075b330909591fcd3e9da19c434667bc1452f0ddbb7eee279e11a003553478eac64736f6c63430008190033
Verified Source Code Full Match
Compiler: v0.8.25+commit.b61c2a91
EVM: cancun
Optimization: Yes (800 runs)
XOracle.sol 185 lines
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.19;
import "@openzeppelin/contracts/access/AccessControl.sol";
import "src/interfaces/IOracle.sol";
import "src/utils/AddressUtils.sol";
contract XOracle is AccessControl, IOracle {
bytes32 public constant FEEDER_ROLE = keccak256("FEEDER_ROLE");
bytes32 public constant GUARDIAN_ROLE = keccak256("GUARDIAN_ROLE");
/// @inheritdoc IOracle
uint32 public constant STALENESS_DEFAULT_THRESHOLD = 86400;
/// @inheritdoc IOracle
address public immutable baseToken;
mapping (address => IOracle.Price) public prices;
/**
* @notice Maps the token address to to the staleness threshold in seconds.
* When the value equals to the max value of uint32, it indicates unrestricted.
*/
mapping(address quoteToken => uint32) internal _stalenessThreshold;
mapping(address quoteToken => uint256) internal _maxPriceTolerance;
mapping(address quoteToken => uint256) internal _minPriceTolerance;
constructor(address baseToken_) {
// Grant the contract deployer the default admin role: it will be able
// to grant and revoke any roles
_setRoleAdmin(GUARDIAN_ROLE, GUARDIAN_ROLE);
_setRoleAdmin(FEEDER_ROLE, GUARDIAN_ROLE);
_grantRole(GUARDIAN_ROLE, msg.sender);
_grantRole(FEEDER_ROLE, msg.sender);
AddressUtils.checkContract(baseToken_);
baseToken = baseToken_;
}
// ========================= FEEDER FUNCTIONS ====================================
/// @inheritdoc IOracle
function putPrice(address asset, uint64 timestamp, uint256 price) public onlyRole(FEEDER_ROLE) {
uint64 prev_timestamp = prices[asset].timestamp;
if (timestamp <= prev_timestamp || timestamp > block.timestamp) revert TimestampInvalid();
_checkPriceInTolerance(asset, price);
uint256 prev_price = prices[asset].price;
prices[asset] = IOracle.Price(asset, timestamp, prev_timestamp, price, prev_price);
emit newPrice(asset, timestamp, price);
}
/// @inheritdoc IOracle
function updatePrices(IOracle.NewPrice[] calldata _array) external onlyRole(FEEDER_ROLE) {
uint256 arrLength = _array.length;
for(uint256 i=0; i<arrLength; ){
address asset = _array[i].asset;
uint64 timestamp = _array[i].timestamp;
uint256 price = _array[i].price;
putPrice(asset, timestamp, price);
unchecked {
i++;
}
}
}
/// @inheritdoc IOracle
function setStalenessThresholds(address[] calldata quoteTokens, uint32[] calldata thresholds) external onlyRole(GUARDIAN_ROLE) {
uint256 tokenCount = quoteTokens.length;
if (tokenCount != thresholds.length) revert LengthMismatched();
for (uint256 i; i < tokenCount; i++) {
_stalenessThreshold[quoteTokens[i]] = thresholds[i];
emit StalenessThresholdUpdated(quoteTokens[i], thresholds[i]);
}
}
/// @inheritdoc IOracle
function setPriceTolerance(address quoteToken, uint256 minPrice, uint256 maxPrice) external onlyRole(GUARDIAN_ROLE) {
_setPriceTolerance(quoteToken, minPrice, maxPrice);
}
// ========================= VIEW FUNCTIONS ====================================
/// @inheritdoc IOracle
function getPrice(address asset) public view returns (uint64, uint64, uint256, uint256) {
return (
prices[asset].timestamp,
prices[asset].prev_timestamp,
prices[asset].price,
prices[asset].prev_price
);
}
/// @inheritdoc IOracle
function getLatestPrice(address quoteToken) public view returns (uint256 price) {
_checkPriceNotStale(quoteToken);
price = prices[quoteToken].price;
if (price == 0) revert PriceZero();
}
/// @inheritdoc IOracle
function getPrices(address[] calldata assets) public view returns (IOracle.Price[] memory) {
uint256 assetCount = assets.length;
IOracle.Price[] memory _prices = new IOracle.Price[](assetCount);
for (uint256 i; i < assetCount; i++) {
_prices[i] = prices[assets[i]];
}
return _prices;
}
/// @inheritdoc IOracle
function getStalenessThreshold(address quoteToken) public view returns (uint32) {
uint32 threshold = _stalenessThreshold[quoteToken];
return threshold == 0 ? STALENESS_DEFAULT_THRESHOLD : threshold;
}
/// @inheritdoc IOracle
function getPriceTolerance(address quoteToken) public view returns (uint256 minPrice, uint256 maxPrice) {
minPrice = _minPriceTolerance[quoteToken];
maxPrice = _maxPriceTolerance[quoteToken];
}
/// @inheritdoc IOracle
function getQuoteToken(address tokenX, address tokenY) public view returns (address quoteToken) {
if (tokenX == tokenY) revert TokensInvalid();
bool isXBase = tokenX == baseToken;
if (!isXBase && tokenY != baseToken) revert TokensInvalid();
quoteToken = isXBase ? tokenY : tokenX;
}
/// @inheritdoc IOracle
function getQuoteTokenAndPrice(address tokenX, address tokenY) public view returns (address quoteToken, uint256 price) {
quoteToken = getQuoteToken(tokenX, tokenY);
price = getLatestPrice(quoteToken);
}
// ========================= PURE FUNCTIONS ====================================
function decimals() public pure returns (uint8) {
return 18;
}
// ========================= INTERNAL FUNCTIONS ================================
function _setPriceTolerance(address quoteToken, uint256 minPrice, uint256 maxPrice) internal {
if (maxPrice == 0 || minPrice == 0 || minPrice > maxPrice) revert PriceToleranceInvalid();
_maxPriceTolerance[quoteToken] = maxPrice;
_minPriceTolerance[quoteToken] = minPrice;
emit PriceToleranceUpdated(quoteToken, minPrice, maxPrice);
}
/**
* @notice Reverts if the price tolerance is invalid or if the price is outside the acceptable tolerance range
* @param quoteToken Address of quote token
* @param price The price of `baseToken`/`quoteToken`
*/
function _checkPriceInTolerance(address quoteToken, uint256 price) internal view {
(uint256 minPrice, uint256 maxPrice) = getPriceTolerance(quoteToken);
if (minPrice == 0 || maxPrice == 0) revert PriceToleranceInvalid();
if (price < minPrice || price > maxPrice) revert PriceNotInTolerance();
}
/**
* @notice Reverts if the price is stale
* @param quoteToken Address of the quote token
*/
function _checkPriceNotStale(address quoteToken) internal view {
uint32 threshold = getStalenessThreshold(quoteToken);
if (threshold < type(uint32).max) {
uint64 priceTimestamp = prices[quoteToken].timestamp;
if (priceTimestamp <= block.timestamp && block.timestamp - priceTimestamp > threshold) {
revert PriceStale();
}
}
}
}
IOracle.sol 126 lines
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.19;
interface IOracle{
event newPrice(address indexed _asset, uint64 _timestamp, uint256 _price);
event StalenessThresholdUpdated(address indexed quoteToken, uint32 threshold);
event PriceToleranceUpdated(address indexed quoteToken, uint256 minPrice, uint256 maxPrice);
error LengthMismatched();
error PriceStale();
error PriceToleranceInvalid();
error PriceNotInTolerance();
error TokensInvalid();
error PriceZero();
error TimestampInvalid();
/**
* @notice Updates the price of `baseToken`/`asset` to the specified `price` at the given timestamp.
* Reverts if the price tolerance is invalid or if the new price is outside the acceptable tolerance range.
*/
function putPrice(address asset, uint64 timestamp, uint256 price) external;
/**
* @notice Updates the prices
* @param _array An array of `NewPrice` structs containing information about the new prices.
*/
function updatePrices(NewPrice[] calldata _array) external;
/**
* @notice Updates staleness thresholds, reverts if the array lengths mismatched.
* @param quoteTokens The array of quote currency addresses
* @param thresholds The array of the staleness thresholds in seconds
*/
function setStalenessThresholds(address[] calldata quoteTokens, uint32[] calldata thresholds) external;
/**
* @notice Updates the price tolerance range of USD1/`token`
* @param quoteToken Address of the quote currency
* @param minPrice Min price tolerance
* @param maxPrice Max price tolerance
*/
function setPriceTolerance(address quoteToken, uint256 minPrice, uint256 maxPrice) external;
/**
* @notice Returns the base token for all oracle prices, which is USD1.
*/
function baseToken() external view returns (address);
/**
* @notice Gets the price info of `asset`
*/
function getPrice(address asset) external view returns (uint64 timestamp, uint64 prevTimestamp, uint256 price, uint256 prevPrice);
/**
* @notice Gets a list of prices.
* @param assets The token addresses
* @return The prices of assets
*/
function getPrices(address[] calldata assets) external view returns (IOracle.Price[] memory);
/**
* @notice Gets the latest price.
* Reverts if the timestamp of the price exceeds the staleness limit, or the price is zero.
* @param quoteToken Address of the quote currency
* @return price The price of `baseToken`/`quoteToken`
*/
function getLatestPrice(address quoteToken) external view returns (uint256 price);
/**
* @notice Gets the price staleness threshold, returns `STALENESS_DEFAULT_THRESHOLD` if it is zero.
* @param quoteToken Address of the quote token
* @return The staleness threshold in seconds
*/
function getStalenessThreshold(address quoteToken) external view returns (uint32);
/**
* @notice Gets the price tolerance of `baseToken`/`quoteToken`
*/
function getPriceTolerance(address quoteToken) external view returns (uint256 minPrice, uint256 maxPrice);
/**
* @notice Gets the quote token of oracle price by two token addresses.
* Because of the base currencies of all oracle prices are always USD1 (e.g., USD1/USDT and USD1/USD91),
* one of `tokenX` or `tokenY` must be USD1, and the other must not be USD1.
* @param tokenX Address of base currency or quote currency
* @param tokenY Address of base currency or quote currency
* @return quoteToken The quote currency of oracle price
*/
function getQuoteToken(address tokenX, address tokenY) external view returns (address quoteToken);
/**
* @notice Gets the quote token of oracle and the latest price.
* Reverts if the two token addresses are invalid, the timestamp of the price exceeds the staleness limit, or the price is zero.
* @param tokenX Address of base currency or quote currency
* @param tokenY Address of base currency or quote currency
*/
function getQuoteTokenAndPrice(address tokenX, address tokenY) external view returns (address quoteToken, uint256 price);
function FEEDER_ROLE() external pure returns (bytes32);
function GUARDIAN_ROLE() external pure returns (bytes32);
/**
* @notice Default threshold for staleness in seconds.
* When the value of `_stalenessThreshold` is zero, this default value is used.
*/
function STALENESS_DEFAULT_THRESHOLD() external pure returns (uint32);
function decimals() external pure returns (uint8);
// Struct of main contract XOracle
struct Price{
address asset;
uint64 timestamp;
uint64 prev_timestamp;
uint256 price;
uint256 prev_price;
}
struct NewPrice{
address asset;
uint64 timestamp;
uint256 price;
}
}
AddressUtils.sol 27 lines
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.19;
library AddressUtils {
error AddressZero();
error AddressCodeSizeZero();
/**
* @notice Reverts if `account` is zero or the code size is zero
*/
function checkContract(address account) internal view {
checkNotZero(account);
uint256 size;
assembly {
size := extcodesize(account)
}
if (size == 0) revert AddressCodeSizeZero();
}
/**
* @notice Reverts if `account` is zero
*/
function checkNotZero(address account) internal pure {
if (account == address(0)) revert AddressZero();
}
}
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 70 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/Math.sol";
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @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] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
}
Math.sol 345 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator
) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1);
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
// See https://cs.stackexchange.com/q/138556/92363.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
// in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator,
Rounding rounding
) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10**64) {
value /= 10**64;
result += 64;
}
if (value >= 10**32) {
value /= 10**32;
result += 32;
}
if (value >= 10**16) {
value /= 10**16;
result += 16;
}
if (value >= 10**8) {
value /= 10**8;
result += 8;
}
if (value >= 10**4) {
value /= 10**4;
result += 4;
}
if (value >= 10**2) {
value /= 10**2;
result += 2;
}
if (value >= 10**1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
}
}
}
AccessControl.sol 247 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol)
pragma solidity ^0.8.0;
import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/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);
_;
}
/**
* @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 `_msgSender()` is missing `role`.
* Overriding this function changes the behavior of the {onlyRole} modifier.
*
* Format of the revert message is described in {_checkRole}.
*
* _Available since v4.6._
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @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(account),
" 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.
*
* May emit a {RoleGranted} event.
*/
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.
*
* May emit a {RoleRevoked} event.
*/
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`.
*
* May emit a {RoleRevoked} event.
*/
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.
*
* May emit a {RoleGranted} event.
*
* [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.
*
* May emit a {RoleGranted} event.
*/
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.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
}
IAccessControl.sol 88 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;
}
ERC165.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./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
DEFAULT_ADMIN_ROLE 0xa217fddf → bytes32
FEEDER_ROLE 0xceb20971 → bytes32
GUARDIAN_ROLE 0x24ea54f4 → bytes32
STALENESS_DEFAULT_THRESHOLD 0x7f4c9b60 → uint32
baseToken 0xc55dae63 → address
decimals 0x313ce567 → uint8
getLatestPrice 0x16345f18 → uint256
getPrice 0x41976e09 → uint64, uint64, uint256, uint256
getPriceTolerance 0x6e757234 → uint256, uint256
getPrices 0x8fb5a482 → tuple[]
getQuoteToken 0x8f613419 → address
getQuoteTokenAndPrice 0x224dc0fe → address, uint256
getRoleAdmin 0x248a9ca3 → bytes32
getStalenessThreshold 0xee8f525e → uint32
hasRole 0x91d14854 → bool
prices 0xcfed246b → address, uint64, uint64, uint256, uint256
supportsInterface 0x01ffc9a7 → bool
Write Contract 7 functions
These functions modify contract state and require a wallet transaction to execute.
grantRole 0x2f2ff15d
bytes32 role
address account
putPrice 0x7b3132d2
address asset
uint64 timestamp
uint256 price
renounceRole 0x36568abe
bytes32 role
address account
revokeRole 0xd547741f
bytes32 role
address account
setPriceTolerance 0x6c90659e
address quoteToken
uint256 minPrice
uint256 maxPrice
setStalenessThresholds 0x5b4481d5
address[] quoteTokens
uint32[] thresholds
updatePrices 0xa0f48069
tuple[] _array
Recent Transactions
No transactions found for this address