Verified contractExactUNLICENSED
FLAMMSettleLib
Address0x1834d367bd65af7ccf41d2025758bb69af56e060
- 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,446,216
- Creation transaction
- 0x9572e45a20…c8ae77485a
- Libraries
- src/core/mm/MMRouterLib.sol:MMRouterLib0xa474…d2b4e5src/core/flamm/FLAMMLane.sol:FLAMMLane0x82a0…7f67dfsrc/core/flamm/FLAMMRoute.sol:FLAMMRoute0x312e…0fdaa9src/periphery/FLAMMMaxima.sol:FLAMMMaxima0x4a99…d6259csrc/core/flamm/FLAMMLawLib.sol:FLAMMLawLib0x5d47…27cc62src/core/flamm/FLAMMOpsLib.sol:FLAMMOpsLib0x3bd2…f79a69src/core/mm/AaveV3ReadsLib.sol:AaveV3ReadsLib0xd53f…ed5983src/core/flamm/FLAMMFlowLib.sol:FLAMMFlowLib0xac61…6a909dsrc/core/flamm/FLAMMGateLib.sol:FLAMMGateLib0x2291…64f98csrc/core/flamm/FLAMMKeptLib.sol:FLAMMKeptLib0x7a11…58517bsrc/core/mm/CTokenMarketLib.sol:CTokenMarketLib0xfd87…6df060src/core/flamm/FLAMMAdmitLib.sol:FLAMMAdmitLib0x4aac…e1aed6src/core/flamm/FLAMMBlindLib.sol:FLAMMBlindLib0x9e50…7eeb41src/core/flamm/FLAMMClaimLib.sol:FLAMMClaimLib0xc6c9…da2afesrc/core/flamm/FLAMMFenceLib.sol:FLAMMFenceLib0x739d…5a629fsrc/core/flamm/FLAMMFloatLib.sol:FLAMMFloatLib0xf128…b16b70src/core/flamm/FLAMMQuoteLib.sol:FLAMMQuoteLib0xf284…efd526src/core/flamm/FLAMMTopUpLib.sol:FLAMMTopUpLib0xd561…60c5a5src/core/mm/CTokenRewardsLib.sol:CTokenRewardsLib0xcda6…a4dcf7src/core/mm/MMRouterAdminLib.sol:MMRouterAdminLib0x8423…7adc96src/core/flamm/FLAMMPolicyLib.sol:FLAMMPolicyLib0x6fe6…678097src/core/flamm/FLAMMSettleLib.sol:FLAMMSettleLib0x1834…56e060src/core/flamm/FLAMMSharedLib.sol:FLAMMSharedLib0xfaae…2511basrc/periphery/FLAMMExitMaxima.sol:FLAMMExitMaxima0x480f…4e0a81src/hooks/everlong/LeverageLib.sol:LeverageLib0x1b1d…40ad11src/core/flamm/FLAMMMaintainLib.sol:FLAMMMaintainLib0x5691…f4d380src/core/flamm/FLAMMPairQuoteLib.sol:FLAMMPairQuoteLib0xa0c8…50c3e3src/hooks/everlong/EverlongOpsLib.sol:EverlongOpsLib0xabe4…7426f7
52 files
The source code is large: one file is shown at a time. Choose a file in the list.
- src/core/flamm/FLAMMSettleLib.solmain42.92 KB
- lib/openzeppelin-contracts-compat/contracts/interfaces/draft-IERC6093.sol6.54 KB
- lib/openzeppelin-contracts-compat/contracts/token/ERC20/IERC20.sol2.77 KB
- lib/openzeppelin-contracts-compat/contracts/token/ERC20/extensions/IERC20Metadata.sol683 B
- lib/openzeppelin-contracts-compat/contracts/utils/math/Math.sol12.51 KB
- lib/openzeppelin-contracts-compat/contracts/utils/math/SafeCast.sol35.08 KB
- lib/openzeppelin-contracts-upgradeable-compat/contracts/proxy/utils/Initializable.sol8.91 KB
- lib/openzeppelin-contracts-upgradeable-compat/contracts/token/ERC20/ERC20Upgradeable.sol12.23 KB
- lib/openzeppelin-contracts-upgradeable-compat/contracts/utils/ContextUpgradeable.sol1.19 KB
- src/core/PriceFeed.sol19.12 KB
- src/core/flamm/FLAMM.sol55.76 KB
- src/core/flamm/FLAMMAdmitLib.sol37.35 KB
- src/core/flamm/FLAMMBlindLib.sol44.11 KB
- src/core/flamm/FLAMMClaimLib.sol49.63 KB
- src/core/flamm/FLAMMClaimVault.sol1.65 KB
- src/core/flamm/FLAMMFenceLib.sol72.81 KB
- src/core/flamm/FLAMMFloatLib.sol58.79 KB
- src/core/flamm/FLAMMFlowLib.sol54.32 KB
- src/core/flamm/FLAMMGateLib.sol90.43 KB
- src/core/flamm/FLAMMKeptLib.sol45.86 KB
- src/core/flamm/FLAMMLane.sol70.53 KB
- src/core/flamm/FLAMMLawLib.sol60.67 KB
- src/core/flamm/FLAMMMaintainLib.sol42.7 KB
- src/core/flamm/FLAMMOpsLib.sol32.2 KB
- src/core/flamm/FLAMMPolicyLib.sol39.79 KB
- src/core/flamm/FLAMMQuoteLib.sol17 KB
- src/core/flamm/FLAMMRoute.sol16.45 KB
- src/core/flamm/FLAMMSharedLib.sol13.11 KB
- src/core/flamm/FLAMMStore.sol135.51 KB
- src/core/flamm/FLAMMSwapLib.sol55.76 KB
- src/core/flamm/FLAMMTopUpLib.sol50.7 KB
- src/core/mm/MMRouterAdminLib.sol24.07 KB
- src/core/mm/MMRouterLib.sol72.71 KB
- src/core/mm/VenueAccountBase.sol15.61 KB
- src/core/mm/VenueReads.sol2.05 KB
- src/interfaces/core/IDepositAllowlist.sol1.06 KB
- src/interfaces/core/IEverlongCore.sol889 B
- src/interfaces/core/IPriceFeed.sol3.71 KB
- src/interfaces/core/flamm/IFLAMM.sol52.68 KB
- src/interfaces/core/flamm/IFLAMMHooks.sol8.36 KB
- src/interfaces/core/flamm/IHookCapabilities.sol2.63 KB
- src/interfaces/core/flamm/IPairHook.sol14.14 KB
- src/interfaces/core/mm/IAccountDeployer.sol2.99 KB
- src/interfaces/core/mm/IFinancingAccount.sol46.04 KB
- src/interfaces/core/mm/IHeldRepay.sol2.61 KB
- src/interfaces/core/mm/IMMRouter.sol70.37 KB
- src/interfaces/utils/integrations/IAggregatorV3Interface.sol818 B
- src/libraries/Constants.sol2.11 KB
- src/libraries/DelayLib.sol11.22 KB
- src/libraries/ReentrancyGuardLib.sol2.52 KB
- src/libraries/SafeTransferLib.sol5.11 KB
- src/propamm/libraries/PropAMMLaneLib.sol2.31 KB
src/core/flamm/FLAMMSettleLib.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, LedgerBoundBreached, RoomExhausted, VenueReportsLoss, WAD} from "src/core/flamm/FLAMMStore.sol";
import {FLAMMGateLib} from "src/core/flamm/FLAMMGateLib.sol";
import {FLAMMLawLib} from "src/core/flamm/FLAMMLawLib.sol";
import {FLAMMTopUpLib} from "src/core/flamm/FLAMMTopUpLib.sol";
import {FLAMMKeptLib} from "src/core/flamm/FLAMMKeptLib.sol";
import {FLAMMSharedLib} from "src/core/flamm/FLAMMSharedLib.sol";
import {IMMRouter} from "src/interfaces/core/mm/IMMRouter.sol";
import {VenueReads} from "src/core/mm/VenueReads.sol";
import {ReentrancyGuardLib} from "src/libraries/ReentrancyGuardLib.sol";
/// @notice The settlement of a swap of any listed token `x` for any other `y`, on the book its plan read and priced,
/// whose custody it keeps in memory and writes once.
/// @dev In order:
/// 1. finds or pulls the input (`FLAMMStore.takeIn`) and credits exactly what the fill used;
/// 2. where `x` is owed, repays it with all the custody of it the pool now holds (a token owed at two or more
/// pairs, or with two or more live pairs: the input alone unless that custody clears the whole debt; one owed
/// at two or more: at the cover pair's venues first where there is one), before any release or borrow (a repay
/// reads no price, so a covering swap runs while a market's oracle is dead; a proportional release is proven
/// against the repay's snapshot; and no borrow ever precedes the repay);
/// 3. pays `y` from custody, then from its collateral (what the pin frees, unless a rotation follows, then what
/// the repay freed in proportion), then by the plan's one rotation (the debt `y` backs drawn on the input's
/// pair and repaid at `y`'s, venue by venue, `y` released in proportion, past the custody it keeps for the law
/// at `y`), then by a draw on the plan's payout pair (the backing token's supply withdrawn first as far as the
/// Router's plan and the credit law need it), else from supply alone, else a strict release, which reverts
/// rather than pay partially;
/// 4. lends the input's surplus after the payout, never a token that backs a debt or that it posted;
/// 5. re-reads the book once if a venue moved, marks `x` and `y` debt-free where they owe nothing, and asserts the
/// whole credit law where the payout raised `y`'s net debt or a rotation ran (a draw the Router paid from `y`'s
/// own supply raises none; where the law fails on a plan that may draw, the payout pair's lent backing, which
/// its room counted, is withdrawn as far as the law needs it, and the law read again), the entry gate
/// otherwise;
/// 6. releases `y`'s collateral above the posting law, with hysteresis: a lender that pays in part, or refuses
/// with an eighth of its call's gas to spare, never fails the swap; a release the swap's own gas limit may
/// have starved does, so no limit picks the settlement;
/// 7. writes the custody of every token it moved and reconciles those.
/// While a venue of a frame posting `y` lacks, the plan's ceiling counts `y` there and steps 3 and 6 reclaim it
/// only down to what the frame's venues' triggers ask (`FLAMMTopUpLib.frameBound`). The plan's ceiling counts a
/// rotation's release without that bound, so a rotation that would release more than those frames spare, read
/// before its repays, reverts `RoomExhausted` here, though its quote passed: the caller sends a smaller swap, or
/// the swap goes once the venue that lacks is topped up.
library FLAMMSettleLib {
/// @dev Units of the owed token a rotation repays at a venue over its proportional share: a partial repay by
/// assets can leave the lender's rounding over the exact rest, and the proportional release is sized from the
/// debt the repay left.
uint256 internal constant REPAY_MARGIN = 2;
/// @dev The least a payout draws, in units of the drawn token, the rest held in custody: a lender checks a new
/// borrow's health at its own oracle with floored products, which a slice of a few units posted at the pin can
/// fail; this many units clear them past the pin, the threshold's gap and the oracle's band. Only a short past
/// the drawn token's own supply takes it: one within that supply the Router pays from the supply, borrowing
/// only what its lenders cannot return now.
uint256 internal constant MIN_DRAW = 1_000;
/// @dev The transient word a swap that plans a rotation sets for its settlement and clears after it
/// (`FLAMMSwapLib.run`; a revert drops it with the swap): what the plan's ceiling found of the venues it
/// releases at (`FLAMMLawLib.rotationCapacity`'s `verdicts`), which the rotation takes in place of asking
/// each venue again (`FLAMMTopUpLib.rotate`). It carries no position and no amount: the rotation reads
/// those itself, and proves every release against its repay.
/// - Between the plan's read and the rotation run the hook's fill and the input's transfer, under the pool's
/// lock and the Router's, so no leg of the pool moves a venue there. A lender's own state can still move
/// (another account's repay or post on a venue's behalf, its oracle, its switches).
/// - A venue the word calls sound that no longer is has its repay or its release refused by its lender: a
/// refused repay reverts the swap, a refused release is skipped, and the swap pays the rest as it can or
/// reverts, where asking again would have passed the venue over and released at the next. One the word
/// calls refused is passed over, as the plan counted it.
/// - The credit law is checked whole after every rotation either way.
uint256 internal constant VERDICTS = uint256(keccak256("everlong.flamm.rotation.verdicts")) - 1;
/// @dev Writes {VERDICTS}.
function setVerdicts(uint256 verdicts) internal {
uint256 slot = VERDICTS;
assembly ("memory-safe") {
tstore(slot, verdicts)
}
}
/// @dev Reads {VERDICTS}: zero outside a swap that planned a rotation.
function verdictsOf() internal view returns (uint256 verdicts) {
uint256 slot = VERDICTS;
assembly ("memory-safe") {
verdicts := tload(slot)
}
}
/// @notice What the plan hands the settlement. `x` and `y`: the input's and the output's token indices, whose
/// addresses are `tokenX` and `tokenY`. Pairs are pool pair indices, `FLAMMStore.NO_PAIR` where unused.
/// `asked`: the input the caller named: `used` is at most it. `used`, `out`: the input the fill used and
/// its net output, native units. `to`: who the net goes to.
struct Settle {
uint8 x;
uint8 y;
uint8 borrowPair; // (a -> y): the payout borrows `y` there past custody and collateral
uint8 coverPair; // (y -> x): the input repays this pair's venues first, so their release frees `y`
uint8 rotIn; // (x -> t): a rotation draws the debt token `t` here, posting the input
uint8 rotOut; // (y -> t): and repays it here, releasing `y` in proportion
uint256 asked;
address tokenX;
address tokenY;
uint256 used;
uint256 out;
address to;
// low 128 bits: the custody of `y` a rotation keeps for the law at `y`, zero without one; high 128 bits: the
// fill's protocol part owed in `y` plus the operator's share of it where the pool sets one
// (`FLAMMSwapLib.validate`), an outflow of the pool's own custody into the custody kept for the fee, which
// {settle} funds and moves with the payout, so the law reads it as gone
uint256 keep;
}
/// @dev The settlement's running record: the input's balance as last read, the tokens whose custody moved, the
/// tokens it posted, and whether it rotated.
struct Run {
uint256 balX;
uint256 moved;
uint256 posted;
bool rotated;
}
// ------------------------------------------------------------------ entry
/// @notice The swap's settlement ({FLAMMSettleLib}), then the reconcile of the tokens it moved: the plan's book and
/// the settlement record cross by value.
function settleEntry(FLAMMGateLib.Book memory b, Settle memory s) public {
FLAMMStore.S storage $ = FLAMMStore.s();
(uint256 bal, uint256 moved) = settle($, b, s);
FLAMMStore.reconcileMoved($, moved, s.x, bal);
}
/// @notice Returns the pool's balance of `x` after its input step where no venue moved (zero where one did), which
/// the reconcile reuses, and the tokens whose custody it moved.
function settle(FLAMMStore.S storage $, FLAMMGateLib.Book memory b, Settle memory s)
internal
returns (uint256 bal, uint256 moved)
{
FLAMMGateLib.Leg memory Lx = b.legs[s.x];
FLAMMGateLib.Leg memory Ly = b.legs[s.y];
// The fill's protocol part and the operator's share, in `keep`'s high half, leave the pool's own custody with
// the payout: from here `s.out` is the payout with them; the taker is paid the net alone.
uint256 net = s.out;
if (s.keep >> 128 != 0) (s.out, s.keep) = (net + (s.keep >> 128), s.keep & type(uint128).max);
// The gates' anchor and the paid token's net debt, before anything moves.
(uint256[] memory u0, uint256[] memory g0, uint256[] memory d0, uint256[] memory o0) = FLAMMLawLib.anchorOf(b);
uint256 uy = FLAMMGateLib.netDebt(Ly);
Run memory w;
bool venues;
w.balX = FLAMMStore.takeIn(s.tokenX, FLAMMGateLib.tracked(Lx), s.asked, s.used);
Lx.held += s.used;
// DO NOT REORDER: the repay comes before any release and any borrow (see above).
uint256[] memory pre;
if (Lx.owed != 0) {
pre = _repayInput($, b, s, w);
venues = true;
}
if (Ly.held < s.out + s.keep) {
_pay($, b, s, pre, w);
venues = true;
}
Ly.held -= s.out;
FLAMMStore.safeTransfer(s.tokenY, s.to, net);
if (_lend($, b, s.x, s.tokenX, w.posted)) venues = true;
// a priced swap (a pool with a band) re-reads, marks and runs the gates
bool gated = b.usd[s.y] != 0;
if (venues && gated) {
// The read returns the idle record it skipped, which the debt-free marks leave as it is (each writes its
// token's word); a token is marked only where it owes nothing and some live pair owes it.
uint32 idle = FLAMMGateLib.reread($, b);
if (Lx.partner != FLAMMStore.NO_PARTNER && Lx.owed == 0) FLAMMGateLib.markDebtFreeOf($, b, s.x);
if (Ly.partner != FLAMMStore.NO_PARTNER && Ly.owed == 0) FLAMMGateLib.markDebtFreeOf($, b, s.y);
FLAMMGateLib.markIdleFrom($, idle, b.empty);
}
if (gated) {
// A payout that raised the net debt of the token it pays drew credit, and a rotation drew at the input:
// the law itself, the whole of it (a rotation runs only on a book inside it, `FLAMMLawLib.rotationPlan`).
// One the Router paid from that token's own supply drew none, as its room let it on a book over the law.
// Any other swap moves collateral toward custody or repays: the entry gate, which a deleveraging swap
// clears on a book over the law, and which refuses any token drawn now that was not at the anchor.
if (FLAMMGateLib.netDebt(Ly) > uy || w.rotated) {
if (!FLAMMLawLib.lawAt($, b, FLAMMLawLib.NONE, 0)) {
// a plan that may draw: its room counted the lent backing ({_lentLaw})
if (s.borrowPair == FLAMMStore.NO_PAIR || !_lentLaw($, b, s, w) || !FLAMMLawLib.lawAt($, b, FLAMMLawLib.NONE, 0)) {
revert LedgerBoundBreached();
}
venues = true;
}
} else if (FLAMMGateLib.owes(b)) {
FLAMMLawLib.entryGateAt($, b, u0, g0, d0, o0, 0, LedgerBoundBreached.selector);
}
// A release moves posted collateral to custody one for one, changing no net debt or backing, so it cannot
// change the verdict.
if (Ly.posted != 0) _releaseExcess($, b, s.y);
}
moved = w.moved | (uint256(1) << s.x) | (uint256(1) << s.y);
_flush($, b, moved);
bal = venues ? 0 : w.balX;
}
/// @dev Step 2: the input repays its own debt with all the custody of it; where the input is owed at two or more
/// pairs, or has two or more live pairs, with the input alone unless that custody clears the whole debt (never
/// the custody that nets its other debts, so the share of its debt it nets cannot fall and the monotone gate
/// reads no ratio worse, nor the custody another live pair pays its sellers from); where it is owed at two or
/// more pairs, at the cover pair's venues first where there is one, so their release frees the output; then
/// the cascade. Each venue repay offers what the grant has left, and passes over a venue that refuses repays,
/// as the cascade does: a venue that takes less of it than the Router pulled returns the rest to custody,
/// where it stays. Returns the cover pair's venues' (debt, collateral) before the repay where the payout may
/// need what the repay frees.
function _repayInput(FLAMMStore.S storage $, FLAMMGateLib.Book memory b, Settle memory s, Run memory w)
private
returns (uint256[] memory pre)
{
FLAMMGateLib.Leg memory Lx = b.legs[s.x];
IMMRouter r = $.router;
if (s.coverPair != FLAMMStore.NO_PAIR && b.legs[s.y].held < s.out && Lx.held < Lx.owed) {
pre = _venuesOf($, s.coverPair);
}
bool many = Lx.partner == FLAMMStore.MANY;
uint256 pay = Lx.owed < Lx.held ? Lx.owed : Lx.held;
if (pay > s.used && pay < Lx.owed && (many || FLAMMGateLib.split(b, s.x))) pay = s.used;
FLAMMStore.approveRouter($, s.tokenX, pay);
uint256 left = pay;
if (many && s.coverPair != FLAMMStore.NO_PAIR) {
uint256 mask = $.pairs[s.coverPair].venues;
for (uint256 i; mask >> i != 0 && left != 0; ++i) {
if ((mask >> i) & 1 == 0 || FLAMMGateLib.repayRefused($, i)) continue;
r.repay(uint16(i), left);
left = FLAMMStore.granted($, s.tokenX);
}
}
// The cascade pulls at most the grant, so one that repaid all of it spent it: no allowance is left to read.
if (left != 0 && r.repayCascade(s.x, left) != left) FLAMMStore.revoke($, s.tokenX);
uint256 after_ = FLAMMStore.balanceOfThis(s.tokenX);
// the repay off the input's custody and its debt, so a crossing's draw reads the input as cleared
(Lx.held, Lx.owed) = (Lx.held - (w.balX - after_), Lx.owed - (w.balX - after_));
w.balX = after_;
}
/// @dev Step 3: the output's short past custody (with the fill's protocol part, the operator's share and the
/// custody a rotation keeps), into custody, as its balance shows.
function _pay(
FLAMMStore.S storage $,
FLAMMGateLib.Book memory b,
Settle memory s,
uint256[] memory pre,
Run memory w
) private {
FLAMMGateLib.Leg memory Ly = b.legs[s.y];
uint256 short = s.out + s.keep - Ly.held;
(IMMRouter r, uint256 pooled) = ($.router, $.gatedVenues);
uint256 before = FLAMMStore.balanceOfThis(s.tokenY);
if (Ly.posted != 0) {
// A rotation releases in proportion to its repays alone: a reclaim first would pay out collateral it then
// sizes against.
if (s.rotIn == FLAMMStore.NO_PAIR) {
uint256 take = pooled == 0 ? short : FLAMMTopUpLib.frameBound(b, s.y, short, FLAMMStore.NO_PAIR);
short -= r.reclaimBestEffort(s.y, take, b.usd);
}
if (short != 0 && pre.length != 0) short -= releaseRepaid($, short, pre, b.usd);
}
if (short != 0 && s.rotIn != FLAMMStore.NO_PAIR) {
// A rotation's releases are proven against each venue's own ratio alone, and at a frame's account a
// venue's collateral over its trigger may be what a mate stands on. The plan's ceiling counts them
// whole, so one that would take more than the frames posting `y` spare does not run.
if (pooled != 0 && FLAMMTopUpLib.frameBound(b, s.y, short, FLAMMStore.NO_PAIR) != short) {
revert RoomExhausted();
}
short -= _rotate($, b, s, short, w);
}
if (short != 0) {
if (s.borrowPair != FLAMMStore.NO_PAIR) _borrow($, b, s, short, w);
else if (Ly.partner != FLAMMStore.NO_PARTNER) _withdrawOnly($, b, s.y, short);
else {
// The plan's ceiling reads a cover's venues as repaid in full, and a repay can land short of that or
// elsewhere: what still reaches this walk takes no more of a frame than it spares.
if (pooled != 0 && FLAMMTopUpLib.frameBound(b, s.y, short, FLAMMStore.NO_PAIR) != short) {
revert RoomExhausted();
}
r.reclaim(s.y, short, b.usd);
}
}
Ly.held += FLAMMStore.balanceOfThis(s.tokenY) - before;
}
/// @dev The rotation, out of line (`FLAMMTopUpLib.rotate`): what it released of `y`, the input's custody it
/// posted and the owed token's custody it moved written back to `b`.
function _rotate(FLAMMStore.S storage $, FLAMMGateLib.Book memory b, Settle memory s, uint256 short, Run memory w)
private
returns (uint256 got)
{
uint256 t = $.pairs[s.rotOut].debt;
FLAMMGateLib.Leg memory Lx = b.legs[s.x];
// the rotation's draw posts the input's custody at its pair, as a payout's draw posts ({_borrow})
requireNoLossAt($, s.rotIn);
uint256 spent;
uint256 heldT;
(got, spent, heldT) = FLAMMTopUpLib.rotate(s.rotIn, s.rotOut, s.tokenX, Lx.held, short, b.usd);
(Lx.held, w.balX) = (Lx.held - spent, w.balX - spent);
b.legs[t].held += heldT;
(w.moved, w.posted, w.rotated) = (w.moved | (uint256(1) << t), w.posted | (uint256(1) << s.x), true);
}
/// @dev Borrows `short` of `y` on `borrowPair` (a -> y), at least `MIN_DRAW` where `short` is past `y`'s supply
/// (the rest held in custody, which nets the debt it adds; a short within that supply takes no floor, and
/// `fund` pays it from the supply, borrowing only what its lenders cannot return now), posting what the pool
/// holds of `a`: `y`'s debt-free flag cleared and the pair's venues woken first. Where `a` is lent, its supply
/// is withdrawn first as far as the Router's own plan posts it (`IMMRouter.fundingCollateral`, at this pair's
/// venues alone, with its rounding) and as far as the credit law needs it at `a` after the draw
/// ({_lawShortfall}), on recognized collateral: the room counted that supply as backing. `fund` plans after
/// the withdrawal, which can free room under the posting market's supply cap and lower its collateral reads,
/// so it runs at the custody the withdrawal leaves, the pool's grant: it posts no more than that, and refuses
/// what that cannot post. No draw runs while a venue of the pair that borrows reports a loss on its collateral
/// or takes a redemption fee on it ({requireNoLossAt}); that check runs before `fund`, so it refuses a payout
/// the pair's supply would pay too.
function _borrow(FLAMMStore.S storage $, FLAMMGateLib.Book memory b, Settle memory s, uint256 short, Run memory w)
private
{
requireNoLossAt($, s.borrowPair);
FLAMMStore.PairCfg storage pc = $.pairs[s.borrowPair];
uint256 a = pc.coll;
FLAMMGateLib.Leg memory La = b.legs[a];
FLAMMStore.TokenCfg storage cy = $.tokens[s.y];
// The fund below borrows `y`: its flag is cleared first, and only a position read after the flow sets it again.
if (cy.debtFree) cy.debtFree = false;
FLAMMGateLib.wake($, pc.venues);
address tokenA = FLAMMStore.tokenOf($, a);
uint256 coll = La.held;
if (short < MIN_DRAW && short > b.legs[s.y].supplied) short = MIN_DRAW;
if (La.supplied != 0) {
uint256 got;
(coll, got) = _withdrawBacking($, b, s, short, tokenA);
La.held += got;
if (a == s.x) w.balX += got;
}
// The grant is the whole custody of the backing token and is never used up, so it is reset without a read.
uint256 balA = a == s.x ? w.balX : FLAMMStore.balanceOfThis(tokenA);
if (La.held != 0) FLAMMStore.approveRouter($, tokenA, La.held);
$.router.fund(s.borrowPair, short, address(this), coll, b.usd);
if (La.held != 0) {
FLAMMStore.approveRouter($, tokenA, 0);
La.held -= balA - FLAMMStore.balanceOfThis(tokenA);
}
(w.moved, w.posted) = (w.moved | (uint256(1) << a), w.posted | (uint256(1) << a));
}
/// @dev Reverts `VenueReportsLoss` where a venue of pair `pair` that borrows reports a loss on its collateral of
/// `FLAMMStore.LOSS_MOVE_FLOOR` or more (`FLAMMKeptLib.lossAtFloor`: the larger of the lender's ratio now and
/// the venue's loss mark, read as stored, no mark written), or takes a redemption fee of any size on it
/// (`FLAMMStore.LOSS_LEG_FEES`): a draw there posts custody of the collateral token, sized by the caller's
/// swap, and NAV, which counts custody at par and cuts what is posted by that ratio, would fall by the ratio's
/// share of the post in the caller's transaction and rise again with the swap back. Under a fee NAV falls by
/// the fee's share of the post at the draw, the post being about the draw over the pair's pin, and nothing
/// returns it: at a fee venue that owed nothing the caller's own swap back clears the whole debt and the
/// release of the post pays the fee to the lender, so any caller could repeat the round trip with no limit; at
/// one that owes the swap back leaves the post in place, which spends the custody the exits are paid from. So
/// no draw runs at a pair while one of its venues that borrows stands under a fee: a pair with no other venue
/// that borrows draws nothing until the fee ends. The operator frees the pair's other venues by turning that
/// venue's borrowing off, a tightening that lands at once. The guardian can make the cure too. Switching the
/// borrowing back on waits the pool's delay where the cheap lane is on (`FLAMMPolicyLib.setVenueFlags`) and
/// must clear the dust gap. The pair's own borrow switch off (`FLAMMStore.PairCfg.borrowOff`) leaves the
/// payouts its supply pays, as no venue of it lends then. Read only on a pool that lists a venue whose kind
/// reports a loss (`FLAMMStore.LOSS_MARKS`): elsewhere a draw pays the flag's test alone. The quote
/// (`FLAMMPairQuoteLib`) calls this same check where its plan reaches a draw or a rotation.
function requireNoLossAt(FLAMMStore.S storage $, uint256 pair) internal view {
if (
$.features & FLAMMStore.LOSS_MARKS != 0
&& FLAMMKeptLib.lossAtFloor($.pairs[pair].venues, FLAMMStore.LOSS_LEG_BORROW | FLAMMStore.LOSS_LEG_FEES)
) revert VenueReportsLoss();
}
/// @dev A payout on a plan that may draw, past the credit law: its room counted the payout pair's lent backing `a`,
/// which only a draw's funding withdraws ({_withdrawBacking}), so where custody and releases paid `y` and
/// nothing drew, what the law lacks at `a` is withdrawn into custody, at most what is lent (after a draw, past
/// what its funding withdrew). Whether it withdrew.
function _lentLaw(FLAMMStore.S storage $, FLAMMGateLib.Book memory b, Settle memory s, Run memory w)
private
returns (bool)
{
uint8 a = $.pairs[s.borrowPair].coll;
FLAMMGateLib.Leg memory La = b.legs[a];
if (La.supplied == 0 || b.legs[s.y].owed == 0) return false;
uint256 need = FLAMMLawLib.backingNeed($, b, a);
uint256 have = FLAMMGateLib.backing(La);
if (need <= have) return false;
uint256 take = need - have;
if (take > La.supplied) take = La.supplied;
address tokenA = FLAMMStore.tokenOf($, a);
uint256 b0 = FLAMMStore.balanceOfThis(tokenA);
$.router.withdrawCascade(a, take, address(this));
uint256 got = FLAMMStore.balanceOfThis(tokenA) - b0;
La.held += got;
if (a == s.x) w.balX += got;
w.moved |= uint256(1) << a;
return true;
}
/// @dev {_borrow}'s withdrawal of lent backing token `a` (`tokenA`): the larger of what the Router's plan posts
/// past custody and the law's shortfall at `a` after the draw, at most what is lent; the collateral bound
/// `fund` then runs at, the custody the withdrawal leaves, which is the pool's grant (custody and supply
/// together where it withdraws nothing: the plan read then posts within custody), and what it withdrew. A
/// withdrawal from a market the pair posts at frees room under that market's supply cap, which `fund`,
/// planning after it, would fill past the plan read, moving the draw onto that venue and off one that needed
/// no post; and it lowers a post's collateral read there by up to one unit's assets and one per leg
/// (`IFinancingAccount` ADMISSION), so `fund` posts that much more: the plan's part carries that much more
/// too, a unit's assets and one per accruing venue of the pair for each venue of the pool, which the custody
/// keeps where `fund` posts less.
function _withdrawBacking(
FLAMMStore.S storage $,
FLAMMGateLib.Book memory b,
Settle memory s,
uint256 short,
address tokenA
) private returns (uint256 bound, uint256 got) {
IMMRouter r = $.router;
uint8 pair = s.borrowPair;
uint8 a = $.pairs[pair].coll;
FLAMMGateLib.Leg memory La = b.legs[a];
(uint256 held, uint256 supplied) = (La.held, La.supplied);
bound = held + supplied;
uint256 take = r.fundingCollateral(address(this), pair, short, bound, b.usd);
if (take > held) {
take = take - held
+ FLAMMSharedLib.roundingAllowance($, $.pairs[pair].venues) * r.venueCount(address(this));
} else {
take = 0;
}
uint256 law = _lawShortfall($, b, s, short, a);
if (law > take) take = law;
if (take > supplied) take = supplied;
if (take == 0) return (bound, 0);
uint256 b0 = FLAMMStore.balanceOfThis(tokenA);
r.withdrawCascade(a, take, address(this));
got = FLAMMStore.balanceOfThis(tokenA) - b0;
bound = held + got;
}
/// @dev The backing `a` lacks for the credit law after a draw of `short` of `y` funds the payout: the load at `a`
/// with `y` owing `short` more at the draw's pair, and `FLAMMGateLib.READ_BACK_UNITS` more per venue of it (a
/// lender reads a new borrow back up to that high, which the room shaves too), and holding nothing past the
/// payout, over what `a` holds and posts, less what the posts lose: at each venue of the pair whose collateral
/// accrues, a post reads back up to one unit's assets and one low (`CAP_ACCRUING_COLLATERAL`, the lender's
/// share rounding). Where `y` owes at another pair, the draw is a second one: `y` reads as owed at two or
/// more, each pair's debt apart, as the law will read it.
function _lawShortfall(FLAMMStore.S storage $, FLAMMGateLib.Book memory b, Settle memory s, uint256 short, uint256 a)
private
view
returns (uint256)
{
FLAMMGateLib.Leg memory Ly = b.legs[s.y];
uint8 bp = s.borrowPair;
for (uint256 m = $.pairs[bp].venues; m != 0; m &= m - 1) short += FLAMMGateLib.READ_BACK_UNITS;
(uint256 owed, uint256 held, uint8 partner, uint8 pair) = (Ly.owed, Ly.held, Ly.partner, Ly.pair);
(uint256 many, uint256 backs) = (b.many, b.backs);
bool second = owed != 0 && (partner == FLAMMStore.MANY || pair != bp);
if (second) {
// a token with two or more live pairs: its book reads each pair's debt
if (partner != FLAMMStore.MANY) b.backs |= uint256(1) << partner;
(Ly.partner, b.many, b.backs) = (FLAMMStore.MANY, many | (uint256(1) << s.y), b.backs | (uint256(1) << a));
b.pairOwed[bp] += short;
} else {
(Ly.partner, Ly.pair) = (uint8(a), bp);
}
(Ly.owed, Ly.held) = (owed + short, 0);
uint256 need = FLAMMLawLib.backingNeed($, b, a);
(Ly.owed, Ly.held, Ly.partner, Ly.pair) = (owed, held, partner, pair);
(b.many, b.backs) = (many, backs);
if (second) b.pairOwed[bp] -= short;
need += FLAMMSharedLib.roundingAllowance($, $.pairs[bp].venues);
uint256 have = FLAMMGateLib.backing(b.legs[a]);
return need > have ? need - have : 0;
}
/// @dev Withdraws `short` of `y` from supply alone, through a pair that owes it, at no price, which borrows
/// nothing. With a minimum supply batch set, it also refills custody to the reserve target, within what is
/// supplied, so the next payouts come from custody. The refill is best effort: a venue short of the cash for
/// it still pays the shortfall alone, as `fund` would without it. A batch at its maximum lends nothing and
/// refills nothing, so the guardian can stop both.
function _withdrawOnly(FLAMMStore.S storage $, FLAMMGateLib.Book memory b, uint256 y, uint256 short) private {
FLAMMGateLib.Leg memory Ly = b.legs[y];
uint256[] memory none = new uint256[](b.usd.length);
uint8 pair = Ly.pair; // a live pair that owes `y`, its first where it has two or more
if (Ly.supplied > short) {
FLAMMStore.TokenCfg storage cy = $.tokens[y];
uint256 batch = cy.minSupplyBatch;
uint256 extra = Math.min(cy.reserveTarget, Ly.supplied - short);
if (batch != 0 && batch != type(uint128).max && extra != 0) {
try $.router.fund(pair, short + extra, address(this), 0, none) {
return;
} catch {}
}
}
$.router.fund(pair, short, address(this), 0, none);
}
/// @dev Step 4: lends the surplus of the input `x` over its reserve target, at least one batch, at the venues that
/// lend it, when the pool is unpaused, has a live venue and `FEATURE_SUPPLY_LENDING` is set, `x` backs no
/// debt after the swap and was not posted by it (`posted`), and no venue that would take it reports a loss on
/// its supply (`FLAMMKeptLib.lendReportsLoss`): the surplus then stays in custody. Lending is risk-increasing, so it honours the
/// pool's own pause (`supplyCascade` reads only the global one), and it runs after the payout. The pool asset
/// lends only where its bit says its batch allows it. A surplus under the batch stays in custody until a later
/// input lifts it to the batch. `lent`: the cascade ran, whatever the venues took, so the settlement re-reads
/// the book.
function _lend(FLAMMStore.S storage $, FLAMMGateLib.Book memory b, uint256 x, address tokenX, uint256 posted)
private
returns (bool lent)
{
FLAMMGateLib.Leg memory Lx = b.legs[x];
if (Lx.partner == FLAMMStore.NO_PARTNER) return false;
uint256 features = $.features;
if ($.paused || $.noLiveVenue || features & FLAMMStore.FEATURE_SUPPLY_LENDING == 0) return false;
if (x == 0 && $.poolBits & FLAMMStore.POOL_ASSET_LENDS == 0) return false;
if ((posted >> x) & 1 != 0 || FLAMMGateLib.backsDebt(b, x)) return false;
FLAMMStore.TokenCfg storage cx = $.tokens[x];
// the fee owed past custody (`Lx.fee`'s low half) stays in custody beside the target: custody covers it before
// anything is lent; both are custody amounts, under 2^128
uint256 target;
unchecked {
target = cx.reserveTarget + uint128(Lx.fee);
}
uint256 excess = Lx.held > target ? Lx.held - target : 0;
if (excess == 0 || excess < cx.minSupplyBatch) return false;
// nothing is lent while a venue that would take it reports a loss on its supply: NAV cuts what is lent there
// and counts custody at par, so the lend would lower NAV by the loss's share of it, in a call anyone makes.
// Read only on a pool that lists a venue whose kind reports a loss.
if (features & FLAMMStore.LOSS_MARKS != 0 && FLAMMKeptLib.lendReportsLoss(x)) return false;
// `supplyCascade` is keyed by token: every pair that owes `x` may take it, so each one's venues wake
if ($.poolBits & FLAMMStore.POOL_MULTI == 0) {
FLAMMGateLib.wake($, $.pairs[Lx.pair].venues);
} else {
(uint256 pairs,) = FLAMMStore.lanes($, x);
for (uint256 p; pairs >> p != 0; ++p) {
if ((pairs >> p) & 1 != 0) FLAMMGateLib.wake($, $.pairs[p].venues);
}
}
uint256 before = FLAMMStore.balanceOfThis(tokenX);
FLAMMStore.approveRouter($, tokenX, excess);
// as the repay's: a cascade that supplied the whole grant spent it
if ($.router.supplyCascade(uint8(x), excess) != excess) FLAMMStore.revoke($, tokenX);
Lx.held -= before - FLAMMStore.balanceOfThis(tokenX);
return true;
}
/// @dev Each venue's (debt, collateral) of `pair`, interleaved by venue id, as `repay` snapshots them: nothing
/// moves a venue between this read and the repay.
function _venuesOf(FLAMMStore.S storage $, uint8 pair) private view returns (uint256[] memory pre) {
uint256 mask = $.pairs[pair].venues;
uint256 n = span(mask);
pre = new uint256[](2 * n);
IMMRouter r = $.router;
for (uint256 i; i < n; ++i) {
if ((mask >> i) & 1 == 0) continue;
(uint256 c,,,, uint256 d) = r.venuePosition(address(this), uint16(i));
(pre[2 * i], pre[2 * i + 1]) = (d, c);
}
}
/// @notice The venue ids a mask spans: one past its highest set bit, zero for none.
function span(uint256 mask) internal pure returns (uint256 n) {
while (mask >> n != 0) ++n;
}
/// @dev Up to `short` of the collateral token from the venues the repay reduced, each at most what keeps its
/// debt/collateral at or under its ratio before the repay ({_repaidSurplus}). The Router proves that against
/// its repay snapshot, so it reads no price and needs no room above the pin. The market still checks the
/// venue's health on every withdrawal, at the venue's own oracle: a venue the release would leave past its
/// threshold, or whose oracle reverts while it has debt, refuses and is skipped; what the venue cannot release
/// now stays posted, and only what the Router released counts. `usd`: the swap's price vector, which the
/// proportional release carries but does not read.
function releaseRepaid(FLAMMStore.S storage $, uint256 short, uint256[] memory pre, uint256[] memory usd)
internal
returns (uint256 got)
{
for (uint256 i; 2 * i < pre.length && got < short; ++i) {
uint256 take = _repaidSurplus($, uint16(i), pre[2 * i], pre[2 * i + 1]);
if (take > short - got) take = short - got;
if (take == 0) continue;
try $.router.withdrawCollateral(uint16(i), take, usd, true) returns (uint256 released) {
got += released;
} catch {}
}
}
/// @dev What venue `id` may release after a repay from debt `d0` and collateral `c0`: the collateral above what
/// keeps its debt/collateral at or under `d0 / c0`, at most its recognized collateral; nothing where the repay
/// did not lower its debt.
function _repaidSurplus(FLAMMStore.S storage $, uint16 id, uint256 d0, uint256 c0)
private
view
returns (uint256 take)
{
if (d0 == 0) return 0;
(uint256 c, uint256 rec,,, uint256 d) = $.router.venuePosition(address(this), id);
if (d >= d0) return 0;
uint256 keep = Math.mulDiv(d, c0, d0, Math.Rounding.Up);
take = c > keep ? c - keep : 0;
if (take > rec) take = rec;
}
/// @dev Opportunistic release of `y`'s posted collateral above the posting law (every debt it backs at its pair's
/// LTV and price scale, a token owed at two or more pairs at each such pair's debt), with hysteresis; a
/// lender's refusal or part payment is never a reason to fail the caller, a release the caller's own gas limit
/// may have starved is: the Router's walk reverts `VenueReads.ReadStarved` where a venue's release or read
/// failed short of gas, and runs out of gas where the walk itself did, and on either the swap reverts
/// `ReadStarved` (the front's starvation rule), so a higher limit settles whole where the swap fits the gas
/// one transaction may take (EIP-7825), and a swap whose release takes it past that gas reverts at every limit
/// while the release is due, where no venue's release alone takes three million gas (a release that began with
/// that much and failed starved ends the walk as the lender's burn: `reclaim`), as nothing on chain bounds
/// that gas (the Router's `MAX_VENUES`). A debt at an unchecked price releases nothing. With `y`'s collateral
/// reserve rule on it only refills custody to the reserve, once custody has fallen a tenth of it short, and
/// leaves the rest posted (`FLAMMPolicyLib.setCollateralReserve`). While a frame posting `y` has a venue that lacks, no
/// more than that frame spares (`FLAMMTopUpLib.frameBound`), read after the repay, so a swap paying `y` never
/// takes that venue's cover. What it reclaims is added to `b`'s custody, which the swap writes after it.
function _releaseExcess(FLAMMStore.S storage $, FLAMMGateLib.Book memory b, uint256 y) private {
FLAMMGateLib.Leg memory Ly = b.legs[y];
uint256 need;
for (uint256 t; t < b.legs.length; ++t) {
FLAMMGateLib.Leg memory L = b.legs[t];
if (L.partner != y || L.owed == 0) continue;
uint256 p = FLAMMGateLib.frameOf(b, y, t);
if (p == 0) return;
need += FLAMMGateLib.requiredPosted(L.owed, $.pairs[L.pair].ltvWad, p);
}
for (uint256 r; r < b.pairOwed.length; ++r) {
uint256 d = b.pairOwed[r];
if (d == 0) continue;
FLAMMStore.PairCfg storage pc = $.pairs[r];
if (pc.coll != y || b.legs[pc.debt].partner != FLAMMStore.MANY) continue;
uint256 p = FLAMMGateLib.frameOf(b, y, pc.debt);
if (p == 0) return;
need += FLAMMGateLib.requiredPosted(d, pc.ltvWad, p);
}
if (Ly.posted <= need) return;
uint256 excess = Ly.posted - need;
if (Math.mulDiv(excess, WAD, Ly.posted) < FLAMMStore.RELEASE_HYSTERESIS_WAD) return;
// The switch shares a word the swap has read; the rule's own word is read only while it is on.
uint256 reserve = $.poolBits & FLAMMStore.POOL_RESERVE_ON != 0 ? $.reserves[y].reserve : 0;
if (reserve != 0) {
uint256 short = reserve > Ly.held ? reserve - Ly.held : 0;
if (Math.mulDiv(short, WAD, reserve) < FLAMMStore.RELEASE_HYSTERESIS_WAD) return;
if (short < excess) excess = short;
}
(IMMRouter r, uint256 pooled) = ($.router, $.gatedVenues);
if (pooled != 0) {
excess = FLAMMTopUpLib.frameBound(b, y, excess, FLAMMStore.NO_PAIR);
if (excess == 0) return;
}
address tokenY = FLAMMStore.tokenOf($, y);
uint256 before = FLAMMStore.balanceOfThis(tokenY);
uint256 g = gasleft();
try r.reclaimBestEffort(uint8(y), excess, b.usd) returns (uint256) {
Ly.held += FLAMMStore.balanceOfThis(tokenY) - before;
} catch {
// A revert of `ReadStarved`, or one that hands back under an eighth of the gas, is the caller's limit,
// read while the return buffer holds it; any other is the lenders', and the collateral stays posted.
bool starved = gasleft() < g / 8;
bytes4 sel = VenueReads.ReadStarved.selector;
bytes4 lockSel = ReentrancyGuardLib.Reentrant.selector;
bool locked;
assembly ("memory-safe") {
if eq(returndatasize(), 4) {
returndatacopy(0, 0, 4)
starved := or(starved, eq(shr(224, mload(0)), shr(224, sel)))
locked := eq(shr(224, mload(0)), shr(224, lockSel))
}
}
// the Router's lock, held by a callback, is no lender's failure: it passes on
if (locked) revert ReentrancyGuardLib.Reentrant();
if (starved) revert VenueReads.ReadStarved();
}
}
/// @dev The custody of every token the settlement moved: the custody word whole, the pool's own (`FLAMMLane.post`
/// adds back what custody keeps of the fee owed in its two tokens), and each moved token past 1 tracked whole,
/// what custody keeps of the fee owed in it included (`FLAMMGateLib.tracked`).
function _flush(FLAMMStore.S storage $, FLAMMGateLib.Book memory b, uint256 moved) private {
FLAMMStore.setCustody($, b.legs[0].held, b.legs[1].held);
moved >>= 2;
for (uint256 t = 2; moved != 0; ++t) {
if (moved & 1 != 0) $.tokens[t].heldRest = FLAMMGateLib.tracked(b.legs[t]);
moved >>= 1;
}
}
}
Compiler settingsShow
{
"viaIR": true,
"metadata": {
"appendCBOR": true,
"bytecodeHash": "ipfs",
"useLiteralContent": false
},
"libraries": {
"src/core/mm/MMRouterLib.sol": {
"MMRouterLib": "0xA4749766934833DfBeaF4Fc0d79c150A1Dd2B4E5"
},
"src/core/flamm/FLAMMLane.sol": {
"FLAMMLane": "0x82a048459DF53186031Fd66507B260EeaC7F67df"
},
"src/core/flamm/FLAMMRoute.sol": {
"FLAMMRoute": "0x312ee92ecd113F925dD513d450b062C8740fDaA9"
},
"src/periphery/FLAMMMaxima.sol": {
"FLAMMMaxima": "0x4A997343D91c981BF63274fc222AA96D32d6259c"
},
"src/core/flamm/FLAMMLawLib.sol": {
"FLAMMLawLib": "0x5D473B15E032756Cd81fc66B8F1e9BE2f427cc62"
},
"src/core/flamm/FLAMMOpsLib.sol": {
"FLAMMOpsLib": "0x3Bd2B976e70C0D6ea7eb041e36ad525F66F79A69"
},
"src/core/mm/AaveV3ReadsLib.sol": {
"AaveV3ReadsLib": "0xD53F6170226A74D453e84414Ffc2FFcE5ded5983"
},
"src/core/flamm/FLAMMFlowLib.sol": {
"FLAMMFlowLib": "0xAC619698656d47651EF67a050859578e176A909D"
},
"src/core/flamm/FLAMMGateLib.sol": {
"FLAMMGateLib": "0x2291F5e012B0740468E2e2E9AeA37F7Fea64F98c"
},
"src/core/flamm/FLAMMKeptLib.sol": {
"FLAMMKeptLib": "0x7a11899232dd9F17c28bF062Ec2ee2267158517b"
},
"src/core/mm/CTokenMarketLib.sol": {
"CTokenMarketLib": "0xfD87dcDDdc9b4eCe3F2413A858B265D8Ec6dF060"
},
"src/core/flamm/FLAMMAdmitLib.sol": {
"FLAMMAdmitLib": "0x4AAcA346B9430656eB1316094cea0Df0f2e1AED6"
},
"src/core/flamm/FLAMMBlindLib.sol": {
"FLAMMBlindLib": "0x9E5010D8393EB299b6FEce8EB160b3826f7eEb41"
},
"src/core/flamm/FLAMMClaimLib.sol": {
"FLAMMClaimLib": "0xC6C94A120AC43f689BD8D8444dFf300eb9Da2aFe"
},
"src/core/flamm/FLAMMFenceLib.sol": {
"FLAMMFenceLib": "0x739D84c7662030d5Ed8C6BA7606152977D5A629f"
},
"src/core/flamm/FLAMMFloatLib.sol": {
"FLAMMFloatLib": "0xf128B7AdB5bF43814D595E3d1fC95a1f2bB16b70"
},
"src/core/flamm/FLAMMQuoteLib.sol": {
"FLAMMQuoteLib": "0xF284B0271EA829F3a15f005BB588b7Df4bEFd526"
},
"src/core/flamm/FLAMMTopUpLib.sol": {
"FLAMMTopUpLib": "0xD56127118C7619e4a13713Fb4280Cf66D560C5A5"
},
"src/core/mm/CTokenRewardsLib.sol": {
"CTokenRewardsLib": "0xcda63d7eCCF838F2732Bff676706BDE5abA4DcF7"
},
"src/core/mm/MMRouterAdminLib.sol": {
"MMRouterAdminLib": "0x8423744b3F304ED0B43043d7ad4E7d8A247aDc96"
},
"src/core/flamm/FLAMMPolicyLib.sol": {
"FLAMMPolicyLib": "0x6FE69Ed6659A547da6100225Cd0616CfDB678097"
},
"src/core/flamm/FLAMMSettleLib.sol": {
"FLAMMSettleLib": "0x1834d367BD65AF7CCf41D2025758bB69Af56e060"
},
"src/core/flamm/FLAMMSharedLib.sol": {
"FLAMMSharedLib": "0xFaAEd38962aEb6c282Ac36E0cdE9313AbA2511ba"
},
"src/periphery/FLAMMExitMaxima.sol": {
"FLAMMExitMaxima": "0x480f51866554e92649c9d3502bA31AA4234e0a81"
},
"src/hooks/everlong/LeverageLib.sol": {
"LeverageLib": "0x1B1D1C42d26c169dB59D8681d0FD4C9a2840Ad11"
},
"src/core/flamm/FLAMMMaintainLib.sol": {
"FLAMMMaintainLib": "0x5691dc81338DFdF5e4E76Fccb79e38540ff4D380"
},
"src/core/flamm/FLAMMPairQuoteLib.sol": {
"FLAMMPairQuoteLib": "0xa0c8489D5a572eAeAeEDDf48cb888c20A950c3E3"
},
"src/hooks/everlong/EverlongOpsLib.sol": {
"EverlongOpsLib": "0xAbe4447C954E3C7a405f8E75116BF9f5787426F7"
}
},
"optimizer": {
"runs": 100,
"enabled": true
},
"viaSSACFG": false,
"evmVersion": "cancun",
"remappings": [
"@openzeppelin/contracts/=lib/openzeppelin-contracts-compat/contracts/",
"@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable-compat/contracts/",
"solady/=lib/solady/src/",
"forge-std/=lib/forge-std/src/"
],
"experimental": false
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.