Skip to content
Verified contractPartialMIT

SeriesParameters

Address0x11fb5efb95d04cfdccb2c2b6d45474eef48481cb
Balance

0 ETH

 

Transactions

6

 

Compiler

solc 0.8.26

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.26+commit.8a97fa7a
Language
solidity
Optimization
Yes, 200 runs
EVM version
cancun
License
MIT
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,323,040
Creation transaction
0xab7b2d2f3e…52a3283f5d

src/SeriesParameters.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

/// @title SeriesParameters — the tariffs and the gate of every series, in one place, set by governance
/// @notice What used to be a configuration file and an operator's input is on chain here: the entry fee, the
///         exit and switch fee by the age of the units, the management and performance fee rates that
///         accrue inside NAV, and the redemption gate (a share of NAV per window of days, and how long a
///         request may wait). The escrow reads the entry fee, the queue reads the exit and switch fees and
///         the gate, the Calculation Agent reads the NAV fee rates: none of them takes a rate from anyone's
///         hand. Only governance changes a value, through the timelock, within the bounds below; the
///         deployer may fill a series' terms once, at deployment, before governance exists.
/// @notice A change of a tariff reaches only what comes after it (owner, 04.10.2026; review of 03.10.2026,
///         B-01, B-02). Every exit and switch schedule a series has had is kept under a version number; a
///         redemption request carries the versions in force when it was placed and is charged the lower of
///         that schedule and the one in force when it settles. The entry fee is recorded with each deposit by
///         the escrow on the same rule.
/// @dev What the parameters tell the fee ledger before a NAV rate changes.
interface IFeeCheckpoint {
    function checkpoint(address token, bool performance) external;
}

contract SeriesParameters {
    /// @notice One band of a fee-by-age schedule: `bps` for units younger than `untilDays`. The last band
    ///         carries `type(uint32).max` and applies for ever.
    struct Band {
        uint32 untilDays;
        uint16 bps;
    }

    /// @notice The redemption gate: at most `bps` of NAV settled in any `windowDays`; zero bps, no gate.
    ///         `maxWaitDays` is the rule for the operations Safe (a request older than that is overdue),
    ///         read off chain.
    struct Gate {
        uint16 bps;
        uint16 windowDays;
        uint16 maxWaitDays;
    }

    /// @notice A series' terms as a reader gets them: the schedules are the ones in force now.
    struct Terms {
        bool set;
        uint16 entryBps;
        uint16 managementBps;
        uint16 performanceBps;
        Gate gate;
        Band[] exit;
        Band[] switching;
        uint128 minRedeemUnits;
    }

    /// @dev What is stored per series beside the schedules.
    struct Core {
        bool set;
        uint16 entryBps;
        uint16 managementBps;
        uint16 performanceBps;
        Gate gate;
        /// @dev The least a redemption request may ask for, unless it is the holder's whole balance: below it
        ///      the fees of a request round to nothing (review of 03.10.2026, B-16).
        uint128 minRedeemUnits;
    }

    /// @notice Governance (the Governance Safe behind the timelock).
    address public immutable governance;
    /// @notice May fill a series' terms once, while they are unset: the deployer, at deployment.
    address public immutable initializer;
    /// @notice Until when the deployer may fill a series' terms: a day, like its right on the queue and the anchor (F-04).
    uint64 public immutable initializerUntil;

    /// @notice The fee ledger, told before a NAV rate changes so what accrued does so at the old rate (review
    ///         of 28.09.2026, M-16). Set once: by the deployer at deployment, else by governance.
    address public feeLedger;

    /// @notice Bounds no change can cross.
    uint16 public constant MAX_FEE_BPS = 500;
    /// @dev The longest gate window: what the queue keeps of its payout history, so a widened window still counts it.
    uint16 public constant MAX_GATE_WINDOW_DAYS = 92;
    uint16 public constant MAX_MANAGEMENT_BPS = 300;
    uint16 public constant MAX_PERFORMANCE_BPS = 3000;
    uint256 public constant MAX_BANDS = 8;

    mapping(address => Core) private _terms;
    /// @dev Every exit and switch schedule a series has had, in order: the index is the version.
    mapping(address => Band[][]) private _exit;
    mapping(address => Band[][]) private _switching;

    event EntryFeeSet(address indexed token, uint16 bps);
    event FeeLedgerSet(address ledger);
    event ExitScheduleSet(address indexed token, Band[] bands);
    event SwitchScheduleSet(address indexed token, Band[] bands);
    event NavFeesSet(address indexed token, uint16 managementBps, uint16 performanceBps);
    event GateSet(address indexed token, uint16 bps, uint16 windowDays, uint16 maxWaitDays);
    event MinRedeemSet(address indexed token, uint128 units);

    error NotGovernance();
    error NotInitializer();
    error LedgerSet();
    error AlreadySet(address token);
    error ZeroAddress();
    error FeeTooHigh(uint16 bps);
    error ManagementTooHigh(uint16 bps);
    error PerformanceTooHigh(uint16 bps);
    error GateInvalid();
    error ScheduleInvalid();
    error TermsNotSet(address token);

    modifier onlyGovernance() {
        if (msg.sender != governance) revert NotGovernance();
        _;
    }

    /// @dev A setter changes terms that exist: a series' terms are filed whole, by `initialise`, and a single
    ///      setter never marks them as filed with the rest empty (review of 03.10.2026, B-14).
    modifier whenSet(address token) {
        if (!_terms[token].set) revert TermsNotSet(token);
        _;
    }

    constructor(address governance_, address initializer_) {
        if (governance_ == address(0) || initializer_ == address(0)) revert ZeroAddress();
        governance = governance_;
        initializer = initializer_;
        initializerUntil = uint64(block.timestamp + 1 days);
    }

    // ── Deployment: once per series ─────────────────────────────────────────────────────────

    /// @notice Fill a series' terms while they are unset. The deployer at deployment, or governance.
    function initialise(
        address token,
        uint16 entryBps,
        Band[] calldata exit,
        Band[] calldata switching,
        uint16 managementBps,
        uint16 performanceBps,
        Gate calldata gate
    ) external {
        if (msg.sender != governance && !(msg.sender == initializer && block.timestamp <= initializerUntil)) revert NotInitializer();
        if (token == address(0)) revert ZeroAddress();
        if (_terms[token].set) revert AlreadySet(token);
        _terms[token].set = true;
        _setEntry(token, entryBps);
        _setSchedule(token, exit, true);
        _setSchedule(token, switching, false);
        _setNavFees(token, managementBps, performanceBps);
        _setGate(token, gate);
    }

    // ── Governance (through the timelock) ───────────────────────────────────────────────────

    function setEntryFee(address token, uint16 bps) external onlyGovernance whenSet(token) {
        _setEntry(token, bps);
    }

    function setExitSchedule(address token, Band[] calldata bands) external onlyGovernance whenSet(token) {
        _setSchedule(token, bands, true);
    }

    function setSwitchSchedule(address token, Band[] calldata bands) external onlyGovernance whenSet(token) {
        _setSchedule(token, bands, false);
    }

    function setNavFees(address token, uint16 managementBps, uint16 performanceBps)
        external
        onlyGovernance
        whenSet(token)
    {
        // what has accrued so far is settled at the rates that were in force; the new ones apply from here
        if (feeLedger != address(0)) {
            // performance is settled at the old rate only when that rate changes: a management change alone
            // moves no mark (review of 28.09.2026, I-01)
            IFeeCheckpoint(feeLedger).checkpoint(token, _terms[token].performanceBps != performanceBps);
        }
        _setNavFees(token, managementBps, performanceBps);
    }

    /// @notice The least a redemption request may ask for (a holder may always ask for all he has). Governance,
    ///         or the deployer within its day while it is unset.
    function setMinRedeem(address token, uint128 units) external whenSet(token) {
        if (msg.sender != governance) {
            bool deployerInWindow = msg.sender == initializer && block.timestamp <= initializerUntil;
            if (!deployerInWindow || _terms[token].minRedeemUnits != 0) revert NotGovernance();
        }
        _terms[token].minRedeemUnits = units;
        emit MinRedeemSet(token, units);
    }

    /// @notice Name the fee ledger, once. The deployer at deployment, else governance.
    function setFeeLedger(address ledger) external {
        if (msg.sender != governance && !(msg.sender == initializer && block.timestamp <= initializerUntil)) {
            revert NotInitializer();
        }
        if (ledger == address(0)) revert ZeroAddress();
        if (feeLedger != address(0)) revert LedgerSet();
        feeLedger = ledger;
        emit FeeLedgerSet(ledger);
    }

    function setGate(address token, Gate calldata gate) external onlyGovernance whenSet(token) {
        _setGate(token, gate);
    }

    // ── Views the contracts read ────────────────────────────────────────────────────────────

    function isSet(address token) external view returns (bool) {
        return _terms[token].set;
    }

    function entryBpsOf(address token) external view returns (uint16) {
        return _terms[token].entryBps;
    }

    /// @notice The exit fee for units `ageDays` old under the schedule in force now. Nothing set, nothing charged.
    function exitBpsFor(address token, uint256 ageDays) external view returns (uint16) {
        return _bpsFor(_latest(_exit[token]), ageDays);
    }

    /// @notice The switch fee for units `ageDays` old under the schedule in force now.
    function switchBpsFor(address token, uint256 ageDays) external view returns (uint16) {
        return _bpsFor(_latest(_switching[token]), ageDays);
    }

    /// @notice The exit and the switch fee a request placed under versions `exitVersion` and `switchVersion`
    ///         pays for units `ageDays` old: for each, the lower of that schedule and the one in force now.
    function feesFor(address token, uint256 ageDays, uint32 exitVersion, uint32 switchVersion)
        external
        view
        returns (uint16 exitBps, uint16 switchBps)
    {
        exitBps = _lower(_exit[token], exitVersion, ageDays);
        switchBps = _lower(_switching[token], switchVersion, ageDays);
    }

    /// @notice The versions of the exit and switch schedules in force now.
    function versionsOf(address token) external view returns (uint32 exitVersion, uint32 switchVersion) {
        uint256 e = _exit[token].length;
        uint256 w = _switching[token].length;
        return (e == 0 ? 0 : uint32(e - 1), w == 0 ? 0 : uint32(w - 1));
    }

    function minRedeemOf(address token) external view returns (uint128) {
        return _terms[token].minRedeemUnits;
    }

    function navFeesOf(address token) external view returns (uint16 managementBps, uint16 performanceBps) {
        Core storage t = _terms[token];
        return (t.managementBps, t.performanceBps);
    }

    function gateOf(address token) external view returns (Gate memory) {
        return _terms[token].gate;
    }

    function exitScheduleOf(address token) external view returns (Band[] memory) {
        return _latest(_exit[token]);
    }

    function switchScheduleOf(address token) external view returns (Band[] memory) {
        return _latest(_switching[token]);
    }

    /// @notice Everything at once, for the console and the Calculation Agent.
    function termsOf(address token) external view returns (Terms memory) {
        Core storage t = _terms[token];
        return Terms({
            set: t.set,
            entryBps: t.entryBps,
            managementBps: t.managementBps,
            performanceBps: t.performanceBps,
            gate: t.gate,
            exit: _latest(_exit[token]),
            switching: _latest(_switching[token]),
            minRedeemUnits: t.minRedeemUnits
        });
    }

    // ── Internals ───────────────────────────────────────────────────────────────────────────

    function _bpsFor(Band[] memory bands, uint256 ageDays) private pure returns (uint16) {
        for (uint256 i = 0; i < bands.length; i++) {
            if (ageDays < bands[i].untilDays) return bands[i].bps;
        }
        return 0;
    }

    /// @dev The schedule in force now: the last version, or none.
    function _latest(Band[][] storage versions) private view returns (Band[] memory) {
        uint256 n = versions.length;
        if (n == 0) return new Band[](0);
        return versions[n - 1];
    }

    /// @dev The lower of the rate under `version` and the rate in force now. A version the series never had
    ///      is read as the current one.
    function _lower(Band[][] storage versions, uint32 version, uint256 ageDays) private view returns (uint16 bps) {
        uint256 n = versions.length;
        if (n == 0) return 0;
        bps = _bpsFor(versions[n - 1], ageDays);
        if (version < n - 1) {
            uint16 then = _bpsFor(versions[version], ageDays);
            if (then < bps) bps = then;
        }
    }

    function _setEntry(address token, uint16 bps) private {
        if (bps > MAX_FEE_BPS) revert FeeTooHigh(bps);
        _terms[token].entryBps = bps;
        emit EntryFeeSet(token, bps);
    }

    /// @dev A schedule is 1 to MAX_BANDS bands, each within the cap, strictly ascending in `untilDays`, the
    ///      last one open-ended — so every age finds exactly one band.
    function _setSchedule(address token, Band[] calldata bands, bool isExit) private {
        if (bands.length == 0 || bands.length > MAX_BANDS) revert ScheduleInvalid();
        if (bands[bands.length - 1].untilDays != type(uint32).max) revert ScheduleInvalid();
        Band[][] storage versions = isExit ? _exit[token] : _switching[token];
        Band[] storage dst = versions.push();
        uint32 last = 0;
        for (uint256 i = 0; i < bands.length; i++) {
            if (bands[i].bps > MAX_FEE_BPS) revert FeeTooHigh(bands[i].bps);
            if (i != 0 && bands[i].untilDays <= last) revert ScheduleInvalid();
            last = bands[i].untilDays;
            dst.push(bands[i]);
        }
        if (isExit) emit ExitScheduleSet(token, bands);
        else emit SwitchScheduleSet(token, bands);
    }

    function _setNavFees(address token, uint16 managementBps, uint16 performanceBps) private {
        if (managementBps > MAX_MANAGEMENT_BPS) revert ManagementTooHigh(managementBps);
        if (performanceBps > MAX_PERFORMANCE_BPS) revert PerformanceTooHigh(performanceBps);
        _terms[token].managementBps = managementBps;
        _terms[token].performanceBps = performanceBps;
        emit NavFeesSet(token, managementBps, performanceBps);
    }

    function _setGate(address token, Gate calldata gate) private {
        if (gate.bps > 10_000 || (gate.bps != 0 && gate.windowDays == 0)) revert GateInvalid();
        if (gate.windowDays > MAX_GATE_WINDOW_DAYS) revert GateInvalid();
        _terms[token].gate = gate;
        emit GateSet(token, gate.bps, gate.windowDays, gate.maxWaitDays);
    }
}
Compiler settingsShow
{
  "viaIR": false,
  "metadata": {
    "appendCBOR": false,
    "bytecodeHash": "none",
    "useLiteralContent": false
  },
  "libraries": {},
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "cancun",
  "remappings": [
    "@openzeppelin/=lib/openzeppelin-contracts/",
    "forge-std/=lib/forge-std/src/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.