Skip to content
Verified contractPartialBUSL-1.1

PTParameterRegistry

Address0x77f5bb4195a04508b75ab944075f030263610263
Balance

0 ETH

 

Transactions

2

 

Compiler

solc 0.8.27

 

Same code

1 more contract

 

Details

Compiler
solc 0.8.27+commit.40a35a09
Language
solidity
Optimization
Yes, 10,000 runs
EVM version
shanghai
License
BUSL-1.1
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
25,723,147
Creation transaction
0x42240c46e1…b9d2698e41

src/PTParameterRegistry.sol

// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.27;

import { Ownable, Ownable2Step } from "@openzeppelin/contracts/access/Ownable2Step.sol";

/// @title PTParameterRegistry
/// @notice Per-market tuning knobs consumed by the three PT CRE workflows (EMA, discount-rate, risk-params).
/// @dev Schema follows `docs/architecture.md` §6 (`PtMarketParams`). Hardcoded `LB_floor` / `LT_cap`
///      tables are intentionally NOT stored here — those live in CRE `pendle_common` per
///      `docs/spec-risk-parameters.md`. Access control mirrors `contracts/lib/llamaguard-contracts`
///      `ParameterRegistry`: `Ownable2Step` owner plus a separate `updater` role for day-to-day setters.
contract PTParameterRegistry is Ownable2Step {
    /// @notice Cap on any basis-point input (100% = 10_000 bps).
    uint64 public constant MAX_BPS = 10_000;
    /// @notice Fixed-point scale for the risk-params reference-proportion multiplier K.
    uint64 public constant K_FACTOR_SCALE = 10_000;

    struct PtMarketParams {
        // shared
        bool enabled;
        uint32 modelVersion;
        // EMA slice
        uint32 emaSpan;
        uint64 emaFreshnessSeconds;
        // Discount-rate slice
        uint64 thresholdBps; // deviation threshold for update gating (0.30% = 30 bps)
        // Risk-params slice
        uint64 kReferenceEndpoint; // K parameter for p_star calculation (scaled by K_FACTOR_SCALE)
        uint16[] emodeCategoryIds; // eMode categories this PT is listed in
    }

    address public updater;
    mapping(address market => PtMarketParams) private _ptParams;
    mapping(address market => bool) private _exists;

    event UpdaterChanged(address indexed previousUpdater, address indexed newUpdater);
    event PtMarketParamsSet(address indexed market, PtMarketParams params);
    event EnabledSet(address indexed market, bool enabled);
    event ModelVersionSet(address indexed market, uint32 modelVersion);
    event EmaSpanSet(address indexed market, uint32 emaSpan);
    event EmaFreshnessSecondsSet(address indexed market, uint64 emaFreshnessSeconds);
    event DeviationThresholdBpsSet(address indexed market, uint64 thresholdBps);
    event KReferenceEndpointSet(address indexed market, uint64 kReferenceEndpoint);
    event EmodeCategoryIdsSet(address indexed market, uint16[] emodeCategoryIds);
    event MarketDeleted(address indexed market);

    error OnlyUpdater();
    error MarketNotFound();
    error ZeroAddress();
    error InvalidEmaSpan();
    error InvalidEmaFreshness();
    error InvalidKReferenceEndpoint();
    error BpsTooHigh(uint64 value);
    error EmptyEmodeCategoryIds();

    modifier onlyUpdater() {
        if (msg.sender != updater) revert OnlyUpdater();
        _;
    }

    constructor(address _owner, address _updater) Ownable(_owner) {
        if (_updater == address(0)) revert ZeroAddress();
        updater = _updater;
        emit UpdaterChanged(address(0), _updater);
    }

    // ============================================================================================
    // Owner functions
    // ============================================================================================

    function setUpdater(address _updater) external onlyOwner {
        if (_updater == address(0)) revert ZeroAddress();
        address previous = updater;
        updater = _updater;
        emit UpdaterChanged(previous, _updater);
    }

    // ============================================================================================
    // Updater functions
    // ============================================================================================

    function setPtMarketParams(address market, PtMarketParams calldata p) external onlyUpdater {
        if (market == address(0)) revert ZeroAddress();
        _validateParams(p);

        _ptParams[market] = p;
        _exists[market] = true;

        emit PtMarketParamsSet(market, p);
    }

    function setEnabled(address market, bool enabled_) external onlyUpdater {
        if (!_exists[market]) revert MarketNotFound();
        _ptParams[market].enabled = enabled_;
        emit EnabledSet(market, enabled_);
    }

    function setModelVersion(address market, uint32 modelVersion) external onlyUpdater {
        if (!_exists[market]) revert MarketNotFound();
        _ptParams[market].modelVersion = modelVersion;
        emit ModelVersionSet(market, modelVersion);
    }

    function setEmaSpan(address market, uint32 emaSpan) external onlyUpdater {
        if (!_exists[market]) revert MarketNotFound();
        if (emaSpan == 0) revert InvalidEmaSpan();
        _ptParams[market].emaSpan = emaSpan;
        emit EmaSpanSet(market, emaSpan);
    }

    function setEmaFreshnessSeconds(address market, uint64 emaFreshnessSeconds) external onlyUpdater {
        if (!_exists[market]) revert MarketNotFound();
        if (emaFreshnessSeconds == 0) revert InvalidEmaFreshness();
        _ptParams[market].emaFreshnessSeconds = emaFreshnessSeconds;
        emit EmaFreshnessSecondsSet(market, emaFreshnessSeconds);
    }

    /// @notice Set the deviation threshold for discount-rate update gating.
    /// @param market PT market address
    /// @param thresholdBps Deviation threshold in basis points (e.g., 30 = 0.30%)
    function setDeviationThresholdBps(address market, uint64 thresholdBps) external onlyUpdater {
        if (!_exists[market]) revert MarketNotFound();
        if (thresholdBps > MAX_BPS) revert BpsTooHigh(thresholdBps);
        _ptParams[market].thresholdBps = thresholdBps;
        emit DeviationThresholdBpsSet(market, thresholdBps);
    }

    /// @notice Set the K reference endpoint for risk-params p_star calculation.
    /// @param market PT market address
    /// @param kReferenceEndpoint K parameter scaled by K_FACTOR_SCALE (10000)
    function setKReferenceEndpoint(address market, uint64 kReferenceEndpoint) external onlyUpdater {
        if (!_exists[market]) revert MarketNotFound();
        if (kReferenceEndpoint == 0) revert InvalidKReferenceEndpoint();
        _ptParams[market].kReferenceEndpoint = kReferenceEndpoint;
        emit KReferenceEndpointSet(market, kReferenceEndpoint);
    }

    function setEmodeCategoryIds(address market, uint16[] calldata ids) external onlyUpdater {
        if (!_exists[market]) revert MarketNotFound();
        if (ids.length == 0) revert EmptyEmodeCategoryIds();
        _ptParams[market].emodeCategoryIds = ids;
        emit EmodeCategoryIdsSet(market, ids);
    }

    function deleteMarket(address market) external onlyUpdater {
        if (!_exists[market]) revert MarketNotFound();
        delete _ptParams[market];
        _exists[market] = false;
        emit MarketDeleted(market);
    }

    // ============================================================================================
    // Views
    // ============================================================================================

    function getPtMarketParams(address market) external view returns (PtMarketParams memory) {
        if (!_exists[market]) revert MarketNotFound();
        return _ptParams[market];
    }

    function marketExists(address market) external view returns (bool) {
        return _exists[market];
    }

    function getEmodeCategoryIds(address market) external view returns (uint16[] memory) {
        if (!_exists[market]) revert MarketNotFound();
        return _ptParams[market].emodeCategoryIds;
    }

    // ============================================================================================
    // Internal
    // ============================================================================================

    function _validateParams(PtMarketParams calldata p) internal pure {
        _validateTiming(p);
        _validateBps(p);
        if (p.emodeCategoryIds.length == 0) revert EmptyEmodeCategoryIds();
    }

    function _validateTiming(PtMarketParams calldata p) internal pure {
        if (p.emaSpan == 0) revert InvalidEmaSpan();
        if (p.emaFreshnessSeconds == 0) revert InvalidEmaFreshness();
        if (p.kReferenceEndpoint == 0) revert InvalidKReferenceEndpoint();
    }

    function _validateBps(PtMarketParams calldata p) internal pure {
        if (p.thresholdBps > MAX_BPS) revert BpsTooHigh(p.thresholdBps);
    }
}

node_modules/@openzeppelin/contracts/access/Ownable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {Context} from "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * The initial owner is set to the address provided by the deployer. This can
 * later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

node_modules/@openzeppelin/contracts/access/Ownable2Step.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (access/Ownable2Step.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Contract module which provides access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * This extension of the {Ownable} contract includes a two-step mechanism to transfer
 * ownership, where the new owner must call {acceptOwnership} in order to replace the
 * old one. This can help prevent common mistakes, such as transfers of ownership to
 * incorrect accounts, or to contracts that are unable to interact with the
 * permission system.
 *
 * The initial owner is specified at deployment time in the constructor for `Ownable`. This
 * can later be changed with {transferOwnership} and {acceptOwnership}.
 *
 * This module is used through inheritance. It will make available all functions
 * from parent (Ownable).
 */
abstract contract Ownable2Step is Ownable {
    address private _pendingOwner;

    event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Returns the address of the pending owner.
     */
    function pendingOwner() public view virtual returns (address) {
        return _pendingOwner;
    }

    /**
     * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
     * Can only be called by the current owner.
     *
     * Setting `newOwner` to the zero address is allowed; this can be used to cancel an initiated ownership transfer.
     */
    function transferOwnership(address newOwner) public virtual override onlyOwner {
        _pendingOwner = newOwner;
        emit OwnershipTransferStarted(owner(), newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual override {
        delete _pendingOwner;
        super._transferOwnership(newOwner);
    }

    /**
     * @dev The new owner accepts the ownership transfer.
     */
    function acceptOwnership() public virtual {
        address sender = _msgSender();
        if (pendingOwner() != sender) {
            revert OwnableUnauthorizedAccount(sender);
        }
        _transferOwnership(sender);
    }
}

node_modules/@openzeppelin/contracts/utils/Context.sol

// 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;
    }
}
Compiler settingsShow
{
  "viaIR": false,
  "metadata": {
    "appendCBOR": true,
    "bytecodeHash": "none",
    "useLiteralContent": false
  },
  "optimizer": {
    "runs": 10000,
    "enabled": true
  },
  "evmVersion": "shanghai",
  "remappings": [
    "@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/",
    "llamaguard-contracts/=lib/llamaguard-contracts/",
    "@chainlink/contracts/=node_modules/@chainlink/contracts/",
    "forge-std/=node_modules/forge-std/src/",
    "chaos-agents/=node_modules/chaos-agents/",
    "aave-risk-agents/=node_modules/aave-risk-agents/",
    "aave-price-feeds/=node_modules/aave-price-feeds/src/",
    "aave-v3-risk-stewards/=node_modules/aave-v3-risk-stewards/src/",
    "openzeppelin-contracts/contracts/=node_modules/@openzeppelin/contracts/",
    "aave-address-book/=node_modules/@aave-dao/aave-address-book/src/",
    "aave-v3-origin/src/=node_modules/@aave-dao/aave-v3-origin/src/",
    "aave-v3-origin/contracts/=node_modules/@aave-dao/aave-v3-origin/src/contracts/",
    "solidity-utils/=node_modules/@bgd-labs/solidity-utils/src/",
    "openzeppelin-contracts-upgradeable/contracts/=node_modules/@openzeppelin/contracts-upgradeable/",
    "@openzeppelin/contracts-upgradeable/=node_modules/@openzeppelin/contracts-upgradeable/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.