ETH Price: $2,811.71 (+2.20%)

Contract

0x12Ed60319e247B8a86163435fDE9987F1207Baf6

Overview

ETH Balance

0 ETH

ETH Value

$0.00

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

Advanced mode:
Parent Transaction Hash Block From To
View All Internal Transactions

Cross-Chain Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
LiquidStabilityPoolGetters

Compiler Version
v0.8.26+commit.8a97fa7a

Optimization Enabled:
Yes with 1 runs

Other Settings:
cancun EvmVersion
// SPDX-License-Identifier: MIT

pragma solidity 0.8.26;

import {PropMath} from "src/dependencies/PropMath.sol";
import {ILiquidStabilityPool} from "src/interfaces/core/ILiquidStabilityPool.sol";
import {LSPStorageLib} from "src/libraries/LSPStorageLib.sol";
import {EmissionsLib} from "src/libraries/EmissionsLib.sol";
import {ILiquidStabilityPoolGetters} from "src/interfaces/core/helpers/ILSPGetters.sol";

contract LiquidStabilityPoolGetters is ILiquidStabilityPoolGetters {
    ILiquidStabilityPool public immutable lsp;

    constructor(ILiquidStabilityPool _lsp) {
        lsp = _lsp;
    }

    function metaCore() external view returns (address) {
        bytes32[] memory slot = _array(LSPStorageLib.metaCoreSlot());
        return address(uint160(uint(lsp.extSloads(slot)[0])));
    }

    // Previously named getFeeReceiver
    function feeReceiver() external view returns (address) {
        bytes32[] memory slot = _array(LSPStorageLib.feeReceiverSlot());
        return address(uint160(uint(lsp.extSloads(slot)[0])));
    }

    // Previously named getExtraAssets
    function extraAssets() public view returns (address[] memory res) {
        bytes32[] memory slot = _array(LSPStorageLib.extraAssetsValuesSlot());
        uint256 len = uint(lsp.extSloads(slot)[0]);

        res = new address[](len);
        for (uint256 i; i < len; i++) {
            slot = _array(bytes32(LSPStorageLib.extraAssetsArrayValuesSlot(i)));
            res[i] = address(uint160(uint(lsp.extSloads(slot)[0])));
        }
    }

    function extraAssetsIndex(address asset) public view returns (uint256) {
        bytes32 value = bytes32(uint(uint160(asset)));
        bytes32[] memory slot = _array(LSPStorageLib.extraAssetsIndexesMappingSlot(value));
        return uint(lsp.extSloads(slot)[0]);
    }

    function firstSunsetIndexKey() external view returns (uint16) {
        bytes32[] memory slot = _array(LSPStorageLib.firstSunsetAndExtSunsetIndexKeysSlot());
        return uint16(uint(lsp.extSloads(slot)[0]));
    }

    function nextSunsetIndexKey() external view returns (uint16) {
        bytes32[] memory slot = _array(LSPStorageLib.firstSunsetAndExtSunsetIndexKeysSlot());
        return uint16(uint(lsp.extSloads(slot)[0] >> LSPStorageLib.EXT_SUNSET_INDEX_KEY_BITS));
    }

    function collateralTokens() external view returns (address[] memory res) {
        bytes32[] memory slot = _array(LSPStorageLib.collateralTokensSlot());
        uint256 len = uint(lsp.extSloads(slot)[0]);

        res = new address[](len);
        for (uint256 i; i < len; i++) {
            slot = _array(bytes32(LSPStorageLib.collateralTokensArraySlot(i)));
            res[i] = address(uint160(uint(lsp.extSloads(slot)[0])));
        }
    }

    function sunsetIndexIdx(uint16 index) external view returns (uint128) {
        bytes32[] memory slot = _array(LSPStorageLib.sunsetIndexesMappingSlot(index));
        return uint128(uint(lsp.extSloads(slot)[0]));
    }

    function sunsetIndexExpiry(uint16 index) external view returns (uint128) {
        bytes32[] memory slot = _array(LSPStorageLib.sunsetIndexesMappingSlot(index));
        return uint128(uint(lsp.extSloads(slot)[0] >> LSPStorageLib.EXPIRY));
    }

    // Previously named getIndexByCollateral
    function indexByCollateral(address collateral) external view returns (uint256) {
        bytes32[] memory slot = _array(LSPStorageLib.indexByCollateralMappingSlot(collateral));
        return uint(lsp.extSloads(slot)[0]);
    }

    function balance(address account) public view returns (uint256) {
        bytes32[] memory slot = _array(LSPStorageLib.balanceMappingSlot(account));
        return uint(lsp.extSloads(slot)[0]);
    }

    function threshold(bytes32 key) public view returns (uint256) {
        bytes32[] memory slot = _array(LSPStorageLib.thresholdMappingSlot(key));
        return uint(lsp.extSloads(slot)[0]);
    }

    function emissionScheduleEmissions(address token) public view returns (uint128) {
        bytes32[] memory slot = _array(LSPStorageLib.emissionScheduleMappingSlot(token));
        return uint128(uint(lsp.extSloads(slot)[0]));
    }

    // Previously named getLastTimestampUpdate
    function emissionScheduleLockTimestamp(address token) public view returns (uint64) {
        bytes32[] memory slot = _array(LSPStorageLib.emissionScheduleMappingSlot(token));
        return uint64(uint(lsp.extSloads(slot)[0] >> LSPStorageLib.LOCK_TIMESTAMP));
    }

    // Previously named getUnlockRatePerSecond
    function emissionScheduleUnlockRatePerSecond(address token) public view returns (uint64) {
        bytes32[] memory slot = _array(LSPStorageLib.emissionScheduleMappingSlot(token));
        return uint64(uint(lsp.extSloads(slot)[0] >> LSPStorageLib.UNLOCK_RATE_PER_SECOND));
    }

    function isFactory(address factory) external view returns (bool) {
        bytes32[] memory slot = _array(LSPStorageLib.factoryProtocolMappingSlot(factory));
        return uint(lsp.extSloads(slot)[0]) == 1;
    }

    function isLiquidationManager(address liquidationManager) external view returns (bool) {
        bytes32[] memory slot = _array(LSPStorageLib.liquidationManagerProtocolMappingSlot(liquidationManager));
        return uint(lsp.extSloads(slot)[0]) == 1;
    }

    function isPrivilegedDebtRedeemer(address redeemer) external view returns (bool) {
        bytes32[] memory slot = _array(LSPStorageLib.privilegedDebtRedeemerMappingSlot(redeemer));
        return uint(lsp.extSloads(slot)[0]) == 1;
    }

    // Helper functions

    function getFullProfitUnlockTimestamp(address token) external view returns (uint) {
        // If 0 is because it's unused on EmissionsLib function
        EmissionsLib.EmissionSchedule memory schedule = EmissionsLib.EmissionSchedule({
            emissions: 0,
            lockTimestamp: emissionScheduleLockTimestamp(token),
            _unlockRatePerSecond: emissionScheduleUnlockRatePerSecond(token)
        });

        return EmissionsLib.unlockTimestamp(schedule);
    }

    function unlockedEmissions(address token) external view returns (uint) {
        EmissionsLib.EmissionSchedule memory schedule = EmissionsLib.EmissionSchedule({
            emissions: emissionScheduleEmissions(token),
            lockTimestamp: emissionScheduleLockTimestamp(token),
            _unlockRatePerSecond: emissionScheduleUnlockRatePerSecond(token)
        });

        return EmissionsLib.unlockedEmissions(schedule);
    }

    function unlockRatePerSecond(address token) external view returns (uint) {
        EmissionsLib.EmissionSchedule memory schedule = EmissionsLib.EmissionSchedule({
            emissions: 0,
            lockTimestamp: 0,
            _unlockRatePerSecond: emissionScheduleUnlockRatePerSecond(token)
        });

        return EmissionsLib.unlockRatePerSecond(schedule);
    }

    function getBalanceOfWithFutureEmissions(address token) external view returns (uint) {
        return balance(token);
    }

    function getThreshold(address tokenIn, address tokenOut) external view returns (uint) {
        bytes32 hash = keccak256(abi.encodePacked(tokenIn, tokenOut));
        return threshold(hash);
    }

    /**
     * @notice Unlocked collateral and extra assets balances
     */
    function getTokenVirtualBalance(address token) public view returns (uint) {
        EmissionsLib.EmissionSchedule memory schedule = EmissionsLib.EmissionSchedule({
            emissions: emissionScheduleEmissions(token),
            lockTimestamp: emissionScheduleLockTimestamp(token),
            _unlockRatePerSecond: emissionScheduleUnlockRatePerSecond(token)
        });

        return balance(token) - EmissionsLib.lockedEmissions(schedule, EmissionsLib.unlockTimestamp(schedule));
    }

    function containsExtraAsset(address token) external view returns (bool) {
        return extraAssetsIndex(token) != 0;
    }

    function _array(bytes32 x) private pure returns (bytes32[] memory) {
        bytes32[] memory res = new bytes32[](1);
        res[0] = x;
        return res;
    }
}

// SPDX-License-Identifier: MIT

pragma solidity 0.8.26;

library PropMath {
    uint256 internal constant DECIMAL_PRECISION = 1e18;

    /* Precision for Nominal ICR (independent of price). Rationale for the value:
     *
     * - Making it “too high” could lead to overflows.
     * - Making it “too low” could lead to an ICR equal to zero, due to truncation from Solidity floor division.
     *
     * This value of 1e20 is chosen for safety: the NICR will only overflow for numerator > ~1e39,
     * and will only truncate to 0 if the denominator is at least 1e20 times greater than the numerator.
     *
     */
    uint256 internal constant NICR_PRECISION = 1e20;

    function _min(uint256 _a, uint256 _b) internal pure returns (uint256) {
        return (_a < _b) ? _a : _b;
    }

    function _max(uint256 _a, uint256 _b) internal pure returns (uint256) {
        return (_a >= _b) ? _a : _b;
    }

    /*
     * Multiply two decimal numbers and use normal rounding rules:
     * -round product up if 19'th mantissa digit >= 5
     * -round product down if 19'th mantissa digit < 5
     *
     * Used only inside the exponentiation, _decPow().
     */
    function decMul(uint256 x, uint256 y) internal pure returns (uint256 decProd) {
        uint256 prod_xy = x * y;

        decProd = (prod_xy + (DECIMAL_PRECISION / 2)) / DECIMAL_PRECISION;
    }

    /*
     * _decPow: Exponentiation function for 18-digit decimal base, and integer exponent n.
     *
     * Uses the efficient "exponentiation by squaring" algorithm. O(log(n)) complexity.
     *
     * Called by two functions that represent time in units of minutes:
     * 1) PositionManager._calcDecayedBaseRate
     * 2) CommunityIssuance._getCumulativeIssuanceFraction
     *
     * The exponent is capped to avoid reverting due to overflow. The cap 525600000 equals
     * "minutes in 1000 years": 60 * 24 * 365 * 1000
     *
     * If a period of > 1000 years is ever used as an exponent in either of the above functions, the result will be
     * negligibly different from just passing the cap, since:
     *
     * In function 1), the decayed base rate will be 0 for 1000 years or > 1000 years
     * In function 2), the difference in tokens issued at 1000 years and any time > 1000 years, will be negligible
     */
    function _decPow(uint256 _base, uint256 _minutes) internal pure returns (uint256) {
        if (_minutes > 525600000) {
            _minutes = 525600000;
        } // cap to avoid overflow

        if (_minutes == 0) {
            return DECIMAL_PRECISION;
        }

        uint256 y = DECIMAL_PRECISION;
        uint256 x = _base;
        uint256 n = _minutes;

        // Exponentiation-by-squaring
        while (n > 1) {
            if (n % 2 == 0) {
                x = decMul(x, x);
                n = n / 2;
            } else {
                // if (n % 2 != 0)
                y = decMul(x, y);
                x = decMul(x, x);
                n = (n - 1) / 2;
            }
        }

        return decMul(x, y);
    }

    function _getAbsoluteDifference(uint256 _a, uint256 _b) internal pure returns (uint256) {
        return (_a >= _b) ? _a - _b : _b - _a;
    }

    function _computeNominalCR(uint256 _coll, uint256 _debt) internal pure returns (uint256) {
        if (_debt > 0) {
            return (_coll * NICR_PRECISION) / _debt;
        }
        // Return the maximal value for uint256 if the Position has a debt of 0. Represents "infinite" CR.
        else {
            // if (_debt == 0)
            return 2 ** 256 - 1;
        }
    }

    function _computeCR(uint256 _coll, uint256 _debt, uint256 _price) internal pure returns (uint256) {
        if (_debt > 0) {
            uint256 newCollRatio = (_coll * _price) / _debt;

            return newCollRatio;
        }
        // Return the maximal value for uint256 if the Position has a debt of 0. Represents "infinite" CR.
        else {
            // if (_debt == 0)
            return 2 ** 256 - 1;
        }
    }

    function _computeCR(uint256 _coll, uint256 _debt) internal pure returns (uint256) {
        if (_debt > 0) {
            uint256 newCollRatio = (_coll) / _debt;

            return newCollRatio;
        }
        // Return the maximal value for uint256 if the Position has a debt of 0. Represents "infinite" CR.
        else {
            // if (_debt == 0)
            return 2 ** 256 - 1;
        }
    }

    function _isApproxEqAbs(uint256 a, uint256 b, uint256 tolerance) internal pure returns (bool) {
        return a > b ? (a - b) <= tolerance : (b - a) <= tolerance;
    }

    function _isWithinToleranceAbove(
        uint256 a,
        uint256 b,
        uint256 tolerance
    ) internal pure returns (bool) {
        if (a < b) return false;
        return (a - b) <= tolerance;
    }

    function _isWithinToleranceBelow(
        uint256 a,
        uint256 b,
        uint256 tolerance
    ) internal pure returns (bool) {
        if (a > b) return false;
        return (b - a) <= tolerance;
    }
}

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

import {IERC4626} from "@openzeppelin/contracts/interfaces/IERC4626.sol";
import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol";
import {IERC20} from "@openzeppelin/contracts/interfaces/IERC20.sol";
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import {IMetaCore} from "./IMetaCore.sol";
import {IDebtToken} from "./IDebtToken.sol";
import {IDebtToken} from "./IDebtToken.sol";
import {EmissionsLib} from "src/libraries/EmissionsLib.sol";

interface ILiquidStabilityPool is IERC4626, IERC1822Proxiable {
    struct LSPStorage {
        IMetaCore metaCore;
        address feeReceiver;
        /// @notice Array of tokens that have been emitted to the LiquidStabilityPool
        /// @notice Used to track which tokens can be withdrawn to LSP share holders
        /// @dev Doesn't include tokens that are already collaterals
        EnumerableSet.AddressSet extraAssets;
        Queue queue;
        address[] collateralTokens;
        mapping(uint16 => SunsetIndex) _sunsetIndexes;
        mapping(address collateral => uint256 index) indexByCollateral;
        mapping(bytes32 => uint) threshold;
        EmissionsLib.BalanceData balanceData;
        mapping(address => bool) factoryProtocol;
        mapping(address => bool) liquidationManagerProtocol;
        mapping(address => bool) privilegedDebtRedeemers;
    }

    struct InitParams {
        IERC20 _asset;
        string _sharesName;
        string _sharesSymbol;
        IMetaCore _metaCore;
        address _liquidationManager;
        address _factory;
        address _feeReceiver;
    }

    struct RebalanceParams {
        address sentCurrency;
        uint sentAmount;
        address receivedCurrency;
        address swapper;
        bytes payload;
    }

    struct SunsetIndex {
        uint128 idx;
        uint128 expiry;
    }

    struct Queue {
        uint16 firstSunsetIndexKey;
        uint16 nextSunsetIndexKey;
    }

    event CollAndEmissionsWithdraw(
        address indexed receiver,
        uint shares,
        uint[] amounts
    );

    struct Arrays {
        uint length;
        address[] collaterals;
        uint collateralsLength;
        uint[] amounts;
    }

    event EmissionTokenAdded(address token);
    event EmissionTokenRemoved(address token);
    event StabilityPoolDebtBalanceUpdated(uint256 newBalance);
    event UserDepositChanged(address indexed depositor, uint256 newDeposit);
    event CollateralOverwritten(address oldCollateral, address newCollateral);

    // PROXY
    function upgradeToAndCall(address newImplementation, bytes calldata data) external;
    function getCurrentImplementation() external view returns (address);

    function SUNSET_DURATION() external view returns (uint128);
    function totalDebtTokenDeposits() external view returns (uint256);
    function enableCollateral(address _collateral, uint64 _unlockRatePerSecond, bool forceThroughBalanceCheck) external;
    function startCollateralSunset(address collateral) external;
    function getTotalDebtTokenDeposits() external view returns (uint256);
    function getCollateralTokens() external view returns (address[] memory);
    function offset(address collateral, uint256 _debtToOffset, uint256 _collToAdd) external;
    function initialize(InitParams calldata params) external;
    function rebalance(RebalanceParams calldata p) external;
    function linearVestingExtraAssets(address token, int amount, address recipient) external;
    function withdraw(
        uint assets,
        address[] calldata preferredUnderlyingTokens,
        address receiver,
        address _owner
    ) external returns (uint shares);
    function redeem(
        uint shares,
        address[] calldata preferredUnderlyingTokens,
        address receiver,
        address _owner
    ) external returns (uint assets);
    function updateProtocol(
        address _liquidationManager, 
        address _factory,
        bool _register
    ) external;

    function redeem(
        uint assets,
        address receiver
    ) external returns (uint shares);
    function addNewExtraAsset(address token, uint64 _unlockRatePerSecond) external;
    function removeEmitedTokens(address token) external;
    function setPairThreshold(address tokenIn, address tokenOut, uint thresholdInBP) external;
    function setUnlockRatePerSecond(address token, uint64 _unlockRatePerSecond) external;
    function getPrice(address token) external view returns (uint);
    function getLockedEmissions(address token) external view returns (uint);
    function extSloads(bytes32[] calldata slots) external view returns (bytes32[] memory res);
    function unlockRatePerSecond(address token) external view returns (uint);
    function removeExtraAsset(address token) external;
}

// SPDX-License-Identifier: MIT

pragma solidity 0.8.26;

library LSPStorageLib {
    uint private constant LiquidStabilityPoolStorageLocation = 0x3c2bbd5b01c023780ac7877400fd851b17fd98c152afdb1efc02015acd68a300;

    /* SLOTS */
    uint internal constant META_CORE_SLOT = 0;
    uint internal constant FEE_RECEIVER_SLOT = 1;
    uint internal constant EXTRA_ASSETS_VALUES_SLOT = 2; // length of array
    uint internal constant EXTRA_ASSETS_INDEXES_MAPPING_SLOT = 3;
    uint internal constant FIRST_SUNSET_AND_EXT_SUNSET_INDEX_KEYS_SLOT = 4;
    uint internal constant COLLATERAL_TOKENS_SLOT = 5; // length of array
    uint internal constant SUNSET_INDEXES_MAPPING_SLOT = 6;
    uint internal constant INDEX_BY_COLLATERAL_MAPPING_SLOT = 7;
    uint internal constant THRESHOLD_MAPPING_SLOT = 8;
    uint internal constant BALANCE_MAPPING_SLOT = 9;
    uint internal constant EMISSION_SCHEDULE_MAPPING_SLOT = 10;
    uint internal constant FACTORY_PRTOCOL_MAPPING_SLOT = 11;
    uint internal constant LIQUIDATION_MANAGER_PROTOCOL_MAPPING_SLOT = 12;
    uint internal constant PRIVILEGED_DEBT_REDEEMERS_MAPPING_SLOT = 13;

    /* SLOTS_OFFSETS */
    uint internal constant EXTRA_ASSETS_ARRAY_SLOT = uint(keccak256(abi.encode(LiquidStabilityPoolStorageLocation + EXTRA_ASSETS_VALUES_SLOT)));
    uint internal constant COLLATERAL_TOKENS_ARRAY_SLOT = uint(keccak256(abi.encode(LiquidStabilityPoolStorageLocation + COLLATERAL_TOKENS_SLOT)));
    
    /* BITS_OFFSETS */
    // ILiquidStabilityPool.Queue
    uint internal constant FIRST_SUNSET_INDEX_KEY_BITS = 0;
    uint internal constant EXT_SUNSET_INDEX_KEY_BITS = 16;

    // ILiquidStabilityPool.SunsetIndex
    uint internal constant IDX = 0;
    uint internal constant EXPIRY = 128;

    // ILiquidStabilityPool.EmissionSchedule
    uint internal constant EMISSIONS = 0;
    uint internal constant LOCK_TIMESTAMP = 128;
    uint internal constant UNLOCK_RATE_PER_SECOND = 192;

    /* SLOTS GETTERS */

    function metaCoreSlot() internal pure returns (bytes32) {
        return bytes32(LiquidStabilityPoolStorageLocation + META_CORE_SLOT);
    }

    function feeReceiverSlot() internal pure returns (bytes32) {
        return bytes32(LiquidStabilityPoolStorageLocation + FEE_RECEIVER_SLOT);
    }

    function extraAssetsValuesSlot() internal pure returns (bytes32) {
        return bytes32(LiquidStabilityPoolStorageLocation + EXTRA_ASSETS_VALUES_SLOT);
    }

    function extraAssetsArrayValuesSlot(uint index) internal pure returns (bytes32) {
        return bytes32(EXTRA_ASSETS_ARRAY_SLOT + index);
    }

    function extraAssetsIndexesMappingSlot(bytes32 value) internal pure returns (bytes32) {
        bytes32 slot = bytes32(LiquidStabilityPoolStorageLocation + EXTRA_ASSETS_INDEXES_MAPPING_SLOT);
        bytes memory data = abi.encode(value, slot);
        return keccak256(data);
    }

    function firstSunsetAndExtSunsetIndexKeysSlot() internal pure returns (bytes32) {
        return bytes32(LiquidStabilityPoolStorageLocation + FIRST_SUNSET_AND_EXT_SUNSET_INDEX_KEYS_SLOT);
    }

    function collateralTokensSlot() internal pure returns (bytes32) {
        return bytes32(LiquidStabilityPoolStorageLocation + COLLATERAL_TOKENS_SLOT);
    }

    function collateralTokensArraySlot(uint index) internal pure returns (bytes32) {
        return bytes32(COLLATERAL_TOKENS_ARRAY_SLOT + index);
    }

    function sunsetIndexesMappingSlot(uint16 value) internal pure returns (bytes32) {
        bytes32 slot = bytes32(LiquidStabilityPoolStorageLocation + SUNSET_INDEXES_MAPPING_SLOT);
        bytes memory data = abi.encode(value, slot);
        return keccak256(data);
    }

    function indexByCollateralMappingSlot(address value) internal pure returns (bytes32) {
        bytes32 slot = bytes32(LiquidStabilityPoolStorageLocation + INDEX_BY_COLLATERAL_MAPPING_SLOT);
        bytes memory data = abi.encode(value, slot);
        return keccak256(data);
    }

    function thresholdMappingSlot(bytes32 value) internal pure returns (bytes32) {
        bytes32 slot = bytes32(LiquidStabilityPoolStorageLocation + THRESHOLD_MAPPING_SLOT);
        bytes memory data = abi.encode(value, slot);
        return keccak256(data);
    }

    function balanceMappingSlot(address value) internal pure returns (bytes32) {
        bytes32 slot = bytes32(LiquidStabilityPoolStorageLocation + BALANCE_MAPPING_SLOT);
        bytes memory data = abi.encode(value, slot);
        return keccak256(data);
    }

    function emissionScheduleMappingSlot(address value) internal pure returns (bytes32) {
        bytes32 slot = bytes32(LiquidStabilityPoolStorageLocation + EMISSION_SCHEDULE_MAPPING_SLOT);
        bytes memory data = abi.encode(value, slot);
        return bytes32(uint(keccak256(data)));
    }

    function factoryProtocolMappingSlot(address value) internal pure returns (bytes32) {
        bytes32 slot = bytes32(LiquidStabilityPoolStorageLocation + FACTORY_PRTOCOL_MAPPING_SLOT);
        bytes memory data = abi.encode(value, slot);
        return bytes32(uint(keccak256(data)));
    }

    function liquidationManagerProtocolMappingSlot(address value) internal pure returns (bytes32) {
        bytes32 slot = bytes32(LiquidStabilityPoolStorageLocation + LIQUIDATION_MANAGER_PROTOCOL_MAPPING_SLOT);
        bytes memory data = abi.encode(value, slot);
        return bytes32(uint(keccak256(data)));
    }

    function privilegedDebtRedeemerMappingSlot(address value) internal pure returns (bytes32) {
        bytes32 slot = bytes32(LiquidStabilityPoolStorageLocation + PRIVILEGED_DEBT_REDEEMERS_MAPPING_SLOT);
        bytes memory data = abi.encode(value, slot);
        return bytes32(uint(keccak256(data)));
    }
}

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

import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol";
import {ILiquidStabilityPool} from "../interfaces/core/ILiquidStabilityPool.sol";

library EmissionsLib {
    using SafeCast for uint256;
    uint64 constant internal DEFAULT_UNLOCK_RATE = 1e11; // 10% per second
    uint64 constant internal MAX_UNLOCK_RATE = 1e12; // 100%

    struct BalanceData {
        mapping(address token => uint) balance;
        mapping(address token => EmissionSchedule) emissionSchedule;
    }

    struct EmissionSchedule {
        uint128 emissions;
        uint64 lockTimestamp;
        uint64 _unlockRatePerSecond; // rate points
    }

    error AmountCannotBeZero();
    error EmissionRateExceedsMax();
    // error UnsupportedEmissionConfig();

    event EmissionsAdded(address indexed token, uint128 amount);
    event EmissionsSub(address indexed token, uint128 amount);
    event NewUnlockRatePerSecond(address indexed token, uint64 unlockRatePerSecond);

    /// @dev zero _unlockRatePerSecond parameter resets rate back to DEFAULT_UNLOCK_RATE
    function setUnlockRatePerSecond(BalanceData storage $, address token, uint64 _unlockRatePerSecond) internal {
        if (_unlockRatePerSecond > MAX_UNLOCK_RATE) revert EmissionRateExceedsMax();
        _addEmissions($, token, 0); // update lockTimestamp and emissions
        $.emissionSchedule[token]._unlockRatePerSecond = _unlockRatePerSecond;

        emit NewUnlockRatePerSecond(token, _unlockRatePerSecond);
    }

    function addEmissions(BalanceData storage $, address token, uint128 amount) internal {
        if (amount == 0) revert AmountCannotBeZero();
        _addEmissions($, token, amount);

        emit EmissionsAdded(token, amount);
    }

    function _addEmissions(BalanceData storage $, address token, uint128 amount) private {        
        EmissionSchedule memory schedule = $.emissionSchedule[token];

        uint256 _unlockTimestamp = unlockTimestamp(schedule);
        uint128 nextEmissions = (lockedEmissions(schedule, _unlockTimestamp) + amount).toUint128();

        schedule.emissions = nextEmissions;
        schedule.lockTimestamp = block.timestamp.toUint64();
        $.balance[token] += amount;

        $.emissionSchedule[token] = schedule;
    }

    function subEmissions(BalanceData storage $, address token, uint128 amount) internal {
        if (amount == 0) revert AmountCannotBeZero();
        _subEmissions($, token, amount);

        emit EmissionsSub(token, amount);
    }

    function _subEmissions(BalanceData storage $, address token, uint128 amount) private {
        EmissionSchedule memory schedule = $.emissionSchedule[token];

        uint256 _unlockTimestamp = unlockTimestamp(schedule);
        uint128 nextEmissions = (lockedEmissions(schedule, _unlockTimestamp) - amount).toUint128();

        schedule.emissions = nextEmissions;
        schedule.lockTimestamp = block.timestamp.toUint64();
        $.balance[token] -= amount;

        $.emissionSchedule[token] = schedule;
    }

    /// @dev Doesn't include locked emissions
    function unlockedEmissions(EmissionSchedule memory schedule) internal view returns (uint256) {
        return schedule.emissions - lockedEmissions(schedule, unlockTimestamp(schedule));
    }

    function balanceOfWithFutureEmissions(BalanceData storage $, address token) internal view returns (uint256) {
        return $.balance[token];
    }

    /**
     * @notice Returns the unlocked token emissions
     */
    function balanceOf(BalanceData storage $, address token) internal view returns (uint256) {
        EmissionSchedule memory schedule = $.emissionSchedule[token];
        return $.balance[token] - lockedEmissions(schedule, unlockTimestamp(schedule));
    }

    /**
     * @notice Returns locked emissions
     */
    function lockedEmissions(EmissionSchedule memory schedule, uint256 _unlockTimestamp) internal view returns (uint256) {
        if (block.timestamp >= _unlockTimestamp) {
            // all emissions were unlocked 
            return 0;
        } else {
            // emissions are still unlocking, calculate the amount of already unlocked emissions
            uint256 secondsSinceLockup = block.timestamp - schedule.lockTimestamp;
            // design decision - use dimensionless 'unlock rate units' to unlock emissions over a fixed time window 
            uint256 ratePointsUnlocked = unlockRatePerSecond(schedule) * secondsSinceLockup;
            // emissions remainder is designed to be added to balance in unlockTimestamp
            return schedule.emissions - ratePointsUnlocked * schedule.emissions / MAX_UNLOCK_RATE;
        }
    } 

    // timestamp at which all emissions are fully unlocked
    function unlockTimestamp(EmissionSchedule memory schedule) internal pure returns (uint256) {
        // ceil to account for remainder seconds left after integer division
        return divRoundUp(MAX_UNLOCK_RATE, unlockRatePerSecond(schedule)) + schedule.lockTimestamp; 
    }

    function unlockRatePerSecond(EmissionSchedule memory schedule) internal pure returns (uint256) {
        return schedule._unlockRatePerSecond == 0 ? DEFAULT_UNLOCK_RATE : schedule._unlockRatePerSecond;
    }

    function divRoundUp(uint256 dividend, uint256 divisor) internal pure returns (uint256) {
        return (dividend + divisor - 1) / divisor;
    }
}

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

interface ILiquidStabilityPoolGetters {
    function metaCore() external view returns (address);
    function isLiquidationManager(address liquidatioManager) external view returns (bool);
    function isFactory(address factory) external view returns (bool);
    function feeReceiver() external view returns (address);
    function extraAssets() external view returns (address[] memory);
    function extraAssetsIndex(address asset) external view returns (uint256);
    function firstSunsetIndexKey() external view returns (uint16);
    function nextSunsetIndexKey() external view returns (uint16);
    function collateralTokens() external view returns (address[] memory);
    function sunsetIndexIdx(uint16 index) external view returns (uint128);
    function sunsetIndexExpiry(uint16 index) external view returns (uint128);
    function indexByCollateral(address collateral) external view returns (uint256);
    function balance(address account) external view returns (uint256);
    function threshold(bytes32 key) external view returns (uint256);
    function emissionScheduleEmissions(address token) external view returns (uint128);
    function emissionScheduleLockTimestamp(address token) external view returns (uint64);
    function emissionScheduleUnlockRatePerSecond(address token) external view returns (uint64);
    function getFullProfitUnlockTimestamp(address token) external view returns (uint);
    function unlockedEmissions(address token) external view returns (uint);
    function getBalanceOfWithFutureEmissions(address token) external view returns (uint);
    function getThreshold(address tokenIn, address tokenOut) external view returns (uint);
    function getTokenVirtualBalance(address token) external view returns (uint);
    function containsExtraAsset(address token) external view returns (bool);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (interfaces/IERC4626.sol)

pragma solidity ^0.8.0;

import "../token/ERC20/IERC20.sol";
import "../token/ERC20/extensions/IERC20Metadata.sol";

/**
 * @dev Interface of the ERC4626 "Tokenized Vault Standard", as defined in
 * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].
 *
 * _Available since v4.7._
 */
interface IERC4626 is IERC20, IERC20Metadata {
    event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);

    event Withdraw(
        address indexed sender,
        address indexed receiver,
        address indexed owner,
        uint256 assets,
        uint256 shares
    );

    /**
     * @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.
     *
     * - MUST be an ERC-20 token contract.
     * - MUST NOT revert.
     */
    function asset() external view returns (address assetTokenAddress);

    /**
     * @dev Returns the total amount of the underlying asset that is “managed” by Vault.
     *
     * - SHOULD include any compounding that occurs from yield.
     * - MUST be inclusive of any fees that are charged against assets in the Vault.
     * - MUST NOT revert.
     */
    function totalAssets() external view returns (uint256 totalManagedAssets);

    /**
     * @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal
     * scenario where all the conditions are met.
     *
     * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.
     * - MUST NOT show any variations depending on the caller.
     * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
     * - MUST NOT revert.
     *
     * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the
     * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and
     * from.
     */
    function convertToShares(uint256 assets) external view returns (uint256 shares);

    /**
     * @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal
     * scenario where all the conditions are met.
     *
     * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.
     * - MUST NOT show any variations depending on the caller.
     * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
     * - MUST NOT revert.
     *
     * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the
     * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and
     * from.
     */
    function convertToAssets(uint256 shares) external view returns (uint256 assets);

    /**
     * @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver,
     * through a deposit call.
     *
     * - MUST return a limited value if receiver is subject to some deposit limit.
     * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.
     * - MUST NOT revert.
     */
    function maxDeposit(address receiver) external view returns (uint256 maxAssets);

    /**
     * @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given
     * current on-chain conditions.
     *
     * - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit
     *   call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called
     *   in the same transaction.
     * - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the
     *   deposit would be accepted, regardless if the user has enough tokens approved, etc.
     * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
     * - MUST NOT revert.
     *
     * NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in
     * share price or some other type of condition, meaning the depositor will lose assets by depositing.
     */
    function previewDeposit(uint256 assets) external view returns (uint256 shares);

    /**
     * @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.
     *
     * - MUST emit the Deposit event.
     * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
     *   deposit execution, and are accounted for during deposit.
     * - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not
     *   approving enough underlying tokens to the Vault contract, etc).
     *
     * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
     */
    function deposit(uint256 assets, address receiver) external returns (uint256 shares);

    /**
     * @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.
     * - MUST return a limited value if receiver is subject to some mint limit.
     * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.
     * - MUST NOT revert.
     */
    function maxMint(address receiver) external view returns (uint256 maxShares);

    /**
     * @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given
     * current on-chain conditions.
     *
     * - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call
     *   in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the
     *   same transaction.
     * - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint
     *   would be accepted, regardless if the user has enough tokens approved, etc.
     * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
     * - MUST NOT revert.
     *
     * NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in
     * share price or some other type of condition, meaning the depositor will lose assets by minting.
     */
    function previewMint(uint256 shares) external view returns (uint256 assets);

    /**
     * @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.
     *
     * - MUST emit the Deposit event.
     * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint
     *   execution, and are accounted for during mint.
     * - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not
     *   approving enough underlying tokens to the Vault contract, etc).
     *
     * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
     */
    function mint(uint256 shares, address receiver) external returns (uint256 assets);

    /**
     * @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the
     * Vault, through a withdraw call.
     *
     * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.
     * - MUST NOT revert.
     */
    function maxWithdraw(address owner) external view returns (uint256 maxAssets);

    /**
     * @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,
     * given current on-chain conditions.
     *
     * - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw
     *   call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if
     *   called
     *   in the same transaction.
     * - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though
     *   the withdrawal would be accepted, regardless if the user has enough shares, etc.
     * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
     * - MUST NOT revert.
     *
     * NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in
     * share price or some other type of condition, meaning the depositor will lose assets by depositing.
     */
    function previewWithdraw(uint256 assets) external view returns (uint256 shares);

    /**
     * @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver.
     *
     * - MUST emit the Withdraw event.
     * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
     *   withdraw execution, and are accounted for during withdraw.
     * - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner
     *   not having enough shares, etc).
     *
     * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
     * Those methods should be performed separately.
     */
    function withdraw(
        uint256 assets,
        address receiver,
        address owner
    ) external returns (uint256 shares);

    /**
     * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault,
     * through a redeem call.
     *
     * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.
     * - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.
     * - MUST NOT revert.
     */
    function maxRedeem(address owner) external view returns (uint256 maxShares);

    /**
     * @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block,
     * given current on-chain conditions.
     *
     * - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call
     *   in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the
     *   same transaction.
     * - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the
     *   redemption would be accepted, regardless if the user has enough shares, etc.
     * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
     * - MUST NOT revert.
     *
     * NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in
     * share price or some other type of condition, meaning the depositor will lose assets by redeeming.
     */
    function previewRedeem(uint256 shares) external view returns (uint256 assets);

    /**
     * @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver.
     *
     * - MUST emit the Withdraw event.
     * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
     *   redeem execution, and are accounted for during redeem.
     * - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner
     *   not having enough shares, etc).
     *
     * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
     * Those methods should be performed separately.
     */
    function redeem(
        uint256 shares,
        address receiver,
        address owner
    ) external returns (uint256 assets);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)

pragma solidity ^0.8.0;

/**
 * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
 * proxy whose upgrades are fully controlled by the current implementation.
 */
interface IERC1822Proxiable {
    /**
     * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
     * address.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy.
     */
    function proxiableUUID() external view returns (bytes32);
}

File 9 of 17 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol)

pragma solidity ^0.8.0;

import "../token/ERC20/IERC20.sol";

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.

pragma solidity ^0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 *
 * [WARNING]
 * ====
 * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
 * unusable.
 * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
 *
 * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
 * array of EnumerableSet.
 * ====
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;
        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping(bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) {
            // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            if (lastIndex != toDeleteIndex) {
                bytes32 lastValue = set._values[lastIndex];

                // Move the last value to the index where the value to delete is
                set._values[toDeleteIndex] = lastValue;
                // Update the index for the moved value
                set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
            }

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        return set._values[index];
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function _values(Set storage set) private view returns (bytes32[] memory) {
        return set._values;
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
        bytes32[] memory store = _values(set._inner);
        bytes32[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(AddressSet storage set) internal view returns (address[] memory) {
        bytes32[] memory store = _values(set._inner);
        address[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(UintSet storage set) internal view returns (uint256[] memory) {
        bytes32[] memory store = _values(set._inner);
        uint256[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }
}

// SPDX-License-Identifier: MIT

pragma solidity 0.8.26;

interface IMetaCore {
    // ---------------------------------
    // Structures
    // ---------------------------------
    struct FeeInfo {
        bool existsForDebtToken;
        uint16 debtTokenFee;
    }

    struct RebalancerFeeInfo {
        bool exists;
        uint16 entryFee;
        uint16 exitFee;
    }

    // ---------------------------------
    // Public constants
    // ---------------------------------
    function OWNERSHIP_TRANSFER_DELAY() external view returns (uint256);
    function DEFAULT_FLASH_LOAN_FEE() external view returns (uint16);

    // ---------------------------------
    // Public state variables
    // ---------------------------------
    function debtToken() external view returns (address);
    function lspEntryFee() external view returns (uint16);
    function lspExitFee() external view returns (uint16);
    function interestProtocolShare() external view returns (uint16);
    /// @dev Default interest receiver for all PositionManagers, unless overriden in the respective PM
    function defaultInterestReceiver() external view returns (address);

    function feeReceiver() external view returns (address);
    function priceFeed() external view returns (address);
    function owner() external view returns (address);
    function pendingOwner() external view returns (address);
    function ownershipTransferDeadline() external view returns (uint256);
    function guardian() external view returns (address);
    function paused() external view returns (bool);
    function lspBootstrapPeriod() external view returns (uint64);

    // ---------------------------------
    // External functions
    // ---------------------------------
    function setFeeReceiver(address _feeReceiver) external;
    function setPriceFeed(address _priceFeed) external;
    function setGuardian(address _guardian) external;

    /**
     * @notice Global pause/unpause
     *         Pausing halts new deposits/borrowing across the protocol
     */
    function setPaused(bool _paused) external;

    /**
     * @notice Extend or change the LSP bootstrap period,
     *         after which certain protocol mechanics change
     */
    function setLspBootstrapPeriod(uint64 _bootstrapPeriod) external;

    /**
     * @notice Set a custom flash-loan fee for a given periphery contract
     * @param _periphery Target contract that will get this custom fee
     * @param _debtTokenFee Fee in basis points (bp)
     * @param _existsForDebtToken Whether this custom fee is used when the caller = `debtToken`
     */
    function setPeripheryFlashLoanFee(address _periphery, uint16 _debtTokenFee, bool _existsForDebtToken) external;

    /**
     * @notice Begin the ownership transfer process
     * @param newOwner The address proposed to be the new owner
     */
    function commitTransferOwnership(address newOwner) external;

    /**
     * @notice Finish the ownership transfer, after the mandatory delay
     */
    function acceptTransferOwnership() external;

    /**
     * @notice Revoke a pending ownership transfer
     */
    function revokeTransferOwnership() external;

    /**
     * @notice Look up a custom flash-loan fee for a specific periphery contract
     * @param peripheryContract The contract that might have a custom fee
     * @return The flash-loan fee in basis points
     */
    function getPeripheryFlashLoanFee(address peripheryContract) external view returns (uint16);

    /**
     * @notice Set / override entry & exit fees for a special rebalancer contract
     */
    function setRebalancerFee(address _rebalancer, uint16 _entryFee, uint16 _exitFee) external;

    /**
     * @notice Set the LSP entry fee globally
     * @param _fee Fee in basis points
     */
    function setEntryFee(uint16 _fee) external;

    /**
     * @notice Set the LSP exit fee globally
     * @param _fee Fee in basis points
     */
    function setExitFee(uint16 _fee) external;

    /**
     * @notice Set the interest protocol share globally to all PositionManagers
     * @param _interestProtocolShare Share in basis points
     */
    function setInterestProtocolShare(uint16 _interestProtocolShare) external;

    /**
     * @notice Look up the LSP entry fee for a rebalancer
     * @param rebalancer Possibly has a special fee
     * @return The entry fee in basis points
     */
    function getLspEntryFee(address rebalancer) external view returns (uint16);

    /**
     * @notice Look up the LSP exit fee for a rebalancer
     * @param rebalancer Possibly has a special fee
     * @return The exit fee in basis points
     */
    function getLspExitFee(address rebalancer) external view returns (uint16);

    // ---------------------------------
    // Events
    // ---------------------------------
    event NewOwnerCommitted(address indexed owner, address indexed pendingOwner, uint256 deadline);
    event NewOwnerAccepted(address indexed oldOwner, address indexed newOwner);
    event NewOwnerRevoked(address indexed owner, address indexed revokedOwner);

    event FeeReceiverSet(address indexed feeReceiver);
    event PriceFeedSet(address indexed priceFeed);
    event GuardianSet(address indexed guardian);
    event PeripheryFlashLoanFee(address indexed periphery, uint16 debtTokenFee);
    event LSPBootstrapPeriodSet(uint64 bootstrapPeriod);
    event RebalancerFees(address indexed rebalancer, uint16 entryFee, uint16 exitFee);
    event EntryFeeSet(uint16 fee);
    event ExitFeeSet(uint16 fee);
    event InterestProtocolShareSet(uint16 interestProtocolShare);
    event DefaultInterestReceiverSet(address indexed defaultInterestReceiver);
    event Paused();
    event Unpaused();
}

File 12 of 17 : IDebtToken.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.26;

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 
import { IERC3156FlashBorrower } from "@openzeppelin/contracts/interfaces/IERC3156FlashBorrower.sol";
import "./ICore.sol";

interface IDebtToken is IERC20 {
    // --- Events ---
    event FlashLoanFeeUpdated(uint256 newFee);

    // --- Public constants ---
    function version() external view returns (string memory);
    function permitTypeHash() external view returns (bytes32);

    // --- Public immutables ---
    function gasPool() external view returns (address);
    function DEBT_GAS_COMPENSATION() external view returns (uint256);

    // --- Public mappings ---
    function liquidStabilityPools(address) external view returns (bool);
    function borrowerOperations(address) external view returns (bool);
    function factories(address) external view returns (bool);
    function peripheries(address) external view returns (bool);
    function positionManagers(address) external view returns (bool);

    // --- External functions ---

    function enablePositionManager(address _positionManager) external;
    function mintWithGasCompensation(address _account, uint256 _amount) external returns (bool);
    function burnWithGasCompensation(address _account, uint256 _amount) external returns (bool);
    function mint(address _account, uint256 _amount) external;
    function burn(address _account, uint256 _amount) external;
    function decimals() external view returns (uint8);
    function sendToPeriphery(address _sender, uint256 _amount) external;
    function sendToSP(address _sender, uint256 _amount) external;
    function returnFromPool(address _poolAddress, address _receiver, uint256 _amount) external;
    function transfer(address recipient, uint256 amount) external returns (bool);
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
    function maxFlashLoan(address token) external view returns (uint256);
    function flashFee(address token, uint256 amount) external view returns (uint256);
    function flashLoan(
        IERC3156FlashBorrower receiver,
        address token,
        uint256 amount,
        bytes calldata data
    ) external returns (bool);
    function whitelistLiquidStabilityPoolAddress(address _liquidStabilityPool, bool active) external;
    function whitelistBorrowerOperationsAddress(address _borrowerOperations, bool active) external;
    function whitelistFactoryAddress(address _factory, bool active) external;
    function whitelistPeripheryAddress(address _periphery, bool active) external;
    function whitelistPSM(address, bool) external;
    function setDebtGasCompensation(uint256 _gasCompensation, bool _isFinalValue) external;
    function setFlashLoanFee(uint256 _fee) external;
    function DOMAIN_SEPARATOR() external view returns (bytes32);
    function permit(
        address owner,
        address spender,
        uint256 amount,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;
    function nonces(address owner) external view returns (uint256);
}

File 13 of 17 : SafeCast.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.

pragma solidity ^0.8.0;

/**
 * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
 * checks.
 *
 * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
 * easily result in undesired exploitation or bugs, since developers usually
 * assume that overflows raise errors. `SafeCast` restores this intuition by
 * reverting the transaction when such an operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 *
 * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing
 * all math on `uint256` and `int256` and then downcasting.
 */
library SafeCast {
    /**
     * @dev Returns the downcasted uint248 from uint256, reverting on
     * overflow (when the input is greater than largest uint248).
     *
     * Counterpart to Solidity's `uint248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     *
     * _Available since v4.7._
     */
    function toUint248(uint256 value) internal pure returns (uint248) {
        require(value <= type(uint248).max, "SafeCast: value doesn't fit in 248 bits");
        return uint248(value);
    }

    /**
     * @dev Returns the downcasted uint240 from uint256, reverting on
     * overflow (when the input is greater than largest uint240).
     *
     * Counterpart to Solidity's `uint240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     *
     * _Available since v4.7._
     */
    function toUint240(uint256 value) internal pure returns (uint240) {
        require(value <= type(uint240).max, "SafeCast: value doesn't fit in 240 bits");
        return uint240(value);
    }

    /**
     * @dev Returns the downcasted uint232 from uint256, reverting on
     * overflow (when the input is greater than largest uint232).
     *
     * Counterpart to Solidity's `uint232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     *
     * _Available since v4.7._
     */
    function toUint232(uint256 value) internal pure returns (uint232) {
        require(value <= type(uint232).max, "SafeCast: value doesn't fit in 232 bits");
        return uint232(value);
    }

    /**
     * @dev Returns the downcasted uint224 from uint256, reverting on
     * overflow (when the input is greater than largest uint224).
     *
     * Counterpart to Solidity's `uint224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     *
     * _Available since v4.2._
     */
    function toUint224(uint256 value) internal pure returns (uint224) {
        require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits");
        return uint224(value);
    }

    /**
     * @dev Returns the downcasted uint216 from uint256, reverting on
     * overflow (when the input is greater than largest uint216).
     *
     * Counterpart to Solidity's `uint216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     *
     * _Available since v4.7._
     */
    function toUint216(uint256 value) internal pure returns (uint216) {
        require(value <= type(uint216).max, "SafeCast: value doesn't fit in 216 bits");
        return uint216(value);
    }

    /**
     * @dev Returns the downcasted uint208 from uint256, reverting on
     * overflow (when the input is greater than largest uint208).
     *
     * Counterpart to Solidity's `uint208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     *
     * _Available since v4.7._
     */
    function toUint208(uint256 value) internal pure returns (uint208) {
        require(value <= type(uint208).max, "SafeCast: value doesn't fit in 208 bits");
        return uint208(value);
    }

    /**
     * @dev Returns the downcasted uint200 from uint256, reverting on
     * overflow (when the input is greater than largest uint200).
     *
     * Counterpart to Solidity's `uint200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     *
     * _Available since v4.7._
     */
    function toUint200(uint256 value) internal pure returns (uint200) {
        require(value <= type(uint200).max, "SafeCast: value doesn't fit in 200 bits");
        return uint200(value);
    }

    /**
     * @dev Returns the downcasted uint192 from uint256, reverting on
     * overflow (when the input is greater than largest uint192).
     *
     * Counterpart to Solidity's `uint192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     *
     * _Available since v4.7._
     */
    function toUint192(uint256 value) internal pure returns (uint192) {
        require(value <= type(uint192).max, "SafeCast: value doesn't fit in 192 bits");
        return uint192(value);
    }

    /**
     * @dev Returns the downcasted uint184 from uint256, reverting on
     * overflow (when the input is greater than largest uint184).
     *
     * Counterpart to Solidity's `uint184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     *
     * _Available since v4.7._
     */
    function toUint184(uint256 value) internal pure returns (uint184) {
        require(value <= type(uint184).max, "SafeCast: value doesn't fit in 184 bits");
        return uint184(value);
    }

    /**
     * @dev Returns the downcasted uint176 from uint256, reverting on
     * overflow (when the input is greater than largest uint176).
     *
     * Counterpart to Solidity's `uint176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     *
     * _Available since v4.7._
     */
    function toUint176(uint256 value) internal pure returns (uint176) {
        require(value <= type(uint176).max, "SafeCast: value doesn't fit in 176 bits");
        return uint176(value);
    }

    /**
     * @dev Returns the downcasted uint168 from uint256, reverting on
     * overflow (when the input is greater than largest uint168).
     *
     * Counterpart to Solidity's `uint168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     *
     * _Available since v4.7._
     */
    function toUint168(uint256 value) internal pure returns (uint168) {
        require(value <= type(uint168).max, "SafeCast: value doesn't fit in 168 bits");
        return uint168(value);
    }

    /**
     * @dev Returns the downcasted uint160 from uint256, reverting on
     * overflow (when the input is greater than largest uint160).
     *
     * Counterpart to Solidity's `uint160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     *
     * _Available since v4.7._
     */
    function toUint160(uint256 value) internal pure returns (uint160) {
        require(value <= type(uint160).max, "SafeCast: value doesn't fit in 160 bits");
        return uint160(value);
    }

    /**
     * @dev Returns the downcasted uint152 from uint256, reverting on
     * overflow (when the input is greater than largest uint152).
     *
     * Counterpart to Solidity's `uint152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     *
     * _Available since v4.7._
     */
    function toUint152(uint256 value) internal pure returns (uint152) {
        require(value <= type(uint152).max, "SafeCast: value doesn't fit in 152 bits");
        return uint152(value);
    }

    /**
     * @dev Returns the downcasted uint144 from uint256, reverting on
     * overflow (when the input is greater than largest uint144).
     *
     * Counterpart to Solidity's `uint144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     *
     * _Available since v4.7._
     */
    function toUint144(uint256 value) internal pure returns (uint144) {
        require(value <= type(uint144).max, "SafeCast: value doesn't fit in 144 bits");
        return uint144(value);
    }

    /**
     * @dev Returns the downcasted uint136 from uint256, reverting on
     * overflow (when the input is greater than largest uint136).
     *
     * Counterpart to Solidity's `uint136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     *
     * _Available since v4.7._
     */
    function toUint136(uint256 value) internal pure returns (uint136) {
        require(value <= type(uint136).max, "SafeCast: value doesn't fit in 136 bits");
        return uint136(value);
    }

    /**
     * @dev Returns the downcasted uint128 from uint256, reverting on
     * overflow (when the input is greater than largest uint128).
     *
     * Counterpart to Solidity's `uint128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     *
     * _Available since v2.5._
     */
    function toUint128(uint256 value) internal pure returns (uint128) {
        require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits");
        return uint128(value);
    }

    /**
     * @dev Returns the downcasted uint120 from uint256, reverting on
     * overflow (when the input is greater than largest uint120).
     *
     * Counterpart to Solidity's `uint120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     *
     * _Available since v4.7._
     */
    function toUint120(uint256 value) internal pure returns (uint120) {
        require(value <= type(uint120).max, "SafeCast: value doesn't fit in 120 bits");
        return uint120(value);
    }

    /**
     * @dev Returns the downcasted uint112 from uint256, reverting on
     * overflow (when the input is greater than largest uint112).
     *
     * Counterpart to Solidity's `uint112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     *
     * _Available since v4.7._
     */
    function toUint112(uint256 value) internal pure returns (uint112) {
        require(value <= type(uint112).max, "SafeCast: value doesn't fit in 112 bits");
        return uint112(value);
    }

    /**
     * @dev Returns the downcasted uint104 from uint256, reverting on
     * overflow (when the input is greater than largest uint104).
     *
     * Counterpart to Solidity's `uint104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     *
     * _Available since v4.7._
     */
    function toUint104(uint256 value) internal pure returns (uint104) {
        require(value <= type(uint104).max, "SafeCast: value doesn't fit in 104 bits");
        return uint104(value);
    }

    /**
     * @dev Returns the downcasted uint96 from uint256, reverting on
     * overflow (when the input is greater than largest uint96).
     *
     * Counterpart to Solidity's `uint96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     *
     * _Available since v4.2._
     */
    function toUint96(uint256 value) internal pure returns (uint96) {
        require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits");
        return uint96(value);
    }

    /**
     * @dev Returns the downcasted uint88 from uint256, reverting on
     * overflow (when the input is greater than largest uint88).
     *
     * Counterpart to Solidity's `uint88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     *
     * _Available since v4.7._
     */
    function toUint88(uint256 value) internal pure returns (uint88) {
        require(value <= type(uint88).max, "SafeCast: value doesn't fit in 88 bits");
        return uint88(value);
    }

    /**
     * @dev Returns the downcasted uint80 from uint256, reverting on
     * overflow (when the input is greater than largest uint80).
     *
     * Counterpart to Solidity's `uint80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     *
     * _Available since v4.7._
     */
    function toUint80(uint256 value) internal pure returns (uint80) {
        require(value <= type(uint80).max, "SafeCast: value doesn't fit in 80 bits");
        return uint80(value);
    }

    /**
     * @dev Returns the downcasted uint72 from uint256, reverting on
     * overflow (when the input is greater than largest uint72).
     *
     * Counterpart to Solidity's `uint72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     *
     * _Available since v4.7._
     */
    function toUint72(uint256 value) internal pure returns (uint72) {
        require(value <= type(uint72).max, "SafeCast: value doesn't fit in 72 bits");
        return uint72(value);
    }

    /**
     * @dev Returns the downcasted uint64 from uint256, reverting on
     * overflow (when the input is greater than largest uint64).
     *
     * Counterpart to Solidity's `uint64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     *
     * _Available since v2.5._
     */
    function toUint64(uint256 value) internal pure returns (uint64) {
        require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits");
        return uint64(value);
    }

    /**
     * @dev Returns the downcasted uint56 from uint256, reverting on
     * overflow (when the input is greater than largest uint56).
     *
     * Counterpart to Solidity's `uint56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     *
     * _Available since v4.7._
     */
    function toUint56(uint256 value) internal pure returns (uint56) {
        require(value <= type(uint56).max, "SafeCast: value doesn't fit in 56 bits");
        return uint56(value);
    }

    /**
     * @dev Returns the downcasted uint48 from uint256, reverting on
     * overflow (when the input is greater than largest uint48).
     *
     * Counterpart to Solidity's `uint48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     *
     * _Available since v4.7._
     */
    function toUint48(uint256 value) internal pure returns (uint48) {
        require(value <= type(uint48).max, "SafeCast: value doesn't fit in 48 bits");
        return uint48(value);
    }

    /**
     * @dev Returns the downcasted uint40 from uint256, reverting on
     * overflow (when the input is greater than largest uint40).
     *
     * Counterpart to Solidity's `uint40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     *
     * _Available since v4.7._
     */
    function toUint40(uint256 value) internal pure returns (uint40) {
        require(value <= type(uint40).max, "SafeCast: value doesn't fit in 40 bits");
        return uint40(value);
    }

    /**
     * @dev Returns the downcasted uint32 from uint256, reverting on
     * overflow (when the input is greater than largest uint32).
     *
     * Counterpart to Solidity's `uint32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     *
     * _Available since v2.5._
     */
    function toUint32(uint256 value) internal pure returns (uint32) {
        require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits");
        return uint32(value);
    }

    /**
     * @dev Returns the downcasted uint24 from uint256, reverting on
     * overflow (when the input is greater than largest uint24).
     *
     * Counterpart to Solidity's `uint24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     *
     * _Available since v4.7._
     */
    function toUint24(uint256 value) internal pure returns (uint24) {
        require(value <= type(uint24).max, "SafeCast: value doesn't fit in 24 bits");
        return uint24(value);
    }

    /**
     * @dev Returns the downcasted uint16 from uint256, reverting on
     * overflow (when the input is greater than largest uint16).
     *
     * Counterpart to Solidity's `uint16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     *
     * _Available since v2.5._
     */
    function toUint16(uint256 value) internal pure returns (uint16) {
        require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits");
        return uint16(value);
    }

    /**
     * @dev Returns the downcasted uint8 from uint256, reverting on
     * overflow (when the input is greater than largest uint8).
     *
     * Counterpart to Solidity's `uint8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     *
     * _Available since v2.5._
     */
    function toUint8(uint256 value) internal pure returns (uint8) {
        require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits");
        return uint8(value);
    }

    /**
     * @dev Converts a signed int256 into an unsigned uint256.
     *
     * Requirements:
     *
     * - input must be greater than or equal to 0.
     *
     * _Available since v3.0._
     */
    function toUint256(int256 value) internal pure returns (uint256) {
        require(value >= 0, "SafeCast: value must be positive");
        return uint256(value);
    }

    /**
     * @dev Returns the downcasted int248 from int256, reverting on
     * overflow (when the input is less than smallest int248 or
     * greater than largest int248).
     *
     * Counterpart to Solidity's `int248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     *
     * _Available since v4.7._
     */
    function toInt248(int256 value) internal pure returns (int248 downcasted) {
        downcasted = int248(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 248 bits");
    }

    /**
     * @dev Returns the downcasted int240 from int256, reverting on
     * overflow (when the input is less than smallest int240 or
     * greater than largest int240).
     *
     * Counterpart to Solidity's `int240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     *
     * _Available since v4.7._
     */
    function toInt240(int256 value) internal pure returns (int240 downcasted) {
        downcasted = int240(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 240 bits");
    }

    /**
     * @dev Returns the downcasted int232 from int256, reverting on
     * overflow (when the input is less than smallest int232 or
     * greater than largest int232).
     *
     * Counterpart to Solidity's `int232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     *
     * _Available since v4.7._
     */
    function toInt232(int256 value) internal pure returns (int232 downcasted) {
        downcasted = int232(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 232 bits");
    }

    /**
     * @dev Returns the downcasted int224 from int256, reverting on
     * overflow (when the input is less than smallest int224 or
     * greater than largest int224).
     *
     * Counterpart to Solidity's `int224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     *
     * _Available since v4.7._
     */
    function toInt224(int256 value) internal pure returns (int224 downcasted) {
        downcasted = int224(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 224 bits");
    }

    /**
     * @dev Returns the downcasted int216 from int256, reverting on
     * overflow (when the input is less than smallest int216 or
     * greater than largest int216).
     *
     * Counterpart to Solidity's `int216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     *
     * _Available since v4.7._
     */
    function toInt216(int256 value) internal pure returns (int216 downcasted) {
        downcasted = int216(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 216 bits");
    }

    /**
     * @dev Returns the downcasted int208 from int256, reverting on
     * overflow (when the input is less than smallest int208 or
     * greater than largest int208).
     *
     * Counterpart to Solidity's `int208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     *
     * _Available since v4.7._
     */
    function toInt208(int256 value) internal pure returns (int208 downcasted) {
        downcasted = int208(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 208 bits");
    }

    /**
     * @dev Returns the downcasted int200 from int256, reverting on
     * overflow (when the input is less than smallest int200 or
     * greater than largest int200).
     *
     * Counterpart to Solidity's `int200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     *
     * _Available since v4.7._
     */
    function toInt200(int256 value) internal pure returns (int200 downcasted) {
        downcasted = int200(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 200 bits");
    }

    /**
     * @dev Returns the downcasted int192 from int256, reverting on
     * overflow (when the input is less than smallest int192 or
     * greater than largest int192).
     *
     * Counterpart to Solidity's `int192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     *
     * _Available since v4.7._
     */
    function toInt192(int256 value) internal pure returns (int192 downcasted) {
        downcasted = int192(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 192 bits");
    }

    /**
     * @dev Returns the downcasted int184 from int256, reverting on
     * overflow (when the input is less than smallest int184 or
     * greater than largest int184).
     *
     * Counterpart to Solidity's `int184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     *
     * _Available since v4.7._
     */
    function toInt184(int256 value) internal pure returns (int184 downcasted) {
        downcasted = int184(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 184 bits");
    }

    /**
     * @dev Returns the downcasted int176 from int256, reverting on
     * overflow (when the input is less than smallest int176 or
     * greater than largest int176).
     *
     * Counterpart to Solidity's `int176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     *
     * _Available since v4.7._
     */
    function toInt176(int256 value) internal pure returns (int176 downcasted) {
        downcasted = int176(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 176 bits");
    }

    /**
     * @dev Returns the downcasted int168 from int256, reverting on
     * overflow (when the input is less than smallest int168 or
     * greater than largest int168).
     *
     * Counterpart to Solidity's `int168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     *
     * _Available since v4.7._
     */
    function toInt168(int256 value) internal pure returns (int168 downcasted) {
        downcasted = int168(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 168 bits");
    }

    /**
     * @dev Returns the downcasted int160 from int256, reverting on
     * overflow (when the input is less than smallest int160 or
     * greater than largest int160).
     *
     * Counterpart to Solidity's `int160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     *
     * _Available since v4.7._
     */
    function toInt160(int256 value) internal pure returns (int160 downcasted) {
        downcasted = int160(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 160 bits");
    }

    /**
     * @dev Returns the downcasted int152 from int256, reverting on
     * overflow (when the input is less than smallest int152 or
     * greater than largest int152).
     *
     * Counterpart to Solidity's `int152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     *
     * _Available since v4.7._
     */
    function toInt152(int256 value) internal pure returns (int152 downcasted) {
        downcasted = int152(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 152 bits");
    }

    /**
     * @dev Returns the downcasted int144 from int256, reverting on
     * overflow (when the input is less than smallest int144 or
     * greater than largest int144).
     *
     * Counterpart to Solidity's `int144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     *
     * _Available since v4.7._
     */
    function toInt144(int256 value) internal pure returns (int144 downcasted) {
        downcasted = int144(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 144 bits");
    }

    /**
     * @dev Returns the downcasted int136 from int256, reverting on
     * overflow (when the input is less than smallest int136 or
     * greater than largest int136).
     *
     * Counterpart to Solidity's `int136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     *
     * _Available since v4.7._
     */
    function toInt136(int256 value) internal pure returns (int136 downcasted) {
        downcasted = int136(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 136 bits");
    }

    /**
     * @dev Returns the downcasted int128 from int256, reverting on
     * overflow (when the input is less than smallest int128 or
     * greater than largest int128).
     *
     * Counterpart to Solidity's `int128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     *
     * _Available since v3.1._
     */
    function toInt128(int256 value) internal pure returns (int128 downcasted) {
        downcasted = int128(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 128 bits");
    }

    /**
     * @dev Returns the downcasted int120 from int256, reverting on
     * overflow (when the input is less than smallest int120 or
     * greater than largest int120).
     *
     * Counterpart to Solidity's `int120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     *
     * _Available since v4.7._
     */
    function toInt120(int256 value) internal pure returns (int120 downcasted) {
        downcasted = int120(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 120 bits");
    }

    /**
     * @dev Returns the downcasted int112 from int256, reverting on
     * overflow (when the input is less than smallest int112 or
     * greater than largest int112).
     *
     * Counterpart to Solidity's `int112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     *
     * _Available since v4.7._
     */
    function toInt112(int256 value) internal pure returns (int112 downcasted) {
        downcasted = int112(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 112 bits");
    }

    /**
     * @dev Returns the downcasted int104 from int256, reverting on
     * overflow (when the input is less than smallest int104 or
     * greater than largest int104).
     *
     * Counterpart to Solidity's `int104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     *
     * _Available since v4.7._
     */
    function toInt104(int256 value) internal pure returns (int104 downcasted) {
        downcasted = int104(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 104 bits");
    }

    /**
     * @dev Returns the downcasted int96 from int256, reverting on
     * overflow (when the input is less than smallest int96 or
     * greater than largest int96).
     *
     * Counterpart to Solidity's `int96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     *
     * _Available since v4.7._
     */
    function toInt96(int256 value) internal pure returns (int96 downcasted) {
        downcasted = int96(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 96 bits");
    }

    /**
     * @dev Returns the downcasted int88 from int256, reverting on
     * overflow (when the input is less than smallest int88 or
     * greater than largest int88).
     *
     * Counterpart to Solidity's `int88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     *
     * _Available since v4.7._
     */
    function toInt88(int256 value) internal pure returns (int88 downcasted) {
        downcasted = int88(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 88 bits");
    }

    /**
     * @dev Returns the downcasted int80 from int256, reverting on
     * overflow (when the input is less than smallest int80 or
     * greater than largest int80).
     *
     * Counterpart to Solidity's `int80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     *
     * _Available since v4.7._
     */
    function toInt80(int256 value) internal pure returns (int80 downcasted) {
        downcasted = int80(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 80 bits");
    }

    /**
     * @dev Returns the downcasted int72 from int256, reverting on
     * overflow (when the input is less than smallest int72 or
     * greater than largest int72).
     *
     * Counterpart to Solidity's `int72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     *
     * _Available since v4.7._
     */
    function toInt72(int256 value) internal pure returns (int72 downcasted) {
        downcasted = int72(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 72 bits");
    }

    /**
     * @dev Returns the downcasted int64 from int256, reverting on
     * overflow (when the input is less than smallest int64 or
     * greater than largest int64).
     *
     * Counterpart to Solidity's `int64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     *
     * _Available since v3.1._
     */
    function toInt64(int256 value) internal pure returns (int64 downcasted) {
        downcasted = int64(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 64 bits");
    }

    /**
     * @dev Returns the downcasted int56 from int256, reverting on
     * overflow (when the input is less than smallest int56 or
     * greater than largest int56).
     *
     * Counterpart to Solidity's `int56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     *
     * _Available since v4.7._
     */
    function toInt56(int256 value) internal pure returns (int56 downcasted) {
        downcasted = int56(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 56 bits");
    }

    /**
     * @dev Returns the downcasted int48 from int256, reverting on
     * overflow (when the input is less than smallest int48 or
     * greater than largest int48).
     *
     * Counterpart to Solidity's `int48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     *
     * _Available since v4.7._
     */
    function toInt48(int256 value) internal pure returns (int48 downcasted) {
        downcasted = int48(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 48 bits");
    }

    /**
     * @dev Returns the downcasted int40 from int256, reverting on
     * overflow (when the input is less than smallest int40 or
     * greater than largest int40).
     *
     * Counterpart to Solidity's `int40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     *
     * _Available since v4.7._
     */
    function toInt40(int256 value) internal pure returns (int40 downcasted) {
        downcasted = int40(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 40 bits");
    }

    /**
     * @dev Returns the downcasted int32 from int256, reverting on
     * overflow (when the input is less than smallest int32 or
     * greater than largest int32).
     *
     * Counterpart to Solidity's `int32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     *
     * _Available since v3.1._
     */
    function toInt32(int256 value) internal pure returns (int32 downcasted) {
        downcasted = int32(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 32 bits");
    }

    /**
     * @dev Returns the downcasted int24 from int256, reverting on
     * overflow (when the input is less than smallest int24 or
     * greater than largest int24).
     *
     * Counterpart to Solidity's `int24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     *
     * _Available since v4.7._
     */
    function toInt24(int256 value) internal pure returns (int24 downcasted) {
        downcasted = int24(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 24 bits");
    }

    /**
     * @dev Returns the downcasted int16 from int256, reverting on
     * overflow (when the input is less than smallest int16 or
     * greater than largest int16).
     *
     * Counterpart to Solidity's `int16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     *
     * _Available since v3.1._
     */
    function toInt16(int256 value) internal pure returns (int16 downcasted) {
        downcasted = int16(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 16 bits");
    }

    /**
     * @dev Returns the downcasted int8 from int256, reverting on
     * overflow (when the input is less than smallest int8 or
     * greater than largest int8).
     *
     * Counterpart to Solidity's `int8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     *
     * _Available since v3.1._
     */
    function toInt8(int256 value) internal pure returns (int8 downcasted) {
        downcasted = int8(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 8 bits");
    }

    /**
     * @dev Converts an unsigned uint256 into a signed int256.
     *
     * Requirements:
     *
     * - input must be less than or equal to maxInt256.
     *
     * _Available since v3.0._
     */
    function toInt256(uint256 value) internal pure returns (int256) {
        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
        require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256");
        return int256(value);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) external returns (bool);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

File 16 of 17 : IERC3156FlashBorrower.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (interfaces/IERC3156FlashBorrower.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC3156 FlashBorrower, as defined in
 * https://eips.ethereum.org/EIPS/eip-3156[ERC-3156].
 *
 * _Available since v4.1._
 */
interface IERC3156FlashBorrower {
    /**
     * @dev Receive a flash loan.
     * @param initiator The initiator of the loan.
     * @param token The loan currency.
     * @param amount The amount of tokens lent.
     * @param fee The additional amount of tokens to repay.
     * @param data Arbitrary data structure, intended to contain user-defined parameters.
     * @return The keccak256 hash of "IERC3156FlashBorrower.onFlashLoan"
     */
    function onFlashLoan(
        address initiator,
        address token,
        uint256 amount,
        uint256 fee,
        bytes calldata data
    ) external returns (bytes32);
}

// SPDX-License-Identifier: MIT

pragma solidity 0.8.26;

import {IMetaCore} from "src/interfaces/core/IMetaCore.sol";

interface ICore {

    // --- Public variables ---
    function metaCore() external view returns (IMetaCore);
    function startTime() external view returns (uint256);
    function CCR() external view returns (uint256);
    function dmBootstrapPeriod() external view returns (uint64);
    function isPeriphery(address peripheryContract) external view returns (bool);

    // --- External functions ---

    function setPeripheryEnabled(address _periphery, bool _enabled) external;
    function setPMBootstrapPeriod(address dm, uint64 _bootstrapPeriod) external;
    function setNewCCR(uint256 _CCR) external;

    function priceFeed() external view returns (address);
    function owner() external view returns (address);
    function pendingOwner() external view returns (address);
    function guardian() external view returns (address);
    function feeReceiver() external view returns (address);
    function paused() external view returns (bool);
    function lspBootstrapPeriod() external view returns (uint64);
    function getLspEntryFee(address rebalancer) external view returns (uint16);
    function getLspExitFee(address rebalancer) external view returns (uint16);
    function interestProtocolShare() external view returns (uint16);
    function defaultInterestReceiver() external view returns (address);

    // --- Events ---
    event CCRSet(uint256 initialCCR);
    event PMBootstrapPeriodSet(address dm, uint64 bootstrapPeriod);
    event PeripheryEnabled(address indexed periphery, bool enabled);
}

Settings
{
  "remappings": [
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    "@openzeppelin-upgradeable/contracts/=lib/openzeppelin-contracts-upgradeable/contracts/",
    "solady/=lib/solady/src/",
    "@solmate/=lib/solmate/src/",
    "@chimera/=lib/chimera/src/",
    "forge-std/=lib/forge-std/src/",
    "@uniswap/v3-core/=lib/v3-core/",
    "@uniswap/v3-periphery/=lib/v3-periphery/",
    "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
    "chimera/=lib/chimera/src/",
    "ds-test/=lib/solmate/lib/ds-test/src/",
    "erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
    "halmos-cheatcodes/=lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/",
    "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "rewards/=lib/rewards/",
    "solmate/=lib/solmate/src/",
    "uniswap/=lib/uniswap/",
    "v3-core/=lib/v3-core/contracts/",
    "v3-periphery/=lib/v3-periphery/contracts/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 1
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "cancun",
  "viaIR": false
}

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"contract ILiquidStabilityPool","name":"_lsp","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"collateralTokens","outputs":[{"internalType":"address[]","name":"res","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"containsExtraAsset","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"emissionScheduleEmissions","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"emissionScheduleLockTimestamp","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"emissionScheduleUnlockRatePerSecond","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"extraAssets","outputs":[{"internalType":"address[]","name":"res","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"extraAssetsIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeReceiver","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"firstSunsetIndexKey","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getBalanceOfWithFutureEmissions","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getFullProfitUnlockTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"address","name":"tokenOut","type":"address"}],"name":"getThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getTokenVirtualBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"collateral","type":"address"}],"name":"indexByCollateral","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"factory","type":"address"}],"name":"isFactory","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"liquidationManager","type":"address"}],"name":"isLiquidationManager","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"redeemer","type":"address"}],"name":"isPrivilegedDebtRedeemer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lsp","outputs":[{"internalType":"contract ILiquidStabilityPool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"metaCore","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nextSunsetIndexKey","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"index","type":"uint16"}],"name":"sunsetIndexExpiry","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"index","type":"uint16"}],"name":"sunsetIndexIdx","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"key","type":"bytes32"}],"name":"threshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"unlockRatePerSecond","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"unlockedEmissions","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]

60a0604052348015600e575f80fd5b50604051611637380380611637833981016040819052602b91603b565b6001600160a01b03166080526066565b5f60208284031215604a575f80fd5b81516001600160a01b0381168114605f575f80fd5b9392505050565b60805161156c6100cb5f395f8181610361015281816103b80152818161047901528181610568015281816106120152818161072e015281816108950152818161096801528181610a8401528181610b7901528181610c270152610cf8015261156c5ff3fe608060405234801561000f575f80fd5b506004361061013c575f3560e01c80630b4b419a146101405780630f04ba671461017057806325605b6d14610193578063295ee4a3146101b457806329d78c88146101c7578063474566c6146101da5780634931b767146101fa5780634b9dddb01461020f5780635383dfcb146102225780635c73893814610235578063675ab22c1461025057806369e731601461026357806372458a161461026b5780639e2258c61461027e578063b3f0067414610291578063b81c8d1914610299578063c7206531146102c4578063d312ef4f146102d7578063d5c16d79146102ea578063d66213c6146102fd578063d9c0019714610310578063df43c29014610323578063e3d670d714610336578063ebe22ff614610349578063f188e4311461035c578063f7166cc614610383575b5f80fd5b61015361014e36600461129d565b61038b565b6040516001600160801b0390911681526020015b60405180910390f35b61018361017e3660046112d4565b610451565b6040519015158152602001610167565b6101a66101a13660046112ed565b610515565b604051908152602001610167565b6101836101c23660046112d4565b610523565b6101a66101d53660046112d4565b610531565b6101e2610541565b6040516001600160a01b039091168152602001610167565b6102026105ff565b6040516101679190611304565b6101a661021d3660046112d4565b6107f7565b6101a66102303660046112d4565b610874565b61023d610882565b60405161ffff9091168152602001610167565b61018361025e3660046112d4565b610943565b610202610955565b6101a66102793660046112d4565b610b47565b61015361028c36600461129d565b610c13565b6101e2610cd7565b6102ac6102a73660046112d4565b610ce4565b6040516001600160401b039091168152602001610167565b6101a66102d23660046112d4565b610d42565b6101a66102e536600461134f565b610d9c565b6101a66102f83660046112d4565b610ded565b61015361030b3660046112d4565b610e3f565b6101a661031e3660046112d4565b610e4d565b6102ac6103313660046112d4565b610e97565b6101a66103443660046112d4565b610ea5565b6101836103573660046112d4565b610eb3565b6101e27f000000000000000000000000000000000000000000000000000000000000000081565b61023d610ec1565b5f8061039e61039984610ece565b610f25565b604051637784c68560e01b81529091506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690637784c685906103ed908490600401611380565b5f60405180830381865afa158015610407573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f1916820160405261042e91908101906113cb565b5f8151811061043f5761043f611492565b60200260200101515f1c915050919050565b5f8061045f61039984610f6e565b604051637784c68560e01b81529091506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690637784c685906104ae908490600401611380565b5f60405180830381865afa1580156104c8573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526104ef91908101906113cb565b5f8151811061050057610500611492565b60200260200101515f1c600114915050919050565b5f8061039e61039984610fae565b5f8061045f61039984610fe6565b5f61053b82610ea5565b92915050565b5f8061054e610399611000565b604051637784c68560e01b81529091506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690637784c6859061059d908490600401611380565b5f60405180830381865afa1580156105b7573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526105de91908101906113cb565b5f815181106105ef576105ef611492565b60200260200101515f1c91505090565b60605f61060d61039961101d565b90505f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316637784c685836040518263ffffffff1660e01b815260040161065c9190611380565b5f60405180830381865afa158015610676573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f1916820160405261069d91908101906113cb565b5f815181106106ae576106ae611492565b60200260200101515f1c9050806001600160401b038111156106d2576106d26113b7565b6040519080825280602002602001820160405280156106fb578160200160208202803683370190505b5092505f5b818110156107f15761071461039982611036565b604051637784c68560e01b81529093506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690637784c68590610763908690600401611380565b5f60405180830381865afa15801561077d573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526107a491908101906113cb565b5f815181106107b5576107b5611492565b60200260200101515f1c8482815181106107d1576107d1611492565b6001600160a01b0390921660209283029190910190910152600101610700565b50505090565b5f80604051806060016040528061080d85610e3f565b6001600160801b0316815260200161082485610e97565b6001600160401b0316815260200161083b85610ce4565b6001600160401b03169052905061085a8161085581611084565b6110b5565b61086384610ea5565b61086d91906114ba565b9392505050565b5f8061039e6103998461113c565b5f8061088f610399611156565b905060107f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316637784c685836040518263ffffffff1660e01b81526004016108df9190611380565b5f60405180830381865afa1580156108f9573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f1916820160405261092091908101906113cb565b5f8151811061093157610931611492565b6020026020010151901c5f1c91505090565b5f61094d82610b47565b151592915050565b60605f61096361039961116f565b90505f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316637784c685836040518263ffffffff1660e01b81526004016109b29190611380565b5f60405180830381865afa1580156109cc573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526109f391908101906113cb565b5f81518110610a0457610a04611492565b60200260200101515f1c9050806001600160401b03811115610a2857610a286113b7565b604051908082528060200260200182016040528015610a51578160200160208202803683370190505b5092505f5b818110156107f157610a6a61039982611188565b604051637784c68560e01b81529093506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690637784c68590610ab9908690600401611380565b5f60405180830381865afa158015610ad3573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052610afa91908101906113cb565b5f81518110610b0b57610b0b611492565b60200260200101515f1c848281518110610b2757610b27611492565b6001600160a01b0390921660209283029190910190910152600101610a56565b5f6001600160a01b03821681610b5f610399836111a2565b604051637784c68560e01b81529091506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690637784c68590610bae908490600401611380565b5f60405180830381865afa158015610bc8573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052610bef91908101906113cb565b5f81518110610c0057610c00611492565b60200260200101515f1c92505050919050565b5f80610c2161039984610ece565b905060807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316637784c685836040518263ffffffff1660e01b8152600401610c719190611380565b5f60405180830381865afa158015610c8b573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052610cb291908101906113cb565b5f81518110610cc357610cc3611492565b6020026020010151901c5f1c915050919050565b5f8061054e6103996111bc565b5f80610cf2610399846111d5565b905060c07f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316637784c685836040518263ffffffff1660e01b8152600401610c719190611380565b5f806040518060600160405280610d5885610e3f565b6001600160801b03168152602001610d6f85610e97565b6001600160401b03168152602001610d8685610ce4565b6001600160401b03169052905061086d816111ef565b6040516001600160601b0319606084811b8216602084015283901b1660348201525f908190604801604051602081830303815290604052805190602001209050610de581610515565b949350505050565b5f8060405180606001604052805f6001600160801b03168152602001610e1285610e97565b6001600160401b03168152602001610e2985610ce4565b6001600160401b03169052905061086d81611084565b5f8061039e610399846111d5565b5f8060405180606001604052805f6001600160801b031681526020015f6001600160401b03168152602001610e8185610ce4565b6001600160401b03169052905061086d81611212565b5f80610c21610399846111d5565b5f8061039e61039984611247565b5f8061045f61039984611261565b5f8061054e610399611156565b5f80610ee860065f805160206115178339815191526114cd565b6040805161ffff861660208201529081018290529091505f906060015b60408051601f198184030181529190528051602090910120949350505050565b6040805160018082528183019092526060915f91906020808301908036833701905050905082815f81518110610f5d57610f5d611492565b602090810291909101015292915050565b5f80610f88600b5f805160206115178339815191526114cd565b604080516001600160a01b03861660208201529081018290529091505f90606001610f05565b5f80610fc860085f805160206115178339815191526114cd565b60408051602081018690529081018290529091505f90606001610f05565b5f80610f88600c5f805160206115178339815191526114cd565b5f611018815f805160206115178339815191526114cd565b919050565b5f61101860025f805160206115178339815191526114cd565b5f8161105060025f805160206115178339815191526114cd565b60405160200161106291815260200190565b604051602081830303815290604052805190602001205f1c61053b91906114cd565b60208101515f906001600160401b03166110ab64e8d4a510006110a685611212565b61127b565b61053b91906114cd565b5f8142106110c457505f61053b565b5f83602001516001600160401b0316426110de91906114ba565b90505f816110eb86611212565b6110f591906114e0565b855190915064e8d4a5100090611114906001600160801b0316836114e0565b61111e91906114f7565b855161113391906001600160801b03166114ba565b9250505061053b565b5f80610f8860075f805160206115178339815191526114cd565b5f61101860045f805160206115178339815191526114cd565b5f61101860055f805160206115178339815191526114cd565b5f8161105060055f805160206115178339815191526114cd565b5f80610fc860035f805160206115178339815191526114cd565b5f61101860015f805160206115178339815191526114cd565b5f80610f88600a5f805160206115178339815191526114cd565b5f6111fd8261085584611084565b825161053b91906001600160801b03166114ba565b5f81604001516001600160401b03165f14611231578160400151611238565b64174876e8005b6001600160401b031692915050565b5f80610f8860095f805160206115178339815191526114cd565b5f80610f88600d5f805160206115178339815191526114cd565b5f81600161128982866114cd565b61129391906114ba565b61086d91906114f7565b5f602082840312156112ad575f80fd5b813561ffff8116811461086d575f80fd5b80356001600160a01b0381168114611018575f80fd5b5f602082840312156112e4575f80fd5b61086d826112be565b5f602082840312156112fd575f80fd5b5035919050565b602080825282518282018190525f918401906040840190835b818110156113445783516001600160a01b031683526020938401939092019160010161131d565b509095945050505050565b5f8060408385031215611360575f80fd5b611369836112be565b9150611377602084016112be565b90509250929050565b602080825282518282018190525f918401906040840190835b81811015611344578351835260209384019390920191600101611399565b634e487b7160e01b5f52604160045260245ffd5b5f602082840312156113db575f80fd5b81516001600160401b038111156113f0575f80fd5b8201601f81018413611400575f80fd5b80516001600160401b03811115611419576114196113b7565b604051600582901b90603f8201601f191681016001600160401b0381118282101715611447576114476113b7565b604052918252602081840181019290810187841115611464575f80fd5b6020850194505b838510156114875784518082526020958601959093500161146b565b509695505050505050565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b8181038181111561053b5761053b6114a6565b8082018082111561053b5761053b6114a6565b808202811582820484141761053b5761053b6114a6565b5f8261151157634e487b7160e01b5f52601260045260245ffd5b50049056fe3c2bbd5b01c023780ac7877400fd851b17fd98c152afdb1efc02015acd68a300a26469706673582212204e55aa5dbd9d3ea2296b631363629a8bcb0441caa20f6c6b4fa50e9018c405aa64736f6c634300081a003300000000000000000000000044bc1c218d3ee787ca222c09a5b30e090bf96217

Deployed Bytecode

0x608060405234801561000f575f80fd5b506004361061013c575f3560e01c80630b4b419a146101405780630f04ba671461017057806325605b6d14610193578063295ee4a3146101b457806329d78c88146101c7578063474566c6146101da5780634931b767146101fa5780634b9dddb01461020f5780635383dfcb146102225780635c73893814610235578063675ab22c1461025057806369e731601461026357806372458a161461026b5780639e2258c61461027e578063b3f0067414610291578063b81c8d1914610299578063c7206531146102c4578063d312ef4f146102d7578063d5c16d79146102ea578063d66213c6146102fd578063d9c0019714610310578063df43c29014610323578063e3d670d714610336578063ebe22ff614610349578063f188e4311461035c578063f7166cc614610383575b5f80fd5b61015361014e36600461129d565b61038b565b6040516001600160801b0390911681526020015b60405180910390f35b61018361017e3660046112d4565b610451565b6040519015158152602001610167565b6101a66101a13660046112ed565b610515565b604051908152602001610167565b6101836101c23660046112d4565b610523565b6101a66101d53660046112d4565b610531565b6101e2610541565b6040516001600160a01b039091168152602001610167565b6102026105ff565b6040516101679190611304565b6101a661021d3660046112d4565b6107f7565b6101a66102303660046112d4565b610874565b61023d610882565b60405161ffff9091168152602001610167565b61018361025e3660046112d4565b610943565b610202610955565b6101a66102793660046112d4565b610b47565b61015361028c36600461129d565b610c13565b6101e2610cd7565b6102ac6102a73660046112d4565b610ce4565b6040516001600160401b039091168152602001610167565b6101a66102d23660046112d4565b610d42565b6101a66102e536600461134f565b610d9c565b6101a66102f83660046112d4565b610ded565b61015361030b3660046112d4565b610e3f565b6101a661031e3660046112d4565b610e4d565b6102ac6103313660046112d4565b610e97565b6101a66103443660046112d4565b610ea5565b6101836103573660046112d4565b610eb3565b6101e27f00000000000000000000000044bc1c218d3ee787ca222c09a5b30e090bf9621781565b61023d610ec1565b5f8061039e61039984610ece565b610f25565b604051637784c68560e01b81529091506001600160a01b037f00000000000000000000000044bc1c218d3ee787ca222c09a5b30e090bf962171690637784c685906103ed908490600401611380565b5f60405180830381865afa158015610407573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f1916820160405261042e91908101906113cb565b5f8151811061043f5761043f611492565b60200260200101515f1c915050919050565b5f8061045f61039984610f6e565b604051637784c68560e01b81529091506001600160a01b037f00000000000000000000000044bc1c218d3ee787ca222c09a5b30e090bf962171690637784c685906104ae908490600401611380565b5f60405180830381865afa1580156104c8573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526104ef91908101906113cb565b5f8151811061050057610500611492565b60200260200101515f1c600114915050919050565b5f8061039e61039984610fae565b5f8061045f61039984610fe6565b5f61053b82610ea5565b92915050565b5f8061054e610399611000565b604051637784c68560e01b81529091506001600160a01b037f00000000000000000000000044bc1c218d3ee787ca222c09a5b30e090bf962171690637784c6859061059d908490600401611380565b5f60405180830381865afa1580156105b7573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526105de91908101906113cb565b5f815181106105ef576105ef611492565b60200260200101515f1c91505090565b60605f61060d61039961101d565b90505f7f00000000000000000000000044bc1c218d3ee787ca222c09a5b30e090bf962176001600160a01b0316637784c685836040518263ffffffff1660e01b815260040161065c9190611380565b5f60405180830381865afa158015610676573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f1916820160405261069d91908101906113cb565b5f815181106106ae576106ae611492565b60200260200101515f1c9050806001600160401b038111156106d2576106d26113b7565b6040519080825280602002602001820160405280156106fb578160200160208202803683370190505b5092505f5b818110156107f15761071461039982611036565b604051637784c68560e01b81529093506001600160a01b037f00000000000000000000000044bc1c218d3ee787ca222c09a5b30e090bf962171690637784c68590610763908690600401611380565b5f60405180830381865afa15801561077d573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526107a491908101906113cb565b5f815181106107b5576107b5611492565b60200260200101515f1c8482815181106107d1576107d1611492565b6001600160a01b0390921660209283029190910190910152600101610700565b50505090565b5f80604051806060016040528061080d85610e3f565b6001600160801b0316815260200161082485610e97565b6001600160401b0316815260200161083b85610ce4565b6001600160401b03169052905061085a8161085581611084565b6110b5565b61086384610ea5565b61086d91906114ba565b9392505050565b5f8061039e6103998461113c565b5f8061088f610399611156565b905060107f00000000000000000000000044bc1c218d3ee787ca222c09a5b30e090bf962176001600160a01b0316637784c685836040518263ffffffff1660e01b81526004016108df9190611380565b5f60405180830381865afa1580156108f9573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f1916820160405261092091908101906113cb565b5f8151811061093157610931611492565b6020026020010151901c5f1c91505090565b5f61094d82610b47565b151592915050565b60605f61096361039961116f565b90505f7f00000000000000000000000044bc1c218d3ee787ca222c09a5b30e090bf962176001600160a01b0316637784c685836040518263ffffffff1660e01b81526004016109b29190611380565b5f60405180830381865afa1580156109cc573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526109f391908101906113cb565b5f81518110610a0457610a04611492565b60200260200101515f1c9050806001600160401b03811115610a2857610a286113b7565b604051908082528060200260200182016040528015610a51578160200160208202803683370190505b5092505f5b818110156107f157610a6a61039982611188565b604051637784c68560e01b81529093506001600160a01b037f00000000000000000000000044bc1c218d3ee787ca222c09a5b30e090bf962171690637784c68590610ab9908690600401611380565b5f60405180830381865afa158015610ad3573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052610afa91908101906113cb565b5f81518110610b0b57610b0b611492565b60200260200101515f1c848281518110610b2757610b27611492565b6001600160a01b0390921660209283029190910190910152600101610a56565b5f6001600160a01b03821681610b5f610399836111a2565b604051637784c68560e01b81529091506001600160a01b037f00000000000000000000000044bc1c218d3ee787ca222c09a5b30e090bf962171690637784c68590610bae908490600401611380565b5f60405180830381865afa158015610bc8573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052610bef91908101906113cb565b5f81518110610c0057610c00611492565b60200260200101515f1c92505050919050565b5f80610c2161039984610ece565b905060807f00000000000000000000000044bc1c218d3ee787ca222c09a5b30e090bf962176001600160a01b0316637784c685836040518263ffffffff1660e01b8152600401610c719190611380565b5f60405180830381865afa158015610c8b573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052610cb291908101906113cb565b5f81518110610cc357610cc3611492565b6020026020010151901c5f1c915050919050565b5f8061054e6103996111bc565b5f80610cf2610399846111d5565b905060c07f00000000000000000000000044bc1c218d3ee787ca222c09a5b30e090bf962176001600160a01b0316637784c685836040518263ffffffff1660e01b8152600401610c719190611380565b5f806040518060600160405280610d5885610e3f565b6001600160801b03168152602001610d6f85610e97565b6001600160401b03168152602001610d8685610ce4565b6001600160401b03169052905061086d816111ef565b6040516001600160601b0319606084811b8216602084015283901b1660348201525f908190604801604051602081830303815290604052805190602001209050610de581610515565b949350505050565b5f8060405180606001604052805f6001600160801b03168152602001610e1285610e97565b6001600160401b03168152602001610e2985610ce4565b6001600160401b03169052905061086d81611084565b5f8061039e610399846111d5565b5f8060405180606001604052805f6001600160801b031681526020015f6001600160401b03168152602001610e8185610ce4565b6001600160401b03169052905061086d81611212565b5f80610c21610399846111d5565b5f8061039e61039984611247565b5f8061045f61039984611261565b5f8061054e610399611156565b5f80610ee860065f805160206115178339815191526114cd565b6040805161ffff861660208201529081018290529091505f906060015b60408051601f198184030181529190528051602090910120949350505050565b6040805160018082528183019092526060915f91906020808301908036833701905050905082815f81518110610f5d57610f5d611492565b602090810291909101015292915050565b5f80610f88600b5f805160206115178339815191526114cd565b604080516001600160a01b03861660208201529081018290529091505f90606001610f05565b5f80610fc860085f805160206115178339815191526114cd565b60408051602081018690529081018290529091505f90606001610f05565b5f80610f88600c5f805160206115178339815191526114cd565b5f611018815f805160206115178339815191526114cd565b919050565b5f61101860025f805160206115178339815191526114cd565b5f8161105060025f805160206115178339815191526114cd565b60405160200161106291815260200190565b604051602081830303815290604052805190602001205f1c61053b91906114cd565b60208101515f906001600160401b03166110ab64e8d4a510006110a685611212565b61127b565b61053b91906114cd565b5f8142106110c457505f61053b565b5f83602001516001600160401b0316426110de91906114ba565b90505f816110eb86611212565b6110f591906114e0565b855190915064e8d4a5100090611114906001600160801b0316836114e0565b61111e91906114f7565b855161113391906001600160801b03166114ba565b9250505061053b565b5f80610f8860075f805160206115178339815191526114cd565b5f61101860045f805160206115178339815191526114cd565b5f61101860055f805160206115178339815191526114cd565b5f8161105060055f805160206115178339815191526114cd565b5f80610fc860035f805160206115178339815191526114cd565b5f61101860015f805160206115178339815191526114cd565b5f80610f88600a5f805160206115178339815191526114cd565b5f6111fd8261085584611084565b825161053b91906001600160801b03166114ba565b5f81604001516001600160401b03165f14611231578160400151611238565b64174876e8005b6001600160401b031692915050565b5f80610f8860095f805160206115178339815191526114cd565b5f80610f88600d5f805160206115178339815191526114cd565b5f81600161128982866114cd565b61129391906114ba565b61086d91906114f7565b5f602082840312156112ad575f80fd5b813561ffff8116811461086d575f80fd5b80356001600160a01b0381168114611018575f80fd5b5f602082840312156112e4575f80fd5b61086d826112be565b5f602082840312156112fd575f80fd5b5035919050565b602080825282518282018190525f918401906040840190835b818110156113445783516001600160a01b031683526020938401939092019160010161131d565b509095945050505050565b5f8060408385031215611360575f80fd5b611369836112be565b9150611377602084016112be565b90509250929050565b602080825282518282018190525f918401906040840190835b81811015611344578351835260209384019390920191600101611399565b634e487b7160e01b5f52604160045260245ffd5b5f602082840312156113db575f80fd5b81516001600160401b038111156113f0575f80fd5b8201601f81018413611400575f80fd5b80516001600160401b03811115611419576114196113b7565b604051600582901b90603f8201601f191681016001600160401b0381118282101715611447576114476113b7565b604052918252602081840181019290810187841115611464575f80fd5b6020850194505b838510156114875784518082526020958601959093500161146b565b509695505050505050565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b8181038181111561053b5761053b6114a6565b8082018082111561053b5761053b6114a6565b808202811582820484141761053b5761053b6114a6565b5f8261151157634e487b7160e01b5f52601260045260245ffd5b50049056fe3c2bbd5b01c023780ac7877400fd851b17fd98c152afdb1efc02015acd68a300a26469706673582212204e55aa5dbd9d3ea2296b631363629a8bcb0441caa20f6c6b4fa50e9018c405aa64736f6c634300081a0033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

00000000000000000000000044bc1c218d3ee787ca222c09a5b30e090bf96217

-----Decoded View---------------
Arg [0] : _lsp (address): 0x44bc1C218d3eE787Ca222C09a5B30E090bf96217

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 00000000000000000000000044bc1c218d3ee787ca222c09a5b30e090bf96217


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.