Skip to content
Verified contractExactUNLICENSED

FLAMMPolicyLib

Address0x3858e2202cebcb6f12f36a596260dd2ed8f91f06
Balance

0 ETH

 

Transactions

0

 

Compiler

solc 0.8.35

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.35+commit.47b9dedd
Language
solidity
Optimization
Yes, 100 runs
EVM version
cancun
Via IR
yes
License
UNLICENSED
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,480,489
Creation transaction
0x6d6ec41516…849129f9af
Libraries
src/core/mm/MMRouterLib.sol:MMRouterLib0x95b3…48ef2csrc/core/flamm/FLAMMLane.sol:FLAMMLane0x5d81…90de37src/core/flamm/FLAMMRoute.sol:FLAMMRoute0xb1ff…7fb0fesrc/periphery/FLAMMMaxima.sol:FLAMMMaxima0x6854…90a91bsrc/core/flamm/FLAMMLawLib.sol:FLAMMLawLib0xf55c…49cf45src/core/flamm/FLAMMOpsLib.sol:FLAMMOpsLib0x0be7…5ecc47src/core/mm/AaveV3ReadsLib.sol:AaveV3ReadsLib0xa5db…72803esrc/core/flamm/FLAMMFlowLib.sol:FLAMMFlowLib0x2795…4cfb77src/core/flamm/FLAMMGateLib.sol:FLAMMGateLib0x3a05…434368src/core/flamm/FLAMMKeptLib.sol:FLAMMKeptLib0x70ca…60bee4src/core/mm/CTokenMarketLib.sol:CTokenMarketLib0x60e4…314010src/core/flamm/FLAMMAdmitLib.sol:FLAMMAdmitLib0x0b10…1ce950src/core/flamm/FLAMMBlindLib.sol:FLAMMBlindLib0x634d…298fcdsrc/core/flamm/FLAMMClaimLib.sol:FLAMMClaimLib0x5dc3…aa7e91src/core/flamm/FLAMMFenceLib.sol:FLAMMFenceLib0x9dbb…798f1asrc/core/flamm/FLAMMFloatLib.sol:FLAMMFloatLib0x6b2b…518935src/core/flamm/FLAMMQuoteLib.sol:FLAMMQuoteLib0x99de…929869src/core/flamm/FLAMMTopUpLib.sol:FLAMMTopUpLib0xe4be…cfac2esrc/core/mm/CTokenRewardsLib.sol:CTokenRewardsLib0x93ab…262861src/core/mm/MMRouterAdminLib.sol:MMRouterAdminLib0x6abb…60ea7esrc/core/flamm/FLAMMPolicyLib.sol:FLAMMPolicyLib0x3858…f91f06src/core/flamm/FLAMMSettleLib.sol:FLAMMSettleLib0x4551…33b301src/core/flamm/FLAMMSharedLib.sol:FLAMMSharedLib0xb852…b71005src/periphery/FLAMMExitMaxima.sol:FLAMMExitMaxima0x6a6a…798659src/hooks/everlong/LeverageLib.sol:LeverageLib0x8039…16d055src/core/flamm/FLAMMMaintainLib.sol:FLAMMMaintainLib0xaa54…b56417src/core/flamm/FLAMMPairQuoteLib.sol:FLAMMPairQuoteLib0x3bc5…2055ddsrc/hooks/everlong/EverlongOpsLib.sol:EverlongOpsLib0xf6d5…9dfeef

52 files

The source code is large: one file is shown at a time. Choose a file in the list.

src/core/flamm/FLAMMPolicyLib.sol

// SPDX-License-Identifier: UNLICENSED
// Copyright (c) 2025-2026 Everlong Labs Limited
pragma solidity ^0.8.26;

import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";

import {
    FLAMMStore, NotCurator, InvalidConfig, GuardianMayOnlyTighten, DialsSet, FeeBoundsSet, FeaturesSet,
    TokenConfigSet, MinSupplyBatchSet, CeilingBreached, CeilingsSet, CeilingsScheduled, HookSetNotReady,
    VenueReportsLoss, CollateralReserveSet, NotScheduled, TradePairsSet, TradePairsScheduled, TradePairsCancelled,
    WAD
} from "src/core/flamm/FLAMMStore.sol";
import {FLAMMAdmitLib} from "src/core/flamm/FLAMMAdmitLib.sol";
import {FLAMMGateLib} from "src/core/flamm/FLAMMGateLib.sol";
import {FLAMMTopUpLib} from "src/core/flamm/FLAMMTopUpLib.sol";
import {FLAMMQuoteLib} from "src/core/flamm/FLAMMQuoteLib.sol";
import {FLAMMLane} from "src/core/flamm/FLAMMLane.sol";
import {FLAMMOpsLib} from "src/core/flamm/FLAMMOpsLib.sol";
import {FLAMMKeptLib} from "src/core/flamm/FLAMMKeptLib.sol";
import {IMMRouter, VENUE_RETIRED} from "src/interfaces/core/mm/IMMRouter.sol";
import {IFinancingAccount, CAP_ACCRUING_COLLATERAL} from "src/interfaces/core/mm/IFinancingAccount.sol";
import {ReentrancyGuardLib} from "src/libraries/ReentrancyGuardLib.sol";

/// @notice The pool's policy setters, the operator's and the guardian's: the features, each token's swap policy, its
///         supply batch and its supply cap, the fee bounds, each pair's caps, its venue-oracle band and its dials, the
///         drawn-token limit, each venue's switches and caps, the committed ceilings, the trade masks and the
///         collateral reserve rules. The pool's dispatch table (`FLAMM.route`) hands each entry here under the
///         pool's own selector, so each takes the pool's storage from its own namespace, checks its own caller and
///         holds the pool's lock. None of it runs on a swap, an entry or an exit.
library FLAMMPolicyLib {
    // The pool's own cap and switch setters, which key a cheap-lane pool's delayed loosening in the pending table
    // (`FLAMMLane.capDue`), and the fee floors' setters, which key any other pool's delayed cut of a floor there
    // (`FLAMMLane.scheduledCut`): the pool's floor by `SET_FEE_BOUNDS` alone, a token's by `SET_TOKEN_CONFIG` and the
    // token.
    bytes4 internal constant SET_TOKEN_CONFIG =
        bytes4(keccak256("setTokenConfig(uint8,uint64,uint64,uint256,uint256)"));
    bytes4 internal constant SET_FEE_BOUNDS = bytes4(keccak256("setFeeBounds(uint64,uint64)"));
    bytes4 internal constant SET_TOKEN_SUPPLY_CAP = bytes4(keccak256("setTokenSupplyCap(uint8,uint128)"));
    bytes4 internal constant SET_PAIR_CAPS = bytes4(keccak256("setPairCaps(uint8,uint128,bool)"));
    bytes4 internal constant SET_VENUE_CAPS = bytes4(keccak256("setVenueCaps(uint16,uint128,uint128,uint64)"));
    bytes4 internal constant SET_VENUE_FLAGS = bytes4(keccak256("setVenueFlags(uint16,bool,bool)"));
    bytes4 internal constant SET_ORACLE_BAND = bytes4(keccak256("setOracleBand(uint8,uint64)"));
    bytes4 internal constant SET_MAX_DRAWN_TOKENS = bytes4(keccak256("setMaxDrawnTokens(uint8)"));
    bytes4 internal constant SET_MIN_SUPPLY_BATCH = bytes4(keccak256("setMinSupplyBatch(uint8,uint128)"));
    bytes4 internal constant SET_FEATURES = bytes4(keccak256("setFeatures(uint256)"));

    /// @dev The gate every cap and switch setter shares: the guardian may only tighten (`GuardianMayOnlyTighten`); on
    ///      a pool whose cheap lane is on a tightening drops the same setting's scheduled loosening, and the curator's
    ///      loosening waits the pool's delay (`FLAMMLane.capDue`). True while `call` is scheduled, not applied.
    function _waits(FLAMMStore.S storage $, bool guardian, bool tight, bytes memory call) private returns (bool) {
        if (guardian && !tight) revert GuardianMayOnlyTighten();
        return FLAMMLane.capDue($, tight, call) != 0;
    }

    // ------------------------------------------------------------------ the entries' callers and the lock
    // Each entry checks its own caller and holds the pool's lock, in the order its modifiers stand.

    /// @dev The curator (`NotCurator`).
    modifier onlyCurator() {
        FLAMMStore.requireCurator(FLAMMStore.s());
        _;
    }

    /// @dev The curator or the pool's guardian (`NotGuardianOrCurator`).
    modifier curatorOrGuardian() {
        FLAMMStore.curatorOrGuardian(FLAMMStore.s());
        _;
    }

    /// @dev The keeper or the curator (`NotKeeperOrCurator`).
    modifier keeperOrCurator() {
        FLAMMStore.requireKeeperOrCurator(FLAMMStore.s(), false);
        _;
    }

    /// @dev The pool's lock, taken for the entry and cleared when it returns.
    modifier nonReentrant() {
        ReentrancyGuardLib._guard();
        _;
        ReentrancyGuardLib._unlockGuard();
    }

    // ------------------------------------------------------------------ features
    /// @notice The curator's feature bitmap (`FLAMMStore.FEATURE_*`): the guardian may only clear bits, and on a pool
    ///         whose cheap lane is on the curator's bitmap that sets one waits the pool's delay (`FLAMMLane.capDue`);
    ///         no bit gates a redemption. A swap of the pool asset takes `FEATURE_SWAP_SELL` or `FEATURE_SWAP_BUY`; one
    ///         of two tokens past it takes the trade masks alone (`setTradePairs`).
    /// @dev A bit turned on is a loosening: the guardian's refused, and on a pool whose cheap lane is on the curator's
    ///      waits the pool's delay ({_waits}); a bitmap that turns none on applies at once. The custody-blind law's bit,
    ///      the operator's share's and the loss marks' are no switches (`FLAMMStore.CUSTODY_BLIND`,
    ///      `FLAMMStore.OPERATOR_SHARE`, `FLAMMStore.LOSS_MARKS`): every write keeps the first two, and sets the third
    ///      exactly where a venue slot's kind reports a loss, a redemption fee or not, as an admission does. So the
    ///      switches as they stand, written again by the operator or the guardian, set that bit at once on a pool
    ///      whose venues were admitted before it had a meaning, and no write clears it while such a venue is listed.
    function setFeatures(uint256 bitmap) public nonReentrant {
        FLAMMStore.S storage $ = FLAMMStore.s();
        bool guardian = FLAMMStore.curatorOrGuardian($);
        if (bitmap & ~FLAMMStore.FEATURES_ALL != 0) revert InvalidConfig();
        uint256 cur = $.features;
        if (_waits($, guardian, bitmap & ~cur == 0, abi.encode(SET_FEATURES, bitmap))) return;
        // the loss marks' bit is read from the venue sets again, as an admission writes it, so a pool whose venues were
        // admitted before the bit had a meaning carries it from its first feature write on
        cur &= FLAMMStore.CUSTODY_BLIND | FLAMMStore.OPERATOR_SHARE;
        if ($.lossVenues != 0) cur |= FLAMMStore.LOSS_MARKS;
        $.features = uint16(bitmap | cur);
        emit FeaturesSet(bitmap, msg.sender);
    }

    // ------------------------------------------------------------------ tokens
    /// @dev A token's swap policy, its config's and a token's at genesis and admission alike (`FLAMMAdmitLib`): a band
    ///      in (0, MAX] (zero where `zero`), a fee floor at most the pool's cap, 128-bit caps.
    function checkPolicy(FLAMMStore.S storage $, bool zero, uint64 band, uint64 floor, uint256 cap, uint256 target)
        internal
        view
    {
        if (zero ? band != 0 : (band == 0 || band > FLAMMStore.MAX_SWAP_PRICE_BAND_WAD)) revert InvalidConfig();
        if (floor > $.feeCapWad || cap > type(uint128).max || target > type(uint128).max) revert InvalidConfig();
    }

    /// @notice Token `t`'s swap policy: its band under the committed ceiling (token 1's is the market band, zero, as it
    ///         stays, on a pool with no band; the pool asset's is always zero), its fee floor, its notional cap (zero:
    ///         none) and its reserve target. The guardian may only tighten: a band no wider, a lower or first notional
    ///         cap, a reserve target and a fee floor no lower (on a custody-blind pool a borrowed token's reserve
    ///         target no higher, as it caps the buffer a refill holds); on a pool whose cheap lane is on any other
    ///         change of the curator's waits the pool's delay (`FLAMMLane.capDue`). On any other pool the curator's cut
    ///         of a token's fee floor waits it, the pool asset's aside (no fill reads that floor), as an admission
    ///         (`FLAMMLane.scheduledCut`): the first call schedules it (`AdmissionScheduled`), replacing the token's
    ///         cut scheduled before; the identical call applies it from its due time until one delay later, past which
    ///         it lapses; a call with a floor no lower, the guardian's included, applies at once and drops it, and the
    ///         curator or the guardian cancels it (`cancel`). Every other change applies at once there. A due cut
    ///         stays armed for its whole window, so LPs act on its scheduling event (`AdmissionScheduled`), not on the
    ///         wait itself.
    /// @dev A tighter band can refuse the covering swap that ends a market-oracle freeze, as clearing its direction's
    ///      feature bit does, and a lower notional cap can cut it short of the debt. The band is at most its committed
    ///      ceiling ({setBandAndFeeCeilings}); token 1's is zero while the pool has no market band, which only
    ///      `FLAMM.setMarketBand` attaches, and the pool asset's is always zero (no swap reads it). A wider band keeps
    ///      the LTV of every live pair of the token within what the band and the protocol's part keep
    ///      (`FLAMMStore.coverSafe`; `InvalidConfig` otherwise), as the pair's admission, its dial raises and the
    ///      market band's attach do (`FLAMMQuoteLib.pinsWithinBand`). On a cheap-lane pool token 1's notional cap is
    ///      written to its mirror in `laneConfig` too (`FLAMMStore.LANE_NOTIONAL_SHIFT`), which the hook pair's fill
    ///      reads, and every loosening waits the pool's delay (`FLAMMLane.capDue`). On any other pool a cut of a
    ///      token's fee floor waits it (`FLAMMLane.scheduledCut`, keyed by this setter and the token), the pool
    ///      asset's aside, as no fill reads that floor (`FLAMMSwapLib`'s bounds): a call with a floor no lower applies
    ///      at once and drops the token's cut scheduled.
    function setTokenConfig(uint8 t, uint64 bandWad, uint64 feeFloorWad, uint256 maxSwapNotional, uint256 reserveTarget)
        public
        nonReentrant
    {
        FLAMMStore.S storage $ = FLAMMStore.s();
        bool guardian = FLAMMStore.curatorOrGuardian($);
        FLAMMStore.checkToken($, t);
        checkPolicy($, t == 0 || (t == 1 && $.noBand), bandWad, feeFloorWad, maxSwapNotional, reserveTarget);
        FLAMMStore.TokenCfg storage cur = $.tokens[t];
        // a tightening: a band no wider, a lower or first notional cap, a reserve target and a fee floor no lower; but
        // on a custody-blind pool a borrowed token's target caps the buffer its refill holds in custody
        // (`FLAMMBlindLib.refillBuffer`), so there a cut is the tightening and a raise the loosening
        bool buffer = cur.partner != FLAMMStore.NO_PARTNER && $.features & FLAMMStore.CUSTODY_BLIND != 0;
        bool tight = bandWad <= cur.swapPriceBandWad && FLAMMStore.tighter(maxSwapNotional, cur.maxSwapNotional)
            && (buffer ? reserveTarget <= cur.reserveTarget : reserveTarget >= cur.reserveTarget)
            && feeFloorWad >= cur.feeFloorWad;
        if (guardian && !tight) revert GuardianMayOnlyTighten();
        if (bandWad > $.bandCeilingWad) revert CeilingBreached();
        // A cheap-lane pool's cheap fills honour token 1's notional cap alone, so it takes none on the pool asset;
        // every loosening of a token's policy waits its delay there. On any other pool a cut of a token's fee floor
        // waits it, the pool asset's aside.
        if (t == 0 && maxSwapNotional != 0 && $.swapBits & FLAMMStore.SWAP_LANE != 0) revert InvalidConfig();
        bytes memory data = abi.encode(SET_TOKEN_CONFIG, t, bandWad, feeFloorWad, maxSwapNotional, reserveTarget);
        if (
            $.swapBits & FLAMMStore.SWAP_LANE != 0
                ? _waits($, false, tight, data)
                : t != 0
                    && FLAMMLane.scheduledCut(
                        $, keccak256(abi.encode(SET_TOKEN_CONFIG, t)), feeFloorWad >= cur.feeFloorWad, data
                    ) != 0
        ) return;
        bool wider = bandWad > cur.swapPriceBandWad;
        cur.swapPriceBandWad = bandWad;
        // a wider band keeps every live pair of the token at an LTV its covers cannot raise past its cap
        if (wider) FLAMMQuoteLib.pinsWithinBand($, t);
        cur.feeFloorWad = feeFloorWad;
        cur.maxSwapNotional = uint128(maxSwapNotional);
        cur.reserveTarget = uint128(reserveTarget);
        if (t == 0) _poolAssetBits($, maxSwapNotional != 0, cur.minSupplyBatch);
        else if (t == 1 && $.swapBits & FLAMMStore.SWAP_LANE != 0) {
            $.laneConfig = uint128($.laneConfig) | (maxSwapNotional << FLAMMStore.LANE_NOTIONAL_SHIFT);
        }
        emit TokenConfigSet(t, bandWad, feeFloorWad, maxSwapNotional, reserveTarget);
    }

    /// @notice Token `t`'s minimum supply batch, native units: a swap lends once its custody exceeds the reserve target
    ///         by at least this much, and then lends all of the excess. While it is set, a payout the token cannot
    ///         borrow also withdraws back up to the reserve target, and a pro-rata supply leg under it stays in (or is
    ///         paid from) custody, unless its venue refuses the leg's action now, or, for an exit, the token backs a
    ///         debt (custody of it is backing) or that venue cuts its supply (the slice leaves at face). Zero lends
    ///         every surplus; the maximum lends none and refills none, as the pool asset's is at birth. The guardian
    ///         may only raise it; on a pool whose cheap lane is on the curator's cut waits the pool's delay
    ///         (`FLAMMLane.capDue`). Where a venue holding a minimum position (`CAP_HELD_REPAY`) lends `t`, a batch of
    ///         at least that minimum and the lenders' rounding (`MMRouterLib.RELEASE_SLACK`) keeps every smaller supply
    ///         leg in custody, so an entry whose leg would leave that venue under its minimum, which its preview
    ///         refuses, enters instead (`FLAMMMaxima.maxDepositProRata`).
    /// @dev A larger batch lends less often and never more (the maximum lends nothing and stops the refills a market
    ///      short of cash would refuse), so the guardian may only raise it.
    function setMinSupplyBatch(uint8 t, uint128 batch) public nonReentrant {
        FLAMMStore.S storage $ = FLAMMStore.s();
        bool guardian = FLAMMStore.curatorOrGuardian($);
        FLAMMStore.checkToken($, t);
        FLAMMStore.TokenCfg storage cur = $.tokens[t];
        if (_waits($, guardian, batch >= cur.minSupplyBatch, abi.encode(SET_MIN_SUPPLY_BATCH, t, batch))) return;
        cur.minSupplyBatch = batch;
        if (t == 0) _poolAssetBits($, cur.maxSwapNotional != 0, batch);
        emit MinSupplyBatchSet(t, batch);
    }

    /// @dev The pool asset's bits a swap reads instead of its record: its notional cap set, its batch under the
    ///      maximum. The pool's other bits are kept.
    function _poolAssetBits(FLAMMStore.S storage $, bool capped, uint128 batch) private {
        uint8 bits = $.poolBits & ~(FLAMMStore.POOL_ASSET_CAPPED | FLAMMStore.POOL_ASSET_LENDS);
        if (capped) bits |= FLAMMStore.POOL_ASSET_CAPPED;
        if (batch != type(uint128).max) bits |= FLAMMStore.POOL_ASSET_LENDS;
        $.poolBits = bits;
    }

    /// @notice The Router's supply cap on token `t` (zero: none); the guardian may only tighten it.
    /// @dev The Router's supply cap on token `t`, across every venue lending it; the guardian may only tighten it.
    function setTokenSupplyCap(uint8 t, uint128 cap) public nonReentrant {
        FLAMMStore.S storage $ = FLAMMStore.s();
        bool guardian = FLAMMStore.curatorOrGuardian($);
        IMMRouter r = $.router;
        bool tight = FLAMMStore.tighter(cap, r.token(address(this), t).supplyCap);
        if (_waits($, guardian, tight, abi.encode(SET_TOKEN_SUPPLY_CAP, t, cap))) return;
        r.setTokenSupplyCap(t, cap);
    }

    /// @notice The pool's fee floor and its cap, the cap under the committed ceiling and at or above every floor in
    ///         force. On a pool whose cheap lane is off a cut of the floor waits the pool's delay as an admission
    ///         (`FLAMMLane.scheduledCut`, one cut at a time): the first call schedules it (`AdmissionScheduled`),
    ///         replacing the cut scheduled before; the identical call applies it from its due time until one delay
    ///         later, past which it lapses; a call with a floor no lower applies at once, the cap's cut or raise
    ///         included, and drops it; the curator or the guardian cancels it (`cancel`). A due cut stays armed for its
    ///         whole window, so LPs act on its scheduling event (`AdmissionScheduled`), not on the wait itself. On a
    ///         pool whose cheap lane is on every call applies at once.
    /// @dev The cap may not undercut any token's fee floor, which would wedge `setTokenConfig`, nor pass its committed
    ///      ceiling ({setBandAndFeeCeilings}). On a pool whose cheap lane is off a cut of the pool's floor waits
    ///      the pool's delay (`FLAMMLane.scheduledCut`, keyed by this setter's selector alone, so one cut stands at a
    ///      time and every call with a floor no lower applies at once and drops it); the cap moves at once, down to the
    ///      floors in force. On a cheap-lane pool every call applies at once.
    function setFeeBounds(uint64 floorWad, uint64 capWad) public onlyCurator nonReentrant {
        FLAMMStore.S storage $ = FLAMMStore.s();
        if (floorWad > capWad || capWad > WAD) revert InvalidConfig();
        uint256 n = $.tokenCount;
        for (uint256 t; t < n; ++t) {
            if ($.tokens[t].feeFloorWad > capWad) revert InvalidConfig();
        }
        if (capWad > $.feeCapCeilingWad) revert CeilingBreached();
        if (
            $.swapBits & FLAMMStore.SWAP_LANE == 0
                && FLAMMLane.scheduledCut(
                    $, bytes32(SET_FEE_BOUNDS), floorWad >= $.feeFloorWad, abi.encode(SET_FEE_BOUNDS, floorWad, capWad)
                ) != 0
        ) return;
        $.feeFloorWad = floorWad;
        $.feeCapWad = capWad;
        emit FeeBoundsSet(floorWad, capWad);
    }

    // ------------------------------------------------------------------ pairs
    /// @notice Pair `pair`'s debt cap across its venues (zero: uncapped) and its borrow switch; the guardian may only
    ///         tighten. With no market band every switch stays off (`setMarketBand`).
    /// @dev Pair `p`'s debt cap across its venues (zero: uncapped) and its borrow switch at the Router, the pool's
    ///      mirror following. `guardian`: the caller is the guardian, who may only tighten each. With no market band
    ///      every switch stays off.
    function setPairCaps(uint8 p, uint128 debtCap, bool borrowEnabled) public nonReentrant {
        FLAMMStore.S storage $ = FLAMMStore.s();
        bool guardian = FLAMMStore.curatorOrGuardian($);
        FLAMMStore.checkPair($, p);
        IMMRouter r = $.router;
        IMMRouter.PairView memory v = r.pair(address(this), p);
        bool tight = FLAMMStore.tighter(debtCap, v.debtCap) && !(borrowEnabled && !v.borrowEnabled);
        if (_waits($, guardian, tight, abi.encode(SET_PAIR_CAPS, p, debtCap, borrowEnabled))) return;
        if (borrowEnabled && $.noBand) revert InvalidConfig();
        r.setPairCaps(p, debtCap, borrowEnabled);
        $.pairs[p].borrowOff = !borrowEnabled;
        FLAMMOpsLib.syncLanes($);
    }

    /// @notice Pair `pair`'s venue-oracle band at the Router, which its borrows, priced releases, refinances and venue
    ///         admissions check the venue's oracle against (but on a pool with no market band, which reads no price),
    ///         and while it is on `maintainCollateral` prices the pair's venues at their oracle where that is lower and
    ///         custody can still bring the venue under its threshold there; zero turns it off and no venue oracle is
    ///         read. The curator sets any value the Router admits; the guardian may only tighten: turn it on, or narrow
    ///         it. On a pool whose cheap lane is on the curator's widening, or turning it off, waits the pool's delay
    ///         (`FLAMMLane.capDue`).
    /// @dev Pair `p`'s venue-oracle band at the Router, which its borrows, priced releases, refinances and venue
    ///      admissions check the venue's oracle against; zero turns it off. `guardian`: the caller is the guardian,
    ///      who may only tighten it (turn it on, or narrow it).
    function setOracleBand(uint8 p, uint64 bandWad) public nonReentrant {
        FLAMMStore.S storage $ = FLAMMStore.s();
        bool guardian = FLAMMStore.curatorOrGuardian($);
        IMMRouter r = $.router;
        bool tight = FLAMMStore.tighter(bandWad, r.pair(address(this), p).oracleBandWad);
        if (_waits($, guardian, tight, abi.encode(SET_ORACLE_BAND, p, bandWad))) return;
        r.setOracleBand(p, bandWad);
    }

    /// @notice How many tokens the Router lets the pool owe at once; the guardian may only lower it, and on a pool
    ///         whose cheap lane is on the curator's raise waits the pool's delay (`FLAMMLane.capDue`).
    /// @dev The Router's drawn-set size, which the pool mirrors for its swaps' draw rule; the guardian may only lower
    ///      it.
    function setMaxDrawnTokens(uint8 n) public nonReentrant {
        FLAMMStore.S storage $ = FLAMMStore.s();
        bool guardian = FLAMMStore.curatorOrGuardian($);
        IMMRouter r = $.router;
        if (_waits($, guardian, n <= r.maxDrawnTokens(address(this)), abi.encode(SET_MAX_DRAWN_TOKENS, n))) return;
        r.setMaxDrawnTokens(n);
        $.maxDrawnTokens = n;
    }

    /// @notice A venue's borrow and supply switches; the guardian may only switch them off, and on a pool whose cheap
    ///         lane is on the curator's switch-on waits the pool's delay (`FLAMMLane.capDue`).
    /// @dev A venue's borrow and supply switches at the Router. `guardian`: the caller is the guardian, who may only
    ///      switch them off. Borrowing switched on keeps the larger of the pair's gap and 1 % over the pin: the
    ///      Router holds the gap first, then `FLAMMGateLib.requireDustGap` the 1 %.
    function setVenueFlags(uint16 id, bool borrowEnabled, bool supplyEnabled) public nonReentrant {
        FLAMMStore.S storage $ = FLAMMStore.s();
        bool guardian = FLAMMStore.curatorOrGuardian($);
        IMMRouter r = $.router;
        IMMRouter.VenueView memory v = r.venue(address(this), id);
        bool on = borrowEnabled && !v.borrowEnabled;
        bool tight = !on && !(supplyEnabled && !v.supplyEnabled);
        if (_waits($, guardian, tight, abi.encode(SET_VENUE_FLAGS, id, borrowEnabled, supplyEnabled))) return;
        r.setVenueFlags(id, borrowEnabled, supplyEnabled);
        if (on) FLAMMGateLib.requireDustGap($, v.pair, v.lltvWad);
    }

    /// @notice A venue's debt and supply caps and its borrow-rate ceiling (zero: uncapped); the guardian may only
    ///         tighten each.
    /// @dev A venue's debt and supply caps and its borrow-rate ceiling at the Router (zero: uncapped). `guardian`:
    ///      the caller is the guardian, who may only tighten each.
    function setVenueCaps(uint16 id, uint128 debtCap, uint128 supplyCap, uint64 maxBorrowRateWad) public nonReentrant {
        FLAMMStore.S storage $ = FLAMMStore.s();
        bool guardian = FLAMMStore.curatorOrGuardian($);
        IMMRouter r = $.router;
        IMMRouter.VenueView memory v = r.venue(address(this), id);
        bool tight = FLAMMStore.tighter(debtCap, v.debtCap) && FLAMMStore.tighter(supplyCap, v.supplyCap)
            && FLAMMStore.tighter(maxBorrowRateWad, v.maxBorrowRateWad);
        if (_waits($, guardian, tight, abi.encode(SET_VENUE_CAPS, id, debtCap, supplyCap, maxBorrowRateWad))) return;
        r.setVenueCaps(id, debtCap, supplyCap, maxBorrowRateWad);
    }

    /// @notice Move pair `pair`'s two dials at once (keeper or curator): each inside its envelope, a credit past
    ///         `1 / (1 + band)` of the pair's tokens as the band stands stored at that cap (never below the envelope's
    ///         floor; the dial stores and logs the cap), a higher LTV step-limited and a lower one not, the pair's
    ///         cooldown, which a lower LTV that raises neither dial skips while a lender's cut stands over the pair's
    ///         pin; an LTV raised or kept lands at least the larger of the pair's gap and 1 % under the binding
    ///         threshold, and a lower one there too, at or over the threshold, or at the envelope's floor
    ///         (`LtvLltvGap`); the Router pin follows the LTV.
    /// @dev Pair `p`'s two dials, its pin following ({FLAMMGateLib.validateDialMove}). On a pool that lists a venue
    ///      whose kind reports a loss, a lower LTV is refused (`VenueReportsLoss`) while a venue of the pair, or of a
    ///      frame one of them shares, reports a loss on its collateral of `FLAMMStore.LOSS_MOVE_FLOOR` or more, or
    ///      takes a redemption fee of any size on it (`FLAMMKeptLib.lossAtPair`), unless a lender's cut stands over the
    ///      pin and the LTV lands no lower than the gap under the lender's threshold; a raise, and any move at a pair
    ///      with no such venue, is untouched. That cut is read pair-wide, at the lowest threshold of the pair's venues
    ///      (`IMMRouter.minLltv`): a lender's cut at one venue lets the keeper and the operator lower the pin, to the
    ///      gap under that threshold, while an owing fee venue of the same pair stands, and the collateral maintainer
    ///      then posts into the fee venue back to that pin, paying the fee. With no such cut, while any fee stands at a
    ///      live fee venue of the pair or of a frame mate, the LTV dial is raise-only for the keeper and the operator,
    ///      even where that venue owes nothing, and the cure under a fee is a repay (a buy's, a flush, an emergency
    ///      `Repay`), which pays no fee; only a repay that clears the venue's whole debt frees the exits' stall there
    ///      (`FLAMMFlowLib.redeem`). A taker's draw at a pair one of whose venues that borrows stands under a fee is
    ///      refused (`FLAMMSettleLib`). What still posts custody into a fee venue under a fee: the operator's emergency
    ///      `TopUp` at one that owes (`FLAMMMaintainLib.emergency`); the collateral maintainer's post back to the pin
    ///      (`FLAMMTopUpLib.maintainCollateral`), which the pin and the pair's venue-oracle band size: switched on
    ///      (`setOracleBand`, at once for the operator and the guardian) the band prices that post at the venue's
    ///      oracle where that is lower and custody can still bring the venue under its threshold there, so it posts
    ///      more; and an entry's restoring leg (`FLAMMFlowLib.proRata`). An entry's pro-rata post and borrow also reach
    ///      an owing fee venue, and an exit of those shares is paid from custody; a custody-blind refill's borrow at a
    ///      fee venue that needs no new post lands too.
    function setDials(uint8 p, uint64 phiWad, uint64 ltvWad) public keeperOrCurator nonReentrant {
        FLAMMStore.S storage $ = FLAMMStore.s();
        FLAMMStore.checkPair($, p);
        FLAMMStore.PairCfg storage pc = $.pairs[p];
        if ($.features & FLAMMStore.LOSS_MARKS != 0) {
            // a reading of the loss marks, witnessed where a plain key's own transaction calls and one is due
            FLAMMKeptLib.recordLossMarks();
            // The collateral maintainer, which anyone calls, posts custody at a venue back to its pair's pin: a pin
            // lowered while a venue it would post at reports a loss on its collateral, or takes a redemption fee on
            // it, would size that post, and NAV fall by the loss's or the fee's share of it. So no lowering there,
            // but under a lender's cut that stands over the pin (a threshold under the pin plus the gap, as the
            // cooldown's exception reads it), and then no lower than the gap under that threshold; none where the
            // threshold reads zero, as a lender's frozen or unreadable reserve answers, which would let the pin fall
            // to its floor.
            if (ltvWad < pc.ltvWad && FLAMMKeptLib.lossAtPair(p)) {
                IMMRouter r = $.router;
                (uint256 lltv, uint256 gap) = (r.minLltv(address(this), p), r.pair(address(this), p).safetyGapWad);
                if (gap < FLAMMStore.MIN_DUST_GAP_WAD) gap = FLAMMStore.MIN_DUST_GAP_WAD;
                if (lltv == 0 || lltv >= uint256(pc.ltvWad) + gap || uint256(ltvWad) + gap < lltv) {
                    revert VenueReportsLoss();
                }
            }
        }
        // a credit inside the envelope stored at most at what a fill inside the pair's band guarantees an input is
        // worth, as the band stands, and never below the envelope's floor
        uint256 cap = Math.max(FLAMMStore.creditCap($, pc.coll, pc.debt), pc.phiMinWad);
        if (phiWad > cap && phiWad <= pc.phiMaxWad) phiWad = uint64(cap);
        FLAMMGateLib.validateDialMove($, p, phiWad, ltvWad);
        (pc.phiWad, pc.ltvWad, pc.lastDialMoveTs) = (phiWad, ltvWad, uint48(block.timestamp));
        $.router.setPin(p, ltvWad);
        emit DialsSet(p, phiWad, ltvWad, msg.sender);
    }

    // ------------------------------------------------------------------ the committed ceilings
    /// @notice The committed ceilings: the widest swap band any token may take and the highest fee cap, under which the
    ///         curator moves each at once (`setTokenConfig`, `setFeeBounds`); a pool is born with its widest band and
    ///         its cap as its ceilings. A cut, or the ceilings as they stand, applies at once and clears a scheduled
    ///         raise; a raise (either ceiling higher) is scheduled for `governanceDelaySec`, and one of the band's for
    ///         at least `FLAMMStore.MIN_BAND_DELAY_SEC`, replacing one already scheduled, and the identical call
    ///         applies it once due; a due raise does not lapse. The guardian's only form is the ceilings as they stand,
    ///         which cancels a scheduled raise. The band's ceiling may be `FLAMMStore.NO_BAND_CEILING`, wider than any
    ///         band: the only one under which `setMarketBand` drops the band, and the one a pool born with none has.
    /// @dev The widest swap band any token may take, in (0, MAX] or
    ///      `FLAMMStore.NO_BAND_CEILING`, which also lets the market band go, and the highest fee cap. A cut, or the
    ///      ceilings as they stand, applies at once and clears a scheduled raise; a raise (either ceiling higher) is
    ///      scheduled for `governanceDelaySec`, one of the band's for at least `FLAMMStore.MIN_BAND_DELAY_SEC`,
    ///      replacing one already scheduled, and the identical call applies it once due. What applies must hold the
    ///      fee cap and every band standing (`CeilingBreached`), a pool with no band only under the ceiling that
    ///      admits none. `guardian`: the caller is the guardian, whose only form is the ceilings as they stand.
    function setBandAndFeeCeilings(uint64 bandWad, uint64 feeCapWad) public nonReentrant {
        FLAMMStore.S storage $ = FLAMMStore.s();
        bool guardian = FLAMMStore.curatorOrGuardian($);
        if (
            bandWad == 0 || (bandWad > FLAMMStore.MAX_SWAP_PRICE_BAND_WAD && bandWad != FLAMMStore.NO_BAND_CEILING)
                || feeCapWad > WAD
        ) revert InvalidConfig();
        (uint64 band, uint64 cap) = ($.bandCeilingWad, $.feeCapCeilingWad);
        if (guardian && (bandWad != band || feeCapWad != cap)) revert NotCurator();
        if (bandWad > band || feeCapWad > cap) {
            if (bandWad != $.pendingBandCeilingWad || feeCapWad != $.pendingFeeCapCeilingWad) {
                uint256 delay = $.governanceDelaySec;
                if (bandWad > band && delay < FLAMMStore.MIN_BAND_DELAY_SEC) delay = FLAMMStore.MIN_BAND_DELAY_SEC;
                uint48 due = uint48(block.timestamp + delay);
                ($.pendingBandCeilingWad, $.pendingFeeCapCeilingWad, $.ceilingsExecutableAt) = (bandWad, feeCapWad, due);
                emit CeilingsScheduled(bandWad, feeCapWad, due);
                return;
            }
            if (block.timestamp < $.ceilingsExecutableAt) revert HookSetNotReady();
        }
        // No band is the widest: only the ceiling that admits none holds a pool without one.
        if ($.feeCapWad > feeCapWad || ($.noBand && bandWad != FLAMMStore.NO_BAND_CEILING)) revert CeilingBreached();
        uint256 n = $.tokenCount;
        for (uint256 t; t < n; ++t) {
            if ($.tokens[t].swapPriceBandWad > bandWad) revert CeilingBreached();
        }
        ($.bandCeilingWad, $.feeCapCeilingWad) = (bandWad, feeCapWad);
        ($.pendingBandCeilingWad, $.pendingFeeCapCeilingWad, $.ceilingsExecutableAt) = (0, 0, 0);
        emit CeilingsSet(bandWad, feeCapWad, msg.sender);
    }

    // ------------------------------------------------------------------ the trade masks
    /// @notice The curator's trade mask, as `tradablePairs` lays it out; its closings apply at once, always. One that
    ///         opens no pair applies whole and clears a scheduled opening; one that opens a pair closes what it closes
    ///         now and waits `governanceDelaySec` for the rest, replacing one already scheduled, and anyone applies it
    ///         then ({executeTradePairs}). The guardian may only close. A closed pair stops its swaps at once; credit
    ///         pairs (`FLAMMAdmitLib.addPair`) are apart.
    /// @dev The curator's trade mask, whose closings apply at once, always. One that opens no
    ///      pair applies at once whole and clears a scheduled opening; one that opens a pair closes what it closes
    ///      now and is scheduled for `governanceDelaySec`, replacing one already scheduled, and applies whole once
    ///      due ({executeTradePairs}). `guardian`: the caller is the guardian, who may only close.
    function setTradePairs(uint256 mask) public nonReentrant {
        FLAMMStore.S storage $ = FLAMMStore.s();
        bool guardian = FLAMMStore.curatorOrGuardian($);
        uint256 cur = $.tradePairs;
        uint256 kept = $.swapBits & FLAMMStore.SWAP_FENCE != 0 ? $.fenceTrades : 0;
        if (mask & ~(cur | kept) == 0) return FLAMMAdmitLib.setTradeMask($, mask);
        if (guardian) revert GuardianMayOnlyTighten();
        if (cur & ~mask != 0) {
            $.tradePairs = cur & mask;
            FLAMMAdmitLib.syncSwapBits($, $.hookPairs, cur & mask);
            emit TradePairsSet(cur & mask, msg.sender);
        }
        if (kept & ~mask != 0) $.fenceTrades = kept & mask;
        uint48 due = uint48(block.timestamp + $.governanceDelaySec);
        ($.pendingTradePairs, $.tradePairsExecutableAt) = (mask, due);
        emit TradePairsScheduled(mask, due);
    }

    /// @notice Applies the curator's scheduled trade mask once due, within its window (`FLAMMStore.executionWindow`),
    ///         past which it lapses as other due changes do (`NotScheduled`) and the curator schedules it again;
    ///         permissionless.
    /// @dev Applies the scheduled mask once due and before it lapses; anyone.
    function executeTradePairs() public nonReentrant {
        FLAMMStore.S storage $ = FLAMMStore.s();
        uint48 due = $.tradePairsExecutableAt;
        if (due == 0 || block.timestamp > due + FLAMMStore.executionWindow($.governanceDelaySec)) {
            revert NotScheduled();
        }
        if (block.timestamp < due) revert HookSetNotReady();
        FLAMMAdmitLib.setTradeMask($, $.pendingTradePairs);
    }

    /// @notice Drops the curator's scheduled trade mask; the curator's or the guardian's.
    /// @dev Drops the scheduled mask; the curator's or the guardian's.
    function cancelTradePairs() public curatorOrGuardian nonReentrant {
        FLAMMStore.S storage $ = FLAMMStore.s();
        if ($.tradePairsExecutableAt == 0) revert NotScheduled();
        ($.pendingTradePairs, $.tradePairsExecutableAt) = (0, 0);
        emit TradePairsCancelled(msg.sender);
    }

    /// @dev The collateral reserve's setter, which keys a cheap-lane pool's delayed rule in the pending table
    ///      (`FLAMMLane.capDue`).
    bytes4 internal constant SET_COLLATERAL_RESERVE = bytes4(keccak256("setCollateralReserve(uint8,uint16,uint128)"));

    // ------------------------------------------------------------------ collateral reserves
    /// @notice Token `t`'s collateral reserve rule, for a lender that pays on collateral: while `reserve` is set, a
    ///         release of `t` refills its custody only up to it, once custody is a tenth of it short, so collateral
    ///         above the posting law stays posted wherever it is. The venue must be live, its collateral `t` and
    ///         accruing (`CAP_ACCRUING_COLLATERAL`), and it retires only once the rule is off. Zero is the rule off;
    ///         the guardian may only switch it off, and on a pool whose cheap lane is on the curator's rule waits the
    ///         pool's delay (`FLAMMLane.capDue`), which switching it off drops.
    /// @dev Token `t`'s collateral reserve rule: while `reserve` is set, a release of `t` refills its custody only up
    ///      to it and leaves the rest posted. The rule names venue `venueId`, whose collateral must be `t` and accrue
    ///      (`CAP_ACCRUING_COLLATERAL`): keeping it posted pays nothing otherwise. Switching the rule off returns the
    ///      idle collateral from the lender at the next due release, so it is the guardian's only move.
    function setCollateralReserve(uint8 t, uint16 venueId, uint128 reserve) public nonReentrant {
        FLAMMStore.S storage $ = FLAMMStore.s();
        bool guardian = FLAMMStore.curatorOrGuardian($);
        FLAMMStore.checkToken($, t);
        if (reserve == 0) {
            venueId = 0;
        } else {
            if (guardian) revert GuardianMayOnlyTighten();
            IMMRouter.VenueView memory v = $.router.venue(address(this), venueId);
            if (v.status & VENUE_RETIRED != 0) revert IMMRouter.VenueIsRetired();
            if (v.status != 0) revert IMMRouter.VenueIsFenced();
            if (v.coll != t || IFinancingAccount(v.account).capabilities() & CAP_ACCRUING_COLLATERAL == 0) {
                revert InvalidConfig();
            }
        }
        // a rule set is a loosening: on a pool whose cheap lane is on the curator's waits the pool's delay, and the
        // rule off applies at once and drops it
        if (FLAMMLane.capDue($, reserve == 0, abi.encode(SET_COLLATERAL_RESERVE, t, venueId, reserve)) != 0) return;
        $.reserves[t] = FLAMMStore.CollateralReserve(reserve, venueId);
        bool on;
        uint256 n = $.tokenCount;
        for (uint256 i; i < n && !on; ++i) {
            on = $.reserves[i].reserve != 0;
        }
        uint8 bits = $.poolBits & ~FLAMMStore.POOL_RESERVE_ON;
        $.poolBits = on ? bits | FLAMMStore.POOL_RESERVE_ON : bits;
        emit CollateralReserveSet(t, venueId, reserve);
    }
}
Compiler settingsShow
{
  "viaIR": true,
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "libraries": {
    "src/core/mm/MMRouterLib.sol": {
      "MMRouterLib": "0x95b386d242c061ab2551a0d294c94dfe3948ef2c"
    },
    "src/core/flamm/FLAMMLane.sol": {
      "FLAMMLane": "0x5d81d4a7cfd40c3dfe9e009212545608be90de37"
    },
    "src/core/flamm/FLAMMRoute.sol": {
      "FLAMMRoute": "0xb1ffeae12c53f876aa0e495e9c00c829f47fb0fe"
    },
    "src/periphery/FLAMMMaxima.sol": {
      "FLAMMMaxima": "0x68546ce65986354c5394e4bc2f28027ef490a91b"
    },
    "src/core/flamm/FLAMMLawLib.sol": {
      "FLAMMLawLib": "0xf55c5807b6fbe5555443fd6ddbbd52079849cf45"
    },
    "src/core/flamm/FLAMMOpsLib.sol": {
      "FLAMMOpsLib": "0x0be7fdb3d611b05df90a61778a644654735ecc47"
    },
    "src/core/mm/AaveV3ReadsLib.sol": {
      "AaveV3ReadsLib": "0xa5db415d1af2158dd0a4a3c9c1eada277472803e"
    },
    "src/core/flamm/FLAMMFlowLib.sol": {
      "FLAMMFlowLib": "0x27957f4ddf818de39a1c9dba0bf273a5994cfb77"
    },
    "src/core/flamm/FLAMMGateLib.sol": {
      "FLAMMGateLib": "0x3a05779218510235badcbddcdd78732a16434368"
    },
    "src/core/flamm/FLAMMKeptLib.sol": {
      "FLAMMKeptLib": "0x70cace9076ac8dd6a691ced2f9aa62a5c360bee4"
    },
    "src/core/mm/CTokenMarketLib.sol": {
      "CTokenMarketLib": "0x60e4ab6b6ba72325c58924ee7753b14b37314010"
    },
    "src/core/flamm/FLAMMAdmitLib.sol": {
      "FLAMMAdmitLib": "0x0b107b1f0c64f3716554ccc83b53e492e51ce950"
    },
    "src/core/flamm/FLAMMBlindLib.sol": {
      "FLAMMBlindLib": "0x634d5a14c42fb5bec82a7aea32bf636a8d298fcd"
    },
    "src/core/flamm/FLAMMClaimLib.sol": {
      "FLAMMClaimLib": "0x5dc3bb30c60390ce9522b7e3ca315dd334aa7e91"
    },
    "src/core/flamm/FLAMMFenceLib.sol": {
      "FLAMMFenceLib": "0x9dbba0cbd9d7883f4eedd1c8e08780fac4798f1a"
    },
    "src/core/flamm/FLAMMFloatLib.sol": {
      "FLAMMFloatLib": "0x6b2b25ebba12e78afea697b9ac6d2167a6518935"
    },
    "src/core/flamm/FLAMMQuoteLib.sol": {
      "FLAMMQuoteLib": "0x99de54a108c64ebe23ac7766901c199a91929869"
    },
    "src/core/flamm/FLAMMTopUpLib.sol": {
      "FLAMMTopUpLib": "0xe4be161081d1c9aa91951ca347cc99da35cfac2e"
    },
    "src/core/mm/CTokenRewardsLib.sol": {
      "CTokenRewardsLib": "0x93ab647215a9f9f1050302a76506afcbc0262861"
    },
    "src/core/mm/MMRouterAdminLib.sol": {
      "MMRouterAdminLib": "0x6abb06b1e9cba80888992d366913bb9b7760ea7e"
    },
    "src/core/flamm/FLAMMPolicyLib.sol": {
      "FLAMMPolicyLib": "0x3858e2202cebcb6f12f36a596260dd2ed8f91f06"
    },
    "src/core/flamm/FLAMMSettleLib.sol": {
      "FLAMMSettleLib": "0x4551cddb1de95f5452f6a0f836e047e01833b301"
    },
    "src/core/flamm/FLAMMSharedLib.sol": {
      "FLAMMSharedLib": "0xb852d9cbdda85cbed7da0885bca2714ba1b71005"
    },
    "src/periphery/FLAMMExitMaxima.sol": {
      "FLAMMExitMaxima": "0x6a6a3ff1e834dbbf07dee472e07d1ca977798659"
    },
    "src/hooks/everlong/LeverageLib.sol": {
      "LeverageLib": "0x80396f9f894cc3060dfaa7468c4f576e8b16d055"
    },
    "src/core/flamm/FLAMMMaintainLib.sol": {
      "FLAMMMaintainLib": "0xaa5434e13eb54f37c577229efc981cceceb56417"
    },
    "src/core/flamm/FLAMMPairQuoteLib.sol": {
      "FLAMMPairQuoteLib": "0x3bc57bc05cc9dd1fe18106add8ffc060882055dd"
    },
    "src/hooks/everlong/EverlongOpsLib.sol": {
      "EverlongOpsLib": "0xf6d56f4ed6a7c441fd96c53a327026bac19dfeef"
    }
  },
  "optimizer": {
    "runs": 100,
    "enabled": true
  },
  "evmVersion": "cancun",
  "remappings": [
    "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable-compat/contracts/",
    "@openzeppelin/contracts/=lib/openzeppelin-contracts-compat/contracts/",
    "forge-std/=lib/forge-std/src/",
    "solady/=lib/solady/src/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.