OracleRegistry

Description:

Decentralized Finance (DeFi) protocol contract providing Swap, Factory, Oracle functionality.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

{{
  "language": "Solidity",
  "sources": {
    "src/oracle/OracleRegistry.sol": {
      "content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.26;

import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol";

import {IOracleFeed} from "../interfaces/IOracleFeed.sol";
import {IOracleRegistry} from "../interfaces/IOracleRegistry.sol";
import {IParamRegistry} from "../interfaces/IParamRegistry.sol";

import {Constants} from "../common/Constants.sol";
import {Errors} from "../libraries/Errors.sol";

/// @title OracleRegistry
/// @author luoyhang003
/// @notice Manages prices for vaultToken and other registered tokens, including updates from oracles and cut-off prices.
/// @dev Uses OpenZeppelin AccessControl for role-based permissioning
/// @dev Stores historical prices and supports both common and cut-off price updates
/// @dev Performs deviation checks to prevent extreme price manipulations
contract OracleRegistry is AccessControl, Constants, IOracleRegistry {
    /*//////////////////////////////////////////////////////////////////////////
                                    STATE VARIABLES
    //////////////////////////////////////////////////////////////////////////*/

    /// @notice Role allowed to update prices
    /// @dev Only addresses with this role can call `updatePrices`
    /// @dev Calculated as keccak256("PRICE_UPDATE_ROLE").
    bytes32 public constant PRICE_UPDATE_ROLE = keccak256("PRICE_UPDATE_ROLE");

    /// @notice Role allowed to manage oracles
    /// @dev Only addresses with this role can call `addTokenOracle`, `removeTokenOracle`, `updateTokenOracle`
    /// @dev Calculated as keccak256("ORACLE_MANAGE_ROLE").
    bytes32 public constant ORACLE_MANAGE_ROLE =
        keccak256("ORACLE_MANAGE_ROLE");

    /// @notice Parameter registry contract
    /// @dev Used to fetch tolerances, price update intervals, and validity durations
    IParamRegistry public paramRegistry;

    /// @notice Vault token address
    /// @dev Core token whose price is specially managed and checked against exchange rate tolerances
    address public immutable vaultToken;

    /// @notice List of all registered tokens
    /// @dev Used for iteration during price updates and retrieving historical prices
    address[] public tokens;

    /// @notice Timestamps of common price updates
    /// @dev Index corresponds to historical versions of price updates
    uint256[] public commonPriceUpdatedAt;

    /// @notice Timestamps of cut-off price updates
    /// @dev Only updated when `_isCutOffPrice` is true during `updatePrices`
    uint256[] public cutOffPriceUpdateAt;

    /// @notice Token => Timestamp => Price mapping
    /// @dev Stores all historical prices for each token
    mapping(address => mapping(uint256 => uint256)) public prices;

    /// @notice Token => OracleFeed mapping
    /// @dev Internal mapping to track which oracle feed is used for each token
    mapping(address => IOracleFeed) private _oracles;

    /*//////////////////////////////////////////////////////////////////////////
                                    CONSTRUCTOR
    //////////////////////////////////////////////////////////////////////////*/

    /// @notice Initializes OracleRegistry
    /// @param _vaultToken Core vault token
    /// @param _tokens Tokens to register initially
    /// @param _oracleFeeds Corresponding oracle feeds
    /// @param _paramRegistry Parameter registry contract
    /// @param _defaultAdmin Admin address for DEFAULT_ADMIN_ROLE
    /// @param _priceUpdateRole Address granted the PRICE_UPDATE_ROLE.
    /// @param _oracleManageRole Address granted the ORACLE_MANAGE_ROLE.
    /// @dev Performs zero-address checks and ensures token/oracle arrays have the same length
    /// @dev Initializes initial prices and emits `PriceUpdated` events
    constructor(
        address _vaultToken,
        address[] memory _tokens,
        address[] memory _oracleFeeds,
        address _paramRegistry,
        address _defaultAdmin,
        address _priceUpdateRole,
        address _oracleManageRole
    ) {
        if (
            _vaultToken == address(0) ||
            _paramRegistry == address(0) ||
            _defaultAdmin == address(0) ||
            _priceUpdateRole == address(0) ||
            _oracleManageRole == address(0)
        ) revert Errors.ZeroAddress();

        paramRegistry = IParamRegistry(_paramRegistry);

        uint256 tokenLength = _tokens.length;
        if (tokenLength == 0 || tokenLength != _oracleFeeds.length)
            revert Errors.InvalidArrayLength();

        uint256 updatedAt = block.timestamp;

        // Initialize token-oracle pairs
        uint256 i;
        for (i = 0; i < tokenLength; i++) {
            address token = _tokens[i];
            address oracle = _oracleFeeds[i];

            if (token == _vaultToken) revert Errors.ConflictiveToken();

            if (token == address(0) || oracle == address(0))
                revert Errors.ZeroAddress();

            tokens.push(token);

            IOracleFeed feed = IOracleFeed(oracle);
            _checkOracleInitialPrice(feed);
            _oracles[token] = feed;

            emit OracleAdded(token, oracle);

            uint256 price = feed.peek();
            prices[token][updatedAt] = price;

            emit PriceUpdated(token, price, updatedAt, false);
        }

        // Initialize vault token price
        vaultToken = _vaultToken;
        prices[_vaultToken][updatedAt] = INIT_EXCHANGE_PRICE;

        emit PriceUpdated(_vaultToken, INIT_EXCHANGE_PRICE, updatedAt, false);

        commonPriceUpdatedAt.push(updatedAt);

        // Grant default admin role
        _grantRole(DEFAULT_ADMIN_ROLE, _defaultAdmin);

        _grantRole(PRICE_UPDATE_ROLE, _priceUpdateRole);
        _grantRole(ORACLE_MANAGE_ROLE, _oracleManageRole);
    }

    /*//////////////////////////////////////////////////////////////////////////
                                    PRICE UPDATE LOGIC
    //////////////////////////////////////////////////////////////////////////*/

    /// @notice Updates prices for vault token and other registered tokens
    /// @param _vaultTokenPrice New vault token price
    /// @param _isCutOffPrice Whether the update is a cut-off price
    /// @dev Reverts if price deviates beyond tolerances or updates are too frequent
    /// @dev Updates all registered tokens based on their oracle feeds
    function updatePrices(
        uint256 _vaultTokenPrice,
        bool _isCutOffPrice
    ) external onlyRole(PRICE_UPDATE_ROLE) {
        uint256 latestExchangeRate = onlyPeekAt(vaultToken, 0);
        uint256 maxUpperDeviation = (latestExchangeRate *
            paramRegistry.getExchangeRateMaxUpperToleranceBps()) /
            BPS_DENOMINATOR;

        uint256 maxLowerDeviation = (latestExchangeRate *
            paramRegistry.getExchangeRateMaxLowerToleranceBps()) /
            BPS_DENOMINATOR;

        if (
            _vaultTokenPrice > latestExchangeRate + maxUpperDeviation ||
            _vaultTokenPrice < latestExchangeRate - maxLowerDeviation
        ) revert Errors.ExceedMaxDeviation();

        uint256 updatedAt = block.timestamp;

        if (
            latestPricesUpdatedAt() + paramRegistry.getPriceUpdateInterval() >
            updatedAt
        ) revert Errors.PriceUpdateTooFrequent();

        // Update vault token price
        prices[vaultToken][updatedAt] = _vaultTokenPrice;

        emit PriceUpdated(
            vaultToken,
            _vaultTokenPrice,
            updatedAt,
            _isCutOffPrice
        );

        // Update other tokens
        uint256 i;
        uint256 tokenLength = tokens.length;
        for (i; i < tokenLength; i++) {
            address token = tokens[i];
            uint256 price = peek(token);

            prices[token][updatedAt] = price;

            emit PriceUpdated(token, price, updatedAt, _isCutOffPrice);
        }

        commonPriceUpdatedAt.push(updatedAt);

        if (_isCutOffPrice) {
            cutOffPriceUpdateAt.push(updatedAt);
        }
    }

    /*//////////////////////////////////////////////////////////////////////////
                                    ORACLE MANAGE LOGIC
    //////////////////////////////////////////////////////////////////////////*/

    /// @notice Adds a new token and its oracle feed
    /// @param _token Token address
    /// @param _oracle Oracle feed address
    /// @dev Only callable by ORACLE_MANAGE_ROLE
    /// @dev Reverts if token already exists or any address is zero
    function addTokenOracle(
        address _token,
        address _oracle
    ) external onlyRole(ORACLE_MANAGE_ROLE) {
        if (tokens.length >= paramRegistry.getArrayLengthLimit())
            revert Errors.ExceedArrayLengthLimit();

        if (_token == vaultToken) revert Errors.ConflictiveToken();

        if (_token == address(0) || _oracle == address(0))
            revert Errors.ZeroAddress();

        if (address(_oracles[_token]) != address(0))
            revert Errors.OracleAlreadyAdded();

        // Fetch initial price and enforce stablecoin deviation limits
        IOracleFeed feed = IOracleFeed(_oracle);
        _checkOracleInitialPrice(feed);

        tokens.push(_token);
        _oracles[_token] = feed;

        emit OracleAdded(_token, _oracle);
    }

    /// @notice Removes a token and its oracle feed
    /// @param _token Token address to remove
    /// @dev Uses swap-and-pop for efficient removal from array
    /// @dev Only callable by ORACLE_MANAGE_ROLE
    function removeTokenOracle(
        address _token
    ) external onlyRole(ORACLE_MANAGE_ROLE) {
        if (address(_oracles[_token]) == address(0))
            revert Errors.OracleNotExist();

        uint256 length = tokens.length;
        uint256 i;
        for (i; i < length; i++) {
            if (tokens[i] == _token) {
                tokens[i] = tokens[length - 1];
                tokens.pop();
                break;
            }
        }
        delete _oracles[_token];

        emit OracleRemoved(_token);
    }

    /// @notice Updates an existing token’s oracle feed
    /// @param _token Token address
    /// @param _oracle New oracle feed address
    /// @dev Only callable by ORACLE_MANAGE_ROLE
    /// @dev Reverts if token does not exist or any address is zero
    function updateTokenOracle(
        address _token,
        address _oracle
    ) external onlyRole(ORACLE_MANAGE_ROLE) {
        if (_token == address(0) || _oracle == address(0))
            revert Errors.ZeroAddress();

        if (address(_oracles[_token]) == address(0))
            revert Errors.OracleNotExist();

        // Fetch initial price and enforce stablecoin deviation limits
        IOracleFeed feed = IOracleFeed(_oracle);
        _checkOracleInitialPrice(feed);

        _oracles[_token] = feed;

        emit OracleUpdated(_token, _oracle);
    }

    /*//////////////////////////////////////////////////////////////////////////
                                    VIEW FUNCTIONS
    //////////////////////////////////////////////////////////////////////////*/

    /// @notice Returns the oracle feed address for a given token
    /// @param _token Token address to query
    /// @return oracle_ Address of the oracle feed
    /// @dev Returns zero address if token is not registered
    function getOracle(address _token) external view returns (address oracle_) {
        return address(_oracles[_token]);
    }

    /// @notice Returns all registered token addresses
    /// @return tokens_ Array of token addresses
    /// @dev Useful for iterating over all tokens to fetch historical prices
    function getTokens() external view returns (address[] memory tokens_) {
        return tokens;
    }

    /// @notice Returns the timestamp of the latest common price update
    /// @return timestamp_ Timestamp of latest update
    /// @dev Reverts if no updates exist
    function latestPricesUpdatedAt() public view returns (uint256 timestamp_) {
        uint256 length = commonPriceUpdatedAt.length;
        if (length == 0) revert Errors.IndexOutOfBounds();

        return commonPriceUpdatedAt[length - 1];
    }

    /// @notice Returns the timestamp of the latest cut-off price update
    /// @return timestamp_ Timestamp of latest cut-off update
    /// @dev Reverts if no cut-off updates exist
    function latestCutOffPriceUpdatedAt()
        external
        view
        returns (uint256 timestamp_)
    {
        uint256 length = cutOffPriceUpdateAt.length;
        if (length == 0) revert Errors.IndexOutOfBounds();

        return cutOffPriceUpdateAt[length - 1];
    }

    /// @notice Returns the latest price of a token from its oracle
    /// @param _token Token address
    /// @return price_ Latest price from oracle
    /// @dev Performs deviation check to prevent extreme values
    function peek(address _token) public view returns (uint256 price_) {
        if (address(_oracles[_token]) == address(0))
            revert Errors.OracleNotExist();

        uint256 price = _oracles[_token].peek();
        uint256 maxDeviation = (STABLECOIN_BASE_PRICE *
            paramRegistry.getStablecoinPriceToleranceBps()) / BPS_DENOMINATOR;

        if (
            price > STABLECOIN_BASE_PRICE + maxDeviation ||
            price < STABLECOIN_BASE_PRICE - maxDeviation
        ) revert Errors.ExceedMaxDeviation();

        return price;
    }

    /// @notice Returns historical price for a token at a given index
    /// @param _token Token address
    /// @param _index Index (0 = latest)
    /// @return price_ Historical price
    /// @dev Checks price validity (time not expired)
    function peekAt(
        address _token,
        uint256 _index
    ) public view returns (uint256 price_) {
        return _getPrice(_token, _index, true);
    }

    /// @notice Returns historical price without validity check
    /// @param _token Token address
    /// @param _index Index (0 = latest)
    /// @return price_ Historical price
    /// @dev Useful for auditing or internal calculations
    function onlyPeekAt(
        address _token,
        uint256 _index
    ) public view returns (uint256 price_) {
        return _getPrice(_token, _index, false);
    }

    /// @notice Returns the historical price of the vault token at a given index
    /// @param _index Index (0 = latest)
    /// @return price_ Vault token price
    /// @dev Checks price validity
    function getVaultTokenPrice(
        uint256 _index
    ) public view returns (uint256 price_) {
        return _getPrice(vaultToken, _index, true);
    }

    /// @notice Returns the historical price of the vault token without validity check
    /// @param _index Index (0 = latest)
    /// @return price_ Vault token price
    /// @dev Useful for internal calculations
    function onlyGetVaultTokenPrice(
        uint256 _index
    ) public view returns (uint256 price_) {
        return _getPrice(vaultToken, _index, false);
    }

    /// @notice Returns token price at a cut-off update
    /// @param _token Token address
    /// @param _index Index of cut-off update (0 = latest)
    /// @return price_ The cut-off price for the token
    /// @dev Reverts if price is expired or index out of bounds
    function getCutOffPrice(
        address _token,
        uint256 _index
    ) external view returns (uint256 price_) {
        uint256 length = cutOffPriceUpdateAt.length;
        if (_index >= length) revert Errors.IndexOutOfBounds();

        uint256 updatedAt = cutOffPriceUpdateAt[length - _index - 1];
        if (
            block.timestamp >
            paramRegistry.getPriceValidityDuration() + updatedAt
        ) revert Errors.PriceValidityExpired();

        price_ = prices[_token][updatedAt];

        if (price_ == 0) revert Errors.InvalidZeroPrice();
    }

    /// @notice Returns token addresses and prices at a cut-off update
    /// @param _index Index of cut-off update (0 = latest)
    /// @return tokens_ Array of token addresses
    /// @return prices_ Array of prices for each token
    /// @dev Reverts if price is expired or index out of bounds
    function getCutOffPrices(
        uint256 _index
    )
        external
        view
        returns (address[] memory tokens_, uint256[] memory prices_)
    {
        uint256 length = cutOffPriceUpdateAt.length;
        if (_index >= length) revert Errors.IndexOutOfBounds();

        uint256 updatedAt = cutOffPriceUpdateAt[length - _index - 1];
        if (
            block.timestamp >
            paramRegistry.getPriceValidityDuration() + updatedAt
        ) revert Errors.PriceValidityExpired();

        uint256 tokenLength = tokens.length;
        tokens_ = new address[](tokenLength);
        prices_ = new uint256[](tokenLength);

        uint256 i;
        for (i; i < tokenLength; i++) {
            address token = tokens[i];
            uint256 price = prices[token][updatedAt];

            if (price == 0) revert Errors.InvalidZeroPrice();

            tokens_[i] = token;
            prices_[i] = price;
        }
    }

    /// @notice Same as `getCutOffPrices` but does not check validity
    /// @param _index Index of cut-off update (0 = latest)
    /// @return tokens_ Array of token addresses
    /// @return prices_ Array of prices for each token
    /// @dev Useful for internal auditing or calculation
    function onlyGetCutOffPrices(
        uint256 _index
    )
        external
        view
        returns (address[] memory tokens_, uint256[] memory prices_)
    {
        uint256 length = cutOffPriceUpdateAt.length;
        if (_index >= length) revert Errors.IndexOutOfBounds();

        uint256 updatedAt = cutOffPriceUpdateAt[length - _index - 1];

        uint256 tokenLength = tokens.length;
        tokens_ = new address[](tokenLength);
        prices_ = new uint256[](tokenLength);

        uint256 i;
        for (i; i < tokenLength; i++) {
            address token = tokens[i];
            uint256 price = prices[token][updatedAt];

            if (price == 0) revert Errors.InvalidZeroPrice();

            tokens_[i] = token;
            prices_[i] = price;
        }
    }

    /// @notice Returns the vault token cut-off price at a given index
    /// @param _index Index of cut-off update (0 = latest)
    /// @return price_ Vault token price
    /// @dev Checks validity
    function getVaultTokenCutOffPrice(
        uint256 _index
    ) external view returns (uint256 price_) {
        uint256 length = cutOffPriceUpdateAt.length;
        if (_index >= length) revert Errors.IndexOutOfBounds();

        uint256 updatedAt = cutOffPriceUpdateAt[length - _index - 1];
        if (
            block.timestamp >
            paramRegistry.getPriceValidityDuration() + updatedAt
        ) revert Errors.PriceValidityExpired();

        price_ = prices[vaultToken][updatedAt];
    }

    /// @notice Returns the vault token cut-off price without validity check
    /// @param _index Index of cut-off update (0 = latest)
    /// @return price_ Vault token price
    /// @dev Useful for internal calculations
    function onlyGetVaultTokenCutOffPrice(
        uint256 _index
    ) external view returns (uint256 price_) {
        uint256 length = cutOffPriceUpdateAt.length;
        if (_index >= length) revert Errors.IndexOutOfBounds();

        uint256 updatedAt = cutOffPriceUpdateAt[length - _index - 1];

        price_ = prices[vaultToken][updatedAt];
    }

    /*//////////////////////////////////////////////////////////////////////////
                                    INTERNAL FUNCTIONS
    //////////////////////////////////////////////////////////////////////////*/

    /// @notice Retrieves the historical price of a token at a given index
    /// @param _token Token address to query
    /// @param _index Index of the historical price (0 = latest)
    /// @param _checkValidity Whether to check if the price is still valid
    /// @return price_ Price of the token at the given index
    /// @dev
    /// - Uses `commonPriceUpdatedAt` array to find the timestamp of the requested price.
    /// - If `_checkValidity` is true, reverts if the price is older than
    ///   `paramRegistry.getPriceValidityDuration()`.
    /// - Reverts if `_index` is out of bounds.
    /// - Returns the stored price from `prices[token][updatedAt]`.
    function _getPrice(
        address _token,
        uint256 _index,
        bool _checkValidity
    ) internal view returns (uint256) {
        uint256 length = commonPriceUpdatedAt.length;
        if (_index >= length) revert Errors.IndexOutOfBounds();

        uint256 updatedAt = commonPriceUpdatedAt[length - _index - 1];

        if (_checkValidity) {
            uint256 validityDuration = paramRegistry.getPriceValidityDuration();
            if (block.timestamp > updatedAt + validityDuration) {
                revert Errors.PriceValidityExpired();
            }
        }

        return prices[_token][updatedAt];
    }

    /// @notice Verifies that the initial oracle price of a stablecoin is within the acceptable deviation range.
    /// @param _feed The oracle feed contract providing the stablecoin price.
    /// @dev This function ensures that the oracle feed provides a reasonable price at initialization time,
    ///      preventing cases where the oracle might return an outlier or depegged value.
    ///      - The function reads the current price via `_feed.peek()`.
    ///      - It then computes the maximum allowed deviation from the stablecoin’s base price
    ///        using the tolerance (in basis points) from the ParamRegistry.
    ///      - If the oracle-reported price exceeds the upper or lower deviation boundary,
    ///        the function reverts with `Errors.ExceedMaxDeviation()`.
    ///      - Reverts Errors.ExceedMaxDeviation() if the oracle price is outside the permitted tolerance range.
    function _checkOracleInitialPrice(IOracleFeed _feed) internal view {
        uint256 price = _feed.peek();
        uint256 maxDeviation = (STABLECOIN_BASE_PRICE *
            paramRegistry.getStablecoinPriceToleranceBps()) / BPS_DENOMINATOR;

        if (
            price > STABLECOIN_BASE_PRICE + maxDeviation ||
            price < STABLECOIN_BASE_PRICE - maxDeviation
        ) revert Errors.ExceedMaxDeviation();
    }
}
"
    },
    "lib/openzeppelin-contracts/contracts/access/AccessControl.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (access/AccessControl.sol)

pragma solidity ^0.8.20;

import {IAccessControl} from "./IAccessControl.sol";
import {Context} from "../utils/Context.sol";
import {IERC165, ERC165} from "../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:
 *
 * ```solidity
 * 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}:
 *
 * ```solidity
 * 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. We recommend using {AccessControlDefaultAdminRules}
 * to enforce additional security measures for this role.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address account => bool) hasRole;
        bytes32 adminRole;
    }

    mapping(bytes32 role => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with an {AccessControlUnauthorizedAccount} error including the required role.
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

    /// @inheritdoc IERC165
    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 returns (bool) {
        return _roles[role].hasRole[account];
    }

    /**
     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
     * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
     * is missing `role`.
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert AccessControlUnauthorizedAccount(account, role);
        }
    }

    /**
     * @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 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 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 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 `callerConfirmation`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address callerConfirmation) public virtual {
        if (callerConfirmation != _msgSender()) {
            revert AccessControlBadConfirmation();
        }

        _revokeRole(role, callerConfirmation);
    }

    /**
     * @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 Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
        if (!hasRole(role, account)) {
            _roles[role].hasRole[account] = true;
            emit RoleGranted(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Attempts to revoke `role` from `account` and returns a boolean indicating if `role` was revoked.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
        if (hasRole(role, account)) {
            _roles[role].hasRole[account] = false;
            emit RoleRevoked(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }
}
"
    },
    "src/interfaces/IOracleFeed.sol": {
      "content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.26;

/// @title IOracleFeed
/// @author luoyhang003
/// @notice Standardized interface for oracle price feeds.
/// @dev Provides a unified method for fetching the latest asset price.
///      Implementations may differ (e.g., Chainlink, Redstone, custom oracles),
///      but must conform to this interface.
interface IOracleFeed {
    /*//////////////////////////////////////////////////////////////////////////
                                    VIEW FUNCTIONS
    //////////////////////////////////////////////////////////////////////////*/

    /// @notice Returns the latest price from the oracle.
    /// @dev The return value should be normalized to 18 decimals whenever possible
    ///      to maintain consistency across different oracle implementations.
    /// @return price_ The most recent valid price.
    function peek() external view returns (uint256 price_);
}
"
    },
    "src/interfaces/IOracleRegistry.sol": {
      "content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.26;

/// @title IOracleRegistry
/// @author luoyhang003
/// @notice Interface for Oracle Registry contract to manage token oracles and price updates
/// @dev Handles addition, removal, and updates of token oracles. Stores historical prices and cut-off prices.
///      Includes role-based access control: PRICE_UPDATE_ROLE for price updates, ORACLE_MANAGE_ROLE for oracle management.
interface IOracleRegistry {
    /*//////////////////////////////////////////////////////////////////////////
                                    EVENTS
    //////////////////////////////////////////////////////////////////////////*/

    /// @notice Emitted when a new token oracle is added
    /// @param token The token address associated with the oracle
    /// @param oracle The oracle address providing price feeds
    /// @dev Only callable via OracleRegistry contract functions that manage oracles
    event OracleAdded(address indexed token, address indexed oracle);

    /// @notice Emitted when a token oracle is removed
    /// @param token The token address whose oracle is removed
    /// @dev Only callable via OracleRegistry contract functions that manage oracles
    event OracleRemoved(address indexed token);

    /// @notice Emitted when a token oracle is updated
    /// @param token The token address whose oracle is updated
    /// @param oracle The new oracle address
    /// @dev Only callable via OracleRegistry contract functions that manage oracles
    event OracleUpdated(address indexed token, address indexed oracle);

    /// @notice Emitted when a token price is updated
    /// @param token The token address
    /// @param price The new price
    /// @param updatedAt Timestamp when the price is updated
    /// @param isCutOffPrice Whether this price is a cut-off price
    /// @dev Only callable by addresses with PRICE_UPDATE_ROLE
    event PriceUpdated(
        address indexed token,
        uint256 price,
        uint256 updatedAt,
        bool isCutOffPrice
    );

    /*//////////////////////////////////////////////////////////////////////////
                                    VIEW FUNCTIONS
    //////////////////////////////////////////////////////////////////////////*/

    /// @notice Returns the oracle feed address for a given token
    /// @param _token Token address to query
    /// @return oracle_ Address of the oracle feed
    /// @dev Returns zero address if token is not registered
    function getOracle(address _token) external view returns (address oracle_);

    /// @notice Returns all registered token addresses
    /// @return tokens_ Array of token addresses
    /// @dev Useful for iterating over all tokens to fetch historical prices
    function getTokens() external view returns (address[] memory tokens_);

    /// @notice Returns the timestamp of the latest common price update
    /// @return timestamp_ Timestamp of latest update
    /// @dev Reverts if no updates exist
    function latestPricesUpdatedAt() external view returns (uint256 timestamp_);

    /// @notice Returns the timestamp of the latest cut-off price update
    /// @return timestamp_ Timestamp of latest cut-off update
    /// @dev Reverts if no cut-off updates exist
    function latestCutOffPriceUpdatedAt()
        external
        view
        returns (uint256 timestamp_);

    /// @notice Returns the latest price of a token from its oracle
    /// @param _token Token address
    /// @return price_ Latest price from oracle
    /// @dev Performs deviation check to prevent extreme values
    function peek(address _token) external view returns (uint256 price_);

    /// @notice Returns historical price for a token at a given index
    /// @param _token Token address
    /// @param _index Index (0 = latest)
    /// @return price_ Historical price
    /// @dev Checks price validity (time not expired)
    function peekAt(
        address _token,
        uint256 _index
    ) external view returns (uint256 price_);

    /// @notice Returns historical price without validity check
    /// @param _token Token address
    /// @param _index Index (0 = latest)
    /// @return price_ Historical price
    /// @dev Useful for auditing or internal calculations
    function onlyPeekAt(
        address _token,
        uint256 _index
    ) external view returns (uint256 price_);

    /// @notice Returns the historical price of the vault token at a given index
    /// @param _index Index (0 = latest)
    /// @return price_ Vault token price
    /// @dev Checks price validity
    function getVaultTokenPrice(
        uint256 _index
    ) external view returns (uint256 price_);

    /// @notice Returns the historical price of the vault token without validity check
    /// @param _index Index (0 = latest)
    /// @return price_ Vault token price
    /// @dev Useful for internal calculations
    function onlyGetVaultTokenPrice(
        uint256 _index
    ) external view returns (uint256 price_);

    /// @notice Returns token price at a cut-off update
    /// @param _token Token address
    /// @param _index Index of cut-off update (0 = latest)
    /// @return price_ The cut-off price for the token
    /// @dev Reverts if price is expired or index out of bounds
    function getCutOffPrice(
        address _token,
        uint256 _index
    ) external view returns (uint256 price_);

    /// @notice Returns token addresses and prices at a cut-off update
    /// @param _index Index of cut-off update (0 = latest)
    /// @return tokens_ Array of token addresses
    /// @return prices_ Array of prices for each token
    /// @dev Reverts if price is expired or index out of bounds
    function getCutOffPrices(
        uint256 _index
    )
        external
        view
        returns (address[] memory tokens_, uint256[] memory prices_);

    /// @notice Same as `getCutOffPrices` but does not check validity
    /// @param _index Index of cut-off update (0 = latest)
    /// @return tokens_ Array of token addresses
    /// @return prices_ Array of prices for each token
    /// @dev Useful for internal auditing or calculation
    function onlyGetCutOffPrices(
        uint256 _index
    )
        external
        view
        returns (address[] memory tokens_, uint256[] memory prices_);

    /// @notice Returns the vault token cut-off price at a given index
    /// @param _index Index of cut-off update (0 = latest)
    /// @return price_ Vault token price
    /// @dev Checks validity
    function getVaultTokenCutOffPrice(
        uint256 _index
    ) external view returns (uint256 price_);

    /// @notice Returns the vault token cut-off price without validity check
    /// @param _index Index of cut-off update (0 = latest)
    /// @return price_ Vault token price
    /// @dev Useful for internal calculations
    function onlyGetVaultTokenCutOffPrice(
        uint256 _index
    ) external view returns (uint256 price_);
}
"
    },
    "src/interfaces/IParamRegistry.sol": {
      "content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.26;

/// @title IParamRegistry
/// @author luoyhang003
/// @notice Interface for the protocol parameter registry contract.
/// @dev
/// - Defines key protocol configuration parameters such as fee rates, deposit caps,
///   price tolerances, and critical role-restricted settings.
/// - Provides events for tracking parameter updates to ensure transparency and auditability.
/// - Exposes getter functions for external contracts to query configuration values,
///   and (in the implementing contract) setter functions protected by timelock roles.
/// - Used as the central source of truth for system-wide configuration and policy enforcement.
interface IParamRegistry {
    /*//////////////////////////////////////////////////////////////////////////
                                    EVENTS
    //////////////////////////////////////////////////////////////////////////*/

    /// @notice Emitted when the maximum upper tolerance for exchange rate deviation is updated.
    /// @param oldVal Previous tolerance value in basis points.
    /// @param newVal New tolerance value in basis points.
    event SetExchangeRateMaxUpperToleranceBps(uint256 oldVal, uint256 newVal);

    /// @notice Emitted when the maximum lower tolerance for exchange rate deviation is updated.
    /// @param oldVal Previous tolerance value in basis points.
    /// @param newVal New tolerance value in basis points.
    event SetExchangeRateMaxLowerToleranceBps(uint256 oldVal, uint256 newVal);

    /// @notice Emitted when the stablecoin price tolerance is updated.
    /// @param oldVal Previous tolerance value in basis points.
    /// @param newVal New tolerance value in basis points.
    event SetStablecoinPriceToleranceBps(uint256 oldVal, uint256 newVal);

    /// @notice Emitted when the volatile asset price tolerance is updated.
    /// @param oldVal Previous tolerance value in basis points.
    /// @param newVal New tolerance value in basis points.
    event SetVolatileAssetPriceToleranceBps(uint256 oldVal, uint256 newVal);

    /// @notice Emitted when the minimum price update interval is updated.
    /// @param oldVal Previous interval value in seconds.
    /// @param newVal New interval value in seconds.
    event SetPriceUpdateInterval(uint256 oldVal, uint256 newVal);

    /// @notice Emitted when the maximum price validity duration is updated.
    /// @param oldVal Previous duration value in seconds.
    /// @param newVal New duration value in seconds.
    event SetPriceValidityDuration(uint256 oldVal, uint256 newVal);

    /// @notice Emitted when the mint fee rate for a specific asset is updated.
    /// @param asset The address of the asset.
    /// @param oldRate Previous mint fee rate in basis points.
    /// @param newRate New mint fee rate in basis points.
    event SetMintFeeRate(
        address indexed asset,
        uint256 oldRate,
        uint256 newRate
    );

    /// @notice Emitted when the redeem fee rate for a specific asset is updated.
    /// @param asset The address of the asset.
    /// @param oldRate Previous redeem fee rate in basis points.
    /// @param newRate New redeem fee rate in basis points.
    event SetRedeemFeeRate(
        address indexed asset,
        uint256 oldRate,
        uint256 newRate
    );

    /// @notice Emitted when deposit enablement is updated for a specific asset.
    /// @param asset The address of the asset.
    /// @param enabled True if deposits are enabled, false otherwise.
    event SetDepositEnabled(address indexed asset, bool enabled);

    /// @notice Emitted when redemption enablement is updated for a specific asset.
    /// @param asset The address of the asset.
    /// @param enabled True if redemptions are enabled, false otherwise.
    event SetRedeemEnabled(address indexed asset, bool enabled);

    /// @notice Emitted when the global deposit cap is updated.
    /// @param oldVal Previous global deposit cap.
    /// @param newVal New global deposit cap.
    event SetTotalDepositCap(uint256 oldVal, uint256 newVal);

    /// @notice Emitted when the deposit cap for a specific asset is updated.
    /// @param asset The address of the asset.
    /// @param oldVal Previous cap value.
    /// @param newVal New cap value.
    event SetTokenDepositCap(
        address indexed asset,
        uint256 oldVal,
        uint256 newVal
    );

    /// @notice Emitted when the global array length limit is updated.
    /// @param oldVal Previous limit value.
    /// @param newVal New limit value.
    event SetArrayLengthLimit(uint256 oldVal, uint256 newVal);

    /// @notice Emitted when the fee recipient address is updated.
    /// @param oldVal Previous fee recipient address.
    /// @param newVal New fee recipient address.
    event SetFeeRecipient(address oldVal, address newVal);

    /// @notice Emitted when the forfeited assets treasury address is updated.
    /// @param oldVal Previous treasury address.
    /// @param newVal New treasury address.
    event SetForfeitTreasury(address oldVal, address newVal);

    /*//////////////////////////////////////////////////////////////////////////
                                    VIEW FUNCTIONS
    //////////////////////////////////////////////////////////////////////////*/

    /// @notice Returns the current upper tolerance for exchange rate deviation.
    function getExchangeRateMaxUpperToleranceBps()
        external
        view
        returns (uint256);

    /// @notice Returns the current lower tolerance for exchange rate deviation.
    function getExchangeRateMaxLowerToleranceBps()
        external
        view
        returns (uint256);

    /// @notice Returns the current stablecoin price tolerance in bps.
    function getStablecoinPriceToleranceBps() external view returns (uint256);

    /// @notice Returns the current volatile asset price tolerance in bps.
    function getVolatileAssetPriceToleranceBps()
        external
        view
        returns (uint256);

    /// @notice Returns the minimum interval between price updates.
    function getPriceUpdateInterval() external view returns (uint256);

    /// @notice Returns the maximum validity duration of cached prices.
    function getPriceValidityDuration() external view returns (uint256);

    /// @notice Returns the configured mint fee rate for a given asset.
    /// @param _asset The address of the asset.
    /// @return The mint fee rate in basis points.
    function getMintFeeRate(address _asset) external view returns (uint256);

    /// @notice Returns the configured redeem fee rate for a given asset.
    /// @param _asset The address of the asset.
    /// @return The redeem fee rate in basis points.
    function getRedeemFeeRate(address _asset) external view returns (uint256);

    /// @notice Returns whether deposits are enabled for a given asset.
    /// @param _asset The address of the asset.
    /// @return True if deposits are enabled, false otherwise.
    function getDepositEnabled(address _asset) external view returns (bool);

    /// @notice Returns whether redemptions are enabled for a given asset.
    /// @param _asset The address of the asset.
    /// @return True if redemptions are enabled, false otherwise.
    function getRedeemEnabled(address _asset) external view returns (bool);

    /// @notice Returns the global deposit cap.
    function getTotalDepositCap() external view returns (uint256);

    /// @notice Returns the deposit cap for a specific asset.
    /// @param _asset The address of the asset.
    function getTokenDepositCap(address _asset) external view returns (uint256);

    /// @notice Returns the global array length limit.
    function getArrayLengthLimit() external view returns (uint256);

    /// @notice Returns the address of the fee recipient.
    function getFeeRecipient() external view returns (address);

    /// @notice Returns the address of the forfeited assets treasury.
    function getForfeitTreasury() external view returns (address);
}
"
    },
    "src/common/Constants.sol": {
      "content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;

/// @title Constants
/// @author luoyhang003
/// @notice Provides commonly used mathematical and configuration constants
/// @dev Designed to be inherited by other contracts that require fixed values
abstract contract Constants {
    /// @notice Scaling factor for 18-decimal precision (commonly used in ERC20 tokens)
    /// @dev Equal to 10^18
    uint256 internal constant D18 = 1e18;

    /// @notice Scaling factor for 6-decimal precision
    /// @dev Equal to 10^6
    uint256 internal constant D6 = 1e6;

    /// @notice Default number of decimals used for calculations
    /// @dev Typically corresponds to 18-decimal precision
    uint256 internal constant BASE_DECIMALS = 18;

    /// @notice Denominator used for fee calculations
    /// @dev Basis point system: denominator = 10,000 (e.g., 100 = 1%)
    uint256 internal constant FEE_DENOMINATOR = 1e4;

    /// @notice Denominator for basis points calculations (10000 = 100%)
    /// @dev Basis point system: denominator = 10,000 (e.g., 100 = 1%)
    uint256 internal constant BPS_DENOMINATOR = 1e4;

    /// @notice Initial exchange price for tokenized vault lp
    /// @dev Set to 1 * 10^18 (represents a price of 1.0 in 18 decimals)
    uint256 internal constant INIT_EXCHANGE_PRICE = 1e18;

    /// @notice The base reference price for a stablecoin, normalized to 18 decimals.
    /// @dev Set to 1 * 10^18 (represents a price of 1.0 in 18 decimals)
    uint256 internal constant STABLECOIN_BASE_PRICE = 1e18;
}
"
    },
    "src/libraries/Errors.sol": {
      "content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.26;

/// @title Errors Library
/// @author luoyhang003
/// @notice Centralized custom errors for all contracts in the protocol.
/// @dev Each error saves gas compared to revert strings. The @dev comment
///      also includes the corresponding 4-byte selector for debugging
///      and off-chain tooling.
library Errors {
    /*//////////////////////////////////////////////////////////////////////////
                                    GENERAL
    //////////////////////////////////////////////////////////////////////////*/

    /// @notice Thrown when array lengths do not match or are zero.
    /// @dev Selector: 0x9d89020a
    error InvalidArrayLength();

    /// @notice Thrown when a provided address is zero.
    /// @dev Selector: 0xd92e233d
    error ZeroAddress();

    /// @notice Thrown when a provided amount is zero.
    /// @dev Selector: 0x1f2a2005
    error ZeroAmount();

    /// @notice Thrown when an index is out of bounds.
    /// @dev Selector: 0x4e23d035
    error IndexOutOfBounds();

    /// @notice Thrown when a user is not whitelisted but tries to interact.
    /// @dev Selector: 0x2ba75b25
    error UserNotWhitelisted();

    /// @notice Thrown when a token has invalid decimals (e.g., >18).
    /// @dev Selector: 0xd25598a0
    error InvalidDecimals();

    /// @notice Thrown when an asset is not supported.
    /// @dev Selector: 0x24a01144
    error UnsupportedAsset();

    /// @notice Thrown when trying to add an already added asset.
    /// @dev Selector: 0x5ed26801
    error AssetAlreadyAdded();

    /// @notice Thrown when trying to remove an asset that was already removed.
    /// @dev Selector: 0x422afd8f
    error AssetAlreadyRemoved();

    /// @notice Thrown when a common token address conflict with the vault token address.
    /// @dev Selector: 0x8a7ea521
    error ConflictiveToken();

    /// @notice Thrown when an array is reach to the length limit.
    /// @dev Selector: 0x951becfa
    error ExceedArrayLengthLimit();

    /*//////////////////////////////////////////////////////////////////////////
                                    Token.sol
    //////////////////////////////////////////////////////////////////////////*/

    /// @notice Thrown when transfer is attempted by/for a blacklisted address.
    /// @dev Selector: 0x6554e8c5
    error TransferBlacklisted();

    /*//////////////////////////////////////////////////////////////////////////
                                    DepositVault.sol
    //////////////////////////////////////////////////////////////////////////*/

    /// @notice Thrown when deposits are paused.
    /// @dev Selector: 0x35edea30
    error DepositPaused();

    /// @notice Thrown when a deposit exceeds per-token deposit cap.
    /// @dev Selector: 0xcc60dc5b
    error ExceedTokenDepositCap();

    /// @notice Thrown when a deposit exceeds global deposit cap.
    /// @dev Selector: 0x5054f250
    error ExceedTotalDepositCap();

    /// @notice Thrown when minting results in zero shares.
    /// @dev Selector: 0x1d31001e
    error MintZeroShare();

    /// @notice Thrown when attempting to deposit zero assets.
    /// @dev Selector: 0xd69b89cc
    error DepositZeroAsset();

    /// @notice Thrown when the oracle for an asset is invalid or missing.
    /// @dev Selector: 0x9589a27d
    error InvalidOracle();

    /*//////////////////////////////////////////////////////////////////////////
                                WithdrawController.sol
    //////////////////////////////////////////////////////////////////////////*/

    /// @notice Thrown when withdrawals are paused.
    /// @dev Selector: 0xe0a39803
    error WithdrawPaused();

    /// @notice Thrown when attempting to request withdrawal of zero shares.
    /// @dev Selector: 0xef9c351b
    error RequestZeroShare();

    /// @notice Thrown when a withdrawal receipt has invalid status for the operation.
    /// @dev Selector: 0x3bb3ba88
    error InvalidReceiptStatus();

    /// @notice Thrown when a caller is not the original withdrawal requester.
    /// @dev Selector: 0xe39da59e
    error NotRequester();

    /// @notice Thrown when a caller is blacklisted.
    /// @dev Selector: 0x473250af
    error UserBlacklisted();

    /*//////////////////////////////////////////////////////////////////////////
                                  AssetsRouter.sol
    //////////////////////////////////////////////////////////////////////////*/

    /// @notice Thrown when a recipient is already added.
    /// @dev Selector: 0xce2c4eb3
    error RecipientAlreadyAdded();

    /// @notice Thrown when a recipient is already removed.
    /// @dev Selector: 0x1c7dcc84
    error RecipientAlreadyRemoved();

    /// @notice Thrown when attempting to set auto-route to its current state.
    /// @dev Selector: 0xdf2e473d
    error InvalidRouteEnabledStatus();

    /// @notice Thrown when a non-registered recipient is used.
    /// @dev Selector: 0xf29851db
    error NotRouterRecipient();

    /// @notice Thrown when attempting to remove the currently active recipient.
    /// @dev Selector: 0xa453bd1b
    error RemoveActiveRouter();

    /// @notice Thrown when attempting to manual route the asstes when auto route is enabled.
    /// @dev Selector: 0x92d56bf7
    error AutoRouteEnabled();

    /// @notice Thrown when setting the same router address.
    /// @dev Selector: 0x23b920b6
    error SameRouterAddress();

    /*//////////////////////////////////////////////////////////////////////////
                                  AccessRegistry.sol
    //////////////////////////////////////////////////////////////////////////*/

    /// @notice Thrown when trying to blacklist an already blacklisted user.
    /// @dev Selector: 0xf53de75f
    error AlreadyBlacklisted();

    /// @notice Thrown when trying to whitelist an already whitelisted user.
    /// @dev Selector: 0xb73e95e1
    error AlreadyWhitelisted();

    /// @notice Reverts when the requested state matches the current state.
    /// @dev Selector: 0x3fbc93f3
    error AlreadyInSameState();

    /*//////////////////////////////////////////////////////////////////////////
                                  OracleRegister.sol
    //////////////////////////////////////////////////////////////////////////*/

    /// @notice Thrown when an oracle is already registered for an asset.
    /// @dev Selector: 0x652a449e
    error OracleAlreadyAdded();

    /// @notice Thrown when an oracle does not exist for an asset.
    /// @dev Selector: 0x4dca4f7d
    error OracleNotExist();

    /// @notice Thrown when price deviation exceeds maximum allowed.
    /// @dev Selector: 0x8774ad87
    error ExceedMaxDeviation();

    /// @notice Thrown when price updates are attempted too frequently.
    /// @dev Selector: 0x8f46908a
    error PriceUpdateTooFrequent();

    /// @notice Thrown when a price validity period has expired.
    /// @dev Selector: 0x7c9d063a
    error PriceValidityExpired();

    /// @notice Thrown when a price is zero.
    /// @dev Selector: 0x10256287
    error InvalidZeroPrice();

    /*//////////////////////////////////////////////////////////////////////////
                                  ParamRegister.sol
    //////////////////////////////////////////////////////////////////////////*/

    /// @notice Thrown when tolerance basis points exceed maximum deviation.
    /// @dev Selector: 0xb8d855e2
    error ExceedMaxDeviationBps();

    /// @notice Thrown when price update interval is invalid.
    /// @dev Selector: 0xfff67f52
    error InvalidPriceUpdateInterval();

    /// @notice Thrown when price validity duration exceeds allowed maximum.
    /// @dev Selector: 0x6eca7e24
    error PriceMaxValidityExceeded();

    /// @notice Thrown when mint fee rate exceeds maximum allowed.
    /// @dev Selector: 0x8f59faf8
    error ExceedMaxMintFeeRate();

    /// @notice Thrown when redeem fee rate exceeds maximum allowed.
    /// @dev Selector: 0x86871089
    error ExceedMaxRedeemFeeRate();

    /*//////////////////////////////////////////////////////////////////////////
                              ChainlinkOracleFeed.sol
    //////////////////////////////////////////////////////////////////////////*/

    /// @notice Thrown when a reported price is invalid.
    /// @dev Selector: 0x00bfc921
    error InvalidPrice();

    /// @notice Thrown when a reported price is stale.
    /// @dev Selector: 0x19abf40e
    error StalePrice();

    /// @notice Thrown when a Chainlink round is incomplete.
    /// @dev Selector: 0x8ad52bdd
    error IncompleteRound();
}
"
    },
    "lib/openzeppelin-contracts/contracts/access/IAccessControl.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (access/IAccessControl.sol)

pragma solidity >=0.8.4;

/**
 * @dev External interface of AccessControl declared to support ERC-165 detection.
 */
interface IAccessControl {
    /**
     * @dev The `account` is missing a role.
     */
    error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);

    /**
     * @dev The caller of a function is not the expected one.
     *
     * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
     */
    error AccessControlBadConfirmation();

    /**
     * @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 to signal this.
     */
    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. This account bears the admin role (for the granted role).
     * Expected in cases where the role was granted using the internal {AccessControl-_grantRole}.
     */
    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 `callerConfirmation`.
     */
    function renounceRole(bytes32 role, address callerConfirmation) external;
}
"
    },
    "lib/openzeppelin-contracts/contracts/utils/Context.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

/**
 * @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;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}
"
    },
    "lib/openzeppelin-contracts/contracts/utils/introspection/ERC165.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/ERC165.sol)

pragma solidity ^0.8.20;

import {IERC165} from "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC-165 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);
 * }
 * ```
 */
abstract contract ERC165 is IERC165 {
    /// @inheritdoc IERC165
    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}
"
    },
    "lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/IERC165.sol)

pragma solidity >=0.4.16;

/**
 * @dev Interface of the ERC-165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[ERC].
 *
 * 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[ERC 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);
}
"
    }
  },
  "settings": {
    "remappings": [
      "@uniswap/v3-periphery/contracts/=lib/v3-periphery/contracts/",
      "@chainlink/contracts/src/v0.8/=lib/chainlink-evm/contracts/src/v0.8/shared/",
      "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
      "chainlink-evm/=lib/chainlink-evm/",
      "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
      "forge-std/=lib/forge-std/src/",
      "halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
      "openzeppelin-contracts/=lib/openzeppelin-contracts/",
      "v3-periphery/=lib/v3-periphery/contracts/"
    ],
    "optimizer": {
      "enabled": false,
      "runs": 200
    },
    "metadata": {
      "useLiteralContent": false,
      "bytecodeHash": "ipfs",
      "appendCBOR": true
    },
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    },
    "evmVersion": "cancun",
    "viaIR": false
  }
}}

Tags:
ERC165, DeFi, Swap, Factory, Oracle|addr:0xa77cf3a4c2e97830c9e025a43d2eb1e8a9fd9196|verified:true|block:23628641|tx:0xa0851ad1c12bbb4865bcaafd48fca337f07da19346581e80550e6eba0f09a43d|first_check:1761230364

Submitted on: 2025-10-23 16:39:27

Comments

Log in to comment.

No comments yet.