Verified contractExactBUSL-1.1
DefaultInitLib
Address0x655bc58011e4a1b3d2223c281e211d19ec99a186
- Balance
0 ETH
- Transactions
0
- Compiler
solc 0.8.30
- Same code
Only this contract
Details
- Compiler
- solc 0.8.30+commit.73712a01
- Language
- solidity
- Optimization
- Yes, 100 runs
- EVM version
- cancun
- License
- BUSL-1.1
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,486,035
- Creation transaction
- 0x5c6077d9c6…f547cb7724
85 files
The source code is large: one file is shown at a time. Choose a file in the list.
- src/libraries/DefaultInitLib.solmain5.62 KB
- lib/openzeppelin-contracts-upgradeable/contracts/access/AccessControlUpgradeable.sol8.33 KB
- lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol9.28 KB
- lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol6.57 KB
- lib/openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol12.13 KB
- lib/openzeppelin-contracts-upgradeable/contracts/token/ERC20/extensions/ERC4626Upgradeable.sol13.29 KB
- lib/openzeppelin-contracts-upgradeable/contracts/token/ERC721/ERC721Upgradeable.sol17.8 KB
- lib/openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol1.19 KB
- lib/openzeppelin-contracts-upgradeable/contracts/utils/PausableUpgradeable.sol3.66 KB
- lib/openzeppelin-contracts-upgradeable/contracts/utils/ReentrancyGuardUpgradeable.sol4.51 KB
- lib/openzeppelin-contracts-upgradeable/contracts/utils/introspection/ERC165Upgradeable.sol1.15 KB
- lib/openzeppelin-contracts/contracts/access/IAccessControl.sol3.34 KB
- lib/openzeppelin-contracts/contracts/interfaces/IERC1363.sol4.45 KB
- lib/openzeppelin-contracts/contracts/interfaces/IERC165.sol193 B
- lib/openzeppelin-contracts/contracts/interfaces/IERC1967.sol637 B
- lib/openzeppelin-contracts/contracts/interfaces/IERC20.sol182 B
- lib/openzeppelin-contracts/contracts/interfaces/IERC4626.sol12.18 KB
- lib/openzeppelin-contracts/contracts/interfaces/draft-IERC1822.sol882 B
- lib/openzeppelin-contracts/contracts/interfaces/draft-IERC6093.sol6.54 KB
- lib/openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Utils.sol6.24 KB
- lib/openzeppelin-contracts/contracts/proxy/beacon/IBeacon.sol473 B
- lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol2.78 KB
- lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol684 B
- lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol10.08 KB
- lib/openzeppelin-contracts/contracts/token/ERC721/IERC721.sol4.93 KB
- lib/openzeppelin-contracts/contracts/token/ERC721/IERC721Receiver.sol997 B
- lib/openzeppelin-contracts/contracts/token/ERC721/extensions/IERC721Metadata.sol792 B
- lib/openzeppelin-contracts/contracts/token/ERC721/utils/ERC721Utils.sol1.92 KB
- lib/openzeppelin-contracts/contracts/utils/Address.sol6 KB
- lib/openzeppelin-contracts/contracts/utils/Errors.sol896 B
- lib/openzeppelin-contracts/contracts/utils/Panic.sol1.97 KB
- lib/openzeppelin-contracts/contracts/utils/StorageSlot.sol4.18 KB
- lib/openzeppelin-contracts/contracts/utils/Strings.sol19.28 KB
- lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol871 B
- lib/openzeppelin-contracts/contracts/utils/math/Math.sol32.15 KB
- lib/openzeppelin-contracts/contracts/utils/math/SafeCast.sol34.94 KB
- lib/openzeppelin-contracts/contracts/utils/math/SignedMath.sol2.61 KB
- lib/solady/src/utils/FixedPointMathLib.sol55.69 KB
- src/ClaimBridge.sol50.08 KB
- src/CommitmentLedger.sol13.84 KB
- src/CommitmentLedgerFactory.sol814 B
- src/ConservativeImpairmentMath.sol23.87 KB
- src/DefaultManager.sol77.1 KB
- src/WaterfallEngine.sol87.97 KB
- src/interfaces/IAccrualExposure.sol2.49 KB
- src/interfaces/IAccrualLifecycle.sol6.67 KB
- src/interfaces/IAccrualMigration.sol2.22 KB
- src/interfaces/IAttestationOracle.sol11.8 KB
- src/interfaces/ICascadeBackstop.sol3.47 KB
- src/interfaces/ICollateralRegistry.sol21.89 KB
- src/interfaces/ICommitmentLedger.sol3.25 KB
- src/interfaces/ICommitmentPrincipalSource.sol188 B
- src/interfaces/IComplianceRegistry.sol2.52 KB
- src/interfaces/IConservativeImpairmentBook.sol3.16 KB
- src/interfaces/IContinuousAccrual.sol4.69 KB
- src/interfaces/ICuratorModule.sol22.46 KB
- src/interfaces/IDefaultManager.sol34.39 KB
- src/interfaces/IImpairmentSource.sol2.26 KB
- src/interfaces/ILossProtection.sol355 B
- src/interfaces/IMintRedeemController.sol42.91 KB
- src/interfaces/IPointsModule.sol2.43 KB
- src/interfaces/IReserveLossAbsorber.sol2.11 KB
- src/interfaces/IReserveManager.sol31.28 KB
- src/interfaces/IRevisionedImpairmentSource.sol2.79 KB
- src/interfaces/IWaterfallEngine.sol16.65 KB
- src/interfaces/IsUSDfr.sol14.06 KB
- src/libraries/AccrualMath.sol8.76 KB
- src/libraries/BridgeAccrualLib.sol5.25 KB
- src/libraries/BridgeFundingLib.sol14.58 KB
- src/libraries/BridgeMixedInterestLib.sol32.77 KB
- src/libraries/Config.sol23.1 KB
- src/libraries/DefaultAccrualLib.sol38.7 KB
- src/libraries/DefaultBackstopLib.sol4.39 KB
- src/libraries/DefaultLossLib.sol26.26 KB
- src/libraries/DefaultReliefLib.sol13.45 KB
- src/libraries/LossEventIds.sol1.35 KB
- src/libraries/LossProtectionLib.sol5.39 KB
- src/libraries/PastDueReliefIndex.sol6.08 KB
- src/libraries/PointsHookGas.sol3.99 KB
- src/libraries/Roles.sol4.2 KB
- src/libraries/VaultAccrualLib.sol18.03 KB
- src/libraries/VaultFeeMath.sol9.97 KB
- src/libraries/VaultStreamLib.sol4.99 KB
- src/libraries/WaterfallAccrualLib.sol14.98 KB
- src/sUSDfr.sol70.36 KB
src/libraries/DefaultInitLib.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.30;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {ClaimBridge} from "../ClaimBridge.sol";
import {Config} from "./Config.sol";
import {LossProtectionLib} from "./LossProtectionLib.sol";
import {DefaultManager} from "../DefaultManager.sol";
import {IAttestationOracle} from "../interfaces/IAttestationOracle.sol";
import {ICollateralRegistry} from "../interfaces/ICollateralRegistry.sol";
import {ICommitmentLedger} from "../interfaces/ICommitmentLedger.sol";
import {ICuratorModule} from "../interfaces/ICuratorModule.sol";
import {IDefaultManager} from "../interfaces/IDefaultManager.sol";
import {IMintRedeemController} from "../interfaces/IMintRedeemController.sol";
import {IReserveManager} from "../interfaces/IReserveManager.sol";
/// @title DefaultInitLib - the DefaultManager's one-shot wiring body
///
/// @notice EXTRACTED 2026-09-10 FOR EIP-170, following the `ReserveCreditLib` precedent set on
/// 2026-09-09. The Ethereum `DefaultManager` was measured at 24,848 bytes after the PIK
/// crank-liveness guard landed, 272 over the 24,576 limit. Working backwards from the last
/// green `check-contract-sizes` run, it had roughly 76 bytes of margin BEFORE that change,
/// so it was already frozen against any new function and nothing in the repository said so.
/// The BSC twin measured 22,830 (margin 1,746) and is not affected.
///
/// @dev WHY `initialize` AND NOT A CASCADE FUNCTION. The obvious candidates by size are
/// `realizeLoss` and `absorbReserveLoss`, and both were rejected for this pass: they are the
/// loss cascade, they are the most heavily audited paths in the contract, and moving them
/// behind a delegatecall is a change that deserves review rather than a late-night commit.
/// `initialize` is the opposite kind of code. It runs exactly once, at deployment, and EVERY
/// test fixture in the repository calls it in `setUp`, so a mistake here does not hide: it
/// fails the entire suite immediately and loudly.
///
/// @dev EVERY FUNCTION HERE IS `public` AND THAT IS THE WHOLE POINT. A `public` library function is
/// deployed as its own contract and reached by delegatecall, so its bytecode leaves the
/// caller's runtime; an `internal` one is inlined and saves nothing. This library therefore
/// needs LINKING at deploy time, exactly as `ReserveCreditLib` does.
///
/// @dev WHAT STAYED BEHIND, and why. The `initializer` modifier, `__AccessControl_init` and its
/// siblings, and `_grantRole` are all internal members of the inherited OpenZeppelin
/// contracts, which a library cannot reach. They remain in `DefaultManager.initialize`, which
/// keeps the initialisation guard and the role grants exactly where an auditor expects them.
/// `commitmentLedgerFactory` is an `immutable` on the implementation and a delegatecall
/// library cannot read the caller's immutables, so the freshly created ledger address is
/// passed in as an argument rather than created here.
library DefaultInitLib {
/// @notice Validates the module set and writes it into namespaced storage, then seeds every
/// class with its default cure and grace windows.
///
/// @param $ The manager's ERC-7201 storage struct, reached by delegatecall in the proxy.
/// @param m The wired protocol modules.
/// @param ledger The commitment ledger the caller created from its immutable factory.
///
/// @dev The zero-address check covers the module set only. `admin`, `guardian` and `upgrader`
/// are checked by the caller, because it is the caller that grants them roles and the
/// check belongs next to the use.
function wire(DefaultManager.DefaultStorage storage $, DefaultManager.InitModules calldata m, address ledger)
public
{
if (
m.bridge == address(0) || m.registry == address(0) || m.reserves == address(0) || m.controller == address(0)
|| m.curator == address(0) || m.oracle == address(0) || m.usdfr == address(0) || m.vault == address(0)
) revert IDefaultManager.DefaultManager_ZeroAddress();
LossProtectionLib.initializeHistorical(0, bytes32(0));
$.bridge = ClaimBridge(m.bridge);
$.registry = ICollateralRegistry(m.registry);
$.reserves = IReserveManager(m.reserves);
$.controller = IMintRedeemController(m.controller);
$.curator = ICuratorModule(m.curator);
$.oracle = IAttestationOracle(m.oracle);
$.usdfr = IERC20(m.usdfr);
$.vault = m.vault;
$.commitmentLedger = ICommitmentLedger(ledger);
for (uint256 classId = 1; classId <= Config.NUM_CLASSES; ++classId) {
$.cureWindows[classId] = Config.DEFAULT_MARGIN_CURE_WINDOW;
emit IDefaultManager.CureWindowSet(classId, Config.DEFAULT_MARGIN_CURE_WINDOW);
// AUDIT FIX (H-5), moved here with the loop on 2026-09-10: the past-due grace window
// defaults to (and is capped at) the redemption cooldown. Governance may only ever
// lower it (see `DefaultManager.setGraceWindow`'s cap). The cap bounds the
// maturity-anchored marking lag; it does NOT fully cover the request-anchored
// redemption cooldown (a partial par-exit window survives, and is documented).
$.graceWindows[classId] = Config.DEFAULT_REDEEM_COOLDOWN;
emit IDefaultManager.GraceWindowSet(classId, Config.DEFAULT_REDEEM_COOLDOWN);
}
}
}
Compiler settingsShow
{
"metadata": {
"bytecodeHash": "ipfs"
},
"libraries": {},
"optimizer": {
"runs": 100,
"enabled": true
},
"evmVersion": "cancun",
"remappings": [
"@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
"forge-std/=lib/forge-std/src/",
"halmos-cheatcodes/=lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/",
"openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"solady/=lib/solady/src/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.