Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Source Code Verified (Exact Match)
Contract Name:
VaultYieldRSETH
Compiler Version
v0.8.25+commit.b61c2a91
Optimization Enabled:
Yes with 100 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 "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "../interfaces/kelp/ILRTDepositPool.sol"; import "../interfaces/weth/IWETH.sol"; import "../interfaces/lido/IstETH.sol"; import "./libraries/Errors.sol"; import "./common/Constants.sol"; import "./vault/VaultYieldBasic.sol"; /** * @title VaultYieldRSETH contract * @author Naturelab * @dev This contract is the logical implementation of the vault, * and its main purpose is to provide users with a gateway for depositing * and withdrawing funds and to manage user shares. */ contract VaultYieldRSETH is VaultYieldBasic, Constants { using SafeERC20 for IERC20; string public constant VERSION = "2.0"; address public constant STETH = 0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84; ILRTDepositPool internal constant KELP_POOL = ILRTDepositPool(0x036676389e48133B63a802f8635AD39E752D375D); constructor(uint256 _minMarketCapacity) VaultYieldBasic(1e18, _minMarketCapacity) {} function underlyingTvl() public override returns (uint256) { uint256 rsethBal_ = IERC20(RSETH).balanceOf(address(this)); uint256 totalStrategy_ = totalStrategiesAssets(); return totalStrategy_ + rsethBal_ - vaultState.revenue; } /** * @dev Internal function to calculate the shares issued for a deposit. * @param _assets The amount of assets to deposit. * @param _receiver The address of the receiver of the shares. * @return shares_ The amount of shares issued. */ function optionalDepositDeal(uint256 _assets, address _receiver) internal returns (uint256 shares_) { uint256 maxAssets = maxDeposit(_receiver); if (_assets > maxAssets) { revert ERC4626ExceededMaxDeposit(_receiver, _assets, maxAssets); } shares_ = previewDeposit(_assets); emit Deposit(msg.sender, _receiver, _assets, shares_); } /** * @dev Optional deposit function allowing deposits in different token types. * @param _token The address of the token to deposit. * @param _assets The amount of assets to deposit. * @param _receiver The address of the receiver of the shares. * @param _referral Address of the referrer. * @return shares_ The amount of shares issued. */ function optionalDeposit(address _token, uint256 _assets, address _receiver, address _referral) public payable override nonReentrant whenNotPaused returns (uint256 shares_) { if (_token == ETHx || _token == STETH) { IERC20(_token).safeTransferFrom(msg.sender, address(this), _assets); IERC20(_token).safeIncreaseAllowance(address(KELP_POOL), _assets); uint256 tokenBefore_ = IERC20(RSETH).balanceOf(address(this)); KELP_POOL.depositAsset(_token, _assets, 0, ""); uint256 tokenGet_ = IERC20(RSETH).balanceOf(address(this)) - tokenBefore_; shares_ = optionalDepositDeal(tokenGet_, _receiver); } else if (_token == RSETH) { shares_ = optionalDepositDeal(_assets, _receiver); IERC20(_token).safeTransferFrom(msg.sender, address(this), _assets); } else if (_token == ETH) { uint256 tokenBefore_ = IERC20(RSETH).balanceOf(address(this)); KELP_POOL.depositETH{value: msg.value}(0, ""); uint256 tokenGet_ = IERC20(RSETH).balanceOf(address(this)) - tokenBefore_; shares_ = optionalDepositDeal(tokenGet_, _receiver); } else { revert Errors.UnsupportedToken(); } _mint(_receiver, shares_); emit OptionalDeposit(msg.sender, _token, _assets, _receiver, _referral); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol) pragma solidity ^0.8.20; import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol"; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * The initial owner is set to the address provided by the deployer. This can * later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { /// @custom:storage-location erc7201:openzeppelin.storage.Ownable struct OwnableStorage { address _owner; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant OwnableStorageLocation = 0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300; function _getOwnableStorage() private pure returns (OwnableStorage storage $) { assembly { $.slot := OwnableStorageLocation } } /** * @dev The caller account is not authorized to perform an operation. */ error OwnableUnauthorizedAccount(address account); /** * @dev The owner is not a valid owner account. (eg. `address(0)`) */ error OwnableInvalidOwner(address owner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the address provided by the deployer as the initial owner. */ function __Ownable_init(address initialOwner) internal onlyInitializing { __Ownable_init_unchained(initialOwner); } function __Ownable_init_unchained(address initialOwner) internal onlyInitializing { if (initialOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(initialOwner); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { OwnableStorage storage $ = _getOwnableStorage(); return $._owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { if (owner() != _msgSender()) { revert OwnableUnauthorizedAccount(_msgSender()); } } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { if (newOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { OwnableStorage storage $ = _getOwnableStorage(); address oldOwner = $._owner; $._owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.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/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) (utils/Pausable.sol) pragma solidity ^0.8.20; import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol"; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /// @custom:storage-location erc7201:openzeppelin.storage.Pausable struct PausableStorage { bool _paused; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Pausable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant PausableStorageLocation = 0xcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300; function _getPausableStorage() private pure returns (PausableStorage storage $) { assembly { $.slot := PausableStorageLocation } } /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); /** * @dev The operation failed because the contract is paused. */ error EnforcedPause(); /** * @dev The operation failed because the contract is not paused. */ error ExpectedPause(); /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal onlyInitializing { __Pausable_init_unchained(); } function __Pausable_init_unchained() internal onlyInitializing { PausableStorage storage $ = _getPausableStorage(); $._paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { PausableStorage storage $ = _getPausableStorage(); return $._paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { if (paused()) { revert EnforcedPause(); } } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { if (!paused()) { revert ExpectedPause(); } } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { PausableStorage storage $ = _getPausableStorage(); $._paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { PausableStorage storage $ = _getPausableStorage(); $._paused = false; emit Unpaused(_msgSender()); } }
// 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 // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol) pragma solidity ^0.8.20; import {Context} from "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * The initial owner is set to the address provided by the deployer. This can * later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; /** * @dev The caller account is not authorized to perform an operation. */ error OwnableUnauthorizedAccount(address account); /** * @dev The owner is not a valid owner account. (eg. `address(0)`) */ error OwnableInvalidOwner(address owner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the address provided by the deployer as the initial owner. */ constructor(address initialOwner) { if (initialOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(initialOwner); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { if (owner() != _msgSender()) { revert OwnableUnauthorizedAccount(_msgSender()); } } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { if (newOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.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) (interfaces/IERC1967.sol) pragma solidity ^0.8.20; /** * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC. */ interface IERC1967 { /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Emitted when the beacon is changed. */ event BeaconUpgraded(address indexed beacon); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.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) (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.20; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeacon { /** * @dev Must return an address that can be used as a delegate call target. * * {UpgradeableBeacon} will check that this address is a contract. */ function implementation() external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/ERC1967/ERC1967Proxy.sol) pragma solidity ^0.8.20; import {Proxy} from "../Proxy.sol"; import {ERC1967Utils} from "./ERC1967Utils.sol"; /** * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an * implementation address that can be changed. This address is stored in storage in the location specified by * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the * implementation behind the proxy. */ contract ERC1967Proxy is Proxy { /** * @dev Initializes the upgradeable proxy with an initial implementation specified by `implementation`. * * If `_data` is nonempty, it's used as data in a delegate call to `implementation`. This will typically be an * encoded function call, and allows initializing the storage of the proxy like a Solidity constructor. * * Requirements: * * - If `data` is empty, `msg.value` must be zero. */ constructor(address implementation, bytes memory _data) payable { ERC1967Utils.upgradeToAndCall(implementation, _data); } /** * @dev Returns the current implementation address. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using * the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc` */ function _implementation() internal view virtual override returns (address) { return ERC1967Utils.getImplementation(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/ERC1967/ERC1967Utils.sol) pragma solidity ^0.8.20; import {IBeacon} from "../beacon/IBeacon.sol"; import {Address} from "../../utils/Address.sol"; import {StorageSlot} from "../../utils/StorageSlot.sol"; /** * @dev This abstract contract provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots. */ library ERC1967Utils { // We re-declare ERC-1967 events here because they can't be used directly from IERC1967. // This will be fixed in Solidity 0.8.21. At that point we should remove these events. /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Emitted when the beacon is changed. */ event BeaconUpgraded(address indexed beacon); /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev The `implementation` of the proxy is invalid. */ error ERC1967InvalidImplementation(address implementation); /** * @dev The `admin` of the proxy is invalid. */ error ERC1967InvalidAdmin(address admin); /** * @dev The `beacon` of the proxy is invalid. */ error ERC1967InvalidBeacon(address beacon); /** * @dev An upgrade function sees `msg.value > 0` that may be lost. */ error ERC1967NonPayable(); /** * @dev Returns the current implementation address. */ function getImplementation() internal view returns (address) { return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { if (newImplementation.code.length == 0) { revert ERC1967InvalidImplementation(newImplementation); } StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Performs implementation upgrade with additional setup call if data is nonempty. * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected * to avoid stuck value in the contract. * * Emits an {IERC1967-Upgraded} event. */ function upgradeToAndCall(address newImplementation, bytes memory data) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); if (data.length > 0) { Address.functionDelegateCall(newImplementation, data); } else { _checkNonPayable(); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Returns the current admin. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using * the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103` */ function getAdmin() internal view returns (address) { return StorageSlot.getAddressSlot(ADMIN_SLOT).value; } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { if (newAdmin == address(0)) { revert ERC1967InvalidAdmin(address(0)); } StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {IERC1967-AdminChanged} event. */ function changeAdmin(address newAdmin) internal { emit AdminChanged(getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Returns the current beacon. */ function getBeacon() internal view returns (address) { return StorageSlot.getAddressSlot(BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { if (newBeacon.code.length == 0) { revert ERC1967InvalidBeacon(newBeacon); } StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon; address beaconImplementation = IBeacon(newBeacon).implementation(); if (beaconImplementation.code.length == 0) { revert ERC1967InvalidImplementation(beaconImplementation); } } /** * @dev Change the beacon and trigger a setup call if data is nonempty. * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected * to avoid stuck value in the contract. * * Emits an {IERC1967-BeaconUpgraded} event. * * CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since * it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for * efficiency. */ function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0) { Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data); } else { _checkNonPayable(); } } /** * @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract * if an upgrade doesn't perform an initialization call. */ function _checkNonPayable() private { if (msg.value > 0) { revert ERC1967NonPayable(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/Proxy.sol) pragma solidity ^0.8.20; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internal call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overridden so it returns the address to which the fallback * function and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internal call site, it will return directly to the external caller. */ function _fallback() internal virtual { _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback() external payable virtual { _fallback(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/transparent/ProxyAdmin.sol) pragma solidity ^0.8.20; import {ITransparentUpgradeableProxy} from "./TransparentUpgradeableProxy.sol"; import {Ownable} from "../../access/Ownable.sol"; /** * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}. */ contract ProxyAdmin is Ownable { /** * @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgrade(address)` * and `upgradeAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called, * while `upgradeAndCall` will invoke the `receive` function if the second argument is the empty byte string. * If the getter returns `"5.0.0"`, only `upgradeAndCall(address,bytes)` is present, and the second argument must * be the empty byte string if no function should be called, making it impossible to invoke the `receive` function * during an upgrade. */ string public constant UPGRADE_INTERFACE_VERSION = "5.0.0"; /** * @dev Sets the initial owner who can perform upgrades. */ constructor(address initialOwner) Ownable(initialOwner) {} /** * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. * See {TransparentUpgradeableProxy-_dispatchUpgradeToAndCall}. * * Requirements: * * - This contract must be the admin of `proxy`. * - If `data` is empty, `msg.value` must be zero. */ function upgradeAndCall( ITransparentUpgradeableProxy proxy, address implementation, bytes memory data ) public payable virtual onlyOwner { proxy.upgradeToAndCall{value: msg.value}(implementation, data); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/transparent/TransparentUpgradeableProxy.sol) pragma solidity ^0.8.20; import {ERC1967Utils} from "../ERC1967/ERC1967Utils.sol"; import {ERC1967Proxy} from "../ERC1967/ERC1967Proxy.sol"; import {IERC1967} from "../../interfaces/IERC1967.sol"; import {ProxyAdmin} from "./ProxyAdmin.sol"; /** * @dev Interface for {TransparentUpgradeableProxy}. In order to implement transparency, {TransparentUpgradeableProxy} * does not implement this interface directly, and its upgradeability mechanism is implemented by an internal dispatch * mechanism. The compiler is unaware that these functions are implemented by {TransparentUpgradeableProxy} and will not * include them in the ABI so this interface must be used to interact with it. */ interface ITransparentUpgradeableProxy is IERC1967 { function upgradeToAndCall(address, bytes calldata) external payable; } /** * @dev This contract implements a proxy that is upgradeable through an associated {ProxyAdmin} instance. * * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector * clashing], which can potentially be used in an attack, this contract uses the * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two * things that go hand in hand: * * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if * that call matches the {ITransparentUpgradeableProxy-upgradeToAndCall} function exposed by the proxy itself. * 2. If the admin calls the proxy, it can call the `upgradeToAndCall` function but any other call won't be forwarded to * the implementation. If the admin tries to call a function on the implementation it will fail with an error indicating * the proxy admin cannot fallback to the target implementation. * * These properties mean that the admin account can only be used for upgrading the proxy, so it's best if it's a * dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to * call a function from the proxy implementation. For this reason, the proxy deploys an instance of {ProxyAdmin} and * allows upgrades only if they come through it. You should think of the `ProxyAdmin` instance as the administrative * interface of the proxy, including the ability to change who can trigger upgrades by transferring ownership. * * NOTE: The real interface of this proxy is that defined in `ITransparentUpgradeableProxy`. This contract does not * inherit from that interface, and instead `upgradeToAndCall` is implicitly implemented using a custom dispatch * mechanism in `_fallback`. Consequently, the compiler will not produce an ABI for this contract. This is necessary to * fully implement transparency without decoding reverts caused by selector clashes between the proxy and the * implementation. * * NOTE: This proxy does not inherit from {Context} deliberately. The {ProxyAdmin} of this contract won't send a * meta-transaction in any way, and any other meta-transaction setup should be made in the implementation contract. * * IMPORTANT: This contract avoids unnecessary storage reads by setting the admin only during construction as an * immutable variable, preventing any changes thereafter. However, the admin slot defined in ERC-1967 can still be * overwritten by the implementation logic pointed to by this proxy. In such cases, the contract may end up in an * undesirable state where the admin slot is different from the actual admin. * * WARNING: It is not recommended to extend this contract to add additional external functions. If you do so, the * compiler will not check that there are no selector conflicts, due to the note above. A selector clash between any new * function and the functions declared in {ITransparentUpgradeableProxy} will be resolved in favor of the new one. This * could render the `upgradeToAndCall` function inaccessible, preventing upgradeability and compromising transparency. */ contract TransparentUpgradeableProxy is ERC1967Proxy { // An immutable address for the admin to avoid unnecessary SLOADs before each call // at the expense of removing the ability to change the admin once it's set. // This is acceptable if the admin is always a ProxyAdmin instance or similar contract // with its own ability to transfer the permissions to another account. address private immutable _admin; /** * @dev The proxy caller is the current admin, and can't fallback to the proxy target. */ error ProxyDeniedAdminAccess(); /** * @dev Initializes an upgradeable proxy managed by an instance of a {ProxyAdmin} with an `initialOwner`, * backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in * {ERC1967Proxy-constructor}. */ constructor(address _logic, address initialOwner, bytes memory _data) payable ERC1967Proxy(_logic, _data) { _admin = address(new ProxyAdmin(initialOwner)); // Set the storage value and emit an event for ERC-1967 compatibility ERC1967Utils.changeAdmin(_proxyAdmin()); } /** * @dev Returns the admin of this proxy. */ function _proxyAdmin() internal virtual returns (address) { return _admin; } /** * @dev If caller is the admin process the call internally, otherwise transparently fallback to the proxy behavior. */ function _fallback() internal virtual override { if (msg.sender == _proxyAdmin()) { if (msg.sig != ITransparentUpgradeableProxy.upgradeToAndCall.selector) { revert ProxyDeniedAdminAccess(); } else { _dispatchUpgradeToAndCall(); } } else { super._fallback(); } } /** * @dev Upgrade the implementation of the proxy. See {ERC1967Utils-upgradeToAndCall}. * * Requirements: * * - If `data` is empty, `msg.value` must be zero. */ function _dispatchUpgradeToAndCall() private { (address newImplementation, bytes memory data) = abi.decode(msg.data[4:], (address, bytes)); ERC1967Utils.upgradeToAndCall(newImplementation, data); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.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) (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) (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/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) (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.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: 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.0) (utils/StorageSlot.sol) // This file was procedurally generated from scripts/generate/templates/StorageSlot.js. pragma solidity ^0.8.20; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ```solidity * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(newImplementation.code.length > 0); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } struct StringSlot { string value; } struct BytesSlot { bytes value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` with member `value` located at `slot`. */ function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` representation of the string storage pointer `store`. */ function getStringSlot(string storage store) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } /** * @dev Returns an `BytesSlot` with member `value` located at `slot`. */ function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`. */ function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } }
// 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: BUSL-1.1 pragma solidity ^0.8.25; interface IRedeemOperator { // Events for logging actions event RegisterWithdrawal(address indexed user, uint256 shares); event ConfirmWithdrawal(address[] users, uint256[] amounts); event UpdateOperator(address oldOperator, address newOperator); event UpdateFeeReceiver(address oldFeeReceiver, address newFeeReceiver); event Sweep(address token); function registerWithdrawal(address _user, uint256 _shares) external; function pendingWithdrawersCount() external view returns (uint256); function pendingWithdrawers(uint256 _limit, uint256 _offset) external view returns (address[] memory result_); function allPendingWithdrawers() external view returns (address[] memory); function confirmWithdrawal(address[] calldata _Users, uint256 _totalGasTokenAmount) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.25; interface IStrategy { function getNetAssets() external returns (uint256); function onTransferIn(address token, uint256 amount) external returns (bool); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.25; interface IVault { event UpdateMarketCapacity(uint256 oldCapacityLimit, uint256 newCapacityLimit); event UpdateManagementFee(uint256 oldManagementFee, uint256 newManagementFee); event UpdateManagementFeeClaimPeriod(uint256 oldManagementFeeClaimPeriod, uint256 newManagementFeeClaimPeriod); event UpdateMaxPriceUpdatePeriod(uint256 oldMaxPriceUpdatePeriod, uint256 newMaxPriceUpdatePeriod); event UpdateRevenueRate(uint256 oldRevenueRate, uint256 newRevenueRate); event UpdateExitFeeRate(uint256 oldExitFeeRate, uint256 newExitFeeRate); event UpdateRebalancer(address oldRebalancer, address newRebalancer); event UpdateUnbackedMinter(address oldUnbackedMinter, address newUnbackedMinter); event UpdateFeeReceiver(address oldFeeReceiver, address newFeeReceiver); event UpdateRedeemOperator(address oldRedeemOperator, address newRedeemOperator); event UpdateExchangePrice(uint256 newExchangePrice, uint256 newRevenue); event TransferToStrategy(address token, uint256 amount, uint256 strategyIndex); event OptionalDeposit(address caller, address token, uint256 assets, address receiver, address referral); event OptionalRedeem(address token, uint256 shares, address receiver, address owner); event RequestRedeem(address user, uint256 shares, address token); event CollectManagementFee(uint256 assets); event CollectRevenue(uint256 revenue); event AddToken(address token); event RemoveToken(address token); /** * @dev Parameters for initializing the vault contract. * @param underlyingToken The address of the underlying token for the vault. * @param name The name of the vault token. * @param symbol The symbol of the vault token. * @param marketCapacity The maximum market capacity of the vault. * @param managementFeeRate The rate of the management fee. * @param managementFeeClaimPeriod The period for claiming the management fee. * @param maxPriceUpdatePeriod The maximum allowed price update period. * @param revenueRate The rate of the revenue fee. * @param exitFeeRate The rate of the exit fee. * @param admin The address of the administrator. * @param rebalancer The address responsible for rebalancing the vault. * @param feeReceiver The address that will receive the fees. * @param redeemOperator The address of the operator responsible for redeeming shares */ struct VaultParams { address underlyingToken; string name; string symbol; uint256 marketCapacity; uint256 managementFeeRate; uint256 managementFeeClaimPeriod; uint256 maxPriceUpdatePeriod; uint256 revenueRate; uint256 exitFeeRate; address admin; address rebalancer; address feeReceiver; address redeemOperator; } /** * @dev * @param exchangePrice The exchange rate used during user deposit and withdrawal operations. * @param revenueExchangePrice The exchange rate used when calculating performance fees,Performance fees will be recorded when the real exchange rate exceeds this rate. * @param revenue Collected revenue, stored in pegged ETH. * @param lastClaimMngFeeTime The last time the management fees were charged. * @param lastUpdatePriceTime The last time the exchange price was updated. */ struct VaultState { uint256 exchangePrice; uint256 revenueExchangePrice; uint256 revenue; uint256 lastClaimMngFeeTime; uint256 lastUpdatePriceTime; } function optionalRedeem(address _token, uint256 _shares, uint256 _cutPercentage, address _receiver, address _owner) external returns (uint256 assetsAfterFee_); function getWithdrawFee(uint256 _amount) external view returns (uint256 amount_); function exchangePrice() external view returns (uint256); function revenueExchangePrice() external view returns (uint256); function revenue() external view returns (uint256); function lastExchangePrice() external view returns (uint256); function getPrecison() external view returns (uint256); function burnUnbacked(uint256 _amount) external; function mintUnbacked(uint256 _amount) external; function optionalDeposit(address _token, uint256 _assets, address _receiver, address _referral) external payable returns (uint256 shares_); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.21; interface ILRTDepositPool { //errors error InvalidAmountToDeposit(); error NotEnoughAssetToTransfer(); error MaximumDepositLimitReached(); error MaximumNodeDelegatorLimitReached(); error InvalidMaximumNodeDelegatorLimit(); error MinimumAmountToReceiveNotMet(); error NodeDelegatorNotFound(); error NodeDelegatorHasAssetBalance(address assetAddress, uint256 assetBalance); error NodeDelegatorHasETH(); error EthTransferFailed(); //events event MaxNodeDelegatorLimitUpdated(uint256 maxNodeDelegatorLimit); event NodeDelegatorAddedinQueue(address[] nodeDelegatorContracts); event NodeDelegatorRemovedFromQueue(address nodeDelegatorContracts); event AssetDeposit( address indexed depositor, address indexed asset, uint256 depositAmount, uint256 rsethMintAmount, string referralId ); event ETHDeposit(address indexed depositor, uint256 depositAmount, uint256 rsethMintAmount, string referralId); event MinAmountToDepositUpdated(uint256 minAmountToDeposit); event MaxNegligibleAmountUpdated(uint256 maxNegligibleAmount); event ETHSwappedForLST(uint256 ethAmount, address indexed toAsset, uint256 returnAmount); event EthTransferred(address to, uint256 amount); // functions function depositETH( uint256 minRSETHAmountExpected, string calldata referralId ) external payable; function depositAsset( address asset, uint256 depositAmount, uint256 minRSETHAmountExpected, string calldata referralId ) external; function getSwapETHToAssetReturnAmount(address toAsset, uint256 ethAmountToSend) external view returns (uint256 returnAmount); function getTotalAssetDeposits(address asset) external view returns (uint256); function getAssetCurrentLimit(address asset) external view returns (uint256); function getRsETHAmountToMint(address asset, uint256 depositAmount) external view returns (uint256); function addNodeDelegatorContractToQueue(address[] calldata nodeDelegatorContract) external; function transferAssetToNodeDelegator(uint256 ndcIndex, address asset, uint256 amount) external; function updateMaxNodeDelegatorLimit(uint256 maxNodeDelegatorLimit) external; function getNodeDelegatorQueue() external view returns (address[] memory); function getAssetDistributionData(address asset) external view returns ( uint256 assetLyingInDepositPool, uint256 assetLyingInNDCs, uint256 assetStakedInEigenLayer, uint256 assetUnstakingFromEigenLayer, uint256 assetLyingInConverter, uint256 assetLyingUnstakingVault ); function getETHDistributionData() external view returns ( uint256 ethLyingInDepositPool, uint256 ethLyingInNDCs, uint256 ethStakedInEigenLayer, uint256 ethUnstakingFromEigenLayer, uint256 ethLyingInConverter, uint256 ethLyingInUnstakingVault ); function isNodeDelegator(address nodeDelegatorContract) external view returns (uint256); // receivers function receiveFromRewardReceiver() external payable; function receiveFromLRTConverter() external payable; function receiveFromNodeDelegator() external payable; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IstETH is IERC20 { function submit(address _referral) external payable returns (uint256); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IWETH is IERC20 { function deposit() external payable; function withdraw(uint256 wad) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.25; abstract contract Constants { address public constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; address public constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; address public constant RSETH = 0xA1290d69c65A6Fe4DF752f95823fae25cB99e5A7; address public constant ETHx = 0xA35b1B31Ce002FBF2058D22F30f95D405200A15b; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.25; library Errors { // Revert Errors: error CallerNotOperator(); // 0xa5523ee5 error CallerNotRebalancer(); // 0xbd72e291 error CallerNotVault(); // 0xedd7338f error CallerNotMinter(); // 0x5eee367a error ExitFeeRateTooHigh(); // 0xf4d1caab error FlashloanInProgress(); // 0x772ac4e8 error IncorrectState(); // 0x508c9390 error InfoExpired(); // 0x4ddf4a65 error InvalidAccount(); // 0x6d187b28 error InvalidAdapter(); // 0xfbf66df1 error InvalidAdmin(); // 0xb5eba9f0 error InvalidAsset(); // 0xc891add2 error InvalidCaller(); // 0x48f5c3ed error InvalidClaimTime(); // 0x1221b97b error InvalidFeeReceiver(); // 0xd200485c error InvalidFlashloanCall(); // 0xd2208d52 error InvalidFlashloanHelper(); // 0x8690f016 error InvalidFlashloanProvider(); // 0xb6b48551 error InvalidGasLimit(); // 0x98bdb2e0 error InvalidInitiator(); // 0xbfda1f28 error InvalidLength(); // 0x947d5a84 error InvalidLimit(); // 0xe55fb509 error InvalidManagementFeeClaimPeriod(); // 0x4022e4f6 error InvalidManagementFeeRate(); // 0x09aa66eb error InvalidMarketCapacity(); // 0xc9034604 error InvalidNetAssets(); // 0x6da79d69 error InvalidNewOperator(); // 0xba0cdec5 error InvalidOperator(); // 0xccea9e6f error InvalidRebalancer(); // 0xff288a8e error InvalidRedeemOperator(); // 0xd214a597 error InvalidSafeProtocolRatio(); // 0x7c6b23d6 error InvalidShares(); // 0x6edcc523 error InvalidTarget(); // 0x82d5d76a error InvalidToken(); // 0xc1ab6dc1 error InvalidTokenId(); // 0x3f6cc768 error InvalidUnderlyingToken(); // 0x2fb86f96 error InvalidVault(); // 0xd03a6320 error InvalidWithdrawalUser(); // 0x36c17319 error ManagementFeeRateTooHigh(); // 0x09aa66eb error ManagementFeeClaimPeriodTooShort(); // 0x4022e4f6 error MarketCapacityTooLow(); // 0xc9034604 error NotSupportedYet(); // 0xfb89ba2a error PriceNotUpdated(); // 0x1f4bcb2b error PriceUpdatePeriodTooLong(); // 0xe88d3ecb error RatioOutOfRange(); // 0x9179cbfa error RevenueFeeRateTooHigh(); // 0x0674143f error UnSupportedOperation(); // 0xe9ec8129 error UnsupportedToken(); // 0x6a172882 error WithdrawZero(); // 0x7ea773a9 // for 1inch swap error OneInchInvalidReceiver(); // 0xd540519e error OneInchInvalidToken(); // 0x8e7ad912 error OneInchInvalidInputAmount(); // 0x672b500f error OneInchInvalidFunctionSignature(); // 0x247f51aa error OneInchUnexpectedSpentAmount(); // 0x295ada05 error OneInchUnexpectedReturnAmount(); // 0x05e64ca8 error OneInchNotSupported(); // 0x04b2de78 }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol) // This file was procedurally generated from scripts/generate/templates/StorageSlot.js. pragma solidity ^0.8.25; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC-1967 implementation slot: * ```solidity * contract ERC1967 { * // Define the slot. Alternatively, use the SlotDerivation library to derive the slot. * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(newImplementation.code.length > 0); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * Since version 5.1, this library also support writing and reading value types to and from transient storage. * * * Example using transient storage: * ```solidity * contract Lock { * // Define the slot. Alternatively, use the SlotDerivation library to derive the slot. * bytes32 internal constant _LOCK_SLOT = 0xf4678858b2b588224636b8522b729e7722d32fc491da849ed75b3fdf3c84f542; * * modifier locked() { * require(!_LOCK_SLOT.asBoolean().tload()); * * _LOCK_SLOT.asBoolean().tstore(true); * _; * _LOCK_SLOT.asBoolean().tstore(false); * } * } * ``` * * TIP: Consider using this library along with {SlotDerivation}. */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } struct Int256Slot { int256 value; } struct StringSlot { string value; } struct BytesSlot { bytes value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Int256Slot` with member `value` located at `slot`. */ function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` with member `value` located at `slot`. */ function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` representation of the string storage pointer `store`. */ function getStringSlot(string storage store) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } /** * @dev Returns an `BytesSlot` with member `value` located at `slot`. */ function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`. */ function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } /** * @dev UDVT that represent a slot holding a address. */ type AddressSlotType is bytes32; /** * @dev Cast an arbitrary slot to a AddressSlotType. */ function asAddress(bytes32 slot) internal pure returns (AddressSlotType) { return AddressSlotType.wrap(slot); } /** * @dev UDVT that represent a slot holding a bool. */ type BooleanSlotType is bytes32; /** * @dev Cast an arbitrary slot to a BooleanSlotType. */ function asBoolean(bytes32 slot) internal pure returns (BooleanSlotType) { return BooleanSlotType.wrap(slot); } /** * @dev UDVT that represent a slot holding a bytes32. */ type Bytes32SlotType is bytes32; /** * @dev Cast an arbitrary slot to a Bytes32SlotType. */ function asBytes32(bytes32 slot) internal pure returns (Bytes32SlotType) { return Bytes32SlotType.wrap(slot); } /** * @dev UDVT that represent a slot holding a uint256. */ type Uint256SlotType is bytes32; /** * @dev Cast an arbitrary slot to a Uint256SlotType. */ function asUint256(bytes32 slot) internal pure returns (Uint256SlotType) { return Uint256SlotType.wrap(slot); } /** * @dev UDVT that represent a slot holding a int256. */ type Int256SlotType is bytes32; /** * @dev Cast an arbitrary slot to a Int256SlotType. */ function asInt256(bytes32 slot) internal pure returns (Int256SlotType) { return Int256SlotType.wrap(slot); } /** * @dev Load the value held at location `slot` in transient storage. */ function tload(AddressSlotType slot) internal view returns (address value) { /// @solidity memory-safe-assembly assembly { value := tload(slot) } } /** * @dev Store `value` at location `slot` in transient storage. */ function tstore(AddressSlotType slot, address value) internal { /// @solidity memory-safe-assembly assembly { tstore(slot, value) } } /** * @dev Load the value held at location `slot` in transient storage. */ function tload(BooleanSlotType slot) internal view returns (bool value) { /// @solidity memory-safe-assembly assembly { value := tload(slot) } } /** * @dev Store `value` at location `slot` in transient storage. */ function tstore(BooleanSlotType slot, bool value) internal { /// @solidity memory-safe-assembly assembly { tstore(slot, value) } } /** * @dev Load the value held at location `slot` in transient storage. */ function tload(Bytes32SlotType slot) internal view returns (bytes32 value) { /// @solidity memory-safe-assembly assembly { value := tload(slot) } } /** * @dev Store `value` at location `slot` in transient storage. */ function tstore(Bytes32SlotType slot, bytes32 value) internal { /// @solidity memory-safe-assembly assembly { tstore(slot, value) } } /** * @dev Load the value held at location `slot` in transient storage. */ function tload(Uint256SlotType slot) internal view returns (uint256 value) { /// @solidity memory-safe-assembly assembly { value := tload(slot) } } /** * @dev Store `value` at location `slot` in transient storage. */ function tstore(Uint256SlotType slot, uint256 value) internal { /// @solidity memory-safe-assembly assembly { tstore(slot, value) } } /** * @dev Load the value held at location `slot` in transient storage. */ function tload(Int256SlotType slot) internal view returns (int256 value) { /// @solidity memory-safe-assembly assembly { value := tload(slot) } } /** * @dev Store `value` at location `slot` in transient storage. */ function tstore(Int256SlotType slot, int256 value) internal { /// @solidity memory-safe-assembly assembly { tstore(slot, value) } } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.25; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol"; import "../../interfaces/IRedeemOperator.sol"; import "../../interfaces/IStrategy.sol"; import "../libraries/Errors.sol"; /** * @title StrategyFactory contract * @author Naturelab * @dev This contract is responsible for managing strategies in a vault. * It allows the owner to create, remove, and interact with different strategies. */ abstract contract StrategyFactory is OwnableUpgradeable { using SafeERC20 for IERC20; using EnumerableSet for EnumerableSet.AddressSet; uint256 public constant MAX_POSITION_LIMIT = 10000; // 10000/10000 = 100% // Set to keep track of the addresses of strategies EnumerableSet.AddressSet private _strategies; // This mapping is used to set position limits for various strategies. // The key is the strategy ID, and the value is the maximum percentage of the entire position // that the strategy is allowed to occupy. 1000 = 10% mapping(address => uint256) public positionLimit; // Events for logging actions event CreateStrategy(address strategy, address impl); event RemoveStrategy(address strategy); event UpdateOperator(address oldOperator, address newOperator); event UpdateStrategyLimit(uint256 oldLimit, uint256 newLimit); /** * @dev Returns the number of strategies in the set. * @return The number of strategies. */ function strategiesCount() public view returns (uint256) { return _strategies.length(); } /** * @dev Returns an array of all strategy addresses. * @return An array of strategy addresses. */ function strategies() public view returns (address[] memory) { return _strategies.values(); } /** * @dev Returns the address of a strategy at a specific index. * @param _offset The index of the strategy. * @return The address of the strategy. */ function strategyAddress(uint256 _offset) public view returns (address) { return _strategies.at(_offset); } /** * @dev Returns the total assets managed by a specific strategy. * @param _offset The index of the strategy. * @return totalAssets_ The total assets managed by the strategy. */ function strategyAssets(uint256 _offset) public returns (uint256 totalAssets_) { totalAssets_ = IStrategy(_strategies.at(_offset)).getNetAssets(); } /** * @dev Returns the total assets managed by all strategies combined. * @return totalAssets_ The total assets managed by all strategies. */ function totalStrategiesAssets() public returns (uint256 totalAssets_) { uint256 length_ = strategiesCount(); address[] memory strategies_ = strategies(); for (uint256 i = 0; i < length_; ++i) { totalAssets_ += IStrategy(strategies_[i]).getNetAssets(); } } /** * @dev Allows the owner to create a new strategy. * @param _impl The implementation address of the strategy. * @param _initBytes The initialization parameters for the strategy. */ function createStrategy(address _impl, bytes calldata _initBytes, uint256 _positionLimit) external onlyOwner { if (_positionLimit == 0 || _positionLimit > MAX_POSITION_LIMIT) revert Errors.InvalidLimit(); address newStrategy_ = address(new TransparentUpgradeableProxy(_impl, msg.sender, _initBytes)); positionLimit[newStrategy_] = _positionLimit; _strategies.add(newStrategy_); emit CreateStrategy(newStrategy_, _impl); } /** * @dev Allows the owner to remove a strategy from the set. * @param _strategy The address of the strategy to be removed. */ function removeStrategy(address _strategy) external onlyOwner { if (IStrategy(_strategy).getNetAssets() > 0) revert Errors.UnSupportedOperation(); _strategies.remove(_strategy); positionLimit[_strategy] = 0; emit RemoveStrategy(_strategy); } /** * @dev Update the temporary address of shares when users redeem. * @param _newPositionLimit The new redeem operator address. */ function updateStrategyLimit(uint256 _offset, uint256 _newPositionLimit) external onlyOwner { if (_newPositionLimit == 0 || _newPositionLimit > MAX_POSITION_LIMIT) revert Errors.InvalidLimit(); address strategyAddress_ = _strategies.at(_offset); emit UpdateStrategyLimit(positionLimit[strategyAddress_], _newPositionLimit); positionLimit[strategyAddress_] = _newPositionLimit; } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.25; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC4626Upgradeable.sol"; import "../../interfaces/IRedeemOperator.sol"; import "../../interfaces/IStrategy.sol"; import "../../interfaces/IVault.sol"; import "../libraries/StorageSlot.sol"; import "../libraries/Errors.sol"; import "./StrategyFactory.sol"; /** * @title VaultYieldBasic contract * @author Naturelab * @dev This contract is the logical implementation of the vault, * and its main purpose is to provide users with a gateway for depositing * and withdrawing funds and to manage user shares. */ contract VaultYieldBasic is IVault, StrategyFactory, ERC4626Upgradeable, PausableUpgradeable, ReentrancyGuardUpgradeable { using SafeERC20 for IERC20; using StorageSlot for *; using EnumerableSet for EnumerableSet.AddressSet; // Use EIP-1153 to temporarily store prices for calculation. bytes32 internal constant EXCHANGE_PRICE_CACHE = keccak256("EXCHANGE_PRICE_CACHE"); // Define a constant variable representing the fee denominator, 10000 (used for percentage calculations) uint256 internal constant FEE_DENOMINATOR = 1e4; // Up to 0.04% can be charged as a management fee in each cycle (4 / 10000) uint256 internal constant MAX_MANAGEMENT_FEE_RATE = 4; // The shortest cycle for charging the management fee is 7 days uint256 internal constant MIN_MANAGEMENT_FEE_CLAIM_PERIOD = 7 days; // The maximum interval for price updates. If prices are not updated for a long time, // deposits will be temporarily unavailable. uint256 internal constant MAX_PRICE_UPDATED_PERIOD = 3 days; // The maximum fee for withdrawing from the idle treasury is 1.2% (120 / 10000) uint256 internal constant MAX_EXIT_FEE_RATE = 120; // The maximum revenue fee rate is 15% (1500 / 10000) uint256 internal constant MAX_REVENUE_FEE_RATE = 1500; // Prevents erroneous price fluctuations. (100 / 10000) uint256 internal constant MAX_PRICE_CHANGE_RATE = 100; // Units of measurement used for precise calculations. uint256 internal immutable PRECISION; // Used to determine the initial exchange price. uint256 internal immutable INIT_EXCHANGE_PRICE; // Used to limit the minimum initial price. uint256 internal immutable MIN_MARKET_CAPACITY; // Vault parameters, encapsulating the configuration of the vault VaultParams internal vaultParams; // Vault state, encapsulating the state of the vault VaultState internal vaultState; // Used to manage tokens allowed to be deposited. EnumerableSet.AddressSet internal tokens; // The amount of unbacked minted shares uint256 public unbackedMintedAmount; // The allowed contract to mint unbacked shares address public unbackedMinter; /** * @dev Ensure that this method is only called by authorized portfolio managers. */ modifier onlyRebalancer() { if (msg.sender != vaultParams.rebalancer) revert Errors.CallerNotRebalancer(); _; } /** * @dev Ensure that this method is only called by the unbacked minter. */ modifier onlyUnbackedMinter() { if (msg.sender != unbackedMinter) revert Errors.CallerNotMinter(); _; } constructor(uint256 _precision, uint256 _minMarketCapacity) { PRECISION = _precision; INIT_EXCHANGE_PRICE = _precision; MIN_MARKET_CAPACITY = _minMarketCapacity; } /** * @dev Initialize various parameters of the Vault contract. * @param _initBytes The encoded initialization parameters. */ function initialize(bytes calldata _initBytes) external initializer { (VaultParams memory params_, address[] memory tokens_) = abi.decode(_initBytes, (IVault.VaultParams, address[])); __Pausable_init(); __ReentrancyGuard_init(); __ERC20_init(params_.name, params_.symbol); if (params_.underlyingToken == address(0)) revert Errors.InvalidUnderlyingToken(); if (params_.rebalancer == address(0)) revert Errors.InvalidRebalancer(); if (params_.admin == address(0)) revert Errors.InvalidAdmin(); if (params_.feeReceiver == address(0)) revert Errors.InvalidFeeReceiver(); if (params_.marketCapacity < MIN_MARKET_CAPACITY) revert Errors.MarketCapacityTooLow(); if (params_.managementFeeRate > MAX_MANAGEMENT_FEE_RATE) revert Errors.ManagementFeeRateTooHigh(); if (params_.managementFeeClaimPeriod < MIN_MANAGEMENT_FEE_CLAIM_PERIOD) { revert Errors.ManagementFeeClaimPeriodTooShort(); } if (params_.maxPriceUpdatePeriod > MAX_PRICE_UPDATED_PERIOD) revert Errors.PriceUpdatePeriodTooLong(); if (params_.revenueRate > MAX_REVENUE_FEE_RATE) revert Errors.RevenueFeeRateTooHigh(); if (params_.exitFeeRate > MAX_EXIT_FEE_RATE) revert Errors.ExitFeeRateTooHigh(); __Ownable_init(params_.admin); __ERC4626_init(IERC20(params_.underlyingToken)); vaultState.lastClaimMngFeeTime = block.timestamp; vaultState.lastUpdatePriceTime = block.timestamp; vaultState.exchangePrice = INIT_EXCHANGE_PRICE; vaultParams = params_; for (uint256 i; i < tokens_.length; i++) { if (tokens_[i] == address(0)) revert Errors.InvalidUnderlyingToken(); tokens.add(tokens_[i]); } } /** * @dev Returns the vault parameters. * @return A struct containing the vault parameters. */ function getVaultParams() public view returns (VaultParams memory) { return vaultParams; } /** * @dev Returns the vault state. * @return A struct containing the vault state. */ function getVaultState() public view returns (VaultState memory) { return vaultState; } function getPrecison() public view returns (uint256) { return PRECISION; } function getTokens() public view returns (address[] memory) { return tokens.values(); } /** * @dev Update the size of the pool's capacity. * @param _newCapacityLimit The new size of the capacity. */ function updateMarketCapacity(uint256 _newCapacityLimit) external onlyOwner { if (_newCapacityLimit <= vaultParams.marketCapacity) revert Errors.UnSupportedOperation(); emit UpdateMarketCapacity(vaultParams.marketCapacity, _newCapacityLimit); vaultParams.marketCapacity = _newCapacityLimit; } /** * @dev Update the management fee rate. * @param _newManagementFeeRate The new rate. */ function updateManagementFee(uint256 _newManagementFeeRate) external onlyOwner { if (_newManagementFeeRate > MAX_MANAGEMENT_FEE_RATE) revert Errors.ManagementFeeRateTooHigh(); emit UpdateManagementFee(vaultParams.managementFeeRate, _newManagementFeeRate); vaultParams.managementFeeRate = _newManagementFeeRate; } /** * @dev Update the collection cycle of management fees. * @param _newmanagementFeeClaimPeriod The new management fee claim period. */ function updateManagementFeeClaimPeriod(uint256 _newmanagementFeeClaimPeriod) external onlyOwner { if (_newmanagementFeeClaimPeriod < MIN_MANAGEMENT_FEE_CLAIM_PERIOD) { revert Errors.ManagementFeeClaimPeriodTooShort(); } emit UpdateManagementFeeClaimPeriod(vaultParams.managementFeeClaimPeriod, _newmanagementFeeClaimPeriod); vaultParams.managementFeeClaimPeriod = _newmanagementFeeClaimPeriod; } /** * @dev Update the maximum allowed price update period. * @param _newMaxPriceUpdatePeriod The new period. */ function updateMaxPriceUpdatePeriod(uint256 _newMaxPriceUpdatePeriod) external onlyOwner { if (_newMaxPriceUpdatePeriod > MAX_PRICE_UPDATED_PERIOD) revert Errors.PriceUpdatePeriodTooLong(); emit UpdateMaxPriceUpdatePeriod(vaultParams.maxPriceUpdatePeriod, _newMaxPriceUpdatePeriod); vaultParams.maxPriceUpdatePeriod = _newMaxPriceUpdatePeriod; } /** * @dev Update the revenue fee rate. * @param _newRevenueRate The new rate. */ function updateRevenueRate(uint256 _newRevenueRate) external onlyOwner { if (_newRevenueRate > MAX_REVENUE_FEE_RATE) revert Errors.RevenueFeeRateTooHigh(); emit UpdateRevenueRate(vaultParams.revenueRate, _newRevenueRate); vaultParams.revenueRate = _newRevenueRate; } /** * @dev Update the exit fee rate. * @param _newExitFeeRate The new rate. */ function updateExitFeeRate(uint256 _newExitFeeRate) external onlyOwner { if (_newExitFeeRate > MAX_EXIT_FEE_RATE) revert Errors.ExitFeeRateTooHigh(); emit UpdateExitFeeRate(vaultParams.exitFeeRate, _newExitFeeRate); vaultParams.exitFeeRate = _newExitFeeRate; } /** * @dev Add a new address to the position adjustment whitelist. * @param _newRebalancer The new address to be added. */ function updateRebalancer(address _newRebalancer) external onlyOwner { if (_newRebalancer == address(0)) revert Errors.InvalidRebalancer(); emit UpdateRebalancer(vaultParams.rebalancer, _newRebalancer); vaultParams.rebalancer = _newRebalancer; } /** * @dev Update the address of the unbacked minter. * @param _newUnbackedMinter The new address of the unbacked minter. */ function updateUnbackedMinter(address _newUnbackedMinter) external onlyOwner { emit UpdateUnbackedMinter(unbackedMinter, _newUnbackedMinter); unbackedMinter = _newUnbackedMinter; } /** * @dev Update the address of the recipient for management fees. * @param _newFeeReceiver The new address of the recipient for management fees. */ function updateFeeReceiver(address _newFeeReceiver) external onlyOwner { if (_newFeeReceiver == address(0)) revert Errors.InvalidFeeReceiver(); emit UpdateFeeReceiver(vaultParams.feeReceiver, _newFeeReceiver); vaultParams.feeReceiver = _newFeeReceiver; } /** * @dev Update the temporary address of shares when users redeem. * @param _newRedeemOperator The new redeem operator address. */ function updateRedeemOperator(address _newRedeemOperator) external onlyOwner { if (_newRedeemOperator == address(0)) revert Errors.InvalidRedeemOperator(); emit UpdateRedeemOperator(vaultParams.redeemOperator, _newRedeemOperator); vaultParams.redeemOperator = _newRedeemOperator; } function addToken(address _newToken) external onlyOwner { if (_newToken == address(0)) revert Errors.InvalidUnderlyingToken(); tokens.add(_newToken); emit AddToken(_newToken); } function removeToken(address _token) external onlyOwner { tokens.remove(_token); emit RemoveToken(_token); } /* * @return newExchangePrice The new exercise price * @return newRevenue The new realized profit. */ function updateExchangePrice() external onlyRebalancer returns (uint256 newExchangePrice, uint256 newRevenue) { EXCHANGE_PRICE_CACHE.asUint256().tstore(vaultState.exchangePrice); vaultState.lastUpdatePriceTime = block.timestamp; uint256 totalSupply_ = totalSupply(); if (totalSupply_ == 0) { return (vaultState.exchangePrice, vaultState.revenue); } uint256 currentNetAssets_ = underlyingTvl(); newExchangePrice = currentNetAssets_ * PRECISION / totalSupply_; if (newExchangePrice > vaultState.revenueExchangePrice) { if (vaultState.revenueExchangePrice == 0) { vaultState.revenueExchangePrice = newExchangePrice; vaultState.exchangePrice = newExchangePrice; return (vaultState.exchangePrice, vaultState.revenue); } uint256 newProfit_ = currentNetAssets_ - ((vaultState.revenueExchangePrice * totalSupply_) / PRECISION); newRevenue = (newProfit_ * vaultParams.revenueRate) / FEE_DENOMINATOR; vaultState.revenue += newRevenue; uint256 oldExchangePrice_ = vaultState.exchangePrice; vaultState.exchangePrice = ((currentNetAssets_ - newRevenue) * PRECISION) / totalSupply_; if (vaultState.exchangePrice - oldExchangePrice_ > oldExchangePrice_ * MAX_PRICE_CHANGE_RATE / 1e4) { revert Errors.IncorrectState(); } vaultState.revenueExchangePrice = vaultState.exchangePrice; } else { uint256 diffExchangePrice_ = vaultState.exchangePrice > newExchangePrice ? vaultState.exchangePrice - newExchangePrice : newExchangePrice - vaultState.exchangePrice; if (diffExchangePrice_ > vaultState.exchangePrice * MAX_PRICE_CHANGE_RATE / 1e4) { revert Errors.IncorrectState(); } vaultState.exchangePrice = newExchangePrice; } emit UpdateExchangePrice(newExchangePrice, newRevenue); } /** * @dev Transfer tokens to a strategy. * @param _token The address of the token to transfer. * @param _amount The amount of tokens to transfer. * @param _strategyIndex The index of the strategy to transfer to. */ function transferToStrategy(address _token, uint256 _amount, uint256 _strategyIndex) external { address caller_ = msg.sender; if (_strategyIndex == 0) { if (caller_ != owner() && caller_ != vaultParams.rebalancer) revert Errors.InvalidOperator(); } else { if (caller_ != owner()) revert Errors.InvalidOperator(); } address strategyAddress_ = strategyAddress(_strategyIndex); uint256 positionLimit_ = positionLimit[strategyAddress_]; uint256 nowAssets_ = IStrategy(strategyAddress_).getNetAssets(); uint8 coreDecimals_ = decimals(); uint8 tokenDecimals_ = IERC20Metadata(_token).decimals(); uint256 transferAsset_ = _amount; if (tokenDecimals_ > coreDecimals_) { transferAsset_ = _amount / (10 ** (tokenDecimals_ - coreDecimals_)); } else if (tokenDecimals_ < coreDecimals_) { transferAsset_ = _amount * (10 ** (coreDecimals_ - tokenDecimals_)); } if ((nowAssets_ + transferAsset_) > (totalAssets() * positionLimit_ / 1e4)) revert Errors.InvalidLimit(); IERC20(_token).safeIncreaseAllowance(strategyAddress_, _amount); if (!IStrategy(strategyAddress_).onTransferIn(_token, _amount)) revert Errors.IncorrectState(); emit TransferToStrategy(_token, _amount, _strategyIndex); } /** * @dev Retrieve the amount of the exit fee. * @param _assetAmount The amount of asset to be withdrawn. * @return withdrawFee_ The exit fee to be deducted. */ function getWithdrawFee(uint256 _assetAmount) public view returns (uint256 withdrawFee_) { withdrawFee_ = _assetAmount * vaultParams.exitFeeRate / FEE_DENOMINATOR; } /** * @dev Retrieve the total value locked (TVL) in underlying assets. * @return The total value locked in underlying assets. */ function underlyingTvl() public virtual returns (uint256) { uint256 totalBal_; address token_; uint8 coreDecimals = decimals(); for (uint256 i = 0; i < tokens.length(); i++) { token_ = tokens.at(i); uint256 tokenBal_ = IERC20(token_).balanceOf(address(this)); uint8 tokenDecimals = IERC20Metadata(token_).decimals(); // Adjust balance based on the difference in decimals if (tokenDecimals > coreDecimals) { // If tokenDecimals is greater than core asset decimals, scale down to match core asset tokenBal_ = tokenBal_ / (10 ** (tokenDecimals - coreDecimals)); } else if (tokenDecimals < coreDecimals) { // If tokenDecimals is less than core asset decimals, scale up to match core asset tokenBal_ = tokenBal_ * (10 ** (coreDecimals - tokenDecimals)); } totalBal_ += tokenBal_; } uint256 totalStrategy_ = totalStrategiesAssets(); return totalStrategy_ + totalBal_ - vaultState.revenue; } /** * @dev Retrieve the amount of the actual shares in the vault. * @return The total amount of shares in the vault. */ function totalSupply() public view override(ERC20Upgradeable, IERC20) returns (uint256) { return ERC20Upgradeable.totalSupply() - unbackedMintedAmount; } /** * @dev Retrieve the amount of assets in the strategy pool. * @return The total assets in the strategy pool. */ function totalAssets() public view override returns (uint256) { if (block.timestamp - vaultState.lastUpdatePriceTime > vaultParams.maxPriceUpdatePeriod) { revert Errors.PriceNotUpdated(); } return vaultState.exchangePrice * totalSupply() / PRECISION; } /** * @return Actual LP price during the user's deposit phase. */ function exchangePrice() public view override returns (uint256) { return vaultState.exchangePrice; } /** * @dev When the actual LP price exceeds this price, performance fee settlement can be conducted. * @return LP price for settling performance fees. */ function revenueExchangePrice() public view override returns (uint256) { return vaultState.revenueExchangePrice; } /** * @return Currently accumulated performance fees. */ function revenue() public view override returns (uint256) { return vaultState.revenue; } /** * @return The remaining time. If it is 0, deposits are currently not allowed. * @dev If it is not 0, the admin needs to update the price within this period. */ function remainingUpdateTime() public view returns (uint256) { uint256 timeDiff_ = block.timestamp - vaultState.lastUpdatePriceTime; return vaultParams.maxPriceUpdatePeriod > timeDiff_ ? (vaultParams.maxPriceUpdatePeriod - timeDiff_) : 0; } /** * @dev Retrieve the maximum amount that can be deposited by an address. * @return maxAssets_ The maximum deposit amount. */ function maxDeposit(address) public view override returns (uint256 maxAssets_) { maxAssets_ = vaultParams.marketCapacity - totalAssets(); } /** * @return The actual LP price before the last update. * @dev If it is lower than current price, there might be a withdrawal rebalancing loss, * which the user needs to bear. This usually does not happen. */ function lastExchangePrice() public view override returns (uint256) { return EXCHANGE_PRICE_CACHE.asUint256().tload(); } /** * @dev Optional deposit function allowing deposits in different token types. * @param _token The address of the token to deposit. * @param _assets The amount of assets to deposit. * @param _receiver The address of the receiver of the shares. * @param _referral Address of the referrer. * @return shares_ The amount of shares issued. */ function optionalDeposit(address _token, uint256 _assets, address _receiver, address _referral) public payable virtual nonReentrant whenNotPaused returns (uint256 shares_) { if (vaultParams.maxPriceUpdatePeriod < block.timestamp - vaultState.lastUpdatePriceTime) { revert Errors.PriceNotUpdated(); } if (_token != asset()) revert Errors.InvalidUnderlyingToken(); shares_ = super.deposit(_assets, _receiver); emit OptionalDeposit(msg.sender, _token, _assets, _receiver, _referral); } /** * @dev Redemption operation executed by the redeemOperator. Currently, only rsETH redemptions are supported. * @param _token The address of the token to be redeemed. * @param _shares The amount of share tokens to be redeemed. * @param _cutPercentage The percentage of the rebalancing loss incurred. * @param _receiver The address of the receiver of the assets. * @param _owner The owner address of the shares. * @return assetsAfterFee_ The amount of assets obtained. */ function optionalRedeem(address _token, uint256 _shares, uint256 _cutPercentage, address _receiver, address _owner) public override nonReentrant whenNotPaused returns (uint256 assetsAfterFee_) { if (!tokens.contains(_token)) revert Errors.InvalidAsset(); if (msg.sender != vaultParams.redeemOperator) revert Errors.UnSupportedOperation(); if (vaultState.lastUpdatePriceTime != block.timestamp) revert Errors.PriceNotUpdated(); if (_shares == type(uint256).max) { _shares = maxRedeem(_owner); } else { require(_shares <= maxRedeem(_owner), "ERC4626: redeem more than max"); } if (msg.sender != _owner) { _spendAllowance(_owner, msg.sender, _shares); } uint256 assets_ = previewRedeem(_shares * (PRECISION - _cutPercentage) / PRECISION); _burn(_owner, _shares); assetsAfterFee_ = assets_ - getWithdrawFee(assets_); IERC20(_token).safeTransfer(_receiver, assetsAfterFee_); emit OptionalRedeem(_token, _shares, _receiver, _owner); } /** * @dev The deposit method of ERC4626, with the parameter being the amount of assets. * @param _assets The amount of asset being deposited. * @param _receiver The recipient of the share tokens. * @return shares_ The amount of share tokens obtained. */ function deposit(uint256 _assets, address _receiver) public override nonReentrant whenNotPaused returns (uint256 shares_) { if (vaultParams.maxPriceUpdatePeriod < block.timestamp - vaultState.lastUpdatePriceTime) { revert Errors.PriceNotUpdated(); } if (_assets == type(uint256).max) { _assets = IERC20(asset()).balanceOf(msg.sender); } shares_ = super.deposit(_assets, _receiver); } /** * @dev The deposit method of ERC4626, with the parameter being the amount of share tokens. * @param _shares The amount of share tokens to be minted. * @param _receiver The recipient of the share tokens. * @return assets_ The amount of assets consumed. */ function mint(uint256 _shares, address _receiver) public override nonReentrant whenNotPaused returns (uint256 assets_) { if (vaultParams.maxPriceUpdatePeriod < block.timestamp - vaultState.lastUpdatePriceTime) { revert Errors.PriceNotUpdated(); } assets_ = super.mint(_shares, _receiver); } function withdraw(uint256, address, address) public override returns (uint256) { // Only delayed withdrawals are supported revert Errors.NotSupportedYet(); } function redeem(uint256, address, address) public override returns (uint256) { // Only delayed withdrawals are supported revert Errors.NotSupportedYet(); } /** * @dev Burn unbacked minted shares. */ function burnUnbacked(uint256 _amount) external onlyUnbackedMinter { if (_amount > unbackedMintedAmount) revert Errors.InvalidShares(); unbackedMintedAmount -= _amount; _burn(unbackedMinter, _amount); } /** * @dev Mint unbacked minted shares, for providing liquidity on L2. */ function mintUnbacked(uint256 _amount) external onlyUnbackedMinter { unbackedMintedAmount += _amount; _mint(unbackedMinter, _amount); } /** * @dev When a user applies for redemption, his share will be * transferred to the RedeemOperator address. * @param _shares The amount of share tokens to be redeemed. * @param _token The address of the token to redeem. */ function requestRedeem(uint256 _shares, address _token) external nonReentrant whenNotPaused { if (_shares == 0) revert Errors.WithdrawZero(); _transfer(msg.sender, vaultParams.redeemOperator, _shares); IRedeemOperator(vaultParams.redeemOperator).registerWithdrawal(msg.sender, _shares); emit RequestRedeem(msg.sender, _shares, _token); } /** * @dev Collect management fee. */ function collectManagementFee() external { if (msg.sender != vaultParams.feeReceiver) revert Errors.InvalidFeeReceiver(); uint256 nowTime_ = block.timestamp; if (nowTime_ - vaultState.lastClaimMngFeeTime < vaultParams.managementFeeClaimPeriod) { revert Errors.InvalidClaimTime(); } vaultState.lastClaimMngFeeTime = nowTime_; uint256 assets_ = totalAssets() * vaultParams.managementFeeRate / FEE_DENOMINATOR; IERC20(asset()).safeTransfer(vaultParams.feeReceiver, assets_); emit CollectManagementFee(assets_); } /** * @dev Collect performance fees to the recipient address. */ function collectRevenue() external { if (msg.sender != vaultParams.feeReceiver) revert Errors.InvalidFeeReceiver(); IERC20(asset()).safeTransfer(vaultParams.feeReceiver, vaultState.revenue); emit CollectRevenue(vaultState.revenue); vaultState.revenue = 0; } function pause() external { if (msg.sender != owner() && msg.sender != vaultParams.rebalancer) revert Errors.UnSupportedOperation(); _pause(); } function unpause() external onlyOwner { _unpause(); } receive() external payable {} }
{ "optimizer": { "enabled": true, "runs": 100 }, "evmVersion": "cancun", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"uint256","name":"_minMarketCapacity","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"CallerNotMinter","type":"error"},{"inputs":[],"name":"CallerNotRebalancer","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":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExitFeeRateTooHigh","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[],"name":"IncorrectState","type":"error"},{"inputs":[],"name":"InvalidAdmin","type":"error"},{"inputs":[],"name":"InvalidAsset","type":"error"},{"inputs":[],"name":"InvalidClaimTime","type":"error"},{"inputs":[],"name":"InvalidFeeReceiver","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"InvalidLimit","type":"error"},{"inputs":[],"name":"InvalidOperator","type":"error"},{"inputs":[],"name":"InvalidRebalancer","type":"error"},{"inputs":[],"name":"InvalidRedeemOperator","type":"error"},{"inputs":[],"name":"InvalidShares","type":"error"},{"inputs":[],"name":"InvalidUnderlyingToken","type":"error"},{"inputs":[],"name":"ManagementFeeClaimPeriodTooShort","type":"error"},{"inputs":[],"name":"ManagementFeeRateTooHigh","type":"error"},{"inputs":[],"name":"MarketCapacityTooLow","type":"error"},{"inputs":[],"name":"MathOverflowedMulDiv","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"NotSupportedYet","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"PriceNotUpdated","type":"error"},{"inputs":[],"name":"PriceUpdatePeriodTooLong","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[],"name":"RevenueFeeRateTooHigh","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"UnSupportedOperation","type":"error"},{"inputs":[],"name":"UnsupportedToken","type":"error"},{"inputs":[],"name":"WithdrawZero","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"}],"name":"AddToken","type":"event"},{"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":false,"internalType":"uint256","name":"assets","type":"uint256"}],"name":"CollectManagementFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"revenue","type":"uint256"}],"name":"CollectRevenue","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"strategy","type":"address"},{"indexed":false,"internalType":"address","name":"impl","type":"address"}],"name":"CreateStrategy","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":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"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":"OptionalDeposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"address","name":"owner","type":"address"}],"name":"OptionalRedeem","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"strategy","type":"address"}],"name":"RemoveStrategy","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"}],"name":"RemoveToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"},{"indexed":false,"internalType":"address","name":"token","type":"address"}],"name":"RequestRedeem","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":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"strategyIndex","type":"uint256"}],"name":"TransferToStrategy","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newExchangePrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newRevenue","type":"uint256"}],"name":"UpdateExchangePrice","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldExitFeeRate","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newExitFeeRate","type":"uint256"}],"name":"UpdateExitFeeRate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldFeeReceiver","type":"address"},{"indexed":false,"internalType":"address","name":"newFeeReceiver","type":"address"}],"name":"UpdateFeeReceiver","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldManagementFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newManagementFee","type":"uint256"}],"name":"UpdateManagementFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldManagementFeeClaimPeriod","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newManagementFeeClaimPeriod","type":"uint256"}],"name":"UpdateManagementFeeClaimPeriod","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldCapacityLimit","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newCapacityLimit","type":"uint256"}],"name":"UpdateMarketCapacity","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldMaxPriceUpdatePeriod","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newMaxPriceUpdatePeriod","type":"uint256"}],"name":"UpdateMaxPriceUpdatePeriod","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldOperator","type":"address"},{"indexed":false,"internalType":"address","name":"newOperator","type":"address"}],"name":"UpdateOperator","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldRebalancer","type":"address"},{"indexed":false,"internalType":"address","name":"newRebalancer","type":"address"}],"name":"UpdateRebalancer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldRedeemOperator","type":"address"},{"indexed":false,"internalType":"address","name":"newRedeemOperator","type":"address"}],"name":"UpdateRedeemOperator","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldRevenueRate","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newRevenueRate","type":"uint256"}],"name":"UpdateRevenueRate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldLimit","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newLimit","type":"uint256"}],"name":"UpdateStrategyLimit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldUnbackedMinter","type":"address"},{"indexed":false,"internalType":"address","name":"newUnbackedMinter","type":"address"}],"name":"UpdateUnbackedMinter","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"},{"inputs":[],"name":"ETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ETHx","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_POSITION_LIMIT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"RSETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"STETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newToken","type":"address"}],"name":"addToken","outputs":[],"stateMutability":"nonpayable","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":"uint256","name":"_amount","type":"uint256"}],"name":"burnUnbacked","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"collectManagementFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"collectRevenue","outputs":[],"stateMutability":"nonpayable","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":[{"internalType":"address","name":"_impl","type":"address"},{"internalType":"bytes","name":"_initBytes","type":"bytes"},{"internalType":"uint256","name":"_positionLimit","type":"uint256"}],"name":"createStrategy","outputs":[],"stateMutability":"nonpayable","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"}],"name":"deposit","outputs":[{"internalType":"uint256","name":"shares_","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"exchangePrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrecison","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTokens","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getVaultParams","outputs":[{"components":[{"internalType":"address","name":"underlyingToken","type":"address"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"uint256","name":"marketCapacity","type":"uint256"},{"internalType":"uint256","name":"managementFeeRate","type":"uint256"},{"internalType":"uint256","name":"managementFeeClaimPeriod","type":"uint256"},{"internalType":"uint256","name":"maxPriceUpdatePeriod","type":"uint256"},{"internalType":"uint256","name":"revenueRate","type":"uint256"},{"internalType":"uint256","name":"exitFeeRate","type":"uint256"},{"internalType":"address","name":"admin","type":"address"},{"internalType":"address","name":"rebalancer","type":"address"},{"internalType":"address","name":"feeReceiver","type":"address"},{"internalType":"address","name":"redeemOperator","type":"address"}],"internalType":"struct IVault.VaultParams","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getVaultState","outputs":[{"components":[{"internalType":"uint256","name":"exchangePrice","type":"uint256"},{"internalType":"uint256","name":"revenueExchangePrice","type":"uint256"},{"internalType":"uint256","name":"revenue","type":"uint256"},{"internalType":"uint256","name":"lastClaimMngFeeTime","type":"uint256"},{"internalType":"uint256","name":"lastUpdatePriceTime","type":"uint256"}],"internalType":"struct IVault.VaultState","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_assetAmount","type":"uint256"}],"name":"getWithdrawFee","outputs":[{"internalType":"uint256","name":"withdrawFee_","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"_initBytes","type":"bytes"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lastExchangePrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"maxDeposit","outputs":[{"internalType":"uint256","name":"maxAssets_","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"maxMint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"maxRedeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"maxWithdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_shares","type":"uint256"},{"internalType":"address","name":"_receiver","type":"address"}],"name":"mint","outputs":[{"internalType":"uint256","name":"assets_","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"mintUnbacked","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_assets","type":"uint256"},{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"address","name":"_referral","type":"address"}],"name":"optionalDeposit","outputs":[{"internalType":"uint256","name":"shares_","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_shares","type":"uint256"},{"internalType":"uint256","name":"_cutPercentage","type":"uint256"},{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"address","name":"_owner","type":"address"}],"name":"optionalRedeem","outputs":[{"internalType":"uint256","name":"assetsAfterFee_","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"positionLimit","outputs":[{"internalType":"uint256","name":"","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":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"redeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"remainingUpdateTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_strategy","type":"address"}],"name":"removeStrategy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"removeToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_shares","type":"uint256"},{"internalType":"address","name":"_token","type":"address"}],"name":"requestRedeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"revenue","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"revenueExchangePrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"strategies","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"strategiesCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_offset","type":"uint256"}],"name":"strategyAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_offset","type":"uint256"}],"name":"strategyAssets","outputs":[{"internalType":"uint256","name":"totalAssets_","type":"uint256"}],"stateMutability":"nonpayable","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":"totalStrategiesAssets","outputs":[{"internalType":"uint256","name":"totalAssets_","type":"uint256"}],"stateMutability":"nonpayable","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":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_strategyIndex","type":"uint256"}],"name":"transferToStrategy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unbackedMintedAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unbackedMinter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"underlyingTvl","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"updateExchangePrice","outputs":[{"internalType":"uint256","name":"newExchangePrice","type":"uint256"},{"internalType":"uint256","name":"newRevenue","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newExitFeeRate","type":"uint256"}],"name":"updateExitFeeRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newFeeReceiver","type":"address"}],"name":"updateFeeReceiver","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newManagementFeeRate","type":"uint256"}],"name":"updateManagementFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newmanagementFeeClaimPeriod","type":"uint256"}],"name":"updateManagementFeeClaimPeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newCapacityLimit","type":"uint256"}],"name":"updateMarketCapacity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newMaxPriceUpdatePeriod","type":"uint256"}],"name":"updateMaxPriceUpdatePeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newRebalancer","type":"address"}],"name":"updateRebalancer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newRedeemOperator","type":"address"}],"name":"updateRedeemOperator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newRevenueRate","type":"uint256"}],"name":"updateRevenueRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_offset","type":"uint256"},{"internalType":"uint256","name":"_newPositionLimit","type":"uint256"}],"name":"updateStrategyLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newUnbackedMinter","type":"address"}],"name":"updateUnbackedMinter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"withdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
60e0604052348015600e575f80fd5b50604051615eb0380380615eb0833981016040819052602b916043565b670de0b6b3a7640000608081905260a05260c0526059565b5f602082840312156052575f80fd5b5051919050565b60805160a05160c051615e0a6100a65f395f611e1d01525f611f4801525f8181610d3101528181610eb6015281816119cb01528181611a2701528181611aaa0152612ac80152615e0a5ff3fe60806040526004361061047c575f3560e01c80638322fff21161024c578063ba0876521161013f578063d9f9027f116100be578063ef8b30f711610083578063ef8b30f714610c4d578063f2fde38b14610d69578063f4ad878814610d88578063f6c278c114610d9d578063fa559a3514610dc4578063ffa1ad7414610de3575f80fd5b8063d9f9027f14610cc9578063dd62ed3e14610cdd578063e00bfe5014610cfc578063e3ea7c6a14610d23578063ed14d17e14610d55575f80fd5b8063c69bebe411610104578063c69bebe414610c2e578063c6e6f59214610c4d578063ce96cb7714610c6c578063d48bfca714610c8b578063d905777e14610caa575f80fd5b8063ba08765214610b89578063ba8bfa2a14610ba8578063bf6590a414610bc7578063c0587a9514610bdb578063c63d75b614610c0e575f80fd5b8063a7b73254116101cb578063b046a44911610190578063b046a44914610b01578063b0caa89114610b20578063b2db983a14610b4b578063b3d7f6b914610b6a578063b460af9414610b89575f80fd5b8063a7b7325414610a5c578063a9059cbb14610a7b578063aa6ca80814610a9a578063ad35530b14610abb578063ad5c464814610ada575f80fd5b806395d89b411161021157806395d89b41146109ed57806398e1862c14610a015780639c016ffd14610a155780639c5861b614610a295780639e65741e14610a48575f80fd5b80638322fff21461095e5780638456cb591461098557806388bb4f60146109995780638da5cb5b146109ba57806394bf804d146109ce575f80fd5b806338d52e0f1161036f5780634cdad506116102ee5780636e553f65116102b35780636e553f65146108af57806370a08231146108ce578063715018a6146108ed5780637a825e07146109015780637f6c81b7146109205780638152cd181461093f575f80fd5b80634cdad5061461052357806355d17ee014610836578063596384ae1461085d5780635c975abb1461087c5780635fa7b58414610890575f80fd5b80633f4ba83a116103345780633f4ba83a14610770578063402d267d14610784578063439fab91146107a35780634a8c110a146107c25780634b59b82e14610817575f80fd5b806338d52e0f146106df5780633b0426db146107005780633bfaa7e3146107145780633c5280e41461073d5780633e9491a21461075c575f80fd5b806318160ddd116103fb57806329c23e4a116103c057806329c23e4a146106535780632de10fab14610672578063313ce5671461068757806332507a5f146106ad57806334069157146106c0575f80fd5b806318160ddd146105ce57806323b872dd146105e25780632489f7f71461060157806325bd414214610615578063266f8dc914610634575f80fd5b806307a2d13a1161044157806307a2d13a14610523578063095ea7b3146105425780630a28a47714610571578063107703ab14610590578063175188e8146105af575f80fd5b806301c704ba1461048757806301e1d114146104a8578063030d624a146104cf57806306fdde03146104ee578063079c3b881461050f575f80fd5b3661048357005b5f80fd5b348015610492575f80fd5b506104a66104a1366004614499565b610e11565b005b3480156104b3575f80fd5b506104bc610e82565b6040519081526020015b60405180910390f35b3480156104da575f80fd5b506104a66104e93660046144b2565b610ef9565b3480156104f9575f80fd5b50610502610f64565b6040516104c691906144f7565b34801561051a575f80fd5b506104bc611002565b34801561052e575f80fd5b506104bc61053d3660046144b2565b6110a8565b34801561054d575f80fd5b5061056161055c366004614509565b6110b9565b60405190151581526020016104c6565b34801561057c575f80fd5b506104bc61058b3660046144b2565b6110d0565b34801561059b575f80fd5b506104a66105aa366004614531565b6110dc565b3480156105ba575f80fd5b506104a66105c9366004614499565b6111d8565b3480156105d9575f80fd5b506104bc6112c1565b3480156105ed575f80fd5b506105616105fc36600461455b565b6112d7565b34801561060c575f80fd5b506104bc6112fc565b348015610620575f80fd5b506104a661062f3660046144b2565b611306565b34801561063f575f80fd5b506104a661064e3660046144b2565b611371565b34801561065e575f80fd5b506104bc61066d3660046144b2565b6113dd565b34801561067d575f80fd5b506104bc60175481565b348015610692575f80fd5b5061069b6113fa565b60405160ff90911681526020016104c6565b6104bc6106bb366004614594565b611423565b3480156106cb575f80fd5b506104a66106da3660046144b2565b61187e565b3480156106ea575f80fd5b506106f36118eb565b6040516104c691906145de565b34801561070b575f80fd5b506104bc611905565b34801561071f575f80fd5b50610728611938565b604080519283526020830191909152016104c6565b348015610748575f80fd5b506104a66107573660046144b2565b611bee565b348015610767575f80fd5b506012546104bc565b34801561077b575f80fd5b506104a6611c5b565b34801561078f575f80fd5b506104bc61079e366004614499565b611c6d565b3480156107ae575f80fd5b506104a66107bd366004614636565b611c83565b3480156107cd575f80fd5b506107d661213c565b6040516104c691905f60a082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015292915050565b348015610822575f80fd5b506106f36108313660046144b2565b61219e565b348015610841575f80fd5b506106f373a1290d69c65a6fe4df752f95823fae25cb99e5a781565b348015610868575f80fd5b506104a66108773660046144b2565b6121a9565b348015610887575f80fd5b50610561612203565b34801561089b575f80fd5b506104a66108aa366004614499565b612217565b3480156108ba575f80fd5b506104bc6108c9366004614531565b61225a565b3480156108d9575f80fd5b506104bc6108e8366004614499565b61232b565b3480156108f8575f80fd5b506104a6612354565b34801561090c575f80fd5b506104a661091b366004614499565b612365565b34801561092b575f80fd5b506104a661093a3660046144b2565b6123fd565b34801561094a575f80fd5b506104a6610959366004614674565b612468565b348015610969575f80fd5b506106f373eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee81565b348015610990575f80fd5b506104a6612516565b3480156109a4575f80fd5b506109ad612570565b6040516104c69190614694565b3480156109c5575f80fd5b506106f36127ba565b3480156109d9575f80fd5b506104bc6109e8366004614531565b6127e2565b3480156109f8575f80fd5b5061050261282c565b348015610a0c575f80fd5b506011546104bc565b348015610a20575f80fd5b506104a6612848565b348015610a34575f80fd5b506104a6610a433660046144b2565b612932565b348015610a53575f80fd5b506010546104bc565b348015610a67575f80fd5b506104bc610a7636600461479e565b6129ac565b348015610a86575f80fd5b50610561610a95366004614509565b612b9e565b348015610aa5575f80fd5b50610aae612bab565b6040516104c691906147f1565b348015610ac6575f80fd5b506104a6610ad536600461483d565b612bb7565b348015610ae5575f80fd5b506106f373c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b348015610b0c575f80fd5b506104a6610b1b366004614499565b612c8b565b348015610b2b575f80fd5b506104bc610b3a366004614499565b60026020525f908152604090205481565b348015610b56575f80fd5b506104bc610b653660046144b2565b612d26565b348015610b75575f80fd5b506104bc610b843660046144b2565b612d91565b348015610b94575f80fd5b506104bc610ba3366004614892565b612d9d565b348015610bb3575f80fd5b506104a6610bc23660046148cb565b612db7565b348015610bd2575f80fd5b506104bc6130db565b348015610be6575f80fd5b507f4995646f72fa9a270ffc094641ab616ce576b2e3eab25eaf05c15caa4f0e595d5c6104bc565b348015610c19575f80fd5b506104bc610c28366004614499565b505f1990565b348015610c39575f80fd5b506104a6610c48366004614499565b613190565b348015610c58575f80fd5b506104bc610c673660046144b2565b613228565b348015610c77575f80fd5b506104bc610c86366004614499565b613233565b348015610c96575f80fd5b506104a6610ca5366004614499565b613246565b348015610cb5575f80fd5b506104bc610cc4366004614499565b6132b0565b348015610cd4575f80fd5b50610aae6132ba565b348015610ce8575f80fd5b506104bc610cf73660046148fb565b6132c5565b348015610d07575f80fd5b506106f373ae7ab96520de3a18e5e111b5eaab095312d7fe8481565b348015610d2e575f80fd5b507f00000000000000000000000000000000000000000000000000000000000000006104bc565b348015610d60575f80fd5b506104a66132ff565b348015610d74575f80fd5b506104a6610d83366004614499565b613382565b348015610d93575f80fd5b506104bc61271081565b348015610da8575f80fd5b506106f373a35b1b31ce002fbf2058d22f30f95d405200a15b81565b348015610dcf575f80fd5b506018546106f3906001600160a01b031681565b348015610dee575f80fd5b50610502604051806040016040528060038152602001620322e360ec1b81525081565b610e196133bc565b6018546040517f65c8da338cfcbb5abedd2f9099bb2a2bdf31ffc65d130e715901eeb06b205cdf91610e58916001600160a01b03909116908490614923565b60405180910390a1601880546001600160a01b0319166001600160a01b0392909216919091179055565b6009546014545f9190610e959042614951565b1115610eb457604051631f4bcb2b60e01b815260040160405180910390fd5b7f0000000000000000000000000000000000000000000000000000000000000000610edd6112c1565b601054610eea9190614964565b610ef4919061498f565b905090565b610f016133bc565b6004811115610f23576040516309aa66eb60e01b815260040160405180910390fd5b60075460408051918252602082018390527f29b9d7a7d8a7a3ac22c295e4517723bc4e386eea60173e59e6da1dbd460cb409910160405180910390a1600755565b60605f610f6f6133ee565b9050806003018054610f80906149a2565b80601f0160208091040260200160405190810160405280929190818152602001828054610fac906149a2565b8015610ff75780601f10610fce57610100808354040283529160200191610ff7565b820191905f5260205f20905b815481529060010190602001808311610fda57829003601f168201915b505050505091505090565b6040516370a0823160e01b81525f90819073a1290d69c65a6fe4df752f95823fae25cb99e5a7906370a082319061103d9030906004016145de565b602060405180830381865afa158015611058573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061107c91906149da565b90505f6110876130db565b60125490915061109783836149f1565b6110a19190614951565b9250505090565b5f6110b3825f613412565b92915050565b5f336110c681858561344f565b5060019392505050565b5f6110b3826001613461565b6110e4613495565b6110ec6134df565b815f0361110c57604051637ea773a960e01b815260040160405180910390fd5b600f546111249033906001600160a01b031684613505565b600f546040516336c69b5d60e11b81526001600160a01b0390911690636d8d36ba906111569033908690600401614a04565b5f604051808303815f87803b15801561116d575f80fd5b505af115801561117f573d5f803e3d5ffd5b505060408051338152602081018690526001600160a01b0385168183015290517ff9fd31dd1a61b95c600dd5aa1a6330f6c5cbe70a39a660edc081daf217db3cfb9350908190036060019150a16111d4613562565b5050565b6111e06133bc565b5f816001600160a01b03166308bb5fb06040518163ffffffff1660e01b81526004016020604051808303815f875af115801561121e573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061124291906149da565b11156112615760405163e9ec812960e01b815260040160405180910390fd5b61126b5f82613588565b506001600160a01b0381165f9081526002602052604080822091909155517fd3281a40d50ae838fe77dc627744037b8f0fc6a5711d66119a9b670c5cde41af906112b69083906145de565b60405180910390a150565b5f6017546112cd61359c565b610ef49190614951565b5f336112e48582856135b0565b6112ef858585613505565b60019150505b9392505050565b5f610ef45f613600565b61130e6133bc565b60788111156113305760405163f4d1caab60e01b815260040160405180910390fd5b600b5460408051918252602082018390527f394967f6fe403cda0905b23e81b928c5ca79107000b1404c6b3185442f05213c910160405180910390a1600b55565b6113796133bc565b6105dc81111561139c57604051630674143f60e01b815260040160405180910390fd5b600a5460408051918252602082018390527f63058ed61801434ac6bfe39e74400bed7f3ba09b7cb6294092974450727eb753910160405180910390a1600a55565b600b545f90612710906113f09084614964565b6110b3919061498f565b5f80611404613609565b90505f815461141d9190600160a01b900460ff16614a1d565b91505090565b5f61142c613495565b6114346134df565b6001600160a01b03851673a35b1b31ce002fbf2058d22f30f95d405200a15b148061147b57506001600160a01b03851673ae7ab96520de3a18e5e111b5eaab095312d7fe84145b15611654576114956001600160a01b03861633308761362d565b6114bd6001600160a01b03861673036676389e48133b63a802f8635ad39e752d375d86613694565b6040516370a0823160e01b81525f9073a1290d69c65a6fe4df752f95823fae25cb99e5a7906370a08231906114f69030906004016145de565b602060405180830381865afa158015611511573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061153591906149da565b6040516361d70bb360e11b81526001600160a01b0388166004820152602481018790525f6044820181905260806064830152608482015290915073036676389e48133b63a802f8635ad39e752d375d9063c3ae17669060a4015f604051808303815f87803b1580156115a5575f80fd5b505af11580156115b7573d5f803e3d5ffd5b50506040516370a0823160e01b81525f925083915073a1290d69c65a6fe4df752f95823fae25cb99e5a7906370a08231906115f69030906004016145de565b602060405180830381865afa158015611611573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061163591906149da565b61163f9190614951565b905061164b8186613719565b9250505061180c565b73a1290d69c65a6fe4df752f95823fae25cb99e5a6196001600160a01b0386160161169f576116838484613719565b905061169a6001600160a01b03861633308761362d565b61180c565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeed196001600160a01b038616016117f3576040516370a0823160e01b81525f9073a1290d69c65a6fe4df752f95823fae25cb99e5a7906370a08231906116fd9030906004016145de565b602060405180830381865afa158015611718573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061173c91906149da565b6040516372c51c0b60e01b815290915073036676389e48133b63a802f8635ad39e752d375d906372c51c0b90349061178a905f906004019081526040602082018190525f9082015260600190565b5f604051808303818588803b1580156117a1575f80fd5b505af11580156117b3573d5f803e3d5ffd5b50506040516370a0823160e01b81525f935084925073a1290d69c65a6fe4df752f95823fae25cb99e5a791506370a08231906115f69030906004016145de565b60405163350b944160e11b815260040160405180910390fd5b61181683826137a6565b604080513381526001600160a01b03878116602083015281830187905285811660608301528416608082015290517f308d36d8f61bd4393536b6557142f55554c34d4ea2a3dbf54fe782b98889dfb29181900360a00190a1611876613562565b949350505050565b6118866133bc565b6203f4808111156118aa5760405163e88d3ecb60e01b815260040160405180910390fd5b60095460408051918252602082018390527fcc5a4a7c466fc20af4119a7a26048791fdb55cbd401aff36ef2bfc639662b2e2910160405180910390a1600955565b5f806118f5613609565b546001600160a01b031692915050565b6014545f9081906119169042614951565b9050806003600601541161192a575f61141d565b60095461141d908290614951565b600d545f9081906001600160a01b031633146119675760405163bd72e29160e01b815260040160405180910390fd5b601054611995907f4995646f72fa9a270ffc094641ab616ce576b2e3eab25eaf05c15caa4f0e595d906137da565b426014555f6119a26112c1565b9050805f036119ba5750506010546012549091509091565b5f6119c3611002565b9050816119f07f000000000000000000000000000000000000000000000000000000000000000083614964565b6119fa919061498f565b601154909450841115611b3c576011545f03611a2457505050601181905560108190556012549091565b5f7f000000000000000000000000000000000000000000000000000000000000000083601060010154611a579190614964565b611a61919061498f565b611a6b9083614951565b600a5490915061271090611a7f9083614964565b611a89919061498f565b93508360106002015f828254611a9f91906149f1565b9091555050601054837f0000000000000000000000000000000000000000000000000000000000000000611ad38786614951565b611add9190614964565b611ae7919061498f565b601055612710611af8606483614964565b611b02919061498f565b601054611b10908390614951565b1115611b2f57604051630508c93960e41b815260040160405180910390fd5b5050601054601155611baf565b5f8460105f015411611b5a57601054611b559086614951565b611b68565b601054611b68908690614951565b9050612710606460105f0154611b7e9190614964565b611b88919061498f565b811115611ba857604051630508c93960e41b815260040160405180910390fd5b5060108490555b60408051858152602081018590527f83d2ad38a3d31bbc70811535dd8943b0140df344c23e6e167ee1ca32f9a1a459910160405180910390a150509091565b611bf66133bc565b62093a80811015611c1a57604051632011727b60e11b815260040160405180910390fd5b60085460408051918252602082018390527fcdbf56e2a82365307f9691ad933e9762726485d202543fe224f47447d79feaf0910160405180910390a1600855565b611c636133bc565b611c6b6137e1565b565b5f611c76610e82565b6006546110b39190614951565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff1615906001600160401b03165f81158015611cc75750825b90505f826001600160401b03166001148015611ce25750303b155b905081158015611cf0575080155b15611d0e5760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff191660011785558315611d3857845460ff60401b1916600160401b1785555b5f80611d46888a018a614b91565b91509150611d5261382c565b611d5a61383c565b611d6c8260200151836040015161384c565b81516001600160a01b0316611d94576040516317dc37cb60e11b815260040160405180910390fd5b6101408201516001600160a01b0316611dc3576040516001626bbab960e11b0319815260040160405180910390fd5b6101208201516001600160a01b0316611def57604051630b5eba9f60e41b815260040160405180910390fd5b6101608201516001600160a01b0316611e1b57604051633480121760e21b815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000082606001511015611e6057604051633240d18160e21b815260040160405180910390fd5b600482608001511115611e86576040516309aa66eb60e01b815260040160405180910390fd5b62093a808260a001511015611eae57604051632011727b60e11b815260040160405180910390fd5b6203f4808260c001511115611ed65760405163e88d3ecb60e01b815260040160405180910390fd5b6105dc8260e001511115611efd57604051630674143f60e01b815260040160405180910390fd5b60788261010001511115611f245760405163f4d1caab60e01b815260040160405180910390fd5b611f3282610120015161385e565b8151611f3d9061386f565b4260138190556014557f00000000000000000000000000000000000000000000000000000000000000006010558151600380546001600160a01b0319166001600160a01b039092169190911781556020830151839190600490611fa09082614d1b565b5060408201516002820190611fb59082614d1b565b50606082015160038201556080820151600482015560a0820151600582015560c0820151600682015560e0820151600782015561010082015160088201556101208201516009820180546001600160a01b03199081166001600160a01b0393841617909155610140840151600a840180548316918416919091179055610160840151600b84018054831691841691909117905561018090930151600c909201805490931691161790555f5b81518110156120ea575f6001600160a01b031682828151811061208557612085614dda565b60200260200101516001600160a01b0316036120b4576040516317dc37cb60e11b815260040160405180910390fd5b6120e18282815181106120c9576120c9614dda565b6020026020010151601561388090919063ffffffff16565b50600101612060565b505050831561213357845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50505050505050565b6121696040518060a001604052805f81526020015f81526020015f81526020015f81526020015f81525090565b506040805160a08101825260105481526011546020820152601254918101919091526013546060820152601454608082015290565b5f6110b38183613894565b6018546001600160a01b031633146121d457604051632f771b3d60e11b815260040160405180910390fd5b8060175f8282546121e591906149f1565b9091555050601854612200906001600160a01b0316826137a6565b50565b5f8061220d61389f565b5460ff1692915050565b61221f6133bc565b61222a601582613588565b507f4eb129c82dcd3eedb52df2b0e6fb4cfa41ac64ee9d63ff081acbb1877e85d79b816040516112b691906145de565b5f612263613495565b61226b6134df565b6014546122789042614951565b600954101561229a57604051631f4bcb2b60e01b815260040160405180910390fd5b5f198303612317576122aa6118eb565b6001600160a01b03166370a08231336040518263ffffffff1660e01b81526004016122d591906145de565b602060405180830381865afa1580156122f0573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061231491906149da565b92505b61232183836138c3565b90506110b3613562565b5f806123356133ee565b6001600160a01b039093165f9081526020939093525050604090205490565b61235c6133bc565b611c6b5f61390f565b61236d6133bc565b6001600160a01b0381166123945760405163d214a59760e01b815260040160405180910390fd5b600f546040517fe74dd8b1f5f3d5328df682e649c08b085f09c2ce77b68e54329e8d30e2642f78916123d3916001600160a01b03909116908490614923565b60405180910390a1600f80546001600160a01b0319166001600160a01b0392909216919091179055565b6124056133bc565b60065481116124275760405163e9ec812960e01b815260040160405180910390fd5b60065460408051918252602082018390527f7f3306669f28a6aa13d0f709be2bd4f3e21d2f37aee9358846a50e1988ee4832910160405180910390a1600655565b6124706133bc565b80158061247e575061271081115b1561249c5760405163e55fb50960e01b815260040160405180910390fd5b5f6124a78184613894565b6001600160a01b0381165f908152600260209081526040918290205482519081529081018590529192507f7cd01dd3533c6dc08821cd303814de60aba1901f1531c3cbcd95d26ed924e9cf910160405180910390a16001600160a01b03165f9081526002602052604090205550565b61251e6127ba565b6001600160a01b0316336001600160a01b03161415801561254a5750600d546001600160a01b03163314155b156125685760405163e9ec812960e01b815260040160405180910390fd5b611c6b61397f565b6125fd604051806101a001604052805f6001600160a01b0316815260200160608152602001606081526020015f81526020015f81526020015f81526020015f81526020015f81526020015f81526020015f6001600160a01b031681526020015f6001600160a01b031681526020015f6001600160a01b031681526020015f6001600160a01b031681525090565b604080516101a08101909152600380546001600160a01b031682526004805460208401919061262b906149a2565b80601f0160208091040260200160405190810160405280929190818152602001828054612657906149a2565b80156126a25780601f10612679576101008083540402835291602001916126a2565b820191905f5260205f20905b81548152906001019060200180831161268557829003601f168201915b505050505081526020016002820180546126bb906149a2565b80601f01602080910402602001604051908101604052809291908181526020018280546126e7906149a2565b80156127325780601f1061270957610100808354040283529160200191612732565b820191905f5260205f20905b81548152906001019060200180831161271557829003601f168201915b505050918352505060038201546020820152600482015460408201526005820154606082015260068201546080820152600782015460a0820152600882015460c082015260098201546001600160a01b0390811660e0830152600a8301548116610100830152600b8301548116610120830152600c9092015490911661014090910152919050565b5f807f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c1993006118f5565b5f6127eb613495565b6127f36134df565b6014546128009042614951565b600954101561282257604051631f4bcb2b60e01b815260040160405180910390fd5b61232183836139c5565b60605f6128376133ee565b9050806004018054610f80906149a2565b600e546001600160a01b0316331461287357604051633480121760e21b815260040160405180910390fd5b6008546013544291906128869083614951565b10156128a557604051631221b97b60e01b815260040160405180910390fd5b60138190556007545f90612710906128bb610e82565b6128c59190614964565b6128cf919061498f565b600e549091506128fb906001600160a01b0316826128eb6118eb565b6001600160a01b031691906139e0565b6040518181527f55ce6141cc7099e5baac44c64543a6d7fc4e37ebba0fcaa65fa1f2a9996ec5a59060200160405180910390a15050565b6018546001600160a01b0316331461295d57604051632f771b3d60e11b815260040160405180910390fd5b60175481111561298057604051636edcc52360e01b815260040160405180910390fd5b8060175f8282546129919190614951565b9091555050601854612200906001600160a01b031682613a06565b5f6129b5613495565b6129bd6134df565b6129c8601587613a3a565b6129e557604051636448d6e960e11b815260040160405180910390fd5b600f546001600160a01b03163314612a105760405163e9ec812960e01b815260040160405180910390fd5b6014544214612a3257604051631f4bcb2b60e01b815260040160405180910390fd5b5f198503612a4a57612a43826132b0565b9450612aa7565b612a53826132b0565b851115612aa75760405162461bcd60e51b815260206004820152601d60248201527f455243343632363a2072656465656d206d6f7265207468616e206d617800000060448201526064015b60405180910390fd5b336001600160a01b03831614612ac257612ac28233876135b0565b5f612b057f0000000000000000000000000000000000000000000000000000000000000000612af18782614951565b612afb9089614964565b61053d919061498f565b9050612b118387613a06565b612b1a816113dd565b612b249082614951565b9150612b3a6001600160a01b03881685846139e0565b604080516001600160a01b03898116825260208201899052868116828401528516606082015290517f4e19afb1df46d77083cc4e520735afa0cdc2d763d6bc5d710661c3dbb35f4c4d9181900360800190a150612b95613562565b95945050505050565b5f336110c6818585613505565b6060610ef46015613a5b565b612bbf6133bc565b801580612bcd575061271081115b15612beb5760405163e55fb50960e01b815260040160405180910390fd5b5f84338585604051612bfc90614471565b612c099493929190614dee565b604051809103905ff080158015612c22573d5f803e3d5ffd5b506001600160a01b0381165f908152600260205260408120849055909150612c4a9082613880565b507f0803371633b57311f58d10924711080d2dae75ab17c5c0c262af3887cfca00bb8186604051612c7c929190614923565b60405180910390a15050505050565b612c936133bc565b6001600160a01b038116612cbd576040516001626bbab960e11b0319815260040160405180910390fd5b600d546040517fe2eeab472f89ac267be30e463da684fb96f56cc8e947839361fdf45bf6a3458e91612cfc916001600160a01b03909116908490614923565b60405180910390a1600d80546001600160a01b0319166001600160a01b0392909216919091179055565b5f612d318183613894565b6001600160a01b03166308bb5fb06040518163ffffffff1660e01b81526004016020604051808303815f875af1158015612d6d573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906110b391906149da565b5f6110b3826001613412565b5f604051637dc4dd1560e11b815260040160405180910390fd5b335f829003612e1a57612dc86127ba565b6001600160a01b0316816001600160a01b031614158015612df75750600d546001600160a01b03828116911614155b15612e155760405163ccea9e6f60e01b815260040160405180910390fd5b612e53565b612e226127ba565b6001600160a01b0316816001600160a01b031614612e535760405163ccea9e6f60e01b815260040160405180910390fd5b5f612e5d8361219e565b6001600160a01b0381165f818152600260209081526040808320548151628bb5fb60e41b81529151959650949293926308bb5fb092600480840193919291829003018187875af1158015612eb3573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612ed791906149da565b90505f612ee26113fa565b90505f886001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612f21573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612f459190614e38565b90508760ff8084169083161115612f7c57612f608383614e58565b612f6b90600a614f51565b612f75908a61498f565b9050612fac565b8260ff168260ff161015612fac57612f948284614e58565b612f9f90600a614f51565b612fa9908a614964565b90505b61271085612fb8610e82565b612fc29190614964565b612fcc919061498f565b612fd682866149f1565b1115612ff55760405163e55fb50960e01b815260040160405180910390fd5b6130096001600160a01b038b16878b613694565b6040516356f4edaf60e01b81526001600160a01b038716906356f4edaf90613037908d908d90600401614a04565b6020604051808303815f875af1158015613053573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906130779190614f5f565b61309457604051630508c93960e41b815260040160405180910390fd5b7f921f9e77ef648025190d46d8b7f3d22a5546367ff7aaa883b1f39ffd2a2d325d8a8a8a6040516130c793929190614f7e565b60405180910390a150505050505050505050565b5f806130e56112fc565b90505f6130f06132ba565b90505f5b8281101561318a5781818151811061310e5761310e614dda565b60200260200101516001600160a01b03166308bb5fb06040518163ffffffff1660e01b81526004016020604051808303815f875af1158015613152573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061317691906149da565b61318090856149f1565b93506001016130f4565b50505090565b6131986133bc565b6001600160a01b0381166131bf57604051633480121760e21b815260040160405180910390fd5b600e546040517f2861448678f0be67f11bfb5481b3e3b4cfeb3acc6126ad60a05f95bfc6530666916131fe916001600160a01b03909116908490614923565b60405180910390a1600e80546001600160a01b0319166001600160a01b0392909216919091179055565b5f6110b3825f613461565b5f6110b36132408361232b565b5f613412565b61324e6133bc565b6001600160a01b038116613275576040516317dc37cb60e11b815260040160405180910390fd5b613280601582613880565b507fe473c74f34be27c1464d6624f14a0d7fd4e301cbfa29c3eba425d378c8a7ebe0816040516112b691906145de565b5f6110b38261232b565b6060610ef45f613a5b565b5f806132cf6133ee565b6001600160a01b039485165f90815260019190910160209081526040808320959096168252939093525050205490565b600e546001600160a01b0316331461332a57604051633480121760e21b815260040160405180910390fd5b600e54601254613346916001600160a01b0316906128eb6118eb565b6012546040519081527f8a2034f45f83800eed1750a670ad845ceee6add62106ca5326598842cfbd6ea79060200160405180910390a15f601255565b61338a6133bc565b6001600160a01b0381166133b3575f604051631e4fbdf760e01b8152600401612a9e91906145de565b6122008161390f565b336133c56127ba565b6001600160a01b031614611c6b573360405163118cdaa760e01b8152600401612a9e91906145de565b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0090565b5f6112f561341e610e82565b6134299060016149f1565b6134345f600a614f51565b61343c6112c1565b61344691906149f1565b85919085613a67565b61345c8383836001613ab4565b505050565b5f6112f561347082600a614f51565b6134786112c1565b61348291906149f1565b61348a610e82565b6134469060016149f1565b7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f008054600119016134d957604051633ee5aeb560e01b815260040160405180910390fd5b60029055565b6134e7612203565b15611c6b5760405163d93c066560e01b815260040160405180910390fd5b6001600160a01b03831661352e575f604051634b637e8f60e11b8152600401612a9e91906145de565b6001600160a01b038216613557575f60405163ec442f0560e01b8152600401612a9e91906145de565b61345c838383613b95565b60017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b5f6112f5836001600160a01b038416613cb8565b5f806135a66133ee565b6002015492915050565b5f6135bb84846132c5565b90505f1981146135fa57818110156135ec57828183604051637dc7a0d960e11b8152600401612a9e93929190614f7e565b6135fa84848484035f613ab4565b50505050565b5f6110b3825490565b7f0773e532dfede91f04b12a73d3d2acd361424f41f76b4fb79f090161e36b4e0090565b6040516001600160a01b0384811660248301528381166044830152606482018390526135fa9186918216906323b872dd906084015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050613d9b565b604051636eb1769f60e11b81525f906001600160a01b0385169063dd62ed3e906136c49030908790600401614923565b602060405180830381865afa1580156136df573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061370391906149da565b90506135fa848461371485856149f1565b613df3565b5f8061372483611c6d565b90508084111561374d57828482604051633c8097d960e11b8152600401612a9e93929190614f7e565b61375684613228565b60408051868152602081018390529193506001600160a01b0385169133917fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d7910160405180910390a35092915050565b6001600160a01b0382166137cf575f60405163ec442f0560e01b8152600401612a9e91906145de565b6111d45f8383613b95565b80825d5050565b6137e9613e83565b5f6137f261389f565b805460ff1916815590507f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516112b691906145de565b613834613ea8565b611c6b613ef1565b613844613ea8565b611c6b613f0d565b613854613ea8565b6111d48282613f15565b613866613ea8565b61220081613f45565b613877613ea8565b61220081613f4d565b5f6112f5836001600160a01b038416613fba565b5f6112f58383614006565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f0330090565b5f806138ce83611c6d565b9050808411156138f757828482604051633c8097d960e11b8152600401612a9e93929190614f7e565b5f61390185613228565b90506118763385878461402c565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080546001600160a01b031981166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a3505050565b6139876134df565b5f61399061389f565b805460ff1916600117815590507f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861381f3390565b5f5f195f6139d285612d91565b90506118763385838861402c565b61345c83846001600160a01b031663a9059cbb8585604051602401613662929190614a04565b6001600160a01b038216613a2f575f604051634b637e8f60e11b8152600401612a9e91906145de565b6111d4825f83613b95565b6001600160a01b0381165f90815260018301602052604081205415156112f5565b60605f6112f5836140a7565b5f80613a74868686614100565b9050613a7f836141bf565b8015613a9a57505f8480613a9557613a9561497b565b868809115b15612b9557613aaa6001826149f1565b9695505050505050565b5f613abd6133ee565b90506001600160a01b038516613ae8575f60405163e602df0560e01b8152600401612a9e91906145de565b6001600160a01b038416613b11575f604051634a1406b160e11b8152600401612a9e91906145de565b6001600160a01b038086165f90815260018301602090815260408083209388168352929052208390558115613b8e57836001600160a01b0316856001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92585604051613b8591815260200190565b60405180910390a35b5050505050565b5f613b9e6133ee565b90506001600160a01b038416613bcc5781816002015f828254613bc191906149f1565b90915550613c299050565b6001600160a01b0384165f9081526020829052604090205482811015613c0b5784818460405163391434e360e21b8152600401612a9e93929190614f7e565b6001600160a01b0385165f9081526020839052604090209083900390555b6001600160a01b038316613c47576002810180548390039055613c65565b6001600160a01b0383165f9081526020829052604090208054830190555b826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051613caa91815260200190565b60405180910390a350505050565b5f8181526001830160205260408120548015613d92575f613cda600183614951565b85549091505f90613ced90600190614951565b9050808214613d4c575f865f018281548110613d0b57613d0b614dda565b905f5260205f200154905080875f018481548110613d2b57613d2b614dda565b5f918252602080832090910192909255918252600188019052604090208390555b8554869080613d5d57613d5d614f9f565b600190038181905f5260205f20015f90559055856001015f8681526020019081526020015f205f9055600193505050506110b3565b5f9150506110b3565b5f613daf6001600160a01b038416836141eb565b905080515f14158015613dd3575080806020019051810190613dd19190614f5f565b155b1561345c5782604051635274afe760e01b8152600401612a9e91906145de565b5f836001600160a01b031663095ea7b38484604051602401613e16929190614a04565b604051602081830303815290604052915060e01b6020820180516001600160e01b0383818316178352505050509050613e4f84826141f8565b6135fa57613e7984856001600160a01b031663095ea7b3865f604051602401613662929190614a04565b6135fa8482613d9b565b613e8b612203565b611c6b57604051638dfc202b60e01b815260040160405180910390fd5b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff16611c6b57604051631afcd79f60e31b815260040160405180910390fd5b613ef9613ea8565b5f613f0261389f565b805460ff1916905550565b613562613ea8565b613f1d613ea8565b5f613f266133ee565b905060038101613f368482614d1b565b50600481016135fa8382614d1b565b61338a613ea8565b613f55613ea8565b5f613f5e613609565b90505f80613f6b84614295565b9150915081613f7b576012613f7d565b805b83546001600160a81b031916600160a01b60ff92909216919091026001600160a01b031916176001600160a01b0394909416939093179091555050565b5f818152600183016020526040812054613fff57508154600181810184555f8481526020808220909301849055845484825282860190935260409020919091556110b3565b505f6110b3565b5f825f01828154811061401b5761401b614dda565b905f5260205f200154905092915050565b5f614035613609565b805490915061404f906001600160a01b031686308661362d565b61405984836137a6565b836001600160a01b0316856001600160a01b03167fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d78585604051613b85929190918252602082015260400190565b6060815f018054806020026020016040519081016040528092919081815260200182805480156140f457602002820191905f5260205f20905b8154815260200190600101908083116140e0575b50505050509050919050565b5f838302815f1985870982811083820303915050805f036141345783828161412a5761412a61497b565b04925050506112f5565b8084116141545760405163227bc15360e01b815260040160405180910390fd5b5f848688095f868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b5f60028260038111156141d4576141d4614fb3565b6141de9190614fc7565b60ff166001149050919050565b60606112f583835f61436b565b5f805f846001600160a01b0316846040516142139190614fe8565b5f604051808303815f865af19150503d805f811461424c576040519150601f19603f3d011682016040523d82523d5f602084013e614251565b606091505b509150915081801561427b57508051158061427b57508080602001905181019061427b9190614f5f565b8015612b955750505050506001600160a01b03163b151590565b60408051600481526024810182526020810180516001600160e01b031663313ce56760e01b17905290515f918291829182916001600160a01b038716916142db91614fe8565b5f60405180830381855afa9150503d805f8114614313576040519150601f19603f3d011682016040523d82523d5f602084013e614318565b606091505b509150915081801561432c57506020815110155b1561435f575f8180602001905181019061434691906149da565b905060ff811161435d576001969095509350505050565b505b505f9485945092505050565b606081471015614390573060405163cd78605960e01b8152600401612a9e91906145de565b5f80856001600160a01b031684866040516143ab9190614fe8565b5f6040518083038185875af1925050503d805f81146143e5576040519150601f19603f3d011682016040523d82523d5f602084013e6143ea565b606091505b5091509150613aaa86838360608261440a5761440582614448565b6112f5565b815115801561442157506001600160a01b0384163b155b156144415783604051639996b31560e01b8152600401612a9e91906145de565b50806112f5565b8051156144585780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b610dd680614fff83390190565b80356001600160a01b0381168114614494575f80fd5b919050565b5f602082840312156144a9575f80fd5b6112f58261447e565b5f602082840312156144c2575f80fd5b5035919050565b5f81518084528060208401602086015e5f602082860101526020601f19601f83011685010191505092915050565b602081525f6112f560208301846144c9565b5f806040838503121561451a575f80fd5b6145238361447e565b946020939093013593505050565b5f8060408385031215614542575f80fd5b823591506145526020840161447e565b90509250929050565b5f805f6060848603121561456d575f80fd5b6145768461447e565b92506145846020850161447e565b9150604084013590509250925092565b5f805f80608085870312156145a7575f80fd5b6145b08561447e565b9350602085013592506145c56040860161447e565b91506145d36060860161447e565b905092959194509250565b6001600160a01b0391909116815260200190565b5f8083601f840112614602575f80fd5b5081356001600160401b03811115614618575f80fd5b60208301915083602082850101111561462f575f80fd5b9250929050565b5f8060208385031215614647575f80fd5b82356001600160401b0381111561465c575f80fd5b614668858286016145f2565b90969095509350505050565b5f8060408385031215614685575f80fd5b50508035926020909101359150565b602081526146ae6020820183516001600160a01b03169052565b5f60208301516101a08060408501526146cb6101c08501836144c9565b91506040850151601f198584030160608601526146e883826144c9565b92505060608501516080850152608085015160a085015260a085015160c085015260c085015160e085015260e085015161010081818701528087015191505061012081818701528087015191505061014061474d818701836001600160a01b03169052565b8601519050610160614769868201836001600160a01b03169052565b8601519050610180614785868201836001600160a01b03169052565b909501516001600160a01b031693019290925250919050565b5f805f805f60a086880312156147b2575f80fd5b6147bb8661447e565b945060208601359350604086013592506147d76060870161447e565b91506147e56080870161447e565b90509295509295909350565b602080825282518282018190525f9190848201906040850190845b818110156148315783516001600160a01b03168352928401929184019160010161480c565b50909695505050505050565b5f805f8060608587031215614850575f80fd5b6148598561447e565b935060208501356001600160401b03811115614873575f80fd5b61487f878288016145f2565b9598909750949560400135949350505050565b5f805f606084860312156148a4575f80fd5b833592506148b46020850161447e565b91506148c26040850161447e565b90509250925092565b5f805f606084860312156148dd575f80fd5b6148e68461447e565b95602085013595506040909401359392505050565b5f806040838503121561490c575f80fd5b6149158361447e565b91506145526020840161447e565b6001600160a01b0392831681529116602082015260400190565b634e487b7160e01b5f52601160045260245ffd5b818103818111156110b3576110b361493d565b80820281158282048414176110b3576110b361493d565b634e487b7160e01b5f52601260045260245ffd5b5f8261499d5761499d61497b565b500490565b600181811c908216806149b657607f821691505b6020821081036149d457634e487b7160e01b5f52602260045260245ffd5b50919050565b5f602082840312156149ea575f80fd5b5051919050565b808201808211156110b3576110b361493d565b6001600160a01b03929092168252602082015260400190565b60ff81811683821601908111156110b3576110b361493d565b634e487b7160e01b5f52604160045260245ffd5b6040516101a081016001600160401b0381118282101715614a6d57614a6d614a36565b60405290565b604051601f8201601f191681016001600160401b0381118282101715614a9b57614a9b614a36565b604052919050565b5f82601f830112614ab2575f80fd5b81356001600160401b03811115614acb57614acb614a36565b614ade601f8201601f1916602001614a73565b818152846020838601011115614af2575f80fd5b816020850160208301375f918101602001919091529392505050565b5f82601f830112614b1d575f80fd5b813560206001600160401b03821115614b3857614b38614a36565b8160051b614b47828201614a73565b9283528481018201928281019087851115614b60575f80fd5b83870192505b84831015614b8657614b778361447e565b82529183019190830190614b66565b979650505050505050565b5f8060408385031215614ba2575f80fd5b82356001600160401b0380821115614bb8575f80fd5b908401906101a08287031215614bcc575f80fd5b614bd4614a4a565b614bdd8361447e565b8152602083013582811115614bf0575f80fd5b614bfc88828601614aa3565b602083015250604083013582811115614c13575f80fd5b614c1f88828601614aa3565b604083015250606083013560608201526080830135608082015260a083013560a082015260c083013560c082015260e083013560e0820152610100808401358183015250610120614c7181850161447e565b90820152610140614c8384820161447e565b90820152610160614c9584820161447e565b90820152610180614ca784820161447e565b9082015293506020850135915080821115614cc0575f80fd5b50614ccd85828601614b0e565b9150509250929050565b601f82111561345c57805f5260205f20601f840160051c81016020851015614cfc5750805b601f840160051c820191505b81811015613b8e575f8155600101614d08565b81516001600160401b03811115614d3457614d34614a36565b614d4881614d4284546149a2565b84614cd7565b602080601f831160018114614d7b575f8415614d645750858301515b5f19600386901b1c1916600185901b178555614dd2565b5f85815260208120601f198616915b82811015614da957888601518255948401946001909101908401614d8a565b5085821015614dc657878501515f19600388901b60f8161c191681555b505060018460011b0185555b505050505050565b634e487b7160e01b5f52603260045260245ffd5b6001600160a01b0385811682528416602082015260606040820181905281018290525f828460808401375f608084840101526080601f19601f850116830101905095945050505050565b5f60208284031215614e48575f80fd5b815160ff811681146112f5575f80fd5b60ff82811682821603908111156110b3576110b361493d565b600181815b80851115614eab57815f1904821115614e9157614e9161493d565b80851615614e9e57918102915b93841c9390800290614e76565b509250929050565b5f82614ec1575060016110b3565b81614ecd57505f6110b3565b8160018114614ee35760028114614eed57614f09565b60019150506110b3565b60ff841115614efe57614efe61493d565b50506001821b6110b3565b5060208310610133831016604e8410600b8410161715614f2c575081810a6110b3565b614f368383614e71565b805f1904821115614f4957614f4961493d565b029392505050565b5f6112f560ff841683614eb3565b5f60208284031215614f6f575f80fd5b815180151581146112f5575f80fd5b6001600160a01b039390931683526020830191909152604082015260600190565b634e487b7160e01b5f52603160045260245ffd5b634e487b7160e01b5f52602160045260245ffd5b5f60ff831680614fd957614fd961497b565b8060ff84160691505092915050565b5f82518060208501845e5f92019182525091905056fe60a0604052604051610dd6380380610dd68339810160408190526100229161036a565b828161002e828261008c565b50508160405161003d9061032e565b6001600160a01b039091168152602001604051809103905ff080158015610066573d5f803e3d5ffd5b506001600160a01b031660805261008461007f60805190565b6100ea565b50505061044b565b61009582610157565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a28051156100de576100d982826101d5565b505050565b6100e6610248565b5050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6101295f80516020610db6833981519152546001600160a01b031690565b604080516001600160a01b03928316815291841660208301520160405180910390a161015481610269565b50565b806001600160a01b03163b5f0361019157604051634c9c8ce360e01b81526001600160a01b03821660048201526024015b60405180910390fd5b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5b80546001600160a01b0319166001600160a01b039290921691909117905550565b60605f80846001600160a01b0316846040516101f19190610435565b5f60405180830381855af49150503d805f8114610229576040519150601f19603f3d011682016040523d82523d5f602084013e61022e565b606091505b50909250905061023f8583836102a6565b95945050505050565b34156102675760405163b398979f60e01b815260040160405180910390fd5b565b6001600160a01b03811661029257604051633173bdd160e11b81525f6004820152602401610188565b805f80516020610db68339815191526101b4565b6060826102bb576102b682610305565b6102fe565b81511580156102d257506001600160a01b0384163b155b156102fb57604051639996b31560e01b81526001600160a01b0385166004820152602401610188565b50805b9392505050565b8051156103155780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b610501806108b583390190565b80516001600160a01b0381168114610351575f80fd5b919050565b634e487b7160e01b5f52604160045260245ffd5b5f805f6060848603121561037c575f80fd5b6103858461033b565b92506103936020850161033b565b60408501519092506001600160401b03808211156103af575f80fd5b818601915086601f8301126103c2575f80fd5b8151818111156103d4576103d4610356565b604051601f8201601f19908116603f011681019083821181831017156103fc576103fc610356565b81604052828152896020848701011115610414575f80fd5b8260208601602083015e5f6020848301015280955050505050509250925092565b5f82518060208501845e5f920191825250919050565b6080516104536104625f395f601001526104535ff3fe608060405261000c61000e565b005b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361007a575f356001600160e01b03191663278f794360e11b14610070576040516334ad5dbb60e21b815260040160405180910390fd5b610078610082565b565b6100786100b0565b5f806100913660048184610303565b81019061009e919061033e565b915091506100ac82826100c0565b5050565b6100786100bb61011a565b610151565b6100c98261016f565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a28051156101125761010d82826101ea565b505050565b6100ac61025c565b5f61014c7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b365f80375f80365f845af43d5f803e80801561016b573d5ff35b3d5ffd5b806001600160a01b03163b5f036101a957604051634c9c8ce360e01b81526001600160a01b03821660048201526024015b60405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b60605f80846001600160a01b0316846040516102069190610407565b5f60405180830381855af49150503d805f811461023e576040519150601f19603f3d011682016040523d82523d5f602084013e610243565b606091505b509150915061025385838361027b565b95945050505050565b34156100785760405163b398979f60e01b815260040160405180910390fd5b6060826102905761028b826102da565b6102d3565b81511580156102a757506001600160a01b0384163b155b156102d057604051639996b31560e01b81526001600160a01b03851660048201526024016101a0565b50805b9392505050565b8051156102ea5780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b5f8085851115610311575f80fd5b8386111561031d575f80fd5b5050820193919092039150565b634e487b7160e01b5f52604160045260245ffd5b5f806040838503121561034f575f80fd5b82356001600160a01b0381168114610365575f80fd5b9150602083013567ffffffffffffffff80821115610381575f80fd5b818501915085601f830112610394575f80fd5b8135818111156103a6576103a661032a565b604051601f8201601f19908116603f011681019083821181831017156103ce576103ce61032a565b816040528281528860208487010111156103e6575f80fd5b826020860160208301375f6020848301015280955050505050509250929050565b5f82518060208501845e5f92019182525091905056fea2646970667358221220117f216494c9098d12bbff87c8d584f4d545471f7a95c3c910c20d7f0d1a105964736f6c63430008190033608060405234801561000f575f80fd5b5060405161050138038061050183398101604081905261002e916100bb565b806001600160a01b03811661005c57604051631e4fbdf760e01b81525f600482015260240160405180910390fd5b6100658161006c565b50506100e8565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b5f602082840312156100cb575f80fd5b81516001600160a01b03811681146100e1575f80fd5b9392505050565b61040c806100f55f395ff3fe608060405260043610610049575f3560e01c8063715018a61461004d5780638da5cb5b146100635780639623609d14610090578063ad3cb1cc146100a3578063f2fde38b146100e0575b5f80fd5b348015610058575f80fd5b506100616100ff565b005b34801561006e575f80fd5b505f546001600160a01b0316604051610087919061023e565b60405180910390f35b61006161009e36600461027a565b610112565b3480156100ae575f80fd5b506100d3604051806040016040528060058152602001640352e302e360dc1b81525081565b6040516100879190610377565b3480156100eb575f80fd5b506100616100fa366004610390565b61017d565b6101076101c3565b6101105f6101ef565b565b61011a6101c3565b60405163278f794360e11b81526001600160a01b03841690634f1ef28690349061014a90869086906004016103ab565b5f604051808303818588803b158015610161575f80fd5b505af1158015610173573d5f803e3d5ffd5b5050505050505050565b6101856101c3565b6001600160a01b0381166101b7575f604051631e4fbdf760e01b81526004016101ae919061023e565b60405180910390fd5b6101c0816101ef565b50565b5f546001600160a01b03163314610110573360405163118cdaa760e01b81526004016101ae919061023e565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b0391909116815260200190565b6001600160a01b03811681146101c0575f80fd5b634e487b7160e01b5f52604160045260245ffd5b5f805f6060848603121561028c575f80fd5b833561029781610252565b925060208401356102a781610252565b9150604084013567ffffffffffffffff808211156102c3575f80fd5b818601915086601f8301126102d6575f80fd5b8135818111156102e8576102e8610266565b604051601f8201601f19908116603f0116810190838211818310171561031057610310610266565b81604052828152896020848701011115610328575f80fd5b826020860160208301375f6020848301015280955050505050509250925092565b5f81518084528060208401602086015e5f602082860101526020601f19601f83011685010191505092915050565b602081525f6103896020830184610349565b9392505050565b5f602082840312156103a0575f80fd5b813561038981610252565b6001600160a01b03831681526040602082018190525f906103ce90830184610349565b94935050505056fea2646970667358221220497e1225d21503b2c0e72feef0d5216fe1525afb4c43c9fa065eef75c65856e264736f6c63430008190033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103a2646970667358221220fedb0f518755c8d12fda617112f8e012e1f4e1586b176433ddae69569445594f64736f6c634300081900330000000000000000000000000000000000000000000000000de0b6b3a7640000
Deployed Bytecode
0x60806040526004361061047c575f3560e01c80638322fff21161024c578063ba0876521161013f578063d9f9027f116100be578063ef8b30f711610083578063ef8b30f714610c4d578063f2fde38b14610d69578063f4ad878814610d88578063f6c278c114610d9d578063fa559a3514610dc4578063ffa1ad7414610de3575f80fd5b8063d9f9027f14610cc9578063dd62ed3e14610cdd578063e00bfe5014610cfc578063e3ea7c6a14610d23578063ed14d17e14610d55575f80fd5b8063c69bebe411610104578063c69bebe414610c2e578063c6e6f59214610c4d578063ce96cb7714610c6c578063d48bfca714610c8b578063d905777e14610caa575f80fd5b8063ba08765214610b89578063ba8bfa2a14610ba8578063bf6590a414610bc7578063c0587a9514610bdb578063c63d75b614610c0e575f80fd5b8063a7b73254116101cb578063b046a44911610190578063b046a44914610b01578063b0caa89114610b20578063b2db983a14610b4b578063b3d7f6b914610b6a578063b460af9414610b89575f80fd5b8063a7b7325414610a5c578063a9059cbb14610a7b578063aa6ca80814610a9a578063ad35530b14610abb578063ad5c464814610ada575f80fd5b806395d89b411161021157806395d89b41146109ed57806398e1862c14610a015780639c016ffd14610a155780639c5861b614610a295780639e65741e14610a48575f80fd5b80638322fff21461095e5780638456cb591461098557806388bb4f60146109995780638da5cb5b146109ba57806394bf804d146109ce575f80fd5b806338d52e0f1161036f5780634cdad506116102ee5780636e553f65116102b35780636e553f65146108af57806370a08231146108ce578063715018a6146108ed5780637a825e07146109015780637f6c81b7146109205780638152cd181461093f575f80fd5b80634cdad5061461052357806355d17ee014610836578063596384ae1461085d5780635c975abb1461087c5780635fa7b58414610890575f80fd5b80633f4ba83a116103345780633f4ba83a14610770578063402d267d14610784578063439fab91146107a35780634a8c110a146107c25780634b59b82e14610817575f80fd5b806338d52e0f146106df5780633b0426db146107005780633bfaa7e3146107145780633c5280e41461073d5780633e9491a21461075c575f80fd5b806318160ddd116103fb57806329c23e4a116103c057806329c23e4a146106535780632de10fab14610672578063313ce5671461068757806332507a5f146106ad57806334069157146106c0575f80fd5b806318160ddd146105ce57806323b872dd146105e25780632489f7f71461060157806325bd414214610615578063266f8dc914610634575f80fd5b806307a2d13a1161044157806307a2d13a14610523578063095ea7b3146105425780630a28a47714610571578063107703ab14610590578063175188e8146105af575f80fd5b806301c704ba1461048757806301e1d114146104a8578063030d624a146104cf57806306fdde03146104ee578063079c3b881461050f575f80fd5b3661048357005b5f80fd5b348015610492575f80fd5b506104a66104a1366004614499565b610e11565b005b3480156104b3575f80fd5b506104bc610e82565b6040519081526020015b60405180910390f35b3480156104da575f80fd5b506104a66104e93660046144b2565b610ef9565b3480156104f9575f80fd5b50610502610f64565b6040516104c691906144f7565b34801561051a575f80fd5b506104bc611002565b34801561052e575f80fd5b506104bc61053d3660046144b2565b6110a8565b34801561054d575f80fd5b5061056161055c366004614509565b6110b9565b60405190151581526020016104c6565b34801561057c575f80fd5b506104bc61058b3660046144b2565b6110d0565b34801561059b575f80fd5b506104a66105aa366004614531565b6110dc565b3480156105ba575f80fd5b506104a66105c9366004614499565b6111d8565b3480156105d9575f80fd5b506104bc6112c1565b3480156105ed575f80fd5b506105616105fc36600461455b565b6112d7565b34801561060c575f80fd5b506104bc6112fc565b348015610620575f80fd5b506104a661062f3660046144b2565b611306565b34801561063f575f80fd5b506104a661064e3660046144b2565b611371565b34801561065e575f80fd5b506104bc61066d3660046144b2565b6113dd565b34801561067d575f80fd5b506104bc60175481565b348015610692575f80fd5b5061069b6113fa565b60405160ff90911681526020016104c6565b6104bc6106bb366004614594565b611423565b3480156106cb575f80fd5b506104a66106da3660046144b2565b61187e565b3480156106ea575f80fd5b506106f36118eb565b6040516104c691906145de565b34801561070b575f80fd5b506104bc611905565b34801561071f575f80fd5b50610728611938565b604080519283526020830191909152016104c6565b348015610748575f80fd5b506104a66107573660046144b2565b611bee565b348015610767575f80fd5b506012546104bc565b34801561077b575f80fd5b506104a6611c5b565b34801561078f575f80fd5b506104bc61079e366004614499565b611c6d565b3480156107ae575f80fd5b506104a66107bd366004614636565b611c83565b3480156107cd575f80fd5b506107d661213c565b6040516104c691905f60a082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015292915050565b348015610822575f80fd5b506106f36108313660046144b2565b61219e565b348015610841575f80fd5b506106f373a1290d69c65a6fe4df752f95823fae25cb99e5a781565b348015610868575f80fd5b506104a66108773660046144b2565b6121a9565b348015610887575f80fd5b50610561612203565b34801561089b575f80fd5b506104a66108aa366004614499565b612217565b3480156108ba575f80fd5b506104bc6108c9366004614531565b61225a565b3480156108d9575f80fd5b506104bc6108e8366004614499565b61232b565b3480156108f8575f80fd5b506104a6612354565b34801561090c575f80fd5b506104a661091b366004614499565b612365565b34801561092b575f80fd5b506104a661093a3660046144b2565b6123fd565b34801561094a575f80fd5b506104a6610959366004614674565b612468565b348015610969575f80fd5b506106f373eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee81565b348015610990575f80fd5b506104a6612516565b3480156109a4575f80fd5b506109ad612570565b6040516104c69190614694565b3480156109c5575f80fd5b506106f36127ba565b3480156109d9575f80fd5b506104bc6109e8366004614531565b6127e2565b3480156109f8575f80fd5b5061050261282c565b348015610a0c575f80fd5b506011546104bc565b348015610a20575f80fd5b506104a6612848565b348015610a34575f80fd5b506104a6610a433660046144b2565b612932565b348015610a53575f80fd5b506010546104bc565b348015610a67575f80fd5b506104bc610a7636600461479e565b6129ac565b348015610a86575f80fd5b50610561610a95366004614509565b612b9e565b348015610aa5575f80fd5b50610aae612bab565b6040516104c691906147f1565b348015610ac6575f80fd5b506104a6610ad536600461483d565b612bb7565b348015610ae5575f80fd5b506106f373c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b348015610b0c575f80fd5b506104a6610b1b366004614499565b612c8b565b348015610b2b575f80fd5b506104bc610b3a366004614499565b60026020525f908152604090205481565b348015610b56575f80fd5b506104bc610b653660046144b2565b612d26565b348015610b75575f80fd5b506104bc610b843660046144b2565b612d91565b348015610b94575f80fd5b506104bc610ba3366004614892565b612d9d565b348015610bb3575f80fd5b506104a6610bc23660046148cb565b612db7565b348015610bd2575f80fd5b506104bc6130db565b348015610be6575f80fd5b507f4995646f72fa9a270ffc094641ab616ce576b2e3eab25eaf05c15caa4f0e595d5c6104bc565b348015610c19575f80fd5b506104bc610c28366004614499565b505f1990565b348015610c39575f80fd5b506104a6610c48366004614499565b613190565b348015610c58575f80fd5b506104bc610c673660046144b2565b613228565b348015610c77575f80fd5b506104bc610c86366004614499565b613233565b348015610c96575f80fd5b506104a6610ca5366004614499565b613246565b348015610cb5575f80fd5b506104bc610cc4366004614499565b6132b0565b348015610cd4575f80fd5b50610aae6132ba565b348015610ce8575f80fd5b506104bc610cf73660046148fb565b6132c5565b348015610d07575f80fd5b506106f373ae7ab96520de3a18e5e111b5eaab095312d7fe8481565b348015610d2e575f80fd5b507f0000000000000000000000000000000000000000000000000de0b6b3a76400006104bc565b348015610d60575f80fd5b506104a66132ff565b348015610d74575f80fd5b506104a6610d83366004614499565b613382565b348015610d93575f80fd5b506104bc61271081565b348015610da8575f80fd5b506106f373a35b1b31ce002fbf2058d22f30f95d405200a15b81565b348015610dcf575f80fd5b506018546106f3906001600160a01b031681565b348015610dee575f80fd5b50610502604051806040016040528060038152602001620322e360ec1b81525081565b610e196133bc565b6018546040517f65c8da338cfcbb5abedd2f9099bb2a2bdf31ffc65d130e715901eeb06b205cdf91610e58916001600160a01b03909116908490614923565b60405180910390a1601880546001600160a01b0319166001600160a01b0392909216919091179055565b6009546014545f9190610e959042614951565b1115610eb457604051631f4bcb2b60e01b815260040160405180910390fd5b7f0000000000000000000000000000000000000000000000000de0b6b3a7640000610edd6112c1565b601054610eea9190614964565b610ef4919061498f565b905090565b610f016133bc565b6004811115610f23576040516309aa66eb60e01b815260040160405180910390fd5b60075460408051918252602082018390527f29b9d7a7d8a7a3ac22c295e4517723bc4e386eea60173e59e6da1dbd460cb409910160405180910390a1600755565b60605f610f6f6133ee565b9050806003018054610f80906149a2565b80601f0160208091040260200160405190810160405280929190818152602001828054610fac906149a2565b8015610ff75780601f10610fce57610100808354040283529160200191610ff7565b820191905f5260205f20905b815481529060010190602001808311610fda57829003601f168201915b505050505091505090565b6040516370a0823160e01b81525f90819073a1290d69c65a6fe4df752f95823fae25cb99e5a7906370a082319061103d9030906004016145de565b602060405180830381865afa158015611058573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061107c91906149da565b90505f6110876130db565b60125490915061109783836149f1565b6110a19190614951565b9250505090565b5f6110b3825f613412565b92915050565b5f336110c681858561344f565b5060019392505050565b5f6110b3826001613461565b6110e4613495565b6110ec6134df565b815f0361110c57604051637ea773a960e01b815260040160405180910390fd5b600f546111249033906001600160a01b031684613505565b600f546040516336c69b5d60e11b81526001600160a01b0390911690636d8d36ba906111569033908690600401614a04565b5f604051808303815f87803b15801561116d575f80fd5b505af115801561117f573d5f803e3d5ffd5b505060408051338152602081018690526001600160a01b0385168183015290517ff9fd31dd1a61b95c600dd5aa1a6330f6c5cbe70a39a660edc081daf217db3cfb9350908190036060019150a16111d4613562565b5050565b6111e06133bc565b5f816001600160a01b03166308bb5fb06040518163ffffffff1660e01b81526004016020604051808303815f875af115801561121e573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061124291906149da565b11156112615760405163e9ec812960e01b815260040160405180910390fd5b61126b5f82613588565b506001600160a01b0381165f9081526002602052604080822091909155517fd3281a40d50ae838fe77dc627744037b8f0fc6a5711d66119a9b670c5cde41af906112b69083906145de565b60405180910390a150565b5f6017546112cd61359c565b610ef49190614951565b5f336112e48582856135b0565b6112ef858585613505565b60019150505b9392505050565b5f610ef45f613600565b61130e6133bc565b60788111156113305760405163f4d1caab60e01b815260040160405180910390fd5b600b5460408051918252602082018390527f394967f6fe403cda0905b23e81b928c5ca79107000b1404c6b3185442f05213c910160405180910390a1600b55565b6113796133bc565b6105dc81111561139c57604051630674143f60e01b815260040160405180910390fd5b600a5460408051918252602082018390527f63058ed61801434ac6bfe39e74400bed7f3ba09b7cb6294092974450727eb753910160405180910390a1600a55565b600b545f90612710906113f09084614964565b6110b3919061498f565b5f80611404613609565b90505f815461141d9190600160a01b900460ff16614a1d565b91505090565b5f61142c613495565b6114346134df565b6001600160a01b03851673a35b1b31ce002fbf2058d22f30f95d405200a15b148061147b57506001600160a01b03851673ae7ab96520de3a18e5e111b5eaab095312d7fe84145b15611654576114956001600160a01b03861633308761362d565b6114bd6001600160a01b03861673036676389e48133b63a802f8635ad39e752d375d86613694565b6040516370a0823160e01b81525f9073a1290d69c65a6fe4df752f95823fae25cb99e5a7906370a08231906114f69030906004016145de565b602060405180830381865afa158015611511573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061153591906149da565b6040516361d70bb360e11b81526001600160a01b0388166004820152602481018790525f6044820181905260806064830152608482015290915073036676389e48133b63a802f8635ad39e752d375d9063c3ae17669060a4015f604051808303815f87803b1580156115a5575f80fd5b505af11580156115b7573d5f803e3d5ffd5b50506040516370a0823160e01b81525f925083915073a1290d69c65a6fe4df752f95823fae25cb99e5a7906370a08231906115f69030906004016145de565b602060405180830381865afa158015611611573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061163591906149da565b61163f9190614951565b905061164b8186613719565b9250505061180c565b73a1290d69c65a6fe4df752f95823fae25cb99e5a6196001600160a01b0386160161169f576116838484613719565b905061169a6001600160a01b03861633308761362d565b61180c565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeed196001600160a01b038616016117f3576040516370a0823160e01b81525f9073a1290d69c65a6fe4df752f95823fae25cb99e5a7906370a08231906116fd9030906004016145de565b602060405180830381865afa158015611718573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061173c91906149da565b6040516372c51c0b60e01b815290915073036676389e48133b63a802f8635ad39e752d375d906372c51c0b90349061178a905f906004019081526040602082018190525f9082015260600190565b5f604051808303818588803b1580156117a1575f80fd5b505af11580156117b3573d5f803e3d5ffd5b50506040516370a0823160e01b81525f935084925073a1290d69c65a6fe4df752f95823fae25cb99e5a791506370a08231906115f69030906004016145de565b60405163350b944160e11b815260040160405180910390fd5b61181683826137a6565b604080513381526001600160a01b03878116602083015281830187905285811660608301528416608082015290517f308d36d8f61bd4393536b6557142f55554c34d4ea2a3dbf54fe782b98889dfb29181900360a00190a1611876613562565b949350505050565b6118866133bc565b6203f4808111156118aa5760405163e88d3ecb60e01b815260040160405180910390fd5b60095460408051918252602082018390527fcc5a4a7c466fc20af4119a7a26048791fdb55cbd401aff36ef2bfc639662b2e2910160405180910390a1600955565b5f806118f5613609565b546001600160a01b031692915050565b6014545f9081906119169042614951565b9050806003600601541161192a575f61141d565b60095461141d908290614951565b600d545f9081906001600160a01b031633146119675760405163bd72e29160e01b815260040160405180910390fd5b601054611995907f4995646f72fa9a270ffc094641ab616ce576b2e3eab25eaf05c15caa4f0e595d906137da565b426014555f6119a26112c1565b9050805f036119ba5750506010546012549091509091565b5f6119c3611002565b9050816119f07f0000000000000000000000000000000000000000000000000de0b6b3a764000083614964565b6119fa919061498f565b601154909450841115611b3c576011545f03611a2457505050601181905560108190556012549091565b5f7f0000000000000000000000000000000000000000000000000de0b6b3a764000083601060010154611a579190614964565b611a61919061498f565b611a6b9083614951565b600a5490915061271090611a7f9083614964565b611a89919061498f565b93508360106002015f828254611a9f91906149f1565b9091555050601054837f0000000000000000000000000000000000000000000000000de0b6b3a7640000611ad38786614951565b611add9190614964565b611ae7919061498f565b601055612710611af8606483614964565b611b02919061498f565b601054611b10908390614951565b1115611b2f57604051630508c93960e41b815260040160405180910390fd5b5050601054601155611baf565b5f8460105f015411611b5a57601054611b559086614951565b611b68565b601054611b68908690614951565b9050612710606460105f0154611b7e9190614964565b611b88919061498f565b811115611ba857604051630508c93960e41b815260040160405180910390fd5b5060108490555b60408051858152602081018590527f83d2ad38a3d31bbc70811535dd8943b0140df344c23e6e167ee1ca32f9a1a459910160405180910390a150509091565b611bf66133bc565b62093a80811015611c1a57604051632011727b60e11b815260040160405180910390fd5b60085460408051918252602082018390527fcdbf56e2a82365307f9691ad933e9762726485d202543fe224f47447d79feaf0910160405180910390a1600855565b611c636133bc565b611c6b6137e1565b565b5f611c76610e82565b6006546110b39190614951565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff1615906001600160401b03165f81158015611cc75750825b90505f826001600160401b03166001148015611ce25750303b155b905081158015611cf0575080155b15611d0e5760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff191660011785558315611d3857845460ff60401b1916600160401b1785555b5f80611d46888a018a614b91565b91509150611d5261382c565b611d5a61383c565b611d6c8260200151836040015161384c565b81516001600160a01b0316611d94576040516317dc37cb60e11b815260040160405180910390fd5b6101408201516001600160a01b0316611dc3576040516001626bbab960e11b0319815260040160405180910390fd5b6101208201516001600160a01b0316611def57604051630b5eba9f60e41b815260040160405180910390fd5b6101608201516001600160a01b0316611e1b57604051633480121760e21b815260040160405180910390fd5b7f0000000000000000000000000000000000000000000000000de0b6b3a764000082606001511015611e6057604051633240d18160e21b815260040160405180910390fd5b600482608001511115611e86576040516309aa66eb60e01b815260040160405180910390fd5b62093a808260a001511015611eae57604051632011727b60e11b815260040160405180910390fd5b6203f4808260c001511115611ed65760405163e88d3ecb60e01b815260040160405180910390fd5b6105dc8260e001511115611efd57604051630674143f60e01b815260040160405180910390fd5b60788261010001511115611f245760405163f4d1caab60e01b815260040160405180910390fd5b611f3282610120015161385e565b8151611f3d9061386f565b4260138190556014557f0000000000000000000000000000000000000000000000000de0b6b3a76400006010558151600380546001600160a01b0319166001600160a01b039092169190911781556020830151839190600490611fa09082614d1b565b5060408201516002820190611fb59082614d1b565b50606082015160038201556080820151600482015560a0820151600582015560c0820151600682015560e0820151600782015561010082015160088201556101208201516009820180546001600160a01b03199081166001600160a01b0393841617909155610140840151600a840180548316918416919091179055610160840151600b84018054831691841691909117905561018090930151600c909201805490931691161790555f5b81518110156120ea575f6001600160a01b031682828151811061208557612085614dda565b60200260200101516001600160a01b0316036120b4576040516317dc37cb60e11b815260040160405180910390fd5b6120e18282815181106120c9576120c9614dda565b6020026020010151601561388090919063ffffffff16565b50600101612060565b505050831561213357845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50505050505050565b6121696040518060a001604052805f81526020015f81526020015f81526020015f81526020015f81525090565b506040805160a08101825260105481526011546020820152601254918101919091526013546060820152601454608082015290565b5f6110b38183613894565b6018546001600160a01b031633146121d457604051632f771b3d60e11b815260040160405180910390fd5b8060175f8282546121e591906149f1565b9091555050601854612200906001600160a01b0316826137a6565b50565b5f8061220d61389f565b5460ff1692915050565b61221f6133bc565b61222a601582613588565b507f4eb129c82dcd3eedb52df2b0e6fb4cfa41ac64ee9d63ff081acbb1877e85d79b816040516112b691906145de565b5f612263613495565b61226b6134df565b6014546122789042614951565b600954101561229a57604051631f4bcb2b60e01b815260040160405180910390fd5b5f198303612317576122aa6118eb565b6001600160a01b03166370a08231336040518263ffffffff1660e01b81526004016122d591906145de565b602060405180830381865afa1580156122f0573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061231491906149da565b92505b61232183836138c3565b90506110b3613562565b5f806123356133ee565b6001600160a01b039093165f9081526020939093525050604090205490565b61235c6133bc565b611c6b5f61390f565b61236d6133bc565b6001600160a01b0381166123945760405163d214a59760e01b815260040160405180910390fd5b600f546040517fe74dd8b1f5f3d5328df682e649c08b085f09c2ce77b68e54329e8d30e2642f78916123d3916001600160a01b03909116908490614923565b60405180910390a1600f80546001600160a01b0319166001600160a01b0392909216919091179055565b6124056133bc565b60065481116124275760405163e9ec812960e01b815260040160405180910390fd5b60065460408051918252602082018390527f7f3306669f28a6aa13d0f709be2bd4f3e21d2f37aee9358846a50e1988ee4832910160405180910390a1600655565b6124706133bc565b80158061247e575061271081115b1561249c5760405163e55fb50960e01b815260040160405180910390fd5b5f6124a78184613894565b6001600160a01b0381165f908152600260209081526040918290205482519081529081018590529192507f7cd01dd3533c6dc08821cd303814de60aba1901f1531c3cbcd95d26ed924e9cf910160405180910390a16001600160a01b03165f9081526002602052604090205550565b61251e6127ba565b6001600160a01b0316336001600160a01b03161415801561254a5750600d546001600160a01b03163314155b156125685760405163e9ec812960e01b815260040160405180910390fd5b611c6b61397f565b6125fd604051806101a001604052805f6001600160a01b0316815260200160608152602001606081526020015f81526020015f81526020015f81526020015f81526020015f81526020015f81526020015f6001600160a01b031681526020015f6001600160a01b031681526020015f6001600160a01b031681526020015f6001600160a01b031681525090565b604080516101a08101909152600380546001600160a01b031682526004805460208401919061262b906149a2565b80601f0160208091040260200160405190810160405280929190818152602001828054612657906149a2565b80156126a25780601f10612679576101008083540402835291602001916126a2565b820191905f5260205f20905b81548152906001019060200180831161268557829003601f168201915b505050505081526020016002820180546126bb906149a2565b80601f01602080910402602001604051908101604052809291908181526020018280546126e7906149a2565b80156127325780601f1061270957610100808354040283529160200191612732565b820191905f5260205f20905b81548152906001019060200180831161271557829003601f168201915b505050918352505060038201546020820152600482015460408201526005820154606082015260068201546080820152600782015460a0820152600882015460c082015260098201546001600160a01b0390811660e0830152600a8301548116610100830152600b8301548116610120830152600c9092015490911661014090910152919050565b5f807f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c1993006118f5565b5f6127eb613495565b6127f36134df565b6014546128009042614951565b600954101561282257604051631f4bcb2b60e01b815260040160405180910390fd5b61232183836139c5565b60605f6128376133ee565b9050806004018054610f80906149a2565b600e546001600160a01b0316331461287357604051633480121760e21b815260040160405180910390fd5b6008546013544291906128869083614951565b10156128a557604051631221b97b60e01b815260040160405180910390fd5b60138190556007545f90612710906128bb610e82565b6128c59190614964565b6128cf919061498f565b600e549091506128fb906001600160a01b0316826128eb6118eb565b6001600160a01b031691906139e0565b6040518181527f55ce6141cc7099e5baac44c64543a6d7fc4e37ebba0fcaa65fa1f2a9996ec5a59060200160405180910390a15050565b6018546001600160a01b0316331461295d57604051632f771b3d60e11b815260040160405180910390fd5b60175481111561298057604051636edcc52360e01b815260040160405180910390fd5b8060175f8282546129919190614951565b9091555050601854612200906001600160a01b031682613a06565b5f6129b5613495565b6129bd6134df565b6129c8601587613a3a565b6129e557604051636448d6e960e11b815260040160405180910390fd5b600f546001600160a01b03163314612a105760405163e9ec812960e01b815260040160405180910390fd5b6014544214612a3257604051631f4bcb2b60e01b815260040160405180910390fd5b5f198503612a4a57612a43826132b0565b9450612aa7565b612a53826132b0565b851115612aa75760405162461bcd60e51b815260206004820152601d60248201527f455243343632363a2072656465656d206d6f7265207468616e206d617800000060448201526064015b60405180910390fd5b336001600160a01b03831614612ac257612ac28233876135b0565b5f612b057f0000000000000000000000000000000000000000000000000de0b6b3a7640000612af18782614951565b612afb9089614964565b61053d919061498f565b9050612b118387613a06565b612b1a816113dd565b612b249082614951565b9150612b3a6001600160a01b03881685846139e0565b604080516001600160a01b03898116825260208201899052868116828401528516606082015290517f4e19afb1df46d77083cc4e520735afa0cdc2d763d6bc5d710661c3dbb35f4c4d9181900360800190a150612b95613562565b95945050505050565b5f336110c6818585613505565b6060610ef46015613a5b565b612bbf6133bc565b801580612bcd575061271081115b15612beb5760405163e55fb50960e01b815260040160405180910390fd5b5f84338585604051612bfc90614471565b612c099493929190614dee565b604051809103905ff080158015612c22573d5f803e3d5ffd5b506001600160a01b0381165f908152600260205260408120849055909150612c4a9082613880565b507f0803371633b57311f58d10924711080d2dae75ab17c5c0c262af3887cfca00bb8186604051612c7c929190614923565b60405180910390a15050505050565b612c936133bc565b6001600160a01b038116612cbd576040516001626bbab960e11b0319815260040160405180910390fd5b600d546040517fe2eeab472f89ac267be30e463da684fb96f56cc8e947839361fdf45bf6a3458e91612cfc916001600160a01b03909116908490614923565b60405180910390a1600d80546001600160a01b0319166001600160a01b0392909216919091179055565b5f612d318183613894565b6001600160a01b03166308bb5fb06040518163ffffffff1660e01b81526004016020604051808303815f875af1158015612d6d573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906110b391906149da565b5f6110b3826001613412565b5f604051637dc4dd1560e11b815260040160405180910390fd5b335f829003612e1a57612dc86127ba565b6001600160a01b0316816001600160a01b031614158015612df75750600d546001600160a01b03828116911614155b15612e155760405163ccea9e6f60e01b815260040160405180910390fd5b612e53565b612e226127ba565b6001600160a01b0316816001600160a01b031614612e535760405163ccea9e6f60e01b815260040160405180910390fd5b5f612e5d8361219e565b6001600160a01b0381165f818152600260209081526040808320548151628bb5fb60e41b81529151959650949293926308bb5fb092600480840193919291829003018187875af1158015612eb3573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612ed791906149da565b90505f612ee26113fa565b90505f886001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612f21573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612f459190614e38565b90508760ff8084169083161115612f7c57612f608383614e58565b612f6b90600a614f51565b612f75908a61498f565b9050612fac565b8260ff168260ff161015612fac57612f948284614e58565b612f9f90600a614f51565b612fa9908a614964565b90505b61271085612fb8610e82565b612fc29190614964565b612fcc919061498f565b612fd682866149f1565b1115612ff55760405163e55fb50960e01b815260040160405180910390fd5b6130096001600160a01b038b16878b613694565b6040516356f4edaf60e01b81526001600160a01b038716906356f4edaf90613037908d908d90600401614a04565b6020604051808303815f875af1158015613053573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906130779190614f5f565b61309457604051630508c93960e41b815260040160405180910390fd5b7f921f9e77ef648025190d46d8b7f3d22a5546367ff7aaa883b1f39ffd2a2d325d8a8a8a6040516130c793929190614f7e565b60405180910390a150505050505050505050565b5f806130e56112fc565b90505f6130f06132ba565b90505f5b8281101561318a5781818151811061310e5761310e614dda565b60200260200101516001600160a01b03166308bb5fb06040518163ffffffff1660e01b81526004016020604051808303815f875af1158015613152573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061317691906149da565b61318090856149f1565b93506001016130f4565b50505090565b6131986133bc565b6001600160a01b0381166131bf57604051633480121760e21b815260040160405180910390fd5b600e546040517f2861448678f0be67f11bfb5481b3e3b4cfeb3acc6126ad60a05f95bfc6530666916131fe916001600160a01b03909116908490614923565b60405180910390a1600e80546001600160a01b0319166001600160a01b0392909216919091179055565b5f6110b3825f613461565b5f6110b36132408361232b565b5f613412565b61324e6133bc565b6001600160a01b038116613275576040516317dc37cb60e11b815260040160405180910390fd5b613280601582613880565b507fe473c74f34be27c1464d6624f14a0d7fd4e301cbfa29c3eba425d378c8a7ebe0816040516112b691906145de565b5f6110b38261232b565b6060610ef45f613a5b565b5f806132cf6133ee565b6001600160a01b039485165f90815260019190910160209081526040808320959096168252939093525050205490565b600e546001600160a01b0316331461332a57604051633480121760e21b815260040160405180910390fd5b600e54601254613346916001600160a01b0316906128eb6118eb565b6012546040519081527f8a2034f45f83800eed1750a670ad845ceee6add62106ca5326598842cfbd6ea79060200160405180910390a15f601255565b61338a6133bc565b6001600160a01b0381166133b3575f604051631e4fbdf760e01b8152600401612a9e91906145de565b6122008161390f565b336133c56127ba565b6001600160a01b031614611c6b573360405163118cdaa760e01b8152600401612a9e91906145de565b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0090565b5f6112f561341e610e82565b6134299060016149f1565b6134345f600a614f51565b61343c6112c1565b61344691906149f1565b85919085613a67565b61345c8383836001613ab4565b505050565b5f6112f561347082600a614f51565b6134786112c1565b61348291906149f1565b61348a610e82565b6134469060016149f1565b7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f008054600119016134d957604051633ee5aeb560e01b815260040160405180910390fd5b60029055565b6134e7612203565b15611c6b5760405163d93c066560e01b815260040160405180910390fd5b6001600160a01b03831661352e575f604051634b637e8f60e11b8152600401612a9e91906145de565b6001600160a01b038216613557575f60405163ec442f0560e01b8152600401612a9e91906145de565b61345c838383613b95565b60017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b5f6112f5836001600160a01b038416613cb8565b5f806135a66133ee565b6002015492915050565b5f6135bb84846132c5565b90505f1981146135fa57818110156135ec57828183604051637dc7a0d960e11b8152600401612a9e93929190614f7e565b6135fa84848484035f613ab4565b50505050565b5f6110b3825490565b7f0773e532dfede91f04b12a73d3d2acd361424f41f76b4fb79f090161e36b4e0090565b6040516001600160a01b0384811660248301528381166044830152606482018390526135fa9186918216906323b872dd906084015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050613d9b565b604051636eb1769f60e11b81525f906001600160a01b0385169063dd62ed3e906136c49030908790600401614923565b602060405180830381865afa1580156136df573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061370391906149da565b90506135fa848461371485856149f1565b613df3565b5f8061372483611c6d565b90508084111561374d57828482604051633c8097d960e11b8152600401612a9e93929190614f7e565b61375684613228565b60408051868152602081018390529193506001600160a01b0385169133917fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d7910160405180910390a35092915050565b6001600160a01b0382166137cf575f60405163ec442f0560e01b8152600401612a9e91906145de565b6111d45f8383613b95565b80825d5050565b6137e9613e83565b5f6137f261389f565b805460ff1916815590507f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516112b691906145de565b613834613ea8565b611c6b613ef1565b613844613ea8565b611c6b613f0d565b613854613ea8565b6111d48282613f15565b613866613ea8565b61220081613f45565b613877613ea8565b61220081613f4d565b5f6112f5836001600160a01b038416613fba565b5f6112f58383614006565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f0330090565b5f806138ce83611c6d565b9050808411156138f757828482604051633c8097d960e11b8152600401612a9e93929190614f7e565b5f61390185613228565b90506118763385878461402c565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080546001600160a01b031981166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a3505050565b6139876134df565b5f61399061389f565b805460ff1916600117815590507f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861381f3390565b5f5f195f6139d285612d91565b90506118763385838861402c565b61345c83846001600160a01b031663a9059cbb8585604051602401613662929190614a04565b6001600160a01b038216613a2f575f604051634b637e8f60e11b8152600401612a9e91906145de565b6111d4825f83613b95565b6001600160a01b0381165f90815260018301602052604081205415156112f5565b60605f6112f5836140a7565b5f80613a74868686614100565b9050613a7f836141bf565b8015613a9a57505f8480613a9557613a9561497b565b868809115b15612b9557613aaa6001826149f1565b9695505050505050565b5f613abd6133ee565b90506001600160a01b038516613ae8575f60405163e602df0560e01b8152600401612a9e91906145de565b6001600160a01b038416613b11575f604051634a1406b160e11b8152600401612a9e91906145de565b6001600160a01b038086165f90815260018301602090815260408083209388168352929052208390558115613b8e57836001600160a01b0316856001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92585604051613b8591815260200190565b60405180910390a35b5050505050565b5f613b9e6133ee565b90506001600160a01b038416613bcc5781816002015f828254613bc191906149f1565b90915550613c299050565b6001600160a01b0384165f9081526020829052604090205482811015613c0b5784818460405163391434e360e21b8152600401612a9e93929190614f7e565b6001600160a01b0385165f9081526020839052604090209083900390555b6001600160a01b038316613c47576002810180548390039055613c65565b6001600160a01b0383165f9081526020829052604090208054830190555b826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051613caa91815260200190565b60405180910390a350505050565b5f8181526001830160205260408120548015613d92575f613cda600183614951565b85549091505f90613ced90600190614951565b9050808214613d4c575f865f018281548110613d0b57613d0b614dda565b905f5260205f200154905080875f018481548110613d2b57613d2b614dda565b5f918252602080832090910192909255918252600188019052604090208390555b8554869080613d5d57613d5d614f9f565b600190038181905f5260205f20015f90559055856001015f8681526020019081526020015f205f9055600193505050506110b3565b5f9150506110b3565b5f613daf6001600160a01b038416836141eb565b905080515f14158015613dd3575080806020019051810190613dd19190614f5f565b155b1561345c5782604051635274afe760e01b8152600401612a9e91906145de565b5f836001600160a01b031663095ea7b38484604051602401613e16929190614a04565b604051602081830303815290604052915060e01b6020820180516001600160e01b0383818316178352505050509050613e4f84826141f8565b6135fa57613e7984856001600160a01b031663095ea7b3865f604051602401613662929190614a04565b6135fa8482613d9b565b613e8b612203565b611c6b57604051638dfc202b60e01b815260040160405180910390fd5b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff16611c6b57604051631afcd79f60e31b815260040160405180910390fd5b613ef9613ea8565b5f613f0261389f565b805460ff1916905550565b613562613ea8565b613f1d613ea8565b5f613f266133ee565b905060038101613f368482614d1b565b50600481016135fa8382614d1b565b61338a613ea8565b613f55613ea8565b5f613f5e613609565b90505f80613f6b84614295565b9150915081613f7b576012613f7d565b805b83546001600160a81b031916600160a01b60ff92909216919091026001600160a01b031916176001600160a01b0394909416939093179091555050565b5f818152600183016020526040812054613fff57508154600181810184555f8481526020808220909301849055845484825282860190935260409020919091556110b3565b505f6110b3565b5f825f01828154811061401b5761401b614dda565b905f5260205f200154905092915050565b5f614035613609565b805490915061404f906001600160a01b031686308661362d565b61405984836137a6565b836001600160a01b0316856001600160a01b03167fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d78585604051613b85929190918252602082015260400190565b6060815f018054806020026020016040519081016040528092919081815260200182805480156140f457602002820191905f5260205f20905b8154815260200190600101908083116140e0575b50505050509050919050565b5f838302815f1985870982811083820303915050805f036141345783828161412a5761412a61497b565b04925050506112f5565b8084116141545760405163227bc15360e01b815260040160405180910390fd5b5f848688095f868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b5f60028260038111156141d4576141d4614fb3565b6141de9190614fc7565b60ff166001149050919050565b60606112f583835f61436b565b5f805f846001600160a01b0316846040516142139190614fe8565b5f604051808303815f865af19150503d805f811461424c576040519150601f19603f3d011682016040523d82523d5f602084013e614251565b606091505b509150915081801561427b57508051158061427b57508080602001905181019061427b9190614f5f565b8015612b955750505050506001600160a01b03163b151590565b60408051600481526024810182526020810180516001600160e01b031663313ce56760e01b17905290515f918291829182916001600160a01b038716916142db91614fe8565b5f60405180830381855afa9150503d805f8114614313576040519150601f19603f3d011682016040523d82523d5f602084013e614318565b606091505b509150915081801561432c57506020815110155b1561435f575f8180602001905181019061434691906149da565b905060ff811161435d576001969095509350505050565b505b505f9485945092505050565b606081471015614390573060405163cd78605960e01b8152600401612a9e91906145de565b5f80856001600160a01b031684866040516143ab9190614fe8565b5f6040518083038185875af1925050503d805f81146143e5576040519150601f19603f3d011682016040523d82523d5f602084013e6143ea565b606091505b5091509150613aaa86838360608261440a5761440582614448565b6112f5565b815115801561442157506001600160a01b0384163b155b156144415783604051639996b31560e01b8152600401612a9e91906145de565b50806112f5565b8051156144585780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b610dd680614fff83390190565b80356001600160a01b0381168114614494575f80fd5b919050565b5f602082840312156144a9575f80fd5b6112f58261447e565b5f602082840312156144c2575f80fd5b5035919050565b5f81518084528060208401602086015e5f602082860101526020601f19601f83011685010191505092915050565b602081525f6112f560208301846144c9565b5f806040838503121561451a575f80fd5b6145238361447e565b946020939093013593505050565b5f8060408385031215614542575f80fd5b823591506145526020840161447e565b90509250929050565b5f805f6060848603121561456d575f80fd5b6145768461447e565b92506145846020850161447e565b9150604084013590509250925092565b5f805f80608085870312156145a7575f80fd5b6145b08561447e565b9350602085013592506145c56040860161447e565b91506145d36060860161447e565b905092959194509250565b6001600160a01b0391909116815260200190565b5f8083601f840112614602575f80fd5b5081356001600160401b03811115614618575f80fd5b60208301915083602082850101111561462f575f80fd5b9250929050565b5f8060208385031215614647575f80fd5b82356001600160401b0381111561465c575f80fd5b614668858286016145f2565b90969095509350505050565b5f8060408385031215614685575f80fd5b50508035926020909101359150565b602081526146ae6020820183516001600160a01b03169052565b5f60208301516101a08060408501526146cb6101c08501836144c9565b91506040850151601f198584030160608601526146e883826144c9565b92505060608501516080850152608085015160a085015260a085015160c085015260c085015160e085015260e085015161010081818701528087015191505061012081818701528087015191505061014061474d818701836001600160a01b03169052565b8601519050610160614769868201836001600160a01b03169052565b8601519050610180614785868201836001600160a01b03169052565b909501516001600160a01b031693019290925250919050565b5f805f805f60a086880312156147b2575f80fd5b6147bb8661447e565b945060208601359350604086013592506147d76060870161447e565b91506147e56080870161447e565b90509295509295909350565b602080825282518282018190525f9190848201906040850190845b818110156148315783516001600160a01b03168352928401929184019160010161480c565b50909695505050505050565b5f805f8060608587031215614850575f80fd5b6148598561447e565b935060208501356001600160401b03811115614873575f80fd5b61487f878288016145f2565b9598909750949560400135949350505050565b5f805f606084860312156148a4575f80fd5b833592506148b46020850161447e565b91506148c26040850161447e565b90509250925092565b5f805f606084860312156148dd575f80fd5b6148e68461447e565b95602085013595506040909401359392505050565b5f806040838503121561490c575f80fd5b6149158361447e565b91506145526020840161447e565b6001600160a01b0392831681529116602082015260400190565b634e487b7160e01b5f52601160045260245ffd5b818103818111156110b3576110b361493d565b80820281158282048414176110b3576110b361493d565b634e487b7160e01b5f52601260045260245ffd5b5f8261499d5761499d61497b565b500490565b600181811c908216806149b657607f821691505b6020821081036149d457634e487b7160e01b5f52602260045260245ffd5b50919050565b5f602082840312156149ea575f80fd5b5051919050565b808201808211156110b3576110b361493d565b6001600160a01b03929092168252602082015260400190565b60ff81811683821601908111156110b3576110b361493d565b634e487b7160e01b5f52604160045260245ffd5b6040516101a081016001600160401b0381118282101715614a6d57614a6d614a36565b60405290565b604051601f8201601f191681016001600160401b0381118282101715614a9b57614a9b614a36565b604052919050565b5f82601f830112614ab2575f80fd5b81356001600160401b03811115614acb57614acb614a36565b614ade601f8201601f1916602001614a73565b818152846020838601011115614af2575f80fd5b816020850160208301375f918101602001919091529392505050565b5f82601f830112614b1d575f80fd5b813560206001600160401b03821115614b3857614b38614a36565b8160051b614b47828201614a73565b9283528481018201928281019087851115614b60575f80fd5b83870192505b84831015614b8657614b778361447e565b82529183019190830190614b66565b979650505050505050565b5f8060408385031215614ba2575f80fd5b82356001600160401b0380821115614bb8575f80fd5b908401906101a08287031215614bcc575f80fd5b614bd4614a4a565b614bdd8361447e565b8152602083013582811115614bf0575f80fd5b614bfc88828601614aa3565b602083015250604083013582811115614c13575f80fd5b614c1f88828601614aa3565b604083015250606083013560608201526080830135608082015260a083013560a082015260c083013560c082015260e083013560e0820152610100808401358183015250610120614c7181850161447e565b90820152610140614c8384820161447e565b90820152610160614c9584820161447e565b90820152610180614ca784820161447e565b9082015293506020850135915080821115614cc0575f80fd5b50614ccd85828601614b0e565b9150509250929050565b601f82111561345c57805f5260205f20601f840160051c81016020851015614cfc5750805b601f840160051c820191505b81811015613b8e575f8155600101614d08565b81516001600160401b03811115614d3457614d34614a36565b614d4881614d4284546149a2565b84614cd7565b602080601f831160018114614d7b575f8415614d645750858301515b5f19600386901b1c1916600185901b178555614dd2565b5f85815260208120601f198616915b82811015614da957888601518255948401946001909101908401614d8a565b5085821015614dc657878501515f19600388901b60f8161c191681555b505060018460011b0185555b505050505050565b634e487b7160e01b5f52603260045260245ffd5b6001600160a01b0385811682528416602082015260606040820181905281018290525f828460808401375f608084840101526080601f19601f850116830101905095945050505050565b5f60208284031215614e48575f80fd5b815160ff811681146112f5575f80fd5b60ff82811682821603908111156110b3576110b361493d565b600181815b80851115614eab57815f1904821115614e9157614e9161493d565b80851615614e9e57918102915b93841c9390800290614e76565b509250929050565b5f82614ec1575060016110b3565b81614ecd57505f6110b3565b8160018114614ee35760028114614eed57614f09565b60019150506110b3565b60ff841115614efe57614efe61493d565b50506001821b6110b3565b5060208310610133831016604e8410600b8410161715614f2c575081810a6110b3565b614f368383614e71565b805f1904821115614f4957614f4961493d565b029392505050565b5f6112f560ff841683614eb3565b5f60208284031215614f6f575f80fd5b815180151581146112f5575f80fd5b6001600160a01b039390931683526020830191909152604082015260600190565b634e487b7160e01b5f52603160045260245ffd5b634e487b7160e01b5f52602160045260245ffd5b5f60ff831680614fd957614fd961497b565b8060ff84160691505092915050565b5f82518060208501845e5f92019182525091905056fe60a0604052604051610dd6380380610dd68339810160408190526100229161036a565b828161002e828261008c565b50508160405161003d9061032e565b6001600160a01b039091168152602001604051809103905ff080158015610066573d5f803e3d5ffd5b506001600160a01b031660805261008461007f60805190565b6100ea565b50505061044b565b61009582610157565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a28051156100de576100d982826101d5565b505050565b6100e6610248565b5050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6101295f80516020610db6833981519152546001600160a01b031690565b604080516001600160a01b03928316815291841660208301520160405180910390a161015481610269565b50565b806001600160a01b03163b5f0361019157604051634c9c8ce360e01b81526001600160a01b03821660048201526024015b60405180910390fd5b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5b80546001600160a01b0319166001600160a01b039290921691909117905550565b60605f80846001600160a01b0316846040516101f19190610435565b5f60405180830381855af49150503d805f8114610229576040519150601f19603f3d011682016040523d82523d5f602084013e61022e565b606091505b50909250905061023f8583836102a6565b95945050505050565b34156102675760405163b398979f60e01b815260040160405180910390fd5b565b6001600160a01b03811661029257604051633173bdd160e11b81525f6004820152602401610188565b805f80516020610db68339815191526101b4565b6060826102bb576102b682610305565b6102fe565b81511580156102d257506001600160a01b0384163b155b156102fb57604051639996b31560e01b81526001600160a01b0385166004820152602401610188565b50805b9392505050565b8051156103155780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b610501806108b583390190565b80516001600160a01b0381168114610351575f80fd5b919050565b634e487b7160e01b5f52604160045260245ffd5b5f805f6060848603121561037c575f80fd5b6103858461033b565b92506103936020850161033b565b60408501519092506001600160401b03808211156103af575f80fd5b818601915086601f8301126103c2575f80fd5b8151818111156103d4576103d4610356565b604051601f8201601f19908116603f011681019083821181831017156103fc576103fc610356565b81604052828152896020848701011115610414575f80fd5b8260208601602083015e5f6020848301015280955050505050509250925092565b5f82518060208501845e5f920191825250919050565b6080516104536104625f395f601001526104535ff3fe608060405261000c61000e565b005b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361007a575f356001600160e01b03191663278f794360e11b14610070576040516334ad5dbb60e21b815260040160405180910390fd5b610078610082565b565b6100786100b0565b5f806100913660048184610303565b81019061009e919061033e565b915091506100ac82826100c0565b5050565b6100786100bb61011a565b610151565b6100c98261016f565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a28051156101125761010d82826101ea565b505050565b6100ac61025c565b5f61014c7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b365f80375f80365f845af43d5f803e80801561016b573d5ff35b3d5ffd5b806001600160a01b03163b5f036101a957604051634c9c8ce360e01b81526001600160a01b03821660048201526024015b60405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b60605f80846001600160a01b0316846040516102069190610407565b5f60405180830381855af49150503d805f811461023e576040519150601f19603f3d011682016040523d82523d5f602084013e610243565b606091505b509150915061025385838361027b565b95945050505050565b34156100785760405163b398979f60e01b815260040160405180910390fd5b6060826102905761028b826102da565b6102d3565b81511580156102a757506001600160a01b0384163b155b156102d057604051639996b31560e01b81526001600160a01b03851660048201526024016101a0565b50805b9392505050565b8051156102ea5780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b5f8085851115610311575f80fd5b8386111561031d575f80fd5b5050820193919092039150565b634e487b7160e01b5f52604160045260245ffd5b5f806040838503121561034f575f80fd5b82356001600160a01b0381168114610365575f80fd5b9150602083013567ffffffffffffffff80821115610381575f80fd5b818501915085601f830112610394575f80fd5b8135818111156103a6576103a661032a565b604051601f8201601f19908116603f011681019083821181831017156103ce576103ce61032a565b816040528281528860208487010111156103e6575f80fd5b826020860160208301375f6020848301015280955050505050509250929050565b5f82518060208501845e5f92019182525091905056fea2646970667358221220117f216494c9098d12bbff87c8d584f4d545471f7a95c3c910c20d7f0d1a105964736f6c63430008190033608060405234801561000f575f80fd5b5060405161050138038061050183398101604081905261002e916100bb565b806001600160a01b03811661005c57604051631e4fbdf760e01b81525f600482015260240160405180910390fd5b6100658161006c565b50506100e8565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b5f602082840312156100cb575f80fd5b81516001600160a01b03811681146100e1575f80fd5b9392505050565b61040c806100f55f395ff3fe608060405260043610610049575f3560e01c8063715018a61461004d5780638da5cb5b146100635780639623609d14610090578063ad3cb1cc146100a3578063f2fde38b146100e0575b5f80fd5b348015610058575f80fd5b506100616100ff565b005b34801561006e575f80fd5b505f546001600160a01b0316604051610087919061023e565b60405180910390f35b61006161009e36600461027a565b610112565b3480156100ae575f80fd5b506100d3604051806040016040528060058152602001640352e302e360dc1b81525081565b6040516100879190610377565b3480156100eb575f80fd5b506100616100fa366004610390565b61017d565b6101076101c3565b6101105f6101ef565b565b61011a6101c3565b60405163278f794360e11b81526001600160a01b03841690634f1ef28690349061014a90869086906004016103ab565b5f604051808303818588803b158015610161575f80fd5b505af1158015610173573d5f803e3d5ffd5b5050505050505050565b6101856101c3565b6001600160a01b0381166101b7575f604051631e4fbdf760e01b81526004016101ae919061023e565b60405180910390fd5b6101c0816101ef565b50565b5f546001600160a01b03163314610110573360405163118cdaa760e01b81526004016101ae919061023e565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b0391909116815260200190565b6001600160a01b03811681146101c0575f80fd5b634e487b7160e01b5f52604160045260245ffd5b5f805f6060848603121561028c575f80fd5b833561029781610252565b925060208401356102a781610252565b9150604084013567ffffffffffffffff808211156102c3575f80fd5b818601915086601f8301126102d6575f80fd5b8135818111156102e8576102e8610266565b604051601f8201601f19908116603f0116810190838211818310171561031057610310610266565b81604052828152896020848701011115610328575f80fd5b826020860160208301375f6020848301015280955050505050509250925092565b5f81518084528060208401602086015e5f602082860101526020601f19601f83011685010191505092915050565b602081525f6103896020830184610349565b9392505050565b5f602082840312156103a0575f80fd5b813561038981610252565b6001600160a01b03831681526040602082018190525f906103ce90830184610349565b94935050505056fea2646970667358221220497e1225d21503b2c0e72feef0d5216fe1525afb4c43c9fa065eef75c65856e264736f6c63430008190033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103a2646970667358221220fedb0f518755c8d12fda617112f8e012e1f4e1586b176433ddae69569445594f64736f6c63430008190033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000000000000000000000000000000de0b6b3a7640000
-----Decoded View---------------
Arg [0] : _minMarketCapacity (uint256): 1000000000000000000
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000de0b6b3a7640000
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.