Source Code
Overview
MON Balance
MON Value
$0.00| Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
Latest 1 internal transaction
Advanced mode:
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 37060031 | 67 days ago | Contract Creation | 0 MON |
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:
Vault
Compiler Version
v0.8.25+commit.b61c2a91
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.25;
import "../interfaces/factories/IFactoryEntity.sol";
import "../modules/ACLModule.sol";
import "../modules/ShareModule.sol";
import "../modules/VaultModule.sol";
contract Vault is IFactoryEntity, VaultModule, ShareModule {
struct RoleHolder {
bytes32 role;
address holder;
}
constructor(
string memory name_,
uint256 version_,
address depositQueueFactory_,
address redeemQueueFactory_,
address subvaultFactory_,
address verifierFactory_
)
ACLModule(name_, version_)
ShareModule(name_, version_, depositQueueFactory_, redeemQueueFactory_)
VaultModule(name_, version_, subvaultFactory_, verifierFactory_)
{}
function initialize(bytes calldata initParams) external initializer {
{
(
address admin_,
address shareManager_,
address feeManager_,
address riskManager_,
address oracle_,
address defaultDepositHook_,
address defaultRedeemHook_,
uint256 queueLimit_,
RoleHolder[] memory roleHolders
) = abi.decode(
initParams, (address, address, address, address, address, address, address, uint256, RoleHolder[])
);
__BaseModule_init();
__ACLModule_init(admin_);
__ShareModule_init(
shareManager_, feeManager_, oracle_, defaultDepositHook_, defaultRedeemHook_, queueLimit_
);
__VaultModule_init(riskManager_);
for (uint256 i = 0; i < roleHolders.length; i++) {
_grantRole(roleHolders[i].role, roleHolders[i].holder);
}
}
emit Initialized(initParams);
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.25;
/// @title IFactoryEntity
interface IFactoryEntity {
/// @notice Initializes the factory-created entity with arbitrary initialization data.
/// @param initParams The initialization parameters.
function initialize(bytes calldata initParams) external;
/// @notice Emitted once the entity has been initialized.
/// @param initParams The initialization parameters.
event Initialized(bytes initParams);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.25;
import "../interfaces/modules/IACLModule.sol";
import "../libraries/SlotLibrary.sol";
import "../permissions/MellowACL.sol";
import "./BaseModule.sol";
abstract contract ACLModule is IACLModule, BaseModule, MellowACL {
constructor(string memory name_, uint256 version_) MellowACL(name_, version_) {}
// Internal functions
function __ACLModule_init(address admin_) internal onlyInitializing {
if (admin_ == address(0)) {
revert ZeroAddress();
}
_grantRole(DEFAULT_ADMIN_ROLE, admin_);
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.25;
import "../interfaces/modules/IShareModule.sol";
import "../libraries/SlotLibrary.sol";
import "../libraries/TransferLibrary.sol";
import "./ACLModule.sol";
abstract contract ShareModule is IShareModule, ACLModule {
using EnumerableSet for EnumerableSet.AddressSet;
/// @inheritdoc IShareModule
bytes32 public constant SET_HOOK_ROLE = keccak256("modules.ShareModule.SET_HOOK_ROLE");
/// @inheritdoc IShareModule
bytes32 public constant CREATE_QUEUE_ROLE = keccak256("modules.ShareModule.CREATE_QUEUE_ROLE");
/// @inheritdoc IShareModule
bytes32 public constant SET_QUEUE_STATUS_ROLE = keccak256("modules.ShareModule.SET_QUEUE_STATUS_ROLE");
/// @inheritdoc IShareModule
bytes32 public constant SET_QUEUE_LIMIT_ROLE = keccak256("modules.ShareModule.SET_QUEUE_LIMIT_ROLE");
/// @inheritdoc IShareModule
bytes32 public constant REMOVE_QUEUE_ROLE = keccak256("modules.ShareModule.REMOVE_QUEUE_ROLE");
/// @inheritdoc IShareModule
IFactory public immutable depositQueueFactory;
/// @inheritdoc IShareModule
IFactory public immutable redeemQueueFactory;
bytes32 private immutable _shareModuleStorageSlot;
constructor(string memory name_, uint256 version_, address depositQueueFactory_, address redeemQueueFactory_) {
_shareModuleStorageSlot = SlotLibrary.getSlot("ShareModule", name_, version_);
depositQueueFactory = IFactory(depositQueueFactory_);
redeemQueueFactory = IFactory(redeemQueueFactory_);
}
// View functions
/// @inheritdoc IShareModule
function shareManager() public view returns (IShareManager) {
return IShareManager(_shareModuleStorage().shareManager);
}
/// @inheritdoc IShareModule
function feeManager() public view returns (IFeeManager) {
return IFeeManager(_shareModuleStorage().feeManager);
}
/// @inheritdoc IShareModule
function oracle() public view returns (IOracle) {
return IOracle(_shareModuleStorage().oracle);
}
/// @inheritdoc IShareModule
function hasQueue(address queue) public view returns (bool) {
return _shareModuleStorage().queues[IQueue(queue).asset()].contains(queue);
}
/// @inheritdoc IShareModule
function getAssetCount() public view returns (uint256) {
return _shareModuleStorage().assets.length();
}
/// @inheritdoc IShareModule
function assetAt(uint256 index) public view returns (address) {
return _shareModuleStorage().assets.at(index);
}
/// @inheritdoc IShareModule
function hasAsset(address asset) public view returns (bool) {
return _shareModuleStorage().assets.contains(asset);
}
/// @inheritdoc IShareModule
function queueAt(address asset, uint256 index) public view returns (address) {
return _shareModuleStorage().queues[asset].at(index);
}
/// @inheritdoc IShareModule
function getQueueCount() public view returns (uint256) {
return _shareModuleStorage().queueCount;
}
/// @inheritdoc IShareModule
function getQueueCount(address asset) public view returns (uint256) {
return _shareModuleStorage().queues[asset].length();
}
/// @inheritdoc IShareModule
function queueLimit() public view returns (uint256) {
return _shareModuleStorage().queueLimit;
}
/// @inheritdoc IShareModule
function isDepositQueue(address queue) public view returns (bool) {
return _shareModuleStorage().isDepositQueue[queue];
}
/// @inheritdoc IShareModule
function isPausedQueue(address queue) public view returns (bool) {
return _shareModuleStorage().isPausedQueue[queue];
}
/// @inheritdoc IShareModule
function defaultDepositHook() public view returns (address) {
return _shareModuleStorage().defaultDepositHook;
}
/// @inheritdoc IShareModule
function defaultRedeemHook() public view returns (address) {
return _shareModuleStorage().defaultRedeemHook;
}
/// @inheritdoc IShareModule
function claimableSharesOf(address account) public view returns (uint256 shares) {
ShareModuleStorage storage $ = _shareModuleStorage();
EnumerableSet.AddressSet storage assets = $.assets;
uint256 assetsCount = assets.length();
for (uint256 i = 0; i < assetsCount; i++) {
address asset = assets.at(i);
EnumerableSet.AddressSet storage queues = $.queues[asset];
uint256 queuesCount = queues.length();
for (uint256 j = 0; j < queuesCount; j++) {
address queue = queues.at(j);
if ($.isDepositQueue[queue]) {
shares += IDepositQueue(queue).claimableOf(account);
}
}
}
return shares;
}
/// @inheritdoc IShareModule
function getHook(address queue) public view returns (address) {
ShareModuleStorage storage $ = _shareModuleStorage();
address hook = $.customHooks[queue];
return hook != address(0) ? hook : $.isDepositQueue[queue] ? $.defaultDepositHook : $.defaultRedeemHook;
}
/// @inheritdoc IShareModule
function getLiquidAssets() public view returns (uint256) {
address queue = _msgSender();
address asset = IQueue(queue).asset();
ShareModuleStorage storage $ = _shareModuleStorage();
if (!$.queues[asset].contains(queue) || $.isDepositQueue[queue]) {
revert Forbidden();
}
address hook = getHook(queue);
if (hook == address(0)) {
return TransferLibrary.balanceOf(asset, address(this));
}
return IRedeemHook(hook).getLiquidAssets(asset);
}
// Mutable functions
/// @inheritdoc IShareModule
function setCustomHook(address queue, address hook) external onlyRole(SET_HOOK_ROLE) {
if (queue == address(0)) {
revert ZeroAddress();
}
_shareModuleStorage().customHooks[queue] = hook;
emit CustomHookSet(queue, hook);
}
/// @inheritdoc IShareModule
function setDefaultDepositHook(address hook) external onlyRole(SET_HOOK_ROLE) {
_shareModuleStorage().defaultDepositHook = hook;
emit DefaultHookSet(hook, true);
}
/// @inheritdoc IShareModule
function setDefaultRedeemHook(address hook) external onlyRole(SET_HOOK_ROLE) {
_shareModuleStorage().defaultRedeemHook = hook;
emit DefaultHookSet(hook, false);
}
/// @inheritdoc IShareModule
function setQueueLimit(uint256 limit) external onlyRole(SET_QUEUE_LIMIT_ROLE) {
_shareModuleStorage().queueLimit = limit;
emit QueueLimitSet(limit);
}
/// @inheritdoc IShareModule
function setQueueStatus(address queue, bool isPaused) external onlyRole(SET_QUEUE_STATUS_ROLE) {
if (!hasQueue(queue)) {
revert Forbidden();
}
_shareModuleStorage().isPausedQueue[queue] = isPaused;
emit SetQueueStatus(queue, isPaused);
}
/// @inheritdoc IShareModule
function createQueue(uint256 version, bool isDeposit, address owner, address asset, bytes calldata data)
external
nonReentrant
onlyRole(CREATE_QUEUE_ROLE)
{
ShareModuleStorage storage $ = _shareModuleStorage();
if (!IOracle($.oracle).isSupportedAsset(asset)) {
revert UnsupportedAsset(asset);
}
uint256 count = $.queueCount + 1;
if (count > $.queueLimit) {
revert QueueLimitReached();
}
address queue = (isDeposit ? depositQueueFactory : redeemQueueFactory).create(
version, owner, abi.encode(asset, address(this), data)
);
$.queueCount = count;
$.queues[asset].add(queue);
$.assets.add(asset);
$.isDepositQueue[queue] = isDeposit;
emit QueueCreated(queue, asset, isDeposit);
}
/// @inheritdoc IShareModule
function removeQueue(address queue) external onlyRole(REMOVE_QUEUE_ROLE) {
if (!IQueue(queue).canBeRemoved()) {
revert Forbidden();
}
address asset = IQueue(queue).asset();
ShareModuleStorage storage $ = _shareModuleStorage();
if (!$.queues[asset].remove(queue)) {
revert Forbidden();
}
delete $.isDepositQueue[queue];
if ($.queues[asset].length() == 0) {
$.assets.remove(asset);
}
delete $.customHooks[queue];
--$.queueCount;
emit QueueRemoved(queue, asset);
}
/// @inheritdoc IShareModule
function claimShares(address account) external {
ShareModuleStorage storage $ = _shareModuleStorage();
EnumerableSet.AddressSet storage assets = $.assets;
uint256 assetsCount = assets.length();
for (uint256 i = 0; i < assetsCount; i++) {
address asset = assets.at(i);
EnumerableSet.AddressSet storage queues = $.queues[asset];
uint256 queuesCount = queues.length();
for (uint256 j = 0; j < queuesCount; j++) {
address queue = queues.at(j);
if ($.isDepositQueue[queue]) {
IDepositQueue(queue).claim(account);
}
}
}
emit SharesClaimed(account);
}
/// @inheritdoc IShareModule
function callHook(uint256 assets) external {
address queue = _msgSender();
address asset = IQueue(queue).asset();
ShareModuleStorage storage $ = _shareModuleStorage();
if (!_shareModuleStorage().queues[asset].contains(queue)) {
revert Forbidden();
}
address hook = getHook(queue);
if (hook != address(0)) {
Address.functionDelegateCall(hook, abi.encodeCall(IHook.callHook, (asset, assets)));
}
if (!$.isDepositQueue[queue]) {
TransferLibrary.sendAssets(asset, queue, assets);
}
emit HookCalled(queue, asset, assets, hook);
}
/// @inheritdoc IShareModule
function handleReport(address asset, uint224 priceD18, uint32 depositTimestamp, uint32 redeemTimestamp)
external
nonReentrant
{
ShareModuleStorage storage $ = _shareModuleStorage();
if (_msgSender() != $.oracle) {
revert Forbidden();
}
IShareManager shareManager_ = IShareManager($.shareManager);
IFeeManager feeManager_ = IFeeManager($.feeManager);
uint256 fees;
if (asset == feeManager_.baseAsset(address(this))) {
address feeRecipient_ = feeManager_.feeRecipient();
fees = feeManager_.calculateFee(
address(this),
asset,
priceD18,
shareManager_.totalShares() - shareManager_.activeSharesOf(feeRecipient_)
);
if (fees != 0) {
shareManager_.mint(feeRecipient_, fees);
}
feeManager_.updateState(asset, priceD18);
}
EnumerableSet.AddressSet storage queues = _shareModuleStorage().queues[asset];
uint256 length = queues.length();
for (uint256 i = 0; i < length; i++) {
address queue = queues.at(i);
IQueue(queue).handleReport(priceD18, $.isDepositQueue[queue] ? depositTimestamp : redeemTimestamp);
}
emit ReportHandled(asset, priceD18, depositTimestamp, redeemTimestamp, fees);
}
// Internal functions
function __ShareModule_init(
address shareManager_,
address feeManager_,
address oracle_,
address defaultDepositHook_,
address defaultRedeemHook_,
uint256 queueLimit_
) internal onlyInitializing {
if (shareManager_ == address(0) || feeManager_ == address(0) || oracle_ == address(0)) {
revert ZeroAddress();
}
ShareModuleStorage storage $ = _shareModuleStorage();
$.shareManager = shareManager_;
$.feeManager = feeManager_;
$.oracle = oracle_;
$.defaultDepositHook = defaultDepositHook_;
$.defaultRedeemHook = defaultRedeemHook_;
$.queueLimit = queueLimit_;
}
function _shareModuleStorage() internal view returns (ShareModuleStorage storage $) {
bytes32 slot = _shareModuleStorageSlot;
assembly {
$.slot := slot
}
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.25;
import "../interfaces/modules/IVaultModule.sol";
import "../libraries/SlotLibrary.sol";
import "../libraries/TransferLibrary.sol";
import "./ACLModule.sol";
abstract contract VaultModule is IVaultModule, ACLModule {
using EnumerableSet for EnumerableSet.AddressSet;
/// @inheritdoc IVaultModule
bytes32 public constant CREATE_SUBVAULT_ROLE = keccak256("modules.VaultModule.CREATE_SUBVAULT_ROLE");
/// @inheritdoc IVaultModule
bytes32 public constant DISCONNECT_SUBVAULT_ROLE = keccak256("modules.VaultModule.DISCONNECT_SUBVAULT_ROLE");
/// @inheritdoc IVaultModule
bytes32 public constant RECONNECT_SUBVAULT_ROLE = keccak256("modules.VaultModule.RECONNECT_SUBVAULT_ROLE");
/// @inheritdoc IVaultModule
bytes32 public constant PULL_LIQUIDITY_ROLE = keccak256("modules.VaultModule.PULL_LIQUIDITY_ROLE");
/// @inheritdoc IVaultModule
bytes32 public constant PUSH_LIQUIDITY_ROLE = keccak256("modules.VaultModule.PUSH_LIQUIDITY_ROLE");
/// @inheritdoc IVaultModule
IFactory public immutable subvaultFactory;
/// @inheritdoc IVaultModule
IFactory public immutable verifierFactory;
bytes32 private immutable _subvaultModuleStorageSlot;
constructor(string memory name_, uint256 version_, address subvaultFactory_, address verifierFactory_) {
_subvaultModuleStorageSlot = SlotLibrary.getSlot("VaultModule", name_, version_);
subvaultFactory = IFactory(subvaultFactory_);
verifierFactory = IFactory(verifierFactory_);
}
// View functionss
/// @inheritdoc IVaultModule
function subvaults() public view returns (uint256) {
return _vaultStorage().subvaults.length();
}
/// @inheritdoc IVaultModule
function subvaultAt(uint256 index) public view returns (address) {
return _vaultStorage().subvaults.at(index);
}
/// @inheritdoc IVaultModule
function hasSubvault(address subvault) public view returns (bool) {
return _vaultStorage().subvaults.contains(subvault);
}
/// @inheritdoc IVaultModule
function riskManager() public view returns (IRiskManager) {
return IRiskManager(_vaultStorage().riskManager);
}
// Mutable functions
/// @inheritdoc IVaultModule
function createSubvault(uint256 version, address owner, address verifier)
external
onlyRole(CREATE_SUBVAULT_ROLE)
nonReentrant
returns (address subvault)
{
if (!verifierFactory.isEntity(verifier)) {
revert NotEntity(verifier);
}
if (address(IVerifier(verifier).vault()) != address(this)) {
revert Forbidden();
}
subvault = subvaultFactory.create(version, owner, abi.encode(verifier, address(this)));
_vaultStorage().subvaults.add(subvault);
emit SubvaultCreated(subvault, version, owner, verifier);
}
/// @inheritdoc IVaultModule
function disconnectSubvault(address subvault) external onlyRole(DISCONNECT_SUBVAULT_ROLE) {
VaultModuleStorage storage $ = _vaultStorage();
if (!$.subvaults.remove(subvault)) {
revert NotConnected(subvault);
}
emit SubvaultDisconnected(subvault);
}
/// @inheritdoc IVaultModule
function reconnectSubvault(address subvault) external onlyRole(RECONNECT_SUBVAULT_ROLE) {
VaultModuleStorage storage $ = _vaultStorage();
if (!subvaultFactory.isEntity(subvault)) {
revert NotEntity(subvault);
}
if (ISubvaultModule(subvault).vault() != address(this)) {
revert InvalidSubvault(subvault);
}
IVerifier verifier = IVerifierModule(subvault).verifier();
if (!verifierFactory.isEntity(address(verifier))) {
revert NotEntity(address(verifier));
}
if (address(verifier.vault()) != address(this)) {
revert Forbidden();
}
if (!$.subvaults.add(subvault)) {
revert AlreadyConnected(subvault);
}
emit SubvaultReconnected(subvault, address(verifier));
}
/// @inheritdoc IVaultModule
function pullAssets(address subvault, address asset, uint256 value)
external
onlyRole(PULL_LIQUIDITY_ROLE)
nonReentrant
{
_pullAssets(subvault, asset, value);
}
/// @inheritdoc IVaultModule
function pushAssets(address subvault, address asset, uint256 value)
external
onlyRole(PUSH_LIQUIDITY_ROLE)
nonReentrant
{
_pushAssets(subvault, asset, value);
}
/// @inheritdoc IVaultModule
function hookPullAssets(address subvault, address asset, uint256 value) external {
if (_msgSender() != address(this)) {
revert Forbidden();
}
_pullAssets(subvault, asset, value);
}
/// @inheritdoc IVaultModule
function hookPushAssets(address subvault, address asset, uint256 value) external {
if (_msgSender() != address(this)) {
revert Forbidden();
}
_pushAssets(subvault, asset, value);
}
// Internal functions
function _pullAssets(address subvault, address asset, uint256 value) internal {
riskManager().modifySubvaultBalance(subvault, asset, -int256(value));
ISubvaultModule(subvault).pullAssets(asset, value);
emit AssetsPulled(asset, subvault, value);
}
function _pushAssets(address subvault, address asset, uint256 value) internal {
riskManager().modifySubvaultBalance(subvault, asset, int256(value));
TransferLibrary.sendAssets(asset, subvault, value);
emit AssetsPushed(asset, subvault, value);
}
function __VaultModule_init(address riskManager_) internal onlyInitializing {
if (riskManager_ == address(0)) {
revert ZeroAddress();
}
_vaultStorage().riskManager = riskManager_;
}
function _vaultStorage() private view returns (VaultModuleStorage storage $) {
bytes32 slot = _subvaultModuleStorageSlot;
assembly {
$.slot := slot
}
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.25;
import "../permissions/IMellowACL.sol";
import "./IBaseModule.sol";
/// @notice Interface for the ACLModule, implements IMellowACL
interface IACLModule is IMellowACL {
/// @notice Thrown when a zero address is provided
error ZeroAddress();
/// @notice Thrown when an unauthorized caller attempts a restricted operation
error Forbidden();
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.25;
/// @title SlotLibrary
/// @notice Library for computing deterministic and collision-resistant storage slots
/// @dev Used to generate unique storage slots for upgradeable modules using string identifiers
library SlotLibrary {
/// @notice Computes a unique storage slot based on the module's identifiers
/// @param contractName Logical contract/module name (e.g., "ShareModule")
/// @param name Human-readable instance name (e.g., "Mellow")
/// @param version Version number for the module configuration
/// @return A bytes32 value representing the derived storage slot
function getSlot(string memory contractName, string memory name, uint256 version) internal pure returns (bytes32) {
return keccak256(
abi.encode(
uint256(keccak256(abi.encodePacked("mellow.flexible-vaults.storage.", contractName, name, version))) - 1
)
) & ~bytes32(uint256(0xff));
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.25;
import "../interfaces/permissions/IMellowACL.sol";
import "../libraries/SlotLibrary.sol";
abstract contract MellowACL is IMellowACL, AccessControlEnumerableUpgradeable {
using EnumerableSet for EnumerableSet.Bytes32Set;
bytes32 private immutable _mellowACLStorageSlot;
constructor(string memory name_, uint256 version_) {
_mellowACLStorageSlot = SlotLibrary.getSlot("MellowACL", name_, version_);
_disableInitializers();
}
// View functions
/// @inheritdoc IMellowACL
function supportedRoles() external view returns (uint256) {
return _mellowACLStorage().supportedRoles.length();
}
/// @inheritdoc IMellowACL
function supportedRoleAt(uint256 index) external view returns (bytes32) {
return _mellowACLStorage().supportedRoles.at(index);
}
/// @inheritdoc IMellowACL
function hasSupportedRole(bytes32 role) external view returns (bool) {
return _mellowACLStorage().supportedRoles.contains(role);
}
// Internal functions
function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {
if (super._grantRole(role, account)) {
if (_mellowACLStorage().supportedRoles.add(role)) {
emit RoleAdded(role);
}
return true;
}
return false;
}
function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {
if (super._revokeRole(role, account)) {
if (getRoleMemberCount(role) == 0) {
_mellowACLStorage().supportedRoles.remove(role);
emit RoleRemoved(role);
}
return true;
}
return false;
}
function _mellowACLStorage() private view returns (MellowACLStorage storage $) {
bytes32 slot = _mellowACLStorageSlot;
assembly {
$.slot := slot
}
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.25;
import "../interfaces/modules/IBaseModule.sol";
abstract contract BaseModule is IBaseModule, ContextUpgradeable, ReentrancyGuardUpgradeable {
constructor() {
_disableInitializers();
}
// View functions
/// @inheritdoc IBaseModule
function getStorageAt(bytes32 slot) external pure returns (StorageSlot.Bytes32Slot memory) {
return StorageSlot.getBytes32Slot(slot);
}
/// @inheritdoc IERC721Receiver
function onERC721Received(address, address, uint256, bytes calldata) external pure returns (bytes4) {
return IERC721Receiver.onERC721Received.selector;
}
// Mutable functions
receive() external payable {}
// Internal functions
function __BaseModule_init() internal onlyInitializing {
__ReentrancyGuard_init();
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.25;
import "../factories/IFactory.sol";
import "../hooks/IRedeemHook.sol";
import "../managers/IFeeManager.sol";
import "../managers/IShareManager.sol";
import "../oracles/IOracle.sol";
import "../queues/IDepositQueue.sol";
import "../queues/IQueue.sol";
import "../queues/IRedeemQueue.sol";
import "./IBaseModule.sol";
/// @title IShareModule
/// @notice Manages user-facing interactions with the vault via deposit/redeem queues, hooks, and share accounting.
/// @dev Coordinates oracle report handling, hook invocation, fee calculation, and queue lifecycle.
interface IShareModule is IBaseModule {
/// @notice Thrown when an unsupported asset is used for queue creation.
error UnsupportedAsset(address asset);
/// @notice Thrown when the number of queues exceeds the allowed system-wide maximum.
error QueueLimitReached();
/// @notice Thrown when an operation is attempted with a zero-value parameter.
error ZeroValue();
/// @dev Storage structure for the ShareModule.
struct ShareModuleStorage {
address shareManager; // Address of the ShareManager responsible for minting/burning shares
address feeManager; // Address of the FeeManager that calculates and collects protocol fees
address oracle; // Address of the Oracle
address defaultDepositHook; // Optional hook that is called by default after DepositQueue requests are processed
address defaultRedeemHook; // Optional hook that is called by default before RedeemQueue requests are processed
uint256 queueCount; // Total number of queues across all assets
uint256 queueLimit; // Maximum number of queues allowed in the system
mapping(address => address) customHooks; // Optional queue-specific hooks
mapping(address => bool) isDepositQueue; // Whether the queue is a deposit queue
mapping(address => bool) isPausedQueue; // Whether queue operations are currently paused
mapping(address => EnumerableSet.AddressSet) queues; // Mapping of asset to its associated queues
EnumerableSet.AddressSet assets; // Set of all supported assets with queues
}
/// @notice Role identifier for managing per-queue and default hooks
function SET_HOOK_ROLE() external view returns (bytes32);
/// @notice Role identifier for creating new queues
function CREATE_QUEUE_ROLE() external view returns (bytes32);
/// @notice Role identifier for changing the active/paused status of queues
function SET_QUEUE_STATUS_ROLE() external view returns (bytes32);
/// @notice Role identifier for modifying the global queue limit
function SET_QUEUE_LIMIT_ROLE() external view returns (bytes32);
/// @notice Role identifier for removing existing queues
function REMOVE_QUEUE_ROLE() external view returns (bytes32);
/// @notice Returns the ShareManager used for minting and burning shares
function shareManager() external view returns (IShareManager);
/// @notice Returns the FeeManager contract used for fee calculations
function feeManager() external view returns (IFeeManager);
/// @notice Returns the Oracle contract used for handling reports and managing supported assets.
function oracle() external view returns (IOracle);
/// @notice Returns the factory used for deploying deposit queues
function depositQueueFactory() external view returns (IFactory);
/// @notice Returns the factory used for deploying redeem queues
function redeemQueueFactory() external view returns (IFactory);
/// @notice Returns total number of distinct assets with queues
function getAssetCount() external view returns (uint256);
/// @notice Returns the address of the asset at the given index
function assetAt(uint256 index) external view returns (address);
/// @notice Returns whether the given asset is associated with any queues
function hasAsset(address asset) external view returns (bool);
/// @notice Returns whether the given queue is registered
function hasQueue(address queue) external view returns (bool);
/// @notice Returns whether the given queue is a deposit queue
function isDepositQueue(address queue) external view returns (bool);
/// @notice Returns whether the given queue is currently paused
function isPausedQueue(address queue) external view returns (bool);
/// @notice Returns number of queues associated with a given asset
function getQueueCount(address asset) external view returns (uint256);
/// @notice Returns the total number of queues across all assets
function getQueueCount() external view returns (uint256);
/// @notice Returns the queue at the given index for the specified asset
function queueAt(address asset, uint256 index) external view returns (address);
/// @notice Returns the hook assigned to a queue (customHook or defaultHook as a fallback)
function getHook(address queue) external view returns (address hook);
/// @notice Returns the default hook for deposit queues
function defaultDepositHook() external view returns (address);
/// @notice Returns the default hook for redeem queues
function defaultRedeemHook() external view returns (address);
/// @notice Returns the current global queue limit
function queueLimit() external view returns (uint256);
/// @notice Returns the total number of claimable shares for a given user
function claimableSharesOf(address account) external view returns (uint256 shares);
/// @notice Called by redeem queues to check the amount of assets available for instant withdrawal
function getLiquidAssets() external view returns (uint256);
/// @notice Claims all claimable shares from deposit queues for the specified account
function claimShares(address account) external;
/// @notice Assigns a custom hook contract to a specific queue
function setCustomHook(address queue, address hook) external;
/// @notice Sets the global default deposit hook
function setDefaultDepositHook(address hook) external;
/// @notice Sets the global default redeem hook
function setDefaultRedeemHook(address hook) external;
/// @notice Creates a new deposit or redeem queue for a given asset
function createQueue(uint256 version, bool isDepositQueue, address owner, address asset, bytes calldata data)
external;
/// @notice Removes a queue from the system if its `canBeRemoved()` function returns true
function removeQueue(address queue) external;
/// @notice Sets the maximum number of allowed queues across the module
function setQueueLimit(uint256 limit) external;
/// @notice Pauses or resumes a queue's operation
function setQueueStatus(address queue, bool isPaused) external;
/// @notice Invokes a queue's hook (also transfers assets to the queue for redeem queues)
function callHook(uint256 assets) external;
/// @notice Handles an oracle price report, distributes fees and calls internal hooks
function handleReport(address asset, uint224 priceD18, uint32 depositTimestamp, uint32 redeemTimestamp) external;
/// @notice Emitted when a user successfully claims shares from deposit queues
event SharesClaimed(address indexed account);
/// @notice Emitted when a queue-specific custom hook is updated
event CustomHookSet(address indexed queue, address indexed hook);
/// @notice Emitted when a new queue is created
event QueueCreated(address indexed queue, address indexed asset, bool isDepositQueue);
/// @notice Emitted when a queue is removed
event QueueRemoved(address indexed queue, address indexed asset);
/// @notice Emitted after a queue hook is successfully called
event HookCalled(address indexed queue, address indexed asset, uint256 assets, address hook);
/// @notice Emitted when the global queue limit is updated
event QueueLimitSet(uint256 limit);
/// @notice Emitted when a queue's paused status changes
event SetQueueStatus(address indexed queue, bool indexed isPaused);
/// @notice Emitted when a new default hook is configured
event DefaultHookSet(address indexed hook, bool isDepositHook);
/// @notice Emitted after processing a price report and fee distribution
event ReportHandled(
address indexed asset, uint224 indexed priceD18, uint32 depositTimestamp, uint32 redeemTimestamp, uint256 fees
);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.25;
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/Address.sol";
/// @title TransferLibrary
/// @notice Library for unified handling of native ETH and ERC20 asset transfers.
/// @dev Provides safe and abstracted methods for sending and receiving both ETH and ERC20 tokens.
///
/// # ETH Convention
/// Uses the constant `ETH = 0xEeee...EeE` to distinguish native ETH from ERC20 tokens.
library TransferLibrary {
using SafeERC20 for IERC20;
/// @notice Error thrown when `msg.value` does not match expected ETH amount
error InvalidValue();
/// @dev Placeholder address used to represent native ETH transfers
address public constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
/// @notice Safely sends assets (ETH or ERC20) to a recipient
/// @param asset Address of the asset to send (use `ETH` constant for native ETH)
/// @param to Recipient address
/// @param assets Amount of assets to send
/// @dev Uses `Address.sendValue` for ETH and `safeTransfer` for ERC20
function sendAssets(address asset, address to, uint256 assets) internal {
if (asset == ETH) {
Address.sendValue(payable(to), assets);
} else {
IERC20(asset).safeTransfer(to, assets);
}
}
/// @notice Safely receives assets (ETH or ERC20) from a sender
/// @param asset Address of the asset to receive (use `ETH` constant for native ETH)
/// @param from Sender address (only used for ERC20)
/// @param assets Amount of assets expected to receive
/// @dev Reverts if `msg.value` is incorrect for ETH or uses `safeTransferFrom` for ERC20
function receiveAssets(address asset, address from, uint256 assets) internal {
if (asset == ETH) {
if (msg.value != assets) {
revert InvalidValue();
}
} else {
IERC20(asset).safeTransferFrom(from, address(this), assets);
}
}
/// @notice Returns the balance of an account for a given asset
/// @param asset Address of the asset to check the balance of (use `ETH` constant for native ETH)
/// @param account Address of the account to check the balance of
/// @return Balance of the account for the given asset
function balanceOf(address asset, address account) internal view returns (uint256) {
if (asset == ETH) {
return account.balance;
} else {
return IERC20(asset).balanceOf(account);
}
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.25;
import "../factories/IFactory.sol";
import "../managers/IRiskManager.sol";
import "./IACLModule.sol";
import "./IShareModule.sol";
import "./ISubvaultModule.sol";
import "./IVerifierModule.sol";
/// @title IVaultModule
/// @notice Interface for a VaultModule that manages and coordinates asset flows
/// and sub-vault connections within a modular vault architecture.
interface IVaultModule is IACLModule {
/// @dev Thrown when trying to reconnect a subvault that is already connected.
error AlreadyConnected(address subvault);
/// @dev Thrown when trying to disconnect a subvault that is not currently connected.
error NotConnected(address subvault);
/// @dev Thrown when the provided address is not a valid factory-deployed entity.
error NotEntity(address subvault);
/// @dev Thrown when a given subvault is not correctly configured.
error InvalidSubvault(address subvault);
/// @notice Storage structure used to track vault state and subvaults.
struct VaultModuleStorage {
address riskManager;
EnumerableSet.AddressSet subvaults;
}
/// @notice Role that allows the creation of new subvaults.
function CREATE_SUBVAULT_ROLE() external view returns (bytes32);
/// @notice Role that allows disconnecting existing subvaults.
function DISCONNECT_SUBVAULT_ROLE() external view returns (bytes32);
/// @notice Role identifier for reconnecting subvaults.
/// @dev Grants permission to reattach a subvault to the vault system.
/// This includes both re-connecting a previously disconnected subvault
/// and connecting a new, properly configured subvault for the first time.
/// Used to maintain modularity and support hot-swapping of subvaults.
function RECONNECT_SUBVAULT_ROLE() external view returns (bytes32);
/// @notice Role that allows pulling assets from subvaults.
function PULL_LIQUIDITY_ROLE() external view returns (bytes32);
/// @notice Role that allows pushing assets into subvaults.
function PUSH_LIQUIDITY_ROLE() external view returns (bytes32);
/// @notice Returns the factory used to deploy new subvaults.
function subvaultFactory() external view returns (IFactory);
/// @notice Returns the factory used to deploy verifiers.
function verifierFactory() external view returns (IFactory);
/// @notice Returns the total number of connected subvaults.
function subvaults() external view returns (uint256);
/// @notice Returns the address of the subvault at a specific index.
/// @param index Index in the set of subvaults.
function subvaultAt(uint256 index) external view returns (address);
/// @notice Checks whether a given address is currently an active subvault.
/// @param subvault Address to check.
function hasSubvault(address subvault) external view returns (bool);
/// @notice Returns the address of the risk manager module.
function riskManager() external view returns (IRiskManager);
/// @notice Creates and connects a new subvault.
/// @param version Version of the subvault contract to deploy.
/// @param owner Owner of the newly created subvault.
/// @param verifier Verifier contract used for permissions within the subvault.
/// @return subvault Address of the newly created subvault.
function createSubvault(uint256 version, address owner, address verifier) external returns (address subvault);
/// @notice Disconnects a subvault from the vault.
/// @param subvault Address of the subvault to disconnect.
function disconnectSubvault(address subvault) external;
/// @notice Reconnects a subvault to the main vault system.
/// @dev Can be used to reattach either:
/// - A previously disconnected subvault, or
/// - A newly created and properly configured subvault.
/// Requires the caller to have the `RECONNECT_SUBVAULT_ROLE`.
/// @param subvault The address of the subvault to reconnect.
function reconnectSubvault(address subvault) external;
/// @notice Sends a specified amount of assets from the vault to a connected subvault.
/// @param subvault Address of the destination subvault.
/// @param asset Address of the asset to transfer.
/// @param value Amount of the asset to send.
function pushAssets(address subvault, address asset, uint256 value) external;
/// @notice Pulls a specified amount of assets from a connected subvault into the vault.
/// @param subvault Address of the source subvault.
/// @param asset Address of the asset to transfer.
/// @param value Amount of the asset to receive.
function pullAssets(address subvault, address asset, uint256 value) external;
/// @notice Internally used function that transfers assets from the vault to a connected subvault.
/// @dev Must be invoked by the vault itself via hook execution logic.
/// @param subvault Address of the destination subvault.
/// @param asset Address of the asset being transferred.
/// @param value Amount of the asset being transferred.
function hookPushAssets(address subvault, address asset, uint256 value) external;
/// @notice Internally used function that pulls assets from a connected subvault into the vault.
/// @dev Must be invoked by the vault itself via hook execution logic.
/// @param subvault Address of the source subvault.
/// @param asset Address of the asset being pulled.
/// @param value Amount of the asset being pulled.
function hookPullAssets(address subvault, address asset, uint256 value) external;
/// @notice Emitted when a new subvault is created.
event SubvaultCreated(address indexed subvault, uint256 version, address indexed owner, address indexed verifier);
/// @notice Emitted when a subvault is disconnected.
event SubvaultDisconnected(address indexed subvault);
/// @notice Emitted when a subvault is reconnected.
event SubvaultReconnected(address indexed subvault, address indexed verifier);
/// @notice Emitted when assets are pulled from a subvault into the vault.
event AssetsPulled(address indexed asset, address indexed subvault, uint256 value);
/// @notice Emitted when assets are pushed from the vault into a subvault.
event AssetsPushed(address indexed asset, address indexed subvault, uint256 value);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.25;
import "@openzeppelin/contracts-upgradeable/access/extensions/AccessControlEnumerableUpgradeable.sol";
/// @notice Interface for the MellowACL contract, which extends OpenZeppelin's AccessControlEnumerable
/// @dev Adds tracking of which roles are actively in use (i.e., assigned to at least one address)
interface IMellowACL is IAccessControlEnumerable {
/// @notice Storage layout used to track actively assigned roles
struct MellowACLStorage {
EnumerableSet.Bytes32Set supportedRoles; // Set of roles that have at least one assigned member
}
/// @notice Returns the total number of unique roles that are currently assigned
function supportedRoles() external view returns (uint256);
/// @notice Returns the role at the specified index in the set of active roles
/// @param index Index within the supported role set
/// @return role The bytes32 identifier of the role
function supportedRoleAt(uint256 index) external view returns (bytes32);
/// @notice Checks whether a given role is currently active (i.e., has at least one member)
/// @param role The bytes32 identifier of the role to check
/// @return isActive True if the role has any members assigned
function hasSupportedRole(bytes32 role) external view returns (bool);
/// @notice Emitted when a new role is granted for the first time
event RoleAdded(bytes32 indexed role);
/// @notice Emitted when a role loses its last member
event RoleRemoved(bytes32 indexed role);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.25;
import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import "@openzeppelin/contracts/utils/StorageSlot.sol";
/// @notice Interface for base module functionality shared across all modules
/// @dev Provides basic utilities such as raw storage access, ERC721 receiver support and `receive()` callback
interface IBaseModule is IERC721Receiver {
/// @notice Returns a reference to a storage slot as a `StorageSlot.Bytes32Slot` struct
/// @param slot The keccak256-derived storage slot identifier
/// @return A struct exposing the `.value` field stored at the given slot
function getStorageAt(bytes32 slot) external pure returns (StorageSlot.Bytes32Slot memory);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.25;
import "./IFactoryEntity.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
/// @title IFactory
/// @notice Interface for a factory that manages deployable upgradeable proxies and implementation governance.
interface IFactory is IFactoryEntity {
/// @notice Thrown when attempting to access an index outside the valid range.
error OutOfBounds(uint256 index);
/// @notice Thrown when trying to use an implementation version that is blacklisted.
error BlacklistedVersion(uint256 version);
/// @notice Thrown when an implementation is already in the accepted list.
error ImplementationAlreadyAccepted(address implementation);
/// @notice Thrown when an implementation has already been proposed.
error ImplementationAlreadyProposed(address implementation);
/// @notice Thrown when attempting to accept an implementation that was never proposed.
error ImplementationNotProposed(address implementation);
/// @dev Internal storage structure for tracking factory state.
struct FactoryStorage {
EnumerableSet.AddressSet entities; // Set of deployed upgradeable proxies
EnumerableSet.AddressSet implementations; // Set of accepted implementation addresses
EnumerableSet.AddressSet proposals; // Set of currently proposed (but not yet accepted) implementations
mapping(uint256 version => bool) isBlacklisted; // Tracks whether a given version is blacklisted
}
/// @notice Returns the total number of deployed entities (proxies).
function entities() external view returns (uint256);
/// @notice Returns the address of the deployed entity at a given index.
function entityAt(uint256 index) external view returns (address);
/// @notice Returns whether the given address is a deployed entity.
function isEntity(address entity) external view returns (bool);
/// @notice Returns the total number of accepted implementation contracts.
function implementations() external view returns (uint256);
/// @notice Returns the implementation address at the given index.
function implementationAt(uint256 index) external view returns (address);
/// @notice Returns the number of currently proposed (pending) implementations.
function proposals() external view returns (uint256);
/// @notice Returns the address of a proposed implementation at a given index.
function proposalAt(uint256 index) external view returns (address);
/// @notice Returns whether the given implementation version is blacklisted.
function isBlacklisted(uint256 version) external view returns (bool);
/// @notice Updates the blacklist status for a specific implementation version.
/// @param version The version index to update.
/// @param flag True to blacklist, false to unblacklist.
function setBlacklistStatus(uint256 version, bool flag) external;
/// @notice Proposes a new implementation for future deployment.
/// @param implementation The address of the proposed implementation contract.
function proposeImplementation(address implementation) external;
/// @notice Approves a previously proposed implementation, allowing it to be used for deployments.
/// @param implementation The address of the proposed implementation to approve.
function acceptProposedImplementation(address implementation) external;
/// @notice Deploys a new TransparentUpgradeableProxy using an accepted implementation.
/// @param version The version index of the implementation to use.
/// @param owner The address that will become the owner of the proxy.
/// @param initParams Calldata to be passed for initialization of the new proxy instance.
/// @return instance The address of the newly deployed proxy contract.
function create(uint256 version, address owner, bytes calldata initParams) external returns (address instance);
/// @notice Emitted when the blacklist status of a version is updated.
event SetBlacklistStatus(uint256 version, bool flag);
/// @notice Emitted when a new implementation is proposed.
event ProposeImplementation(address implementation);
/// @notice Emitted when a proposed implementation is accepted.
event AcceptProposedImplementation(address implementation);
/// @notice Emitted when a new proxy instance is successfully deployed.
event Created(address indexed instance, uint256 indexed version, address indexed owner, bytes initParams);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.25;
import "./IHook.sol";
/// @title IRedeemHook
/// @notice Interface for redeem-side hooks that implement custom logic during asset redemptions.
interface IRedeemHook is IHook {
/// @notice Returns the amount of liquid (immediately withdrawable) assets available for a given token.
/// @dev Used by queues to determine how much can be processed in the current redemption cycle.
/// @param asset The address of the ERC20 asset to check.
/// @return assets The amount of the asset that is liquid and available.
function getLiquidAssets(address asset) external view returns (uint256 assets);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.25;
import "../factories/IFactoryEntity.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts/utils/math/Math.sol";
/// @notice Interface for the FeeManager contract
/// @dev Handles deposit, redeem, performance, and protocol fees for vaults, and tracks per-vault price/timestamp states
interface IFeeManager is IFactoryEntity {
/// @notice Thrown when a required address is zero
error ZeroAddress();
/// @notice Thrown when the sum of all fees exceeds 100% (1e6 in D6 precision)
error InvalidFees(uint24 depositFeeD6, uint24 redeemFeeD6, uint24 performanceFeeD6, uint24 protocolFeeD6);
/// @notice Thrown when trying to overwrite a vault's base asset that was already set
error BaseAssetAlreadySet(address vault, address baseAsset);
/// @notice Storage layout used internally by FeeManager
struct FeeManagerStorage {
address feeRecipient; // Address that collects all fee shares
uint24 depositFeeD6; // Deposit fee in 6 decimals (e.g. 10000 = 1%)
uint24 redeemFeeD6; // Redeem fee in 6 decimals
uint24 performanceFeeD6; // Performance fee applied on price increase (6 decimals)
uint24 protocolFeeD6; // Protocol fee applied over time (6 decimals annualized)
mapping(address vault => uint256) timestamps; // Last update timestamp for protocol fee accrual
mapping(address vault => uint256) minPriceD18; // Lowests price seen for performance fee trigger (price * assets = shares)
mapping(address vault => address) baseAsset; // Base asset used to evaluate price-based fees
}
/// @notice Returns the current fee recipient address
function feeRecipient() external view returns (address);
/// @notice Returns the configured deposit fee (in D6 precision)
function depositFeeD6() external view returns (uint24);
/// @notice Returns the configured redeem fee (in D6 precision)
function redeemFeeD6() external view returns (uint24);
/// @notice Returns the configured performance fee (in D6 precision)
function performanceFeeD6() external view returns (uint24);
/// @notice Returns the configured protocol fee (in D6 precision per year)
function protocolFeeD6() external view returns (uint24);
/// @notice Returns the last recorded timestamp for a given vault (used for protocol fee accrual)
function timestamps(address vault) external view returns (uint256);
/// @notice Returns the last recorded min price for a vault's base asset (used for performance fee)
function minPriceD18(address vault) external view returns (uint256);
/// @notice Returns the base asset configured for a vault
function baseAsset(address vault) external view returns (address);
/// @notice Calculates the deposit fee in shares based on the amount
/// @param amount Number of shares being deposited
/// @return Fee in shares to be deducted
function calculateDepositFee(uint256 amount) external view returns (uint256);
/// @notice Calculates the redeem fee in shares based on the amount
/// @param amount Number of shares being redeemed
/// @return Fee in shares to be deducted
function calculateRedeemFee(uint256 amount) external view returns (uint256);
/// @notice Calculates the combined performance and protocol fee in shares
/// @param vault Address of the vault
/// @param asset Asset used for pricing
/// @param priceD18 Current vault share price for the specific `asset` (price = shares / assets)
/// @param totalShares Total shares of the vault
/// @return shares Fee to be added in shares
function calculateFee(address vault, address asset, uint256 priceD18, uint256 totalShares)
external
view
returns (uint256 shares);
/// @notice Sets the recipient address for all collected fees
/// @param feeRecipient_ Address to receive fees
function setFeeRecipient(address feeRecipient_) external;
/// @notice Sets the global fee configuration (deposit, redeem, performance, protocol)
/// @dev Total of all fees must be <= 1e6 (i.e. 100%)
function setFees(uint24 depositFeeD6_, uint24 redeemFeeD6_, uint24 performanceFeeD6_, uint24 protocolFeeD6_)
external;
/// @notice Sets the base asset for a vault, required for performance fee calculation
/// @dev Can only be set once per vault
function setBaseAsset(address vault, address baseAsset_) external;
/// @notice Updates the vault's state (min price and timestamp) based on asset price only if `asset` == `baseAssets[vault]`
/// @dev Used by the vault to notify FeeManager of new price highs or protocol fee accrual checkpoints
function updateState(address asset, uint256 priceD18) external;
/// @notice Emitted when the fee recipient is changed
event SetFeeRecipient(address indexed feeRecipient);
/// @notice Emitted when the fee configuration is updated
event SetFees(uint24 depositFeeD6, uint24 redeemFeeD6, uint24 performanceFeeD6, uint24 protocolFeeD6);
/// @notice Emitted when a vault's base asset is set
event SetBaseAsset(address indexed vault, address indexed baseAsset);
/// @notice Emitted when the vault's min price or timestamp is updated
event UpdateState(address indexed vault, address indexed asset, uint256 priceD18);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.25;
import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import "../factories/IFactoryEntity.sol";
import "../modules/IACLModule.sol";
import "../modules/IShareModule.sol";
/// @title IShareManager
/// @notice Interface for managing share allocations, permissions, minting, burning, and user restrictions
interface IShareManager is IFactoryEntity {
/// @notice Unauthorized call
error Forbidden();
/// @notice Attempted to mint more shares than pre-allocated
error InsufficientAllocatedShares(uint256 value, uint256 allocated);
/// @notice Global lockup not yet expired
error GlobalLockupNotExpired(uint256 timestamp, uint32 globalLockup);
/// @notice Blacklisted account tried to interact
error Blacklisted(address account);
/// @notice Transfers are currently paused
error TransferPaused();
/// @notice Minting is currently paused
error MintPaused();
/// @notice Burning is currently paused
error BurnPaused();
/// @notice Mint would exceed share limit
error LimitExceeded(uint256 value, uint256 limit);
/// @notice Account is not whitelisted to deposit
error NotWhitelisted(address account);
/// @notice Transfer between accounts not allowed by whitelist
error TransferNotAllowed(address from, address to);
/// @notice Provided value was zero
error ZeroValue();
/// @notice Storage layout for ShareManager.
struct ShareManagerStorage {
/// @notice Address of the vault associated with this ShareManager.
address vault;
/// @notice Bitpacked configuration flags controlling global minting, burning, transfers, whitelists and lockups.
uint256 flags;
/// @notice Total shares allocated to all accounts (includes pending shares).
uint256 allocatedShares;
/// @notice Merkle root for verifying account permissions (used for deposits if whitelist flags are active).
bytes32 whitelistMerkleRoot;
/// @notice Tracks individual account permissions, blacklist status, and lockup.
mapping(address account => AccountInfo) accounts;
}
/// @notice Per-account permission and state tracking.
struct AccountInfo {
/// @notice Whether the account is allowed to deposit when the `hasWhitelist` flag is active.
bool canDeposit;
/// @notice Whether the account is allowed to transfer (send or receive) shares when the `hasTransferWhitelist` flag is active.
bool canTransfer;
/// @notice Whether the account is disallowed to send or receive shares.
bool isBlacklisted;
}
/// @notice Decoded configuration flags from `ShareManagerStorage.flags`.
struct Flags {
/// @notice If true, minting is globally paused.
bool hasMintPause;
/// @notice If true, burning of shares is globally paused.
bool hasBurnPause;
/// @notice If true, transfers of shares between accounts are globally paused (only for TokenizedShareManager).
bool hasTransferPause;
/// @notice If true, deposit access is controlled via onchain whitelist (mapping `accounts`).
bool hasWhitelist;
/// @notice If true, transfer access is controlled via offchain whitelist (`whitelistMerkleRoot`).
bool hasTransferWhitelist;
/// @notice Global lockup duration (timestamp in seconds) applied to all users in the vault.
uint32 globalLockup;
}
/// @return bytes32 Returns role required to set global flags
function SET_FLAGS_ROLE() external view returns (bytes32);
/// @return bytes32 Returns role required to set per-user flags
function SET_ACCOUNT_INFO_ROLE() external view returns (bytes32);
/// @return bytes32 Returns role required to set new merkle root for whitelist validation
function SET_WHITELIST_MERKLE_ROOT_ROLE() external view returns (bytes32);
/// @return address Returns address of the vault using this ShareManager
function vault() external view returns (address);
/// @return uint256 Total allocated shares
function allocatedShares() external view returns (uint256);
/// @return f Returns current flag structure
function flags() external view returns (Flags memory f);
/// @return bytes32 Returns Merkle root used for deposit whitelist verification
function whitelistMerkleRoot() external view returns (bytes32);
/// @return bool Returns true whether depositor is allowed under current Merkle root and flag settings
function isDepositorWhitelisted(address account, bytes32[] calldata merkleProof) external view returns (bool);
/// @return shares Returns total shares (active + claimable) for an account
function sharesOf(address account) external view returns (uint256 shares);
/// @return shares Returns claimable shares for an account
function claimableSharesOf(address account) external view returns (uint256 shares);
/// @return shares Returns active shares for an account
function activeSharesOf(address account) external view returns (uint256 shares);
/// @return shares Returns total active shares across the vault
function activeShares() external view returns (uint256 shares);
/// @return shares Total shares including active and claimable
function totalShares() external view returns (uint256 shares);
/// @return info Returns account-specific configuration and permissions
function accounts(address account) external view returns (AccountInfo memory info);
/// @notice Internal checks for mint/burn/transfer under flags, lockups, blacklists, etc.
function updateChecks(address from, address to) external view;
/// @notice Triggers share claiming from queue to user
function claimShares(address account) external;
/// @notice Sets permissions and flags for a specific account
function setAccountInfo(address account, AccountInfo memory info) external;
/// @notice Sets global flag bitmask controlling mints, burns, lockups, etc.
function setFlags(Flags calldata flags) external;
/// @notice Sets new whitelist merkle root
function setWhitelistMerkleRoot(bytes32 whitelistMerkleRoot) external;
/// @notice Allocates `shares` that can be later minted via `mintAllocatedShares`
function allocateShares(uint256 shares) external;
/// @notice Mints shares from the allocated pool
function mintAllocatedShares(address to, uint256 shares) external;
/// @notice Mints new shares to a user directly
function mint(address to, uint256 shares) external;
/// @notice Burns user's shares
function burn(address account, uint256 amount) external;
/// @notice 'Locks' user's shares by transferring them to the vault balance
function lock(address acount, uint256 amount) external;
/// @notice One-time vault assignment during initialization
function setVault(address vault_) external;
/// @notice Emitted when shares are allocated or removed (positive/negative)
event AllocateShares(int256 value);
/// @notice Emitted when new shares are minted
event Mint(address indexed account, uint256 shares);
/// @notice Emitted when shares are burned
event Burn(address indexed account, uint256 shares);
/// @notice Emitted when shares are locked
event Lock(address account, uint256 value);
/// @notice Emitted when global flag configuration is changed
event SetFlags(Flags flags);
/// @notice Emitted when whitelist merkle root is changed
event SetWhitelistMerkleRoot(bytes32 newWhitelistMerkleRoot);
/// @notice Emitted when a user account is updated
event SetAccountInfo(address indexed account, AccountInfo info);
/// @notice Emitted when vault is set
event SetVault(address indexed vault);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.25;
import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts/access/IAccessControl.sol";
import "@openzeppelin/contracts/utils/math/Math.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "../factories/IFactoryEntity.sol";
import "../modules/IShareModule.sol";
/// @title IOracle
/// @notice Interface for the vault price oracle responsible for submitting, validating, and propagating price reports.
/// @dev The reported price is structured such that the invariant `shares = assets * price` holds true.
/// @dev Typically used to coordinate deposit, redemption and limit operations across queues, the vault and subvaults.
interface IOracle is IFactoryEntity {
/// @notice Thrown when an asset is not supported by the oracle.
/// @param asset The address of the unsupported asset.
error UnsupportedAsset(address asset);
/// @notice Thrown when attempting to register an asset that is already supported.
/// @param asset The address of the already supported asset.
error AlreadySupportedAsset(address asset);
/// @notice Thrown when a suspicious report fails validation due to unexpected data.
/// @dev This includes mismatches in price, timestamp, or incorrect `isSuspicios` flag.
error InvalidReport();
/// @notice Thrown when a function receives a zero value where a non-zero value is required.
error ZeroValue();
/// @notice Thrown when a report is submitted before the required timeout period,
/// and the previous report was not marked as suspicious.
/// @param timestamp The submitted report timestamp.
/// @param minTimestamp The earliest acceptable timestamp based on timeout configuration.
error TooEarly(uint256 timestamp, uint256 minTimestamp);
/// @notice Thrown when the submitted price violates oracle security rules.
/// @param priceD18 The submitted price in 18-decimal fixed-point format.
error InvalidPrice(uint256 priceD18);
/// @notice Thrown when the caller lacks the necessary permission to perform the operation.
error Forbidden();
/// @notice Configuration parameters that govern oracle price validation logic and reporting cadence.
struct SecurityParams {
/// @notice Maximum absolute difference between the new and previous price, beyond which the report is rejected.
uint224 maxAbsoluteDeviation;
/// @notice Absolute deviation threshold beyond which the report is flagged as suspicious (but not rejected).
uint224 suspiciousAbsoluteDeviation;
/// @notice Maximum allowed relative price deviation (as a fixed-point value with 18 decimals), beyond which the report is rejected.
/// Example: 0.05 * 1e18 = 5% max relative deviation.
uint64 maxRelativeDeviationD18;
/// @notice Relative deviation threshold for flagging suspicious reports (in 18-decimal format),
/// beyond which the report is flagged as suspicious (but not rejected).
/// Example: 0.03 * 1e18 = 3% suspicious threshold.
uint64 suspiciousRelativeDeviationD18;
/// @notice Minimum time in seconds required between two valid non-suspicious reports.
uint32 timeout;
/// @notice Minimum age (in seconds) a deposit request must have to be eligible for processing by a report submitted at the current timestamp.
uint32 depositInterval;
/// @notice Minimum age (in seconds) a redemption request must have to be eligible for processing by a report submitted at the current timestamp.
uint32 redeemInterval;
}
/// @notice Struct representing a price report submitted to the oracle.
/// @dev Used in vault accounting where `shares = (assets * priceD18) / 1e18`.
struct Report {
address asset; // Address of the asset the price refers to
uint224 priceD18; // Asset price in 18-decimal fixed-point format
}
/// @notice Detailed price report used for validation and tracking
struct DetailedReport {
uint224 priceD18; // Reported asset price in 18-decimal fixed-point format
uint32 timestamp; // Timestamp when the report was submitted
bool isSuspicious; // Whether the report is flagged as suspicious according to deviation thresholds
}
/// @notice Storage layout of the oracle
struct OracleStorage {
IShareModule vault; // The vault module that integrates with oracle reports
SecurityParams securityParams; // Oracle security configuration
EnumerableSet.AddressSet supportedAssets; // List of supported assets
mapping(address asset => DetailedReport) reports; // Latest report per asset
}
/// @notice Role required to submit reports
function SUBMIT_REPORTS_ROLE() external view returns (bytes32);
/// @notice Role required to accept suspicious reports
function ACCEPT_REPORT_ROLE() external view returns (bytes32);
/// @notice Role required to update security parameters
function SET_SECURITY_PARAMS_ROLE() external view returns (bytes32);
/// @notice Role required to add new supported assets
function ADD_SUPPORTED_ASSETS_ROLE() external view returns (bytes32);
/// @notice Role required to remove supported assets
function REMOVE_SUPPORTED_ASSETS_ROLE() external view returns (bytes32);
/// @notice Returns the connected vault module
function vault() external view returns (IShareModule);
/// @notice Returns current security parameters
function securityParams() external view returns (SecurityParams memory);
/// @notice Returns total count of supported assets
function supportedAssets() external view returns (uint256);
/// @notice Returns the supported asset at a specific index
/// @param index Index in the supported asset set
function supportedAssetAt(uint256 index) external view returns (address);
/// @notice Checks whether an asset is supported
/// @param asset Address of the asset
function isSupportedAsset(address asset) external view returns (bool);
/// @notice Returns the most recent detailed report for an asset
/// @param asset Address of the asset
function getReport(address asset) external view returns (DetailedReport memory);
/// @notice Validates the given price for a specific asset based on oracle security parameters.
/// @dev Evaluates both absolute and relative deviation limits to determine whether the price is valid or suspicious.
/// @param priceD18 Price to validate, in 18-decimal fixed-point format.
/// @param asset Address of the asset being evaluated.
/// @return isValid True if the price is within maximum allowed deviation.
/// @return isSuspicious True if the price exceeds the suspicious deviation threshold.
function validatePrice(uint256 priceD18, address asset) external view returns (bool isValid, bool isSuspicious);
/// @notice Submits price reports for supported assets.
/// @dev Processes pending deposit and redemption requests across DepositQueue and RedeemQueue contracts.
/// The core processing logic is determined by the ShareModule and Queue contracts.
/// Only callable by accounts with the `SUBMIT_REPORTS_ROLE`.
/// @param reports An array of price reports, each specifying the target asset and its latest price (in 18 decimals).
///
/// @dev Note: Submitted prices MUST reflect protocol and performance fee deductions, ensuring accurate share issuance.
function submitReports(Report[] calldata reports) external;
/// @notice Accepts a previously suspicious report
/// @dev Callable only by account with `ACCEPT_REPORT_ROLE`
/// @param asset Address of the asset
/// @param priceD18 Timestamp that must match existing suspicious report
/// @param timestamp Timestamp that must match existing suspicious report
function acceptReport(address asset, uint256 priceD18, uint32 timestamp) external;
/// @notice Updates oracle security parameters
/// @param securityParams_ New security settings
function setSecurityParams(SecurityParams calldata securityParams_) external;
/// @notice Adds multiple new assets to the supported set
/// @param assets Array of asset addresses to add
function addSupportedAssets(address[] calldata assets) external;
/// @notice Removes assets from the supported set
/// @param assets Array of asset addresses to remove
function removeSupportedAssets(address[] calldata assets) external;
/// @notice Sets the associated vault
/// @param vault_ Address of the vault module
function setVault(address vault_) external;
/// @notice Emitted when price reports are submitted
event ReportsSubmitted(Report[] reports);
/// @notice Emitted when a suspicious report is accepted
event ReportAccepted(address indexed asset, uint224 indexed priceD18, uint32 indexed timestamp);
/// @notice Emitted when new security parameters are set
event SecurityParamsSet(SecurityParams securityParams);
/// @notice Emitted when new assets are added
event SupportedAssetsAdded(address[] assets);
/// @notice Emitted when supported assets are removed
event SupportedAssetsRemoved(address[] assets);
/// @notice Emitted when vault is set
event SetVault(address indexed vault);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.25;
import "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts/utils/math/Math.sol";
import "@openzeppelin/contracts/utils/structs/Checkpoints.sol";
import "../../libraries/FenwickTreeLibrary.sol";
import "../managers/IRiskManager.sol";
import "../modules/IShareModule.sol";
import "../modules/IVaultModule.sol";
import "./IQueue.sol";
/// @title IDepositQueue
/// @notice Interface for deposit queues that manage time-delayed deposit requests with oracle-based pricing.
/// @dev Implements request creation, cancellation, and oracle-based price batch processing.
///
/// # Overview
/// A `DepositQueue` manages deposits for a specific asset with a time delay enforced by an oracle (`depositInterval`). It enforces the following invariants:
/// 1. Each user may have only one pending deposit request at a time.
/// 2. Each request is defined by `(amount, timestamp)`.
/// 3. Based on oracle reports queue determines when deposit requests are processed.
/// A report handles only those requests older than a configured `depositInterval`.
///
/// Once an oracle report is submitted at `reportTimestamp`, it processes all requests with `timestamp <= reportTimestamp - depositInterval`, converting asset deposits into vault shares at the reported price.
///
/// # User Cancellation
/// Users can cancel pending deposit requests before they are processed. This ensures a binary lifecycle:
/// - Either a user has a pending request they can cancel, or
/// - The request has been executed and the user owns shares.
///
/// # Scalability Challenge
/// Vaults can receive thousands of deposit requests per day. Processing each request individually is gas-inefficient.
/// To solve this, a **Fenwick Tree** is used to maintain prefix sums of deposits per timestamp.
///
/// # Fenwick Tree Usage
/// - When a user deposits `amount` at time `T`, the system records `fenwickTree[T] += amount`.
/// - If the user cancels, then `fenwickTree[T] -= amount`.
/// - On oracle report at time `reportTimestamp`, the system calculates:
/// `fenwickTree.getSum(latestHandledTimestamp + 1, reportTimestamp - depositInterval)`
/// to determine the total amount to convert into vault shares at the reported price.
///
/// The vault uses **lazy propagation** to calculate claimable shares per user without eagerly updating all balances in the `handleReport` processing.
/// Shares become fully claimed on the next interaction (e.g., claim, transfer or new deposit).
///
/// Additionally, **timestamp compression (coordinate compression)** is used to track in FenwickTree only timestamps where actual requests were made, reducing storage overhead.
interface IDepositQueue is IQueue {
/// @notice Thrown when a user is not allowed to deposit.
error DepositNotAllowed();
/// @notice Thrown if a new deposit is attempted while a pending request exists.
error PendingRequestExists();
/// @notice Thrown when attempting to cancel a deposit request that has become claimable.
error ClaimableRequestExists();
/// @notice Thrown when trying to cancel a non-existent deposit request.
error NoPendingRequest();
/// @notice Storage layout for managing the state of a deposit queue.
struct DepositQueueStorage {
/// @dev Iterator representing the number of fully processed `timestamps`.
/// Each timestamp may correspond to multiple user requests.
uint256 handledIndices;
/// @dev Mapping of user address to their latest deposit request.
/// Each request is stored as a checkpoint with timestamp (key) and asset amount (value).
mapping(address account => Checkpoints.Checkpoint224) requestOf;
/// @dev Fenwick tree tracking cumulative asset deposits by timestamp indices.
/// Enables efficient range sum queries and updates for oracle processing.
FenwickTreeLibrary.Tree requests;
/// @dev Price history reported by the oracle (indexed by timestamp).
/// Used to convert deposited assets into vault shares.
Checkpoints.Trace224 prices;
/// @dev Total number of unclaimed requests.
/// Used to check that the queue can be deleted.
uint256 unclaimedRequests;
}
/// @notice Returns the number of shares that can currently be claimed by the given account.
/// @param account Address of the user.
/// @return shares Amount of claimable shares.
function claimableOf(address account) external view returns (uint256 shares);
/// @notice Retrieves the timestamp and asset amount for a user's pending deposit request.
/// @param account Address of the user.
/// @return timestamp When the deposit was requested.
/// @return assets Amount of assets deposited.
function requestOf(address account) external view returns (uint256 timestamp, uint256 assets);
/// @notice Returns the number of unclaimed requests.
/// @return unclaimedRequests Number of unclaimed requests.
function unclaimedRequests() external view returns (uint256 unclaimedRequests);
/// @notice Submits a new deposit request into the queue.
/// @dev Reverts if a previous pending (not yet claimable) request exists.
/// @param assets Amount of assets to deposit.
/// @param referral Optional referral address.
/// @param merkleProof Merkle proof for whitelist validation, if required.
function deposit(uint224 assets, address referral, bytes32[] calldata merkleProof) external payable;
/// @notice Cancels the caller's current pending deposit request.
/// @dev Refunds the originally deposited assets. Reverts with `ClaimableRequestExists` if the
/// request has already become claimable.
function cancelDepositRequest() external;
/// @notice Claims shares from a fulfilled deposit request for a specific account.
/// @param account Address for which to claim shares.
/// @return success Boolean indicating whether a claim was successful.
function claim(address account) external returns (bool success);
/// @notice Emitted when a new deposit request is submitted.
/// @param account The depositor's address.
/// @param referral Optional referral address.
/// @param assets Amount of assets deposited.
/// @param timestamp Timestamp when the request was created.
event DepositRequested(address indexed account, address indexed referral, uint224 assets, uint32 timestamp);
/// @notice Emitted when a pending deposit request is canceled.
/// @param account Address of the user who canceled the request.
/// @param assets Amount of assets refunded.
/// @param timestamp Timestamp of the original request.
event DepositRequestCanceled(address indexed account, uint256 assets, uint32 timestamp);
/// @notice Emitted when a deposit request is successfully claimed into shares.
/// @param account Address receiving the shares.
/// @param shares Number of shares claimed.
/// @param timestamp Timestamp of the original deposit request.
event DepositRequestClaimed(address indexed account, uint256 shares, uint32 timestamp);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.25;
import "../factories/IFactoryEntity.sol";
import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts/utils/structs/Checkpoints.sol";
/// @title IQueue
/// @notice Base interface for deposit and redeem queues.
/// @dev Provides common structure and logic for queue operations such as pricing and vault association.
interface IQueue is IFactoryEntity {
/// @notice Reverts when a zero input value is supplied where non-zero is required.
error ZeroValue();
/// @notice Reverts when caller is not authorized to perform an action.
error Forbidden();
/// @notice Reverts when an oracle price report is invalid.
error InvalidReport();
/// @notice Reverts when queue interactions are restricted due to governance or ACL pause.
error QueuePaused();
/// @notice Storage layout for a generic queue contract (deposit or redeem).
struct QueueStorage {
/// @notice The asset managed by this queue (ERC20 or ETH).
address asset;
/// @notice The vault that this queue is connected to. Only this vault can trigger `handleReport`.
address vault;
/// @notice Timeline of user request checkpoints.
/// @dev Stores a sorted series of (timestamp, value) pairs, where the meaning of `value` is defined by the specific queue implementation.
Checkpoints.Trace224 timestamps;
}
/// @notice Returns the associated vault address.
function vault() external view returns (address vault);
/// @notice Returns the asset handled by this queue (ERC20 or ETH).
function asset() external view returns (address asset);
/// @notice Returns true if this queue is eligible for removal by the vault.
/// @return removable True if the queue is safe to remove.
function canBeRemoved() external view returns (bool removable);
/// @notice Handles a new price report from the oracle.
/// @dev Only callable by the vault. Validates input timestamp and price.
/// @param priceD18 Price reported with 18 decimal precision (shares = price * assets).
/// @param timestamp Timestamp when the report becomes effective.
function handleReport(uint224 priceD18, uint32 timestamp) external;
/// @notice Emitted when a price report is successfully processed by the queue.
/// @param priceD18 Reported price in 18-decimal fixed-point format (shares = assets * price).
/// @param timestamp All unprocessed requests with timestamps <= this value were handled using this report.
event ReportHandled(uint224 priceD18, uint32 timestamp);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.25;
import "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts/utils/math/Math.sol";
import "@openzeppelin/contracts/utils/structs/Checkpoints.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableMap.sol";
import "../modules/IVaultModule.sol";
import "./IQueue.sol";
/// @title IRedeemQueue
/// @notice Interface for redeem queues that manage time-delayed redemptions of vault shares into underlying assets.
/// @dev Handles request creation, price-based batch processing, and asynchronous liquidity settlement.
///
/// # Overview
/// A `RedeemQueue` allows users to request conversion of their vault shares into assets. It introduces a delay enforced by an oracle (`redeemInterval`), and ensures the following invariants:
/// 1. Each request is defined by `(shares, timestamp)`.
/// 2. Requests are **not cancellable**, to prevent griefing (e.g., by requesting redemption and cancelling after unstaking starts).
/// 3. Users may have multiple independent redemption requests.
///
/// Once an oracle report is submitted at `reportTimestamp`, it processes all requests with `timestamp <= reportTimestamp - redeemInterval`, converting vault shares into asset values using the reported price.
///
/// # Liquidity Processing (Two-Stage)
/// Redemption handling is decoupled from actual asset movement to allow asynchronous liquidity management:
/// - After a request is created, vault curators may pull liquidity from external protocols.
/// - Once oracle report is submitted and enough liquidity is available, vault curator (or any other actor) calls `handleReport()` on the redeem queue.
/// - This pulls required amount of assets from the Vault (and Subvaults) processing created redemption requests.
///
/// # Scalability Approach
/// Unlike deposits, redemption requests are never cancelled. This allows the system to use a **prefix sum array** to track requests over time.
///
/// # Redemption Processing
/// - When a user redeems `amount` shares at time `T`, the system records `prefixSum[T] += shares`.
/// - At oracle report time `reportTimestamp`, all requests with `timestamp <= reportTimestamp - redeemInterval` are marked as processed.
/// - Curator pushes the required assets to the queue by managin vault liquidity and calling `handleBatches` function afterwards.
/// - Users call `claim(receiver, timestamps[])` to redeem their processed shares for assets.
interface IRedeemQueue is IQueue {
/// @notice Redemption request metadata for a user.
/// @dev Represents a single request to convert vault shares into underlying assets.
struct Request {
/// @notice Timestamp when the redemption request was submitted.
/// @dev Determines eligibility for processing based on oracle report timing and `redeemInterval`.
uint256 timestamp;
/// @notice Amount of vault shares submitted for redemption.
uint256 shares;
/// @notice Whether the request has been processed and is now claimable.
/// @dev Set to `true` after liquidity has been allocated via `handleBatches`.
bool isClaimable;
/// @notice Amount of assets that can be claimed by the user.
/// @dev Calculated and stored after a matching oracle report has been processed via `handleReport`.
uint256 assets;
}
/// @notice Redemption batch result with total matched shares and corresponding assets.
/// @dev Represents a single price batch where multiple redemption requests are settled at the same oracle-reported price.
struct Batch {
/// @notice Total amount of assets allocated for this redemption batch.
/// @dev Calculated during `handleReport` using the reported price and total matched shares.
uint256 assets;
/// @notice Total number of vault shares handled in this batch.
/// @dev Includes all user requests processed at the same oracle report.
uint256 shares;
}
/// @notice Storage layout for the RedeemQueue contract.
/// @dev Tracks redemption request state, oracle-based batch settlements, and pricing checkpoints.
struct RedeemQueueStorage {
/// @notice Number of timestamp-based redemption checkpoints that have been processed.
/// @dev Ensures sequential handling of oracle reports.
uint256 handledIndices;
/// @notice Number of claimable batches.
/// @dev Increments as batches are handled via `handleBatches` and become claimable.
uint256 batchIterator;
/// @notice Total amount of assets needed to fulfill all currently batched redemption requests.
/// @dev Equals the sum of `batches[i].assets` for all indices `i` such that `batchIterator <= i < batches.length`.
uint256 totalDemandAssets;
/// @notice Total shares from redemption requests that are not yet claimable.
/// @dev Increases when users create new redemption requests and decreases after they are processed via `handleBatches`.
uint256 totalPendingShares;
/// @notice Mapping of redemption requests per user.
/// @dev Each user maps to a set of `(timestamp => shares)` representing open requests.
mapping(address => EnumerableMap.UintToUintMap) requestsOf;
/// @notice Prefix sum of requested shares grouped by timestamp.
/// @dev Enables efficient calculation of total demand in a redemption window.
mapping(uint256 => uint256) prefixSum;
/// @notice Batches created from processed oracle reports.
/// @dev Each batch maps total requested shares to the equivalent amount of assets.
Batch[] batches;
/// @notice Historical oracle pricing checkpoints for batch processing.
/// @dev Associates report timestamps with their respective batch index.
Checkpoints.Trace224 prices;
}
/// @notice Returns a paginated list of redemption requests for a user.
/// @dev Returned requests can be in one of the following states:
/// - Pending: Awaiting processing by an oracle report.
/// - Handled: Processed by oracle report but not yet claimable (assets not yet pulled from the Vault).
/// - Claimable: Processed and fully settled; assets are ready to be claimed.
/// @param account Address of the user.
/// @param offset Starting index for pagination.
/// @param limit Maximum number of requests to return.
/// @return requests Array of user's redemption requests with full status metadata.
function requestsOf(address account, uint256 offset, uint256 limit)
external
view
returns (Request[] memory requests);
/// @notice Returns assets and shares for a redemption batch at a given index.
/// @param batchIndex Index of the redemption batch.
/// @return assets Total assets corresponding to this batch.
/// @return shares Total shares redeemed in this batch.
function batchAt(uint256 batchIndex) external view returns (uint256 assets, uint256 shares);
/// @notice Returns the current state of the redeem queue system.
/// @return batchIterator Current index of the batch iterator (i.e., next batch to process).
/// @return batches Total number of recorded redemption batches.
/// @return totalDemandAssets Aggregate amount of redeem requests (in assets) awaiting fulfillment.
/// @return totalPendingShares Total number of shares across all redemption requests that are not yet claimable.
function getState()
external
view
returns (uint256 batchIterator, uint256 batches, uint256 totalDemandAssets, uint256 totalPendingShares);
/// @notice Initiates a new redemption by queuing shares for future asset claims.
/// @param shares Amount of shares to redeem.
function redeem(uint256 shares) external;
/// @notice Claims redemption requests for a user based on the provided timestamps.
/// @dev A request is successfully claimed only if:
/// - The associated timestamp has been processed by an oracle report, and
/// - The corresponding batch has been settled via `handleBatches`.
///
/// The function is idempotent — requests that are already claimed or not yet eligible are skipped without reverting.
///
/// @param account Address of the user claiming the redemptions.
/// @param timestamps List of request timestamps to claim.
/// @return assets Total amount of assets successfully claimed.
function claim(address account, uint32[] calldata timestamps) external returns (uint256 assets);
/// @notice Processes pending redemption batches by pulling required liquidity from the Vault.
/// @dev This function fulfills the asset side of redemption requests that have already been priced
/// via oracle reports. For each processed batch:
/// - Assets are pulled from the Vault to the RedeemQueue contract.
/// - Matching shares are marked as claimable for users.
///
/// This function enables asynchronous coordination between oracle reporting and vault liquidity management.
///
/// @param batches Maximum number of batches to process in this call.
/// @return counter Number of successfully processed redemption batches.
function handleBatches(uint256 batches) external returns (uint256 counter);
/// @notice Emitted when a new redemption request is requested.
event RedeemRequested(address indexed account, uint256 shares, uint256 timestamp);
/// @notice Emitted when redemption is claimed by a user.
event RedeemRequestClaimed(address indexed account, address indexed receiver, uint256 assets, uint32 timestamp);
/// @notice Emitted when oracle price reports are processed.
event RedeemRequestsHandled(uint256 counter, uint256 demand);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.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 Variant of {safeTransfer} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool) {
return _callOptionalReturnBool(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Variant of {safeTransferFrom} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool) {
return _callOptionalReturnBool(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: BUSL-1.1
pragma solidity 0.8.25;
import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol";
import "@openzeppelin/contracts/utils/math/SafeCast.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "../factories/IFactoryEntity.sol";
import "../modules/IACLModule.sol";
import "../modules/IShareModule.sol";
import "../modules/IVaultModule.sol";
import "../oracles/IOracle.sol";
/// @notice Interface for the RiskManager contract
/// @dev Handles vault and subvault balance limits, pending asset tracking, and asset permissioning
interface IRiskManager is IFactoryEntity {
/// @notice Thrown when the caller lacks appropriate permission
error Forbidden();
/// @notice Thrown when a price report is flagged as suspicious, or has not been set yet.
error InvalidReport();
/// @notice Thrown when attempting to allow an already allowed asset
error AlreadyAllowedAsset(address asset);
/// @notice Thrown when attempting to disallow or use a non-allowed asset
error NotAllowedAsset(address asset);
/// @notice Thrown when a vault or subvault exceeds its configured limit
error LimitExceeded(int256 newValue, int256 maxValue);
/// @notice Thrown when a given address is not recognized as a valid subvault
error NotSubvault(address subvault);
/// @notice Thrown when a zero address is passed as a parameter
error ZeroValue();
/// @notice Tracks current and maximum balance for a vault or subvault
struct State {
int256 balance; // Current approximate shares held
int256 limit; // Maximum allowable approximate shares
}
/// @notice Storage layout for RiskManager.
struct RiskManagerStorage {
address vault; // Address of the Vault associated with this risk manager.
State vaultState; // Tracks the share balance and limit for the Vault.
int256 pendingBalance;
/// Cumulative approximate share balance from all pending requests in all deposit queues. Used to track unprocessed inflows.
mapping(address asset => int256) pendingAssets; // Pending inflow amount per asset.
mapping(address asset => int256) pendingShares; // Pending inflow amount in shares per asset converted by the last oracle report.
mapping(address subvault => State) subvaultStates; // Share state tracking for each connected subvault.
mapping(address subvault => EnumerableSet.AddressSet) allowedAssets; // List of assets that each subvault is allowed to interact with.
}
/// @notice Reverts if the given subvault is not valid for the vault
function requireValidSubvault(address vault_, address subvault) external view;
/// @notice Returns the address of the Vault
function vault() external view returns (address);
/// @notice Returns the approximate share balance and the share limit limit of the vault.
function vaultState() external view returns (State memory);
/// @notice Returns the pending share balance across all assets and deposit queues.
function pendingBalance() external view returns (int256);
/// @notice Returns the pending asset value for a specific asset
function pendingAssets(address asset) external view returns (int256);
/// @notice Returns the pending shares equivalent of a specific asset converted by the last oracle report for the given asset.
function pendingShares(address asset) external view returns (int256);
/// @notice Returns the approximate balance and the limit of a specific subvault
function subvaultState(address subvault) external view returns (State memory);
/// @notice Returns number of assets allowed for a given subvault
function allowedAssets(address subvault) external view returns (uint256);
/// @notice Returns the allowed asset at a given index for a subvault
function allowedAssetAt(address subvault, uint256 index) external view returns (address);
/// @notice Checks if an asset is allowed for the specified subvault
function isAllowedAsset(address subvault, address asset) external view returns (bool);
/// @notice Converts an asset amount into its equivalent share representation by the last oracle report
/// @param asset Asset being valued
/// @param value Amount in asset units (can be positive or negative)
/// @return shares Share amount
function convertToShares(address asset, int256 value) external view returns (int256 shares);
/// @notice Returns the maximum amount that can be deposited into a subvault for a specific asset
function maxDeposit(address subvault, address asset) external view returns (uint256 limit);
/// @notice Modifies the vault's internal balance by a signed delta (in asset terms)
function modifyVaultBalance(address asset, int256 delta) external;
/// @notice Modifies a subvault's internal balance by a signed delta (in asset terms)
function modifySubvaultBalance(address subvault, address asset, int256 delta) external;
/// @notice Sets the maximum allowable approximate (soft) balance for the entire vault in shares
function setVaultLimit(int256 limit) external;
/// @notice Sets the maximum allowable approximate (soft) balance for a specific subvault
function setSubvaultLimit(address subvault, int256 limit) external;
/// @notice Allows specific assets to be used in a subvault
function allowSubvaultAssets(address subvault, address[] calldata assets) external;
/// @notice Disallows specific assets from being used in a subvault
function disallowSubvaultAssets(address subvault, address[] calldata assets) external;
/// @notice Modifies the vault's pending balances by a signed delta (in asset terms)
function modifyPendingAssets(address asset, int256 change) external;
/// @notice Sets the vault address this RiskManager is associated with
function setVault(address vault_) external;
/// @notice Emitted when a limit is set for a specific subvault
event SetSubvaultLimit(address indexed subvault, int256 limit);
/// @notice Emitted when the vault limit is updated
event SetVaultLimit(int256 limit);
/// @notice Emitted when assets are newly allowed for a subvault
event AllowSubvaultAssets(address indexed subvault, address[] assets);
/// @notice Emitted when assets are disallowed from a subvault
event DisallowSubvaultAssets(address indexed subvault, address[] assets);
/// @notice Emitted when pending asset balances are updated
event ModifyPendingAssets(
address indexed asset, int256 change, int256 pendingAssetsAfter, int256 pendingSharesAfter
);
/// @notice Emitted when the vault balance is changed
event ModifyVaultBalance(address indexed asset, int256 shares, int256 newBalance);
/// @notice Emitted when a subvault's balance is changed
event ModifySubvaultBalance(address indexed subvault, address indexed asset, int256 change, int256 newBalance);
/// @notice Emitted when the associated vault address is set
event SetVault(address indexed vault);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.25;
import "../factories/IFactory.sol";
/// @title ISubvaultModule
/// @notice Interface for a Subvault module used in modular vault architecture.
/// @dev A Subvault is a child vault that holds assets and can release them to its parent vault upon request.
/// Each Subvault is isolated and may integrate with external protocols through its own Verifier & CallModule, enabling
/// fine-grained delegation of liquidity while maintaining separation between subvaults.
interface ISubvaultModule {
/// @notice Reverts when a caller is not the associated vault.
error NotVault();
/// @notice Storage laylout of ISubvaultModule.
/// @dev Stores the address of the parent vault that has permission to pull assets.
struct SubvaultModuleStorage {
address vault;
}
/// @notice Returns the address of the parent vault contract.
/// @return address The vault address allowed to interact with this subvault.
function vault() external view returns (address);
/// @notice Transfers a specified amount of an asset to the vault.
/// @dev Can only be called by the parent vault.
/// @param asset Address of the ERC20 token or native ETH.
/// @param value Amount of the asset to transfer.
function pullAssets(address asset, uint256 value) external;
/// @notice Emitted when assets are pulled from the subvault to the vault.
/// @param asset Address of the asset that was pulled.
/// @param to Recipient address (must be the vault).
/// @param value Amount of the asset that was pulled.
event AssetsPulled(address indexed asset, address indexed to, uint256 value);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.25;
import "../permissions/IVerifier.sol";
import "./IBaseModule.sol";
/// @notice Interface for the VerifierModule, which integrates with an external IVerifier contract
/// @dev Used in modular systems to delegate permission checks or validation to a shared verifier
interface IVerifierModule is IBaseModule {
/// @notice Thrown when a zero address is provided
error ZeroAddress();
/// @notice Internal storage structure for VerifierModule
struct VerifierModuleStorage {
address verifier; // Address of the IVerifier contract used for external call validation
}
/// @notice Returns the current verifier contract used by the module
/// @return Address of the IVerifier contract
function verifier() external view returns (IVerifier);
}// 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.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: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,
* consider using {ReentrancyGuardTransient} instead.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuardUpgradeable is Initializable {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
/// @custom:storage-location erc7201:openzeppelin.storage.ReentrancyGuard
struct ReentrancyGuardStorage {
uint256 _status;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant ReentrancyGuardStorageLocation = 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;
function _getReentrancyGuardStorage() private pure returns (ReentrancyGuardStorage storage $) {
assembly {
$.slot := ReentrancyGuardStorageLocation
}
}
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
function __ReentrancyGuard_init() internal onlyInitializing {
__ReentrancyGuard_init_unchained();
}
function __ReentrancyGuard_init_unchained() internal onlyInitializing {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
$._status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
// On the first call to nonReentrant, _status will be NOT_ENTERED
if ($._status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
$._status = ENTERED;
}
function _nonReentrantAfter() private {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
$._status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
return $._status == ENTERED;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.20;
/**
* @title ERC-721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC-721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be
* reverted.
*
* The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}// 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: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
/// @custom:storage-location erc7201:openzeppelin.storage.Ownable
struct OwnableStorage {
address _owner;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant OwnableStorageLocation = 0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300;
function _getOwnableStorage() private pure returns (OwnableStorage storage $) {
assembly {
$.slot := OwnableStorageLocation
}
}
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
function __Ownable_init(address initialOwner) internal onlyInitializing {
__Ownable_init_unchained(initialOwner);
}
function __Ownable_init_unchained(address initialOwner) internal onlyInitializing {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
OwnableStorage storage $ = _getOwnableStorage();
return $._owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
OwnableStorage storage $ = _getOwnableStorage();
address oldOwner = $._owner;
$._owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (proxy/transparent/TransparentUpgradeableProxy.sol)
pragma solidity ^0.8.22;
import {ERC1967Utils} from "../ERC1967/ERC1967Utils.sol";
import {ERC1967Proxy} from "../ERC1967/ERC1967Proxy.sol";
import {IERC1967} from "../../interfaces/IERC1967.sol";
import {ProxyAdmin} from "./ProxyAdmin.sol";
/**
* @dev Interface for {TransparentUpgradeableProxy}. In order to implement transparency, {TransparentUpgradeableProxy}
* does not implement this interface directly, and its upgradeability mechanism is implemented by an internal dispatch
* mechanism. The compiler is unaware that these functions are implemented by {TransparentUpgradeableProxy} and will not
* include them in the ABI so this interface must be used to interact with it.
*/
interface ITransparentUpgradeableProxy is IERC1967 {
/// @dev See {UUPSUpgradeable-upgradeToAndCall}
function upgradeToAndCall(address newImplementation, bytes calldata data) external payable;
}
/**
* @dev This contract implements a proxy that is upgradeable through an associated {ProxyAdmin} instance.
*
* To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector
* clashing], which can potentially be used in an attack, this contract uses the
* https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two
* things that go hand in hand:
*
* 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if
* that call matches the {ITransparentUpgradeableProxy-upgradeToAndCall} function exposed by the proxy itself.
* 2. If the admin calls the proxy, it can call the `upgradeToAndCall` function but any other call won't be forwarded to
* the implementation. If the admin tries to call a function on the implementation it will fail with an error indicating
* the proxy admin cannot fallback to the target implementation.
*
* These properties mean that the admin account can only be used for upgrading the proxy, so it's best if it's a
* dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to
* call a function from the proxy implementation. For this reason, the proxy deploys an instance of {ProxyAdmin} and
* allows upgrades only if they come through it. You should think of the `ProxyAdmin` instance as the administrative
* interface of the proxy, including the ability to change who can trigger upgrades by transferring ownership.
*
* NOTE: The real interface of this proxy is that defined in `ITransparentUpgradeableProxy`. This contract does not
* inherit from that interface, and instead `upgradeToAndCall` is implicitly implemented using a custom dispatch
* mechanism in `_fallback`. Consequently, the compiler will not produce an ABI for this contract. This is necessary to
* fully implement transparency without decoding reverts caused by selector clashes between the proxy and the
* implementation.
*
* NOTE: This proxy does not inherit from {Context} deliberately. The {ProxyAdmin} of this contract won't send a
* meta-transaction in any way, and any other meta-transaction setup should be made in the implementation contract.
*
* IMPORTANT: This contract avoids unnecessary storage reads by setting the admin only during construction as an
* immutable variable, preventing any changes thereafter. However, the admin slot defined in ERC-1967 can still be
* overwritten by the implementation logic pointed to by this proxy. In such cases, the contract may end up in an
* undesirable state where the admin slot is different from the actual admin. Relying on the value of the admin slot
* is generally fine if the implementation is trusted.
*
* WARNING: It is not recommended to extend this contract to add additional external functions. If you do so, the
* compiler will not check that there are no selector conflicts, due to the note above. A selector clash between any new
* function and the functions declared in {ITransparentUpgradeableProxy} will be resolved in favor of the new one. This
* could render the `upgradeToAndCall` function inaccessible, preventing upgradeability and compromising transparency.
*/
contract TransparentUpgradeableProxy is ERC1967Proxy {
// An immutable address for the admin to avoid unnecessary SLOADs before each call
// at the expense of removing the ability to change the admin once it's set.
// This is acceptable if the admin is always a ProxyAdmin instance or similar contract
// with its own ability to transfer the permissions to another account.
address private immutable _admin;
/**
* @dev The proxy caller is the current admin, and can't fallback to the proxy target.
*/
error ProxyDeniedAdminAccess();
/**
* @dev Initializes an upgradeable proxy managed by an instance of a {ProxyAdmin} with an `initialOwner`,
* backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in
* {ERC1967Proxy-constructor}.
*/
constructor(address _logic, address initialOwner, bytes memory _data) payable ERC1967Proxy(_logic, _data) {
_admin = address(new ProxyAdmin(initialOwner));
// Set the storage value and emit an event for ERC-1967 compatibility
ERC1967Utils.changeAdmin(_proxyAdmin());
}
/**
* @dev Returns the admin of this proxy.
*/
function _proxyAdmin() internal view virtual returns (address) {
return _admin;
}
/**
* @dev If caller is the admin process the call internally, otherwise transparently fallback to the proxy behavior.
*/
function _fallback() internal virtual override {
if (msg.sender == _proxyAdmin()) {
if (msg.sig != ITransparentUpgradeableProxy.upgradeToAndCall.selector) {
revert ProxyDeniedAdminAccess();
} else {
_dispatchUpgradeToAndCall();
}
} else {
super._fallback();
}
}
/**
* @dev Upgrade the implementation of the proxy. See {ERC1967Utils-upgradeToAndCall}.
*
* Requirements:
*
* - If `data` is empty, `msg.value` must be zero.
*/
function _dispatchUpgradeToAndCall() private {
(address newImplementation, bytes memory data) = abi.decode(msg.data[4:], (address, bytes));
ERC1967Utils.upgradeToAndCall(newImplementation, data);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.
pragma solidity ^0.8.20;
import {Arrays} from "../Arrays.sol";
/**
* @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.
* - Set can be cleared (all elements removed) in O(n).
*
* ```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 Removes all the values from a set. O(n).
*
* WARNING: Developers should keep in mind that this function has an unbounded cost and using it may render the
* function uncallable if the set grows to the point where clearing it consumes too much gas to fit in a block.
*/
function _clear(Set storage set) private {
uint256 len = _length(set);
for (uint256 i = 0; i < len; ++i) {
delete set._positions[set._values[i]];
}
Arrays.unsafeSetLength(set._values, 0);
}
/**
* @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 Removes all the values from a set. O(n).
*
* WARNING: Developers should keep in mind that this function has an unbounded cost and using it may render the
* function uncallable if the set grows to the point where clearing it consumes too much gas to fit in a block.
*/
function clear(Bytes32Set storage set) internal {
_clear(set._inner);
}
/**
* @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 Removes all the values from a set. O(n).
*
* WARNING: Developers should keep in mind that this function has an unbounded cost and using it may render the
* function uncallable if the set grows to the point where clearing it consumes too much gas to fit in a block.
*/
function clear(AddressSet storage set) internal {
_clear(set._inner);
}
/**
* @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 Removes all the values from a set. O(n).
*
* WARNING: Developers should keep in mind that this function has an unbounded cost and using it may render the
* function uncallable if the set grows to the point where clearing it consumes too much gas to fit in a block.
*/
function clear(UintSet storage set) internal {
_clear(set._inner);
}
/**
* @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: BUSL-1.1
pragma solidity 0.8.25;
/// @title IHook
/// @notice Interface for a generic hook contract used to process asset-related logic during queue execution upon oracle reports.
/// @dev This interface is intended for both deposit and redeem queues, where additional logic (e.g. wrapping, redistributions, auto-compounding,
/// liquidity checks) must be executed atomically during queue finalization. Typically called via `delegatecall`.
interface IHook {
/// @notice Executes custom logic for the given asset and amount during queue processing.
/// @dev This function is called via `delegatecall` by the ShareModule or Vault.
/// @param asset The address of the ERC20 asset being processed.
/// @param assets The amount of the asset involved in the operation.
function callHook(address asset, uint256 assets) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.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 Return the 512-bit addition of two uint256.
*
* The result is stored in two 256 variables such that sum = high * 2²⁵⁶ + low.
*/
function add512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {
assembly ("memory-safe") {
low := add(a, b)
high := lt(low, a)
}
}
/**
* @dev Return the 512-bit multiplication of two uint256.
*
* The result is stored in two 256 variables such that product = high * 2²⁵⁶ + low.
*/
function mul512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {
// 512-bit multiply [high low] = 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 = high * 2²⁵⁶ + low.
assembly ("memory-safe") {
let mm := mulmod(a, b, not(0))
low := mul(a, b)
high := sub(sub(mm, low), lt(mm, low))
}
}
/**
* @dev Returns the addition of two unsigned integers, with a success flag (no overflow).
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a + b;
success = c >= a;
result = c * SafeCast.toUint(success);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with a success flag (no overflow).
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a - b;
success = c <= a;
result = c * SafeCast.toUint(success);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with a success flag (no overflow).
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a * b;
assembly ("memory-safe") {
// Only true when the multiplication doesn't overflow
// (c / a == b) || (a == 0)
success := or(eq(div(c, a), b), iszero(a))
}
// equivalent to: success ? c : 0
result = c * SafeCast.toUint(success);
}
}
/**
* @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 {
success = b > 0;
assembly ("memory-safe") {
// The `DIV` opcode returns zero when the denominator is 0.
result := div(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 {
success = b > 0;
assembly ("memory-safe") {
// The `MOD` opcode returns zero when the denominator is 0.
result := mod(a, b)
}
}
}
/**
* @dev Unsigned saturating addition, bounds to `2²⁵⁶ - 1` instead of overflowing.
*/
function saturatingAdd(uint256 a, uint256 b) internal pure returns (uint256) {
(bool success, uint256 result) = tryAdd(a, b);
return ternary(success, result, type(uint256).max);
}
/**
* @dev Unsigned saturating subtraction, bounds to zero instead of overflowing.
*/
function saturatingSub(uint256 a, uint256 b) internal pure returns (uint256) {
(, uint256 result) = trySub(a, b);
return result;
}
/**
* @dev Unsigned saturating multiplication, bounds to `2²⁵⁶ - 1` instead of overflowing.
*/
function saturatingMul(uint256 a, uint256 b) internal pure returns (uint256) {
(bool success, uint256 result) = tryMul(a, b);
return ternary(success, result, type(uint256).max);
}
/**
* @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 {
(uint256 high, uint256 low) = mul512(x, y);
// Handle non-overflow cases, 256 by 256 division.
if (high == 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 low / denominator;
}
// Make sure the result is less than 2²⁵⁶. Also prevents denominator == 0.
if (denominator <= high) {
Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW));
}
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [high low].
uint256 remainder;
assembly ("memory-safe") {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
high := sub(high, gt(remainder, low))
low := sub(low, 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 ("memory-safe") {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [high low] by twos.
low := div(low, 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 high into low.
low |= high * 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 high
// is no longer required.
result = low * 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 Calculates floor(x * y >> n) with full precision. Throws if result overflows a uint256.
*/
function mulShr(uint256 x, uint256 y, uint8 n) internal pure returns (uint256 result) {
unchecked {
(uint256 high, uint256 low) = mul512(x, y);
if (high >= 1 << n) {
Panic.panic(Panic.UNDER_OVERFLOW);
}
return (high << (256 - n)) | (low >> n);
}
}
/**
* @dev Calculates x * y >> n with full precision, following the selected rounding direction.
*/
function mulShr(uint256 x, uint256 y, uint8 n, Rounding rounding) internal pure returns (uint256) {
return mulShr(x, y, n) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, 1 << n) > 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 x) internal pure returns (uint256 r) {
// If value has upper 128 bits set, log2 result is at least 128
r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;
// If upper 64 bits of 128-bit half set, add 64 to result
r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;
// If upper 32 bits of 64-bit half set, add 32 to result
r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;
// If upper 16 bits of 32-bit half set, add 16 to result
r |= SafeCast.toUint((x >> r) > 0xffff) << 4;
// If upper 8 bits of 16-bit half set, add 8 to result
r |= SafeCast.toUint((x >> r) > 0xff) << 3;
// If upper 4 bits of 8-bit half set, add 4 to result
r |= SafeCast.toUint((x >> r) > 0xf) << 2;
// Shifts value right by the current result and use it as an index into this lookup table:
//
// | x (4 bits) | index | table[index] = MSB position |
// |------------|---------|-----------------------------|
// | 0000 | 0 | table[0] = 0 |
// | 0001 | 1 | table[1] = 0 |
// | 0010 | 2 | table[2] = 1 |
// | 0011 | 3 | table[3] = 1 |
// | 0100 | 4 | table[4] = 2 |
// | 0101 | 5 | table[5] = 2 |
// | 0110 | 6 | table[6] = 2 |
// | 0111 | 7 | table[7] = 2 |
// | 1000 | 8 | table[8] = 3 |
// | 1001 | 9 | table[9] = 3 |
// | 1010 | 10 | table[10] = 3 |
// | 1011 | 11 | table[11] = 3 |
// | 1100 | 12 | table[12] = 3 |
// | 1101 | 13 | table[13] = 3 |
// | 1110 | 14 | table[14] = 3 |
// | 1111 | 15 | table[15] = 3 |
//
// The lookup table is represented as a 32-byte value with the MSB positions for 0-15 in the last 16 bytes.
assembly ("memory-safe") {
r := or(r, byte(shr(r, x), 0x0000010102020202030303030303030300000000000000000000000000000000))
}
}
/**
* @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 x) internal pure returns (uint256 r) {
// If value has upper 128 bits set, log2 result is at least 128
r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;
// If upper 64 bits of 128-bit half set, add 64 to result
r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;
// If upper 32 bits of 64-bit half set, add 32 to result
r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;
// If upper 16 bits of 32-bit half set, add 16 to result
r |= SafeCast.toUint((x >> r) > 0xffff) << 4;
// Add 1 if upper 8 bits of 16-bit half set, and divide accumulated result by 8
return (r >> 3) | SafeCast.toUint((x >> r) > 0xff);
}
/**
* @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) (utils/cryptography/MerkleProof.sol)
// This file was procedurally generated from scripts/generate/templates/MerkleProof.js.
pragma solidity ^0.8.20;
import {Hashes} from "./Hashes.sol";
/**
* @dev These functions deal with verification of Merkle Tree proofs.
*
* The tree and the proofs can be generated using our
* https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
* You will find a quickstart guide in the readme.
*
* WARNING: You should avoid using leaf values that are 64 bytes long prior to
* hashing, or use a hash function other than keccak256 for hashing leaves.
* This is because the concatenation of a sorted pair of internal nodes in
* the Merkle tree could be reinterpreted as a leaf value.
* OpenZeppelin's JavaScript library generates Merkle trees that are safe
* against this attack out of the box.
*
* IMPORTANT: Consider memory side-effects when using custom hashing functions
* that access memory in an unsafe way.
*
* NOTE: This library supports proof verification for merkle trees built using
* custom _commutative_ hashing functions (i.e. `H(a, b) == H(b, a)`). Proving
* leaf inclusion in trees built using non-commutative hashing functions requires
* additional logic that is not supported by this library.
*/
library MerkleProof {
/**
*@dev The multiproof provided is not valid.
*/
error MerkleProofInvalidMultiproof();
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*
* This version handles proofs in memory with the default hashing function.
*/
function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leaves & pre-images are assumed to be sorted.
*
* This version handles proofs in memory with the default hashing function.
*/
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = Hashes.commutativeKeccak256(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*
* This version handles proofs in memory with a custom hashing function.
*/
function verify(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bool) {
return processProof(proof, leaf, hasher) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leaves & pre-images are assumed to be sorted.
*
* This version handles proofs in memory with a custom hashing function.
*/
function processProof(
bytes32[] memory proof,
bytes32 leaf,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = hasher(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*
* This version handles proofs in calldata with the default hashing function.
*/
function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
return processProofCalldata(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leaves & pre-images are assumed to be sorted.
*
* This version handles proofs in calldata with the default hashing function.
*/
function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = Hashes.commutativeKeccak256(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*
* This version handles proofs in calldata with a custom hashing function.
*/
function verifyCalldata(
bytes32[] calldata proof,
bytes32 root,
bytes32 leaf,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bool) {
return processProofCalldata(proof, leaf, hasher) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leaves & pre-images are assumed to be sorted.
*
* This version handles proofs in calldata with a custom hashing function.
*/
function processProofCalldata(
bytes32[] calldata proof,
bytes32 leaf,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = hasher(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
* `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
*
* This version handles multiproofs in memory with the default hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
*
* NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`.
* The `leaves` must be validated independently. See {processMultiProof}.
*/
function multiProofVerify(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProof(proof, proofFlags, leaves) == root;
}
/**
* @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
* proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
* leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
* respectively.
*
* This version handles multiproofs in memory with the default hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
* is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
* tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
*
* NOTE: The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op,
* and therefore a valid multiproof (i.e. it returns `proof[0]`). Consider disallowing this case if you're not
* validating the leaves elsewhere.
*/
function processMultiProof(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
// This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the Merkle tree.
uint256 leavesLen = leaves.length;
uint256 proofFlagsLen = proofFlags.length;
// Check proof validity.
if (leavesLen + proof.length != proofFlagsLen + 1) {
revert MerkleProofInvalidMultiproof();
}
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](proofFlagsLen);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < proofFlagsLen; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i]
? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
: proof[proofPos++];
hashes[i] = Hashes.commutativeKeccak256(a, b);
}
if (proofFlagsLen > 0) {
if (proofPos != proof.length) {
revert MerkleProofInvalidMultiproof();
}
unchecked {
return hashes[proofFlagsLen - 1];
}
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
/**
* @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
* `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
*
* This version handles multiproofs in memory with a custom hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
*
* NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`.
* The `leaves` must be validated independently. See {processMultiProof}.
*/
function multiProofVerify(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32 root,
bytes32[] memory leaves,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bool) {
return processMultiProof(proof, proofFlags, leaves, hasher) == root;
}
/**
* @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
* proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
* leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
* respectively.
*
* This version handles multiproofs in memory with a custom hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
* is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
* tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
*
* NOTE: The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op,
* and therefore a valid multiproof (i.e. it returns `proof[0]`). Consider disallowing this case if you're not
* validating the leaves elsewhere.
*/
function processMultiProof(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32[] memory leaves,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bytes32 merkleRoot) {
// This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the Merkle tree.
uint256 leavesLen = leaves.length;
uint256 proofFlagsLen = proofFlags.length;
// Check proof validity.
if (leavesLen + proof.length != proofFlagsLen + 1) {
revert MerkleProofInvalidMultiproof();
}
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](proofFlagsLen);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < proofFlagsLen; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i]
? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
: proof[proofPos++];
hashes[i] = hasher(a, b);
}
if (proofFlagsLen > 0) {
if (proofPos != proof.length) {
revert MerkleProofInvalidMultiproof();
}
unchecked {
return hashes[proofFlagsLen - 1];
}
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
/**
* @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
* `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
*
* This version handles multiproofs in calldata with the default hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
*
* NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`.
* The `leaves` must be validated independently. See {processMultiProofCalldata}.
*/
function multiProofVerifyCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProofCalldata(proof, proofFlags, leaves) == root;
}
/**
* @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
* proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
* leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
* respectively.
*
* This version handles multiproofs in calldata with the default hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
* is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
* tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
*
* NOTE: The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op,
* and therefore a valid multiproof (i.e. it returns `proof[0]`). Consider disallowing this case if you're not
* validating the leaves elsewhere.
*/
function processMultiProofCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
// This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the Merkle tree.
uint256 leavesLen = leaves.length;
uint256 proofFlagsLen = proofFlags.length;
// Check proof validity.
if (leavesLen + proof.length != proofFlagsLen + 1) {
revert MerkleProofInvalidMultiproof();
}
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](proofFlagsLen);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < proofFlagsLen; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i]
? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
: proof[proofPos++];
hashes[i] = Hashes.commutativeKeccak256(a, b);
}
if (proofFlagsLen > 0) {
if (proofPos != proof.length) {
revert MerkleProofInvalidMultiproof();
}
unchecked {
return hashes[proofFlagsLen - 1];
}
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
/**
* @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
* `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
*
* This version handles multiproofs in calldata with a custom hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
*
* NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`.
* The `leaves` must be validated independently. See {processMultiProofCalldata}.
*/
function multiProofVerifyCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32 root,
bytes32[] memory leaves,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bool) {
return processMultiProofCalldata(proof, proofFlags, leaves, hasher) == root;
}
/**
* @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
* proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
* leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
* respectively.
*
* This version handles multiproofs in calldata with a custom hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
* is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
* tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
*
* NOTE: The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op,
* and therefore a valid multiproof (i.e. it returns `proof[0]`). Consider disallowing this case if you're not
* validating the leaves elsewhere.
*/
function processMultiProofCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32[] memory leaves,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bytes32 merkleRoot) {
// This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the Merkle tree.
uint256 leavesLen = leaves.length;
uint256 proofFlagsLen = proofFlags.length;
// Check proof validity.
if (leavesLen + proof.length != proofFlagsLen + 1) {
revert MerkleProofInvalidMultiproof();
}
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](proofFlagsLen);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < proofFlagsLen; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i]
? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
: proof[proofPos++];
hashes[i] = hasher(a, b);
}
if (proofFlagsLen > 0) {
if (proofPos != proof.length) {
revert MerkleProofInvalidMultiproof();
}
unchecked {
return hashes[proofFlagsLen - 1];
}
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.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 to signal 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.3.0) (utils/structs/Checkpoints.sol)
// This file was procedurally generated from scripts/generate/templates/Checkpoints.js.
pragma solidity ^0.8.20;
import {Math} from "../math/Math.sol";
/**
* @dev This library defines the `Trace*` struct, for checkpointing values as they change at different points in
* time, and later looking up past values by block number. See {Votes} as an example.
*
* To create a history of checkpoints define a variable type `Checkpoints.Trace*` in your contract, and store a new
* checkpoint for the current transaction block using the {push} function.
*/
library Checkpoints {
/**
* @dev A value was attempted to be inserted on a past checkpoint.
*/
error CheckpointUnorderedInsertion();
struct Trace224 {
Checkpoint224[] _checkpoints;
}
struct Checkpoint224 {
uint32 _key;
uint224 _value;
}
/**
* @dev Pushes a (`key`, `value`) pair into a Trace224 so that it is stored as the checkpoint.
*
* Returns previous value and new value.
*
* IMPORTANT: Never accept `key` as a user input, since an arbitrary `type(uint32).max` key set will disable the
* library.
*/
function push(
Trace224 storage self,
uint32 key,
uint224 value
) internal returns (uint224 oldValue, uint224 newValue) {
return _insert(self._checkpoints, key, value);
}
/**
* @dev Returns the value in the first (oldest) checkpoint with key greater or equal than the search key, or zero if
* there is none.
*/
function lowerLookup(Trace224 storage self, uint32 key) internal view returns (uint224) {
uint256 len = self._checkpoints.length;
uint256 pos = _lowerBinaryLookup(self._checkpoints, key, 0, len);
return pos == len ? 0 : _unsafeAccess(self._checkpoints, pos)._value;
}
/**
* @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero
* if there is none.
*/
function upperLookup(Trace224 storage self, uint32 key) internal view returns (uint224) {
uint256 len = self._checkpoints.length;
uint256 pos = _upperBinaryLookup(self._checkpoints, key, 0, len);
return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;
}
/**
* @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero
* if there is none.
*
* NOTE: This is a variant of {upperLookup} that is optimised to find "recent" checkpoint (checkpoints with high
* keys).
*/
function upperLookupRecent(Trace224 storage self, uint32 key) internal view returns (uint224) {
uint256 len = self._checkpoints.length;
uint256 low = 0;
uint256 high = len;
if (len > 5) {
uint256 mid = len - Math.sqrt(len);
if (key < _unsafeAccess(self._checkpoints, mid)._key) {
high = mid;
} else {
low = mid + 1;
}
}
uint256 pos = _upperBinaryLookup(self._checkpoints, key, low, high);
return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;
}
/**
* @dev Returns the value in the most recent checkpoint, or zero if there are no checkpoints.
*/
function latest(Trace224 storage self) internal view returns (uint224) {
uint256 pos = self._checkpoints.length;
return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;
}
/**
* @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value
* in the most recent checkpoint.
*/
function latestCheckpoint(Trace224 storage self) internal view returns (bool exists, uint32 _key, uint224 _value) {
uint256 pos = self._checkpoints.length;
if (pos == 0) {
return (false, 0, 0);
} else {
Checkpoint224 storage ckpt = _unsafeAccess(self._checkpoints, pos - 1);
return (true, ckpt._key, ckpt._value);
}
}
/**
* @dev Returns the number of checkpoints.
*/
function length(Trace224 storage self) internal view returns (uint256) {
return self._checkpoints.length;
}
/**
* @dev Returns checkpoint at given position.
*/
function at(Trace224 storage self, uint32 pos) internal view returns (Checkpoint224 memory) {
return self._checkpoints[pos];
}
/**
* @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint,
* or by updating the last one.
*/
function _insert(
Checkpoint224[] storage self,
uint32 key,
uint224 value
) private returns (uint224 oldValue, uint224 newValue) {
uint256 pos = self.length;
if (pos > 0) {
Checkpoint224 storage last = _unsafeAccess(self, pos - 1);
uint32 lastKey = last._key;
uint224 lastValue = last._value;
// Checkpoint keys must be non-decreasing.
if (lastKey > key) {
revert CheckpointUnorderedInsertion();
}
// Update or push new checkpoint
if (lastKey == key) {
last._value = value;
} else {
self.push(Checkpoint224({_key: key, _value: value}));
}
return (lastValue, value);
} else {
self.push(Checkpoint224({_key: key, _value: value}));
return (0, value);
}
}
/**
* @dev Return the index of the first (oldest) checkpoint with key strictly bigger than the search key, or `high`
* if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and exclusive
* `high`.
*
* WARNING: `high` should not be greater than the array's length.
*/
function _upperBinaryLookup(
Checkpoint224[] storage self,
uint32 key,
uint256 low,
uint256 high
) private view returns (uint256) {
while (low < high) {
uint256 mid = Math.average(low, high);
if (_unsafeAccess(self, mid)._key > key) {
high = mid;
} else {
low = mid + 1;
}
}
return high;
}
/**
* @dev Return the index of the first (oldest) checkpoint with key greater or equal than the search key, or `high`
* if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and exclusive
* `high`.
*
* WARNING: `high` should not be greater than the array's length.
*/
function _lowerBinaryLookup(
Checkpoint224[] storage self,
uint32 key,
uint256 low,
uint256 high
) private view returns (uint256) {
while (low < high) {
uint256 mid = Math.average(low, high);
if (_unsafeAccess(self, mid)._key < key) {
low = mid + 1;
} else {
high = mid;
}
}
return high;
}
/**
* @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds.
*/
function _unsafeAccess(
Checkpoint224[] storage self,
uint256 pos
) private pure returns (Checkpoint224 storage result) {
assembly {
mstore(0, self.slot)
result.slot := add(keccak256(0, 0x20), pos)
}
}
struct Trace208 {
Checkpoint208[] _checkpoints;
}
struct Checkpoint208 {
uint48 _key;
uint208 _value;
}
/**
* @dev Pushes a (`key`, `value`) pair into a Trace208 so that it is stored as the checkpoint.
*
* Returns previous value and new value.
*
* IMPORTANT: Never accept `key` as a user input, since an arbitrary `type(uint48).max` key set will disable the
* library.
*/
function push(
Trace208 storage self,
uint48 key,
uint208 value
) internal returns (uint208 oldValue, uint208 newValue) {
return _insert(self._checkpoints, key, value);
}
/**
* @dev Returns the value in the first (oldest) checkpoint with key greater or equal than the search key, or zero if
* there is none.
*/
function lowerLookup(Trace208 storage self, uint48 key) internal view returns (uint208) {
uint256 len = self._checkpoints.length;
uint256 pos = _lowerBinaryLookup(self._checkpoints, key, 0, len);
return pos == len ? 0 : _unsafeAccess(self._checkpoints, pos)._value;
}
/**
* @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero
* if there is none.
*/
function upperLookup(Trace208 storage self, uint48 key) internal view returns (uint208) {
uint256 len = self._checkpoints.length;
uint256 pos = _upperBinaryLookup(self._checkpoints, key, 0, len);
return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;
}
/**
* @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero
* if there is none.
*
* NOTE: This is a variant of {upperLookup} that is optimised to find "recent" checkpoint (checkpoints with high
* keys).
*/
function upperLookupRecent(Trace208 storage self, uint48 key) internal view returns (uint208) {
uint256 len = self._checkpoints.length;
uint256 low = 0;
uint256 high = len;
if (len > 5) {
uint256 mid = len - Math.sqrt(len);
if (key < _unsafeAccess(self._checkpoints, mid)._key) {
high = mid;
} else {
low = mid + 1;
}
}
uint256 pos = _upperBinaryLookup(self._checkpoints, key, low, high);
return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;
}
/**
* @dev Returns the value in the most recent checkpoint, or zero if there are no checkpoints.
*/
function latest(Trace208 storage self) internal view returns (uint208) {
uint256 pos = self._checkpoints.length;
return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;
}
/**
* @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value
* in the most recent checkpoint.
*/
function latestCheckpoint(Trace208 storage self) internal view returns (bool exists, uint48 _key, uint208 _value) {
uint256 pos = self._checkpoints.length;
if (pos == 0) {
return (false, 0, 0);
} else {
Checkpoint208 storage ckpt = _unsafeAccess(self._checkpoints, pos - 1);
return (true, ckpt._key, ckpt._value);
}
}
/**
* @dev Returns the number of checkpoints.
*/
function length(Trace208 storage self) internal view returns (uint256) {
return self._checkpoints.length;
}
/**
* @dev Returns checkpoint at given position.
*/
function at(Trace208 storage self, uint32 pos) internal view returns (Checkpoint208 memory) {
return self._checkpoints[pos];
}
/**
* @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint,
* or by updating the last one.
*/
function _insert(
Checkpoint208[] storage self,
uint48 key,
uint208 value
) private returns (uint208 oldValue, uint208 newValue) {
uint256 pos = self.length;
if (pos > 0) {
Checkpoint208 storage last = _unsafeAccess(self, pos - 1);
uint48 lastKey = last._key;
uint208 lastValue = last._value;
// Checkpoint keys must be non-decreasing.
if (lastKey > key) {
revert CheckpointUnorderedInsertion();
}
// Update or push new checkpoint
if (lastKey == key) {
last._value = value;
} else {
self.push(Checkpoint208({_key: key, _value: value}));
}
return (lastValue, value);
} else {
self.push(Checkpoint208({_key: key, _value: value}));
return (0, value);
}
}
/**
* @dev Return the index of the first (oldest) checkpoint with key strictly bigger than the search key, or `high`
* if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and exclusive
* `high`.
*
* WARNING: `high` should not be greater than the array's length.
*/
function _upperBinaryLookup(
Checkpoint208[] storage self,
uint48 key,
uint256 low,
uint256 high
) private view returns (uint256) {
while (low < high) {
uint256 mid = Math.average(low, high);
if (_unsafeAccess(self, mid)._key > key) {
high = mid;
} else {
low = mid + 1;
}
}
return high;
}
/**
* @dev Return the index of the first (oldest) checkpoint with key greater or equal than the search key, or `high`
* if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and exclusive
* `high`.
*
* WARNING: `high` should not be greater than the array's length.
*/
function _lowerBinaryLookup(
Checkpoint208[] storage self,
uint48 key,
uint256 low,
uint256 high
) private view returns (uint256) {
while (low < high) {
uint256 mid = Math.average(low, high);
if (_unsafeAccess(self, mid)._key < key) {
low = mid + 1;
} else {
high = mid;
}
}
return high;
}
/**
* @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds.
*/
function _unsafeAccess(
Checkpoint208[] storage self,
uint256 pos
) private pure returns (Checkpoint208 storage result) {
assembly {
mstore(0, self.slot)
result.slot := add(keccak256(0, 0x20), pos)
}
}
struct Trace160 {
Checkpoint160[] _checkpoints;
}
struct Checkpoint160 {
uint96 _key;
uint160 _value;
}
/**
* @dev Pushes a (`key`, `value`) pair into a Trace160 so that it is stored as the checkpoint.
*
* Returns previous value and new value.
*
* IMPORTANT: Never accept `key` as a user input, since an arbitrary `type(uint96).max` key set will disable the
* library.
*/
function push(
Trace160 storage self,
uint96 key,
uint160 value
) internal returns (uint160 oldValue, uint160 newValue) {
return _insert(self._checkpoints, key, value);
}
/**
* @dev Returns the value in the first (oldest) checkpoint with key greater or equal than the search key, or zero if
* there is none.
*/
function lowerLookup(Trace160 storage self, uint96 key) internal view returns (uint160) {
uint256 len = self._checkpoints.length;
uint256 pos = _lowerBinaryLookup(self._checkpoints, key, 0, len);
return pos == len ? 0 : _unsafeAccess(self._checkpoints, pos)._value;
}
/**
* @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero
* if there is none.
*/
function upperLookup(Trace160 storage self, uint96 key) internal view returns (uint160) {
uint256 len = self._checkpoints.length;
uint256 pos = _upperBinaryLookup(self._checkpoints, key, 0, len);
return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;
}
/**
* @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero
* if there is none.
*
* NOTE: This is a variant of {upperLookup} that is optimised to find "recent" checkpoint (checkpoints with high
* keys).
*/
function upperLookupRecent(Trace160 storage self, uint96 key) internal view returns (uint160) {
uint256 len = self._checkpoints.length;
uint256 low = 0;
uint256 high = len;
if (len > 5) {
uint256 mid = len - Math.sqrt(len);
if (key < _unsafeAccess(self._checkpoints, mid)._key) {
high = mid;
} else {
low = mid + 1;
}
}
uint256 pos = _upperBinaryLookup(self._checkpoints, key, low, high);
return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;
}
/**
* @dev Returns the value in the most recent checkpoint, or zero if there are no checkpoints.
*/
function latest(Trace160 storage self) internal view returns (uint160) {
uint256 pos = self._checkpoints.length;
return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;
}
/**
* @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value
* in the most recent checkpoint.
*/
function latestCheckpoint(Trace160 storage self) internal view returns (bool exists, uint96 _key, uint160 _value) {
uint256 pos = self._checkpoints.length;
if (pos == 0) {
return (false, 0, 0);
} else {
Checkpoint160 storage ckpt = _unsafeAccess(self._checkpoints, pos - 1);
return (true, ckpt._key, ckpt._value);
}
}
/**
* @dev Returns the number of checkpoints.
*/
function length(Trace160 storage self) internal view returns (uint256) {
return self._checkpoints.length;
}
/**
* @dev Returns checkpoint at given position.
*/
function at(Trace160 storage self, uint32 pos) internal view returns (Checkpoint160 memory) {
return self._checkpoints[pos];
}
/**
* @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint,
* or by updating the last one.
*/
function _insert(
Checkpoint160[] storage self,
uint96 key,
uint160 value
) private returns (uint160 oldValue, uint160 newValue) {
uint256 pos = self.length;
if (pos > 0) {
Checkpoint160 storage last = _unsafeAccess(self, pos - 1);
uint96 lastKey = last._key;
uint160 lastValue = last._value;
// Checkpoint keys must be non-decreasing.
if (lastKey > key) {
revert CheckpointUnorderedInsertion();
}
// Update or push new checkpoint
if (lastKey == key) {
last._value = value;
} else {
self.push(Checkpoint160({_key: key, _value: value}));
}
return (lastValue, value);
} else {
self.push(Checkpoint160({_key: key, _value: value}));
return (0, value);
}
}
/**
* @dev Return the index of the first (oldest) checkpoint with key strictly bigger than the search key, or `high`
* if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and exclusive
* `high`.
*
* WARNING: `high` should not be greater than the array's length.
*/
function _upperBinaryLookup(
Checkpoint160[] storage self,
uint96 key,
uint256 low,
uint256 high
) private view returns (uint256) {
while (low < high) {
uint256 mid = Math.average(low, high);
if (_unsafeAccess(self, mid)._key > key) {
high = mid;
} else {
low = mid + 1;
}
}
return high;
}
/**
* @dev Return the index of the first (oldest) checkpoint with key greater or equal than the search key, or `high`
* if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and exclusive
* `high`.
*
* WARNING: `high` should not be greater than the array's length.
*/
function _lowerBinaryLookup(
Checkpoint160[] storage self,
uint96 key,
uint256 low,
uint256 high
) private view returns (uint256) {
while (low < high) {
uint256 mid = Math.average(low, high);
if (_unsafeAccess(self, mid)._key < key) {
low = mid + 1;
} else {
high = mid;
}
}
return high;
}
/**
* @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds.
*/
function _unsafeAccess(
Checkpoint160[] storage self,
uint256 pos
) private pure returns (Checkpoint160 storage result) {
assembly {
mstore(0, self.slot)
result.slot := add(keccak256(0, 0x20), pos)
}
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.25;
/// @title FenwickTreeLibrary
/// @notice Implements a 0-indexed Fenwick Tree (Binary Indexed Tree) for prefix sum operations.
/// @dev Enables efficient updates and prefix sum queries over a dynamic array.
///
/// # Overview
/// Fenwick Tree is a compact data structure optimized for cumulative frequency computations:
/// - `update(i, delta)` increments the element at index `i` by signed `delta`.
/// - `prefixSum(i)` returns the sum of elements in the range `[0, i]`.
///
/// This library provides:
/// - `O(log n)` time complexity for updates and prefix queries.
/// - `O(1)` fixed cost for extending the tree by doubling its capacity.
/// - Support only for arrays whose lengths are powers of two (2^k).
///
/// # References
/// - https://cp-algorithms.com/data_structures/fenwick.html
/// - https://en.wikipedia.org/wiki/Fenwick_tree
library FenwickTreeLibrary {
/// @notice Thrown when initializing with an invalid length (must be power of 2 and nonzero), or during overflow.
error InvalidLength();
/// @notice Thrown when an index is outside the bounds of the tree.
error IndexOutOfBounds();
/// @notice Internal Fenwick Tree structure using a mapping as a flat array.
struct Tree {
/// @notice Mapping of index to its cumulative value.
mapping(uint256 index => int256) _values;
/// @notice Length of the tree (must be a power of 2).
uint256 _length;
}
/// @notice Initializes the tree with a given length (must be > 0 and power of 2).
/// @param tree The Fenwick tree to initialize.
/// @param length_ The length of the tree.
function initialize(Tree storage tree, uint256 length_) internal {
if (tree._length != 0 || length_ == 0 || (length_ & (length_ - 1)) != 0) {
revert InvalidLength();
}
tree._length = length_;
}
/// @notice Returns the current size of the tree.
/// @param tree The Fenwick tree.
/// @return The length of the tree.
function length(Tree storage tree) internal view returns (uint256) {
return tree._length;
}
/// @notice Doubles the length of the Fenwick tree while preserving internal state.
/// @param tree The Fenwick tree to be extended.
function extend(Tree storage tree) internal {
uint256 length_ = tree._length;
if (length_ >= (1 << 255)) {
revert InvalidLength();
}
tree._length = length_ << 1;
tree._values[(length_ << 1) - 1] = tree._values[length_ - 1];
}
/// @notice Updates the tree at the specified index by a given delta.
/// @param tree The Fenwick tree.
/// @param index Index to modify.
/// @param value Value to add (can be negative).
function modify(Tree storage tree, uint256 index, int256 value) internal {
uint256 length_ = tree._length;
if (index >= length_) {
revert IndexOutOfBounds();
}
if (value == 0) {
return;
}
_modify(tree, index, length_, value);
}
/// @dev Internal function to apply Fenwick update logic.
/// @param tree The Fenwick tree.
/// @param index Index to start updating from.
/// @param length_ Length of the tree.
/// @param value Value to add.
function _modify(Tree storage tree, uint256 index, uint256 length_, int256 value) private {
while (index < length_) {
tree._values[index] += value;
index |= index + 1;
}
}
/// @notice Returns the prefix sum from index 0 to `index` (inclusive).
/// @param tree The Fenwick tree.
/// @param index Right bound index for sum (inclusive).
/// @return prefixSum The sum of values from index 0 to `index`.
function get(Tree storage tree, uint256 index) internal view returns (int256) {
uint256 length_ = tree._length;
if (index >= length_) {
index = length_ - 1;
}
return _get(tree, index);
}
/// @dev Internal function to compute prefix sum up to `index`.
/// @param tree The Fenwick tree.
/// @param index Right bound index for sum (inclusive).
/// @return prefixSum The cumulative sum up to and including `index`.
function _get(Tree storage tree, uint256 index) private view returns (int256 prefixSum) {
assembly ("memory-safe") {
mstore(0x20, tree.slot)
for {} 1 { index := sub(index, 1) } {
mstore(0x00, index)
prefixSum := add(prefixSum, sload(keccak256(0x00, 0x40)))
index := and(index, add(index, 1))
if iszero(index) { break }
}
}
}
/// @notice Returns the sum over the interval [from, to].
/// @param tree The Fenwick tree.
/// @param from Left bound index (inclusive).
/// @param to Right bound index (inclusive).
/// @return The sum over the specified interval.
function get(Tree storage tree, uint256 from, uint256 to) internal view returns (int256) {
if (from > to) {
return 0;
}
return _get(tree, to) - (from == 0 ? int256(0) : _get(tree, from - 1));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/structs/EnumerableMap.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableMap.js.
pragma solidity ^0.8.20;
import {EnumerableSet} from "./EnumerableSet.sol";
/**
* @dev Library for managing an enumerable variant of Solidity's
* https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`]
* type.
*
* Maps have the following properties:
*
* - Entries are added, removed, and checked for existence in constant time
* (O(1)).
* - Entries are enumerated in O(n). No guarantees are made on the ordering.
* - Map can be cleared (all entries removed) in O(n).
*
* ```solidity
* contract Example {
* // Add the library methods
* using EnumerableMap for EnumerableMap.UintToAddressMap;
*
* // Declare a set state variable
* EnumerableMap.UintToAddressMap private myMap;
* }
* ```
*
* The following map types are supported:
*
* - `uint256 -> address` (`UintToAddressMap`) since v3.0.0
* - `address -> uint256` (`AddressToUintMap`) since v4.6.0
* - `bytes32 -> bytes32` (`Bytes32ToBytes32Map`) since v4.6.0
* - `uint256 -> uint256` (`UintToUintMap`) since v4.7.0
* - `bytes32 -> uint256` (`Bytes32ToUintMap`) since v4.7.0
* - `uint256 -> bytes32` (`UintToBytes32Map`) since v5.1.0
* - `address -> address` (`AddressToAddressMap`) since v5.1.0
* - `address -> bytes32` (`AddressToBytes32Map`) since v5.1.0
* - `bytes32 -> address` (`Bytes32ToAddressMap`) since v5.1.0
*
* [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 EnumerableMap, you can either remove all elements one by one or create a fresh instance using an
* array of EnumerableMap.
* ====
*/
library EnumerableMap {
using EnumerableSet for EnumerableSet.Bytes32Set;
// To implement this library for multiple types with as little code repetition as possible, we write it in
// terms of a generic Map type with bytes32 keys and values. The Map implementation uses private functions,
// and user-facing implementations such as `UintToAddressMap` are just wrappers around the underlying Map.
// This means that we can only create new EnumerableMaps for types that fit in bytes32.
/**
* @dev Query for a nonexistent map key.
*/
error EnumerableMapNonexistentKey(bytes32 key);
struct Bytes32ToBytes32Map {
// Storage of keys
EnumerableSet.Bytes32Set _keys;
mapping(bytes32 key => bytes32) _values;
}
/**
* @dev Adds a key-value pair to a map, or updates the value for an existing
* key. O(1).
*
* Returns true if the key was added to the map, that is if it was not
* already present.
*/
function set(Bytes32ToBytes32Map storage map, bytes32 key, bytes32 value) internal returns (bool) {
map._values[key] = value;
return map._keys.add(key);
}
/**
* @dev Removes a key-value pair from a map. O(1).
*
* Returns true if the key was removed from the map, that is if it was present.
*/
function remove(Bytes32ToBytes32Map storage map, bytes32 key) internal returns (bool) {
delete map._values[key];
return map._keys.remove(key);
}
/**
* @dev Removes all the entries from a map. O(n).
*
* WARNING: Developers should keep in mind that this function has an unbounded cost and using it may render the
* function uncallable if the map grows to the point where clearing it consumes too much gas to fit in a block.
*/
function clear(Bytes32ToBytes32Map storage map) internal {
uint256 len = length(map);
for (uint256 i = 0; i < len; ++i) {
delete map._values[map._keys.at(i)];
}
map._keys.clear();
}
/**
* @dev Returns true if the key is in the map. O(1).
*/
function contains(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool) {
return map._keys.contains(key);
}
/**
* @dev Returns the number of key-value pairs in the map. O(1).
*/
function length(Bytes32ToBytes32Map storage map) internal view returns (uint256) {
return map._keys.length();
}
/**
* @dev Returns the key-value pair stored at position `index` in the map. O(1).
*
* Note that there are no guarantees on the ordering of entries inside the
* array, and it may change when more entries are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32ToBytes32Map storage map, uint256 index) internal view returns (bytes32 key, bytes32 value) {
bytes32 atKey = map._keys.at(index);
return (atKey, map._values[atKey]);
}
/**
* @dev Tries to returns the value associated with `key`. O(1).
* Does not revert if `key` is not in the map.
*/
function tryGet(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool exists, bytes32 value) {
bytes32 val = map._values[key];
if (val == bytes32(0)) {
return (contains(map, key), bytes32(0));
} else {
return (true, val);
}
}
/**
* @dev Returns the value associated with `key`. O(1).
*
* Requirements:
*
* - `key` must be in the map.
*/
function get(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bytes32) {
bytes32 value = map._values[key];
if (value == 0 && !contains(map, key)) {
revert EnumerableMapNonexistentKey(key);
}
return value;
}
/**
* @dev Return the an array containing all the keys
*
* 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 map grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function keys(Bytes32ToBytes32Map storage map) internal view returns (bytes32[] memory) {
return map._keys.values();
}
// UintToUintMap
struct UintToUintMap {
Bytes32ToBytes32Map _inner;
}
/**
* @dev Adds a key-value pair to a map, or updates the value for an existing
* key. O(1).
*
* Returns true if the key was added to the map, that is if it was not
* already present.
*/
function set(UintToUintMap storage map, uint256 key, uint256 value) internal returns (bool) {
return set(map._inner, bytes32(key), bytes32(value));
}
/**
* @dev Removes a value from a map. O(1).
*
* Returns true if the key was removed from the map, that is if it was present.
*/
function remove(UintToUintMap storage map, uint256 key) internal returns (bool) {
return remove(map._inner, bytes32(key));
}
/**
* @dev Removes all the entries from a map. O(n).
*
* WARNING: Developers should keep in mind that this function has an unbounded cost and using it may render the
* function uncallable if the map grows to the point where clearing it consumes too much gas to fit in a block.
*/
function clear(UintToUintMap storage map) internal {
clear(map._inner);
}
/**
* @dev Returns true if the key is in the map. O(1).
*/
function contains(UintToUintMap storage map, uint256 key) internal view returns (bool) {
return contains(map._inner, bytes32(key));
}
/**
* @dev Returns the number of elements in the map. O(1).
*/
function length(UintToUintMap storage map) internal view returns (uint256) {
return length(map._inner);
}
/**
* @dev Returns the element stored at position `index` in the map. 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(UintToUintMap storage map, uint256 index) internal view returns (uint256 key, uint256 value) {
(bytes32 atKey, bytes32 val) = at(map._inner, index);
return (uint256(atKey), uint256(val));
}
/**
* @dev Tries to returns the value associated with `key`. O(1).
* Does not revert if `key` is not in the map.
*/
function tryGet(UintToUintMap storage map, uint256 key) internal view returns (bool exists, uint256 value) {
(bool success, bytes32 val) = tryGet(map._inner, bytes32(key));
return (success, uint256(val));
}
/**
* @dev Returns the value associated with `key`. O(1).
*
* Requirements:
*
* - `key` must be in the map.
*/
function get(UintToUintMap storage map, uint256 key) internal view returns (uint256) {
return uint256(get(map._inner, bytes32(key)));
}
/**
* @dev Return the an array containing all the keys
*
* 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 map grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function keys(UintToUintMap storage map) internal view returns (uint256[] memory) {
bytes32[] memory store = keys(map._inner);
uint256[] memory result;
assembly ("memory-safe") {
result := store
}
return result;
}
// UintToAddressMap
struct UintToAddressMap {
Bytes32ToBytes32Map _inner;
}
/**
* @dev Adds a key-value pair to a map, or updates the value for an existing
* key. O(1).
*
* Returns true if the key was added to the map, that is if it was not
* already present.
*/
function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) {
return set(map._inner, bytes32(key), bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a map. O(1).
*
* Returns true if the key was removed from the map, that is if it was present.
*/
function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) {
return remove(map._inner, bytes32(key));
}
/**
* @dev Removes all the entries from a map. O(n).
*
* WARNING: Developers should keep in mind that this function has an unbounded cost and using it may render the
* function uncallable if the map grows to the point where clearing it consumes too much gas to fit in a block.
*/
function clear(UintToAddressMap storage map) internal {
clear(map._inner);
}
/**
* @dev Returns true if the key is in the map. O(1).
*/
function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) {
return contains(map._inner, bytes32(key));
}
/**
* @dev Returns the number of elements in the map. O(1).
*/
function length(UintToAddressMap storage map) internal view returns (uint256) {
return length(map._inner);
}
/**
* @dev Returns the element stored at position `index` in the map. 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(UintToAddressMap storage map, uint256 index) internal view returns (uint256 key, address value) {
(bytes32 atKey, bytes32 val) = at(map._inner, index);
return (uint256(atKey), address(uint160(uint256(val))));
}
/**
* @dev Tries to returns the value associated with `key`. O(1).
* Does not revert if `key` is not in the map.
*/
function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool exists, address value) {
(bool success, bytes32 val) = tryGet(map._inner, bytes32(key));
return (success, address(uint160(uint256(val))));
}
/**
* @dev Returns the value associated with `key`. O(1).
*
* Requirements:
*
* - `key` must be in the map.
*/
function get(UintToAddressMap storage map, uint256 key) internal view returns (address) {
return address(uint160(uint256(get(map._inner, bytes32(key)))));
}
/**
* @dev Return the an array containing all the keys
*
* 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 map grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function keys(UintToAddressMap storage map) internal view returns (uint256[] memory) {
bytes32[] memory store = keys(map._inner);
uint256[] memory result;
assembly ("memory-safe") {
result := store
}
return result;
}
// UintToBytes32Map
struct UintToBytes32Map {
Bytes32ToBytes32Map _inner;
}
/**
* @dev Adds a key-value pair to a map, or updates the value for an existing
* key. O(1).
*
* Returns true if the key was added to the map, that is if it was not
* already present.
*/
function set(UintToBytes32Map storage map, uint256 key, bytes32 value) internal returns (bool) {
return set(map._inner, bytes32(key), value);
}
/**
* @dev Removes a value from a map. O(1).
*
* Returns true if the key was removed from the map, that is if it was present.
*/
function remove(UintToBytes32Map storage map, uint256 key) internal returns (bool) {
return remove(map._inner, bytes32(key));
}
/**
* @dev Removes all the entries from a map. O(n).
*
* WARNING: Developers should keep in mind that this function has an unbounded cost and using it may render the
* function uncallable if the map grows to the point where clearing it consumes too much gas to fit in a block.
*/
function clear(UintToBytes32Map storage map) internal {
clear(map._inner);
}
/**
* @dev Returns true if the key is in the map. O(1).
*/
function contains(UintToBytes32Map storage map, uint256 key) internal view returns (bool) {
return contains(map._inner, bytes32(key));
}
/**
* @dev Returns the number of elements in the map. O(1).
*/
function length(UintToBytes32Map storage map) internal view returns (uint256) {
return length(map._inner);
}
/**
* @dev Returns the element stored at position `index` in the map. 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(UintToBytes32Map storage map, uint256 index) internal view returns (uint256 key, bytes32 value) {
(bytes32 atKey, bytes32 val) = at(map._inner, index);
return (uint256(atKey), val);
}
/**
* @dev Tries to returns the value associated with `key`. O(1).
* Does not revert if `key` is not in the map.
*/
function tryGet(UintToBytes32Map storage map, uint256 key) internal view returns (bool exists, bytes32 value) {
(bool success, bytes32 val) = tryGet(map._inner, bytes32(key));
return (success, val);
}
/**
* @dev Returns the value associated with `key`. O(1).
*
* Requirements:
*
* - `key` must be in the map.
*/
function get(UintToBytes32Map storage map, uint256 key) internal view returns (bytes32) {
return get(map._inner, bytes32(key));
}
/**
* @dev Return the an array containing all the keys
*
* 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 map grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function keys(UintToBytes32Map storage map) internal view returns (uint256[] memory) {
bytes32[] memory store = keys(map._inner);
uint256[] memory result;
assembly ("memory-safe") {
result := store
}
return result;
}
// AddressToUintMap
struct AddressToUintMap {
Bytes32ToBytes32Map _inner;
}
/**
* @dev Adds a key-value pair to a map, or updates the value for an existing
* key. O(1).
*
* Returns true if the key was added to the map, that is if it was not
* already present.
*/
function set(AddressToUintMap storage map, address key, uint256 value) internal returns (bool) {
return set(map._inner, bytes32(uint256(uint160(key))), bytes32(value));
}
/**
* @dev Removes a value from a map. O(1).
*
* Returns true if the key was removed from the map, that is if it was present.
*/
function remove(AddressToUintMap storage map, address key) internal returns (bool) {
return remove(map._inner, bytes32(uint256(uint160(key))));
}
/**
* @dev Removes all the entries from a map. O(n).
*
* WARNING: Developers should keep in mind that this function has an unbounded cost and using it may render the
* function uncallable if the map grows to the point where clearing it consumes too much gas to fit in a block.
*/
function clear(AddressToUintMap storage map) internal {
clear(map._inner);
}
/**
* @dev Returns true if the key is in the map. O(1).
*/
function contains(AddressToUintMap storage map, address key) internal view returns (bool) {
return contains(map._inner, bytes32(uint256(uint160(key))));
}
/**
* @dev Returns the number of elements in the map. O(1).
*/
function length(AddressToUintMap storage map) internal view returns (uint256) {
return length(map._inner);
}
/**
* @dev Returns the element stored at position `index` in the map. 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(AddressToUintMap storage map, uint256 index) internal view returns (address key, uint256 value) {
(bytes32 atKey, bytes32 val) = at(map._inner, index);
return (address(uint160(uint256(atKey))), uint256(val));
}
/**
* @dev Tries to returns the value associated with `key`. O(1).
* Does not revert if `key` is not in the map.
*/
function tryGet(AddressToUintMap storage map, address key) internal view returns (bool exists, uint256 value) {
(bool success, bytes32 val) = tryGet(map._inner, bytes32(uint256(uint160(key))));
return (success, uint256(val));
}
/**
* @dev Returns the value associated with `key`. O(1).
*
* Requirements:
*
* - `key` must be in the map.
*/
function get(AddressToUintMap storage map, address key) internal view returns (uint256) {
return uint256(get(map._inner, bytes32(uint256(uint160(key)))));
}
/**
* @dev Return the an array containing all the keys
*
* 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 map grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function keys(AddressToUintMap storage map) internal view returns (address[] memory) {
bytes32[] memory store = keys(map._inner);
address[] memory result;
assembly ("memory-safe") {
result := store
}
return result;
}
// AddressToAddressMap
struct AddressToAddressMap {
Bytes32ToBytes32Map _inner;
}
/**
* @dev Adds a key-value pair to a map, or updates the value for an existing
* key. O(1).
*
* Returns true if the key was added to the map, that is if it was not
* already present.
*/
function set(AddressToAddressMap storage map, address key, address value) internal returns (bool) {
return set(map._inner, bytes32(uint256(uint160(key))), bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a map. O(1).
*
* Returns true if the key was removed from the map, that is if it was present.
*/
function remove(AddressToAddressMap storage map, address key) internal returns (bool) {
return remove(map._inner, bytes32(uint256(uint160(key))));
}
/**
* @dev Removes all the entries from a map. O(n).
*
* WARNING: Developers should keep in mind that this function has an unbounded cost and using it may render the
* function uncallable if the map grows to the point where clearing it consumes too much gas to fit in a block.
*/
function clear(AddressToAddressMap storage map) internal {
clear(map._inner);
}
/**
* @dev Returns true if the key is in the map. O(1).
*/
function contains(AddressToAddressMap storage map, address key) internal view returns (bool) {
return contains(map._inner, bytes32(uint256(uint160(key))));
}
/**
* @dev Returns the number of elements in the map. O(1).
*/
function length(AddressToAddressMap storage map) internal view returns (uint256) {
return length(map._inner);
}
/**
* @dev Returns the element stored at position `index` in the map. 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(AddressToAddressMap storage map, uint256 index) internal view returns (address key, address value) {
(bytes32 atKey, bytes32 val) = at(map._inner, index);
return (address(uint160(uint256(atKey))), address(uint160(uint256(val))));
}
/**
* @dev Tries to returns the value associated with `key`. O(1).
* Does not revert if `key` is not in the map.
*/
function tryGet(AddressToAddressMap storage map, address key) internal view returns (bool exists, address value) {
(bool success, bytes32 val) = tryGet(map._inner, bytes32(uint256(uint160(key))));
return (success, address(uint160(uint256(val))));
}
/**
* @dev Returns the value associated with `key`. O(1).
*
* Requirements:
*
* - `key` must be in the map.
*/
function get(AddressToAddressMap storage map, address key) internal view returns (address) {
return address(uint160(uint256(get(map._inner, bytes32(uint256(uint160(key)))))));
}
/**
* @dev Return the an array containing all the keys
*
* 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 map grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function keys(AddressToAddressMap storage map) internal view returns (address[] memory) {
bytes32[] memory store = keys(map._inner);
address[] memory result;
assembly ("memory-safe") {
result := store
}
return result;
}
// AddressToBytes32Map
struct AddressToBytes32Map {
Bytes32ToBytes32Map _inner;
}
/**
* @dev Adds a key-value pair to a map, or updates the value for an existing
* key. O(1).
*
* Returns true if the key was added to the map, that is if it was not
* already present.
*/
function set(AddressToBytes32Map storage map, address key, bytes32 value) internal returns (bool) {
return set(map._inner, bytes32(uint256(uint160(key))), value);
}
/**
* @dev Removes a value from a map. O(1).
*
* Returns true if the key was removed from the map, that is if it was present.
*/
function remove(AddressToBytes32Map storage map, address key) internal returns (bool) {
return remove(map._inner, bytes32(uint256(uint160(key))));
}
/**
* @dev Removes all the entries from a map. O(n).
*
* WARNING: Developers should keep in mind that this function has an unbounded cost and using it may render the
* function uncallable if the map grows to the point where clearing it consumes too much gas to fit in a block.
*/
function clear(AddressToBytes32Map storage map) internal {
clear(map._inner);
}
/**
* @dev Returns true if the key is in the map. O(1).
*/
function contains(AddressToBytes32Map storage map, address key) internal view returns (bool) {
return contains(map._inner, bytes32(uint256(uint160(key))));
}
/**
* @dev Returns the number of elements in the map. O(1).
*/
function length(AddressToBytes32Map storage map) internal view returns (uint256) {
return length(map._inner);
}
/**
* @dev Returns the element stored at position `index` in the map. 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(AddressToBytes32Map storage map, uint256 index) internal view returns (address key, bytes32 value) {
(bytes32 atKey, bytes32 val) = at(map._inner, index);
return (address(uint160(uint256(atKey))), val);
}
/**
* @dev Tries to returns the value associated with `key`. O(1).
* Does not revert if `key` is not in the map.
*/
function tryGet(AddressToBytes32Map storage map, address key) internal view returns (bool exists, bytes32 value) {
(bool success, bytes32 val) = tryGet(map._inner, bytes32(uint256(uint160(key))));
return (success, val);
}
/**
* @dev Returns the value associated with `key`. O(1).
*
* Requirements:
*
* - `key` must be in the map.
*/
function get(AddressToBytes32Map storage map, address key) internal view returns (bytes32) {
return get(map._inner, bytes32(uint256(uint160(key))));
}
/**
* @dev Return the an array containing all the keys
*
* 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 map grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function keys(AddressToBytes32Map storage map) internal view returns (address[] memory) {
bytes32[] memory store = keys(map._inner);
address[] memory result;
assembly ("memory-safe") {
result := store
}
return result;
}
// Bytes32ToUintMap
struct Bytes32ToUintMap {
Bytes32ToBytes32Map _inner;
}
/**
* @dev Adds a key-value pair to a map, or updates the value for an existing
* key. O(1).
*
* Returns true if the key was added to the map, that is if it was not
* already present.
*/
function set(Bytes32ToUintMap storage map, bytes32 key, uint256 value) internal returns (bool) {
return set(map._inner, key, bytes32(value));
}
/**
* @dev Removes a value from a map. O(1).
*
* Returns true if the key was removed from the map, that is if it was present.
*/
function remove(Bytes32ToUintMap storage map, bytes32 key) internal returns (bool) {
return remove(map._inner, key);
}
/**
* @dev Removes all the entries from a map. O(n).
*
* WARNING: Developers should keep in mind that this function has an unbounded cost and using it may render the
* function uncallable if the map grows to the point where clearing it consumes too much gas to fit in a block.
*/
function clear(Bytes32ToUintMap storage map) internal {
clear(map._inner);
}
/**
* @dev Returns true if the key is in the map. O(1).
*/
function contains(Bytes32ToUintMap storage map, bytes32 key) internal view returns (bool) {
return contains(map._inner, key);
}
/**
* @dev Returns the number of elements in the map. O(1).
*/
function length(Bytes32ToUintMap storage map) internal view returns (uint256) {
return length(map._inner);
}
/**
* @dev Returns the element stored at position `index` in the map. 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(Bytes32ToUintMap storage map, uint256 index) internal view returns (bytes32 key, uint256 value) {
(bytes32 atKey, bytes32 val) = at(map._inner, index);
return (atKey, uint256(val));
}
/**
* @dev Tries to returns the value associated with `key`. O(1).
* Does not revert if `key` is not in the map.
*/
function tryGet(Bytes32ToUintMap storage map, bytes32 key) internal view returns (bool exists, uint256 value) {
(bool success, bytes32 val) = tryGet(map._inner, key);
return (success, uint256(val));
}
/**
* @dev Returns the value associated with `key`. O(1).
*
* Requirements:
*
* - `key` must be in the map.
*/
function get(Bytes32ToUintMap storage map, bytes32 key) internal view returns (uint256) {
return uint256(get(map._inner, key));
}
/**
* @dev Return the an array containing all the keys
*
* 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 map grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function keys(Bytes32ToUintMap storage map) internal view returns (bytes32[] memory) {
bytes32[] memory store = keys(map._inner);
bytes32[] memory result;
assembly ("memory-safe") {
result := store
}
return result;
}
// Bytes32ToAddressMap
struct Bytes32ToAddressMap {
Bytes32ToBytes32Map _inner;
}
/**
* @dev Adds a key-value pair to a map, or updates the value for an existing
* key. O(1).
*
* Returns true if the key was added to the map, that is if it was not
* already present.
*/
function set(Bytes32ToAddressMap storage map, bytes32 key, address value) internal returns (bool) {
return set(map._inner, key, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a map. O(1).
*
* Returns true if the key was removed from the map, that is if it was present.
*/
function remove(Bytes32ToAddressMap storage map, bytes32 key) internal returns (bool) {
return remove(map._inner, key);
}
/**
* @dev Removes all the entries from a map. O(n).
*
* WARNING: Developers should keep in mind that this function has an unbounded cost and using it may render the
* function uncallable if the map grows to the point where clearing it consumes too much gas to fit in a block.
*/
function clear(Bytes32ToAddressMap storage map) internal {
clear(map._inner);
}
/**
* @dev Returns true if the key is in the map. O(1).
*/
function contains(Bytes32ToAddressMap storage map, bytes32 key) internal view returns (bool) {
return contains(map._inner, key);
}
/**
* @dev Returns the number of elements in the map. O(1).
*/
function length(Bytes32ToAddressMap storage map) internal view returns (uint256) {
return length(map._inner);
}
/**
* @dev Returns the element stored at position `index` in the map. 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(Bytes32ToAddressMap storage map, uint256 index) internal view returns (bytes32 key, address value) {
(bytes32 atKey, bytes32 val) = at(map._inner, index);
return (atKey, address(uint160(uint256(val))));
}
/**
* @dev Tries to returns the value associated with `key`. O(1).
* Does not revert if `key` is not in the map.
*/
function tryGet(Bytes32ToAddressMap storage map, bytes32 key) internal view returns (bool exists, address value) {
(bool success, bytes32 val) = tryGet(map._inner, key);
return (success, address(uint160(uint256(val))));
}
/**
* @dev Returns the value associated with `key`. O(1).
*
* Requirements:
*
* - `key` must be in the map.
*/
function get(Bytes32ToAddressMap storage map, bytes32 key) internal view returns (address) {
return address(uint160(uint256(get(map._inner, key))));
}
/**
* @dev Return the an array containing all the keys
*
* 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 map grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function keys(Bytes32ToAddressMap storage map) internal view returns (bytes32[] memory) {
bytes32[] memory store = keys(map._inner);
bytes32[] memory result;
assembly ("memory-safe") {
result := store
}
return result;
}
}// 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.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/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: BUSL-1.1
pragma solidity 0.8.25;
import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol";
import "@openzeppelin/contracts/access/IAccessControl.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "../factories/IFactoryEntity.sol";
import "./ICustomVerifier.sol";
/// @notice Interface for the Verifier contract, used to validate allowed calls via multiple verification mechanisms
interface IVerifier is IFactoryEntity {
/// @notice Thrown when a caller lacks necessary permissions
error Forbidden();
/// @notice Thrown when a call fails verification
error VerificationFailed();
/// @notice Thrown when a required value (e.g. address) is zero
error ZeroValue();
/// @notice Thrown when input array lengths mismatch
error InvalidLength();
/// @notice Thrown when attempting to allow an already allowed CompactCall
error CompactCallAlreadyAllowed(address who, address where, bytes4 selector);
/// @notice Thrown when attempting to disallow a non-existent CompactCall
error CompactCallNotFound(address who, address where, bytes4 selector);
/// @notice Represents a minimal function call format using only selector-level granularity.
/// @dev Used in compact verification where only caller, target, and function selector are validated.
struct CompactCall {
address who; // The address initiating the call (caller)
address where; // The target contract address
bytes4 selector; // 4-byte function selector (first 4 bytes of calldata)
}
/// @notice Represents a full function call with calldata and ETH value.
/// @dev Used in extended verification types where arguments and call value must be validated.
struct ExtendedCall {
address who; // The address initiating the call (caller)
address where; // The target contract address
uint256 value; // ETH value sent with the call
bytes data; // Full calldata (function selector + encoded arguments)
}
/// @notice Internal storage layout used by the Verifier contract.
/// @dev Tracks verification configuration and access control data for calls made by the vault.
struct VerifierStorage {
address vault; // The vault that owns this verifier.
bytes32 merkleRoot; // Root of the Merkle tree used in Merkle-based verification modes
EnumerableSet.Bytes32Set compactCallHashes; // Set of approved hashed CompactCall entries for ONCHAIN_COMPACT verification types
mapping(bytes32 => CompactCall) compactCalls; // Optional mapping to recover original CompactCall from hash
}
/// @notice Enum defining the method used to verify a function call authorization.
enum VerificationType {
/// @dev Compact on-chain verification.
/// Checks if `keccak256(abi.encode(who, where, selector))` exists in the verifier's `compactCallHashes` set.
ONCHAIN_COMPACT,
/// @dev Merkle-based verification of a compact call.
/// Validates a Merkle proof for `keccak256(abi.encode(who, where, selector))` against a stored Merkle root.
MERKLE_COMPACT,
/// @dev Merkle-based verification of an extended call.
/// Validates a Merkle proof for `keccak256(abi.encode(who, where, value, data))` against a stored Merkle root.
MERKLE_EXTENDED,
/// @dev Delegated verification via external contract.
/// Forwards call details `abi.encode(address customVerifier, customVerifierSpecificData)`
/// to a custom verifier contract implementing `ICustomVerifier`.
CUSTOM_VERIFIER
}
/// @notice Struct containing all inputs required to verify a delegated function call.
struct VerificationPayload {
/// @dev The method used to verify the delegated call.
VerificationType verificationType;
/// @dev Encoded payload to be verified, varies by verification type:
/// - ONCHAIN_COMPACT: empty, checking directly that `keccak256(abi.encode(who, where, selector))` is allowed
/// - MERKLE_COMPACT: `abi.encodePacked(keccak256(abi.encode(who, where, selector)))` to validates a Merkle proof
/// - MERKLE_EXTENDED: `abi.encodePacked(keccak256(abi.encode(who, where, value, data)))` to validates a Merkle proof
/// - CUSTOM_VERIFIER: `abi.encode(address customVerifier, customVerifierSpecificData)`
bytes verificationData;
/// @dev Merkle proof used to validate the `verificationType` and `verificationData` for MERKLE_COMPACT,
/// MERKLE_EXTENDED, and CUSTOM_VERIFIER types.
bytes32[] proof;
}
/// @notice Role identifier for setting Merkle root
function SET_MERKLE_ROOT_ROLE() external view returns (bytes32);
/// @notice Role identifier for permitted callers
function CALLER_ROLE() external view returns (bytes32);
/// @notice Role identifier for allowing new CompactCalls
function ALLOW_CALL_ROLE() external view returns (bytes32);
/// @notice Role identifier for removing CompactCalls
function DISALLOW_CALL_ROLE() external view returns (bytes32);
/// @notice Returns the vault associated to this Verifier contract
function vault() external view returns (IAccessControl);
/// @notice Returns the current Merkle root
function merkleRoot() external view returns (bytes32);
/// @notice Returns number of currently allowed compact calls
function allowedCalls() external view returns (uint256);
/// @notice Returns the compact call at a specific index
function allowedCallAt(uint256 index) external view returns (CompactCall memory);
/// @notice Checks if a CompactCall is explicitly allowed
function isAllowedCall(address who, address where, bytes calldata callData) external view returns (bool);
/// @notice Computes the hash of a CompactCall
function hashCall(CompactCall memory call) external pure returns (bytes32);
/// @notice Computes the hash of an ExtendedCall
function hashCall(ExtendedCall memory call) external pure returns (bytes32);
/// @notice Validates a function call using the provided verification payload, reverts on failure
function verifyCall(
address who,
address where,
uint256 value,
bytes calldata data,
VerificationPayload calldata verificationPayload
) external view;
/// @return bool Returns whether a given call passes verification
function getVerificationResult(
address who,
address where,
uint256 value,
bytes calldata callData,
VerificationPayload calldata verificationPayload
) external view returns (bool);
/// @notice Sets the Merkle root used for verification
function setMerkleRoot(bytes32 merkleRoot_) external;
/// @notice Adds a list of CompactCalls to the allowlist
function allowCalls(CompactCall[] calldata compactCalls) external;
/// @notice Removes a list of CompactCalls from the allowlist
function disallowCalls(CompactCall[] calldata compactCalls) external;
/// @notice Emitted when the Merkle root is set
event SetMerkleRoot(bytes32 merkleRoot);
/// @notice Emitted when a new CompactCall is allowed
event AllowCall(address who, address where, bytes4 selector);
/// @notice Emitted when a CompactCall is disallowed
event DisallowCall(address who, address where, bytes4 selector);
}// 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.3.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` from `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.3.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 reinitialization) 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 Pointer to storage slot. Allows integrators to override it with a custom storage location.
*
* NOTE: Consider following the ERC-7201 formula to derive storage locations.
*/
function _initializableStorageSlot() internal pure virtual returns (bytes32) {
return INITIALIZABLE_STORAGE;
}
/**
* @dev Returns a pointer to the storage namespace.
*/
// solhint-disable-next-line var-name-mixedcase
function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
bytes32 slot = _initializableStorageSlot();
assembly {
$.slot := slot
}
}
}// 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: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (proxy/ERC1967/ERC1967Proxy.sol)
pragma solidity ^0.8.22;
import {Proxy} from "../Proxy.sol";
import {ERC1967Utils} from "./ERC1967Utils.sol";
/**
* @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an
* implementation address that can be changed. This address is stored in storage in the location specified by
* https://eips.ethereum.org/EIPS/eip-1967[ERC-1967], so that it doesn't conflict with the storage layout of the
* implementation behind the proxy.
*/
contract ERC1967Proxy is Proxy {
/**
* @dev Initializes the upgradeable proxy with an initial implementation specified by `implementation`.
*
* If `_data` is nonempty, it's used as data in a delegate call to `implementation`. This will typically be an
* encoded function call, and allows initializing the storage of the proxy like a Solidity constructor.
*
* Requirements:
*
* - If `data` is empty, `msg.value` must be zero.
*/
constructor(address implementation, bytes memory _data) payable {
ERC1967Utils.upgradeToAndCall(implementation, _data);
}
/**
* @dev Returns the current implementation address.
*
* 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.
* `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
*/
function _implementation() internal view virtual override returns (address) {
return ERC1967Utils.getImplementation();
}
}// 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.2.0) (proxy/transparent/ProxyAdmin.sol)
pragma solidity ^0.8.22;
import {ITransparentUpgradeableProxy} from "./TransparentUpgradeableProxy.sol";
import {Ownable} from "../../access/Ownable.sol";
/**
* @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an
* explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.
*/
contract ProxyAdmin is Ownable {
/**
* @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgrade(address,address)`
* and `upgradeAndCall(address,address,bytes)` are present, and `upgrade` must be used if no function should be called,
* while `upgradeAndCall` will invoke the `receive` function if the third argument is the empty byte string.
* If the getter returns `"5.0.0"`, only `upgradeAndCall(address,address,bytes)` is present, and the third 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 Sets the initial owner who can perform upgrades.
*/
constructor(address initialOwner) Ownable(initialOwner) {}
/**
* @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation.
* See {TransparentUpgradeableProxy-_dispatchUpgradeToAndCall}.
*
* Requirements:
*
* - This contract must be the admin of `proxy`.
* - If `data` is empty, `msg.value` must be zero.
*/
function upgradeAndCall(
ITransparentUpgradeableProxy proxy,
address implementation,
bytes memory data
) public payable virtual onlyOwner {
proxy.upgradeToAndCall{value: msg.value}(implementation, data);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/Arrays.sol)
// This file was procedurally generated from scripts/generate/templates/Arrays.js.
pragma solidity ^0.8.20;
import {Comparators} from "./Comparators.sol";
import {SlotDerivation} from "./SlotDerivation.sol";
import {StorageSlot} from "./StorageSlot.sol";
import {Math} from "./math/Math.sol";
/**
* @dev Collection of functions related to array types.
*/
library Arrays {
using SlotDerivation for bytes32;
using StorageSlot for bytes32;
/**
* @dev Sort an array of uint256 (in memory) following the provided comparator function.
*
* This function does the sorting "in place", meaning that it overrides the input. The object is returned for
* convenience, but that returned value can be discarded safely if the caller has a memory pointer to the array.
*
* NOTE: this function's cost is `O(n · log(n))` in average and `O(n²)` in the worst case, with n the length of the
* array. Using it in view functions that are executed through `eth_call` is safe, but one should be very careful
* when executing this as part of a transaction. If the array being sorted is too large, the sort operation may
* consume more gas than is available in a block, leading to potential DoS.
*
* IMPORTANT: Consider memory side-effects when using custom comparator functions that access memory in an unsafe way.
*/
function sort(
uint256[] memory array,
function(uint256, uint256) pure returns (bool) comp
) internal pure returns (uint256[] memory) {
_quickSort(_begin(array), _end(array), comp);
return array;
}
/**
* @dev Variant of {sort} that sorts an array of uint256 in increasing order.
*/
function sort(uint256[] memory array) internal pure returns (uint256[] memory) {
sort(array, Comparators.lt);
return array;
}
/**
* @dev Sort an array of address (in memory) following the provided comparator function.
*
* This function does the sorting "in place", meaning that it overrides the input. The object is returned for
* convenience, but that returned value can be discarded safely if the caller has a memory pointer to the array.
*
* NOTE: this function's cost is `O(n · log(n))` in average and `O(n²)` in the worst case, with n the length of the
* array. Using it in view functions that are executed through `eth_call` is safe, but one should be very careful
* when executing this as part of a transaction. If the array being sorted is too large, the sort operation may
* consume more gas than is available in a block, leading to potential DoS.
*
* IMPORTANT: Consider memory side-effects when using custom comparator functions that access memory in an unsafe way.
*/
function sort(
address[] memory array,
function(address, address) pure returns (bool) comp
) internal pure returns (address[] memory) {
sort(_castToUint256Array(array), _castToUint256Comp(comp));
return array;
}
/**
* @dev Variant of {sort} that sorts an array of address in increasing order.
*/
function sort(address[] memory array) internal pure returns (address[] memory) {
sort(_castToUint256Array(array), Comparators.lt);
return array;
}
/**
* @dev Sort an array of bytes32 (in memory) following the provided comparator function.
*
* This function does the sorting "in place", meaning that it overrides the input. The object is returned for
* convenience, but that returned value can be discarded safely if the caller has a memory pointer to the array.
*
* NOTE: this function's cost is `O(n · log(n))` in average and `O(n²)` in the worst case, with n the length of the
* array. Using it in view functions that are executed through `eth_call` is safe, but one should be very careful
* when executing this as part of a transaction. If the array being sorted is too large, the sort operation may
* consume more gas than is available in a block, leading to potential DoS.
*
* IMPORTANT: Consider memory side-effects when using custom comparator functions that access memory in an unsafe way.
*/
function sort(
bytes32[] memory array,
function(bytes32, bytes32) pure returns (bool) comp
) internal pure returns (bytes32[] memory) {
sort(_castToUint256Array(array), _castToUint256Comp(comp));
return array;
}
/**
* @dev Variant of {sort} that sorts an array of bytes32 in increasing order.
*/
function sort(bytes32[] memory array) internal pure returns (bytes32[] memory) {
sort(_castToUint256Array(array), Comparators.lt);
return array;
}
/**
* @dev Performs a quick sort of a segment of memory. The segment sorted starts at `begin` (inclusive), and stops
* at end (exclusive). Sorting follows the `comp` comparator.
*
* Invariant: `begin <= end`. This is the case when initially called by {sort} and is preserved in subcalls.
*
* IMPORTANT: Memory locations between `begin` and `end` are not validated/zeroed. This function should
* be used only if the limits are within a memory array.
*/
function _quickSort(uint256 begin, uint256 end, function(uint256, uint256) pure returns (bool) comp) private pure {
unchecked {
if (end - begin < 0x40) return;
// Use first element as pivot
uint256 pivot = _mload(begin);
// Position where the pivot should be at the end of the loop
uint256 pos = begin;
for (uint256 it = begin + 0x20; it < end; it += 0x20) {
if (comp(_mload(it), pivot)) {
// If the value stored at the iterator's position comes before the pivot, we increment the
// position of the pivot and move the value there.
pos += 0x20;
_swap(pos, it);
}
}
_swap(begin, pos); // Swap pivot into place
_quickSort(begin, pos, comp); // Sort the left side of the pivot
_quickSort(pos + 0x20, end, comp); // Sort the right side of the pivot
}
}
/**
* @dev Pointer to the memory location of the first element of `array`.
*/
function _begin(uint256[] memory array) private pure returns (uint256 ptr) {
assembly ("memory-safe") {
ptr := add(array, 0x20)
}
}
/**
* @dev Pointer to the memory location of the first memory word (32bytes) after `array`. This is the memory word
* that comes just after the last element of the array.
*/
function _end(uint256[] memory array) private pure returns (uint256 ptr) {
unchecked {
return _begin(array) + array.length * 0x20;
}
}
/**
* @dev Load memory word (as a uint256) at location `ptr`.
*/
function _mload(uint256 ptr) private pure returns (uint256 value) {
assembly {
value := mload(ptr)
}
}
/**
* @dev Swaps the elements memory location `ptr1` and `ptr2`.
*/
function _swap(uint256 ptr1, uint256 ptr2) private pure {
assembly {
let value1 := mload(ptr1)
let value2 := mload(ptr2)
mstore(ptr1, value2)
mstore(ptr2, value1)
}
}
/// @dev Helper: low level cast address memory array to uint256 memory array
function _castToUint256Array(address[] memory input) private pure returns (uint256[] memory output) {
assembly {
output := input
}
}
/// @dev Helper: low level cast bytes32 memory array to uint256 memory array
function _castToUint256Array(bytes32[] memory input) private pure returns (uint256[] memory output) {
assembly {
output := input
}
}
/// @dev Helper: low level cast address comp function to uint256 comp function
function _castToUint256Comp(
function(address, address) pure returns (bool) input
) private pure returns (function(uint256, uint256) pure returns (bool) output) {
assembly {
output := input
}
}
/// @dev Helper: low level cast bytes32 comp function to uint256 comp function
function _castToUint256Comp(
function(bytes32, bytes32) pure returns (bool) input
) private pure returns (function(uint256, uint256) pure returns (bool) output) {
assembly {
output := input
}
}
/**
* @dev Searches a sorted `array` and returns the first index that contains
* a value greater or equal to `element`. If no such index exists (i.e. all
* values in the array are strictly less than `element`), the array length is
* returned. Time complexity O(log n).
*
* NOTE: The `array` is expected to be sorted in ascending order, and to
* contain no repeated elements.
*
* IMPORTANT: Deprecated. This implementation behaves as {lowerBound} but lacks
* support for repeated elements in the array. The {lowerBound} function should
* be used instead.
*/
function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) {
uint256 low = 0;
uint256 high = array.length;
if (high == 0) {
return 0;
}
while (low < high) {
uint256 mid = Math.average(low, high);
// Note that mid will always be strictly less than high (i.e. it will be a valid array index)
// because Math.average rounds towards zero (it does integer division with truncation).
if (unsafeAccess(array, mid).value > element) {
high = mid;
} else {
low = mid + 1;
}
}
// At this point `low` is the exclusive upper bound. We will return the inclusive upper bound.
if (low > 0 && unsafeAccess(array, low - 1).value == element) {
return low - 1;
} else {
return low;
}
}
/**
* @dev Searches an `array` sorted in ascending order and returns the first
* index that contains a value greater or equal than `element`. If no such index
* exists (i.e. all values in the array are strictly less than `element`), the array
* length is returned. Time complexity O(log n).
*
* See C++'s https://en.cppreference.com/w/cpp/algorithm/lower_bound[lower_bound].
*/
function lowerBound(uint256[] storage array, uint256 element) internal view returns (uint256) {
uint256 low = 0;
uint256 high = array.length;
if (high == 0) {
return 0;
}
while (low < high) {
uint256 mid = Math.average(low, high);
// Note that mid will always be strictly less than high (i.e. it will be a valid array index)
// because Math.average rounds towards zero (it does integer division with truncation).
if (unsafeAccess(array, mid).value < element) {
// this cannot overflow because mid < high
unchecked {
low = mid + 1;
}
} else {
high = mid;
}
}
return low;
}
/**
* @dev Searches an `array` sorted in ascending order and returns the first
* index that contains a value strictly greater than `element`. If no such index
* exists (i.e. all values in the array are strictly less than `element`), the array
* length is returned. Time complexity O(log n).
*
* See C++'s https://en.cppreference.com/w/cpp/algorithm/upper_bound[upper_bound].
*/
function upperBound(uint256[] storage array, uint256 element) internal view returns (uint256) {
uint256 low = 0;
uint256 high = array.length;
if (high == 0) {
return 0;
}
while (low < high) {
uint256 mid = Math.average(low, high);
// Note that mid will always be strictly less than high (i.e. it will be a valid array index)
// because Math.average rounds towards zero (it does integer division with truncation).
if (unsafeAccess(array, mid).value > element) {
high = mid;
} else {
// this cannot overflow because mid < high
unchecked {
low = mid + 1;
}
}
}
return low;
}
/**
* @dev Same as {lowerBound}, but with an array in memory.
*/
function lowerBoundMemory(uint256[] memory array, uint256 element) internal pure returns (uint256) {
uint256 low = 0;
uint256 high = array.length;
if (high == 0) {
return 0;
}
while (low < high) {
uint256 mid = Math.average(low, high);
// Note that mid will always be strictly less than high (i.e. it will be a valid array index)
// because Math.average rounds towards zero (it does integer division with truncation).
if (unsafeMemoryAccess(array, mid) < element) {
// this cannot overflow because mid < high
unchecked {
low = mid + 1;
}
} else {
high = mid;
}
}
return low;
}
/**
* @dev Same as {upperBound}, but with an array in memory.
*/
function upperBoundMemory(uint256[] memory array, uint256 element) internal pure returns (uint256) {
uint256 low = 0;
uint256 high = array.length;
if (high == 0) {
return 0;
}
while (low < high) {
uint256 mid = Math.average(low, high);
// Note that mid will always be strictly less than high (i.e. it will be a valid array index)
// because Math.average rounds towards zero (it does integer division with truncation).
if (unsafeMemoryAccess(array, mid) > element) {
high = mid;
} else {
// this cannot overflow because mid < high
unchecked {
low = mid + 1;
}
}
}
return low;
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeAccess(address[] storage arr, uint256 pos) internal pure returns (StorageSlot.AddressSlot storage) {
bytes32 slot;
assembly ("memory-safe") {
slot := arr.slot
}
return slot.deriveArray().offset(pos).getAddressSlot();
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeAccess(bytes32[] storage arr, uint256 pos) internal pure returns (StorageSlot.Bytes32Slot storage) {
bytes32 slot;
assembly ("memory-safe") {
slot := arr.slot
}
return slot.deriveArray().offset(pos).getBytes32Slot();
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeAccess(uint256[] storage arr, uint256 pos) internal pure returns (StorageSlot.Uint256Slot storage) {
bytes32 slot;
assembly ("memory-safe") {
slot := arr.slot
}
return slot.deriveArray().offset(pos).getUint256Slot();
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeMemoryAccess(address[] memory arr, uint256 pos) internal pure returns (address res) {
assembly {
res := mload(add(add(arr, 0x20), mul(pos, 0x20)))
}
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeMemoryAccess(bytes32[] memory arr, uint256 pos) internal pure returns (bytes32 res) {
assembly {
res := mload(add(add(arr, 0x20), mul(pos, 0x20)))
}
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeMemoryAccess(uint256[] memory arr, uint256 pos) internal pure returns (uint256 res) {
assembly {
res := mload(add(add(arr, 0x20), mul(pos, 0x20)))
}
}
/**
* @dev Helper to set the length of a dynamic array. Directly writing to `.length` is forbidden.
*
* WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased.
*/
function unsafeSetLength(address[] storage array, uint256 len) internal {
assembly ("memory-safe") {
sstore(array.slot, len)
}
}
/**
* @dev Helper to set the length of a dynamic array. Directly writing to `.length` is forbidden.
*
* WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased.
*/
function unsafeSetLength(bytes32[] storage array, uint256 len) internal {
assembly ("memory-safe") {
sstore(array.slot, len)
}
}
/**
* @dev Helper to set the length of a dynamic array. Directly writing to `.length` is forbidden.
*
* WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased.
*/
function unsafeSetLength(uint256[] storage array, uint256 len) internal {
assembly ("memory-safe") {
sstore(array.slot, len)
}
}
}// 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.3.0) (utils/cryptography/Hashes.sol)
pragma solidity ^0.8.20;
/**
* @dev Library of standard hash functions.
*
* _Available since v5.1._
*/
library Hashes {
/**
* @dev Commutative Keccak256 hash of a sorted pair of bytes32. Frequently used when working with merkle proofs.
*
* NOTE: Equivalent to the `standardNodeHash` in our https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
*/
function commutativeKeccak256(bytes32 a, bytes32 b) internal pure returns (bytes32) {
return a < b ? efficientKeccak256(a, b) : efficientKeccak256(b, a);
}
/**
* @dev Implementation of keccak256(abi.encode(a, b)) that doesn't allocate or expand memory.
*/
function efficientKeccak256(bytes32 a, bytes32 b) internal pure returns (bytes32 value) {
assembly ("memory-safe") {
mstore(0x00, a)
mstore(0x20, b)
value := keccak256(0x00, 0x40)
}
}
}// 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: BUSL-1.1
pragma solidity 0.8.25;
/// @notice Interface for external/custom verification logic
/// @dev Allows plug-in modules to define arbitrary logic for verifying function calls.
/// Used with `VerificationType.CUSTOM_VERIFIER` in the main Verifier contract.
interface ICustomVerifier {
/// @notice Verifies whether the given call is permitted using custom logic
/// @param who Address attempting the call
/// @param where Target contract the call is directed to
/// @param value ETH value sent with the call
/// @param callData Full calldata of the intended call
/// @param verificationData Extra data provided by the caller to support verification logic
/// @return isValid True if the call is considered valid, false otherwise
function verifyCall(
address who,
address where,
uint256 value,
bytes calldata callData,
bytes calldata verificationData
) external view returns (bool);
}// 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) (proxy/Proxy.sol)
pragma solidity ^0.8.20;
/**
* @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
* instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
* be specified by overriding the virtual {_implementation} function.
*
* Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
* different contract through the {_delegate} function.
*
* The success and return data of the delegated call will be returned back to the caller of the proxy.
*/
abstract contract Proxy {
/**
* @dev Delegates the current call to `implementation`.
*
* This function does not return to its internal call site, it will return directly to the external caller.
*/
function _delegate(address implementation) internal virtual {
assembly {
// Copy msg.data. We take full control of memory in this inline assembly
// block because it will not return to Solidity code. We overwrite the
// Solidity scratch pad at memory position 0.
calldatacopy(0, 0, calldatasize())
// Call the implementation.
// out and outsize are 0 because we don't know the size yet.
let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
// Copy the returned data.
returndatacopy(0, 0, returndatasize())
switch result
// delegatecall returns 0 on error.
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
/**
* @dev This is a virtual function that should be overridden so it returns the address to which the fallback
* function and {_fallback} should delegate.
*/
function _implementation() internal view virtual returns (address);
/**
* @dev Delegates the current call to the address returned by `_implementation()`.
*
* This function does not return to its internal call site, it will return directly to the external caller.
*/
function _fallback() internal virtual {
_delegate(_implementation());
}
/**
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
* function in the contract matches the call data.
*/
fallback() external payable virtual {
_fallback();
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Comparators.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides a set of functions to compare values.
*
* _Available since v5.1._
*/
library Comparators {
function lt(uint256 a, uint256 b) internal pure returns (bool) {
return a < b;
}
function gt(uint256 a, uint256 b) internal pure returns (bool) {
return a > b;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/SlotDerivation.sol)
// This file was procedurally generated from scripts/generate/templates/SlotDerivation.js.
pragma solidity ^0.8.20;
/**
* @dev Library for computing storage (and transient storage) locations from namespaces and deriving slots
* corresponding to standard patterns. The derivation method for array and mapping matches the storage layout used by
* the solidity language / compiler.
*
* See https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays[Solidity docs for mappings and dynamic arrays.].
*
* Example usage:
* ```solidity
* contract Example {
* // Add the library methods
* using StorageSlot for bytes32;
* using SlotDerivation for bytes32;
*
* // Declare a namespace
* string private constant _NAMESPACE = "<namespace>"; // eg. OpenZeppelin.Slot
*
* function setValueInNamespace(uint256 key, address newValue) internal {
* _NAMESPACE.erc7201Slot().deriveMapping(key).getAddressSlot().value = newValue;
* }
*
* function getValueInNamespace(uint256 key) internal view returns (address) {
* return _NAMESPACE.erc7201Slot().deriveMapping(key).getAddressSlot().value;
* }
* }
* ```
*
* TIP: Consider using this library along with {StorageSlot}.
*
* NOTE: This library provides a way to manipulate storage locations in a non-standard way. Tooling for checking
* upgrade safety will ignore the slots accessed through this library.
*
* _Available since v5.1._
*/
library SlotDerivation {
/**
* @dev Derive an ERC-7201 slot from a string (namespace).
*/
function erc7201Slot(string memory namespace) internal pure returns (bytes32 slot) {
assembly ("memory-safe") {
mstore(0x00, sub(keccak256(add(namespace, 0x20), mload(namespace)), 1))
slot := and(keccak256(0x00, 0x20), not(0xff))
}
}
/**
* @dev Add an offset to a slot to get the n-th element of a structure or an array.
*/
function offset(bytes32 slot, uint256 pos) internal pure returns (bytes32 result) {
unchecked {
return bytes32(uint256(slot) + pos);
}
}
/**
* @dev Derive the location of the first element in an array from the slot where the length is stored.
*/
function deriveArray(bytes32 slot) internal pure returns (bytes32 result) {
assembly ("memory-safe") {
mstore(0x00, slot)
result := keccak256(0x00, 0x20)
}
}
/**
* @dev Derive the location of a mapping element from the key.
*/
function deriveMapping(bytes32 slot, address key) internal pure returns (bytes32 result) {
assembly ("memory-safe") {
mstore(0x00, and(key, shr(96, not(0))))
mstore(0x20, slot)
result := keccak256(0x00, 0x40)
}
}
/**
* @dev Derive the location of a mapping element from the key.
*/
function deriveMapping(bytes32 slot, bool key) internal pure returns (bytes32 result) {
assembly ("memory-safe") {
mstore(0x00, iszero(iszero(key)))
mstore(0x20, slot)
result := keccak256(0x00, 0x40)
}
}
/**
* @dev Derive the location of a mapping element from the key.
*/
function deriveMapping(bytes32 slot, bytes32 key) internal pure returns (bytes32 result) {
assembly ("memory-safe") {
mstore(0x00, key)
mstore(0x20, slot)
result := keccak256(0x00, 0x40)
}
}
/**
* @dev Derive the location of a mapping element from the key.
*/
function deriveMapping(bytes32 slot, uint256 key) internal pure returns (bytes32 result) {
assembly ("memory-safe") {
mstore(0x00, key)
mstore(0x20, slot)
result := keccak256(0x00, 0x40)
}
}
/**
* @dev Derive the location of a mapping element from the key.
*/
function deriveMapping(bytes32 slot, int256 key) internal pure returns (bytes32 result) {
assembly ("memory-safe") {
mstore(0x00, key)
mstore(0x20, slot)
result := keccak256(0x00, 0x40)
}
}
/**
* @dev Derive the location of a mapping element from the key.
*/
function deriveMapping(bytes32 slot, string memory key) internal pure returns (bytes32 result) {
assembly ("memory-safe") {
let length := mload(key)
let begin := add(key, 0x20)
let end := add(begin, length)
let cache := mload(end)
mstore(end, slot)
result := keccak256(begin, add(length, 0x20))
mstore(end, cache)
}
}
/**
* @dev Derive the location of a mapping element from the key.
*/
function deriveMapping(bytes32 slot, bytes memory key) internal pure returns (bytes32 result) {
assembly ("memory-safe") {
let length := mload(key)
let begin := add(key, 0x20)
let end := add(begin, length)
let cache := mload(end)
mstore(end, slot)
result := keccak256(begin, add(length, 0x20))
mstore(end, cache)
}
}
}// 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);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @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 Context {
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;
}
}{
"remappings": [
"forge-std/=lib/openzeppelin-contracts-upgradeable/lib/forge-std/src/",
"@openzeppelin/contracts/=lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/",
"@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"@cowswap/contracts/=lib/contracts/src/contracts/",
"contracts/=lib/contracts/src/",
"erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
"halmos-cheatcodes/=lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/",
"openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts/=lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/"
],
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"abi"
]
}
},
"evmVersion": "cancun",
"viaIR": false
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"string","name":"name_","type":"string"},{"internalType":"uint256","name":"version_","type":"uint256"},{"internalType":"address","name":"depositQueueFactory_","type":"address"},{"internalType":"address","name":"redeemQueueFactory_","type":"address"},{"internalType":"address","name":"subvaultFactory_","type":"address"},{"internalType":"address","name":"verifierFactory_","type":"address"}],"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":"subvault","type":"address"}],"name":"AlreadyConnected","type":"error"},{"inputs":[],"name":"FailedCall","type":"error"},{"inputs":[],"name":"Forbidden","type":"error"},{"inputs":[{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"InsufficientBalance","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[{"internalType":"address","name":"subvault","type":"address"}],"name":"InvalidSubvault","type":"error"},{"inputs":[{"internalType":"address","name":"subvault","type":"address"}],"name":"NotConnected","type":"error"},{"inputs":[{"internalType":"address","name":"subvault","type":"address"}],"name":"NotEntity","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"QueueLimitReached","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"UnsupportedAsset","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"inputs":[],"name":"ZeroValue","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":true,"internalType":"address","name":"subvault","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"AssetsPulled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":true,"internalType":"address","name":"subvault","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"AssetsPushed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"queue","type":"address"},{"indexed":true,"internalType":"address","name":"hook","type":"address"}],"name":"CustomHookSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"hook","type":"address"},{"indexed":false,"internalType":"bool","name":"isDepositHook","type":"bool"}],"name":"DefaultHookSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"queue","type":"address"},{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"},{"indexed":false,"internalType":"address","name":"hook","type":"address"}],"name":"HookCalled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"initParams","type":"bytes"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"queue","type":"address"},{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"bool","name":"isDepositQueue","type":"bool"}],"name":"QueueCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"limit","type":"uint256"}],"name":"QueueLimitSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"queue","type":"address"},{"indexed":true,"internalType":"address","name":"asset","type":"address"}],"name":"QueueRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":true,"internalType":"uint224","name":"priceD18","type":"uint224"},{"indexed":false,"internalType":"uint32","name":"depositTimestamp","type":"uint32"},{"indexed":false,"internalType":"uint32","name":"redeemTimestamp","type":"uint32"},{"indexed":false,"internalType":"uint256","name":"fees","type":"uint256"}],"name":"ReportHandled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"RoleAdded","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"}],"name":"RoleRemoved","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":"queue","type":"address"},{"indexed":true,"internalType":"bool","name":"isPaused","type":"bool"}],"name":"SetQueueStatus","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"SharesClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"subvault","type":"address"},{"indexed":false,"internalType":"uint256","name":"version","type":"uint256"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"verifier","type":"address"}],"name":"SubvaultCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"subvault","type":"address"}],"name":"SubvaultDisconnected","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"subvault","type":"address"},{"indexed":true,"internalType":"address","name":"verifier","type":"address"}],"name":"SubvaultReconnected","type":"event"},{"inputs":[],"name":"CREATE_QUEUE_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CREATE_SUBVAULT_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DISCONNECT_SUBVAULT_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PULL_LIQUIDITY_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PUSH_LIQUIDITY_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"RECONNECT_SUBVAULT_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"REMOVE_QUEUE_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SET_HOOK_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SET_QUEUE_LIMIT_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SET_QUEUE_STATUS_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"assetAt","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"name":"callHook","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"claimShares","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"claimableSharesOf","outputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"version","type":"uint256"},{"internalType":"bool","name":"isDeposit","type":"bool"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"createQueue","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"version","type":"uint256"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"verifier","type":"address"}],"name":"createSubvault","outputs":[{"internalType":"address","name":"subvault","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"defaultDepositHook","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultRedeemHook","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"depositQueueFactory","outputs":[{"internalType":"contract IFactory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"subvault","type":"address"}],"name":"disconnectSubvault","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feeManager","outputs":[{"internalType":"contract IFeeManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAssetCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"queue","type":"address"}],"name":"getHook","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLiquidAssets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getQueueCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"getQueueCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","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":"slot","type":"bytes32"}],"name":"getStorageAt","outputs":[{"components":[{"internalType":"bytes32","name":"value","type":"bytes32"}],"internalType":"struct StorageSlot.Bytes32Slot","name":"","type":"tuple"}],"stateMutability":"pure","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":"uint224","name":"priceD18","type":"uint224"},{"internalType":"uint32","name":"depositTimestamp","type":"uint32"},{"internalType":"uint32","name":"redeemTimestamp","type":"uint32"}],"name":"handleReport","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"hasAsset","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"queue","type":"address"}],"name":"hasQueue","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","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":"subvault","type":"address"}],"name":"hasSubvault","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"hasSupportedRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"subvault","type":"address"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"hookPullAssets","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"subvault","type":"address"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"hookPushAssets","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"initParams","type":"bytes"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"queue","type":"address"}],"name":"isDepositQueue","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"queue","type":"address"}],"name":"isPausedQueue","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"oracle","outputs":[{"internalType":"contract IOracle","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"subvault","type":"address"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"pullAssets","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"subvault","type":"address"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"pushAssets","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"queueAt","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"queueLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"subvault","type":"address"}],"name":"reconnectSubvault","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"redeemQueueFactory","outputs":[{"internalType":"contract IFactory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"queue","type":"address"}],"name":"removeQueue","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","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":[],"name":"riskManager","outputs":[{"internalType":"contract IRiskManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"queue","type":"address"},{"internalType":"address","name":"hook","type":"address"}],"name":"setCustomHook","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"hook","type":"address"}],"name":"setDefaultDepositHook","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"hook","type":"address"}],"name":"setDefaultRedeemHook","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"limit","type":"uint256"}],"name":"setQueueLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"queue","type":"address"},{"internalType":"bool","name":"isPaused","type":"bool"}],"name":"setQueueStatus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"shareManager","outputs":[{"internalType":"contract IShareManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"subvaultAt","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"subvaultFactory","outputs":[{"internalType":"contract IFactory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"subvaults","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"supportedRoleAt","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"supportedRoles","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"verifierFactory","outputs":[{"internalType":"contract IFactory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]Contract Creation Code
610160604052348015610010575f80fd5b506040516148af3803806148af83398101604081905261002f91610282565b85858585838387878383818161004361011b565b60408051808201909152600981526813595b1b1bddd050d360ba1b602082015261006e9083836101b8565b60805261007961011b565b505050506100b16040518060400160405280600b81526020016a5661756c744d6f64756c6560a81b81525085856101b860201b60201c565b60e0526001600160a01b0391821660a0521660c052505060408051808201909152600b81526a53686172654d6f64756c6560a81b60208201526100f59085856101b8565b610140526001600160a01b03918216610100521661012052506103f39650505050505050565b5f610124610229565b805490915068010000000000000000900460ff16156101565760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b03908116146101b55780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b5f60ff5f1b1960018585856040516020016101d59392919061038c565b604051602081830303815290604052805190602001205f1c6101f791906103d4565b60405160200161020991815260200190565b604051602081830303815290604052805190602001201690509392505050565b5f807ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005b92915050565b634e487b7160e01b5f52604160045260245ffd5b80516001600160a01b038116811461027d575f80fd5b919050565b5f805f805f8060c08789031215610297575f80fd5b86516001600160401b03808211156102ad575f80fd5b818901915089601f8301126102c0575f80fd5b8151818111156102d2576102d2610253565b604051601f8201601f19908116603f011681019083821181831017156102fa576102fa610253565b816040528281528c6020848701011115610312575f80fd5b8260208601602083015e5f60208483010152809a5050505050506020870151945061033f60408801610267565b935061034d60608801610267565b925061035b60808801610267565b915061036960a08801610267565b90509295509295509295565b5f81518060208401855e5f93019283525090919050565b7f6d656c6c6f772e666c657869626c652d7661756c74732e73746f726167652e0081525f6103c66103c0601f840187610375565b85610375565b928352505060200192915050565b8181038181111561024d57634e487b7160e01b5f52601160045260245ffd5b60805160a05160c05160e0516101005161012051610140516143f46104bb5f395f612eea01525f81816109750152611c8701525f818161078b0152611cad01525f818161119301528181611591015281816118bd01528181611b4d015281816123ac01528181612447015281816124f2015261331701525f818161064a015281816116cc01526126e501525f81816109e6015281816117f0015261253301525f8181611388015281816115c6015281816123ec015281816130c5015261314e01526143f45ff3fe6080604052600436106103ed575f3560e01c8063850260ff1161020a578063b014f4451161011e578063e4f8d0e6116100a8578063eb56d52d11610078578063eb56d52d14610cc3578063ec0f580014610ce2578063ecef475f14610d01578063f31cb0c614610d20578063f68e730414610d3f575f80fd5b8063e4f8d0e614610c33578063e6c8cd9f14610c52578063e6ed8d7414610c71578063e984f35314610ca4575f80fd5b8063ca15c873116100ee578063ca15c87314610b8f578063d0fb020314610bae578063d27d250314610bc2578063d547741f14610be1578063d8b07a6514610c00575f80fd5b8063b014f44514610aff578063b1a62e3b14610b1e578063b2b71a2714610b51578063b91c935c14610b70575f80fd5b80639ff2cb9d1161019f578063a3246ad31161016f578063a3246ad314610a4e578063a35f620a14610a7a578063a567fb4714610a8e578063aa9239f514610aad578063adf167ce14610acc575f80fd5b80639ff2cb9d146109d5578063a0aead4d14610a08578063a217fddf14610a1c578063a2cb31e514610a2f575f80fd5b806392e6ece5116101da57806392e6ece5146109455780639662d42914610964578063974d942e146109975780639bd0911b146109b6575f80fd5b8063850260ff146108c95780638679ed7c146108e85780639010d07c1461090757806391d1485414610926575f80fd5b8063419a2053116103015780635636d54911610296578063651ae6c711610266578063651ae6c71461081c578063663ade061461084f5780636b8b1ccd146108825780637dc0d1d0146108965780638333903b146108aa575f80fd5b80635636d549146107ad57806358b7bf30146107c15780635c60173d146107f45780635d66b00a14610808575f80fd5b80634b694b96116102d15780634b694b961461071d5780634b812c1f1461073c57806352278ab71461075b57806352fd42541461077a575f80fd5b8063419a2053146106b7578063439fab91146106cb57806347842663146106ea5780634a46b4cf146106fe575f80fd5b80632f2ff15d1161038257806336568abe1161035257806336568abe146105fb578063370488161461061a578063387db78f146106395780633d4304e6146106845780634015b2a8146106a3575f80fd5b80632f2ff15d146105765780632f8ecb50146105955780633314bbb9146105b45780633471b337146105e7575f80fd5b806317cbc8b1116103bd57806317cbc8b1146104d25780631c14724f146104f15780631ca0027a14610510578063248a9ca314610557575f80fd5b806301ffc9a7146103f8578063040bee6d1461042c57806313cb953a1461044d578063150b7a021461048e575f80fd5b366103f457005b5f80fd5b348015610403575f80fd5b50610417610412366004613b76565b610d5f565b60405190151581526020015b60405180910390f35b348015610437575f80fd5b5061044b610446366004613bb1565b610d89565b005b348015610458575f80fd5b506104807f32a781031f04cc60b32394e40124d1e87f54273bf26d0532a115a424f6a9329881565b604051908152602001610423565b348015610499575f80fd5b506104b96104a8366004613c11565b630a85bd0160e11b95945050505050565b6040516001600160e01b03199091168152602001610423565b3480156104dd575f80fd5b5061044b6104ec366004613c7f565b610fa9565b3480156104fc575f80fd5b5061048061050b366004613bb1565b611002565b34801561051b575f80fd5b5061054861052a366004613cbd565b60408051602080820183525f90915281519081019091529054815290565b60405190518152602001610423565b348015610562575f80fd5b50610480610571366004613cbd565b61112b565b348015610581575f80fd5b5061044b610590366004613cd4565b61114b565b3480156105a0575f80fd5b5061044b6105af366004613bb1565b611167565b3480156105bf575f80fd5b506104807f68895691ff006f290ca74825ce06ed17fffab55af49f0274f49b7424f752583a81565b3480156105f2575f80fd5b50610480611224565b348015610606575f80fd5b5061044b610615366004613cd4565b611236565b348015610625575f80fd5b5061044b610634366004613bb1565b61126e565b348015610644575f80fd5b5061066c7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610423565b34801561068f575f80fd5b5061066c61069e366004613bb1565b6112e8565b3480156106ae575f80fd5b5061066c611367565b3480156106c2575f80fd5b50610480611382565b3480156106d6575f80fd5b5061044b6106e5366004613d02565b6113b1565b3480156106f5575f80fd5b5061066c61158e565b348015610709575f80fd5b50610417610718366004613cbd565b6115c0565b348015610728575f80fd5b50610417610737366004613bb1565b6115eb565b348015610747575f80fd5b5061066c610756366004613d41565b61167a565b348015610766575f80fd5b50610480610775366004613bb1565b611959565b348015610785575f80fd5b5061066c7f000000000000000000000000000000000000000000000000000000000000000081565b3480156107b8575f80fd5b5061066c611985565b3480156107cc575f80fd5b506104807fb557d53a2e72d8333ffa3bf2f556678becb5e995b0e25b7dca354627e550c08f81565b3480156107ff575f80fd5b5061066c6119a0565b348015610813575f80fd5b506104806119a9565b348015610827575f80fd5b506104807f9a4c49d6fb9452bbfe187968075d0fac7d7202d2b7f731d8cffbce9cf66756b281565b34801561085a575f80fd5b506104807ff610639f4b9b8986f875fcb4e49486da5c7aa449a6942b5013fabd061e9b9fff81565b34801561088d575f80fd5b50610480611b18565b3480156108a1575f80fd5b5061066c611b2a565b3480156108b5575f80fd5b506104176108c4366004613bb1565b611b45565b3480156108d4575f80fd5b5061044b6108e3366004613d8d565b611b73565b3480156108f3575f80fd5b50610417610902366004613bb1565b611e20565b348015610912575f80fd5b5061066c610921366004613e0d565b611e4d565b348015610931575f80fd5b50610417610940366004613cd4565b611e72565b348015610950575f80fd5b5061041761095f366004613bb1565b611ea8565b34801561096f575f80fd5b5061066c7f000000000000000000000000000000000000000000000000000000000000000081565b3480156109a2575f80fd5b5061044b6109b1366004613e45565b611ed5565b3480156109c1575f80fd5b5061066c6109d0366004613cbd565b6123a4565b3480156109e0575f80fd5b5061066c7f000000000000000000000000000000000000000000000000000000000000000081565b348015610a13575f80fd5b506104806123d2565b348015610a27575f80fd5b506104805f81565b348015610a3a575f80fd5b50610480610a49366004613cbd565b6123e6565b348015610a59575f80fd5b50610a6d610a68366004613cbd565b612411565b6040516104239190613ea5565b348015610a85575f80fd5b50610480612441565b348015610a99575f80fd5b50610417610aa8366004613bb1565b61246e565b348015610ab8575f80fd5b5061066c610ac7366004613cbd565b612484565b348015610ad7575f80fd5b506104807f85c2023fdfb1e93dedf5d18f9bc0e79347e071d12740ba71aeb84a4fcbdc4b7981565b348015610b0a575f80fd5b5061044b610b19366004613c7f565b61249a565b348015610b29575f80fd5b506104807f6788636e7899d6d227901dc9f8c4c785401c0991724cf908dc65388af686da6f81565b348015610b5c575f80fd5b5061044b610b6b366004613bb1565b6124c5565b348015610b7b575f80fd5b5061066c610b8a366004613ef1565b612884565b348015610b9a575f80fd5b50610480610ba9366004613cbd565b6128b2565b348015610bb9575f80fd5b5061066c6128d6565b348015610bcd575f80fd5b5061044b610bdc366004613cbd565b6128f1565b348015610bec575f80fd5b5061044b610bfb366004613cd4565b612a98565b348015610c0b575f80fd5b506104807f6618a6d92147bbcacfb2ef2375976fc4c529eeeaeb72a66048296571370c694681565b348015610c3e575f80fd5b5061044b610c4d366004613f1b565b612ab4565b348015610c5d575f80fd5b5061044b610c6c366004613c7f565b612b5d565b348015610c7c575f80fd5b506104807f407fc42eadf1aba68b1d4a8c3c4aa2e8b6beac7957623f3694d0ad77bfb70e0681565b348015610caf575f80fd5b5061044b610cbe366004613c7f565b612b88565b348015610cce575f80fd5b5061044b610cdd366004613f47565b612bc5565b348015610ced575f80fd5b5061044b610cfc366004613bb1565b612c79565b348015610d0c575f80fd5b5061044b610d1b366004613cbd565b612cea565b348015610d2b575f80fd5b5061044b610d3a366004613bb1565b612d58565b348015610d4a575f80fd5b506104805f8051602061433f83398151915281565b5f6001600160e01b03198216635a05180f60e01b1480610d835750610d8382612ea7565b92915050565b7f9a4c49d6fb9452bbfe187968075d0fac7d7202d2b7f731d8cffbce9cf66756b2610db381612edb565b816001600160a01b031663c2f218966040518163ffffffff1660e01b8152600401602060405180830381865afa158015610def573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e139190613f73565b610e3057604051631dd2188d60e31b815260040160405180910390fd5b5f826001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e6d573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e919190613f8e565b90505f610e9c612ee8565b6001600160a01b0383165f908152600a820160205260409020909150610ec29085612f0c565b610edf57604051631dd2188d60e31b815260040160405180910390fd5b6001600160a01b038085165f9081526008830160209081526040808320805460ff191690559285168252600a8401905220610f1990612f20565b5f03610f2e57610f2c600b820183612f0c565b505b6001600160a01b0384165f908152600782016020526040812080546001600160a01b0319169055600582018054909190610f6790613fbd565b909155506040516001600160a01b0380841691908616907faf660c1b265f07536d70b577e6dac1fed859eae81dca40591155a8fa2294553d905f90a350505050565b7f68895691ff006f290ca74825ce06ed17fffab55af49f0274f49b7424f752583a610fd381612edb565b610fdb612f29565b610fe6848484612f60565b610ffc60015f8051602061439f83398151915255565b50505050565b5f8061100c612ee8565b9050600b81015f61101c82612f20565b90505f5b81811015611122575f61103384836130a5565b6001600160a01b0381165f908152600a87016020526040812091925061105882612f20565b90505f5b81811015611112575f61106f84836130a5565b6001600160a01b0381165f90815260088b01602052604090205490915060ff161561110957604051638903ab9d60e01b81526001600160a01b038c81166004830152821690638903ab9d90602401602060405180830381865afa1580156110d8573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906110fc9190613fd2565b611106908b613fe9565b99505b5060010161105c565b5050600190920191506110209050565b50505050919050565b5f9081525f8051602061437f833981519152602052604090206001015490565b6111548261112b565b61115d81612edb565b610ffc83836130b0565b7ff610639f4b9b8986f875fcb4e49486da5c7aa449a6942b5013fabd061e9b9fff61119181612edb565b7f00000000000000000000000000000000000000000000000000000000000000006111bf6001820184612f0c565b6111ec57604051635c6a489f60e01b81526001600160a01b03841660048201526024015b60405180910390fd5b6040516001600160a01b038416907f95067a3324c952e40449419ed59015549ae2c2b2c5988efb9bdaaf33baf6f793905f90a2505050565b5f61122d612ee8565b60050154905090565b6001600160a01b038116331461125f5760405163334bd91960e11b815260040160405180910390fd5b611269828261312a565b505050565b5f8051602061433f83398151915261128581612edb565b8161128e612ee8565b60030180546001600160a01b0319166001600160a01b0392831617905560405160018152908316907f59dc533a8345ccff036afdd89363a87154a5e6c51ff4fc507fc1865bb925438e906020015b60405180910390a25050565b5f806112f2612ee8565b6001600160a01b038085165f908152600783016020526040902054919250168061135d576001600160a01b0384165f90815260088301602052604090205460ff1661134a5760048201546001600160a01b031661135f565b60038201546001600160a01b031661135f565b805b949350505050565b5f611370612ee8565b600401546001600160a01b0316919050565b5f6113ac7f0000000000000000000000000000000000000000000000000000000000000000612f20565b905090565b5f6113ba6131a6565b805490915060ff600160401b820416159067ffffffffffffffff165f811580156113e15750825b90505f8267ffffffffffffffff1660011480156113fd5750303b155b90508115801561140b575080155b156114295760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff19166001178555831561145357845460ff60401b1916600160401b1785555b5f805f805f805f805f8f8f81019061146b919061406a565b9850985098509850985098509850985098506114856131ce565b61148e896131e0565b61149c88888787878761321d565b6114a5866132e6565b5f5b81518110156114fc576114f38282815181106114c5576114c5614217565b60200260200101515f01518383815181106114e2576114e2614217565b6020026020010151602001516130b0565b506001016114a7565b505050505050505050507f5e399709a9ff1709f6f6be7268c8e5c3eeaa9da9cd9797e78f07ef287c3717fe8787604051611537929190614253565b60405180910390a1831561158557845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50505050505050565b5f7f00000000000000000000000000000000000000000000000000000000000000005b546001600160a01b0316919050565b5f610d837f000000000000000000000000000000000000000000000000000000000000000083613356565b5f610d83826115f8612ee8565b600a015f856001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611638573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061165c9190613f8e565b6001600160a01b0316815260208101919091526040015f209061336d565b5f7f85c2023fdfb1e93dedf5d18f9bc0e79347e071d12740ba71aeb84a4fcbdc4b796116a581612edb565b6116ad612f29565b6040516302910f8b60e31b81526001600160a01b0384811660048301527f000000000000000000000000000000000000000000000000000000000000000016906314887c5890602401602060405180830381865afa158015611711573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906117359190613f73565b61175d5760405163d0b5c30560e01b81526001600160a01b03841660048201526024016111e3565b306001600160a01b0316836001600160a01b031663fbfa77cf6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156117a3573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906117c79190613f8e565b6001600160a01b0316146117ee57604051631dd2188d60e31b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166346fbcbb2868686306040516020016118479291906001600160a01b0392831681529116602082015260400190565b6040516020818303038152906040526040518463ffffffff1660e01b815260040161187493929190614266565b6020604051808303815f875af1158015611890573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906118b49190613f8e565b91506118e360017f0000000000000000000000000000000000000000000000000000000000000000018361338e565b50826001600160a01b0316846001600160a01b0316836001600160a01b03167fae0bbc337ca4971dd982cb61e17432f83cf2e5647ad778f7db9ff18efd77a2118860405161193391815260200190565b60405180910390a461195160015f8051602061439f83398151915255565b509392505050565b5f610d83611965612ee8565b6001600160a01b0384165f908152600a9190910160205260409020612f20565b5f61198e612ee8565b600301546001600160a01b0316919050565b5f6115b1612ee8565b5f803390505f816001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156119eb573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611a0f9190613f8e565b90505f611a1a612ee8565b6001600160a01b0383165f908152600a820160205260409020909150611a40908461336d565b1580611a6557506001600160a01b0383165f90815260088201602052604090205460ff165b15611a8357604051631dd2188d60e31b815260040160405180910390fd5b5f611a8d846112e8565b90506001600160a01b038116611ab057611aa783306133a2565b94505050505090565b604051630af5049b60e11b81526001600160a01b0384811660048301528216906315ea093690602401602060405180830381865afa158015611af4573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611aa79190613fd2565b5f611b21612ee8565b60060154905090565b5f611b33612ee8565b600201546001600160a01b0316919050565b5f610d8360017f0000000000000000000000000000000000000000000000000000000000000000018361336d565b611b7b612f29565b7f6788636e7899d6d227901dc9f8c4c785401c0991724cf908dc65388af686da6f611ba581612edb565b5f611bae612ee8565b6002810154604051634df48c7360e11b81526001600160a01b038881166004830152929350911690639be918e690602401602060405180830381865afa158015611bfa573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611c1e9190613f73565b611c465760405163ee84f40b60e01b81526001600160a01b03861660048201526024016111e3565b5f81600501546001611c589190613fe9565b90508160060154811115611c7f5760405163082d389160e31b815260040160405180910390fd5b5f88611cab577f0000000000000000000000000000000000000000000000000000000000000000611ccd565b7f00000000000000000000000000000000000000000000000000000000000000005b6001600160a01b03166346fbcbb28b8a8a308b8b604051602001611cf494939291906142b1565b6040516020818303038152906040526040518463ffffffff1660e01b8152600401611d2193929190614266565b6020604051808303815f875af1158015611d3d573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611d619190613f8e565b600584018390556001600160a01b0388165f908152600a850160205260409020909150611d8e908261338e565b50611d9c600b84018861338e565b506001600160a01b038181165f818152600886016020908152604091829020805460ff19168e15159081179091559151918252928a16927f8138cea23ce1869026f924550085f1d5666d82c6c948c921cf9003cac6bfea9c910160405180910390a350505050611e1860015f8051602061439f83398151915255565b505050505050565b5f611e29612ee8565b6001600160a01b039092165f90815260099290920160205250604090205460ff1690565b5f8281525f8051602061435f83398151915260208190526040822061135f90846130a5565b5f9182525f8051602061437f833981519152602090815260408084206001600160a01b0393909316845291905290205460ff1690565b5f611eb1612ee8565b6001600160a01b039092165f90815260089290920160205250604090205460ff1690565b611edd612f29565b5f611ee6612ee8565b60028101549091506001600160a01b0316336001600160a01b031614611f1f57604051631dd2188d60e31b815260040160405180910390fd5b80546001820154604051630cd9f5f560e11b81523060048201526001600160a01b0392831692909116905f9082906319b3ebea90602401602060405180830381865afa158015611f71573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611f959190613f8e565b6001600160a01b0316886001600160a01b031603612242575f826001600160a01b031663469048406040518163ffffffff1660e01b8152600401602060405180830381865afa158015611fea573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061200e9190613f8e565b604051639d66201b60e01b81526001600160a01b0380831660048301529192508185169163e0e193a29130918d918d918a1690639d66201b90602401602060405180830381865afa158015612065573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906120899190613fd2565b896001600160a01b0316633a98ef396040518163ffffffff1660e01b8152600401602060405180830381865afa1580156120c5573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906120e99190613fd2565b6120f391906142e7565b6040516001600160e01b031960e087901b1681526001600160a01b0394851660048201529390921660248401526001600160e01b031660448301526064820152608401602060405180830381865afa158015612151573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906121759190613fd2565b915081156121db576040516340c10f1960e01b81526001600160a01b038281166004830152602482018490528516906340c10f19906044015f604051808303815f87803b1580156121c4575f80fd5b505af11580156121d6573d5f803e3d5ffd5b505050505b604051634d71303160e11b81526001600160a01b038a811660048301526001600160e01b038a166024830152841690639ae26062906044015f604051808303815f87803b15801561222a575f80fd5b505af115801561223c573d5f803e3d5ffd5b50505050505b5f61224b612ee8565b6001600160a01b038a165f908152600a9190910160205260408120915061227182612f20565b90505f5b81811015612329575f61228884836130a5565b6001600160a01b0381165f81815260088b0160205260409020549192509063b8c5ea8a908d9060ff166122bb578b6122bd565b8c5b6040516001600160e01b031960e085901b1681526001600160e01b03909216600483015263ffffffff1660248201526044015f604051808303815f87803b158015612306575f80fd5b505af1158015612318573d5f803e3d5ffd5b505060019093019250612275915050565b506040805163ffffffff808b168252891660208201529081018490526001600160e01b038a16906001600160a01b038c16907f24bbf515a701fcb7a993b1e8c3f201ab4e608f7b85c61b1f8cc0e19dc9d526539060600160405180910390a3505050505050610ffc60015f8051602061439f83398151915255565b5f610d8360017f000000000000000000000000000000000000000000000000000000000000000001836130a5565b5f6113ac6123de612ee8565b600b01612f20565b5f610d837f0000000000000000000000000000000000000000000000000000000000000000836130a5565b5f8181525f8051602061435f833981519152602081905260409091206060919061243a90613448565b9392505050565b5f6113ac7f0000000000000000000000000000000000000000000000000000000000000000600101612f20565b5f610d838261247b612ee8565b600b019061336d565b5f610d8382612491612ee8565b600b01906130a5565b3330146124ba57604051631dd2188d60e31b815260040160405180910390fd5b611269838383612f60565b7fb557d53a2e72d8333ffa3bf2f556678becb5e995b0e25b7dca354627e550c08f6124ef81612edb565b5f7f00000000000000000000000000000000000000000000000000000000000000006040516302910f8b60e31b81526001600160a01b0385811660048301529192507f0000000000000000000000000000000000000000000000000000000000000000909116906314887c5890602401602060405180830381865afa15801561257a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061259e9190613f73565b6125c65760405163d0b5c30560e01b81526001600160a01b03841660048201526024016111e3565b306001600160a01b0316836001600160a01b031663fbfa77cf6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561260c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906126309190613f8e565b6001600160a01b0316146126625760405163d034fb7960e01b81526001600160a01b03841660048201526024016111e3565b5f836001600160a01b0316632b7ac3f36040518163ffffffff1660e01b8152600401602060405180830381865afa15801561269f573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906126c39190613f8e565b6040516302910f8b60e31b81526001600160a01b0380831660048301529192507f0000000000000000000000000000000000000000000000000000000000000000909116906314887c5890602401602060405180830381865afa15801561272c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906127509190613f73565b6127785760405163d0b5c30560e01b81526001600160a01b03821660048201526024016111e3565b306001600160a01b0316816001600160a01b031663fbfa77cf6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156127be573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906127e29190613f8e565b6001600160a01b03161461280957604051631dd2188d60e31b815260040160405180910390fd5b612816600183018561338e565b61283e57604051638cd80ed360e01b81526001600160a01b03851660048201526024016111e3565b806001600160a01b0316846001600160a01b03167ff75f2e4922769fc299f8f612c31f2d1f8ea0e6fa4c82fdb143bf9c8a070c974c60405160405180910390a350505050565b5f61243a82612891612ee8565b6001600160a01b0386165f908152600a9190910160205260409020906130a5565b5f8181525f8051602061435f83398151915260208190526040822061243a90612f20565b5f6128df612ee8565b600101546001600160a01b0316919050565b5f3390505f816001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612932573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906129569190613f8e565b90505f612961612ee8565b90506129908361296f612ee8565b6001600160a01b0385165f908152600a91909101602052604090209061336d565b6129ad57604051631dd2188d60e31b815260040160405180910390fd5b5f6129b7846112e8565b90506001600160a01b03811615612a1b576040516001600160a01b038416602482015260448101869052612a1990829060640160408051601f198184030181529190526020810180516001600160e01b03166330f736c160e21b179052613454565b505b6001600160a01b0384165f90815260088301602052604090205460ff16612a4757612a478385876134c6565b604080518681526001600160a01b03838116602083015280861692908716917fc23ec549723039bc8a35cac0162f81095410795793f7730887eb1a0e06ef5476910160405180910390a35050505050565b612aa18261112b565b612aaa81612edb565b610ffc838361312a565b5f8051602061433f833981519152612acb81612edb565b6001600160a01b038316612af25760405163d92e233d60e01b815260040160405180910390fd5b81612afb612ee8565b6001600160a01b038581165f818152600793909301602052604080842080546001600160a01b03191695841695909517909455925190851692917f329d0838d5265a7d9d220b95803da511a475abe411dc4df364c1d1b8b923cdf991a3505050565b333014612b7d57604051631dd2188d60e31b815260040160405180910390fd5b611269838383613509565b7f32a781031f04cc60b32394e40124d1e87f54273bf26d0532a115a424f6a93298612bb281612edb565b612bba612f29565b610fe6848484613509565b7f6618a6d92147bbcacfb2ef2375976fc4c529eeeaeb72a66048296571370c6946612bef81612edb565b612bf8836115eb565b612c1557604051631dd2188d60e31b815260040160405180910390fd5b81612c1e612ee8565b6001600160a01b0385165f8181526009929092016020526040808320805460ff191694151594909417909355915184151592917f0adde9ce751962c98f81b39c8c220e3e355e0427d8f497ad6533849e0887543d91a3505050565b5f8051602061433f833981519152612c9081612edb565b81612c99612ee8565b60040180546001600160a01b0319166001600160a01b039283161790556040515f8152908316907f59dc533a8345ccff036afdd89363a87154a5e6c51ff4fc507fc1865bb925438e906020016112dc565b7f407fc42eadf1aba68b1d4a8c3c4aa2e8b6beac7957623f3694d0ad77bfb70e06612d1481612edb565b81612d1d612ee8565b600601556040518281527f7abc95a9228ca8caf8cbd0d9add729de5d2032bb1792bb6c5faff0f175f1bd509060200160405180910390a15050565b5f612d61612ee8565b9050600b81015f612d7182612f20565b90505f5b81811015612e6d575f612d8884836130a5565b6001600160a01b0381165f908152600a870160205260408120919250612dad82612f20565b90505f5b81811015612e5d575f612dc484836130a5565b6001600160a01b0381165f90815260088b01602052604090205490915060ff1615612e5457604051630f41a04d60e11b81526001600160a01b038b81166004830152821690631e83409a906024016020604051808303815f875af1158015612e2e573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612e529190613f73565b505b50600101612db1565b505060019092019150612d759050565b506040516001600160a01b038516907f3a97aa17a51b3fa88e27cdce48823bea308838ed5ea8015ae0598abb1288954b905f90a250505050565b5f6001600160e01b03198216637965db0b60e01b1480610d8357506301ffc9a760e01b6001600160e01b0319831614610d83565b612ee581336135c8565b50565b7f000000000000000000000000000000000000000000000000000000000000000090565b5f61243a836001600160a01b038416613601565b5f610d83825490565b5f8051602061439f833981519152805460011901612f5a57604051633ee5aeb560e01b815260040160405180910390fd5b60029055565b612f6861158e565b6001600160a01b031663fea34d988484612f81856142fa565b6040516001600160e01b031960e086901b1681526001600160a01b03938416600482015292909116602483015260448201526064015f604051808303815f87803b158015612fcd575f80fd5b505af1158015612fdf573d5f803e3d5ffd5b50506040516387cd303d60e01b81526001600160a01b03858116600483015260248201859052861692506387cd303d91506044015f604051808303815f87803b15801561302a575f80fd5b505af115801561303c573d5f803e3d5ffd5b50505050826001600160a01b0316826001600160a01b03167f409f90100010c596e4859c24945544ea3430a899b81522dadfd9671b9bc1a4028360405161308591815260200190565b60405180910390a3505050565b60015f8051602061439f83398151915255565b5f61243a83836136e4565b5f6130bb838361370a565b15613122576130ea7f00000000000000000000000000000000000000000000000000000000000000008461374c565b1561311a5760405183907fea0f1c470fa813c725756c036120b6688028969f5afbc607918fcd1ff9229435905f90a25b506001610d83565b505f92915050565b5f6131358383613757565b1561312257613143836128b2565b5f0361311a576131737f000000000000000000000000000000000000000000000000000000000000000084613790565b5060405183907f4c9a714f78b79aa08074addab7cbdb196cccdf6d67efbf0b99914db8a6b08e73905f90a2506001610d83565b5f807ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00610d83565b6131d661379b565b6131de6137c0565b565b6131e861379b565b6001600160a01b03811661320f5760405163d92e233d60e01b815260040160405180910390fd5b6132195f826130b0565b5050565b61322561379b565b6001600160a01b038616158061324257506001600160a01b038516155b8061325457506001600160a01b038416155b156132725760405163d92e233d60e01b815260040160405180910390fd5b5f61327b612ee8565b80546001600160a01b03199081166001600160a01b03998a161782556001820180548216988a16989098179097556002810180548816968916969096179095555060038401805486169387169390931790925560048301805490941694169390931790915560060155565b6132ee61379b565b6001600160a01b0381166133155760405163d92e233d60e01b815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000080546001600160a01b0319166001600160a01b0392909216919091179055565b5f818152600183016020526040812054151561243a565b6001600160a01b0381165f908152600183016020526040812054151561243a565b5f61243a836001600160a01b0384166137d0565b5f73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeed196001600160a01b038416016133d957506001600160a01b03811631610d83565b6040516370a0823160e01b81526001600160a01b0383811660048301528416906370a0823190602401602060405180830381865afa15801561341d573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906134419190613fd2565b9050610d83565b60605f61243a8361381c565b60605f80846001600160a01b0316846040516134709190614314565b5f60405180830381855af49150503d805f81146134a8576040519150601f19603f3d011682016040523d82523d5f602084013e6134ad565b606091505b50915091506134bd858383613875565b95945050505050565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeed196001600160a01b038416016134f55761126982826138d1565b6112696001600160a01b038416838361395d565b61351161158e565b604051631fd469b360e31b81526001600160a01b038581166004830152848116602483015260448201849052919091169063fea34d98906064015f604051808303815f87803b158015613562575f80fd5b505af1158015613574573d5f803e3d5ffd5b505050506135838284836134c6565b826001600160a01b0316826001600160a01b03167f7ceb394e9ff104c51756ee69383bfb2d366c02d663c194870b8001bad9021aef8360405161308591815260200190565b6135d28282611e72565b6132195760405163e2517d3f60e01b81526001600160a01b0382166004820152602481018390526044016111e3565b5f81815260018301602052604081205480156136db575f6136236001836142e7565b85549091505f90613636906001906142e7565b9050808214613695575f865f01828154811061365457613654614217565b905f5260205f200154905080875f01848154811061367457613674614217565b5f918252602080832090910192909255918252600188019052604090208390555b85548690806136a6576136a661432a565b600190038181905f5260205f20015f90559055856001015f8681526020019081526020015f205f905560019350505050610d83565b5f915050610d83565b5f825f0182815481106136f9576136f9614217565b905f5260205f200154905092915050565b5f5f8051602061435f8339815191528161372485856139af565b9050801561135f575f858152602083905260409020613743908561338e565b50949350505050565b5f61243a83836137d0565b5f5f8051602061435f833981519152816137718585613a47565b9050801561135f575f8581526020839052604090206137439085612f0c565b5f61243a8383613601565b6137a3613ac0565b6131de57604051631afcd79f60e31b815260040160405180910390fd5b6137c861379b565b6131de613ad9565b5f81815260018301602052604081205461381557508154600181810184555f848152602080822090930184905584548482528286019093526040902091909155610d83565b505f610d83565b6060815f0180548060200260200160405190810160405280929190818152602001828054801561386957602002820191905f5260205f20905b815481526020019060010190808311613855575b50505050509050919050565b60608261388a5761388582613ae1565b61243a565b81511580156138a157506001600160a01b0384163b155b156138ca57604051639996b31560e01b81526001600160a01b03851660048201526024016111e3565b5092915050565b804710156138fb5760405163cf47918160e01b8152476004820152602481018290526044016111e3565b5f80836001600160a01b0316836040515f6040518083038185875af1925050503d805f8114613945576040519150601f19603f3d011682016040523d82523d5f602084013e61394a565b606091505b509150915081610ffc57610ffc81613ae1565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052611269908490613b0a565b5f5f8051602061437f8339815191526139c88484611e72565b6136db575f848152602082815260408083206001600160a01b03871684529091529020805460ff191660011790556139fd3390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001915050610d83565b5f5f8051602061437f833981519152613a608484611e72565b156136db575f848152602082815260408083206001600160a01b0387168085529252808320805460ff1916905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a46001915050610d83565b5f613ac96131a6565b54600160401b900460ff16919050565b61309261379b565b805115613af15780518082602001fd5b60405163d6bda27560e01b815260040160405180910390fd5b5f8060205f8451602086015f885af180613b29576040513d5f823e3d81fd5b50505f513d91508115613b40578060011415613b4d565b6001600160a01b0384163b155b15610ffc57604051635274afe760e01b81526001600160a01b03851660048201526024016111e3565b5f60208284031215613b86575f80fd5b81356001600160e01b03198116811461243a575f80fd5b6001600160a01b0381168114612ee5575f80fd5b5f60208284031215613bc1575f80fd5b813561243a81613b9d565b5f8083601f840112613bdc575f80fd5b50813567ffffffffffffffff811115613bf3575f80fd5b602083019150836020828501011115613c0a575f80fd5b9250929050565b5f805f805f60808688031215613c25575f80fd5b8535613c3081613b9d565b94506020860135613c4081613b9d565b935060408601359250606086013567ffffffffffffffff811115613c62575f80fd5b613c6e88828901613bcc565b969995985093965092949392505050565b5f805f60608486031215613c91575f80fd5b8335613c9c81613b9d565b92506020840135613cac81613b9d565b929592945050506040919091013590565b5f60208284031215613ccd575f80fd5b5035919050565b5f8060408385031215613ce5575f80fd5b823591506020830135613cf781613b9d565b809150509250929050565b5f8060208385031215613d13575f80fd5b823567ffffffffffffffff811115613d29575f80fd5b613d3585828601613bcc565b90969095509350505050565b5f805f60608486031215613d53575f80fd5b833592506020840135613d6581613b9d565b91506040840135613d7581613b9d565b809150509250925092565b8015158114612ee5575f80fd5b5f805f805f8060a08789031215613da2575f80fd5b863595506020870135613db481613d80565b94506040870135613dc481613b9d565b93506060870135613dd481613b9d565b9250608087013567ffffffffffffffff811115613def575f80fd5b613dfb89828a01613bcc565b979a9699509497509295939492505050565b5f8060408385031215613e1e575f80fd5b50508035926020909101359150565b803563ffffffff81168114613e40575f80fd5b919050565b5f805f8060808587031215613e58575f80fd5b8435613e6381613b9d565b935060208501356001600160e01b0381168114613e7e575f80fd5b9250613e8c60408601613e2d565b9150613e9a60608601613e2d565b905092959194509250565b602080825282518282018190525f9190848201906040850190845b81811015613ee55783516001600160a01b031683529284019291840191600101613ec0565b50909695505050505050565b5f8060408385031215613f02575f80fd5b8235613f0d81613b9d565b946020939093013593505050565b5f8060408385031215613f2c575f80fd5b8235613f3781613b9d565b91506020830135613cf781613b9d565b5f8060408385031215613f58575f80fd5b8235613f6381613b9d565b91506020830135613cf781613d80565b5f60208284031215613f83575f80fd5b815161243a81613d80565b5f60208284031215613f9e575f80fd5b815161243a81613b9d565b634e487b7160e01b5f52601160045260245ffd5b5f81613fcb57613fcb613fa9565b505f190190565b5f60208284031215613fe2575f80fd5b5051919050565b80820180821115610d8357610d83613fa9565b634e487b7160e01b5f52604160045260245ffd5b6040805190810167ffffffffffffffff8111828210171561403357614033613ffc565b60405290565b604051601f8201601f1916810167ffffffffffffffff8111828210171561406257614062613ffc565b604052919050565b5f805f805f805f805f6101208a8c031215614083575f80fd5b61408d8a35613b9d565b8935985061409e60208b0135613b9d565b60208a013597506140b260408b0135613b9d565b60408a013596506140c660608b0135613b9d565b60608a013595506140da60808b0135613b9d565b60808a013594506140ee60a08b0135613b9d565b60a08a0135935061410260c08b0135613b9d565b60c08a0135925060e08a0135915067ffffffffffffffff6101008b01351115614129575f80fd5b8a601f6101008c01358c01011261413e575f80fd5b67ffffffffffffffff6101008b01358b0135111561415e5761415e613ffc565b61417560206101008c01358c013560051b01614039565b6101008b01358b0180358083526020808401939260069290921b909101018d101561419e575f80fd5b60206101008d01358d01015b6101008d01358d01803560061b01602001811015614204576040818f0312156141d1575f80fd5b6141d9614010565b813581526141ea6020830135613b9d565b6020828101358282015290845292909201916040016141aa565b5080925050509295985092959850929598565b634e487b7160e01b5f52603260045260245ffd5b81835281816020850137505f828201602090810191909152601f909101601f19169091010190565b602081525f61135f60208301848661422b565b83815260018060a01b0383166020820152606060408201525f82518060608401528060208501608085015e5f608082850101526080601f19601f830116840101915050949350505050565b6001600160a01b038581168252841660208201526060604082018190525f906142dd908301848661422b565b9695505050505050565b81810381811115610d8357610d83613fa9565b5f600160ff1b820161430e5761430e613fa9565b505f0390565b5f82518060208501845e5f920191825250919050565b634e487b7160e01b5f52603160045260245ffdfe627f9e4ac2dadb64d045e7e6333c09f39ed34e0e066957955d0052b46d2e83e8c1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e8237170593200002dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268009b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00a2646970667358221220f303aa1e88b412ecf0bdcb901f6ae9e7c31b41c352254af18ab9efef324a829664736f6c6343000819003300000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000a67330bb89668ba66502a6d6670dacf5f334eb53000000000000000000000000a92cea07d6009de8f2aa377a4298deccf94d942a0000000000000000000000005e11c97db901edd8932fdaa77b015da89f3f289e00000000000000000000000048766b2e6b321f6550988d1a2e09b42e9170875900000000000000000000000000000000000000000000000000000000000000064d656c6c6f770000000000000000000000000000000000000000000000000000
Deployed Bytecode
0x6080604052600436106103ed575f3560e01c8063850260ff1161020a578063b014f4451161011e578063e4f8d0e6116100a8578063eb56d52d11610078578063eb56d52d14610cc3578063ec0f580014610ce2578063ecef475f14610d01578063f31cb0c614610d20578063f68e730414610d3f575f80fd5b8063e4f8d0e614610c33578063e6c8cd9f14610c52578063e6ed8d7414610c71578063e984f35314610ca4575f80fd5b8063ca15c873116100ee578063ca15c87314610b8f578063d0fb020314610bae578063d27d250314610bc2578063d547741f14610be1578063d8b07a6514610c00575f80fd5b8063b014f44514610aff578063b1a62e3b14610b1e578063b2b71a2714610b51578063b91c935c14610b70575f80fd5b80639ff2cb9d1161019f578063a3246ad31161016f578063a3246ad314610a4e578063a35f620a14610a7a578063a567fb4714610a8e578063aa9239f514610aad578063adf167ce14610acc575f80fd5b80639ff2cb9d146109d5578063a0aead4d14610a08578063a217fddf14610a1c578063a2cb31e514610a2f575f80fd5b806392e6ece5116101da57806392e6ece5146109455780639662d42914610964578063974d942e146109975780639bd0911b146109b6575f80fd5b8063850260ff146108c95780638679ed7c146108e85780639010d07c1461090757806391d1485414610926575f80fd5b8063419a2053116103015780635636d54911610296578063651ae6c711610266578063651ae6c71461081c578063663ade061461084f5780636b8b1ccd146108825780637dc0d1d0146108965780638333903b146108aa575f80fd5b80635636d549146107ad57806358b7bf30146107c15780635c60173d146107f45780635d66b00a14610808575f80fd5b80634b694b96116102d15780634b694b961461071d5780634b812c1f1461073c57806352278ab71461075b57806352fd42541461077a575f80fd5b8063419a2053146106b7578063439fab91146106cb57806347842663146106ea5780634a46b4cf146106fe575f80fd5b80632f2ff15d1161038257806336568abe1161035257806336568abe146105fb578063370488161461061a578063387db78f146106395780633d4304e6146106845780634015b2a8146106a3575f80fd5b80632f2ff15d146105765780632f8ecb50146105955780633314bbb9146105b45780633471b337146105e7575f80fd5b806317cbc8b1116103bd57806317cbc8b1146104d25780631c14724f146104f15780631ca0027a14610510578063248a9ca314610557575f80fd5b806301ffc9a7146103f8578063040bee6d1461042c57806313cb953a1461044d578063150b7a021461048e575f80fd5b366103f457005b5f80fd5b348015610403575f80fd5b50610417610412366004613b76565b610d5f565b60405190151581526020015b60405180910390f35b348015610437575f80fd5b5061044b610446366004613bb1565b610d89565b005b348015610458575f80fd5b506104807f32a781031f04cc60b32394e40124d1e87f54273bf26d0532a115a424f6a9329881565b604051908152602001610423565b348015610499575f80fd5b506104b96104a8366004613c11565b630a85bd0160e11b95945050505050565b6040516001600160e01b03199091168152602001610423565b3480156104dd575f80fd5b5061044b6104ec366004613c7f565b610fa9565b3480156104fc575f80fd5b5061048061050b366004613bb1565b611002565b34801561051b575f80fd5b5061054861052a366004613cbd565b60408051602080820183525f90915281519081019091529054815290565b60405190518152602001610423565b348015610562575f80fd5b50610480610571366004613cbd565b61112b565b348015610581575f80fd5b5061044b610590366004613cd4565b61114b565b3480156105a0575f80fd5b5061044b6105af366004613bb1565b611167565b3480156105bf575f80fd5b506104807f68895691ff006f290ca74825ce06ed17fffab55af49f0274f49b7424f752583a81565b3480156105f2575f80fd5b50610480611224565b348015610606575f80fd5b5061044b610615366004613cd4565b611236565b348015610625575f80fd5b5061044b610634366004613bb1565b61126e565b348015610644575f80fd5b5061066c7f00000000000000000000000048766b2e6b321f6550988d1a2e09b42e9170875981565b6040516001600160a01b039091168152602001610423565b34801561068f575f80fd5b5061066c61069e366004613bb1565b6112e8565b3480156106ae575f80fd5b5061066c611367565b3480156106c2575f80fd5b50610480611382565b3480156106d6575f80fd5b5061044b6106e5366004613d02565b6113b1565b3480156106f5575f80fd5b5061066c61158e565b348015610709575f80fd5b50610417610718366004613cbd565b6115c0565b348015610728575f80fd5b50610417610737366004613bb1565b6115eb565b348015610747575f80fd5b5061066c610756366004613d41565b61167a565b348015610766575f80fd5b50610480610775366004613bb1565b611959565b348015610785575f80fd5b5061066c7f000000000000000000000000a67330bb89668ba66502a6d6670dacf5f334eb5381565b3480156107b8575f80fd5b5061066c611985565b3480156107cc575f80fd5b506104807fb557d53a2e72d8333ffa3bf2f556678becb5e995b0e25b7dca354627e550c08f81565b3480156107ff575f80fd5b5061066c6119a0565b348015610813575f80fd5b506104806119a9565b348015610827575f80fd5b506104807f9a4c49d6fb9452bbfe187968075d0fac7d7202d2b7f731d8cffbce9cf66756b281565b34801561085a575f80fd5b506104807ff610639f4b9b8986f875fcb4e49486da5c7aa449a6942b5013fabd061e9b9fff81565b34801561088d575f80fd5b50610480611b18565b3480156108a1575f80fd5b5061066c611b2a565b3480156108b5575f80fd5b506104176108c4366004613bb1565b611b45565b3480156108d4575f80fd5b5061044b6108e3366004613d8d565b611b73565b3480156108f3575f80fd5b50610417610902366004613bb1565b611e20565b348015610912575f80fd5b5061066c610921366004613e0d565b611e4d565b348015610931575f80fd5b50610417610940366004613cd4565b611e72565b348015610950575f80fd5b5061041761095f366004613bb1565b611ea8565b34801561096f575f80fd5b5061066c7f000000000000000000000000a92cea07d6009de8f2aa377a4298deccf94d942a81565b3480156109a2575f80fd5b5061044b6109b1366004613e45565b611ed5565b3480156109c1575f80fd5b5061066c6109d0366004613cbd565b6123a4565b3480156109e0575f80fd5b5061066c7f0000000000000000000000005e11c97db901edd8932fdaa77b015da89f3f289e81565b348015610a13575f80fd5b506104806123d2565b348015610a27575f80fd5b506104805f81565b348015610a3a575f80fd5b50610480610a49366004613cbd565b6123e6565b348015610a59575f80fd5b50610a6d610a68366004613cbd565b612411565b6040516104239190613ea5565b348015610a85575f80fd5b50610480612441565b348015610a99575f80fd5b50610417610aa8366004613bb1565b61246e565b348015610ab8575f80fd5b5061066c610ac7366004613cbd565b612484565b348015610ad7575f80fd5b506104807f85c2023fdfb1e93dedf5d18f9bc0e79347e071d12740ba71aeb84a4fcbdc4b7981565b348015610b0a575f80fd5b5061044b610b19366004613c7f565b61249a565b348015610b29575f80fd5b506104807f6788636e7899d6d227901dc9f8c4c785401c0991724cf908dc65388af686da6f81565b348015610b5c575f80fd5b5061044b610b6b366004613bb1565b6124c5565b348015610b7b575f80fd5b5061066c610b8a366004613ef1565b612884565b348015610b9a575f80fd5b50610480610ba9366004613cbd565b6128b2565b348015610bb9575f80fd5b5061066c6128d6565b348015610bcd575f80fd5b5061044b610bdc366004613cbd565b6128f1565b348015610bec575f80fd5b5061044b610bfb366004613cd4565b612a98565b348015610c0b575f80fd5b506104807f6618a6d92147bbcacfb2ef2375976fc4c529eeeaeb72a66048296571370c694681565b348015610c3e575f80fd5b5061044b610c4d366004613f1b565b612ab4565b348015610c5d575f80fd5b5061044b610c6c366004613c7f565b612b5d565b348015610c7c575f80fd5b506104807f407fc42eadf1aba68b1d4a8c3c4aa2e8b6beac7957623f3694d0ad77bfb70e0681565b348015610caf575f80fd5b5061044b610cbe366004613c7f565b612b88565b348015610cce575f80fd5b5061044b610cdd366004613f47565b612bc5565b348015610ced575f80fd5b5061044b610cfc366004613bb1565b612c79565b348015610d0c575f80fd5b5061044b610d1b366004613cbd565b612cea565b348015610d2b575f80fd5b5061044b610d3a366004613bb1565b612d58565b348015610d4a575f80fd5b506104805f8051602061433f83398151915281565b5f6001600160e01b03198216635a05180f60e01b1480610d835750610d8382612ea7565b92915050565b7f9a4c49d6fb9452bbfe187968075d0fac7d7202d2b7f731d8cffbce9cf66756b2610db381612edb565b816001600160a01b031663c2f218966040518163ffffffff1660e01b8152600401602060405180830381865afa158015610def573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e139190613f73565b610e3057604051631dd2188d60e31b815260040160405180910390fd5b5f826001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e6d573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e919190613f8e565b90505f610e9c612ee8565b6001600160a01b0383165f908152600a820160205260409020909150610ec29085612f0c565b610edf57604051631dd2188d60e31b815260040160405180910390fd5b6001600160a01b038085165f9081526008830160209081526040808320805460ff191690559285168252600a8401905220610f1990612f20565b5f03610f2e57610f2c600b820183612f0c565b505b6001600160a01b0384165f908152600782016020526040812080546001600160a01b0319169055600582018054909190610f6790613fbd565b909155506040516001600160a01b0380841691908616907faf660c1b265f07536d70b577e6dac1fed859eae81dca40591155a8fa2294553d905f90a350505050565b7f68895691ff006f290ca74825ce06ed17fffab55af49f0274f49b7424f752583a610fd381612edb565b610fdb612f29565b610fe6848484612f60565b610ffc60015f8051602061439f83398151915255565b50505050565b5f8061100c612ee8565b9050600b81015f61101c82612f20565b90505f5b81811015611122575f61103384836130a5565b6001600160a01b0381165f908152600a87016020526040812091925061105882612f20565b90505f5b81811015611112575f61106f84836130a5565b6001600160a01b0381165f90815260088b01602052604090205490915060ff161561110957604051638903ab9d60e01b81526001600160a01b038c81166004830152821690638903ab9d90602401602060405180830381865afa1580156110d8573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906110fc9190613fd2565b611106908b613fe9565b99505b5060010161105c565b5050600190920191506110209050565b50505050919050565b5f9081525f8051602061437f833981519152602052604090206001015490565b6111548261112b565b61115d81612edb565b610ffc83836130b0565b7ff610639f4b9b8986f875fcb4e49486da5c7aa449a6942b5013fabd061e9b9fff61119181612edb565b7fa0dfab7837230c89b90a550f1ff19f8fa745cc29985f05675859eedfef5b80006111bf6001820184612f0c565b6111ec57604051635c6a489f60e01b81526001600160a01b03841660048201526024015b60405180910390fd5b6040516001600160a01b038416907f95067a3324c952e40449419ed59015549ae2c2b2c5988efb9bdaaf33baf6f793905f90a2505050565b5f61122d612ee8565b60050154905090565b6001600160a01b038116331461125f5760405163334bd91960e11b815260040160405180910390fd5b611269828261312a565b505050565b5f8051602061433f83398151915261128581612edb565b8161128e612ee8565b60030180546001600160a01b0319166001600160a01b0392831617905560405160018152908316907f59dc533a8345ccff036afdd89363a87154a5e6c51ff4fc507fc1865bb925438e906020015b60405180910390a25050565b5f806112f2612ee8565b6001600160a01b038085165f908152600783016020526040902054919250168061135d576001600160a01b0384165f90815260088301602052604090205460ff1661134a5760048201546001600160a01b031661135f565b60038201546001600160a01b031661135f565b805b949350505050565b5f611370612ee8565b600401546001600160a01b0316919050565b5f6113ac7f062030953ce644a2a7115259790ad01d3c2b5e8c98fc6b190da443a3f0a7c900612f20565b905090565b5f6113ba6131a6565b805490915060ff600160401b820416159067ffffffffffffffff165f811580156113e15750825b90505f8267ffffffffffffffff1660011480156113fd5750303b155b90508115801561140b575080155b156114295760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff19166001178555831561145357845460ff60401b1916600160401b1785555b5f805f805f805f805f8f8f81019061146b919061406a565b9850985098509850985098509850985098506114856131ce565b61148e896131e0565b61149c88888787878761321d565b6114a5866132e6565b5f5b81518110156114fc576114f38282815181106114c5576114c5614217565b60200260200101515f01518383815181106114e2576114e2614217565b6020026020010151602001516130b0565b506001016114a7565b505050505050505050507f5e399709a9ff1709f6f6be7268c8e5c3eeaa9da9cd9797e78f07ef287c3717fe8787604051611537929190614253565b60405180910390a1831561158557845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50505050505050565b5f7fa0dfab7837230c89b90a550f1ff19f8fa745cc29985f05675859eedfef5b80005b546001600160a01b0316919050565b5f610d837f062030953ce644a2a7115259790ad01d3c2b5e8c98fc6b190da443a3f0a7c90083613356565b5f610d83826115f8612ee8565b600a015f856001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611638573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061165c9190613f8e565b6001600160a01b0316815260208101919091526040015f209061336d565b5f7f85c2023fdfb1e93dedf5d18f9bc0e79347e071d12740ba71aeb84a4fcbdc4b796116a581612edb565b6116ad612f29565b6040516302910f8b60e31b81526001600160a01b0384811660048301527f00000000000000000000000048766b2e6b321f6550988d1a2e09b42e9170875916906314887c5890602401602060405180830381865afa158015611711573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906117359190613f73565b61175d5760405163d0b5c30560e01b81526001600160a01b03841660048201526024016111e3565b306001600160a01b0316836001600160a01b031663fbfa77cf6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156117a3573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906117c79190613f8e565b6001600160a01b0316146117ee57604051631dd2188d60e31b815260040160405180910390fd5b7f0000000000000000000000005e11c97db901edd8932fdaa77b015da89f3f289e6001600160a01b03166346fbcbb2868686306040516020016118479291906001600160a01b0392831681529116602082015260400190565b6040516020818303038152906040526040518463ffffffff1660e01b815260040161187493929190614266565b6020604051808303815f875af1158015611890573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906118b49190613f8e565b91506118e360017fa0dfab7837230c89b90a550f1ff19f8fa745cc29985f05675859eedfef5b8000018361338e565b50826001600160a01b0316846001600160a01b0316836001600160a01b03167fae0bbc337ca4971dd982cb61e17432f83cf2e5647ad778f7db9ff18efd77a2118860405161193391815260200190565b60405180910390a461195160015f8051602061439f83398151915255565b509392505050565b5f610d83611965612ee8565b6001600160a01b0384165f908152600a9190910160205260409020612f20565b5f61198e612ee8565b600301546001600160a01b0316919050565b5f6115b1612ee8565b5f803390505f816001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156119eb573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611a0f9190613f8e565b90505f611a1a612ee8565b6001600160a01b0383165f908152600a820160205260409020909150611a40908461336d565b1580611a6557506001600160a01b0383165f90815260088201602052604090205460ff165b15611a8357604051631dd2188d60e31b815260040160405180910390fd5b5f611a8d846112e8565b90506001600160a01b038116611ab057611aa783306133a2565b94505050505090565b604051630af5049b60e11b81526001600160a01b0384811660048301528216906315ea093690602401602060405180830381865afa158015611af4573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611aa79190613fd2565b5f611b21612ee8565b60060154905090565b5f611b33612ee8565b600201546001600160a01b0316919050565b5f610d8360017fa0dfab7837230c89b90a550f1ff19f8fa745cc29985f05675859eedfef5b8000018361336d565b611b7b612f29565b7f6788636e7899d6d227901dc9f8c4c785401c0991724cf908dc65388af686da6f611ba581612edb565b5f611bae612ee8565b6002810154604051634df48c7360e11b81526001600160a01b038881166004830152929350911690639be918e690602401602060405180830381865afa158015611bfa573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611c1e9190613f73565b611c465760405163ee84f40b60e01b81526001600160a01b03861660048201526024016111e3565b5f81600501546001611c589190613fe9565b90508160060154811115611c7f5760405163082d389160e31b815260040160405180910390fd5b5f88611cab577f000000000000000000000000a92cea07d6009de8f2aa377a4298deccf94d942a611ccd565b7f000000000000000000000000a67330bb89668ba66502a6d6670dacf5f334eb535b6001600160a01b03166346fbcbb28b8a8a308b8b604051602001611cf494939291906142b1565b6040516020818303038152906040526040518463ffffffff1660e01b8152600401611d2193929190614266565b6020604051808303815f875af1158015611d3d573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611d619190613f8e565b600584018390556001600160a01b0388165f908152600a850160205260409020909150611d8e908261338e565b50611d9c600b84018861338e565b506001600160a01b038181165f818152600886016020908152604091829020805460ff19168e15159081179091559151918252928a16927f8138cea23ce1869026f924550085f1d5666d82c6c948c921cf9003cac6bfea9c910160405180910390a350505050611e1860015f8051602061439f83398151915255565b505050505050565b5f611e29612ee8565b6001600160a01b039092165f90815260099290920160205250604090205460ff1690565b5f8281525f8051602061435f83398151915260208190526040822061135f90846130a5565b5f9182525f8051602061437f833981519152602090815260408084206001600160a01b0393909316845291905290205460ff1690565b5f611eb1612ee8565b6001600160a01b039092165f90815260089290920160205250604090205460ff1690565b611edd612f29565b5f611ee6612ee8565b60028101549091506001600160a01b0316336001600160a01b031614611f1f57604051631dd2188d60e31b815260040160405180910390fd5b80546001820154604051630cd9f5f560e11b81523060048201526001600160a01b0392831692909116905f9082906319b3ebea90602401602060405180830381865afa158015611f71573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611f959190613f8e565b6001600160a01b0316886001600160a01b031603612242575f826001600160a01b031663469048406040518163ffffffff1660e01b8152600401602060405180830381865afa158015611fea573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061200e9190613f8e565b604051639d66201b60e01b81526001600160a01b0380831660048301529192508185169163e0e193a29130918d918d918a1690639d66201b90602401602060405180830381865afa158015612065573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906120899190613fd2565b896001600160a01b0316633a98ef396040518163ffffffff1660e01b8152600401602060405180830381865afa1580156120c5573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906120e99190613fd2565b6120f391906142e7565b6040516001600160e01b031960e087901b1681526001600160a01b0394851660048201529390921660248401526001600160e01b031660448301526064820152608401602060405180830381865afa158015612151573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906121759190613fd2565b915081156121db576040516340c10f1960e01b81526001600160a01b038281166004830152602482018490528516906340c10f19906044015f604051808303815f87803b1580156121c4575f80fd5b505af11580156121d6573d5f803e3d5ffd5b505050505b604051634d71303160e11b81526001600160a01b038a811660048301526001600160e01b038a166024830152841690639ae26062906044015f604051808303815f87803b15801561222a575f80fd5b505af115801561223c573d5f803e3d5ffd5b50505050505b5f61224b612ee8565b6001600160a01b038a165f908152600a9190910160205260408120915061227182612f20565b90505f5b81811015612329575f61228884836130a5565b6001600160a01b0381165f81815260088b0160205260409020549192509063b8c5ea8a908d9060ff166122bb578b6122bd565b8c5b6040516001600160e01b031960e085901b1681526001600160e01b03909216600483015263ffffffff1660248201526044015f604051808303815f87803b158015612306575f80fd5b505af1158015612318573d5f803e3d5ffd5b505060019093019250612275915050565b506040805163ffffffff808b168252891660208201529081018490526001600160e01b038a16906001600160a01b038c16907f24bbf515a701fcb7a993b1e8c3f201ab4e608f7b85c61b1f8cc0e19dc9d526539060600160405180910390a3505050505050610ffc60015f8051602061439f83398151915255565b5f610d8360017fa0dfab7837230c89b90a550f1ff19f8fa745cc29985f05675859eedfef5b800001836130a5565b5f6113ac6123de612ee8565b600b01612f20565b5f610d837f062030953ce644a2a7115259790ad01d3c2b5e8c98fc6b190da443a3f0a7c900836130a5565b5f8181525f8051602061435f833981519152602081905260409091206060919061243a90613448565b9392505050565b5f6113ac7fa0dfab7837230c89b90a550f1ff19f8fa745cc29985f05675859eedfef5b8000600101612f20565b5f610d838261247b612ee8565b600b019061336d565b5f610d8382612491612ee8565b600b01906130a5565b3330146124ba57604051631dd2188d60e31b815260040160405180910390fd5b611269838383612f60565b7fb557d53a2e72d8333ffa3bf2f556678becb5e995b0e25b7dca354627e550c08f6124ef81612edb565b5f7fa0dfab7837230c89b90a550f1ff19f8fa745cc29985f05675859eedfef5b80006040516302910f8b60e31b81526001600160a01b0385811660048301529192507f0000000000000000000000005e11c97db901edd8932fdaa77b015da89f3f289e909116906314887c5890602401602060405180830381865afa15801561257a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061259e9190613f73565b6125c65760405163d0b5c30560e01b81526001600160a01b03841660048201526024016111e3565b306001600160a01b0316836001600160a01b031663fbfa77cf6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561260c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906126309190613f8e565b6001600160a01b0316146126625760405163d034fb7960e01b81526001600160a01b03841660048201526024016111e3565b5f836001600160a01b0316632b7ac3f36040518163ffffffff1660e01b8152600401602060405180830381865afa15801561269f573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906126c39190613f8e565b6040516302910f8b60e31b81526001600160a01b0380831660048301529192507f00000000000000000000000048766b2e6b321f6550988d1a2e09b42e91708759909116906314887c5890602401602060405180830381865afa15801561272c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906127509190613f73565b6127785760405163d0b5c30560e01b81526001600160a01b03821660048201526024016111e3565b306001600160a01b0316816001600160a01b031663fbfa77cf6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156127be573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906127e29190613f8e565b6001600160a01b03161461280957604051631dd2188d60e31b815260040160405180910390fd5b612816600183018561338e565b61283e57604051638cd80ed360e01b81526001600160a01b03851660048201526024016111e3565b806001600160a01b0316846001600160a01b03167ff75f2e4922769fc299f8f612c31f2d1f8ea0e6fa4c82fdb143bf9c8a070c974c60405160405180910390a350505050565b5f61243a82612891612ee8565b6001600160a01b0386165f908152600a9190910160205260409020906130a5565b5f8181525f8051602061435f83398151915260208190526040822061243a90612f20565b5f6128df612ee8565b600101546001600160a01b0316919050565b5f3390505f816001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612932573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906129569190613f8e565b90505f612961612ee8565b90506129908361296f612ee8565b6001600160a01b0385165f908152600a91909101602052604090209061336d565b6129ad57604051631dd2188d60e31b815260040160405180910390fd5b5f6129b7846112e8565b90506001600160a01b03811615612a1b576040516001600160a01b038416602482015260448101869052612a1990829060640160408051601f198184030181529190526020810180516001600160e01b03166330f736c160e21b179052613454565b505b6001600160a01b0384165f90815260088301602052604090205460ff16612a4757612a478385876134c6565b604080518681526001600160a01b03838116602083015280861692908716917fc23ec549723039bc8a35cac0162f81095410795793f7730887eb1a0e06ef5476910160405180910390a35050505050565b612aa18261112b565b612aaa81612edb565b610ffc838361312a565b5f8051602061433f833981519152612acb81612edb565b6001600160a01b038316612af25760405163d92e233d60e01b815260040160405180910390fd5b81612afb612ee8565b6001600160a01b038581165f818152600793909301602052604080842080546001600160a01b03191695841695909517909455925190851692917f329d0838d5265a7d9d220b95803da511a475abe411dc4df364c1d1b8b923cdf991a3505050565b333014612b7d57604051631dd2188d60e31b815260040160405180910390fd5b611269838383613509565b7f32a781031f04cc60b32394e40124d1e87f54273bf26d0532a115a424f6a93298612bb281612edb565b612bba612f29565b610fe6848484613509565b7f6618a6d92147bbcacfb2ef2375976fc4c529eeeaeb72a66048296571370c6946612bef81612edb565b612bf8836115eb565b612c1557604051631dd2188d60e31b815260040160405180910390fd5b81612c1e612ee8565b6001600160a01b0385165f8181526009929092016020526040808320805460ff191694151594909417909355915184151592917f0adde9ce751962c98f81b39c8c220e3e355e0427d8f497ad6533849e0887543d91a3505050565b5f8051602061433f833981519152612c9081612edb565b81612c99612ee8565b60040180546001600160a01b0319166001600160a01b039283161790556040515f8152908316907f59dc533a8345ccff036afdd89363a87154a5e6c51ff4fc507fc1865bb925438e906020016112dc565b7f407fc42eadf1aba68b1d4a8c3c4aa2e8b6beac7957623f3694d0ad77bfb70e06612d1481612edb565b81612d1d612ee8565b600601556040518281527f7abc95a9228ca8caf8cbd0d9add729de5d2032bb1792bb6c5faff0f175f1bd509060200160405180910390a15050565b5f612d61612ee8565b9050600b81015f612d7182612f20565b90505f5b81811015612e6d575f612d8884836130a5565b6001600160a01b0381165f908152600a870160205260408120919250612dad82612f20565b90505f5b81811015612e5d575f612dc484836130a5565b6001600160a01b0381165f90815260088b01602052604090205490915060ff1615612e5457604051630f41a04d60e11b81526001600160a01b038b81166004830152821690631e83409a906024016020604051808303815f875af1158015612e2e573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612e529190613f73565b505b50600101612db1565b505060019092019150612d759050565b506040516001600160a01b038516907f3a97aa17a51b3fa88e27cdce48823bea308838ed5ea8015ae0598abb1288954b905f90a250505050565b5f6001600160e01b03198216637965db0b60e01b1480610d8357506301ffc9a760e01b6001600160e01b0319831614610d83565b612ee581336135c8565b50565b7f5e907b18dc7e0ef0ce1a83718e9f42938fe96f2ef0fee10bf8326c664faa870090565b5f61243a836001600160a01b038416613601565b5f610d83825490565b5f8051602061439f833981519152805460011901612f5a57604051633ee5aeb560e01b815260040160405180910390fd5b60029055565b612f6861158e565b6001600160a01b031663fea34d988484612f81856142fa565b6040516001600160e01b031960e086901b1681526001600160a01b03938416600482015292909116602483015260448201526064015f604051808303815f87803b158015612fcd575f80fd5b505af1158015612fdf573d5f803e3d5ffd5b50506040516387cd303d60e01b81526001600160a01b03858116600483015260248201859052861692506387cd303d91506044015f604051808303815f87803b15801561302a575f80fd5b505af115801561303c573d5f803e3d5ffd5b50505050826001600160a01b0316826001600160a01b03167f409f90100010c596e4859c24945544ea3430a899b81522dadfd9671b9bc1a4028360405161308591815260200190565b60405180910390a3505050565b60015f8051602061439f83398151915255565b5f61243a83836136e4565b5f6130bb838361370a565b15613122576130ea7f062030953ce644a2a7115259790ad01d3c2b5e8c98fc6b190da443a3f0a7c9008461374c565b1561311a5760405183907fea0f1c470fa813c725756c036120b6688028969f5afbc607918fcd1ff9229435905f90a25b506001610d83565b505f92915050565b5f6131358383613757565b1561312257613143836128b2565b5f0361311a576131737f062030953ce644a2a7115259790ad01d3c2b5e8c98fc6b190da443a3f0a7c90084613790565b5060405183907f4c9a714f78b79aa08074addab7cbdb196cccdf6d67efbf0b99914db8a6b08e73905f90a2506001610d83565b5f807ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00610d83565b6131d661379b565b6131de6137c0565b565b6131e861379b565b6001600160a01b03811661320f5760405163d92e233d60e01b815260040160405180910390fd5b6132195f826130b0565b5050565b61322561379b565b6001600160a01b038616158061324257506001600160a01b038516155b8061325457506001600160a01b038416155b156132725760405163d92e233d60e01b815260040160405180910390fd5b5f61327b612ee8565b80546001600160a01b03199081166001600160a01b03998a161782556001820180548216988a16989098179097556002810180548816968916969096179095555060038401805486169387169390931790925560048301805490941694169390931790915560060155565b6132ee61379b565b6001600160a01b0381166133155760405163d92e233d60e01b815260040160405180910390fd5b7fa0dfab7837230c89b90a550f1ff19f8fa745cc29985f05675859eedfef5b800080546001600160a01b0319166001600160a01b0392909216919091179055565b5f818152600183016020526040812054151561243a565b6001600160a01b0381165f908152600183016020526040812054151561243a565b5f61243a836001600160a01b0384166137d0565b5f73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeed196001600160a01b038416016133d957506001600160a01b03811631610d83565b6040516370a0823160e01b81526001600160a01b0383811660048301528416906370a0823190602401602060405180830381865afa15801561341d573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906134419190613fd2565b9050610d83565b60605f61243a8361381c565b60605f80846001600160a01b0316846040516134709190614314565b5f60405180830381855af49150503d805f81146134a8576040519150601f19603f3d011682016040523d82523d5f602084013e6134ad565b606091505b50915091506134bd858383613875565b95945050505050565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeed196001600160a01b038416016134f55761126982826138d1565b6112696001600160a01b038416838361395d565b61351161158e565b604051631fd469b360e31b81526001600160a01b038581166004830152848116602483015260448201849052919091169063fea34d98906064015f604051808303815f87803b158015613562575f80fd5b505af1158015613574573d5f803e3d5ffd5b505050506135838284836134c6565b826001600160a01b0316826001600160a01b03167f7ceb394e9ff104c51756ee69383bfb2d366c02d663c194870b8001bad9021aef8360405161308591815260200190565b6135d28282611e72565b6132195760405163e2517d3f60e01b81526001600160a01b0382166004820152602481018390526044016111e3565b5f81815260018301602052604081205480156136db575f6136236001836142e7565b85549091505f90613636906001906142e7565b9050808214613695575f865f01828154811061365457613654614217565b905f5260205f200154905080875f01848154811061367457613674614217565b5f918252602080832090910192909255918252600188019052604090208390555b85548690806136a6576136a661432a565b600190038181905f5260205f20015f90559055856001015f8681526020019081526020015f205f905560019350505050610d83565b5f915050610d83565b5f825f0182815481106136f9576136f9614217565b905f5260205f200154905092915050565b5f5f8051602061435f8339815191528161372485856139af565b9050801561135f575f858152602083905260409020613743908561338e565b50949350505050565b5f61243a83836137d0565b5f5f8051602061435f833981519152816137718585613a47565b9050801561135f575f8581526020839052604090206137439085612f0c565b5f61243a8383613601565b6137a3613ac0565b6131de57604051631afcd79f60e31b815260040160405180910390fd5b6137c861379b565b6131de613ad9565b5f81815260018301602052604081205461381557508154600181810184555f848152602080822090930184905584548482528286019093526040902091909155610d83565b505f610d83565b6060815f0180548060200260200160405190810160405280929190818152602001828054801561386957602002820191905f5260205f20905b815481526020019060010190808311613855575b50505050509050919050565b60608261388a5761388582613ae1565b61243a565b81511580156138a157506001600160a01b0384163b155b156138ca57604051639996b31560e01b81526001600160a01b03851660048201526024016111e3565b5092915050565b804710156138fb5760405163cf47918160e01b8152476004820152602481018290526044016111e3565b5f80836001600160a01b0316836040515f6040518083038185875af1925050503d805f8114613945576040519150601f19603f3d011682016040523d82523d5f602084013e61394a565b606091505b509150915081610ffc57610ffc81613ae1565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052611269908490613b0a565b5f5f8051602061437f8339815191526139c88484611e72565b6136db575f848152602082815260408083206001600160a01b03871684529091529020805460ff191660011790556139fd3390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001915050610d83565b5f5f8051602061437f833981519152613a608484611e72565b156136db575f848152602082815260408083206001600160a01b0387168085529252808320805460ff1916905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a46001915050610d83565b5f613ac96131a6565b54600160401b900460ff16919050565b61309261379b565b805115613af15780518082602001fd5b60405163d6bda27560e01b815260040160405180910390fd5b5f8060205f8451602086015f885af180613b29576040513d5f823e3d81fd5b50505f513d91508115613b40578060011415613b4d565b6001600160a01b0384163b155b15610ffc57604051635274afe760e01b81526001600160a01b03851660048201526024016111e3565b5f60208284031215613b86575f80fd5b81356001600160e01b03198116811461243a575f80fd5b6001600160a01b0381168114612ee5575f80fd5b5f60208284031215613bc1575f80fd5b813561243a81613b9d565b5f8083601f840112613bdc575f80fd5b50813567ffffffffffffffff811115613bf3575f80fd5b602083019150836020828501011115613c0a575f80fd5b9250929050565b5f805f805f60808688031215613c25575f80fd5b8535613c3081613b9d565b94506020860135613c4081613b9d565b935060408601359250606086013567ffffffffffffffff811115613c62575f80fd5b613c6e88828901613bcc565b969995985093965092949392505050565b5f805f60608486031215613c91575f80fd5b8335613c9c81613b9d565b92506020840135613cac81613b9d565b929592945050506040919091013590565b5f60208284031215613ccd575f80fd5b5035919050565b5f8060408385031215613ce5575f80fd5b823591506020830135613cf781613b9d565b809150509250929050565b5f8060208385031215613d13575f80fd5b823567ffffffffffffffff811115613d29575f80fd5b613d3585828601613bcc565b90969095509350505050565b5f805f60608486031215613d53575f80fd5b833592506020840135613d6581613b9d565b91506040840135613d7581613b9d565b809150509250925092565b8015158114612ee5575f80fd5b5f805f805f8060a08789031215613da2575f80fd5b863595506020870135613db481613d80565b94506040870135613dc481613b9d565b93506060870135613dd481613b9d565b9250608087013567ffffffffffffffff811115613def575f80fd5b613dfb89828a01613bcc565b979a9699509497509295939492505050565b5f8060408385031215613e1e575f80fd5b50508035926020909101359150565b803563ffffffff81168114613e40575f80fd5b919050565b5f805f8060808587031215613e58575f80fd5b8435613e6381613b9d565b935060208501356001600160e01b0381168114613e7e575f80fd5b9250613e8c60408601613e2d565b9150613e9a60608601613e2d565b905092959194509250565b602080825282518282018190525f9190848201906040850190845b81811015613ee55783516001600160a01b031683529284019291840191600101613ec0565b50909695505050505050565b5f8060408385031215613f02575f80fd5b8235613f0d81613b9d565b946020939093013593505050565b5f8060408385031215613f2c575f80fd5b8235613f3781613b9d565b91506020830135613cf781613b9d565b5f8060408385031215613f58575f80fd5b8235613f6381613b9d565b91506020830135613cf781613d80565b5f60208284031215613f83575f80fd5b815161243a81613d80565b5f60208284031215613f9e575f80fd5b815161243a81613b9d565b634e487b7160e01b5f52601160045260245ffd5b5f81613fcb57613fcb613fa9565b505f190190565b5f60208284031215613fe2575f80fd5b5051919050565b80820180821115610d8357610d83613fa9565b634e487b7160e01b5f52604160045260245ffd5b6040805190810167ffffffffffffffff8111828210171561403357614033613ffc565b60405290565b604051601f8201601f1916810167ffffffffffffffff8111828210171561406257614062613ffc565b604052919050565b5f805f805f805f805f6101208a8c031215614083575f80fd5b61408d8a35613b9d565b8935985061409e60208b0135613b9d565b60208a013597506140b260408b0135613b9d565b60408a013596506140c660608b0135613b9d565b60608a013595506140da60808b0135613b9d565b60808a013594506140ee60a08b0135613b9d565b60a08a0135935061410260c08b0135613b9d565b60c08a0135925060e08a0135915067ffffffffffffffff6101008b01351115614129575f80fd5b8a601f6101008c01358c01011261413e575f80fd5b67ffffffffffffffff6101008b01358b0135111561415e5761415e613ffc565b61417560206101008c01358c013560051b01614039565b6101008b01358b0180358083526020808401939260069290921b909101018d101561419e575f80fd5b60206101008d01358d01015b6101008d01358d01803560061b01602001811015614204576040818f0312156141d1575f80fd5b6141d9614010565b813581526141ea6020830135613b9d565b6020828101358282015290845292909201916040016141aa565b5080925050509295985092959850929598565b634e487b7160e01b5f52603260045260245ffd5b81835281816020850137505f828201602090810191909152601f909101601f19169091010190565b602081525f61135f60208301848661422b565b83815260018060a01b0383166020820152606060408201525f82518060608401528060208501608085015e5f608082850101526080601f19601f830116840101915050949350505050565b6001600160a01b038581168252841660208201526060604082018190525f906142dd908301848661422b565b9695505050505050565b81810381811115610d8357610d83613fa9565b5f600160ff1b820161430e5761430e613fa9565b505f0390565b5f82518060208501845e5f920191825250919050565b634e487b7160e01b5f52603160045260245ffdfe627f9e4ac2dadb64d045e7e6333c09f39ed34e0e066957955d0052b46d2e83e8c1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e8237170593200002dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268009b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00a2646970667358221220f303aa1e88b412ecf0bdcb901f6ae9e7c31b41c352254af18ab9efef324a829664736f6c63430008190033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000a67330bb89668ba66502a6d6670dacf5f334eb53000000000000000000000000a92cea07d6009de8f2aa377a4298deccf94d942a0000000000000000000000005e11c97db901edd8932fdaa77b015da89f3f289e00000000000000000000000048766b2e6b321f6550988d1a2e09b42e9170875900000000000000000000000000000000000000000000000000000000000000064d656c6c6f770000000000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : name_ (string): Mellow
Arg [1] : version_ (uint256): 1
Arg [2] : depositQueueFactory_ (address): 0xa67330bb89668bA66502a6D6670dACf5F334eb53
Arg [3] : redeemQueueFactory_ (address): 0xA92CeA07d6009DE8F2AA377a4298dECCF94d942a
Arg [4] : subvaultFactory_ (address): 0x5e11c97dB901EdD8932fdaA77b015da89F3f289E
Arg [5] : verifierFactory_ (address): 0x48766B2e6B321f6550988d1A2e09b42E91708759
-----Encoded View---------------
8 Constructor Arguments found :
Arg [0] : 00000000000000000000000000000000000000000000000000000000000000c0
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [2] : 000000000000000000000000a67330bb89668ba66502a6d6670dacf5f334eb53
Arg [3] : 000000000000000000000000a92cea07d6009de8f2aa377a4298deccf94d942a
Arg [4] : 0000000000000000000000005e11c97db901edd8932fdaa77b015da89f3f289e
Arg [5] : 00000000000000000000000048766b2e6b321f6550988d1a2e09b42e91708759
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000006
Arg [7] : 4d656c6c6f770000000000000000000000000000000000000000000000000000
Deployed Bytecode Sourcemap
226:1637:67:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1695:212:2;;;;;;;;;;-1:-1:-1;1695:212:2;;;;;:::i;:::-;;:::i;:::-;;;470:14:68;;463:22;445:41;;433:2;418:18;1695:212:2;;;;;;;;8006:597:64;;;;;;;;;;-1:-1:-1;8006:597:64;;;;;:::i;:::-;;:::i;:::-;;941:98:65;;;;;;;;;;;;987:52;941:98;;;;;1031:25:68;;;1019:2;1004:18;941:98:65;885:177:68;512:165:63;;;;;;;;;;-1:-1:-1;512:165:63;;;;;:::i;:::-;-1:-1:-1;;;512:165:63;;;;;;;;;;;-1:-1:-1;;;;;;2340:33:68;;;2322:52;;2310:2;2295:18;512:165:63;2178:202:68;4164:200:65;;;;;;;;;;-1:-1:-1;4164:200:65;;;;;:::i;:::-;;:::i;4106:760:64:-;;;;;;;;;;-1:-1:-1;4106:760:64;;;;;:::i;:::-;;:::i;323:147:63:-;;;;;;;;;;-1:-1:-1;323:147:63;;;;;:::i;:::-;-1:-1:-1;;;;;;;;;;;;;424:39:63;;;;;;;;;;;;;323:147;;;;3435:13:68;;3417:32;;3405:2;3390:18;323:147:63;3213:242:68;4759:191:0;;;;;;;;;;-1:-1:-1;4759:191:0;;;;;:::i;:::-;;:::i;5246:136::-;;;;;;;;;;-1:-1:-1;5246:136:0;;;;;:::i;:::-;;:::i;2968:296:65:-;;;;;;;;;;-1:-1:-1;2968:296:65;;;;;:::i;:::-;;:::i;804:98::-;;;;;;;;;;;;850:52;804:98;;2968:111:64;;;;;;;;;;;;;:::i;6348:245:0:-;;;;;;;;;;-1:-1:-1;6348:245:0;;;;;:::i;:::-;;:::i;6142:183:64:-;;;;;;;;;;-1:-1:-1;6142:183:64;;;;;:::i;:::-;;:::i;1159:41:65:-;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;3962:32:68;;;3944:51;;3932:2;3917:18;1159:41:65;3780:221:68;4905:289:64;;;;;;;;;;-1:-1:-1;4905:289:64;;;;;:::i;:::-;;:::i;3945:122::-;;;;;;;;;;;;;:::i;580:125:66:-;;;;;;;;;;;;;:::i;784:1077:67:-;;;;;;;;;;-1:-1:-1;784:1077:67;;;;;:::i;:::-;;:::i;2121:123:65:-;;;;;;;;;;;;;:::i;919:142:66:-;;;;;;;;;;-1:-1:-1;919:142:66;;;;;:::i;:::-;;:::i;2108:151:64:-;;;;;;;;;;-1:-1:-1;2108:151:64;;;;;:::i;:::-;;:::i;2309:620:65:-;;;;;;;;;;-1:-1:-1;2309:620:65;;;;;:::i;:::-;;:::i;3118:136:64:-;;;;;;;;;;-1:-1:-1;3118:136:64;;;;;:::i;:::-;;:::i;1045:45::-;;;;;;;;;;;;;;;3782:124;;;;;;;;;;;;;:::i;659:106:65:-;;;;;;;;;;;;709:56;659:106;;1624:133:64;;;;;;;;;;;;;:::i;5233:536::-;;;;;;;;;;;;;:::i;911:94::-;;;;;;;;;;;;955:50;911:94;;512:108:65;;;;;;;;;;;;563:57;512:108;;3293::64;;;;;;;;;;;;;:::i;1960:109::-;;;;;;;;;;;;;:::i;1948:134:65:-;;;;;;;;;;-1:-1:-1;1948:134:65;;;;;:::i;:::-;;:::i;7118:849:64:-;;;;;;;;;;-1:-1:-1;7118:849:64;;;;;:::i;:::-;;:::i;3612:131::-;;;;;;;;;;-1:-1:-1;3612:131:64;;;;;:::i;:::-;;:::i;2492:233:2:-;;;;;;;;;;-1:-1:-1;2492:233:2;;;;;:::i;:::-;;:::i;3732:207:0:-;;;;;;;;;;-1:-1:-1;3732:207:0;;;;;:::i;:::-;;:::i;3440:133:64:-;;;;;;;;;;-1:-1:-1;3440:133:64;;;;;:::i;:::-;;:::i;1129:44::-;;;;;;;;;;;;;;;10096:1394;;;;;;;;;;-1:-1:-1;10096:1394:64;;;;;:::i;:::-;;:::i;1785:124:65:-;;;;;;;;;;-1:-1:-1;1785:124:65;;;;;:::i;:::-;;:::i;1079:41::-;;;;;;;;;;;;;;;2298:116:64;;;;;;;;;;;;;:::i;2317:49:0:-;;;;;;;;;;-1:-1:-1;2317:49:0;2362:4;2317:49;;742:140:66;;;;;;;;;;-1:-1:-1;742:140:66;;;;;:::i;:::-;;:::i;3658:227:2:-;;;;;;;;;;-1:-1:-1;3658:227:2;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;1637:109:65:-;;;;;;;;;;;;;:::i;2616:128:64:-;;;;;;;;;;-1:-1:-1;2616:128:64;;;;;:::i;:::-;;:::i;2453:124::-;;;;;;;;;;-1:-1:-1;2453:124:64;;;;;:::i;:::-;;:::i;373:100:65:-;;;;;;;;;;;;420:53;373:100;;4642:220;;;;;;;;;;-1:-1:-1;4642:220:65;;;;;:::i;:::-;;:::i;498:94:64:-;;;;;;;;;;;;542:50;498:94;;3303:822:65;;;;;;;;;;-1:-1:-1;3303:822:65;;;;;:::i;:::-;;:::i;2783:146:64:-;;;;;;;;;;-1:-1:-1;2783:146:64;;;;;:::i;:::-;;:::i;2893:222:2:-;;;;;;;;;;-1:-1:-1;2893:222:2;;;;;:::i;:::-;;:::i;1796:125:64:-;;;;;;;;;;;;;:::i;9405:652::-;;;;;;;;;;-1:-1:-1;9405:652:64;;;;;:::i;:::-;;:::i;5662:138:0:-;;;;;;;;;;-1:-1:-1;5662:138:0;;;;;:::i;:::-;;:::i;631:102:64:-;;;;;;;;;;;;679:54;631:102;;5834:269;;;;;;;;;;-1:-1:-1;5834:269:64;;;;;:::i;:::-;;:::i;4901:220:65:-;;;;;;;;;;-1:-1:-1;4901:220:65;;;;;:::i;:::-;;:::i;772:100:64:-;;;;;;;;;;;;819:53;772:100;;4403:200:65;;;;;;;;;;-1:-1:-1;4403:200:65;;;;;:::i;:::-;;:::i;6794:285:64:-;;;;;;;;;;-1:-1:-1;6794:285:64;;;;;:::i;:::-;;:::i;6364:182::-;;;;;;;;;;-1:-1:-1;6364:182:64;;;;;:::i;:::-;;:::i;6585:170::-;;;;;;;;;;-1:-1:-1;6585:170:64;;;;;:::i;:::-;;:::i;8642:724::-;;;;;;;;;;-1:-1:-1;8642:724:64;;;;;:::i;:::-;;:::i;373:86::-;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;373:86:64;;1695:212:2;1780:4;-1:-1:-1;;;;;;1803:57:2;;-1:-1:-1;;;1803:57:2;;:97;;;1864:36;1888:11;1864:23;:36::i;:::-;1796:104;1695:212;-1:-1:-1;;1695:212:2:o;8006:597:64:-;955:50;3191:16:0;3202:4;3191:10;:16::i;:::-;8101:5:64::1;-1:-1:-1::0;;;;;8094:26:64::1;;:28;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;8089:78;;8145:11;;-1:-1:-1::0;;;8145:11:64::1;;;;;;;;;;;8089:78;8176:13;8199:5;-1:-1:-1::0;;;;;8192:19:64::1;;:21;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;8176:37;;8223:28;8254:21;:19;:21::i;:::-;-1:-1:-1::0;;;;;8290:15:64;::::1;;::::0;;;:8:::1;::::0;::::1;:15;::::0;;;;8223:52;;-1:-1:-1;8290:29:64::1;::::0;8313:5;8290:22:::1;:29::i;:::-;8285:79;;8342:11;;-1:-1:-1::0;;;8342:11:64::1;;;;;;;;;;;8285:79;-1:-1:-1::0;;;;;8380:23:64;;::::1;;::::0;;;:16:::1;::::0;::::1;:23;::::0;;;;;;;8373:30;;-1:-1:-1;;8373:30:64::1;::::0;;8417:15;;::::1;::::0;;:8:::1;::::0;::::1;:15:::0;;;:24:::1;::::0;:22:::1;:24::i;:::-;8445:1;8417:29:::0;8413:82:::1;;8462:22;:8;::::0;::::1;8478:5:::0;8462:15:::1;:22::i;:::-;;8413:82;-1:-1:-1::0;;;;;8511:20:64;::::1;;::::0;;;:13:::1;::::0;::::1;:20;::::0;;;;8504:27;;-1:-1:-1;;;;;;8504:27:64::1;::::0;;8543:12:::1;::::0;::::1;8541:14:::0;;8543:12;;8511:20;8541:14:::1;::::0;::::1;:::i;:::-;::::0;;;-1:-1:-1;8570:26:64::1;::::0;-1:-1:-1;;;;;8570:26:64;;::::1;::::0;;;::::1;::::0;::::1;::::0;;;::::1;8079:524;;8006:597:::0;;:::o;4164:200:65:-;850:52;3191:16:0;3202:4;3191:10;:16::i;:::-;3395:21:5::1;:19;:21::i;:::-;4322:35:65::2;4334:8;4344:5;4351;4322:11;:35::i;:::-;3437:20:5::1;1949:1:::0;-1:-1:-1;;;;;;;;;;;4113:23:5;3860:283;3437:20:::1;4164:200:65::0;;;;:::o;4106:760:64:-;4171:14;4197:28;4228:21;:19;:21::i;:::-;4197:52;-1:-1:-1;4301:8:64;;;4259:39;4341:15;4301:8;4341:13;:15::i;:::-;4319:37;;4371:9;4366:471;4390:11;4386:1;:15;4366:471;;;4422:13;4438:12;:6;4448:1;4438:9;:12::i;:::-;-1:-1:-1;;;;;4506:15:64;;4464:39;4506:15;;;:8;;;:15;;;;;4422:28;;-1:-1:-1;4557:15:64;4506;4557:13;:15::i;:::-;4535:37;;4591:9;4586:241;4610:11;4606:1;:15;4586:241;;;4646:13;4662:12;:6;4672:1;4662:9;:12::i;:::-;-1:-1:-1;;;;;4696:23:64;;;;;;:16;;;:23;;;;;;4646:28;;-1:-1:-1;4696:23:64;;4692:121;;;4753:41;;-1:-1:-1;;;4753:41:64;;-1:-1:-1;;;;;3962:32:68;;;4753:41:64;;;3944:51:68;4753:32:64;;;;;3917:18:68;;4753:41:64;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;4743:51;;;;:::i;:::-;;;4692:121;-1:-1:-1;4623:3:64;;4586:241;;;-1:-1:-1;;4403:3:64;;;;;-1:-1:-1;4366:471:64;;-1:-1:-1;4366:471:64;;;4846:13;;;4106:760;;;:::o;4759:191:0:-;4824:7;4919:14;;;-1:-1:-1;;;;;;;;;;;4919:14:0;;;;;:24;;;;4759:191::o;5246:136::-;5320:18;5333:4;5320:12;:18::i;:::-;3191:16;3202:4;3191:10;:16::i;:::-;5350:25:::1;5361:4;5367:7;5350:10;:25::i;2968:296:65:-:0;563:57;3191:16:0;3202:4;3191:10;:16::i;:::-;6042:26:65;3129:28:::1;:11;::::0;::::1;3148:8:::0;3129:18:::1;:28::i;:::-;3124:89;;3180:22;::::0;-1:-1:-1;;;3180:22:65;;-1:-1:-1;;;;;3962:32:68;;3180:22:65::1;::::0;::::1;3944:51:68::0;3917:18;;3180:22:65::1;;;;;;;;3124:89;3227:30;::::0;-1:-1:-1;;;;;3227:30:65;::::1;::::0;::::1;::::0;;;::::1;3058:206;2968:296:::0;;:::o;:111:64:-;3014:7;3040:21;:19;:21::i;:::-;:32;;;3033:39;;2968:111;:::o;6348:245:0:-;-1:-1:-1;;;;;6441:34:0;;966:10:4;6441:34:0;6437:102;;6498:30;;-1:-1:-1;;;6498:30:0;;;;;;;;;;;6437:102;6549:37;6561:4;6567:18;6549:11;:37::i;:::-;;6348:245;;:::o;6142:183:64:-;-1:-1:-1;;;;;;;;;;;3191:16:0;3202:4;3191:10;:16::i;:::-;6273:4:64::1;6230:21;:19;:21::i;:::-;:40;;:47:::0;;-1:-1:-1;;;;;;6230:47:64::1;-1:-1:-1::0;;;;;6230:47:64;;::::1;;::::0;;6292:26:::1;::::0;-1:-1:-1;445:41:68;;6292:26:64;;::::1;::::0;::::1;::::0;433:2:68;418:18;6292:26:64::1;;;;;;;;6142:183:::0;;:::o;4905:289::-;4958:7;4977:28;5008:21;:19;:21::i;:::-;-1:-1:-1;;;;;5054:20:64;;;5039:12;5054:20;;;:13;;;:20;;;;;;4977:52;;-1:-1:-1;5054:20:64;;5091:96;;-1:-1:-1;;;;;5119:23:64;;;;;;:16;;;:23;;;;;;;;:68;;5168:19;;;;-1:-1:-1;;;;;5168:19:64;5091:96;;5119:68;5145:20;;;;-1:-1:-1;;;;;5145:20:64;5091:96;;;5112:4;5091:96;5084:103;4905:289;-1:-1:-1;;;;4905:289:64:o;3945:122::-;3995:7;4021:21;:19;:21::i;:::-;:39;;;-1:-1:-1;;;;;4021:39:64;;3945:122;-1:-1:-1;3945:122:64:o;580:125:66:-;629:7;655:43;1902:21;655:41;:43::i;:::-;648:50;;580:125;:::o;784:1077:67:-;4158:30:3;4191:26;:24;:26::i;:::-;4302:15;;4158:59;;-1:-1:-1;4302:15:3;-1:-1:-1;;;4302:15:3;;;4301:16;;4348:14;;4279:19;4724:16;;:34;;;;;4744:14;4724:34;4704:54;;4768:17;4788:11;:16;;4803:1;4788:16;:50;;;;-1:-1:-1;4816:4:3;4808:25;:30;4788:50;4768:70;;4854:12;4853:13;:30;;;;;4871:12;4870:13;4853:30;4849:91;;;4906:23;;-1:-1:-1;;;4906:23:3;;;;;;;;;;;4849:91;4949:18;;-1:-1:-1;;4949:18:3;4966:1;4949:18;;;4977:67;;;;5011:22;;-1:-1:-1;;;;5011:22:3;-1:-1:-1;;;5011:22:3;;;4977:67;894:14:67::1;926:21:::0;965:19:::1;1002:20:::0;1040:15:::1;1073:27:::0;1118:26:::1;1162:19:::0;1199:31:::1;1275:10;;1247:140;;;;;;;:::i;:::-;876:511;;;;;;;;;;;;;;;;;;1401:19;:17;:19::i;:::-;1434:24;1451:6;1434:16;:24::i;:::-;1472:139;1508:13;1523:11;1536:7;1545:19;1566:18;1586:11;1472:18;:139::i;:::-;1625:32;1644:12;1625:18;:32::i;:::-;1676:9;1671:136;1695:11;:18;1691:1;:22;1671:136;;;1738:54;1749:11;1761:1;1749:14;;;;;;;;:::i;:::-;;;;;;;:19;;;1770:11;1782:1;1770:14;;;;;;;;:::i;:::-;;;;;;;:21;;;1738:10;:54::i;:::-;-1:-1:-1::0;1715:3:67::1;;1671:136;;;;862:955;;;;;;;;;1831:23;1843:10;;1831:23;;;;;;;:::i;:::-;;;;;;;;5068:14:3::0;5064:101;;;5098:23;;-1:-1:-1;;;;5098:23:3;;;5140:14;;-1:-1:-1;15222:50:68;;5140:14:3;;15210:2:68;15195:18;5140:14:3;;;;;;;5064:101;4092:1079;;;;;784:1077:67;;:::o;2121:123:65:-;2165:12;6042:26;2209:15;:27;-1:-1:-1;;;;;2209:27:65;;2121:123;-1:-1:-1;2121:123:65:o;919:142:66:-;982:4;1005:49;1902:21;1049:4;1005:43;:49::i;2108:151:64:-;2162:4;2185:67;2246:5;2185:21;:19;:21::i;:::-;:28;;:51;2221:5;-1:-1:-1;;;;;2214:19:64;;:21;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;-1:-1:-1;;;;;2185:51:64;;;;;;;;;;;;-1:-1:-1;2185:51:64;;:60;:67::i;2309:620:65:-;2477:16;420:53;3191:16:0;3202:4;3191:10;:16::i;:::-;3395:21:5::1;:19;:21::i;:::-;2514:34:65::2;::::0;-1:-1:-1;;;2514:34:65;;-1:-1:-1;;;;;3962:32:68;;;2514:34:65::2;::::0;::::2;3944:51:68::0;2514:15:65::2;:24;::::0;::::2;::::0;3917:18:68;;2514:34:65::2;;;;;;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;2509:92;;2571:19;::::0;-1:-1:-1;;;2571:19:65;;-1:-1:-1;;;;;3962:32:68;;2571:19:65::2;::::0;::::2;3944:51:68::0;3917:18;;2571:19:65::2;3780:221:68::0;2509:92:65::2;2662:4;-1:-1:-1::0;;;;;2614:53:65::2;2632:8;-1:-1:-1::0;;;;;2622:25:65::2;;:27;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;-1:-1:-1::0;;;;;2614:53:65::2;;2610:102;;2690:11;;-1:-1:-1::0;;;2690:11:65::2;;;;;;;;;;;2610:102;2732:15;-1:-1:-1::0;;;;;2732:22:65::2;;2755:7;2764:5;2782:8;2800:4;2771:35;;;;;;;;-1:-1:-1::0;;;;;15792:15:68;;;15774:34;;15844:15;;15839:2;15824:18;;15817:43;15724:2;15709:18;;15562:304;2771:35:65::2;;;;;;;;;;;;;2732:75;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;2721:86:::0;-1:-1:-1;2817:39:65::2;:25;6042:26:::0;2817:25:::2;2721:86:::0;2817:29:::2;:39::i;:::-;;2913:8;-1:-1:-1::0;;;;;2871:51:65::2;2906:5;-1:-1:-1::0;;;;;2871:51:65::2;2887:8;-1:-1:-1::0;;;;;2871:51:65::2;;2897:7;2871:51;;;;1031:25:68::0;;1019:2;1004:18;;885:177;2871:51:65::2;;;;;;;;3437:20:5::1;1949:1:::0;-1:-1:-1;;;;;;;;;;;4113:23:5;3860:283;3437:20:::1;2309:620:65::0;;;;;;:::o;3118:136:64:-;3177:7;3203:44;:21;:19;:21::i;:::-;-1:-1:-1;;;;;3203:35:64;;;;;;:28;;;;;:35;;;;;:42;:44::i;3782:124::-;3833:7;3859:21;:19;:21::i;:::-;:40;;;-1:-1:-1;;;;;3859:40:64;;3782:124;-1:-1:-1;3782:124:64:o;1624:133::-;1669:13;1715:21;:19;:21::i;5233:536::-;5281:7;;966:10:4;5300:28:64;;5338:13;5361:5;-1:-1:-1;;;;;5354:19:64;;:21;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;5338:37;;5385:28;5416:21;:19;:21::i;:::-;-1:-1:-1;;;;;5452:15:64;;;;;;:8;;;:15;;;;;5385:52;;-1:-1:-1;5452:31:64;;5477:5;5452:24;:31::i;:::-;5451:32;:59;;;-1:-1:-1;;;;;;5487:23:64;;;;;;:16;;;:23;;;;;;;;5451:59;5447:108;;;5533:11;;-1:-1:-1;;;5533:11:64;;;;;;;;;;;5447:108;5564:12;5579:14;5587:5;5579:7;:14::i;:::-;5564:29;-1:-1:-1;;;;;;5607:18:64;;5603:103;;5648:47;5674:5;5689:4;5648:25;:47::i;:::-;5641:54;;;;;;5233:536;:::o;5603:103::-;5722:40;;-1:-1:-1;;;5722:40:64;;-1:-1:-1;;;;;3962:32:68;;;5722:40:64;;;3944:51:68;5722:33:64;;;;;3917:18:68;;5722:40:64;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;3293:108::-;3336:7;3362:21;:19;:21::i;:::-;:32;;;3355:39;;3293:108;:::o;1960:109::-;1999:7;2033:21;:19;:21::i;:::-;:28;;;-1:-1:-1;;;;;2033:28:64;;1960:109;-1:-1:-1;1960:109:64:o;1948:134:65:-;2008:4;2031:44;:25;6042:26;2031:25;2066:8;2031:34;:44::i;7118:849:64:-;3395:21:5;:19;:21::i;:::-;542:50:64::1;3191:16:0;3202:4;3191:10;:16::i;:::-;7311:28:64::2;7342:21;:19;:21::i;:::-;7386:8;::::0;::::2;::::0;7378:41:::2;::::0;-1:-1:-1;;;7378:41:64;;-1:-1:-1;;;;;3962:32:68;;;7378:41:64::2;::::0;::::2;3944:51:68::0;7386:8:64;;-1:-1:-1;7386:8:64;::::2;::::0;7378:34:::2;::::0;3917:18:68;;7378:41:64::2;;;;;;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;7373:103;;7442:23;::::0;-1:-1:-1;;;7442:23:64;;-1:-1:-1;;;;;3962:32:68;;7442:23:64::2;::::0;::::2;3944:51:68::0;3917:18;;7442:23:64::2;3780:221:68::0;7373:103:64::2;7485:13;7501:1;:12;;;7516:1;7501:16;;;;:::i;:::-;7485:32;;7539:1;:12;;;7531:5;:20;7527:77;;;7574:19;;-1:-1:-1::0;;;7574:19:64::2;;;;;;;;;;;7527:77;7613:13;7630:9;:52;;7664:18;7630:52;;;7642:19;7630:52;-1:-1:-1::0;;;;;7629:61:64::2;;7704:7;7713:5;7731;7746:4;7753;;7720:38;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;7629:139;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;7778:12;::::0;::::2;:20:::0;;;-1:-1:-1;;;;;7808:15:64;::::2;;::::0;;;:8:::2;::::0;::::2;:15;::::0;;;;7613:155;;-1:-1:-1;7808:26:64::2;::::0;7613:155;7808:19:::2;:26::i;:::-;-1:-1:-1::0;7844:19:64::2;:8;::::0;::::2;7857:5:::0;7844:12:::2;:19::i;:::-;-1:-1:-1::0;;;;;;7873:23:64;;::::2;;::::0;;;:16:::2;::::0;::::2;:23;::::0;;;;;;;;:35;;-1:-1:-1;;7873:35:64::2;::::0;::::2;;::::0;;::::2;::::0;;;7923:37;;445:41:68;;;7923:37:64;;::::2;::::0;::::2;::::0;418:18:68;7923:37:64::2;;;;;;;7301:666;;;3426:1:5::1;3437:20:::0;1949:1;-1:-1:-1;;;;;;;;;;;4113:23:5;3860:283;3437:20;7118:849:64;;;;;;:::o;3612:131::-;3671:4;3694:21;:19;:21::i;:::-;-1:-1:-1;;;;;3694:42:64;;;;;;;:35;;;;;:42;;-1:-1:-1;3694:42:64;;;;;;;3612:131::o;2492:233:2:-;2573:7;2688:20;;;-1:-1:-1;;;;;;;;;;;2688:20:2;;;;;;;:30;;2712:5;2688:23;:30::i;3732:207:0:-;3809:4;3901:14;;;-1:-1:-1;;;;;;;;;;;3901:14:0;;;;;;;;-1:-1:-1;;;;;3901:31:0;;;;;;;;;;;;;;;3732:207::o;3440:133:64:-;3500:4;3523:21;:19;:21::i;:::-;-1:-1:-1;;;;;3523:43:64;;;;;;;:36;;;;;:43;;-1:-1:-1;3523:43:64;;;;;;;3440:133::o;10096:1394::-;3395:21:5;:19;:21::i;:::-;10252:28:64::1;10283:21;:19;:21::i;:::-;10334:8;::::0;::::1;::::0;;;-1:-1:-1;;;;;;10334:8:64::1;966:10:4::0;-1:-1:-1;;;;;10318:24:64::1;;10314:73;;10365:11;;-1:-1:-1::0;;;10365:11:64::1;;;;;;;;;;;10314:73;10440:14:::0;;;10503:12;::::1;::::0;10561:36:::1;::::0;-1:-1:-1;;;10561:36:64;;10591:4:::1;10561:36;::::0;::::1;3944:51:68::0;-1:-1:-1;;;;;10440:14:64;;::::1;::::0;10503:12;;::::1;::::0;10396:27:::1;::::0;10503:12;;10561:21:::1;::::0;3917:18:68;;10561:36:64::1;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;-1:-1:-1::0;;;;;10552:45:64::1;:5;-1:-1:-1::0;;;;;10552:45:64::1;::::0;10548:510:::1;;10613:21;10637:11;-1:-1:-1::0;;;;;10637:24:64::1;;:26;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;10836:43;::::0;-1:-1:-1;;;10836:43:64;;-1:-1:-1;;;;;3962:32:68;;;10836:43:64::1;::::0;::::1;3944:51:68::0;10613:50:64;;-1:-1:-1;10684:24:64;;::::1;::::0;::::1;::::0;10734:4:::1;::::0;10757:5;;10780:8;;10836:28;::::1;::::0;::::1;::::0;3917:18:68;;10836:43:64::1;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;10806:13;-1:-1:-1::0;;;;;10806:25:64::1;;:27;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;:73;;;;:::i;:::-;10684:209;::::0;-1:-1:-1;;;;;;10684:209:64::1;::::0;;;;;;-1:-1:-1;;;;;17330:15:68;;;10684:209:64::1;::::0;::::1;17312:34:68::0;17382:15;;;;17362:18;;;17355:43;-1:-1:-1;;;;;17434:32:68;17414:18;;;17407:60;17483:18;;;17476:34;17246:19;;10684:209:64::1;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;10677:216:::0;-1:-1:-1;10911:9:64;;10907:87:::1;;10940:39;::::0;-1:-1:-1;;;10940:39:64;;-1:-1:-1;;;;;17713:32:68;;;10940:39:64::1;::::0;::::1;17695:51:68::0;17762:18;;;17755:34;;;10940:18:64;::::1;::::0;::::1;::::0;17668::68;;10940:39:64::1;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;10907:87;11007:40;::::0;-1:-1:-1;;;11007:40:64;;-1:-1:-1;;;;;17992:32:68;;;11007:40:64::1;::::0;::::1;17974:51:68::0;-1:-1:-1;;;;;18061:32:68;;18041:18;;;18034:60;11007:23:64;::::1;::::0;::::1;::::0;17947:18:68;;11007:40:64::1;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;10599:459;10548:510;11067:39;11109:21;:19;:21::i;:::-;-1:-1:-1::0;;;;;11109:35:64;::::1;;::::0;;;:28:::1;::::0;;;::::1;:35;::::0;;;;;-1:-1:-1;11171:15:64::1;11109:35:::0;11171:13:::1;:15::i;:::-;11154:32;;11201:9;11196:202;11220:6;11216:1;:10;11196:202;;;11247:13;11263:12;:6:::0;11273:1;11263:9:::1;:12::i;:::-;-1:-1:-1::0;;;;;11289:26:64;::::1;11326:23;::::0;;;:16:::1;::::0;::::1;:23;::::0;;;;;11247:28;;-1:-1:-1;11289:26:64;::::1;::::0;11316:8;;11326:23:::1;;:60;;11371:15;11326:60;;;11352:16;11326:60;11289:98;::::0;-1:-1:-1;;;;;;11289:98:64::1;::::0;;;;;;-1:-1:-1;;;;;18295:32:68;;;11289:98:64::1;::::0;::::1;18277:51:68::0;11289:98:64::1;18364:23:68::0;18344:18;;;18337:51;18250:18;;11289:98:64::1;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;-1:-1:-1::0;;11228:3:64::1;::::0;;::::1;::::0;-1:-1:-1;11196:202:64::1;::::0;-1:-1:-1;;11196:202:64::1;;-1:-1:-1::0;11412:71:64::1;::::0;;18607:10:68;18644:15;;;18626:34;;18696:15;;18691:2;18676:18;;18669:43;18728:18;;;18721:34;;;-1:-1:-1;;;;;11412:71:64;::::1;::::0;-1:-1:-1;;;;;11412:71:64;::::1;::::0;::::1;::::0;18585:2:68;18570:18;11412:71:64::1;;;;;;;10242:1248;;;;;;3437:20:5::0;1949:1;-1:-1:-1;;;;;;;;;;;4113:23:5;3860:283;1785:124:65;1841:7;1867:35;:25;6042:26;1867:25;1896:5;1867:28;:35::i;2298:116:64:-;2344:7;2370:37;:21;:19;:21::i;:::-;:28;;:35;:37::i;742:140:66:-;805:7;831:44;1902:21;869:5;831:37;:44::i;3658:227:2:-;3753:40;3849:20;;;-1:-1:-1;;;;;;;;;;;3849:20:2;;;;;;;;3725:16;;1403:38;3849:29;;:27;:29::i;:::-;3842:36;3658:227;-1:-1:-1;;;3658:227:2:o;1637:109:65:-;1679:7;1705:34;6042:26;1705:25;;:32;:34::i;2616:128:64:-;2670:4;2693:44;2731:5;2693:21;:19;:21::i;:::-;:28;;;:37;:44::i;2453:124::-;2506:7;2532:38;2564:5;2532:21;:19;:21::i;:::-;:28;;;:31;:38::i;4642:220:65:-;966:10:4;4761:4:65;4737:29;4733:78;;4789:11;;-1:-1:-1;;;4789:11:65;;;;;;;;;;;4733:78;4820:35;4832:8;4842:5;4849;4820:11;:35::i;3303:822::-;709:56;3191:16:0;3202:4;3191:10;:16::i;:::-;3401:28:65::1;6042:26:::0;3462:34:::1;::::0;-1:-1:-1;;;3462:34:65;;-1:-1:-1;;;;;3962:32:68;;;3462:34:65::1;::::0;::::1;3944:51:68::0;3401:46:65;;-1:-1:-1;3462:15:65::1;:24:::0;;::::1;::::0;::::1;::::0;3917:18:68;;3462:34:65::1;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;3457:92;;3519:19;::::0;-1:-1:-1;;;3519:19:65;;-1:-1:-1;;;;;3962:32:68;;3519:19:65::1;::::0;::::1;3944:51:68::0;3917:18;;3519:19:65::1;3780:221:68::0;3457:92:65::1;3607:4;-1:-1:-1::0;;;;;3562:50:65::1;3578:8;-1:-1:-1::0;;;;;3562:31:65::1;;:33;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;-1:-1:-1::0;;;;;3562:50:65::1;;3558:113;;3635:25;::::0;-1:-1:-1;;;3635:25:65;;-1:-1:-1;;;;;3962:32:68;;3635:25:65::1;::::0;::::1;3944:51:68::0;3917:18;;3635:25:65::1;3780:221:68::0;3558:113:65::1;3680:18;3717:8;-1:-1:-1::0;;;;;3701:34:65::1;;:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;3752:43;::::0;-1:-1:-1;;;3752:43:65;;-1:-1:-1;;;;;3962:32:68;;;3752:43:65::1;::::0;::::1;3944:51:68::0;3680:57:65;;-1:-1:-1;3752:15:65::1;:24:::0;;::::1;::::0;::::1;::::0;3917:18:68;;3752:43:65::1;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;3747:110;;3818:28;::::0;-1:-1:-1;;;3818:28:65;;-1:-1:-1;;;;;3962:32:68;;3818:28:65::1;::::0;::::1;3944:51:68::0;3917:18;;3818:28:65::1;3780:221:68::0;3747:110:65::1;3907:4;-1:-1:-1::0;;;;;3870:42:65::1;3878:8;-1:-1:-1::0;;;;;3878:14:65::1;;:16;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;-1:-1:-1::0;;;;;3870:42:65::1;;3866:91;;3935:11;;-1:-1:-1::0;;;3935:11:65::1;;;;;;;;;;;3866:91;3971:25;:11;::::0;::::1;3987:8:::0;3971:15:::1;:25::i;:::-;3966:90;;4019:26;::::0;-1:-1:-1;;;4019:26:65;;-1:-1:-1;;;;;3962:32:68;;4019:26:65::1;::::0;::::1;3944:51:68::0;3917:18;;4019:26:65::1;3780:221:68::0;3966:90:65::1;4108:8;-1:-1:-1::0;;;;;4070:48:65::1;4090:8;-1:-1:-1::0;;;;;4070:48:65::1;;;;;;;;;;;3391:734;;3303:822:::0;;:::o;2783:146:64:-;2851:7;2877:45;2916:5;2877:21;:19;:21::i;:::-;-1:-1:-1;;;;;2877:35:64;;;;;;:28;;;;;:35;;;;;;:38;:45::i;2893:222:2:-;2964:7;3079:20;;;-1:-1:-1;;;;;;;;;;;3079:20:2;;;;;;;:29;;:27;:29::i;1796:125:64:-;1839:11;1881:21;:19;:21::i;:::-;:32;;;-1:-1:-1;;;;;1881:32:64;;1796:125;-1:-1:-1;1796:125:64:o;9405:652::-;9458:13;966:10:4;9458:28:64;;9496:13;9519:5;-1:-1:-1;;;;;9512:19:64;;:21;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;9496:37;;9543:28;9574:21;:19;:21::i;:::-;9543:52;;9610:51;9655:5;9610:21;:19;:21::i;:::-;-1:-1:-1;;;;;9610:35:64;;;;;;:28;;;;;:35;;;;;;:44;:51::i;:::-;9605:101;;9684:11;;-1:-1:-1;;;9684:11:64;;;;;;;;;;;9605:101;9715:12;9730:14;9738:5;9730:7;:14::i;:::-;9715:29;-1:-1:-1;;;;;;9758:18:64;;;9754:132;;9827:47;;-1:-1:-1;;;;;17713:32:68;;9827:47:64;;;17695:51:68;17762:18;;;17755:34;;;9792:83:64;;9821:4;;17668:18:68;;9827:47:64;;;-1:-1:-1;;9827:47:64;;;;;;;;;;;;;;-1:-1:-1;;;;;9827:47:64;-1:-1:-1;;;9827:47:64;;;9792:28;:83::i;:::-;;9754:132;-1:-1:-1;;;;;9900:23:64;;;;;;:16;;;:23;;;;;;;;9895:103;;9939:48;9966:5;9973;9980:6;9939:26;:48::i;:::-;10012:38;;;19215:25:68;;;-1:-1:-1;;;;;19276:32:68;;;19271:2;19256:18;;19249:60;10012:38:64;;;;;;;;;;19188:18:68;10012:38:64;;;;;;;9448:609;;;;9405:652;:::o;5662:138:0:-;5737:18;5750:4;5737:12;:18::i;:::-;3191:16;3202:4;3191:10;:16::i;:::-;5767:26:::1;5779:4;5785:7;5767:11;:26::i;5834:269:64:-:0;-1:-1:-1;;;;;;;;;;;3191:16:0;3202:4;3191:10;:16::i;:::-;-1:-1:-1;;;;;5933:19:64;::::1;5929:70;;5975:13;;-1:-1:-1::0;;;5975:13:64::1;;;;;;;;;;;5929:70;6051:4;6008:21;:19;:21::i;:::-;-1:-1:-1::0;;;;;6008:40:64;;::::1;;::::0;;;:33:::1;::::0;;;::::1;:40;::::0;;;;;:47;;-1:-1:-1;;;;;;6008:47:64::1;::::0;;::::1;::::0;;;::::1;::::0;;;6070:26;;;;::::1;::::0;6008:40;6070:26:::1;::::0;::::1;5834:269:::0;;;:::o;4901:220:65:-;966:10:4;5020:4:65;4996:29;4992:78;;5048:11;;-1:-1:-1;;;5048:11:65;;;;;;;;;;;4992:78;5079:35;5091:8;5101:5;5108;5079:11;:35::i;4403:200::-;987:52;3191:16:0;3202:4;3191:10;:16::i;:::-;3395:21:5::1;:19;:21::i;:::-;4561:35:65::2;4573:8;4583:5;4590;4561:11;:35::i;6794:285:64:-:0;679:54;3191:16:0;3202:4;3191:10;:16::i;:::-;6904:15:64::1;6913:5;6904:8;:15::i;:::-;6899:65;;6942:11;;-1:-1:-1::0;;;6942:11:64::1;;;;;;;;;;;6899:65;7018:8;6973:21;:19;:21::i;:::-;-1:-1:-1::0;;;;;6973:42:64;::::1;;::::0;;;:35:::1;::::0;;;::::1;:42;::::0;;;;;:53;;-1:-1:-1;;6973:53:64::1;::::0;::::1;;::::0;;;::::1;::::0;;;7041:31;;;::::1;;::::0;6973:42;7041:31:::1;::::0;::::1;6794:285:::0;;;:::o;6364:182::-;-1:-1:-1;;;;;;;;;;;3191:16:0;3202:4;3191:10;:16::i;:::-;6493:4:64::1;6451:21;:19;:21::i;:::-;:39;;:46:::0;;-1:-1:-1;;;;;;6451:46:64::1;-1:-1:-1::0;;;;;6451:46:64;;::::1;;::::0;;6512:27:::1;::::0;-1:-1:-1;445:41:68;;6512:27:64;;::::1;::::0;::::1;::::0;433:2:68;418:18;6512:27:64::1;305:187:68::0;6585:170:64;819:53;3191:16:0;3202:4;3191:10;:16::i;:::-;6708:5:64::1;6673:21;:19;:21::i;:::-;:32;;:40:::0;6728:20:::1;::::0;1031:25:68;;;6728:20:64::1;::::0;1019:2:68;1004:18;6728:20:64::1;;;;;;;6585:170:::0;;:::o;8642:724::-;8699:28;8730:21;:19;:21::i;:::-;8699:52;-1:-1:-1;8803:8:64;;;8761:39;8843:15;8803:8;8843:13;:15::i;:::-;8821:37;;8873:9;8868:455;8892:11;8888:1;:15;8868:455;;;8924:13;8940:12;:6;8950:1;8940:9;:12::i;:::-;-1:-1:-1;;;;;9008:15:64;;8966:39;9008:15;;;:8;;;:15;;;;;8924:28;;-1:-1:-1;9059:15:64;9008;9059:13;:15::i;:::-;9037:37;;9093:9;9088:225;9112:11;9108:1;:15;9088:225;;;9148:13;9164:12;:6;9174:1;9164:9;:12::i;:::-;-1:-1:-1;;;;;9198:23:64;;;;;;:16;;;:23;;;;;;9148:28;;-1:-1:-1;9198:23:64;;9194:105;;;9245:35;;-1:-1:-1;;;9245:35:64;;-1:-1:-1;;;;;3962:32:68;;;9245:35:64;;;3944:51:68;9245:26:64;;;;;3917:18:68;;9245:35:64;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;9194:105;-1:-1:-1;9125:3:64;;9088:225;;;-1:-1:-1;;8905:3:64;;;;;-1:-1:-1;8868:455:64;;-1:-1:-1;8868:455:64;;-1:-1:-1;9337:22:64;;-1:-1:-1;;;;;9337:22:64;;;;;;;;8689:677;;;8642:724;:::o;3443:202:0:-;3528:4;-1:-1:-1;;;;;;3551:47:0;;-1:-1:-1;;;3551:47:0;;:87;;-1:-1:-1;;;;;;;;;;1134:40:6;;;3602:36:0;1035:146:6;4148:103:0;4214:30;4225:4;966:10:4;4214::0;:30::i;:::-;4148:103;:::o;12228:195:64:-;12337:23;;12228:195::o;9650:156:38:-;9723:4;9746:53;9754:3;-1:-1:-1;;;;;9774:23:38;;9746:7;:53::i;10530:115::-;10593:7;10619:19;10627:3;5202:18;;5120:107;3470:384:5;-1:-1:-1;;;;;;;;;;;3670:9:5;;-1:-1:-1;;3670:20:5;3666:88;;3713:30;;-1:-1:-1;;;3713:30:5;;;;;;;;;;;3666:88;1991:1;3828:19;;3470:384::o;5154:274:65:-;5242:13;:11;:13::i;:::-;-1:-1:-1;;;;;5242:35:65;;5278:8;5288:5;5295:14;5303:5;5295:14;:::i;:::-;5242:68;;-1:-1:-1;;;;;;5242:68:65;;;;;;;-1:-1:-1;;;;;19717:15:68;;;5242:68:65;;;19699:34:68;19769:15;;;;19749:18;;;19742:43;19801:18;;;19794:34;19634:18;;5242:68:65;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;5320:50:65;;-1:-1:-1;;;5320:50:65;;-1:-1:-1;;;;;17713:32:68;;;5320:50:65;;;17695:51:68;17762:18;;;17755:34;;;5320:36:65;;;-1:-1:-1;5320:36:65;;-1:-1:-1;17668:18:68;;5320:50:65;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5405:8;-1:-1:-1;;;;;5385:36:65;5398:5;-1:-1:-1;;;;;5385:36:65;;5415:5;5385:36;;;;1031:25:68;;1019:2;1004:18;;885:177;5385:36:65;;;;;;;;5154:274;;;:::o;3860:283:5:-;1949:1;-1:-1:-1;;;;;;;;;;;4113:23:5;3860:283::o;10987:156:38:-;11061:7;11111:22;11115:3;11127:5;11111:3;:22::i;1094:319:66:-;1180:4;1200:31;1217:4;1223:7;1200:16;:31::i;:::-;1196:189;;;1251:44;1902:21;1290:4;1251:38;:44::i;:::-;1247:103;;;1320:15;;1330:4;;1320:15;;;;;1247:103;-1:-1:-1;1370:4:66;1363:11;;1196:189;-1:-1:-1;1401:5:66;1094:319;;;;:::o;1419:373::-;1506:4;1526:32;1544:4;1550:7;1526:17;:32::i;:::-;1522:242;;;1578:24;1597:4;1578:18;:24::i;:::-;1606:1;1578:29;1574:155;;1627:47;1902:21;1669:4;1627:41;:47::i;:::-;-1:-1:-1;1697:17:66;;1709:4;;1697:17;;;;;-1:-1:-1;1749:4:66;1742:11;;9071:205:3;9129:30;;3147:66;9186:27;8819:122;771:96:63;6929:20:3;:18;:20::i;:::-;836:24:63::1;:22;:24::i;:::-;771:96::o:0;401:203:62:-;6929:20:3;:18;:20::i;:::-;-1:-1:-1;;;;;483:20:62;::::1;479:71;;526:13;;-1:-1:-1::0;;;526:13:62::1;;;;;;;;;;;479:71;559:38;2362:4:0;590:6:62::0;559:10:::1;:38::i;:::-;;401:203:::0;:::o;11523:699:64:-;6929:20:3;:18;:20::i;:::-;-1:-1:-1;;;;;11784:27:64;::::1;::::0;;:56:::1;;-1:-1:-1::0;;;;;;11815:25:64;::::1;::::0;11784:56:::1;:81;;;-1:-1:-1::0;;;;;;11844:21:64;::::1;::::0;11784:81:::1;11780:132;;;11888:13;;-1:-1:-1::0;;;11888:13:64::1;;;;;;;;;;;11780:132;11921:28;11952:21;:19;:21::i;:::-;11983:30:::0;;-1:-1:-1;;;;;;11983:30:64;;::::1;-1:-1:-1::0;;;;;11983:30:64;;::::1;;::::0;;-1:-1:-1;12023:12:64;::::1;:26:::0;;;::::1;::::0;;::::1;::::0;;;::::1;::::0;;;12059:8:::1;::::0;::::1;:18:::0;;;::::1;::::0;;::::1;::::0;;;::::1;::::0;;;-1:-1:-1;12087:20:64::1;::::0;::::1;:42:::0;;;::::1;::::0;;::::1;::::0;;;::::1;::::0;;;12139:19:::1;::::0;::::1;:40:::0;;;;::::1;::::0;::::1;::::0;;;::::1;::::0;;;12189:12:::1;;:26:::0;11523:699::o;5713:221:65:-;6929:20:3;:18;:20::i;:::-;-1:-1:-1;;;;;5803:26:65;::::1;5799:77;;5852:13;;-1:-1:-1::0;;;5852:13:65::1;;;;;;;;;;;5799:77;6042:26:::0;5885:42;;-1:-1:-1;;;;;;5885:42:65::1;-1:-1:-1::0;;;;;5885:42:65;;;::::1;::::0;;;::::1;::::0;;5713:221::o;7474:138:38:-;7554:4;5006:21;;;:14;;;:21;;;;;;:26;;7577:28;4910:129;10284:165;-1:-1:-1;;;;;10417:23:38;;10364:4;5006:21;;;:14;;;:21;;;;;;:26;;10387:55;4910:129;9332:150;9402:4;9425:50;9430:3;-1:-1:-1;;;;;9450:23:38;;9425:4;:50::i;2354:234:61:-;2428:7;-1:-1:-1;;;;;;;2451:12:61;;;2447:135;;-1:-1:-1;;;;;;2486:15:61;;;2479:22;;2447:135;2539:32;;-1:-1:-1;;;2539:32:61;;-1:-1:-1;;;;;3962:32:68;;;2539::61;;;3944:51:68;2539:23:61;;;;;3917:18:68;;2539:32:61;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;2532:39;;;;11683:273:38;11746:16;11774:22;11799:19;11807:3;11799:7;:19::i;3916:253:23:-;3999:12;4024;4038:23;4065:6;-1:-1:-1;;;;;4065:19:23;4085:4;4065:25;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4023:67;;;;4107:55;4134:6;4142:7;4151:10;4107:26;:55::i;:::-;4100:62;3916:253;-1:-1:-1;;;;;3916:253:23:o;1134:238:61:-;-1:-1:-1;;;;;;;1220:12:61;;;1216:150;;1248:38;1274:2;1279:6;1248:17;:38::i;1216:150::-;1317:38;-1:-1:-1;;;;;1317:26:61;;1344:2;1348:6;1317:26;:38::i;5434:273:65:-;5522:13;:11;:13::i;:::-;:67;;-1:-1:-1;;;5522:67:65;;-1:-1:-1;;;;;19717:15:68;;;5522:67:65;;;19699:34:68;19769:15;;;19749:18;;;19742:43;19801:18;;;19794:34;;;5522:35:65;;;;;;;19634:18:68;;5522:67:65;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5599:50;5626:5;5633:8;5643:5;5599:26;:50::i;:::-;5684:8;-1:-1:-1;;;;;5664:36:65;5677:5;-1:-1:-1;;;;;5664:36:65;;5694:5;5664:36;;;;1031:25:68;;1019:2;1004:18;;885:177;4381:197:0;4469:22;4477:4;4483:7;4469;:22::i;:::-;4464:108;;4514:47;;-1:-1:-1;;;4514:47:0;;-1:-1:-1;;;;;17713:32:68;;4514:47:0;;;17695:51:68;17762:18;;;17755:34;;;17668:18;;4514:47:0;17521:274:68;2910:1368:38;2976:4;3105:21;;;:14;;;:21;;;;;;3141:13;;3137:1135;;3508:18;3529:12;3540:1;3529:8;:12;:::i;:::-;3575:18;;3508:33;;-1:-1:-1;3555:17:38;;3575:22;;3596:1;;3575:22;:::i;:::-;3555:42;;3630:9;3616:10;:23;3612:378;;3659:17;3679:3;:11;;3691:9;3679:22;;;;;;;;:::i;:::-;;;;;;;;;3659:42;;3826:9;3800:3;:11;;3812:10;3800:23;;;;;;;;:::i;:::-;;;;;;;;;;;;:35;;;;3939:25;;;:14;;;:25;;;;;:36;;;3612:378;4068:17;;:3;;:17;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;4171:3;:14;;:21;4186:5;4171:21;;;;;;;;;;;4164:28;;;4214:4;4207:11;;;;;;;3137:1135;4256:5;4249:12;;;;;5569:118;5636:7;5662:3;:11;;5674:5;5662:18;;;;;;;;:::i;:::-;;;;;;;;;5655:25;;5569:118;;;;:::o;3987:348:2:-;4073:4;-1:-1:-1;;;;;;;;;;;4073:4:2;4193:31;4210:4;4216:7;4193:16;:31::i;:::-;4178:46;;4238:7;4234:71;;;4261:14;:20;;;;;;;;;;:33;;4286:7;4261:24;:33::i;:::-;;4321:7;3987:348;-1:-1:-1;;;;3987:348:2:o;6576:123:38:-;6646:4;6669:23;6674:3;6686:5;6669:4;:23::i;4438:353:2:-;4525:4;-1:-1:-1;;;;;;;;;;;4525:4:2;4645:32;4663:4;4669:7;4645:17;:32::i;:::-;4630:47;;4691:7;4687:74;;;4714:14;:20;;;;;;;;;;:36;;4742:7;4714:27;:36::i;6867:129:38:-;6940:4;6963:26;6971:3;6983:5;6963:7;:26::i;7082:141:3:-;7149:17;:15;:17::i;:::-;7144:73;;7189:17;;-1:-1:-1;;;7189:17:3;;;;;;;;;;;2684:111:5;6929:20:3;:18;:20::i;:::-;2754:34:5::1;:32;:34::i;2336:406:38:-:0;2399:4;5006:21;;;:14;;;:21;;;;;;2415:321;;-1:-1:-1;2457:23:38;;;;;;;;:11;:23;;;;;;;;;;;;;2639:18;;2615:21;;;:14;;;:21;;;;;;:42;;;;2671:11;;2415:321;-1:-1:-1;2720:5:38;2713:12;;6227:109;6283:16;6318:3;:11;;6311:18;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6227:109;;;:::o;4437:582:23:-;4581:12;4610:7;4605:408;;4633:19;4641:10;4633:7;:19::i;:::-;4605:408;;;4857:17;;:22;:49;;;;-1:-1:-1;;;;;;4883:18:23;;;:23;4857:49;4853:119;;;4933:24;;-1:-1:-1;;;4933:24:23;;-1:-1:-1;;;;;3962:32:68;;4933:24:23;;;3944:51:68;3917:18;;4933:24:23;3780:221:68;4853:119:23;-1:-1:-1;4992:10:23;4437:582;-1:-1:-1;;4437:582:23:o;1290:365::-;1399:6;1375:21;:30;1371:125;;;1428:57;;-1:-1:-1;;;1428:57:23;;1455:21;1428:57;;;20730:25:68;20771:18;;;20764:34;;;20703:18;;1428:57:23;20556:248:68;1371:125:23;1507:12;1521:23;1548:9;-1:-1:-1;;;;;1548:14:23;1570:6;1548:33;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1506:75;;;;1596:7;1591:58;;1619:19;1627:10;1619:7;:19::i;1219:160:21:-;1328:43;;;-1:-1:-1;;;;;17713:32:68;;1328:43:21;;;17695:51:68;17762:18;;;;17755:34;;;1328:43:21;;;;;;;;;;17668:18:68;;;;1328:43:21;;;;;;;;-1:-1:-1;;;;;1328:43:21;-1:-1:-1;;;1328:43:21;;;1301:71;;1321:5;;1301:19;:71::i;7270:387:0:-;7347:4;-1:-1:-1;;;;;;;;;;;7437:22:0;7445:4;7451:7;7437;:22::i;:::-;7432:219;;7475:8;:14;;;;;;;;;;;-1:-1:-1;;;;;7475:31:0;;;;;;;;;:38;;-1:-1:-1;;7475:38:0;7509:4;7475:38;;;7559:12;966:10:4;;887:96;7559:12:0;-1:-1:-1;;;;;7532:40:0;7550:7;-1:-1:-1;;;;;7532:40:0;7544:4;7532:40;;;;;;;;;;7593:4;7586:11;;;;;7894:388;7972:4;-1:-1:-1;;;;;;;;;;;8061:22:0;8069:4;8075:7;8061;:22::i;:::-;8057:219;;;8133:5;8099:14;;;;;;;;;;;-1:-1:-1;;;;;8099:31:0;;;;;;;;;;:39;;-1:-1:-1;;8099:39:0;;;8157:40;966:10:4;;8099:14:0;;8157:40;;8133:5;8157:40;8218:4;8211:11;;;;;8485:120:3;8535:4;8558:26;:24;:26::i;:::-;:40;-1:-1:-1;;;8558:40:3;;;;;;-1:-1:-1;8485:120:3:o;2801:183:5:-;6929:20:3;:18;:20::i;5559:487:23:-;5690:17;;:21;5686:354;;5887:10;5881:17;5943:15;5930:10;5926:2;5922:19;5915:44;5686:354;6010:19;;-1:-1:-1;;;6010:19:23;;;;;;;;;;;8370:720:21;8450:18;8478:19;8616:4;8613:1;8606:4;8600:11;8593:4;8587;8583:15;8580:1;8573:5;8566;8561:60;8673:7;8663:176;;8717:4;8711:11;8762:16;8759:1;8754:3;8739:40;8808:16;8803:3;8796:29;8663:176;-1:-1:-1;;8916:1:21;8910:8;8866:16;;-1:-1:-1;8942:15:21;;:68;;8994:11;9009:1;8994:16;;8942:68;;;-1:-1:-1;;;;;8960:26:21;;;:31;8942:68;8938:146;;;9033:40;;-1:-1:-1;;;9033:40:21;;-1:-1:-1;;;;;3962:32:68;;9033:40:21;;;3944:51:68;3917:18;;9033:40:21;3780:221:68;14:286;72:6;125:2;113:9;104:7;100:23;96:32;93:52;;;141:1;138;131:12;93:52;167:23;;-1:-1:-1;;;;;;219:32:68;;209:43;;199:71;;266:1;263;256:12;497:131;-1:-1:-1;;;;;572:31:68;;562:42;;552:70;;618:1;615;608:12;633:247;692:6;745:2;733:9;724:7;720:23;716:32;713:52;;;761:1;758;751:12;713:52;800:9;787:23;819:31;844:5;819:31;:::i;1067:347::-;1118:8;1128:6;1182:3;1175:4;1167:6;1163:17;1159:27;1149:55;;1200:1;1197;1190:12;1149:55;-1:-1:-1;1223:20:68;;1266:18;1255:30;;1252:50;;;1298:1;1295;1288:12;1252:50;1335:4;1327:6;1323:17;1311:29;;1387:3;1380:4;1371:6;1363;1359:19;1355:30;1352:39;1349:59;;;1404:1;1401;1394:12;1349:59;1067:347;;;;;:::o;1419:754::-;1516:6;1524;1532;1540;1548;1601:3;1589:9;1580:7;1576:23;1572:33;1569:53;;;1618:1;1615;1608:12;1569:53;1657:9;1644:23;1676:31;1701:5;1676:31;:::i;:::-;1726:5;-1:-1:-1;1783:2:68;1768:18;;1755:32;1796:33;1755:32;1796:33;:::i;:::-;1848:7;-1:-1:-1;1902:2:68;1887:18;;1874:32;;-1:-1:-1;1957:2:68;1942:18;;1929:32;1984:18;1973:30;;1970:50;;;2016:1;2013;2006:12;1970:50;2055:58;2105:7;2096:6;2085:9;2081:22;2055:58;:::i;:::-;1419:754;;;;-1:-1:-1;1419:754:68;;-1:-1:-1;2132:8:68;;2029:84;1419:754;-1:-1:-1;;;1419:754:68:o;2385:456::-;2462:6;2470;2478;2531:2;2519:9;2510:7;2506:23;2502:32;2499:52;;;2547:1;2544;2537:12;2499:52;2586:9;2573:23;2605:31;2630:5;2605:31;:::i;:::-;2655:5;-1:-1:-1;2712:2:68;2697:18;;2684:32;2725:33;2684:32;2725:33;:::i;:::-;2385:456;;2777:7;;-1:-1:-1;;;2831:2:68;2816:18;;;;2803:32;;2385:456::o;3028:180::-;3087:6;3140:2;3128:9;3119:7;3115:23;3111:32;3108:52;;;3156:1;3153;3146:12;3108:52;-1:-1:-1;3179:23:68;;3028:180;-1:-1:-1;3028:180:68:o;3460:315::-;3528:6;3536;3589:2;3577:9;3568:7;3564:23;3560:32;3557:52;;;3605:1;3602;3595:12;3557:52;3641:9;3628:23;3618:33;;3701:2;3690:9;3686:18;3673:32;3714:31;3739:5;3714:31;:::i;:::-;3764:5;3754:15;;;3460:315;;;;;:::o;4214:409::-;4284:6;4292;4345:2;4333:9;4324:7;4320:23;4316:32;4313:52;;;4361:1;4358;4351:12;4313:52;4401:9;4388:23;4434:18;4426:6;4423:30;4420:50;;;4466:1;4463;4456:12;4420:50;4505:58;4555:7;4546:6;4535:9;4531:22;4505:58;:::i;:::-;4582:8;;4479:84;;-1:-1:-1;4214:409:68;-1:-1:-1;;;;4214:409:68:o;4858:456::-;4935:6;4943;4951;5004:2;4992:9;4983:7;4979:23;4975:32;4972:52;;;5020:1;5017;5010:12;4972:52;5056:9;5043:23;5033:33;;5116:2;5105:9;5101:18;5088:32;5129:31;5154:5;5129:31;:::i;:::-;5179:5;-1:-1:-1;5236:2:68;5221:18;;5208:32;5249:33;5208:32;5249:33;:::i;:::-;5301:7;5291:17;;;4858:456;;;;;:::o;5775:118::-;5861:5;5854:13;5847:21;5840:5;5837:32;5827:60;;5883:1;5880;5873:12;5898:890;6001:6;6009;6017;6025;6033;6041;6094:3;6082:9;6073:7;6069:23;6065:33;6062:53;;;6111:1;6108;6101:12;6062:53;6147:9;6134:23;6124:33;;6207:2;6196:9;6192:18;6179:32;6220:28;6242:5;6220:28;:::i;:::-;6267:5;-1:-1:-1;6324:2:68;6309:18;;6296:32;6337:33;6296:32;6337:33;:::i;:::-;6389:7;-1:-1:-1;6448:2:68;6433:18;;6420:32;6461:33;6420:32;6461:33;:::i;:::-;6513:7;-1:-1:-1;6571:3:68;6556:19;;6543:33;6599:18;6588:30;;6585:50;;;6631:1;6628;6621:12;6585:50;6670:58;6720:7;6711:6;6700:9;6696:22;6670:58;:::i;:::-;5898:890;;;;-1:-1:-1;5898:890:68;;-1:-1:-1;5898:890:68;;6747:8;;5898:890;-1:-1:-1;;;5898:890:68:o;6793:248::-;6861:6;6869;6922:2;6910:9;6901:7;6897:23;6893:32;6890:52;;;6938:1;6935;6928:12;6890:52;-1:-1:-1;;6961:23:68;;;7031:2;7016:18;;;7003:32;;-1:-1:-1;6793:248:68:o;7046:163::-;7113:20;;7173:10;7162:22;;7152:33;;7142:61;;7199:1;7196;7189:12;7142:61;7046:163;;;:::o;7214:574::-;7298:6;7306;7314;7322;7375:3;7363:9;7354:7;7350:23;7346:33;7343:53;;;7392:1;7389;7382:12;7343:53;7431:9;7418:23;7450:31;7475:5;7450:31;:::i;:::-;7500:5;-1:-1:-1;7557:2:68;7542:18;;7529:32;-1:-1:-1;;;;;7592:33:68;;7580:46;;7570:74;;7640:1;7637;7630:12;7570:74;7663:7;-1:-1:-1;7689:37:68;7722:2;7707:18;;7689:37;:::i;:::-;7679:47;;7745:37;7778:2;7767:9;7763:18;7745:37;:::i;:::-;7735:47;;7214:574;;;;;;;:::o;7978:658::-;8149:2;8201:21;;;8271:13;;8174:18;;;8293:22;;;8120:4;;8149:2;8372:15;;;;8346:2;8331:18;;;8120:4;8415:195;8429:6;8426:1;8423:13;8415:195;;;8494:13;;-1:-1:-1;;;;;8490:39:68;8478:52;;8585:15;;;;8550:12;;;;8526:1;8444:9;8415:195;;;-1:-1:-1;8627:3:68;;7978:658;-1:-1:-1;;;;;;7978:658:68:o;8641:315::-;8709:6;8717;8770:2;8758:9;8749:7;8745:23;8741:32;8738:52;;;8786:1;8783;8776:12;8738:52;8825:9;8812:23;8844:31;8869:5;8844:31;:::i;:::-;8894:5;8946:2;8931:18;;;;8918:32;;-1:-1:-1;;;8641:315:68:o;9190:388::-;9258:6;9266;9319:2;9307:9;9298:7;9294:23;9290:32;9287:52;;;9335:1;9332;9325:12;9287:52;9374:9;9361:23;9393:31;9418:5;9393:31;:::i;:::-;9443:5;-1:-1:-1;9500:2:68;9485:18;;9472:32;9513:33;9472:32;9513:33;:::i;9583:382::-;9648:6;9656;9709:2;9697:9;9688:7;9684:23;9680:32;9677:52;;;9725:1;9722;9715:12;9677:52;9764:9;9751:23;9783:31;9808:5;9783:31;:::i;:::-;9833:5;-1:-1:-1;9890:2:68;9875:18;;9862:32;9903:30;9862:32;9903:30;:::i;9970:245::-;10037:6;10090:2;10078:9;10069:7;10065:23;10061:32;10058:52;;;10106:1;10103;10096:12;10058:52;10138:9;10132:16;10157:28;10179:5;10157:28;:::i;10220:251::-;10290:6;10343:2;10331:9;10322:7;10318:23;10314:32;10311:52;;;10359:1;10356;10349:12;10311:52;10391:9;10385:16;10410:31;10435:5;10410:31;:::i;10476:127::-;10537:10;10532:3;10528:20;10525:1;10518:31;10568:4;10565:1;10558:15;10592:4;10589:1;10582:15;10608:136;10647:3;10675:5;10665:39;;10684:18;;:::i;:::-;-1:-1:-1;;;10720:18:68;;10608:136::o;10749:184::-;10819:6;10872:2;10860:9;10851:7;10847:23;10843:32;10840:52;;;10888:1;10885;10878:12;10840:52;-1:-1:-1;10911:16:68;;10749:184;-1:-1:-1;10749:184:68:o;10938:125::-;11003:9;;;11024:10;;;11021:36;;;11037:18;;:::i;11068:127::-;11129:10;11124:3;11120:20;11117:1;11110:31;11160:4;11157:1;11150:15;11184:4;11181:1;11174:15;11200:257;11272:4;11266:11;;;11304:17;;11351:18;11336:34;;11372:22;;;11333:62;11330:88;;;11398:18;;:::i;:::-;11434:4;11427:24;11200:257;:::o;11462:275::-;11533:2;11527:9;11598:2;11579:13;;-1:-1:-1;;11575:27:68;11563:40;;11633:18;11618:34;;11654:22;;;11615:62;11612:88;;;11680:18;;:::i;:::-;11716:2;11709:22;11462:275;;-1:-1:-1;11462:275:68:o;11742:2670::-;11983:6;11991;11999;12007;12015;12023;12031;12039;12047;12100:3;12088:9;12079:7;12075:23;12071:33;12068:53;;;12117:1;12114;12107:12;12068:53;12130:49;12168:9;12155:23;12130:49;:::i;:::-;12211:9;12198:23;12188:33;;12230:58;12283:2;12272:9;12268:18;12255:32;12230:58;:::i;:::-;12335:2;12324:9;12320:18;12307:32;12297:42;;12348:58;12401:2;12390:9;12386:18;12373:32;12348:58;:::i;:::-;12453:2;12442:9;12438:18;12425:32;12415:42;;12466:58;12519:2;12508:9;12504:18;12491:32;12466:58;:::i;:::-;12571:2;12560:9;12556:18;12543:32;12533:42;;12584:59;12637:3;12626:9;12622:19;12609:33;12584:59;:::i;:::-;12690:3;12679:9;12675:19;12662:33;12652:43;;12704:59;12757:3;12746:9;12742:19;12729:33;12704:59;:::i;:::-;12810:3;12799:9;12795:19;12782:33;12772:43;;12824:59;12877:3;12866:9;12862:19;12849:33;12824:59;:::i;:::-;12930:3;12919:9;12915:19;12902:33;12892:43;;12982:3;12971:9;12967:19;12954:33;12944:43;;13037:18;13030:3;13019:9;13015:19;13002:33;12999:57;12996:77;;;13069:1;13066;13059:12;12996:77;13158:7;13151:4;13143:3;13132:9;13128:19;13115:33;13104:9;13100:49;13096:60;13092:74;13082:102;;13180:1;13177;13170:12;13082:102;13264:18;13255:3;13244:9;13240:19;13227:33;13216:9;13212:49;13199:63;13196:87;13193:113;;;13286:18;;:::i;:::-;13326:97;13419:2;13409:3;13398:9;13394:19;13381:33;13370:9;13366:49;13353:63;13350:1;13346:71;13342:80;13326:97;:::i;:::-;13525:3;13510:19;;13497:33;13482:49;;13469:63;;13457:76;;;13558:2;13549:12;;;;13445:3;13639:1;13635:71;;;;13580:127;;;13576:136;13573:149;-1:-1:-1;13570:169:68;;;13735:1;13732;13725:12;13570:169;13814:2;13806:3;13795:9;13791:19;13778:33;13767:9;13763:49;13759:58;13826:556;13972:3;13957:19;;13944:33;13929:49;;13916:63;;13913:1;13909:71;13854:127;13983:2;13850:136;13842:145;;13826:556;;;14068:2;14062:3;14053:7;14049:17;14045:26;14042:46;;;14084:1;14081;14074:12;14042:46;14114:22;;:::i;:::-;14176:3;14163:17;14156:5;14149:32;14194:52;14241:2;14236:3;14232:12;14219:26;14194:52;:::i;:::-;14304:2;14295:12;;;14282:26;14266:14;;;14259:50;14322:18;;;14360:12;;;;;14014:2;14005:12;13826:556;;;13830:3;14401:5;14391:15;;;;11742:2670;;;;;;;;;;;:::o;14417:127::-;14478:10;14473:3;14469:20;14466:1;14459:31;14509:4;14506:1;14499:15;14533:4;14530:1;14523:15;14549:266;14637:6;14632:3;14625:19;14689:6;14682:5;14675:4;14670:3;14666:14;14653:43;-1:-1:-1;14741:1:68;14716:16;;;14734:4;14712:27;;;14705:38;;;;14797:2;14776:15;;;-1:-1:-1;;14772:29:68;14763:39;;;14759:50;;14549:266::o;14820:244::-;14977:2;14966:9;14959:21;14940:4;14997:61;15054:2;15043:9;15039:18;15031:6;15023;14997:61;:::i;15871:587::-;16074:6;16063:9;16056:25;16146:1;16142;16137:3;16133:11;16129:19;16121:6;16117:32;16112:2;16101:9;16097:18;16090:60;16186:2;16181;16170:9;16166:18;16159:30;16037:4;16218:6;16212:13;16261:6;16256:2;16245:9;16241:18;16234:34;16321:6;16316:2;16308:6;16304:15;16298:3;16287:9;16283:19;16277:51;16378:1;16372:3;16363:6;16352:9;16348:22;16344:32;16337:43;16448:3;16441:2;16437:7;16432:2;16424:6;16420:15;16416:29;16405:9;16401:45;16397:55;16389:63;;;15871:587;;;;;;:::o;16463:442::-;-1:-1:-1;;;;;16714:15:68;;;16696:34;;16766:15;;16761:2;16746:18;;16739:43;16818:2;16813;16798:18;;16791:30;;;16639:4;;16838:61;;16880:18;;16872:6;16864;16838:61;:::i;:::-;16830:69;16463:442;-1:-1:-1;;;;;;16463:442:68:o;16910:128::-;16977:9;;;16998:11;;;16995:37;;;17012:18;;:::i;19320:136::-;19355:3;-1:-1:-1;;;19376:22:68;;19373:48;;19401:18;;:::i;:::-;-1:-1:-1;19441:1:68;19437:13;;19320:136::o;19839:301::-;19968:3;20006:6;20000:13;20052:6;20045:4;20037:6;20033:17;20028:3;20022:37;20114:1;20078:16;;20103:13;;;-1:-1:-1;20078:16:68;19839:301;-1:-1:-1;19839:301:68:o;20424:127::-;20485:10;20480:3;20476:20;20473:1;20466:31;20516:4;20513:1;20506:15;20540:4;20537:1;20530:15
Swarm Source
ipfs://f303aa1e88b412ecf0bdcb901f6ae9e7c31b41c352254af18ab9efef324a8296
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in MON
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
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.