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:
StakingLPRewards
Compiler Version
v0.8.21+commit.d9974bed
Optimization Enabled:
Yes with 100 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GPL-3.0 // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ // ██╔████╔██║███████║███████║███████║ // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ // Website: https://maha.xyz // Discord: https://discord.gg/mahadao // Twitter: https://twitter.com/mahaxyz_ pragma solidity 0.8.21; import {MultiStakingRewardsERC4626} from "../../core/utils/MultiStakingRewardsERC4626.sol"; contract StakingLPRewards is MultiStakingRewardsERC4626 { function initialize( string memory _name, string memory _symbol, address _stakingToken, address _governance, address _rewardToken1, address _rewardToken2, uint256 _rewardsDuration, address _staking ) external reinitializer(1) { __MultiStakingRewardsERC4626_init( _name, _symbol, _stakingToken, 21 days, _governance, _rewardToken1, _rewardToken2, _rewardsDuration, _staking ); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol) pragma solidity ^0.8.20; import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol"; import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol"; import {ERC165Upgradeable} from "../utils/introspection/ERC165Upgradeable.sol"; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ```solidity * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ```solidity * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules} * to enforce additional security measures for this role. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable { struct RoleData { mapping(address account => bool) hasRole; bytes32 adminRole; } bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl struct AccessControlStorage { mapping(bytes32 role => RoleData) _roles; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.AccessControl")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800; function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) { assembly { $.slot := AccessControlStorageLocation } } /** * @dev Modifier that checks that an account has a specific role. Reverts * with an {AccessControlUnauthorizedAccount} error including the required role. */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } function __AccessControl_init() internal onlyInitializing { } function __AccessControl_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual returns (bool) { AccessControlStorage storage $ = _getAccessControlStorage(); return $._roles[role].hasRole[account]; } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()` * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier. */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account` * is missing `role`. */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert AccessControlUnauthorizedAccount(account, role); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) { AccessControlStorage storage $ = _getAccessControlStorage(); return $._roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `callerConfirmation`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address callerConfirmation) public virtual { if (callerConfirmation != _msgSender()) { revert AccessControlBadConfirmation(); } _revokeRole(role, callerConfirmation); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { AccessControlStorage storage $ = _getAccessControlStorage(); bytes32 previousAdminRole = getRoleAdmin(role); $._roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual returns (bool) { AccessControlStorage storage $ = _getAccessControlStorage(); if (!hasRole(role, account)) { $._roles[role].hasRole[account] = true; emit RoleGranted(role, account, _msgSender()); return true; } else { return false; } } /** * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual returns (bool) { AccessControlStorage storage $ = _getAccessControlStorage(); if (hasRole(role, account)) { $._roles[role].hasRole[account] = false; emit RoleRevoked(role, account, _msgSender()); return true; } else { return false; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol) pragma solidity ^0.8.20; import {IAccessControlEnumerable} from "@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol"; import {AccessControlUpgradeable} from "../AccessControlUpgradeable.sol"; import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import {Initializable} from "../../proxy/utils/Initializable.sol"; /** * @dev Extension of {AccessControl} that allows enumerating the members of each role. */ abstract contract AccessControlEnumerableUpgradeable is Initializable, IAccessControlEnumerable, AccessControlUpgradeable { using EnumerableSet for EnumerableSet.AddressSet; /// @custom:storage-location erc7201:openzeppelin.storage.AccessControlEnumerable struct AccessControlEnumerableStorage { mapping(bytes32 role => EnumerableSet.AddressSet) _roleMembers; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.AccessControlEnumerable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant AccessControlEnumerableStorageLocation = 0xc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e82371705932000; function _getAccessControlEnumerableStorage() private pure returns (AccessControlEnumerableStorage storage $) { assembly { $.slot := AccessControlEnumerableStorageLocation } } function __AccessControlEnumerable_init() internal onlyInitializing { } function __AccessControlEnumerable_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) { AccessControlEnumerableStorage storage $ = _getAccessControlEnumerableStorage(); return $._roleMembers[role].at(index); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) { AccessControlEnumerableStorage storage $ = _getAccessControlEnumerableStorage(); return $._roleMembers[role].length(); } /** * @dev Overload {AccessControl-_grantRole} to track enumerable memberships */ function _grantRole(bytes32 role, address account) internal virtual override returns (bool) { AccessControlEnumerableStorage storage $ = _getAccessControlEnumerableStorage(); bool granted = super._grantRole(role, account); if (granted) { $._roleMembers[role].add(account); } return granted; } /** * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships */ function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) { AccessControlEnumerableStorage storage $ = _getAccessControlEnumerableStorage(); bool revoked = super._revokeRole(role, account); if (revoked) { $._roleMembers[role].remove(account); } return revoked; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (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/introspection/ERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import {Initializable} from "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` */ abstract contract ERC165Upgradeable is Initializable, IERC165 { function __ERC165_init() internal onlyInitializing { } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Multicall.sol) pragma solidity ^0.8.20; import {Address} from "@openzeppelin/contracts/utils/Address.sol"; import {ContextUpgradeable} from "./ContextUpgradeable.sol"; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Provides a function to batch together multiple calls in a single external call. * * Consider any assumption about calldata validation performed by the sender may be violated if it's not especially * careful about sending transactions invoking {multicall}. For example, a relay address that filters function * selectors won't filter calls nested within a {multicall} operation. * * NOTE: Since 5.0.1 and 4.9.4, this contract identifies non-canonical contexts (i.e. `msg.sender` is not {_msgSender}). * If a non-canonical context is identified, the following self `delegatecall` appends the last bytes of `msg.data` * to the subcall. This makes it safe to use with {ERC2771Context}. Contexts that don't affect the resolution of * {_msgSender} are not propagated to subcalls. */ abstract contract MulticallUpgradeable is Initializable, ContextUpgradeable { function __Multicall_init() internal onlyInitializing { } function __Multicall_init_unchained() internal onlyInitializing { } /** * @dev Receives and executes a batch of function calls on this contract. * @custom:oz-upgrades-unsafe-allow-reachable delegatecall */ function multicall(bytes[] calldata data) external virtual returns (bytes[] memory results) { bytes memory context = msg.sender == _msgSender() ? new bytes(0) : msg.data[msg.data.length - _contextSuffixLength():]; results = new bytes[](data.length); for (uint256 i = 0; i < data.length; i++) { results[i] = Address.functionDelegateCall(address(this), bytes.concat(data[i], context)); } return results; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/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/extensions/IAccessControlEnumerable.sol) pragma solidity ^0.8.20; import {IAccessControl} from "../IAccessControl.sol"; /** * @dev External interface of AccessControlEnumerable declared to support ERC165 detection. */ interface IAccessControlEnumerable is IAccessControl { /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) external view returns (address); /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol) pragma solidity ^0.8.20; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev The `account` is missing a role. */ error AccessControlUnauthorizedAccount(address account, bytes32 neededRole); /** * @dev The caller of a function is not the expected one. * * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}. */ error AccessControlBadConfirmation(); /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `callerConfirmation`. */ function renounceRole(bytes32 role, address callerConfirmation) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (governance/utils/IVotes.sol) pragma solidity ^0.8.20; /** * @dev Common interface for {ERC20Votes}, {ERC721Votes}, and other {Votes}-enabled contracts. */ interface IVotes { /** * @dev The signature used has expired. */ error VotesExpiredSignature(uint256 expiry); /** * @dev Emitted when an account changes their delegate. */ event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate); /** * @dev Emitted when a token transfer or delegate change results in changes to a delegate's number of voting units. */ event DelegateVotesChanged(address indexed delegate, uint256 previousVotes, uint256 newVotes); /** * @dev Returns the current amount of votes that `account` has. */ function getVotes(address account) external view returns (uint256); /** * @dev Returns the amount of votes that `account` had at a specific moment in the past. If the `clock()` is * configured to use block numbers, this will return the value at the end of the corresponding block. */ function getPastVotes(address account, uint256 timepoint) external view returns (uint256); /** * @dev Returns the total supply of votes available at a specific moment in the past. If the `clock()` is * configured to use block numbers, this will return the value at the end of the corresponding block. * * NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes. * Votes that have not been delegated are still part of total supply, even though they would not participate in a * vote. */ function getPastTotalSupply(uint256 timepoint) external view returns (uint256); /** * @dev Returns the delegate that `account` has chosen. */ function delegates(address account) external view returns (address); /** * @dev Delegates votes from the sender to `delegatee`. */ function delegate(address delegatee) external; /** * @dev Delegates votes from signer to `delegatee`. */ function delegateBySig(address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s) external; }
// 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/IERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../token/ERC20/IERC20.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/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) (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) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.20; import {IERC721} from "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.20; import {IERC165} from "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon * a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or * {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon * a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the address zero. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol) pragma solidity ^0.8.20; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error AddressInsufficientBalance(address account); /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedInnerCall(); /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { if (address(this).balance < amount) { revert AddressInsufficientBalance(address(this)); } (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert FailedInnerCall(); } } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason or custom error, it is bubbled * up by this function (like regular Solidity function calls). However, if * the call reverted with no returned reason, this function reverts with a * {FailedInnerCall} error. * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { if (address(this).balance < value) { revert AddressInsufficientBalance(address(this)); } (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an * unsuccessful call. */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata ) internal view returns (bytes memory) { if (!success) { _revert(returndata); } else { // only check if target is a contract if the call was successful and the return data is empty // otherwise we already know that it was a contract if (returndata.length == 0 && target.code.length == 0) { revert AddressEmptyCode(target); } return returndata; } } /** * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the * revert reason or with a default {FailedInnerCall} error. */ function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) { if (!success) { _revert(returndata); } else { return returndata; } } /** * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}. */ function _revert(bytes memory returndata) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert FailedInnerCall(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// 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/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: GPL-3.0 // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ // ██╔████╔██║███████║███████║███████║ // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ // Website: https://maha.xyz // Discord: https://discord.gg/mahadao // Twitter: https://twitter.com/mahaxyz_ pragma solidity 0.8.21; import {AccessControlEnumerableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/extensions/AccessControlEnumerableUpgradeable.sol"; import {ERC4626Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC4626Upgradeable.sol"; import {IMultiStakingRewardsERC4626, IMultiTokenRewards} from "../../interfaces/core/IMultiStakingRewardsERC4626.sol"; import {IMultiTokenRewardsWithWithdrawalDelay} from "../../interfaces/core/IMultiTokenRewardsWithWithdrawalDelay.sol"; import {IOmnichainStaking} from "../../interfaces/governance/IOmnichainStaking.sol"; import {MulticallUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/MulticallUpgradeable.sol"; import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol"; import {IERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol"; import {IERC20, SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; /** * @title ERC4262 Staking Rewards * @author maha.xyz * @dev Forked form SetProtocol * @notice The `MultiStakingRewardsERC4626` contracts allows to stake an ERC20 token and * receieve multiple other ERC20 rewards. * https://github.com/SetProtocol/index-coop-contracts/blob/master/contracts/staking/StakingRewards.sol * @dev This contracts is designed to be used via a proxy and follows the ERC4626 standard. * @dev This contracts needs at least two reward tokens to be used */ abstract contract MultiStakingRewardsERC4626 is AccessControlEnumerableUpgradeable, ERC4626Upgradeable, ReentrancyGuardUpgradeable, MulticallUpgradeable, IMultiTokenRewardsWithWithdrawalDelay { using SafeERC20 for IERC20; /// @inheritdoc IMultiStakingRewardsERC4626 bytes32 public immutable DISTRIBUTOR_ROLE = keccak256("DISTRIBUTOR_ROLE"); /// @inheritdoc IMultiTokenRewards mapping(IERC20 reward => uint256) public periodFinish; /// @inheritdoc IMultiTokenRewards mapping(IERC20 reward => uint256) public rewardRate; /// @inheritdoc IMultiTokenRewards uint256 public rewardsDuration; /// @inheritdoc IMultiTokenRewards mapping(IERC20 reward => uint256) public lastUpdateTime; /// @inheritdoc IMultiTokenRewards mapping(IERC20 reward => uint256) public rewardPerTokenStored; /// @inheritdoc IMultiTokenRewards mapping(IERC20 reward => mapping(address who => uint256)) public userRewardPerTokenPaid; /// @inheritdoc IMultiTokenRewards mapping(IERC20 reward => mapping(address who => uint256 rewards)) public rewards; /// @inheritdoc IMultiTokenRewards IERC20 public rewardToken1; /// @inheritdoc IMultiTokenRewards IERC20 public rewardToken2; /// @inheritdoc IMultiStakingRewardsERC4626 IOmnichainStaking public staking; /// @dev Boosted total supply that is used to compute the rewards uint256 internal _boostedTotalSupply; /// @dev Total voting power of all the depositors uint256 internal _totalVotingPower; /// @dev Voting power of a depositor mapping(address who => uint256 votingPower) internal _votingPower; /// @dev Boosted balances that are used to compute the rewards mapping(address who => uint256 boostedBalance) internal _boostedBalances; /// @inheritdoc IMultiTokenRewardsWithWithdrawalDelay uint256 public withdrawalDelay; /// @inheritdoc IMultiTokenRewardsWithWithdrawalDelay mapping(address => uint256) public withdrawalTimestamp; /// @inheritdoc IMultiTokenRewardsWithWithdrawalDelay mapping(address => uint256) public withdrawalAmount; /// @notice Initializes the staking contract with a first set of parameters function __MultiStakingRewardsERC4626_init( string memory name, string memory symbol, address _stakingToken, uint256 _withdrawalDelay, address _governance, address _rewardToken1, address _rewardToken2, uint256 _rewardsDuration, address _staking ) internal onlyInitializing { __ERC20_init(name, symbol); __ERC4626_init(IERC20(_stakingToken)); __AccessControlEnumerable_init(); require(_rewardToken1 != address(0), "reward token 1 is 0x0"); require(_rewardToken2 != address(0), "reward token 2 is 0x0"); // We are not checking the compatibility of the reward token between the distributor and this contract here // because it is checked by the `RewardsDistributor` when activating the staking contract // Parameters rewardsDuration = _rewardsDuration; rewardToken1 = IERC20(_rewardToken1); rewardToken2 = IERC20(_rewardToken2); staking = IOmnichainStaking(_staking); _grantRole(DEFAULT_ADMIN_ROLE, _governance); _grantRole(DISTRIBUTOR_ROLE, _governance); if (_boostedTotalSupply == 0) { _boostedTotalSupply = totalSupply(); } // register the erc20 event _mint(msg.sender, 1e18); _burn(msg.sender, 1e18); withdrawalDelay = _withdrawalDelay; } /// @inheritdoc IMultiTokenRewardsWithWithdrawalDelay function queueWithdrawal(uint256 shares) external { require(shares <= balanceOf(msg.sender), "insufficient balance"); withdrawalTimestamp[msg.sender] = block.timestamp + withdrawalDelay; withdrawalAmount[msg.sender] = shares; emit WithdrawalQueueUpdated(shares, withdrawalTimestamp[msg.sender], msg.sender); _updateRewardDual(rewardToken1, rewardToken2, msg.sender); } /// @inheritdoc IMultiTokenRewardsWithWithdrawalDelay function cancelWithdrawal() external { withdrawalTimestamp[msg.sender] = 0; withdrawalAmount[msg.sender] = 0; emit WithdrawalQueueUpdated(0, 0, msg.sender); _updateRewardDual(rewardToken1, rewardToken2, msg.sender); } /// @inheritdoc IMultiTokenRewards function lastTimeRewardApplicable(IERC20 token) public view returns (uint256) { return Math.min(block.timestamp, periodFinish[token]); } /// @inheritdoc IMultiTokenRewards function rewardPerToken(IERC20 token) external view returns (uint256) { return _rewardPerToken(token, _boostedTotalSupply); } /// @inheritdoc IMultiTokenRewards function earned(IERC20 token, address account) public view returns (uint256) { (uint256 boostedBalance_, uint256 boostedTotalSupply_) = _calculateBoostedBalance(account); return _earned(token, account, boostedBalance_, boostedTotalSupply_); } /// @inheritdoc IMultiStakingRewardsERC4626 function totalBoostedSupply() external view returns (uint256 boostedTotalSupply_) { (, boostedTotalSupply_) = _calculateBoostedBalance(address(0)); } /// @inheritdoc IMultiStakingRewardsERC4626 function boostedBalance(address who) external view returns (uint256 boostedBalance_) { (boostedBalance_,) = _calculateBoostedBalance(who); } /// @inheritdoc IMultiStakingRewardsERC4626 function totalVotingPower() external view returns (uint256 supply) { (, supply) = _getVotingPower(address(0)); } /// @inheritdoc IMultiStakingRewardsERC4626 function votingPower(address who) external view returns (uint256 balance) { (balance,) = _getVotingPower(who); } /// @inheritdoc IMultiStakingRewardsERC4626 function approveUnderlyingWithPermit(uint256 val, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external { IERC20Permit(asset()).permit(msg.sender, address(this), val, deadline, v, r, s); } /// @inheritdoc IMultiTokenRewards function getReward(address who, IERC20 token) public nonReentrant { _updateReward(token, who); uint256 reward = rewards[token][who]; if (reward > 0) { rewards[token][who] = 0; token.safeTransfer(who, reward); emit RewardClaimed(token, reward, who, msg.sender); } } /// @inheritdoc IMultiTokenRewards function getRewardDual(address who) public nonReentrant { _updateRewardDual(rewardToken1, rewardToken2, who); uint256 reward1 = rewards[rewardToken1][who]; if (reward1 > 0) { rewards[rewardToken1][who] = 0; rewardToken1.safeTransfer(who, reward1); emit RewardClaimed(rewardToken1, reward1, who, msg.sender); } uint256 reward2 = rewards[rewardToken2][who]; if (reward2 > 0) { rewards[rewardToken2][who] = 0; rewardToken2.safeTransfer(who, reward2); emit RewardClaimed(rewardToken2, reward2, who, msg.sender); } } /// @inheritdoc IMultiTokenRewards function notifyRewardAmount(IERC20 token, uint256 reward) external onlyRole(DISTRIBUTOR_ROLE) nonReentrant { _updateReward(token, address(0)); token.safeTransferFrom(msg.sender, address(this), reward); if (block.timestamp >= periodFinish[token]) { // If no reward is currently being distributed, the new rate is just `reward / duration` rewardRate[token] = reward / rewardsDuration; } else { // Otherwise, cancel the future reward and add the amount left to distribute to reward uint256 remaining = periodFinish[token] - block.timestamp; uint256 leftover = remaining * rewardRate[token]; rewardRate[token] = (reward + leftover) / rewardsDuration; } // Ensures the provided reward amount is not more than the balance in the contract. // This keeps the reward rate in the right range, preventing overflows due to // very high values of `rewardRate` in the earned and `rewardsPerToken` functions; // Reward + leftover must be less than 2^256 / 10^18 to avoid overflow. uint256 balance = token.balanceOf(address(this)); require(rewardRate[token] <= balance / rewardsDuration, "not enough balance"); lastUpdateTime[token] = block.timestamp; periodFinish[token] = block.timestamp + rewardsDuration; // Change the duration emit RewardAdded(token, reward, msg.sender); } /// @inheritdoc IMultiTokenRewards function updateRewards(IERC20 token, address who) external { _updateReward(token, who); } function _rewardPerToken(IERC20 _token, uint256 boostedTotalSupply_) internal view returns (uint256) { if (boostedTotalSupply_ == 0) { return rewardPerTokenStored[_token]; } return rewardPerTokenStored[_token] + (((lastTimeRewardApplicable(_token) - lastUpdateTime[_token]) * rewardRate[_token] * 1e18) / boostedTotalSupply_); } /// @inheritdoc ERC4626Upgradeable function _withdraw(address caller, address receiver, address owner, uint256 assets, uint256 shares) internal override { uint256 amount = withdrawalAmount[owner]; require(withdrawalTimestamp[owner] <= block.timestamp, "withdrawal not ready"); require(shares == amount && amount > 0, "invalid withdrawal"); withdrawalTimestamp[owner] = 0; withdrawalAmount[owner] = 0; emit WithdrawalQueueUpdated(0, 0, owner); _updateRewardDual(rewardToken1, rewardToken2, owner); super._withdraw(caller, receiver, owner, assets, shares); } /// @inheritdoc ERC4626Upgradeable function _deposit(address caller, address receiver, uint256 assets, uint256 shares) internal virtual override { _updateRewardDual(rewardToken1, rewardToken2, receiver); super._deposit(caller, receiver, assets, shares); } /** * @notice Computes the amount earned by an account * @dev Takes into account the boosted balance and the boosted total supply * @param token_ The token for which the rewards are computed * @param account_ The account for which the rewards are computed * @param boostedBalance_ The boosted balance of the account * @param boostedTotalSupply_ The boosted total supply */ function _earned( IERC20 token_, address account_, uint256 boostedBalance_, uint256 boostedTotalSupply_ ) internal view returns (uint256) { return (boostedBalance_ * (_rewardPerToken(token_, boostedTotalSupply_) - userRewardPerTokenPaid[token_][account_])) / 1e18 + rewards[token_][account_]; } /** * @notice Called frequently to update the staking parameters associated to an address * @param token The token for which the rewards are updated * @param account The account for which the rewards are updated */ function _updateReward(IERC20 token, address account) internal { _updatingVotingPower(account); (uint256 boostedBalance_, uint256 boostedTotalSupply_) = _calculateBoostedBalance(account); _boostedTotalSupply = boostedTotalSupply_; rewardPerTokenStored[token] = _rewardPerToken(token, boostedTotalSupply_); lastUpdateTime[token] = lastTimeRewardApplicable(token); if (account != address(0)) { _boostedBalances[account] = boostedBalance_; rewards[token][account] = _earned(token, account, boostedBalance_, boostedTotalSupply_); userRewardPerTokenPaid[token][account] = rewardPerTokenStored[token]; emit UpdatedBoost(account, boostedBalance_, boostedTotalSupply_); } } /** * @notice Called frequently to update the staking parameters associated to an address * @param token1 The first token for which the rewards are updated * @param token2 The second token for which the rewards are updated * @param account The account for which the rewards are updated */ function _updateRewardDual(IERC20 token1, IERC20 token2, address account) internal { _updatingVotingPower(account); (uint256 boostedBalance_, uint256 boostedTotalSupply_) = _calculateBoostedBalance(account); _boostedTotalSupply = boostedTotalSupply_; rewardPerTokenStored[token1] = _rewardPerToken(token1, boostedTotalSupply_); lastUpdateTime[token1] = lastTimeRewardApplicable(token1); rewardPerTokenStored[token2] = _rewardPerToken(token2, boostedTotalSupply_); lastUpdateTime[token2] = lastTimeRewardApplicable(token2); if (account != address(0)) { _boostedBalances[account] = boostedBalance_; rewards[token1][account] = _earned(token1, account, boostedBalance_, boostedTotalSupply_); rewards[token2][account] = _earned(token2, account, boostedBalance_, boostedTotalSupply_); userRewardPerTokenPaid[token1][account] = rewardPerTokenStored[token1]; userRewardPerTokenPaid[token2][account] = rewardPerTokenStored[token2]; emit UpdatedBoost(account, boostedBalance_, boostedTotalSupply_); } } /** * @notice Updates the voting power of an account * @param account The account for which the voting power is updated */ function _updatingVotingPower(address account) internal { (uint256 votingBalance, uint256 votingTotal) = _getVotingPower(account); _votingPower[account] = votingBalance; _totalVotingPower = votingTotal; } /** * @notice Computes the boosted balance and the boosted total supply of an account * @param account The account for which the boosted balance and the boosted total supply are computed * @return boostedBalance_ The boosted balance of the account * @return boostedTotalSupply_ The boosted total supply */ function _calculateBoostedBalance(address account) internal view virtual returns (uint256 boostedBalance_, uint256 boostedTotalSupply_) { uint256 balance = balanceOf(account); uint256 totalSupply = totalSupply(); if (staking == IOmnichainStaking(address(0))) return (balance / 5, totalSupply / 5); boostedBalance_ = balance / 5; if (_totalVotingPower > 0) { boostedBalance_ += (totalSupply * _votingPower[account] / _totalVotingPower) * 4 / 5; } boostedBalance_ = Math.min(balance, boostedBalance_); boostedTotalSupply_ = _boostedTotalSupply + boostedBalance_ - _boostedBalances[account]; return (boostedBalance_, boostedTotalSupply_); } /** * @notice Computes the voting power of an account * @param account The account for which the voting power is requested * @return votingBalance The voting power of the account * @return votingTotal The total voting power */ function _getVotingPower(address account) internal view returns (uint256 votingBalance, uint256 votingTotal) { if (account == address(0) || address(staking) == address(0)) return (0, _totalVotingPower); votingBalance = staking.getVotes(account); votingTotal = _totalVotingPower + votingBalance - _votingPower[account]; } }
// SPDX-License-Identifier: GPL-3.0 // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ // ██╔████╔██║███████║███████║███████║ // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ // Website: https://maha.xyz // Discord: https://discord.gg/mahadao // Twitter: https://twitter.com/mahaxyz_ pragma solidity 0.8.21; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {IOmnichainStaking} from "../governance/IOmnichainStaking.sol"; import {IMultiTokenRewards} from "./IMultiTokenRewards.sol"; /** * @title IMultiStakingRewardsERC4626 * @author maha.xyz * @notice This interface is used to interact with the MultiStakingRewardsERC4626 contract */ interface IMultiStakingRewardsERC4626 is IMultiTokenRewards { event UpdatedBoost(address indexed account, uint256 boostedBalance, uint256 boostedTotalSupply); /** * @notice Gets the role that is able to distribute rewards */ function DISTRIBUTOR_ROLE() external view returns (bytes32); /** * @notice Gets the total supply of boosted tokens */ function totalBoostedSupply() external view returns (uint256); /** * @notice Gets the total voting power of all the participants */ function totalVotingPower() external view returns (uint256); /** * @notice Gets the boosted balance for an account * @dev Code taken from * https://github.com/curvefi/curve-dao-contracts/blob/master/contracts/gauges/LiquidityGaugeV5.vy#L191-L213 */ function boostedBalance(address who) external view returns (uint256); /** * @notice Gets the voting power for an account * @param who The account for which the voting power is requested */ function votingPower(address who) external view returns (uint256); /** * @notice Gets the staking contract that returns the voting power of an account */ function staking() external view returns (IOmnichainStaking); /** * @notice Grants approval to the staking contract to spend the underlying token using permits */ function approveUnderlyingWithPermit(uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external; }
// SPDX-License-Identifier: GPL-3.0 // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ // ██╔████╔██║███████║███████║███████║ // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ // Website: https://maha.xyz // Discord: https://discord.gg/mahadao // Twitter: https://twitter.com/mahaxyz_ pragma solidity 0.8.21; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /** * @title IMultiTokenRewards * @author maha.xyz * @notice This interface is used to interact with a staking contract that gives multiple rewards */ interface IMultiTokenRewards { event RewardAdded(IERC20 indexed reward, uint256 indexed amount, address caller); event RewardClaimed(IERC20 indexed reward, uint256 indexed amount, address indexed who, address caller); /** * @notice Gets the period finish for a reward token * @param reward The token for which the period finish is requested */ function periodFinish(IERC20 reward) external view returns (uint256); /** * @notice Reward per second given to the staking contract, split among the staked tokens * @param reward The token for which the reward rate is requested */ function rewardRate(IERC20 reward) external view returns (uint256); /** * @notice Duration of the reward distribution */ function rewardsDuration() external view returns (uint256); /** * @notice Last time `rewardPerTokenStored` was updated * @param reward The token for which the last update time is requested */ function lastUpdateTime(IERC20 reward) external view returns (uint256); /** * @notice Helps to compute the amount earned by someone. * Cumulates rewards accumulated for one token since the beginning. * Stored as a uint so it is actually a float times the base of the reward token * @param reward The token for which the rewards are stored */ function rewardPerTokenStored(IERC20 reward) external view returns (uint256); /** * Stores for each account the `rewardPerToken`: we do the difference * between the current and the old value to compute what has been earned by an account * @param reward The token for which the rewards are stored * @param who The account for which the rewards are stored */ function userRewardPerTokenPaid(IERC20 reward, address who) external view returns (uint256); /** * @notice Stores for each account the accumulated rewards * @param reward The token for which the rewards are stored * @param who The account for which the rewards are stored */ function rewards(IERC20 reward, address who) external view returns (uint256); /** * @notice Gets the second reward token for which the rewards are distributed */ function rewardToken2() external view returns (IERC20); /** * @notice Gets the first reward token for which the rewards are distributed */ function rewardToken1() external view returns (IERC20); /** * @notice Updates the rewards for an account * @param token The token for which the rewards are updated * @param who The account for which the rewards are updated */ function updateRewards(IERC20 token, address who) external; /** * @notice Queries the last timestamp at which a reward was distributed * @dev Returns the current timestamp if a reward is being distributed and the end of the staking * period if staking is done * @param token The token for which the last time reward applicable is requested */ function lastTimeRewardApplicable(IERC20 token) external view returns (uint256); /** * @notice Used to actualize the `rewardPerTokenStored` * @dev It adds to the reward per token: the time elapsed since the `rewardPerTokenStored` was * last updated multiplied by the `rewardRate` divided by the number of tokens * @param token The token for which the reward per token is updated */ function rewardPerToken(IERC20 token) external view returns (uint256); /** * @notice Returns how much a given account earned rewards * @param token The token for which the rewards are earned * @param account The account for which the rewards are earned * @return How much a given account earned rewards * @dev It adds to the rewards the amount of reward earned since last time that is the difference * in reward per token from now and last time multiplied by the number of tokens staked by the person */ function earned(IERC20 token, address account) external view returns (uint256); /** * @notice Triggers a payment of the reward earned to the msg.sender * @param who The account for which the rewards are paid * @param token The token for which the rewards are paid */ function getReward(address who, IERC20 token) external; /** * @notice Adds rewards to be distributed * @param token The token for which the rewards are added * @param reward Amount of reward tokens to distribute */ function notifyRewardAmount(IERC20 token, uint256 reward) external; /** * @notice Triggers a payment of the rewards earned for both tokens * @param who The account for which the rewards are paid */ function getRewardDual(address who) external; }
// SPDX-License-Identifier: GPL-3.0 // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ // ██╔████╔██║███████║███████║███████║ // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ // Website: https://maha.xyz // Discord: https://discord.gg/mahadao // Twitter: https://twitter.com/mahaxyz_ pragma solidity 0.8.21; import {IMultiStakingRewardsERC4626} from "./IMultiStakingRewardsERC4626.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IMultiTokenRewardsWithWithdrawalDelay is IMultiStakingRewardsERC4626 { event WithdrawalQueueUpdated(uint256 indexed amt, uint256 indexed unlockTime, address indexed caller); function queueWithdrawal(uint256 shares) external; function withdrawalDelay() external view returns (uint256); function withdrawalAmount(address who) external view returns (uint256); function withdrawalTimestamp(address who) external view returns (uint256); function cancelWithdrawal() external; }
// SPDX-License-Identifier: GPL-3.0 // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ // ██╔████╔██║███████║███████║███████║ // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ // Website: https://maha.xyz // Discord: https://discord.gg/mahadao // Twitter: https://twitter.com/mahaxyz_ pragma solidity 0.8.21; import {IERC20} from "@openzeppelin/contracts/interfaces/IERC20.sol"; import {IERC721Enumerable} from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol"; /// @title ILocker Interface /// @notice Interface for a contract that handles locking ERC20 tokens in exchange for NFT representations interface ILocker is IERC721Enumerable { /** * @notice Structure to store locked balance information * @param amount Amount of tokens locked * @param end End time of the lock period (timestamp) * @param start Start time of the lock period (timestamp) * @param power Additional parameter, potentially for governance or staking power */ struct LockedBalance { uint256 amount; uint256 end; uint256 start; uint256 power; } enum DepositType { DEPOSIT_FOR_TYPE, CREATE_LOCK_TYPE, INCREASE_LOCK_AMOUNT, INCREASE_UNLOCK_TIME, MERGE_TYPE } /** * @notice Get the balance associated with an NFT * @param _tokenId The NFT ID * @return The balance of the NFT */ function balanceOfNFT(uint256 _tokenId) external view returns (uint256); /** * @notice Get the underlying ERC20 token * @return The ERC20 token contract */ function underlying() external view returns (IERC20); /** * @notice Get the locked balance details of an NFT * @param _tokenId The NFT ID * @return The LockedBalance struct containing lock details */ function locked(uint256 _tokenId) external view returns (LockedBalance memory); /** * @notice Get the end time of the lock for a specific NFT * @param _tokenId The NFT ID * @return The end time of the lock period (timestamp) */ function lockedEnd(uint256 _tokenId) external view returns (uint256); /** * @notice Get the voting power of a specific address * @param _owner The address of the owner * @return _power The voting power of the owner */ function votingPowerOf(address _owner) external view returns (uint256 _power); /** * @notice Merge two NFTs into one * @param _from The ID of the NFT to merge from * @param _to The ID of the NFT to merge into */ function merge(uint256 _from, uint256 _to) external; /** * @notice Deposit tokens for a specific NFT * @param _tokenId The ID of the NFT * @param _value The amount of tokens to deposit */ function depositFor(uint256 _tokenId, uint256 _value) external; /** * @notice Create a lock for a specified amount and duration * @param _value The amount of tokens to lock * @param _lockDuration The lock duration in seconds * @param _stakeNFT Whether the NFT should be staked * @return The ID of the created NFT */ function createLock(uint256 _value, uint256 _lockDuration, bool _stakeNFT) external returns (uint256); /** * @notice Increase the amount of tokens locked in a specific NFT * @param _tokenId The ID of the NFT * @param _value The additional amount of tokens to lock */ function increaseAmount(uint256 _tokenId, uint256 _value) external; /** * @notice Extend the unlock time for an NFT * @param _lockDuration New number of seconds until tokens unlock */ function increaseUnlockTime(uint256 _tokenId, uint256 _lockDuration) external; /** * @notice Create a lock for a specified amount, duration, and recipient * @param _value The amount of tokens to lock * @param _lockDuration The lock duration in seconds * @param _to The address to receive the NFT * @param _stakeNFT Whether the NFT should be staked * @return The ID of the created NFT */ function createLockFor(uint256 _value, uint256 _lockDuration, address _to, bool _stakeNFT) external returns (uint256); /** * @notice Withdraw tokens from a specific NFT * @param _tokenId The ID of the NFT */ function withdraw(uint256 _tokenId) external; /** * @notice Withdraw tokens from multiple NFTs * @param _tokenIds An array of NFT IDs */ function withdraw(uint256[] calldata _tokenIds) external; /** * @notice Withdraw tokens for a specific user * @param _user The address of the user */ function withdraw(address _user) external; event Deposit( address indexed provider, uint256 tokenId, uint256 value, uint256 indexed locktime, DepositType deposit_type, uint256 ts ); event Withdraw(address indexed provider, uint256 tokenId, uint256 value, uint256 ts); event Supply(uint256 prevSupply, uint256 supply); event LockUpdated(LockedBalance indexed lock, uint256 indexed tokenId, address caller); event TokenAddressSet(address indexed oldToken, address indexed newToken); event StakingAddressSet(address indexed oldStaking, address indexed newStaking); event StakingBonusAddressSet(address indexed oldStakingBonus, address indexed newStakingBonus); }
// SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity ^0.8.20; // ███████╗███████╗██████╗ ██████╗ // ╚══███╔╝██╔════╝██╔══██╗██╔═══██╗ // ███╔╝ █████╗ ██████╔╝██║ ██║ // ███╔╝ ██╔══╝ ██╔══██╗██║ ██║ // ███████╗███████╗██║ ██║╚██████╔╝ // ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═════╝ // Website: https://zerolend.xyz // Discord: https://discord.gg/zerolend // Twitter: https://twitter.com/zerolendxyz import {IVotes} from "@openzeppelin/contracts/governance/utils/IVotes.sol"; import {IERC20, IMultiTokenRewards} from "../core/IMultiTokenRewards.sol"; import {ILocker} from "./ILocker.sol"; /** * @title OmnichainStaking interface * @author maha.xyz * @notice An omni-chain staking contract that allows users to stake their veNFT and get some * voting power. Once staked the voting power is available cross-chain. */ interface IOmnichainStaking is IMultiTokenRewards, IVotes { event LpOracleSet(address indexed oldLpOracle, address indexed newLpOracle); event ZeroAggregatorSet(address indexed oldZeroAggregator, address indexed newZeroAggregator); event Recovered(address token, uint256 amount); event RewardsDurationUpdated(uint256 newDuration); event TokenLockerUpdated(address previousLocker, address _tokenLocker); event RewardsTokenUpdated(address previousToken, address _zeroToken); event PoolVoterUpdated(address previousVoter, address _poolVoter); error InvalidUnstaker(address, address); /** * @notice The address of the rewards distributor. */ function distributor() external view returns (address); /** * @notice The address of the WETH token. */ function weth() external view returns (IERC20); /** * @notice The address of the locker contract. */ function locker() external view returns (ILocker); /** * @notice How much voting power a given NFT ID has. * @param id The ID of the NFT. */ function power(uint256 id) external view returns (uint256); /** * @notice used to keep track of ownership of token lockers * @param id The ID of the NFT. */ function lockedByToken(uint256 id) external view returns (address); /** * @notice Gets the details of locked NFTs for a given user. * @param _user The address of the user. * @return lockedTokenIds The array of locked NFT IDs. * @return tokenDetails The array of locked NFT details. */ function getLockedNftDetails(address _user) external view returns (uint256[] memory, ILocker.LockedBalance[] memory); /** * @notice Receives an ERC721 token from the lockers and grants voting power accordingly. * @param from The address sending the ERC721 token. * @param tokenId The ID of the ERC721 token. * @param data Additional data. * @return ERC721 onERC721Received selector. */ function onERC721Received(address to, address from, uint256 tokenId, bytes calldata data) external returns (bytes4); /** * @notice Unstakes a regular token NFT and transfers it back to the user. * @param tokenId The ID of the regular token NFT to unstake. */ function unstakeToken(uint256 tokenId) external; /** * @notice Updates the lock duration for a specific NFT. * @param tokenId The ID of the NFT for which to update the lock duration. * @param newLockDuration The new lock duration in seconds. */ function increaseLockDuration(uint256 tokenId, uint256 newLockDuration) external; /** * @notice Updates the lock amount for a specific NFT. * @param tokenId The ID of the NFT for which to update the lock amount. * @param newLockAmount The new lock amount in tokens. */ function increaseLockAmount(uint256 tokenId, uint256 newLockAmount) external; /** * @notice Returns how much max voting power this locker will give out for the * given amount of tokens. This varies for the instance of locker. * @param amount The amount of tokens to give voting power for. */ function getTokenPower(uint256 amount) external view returns (uint256 _power); /** * @notice The total number of NFTs staked in this contract for a user * @param who The address of the user. */ function totalNFTStaked(address who) external view returns (uint256); /** * @dev Admin function to recover ERC20 tokens sent to this contract. * @param tokenAddress The address of the ERC20 token to recover. * @param tokenAmount The amount of tokens to recover. */ function recoverERC20(address tokenAddress, uint256 tokenAmount) external; /** * Admin only function to set the rewards distributor * @param what The new address for the rewards distributor */ function setRewardDistributor(address what) external; /** * @notice This is an ETH variant of the get rewards function. It unwraps the token and sends out * raw ETH to the user. */ function getRewardETH(address who) external; /** * @notice The total number of votes in this contract */ function totalVotes() external view returns (uint256); }
{ "optimizer": { "enabled": true, "runs": 100 }, "evmVersion": "paris", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"allowance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientAllowance","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC20InvalidApprover","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC20InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC20InvalidSender","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"}],"name":"ERC20InvalidSpender","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"ERC4626ExceededMaxDeposit","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"ERC4626ExceededMaxMint","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"ERC4626ExceededMaxRedeem","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"ERC4626ExceededMaxWithdraw","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"MathOverflowedMulDiv","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC20","name":"reward","type":"address"},{"indexed":true,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"RewardAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC20","name":"reward","type":"address"},{"indexed":true,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"who","type":"address"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"RewardClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"boostedBalance","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"boostedTotalSupply","type":"uint256"}],"name":"UpdatedBoost","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"Withdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"amt","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"unlockTime","type":"uint256"},{"indexed":true,"internalType":"address","name":"caller","type":"address"}],"name":"WithdrawalQueueUpdated","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DISTRIBUTOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"val","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"approveUnderlyingWithPermit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"asset","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"who","type":"address"}],"name":"boostedBalance","outputs":[{"internalType":"uint256","name":"boostedBalance_","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cancelWithdrawal","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":[],"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":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"address","name":"account","type":"address"}],"name":"earned","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"who","type":"address"},{"internalType":"contract IERC20","name":"token","type":"address"}],"name":"getReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"who","type":"address"}],"name":"getRewardDual","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"address","name":"_stakingToken","type":"address"},{"internalType":"address","name":"_governance","type":"address"},{"internalType":"address","name":"_rewardToken1","type":"address"},{"internalType":"address","name":"_rewardToken2","type":"address"},{"internalType":"uint256","name":"_rewardsDuration","type":"uint256"},{"internalType":"address","name":"_staking","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"}],"name":"lastTimeRewardApplicable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"reward","type":"address"}],"name":"lastUpdateTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"maxDeposit","outputs":[{"internalType":"uint256","name":"","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":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"results","type":"bytes[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"uint256","name":"reward","type":"uint256"}],"name":"notifyRewardAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"reward","type":"address"}],"name":"periodFinish","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":"shares","type":"uint256"}],"name":"queueWithdrawal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"owner","type":"address"}],"name":"redeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"}],"name":"rewardPerToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"reward","type":"address"}],"name":"rewardPerTokenStored","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"reward","type":"address"}],"name":"rewardRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardToken1","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardToken2","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"reward","type":"address"},{"internalType":"address","name":"who","type":"address"}],"name":"rewards","outputs":[{"internalType":"uint256","name":"rewards","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardsDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"staking","outputs":[{"internalType":"contract IOmnichainStaking","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"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":"totalBoostedSupply","outputs":[{"internalType":"uint256","name":"boostedTotalSupply_","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalVotingPower","outputs":[{"internalType":"uint256","name":"supply","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":"contract IERC20","name":"token","type":"address"},{"internalType":"address","name":"who","type":"address"}],"name":"updateRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"reward","type":"address"},{"internalType":"address","name":"who","type":"address"}],"name":"userRewardPerTokenPaid","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"who","type":"address"}],"name":"votingPower","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"owner","type":"address"}],"name":"withdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"withdrawalAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdrawalDelay","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"withdrawalTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60a06040527ffbd454f36a7e1a388bd6fc3ab10d434aa4578f811acbbcf33afb1c697486313c60805234801561003457600080fd5b506080516137c861005e600039600081816107f50152818161113d015261201c01526137c86000f3fe608060405234801561001057600080fd5b50600436106103505760003560e01c806370a08231116101bf578063c63d75b6116100fa578063daa91f2e1161009d578063daa91f2e1461077f578063dd62ed3e1461079f578063e70b9e27146107b2578063ef8b30f7146106ed578063f01edde0146107dd578063f0bd87cc146107f0578063f122977714610817578063f3da8d391461082a57600080fd5b8063c63d75b6146104e5578063c6e6f592146106ed578063ca15c87314610700578063ce96cb7714610713578063d547741f14610726578063d61a47f114610739578063d905777e1461074c578063da09d19d1461075f57600080fd5b8063a7ab696111610162578063a7ab696114610652578063a9059cbb1461065b578063ac9650d81461066e578063b3d7f6b91461068e578063b460af94146106a1578063b66503cf146106b4578063ba087652146106c7578063c07473f6146106da57600080fd5b806370a08231146105c35780639010d07c146105d657806391d14854146105e957806394bf804d146105fc57806395d89b411461060f5780639ce43f9014610617578063a217fddf14610637578063a55052931461063f57600080fd5b8063313ce5671161028f5780635ba83cac116102325780635ba83cac1461051e578063638634ee14610531578063671b3793146105445780636b0916951461054c5780636b174f351461055f5780636e553f65146105725780636f28d688146105855780637035ab981461059857600080fd5b8063313ce5671461049a57806336568abe146104b4578063386a9525146104c757806338d52e0f146104d0578063402d267d146104e55780634cdad506146103a85780634cf088d9146104f85780635116ee421461050b57600080fd5b806318160ddd116102f757806318160ddd146103fe578063211dc32d14610406578063221ca18c14610419578063226112801461043957806323b872dd14610441578063248a9ca3146104545780632ce9aead146104675780632f2ff15d1461048757600080fd5b806301e1d1141461035557806301ffc9a71461037057806306fdde031461039357806307a2d13a146103a8578063095ea7b3146103bb5780630a28a477146103ce5780630dda7299146103e15780630e37d36f146103e9575b600080fd5b61035d61084a565b6040519081526020015b60405180910390f35b61038361037e366004612e73565b6108cc565b6040519015158152602001610367565b61039b6108f7565b6040516103679190612eed565b61035d6103b6366004612f00565b610998565b6103836103c9366004612f2e565b6109a5565b61035d6103dc366004612f00565b6109bd565b61035d6109ca565b6103fc6103f7366004612f5a565b6109d6565b005b61035d6109e4565b61035d610414366004612f5a565b6109f9565b61035d610427366004612f93565b60016020526000908152604090205481565b6103fc610a20565b61038361044f366004612fb0565b610a75565b61035d610462366004612f00565b610a9b565b61035d610475366004612f93565b60036020526000908152604090205481565b6103fc610495366004612ff1565b610abb565b6104a2610add565b60405160ff9091168152602001610367565b6103fc6104c2366004612ff1565b610b02565b61035d60025481565b6104d8610b3a565b6040516103679190613016565b61035d6104f3366004612f93565b610b55565b6009546104d8906001600160a01b031681565b6103fc61051936600461302a565b610b5c565b61035d61052c366004612f93565b610bf1565b61035d61053f366004612f93565b610c03565b61035d610c27565b6103fc61055a366004612f5a565b610c33565b6103fc61056d366004612f00565b610ceb565b61035d610580366004612ff1565b610da8565b6007546104d8906001600160a01b031681565b61035d6105a6366004612f5a565b600560209081526000928352604080842090915290825290205481565b61035d6105d1366004612f93565b610dfe565b6104d86105e4366004613079565b610e29565b6103836105f7366004612ff1565b610e4f565b61035d61060a366004612ff1565b610e85565b61039b610ed3565b61035d610625366004612f93565b60046020526000908152604090205481565b61035d600081565b6103fc61064d36600461313d565b610ef0565b61035d600e5481565b610383610669366004612f2e565b610fdf565b61068161067c366004613209565b610fed565b604051610367919061327d565b61035d61069c366004612f00565b6110df565b61035d6106af3660046132df565b6110ec565b6103fc6106c2366004612f2e565b61113b565b61035d6106d53660046132df565b6113be565b61035d6106e8366004612f93565b61140d565b61035d6106fb366004612f00565b611418565b61035d61070e366004612f00565b611425565b61035d610721366004612f93565b61144a565b6103fc610734366004612ff1565b61145f565b6008546104d8906001600160a01b031681565b61035d61075a366004612f93565b61147b565b61035d61076d366004612f93565b60006020819052908152604090205481565b61035d61078d366004612f93565b60106020526000908152604090205481565b61035d6107ad366004612f5a565b611486565b61035d6107c0366004612f5a565b600660209081526000928352604080842090915290825290205481565b6103fc6107eb366004612f93565b6114c2565b61035d7f000000000000000000000000000000000000000000000000000000000000000081565b61035d610825366004612f93565b611637565b61035d610838366004612f93565b600f6020526000908152604090205481565b600080610855611645565b80546040516370a0823160e01b81529192506001600160a01b0316906370a0823190610885903090600401613016565b602060405180830381865afa1580156108a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108c69190613321565b91505090565b60006001600160e01b03198216635a05180f60e01b14806108f157506108f182611669565b92915050565b6060600061090361169e565b90508060030180546109149061333a565b80601f01602080910402602001604051908101604052809291908181526020018280546109409061333a565b801561098d5780601f106109625761010080835404028352916020019161098d565b820191906000526020600020905b81548152906001019060200180831161097057829003601f168201915b505050505091505090565b60006108f18260006116c2565b6000336109b3818585611701565b5060019392505050565b60006108f182600161170e565b60006108f16000611743565b6109e08282611845565b5050565b6000806109ef61169e565b6002015492915050565b6000806000610a0784611743565b91509150610a1785858484611961565b95945050505050565b336000818152600f602090815260408083208390556010909152808220829055518190600080516020613753833981519152908290a4600754600854610a73916001600160a01b039081169116336119da565b565b600033610a83858285611b96565b610a8e858585611be3565b60019150505b9392505050565b600080610aa6611c42565b60009384526020525050604090206001015490565b610ac482610a9b565b610acd81611c66565b610ad78383611c70565b50505050565b600080610ae8611645565b9050600081546108c69190600160a01b900460ff1661338a565b6001600160a01b0381163314610b2b5760405163334bd91960e11b815260040160405180910390fd5b610b358282611cb2565b505050565b600080610b45611645565b546001600160a01b031692915050565b5060001990565b610b64610b3a565b60405163d505accf60e01b8152336004820152306024820152604481018790526064810186905260ff8516608482015260a4810184905260c481018390526001600160a01b03919091169063d505accf9060e401600060405180830381600087803b158015610bd257600080fd5b505af1158015610be6573d6000803e3d6000fd5b505050505050505050565b6000610bfc82611743565b5092915050565b6001600160a01b0381166000908152602081905260408120546108f1904290611ceb565b60006108f16000611d01565b610c3b611de2565b610c458183611845565b6001600160a01b038082166000908152600660209081526040808320938616835292905220548015610ce2576001600160a01b038083166000818152600660209081526040808320948816835293905291822091909155610ca7908483611e2c565b826001600160a01b031681836001600160a01b031660008051602061377383398151915233604051610cd99190613016565b60405180910390a45b506109e0611e8b565b610cf433610dfe565b811115610d3f5760405162461bcd60e51b8152602060048201526014602482015273696e73756666696369656e742062616c616e636560601b60448201526064015b60405180910390fd5b600e54610d4c90426133a3565b336000818152600f602081815260408084209586556010825280842087905591905292549251919291849160008051602061375383398151915291a4600754600854610da5916001600160a01b039081169116336119da565b50565b600080610db483610b55565b905080841115610ddd57828482604051633c8097d960e11b8152600401610d36939291906133b6565b6000610de885611418565b9050610df633858784611eb1565b949350505050565b600080610e0961169e565b6001600160a01b0390931660009081526020939093525050604090205490565b600080610e34611eda565b6000858152602082905260409020909150610df69084611efe565b600080610e5a611c42565b6000948552602090815260408086206001600160a01b03959095168652939052505090205460ff1690565b600080610e9183610b55565b905080841115610eba5782848260405163284ff66760e01b8152600401610d36939291906133b6565b6000610ec5856110df565b9050610df633858388611eb1565b60606000610edf61169e565b90508060040180546109149061333a565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805460019190600160401b900460ff1680610f39575080546001600160401b03808416911610155b15610f575760405163f92ee8a960e01b815260040160405180910390fd5b805468ffffffffffffffffff19166001600160401b03831617600160401b178155610f8c8a8a8a621baf808b8b8b8b8b611f0a565b805460ff60401b191681556040516001600160401b03831681527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a150505050505050505050565b6000336109b3818585611be3565b604080516000815260208101909152606090826001600160401b038111156110175761101761309b565b60405190808252806020026020018201604052801561104a57816020015b60608152602001906001900390816110355790505b50915060005b838110156110d7576110a73086868481811061106e5761106e6133ea565b90506020028101906110809190613400565b856040516020016110939392919061344d565b60405160208183030381529060405261208c565b8382815181106110b9576110b96133ea565b602002602001018190525080806110cf90613474565b915050611050565b505092915050565b60006108f18260016116c2565b6000806110f88361144a565b90508085111561112157828582604051633fa733bb60e21b8152600401610d36939291906133b6565b600061112c866109bd565b9050610a1733868689856120f9565b7f000000000000000000000000000000000000000000000000000000000000000061116581611c66565b61116d611de2565b611178836000611845565b61118d6001600160a01b038416333085612225565b6001600160a01b03831660009081526020819052604090205442106111d7576002546111b990836134a3565b6001600160a01b038416600090815260016020526040902055611258565b6001600160a01b0383166000908152602081905260408120546111fb9042906133d7565b6001600160a01b0385166000908152600160205260408120549192509061122290836134b7565b60025490915061123282866133a3565b61123c91906134a3565b6001600160a01b03861660009081526001602052604090205550505b6040516370a0823160e01b81526000906001600160a01b038516906370a0823190611287903090600401613016565b602060405180830381865afa1580156112a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112c89190613321565b9050600254816112d891906134a3565b6001600160a01b03851660009081526001602052604090205411156113345760405162461bcd60e51b81526020600482015260126024820152716e6f7420656e6f7567682062616c616e636560701b6044820152606401610d36565b6001600160a01b0384166000908152600360205260409020429081905560025461135d916133a3565b6001600160a01b038516600081815260208190526040908190209290925590518491907f54dba80f86e498df5a2fcdb5c089d051d97ce8ca9ddb708c70da66557a954de7906113ad903390613016565b60405180910390a350610b35611e8b565b6000806113ca8361147b565b9050808511156113f357828582604051632e52afbb60e21b8152600401610d36939291906133b6565b60006113fe86610998565b9050610a17338686848a6120f9565b6000610bfc82611d01565b60006108f182600061170e565b600080611430611eda565b6000848152602082905260409020909150610a949061225e565b60006108f161145883610dfe565b60006116c2565b61146882610a9b565b61147181611c66565b610ad78383611cb2565b60006108f182610dfe565b60008061149161169e565b6001600160a01b03948516600090815260019190910160209081526040808320959096168252939093525050205490565b6114ca611de2565b6007546008546114e7916001600160a01b039081169116836119da565b6007546001600160a01b03908116600090815260066020908152604080832093851683529290522054801561158a57600780546001600160a01b0390811660009081526006602090815260408083208785168452909152812055905461154f91168383611e2c565b6007546040516001600160a01b0380851692849291169060008051602061377383398151915290611581903390613016565b60405180910390a45b6008546001600160a01b03908116600090815260066020908152604080832093861683529290522054801561162d57600880546001600160a01b039081166000908152600660209081526040808320888516845290915281205590546115f291168483611e2c565b6008546040516001600160a01b0380861692849291169060008051602061377383398151915290611624903390613016565b60405180910390a45b5050610da5611e8b565b60006108f182600a54612268565b7f0773e532dfede91f04b12a73d3d2acd361424f41f76b4fb79f090161e36b4e0090565b60006001600160e01b03198216637965db0b60e01b14806108f157506301ffc9a760e01b6001600160e01b03198316146108f1565b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0090565b6000610a946116cf61084a565b6116da9060016133a3565b6116e66000600a6135b2565b6116ee6109e4565b6116f891906133a3565b85919085612315565b610b358383836001612364565b6000610a9461171e82600a6135b2565b6117266109e4565b61173091906133a3565b61173861084a565b6116f89060016133a3565b600080600061175184610dfe565b9050600061175d6109e4565b6009549091506001600160a01b03166117915761177b6005836134a3565b6117866005836134a3565b935093505050915091565b61179c6005836134a3565b600b54909450156117fd57600b546001600160a01b0386166000908152600c6020526040902054600591906117d190846134b7565b6117db91906134a3565b6117e69060046134b7565b6117f091906134a3565b6117fa90856133a3565b93505b6118078285611ceb565b6001600160a01b0386166000908152600d6020526040902054600a54919550906118329086906133a3565b61183c91906133d7565b92505050915091565b61184e81612448565b60008061185a83611743565b600a819055909250905061186e8482612268565b6001600160a01b03851660009081526004602052604090205561189084610c03565b6001600160a01b03808616600090815260036020526040902091909155831615610ad7576001600160a01b0383166000908152600d602052604090208290556118db84848484611961565b6001600160a01b0385811660008181526006602090815260408083209489168084529482528083209590955591815260048252838120546005835284822084835283529084902055825185815290810184905290917f115e39d10dd5f122500a5729d0f739ba721d5ae9b3f8809171b70e431bbe23ae910160405180910390a250505050565b6001600160a01b038085166000818152600660209081526040808320948816808452948252808320549383526005825280832094835293905291822054670de0b6b3a7640000906119b28886612268565b6119bc91906133d7565b6119c690866134b7565b6119d091906134a3565b610a1791906133a3565b6119e381612448565b6000806119ef83611743565b600a8190559092509050611a038582612268565b6001600160a01b038616600090815260046020526040902055611a2585610c03565b6001600160a01b038616600090815260036020526040902055611a488482612268565b6001600160a01b038516600090815260046020526040902055611a6a84610c03565b6001600160a01b03808616600090815260036020526040902091909155831615611b8f576001600160a01b0383166000908152600d60205260409020829055611ab585848484611961565b6001600160a01b03808716600090815260066020908152604080832093881683529290522055611ae784848484611961565b6001600160a01b03808616600081815260066020908152604080832089861680855290835281842096909655938a1682526004808252848320546005808452868520888652845286852091909155938352815283822054928152838220858352905282902055517f115e39d10dd5f122500a5729d0f739ba721d5ae9b3f8809171b70e431bbe23ae90611b869085908590918252602082015260400190565b60405180910390a25b5050505050565b6000611ba28484611486565b90506000198114610ad75781811015611bd457828183604051637dc7a0d960e11b8152600401610d36939291906133b6565b610ad784848484036000612364565b6001600160a01b038316611c0d576000604051634b637e8f60e11b8152600401610d369190613016565b6001600160a01b038216611c3757600060405163ec442f0560e01b8152600401610d369190613016565b610b35838383612475565b7f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b62680090565b610da5813361259d565b600080611c7b611eda565b90506000611c8985856125d6565b90508015610df6576000858152602083905260409020611ca99085612677565b50949350505050565b600080611cbd611eda565b90506000611ccb858561268c565b90508015610df6576000858152602083905260409020611ca99085612704565b6000818310611cfa5781610a94565b5090919050565b6000806001600160a01b0383161580611d2357506009546001600160a01b0316155b15611d35575050600b54600092909150565b6009546040516309ab24eb60e41b81526001600160a01b0390911690639ab24eb090611d65908690600401613016565b602060405180830381865afa158015611d82573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611da69190613321565b6001600160a01b0384166000908152600c6020526040902054600b5491935090611dd19084906133a3565b611ddb91906133d7565b9050915091565b7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00805460011901611e2657604051633ee5aeb560e01b815260040160405180910390fd5b60029055565b6040516001600160a01b03838116602483015260448201839052610b3591859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050612719565b60017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b600754600854611ece916001600160a01b039081169116856119da565b610ad784848484612773565b7fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e8237170593200090565b6000610a9483836127ef565b611f12612819565b611f1c8989612862565b611f2587612874565b611f2d612885565b6001600160a01b038416611f7b5760405162461bcd60e51b8152602060048201526015602482015274072657761726420746f6b656e20312069732030783605c1b6044820152606401610d36565b6001600160a01b038316611fc95760405162461bcd60e51b8152602060048201526015602482015274072657761726420746f6b656e20322069732030783605c1b6044820152606401610d36565b6002829055600780546001600160a01b038087166001600160a01b031992831617909255600880548684169083161790556009805492841692909116919091179055612016600086611c70565b506120417f000000000000000000000000000000000000000000000000000000000000000086611c70565b50600a54600003612058576120546109e4565b600a555b61206a33670de0b6b3a764000061288d565b61207c33670de0b6b3a76400006128c3565b505050600e929092555050505050565b6060600080846001600160a01b0316846040516120a991906135c1565b600060405180830381855af49150503d80600081146120e4576040519150601f19603f3d011682016040523d82523d6000602084013e6120e9565b606091505b5091509150610a178583836128f9565b6001600160a01b038316600090815260106020908152604080832054600f909252909120544210156121645760405162461bcd60e51b81526020600482015260146024820152737769746864726177616c206e6f7420726561647960601b6044820152606401610d36565b80821480156121735750600081115b6121b45760405162461bcd60e51b81526020600482015260126024820152711a5b9d985b1a59081dda5d1a191c985dd85b60721b6044820152606401610d36565b6001600160a01b0384166000818152600f602090815260408083208390556010909152808220829055518190600080516020613753833981519152908290a4600754600854612210916001600160a01b039081169116866119da565b61221d868686868661294c565b505050505050565b6040516001600160a01b038481166024830152838116604483015260648201839052610ad79186918216906323b872dd90608401611e59565b60006108f1825490565b60008160000361229157506001600160a01b0382166000908152600460205260409020546108f1565b6001600160a01b0383166000908152600160209081526040808320546003909252909120548391906122c286610c03565b6122cc91906133d7565b6122d691906134b7565b6122e890670de0b6b3a76400006134b7565b6122f291906134a3565b6001600160a01b038416600090815260046020526040902054610a9491906133a3565b600080612323868686612a04565b905061232e83612ac8565b801561234a5750600084806123455761234561348d565b868809115b15610a175761235a6001826133a3565b9695505050505050565b600061236e61169e565b90506001600160a01b03851661239a57600060405163e602df0560e01b8152600401610d369190613016565b6001600160a01b0384166123c4576000604051634a1406b160e11b8152600401610d369190613016565b6001600160a01b03808616600090815260018301602090815260408083209388168352929052208390558115611b8f57836001600160a01b0316856001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258560405161243991815260200190565b60405180910390a35050505050565b60008061245483611d01565b6001600160a01b039094166000908152600c60205260409020555050600b55565b600061247f61169e565b90506001600160a01b0384166124ae57818160020160008282546124a391906133a3565b9091555061250d9050565b6001600160a01b038416600090815260208290526040902054828110156124ee5784818460405163391434e360e21b8152600401610d36939291906133b6565b6001600160a01b03851660009081526020839052604090209083900390555b6001600160a01b03831661252b57600281018054839003905561254a565b6001600160a01b03831660009081526020829052604090208054830190555b826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161258f91815260200190565b60405180910390a350505050565b6125a78282610e4f565b6109e05760405163e2517d3f60e01b81526001600160a01b038216600482015260248101839052604401610d36565b6000806125e1611c42565b90506125ed8484610e4f565b61266d576000848152602082815260408083206001600160a01b03871684529091529020805460ff191660011790556126233390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a460019150506108f1565b60009150506108f1565b6000610a94836001600160a01b038416612af5565b600080612697611c42565b90506126a38484610e4f565b1561266d576000848152602082815260408083206001600160a01b0387168085529252808320805460ff1916905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a460019150506108f1565b6000610a94836001600160a01b038416612b44565b600061272e6001600160a01b03841683612c2d565b9050805160001415801561275357508080602001905181019061275191906135dd565b155b15610b355782604051635274afe760e01b8152600401610d369190613016565b600061277d611645565b8054909150612797906001600160a01b0316863086612225565b6127a1848361288d565b836001600160a01b0316856001600160a01b03167fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d78585604051612439929190918252602082015260400190565b6000826000018281548110612806576128066133ea565b9060005260206000200154905092915050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff16610a7357604051631afcd79f60e31b815260040160405180910390fd5b61286a612819565b6109e08282612c3b565b61287c612819565b610da581612c6c565b610a73612819565b6001600160a01b0382166128b757600060405163ec442f0560e01b8152600401610d369190613016565b6109e060008383612475565b6001600160a01b0382166128ed576000604051634b637e8f60e11b8152600401610d369190613016565b6109e082600083612475565b60608261290e5761290982612cdb565b610a94565b815115801561292557506001600160a01b0384163b155b156129455783604051639996b31560e01b8152600401610d369190613016565b5080610a94565b6000612956611645565b9050836001600160a01b0316866001600160a01b03161461297c5761297c848784611b96565b61298684836128c3565b805461299c906001600160a01b03168685611e2c565b836001600160a01b0316856001600160a01b0316876001600160a01b03167ffbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db86866040516129f4929190918252602082015260400190565b60405180910390a4505050505050565b6000838302816000198587098281108382030391505080600003612a3b57838281612a3157612a3161348d565b0492505050610a94565b808411612a5b5760405163227bc15360e01b815260040160405180910390fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b60006002826003811115612ade57612ade6135ff565b612ae89190613615565b60ff166001149050919050565b6000818152600183016020526040812054612b3c575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556108f1565b5060006108f1565b6000818152600183016020526040812054801561266d576000612b686001836133d7565b8554909150600090612b7c906001906133d7565b9050808214612be1576000866000018281548110612b9c57612b9c6133ea565b9060005260206000200154905080876000018481548110612bbf57612bbf6133ea565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080612bf257612bf2613637565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506108f1565b6060610a9483836000612d04565b612c43612819565b6000612c4d61169e565b905060038101612c5d8482613693565b5060048101610ad78382613693565b612c74612819565b6000612c7e611645565b9050600080612c8c84612d97565b9150915081612c9c576012612c9e565b805b83546001600160a81b031916600160a01b60ff92909216919091026001600160a01b031916176001600160a01b0394909416939093179091555050565b805115612ceb5780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b606081471015612d29573060405163cd78605960e01b8152600401610d369190613016565b600080856001600160a01b03168486604051612d4591906135c1565b60006040518083038185875af1925050503d8060008114612d82576040519150601f19603f3d011682016040523d82523d6000602084013e612d87565b606091505b509150915061235a8683836128f9565b60408051600481526024810182526020810180516001600160e01b031663313ce56760e01b17905290516000918291829182916001600160a01b03871691612dde916135c1565b600060405180830381855afa9150503d8060008114612e19576040519150601f19603f3d011682016040523d82523d6000602084013e612e1e565b606091505b5091509150818015612e3257506020815110155b15612e6657600081806020019051810190612e4d9190613321565b905060ff8111612e64576001969095509350505050565b505b5060009485945092505050565b600060208284031215612e8557600080fd5b81356001600160e01b031981168114610a9457600080fd5b60005b83811015612eb8578181015183820152602001612ea0565b50506000910152565b60008151808452612ed9816020860160208601612e9d565b601f01601f19169290920160200192915050565b602081526000610a946020830184612ec1565b600060208284031215612f1257600080fd5b5035919050565b6001600160a01b0381168114610da557600080fd5b60008060408385031215612f4157600080fd5b8235612f4c81612f19565b946020939093013593505050565b60008060408385031215612f6d57600080fd5b8235612f7881612f19565b91506020830135612f8881612f19565b809150509250929050565b600060208284031215612fa557600080fd5b8135610a9481612f19565b600080600060608486031215612fc557600080fd5b8335612fd081612f19565b92506020840135612fe081612f19565b929592945050506040919091013590565b6000806040838503121561300457600080fd5b823591506020830135612f8881612f19565b6001600160a01b0391909116815260200190565b600080600080600060a0868803121561304257600080fd5b8535945060208601359350604086013560ff8116811461306157600080fd5b94979396509394606081013594506080013592915050565b6000806040838503121561308c57600080fd5b50508035926020909101359150565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126130c257600080fd5b81356001600160401b03808211156130dc576130dc61309b565b604051601f8301601f19908116603f011681019082821181831017156131045761310461309b565b8160405283815286602085880101111561311d57600080fd5b836020870160208301376000602085830101528094505050505092915050565b600080600080600080600080610100898b03121561315a57600080fd5b88356001600160401b038082111561317157600080fd5b61317d8c838d016130b1565b995060208b013591508082111561319357600080fd5b506131a08b828c016130b1565b97505060408901356131b181612f19565b955060608901356131c181612f19565b945060808901356131d181612f19565b935060a08901356131e181612f19565b925060c0890135915060e08901356131f881612f19565b809150509295985092959890939650565b6000806020838503121561321c57600080fd5b82356001600160401b038082111561323357600080fd5b818501915085601f83011261324757600080fd5b81358181111561325657600080fd5b8660208260051b850101111561326b57600080fd5b60209290920196919550909350505050565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b828110156132d257603f198886030184526132c0858351612ec1565b945092850192908501906001016132a4565b5092979650505050505050565b6000806000606084860312156132f457600080fd5b83359250602084013561330681612f19565b9150604084013561331681612f19565b809150509250925092565b60006020828403121561333357600080fd5b5051919050565b600181811c9082168061334e57607f821691505b60208210810361336e57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b60ff81811683821601908111156108f1576108f1613374565b808201808211156108f1576108f1613374565b6001600160a01b039390931683526020830191909152604082015260600190565b818103818111156108f1576108f1613374565b634e487b7160e01b600052603260045260246000fd5b6000808335601e1984360301811261341757600080fd5b8301803591506001600160401b0382111561343157600080fd5b60200191503681900382131561344657600080fd5b9250929050565b82848237600083820160008152835161346a818360208801612e9d565b0195945050505050565b60006001820161348657613486613374565b5060010190565b634e487b7160e01b600052601260045260246000fd5b6000826134b2576134b261348d565b500490565b80820281158282048414176108f1576108f1613374565b600181815b808511156135095781600019048211156134ef576134ef613374565b808516156134fc57918102915b93841c93908002906134d3565b509250929050565b600082613520575060016108f1565b8161352d575060006108f1565b8160018114613543576002811461354d57613569565b60019150506108f1565b60ff84111561355e5761355e613374565b50506001821b6108f1565b5060208310610133831016604e8410600b841016171561358c575081810a6108f1565b61359683836134ce565b80600019048211156135aa576135aa613374565b029392505050565b6000610a9460ff841683613511565b600082516135d3818460208701612e9d565b9190910192915050565b6000602082840312156135ef57600080fd5b81518015158114610a9457600080fd5b634e487b7160e01b600052602160045260246000fd5b600060ff8316806136285761362861348d565b8060ff84160691505092915050565b634e487b7160e01b600052603160045260246000fd5b601f821115610b3557600081815260208120601f850160051c810160208610156136745750805b601f850160051c820191505b8181101561221d57828155600101613680565b81516001600160401b038111156136ac576136ac61309b565b6136c0816136ba845461333a565b8461364d565b602080601f8311600181146136f557600084156136dd5750858301515b600019600386901b1c1916600185901b17855561221d565b600085815260208120601f198616915b8281101561372457888601518255948401946001909101908401613705565b50858210156137425787850151600019600388901b60f8161c191681555b5050505050600190811b0190555056fed8889e83fc2ffb229540f381705914cbb36a5cd705d85e1b0035c5eba0c30f4ae6ac6a784fb43c9f6329d2f5c82f88a26a93bad4281f7780725af5f071f0aafaa2646970667358221220a75049a76e814e8bc3ccdc88764ab497290ed7956feb324355beecb31ad8aae664736f6c63430008150033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106103505760003560e01c806370a08231116101bf578063c63d75b6116100fa578063daa91f2e1161009d578063daa91f2e1461077f578063dd62ed3e1461079f578063e70b9e27146107b2578063ef8b30f7146106ed578063f01edde0146107dd578063f0bd87cc146107f0578063f122977714610817578063f3da8d391461082a57600080fd5b8063c63d75b6146104e5578063c6e6f592146106ed578063ca15c87314610700578063ce96cb7714610713578063d547741f14610726578063d61a47f114610739578063d905777e1461074c578063da09d19d1461075f57600080fd5b8063a7ab696111610162578063a7ab696114610652578063a9059cbb1461065b578063ac9650d81461066e578063b3d7f6b91461068e578063b460af94146106a1578063b66503cf146106b4578063ba087652146106c7578063c07473f6146106da57600080fd5b806370a08231146105c35780639010d07c146105d657806391d14854146105e957806394bf804d146105fc57806395d89b411461060f5780639ce43f9014610617578063a217fddf14610637578063a55052931461063f57600080fd5b8063313ce5671161028f5780635ba83cac116102325780635ba83cac1461051e578063638634ee14610531578063671b3793146105445780636b0916951461054c5780636b174f351461055f5780636e553f65146105725780636f28d688146105855780637035ab981461059857600080fd5b8063313ce5671461049a57806336568abe146104b4578063386a9525146104c757806338d52e0f146104d0578063402d267d146104e55780634cdad506146103a85780634cf088d9146104f85780635116ee421461050b57600080fd5b806318160ddd116102f757806318160ddd146103fe578063211dc32d14610406578063221ca18c14610419578063226112801461043957806323b872dd14610441578063248a9ca3146104545780632ce9aead146104675780632f2ff15d1461048757600080fd5b806301e1d1141461035557806301ffc9a71461037057806306fdde031461039357806307a2d13a146103a8578063095ea7b3146103bb5780630a28a477146103ce5780630dda7299146103e15780630e37d36f146103e9575b600080fd5b61035d61084a565b6040519081526020015b60405180910390f35b61038361037e366004612e73565b6108cc565b6040519015158152602001610367565b61039b6108f7565b6040516103679190612eed565b61035d6103b6366004612f00565b610998565b6103836103c9366004612f2e565b6109a5565b61035d6103dc366004612f00565b6109bd565b61035d6109ca565b6103fc6103f7366004612f5a565b6109d6565b005b61035d6109e4565b61035d610414366004612f5a565b6109f9565b61035d610427366004612f93565b60016020526000908152604090205481565b6103fc610a20565b61038361044f366004612fb0565b610a75565b61035d610462366004612f00565b610a9b565b61035d610475366004612f93565b60036020526000908152604090205481565b6103fc610495366004612ff1565b610abb565b6104a2610add565b60405160ff9091168152602001610367565b6103fc6104c2366004612ff1565b610b02565b61035d60025481565b6104d8610b3a565b6040516103679190613016565b61035d6104f3366004612f93565b610b55565b6009546104d8906001600160a01b031681565b6103fc61051936600461302a565b610b5c565b61035d61052c366004612f93565b610bf1565b61035d61053f366004612f93565b610c03565b61035d610c27565b6103fc61055a366004612f5a565b610c33565b6103fc61056d366004612f00565b610ceb565b61035d610580366004612ff1565b610da8565b6007546104d8906001600160a01b031681565b61035d6105a6366004612f5a565b600560209081526000928352604080842090915290825290205481565b61035d6105d1366004612f93565b610dfe565b6104d86105e4366004613079565b610e29565b6103836105f7366004612ff1565b610e4f565b61035d61060a366004612ff1565b610e85565b61039b610ed3565b61035d610625366004612f93565b60046020526000908152604090205481565b61035d600081565b6103fc61064d36600461313d565b610ef0565b61035d600e5481565b610383610669366004612f2e565b610fdf565b61068161067c366004613209565b610fed565b604051610367919061327d565b61035d61069c366004612f00565b6110df565b61035d6106af3660046132df565b6110ec565b6103fc6106c2366004612f2e565b61113b565b61035d6106d53660046132df565b6113be565b61035d6106e8366004612f93565b61140d565b61035d6106fb366004612f00565b611418565b61035d61070e366004612f00565b611425565b61035d610721366004612f93565b61144a565b6103fc610734366004612ff1565b61145f565b6008546104d8906001600160a01b031681565b61035d61075a366004612f93565b61147b565b61035d61076d366004612f93565b60006020819052908152604090205481565b61035d61078d366004612f93565b60106020526000908152604090205481565b61035d6107ad366004612f5a565b611486565b61035d6107c0366004612f5a565b600660209081526000928352604080842090915290825290205481565b6103fc6107eb366004612f93565b6114c2565b61035d7ffbd454f36a7e1a388bd6fc3ab10d434aa4578f811acbbcf33afb1c697486313c81565b61035d610825366004612f93565b611637565b61035d610838366004612f93565b600f6020526000908152604090205481565b600080610855611645565b80546040516370a0823160e01b81529192506001600160a01b0316906370a0823190610885903090600401613016565b602060405180830381865afa1580156108a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108c69190613321565b91505090565b60006001600160e01b03198216635a05180f60e01b14806108f157506108f182611669565b92915050565b6060600061090361169e565b90508060030180546109149061333a565b80601f01602080910402602001604051908101604052809291908181526020018280546109409061333a565b801561098d5780601f106109625761010080835404028352916020019161098d565b820191906000526020600020905b81548152906001019060200180831161097057829003601f168201915b505050505091505090565b60006108f18260006116c2565b6000336109b3818585611701565b5060019392505050565b60006108f182600161170e565b60006108f16000611743565b6109e08282611845565b5050565b6000806109ef61169e565b6002015492915050565b6000806000610a0784611743565b91509150610a1785858484611961565b95945050505050565b336000818152600f602090815260408083208390556010909152808220829055518190600080516020613753833981519152908290a4600754600854610a73916001600160a01b039081169116336119da565b565b600033610a83858285611b96565b610a8e858585611be3565b60019150505b9392505050565b600080610aa6611c42565b60009384526020525050604090206001015490565b610ac482610a9b565b610acd81611c66565b610ad78383611c70565b50505050565b600080610ae8611645565b9050600081546108c69190600160a01b900460ff1661338a565b6001600160a01b0381163314610b2b5760405163334bd91960e11b815260040160405180910390fd5b610b358282611cb2565b505050565b600080610b45611645565b546001600160a01b031692915050565b5060001990565b610b64610b3a565b60405163d505accf60e01b8152336004820152306024820152604481018790526064810186905260ff8516608482015260a4810184905260c481018390526001600160a01b03919091169063d505accf9060e401600060405180830381600087803b158015610bd257600080fd5b505af1158015610be6573d6000803e3d6000fd5b505050505050505050565b6000610bfc82611743565b5092915050565b6001600160a01b0381166000908152602081905260408120546108f1904290611ceb565b60006108f16000611d01565b610c3b611de2565b610c458183611845565b6001600160a01b038082166000908152600660209081526040808320938616835292905220548015610ce2576001600160a01b038083166000818152600660209081526040808320948816835293905291822091909155610ca7908483611e2c565b826001600160a01b031681836001600160a01b031660008051602061377383398151915233604051610cd99190613016565b60405180910390a45b506109e0611e8b565b610cf433610dfe565b811115610d3f5760405162461bcd60e51b8152602060048201526014602482015273696e73756666696369656e742062616c616e636560601b60448201526064015b60405180910390fd5b600e54610d4c90426133a3565b336000818152600f602081815260408084209586556010825280842087905591905292549251919291849160008051602061375383398151915291a4600754600854610da5916001600160a01b039081169116336119da565b50565b600080610db483610b55565b905080841115610ddd57828482604051633c8097d960e11b8152600401610d36939291906133b6565b6000610de885611418565b9050610df633858784611eb1565b949350505050565b600080610e0961169e565b6001600160a01b0390931660009081526020939093525050604090205490565b600080610e34611eda565b6000858152602082905260409020909150610df69084611efe565b600080610e5a611c42565b6000948552602090815260408086206001600160a01b03959095168652939052505090205460ff1690565b600080610e9183610b55565b905080841115610eba5782848260405163284ff66760e01b8152600401610d36939291906133b6565b6000610ec5856110df565b9050610df633858388611eb1565b60606000610edf61169e565b90508060040180546109149061333a565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805460019190600160401b900460ff1680610f39575080546001600160401b03808416911610155b15610f575760405163f92ee8a960e01b815260040160405180910390fd5b805468ffffffffffffffffff19166001600160401b03831617600160401b178155610f8c8a8a8a621baf808b8b8b8b8b611f0a565b805460ff60401b191681556040516001600160401b03831681527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a150505050505050505050565b6000336109b3818585611be3565b604080516000815260208101909152606090826001600160401b038111156110175761101761309b565b60405190808252806020026020018201604052801561104a57816020015b60608152602001906001900390816110355790505b50915060005b838110156110d7576110a73086868481811061106e5761106e6133ea565b90506020028101906110809190613400565b856040516020016110939392919061344d565b60405160208183030381529060405261208c565b8382815181106110b9576110b96133ea565b602002602001018190525080806110cf90613474565b915050611050565b505092915050565b60006108f18260016116c2565b6000806110f88361144a565b90508085111561112157828582604051633fa733bb60e21b8152600401610d36939291906133b6565b600061112c866109bd565b9050610a1733868689856120f9565b7ffbd454f36a7e1a388bd6fc3ab10d434aa4578f811acbbcf33afb1c697486313c61116581611c66565b61116d611de2565b611178836000611845565b61118d6001600160a01b038416333085612225565b6001600160a01b03831660009081526020819052604090205442106111d7576002546111b990836134a3565b6001600160a01b038416600090815260016020526040902055611258565b6001600160a01b0383166000908152602081905260408120546111fb9042906133d7565b6001600160a01b0385166000908152600160205260408120549192509061122290836134b7565b60025490915061123282866133a3565b61123c91906134a3565b6001600160a01b03861660009081526001602052604090205550505b6040516370a0823160e01b81526000906001600160a01b038516906370a0823190611287903090600401613016565b602060405180830381865afa1580156112a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112c89190613321565b9050600254816112d891906134a3565b6001600160a01b03851660009081526001602052604090205411156113345760405162461bcd60e51b81526020600482015260126024820152716e6f7420656e6f7567682062616c616e636560701b6044820152606401610d36565b6001600160a01b0384166000908152600360205260409020429081905560025461135d916133a3565b6001600160a01b038516600081815260208190526040908190209290925590518491907f54dba80f86e498df5a2fcdb5c089d051d97ce8ca9ddb708c70da66557a954de7906113ad903390613016565b60405180910390a350610b35611e8b565b6000806113ca8361147b565b9050808511156113f357828582604051632e52afbb60e21b8152600401610d36939291906133b6565b60006113fe86610998565b9050610a17338686848a6120f9565b6000610bfc82611d01565b60006108f182600061170e565b600080611430611eda565b6000848152602082905260409020909150610a949061225e565b60006108f161145883610dfe565b60006116c2565b61146882610a9b565b61147181611c66565b610ad78383611cb2565b60006108f182610dfe565b60008061149161169e565b6001600160a01b03948516600090815260019190910160209081526040808320959096168252939093525050205490565b6114ca611de2565b6007546008546114e7916001600160a01b039081169116836119da565b6007546001600160a01b03908116600090815260066020908152604080832093851683529290522054801561158a57600780546001600160a01b0390811660009081526006602090815260408083208785168452909152812055905461154f91168383611e2c565b6007546040516001600160a01b0380851692849291169060008051602061377383398151915290611581903390613016565b60405180910390a45b6008546001600160a01b03908116600090815260066020908152604080832093861683529290522054801561162d57600880546001600160a01b039081166000908152600660209081526040808320888516845290915281205590546115f291168483611e2c565b6008546040516001600160a01b0380861692849291169060008051602061377383398151915290611624903390613016565b60405180910390a45b5050610da5611e8b565b60006108f182600a54612268565b7f0773e532dfede91f04b12a73d3d2acd361424f41f76b4fb79f090161e36b4e0090565b60006001600160e01b03198216637965db0b60e01b14806108f157506301ffc9a760e01b6001600160e01b03198316146108f1565b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0090565b6000610a946116cf61084a565b6116da9060016133a3565b6116e66000600a6135b2565b6116ee6109e4565b6116f891906133a3565b85919085612315565b610b358383836001612364565b6000610a9461171e82600a6135b2565b6117266109e4565b61173091906133a3565b61173861084a565b6116f89060016133a3565b600080600061175184610dfe565b9050600061175d6109e4565b6009549091506001600160a01b03166117915761177b6005836134a3565b6117866005836134a3565b935093505050915091565b61179c6005836134a3565b600b54909450156117fd57600b546001600160a01b0386166000908152600c6020526040902054600591906117d190846134b7565b6117db91906134a3565b6117e69060046134b7565b6117f091906134a3565b6117fa90856133a3565b93505b6118078285611ceb565b6001600160a01b0386166000908152600d6020526040902054600a54919550906118329086906133a3565b61183c91906133d7565b92505050915091565b61184e81612448565b60008061185a83611743565b600a819055909250905061186e8482612268565b6001600160a01b03851660009081526004602052604090205561189084610c03565b6001600160a01b03808616600090815260036020526040902091909155831615610ad7576001600160a01b0383166000908152600d602052604090208290556118db84848484611961565b6001600160a01b0385811660008181526006602090815260408083209489168084529482528083209590955591815260048252838120546005835284822084835283529084902055825185815290810184905290917f115e39d10dd5f122500a5729d0f739ba721d5ae9b3f8809171b70e431bbe23ae910160405180910390a250505050565b6001600160a01b038085166000818152600660209081526040808320948816808452948252808320549383526005825280832094835293905291822054670de0b6b3a7640000906119b28886612268565b6119bc91906133d7565b6119c690866134b7565b6119d091906134a3565b610a1791906133a3565b6119e381612448565b6000806119ef83611743565b600a8190559092509050611a038582612268565b6001600160a01b038616600090815260046020526040902055611a2585610c03565b6001600160a01b038616600090815260036020526040902055611a488482612268565b6001600160a01b038516600090815260046020526040902055611a6a84610c03565b6001600160a01b03808616600090815260036020526040902091909155831615611b8f576001600160a01b0383166000908152600d60205260409020829055611ab585848484611961565b6001600160a01b03808716600090815260066020908152604080832093881683529290522055611ae784848484611961565b6001600160a01b03808616600081815260066020908152604080832089861680855290835281842096909655938a1682526004808252848320546005808452868520888652845286852091909155938352815283822054928152838220858352905282902055517f115e39d10dd5f122500a5729d0f739ba721d5ae9b3f8809171b70e431bbe23ae90611b869085908590918252602082015260400190565b60405180910390a25b5050505050565b6000611ba28484611486565b90506000198114610ad75781811015611bd457828183604051637dc7a0d960e11b8152600401610d36939291906133b6565b610ad784848484036000612364565b6001600160a01b038316611c0d576000604051634b637e8f60e11b8152600401610d369190613016565b6001600160a01b038216611c3757600060405163ec442f0560e01b8152600401610d369190613016565b610b35838383612475565b7f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b62680090565b610da5813361259d565b600080611c7b611eda565b90506000611c8985856125d6565b90508015610df6576000858152602083905260409020611ca99085612677565b50949350505050565b600080611cbd611eda565b90506000611ccb858561268c565b90508015610df6576000858152602083905260409020611ca99085612704565b6000818310611cfa5781610a94565b5090919050565b6000806001600160a01b0383161580611d2357506009546001600160a01b0316155b15611d35575050600b54600092909150565b6009546040516309ab24eb60e41b81526001600160a01b0390911690639ab24eb090611d65908690600401613016565b602060405180830381865afa158015611d82573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611da69190613321565b6001600160a01b0384166000908152600c6020526040902054600b5491935090611dd19084906133a3565b611ddb91906133d7565b9050915091565b7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00805460011901611e2657604051633ee5aeb560e01b815260040160405180910390fd5b60029055565b6040516001600160a01b03838116602483015260448201839052610b3591859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050612719565b60017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b600754600854611ece916001600160a01b039081169116856119da565b610ad784848484612773565b7fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e8237170593200090565b6000610a9483836127ef565b611f12612819565b611f1c8989612862565b611f2587612874565b611f2d612885565b6001600160a01b038416611f7b5760405162461bcd60e51b8152602060048201526015602482015274072657761726420746f6b656e20312069732030783605c1b6044820152606401610d36565b6001600160a01b038316611fc95760405162461bcd60e51b8152602060048201526015602482015274072657761726420746f6b656e20322069732030783605c1b6044820152606401610d36565b6002829055600780546001600160a01b038087166001600160a01b031992831617909255600880548684169083161790556009805492841692909116919091179055612016600086611c70565b506120417ffbd454f36a7e1a388bd6fc3ab10d434aa4578f811acbbcf33afb1c697486313c86611c70565b50600a54600003612058576120546109e4565b600a555b61206a33670de0b6b3a764000061288d565b61207c33670de0b6b3a76400006128c3565b505050600e929092555050505050565b6060600080846001600160a01b0316846040516120a991906135c1565b600060405180830381855af49150503d80600081146120e4576040519150601f19603f3d011682016040523d82523d6000602084013e6120e9565b606091505b5091509150610a178583836128f9565b6001600160a01b038316600090815260106020908152604080832054600f909252909120544210156121645760405162461bcd60e51b81526020600482015260146024820152737769746864726177616c206e6f7420726561647960601b6044820152606401610d36565b80821480156121735750600081115b6121b45760405162461bcd60e51b81526020600482015260126024820152711a5b9d985b1a59081dda5d1a191c985dd85b60721b6044820152606401610d36565b6001600160a01b0384166000818152600f602090815260408083208390556010909152808220829055518190600080516020613753833981519152908290a4600754600854612210916001600160a01b039081169116866119da565b61221d868686868661294c565b505050505050565b6040516001600160a01b038481166024830152838116604483015260648201839052610ad79186918216906323b872dd90608401611e59565b60006108f1825490565b60008160000361229157506001600160a01b0382166000908152600460205260409020546108f1565b6001600160a01b0383166000908152600160209081526040808320546003909252909120548391906122c286610c03565b6122cc91906133d7565b6122d691906134b7565b6122e890670de0b6b3a76400006134b7565b6122f291906134a3565b6001600160a01b038416600090815260046020526040902054610a9491906133a3565b600080612323868686612a04565b905061232e83612ac8565b801561234a5750600084806123455761234561348d565b868809115b15610a175761235a6001826133a3565b9695505050505050565b600061236e61169e565b90506001600160a01b03851661239a57600060405163e602df0560e01b8152600401610d369190613016565b6001600160a01b0384166123c4576000604051634a1406b160e11b8152600401610d369190613016565b6001600160a01b03808616600090815260018301602090815260408083209388168352929052208390558115611b8f57836001600160a01b0316856001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258560405161243991815260200190565b60405180910390a35050505050565b60008061245483611d01565b6001600160a01b039094166000908152600c60205260409020555050600b55565b600061247f61169e565b90506001600160a01b0384166124ae57818160020160008282546124a391906133a3565b9091555061250d9050565b6001600160a01b038416600090815260208290526040902054828110156124ee5784818460405163391434e360e21b8152600401610d36939291906133b6565b6001600160a01b03851660009081526020839052604090209083900390555b6001600160a01b03831661252b57600281018054839003905561254a565b6001600160a01b03831660009081526020829052604090208054830190555b826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161258f91815260200190565b60405180910390a350505050565b6125a78282610e4f565b6109e05760405163e2517d3f60e01b81526001600160a01b038216600482015260248101839052604401610d36565b6000806125e1611c42565b90506125ed8484610e4f565b61266d576000848152602082815260408083206001600160a01b03871684529091529020805460ff191660011790556126233390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a460019150506108f1565b60009150506108f1565b6000610a94836001600160a01b038416612af5565b600080612697611c42565b90506126a38484610e4f565b1561266d576000848152602082815260408083206001600160a01b0387168085529252808320805460ff1916905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a460019150506108f1565b6000610a94836001600160a01b038416612b44565b600061272e6001600160a01b03841683612c2d565b9050805160001415801561275357508080602001905181019061275191906135dd565b155b15610b355782604051635274afe760e01b8152600401610d369190613016565b600061277d611645565b8054909150612797906001600160a01b0316863086612225565b6127a1848361288d565b836001600160a01b0316856001600160a01b03167fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d78585604051612439929190918252602082015260400190565b6000826000018281548110612806576128066133ea565b9060005260206000200154905092915050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff16610a7357604051631afcd79f60e31b815260040160405180910390fd5b61286a612819565b6109e08282612c3b565b61287c612819565b610da581612c6c565b610a73612819565b6001600160a01b0382166128b757600060405163ec442f0560e01b8152600401610d369190613016565b6109e060008383612475565b6001600160a01b0382166128ed576000604051634b637e8f60e11b8152600401610d369190613016565b6109e082600083612475565b60608261290e5761290982612cdb565b610a94565b815115801561292557506001600160a01b0384163b155b156129455783604051639996b31560e01b8152600401610d369190613016565b5080610a94565b6000612956611645565b9050836001600160a01b0316866001600160a01b03161461297c5761297c848784611b96565b61298684836128c3565b805461299c906001600160a01b03168685611e2c565b836001600160a01b0316856001600160a01b0316876001600160a01b03167ffbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db86866040516129f4929190918252602082015260400190565b60405180910390a4505050505050565b6000838302816000198587098281108382030391505080600003612a3b57838281612a3157612a3161348d565b0492505050610a94565b808411612a5b5760405163227bc15360e01b815260040160405180910390fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b60006002826003811115612ade57612ade6135ff565b612ae89190613615565b60ff166001149050919050565b6000818152600183016020526040812054612b3c575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556108f1565b5060006108f1565b6000818152600183016020526040812054801561266d576000612b686001836133d7565b8554909150600090612b7c906001906133d7565b9050808214612be1576000866000018281548110612b9c57612b9c6133ea565b9060005260206000200154905080876000018481548110612bbf57612bbf6133ea565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080612bf257612bf2613637565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506108f1565b6060610a9483836000612d04565b612c43612819565b6000612c4d61169e565b905060038101612c5d8482613693565b5060048101610ad78382613693565b612c74612819565b6000612c7e611645565b9050600080612c8c84612d97565b9150915081612c9c576012612c9e565b805b83546001600160a81b031916600160a01b60ff92909216919091026001600160a01b031916176001600160a01b0394909416939093179091555050565b805115612ceb5780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b606081471015612d29573060405163cd78605960e01b8152600401610d369190613016565b600080856001600160a01b03168486604051612d4591906135c1565b60006040518083038185875af1925050503d8060008114612d82576040519150601f19603f3d011682016040523d82523d6000602084013e612d87565b606091505b509150915061235a8683836128f9565b60408051600481526024810182526020810180516001600160e01b031663313ce56760e01b17905290516000918291829182916001600160a01b03871691612dde916135c1565b600060405180830381855afa9150503d8060008114612e19576040519150601f19603f3d011682016040523d82523d6000602084013e612e1e565b606091505b5091509150818015612e3257506020815110155b15612e6657600081806020019051810190612e4d9190613321565b905060ff8111612e64576001969095509350505050565b505b5060009485945092505050565b600060208284031215612e8557600080fd5b81356001600160e01b031981168114610a9457600080fd5b60005b83811015612eb8578181015183820152602001612ea0565b50506000910152565b60008151808452612ed9816020860160208601612e9d565b601f01601f19169290920160200192915050565b602081526000610a946020830184612ec1565b600060208284031215612f1257600080fd5b5035919050565b6001600160a01b0381168114610da557600080fd5b60008060408385031215612f4157600080fd5b8235612f4c81612f19565b946020939093013593505050565b60008060408385031215612f6d57600080fd5b8235612f7881612f19565b91506020830135612f8881612f19565b809150509250929050565b600060208284031215612fa557600080fd5b8135610a9481612f19565b600080600060608486031215612fc557600080fd5b8335612fd081612f19565b92506020840135612fe081612f19565b929592945050506040919091013590565b6000806040838503121561300457600080fd5b823591506020830135612f8881612f19565b6001600160a01b0391909116815260200190565b600080600080600060a0868803121561304257600080fd5b8535945060208601359350604086013560ff8116811461306157600080fd5b94979396509394606081013594506080013592915050565b6000806040838503121561308c57600080fd5b50508035926020909101359150565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126130c257600080fd5b81356001600160401b03808211156130dc576130dc61309b565b604051601f8301601f19908116603f011681019082821181831017156131045761310461309b565b8160405283815286602085880101111561311d57600080fd5b836020870160208301376000602085830101528094505050505092915050565b600080600080600080600080610100898b03121561315a57600080fd5b88356001600160401b038082111561317157600080fd5b61317d8c838d016130b1565b995060208b013591508082111561319357600080fd5b506131a08b828c016130b1565b97505060408901356131b181612f19565b955060608901356131c181612f19565b945060808901356131d181612f19565b935060a08901356131e181612f19565b925060c0890135915060e08901356131f881612f19565b809150509295985092959890939650565b6000806020838503121561321c57600080fd5b82356001600160401b038082111561323357600080fd5b818501915085601f83011261324757600080fd5b81358181111561325657600080fd5b8660208260051b850101111561326b57600080fd5b60209290920196919550909350505050565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b828110156132d257603f198886030184526132c0858351612ec1565b945092850192908501906001016132a4565b5092979650505050505050565b6000806000606084860312156132f457600080fd5b83359250602084013561330681612f19565b9150604084013561331681612f19565b809150509250925092565b60006020828403121561333357600080fd5b5051919050565b600181811c9082168061334e57607f821691505b60208210810361336e57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b60ff81811683821601908111156108f1576108f1613374565b808201808211156108f1576108f1613374565b6001600160a01b039390931683526020830191909152604082015260600190565b818103818111156108f1576108f1613374565b634e487b7160e01b600052603260045260246000fd5b6000808335601e1984360301811261341757600080fd5b8301803591506001600160401b0382111561343157600080fd5b60200191503681900382131561344657600080fd5b9250929050565b82848237600083820160008152835161346a818360208801612e9d565b0195945050505050565b60006001820161348657613486613374565b5060010190565b634e487b7160e01b600052601260045260246000fd5b6000826134b2576134b261348d565b500490565b80820281158282048414176108f1576108f1613374565b600181815b808511156135095781600019048211156134ef576134ef613374565b808516156134fc57918102915b93841c93908002906134d3565b509250929050565b600082613520575060016108f1565b8161352d575060006108f1565b8160018114613543576002811461354d57613569565b60019150506108f1565b60ff84111561355e5761355e613374565b50506001821b6108f1565b5060208310610133831016604e8410600b841016171561358c575081810a6108f1565b61359683836134ce565b80600019048211156135aa576135aa613374565b029392505050565b6000610a9460ff841683613511565b600082516135d3818460208701612e9d565b9190910192915050565b6000602082840312156135ef57600080fd5b81518015158114610a9457600080fd5b634e487b7160e01b600052602160045260246000fd5b600060ff8316806136285761362861348d565b8060ff84160691505092915050565b634e487b7160e01b600052603160045260246000fd5b601f821115610b3557600081815260208120601f850160051c810160208610156136745750805b601f850160051c820191505b8181101561221d57828155600101613680565b81516001600160401b038111156136ac576136ac61309b565b6136c0816136ba845461333a565b8461364d565b602080601f8311600181146136f557600084156136dd5750858301515b600019600386901b1c1916600185901b17855561221d565b600085815260208120601f198616915b8281101561372457888601518255948401946001909101908401613705565b50858210156137425787850151600019600388901b60f8161c191681555b5050505050600190811b0190555056fed8889e83fc2ffb229540f381705914cbb36a5cd705d85e1b0035c5eba0c30f4ae6ac6a784fb43c9f6329d2f5c82f88a26a93bad4281f7780725af5f071f0aafaa2646970667358221220a75049a76e814e8bc3ccdc88764ab497290ed7956feb324355beecb31ad8aae664736f6c63430008150033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 31 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.