Source Code
Overview
ETH Balance
0 ETH
Eth Value
$0.00View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Contract Name:
MHyperRedemptionVaultWithSwapper
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 "../RedemptionVaultWithSwapper.sol";
import "./MHyperMidasAccessControlRoles.sol";
/**
* @title MHyperRedemptionVaultWithSwapper.sol
* @notice Smart contract that handles mHYPER redemptions
* @author RedDuck Software
*/
contract MHyperRedemptionVaultWithSwapper is
RedemptionVaultWithSwapper,
MHyperMidasAccessControlRoles
{
/**
* @dev leaving a storage gap for futures updates
*/
uint256[50] private __gap;
/**
* @inheritdoc ManageableVault
*/
function vaultRole() public pure override returns (bytes32) {
return M_HYPER_REDEMPTION_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 "@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 "./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;
import "./IManageableVault.sol";
/**
* @notice Redeem request scruct
* @param sender user address who create
* @param tokenOut tokenOut address
* @param status request status
* @param amountMToken amount mToken
* @param mTokenRate rate of mToken at request creation time
* @param tokenOutRate rate of tokenOut at request creation time
*/
struct Request {
address sender;
address tokenOut;
RequestStatus status;
uint256 amountMToken;
uint256 mTokenRate;
uint256 tokenOutRate;
}
struct FiatRedeptionInitParams {
uint256 fiatAdditionalFee;
uint256 fiatFlatFee;
uint256 minFiatRedeemAmount;
}
/**
* @title IRedemptionVault
* @author RedDuck Software
*/
interface IRedemptionVault is IManageableVault {
/**
* @param user function caller (msg.sender)
* @param tokenOut address of tokenOut
* @param amount amount of mToken
* @param feeAmount fee amount in mToken
* @param amountTokenOut amount of tokenOut
*/
event RedeemInstant(
address indexed user,
address indexed tokenOut,
uint256 amount,
uint256 feeAmount,
uint256 amountTokenOut
);
/**
* @param requestId request id
* @param user function caller (msg.sender)
* @param tokenOut address of tokenOut
* @param amountMTokenIn amount of mToken
*/
event RedeemRequest(
uint256 indexed requestId,
address indexed user,
address indexed tokenOut,
uint256 amountMTokenIn,
uint256 feeAmount
);
/**
* @param requestId mint request id
* @param newMTokenRate net mToken rate
*/
event ApproveRequest(uint256 indexed requestId, uint256 newMTokenRate);
/**
* @param requestId mint request id
* @param newMTokenRate net mToken rate
*/
event SafeApproveRequest(uint256 indexed requestId, uint256 newMTokenRate);
/**
* @param requestId mint request id
* @param user address of user
*/
event RejectRequest(uint256 indexed requestId, address indexed user);
/**
* @param caller function caller (msg.sender)
* @param newMinAmount new min amount for fiat requests
*/
event SetMinFiatRedeemAmount(address indexed caller, uint256 newMinAmount);
/**
* @param caller function caller (msg.sender)
* @param feeInMToken fee amount in mToken
*/
event SetFiatFlatFee(address indexed caller, uint256 feeInMToken);
/**
* @param caller function caller (msg.sender)
* @param newfee new fiat fee percent 1% = 100
*/
event SetFiatAdditionalFee(address indexed caller, uint256 newfee);
/**
* @param caller function caller (msg.sender)
* @param redeemer new address of request redeemer
*/
event SetRequestRedeemer(address indexed caller, address redeemer);
/**
* @notice redeem mToken to tokenOut if daily limit and allowance not exceeded
* Burns mTBILL from the user.
* Transfers fee in mToken to feeReceiver
* Transfers tokenOut to user.
* @param tokenOut stable coin token address to redeem to
* @param amountMTokenIn amount of mTBILL to redeem (decimals 18)
* @param minReceiveAmount minimum expected amount of tokenOut to receive (decimals 18)
*/
function redeemInstant(
address tokenOut,
uint256 amountMTokenIn,
uint256 minReceiveAmount
) external;
/**
* @notice creating redeem request if tokenOut not fiat
* Transfers amount in mToken to contract
* Transfers fee in mToken to feeReceiver
* @param tokenOut stable coin token address to redeem to
* @param amountMTokenIn amount of mToken to redeem (decimals 18)
* @return request id
*/
function redeemRequest(address tokenOut, uint256 amountMTokenIn)
external
returns (uint256);
/**
* @notice creating redeem request if tokenOut is fiat
* Transfers amount in mToken to contract
* Transfers fee in mToken to feeReceiver
* @param amountMTokenIn amount of mToken to redeem (decimals 18)
* @return request id
*/
function redeemFiatRequest(uint256 amountMTokenIn)
external
returns (uint256);
/**
* @notice approving redeem request if not exceed tokenOut allowance
* Burns amount mToken from contract
* Transfers tokenOut to user
* Sets flag Processed
* @param requestId request id
* @param newMTokenRate new mToken rate inputted by vault admin
*/
function approveRequest(uint256 requestId, uint256 newMTokenRate) external;
/**
* @notice approving request if inputted token rate fit price diviation percent
* Burns amount mToken from contract
* Transfers tokenOut to user
* Sets flag Processed
* @param requestId request id
* @param newMTokenRate new mToken rate inputted by vault admin
*/
function safeApproveRequest(uint256 requestId, uint256 newMTokenRate)
external;
/**
* @notice rejecting request
* Sets request flag to Canceled.
* @param requestId request id
*/
function rejectRequest(uint256 requestId) external;
/**
* @notice set new min amount for fiat requests
* @param newValue new min amount
*/
function setMinFiatRedeemAmount(uint256 newValue) external;
/**
* @notice set fee amount in mToken for fiat requests
* @param feeInMToken fee amount in mToken
*/
function setFiatFlatFee(uint256 feeInMToken) external;
/**
* @notice set new fee percent for fiat requests
* @param newFee new fee percent 1% = 100
*/
function setFiatAdditionalFee(uint256 newFee) external;
/**
* @notice set address which is designated for standard redemptions, allowing tokens to be pulled from this address
* @param redeemer new address of request redeemer
*/
function setRequestRedeemer(address redeemer) external;
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import "./IRedemptionVault.sol";
/**
* @title IRedemptionVaultWithSwapper
* @author RedDuck Software
*/
interface IRedemptionVaultWithSwapper is IRedemptionVault {
/**
* @param caller caller address (msg.sender)
* @param provider new LP address
*/
event SetLiquidityProvider(
address indexed caller,
address indexed provider
);
/**
* @param caller caller address (msg.sender)
* @param vault new underlying vault for swapper
*/
event SetSwapperVault(address indexed caller, address indexed vault);
/**
* @notice sets new liquidity provider address
* @param provider new liquidity provider address
*/
function setLiquidityProvider(address provider) external;
/**
* @notice sets new underlying vault for swapper
* @param vault new underlying vault for swapper
*/
function setSwapperVault(address vault) 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 MHyperMidasAccessControlRoles.sol
* @notice Base contract that stores all roles descriptors for mHYPER contracts
* @author RedDuck Software
*/
abstract contract MHyperMidasAccessControlRoles {
/**
* @notice actor that can manage MHyperDepositVault
*/
bytes32 public constant M_HYPER_DEPOSIT_VAULT_ADMIN_ROLE =
keccak256("M_HYPER_DEPOSIT_VAULT_ADMIN_ROLE");
/**
* @notice actor that can manage MHyperRedemptionVault
*/
bytes32 public constant M_HYPER_REDEMPTION_VAULT_ADMIN_ROLE =
keccak256("M_HYPER_REDEMPTION_VAULT_ADMIN_ROLE");
/**
* @notice actor that can manage MHyperCustomAggregatorFeed and MHyperDataFeed
*/
bytes32 public constant M_HYPER_CUSTOM_AGGREGATOR_FEED_ADMIN_ROLE =
keccak256("M_HYPER_CUSTOM_AGGREGATOR_FEED_ADMIN_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/IRedemptionVault.sol";
import "./interfaces/IMTbill.sol";
import "./interfaces/IDataFeed.sol";
import "./abstract/ManageableVault.sol";
import "./access/Greenlistable.sol";
/**
* @title RedemptionVault
* @notice Smart contract that handles mTBILL redemptions
* @author RedDuck Software
*/
contract RedemptionVault is ManageableVault, IRedemptionVault {
using Counters for Counters.Counter;
/**
* @notice min amount for fiat requests
*/
uint256 public minFiatRedeemAmount;
/**
* @notice fee percent for fiat requests
*/
uint256 public fiatAdditionalFee;
/**
* @notice static fee in mToken for fiat requests
*/
uint256 public fiatFlatFee;
/**
* @notice mapping, requestId to request data
*/
mapping(uint256 => Request) public redeemRequests;
/**
* @notice address is designated for standard redemptions, allowing tokens to be pulled from this address
*/
address public requestRedeemer;
/**
* @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
* @param _fiatRedemptionInitParams params fiatAdditionalFee, fiatFlatFee, minFiatRedeemAmount
* @param _requestRedeemer address is designated for standard redemptions, allowing tokens to be pulled from this address
*/
function initialize(
address _ac,
MTokenInitParams calldata _mTokenInitParams,
ReceiversInitParams calldata _receiversInitParams,
InstantInitParams calldata _instantInitParams,
address _sanctionsList,
uint256 _variationTolerance,
uint256 _minAmount,
FiatRedeptionInitParams calldata _fiatRedemptionInitParams,
address _requestRedeemer
) external initializer {
__RedemptionVault_init(
_ac,
_mTokenInitParams,
_receiversInitParams,
_instantInitParams,
_sanctionsList,
_variationTolerance,
_minAmount,
_fiatRedemptionInitParams,
_requestRedeemer
);
}
// solhint-disable func-name-mixedcase
function __RedemptionVault_init(
address _ac,
MTokenInitParams calldata _mTokenInitParams,
ReceiversInitParams calldata _receiversInitParams,
InstantInitParams calldata _instantInitParams,
address _sanctionsList,
uint256 _variationTolerance,
uint256 _minAmount,
FiatRedeptionInitParams calldata _fiatRedemptionInitParams,
address _requestRedeemer
) internal onlyInitializing {
__ManageableVault_init(
_ac,
_mTokenInitParams,
_receiversInitParams,
_instantInitParams,
_sanctionsList,
_variationTolerance,
_minAmount
);
_validateFee(_fiatRedemptionInitParams.fiatAdditionalFee, false);
_validateAddress(_requestRedeemer, false);
minFiatRedeemAmount = _fiatRedemptionInitParams.minFiatRedeemAmount;
fiatAdditionalFee = _fiatRedemptionInitParams.fiatAdditionalFee;
fiatFlatFee = _fiatRedemptionInitParams.fiatFlatFee;
requestRedeemer = _requestRedeemer;
}
/**
* @inheritdoc IRedemptionVault
*/
function redeemInstant(
address tokenOut,
uint256 amountMTokenIn,
uint256 minReceiveAmount
)
external
virtual
whenFnNotPaused(this.redeemInstant.selector)
onlyGreenlisted(msg.sender)
onlyNotBlacklisted(msg.sender)
onlyNotSanctioned(msg.sender)
{
address user = msg.sender;
(
uint256 feeAmount,
uint256 amountMTokenWithoutFee
) = _calcAndValidateRedeem(user, tokenOut, amountMTokenIn, true, false);
_requireAndUpdateLimit(amountMTokenIn);
uint256 tokenDecimals = _tokenDecimals(tokenOut);
uint256 amountMTokenInCopy = amountMTokenIn;
address tokenOutCopy = tokenOut;
uint256 minReceiveAmountCopy = minReceiveAmount;
(uint256 amountMTokenInUsd, uint256 mTokenRate) = _convertMTokenToUsd(
amountMTokenInCopy
);
(uint256 amountTokenOut, uint256 tokenOutRate) = _convertUsdToToken(
amountMTokenInUsd,
tokenOutCopy
);
uint256 amountTokenOutWithoutFee = _truncate(
(amountMTokenWithoutFee * mTokenRate) / tokenOutRate,
tokenDecimals
);
require(
amountTokenOutWithoutFee >= minReceiveAmountCopy,
"RV: minReceiveAmount > actual"
);
_requireAndUpdateAllowance(tokenOutCopy, amountTokenOut);
mToken.burn(user, amountMTokenWithoutFee);
if (feeAmount > 0)
_tokenTransferFromUser(address(mToken), feeReceiver, feeAmount, 18);
_tokenTransferToUser(
tokenOutCopy,
user,
amountTokenOutWithoutFee,
tokenDecimals
);
emit RedeemInstant(
user,
tokenOutCopy,
amountMTokenInCopy,
feeAmount,
amountTokenOutWithoutFee
);
}
/**
* @inheritdoc IRedemptionVault
*/
function redeemRequest(address tokenOut, uint256 amountMTokenIn)
external
whenFnNotPaused(this.redeemRequest.selector)
onlyGreenlisted(msg.sender)
onlyNotBlacklisted(msg.sender)
onlyNotSanctioned(msg.sender)
returns (uint256 requestId)
{
require(tokenOut != MANUAL_FULLFILMENT_TOKEN, "RV: tokenOut == fiat");
return _redeemRequest(tokenOut, amountMTokenIn);
}
/**
* @inheritdoc IRedemptionVault
*/
function redeemFiatRequest(uint256 amountMTokenIn)
external
whenFnNotPaused(this.redeemFiatRequest.selector)
onlyAlwaysGreenlisted(msg.sender)
onlyNotBlacklisted(msg.sender)
onlyNotSanctioned(msg.sender)
returns (uint256 requestId)
{
return _redeemRequest(MANUAL_FULLFILMENT_TOKEN, amountMTokenIn);
}
/**
* @inheritdoc IRedemptionVault
*/
function approveRequest(uint256 requestId, uint256 newMTokenRate)
external
onlyVaultAdmin
{
_approveRequest(requestId, newMTokenRate, false);
emit ApproveRequest(requestId, newMTokenRate);
}
/**
* @inheritdoc IRedemptionVault
*/
function safeApproveRequest(uint256 requestId, uint256 newMTokenRate)
external
onlyVaultAdmin
{
_approveRequest(requestId, newMTokenRate, true);
emit SafeApproveRequest(requestId, newMTokenRate);
}
/**
* @inheritdoc IRedemptionVault
*/
function rejectRequest(uint256 requestId) external onlyVaultAdmin {
Request memory request = redeemRequests[requestId];
_validateRequest(request.sender, request.status);
redeemRequests[requestId].status = RequestStatus.Canceled;
emit RejectRequest(requestId, request.sender);
}
/**
* @inheritdoc IRedemptionVault
*/
function setMinFiatRedeemAmount(uint256 newValue) external onlyVaultAdmin {
minFiatRedeemAmount = newValue;
emit SetMinFiatRedeemAmount(msg.sender, newValue);
}
/**
* @inheritdoc IRedemptionVault
*/
function setFiatFlatFee(uint256 feeInMToken) external onlyVaultAdmin {
fiatFlatFee = feeInMToken;
emit SetFiatFlatFee(msg.sender, feeInMToken);
}
/**
* @inheritdoc IRedemptionVault
*/
function setFiatAdditionalFee(uint256 newFee) external onlyVaultAdmin {
_validateFee(newFee, false);
fiatAdditionalFee = newFee;
emit SetFiatAdditionalFee(msg.sender, newFee);
}
/**
* @inheritdoc IRedemptionVault
*/
function setRequestRedeemer(address redeemer) external onlyVaultAdmin {
_validateAddress(redeemer, false);
requestRedeemer = redeemer;
emit SetRequestRedeemer(msg.sender, redeemer);
}
/**
* @inheritdoc ManageableVault
*/
function vaultRole() public pure virtual override returns (bytes32) {
return REDEMPTION_VAULT_ADMIN_ROLE;
}
/**
* @notice validates approve
* burns amount from contract
* transfer tokenOut to user if not fiat
* sets flag Processed
* @param requestId request id
* @param newMTokenRate new mToken rate
* @param isSafe new mToken rate
*/
function _approveRequest(
uint256 requestId,
uint256 newMTokenRate,
bool isSafe
) internal {
Request memory request = redeemRequests[requestId];
_validateRequest(request.sender, request.status);
if (isSafe) {
_requireVariationTolerance(request.mTokenRate, newMTokenRate);
}
mToken.burn(address(this), request.amountMToken);
bool isFiat = request.tokenOut == MANUAL_FULLFILMENT_TOKEN;
uint256 tokenDecimals = isFiat ? 18 : _tokenDecimals(request.tokenOut);
uint256 amountTokenOutWithoutFee = _truncate(
(request.amountMToken * newMTokenRate) / request.tokenOutRate,
tokenDecimals
);
_requireAndUpdateAllowance(request.tokenOut, amountTokenOutWithoutFee);
if (!isFiat) {
_tokenTransferFromTo(
request.tokenOut,
requestRedeemer,
request.sender,
amountTokenOutWithoutFee,
tokenDecimals
);
}
request.status = RequestStatus.Processed;
request.mTokenRate = newMTokenRate;
redeemRequests[requestId] = request;
}
/**
* @notice validates request
* if exist
* if not processed
* @param sender sender address
* @param status request status
*/
function _validateRequest(address sender, RequestStatus status)
internal
pure
{
require(sender != address(0), "RV: request not exist");
require(status == RequestStatus.Pending, "RV: request not pending");
}
/**
* @notice Creating request depends on tokenOut
* @param tokenOut tokenOut address
* @param amountMTokenIn amount of mToken (decimals 18)
*
* @return requestId request id
*/
function _redeemRequest(address tokenOut, uint256 amountMTokenIn)
internal
returns (uint256)
{
address user = msg.sender;
bool isFiat = tokenOut == MANUAL_FULLFILMENT_TOKEN;
(
uint256 feeAmount,
uint256 amountMTokenWithoutFee
) = _calcAndValidateRedeem(
user,
tokenOut,
amountMTokenIn,
false,
isFiat
);
address tokenOutCopy = tokenOut;
// assigning the default value which is gonna be used
// only for fiat redemptions
uint256 tokenOutRate = 1e18;
if (!isFiat) {
TokenConfig storage config = tokensConfig[tokenOutCopy];
tokenOutRate = _getTokenRate(config.dataFeed, config.stable);
}
uint256 amountMTokenInCopy = amountMTokenIn;
uint256 mTokenRate = mTokenDataFeed.getDataInBase18();
_tokenTransferFromUser(
address(mToken),
address(this),
amountMTokenWithoutFee,
18 // mToken always have 18 decimals
);
if (feeAmount > 0)
_tokenTransferFromUser(address(mToken), feeReceiver, feeAmount, 18);
uint256 requestId = currentRequestId.current();
currentRequestId.increment();
redeemRequests[requestId] = Request({
sender: user,
tokenOut: tokenOutCopy,
status: RequestStatus.Pending,
amountMToken: amountMTokenWithoutFee,
mTokenRate: mTokenRate,
tokenOutRate: tokenOutRate
});
emit RedeemRequest(
requestId,
user,
tokenOutCopy,
amountMTokenInCopy,
feeAmount
);
return requestId;
}
/**
* @dev calculates tokenOut amount from USD amount
* @param amountUsd amount of USD (decimals 18)
* @param tokenOut tokenOut address
*
* @return amountToken converted USD to tokenOut
* @return tokenRate conversion rate
*/
function _convertUsdToToken(uint256 amountUsd, address tokenOut)
internal
view
returns (uint256 amountToken, uint256 tokenRate)
{
require(amountUsd > 0, "RV: amount zero");
TokenConfig storage tokenConfig = tokensConfig[tokenOut];
tokenRate = _getTokenRate(tokenConfig.dataFeed, tokenConfig.stable);
require(tokenRate > 0, "RV: rate zero");
amountToken = (amountUsd * (10**18)) / tokenRate;
}
/**
* @dev calculates USD amount from mToken amount
* @param amountMToken amount of mToken (decimals 18)
*
* @return amountUsd converted amount to USD
* @return mTokenRate conversion rate
*/
function _convertMTokenToUsd(uint256 amountMToken)
internal
view
returns (uint256 amountUsd, uint256 mTokenRate)
{
require(amountMToken > 0, "RV: amount zero");
mTokenRate = _getTokenRate(address(mTokenDataFeed), false);
require(mTokenRate > 0, "RV: rate zero");
amountUsd = (amountMToken * mTokenRate) / (10**18);
}
/**
* @dev validate redeem and calculate fee
* @param user user address
* @param tokenOut tokenOut address
* @param amountMTokenIn mToken amount (decimals 18)
* @param isInstant is instant operation
* @param isFiat is fiat operation
*
* @return feeAmount fee amount in mToken
* @return amountMTokenWithoutFee mToken amount without fee
*/
function _calcAndValidateRedeem(
address user,
address tokenOut,
uint256 amountMTokenIn,
bool isInstant,
bool isFiat
)
internal
view
returns (uint256 feeAmount, uint256 amountMTokenWithoutFee)
{
require(amountMTokenIn > 0, "RV: invalid amount");
if (!isFreeFromMinAmount[user]) {
uint256 minRedeemAmount = isFiat ? minFiatRedeemAmount : minAmount;
require(minRedeemAmount <= amountMTokenIn, "RV: amount < min");
}
feeAmount = _getFeeAmount(
user,
tokenOut,
amountMTokenIn,
isInstant,
isFiat ? fiatAdditionalFee : 0
);
if (isFiat) {
require(
tokenOut == MANUAL_FULLFILMENT_TOKEN,
"RV: tokenOut != fiat"
);
if (!waivedFeeRestriction[user]) feeAmount += fiatFlatFee;
} else {
_requireTokenExists(tokenOut);
}
require(amountMTokenIn > feeAmount, "RV: amountMTokenIn < fee");
amountMTokenWithoutFee = amountMTokenIn - feeAmount;
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import {IERC20Upgradeable as IERC20} from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import {SafeERC20Upgradeable as SafeERC20} from "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import "./RedemptionVault.sol";
import "./interfaces/IRedemptionVault.sol";
import "./interfaces/IRedemptionVaultWithSwapper.sol";
import "./libraries/DecimalsCorrectionLibrary.sol";
/**
* @title RedemptionVaultWithSwapper
* @notice Smart contract that handles mToken redemption.
* In case of insufficient liquidity it uses a RV from a different
* Midas product to fulfill instant redemption.
* @dev mToken1 - is a main mToken of this vault
* mToken2 - is a token of a second vault that is triggered when
* current vault don`t have enough liquidity
* @author RedDuck Software
*/
contract RedemptionVaultWithSwapper is
IRedemptionVaultWithSwapper,
RedemptionVault
{
using DecimalsCorrectionLibrary for uint256;
using SafeERC20 for IERC20;
/**
* @dev added second gap here to match the storage layout
* from the previous contracts inheritance tree
*/
uint256[50] private ___gap;
/**
* @notice mToken1 redemption vault
* @dev The naming was not altered to maintain
* compatibility with the currently deployed contracts.
*/
IRedemptionVault public mTbillRedemptionVault;
address public liquidityProvider;
/**
* @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 mToken1
* @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
* @param _fiatRedemptionInitParams params fiatAdditionalFee, fiatFlatFee, minFiatRedeemAmount
* @param _requestRedeemer address is designated for standard redemptions, allowing tokens to be pulled from this address
* @param _mTbillRedemptionVault mToken2 redemptionVault address
* @param _liquidityProvider liquidity provider for pull mToken2
*/
function initialize(
address _ac,
MTokenInitParams calldata _mTokenInitParams,
ReceiversInitParams calldata _receiversInitParams,
InstantInitParams calldata _instantInitParams,
address _sanctionsList,
uint256 _variationTolerance,
uint256 _minAmount,
FiatRedeptionInitParams calldata _fiatRedemptionInitParams,
address _requestRedeemer,
address _mTbillRedemptionVault,
address _liquidityProvider
) external initializer {
__RedemptionVault_init(
_ac,
_mTokenInitParams,
_receiversInitParams,
_instantInitParams,
_sanctionsList,
_variationTolerance,
_minAmount,
_fiatRedemptionInitParams,
_requestRedeemer
);
_validateAddress(_mTbillRedemptionVault, true);
_validateAddress(_liquidityProvider, false);
mTbillRedemptionVault = IRedemptionVault(_mTbillRedemptionVault);
liquidityProvider = _liquidityProvider;
}
/**
* @notice redeem mToken1 to tokenOut if daily limit and allowance not exceeded
* If contract don't have enough tokenOut, mToken1 will swap to mToken2 and redeem on mToken2 vault
* Burns mToken1 from the user, if swap need mToken1 just tranfers to contract.
* Transfers fee in mToken1 to feeReceiver
* Transfers tokenOut to user.
* @param tokenOut token out address
* @param amountMTokenIn amount of mToken1 to redeem
* @param minReceiveAmount minimum expected amount of tokenOut to receive (decimals 18)
*/
function redeemInstant(
address tokenOut,
uint256 amountMTokenIn,
uint256 minReceiveAmount
)
external
override(IRedemptionVault, RedemptionVault)
whenFnNotPaused(this.redeemInstant.selector)
onlyGreenlisted(msg.sender)
onlyNotBlacklisted(msg.sender)
onlyNotSanctioned(msg.sender)
{
address user = msg.sender;
(
uint256 feeAmount,
uint256 amountMTokenWithoutFee
) = _calcAndValidateRedeem(user, tokenOut, amountMTokenIn, true, false);
uint256 tokenDecimals = _tokenDecimals(tokenOut);
uint256 amountMTokenInCopy = amountMTokenIn;
address tokenOutCopy = tokenOut;
uint256 minReceiveAmountCopy = minReceiveAmount;
(uint256 amountMTokenInUsd, uint256 mTokenRate) = _convertMTokenToUsd(
amountMTokenInCopy
);
(uint256 amountTokenOut, uint256 tokenOutRate) = _convertUsdToToken(
amountMTokenInUsd,
tokenOutCopy
);
uint256 amountTokenOutWithoutFee = _truncate(
(amountMTokenWithoutFee * mTokenRate) / tokenOutRate,
tokenDecimals
);
require(
amountTokenOutWithoutFee >= minReceiveAmountCopy,
"RVS: minReceiveAmount > actual"
);
if (feeAmount > 0)
_tokenTransferFromUser(address(mToken), feeReceiver, feeAmount, 18);
uint256 contractTokenOutBalance = IERC20(tokenOutCopy).balanceOf(
address(this)
);
_requireAndUpdateLimit(amountMTokenInCopy);
_requireAndUpdateAllowance(tokenOutCopy, amountTokenOut);
if (
contractTokenOutBalance >=
amountTokenOutWithoutFee.convertFromBase18(tokenDecimals)
) {
mToken.burn(user, amountMTokenWithoutFee);
} else {
uint256 mTbillAmount = _swapMToken1ToMToken2(
amountMTokenWithoutFee
);
IERC20(mTbillRedemptionVault.mToken()).safeIncreaseAllowance(
address(mTbillRedemptionVault),
mTbillAmount
);
mTbillRedemptionVault.redeemInstant(
tokenOutCopy,
mTbillAmount,
minReceiveAmountCopy
);
uint256 contractTokenOutBalanceAfterRedeem = IERC20(tokenOutCopy)
.balanceOf(address(this));
amountTokenOutWithoutFee = (contractTokenOutBalanceAfterRedeem -
contractTokenOutBalance).convertToBase18(tokenDecimals);
}
_tokenTransferToUser(
tokenOutCopy,
user,
amountTokenOutWithoutFee,
tokenDecimals
);
emit RedeemInstant(
user,
tokenOutCopy,
amountMTokenInCopy,
feeAmount,
amountTokenOutWithoutFee
);
}
/**
* @inheritdoc IRedemptionVaultWithSwapper
*/
function setLiquidityProvider(address provider) external onlyVaultAdmin {
require(liquidityProvider != provider, "MRVS: already provider");
_validateAddress(provider, false);
liquidityProvider = provider;
emit SetLiquidityProvider(msg.sender, provider);
}
/**
* @inheritdoc IRedemptionVaultWithSwapper
*/
function setSwapperVault(address newVault) external onlyVaultAdmin {
require(
newVault != address(mTbillRedemptionVault),
"MRVS: already provider"
);
_validateAddress(newVault, true);
mTbillRedemptionVault = IRedemptionVault(newVault);
emit SetSwapperVault(msg.sender, newVault);
}
/**
* @notice Transfers mToken1 to liquidity provider
* Transfers mToken2 from liquidity provider to contract
* Returns amount on mToken2 using exchange rates
* @param mToken1Amount mToken1 token amount (decimals 18)
*/
function _swapMToken1ToMToken2(uint256 mToken1Amount)
internal
returns (uint256 mTokenAmount)
{
_tokenTransferFromUser(
address(mToken),
liquidityProvider,
mToken1Amount,
18
);
uint256 mTbillRate = mTbillRedemptionVault
.mTokenDataFeed()
.getDataInBase18();
uint256 mTokenRate = mTokenDataFeed.getDataInBase18();
mTokenAmount = (mToken1Amount * mTokenRate) / mTbillRate;
_tokenTransferFromTo(
address(mTbillRedemptionVault.mToken()),
liquidityProvider,
address(this),
mTokenAmount,
18
);
}
}{
"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":"newMTokenRate","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":false,"internalType":"bool","name":"enable","type":"bool"}],"name":"FreeFromMinAmount","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":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"tokenOut","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feeAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountTokenOut","type":"uint256"}],"name":"RedeemInstant","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":"tokenOut","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountMTokenIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feeAmount","type":"uint256"}],"name":"RedeemRequest","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":"newMTokenRate","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":"caller","type":"address"},{"indexed":false,"internalType":"uint256","name":"newfee","type":"uint256"}],"name":"SetFiatAdditionalFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"uint256","name":"feeInMToken","type":"uint256"}],"name":"SetFiatFlatFee","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":true,"internalType":"address","name":"provider","type":"address"}],"name":"SetLiquidityProvider","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":"newMinAmount","type":"uint256"}],"name":"SetMinFiatRedeemAmount","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"address","name":"redeemer","type":"address"}],"name":"SetRequestRedeemer","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":"vault","type":"address"}],"name":"SetSwapperVault","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_HYPER_CUSTOM_AGGREGATOR_FEED_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"M_HYPER_DEPOSIT_VAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"M_HYPER_REDEMPTION_VAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"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":"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":"newMTokenRate","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":[],"name":"feeReceiver","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fiatAdditionalFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fiatFlatFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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"},{"components":[{"internalType":"uint256","name":"fiatAdditionalFee","type":"uint256"},{"internalType":"uint256","name":"fiatFlatFee","type":"uint256"},{"internalType":"uint256","name":"minFiatRedeemAmount","type":"uint256"}],"internalType":"struct FiatRedeptionInitParams","name":"_fiatRedemptionInitParams","type":"tuple"},{"internalType":"address","name":"_requestRedeemer","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","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"},{"components":[{"internalType":"uint256","name":"fiatAdditionalFee","type":"uint256"},{"internalType":"uint256","name":"fiatFlatFee","type":"uint256"},{"internalType":"uint256","name":"minFiatRedeemAmount","type":"uint256"}],"internalType":"struct FiatRedeptionInitParams","name":"_fiatRedemptionInitParams","type":"tuple"},{"internalType":"address","name":"_requestRedeemer","type":"address"},{"internalType":"address","name":"_mTbillRedemptionVault","type":"address"},{"internalType":"address","name":"_liquidityProvider","type":"address"}],"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":"liquidityProvider","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mTbillRedemptionVault","outputs":[{"internalType":"contract IRedemptionVault","name":"","type":"address"}],"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":"minFiatRedeemAmount","outputs":[{"internalType":"uint256","name":"","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":"amountMTokenIn","type":"uint256"}],"name":"redeemFiatRequest","outputs":[{"internalType":"uint256","name":"requestId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenOut","type":"address"},{"internalType":"uint256","name":"amountMTokenIn","type":"uint256"},{"internalType":"uint256","name":"minReceiveAmount","type":"uint256"}],"name":"redeemInstant","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenOut","type":"address"},{"internalType":"uint256","name":"amountMTokenIn","type":"uint256"}],"name":"redeemRequest","outputs":[{"internalType":"uint256","name":"requestId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"redeemRequests","outputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"tokenOut","type":"address"},{"internalType":"enum RequestStatus","name":"status","type":"uint8"},{"internalType":"uint256","name":"amountMToken","type":"uint256"},{"internalType":"uint256","name":"mTokenRate","type":"uint256"},{"internalType":"uint256","name":"tokenOutRate","type":"uint256"}],"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":[],"name":"requestRedeemer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"},{"internalType":"uint256","name":"newMTokenRate","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":"uint256","name":"newFee","type":"uint256"}],"name":"setFiatAdditionalFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"feeInMToken","type":"uint256"}],"name":"setFiatFlatFee","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":"address","name":"provider","type":"address"}],"name":"setLiquidityProvider","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":"setMinFiatRedeemAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"redeemer","type":"address"}],"name":"setRequestRedeemer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newSanctionsList","type":"address"}],"name":"setSanctionsList","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newVault","type":"address"}],"name":"setSwapperVault","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":[],"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
60806040523480156200001157600080fd5b506200001c62000022565b620000e3565b600054610100900460ff16156200008f5760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff90811614620000e1576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b614c4580620000f36000396000f3fe608060405234801561001057600080fd5b50600436106104a05760003560e01c80638456cb591161026d578063c3b6f93911610151578063db74d8b5116100ce578063e624c4bc11610092578063e624c4bc14610ba3578063e85ba3e914610bb6578063eaf896fd14610c1c578063ec571c6a14610c24578063ef3d7e6c14610c38578063efdcd97414610c5f57600080fd5b8063db74d8b514610b44578063dd0081c714610b57578063e2c4d73714610b60578063e428877e14610b87578063e5b5019a14610b9a57600080fd5b8063d35780b411610115578063d35780b414610ae6578063d5f73f5c14610af9578063d7fd2bae14610b0c578063d9fbce8114610b30578063daddcb1614610ade57600080fd5b8063c3b6f93914610a98578063c47d51be14610aac578063c64b639114610ab6578063ca5e553e14610ac9578063cabccc7f14610ade57600080fd5b8063a1e99b05116101ea578063ad9e5649116101ae578063ad9e5649146109a2578063b3f00674146109b5578063bbae4086146109c9578063bc63773f146109ef578063bc979af614610a16578063bfc2d46a14610a8557600080fd5b8063a1e99b0514610943578063a217fddf1461096a578063a3ece89314610972578063a51254211461097c578063a8f9a71d1461098f57600080fd5b80638a0ae615116102315780638a0ae615146108fc5780638b53f75e1461090f578063978ff560146109225780639af40265146109315780639b2cb5d81461093957600080fd5b80638456cb591461089457806388a6de681461089c5780638978ac45146108af578063897b0637146108d657806389cbaae6146108e957600080fd5b80633ccdbb28116103945780635c975abb116103115780636dc69e03116102d55780636dc69e03146108255780637192de4b1461084657806373b7f8731461085057806373e9e01f14610863578063769bc79c146108775780637af5ca991461088a57600080fd5b80635c975abb146107a557806360348156146107b05780636254afb6146107d757806362b199c5146107eb5780636957463a1461081257600080fd5b80634a5971eb116103585780634a5971eb146107395780635300b4ba1461074c578063563b1dbf146107735780635ae2bfdb146107865780635b8bec551461079157600080fd5b80633ccdbb28146106d15780633f4ba83a146106e457806340985323146106ec578063476abc761461071357806349dc5e8d1461072657600080fd5b80632739c61a1161042257806334c24489116103e657806334c244891461067b5780633733337d1461068e5780633807be7d146106a15780633972183c146106b457806339dac34d146106be57600080fd5b80632739c61a146105f557806327abf5181461061c5780632c0a90a91461062f5780632d7788db1461064257806332b30cce1461065557600080fd5b806315b9598a1161046957806315b9598a1461057457806316683aa51461059b578063191f3a3e146105b05780631ed41163146105ba5780631fa1e8d4146105e157600080fd5b8062eafebf146104a5578063042da5ee146104df5780630b5a57bd14610513578063105ed2b21461053657806313007d5514610543575b600080fd5b6104cc7fa402581169544bec3e7f4fdb6f22f3658bc2f7bad057fd353bca877dc365e4ee81565b6040519081526020015b60405180910390f35b6105036104ed366004614423565b61016b6020526000908152604090205460ff1681565b60405190151581526020016104d6565b610503610521366004614440565b60976020526000908152604090205460ff1681565b60fc546105039060ff1681565b60005461055c906201000090046001600160a01b031681565b6040516001600160a01b0390911681526020016104d6565b6104cc7f77c5b782690f31cd39b1abf2448215259a688a75920040c399d96a676bd1999d81565b6105ae6105a9366004614423565b610c72565b005b6104cc6101a45481565b6104cc7fd2576bd6a4c5558421de15cb8ecdf4eb3282aac06b94d4f004e8cd0d00f3ebd881565b6101655461055c906001600160a01b031681565b6104cc7ff579edbdfe71eecb0735bb2656b6d53f5b7ee74072467c73e651c84bd4f94e1b81565b6105ae61062a366004614478565b610d2d565b6105ae61063d366004614495565b610dd2565b6105ae6106503660046144b7565b610e27565b7fa28974a2ecc1bcbd5ca81af766b1ac289c6579162f91147085217b9df96014426104cc565b6105ae6106893660046144b7565b610f2f565b6105ae61069c366004614440565b610f7d565b6105ae6106af366004614440565b611019565b6104cc6101675481565b6105ae6106cc3660046144d0565b6110d9565b6105ae6106df366004614509565b6111a0565b6105ae61121b565b6104cc7f2728bd32a7e1e24afac41a073e9c92dbb65527c9ec3baa2a8d5ee1d06c0fa77981565b6105ae610721366004614423565b611230565b6105ae610734366004614423565b611293565b6105ae610747366004614575565b6112eb565b6104cc7f2fdc6683bc8d03effec5b41d3834f28bd219e06ca0a6a26fc737e44b1c7889ff81565b6105ae6107813660046144b7565b6113c7565b610162546104cc9081565b61020d5461055c906001600160a01b031681565b60655460ff16610503565b6104cc7f82830251f95316fd2426de66b9298a230aae8afa718479a58eb92f667eaa8b2d81565b6101645461055c906001600160a01b031681565b6104cc7f548c7f0307ab2a7ea894e5c7e8c5353cc750bb9385ee2e945f189a9a83daa8ed81565b6105ae6108203660046144b7565b61140a565b6104cc6108333660046144b7565b6101686020526000908152604090205481565b6104cc61016a5481565b6105ae61085e3660046144b7565b61148e565b6101a75461055c906001600160a01b031681565b6105ae6108853660046144b7565b6114dc565b6104cc6101a35481565b6105ae61151f565b6105ae6108aa366004614495565b611532565b6104cc7f3d63b8d5d9c57f3a193bc98b7ebe0c3f62ed0859cbe92c95839f2c4948a3bbff81565b6105ae6108e43660046144b7565b61157b565b6105ae6108f7366004614423565b6115be565b6105ae61090a36600461461e565b611679565b6105ae61091d36600461464a565b611741565b6104cc670de0b6b3a764000081565b61055c600081565b6104cc61016f5481565b6104cc7fa6095bf1d1689844730f85ea9c1edf7d9e1566838e1baa0327271b6c8c31dd8a81565b6104cc600081565b6104cc6101a55481565b6105ae61098a366004614423565b611c60565b6105ae61099d366004614423565b611d1f565b6105ae6109b03660046144b7565b611d86565b6101695461055c906001600160a01b031681565b7fd2576bd6a4c5558421de15cb8ecdf4eb3282aac06b94d4f004e8cd0d00f3ebd86104cc565b6104cc7fa28974a2ecc1bcbd5ca81af766b1ac289c6579162f91147085217b9df960144281565b610a59610a24366004614423565b61016e6020526000908152604090208054600182015460028301546003909301546001600160a01b0390921692909160ff1684565b604080516001600160a01b039095168552602085019390935291830152151560608201526080016104d6565b6104cc610a9336600461461e565b611dd4565b6101635461055c906001600160a01b031681565b6104cc6101665481565b6105ae610ac436600461467f565b611f4e565b610ad161207b565b6040516104d691906146d2565b6104cc61208d565b6105ae610af436600461471f565b612097565b6104cc610b073660046144b7565b6121bd565b610503610b1a366004614423565b6101706020526000908152604090205460ff1681565b61020c5461055c906001600160a01b031681565b6105ae610b5236600461461e565b6122de565b6104cc61271081565b6104cc7f57df534b215589c7ade8c8abe0978debf2ea95cf1d442550f94eec78a69d238e81565b6105ae610b95366004614423565b612351565b6104cc60001981565b6105ae610bb1366004614423565b612409565b610c0a610bc43660046144b7565b6101a660205260009081526040902080546001820154600283015460038401546004909401546001600160a01b039384169493831693600160a01b90930460ff16929086565b6040516104d696959493929190614806565b6104cc6124c4565b61012f5461055c906001600160a01b031681565b6104cc7f5375b38f2ad9c8c8833b90d06ab20e4199feca9d6a6c8f2369d8f717325f473281565b6105ae610c6d366004614423565b6124e8565b610c83610c7d6124c4565b3361254b565b6001600160a01b038116600090815261016b602052604090205460ff16610ce15760405162461bcd60e51b815260206004820152600d60248201526c13558e881b9bdd08199bdd5b99609a1b60448201526064015b60405180910390fd5b6001600160a01b038116600081815261016b6020526040808220805460ff19169055513392917f57c4a95f59c12f0d4d846443c2d54c7d97f1505080199522fca2819e65213ca291a350565b610d3633612619565b60fc5460ff1615158115151415610d885760405162461bcd60e51b8152602060048201526016602482015275474c3a2073616d6520656e61626c652073746174757360501b6044820152606401610cd8565b60fc805460ff191682151590811790915560405190815233907fa8434267b880129bc4ba30249aa4a2ac349e8997c699282a9f70562f0f152f54906020015b60405180910390a250565b610ddd610c7d6124c4565b610de98282600061264b565b817ff7d1fde87f32720fc30ce6847e0aae77e640b59bfac41b11b270358ccfa7a0ac82604051610e1b91815260200190565b60405180910390a25050565b610e32610c7d6124c4565b60008181526101a660209081526040808320815160c08101835281546001600160a01b039081168252600183015490811694820194909452929091830190600160a01b900460ff166002811115610e8b57610e8b6147f0565b6002811115610e9c57610e9c6147f0565b815260200160028201548152602001600382015481526020016004820154815250509050610ed2816000015182604001516128ab565b60008281526101a66020526040808220600101805460ff60a01b1916600160a11b179055825190516001600160a01b039091169184917ece63cc55966b103e4f4cb39f3426cb91718ad4f8eb4ad08c14a7ee749d81579190a35050565b610f3a610c7d6124c4565b610f4581600161295a565b61016a81905560405181815233907f018be394ba93a0dbca235443cfdc7173b2479180ad766083ce05199fbf3fc62490602001610dc7565b610f88610c7d61208d565b6001600160e01b0319811660009081526097602052604090205460ff1615610fc25760405162461bcd60e51b8152600401610cd89061485f565b6001600160e01b03198116600081815260976020908152604091829020805460ff19166001179055905191825233917f2278e547293e53a66144c1743877f8388ac3101bd21cfd7c7f4ce8c15c14f5c19101610dc7565b611024610c7d61208d565b6001600160e01b0319811660009081526097602052604090205460ff166110855760405162461bcd60e51b815260206004820152601560248201527414185d5cd8589b194e88199b881d5b9c185d5cd959605a1b6044820152606401610cd8565b6001600160e01b03198116600081815260976020908152604091829020805460ff19169055905191825233917f929135cc6324f958693bb5f24a4dbc226a83c721523fc2785545019a3423b2d79101610dc7565b6110e4610c7d6124c4565b6001600160a01b0382166000908152610170602052604090205460ff16151581151514156111475760405162461bcd60e51b815260206004820152601060248201526f44563a20616c7265616479206672656560801b6044820152606401610cd8565b6001600160a01b03821660008181526101706020908152604091829020805460ff191685151590811790915591519182527f80f6f2f8801c6ac8fc60bf218b44fde97744d8709f69281972ec5557c10226cc9101610e1b565b6111ab610c7d6124c4565b6111bf6001600160a01b03841682846129da565b806001600160a01b0316836001600160a01b0316336001600160a01b03167f9ca7c1e047552a8048d924a5a8d3c150eb861086a72a9100e5f19d1176c1b7468560405161120e91815260200190565b60405180910390a4505050565b611226610c7d61208d565b61122e612a3d565b565b61123b610c7d6124c4565b611246816001612a8f565b61016580546001600160a01b0319166001600160a01b03831690811790915560405133907fdb5a411e1a379f981ff6bc5284aa2c2522a9b8fd33a9db9ca19b34006cefbe9c90600090a350565b61129e610c7d61208d565b61012f80546001600160a01b0319166001600160a01b03831690811790915560405133907f7f0c791852a03e270d4c2b78bbd4b959bca234de8d1ccf27eee03afaeafe63c490600090a350565b600054610100900460ff161580801561130b5750600054600160ff909116105b806113255750303b158015611325575060005460ff166001145b6113415760405162461bcd60e51b8152600401610cd89061488c565b6000805460ff191660011790558015611364576000805461ff0019166101001790555b6113758a8a8a8a8a8a8a8a8a612b25565b80156113bb576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050505050565b6113d2610c7d6124c4565b6101a581905560405181815233907f72bae0b4c0979f93d77dce748bd8dfbc89d0f1cd524eee95367e3d2ce5eca93f90602001610dc7565b611415610c7d6124c4565b600081116114565760405162461bcd60e51b815260206004820152600e60248201526d4d563a206c696d6974207a65726f60901b6044820152606401610cd8565b61016781905560405181815233907f5e8309fc6b2360e7438bc53790b00913395fffa870f39043fe63ddc8a438a9b290602001610dc7565b611499610c7d6124c4565b6114a481600061295a565b6101a481905560405181815233907fa627d2a34207df740c6b90691350e2a762296cbf59affeb2282e6a54d631d4db90602001610dc7565b6114e7610c7d6124c4565b6101a381905560405181815233907f8855fe6f9cbc4052017b3546fa14e167c5af2daad7f1c64db7f897fbcfb657b090602001610dc7565b61152a610c7d61208d565b61122e612bb4565b61153d610c7d6124c4565b6115498282600161264b565b817f03ea09e71742c9c754c9746b3e671ecb27fc372e3d29c31bac0192458ffd9d4b82604051610e1b91815260200190565b611586610c7d6124c4565b61016f81905560405181815233907f57e764c1fef224e74706b109734513889970db6f1dde107b1bda66e10d80ca9b90602001610dc7565b6115c9610c7d6124c4565b61020c546001600160a01b03828116911614156116215760405162461bcd60e51b815260206004820152601660248201527526a92b299d1030b63932b0b23c90383937bb34b232b960511b6044820152606401610cd8565b61162c816001612a8f565b61020c80546001600160a01b0319166001600160a01b03831690811790915560405133907fd081462190bc4f588c3e60685e37e27b800f5ac8b62c3edd7eecba5d1cecb9d590600090a350565b611684610c7d6124c4565b6001600160a01b0382161561169c5761169c82612bf1565b600081116116e15760405162461bcd60e51b81526020600482015260126024820152714d563a207a65726f20616c6c6f77616e636560701b6044820152606401610cd8565b6001600160a01b038216600081815261016e602052604090819020600201839055513391907ff7273742887a46d8b97d83d1d12b6d8d8e6d21d814072369e2f4b355690221d7906117359085815260200190565b60405180910390a35050565b6345a9fbaf60e11b611751612c43565b6001600160e01b0319811660009081526097602052604090205460ff161561178b5760405162461bcd60e51b8152600401610cd89061485f565b60fc54339060ff16156117a1576117a181612c89565b336117ab81612caf565b61012f5433906001600160a01b031680156118565760405163df592f7d60e01b81526001600160a01b03838116600483015282169063df592f7d9060240160206040518083038186803b15801561180157600080fd5b505afa158015611815573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061183991906148da565b156118565760405162461bcd60e51b8152600401610cd8906148f7565b33600080611868838c8c600185612cdb565b9150915060006118778c612eb7565b60ff1690508a8c8b60008061188b85612f30565b9150915060008061189c8487612ff3565b909250905060006118c1826118b1868d614936565b6118bb9190614955565b8a6130d3565b9050858110156119135760405162461bcd60e51b815260206004820152601e60248201527f5256533a206d696e52656365697665416d6f756e74203e2061637475616c00006044820152606401610cd8565b8a1561193a57610163546101695461193a916001600160a01b0390811691168d60126130ea565b6040516370a0823160e01b81523060048201526000906001600160a01b038916906370a082319060240160206040518083038186803b15801561197c57600080fd5b505afa158015611990573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119b49190614977565b90506119bf8961313c565b6119c988856131c6565b6119d3828b61326f565b8110611a455761016354604051632770a7eb60e21b81526001600160a01b038f81166004830152602482018e905290911690639dc29fac90604401600060405180830381600087803b158015611a2857600080fd5b505af1158015611a3c573d6000803e3d6000fd5b50505050611bec565b6000611a508c61327d565b61020c546040805163c3b6f93960e01b81529051929350611ae9926001600160a01b03909216918491839163c3b6f93991600480820192602092909190829003018186803b158015611aa157600080fd5b505afa158015611ab5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ad99190614990565b6001600160a01b031691906134da565b61020c546040516345a9fbaf60e11b81526001600160a01b038b8116600483015260248201849052604482018b905290911690638b53f75e90606401600060405180830381600087803b158015611b3f57600080fd5b505af1158015611b53573d6000803e3d6000fd5b50506040516370a0823160e01b8152306004820152600092506001600160a01b038c1691506370a082319060240160206040518083038186803b158015611b9957600080fd5b505afa158015611bad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bd19190614977565b9050611be78c611be185846149ad565b9061359c565b935050505b611bf8888e848d6135aa565b604080518a8152602081018e90529081018390526001600160a01b03808a1691908f16907f1af12536d161c2c30ad907b0abe442f94c4a7824f2463585b3fc893275247cce9060600160405180910390a3505050505050505050505050505050505050505050565b611c6b610c7d6124c4565b611c7761016c826135f4565b611cb45760405162461bcd60e51b815260206004820152600e60248201526d4d563a206e6f742065786973747360901b6044820152606401610cd8565b6001600160a01b038116600081815261016e602052604080822080546001600160a01b03191681556001810183905560028101839055600301805460ff19169055513392917f652fa2f5d587d3f1c189df0081b7bf3121f47d51d5471bf58d7d2c8a084894c391a350565b611d2a610c7d6124c4565b611d35816000612a8f565b6101a780546001600160a01b0319166001600160a01b03831690811790915560405190815233907f5059e224ac539671fe0261fc6672c365607aa98da29c849726ac5956902221b490602001610dc7565b611d91610c7d6124c4565b611d9c81600061295a565b61016681905560405181815233907f45acc8bd6ebd6fbb59ce049b682c124aeccc93c468fcf60fecf61340e86e79d390602001610dc7565b6000635fe16a3560e11b611de6612c43565b6001600160e01b0319811660009081526097602052604090205460ff1615611e205760405162461bcd60e51b8152600401610cd89061485f565b60fc54339060ff1615611e3657611e3681612c89565b33611e4081612caf565b61012f5433906001600160a01b03168015611eeb5760405163df592f7d60e01b81526001600160a01b03838116600483015282169063df592f7d9060240160206040518083038186803b158015611e9657600080fd5b505afa158015611eaa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ece91906148da565b15611eeb5760405162461bcd60e51b8152600401610cd8906148f7565b6001600160a01b038816611f385760405162461bcd60e51b815260206004820152601460248201527314958e881d1bdad95b93dd5d080f4f48199a585d60621b6044820152606401610cd8565b611f428888613609565b98975050505050505050565b611f59610c7d6124c4565b611f6561016c85613889565b611fa55760405162461bcd60e51b815260206004820152601160248201527013558e88185b1c9958591e481859191959607a1b6044820152606401610cd8565b611fb0836000612a8f565b611fbb82600061295a565b604080516080810182526001600160a01b038581168083526020808401878152600019858701908152871515606087018181528c8716600081815261016e87528a9020985189546001600160a01b0319169816979097178855925160018801559051600287015590516003909501805460ff19169515159590951790945584518781529081019390935292909133917f619139d13e799b88ce56bff114b5510808a19ea7440710070ef78528a05ed672910160405180910390a450505050565b606061208861016c61389e565b905090565b60006120886124c4565b600054610100900460ff16158080156120b75750600054600160ff909116105b806120d15750303b1580156120d1575060005460ff166001145b6120ed5760405162461bcd60e51b8152600401610cd89061488c565b6000805460ff191660011790558015612110576000805461ff0019166101001790555b6121218c8c8c8c8c8c8c8c8c612b25565b61212c836001612a8f565b612137826000612a8f565b61020c80546001600160a01b038086166001600160a01b03199283161790925561020d80549285169290911691909117905580156121af576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050505050505050565b600063357dcfd760e21b6121cf612c43565b6001600160e01b0319811660009081526097602052604090205460ff16156122095760405162461bcd60e51b8152600401610cd89061485f565b3361221381612c89565b3361221d81612caf565b61012f5433906001600160a01b031680156122c85760405163df592f7d60e01b81526001600160a01b03838116600483015282169063df592f7d9060240160206040518083038186803b15801561227357600080fd5b505afa158015612287573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122ab91906148da565b156122c85760405162461bcd60e51b8152600401610cd8906148f7565b6122d3600088613609565b979650505050505050565b6122e9610c7d6124c4565b6122f282612bf1565b6122fd81600061295a565b6001600160a01b038216600081815261016e602052604090819020600101839055513391907f1582567d288d96695cf3fe7280c630a4f1c82fc7e665e1db58468f2960fef869906117359085815260200190565b61235c610c7d6124c4565b6001600160a01b038116600090815261016b602052604090205460ff16156123ba5760405162461bcd60e51b815260206004820152601160248201527013558e88185b1c9958591e481859191959607a1b6044820152606401610cd8565b6001600160a01b038116600081815261016b6020526040808220805460ff19166001179055513392917f221f04b37331150bcfd05e2de362f50785c29ee4ab14f26d4495a51f3c02906091a350565b612414610c7d6124c4565b61020d546001600160a01b038281169116141561246c5760405162461bcd60e51b815260206004820152601660248201527526a92b299d1030b63932b0b23c90383937bb34b232b960511b6044820152606401610cd8565b612477816000612a8f565b61020d80546001600160a01b0319166001600160a01b03831690811790915560405133907f96210ef89e9bcdbde362a89b05013b89c67c586c9de1243edbf07af800c5da1290600090a350565b7fa6095bf1d1689844730f85ea9c1edf7d9e1566838e1baa0327271b6c8c31dd8a90565b6124f3610c7d6124c4565b6124fe816001612a8f565b61016980546001600160a01b0319166001600160a01b03831690811790915560405133907f1b092cca381ac00a07e1226c164f47c475d212f5e55699475a7f411811f77dd490600090a350565b600054604051632474521560e21b8152600481018490526001600160a01b03838116602483015262010000909204909116906391d148549060440160206040518083038186803b15801561259e57600080fd5b505afa1580156125b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125d691906148da565b6126155760405162461bcd60e51b815260206004820152601060248201526f574d41433a206861736e7420726f6c6560801b6044820152606401610cd8565b5050565b7fa28974a2ecc1bcbd5ca81af766b1ac289c6579162f91147085217b9df96014425b81612646828261254b565b505050565b60008381526101a660209081526040808320815160c08101835281546001600160a01b039081168252600183015490811694820194909452929091830190600160a01b900460ff1660028111156126a4576126a46147f0565b60028111156126b5576126b56147f0565b8152602001600282015481526020016003820154815260200160048201548152505090506126eb816000015182604001516128ab565b81156126ff576126ff8160800151846138ab565b610163546060820151604051632770a7eb60e21b815230600482015260248101919091526001600160a01b0390911690639dc29fac90604401600060405180830381600087803b15801561275257600080fd5b505af1158015612766573d6000803e3d6000fd5b5050505060208101516001600160a01b0316156000816127925761278d8360200151612eb7565b612795565b60125b60ff16905060006127c48460a001518786606001516127b49190614936565b6127be9190614955565b836130d3565b90506127d48460200151826131c6565b826127fa5760208401516101a75485516127fa92916001600160a01b031690848661393e565b600160408501819052506080840186905260008781526101a66020908152604091829020865181546001600160a01b039182166001600160a01b0319918216178355928801516001830180549190921693811684178255938801518894929390926001600160a81b03191617600160a01b83600281111561287d5761287d6147f0565b0217905550606082015160028201556080820151600382015560a09091015160049091015550505050505050565b6001600160a01b0382166128f95760405162461bcd60e51b815260206004820152601560248201527414958e881c995c5d595cdd081b9bdd08195e1a5cdd605a1b6044820152606401610cd8565b600081600281111561290d5761290d6147f0565b146126155760405162461bcd60e51b815260206004820152601760248201527f52563a2072657175657374206e6f742070656e64696e670000000000000000006044820152606401610cd8565b6127108211156129995760405162461bcd60e51b815260206004820152600a602482015269666565203e203130302560b01b6044820152606401610cd8565b801561261557600082116126155760405162461bcd60e51b81526020600482015260086024820152670666565203d3d20360c41b6044820152606401610cd8565b6040516001600160a01b03831660248201526044810182905261264690849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613991565b612a45613a66565b6065805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6001600160a01b038216612ad45760405162461bcd60e51b815260206004820152600c60248201526b7a65726f206164647265737360a01b6044820152606401610cd8565b8015612615576001600160a01b0382163014156126155760405162461bcd60e51b815260206004820152600f60248201526e696e76616c6964206164647265737360881b6044820152606401610cd8565b600054610100900460ff16612b4c5760405162461bcd60e51b8152600401610cd8906149c4565b612b5b89898989898989613aaf565b612b678235600061295a565b612b72816000612a8f565b60408201356101a35581356101a4556020909101356101a5556101a780546001600160a01b0319166001600160a01b0390921691909117905550505050505050565b612bbc612c43565b6065805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612a723390565b612bfd61016c82613c87565b612c405760405162461bcd60e51b81526020600482015260146024820152734d563a20746f6b656e206e6f742065786973747360601b6044820152606401610cd8565b50565b60655460ff161561122e5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610cd8565b7fd2576bd6a4c5558421de15cb8ecdf4eb3282aac06b94d4f004e8cd0d00f3ebd861263b565b7f548c7f0307ab2a7ea894e5c7e8c5353cc750bb9385ee2e945f189a9a83daa8ed816126468282613ca9565b60008060008511612d235760405162461bcd60e51b815260206004820152601260248201527114958e881a5b9d985b1a5908185b5bdd5b9d60721b6044820152606401610cd8565b6001600160a01b0387166000908152610170602052604090205460ff16612da057600083612d545761016f54612d59565b6101a3545b905085811115612d9e5760405162461bcd60e51b815260206004820152601060248201526f292b1d1030b6b7bab73a101e1036b4b760811b6044820152606401610cd8565b505b612dbc8787878787612db3576000613d72565b6101a454613d72565b91508215612e49576001600160a01b03861615612e125760405162461bcd60e51b815260206004820152601460248201527314958e881d1bdad95b93dd5d08084f48199a585d60621b6044820152606401610cd8565b6001600160a01b038716600090815261016b602052604090205460ff16612e44576101a554612e419083614a0f565b91505b612e52565b612e5286612bf1565b818511612ea15760405162461bcd60e51b815260206004820152601860248201527f52563a20616d6f756e744d546f6b656e496e203c2066656500000000000000006044820152606401610cd8565b612eab82866149ad565b90509550959350505050565b6000816001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015612ef257600080fd5b505afa158015612f06573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f2a9190614a27565b92915050565b60008060008311612f755760405162461bcd60e51b815260206004820152600f60248201526e52563a20616d6f756e74207a65726f60881b6044820152606401610cd8565b61016454612f8d906001600160a01b03166000613e13565b905060008111612fcf5760405162461bcd60e51b815260206004820152600d60248201526c52563a2072617465207a65726f60981b6044820152606401610cd8565b670de0b6b3a7640000612fe28285614936565b612fec9190614955565b9150915091565b600080600084116130385760405162461bcd60e51b815260206004820152600f60248201526e52563a20616d6f756e74207a65726f60881b6044820152606401610cd8565b6001600160a01b03808416600090815261016e6020526040902080546003820154919261306a9291169060ff16613e13565b9150600082116130ac5760405162461bcd60e51b815260206004820152600d60248201526c52563a2072617465207a65726f60981b6044820152606401610cd8565b816130bf86670de0b6b3a7640000614936565b6130c99190614955565b9250509250929050565b60006130e382611be1858261326f565b9392505050565b60006130f6838361326f565b9050613102818361359c565b83146131205760405162461bcd60e51b8152600401610cd890614a4a565b6131356001600160a01b038616338684613ea0565b5050505050565b600061314b6201518042614955565b600081815261016860205260408120549192509061316a908490614a0f565b9050610167548111156131b25760405162461bcd60e51b815260206004820152601060248201526f13558e88195e18d95959081b1a5b5a5d60821b6044820152606401610cd8565b600091825261016860205260409091205550565b6001600160a01b038216600090815261016e60205260409020600201546000198114156131f257505050565b818110156132395760405162461bcd60e51b81526020600482015260146024820152734d563a2065786365656420616c6c6f77616e636560601b6044820152606401610cd8565b6001600160a01b038316600090815261016e6020526040812060020180548492906132659084906149ad565b9091555050505050565b60006130e383601284613ed8565b6101635461020d546000916132a1916001600160a01b0391821691168460126130ea565b61020c546040805163312a57db60e11b815290516000926001600160a01b031691636254afb6916004808301926020929190829003018186803b1580156132e757600080fd5b505afa1580156132fb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061331f9190614990565b6001600160a01b031663636929056040518163ffffffff1660e01b815260040160206040518083038186803b15801561335757600080fd5b505afa15801561336b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061338f9190614977565b9050600061016460009054906101000a90046001600160a01b03166001600160a01b031663636929056040518163ffffffff1660e01b815260040160206040518083038186803b1580156133e257600080fd5b505afa1580156133f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061341a9190614977565b9050816134278286614936565b6134319190614955565b92506134d361020c60009054906101000a90046001600160a01b03166001600160a01b031663c3b6f9396040518163ffffffff1660e01b815260040160206040518083038186803b15801561348557600080fd5b505afa158015613499573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134bd9190614990565b61020d546001600160a01b03163086601261393e565b5050919050565b604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e9060440160206040518083038186803b15801561352557600080fd5b505afa158015613539573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061355d9190614977565b90506135968463095ea7b360e01b856135768686614a0f565b6040516001600160a01b0390921660248301526044820152606401612a06565b50505050565b60006130e383836012613ed8565b60006135b6838361326f565b90506135c2818361359c565b83146135e05760405162461bcd60e51b8152600401610cd890614a4a565b6131356001600160a01b03861685836129da565b60006130e3836001600160a01b038416613f50565b6000336001600160a01b0384161582806136268488888487612cdb565b909250905086670de0b6b3a764000084613670576001600160a01b03808316600090815261016e6020526040902080546003820154919261366c9291169060ff16613e13565b9150505b6101645460408051636369290560e01b815290518a926000926001600160a01b0390911691636369290591600480820192602092909190829003018186803b1580156136bb57600080fd5b505afa1580156136cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136f39190614977565b61016354909150613710906001600160a01b0316308760126130ea565b8515613737576101635461016954613737916001600160a01b0390811691168860126130ea565b60006137436101625490565b905061375461016280546001019055565b6040805160c0810182526001600160a01b03808c168252871660208201529081016000815260208082018990526040808301869052606090920187905260008481526101a68252829020835181546001600160a01b039182166001600160a01b0319918216178355928501516001830180549190921693811684178255938501519193919290916001600160a81b03191617600160a01b8360028111156137fd576137fd6147f0565b0217905550606082015181600201556080820151816003015560a08201518160040155905050846001600160a01b0316896001600160a01b0316827f55ba94d231fa70a45e82b0a1c6a60ef72e41bb2455385128ee5cf8d98c0c1c0e868b604051613872929190918252602082015260400190565b60405180910390a49b9a5050505050505050505050565b60006130e3836001600160a01b038416614043565b606060006130e383614092565b6000828210156138c4576138bf82846149ad565b6138ce565b6138ce83836149ad565b90506000836138df61271084614936565b6138e99190614955565b905061016a548111156135965760405162461bcd60e51b815260206004820152601a60248201527f4d563a2065786365656420707269636520646976696174696f6e0000000000006044820152606401610cd8565b600061394a838361326f565b9050613956818361359c565b83146139745760405162461bcd60e51b8152600401610cd890614a4a565b6139896001600160a01b038716868684613ea0565b505050505050565b60006139e6826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166140ee9092919063ffffffff16565b9050805160001480613a07575080806020019051810190613a0791906148da565b6126465760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610cd8565b60655460ff1661122e5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610cd8565b600054610100900460ff16613ad65760405162461bcd60e51b8152600401610cd8906149c4565b613aed613ae66020880188614423565b6000612a8f565b613b00613ae66040880160208901614423565b613b17613b106020870187614423565b6001612a8f565b613b2a613b106040870160208801614423565b6000846020013511613b6b5760405162461bcd60e51b815260206004820152600a6024820152691e995c9bc81b1a5b5a5d60b21b6044820152606401610cd8565b613b7682600161295a565b613b828435600061295a565b613b8f6020870187614423565b61016380546001600160a01b0319166001600160a01b0392909216919091179055613bb9876140fd565b613bc1614135565b613bc9614135565b613bd28361415c565b613bdf6020860186614423565b61016580546001600160a01b0319166001600160a01b0392909216919091179055613c106040860160208701614423565b61016980546001600160a01b0319166001600160a01b03929092169190911790558335610166556020808501356101675561016f82905561016a839055613c5d9060408801908801614423565b61016480546001600160a01b0319166001600160a01b039290921691909117905550505050505050565b6001600160a01b038116600090815260018301602052604081205415156130e3565b600054604051632474521560e21b8152600481018490526001600160a01b03838116602483015262010000909204909116906391d148549060440160206040518083038186803b158015613cfc57600080fd5b505afa158015613d10573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d3491906148da565b156126155760405162461bcd60e51b815260206004820152600e60248201526d574d41433a2068617320726f6c6560901b6044820152606401610cd8565b6001600160a01b038516600090815261016b602052604081205460ff1615613d9c57506000613e0a565b600082613dc657506001600160a01b038516600090815261016e6020526040902060010154613dc9565b50815b8315613de05761016654613ddd9082614a0f565b90505b612710811115613def57506127105b612710613dfc8287614936565b613e069190614955565b9150505b95945050505050565b600080836001600160a01b031663636929056040518163ffffffff1660e01b815260040160206040518083038186803b158015613e4f57600080fd5b505afa158015613e63573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e879190614977565b905082156130e357670de0b6b3a7640000915050612f2a565b6040516001600160a01b03808516602483015283166044820152606481018290526135969085906323b872dd60e01b90608401612a06565b600083613ee7575060006130e3565b81831415613ef65750826130e3565b600082841115613f2657613f0a83856149ad565b613f1590600a614b5c565b613f1f9086614955565b9050613f48565b613f3084846149ad565b613f3b90600a614b5c565b613f459086614936565b90505b949350505050565b60008181526001830160205260408120548015614039576000613f746001836149ad565b8554909150600090613f88906001906149ad565b9050818114613fed576000866000018281548110613fa857613fa8614b68565b9060005260206000200154905080876000018481548110613fcb57613fcb614b68565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080613ffe57613ffe614b7e565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050612f2a565b6000915050612f2a565b600081815260018301602052604081205461408a57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155612f2a565b506000612f2a565b6060816000018054806020026020016040519081016040528092919081815260200182805480156140e257602002820191906000526020600020905b8154815260200190600101908083116140ce575b50505050509050919050565b6060613f4884846000856141a6565b600054610100900460ff166141245760405162461bcd60e51b8152600401610cd8906149c4565b61412c614276565b612c40816142a5565b600054610100900460ff1661122e5760405162461bcd60e51b8152600401610cd8906149c4565b600054610100900460ff166141835760405162461bcd60e51b8152600401610cd8906149c4565b61012f80546001600160a01b0319166001600160a01b0392909216919091179055565b6060824710156142075760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610cd8565b600080866001600160a01b031685876040516142239190614bc0565b60006040518083038185875af1925050503d8060008114614260576040519150601f19603f3d011682016040523d82523d6000602084013e614265565b606091505b50915091506122d38783838761433b565b600054610100900460ff1661429d5760405162461bcd60e51b8152600401610cd8906149c4565b61122e6143b1565b600054610100900460ff166142cc5760405162461bcd60e51b8152600401610cd8906149c4565b6001600160a01b0381166143115760405162461bcd60e51b815260206004820152600c60248201526b7a65726f206164647265737360a01b6044820152606401610cd8565b600080546001600160a01b03909216620100000262010000600160b01b0319909216919091179055565b606083156143a75782516143a0576001600160a01b0385163b6143a05760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610cd8565b5081613f48565b613f4883836143e4565b600054610100900460ff166143d85760405162461bcd60e51b8152600401610cd8906149c4565b6065805460ff19169055565b8151156143f45781518083602001fd5b8060405162461bcd60e51b8152600401610cd89190614bdc565b6001600160a01b0381168114612c4057600080fd5b60006020828403121561443557600080fd5b81356130e38161440e565b60006020828403121561445257600080fd5b81356001600160e01b0319811681146130e357600080fd5b8015158114612c4057600080fd5b60006020828403121561448a57600080fd5b81356130e38161446a565b600080604083850312156144a857600080fd5b50508035926020909101359150565b6000602082840312156144c957600080fd5b5035919050565b600080604083850312156144e357600080fd5b82356144ee8161440e565b915060208301356144fe8161446a565b809150509250929050565b60008060006060848603121561451e57600080fd5b83356145298161440e565b92506020840135915060408401356145408161440e565b809150509250925092565b60006040828403121561455d57600080fd5b50919050565b60006060828403121561455d57600080fd5b60008060008060008060008060006101c08a8c03121561459457600080fd5b893561459f8161440e565b98506145ae8b60208c0161454b565b97506145bd8b60608c0161454b565b96506145cc8b60a08c0161454b565b955060e08a01356145dc8161440e565b94506101008a013593506101208a013592506145fc8b6101408c01614563565b91506101a08a013561460d8161440e565b809150509295985092959850929598565b6000806040838503121561463157600080fd5b823561463c8161440e565b946020939093013593505050565b60008060006060848603121561465f57600080fd5b833561466a8161440e565b95602085013595506040909401359392505050565b6000806000806080858703121561469557600080fd5b84356146a08161440e565b935060208501356146b08161440e565b92506040850135915060608501356146c78161446a565b939692955090935050565b6020808252825182820181905260009190848201906040850190845b818110156147135783516001600160a01b0316835292840192918401916001016146ee565b50909695505050505050565b60008060008060008060008060008060006102008c8e03121561474157600080fd5b8b3561474c8161440e565b9a5061475b8d60208e0161454b565b995061476a8d60608e0161454b565b98506147798d60a08e0161454b565b975060e08c01356147898161440e565b96506101008c013595506101208c013594506147a98d6101408e01614563565b93506101a08c01356147ba8161440e565b92506101c08c01356147cb8161440e565b91506101e08c01356147dc8161440e565b809150509295989b509295989b9093969950565b634e487b7160e01b600052602160045260246000fd5b6001600160a01b0387811682528616602082015260c081016003861061483c57634e487b7160e01b600052602160045260246000fd5b8560408301528460608301528360808301528260a0830152979650505050505050565b60208082526013908201527214185d5cd8589b194e88199b881c185d5cd959606a1b604082015260600190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6000602082840312156148ec57600080fd5b81516130e38161446a565b6020808252600f908201526e15d4d30e881cd85b98dd1a5bdb9959608a1b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b600081600019048311821515161561495057614950614920565b500290565b60008261497257634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121561498957600080fd5b5051919050565b6000602082840312156149a257600080fd5b81516130e38161440e565b6000828210156149bf576149bf614920565b500390565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60008219821115614a2257614a22614920565b500190565b600060208284031215614a3957600080fd5b815160ff811681146130e357600080fd5b6020808252601490820152734d563a20696e76616c696420726f756e64696e6760601b604082015260600190565b600181815b80851115614ab3578160001904821115614a9957614a99614920565b80851615614aa657918102915b93841c9390800290614a7d565b509250929050565b600082614aca57506001612f2a565b81614ad757506000612f2a565b8160018114614aed5760028114614af757614b13565b6001915050612f2a565b60ff841115614b0857614b08614920565b50506001821b612f2a565b5060208310610133831016604e8410600b8410161715614b36575081810a612f2a565b614b408383614a78565b8060001904821115614b5457614b54614920565b029392505050565b60006130e38383614abb565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b60005b83811015614baf578181015183820152602001614b97565b838111156135965750506000910152565b60008251614bd2818460208701614b94565b9190910192915050565b6020815260008251806020840152614bfb816040850160208701614b94565b601f01601f1916919091016040019291505056fea2646970667358221220fb02e7cdadb0b9dc1ec3934b82e5d8d98924b4ba6f8fe3a19b1938bd4a5620c164736f6c63430008090033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106104a05760003560e01c80638456cb591161026d578063c3b6f93911610151578063db74d8b5116100ce578063e624c4bc11610092578063e624c4bc14610ba3578063e85ba3e914610bb6578063eaf896fd14610c1c578063ec571c6a14610c24578063ef3d7e6c14610c38578063efdcd97414610c5f57600080fd5b8063db74d8b514610b44578063dd0081c714610b57578063e2c4d73714610b60578063e428877e14610b87578063e5b5019a14610b9a57600080fd5b8063d35780b411610115578063d35780b414610ae6578063d5f73f5c14610af9578063d7fd2bae14610b0c578063d9fbce8114610b30578063daddcb1614610ade57600080fd5b8063c3b6f93914610a98578063c47d51be14610aac578063c64b639114610ab6578063ca5e553e14610ac9578063cabccc7f14610ade57600080fd5b8063a1e99b05116101ea578063ad9e5649116101ae578063ad9e5649146109a2578063b3f00674146109b5578063bbae4086146109c9578063bc63773f146109ef578063bc979af614610a16578063bfc2d46a14610a8557600080fd5b8063a1e99b0514610943578063a217fddf1461096a578063a3ece89314610972578063a51254211461097c578063a8f9a71d1461098f57600080fd5b80638a0ae615116102315780638a0ae615146108fc5780638b53f75e1461090f578063978ff560146109225780639af40265146109315780639b2cb5d81461093957600080fd5b80638456cb591461089457806388a6de681461089c5780638978ac45146108af578063897b0637146108d657806389cbaae6146108e957600080fd5b80633ccdbb28116103945780635c975abb116103115780636dc69e03116102d55780636dc69e03146108255780637192de4b1461084657806373b7f8731461085057806373e9e01f14610863578063769bc79c146108775780637af5ca991461088a57600080fd5b80635c975abb146107a557806360348156146107b05780636254afb6146107d757806362b199c5146107eb5780636957463a1461081257600080fd5b80634a5971eb116103585780634a5971eb146107395780635300b4ba1461074c578063563b1dbf146107735780635ae2bfdb146107865780635b8bec551461079157600080fd5b80633ccdbb28146106d15780633f4ba83a146106e457806340985323146106ec578063476abc761461071357806349dc5e8d1461072657600080fd5b80632739c61a1161042257806334c24489116103e657806334c244891461067b5780633733337d1461068e5780633807be7d146106a15780633972183c146106b457806339dac34d146106be57600080fd5b80632739c61a146105f557806327abf5181461061c5780632c0a90a91461062f5780632d7788db1461064257806332b30cce1461065557600080fd5b806315b9598a1161046957806315b9598a1461057457806316683aa51461059b578063191f3a3e146105b05780631ed41163146105ba5780631fa1e8d4146105e157600080fd5b8062eafebf146104a5578063042da5ee146104df5780630b5a57bd14610513578063105ed2b21461053657806313007d5514610543575b600080fd5b6104cc7fa402581169544bec3e7f4fdb6f22f3658bc2f7bad057fd353bca877dc365e4ee81565b6040519081526020015b60405180910390f35b6105036104ed366004614423565b61016b6020526000908152604090205460ff1681565b60405190151581526020016104d6565b610503610521366004614440565b60976020526000908152604090205460ff1681565b60fc546105039060ff1681565b60005461055c906201000090046001600160a01b031681565b6040516001600160a01b0390911681526020016104d6565b6104cc7f77c5b782690f31cd39b1abf2448215259a688a75920040c399d96a676bd1999d81565b6105ae6105a9366004614423565b610c72565b005b6104cc6101a45481565b6104cc7fd2576bd6a4c5558421de15cb8ecdf4eb3282aac06b94d4f004e8cd0d00f3ebd881565b6101655461055c906001600160a01b031681565b6104cc7ff579edbdfe71eecb0735bb2656b6d53f5b7ee74072467c73e651c84bd4f94e1b81565b6105ae61062a366004614478565b610d2d565b6105ae61063d366004614495565b610dd2565b6105ae6106503660046144b7565b610e27565b7fa28974a2ecc1bcbd5ca81af766b1ac289c6579162f91147085217b9df96014426104cc565b6105ae6106893660046144b7565b610f2f565b6105ae61069c366004614440565b610f7d565b6105ae6106af366004614440565b611019565b6104cc6101675481565b6105ae6106cc3660046144d0565b6110d9565b6105ae6106df366004614509565b6111a0565b6105ae61121b565b6104cc7f2728bd32a7e1e24afac41a073e9c92dbb65527c9ec3baa2a8d5ee1d06c0fa77981565b6105ae610721366004614423565b611230565b6105ae610734366004614423565b611293565b6105ae610747366004614575565b6112eb565b6104cc7f2fdc6683bc8d03effec5b41d3834f28bd219e06ca0a6a26fc737e44b1c7889ff81565b6105ae6107813660046144b7565b6113c7565b610162546104cc9081565b61020d5461055c906001600160a01b031681565b60655460ff16610503565b6104cc7f82830251f95316fd2426de66b9298a230aae8afa718479a58eb92f667eaa8b2d81565b6101645461055c906001600160a01b031681565b6104cc7f548c7f0307ab2a7ea894e5c7e8c5353cc750bb9385ee2e945f189a9a83daa8ed81565b6105ae6108203660046144b7565b61140a565b6104cc6108333660046144b7565b6101686020526000908152604090205481565b6104cc61016a5481565b6105ae61085e3660046144b7565b61148e565b6101a75461055c906001600160a01b031681565b6105ae6108853660046144b7565b6114dc565b6104cc6101a35481565b6105ae61151f565b6105ae6108aa366004614495565b611532565b6104cc7f3d63b8d5d9c57f3a193bc98b7ebe0c3f62ed0859cbe92c95839f2c4948a3bbff81565b6105ae6108e43660046144b7565b61157b565b6105ae6108f7366004614423565b6115be565b6105ae61090a36600461461e565b611679565b6105ae61091d36600461464a565b611741565b6104cc670de0b6b3a764000081565b61055c600081565b6104cc61016f5481565b6104cc7fa6095bf1d1689844730f85ea9c1edf7d9e1566838e1baa0327271b6c8c31dd8a81565b6104cc600081565b6104cc6101a55481565b6105ae61098a366004614423565b611c60565b6105ae61099d366004614423565b611d1f565b6105ae6109b03660046144b7565b611d86565b6101695461055c906001600160a01b031681565b7fd2576bd6a4c5558421de15cb8ecdf4eb3282aac06b94d4f004e8cd0d00f3ebd86104cc565b6104cc7fa28974a2ecc1bcbd5ca81af766b1ac289c6579162f91147085217b9df960144281565b610a59610a24366004614423565b61016e6020526000908152604090208054600182015460028301546003909301546001600160a01b0390921692909160ff1684565b604080516001600160a01b039095168552602085019390935291830152151560608201526080016104d6565b6104cc610a9336600461461e565b611dd4565b6101635461055c906001600160a01b031681565b6104cc6101665481565b6105ae610ac436600461467f565b611f4e565b610ad161207b565b6040516104d691906146d2565b6104cc61208d565b6105ae610af436600461471f565b612097565b6104cc610b073660046144b7565b6121bd565b610503610b1a366004614423565b6101706020526000908152604090205460ff1681565b61020c5461055c906001600160a01b031681565b6105ae610b5236600461461e565b6122de565b6104cc61271081565b6104cc7f57df534b215589c7ade8c8abe0978debf2ea95cf1d442550f94eec78a69d238e81565b6105ae610b95366004614423565b612351565b6104cc60001981565b6105ae610bb1366004614423565b612409565b610c0a610bc43660046144b7565b6101a660205260009081526040902080546001820154600283015460038401546004909401546001600160a01b039384169493831693600160a01b90930460ff16929086565b6040516104d696959493929190614806565b6104cc6124c4565b61012f5461055c906001600160a01b031681565b6104cc7f5375b38f2ad9c8c8833b90d06ab20e4199feca9d6a6c8f2369d8f717325f473281565b6105ae610c6d366004614423565b6124e8565b610c83610c7d6124c4565b3361254b565b6001600160a01b038116600090815261016b602052604090205460ff16610ce15760405162461bcd60e51b815260206004820152600d60248201526c13558e881b9bdd08199bdd5b99609a1b60448201526064015b60405180910390fd5b6001600160a01b038116600081815261016b6020526040808220805460ff19169055513392917f57c4a95f59c12f0d4d846443c2d54c7d97f1505080199522fca2819e65213ca291a350565b610d3633612619565b60fc5460ff1615158115151415610d885760405162461bcd60e51b8152602060048201526016602482015275474c3a2073616d6520656e61626c652073746174757360501b6044820152606401610cd8565b60fc805460ff191682151590811790915560405190815233907fa8434267b880129bc4ba30249aa4a2ac349e8997c699282a9f70562f0f152f54906020015b60405180910390a250565b610ddd610c7d6124c4565b610de98282600061264b565b817ff7d1fde87f32720fc30ce6847e0aae77e640b59bfac41b11b270358ccfa7a0ac82604051610e1b91815260200190565b60405180910390a25050565b610e32610c7d6124c4565b60008181526101a660209081526040808320815160c08101835281546001600160a01b039081168252600183015490811694820194909452929091830190600160a01b900460ff166002811115610e8b57610e8b6147f0565b6002811115610e9c57610e9c6147f0565b815260200160028201548152602001600382015481526020016004820154815250509050610ed2816000015182604001516128ab565b60008281526101a66020526040808220600101805460ff60a01b1916600160a11b179055825190516001600160a01b039091169184917ece63cc55966b103e4f4cb39f3426cb91718ad4f8eb4ad08c14a7ee749d81579190a35050565b610f3a610c7d6124c4565b610f4581600161295a565b61016a81905560405181815233907f018be394ba93a0dbca235443cfdc7173b2479180ad766083ce05199fbf3fc62490602001610dc7565b610f88610c7d61208d565b6001600160e01b0319811660009081526097602052604090205460ff1615610fc25760405162461bcd60e51b8152600401610cd89061485f565b6001600160e01b03198116600081815260976020908152604091829020805460ff19166001179055905191825233917f2278e547293e53a66144c1743877f8388ac3101bd21cfd7c7f4ce8c15c14f5c19101610dc7565b611024610c7d61208d565b6001600160e01b0319811660009081526097602052604090205460ff166110855760405162461bcd60e51b815260206004820152601560248201527414185d5cd8589b194e88199b881d5b9c185d5cd959605a1b6044820152606401610cd8565b6001600160e01b03198116600081815260976020908152604091829020805460ff19169055905191825233917f929135cc6324f958693bb5f24a4dbc226a83c721523fc2785545019a3423b2d79101610dc7565b6110e4610c7d6124c4565b6001600160a01b0382166000908152610170602052604090205460ff16151581151514156111475760405162461bcd60e51b815260206004820152601060248201526f44563a20616c7265616479206672656560801b6044820152606401610cd8565b6001600160a01b03821660008181526101706020908152604091829020805460ff191685151590811790915591519182527f80f6f2f8801c6ac8fc60bf218b44fde97744d8709f69281972ec5557c10226cc9101610e1b565b6111ab610c7d6124c4565b6111bf6001600160a01b03841682846129da565b806001600160a01b0316836001600160a01b0316336001600160a01b03167f9ca7c1e047552a8048d924a5a8d3c150eb861086a72a9100e5f19d1176c1b7468560405161120e91815260200190565b60405180910390a4505050565b611226610c7d61208d565b61122e612a3d565b565b61123b610c7d6124c4565b611246816001612a8f565b61016580546001600160a01b0319166001600160a01b03831690811790915560405133907fdb5a411e1a379f981ff6bc5284aa2c2522a9b8fd33a9db9ca19b34006cefbe9c90600090a350565b61129e610c7d61208d565b61012f80546001600160a01b0319166001600160a01b03831690811790915560405133907f7f0c791852a03e270d4c2b78bbd4b959bca234de8d1ccf27eee03afaeafe63c490600090a350565b600054610100900460ff161580801561130b5750600054600160ff909116105b806113255750303b158015611325575060005460ff166001145b6113415760405162461bcd60e51b8152600401610cd89061488c565b6000805460ff191660011790558015611364576000805461ff0019166101001790555b6113758a8a8a8a8a8a8a8a8a612b25565b80156113bb576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050505050565b6113d2610c7d6124c4565b6101a581905560405181815233907f72bae0b4c0979f93d77dce748bd8dfbc89d0f1cd524eee95367e3d2ce5eca93f90602001610dc7565b611415610c7d6124c4565b600081116114565760405162461bcd60e51b815260206004820152600e60248201526d4d563a206c696d6974207a65726f60901b6044820152606401610cd8565b61016781905560405181815233907f5e8309fc6b2360e7438bc53790b00913395fffa870f39043fe63ddc8a438a9b290602001610dc7565b611499610c7d6124c4565b6114a481600061295a565b6101a481905560405181815233907fa627d2a34207df740c6b90691350e2a762296cbf59affeb2282e6a54d631d4db90602001610dc7565b6114e7610c7d6124c4565b6101a381905560405181815233907f8855fe6f9cbc4052017b3546fa14e167c5af2daad7f1c64db7f897fbcfb657b090602001610dc7565b61152a610c7d61208d565b61122e612bb4565b61153d610c7d6124c4565b6115498282600161264b565b817f03ea09e71742c9c754c9746b3e671ecb27fc372e3d29c31bac0192458ffd9d4b82604051610e1b91815260200190565b611586610c7d6124c4565b61016f81905560405181815233907f57e764c1fef224e74706b109734513889970db6f1dde107b1bda66e10d80ca9b90602001610dc7565b6115c9610c7d6124c4565b61020c546001600160a01b03828116911614156116215760405162461bcd60e51b815260206004820152601660248201527526a92b299d1030b63932b0b23c90383937bb34b232b960511b6044820152606401610cd8565b61162c816001612a8f565b61020c80546001600160a01b0319166001600160a01b03831690811790915560405133907fd081462190bc4f588c3e60685e37e27b800f5ac8b62c3edd7eecba5d1cecb9d590600090a350565b611684610c7d6124c4565b6001600160a01b0382161561169c5761169c82612bf1565b600081116116e15760405162461bcd60e51b81526020600482015260126024820152714d563a207a65726f20616c6c6f77616e636560701b6044820152606401610cd8565b6001600160a01b038216600081815261016e602052604090819020600201839055513391907ff7273742887a46d8b97d83d1d12b6d8d8e6d21d814072369e2f4b355690221d7906117359085815260200190565b60405180910390a35050565b6345a9fbaf60e11b611751612c43565b6001600160e01b0319811660009081526097602052604090205460ff161561178b5760405162461bcd60e51b8152600401610cd89061485f565b60fc54339060ff16156117a1576117a181612c89565b336117ab81612caf565b61012f5433906001600160a01b031680156118565760405163df592f7d60e01b81526001600160a01b03838116600483015282169063df592f7d9060240160206040518083038186803b15801561180157600080fd5b505afa158015611815573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061183991906148da565b156118565760405162461bcd60e51b8152600401610cd8906148f7565b33600080611868838c8c600185612cdb565b9150915060006118778c612eb7565b60ff1690508a8c8b60008061188b85612f30565b9150915060008061189c8487612ff3565b909250905060006118c1826118b1868d614936565b6118bb9190614955565b8a6130d3565b9050858110156119135760405162461bcd60e51b815260206004820152601e60248201527f5256533a206d696e52656365697665416d6f756e74203e2061637475616c00006044820152606401610cd8565b8a1561193a57610163546101695461193a916001600160a01b0390811691168d60126130ea565b6040516370a0823160e01b81523060048201526000906001600160a01b038916906370a082319060240160206040518083038186803b15801561197c57600080fd5b505afa158015611990573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119b49190614977565b90506119bf8961313c565b6119c988856131c6565b6119d3828b61326f565b8110611a455761016354604051632770a7eb60e21b81526001600160a01b038f81166004830152602482018e905290911690639dc29fac90604401600060405180830381600087803b158015611a2857600080fd5b505af1158015611a3c573d6000803e3d6000fd5b50505050611bec565b6000611a508c61327d565b61020c546040805163c3b6f93960e01b81529051929350611ae9926001600160a01b03909216918491839163c3b6f93991600480820192602092909190829003018186803b158015611aa157600080fd5b505afa158015611ab5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ad99190614990565b6001600160a01b031691906134da565b61020c546040516345a9fbaf60e11b81526001600160a01b038b8116600483015260248201849052604482018b905290911690638b53f75e90606401600060405180830381600087803b158015611b3f57600080fd5b505af1158015611b53573d6000803e3d6000fd5b50506040516370a0823160e01b8152306004820152600092506001600160a01b038c1691506370a082319060240160206040518083038186803b158015611b9957600080fd5b505afa158015611bad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bd19190614977565b9050611be78c611be185846149ad565b9061359c565b935050505b611bf8888e848d6135aa565b604080518a8152602081018e90529081018390526001600160a01b03808a1691908f16907f1af12536d161c2c30ad907b0abe442f94c4a7824f2463585b3fc893275247cce9060600160405180910390a3505050505050505050505050505050505050505050565b611c6b610c7d6124c4565b611c7761016c826135f4565b611cb45760405162461bcd60e51b815260206004820152600e60248201526d4d563a206e6f742065786973747360901b6044820152606401610cd8565b6001600160a01b038116600081815261016e602052604080822080546001600160a01b03191681556001810183905560028101839055600301805460ff19169055513392917f652fa2f5d587d3f1c189df0081b7bf3121f47d51d5471bf58d7d2c8a084894c391a350565b611d2a610c7d6124c4565b611d35816000612a8f565b6101a780546001600160a01b0319166001600160a01b03831690811790915560405190815233907f5059e224ac539671fe0261fc6672c365607aa98da29c849726ac5956902221b490602001610dc7565b611d91610c7d6124c4565b611d9c81600061295a565b61016681905560405181815233907f45acc8bd6ebd6fbb59ce049b682c124aeccc93c468fcf60fecf61340e86e79d390602001610dc7565b6000635fe16a3560e11b611de6612c43565b6001600160e01b0319811660009081526097602052604090205460ff1615611e205760405162461bcd60e51b8152600401610cd89061485f565b60fc54339060ff1615611e3657611e3681612c89565b33611e4081612caf565b61012f5433906001600160a01b03168015611eeb5760405163df592f7d60e01b81526001600160a01b03838116600483015282169063df592f7d9060240160206040518083038186803b158015611e9657600080fd5b505afa158015611eaa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ece91906148da565b15611eeb5760405162461bcd60e51b8152600401610cd8906148f7565b6001600160a01b038816611f385760405162461bcd60e51b815260206004820152601460248201527314958e881d1bdad95b93dd5d080f4f48199a585d60621b6044820152606401610cd8565b611f428888613609565b98975050505050505050565b611f59610c7d6124c4565b611f6561016c85613889565b611fa55760405162461bcd60e51b815260206004820152601160248201527013558e88185b1c9958591e481859191959607a1b6044820152606401610cd8565b611fb0836000612a8f565b611fbb82600061295a565b604080516080810182526001600160a01b038581168083526020808401878152600019858701908152871515606087018181528c8716600081815261016e87528a9020985189546001600160a01b0319169816979097178855925160018801559051600287015590516003909501805460ff19169515159590951790945584518781529081019390935292909133917f619139d13e799b88ce56bff114b5510808a19ea7440710070ef78528a05ed672910160405180910390a450505050565b606061208861016c61389e565b905090565b60006120886124c4565b600054610100900460ff16158080156120b75750600054600160ff909116105b806120d15750303b1580156120d1575060005460ff166001145b6120ed5760405162461bcd60e51b8152600401610cd89061488c565b6000805460ff191660011790558015612110576000805461ff0019166101001790555b6121218c8c8c8c8c8c8c8c8c612b25565b61212c836001612a8f565b612137826000612a8f565b61020c80546001600160a01b038086166001600160a01b03199283161790925561020d80549285169290911691909117905580156121af576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050505050505050565b600063357dcfd760e21b6121cf612c43565b6001600160e01b0319811660009081526097602052604090205460ff16156122095760405162461bcd60e51b8152600401610cd89061485f565b3361221381612c89565b3361221d81612caf565b61012f5433906001600160a01b031680156122c85760405163df592f7d60e01b81526001600160a01b03838116600483015282169063df592f7d9060240160206040518083038186803b15801561227357600080fd5b505afa158015612287573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122ab91906148da565b156122c85760405162461bcd60e51b8152600401610cd8906148f7565b6122d3600088613609565b979650505050505050565b6122e9610c7d6124c4565b6122f282612bf1565b6122fd81600061295a565b6001600160a01b038216600081815261016e602052604090819020600101839055513391907f1582567d288d96695cf3fe7280c630a4f1c82fc7e665e1db58468f2960fef869906117359085815260200190565b61235c610c7d6124c4565b6001600160a01b038116600090815261016b602052604090205460ff16156123ba5760405162461bcd60e51b815260206004820152601160248201527013558e88185b1c9958591e481859191959607a1b6044820152606401610cd8565b6001600160a01b038116600081815261016b6020526040808220805460ff19166001179055513392917f221f04b37331150bcfd05e2de362f50785c29ee4ab14f26d4495a51f3c02906091a350565b612414610c7d6124c4565b61020d546001600160a01b038281169116141561246c5760405162461bcd60e51b815260206004820152601660248201527526a92b299d1030b63932b0b23c90383937bb34b232b960511b6044820152606401610cd8565b612477816000612a8f565b61020d80546001600160a01b0319166001600160a01b03831690811790915560405133907f96210ef89e9bcdbde362a89b05013b89c67c586c9de1243edbf07af800c5da1290600090a350565b7fa6095bf1d1689844730f85ea9c1edf7d9e1566838e1baa0327271b6c8c31dd8a90565b6124f3610c7d6124c4565b6124fe816001612a8f565b61016980546001600160a01b0319166001600160a01b03831690811790915560405133907f1b092cca381ac00a07e1226c164f47c475d212f5e55699475a7f411811f77dd490600090a350565b600054604051632474521560e21b8152600481018490526001600160a01b03838116602483015262010000909204909116906391d148549060440160206040518083038186803b15801561259e57600080fd5b505afa1580156125b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125d691906148da565b6126155760405162461bcd60e51b815260206004820152601060248201526f574d41433a206861736e7420726f6c6560801b6044820152606401610cd8565b5050565b7fa28974a2ecc1bcbd5ca81af766b1ac289c6579162f91147085217b9df96014425b81612646828261254b565b505050565b60008381526101a660209081526040808320815160c08101835281546001600160a01b039081168252600183015490811694820194909452929091830190600160a01b900460ff1660028111156126a4576126a46147f0565b60028111156126b5576126b56147f0565b8152602001600282015481526020016003820154815260200160048201548152505090506126eb816000015182604001516128ab565b81156126ff576126ff8160800151846138ab565b610163546060820151604051632770a7eb60e21b815230600482015260248101919091526001600160a01b0390911690639dc29fac90604401600060405180830381600087803b15801561275257600080fd5b505af1158015612766573d6000803e3d6000fd5b5050505060208101516001600160a01b0316156000816127925761278d8360200151612eb7565b612795565b60125b60ff16905060006127c48460a001518786606001516127b49190614936565b6127be9190614955565b836130d3565b90506127d48460200151826131c6565b826127fa5760208401516101a75485516127fa92916001600160a01b031690848661393e565b600160408501819052506080840186905260008781526101a66020908152604091829020865181546001600160a01b039182166001600160a01b0319918216178355928801516001830180549190921693811684178255938801518894929390926001600160a81b03191617600160a01b83600281111561287d5761287d6147f0565b0217905550606082015160028201556080820151600382015560a09091015160049091015550505050505050565b6001600160a01b0382166128f95760405162461bcd60e51b815260206004820152601560248201527414958e881c995c5d595cdd081b9bdd08195e1a5cdd605a1b6044820152606401610cd8565b600081600281111561290d5761290d6147f0565b146126155760405162461bcd60e51b815260206004820152601760248201527f52563a2072657175657374206e6f742070656e64696e670000000000000000006044820152606401610cd8565b6127108211156129995760405162461bcd60e51b815260206004820152600a602482015269666565203e203130302560b01b6044820152606401610cd8565b801561261557600082116126155760405162461bcd60e51b81526020600482015260086024820152670666565203d3d20360c41b6044820152606401610cd8565b6040516001600160a01b03831660248201526044810182905261264690849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613991565b612a45613a66565b6065805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6001600160a01b038216612ad45760405162461bcd60e51b815260206004820152600c60248201526b7a65726f206164647265737360a01b6044820152606401610cd8565b8015612615576001600160a01b0382163014156126155760405162461bcd60e51b815260206004820152600f60248201526e696e76616c6964206164647265737360881b6044820152606401610cd8565b600054610100900460ff16612b4c5760405162461bcd60e51b8152600401610cd8906149c4565b612b5b89898989898989613aaf565b612b678235600061295a565b612b72816000612a8f565b60408201356101a35581356101a4556020909101356101a5556101a780546001600160a01b0319166001600160a01b0390921691909117905550505050505050565b612bbc612c43565b6065805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612a723390565b612bfd61016c82613c87565b612c405760405162461bcd60e51b81526020600482015260146024820152734d563a20746f6b656e206e6f742065786973747360601b6044820152606401610cd8565b50565b60655460ff161561122e5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610cd8565b7fd2576bd6a4c5558421de15cb8ecdf4eb3282aac06b94d4f004e8cd0d00f3ebd861263b565b7f548c7f0307ab2a7ea894e5c7e8c5353cc750bb9385ee2e945f189a9a83daa8ed816126468282613ca9565b60008060008511612d235760405162461bcd60e51b815260206004820152601260248201527114958e881a5b9d985b1a5908185b5bdd5b9d60721b6044820152606401610cd8565b6001600160a01b0387166000908152610170602052604090205460ff16612da057600083612d545761016f54612d59565b6101a3545b905085811115612d9e5760405162461bcd60e51b815260206004820152601060248201526f292b1d1030b6b7bab73a101e1036b4b760811b6044820152606401610cd8565b505b612dbc8787878787612db3576000613d72565b6101a454613d72565b91508215612e49576001600160a01b03861615612e125760405162461bcd60e51b815260206004820152601460248201527314958e881d1bdad95b93dd5d08084f48199a585d60621b6044820152606401610cd8565b6001600160a01b038716600090815261016b602052604090205460ff16612e44576101a554612e419083614a0f565b91505b612e52565b612e5286612bf1565b818511612ea15760405162461bcd60e51b815260206004820152601860248201527f52563a20616d6f756e744d546f6b656e496e203c2066656500000000000000006044820152606401610cd8565b612eab82866149ad565b90509550959350505050565b6000816001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015612ef257600080fd5b505afa158015612f06573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f2a9190614a27565b92915050565b60008060008311612f755760405162461bcd60e51b815260206004820152600f60248201526e52563a20616d6f756e74207a65726f60881b6044820152606401610cd8565b61016454612f8d906001600160a01b03166000613e13565b905060008111612fcf5760405162461bcd60e51b815260206004820152600d60248201526c52563a2072617465207a65726f60981b6044820152606401610cd8565b670de0b6b3a7640000612fe28285614936565b612fec9190614955565b9150915091565b600080600084116130385760405162461bcd60e51b815260206004820152600f60248201526e52563a20616d6f756e74207a65726f60881b6044820152606401610cd8565b6001600160a01b03808416600090815261016e6020526040902080546003820154919261306a9291169060ff16613e13565b9150600082116130ac5760405162461bcd60e51b815260206004820152600d60248201526c52563a2072617465207a65726f60981b6044820152606401610cd8565b816130bf86670de0b6b3a7640000614936565b6130c99190614955565b9250509250929050565b60006130e382611be1858261326f565b9392505050565b60006130f6838361326f565b9050613102818361359c565b83146131205760405162461bcd60e51b8152600401610cd890614a4a565b6131356001600160a01b038616338684613ea0565b5050505050565b600061314b6201518042614955565b600081815261016860205260408120549192509061316a908490614a0f565b9050610167548111156131b25760405162461bcd60e51b815260206004820152601060248201526f13558e88195e18d95959081b1a5b5a5d60821b6044820152606401610cd8565b600091825261016860205260409091205550565b6001600160a01b038216600090815261016e60205260409020600201546000198114156131f257505050565b818110156132395760405162461bcd60e51b81526020600482015260146024820152734d563a2065786365656420616c6c6f77616e636560601b6044820152606401610cd8565b6001600160a01b038316600090815261016e6020526040812060020180548492906132659084906149ad565b9091555050505050565b60006130e383601284613ed8565b6101635461020d546000916132a1916001600160a01b0391821691168460126130ea565b61020c546040805163312a57db60e11b815290516000926001600160a01b031691636254afb6916004808301926020929190829003018186803b1580156132e757600080fd5b505afa1580156132fb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061331f9190614990565b6001600160a01b031663636929056040518163ffffffff1660e01b815260040160206040518083038186803b15801561335757600080fd5b505afa15801561336b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061338f9190614977565b9050600061016460009054906101000a90046001600160a01b03166001600160a01b031663636929056040518163ffffffff1660e01b815260040160206040518083038186803b1580156133e257600080fd5b505afa1580156133f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061341a9190614977565b9050816134278286614936565b6134319190614955565b92506134d361020c60009054906101000a90046001600160a01b03166001600160a01b031663c3b6f9396040518163ffffffff1660e01b815260040160206040518083038186803b15801561348557600080fd5b505afa158015613499573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134bd9190614990565b61020d546001600160a01b03163086601261393e565b5050919050565b604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e9060440160206040518083038186803b15801561352557600080fd5b505afa158015613539573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061355d9190614977565b90506135968463095ea7b360e01b856135768686614a0f565b6040516001600160a01b0390921660248301526044820152606401612a06565b50505050565b60006130e383836012613ed8565b60006135b6838361326f565b90506135c2818361359c565b83146135e05760405162461bcd60e51b8152600401610cd890614a4a565b6131356001600160a01b03861685836129da565b60006130e3836001600160a01b038416613f50565b6000336001600160a01b0384161582806136268488888487612cdb565b909250905086670de0b6b3a764000084613670576001600160a01b03808316600090815261016e6020526040902080546003820154919261366c9291169060ff16613e13565b9150505b6101645460408051636369290560e01b815290518a926000926001600160a01b0390911691636369290591600480820192602092909190829003018186803b1580156136bb57600080fd5b505afa1580156136cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136f39190614977565b61016354909150613710906001600160a01b0316308760126130ea565b8515613737576101635461016954613737916001600160a01b0390811691168860126130ea565b60006137436101625490565b905061375461016280546001019055565b6040805160c0810182526001600160a01b03808c168252871660208201529081016000815260208082018990526040808301869052606090920187905260008481526101a68252829020835181546001600160a01b039182166001600160a01b0319918216178355928501516001830180549190921693811684178255938501519193919290916001600160a81b03191617600160a01b8360028111156137fd576137fd6147f0565b0217905550606082015181600201556080820151816003015560a08201518160040155905050846001600160a01b0316896001600160a01b0316827f55ba94d231fa70a45e82b0a1c6a60ef72e41bb2455385128ee5cf8d98c0c1c0e868b604051613872929190918252602082015260400190565b60405180910390a49b9a5050505050505050505050565b60006130e3836001600160a01b038416614043565b606060006130e383614092565b6000828210156138c4576138bf82846149ad565b6138ce565b6138ce83836149ad565b90506000836138df61271084614936565b6138e99190614955565b905061016a548111156135965760405162461bcd60e51b815260206004820152601a60248201527f4d563a2065786365656420707269636520646976696174696f6e0000000000006044820152606401610cd8565b600061394a838361326f565b9050613956818361359c565b83146139745760405162461bcd60e51b8152600401610cd890614a4a565b6139896001600160a01b038716868684613ea0565b505050505050565b60006139e6826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166140ee9092919063ffffffff16565b9050805160001480613a07575080806020019051810190613a0791906148da565b6126465760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610cd8565b60655460ff1661122e5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610cd8565b600054610100900460ff16613ad65760405162461bcd60e51b8152600401610cd8906149c4565b613aed613ae66020880188614423565b6000612a8f565b613b00613ae66040880160208901614423565b613b17613b106020870187614423565b6001612a8f565b613b2a613b106040870160208801614423565b6000846020013511613b6b5760405162461bcd60e51b815260206004820152600a6024820152691e995c9bc81b1a5b5a5d60b21b6044820152606401610cd8565b613b7682600161295a565b613b828435600061295a565b613b8f6020870187614423565b61016380546001600160a01b0319166001600160a01b0392909216919091179055613bb9876140fd565b613bc1614135565b613bc9614135565b613bd28361415c565b613bdf6020860186614423565b61016580546001600160a01b0319166001600160a01b0392909216919091179055613c106040860160208701614423565b61016980546001600160a01b0319166001600160a01b03929092169190911790558335610166556020808501356101675561016f82905561016a839055613c5d9060408801908801614423565b61016480546001600160a01b0319166001600160a01b039290921691909117905550505050505050565b6001600160a01b038116600090815260018301602052604081205415156130e3565b600054604051632474521560e21b8152600481018490526001600160a01b03838116602483015262010000909204909116906391d148549060440160206040518083038186803b158015613cfc57600080fd5b505afa158015613d10573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d3491906148da565b156126155760405162461bcd60e51b815260206004820152600e60248201526d574d41433a2068617320726f6c6560901b6044820152606401610cd8565b6001600160a01b038516600090815261016b602052604081205460ff1615613d9c57506000613e0a565b600082613dc657506001600160a01b038516600090815261016e6020526040902060010154613dc9565b50815b8315613de05761016654613ddd9082614a0f565b90505b612710811115613def57506127105b612710613dfc8287614936565b613e069190614955565b9150505b95945050505050565b600080836001600160a01b031663636929056040518163ffffffff1660e01b815260040160206040518083038186803b158015613e4f57600080fd5b505afa158015613e63573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e879190614977565b905082156130e357670de0b6b3a7640000915050612f2a565b6040516001600160a01b03808516602483015283166044820152606481018290526135969085906323b872dd60e01b90608401612a06565b600083613ee7575060006130e3565b81831415613ef65750826130e3565b600082841115613f2657613f0a83856149ad565b613f1590600a614b5c565b613f1f9086614955565b9050613f48565b613f3084846149ad565b613f3b90600a614b5c565b613f459086614936565b90505b949350505050565b60008181526001830160205260408120548015614039576000613f746001836149ad565b8554909150600090613f88906001906149ad565b9050818114613fed576000866000018281548110613fa857613fa8614b68565b9060005260206000200154905080876000018481548110613fcb57613fcb614b68565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080613ffe57613ffe614b7e565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050612f2a565b6000915050612f2a565b600081815260018301602052604081205461408a57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155612f2a565b506000612f2a565b6060816000018054806020026020016040519081016040528092919081815260200182805480156140e257602002820191906000526020600020905b8154815260200190600101908083116140ce575b50505050509050919050565b6060613f4884846000856141a6565b600054610100900460ff166141245760405162461bcd60e51b8152600401610cd8906149c4565b61412c614276565b612c40816142a5565b600054610100900460ff1661122e5760405162461bcd60e51b8152600401610cd8906149c4565b600054610100900460ff166141835760405162461bcd60e51b8152600401610cd8906149c4565b61012f80546001600160a01b0319166001600160a01b0392909216919091179055565b6060824710156142075760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610cd8565b600080866001600160a01b031685876040516142239190614bc0565b60006040518083038185875af1925050503d8060008114614260576040519150601f19603f3d011682016040523d82523d6000602084013e614265565b606091505b50915091506122d38783838761433b565b600054610100900460ff1661429d5760405162461bcd60e51b8152600401610cd8906149c4565b61122e6143b1565b600054610100900460ff166142cc5760405162461bcd60e51b8152600401610cd8906149c4565b6001600160a01b0381166143115760405162461bcd60e51b815260206004820152600c60248201526b7a65726f206164647265737360a01b6044820152606401610cd8565b600080546001600160a01b03909216620100000262010000600160b01b0319909216919091179055565b606083156143a75782516143a0576001600160a01b0385163b6143a05760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610cd8565b5081613f48565b613f4883836143e4565b600054610100900460ff166143d85760405162461bcd60e51b8152600401610cd8906149c4565b6065805460ff19169055565b8151156143f45781518083602001fd5b8060405162461bcd60e51b8152600401610cd89190614bdc565b6001600160a01b0381168114612c4057600080fd5b60006020828403121561443557600080fd5b81356130e38161440e565b60006020828403121561445257600080fd5b81356001600160e01b0319811681146130e357600080fd5b8015158114612c4057600080fd5b60006020828403121561448a57600080fd5b81356130e38161446a565b600080604083850312156144a857600080fd5b50508035926020909101359150565b6000602082840312156144c957600080fd5b5035919050565b600080604083850312156144e357600080fd5b82356144ee8161440e565b915060208301356144fe8161446a565b809150509250929050565b60008060006060848603121561451e57600080fd5b83356145298161440e565b92506020840135915060408401356145408161440e565b809150509250925092565b60006040828403121561455d57600080fd5b50919050565b60006060828403121561455d57600080fd5b60008060008060008060008060006101c08a8c03121561459457600080fd5b893561459f8161440e565b98506145ae8b60208c0161454b565b97506145bd8b60608c0161454b565b96506145cc8b60a08c0161454b565b955060e08a01356145dc8161440e565b94506101008a013593506101208a013592506145fc8b6101408c01614563565b91506101a08a013561460d8161440e565b809150509295985092959850929598565b6000806040838503121561463157600080fd5b823561463c8161440e565b946020939093013593505050565b60008060006060848603121561465f57600080fd5b833561466a8161440e565b95602085013595506040909401359392505050565b6000806000806080858703121561469557600080fd5b84356146a08161440e565b935060208501356146b08161440e565b92506040850135915060608501356146c78161446a565b939692955090935050565b6020808252825182820181905260009190848201906040850190845b818110156147135783516001600160a01b0316835292840192918401916001016146ee565b50909695505050505050565b60008060008060008060008060008060006102008c8e03121561474157600080fd5b8b3561474c8161440e565b9a5061475b8d60208e0161454b565b995061476a8d60608e0161454b565b98506147798d60a08e0161454b565b975060e08c01356147898161440e565b96506101008c013595506101208c013594506147a98d6101408e01614563565b93506101a08c01356147ba8161440e565b92506101c08c01356147cb8161440e565b91506101e08c01356147dc8161440e565b809150509295989b509295989b9093969950565b634e487b7160e01b600052602160045260246000fd5b6001600160a01b0387811682528616602082015260c081016003861061483c57634e487b7160e01b600052602160045260246000fd5b8560408301528460608301528360808301528260a0830152979650505050505050565b60208082526013908201527214185d5cd8589b194e88199b881c185d5cd959606a1b604082015260600190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6000602082840312156148ec57600080fd5b81516130e38161446a565b6020808252600f908201526e15d4d30e881cd85b98dd1a5bdb9959608a1b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b600081600019048311821515161561495057614950614920565b500290565b60008261497257634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121561498957600080fd5b5051919050565b6000602082840312156149a257600080fd5b81516130e38161440e565b6000828210156149bf576149bf614920565b500390565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60008219821115614a2257614a22614920565b500190565b600060208284031215614a3957600080fd5b815160ff811681146130e357600080fd5b6020808252601490820152734d563a20696e76616c696420726f756e64696e6760601b604082015260600190565b600181815b80851115614ab3578160001904821115614a9957614a99614920565b80851615614aa657918102915b93841c9390800290614a7d565b509250929050565b600082614aca57506001612f2a565b81614ad757506000612f2a565b8160018114614aed5760028114614af757614b13565b6001915050612f2a565b60ff841115614b0857614b08614920565b50506001821b612f2a565b5060208310610133831016604e8410600b8410161715614b36575081810a612f2a565b614b408383614a78565b8060001904821115614b5457614b54614920565b029392505050565b60006130e38383614abb565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b60005b83811015614baf578181015183820152602001614b97565b838111156135965750506000910152565b60008251614bd2818460208701614b94565b9190910192915050565b6020815260008251806020840152614bfb816040850160208701614b94565b601f01601f1916919091016040019291505056fea2646970667358221220fb02e7cdadb0b9dc1ec3934b82e5d8d98924b4ba6f8fe3a19b1938bd4a5620c164736f6c63430008090033
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 34 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.