Source Code
Overview
ETH Balance
0 ETH
ETH Value
$0.00| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
Latest 1 internal transaction
Advanced mode:
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 25195675 | 116 days ago | Contract Creation | 0 ETH |
Cross-Chain Transactions
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
MitosisVault
Compiler Version
v0.8.30+commit.73712a01
Optimization Enabled:
Yes with 150 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.28;
import { IERC20 } from '@oz/token/ERC20/IERC20.sol';
import { SafeERC20 } from '@oz/token/ERC20/utils/SafeERC20.sol';
import { Address } from '@oz/utils/Address.sol';
import { Math } from '@oz/utils/math/Math.sol';
import { AccessControlEnumerableUpgradeable } from '@ozu/access/extensions/AccessControlEnumerableUpgradeable.sol';
import { UUPSUpgradeable } from '@ozu/proxy/utils/UUPSUpgradeable.sol';
import { AssetAction, IMitosisVault } from '../interfaces/branch/IMitosisVault.sol';
import { IMitosisVaultEntrypoint } from '../interfaces/branch/IMitosisVaultEntrypoint.sol';
import { ERC7201Utils } from '../lib/ERC7201Utils.sol';
import { Pausable } from '../lib/Pausable.sol';
import { StdError } from '../lib/StdError.sol';
import { Versioned } from '../lib/Versioned.sol';
import { MitosisVaultVLF } from './MitosisVaultVLF.sol';
contract MitosisVault is
IMitosisVault,
Pausable,
AccessControlEnumerableUpgradeable,
UUPSUpgradeable,
MitosisVaultVLF,
Versioned
{
using SafeERC20 for IERC20;
using ERC7201Utils for string;
/// @dev Role for managing caps
bytes32 public constant LIQUIDITY_MANAGER_ROLE = keccak256('LIQUIDITY_MANAGER_ROLE');
struct AssetInfo {
bool initialized;
uint256 maxCap;
uint256 availableCap;
mapping(AssetAction => bool) isHalted;
}
struct StorageV1 {
IMitosisVaultEntrypoint entrypoint;
mapping(address asset => AssetInfo) assets;
}
string private constant _NAMESPACE = 'mitosis.storage.MitosisVaultStorage.v1';
bytes32 private immutable _slot = _NAMESPACE.storageSlot();
function _getStorageV1() internal view returns (StorageV1 storage $) {
bytes32 slot = _slot;
// slither-disable-next-line assembly
assembly {
$.slot := slot
}
}
//=========== NOTE: INITIALIZATION FUNCTIONS ===========//
constructor() {
_disableInitializers();
}
fallback() external payable {
revert StdError.NotSupported();
}
receive() external payable {
revert StdError.NotSupported();
}
function initialize(address owner_) public initializer {
__Pausable_init();
__AccessControl_init();
__AccessControlEnumerable_init();
__UUPSUpgradeable_init();
_grantRole(DEFAULT_ADMIN_ROLE, owner_);
}
//=========== NOTE: VIEW FUNCTIONS ===========//
function maxCap(address asset) external view returns (uint256) {
return _getStorageV1().assets[asset].maxCap;
}
function availableCap(address asset) external view returns (uint256) {
return _getStorageV1().assets[asset].availableCap;
}
function isAssetActionHalted(address asset, AssetAction action) external view returns (bool) {
return _isHalted(_getStorageV1(), asset, action);
}
function isAssetInitialized(address asset) external view returns (bool) {
return _isAssetInitialized(_getStorageV1(), asset);
}
function entrypoint() external view override returns (address) {
return address(_getStorageV1().entrypoint);
}
function quoteDeposit(address asset, address to, uint256 amount) external view returns (uint256) {
return _getStorageV1().entrypoint.quoteDeposit(asset, to, amount);
}
//=========== NOTE: MUTATIVE - ASSET FUNCTIONS ===========//
function initializeAsset(address asset) external whenNotPaused {
StorageV1 storage $ = _getStorageV1();
_assertOnlyEntrypoint($);
_assertAssetNotInitialized($, asset);
$.assets[asset].initialized = true;
emit AssetInitialized(asset);
// NOTE: we halt deposit and keep the cap at zero by default.
_haltAsset($, asset, AssetAction.Deposit);
}
function deposit(address asset, address to, uint256 amount) external payable whenNotPaused {
_deposit(asset, to, amount);
_entrypoint().deposit{ value: msg.value }(asset, to, amount, _msgSender());
emit Deposited(asset, to, amount);
}
function withdraw(address asset, address to, uint256 amount) external whenNotPaused {
StorageV1 storage $ = _getStorageV1();
_assertOnlyEntrypoint($);
_assertAssetInitialized(asset);
$.assets[asset].availableCap += Math.min(amount, $.assets[asset].maxCap - $.assets[asset].availableCap);
IERC20(asset).safeTransfer(to, amount);
emit Withdrawn(asset, to, amount);
}
//=========== NOTE: MUTATIVE - ROLE BASED FUNCTIONS ===========//
function _authorizeUpgrade(address) internal override onlyRole(DEFAULT_ADMIN_ROLE) { }
function _authorizePause(address) internal view override onlyRole(DEFAULT_ADMIN_ROLE) { }
function setEntrypoint(address entrypoint_) external onlyRole(DEFAULT_ADMIN_ROLE) {
_getStorageV1().entrypoint = IMitosisVaultEntrypoint(entrypoint_);
emit EntrypointSet(address(entrypoint_));
}
function setCap(address asset, uint256 newCap) external onlyRole(LIQUIDITY_MANAGER_ROLE) {
StorageV1 storage $ = _getStorageV1();
_assertAssetInitialized(asset);
_setCap($, asset, newCap);
}
function haltAsset(address asset, AssetAction action) external onlyRole(DEFAULT_ADMIN_ROLE) {
StorageV1 storage $ = _getStorageV1();
_assertAssetInitialized(asset);
return _haltAsset($, asset, action);
}
function resumeAsset(address asset, AssetAction action) external onlyRole(DEFAULT_ADMIN_ROLE) {
StorageV1 storage $ = _getStorageV1();
_assertAssetInitialized(asset);
return _resumeAsset($, asset, action);
}
//=========== NOTE: INTERNAL FUNCTIONS ===========//
function _entrypoint() internal view override returns (IMitosisVaultEntrypoint) {
return IMitosisVaultEntrypoint(_getStorageV1().entrypoint);
}
function _assertOnlyEntrypoint(StorageV1 storage $) internal view {
require(_msgSender() == address($.entrypoint), StdError.Unauthorized());
}
function _assertCapNotExceeded(StorageV1 storage $, address asset, uint256 amount) internal view {
uint256 available = $.assets[asset].availableCap;
require(available >= amount, IMitosisVault__ExceededCap(asset, amount, available));
}
function _assertAssetInitialized(address asset) internal view override {
require(_isAssetInitialized(_getStorageV1(), asset), IMitosisVault__AssetNotInitialized(asset));
}
function _assertAssetNotInitialized(StorageV1 storage $, address asset) internal view {
require(!_isAssetInitialized($, asset), IMitosisVault__AssetAlreadyInitialized(asset));
}
function _assertNotHalted(StorageV1 storage $, address asset, AssetAction action) internal view {
require(!_isHalted($, asset, action), StdError.Halted());
}
function _isHalted(StorageV1 storage $, address asset, AssetAction action) internal view returns (bool) {
return $.assets[asset].isHalted[action];
}
function _isAssetInitialized(StorageV1 storage $, address asset) internal view returns (bool) {
return $.assets[asset].initialized;
}
function _setCap(StorageV1 storage $, address asset, uint256 newCap) internal {
AssetInfo storage assetInfo = $.assets[asset];
uint256 prevCap = assetInfo.maxCap;
uint256 prevSpent = prevCap - Math.min(assetInfo.availableCap, prevCap);
assetInfo.maxCap = newCap;
assetInfo.availableCap = newCap - Math.min(prevSpent, newCap);
emit CapSet(_msgSender(), asset, prevCap, newCap);
}
function _haltAsset(StorageV1 storage $, address asset, AssetAction action) internal {
$.assets[asset].isHalted[action] = true;
emit AssetHalted(asset, action);
}
function _resumeAsset(StorageV1 storage $, address asset, AssetAction action) internal {
$.assets[asset].isHalted[action] = false;
emit AssetResumed(asset, action);
}
function _deposit(address asset, address to, uint256 amount) internal override {
StorageV1 storage $ = _getStorageV1();
require(to != address(0), StdError.ZeroAddress('to'));
require(amount != 0, StdError.ZeroAmount());
_assertAssetInitialized(asset);
_assertNotHalted($, asset, AssetAction.Deposit);
_assertCapNotExceeded($, asset, amount);
$.assets[asset].availableCap -= amount;
IERC20(asset).safeTransferFrom(_msgSender(), address(this), amount);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
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 value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` 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 value) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
/**
* @dev An operation with an ERC-20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
* set here.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
// bubble errors
if iszero(success) {
let ptr := mload(0x40)
returndatacopy(ptr, 0, returndatasize())
revert(ptr, returndatasize())
}
returnSize := returndatasize()
returnValue := mload(0)
}
if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
bool success;
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
returnSize := returndatasize()
returnValue := mload(0)
}
return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (utils/Address.sol)
pragma solidity ^0.8.20;
import {Errors} from "./Errors.sol";
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert Errors.InsufficientBalance(address(this).balance, amount);
}
(bool success, bytes memory returndata) = recipient.call{value: amount}("");
if (!success) {
_revert(returndata);
}
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {Errors.FailedCall} error.
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert Errors.InsufficientBalance(address(this).balance, value);
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case
* of an unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {Errors.FailedCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}.
*/
function _revert(bytes memory returndata) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly ("memory-safe") {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert Errors.FailedCall();
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/Math.sol)
pragma solidity ^0.8.20;
import {Panic} from "../Panic.sol";
import {SafeCast} from "./SafeCast.sol";
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Floor, // Toward negative infinity
Ceil, // Toward positive infinity
Trunc, // Toward zero
Expand // Away from zero
}
/**
* @dev Returns the addition of two unsigned integers, with an success flag (no overflow).
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an success flag (no overflow).
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an success flag (no overflow).
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a success flag (no division by zero).
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero).
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.
*
* IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
* However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute
* one branch when needed, making this function more expensive.
*/
function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) {
unchecked {
// branchless ternary works because:
// b ^ (a ^ b) == a
// b ^ 0 == b
return b ^ ((a ^ b) * SafeCast.toUint(condition));
}
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return ternary(a > b, a, b);
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return ternary(a < b, a, b);
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds towards infinity instead
* of rounding towards zero.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) {
// Guarantee the same behavior as in a regular Solidity division.
Panic.panic(Panic.DIVISION_BY_ZERO);
}
// The following calculation ensures accurate ceiling division without overflow.
// Since a is non-zero, (a - 1) / b will not overflow.
// The largest possible result occurs when (a - 1) / b is type(uint256).max,
// but the largest value we can obtain is type(uint256).max - 1, which happens
// when a = type(uint256).max and b = 1.
unchecked {
return SafeCast.toUint(a > 0) * ((a - 1) / b + 1);
}
}
/**
* @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
* denominator == 0.
*
* Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
* Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2²⁵⁶ and mod 2²⁵⁶ - 1, then use
// the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2²⁵⁶ + prod0.
uint256 prod0 = x * y; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2²⁵⁶. Also prevents denominator == 0.
if (denominator <= prod1) {
Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW));
}
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator.
// Always >= 1. See https://cs.stackexchange.com/q/138556/92363.
uint256 twos = denominator & (0 - denominator);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2²⁵⁶ / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2²⁵⁶. Now that denominator is an odd number, it has an inverse modulo 2²⁵⁶ such
// that denominator * inv ≡ 1 mod 2²⁵⁶. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv ≡ 1 mod 2⁴.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
// works in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2⁸
inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶
inverse *= 2 - denominator * inverse; // inverse mod 2³²
inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴
inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸
inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2²⁵⁶. Since the preconditions guarantee that the outcome is
// less than 2²⁵⁶, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @dev Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0);
}
/**
* @dev Calculate the modular multiplicative inverse of a number in Z/nZ.
*
* If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0.
* If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible.
*
* If the input value is not inversible, 0 is returned.
*
* NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the
* inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}.
*/
function invMod(uint256 a, uint256 n) internal pure returns (uint256) {
unchecked {
if (n == 0) return 0;
// The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version)
// Used to compute integers x and y such that: ax + ny = gcd(a, n).
// When the gcd is 1, then the inverse of a modulo n exists and it's x.
// ax + ny = 1
// ax = 1 + (-y)n
// ax ≡ 1 (mod n) # x is the inverse of a modulo n
// If the remainder is 0 the gcd is n right away.
uint256 remainder = a % n;
uint256 gcd = n;
// Therefore the initial coefficients are:
// ax + ny = gcd(a, n) = n
// 0a + 1n = n
int256 x = 0;
int256 y = 1;
while (remainder != 0) {
uint256 quotient = gcd / remainder;
(gcd, remainder) = (
// The old remainder is the next gcd to try.
remainder,
// Compute the next remainder.
// Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd
// where gcd is at most n (capped to type(uint256).max)
gcd - remainder * quotient
);
(x, y) = (
// Increment the coefficient of a.
y,
// Decrement the coefficient of n.
// Can overflow, but the result is casted to uint256 so that the
// next value of y is "wrapped around" to a value between 0 and n - 1.
x - y * int256(quotient)
);
}
if (gcd != 1) return 0; // No inverse exists.
return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative.
}
}
/**
* @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`.
*
* From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is
* prime, then `a**(p-1) ≡ 1 mod p`. As a consequence, we have `a * a**(p-2) ≡ 1 mod p`, which means that
* `a**(p-2)` is the modular multiplicative inverse of a in Fp.
*
* NOTE: this function does NOT check that `p` is a prime greater than `2`.
*/
function invModPrime(uint256 a, uint256 p) internal view returns (uint256) {
unchecked {
return Math.modExp(a, p - 2, p);
}
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m)
*
* Requirements:
* - modulus can't be zero
* - underlying staticcall to precompile must succeed
*
* IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make
* sure the chain you're using it on supports the precompiled contract for modular exponentiation
* at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise,
* the underlying function will succeed given the lack of a revert, but the result may be incorrectly
* interpreted as 0.
*/
function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) {
(bool success, uint256 result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m).
* It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying
* to operate modulo 0 or if the underlying precompile reverted.
*
* IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain
* you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in
* https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack
* of a revert, but the result may be incorrectly interpreted as 0.
*/
function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) {
if (m == 0) return (false, 0);
assembly ("memory-safe") {
let ptr := mload(0x40)
// | Offset | Content | Content (Hex) |
// |-----------|------------|--------------------------------------------------------------------|
// | 0x00:0x1f | size of b | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x20:0x3f | size of e | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x40:0x5f | size of m | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x60:0x7f | value of b | 0x<.............................................................b> |
// | 0x80:0x9f | value of e | 0x<.............................................................e> |
// | 0xa0:0xbf | value of m | 0x<.............................................................m> |
mstore(ptr, 0x20)
mstore(add(ptr, 0x20), 0x20)
mstore(add(ptr, 0x40), 0x20)
mstore(add(ptr, 0x60), b)
mstore(add(ptr, 0x80), e)
mstore(add(ptr, 0xa0), m)
// Given the result < m, it's guaranteed to fit in 32 bytes,
// so we can use the memory scratch space located at offset 0.
success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20)
result := mload(0x00)
}
}
/**
* @dev Variant of {modExp} that supports inputs of arbitrary length.
*/
function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) {
(bool success, bytes memory result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Variant of {tryModExp} that supports inputs of arbitrary length.
*/
function tryModExp(
bytes memory b,
bytes memory e,
bytes memory m
) internal view returns (bool success, bytes memory result) {
if (_zeroBytes(m)) return (false, new bytes(0));
uint256 mLen = m.length;
// Encode call args in result and move the free memory pointer
result = abi.encodePacked(b.length, e.length, mLen, b, e, m);
assembly ("memory-safe") {
let dataPtr := add(result, 0x20)
// Write result on top of args to avoid allocating extra memory.
success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen)
// Overwrite the length.
// result.length > returndatasize() is guaranteed because returndatasize() == m.length
mstore(result, mLen)
// Set the memory pointer after the returned data.
mstore(0x40, add(dataPtr, mLen))
}
}
/**
* @dev Returns whether the provided byte array is zero.
*/
function _zeroBytes(bytes memory byteArray) private pure returns (bool) {
for (uint256 i = 0; i < byteArray.length; ++i) {
if (byteArray[i] != 0) {
return false;
}
}
return true;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
* towards zero.
*
* This method is based on Newton's method for computing square roots; the algorithm is restricted to only
* using integer operations.
*/
function sqrt(uint256 a) internal pure returns (uint256) {
unchecked {
// Take care of easy edge cases when a == 0 or a == 1
if (a <= 1) {
return a;
}
// In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a
// sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between
// the current value as `ε_n = | x_n - sqrt(a) |`.
//
// For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root
// of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is
// bigger than any uint256.
//
// By noticing that
// `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)`
// we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar
// to the msb function.
uint256 aa = a;
uint256 xn = 1;
if (aa >= (1 << 128)) {
aa >>= 128;
xn <<= 64;
}
if (aa >= (1 << 64)) {
aa >>= 64;
xn <<= 32;
}
if (aa >= (1 << 32)) {
aa >>= 32;
xn <<= 16;
}
if (aa >= (1 << 16)) {
aa >>= 16;
xn <<= 8;
}
if (aa >= (1 << 8)) {
aa >>= 8;
xn <<= 4;
}
if (aa >= (1 << 4)) {
aa >>= 4;
xn <<= 2;
}
if (aa >= (1 << 2)) {
xn <<= 1;
}
// We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1).
//
// We can refine our estimation by noticing that the middle of that interval minimizes the error.
// If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2).
// This is going to be our x_0 (and ε_0)
xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2)
// From here, Newton's method give us:
// x_{n+1} = (x_n + a / x_n) / 2
//
// One should note that:
// x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a
// = ((x_n² + a) / (2 * x_n))² - a
// = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a
// = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²)
// = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²)
// = (x_n² - a)² / (2 * x_n)²
// = ((x_n² - a) / (2 * x_n))²
// ≥ 0
// Which proves that for all n ≥ 1, sqrt(a) ≤ x_n
//
// This gives us the proof of quadratic convergence of the sequence:
// ε_{n+1} = | x_{n+1} - sqrt(a) |
// = | (x_n + a / x_n) / 2 - sqrt(a) |
// = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) |
// = | (x_n - sqrt(a))² / (2 * x_n) |
// = | ε_n² / (2 * x_n) |
// = ε_n² / | (2 * x_n) |
//
// For the first iteration, we have a special case where x_0 is known:
// ε_1 = ε_0² / | (2 * x_0) |
// ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2)))
// ≤ 2**(2*e-4) / (3 * 2**(e-1))
// ≤ 2**(e-3) / 3
// ≤ 2**(e-3-log2(3))
// ≤ 2**(e-4.5)
//
// For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n:
// ε_{n+1} = ε_n² / | (2 * x_n) |
// ≤ (2**(e-k))² / (2 * 2**(e-1))
// ≤ 2**(2*e-2*k) / 2**e
// ≤ 2**(e-2*k)
xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5) -- special case, see above
xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9) -- general case with k = 4.5
xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18) -- general case with k = 9
xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36) -- general case with k = 18
xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72) -- general case with k = 36
xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144) -- general case with k = 72
// Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision
// ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either
// sqrt(a) or sqrt(a) + 1.
return xn - SafeCast.toUint(xn > a / xn);
}
}
/**
* @dev Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a);
}
}
/**
* @dev Return the log in base 2 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
uint256 exp;
unchecked {
exp = 128 * SafeCast.toUint(value > (1 << 128) - 1);
value >>= exp;
result += exp;
exp = 64 * SafeCast.toUint(value > (1 << 64) - 1);
value >>= exp;
result += exp;
exp = 32 * SafeCast.toUint(value > (1 << 32) - 1);
value >>= exp;
result += exp;
exp = 16 * SafeCast.toUint(value > (1 << 16) - 1);
value >>= exp;
result += exp;
exp = 8 * SafeCast.toUint(value > (1 << 8) - 1);
value >>= exp;
result += exp;
exp = 4 * SafeCast.toUint(value > (1 << 4) - 1);
value >>= exp;
result += exp;
exp = 2 * SafeCast.toUint(value > (1 << 2) - 1);
value >>= exp;
result += exp;
result += SafeCast.toUint(value > 1);
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value);
}
}
/**
* @dev Return the log in base 10 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value);
}
}
/**
* @dev Return the log in base 256 of a positive value rounded towards zero.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
uint256 isGt;
unchecked {
isGt = SafeCast.toUint(value > (1 << 128) - 1);
value >>= isGt * 128;
result += isGt * 16;
isGt = SafeCast.toUint(value > (1 << 64) - 1);
value >>= isGt * 64;
result += isGt * 8;
isGt = SafeCast.toUint(value > (1 << 32) - 1);
value >>= isGt * 32;
result += isGt * 4;
isGt = SafeCast.toUint(value > (1 << 16) - 1);
value >>= isGt * 16;
result += isGt * 2;
result += SafeCast.toUint(value > (1 << 8) - 1);
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value);
}
}
/**
* @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
*/
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
return uint8(rounding) % 2 == 1;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (access/extensions/AccessControlEnumerable.sol)
pragma solidity ^0.8.20;
import {IAccessControlEnumerable} from "@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol";
import {AccessControlUpgradeable} from "../AccessControlUpgradeable.sol";
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import {Initializable} from "../../proxy/utils/Initializable.sol";
/**
* @dev Extension of {AccessControl} that allows enumerating the members of each role.
*/
abstract contract AccessControlEnumerableUpgradeable is Initializable, IAccessControlEnumerable, AccessControlUpgradeable {
using EnumerableSet for EnumerableSet.AddressSet;
/// @custom:storage-location erc7201:openzeppelin.storage.AccessControlEnumerable
struct AccessControlEnumerableStorage {
mapping(bytes32 role => EnumerableSet.AddressSet) _roleMembers;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.AccessControlEnumerable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant AccessControlEnumerableStorageLocation = 0xc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e82371705932000;
function _getAccessControlEnumerableStorage() private pure returns (AccessControlEnumerableStorage storage $) {
assembly {
$.slot := AccessControlEnumerableStorageLocation
}
}
function __AccessControlEnumerable_init() internal onlyInitializing {
}
function __AccessControlEnumerable_init_unchained() internal onlyInitializing {
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {
AccessControlEnumerableStorage storage $ = _getAccessControlEnumerableStorage();
return $._roleMembers[role].at(index);
}
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {
AccessControlEnumerableStorage storage $ = _getAccessControlEnumerableStorage();
return $._roleMembers[role].length();
}
/**
* @dev Return all accounts that have `role`
*
* 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 getRoleMembers(bytes32 role) public view virtual returns (address[] memory) {
AccessControlEnumerableStorage storage $ = _getAccessControlEnumerableStorage();
return $._roleMembers[role].values();
}
/**
* @dev Overload {AccessControl-_grantRole} to track enumerable memberships
*/
function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {
AccessControlEnumerableStorage storage $ = _getAccessControlEnumerableStorage();
bool granted = super._grantRole(role, account);
if (granted) {
$._roleMembers[role].add(account);
}
return granted;
}
/**
* @dev Overload {AccessControl-_revokeRole} to track enumerable memberships
*/
function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {
AccessControlEnumerableStorage storage $ = _getAccessControlEnumerableStorage();
bool revoked = super._revokeRole(role, account);
if (revoked) {
$._roleMembers[role].remove(account);
}
return revoked;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (proxy/utils/UUPSUpgradeable.sol)
pragma solidity ^0.8.22;
import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol";
import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol";
import {Initializable} from "./Initializable.sol";
/**
* @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
* {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
*
* A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
* reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
* `UUPSUpgradeable` with a custom implementation of upgrades.
*
* The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
*/
abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable {
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
address private immutable __self = address(this);
/**
* @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)`
* and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called,
* while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string.
* If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must
* be the empty byte string if no function should be called, making it impossible to invoke the `receive` function
* during an upgrade.
*/
string public constant UPGRADE_INTERFACE_VERSION = "5.0.0";
/**
* @dev The call is from an unauthorized context.
*/
error UUPSUnauthorizedCallContext();
/**
* @dev The storage `slot` is unsupported as a UUID.
*/
error UUPSUnsupportedProxiableUUID(bytes32 slot);
/**
* @dev Check that the execution is being performed through a delegatecall call and that the execution context is
* a proxy contract with an implementation (as defined in ERC-1967) pointing to self. This should only be the case
* for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
* function through ERC-1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
* fail.
*/
modifier onlyProxy() {
_checkProxy();
_;
}
/**
* @dev Check that the execution is not being performed through a delegate call. This allows a function to be
* callable on the implementing contract but not through proxies.
*/
modifier notDelegated() {
_checkNotDelegated();
_;
}
function __UUPSUpgradeable_init() internal onlyInitializing {
}
function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
}
/**
* @dev Implementation of the ERC-1822 {proxiableUUID} function. This returns the storage slot used by the
* implementation. It is used to validate the implementation's compatibility when performing an upgrade.
*
* 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. This is guaranteed by the `notDelegated` modifier.
*/
function proxiableUUID() external view virtual notDelegated returns (bytes32) {
return ERC1967Utils.IMPLEMENTATION_SLOT;
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
* encoded in `data`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*
* @custom:oz-upgrades-unsafe-allow-reachable delegatecall
*/
function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, data);
}
/**
* @dev Reverts if the execution is not performed via delegatecall or the execution
* context is not of a proxy with an ERC-1967 compliant implementation pointing to self.
* See {_onlyProxy}.
*/
function _checkProxy() internal view virtual {
if (
address(this) == __self || // Must be called through delegatecall
ERC1967Utils.getImplementation() != __self // Must be called through an active proxy
) {
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Reverts if the execution is performed via delegatecall.
* See {notDelegated}.
*/
function _checkNotDelegated() internal view virtual {
if (address(this) != __self) {
// Must not be called through delegatecall
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
* {upgradeToAndCall}.
*
* Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
*
* ```solidity
* function _authorizeUpgrade(address) internal onlyOwner {}
* ```
*/
function _authorizeUpgrade(address newImplementation) internal virtual;
/**
* @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call.
*
* As a security check, {proxiableUUID} is invoked in the new implementation, and the return value
* is expected to be the implementation slot in ERC-1967.
*
* Emits an {IERC1967-Upgraded} event.
*/
function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private {
try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) {
revert UUPSUnsupportedProxiableUUID(slot);
}
ERC1967Utils.upgradeToAndCall(newImplementation, data);
} catch {
// The implementation is not UUPS
revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation);
}
}
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.28;
import { IMitosisVaultVLF } from './IMitosisVaultVLF.sol';
enum AssetAction {
None,
Deposit
}
interface IMitosisVault is IMitosisVaultVLF {
//=========== NOTE: EVENT DEFINITIONS ===========//
event CapSet(address indexed setter, address indexed asset, uint256 prevMaxCap, uint256 newMaxCap);
event AssetInitialized(address asset);
event Deposited(address indexed asset, address indexed to, uint256 amount);
event Withdrawn(address indexed asset, address indexed to, uint256 amount);
event EntrypointSet(address entrypoint);
event AssetHalted(address indexed asset, AssetAction action);
event AssetResumed(address indexed asset, AssetAction action);
//=========== NOTE: ERROR DEFINITIONS ===========//
error IMitosisVault__ExceededCap(address asset, uint256 increasedSupply, uint256 availableCap);
error IMitosisVault__InsufficientBalance(address asset, uint256 amount);
error IMitosisVault__AssetNotInitialized(address asset);
error IMitosisVault__AssetAlreadyInitialized(address asset);
//=========== NOTE: View functions ===========//
function isAssetInitialized(address asset) external view returns (bool);
function entrypoint() external view returns (address);
function quoteDeposit(address asset, address to, uint256 amount) external view returns (uint256);
//=========== NOTE: Asset ===========//
/// @dev Hyperlane message receiver
function initializeAsset(address asset) external;
/// @dev Hyperlane message sender
function deposit(address asset, address to, uint256 amount) external payable;
/// @dev Hyperlane message receiver
function withdraw(address asset, address to, uint256 amount) external;
//=========== NOTE: OWNABLE FUNCTIONS ===========//
function setEntrypoint(address entrypoint) external;
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.28;
import { IMitosisVault } from './IMitosisVault.sol';
interface IMitosisVaultEntrypoint {
function vault() external view returns (IMitosisVault);
function mitosisDomain() external view returns (uint32);
function mitosisAddr() external view returns (bytes32);
//=========== NOTE: QUOTE FUNCTIONS ===========//
function quoteDeposit(address asset, address to, uint256 amount) external view returns (uint256);
function quoteDepositWithSupplyVLF(address asset, address to, address hubVLFVault, uint256 amount)
external
view
returns (uint256);
function quoteDeallocateVLF(address hubVLFVault, uint256 amount) external view returns (uint256);
function quoteSettleVLFYield(address hubVLFVault, uint256 amount) external view returns (uint256);
function quoteSettleVLFLoss(address hubVLFVault, uint256 amount) external view returns (uint256);
function quoteSettleVLFExtraRewards(address hubVLFVault, address reward, uint256 amount)
external
view
returns (uint256);
//=========== NOTE: MUTATIVE FUNCTIONS ===========//
function deposit(address asset, address to, uint256 amount, address refundTo) external payable;
function depositWithSupplyVLF(address asset, address to, address hubVLFVault, uint256 amount, address refundTo)
external
payable;
function deallocateVLF(address hubVLFVault, uint256 amount, address refundTo) external payable;
function settleVLFYield(address hubVLFVault, uint256 amount, address refundTo) external payable;
function settleVLFLoss(address hubVLFVault, uint256 amount, address refundTo) external payable;
function settleVLFExtraRewards(address hubVLFVault, address reward, uint256 amount, address refundTo)
external
payable;
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.28;
library ERC7201Utils {
function storageSlot(string memory namespace) internal pure returns (bytes32 slot) {
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, sub(keccak256(add(namespace, 0x20), mload(namespace)), 1))
slot := and(keccak256(0x00, 0x20), not(0xff))
}
}
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.28;
import { ContextUpgradeable } from '@ozu/utils/ContextUpgradeable.sol';
import { ERC7201Utils } from './ERC7201Utils.sol';
import { StdError } from './StdError.sol';
abstract contract Pausable is ContextUpgradeable {
using ERC7201Utils for string;
/// @custom:storage-location mitosis.storage.Pausable
struct PausableStorage {
bool global_;
mapping(bytes4 sig => bool isPaused) paused;
}
error Pausable__Paused(bytes4 sig);
error Pausable__NotPaused(bytes4 sig);
// =========================== NOTE: STORAGE DEFINITIONS =========================== //
string private constant _NAMESPACE = 'mitosis.storage.Pausable';
bytes32 private immutable _slot = _NAMESPACE.storageSlot();
function _getPausableStorage() private view returns (PausableStorage storage $) {
bytes32 slot = _slot;
// slither-disable-next-line assembly
assembly {
$.slot := slot
}
}
// =========================== NOTE: INITIALIZE HELPERS =========================== //
function __Pausable_init() internal {
PausableStorage storage $ = _getPausableStorage();
$.global_ = false;
}
// =========================== NOTE: MODIFIERS =========================== //
modifier whenNotPaused() {
require(!_isPaused(msg.sig), Pausable__Paused(msg.sig));
_;
}
modifier whenPaused() {
require(_isPaused(msg.sig), Pausable__NotPaused(msg.sig));
_;
}
modifier onlyPauseManager() {
_authorizePause(_msgSender());
_;
}
// =========================== NOTE: VIRTUAL FUNCTIONS =========================== //
function _authorizePause(address) internal view virtual;
// =========================== NOTE: MAIN FUNCTIONS =========================== //
function isPaused(bytes4 sig) external view returns (bool) {
return _isPaused(sig);
}
function isPausedGlobally() external view returns (bool) {
return _isPausedGlobally();
}
function pause() external onlyPauseManager {
_pause();
}
function pause(bytes4 sig) external onlyPauseManager {
_pause(sig);
}
function unpause() external onlyPauseManager {
_unpause();
}
function unpause(bytes4 sig) external onlyPauseManager {
_unpause(sig);
}
// =========================== NOTE: INTERNAL FUNCTIONS =========================== //
function _pause() internal virtual {
_getPausableStorage().global_ = true;
}
function _pause(bytes4 sig) internal virtual {
_getPausableStorage().paused[sig] = true;
}
function _unpause() internal virtual {
_getPausableStorage().global_ = false;
}
function _unpause(bytes4 sig) internal virtual {
_getPausableStorage().paused[sig] = false;
}
function _isPaused(bytes4 sig) internal view virtual returns (bool) {
PausableStorage storage $ = _getPausableStorage();
return $.global_ || $.paused[sig];
}
function _isPausedGlobally() internal view virtual returns (bool) {
return _getPausableStorage().global_;
}
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.28;
library StdError {
error Halted();
error Unauthorized();
error NotFound(string description);
error NotImplemented();
error NotSupported();
error InvalidId(string description);
error InvalidAddress(string description);
error InvalidParameter(string description);
error ZeroAmount();
error ZeroAddress(string description);
error EnumOutOfBounds(uint8 max, uint8 actual);
}// SPDX-License-Identifier: Apache-2.0
// THIS IS GENERATED FILE. DO NOT EDIT.
pragma solidity ^0.8.28;
import { IVersioned } from '../interfaces/lib/IVersioned.sol';
contract Versioned is IVersioned {
string public constant GIT_TAG = 'v1.1.0';
string public constant GIT_COMMIT = '4f6a15a0854cb1db34ba7ccc11aa61e1f7c13bac';
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.28;
import { IERC20 } from '@oz/token/ERC20/IERC20.sol';
import { SafeERC20 } from '@oz/token/ERC20/utils/SafeERC20.sol';
import { Address } from '@oz/utils/Address.sol';
import { AccessControlEnumerableUpgradeable } from '@ozu/access/extensions/AccessControlEnumerableUpgradeable.sol';
import { IMitosisVaultEntrypoint } from '../interfaces/branch/IMitosisVaultEntrypoint.sol';
import { IMitosisVaultVLF, VLFAction } from '../interfaces/branch/IMitosisVaultVLF.sol';
import { INativeWrappedToken } from '../interfaces/branch/INativeWrappedToken.sol';
import { IVLFStrategyExecutor } from '../interfaces/branch/strategy/IVLFStrategyExecutor.sol';
import { ERC7201Utils } from '../lib/ERC7201Utils.sol';
import { Pausable } from '../lib/Pausable.sol';
import { StdError } from '../lib/StdError.sol';
abstract contract MitosisVaultVLF is IMitosisVaultVLF, Pausable, AccessControlEnumerableUpgradeable {
using ERC7201Utils for string;
using SafeERC20 for IERC20;
struct VLFInfo {
bool initialized;
address asset;
address strategyExecutor;
uint256 availableLiquidity;
mapping(VLFAction => bool) isHalted;
}
struct VLFStorageV1 {
mapping(address hubVLFVault => VLFInfo) vlfs;
}
string private constant _NAMESPACE = 'mitosis.storage.MitosisVault.VLF.v1';
bytes32 private immutable _slot = _NAMESPACE.storageSlot();
function _getVLFStorageV1() private view returns (VLFStorageV1 storage $) {
bytes32 slot = _slot;
assembly {
$.slot := slot
}
}
//=========== NOTE: View ===========//
function isVLFActionHalted(address hubVLFVault, VLFAction action) external view returns (bool) {
return _isVLFHalted(_getVLFStorageV1(), hubVLFVault, action);
}
function isVLFInitialized(address hubVLFVault) external view returns (bool) {
return _isVLFInitialized(_getVLFStorageV1(), hubVLFVault);
}
function availableVLF(address hubVLFVault) external view returns (uint256) {
return _getVLFStorageV1().vlfs[hubVLFVault].availableLiquidity;
}
function vlfStrategyExecutor(address hubVLFVault) external view returns (address) {
return _getVLFStorageV1().vlfs[hubVLFVault].strategyExecutor;
}
function quoteDepositWithSupplyVLF(address asset, address to, address hubVLFVault, uint256 amount)
external
view
returns (uint256)
{
return _entrypoint().quoteDepositWithSupplyVLF(asset, to, hubVLFVault, amount);
}
function quoteDeallocateVLF(address hubVLFVault, uint256 amount) external view returns (uint256) {
return _entrypoint().quoteDeallocateVLF(hubVLFVault, amount);
}
function quoteSettleVLFYield(address hubVLFVault, uint256 amount) external view returns (uint256) {
return _entrypoint().quoteSettleVLFYield(hubVLFVault, amount);
}
function quoteSettleVLFLoss(address hubVLFVault, uint256 amount) external view returns (uint256) {
return _entrypoint().quoteSettleVLFLoss(hubVLFVault, amount);
}
function quoteSettleVLFExtraRewards(address hubVLFVault, address reward, uint256 amount)
external
view
returns (uint256)
{
return _entrypoint().quoteSettleVLFExtraRewards(hubVLFVault, reward, amount);
}
//=========== NOTE: Asset ===========//
function _entrypoint() internal view virtual returns (IMitosisVaultEntrypoint);
function _deposit(address asset, address to, uint256 amount) internal virtual;
function _assertAssetInitialized(address asset) internal view virtual;
function depositWithSupplyVLF(address asset, address to, address hubVLFVault, uint256 amount)
external
payable
whenNotPaused
{
_deposit(asset, to, amount);
VLFStorageV1 storage $ = _getVLFStorageV1();
_assertVLFInitialized($, hubVLFVault);
require(asset == $.vlfs[hubVLFVault].asset, IMitosisVaultVLF__InvalidVLF(hubVLFVault, asset));
_entrypoint().depositWithSupplyVLF{ value: msg.value }(asset, to, hubVLFVault, amount, _msgSender());
emit VLFDepositedWithSupply(asset, to, hubVLFVault, amount);
}
//=========== NOTE: VLF Lifecycle ===========//
function initializeVLF(address hubVLFVault, address asset) external whenNotPaused {
require(address(_entrypoint()) == _msgSender(), StdError.Unauthorized());
VLFStorageV1 storage $ = _getVLFStorageV1();
_assertVLFNotInitialized($, hubVLFVault);
_assertAssetInitialized(asset);
$.vlfs[hubVLFVault].initialized = true;
$.vlfs[hubVLFVault].asset = asset;
emit VLFInitialized(hubVLFVault, asset);
}
function allocateVLF(address hubVLFVault, uint256 amount) external whenNotPaused {
require(address(_entrypoint()) == _msgSender(), StdError.Unauthorized());
VLFStorageV1 storage $ = _getVLFStorageV1();
_assertVLFInitialized($, hubVLFVault);
$.vlfs[hubVLFVault].availableLiquidity += amount;
emit VLFAllocated(hubVLFVault, amount);
}
function deallocateVLF(address hubVLFVault, uint256 amount) external payable whenNotPaused {
VLFStorageV1 storage $ = _getVLFStorageV1();
_assertVLFInitialized($, hubVLFVault);
_assertOnlyStrategyExecutor($, hubVLFVault);
$.vlfs[hubVLFVault].availableLiquidity -= amount;
_entrypoint().deallocateVLF{ value: msg.value }(hubVLFVault, amount, _msgSender());
emit VLFDeallocated(hubVLFVault, amount);
}
function fetchVLF(address hubVLFVault, uint256 amount) external whenNotPaused {
VLFStorageV1 storage $ = _getVLFStorageV1();
_assertVLFInitialized($, hubVLFVault);
_assertOnlyStrategyExecutor($, hubVLFVault);
_assertNotHalted($, hubVLFVault, VLFAction.FetchVLF);
VLFInfo storage vlfInfo = $.vlfs[hubVLFVault];
vlfInfo.availableLiquidity -= amount;
IERC20(vlfInfo.asset).safeTransfer(vlfInfo.strategyExecutor, amount);
emit VLFFetched(hubVLFVault, amount);
}
function returnVLF(address hubVLFVault, uint256 amount) external whenNotPaused {
VLFStorageV1 storage $ = _getVLFStorageV1();
_assertVLFInitialized($, hubVLFVault);
_assertOnlyStrategyExecutor($, hubVLFVault);
VLFInfo storage vlfInfo = $.vlfs[hubVLFVault];
vlfInfo.availableLiquidity += amount;
IERC20(vlfInfo.asset).safeTransferFrom(vlfInfo.strategyExecutor, address(this), amount);
emit VLFReturned(hubVLFVault, amount);
}
function settleVLFYield(address hubVLFVault, uint256 amount) external payable whenNotPaused {
VLFStorageV1 storage $ = _getVLFStorageV1();
_assertVLFInitialized($, hubVLFVault);
_assertOnlyStrategyExecutor($, hubVLFVault);
_entrypoint().settleVLFYield{ value: msg.value }(hubVLFVault, amount, _msgSender());
emit VLFYieldSettled(hubVLFVault, amount);
}
function settleVLFLoss(address hubVLFVault, uint256 amount) external payable whenNotPaused {
VLFStorageV1 storage $ = _getVLFStorageV1();
_assertVLFInitialized($, hubVLFVault);
_assertOnlyStrategyExecutor($, hubVLFVault);
_entrypoint().settleVLFLoss{ value: msg.value }(hubVLFVault, amount, _msgSender());
emit VLFLossSettled(hubVLFVault, amount);
}
function settleVLFExtraRewards(address hubVLFVault, address reward, uint256 amount) external payable whenNotPaused {
VLFStorageV1 storage $ = _getVLFStorageV1();
_assertVLFInitialized($, hubVLFVault);
_assertOnlyStrategyExecutor($, hubVLFVault);
_assertAssetInitialized(reward);
require(reward != $.vlfs[hubVLFVault].asset, StdError.InvalidAddress('reward'));
IERC20(reward).safeTransferFrom(_msgSender(), address(this), amount);
_entrypoint().settleVLFExtraRewards{ value: msg.value }(hubVLFVault, reward, amount, _msgSender());
emit VLFExtraRewardsSettled(hubVLFVault, reward, amount);
}
//=========== NOTE: OWNABLE FUNCTIONS ===========//
function haltVLF(address hubVLFVault, VLFAction action) external onlyRole(DEFAULT_ADMIN_ROLE) {
VLFStorageV1 storage $ = _getVLFStorageV1();
_assertVLFInitialized($, hubVLFVault);
return _haltVLF($, hubVLFVault, action);
}
function resumeVLF(address hubVLFVault, VLFAction action) external onlyRole(DEFAULT_ADMIN_ROLE) {
VLFStorageV1 storage $ = _getVLFStorageV1();
_assertVLFInitialized($, hubVLFVault);
return _resumeVLF($, hubVLFVault, action);
}
function setVLFStrategyExecutor(address hubVLFVault, address strategyExecutor_) external onlyRole(DEFAULT_ADMIN_ROLE) {
VLFStorageV1 storage $ = _getVLFStorageV1();
VLFInfo storage vlfInfo = $.vlfs[hubVLFVault];
_assertVLFInitialized($, hubVLFVault);
if (vlfInfo.strategyExecutor != address(0)) {
// NOTE: no way to check if every extra rewards are settled.
bool drained = IVLFStrategyExecutor(vlfInfo.strategyExecutor).totalBalance() == 0
&& IVLFStrategyExecutor(vlfInfo.strategyExecutor).storedTotalBalance() == 0;
require(drained, IMitosisVaultVLF__StrategyExecutorNotDrained(hubVLFVault, vlfInfo.strategyExecutor));
}
require(
hubVLFVault == IVLFStrategyExecutor(strategyExecutor_).hubVLFVault(),
StdError.InvalidId('VLFStrategyExecutor.hubVLFVault')
);
require(
address(this) == address(IVLFStrategyExecutor(strategyExecutor_).vault()),
StdError.InvalidAddress('VLFStrategyExecutor.vault')
);
require(
vlfInfo.asset == address(IVLFStrategyExecutor(strategyExecutor_).asset()),
StdError.InvalidAddress('VLFStrategyExecutor.asset')
);
vlfInfo.strategyExecutor = strategyExecutor_;
emit VLFStrategyExecutorSet(hubVLFVault, strategyExecutor_);
}
//=========== NOTE: INTERNAL FUNCTIONS ===========//
function _isVLFHalted(VLFStorageV1 storage $, address hubVLFVault, VLFAction action) internal view returns (bool) {
return $.vlfs[hubVLFVault].isHalted[action];
}
function _haltVLF(VLFStorageV1 storage $, address hubVLFVault, VLFAction action) internal {
$.vlfs[hubVLFVault].isHalted[action] = true;
emit VLFHalted(hubVLFVault, action);
}
function _resumeVLF(VLFStorageV1 storage $, address hubVLFVault, VLFAction action) internal {
$.vlfs[hubVLFVault].isHalted[action] = false;
emit VLFResumed(hubVLFVault, action);
}
function _assertNotHalted(VLFStorageV1 storage $, address hubVLFVault, VLFAction action) internal view {
require(!_isVLFHalted($, hubVLFVault, action), StdError.Halted());
}
function _isVLFInitialized(VLFStorageV1 storage $, address hubVLFVault) internal view returns (bool) {
return $.vlfs[hubVLFVault].initialized;
}
function _assertVLFInitialized(VLFStorageV1 storage $, address hubVLFVault) internal view {
require(_isVLFInitialized($, hubVLFVault), IMitosisVaultVLF__VLFNotInitialized(hubVLFVault));
}
function _assertVLFNotInitialized(VLFStorageV1 storage $, address hubVLFVault) internal view {
require(!_isVLFInitialized($, hubVLFVault), IMitosisVaultVLF__VLFAlreadyInitialized(hubVLFVault));
}
function _assertOnlyStrategyExecutor(VLFStorageV1 storage $, address hubVLFVault) internal view {
require(_msgSender() == $.vlfs[hubVLFVault].strategyExecutor, StdError.Unauthorized());
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";
/**
* @title IERC1363
* @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*
* Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
* after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @param data Additional data with no specified format, sent in call to `spender`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of common custom errors used in multiple contracts
*
* IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.
* It is recommended to avoid relying on the error API for critical functionality.
*
* _Available since v5.1._
*/
library Errors {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error InsufficientBalance(uint256 balance, uint256 needed);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedCall();
/**
* @dev The deployment failed.
*/
error FailedDeployment();
/**
* @dev A necessary precompile is missing.
*/
error MissingPrecompile(address);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Panic.sol)
pragma solidity ^0.8.20;
/**
* @dev Helper library for emitting standardized panic codes.
*
* ```solidity
* contract Example {
* using Panic for uint256;
*
* // Use any of the declared internal constants
* function foo() { Panic.GENERIC.panic(); }
*
* // Alternatively
* function foo() { Panic.panic(Panic.GENERIC); }
* }
* ```
*
* Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil].
*
* _Available since v5.1._
*/
// slither-disable-next-line unused-state
library Panic {
/// @dev generic / unspecified error
uint256 internal constant GENERIC = 0x00;
/// @dev used by the assert() builtin
uint256 internal constant ASSERT = 0x01;
/// @dev arithmetic underflow or overflow
uint256 internal constant UNDER_OVERFLOW = 0x11;
/// @dev division or modulo by zero
uint256 internal constant DIVISION_BY_ZERO = 0x12;
/// @dev enum conversion error
uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;
/// @dev invalid encoding in storage
uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;
/// @dev empty array pop
uint256 internal constant EMPTY_ARRAY_POP = 0x31;
/// @dev array out of bounds access
uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;
/// @dev resource error (too large allocation or too large array)
uint256 internal constant RESOURCE_ERROR = 0x41;
/// @dev calling invalid internal function
uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;
/// @dev Reverts with a panic code. Recommended to use with
/// the internal constants with predefined codes.
function panic(uint256 code) internal pure {
assembly ("memory-safe") {
mstore(0x00, 0x4e487b71)
mstore(0x20, code)
revert(0x1c, 0x24)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.
pragma solidity ^0.8.20;
/**
* @dev Wrappers over Solidity's uintXX/intXX/bool 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.
*/
library SafeCast {
/**
* @dev Value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);
/**
* @dev An int value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedIntToUint(int256 value);
/**
* @dev Value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);
/**
* @dev An uint value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedUintToInt(uint256 value);
/**
* @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
*/
function toUint248(uint256 value) internal pure returns (uint248) {
if (value > type(uint248).max) {
revert SafeCastOverflowedUintDowncast(248, value);
}
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
*/
function toUint240(uint256 value) internal pure returns (uint240) {
if (value > type(uint240).max) {
revert SafeCastOverflowedUintDowncast(240, value);
}
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
*/
function toUint232(uint256 value) internal pure returns (uint232) {
if (value > type(uint232).max) {
revert SafeCastOverflowedUintDowncast(232, value);
}
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
*/
function toUint224(uint256 value) internal pure returns (uint224) {
if (value > type(uint224).max) {
revert SafeCastOverflowedUintDowncast(224, value);
}
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
*/
function toUint216(uint256 value) internal pure returns (uint216) {
if (value > type(uint216).max) {
revert SafeCastOverflowedUintDowncast(216, value);
}
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
*/
function toUint208(uint256 value) internal pure returns (uint208) {
if (value > type(uint208).max) {
revert SafeCastOverflowedUintDowncast(208, value);
}
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
*/
function toUint200(uint256 value) internal pure returns (uint200) {
if (value > type(uint200).max) {
revert SafeCastOverflowedUintDowncast(200, value);
}
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
*/
function toUint192(uint256 value) internal pure returns (uint192) {
if (value > type(uint192).max) {
revert SafeCastOverflowedUintDowncast(192, value);
}
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
*/
function toUint184(uint256 value) internal pure returns (uint184) {
if (value > type(uint184).max) {
revert SafeCastOverflowedUintDowncast(184, value);
}
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
*/
function toUint176(uint256 value) internal pure returns (uint176) {
if (value > type(uint176).max) {
revert SafeCastOverflowedUintDowncast(176, value);
}
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
*/
function toUint168(uint256 value) internal pure returns (uint168) {
if (value > type(uint168).max) {
revert SafeCastOverflowedUintDowncast(168, value);
}
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
*/
function toUint160(uint256 value) internal pure returns (uint160) {
if (value > type(uint160).max) {
revert SafeCastOverflowedUintDowncast(160, value);
}
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
*/
function toUint152(uint256 value) internal pure returns (uint152) {
if (value > type(uint152).max) {
revert SafeCastOverflowedUintDowncast(152, value);
}
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
*/
function toUint144(uint256 value) internal pure returns (uint144) {
if (value > type(uint144).max) {
revert SafeCastOverflowedUintDowncast(144, value);
}
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
*/
function toUint136(uint256 value) internal pure returns (uint136) {
if (value > type(uint136).max) {
revert SafeCastOverflowedUintDowncast(136, value);
}
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
*/
function toUint128(uint256 value) internal pure returns (uint128) {
if (value > type(uint128).max) {
revert SafeCastOverflowedUintDowncast(128, value);
}
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
*/
function toUint120(uint256 value) internal pure returns (uint120) {
if (value > type(uint120).max) {
revert SafeCastOverflowedUintDowncast(120, value);
}
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
*/
function toUint112(uint256 value) internal pure returns (uint112) {
if (value > type(uint112).max) {
revert SafeCastOverflowedUintDowncast(112, value);
}
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
*/
function toUint104(uint256 value) internal pure returns (uint104) {
if (value > type(uint104).max) {
revert SafeCastOverflowedUintDowncast(104, value);
}
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
*/
function toUint96(uint256 value) internal pure returns (uint96) {
if (value > type(uint96).max) {
revert SafeCastOverflowedUintDowncast(96, value);
}
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
*/
function toUint88(uint256 value) internal pure returns (uint88) {
if (value > type(uint88).max) {
revert SafeCastOverflowedUintDowncast(88, value);
}
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
*/
function toUint80(uint256 value) internal pure returns (uint80) {
if (value > type(uint80).max) {
revert SafeCastOverflowedUintDowncast(80, value);
}
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
*/
function toUint72(uint256 value) internal pure returns (uint72) {
if (value > type(uint72).max) {
revert SafeCastOverflowedUintDowncast(72, value);
}
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
*/
function toUint64(uint256 value) internal pure returns (uint64) {
if (value > type(uint64).max) {
revert SafeCastOverflowedUintDowncast(64, value);
}
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
*/
function toUint56(uint256 value) internal pure returns (uint56) {
if (value > type(uint56).max) {
revert SafeCastOverflowedUintDowncast(56, value);
}
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
*/
function toUint48(uint256 value) internal pure returns (uint48) {
if (value > type(uint48).max) {
revert SafeCastOverflowedUintDowncast(48, value);
}
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
*/
function toUint40(uint256 value) internal pure returns (uint40) {
if (value > type(uint40).max) {
revert SafeCastOverflowedUintDowncast(40, value);
}
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
*/
function toUint32(uint256 value) internal pure returns (uint32) {
if (value > type(uint32).max) {
revert SafeCastOverflowedUintDowncast(32, value);
}
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
*/
function toUint24(uint256 value) internal pure returns (uint24) {
if (value > type(uint24).max) {
revert SafeCastOverflowedUintDowncast(24, value);
}
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
*/
function toUint16(uint256 value) internal pure returns (uint16) {
if (value > type(uint16).max) {
revert SafeCastOverflowedUintDowncast(16, value);
}
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
*/
function toUint8(uint256 value) internal pure returns (uint8) {
if (value > type(uint8).max) {
revert SafeCastOverflowedUintDowncast(8, value);
}
return uint8(value);
}
/**
* @dev Converts a signed int256 into an unsigned uint256.
*
* Requirements:
*
* - input must be greater than or equal to 0.
*/
function toUint256(int256 value) internal pure returns (uint256) {
if (value < 0) {
revert SafeCastOverflowedIntToUint(value);
}
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
*/
function toInt248(int256 value) internal pure returns (int248 downcasted) {
downcasted = int248(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(248, value);
}
}
/**
* @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
*/
function toInt240(int256 value) internal pure returns (int240 downcasted) {
downcasted = int240(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(240, value);
}
}
/**
* @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
*/
function toInt232(int256 value) internal pure returns (int232 downcasted) {
downcasted = int232(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(232, value);
}
}
/**
* @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
*/
function toInt224(int256 value) internal pure returns (int224 downcasted) {
downcasted = int224(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(224, value);
}
}
/**
* @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
*/
function toInt216(int256 value) internal pure returns (int216 downcasted) {
downcasted = int216(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(216, value);
}
}
/**
* @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
*/
function toInt208(int256 value) internal pure returns (int208 downcasted) {
downcasted = int208(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(208, value);
}
}
/**
* @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
*/
function toInt200(int256 value) internal pure returns (int200 downcasted) {
downcasted = int200(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(200, value);
}
}
/**
* @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
*/
function toInt192(int256 value) internal pure returns (int192 downcasted) {
downcasted = int192(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(192, value);
}
}
/**
* @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
*/
function toInt184(int256 value) internal pure returns (int184 downcasted) {
downcasted = int184(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(184, value);
}
}
/**
* @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
*/
function toInt176(int256 value) internal pure returns (int176 downcasted) {
downcasted = int176(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(176, value);
}
}
/**
* @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
*/
function toInt168(int256 value) internal pure returns (int168 downcasted) {
downcasted = int168(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(168, value);
}
}
/**
* @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
*/
function toInt160(int256 value) internal pure returns (int160 downcasted) {
downcasted = int160(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(160, value);
}
}
/**
* @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
*/
function toInt152(int256 value) internal pure returns (int152 downcasted) {
downcasted = int152(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(152, value);
}
}
/**
* @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
*/
function toInt144(int256 value) internal pure returns (int144 downcasted) {
downcasted = int144(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(144, value);
}
}
/**
* @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
*/
function toInt136(int256 value) internal pure returns (int136 downcasted) {
downcasted = int136(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(136, value);
}
}
/**
* @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
*/
function toInt128(int256 value) internal pure returns (int128 downcasted) {
downcasted = int128(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(128, value);
}
}
/**
* @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
*/
function toInt120(int256 value) internal pure returns (int120 downcasted) {
downcasted = int120(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(120, value);
}
}
/**
* @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
*/
function toInt112(int256 value) internal pure returns (int112 downcasted) {
downcasted = int112(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(112, value);
}
}
/**
* @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
*/
function toInt104(int256 value) internal pure returns (int104 downcasted) {
downcasted = int104(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(104, value);
}
}
/**
* @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
*/
function toInt96(int256 value) internal pure returns (int96 downcasted) {
downcasted = int96(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(96, value);
}
}
/**
* @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
*/
function toInt88(int256 value) internal pure returns (int88 downcasted) {
downcasted = int88(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(88, value);
}
}
/**
* @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
*/
function toInt80(int256 value) internal pure returns (int80 downcasted) {
downcasted = int80(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(80, value);
}
}
/**
* @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
*/
function toInt72(int256 value) internal pure returns (int72 downcasted) {
downcasted = int72(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(72, value);
}
}
/**
* @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
*/
function toInt64(int256 value) internal pure returns (int64 downcasted) {
downcasted = int64(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(64, value);
}
}
/**
* @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
*/
function toInt56(int256 value) internal pure returns (int56 downcasted) {
downcasted = int56(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(56, value);
}
}
/**
* @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
*/
function toInt48(int256 value) internal pure returns (int48 downcasted) {
downcasted = int48(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(48, value);
}
}
/**
* @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
*/
function toInt40(int256 value) internal pure returns (int40 downcasted) {
downcasted = int40(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(40, value);
}
}
/**
* @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
*/
function toInt32(int256 value) internal pure returns (int32 downcasted) {
downcasted = int32(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(32, value);
}
}
/**
* @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
*/
function toInt24(int256 value) internal pure returns (int24 downcasted) {
downcasted = int24(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(24, value);
}
}
/**
* @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
*/
function toInt16(int256 value) internal pure returns (int16 downcasted) {
downcasted = int16(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(16, value);
}
}
/**
* @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
*/
function toInt8(int256 value) internal pure returns (int8 downcasted) {
downcasted = int8(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(8, value);
}
}
/**
* @dev Converts an unsigned uint256 into a signed int256.
*
* Requirements:
*
* - input must be less than or equal to maxInt256.
*/
function toInt256(uint256 value) internal pure returns (int256) {
// Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
if (value > uint256(type(int256).max)) {
revert SafeCastOverflowedUintToInt(value);
}
return int256(value);
}
/**
* @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.
*/
function toUint(bool b) internal pure returns (uint256 u) {
assembly ("memory-safe") {
u := iszero(iszero(b))
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (access/extensions/IAccessControlEnumerable.sol)
pragma solidity ^0.8.20;
import {IAccessControl} from "../IAccessControl.sol";
/**
* @dev External interface of AccessControlEnumerable declared to support ERC-165 detection.
*/
interface IAccessControlEnumerable is IAccessControl {
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index) external view returns (address);
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) external view returns (uint256);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)
pragma solidity ^0.8.20;
import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol";
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {ERC165Upgradeable} from "../utils/introspection/ERC165Upgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```solidity
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```solidity
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
* to enforce additional security measures for this role.
*/
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {
struct RoleData {
mapping(address account => bool) hasRole;
bytes32 adminRole;
}
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/// @custom:storage-location erc7201:openzeppelin.storage.AccessControl
struct AccessControlStorage {
mapping(bytes32 role => RoleData) _roles;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.AccessControl")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;
function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {
assembly {
$.slot := AccessControlStorageLocation
}
}
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with an {AccessControlUnauthorizedAccount} error including the required role.
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
function __AccessControl_init() internal onlyInitializing {
}
function __AccessControl_init_unchained() internal onlyInitializing {
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual returns (bool) {
AccessControlStorage storage $ = _getAccessControlStorage();
return $._roles[role].hasRole[account];
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
* is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
* is missing `role`.
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert AccessControlUnauthorizedAccount(account, role);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {
AccessControlStorage storage $ = _getAccessControlStorage();
return $._roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address callerConfirmation) public virtual {
if (callerConfirmation != _msgSender()) {
revert AccessControlBadConfirmation();
}
_revokeRole(role, callerConfirmation);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
AccessControlStorage storage $ = _getAccessControlStorage();
bytes32 previousAdminRole = getRoleAdmin(role);
$._roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
AccessControlStorage storage $ = _getAccessControlStorage();
if (!hasRole(role, account)) {
$._roles[role].hasRole[account] = true;
emit RoleGranted(role, account, _msgSender());
return true;
} else {
return false;
}
}
/**
* @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
AccessControlStorage storage $ = _getAccessControlStorage();
if (hasRole(role, account)) {
$._roles[role].hasRole[account] = false;
emit RoleRevoked(role, account, _msgSender());
return true;
} else {
return false;
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.
pragma solidity ^0.8.20;
/**
* @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.
*
* ```solidity
* 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 is the index of the value in the `values` array plus 1.
// Position 0 is used to mean a value is not in the set.
mapping(bytes32 value => uint256) _positions;
}
/**
* @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._positions[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 cache the value's position to prevent multiple reads from the same storage slot
uint256 position = set._positions[value];
if (position != 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 valueIndex = position - 1;
uint256 lastIndex = set._values.length - 1;
if (valueIndex != lastIndex) {
bytes32 lastValue = set._values[lastIndex];
// Move the lastValue to the index where the value to delete is
set._values[valueIndex] = lastValue;
// Update the tracked position of the lastValue (that was just moved)
set._positions[lastValue] = position;
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the tracked position for the deleted slot
delete set._positions[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._positions[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;
assembly ("memory-safe") {
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;
assembly ("memory-safe") {
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;
assembly ("memory-safe") {
result := store
}
return result;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.20;
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Storage of the initializable contract.
*
* It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
* when using with upgradeable contracts.
*
* @custom:storage-location erc7201:openzeppelin.storage.Initializable
*/
struct InitializableStorage {
/**
* @dev Indicates that the contract has been initialized.
*/
uint64 _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool _initializing;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;
/**
* @dev The contract is already initialized.
*/
error InvalidInitialization();
/**
* @dev The contract is not initializing.
*/
error NotInitializing();
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint64 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
* number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
* production.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
// Cache values to avoid duplicated sloads
bool isTopLevelCall = !$._initializing;
uint64 initialized = $._initialized;
// Allowed calls:
// - initialSetup: the contract is not in the initializing state and no previous version was
// initialized
// - construction: the contract is initialized at version 1 (no reininitialization) and the
// current contract is just being deployed
bool initialSetup = initialized == 0 && isTopLevelCall;
bool construction = initialized == 1 && address(this).code.length == 0;
if (!initialSetup && !construction) {
revert InvalidInitialization();
}
$._initialized = 1;
if (isTopLevelCall) {
$._initializing = true;
}
_;
if (isTopLevelCall) {
$._initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint64 version) {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing || $._initialized >= version) {
revert InvalidInitialization();
}
$._initialized = version;
$._initializing = true;
_;
$._initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
_checkInitializing();
_;
}
/**
* @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
*/
function _checkInitializing() internal view virtual {
if (!_isInitializing()) {
revert NotInitializing();
}
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing) {
revert InvalidInitialization();
}
if ($._initialized != type(uint64).max) {
$._initialized = type(uint64).max;
emit Initialized(type(uint64).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint64) {
return _getInitializableStorage()._initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _getInitializableStorage()._initializing;
}
/**
* @dev Returns a pointer to the storage namespace.
*/
// solhint-disable-next-line var-name-mixedcase
function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
assembly {
$.slot := INITIALIZABLE_STORAGE
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC1822.sol)
pragma solidity ^0.8.20;
/**
* @dev ERC-1822: 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);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (proxy/ERC1967/ERC1967Utils.sol)
pragma solidity ^0.8.22;
import {IBeacon} from "../beacon/IBeacon.sol";
import {IERC1967} from "../../interfaces/IERC1967.sol";
import {Address} from "../../utils/Address.sol";
import {StorageSlot} from "../../utils/StorageSlot.sol";
/**
* @dev This library provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[ERC-1967] slots.
*/
library ERC1967Utils {
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev The `implementation` of the proxy is invalid.
*/
error ERC1967InvalidImplementation(address implementation);
/**
* @dev The `admin` of the proxy is invalid.
*/
error ERC1967InvalidAdmin(address admin);
/**
* @dev The `beacon` of the proxy is invalid.
*/
error ERC1967InvalidBeacon(address beacon);
/**
* @dev An upgrade function sees `msg.value > 0` that may be lost.
*/
error ERC1967NonPayable();
/**
* @dev Returns the current implementation address.
*/
function getImplementation() internal view returns (address) {
return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the ERC-1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
if (newImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(newImplementation);
}
StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Performs implementation upgrade with additional setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-Upgraded} event.
*/
function upgradeToAndCall(address newImplementation, bytes memory data) internal {
_setImplementation(newImplementation);
emit IERC1967.Upgraded(newImplementation);
if (data.length > 0) {
Address.functionDelegateCall(newImplementation, data);
} else {
_checkNonPayable();
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Returns the current admin.
*
* TIP: To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using
* the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
* `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
*/
function getAdmin() internal view returns (address) {
return StorageSlot.getAddressSlot(ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the ERC-1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
if (newAdmin == address(0)) {
revert ERC1967InvalidAdmin(address(0));
}
StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {IERC1967-AdminChanged} event.
*/
function changeAdmin(address newAdmin) internal {
emit IERC1967.AdminChanged(getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
/**
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
* This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Returns the current beacon.
*/
function getBeacon() internal view returns (address) {
return StorageSlot.getAddressSlot(BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the ERC-1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
if (newBeacon.code.length == 0) {
revert ERC1967InvalidBeacon(newBeacon);
}
StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon;
address beaconImplementation = IBeacon(newBeacon).implementation();
if (beaconImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(beaconImplementation);
}
}
/**
* @dev Change the beacon and trigger a setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-BeaconUpgraded} event.
*
* CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since
* it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for
* efficiency.
*/
function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal {
_setBeacon(newBeacon);
emit IERC1967.BeaconUpgraded(newBeacon);
if (data.length > 0) {
Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
} else {
_checkNonPayable();
}
}
/**
* @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract
* if an upgrade doesn't perform an initialization call.
*/
function _checkNonPayable() private {
if (msg.value > 0) {
revert ERC1967NonPayable();
}
}
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.28;
enum VLFAction {
None,
FetchVLF
}
interface IMitosisVaultVLF {
//=========== NOTE: EVENT DEFINITIONS ===========//
event VLFInitialized(address hubVLFVault, address asset);
event VLFDepositedWithSupply(address indexed asset, address indexed to, address indexed hubVLFVault, uint256 amount);
event VLFAllocated(address indexed hubVLFVault, uint256 amount);
event VLFDeallocated(address indexed hubVLFVault, uint256 amount);
event VLFFetched(address indexed hubVLFVault, uint256 amount);
event VLFReturned(address indexed hubVLFVault, uint256 amount);
event VLFYieldSettled(address indexed hubVLFVault, uint256 amount);
event VLFLossSettled(address indexed hubVLFVault, uint256 amount);
event VLFExtraRewardsSettled(address indexed hubVLFVault, address indexed reward, uint256 amount);
event VLFHalted(address indexed hubVLFVault, VLFAction action);
event VLFResumed(address indexed hubVLFVault, VLFAction action);
event VLFStrategyExecutorSet(address indexed hubVLFVault, address indexed strategyExecutor);
//=========== NOTE: ERROR DEFINITIONS ===========//
error IMitosisVaultVLF__VLFNotInitialized(address hubVLFVault);
error IMitosisVaultVLF__VLFAlreadyInitialized(address hubVLFVault);
error IMitosisVaultVLF__InvalidVLF(address hubVLFVault, address asset);
error IMitosisVaultVLF__StrategyExecutorNotDrained(address hubVLFVault, address strategyExecutor);
//=========== NOTE: View functions ===========//
function isVLFInitialized(address hubVLFVault) external view returns (bool);
function availableVLF(address hubVLFVault) external view returns (uint256);
function vlfStrategyExecutor(address hubVLFVault) external view returns (address);
//=========== NOTE: QUOTE FUNCTIONS ===========//
function quoteDepositWithSupplyVLF(address asset, address to, address hubVLFVault, uint256 amount)
external
view
returns (uint256);
function quoteDeallocateVLF(address hubVLFVault, uint256 amount) external view returns (uint256);
function quoteSettleVLFYield(address hubVLFVault, uint256 amount) external view returns (uint256);
function quoteSettleVLFLoss(address hubVLFVault, uint256 amount) external view returns (uint256);
function quoteSettleVLFExtraRewards(address hubVLFVault, address reward, uint256 amount)
external
view
returns (uint256);
//=========== NOTE: Asset ===========//
function depositWithSupplyVLF(address asset, address to, address hubVLFVault, uint256 amount) external payable;
//=========== NOTE: VLF ===========//
function initializeVLF(address hubVLFVault, address asset) external;
function allocateVLF(address hubVLFVault, uint256 amount) external;
function deallocateVLF(address hubVLFVault, uint256 amount) external payable;
function fetchVLF(address hubVLFVault, uint256 amount) external;
function returnVLF(address hubVLFVault, uint256 amount) external;
function settleVLFYield(address hubVLFVault, uint256 amount) external payable;
function settleVLFLoss(address hubVLFVault, uint256 amount) external payable;
function settleVLFExtraRewards(address hubVLFVault, address reward, uint256 amount) external payable;
//=========== NOTE: Ownable ===========//
function setVLFStrategyExecutor(address hubVLFVault, address strategyExecutor) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.28;
interface IVersioned {
function GIT_TAG() external view returns (string memory);
function GIT_COMMIT() external view returns (string memory);
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.28;
import { IERC20 } from '@oz/interfaces/IERC20.sol';
interface INativeWrappedToken is IERC20 {
function deposit() external payable;
function withdraw(uint256 amount) external;
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.28;
import { IERC20 } from '@oz/token/ERC20/IERC20.sol';
import { IMitosisVault } from '../IMitosisVault.sol';
import { IStrategyExecutor } from './IStrategyExecutor.sol';
import { ITally } from './tally/ITally.sol';
interface IVLFStrategyExecutor is IStrategyExecutor {
error IVLFStrategyExecutor__TallyTotalBalanceNotZero(address implementation);
error IVLFStrategyExecutor__TallyAlreadySet(address implementation);
error IVLFStrategyExecutor__StrategistNotSet();
error IVLFStrategyExecutor__ExecutorNotSet();
function vault() external view returns (IMitosisVault);
function asset() external view returns (IERC20);
function hubVLFVault() external view returns (address);
function strategist() external view returns (address);
function executor() external view returns (address);
function tally() external view returns (ITally);
function totalBalance() external view returns (uint256);
function storedTotalBalance() external view returns (uint256);
function quoteDeallocateLiquidity(uint256 amount) external view returns (uint256);
function quoteSettleYield(uint256 amount) external view returns (uint256);
function quoteSettleLoss(uint256 amount) external view returns (uint256);
function quoteSettleExtraRewards(address reward, uint256 amount) external view returns (uint256);
function deallocateLiquidity(uint256 amount) external payable;
function fetchLiquidity(uint256 amount) external;
function returnLiquidity(uint256 amount) external;
function settle() external payable;
function settleExtraRewards(address reward, uint256 amount) external payable;
function setTally(address implementation) external;
function setStrategist(address strategist_) external;
function setExecutor(address executor_) external;
function unsetStrategist() external;
function unsetExecutor() external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../token/ERC20/IERC20.sol";// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../utils/introspection/IERC165.sol";// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (access/IAccessControl.sol)
pragma solidity ^0.8.20;
/**
* @dev External interface of AccessControl declared to support ERC-165 detection.
*/
interface IAccessControl {
/**
* @dev The `account` is missing a role.
*/
error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);
/**
* @dev The caller of a function is not the expected one.
*
* NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
*/
error AccessControlBadConfirmation();
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call. This account bears the admin role (for the granted role).
* Expected in cases where the role was granted using the internal {AccessControl-_grantRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*/
function renounceRole(bytes32 role, address callerConfirmation) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/ERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import {Initializable} from "../../proxy/utils/Initializable.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*/
abstract contract ERC165Upgradeable is Initializable, IERC165 {
function __ERC165_init() internal onlyInitializing {
}
function __ERC165_init_unchained() internal onlyInitializing {
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/IBeacon.sol)
pragma solidity ^0.8.20;
/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/
interface IBeacon {
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {UpgradeableBeacon} will check that this address is a contract.
*/
function implementation() external view returns (address);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC1967.sol)
pragma solidity ^0.8.20;
/**
* @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.
*/
interface IERC1967 {
/**
* @dev Emitted when the implementation is upgraded.
*/
event Upgraded(address indexed implementation);
/**
* @dev Emitted when the admin account has changed.
*/
event AdminChanged(address previousAdmin, address newAdmin);
/**
* @dev Emitted when the beacon is changed.
*/
event BeaconUpgraded(address indexed beacon);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.
pragma solidity ^0.8.20;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC-1967 implementation slot:
* ```solidity
* contract ERC1967 {
* // Define the slot. Alternatively, use the SlotDerivation library to derive the slot.
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(newImplementation.code.length > 0);
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* TIP: Consider using this library along with {SlotDerivation}.
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
struct Int256Slot {
int256 value;
}
struct StringSlot {
string value;
}
struct BytesSlot {
bytes value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Int256Slot` with member `value` located at `slot`.
*/
function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `StringSlot` with member `value` located at `slot`.
*/
function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` representation of the string storage pointer `store`.
*/
function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
assembly ("memory-safe") {
r.slot := store.slot
}
}
/**
* @dev Returns a `BytesSlot` with member `value` located at `slot`.
*/
function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
*/
function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
assembly ("memory-safe") {
r.slot := store.slot
}
}
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.28;
import { IERC20 } from '@oz/token/ERC20/IERC20.sol';
import { IMitosisVault } from '../IMitosisVault.sol';
interface IStrategyExecutor {
//=========== NOTE: EVENT DEFINITIONS ===========//
event TallySet(address indexed implementation);
event StrategistSet(address indexed strategist);
event ExecutorSet(address indexed executor);
function execute(address target, bytes calldata data, uint256 value) external payable returns (bytes memory result);
function execute(address[] calldata targets, bytes[] calldata data, uint256[] calldata values)
external
payable
returns (bytes[] memory results);
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.28;
interface ITally {
function totalBalance(bytes memory context) external view returns (uint256 totalBalance_);
function withdrawableBalance(bytes memory context) external view returns (uint256 withdrawableBalance_);
function pendingDepositBalance(bytes memory context) external view returns (uint256 pendingDepositBalance_);
function pendingWithdrawBalance(bytes memory context) external view returns (uint256 pendingWithdrawBalance_);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}{
"remappings": [
"@elliptic-curve-solidity/=dependencies/@elliptic-curve-solidity-0.2.5/",
"@hpl/=node_modules/@hyperlane-xyz/core/contracts/",
"@mito-expedition/=dependencies/mito-expedition-0.0.3/src/",
"@mito-mainnet/=dependencies/mitosis-1.1.0/",
"@mito-tracle/=dependencies/mito-tracle-0.0.1/src/",
"@mito-utils/=dependencies/mito-utils-0.0.1/src/",
"@oz/=dependencies/@openzeppelin-contracts-5.2.0/",
"@ozu/=dependencies/@openzeppelin-contracts-upgradeable-5.2.0/",
"@solady/=dependencies/solady-0.1.21/src/",
"@solmate/=dependencies/solmate-6.8.0/src/",
"@std/=dependencies/forge-std-1.9.6/src/",
"@oz-v4/=dependencies/mito-expedition-0.0.3/dependencies/@openzeppelin-contracts-4.9.6/",
"@ozu-v4/=dependencies/mito-expedition-0.0.3/dependencies/@openzeppelin-contracts-upgradeable-4.9.6/",
"@openzeppelin/contracts-upgradeable/=dependencies/@openzeppelin-contracts-upgradeable-5.2.0/",
"@openzeppelin/contracts/=dependencies/@openzeppelin-contracts-5.2.0/",
"dependencies/mito-expedition-0.0.3:@hpl-v3/=dependencies/mito-expedition-0.0.3/dependencies/@hpl-3.0.0/contracts/",
"dependencies/mito-expedition-0.0.3:@oz-v4/=dependencies/mito-expedition-0.0.3/dependencies/@openzeppelin-contracts-4.9.6/",
"dependencies/mito-expedition-0.0.3:@ozu-v4/=dependencies/mito-expedition-0.0.3/dependencies/@openzeppelin-contracts-upgradeable-4.9.6/",
"node_modules/@hyperlane-xyz/core:@openzeppelin/=node_modules/@openzeppelin/",
"@arbitrum/=node_modules/@arbitrum/",
"@chainlink/=node_modules/@chainlink/",
"@elliptic-curve-solidity-0.2.5/=dependencies/@elliptic-curve-solidity-0.2.5/",
"@eth-optimism/=node_modules/@eth-optimism/",
"@hpl-v3/=dependencies/mito-expedition-0.0.3/dependencies/@hpl-3.0.0/contracts/",
"@hyperlane-xyz/=node_modules/@hyperlane-xyz/",
"@layerzerolabs/=node_modules/@layerzerolabs/",
"@mito/=dependencies/mito-utils-0.0.1/dependencies/mitosis-1.0.1/",
"@murky-0.0.1/=dependencies/mitosis-1.1.0/dependencies/@murky-0.0.1/",
"@murky/=dependencies/mitosis-1.1.0/dependencies/@murky-0.0.1/src/",
"@offchainlabs/=node_modules/@offchainlabs/",
"@openzeppelin-contracts-5.2.0/=dependencies/@openzeppelin-contracts-5.2.0/",
"@openzeppelin-contracts-upgradeable-5.2.0/=dependencies/@openzeppelin-contracts-upgradeable-5.2.0/",
"@scroll-tech/=node_modules/@scroll-tech/",
"@zksync/=node_modules/@zksync/",
"forge-std-1.9.6/=dependencies/forge-std-1.9.6/src/",
"forge-std/=dependencies/solady-0.1.21/test/utils/forge-std/",
"fx-portal/=node_modules/fx-portal/",
"mito-expedition-0.0.3/=dependencies/mito-expedition-0.0.3/src/",
"mito-tracle-0.0.1/=dependencies/mito-tracle-0.0.1/src/",
"mito-utils-0.0.1/=dependencies/mito-utils-0.0.1/src/",
"mitosis-1.1.0/=dependencies/mitosis-1.1.0/",
"proxy/=dependencies/mitosis-1.1.0/lib/proxy/",
"solady-0.1.12/=dependencies/mitosis-1.1.0/dependencies/solady-0.1.12/",
"solady-0.1.21/=dependencies/solady-0.1.21/src/",
"solady/=node_modules/solady/",
"solmate-6.8.0/=dependencies/solmate-6.8.0/src/",
"dependencies/@openzeppelin-contracts-upgradeable-5.1.0:@openzeppelin/contracts/=dependencies/mitosis-1.1.0/dependencies/@openzeppelin-contracts-5.1.0/"
],
"optimizer": {
"enabled": true,
"runs": 150
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "cancun",
"viaIR": false
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"implementation","type":"address"}],"name":"ERC1967InvalidImplementation","type":"error"},{"inputs":[],"name":"ERC1967NonPayable","type":"error"},{"inputs":[],"name":"FailedCall","type":"error"},{"inputs":[],"name":"Halted","type":"error"},{"inputs":[{"internalType":"address","name":"hubVLFVault","type":"address"},{"internalType":"address","name":"asset","type":"address"}],"name":"IMitosisVaultVLF__InvalidVLF","type":"error"},{"inputs":[{"internalType":"address","name":"hubVLFVault","type":"address"},{"internalType":"address","name":"strategyExecutor","type":"address"}],"name":"IMitosisVaultVLF__StrategyExecutorNotDrained","type":"error"},{"inputs":[{"internalType":"address","name":"hubVLFVault","type":"address"}],"name":"IMitosisVaultVLF__VLFAlreadyInitialized","type":"error"},{"inputs":[{"internalType":"address","name":"hubVLFVault","type":"address"}],"name":"IMitosisVaultVLF__VLFNotInitialized","type":"error"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"IMitosisVault__AssetAlreadyInitialized","type":"error"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"IMitosisVault__AssetNotInitialized","type":"error"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"increasedSupply","type":"uint256"},{"internalType":"uint256","name":"availableCap","type":"uint256"}],"name":"IMitosisVault__ExceededCap","type":"error"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"IMitosisVault__InsufficientBalance","type":"error"},{"inputs":[{"internalType":"string","name":"description","type":"string"}],"name":"InvalidAddress","type":"error"},{"inputs":[{"internalType":"string","name":"description","type":"string"}],"name":"InvalidId","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"NotSupported","type":"error"},{"inputs":[{"internalType":"bytes4","name":"sig","type":"bytes4"}],"name":"Pausable__NotPaused","type":"error"},{"inputs":[{"internalType":"bytes4","name":"sig","type":"bytes4"}],"name":"Pausable__Paused","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"UUPSUnauthorizedCallContext","type":"error"},{"inputs":[{"internalType":"bytes32","name":"slot","type":"bytes32"}],"name":"UUPSUnsupportedProxiableUUID","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"inputs":[{"internalType":"string","name":"description","type":"string"}],"name":"ZeroAddress","type":"error"},{"inputs":[],"name":"ZeroAmount","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"enum AssetAction","name":"action","type":"uint8"}],"name":"AssetHalted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"asset","type":"address"}],"name":"AssetInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"enum AssetAction","name":"action","type":"uint8"}],"name":"AssetResumed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"setter","type":"address"},{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"prevMaxCap","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newMaxCap","type":"uint256"}],"name":"CapSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"entrypoint","type":"address"}],"name":"EntrypointSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"hubVLFVault","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"VLFAllocated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"hubVLFVault","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"VLFDeallocated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"address","name":"hubVLFVault","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"VLFDepositedWithSupply","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"hubVLFVault","type":"address"},{"indexed":true,"internalType":"address","name":"reward","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"VLFExtraRewardsSettled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"hubVLFVault","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"VLFFetched","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"hubVLFVault","type":"address"},{"indexed":false,"internalType":"enum VLFAction","name":"action","type":"uint8"}],"name":"VLFHalted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"hubVLFVault","type":"address"},{"indexed":false,"internalType":"address","name":"asset","type":"address"}],"name":"VLFInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"hubVLFVault","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"VLFLossSettled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"hubVLFVault","type":"address"},{"indexed":false,"internalType":"enum VLFAction","name":"action","type":"uint8"}],"name":"VLFResumed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"hubVLFVault","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"VLFReturned","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"hubVLFVault","type":"address"},{"indexed":true,"internalType":"address","name":"strategyExecutor","type":"address"}],"name":"VLFStrategyExecutorSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"hubVLFVault","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"VLFYieldSettled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"GIT_COMMIT","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"GIT_TAG","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LIQUIDITY_MANAGER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UPGRADE_INTERFACE_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"hubVLFVault","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"allocateVLF","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"availableCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"hubVLFVault","type":"address"}],"name":"availableVLF","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"hubVLFVault","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"deallocateVLF","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"address","name":"hubVLFVault","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"depositWithSupplyVLF","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"entrypoint","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"hubVLFVault","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"fetchVLF","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMembers","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"enum AssetAction","name":"action","type":"uint8"}],"name":"haltAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"hubVLFVault","type":"address"},{"internalType":"enum VLFAction","name":"action","type":"uint8"}],"name":"haltVLF","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner_","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"initializeAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"hubVLFVault","type":"address"},{"internalType":"address","name":"asset","type":"address"}],"name":"initializeVLF","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"enum AssetAction","name":"action","type":"uint8"}],"name":"isAssetActionHalted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"isAssetInitialized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"sig","type":"bytes4"}],"name":"isPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isPausedGlobally","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"hubVLFVault","type":"address"},{"internalType":"enum VLFAction","name":"action","type":"uint8"}],"name":"isVLFActionHalted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"hubVLFVault","type":"address"}],"name":"isVLFInitialized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"maxCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"sig","type":"bytes4"}],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"hubVLFVault","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"quoteDeallocateVLF","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"quoteDeposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"address","name":"hubVLFVault","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"quoteDepositWithSupplyVLF","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"hubVLFVault","type":"address"},{"internalType":"address","name":"reward","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"quoteSettleVLFExtraRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"hubVLFVault","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"quoteSettleVLFLoss","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"hubVLFVault","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"quoteSettleVLFYield","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"enum AssetAction","name":"action","type":"uint8"}],"name":"resumeAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"hubVLFVault","type":"address"},{"internalType":"enum VLFAction","name":"action","type":"uint8"}],"name":"resumeVLF","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"hubVLFVault","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"returnVLF","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"newCap","type":"uint256"}],"name":"setCap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"entrypoint_","type":"address"}],"name":"setEntrypoint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"hubVLFVault","type":"address"},{"internalType":"address","name":"strategyExecutor_","type":"address"}],"name":"setVLFStrategyExecutor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"hubVLFVault","type":"address"},{"internalType":"address","name":"reward","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"settleVLFExtraRewards","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"hubVLFVault","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"settleVLFLoss","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"hubVLFVault","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"settleVLFYield","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"sig","type":"bytes4"}],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"hubVLFVault","type":"address"}],"name":"vlfStrategyExecutor","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]Contract Creation Code
6018610100527f6d69746f7369732e73746f726167652e5061757361626c650000000000000000610120527fc54626fc04d85ad9376dab049820c729659d7c41d8f5502284beb6f5d9455f7f5f527f582977cdeb9b6be2e2a29b3d4fca6da72f5834abc9644d4ffc634612bd49c0006080523060a0526101a060405260236101408181526100a591613b016101603980516020918201205f19015f9081522060ff191690565b60c0908152506100de604051806060016040528060268152602001613b246026913980516020918201205f19015f9081522060ff191690565b60e0523480156100ec575f5ffd5b506100f56100fa565b6101ac565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff161561014a5760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b03908116146101a95780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b60805160a05160c05160e0516139146101ed5f395f6123eb01525f61236901525f818161270f0152818161273801526128e501525f612dbc01526139145ff3fe608060405260043610610309575f3560e01c806391d14854116101a0578063bf779f1d116100f1578063d547741f1161009f578063ee5125171161006e578063ee512517146109b0578063f25582fd146109cf578063f4164f01146109e2578063f8688b16146109f557610327565b8063d547741f14610934578063d86f0de314610953578063d9caed1214610972578063e162a1b41461099157610327565b8063bf779f1d14610867578063c035a68014610886578063c0b0e776146108a5578063c4d66de8146108c4578063c794b913146108e3578063ca15c873146108f6578063ce9aadf51461091557610327565b8063ad3cb1cc1161014e578063ad3cb1cc14610769578063b0f407da146107a6578063b175eb4d146107c5578063b39d5e10146107f6578063b83fd9ff14610815578063b8a15e3a14610834578063bac1e94b1461084857610327565b806391d14854146106a557806393a9ec75146106c4578063a217fddf146106d8578063a3246ad3146106eb578063a65d69d414610717578063a6f77f961461072b578063a71f26011461074a57610327565b80634f1ef2861161025a57806368b8fc1f1161020857806368b8fc1f146105d657806380ad2cf3146105f557806382fb069a146106145780638340f549146106335780638456cb591461064657806384fde5351461065a5780639010d07c1461068657610327565b80634f1ef2861461052057806350b99f5d1461053357806352d1902d1461055257806359fd2f89146105665780635b9a0e19146105795780635bbcc9081461059857806366a0cce9146105b757610327565b8063248a9ca3116102b7578063248a9ca3146104525780632f2ff15d1461047157806336568abe146104905780633aa83ec7146104af5780633c57dd5d146104ce5780633f4ba83a146104ed57806347c8fb5a1461050157610327565b806301a1c8ae1461034057806301ffc9a7146103615780630548c04f1461039557806309b65e66146103b45780630ab9b17d146103d35780631b150a6f146103f2578063242f05511461041157610327565b3661032757604051630280e1e560e61b815260040160405180910390fd5b604051630280e1e560e61b815260040160405180910390fd5b34801561034b575f5ffd5b5061035f61035a3660046133ba565b610a08565b005b34801561036c575f5ffd5b5061038061037b3660046133f1565b610e25565b60405190151581526020015b60405180910390f35b3480156103a0575f5ffd5b506103806103af366004613424565b610e4f565b3480156103bf575f5ffd5b506103806103ce3660046133f1565b610e69565b3480156103de575f5ffd5b5061035f6103ed366004613424565b610e73565b3480156103fd575f5ffd5b5061035f61040c366004613424565b610ea4565b34801561041c575f5ffd5b506104447f77e60b99a50d27fb027f6912a507d956105b4148adab27a86d235c8bcca8fa2f81565b60405190815260200161038c565b34801561045d575f5ffd5b5061044461046c366004613450565b610ecd565b34801561047c575f5ffd5b5061035f61048b366004613467565b610eed565b34801561049b575f5ffd5b5061035f6104aa366004613467565b610f09565b3480156104ba575f5ffd5b5061035f6104c93660046133f1565b610f3c565b3480156104d9575f5ffd5b506104446104e836600461348a565b610f51565b3480156104f8575f5ffd5b5061035f610fd3565b34801561050c575f5ffd5b5061038061051b3660046134c8565b610fe6565b61035f61052e3660046134f7565b610ff8565b34801561053e575f5ffd5b5061035f61054d3660046135bd565b611017565b34801561055d575f5ffd5b50610444611115565b61035f61057436600461348a565b611130565b348015610584575f5ffd5b506104446105933660046135e7565b6112c3565b3480156105a3575f5ffd5b5061035f6105b23660046134c8565b611356565b3480156105c2575f5ffd5b5061035f6105d1366004613424565b61141e565b3480156105e1575f5ffd5b506104446105f03660046134c8565b611447565b348015610600575f5ffd5b5061035f61060f3660046135bd565b611474565b34801561061f575f5ffd5b5061035f61062e3660046135bd565b6114bd565b61035f61064136600461348a565b6115b8565b348015610651575f5ffd5b5061035f6116be565b348015610665575f5ffd5b506106796106743660046134c8565b6116cf565b60405161038c9190613635565b348015610691575f5ffd5b506106796106a0366004613649565b6116fd565b3480156106b0575f5ffd5b506103806106bf366004613467565b611721565b3480156106cf575f5ffd5b50610380611757565b3480156106e3575f5ffd5b506104445f81565b3480156106f6575f5ffd5b5061070a610705366004613450565b611765565b60405161038c9190613669565b348015610722575f5ffd5b50610679611789565b348015610736575f5ffd5b506103806107453660046134c8565b6117a1565b348015610755575f5ffd5b506104446107643660046134c8565b6117b3565b348015610774575f5ffd5b50610799604051806040016040528060058152602001640352e302e360dc1b81525081565b60405161038c91906136b4565b3480156107b1575f5ffd5b5061035f6107c0366004613424565b6117e0565b3480156107d0575f5ffd5b5061079960405180604001604052806006815260200165076312e312e360d41b81525081565b348015610801575f5ffd5b5061035f6108103660046133ba565b61180a565b348015610820575f5ffd5b5061044461082f3660046135bd565b61190a565b34801561083f575f5ffd5b5061079961197f565b348015610853575f5ffd5b5061035f6108623660046133f1565b61199b565b348015610872575f5ffd5b5061044461088136600461348a565b6119ad565b348015610891575f5ffd5b5061035f6108a03660046135bd565b6119e5565b3480156108b0575f5ffd5b506104446108bf3660046135bd565b611add565b3480156108cf575f5ffd5b5061035f6108de3660046134c8565b611b13565b61035f6108f13660046135e7565b611c43565b348015610901575f5ffd5b50610444610910366004613450565b611dea565b348015610920575f5ffd5b5061044461092f3660046134c8565b611e0d565b34801561093f575f5ffd5b5061035f61094e366004613467565b611e37565b34801561095e575f5ffd5b5061044461096d3660046135bd565b611e53565b34801561097d575f5ffd5b5061035f61098c36600461348a565b611e89565b34801561099c575f5ffd5b506103806109ab366004613424565b611faa565b3480156109bb575f5ffd5b5061035f6109ca3660046134c8565b611fbd565b61035f6109dd3660046135bd565b61202a565b61035f6109f03660046135bd565b61212b565b61035f610a033660046135bd565b61225c565b5f610a128161235d565b5f610a1b612367565b6001600160a01b0385165f908152602082905260409020909150610a3f828661238b565b60018101546001600160a01b031615610b8c5760018101546040805163ad7a672f60e01b815290515f926001600160a01b03169163ad7a672f9160048083019260209291908290030181865afa158015610a9b573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610abf91906136e9565b158015610b3f5750816001015f9054906101000a90046001600160a01b03166001600160a01b03166350dcefc56040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b19573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610b3d91906136e9565b155b600183015490915086906001600160a01b031682610b8857604051635cb4c20560e11b81526001600160a01b039283166004820152911660248201526044015b60405180910390fd5b5050505b836001600160a01b03166345cbdf856040518163ffffffff1660e01b8152600401602060405180830381865afa158015610bc8573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610bec9190613700565b6001600160a01b0316856001600160a01b031614610c4d576040516356e22f5760e11b815260206004820152601f60248201527f564c4653747261746567794578656375746f722e687562564c465661756c74006044820152606401610b7f565b836001600160a01b031663fbfa77cf6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c89573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610cad9190613700565b6001600160a01b0316306001600160a01b031614610d0e57604051630b0f5aa160e11b815260206004820152601960248201527f564c4653747261746567794578656375746f722e7661756c74000000000000006044820152606401610b7f565b836001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d4a573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d6e9190613700565b815461010090046001600160a01b03908116911614610dd057604051630b0f5aa160e11b815260206004820152601960248201527f564c4653747261746567794578656375746f722e6173736574000000000000006044820152606401610b7f565b6001810180546001600160a01b0319166001600160a01b0386811691821790925560405190918716907fe33c4a07b426a165492de4c99e8c0aaf12a7e2f4d7e9ecddd951f3a8b94e292d905f90a35050505050565b5f6001600160e01b03198216635a05180f60e01b1480610e495750610e49826123b5565b92915050565b5f610e62610e5b6123e9565b848461240d565b9392505050565b5f610e498261246a565b5f610e7d8161235d565b5f610e86612367565b9050610e92818561238b565b610e9d8185856124a7565b505b505050565b5f610eae8161235d565b5f610eb76123e9565b9050610ec284612545565b610e9d818585612576565b5f9081525f5160206138975f395f51905f52602052604090206001015490565b610ef682610ecd565b610eff8161235d565b610e9d8383612614565b6001600160a01b0381163314610f325760405163334bd91960e11b815260040160405180910390fd5b610e9f8282612653565b610f4533612689565b610f4e81612693565b50565b5f610f5a6123e9565b54604051633c57dd5d60e01b81526001600160a01b0390911690633c57dd5d90610f8c9087908790879060040161371b565b602060405180830381865afa158015610fa7573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610fcb91906136e9565b949350505050565b610fdc33612689565b610fe46126cc565b565b5f610e49610ff2612367565b836126e6565b611000612704565b61100982612689565b6110138282612792565b5050565b61102b5f356001600160e01b03191661246a565b155f356001600160e01b0319169061105757604051633dba50a160e11b8152600401610b7f919061373f565b505f611061612367565b905061106d818461238b565b6110778184612845565b6001600160a01b0383165f908152602082905260408120600281018054919285926110a3908490613768565b9091555050600181015481546110cc916001600160a01b03610100909204821691163086612880565b836001600160a01b03167fad7b770e4601b306bc5d9616605363bc5308982391b45586efb2a7e502e1432d8460405161110791815260200190565b60405180910390a250505050565b5f61111e6128da565b505f5160206138775f395f51905f5290565b6111445f356001600160e01b03191661246a565b155f356001600160e01b0319169061117057604051633dba50a160e11b8152600401610b7f919061373f565b505f61117a612367565b9050611186818561238b565b6111908185612845565b61119983612545565b6001600160a01b038085165f9081526020839052604090205461010090048116908416036111f357604051630b0f5aa160e11b81526020600482015260066024820152651c995dd85c9960d21b6044820152606401610b7f565b6112086001600160a01b038416333085612880565b611210611789565b6001600160a01b0316632b52cac534868686336040518663ffffffff1660e01b8152600401611242949392919061377b565b5f604051808303818588803b158015611259575f5ffd5b505af115801561126b573d5f5f3e3d5ffd5b5050505050826001600160a01b0316846001600160a01b03167fb4010c0e1f7bae6953fc6794cbfe3472778d7196ab26508e3ec87e3cc33a0ffd846040516112b591815260200190565b60405180910390a350505050565b5f6112cc611789565b604051635b9a0e1960e01b81526001600160a01b03878116600483015286811660248301528581166044830152606482018590529190911690635b9a0e1990608401602060405180830381865afa158015611329573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061134d91906136e9565b95945050505050565b61136a5f356001600160e01b03191661246a565b155f356001600160e01b0319169061139657604051633dba50a160e11b8152600401610b7f919061373f565b505f6113a06123e9565b90506113ab81612923565b6113b58183612955565b6001600160a01b0382165f9081526001828101602052604091829020805460ff19169091179055517f271b4511ff4aaef63080ee912e106daf4730d4103103ece6b8945b8f63ee02499061140a908490613635565b60405180910390a161101381836001612980565b5f6114288161235d565b5f6114316123e9565b905061143c84612545565b610e9d818585612980565b5f6114506123e9565b6001600160a01b039092165f90815260019283016020526040902090910154919050565b7f77e60b99a50d27fb027f6912a507d956105b4148adab27a86d235c8bcca8fa2f61149e8161235d565b5f6114a76123e9565b90506114b284612545565b610e9d818585612a20565b6114d15f356001600160e01b03191661246a565b155f356001600160e01b031916906114fd57604051633dba50a160e11b8152600401610b7f919061373f565b505f611507612367565b9050611513818461238b565b61151d8184612845565b61152981846001612acb565b6001600160a01b0383165f908152602082905260408120600281018054919285926115559084906137a6565b90915550506001810154815461157d916001600160a01b036101009092048216911685612af4565b836001600160a01b03167f71248be0fed002e6813a6fb135948440ac02c47bf6cb7740c49d192093e240fa8460405161110791815260200190565b6115cc5f356001600160e01b03191661246a565b155f356001600160e01b031916906115f857604051633dba50a160e11b8152600401610b7f919061373f565b50611604838383612b1a565b61160c611789565b6001600160a01b0316633bc1f1ed34858585336040518663ffffffff1660e01b815260040161163e949392919061377b565b5f604051808303818588803b158015611655575f5ffd5b505af1158015611667573d5f5f3e3d5ffd5b5050505050816001600160a01b0316836001600160a01b03167f8752a472e571a816aea92eec8dae9baf628e840f4929fbcc2d155e6233ff68a7836040516116b191815260200190565b60405180910390a3505050565b6116c733612689565b610fe4612be8565b5f6116d8612367565b6001600160a01b039283165f9081526020919091526040902060010154909116919050565b5f5f611707612bf2565b5f858152602082905260409020909150610fcb9084612c16565b5f9182525f5160206138975f395f51905f52602090815260408084206001600160a01b0393909316845291905290205460ff1690565b5f611760612c21565b905090565b60605f611770612bf2565b5f848152602082905260409020909150610e6290612c33565b5f6117926123e9565b546001600160a01b0316919050565b5f610e496117ad6123e9565b83612c3f565b5f6117bc6123e9565b6001600160a01b039092165f90815260019290920160205250604090206002015490565b5f6117ea8161235d565b5f6117f3612367565b90506117ff818561238b565b610e9d818585612c60565b61181e5f356001600160e01b03191661246a565b155f356001600160e01b0319169061184a57604051633dba50a160e11b8152600401610b7f919061373f565b5033611854611789565b6001600160a01b03161461187a576040516282b42960e81b815260040160405180910390fd5b5f611883612367565b905061188f8184612cfa565b61189882612545565b6001600160a01b038381165f8181526020848152604091829020805460016001600160a81b03199091166101009689169687021717905581519283528201929092527ffeaa4cbc48054e489f18778fdf9688fc858cc9232407b5774fc30247420975eb910160405180910390a1505050565b5f611913611789565b6001600160a01b031663b83fd9ff84846040518363ffffffff1660e01b81526004016119409291906137b9565b602060405180830381865afa15801561195b573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e6291906136e9565b6040518060600160405280602881526020016138b76028913981565b6119a433612689565b610f4e81612d25565b5f6119b6611789565b6001600160a01b031663bf779f1d8585856040518463ffffffff1660e01b8152600401610f8c9392919061371b565b6119f95f356001600160e01b03191661246a565b155f356001600160e01b03191690611a2557604051633dba50a160e11b8152600401610b7f919061373f565b5033611a2f611789565b6001600160a01b031614611a55576040516282b42960e81b815260040160405180910390fd5b5f611a5e612367565b9050611a6a818461238b565b6001600160a01b0383165f9081526020829052604081206002018054849290611a94908490613768565b90915550506040518281526001600160a01b038416907fb5b50a62d4e1cba9918f5958084ec018cbcc745d8b21a305684e8cbe69d5a0fe906020015b60405180910390a2505050565b5f611ae6611789565b6001600160a01b031663c0b0e77684846040518363ffffffff1660e01b81526004016119409291906137b9565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff16159067ffffffffffffffff165f81158015611b585750825b90505f8267ffffffffffffffff166001148015611b745750303b155b905081158015611b82575080155b15611ba05760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff191660011785558315611bca57845460ff60401b1916600160401b1785555b611bd2612d2e565b611bda612d42565b611be2612d42565b611bea612d42565b611bf45f87612614565b508315611c3b57845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b505050505050565b611c575f356001600160e01b03191661246a565b155f356001600160e01b03191690611c8357604051633dba50a160e11b8152600401610b7f919061373f565b50611c8f848483612b1a565b5f611c98612367565b9050611ca4818461238b565b6001600160a01b038381165f90815260208390526040902054849187916101009004811690821614611cfc5760405163666845bf60e11b81526001600160a01b03928316600482015291166024820152604401610b7f565b5050611d06611789565b6001600160a01b031663136cbbe234878787873360405160e088901b6001600160e01b03191681526001600160a01b039586166004820152938516602485015291841660448401526064830152909116608482015260a4015f604051808303818588803b158015611d75575f5ffd5b505af1158015611d87573d5f5f3e3d5ffd5b5050505050826001600160a01b0316846001600160a01b0316866001600160a01b03167ffb94a3cc1fb9fc8de6bcafbef31f0aecc14e2d9016aab073d72c8410aabe2ebf85604051611ddb91815260200190565b60405180910390a45050505050565b5f5f611df4612bf2565b5f848152602082905260409020909150610e6290612d4a565b5f611e16612367565b6001600160a01b039092165f90815260209290925250604090206002015490565b611e4082610ecd565b611e498161235d565b610e9d8383612653565b5f611e5c611789565b6001600160a01b031663d86f0de384846040518363ffffffff1660e01b81526004016119409291906137b9565b611e9d5f356001600160e01b03191661246a565b155f356001600160e01b03191690611ec957604051633dba50a160e11b8152600401610b7f919061373f565b505f611ed36123e9565b9050611ede81612923565b611ee784612545565b6001600160a01b0384165f908152600180830160205260409091206002810154910154611f1f918491611f1a91906137a6565b612d53565b6001600160a01b0385165f90815260018301602052604081206002018054909190611f4b908490613768565b90915550611f6590506001600160a01b0385168484612af4565b826001600160a01b0316846001600160a01b03167fd1c19fbcd4551a5edfb66d43d2e337c04837afda3482b42bdf569a8fccdae5fb846040516112b591815260200190565b5f610e62611fb6612367565b8484612d62565b5f611fc78161235d565b81611fd06123e9565b80546001600160a01b0319166001600160a01b03929092169190911790556040517f19801148c19aa672dbfd5937fc6fc37a80e7686a916c4d17c3050c009abb44c39061201e908490613635565b60405180910390a15050565b61203e5f356001600160e01b03191661246a565b155f356001600160e01b0319169061206a57604051633dba50a160e11b8152600401610b7f919061373f565b505f612074612367565b9050612080818461238b565b61208a8184612845565b612092611789565b6001600160a01b0316637850cef7348585336040518563ffffffff1660e01b81526004016120c2939291906137d2565b5f604051808303818588803b1580156120d9575f5ffd5b505af11580156120eb573d5f5f3e3d5ffd5b5050505050826001600160a01b03167fa42a17de83bab77c0db989620426811a993d7b5678130bc555414126ba83bcb083604051611ad091815260200190565b61213f5f356001600160e01b03191661246a565b155f356001600160e01b0319169061216b57604051633dba50a160e11b8152600401610b7f919061373f565b505f612175612367565b9050612181818461238b565b61218b8184612845565b6001600160a01b0383165f90815260208290526040812060020180548492906121b59084906137a6565b909155506121c39050611789565b6001600160a01b0316634b5e6762348585336040518563ffffffff1660e01b81526004016121f3939291906137d2565b5f604051808303818588803b15801561220a575f5ffd5b505af115801561221c573d5f5f3e3d5ffd5b5050505050826001600160a01b03167f704070690fc3d8d2bc7b3f7c20a0315c249e0e576107fd544ac4868aba173f7583604051611ad091815260200190565b6122705f356001600160e01b03191661246a565b155f356001600160e01b0319169061229c57604051633dba50a160e11b8152600401610b7f919061373f565b505f6122a6612367565b90506122b2818461238b565b6122bc8184612845565b6122c4611789565b6001600160a01b0316638bffca0a348585336040518563ffffffff1660e01b81526004016122f4939291906137d2565b5f604051808303818588803b15801561230b575f5ffd5b505af115801561231d573d5f5f3e3d5ffd5b5050505050826001600160a01b03167f1d12ec15be79d81c3d88430333a0e42a69e76048bb1cef558f26284c532938f483604051611ad091815260200190565b610f4e8133612d8f565b7f000000000000000000000000000000000000000000000000000000000000000090565b61239582826126e6565b8190610e9f576040516385658c5d60e01b8152600401610b7f9190613635565b5f6001600160e01b03198216637965db0b60e01b1480610e4957506301ffc9a760e01b6001600160e01b0319831614610e49565b7f000000000000000000000000000000000000000000000000000000000000000090565b6001600160a01b0382165f908152600180850160205260408220600301908290849081111561243e5761243e6137f5565b600181111561244f5761244f6137f5565b815260208101919091526040015f205460ff16949350505050565b5f5f612474612dba565b805490915060ff1680610e6257506001600160e01b031983165f90815260018201602052604090205460ff169392505050565b6001600160a01b0382165f90815260208490526040812060019160039091019083838111156124d8576124d86137f5565b60018111156124e9576124e96137f5565b81526020019081526020015f205f6101000a81548160ff021916908315150217905550816001600160a01b03167fce464916f830b40184232aa1ac2108cd5490353611394f813b4ba5b65d79331a82604051611ad09190613825565b6125566125506123e9565b82612c3f565b81906110135760405163b6f7e20b60e01b8152600401610b7f9190613635565b6001600160a01b0382165f90815260018085016020526040822060030190829084908111156125a7576125a76137f5565b60018111156125b8576125b86137f5565b81526020019081526020015f205f6101000a81548160ff021916908315150217905550816001600160a01b03167f78c53ca60cda52c4385b49b56e1267bbe1aa1f31bbab3c68abd3ac94bd0d283782604051611ad09190613825565b5f5f61261e612bf2565b90505f61262b8585612dde565b90508015610fcb575f85815260208390526040902061264a9085612e7f565b50949350505050565b5f5f61265d612bf2565b90505f61266a8585612e93565b90508015610fcb575f85815260208390526040902061264a9085612f0c565b5f6110138161235d565b600161269d612dba565b6001600160e01b0319929092165f90815260019092016020526040909120805460ff1916911515919091179055565b5f6126d5612dba565b805460ff1916911515919091179055565b6001600160a01b03165f908152602091909152604090205460ff1690565b306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016148061277457507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316612768612f20565b6001600160a01b031614155b15610fe45760405163703e46dd60e11b815260040160405180910390fd5b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa9250505080156127ec575060408051601f3d908101601f191682019092526127e9918101906136e9565b60015b61280b5781604051634c9c8ce360e01b8152600401610b7f9190613635565b5f5160206138775f395f51905f52811461283b57604051632a87526960e21b815260048101829052602401610b7f565b610e9f8383612f34565b6001600160a01b038181165f90815260208490526040902060010154163314611013576040516282b42960e81b815260040160405180910390fd5b610e9d84856001600160a01b03166323b872dd8686866040516024016128a89392919061371b565b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050612f89565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610fe45760405163703e46dd60e11b815260040160405180910390fd5b80546001600160a01b0316336001600160a01b031614610f4e576040516282b42960e81b815260040160405180910390fd5b61295f8282612c3f565b158190610e9f57604051631d2ea86560e01b8152600401610b7f9190613635565b6001600160a01b0382165f908152600184810160205260408220909160039091019083838111156129b3576129b36137f5565b60018111156129c4576129c46137f5565b81526020019081526020015f205f6101000a81548160ff021916908315150217905550816001600160a01b03167ff8eb1057d2af1a68108187f026676ece3d27deaeda5e8f633b1eb2fc8281f4a382604051611ad09190613825565b6001600160a01b0382165f90815260018085016020526040822090810154600282015491929091612a519083612d53565b612a5b90836137a6565b600184018590559050612a6e8185612d53565b612a7890856137a6565b600284015560408051838152602081018690526001600160a01b0387169133917f77bdd031f88d6817d965aa27479103530a015309d88ce87197f8113df2e5a544910160405180910390a3505050505050565b612ad6838383612d62565b15610e9f57604051631ee9080f60e01b815260040160405180910390fd5b610e9f83846001600160a01b031663a9059cbb85856040516024016128a89291906137b9565b5f612b236123e9565b90506001600160a01b038316612b615760405163eac0d38960e01b8152602060048201526002602482015261746f60f01b6044820152606401610b7f565b815f03612b8157604051631f2a200560e01b815260040160405180910390fd5b612b8a84612545565b612b9681856001612fec565b612ba1818584612ff7565b6001600160a01b0384165f90815260018201602052604081206002018054849290612bcd9084906137a6565b90915550610e9d90506001600160a01b038516333085612880565b60016126d5612dba565b7fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e8237170593200090565b5f610e62838361305a565b5f612c2a612dba565b5460ff16919050565b60605f610e6283613080565b6001600160a01b03165f908152600191909101602052604090205460ff1690565b6001600160a01b0382165f90815260208490526040812060030181836001811115612c8d57612c8d6137f5565b6001811115612c9e57612c9e6137f5565b81526020019081526020015f205f6101000a81548160ff021916908315150217905550816001600160a01b03167f97a72046f05d63620e0cd6704ffe79ad8d369ecba6758345d740df92c47e948d82604051611ad09190613825565b612d0482826126e6565b158190610e9f57604051632fa60d0d60e01b8152600401610b7f9190613635565b5f61269d612dba565b5f612d37612dba565b805460ff1916905550565b610fe46130d9565b5f610e49825490565b5f828218828410028218610e62565b6001600160a01b0382165f9081526020849052604081206003018183600181111561243e5761243e6137f5565b612d998282611721565b61101357808260405163e2517d3f60e01b8152600401610b7f9291906137b9565b7f000000000000000000000000000000000000000000000000000000000000000090565b5f5f5160206138975f395f51905f52612df78484611721565b612e76575f848152602082815260408083206001600160a01b03871684529091529020805460ff19166001179055612e2c3390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001915050610e49565b5f915050610e49565b5f610e62836001600160a01b038416613122565b5f5f5160206138975f395f51905f52612eac8484611721565b15612e76575f848152602082815260408083206001600160a01b0387168085529252808320805460ff1916905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a46001915050610e49565b5f610e62836001600160a01b03841661316e565b5f5f5160206138775f395f51905f52611792565b612f3d82613248565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a2805115612f8157610e9f82826132a2565b61101361330b565b5f5f60205f8451602086015f885af180612fa8576040513d5f823e3d81fd5b50505f513d91508115612fbf578060011415612fcc565b6001600160a01b0384163b155b15610e9d5783604051635274afe760e01b8152600401610b7f9190613635565b612ad683838361240d565b6001600160a01b0382165f9081526001840160205260409020600201548282828181101561305157604051631f672d5f60e01b81526001600160a01b03909316600484015260248301919091526044820152606401610b7f565b50505050505050565b5f825f01828154811061306f5761306f613838565b905f5260205f200154905092915050565b6060815f018054806020026020016040519081016040528092919081815260200182805480156130cd57602002820191905f5260205f20905b8154815260200190600101908083116130b9575b50505050509050919050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff16610fe457604051631afcd79f60e31b815260040160405180910390fd5b5f81815260018301602052604081205461316757508154600181810184555f848152602080822090930184905584548482528286019093526040902091909155610e49565b505f610e49565b5f8181526001830160205260408120548015612e76575f6131906001836137a6565b85549091505f906131a3906001906137a6565b9050808214613202575f865f0182815481106131c1576131c1613838565b905f5260205f200154905080875f0184815481106131e1576131e1613838565b5f918252602080832090910192909255918252600188019052604090208390555b85548690806132135761321361384c565b600190038181905f5260205f20015f90559055856001015f8681526020019081526020015f205f905560019350505050610e49565b806001600160a01b03163b5f036132745780604051634c9c8ce360e01b8152600401610b7f9190613635565b5f5160206138775f395f51905f5280546001600160a01b0319166001600160a01b0392909216919091179055565b60605f5f846001600160a01b0316846040516132be9190613860565b5f60405180830381855af49150503d805f81146132f6576040519150601f19603f3d011682016040523d82523d5f602084013e6132fb565b606091505b509150915061134d85838361332a565b3415610fe45760405163b398979f60e01b815260040160405180910390fd5b60608261333f5761333a8261337d565b610e62565b815115801561335657506001600160a01b0384163b155b156133765783604051639996b31560e01b8152600401610b7f9190613635565b5080610e62565b80511561338d5780518082602001fd5b60405163d6bda27560e01b815260040160405180910390fd5b6001600160a01b0381168114610f4e575f5ffd5b5f5f604083850312156133cb575f5ffd5b82356133d6816133a6565b915060208301356133e6816133a6565b809150509250929050565b5f60208284031215613401575f5ffd5b81356001600160e01b031981168114610e62575f5ffd5b60028110610f4e575f5ffd5b5f5f60408385031215613435575f5ffd5b8235613440816133a6565b915060208301356133e681613418565b5f60208284031215613460575f5ffd5b5035919050565b5f5f60408385031215613478575f5ffd5b8235915060208301356133e6816133a6565b5f5f5f6060848603121561349c575f5ffd5b83356134a7816133a6565b925060208401356134b7816133a6565b929592945050506040919091013590565b5f602082840312156134d8575f5ffd5b8135610e62816133a6565b634e487b7160e01b5f52604160045260245ffd5b5f5f60408385031215613508575f5ffd5b8235613513816133a6565b9150602083013567ffffffffffffffff81111561352e575f5ffd5b8301601f8101851361353e575f5ffd5b803567ffffffffffffffff811115613558576135586134e3565b604051601f8201601f19908116603f0116810167ffffffffffffffff81118282101715613587576135876134e3565b60405281815282820160200187101561359e575f5ffd5b816020840160208301375f602083830101528093505050509250929050565b5f5f604083850312156135ce575f5ffd5b82356135d9816133a6565b946020939093013593505050565b5f5f5f5f608085870312156135fa575f5ffd5b8435613605816133a6565b93506020850135613615816133a6565b92506040850135613625816133a6565b9396929550929360600135925050565b6001600160a01b0391909116815260200190565b5f5f6040838503121561365a575f5ffd5b50508035926020909101359150565b602080825282518282018190525f918401906040840190835b818110156136a95783516001600160a01b0316835260209384019390920191600101613682565b509095945050505050565b602081525f82518060208401528060208501604085015e5f604082850101526040601f19601f83011684010191505092915050565b5f602082840312156136f9575f5ffd5b5051919050565b5f60208284031215613710575f5ffd5b8151610e62816133a6565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160e01b031991909116815260200190565b634e487b7160e01b5f52601160045260245ffd5b80820180821115610e4957610e49613754565b6001600160a01b03948516815292841660208401526040830191909152909116606082015260800190565b81810381811115610e4957610e49613754565b6001600160a01b03929092168252602082015260400190565b6001600160a01b0393841681526020810192909252909116604082015260600190565b634e487b7160e01b5f52602160045260245ffd5b60028110610f4e57634e487b7160e01b5f52602160045260245ffd5b6020810161383283613809565b91905290565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52603160045260245ffd5b5f82518060208501845e5f92019182525091905056fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b62680034663661313561303835346362316462333462613763636331316161363165316637633133626163a2646970667358221220de6fd3dfd6a65317219953733f297ea828911a37e2fdeb833d0bee9d657661f664736f6c634300081e00336d69746f7369732e73746f726167652e4d69746f7369735661756c742e564c462e76316d69746f7369732e73746f726167652e4d69746f7369735661756c7453746f726167652e7631
Deployed Bytecode
0x608060405260043610610309575f3560e01c806391d14854116101a0578063bf779f1d116100f1578063d547741f1161009f578063ee5125171161006e578063ee512517146109b0578063f25582fd146109cf578063f4164f01146109e2578063f8688b16146109f557610327565b8063d547741f14610934578063d86f0de314610953578063d9caed1214610972578063e162a1b41461099157610327565b8063bf779f1d14610867578063c035a68014610886578063c0b0e776146108a5578063c4d66de8146108c4578063c794b913146108e3578063ca15c873146108f6578063ce9aadf51461091557610327565b8063ad3cb1cc1161014e578063ad3cb1cc14610769578063b0f407da146107a6578063b175eb4d146107c5578063b39d5e10146107f6578063b83fd9ff14610815578063b8a15e3a14610834578063bac1e94b1461084857610327565b806391d14854146106a557806393a9ec75146106c4578063a217fddf146106d8578063a3246ad3146106eb578063a65d69d414610717578063a6f77f961461072b578063a71f26011461074a57610327565b80634f1ef2861161025a57806368b8fc1f1161020857806368b8fc1f146105d657806380ad2cf3146105f557806382fb069a146106145780638340f549146106335780638456cb591461064657806384fde5351461065a5780639010d07c1461068657610327565b80634f1ef2861461052057806350b99f5d1461053357806352d1902d1461055257806359fd2f89146105665780635b9a0e19146105795780635bbcc9081461059857806366a0cce9146105b757610327565b8063248a9ca3116102b7578063248a9ca3146104525780632f2ff15d1461047157806336568abe146104905780633aa83ec7146104af5780633c57dd5d146104ce5780633f4ba83a146104ed57806347c8fb5a1461050157610327565b806301a1c8ae1461034057806301ffc9a7146103615780630548c04f1461039557806309b65e66146103b45780630ab9b17d146103d35780631b150a6f146103f2578063242f05511461041157610327565b3661032757604051630280e1e560e61b815260040160405180910390fd5b604051630280e1e560e61b815260040160405180910390fd5b34801561034b575f5ffd5b5061035f61035a3660046133ba565b610a08565b005b34801561036c575f5ffd5b5061038061037b3660046133f1565b610e25565b60405190151581526020015b60405180910390f35b3480156103a0575f5ffd5b506103806103af366004613424565b610e4f565b3480156103bf575f5ffd5b506103806103ce3660046133f1565b610e69565b3480156103de575f5ffd5b5061035f6103ed366004613424565b610e73565b3480156103fd575f5ffd5b5061035f61040c366004613424565b610ea4565b34801561041c575f5ffd5b506104447f77e60b99a50d27fb027f6912a507d956105b4148adab27a86d235c8bcca8fa2f81565b60405190815260200161038c565b34801561045d575f5ffd5b5061044461046c366004613450565b610ecd565b34801561047c575f5ffd5b5061035f61048b366004613467565b610eed565b34801561049b575f5ffd5b5061035f6104aa366004613467565b610f09565b3480156104ba575f5ffd5b5061035f6104c93660046133f1565b610f3c565b3480156104d9575f5ffd5b506104446104e836600461348a565b610f51565b3480156104f8575f5ffd5b5061035f610fd3565b34801561050c575f5ffd5b5061038061051b3660046134c8565b610fe6565b61035f61052e3660046134f7565b610ff8565b34801561053e575f5ffd5b5061035f61054d3660046135bd565b611017565b34801561055d575f5ffd5b50610444611115565b61035f61057436600461348a565b611130565b348015610584575f5ffd5b506104446105933660046135e7565b6112c3565b3480156105a3575f5ffd5b5061035f6105b23660046134c8565b611356565b3480156105c2575f5ffd5b5061035f6105d1366004613424565b61141e565b3480156105e1575f5ffd5b506104446105f03660046134c8565b611447565b348015610600575f5ffd5b5061035f61060f3660046135bd565b611474565b34801561061f575f5ffd5b5061035f61062e3660046135bd565b6114bd565b61035f61064136600461348a565b6115b8565b348015610651575f5ffd5b5061035f6116be565b348015610665575f5ffd5b506106796106743660046134c8565b6116cf565b60405161038c9190613635565b348015610691575f5ffd5b506106796106a0366004613649565b6116fd565b3480156106b0575f5ffd5b506103806106bf366004613467565b611721565b3480156106cf575f5ffd5b50610380611757565b3480156106e3575f5ffd5b506104445f81565b3480156106f6575f5ffd5b5061070a610705366004613450565b611765565b60405161038c9190613669565b348015610722575f5ffd5b50610679611789565b348015610736575f5ffd5b506103806107453660046134c8565b6117a1565b348015610755575f5ffd5b506104446107643660046134c8565b6117b3565b348015610774575f5ffd5b50610799604051806040016040528060058152602001640352e302e360dc1b81525081565b60405161038c91906136b4565b3480156107b1575f5ffd5b5061035f6107c0366004613424565b6117e0565b3480156107d0575f5ffd5b5061079960405180604001604052806006815260200165076312e312e360d41b81525081565b348015610801575f5ffd5b5061035f6108103660046133ba565b61180a565b348015610820575f5ffd5b5061044461082f3660046135bd565b61190a565b34801561083f575f5ffd5b5061079961197f565b348015610853575f5ffd5b5061035f6108623660046133f1565b61199b565b348015610872575f5ffd5b5061044461088136600461348a565b6119ad565b348015610891575f5ffd5b5061035f6108a03660046135bd565b6119e5565b3480156108b0575f5ffd5b506104446108bf3660046135bd565b611add565b3480156108cf575f5ffd5b5061035f6108de3660046134c8565b611b13565b61035f6108f13660046135e7565b611c43565b348015610901575f5ffd5b50610444610910366004613450565b611dea565b348015610920575f5ffd5b5061044461092f3660046134c8565b611e0d565b34801561093f575f5ffd5b5061035f61094e366004613467565b611e37565b34801561095e575f5ffd5b5061044461096d3660046135bd565b611e53565b34801561097d575f5ffd5b5061035f61098c36600461348a565b611e89565b34801561099c575f5ffd5b506103806109ab366004613424565b611faa565b3480156109bb575f5ffd5b5061035f6109ca3660046134c8565b611fbd565b61035f6109dd3660046135bd565b61202a565b61035f6109f03660046135bd565b61212b565b61035f610a033660046135bd565b61225c565b5f610a128161235d565b5f610a1b612367565b6001600160a01b0385165f908152602082905260409020909150610a3f828661238b565b60018101546001600160a01b031615610b8c5760018101546040805163ad7a672f60e01b815290515f926001600160a01b03169163ad7a672f9160048083019260209291908290030181865afa158015610a9b573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610abf91906136e9565b158015610b3f5750816001015f9054906101000a90046001600160a01b03166001600160a01b03166350dcefc56040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b19573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610b3d91906136e9565b155b600183015490915086906001600160a01b031682610b8857604051635cb4c20560e11b81526001600160a01b039283166004820152911660248201526044015b60405180910390fd5b5050505b836001600160a01b03166345cbdf856040518163ffffffff1660e01b8152600401602060405180830381865afa158015610bc8573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610bec9190613700565b6001600160a01b0316856001600160a01b031614610c4d576040516356e22f5760e11b815260206004820152601f60248201527f564c4653747261746567794578656375746f722e687562564c465661756c74006044820152606401610b7f565b836001600160a01b031663fbfa77cf6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c89573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610cad9190613700565b6001600160a01b0316306001600160a01b031614610d0e57604051630b0f5aa160e11b815260206004820152601960248201527f564c4653747261746567794578656375746f722e7661756c74000000000000006044820152606401610b7f565b836001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d4a573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d6e9190613700565b815461010090046001600160a01b03908116911614610dd057604051630b0f5aa160e11b815260206004820152601960248201527f564c4653747261746567794578656375746f722e6173736574000000000000006044820152606401610b7f565b6001810180546001600160a01b0319166001600160a01b0386811691821790925560405190918716907fe33c4a07b426a165492de4c99e8c0aaf12a7e2f4d7e9ecddd951f3a8b94e292d905f90a35050505050565b5f6001600160e01b03198216635a05180f60e01b1480610e495750610e49826123b5565b92915050565b5f610e62610e5b6123e9565b848461240d565b9392505050565b5f610e498261246a565b5f610e7d8161235d565b5f610e86612367565b9050610e92818561238b565b610e9d8185856124a7565b505b505050565b5f610eae8161235d565b5f610eb76123e9565b9050610ec284612545565b610e9d818585612576565b5f9081525f5160206138975f395f51905f52602052604090206001015490565b610ef682610ecd565b610eff8161235d565b610e9d8383612614565b6001600160a01b0381163314610f325760405163334bd91960e11b815260040160405180910390fd5b610e9f8282612653565b610f4533612689565b610f4e81612693565b50565b5f610f5a6123e9565b54604051633c57dd5d60e01b81526001600160a01b0390911690633c57dd5d90610f8c9087908790879060040161371b565b602060405180830381865afa158015610fa7573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610fcb91906136e9565b949350505050565b610fdc33612689565b610fe46126cc565b565b5f610e49610ff2612367565b836126e6565b611000612704565b61100982612689565b6110138282612792565b5050565b61102b5f356001600160e01b03191661246a565b155f356001600160e01b0319169061105757604051633dba50a160e11b8152600401610b7f919061373f565b505f611061612367565b905061106d818461238b565b6110778184612845565b6001600160a01b0383165f908152602082905260408120600281018054919285926110a3908490613768565b9091555050600181015481546110cc916001600160a01b03610100909204821691163086612880565b836001600160a01b03167fad7b770e4601b306bc5d9616605363bc5308982391b45586efb2a7e502e1432d8460405161110791815260200190565b60405180910390a250505050565b5f61111e6128da565b505f5160206138775f395f51905f5290565b6111445f356001600160e01b03191661246a565b155f356001600160e01b0319169061117057604051633dba50a160e11b8152600401610b7f919061373f565b505f61117a612367565b9050611186818561238b565b6111908185612845565b61119983612545565b6001600160a01b038085165f9081526020839052604090205461010090048116908416036111f357604051630b0f5aa160e11b81526020600482015260066024820152651c995dd85c9960d21b6044820152606401610b7f565b6112086001600160a01b038416333085612880565b611210611789565b6001600160a01b0316632b52cac534868686336040518663ffffffff1660e01b8152600401611242949392919061377b565b5f604051808303818588803b158015611259575f5ffd5b505af115801561126b573d5f5f3e3d5ffd5b5050505050826001600160a01b0316846001600160a01b03167fb4010c0e1f7bae6953fc6794cbfe3472778d7196ab26508e3ec87e3cc33a0ffd846040516112b591815260200190565b60405180910390a350505050565b5f6112cc611789565b604051635b9a0e1960e01b81526001600160a01b03878116600483015286811660248301528581166044830152606482018590529190911690635b9a0e1990608401602060405180830381865afa158015611329573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061134d91906136e9565b95945050505050565b61136a5f356001600160e01b03191661246a565b155f356001600160e01b0319169061139657604051633dba50a160e11b8152600401610b7f919061373f565b505f6113a06123e9565b90506113ab81612923565b6113b58183612955565b6001600160a01b0382165f9081526001828101602052604091829020805460ff19169091179055517f271b4511ff4aaef63080ee912e106daf4730d4103103ece6b8945b8f63ee02499061140a908490613635565b60405180910390a161101381836001612980565b5f6114288161235d565b5f6114316123e9565b905061143c84612545565b610e9d818585612980565b5f6114506123e9565b6001600160a01b039092165f90815260019283016020526040902090910154919050565b7f77e60b99a50d27fb027f6912a507d956105b4148adab27a86d235c8bcca8fa2f61149e8161235d565b5f6114a76123e9565b90506114b284612545565b610e9d818585612a20565b6114d15f356001600160e01b03191661246a565b155f356001600160e01b031916906114fd57604051633dba50a160e11b8152600401610b7f919061373f565b505f611507612367565b9050611513818461238b565b61151d8184612845565b61152981846001612acb565b6001600160a01b0383165f908152602082905260408120600281018054919285926115559084906137a6565b90915550506001810154815461157d916001600160a01b036101009092048216911685612af4565b836001600160a01b03167f71248be0fed002e6813a6fb135948440ac02c47bf6cb7740c49d192093e240fa8460405161110791815260200190565b6115cc5f356001600160e01b03191661246a565b155f356001600160e01b031916906115f857604051633dba50a160e11b8152600401610b7f919061373f565b50611604838383612b1a565b61160c611789565b6001600160a01b0316633bc1f1ed34858585336040518663ffffffff1660e01b815260040161163e949392919061377b565b5f604051808303818588803b158015611655575f5ffd5b505af1158015611667573d5f5f3e3d5ffd5b5050505050816001600160a01b0316836001600160a01b03167f8752a472e571a816aea92eec8dae9baf628e840f4929fbcc2d155e6233ff68a7836040516116b191815260200190565b60405180910390a3505050565b6116c733612689565b610fe4612be8565b5f6116d8612367565b6001600160a01b039283165f9081526020919091526040902060010154909116919050565b5f5f611707612bf2565b5f858152602082905260409020909150610fcb9084612c16565b5f9182525f5160206138975f395f51905f52602090815260408084206001600160a01b0393909316845291905290205460ff1690565b5f611760612c21565b905090565b60605f611770612bf2565b5f848152602082905260409020909150610e6290612c33565b5f6117926123e9565b546001600160a01b0316919050565b5f610e496117ad6123e9565b83612c3f565b5f6117bc6123e9565b6001600160a01b039092165f90815260019290920160205250604090206002015490565b5f6117ea8161235d565b5f6117f3612367565b90506117ff818561238b565b610e9d818585612c60565b61181e5f356001600160e01b03191661246a565b155f356001600160e01b0319169061184a57604051633dba50a160e11b8152600401610b7f919061373f565b5033611854611789565b6001600160a01b03161461187a576040516282b42960e81b815260040160405180910390fd5b5f611883612367565b905061188f8184612cfa565b61189882612545565b6001600160a01b038381165f8181526020848152604091829020805460016001600160a81b03199091166101009689169687021717905581519283528201929092527ffeaa4cbc48054e489f18778fdf9688fc858cc9232407b5774fc30247420975eb910160405180910390a1505050565b5f611913611789565b6001600160a01b031663b83fd9ff84846040518363ffffffff1660e01b81526004016119409291906137b9565b602060405180830381865afa15801561195b573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e6291906136e9565b6040518060600160405280602881526020016138b76028913981565b6119a433612689565b610f4e81612d25565b5f6119b6611789565b6001600160a01b031663bf779f1d8585856040518463ffffffff1660e01b8152600401610f8c9392919061371b565b6119f95f356001600160e01b03191661246a565b155f356001600160e01b03191690611a2557604051633dba50a160e11b8152600401610b7f919061373f565b5033611a2f611789565b6001600160a01b031614611a55576040516282b42960e81b815260040160405180910390fd5b5f611a5e612367565b9050611a6a818461238b565b6001600160a01b0383165f9081526020829052604081206002018054849290611a94908490613768565b90915550506040518281526001600160a01b038416907fb5b50a62d4e1cba9918f5958084ec018cbcc745d8b21a305684e8cbe69d5a0fe906020015b60405180910390a2505050565b5f611ae6611789565b6001600160a01b031663c0b0e77684846040518363ffffffff1660e01b81526004016119409291906137b9565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff16159067ffffffffffffffff165f81158015611b585750825b90505f8267ffffffffffffffff166001148015611b745750303b155b905081158015611b82575080155b15611ba05760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff191660011785558315611bca57845460ff60401b1916600160401b1785555b611bd2612d2e565b611bda612d42565b611be2612d42565b611bea612d42565b611bf45f87612614565b508315611c3b57845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b505050505050565b611c575f356001600160e01b03191661246a565b155f356001600160e01b03191690611c8357604051633dba50a160e11b8152600401610b7f919061373f565b50611c8f848483612b1a565b5f611c98612367565b9050611ca4818461238b565b6001600160a01b038381165f90815260208390526040902054849187916101009004811690821614611cfc5760405163666845bf60e11b81526001600160a01b03928316600482015291166024820152604401610b7f565b5050611d06611789565b6001600160a01b031663136cbbe234878787873360405160e088901b6001600160e01b03191681526001600160a01b039586166004820152938516602485015291841660448401526064830152909116608482015260a4015f604051808303818588803b158015611d75575f5ffd5b505af1158015611d87573d5f5f3e3d5ffd5b5050505050826001600160a01b0316846001600160a01b0316866001600160a01b03167ffb94a3cc1fb9fc8de6bcafbef31f0aecc14e2d9016aab073d72c8410aabe2ebf85604051611ddb91815260200190565b60405180910390a45050505050565b5f5f611df4612bf2565b5f848152602082905260409020909150610e6290612d4a565b5f611e16612367565b6001600160a01b039092165f90815260209290925250604090206002015490565b611e4082610ecd565b611e498161235d565b610e9d8383612653565b5f611e5c611789565b6001600160a01b031663d86f0de384846040518363ffffffff1660e01b81526004016119409291906137b9565b611e9d5f356001600160e01b03191661246a565b155f356001600160e01b03191690611ec957604051633dba50a160e11b8152600401610b7f919061373f565b505f611ed36123e9565b9050611ede81612923565b611ee784612545565b6001600160a01b0384165f908152600180830160205260409091206002810154910154611f1f918491611f1a91906137a6565b612d53565b6001600160a01b0385165f90815260018301602052604081206002018054909190611f4b908490613768565b90915550611f6590506001600160a01b0385168484612af4565b826001600160a01b0316846001600160a01b03167fd1c19fbcd4551a5edfb66d43d2e337c04837afda3482b42bdf569a8fccdae5fb846040516112b591815260200190565b5f610e62611fb6612367565b8484612d62565b5f611fc78161235d565b81611fd06123e9565b80546001600160a01b0319166001600160a01b03929092169190911790556040517f19801148c19aa672dbfd5937fc6fc37a80e7686a916c4d17c3050c009abb44c39061201e908490613635565b60405180910390a15050565b61203e5f356001600160e01b03191661246a565b155f356001600160e01b0319169061206a57604051633dba50a160e11b8152600401610b7f919061373f565b505f612074612367565b9050612080818461238b565b61208a8184612845565b612092611789565b6001600160a01b0316637850cef7348585336040518563ffffffff1660e01b81526004016120c2939291906137d2565b5f604051808303818588803b1580156120d9575f5ffd5b505af11580156120eb573d5f5f3e3d5ffd5b5050505050826001600160a01b03167fa42a17de83bab77c0db989620426811a993d7b5678130bc555414126ba83bcb083604051611ad091815260200190565b61213f5f356001600160e01b03191661246a565b155f356001600160e01b0319169061216b57604051633dba50a160e11b8152600401610b7f919061373f565b505f612175612367565b9050612181818461238b565b61218b8184612845565b6001600160a01b0383165f90815260208290526040812060020180548492906121b59084906137a6565b909155506121c39050611789565b6001600160a01b0316634b5e6762348585336040518563ffffffff1660e01b81526004016121f3939291906137d2565b5f604051808303818588803b15801561220a575f5ffd5b505af115801561221c573d5f5f3e3d5ffd5b5050505050826001600160a01b03167f704070690fc3d8d2bc7b3f7c20a0315c249e0e576107fd544ac4868aba173f7583604051611ad091815260200190565b6122705f356001600160e01b03191661246a565b155f356001600160e01b0319169061229c57604051633dba50a160e11b8152600401610b7f919061373f565b505f6122a6612367565b90506122b2818461238b565b6122bc8184612845565b6122c4611789565b6001600160a01b0316638bffca0a348585336040518563ffffffff1660e01b81526004016122f4939291906137d2565b5f604051808303818588803b15801561230b575f5ffd5b505af115801561231d573d5f5f3e3d5ffd5b5050505050826001600160a01b03167f1d12ec15be79d81c3d88430333a0e42a69e76048bb1cef558f26284c532938f483604051611ad091815260200190565b610f4e8133612d8f565b7f48c02e93c5611cb6f3452f3a15e71677de2e3fe970c6528c336f2140f4820b0090565b61239582826126e6565b8190610e9f576040516385658c5d60e01b8152600401610b7f9190613635565b5f6001600160e01b03198216637965db0b60e01b1480610e4957506301ffc9a760e01b6001600160e01b0319831614610e49565b7f2a1bdb3310ea01974b4680a4347f9f5fe1e2718cb545ba792b0b6d3da731320090565b6001600160a01b0382165f908152600180850160205260408220600301908290849081111561243e5761243e6137f5565b600181111561244f5761244f6137f5565b815260208101919091526040015f205460ff16949350505050565b5f5f612474612dba565b805490915060ff1680610e6257506001600160e01b031983165f90815260018201602052604090205460ff169392505050565b6001600160a01b0382165f90815260208490526040812060019160039091019083838111156124d8576124d86137f5565b60018111156124e9576124e96137f5565b81526020019081526020015f205f6101000a81548160ff021916908315150217905550816001600160a01b03167fce464916f830b40184232aa1ac2108cd5490353611394f813b4ba5b65d79331a82604051611ad09190613825565b6125566125506123e9565b82612c3f565b81906110135760405163b6f7e20b60e01b8152600401610b7f9190613635565b6001600160a01b0382165f90815260018085016020526040822060030190829084908111156125a7576125a76137f5565b60018111156125b8576125b86137f5565b81526020019081526020015f205f6101000a81548160ff021916908315150217905550816001600160a01b03167f78c53ca60cda52c4385b49b56e1267bbe1aa1f31bbab3c68abd3ac94bd0d283782604051611ad09190613825565b5f5f61261e612bf2565b90505f61262b8585612dde565b90508015610fcb575f85815260208390526040902061264a9085612e7f565b50949350505050565b5f5f61265d612bf2565b90505f61266a8585612e93565b90508015610fcb575f85815260208390526040902061264a9085612f0c565b5f6110138161235d565b600161269d612dba565b6001600160e01b0319929092165f90815260019092016020526040909120805460ff1916911515919091179055565b5f6126d5612dba565b805460ff1916911515919091179055565b6001600160a01b03165f908152602091909152604090205460ff1690565b306001600160a01b037f00000000000000000000000091cdd4e96ce835b98baa98c48b424ef427dab0ae16148061277457507f00000000000000000000000091cdd4e96ce835b98baa98c48b424ef427dab0ae6001600160a01b0316612768612f20565b6001600160a01b031614155b15610fe45760405163703e46dd60e11b815260040160405180910390fd5b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa9250505080156127ec575060408051601f3d908101601f191682019092526127e9918101906136e9565b60015b61280b5781604051634c9c8ce360e01b8152600401610b7f9190613635565b5f5160206138775f395f51905f52811461283b57604051632a87526960e21b815260048101829052602401610b7f565b610e9f8383612f34565b6001600160a01b038181165f90815260208490526040902060010154163314611013576040516282b42960e81b815260040160405180910390fd5b610e9d84856001600160a01b03166323b872dd8686866040516024016128a89392919061371b565b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050612f89565b306001600160a01b037f00000000000000000000000091cdd4e96ce835b98baa98c48b424ef427dab0ae1614610fe45760405163703e46dd60e11b815260040160405180910390fd5b80546001600160a01b0316336001600160a01b031614610f4e576040516282b42960e81b815260040160405180910390fd5b61295f8282612c3f565b158190610e9f57604051631d2ea86560e01b8152600401610b7f9190613635565b6001600160a01b0382165f908152600184810160205260408220909160039091019083838111156129b3576129b36137f5565b60018111156129c4576129c46137f5565b81526020019081526020015f205f6101000a81548160ff021916908315150217905550816001600160a01b03167ff8eb1057d2af1a68108187f026676ece3d27deaeda5e8f633b1eb2fc8281f4a382604051611ad09190613825565b6001600160a01b0382165f90815260018085016020526040822090810154600282015491929091612a519083612d53565b612a5b90836137a6565b600184018590559050612a6e8185612d53565b612a7890856137a6565b600284015560408051838152602081018690526001600160a01b0387169133917f77bdd031f88d6817d965aa27479103530a015309d88ce87197f8113df2e5a544910160405180910390a3505050505050565b612ad6838383612d62565b15610e9f57604051631ee9080f60e01b815260040160405180910390fd5b610e9f83846001600160a01b031663a9059cbb85856040516024016128a89291906137b9565b5f612b236123e9565b90506001600160a01b038316612b615760405163eac0d38960e01b8152602060048201526002602482015261746f60f01b6044820152606401610b7f565b815f03612b8157604051631f2a200560e01b815260040160405180910390fd5b612b8a84612545565b612b9681856001612fec565b612ba1818584612ff7565b6001600160a01b0384165f90815260018201602052604081206002018054849290612bcd9084906137a6565b90915550610e9d90506001600160a01b038516333085612880565b60016126d5612dba565b7fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e8237170593200090565b5f610e62838361305a565b5f612c2a612dba565b5460ff16919050565b60605f610e6283613080565b6001600160a01b03165f908152600191909101602052604090205460ff1690565b6001600160a01b0382165f90815260208490526040812060030181836001811115612c8d57612c8d6137f5565b6001811115612c9e57612c9e6137f5565b81526020019081526020015f205f6101000a81548160ff021916908315150217905550816001600160a01b03167f97a72046f05d63620e0cd6704ffe79ad8d369ecba6758345d740df92c47e948d82604051611ad09190613825565b612d0482826126e6565b158190610e9f57604051632fa60d0d60e01b8152600401610b7f9190613635565b5f61269d612dba565b5f612d37612dba565b805460ff1916905550565b610fe46130d9565b5f610e49825490565b5f828218828410028218610e62565b6001600160a01b0382165f9081526020849052604081206003018183600181111561243e5761243e6137f5565b612d998282611721565b61101357808260405163e2517d3f60e01b8152600401610b7f9291906137b9565b7f582977cdeb9b6be2e2a29b3d4fca6da72f5834abc9644d4ffc634612bd49c00090565b5f5f5160206138975f395f51905f52612df78484611721565b612e76575f848152602082815260408083206001600160a01b03871684529091529020805460ff19166001179055612e2c3390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001915050610e49565b5f915050610e49565b5f610e62836001600160a01b038416613122565b5f5f5160206138975f395f51905f52612eac8484611721565b15612e76575f848152602082815260408083206001600160a01b0387168085529252808320805460ff1916905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a46001915050610e49565b5f610e62836001600160a01b03841661316e565b5f5f5160206138775f395f51905f52611792565b612f3d82613248565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a2805115612f8157610e9f82826132a2565b61101361330b565b5f5f60205f8451602086015f885af180612fa8576040513d5f823e3d81fd5b50505f513d91508115612fbf578060011415612fcc565b6001600160a01b0384163b155b15610e9d5783604051635274afe760e01b8152600401610b7f9190613635565b612ad683838361240d565b6001600160a01b0382165f9081526001840160205260409020600201548282828181101561305157604051631f672d5f60e01b81526001600160a01b03909316600484015260248301919091526044820152606401610b7f565b50505050505050565b5f825f01828154811061306f5761306f613838565b905f5260205f200154905092915050565b6060815f018054806020026020016040519081016040528092919081815260200182805480156130cd57602002820191905f5260205f20905b8154815260200190600101908083116130b9575b50505050509050919050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff16610fe457604051631afcd79f60e31b815260040160405180910390fd5b5f81815260018301602052604081205461316757508154600181810184555f848152602080822090930184905584548482528286019093526040902091909155610e49565b505f610e49565b5f8181526001830160205260408120548015612e76575f6131906001836137a6565b85549091505f906131a3906001906137a6565b9050808214613202575f865f0182815481106131c1576131c1613838565b905f5260205f200154905080875f0184815481106131e1576131e1613838565b5f918252602080832090910192909255918252600188019052604090208390555b85548690806132135761321361384c565b600190038181905f5260205f20015f90559055856001015f8681526020019081526020015f205f905560019350505050610e49565b806001600160a01b03163b5f036132745780604051634c9c8ce360e01b8152600401610b7f9190613635565b5f5160206138775f395f51905f5280546001600160a01b0319166001600160a01b0392909216919091179055565b60605f5f846001600160a01b0316846040516132be9190613860565b5f60405180830381855af49150503d805f81146132f6576040519150601f19603f3d011682016040523d82523d5f602084013e6132fb565b606091505b509150915061134d85838361332a565b3415610fe45760405163b398979f60e01b815260040160405180910390fd5b60608261333f5761333a8261337d565b610e62565b815115801561335657506001600160a01b0384163b155b156133765783604051639996b31560e01b8152600401610b7f9190613635565b5080610e62565b80511561338d5780518082602001fd5b60405163d6bda27560e01b815260040160405180910390fd5b6001600160a01b0381168114610f4e575f5ffd5b5f5f604083850312156133cb575f5ffd5b82356133d6816133a6565b915060208301356133e6816133a6565b809150509250929050565b5f60208284031215613401575f5ffd5b81356001600160e01b031981168114610e62575f5ffd5b60028110610f4e575f5ffd5b5f5f60408385031215613435575f5ffd5b8235613440816133a6565b915060208301356133e681613418565b5f60208284031215613460575f5ffd5b5035919050565b5f5f60408385031215613478575f5ffd5b8235915060208301356133e6816133a6565b5f5f5f6060848603121561349c575f5ffd5b83356134a7816133a6565b925060208401356134b7816133a6565b929592945050506040919091013590565b5f602082840312156134d8575f5ffd5b8135610e62816133a6565b634e487b7160e01b5f52604160045260245ffd5b5f5f60408385031215613508575f5ffd5b8235613513816133a6565b9150602083013567ffffffffffffffff81111561352e575f5ffd5b8301601f8101851361353e575f5ffd5b803567ffffffffffffffff811115613558576135586134e3565b604051601f8201601f19908116603f0116810167ffffffffffffffff81118282101715613587576135876134e3565b60405281815282820160200187101561359e575f5ffd5b816020840160208301375f602083830101528093505050509250929050565b5f5f604083850312156135ce575f5ffd5b82356135d9816133a6565b946020939093013593505050565b5f5f5f5f608085870312156135fa575f5ffd5b8435613605816133a6565b93506020850135613615816133a6565b92506040850135613625816133a6565b9396929550929360600135925050565b6001600160a01b0391909116815260200190565b5f5f6040838503121561365a575f5ffd5b50508035926020909101359150565b602080825282518282018190525f918401906040840190835b818110156136a95783516001600160a01b0316835260209384019390920191600101613682565b509095945050505050565b602081525f82518060208401528060208501604085015e5f604082850101526040601f19601f83011684010191505092915050565b5f602082840312156136f9575f5ffd5b5051919050565b5f60208284031215613710575f5ffd5b8151610e62816133a6565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160e01b031991909116815260200190565b634e487b7160e01b5f52601160045260245ffd5b80820180821115610e4957610e49613754565b6001600160a01b03948516815292841660208401526040830191909152909116606082015260800190565b81810381811115610e4957610e49613754565b6001600160a01b03929092168252602082015260400190565b6001600160a01b0393841681526020810192909252909116604082015260600190565b634e487b7160e01b5f52602160045260245ffd5b60028110610f4e57634e487b7160e01b5f52602160045260245ffd5b6020810161383283613809565b91905290565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52603160045260245ffd5b5f82518060208501845e5f92019182525091905056fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b62680034663661313561303835346362316462333462613763636331316161363165316637633133626163a2646970667358221220de6fd3dfd6a65317219953733f297ea828911a37e2fdeb833d0bee9d657661f664736f6c634300081e0033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
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.