Skip to content
Verified contractExactUNLICENSED

FLAMMMaxima

Address0x68546ce65986354c5394e4bc2f28027ef490a91b
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,508
Creation transaction
0x867d12f478…60518e388c
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

55 files

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

src/periphery/FLAMMMaxima.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, VenueFrozen, WAD} from "src/core/flamm/FLAMMStore.sol";
import {FLAMMGateLib} from "src/core/flamm/FLAMMGateLib.sol";
import {FLAMMFlowLib} from "src/core/flamm/FLAMMFlowLib.sol";
import {IFLAMM, IFLAMMProtocolFee} from "src/interfaces/core/flamm/IFLAMM.sol";
import {IFLAMMFence} from "src/interfaces/core/flamm/IFLAMMFence.sol";
import {IMMRouter} from "src/interfaces/core/mm/IMMRouter.sol";
import {
    IFinancingAccount,
    CAN_SUPPLY,
    CAP_ACTION_GATES,
    CAP_REPORTED_LOSS,
    CAP_SHARED_LIQUIDITY,
    CAP_REDEMPTION_FEE,
    CAP_HELD_REPAY,
    CAP_ACCRUING_COLLATERAL
} from "src/interfaces/core/mm/IFinancingAccount.sol";
import {IPriceFeed} from "src/interfaces/core/IPriceFeed.sol";
import {IDepositAllowlist} from "src/interfaces/core/IDepositAllowlist.sol";
import {IEverlongCore} from "src/interfaces/core/IEverlongCore.sol";
import {ReentrancyGuardLib} from "src/libraries/ReentrancyGuardLib.sol";
import {FLAMMExitMaxima} from "src/periphery/FLAMMExitMaxima.sol";

/// @notice The pool views the maxima read through this interface: the cheap lane's words, whose config word's version
///         bits are nonzero once the cheap lane is on (`FLAMMStore.LANE_VERSION_SHIFT`); the deposit basket, every
///         token's entry (`FLAMMFloatLib`); and the spread fee owed in a token (`FLAMM`).
interface IFLAMMBasketViews {
    /// @notice The cheap-lane word and the config word as they stand; the third word reads zero.
    function lane() external view returns (uint256 laneWord, uint256 laneConfig, uint256 pending);
    /// @notice A cheap-lane pool's deposit basket per 1e18 shares, one entry per listed token in its base units.
    function basketTokens() external view returns (uint256[] memory e);
    /// @notice The spread fee the pool owes the protocol in token `t`, native units.
    function spreadFeeOwed(uint8 t) external view returns (uint256);
}

/// @notice The pro-rata maxima of any pool, outside it: the largest `depositProRata`, `mintProRata` and `redeemProRata`
///         a holder may make now, recomputed from the pool's public views and the Router's with the pool's own
///         arithmetic (`FLAMMGateLib`'s and `FLAMMFlowLib`'s pure helpers) on the pool book (its `position` of every
///         token) and the entry's own legs (its previews). Deployed once and read like a contract (its entries are
///         views): each entry takes the pool.
/// @dev Where it reads other than the pool's flows would size:
///      - A venue the pool holds idle (found empty at its last read) that has since taken a gift or kept share dust
///        bounds this getter's sizes and none of the pool's, as no view tells the pool's idle record, so it reads lower
///        there.
///      - Venues sharing one reserve's cash are netted by token, so where such venues of one token sit on different
///        reserves (two markets of one lender) the least room or cash of them bounds them all and it reads lower, far
///        where a strict rate ceiling leaves one of them little room.
///      - Past a lender's borrow index of 2 RAY an entry at its maximum with two borrow legs at one pair's venues can
///        be refused at the pair's debt cap (`FLAMMGateLib.READ_BACK_UNITS`).
///      - Where the deposit preview at the pool asset's whole legs does not answer (a pool book that owes the pool
///        asset, or an entry of that size its preview refuses), the shares the fee's skim mints first (none while a
///        fence holds a pool part, as the pool mints none then) are rebuilt from `limits()`, whose fee mark is the
///        pool's divided by the share scale, and the maxima take the end of that rounding that sizes lower, but the
///        record of what exits forfeited at frozen venue marks, which raises the pool's fee mark until the next skim,
///        is not read there: in that window, with a fee rate on, the mint and exit maxima can read up to about the fee
///        on the forfeited value higher than the flows would size.
///      - An entry whose borrow or supply leg would leave a venue holding a minimum position under it (one whose
///        minimum rose past its debt, or whose supply a payout or an exit left under its minimum) reads 0, as its
///        preview refuses it (`FLAMMSharedLib.heldLegsCheck`) and no smaller entry passes: a safe under-report, which a
///        supply batch of at least such a venue's minimum and the lenders' rounding avoids (a supply leg under the
///        batch moves through custody), though a dust entry whose borrow leg rounds to nothing can pass, and where a
///        debt cap's room lands within a unit of the minimum the rounding can read 0 though a slightly larger entry
///        within the cap passes (the bound can be the mint cap, a pair's debt cap, which `borrowRoom` applies after the
///        minimum's check, or a venue cap's rounding edge).
///      - At a venue whose collateral accrues and whose margin at its threshold, read at the lower of the lender's own
///        price and the pool's price, covers one unit neither over the pin nor over the venue's own debt (a venue of a
///        few units), an entry whose post there credits no unit still borrows its slice, which the lender refuses past
///        what the units the venue holds carry, while a larger entry, whose post credits one, passes: the entry maxima
///        read at most the size whose slice the lender takes with nothing credited at that threshold, so every smaller
///        entry passes too, and read lower there than the largest entry the lender takes.
///      - Where an entry's preview refuses a restoring leg custody cannot fill (`IMMRouter.Unhealthy`) at the first
///        size the bounds give, that size is halved up to eight times and the maximum reads 0 past them, though a
///        smaller entry can still pass there.
///
///      The legs are read as the flows take them:
///      - An entry's or an exit's supply leg under its token's batch (`minSupplyBatch`) moves through custody, not the
///        venue, so no venue room bounds it.
///      - An exit's collateral a venue releases short is paid from the pool's custody of that token, one budget per
///        token with the exiter's own custody slice and the supply legs it moves, where that token is owed nowhere or
///        stays net debt-free after the exit, as the exit's ledger gate allows.
///      - An exit's repay a venue may take short is read where its kind reports the hold (a minimum position, a
///        lender's bound per market, spent across the venues borrowing there in the exit's order: `FLAMMExitMaxima`),
///        the dust the exit allows there counted only where that venue's slice is its token's only short release, and
///        a repay that leaves a venue owing nothing holds nothing (an accruing lender taking a whole repay a scaled
///        unit short).
///      - Venues sharing one reserve are bounded by that reserve's own room or cash, not by one venue's cap at the
///        Router, and each one's cap there holds back a share's assets and a unit per venue, which earlier legs can
///        move it by.
library FLAMMMaxima {
    /// @dev {_legs}' refusals: a restoring leg custody cannot fill (`IMMRouter.Unhealthy`), and a borrow leg that
    ///      leaves a venue under its minimum position, or a supply leg that does (`IMMRouter.InsufficientLiquidity`).
    uint256 private constant REFUSED_UNHEALTHY = 1;
    uint256 private constant REFUSED_MINIMUM = 2;
    /// @dev How often {_fitVenues} halves its first size while the preview refuses a restoring leg there.
    uint256 private constant RESTORE_HALVINGS = 8;

    /// @dev The facts every maximum reads once: the share supply; the pool's lock (`locked`: a flow holds it, where
    ///      every maximum reads 0), its frozen venue mark (`VenueFrozen`) and its NAV, as `totalAssets` answers; its
    ///      `limits()`; `bandOff`, whether token 1 has no swap band, where the pool reads no price; `lane`, whether the
    ///      pool's cheap lane is on; `m`, the token count; `n`, the venue count; `retired`, the slots the pool's walks
    ///      skip (`IFLAMM.retiredVenues`); the venues past those, by the capabilities their accounts declare (`gated`:
    ///      `CAP_ACTION_GATES`; `shared`: `CAP_SHARED_LIQUIDITY`; `fee`: `CAP_REDEMPTION_FEE`; `lossy`:
    ///      `CAP_REPORTED_LOSS`; `held`: `CAP_HELD_REPAY`; `accruing`: `CAP_ACCRUING_COLLATERAL`), each one's view as
    ///      the Router records it (`v`); `batch`, each token's supply batch, read on first use (one past it, zero
    ///      unread).
    struct Ctx {
        IFLAMM p;
        IMMRouter r;
        uint256 supply;
        bool locked;
        bool frozen;
        bool navOk;
        uint256 nav;
        IFLAMM.Limits lim;
        bool bandOff;
        bool lane;
        uint256 m;
        uint256 n;
        uint256 retired;
        uint256 gated;
        uint256 shared;
        uint256 fee;
        uint256 lossy;
        uint256 held;
        uint256 accruing;
        IMMRouter.VenueView[] v;
        uint256[] batch;
    }

    /// @notice The largest `depositProRata` for `receiver` now, in the pool asset: zero where the entry refuses (the
    ///         lock, the pause, the switch, the allowlist, no supply, a frozen venue mark, a fence holding a pool part,
    ///         written off or not, a cheap-lane pool waiting for its deposit basket, a pool book that owes the pool
    ///         asset, an unpriced debt, a pool book the fee cannot price, a spread fee owed past custody), else bounded
    ///         by the venue legs alone, each within its venue's room, one pair's borrow legs together within its debt
    ///         cap and one token's supply legs together within its supply cap, and `type(uint256).max` where none
    ///         bounds it short of custody's 128 bits.
    function maxDepositProRata(address pool, address receiver) public view returns (uint256) {
        Ctx memory c = _ctx(pool);
        if (c.locked || !_entryOpen(c, receiver)) return 0;
        (FLAMMGateLib.Book memory b, address[] memory tok) = _priced(c);
        if (!_priceable(c, b, tok) || _feePastCustody(c)) return 0;
        FLAMMGateLib.Leg memory L0 = b.legs[0];
        if (L0.owed != 0) return 0;
        uint256 den = L0.held + L0.supplied + L0.posted;
        if (den == 0) return 0;
        // the legs are sized at most at what keeps the gross within 128 bits, as the pool sizes them, and the pull of
        // tokens 0 and 1 within their custody's 128 bits ({_pullRoom})
        uint256 room = _pullRoom(c, b, den < type(uint128).max ? type(uint128).max - den : 0, den);
        uint256 got = _fitVenues(c, b, room, den, true);
        return got == room ? type(uint256).max : got;
    }

    /// @notice The largest `mintProRata` for `receiver` now, in shares, at the supply the mint is sliced at (after its
    ///         fee skim): zero where the entry refuses, also at the cap and on a pool book that holds nothing; else
    ///         bounded by `mintProRataCap`, custody's 128 bits and the venue legs, as the deposit's are.
    function maxMintProRata(address pool, address receiver) public view returns (uint256) {
        Ctx memory c = _ctx(pool);
        if (c.locked || !_entryOpen(c, receiver)) return 0;
        (FLAMMGateLib.Book memory b, address[] memory tok) = _priced(c);
        // the supply after the skim, bounded both ways where rebuilt: each bound read on the side it under-reports
        (uint256 lo, uint256 hi) = _pendingFeeShares(c, b);
        uint256 cap = c.lim.mintProRataCap;
        if (cap <= c.supply + hi) return 0;
        if (!_priceable(c, b, tok) || _feePastCustody(c)) return 0;
        if (!FLAMMFlowLib.holds(b)) return 0;
        uint256 room = cap - c.supply - hi;
        uint256 supply = c.supply + lo;
        return _fitVenues(c, b, _pullRoom(c, b, room, supply), supply, false);
    }

    /// @dev `room`, in `base`'s units of the entry, cut to what keeps tokens 0 and 1 within their custody's 128 bits:
    ///      an entry pulls the whole of each token's slice (custody, supply and collateral legs alike, `held + supplied
    ///      + posted` of it per `base`, rounded up) into tracked custody, the fee kept in it included, before its legs
    ///      leave. Every later token's custody is a full word.
    function _pullRoom(Ctx memory c, FLAMMGateLib.Book memory b, uint256 room, uint256 base)
        private
        view
        returns (uint256)
    {
        for (uint256 t; t < 2; ++t) {
            FLAMMGateLib.Leg memory L = b.legs[t];
            uint256 g = L.held + L.supplied + L.posted;
            if (g == 0) continue;
            uint256 kept = c.p.tokenConfig(uint8(t)).held;
            uint256 r = kept + 1 < type(uint128).max ? Math.mulDiv(type(uint128).max - kept - 1, base, g) : 0;
            if (r < room) room = r;
        }
        return room;
    }

    /// @notice The largest `redeemProRata` of `owner`'s shares now: `FLAMMExitMaxima.maxRedeemProRata`, which this
    ///         runs (a library apart, linked here, so the entry maxima and the exit maximum each fit a contract).
    function maxRedeemProRata(address pool, address owner) public view returns (uint256) {
        return FLAMMExitMaxima.maxRedeemProRata(pool, owner);
    }

    /// @dev Token `t`'s supply batch in `c.batch`, read once: one past the batch, so zero reads as unread.
    function _batch(Ctx memory c, uint256 t) internal view returns (uint256) {
        uint256 k = c.batch[t];
        if (k == 0) {
            k = c.p.tokenConfig(uint8(t)).minSupplyBatch + 1;
            c.batch[t] = k;
        }
        return k;
    }

    // ------------------------------------------------------------------ the pool's facts
    /// @dev The pool's facts ({Ctx}), read once per maximum.
    function _ctx(address pool) internal view returns (Ctx memory c) {
        (c.p, c.r) = (IFLAMM(pool), IMMRouter(IFLAMM(pool).router()));
        c.supply = c.p.totalSupply();
        // `totalAssets` takes the read guard first and refuses a frozen venue mark before it prices:
        // one call tells both
        try c.p.totalAssets() returns (uint256 a) {
            (c.navOk, c.nav) = (true, a);
        } catch (bytes memory e) {
            bytes4 s = bytes4(e);
            (c.locked, c.frozen) = (s == ReentrancyGuardLib.Reentrant.selector, s == VenueFrozen.selector);
        }
        c.lim = c.p.limits();
        c.bandOff = c.p.tokenConfig(1).swapPriceBandWad == 0;
        (, uint256 cfg,) = IFLAMMBasketViews(pool).lane();
        c.lane = (cfg >> FLAMMStore.LANE_VERSION_SHIFT) & 0x7f != 0;
        (c.m, c.n, c.retired) = (c.p.tokenCount(), c.r.venueCount(pool), c.p.retiredVenues());
        (c.v, c.batch) = (new IMMRouter.VenueView[](c.n), new uint256[](c.m));
        for (uint16 i; i < c.n; ++i) {
            if ((c.retired >> i) & 1 != 0) continue;
            IMMRouter.VenueView memory w = c.r.venue(pool, i);
            c.v[i] = w;
            uint256 caps = IFinancingAccount(w.account).capabilities();
            if (caps & CAP_ACTION_GATES != 0) c.gated |= uint256(1) << i;
            if (caps & CAP_SHARED_LIQUIDITY != 0) c.shared |= uint256(1) << i;
            if (caps & CAP_REDEMPTION_FEE != 0) c.fee |= uint256(1) << i;
            if (caps & CAP_REPORTED_LOSS != 0) c.lossy |= uint256(1) << i;
            if (caps & CAP_HELD_REPAY != 0) c.held |= uint256(1) << i;
            if (caps & CAP_ACCRUING_COLLATERAL != 0) c.accruing |= uint256(1) << i;
        }
    }

    /// @dev The entry's gates: the pause, a bootstrapped supply, `FEATURE_DEPOSITS`, a cheap-lane pool's deposit basket
    ///      where the curator's fee cap is nonzero, the allowlist on the receiver, no frozen venue mark and no fence
    ///      holding a pool part, written off or not (`IFLAMMFence.partedFences`; a pool that serves no fence reads
    ///      none).
    function _entryOpen(Ctx memory c, address receiver) private view returns (bool) {
        try IFLAMMFence(address(c.p)).partedFences() returns (uint256 parts) {
            if (parts != 0) return false;
        } catch {}
        (uint256 features,) = c.p.switches();
        if (c.p.paused() || c.supply == 0 || features & FLAMMStore.FEATURE_DEPOSITS == 0) return false;
        if (c.lane && c.lim.maxPerformanceFeeBp != 0 && IFLAMMBasketViews(address(c.p)).basketTokens()[0] == 0) {
            return false;
        }
        address list = c.p.depositAllowlist();
        if (list != address(0) && !IDepositAllowlist(list).isDepositAllowed(receiver)) return false;
        return !c.frozen;
    }

    /// @dev The pool book as the pool reads it (`FLAMMGateLib.bookOf`): every token's legs from its `position` (custody
    ///      net of the spread fee custody keeps, and the Router's book past the venues it passes over); the part of the
    ///      fee owed past custody ({FLAMMGateLib.feeOf}); each scale; and each owed token's partner as the per-pair
    ///      read finds it (`FLAMMLawLib.splitRead`): `MANY` where two or more of its live pairs owe it, else the
    ///      collateral of the one that does. `tok`: each token's address.
    function _book(Ctx memory c) internal view returns (FLAMMGateLib.Book memory b, address[] memory tok) {
        uint256 m = c.m;
        (b.legs, b.usd, tok) = (new FLAMMGateLib.Leg[](m), new uint256[](m), new address[](m));
        for (uint256 t; t < m; ++t) {
            IFLAMM.TokenConfig memory k = c.p.tokenConfig(uint8(t));
            FLAMMGateLib.Leg memory L = b.legs[t];
            (L.held, L.supplied, L.posted, L.owed) = c.p.position(uint8(t));
            (L.scale, L.partner, tok[t]) = (10 ** (18 - k.decimals), k.partner, k.token);
            uint256 f = IFLAMMBasketViews(address(c.p)).spreadFeeOwed(uint8(t));
            if (f > k.held) L.fee = f - k.held;
        }
        _split(c, b);
    }

    /// @dev {_book} priced as the pool prices it (`FLAMMGateLib.priceIn`): none with no band; the pool asset and
    ///      token 1 from one read of their pair, every later token from its own, the pool asset alone first where the
    ///      pair does not answer and a later token is read; then each token's `price36`, the pool asset's price scale
    ///      against it (`FLAMMGateLib.frameAll`).
    function _priced(Ctx memory c) private view returns (FLAMMGateLib.Book memory b, address[] memory tok) {
        (b, tok) = _book(c);
        if (c.bandOff) return (b, tok);
        IPriceFeed feed = IPriceFeed(c.p.priceFeed());
        (bool ok, uint256 u0, uint256 u1,) = feed.peekPair(tok[0], tok[1]);
        if (ok) (b.usd[0], b.usd[1]) = (u0, u1);
        if (c.m > 2 && !ok) {
            (bool ok0, uint256 v0,) = feed.peekUsd(tok[0]);
            if (ok0) b.usd[0] = v0;
        }
        for (uint256 t = 2; t < c.m; ++t) {
            (bool okT, uint256 v,) = feed.peekUsd(tok[t]);
            if (okT) b.usd[t] = v;
        }
        FLAMMGateLib.frameAll(b);
    }

    /// @dev Each owed token's partner where two or more live pairs owe it: each such pair's debt read apart (the
    ///      Router's book of its venues alone), `MANY` where two or more owe, else the collateral of the one that does;
    ///      where two or more owe, their collateral tokens in `b.backs`, as the pool's per-pair read records them
    ///      (`FLAMMLawLib.splitRead`), so `FLAMMGateLib.backsDebt` reads this pool book as the pool reads its own.
    function _split(Ctx memory c, FLAMMGateLib.Book memory b) private view {
        uint256 np = c.p.pairCount();
        IFLAMM.PairConfig[] memory pc = new IFLAMM.PairConfig[](np);
        uint256[] memory live = new uint256[](b.legs.length);
        for (uint256 r; r < np; ++r) {
            pc[r] = c.p.pairConfig(uint8(r));
            if (pc[r].live) ++live[pc[r].debt];
        }
        for (uint256 t; t < b.legs.length; ++t) {
            if (b.legs[t].owed == 0 || live[t] < 2) continue;
            (uint256 owing, uint8 coll, uint256 backs) = (0, 0, 0);
            for (uint256 r; r < np; ++r) {
                if (!pc[r].live || pc[r].debt != t) continue;
                uint256 keep;
                for (uint16 i; i < c.n; ++i) {
                    if ((c.retired >> i) & 1 == 0 && c.v[i].pair == r) keep |= uint256(1) << i;
                }
                if (keep == 0) continue;
                (,, uint256[] memory o,) = c.r.book(address(c.p), ~uint64(keep));
                if (o[t] != 0) (owing, coll, backs) = (owing + 1, pc[r].coll, backs | uint256(1) << pc[r].coll);
            }
            b.legs[t].partner = owing >= 2 ? FLAMMStore.MANY : coll;
            if (owing >= 2) b.backs |= backs;
        }
    }

    /// @dev Whether a spread fee is owed past custody in any token, which an entry refuses.
    function _feePastCustody(Ctx memory c) private view returns (bool) {
        for (uint256 t; t < c.m; ++t) {
            if (IFLAMMBasketViews(address(c.p)).spreadFeeOwed(uint8(t)) > c.p.tokenConfig(uint8(t)).held) return true;
        }
        return false;
    }

    /// @dev As an entry runs: a pool book whose fee mark cannot read enters only with no fee rate on (`totalAssets`
    ///      refuses exactly then, while a rate is on: `FLAMMGateLib.markedAt`, the cheap-lane basket's and the forfeit
    ///      record's prices included), and only while no token with debt is unpriced at a pair that owes it; and every
    ///      borrow leg needs both tokens of its pair on peg.
    function _priceable(Ctx memory c, FLAMMGateLib.Book memory b, address[] memory tok) private view returns (bool) {
        bool feeOn = (c.lim.performanceFeeBp | c.lim.protocolFeeBp) != 0 && !c.bandOff;
        if (feeOn && !c.navOk) return false;
        IPriceFeed feed = IPriceFeed(c.p.priceFeed());
        uint256 np;
        for (uint256 t; t < b.legs.length; ++t) {
            FLAMMGateLib.Leg memory L = b.legs[t];
            if (L.owed == 0) continue;
            if (L.partner == FLAMMStore.NO_PARTNER || !feed.pegOk(tok[t])) return false;
            if (L.partner != FLAMMStore.MANY) {
                if (FLAMMGateLib.frameOf(b, L.partner, t) == 0 || !feed.pegOk(tok[L.partner])) return false;
                continue;
            }
            if (np == 0) np = c.p.pairCount();
            for (uint256 r; r < np; ++r) {
                IFLAMM.PairConfig memory q = c.p.pairConfig(uint8(r));
                if (!q.live || q.debt != t) continue;
                if (FLAMMGateLib.frameOf(b, q.coll, t) == 0 || !feed.pegOk(tok[q.coll])) return false;
            }
        }
        return true;
    }

    /// @dev The shares the skim before a flow mints at the supply, both parts (`FLAMMMaintainLib.pendingFeeShares`), as
    ///      a lower and an upper bound. None while a fence holds a pool part, written off or not
    ///      (`IFLAMMFence.partedFences`), as the pool's skim mints none then. Exact, the two equal, from the deposit
    ///      preview at the pool asset's whole legs, which sizes its shares at the supply after the skim; where it does
    ///      not answer (a pool book that owes the pool asset reads no deposit, or the preview refuses an entry of that
    ///      size), rebuilt from `limits()`, whose fee mark is the pool's divided by the share scale: the bounds are the
    ///      fee at that rounding's two ends, and the forfeit record is not read.
    function _pendingFeeShares(Ctx memory c, FLAMMGateLib.Book memory b) internal view returns (uint256 lo, uint256 hi) {
        (uint256 bp, uint256 pbp) = (c.lim.performanceFeeBp, c.lim.protocolFeeBp);
        if ((bp == 0 && pbp == 0) || c.bandOff) return (0, 0);
        // the skim mints nothing while a fence holds a pool part (`FLAMMMaintainLib.pendingFeeShares`)
        try IFLAMMFence(address(c.p)).partedFences() returns (uint256 parts) {
            if (parts != 0) return (0, 0);
        } catch {}
        FLAMMGateLib.Leg memory L0 = b.legs[0];
        uint256 gross0 = L0.held + L0.supplied + L0.posted;
        if (gross0 != 0 && L0.owed == 0) {
            try c.p.previewDepositProRata(gross0) returns (
                uint256 shares, IFLAMM.VenueLeg[] memory, uint256[] memory, uint256[] memory
            ) {
                if (shares >= c.supply) return (shares - c.supply, shares - c.supply);
            } catch {}
        }
        if (!c.navOk) return (0, 0);
        uint256 scale = L0.scale;
        uint256 assets = c.nav * scale;
        if (c.lane) {
            uint256[] memory e = IFLAMMBasketViews(address(c.p)).basketTokens();
            if (e[0] != 0) {
                (FLAMMGateLib.Book memory q,) = _priced(c);
                uint256 basket = e[0];
                for (uint256 t = 1; t < q.legs.length; ++t) {
                    if (e[t] == 0 && t != 1) continue;
                    uint256 p = q.legs[t].price36;
                    if (p == 0) return (0, 0);
                    basket += Math.mulDiv(e[t], 1e36, p, Math.Rounding.Up);
                }
                assets = Math.mulDiv(c.nav, WAD * scale, basket);
            }
        }
        uint256 cur = Math.mulDiv(assets, WAD, c.supply);
        if (cur > type(uint128).max) return (0, 0);
        if (bp != 0) {
            try IEverlongCore(c.p.core()).feeReceiver() returns (address to) {
                if (to == address(0)) bp = 0;
            } catch {
                bp = 0;
            }
        }
        if (pbp != 0) {
            try IFLAMMProtocolFee(c.p.factory()).protocolFeeReceiver() returns (address to) {
                if (to == address(0)) pbp = 0;
            } catch {
                pbp = 0;
            }
        }
        // the pool's fee mark lies in [q * scale, (q + 1) * scale - 1]
        uint256 floorPeak = uint256(c.lim.peakSharePriceWad) * scale;
        lo = _fee(c.supply, cur, floorPeak + scale - 1, bp, pbp);
        hi = _fee(c.supply, cur, floorPeak, bp, pbp);
    }

    /// @dev Both parts of the fee at the fee mark `peak` (`FLAMMFlowLib.split`), none at or under it.
    function _fee(uint256 supply, uint256 cur, uint256 peak, uint256 bp, uint256 pbp) private pure returns (uint256) {
        if (cur <= peak) return 0;
        (uint256 f, uint256 g) = FLAMMFlowLib.split(supply, cur, peak, bp, pbp);
        return f + g;
    }

    // ------------------------------------------------------------------ the venue legs
    /// @dev The largest size up to `size` (of `den`: the deposit's pool-asset base, or the mint's supply) whose venue
    ///      legs every venue takes now (`FLAMMQuoteLib`'s fit, restated):
    ///      - Each supply leg lies within its supply room, or under its token's batch, where it stays in custody
    ///        ({_under}), and one token's together within its supply cap.
    ///      - The legs of venues sharing one reserve's room, what they lend and post of one token in proportion to what
    ///        they hold, lie together within the least room any of their accounts reports for the reserve (not a
    ///        venue's own cap at the Router, which bounds its own leg), and their borrow legs of one token within the
    ///        least any of them can lend.
    ///      - Then over two passes each collateral leg lies within its post room, each borrow leg within the Router's
    ///        `borrowRoom`, the shared legs within their least room, one pair's borrow legs together within its debt
    ///        cap and one token's supply legs past custody within its supply cap; trimmed once.
    ///      - The legs are the entry's own (its preview at the size, a leg under its batch in custody).
    ///      - Where the preview refuses a restoring leg the fit cut past rounding dust (`IMMRouter.Unhealthy`), the
    ///        first size is halved up to `RESTORE_HALVINGS` times, as a smaller entry needs less, and reads 0 where
    ///        every one is refused.
    ///      - One whose borrow or supply leg leaves a venue under its minimum position
    ///        (`IMMRouter.InsufficientLiquidity`) reads 0.
    function _fitVenues(Ctx memory c, FLAMMGateLib.Book memory b, uint256 size, uint256 den, bool deposit)
        private
        view
        returns (uint256)
    {
        address pool = address(c.p);
        uint256[] memory debts = new uint256[](c.n);
        // venues sharing one reserve's room: their legs per token, the supply they lend and the collateral they post,
        // and the least room any reports; past the tokens, apart, what they owe of each and the least any can lend
        uint256 m = c.shared == 0 ? 0 : c.m;
        (uint256[] memory pooled, uint256[] memory least) = (new uint256[](2 * m), new uint256[](2 * m));
        // per token, the most size at which every supply leg of it stays in custody
        uint256[] memory under = _maxed(c.m);
        for (uint16 i; i < c.n; ++i) {
            if ((c.retired >> i) & 1 != 0) continue;
            (, uint256 coll,, uint256 sup, uint256 debt) = c.r.venuePosition(pool, i);
            debts[i] = debt;
            IMMRouter.VenueView memory v = c.v[i];
            if (sup != 0) {
                uint256 u = _under(c, v, i, sup, den);
                if (u < under[v.debt]) under[v.debt] = u;
                size = _roomFit(c, i, sup, den, size, u);
            }
            if ((c.shared >> i) & 1 == 0 || (sup | coll | debt) == 0) continue;
            IFinancingAccount.Capacity memory k = c.r.venueCapacity(pool, i);
            if (sup != 0) _pool(v.debt, sup, k.suppliable, pooled, least);
            if (coll != 0) _pool(v.coll, coll, k.collateralPostable, pooled, least);
            if (debt != 0) _pool(m + v.debt, debt, _lendable(v), pooled, least);
        }
        for (uint256 t; t < pooled.length; ++t) {
            uint256 u = pooled[t];
            if (u == 0 || least[t] == type(uint256).max) continue;
            uint256 k = t < m ? c.n : c.n * FLAMMGateLib.READ_BACK_UNITS;
            if (k > least[t]) k = least[t];
            size = Math.min(size, Math.mulDiv(least[t] - k, den, u));
        }
        size = _tokenCapFit(c, b, den, size, under);
        for (uint256 pass; pass < 2; ++pass) {
            if (size == 0) return 0;
            (uint256 refused, IFLAMM.VenueLeg[] memory legs) = _legs(c, size, deposit);
            // a restoring leg custody cannot fill grows with the entry, so a smaller one may pass: the first size,
            // halved up to `RESTORE_HALVINGS` times until its preview takes it
            for (uint256 k; refused == REFUSED_UNHEALTHY && pass == 0 && k < RESTORE_HALVINGS && size > 1; ++k) {
                size /= 2;
                (refused, legs) = _legs(c, size, deposit);
            }
            if (refused != 0) return 0;
            uint256 next = size;
            for (uint16 i; i < legs.length; ++i) {
                IFLAMM.VenueLeg memory v = legs[i];
                uint256 p = v.collateral == 0 ? 0 : c.r.venueCapacity(pool, i).collateralPostable;
                if (v.collateral > p) {
                    if (pass == 1) return 0;
                    next = Math.min(next, Math.mulDiv(size, p, v.collateral));
                }
                if (v.owed == 0) continue;
                if ((c.accruing >> i) & 1 != 0) {
                    next = Math.min(
                        next, _unitBound(c, i, debts[i], den, FLAMMGateLib.frameOf(b, c.v[i].coll, c.v[i].debt))
                    );
                }
                uint256 room = c.r.borrowRoom(pool, i, v.collateral, b.usd);
                if (v.owed <= room) continue;
                if (pass == 1) return 0;
                next = Math.min(next, Math.mulDiv(room, den, debts[i]));
            }
            if (c.shared != 0) next = _sharedFit(c, legs, pooled, least, size, next, pass);
            next = _pairCapFit(c, legs, debts, den, next, pass);
            next = _tokenCapPass(c, b, legs, size, next, pass);
            if (next == 0) return 0;
            if (next == size) return size;
            size = next;
        }
        return size;
    }

    /// @dev The most size (of `den`) every smaller entry also takes at venue `i`, whose collateral accrues and which
    ///      owes `debt`. Zero where `frame` cannot be read.
    ///      - The lender credits a post in its own units, rounded down (a post under one unit's assets, none: the Venus
    ///        kind holds it for a later post), and checks its own threshold on what it credits, at its own price, which
    ///        the Router lets sit under the pool's price by up to the pair's venue-oracle band.
    ///      - So the threshold is read at the lower of the two (`frame`, the pair's at the pool's prices, and the
    ///        venue's `oraclePrice`), as the maintainer reads it (`FLAMMMaintainLib`).
    ///      - An entry's legs are pro rata, so it keeps the venue's ratio, and its post loses at most one unit's assets
    ///        and one to the lender's rounding.
    ///      - Where that threshold's margin over the pin covers that unit, or the venue's own margin there, its
    ///        collateral at that threshold over its debt, covers the unit's worth (the margin that counts where the
    ///        lender's price takes the threshold to the pin or under it, at a venue under its pin), a borrow the pin
    ///        allows passes the lender at any size (none: `type(uint256).max`).
    ///      - Where it holds fewer, an entry whose post credits nothing still borrows its slice, which the lender
    ///        refuses past what the units the venue holds carry, while a larger entry, whose post credits a unit,
    ///        passes: such an entry is held to the size whose slice the lender takes with nothing credited, that same
    ///        margin. More credit only helps, and the Router allows a post's rounding on its own side
    ///        (`MMRouterLib.requireSliceFits`).
    ///      - The collateral is read at the rate the next accrual sets, which a lender checking its stored rate reads a
    ///        little lower, so a venue within that drift of its threshold can refuse an entry the maximum advertises.
    function _unitBound(Ctx memory c, uint16 i, uint256 debt, uint256 den, uint256 frame)
        private
        view
        returns (uint256)
    {
        IMMRouter.VenueView memory v = c.v[i];
        address pool = address(c.p);
        uint256 one = IFinancingAccount(v.account).collateralUnitsToAssets(v.id, 1) + 1;
        uint256 pin = c.r.pair(pool, v.pair).pinLtvWad;
        if (frame == 0) return 0;
        (bool ok, uint256 q) = IFinancingAccount(v.account).oraclePrice(v.id);
        uint256 l = v.lltvWad;
        if (ok && q != 0 && q < frame) l = Math.mulDiv(l, q, frame);
        (, uint256 coll,,,) = c.r.venuePosition(pool, i);
        if (l > pin && (l - pin) * coll >= l * one) return type(uint256).max;
        // what the lender takes with nothing credited, at that threshold, and what a post's rounding loses there
        uint256 cap = Math.mulDiv(Math.mulDiv(coll, frame, 1e36), l, WAD);
        uint256 loss = Math.mulDiv(Math.mulDiv(one, frame, 1e36, Math.Rounding.Up), l, WAD, Math.Rounding.Up);
        // a margin past that loss, a borrow leg's rounding beside it, takes every pro-rata entry
        if (cap > debt + loss) return type(uint256).max;
        return cap > debt ? Math.mulDiv(cap - debt, den, debt) : 0;
    }

    /// @dev The most size (of `den`) at which venue `i`'s entry supply leg of `sup` stays in custody: under its token's
    ///      batch, rounded up as the entry's is, where the venue allows the leg's action or cannot refuse one
    ///      (`FLAMMFlowLib.proRata`); zero where none does.
    function _under(Ctx memory c, IMMRouter.VenueView memory v, uint16 i, uint256 sup, uint256 den)
        private
        view
        returns (uint256)
    {
        uint256 k = _batch(c, v.debt);
        if (k < 3) return 0;
        if ((c.gated >> i) & 1 != 0 && c.r.venueCapacity(address(c.p), i).actions & CAN_SUPPLY == 0) return 0;
        return Math.mulDiv(k - 2, den, sup);
    }

    /// @dev {_fitVenues}' bound from venue `i`'s supply room on its leg of `sup`: within the room, or up to `u`, where
    ///      the leg stays in custody. At a reserve it shares, a share's assets and a unit are held back per venue: the
    ///      entry's earlier legs there run first, and each supply's shares, rounded down, leave the rest of a share's
    ///      assets to every holder, which raises what this venue recognizes against its cap by up to that much.
    function _roomFit(Ctx memory c, uint16 i, uint256 sup, uint256 den, uint256 size, uint256 u)
        private
        view
        returns (uint256)
    {
        uint256 room = c.r.supplyRoom(address(c.p), i);
        if (room == type(uint256).max) return size;
        if ((c.shared >> i) & 1 != 0) {
            IMMRouter.VenueView memory v = c.v[i];
            uint256 k = c.n * (IFinancingAccount(v.account).supplySharesToAssets(v.id, 1) + 1);
            room = room > k ? room - k : 0;
        }
        return Math.min(size, Math.max(Math.mulDiv(room, den, sup), u));
    }

    /// @dev `n` words, each `type(uint256).max`.
    function _maxed(uint256 n) private pure returns (uint256[] memory a) {
        a = new uint256[](n);
        for (uint256 t; t < n; ++t) {
            a[t] = type(uint256).max;
        }
    }

    /// @dev {_fitVenues}' bound on the legs at `size` past custody against each token's supply cap at the Router:
    ///      their supply legs together within the cap less what its venues lend, a unit over its share each of the
    ///      venues, as {_tokenCapFit} reads it from the pool book.
    function _tokenCapPass(
        Ctx memory c,
        FLAMMGateLib.Book memory b,
        IFLAMM.VenueLeg[] memory legs,
        uint256 size,
        uint256 next,
        uint256 pass
    ) private view returns (uint256) {
        uint256[] memory sum = new uint256[](c.m);
        for (uint256 i; i < legs.length; ++i) {
            if (legs[i].supplied != 0) sum[c.v[i].debt] += legs[i].supplied;
        }
        for (uint256 t; t < c.m; ++t) {
            if (sum[t] == 0) continue;
            uint256 cap = c.r.token(address(c.p), uint8(t)).supplyCap;
            if (cap == 0) continue;
            uint256 k = b.legs[t].supplied + c.n;
            if (sum[t] + k <= cap) continue;
            if (pass == 1) return 0;
            next = Math.min(next, cap > k ? Math.mulDiv(size, cap - k, sum[t]) : 0);
        }
        return next;
    }

    /// @dev {_fitVenues}' bound on the legs at `size` at the shared venues: each token's collateral and supply legs
    ///      there together within the least room any of them holding a leg of it reports.
    function _sharedFit(
        Ctx memory c,
        IFLAMM.VenueLeg[] memory legs,
        uint256[] memory pooled,
        uint256[] memory least,
        uint256 size,
        uint256 next,
        uint256 pass
    ) private pure returns (uint256) {
        uint256[] memory sum = new uint256[](least.length);
        for (uint256 i; i < legs.length; ++i) {
            if ((c.shared >> i) & 1 == 0) continue;
            IFLAMM.VenueLeg memory v = legs[i];
            sum[c.v[i].coll] += v.collateral;
            sum[c.v[i].debt] += v.supplied;
        }
        for (uint256 t; t < sum.length; ++t) {
            if (pooled[t] == 0 || sum[t] <= least[t]) continue;
            if (pass == 1) return 0;
            next = Math.min(next, Math.mulDiv(size, least[t], sum[t]));
        }
        return next;
    }

    /// @dev {_fitVenues}' bound on the borrow legs at the venues of one pair, where two or more draw: together within
    ///      the pair's debt cap less what its venues owe and less `FLAMMGateLib.READ_BACK_UNITS` per leg after the
    ///      first.
    function _pairCapFit(
        Ctx memory c,
        IFLAMM.VenueLeg[] memory legs,
        uint256[] memory debts,
        uint256 den,
        uint256 next,
        uint256 pass
    ) private view returns (uint256) {
        uint256 m = c.p.pairCount();
        (uint256[] memory owed, uint256[] memory used, uint256[] memory count) =
            (new uint256[](m), new uint256[](m), new uint256[](m));
        for (uint256 i; i < legs.length; ++i) {
            IFLAMM.VenueLeg memory v = legs[i];
            used[v.pair] += debts[i];
            if (v.owed == 0) continue;
            owed[v.pair] += v.owed;
            ++count[v.pair];
        }
        for (uint256 p; p < m; ++p) {
            if (count[p] < 2) continue;
            uint256 cap = c.r.pair(address(c.p), uint8(p)).debtCap;
            uint256 k = used[p] + (count[p] - 1) * FLAMMGateLib.READ_BACK_UNITS;
            if (cap == 0 || owed[p] + k <= cap) continue;
            if (pass == 1) return 0;
            next = Math.min(next, cap > k ? Math.mulDiv(cap - k, den, used[p]) : 0);
        }
        return next;
    }

    /// @dev {_fitVenues}' bound on the size from each token's supply cap at the Router: its supply legs together within
    ///      the cap less what its venues lend, a unit over its share each of the venues; up to the size at which every
    ///      supply leg of the token stays in custody (`under`), which no cap bounds ({_tokenCapPass} reads the legs).
    function _tokenCapFit(
        Ctx memory c,
        FLAMMGateLib.Book memory b,
        uint256 den,
        uint256 size,
        uint256[] memory under
    ) private view returns (uint256) {
        for (uint256 t; t < b.legs.length; ++t) {
            uint256 used = b.legs[t].supplied;
            if (used == 0) continue;
            uint256 cap = c.r.token(address(c.p), uint8(t)).supplyCap;
            if (cap == 0) continue;
            uint256 k = used + c.n;
            size = Math.min(size, Math.max(cap > k ? Math.mulDiv(cap - k, den, used) : 0, under[t]));
        }
        return size;
    }

    /// @dev What venue `v` can lend now, within its borrow-rate ceiling (`IFinancingAccount.ceilingBorrowSlice`).
    function _lendable(IMMRouter.VenueView memory v) private view returns (uint256 lend) {
        lend = IFinancingAccount(v.account).borrowable(v.id);
        if (v.maxBorrowRateWad != 0) {
            lend = IFinancingAccount(v.account).ceilingBorrowSlice(v.id, 0, 0, lend, v.maxBorrowRateWad);
        }
    }

    /// @dev The entry's venue legs at `size`, from its preview; `refused` nonzero where the preview refuses a restoring
    ///      leg (`IMMRouter.Unhealthy`: `REFUSED_UNHEALTHY`, which a smaller entry may pass) or a borrow or supply leg
    ///      that leaves a venue under its minimum position (`IMMRouter.InsufficientLiquidity`: `REFUSED_MINIMUM`, which
    ///      only `FLAMMSharedLib.heldLegsCheck` raises on a preview, and which no smaller entry passes, the leg
    ///      shrinking with it). Any other refusal bubbles.
    function _legs(Ctx memory c, uint256 size, bool deposit)
        private
        view
        returns (uint256 refused, IFLAMM.VenueLeg[] memory legs)
    {
        bytes memory e;
        if (deposit) {
            try c.p.previewDepositProRata(size) returns (
                uint256, IFLAMM.VenueLeg[] memory l, uint256[] memory, uint256[] memory
            ) {
                return (0, l);
            } catch (bytes memory x) {
                e = x;
            }
        } else {
            try c.p.previewMintProRata(size) returns (IFLAMM.VenueLeg[] memory l, uint256[] memory, uint256[] memory) {
                return (0, l);
            } catch (bytes memory x) {
                e = x;
            }
        }
        bytes4 s = bytes4(e);
        if (s == IMMRouter.Unhealthy.selector) return (REFUSED_UNHEALTHY, legs);
        if (s == IMMRouter.InsufficientLiquidity.selector) return (REFUSED_MINIMUM, legs);
        assembly ("memory-safe") {
            revert(add(e, 0x20), mload(e))
        }
    }

    /// @dev Adds a venue's `units` of token `t` to that token's sum, and its `free` to the least.
    function _pool(uint256 t, uint256 units, uint256 free, uint256[] memory sums, uint256[] memory least)
        private
        pure
    {
        if (sums[t] == 0 || free < least[t]) least[t] = free;
        sums[t] += units;
    }
}
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.