Source Code
Overview
ETH Balance
0 ETH
Eth Value
$0.00View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Contract Name:
TEthDepositVault
Compiler Version
v0.8.9+commit.e5eed63a
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import "../DepositVault.sol";
import "./TEthMidasAccessControlRoles.sol";
/**
* @title TEthDepositVault
* @notice Smart contract that handles tETH minting
* @author RedDuck Software
*/
contract TEthDepositVault is DepositVault, TEthMidasAccessControlRoles {
/**
* @dev leaving a storage gap for futures updates
*/
uint256[50] private __gap;
/**
* @inheritdoc ManageableVault
*/
function vaultRole() public pure override returns (bytes32) {
return T_ETH_DEPOSIT_VAULT_ADMIN_ROLE;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface AggregatorV3Interface {
function decimals() external view returns (uint8);
function description() external view returns (string memory);
function version() external view returns (uint256);
function getRoundData(uint80 _roundId)
external
view
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
);
function latestRoundData()
external
view
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol)
pragma solidity ^0.8.0;
import "./IAccessControlUpgradeable.sol";
import "../utils/ContextUpgradeable.sol";
import "../utils/StringsUpgradeable.sol";
import "../utils/introspection/ERC165Upgradeable.sol";
import "../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, IAccessControlUpgradeable, ERC165Upgradeable {
function __AccessControl_init() internal onlyInitializing {
}
function __AccessControl_init_unchained() internal onlyInitializing {
}
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
mapping(bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with a standardized message including the required role.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*
* _Available since v4.1._
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
return _roles[role].members[account];
}
/**
* @dev Revert with a standard message if `_msgSender()` is missing `role`.
* Overriding this function changes the behavior of the {onlyRole} modifier.
*
* Format of the revert message is described in {_checkRole}.
*
* _Available since v4.6._
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Revert with a standard message if `account` is missing `role`.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
StringsUpgradeable.toHexString(account),
" is missing role ",
StringsUpgradeable.toHexString(uint256(role), 32)
)
)
);
}
}
/**
* @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 override returns (bytes32) {
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 override 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 override 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 `account`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address account) public virtual override {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* May emit a {RoleGranted} event.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*
* NOTE: This function is deprecated in favor of {_grantRole}.
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Grants `role` to `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
/**
* @dev Revokes `role` from `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)
pragma solidity ^0.8.0;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControlUpgradeable {
/**
* @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.
*
* _Available since v3.1._
*/
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 `account`.
*/
function renounceRole(bytes32 role, address account) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
import "../../utils/AddressUpgradeable.sol";
/**
* @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 Indicates that the contract has been initialized.
* @custom:oz-retyped-from bool
*/
uint8 private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint8 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 functions marked with `initializer` can be nested in the context of a
* constructor.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
bool isTopLevelCall = !_initializing;
require(
(isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
"Initializable: contract is already initialized"
);
_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 255 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint8 version) {
require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
_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() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
/**
* @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 {
require(!_initializing, "Initializable: contract is initializing");
if (_initialized != type(uint8).max) {
_initialized = type(uint8).max;
emit Initialized(type(uint8).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint8) {
return _initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _initializing;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
function __Pausable_init() internal onlyInitializing {
__Pausable_init_unchained();
}
function __Pausable_init_unchained() internal onlyInitializing {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
require(paused(), "Pausable: not paused");
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
import "./IERC20Upgradeable.sol";
import "./extensions/IERC20MetadataUpgradeable.sol";
import "../../utils/ContextUpgradeable.sol";
import "../../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}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* 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.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
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 {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `amount` 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 amount) public virtual override returns (bool) {
address owner = _msgSender();
_approve(owner, spender, amount);
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 `amount`.
* - the caller must have allowance for ``from``'s tokens of at least
* `amount`.
*/
function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, spender) + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `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.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
*/
function _transfer(address from, address to, uint256 amount) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
// Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
// decrementing then incrementing.
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
unchecked {
// Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
_balances[account] += amount;
}
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
// Overflow not possible: amount <= accountBalance <= totalSupply.
_totalSupply -= amount;
}
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` 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.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `amount`.
*
* Does not update the allowance amount in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Might emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[45] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/ERC20Pausable.sol)
pragma solidity ^0.8.0;
import "../ERC20Upgradeable.sol";
import "../../../security/PausableUpgradeable.sol";
import "../../../proxy/utils/Initializable.sol";
/**
* @dev ERC20 token with pausable token transfers, minting and burning.
*
* Useful for scenarios such as preventing trades until the end of an evaluation
* period, or having an emergency switch for freezing all token transfers in the
* event of a large bug.
*
* IMPORTANT: This contract does not include public pause and unpause functions. In
* addition to inheriting this contract, you must define both functions, invoking the
* {Pausable-_pause} and {Pausable-_unpause} internal functions, with appropriate
* access control, e.g. using {AccessControl} or {Ownable}. Not doing so will
* make the contract unpausable.
*/
abstract contract ERC20PausableUpgradeable is Initializable, ERC20Upgradeable, PausableUpgradeable {
function __ERC20Pausable_init() internal onlyInitializing {
__Pausable_init_unchained();
}
function __ERC20Pausable_init_unchained() internal onlyInitializing {
}
/**
* @dev See {ERC20-_beforeTokenTransfer}.
*
* Requirements:
*
* - the contract must not be paused.
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override {
super._beforeTokenTransfer(from, to, amount);
require(!paused(), "ERC20Pausable: token transfer while paused");
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20Upgradeable.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20MetadataUpgradeable is IERC20Upgradeable {
/**
* @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 v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @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.
*/
interface IERC20PermitUpgradeable {
/**
* @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].
*/
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 v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20Upgradeable {
/**
* @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 amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` 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 amount) 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 `amount` 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 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` 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 amount) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20Upgradeable.sol";
import "../extensions/IERC20PermitUpgradeable.sol";
import "../../../utils/AddressUpgradeable.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 SafeERC20Upgradeable {
using AddressUpgradeable for address;
/**
* @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(IERC20Upgradeable token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, 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(IERC20Upgradeable token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20Upgradeable token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 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(IERC20Upgradeable token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Compatible with tokens that require the approval to be set to
* 0 before setting it to a non-zero value.
*/
function forceApprove(IERC20Upgradeable token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
* Revert on invalid signature.
*/
function safePermit(
IERC20PermitUpgradeable token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @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(IERC20Upgradeable 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, "SafeERC20: low-level call failed");
require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
/**
* @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(IERC20Upgradeable 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))) && AddressUpgradeable.isContract(address(token));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @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.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @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, it is bubbled up by this
* function (like regular Solidity function calls).
*
* 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.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @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`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) 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(errorMessage);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
import "../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;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165Upgradeable.sol";
import "../../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);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {
function __ERC165_init() internal onlyInitializing {
}
function __ERC165_init_unchained() internal onlyInitializing {
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165Upgradeable).interfaceId;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @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 IERC165Upgradeable {
/**
* @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 v4.9.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library MathUpgradeable {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @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 up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (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; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
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.
require(denominator > prod1, "Math: mulDiv overflow");
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
// See https://cs.stackexchange.com/q/138556/92363.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
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 (rounding == Rounding.Up && 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 down.
*
* 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 + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* 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 + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* 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 + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* 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 + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMathUpgradeable {
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// must be unchecked in order to support `n = type(int256).min`
return uint256(n >= 0 ? n : -n);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/MathUpgradeable.sol";
import "./math/SignedMathUpgradeable.sol";
/**
* @dev String operations.
*/
library StringsUpgradeable {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = MathUpgradeable.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toString(int256 value) internal pure returns (string memory) {
return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMathUpgradeable.abs(value))));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, MathUpgradeable.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return keccak256(bytes(a)) == keccak256(bytes(b));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.
pragma solidity ^0.8.0;
/**
* @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 EnumerableSetUpgradeable {
// 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 of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping(bytes32 => uint256) _indexes;
}
/**
* @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._indexes[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 read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 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 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
if (lastIndex != toDeleteIndex) {
bytes32 lastValue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastValue;
// Update the index for the moved value
set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[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._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
bytes32[] memory store = _values(set._inner);
bytes32[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)
pragma solidity ^0.8.0;
/**
* @title Counters
* @author Matt Condon (@shrugs)
* @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
* of elements in a mapping, issuing ERC721 ids, or counting request ids.
*
* Include with `using Counters for Counters.Counter;`
*/
library Counters {
struct Counter {
// This variable should never be directly accessed by users of the library: interactions must be restricted to
// the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
// this feature: see https://github.com/ethereum/solidity/issues/4637
uint256 _value; // default: 0
}
function current(Counter storage counter) internal view returns (uint256) {
return counter._value;
}
function increment(Counter storage counter) internal {
unchecked {
counter._value += 1;
}
}
function decrement(Counter storage counter) internal {
uint256 value = counter._value;
require(value > 0, "Counter: decrement overflow");
unchecked {
counter._value = value - 1;
}
}
function reset(Counter storage counter) internal {
counter._value = 0;
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import {IERC20Upgradeable as IERC20} from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import {IERC20MetadataUpgradeable as IERC20Metadata} from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol";
import {SafeERC20Upgradeable as SafeERC20} from "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import {EnumerableSetUpgradeable as EnumerableSet} from "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol";
import {Counters} from "@openzeppelin/contracts/utils/Counters.sol";
import "../interfaces/IManageableVault.sol";
import "../interfaces/IMTbill.sol";
import "../interfaces/IDataFeed.sol";
import "../access/Greenlistable.sol";
import "../access/Blacklistable.sol";
import "../abstract/WithSanctionsList.sol";
import "../libraries/DecimalsCorrectionLibrary.sol";
import "../access/Pausable.sol";
/**
* @title ManageableVault
* @author RedDuck Software
* @notice Contract with base Vault methods
*/
abstract contract ManageableVault is
Pausable,
IManageableVault,
Blacklistable,
Greenlistable,
WithSanctionsList
{
using EnumerableSet for EnumerableSet.AddressSet;
using DecimalsCorrectionLibrary for uint256;
using SafeERC20 for IERC20;
using Counters for Counters.Counter;
/**
* @notice address that represents off-chain USD bank transfer
*/
address public constant MANUAL_FULLFILMENT_TOKEN = address(0x0);
/**
* @notice stable coin static rate 1:1 USD in 18 decimals
*/
uint256 public constant STABLECOIN_RATE = 10**18;
/**
* @notice last request id
*/
Counters.Counter public currentRequestId;
/**
* @notice 100 percent with base 100
* @dev for example, 10% will be (10 * 100)%
*/
uint256 public constant ONE_HUNDRED_PERCENT = 100 * 100;
uint256 public constant MAX_UINT = type(uint256).max;
/**
* @notice mToken token
*/
IMTbill public mToken;
/**
* @notice mToken data feed contract
*/
IDataFeed public mTokenDataFeed;
/**
* @notice address to which tokens and mTokens will be sent
*/
address public tokensReceiver;
/**
* @dev fee for initial operations 1% = 100
*/
uint256 public instantFee;
/**
* @dev daily limit for initial operations
* if user exceed this limit he will need
* to create requests
*/
uint256 public instantDailyLimit;
/**
* @dev mapping days (number from 1970) to limit amount
*/
mapping(uint256 => uint256) public dailyLimits;
/**
* @notice address to which fees will be sent
*/
address public feeReceiver;
/**
* @notice variation tolerance of tokenOut rates for "safe" requests approve
*/
uint256 public variationTolerance;
/**
* @notice address restriction with zero fees
*/
mapping(address => bool) public waivedFeeRestriction;
/**
* @dev tokens that can be used as USD representation
*/
EnumerableSet.AddressSet internal _paymentTokens;
/**
* @notice mapping, token address to token config
*/
mapping(address => TokenConfig) public tokensConfig;
/**
* @notice basic min operations amount
*/
uint256 public minAmount;
/**
* @notice mapping, user address => is free frmo min amounts
*/
mapping(address => bool) public isFreeFromMinAmount;
/**
* @dev leaving a storage gap for futures updates
*/
uint256[50] private __gap;
/**
* @dev checks that msg.sender do have a vaultRole() role
*/
modifier onlyVaultAdmin() {
_onlyRole(vaultRole(), msg.sender);
_;
}
/**
* @dev upgradeable pattern contract`s initializer
* @param _ac address of MidasAccessControll contract
* @param _mTokenInitParams init params for mToken
* @param _receiversInitParams init params for receivers
* @param _instantInitParams init params for instant operations
* @param _sanctionsList address of sanctionsList contract
* @param _variationTolerance percent of prices diviation 1% = 100
* @param _minAmount basic min amount for operations
*/
// solhint-disable func-name-mixedcase
function __ManageableVault_init(
address _ac,
MTokenInitParams calldata _mTokenInitParams,
ReceiversInitParams calldata _receiversInitParams,
InstantInitParams calldata _instantInitParams,
address _sanctionsList,
uint256 _variationTolerance,
uint256 _minAmount
) internal onlyInitializing {
_validateAddress(_mTokenInitParams.mToken, false);
_validateAddress(_mTokenInitParams.mTokenDataFeed, false);
_validateAddress(_receiversInitParams.tokensReceiver, true);
_validateAddress(_receiversInitParams.feeReceiver, true);
require(_instantInitParams.instantDailyLimit > 0, "zero limit");
_validateFee(_variationTolerance, true);
_validateFee(_instantInitParams.instantFee, false);
mToken = IMTbill(_mTokenInitParams.mToken);
__Pausable_init(_ac);
__Greenlistable_init_unchained();
__Blacklistable_init_unchained();
__WithSanctionsList_init_unchained(_sanctionsList);
tokensReceiver = _receiversInitParams.tokensReceiver;
feeReceiver = _receiversInitParams.feeReceiver;
instantFee = _instantInitParams.instantFee;
instantDailyLimit = _instantInitParams.instantDailyLimit;
minAmount = _minAmount;
variationTolerance = _variationTolerance;
mTokenDataFeed = IDataFeed(_mTokenInitParams.mTokenDataFeed);
}
/**
* @inheritdoc IManageableVault
*/
function withdrawToken(
address token,
uint256 amount,
address withdrawTo
) external onlyVaultAdmin {
IERC20(token).safeTransfer(withdrawTo, amount);
emit WithdrawToken(msg.sender, token, withdrawTo, amount);
}
/**
* @inheritdoc IManageableVault
* @dev reverts if token is already added
*/
function addPaymentToken(
address token,
address dataFeed,
uint256 tokenFee,
bool stable
) external onlyVaultAdmin {
require(_paymentTokens.add(token), "MV: already added");
_validateAddress(dataFeed, false);
_validateFee(tokenFee, false);
tokensConfig[token] = TokenConfig({
dataFeed: dataFeed,
fee: tokenFee,
allowance: MAX_UINT,
stable: stable
});
emit AddPaymentToken(msg.sender, token, dataFeed, tokenFee, stable);
}
/**
* @inheritdoc IManageableVault
* @dev reverts if token is not presented
*/
function removePaymentToken(address token) external onlyVaultAdmin {
require(_paymentTokens.remove(token), "MV: not exists");
delete tokensConfig[token];
emit RemovePaymentToken(token, msg.sender);
}
/**
* @inheritdoc IManageableVault
* @dev reverts if new allowance zero
*/
function changeTokenAllowance(address token, uint256 allowance)
external
onlyVaultAdmin
{
if (token != MANUAL_FULLFILMENT_TOKEN) {
_requireTokenExists(token);
}
require(allowance > 0, "MV: zero allowance");
tokensConfig[token].allowance = allowance;
emit ChangeTokenAllowance(token, msg.sender, allowance);
}
/**
* @inheritdoc IManageableVault
* @dev reverts if new fee > 100%
*/
function changeTokenFee(address token, uint256 fee)
external
onlyVaultAdmin
{
_requireTokenExists(token);
_validateFee(fee, false);
tokensConfig[token].fee = fee;
emit ChangeTokenFee(token, msg.sender, fee);
}
/**
* @inheritdoc IManageableVault
* @dev reverts if new tolerance zero
*/
function setVariationTolerance(uint256 tolerance) external onlyVaultAdmin {
_validateFee(tolerance, true);
variationTolerance = tolerance;
emit SetVariationTolerance(msg.sender, tolerance);
}
/**
* @inheritdoc IManageableVault
*/
function setMinAmount(uint256 newAmount) external onlyVaultAdmin {
minAmount = newAmount;
emit SetMinAmount(msg.sender, newAmount);
}
/**
* @inheritdoc IManageableVault
* @dev reverts if account is already added
*/
function addWaivedFeeAccount(address account) external onlyVaultAdmin {
require(!waivedFeeRestriction[account], "MV: already added");
waivedFeeRestriction[account] = true;
emit AddWaivedFeeAccount(account, msg.sender);
}
/**
* @inheritdoc IManageableVault
* @dev reverts if account is already removed
*/
function removeWaivedFeeAccount(address account) external onlyVaultAdmin {
require(waivedFeeRestriction[account], "MV: not found");
waivedFeeRestriction[account] = false;
emit RemoveWaivedFeeAccount(account, msg.sender);
}
/**
* @inheritdoc IManageableVault
* @dev reverts address zero or equal address(this)
*/
function setFeeReceiver(address receiver) external onlyVaultAdmin {
_validateAddress(receiver, true);
feeReceiver = receiver;
emit SetFeeReceiver(msg.sender, receiver);
}
/**
* @inheritdoc IManageableVault
* @dev reverts address zero or equal address(this)
*/
function setTokensReceiver(address receiver) external onlyVaultAdmin {
_validateAddress(receiver, true);
tokensReceiver = receiver;
emit SetTokensReceiver(msg.sender, receiver);
}
/**
* @inheritdoc IManageableVault
*/
function setInstantFee(uint256 newInstantFee) external onlyVaultAdmin {
_validateFee(newInstantFee, false);
instantFee = newInstantFee;
emit SetInstantFee(msg.sender, newInstantFee);
}
/**
* @inheritdoc IManageableVault
*/
function setInstantDailyLimit(uint256 newInstantDailyLimit)
external
onlyVaultAdmin
{
require(newInstantDailyLimit > 0, "MV: limit zero");
instantDailyLimit = newInstantDailyLimit;
emit SetInstantDailyLimit(msg.sender, newInstantDailyLimit);
}
/**
* @inheritdoc IManageableVault
*/
function freeFromMinAmount(address user, bool enable)
external
onlyVaultAdmin
{
require(isFreeFromMinAmount[user] != enable, "DV: already free");
isFreeFromMinAmount[user] = enable;
emit FreeFromMinAmount(user, enable);
}
/**
* @notice returns array of stablecoins supported by the vault
* can be called only from permissioned actor.
* @return paymentTokens array of payment tokens
*/
function getPaymentTokens() external view returns (address[] memory) {
return _paymentTokens.values();
}
/**
* @notice AC role of vault administrator
* @return role bytes32 role
*/
function vaultRole() public view virtual returns (bytes32);
/**
* @inheritdoc WithSanctionsList
*/
function sanctionsListAdminRole()
public
view
virtual
override
returns (bytes32)
{
return vaultRole();
}
/**
* @inheritdoc Pausable
*/
function pauseAdminRole() public view override returns (bytes32) {
return vaultRole();
}
/**
* @dev do safeTransferFrom on a given token
* and converts `amount` from base18
* to amount with a correct precision. Sends tokens
* from `msg.sender` to `tokensReceiver`
* @param token address of token
* @param to address of user
* @param amount amount of `token` to transfer from `user` (decimals 18)
* @param tokenDecimals token decimals
*/
function _tokenTransferFromUser(
address token,
address to,
uint256 amount,
uint256 tokenDecimals
) internal {
uint256 transferAmount = amount.convertFromBase18(tokenDecimals);
require(
amount == transferAmount.convertToBase18(tokenDecimals),
"MV: invalid rounding"
);
IERC20(token).safeTransferFrom(msg.sender, to, transferAmount);
}
/**
* @dev do safeTransferFrom on a given token
* and converts `amount` from base18
* to amount with a correct precision.
* @param token address of token
* @param from address
* @param to address
* @param amount amount of `token` to transfer from `user`
* @param tokenDecimals token decimals
*/
function _tokenTransferFromTo(
address token,
address from,
address to,
uint256 amount,
uint256 tokenDecimals
) internal {
uint256 transferAmount = amount.convertFromBase18(tokenDecimals);
require(
amount == transferAmount.convertToBase18(tokenDecimals),
"MV: invalid rounding"
);
IERC20(token).safeTransferFrom(from, to, transferAmount);
}
/**
* @dev do safeTransfer on a given token
* and converts `amount` from base18
* to amount with a correct precision. Sends tokens
* from `contract` to `user`
* @param token address of token
* @param to address of user
* @param amount amount of `token` to transfer from `user` (decimals 18)
* @param tokenDecimals token decimals
*/
function _tokenTransferToUser(
address token,
address to,
uint256 amount,
uint256 tokenDecimals
) internal {
uint256 transferAmount = amount.convertFromBase18(tokenDecimals);
require(
amount == transferAmount.convertToBase18(tokenDecimals),
"MV: invalid rounding"
);
IERC20(token).safeTransfer(to, transferAmount);
}
/**
* @dev retreives decimals of a given `token`
* @param token address of token
* @return decimals decinmals value of a given `token`
*/
function _tokenDecimals(address token) internal view returns (uint8) {
return IERC20Metadata(token).decimals();
}
/**
* @dev checks that `token` is presented in `_paymentTokens`
* @param token address of token
*/
function _requireTokenExists(address token) internal view virtual {
require(_paymentTokens.contains(token), "MV: token not exists");
}
/**
* @dev check if operation exceed daily limit and update limit data
* @param amount operation amount (decimals 18)
*/
function _requireAndUpdateLimit(uint256 amount) internal {
uint256 currentDayNumber = block.timestamp / 1 days;
uint256 nextLimitAmount = dailyLimits[currentDayNumber] + amount;
require(nextLimitAmount <= instantDailyLimit, "MV: exceed limit");
dailyLimits[currentDayNumber] = nextLimitAmount;
}
/**
* @dev check if operation exceed token allowance and update allowance
* @param token address of token
* @param amount operation amount (decimals 18)
*/
function _requireAndUpdateAllowance(address token, uint256 amount)
internal
{
uint256 prevAllowance = tokensConfig[token].allowance;
if (prevAllowance == MAX_UINT) return;
require(prevAllowance >= amount, "MV: exceed allowance");
tokensConfig[token].allowance -= amount;
}
/**
* @dev returns calculated fee amount depends on parameters
* if additionalFee not zero, token fee replaced with additionalFee
* @param sender sender address
* @param token token address
* @param amount amount of token (decimals 18)
* @param isInstant is instant operation
* @param additionalFee fee for fiat operations
* @return fee amount of input token
*/
function _getFeeAmount(
address sender,
address token,
uint256 amount,
bool isInstant,
uint256 additionalFee
) internal view returns (uint256) {
if (waivedFeeRestriction[sender]) return 0;
uint256 feePercent;
if (additionalFee == 0) {
TokenConfig storage tokenConfig = tokensConfig[token];
feePercent = tokenConfig.fee;
} else {
feePercent = additionalFee;
}
if (isInstant) feePercent += instantFee;
if (feePercent > ONE_HUNDRED_PERCENT) feePercent = ONE_HUNDRED_PERCENT;
return (amount * feePercent) / ONE_HUNDRED_PERCENT;
}
/**
* @dev check if prev and new prices diviation fit variationTolerance
* @param prevPrice previous rate
* @param newPrice new rate
*/
function _requireVariationTolerance(uint256 prevPrice, uint256 newPrice)
internal
view
{
uint256 priceDif = newPrice >= prevPrice
? newPrice - prevPrice
: prevPrice - newPrice;
uint256 priceDifPercent = (priceDif * ONE_HUNDRED_PERCENT) / prevPrice;
require(
priceDifPercent <= variationTolerance,
"MV: exceed price diviation"
);
}
/**
* @dev convert value to inputted decimals precision
* @param value value for format
* @param decimals decimals
* @return converted amount
*/
function _truncate(uint256 value, uint256 decimals)
internal
pure
returns (uint256)
{
return value.convertFromBase18(decimals).convertToBase18(decimals);
}
/**
* @dev check if fee <= 100% and check > 0 if needs
* @param fee fee value
* @param checkMin if need to check minimum
*/
function _validateFee(uint256 fee, bool checkMin) internal pure {
require(fee <= ONE_HUNDRED_PERCENT, "fee > 100%");
if (checkMin) require(fee > 0, "fee == 0");
}
/**
* @dev check if address not zero and not address(this)
* @param addr address to check
* @param selfCheck check if address not address(this)
*/
function _validateAddress(address addr, bool selfCheck) internal view {
require(addr != address(0), "zero address");
if (selfCheck) require(addr != address(this), "invalid address");
}
/**
* @dev get token rate depends on data feed and stablecoin flag
* @param dataFeed address of dataFeed from token config
* @param stable is stablecoin
*/
function _getTokenRate(address dataFeed, bool stable)
internal
view
virtual
returns (uint256)
{
// @dev if dataFeed returns rate, all peg checks passed
uint256 rate = IDataFeed(dataFeed).getDataInBase18();
if (stable) return STABLECOIN_RATE;
return rate;
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
/**
* @title MidasInitializable
* @author RedDuck Software
* @notice Base Initializable contract that implements constructor
* that calls _disableInitializers() to prevent
* initialization of implementation contract
*/
abstract contract MidasInitializable is Initializable {
constructor() {
_disableInitializers();
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import "../interfaces/ISanctionsList.sol";
import "../access/WithMidasAccessControl.sol";
import "./MidasInitializable.sol";
/**
* @title WithSanctionsList
* @notice Base contract that uses sanctions oracle from
* Chainalysis to check that user is not sanctioned
* @author RedDuck Software
*/
abstract contract WithSanctionsList is WithMidasAccessControl {
/**
* @notice address of Chainalysis sanctions oracle
*/
address public sanctionsList;
/**
* @dev leaving a storage gap for futures updates
*/
uint256[50] private __gap;
/**
* @param caller function caller (msg.sender)
* @param newSanctionsList new address of `sanctionsList`
*/
event SetSanctionsList(
address indexed caller,
address indexed newSanctionsList
);
/**
* @dev checks that a given `user` is not sanctioned
*/
modifier onlyNotSanctioned(address user) {
address _sanctionsList = sanctionsList;
if (_sanctionsList != address(0)) {
require(
!ISanctionsList(_sanctionsList).isSanctioned(user),
"WSL: sanctioned"
);
}
_;
}
/**
* @dev upgradeable pattern contract`s initializer
*/
// solhint-disable func-name-mixedcase
function __WithSanctionsList_init(
address _accesControl,
address _sanctionsList
) internal onlyInitializing {
__WithMidasAccessControl_init(_accesControl);
__WithSanctionsList_init_unchained(_sanctionsList);
}
/**
* @dev upgradeable pattern contract`s initializer unchained
*/
// solhint-disable func-name-mixedcase
function __WithSanctionsList_init_unchained(address _sanctionsList)
internal
onlyInitializing
{
sanctionsList = _sanctionsList;
}
/**
* @notice updates `sanctionsList` address.
* can be called only from permissioned actor that have
* `sanctionsListAdminRole()` role
* @param newSanctionsList new sanctions list address
*/
function setSanctionsList(address newSanctionsList) external {
_onlyRole(sanctionsListAdminRole(), msg.sender);
sanctionsList = newSanctionsList;
emit SetSanctionsList(msg.sender, newSanctionsList);
}
/**
* @notice AC role of sanctions list admin
* @dev address that have this role can use `setSanctionsList`
* @return role bytes32 role
*/
function sanctionsListAdminRole() public view virtual returns (bytes32);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import "./WithMidasAccessControl.sol";
/**
* @title Blacklistable
* @notice Base contract that implements basic functions and modifiers
* to work with blacklistable
* @author RedDuck Software
*/
abstract contract Blacklistable is WithMidasAccessControl {
/**
* @dev leaving a storage gap for futures updates
*/
uint256[50] private __gap;
/**
* @dev checks that a given `account` doesnt
* have BLACKLISTED_ROLE
*/
modifier onlyNotBlacklisted(address account) {
_onlyNotBlacklisted(account);
_;
}
/**
* @dev upgradeable pattern contract`s initializer
* @param _accessControl MidasAccessControl contract address
*/
// solhint-disable func-name-mixedcase
function __Blacklistable_init(address _accessControl)
internal
onlyInitializing
{
__WithMidasAccessControl_init(_accessControl);
__Blacklistable_init_unchained();
}
/**
* @dev upgradeable pattern contract`s initializer unchained
*/
// solhint-disable func-name-mixedcase
function __Blacklistable_init_unchained() internal onlyInitializing {}
/**
* @dev checks that a given `account` doesnt
* have BLACKLISTED_ROLE
*/
function _onlyNotBlacklisted(address account)
internal
view
onlyNotRole(BLACKLISTED_ROLE, account)
{}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import "./WithMidasAccessControl.sol";
/**
* @title Greenlistable
* @notice Base contract that implements basic functions and modifiers
* to work with greenlistable
* @author RedDuck Software
*/
abstract contract Greenlistable is WithMidasAccessControl {
/**
* @notice actor that can change green list enable
*/
bytes32 public constant GREENLIST_TOGGLER_ROLE =
keccak256("GREENLIST_TOGGLER_ROLE");
/**
* @notice is greenlist enabled
*/
bool public greenlistEnabled;
/**
* @dev leaving a storage gap for futures updates
*/
uint256[50] private __gap;
event SetGreenlistEnable(address indexed sender, bool enable);
/**
* @dev checks that a given `account`
* have `greenlistedRole()`
*/
modifier onlyGreenlisted(address account) {
if (greenlistEnabled) _onlyGreenlisted(account);
_;
}
/**
* @dev checks that a given `account`
* have `greenlistedRole()`
* do the check even if greenlist check is off
*/
modifier onlyAlwaysGreenlisted(address account) {
_onlyGreenlisted(account);
_;
}
/**
* @dev upgradeable pattern contract`s initializer
* @param _accessControl MidasAccessControl contract address
*/
// solhint-disable func-name-mixedcase
function __Greenlistable_init(address _accessControl)
internal
onlyInitializing
{
__WithMidasAccessControl_init(_accessControl);
__Greenlistable_init_unchained();
}
/**
* @dev upgradeable pattern contract`s initializer unchained
*/
// solhint-disable func-name-mixedcase
function __Greenlistable_init_unchained() internal onlyInitializing {}
/**
* @notice enable or disable greenlist.
* can be called only from permissioned actor.
* @param enable enable
*/
function setGreenlistEnable(bool enable) external {
_onlyGreenlistToggler(msg.sender);
require(greenlistEnabled != enable, "GL: same enable status");
greenlistEnabled = enable;
emit SetGreenlistEnable(msg.sender, enable);
}
/**
* @notice AC role of a greenlist
* @return role bytes32 role
*/
function greenlistedRole() public view virtual returns (bytes32) {
return GREENLISTED_ROLE;
}
/**
* @notice AC role of a greenlist
* @return role bytes32 role
*/
function greenlistTogglerRole() public view virtual returns (bytes32) {
return GREENLIST_TOGGLER_ROLE;
}
/**
* @dev checks that a given `account`
* have a `greenlistedRole()`
*/
function _onlyGreenlisted(address account)
private
view
onlyRole(greenlistedRole(), account)
{}
/**
* @dev checks that a given `account`
* have a `greenlistTogglerRole()`
*/
function _onlyGreenlistToggler(address account)
internal
view
onlyRole(greenlistTogglerRole(), account)
{}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "./MidasAccessControlRoles.sol";
import "../abstract/MidasInitializable.sol";
/**
* @title MidasAccessControl
* @notice Smart contract that stores all roles for Midas project
* @author RedDuck Software
*/
contract MidasAccessControl is
AccessControlUpgradeable,
MidasInitializable,
MidasAccessControlRoles
{
/**
* @notice upgradeable pattern contract`s initializer
*/
function initialize() external initializer {
__AccessControl_init();
_setupRoles(msg.sender);
}
/**
* @notice grant multiple roles to multiple users
* in one transaction
* @dev length`s of 2 arays should match
* @param roles array of bytes32 roles
* @param addresses array of user addresses
*/
function grantRoleMult(bytes32[] memory roles, address[] memory addresses)
external
{
require(roles.length == addresses.length, "MAC: mismatch arrays");
for (uint256 i = 0; i < roles.length; i++) {
_checkRole(getRoleAdmin(roles[i]), msg.sender);
_grantRole(roles[i], addresses[i]);
}
}
/**
* @notice revoke multiple roles from multiple users
* in one transaction
* @dev length`s of 2 arays should match
* @param roles array of bytes32 roles
* @param addresses array of user addresses
*/
function revokeRoleMult(bytes32[] memory roles, address[] memory addresses)
external
{
require(roles.length == addresses.length, "MAC: mismatch arrays");
for (uint256 i = 0; i < roles.length; i++) {
_checkRole(getRoleAdmin(roles[i]), msg.sender);
_revokeRole(roles[i], addresses[i]);
}
}
//solhint-disable disable-next-line
function renounceRole(bytes32, address) public pure override {
revert("MAC: Forbidden");
}
/**
* @dev setup roles during the contracts initialization
*/
function _setupRoles(address admin) private {
_grantRole(DEFAULT_ADMIN_ROLE, admin);
_grantRole(DEPOSIT_VAULT_ADMIN_ROLE, admin);
_grantRole(REDEMPTION_VAULT_ADMIN_ROLE, admin);
_setRoleAdmin(BLACKLISTED_ROLE, BLACKLIST_OPERATOR_ROLE);
_setRoleAdmin(GREENLISTED_ROLE, GREENLIST_OPERATOR_ROLE);
_grantRole(GREENLIST_OPERATOR_ROLE, admin);
_grantRole(BLACKLIST_OPERATOR_ROLE, admin);
_grantRole(M_TBILL_MINT_OPERATOR_ROLE, admin);
_grantRole(M_TBILL_BURN_OPERATOR_ROLE, admin);
_grantRole(M_TBILL_PAUSE_OPERATOR_ROLE, admin);
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
/**
* @title MidasAccessControlRoles
* @notice Base contract that stores all roles descriptors
* @author RedDuck Software
*/
abstract contract MidasAccessControlRoles {
/**
* @notice actor that can change green list statuses of addresses
*/
bytes32 public constant GREENLIST_OPERATOR_ROLE =
keccak256("GREENLIST_OPERATOR_ROLE");
/**
* @notice actor that can change black list statuses of addresses
*/
bytes32 public constant BLACKLIST_OPERATOR_ROLE =
keccak256("BLACKLIST_OPERATOR_ROLE");
/**
* @notice actor that can mint mTBILL
*/
bytes32 public constant M_TBILL_MINT_OPERATOR_ROLE =
keccak256("M_TBILL_MINT_OPERATOR_ROLE");
/**
* @notice actor that can burn mTBILL
*/
bytes32 public constant M_TBILL_BURN_OPERATOR_ROLE =
keccak256("M_TBILL_BURN_OPERATOR_ROLE");
/**
* @notice actor that can pause mTBILL
*/
bytes32 public constant M_TBILL_PAUSE_OPERATOR_ROLE =
keccak256("M_TBILL_PAUSE_OPERATOR_ROLE");
/**
* @notice actor that have admin rights in deposit vault
*/
bytes32 public constant DEPOSIT_VAULT_ADMIN_ROLE =
keccak256("DEPOSIT_VAULT_ADMIN_ROLE");
/**
* @notice actor that have admin rights in redemption vault
*/
bytes32 public constant REDEMPTION_VAULT_ADMIN_ROLE =
keccak256("REDEMPTION_VAULT_ADMIN_ROLE");
/**
* @notice actor that is greenlisted
*/
bytes32 public constant GREENLISTED_ROLE = keccak256("GREENLISTED_ROLE");
/**
* @notice actor that is blacklisted
*/
bytes32 public constant BLACKLISTED_ROLE = keccak256("BLACKLISTED_ROLE");
}// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.9;
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import "../access/WithMidasAccessControl.sol";
/**
* @title Pausable
* @notice Base contract that implements basic functions and modifiers
* with pause functionality
* @author RedDuck Software
*/
abstract contract Pausable is WithMidasAccessControl, PausableUpgradeable {
mapping(bytes4 => bool) public fnPaused;
/**
* @dev leaving a storage gap for futures updates
*/
uint256[50] private __gap;
/**
* @param caller caller address (msg.sender)
* @param fn function id
*/
event PauseFn(address indexed caller, bytes4 fn);
/**
* @param caller caller address (msg.sender)
* @param fn function id
*/
event UnpauseFn(address indexed caller, bytes4 fn);
modifier whenFnNotPaused(bytes4 fn) {
_requireNotPaused();
require(!fnPaused[fn], "Pausable: fn paused");
_;
}
/**
* @dev checks that a given `account`
* has a determinedPauseAdminRole
*/
modifier onlyPauseAdmin() {
_onlyRole(pauseAdminRole(), msg.sender);
_;
}
/**
* @dev upgradeable pattern contract`s initializer
* @param _accessControl MidasAccessControl contract address
*/
// solhint-disable-next-line func-name-mixedcase
function __Pausable_init(address _accessControl) internal onlyInitializing {
super.__Pausable_init();
__WithMidasAccessControl_init(_accessControl);
}
function pause() external onlyPauseAdmin {
_pause();
}
function unpause() external onlyPauseAdmin {
_unpause();
}
/**
* @dev pause specific function
* @param fn function id
*/
function pauseFn(bytes4 fn) external onlyPauseAdmin {
require(!fnPaused[fn], "Pausable: fn paused");
fnPaused[fn] = true;
emit PauseFn(msg.sender, fn);
}
/**
* @dev unpause specific function
* @param fn function id
*/
function unpauseFn(bytes4 fn) external onlyPauseAdmin {
require(fnPaused[fn], "Pausable: fn unpaused");
fnPaused[fn] = false;
emit UnpauseFn(msg.sender, fn);
}
/**
* @dev virtual function to determine pauseAdmin role
*/
function pauseAdminRole() public view virtual returns (bytes32);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import "./MidasAccessControl.sol";
import "../abstract/MidasInitializable.sol";
/**
* @title WithMidasAccessControl
* @notice Base contract that consumes MidasAccessControl
* @author RedDuck Software
*/
abstract contract WithMidasAccessControl is
MidasInitializable,
MidasAccessControlRoles
{
/**
* @notice admin role
*/
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @notice MidasAccessControl contract address
*/
MidasAccessControl public accessControl;
/**
* @dev leaving a storage gap for futures updates
*/
uint256[50] private __gap;
/**
* @dev checks that given `address` have `role`
*/
modifier onlyRole(bytes32 role, address account) {
_onlyRole(role, account);
_;
}
/**
* @dev checks that given `address` do not have `role`
*/
modifier onlyNotRole(bytes32 role, address account) {
_onlyNotRole(role, account);
_;
}
/**
* @dev upgradeable pattern contract`s initializer
*/
// solhint-disable func-name-mixedcase
function __WithMidasAccessControl_init(address _accessControl)
internal
onlyInitializing
{
require(_accessControl != address(0), "zero address");
accessControl = MidasAccessControl(_accessControl);
}
/**
* @dev checks that given `address` have `role`
*/
function _onlyRole(bytes32 role, address account) internal view {
require(accessControl.hasRole(role, account), "WMAC: hasnt role");
}
/**
* @dev checks that given `address` do not have `role`
*/
function _onlyNotRole(bytes32 role, address account) internal view {
require(!accessControl.hasRole(role, account), "WMAC: has role");
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import {IERC20Upgradeable as IERC20} from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import {IERC20MetadataUpgradeable as IERC20Metadata} from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol";
import {Counters} from "@openzeppelin/contracts/utils/Counters.sol";
import "./interfaces/IDepositVault.sol";
import "./interfaces/IMTbill.sol";
import "./interfaces/IDataFeed.sol";
import "./abstract/ManageableVault.sol";
/**
* @title DepositVault
* @notice Smart contract that handles mTBILL minting
* @author RedDuck Software
*/
contract DepositVault is ManageableVault, IDepositVault {
using Counters for Counters.Counter;
/**
* @notice minimal USD amount for first user`s deposit
*/
uint256 public minMTokenAmountForFirstDeposit;
/**
* @notice mapping, requestId => request data
*/
mapping(uint256 => Request) public mintRequests;
/**
* @dev depositor address => amount minted
*/
mapping(address => uint256) public totalMinted;
/**
* @dev leaving a storage gap for futures updates
*/
uint256[50] private __gap;
/**
* @notice upgradeable pattern contract`s initializer
* @param _ac address of MidasAccessControll contract
* @param _mTokenInitParams init params for mToken
* @param _receiversInitParams init params for receivers
* @param _instantInitParams init params for instant operations
* @param _sanctionsList address of sanctionsList contract
* @param _variationTolerance percent of prices diviation 1% = 100
* @param _minAmount basic min amount for operations in mToken
* @param _minMTokenAmountForFirstDeposit min amount for first deposit in mToken
*/
function initialize(
address _ac,
MTokenInitParams calldata _mTokenInitParams,
ReceiversInitParams calldata _receiversInitParams,
InstantInitParams calldata _instantInitParams,
address _sanctionsList,
uint256 _variationTolerance,
uint256 _minAmount,
uint256 _minMTokenAmountForFirstDeposit
) external initializer {
__ManageableVault_init(
_ac,
_mTokenInitParams,
_receiversInitParams,
_instantInitParams,
_sanctionsList,
_variationTolerance,
_minAmount
);
minMTokenAmountForFirstDeposit = _minMTokenAmountForFirstDeposit;
}
/**
* @inheritdoc IDepositVault
*/
function depositInstant(
address tokenIn,
uint256 amountToken,
uint256 minReceiveAmount,
bytes32 referrerId
)
external
whenFnNotPaused(this.depositInstant.selector)
onlyGreenlisted(msg.sender)
onlyNotBlacklisted(msg.sender)
onlyNotSanctioned(msg.sender)
{
address user = msg.sender;
address tokenInCopy = tokenIn;
uint256 amountTokenCopy = amountToken;
(
uint256 tokenAmountInUsd,
uint256 feeTokenAmount,
uint256 amountTokenWithoutFee,
uint256 mintAmount,
,
,
uint256 tokenDecimals
) = _calcAndValidateDeposit(user, tokenInCopy, amountTokenCopy, true);
require(
mintAmount >= minReceiveAmount,
"DV: minReceiveAmount > actual"
);
totalMinted[user] += mintAmount;
_requireAndUpdateLimit(mintAmount);
_tokenTransferFromUser(
tokenInCopy,
tokensReceiver,
amountTokenWithoutFee,
tokenDecimals
);
if (feeTokenAmount > 0)
_tokenTransferFromUser(
tokenInCopy,
feeReceiver,
feeTokenAmount,
tokenDecimals
);
mToken.mint(user, mintAmount);
bytes32 referrerIdCopy = referrerId;
emit DepositInstant(
user,
tokenInCopy,
tokenAmountInUsd,
amountTokenCopy,
feeTokenAmount,
mintAmount,
referrerIdCopy
);
}
/**
* @inheritdoc IDepositVault
*/
function depositRequest(
address tokenIn,
uint256 amountToken,
bytes32 referrerId
)
external
whenFnNotPaused(this.depositRequest.selector)
onlyGreenlisted(msg.sender)
onlyNotBlacklisted(msg.sender)
onlyNotSanctioned(msg.sender)
returns (uint256 requestId)
{
address user = msg.sender;
address tokenInCopy = tokenIn;
uint256 amountTokenCopy = amountToken;
bytes32 referrerIdCopy = referrerId;
uint256 currentId = currentRequestId.current();
requestId = currentId;
currentRequestId.increment();
(
uint256 tokenAmountInUsd,
uint256 feeAmount,
uint256 amountTokenWithoutFee,
,
uint256 tokenInRate,
uint256 tokenOutRate,
uint256 tokenDecimals
) = _calcAndValidateDeposit(user, tokenInCopy, amountTokenCopy, false);
_tokenTransferFromUser(
tokenInCopy,
tokensReceiver,
amountTokenWithoutFee,
tokenDecimals
);
if (feeAmount > 0)
_tokenTransferFromUser(
tokenInCopy,
feeReceiver,
feeAmount,
tokenDecimals
);
mintRequests[currentId] = Request({
sender: user,
tokenIn: tokenInCopy,
status: RequestStatus.Pending,
depositedUsdAmount: tokenAmountInUsd,
usdAmountWithoutFees: (amountTokenWithoutFee * tokenInRate) /
10**18,
tokenOutRate: tokenOutRate
});
emit DepositRequest(
currentId,
user,
tokenInCopy,
amountTokenCopy,
tokenAmountInUsd,
feeAmount,
tokenOutRate,
referrerIdCopy
);
}
/**
* @inheritdoc IDepositVault
*/
function safeApproveRequest(uint256 requestId, uint256 newOutRate)
external
onlyVaultAdmin
{
_approveRequest(requestId, newOutRate, true);
emit SafeApproveRequest(requestId, newOutRate);
}
/**
* @inheritdoc IDepositVault
*/
function approveRequest(uint256 requestId, uint256 newOutRate)
external
onlyVaultAdmin
{
_approveRequest(requestId, newOutRate, false);
emit ApproveRequest(requestId, newOutRate);
}
/**
* @inheritdoc IDepositVault
*/
function rejectRequest(uint256 requestId) external onlyVaultAdmin {
Request memory request = mintRequests[requestId];
require(request.sender != address(0), "DV: request not exist");
require(
request.status == RequestStatus.Pending,
"DV: request not pending"
);
mintRequests[requestId].status = RequestStatus.Canceled;
emit RejectRequest(requestId, request.sender);
}
/**
* @inheritdoc IDepositVault
*/
function setMinMTokenAmountForFirstDeposit(uint256 newValue)
external
onlyVaultAdmin
{
minMTokenAmountForFirstDeposit = newValue;
emit SetMinMTokenAmountForFirstDeposit(msg.sender, newValue);
}
/**
* @inheritdoc ManageableVault
*/
function vaultRole() public pure virtual override returns (bytes32) {
return DEPOSIT_VAULT_ADMIN_ROLE;
}
/**
* @dev validates that inputted USD amount >= minAmountToDepositInUsd()
* and amount >= minAmount()
* @param user user address
* @param amountMTokenWithoutFee amount of mToken without fee (decimals 18)
*/
function _validateMinAmount(address user, uint256 amountMTokenWithoutFee)
internal
view
{
require(amountMTokenWithoutFee >= minAmount, "DV: mToken amount < min");
if (totalMinted[user] != 0) return;
require(
amountMTokenWithoutFee >= minMTokenAmountForFirstDeposit,
"DV: mint amount < min"
);
}
/**
* @dev approving request
* Checks price diviation if safe
* Mints mTokens to user
* @param requestId request id
* @param newOutRate mToken rate
*/
function _approveRequest(
uint256 requestId,
uint256 newOutRate,
bool isSafe
) private {
Request memory request = mintRequests[requestId];
require(request.sender != address(0), "DV: request not exist");
require(
request.status == RequestStatus.Pending,
"DV: request not pending"
);
if (isSafe)
_requireVariationTolerance(request.tokenOutRate, newOutRate);
uint256 amountMToken = (request.usdAmountWithoutFees * (10**18)) /
newOutRate;
mToken.mint(request.sender, amountMToken);
totalMinted[request.sender] += amountMToken;
request.status = RequestStatus.Processed;
request.tokenOutRate = newOutRate;
mintRequests[requestId] = request;
}
/**
* @dev validate deposit and calculate mint amount
* @param user user address
* @param tokenIn tokenIn address
* @param amountToken tokenIn amount (decimals 18)
* @param isInstant is instant operation
*
* @return tokenAmountInUsd tokenIn amount converted to USD
* @return feeTokenAmount fee amount in tokenIn
* @return amountTokenWithoutFee tokenIn amount without fee
* @return mintAmount mToken amount for mint
* @return tokenInRate tokenIn rate
* @return tokenOutRate mToken rate
* @return tokenDecimals tokenIn decimals
*/
function _calcAndValidateDeposit(
address user,
address tokenIn,
uint256 amountToken,
bool isInstant
)
internal
returns (
uint256 tokenAmountInUsd,
uint256 feeTokenAmount,
uint256 amountTokenWithoutFee,
uint256 mintAmount,
uint256 tokenInRate,
uint256 tokenOutRate,
uint256 tokenDecimals
)
{
require(amountToken > 0, "DV: invalid amount");
tokenDecimals = _tokenDecimals(tokenIn);
_requireTokenExists(tokenIn);
(uint256 amountInUsd, uint256 tokenInUSDRate) = _convertTokenToUsd(
tokenIn,
amountToken
);
tokenAmountInUsd = amountInUsd;
tokenInRate = tokenInUSDRate;
address userCopy = user;
_requireAndUpdateAllowance(tokenIn, amountToken);
feeTokenAmount = _truncate(
_getFeeAmount(userCopy, tokenIn, amountToken, isInstant, 0),
tokenDecimals
);
amountTokenWithoutFee = amountToken - feeTokenAmount;
uint256 feeInUsd = (feeTokenAmount * tokenInRate) / 10**18;
(uint256 mTokenAmount, uint256 mTokenRate) = _convertUsdToMToken(
tokenAmountInUsd - feeInUsd
);
mintAmount = mTokenAmount;
tokenOutRate = mTokenRate;
if (!isFreeFromMinAmount[userCopy]) {
_validateMinAmount(userCopy, mintAmount);
}
require(mintAmount > 0, "DV: invalid mint amount");
}
/**
* @dev calculates USD amount from tokenIn amount
* @param tokenIn tokenIn address
* @param amount amount of tokenIn (decimals 18)
*
* @return amountInUsd converted amount to USD
* @return rate conversion rate
*/
function _convertTokenToUsd(address tokenIn, uint256 amount)
internal
view
virtual
returns (uint256 amountInUsd, uint256 rate)
{
require(amount > 0, "DV: amount zero");
TokenConfig storage tokenConfig = tokensConfig[tokenIn];
rate = _getTokenRate(tokenConfig.dataFeed, tokenConfig.stable);
require(rate > 0, "DV: rate zero");
amountInUsd = (amount * rate) / (10**18);
}
/**
* @dev calculates mToken amount from USD amount
* @param amountUsd amount of USD (decimals 18)
*
* @return amountMToken converted USD to mToken
* @return mTokenRate conversion rate
*/
function _convertUsdToMToken(uint256 amountUsd)
internal
view
virtual
returns (uint256 amountMToken, uint256 mTokenRate)
{
mTokenRate = _getTokenRate(address(mTokenDataFeed), false);
require(mTokenRate > 0, "DV: rate zero");
amountMToken = (amountUsd * (10**18)) / mTokenRate;
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20PausableUpgradeable.sol";
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
import "../access/WithMidasAccessControl.sol";
import "../libraries/DecimalsCorrectionLibrary.sol";
/**
* @title IDataFeed
* @author RedDuck Software
*/
interface IDataFeed {
/**
* @notice upgradeable pattern contract`s initializer
* @param _ac MidasAccessControl contract address
* @param _aggregator AggregatorV3Interface contract address
* @param _healthyDiff max. staleness time for data feed answers
* @param _minExpectedAnswer min.expected answer value from data feed
* @param _maxExpectedAnswer max.expected answer value from data feed
*/
function initialize(
address _ac,
address _aggregator,
uint256 _healthyDiff,
int256 _minExpectedAnswer,
int256 _maxExpectedAnswer
) external;
/**
* @notice updates `aggregator` address
* @param _aggregator new AggregatorV3Interface contract address
*/
function changeAggregator(address _aggregator) external;
/**
* @notice fetches answer from aggregator
* and converts it to the base18 precision
* @return answer fetched aggregator answer
*/
function getDataInBase18() external view returns (uint256 answer);
/**
* @dev describes a role, owner of which can manage this feed
* @return role descriptor
*/
function feedAdminRole() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import "./IManageableVault.sol";
/**
* @notice Mint request scruct
* @param sender user address who create
* @param tokenIn tokenIn address
* @param status request status
* @param depositedUsdAmount amout USD, tokenIn -> USD
* @param usdAmountWithoutFees amout USD, tokenIn - fees -> USD
* @param tokenOutRate rate of mToken at request creation time
*/
struct Request {
address sender;
address tokenIn;
RequestStatus status;
uint256 depositedUsdAmount;
uint256 usdAmountWithoutFees;
uint256 tokenOutRate;
}
/**
* @title IDepositVault
* @author RedDuck Software
*/
interface IDepositVault is IManageableVault {
/**
* @param caller function caller (msg.sender)
* @param newValue new min amount to deposit value
*/
event SetMinMTokenAmountForFirstDeposit(
address indexed caller,
uint256 newValue
);
/**
* @param user function caller (msg.sender)
* @param tokenIn address of tokenIn
* @param amountUsd amount of tokenIn converted to USD
* @param amountToken amount of tokenIn
* @param fee fee amount in tokenIn
* @param minted amount of minted mTokens
* @param referrerId referrer id
*/
event DepositInstant(
address indexed user,
address indexed tokenIn,
uint256 amountUsd,
uint256 amountToken,
uint256 fee,
uint256 minted,
bytes32 referrerId
);
/**
* @param requestId mint request id
* @param user function caller (msg.sender)
* @param tokenIn address of tokenIn
* @param amountToken amount of tokenIn
* @param amountUsd amount of tokenIn converted to USD
* @param fee fee amount in tokenIn
* @param tokenOutRate mToken rate
* @param referrerId referrer id
*/
event DepositRequest(
uint256 indexed requestId,
address indexed user,
address indexed tokenIn,
uint256 amountToken,
uint256 amountUsd,
uint256 fee,
uint256 tokenOutRate,
bytes32 referrerId
);
/**
* @param requestId mint request id
* @param newOutRate mToken rate inputted by admin
*/
event ApproveRequest(uint256 indexed requestId, uint256 newOutRate);
/**
* @param requestId mint request id
* @param newOutRate mToken rate inputted by admin
*/
event SafeApproveRequest(uint256 indexed requestId, uint256 newOutRate);
/**
* @param requestId mint request id
* @param user address of user
*/
event RejectRequest(uint256 indexed requestId, address indexed user);
/**
* @param user address that was freed from min deposit check
*/
event FreeFromMinDeposit(address indexed user);
/**
* @notice depositing proccess with auto mint if
* account fit daily limit and token allowance.
* Transfers token from the user.
* Transfers fee in tokenIn to feeReceiver.
* Mints mToken to user.
* @param tokenIn address of tokenIn
* @param amountToken amount of `tokenIn` that will be taken from user (decimals 18)
* @param minReceiveAmount minimum expected amount of mToken to receive (decimals 18)
* @param referrerId referrer id
*/
function depositInstant(
address tokenIn,
uint256 amountToken,
uint256 minReceiveAmount,
bytes32 referrerId
) external;
/**
* @notice depositing proccess with mint request creating if
* account fit token allowance.
* Transfers token from the user.
* Transfers fee in tokenIn to feeReceiver.
* Creates mint request.
* @param tokenIn address of tokenIn
* @param amountToken amount of `tokenIn` that will be taken from user (decimals 18)
* @param referrerId referrer id
* @return request id
*/
function depositRequest(
address tokenIn,
uint256 amountToken,
bytes32 referrerId
) external returns (uint256);
/**
* @notice approving request if inputted token rate fit price diviation percent
* Mints mToken to user.
* Sets request flag to Processed.
* @param requestId request id
* @param newOutRate mToken rate inputted by vault admin
*/
function safeApproveRequest(uint256 requestId, uint256 newOutRate) external;
/**
* @notice approving request without price diviation check
* Mints mToken to user.
* Sets request flag to Processed.
* @param requestId request id
* @param newOutRate mToken rate inputted by vault admin
*/
function approveRequest(uint256 requestId, uint256 newOutRate) external;
/**
* @notice rejecting request
* Sets request flag to Canceled.
* @param requestId request id
*/
function rejectRequest(uint256 requestId) external;
/**
* @notice sets new minimal amount to deposit in EUR.
* can be called only from vault`s admin
* @param newValue new min. deposit value
*/
function setMinMTokenAmountForFirstDeposit(uint256 newValue) external;
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import "./IMTbill.sol";
import "./IDataFeed.sol";
/**
* @param dataFeed data feed token/USD address
* @param fee fee by token, 1% = 100
* @param allowance token allowance (decimals 18)
*/
struct TokenConfig {
address dataFeed;
uint256 fee;
uint256 allowance;
bool stable;
}
enum RequestStatus {
Pending,
Processed,
Canceled
}
struct MTokenInitParams {
address mToken;
address mTokenDataFeed;
}
struct ReceiversInitParams {
address tokensReceiver;
address feeReceiver;
}
struct InstantInitParams {
uint256 instantFee;
uint256 instantDailyLimit;
}
/**
* @title IManageableVault
* @author RedDuck Software
*/
interface IManageableVault {
/**
* @param caller function caller (msg.sender)
* @param token token that was withdrawn
* @param withdrawTo address to which tokens were withdrawn
* @param amount `token` transfer amount
*/
event WithdrawToken(
address indexed caller,
address indexed token,
address indexed withdrawTo,
uint256 amount
);
/**
* @param caller function caller (msg.sender)
* @param token address of token that
* @param dataFeed token dataFeed address
* @param fee fee 1% = 100
* @param stable stablecoin flag
*/
event AddPaymentToken(
address indexed caller,
address indexed token,
address indexed dataFeed,
uint256 fee,
bool stable
);
/**
* @param token address of token that
* @param caller function caller (msg.sender)
* @param allowance new allowance
*/
event ChangeTokenAllowance(
address indexed token,
address indexed caller,
uint256 allowance
);
/**
* @param token address of token that
* @param caller function caller (msg.sender)
* @param fee new fee
*/
event ChangeTokenFee(
address indexed token,
address indexed caller,
uint256 fee
);
/**
* @param token address of token that
* @param caller function caller (msg.sender)
*/
event RemovePaymentToken(address indexed token, address indexed caller);
/**
* @param account address of account
* @param caller function caller (msg.sender)
*/
event AddWaivedFeeAccount(address indexed account, address indexed caller);
/**
* @param account address of account
* @param caller function caller (msg.sender)
*/
event RemoveWaivedFeeAccount(
address indexed account,
address indexed caller
);
/**
* @param caller function caller (msg.sender)
* @param newFee new operation fee value
*/
event SetInstantFee(address indexed caller, uint256 newFee);
/**
* @param caller function caller (msg.sender)
* @param newAmount new min amount for operation
*/
event SetMinAmount(address indexed caller, uint256 newAmount);
/**
* @param caller function caller (msg.sender)
* @param newLimit new operation daily limit
*/
event SetInstantDailyLimit(address indexed caller, uint256 newLimit);
/**
* @param caller function caller (msg.sender)
* @param newTolerance percent of price diviation 1% = 100
*/
event SetVariationTolerance(address indexed caller, uint256 newTolerance);
/**
* @param caller function caller (msg.sender)
* @param reciever new reciever address
*/
event SetFeeReceiver(address indexed caller, address indexed reciever);
/**
* @param caller function caller (msg.sender)
* @param reciever new reciever address
*/
event SetTokensReceiver(address indexed caller, address indexed reciever);
/**
* @param user user address
* @param enable is enabled
*/
event FreeFromMinAmount(address indexed user, bool enable);
/**
* @notice The mTokenDataFeed contract address.
* @return The address of the mTokenDataFeed contract.
*/
function mTokenDataFeed() external view returns (IDataFeed);
/**
* @notice The mToken contract address.
* @return The address of the mToken contract.
*/
function mToken() external view returns (IMTbill);
/**
* @notice withdraws `amount` of a given `token` from the contract.
* can be called only from permissioned actor.
* @param token token address
* @param amount token amount
* @param withdrawTo withdraw destination address
*/
function withdrawToken(
address token,
uint256 amount,
address withdrawTo
) external;
/**
* @notice adds a token to the stablecoins list.
* can be called only from permissioned actor.
* @param token token address
* @param dataFeed dataFeed address
* @param fee 1% = 100
* @param stable is stablecoin flag
*/
function addPaymentToken(
address token,
address dataFeed,
uint256 fee,
bool stable
) external;
/**
* @notice removes a token from stablecoins list.
* can be called only from permissioned actor.
* @param token token address
*/
function removePaymentToken(address token) external;
/**
* @notice set new token allowance.
* if MAX_UINT = infinite allowance
* prev allowance rewrites by new
* can be called only from permissioned actor.
* @param token token address
* @param allowance new allowance (decimals 18)
*/
function changeTokenAllowance(address token, uint256 allowance) external;
/**
* @notice set new token fee.
* can be called only from permissioned actor.
* @param token token address
* @param fee new fee percent 1% = 100
*/
function changeTokenFee(address token, uint256 fee) external;
/**
* @notice set new prices diviation percent.
* can be called only from permissioned actor.
* @param tolerance new prices diviation percent 1% = 100
*/
function setVariationTolerance(uint256 tolerance) external;
/**
* @notice set new min amount.
* can be called only from permissioned actor.
* @param newAmount min amount for operations in mToken
*/
function setMinAmount(uint256 newAmount) external;
/**
* @notice adds a account to waived fee restriction.
* can be called only from permissioned actor.
* @param account user address
*/
function addWaivedFeeAccount(address account) external;
/**
* @notice removes a account from waived fee restriction.
* can be called only from permissioned actor.
* @param account user address
*/
function removeWaivedFeeAccount(address account) external;
/**
* @notice set new reciever for fees.
* can be called only from permissioned actor.
* @param reciever new fee reciever address
*/
function setFeeReceiver(address reciever) external;
/**
* @notice set new reciever for tokens.
* can be called only from permissioned actor.
* @param reciever new token reciever address
*/
function setTokensReceiver(address reciever) external;
/**
* @notice set operation fee percent.
* can be called only from permissioned actor.
* @param newInstantFee new instant operations fee percent 1& = 100
*/
function setInstantFee(uint256 newInstantFee) external;
/**
* @notice set operation daily limit.
* can be called only from permissioned actor.
* @param newInstantDailyLimit new operation daily limit (decimals 18)
*/
function setInstantDailyLimit(uint256 newInstantDailyLimit) external;
/**
* @notice frees given `user` from the minimal deposit
* amount validation in `initiateDepositRequest`
* @param user address of user
*/
function freeFromMinAmount(address user, bool enable) external;
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
/**
* @title IMTbill
* @author RedDuck Software
*/
interface IMTbill is IERC20Upgradeable {
/**
* @notice mints mTBILL token `amount` to a given `to` address.
* should be called only from permissioned actor
* @param to addres to mint tokens to
* @param amount amount to mint
*/
function mint(address to, uint256 amount) external;
/**
* @notice burns mTBILL token `amount` to a given `to` address.
* should be called only from permissioned actor
* @param from addres to burn tokens from
* @param amount amount to burn
*/
function burn(address from, uint256 amount) external;
/**
* @notice updates contract`s metadata.
* should be called only from permissioned actor
* @param key metadata map. key
* @param data metadata map. value
*/
function setMetadata(bytes32 key, bytes memory data) external;
/**
* @notice puts mTBILL token on pause.
* should be called only from permissioned actor
*/
function pause() external;
/**
* @notice puts mTBILL token on pause.
* should be called only from permissioned actor
*/
function unpause() external;
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
// TODO: add natspec
interface ISanctionsList {
function isSanctioned(address addr) external view returns (bool);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
/**
* @title DecimalsCorrectionLibrary
* @author RedDuck Software
*/
library DecimalsCorrectionLibrary {
/**
* @dev converts `originalAmount` with `originalDecimals` into
* amount with `decidedDecimals`
* @param originalAmount amount to convert
* @param originalDecimals decimals of the original amount
* @param decidedDecimals decimals for the output amount
* @return amount converted amount with `decidedDecimals`
*/
function convert(
uint256 originalAmount,
uint256 originalDecimals,
uint256 decidedDecimals
) internal pure returns (uint256) {
if (originalAmount == 0) return 0;
if (originalDecimals == decidedDecimals) return originalAmount;
uint256 adjustedAmount;
if (originalDecimals > decidedDecimals) {
adjustedAmount =
originalAmount /
(10**(originalDecimals - decidedDecimals));
} else {
adjustedAmount =
originalAmount *
(10**(decidedDecimals - originalDecimals));
}
return adjustedAmount;
}
/**
* @dev converts `originalAmount` with decimals 18 into
* amount with `decidedDecimals`
* @param originalAmount amount to convert
* @param decidedDecimals decimals for the output amount
* @return amount converted amount with `decidedDecimals`
*/
function convertFromBase18(uint256 originalAmount, uint256 decidedDecimals)
internal
pure
returns (uint256)
{
return convert(originalAmount, 18, decidedDecimals);
}
/**
* @dev converts `originalAmount` with `originalDecimals` into
* amount with decimals 18
* @param originalAmount amount to convert
* @param originalDecimals decimals of the original amount
* @return amount converted amount with 18 decimals
*/
function convertToBase18(uint256 originalAmount, uint256 originalDecimals)
internal
pure
returns (uint256)
{
return convert(originalAmount, originalDecimals, 18);
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
/**
* @title TEthMidasAccessControlRoles
* @notice Base contract that stores all roles descriptors for tETH contracts
* @author RedDuck Software
*/
abstract contract TEthMidasAccessControlRoles {
/**
* @notice actor that can manage TEthDepositVault
*/
bytes32 public constant T_ETH_DEPOSIT_VAULT_ADMIN_ROLE =
keccak256("T_ETH_DEPOSIT_VAULT_ADMIN_ROLE");
/**
* @notice actor that can manage TEthRedemptionVault
*/
bytes32 public constant T_ETH_REDEMPTION_VAULT_ADMIN_ROLE =
keccak256("T_ETH_REDEMPTION_VAULT_ADMIN_ROLE");
/**
* @notice actor that can manage TEthCustomAggregatorFeed and TEthDataFeed
*/
bytes32 public constant T_ETH_CUSTOM_AGGREGATOR_FEED_ADMIN_ROLE =
keccak256("T_ETH_CUSTOM_AGGREGATOR_FEED_ADMIN_ROLE");
}{
"optimizer": {
"enabled": true,
"runs": 200
},
"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[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"dataFeed","type":"address"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"},{"indexed":false,"internalType":"bool","name":"stable","type":"bool"}],"name":"AddPaymentToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"caller","type":"address"}],"name":"AddWaivedFeeAccount","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"requestId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newOutRate","type":"uint256"}],"name":"ApproveRequest","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"uint256","name":"allowance","type":"uint256"}],"name":"ChangeTokenAllowance","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"ChangeTokenFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"tokenIn","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountUsd","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountToken","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"minted","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"referrerId","type":"bytes32"}],"name":"DepositInstant","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"requestId","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"tokenIn","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountToken","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountUsd","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokenOutRate","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"referrerId","type":"bytes32"}],"name":"DepositRequest","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"bool","name":"enable","type":"bool"}],"name":"FreeFromMinAmount","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"FreeFromMinDeposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"bytes4","name":"fn","type":"bytes4"}],"name":"PauseFn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"requestId","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"RejectRequest","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"caller","type":"address"}],"name":"RemovePaymentToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"caller","type":"address"}],"name":"RemoveWaivedFeeAccount","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"requestId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newOutRate","type":"uint256"}],"name":"SafeApproveRequest","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"reciever","type":"address"}],"name":"SetFeeReceiver","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"bool","name":"enable","type":"bool"}],"name":"SetGreenlistEnable","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"uint256","name":"newLimit","type":"uint256"}],"name":"SetInstantDailyLimit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"uint256","name":"newFee","type":"uint256"}],"name":"SetInstantFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"uint256","name":"newAmount","type":"uint256"}],"name":"SetMinAmount","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"uint256","name":"newValue","type":"uint256"}],"name":"SetMinMTokenAmountForFirstDeposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"newSanctionsList","type":"address"}],"name":"SetSanctionsList","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"reciever","type":"address"}],"name":"SetTokensReceiver","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"uint256","name":"newTolerance","type":"uint256"}],"name":"SetVariationTolerance","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"bytes4","name":"fn","type":"bytes4"}],"name":"UnpauseFn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"withdrawTo","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawToken","type":"event"},{"inputs":[],"name":"BLACKLISTED_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"BLACKLIST_OPERATOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEPOSIT_VAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"GREENLISTED_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"GREENLIST_OPERATOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"GREENLIST_TOGGLER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MANUAL_FULLFILMENT_TOKEN","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_UINT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"M_TBILL_BURN_OPERATOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"M_TBILL_MINT_OPERATOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"M_TBILL_PAUSE_OPERATOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ONE_HUNDRED_PERCENT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"REDEMPTION_VAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"STABLECOIN_RATE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"T_ETH_CUSTOM_AGGREGATOR_FEED_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"T_ETH_DEPOSIT_VAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"T_ETH_REDEMPTION_VAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"accessControl","outputs":[{"internalType":"contract MidasAccessControl","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"dataFeed","type":"address"},{"internalType":"uint256","name":"tokenFee","type":"uint256"},{"internalType":"bool","name":"stable","type":"bool"}],"name":"addPaymentToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"addWaivedFeeAccount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"},{"internalType":"uint256","name":"newOutRate","type":"uint256"}],"name":"approveRequest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"allowance","type":"uint256"}],"name":"changeTokenAllowance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"fee","type":"uint256"}],"name":"changeTokenFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"currentRequestId","outputs":[{"internalType":"uint256","name":"_value","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"dailyLimits","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"uint256","name":"amountToken","type":"uint256"},{"internalType":"uint256","name":"minReceiveAmount","type":"uint256"},{"internalType":"bytes32","name":"referrerId","type":"bytes32"}],"name":"depositInstant","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"uint256","name":"amountToken","type":"uint256"},{"internalType":"bytes32","name":"referrerId","type":"bytes32"}],"name":"depositRequest","outputs":[{"internalType":"uint256","name":"requestId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feeReceiver","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"name":"fnPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"bool","name":"enable","type":"bool"}],"name":"freeFromMinAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getPaymentTokens","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"greenlistEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"greenlistTogglerRole","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"greenlistedRole","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_ac","type":"address"},{"components":[{"internalType":"address","name":"mToken","type":"address"},{"internalType":"address","name":"mTokenDataFeed","type":"address"}],"internalType":"struct MTokenInitParams","name":"_mTokenInitParams","type":"tuple"},{"components":[{"internalType":"address","name":"tokensReceiver","type":"address"},{"internalType":"address","name":"feeReceiver","type":"address"}],"internalType":"struct ReceiversInitParams","name":"_receiversInitParams","type":"tuple"},{"components":[{"internalType":"uint256","name":"instantFee","type":"uint256"},{"internalType":"uint256","name":"instantDailyLimit","type":"uint256"}],"internalType":"struct InstantInitParams","name":"_instantInitParams","type":"tuple"},{"internalType":"address","name":"_sanctionsList","type":"address"},{"internalType":"uint256","name":"_variationTolerance","type":"uint256"},{"internalType":"uint256","name":"_minAmount","type":"uint256"},{"internalType":"uint256","name":"_minMTokenAmountForFirstDeposit","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"instantDailyLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"instantFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isFreeFromMinAmount","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mToken","outputs":[{"internalType":"contract IMTbill","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mTokenDataFeed","outputs":[{"internalType":"contract IDataFeed","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minMTokenAmountForFirstDeposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"mintRequests","outputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"enum RequestStatus","name":"status","type":"uint8"},{"internalType":"uint256","name":"depositedUsdAmount","type":"uint256"},{"internalType":"uint256","name":"usdAmountWithoutFees","type":"uint256"},{"internalType":"uint256","name":"tokenOutRate","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pauseAdminRole","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"fn","type":"bytes4"}],"name":"pauseFn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"}],"name":"rejectRequest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"removePaymentToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"removeWaivedFeeAccount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"},{"internalType":"uint256","name":"newOutRate","type":"uint256"}],"name":"safeApproveRequest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sanctionsList","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"sanctionsListAdminRole","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"setFeeReceiver","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"enable","type":"bool"}],"name":"setGreenlistEnable","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newInstantDailyLimit","type":"uint256"}],"name":"setInstantDailyLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newInstantFee","type":"uint256"}],"name":"setInstantFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newAmount","type":"uint256"}],"name":"setMinAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newValue","type":"uint256"}],"name":"setMinMTokenAmountForFirstDeposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newSanctionsList","type":"address"}],"name":"setSanctionsList","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"setTokensReceiver","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tolerance","type":"uint256"}],"name":"setVariationTolerance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tokensConfig","outputs":[{"internalType":"address","name":"dataFeed","type":"address"},{"internalType":"uint256","name":"fee","type":"uint256"},{"internalType":"uint256","name":"allowance","type":"uint256"},{"internalType":"bool","name":"stable","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokensReceiver","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"totalMinted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"fn","type":"bytes4"}],"name":"unpauseFn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"variationTolerance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vaultRole","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"waivedFeeRestriction","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"withdrawTo","type":"address"}],"name":"withdrawToken","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
60806040523480156200001157600080fd5b506200001c62000022565b620000e3565b600054610100900460ff16156200008f5760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff90811614620000e1576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b613e8380620000f36000396000f3fe608060405234801561001057600080fd5b50600436106104265760003560e01c80637192de4b1161022b578063c3b6f93911610130578063db74d8b5116100b8578063e5b5019a11610087578063e5b5019a14610ae5578063eaf896fd14610aee578063ec571c6a14610af6578063efdcd97414610b0a578063fe011e5f14610b1d57600080fd5b8063db74d8b514610a8f578063dd0081c714610aa2578063e2c4d73714610aab578063e428877e14610ad257600080fd5b8063cabccc7f116100ff578063cabccc7f14610a32578063cbc3dd8d14610a3a578063d63567a514610a61578063d7fd2bae14610a6b578063daddcb1614610a3257600080fd5b8063c3b6f939146109ec578063c47d51be14610a00578063c64b639114610a0a578063ca5e553e14610a1d57600080fd5b80639c8e5ef1116101b3578063b3f0067411610182578063b3f0067414610909578063bbae40861461091d578063bc63773f14610943578063bc979af61461096a578063c02dd27a146109d957600080fd5b80639c8e5ef1146108c8578063a217fddf146108db578063a5125421146108e3578063ad9e5649146108f657600080fd5b8063897b0637116101fa578063897b0637146108815780638a0ae61514610894578063978ff560146108a75780639af40265146108b65780639b2cb5d8146108be57600080fd5b80637192de4b146108355780638456cb591461083f57806388a6de68146108475780638978ac451461085a57600080fd5b80633807be7d116103315780635300b4ba116102b95780636254afb6116102885780636254afb6146107b357806362b199c5146107c75780636957463a146107ee5780636dc69e03146108015780636e26b9f81461082257600080fd5b80635300b4ba1461074f5780635ae2bfdb146107765780635c975abb14610781578063603481561461078c57600080fd5b80633f4ba83a116103005780633f4ba83a14610694578063409853231461069c578063424e6575146106c3578063476abc761461072957806349dc5e8d1461073c57600080fd5b80633807be7d146106515780633972183c1461066457806339dac34d1461066e5780633ccdbb281461068157600080fd5b80631e022f4c116103b45780632c0a90a9116103835780632c0a90a9146105df5780632d7788db146105f257806332b30cce1461060557806334c244891461062b5780633733337d1461063e57600080fd5b80631e022f4c1461057e5780631ed41163146105915780631fa1e8d4146105b857806327abf518146105cc57600080fd5b8063105ed2b2116103fb578063105ed2b2146104dd57806313007d55146104ea578063138e139b1461051b57806315b9598a1461054257806316683aa51461056957600080fd5b80623d47901461042b578062eafebf1461045f578063042da5ee146104865780630b5a57bd146104ba575b600080fd5b61044c610439366004613802565b6101a56020526000908152604090205481565b6040519081526020015b60405180910390f35b61044c7fa402581169544bec3e7f4fdb6f22f3658bc2f7bad057fd353bca877dc365e4ee81565b6104aa610494366004613802565b61016b6020526000908152604090205460ff1681565b6040519015158152602001610456565b6104aa6104c836600461381d565b60976020526000908152604090205460ff1681565b60fc546104aa9060ff1681565b600054610503906201000090046001600160a01b031681565b6040516001600160a01b039091168152602001610456565b61044c7fed5678b978fd67f3777524a00f27c79e5552efeca1f047f9e805a5dc7c2dadff81565b61044c7f77c5b782690f31cd39b1abf2448215259a688a75920040c399d96a676bd1999d81565b61057c610577366004613802565b610b44565b005b61057c61058c366004613847565b610bff565b61044c7fd2576bd6a4c5558421de15cb8ecdf4eb3282aac06b94d4f004e8cd0d00f3ebd881565b61016554610503906001600160a01b031681565b61057c6105da36600461386e565b610c49565b61057c6105ed36600461388b565b610ce7565b61057c610600366004613847565b610d3c565b7fa28974a2ecc1bcbd5ca81af766b1ac289c6579162f91147085217b9df960144261044c565b61057c610639366004613847565b610ee1565b61057c61064c36600461381d565b610f2f565b61057c61065f36600461381d565b610fcb565b61044c6101675481565b61057c61067c3660046138ad565b61108b565b61057c61068f3660046138e4565b611152565b61057c6111cd565b61044c7f2728bd32a7e1e24afac41a073e9c92dbb65527c9ec3baa2a8d5ee1d06c0fa77981565b6107176106d1366004613847565b6101a460205260009081526040902080546001820154600283015460038401546004909401546001600160a01b039384169493831693600160a01b90930460ff16929086565b60405161045696959493929190613936565b61057c610737366004613802565b6111e2565b61057c61074a366004613802565b611245565b61044c7f2fdc6683bc8d03effec5b41d3834f28bd219e06ca0a6a26fc737e44b1c7889ff81565b6101625461044c9081565b60655460ff166104aa565b61044c7f82830251f95316fd2426de66b9298a230aae8afa718479a58eb92f667eaa8b2d81565b61016454610503906001600160a01b031681565b61044c7f548c7f0307ab2a7ea894e5c7e8c5353cc750bb9385ee2e945f189a9a83daa8ed81565b61057c6107fc366004613847565b61129d565b61044c61080f366004613847565b6101686020526000908152604090205481565b61044c61083036600461398f565b611321565b61044c61016a5481565b61057c611647565b61057c61085536600461388b565b61165a565b61044c7f3d63b8d5d9c57f3a193bc98b7ebe0c3f62ed0859cbe92c95839f2c4948a3bbff81565b61057c61088f366004613847565b6116a3565b61057c6108a23660046139c2565b6116e6565b61044c670de0b6b3a764000081565b610503600081565b61044c61016f5481565b61057c6108d6366004613a04565b6117ae565b61044c600081565b61057c6108f1366004613802565b6118d4565b61057c610904366004613847565b611993565b61016954610503906001600160a01b031681565b7fd2576bd6a4c5558421de15cb8ecdf4eb3282aac06b94d4f004e8cd0d00f3ebd861044c565b61044c7fa28974a2ecc1bcbd5ca81af766b1ac289c6579162f91147085217b9df960144281565b6109ad610978366004613802565b61016e6020526000908152604090208054600182015460028301546003909301546001600160a01b0390921692909160ff1684565b604080516001600160a01b03909516855260208501939093529183015215156060820152608001610456565b61057c6109e7366004613a8a565b6119e1565b61016354610503906001600160a01b031681565b61044c6101665481565b61057c610a18366004613ac3565b611ced565b610a25611e1a565b6040516104569190613b12565b61044c611e2c565b61044c7f15a9a8831d7e86b8cacded60e5295dd3f73e83a49069ee92480fc811440c5c3e81565b61044c6101a35481565b6104aa610a79366004613802565b6101706020526000908152604090205460ff1681565b61057c610a9d3660046139c2565b611e36565b61044c61271081565b61044c7f57df534b215589c7ade8c8abe0978debf2ea95cf1d442550f94eec78a69d238e81565b61057c610ae0366004613802565b611ea9565b61044c60001981565b61044c611f61565b61012f54610503906001600160a01b031681565b61057c610b18366004613802565b611f85565b61044c7f7bd1951470f20c89a15b10ee03824a5ddb66ad1f15509a43080312e5afb004b781565b610b55610b4f611f61565b33611fe8565b6001600160a01b038116600090815261016b602052604090205460ff16610bb35760405162461bcd60e51b815260206004820152600d60248201526c13558e881b9bdd08199bdd5b99609a1b60448201526064015b60405180910390fd5b6001600160a01b038116600081815261016b6020526040808220805460ff19169055513392917f57c4a95f59c12f0d4d846443c2d54c7d97f1505080199522fca2819e65213ca291a350565b610c0a610b4f611f61565b6101a381905560405181815233907ff0af3ac3dc311b130ec783d7ff5582ccf0923fa13c4688c5da387d4cc57d852d906020015b60405180910390a250565b610c52336120b6565b60fc5460ff1615158115151415610ca45760405162461bcd60e51b8152602060048201526016602482015275474c3a2073616d6520656e61626c652073746174757360501b6044820152606401610baa565b60fc805460ff191682151590811790915560405190815233907fa8434267b880129bc4ba30249aa4a2ac349e8997c699282a9f70562f0f152f5490602001610c3e565b610cf2610b4f611f61565b610cfe828260006120e8565b817ff7d1fde87f32720fc30ce6847e0aae77e640b59bfac41b11b270358ccfa7a0ac82604051610d3091815260200190565b60405180910390a25050565b610d47610b4f611f61565b60008181526101a460209081526040808320815160c08101835281546001600160a01b039081168252600183015490811694820194909452929091830190600160a01b900460ff166002811115610da057610da0613920565b6002811115610db157610db1613920565b8152600282015460208201526003820154604082015260049091015460609091015280519091506001600160a01b0316610e255760405162461bcd60e51b815260206004820152601560248201527411158e881c995c5d595cdd081b9bdd08195e1a5cdd605a1b6044820152606401610baa565b600081604001516002811115610e3d57610e3d613920565b14610e845760405162461bcd60e51b815260206004820152601760248201527644563a2072657175657374206e6f742070656e64696e6760481b6044820152606401610baa565b60008281526101a46020526040808220600101805460ff60a01b1916600160a11b179055825190516001600160a01b039091169184917ece63cc55966b103e4f4cb39f3426cb91718ad4f8eb4ad08c14a7ee749d81579190a35050565b610eec610b4f611f61565b610ef78160016123a2565b61016a81905560405181815233907f018be394ba93a0dbca235443cfdc7173b2479180ad766083ce05199fbf3fc62490602001610c3e565b610f3a610b4f611e2c565b6001600160e01b0319811660009081526097602052604090205460ff1615610f745760405162461bcd60e51b8152600401610baa90613b5f565b6001600160e01b03198116600081815260976020908152604091829020805460ff19166001179055905191825233917f2278e547293e53a66144c1743877f8388ac3101bd21cfd7c7f4ce8c15c14f5c19101610c3e565b610fd6610b4f611e2c565b6001600160e01b0319811660009081526097602052604090205460ff166110375760405162461bcd60e51b815260206004820152601560248201527414185d5cd8589b194e88199b881d5b9c185d5cd959605a1b6044820152606401610baa565b6001600160e01b03198116600081815260976020908152604091829020805460ff19169055905191825233917f929135cc6324f958693bb5f24a4dbc226a83c721523fc2785545019a3423b2d79101610c3e565b611096610b4f611f61565b6001600160a01b0382166000908152610170602052604090205460ff16151581151514156110f95760405162461bcd60e51b815260206004820152601060248201526f44563a20616c7265616479206672656560801b6044820152606401610baa565b6001600160a01b03821660008181526101706020908152604091829020805460ff191685151590811790915591519182527f80f6f2f8801c6ac8fc60bf218b44fde97744d8709f69281972ec5557c10226cc9101610d30565b61115d610b4f611f61565b6111716001600160a01b0384168284612422565b806001600160a01b0316836001600160a01b0316336001600160a01b03167f9ca7c1e047552a8048d924a5a8d3c150eb861086a72a9100e5f19d1176c1b746856040516111c091815260200190565b60405180910390a4505050565b6111d8610b4f611e2c565b6111e0612485565b565b6111ed610b4f611f61565b6111f88160016124d7565b61016580546001600160a01b0319166001600160a01b03831690811790915560405133907fdb5a411e1a379f981ff6bc5284aa2c2522a9b8fd33a9db9ca19b34006cefbe9c90600090a350565b611250610b4f611e2c565b61012f80546001600160a01b0319166001600160a01b03831690811790915560405133907f7f0c791852a03e270d4c2b78bbd4b959bca234de8d1ccf27eee03afaeafe63c490600090a350565b6112a8610b4f611f61565b600081116112e95760405162461bcd60e51b815260206004820152600e60248201526d4d563a206c696d6974207a65726f60901b6044820152606401610baa565b61016781905560405181815233907f5e8309fc6b2360e7438bc53790b00913395fffa870f39043fe63ddc8a438a9b290602001610c3e565b6000630dc4d73f60e31b61133361256d565b6001600160e01b0319811660009081526097602052604090205460ff161561136d5760405162461bcd60e51b8152600401610baa90613b5f565b60fc54339060ff161561138357611383816125b3565b3361138d816125d9565b61012f5433906001600160a01b0316801561145a5760405163df592f7d60e01b81526001600160a01b03838116600483015282169063df592f7d9060240160206040518083038186803b1580156113e357600080fd5b505afa1580156113f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061141b9190613b8c565b1561145a5760405162461bcd60e51b815260206004820152600f60248201526e15d4d30e881cd85b98dd1a5bdb9959608a1b6044820152606401610baa565b33898989600061146a6101625490565b9050809a5061147e61016280546001019055565b6000806000806000806114948b8b8b6000612605565b965096509650509550955095506114c38a61016560009054906101000a90046001600160a01b03168684612783565b84156114e357610169546114e3908b906001600160a01b03168784612783565b6040805160c0810182526001600160a01b03808e1682528c1660208201529081016000815260208101889052604001670de0b6b3a76400006115258688613bbf565b61152f9190613bde565b8152602090810184905260008981526101a48252604090819020835181546001600160a01b03199081166001600160a01b0392831617835593850151600183018054958616919092169081178255928501519193919290916001600160a81b03191617600160a01b8360028111156115a9576115a9613920565b02179055506060828101516002830155608080840151600384015560a093840151600490930192909255604080518d8152602081018b90529081018990529081018590529081018a90526001600160a01b03808d1692908e16918a917f3704c9b13a68ac43d7f8a85f2700f0b4f89a11ed9e2bcac5324f0d228d409009910160405180910390a4505050505050505050505050505050509392505050565b611652610b4f611e2c565b6111e06127fc565b611665610b4f611f61565b611671828260016120e8565b817f03ea09e71742c9c754c9746b3e671ecb27fc372e3d29c31bac0192458ffd9d4b82604051610d3091815260200190565b6116ae610b4f611f61565b61016f81905560405181815233907f57e764c1fef224e74706b109734513889970db6f1dde107b1bda66e10d80ca9b90602001610c3e565b6116f1610b4f611f61565b6001600160a01b038216156117095761170982612839565b6000811161174e5760405162461bcd60e51b81526020600482015260126024820152714d563a207a65726f20616c6c6f77616e636560701b6044820152606401610baa565b6001600160a01b038216600081815261016e602052604090819020600201839055513391907ff7273742887a46d8b97d83d1d12b6d8d8e6d21d814072369e2f4b355690221d7906117a29085815260200190565b60405180910390a35050565b600054610100900460ff16158080156117ce5750600054600160ff909116105b806117e85750303b1580156117e8575060005460ff166001145b61184b5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610baa565b6000805460ff19166001179055801561186e576000805461ff0019166101001790555b61187d8989898989898961288b565b6101a382905580156118c9576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050505050565b6118df610b4f611f61565b6118eb61016c82612a63565b6119285760405162461bcd60e51b815260206004820152600e60248201526d4d563a206e6f742065786973747360901b6044820152606401610baa565b6001600160a01b038116600081815261016e602052604080822080546001600160a01b03191681556001810183905560028101839055600301805460ff19169055513392917f652fa2f5d587d3f1c189df0081b7bf3121f47d51d5471bf58d7d2c8a084894c391a350565b61199e610b4f611f61565b6119a98160006123a2565b61016681905560405181815233907f45acc8bd6ebd6fbb59ce049b682c124aeccc93c468fcf60fecf61340e86e79d390602001610c3e565b636016e93d60e11b6119f161256d565b6001600160e01b0319811660009081526097602052604090205460ff1615611a2b5760405162461bcd60e51b8152600401610baa90613b5f565b60fc54339060ff1615611a4157611a41816125b3565b33611a4b816125d9565b61012f5433906001600160a01b03168015611b185760405163df592f7d60e01b81526001600160a01b03838116600483015282169063df592f7d9060240160206040518083038186803b158015611aa157600080fd5b505afa158015611ab5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ad99190613b8c565b15611b185760405162461bcd60e51b815260206004820152600f60248201526e15d4d30e881cd85b98dd1a5bdb9959608a1b6044820152606401610baa565b338989600080808080611b2e8888886001612605565b9650505094509450945094508e821015611b8a5760405162461bcd60e51b815260206004820152601d60248201527f44563a206d696e52656365697665416d6f756e74203e2061637475616c0000006044820152606401610baa565b6001600160a01b03881660009081526101a5602052604081208054849290611bb3908490613c00565b90915550611bc2905082612a81565b61016554611bdc9088906001600160a01b03168584612783565b8315611bfc5761016954611bfc9088906001600160a01b03168684612783565b610163546040516340c10f1960e01b81526001600160a01b038a8116600483015260248201859052909116906340c10f1990604401600060405180830381600087803b158015611c4b57600080fd5b505af1158015611c5f573d6000803e3d6000fd5b5050505060008e9050876001600160a01b0316896001600160a01b03167fdd6865ec496cf9bdd5cb1661ab84cf4e86edc877208a54cbf642f69d744530c5888a898887604051611cd1959493929190948552602085019390935260408401919091526060830152608082015260a00190565b60405180910390a3505050505050505050505050505050505050565b611cf8610b4f611f61565b611d0461016c85612b0b565b611d445760405162461bcd60e51b815260206004820152601160248201527013558e88185b1c9958591e481859191959607a1b6044820152606401610baa565b611d4f8360006124d7565b611d5a8260006123a2565b604080516080810182526001600160a01b038581168083526020808401878152600019858701908152871515606087018181528c8716600081815261016e87528a9020985189546001600160a01b0319169816979097178855925160018801559051600287015590516003909501805460ff19169515159590951790945584518781529081019390935292909133917f619139d13e799b88ce56bff114b5510808a19ea7440710070ef78528a05ed672910160405180910390a450505050565b6060611e2761016c612b20565b905090565b6000611e27611f61565b611e41610b4f611f61565b611e4a82612839565b611e558160006123a2565b6001600160a01b038216600081815261016e602052604090819020600101839055513391907f1582567d288d96695cf3fe7280c630a4f1c82fc7e665e1db58468f2960fef869906117a29085815260200190565b611eb4610b4f611f61565b6001600160a01b038116600090815261016b602052604090205460ff1615611f125760405162461bcd60e51b815260206004820152601160248201527013558e88185b1c9958591e481859191959607a1b6044820152606401610baa565b6001600160a01b038116600081815261016b6020526040808220805460ff19166001179055513392917f221f04b37331150bcfd05e2de362f50785c29ee4ab14f26d4495a51f3c02906091a350565b7fed5678b978fd67f3777524a00f27c79e5552efeca1f047f9e805a5dc7c2dadff90565b611f90610b4f611f61565b611f9b8160016124d7565b61016980546001600160a01b0319166001600160a01b03831690811790915560405133907f1b092cca381ac00a07e1226c164f47c475d212f5e55699475a7f411811f77dd490600090a350565b600054604051632474521560e21b8152600481018490526001600160a01b03838116602483015262010000909204909116906391d148549060440160206040518083038186803b15801561203b57600080fd5b505afa15801561204f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120739190613b8c565b6120b25760405162461bcd60e51b815260206004820152601060248201526f574d41433a206861736e7420726f6c6560801b6044820152606401610baa565b5050565b7fa28974a2ecc1bcbd5ca81af766b1ac289c6579162f91147085217b9df96014425b816120e38282611fe8565b505050565b60008381526101a460209081526040808320815160c08101835281546001600160a01b039081168252600183015490811694820194909452929091830190600160a01b900460ff16600281111561214157612141613920565b600281111561215257612152613920565b8152600282015460208201526003820154604082015260049091015460609091015280519091506001600160a01b03166121c65760405162461bcd60e51b815260206004820152601560248201527411158e881c995c5d595cdd081b9bdd08195e1a5cdd605a1b6044820152606401610baa565b6000816040015160028111156121de576121de613920565b146122255760405162461bcd60e51b815260206004820152601760248201527644563a2072657175657374206e6f742070656e64696e6760481b6044820152606401610baa565b8115612239576122398160a0015184612b34565b6000838260800151670de0b6b3a76400006122549190613bbf565b61225e9190613bde565b6101635483516040516340c10f1960e01b81526001600160a01b0391821660048201526024810184905292935016906340c10f1990604401600060405180830381600087803b1580156122b057600080fd5b505af11580156122c4573d6000803e3d6000fd5b505083516001600160a01b031660009081526101a56020526040812080548594509092506122f3908490613c00565b90915550506001604083810182815260a0850187905260008881526101a46020908152929020855181546001600160a01b039182166001600160a01b031991821617835593870151948201805495909116938516841781559151869491939092916001600160a81b03191617600160a01b83600281111561237657612376613920565b0217905550606082015160028201556080820151600382015560a0909101516004909101555050505050565b6127108211156123e15760405162461bcd60e51b815260206004820152600a602482015269666565203e203130302560b01b6044820152606401610baa565b80156120b257600082116120b25760405162461bcd60e51b81526020600482015260086024820152670666565203d3d20360c41b6044820152606401610baa565b6040516001600160a01b0383166024820152604481018290526120e390849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612bcd565b61248d612ca2565b6065805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6001600160a01b03821661251c5760405162461bcd60e51b815260206004820152600c60248201526b7a65726f206164647265737360a01b6044820152606401610baa565b80156120b2576001600160a01b0382163014156120b25760405162461bcd60e51b815260206004820152600f60248201526e696e76616c6964206164647265737360881b6044820152606401610baa565b60655460ff16156111e05760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610baa565b7fd2576bd6a4c5558421de15cb8ecdf4eb3282aac06b94d4f004e8cd0d00f3ebd86120d8565b7f548c7f0307ab2a7ea894e5c7e8c5353cc750bb9385ee2e945f189a9a83daa8ed816120e38282612ceb565b60008060008060008060008089116126545760405162461bcd60e51b815260206004820152601260248201527111158e881a5b9d985b1a5908185b5bdd5b9d60721b6044820152606401610baa565b61265d8a612db4565b60ff16905061266b8a612839565b6000806126788c8c612e27565b90995094508891508490508c61268e8d8d612f07565b6126a561269f828f8f8f6000612fb0565b85613051565b98506126b1898d613c18565b97506000670de0b6b3a76400006126c8888c613bbf565b6126d29190613bde565b90506000806126e96126e4848f613c18565b613067565b6001600160a01b03861660009081526101706020526040902054919b5098508a925088915060ff1661271f5761271f848b6130e9565b60008a1161276f5760405162461bcd60e51b815260206004820152601760248201527f44563a20696e76616c6964206d696e7420616d6f756e740000000000000000006044820152606401610baa565b505050505050949950949992975094509450565b600061278f83836131aa565b905061279b81836131b8565b83146127e05760405162461bcd60e51b81526020600482015260146024820152734d563a20696e76616c696420726f756e64696e6760601b6044820152606401610baa565b6127f56001600160a01b0386163386846131c6565b5050505050565b61280461256d565b6065805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586124ba3390565b61284561016c826131fe565b6128885760405162461bcd60e51b81526020600482015260146024820152734d563a20746f6b656e206e6f742065786973747360601b6044820152606401610baa565b50565b600054610100900460ff166128b25760405162461bcd60e51b8152600401610baa90613c2f565b6128c96128c26020880188613802565b60006124d7565b6128dc6128c26040880160208901613802565b6128f36128ec6020870187613802565b60016124d7565b6129066128ec6040870160208801613802565b60008460200135116129475760405162461bcd60e51b815260206004820152600a6024820152691e995c9bc81b1a5b5a5d60b21b6044820152606401610baa565b6129528260016123a2565b61295e843560006123a2565b61296b6020870187613802565b61016380546001600160a01b0319166001600160a01b039290921691909117905561299587613220565b61299d613258565b6129a5613258565b6129ae8361327f565b6129bb6020860186613802565b61016580546001600160a01b0319166001600160a01b03929092169190911790556129ec6040860160208701613802565b61016980546001600160a01b0319166001600160a01b03929092169190911790558335610166556020808501356101675561016f82905561016a839055612a399060408801908801613802565b61016480546001600160a01b0319166001600160a01b039290921691909117905550505050505050565b6000612a78836001600160a01b0384166132c9565b90505b92915050565b6000612a906201518042613bde565b6000818152610168602052604081205491925090612aaf908490613c00565b905061016754811115612af75760405162461bcd60e51b815260206004820152601060248201526f13558e88195e18d95959081b1a5b5a5d60821b6044820152606401610baa565b600091825261016860205260409091205550565b6000612a78836001600160a01b0384166133bc565b60606000612b2d8361340b565b9392505050565b600082821015612b4d57612b488284613c18565b612b57565b612b578383613c18565b9050600083612b6861271084613bbf565b612b729190613bde565b905061016a54811115612bc75760405162461bcd60e51b815260206004820152601a60248201527f4d563a2065786365656420707269636520646976696174696f6e0000000000006044820152606401610baa565b50505050565b6000612c22826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166134679092919063ffffffff16565b9050805160001480612c43575080806020019051810190612c439190613b8c565b6120e35760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610baa565b60655460ff166111e05760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610baa565b600054604051632474521560e21b8152600481018490526001600160a01b03838116602483015262010000909204909116906391d148549060440160206040518083038186803b158015612d3e57600080fd5b505afa158015612d52573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d769190613b8c565b156120b25760405162461bcd60e51b815260206004820152600e60248201526d574d41433a2068617320726f6c6560901b6044820152606401610baa565b6000816001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015612def57600080fd5b505afa158015612e03573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a7b9190613c7a565b60008060008311612e6c5760405162461bcd60e51b815260206004820152600f60248201526e44563a20616d6f756e74207a65726f60881b6044820152606401610baa565b6001600160a01b03808516600090815261016e60205260409020805460038201549192612e9e9291169060ff1661347e565b915060008211612ee05760405162461bcd60e51b815260206004820152600d60248201526c44563a2072617465207a65726f60981b6044820152606401610baa565b670de0b6b3a7640000612ef38386613bbf565b612efd9190613bde565b9250509250929050565b6001600160a01b038216600090815261016e6020526040902060020154600019811415612f3357505050565b81811015612f7a5760405162461bcd60e51b81526020600482015260146024820152734d563a2065786365656420616c6c6f77616e636560601b6044820152606401610baa565b6001600160a01b038316600090815261016e602052604081206002018054849290612fa6908490613c18565b9091555050505050565b6001600160a01b038516600090815261016b602052604081205460ff1615612fda57506000613048565b60008261300457506001600160a01b038516600090815261016e6020526040902060010154613007565b50815b831561301e576101665461301b9082613c00565b90505b61271081111561302d57506127105b61271061303a8287613bbf565b6130449190613bde565b9150505b95945050505050565b6000612a788261306185826131aa565b906131b8565b610164546000908190613083906001600160a01b03168261347e565b9050600081116130c55760405162461bcd60e51b815260206004820152600d60248201526c44563a2072617465207a65726f60981b6044820152606401610baa565b806130d884670de0b6b3a7640000613bbf565b6130e29190613bde565b9150915091565b61016f5481101561313c5760405162461bcd60e51b815260206004820152601760248201527f44563a206d546f6b656e20616d6f756e74203c206d696e0000000000000000006044820152606401610baa565b6001600160a01b03821660009081526101a560205260409020541561315f575050565b6101a3548110156120b25760405162461bcd60e51b8152602060048201526015602482015274222b1d1036b4b73a1030b6b7bab73a101e1036b4b760591b6044820152606401610baa565b6000612a788360128461350b565b6000612a788383601261350b565b6040516001600160a01b0380851660248301528316604482015260648101829052612bc79085906323b872dd60e01b9060840161244e565b6001600160a01b03811660009081526001830160205260408120541515612a78565b600054610100900460ff166132475760405162461bcd60e51b8152600401610baa90613c2f565b61324f613578565b612888816135a7565b600054610100900460ff166111e05760405162461bcd60e51b8152600401610baa90613c2f565b600054610100900460ff166132a65760405162461bcd60e51b8152600401610baa90613c2f565b61012f80546001600160a01b0319166001600160a01b0392909216919091179055565b600081815260018301602052604081205480156133b25760006132ed600183613c18565b855490915060009061330190600190613c18565b905081811461336657600086600001828154811061332157613321613c9d565b906000526020600020015490508087600001848154811061334457613344613c9d565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061337757613377613cb3565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050612a7b565b6000915050612a7b565b600081815260018301602052604081205461340357508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155612a7b565b506000612a7b565b60608160000180548060200260200160405190810160405280929190818152602001828054801561345b57602002820191906000526020600020905b815481526020019060010190808311613447575b50505050509050919050565b6060613476848460008561363d565b949350505050565b600080836001600160a01b031663636929056040518163ffffffff1660e01b815260040160206040518083038186803b1580156134ba57600080fd5b505afa1580156134ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134f29190613cc9565b90508215612a7857670de0b6b3a7640000915050612a7b565b60008361351a57506000612b2d565b81831415613529575082612b2d565b6000828411156135595761353d8385613c18565b61354890600a613dc6565b6135529086613bde565b9050613476565b6135638484613c18565b61356e90600a613dc6565b6130489086613bbf565b600054610100900460ff1661359f5760405162461bcd60e51b8152600401610baa90613c2f565b6111e0613718565b600054610100900460ff166135ce5760405162461bcd60e51b8152600401610baa90613c2f565b6001600160a01b0381166136135760405162461bcd60e51b815260206004820152600c60248201526b7a65726f206164647265737360a01b6044820152606401610baa565b600080546001600160a01b03909216620100000262010000600160b01b0319909216919091179055565b60608247101561369e5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610baa565b600080866001600160a01b031685876040516136ba9190613dfe565b60006040518083038185875af1925050503d80600081146136f7576040519150601f19603f3d011682016040523d82523d6000602084013e6136fc565b606091505b509150915061370d8783838761374b565b979650505050505050565b600054610100900460ff1661373f5760405162461bcd60e51b8152600401610baa90613c2f565b6065805460ff19169055565b606083156137b75782516137b0576001600160a01b0385163b6137b05760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610baa565b5081613476565b61347683838151156137cc5781518083602001fd5b8060405162461bcd60e51b8152600401610baa9190613e1a565b80356001600160a01b03811681146137fd57600080fd5b919050565b60006020828403121561381457600080fd5b612a78826137e6565b60006020828403121561382f57600080fd5b81356001600160e01b031981168114612a7857600080fd5b60006020828403121561385957600080fd5b5035919050565b801515811461288857600080fd5b60006020828403121561388057600080fd5b8135612a7881613860565b6000806040838503121561389e57600080fd5b50508035926020909101359150565b600080604083850312156138c057600080fd5b6138c9836137e6565b915060208301356138d981613860565b809150509250929050565b6000806000606084860312156138f957600080fd5b613902846137e6565b925060208401359150613917604085016137e6565b90509250925092565b634e487b7160e01b600052602160045260246000fd5b6001600160a01b0387811682528616602082015260c081016003861061396c57634e487b7160e01b600052602160045260246000fd5b8560408301528460608301528360808301528260a0830152979650505050505050565b6000806000606084860312156139a457600080fd5b6139ad846137e6565b95602085013595506040909401359392505050565b600080604083850312156139d557600080fd5b6139de836137e6565b946020939093013593505050565b6000604082840312156139fe57600080fd5b50919050565b600080600080600080600080610160898b031215613a2157600080fd5b613a2a896137e6565b9750613a398a60208b016139ec565b9650613a488a60608b016139ec565b9550613a578a60a08b016139ec565b9450613a6560e08a016137e6565b979a969950949793969561010085013595506101208501359461014001359350915050565b60008060008060808587031215613aa057600080fd5b613aa9856137e6565b966020860135965060408601359560600135945092505050565b60008060008060808587031215613ad957600080fd5b613ae2856137e6565b9350613af0602086016137e6565b9250604085013591506060850135613b0781613860565b939692955090935050565b6020808252825182820181905260009190848201906040850190845b81811015613b535783516001600160a01b031683529284019291840191600101613b2e565b50909695505050505050565b60208082526013908201527214185d5cd8589b194e88199b881c185d5cd959606a1b604082015260600190565b600060208284031215613b9e57600080fd5b8151612a7881613860565b634e487b7160e01b600052601160045260246000fd5b6000816000190483118215151615613bd957613bd9613ba9565b500290565b600082613bfb57634e487b7160e01b600052601260045260246000fd5b500490565b60008219821115613c1357613c13613ba9565b500190565b600082821015613c2a57613c2a613ba9565b500390565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b600060208284031215613c8c57600080fd5b815160ff81168114612a7857600080fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b600060208284031215613cdb57600080fd5b5051919050565b600181815b80851115613d1d578160001904821115613d0357613d03613ba9565b80851615613d1057918102915b93841c9390800290613ce7565b509250929050565b600082613d3457506001612a7b565b81613d4157506000612a7b565b8160018114613d575760028114613d6157613d7d565b6001915050612a7b565b60ff841115613d7257613d72613ba9565b50506001821b612a7b565b5060208310610133831016604e8410600b8410161715613da0575081810a612a7b565b613daa8383613ce2565b8060001904821115613dbe57613dbe613ba9565b029392505050565b6000612a788383613d25565b60005b83811015613ded578181015183820152602001613dd5565b83811115612bc75750506000910152565b60008251613e10818460208701613dd2565b9190910192915050565b6020815260008251806020840152613e39816040850160208701613dd2565b601f01601f1916919091016040019291505056fea2646970667358221220a173c09b95cceb3e13419d2ce705492e857b87629175fb230ce47148e972763264736f6c63430008090033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106104265760003560e01c80637192de4b1161022b578063c3b6f93911610130578063db74d8b5116100b8578063e5b5019a11610087578063e5b5019a14610ae5578063eaf896fd14610aee578063ec571c6a14610af6578063efdcd97414610b0a578063fe011e5f14610b1d57600080fd5b8063db74d8b514610a8f578063dd0081c714610aa2578063e2c4d73714610aab578063e428877e14610ad257600080fd5b8063cabccc7f116100ff578063cabccc7f14610a32578063cbc3dd8d14610a3a578063d63567a514610a61578063d7fd2bae14610a6b578063daddcb1614610a3257600080fd5b8063c3b6f939146109ec578063c47d51be14610a00578063c64b639114610a0a578063ca5e553e14610a1d57600080fd5b80639c8e5ef1116101b3578063b3f0067411610182578063b3f0067414610909578063bbae40861461091d578063bc63773f14610943578063bc979af61461096a578063c02dd27a146109d957600080fd5b80639c8e5ef1146108c8578063a217fddf146108db578063a5125421146108e3578063ad9e5649146108f657600080fd5b8063897b0637116101fa578063897b0637146108815780638a0ae61514610894578063978ff560146108a75780639af40265146108b65780639b2cb5d8146108be57600080fd5b80637192de4b146108355780638456cb591461083f57806388a6de68146108475780638978ac451461085a57600080fd5b80633807be7d116103315780635300b4ba116102b95780636254afb6116102885780636254afb6146107b357806362b199c5146107c75780636957463a146107ee5780636dc69e03146108015780636e26b9f81461082257600080fd5b80635300b4ba1461074f5780635ae2bfdb146107765780635c975abb14610781578063603481561461078c57600080fd5b80633f4ba83a116103005780633f4ba83a14610694578063409853231461069c578063424e6575146106c3578063476abc761461072957806349dc5e8d1461073c57600080fd5b80633807be7d146106515780633972183c1461066457806339dac34d1461066e5780633ccdbb281461068157600080fd5b80631e022f4c116103b45780632c0a90a9116103835780632c0a90a9146105df5780632d7788db146105f257806332b30cce1461060557806334c244891461062b5780633733337d1461063e57600080fd5b80631e022f4c1461057e5780631ed41163146105915780631fa1e8d4146105b857806327abf518146105cc57600080fd5b8063105ed2b2116103fb578063105ed2b2146104dd57806313007d55146104ea578063138e139b1461051b57806315b9598a1461054257806316683aa51461056957600080fd5b80623d47901461042b578062eafebf1461045f578063042da5ee146104865780630b5a57bd146104ba575b600080fd5b61044c610439366004613802565b6101a56020526000908152604090205481565b6040519081526020015b60405180910390f35b61044c7fa402581169544bec3e7f4fdb6f22f3658bc2f7bad057fd353bca877dc365e4ee81565b6104aa610494366004613802565b61016b6020526000908152604090205460ff1681565b6040519015158152602001610456565b6104aa6104c836600461381d565b60976020526000908152604090205460ff1681565b60fc546104aa9060ff1681565b600054610503906201000090046001600160a01b031681565b6040516001600160a01b039091168152602001610456565b61044c7fed5678b978fd67f3777524a00f27c79e5552efeca1f047f9e805a5dc7c2dadff81565b61044c7f77c5b782690f31cd39b1abf2448215259a688a75920040c399d96a676bd1999d81565b61057c610577366004613802565b610b44565b005b61057c61058c366004613847565b610bff565b61044c7fd2576bd6a4c5558421de15cb8ecdf4eb3282aac06b94d4f004e8cd0d00f3ebd881565b61016554610503906001600160a01b031681565b61057c6105da36600461386e565b610c49565b61057c6105ed36600461388b565b610ce7565b61057c610600366004613847565b610d3c565b7fa28974a2ecc1bcbd5ca81af766b1ac289c6579162f91147085217b9df960144261044c565b61057c610639366004613847565b610ee1565b61057c61064c36600461381d565b610f2f565b61057c61065f36600461381d565b610fcb565b61044c6101675481565b61057c61067c3660046138ad565b61108b565b61057c61068f3660046138e4565b611152565b61057c6111cd565b61044c7f2728bd32a7e1e24afac41a073e9c92dbb65527c9ec3baa2a8d5ee1d06c0fa77981565b6107176106d1366004613847565b6101a460205260009081526040902080546001820154600283015460038401546004909401546001600160a01b039384169493831693600160a01b90930460ff16929086565b60405161045696959493929190613936565b61057c610737366004613802565b6111e2565b61057c61074a366004613802565b611245565b61044c7f2fdc6683bc8d03effec5b41d3834f28bd219e06ca0a6a26fc737e44b1c7889ff81565b6101625461044c9081565b60655460ff166104aa565b61044c7f82830251f95316fd2426de66b9298a230aae8afa718479a58eb92f667eaa8b2d81565b61016454610503906001600160a01b031681565b61044c7f548c7f0307ab2a7ea894e5c7e8c5353cc750bb9385ee2e945f189a9a83daa8ed81565b61057c6107fc366004613847565b61129d565b61044c61080f366004613847565b6101686020526000908152604090205481565b61044c61083036600461398f565b611321565b61044c61016a5481565b61057c611647565b61057c61085536600461388b565b61165a565b61044c7f3d63b8d5d9c57f3a193bc98b7ebe0c3f62ed0859cbe92c95839f2c4948a3bbff81565b61057c61088f366004613847565b6116a3565b61057c6108a23660046139c2565b6116e6565b61044c670de0b6b3a764000081565b610503600081565b61044c61016f5481565b61057c6108d6366004613a04565b6117ae565b61044c600081565b61057c6108f1366004613802565b6118d4565b61057c610904366004613847565b611993565b61016954610503906001600160a01b031681565b7fd2576bd6a4c5558421de15cb8ecdf4eb3282aac06b94d4f004e8cd0d00f3ebd861044c565b61044c7fa28974a2ecc1bcbd5ca81af766b1ac289c6579162f91147085217b9df960144281565b6109ad610978366004613802565b61016e6020526000908152604090208054600182015460028301546003909301546001600160a01b0390921692909160ff1684565b604080516001600160a01b03909516855260208501939093529183015215156060820152608001610456565b61057c6109e7366004613a8a565b6119e1565b61016354610503906001600160a01b031681565b61044c6101665481565b61057c610a18366004613ac3565b611ced565b610a25611e1a565b6040516104569190613b12565b61044c611e2c565b61044c7f15a9a8831d7e86b8cacded60e5295dd3f73e83a49069ee92480fc811440c5c3e81565b61044c6101a35481565b6104aa610a79366004613802565b6101706020526000908152604090205460ff1681565b61057c610a9d3660046139c2565b611e36565b61044c61271081565b61044c7f57df534b215589c7ade8c8abe0978debf2ea95cf1d442550f94eec78a69d238e81565b61057c610ae0366004613802565b611ea9565b61044c60001981565b61044c611f61565b61012f54610503906001600160a01b031681565b61057c610b18366004613802565b611f85565b61044c7f7bd1951470f20c89a15b10ee03824a5ddb66ad1f15509a43080312e5afb004b781565b610b55610b4f611f61565b33611fe8565b6001600160a01b038116600090815261016b602052604090205460ff16610bb35760405162461bcd60e51b815260206004820152600d60248201526c13558e881b9bdd08199bdd5b99609a1b60448201526064015b60405180910390fd5b6001600160a01b038116600081815261016b6020526040808220805460ff19169055513392917f57c4a95f59c12f0d4d846443c2d54c7d97f1505080199522fca2819e65213ca291a350565b610c0a610b4f611f61565b6101a381905560405181815233907ff0af3ac3dc311b130ec783d7ff5582ccf0923fa13c4688c5da387d4cc57d852d906020015b60405180910390a250565b610c52336120b6565b60fc5460ff1615158115151415610ca45760405162461bcd60e51b8152602060048201526016602482015275474c3a2073616d6520656e61626c652073746174757360501b6044820152606401610baa565b60fc805460ff191682151590811790915560405190815233907fa8434267b880129bc4ba30249aa4a2ac349e8997c699282a9f70562f0f152f5490602001610c3e565b610cf2610b4f611f61565b610cfe828260006120e8565b817ff7d1fde87f32720fc30ce6847e0aae77e640b59bfac41b11b270358ccfa7a0ac82604051610d3091815260200190565b60405180910390a25050565b610d47610b4f611f61565b60008181526101a460209081526040808320815160c08101835281546001600160a01b039081168252600183015490811694820194909452929091830190600160a01b900460ff166002811115610da057610da0613920565b6002811115610db157610db1613920565b8152600282015460208201526003820154604082015260049091015460609091015280519091506001600160a01b0316610e255760405162461bcd60e51b815260206004820152601560248201527411158e881c995c5d595cdd081b9bdd08195e1a5cdd605a1b6044820152606401610baa565b600081604001516002811115610e3d57610e3d613920565b14610e845760405162461bcd60e51b815260206004820152601760248201527644563a2072657175657374206e6f742070656e64696e6760481b6044820152606401610baa565b60008281526101a46020526040808220600101805460ff60a01b1916600160a11b179055825190516001600160a01b039091169184917ece63cc55966b103e4f4cb39f3426cb91718ad4f8eb4ad08c14a7ee749d81579190a35050565b610eec610b4f611f61565b610ef78160016123a2565b61016a81905560405181815233907f018be394ba93a0dbca235443cfdc7173b2479180ad766083ce05199fbf3fc62490602001610c3e565b610f3a610b4f611e2c565b6001600160e01b0319811660009081526097602052604090205460ff1615610f745760405162461bcd60e51b8152600401610baa90613b5f565b6001600160e01b03198116600081815260976020908152604091829020805460ff19166001179055905191825233917f2278e547293e53a66144c1743877f8388ac3101bd21cfd7c7f4ce8c15c14f5c19101610c3e565b610fd6610b4f611e2c565b6001600160e01b0319811660009081526097602052604090205460ff166110375760405162461bcd60e51b815260206004820152601560248201527414185d5cd8589b194e88199b881d5b9c185d5cd959605a1b6044820152606401610baa565b6001600160e01b03198116600081815260976020908152604091829020805460ff19169055905191825233917f929135cc6324f958693bb5f24a4dbc226a83c721523fc2785545019a3423b2d79101610c3e565b611096610b4f611f61565b6001600160a01b0382166000908152610170602052604090205460ff16151581151514156110f95760405162461bcd60e51b815260206004820152601060248201526f44563a20616c7265616479206672656560801b6044820152606401610baa565b6001600160a01b03821660008181526101706020908152604091829020805460ff191685151590811790915591519182527f80f6f2f8801c6ac8fc60bf218b44fde97744d8709f69281972ec5557c10226cc9101610d30565b61115d610b4f611f61565b6111716001600160a01b0384168284612422565b806001600160a01b0316836001600160a01b0316336001600160a01b03167f9ca7c1e047552a8048d924a5a8d3c150eb861086a72a9100e5f19d1176c1b746856040516111c091815260200190565b60405180910390a4505050565b6111d8610b4f611e2c565b6111e0612485565b565b6111ed610b4f611f61565b6111f88160016124d7565b61016580546001600160a01b0319166001600160a01b03831690811790915560405133907fdb5a411e1a379f981ff6bc5284aa2c2522a9b8fd33a9db9ca19b34006cefbe9c90600090a350565b611250610b4f611e2c565b61012f80546001600160a01b0319166001600160a01b03831690811790915560405133907f7f0c791852a03e270d4c2b78bbd4b959bca234de8d1ccf27eee03afaeafe63c490600090a350565b6112a8610b4f611f61565b600081116112e95760405162461bcd60e51b815260206004820152600e60248201526d4d563a206c696d6974207a65726f60901b6044820152606401610baa565b61016781905560405181815233907f5e8309fc6b2360e7438bc53790b00913395fffa870f39043fe63ddc8a438a9b290602001610c3e565b6000630dc4d73f60e31b61133361256d565b6001600160e01b0319811660009081526097602052604090205460ff161561136d5760405162461bcd60e51b8152600401610baa90613b5f565b60fc54339060ff161561138357611383816125b3565b3361138d816125d9565b61012f5433906001600160a01b0316801561145a5760405163df592f7d60e01b81526001600160a01b03838116600483015282169063df592f7d9060240160206040518083038186803b1580156113e357600080fd5b505afa1580156113f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061141b9190613b8c565b1561145a5760405162461bcd60e51b815260206004820152600f60248201526e15d4d30e881cd85b98dd1a5bdb9959608a1b6044820152606401610baa565b33898989600061146a6101625490565b9050809a5061147e61016280546001019055565b6000806000806000806114948b8b8b6000612605565b965096509650509550955095506114c38a61016560009054906101000a90046001600160a01b03168684612783565b84156114e357610169546114e3908b906001600160a01b03168784612783565b6040805160c0810182526001600160a01b03808e1682528c1660208201529081016000815260208101889052604001670de0b6b3a76400006115258688613bbf565b61152f9190613bde565b8152602090810184905260008981526101a48252604090819020835181546001600160a01b03199081166001600160a01b0392831617835593850151600183018054958616919092169081178255928501519193919290916001600160a81b03191617600160a01b8360028111156115a9576115a9613920565b02179055506060828101516002830155608080840151600384015560a093840151600490930192909255604080518d8152602081018b90529081018990529081018590529081018a90526001600160a01b03808d1692908e16918a917f3704c9b13a68ac43d7f8a85f2700f0b4f89a11ed9e2bcac5324f0d228d409009910160405180910390a4505050505050505050505050505050509392505050565b611652610b4f611e2c565b6111e06127fc565b611665610b4f611f61565b611671828260016120e8565b817f03ea09e71742c9c754c9746b3e671ecb27fc372e3d29c31bac0192458ffd9d4b82604051610d3091815260200190565b6116ae610b4f611f61565b61016f81905560405181815233907f57e764c1fef224e74706b109734513889970db6f1dde107b1bda66e10d80ca9b90602001610c3e565b6116f1610b4f611f61565b6001600160a01b038216156117095761170982612839565b6000811161174e5760405162461bcd60e51b81526020600482015260126024820152714d563a207a65726f20616c6c6f77616e636560701b6044820152606401610baa565b6001600160a01b038216600081815261016e602052604090819020600201839055513391907ff7273742887a46d8b97d83d1d12b6d8d8e6d21d814072369e2f4b355690221d7906117a29085815260200190565b60405180910390a35050565b600054610100900460ff16158080156117ce5750600054600160ff909116105b806117e85750303b1580156117e8575060005460ff166001145b61184b5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610baa565b6000805460ff19166001179055801561186e576000805461ff0019166101001790555b61187d8989898989898961288b565b6101a382905580156118c9576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050505050565b6118df610b4f611f61565b6118eb61016c82612a63565b6119285760405162461bcd60e51b815260206004820152600e60248201526d4d563a206e6f742065786973747360901b6044820152606401610baa565b6001600160a01b038116600081815261016e602052604080822080546001600160a01b03191681556001810183905560028101839055600301805460ff19169055513392917f652fa2f5d587d3f1c189df0081b7bf3121f47d51d5471bf58d7d2c8a084894c391a350565b61199e610b4f611f61565b6119a98160006123a2565b61016681905560405181815233907f45acc8bd6ebd6fbb59ce049b682c124aeccc93c468fcf60fecf61340e86e79d390602001610c3e565b636016e93d60e11b6119f161256d565b6001600160e01b0319811660009081526097602052604090205460ff1615611a2b5760405162461bcd60e51b8152600401610baa90613b5f565b60fc54339060ff1615611a4157611a41816125b3565b33611a4b816125d9565b61012f5433906001600160a01b03168015611b185760405163df592f7d60e01b81526001600160a01b03838116600483015282169063df592f7d9060240160206040518083038186803b158015611aa157600080fd5b505afa158015611ab5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ad99190613b8c565b15611b185760405162461bcd60e51b815260206004820152600f60248201526e15d4d30e881cd85b98dd1a5bdb9959608a1b6044820152606401610baa565b338989600080808080611b2e8888886001612605565b9650505094509450945094508e821015611b8a5760405162461bcd60e51b815260206004820152601d60248201527f44563a206d696e52656365697665416d6f756e74203e2061637475616c0000006044820152606401610baa565b6001600160a01b03881660009081526101a5602052604081208054849290611bb3908490613c00565b90915550611bc2905082612a81565b61016554611bdc9088906001600160a01b03168584612783565b8315611bfc5761016954611bfc9088906001600160a01b03168684612783565b610163546040516340c10f1960e01b81526001600160a01b038a8116600483015260248201859052909116906340c10f1990604401600060405180830381600087803b158015611c4b57600080fd5b505af1158015611c5f573d6000803e3d6000fd5b5050505060008e9050876001600160a01b0316896001600160a01b03167fdd6865ec496cf9bdd5cb1661ab84cf4e86edc877208a54cbf642f69d744530c5888a898887604051611cd1959493929190948552602085019390935260408401919091526060830152608082015260a00190565b60405180910390a3505050505050505050505050505050505050565b611cf8610b4f611f61565b611d0461016c85612b0b565b611d445760405162461bcd60e51b815260206004820152601160248201527013558e88185b1c9958591e481859191959607a1b6044820152606401610baa565b611d4f8360006124d7565b611d5a8260006123a2565b604080516080810182526001600160a01b038581168083526020808401878152600019858701908152871515606087018181528c8716600081815261016e87528a9020985189546001600160a01b0319169816979097178855925160018801559051600287015590516003909501805460ff19169515159590951790945584518781529081019390935292909133917f619139d13e799b88ce56bff114b5510808a19ea7440710070ef78528a05ed672910160405180910390a450505050565b6060611e2761016c612b20565b905090565b6000611e27611f61565b611e41610b4f611f61565b611e4a82612839565b611e558160006123a2565b6001600160a01b038216600081815261016e602052604090819020600101839055513391907f1582567d288d96695cf3fe7280c630a4f1c82fc7e665e1db58468f2960fef869906117a29085815260200190565b611eb4610b4f611f61565b6001600160a01b038116600090815261016b602052604090205460ff1615611f125760405162461bcd60e51b815260206004820152601160248201527013558e88185b1c9958591e481859191959607a1b6044820152606401610baa565b6001600160a01b038116600081815261016b6020526040808220805460ff19166001179055513392917f221f04b37331150bcfd05e2de362f50785c29ee4ab14f26d4495a51f3c02906091a350565b7fed5678b978fd67f3777524a00f27c79e5552efeca1f047f9e805a5dc7c2dadff90565b611f90610b4f611f61565b611f9b8160016124d7565b61016980546001600160a01b0319166001600160a01b03831690811790915560405133907f1b092cca381ac00a07e1226c164f47c475d212f5e55699475a7f411811f77dd490600090a350565b600054604051632474521560e21b8152600481018490526001600160a01b03838116602483015262010000909204909116906391d148549060440160206040518083038186803b15801561203b57600080fd5b505afa15801561204f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120739190613b8c565b6120b25760405162461bcd60e51b815260206004820152601060248201526f574d41433a206861736e7420726f6c6560801b6044820152606401610baa565b5050565b7fa28974a2ecc1bcbd5ca81af766b1ac289c6579162f91147085217b9df96014425b816120e38282611fe8565b505050565b60008381526101a460209081526040808320815160c08101835281546001600160a01b039081168252600183015490811694820194909452929091830190600160a01b900460ff16600281111561214157612141613920565b600281111561215257612152613920565b8152600282015460208201526003820154604082015260049091015460609091015280519091506001600160a01b03166121c65760405162461bcd60e51b815260206004820152601560248201527411158e881c995c5d595cdd081b9bdd08195e1a5cdd605a1b6044820152606401610baa565b6000816040015160028111156121de576121de613920565b146122255760405162461bcd60e51b815260206004820152601760248201527644563a2072657175657374206e6f742070656e64696e6760481b6044820152606401610baa565b8115612239576122398160a0015184612b34565b6000838260800151670de0b6b3a76400006122549190613bbf565b61225e9190613bde565b6101635483516040516340c10f1960e01b81526001600160a01b0391821660048201526024810184905292935016906340c10f1990604401600060405180830381600087803b1580156122b057600080fd5b505af11580156122c4573d6000803e3d6000fd5b505083516001600160a01b031660009081526101a56020526040812080548594509092506122f3908490613c00565b90915550506001604083810182815260a0850187905260008881526101a46020908152929020855181546001600160a01b039182166001600160a01b031991821617835593870151948201805495909116938516841781559151869491939092916001600160a81b03191617600160a01b83600281111561237657612376613920565b0217905550606082015160028201556080820151600382015560a0909101516004909101555050505050565b6127108211156123e15760405162461bcd60e51b815260206004820152600a602482015269666565203e203130302560b01b6044820152606401610baa565b80156120b257600082116120b25760405162461bcd60e51b81526020600482015260086024820152670666565203d3d20360c41b6044820152606401610baa565b6040516001600160a01b0383166024820152604481018290526120e390849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612bcd565b61248d612ca2565b6065805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6001600160a01b03821661251c5760405162461bcd60e51b815260206004820152600c60248201526b7a65726f206164647265737360a01b6044820152606401610baa565b80156120b2576001600160a01b0382163014156120b25760405162461bcd60e51b815260206004820152600f60248201526e696e76616c6964206164647265737360881b6044820152606401610baa565b60655460ff16156111e05760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610baa565b7fd2576bd6a4c5558421de15cb8ecdf4eb3282aac06b94d4f004e8cd0d00f3ebd86120d8565b7f548c7f0307ab2a7ea894e5c7e8c5353cc750bb9385ee2e945f189a9a83daa8ed816120e38282612ceb565b60008060008060008060008089116126545760405162461bcd60e51b815260206004820152601260248201527111158e881a5b9d985b1a5908185b5bdd5b9d60721b6044820152606401610baa565b61265d8a612db4565b60ff16905061266b8a612839565b6000806126788c8c612e27565b90995094508891508490508c61268e8d8d612f07565b6126a561269f828f8f8f6000612fb0565b85613051565b98506126b1898d613c18565b97506000670de0b6b3a76400006126c8888c613bbf565b6126d29190613bde565b90506000806126e96126e4848f613c18565b613067565b6001600160a01b03861660009081526101706020526040902054919b5098508a925088915060ff1661271f5761271f848b6130e9565b60008a1161276f5760405162461bcd60e51b815260206004820152601760248201527f44563a20696e76616c6964206d696e7420616d6f756e740000000000000000006044820152606401610baa565b505050505050949950949992975094509450565b600061278f83836131aa565b905061279b81836131b8565b83146127e05760405162461bcd60e51b81526020600482015260146024820152734d563a20696e76616c696420726f756e64696e6760601b6044820152606401610baa565b6127f56001600160a01b0386163386846131c6565b5050505050565b61280461256d565b6065805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586124ba3390565b61284561016c826131fe565b6128885760405162461bcd60e51b81526020600482015260146024820152734d563a20746f6b656e206e6f742065786973747360601b6044820152606401610baa565b50565b600054610100900460ff166128b25760405162461bcd60e51b8152600401610baa90613c2f565b6128c96128c26020880188613802565b60006124d7565b6128dc6128c26040880160208901613802565b6128f36128ec6020870187613802565b60016124d7565b6129066128ec6040870160208801613802565b60008460200135116129475760405162461bcd60e51b815260206004820152600a6024820152691e995c9bc81b1a5b5a5d60b21b6044820152606401610baa565b6129528260016123a2565b61295e843560006123a2565b61296b6020870187613802565b61016380546001600160a01b0319166001600160a01b039290921691909117905561299587613220565b61299d613258565b6129a5613258565b6129ae8361327f565b6129bb6020860186613802565b61016580546001600160a01b0319166001600160a01b03929092169190911790556129ec6040860160208701613802565b61016980546001600160a01b0319166001600160a01b03929092169190911790558335610166556020808501356101675561016f82905561016a839055612a399060408801908801613802565b61016480546001600160a01b0319166001600160a01b039290921691909117905550505050505050565b6000612a78836001600160a01b0384166132c9565b90505b92915050565b6000612a906201518042613bde565b6000818152610168602052604081205491925090612aaf908490613c00565b905061016754811115612af75760405162461bcd60e51b815260206004820152601060248201526f13558e88195e18d95959081b1a5b5a5d60821b6044820152606401610baa565b600091825261016860205260409091205550565b6000612a78836001600160a01b0384166133bc565b60606000612b2d8361340b565b9392505050565b600082821015612b4d57612b488284613c18565b612b57565b612b578383613c18565b9050600083612b6861271084613bbf565b612b729190613bde565b905061016a54811115612bc75760405162461bcd60e51b815260206004820152601a60248201527f4d563a2065786365656420707269636520646976696174696f6e0000000000006044820152606401610baa565b50505050565b6000612c22826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166134679092919063ffffffff16565b9050805160001480612c43575080806020019051810190612c439190613b8c565b6120e35760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610baa565b60655460ff166111e05760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610baa565b600054604051632474521560e21b8152600481018490526001600160a01b03838116602483015262010000909204909116906391d148549060440160206040518083038186803b158015612d3e57600080fd5b505afa158015612d52573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d769190613b8c565b156120b25760405162461bcd60e51b815260206004820152600e60248201526d574d41433a2068617320726f6c6560901b6044820152606401610baa565b6000816001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015612def57600080fd5b505afa158015612e03573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a7b9190613c7a565b60008060008311612e6c5760405162461bcd60e51b815260206004820152600f60248201526e44563a20616d6f756e74207a65726f60881b6044820152606401610baa565b6001600160a01b03808516600090815261016e60205260409020805460038201549192612e9e9291169060ff1661347e565b915060008211612ee05760405162461bcd60e51b815260206004820152600d60248201526c44563a2072617465207a65726f60981b6044820152606401610baa565b670de0b6b3a7640000612ef38386613bbf565b612efd9190613bde565b9250509250929050565b6001600160a01b038216600090815261016e6020526040902060020154600019811415612f3357505050565b81811015612f7a5760405162461bcd60e51b81526020600482015260146024820152734d563a2065786365656420616c6c6f77616e636560601b6044820152606401610baa565b6001600160a01b038316600090815261016e602052604081206002018054849290612fa6908490613c18565b9091555050505050565b6001600160a01b038516600090815261016b602052604081205460ff1615612fda57506000613048565b60008261300457506001600160a01b038516600090815261016e6020526040902060010154613007565b50815b831561301e576101665461301b9082613c00565b90505b61271081111561302d57506127105b61271061303a8287613bbf565b6130449190613bde565b9150505b95945050505050565b6000612a788261306185826131aa565b906131b8565b610164546000908190613083906001600160a01b03168261347e565b9050600081116130c55760405162461bcd60e51b815260206004820152600d60248201526c44563a2072617465207a65726f60981b6044820152606401610baa565b806130d884670de0b6b3a7640000613bbf565b6130e29190613bde565b9150915091565b61016f5481101561313c5760405162461bcd60e51b815260206004820152601760248201527f44563a206d546f6b656e20616d6f756e74203c206d696e0000000000000000006044820152606401610baa565b6001600160a01b03821660009081526101a560205260409020541561315f575050565b6101a3548110156120b25760405162461bcd60e51b8152602060048201526015602482015274222b1d1036b4b73a1030b6b7bab73a101e1036b4b760591b6044820152606401610baa565b6000612a788360128461350b565b6000612a788383601261350b565b6040516001600160a01b0380851660248301528316604482015260648101829052612bc79085906323b872dd60e01b9060840161244e565b6001600160a01b03811660009081526001830160205260408120541515612a78565b600054610100900460ff166132475760405162461bcd60e51b8152600401610baa90613c2f565b61324f613578565b612888816135a7565b600054610100900460ff166111e05760405162461bcd60e51b8152600401610baa90613c2f565b600054610100900460ff166132a65760405162461bcd60e51b8152600401610baa90613c2f565b61012f80546001600160a01b0319166001600160a01b0392909216919091179055565b600081815260018301602052604081205480156133b25760006132ed600183613c18565b855490915060009061330190600190613c18565b905081811461336657600086600001828154811061332157613321613c9d565b906000526020600020015490508087600001848154811061334457613344613c9d565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061337757613377613cb3565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050612a7b565b6000915050612a7b565b600081815260018301602052604081205461340357508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155612a7b565b506000612a7b565b60608160000180548060200260200160405190810160405280929190818152602001828054801561345b57602002820191906000526020600020905b815481526020019060010190808311613447575b50505050509050919050565b6060613476848460008561363d565b949350505050565b600080836001600160a01b031663636929056040518163ffffffff1660e01b815260040160206040518083038186803b1580156134ba57600080fd5b505afa1580156134ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134f29190613cc9565b90508215612a7857670de0b6b3a7640000915050612a7b565b60008361351a57506000612b2d565b81831415613529575082612b2d565b6000828411156135595761353d8385613c18565b61354890600a613dc6565b6135529086613bde565b9050613476565b6135638484613c18565b61356e90600a613dc6565b6130489086613bbf565b600054610100900460ff1661359f5760405162461bcd60e51b8152600401610baa90613c2f565b6111e0613718565b600054610100900460ff166135ce5760405162461bcd60e51b8152600401610baa90613c2f565b6001600160a01b0381166136135760405162461bcd60e51b815260206004820152600c60248201526b7a65726f206164647265737360a01b6044820152606401610baa565b600080546001600160a01b03909216620100000262010000600160b01b0319909216919091179055565b60608247101561369e5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610baa565b600080866001600160a01b031685876040516136ba9190613dfe565b60006040518083038185875af1925050503d80600081146136f7576040519150601f19603f3d011682016040523d82523d6000602084013e6136fc565b606091505b509150915061370d8783838761374b565b979650505050505050565b600054610100900460ff1661373f5760405162461bcd60e51b8152600401610baa90613c2f565b6065805460ff19169055565b606083156137b75782516137b0576001600160a01b0385163b6137b05760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610baa565b5081613476565b61347683838151156137cc5781518083602001fd5b8060405162461bcd60e51b8152600401610baa9190613e1a565b80356001600160a01b03811681146137fd57600080fd5b919050565b60006020828403121561381457600080fd5b612a78826137e6565b60006020828403121561382f57600080fd5b81356001600160e01b031981168114612a7857600080fd5b60006020828403121561385957600080fd5b5035919050565b801515811461288857600080fd5b60006020828403121561388057600080fd5b8135612a7881613860565b6000806040838503121561389e57600080fd5b50508035926020909101359150565b600080604083850312156138c057600080fd5b6138c9836137e6565b915060208301356138d981613860565b809150509250929050565b6000806000606084860312156138f957600080fd5b613902846137e6565b925060208401359150613917604085016137e6565b90509250925092565b634e487b7160e01b600052602160045260246000fd5b6001600160a01b0387811682528616602082015260c081016003861061396c57634e487b7160e01b600052602160045260246000fd5b8560408301528460608301528360808301528260a0830152979650505050505050565b6000806000606084860312156139a457600080fd5b6139ad846137e6565b95602085013595506040909401359392505050565b600080604083850312156139d557600080fd5b6139de836137e6565b946020939093013593505050565b6000604082840312156139fe57600080fd5b50919050565b600080600080600080600080610160898b031215613a2157600080fd5b613a2a896137e6565b9750613a398a60208b016139ec565b9650613a488a60608b016139ec565b9550613a578a60a08b016139ec565b9450613a6560e08a016137e6565b979a969950949793969561010085013595506101208501359461014001359350915050565b60008060008060808587031215613aa057600080fd5b613aa9856137e6565b966020860135965060408601359560600135945092505050565b60008060008060808587031215613ad957600080fd5b613ae2856137e6565b9350613af0602086016137e6565b9250604085013591506060850135613b0781613860565b939692955090935050565b6020808252825182820181905260009190848201906040850190845b81811015613b535783516001600160a01b031683529284019291840191600101613b2e565b50909695505050505050565b60208082526013908201527214185d5cd8589b194e88199b881c185d5cd959606a1b604082015260600190565b600060208284031215613b9e57600080fd5b8151612a7881613860565b634e487b7160e01b600052601160045260246000fd5b6000816000190483118215151615613bd957613bd9613ba9565b500290565b600082613bfb57634e487b7160e01b600052601260045260246000fd5b500490565b60008219821115613c1357613c13613ba9565b500190565b600082821015613c2a57613c2a613ba9565b500390565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b600060208284031215613c8c57600080fd5b815160ff81168114612a7857600080fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b600060208284031215613cdb57600080fd5b5051919050565b600181815b80851115613d1d578160001904821115613d0357613d03613ba9565b80851615613d1057918102915b93841c9390800290613ce7565b509250929050565b600082613d3457506001612a7b565b81613d4157506000612a7b565b8160018114613d575760028114613d6157613d7d565b6001915050612a7b565b60ff841115613d7257613d72613ba9565b50506001821b612a7b565b5060208310610133831016604e8410600b8410161715613da0575081810a612a7b565b613daa8383613ce2565b8060001904821115613dbe57613dbe613ba9565b029392505050565b6000612a788383613d25565b60005b83811015613ded578181015183820152602001613dd5565b83811115612bc75750506000910152565b60008251613e10818460208701613dd2565b9190910192915050565b6020815260008251806020840152613e39816040850160208701613dd2565b601f01601f1916919091016040019291505056fea2646970667358221220a173c09b95cceb3e13419d2ce705492e857b87629175fb230ce47148e972763264736f6c63430008090033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 33 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
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.