Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
TokenTracker
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Initialize | 21687106 | 88 days ago | IN | 0 ETH | 0.00184346 |
Latest 1 internal transaction
Advanced mode:
Parent Transaction Hash | Method | Block |
From
|
To
|
|||
---|---|---|---|---|---|---|---|
0x60c06040 | 21686833 | 88 days ago | Contract Creation | 0 ETH |
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
MellowVaultCompat
Compiler Version
v0.8.25+commit.b61c2a91
Optimization Enabled:
Yes with 200 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.25; import "./interfaces/vaults/IMellowVaultCompat.sol"; import {MellowSymbioticVault} from "./MellowSymbioticVault.sol"; contract MellowVaultCompat is IMellowVaultCompat, MellowSymbioticVault { bytes32 private constant ERC20CompatStorageSlot = 0; // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ERC20")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant ERC20UpgradeableStorageSlot = 0x52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00; function _getERC20CompatStorage() private pure returns (ERC20Storage storage $) { assembly { $.slot := ERC20CompatStorageSlot } } function _getERC20UpgradeableStorage() private pure returns (ERC20Storage storage $) { assembly { $.slot := ERC20UpgradeableStorageSlot } } constructor(bytes32 name_, uint256 version_) MellowSymbioticVault(name_, version_) {} /// @inheritdoc IMellowVaultCompat function compatTotalSupply() external view returns (uint256) { return _getERC20CompatStorage()._totalSupply; } /// @inheritdoc IMellowVaultCompat function migrateMultiple(address[] calldata users) external { for (uint256 i = 0; i < users.length; ++i) { migrate(users[i]); } } /// @inheritdoc IMellowVaultCompat function migrate(address user) public { ERC20Storage storage compatStorage = _getERC20CompatStorage(); uint256 balance = compatStorage._balances[user]; if (balance == 0) { return; } ERC20Storage storage upgradeableStorage = _getERC20UpgradeableStorage(); delete compatStorage._balances[user]; unchecked { upgradeableStorage._balances[user] += balance; compatStorage._totalSupply -= balance; upgradeableStorage._totalSupply += balance; } } /// @inheritdoc IMellowVaultCompat function migrateApproval(address from, address to) public { ERC20Storage storage compatStorage = _getERC20CompatStorage(); uint256 allowance_ = compatStorage._allowances[from][to]; if (allowance_ == 0) { return; } delete compatStorage._allowances[from][to]; super._approve(from, to, allowance_, false); } /** * @inheritdoc ERC20Upgradeable * @notice Updates balances for token transfers, ensuring any pre-existing balances in the old storage are migrated before performing the update. * @param from The address sending the tokens. * @param to The address receiving the tokens. * @param value The amount of tokens being transferred. */ function _update(address from, address to, uint256 value) internal virtual override { migrate(from); migrate(to); super._update(from, to, value); } /** * @inheritdoc ERC20Upgradeable * @notice Updates the allowance for the spender, ensuring any pre-existing allowances in the old storage are migrated before performing the update. * @param owner The address allowing the spender to spend tokens. * @param spender The address allowed to spend tokens. * @param value The amount of tokens the spender is allowed to spend. * @param emitEvent A flag to signal if the approval event should be emitted. */ function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual override(ERC20Upgradeable) { migrateApproval(owner, spender); super._approve(owner, spender, value, emitEvent); } /** * @inheritdoc IERC20 * @notice Returns the allowance for the given owner and spender, combining both pre-migration and post-migration allowances. * @param owner The address allowing the spender to spend tokens. * @param spender The address allowed to spend tokens. * @return The combined allowance for the owner and spender. */ function allowance(address owner, address spender) public view virtual override(ERC20Upgradeable, IERC20) returns (uint256) { return _getERC20CompatStorage()._allowances[owner][spender] + super.allowance(owner, spender); } /** * @inheritdoc IERC20 * @notice Returns the balance of the given account, combining both pre-migration and post-migration balances. * @param account The address of the account to query. * @return The combined balance of the account. */ function balanceOf(address account) public view override(IERC20, ERC20Upgradeable) returns (uint256) { return _getERC20CompatStorage()._balances[account] + super.balanceOf(account); } /** * @inheritdoc IERC20 * @notice Returns the total supply of tokens, combining both pre-migration and post-migration supplies. * @return The combined total supply of tokens. */ function totalSupply() public view override(IERC20, ERC20Upgradeable) returns (uint256) { return _getERC20CompatStorage()._totalSupply + super.totalSupply(); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.25; import {ERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; import {ERC4626Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC4626Upgradeable.sol"; import {ContextUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol"; import { Context, ERC20, IERC20, IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "./IMellowSymbioticVault.sol"; /** * @title IMellowVaultCompat * @notice This interface facilitates the migration of vaults from the older Mellow Vault to the newer Mellow Symbiotic Vault. * @dev Migration logic includes transferring user balances from old storage to new storage and gradually decreasing the old `_totalSupply`. * Once the old `_totalSupply` reaches zero, full migration to `MellowSymbioticVault` can be completed, removing redundant checks. */ interface IMellowVaultCompat is IMellowSymbioticVault { /** * @notice Returns the current total supply of the migrating vault. * @dev The total supply decreases as users are migrated to the new vault. * When it reaches zero, complete migration to the `MellowSymbioticVault` can be finalized. * @return compatTotalSupply The remaining total supply of the migrating vault. */ function compatTotalSupply() external view returns (uint256); /** * @notice Migrates the balances of multiple users from the old ERC20 storage to the new ERC20Upgradeable storage. * @param users An array of addresses corresponding to the users whose balances are being migrated. * * @custom:effects * - Transfers the user balances from the old vault storage to the new storage. */ function migrateMultiple(address[] calldata users) external; /** * @notice Migrates the balance of a single user from the old ERC20 storage to the new ERC20Upgradeable storage. * @param user The address of the user whose balance is being migrated. * * @custom:effects * - Transfers the user's balance from the old vault storage to the new storage. */ function migrate(address user) external; /** * @notice Migrates the approval of a spender from the old ERC20 storage to the new ERC20Upgradeable storage. * @param from The address of the user who is granting the approval. * @param to The address of the spender who is being approved. * * @custom:effects * - Transfers the user's approval from the old vault storage to the new storage. */ function migrateApproval(address from, address to) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.25; import {ERC4626Vault} from "./ERC4626Vault.sol"; import {MellowSymbioticVaultStorage} from "./MellowSymbioticVaultStorage.sol"; import {VaultControl, VaultControlStorage} from "./VaultControl.sol"; import "./interfaces/vaults/IMellowSymbioticVault.sol"; contract MellowSymbioticVault is IMellowSymbioticVault, MellowSymbioticVaultStorage, ERC4626Vault { using SafeERC20 for IERC20; using Math for uint256; uint256 private constant D6 = 1e6; bytes32 private constant SET_FARM_ROLE = keccak256("SET_FARM_ROLE"); constructor(bytes32 contractName_, uint256 contractVersion_) MellowSymbioticVaultStorage(contractName_, contractVersion_) VaultControlStorage(contractName_, contractVersion_) {} /// @inheritdoc IMellowSymbioticVault function initialize(InitParams memory initParams) public virtual initializer { __initialize(initParams); } function __initialize(InitParams memory initParams) internal virtual onlyInitializing { address collateral = ISymbioticVault(initParams.symbioticVault).collateral(); __initializeMellowSymbioticVaultStorage( initParams.symbioticCollateral, initParams.symbioticVault, initParams.withdrawalQueue ); __initializeERC4626( initParams.admin, initParams.limit, initParams.depositPause, initParams.withdrawalPause, initParams.depositWhitelist, collateral, initParams.name, initParams.symbol ); } /// @inheritdoc IMellowSymbioticVault function setFarm(uint256 farmId, FarmData memory farmData) external onlyRole(SET_FARM_ROLE) { _setFarmChecks(farmId, farmData); _setFarm(farmId, farmData); } function _setFarmChecks(uint256, /* id */ FarmData memory farmData) internal virtual { require( farmData.rewardToken != address(this) && farmData.rewardToken != address(symbioticVault()), "Vault: forbidden reward token" ); require(farmData.curatorFeeD6 <= D6, "Vault: invalid curator fee"); } /// @inheritdoc IERC4626 function totalAssets() public view virtual override(ERC4626Upgradeable, IERC4626) returns (uint256) { address this_ = address(this); return IERC20(asset()).balanceOf(this_) + symbioticCollateral().balanceOf(this_) + symbioticVault().activeBalanceOf(this_); } /// @inheritdoc ERC4626Upgradeable function _deposit(address caller, address receiver, uint256 assets, uint256 shares) internal virtual override { super._deposit(caller, receiver, assets, shares); pushIntoSymbiotic(); } /// @inheritdoc ERC4626Upgradeable function _withdraw( address caller, address receiver, address owner, uint256 assets, uint256 shares ) internal virtual override { address this_ = address(this); uint256 liquidAsset = IERC20(asset()).balanceOf(this_); if (liquidAsset >= assets) { return super._withdraw(caller, receiver, owner, assets, shares); } uint256 liquidCollateral = symbioticCollateral().balanceOf(this_); if (liquidCollateral != 0) { uint256 amount = liquidCollateral.min(assets - liquidAsset); symbioticCollateral().withdraw(this_, amount); liquidAsset += amount; if (liquidAsset >= assets) { return super._withdraw(caller, receiver, owner, assets, shares); } } uint256 staked = assets - liquidAsset; IWithdrawalQueue withdrawalQueue_ = withdrawalQueue(); (, uint256 requestedShares) = symbioticVault().withdraw(address(withdrawalQueue_), staked); withdrawalQueue_.request(receiver, requestedShares); if (caller != owner) { _spendAllowance(owner, caller, shares); } _burn(owner, shares); if (liquidAsset != 0) { IERC20(asset()).safeTransfer(receiver, liquidAsset); } // emitting event with transfered + new pending assets emit Withdraw(caller, receiver, owner, assets, shares); } /// @inheritdoc IMellowSymbioticVault function claimableAssetsOf(address account) external view returns (uint256 claimableAssets) { claimableAssets = withdrawalQueue().claimableAssetsOf(account); } /// @inheritdoc IMellowSymbioticVault function pendingAssetsOf(address account) external view returns (uint256 pendingAssets) { pendingAssets = withdrawalQueue().pendingAssetsOf(account); } /// @inheritdoc IMellowSymbioticVault function claim(address account, address recipient, uint256 maxAmount) external virtual nonReentrant returns (uint256) { require(account == _msgSender(), "Vault: forbidden"); return withdrawalQueue().claim(account, recipient, maxAmount); } /** * @notice Calculates the remaining deposit capacity in the Symbiotic Vault. * @param vault The Symbiotic Vault to check. * @return The remaining deposit capacity in the vault. Returns 0 if the vault has a deposit whitelist and the current contract is not whitelisted. * * @dev If the vault has no deposit limit, the maximum possible value is returned. * If the deposit limit is greater than the current active stake, the difference is returned. * Otherwise, returns 0. */ function _calculateSymbioticVaultLeftover(ISymbioticVault vault) internal view returns (uint256) { if (vault.depositWhitelist() && !vault.isDepositorWhitelisted(address(this))) { return 0; } if (!vault.isDepositLimit()) { return type(uint256).max; } uint256 activeStake = vault.activeStake(); uint256 limit = vault.depositLimit(); if (limit > activeStake) { return limit - activeStake; } return 0; } /** * @notice Calculates the amounts to be withdrawn from collateral, deposited into collateral, and deposited into the Symbiotic Vault. * @param asset_ The ERC20 asset being managed. * @param collateral The collateral contract associated with the vault. * @param symbioticVault The Symbiotic Vault where assets may be deposited. * @return collateralWithdrawal The amount to be withdrawn from the collateral. * @return collateralDeposit The amount to be deposited into the collateral. * @return vaultDeposit The amount to be deposited into the Symbiotic Vault. * * @dev This function considers the balance of assets and collateral, the remaining deposit capacity in the Symbiotic Vault, and the collateral's limits. * If the Symbiotic Vault has remaining capacity, assets are prioritized for deposit there. * Remaining assets are then considered for collateral deposit based on the collateral's limit. * @custom:effects At most one of the `collateralWithdrawal` and `collateralDeposit` parameters will be non-zero. */ function _calculatePushAmounts( IERC20 asset_, IDefaultCollateral collateral, ISymbioticVault symbioticVault ) internal view returns (uint256 collateralWithdrawal, uint256 collateralDeposit, uint256 vaultDeposit) { address this_ = address(this); uint256 assetAmount = asset_.balanceOf(this_); uint256 collateralAmount = collateral.balanceOf(this_); uint256 symbioticVaultLeftover = _calculateSymbioticVaultLeftover(symbioticVault); if (symbioticVaultLeftover != 0) { if (assetAmount < symbioticVaultLeftover && collateralAmount != 0) { collateralWithdrawal = collateralAmount.min(symbioticVaultLeftover - assetAmount); assetAmount += collateralWithdrawal; } if (assetAmount != 0) { vaultDeposit = assetAmount.min(symbioticVaultLeftover); assetAmount -= vaultDeposit; } } if (assetAmount != 0) { uint256 collateralLimit = collateral.limit(); uint256 collateralStake = collateral.totalSupply(); if (collateralLimit > collateralStake) { collateralDeposit = assetAmount.min(collateralLimit - collateralStake); } } } /// @inheritdoc IMellowSymbioticVault function pushIntoSymbiotic() public returns (uint256 collateralWithdrawal, uint256 collateralDeposit, uint256 vaultDeposit) { IERC20 asset_ = IERC20(asset()); IDefaultCollateral collateral = symbioticCollateral(); ISymbioticVault symbioticVault = symbioticVault(); address this_ = address(this); (collateralWithdrawal, collateralDeposit, vaultDeposit) = _calculatePushAmounts(asset_, collateral, symbioticVault); if (collateralWithdrawal != 0) { collateral.withdraw(this_, collateralWithdrawal); } if (collateralDeposit != 0) { asset_.safeIncreaseAllowance(address(collateral), collateralDeposit); collateral.deposit(this_, collateralDeposit); } if (vaultDeposit != 0) { asset_.safeIncreaseAllowance(address(symbioticVault), vaultDeposit); symbioticVault.deposit(this_, vaultDeposit); } emit SymbioticPushed(_msgSender(), collateralWithdrawal, collateralDeposit, vaultDeposit); } /// @inheritdoc IMellowSymbioticVault function pushRewards(uint256 farmId, bytes calldata symbioticRewardsData) external nonReentrant { FarmData memory data = symbioticFarm(farmId); require(data.rewardToken != address(0), "Vault: farm not set"); IERC20 rewardToken = IERC20(data.rewardToken); uint256 amountBefore = rewardToken.balanceOf(address(this)); IStakerRewards(data.symbioticFarm).claimRewards( address(this), address(rewardToken), symbioticRewardsData ); uint256 rewardAmount = rewardToken.balanceOf(address(this)) - amountBefore; if (rewardAmount == 0) { return; } uint256 curatorFee = rewardAmount.mulDiv(data.curatorFeeD6, D6); if (curatorFee != 0) { rewardToken.safeTransfer(data.curatorTreasury, curatorFee); } // Guranteed to be >= 0 since data.curatorFeeD6 <= D6 rewardAmount = rewardAmount - curatorFee; if (rewardAmount != 0) { rewardToken.safeTransfer(data.distributionFarm, rewardAmount); } emit RewardsPushed(farmId, rewardAmount, curatorFee, block.timestamp); } /// @inheritdoc IMellowSymbioticVault function getBalances(address account) public view returns ( uint256 accountAssets, uint256 accountInstantAssets, uint256 accountShares, uint256 accountInstantShares ) { address this_ = address(this); uint256 instantAssets = IERC20(asset()).balanceOf(this_) + symbioticCollateral().balanceOf(this_); accountShares = balanceOf(account); accountAssets = convertToAssets(accountShares); accountInstantAssets = accountAssets.min(instantAssets); accountInstantShares = convertToShares(accountInstantAssets); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import {ContextUpgradeable} from "../../utils/ContextUpgradeable.sol"; import {IERC20Errors} from "@openzeppelin/contracts/interfaces/draft-IERC6093.sol"; import {Initializable} from "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * * TIP: For a detailed writeup see our guide * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * The default value of {decimals} is 18. To change this, you should override * this function so it returns a different value. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. */ abstract contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20, IERC20Metadata, IERC20Errors { /// @custom:storage-location erc7201:openzeppelin.storage.ERC20 struct ERC20Storage { mapping(address account => uint256) _balances; mapping(address account => mapping(address spender => uint256)) _allowances; uint256 _totalSupply; string _name; string _symbol; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ERC20")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant ERC20StorageLocation = 0x52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00; function _getERC20Storage() private pure returns (ERC20Storage storage $) { assembly { $.slot := ERC20StorageLocation } } /** * @dev Sets the values for {name} and {symbol}. * * All two of these values are immutable: they can only be set once during * construction. */ function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing { __ERC20_init_unchained(name_, symbol_); } function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing { ERC20Storage storage $ = _getERC20Storage(); $._name = name_; $._symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { ERC20Storage storage $ = _getERC20Storage(); return $._name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { ERC20Storage storage $ = _getERC20Storage(); return $._symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the default value returned by this function, unless * it's overridden. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual returns (uint256) { ERC20Storage storage $ = _getERC20Storage(); return $._totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual returns (uint256) { ERC20Storage storage $ = _getERC20Storage(); return $._balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `value`. */ function transfer(address to, uint256 value) public virtual returns (bool) { address owner = _msgSender(); _transfer(owner, to, value); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual returns (uint256) { ERC20Storage storage $ = _getERC20Storage(); return $._allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 value) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, value); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `value`. * - the caller must have allowance for ``from``'s tokens of at least * `value`. */ function transferFrom(address from, address to, uint256 value) public virtual returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, value); _transfer(from, to, value); return true; } /** * @dev Moves a `value` amount of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _transfer(address from, address to, uint256 value) internal { if (from == address(0)) { revert ERC20InvalidSender(address(0)); } if (to == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(from, to, value); } /** * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from` * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding * this function. * * Emits a {Transfer} event. */ function _update(address from, address to, uint256 value) internal virtual { ERC20Storage storage $ = _getERC20Storage(); if (from == address(0)) { // Overflow check required: The rest of the code assumes that totalSupply never overflows $._totalSupply += value; } else { uint256 fromBalance = $._balances[from]; if (fromBalance < value) { revert ERC20InsufficientBalance(from, fromBalance, value); } unchecked { // Overflow not possible: value <= fromBalance <= totalSupply. $._balances[from] = fromBalance - value; } } if (to == address(0)) { unchecked { // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply. $._totalSupply -= value; } } else { unchecked { // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256. $._balances[to] += value; } } emit Transfer(from, to, value); } /** * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0). * Relies on the `_update` mechanism * * Emits a {Transfer} event with `from` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _mint(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(address(0), account, value); } /** * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply. * Relies on the `_update` mechanism. * * Emits a {Transfer} event with `to` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead */ function _burn(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidSender(address(0)); } _update(account, address(0), value); } /** * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. * * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument. */ function _approve(address owner, address spender, uint256 value) internal { _approve(owner, spender, value, true); } /** * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event. * * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any * `Approval` event during `transferFrom` operations. * * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to * true using the following override: * ``` * function _approve(address owner, address spender, uint256 value, bool) internal virtual override { * super._approve(owner, spender, value, true); * } * ``` * * Requirements are the same as {_approve}. */ function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual { ERC20Storage storage $ = _getERC20Storage(); if (owner == address(0)) { revert ERC20InvalidApprover(address(0)); } if (spender == address(0)) { revert ERC20InvalidSpender(address(0)); } $._allowances[owner][spender] = value; if (emitEvent) { emit Approval(owner, spender, value); } } /** * @dev Updates `owner` s allowance for `spender` based on spent `value`. * * Does not update the allowance value in case of infinite allowance. * Revert if not enough allowance is available. * * Does not emit an {Approval} event. */ function _spendAllowance(address owner, address spender, uint256 value) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { if (currentAllowance < value) { revert ERC20InsufficientAllowance(spender, currentAllowance, value); } unchecked { _approve(owner, spender, currentAllowance - value, false); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC4626.sol) pragma solidity ^0.8.20; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import {ERC20Upgradeable} from "../ERC20Upgradeable.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {IERC4626} from "@openzeppelin/contracts/interfaces/IERC4626.sol"; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {Initializable} from "../../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the ERC4626 "Tokenized Vault Standard" as defined in * https://eips.ethereum.org/EIPS/eip-4626[EIP-4626]. * * This extension allows the minting and burning of "shares" (represented using the ERC20 inheritance) in exchange for * underlying "assets" through standardized {deposit}, {mint}, {redeem} and {burn} workflows. This contract extends * the ERC20 standard. Any additional extensions included along it would affect the "shares" token represented by this * contract and not the "assets" token which is an independent contract. * * [CAUTION] * ==== * In empty (or nearly empty) ERC-4626 vaults, deposits are at high risk of being stolen through frontrunning * with a "donation" to the vault that inflates the price of a share. This is variously known as a donation or inflation * attack and is essentially a problem of slippage. Vault deployers can protect against this attack by making an initial * deposit of a non-trivial amount of the asset, such that price manipulation becomes infeasible. Withdrawals may * similarly be affected by slippage. Users can protect against this attack as well as unexpected slippage in general by * verifying the amount received is as expected, using a wrapper that performs these checks such as * https://github.com/fei-protocol/ERC4626#erc4626router-and-base[ERC4626Router]. * * Since v4.9, this implementation uses virtual assets and shares to mitigate that risk. The `_decimalsOffset()` * corresponds to an offset in the decimal representation between the underlying asset's decimals and the vault * decimals. This offset also determines the rate of virtual shares to virtual assets in the vault, which itself * determines the initial exchange rate. While not fully preventing the attack, analysis shows that the default offset * (0) makes it non-profitable, as a result of the value being captured by the virtual shares (out of the attacker's * donation) matching the attacker's expected gains. With a larger offset, the attack becomes orders of magnitude more * expensive than it is profitable. More details about the underlying math can be found * xref:erc4626.adoc#inflation-attack[here]. * * The drawback of this approach is that the virtual shares do capture (a very small) part of the value being accrued * to the vault. Also, if the vault experiences losses, the users try to exit the vault, the virtual shares and assets * will cause the first user to exit to experience reduced losses in detriment to the last users that will experience * bigger losses. Developers willing to revert back to the pre-v4.9 behavior just need to override the * `_convertToShares` and `_convertToAssets` functions. * * To learn more, check out our xref:ROOT:erc4626.adoc[ERC-4626 guide]. * ==== */ abstract contract ERC4626Upgradeable is Initializable, ERC20Upgradeable, IERC4626 { using Math for uint256; /// @custom:storage-location erc7201:openzeppelin.storage.ERC4626 struct ERC4626Storage { IERC20 _asset; uint8 _underlyingDecimals; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ERC4626")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant ERC4626StorageLocation = 0x0773e532dfede91f04b12a73d3d2acd361424f41f76b4fb79f090161e36b4e00; function _getERC4626Storage() private pure returns (ERC4626Storage storage $) { assembly { $.slot := ERC4626StorageLocation } } /** * @dev Attempted to deposit more assets than the max amount for `receiver`. */ error ERC4626ExceededMaxDeposit(address receiver, uint256 assets, uint256 max); /** * @dev Attempted to mint more shares than the max amount for `receiver`. */ error ERC4626ExceededMaxMint(address receiver, uint256 shares, uint256 max); /** * @dev Attempted to withdraw more assets than the max amount for `receiver`. */ error ERC4626ExceededMaxWithdraw(address owner, uint256 assets, uint256 max); /** * @dev Attempted to redeem more shares than the max amount for `receiver`. */ error ERC4626ExceededMaxRedeem(address owner, uint256 shares, uint256 max); /** * @dev Set the underlying asset contract. This must be an ERC20-compatible contract (ERC20 or ERC777). */ function __ERC4626_init(IERC20 asset_) internal onlyInitializing { __ERC4626_init_unchained(asset_); } function __ERC4626_init_unchained(IERC20 asset_) internal onlyInitializing { ERC4626Storage storage $ = _getERC4626Storage(); (bool success, uint8 assetDecimals) = _tryGetAssetDecimals(asset_); $._underlyingDecimals = success ? assetDecimals : 18; $._asset = asset_; } /** * @dev Attempts to fetch the asset decimals. A return value of false indicates that the attempt failed in some way. */ function _tryGetAssetDecimals(IERC20 asset_) private view returns (bool, uint8) { (bool success, bytes memory encodedDecimals) = address(asset_).staticcall( abi.encodeCall(IERC20Metadata.decimals, ()) ); if (success && encodedDecimals.length >= 32) { uint256 returnedDecimals = abi.decode(encodedDecimals, (uint256)); if (returnedDecimals <= type(uint8).max) { return (true, uint8(returnedDecimals)); } } return (false, 0); } /** * @dev Decimals are computed by adding the decimal offset on top of the underlying asset's decimals. This * "original" value is cached during construction of the vault contract. If this read operation fails (e.g., the * asset has not been created yet), a default of 18 is used to represent the underlying asset's decimals. * * See {IERC20Metadata-decimals}. */ function decimals() public view virtual override(IERC20Metadata, ERC20Upgradeable) returns (uint8) { ERC4626Storage storage $ = _getERC4626Storage(); return $._underlyingDecimals + _decimalsOffset(); } /** @dev See {IERC4626-asset}. */ function asset() public view virtual returns (address) { ERC4626Storage storage $ = _getERC4626Storage(); return address($._asset); } /** @dev See {IERC4626-totalAssets}. */ function totalAssets() public view virtual returns (uint256) { ERC4626Storage storage $ = _getERC4626Storage(); return $._asset.balanceOf(address(this)); } /** @dev See {IERC4626-convertToShares}. */ function convertToShares(uint256 assets) public view virtual returns (uint256) { return _convertToShares(assets, Math.Rounding.Floor); } /** @dev See {IERC4626-convertToAssets}. */ function convertToAssets(uint256 shares) public view virtual returns (uint256) { return _convertToAssets(shares, Math.Rounding.Floor); } /** @dev See {IERC4626-maxDeposit}. */ function maxDeposit(address) public view virtual returns (uint256) { return type(uint256).max; } /** @dev See {IERC4626-maxMint}. */ function maxMint(address) public view virtual returns (uint256) { return type(uint256).max; } /** @dev See {IERC4626-maxWithdraw}. */ function maxWithdraw(address owner) public view virtual returns (uint256) { return _convertToAssets(balanceOf(owner), Math.Rounding.Floor); } /** @dev See {IERC4626-maxRedeem}. */ function maxRedeem(address owner) public view virtual returns (uint256) { return balanceOf(owner); } /** @dev See {IERC4626-previewDeposit}. */ function previewDeposit(uint256 assets) public view virtual returns (uint256) { return _convertToShares(assets, Math.Rounding.Floor); } /** @dev See {IERC4626-previewMint}. */ function previewMint(uint256 shares) public view virtual returns (uint256) { return _convertToAssets(shares, Math.Rounding.Ceil); } /** @dev See {IERC4626-previewWithdraw}. */ function previewWithdraw(uint256 assets) public view virtual returns (uint256) { return _convertToShares(assets, Math.Rounding.Ceil); } /** @dev See {IERC4626-previewRedeem}. */ function previewRedeem(uint256 shares) public view virtual returns (uint256) { return _convertToAssets(shares, Math.Rounding.Floor); } /** @dev See {IERC4626-deposit}. */ function deposit(uint256 assets, address receiver) public virtual returns (uint256) { uint256 maxAssets = maxDeposit(receiver); if (assets > maxAssets) { revert ERC4626ExceededMaxDeposit(receiver, assets, maxAssets); } uint256 shares = previewDeposit(assets); _deposit(_msgSender(), receiver, assets, shares); return shares; } /** @dev See {IERC4626-mint}. * * As opposed to {deposit}, minting is allowed even if the vault is in a state where the price of a share is zero. * In this case, the shares will be minted without requiring any assets to be deposited. */ function mint(uint256 shares, address receiver) public virtual returns (uint256) { uint256 maxShares = maxMint(receiver); if (shares > maxShares) { revert ERC4626ExceededMaxMint(receiver, shares, maxShares); } uint256 assets = previewMint(shares); _deposit(_msgSender(), receiver, assets, shares); return assets; } /** @dev See {IERC4626-withdraw}. */ function withdraw(uint256 assets, address receiver, address owner) public virtual returns (uint256) { uint256 maxAssets = maxWithdraw(owner); if (assets > maxAssets) { revert ERC4626ExceededMaxWithdraw(owner, assets, maxAssets); } uint256 shares = previewWithdraw(assets); _withdraw(_msgSender(), receiver, owner, assets, shares); return shares; } /** @dev See {IERC4626-redeem}. */ function redeem(uint256 shares, address receiver, address owner) public virtual returns (uint256) { uint256 maxShares = maxRedeem(owner); if (shares > maxShares) { revert ERC4626ExceededMaxRedeem(owner, shares, maxShares); } uint256 assets = previewRedeem(shares); _withdraw(_msgSender(), receiver, owner, assets, shares); return assets; } /** * @dev Internal conversion function (from assets to shares) with support for rounding direction. */ function _convertToShares(uint256 assets, Math.Rounding rounding) internal view virtual returns (uint256) { return assets.mulDiv(totalSupply() + 10 ** _decimalsOffset(), totalAssets() + 1, rounding); } /** * @dev Internal conversion function (from shares to assets) with support for rounding direction. */ function _convertToAssets(uint256 shares, Math.Rounding rounding) internal view virtual returns (uint256) { return shares.mulDiv(totalAssets() + 1, totalSupply() + 10 ** _decimalsOffset(), rounding); } /** * @dev Deposit/mint common workflow. */ function _deposit(address caller, address receiver, uint256 assets, uint256 shares) internal virtual { ERC4626Storage storage $ = _getERC4626Storage(); // If _asset is ERC777, `transferFrom` can trigger a reentrancy BEFORE the transfer happens through the // `tokensToSend` hook. On the other hand, the `tokenReceived` hook, that is triggered after the transfer, // calls the vault, which is assumed not malicious. // // Conclusion: we need to do the transfer before we mint so that any reentrancy would happen before the // assets are transferred and before the shares are minted, which is a valid state. // slither-disable-next-line reentrancy-no-eth SafeERC20.safeTransferFrom($._asset, caller, address(this), assets); _mint(receiver, shares); emit Deposit(caller, receiver, assets, shares); } /** * @dev Withdraw/redeem common workflow. */ function _withdraw( address caller, address receiver, address owner, uint256 assets, uint256 shares ) internal virtual { ERC4626Storage storage $ = _getERC4626Storage(); if (caller != owner) { _spendAllowance(owner, caller, shares); } // If _asset is ERC777, `transfer` can trigger a reentrancy AFTER the transfer happens through the // `tokensReceived` hook. On the other hand, the `tokensToSend` hook, that is triggered before the transfer, // calls the vault, which is assumed not malicious. // // Conclusion: we need to do the transfer after the burn so that any reentrancy would happen after the // shares are burned and after the assets are transferred, which is a valid state. _burn(owner, shares); SafeERC20.safeTransfer($._asset, receiver, assets); emit Withdraw(caller, receiver, owner, assets, shares); } function _decimalsOffset() internal view virtual returns (uint8) { return 0; } }
// 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.0.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "./IERC20.sol"; import {IERC20Metadata} from "./extensions/IERC20Metadata.sol"; import {Context} from "../../utils/Context.sol"; import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * * TIP: For a detailed writeup see our guide * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * The default value of {decimals} is 18. To change this, you should override * this function so it returns a different value. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. */ abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors { mapping(address account => uint256) private _balances; mapping(address account => mapping(address spender => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the default value returned by this function, unless * it's overridden. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `value`. */ function transfer(address to, uint256 value) public virtual returns (bool) { address owner = _msgSender(); _transfer(owner, to, value); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 value) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, value); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `value`. * - the caller must have allowance for ``from``'s tokens of at least * `value`. */ function transferFrom(address from, address to, uint256 value) public virtual returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, value); _transfer(from, to, value); return true; } /** * @dev Moves a `value` amount of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _transfer(address from, address to, uint256 value) internal { if (from == address(0)) { revert ERC20InvalidSender(address(0)); } if (to == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(from, to, value); } /** * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from` * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding * this function. * * Emits a {Transfer} event. */ function _update(address from, address to, uint256 value) internal virtual { if (from == address(0)) { // Overflow check required: The rest of the code assumes that totalSupply never overflows _totalSupply += value; } else { uint256 fromBalance = _balances[from]; if (fromBalance < value) { revert ERC20InsufficientBalance(from, fromBalance, value); } unchecked { // Overflow not possible: value <= fromBalance <= totalSupply. _balances[from] = fromBalance - value; } } if (to == address(0)) { unchecked { // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply. _totalSupply -= value; } } else { unchecked { // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256. _balances[to] += value; } } emit Transfer(from, to, value); } /** * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0). * Relies on the `_update` mechanism * * Emits a {Transfer} event with `from` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _mint(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(address(0), account, value); } /** * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply. * Relies on the `_update` mechanism. * * Emits a {Transfer} event with `to` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead */ function _burn(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidSender(address(0)); } _update(account, address(0), value); } /** * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. * * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument. */ function _approve(address owner, address spender, uint256 value) internal { _approve(owner, spender, value, true); } /** * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event. * * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any * `Approval` event during `transferFrom` operations. * * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to * true using the following override: * ``` * function _approve(address owner, address spender, uint256 value, bool) internal virtual override { * super._approve(owner, spender, value, true); * } * ``` * * Requirements are the same as {_approve}. */ function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual { if (owner == address(0)) { revert ERC20InvalidApprover(address(0)); } if (spender == address(0)) { revert ERC20InvalidSpender(address(0)); } _allowances[owner][spender] = value; if (emitEvent) { emit Approval(owner, spender, value); } } /** * @dev Updates `owner` s allowance for `spender` based on spent `value`. * * Does not update the allowance value in case of infinite allowance. * Revert if not enough allowance is available. * * Does not emit an {Approval} event. */ function _spendAllowance(address owner, address spender, uint256 value) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { if (currentAllowance < value) { revert ERC20InsufficientAllowance(spender, currentAllowance, value); } unchecked { _approve(owner, spender, currentAllowance - value, false); } } } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.25; import {IDefaultCollateral} from "../tokens/IDefaultCollateral.sol"; import {IWithdrawalQueue} from "../utils/IWithdrawalQueue.sol"; import {IERC4626Vault} from "./IERC4626Vault.sol"; import {IMellowSymbioticVaultStorage} from "./IMellowSymbioticVaultStorage.sol"; import {AccessManagerUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagerUpgradeable.sol"; import { ERC4626Upgradeable, IERC4626 } from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC4626Upgradeable.sol"; import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol"; import {IERC20, SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {IVault as ISymbioticVault} from "@symbiotic/core/interfaces/vault/IVault.sol"; import {IStakerRewards} from "@symbiotic/rewards/interfaces/stakerRewards/IStakerRewards.sol"; /** * @title IMellowSymbioticVault * @notice Interface for the Mellow Symbiotic Vault. */ interface IMellowSymbioticVault is IMellowSymbioticVaultStorage, IERC4626Vault { /** * @notice Struct to store initialization parameters for the vault. * @param limit The maximum limit for deposits. * @param symbioticCollateral The address of the underlying Symbiotic Collateral. * @param symbioticVault The address of the underlying Symbiotic Vault. * @param withdrawalQueue The address of the associated withdrawal queue. * @param admin The address of the vault's admin. * @param depositPause Indicates whether deposits are paused initially. * @param withdrawalPause Indicates whether withdrawals are paused initially. * @param depositWhitelist Indicates whether a deposit whitelist is enabled initially. * @param name The name of the vault token. * @param symbol The symbol of the vault token. */ struct InitParams { uint256 limit; address symbioticCollateral; address symbioticVault; address withdrawalQueue; address admin; bool depositPause; bool withdrawalPause; bool depositWhitelist; string name; string symbol; } /** * @notice Initializes the vault with the provided parameters. * @param initParams The initialization parameters. * * @custom:requirements * - The vault MUST not have been initialized before this call. */ function initialize(InitParams memory initParams) external; /** * @notice Sets a farm for the vault with the given farm ID and data. * @param farmId The ID of the farm. * @param farmData The data for the farm. * * @custom:requirements * - `FarmData.rewardToken` MUST be the vault token or Symbiotic Vault token. * - `farmData.curatorFeeD6` MUST not exceed 10^6 (100%). */ function setFarm(uint256 farmId, FarmData memory farmData) external; /** * @notice Returns the amount of `asset` that can be claimed by a specific account. * @param account The address of the account. * @return claimableAssets The amount of claimable assets. */ function claimableAssetsOf(address account) external view returns (uint256 claimableAssets); /** * @notice Returns the amount of `asset` that is in the withdrawal queue for a specific account. * @param account The address of the account. * @return pendingAssets The amount of pending assets that cannot be claimed yet. */ function pendingAssetsOf(address account) external view returns (uint256 pendingAssets); /** * @notice Finalizes the withdrawal process for an account and transfers assets to the recipient. * @param account The address of the account initiating the withdrawal. * @param recipient The address of the recipient receiving the assets. * @param maxAmount The maximum amount of assets to withdraw. * @return shares The actual number of shares claimed. * * @custom:requirements * - The `account` MUST be equal to `msg.sender`. * * @custom:effects * - Finalizes the withdrawal process and transfers up to `maxAmount` of `asset` to the `recipient`. */ function claim(address account, address recipient, uint256 maxAmount) external returns (uint256); /** * @notice Deposits available assets into the Symbiotic Vault and collateral according to their capacities. * @return collateralWithdrawal The amount of collateral withdrawn to match the Symbiotic Vault deposit requirements. * @return collateralDeposit The amount of assets deposited into the collateral. * @return vaultDeposit The amount of assets deposited into the Symbiotic Vault. * * @dev This function first calculates the appropriate amounts to withdraw and deposit using `_calculatePushAmounts`. * It then performs the necessary withdrawals and deposits, adjusting allowances as needed. * Finally, it emits a `SymbioticPushed` event with the results. * @custom:effects * - Deposits assets into the Symbiotic Vault and collateral according to their capacities. * - Prioritizes Symbiotic Vault deposits over collateral deposits. * - If required withdraws collateral to match the Symbiotic Vault deposit requirements. * - Emits the `SymbioticPushed` event. */ function pushIntoSymbiotic() external returns (uint256 collateralWithdrawal, uint256 collateralDeposit, uint256 vaultDeposit); /** * @notice Pushes rewards to the Farm and Curator of the vault for a specified farm ID. * @param farmId The ID of the farm. * @param symbioticRewardsData The data specific to the Symbiotic Vault's `claimRewards()` method. * * @custom:effects * - Transfers a portion of the Symbiotic Vault's reward token to the Curator as a fee. * - The remaining rewards are pushed to the Farm. * - Emits the `RewardsPushed` event. */ function pushRewards(uint256 farmId, bytes calldata symbioticRewardsData) external; /** * @notice Returns the full balance details for a specific account. * @param account The address of the account. * @return accountAssets The total amount of assets belonging to the account. * @return accountInstantAssets The amount of assets that can be withdrawn instantly. * @return accountShares The total amount of shares belonging to the account. * @return accountInstantShares The amount of shares that can be withdrawn instantly. */ function getBalances(address account) external view returns ( uint256 accountAssets, uint256 accountInstantAssets, uint256 accountShares, uint256 accountInstantShares ); /** * @notice Emitted when rewards are pushed to the Farm and Curator treasury. * @param farmId The ID of the farm. * @param rewardAmount The amount of rewards pushed. * @param curatorFee The fee taken by the curator. * @param timestamp The time at which the rewards were pushed. */ event RewardsPushed( uint256 indexed farmId, uint256 rewardAmount, uint256 curatorFee, uint256 timestamp ); /** * @notice Emitted when assets are pushed from the vault into the Symbiotic Vault. * @param sender The address that initiated the push. * @param vaultAmount The amount of assets pushed to the Symbiotic Vault. * @param collateralDeposit The amount of collateral deposited. * @param collateralWithdrawal The amount of collateral withdrawn. */ event SymbioticPushed( address sender, uint256 collateralWithdrawal, uint256 collateralDeposit, uint256 vaultAmount ); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.25; import "./interfaces/vaults/IERC4626Vault.sol"; import {VaultControl} from "./VaultControl.sol"; abstract contract ERC4626Vault is VaultControl, ERC4626Upgradeable, IERC4626Vault { bytes32[16] private _reserved; // Reserved storage space for backward compatibility. /** * @notice Initializes the ERC4626 vault with the provided settings, including admin, limits, pause states, and token details. * @param _admin The address of the admin to be granted control over the vault. * @param _limit The initial deposit limit for the vault. * @param _depositPause The initial state of the `depositPause` flag. * @param _withdrawalPause The initial state of the `withdrawalPause` flag. * @param _depositWhitelist The initial state of the `depositWhitelist` flag. * @param _asset The address of the underlying ERC20 asset for the ERC4626 vault. * @param _name The name of the ERC20 token representing shares of the vault. * @param _symbol The symbol of the ERC20 token representing shares of the vault. * * @custom:effects * - Initializes the vault control settings, including admin, limits, and pause states, via `__initializeVaultControl`. * - Initializes the ERC20 token properties with the provided `_name` and `_symbol`. * - Initializes the ERC4626 vault with the provided underlying asset (`_asset`). * * @dev This function is protected by the `onlyInitializing` modifier, ensuring it is only called during the initialization phase of the contract. */ function __initializeERC4626( address _admin, uint256 _limit, bool _depositPause, bool _withdrawalPause, bool _depositWhitelist, address _asset, string memory _name, string memory _symbol ) internal onlyInitializing { __initializeVaultControl(_admin, _limit, _depositPause, _withdrawalPause, _depositWhitelist); __ERC20_init(_name, _symbol); __ERC4626_init(IERC20(_asset)); } /// @inheritdoc IERC4626 function maxMint(address account) public view virtual override(ERC4626Upgradeable, IERC4626) returns (uint256) { uint256 assets = maxDeposit(account); if (assets == type(uint256).max) { return type(uint256).max; } return convertToShares(assets); } /// @inheritdoc IERC4626 function maxDeposit(address account) public view virtual override(ERC4626Upgradeable, IERC4626) returns (uint256) { if (depositPause()) { return 0; } if (depositWhitelist() && !isDepositorWhitelisted(account)) { return 0; } uint256 limit_ = limit(); if (limit_ == type(uint256).max) { return type(uint256).max; } uint256 assets_ = totalAssets(); return limit_ >= assets_ ? limit_ - assets_ : 0; } /// @inheritdoc IERC4626 function maxWithdraw(address account) public view virtual override(ERC4626Upgradeable, IERC4626) returns (uint256) { if (withdrawalPause()) { return 0; } return super.maxWithdraw(account); } /// @inheritdoc IERC4626 function maxRedeem(address account) public view virtual override(ERC4626Upgradeable, IERC4626) returns (uint256) { if (withdrawalPause()) { return 0; } return super.maxRedeem(account); } /// @inheritdoc IERC4626Vault function deposit(uint256 assets, address receiver, address referral) public virtual returns (uint256 shares) { shares = deposit(assets, receiver); emit ReferralDeposit(assets, receiver, referral); } /// @inheritdoc IERC4626 function deposit(uint256 assets, address receiver) public virtual override(ERC4626Upgradeable, IERC4626) nonReentrant returns (uint256) { return super.deposit(assets, receiver); } /// @inheritdoc IERC4626 function mint(uint256 shares, address receiver) public virtual override(ERC4626Upgradeable, IERC4626) nonReentrant returns (uint256) { return super.mint(shares, receiver); } /// @inheritdoc IERC4626 function withdraw(uint256 assets, address receiver, address owner) public virtual override(ERC4626Upgradeable, IERC4626) nonReentrant returns (uint256) { return super.withdraw(assets, receiver, owner); } /// @inheritdoc IERC4626 function redeem(uint256 shares, address receiver, address owner) public virtual override(ERC4626Upgradeable, IERC4626) nonReentrant returns (uint256) { return super.redeem(shares, receiver, owner); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.25; import "./interfaces/vaults/IMellowSymbioticVaultStorage.sol"; abstract contract MellowSymbioticVaultStorage is IMellowSymbioticVaultStorage, Initializable { using EnumerableSet for EnumerableSet.UintSet; ///@notice The first slot of the storage. bytes32 private immutable storageSlotRef; constructor(bytes32 name_, uint256 version_) { storageSlotRef = keccak256( abi.encode( uint256( keccak256( abi.encodePacked( "mellow.simple-lrt.storage.MellowSymbioticVaultStorage", name_, version_ ) ) ) - 1 ) ) & ~bytes32(uint256(0xff)); } /** * @notice Initializes the storage of the Mellow Symbiotic Vault. * @param _symbioticCollateral The address of the underlying Symbiotic DefaultCollateral. * @param _symbioticVault The address of the underlying Symbiotic Vault. * @param _withdrawalQueue The address of the associated Withdrawal Queue. * * @custom:requirements * - This function MUST be called only once, during the initialization phase (i.e., it MUST not have been initialized before). * * @custom:effects * - Sets the Symbiotic Vault address, Symbiotic Collateral address and the Withdrawal Queue address in storage. * - Emits the `SymbioticCollateralSet` event, signaling that the Symbiotic Collateral has been successfully set. * - Emits the `SymbioticVaultSet` event, signaling that the Symbiotic Vault has been successfully set. * - Emits the `WithdrawalQueueSet` event, signaling that the Withdrawal Queue has been successfully set. */ function __initializeMellowSymbioticVaultStorage( address _symbioticCollateral, address _symbioticVault, address _withdrawalQueue ) internal onlyInitializing { _setSymbioticCollateral(IDefaultCollateral(_symbioticCollateral)); _setSymbioticVault(ISymbioticVault(_symbioticVault)); _setWithdrawalQueue(IWithdrawalQueue(_withdrawalQueue)); } /// @inheritdoc IMellowSymbioticVaultStorage function symbioticVault() public view returns (ISymbioticVault) { return _symbioticStorage().symbioticVault; } /// @inheritdoc IMellowSymbioticVaultStorage function symbioticCollateral() public view returns (IDefaultCollateral) { return _symbioticStorage().symbioticCollateral; } /// @inheritdoc IMellowSymbioticVaultStorage function withdrawalQueue() public view returns (IWithdrawalQueue) { return _symbioticStorage().withdrawalQueue; } /// @inheritdoc IMellowSymbioticVaultStorage function symbioticFarmIds() public view returns (uint256[] memory) { return _symbioticStorage().farmIds.values(); } /// @inheritdoc IMellowSymbioticVaultStorage function symbioticFarmCount() public view returns (uint256) { return _symbioticStorage().farmIds.length(); } /// @inheritdoc IMellowSymbioticVaultStorage function symbioticFarmIdAt(uint256 index) public view returns (uint256) { return _symbioticStorage().farmIds.at(index); } /// @inheritdoc IMellowSymbioticVaultStorage function symbioticFarmsContains(uint256 farmId) public view returns (bool) { return _symbioticStorage().farmIds.contains(farmId); } /// @inheritdoc IMellowSymbioticVaultStorage function symbioticFarm(uint256 farmId) public view returns (FarmData memory) { return _symbioticStorage().farms[farmId]; } /** * @notice Sets a new Symbiotic Collateral address in the vault's storage. * @param _symbioticCollateral The address of the new Symbiotic DefaultCollateral to be set. * * @custom:effects * - Updates the Symbiotic Collateral address in the storage. * - Emits the `SymbioticCollateralSet` event with the new Symbiotic DefaultCollateral address and the current timestamp. */ function _setSymbioticCollateral(IDefaultCollateral _symbioticCollateral) internal { SymbioticStorage storage s = _symbioticStorage(); s.symbioticCollateral = _symbioticCollateral; emit SymbioticCollateralSet(address(_symbioticCollateral), block.timestamp); } /** * @notice Sets a new Symbiotic Vault address in the vault's storage. * @param _symbioticVault The address of the new Symbiotic Vault to be set. * * @custom:effects * - Updates the Symbiotic Vault address in the storage. * - Emits the `SymbioticVaultSet` event with the new Symbiotic Vault address and the current timestamp. */ function _setSymbioticVault(ISymbioticVault _symbioticVault) internal { SymbioticStorage storage s = _symbioticStorage(); s.symbioticVault = _symbioticVault; emit SymbioticVaultSet(address(_symbioticVault), block.timestamp); } /** * @notice Sets a new Withdrawal Queue address in the vault's storage. * @param _withdrawalQueue The address of the new Withdrawal Queue to be set. * * @custom:effects * - Updates the Withdrawal Queue address in storage. * - Emits the `WithdrawalQueueSet` event with the new Withdrawal Queue address and the current timestamp. */ function _setWithdrawalQueue(IWithdrawalQueue _withdrawalQueue) internal { SymbioticStorage storage s = _symbioticStorage(); s.withdrawalQueue = _withdrawalQueue; emit WithdrawalQueueSet(address(_withdrawalQueue), block.timestamp); } /** * @notice Sets a new Farm with the provided `farmId` and `farmData` in the vault's storage. * @param farmId The ID of the farm to be added or updated. * @param farmData The data structure containing details of the new or updated farm. * * @custom:effects * - Updates the storage with the provided `farmData` for the given `farmId`. * - Adds the `farmId` to the list of active farm IDs if the farm has a valid reward token address. * - Removes the `farmId` from the list of active farm IDs if the reward token address is zero. * - Emits the `FarmSet` event with the `farmId`, `farmData`, and the current timestamp. */ function _setFarm(uint256 farmId, FarmData memory farmData) internal { SymbioticStorage storage s = _symbioticStorage(); s.farms[farmId] = farmData; if (farmData.rewardToken != address(0)) { s.farmIds.add(farmId); } else { s.farmIds.remove(farmId); } emit FarmSet(farmId, farmData, block.timestamp); } /** * @notice Accesses the Symbiotic Vault storage slot. * @return $ A reference to the SymbioticStorage struct stored in the specified slot. * * @dev This function uses inline assembly to access a predefined storage slot. */ function _symbioticStorage() private view returns (SymbioticStorage storage $) { bytes32 slot = storageSlotRef; assembly { $.slot := slot } } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.25; import {VaultControlStorage} from "./VaultControlStorage.sol"; import "./interfaces/vaults/IVaultControl.sol"; abstract contract VaultControl is IVaultControl, VaultControlStorage, ReentrancyGuardUpgradeable, AccessControlEnumerableUpgradeable { bytes32 private constant SET_LIMIT_ROLE = keccak256("SET_LIMIT_ROLE"); bytes32 private constant PAUSE_WITHDRAWALS_ROLE = keccak256("PAUSE_WITHDRAWALS_ROLE"); bytes32 private constant UNPAUSE_WITHDRAWALS_ROLE = keccak256("UNPAUSE_WITHDRAWALS_ROLE"); bytes32 private constant PAUSE_DEPOSITS_ROLE = keccak256("PAUSE_DEPOSITS_ROLE"); bytes32 private constant UNPAUSE_DEPOSITS_ROLE = keccak256("UNPAUSE_DEPOSITS_ROLE"); bytes32 private constant SET_DEPOSIT_WHITELIST_ROLE = keccak256("SET_DEPOSIT_WHITELIST_ROLE"); bytes32 private constant SET_DEPOSITOR_WHITELIST_STATUS_ROLE = keccak256("SET_DEPOSITOR_WHITELIST_STATUS_ROLE"); /** * @notice Initializes the vault control settings, including roles, limits, and pause states. * @param _admin The address of the admin who will be granted the `DEFAULT_ADMIN_ROLE`. * @param _limit The initial limit on deposits for the vault. * @param _depositPause A boolean indicating whether deposits should be paused initially. * @param _withdrawalPause A boolean indicating whether withdrawals should be paused initially. * @param _depositWhitelist A boolean indicating whether a deposit whitelist should be enabled initially. * * @dev This function performs the following steps: * - Initializes the reentrancy guard to prevent reentrancy attacks. * - Initializes the access control system, setting up roles and permissions. * - Grants the `DEFAULT_ADMIN_ROLE` to the specified `_admin` address. * - Initializes the vault control storage with the specified limits, pause states, and whitelist configuration. * - This function is intended to be called during the initialization phase and is protected by the `onlyInitializing` modifier. */ function __initializeVaultControl( address _admin, uint256 _limit, bool _depositPause, bool _withdrawalPause, bool _depositWhitelist ) internal onlyInitializing { __ReentrancyGuard_init(); __AccessControlEnumerable_init(); _grantRole(DEFAULT_ADMIN_ROLE, _admin); __initializeVaultControlStorage(_limit, _depositPause, _withdrawalPause, _depositWhitelist); } /// @inheritdoc IVaultControl function setLimit(uint256 _limit) external onlyRole(SET_LIMIT_ROLE) { _setLimit(_limit); } /// @inheritdoc IVaultControl function pauseWithdrawals() external onlyRole(PAUSE_WITHDRAWALS_ROLE) { _setWithdrawalPause(true); _revokeRole(PAUSE_WITHDRAWALS_ROLE, _msgSender()); } /// @inheritdoc IVaultControl function unpauseWithdrawals() external onlyRole(UNPAUSE_WITHDRAWALS_ROLE) { _setWithdrawalPause(false); } /// @inheritdoc IVaultControl function pauseDeposits() external onlyRole(PAUSE_DEPOSITS_ROLE) { _setDepositPause(true); _revokeRole(PAUSE_DEPOSITS_ROLE, _msgSender()); } /// @inheritdoc IVaultControl function unpauseDeposits() external onlyRole(UNPAUSE_DEPOSITS_ROLE) { _setDepositPause(false); } /// @inheritdoc IVaultControl function setDepositWhitelist(bool status) external onlyRole(SET_DEPOSIT_WHITELIST_ROLE) { _setDepositWhitelist(status); } /// @inheritdoc IVaultControl function setDepositorWhitelistStatus(address account, bool status) external onlyRole(SET_DEPOSITOR_WHITELIST_STATUS_ROLE) { _setDepositorWhitelistStatus(account, status); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the 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.0.0) (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol) pragma solidity ^0.8.20; /** * @dev Standard ERC20 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens. */ interface IERC20Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC20InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC20InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers. * @param spender Address that may be allowed to operate on tokens without being their owner. * @param allowance Amount of tokens a `spender` is allowed to operate with. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC20InvalidApprover(address approver); /** * @dev Indicates a failure with the `spender` to be approved. Used in approvals. * @param spender Address that may be allowed to operate on tokens without being their owner. */ error ERC20InvalidSpender(address spender); } /** * @dev Standard ERC721 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens. */ interface IERC721Errors { /** * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20. * Used in balance queries. * @param owner Address of the current owner of a token. */ error ERC721InvalidOwner(address owner); /** * @dev Indicates a `tokenId` whose `owner` is the zero address. * @param tokenId Identifier number of a token. */ error ERC721NonexistentToken(uint256 tokenId); /** * @dev Indicates an error related to the ownership over a particular token. Used in transfers. * @param sender Address whose tokens are being transferred. * @param tokenId Identifier number of a token. * @param owner Address of the current owner of a token. */ error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC721InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC721InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param tokenId Identifier number of a token. */ error ERC721InsufficientApproval(address operator, uint256 tokenId); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC721InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC721InvalidOperator(address operator); } /** * @dev Standard ERC1155 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens. */ interface IERC1155Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. * @param tokenId Identifier number of a token. */ error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC1155InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC1155InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param owner Address of the current owner of a token. */ error ERC1155MissingApprovalForAll(address operator, address owner); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC1155InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC1155InvalidOperator(address operator); /** * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation. * Used in batch transfers. * @param idsLength Length of the array of token identifiers * @param valuesLength Length of the array of token amounts */ error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.20; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ```solidity * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Storage of the initializable contract. * * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions * when using with upgradeable contracts. * * @custom:storage-location erc7201:openzeppelin.storage.Initializable */ struct InitializableStorage { /** * @dev Indicates that the contract has been initialized. */ uint64 _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool _initializing; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00; /** * @dev The contract is already initialized. */ error InvalidInitialization(); /** * @dev The contract is not initializing. */ error NotInitializing(); /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint64 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in * production. * * Emits an {Initialized} event. */ modifier initializer() { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); // Cache values to avoid duplicated sloads bool isTopLevelCall = !$._initializing; uint64 initialized = $._initialized; // Allowed calls: // - initialSetup: the contract is not in the initializing state and no previous version was // initialized // - construction: the contract is initialized at version 1 (no reininitialization) and the // current contract is just being deployed bool initialSetup = initialized == 0 && isTopLevelCall; bool construction = initialized == 1 && address(this).code.length == 0; if (!initialSetup && !construction) { revert InvalidInitialization(); } $._initialized = 1; if (isTopLevelCall) { $._initializing = true; } _; if (isTopLevelCall) { $._initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint64 version) { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing || $._initialized >= version) { revert InvalidInitialization(); } $._initialized = version; $._initializing = true; _; $._initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { _checkInitializing(); _; } /** * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}. */ function _checkInitializing() internal view virtual { if (!_isInitializing()) { revert NotInitializing(); } } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing) { revert InvalidInitialization(); } if ($._initialized != type(uint64).max) { $._initialized = type(uint64).max; emit Initialized(type(uint64).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint64) { return _getInitializableStorage()._initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _getInitializableStorage()._initializing; } /** * @dev Returns a pointer to the storage namespace. */ // solhint-disable-next-line var-name-mixedcase function _getInitializableStorage() private pure returns (InitializableStorage storage $) { assembly { $.slot := INITIALIZABLE_STORAGE } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; import {IERC20Permit} from "../extensions/IERC20Permit.sol"; import {Address} from "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 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 { using Address for address; /** * @dev An operation with an ERC20 token failed. */ error SafeERC20FailedOperation(address token); /** * @dev Indicates a failed `decreaseAllowance` request. */ error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease); /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value))); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value))); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ 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. */ 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. */ 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 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). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data); if (returndata.length != 0 && !abi.decode(returndata, (bool))) { 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 silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC4626.sol) pragma solidity ^0.8.20; import {IERC20} from "../token/ERC20/IERC20.sol"; import {IERC20Metadata} from "../token/ERC20/extensions/IERC20Metadata.sol"; /** * @dev Interface of the ERC4626 "Tokenized Vault Standard", as defined in * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626]. */ interface IERC4626 is IERC20, IERC20Metadata { event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares); event Withdraw( address indexed sender, address indexed receiver, address indexed owner, uint256 assets, uint256 shares ); /** * @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing. * * - MUST be an ERC-20 token contract. * - MUST NOT revert. */ function asset() external view returns (address assetTokenAddress); /** * @dev Returns the total amount of the underlying asset that is “managed” by Vault. * * - SHOULD include any compounding that occurs from yield. * - MUST be inclusive of any fees that are charged against assets in the Vault. * - MUST NOT revert. */ function totalAssets() external view returns (uint256 totalManagedAssets); /** * @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal * scenario where all the conditions are met. * * - MUST NOT be inclusive of any fees that are charged against assets in the Vault. * - MUST NOT show any variations depending on the caller. * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange. * - MUST NOT revert. * * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and * from. */ function convertToShares(uint256 assets) external view returns (uint256 shares); /** * @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal * scenario where all the conditions are met. * * - MUST NOT be inclusive of any fees that are charged against assets in the Vault. * - MUST NOT show any variations depending on the caller. * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange. * - MUST NOT revert. * * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and * from. */ function convertToAssets(uint256 shares) external view returns (uint256 assets); /** * @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver, * through a deposit call. * * - MUST return a limited value if receiver is subject to some deposit limit. * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited. * - MUST NOT revert. */ function maxDeposit(address receiver) external view returns (uint256 maxAssets); /** * @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given * current on-chain conditions. * * - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit * call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called * in the same transaction. * - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the * deposit would be accepted, regardless if the user has enough tokens approved, etc. * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees. * - MUST NOT revert. * * NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in * share price or some other type of condition, meaning the depositor will lose assets by depositing. */ function previewDeposit(uint256 assets) external view returns (uint256 shares); /** * @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens. * * - MUST emit the Deposit event. * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the * deposit execution, and are accounted for during deposit. * - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not * approving enough underlying tokens to the Vault contract, etc). * * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token. */ function deposit(uint256 assets, address receiver) external returns (uint256 shares); /** * @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call. * - MUST return a limited value if receiver is subject to some mint limit. * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted. * - MUST NOT revert. */ function maxMint(address receiver) external view returns (uint256 maxShares); /** * @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given * current on-chain conditions. * * - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call * in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the * same transaction. * - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint * would be accepted, regardless if the user has enough tokens approved, etc. * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees. * - MUST NOT revert. * * NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in * share price or some other type of condition, meaning the depositor will lose assets by minting. */ function previewMint(uint256 shares) external view returns (uint256 assets); /** * @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens. * * - MUST emit the Deposit event. * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint * execution, and are accounted for during mint. * - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not * approving enough underlying tokens to the Vault contract, etc). * * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token. */ function mint(uint256 shares, address receiver) external returns (uint256 assets); /** * @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the * Vault, through a withdraw call. * * - MUST return a limited value if owner is subject to some withdrawal limit or timelock. * - MUST NOT revert. */ function maxWithdraw(address owner) external view returns (uint256 maxAssets); /** * @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block, * given current on-chain conditions. * * - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw * call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if * called * in the same transaction. * - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though * the withdrawal would be accepted, regardless if the user has enough shares, etc. * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees. * - MUST NOT revert. * * NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in * share price or some other type of condition, meaning the depositor will lose assets by depositing. */ function previewWithdraw(uint256 assets) external view returns (uint256 shares); /** * @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver. * * - MUST emit the Withdraw event. * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the * withdraw execution, and are accounted for during withdraw. * - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner * not having enough shares, etc). * * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed. * Those methods should be performed separately. */ function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares); /** * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault, * through a redeem call. * * - MUST return a limited value if owner is subject to some withdrawal limit or timelock. * - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock. * - MUST NOT revert. */ function maxRedeem(address owner) external view returns (uint256 maxShares); /** * @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block, * given current on-chain conditions. * * - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call * in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the * same transaction. * - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the * redemption would be accepted, regardless if the user has enough shares, etc. * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees. * - MUST NOT revert. * * NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in * share price or some other type of condition, meaning the depositor will lose assets by redeeming. */ function previewRedeem(uint256 shares) external view returns (uint256 assets); /** * @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver. * * - MUST emit the Withdraw event. * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the * redeem execution, and are accounted for during redeem. * - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner * not having enough shares, etc). * * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed. * Those methods should be performed separately. */ function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol) pragma solidity ^0.8.20; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Muldiv operation overflow. */ error MathOverflowedMulDiv(); enum Rounding { Floor, // Toward negative infinity Ceil, // Toward positive infinity Trunc, // Toward zero Expand // Away from zero } /** * @dev Returns the addition of two unsigned integers, with an overflow flag. */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return 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. return a / b; } // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or * denominator == 0. * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by * Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0 = x * y; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. if (denominator <= prod1) { revert MathOverflowedMulDiv(); } /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. // Always >= 1. See https://cs.stackexchange.com/q/138556/92363. uint256 twos = denominator & (0 - denominator); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. 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^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // 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^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice 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) { uint256 result = mulDiv(x, y, denominator); if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded * towards zero. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice 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 + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0); } } /** * @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 + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256 of a positive value rounded towards zero. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0); } } /** * @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.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; } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.25; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IDefaultCollateral is IERC20 { /** * @notice Emitted when debt is issued. * @param issuer address of the debt's issuer * @param recipient address that should receive the underlying asset * @param debtIssued amount of the debt issued */ event IssueDebt(address indexed issuer, address indexed recipient, uint256 debtIssued); /** * @notice Emitted when debt is repaid. * @param issuer address of the debt's issuer * @param recipient address that received the underlying asset * @param debtRepaid amount of the debt repaid */ event RepayDebt(address indexed issuer, address indexed recipient, uint256 debtRepaid); /** * @notice Get the collateral's underlying asset. * @return asset address of the underlying asset */ function asset() external view returns (address); /** * @notice Get a total amount of repaid debt. * @return total repaid debt */ function totalRepaidDebt() external view returns (uint256); /** * @notice Get an amount of repaid debt created by a particular issuer. * @param issuer address of the debt's issuer * @return particular issuer's repaid debt */ function issuerRepaidDebt(address issuer) external view returns (uint256); /** * @notice Get an amount of repaid debt to a particular recipient. * @param recipient address that received the underlying asset * @return particular recipient's repaid debt */ function recipientRepaidDebt(address recipient) external view returns (uint256); /** * @notice Get an amount of repaid debt for a particular issuer-recipient pair. * @param issuer address of the debt's issuer * @param recipient address that received the underlying asset * @return particular pair's repaid debt */ function repaidDebt(address issuer, address recipient) external view returns (uint256); /** * @notice Get a total amount of debt. * @return total debt */ function totalDebt() external view returns (uint256); /** * @notice Get a current debt created by a particular issuer. * @param issuer address of the debt's issuer * @return particular issuer's debt */ function issuerDebt(address issuer) external view returns (uint256); /** * @notice Get a current debt to a particular recipient. * @param recipient address that should receive the underlying asset * @return particular recipient's debt */ function recipientDebt(address recipient) external view returns (uint256); /** * @notice Get a current debt for a particular issuer-recipient pair. * @param issuer address of the debt's issuer * @param recipient address that should receive the underlying asset * @return particular pair's debt */ function debt(address issuer, address recipient) external view returns (uint256); /** * @notice Burn a given amount of the collateral, and increase a debt of the underlying asset for the caller. * @param recipient address that should receive the underlying asset * @param amount amount of the collateral */ function issueDebt(address recipient, uint256 amount) external; error NotLimitIncreaser(); error InsufficientDeposit(); error ExceedsLimit(); error InsufficientWithdraw(); error InsufficientIssueDebt(); /** * @notice Emmited when deposit happens. * @param depositor address of the depositor * @param recipient address of the collateral's recipient * @param amount amount of the collateral minted */ event Deposit(address indexed depositor, address indexed recipient, uint256 amount); /** * @notice Emmited when withdrawal happens. * @param withdrawer address of the withdrawer * @param recipient address of the underlying asset's recipient * @param amount amount of the collateral burned */ event Withdraw(address indexed withdrawer, address indexed recipient, uint256 amount); /** * @notice Emmited when limit is increased. * @param amount amount to increase the limit by */ event IncreaseLimit(uint256 amount); /** * @notice Emmited when new limit increaser is set. * @param limitIncreaser address of the new limit increaser */ event SetLimitIncreaser(address indexed limitIncreaser); /** * @notice Get a maximum possible collateral total supply. * @return maximum collateral total supply */ function limit() external view returns (uint256); /** * @notice Get an address of the limit increaser. * @return address of the limit increaser */ function limitIncreaser() external view returns (address); /** * @notice Deposit a given amount of the underlying asset, and mint the collateral to a particular recipient. * @param recipient address of the collateral's recipient * @param amount amount of the underlying asset * @return amount of the collateral minted */ function deposit(address recipient, uint256 amount) external returns (uint256); /** * @notice Deposit a given amount of the underlying asset using a permit functionality, and mint the collateral to a particular recipient. * @param recipient address of the collateral's recipient * @param amount amount of the underlying asset * @param deadline timestamp of the signature's deadline * @param v v component of the signature * @param r r component of the signature * @param s s component of the signature * @return amount of the collateral minted */ function deposit( address recipient, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external returns (uint256); /** * @notice Withdraw a given amount of the underlying asset, and transfer it to a particular recipient. * @param recipient address of the underlying asset's recipient * @param amount amount of the underlying asset */ function withdraw(address recipient, uint256 amount) external; /** * @notice Increase a limit of maximum collateral total supply. * @param amount amount to increase the limit by * @dev Called only by limitIncreaser. */ function increaseLimit(uint256 amount) external; /** * @notice Set a new limit increaser. * @param limitIncreaser address of the new limit increaser * @dev Called only by limitIncreaser. */ function setLimitIncreaser(address limitIncreaser) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.25; /** * @title IWithdrawalQueue * @notice Interface to handle the withdrawal process from the underlying vault. * @dev Provides functions to manage withdrawals, claimable assets, and interactions with vault epochs. */ interface IWithdrawalQueue { /** * @notice Returns the total amount of claimable collateral by the queue. * @return assets The total claimable collateral amount. */ function pendingAssets() external view returns (uint256); /** * @notice Returns the total collateral amount (both claimable and pending) for a specific account. * @param account The address of the account. * @return balance The total collateral balance for the account. */ function balanceOf(address account) external view returns (uint256); /** * @notice Returns the pending collateral amount for a specific account. * @param account The address of the account. * @return pendingAssets The total amount of pending collateral for the account. */ function pendingAssetsOf(address account) external view returns (uint256); /** * @notice Returns the claimable collateral amount for a specific account. * @param account The address of the account. * @return claimableAssets The total amount of claimable collateral for the account. */ function claimableAssetsOf(address account) external view returns (uint256); /** * @notice Requests the withdrawal of a specified amount of collateral for a given account. * @param account The address of the account requesting the withdrawal. * @param amount The amount of collateral to withdraw. * * @custom:requirements * - `msg.sender` MUST be the vault. * - `amount` MUST be greater than zero. * * @custom:effects * - Emits a `WithdrawalRequested` event. */ function request(address account, uint256 amount) external; /** * @notice Claims collateral from the External Vault for a specified epoch. * @param epoch The epoch number from which to claim collateral. * * @custom:requirements * - The epoch MUST be claimable. * - There MUST be claimable withdrawals for the given epoch. * * @custom:effects * - Emits an `EpochClaimed` event. */ function pull(uint256 epoch) external; /** * @notice Finalizes the collateral claim process for a specific account and transfers it to the recipient. * @dev Transfers the lesser of the claimable amount or the specified maximum amount to the recipient. * @param account The address of the account to claim collateral from. * @param recipient The address of the recipient receiving the collateral. * @param maxAmount The maximum amount of collateral to be claimed. * @return amount The actual amount of collateral claimed and transferred. * * @custom:requirements * - `msg.sender` MUST be the vault or the account itself. * - The claimable amount MUST be greater than zero. * - There MUST be claimable withdrawals for the given account. * * @custom:effects * - Emits a `Claimed` event. */ function claim(address account, address recipient, uint256 maxAmount) external returns (uint256 amount); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.25; import { ERC4626Upgradeable, IERC4626 } from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC4626Upgradeable.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /** * @title IERC4626Vault * @notice Extension of the IERC4626 interface that introduces a `deposit` method with an additional referral address parameter. * @dev This interface enhances the standard ERC4626 vault by adding referral-based deposits. * @dev Also extends the VaultControl interface for managing deposit limits, deposit pause and withdrawal pause. */ interface IERC4626Vault is IERC4626 { /** * @notice Emitted when a deposit is made through a referral. * @param assets The amount of underlying tokens deposited. * @param receiver The address receiving the vault shares. * @param referral The address of the referral involved in the deposit. */ event ReferralDeposit(uint256 assets, address receiver, address referral); /** * @notice Mints vault shares to the `receiver` by depositing a specified amount of `assets` with an associated `referral`. * @param assets The amount of underlying tokens to be deposited. * @param receiver The address that will receive the vault shares. * @param referral The address of the referral associated with the deposit. * @return shares The amount of vault shares minted to the `receiver`. * * @custom:requirements * - The `assets` to be deposited MUST be greater than 0. * * @custom:effects * - Transfers the underlying tokens (`assets`) from the sender to the vault. * - Mints the corresponding `shares` to the `receiver`. * - Deposits the `assets` into the underlying bond. * - Emits a `ReferralDeposit` event. */ function deposit(uint256 assets, address receiver, address referral) external returns (uint256 shares); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.25; import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import {IDefaultCollateral} from "../tokens/IDefaultCollateral.sol"; import {IWithdrawalQueue} from "../utils/IWithdrawalQueue.sol"; import {IVault as ISymbioticVault} from "@symbiotic/core/interfaces/vault/IVault.sol"; import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; /** * @title IMellowSymbioticVaultStorage * @notice Interface for interacting with the storage of the Mellow Symbiotic Vault. * @dev This interface defines methods to manage farms and related vaults. */ interface IMellowSymbioticVaultStorage { /** * @notice Struct to store data related to a specific farm. * @param rewardToken The address of the reward token distributed by the farm. * @param symbioticFarm The address of the symbiotic farm contract. * @param distributionFarm The address of the distribution farm contract. * @param curatorTreasury The address of the curator's treasury receiving fees. * @param curatorFeeD6 The curator's fee, represented with 6 decimal places. */ struct FarmData { address rewardToken; address symbioticFarm; address distributionFarm; address curatorTreasury; uint256 curatorFeeD6; } /** * @notice Struct to manage storage related to the symbiotic vault, withdrawal queue and farms. * @param symbioticVault The address of the associated symbiotic vault. * @param withdrawalQueue The withdrawal queue associated with the vault. * @param farmIds The set of farm IDs associated to this vault. * @param farms Mapping of farm IDs to their respective `FarmData`. */ struct SymbioticStorage { ISymbioticVault symbioticVault; IDefaultCollateral symbioticCollateral; IWithdrawalQueue withdrawalQueue; EnumerableSet.UintSet farmIds; mapping(uint256 => FarmData) farms; } /** * @notice Returns the address of the associated Symbiotic DefaultCollateral. * @return vault The address of the Symbiotic DefaultCollateral. */ function symbioticCollateral() external view returns (IDefaultCollateral); /** * @notice Returns the address of the associated Symbiotic Vault. * @return vault The address of the Symbiotic Vault. */ function symbioticVault() external view returns (ISymbioticVault); /** * @notice Returns the address of the associated withdrawal queue. * @return queue The address of the withdrawal queue. */ function withdrawalQueue() external view returns (IWithdrawalQueue); /** * @notice Returns an array of farm IDs associated to the Symbiotic Vault. * @return farmIds An array of farm IDs. */ function symbioticFarmIds() external view returns (uint256[] memory); /** * @notice Returns the number of associated farms. * @return farmCount The count of associated farms. */ function symbioticFarmCount() external view returns (uint256); /** * @notice Returns the farm ID at the given index. * @param index The index of the farm ID. * @return farmId The farm ID at the specified index. */ function symbioticFarmIdAt(uint256 index) external view returns (uint256); /** * @notice Checks if the given `farmId` exists in the set of linked farms. * @param farmId The ID of the farm. * @return exists `true` if the farm ID exists, `false` otherwise. */ function symbioticFarmsContains(uint256 farmId) external view returns (bool); /** * @notice Returns the `FarmData` associated with the given `farmId`. * @param farmId The ID of the farm. * @return data The `FarmData` struct for the specified farm. */ function symbioticFarm(uint256 farmId) external view returns (FarmData memory); /** * @notice Emitted when a new symbiotic collateral is set. * @param symbioticCollateral The address of the new symbiotic collateral. * @param timestamp The time at which the symbiotic collateral was set. */ event SymbioticCollateralSet(address symbioticCollateral, uint256 timestamp); /** * @notice Emitted when a new symbiotic vault is set. * @param symbioticVault The address of the new symbiotic vault. * @param timestamp The time at which the symbiotic vault was set. */ event SymbioticVaultSet(address symbioticVault, uint256 timestamp); /** * @notice Emitted when a new withdrawal queue is set. * @param withdrawalQueue The address of the new withdrawal queue. * @param timestamp The time at which the withdrawal queue was set. */ event WithdrawalQueueSet(address withdrawalQueue, uint256 timestamp); /** * @notice Emitted when a new farm is set. * @param farmId The ID of the farm. * @param farmData The `FarmData` struct containing details of the farm. * @param timestamp The time at which the farm was set. */ event FarmSet(uint256 farmId, FarmData farmData, uint256 timestamp); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/manager/AccessManager.sol) pragma solidity ^0.8.20; import {IAccessManager} from "@openzeppelin/contracts/access/manager/IAccessManager.sol"; import {IAccessManaged} from "@openzeppelin/contracts/access/manager/IAccessManaged.sol"; import {Address} from "@openzeppelin/contracts/utils/Address.sol"; import {ContextUpgradeable} from "../../utils/ContextUpgradeable.sol"; import {MulticallUpgradeable} from "../../utils/MulticallUpgradeable.sol"; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {Time} from "@openzeppelin/contracts/utils/types/Time.sol"; import {Initializable} from "../../proxy/utils/Initializable.sol"; /** * @dev AccessManager is a central contract to store the permissions of a system. * * A smart contract under the control of an AccessManager instance is known as a target, and will inherit from the * {AccessManaged} contract, be connected to this contract as its manager and implement the {AccessManaged-restricted} * modifier on a set of functions selected to be permissioned. Note that any function without this setup won't be * effectively restricted. * * The restriction rules for such functions are defined in terms of "roles" identified by an `uint64` and scoped * by target (`address`) and function selectors (`bytes4`). These roles are stored in this contract and can be * configured by admins (`ADMIN_ROLE` members) after a delay (see {getTargetAdminDelay}). * * For each target contract, admins can configure the following without any delay: * * * The target's {AccessManaged-authority} via {updateAuthority}. * * Close or open a target via {setTargetClosed} keeping the permissions intact. * * The roles that are allowed (or disallowed) to call a given function (identified by its selector) through {setTargetFunctionRole}. * * By default every address is member of the `PUBLIC_ROLE` and every target function is restricted to the `ADMIN_ROLE` until configured otherwise. * Additionally, each role has the following configuration options restricted to this manager's admins: * * * A role's admin role via {setRoleAdmin} who can grant or revoke roles. * * A role's guardian role via {setRoleGuardian} who's allowed to cancel operations. * * A delay in which a role takes effect after being granted through {setGrantDelay}. * * A delay of any target's admin action via {setTargetAdminDelay}. * * A role label for discoverability purposes with {labelRole}. * * Any account can be added and removed into any number of these roles by using the {grantRole} and {revokeRole} functions * restricted to each role's admin (see {getRoleAdmin}). * * Since all the permissions of the managed system can be modified by the admins of this instance, it is expected that * they will be highly secured (e.g., a multisig or a well-configured DAO). * * NOTE: This contract implements a form of the {IAuthority} interface, but {canCall} has additional return data so it * doesn't inherit `IAuthority`. It is however compatible with the `IAuthority` interface since the first 32 bytes of * the return data are a boolean as expected by that interface. * * NOTE: Systems that implement other access control mechanisms (for example using {Ownable}) can be paired with an * {AccessManager} by transferring permissions (ownership in the case of {Ownable}) directly to the {AccessManager}. * Users will be able to interact with these contracts through the {execute} function, following the access rules * registered in the {AccessManager}. Keep in mind that in that context, the msg.sender seen by restricted functions * will be {AccessManager} itself. * * WARNING: When granting permissions over an {Ownable} or {AccessControl} contract to an {AccessManager}, be very * mindful of the danger associated with functions such as {{Ownable-renounceOwnership}} or * {{AccessControl-renounceRole}}. */ contract AccessManagerUpgradeable is Initializable, ContextUpgradeable, MulticallUpgradeable, IAccessManager { using Time for *; // Structure that stores the details for a target contract. struct TargetConfig { mapping(bytes4 selector => uint64 roleId) allowedRoles; Time.Delay adminDelay; bool closed; } // Structure that stores the details for a role/account pair. This structures fit into a single slot. struct Access { // Timepoint at which the user gets the permission. // If this is either 0 or in the future, then the role permission is not available. uint48 since; // Delay for execution. Only applies to restricted() / execute() calls. Time.Delay delay; } // Structure that stores the details of a role. struct Role { // Members of the role. mapping(address user => Access access) members; // Admin who can grant or revoke permissions. uint64 admin; // Guardian who can cancel operations targeting functions that need this role. uint64 guardian; // Delay in which the role takes effect after being granted. Time.Delay grantDelay; } // Structure that stores the details for a scheduled operation. This structure fits into a single slot. struct Schedule { // Moment at which the operation can be executed. uint48 timepoint; // Operation nonce to allow third-party contracts to identify the operation. uint32 nonce; } uint64 public constant ADMIN_ROLE = type(uint64).min; // 0 uint64 public constant PUBLIC_ROLE = type(uint64).max; // 2**64-1 /// @custom:storage-location erc7201:openzeppelin.storage.AccessManager struct AccessManagerStorage { mapping(address target => TargetConfig mode) _targets; mapping(uint64 roleId => Role) _roles; mapping(bytes32 operationId => Schedule) _schedules; // Used to identify operations that are currently being executed via {execute}. // This should be transient storage when supported by the EVM. bytes32 _executionId; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.AccessManager")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant AccessManagerStorageLocation = 0x40c6c8c28789853c7efd823ab20824bbd71718a8a5915e855f6f288c9a26ad00; function _getAccessManagerStorage() private pure returns (AccessManagerStorage storage $) { assembly { $.slot := AccessManagerStorageLocation } } /** * @dev Check that the caller is authorized to perform the operation, following the restrictions encoded in * {_getAdminRestrictions}. */ modifier onlyAuthorized() { _checkAuthorized(); _; } function __AccessManager_init(address initialAdmin) internal onlyInitializing { __AccessManager_init_unchained(initialAdmin); } function __AccessManager_init_unchained(address initialAdmin) internal onlyInitializing { if (initialAdmin == address(0)) { revert AccessManagerInvalidInitialAdmin(address(0)); } // admin is active immediately and without any execution delay. _grantRole(ADMIN_ROLE, initialAdmin, 0, 0); } // =================================================== GETTERS ==================================================== /// @inheritdoc IAccessManager function canCall( address caller, address target, bytes4 selector ) public view virtual returns (bool immediate, uint32 delay) { if (isTargetClosed(target)) { return (false, 0); } else if (caller == address(this)) { // Caller is AccessManager, this means the call was sent through {execute} and it already checked // permissions. We verify that the call "identifier", which is set during {execute}, is correct. return (_isExecuting(target, selector), 0); } else { uint64 roleId = getTargetFunctionRole(target, selector); (bool isMember, uint32 currentDelay) = hasRole(roleId, caller); return isMember ? (currentDelay == 0, currentDelay) : (false, 0); } } /// @inheritdoc IAccessManager function expiration() public view virtual returns (uint32) { return 1 weeks; } /// @inheritdoc IAccessManager function minSetback() public view virtual returns (uint32) { return 5 days; } /// @inheritdoc IAccessManager function isTargetClosed(address target) public view virtual returns (bool) { AccessManagerStorage storage $ = _getAccessManagerStorage(); return $._targets[target].closed; } /// @inheritdoc IAccessManager function getTargetFunctionRole(address target, bytes4 selector) public view virtual returns (uint64) { AccessManagerStorage storage $ = _getAccessManagerStorage(); return $._targets[target].allowedRoles[selector]; } /// @inheritdoc IAccessManager function getTargetAdminDelay(address target) public view virtual returns (uint32) { AccessManagerStorage storage $ = _getAccessManagerStorage(); return $._targets[target].adminDelay.get(); } /// @inheritdoc IAccessManager function getRoleAdmin(uint64 roleId) public view virtual returns (uint64) { AccessManagerStorage storage $ = _getAccessManagerStorage(); return $._roles[roleId].admin; } /// @inheritdoc IAccessManager function getRoleGuardian(uint64 roleId) public view virtual returns (uint64) { AccessManagerStorage storage $ = _getAccessManagerStorage(); return $._roles[roleId].guardian; } /// @inheritdoc IAccessManager function getRoleGrantDelay(uint64 roleId) public view virtual returns (uint32) { AccessManagerStorage storage $ = _getAccessManagerStorage(); return $._roles[roleId].grantDelay.get(); } /// @inheritdoc IAccessManager function getAccess( uint64 roleId, address account ) public view virtual returns (uint48 since, uint32 currentDelay, uint32 pendingDelay, uint48 effect) { AccessManagerStorage storage $ = _getAccessManagerStorage(); Access storage access = $._roles[roleId].members[account]; since = access.since; (currentDelay, pendingDelay, effect) = access.delay.getFull(); return (since, currentDelay, pendingDelay, effect); } /// @inheritdoc IAccessManager function hasRole( uint64 roleId, address account ) public view virtual returns (bool isMember, uint32 executionDelay) { if (roleId == PUBLIC_ROLE) { return (true, 0); } else { (uint48 hasRoleSince, uint32 currentDelay, , ) = getAccess(roleId, account); return (hasRoleSince != 0 && hasRoleSince <= Time.timestamp(), currentDelay); } } // =============================================== ROLE MANAGEMENT =============================================== /// @inheritdoc IAccessManager function labelRole(uint64 roleId, string calldata label) public virtual onlyAuthorized { if (roleId == ADMIN_ROLE || roleId == PUBLIC_ROLE) { revert AccessManagerLockedRole(roleId); } emit RoleLabel(roleId, label); } /// @inheritdoc IAccessManager function grantRole(uint64 roleId, address account, uint32 executionDelay) public virtual onlyAuthorized { _grantRole(roleId, account, getRoleGrantDelay(roleId), executionDelay); } /// @inheritdoc IAccessManager function revokeRole(uint64 roleId, address account) public virtual onlyAuthorized { _revokeRole(roleId, account); } /// @inheritdoc IAccessManager function renounceRole(uint64 roleId, address callerConfirmation) public virtual { if (callerConfirmation != _msgSender()) { revert AccessManagerBadConfirmation(); } _revokeRole(roleId, callerConfirmation); } /// @inheritdoc IAccessManager function setRoleAdmin(uint64 roleId, uint64 admin) public virtual onlyAuthorized { _setRoleAdmin(roleId, admin); } /// @inheritdoc IAccessManager function setRoleGuardian(uint64 roleId, uint64 guardian) public virtual onlyAuthorized { _setRoleGuardian(roleId, guardian); } /// @inheritdoc IAccessManager function setGrantDelay(uint64 roleId, uint32 newDelay) public virtual onlyAuthorized { _setGrantDelay(roleId, newDelay); } /** * @dev Internal version of {grantRole} without access control. Returns true if the role was newly granted. * * Emits a {RoleGranted} event. */ function _grantRole( uint64 roleId, address account, uint32 grantDelay, uint32 executionDelay ) internal virtual returns (bool) { AccessManagerStorage storage $ = _getAccessManagerStorage(); if (roleId == PUBLIC_ROLE) { revert AccessManagerLockedRole(roleId); } bool newMember = $._roles[roleId].members[account].since == 0; uint48 since; if (newMember) { since = Time.timestamp() + grantDelay; $._roles[roleId].members[account] = Access({since: since, delay: executionDelay.toDelay()}); } else { // No setback here. Value can be reset by doing revoke + grant, effectively allowing the admin to perform // any change to the execution delay within the duration of the role admin delay. ($._roles[roleId].members[account].delay, since) = $._roles[roleId].members[account].delay.withUpdate( executionDelay, 0 ); } emit RoleGranted(roleId, account, executionDelay, since, newMember); return newMember; } /** * @dev Internal version of {revokeRole} without access control. This logic is also used by {renounceRole}. * Returns true if the role was previously granted. * * Emits a {RoleRevoked} event if the account had the role. */ function _revokeRole(uint64 roleId, address account) internal virtual returns (bool) { AccessManagerStorage storage $ = _getAccessManagerStorage(); if (roleId == PUBLIC_ROLE) { revert AccessManagerLockedRole(roleId); } if ($._roles[roleId].members[account].since == 0) { return false; } delete $._roles[roleId].members[account]; emit RoleRevoked(roleId, account); return true; } /** * @dev Internal version of {setRoleAdmin} without access control. * * Emits a {RoleAdminChanged} event. * * NOTE: Setting the admin role as the `PUBLIC_ROLE` is allowed, but it will effectively allow * anyone to set grant or revoke such role. */ function _setRoleAdmin(uint64 roleId, uint64 admin) internal virtual { AccessManagerStorage storage $ = _getAccessManagerStorage(); if (roleId == ADMIN_ROLE || roleId == PUBLIC_ROLE) { revert AccessManagerLockedRole(roleId); } $._roles[roleId].admin = admin; emit RoleAdminChanged(roleId, admin); } /** * @dev Internal version of {setRoleGuardian} without access control. * * Emits a {RoleGuardianChanged} event. * * NOTE: Setting the guardian role as the `PUBLIC_ROLE` is allowed, but it will effectively allow * anyone to cancel any scheduled operation for such role. */ function _setRoleGuardian(uint64 roleId, uint64 guardian) internal virtual { AccessManagerStorage storage $ = _getAccessManagerStorage(); if (roleId == ADMIN_ROLE || roleId == PUBLIC_ROLE) { revert AccessManagerLockedRole(roleId); } $._roles[roleId].guardian = guardian; emit RoleGuardianChanged(roleId, guardian); } /** * @dev Internal version of {setGrantDelay} without access control. * * Emits a {RoleGrantDelayChanged} event. */ function _setGrantDelay(uint64 roleId, uint32 newDelay) internal virtual { AccessManagerStorage storage $ = _getAccessManagerStorage(); if (roleId == PUBLIC_ROLE) { revert AccessManagerLockedRole(roleId); } uint48 effect; ($._roles[roleId].grantDelay, effect) = $._roles[roleId].grantDelay.withUpdate(newDelay, minSetback()); emit RoleGrantDelayChanged(roleId, newDelay, effect); } // ============================================= FUNCTION MANAGEMENT ============================================== /// @inheritdoc IAccessManager function setTargetFunctionRole( address target, bytes4[] calldata selectors, uint64 roleId ) public virtual onlyAuthorized { for (uint256 i = 0; i < selectors.length; ++i) { _setTargetFunctionRole(target, selectors[i], roleId); } } /** * @dev Internal version of {setTargetFunctionRole} without access control. * * Emits a {TargetFunctionRoleUpdated} event. */ function _setTargetFunctionRole(address target, bytes4 selector, uint64 roleId) internal virtual { AccessManagerStorage storage $ = _getAccessManagerStorage(); $._targets[target].allowedRoles[selector] = roleId; emit TargetFunctionRoleUpdated(target, selector, roleId); } /// @inheritdoc IAccessManager function setTargetAdminDelay(address target, uint32 newDelay) public virtual onlyAuthorized { _setTargetAdminDelay(target, newDelay); } /** * @dev Internal version of {setTargetAdminDelay} without access control. * * Emits a {TargetAdminDelayUpdated} event. */ function _setTargetAdminDelay(address target, uint32 newDelay) internal virtual { AccessManagerStorage storage $ = _getAccessManagerStorage(); uint48 effect; ($._targets[target].adminDelay, effect) = $._targets[target].adminDelay.withUpdate(newDelay, minSetback()); emit TargetAdminDelayUpdated(target, newDelay, effect); } // =============================================== MODE MANAGEMENT ================================================ /// @inheritdoc IAccessManager function setTargetClosed(address target, bool closed) public virtual onlyAuthorized { _setTargetClosed(target, closed); } /** * @dev Set the closed flag for a contract. This is an internal setter with no access restrictions. * * Emits a {TargetClosed} event. */ function _setTargetClosed(address target, bool closed) internal virtual { AccessManagerStorage storage $ = _getAccessManagerStorage(); if (target == address(this)) { revert AccessManagerLockedAccount(target); } $._targets[target].closed = closed; emit TargetClosed(target, closed); } // ============================================== DELAYED OPERATIONS ============================================== /// @inheritdoc IAccessManager function getSchedule(bytes32 id) public view virtual returns (uint48) { AccessManagerStorage storage $ = _getAccessManagerStorage(); uint48 timepoint = $._schedules[id].timepoint; return _isExpired(timepoint) ? 0 : timepoint; } /// @inheritdoc IAccessManager function getNonce(bytes32 id) public view virtual returns (uint32) { AccessManagerStorage storage $ = _getAccessManagerStorage(); return $._schedules[id].nonce; } /// @inheritdoc IAccessManager function schedule( address target, bytes calldata data, uint48 when ) public virtual returns (bytes32 operationId, uint32 nonce) { AccessManagerStorage storage $ = _getAccessManagerStorage(); address caller = _msgSender(); // Fetch restrictions that apply to the caller on the targeted function (, uint32 setback) = _canCallExtended(caller, target, data); uint48 minWhen = Time.timestamp() + setback; // if call with delay is not authorized, or if requested timing is too soon if (setback == 0 || (when > 0 && when < minWhen)) { revert AccessManagerUnauthorizedCall(caller, target, _checkSelector(data)); } // Reuse variable due to stack too deep when = uint48(Math.max(when, minWhen)); // cast is safe: both inputs are uint48 // If caller is authorised, schedule operation operationId = hashOperation(caller, target, data); _checkNotScheduled(operationId); unchecked { // It's not feasible to overflow the nonce in less than 1000 years nonce = $._schedules[operationId].nonce + 1; } $._schedules[operationId].timepoint = when; $._schedules[operationId].nonce = nonce; emit OperationScheduled(operationId, nonce, when, caller, target, data); // Using named return values because otherwise we get stack too deep } /** * @dev Reverts if the operation is currently scheduled and has not expired. * (Note: This function was introduced due to stack too deep errors in schedule.) */ function _checkNotScheduled(bytes32 operationId) private view { AccessManagerStorage storage $ = _getAccessManagerStorage(); uint48 prevTimepoint = $._schedules[operationId].timepoint; if (prevTimepoint != 0 && !_isExpired(prevTimepoint)) { revert AccessManagerAlreadyScheduled(operationId); } } /// @inheritdoc IAccessManager // Reentrancy is not an issue because permissions are checked on msg.sender. Additionally, // _consumeScheduledOp guarantees a scheduled operation is only executed once. // slither-disable-next-line reentrancy-no-eth function execute(address target, bytes calldata data) public payable virtual returns (uint32) { AccessManagerStorage storage $ = _getAccessManagerStorage(); address caller = _msgSender(); // Fetch restrictions that apply to the caller on the targeted function (bool immediate, uint32 setback) = _canCallExtended(caller, target, data); // If caller is not authorised, revert if (!immediate && setback == 0) { revert AccessManagerUnauthorizedCall(caller, target, _checkSelector(data)); } bytes32 operationId = hashOperation(caller, target, data); uint32 nonce; // If caller is authorised, check operation was scheduled early enough // Consume an available schedule even if there is no currently enforced delay if (setback != 0 || getSchedule(operationId) != 0) { nonce = _consumeScheduledOp(operationId); } // Mark the target and selector as authorised bytes32 executionIdBefore = $._executionId; $._executionId = _hashExecutionId(target, _checkSelector(data)); // Perform call Address.functionCallWithValue(target, data, msg.value); // Reset execute identifier $._executionId = executionIdBefore; return nonce; } /// @inheritdoc IAccessManager function cancel(address caller, address target, bytes calldata data) public virtual returns (uint32) { AccessManagerStorage storage $ = _getAccessManagerStorage(); address msgsender = _msgSender(); bytes4 selector = _checkSelector(data); bytes32 operationId = hashOperation(caller, target, data); if ($._schedules[operationId].timepoint == 0) { revert AccessManagerNotScheduled(operationId); } else if (caller != msgsender) { // calls can only be canceled by the account that scheduled them, a global admin, or by a guardian of the required role. (bool isAdmin, ) = hasRole(ADMIN_ROLE, msgsender); (bool isGuardian, ) = hasRole(getRoleGuardian(getTargetFunctionRole(target, selector)), msgsender); if (!isAdmin && !isGuardian) { revert AccessManagerUnauthorizedCancel(msgsender, caller, target, selector); } } delete $._schedules[operationId].timepoint; // reset the timepoint, keep the nonce uint32 nonce = $._schedules[operationId].nonce; emit OperationCanceled(operationId, nonce); return nonce; } /// @inheritdoc IAccessManager function consumeScheduledOp(address caller, bytes calldata data) public virtual { address target = _msgSender(); if (IAccessManaged(target).isConsumingScheduledOp() != IAccessManaged.isConsumingScheduledOp.selector) { revert AccessManagerUnauthorizedConsume(target); } _consumeScheduledOp(hashOperation(caller, target, data)); } /** * @dev Internal variant of {consumeScheduledOp} that operates on bytes32 operationId. * * Returns the nonce of the scheduled operation that is consumed. */ function _consumeScheduledOp(bytes32 operationId) internal virtual returns (uint32) { AccessManagerStorage storage $ = _getAccessManagerStorage(); uint48 timepoint = $._schedules[operationId].timepoint; uint32 nonce = $._schedules[operationId].nonce; if (timepoint == 0) { revert AccessManagerNotScheduled(operationId); } else if (timepoint > Time.timestamp()) { revert AccessManagerNotReady(operationId); } else if (_isExpired(timepoint)) { revert AccessManagerExpired(operationId); } delete $._schedules[operationId].timepoint; // reset the timepoint, keep the nonce emit OperationExecuted(operationId, nonce); return nonce; } /// @inheritdoc IAccessManager function hashOperation(address caller, address target, bytes calldata data) public view virtual returns (bytes32) { return keccak256(abi.encode(caller, target, data)); } // ==================================================== OTHERS ==================================================== /// @inheritdoc IAccessManager function updateAuthority(address target, address newAuthority) public virtual onlyAuthorized { IAccessManaged(target).setAuthority(newAuthority); } // ================================================= ADMIN LOGIC ================================================== /** * @dev Check if the current call is authorized according to admin logic. */ function _checkAuthorized() private { address caller = _msgSender(); (bool immediate, uint32 delay) = _canCallSelf(caller, _msgData()); if (!immediate) { if (delay == 0) { (, uint64 requiredRole, ) = _getAdminRestrictions(_msgData()); revert AccessManagerUnauthorizedAccount(caller, requiredRole); } else { _consumeScheduledOp(hashOperation(caller, address(this), _msgData())); } } } /** * @dev Get the admin restrictions of a given function call based on the function and arguments involved. * * Returns: * - bool restricted: does this data match a restricted operation * - uint64: which role is this operation restricted to * - uint32: minimum delay to enforce for that operation (max between operation's delay and admin's execution delay) */ function _getAdminRestrictions( bytes calldata data ) private view returns (bool restricted, uint64 roleAdminId, uint32 executionDelay) { if (data.length < 4) { return (false, 0, 0); } bytes4 selector = _checkSelector(data); // Restricted to ADMIN with no delay beside any execution delay the caller may have if ( selector == this.labelRole.selector || selector == this.setRoleAdmin.selector || selector == this.setRoleGuardian.selector || selector == this.setGrantDelay.selector || selector == this.setTargetAdminDelay.selector ) { return (true, ADMIN_ROLE, 0); } // Restricted to ADMIN with the admin delay corresponding to the target if ( selector == this.updateAuthority.selector || selector == this.setTargetClosed.selector || selector == this.setTargetFunctionRole.selector ) { // First argument is a target. address target = abi.decode(data[0x04:0x24], (address)); uint32 delay = getTargetAdminDelay(target); return (true, ADMIN_ROLE, delay); } // Restricted to that role's admin with no delay beside any execution delay the caller may have. if (selector == this.grantRole.selector || selector == this.revokeRole.selector) { // First argument is a roleId. uint64 roleId = abi.decode(data[0x04:0x24], (uint64)); return (true, getRoleAdmin(roleId), 0); } return (false, 0, 0); } // =================================================== HELPERS ==================================================== /** * @dev An extended version of {canCall} for internal usage that checks {_canCallSelf} * when the target is this contract. * * Returns: * - bool immediate: whether the operation can be executed immediately (with no delay) * - uint32 delay: the execution delay */ function _canCallExtended( address caller, address target, bytes calldata data ) private view returns (bool immediate, uint32 delay) { if (target == address(this)) { return _canCallSelf(caller, data); } else { return data.length < 4 ? (false, 0) : canCall(caller, target, _checkSelector(data)); } } /** * @dev A version of {canCall} that checks for admin restrictions in this contract. */ function _canCallSelf(address caller, bytes calldata data) private view returns (bool immediate, uint32 delay) { if (data.length < 4) { return (false, 0); } if (caller == address(this)) { // Caller is AccessManager, this means the call was sent through {execute} and it already checked // permissions. We verify that the call "identifier", which is set during {execute}, is correct. return (_isExecuting(address(this), _checkSelector(data)), 0); } (bool enabled, uint64 roleId, uint32 operationDelay) = _getAdminRestrictions(data); if (!enabled) { return (false, 0); } (bool inRole, uint32 executionDelay) = hasRole(roleId, caller); if (!inRole) { return (false, 0); } // downcast is safe because both options are uint32 delay = uint32(Math.max(operationDelay, executionDelay)); return (delay == 0, delay); } /** * @dev Returns true if a call with `target` and `selector` is being executed via {executed}. */ function _isExecuting(address target, bytes4 selector) private view returns (bool) { AccessManagerStorage storage $ = _getAccessManagerStorage(); return $._executionId == _hashExecutionId(target, selector); } /** * @dev Returns true if a schedule timepoint is past its expiration deadline. */ function _isExpired(uint48 timepoint) private view returns (bool) { return timepoint + expiration() <= Time.timestamp(); } /** * @dev Extracts the selector from calldata. Panics if data is not at least 4 bytes */ function _checkSelector(bytes calldata data) private pure returns (bytes4) { return bytes4(data[0:4]); } /** * @dev Hashing function for execute protection */ function _hashExecutionId(address target, bytes4 selector) private pure returns (bytes32) { return keccak256(abi.encode(target, selector)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.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 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 pragma solidity ^0.8.0; import {IMigratableEntity} from "../common/IMigratableEntity.sol"; import {IVaultStorage} from "./IVaultStorage.sol"; interface IVault is IMigratableEntity, IVaultStorage { error AlreadyClaimed(); error AlreadySet(); error DelegatorAlreadyInitialized(); error DepositLimitReached(); error InsufficientClaim(); error InsufficientDeposit(); error InsufficientRedemption(); error InsufficientWithdrawal(); error InvalidAccount(); error InvalidCaptureEpoch(); error InvalidClaimer(); error InvalidCollateral(); error InvalidDelegator(); error InvalidEpoch(); error InvalidEpochDuration(); error InvalidLengthEpochs(); error InvalidOnBehalfOf(); error InvalidRecipient(); error InvalidSlasher(); error MissingRoles(); error NotDelegator(); error NotSlasher(); error NotWhitelistedDepositor(); error SlasherAlreadyInitialized(); error TooMuchRedeem(); error TooMuchWithdraw(); /** * @notice Initial parameters needed for a vault deployment. * @param collateral vault's underlying collateral * @param burner vault's burner to issue debt to (e.g., 0xdEaD or some unwrapper contract) * @param epochDuration duration of the vault epoch (it determines sync points for withdrawals) * @param depositWhitelist if enabling deposit whitelist * @param isDepositLimit if enabling deposit limit * @param depositLimit deposit limit (maximum amount of the collateral that can be in the vault simultaneously) * @param defaultAdminRoleHolder address of the initial DEFAULT_ADMIN_ROLE holder * @param depositWhitelistSetRoleHolder address of the initial DEPOSIT_WHITELIST_SET_ROLE holder * @param depositorWhitelistRoleHolder address of the initial DEPOSITOR_WHITELIST_ROLE holder * @param isDepositLimitSetRoleHolder address of the initial IS_DEPOSIT_LIMIT_SET_ROLE holder * @param depositLimitSetRoleHolder address of the initial DEPOSIT_LIMIT_SET_ROLE holder */ struct InitParams { address collateral; address burner; uint48 epochDuration; bool depositWhitelist; bool isDepositLimit; uint256 depositLimit; address defaultAdminRoleHolder; address depositWhitelistSetRoleHolder; address depositorWhitelistRoleHolder; address isDepositLimitSetRoleHolder; address depositLimitSetRoleHolder; } /** * @notice Hints for an active balance. * @param activeSharesOfHint hint for the active shares of checkpoint * @param activeStakeHint hint for the active stake checkpoint * @param activeSharesHint hint for the active shares checkpoint */ struct ActiveBalanceOfHints { bytes activeSharesOfHint; bytes activeStakeHint; bytes activeSharesHint; } /** * @notice Emitted when a deposit is made. * @param depositor account that made the deposit * @param onBehalfOf account the deposit was made on behalf of * @param amount amount of the collateral deposited * @param shares amount of the active shares minted */ event Deposit(address indexed depositor, address indexed onBehalfOf, uint256 amount, uint256 shares); /** * @notice Emitted when a withdrawal is made. * @param withdrawer account that made the withdrawal * @param claimer account that needs to claim the withdrawal * @param amount amount of the collateral withdrawn * @param burnedShares amount of the active shares burned * @param mintedShares amount of the epoch withdrawal shares minted */ event Withdraw( address indexed withdrawer, address indexed claimer, uint256 amount, uint256 burnedShares, uint256 mintedShares ); /** * @notice Emitted when a claim is made. * @param claimer account that claimed * @param recipient account that received the collateral * @param epoch epoch the collateral was claimed for * @param amount amount of the collateral claimed */ event Claim(address indexed claimer, address indexed recipient, uint256 epoch, uint256 amount); /** * @notice Emitted when a batch claim is made. * @param claimer account that claimed * @param recipient account that received the collateral * @param epochs epochs the collateral was claimed for * @param amount amount of the collateral claimed */ event ClaimBatch(address indexed claimer, address indexed recipient, uint256[] epochs, uint256 amount); /** * @notice Emitted when a slash happens. * @param amount amount of the collateral to slash * @param captureTimestamp time point when the stake was captured * @param slashedAmount real amount of the collateral slashed */ event OnSlash(uint256 amount, uint48 captureTimestamp, uint256 slashedAmount); /** * @notice Emitted when a deposit whitelist status is enabled/disabled. * @param status if enabled deposit whitelist */ event SetDepositWhitelist(bool status); /** * @notice Emitted when a depositor whitelist status is set. * @param account account for which the whitelist status is set * @param status if whitelisted the account */ event SetDepositorWhitelistStatus(address indexed account, bool status); /** * @notice Emitted when a deposit limit status is enabled/disabled. * @param status if enabled deposit limit */ event SetIsDepositLimit(bool status); /** * @notice Emitted when a deposit limit is set. * @param limit deposit limit (maximum amount of the collateral that can be in the vault simultaneously) */ event SetDepositLimit(uint256 limit); /** * @notice Emitted when a delegator is set. * @param delegator vault's delegator to delegate the stake to networks and operators * @dev Can be set only once. */ event SetDelegator(address indexed delegator); /** * @notice Emitted when a slasher is set. * @param slasher vault's slasher to provide a slashing mechanism to networks * @dev Can be set only once. */ event SetSlasher(address indexed slasher); /** * @notice Check if the vault is fully initialized (a delegator and a slasher are set). * @return if the vault is fully initialized */ function isInitialized() external view returns (bool); /** * @notice Get a total amount of the collateral that can be slashed. * @return total amount of the slashable collateral */ function totalStake() external view returns (uint256); /** * @notice Get an active balance for a particular account at a given timestamp using hints. * @param account account to get the active balance for * @param timestamp time point to get the active balance for the account at * @param hints hints for checkpoints' indexes * @return active balance for the account at the timestamp */ function activeBalanceOfAt( address account, uint48 timestamp, bytes calldata hints ) external view returns (uint256); /** * @notice Get an active balance for a particular account. * @param account account to get the active balance for * @return active balance for the account */ function activeBalanceOf( address account ) external view returns (uint256); /** * @notice Get withdrawals for a particular account at a given epoch (zero if claimed). * @param epoch epoch to get the withdrawals for the account at * @param account account to get the withdrawals for * @return withdrawals for the account at the epoch */ function withdrawalsOf(uint256 epoch, address account) external view returns (uint256); /** * @notice Get a total amount of the collateral that can be slashed for a given account. * @param account account to get the slashable collateral for * @return total amount of the account's slashable collateral */ function slashableBalanceOf( address account ) external view returns (uint256); /** * @notice Deposit collateral into the vault. * @param onBehalfOf account the deposit is made on behalf of * @param amount amount of the collateral to deposit * @return depositedAmount real amount of the collateral deposited * @return mintedShares amount of the active shares minted */ function deposit( address onBehalfOf, uint256 amount ) external returns (uint256 depositedAmount, uint256 mintedShares); /** * @notice Withdraw collateral from the vault (it will be claimable after the next epoch). * @param claimer account that needs to claim the withdrawal * @param amount amount of the collateral to withdraw * @return burnedShares amount of the active shares burned * @return mintedShares amount of the epoch withdrawal shares minted */ function withdraw(address claimer, uint256 amount) external returns (uint256 burnedShares, uint256 mintedShares); /** * @notice Redeem collateral from the vault (it will be claimable after the next epoch). * @param claimer account that needs to claim the withdrawal * @param shares amount of the active shares to redeem * @return withdrawnAssets amount of the collateral withdrawn * @return mintedShares amount of the epoch withdrawal shares minted */ function redeem(address claimer, uint256 shares) external returns (uint256 withdrawnAssets, uint256 mintedShares); /** * @notice Claim collateral from the vault. * @param recipient account that receives the collateral * @param epoch epoch to claim the collateral for * @return amount amount of the collateral claimed */ function claim(address recipient, uint256 epoch) external returns (uint256 amount); /** * @notice Claim collateral from the vault for multiple epochs. * @param recipient account that receives the collateral * @param epochs epochs to claim the collateral for * @return amount amount of the collateral claimed */ function claimBatch(address recipient, uint256[] calldata epochs) external returns (uint256 amount); /** * @notice Slash callback for burning collateral. * @param amount amount to slash * @param captureTimestamp time point when the stake was captured * @return slashedAmount real amount of the collateral slashed * @dev Only the slasher can call this function. */ function onSlash(uint256 amount, uint48 captureTimestamp) external returns (uint256 slashedAmount); /** * @notice Enable/disable deposit whitelist. * @param status if enabling deposit whitelist * @dev Only a DEPOSIT_WHITELIST_SET_ROLE holder can call this function. */ function setDepositWhitelist( bool status ) external; /** * @notice Set a depositor whitelist status. * @param account account for which the whitelist status is set * @param status if whitelisting the account * @dev Only a DEPOSITOR_WHITELIST_ROLE holder can call this function. */ function setDepositorWhitelistStatus(address account, bool status) external; /** * @notice Enable/disable deposit limit. * @param status if enabling deposit limit * @dev Only a IS_DEPOSIT_LIMIT_SET_ROLE holder can call this function. */ function setIsDepositLimit( bool status ) external; /** * @notice Set a deposit limit. * @param limit deposit limit (maximum amount of the collateral that can be in the vault simultaneously) * @dev Only a DEPOSIT_LIMIT_SET_ROLE holder can call this function. */ function setDepositLimit( uint256 limit ) external; /** * @notice Set a delegator. * @param delegator vault's delegator to delegate the stake to networks and operators * @dev Can be set only once. */ function setDelegator( address delegator ) external; /** * @notice Set a slasher. * @param slasher vault's slasher to provide a slashing mechanism to networks * @dev Can be set only once. */ function setSlasher( address slasher ) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IStakerRewards { /** * @notice Emitted when a reward is distributed. * @param network network on behalf of which the reward is distributed * @param token address of the token * @param amount amount of tokens * @param data some used data */ event DistributeRewards(address indexed network, address indexed token, uint256 amount, bytes data); /** * @notice Get a version of the staker rewards contract (different versions mean different interfaces). * @return version of the staker rewards contract * @dev Must return 1 for this one. */ function version() external view returns (uint64); /** * @notice Get an amount of rewards claimable by a particular account of a given token. * @param token address of the token * @param account address of the claimer * @param data some data to use * @return amount of claimable tokens */ function claimable(address token, address account, bytes calldata data) external view returns (uint256); /** * @notice Distribute rewards on behalf of a particular network using a given token. * @param network network on behalf of which the reward to distribute * @param token address of the token * @param amount amount of tokens * @param data some data to use */ function distributeRewards(address network, address token, uint256 amount, bytes calldata data) external; /** * @notice Claim rewards using a given token. * @param recipient address of the tokens' recipient * @param token address of the token * @param data some data to use */ function claimRewards(address recipient, address token, bytes calldata data) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.25; import "./interfaces/vaults/IVaultControlStorage.sol"; abstract contract VaultControlStorage is IVaultControlStorage, Initializable, ContextUpgradeable { bytes32 private immutable storageSlotRef; constructor(bytes32 name_, uint256 version_) { storageSlotRef = keccak256( abi.encode( uint256( keccak256( abi.encodePacked( "mellow.simple-lrt.storage.VaultControlStorage", name_, version_ ) ) ) - 1 ) ) & ~bytes32(uint256(0xff)); } /** * @notice Initializes the Vault storage with the provided settings for limit, pause states, and whitelist. * @param _limit The initial value for the Vault's deposit limit. * @param _depositPause The initial state for the `depositPause` flag. * @param _withdrawalPause The initial state for the `withdrawalPause` flag. * @param _depositWhitelist The initial state for the `depositWhitelist` flag. * * @custom:requirements * - This function MUST not be called more than once; it is intended for one-time initialization. * * @custom:effects * - Sets the provided limit, pause states, and whitelist state in the Vault's storage. * - Emits the `LimitSet` event after the limit is set. * - Emits the `DepositPauseSet` event after the deposit pause state is set. * - Emits the `WithdrawalPauseSet` event after the withdrawal pause state is set. * - Emits the `DepositWhitelistSet` event after the deposit whitelist state is set. * * @dev This function is protected by the `onlyInitializing` modifier to ensure it is only called during the contract's initialization phase. */ function __initializeVaultControlStorage( uint256 _limit, bool _depositPause, bool _withdrawalPause, bool _depositWhitelist ) internal onlyInitializing { _setLimit(_limit); _setDepositPause(_depositPause); _setWithdrawalPause(_withdrawalPause); _setDepositWhitelist(_depositWhitelist); } /// @inheritdoc IVaultControlStorage function depositPause() public view returns (bool) { return _vaultStorage().depositPause; } /// @inheritdoc IVaultControlStorage function withdrawalPause() public view returns (bool) { return _vaultStorage().withdrawalPause; } /// @inheritdoc IVaultControlStorage function limit() public view returns (uint256) { return _vaultStorage().limit; } /// @inheritdoc IVaultControlStorage function depositWhitelist() public view returns (bool) { return _vaultStorage().depositWhitelist; } /// @inheritdoc IVaultControlStorage function isDepositorWhitelisted(address account) public view returns (bool) { return _vaultStorage().isDepositorWhitelisted[account]; } /** * @notice Sets a new `limit` for the Vault. * @param _limit The new limit for the Vault. * * @custom:effects * - Updates the Vault's `limit` in storage. * - Emits the `LimitSet` event with the new limit, current timestamp, and the caller's address. */ function _setLimit(uint256 _limit) internal { Storage storage s = _vaultStorage(); s.limit = _limit; emit LimitSet(_limit, block.timestamp, _msgSender()); } /** * @notice Sets a new `depositPause` state for the Vault. * @param _paused The new value for the `depositPause` state. * * @custom:effects * - Updates the Vault's `depositPause` state in storage. * - Emits the `DepositPauseSet` event with the new pause state, current timestamp, and the caller's address. */ function _setDepositPause(bool _paused) internal { Storage storage s = _vaultStorage(); s.depositPause = _paused; emit DepositPauseSet(_paused, block.timestamp, _msgSender()); } /** * @notice Sets a new `withdrawalPause` state for the Vault. * @param _paused The new value for the `withdrawalPause` state. * * @custom:effects * - Updates the Vault's `withdrawalPause` state in storage. * - Emits the `WithdrawalPauseSet` event with the new pause state, current timestamp, and the caller's address. */ function _setWithdrawalPause(bool _paused) internal { Storage storage s = _vaultStorage(); s.withdrawalPause = _paused; emit WithdrawalPauseSet(_paused, block.timestamp, _msgSender()); } /** * @notice Sets a new `depositWhitelist` state for the Vault. * @param _status The new value for the `depositWhitelist` state. * * @custom:effects * - Updates the Vault's `depositWhitelist` state in storage. * - Emits the `DepositWhitelistSet` event with the new whitelist status, current timestamp, and the caller's address. */ function _setDepositWhitelist(bool _status) internal { Storage storage s = _vaultStorage(); s.depositWhitelist = _status; emit DepositWhitelistSet(_status, block.timestamp, _msgSender()); } /** * @notice Sets a new whitelist `status` for the given `account`. * @param account The address of the account to update. * @param status The new whitelist status for the account. * * @custom:effects * - Updates the whitelist status of the `account` in storage. * - Emits the `DepositorWhitelistStatusSet` event with the account, new status, current timestamp, and the caller's address. */ function _setDepositorWhitelistStatus(address account, bool status) internal { Storage storage s = _vaultStorage(); s.isDepositorWhitelisted[account] = status; emit DepositorWhitelistStatusSet(account, status, block.timestamp, _msgSender()); } /** * @notice Accesses the storage slot for the Vault's data. * @return $ A reference to the `Storage` struct for the Vault. * * @dev This function uses inline assembly to access a predefined storage slot. */ function _vaultStorage() private view returns (Storage storage $) { bytes32 slot = storageSlotRef; assembly { $.slot := slot } } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.25; import "./IVaultControlStorage.sol"; import {AccessControlEnumerableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/extensions/AccessControlEnumerableUpgradeable.sol"; import {ERC4626Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC4626Upgradeable.sol"; import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /** * @title IVaultControl * @notice Interface for controlling the operational state of a vault, including deposits, withdrawals, limits, and whitelisting. * @dev Extends IVaultControlStorage for managing storage and settings related to vault operations. */ interface IVaultControl is IVaultControlStorage { /** * @notice Sets a new limit for the vault to restrict the total value of assets held. * @dev Can only be called by an address with the `SET_LIMIT_ROLE`. * @param _limit The new limit value to be set. */ function setLimit(uint256 _limit) external; /** * @notice Pauses withdrawals from the vault. * @dev Once paused, no withdrawals can be processed until unpaused. * @dev Can only be called by an address with the `PAUSE_WITHDRAWALS_ROLE`. * @custom:effects * - Emits a `WithdrawalPauseSet` event with `paused` set to `true`. * - Revokes the `PAUSE_WITHDRAWALS_ROLE` from `msg.sender` */ function pauseWithdrawals() external; /** * @notice Unpauses withdrawals from the vault. * @dev Once unpaused, withdrawals can be processed again. * @dev Can only be called by an address with the `UNPAUSE_WITHDRAWALS_ROLE`. * @custom:effects * - Emits a `WithdrawalPauseSet` event with `paused` set to `false`. */ function unpauseWithdrawals() external; /** * @notice Pauses deposits into the vault. * @dev Once paused, no deposits can be made until unpaused. * @dev Can only be called by an address with the `PAUSE_DEPOSITS_ROLE`. * @custom:effects * - Emits a `DepositPauseSet` event with `paused` set to `true`. * - Revokes the `PAUSE_DEPOSITS_ROLE` from `msg.sender` */ function pauseDeposits() external; /** * @notice Unpauses deposits into the vault. * @dev Once unpaused, deposits can be made again. * @dev Can only be called by an address with the `UNPAUSE_DEPOSITS_ROLE`. * @custom:effects * - Emits a `DepositPauseSet` event with `paused` set to `false`. */ function unpauseDeposits() external; /** * @notice Sets the deposit whitelist status for the vault. * @dev When the whitelist is enabled, only addresses on the whitelist can deposit into the vault. * @dev Can only be called by an address with the `SET_DEPOSIT_WHITELIST_ROLE`. * @param status The new whitelist status (`true` to enable, `false` to disable). * @custom:effects * - Emits a `DepositWhitelistSet` event indicating the new whitelist status. */ function setDepositWhitelist(bool status) external; /** * @notice Updates the whitelist status of a specific account. * @dev Allows the contract to grant or revoke the ability of an account to make deposits based on the whitelist. * @dev Can only be called by an address with the `SET_DEPOSITOR_WHITELIST_STATUS_ROLE`. * @param account The address of the account to be updated. * @param status The new whitelist status for the account (`true` for whitelisted, `false` for not whitelisted). * @custom:effects * - Emits a `DepositorWhitelistStatusSet` event indicating the updated whitelist status for the account. */ function setDepositorWhitelistStatus(address account, bool status) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * ==== Security Considerations * * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be * considered as an intention to spend the allowance in any specific way. The second is that because permits have * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be * generally recommended is: * * ```solidity * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public { * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {} * doThing(..., value); * } * * function doThing(..., uint256 value) public { * token.safeTransferFrom(msg.sender, address(this), value); * ... * } * ``` * * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also * {SafeERC20-safeTransferFrom}). * * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so * contracts should have entry points that don't rely on permit. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. * * CAUTION: See Security Considerations above. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol) pragma solidity ^0.8.20; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error AddressInsufficientBalance(address account); /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedInnerCall(); /** * @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 AddressInsufficientBalance(address(this)); } (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert FailedInnerCall(); } } /** * @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 * {FailedInnerCall} 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 AddressInsufficientBalance(address(this)); } (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 {FailedInnerCall}) 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 {FailedInnerCall} 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 {FailedInnerCall}. */ 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 /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert FailedInnerCall(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol) // This file was procedurally generated from scripts/generate/templates/EnumerableSet.js. pragma solidity ^0.8.20; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ```solidity * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure * unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an * array of EnumerableSet. * ==== */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position is the index of the value in the `values` array plus 1. // Position 0 is used to mean a value is not in the set. mapping(bytes32 value => uint256) _positions; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._positions[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We cache the value's position to prevent multiple reads from the same storage slot uint256 position = set._positions[value]; if (position != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 valueIndex = position - 1; uint256 lastIndex = set._values.length - 1; if (valueIndex != lastIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the lastValue to the index where the value to delete is set._values[valueIndex] = lastValue; // Update the tracked position of the lastValue (that was just moved) set._positions[lastValue] = position; } // Delete the slot where the moved value was stored set._values.pop(); // Delete the tracked position for the deleted slot delete set._positions[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._positions[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { bytes32[] memory store = _values(set._inner); bytes32[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values in the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/manager/IAccessManager.sol) pragma solidity ^0.8.20; import {IAccessManaged} from "./IAccessManaged.sol"; import {Time} from "../../utils/types/Time.sol"; interface IAccessManager { /** * @dev A delayed operation was scheduled. */ event OperationScheduled( bytes32 indexed operationId, uint32 indexed nonce, uint48 schedule, address caller, address target, bytes data ); /** * @dev A scheduled operation was executed. */ event OperationExecuted(bytes32 indexed operationId, uint32 indexed nonce); /** * @dev A scheduled operation was canceled. */ event OperationCanceled(bytes32 indexed operationId, uint32 indexed nonce); /** * @dev Informational labelling for a roleId. */ event RoleLabel(uint64 indexed roleId, string label); /** * @dev Emitted when `account` is granted `roleId`. * * NOTE: The meaning of the `since` argument depends on the `newMember` argument. * If the role is granted to a new member, the `since` argument indicates when the account becomes a member of the role, * otherwise it indicates the execution delay for this account and roleId is updated. */ event RoleGranted(uint64 indexed roleId, address indexed account, uint32 delay, uint48 since, bool newMember); /** * @dev Emitted when `account` membership or `roleId` is revoked. Unlike granting, revoking is instantaneous. */ event RoleRevoked(uint64 indexed roleId, address indexed account); /** * @dev Role acting as admin over a given `roleId` is updated. */ event RoleAdminChanged(uint64 indexed roleId, uint64 indexed admin); /** * @dev Role acting as guardian over a given `roleId` is updated. */ event RoleGuardianChanged(uint64 indexed roleId, uint64 indexed guardian); /** * @dev Grant delay for a given `roleId` will be updated to `delay` when `since` is reached. */ event RoleGrantDelayChanged(uint64 indexed roleId, uint32 delay, uint48 since); /** * @dev Target mode is updated (true = closed, false = open). */ event TargetClosed(address indexed target, bool closed); /** * @dev Role required to invoke `selector` on `target` is updated to `roleId`. */ event TargetFunctionRoleUpdated(address indexed target, bytes4 selector, uint64 indexed roleId); /** * @dev Admin delay for a given `target` will be updated to `delay` when `since` is reached. */ event TargetAdminDelayUpdated(address indexed target, uint32 delay, uint48 since); error AccessManagerAlreadyScheduled(bytes32 operationId); error AccessManagerNotScheduled(bytes32 operationId); error AccessManagerNotReady(bytes32 operationId); error AccessManagerExpired(bytes32 operationId); error AccessManagerLockedAccount(address account); error AccessManagerLockedRole(uint64 roleId); error AccessManagerBadConfirmation(); error AccessManagerUnauthorizedAccount(address msgsender, uint64 roleId); error AccessManagerUnauthorizedCall(address caller, address target, bytes4 selector); error AccessManagerUnauthorizedConsume(address target); error AccessManagerUnauthorizedCancel(address msgsender, address caller, address target, bytes4 selector); error AccessManagerInvalidInitialAdmin(address initialAdmin); /** * @dev Check if an address (`caller`) is authorised to call a given function on a given contract directly (with * no restriction). Additionally, it returns the delay needed to perform the call indirectly through the {schedule} * & {execute} workflow. * * This function is usually called by the targeted contract to control immediate execution of restricted functions. * Therefore we only return true if the call can be performed without any delay. If the call is subject to a * previously set delay (not zero), then the function should return false and the caller should schedule the operation * for future execution. * * If `immediate` is true, the delay can be disregarded and the operation can be immediately executed, otherwise * the operation can be executed if and only if delay is greater than 0. * * NOTE: The IAuthority interface does not include the `uint32` delay. This is an extension of that interface that * is backward compatible. Some contracts may thus ignore the second return argument. In that case they will fail * to identify the indirect workflow, and will consider calls that require a delay to be forbidden. * * NOTE: This function does not report the permissions of this manager itself. These are defined by the * {_canCallSelf} function instead. */ function canCall( address caller, address target, bytes4 selector ) external view returns (bool allowed, uint32 delay); /** * @dev Expiration delay for scheduled proposals. Defaults to 1 week. * * IMPORTANT: Avoid overriding the expiration with 0. Otherwise every contract proposal will be expired immediately, * disabling any scheduling usage. */ function expiration() external view returns (uint32); /** * @dev Minimum setback for all delay updates, with the exception of execution delays. It * can be increased without setback (and reset via {revokeRole} in the case event of an * accidental increase). Defaults to 5 days. */ function minSetback() external view returns (uint32); /** * @dev Get whether the contract is closed disabling any access. Otherwise role permissions are applied. */ function isTargetClosed(address target) external view returns (bool); /** * @dev Get the role required to call a function. */ function getTargetFunctionRole(address target, bytes4 selector) external view returns (uint64); /** * @dev Get the admin delay for a target contract. Changes to contract configuration are subject to this delay. */ function getTargetAdminDelay(address target) external view returns (uint32); /** * @dev Get the id of the role that acts as an admin for the given role. * * The admin permission is required to grant the role, revoke the role and update the execution delay to execute * an operation that is restricted to this role. */ function getRoleAdmin(uint64 roleId) external view returns (uint64); /** * @dev Get the role that acts as a guardian for a given role. * * The guardian permission allows canceling operations that have been scheduled under the role. */ function getRoleGuardian(uint64 roleId) external view returns (uint64); /** * @dev Get the role current grant delay. * * Its value may change at any point without an event emitted following a call to {setGrantDelay}. * Changes to this value, including effect timepoint are notified in advance by the {RoleGrantDelayChanged} event. */ function getRoleGrantDelay(uint64 roleId) external view returns (uint32); /** * @dev Get the access details for a given account for a given role. These details include the timepoint at which * membership becomes active, and the delay applied to all operation by this user that requires this permission * level. * * Returns: * [0] Timestamp at which the account membership becomes valid. 0 means role is not granted. * [1] Current execution delay for the account. * [2] Pending execution delay for the account. * [3] Timestamp at which the pending execution delay will become active. 0 means no delay update is scheduled. */ function getAccess(uint64 roleId, address account) external view returns (uint48, uint32, uint32, uint48); /** * @dev Check if a given account currently has the permission level corresponding to a given role. Note that this * permission might be associated with an execution delay. {getAccess} can provide more details. */ function hasRole(uint64 roleId, address account) external view returns (bool, uint32); /** * @dev Give a label to a role, for improved role discoverability by UIs. * * Requirements: * * - the caller must be a global admin * * Emits a {RoleLabel} event. */ function labelRole(uint64 roleId, string calldata label) external; /** * @dev Add `account` to `roleId`, or change its execution delay. * * This gives the account the authorization to call any function that is restricted to this role. An optional * execution delay (in seconds) can be set. If that delay is non 0, the user is required to schedule any operation * that is restricted to members of this role. The user will only be able to execute the operation after the delay has * passed, before it has expired. During this period, admin and guardians can cancel the operation (see {cancel}). * * If the account has already been granted this role, the execution delay will be updated. This update is not * immediate and follows the delay rules. For example, if a user currently has a delay of 3 hours, and this is * called to reduce that delay to 1 hour, the new delay will take some time to take effect, enforcing that any * operation executed in the 3 hours that follows this update was indeed scheduled before this update. * * Requirements: * * - the caller must be an admin for the role (see {getRoleAdmin}) * - granted role must not be the `PUBLIC_ROLE` * * Emits a {RoleGranted} event. */ function grantRole(uint64 roleId, address account, uint32 executionDelay) external; /** * @dev Remove an account from a role, with immediate effect. If the account does not have the role, this call has * no effect. * * Requirements: * * - the caller must be an admin for the role (see {getRoleAdmin}) * - revoked role must not be the `PUBLIC_ROLE` * * Emits a {RoleRevoked} event if the account had the role. */ function revokeRole(uint64 roleId, address account) external; /** * @dev Renounce role permissions for the calling account with immediate effect. If the sender is not in * the role this call has no effect. * * Requirements: * * - the caller must be `callerConfirmation`. * * Emits a {RoleRevoked} event if the account had the role. */ function renounceRole(uint64 roleId, address callerConfirmation) external; /** * @dev Change admin role for a given role. * * Requirements: * * - the caller must be a global admin * * Emits a {RoleAdminChanged} event */ function setRoleAdmin(uint64 roleId, uint64 admin) external; /** * @dev Change guardian role for a given role. * * Requirements: * * - the caller must be a global admin * * Emits a {RoleGuardianChanged} event */ function setRoleGuardian(uint64 roleId, uint64 guardian) external; /** * @dev Update the delay for granting a `roleId`. * * Requirements: * * - the caller must be a global admin * * Emits a {RoleGrantDelayChanged} event. */ function setGrantDelay(uint64 roleId, uint32 newDelay) external; /** * @dev Set the role required to call functions identified by the `selectors` in the `target` contract. * * Requirements: * * - the caller must be a global admin * * Emits a {TargetFunctionRoleUpdated} event per selector. */ function setTargetFunctionRole(address target, bytes4[] calldata selectors, uint64 roleId) external; /** * @dev Set the delay for changing the configuration of a given target contract. * * Requirements: * * - the caller must be a global admin * * Emits a {TargetAdminDelayUpdated} event. */ function setTargetAdminDelay(address target, uint32 newDelay) external; /** * @dev Set the closed flag for a contract. * * Requirements: * * - the caller must be a global admin * * Emits a {TargetClosed} event. */ function setTargetClosed(address target, bool closed) external; /** * @dev Return the timepoint at which a scheduled operation will be ready for execution. This returns 0 if the * operation is not yet scheduled, has expired, was executed, or was canceled. */ function getSchedule(bytes32 id) external view returns (uint48); /** * @dev Return the nonce for the latest scheduled operation with a given id. Returns 0 if the operation has never * been scheduled. */ function getNonce(bytes32 id) external view returns (uint32); /** * @dev Schedule a delayed operation for future execution, and return the operation identifier. It is possible to * choose the timestamp at which the operation becomes executable as long as it satisfies the execution delays * required for the caller. The special value zero will automatically set the earliest possible time. * * Returns the `operationId` that was scheduled. Since this value is a hash of the parameters, it can reoccur when * the same parameters are used; if this is relevant, the returned `nonce` can be used to uniquely identify this * scheduled operation from other occurrences of the same `operationId` in invocations of {execute} and {cancel}. * * Emits a {OperationScheduled} event. * * NOTE: It is not possible to concurrently schedule more than one operation with the same `target` and `data`. If * this is necessary, a random byte can be appended to `data` to act as a salt that will be ignored by the target * contract if it is using standard Solidity ABI encoding. */ function schedule(address target, bytes calldata data, uint48 when) external returns (bytes32, uint32); /** * @dev Execute a function that is delay restricted, provided it was properly scheduled beforehand, or the * execution delay is 0. * * Returns the nonce that identifies the previously scheduled operation that is executed, or 0 if the * operation wasn't previously scheduled (if the caller doesn't have an execution delay). * * Emits an {OperationExecuted} event only if the call was scheduled and delayed. */ function execute(address target, bytes calldata data) external payable returns (uint32); /** * @dev Cancel a scheduled (delayed) operation. Returns the nonce that identifies the previously scheduled * operation that is cancelled. * * Requirements: * * - the caller must be the proposer, a guardian of the targeted function, or a global admin * * Emits a {OperationCanceled} event. */ function cancel(address caller, address target, bytes calldata data) external returns (uint32); /** * @dev Consume a scheduled operation targeting the caller. If such an operation exists, mark it as consumed * (emit an {OperationExecuted} event and clean the state). Otherwise, throw an error. * * This is useful for contract that want to enforce that calls targeting them were scheduled on the manager, * with all the verifications that it implies. * * Emit a {OperationExecuted} event. */ function consumeScheduledOp(address caller, bytes calldata data) external; /** * @dev Hashing function for delayed operations. */ function hashOperation(address caller, address target, bytes calldata data) external view returns (bytes32); /** * @dev Changes the authority of a target managed by this manager instance. * * Requirements: * * - the caller must be a global admin */ function updateAuthority(address target, address newAuthority) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/manager/IAccessManaged.sol) pragma solidity ^0.8.20; interface IAccessManaged { /** * @dev Authority that manages this contract was updated. */ event AuthorityUpdated(address authority); error AccessManagedUnauthorized(address caller); error AccessManagedRequiredDelay(address caller, uint32 delay); error AccessManagedInvalidAuthority(address authority); /** * @dev Returns the current authority. */ function authority() external view returns (address); /** * @dev Transfers control to a new authority. The caller must be the current authority. */ function setAuthority(address) external; /** * @dev Returns true only in the context of a delayed restricted call, at the moment that the scheduled operation is * being consumed. Prevents denial of service for delayed restricted calls in the case that the contract performs * attacker controlled calls. */ function isConsumingScheduledOp() external view returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Multicall.sol) pragma solidity ^0.8.20; import {Address} from "@openzeppelin/contracts/utils/Address.sol"; import {ContextUpgradeable} from "./ContextUpgradeable.sol"; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Provides a function to batch together multiple calls in a single external call. * * Consider any assumption about calldata validation performed by the sender may be violated if it's not especially * careful about sending transactions invoking {multicall}. For example, a relay address that filters function * selectors won't filter calls nested within a {multicall} operation. * * NOTE: Since 5.0.1 and 4.9.4, this contract identifies non-canonical contexts (i.e. `msg.sender` is not {_msgSender}). * If a non-canonical context is identified, the following self `delegatecall` appends the last bytes of `msg.data` * to the subcall. This makes it safe to use with {ERC2771Context}. Contexts that don't affect the resolution of * {_msgSender} are not propagated to subcalls. */ abstract contract MulticallUpgradeable is Initializable, ContextUpgradeable { function __Multicall_init() internal onlyInitializing { } function __Multicall_init_unchained() internal onlyInitializing { } /** * @dev Receives and executes a batch of function calls on this contract. * @custom:oz-upgrades-unsafe-allow-reachable delegatecall */ function multicall(bytes[] calldata data) external virtual returns (bytes[] memory results) { bytes memory context = msg.sender == _msgSender() ? new bytes(0) : msg.data[msg.data.length - _contextSuffixLength():]; results = new bytes[](data.length); for (uint256 i = 0; i < data.length; i++) { results[i] = Address.functionDelegateCall(address(this), bytes.concat(data[i], context)); } return results; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/types/Time.sol) pragma solidity ^0.8.20; import {Math} from "../math/Math.sol"; import {SafeCast} from "../math/SafeCast.sol"; /** * @dev This library provides helpers for manipulating time-related objects. * * It uses the following types: * - `uint48` for timepoints * - `uint32` for durations * * While the library doesn't provide specific types for timepoints and duration, it does provide: * - a `Delay` type to represent duration that can be programmed to change value automatically at a given point * - additional helper functions */ library Time { using Time for *; /** * @dev Get the block timestamp as a Timepoint. */ function timestamp() internal view returns (uint48) { return SafeCast.toUint48(block.timestamp); } /** * @dev Get the block number as a Timepoint. */ function blockNumber() internal view returns (uint48) { return SafeCast.toUint48(block.number); } // ==================================================== Delay ===================================================== /** * @dev A `Delay` is a uint32 duration that can be programmed to change value automatically at a given point in the * future. The "effect" timepoint describes when the transitions happens from the "old" value to the "new" value. * This allows updating the delay applied to some operation while keeping some guarantees. * * In particular, the {update} function guarantees that if the delay is reduced, the old delay still applies for * some time. For example if the delay is currently 7 days to do an upgrade, the admin should not be able to set * the delay to 0 and upgrade immediately. If the admin wants to reduce the delay, the old delay (7 days) should * still apply for some time. * * * The `Delay` type is 112 bits long, and packs the following: * * ``` * | [uint48]: effect date (timepoint) * | | [uint32]: value before (duration) * ↓ ↓ ↓ [uint32]: value after (duration) * 0xAAAAAAAAAAAABBBBBBBBCCCCCCCC * ``` * * NOTE: The {get} and {withUpdate} functions operate using timestamps. Block number based delays are not currently * supported. */ type Delay is uint112; /** * @dev Wrap a duration into a Delay to add the one-step "update in the future" feature */ function toDelay(uint32 duration) internal pure returns (Delay) { return Delay.wrap(duration); } /** * @dev Get the value at a given timepoint plus the pending value and effect timepoint if there is a scheduled * change after this timepoint. If the effect timepoint is 0, then the pending value should not be considered. */ function _getFullAt(Delay self, uint48 timepoint) private pure returns (uint32, uint32, uint48) { (uint32 valueBefore, uint32 valueAfter, uint48 effect) = self.unpack(); return effect <= timepoint ? (valueAfter, 0, 0) : (valueBefore, valueAfter, effect); } /** * @dev Get the current value plus the pending value and effect timepoint if there is a scheduled change. If the * effect timepoint is 0, then the pending value should not be considered. */ function getFull(Delay self) internal view returns (uint32, uint32, uint48) { return _getFullAt(self, timestamp()); } /** * @dev Get the current value. */ function get(Delay self) internal view returns (uint32) { (uint32 delay, , ) = self.getFull(); return delay; } /** * @dev Update a Delay object so that it takes a new duration after a timepoint that is automatically computed to * enforce the old delay at the moment of the update. Returns the updated Delay object and the timestamp when the * new delay becomes effective. */ function withUpdate( Delay self, uint32 newValue, uint32 minSetback ) internal view returns (Delay updatedDelay, uint48 effect) { uint32 value = self.get(); uint32 setback = uint32(Math.max(minSetback, value > newValue ? value - newValue : 0)); effect = timestamp() + setback; return (pack(value, newValue, effect), effect); } /** * @dev Split a delay into its components: valueBefore, valueAfter and effect (transition timepoint). */ function unpack(Delay self) internal pure returns (uint32 valueBefore, uint32 valueAfter, uint48 effect) { uint112 raw = Delay.unwrap(self); valueAfter = uint32(raw); valueBefore = uint32(raw >> 32); effect = uint48(raw >> 64); return (valueBefore, valueAfter, effect); } /** * @dev pack the components into a Delay object. */ function pack(uint32 valueBefore, uint32 valueAfter, uint48 effect) internal pure returns (Delay) { return Delay.wrap((uint112(effect) << 64) | (uint112(valueBefore) << 32) | uint112(valueAfter)); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IMigratableEntity { error AlreadyInitialized(); error NotFactory(); error NotInitialized(); /** * @notice Get the factory's address. * @return address of the factory */ function FACTORY() external view returns (address); /** * @notice Get the entity's version. * @return version of the entity * @dev Starts from 1. */ function version() external view returns (uint64); /** * @notice Initialize this entity contract by using a given data and setting a particular version and owner. * @param initialVersion initial version of the entity * @param owner initial owner of the entity * @param data some data to use */ function initialize(uint64 initialVersion, address owner, bytes calldata data) external; /** * @notice Migrate this entity to a particular newer version using a given data. * @param newVersion new version of the entity * @param data some data to use */ function migrate(uint64 newVersion, bytes calldata data) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IVaultStorage { error InvalidTimestamp(); error NoPreviousEpoch(); /** * @notice Get a deposit whitelist enabler/disabler's role. * @return identifier of the whitelist enabler/disabler role */ function DEPOSIT_WHITELIST_SET_ROLE() external view returns (bytes32); /** * @notice Get a depositor whitelist status setter's role. * @return identifier of the depositor whitelist status setter role */ function DEPOSITOR_WHITELIST_ROLE() external view returns (bytes32); /** * @notice Get a deposit limit enabler/disabler's role. * @return identifier of the deposit limit enabler/disabler role */ function IS_DEPOSIT_LIMIT_SET_ROLE() external view returns (bytes32); /** * @notice Get a deposit limit setter's role. * @return identifier of the deposit limit setter role */ function DEPOSIT_LIMIT_SET_ROLE() external view returns (bytes32); /** * @notice Get the delegator factory's address. * @return address of the delegator factory */ function DELEGATOR_FACTORY() external view returns (address); /** * @notice Get the slasher factory's address. * @return address of the slasher factory */ function SLASHER_FACTORY() external view returns (address); /** * @notice Get a vault collateral. * @return address of the underlying collateral */ function collateral() external view returns (address); /** * @notice Get a burner to issue debt to (e.g., 0xdEaD or some unwrapper contract). * @return address of the burner */ function burner() external view returns (address); /** * @notice Get a delegator (it delegates the vault's stake to networks and operators). * @return address of the delegator */ function delegator() external view returns (address); /** * @notice Get if the delegator is initialized. * @return if the delegator is initialized */ function isDelegatorInitialized() external view returns (bool); /** * @notice Get a slasher (it provides networks a slashing mechanism). * @return address of the slasher */ function slasher() external view returns (address); /** * @notice Get if the slasher is initialized. * @return if the slasher is initialized */ function isSlasherInitialized() external view returns (bool); /** * @notice Get a time point of the epoch duration set. * @return time point of the epoch duration set */ function epochDurationInit() external view returns (uint48); /** * @notice Get a duration of the vault epoch. * @return duration of the epoch */ function epochDuration() external view returns (uint48); /** * @notice Get an epoch at a given timestamp. * @param timestamp time point to get the epoch at * @return epoch at the timestamp * @dev Reverts if the timestamp is less than the start of the epoch 0. */ function epochAt( uint48 timestamp ) external view returns (uint256); /** * @notice Get a current vault epoch. * @return current epoch */ function currentEpoch() external view returns (uint256); /** * @notice Get a start of the current vault epoch. * @return start of the current epoch */ function currentEpochStart() external view returns (uint48); /** * @notice Get a start of the previous vault epoch. * @return start of the previous epoch * @dev Reverts if the current epoch is 0. */ function previousEpochStart() external view returns (uint48); /** * @notice Get a start of the next vault epoch. * @return start of the next epoch */ function nextEpochStart() external view returns (uint48); /** * @notice Get if the deposit whitelist is enabled. * @return if the deposit whitelist is enabled */ function depositWhitelist() external view returns (bool); /** * @notice Get if a given account is whitelisted as a depositor. * @param account address to check * @return if the account is whitelisted as a depositor */ function isDepositorWhitelisted( address account ) external view returns (bool); /** * @notice Get if the deposit limit is set. * @return if the deposit limit is set */ function isDepositLimit() external view returns (bool); /** * @notice Get a deposit limit (maximum amount of the active stake that can be in the vault simultaneously). * @return deposit limit */ function depositLimit() external view returns (uint256); /** * @notice Get a total number of active shares in the vault at a given timestamp using a hint. * @param timestamp time point to get the total number of active shares at * @param hint hint for the checkpoint index * @return total number of active shares at the timestamp */ function activeSharesAt(uint48 timestamp, bytes memory hint) external view returns (uint256); /** * @notice Get a total number of active shares in the vault. * @return total number of active shares */ function activeShares() external view returns (uint256); /** * @notice Get a total amount of active stake in the vault at a given timestamp using a hint. * @param timestamp time point to get the total active stake at * @param hint hint for the checkpoint index * @return total amount of active stake at the timestamp */ function activeStakeAt(uint48 timestamp, bytes memory hint) external view returns (uint256); /** * @notice Get a total amount of active stake in the vault. * @return total amount of active stake */ function activeStake() external view returns (uint256); /** * @notice Get a total number of active shares for a particular account at a given timestamp using a hint. * @param account account to get the number of active shares for * @param timestamp time point to get the number of active shares for the account at * @param hint hint for the checkpoint index * @return number of active shares for the account at the timestamp */ function activeSharesOfAt(address account, uint48 timestamp, bytes memory hint) external view returns (uint256); /** * @notice Get a number of active shares for a particular account. * @param account account to get the number of active shares for * @return number of active shares for the account */ function activeSharesOf( address account ) external view returns (uint256); /** * @notice Get a total amount of the withdrawals at a given epoch. * @param epoch epoch to get the total amount of the withdrawals at * @return total amount of the withdrawals at the epoch */ function withdrawals( uint256 epoch ) external view returns (uint256); /** * @notice Get a total number of withdrawal shares at a given epoch. * @param epoch epoch to get the total number of withdrawal shares at * @return total number of withdrawal shares at the epoch */ function withdrawalShares( uint256 epoch ) external view returns (uint256); /** * @notice Get a number of withdrawal shares for a particular account at a given epoch (zero if claimed). * @param epoch epoch to get the number of withdrawal shares for the account at * @param account account to get the number of withdrawal shares for * @return number of withdrawal shares for the account at the epoch */ function withdrawalSharesOf(uint256 epoch, address account) external view returns (uint256); /** * @notice Get if the withdrawals are claimed for a particular account at a given epoch. * @param epoch epoch to check the withdrawals for the account at * @param account account to check the withdrawals for * @return if the withdrawals are claimed for the account at the epoch */ function isWithdrawalsClaimed(uint256 epoch, address account) external view returns (bool); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.25; import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import {ContextUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol"; /** * @title IVaultControlStorage * @notice Interface for interacting with the storage and control states of a vault. * @dev Provides functions to manage deposit and withdrawal controls, limits, and whitelisting of depositors. */ interface IVaultControlStorage { /** * @notice Storage structure for vault control data. * @dev Used to manage vault settings such as deposit and withdrawal states, limits, and whitelist functionality. * @param depositPause Indicates if deposits are currently paused. * @param withdrawalPause Indicates if withdrawals are currently paused. * @param limit The current limit on deposits. * @param depositWhitelist Indicates if the deposit whitelist is enabled. * @param isDepositorWhitelisted Mapping to track the whitelist status of each depositor by address. */ struct Storage { bool depositPause; bool withdrawalPause; uint256 limit; bool depositWhitelist; mapping(address => bool) isDepositorWhitelisted; } /** * @notice Returns the current value of the `depositPause` state. * @dev When `true`, deposits into the vault are paused. * @return paused The current state of the deposit pause. */ function depositPause() external view returns (bool); /** * @notice Returns the current value of the `withdrawalPause` state. * @dev When `true`, withdrawals from the vault are paused. * @return paused The current state of the withdrawal pause. */ function withdrawalPause() external view returns (bool); /** * @notice Returns the current deposit limit. * @dev This limit can be applied to control the maximum allowed deposits. * @return limit The current limit value. */ function limit() external view returns (uint256); /** * @notice Returns the current value of the `depositWhitelist` state. * @dev When `true`, only whitelisted addresses are allowed to deposit into the vault. * @return whitelistEnabled The current state of the deposit whitelist. */ function depositWhitelist() external view returns (bool); /** * @notice Checks whether a given account is whitelisted for deposits. * @param account The address of the account to check. * @return isWhitelisted `true` if the account is whitelisted, `false` otherwise. */ function isDepositorWhitelisted(address account) external view returns (bool); /** * @notice Emitted when the vault's deposit limit is updated. * @param limit The new limit value. * @param timestamp The time at which the limit was set. * @param sender The address of the account that set the new limit. */ event LimitSet(uint256 limit, uint256 timestamp, address sender); /** * @notice Emitted when the deposit pause state is updated. * @param paused The new state of the deposit pause (`true` for paused, `false` for unpaused). * @param timestamp The time at which the pause state was set. * @param sender The address of the account that set the new state. */ event DepositPauseSet(bool paused, uint256 timestamp, address sender); /** * @notice Emitted when the withdrawal pause state is updated. * @param paused The new state of the withdrawal pause (`true` for paused, `false` for unpaused). * @param timestamp The time at which the pause state was set. * @param sender The address of the account that set the new state. */ event WithdrawalPauseSet(bool paused, uint256 timestamp, address sender); /** * @notice Emitted when the deposit whitelist state is updated. * @param status The new state of the deposit whitelist (`true` for enabled, `false` for disabled). * @param timestamp The time at which the whitelist state was set. * @param sender The address of the account that set the new state. */ event DepositWhitelistSet(bool status, uint256 timestamp, address sender); /** * @notice Emitted when a depositor's whitelist status is updated. * @param account The address of the account whose whitelist status was updated. * @param status The new whitelist status (`true` for whitelisted, `false` for not whitelisted). * @param timestamp The time at which the whitelist status was set. * @param sender The address of the account that set the new status. */ event DepositorWhitelistStatusSet( address account, bool status, uint256 timestamp, address sender ); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.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 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.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 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); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol) pragma solidity ^0.8.20; import {IAccessControl} from "../IAccessControl.sol"; /** * @dev External interface of AccessControlEnumerable declared to support ERC165 detection. */ interface IAccessControlEnumerable is IAccessControl { /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) external view returns (address); /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol) pragma solidity ^0.8.20; import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol"; import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol"; import {ERC165Upgradeable} from "../utils/introspection/ERC165Upgradeable.sol"; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ```solidity * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ```solidity * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules} * to enforce additional security measures for this role. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable { struct RoleData { mapping(address account => bool) hasRole; bytes32 adminRole; } bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl struct AccessControlStorage { mapping(bytes32 role => RoleData) _roles; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.AccessControl")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800; function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) { assembly { $.slot := AccessControlStorageLocation } } /** * @dev Modifier that checks that an account has a specific role. Reverts * with an {AccessControlUnauthorizedAccount} error including the required role. */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } function __AccessControl_init() internal onlyInitializing { } function __AccessControl_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual returns (bool) { AccessControlStorage storage $ = _getAccessControlStorage(); return $._roles[role].hasRole[account]; } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()` * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier. */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account` * is missing `role`. */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert AccessControlUnauthorizedAccount(account, role); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) { AccessControlStorage storage $ = _getAccessControlStorage(); return $._roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `callerConfirmation`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address callerConfirmation) public virtual { if (callerConfirmation != _msgSender()) { revert AccessControlBadConfirmation(); } _revokeRole(role, callerConfirmation); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { AccessControlStorage storage $ = _getAccessControlStorage(); bytes32 previousAdminRole = getRoleAdmin(role); $._roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual returns (bool) { AccessControlStorage storage $ = _getAccessControlStorage(); if (!hasRole(role, account)) { $._roles[role].hasRole[account] = true; emit RoleGranted(role, account, _msgSender()); return true; } else { return false; } } /** * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual returns (bool) { AccessControlStorage storage $ = _getAccessControlStorage(); if (hasRole(role, account)) { $._roles[role].hasRole[account] = false; emit RoleRevoked(role, account, _msgSender()); return true; } else { return false; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol) pragma solidity ^0.8.20; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev The `account` is missing a role. */ error AccessControlUnauthorizedAccount(address account, bytes32 neededRole); /** * @dev The caller of a function is not the expected one. * * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}. */ error AccessControlBadConfirmation(); /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ 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.0.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 ERC165 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) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * 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[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
{ "remappings": [ "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", "@symbiotic/core/=lib/core/src/", "@symbiotic/core-test/=lib/core/test/", "@symbiotic/rewards/=lib/rewards/src/", "@symbiotic/burners/=lib/burners/src/", "@symbioticfi/core/=lib/burners/lib/core/", "burners/=lib/burners/", "core/=lib/core/", "ds-test/=lib/openzeppelin-contracts-upgradeable/lib/forge-std/lib/ds-test/src/", "erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/", "forge-std/=lib/forge-std/src/", "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/", "openzeppelin-contracts/=lib/openzeppelin-contracts/", "rewards/=lib/rewards/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "cancun", "viaIR": false, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"bytes32","name":"name_","type":"bytes32"},{"internalType":"uint256","name":"version_","type":"uint256"}],"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":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"allowance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientAllowance","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC20InvalidApprover","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC20InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC20InvalidSender","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"}],"name":"ERC20InvalidSpender","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"ERC4626ExceededMaxDeposit","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"ERC4626ExceededMaxMint","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"ERC4626ExceededMaxRedeem","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"ERC4626ExceededMaxWithdraw","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"MathOverflowedMulDiv","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"paused","type":"bool"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"},{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"DepositPauseSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"status","type":"bool"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"},{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"DepositWhitelistSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"status","type":"bool"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"},{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"DepositorWhitelistStatusSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"farmId","type":"uint256"},{"components":[{"internalType":"address","name":"rewardToken","type":"address"},{"internalType":"address","name":"symbioticFarm","type":"address"},{"internalType":"address","name":"distributionFarm","type":"address"},{"internalType":"address","name":"curatorTreasury","type":"address"},{"internalType":"uint256","name":"curatorFeeD6","type":"uint256"}],"indexed":false,"internalType":"struct IMellowSymbioticVaultStorage.FarmData","name":"farmData","type":"tuple"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"FarmSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"limit","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"},{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"LimitSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"address","name":"referral","type":"address"}],"name":"ReferralDeposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"farmId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rewardAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"curatorFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"RewardsPushed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"symbioticCollateral","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"SymbioticCollateralSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"collateralWithdrawal","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"collateralDeposit","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"vaultAmount","type":"uint256"}],"name":"SymbioticPushed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"symbioticVault","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"SymbioticVaultSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"Withdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"paused","type":"bool"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"},{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"WithdrawalPauseSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"withdrawalQueue","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"WithdrawalQueueSet","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"asset","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"maxAmount","type":"uint256"}],"name":"claim","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"claimableAssetsOf","outputs":[{"internalType":"uint256","name":"claimableAssets","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"compatTotalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"convertToAssets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"name":"convertToShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"referral","type":"address"}],"name":"deposit","outputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"deposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"depositPause","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"depositWhitelist","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getBalances","outputs":[{"internalType":"uint256","name":"accountAssets","type":"uint256"},{"internalType":"uint256","name":"accountInstantAssets","type":"uint256"},{"internalType":"uint256","name":"accountShares","type":"uint256"},{"internalType":"uint256","name":"accountInstantShares","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"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"limit","type":"uint256"},{"internalType":"address","name":"symbioticCollateral","type":"address"},{"internalType":"address","name":"symbioticVault","type":"address"},{"internalType":"address","name":"withdrawalQueue","type":"address"},{"internalType":"address","name":"admin","type":"address"},{"internalType":"bool","name":"depositPause","type":"bool"},{"internalType":"bool","name":"withdrawalPause","type":"bool"},{"internalType":"bool","name":"depositWhitelist","type":"bool"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"}],"internalType":"struct IMellowSymbioticVault.InitParams","name":"initParams","type":"tuple"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isDepositorWhitelisted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"limit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"maxDeposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"maxMint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"maxRedeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"maxWithdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"migrate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"}],"name":"migrateApproval","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"users","type":"address[]"}],"name":"migrateMultiple","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"mint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pauseDeposits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pauseWithdrawals","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"pendingAssetsOf","outputs":[{"internalType":"uint256","name":"pendingAssets","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"name":"previewDeposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"previewMint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"previewRedeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"name":"previewWithdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pushIntoSymbiotic","outputs":[{"internalType":"uint256","name":"collateralWithdrawal","type":"uint256"},{"internalType":"uint256","name":"collateralDeposit","type":"uint256"},{"internalType":"uint256","name":"vaultDeposit","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"farmId","type":"uint256"},{"internalType":"bytes","name":"symbioticRewardsData","type":"bytes"}],"name":"pushRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"owner","type":"address"}],"name":"redeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":[{"internalType":"bool","name":"status","type":"bool"}],"name":"setDepositWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bool","name":"status","type":"bool"}],"name":"setDepositorWhitelistStatus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"farmId","type":"uint256"},{"components":[{"internalType":"address","name":"rewardToken","type":"address"},{"internalType":"address","name":"symbioticFarm","type":"address"},{"internalType":"address","name":"distributionFarm","type":"address"},{"internalType":"address","name":"curatorTreasury","type":"address"},{"internalType":"uint256","name":"curatorFeeD6","type":"uint256"}],"internalType":"struct IMellowSymbioticVaultStorage.FarmData","name":"farmData","type":"tuple"}],"name":"setFarm","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_limit","type":"uint256"}],"name":"setLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbioticCollateral","outputs":[{"internalType":"contract IDefaultCollateral","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"farmId","type":"uint256"}],"name":"symbioticFarm","outputs":[{"components":[{"internalType":"address","name":"rewardToken","type":"address"},{"internalType":"address","name":"symbioticFarm","type":"address"},{"internalType":"address","name":"distributionFarm","type":"address"},{"internalType":"address","name":"curatorTreasury","type":"address"},{"internalType":"uint256","name":"curatorFeeD6","type":"uint256"}],"internalType":"struct IMellowSymbioticVaultStorage.FarmData","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbioticFarmCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"symbioticFarmIdAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbioticFarmIds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"farmId","type":"uint256"}],"name":"symbioticFarmsContains","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbioticVault","outputs":[{"internalType":"contract IVault","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalAssets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpauseDeposits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpauseWithdrawals","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"owner","type":"address"}],"name":"withdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawalPause","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdrawalQueue","outputs":[{"internalType":"contract IWithdrawalQueue","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60c060405234801561000f575f80fd5b50604051614cc4380380614cc483398101604081905261002e916101b3565b81818181838360ff5f1b19600183836040516020016100959291907f6d656c6c6f772e73696d706c652d6c72742e73746f726167652e5661756c744381526c6f6e74726f6c53746f7261676560981b6020820152602d810192909252604d820152606d0190565b604051602081830303815290604052805190602001205f1c6100b791906101d5565b6040516020016100c991815260200190565b60408051601f198184030181529082905280516020918201209290921660805260ff199350600192506101579186918691017f6d656c6c6f772e73696d706c652d6c72742e73746f726167652e4d656c6c6f7781527f53796d62696f7469635661756c7453746f72616765000000000000000000000060208201526035810192909252605582015260750190565b604051602081830303815290604052805190602001205f1c61017991906101d5565b60405160200161018b91815260200190565b60408051601f1981840301815291905280516020909101201660a052506101fa945050505050565b5f80604083850312156101c4575f80fd5b505080516020909101519092909150565b818103818111156101f457634e487b7160e01b5f52601160045260245ffd5b92915050565b60805160a0516149fa6102ca5f395f8181610bf901528181610ca301528181610ec301528181610f250152818161114e01528181611973015281816119dd01528181611e2c015281816128420152818161377f015281816137ef015261385b01525f81816105b20152818161062201528181610751015281816107d701528181610f7301528181610fa701528181610ff3015281816112ea01528181611c4b01528181611ca801528181611e9301528181612144015281816121f00152818161224c015261296601526149fa5ff3fe608060405234801561000f575f80fd5b50600436106103e0575f3560e01c8063794b15b71161020b578063b460af941161011f578063ce96cb77116100b4578063e3ab43b111610084578063e3ab43b1146108cf578063e4c4be58146108e2578063e7beaf9d146108ea578063ef8b30f714610817578063fb378bdb146108fd575f80fd5b8063ce96cb7714610883578063d547741f14610896578063d905777e146108a9578063dd62ed3e146108bc575f80fd5b8063c6e6f592116100ef578063c6e6f59214610817578063c84aae171461082a578063ca15c8731461085d578063ce5494bb14610870575f80fd5b8063b460af94146107af578063ba087652146107c2578063c19a2aa7146107d5578063c63d75b614610804575f80fd5b80639cab081d116101a0578063a4d66daf11610170578063a4d66daf1461074f578063a9059cbb14610779578063a97ba2311461078c578063aa50ea9214610794578063b3d7f6b91461079c575f80fd5b80639cab081d1461070d578063a084537014610720578063a217fddf14610735578063a28614661461073c575f80fd5b8063922bafd0116101db578063922bafd0146106cc57806394bf804d146106df57806395d89b41146106f2578063996cba68146106fa575f80fd5b8063794b15b7146106705780637980c9eb146106835780639010d07c146106a657806391d14854146106b9575f80fd5b8063313ce5671161030257806348d3b7751161029757806363c6b4eb1161026757806363c6b4eb1461060557806363d8882a146106185780636e22558d146106205780636e553f651461064a57806370a082311461065d575f80fd5b806348d3b775146105b05780634cdad5061461044157806356bb54a7146105dd5780635e02e8df146105e5575f80fd5b806338d52e0f116102d257806338d52e0f1461056f578063402d267d146105775780634105a7dd1461058a5780634655d6391461059d575f80fd5b8063313ce5671461052757806333788f9a1461054157806336568abe1461055457806337d5fe9914610567575f80fd5b806318160ddd116103785780632774fa0c116103485780632774fa0c146104db57806327ea6f2b146104ee5780632e2d2984146105015780632f2ff15d14610514575f80fd5b806318160ddd1461048d57806323b872dd14610495578063248a9ca3146104a85780632554004f146104bb575f80fd5b806307a2d13a116103b357806307a2d13a14610441578063095ea7b3146104545780630a28a4771461046757806316ddfb011461047a575f80fd5b806301e1d114146103e457806301ffc9a7146103ff578063021919801461042257806306fdde031461042c575b5f80fd5b6103ec610905565b6040519081526020015b60405180910390f35b61041261040d366004613ed9565b610a77565b60405190151581526020016103f6565b61042a610aa1565b005b610434610b03565b6040516103f69190613f00565b6103ec61044f366004613f35565b610bc3565b610412610462366004613f70565b610bce565b6103ec610475366004613f35565b610be5565b610412610488366004613f35565b610bf1565b6103ec610c1f565b6104126104a3366004613f9a565b610c5a565b6103ec6104b6366004613f35565b610c7f565b6104c3610c9f565b6040516001600160a01b0390911681526020016103f6565b61042a6104e93660046140b7565b610cd0565b61042a6104fc366004613f35565b610dde565b6103ec61050f3660046141ca565b610e11565b61042a610522366004614209565b610e70565b61052f610e92565b60405160ff90911681526020016103f6565b6103ec61054f366004613f35565b610ebb565b61042a610562366004614209565b610ee9565b6104c3610f21565b6104c3610f52565b6103ec610585366004614237565b610f6d565b61042a610598366004614252565b611055565b61042a6105ab36600461426d565b611088565b7f00000000000000000000000000000000000000000000000000000000000000006002015460ff16610412565b61042a6110c4565b6105f86105f3366004613f35565b611122565b6040516103f6919061431b565b6103ec610613366004614237565b6111cc565b61042a611240565b7f00000000000000000000000000000000000000000000000000000000000000005460ff16610412565b6103ec610658366004614209565b611276565b6103ec61066b366004614237565b6112a1565b61041261067e366004614237565b6112d9565b61068b611318565b604080519384526020840192909252908201526060016103f6565b6104c36106b4366004614329565b611515565b6104126106c7366004614209565b61153a565b61042a6106da366004614349565b611570565b6103ec6106ed366004614209565b6117ef565b610434611802565b6103ec610708366004613f9a565b611840565b61042a61071b3660046143be565b61192e565b61072861196c565b6040516103f69190614468565b6103ec5f81565b61042a61074a3660046144ab565b61199a565b7f0000000000000000000000000000000000000000000000000000000000000000600101546103ec565b610412610787366004613f70565b6119ce565b6002546103ec565b6104c36119db565b6103ec6107aa366004613f35565b611a09565b6103ec6107bd3660046141ca565b611a15565b6103ec6107d03660046141ca565b611a29565b7f000000000000000000000000000000000000000000000000000000000000000054610100900460ff16610412565b6103ec610812366004614237565b611a3d565b6103ec610825366004613f35565b611a60565b61083d610838366004614237565b611a6b565b6040805194855260208501939093529183015260608201526080016103f6565b6103ec61086b366004613f35565b611b97565b61042a61087e366004614237565b611bbb565b6103ec610891366004614237565b611c49565b61042a6108a4366004614209565b611c8a565b6103ec6108b7366004614237565b611ca6565b6103ec6108ca3660046144d7565b611ce7565b61042a6108dd3660046144d7565b611d4c565b61042a611dba565b6103ec6108f8366004614237565b611ded565b6103ec611e26565b5f3061090f6119db565b6040516359f769a960e01b81526001600160a01b03838116600483015291909116906359f769a990602401602060405180830381865afa158015610955573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109799190614503565b610981610c9f565b6040516370a0823160e01b81526001600160a01b03848116600483015291909116906370a0823190602401602060405180830381865afa1580156109c7573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109eb9190614503565b6109f3610f52565b6040516370a0823160e01b81526001600160a01b03858116600483015291909116906370a0823190602401602060405180830381865afa158015610a39573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a5d9190614503565b610a67919061452e565b610a71919061452e565b91505090565b5f6001600160e01b03198216635a05180f60e01b1480610a9b5750610a9b82611e53565b92915050565b7fb0cb335afe1cba10c746b42a1e019651022572bbc76c3f63338df5dd3abb9894610acb81611e87565b610ad56001611e91565b610aff7fb0cb335afe1cba10c746b42a1e019651022572bbc76c3f63338df5dd3abb989433611f11565b5050565b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0380546060915f8051602061494583398151915291610b4190614541565b80601f0160208091040260200160405190810160405280929190818152602001828054610b6d90614541565b8015610bb85780601f10610b8f57610100808354040283529160200191610bb8565b820191905f5260205f20905b815481529060010190602001808311610b9b57829003601f168201915b505050505091505090565b5f610a9b825f611f53565b5f33610bdb818585611f90565b5060019392505050565b5f610a9b826001611f9d565b5f610a9b60037f00000000000000000000000000000000000000000000000000000000000000000183611fd1565b5f610c487f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace025490565b600254610c55919061452e565b905090565b5f33610c67858285611fe8565b610c72858585612032565b60019150505b9392505050565b5f9081525f80516020614965833981519152602052604090206001015490565b60017f000000000000000000000000000000000000000000000000000000000000000001546001600160a01b031690565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff16159067ffffffffffffffff165f81158015610d155750825b90505f8267ffffffffffffffff166001148015610d315750303b155b905081158015610d3f575080155b15610d5d5760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff191660011785558315610d8757845460ff60401b1916600160401b1785555b610d908661208f565b8315610dd657845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b505050505050565b7f6e5811d60b7d57973a97208b6158fed3b8e064ca747403e6a8c81f56a8f9e75f610e0881611e87565b610aff82612142565b5f610e1c8484611276565b604080518681526001600160a01b03868116602083015285168183015290519192507f0f33e518e0001973b4f02d7cef360e8c9290e9ebd0b48695c935af9bac850213919081900360600190a19392505050565b610e7982610c7f565b610e8281611e87565b610e8c83836121a9565b50505050565b5f805f8051602061498583398151915290505f8154610a719190600160a01b900460ff16614579565b5f610a9b60037f000000000000000000000000000000000000000000000000000000000000000001836121e2565b6001600160a01b0381163314610f125760405163334bd91960e11b815260040160405180910390fd5b610f1c8282611f11565b505050565b60027f000000000000000000000000000000000000000000000000000000000000000001546001600160a01b031690565b5f80516020614985833981519152546001600160a01b031690565b5f610f997f00000000000000000000000000000000000000000000000000000000000000005460ff1690565b15610fa557505f919050565b7f00000000000000000000000000000000000000000000000000000000000000006002015460ff168015610fdf5750610fdd826112d9565b155b15610feb57505f919050565b5f61101760017f0000000000000000000000000000000000000000000000000000000000000000015490565b90505f19810361102a57505f1992915050565b5f611033610905565b905080821015611043575f61104d565b61104d8183614592565b949350505050565b7f1b628514858a9a09af73c606e9892743b44cfbdd0c49a7279286ed58eaafcf6d61107f81611e87565b610aff826121ed565b5f5b81811015610f1c576110bc8383838181106110a7576110a76145a5565b905060200201602081019061087e9190614237565b60010161108a565b7ffd367f64dba4612ce1d6ed7e93d2495a59d305f21fba3e15126e1ad62aa9ea156110ee81611e87565b6110f8600161224a565b610aff7ffd367f64dba4612ce1d6ed7e93d2495a59d305f21fba3e15126e1ad62aa9ea1533611f11565b6040805160a0810182525f808252602082018190529181018290526060810182905260808101919091527f00000000000000000000000000000000000000000000000000000000000000005f9283526005016020908152604092839020835160a08101855281546001600160a01b03908116825260018301548116938201939093526002820154831694810194909452600381015490911660608401526004015460808301525090565b5f6111d5610f21565b6040516363c6b4eb60e01b81526001600160a01b03848116600483015291909116906363c6b4eb906024015b602060405180830381865afa15801561121c573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a9b9190614503565b7f49604999f0c13f9a566b3eb2608f60c199b1a3a43d8ff8032fe66a465c945d1d61126a81611e87565b6112735f611e91565b50565b5f61127f6122a5565b61128983836122dc565b9050610a9b60015f805160206149a583398151915255565b6001600160a01b0381165f9081525f80516020614945833981519152602090815260408083205491839052822054610a9b919061452e565b6001600160a01b03165f90815260037f000000000000000000000000000000000000000000000000000000000000000001602052604090205460ff1690565b5f805f80611324610f52565b90505f61132f610c9f565b90505f61133a6119db565b90503061134884848461233b565b9198509650945086156113b15760405163f3fef3a360e01b81526001600160a01b0384169063f3fef3a3906113839084908b906004016145b9565b5f604051808303815f87803b15801561139a575f80fd5b505af11580156113ac573d5f803e3d5ffd5b505050505b851561143b576113cb6001600160a01b038516848861257c565b6040516311f9fbc960e21b81526001600160a01b038416906347e7ef24906113f99084908a906004016145b9565b6020604051808303815f875af1158015611415573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906114399190614503565b505b84156114c5576114556001600160a01b038516838761257c565b6040516311f9fbc960e21b81526001600160a01b038316906347e7ef249061148390849089906004016145b9565b60408051808303815f875af115801561149e573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906114c291906145d2565b50505b60408051338152602081018990528082018890526060810187905290517fb53c38f4658baac1058d6b81869ed82ea19a0b0123b440e23e9b54cd98d4720d9181900360800190a150505050909192565b5f8281525f8051602061492583398151915260208190526040822061104d90846121e2565b5f9182525f80516020614965833981519152602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6115786122a5565b5f61158284611122565b80519091506001600160a01b03166115d75760405162461bcd60e51b815260206004820152601360248201527215985d5b1d0e8819985c9b481b9bdd081cd95d606a1b60448201526064015b60405180910390fd5b80516040516370a0823160e01b81523060048201525f906001600160a01b038316906370a0823190602401602060405180830381865afa15801561161d573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906116419190614503565b6020840151604051635d0b520560e01b81529192506001600160a01b031690635d0b52059061167a90309086908a908a906004016145f4565b5f604051808303815f87803b158015611691575f80fd5b505af11580156116a3573d5f803e3d5ffd5b50506040516370a0823160e01b81523060048201525f92508391506001600160a01b038516906370a0823190602401602060405180830381865afa1580156116ed573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906117119190614503565b61171b9190614592565b9050805f0361172d57505050506117d9565b60808401515f90611743908390620f4240612603565b90508015611765576060850151611765906001600160a01b03861690836126c2565b61176f8183614592565b91508115611791576040850151611791906001600160a01b03861690846126c2565b60408051838152602081018390524281830152905189917f12d8e9280ac85b1633cd74c52f9458f73459aecd6eb0f2d99e2ed27c3fa27e99919081900360600190a250505050505b610f1c60015f805160206149a583398151915255565b5f6117f86122a5565b611289838361271a565b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0480546060915f8051602061494583398151915291610b4190614541565b5f6118496122a5565b6001600160a01b03841633146118945760405162461bcd60e51b815260206004820152601060248201526f2b30bab63a1d103337b93134b23232b760811b60448201526064016115ce565b61189c610f21565b60405163132d974d60e31b81526001600160a01b038681166004830152858116602483015260448201859052919091169063996cba68906064016020604051808303815f875af11580156118f2573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906119169190614503565b9050610c7860015f805160206149a583398151915255565b7f4c30aa7f742e0a14ed7755cb202fc37abe01363d805182186c7cfe8f8a15d64c61195881611e87565b6119628383612766565b610f1c838361283f565b6060610c557f000000000000000000000000000000000000000000000000000000000000000060030161294a565b7f1867ae69910bc7238ccbbb445aa11a0dbdd472b851b7fac0c991101aca0a360d6119c481611e87565b610f1c8383612956565b5f33610bdb818585612032565b7f0000000000000000000000000000000000000000000000000000000000000000546001600160a01b031690565b5f610a9b826001611f53565b5f611a1e6122a5565b6119168484846129e5565b5f611a326122a5565b611916848484612a3b565b5f80611a4883610f6d565b90505f198103611a5b57505f1992915050565b610c78815b5f610a9b825f611f9d565b5f8080803081611a79610c9f565b6040516370a0823160e01b81526001600160a01b03848116600483015291909116906370a0823190602401602060405180830381865afa158015611abf573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611ae39190614503565b611aeb610f52565b6040516370a0823160e01b81526001600160a01b03858116600483015291909116906370a0823190602401602060405180830381865afa158015611b31573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611b559190614503565b611b5f919061452e565b9050611b6a876112a1565b9350611b7584610bc3565b9550611b818682612a88565b9450611b8c85611a60565b925050509193509193565b5f8181525f80516020614925833981519152602081905260408220610c7890612a9d565b6001600160a01b0381165f90815260208190526040812054808203611bdf57505050565b6001600160a01b03929092165f908152602082815260408083208390555f805160206149458339815191529091529020805483019055600201805482900390557f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0280549091019055565b7f0000000000000000000000000000000000000000000000000000000000000000545f90610100900460ff1615611c8157505f919050565b610a9b82612aa6565b611c9382610c7f565b611c9c81611e87565b610e8c8383611f11565b7f0000000000000000000000000000000000000000000000000000000000000000545f90610100900460ff1615611cde57505f919050565b610a9b82612ab9565b6001600160a01b038281165f8181527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0160209081526040808320948616808452948252808320549383526001825280832094835293905291822054610c78919061452e565b6001600160a01b038281165f908152600160209081526040808320938516835292905290812054808203611d805750505050565b6001600160a01b038085165f90815260018401602090815260408083209387168352929052908120819055610e8c90859085908490612ac3565b7f8233fa2806b76ee3f3ba048be2bf735b5c73b63051394e82774bfd7be0db6c02611de481611e87565b6112735f61224a565b5f611df6610f21565b60405163e7beaf9d60e01b81526001600160a01b038481166004830152919091169063e7beaf9d90602401611201565b5f610c557f0000000000000000000000000000000000000000000000000000000000000000600301612a9d565b5f6001600160e01b03198216637965db0b60e01b1480610a9b57506301ffc9a760e01b6001600160e01b0319831614610a9b565b6112738133612ba7565b7f0000000000000000000000000000000000000000000000000000000000000000805460ff19168215151781557f917e249a9d1439adce72cf39ffef9f3ae18f5b7b37a942393522093db79826c48242335b60408051931515845260208401929092526001600160a01b0316908201526060015b60405180910390a15050565b5f5f8051602061492583398151915281611f2b8585612bd2565b9050801561104d575f858152602083905260409020611f4a9085612c54565b50949350505050565b5f610c78611f5f610905565b611f6a90600161452e565b611f755f600a61471e565b611f7d610c1f565b611f87919061452e565b85919085612c68565b610f1c8383836001612cb5565b5f610c78611fac82600a61471e565b611fb4610c1f565b611fbe919061452e565b611fc6610905565b611f8790600161452e565b5f8181526001830160205260408120541515610c78565b5f611ff38484611ce7565b90505f198114610e8c578181101561202457828183604051637dc7a0d960e11b81526004016115ce9392919061472c565b610e8c84848484035f612cb5565b6001600160a01b03831661205b57604051634b637e8f60e11b81525f60048201526024016115ce565b6001600160a01b0382166120845760405163ec442f0560e01b81525f60048201526024016115ce565b610f1c838383612ccb565b612097612ce8565b5f81604001516001600160a01b031663d8dfeb456040518163ffffffff1660e01b8152600401602060405180830381865afa1580156120d8573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906120fc919061474d565b9050612115826020015183604001518460600151612d33565b610aff8260800151835f01518460a001518560c001518660e0015186886101000151896101200151612d56565b7f0000000000000000000000000000000000000000000000000000000000000000600181018290556040805183815242602082015233918101919091527f085b30415f63cd5f875aa6df7b116b64821bdea341dabcb10c94f1cc997138d990606001611f05565b5f5f80516020614925833981519152816121c38585612d88565b9050801561104d575f858152602083905260409020611f4a9085612e20565b5f610c788383612e34565b5f7f000000000000000000000000000000000000000000000000000000000000000060028101805460ff191684151517905590507ffbf9c5de1d63473d377197b4f8bbe7d49c129878194966479bcd64085ad32c55824233611ee3565b7f0000000000000000000000000000000000000000000000000000000000000000805461ff001916610100831515021781557f100e52ba225b1d864d8b4e3725311b44dc3d490024db41251211c87c20da20a7824233611ee3565b5f805160206149a58339815191528054600119016122d657604051633ee5aeb560e01b815260040160405180910390fd5b60029055565b5f806122e783610f6d565b90508084111561231057828482604051633c8097d960e11b81526004016115ce9392919061472c565b5f61231a85611a60565b905061104d33858784612e5a565b60015f805160206149a583398151915255565b6040516370a0823160e01b815230600482018190525f918291829182906001600160a01b038916906370a0823190602401602060405180830381865afa158015612387573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906123ab9190614503565b6040516370a0823160e01b81526001600160a01b0384811660048301529192505f918916906370a0823190602401602060405180830381865afa1580156123f4573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906124189190614503565b90505f61242488612e77565b9050801561248157808310801561243a57508115155b156124625761245361244c8483614592565b8390612a88565b965061245f878461452e565b92505b8215612481576124728382612a88565b945061247e8584614592565b92505b821561256f575f896001600160a01b031663a4d66daf6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156124c4573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906124e89190614503565b90505f8a6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612527573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061254b9190614503565b90508082111561256c576125696125628284614592565b8690612a88565b97505b50505b5050505093509350939050565b604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301525f919085169063dd62ed3e90604401602060405180830381865afa1580156125c9573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906125ed9190614503565b9050610e8c84846125fe858561452e565b6130a0565b5f838302815f1985870982811083820303915050805f036126375783828161262d5761262d614768565b0492505050610c78565b8084116126575760405163227bc15360e01b815260040160405180910390fd5b5f848688095f868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b610f1c83846001600160a01b031663a9059cbb85856040516024016126e89291906145b9565b604051602081830303815290604052915060e01b6020820180516001600160e01b03838183161783525050505061312c565b5f8061272583611a3d565b90508084111561274e5782848260405163284ff66760e01b81526004016115ce9392919061472c565b5f61275885611a09565b905061104d33858388612e5a565b80516001600160a01b0316301480159061279c57506127836119db565b6001600160a01b0316815f01516001600160a01b031614155b6127e85760405162461bcd60e51b815260206004820152601d60248201527f5661756c743a20666f7262696464656e2072657761726420746f6b656e00000060448201526064016115ce565b620f424081608001511115610aff5760405162461bcd60e51b815260206004820152601a60248201527f5661756c743a20696e76616c69642063757261746f722066656500000000000060448201526064016115ce565b5f7f00000000000000000000000000000000000000000000000000000000000000005f848152600582016020908152604091829020855181546001600160a01b03199081166001600160a01b03928316908117845593880151600184018054831691841691909117905593870151600283018054861691831691909117905560608701516003830180549095169116179092556080850151600490920191909155909150156128fb576128f5600382018461318d565b5061290a565b6129086003820184613198565b505b7fc82113fc6fdf62b4568a32b4c4a6f82d6100e4e882f6b75559afde8a63d3d1a383834260405161293d9392919061477c565b60405180910390a1505050565b60605f610c78836131a3565b6001600160a01b0382165f8181527f0000000000000000000000000000000000000000000000000000000000000000600381016020908152604092839020805460ff19168615159081179091558351948552908401524291830191909152336060830152907fd010c5e37d148720c8d15b0b786a180ffe7dfc2f80328bdf924354969c5c13529060800161293d565b5f806129f083611c49565b905080851115612a1957828582604051633fa733bb60e21b81526004016115ce9392919061472c565b5f612a2386610be5565b9050612a3233868689856131fc565b95945050505050565b5f80612a4683611ca6565b905080851115612a6f57828582604051632e52afbb60e21b81526004016115ce9392919061472c565b5f612a7986610bc3565b9050612a32338686848a6131fc565b5f818310612a965781610c78565b5090919050565b5f610a9b825490565b5f610a9b612ab3836112a1565b5f611f53565b5f610a9b826112a1565b5f805160206149458339815191526001600160a01b038516612afa5760405163e602df0560e01b81525f60048201526024016115ce565b6001600160a01b038416612b2357604051634a1406b160e11b81525f60048201526024016115ce565b6001600160a01b038086165f90815260018301602090815260408083209388168352929052208390558115612ba057836001600160a01b0316856001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92585604051612b9791815260200190565b60405180910390a35b5050505050565b612bb1828261153a565b610aff57808260405163e2517d3f60e01b81526004016115ce9291906145b9565b5f5f80516020614965833981519152612beb848461153a565b15612c4b575f848152602082815260408083206001600160a01b0387168085529252808320805460ff1916905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a46001915050610a9b565b5f915050610a9b565b5f610c78836001600160a01b038416613551565b5f80612c75868686612603565b9050612c808361362b565b8015612c9b57505f8480612c9657612c96614768565b868809115b15612a3257612cab60018261452e565b9695505050505050565b612cbf8484611d4c565b610e8c84848484612ac3565b612cd483611bbb565b612cdd82611bbb565b610f1c838383613657565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff16612d3157604051631afcd79f60e31b815260040160405180910390fd5b565b612d3b612ce8565b612d448361377d565b612d4d826137ed565b610f1c81613859565b612d5e612ce8565b612d6b88888888886138c9565b612d7582826138f8565b612d7e8361390a565b5050505050505050565b5f5f80516020614965833981519152612da1848461153a565b612c4b575f848152602082815260408083206001600160a01b03871684529091529020805460ff19166001179055612dd63390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001915050610a9b565b5f610c78836001600160a01b03841661391b565b5f825f018281548110612e4957612e496145a5565b905f5260205f200154905092915050565b612e6684848484613967565b612e6e611318565b50505050505050565b5f816001600160a01b03166348d3b7756040518163ffffffff1660e01b8152600401602060405180830381865afa158015612eb4573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612ed8919061479e565b8015612f47575060405163794b15b760e01b81523060048201526001600160a01b0383169063794b15b790602401602060405180830381865afa158015612f21573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612f45919061479e565b155b15612f5357505f919050565b816001600160a01b031663a1b122026040518163ffffffff1660e01b8152600401602060405180830381865afa158015612f8f573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612fb3919061479e565b612fbf57505f19919050565b5f826001600160a01b031663bd49c35f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ffc573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906130209190614503565b90505f836001600160a01b031663ecf708586040518163ffffffff1660e01b8152600401602060405180830381865afa15801561305f573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906130839190614503565b9050818111156130975761104d8282614592565b505f9392505050565b5f836001600160a01b031663095ea7b384846040516024016130c39291906145b9565b604051602081830303815290604052915060e01b6020820180516001600160e01b03838183161783525050505090506130fc84826139e4565b610e8c5761312684856001600160a01b031663095ea7b3865f6040516024016126e89291906145b9565b610e8c84825b5f6131406001600160a01b03841683613a81565b905080515f14158015613164575080806020019051810190613162919061479e565b155b15610f1c57604051635274afe760e01b81526001600160a01b03841660048201526024016115ce565b5f610c78838361391b565b5f610c788383613551565b6060815f018054806020026020016040519081016040528092919081815260200182805480156131f057602002820191905f5260205f20905b8154815260200190600101908083116131dc575b50505050509050919050565b305f613206610f52565b6040516370a0823160e01b81526001600160a01b03848116600483015291909116906370a0823190602401602060405180830381865afa15801561324c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906132709190614503565b905083811061328d576132868787878787613a8e565b5050612ba0565b5f613296610c9f565b6040516370a0823160e01b81526001600160a01b03858116600483015291909116906370a0823190602401602060405180830381865afa1580156132dc573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906133009190614503565b905080156133a7575f61331661244c8488614592565b9050613320610c9f565b6001600160a01b031663f3fef3a385836040518363ffffffff1660e01b815260040161334d9291906145b9565b5f604051808303815f87803b158015613364575f80fd5b505af1158015613376573d5f803e3d5ffd5b505050508083613386919061452e565b92508583106133a55761339c8989898989613a8e565b50505050612ba0565b505b5f6133b28387614592565b90505f6133bd610f21565b90505f6133c86119db565b6001600160a01b031663f3fef3a383856040518363ffffffff1660e01b81526004016133f59291906145b9565b60408051808303815f875af1158015613410573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061343491906145d2565b60405163c8c01a5560e01b81529092506001600160a01b038416915063c8c01a5590613466908d9085906004016145b9565b5f604051808303815f87803b15801561347d575f80fd5b505af115801561348f573d5f803e3d5ffd5b50505050886001600160a01b03168b6001600160a01b0316146134b7576134b7898c89611fe8565b6134c18988613b42565b84156134e4576134e48a866134d4610f52565b6001600160a01b031691906126c2565b886001600160a01b03168a6001600160a01b03168c6001600160a01b03167ffbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db8b8b60405161353c929190918252602082015260400190565b60405180910390a45050505050505050505050565b5f8181526001830160205260408120548015612c4b575f613573600183614592565b85549091505f9061358690600190614592565b90508082146135e5575f865f0182815481106135a4576135a46145a5565b905f5260205f200154905080875f0184815481106135c4576135c46145a5565b5f918252602080832090910192909255918252600188019052604090208390555b85548690806135f6576135f66147b9565b600190038181905f5260205f20015f90559055856001015f8681526020019081526020015f205f905560019350505050610a9b565b5f6002826003811115613640576136406147cd565b61364a91906147e1565b60ff166001149050919050565b5f805160206149458339815191526001600160a01b0384166136915781816002015f828254613686919061452e565b909155506136ee9050565b6001600160a01b0384165f90815260208290526040902054828110156136d05784818460405163391434e360e21b81526004016115ce9392919061472c565b6001600160a01b0385165f9081526020839052604090209083900390555b6001600160a01b03831661370c57600281018054839003905561372a565b6001600160a01b0383165f9081526020829052604090208054830190555b826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161376f91815260200190565b60405180910390a350505050565b7f00000000000000000000000000000000000000000000000000000000000000006001810180546001600160a01b0319166001600160a01b0384161790556040517f014981eac6d147a04e1f19c72bee12af3e936e522012d172dc4b8f046c098b2690611f0590849042906145b9565b7f000000000000000000000000000000000000000000000000000000000000000080546001600160a01b0319166001600160a01b0383161781556040517f04acf1b5317814c851c2fcddea83249154878a1253de5f4317fd29457fe92a3c90611f0590849042906145b9565b7f00000000000000000000000000000000000000000000000000000000000000006002810180546001600160a01b0319166001600160a01b0384161790556040517fd9cc50299bc8a7fc6c355cb68925d176bcf358f8181473e378ae07bea50f849790611f0590849042906145b9565b6138d1612ce8565b6138d9613b76565b6138e1613b86565b6138eb5f866121a9565b50612ba084848484613b8e565b613900612ce8565b610aff8282613bba565b613912612ce8565b61127381613c0a565b5f81815260018301602052604081205461396057508154600181810184555f848152602080822090930184905584548482528286019093526040902091909155610a9b565b505f610a9b565b5f80516020614985833981519152805461398c906001600160a01b0316863086613c7a565b6139968483613cb3565b836001600160a01b0316856001600160a01b03167fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d78585604051612b97929190918252602082015260400190565b5f805f846001600160a01b0316846040516139ff919061480e565b5f604051808303815f865af19150503d805f8114613a38576040519150601f19603f3d011682016040523d82523d5f602084013e613a3d565b606091505b5091509150818015613a67575080511580613a67575080806020019051810190613a67919061479e565b8015612a325750505050506001600160a01b03163b151590565b6060610c7883835f613ce7565b5f805160206149858339815191526001600160a01b0386811690851614613aba57613aba848784611fe8565b613ac48483613b42565b8054613ada906001600160a01b031686856126c2565b836001600160a01b0316856001600160a01b0316876001600160a01b03167ffbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db8686604051613b32929190918252602082015260400190565b60405180910390a4505050505050565b6001600160a01b038216613b6b57604051634b637e8f60e11b81525f60048201526024016115ce565b610aff825f83612ccb565b613b7e612ce8565b612d31613d76565b612d31612ce8565b613b96612ce8565b613b9f84612142565b613ba883611e91565b613bb18261224a565b610e8c816121ed565b613bc2612ce8565b5f805160206149458339815191527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace03613bfb8482614868565b5060048101610e8c8382614868565b613c12612ce8565b5f805160206149858339815191525f80613c2b84613d7e565b9150915081613c3b576012613c3d565b805b83546001600160a81b031916600160a01b60ff92909216919091026001600160a01b031916176001600160a01b0394909416939093179091555050565b6040516001600160a01b038481166024830152838116604483015260648201839052610e8c9186918216906323b872dd906084016126e8565b6001600160a01b038216613cdc5760405163ec442f0560e01b81525f60048201526024016115ce565b610aff5f8383612ccb565b606081471015613d0c5760405163cd78605960e01b81523060048201526024016115ce565b5f80856001600160a01b03168486604051613d27919061480e565b5f6040518083038185875af1925050503d805f8114613d61576040519150601f19603f3d011682016040523d82523d5f602084013e613d66565b606091505b5091509150612cab868383613e54565b612328612ce8565b60408051600481526024810182526020810180516001600160e01b031663313ce56760e01b17905290515f918291829182916001600160a01b03871691613dc49161480e565b5f60405180830381855afa9150503d805f8114613dfc576040519150601f19603f3d011682016040523d82523d5f602084013e613e01565b606091505b5091509150818015613e1557506020815110155b15613e48575f81806020019051810190613e2f9190614503565b905060ff8111613e46576001969095509350505050565b505b505f9485945092505050565b606082613e6957613e6482613eb0565b610c78565b8151158015613e8057506001600160a01b0384163b155b15613ea957604051639996b31560e01b81526001600160a01b03851660048201526024016115ce565b5080610c78565b805115613ec05780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b5f60208284031215613ee9575f80fd5b81356001600160e01b031981168114610c78575f80fd5b602081525f82518060208401528060208501604085015e5f604082850101526040601f19601f83011684010191505092915050565b5f60208284031215613f45575f80fd5b5035919050565b6001600160a01b0381168114611273575f80fd5b8035613f6b81613f4c565b919050565b5f8060408385031215613f81575f80fd5b8235613f8c81613f4c565b946020939093013593505050565b5f805f60608486031215613fac575f80fd5b8335613fb781613f4c565b92506020840135613fc781613f4c565b929592945050506040919091013590565b634e487b7160e01b5f52604160045260245ffd5b604051610140810167ffffffffffffffff8111828210171561401057614010613fd8565b60405290565b8015158114611273575f80fd5b8035613f6b81614016565b5f82601f83011261403d575f80fd5b813567ffffffffffffffff8082111561405857614058613fd8565b604051601f8301601f19908116603f0116810190828211818310171561408057614080613fd8565b81604052838152866020858801011115614098575f80fd5b836020870160208301375f602085830101528094505050505092915050565b5f602082840312156140c7575f80fd5b813567ffffffffffffffff808211156140de575f80fd5b9083019061014082860312156140f2575f80fd5b6140fa613fec565b8235815261410a60208401613f60565b602082015261411b60408401613f60565b604082015261412c60608401613f60565b606082015261413d60808401613f60565b608082015261414e60a08401614023565b60a082015261415f60c08401614023565b60c082015261417060e08401614023565b60e08201526101008084013583811115614188575f80fd5b6141948882870161402e565b82840152505061012080840135838111156141ad575f80fd5b6141b98882870161402e565b918301919091525095945050505050565b5f805f606084860312156141dc575f80fd5b8335925060208401356141ee81613f4c565b915060408401356141fe81613f4c565b809150509250925092565b5f806040838503121561421a575f80fd5b82359150602083013561422c81613f4c565b809150509250929050565b5f60208284031215614247575f80fd5b8135610c7881613f4c565b5f60208284031215614262575f80fd5b8135610c7881614016565b5f806020838503121561427e575f80fd5b823567ffffffffffffffff80821115614295575f80fd5b818501915085601f8301126142a8575f80fd5b8135818111156142b6575f80fd5b8660208260051b85010111156142ca575f80fd5b60209290920196919550909350505050565b80516001600160a01b03908116835260208083015182169084015260408083015182169084015260608083015190911690830152608090810151910152565b60a08101610a9b82846142dc565b5f806040838503121561433a575f80fd5b50508035926020909101359150565b5f805f6040848603121561435b575f80fd5b83359250602084013567ffffffffffffffff80821115614379575f80fd5b818601915086601f83011261438c575f80fd5b81358181111561439a575f80fd5b8760208285010111156143ab575f80fd5b6020830194508093505050509250925092565b5f8082840360c08112156143d0575f80fd5b8335925060a0601f19820112156143e5575f80fd5b5060405160a0810181811067ffffffffffffffff8211171561440957614409613fd8565b604052602084013561441a81613f4c565b8152604084013561442a81613f4c565b6020820152606084013561443d81613f4c565b6040820152608084013561445081613f4c565b606082015260a0939093013560808401525092909150565b602080825282518282018190525f9190848201906040850190845b8181101561449f57835183529284019291840191600101614483565b50909695505050505050565b5f80604083850312156144bc575f80fd5b82356144c781613f4c565b9150602083013561422c81614016565b5f80604083850312156144e8575f80fd5b82356144f381613f4c565b9150602083013561422c81613f4c565b5f60208284031215614513575f80fd5b5051919050565b634e487b7160e01b5f52601160045260245ffd5b80820180821115610a9b57610a9b61451a565b600181811c9082168061455557607f821691505b60208210810361457357634e487b7160e01b5f52602260045260245ffd5b50919050565b60ff8181168382160190811115610a9b57610a9b61451a565b81810381811115610a9b57610a9b61451a565b634e487b7160e01b5f52603260045260245ffd5b6001600160a01b03929092168252602082015260400190565b5f80604083850312156145e3575f80fd5b505080516020909101519092909150565b6001600160a01b0385811682528416602082015260606040820181905281018290525f828460808401375f608084840101526080601f19601f850116830101905095945050505050565b600181815b8085111561467857815f190482111561465e5761465e61451a565b8085161561466b57918102915b93841c9390800290614643565b509250929050565b5f8261468e57506001610a9b565b8161469a57505f610a9b565b81600181146146b057600281146146ba576146d6565b6001915050610a9b565b60ff8411156146cb576146cb61451a565b50506001821b610a9b565b5060208310610133831016604e8410600b84101617156146f9575081810a610a9b565b614703838361463e565b805f19048211156147165761471661451a565b029392505050565b5f610c7860ff841683614680565b6001600160a01b039390931683526020830191909152604082015260600190565b5f6020828403121561475d575f80fd5b8151610c7881613f4c565b634e487b7160e01b5f52601260045260245ffd5b83815260e0810161479060208301856142dc565b8260c0830152949350505050565b5f602082840312156147ae575f80fd5b8151610c7881614016565b634e487b7160e01b5f52603160045260245ffd5b634e487b7160e01b5f52602160045260245ffd5b5f60ff8316806147ff57634e487b7160e01b5f52601260045260245ffd5b8060ff84160691505092915050565b5f82518060208501845e5f920191825250919050565b601f821115610f1c57805f5260205f20601f840160051c810160208510156148495750805b601f840160051c820191505b81811015612ba0575f8155600101614855565b815167ffffffffffffffff81111561488257614882613fd8565b614896816148908454614541565b84614824565b602080601f8311600181146148c9575f84156148b25750858301515b5f19600386901b1c1916600185901b178555610dd6565b5f85815260208120601f198616915b828110156148f7578886015182559484019460019091019084016148d8565b508582101561491457878501515f19600388901b60f8161c191681555b5050505050600190811b0190555056fec1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e8237170593200052c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0002dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268000773e532dfede91f04b12a73d3d2acd361424f41f76b4fb79f090161e36b4e009b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00a26469706673582212208a2149ba417dba06573f99d5e9e705d04212ac91f02878db7148b0cc8a55fdb964736f6c634300081900334d656c6c6f7753796d62696f7469635661756c740000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
Deployed Bytecode
0x608060405234801561000f575f80fd5b50600436106103e0575f3560e01c8063794b15b71161020b578063b460af941161011f578063ce96cb77116100b4578063e3ab43b111610084578063e3ab43b1146108cf578063e4c4be58146108e2578063e7beaf9d146108ea578063ef8b30f714610817578063fb378bdb146108fd575f80fd5b8063ce96cb7714610883578063d547741f14610896578063d905777e146108a9578063dd62ed3e146108bc575f80fd5b8063c6e6f592116100ef578063c6e6f59214610817578063c84aae171461082a578063ca15c8731461085d578063ce5494bb14610870575f80fd5b8063b460af94146107af578063ba087652146107c2578063c19a2aa7146107d5578063c63d75b614610804575f80fd5b80639cab081d116101a0578063a4d66daf11610170578063a4d66daf1461074f578063a9059cbb14610779578063a97ba2311461078c578063aa50ea9214610794578063b3d7f6b91461079c575f80fd5b80639cab081d1461070d578063a084537014610720578063a217fddf14610735578063a28614661461073c575f80fd5b8063922bafd0116101db578063922bafd0146106cc57806394bf804d146106df57806395d89b41146106f2578063996cba68146106fa575f80fd5b8063794b15b7146106705780637980c9eb146106835780639010d07c146106a657806391d14854146106b9575f80fd5b8063313ce5671161030257806348d3b7751161029757806363c6b4eb1161026757806363c6b4eb1461060557806363d8882a146106185780636e22558d146106205780636e553f651461064a57806370a082311461065d575f80fd5b806348d3b775146105b05780634cdad5061461044157806356bb54a7146105dd5780635e02e8df146105e5575f80fd5b806338d52e0f116102d257806338d52e0f1461056f578063402d267d146105775780634105a7dd1461058a5780634655d6391461059d575f80fd5b8063313ce5671461052757806333788f9a1461054157806336568abe1461055457806337d5fe9914610567575f80fd5b806318160ddd116103785780632774fa0c116103485780632774fa0c146104db57806327ea6f2b146104ee5780632e2d2984146105015780632f2ff15d14610514575f80fd5b806318160ddd1461048d57806323b872dd14610495578063248a9ca3146104a85780632554004f146104bb575f80fd5b806307a2d13a116103b357806307a2d13a14610441578063095ea7b3146104545780630a28a4771461046757806316ddfb011461047a575f80fd5b806301e1d114146103e457806301ffc9a7146103ff578063021919801461042257806306fdde031461042c575b5f80fd5b6103ec610905565b6040519081526020015b60405180910390f35b61041261040d366004613ed9565b610a77565b60405190151581526020016103f6565b61042a610aa1565b005b610434610b03565b6040516103f69190613f00565b6103ec61044f366004613f35565b610bc3565b610412610462366004613f70565b610bce565b6103ec610475366004613f35565b610be5565b610412610488366004613f35565b610bf1565b6103ec610c1f565b6104126104a3366004613f9a565b610c5a565b6103ec6104b6366004613f35565b610c7f565b6104c3610c9f565b6040516001600160a01b0390911681526020016103f6565b61042a6104e93660046140b7565b610cd0565b61042a6104fc366004613f35565b610dde565b6103ec61050f3660046141ca565b610e11565b61042a610522366004614209565b610e70565b61052f610e92565b60405160ff90911681526020016103f6565b6103ec61054f366004613f35565b610ebb565b61042a610562366004614209565b610ee9565b6104c3610f21565b6104c3610f52565b6103ec610585366004614237565b610f6d565b61042a610598366004614252565b611055565b61042a6105ab36600461426d565b611088565b7fa858eff8d4a594e29044957ecc047944ae303c967a7fc403b7c7fdb726ba9e006002015460ff16610412565b61042a6110c4565b6105f86105f3366004613f35565b611122565b6040516103f6919061431b565b6103ec610613366004614237565b6111cc565b61042a611240565b7fa858eff8d4a594e29044957ecc047944ae303c967a7fc403b7c7fdb726ba9e005460ff16610412565b6103ec610658366004614209565b611276565b6103ec61066b366004614237565b6112a1565b61041261067e366004614237565b6112d9565b61068b611318565b604080519384526020840192909252908201526060016103f6565b6104c36106b4366004614329565b611515565b6104126106c7366004614209565b61153a565b61042a6106da366004614349565b611570565b6103ec6106ed366004614209565b6117ef565b610434611802565b6103ec610708366004613f9a565b611840565b61042a61071b3660046143be565b61192e565b61072861196c565b6040516103f69190614468565b6103ec5f81565b61042a61074a3660046144ab565b61199a565b7fa858eff8d4a594e29044957ecc047944ae303c967a7fc403b7c7fdb726ba9e00600101546103ec565b610412610787366004613f70565b6119ce565b6002546103ec565b6104c36119db565b6103ec6107aa366004613f35565b611a09565b6103ec6107bd3660046141ca565b611a15565b6103ec6107d03660046141ca565b611a29565b7fa858eff8d4a594e29044957ecc047944ae303c967a7fc403b7c7fdb726ba9e0054610100900460ff16610412565b6103ec610812366004614237565b611a3d565b6103ec610825366004613f35565b611a60565b61083d610838366004614237565b611a6b565b6040805194855260208501939093529183015260608201526080016103f6565b6103ec61086b366004613f35565b611b97565b61042a61087e366004614237565b611bbb565b6103ec610891366004614237565b611c49565b61042a6108a4366004614209565b611c8a565b6103ec6108b7366004614237565b611ca6565b6103ec6108ca3660046144d7565b611ce7565b61042a6108dd3660046144d7565b611d4c565b61042a611dba565b6103ec6108f8366004614237565b611ded565b6103ec611e26565b5f3061090f6119db565b6040516359f769a960e01b81526001600160a01b03838116600483015291909116906359f769a990602401602060405180830381865afa158015610955573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109799190614503565b610981610c9f565b6040516370a0823160e01b81526001600160a01b03848116600483015291909116906370a0823190602401602060405180830381865afa1580156109c7573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109eb9190614503565b6109f3610f52565b6040516370a0823160e01b81526001600160a01b03858116600483015291909116906370a0823190602401602060405180830381865afa158015610a39573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a5d9190614503565b610a67919061452e565b610a71919061452e565b91505090565b5f6001600160e01b03198216635a05180f60e01b1480610a9b5750610a9b82611e53565b92915050565b7fb0cb335afe1cba10c746b42a1e019651022572bbc76c3f63338df5dd3abb9894610acb81611e87565b610ad56001611e91565b610aff7fb0cb335afe1cba10c746b42a1e019651022572bbc76c3f63338df5dd3abb989433611f11565b5050565b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0380546060915f8051602061494583398151915291610b4190614541565b80601f0160208091040260200160405190810160405280929190818152602001828054610b6d90614541565b8015610bb85780601f10610b8f57610100808354040283529160200191610bb8565b820191905f5260205f20905b815481529060010190602001808311610b9b57829003601f168201915b505050505091505090565b5f610a9b825f611f53565b5f33610bdb818585611f90565b5060019392505050565b5f610a9b826001611f9d565b5f610a9b60037f02851e4af24dcfb1130545553490b405c8a48a0f50eb9a053c1e5e7dbe1628000183611fd1565b5f610c487f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace025490565b600254610c55919061452e565b905090565b5f33610c67858285611fe8565b610c72858585612032565b60019150505b9392505050565b5f9081525f80516020614965833981519152602052604090206001015490565b60017f02851e4af24dcfb1130545553490b405c8a48a0f50eb9a053c1e5e7dbe16280001546001600160a01b031690565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff16159067ffffffffffffffff165f81158015610d155750825b90505f8267ffffffffffffffff166001148015610d315750303b155b905081158015610d3f575080155b15610d5d5760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff191660011785558315610d8757845460ff60401b1916600160401b1785555b610d908661208f565b8315610dd657845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b505050505050565b7f6e5811d60b7d57973a97208b6158fed3b8e064ca747403e6a8c81f56a8f9e75f610e0881611e87565b610aff82612142565b5f610e1c8484611276565b604080518681526001600160a01b03868116602083015285168183015290519192507f0f33e518e0001973b4f02d7cef360e8c9290e9ebd0b48695c935af9bac850213919081900360600190a19392505050565b610e7982610c7f565b610e8281611e87565b610e8c83836121a9565b50505050565b5f805f8051602061498583398151915290505f8154610a719190600160a01b900460ff16614579565b5f610a9b60037f02851e4af24dcfb1130545553490b405c8a48a0f50eb9a053c1e5e7dbe16280001836121e2565b6001600160a01b0381163314610f125760405163334bd91960e11b815260040160405180910390fd5b610f1c8282611f11565b505050565b60027f02851e4af24dcfb1130545553490b405c8a48a0f50eb9a053c1e5e7dbe16280001546001600160a01b031690565b5f80516020614985833981519152546001600160a01b031690565b5f610f997fa858eff8d4a594e29044957ecc047944ae303c967a7fc403b7c7fdb726ba9e005460ff1690565b15610fa557505f919050565b7fa858eff8d4a594e29044957ecc047944ae303c967a7fc403b7c7fdb726ba9e006002015460ff168015610fdf5750610fdd826112d9565b155b15610feb57505f919050565b5f61101760017fa858eff8d4a594e29044957ecc047944ae303c967a7fc403b7c7fdb726ba9e00015490565b90505f19810361102a57505f1992915050565b5f611033610905565b905080821015611043575f61104d565b61104d8183614592565b949350505050565b7f1b628514858a9a09af73c606e9892743b44cfbdd0c49a7279286ed58eaafcf6d61107f81611e87565b610aff826121ed565b5f5b81811015610f1c576110bc8383838181106110a7576110a76145a5565b905060200201602081019061087e9190614237565b60010161108a565b7ffd367f64dba4612ce1d6ed7e93d2495a59d305f21fba3e15126e1ad62aa9ea156110ee81611e87565b6110f8600161224a565b610aff7ffd367f64dba4612ce1d6ed7e93d2495a59d305f21fba3e15126e1ad62aa9ea1533611f11565b6040805160a0810182525f808252602082018190529181018290526060810182905260808101919091527f02851e4af24dcfb1130545553490b405c8a48a0f50eb9a053c1e5e7dbe1628005f9283526005016020908152604092839020835160a08101855281546001600160a01b03908116825260018301548116938201939093526002820154831694810194909452600381015490911660608401526004015460808301525090565b5f6111d5610f21565b6040516363c6b4eb60e01b81526001600160a01b03848116600483015291909116906363c6b4eb906024015b602060405180830381865afa15801561121c573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a9b9190614503565b7f49604999f0c13f9a566b3eb2608f60c199b1a3a43d8ff8032fe66a465c945d1d61126a81611e87565b6112735f611e91565b50565b5f61127f6122a5565b61128983836122dc565b9050610a9b60015f805160206149a583398151915255565b6001600160a01b0381165f9081525f80516020614945833981519152602090815260408083205491839052822054610a9b919061452e565b6001600160a01b03165f90815260037fa858eff8d4a594e29044957ecc047944ae303c967a7fc403b7c7fdb726ba9e0001602052604090205460ff1690565b5f805f80611324610f52565b90505f61132f610c9f565b90505f61133a6119db565b90503061134884848461233b565b9198509650945086156113b15760405163f3fef3a360e01b81526001600160a01b0384169063f3fef3a3906113839084908b906004016145b9565b5f604051808303815f87803b15801561139a575f80fd5b505af11580156113ac573d5f803e3d5ffd5b505050505b851561143b576113cb6001600160a01b038516848861257c565b6040516311f9fbc960e21b81526001600160a01b038416906347e7ef24906113f99084908a906004016145b9565b6020604051808303815f875af1158015611415573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906114399190614503565b505b84156114c5576114556001600160a01b038516838761257c565b6040516311f9fbc960e21b81526001600160a01b038316906347e7ef249061148390849089906004016145b9565b60408051808303815f875af115801561149e573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906114c291906145d2565b50505b60408051338152602081018990528082018890526060810187905290517fb53c38f4658baac1058d6b81869ed82ea19a0b0123b440e23e9b54cd98d4720d9181900360800190a150505050909192565b5f8281525f8051602061492583398151915260208190526040822061104d90846121e2565b5f9182525f80516020614965833981519152602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6115786122a5565b5f61158284611122565b80519091506001600160a01b03166115d75760405162461bcd60e51b815260206004820152601360248201527215985d5b1d0e8819985c9b481b9bdd081cd95d606a1b60448201526064015b60405180910390fd5b80516040516370a0823160e01b81523060048201525f906001600160a01b038316906370a0823190602401602060405180830381865afa15801561161d573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906116419190614503565b6020840151604051635d0b520560e01b81529192506001600160a01b031690635d0b52059061167a90309086908a908a906004016145f4565b5f604051808303815f87803b158015611691575f80fd5b505af11580156116a3573d5f803e3d5ffd5b50506040516370a0823160e01b81523060048201525f92508391506001600160a01b038516906370a0823190602401602060405180830381865afa1580156116ed573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906117119190614503565b61171b9190614592565b9050805f0361172d57505050506117d9565b60808401515f90611743908390620f4240612603565b90508015611765576060850151611765906001600160a01b03861690836126c2565b61176f8183614592565b91508115611791576040850151611791906001600160a01b03861690846126c2565b60408051838152602081018390524281830152905189917f12d8e9280ac85b1633cd74c52f9458f73459aecd6eb0f2d99e2ed27c3fa27e99919081900360600190a250505050505b610f1c60015f805160206149a583398151915255565b5f6117f86122a5565b611289838361271a565b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0480546060915f8051602061494583398151915291610b4190614541565b5f6118496122a5565b6001600160a01b03841633146118945760405162461bcd60e51b815260206004820152601060248201526f2b30bab63a1d103337b93134b23232b760811b60448201526064016115ce565b61189c610f21565b60405163132d974d60e31b81526001600160a01b038681166004830152858116602483015260448201859052919091169063996cba68906064016020604051808303815f875af11580156118f2573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906119169190614503565b9050610c7860015f805160206149a583398151915255565b7f4c30aa7f742e0a14ed7755cb202fc37abe01363d805182186c7cfe8f8a15d64c61195881611e87565b6119628383612766565b610f1c838361283f565b6060610c557f02851e4af24dcfb1130545553490b405c8a48a0f50eb9a053c1e5e7dbe16280060030161294a565b7f1867ae69910bc7238ccbbb445aa11a0dbdd472b851b7fac0c991101aca0a360d6119c481611e87565b610f1c8383612956565b5f33610bdb818585612032565b7f02851e4af24dcfb1130545553490b405c8a48a0f50eb9a053c1e5e7dbe162800546001600160a01b031690565b5f610a9b826001611f53565b5f611a1e6122a5565b6119168484846129e5565b5f611a326122a5565b611916848484612a3b565b5f80611a4883610f6d565b90505f198103611a5b57505f1992915050565b610c78815b5f610a9b825f611f9d565b5f8080803081611a79610c9f565b6040516370a0823160e01b81526001600160a01b03848116600483015291909116906370a0823190602401602060405180830381865afa158015611abf573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611ae39190614503565b611aeb610f52565b6040516370a0823160e01b81526001600160a01b03858116600483015291909116906370a0823190602401602060405180830381865afa158015611b31573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611b559190614503565b611b5f919061452e565b9050611b6a876112a1565b9350611b7584610bc3565b9550611b818682612a88565b9450611b8c85611a60565b925050509193509193565b5f8181525f80516020614925833981519152602081905260408220610c7890612a9d565b6001600160a01b0381165f90815260208190526040812054808203611bdf57505050565b6001600160a01b03929092165f908152602082815260408083208390555f805160206149458339815191529091529020805483019055600201805482900390557f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0280549091019055565b7fa858eff8d4a594e29044957ecc047944ae303c967a7fc403b7c7fdb726ba9e00545f90610100900460ff1615611c8157505f919050565b610a9b82612aa6565b611c9382610c7f565b611c9c81611e87565b610e8c8383611f11565b7fa858eff8d4a594e29044957ecc047944ae303c967a7fc403b7c7fdb726ba9e00545f90610100900460ff1615611cde57505f919050565b610a9b82612ab9565b6001600160a01b038281165f8181527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0160209081526040808320948616808452948252808320549383526001825280832094835293905291822054610c78919061452e565b6001600160a01b038281165f908152600160209081526040808320938516835292905290812054808203611d805750505050565b6001600160a01b038085165f90815260018401602090815260408083209387168352929052908120819055610e8c90859085908490612ac3565b7f8233fa2806b76ee3f3ba048be2bf735b5c73b63051394e82774bfd7be0db6c02611de481611e87565b6112735f61224a565b5f611df6610f21565b60405163e7beaf9d60e01b81526001600160a01b038481166004830152919091169063e7beaf9d90602401611201565b5f610c557f02851e4af24dcfb1130545553490b405c8a48a0f50eb9a053c1e5e7dbe162800600301612a9d565b5f6001600160e01b03198216637965db0b60e01b1480610a9b57506301ffc9a760e01b6001600160e01b0319831614610a9b565b6112738133612ba7565b7fa858eff8d4a594e29044957ecc047944ae303c967a7fc403b7c7fdb726ba9e00805460ff19168215151781557f917e249a9d1439adce72cf39ffef9f3ae18f5b7b37a942393522093db79826c48242335b60408051931515845260208401929092526001600160a01b0316908201526060015b60405180910390a15050565b5f5f8051602061492583398151915281611f2b8585612bd2565b9050801561104d575f858152602083905260409020611f4a9085612c54565b50949350505050565b5f610c78611f5f610905565b611f6a90600161452e565b611f755f600a61471e565b611f7d610c1f565b611f87919061452e565b85919085612c68565b610f1c8383836001612cb5565b5f610c78611fac82600a61471e565b611fb4610c1f565b611fbe919061452e565b611fc6610905565b611f8790600161452e565b5f8181526001830160205260408120541515610c78565b5f611ff38484611ce7565b90505f198114610e8c578181101561202457828183604051637dc7a0d960e11b81526004016115ce9392919061472c565b610e8c84848484035f612cb5565b6001600160a01b03831661205b57604051634b637e8f60e11b81525f60048201526024016115ce565b6001600160a01b0382166120845760405163ec442f0560e01b81525f60048201526024016115ce565b610f1c838383612ccb565b612097612ce8565b5f81604001516001600160a01b031663d8dfeb456040518163ffffffff1660e01b8152600401602060405180830381865afa1580156120d8573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906120fc919061474d565b9050612115826020015183604001518460600151612d33565b610aff8260800151835f01518460a001518560c001518660e0015186886101000151896101200151612d56565b7fa858eff8d4a594e29044957ecc047944ae303c967a7fc403b7c7fdb726ba9e00600181018290556040805183815242602082015233918101919091527f085b30415f63cd5f875aa6df7b116b64821bdea341dabcb10c94f1cc997138d990606001611f05565b5f5f80516020614925833981519152816121c38585612d88565b9050801561104d575f858152602083905260409020611f4a9085612e20565b5f610c788383612e34565b5f7fa858eff8d4a594e29044957ecc047944ae303c967a7fc403b7c7fdb726ba9e0060028101805460ff191684151517905590507ffbf9c5de1d63473d377197b4f8bbe7d49c129878194966479bcd64085ad32c55824233611ee3565b7fa858eff8d4a594e29044957ecc047944ae303c967a7fc403b7c7fdb726ba9e00805461ff001916610100831515021781557f100e52ba225b1d864d8b4e3725311b44dc3d490024db41251211c87c20da20a7824233611ee3565b5f805160206149a58339815191528054600119016122d657604051633ee5aeb560e01b815260040160405180910390fd5b60029055565b5f806122e783610f6d565b90508084111561231057828482604051633c8097d960e11b81526004016115ce9392919061472c565b5f61231a85611a60565b905061104d33858784612e5a565b60015f805160206149a583398151915255565b6040516370a0823160e01b815230600482018190525f918291829182906001600160a01b038916906370a0823190602401602060405180830381865afa158015612387573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906123ab9190614503565b6040516370a0823160e01b81526001600160a01b0384811660048301529192505f918916906370a0823190602401602060405180830381865afa1580156123f4573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906124189190614503565b90505f61242488612e77565b9050801561248157808310801561243a57508115155b156124625761245361244c8483614592565b8390612a88565b965061245f878461452e565b92505b8215612481576124728382612a88565b945061247e8584614592565b92505b821561256f575f896001600160a01b031663a4d66daf6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156124c4573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906124e89190614503565b90505f8a6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612527573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061254b9190614503565b90508082111561256c576125696125628284614592565b8690612a88565b97505b50505b5050505093509350939050565b604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301525f919085169063dd62ed3e90604401602060405180830381865afa1580156125c9573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906125ed9190614503565b9050610e8c84846125fe858561452e565b6130a0565b5f838302815f1985870982811083820303915050805f036126375783828161262d5761262d614768565b0492505050610c78565b8084116126575760405163227bc15360e01b815260040160405180910390fd5b5f848688095f868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b610f1c83846001600160a01b031663a9059cbb85856040516024016126e89291906145b9565b604051602081830303815290604052915060e01b6020820180516001600160e01b03838183161783525050505061312c565b5f8061272583611a3d565b90508084111561274e5782848260405163284ff66760e01b81526004016115ce9392919061472c565b5f61275885611a09565b905061104d33858388612e5a565b80516001600160a01b0316301480159061279c57506127836119db565b6001600160a01b0316815f01516001600160a01b031614155b6127e85760405162461bcd60e51b815260206004820152601d60248201527f5661756c743a20666f7262696464656e2072657761726420746f6b656e00000060448201526064016115ce565b620f424081608001511115610aff5760405162461bcd60e51b815260206004820152601a60248201527f5661756c743a20696e76616c69642063757261746f722066656500000000000060448201526064016115ce565b5f7f02851e4af24dcfb1130545553490b405c8a48a0f50eb9a053c1e5e7dbe1628005f848152600582016020908152604091829020855181546001600160a01b03199081166001600160a01b03928316908117845593880151600184018054831691841691909117905593870151600283018054861691831691909117905560608701516003830180549095169116179092556080850151600490920191909155909150156128fb576128f5600382018461318d565b5061290a565b6129086003820184613198565b505b7fc82113fc6fdf62b4568a32b4c4a6f82d6100e4e882f6b75559afde8a63d3d1a383834260405161293d9392919061477c565b60405180910390a1505050565b60605f610c78836131a3565b6001600160a01b0382165f8181527fa858eff8d4a594e29044957ecc047944ae303c967a7fc403b7c7fdb726ba9e00600381016020908152604092839020805460ff19168615159081179091558351948552908401524291830191909152336060830152907fd010c5e37d148720c8d15b0b786a180ffe7dfc2f80328bdf924354969c5c13529060800161293d565b5f806129f083611c49565b905080851115612a1957828582604051633fa733bb60e21b81526004016115ce9392919061472c565b5f612a2386610be5565b9050612a3233868689856131fc565b95945050505050565b5f80612a4683611ca6565b905080851115612a6f57828582604051632e52afbb60e21b81526004016115ce9392919061472c565b5f612a7986610bc3565b9050612a32338686848a6131fc565b5f818310612a965781610c78565b5090919050565b5f610a9b825490565b5f610a9b612ab3836112a1565b5f611f53565b5f610a9b826112a1565b5f805160206149458339815191526001600160a01b038516612afa5760405163e602df0560e01b81525f60048201526024016115ce565b6001600160a01b038416612b2357604051634a1406b160e11b81525f60048201526024016115ce565b6001600160a01b038086165f90815260018301602090815260408083209388168352929052208390558115612ba057836001600160a01b0316856001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92585604051612b9791815260200190565b60405180910390a35b5050505050565b612bb1828261153a565b610aff57808260405163e2517d3f60e01b81526004016115ce9291906145b9565b5f5f80516020614965833981519152612beb848461153a565b15612c4b575f848152602082815260408083206001600160a01b0387168085529252808320805460ff1916905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a46001915050610a9b565b5f915050610a9b565b5f610c78836001600160a01b038416613551565b5f80612c75868686612603565b9050612c808361362b565b8015612c9b57505f8480612c9657612c96614768565b868809115b15612a3257612cab60018261452e565b9695505050505050565b612cbf8484611d4c565b610e8c84848484612ac3565b612cd483611bbb565b612cdd82611bbb565b610f1c838383613657565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff16612d3157604051631afcd79f60e31b815260040160405180910390fd5b565b612d3b612ce8565b612d448361377d565b612d4d826137ed565b610f1c81613859565b612d5e612ce8565b612d6b88888888886138c9565b612d7582826138f8565b612d7e8361390a565b5050505050505050565b5f5f80516020614965833981519152612da1848461153a565b612c4b575f848152602082815260408083206001600160a01b03871684529091529020805460ff19166001179055612dd63390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001915050610a9b565b5f610c78836001600160a01b03841661391b565b5f825f018281548110612e4957612e496145a5565b905f5260205f200154905092915050565b612e6684848484613967565b612e6e611318565b50505050505050565b5f816001600160a01b03166348d3b7756040518163ffffffff1660e01b8152600401602060405180830381865afa158015612eb4573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612ed8919061479e565b8015612f47575060405163794b15b760e01b81523060048201526001600160a01b0383169063794b15b790602401602060405180830381865afa158015612f21573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612f45919061479e565b155b15612f5357505f919050565b816001600160a01b031663a1b122026040518163ffffffff1660e01b8152600401602060405180830381865afa158015612f8f573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612fb3919061479e565b612fbf57505f19919050565b5f826001600160a01b031663bd49c35f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ffc573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906130209190614503565b90505f836001600160a01b031663ecf708586040518163ffffffff1660e01b8152600401602060405180830381865afa15801561305f573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906130839190614503565b9050818111156130975761104d8282614592565b505f9392505050565b5f836001600160a01b031663095ea7b384846040516024016130c39291906145b9565b604051602081830303815290604052915060e01b6020820180516001600160e01b03838183161783525050505090506130fc84826139e4565b610e8c5761312684856001600160a01b031663095ea7b3865f6040516024016126e89291906145b9565b610e8c84825b5f6131406001600160a01b03841683613a81565b905080515f14158015613164575080806020019051810190613162919061479e565b155b15610f1c57604051635274afe760e01b81526001600160a01b03841660048201526024016115ce565b5f610c78838361391b565b5f610c788383613551565b6060815f018054806020026020016040519081016040528092919081815260200182805480156131f057602002820191905f5260205f20905b8154815260200190600101908083116131dc575b50505050509050919050565b305f613206610f52565b6040516370a0823160e01b81526001600160a01b03848116600483015291909116906370a0823190602401602060405180830381865afa15801561324c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906132709190614503565b905083811061328d576132868787878787613a8e565b5050612ba0565b5f613296610c9f565b6040516370a0823160e01b81526001600160a01b03858116600483015291909116906370a0823190602401602060405180830381865afa1580156132dc573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906133009190614503565b905080156133a7575f61331661244c8488614592565b9050613320610c9f565b6001600160a01b031663f3fef3a385836040518363ffffffff1660e01b815260040161334d9291906145b9565b5f604051808303815f87803b158015613364575f80fd5b505af1158015613376573d5f803e3d5ffd5b505050508083613386919061452e565b92508583106133a55761339c8989898989613a8e565b50505050612ba0565b505b5f6133b28387614592565b90505f6133bd610f21565b90505f6133c86119db565b6001600160a01b031663f3fef3a383856040518363ffffffff1660e01b81526004016133f59291906145b9565b60408051808303815f875af1158015613410573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061343491906145d2565b60405163c8c01a5560e01b81529092506001600160a01b038416915063c8c01a5590613466908d9085906004016145b9565b5f604051808303815f87803b15801561347d575f80fd5b505af115801561348f573d5f803e3d5ffd5b50505050886001600160a01b03168b6001600160a01b0316146134b7576134b7898c89611fe8565b6134c18988613b42565b84156134e4576134e48a866134d4610f52565b6001600160a01b031691906126c2565b886001600160a01b03168a6001600160a01b03168c6001600160a01b03167ffbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db8b8b60405161353c929190918252602082015260400190565b60405180910390a45050505050505050505050565b5f8181526001830160205260408120548015612c4b575f613573600183614592565b85549091505f9061358690600190614592565b90508082146135e5575f865f0182815481106135a4576135a46145a5565b905f5260205f200154905080875f0184815481106135c4576135c46145a5565b5f918252602080832090910192909255918252600188019052604090208390555b85548690806135f6576135f66147b9565b600190038181905f5260205f20015f90559055856001015f8681526020019081526020015f205f905560019350505050610a9b565b5f6002826003811115613640576136406147cd565b61364a91906147e1565b60ff166001149050919050565b5f805160206149458339815191526001600160a01b0384166136915781816002015f828254613686919061452e565b909155506136ee9050565b6001600160a01b0384165f90815260208290526040902054828110156136d05784818460405163391434e360e21b81526004016115ce9392919061472c565b6001600160a01b0385165f9081526020839052604090209083900390555b6001600160a01b03831661370c57600281018054839003905561372a565b6001600160a01b0383165f9081526020829052604090208054830190555b826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161376f91815260200190565b60405180910390a350505050565b7f02851e4af24dcfb1130545553490b405c8a48a0f50eb9a053c1e5e7dbe1628006001810180546001600160a01b0319166001600160a01b0384161790556040517f014981eac6d147a04e1f19c72bee12af3e936e522012d172dc4b8f046c098b2690611f0590849042906145b9565b7f02851e4af24dcfb1130545553490b405c8a48a0f50eb9a053c1e5e7dbe16280080546001600160a01b0319166001600160a01b0383161781556040517f04acf1b5317814c851c2fcddea83249154878a1253de5f4317fd29457fe92a3c90611f0590849042906145b9565b7f02851e4af24dcfb1130545553490b405c8a48a0f50eb9a053c1e5e7dbe1628006002810180546001600160a01b0319166001600160a01b0384161790556040517fd9cc50299bc8a7fc6c355cb68925d176bcf358f8181473e378ae07bea50f849790611f0590849042906145b9565b6138d1612ce8565b6138d9613b76565b6138e1613b86565b6138eb5f866121a9565b50612ba084848484613b8e565b613900612ce8565b610aff8282613bba565b613912612ce8565b61127381613c0a565b5f81815260018301602052604081205461396057508154600181810184555f848152602080822090930184905584548482528286019093526040902091909155610a9b565b505f610a9b565b5f80516020614985833981519152805461398c906001600160a01b0316863086613c7a565b6139968483613cb3565b836001600160a01b0316856001600160a01b03167fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d78585604051612b97929190918252602082015260400190565b5f805f846001600160a01b0316846040516139ff919061480e565b5f604051808303815f865af19150503d805f8114613a38576040519150601f19603f3d011682016040523d82523d5f602084013e613a3d565b606091505b5091509150818015613a67575080511580613a67575080806020019051810190613a67919061479e565b8015612a325750505050506001600160a01b03163b151590565b6060610c7883835f613ce7565b5f805160206149858339815191526001600160a01b0386811690851614613aba57613aba848784611fe8565b613ac48483613b42565b8054613ada906001600160a01b031686856126c2565b836001600160a01b0316856001600160a01b0316876001600160a01b03167ffbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db8686604051613b32929190918252602082015260400190565b60405180910390a4505050505050565b6001600160a01b038216613b6b57604051634b637e8f60e11b81525f60048201526024016115ce565b610aff825f83612ccb565b613b7e612ce8565b612d31613d76565b612d31612ce8565b613b96612ce8565b613b9f84612142565b613ba883611e91565b613bb18261224a565b610e8c816121ed565b613bc2612ce8565b5f805160206149458339815191527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace03613bfb8482614868565b5060048101610e8c8382614868565b613c12612ce8565b5f805160206149858339815191525f80613c2b84613d7e565b9150915081613c3b576012613c3d565b805b83546001600160a81b031916600160a01b60ff92909216919091026001600160a01b031916176001600160a01b0394909416939093179091555050565b6040516001600160a01b038481166024830152838116604483015260648201839052610e8c9186918216906323b872dd906084016126e8565b6001600160a01b038216613cdc5760405163ec442f0560e01b81525f60048201526024016115ce565b610aff5f8383612ccb565b606081471015613d0c5760405163cd78605960e01b81523060048201526024016115ce565b5f80856001600160a01b03168486604051613d27919061480e565b5f6040518083038185875af1925050503d805f8114613d61576040519150601f19603f3d011682016040523d82523d5f602084013e613d66565b606091505b5091509150612cab868383613e54565b612328612ce8565b60408051600481526024810182526020810180516001600160e01b031663313ce56760e01b17905290515f918291829182916001600160a01b03871691613dc49161480e565b5f60405180830381855afa9150503d805f8114613dfc576040519150601f19603f3d011682016040523d82523d5f602084013e613e01565b606091505b5091509150818015613e1557506020815110155b15613e48575f81806020019051810190613e2f9190614503565b905060ff8111613e46576001969095509350505050565b505b505f9485945092505050565b606082613e6957613e6482613eb0565b610c78565b8151158015613e8057506001600160a01b0384163b155b15613ea957604051639996b31560e01b81526001600160a01b03851660048201526024016115ce565b5080610c78565b805115613ec05780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b5f60208284031215613ee9575f80fd5b81356001600160e01b031981168114610c78575f80fd5b602081525f82518060208401528060208501604085015e5f604082850101526040601f19601f83011684010191505092915050565b5f60208284031215613f45575f80fd5b5035919050565b6001600160a01b0381168114611273575f80fd5b8035613f6b81613f4c565b919050565b5f8060408385031215613f81575f80fd5b8235613f8c81613f4c565b946020939093013593505050565b5f805f60608486031215613fac575f80fd5b8335613fb781613f4c565b92506020840135613fc781613f4c565b929592945050506040919091013590565b634e487b7160e01b5f52604160045260245ffd5b604051610140810167ffffffffffffffff8111828210171561401057614010613fd8565b60405290565b8015158114611273575f80fd5b8035613f6b81614016565b5f82601f83011261403d575f80fd5b813567ffffffffffffffff8082111561405857614058613fd8565b604051601f8301601f19908116603f0116810190828211818310171561408057614080613fd8565b81604052838152866020858801011115614098575f80fd5b836020870160208301375f602085830101528094505050505092915050565b5f602082840312156140c7575f80fd5b813567ffffffffffffffff808211156140de575f80fd5b9083019061014082860312156140f2575f80fd5b6140fa613fec565b8235815261410a60208401613f60565b602082015261411b60408401613f60565b604082015261412c60608401613f60565b606082015261413d60808401613f60565b608082015261414e60a08401614023565b60a082015261415f60c08401614023565b60c082015261417060e08401614023565b60e08201526101008084013583811115614188575f80fd5b6141948882870161402e565b82840152505061012080840135838111156141ad575f80fd5b6141b98882870161402e565b918301919091525095945050505050565b5f805f606084860312156141dc575f80fd5b8335925060208401356141ee81613f4c565b915060408401356141fe81613f4c565b809150509250925092565b5f806040838503121561421a575f80fd5b82359150602083013561422c81613f4c565b809150509250929050565b5f60208284031215614247575f80fd5b8135610c7881613f4c565b5f60208284031215614262575f80fd5b8135610c7881614016565b5f806020838503121561427e575f80fd5b823567ffffffffffffffff80821115614295575f80fd5b818501915085601f8301126142a8575f80fd5b8135818111156142b6575f80fd5b8660208260051b85010111156142ca575f80fd5b60209290920196919550909350505050565b80516001600160a01b03908116835260208083015182169084015260408083015182169084015260608083015190911690830152608090810151910152565b60a08101610a9b82846142dc565b5f806040838503121561433a575f80fd5b50508035926020909101359150565b5f805f6040848603121561435b575f80fd5b83359250602084013567ffffffffffffffff80821115614379575f80fd5b818601915086601f83011261438c575f80fd5b81358181111561439a575f80fd5b8760208285010111156143ab575f80fd5b6020830194508093505050509250925092565b5f8082840360c08112156143d0575f80fd5b8335925060a0601f19820112156143e5575f80fd5b5060405160a0810181811067ffffffffffffffff8211171561440957614409613fd8565b604052602084013561441a81613f4c565b8152604084013561442a81613f4c565b6020820152606084013561443d81613f4c565b6040820152608084013561445081613f4c565b606082015260a0939093013560808401525092909150565b602080825282518282018190525f9190848201906040850190845b8181101561449f57835183529284019291840191600101614483565b50909695505050505050565b5f80604083850312156144bc575f80fd5b82356144c781613f4c565b9150602083013561422c81614016565b5f80604083850312156144e8575f80fd5b82356144f381613f4c565b9150602083013561422c81613f4c565b5f60208284031215614513575f80fd5b5051919050565b634e487b7160e01b5f52601160045260245ffd5b80820180821115610a9b57610a9b61451a565b600181811c9082168061455557607f821691505b60208210810361457357634e487b7160e01b5f52602260045260245ffd5b50919050565b60ff8181168382160190811115610a9b57610a9b61451a565b81810381811115610a9b57610a9b61451a565b634e487b7160e01b5f52603260045260245ffd5b6001600160a01b03929092168252602082015260400190565b5f80604083850312156145e3575f80fd5b505080516020909101519092909150565b6001600160a01b0385811682528416602082015260606040820181905281018290525f828460808401375f608084840101526080601f19601f850116830101905095945050505050565b600181815b8085111561467857815f190482111561465e5761465e61451a565b8085161561466b57918102915b93841c9390800290614643565b509250929050565b5f8261468e57506001610a9b565b8161469a57505f610a9b565b81600181146146b057600281146146ba576146d6565b6001915050610a9b565b60ff8411156146cb576146cb61451a565b50506001821b610a9b565b5060208310610133831016604e8410600b84101617156146f9575081810a610a9b565b614703838361463e565b805f19048211156147165761471661451a565b029392505050565b5f610c7860ff841683614680565b6001600160a01b039390931683526020830191909152604082015260600190565b5f6020828403121561475d575f80fd5b8151610c7881613f4c565b634e487b7160e01b5f52601260045260245ffd5b83815260e0810161479060208301856142dc565b8260c0830152949350505050565b5f602082840312156147ae575f80fd5b8151610c7881614016565b634e487b7160e01b5f52603160045260245ffd5b634e487b7160e01b5f52602160045260245ffd5b5f60ff8316806147ff57634e487b7160e01b5f52601260045260245ffd5b8060ff84160691505092915050565b5f82518060208501845e5f920191825250919050565b601f821115610f1c57805f5260205f20601f840160051c810160208510156148495750805b601f840160051c820191505b81811015612ba0575f8155600101614855565b815167ffffffffffffffff81111561488257614882613fd8565b614896816148908454614541565b84614824565b602080601f8311600181146148c9575f84156148b25750858301515b5f19600386901b1c1916600185901b178555610dd6565b5f85815260208120601f198616915b828110156148f7578886015182559484019460019091019084016148d8565b508582101561491457878501515f19600388901b60f8161c191681555b5050505050600190811b0190555056fec1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e8237170593200052c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0002dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268000773e532dfede91f04b12a73d3d2acd361424f41f76b4fb79f090161e36b4e009b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00a26469706673582212208a2149ba417dba06573f99d5e9e705d04212ac91f02878db7148b0cc8a55fdb964736f6c63430008190033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
4d656c6c6f7753796d62696f7469635661756c740000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
-----Decoded View---------------
Arg [0] : name_ (bytes32): 0x4d656c6c6f7753796d62696f7469635661756c74000000000000000000000000
Arg [1] : version_ (uint256): 1
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 4d656c6c6f7753796d62696f7469635661756c74000000000000000000000000
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000001
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 34 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ 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.