ERC-1155
Source Code
Overview
Max Total Supply
3,000 MNFT
Holders
463
Transfers
-
0 (0%)
Market
Volume (24H)
N/A
Min Price (24H)
N/A
Max Price (24H)
N/A
Other Info
Token Contract
Loading...
Loading
Loading...
Loading
Loading...
Loading
| # | Exchange | Pair | Price | 24H Volume | % Volume |
|---|
Contract Name:
MinterestNFT
Compiler Version
v0.8.17+commit.8df45f5f
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "./interfaces/IMinterestNFT.sol";
import "./libraries/ErrorCodes.sol";
import "./InterconnectorLeaf.sol";
/**
* @title MinterestNFT
* @dev Contract module which provides functionality to mint new ERC1155 tokens
* Each token connected with image and metadata. The image and metadata saved
* on IPFS and this contract stores the CID of the folder where lying metadata.
* Also each token belongs one of the Minterest tiers, and give some emission
* boost for Minterest distribution system.
*/
contract MinterestNFT is IMinterestNFT, ERC1155, AccessControl, InterconnectorLeaf {
using Counters for Counters.Counter;
using Strings for string;
/// @notice The right part is the keccak-256 hash of variable name
bytes32 public constant GATEKEEPER = bytes32(0x20162831d2f54c3e11eebafebfeda495d4c52c67b1708251179ec91fb76dd3b2);
/// Name for Minterst NFT Token
string public constant name = "Minterest NFT";
/// Symbol for Minterst NFT Token
string public constant symbol = "MNFT";
/// Address of opensea proxy registry, for opensea integration
ProxyRegistry public immutable proxyRegistry;
/// @dev ERC1155 id, Indicates a specific token or token type
Counters.Counter private idCounter;
/**
* @notice Initialize contract
* @param _baseURI Base of URI where stores images
* @param _admin The address of the Admin
*/
constructor(
string memory _baseURI,
ProxyRegistry _proxyRegistry,
address _admin
) ERC1155(_baseURI) {
require(address(_proxyRegistry) != address(0), ErrorCodes.ZERO_ADDRESS);
require(_admin != address(0), ErrorCodes.ZERO_ADDRESS);
_grantRole(DEFAULT_ADMIN_ROLE, _admin);
_grantRole(GATEKEEPER, _admin);
proxyRegistry = _proxyRegistry;
}
/*** External user-defined functions ***/
/// @inheritdoc IMinterestNFT
function mint(
address account_,
uint256 amount_,
bytes memory data_,
uint256 tier_
) external onlyRole(GATEKEEPER) {
idCounter.increment();
uint256 id = idCounter.current();
_mint(account_, id, amount_, data_);
if (tier_ > 0) {
emissionBooster().onMintToken(
account_,
_asSingletonArray2(id),
_asSingletonArray2(amount_),
_asSingletonArray2(tier_)
);
}
}
/// @inheritdoc IMinterestNFT
function mintBatch(
address account_,
uint256[] memory amounts_,
bytes memory data_,
uint256[] memory tiers_
) external onlyRole(GATEKEEPER) {
require(tiers_.length == amounts_.length, ErrorCodes.INPUT_ARRAY_LENGTHS_ARE_NOT_EQUAL);
uint256[] memory ids = new uint256[](amounts_.length);
for (uint256 i = 0; i < amounts_.length; i++) {
idCounter.increment();
uint256 id = idCounter.current();
ids[i] = id;
}
_mintBatch(account_, ids, amounts_, data_);
emissionBooster().onMintToken(account_, ids, amounts_, tiers_);
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning, as well as batched variants.
*
* The same hook is called on both single and batched variants. For single
* transfers, the length of the `id` and `amount` arrays will be 1.
*/
function _beforeTokenTransfer(
address,
address from_,
address to_,
uint256[] memory ids_,
uint256[] memory amounts_,
bytes memory
) internal virtual override {
// Ignore mint transfers
if (from_ != address(0)) emissionBooster().onTransferToken(from_, to_, ids_, amounts_);
}
/// @inheritdoc IMinterestNFT
function safeTransfer(
address to_,
uint256 id_,
uint256 amount_,
bytes memory data_
) external {
safeTransferFrom(msg.sender, to_, id_, amount_, data_);
}
/// @inheritdoc IMinterestNFT
function safeBatchTransfer(
address to_,
uint256[] memory ids_,
uint256[] memory amounts_,
bytes memory data_
) external {
safeBatchTransferFrom(msg.sender, to_, ids_, amounts_, data_);
}
/*** Admin Functions ***/
/// @inheritdoc IMinterestNFT
function setURI(string memory newBaseUri) external onlyRole(DEFAULT_ADMIN_ROLE) {
_setURI(newBaseUri);
emit NewBaseUri(newBaseUri);
}
/*** Helper special functions ***/
/// @inheritdoc IMinterestNFT
function uri(uint256 tokenId_) public view override(ERC1155, IMinterestNFT) returns (string memory) {
return
_exists(tokenId_)
? string(abi.encodePacked(super.uri(tokenId_), Strings.toString(tokenId_), ".json"))
: super.uri(tokenId_);
}
/// @inheritdoc IMinterestNFT
function isApprovedForAll(address _owner, address _operator)
public
view
override(ERC1155, IMinterestNFT)
returns (bool isOperator)
{
// Whitelist OpenSea proxy contract for easy trading.
if (proxyRegistry.proxies(_owner) == _operator) {
return true;
}
return ERC1155.isApprovedForAll(_owner, _operator);
}
/// @inheritdoc IMinterestNFT
function nextIdToBeMinted() external view returns (uint256) {
return idCounter.current() + 1;
}
function supportsInterface(bytes4 interfaceId)
public
pure
override(AccessControl, ERC1155, IERC165)
returns (bool)
{
return interfaceId == type(IERC1155).interfaceId;
}
/**
* @dev Returns whether the specified token exists
* @param _id uint256 ID of the token to query the existence of
* @return bool whether the token exists
*/
function _exists(uint256 _id) private view returns (bool) {
return _id > 0 && _id <= idCounter.current();
}
function _asSingletonArray2(uint256 element) private pure returns (uint256[] memory) {
uint256[] memory array = new uint256[](1);
array[0] = element;
return array;
}
function emissionBooster() internal view returns (IEmissionBooster) {
return getInterconnector().emissionBooster();
}
}// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "./libraries/ProtocolLinkage.sol";
import "./interfaces/IInterconnectorLeaf.sol";
abstract contract InterconnectorLeaf is IInterconnectorLeaf, LinkageLeaf {
function getInterconnector() public view returns (IInterconnector) {
return IInterconnector(getLinkageRootAddress());
}
}// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts/access/IAccessControl.sol";
import "./ILinkageLeaf.sol";
interface ProxyRegistry {
function proxies(address) external view returns (address);
}
/**
* @title MinterestNFT
* @dev Contract module which provides functionality to mint new ERC1155 tokens
* Each token connected with image and metadata. The image and metadata saved
* on IPFS and this contract stores the CID of the folder where lying metadata.
* Also each token belongs one of the Minterest tiers, and give some emission
* boost for Minterest distribution system.
*/
interface IMinterestNFT is IAccessControl, IERC1155, ILinkageLeaf {
/**
* @notice Emitted when new base URI was installed
*/
event NewBaseUri(string newBaseUri);
/**
* @notice get name for Minterst NFT Token
*/
function name() external view returns (string memory);
/**
* @notice get symbool for Minterst NFT Token
*/
function symbol() external view returns (string memory);
/**
* @notice get address of opensea proxy registry
*/
function proxyRegistry() external view returns (ProxyRegistry);
/**
* @notice get keccak-256 hash of GATEKEEPER role
*/
function GATEKEEPER() external view returns (bytes32);
/**
* @notice Mint new 1155 standard token
* @param account_ The address of the owner of minterestNFT
* @param amount_ Instance count for minterestNFT
* @param data_ The _data argument MAY be re-purposed for the new context.
* @param tier_ tier
*/
function mint(
address account_,
uint256 amount_,
bytes memory data_,
uint256 tier_
) external;
/**
* @notice Mint new ERC1155 standard tokens in one transaction
* @param account_ The address of the owner of tokens
* @param amounts_ Array of instance counts for tokens
* @param data_ The _data argument MAY be re-purposed for the new context.
* @param tiers_ Array of tiers
* @dev RESTRICTION: Gatekeeper only
*/
function mintBatch(
address account_,
uint256[] memory amounts_,
bytes memory data_,
uint256[] memory tiers_
) external;
/**
* @notice Transfer token to another account
* @param to_ The address of the token receiver
* @param id_ token id
* @param amount_ Count of tokens
* @param data_ The _data argument MAY be re-purposed for the new context.
*/
function safeTransfer(
address to_,
uint256 id_,
uint256 amount_,
bytes memory data_
) external;
/**
* @notice Transfer tokens to another account
* @param to_ The address of the tokens receiver
* @param ids_ Array of token ids
* @param amounts_ Array of tokens count
* @param data_ The _data argument MAY be re-purposed for the new context.
*/
function safeBatchTransfer(
address to_,
uint256[] memory ids_,
uint256[] memory amounts_,
bytes memory data_
) external;
/**
* @notice Set new base URI
* @param newBaseUri Base URI
* @dev RESTRICTION: Admin only
*/
function setURI(string memory newBaseUri) external;
/**
* @notice Override function to return image URL, opensea requirement
* @param tokenId_ Id of token to get URL
* @return IPFS URI for token id, opensea requirement
*/
function uri(uint256 tokenId_) external view returns (string memory);
/**
* @notice Override isApprovedForAll to whitelist user's OpenSea proxy accounts to enable gas-free listings.
* @param _owner Owner of tokens
* @param _operator Address to check if the `operator` is the operator for `owner` tokens
* @return isOperator return true if `operator` is the operator for `owner` tokens otherwise true *
*/
function isApprovedForAll(address _owner, address _operator) external view returns (bool);
/**
* @dev Returns the next token ID to be minted
* @return the next token ID to be minted
*/
function nextIdToBeMinted() external view returns (uint256);
}// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
library ErrorCodes {
// Common
string internal constant ADMIN_ONLY = "E101";
string internal constant UNAUTHORIZED = "E102";
string internal constant OPERATION_PAUSED = "E103";
string internal constant WHITELISTED_ONLY = "E104";
string internal constant ADDRESS_IS_NOT_IN_AML_SYSTEM = "E105";
string internal constant ADDRESS_IS_BLACKLISTED = "E106";
// Invalid input
string internal constant ADMIN_ADDRESS_CANNOT_BE_ZERO = "E201";
string internal constant INVALID_REDEEM = "E202";
string internal constant REDEEM_TOO_MUCH = "E203";
string internal constant MARKET_NOT_LISTED = "E204";
string internal constant INSUFFICIENT_LIQUIDITY = "E205";
string internal constant INVALID_SENDER = "E206";
string internal constant BORROW_CAP_REACHED = "E207";
string internal constant BALANCE_OWED = "E208";
string internal constant UNRELIABLE_LIQUIDATOR = "E209";
string internal constant INVALID_DESTINATION = "E210";
string internal constant INSUFFICIENT_STAKE = "E211";
string internal constant INVALID_DURATION = "E212";
string internal constant INVALID_PERIOD_RATE = "E213";
string internal constant EB_TIER_LIMIT_REACHED = "E214";
string internal constant INVALID_DEBT_REDEMPTION_RATE = "E215";
string internal constant LQ_INVALID_SEIZE_DISTRIBUTION = "E216";
string internal constant EB_TIER_DOES_NOT_EXIST = "E217";
string internal constant EB_ZERO_TIER_CANNOT_BE_ENABLED = "E218";
string internal constant EB_ALREADY_ACTIVATED_TIER = "E219";
string internal constant EB_END_BLOCK_MUST_BE_LARGER_THAN_CURRENT = "E220";
string internal constant EB_CANNOT_MINT_TOKEN_FOR_ACTIVATED_TIER = "E221";
string internal constant EB_EMISSION_BOOST_IS_NOT_IN_RANGE = "E222";
string internal constant TARGET_ADDRESS_CANNOT_BE_ZERO = "E223";
string internal constant INSUFFICIENT_TOKEN_IN_VESTING_CONTRACT = "E224";
string internal constant VESTING_SCHEDULE_ALREADY_EXISTS = "E225";
string internal constant INSUFFICIENT_TOKENS_TO_CREATE_SCHEDULE = "E226";
string internal constant NO_VESTING_SCHEDULE = "E227";
string internal constant SCHEDULE_IS_IRREVOCABLE = "E228";
string internal constant MNT_AMOUNT_IS_ZERO = "E230";
string internal constant INCORRECT_AMOUNT = "E231";
string internal constant MEMBERSHIP_LIMIT = "E232";
string internal constant MEMBER_NOT_EXIST = "E233";
string internal constant MEMBER_ALREADY_ADDED = "E234";
string internal constant MEMBERSHIP_LIMIT_REACHED = "E235";
string internal constant REPORTED_PRICE_SHOULD_BE_GREATER_THAN_ZERO = "E236";
string internal constant MTOKEN_ADDRESS_CANNOT_BE_ZERO = "E237";
string internal constant TOKEN_ADDRESS_CANNOT_BE_ZERO = "E238";
string internal constant REDEEM_TOKENS_OR_REDEEM_AMOUNT_MUST_BE_ZERO = "E239";
string internal constant FL_TOKEN_IS_NOT_UNDERLYING = "E240";
string internal constant FL_AMOUNT_IS_TOO_LARGE = "E241";
string internal constant FL_CALLBACK_FAILED = "E242";
string internal constant DD_UNSUPPORTED_TOKEN = "E243";
string internal constant DD_MARKET_ADDRESS_IS_ZERO = "E244";
string internal constant DD_ROUTER_ADDRESS_IS_ZERO = "E245";
string internal constant DD_RECEIVER_ADDRESS_IS_ZERO = "E246";
string internal constant DD_BOT_ADDRESS_IS_ZERO = "E247";
string internal constant DD_MARKET_NOT_FOUND = "E248";
string internal constant DD_RECEIVER_NOT_FOUND = "E249";
string internal constant DD_BOT_NOT_FOUND = "E250";
string internal constant DD_ROUTER_ALREADY_SET = "E251";
string internal constant DD_RECEIVER_ALREADY_SET = "E252";
string internal constant DD_BOT_ALREADY_SET = "E253";
string internal constant EB_MARKET_INDEX_IS_LESS_THAN_USER_INDEX = "E254";
string internal constant LQ_INVALID_DRR_ARRAY = "E255";
string internal constant LQ_INVALID_SEIZE_ARRAY = "E256";
string internal constant LQ_INVALID_DEBT_REDEMPTION_RATE = "E257";
string internal constant LQ_INVALID_SEIZE_INDEX = "E258";
string internal constant LQ_DUPLICATE_SEIZE_INDEX = "E259";
string internal constant DD_INVALID_TOKEN_IN_ADDRESS = "E260";
string internal constant DD_INVALID_TOKEN_OUT_ADDRESS = "E261";
string internal constant DD_INVALID_TOKEN_IN_AMOUNT = "E262";
string internal constant DD_LIQUIDATION_ADDRESS_IS_ZERO = "E263";
string internal constant DD_LIQUIDATION_ALREADY_SET = "E264";
// Protocol errors
string internal constant INVALID_PRICE = "E301";
string internal constant MARKET_NOT_FRESH = "E302";
string internal constant BORROW_RATE_TOO_HIGH = "E303";
string internal constant INSUFFICIENT_TOKEN_CASH = "E304";
string internal constant INSUFFICIENT_TOKENS_FOR_RELEASE = "E305";
string internal constant INSUFFICIENT_MNT_FOR_GRANT = "E306";
string internal constant TOKEN_TRANSFER_IN_UNDERFLOW = "E307";
string internal constant NOT_PARTICIPATING_IN_BUYBACK = "E308";
string internal constant NOT_ENOUGH_PARTICIPATING_ACCOUNTS = "E309";
string internal constant NOTHING_TO_DISTRIBUTE = "E310";
string internal constant ALREADY_PARTICIPATING_IN_BUYBACK = "E311";
string internal constant MNT_APPROVE_FAILS = "E312";
string internal constant TOO_EARLY_TO_DRIP = "E313";
string internal constant BB_UNSTAKE_TOO_EARLY = "E314";
string internal constant INSUFFICIENT_SHORTFALL = "E315";
string internal constant HEALTHY_FACTOR_NOT_IN_RANGE = "E316";
string internal constant BUYBACK_DRIPS_ALREADY_HAPPENED = "E317";
string internal constant EB_INDEX_SHOULD_BE_GREATER_THAN_INITIAL = "E318";
string internal constant NO_VESTING_SCHEDULES = "E319";
string internal constant INSUFFICIENT_UNRELEASED_TOKENS = "E320";
string internal constant ORACLE_PRICE_EXPIRED = "E321";
string internal constant TOKEN_NOT_FOUND = "E322";
string internal constant RECEIVED_PRICE_HAS_INVALID_ROUND = "E323";
string internal constant FL_PULL_AMOUNT_IS_TOO_LOW = "E324";
string internal constant INSUFFICIENT_TOTAL_PROTOCOL_INTEREST = "E325";
string internal constant BB_ACCOUNT_RECENTLY_VOTED = "E326";
string internal constant DD_SWAP_ROUTER_IS_ZERO = "E327";
string internal constant DD_SWAP_CALL_FAILS = "E328";
string internal constant LL_NEW_ROOT_CANNOT_BE_ZERO = "E329";
string internal constant RH_PAYOUT_FROM_FUTURE = "E330";
string internal constant RH_ACCRUE_WITHOUT_UNLOCK = "E331";
string internal constant RH_LERP_DELTA_IS_GREATER_THAN_PERIOD = "E332";
string internal constant PRECONDITIONS_NOT_MET = "E333";
// Invalid input - Admin functions
string internal constant ZERO_EXCHANGE_RATE = "E401";
string internal constant SECOND_INITIALIZATION = "E402";
string internal constant MARKET_ALREADY_LISTED = "E403";
string internal constant IDENTICAL_VALUE = "E404";
string internal constant ZERO_ADDRESS = "E405";
string internal constant EC_INVALID_PROVIDER_REPRESENTATIVE = "E406";
string internal constant EC_PROVIDER_CANT_BE_REPRESENTATIVE = "E407";
string internal constant OR_ORACLE_ADDRESS_CANNOT_BE_ZERO = "E408";
string internal constant OR_UNDERLYING_TOKENS_DECIMALS_SHOULD_BE_GREATER_THAN_ZERO = "E409";
string internal constant OR_REPORTER_MULTIPLIER_SHOULD_BE_GREATER_THAN_ZERO = "E410";
string internal constant INVALID_TOKEN = "E411";
string internal constant INVALID_PROTOCOL_INTEREST_FACTOR_MANTISSA = "E412";
string internal constant INVALID_REDUCE_AMOUNT = "E413";
string internal constant LIQUIDATION_FEE_MANTISSA_SHOULD_BE_GREATER_THAN_ZERO = "E414";
string internal constant INVALID_UTILISATION_FACTOR_MANTISSA = "E415";
string internal constant INVALID_MTOKENS_OR_BORROW_CAPS = "E416";
string internal constant FL_PARAM_IS_TOO_LARGE = "E417";
string internal constant MNT_INVALID_NONVOTING_PERIOD = "E418";
string internal constant INPUT_ARRAY_LENGTHS_ARE_NOT_EQUAL = "E419";
string internal constant EC_INVALID_BOOSTS = "E420";
string internal constant EC_ACCOUNT_IS_ALREADY_LIQUIDITY_PROVIDER = "E421";
string internal constant EC_ACCOUNT_HAS_NO_AGREEMENT = "E422";
string internal constant OR_TIMESTAMP_THRESHOLD_SHOULD_BE_GREATER_THAN_ZERO = "E423";
string internal constant OR_UNDERLYING_TOKENS_DECIMALS_TOO_BIG = "E424";
string internal constant OR_REPORTER_MULTIPLIER_TOO_BIG = "E425";
string internal constant SHOULD_HAVE_REVOCABLE_SCHEDULE = "E426";
string internal constant MEMBER_NOT_IN_DELAY_LIST = "E427";
string internal constant DELAY_LIST_LIMIT = "E428";
string internal constant NUMBER_IS_NOT_IN_SCALE = "E429";
string internal constant BB_STRATUM_OF_FIRST_LOYALTY_GROUP_IS_NOT_ZERO = "E430";
string internal constant INPUT_ARRAY_IS_EMPTY = "E431";
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol)
pragma solidity ^0.8.0;
import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.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:
*
* ```
* 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}:
*
* ```
* 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.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
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(IAccessControl).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 ",
Strings.toHexString(uint160(account), 20),
" is missing role ",
Strings.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());
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_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) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @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] = _HEX_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);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/ERC1155.sol)
pragma solidity ^0.8.0;
import "./IERC1155.sol";
import "./IERC1155Receiver.sol";
import "./extensions/IERC1155MetadataURI.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/introspection/ERC165.sol";
/**
* @dev Implementation of the basic standard multi-token.
* See https://eips.ethereum.org/EIPS/eip-1155
* Originally based on code by Enjin: https://github.com/enjin/erc-1155
*
* _Available since v3.1._
*/
contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI {
using Address for address;
// Mapping from token ID to account balances
mapping(uint256 => mapping(address => uint256)) private _balances;
// Mapping from account to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json
string private _uri;
/**
* @dev See {_setURI}.
*/
constructor(string memory uri_) {
_setURI(uri_);
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC1155).interfaceId ||
interfaceId == type(IERC1155MetadataURI).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC1155MetadataURI-uri}.
*
* This implementation returns the same URI for *all* token types. It relies
* on the token type ID substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* Clients calling this function must replace the `\{id\}` substring with the
* actual token type ID.
*/
function uri(uint256) public view virtual override returns (string memory) {
return _uri;
}
/**
* @dev See {IERC1155-balanceOf}.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) public view virtual override returns (uint256) {
require(account != address(0), "ERC1155: address zero is not a valid owner");
return _balances[id][account];
}
/**
* @dev See {IERC1155-balanceOfBatch}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(address[] memory accounts, uint256[] memory ids)
public
view
virtual
override
returns (uint256[] memory)
{
require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch");
uint256[] memory batchBalances = new uint256[](accounts.length);
for (uint256 i = 0; i < accounts.length; ++i) {
batchBalances[i] = balanceOf(accounts[i], ids[i]);
}
return batchBalances;
}
/**
* @dev See {IERC1155-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC1155-isApprovedForAll}.
*/
function isApprovedForAll(address account, address operator) public view virtual override returns (bool) {
return _operatorApprovals[account][operator];
}
/**
* @dev See {IERC1155-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: caller is not token owner nor approved"
);
_safeTransferFrom(from, to, id, amount, data);
}
/**
* @dev See {IERC1155-safeBatchTransferFrom}.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: caller is not token owner nor approved"
);
_safeBatchTransferFrom(from, to, ids, amounts, data);
}
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
_beforeTokenTransfer(operator, from, to, ids, amounts, data);
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
emit TransferSingle(operator, from, to, id, amount);
_afterTokenTransfer(operator, from, to, ids, amounts, data);
_doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function _safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; ++i) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
}
emit TransferBatch(operator, from, to, ids, amounts);
_afterTokenTransfer(operator, from, to, ids, amounts, data);
_doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data);
}
/**
* @dev Sets a new URI for all token types, by relying on the token type ID
* substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* By this mechanism, any occurrence of the `\{id\}` substring in either the
* URI or any of the amounts in the JSON file at said URI will be replaced by
* clients with the token type ID.
*
* For example, the `https://token-cdn-domain/\{id\}.json` URI would be
* interpreted by clients as
* `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`
* for token type ID 0x4cce0.
*
* See {uri}.
*
* Because these URIs cannot be meaningfully represented by the {URI} event,
* this function emits no events.
*/
function _setURI(string memory newuri) internal virtual {
_uri = newuri;
}
/**
* @dev Creates `amount` tokens of token type `id`, and assigns them to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _mint(
address to,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
address operator = _msgSender();
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
_beforeTokenTransfer(operator, address(0), to, ids, amounts, data);
_balances[id][to] += amount;
emit TransferSingle(operator, address(0), to, id, amount);
_afterTokenTransfer(operator, address(0), to, ids, amounts, data);
_doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function _mintBatch(
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, address(0), to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; i++) {
_balances[ids[i]][to] += amounts[i];
}
emit TransferBatch(operator, address(0), to, ids, amounts);
_afterTokenTransfer(operator, address(0), to, ids, amounts, data);
_doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);
}
/**
* @dev Destroys `amount` tokens of token type `id` from `from`
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `from` must have at least `amount` tokens of token type `id`.
*/
function _burn(
address from,
uint256 id,
uint256 amount
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
address operator = _msgSender();
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
_beforeTokenTransfer(operator, from, address(0), ids, amounts, "");
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
emit TransferSingle(operator, from, address(0), id, amount);
_afterTokenTransfer(operator, from, address(0), ids, amounts, "");
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
*/
function _burnBatch(
address from,
uint256[] memory ids,
uint256[] memory amounts
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, address(0), ids, amounts, "");
for (uint256 i = 0; i < ids.length; i++) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
}
emit TransferBatch(operator, from, address(0), ids, amounts);
_afterTokenTransfer(operator, from, address(0), ids, amounts, "");
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits an {ApprovalForAll} event.
*/
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC1155: setting approval status for self");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning, as well as batched variants.
*
* The same hook is called on both single and batched variants. For single
* transfers, the length of the `ids` and `amounts` arrays will be 1.
*
* Calling conditions (for each `id` and `amount` pair):
*
* - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* of token type `id` will be transferred to `to`.
* - When `from` is zero, `amount` tokens of token type `id` will be minted
* for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
* will be burned.
* - `from` and `to` are never both zero.
* - `ids` and `amounts` have the same, non-zero length.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {}
/**
* @dev Hook that is called after any token transfer. This includes minting
* and burning, as well as batched variants.
*
* The same hook is called on both single and batched variants. For single
* transfers, the length of the `id` and `amount` arrays will be 1.
*
* Calling conditions (for each `id` and `amount` pair):
*
* - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* of token type `id` will be transferred to `to`.
* - When `from` is zero, `amount` tokens of token type `id` will be minted
* for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
* will be burned.
* - `from` and `to` are never both zero.
* - `ids` and `amounts` have the same, non-zero length.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {}
function _doSafeTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
if (response != IERC1155Receiver.onERC1155Received.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non ERC1155Receiver implementer");
}
}
}
function _doSafeBatchTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
bytes4 response
) {
if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non ERC1155Receiver implementer");
}
}
}
function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) {
uint256[] memory array = new uint256[](1);
array[0] = element;
return array;
}
}// 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: BSD-3-Clause
pragma solidity 0.8.17;
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/StorageSlot.sol";
import "../interfaces/ILinkageLeaf.sol";
import "../interfaces/ILinkageRoot.sol";
import "./ErrorCodes.sol";
abstract contract LinkageRoot is ILinkageRoot {
/// @notice Store self address to prevent context changing while delegateCall
ILinkageRoot internal immutable _self = this;
/// @notice Owner address
address public immutable _linkage_owner;
constructor(address owner_) {
require(owner_ != address(0), ErrorCodes.ADMIN_ADDRESS_CANNOT_BE_ZERO);
_linkage_owner = owner_;
}
/// @inheritdoc ILinkageRoot
function switchLinkageRoot(ILinkageRoot newRoot) external {
require(msg.sender == _linkage_owner, ErrorCodes.UNAUTHORIZED);
emit LinkageRootSwitch(newRoot);
Address.functionDelegateCall(
address(newRoot),
abi.encodePacked(LinkageRoot.interconnect.selector),
"LinkageRoot: low-level delegate call failed"
);
}
/// @inheritdoc ILinkageRoot
function interconnect() external {
emit LinkageRootInterconnected();
interconnectInternal();
}
function interconnectInternal() internal virtual;
}
abstract contract LinkageLeaf is ILinkageLeaf {
/// @inheritdoc ILinkageLeaf
function switchLinkageRoot(ILinkageRoot newRoot) public {
require(address(newRoot) != address(0), ErrorCodes.LL_NEW_ROOT_CANNOT_BE_ZERO);
StorageSlot.AddressSlot storage slot = getRootSlot();
address oldRoot = slot.value;
if (oldRoot == address(newRoot)) return;
require(oldRoot == address(0) || oldRoot == msg.sender, ErrorCodes.UNAUTHORIZED);
slot.value = address(newRoot);
emit LinkageRootSwitched(newRoot, LinkageRoot(oldRoot));
}
/**
* @dev Gets current root contract address
*/
function getLinkageRootAddress() internal view returns (address) {
return getRootSlot().value;
}
/**
* @dev Gets current root contract storage slot
*/
function getRootSlot() private pure returns (StorageSlot.AddressSlot storage) {
// keccak256("minterest.slot.linkageRoot")
return StorageSlot.getAddressSlot(0xc34f336ef21a27e6cdbefdb1e201a57e5e6cb9d267e34fc3134d22f9decc8bbf);
}
}// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "./IInterconnector.sol";
import "./ILinkageLeaf.sol";
interface IInterconnectorLeaf is ILinkageLeaf {
function getInterconnector() external view returns (IInterconnector);
}// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "./ILinkageRoot.sol";
interface ILinkageLeaf {
/**
* @notice Emitted when root contract address is changed
*/
event LinkageRootSwitched(ILinkageRoot newRoot, ILinkageRoot oldRoot);
/**
* @notice Connects new root contract address
* @param newRoot New root contract address
*/
function switchLinkageRoot(ILinkageRoot newRoot) external;
}// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
interface ILinkageRoot {
/**
* @notice Emitted when new root contract connected to all leafs
*/
event LinkageRootSwitch(ILinkageRoot newRoot);
/**
* @notice Emitted when root interconnects its contracts
*/
event LinkageRootInterconnected();
/**
* @notice Connects new root to all leafs contracts
* @param newRoot New root contract address
*/
function switchLinkageRoot(ILinkageRoot newRoot) external;
/**
* @notice Update root for all leaf contracts
* @dev Should include only leaf contracts
*/
function interconnect() external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @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
* ====
*
* [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://diligence.consensys.net/posts/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.5.11/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 functionCall(target, data, "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");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(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) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(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) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason 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 {
// 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 (last updated v4.7.0) (utils/StorageSlot.sol)
pragma solidity ^0.8.0;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC1967 implementation slot:
* ```
* contract ERC1967 {
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
}// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "./ISupervisor.sol";
import "./IRewardsHub.sol";
import "./IMnt.sol";
import "./IBuyback.sol";
import "./IVesting.sol";
import "./IMinterestNFT.sol";
import "./IPriceOracle.sol";
import "./ILiquidation.sol";
import "./IBDSystem.sol";
import "./IWeightAggregator.sol";
import "./IEmissionBooster.sol";
interface IInterconnector {
function supervisor() external view returns (ISupervisor);
function buyback() external view returns (IBuyback);
function emissionBooster() external view returns (IEmissionBooster);
function bdSystem() external view returns (IBDSystem);
function rewardsHub() external view returns (IRewardsHub);
function mnt() external view returns (IMnt);
function minterestNFT() external view returns (IMinterestNFT);
function liquidation() external view returns (ILiquidation);
function oracle() external view returns (IPriceOracle);
function vesting() external view returns (IVesting);
function whitelist() external view returns (IWhitelist);
function weightAggregator() external view returns (IWeightAggregator);
}// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "@openzeppelin/contracts/access/IAccessControl.sol";
import "./IMToken.sol";
import "./IBuyback.sol";
import "./IRewardsHub.sol";
import "./ILinkageLeaf.sol";
import "./IWhitelist.sol";
/**
* @title Minterest Supervisor Contract
* @author Minterest
*/
interface ISupervisor is IAccessControl, ILinkageLeaf {
/**
* @notice Emitted when an admin supports a market
*/
event MarketListed(IMToken mToken);
/**
* @notice Emitted when an account enable a market
*/
event MarketEnabledAsCollateral(IMToken mToken, address account);
/**
* @notice Emitted when an account disable a market
*/
event MarketDisabledAsCollateral(IMToken mToken, address account);
/**
* @notice Emitted when a utilisation factor is changed by admin
*/
event NewUtilisationFactor(
IMToken mToken,
uint256 oldUtilisationFactorMantissa,
uint256 newUtilisationFactorMantissa
);
/**
* @notice Emitted when liquidation fee is changed by admin
*/
event NewLiquidationFee(IMToken marketAddress, uint256 oldLiquidationFee, uint256 newLiquidationFee);
/**
* @notice Emitted when borrow cap for a mToken is changed
*/
event NewBorrowCap(IMToken indexed mToken, uint256 newBorrowCap);
/**
* @notice Per-account mapping of "assets you are in"
*/
function accountAssets(address, uint256) external view returns (IMToken);
/**
* @notice Collection of states of supported markets
* @dev Types containing (nested) mappings could not be parameters or return of external methods
*/
function markets(IMToken)
external
view
returns (
bool isListed,
uint256 utilisationFactorMantissa,
uint256 liquidationFeeMantissa
);
/**
* @notice get A list of all markets
*/
function allMarkets(uint256) external view returns (IMToken);
/**
* @notice get Borrow caps enforced by beforeBorrow for each mToken address.
*/
function borrowCaps(IMToken) external view returns (uint256);
/**
* @notice get keccak-256 hash of gatekeeper role
*/
function GATEKEEPER() external view returns (bytes32);
/**
* @notice get keccak-256 hash of timelock
*/
function TIMELOCK() external view returns (bytes32);
/**
* @notice Returns the assets an account has enabled as collateral
* @param account The address of the account to pull assets for
* @return A dynamic list with the assets the account has enabled as collateral
*/
function getAccountAssets(address account) external view returns (IMToken[] memory);
/**
* @notice Returns whether the given account is enabled as collateral in the given asset
* @param account The address of the account to check
* @param mToken The mToken to check
* @return True if the account is in the asset, otherwise false.
*/
function checkMembership(address account, IMToken mToken) external view returns (bool);
/**
* @notice Add assets to be included in account liquidity calculation
* @param mTokens The list of addresses of the mToken markets to be enabled as collateral
*/
function enableAsCollateral(IMToken[] memory mTokens) external;
/**
* @notice Removes asset from sender's account liquidity calculation
* @dev Sender must not have an outstanding borrow balance in the asset,
* or be providing necessary collateral for an outstanding borrow.
* @param mTokenAddress The address of the asset to be removed
*/
function disableAsCollateral(IMToken mTokenAddress) external;
/**
* @notice Makes checks if the account should be allowed to lend tokens in the given market
* @param mToken The market to verify the lend against
* @param lender The account which would get the lent tokens
*/
function beforeLend(IMToken mToken, address lender) external;
/**
* @notice Checks if the account should be allowed to redeem tokens in the given market and triggers emission system
* @param mToken The market to verify the redeem against
* @param redeemer The account which would redeem the tokens
* @param redeemTokens The number of mTokens to exchange for the underlying asset in the market
* @param isAmlProcess Do we need to check the AML system or not
*/
function beforeRedeem(
IMToken mToken,
address redeemer,
uint256 redeemTokens,
bool isAmlProcess
) external;
/**
* @notice Checks if the account should be allowed to borrow the underlying asset of the given market
* @param mToken The market to verify the borrow against
* @param borrower The account which would borrow the asset
* @param borrowAmount The amount of underlying the account would borrow
*/
function beforeBorrow(
IMToken mToken,
address borrower,
uint256 borrowAmount
) external;
/**
* @notice Checks if the account should be allowed to repay a borrow in the given market
* @param mToken The market to verify the repay against
* @param borrower The account which would borrowed the asset
*/
function beforeRepayBorrow(IMToken mToken, address borrower) external;
/**
* @notice Checks if the seizing of assets should be allowed to occur (auto liquidation process)
* @param mToken Asset which was used as collateral and will be seized
* @param liquidator_ The address of liquidator contract
* @param borrower The address of the borrower
*/
function beforeAutoLiquidationSeize(
IMToken mToken,
address liquidator_,
address borrower
) external;
/**
* @notice Checks if the sender should be allowed to repay borrow in the given market (auto liquidation process)
* @param liquidator_ The address of liquidator contract
* @param borrower_ The account which borrowed the asset
* @param mToken_ The market to verify the repay against
*/
function beforeAutoLiquidationRepay(
address liquidator_,
address borrower_,
IMToken mToken_
) external;
/**
* @notice Checks if the address is the Liquidation contract
* @dev Used in liquidation process
* @param liquidator_ Prospective address of the Liquidation contract
*/
function isLiquidator(address liquidator_) external view;
/**
* @notice Checks if the account should be allowed to transfer tokens in the given market
* @param mToken The market to verify the transfer against
* @param src The account which sources the tokens
* @param dst The account which receives the tokens
* @param transferTokens The number of mTokens to transfer
*/
function beforeTransfer(
IMToken mToken,
address src,
address dst,
uint256 transferTokens
) external;
/**
* @notice Makes checks before flash loan in MToken
* @param mToken The address of the token
* receiver - The address of the loan receiver
* amount - How much tokens to flash loan
* fee - Flash loan fee
*/
function beforeFlashLoan(
IMToken mToken,
address, /* receiver */
uint256, /* amount */
uint256 /* fee */
) external view;
/**
* @notice Calculate account liquidity in USD related to utilisation factors of underlying assets
* @return (USD value above total utilisation requirements of all assets,
* USD value below total utilisation requirements of all assets)
*/
function getAccountLiquidity(address account) external view returns (uint256, uint256);
/**
* @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed
* @param mTokenModify The market to hypothetically redeem/borrow in
* @param account The account to determine liquidity for
* @param redeemTokens The number of tokens to hypothetically redeem
* @param borrowAmount The amount of underlying to hypothetically borrow
* @return (hypothetical account liquidity in excess of collateral requirements,
* hypothetical account shortfall below collateral requirements)
*/
function getHypotheticalAccountLiquidity(
address account,
IMToken mTokenModify,
uint256 redeemTokens,
uint256 borrowAmount
) external returns (uint256, uint256);
/**
* @notice Get liquidationFeeMantissa and utilisationFactorMantissa for market
* @param market Market for which values are obtained
* @return (liquidationFeeMantissa, utilisationFactorMantissa)
*/
function getMarketData(IMToken market) external view returns (uint256, uint256);
/**
* @notice Validates redeem and reverts on rejection. May emit logs.
* @param redeemAmount The amount of the underlying asset being redeemed
* @param redeemTokens The number of tokens being redeemed
*/
function redeemVerify(uint256 redeemAmount, uint256 redeemTokens) external view;
/**
* @notice Sets the utilisationFactor for a market
* @dev Governance function to set per-market utilisationFactor
* @param mToken The market to set the factor on
* @param newUtilisationFactorMantissa The new utilisation factor, scaled by 1e18
* @dev RESTRICTION: Timelock only.
*/
function setUtilisationFactor(IMToken mToken, uint256 newUtilisationFactorMantissa) external;
/**
* @notice Sets the liquidationFee for a market
* @dev Governance function to set per-market liquidationFee
* @param mToken The market to set the fee on
* @param newLiquidationFeeMantissa The new liquidation fee, scaled by 1e18
* @dev RESTRICTION: Timelock only.
*/
function setLiquidationFee(IMToken mToken, uint256 newLiquidationFeeMantissa) external;
/**
* @notice Add the market to the markets mapping and set it as listed, also initialize MNT market state.
* @dev Admin function to set isListed and add support for the market
* @param mToken The address of the market (token) to list
* @dev RESTRICTION: Admin only.
*/
function supportMarket(IMToken mToken) external;
/**
* @notice Set the given borrow caps for the given mToken markets.
* Borrowing that brings total borrows to or above borrow cap will revert.
* @dev Admin or gateKeeper function to set the borrow caps.
* A borrow cap of 0 corresponds to unlimited borrowing.
* @param mTokens The addresses of the markets (tokens) to change the borrow caps for
* @param newBorrowCaps The new borrow cap values in underlying to be set.
* A value of 0 corresponds to unlimited borrowing.
* @dev RESTRICTION: Gatekeeper only.
*/
function setMarketBorrowCaps(IMToken[] calldata mTokens, uint256[] calldata newBorrowCaps) external;
/**
* @notice Return all of the markets
* @dev The automatic getter may be used to access an individual market.
* @return The list of market addresses
*/
function getAllMarkets() external view returns (IMToken[] memory);
/**
* @notice Returns true if market is listed in Supervisor
*/
function isMarketListed(IMToken) external view returns (bool);
/**
* @notice Check that account is not in the black list and protocol operations are available.
* @param account The address of the account to check
*/
function isNotBlacklisted(address account) external view returns (bool);
/**
* @notice Check if transfer of MNT is allowed for accounts.
* @param from The source account address to check
* @param to The destination account address to check
*/
function isMntTransferAllowed(address from, address to) external view returns (bool);
/**
* @notice Returns block number
*/
function getBlockNumber() external view returns (uint256);
}// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "./IMToken.sol";
import "./ILinkageLeaf.sol";
interface IRewardsHub is ILinkageLeaf {
event DistributedSupplierMnt(IMToken mToken, address supplier, uint256 mntDelta, uint256 mntSupplyIndex);
event DistributedBorrowerMnt(IMToken mToken, address borrower, uint256 mntDelta, uint256 mntBorrowIndex);
event EmissionRewardAccrued(address account, uint256 amount);
event RepresentativeRewardAccrued(address account, address provider, uint256 amount);
event BuybackRewardAccrued(address account, uint256 amount);
event RewardUnlocked(address account, uint256 amount);
event Withdraw(address account, uint256 amount);
event MntGranted(address recipient, uint256 amount);
event MntSupplyEmissionRateUpdated(IMToken mToken, uint256 newSupplyEmissionRate);
event MntBorrowEmissionRateUpdated(IMToken mToken, uint256 newBorrowEmissionRate);
/**
* @notice get keccak-256 hash of gatekeeper
*/
function GATEKEEPER() external view returns (bytes32);
/**
* @notice get keccak-256 hash of timelock
*/
function TIMELOCK() external view returns (bytes32);
/**
* @notice Gets the rate at which MNT is distributed to the corresponding supply market (per block)
*/
function mntSupplyEmissionRate(IMToken) external view returns (uint256);
/**
* @notice Gets the rate at which MNT is distributed to the corresponding borrow market (per block)
*/
function mntBorrowEmissionRate(IMToken) external view returns (uint256);
/**
* @notice Gets the MNT market supply state for each market
*/
function mntSupplyState(IMToken) external view returns (uint224 index, uint32 blockN);
/**
* @notice Gets the MNT market borrow state for each market
*/
function mntBorrowState(IMToken) external view returns (uint224 index, uint32 blockN);
/**
* @notice Gets the MNT supply index and block number for each market
*/
function mntSupplierState(IMToken, address) external view returns (uint224 index, uint32 blockN);
/**
* @notice Gets the MNT borrow index and block number for each market
*/
function mntBorrowerState(IMToken, address) external view returns (uint224 index, uint32 blockN);
/**
* @notice Gets summary amount of available and delayed balances of an account.
*/
function totalBalanceOf(address account) external view returns (uint256);
/**
* @notice Gets amount of MNT that can be withdrawn from an account at this block.
*/
function availableBalanceOf(address account) external view returns (uint256);
/**
* @notice Initializes market in RewardsHub. Should be called once from Supervisor.supportMarket
* @dev RESTRICTION: Supervisor only
*/
function initMarket(IMToken mToken) external;
/**
* @notice Accrues MNT to the market by updating the borrow and supply indexes
* @dev This method doesn't update MNT index history in Minterest NFT.
* @param market The market whose supply and borrow index to update
* @return (MNT supply index, MNT borrow index)
*/
function updateAndGetMntIndexes(IMToken market) external returns (uint224, uint224);
/**
* @notice Shorthand function to distribute MNT emissions from supplies of one market.
*/
function distributeSupplierMnt(IMToken mToken, address account) external;
/**
* @notice Shorthand function to distribute MNT emissions from borrows of one market.
*/
function distributeBorrowerMnt(IMToken mToken, address account) external;
/**
* @notice Updates market indexes and distributes tokens (if any) for holder
* @dev Updates indexes and distributes only for those markets where the holder have a
* non-zero supply or borrow balance.
* @param account The address to distribute MNT for
*/
function distributeAllMnt(address account) external;
/**
* @notice Distribute all MNT accrued by the accounts
* @param accounts The addresses to distribute MNT for
* @param mTokens The list of markets to distribute MNT in
* @param borrowers Whether or not to distribute MNT earned by borrowing
* @param suppliers Whether or not to distribute MNT earned by supplying
*/
function distributeMnt(
address[] memory accounts,
IMToken[] memory mTokens,
bool borrowers,
bool suppliers
) external;
/**
* @notice Accrues buyback reward
* @dev RESTRICTION: Buyback only
*/
function accrueBuybackReward(address account, uint256 amount) external;
/**
* @notice Gets part of delayed rewards that is unlocked and have become available.
*/
function getUnlockableRewards(address account) external view returns (uint256);
/**
* @notice Transfers available part of MNT rewards to the sender.
* This will decrease accounts buyback and voting weights.
*/
function withdraw(uint256 amount) external;
/**
* @notice Transfers
* @dev RESTRICTION: Admin only
*/
function grant(address recipient, uint256 amount) external;
/**
* @notice Set MNT borrow and supply emission rates for a single market
* @param mToken The market whose MNT emission rate to update
* @param newMntSupplyEmissionRate New supply MNT emission rate for market
* @param newMntBorrowEmissionRate New borrow MNT emission rate for market
* @dev RESTRICTION Timelock only
*/
function setMntEmissionRates(
IMToken mToken,
uint256 newMntSupplyEmissionRate,
uint256 newMntBorrowEmissionRate
) external;
}// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "@openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import "./ILinkageLeaf.sol";
interface IMnt is IERC20Upgradeable, IERC165, IAccessControlUpgradeable, ILinkageLeaf {
event MaxNonVotingPeriodChanged(uint256 oldPeriod, uint256 newPeriod);
event NewGovernor(address governor);
event VotesUpdated(address account, uint256 oldVotingWeight, uint256 newVotingWeight);
event TotalVotesUpdated(uint256 oldTotalVotes, uint256 newTotalVotes);
/**
* @notice get governor
*/
function governor() external view returns (address);
/**
* @notice returns votingWeight for user
*/
function votingWeight(address) external view returns (uint256);
/**
* @notice get total voting weight
*/
function totalVotingWeight() external view returns (uint256);
/**
* @notice Updates voting power of the account
*/
function updateVotingWeight(address account) external;
/**
* @notice Creates new total voting weight checkpoint
* @dev RESTRICTION: Governor only.
*/
function updateTotalWeightCheckpoint() external;
/**
* @notice Checks user activity for the last `maxNonVotingPeriod` blocks
* @param account_ The address of the account
* @return returns true if the user voted or his delegatee voted for the last maxNonVotingPeriod blocks,
* otherwise returns false
*/
function isParticipantActive(address account_) external view returns (bool);
/**
* @notice Updates last voting timestamp of the account
* @dev RESTRICTION: Governor only.
*/
function updateVoteTimestamp(address account) external;
/**
* @notice Gets the latest voting timestamp for account.
* @dev If the user delegated his votes, then it also checks the timestamp of the last vote of the delegatee
* @param account The address of the account
* @return latest voting timestamp for account
*/
function lastActivityTimestamp(address account) external view returns (uint256);
/**
* @notice set new governor
* @dev RESTRICTION: Admin only.
*/
function setGovernor(address newGovernor) external;
/**
* @notice Sets the maxNonVotingPeriod
* @dev Admin function to set maxNonVotingPeriod
* @param newPeriod_ The new maxNonVotingPeriod (in sec). Must be greater than 90 days and lower than 2 years.
* @dev RESTRICTION: Admin only.
*/
function setMaxNonVotingPeriod(uint256 newPeriod_) external;
}// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "@openzeppelin/contracts/access/IAccessControl.sol";
import "./ILinkageLeaf.sol";
interface IBuyback is IAccessControl, ILinkageLeaf {
event Stake(address who, uint256 amount);
event Unstake(address who, uint256 amount);
event NewBuyback(uint256 amount, uint256 share);
event ParticipateBuyback(address who);
event LeaveBuyback(address who, uint256 currentStaked);
event BuybackWeightChanged(address who, uint256 newWeight, uint256 oldWeight, uint256 newTotalWeight);
event LoyaltyParametersChanged(uint256 newCoreFactor, uint32 newCoreResetPenalty);
event LoyaltyStrataChanged();
event LoyaltyGroupsChanged(uint256 newGroupCount);
/**
* @notice Gets info about account membership in Buyback
*/
function getMemberInfo(address account)
external
view
returns (
bool participating,
uint256 weight,
uint256 lastIndex,
uint256 stakeAmount
);
/**
* @notice Gets info about accounts loyalty calculation
*/
function getLoyaltyInfo(address account)
external
view
returns (
uint32 loyaltyStart,
uint256 coreBalance,
uint256 lastBalance
);
/**
* @notice Gets if an account is participating in Buyback
*/
function isParticipating(address account) external view returns (bool);
/**
* @notice Gets stake of the account
*/
function getStakedAmount(address account) external view returns (uint256);
/**
* @notice Gets buyback weight of an account
*/
function getWeight(address account) external view returns (uint256);
/**
* @notice Gets loyalty factor of an account with given balance.
*/
function getLoyaltyFactorForBalance(address account, uint256 balance) external view returns (uint256);
/**
* @notice Gets total Buyback weight, which is the sum of weights of all accounts.
*/
function getTotalWeight() external view returns (uint256);
/**
* @notice Gets current Buyback index.
* Its the accumulated sum of MNTs shares that are given for each weight of an account.
*/
function getBuybackIndex() external view returns (uint256);
/**
* @notice Gets all global loyalty parameters.
*/
function getLoyaltyParameters()
external
view
returns (
uint256[24] memory loyaltyStrata,
uint256[] memory groupThresholds,
uint32[] memory groupStartStrata,
uint256 coreFactor,
uint32 coreResetPenalty
);
/**
* @notice Stakes the specified amount of MNT and transfers them to this contract.
* @notice This contract should be approved to transfer MNT from sender account
* @param amount The amount of MNT to stake
*/
function stake(uint256 amount) external;
/**
* @notice Unstakes the specified amount of MNT and transfers them back to sender if he participates
* in the Buyback system, otherwise just transfers MNT tokens to the sender.
* would not be greater than staked amount left. If `amount == MaxUint256` unstakes all staked tokens.
* @param amount The amount of MNT to unstake
*/
function unstake(uint256 amount) external;
/**
* @notice Claims buyback rewards, updates buyback weight and voting power.
* Does nothing if account is not participating. Reverts if operation is paused.
* @param account Address to update weights for
*/
function updateBuybackAndVotingWeights(address account) external;
/**
* @notice Claims buyback rewards, updates buyback weight and voting power.
* Does nothing if account is not participating or update is paused.
* @param account Address to update weights for
*/
function updateBuybackAndVotingWeightsRelaxed(address account) external;
/**
* @notice Does a buyback using the specified amount of MNT from sender's account
* @param amount The amount of MNT to take and distribute as buyback
* @dev RESTRICTION: Distributor only
*/
function buyback(uint256 amount) external;
/**
* @notice Make account participating in the buyback.
*/
function participate() external;
/**
* @notice Make accounts participate in buyback before its start.
* @param accounts Address to make participate in buyback.
* @dev RESTRICTION: Admin only
*/
function participateOnBehalf(address[] memory accounts) external;
/**
* @notice Leave buyback participation, claim any MNTs rewarded by the buyback.
* Leaving does not withdraw staked MNTs but reduces weight of the account to zero
*/
function leave() external;
/**
* @notice Leave buyback participation on behalf, claim any MNTs rewarded by the buyback and
* reduce the weight of account to zero. All staked MNTs remain on the buyback contract and available
* for their owner to be claimed
* Can only be called if (timestamp > participantLastVoteTimestamp + maxNonVotingPeriod).
* @param participant Address to leave for
* @dev RESTRICTION: GATEKEEPER only
*/
function leaveOnBehalf(address participant) external;
/**
* @notice Leave buyback participation on behalf, claim any MNTs rewarded by the buyback and
* reduce the weight of account to zero. All staked MNTs remain on the buyback contract and available
* for their owner to be claimed.
* @dev Function to leave sanctioned accounts from Buyback system
* Can only be called if the participant is sanctioned by the AML system.
* @param participant Address to leave for
*/
function leaveByAmlDecision(address participant) external;
/**
* @notice Changes loyalty core factor and core reset penalty parameters.
* @dev RESTRICTION: Admin only
*/
function setLoyaltyParameters(uint256 newCoreFactor, uint32 newCoreResetPenalty) external;
/**
* @notice Sets new loyalty factors for all strata.
* @dev RESTRICTION: Admin only
*/
function setLoyaltyStrata(uint256[24] memory newLoyaltyStrata) external;
/**
* @notice Sets new groups and their parameters
* @param newGroupThresholds New list of groups and their balance thresholds.
* @param newGroupStartStrata Indexes of starting stratum of each group. First index MUST be zero.
* Length of array must be equal to the newGroupThresholds
* @dev RESTRICTION: Admin only
*/
function setLoyaltyGroups(uint256[] memory newGroupThresholds, uint32[] memory newGroupStartStrata) external;
}// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "./IMToken.sol";
interface IPriceOracle {
/**
* @notice Get the underlying price of a mToken asset
* @param mToken The mToken to get the underlying price of
* @return The underlying asset price mantissa (scaled by 1e18).
* Zero means the price is unavailable.
*
* @dev Price should be scaled to 1e18 for tokens with tokenDecimals = 1e18
* and for 1e30 for tokens with tokenDecimals = 1e6.
*/
function getUnderlyingPrice(IMToken mToken) external view returns (uint256);
/**
* @notice Return price for an asset
* @param asset address of token
* @return The underlying asset price mantissa (scaled by 1e18).
* Zero means the price is unavailable.
* @dev Price should be scaled to 1e18 for tokens with tokenDecimals = 1e18
* and for 1e30 for tokens with tokenDecimals = 1e6.
*/
function getAssetPrice(address asset) external view returns (uint256);
}// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "@openzeppelin/contracts/access/IAccessControl.sol";
import "./IMToken.sol";
import "./IDeadDrop.sol";
import "./ILinkageLeaf.sol";
import "./IPriceOracle.sol";
/**
* This contract provides the liquidation functionality.
*/
interface ILiquidation is IAccessControl, ILinkageLeaf {
event HealthyFactorLimitChanged(uint256 oldValue, uint256 newValue);
event NewDeadDrop(address oldDeadDrop, address newDeadDrop);
event NewInsignificantLoanThreshold(uint256 oldValue, uint256 newValue);
event ReliableLiquidation(
bool isManualLiquidation,
bool isDebtHealthy,
address liquidator,
address borrower,
IMToken[] marketAddresses,
uint256[] seizeIndexes,
uint256[] debtRates
);
event ProcessingStateUsageChanged(bool newValue);
/**
* @dev Local accountState for avoiding stack-depth limits in calculating liquidation amounts.
*/
struct AccountLiquidationAmounts {
uint256 accountTotalSupplyUsd;
uint256 accountTotalCollateralUsd;
uint256 accountPresumedTotalRepayUsd;
uint256 accountTotalBorrowUsd;
uint256[] repayAmounts;
uint256[] seizeAmounts;
}
/**
* @notice GET The maximum allowable value of a healthy factor after liquidation, scaled by 1e18
*/
function healthyFactorLimit() external view returns (uint256);
/**
* @notice GET Maximum sum in USD for internal liquidation. Collateral for loans that are less
* than this parameter will be counted as protocol interest, scaled by 1e18
*/
function insignificantLoanThreshold() external view returns (uint256);
/**
* @notice get keccak-256 hash of TRUSTED_LIQUIDATOR role
*/
function TRUSTED_LIQUIDATOR() external view returns (bytes32);
/**
* @notice get keccak-256 hash of MANUAL_LIQUIDATOR role
*/
function MANUAL_LIQUIDATOR() external view returns (bytes32);
/**
* @notice get keccak-256 hash of TIMELOCK role
*/
function TIMELOCK() external view returns (bytes32);
/**
* @notice Liquidate insolvent debt position
* @param borrower_ Account which is being liquidated
* @param seizeIndexes_ An array with market indexes that will be used as collateral.
* Each element corresponds to the market index in the accountAssets array
* @param debtRates_ An array of debt redemption rates for each debt markets (scaled by 1e18).
* @dev RESTRICTION: Trusted liquidator only
*/
function liquidateUnsafeLoan(
address borrower_,
uint256[] memory seizeIndexes_,
uint256[] memory debtRates_
) external;
/**
* @notice Accrues interest for all required borrower's markets
* @dev Accrue is required if market is used as borrow (debtRate > 0)
* or collateral (seizeIndex arr contains market index)
* The caller must ensure that the lengths of arrays 'accountAssets' and 'debtRates' are the same,
* array 'seizeIndexes' does not contain duplicates and none of the indexes exceeds the value
* (accountAssets.length - 1).
* @param accountAssets An array with addresses of markets where the debtor is in
* @param seizeIndexes_ An array with market indexes that will be used as collateral
* Each element corresponds to the market index in the accountAssets array
* @param debtRates_ An array of debt redemption rates for each debt markets (scaled by 1e18)
*/
function accrue(
IMToken[] memory accountAssets,
uint256[] memory seizeIndexes_,
uint256[] memory debtRates_
) external;
/**
* @notice For each market calculates the liquidation amounts based on borrower's state.
* @param account_ The address of the borrower
* @param marketAddresses An array with addresses of markets where the debtor is in
* @param seizeIndexes_ An array with market indexes that will be used as collateral
* Each element corresponds to the market index in the accountAssets array
* @param debtRates_ An array of debt redemption rates for each debt markets (scaled by 1e18)
* @return accountState Struct that contains all balance parameters
* All arrays calculated in underlying assets, all total values calculated in USD.
* (the array indexes match each other)
*/
function calculateLiquidationAmounts(
address account_,
IMToken[] memory marketAddresses,
uint256[] memory seizeIndexes_,
uint256[] memory debtRates_
) external view returns (AccountLiquidationAmounts memory);
/**
* @notice Sets a new value for healthyFactorLimit
* @dev RESTRICTION: Timelock only
*/
function setHealthyFactorLimit(uint256 newValue_) external;
/**
* @notice Sets a new minterest deadDrop
* @dev RESTRICTION: Admin only
*/
function setDeadDrop(address newDeadDrop_) external;
/**
* @notice Sets a new insignificantLoanThreshold
* @dev RESTRICTION: Timelock only
*/
function setInsignificantLoanThreshold(uint256 newValue_) external;
/**
* @notice Sets a new state for useProcessingState
* @dev RESTRICTION: Admin only
*/
function setProcessingStateUsage(bool newValue_) external;
}// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "@openzeppelin/contracts/access/IAccessControl.sol";
import "./ILinkageLeaf.sol";
interface IBDSystem is IAccessControl, ILinkageLeaf {
event AgreementAdded(
address indexed liquidityProvider,
address indexed representative,
uint256 representativeBonus,
uint256 liquidityProviderBoost,
uint32 startBlock,
uint32 endBlock
);
event AgreementEnded(
address indexed liquidityProvider,
address indexed representative,
uint256 representativeBonus,
uint256 liquidityProviderBoost,
uint32 endBlock
);
/**
* @notice getter function to get liquidity provider agreement
*/
function providerToAgreement(address)
external
view
returns (
uint256 liquidityProviderBoost,
uint256 representativeBonus,
uint32 endBlock,
address representative
);
/**
* @notice getter function to get counts
* of liquidity providers of the representative
*/
function representativesProviderCounter(address) external view returns (uint256);
/**
* @notice Creates a new agreement between liquidity provider and representative
* @dev Admin function to create a new agreement
* @param liquidityProvider_ address of the liquidity provider
* @param representative_ address of the liquidity provider representative.
* @param representativeBonus_ percentage of the emission boost for representative
* @param liquidityProviderBoost_ percentage of the boost for liquidity provider
* @param endBlock_ The number of the first block when agreement will not be in effect
* @dev RESTRICTION: Admin only
*/
function createAgreement(
address liquidityProvider_,
address representative_,
uint256 representativeBonus_,
uint256 liquidityProviderBoost_,
uint32 endBlock_
) external;
/**
* @notice Removes a agreement between liquidity provider and representative
* @dev Admin function to remove a agreement
* @param liquidityProvider_ address of the liquidity provider
* @param representative_ address of the representative.
* @dev RESTRICTION: Admin only
*/
function removeAgreement(address liquidityProvider_, address representative_) external;
/**
* @notice checks if `account_` is liquidity provider.
* @dev account_ is liquidity provider if he has agreement.
* @param account_ address to check
* @return `true` if `account_` is liquidity provider, otherwise returns false
*/
function isAccountLiquidityProvider(address account_) external view returns (bool);
/**
* @notice checks if `account_` is business development representative.
* @dev account_ is business development representative if he has liquidity providers.
* @param account_ address to check
* @return `true` if `account_` is business development representative, otherwise returns false
*/
function isAccountRepresentative(address account_) external view returns (bool);
/**
* @notice checks if agreement is expired
* @dev reverts if the `account_` is not a valid liquidity provider
* @param account_ address of the liquidity provider
* @return `true` if agreement is expired, otherwise returns false
*/
function isAgreementExpired(address account_) external view returns (bool);
}// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
interface IWeightAggregator {
/**
* @notice Returns MNTs of the account that are used in buyback weight calculation.
*/
function getAccountFunds(address account) external view returns (uint256);
/**
* @notice Returns loyalty factor of the specified account.
*/
function getLoyaltyFactor(address account) external view returns (uint256);
/**
* @notice Returns Buyback weight for the user
*/
function getBuybackWeight(address account) external view returns (uint256);
/**
* @notice Return voting weight for the user
*/
function getVotingWeight(address account) external view returns (uint256);
}// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "@openzeppelin/contracts/access/IAccessControl.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "./IBuyback.sol";
/**
* @title Vesting contract provides unlocking of tokens on a schedule. It uses the *graded vesting* way,
* which unlocks a specific amount of balance every period of time, until all balance unlocked.
*
* Vesting Schedule.
*
* The schedule of a vesting is described by data structure `VestingSchedule`: starting from the start timestamp
* throughout the duration, the entire amount of totalAmount tokens will be unlocked.
*/
interface IVesting is IAccessControl {
/**
* @notice An event that's emitted when a new vesting schedule for a account is created.
*/
event VestingScheduleAdded(address target, VestingSchedule schedule);
/**
* @notice An event that's emitted when a vesting schedule revoked.
*/
event VestingScheduleRevoked(address target, uint256 unreleased, uint256 locked);
/**
* @notice An event that's emitted when the account Withdrawn the released tokens.
*/
event Withdrawn(address target, uint256 withdrawn);
/**
* @notice Emitted when an account is added to the delay list
*/
event AddedToDelayList(address account);
/**
* @notice Emitted when an account is removed from the delay list
*/
event RemovedFromDelayList(address account);
/**
* @notice The structure is used in the contract constructor for create vesting schedules
* during contract deploying.
* @param totalAmount the number of tokens to be vested during the vesting duration.
* @param target the address that will receive tokens according to schedule parameters.
* @param start offset in minutes at which vesting starts. Zero will vesting immediately.
* @param duration duration in minutes of the period in which the tokens will vest.
* @param revocable whether the vesting is revocable or not.
*/
struct ScheduleData {
uint256 totalAmount;
address target;
uint32 start;
uint32 duration;
bool revocable;
}
/**
* @notice Vesting schedules of an account.
* @param totalAmount the number of tokens to be vested during the vesting duration.
* @param released the amount of the token released. It means that the account has called withdraw() and received
* @param start the timestamp in minutes at which vesting starts. Must not be equal to zero, as it is used to
* check for the existence of a vesting schedule.
* @param duration duration in minutes of the period in which the tokens will vest.
* `released amount` of tokens to his address.
* @param revocable whether the vesting is revocable or not.
*/
struct VestingSchedule {
uint256 totalAmount;
uint256 released;
uint32 created;
uint32 start;
uint32 duration;
bool revocable;
}
/// @notice get keccak-256 hash of GATEKEEPER role
function GATEKEEPER() external view returns (bytes32);
/// @notice get keccak-256 hash of TOKEN_PROVIDER role
function TOKEN_PROVIDER() external view returns (bytes32);
/**
* @notice get vesting schedule of an account.
*/
function schedules(address)
external
view
returns (
uint256 totalAmount,
uint256 released,
uint32 created,
uint32 start,
uint32 duration,
bool revocable
);
/**
* @notice Gets the amount of MNT that was transferred to Vesting contract
* and can be transferred to other accounts via vesting process.
* Transferring rewards from Vesting via withdraw method will decrease this amount.
*/
function allocation() external view returns (uint256);
/**
* @notice Gets the amount of allocated MNT tokens that are not used in any vesting schedule yet.
* Creation of new vesting schedules will decrease this amount.
*/
function freeAllocation() external view returns (uint256);
/**
* @notice get Whether or not the account is in the delay list
*/
function delayList(address) external view returns (bool);
/**
* @notice Withdraw the specified number of tokens. For a successful transaction, the requirement
* `amount_ > 0 && amount_ <= unreleased` must be met.
* If `amount_ == MaxUint256` withdraw all unreleased tokens.
* @param amount_ The number of tokens to withdraw.
*/
function withdraw(uint256 amount_) external;
/**
* @notice Increases vesting schedule allocation and transfers MNT into Vesting.
* @dev RESTRICTION: TOKEN_PROVIDER only
*/
function refill(uint256 amount) external;
/**
* @notice Transfers MNT that were added to the contract without calling the refill and are unallocated.
* @dev RESTRICTION: Admin only
*/
function sweep(address recipient, uint256 amount) external;
/**
* @notice Allows the admin to create a new vesting schedules.
* @param schedulesData an array of vesting schedules that will be created.
* @dev RESTRICTION: Admin only.
*/
function createVestingScheduleBatch(ScheduleData[] memory schedulesData) external;
/**
* @notice Allows the admin to revoke the vesting schedule. Tokens already vested
* transfer to the account, the rest are returned to the vesting contract.
* Accounts that are in delay list have their withdraw blocked so they would not receive anything.
* @param target_ the address from which the vesting schedule is revoked.
* @dev RESTRICTION: Gatekeeper only.
*/
function revokeVestingSchedule(address target_) external;
/**
* @notice Calculates the end of the vesting.
* @param who_ account address for which the parameter is returned.
* @return the end of the vesting.
*/
function endOfVesting(address who_) external view returns (uint256);
/**
* @notice Calculates locked amount for a given `time`.
* @param who_ account address for which the parameter is returned.
* @return locked amount for a given `time`.
*/
function lockedAmount(address who_) external view returns (uint256);
/**
* @notice Calculates the amount that has already vested.
* @param who_ account address for which the parameter is returned.
* @return the amount that has already vested.
*/
function vestedAmount(address who_) external view returns (uint256);
/**
* @notice Calculates the amount that has already vested but hasn't been released yet.
* @param who_ account address for which the parameter is returned.
* @return the amount that has already vested but hasn't been released yet.
*/
function releasableAmount(address who_) external view returns (uint256);
/**
* @notice Gets the amount that has already vested but hasn't been released yet if account
* schedule had no starting delay (cliff).
*/
function getReleasableWithoutCliff(address account) external view returns (uint256);
/**
* @notice Add an account with revocable schedule to the delay list
* @param who_ The account that is being added to the delay list
* @dev RESTRICTION: Gatekeeper only.
*/
function addToDelayList(address who_) external;
/**
* @notice Remove an account from the delay list
* @param who_ The account that is being removed from the delay list
* @dev RESTRICTION: Gatekeeper only.
*/
function removeFromDelayList(address who_) external;
}// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "@openzeppelin/contracts/access/IAccessControl.sol";
import "./ISupervisor.sol";
import "./IRewardsHub.sol";
import "./IMToken.sol";
import "./ILinkageLeaf.sol";
interface IEmissionBooster is IAccessControl, ILinkageLeaf {
/**
* @notice Emitted when new Tier was created
*/
event NewTierCreated(uint256 createdTier, uint32 endBoostBlock, uint256 emissionBoost);
/**
* @notice Emitted when Tier was enabled
*/
event TierEnabled(
IMToken market,
uint256 enabledTier,
uint32 startBoostBlock,
uint224 mntSupplyIndex,
uint224 mntBorrowIndex
);
/**
* @notice Emitted when emission boost mode was enabled
*/
event EmissionBoostEnabled(address caller);
/**
* @notice Emitted when MNT supply index of the tier ending on the market was saved to storage
*/
event SupplyIndexUpdated(address market, uint256 nextTier, uint224 newIndex, uint32 endBlock);
/**
* @notice Emitted when MNT borrow index of the tier ending on the market was saved to storage
*/
event BorrowIndexUpdated(address market, uint256 nextTier, uint224 newIndex, uint32 endBlock);
/**
* @notice get the Tier for each MinterestNFT token
*/
function tokenTier(uint256) external view returns (uint256);
/**
* @notice get a list of all created Tiers
*/
function tiers(uint256)
external
view
returns (
uint32,
uint32,
uint256
);
/**
* @notice get status of emission boost mode.
*/
function isEmissionBoostingEnabled() external view returns (bool);
/**
* @notice get Stored markets indexes per block.
*/
function marketSupplyIndexes(IMToken, uint256) external view returns (uint256);
/**
* @notice get Stored markets indexes per block.
*/
function marketBorrowIndexes(IMToken, uint256) external view returns (uint256);
/**
* @notice Mint token hook which is called from MinterestNFT.mint() and sets specific
* settings for this NFT
* @param to_ NFT ovner
* @param ids_ NFTs IDs
* @param amounts_ Amounts of minted NFTs per tier
* @param tiers_ NFT tiers
* @dev RESTRICTION: MinterestNFT only
*/
function onMintToken(
address to_,
uint256[] memory ids_,
uint256[] memory amounts_,
uint256[] memory tiers_
) external;
/**
* @notice Transfer token hook which is called from MinterestNFT.transfer() and sets specific
* settings for this NFT
* @param from_ Address of the tokens previous owner. Should not be zero (minter).
* @param to_ Address of the tokens new owner.
* @param ids_ NFTs IDs
* @param amounts_ Amounts of minted NFTs per tier
* @dev RESTRICTION: MinterestNFT only
*/
function onTransferToken(
address from_,
address to_,
uint256[] memory ids_,
uint256[] memory amounts_
) external;
/**
* @notice Enables emission boost mode.
* @dev Admin function for enabling emission boosts.
* @dev RESTRICTION: Whitelist only
*/
function enableEmissionBoosting() external;
/**
* @notice Creates new Tiers for MinterestNFT tokens
* @dev Admin function for creating Tiers
* @param endBoostBlocks Emission boost end blocks for created Tiers
* @param emissionBoosts Emission boosts for created Tiers, scaled by 1e18
* Note: The arrays passed to the function must be of the same length and the order of the elements must match
* each other
* @dev RESTRICTION: Admin only
*/
function createTiers(uint32[] memory endBoostBlocks, uint256[] memory emissionBoosts) external;
/**
* @notice Enables emission boost in specified Tiers
* @param tiersForEnabling Tier for enabling emission boost
* @dev RESTRICTION: Admin only
*/
function enableTiers(uint256[] memory tiersForEnabling) external;
/**
* @notice Return the number of created Tiers
* @return The number of created Tiers
*/
function getNumberOfTiers() external view returns (uint256);
/**
* @notice Checks if the specified Tier is active
* @param tier_ The Tier that is being checked
*/
function isTierActive(uint256 tier_) external view returns (bool);
/**
* @notice Checks if the specified Tier exists
* @param tier_ The Tier that is being checked
*/
function tierExists(uint256 tier_) external view returns (bool);
/**
* @param account_ The address of the account
* @return Bitmap of all accounts tiers
*/
function getAccountTiersBitmap(address account_) external view returns (uint256);
/**
* @param account_ The address of the account to check if they have any tokens with tier
*/
function isAccountHaveTiers(address account_) external view returns (bool);
/**
* @param account_ Address of the account
* @return tier Highest tier number
* @return boost Highest boost amount
*/
function getCurrentAccountBoost(address account_) external view returns (uint256 tier, uint256 boost);
/**
* @notice Calculates emission boost for the account.
* @param market_ Market for which we are calculating emission boost
* @param account_ The address of the account for which we are calculating emission boost
* @param userLastIndex_ The account's last updated mntBorrowIndex or mntSupplyIndex
* @param userLastBlock_ The block number in which the index for the account was last updated
* @param marketIndex_ The market's current mntBorrowIndex or mntSupplyIndex
* @param isSupply_ boolean value, if true, then return calculate emission boost for suppliers
* @return boostedIndex Boost part of delta index
*/
function calculateEmissionBoost(
IMToken market_,
address account_,
uint256 userLastIndex_,
uint256 userLastBlock_,
uint256 marketIndex_,
bool isSupply_
) external view returns (uint256 boostedIndex);
/**
* @notice Update MNT supply index for market for NFT tiers that are expired but not yet updated.
* @dev This function checks if there are tiers to update and process them one by one:
* calculates the MNT supply index depending on the delta index and delta blocks between
* last MNT supply index update and the current state,
* emits SupplyIndexUpdated event and recalculates next tier to update.
* @param market Address of the market to update
* @param lastUpdatedBlock Last updated block number
* @param lastUpdatedIndex Last updated index value
* @param currentSupplyIndex Current MNT supply index value
* @dev RESTRICTION: RewardsHub only
*/
function updateSupplyIndexesHistory(
IMToken market,
uint256 lastUpdatedBlock,
uint256 lastUpdatedIndex,
uint256 currentSupplyIndex
) external;
/**
* @notice Update MNT borrow index for market for NFT tiers that are expired but not yet updated.
* @dev This function checks if there are tiers to update and process them one by one:
* calculates the MNT borrow index depending on the delta index and delta blocks between
* last MNT borrow index update and the current state,
* emits BorrowIndexUpdated event and recalculates next tier to update.
* @param market Address of the market to update
* @param lastUpdatedBlock Last updated block number
* @param lastUpdatedIndex Last updated index value
* @param currentBorrowIndex Current MNT borrow index value
* @dev RESTRICTION: RewardsHub only
*/
function updateBorrowIndexesHistory(
IMToken market,
uint256 lastUpdatedBlock,
uint256 lastUpdatedIndex,
uint256 currentBorrowIndex
) external;
/**
* @notice Get Id of NFT tier to update next on provided market MNT index, supply or borrow
* @param market Market for which should the next Tier to update be updated
* @param isSupply_ Flag that indicates whether MNT supply or borrow market should be updated
* @return Id of tier to update
*/
function getNextTierToBeUpdatedIndex(IMToken market, bool isSupply_) external view returns (uint256);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC1155 compliant contract, as defined in the
* https://eips.ethereum.org/EIPS/eip-1155[EIP].
*
* _Available since v3.1._
*/
interface IERC1155 is IERC165 {
/**
* @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
*/
event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
/**
* @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
* transfers.
*/
event TransferBatch(
address indexed operator,
address indexed from,
address indexed to,
uint256[] ids,
uint256[] values
);
/**
* @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
* `approved`.
*/
event ApprovalForAll(address indexed account, address indexed operator, bool approved);
/**
* @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
*
* If an {URI} event was emitted for `id`, the standard
* https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
* returned by {IERC1155MetadataURI-uri}.
*/
event URI(string value, uint256 indexed id);
/**
* @dev Returns the amount of tokens of token type `id` owned by `account`.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) external view returns (uint256);
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
external
view
returns (uint256[] memory);
/**
* @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
*
* Emits an {ApprovalForAll} event.
*
* Requirements:
*
* - `operator` cannot be the caller.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address account, address operator) external view returns (bool);
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes calldata data
) external;
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata amounts,
bytes calldata data
) external;
}// 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 IAccessControl {
/**
* @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 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 IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "@openzeppelin/contracts/interfaces/IERC3156FlashLender.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import "@openzeppelin/contracts/access/IAccessControl.sol";
import "./IInterestRateModel.sol";
interface IMToken is IAccessControl, IERC20, IERC3156FlashLender, IERC165 {
/**
* @notice Event emitted when interest is accrued
*/
event AccrueInterest(
uint256 cashPrior,
uint256 interestAccumulated,
uint256 borrowIndex,
uint256 totalBorrows,
uint256 totalProtocolInterest
);
/**
* @notice Event emitted when tokens are lended
*/
event Lend(address lender, uint256 lendAmount, uint256 lendTokens, uint256 newTotalTokenSupply);
/**
* @notice Event emitted when tokens are redeemed
*/
event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens, uint256 newTotalTokenSupply);
/**
* @notice Event emitted when underlying is borrowed
*/
event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);
/**
* @notice Event emitted when tokens are seized
*/
event Seize(
address borrower,
address receiver,
uint256 seizeTokens,
uint256 accountsTokens,
uint256 totalSupply,
uint256 seizeUnderlyingAmount
);
/**
* @notice Event emitted when a borrow is repaid
*/
event RepayBorrow(
address payer,
address borrower,
uint256 repayAmount,
uint256 accountBorrows,
uint256 totalBorrows
);
/**
* @notice Event emitted when a borrow is repaid during autoliquidation
*/
event AutoLiquidationRepayBorrow(
address borrower,
uint256 repayAmount,
uint256 accountBorrowsNew,
uint256 totalBorrowsNew,
uint256 TotalProtocolInterestNew
);
/**
* @notice Event emitted when flash loan is executed
*/
event FlashLoanExecuted(address receiver, uint256 amount, uint256 fee);
/**
* @notice Event emitted when interestRateModel is changed
*/
event NewMarketInterestRateModel(IInterestRateModel oldInterestRateModel, IInterestRateModel newInterestRateModel);
/**
* @notice Event emitted when the protocol interest factor is changed
*/
event NewProtocolInterestFactor(
uint256 oldProtocolInterestFactorMantissa,
uint256 newProtocolInterestFactorMantissa
);
/**
* @notice Event emitted when the flash loan max share is changed
*/
event NewFlashLoanMaxShare(uint256 oldMaxShare, uint256 newMaxShare);
/**
* @notice Event emitted when the flash loan fee is changed
*/
event NewFlashLoanFee(uint256 oldFee, uint256 newFee);
/**
* @notice Event emitted when the protocol interest are added
*/
event ProtocolInterestAdded(address benefactor, uint256 addAmount, uint256 newTotalProtocolInterest);
/**
* @notice Event emitted when the protocol interest reduced
*/
event ProtocolInterestReduced(address admin, uint256 reduceAmount, uint256 newTotalProtocolInterest);
/**
* @notice Value is the Keccak-256 hash of "TIMELOCK"
*/
function TIMELOCK() external view returns (bytes32);
/**
* @notice Underlying asset for this MToken
*/
function underlying() external view returns (IERC20);
/**
* @notice EIP-20 token name for this token
*/
function name() external view returns (string memory);
/**
* @notice EIP-20 token symbol for this token
*/
function symbol() external view returns (string memory);
/**
* @notice EIP-20 token decimals for this token
*/
function decimals() external view returns (uint8);
/**
* @notice Model which tells what the current interest rate should be
*/
function interestRateModel() external view returns (IInterestRateModel);
/**
* @notice Initial exchange rate used when lending the first MTokens (used when totalTokenSupply = 0)
*/
function initialExchangeRateMantissa() external view returns (uint256);
/**
* @notice Fraction of interest currently set aside for protocol interest
*/
function protocolInterestFactorMantissa() external view returns (uint256);
/**
* @notice Block number that interest was last accrued at
*/
function accrualBlockNumber() external view returns (uint256);
/**
* @notice Accumulator of the total earned interest rate since the opening of the market
*/
function borrowIndex() external view returns (uint256);
/**
* @notice Total amount of outstanding borrows of the underlying in this market
*/
function totalBorrows() external view returns (uint256);
/**
* @notice Total amount of protocol interest of the underlying held in this market
*/
function totalProtocolInterest() external view returns (uint256);
/**
* @notice Share of market's current underlying token balance that can be used as flash loan (scaled by 1e18).
*/
function maxFlashLoanShare() external view returns (uint256);
/**
* @notice Share of flash loan amount that would be taken as fee (scaled by 1e18).
*/
function flashLoanFeeShare() external view returns (uint256);
/**
* @notice Returns total token supply
*/
function totalSupply() external view returns (uint256);
/**
* @notice Transfer `amount` tokens from `msg.sender` to `dst`
* @param dst The address of the destination account
* @param amount The number of tokens to transfer
* @return Whether or not the transfer succeeded
*/
function transfer(address dst, uint256 amount) external returns (bool);
/**
* @notice Transfer `amount` tokens from `src` to `dst`
* @param src The address of the source account
* @param dst The address of the destination account
* @param amount The number of tokens to transfer
* @return Whether or not the transfer succeeded
*/
function transferFrom(
address src,
address dst,
uint256 amount
) external returns (bool);
/**
* @notice Approve `spender` to transfer up to `amount` from `src`
* @dev This will overwrite the approval amount for `spender`
* and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)
* @param spender The address of the account which may transfer tokens
* @param amount The number of tokens that are approved (-1 means infinite)
* @return Whether or not the approval succeeded
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @notice Get the current allowance from `owner` for `spender`
* @param owner The address of the account which owns the tokens to be spent
* @param spender The address of the account which may transfer tokens
* @return The number of tokens allowed to be spent (-1 means infinite)
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @notice Get the token balance of the `owner`
* @param owner The address of the account to query
* @return The number of tokens owned by `owner`
*/
function balanceOf(address owner) external view returns (uint256);
/**
* @notice Get the underlying balance of the `owner`
* @dev This also accrues interest in a transaction
* @param owner The address of the account to query
* @return The amount of underlying owned by `owner`
*/
function balanceOfUnderlying(address owner) external returns (uint256);
/**
* @notice Get a snapshot of the account's balances, and the cached exchange rate
* @dev This is used by supervisor to more efficiently perform liquidity checks.
* @param account Address of the account to snapshot
* @return (token balance, borrow balance, exchange rate mantissa)
*/
function getAccountSnapshot(address account)
external
view
returns (
uint256,
uint256,
uint256
);
/**
* @notice Returns the current per-block borrow interest rate for this mToken
* @return The borrow interest rate per block, scaled by 1e18
*/
function borrowRatePerBlock() external view returns (uint256);
/**
* @notice Returns the current per-block supply interest rate for this mToken
* @return The supply interest rate per block, scaled by 1e18
*/
function supplyRatePerBlock() external view returns (uint256);
/**
* @notice Returns the current total borrows plus accrued interest
* @return The total borrows with interest
*/
function totalBorrowsCurrent() external returns (uint256);
/**
* @notice Accrue interest to updated borrowIndex and then calculate account's
* borrow balance using the updated borrowIndex
* @param account The address whose balance should be calculated after updating borrowIndex
* @return The calculated balance
*/
function borrowBalanceCurrent(address account) external returns (uint256);
/**
* @notice Return the borrow balance of account based on stored data
* @param account The address whose balance should be calculated
* @return The calculated balance
*/
function borrowBalanceStored(address account) external view returns (uint256);
/**
* @notice Accrue interest then return the up-to-date exchange rate
* @return Calculated exchange rate scaled by 1e18
*/
function exchangeRateCurrent() external returns (uint256);
/**
* @notice Calculates the exchange rate from the underlying to the MToken
* @dev This function does not accrue interest before calculating the exchange rate
* @return Calculated exchange rate scaled by 1e18
*/
function exchangeRateStored() external view returns (uint256);
/**
* @notice Get cash balance of this mToken in the underlying asset
* @return The quantity of underlying asset owned by this contract
*/
function getCash() external view returns (uint256);
/**
* @notice Applies accrued interest to total borrows and protocol interest
* @dev This calculates interest accrued from the last checkpointed block
* up to the current block and writes new checkpoint to storage.
*/
function accrueInterest() external;
/**
* @notice Sender supplies assets into the market and receives mTokens in exchange
* @dev Accrues interest whether or not the operation succeeds, unless reverted
* @param lendAmount The amount of the underlying asset to supply
*/
function lend(uint256 lendAmount) external;
/**
* @notice Sender redeems mTokens in exchange for the underlying asset
* @dev Accrues interest whether or not the operation succeeds, unless reverted
* @param redeemTokens The number of mTokens to redeem into underlying
*/
function redeem(uint256 redeemTokens) external;
/**
* @notice Redeems all mTokens for account in exchange for the underlying asset.
* Can only be called within the AML system!
* @dev Accrues interest whether or not the operation succeeds, unless reverted
* @param account An account that is potentially sanctioned by the AML system
*/
function redeemByAmlDecision(address account) external;
/**
* @notice Sender redeems mTokens in exchange for a specified amount of underlying asset
* @dev Accrues interest whether or not the operation succeeds, unless reverted
* @param redeemAmount The amount of underlying to receive from redeeming mTokens
*/
function redeemUnderlying(uint256 redeemAmount) external;
/**
* @notice Sender borrows assets from the protocol to their own address
* @param borrowAmount The amount of the underlying asset to borrow
*/
function borrow(uint256 borrowAmount) external;
/**
* @notice Sender repays their own borrow
* @param repayAmount The amount to repay
*/
function repayBorrow(uint256 repayAmount) external;
/**
* @notice Sender repays a borrow belonging to borrower
* @param borrower the account with the debt being payed off
* @param repayAmount The amount to repay
*/
function repayBorrowBehalf(address borrower, uint256 repayAmount) external;
/**
* @notice Liquidator repays a borrow belonging to borrower
* @param borrower_ the account with the debt being payed off
* @param repayAmount_ the amount of underlying tokens being returned
*/
function autoLiquidationRepayBorrow(address borrower_, uint256 repayAmount_) external;
/**
* @notice A public function to sweep accidental ERC-20 transfers to this contract.
* Tokens are sent to admin (timelock)
* @param token The address of the ERC-20 token to sweep
* @dev RESTRICTION: Admin only.
*/
function sweepToken(IERC20 token, address admin_) external;
/**
* @notice Burns collateral tokens at the borrower's address, transfer underlying assets
to the DeadDrop or Liquidator address.
* @dev Called only during an auto liquidation process, msg.sender must be the Liquidation contract.
* @param borrower_ The account having collateral seized
* @param seizeUnderlyingAmount_ The number of underlying assets to seize. The caller must ensure
that the parameter is greater than zero.
* @param isLoanInsignificant_ Marker for insignificant loan whose collateral must be credited to the
protocolInterest
* @param receiver_ Address that receives accounts collateral
*/
function autoLiquidationSeize(
address borrower_,
uint256 seizeUnderlyingAmount_,
bool isLoanInsignificant_,
address receiver_
) external;
/**
* @notice The amount of currency available to be lent.
* @param token The loan currency.
* @return The amount of `token` that can be borrowed.
*/
function maxFlashLoan(address token) external view returns (uint256);
/**
* @notice The fee to be charged for a given loan.
* @param token The loan currency.
* @param amount The amount of tokens lent.
* @return The amount of `token` to be charged for the loan, on top of the returned principal.
*/
function flashFee(address token, uint256 amount) external view returns (uint256);
/**
* @notice Initiate a flash loan.
* @param receiver The receiver of the tokens in the loan, and the receiver of the callback.
* @param token The loan currency.
* @param amount The amount of tokens lent.
* @param data Arbitrary data structure, intended to contain user-defined parameters.
*/
function flashLoan(
IERC3156FlashBorrower receiver,
address token,
uint256 amount,
bytes calldata data
) external returns (bool);
/**
* @notice accrues interest and sets a new protocol interest factor for the protocol
* @dev Admin function to accrue interest and set a new protocol interest factor
* @dev RESTRICTION: Timelock only.
*/
function setProtocolInterestFactor(uint256 newProtocolInterestFactorMantissa) external;
/**
* @notice Accrues interest and increase protocol interest by transferring from msg.sender
* @param addAmount_ Amount of addition to protocol interest
*/
function addProtocolInterest(uint256 addAmount_) external;
/**
* @notice Can only be called by liquidation contract. Increase protocol interest by transferring from payer.
* @dev Calling code should make sure that accrueInterest() was called before.
* @param payer_ The address from which the protocol interest will be transferred
* @param addAmount_ Amount of addition to protocol interest
*/
function addProtocolInterestBehalf(address payer_, uint256 addAmount_) external;
/**
* @notice Accrues interest and reduces protocol interest by transferring to admin
* @param reduceAmount Amount of reduction to protocol interest
* @dev RESTRICTION: Admin only.
*/
function reduceProtocolInterest(uint256 reduceAmount, address admin_) external;
/**
* @notice accrues interest and updates the interest rate model using setInterestRateModelFresh
* @dev Admin function to accrue interest and update the interest rate model
* @param newInterestRateModel the new interest rate model to use
* @dev RESTRICTION: Timelock only.
*/
function setInterestRateModel(IInterestRateModel newInterestRateModel) external;
/**
* @notice Updates share of markets cash that can be used as maximum amount of flash loan.
* @param newMax New max amount share
* @dev RESTRICTION: Timelock only.
*/
function setFlashLoanMaxShare(uint256 newMax) external;
/**
* @notice Updates fee of flash loan.
* @param newFee New fee share of flash loan
* @dev RESTRICTION: Timelock only.
*/
function setFlashLoanFeeShare(uint256 newFee) external;
}// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts/access/IAccessControl.sol";
interface IWhitelist is IAccessControl {
/**
* @notice The given member was added to the whitelist
*/
event MemberAdded(address);
/**
* @notice The given member was removed from the whitelist
*/
event MemberRemoved(address);
/**
* @notice Protocol operation mode switched
*/
event WhitelistModeWasTurnedOff();
/**
* @notice Amount of maxMembers changed
*/
event MaxMemberAmountChanged(uint256);
/**
* @notice get maximum number of members.
* When membership reaches this number, no new members may join.
*/
function maxMembers() external view returns (uint256);
/**
* @notice get the total number of members stored in the map.
*/
function memberCount() external view returns (uint256);
/**
* @notice get protocol operation mode.
*/
function whitelistModeEnabled() external view returns (bool);
/**
* @notice get is account member of whitelist
*/
function accountMembership(address) external view returns (bool);
/**
* @notice get keccak-256 hash of GATEKEEPER role
*/
function GATEKEEPER() external view returns (bytes32);
/**
* @notice Add a new member to the whitelist.
* @param newAccount The account that is being added to the whitelist.
* @dev RESTRICTION: Gatekeeper only.
*/
function addMember(address newAccount) external;
/**
* @notice Remove a member from the whitelist.
* @param accountToRemove The account that is being removed from the whitelist.
* @dev RESTRICTION: Gatekeeper only.
*/
function removeMember(address accountToRemove) external;
/**
* @notice Disables whitelist mode and enables emission boost mode.
* @dev RESTRICTION: Admin only.
*/
function turnOffWhitelistMode() external;
/**
* @notice Set a new threshold of participants.
* @param newThreshold New number of participants.
* @dev RESTRICTION: Gatekeeper only.
*/
function setMaxMembers(uint256 newThreshold) external;
/**
* @notice Check protocol operation mode. In whitelist mode, only members from whitelist and who have
* EmissionBooster can work with protocol.
* @param who The address of the account to check for participation.
*/
function isWhitelisted(address who) external view returns (bool);
}// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
/**
* @title Minterest InterestRateModel Interface
* @author Minterest
*/
interface IInterestRateModel {
/**
* @notice Calculates the current borrow interest rate per block
* @param cash The total amount of cash the market has
* @param borrows The total amount of borrows the market has outstanding
* @param protocolInterest The total amount of protocol interest the market has
* @return The borrow rate per block (as a percentage, and scaled by 1e18)
*/
function getBorrowRate(
uint256 cash,
uint256 borrows,
uint256 protocolInterest
) external view returns (uint256);
/**
* @notice Calculates the current supply interest rate per block
* @param cash The total amount of cash the market has
* @param borrows The total amount of borrows the market has outstanding
* @param protocolInterest The total amount of protocol interest the market has
* @param protocolInterestFactorMantissa The current protocol interest factor the market has
* @return The supply rate per block (as a percentage, and scaled by 1e18)
*/
function getSupplyRate(
uint256 cash,
uint256 borrows,
uint256 protocolInterest,
uint256 protocolInterestFactorMantissa
) external view returns (uint256);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC3156FlashLender.sol)
pragma solidity ^0.8.0;
import "./IERC3156FlashBorrower.sol";
/**
* @dev Interface of the ERC3156 FlashLender, as defined in
* https://eips.ethereum.org/EIPS/eip-3156[ERC-3156].
*
* _Available since v4.1._
*/
interface IERC3156FlashLender {
/**
* @dev The amount of currency available to be lended.
* @param token The loan currency.
* @return The amount of `token` that can be borrowed.
*/
function maxFlashLoan(address token) external view returns (uint256);
/**
* @dev The fee to be charged for a given loan.
* @param token The loan currency.
* @param amount The amount of tokens lent.
* @return The amount of `token` to be charged for the loan, on top of the returned principal.
*/
function flashFee(address token, uint256 amount) external view returns (uint256);
/**
* @dev Initiate a flash loan.
* @param receiver The receiver of the tokens in the loan, and the receiver of the callback.
* @param token The loan currency.
* @param amount The amount of tokens lent.
* @param data Arbitrary data structure, intended to contain user-defined parameters.
*/
function flashLoan(
IERC3156FlashBorrower receiver,
address token,
uint256 amount,
bytes calldata data
) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the 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.7.0) (interfaces/IERC3156FlashBorrower.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC3156 FlashBorrower, as defined in
* https://eips.ethereum.org/EIPS/eip-3156[ERC-3156].
*
* _Available since v4.1._
*/
interface IERC3156FlashBorrower {
/**
* @dev Receive a flash loan.
* @param initiator The initiator of the loan.
* @param token The loan currency.
* @param amount The amount of tokens lent.
* @param fee The additional amount of tokens to repay.
* @param data Arbitrary data structure, intended to contain user-defined parameters.
* @return The keccak256 hash of "IERC3156FlashBorrower.onFlashLoan"
*/
function onFlashLoan(
address initiator,
address token,
uint256 amount,
uint256 fee,
bytes calldata data
) external returns (bytes32);
}// 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.6.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: BSD-3-Clause
pragma solidity 0.8.17;
import "./ILiquidation.sol";
import "./IMToken.sol";
import "@openzeppelin/contracts/access/IAccessControl.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol";
interface IDeadDrop is IAccessControl {
event WithdrewToProtocolInterest(uint256 amount, IERC20 token, IMToken market);
event Withdraw(address token, address to, uint256 amount);
event NewLiquidation(ILiquidation liquidation);
event NewSwapRouter(ISwapRouter router);
event NewAllowedWithdrawReceiver(address receiver);
event NewAllowedBot(address bot);
event NewAllowedMarket(IERC20 token, IMToken market);
event AllowedWithdrawReceiverRemoved(address receiver);
event AllowedBotRemoved(address bot);
event AllowedMarketRemoved(IERC20 token, IMToken market);
event Swap(IERC20 tokenIn, IERC20 tokenOut, uint256 spentAmount, uint256 receivedAmount);
event NewProcessingState(address target, uint256 hashValue, uint256 oldState, uint256 newState);
event LiquidationFinalised(address target, uint256 hashValue);
/**
* @notice get Uniswap SwapRouter
*/
function swapRouter() external view returns (ISwapRouter);
/**
* @notice get Whitelist for markets allowed as a withdrawal destination.
*/
function allowedMarkets(IERC20) external view returns (IMToken);
/**
* @notice get whitelist for users who can be a withdrawal recipients
*/
function allowedWithdrawReceivers(address) external view returns (bool);
/**
* @notice get keccak-256 hash of gatekeeper role
*/
function GATEKEEPER() external view returns (bytes32);
/**
* @notice Perform swap on Uniswap DEX
* @param validationKey first part of the key used for onchain validation
* @param validationHash second part of the key used for onchain validation
* @param requiredState operation code that should precede the current operation
* @param targetState operation code that will be assigned after successful swap
* @param tokenIn input token
* @param tokenInAmount amount of input token
* @param tokenOut output token
* @param data Uniswap calldata
* @dev RESTRICTION: Gatekeeper only
*/
function performSwap(
address validationKey,
uint256 validationHash,
uint256 requiredState,
uint256 targetState,
IERC20 tokenIn,
uint256 tokenInAmount,
IERC20 tokenOut,
bytes calldata data
) external;
/**
* @notice Withdraw underlying asset to market's protocol interest
* @param validationKey first part of the key used for onchain validation
* @param validationHash second part of the key used for onchain validation
* @param requiredState operation code that should precede the current operation
* @param targetState operation code that will be assigned after successful withdrawal
* @param amount Amount to withdraw
* @param underlying Token to withdraw
* @dev RESTRICTION: Gatekeeper only
*/
function withdrawToProtocolInterest(
address validationKey,
uint256 validationHash,
uint256 requiredState,
uint256 targetState,
uint256 amount,
IERC20 underlying
) external;
/**
* @notice Set processing state of started liquidation
* @param target Address of the account under liquidation
* @param hashValue Liquidation identity hash
* @dev RESTRICTION: Liquidator contract only
*/
function initialiseLiquidation(address target, uint256 hashValue) external;
/**
* @notice Update processing state of ongoing liquidation
* @param validationKey first part of the key used for onchain validation
* @param validationHash second part of the key used for onchain validation
* @param targetState New state value of the liquidation
* @dev RESTRICTION: Gatekeeper only
*/
function updateProcessingState(
address validationKey,
uint256 validationHash,
uint256 targetState
) external;
/**
* @notice Finalise processing state of ongoing liquidation
* @param validationKey first part of the key used for onchain validation
* @param validationHash second part of the key used for onchain validation
* @param requiredState State value required to complete finalization
* @dev RESTRICTION: Gatekeeper only
*/
function finaliseLiquidation(
address validationKey,
uint256 validationHash,
uint256 requiredState
) external;
/**
* @notice Withdraw tokens to the wallet
* @param amount Amount to withdraw
* @param underlying Token to withdraw
* @param to Receipient address
* @dev RESTRICTION: Admin only
*/
function withdraw(
uint256 amount,
IERC20 underlying,
address to
) external;
/**
* @notice Add new market to the whitelist
* @dev RESTRICTION: Admin only
*/
function addAllowedMarket(IMToken market) external;
/**
* @notice Set new ILiquidation contract
* @dev RESTRICTION: Admin only
*/
function setLiquidationAddress(ILiquidation liquidationContract) external;
/**
* @notice Set new ISwapRouter router
* @dev RESTRICTION: Admin only
*/
function setRouterAddress(ISwapRouter router) external;
/**
* @notice Add new withdraw receiver address to the whitelist
* @dev RESTRICTION: TIMELOCK only
*/
function addAllowedReceiver(address receiver) external;
/**
* @notice Add new bot address to the whitelist
* @dev RESTRICTION: Admin only
*/
function addAllowedBot(address bot) external;
/**
* @notice Remove market from the whitelist
* @dev RESTRICTION: Admin only
*/
function removeAllowedMarket(IERC20 underlying) external;
/**
* @notice Remove withdraw receiver address from the whitelist
* @dev RESTRICTION: TIMELOCK only
*/
function removeAllowedReceiver(address receiver) external;
/**
* @notice Remove withdraw bot address from the whitelist
* @dev RESTRICTION: Admin only
*/
function removeAllowedBot(address bot) external;
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;
import '@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol';
/// @title Router token swapping functionality
/// @notice Functions for swapping tokens via Uniswap V3
interface ISwapRouter is IUniswapV3SwapCallback {
struct ExactInputSingleParams {
address tokenIn;
address tokenOut;
uint24 fee;
address recipient;
uint256 deadline;
uint256 amountIn;
uint256 amountOutMinimum;
uint160 sqrtPriceLimitX96;
}
/// @notice Swaps `amountIn` of one token for as much as possible of another token
/// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata
/// @return amountOut The amount of the received token
function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);
struct ExactInputParams {
bytes path;
address recipient;
uint256 deadline;
uint256 amountIn;
uint256 amountOutMinimum;
}
/// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path
/// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata
/// @return amountOut The amount of the received token
function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut);
struct ExactOutputSingleParams {
address tokenIn;
address tokenOut;
uint24 fee;
address recipient;
uint256 deadline;
uint256 amountOut;
uint256 amountInMaximum;
uint160 sqrtPriceLimitX96;
}
/// @notice Swaps as little as possible of one token for `amountOut` of another token
/// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata
/// @return amountIn The amount of the input token
function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn);
struct ExactOutputParams {
bytes path;
address recipient;
uint256 deadline;
uint256 amountOut;
uint256 amountInMaximum;
}
/// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed)
/// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata
/// @return amountIn The amount of the input token
function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Callback for IUniswapV3PoolActions#swap
/// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface
interface IUniswapV3SwapCallback {
/// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap.
/// @dev In the implementation you must pay the pool tokens owed for the swap.
/// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.
/// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.
/// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by
/// the end of the swap. If positive, the callback must send that amount of token0 to the pool.
/// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by
/// the end of the swap. If positive, the callback must send that amount of token1 to the pool.
/// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call
function uniswapV3SwapCallback(
int256 amount0Delta,
int256 amount1Delta,
bytes calldata data
) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165.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 ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev _Available since v3.1._
*/
interface IERC1155Receiver is IERC165 {
/**
* @dev Handles the receipt of a single ERC1155 token type. This function is
* called at the end of a `safeTransferFrom` after the balance has been updated.
*
* NOTE: To accept the transfer, this must return
* `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
* (i.e. 0xf23a6e61, or its own function selector).
*
* @param operator The address which initiated the transfer (i.e. msg.sender)
* @param from The address which previously owned the token
* @param id The ID of the token being transferred
* @param value The amount of tokens being transferred
* @param data Additional data with no specified format
* @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
*/
function onERC1155Received(
address operator,
address from,
uint256 id,
uint256 value,
bytes calldata data
) external returns (bytes4);
/**
* @dev Handles the receipt of a multiple ERC1155 token types. This function
* is called at the end of a `safeBatchTransferFrom` after the balances have
* been updated.
*
* NOTE: To accept the transfer(s), this must return
* `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
* (i.e. 0xbc197c81, or its own function selector).
*
* @param operator The address which initiated the batch transfer (i.e. msg.sender)
* @param from The address which previously owned the token
* @param ids An array containing ids of each token being transferred (order and length must match values array)
* @param values An array containing amounts of each token being transferred (order and length must match ids array)
* @param data Additional data with no specified format
* @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
*/
function onERC1155BatchReceived(
address operator,
address from,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external returns (bytes4);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol)
pragma solidity ^0.8.0;
import "../IERC1155.sol";
/**
* @dev Interface of the optional ERC1155MetadataExtension interface, as defined
* in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP].
*
* _Available since v3.1._
*/
interface IERC1155MetadataURI is IERC1155 {
/**
* @dev Returns the URI for token type `id`.
*
* If the `\{id\}` substring is present in the URI, it must be replaced by
* clients with the actual token type ID.
*/
function uri(uint256 id) external view returns (string memory);
}{
"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[{"inputs":[{"internalType":"string","name":"_baseURI","type":"string"},{"internalType":"contract ProxyRegistry","name":"_proxyRegistry","type":"address"},{"internalType":"address","name":"_admin","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract ILinkageRoot","name":"newRoot","type":"address"},{"indexed":false,"internalType":"contract ILinkageRoot","name":"oldRoot","type":"address"}],"name":"LinkageRootSwitched","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"newBaseUri","type":"string"}],"name":"NewBaseUri","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"TransferBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"TransferSingle","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"value","type":"string"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"URI","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"GATEKEEPER","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"balanceOfBatch","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getInterconnector","outputs":[{"internalType":"contract IInterconnector","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"isOperator","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account_","type":"address"},{"internalType":"uint256","name":"amount_","type":"uint256"},{"internalType":"bytes","name":"data_","type":"bytes"},{"internalType":"uint256","name":"tier_","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account_","type":"address"},{"internalType":"uint256[]","name":"amounts_","type":"uint256[]"},{"internalType":"bytes","name":"data_","type":"bytes"},{"internalType":"uint256[]","name":"tiers_","type":"uint256[]"}],"name":"mintBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nextIdToBeMinted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxyRegistry","outputs":[{"internalType":"contract ProxyRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to_","type":"address"},{"internalType":"uint256[]","name":"ids_","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts_","type":"uint256[]"},{"internalType":"bytes","name":"data_","type":"bytes"}],"name":"safeBatchTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeBatchTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to_","type":"address"},{"internalType":"uint256","name":"id_","type":"uint256"},{"internalType":"uint256","name":"amount_","type":"uint256"},{"internalType":"bytes","name":"data_","type":"bytes"}],"name":"safeTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"newBaseUri","type":"string"}],"name":"setURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"contract ILinkageRoot","name":"newRoot","type":"address"}],"name":"switchLinkageRoot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId_","type":"uint256"}],"name":"uri","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"}]Contract Creation Code
60a06040523480156200001157600080fd5b5060405162002d8e38038062002d8e833981016040819052620000349162000232565b82620000408162000123565b506040805180820190915260048152634534303560e01b60208201526001600160a01b0383166200008f5760405162461bcd60e51b815260040162000086919062000311565b60405180910390fd5b506040805180820190915260048152634534303560e01b60208201526001600160a01b038216620000d55760405162461bcd60e51b815260040162000086919062000311565b50620000e360008262000135565b6200010f7f20162831d2f54c3e11eebafebfeda495d4c52c67b1708251179ec91fb76dd3b28262000135565b506001600160a01b031660805250620004a1565b6002620001318282620003d5565b5050565b60008281526003602090815260408083206001600160a01b038516845290915290205460ff16620001315760008281526003602090815260408083206001600160a01b03851684529091529020805460ff19166001179055620001953390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b634e487b7160e01b600052604160045260246000fd5b60005b838110156200020c578181015183820152602001620001f2565b50506000910152565b80516001600160a01b03811681146200022d57600080fd5b919050565b6000806000606084860312156200024857600080fd5b83516001600160401b03808211156200026057600080fd5b818601915086601f8301126200027557600080fd5b8151818111156200028a576200028a620001d9565b604051601f8201601f19908116603f01168101908382118183101715620002b557620002b5620001d9565b81604052828152896020848701011115620002cf57600080fd5b620002e2836020830160208801620001ef565b8097505050505050620002f86020850162000215565b9150620003086040850162000215565b90509250925092565b602081526000825180602084015262000332816040850160208701620001ef565b601f01601f19169190910160400192915050565b600181811c908216806200035b57607f821691505b6020821081036200037c57634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620003d057600081815260208120601f850160051c81016020861015620003ab5750805b601f850160051c820191505b81811015620003cc57828155600101620003b7565b5050505b505050565b81516001600160401b03811115620003f157620003f1620001d9565b620004098162000402845462000346565b8462000382565b602080601f831160018114620004415760008415620004285750858301515b600019600386901b1c1916600185901b178555620003cc565b600085815260208120601f198616915b82811015620004725788860151825594840194600190910190840162000451565b5085821015620004915787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6080516128ca620004c4600039600081816103a60152610bdf01526128ca6000f3fe608060405234801561001057600080fd5b506004361061018d5760003560e01c80633afcad14116100de578063a22cb46511610097578063d547741f11610071578063d547741f146103c8578063e985e9c5146103db578063f242432a146103ee578063f5417e451461040157600080fd5b8063a22cb4651461037b578063ae28b68c1461038e578063b50cbd9f146103a157600080fd5b80633afcad14146102f55780634e1273f414610315578063637997131461033557806391d148541461033d57806395d89b4114610350578063a217fddf1461037357600080fd5b8063248a9ca31161014b5780632f2ff15d116101255780632f2ff15d146102a95780632fdacd9b146102bc57806336568abe146102cf578063368b2842146102e257600080fd5b8063248a9ca31461026057806325dc7ff6146102835780632eb2c2d61461029657600080fd5b8062fdd58e1461019257806301ffc9a7146101b857806302fe5305146101ec57806306fdde03146102015780630e89341c1461023a5780632332aa671461024d575b600080fd5b6101a56101a0366004611ab2565b610428565b6040519081526020015b60405180910390f35b6101dc6101c6366004611af4565b6001600160e01b031916636cdb3d1360e11b1490565b60405190151581526020016101af565b6101ff6101fa366004611bb0565b6104c1565b005b61022d6040518060400160405280600d81526020016c135a5b9d195c995cdd08139195609a1b81525081565b6040516101af9190611c48565b61022d610248366004611c5b565b610510565b6101ff61025b366004611d28565b610565565b6101a561026e366004611c5b565b60009081526003602052604090206001015490565b6101ff610291366004611dc2565b6106ef565b6101ff6102a4366004611ddf565b610823565b6101ff6102b7366004611e8c565b61086f565b6101ff6102ca366004611ebc565b610899565b6101ff6102dd366004611e8c565b610949565b6101ff6102f0366004611f1c565b6109c7565b6102fd6109da565b6040516001600160a01b0390911681526020016101af565b610328610323366004611faa565b610a12565b6040516101af91906120b1565b6101a5610b3b565b6101dc61034b366004611e8c565b610b51565b61022d604051806040016040528060048152602001631353919560e21b81525081565b6101a5600081565b6101ff6103893660046120c4565b610b7c565b6101ff61039c3660046120f7565b610b87565b6102fd7f000000000000000000000000000000000000000000000000000000000000000081565b6101ff6103d6366004611e8c565b610b94565b6101dc6103e936600461214d565b610bb9565b6101ff6103fc36600461217b565b610c91565b6101a57f20162831d2f54c3e11eebafebfeda495d4c52c67b1708251179ec91fb76dd3b281565b60006001600160a01b0383166104985760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a2061646472657373207a65726f206973206e6f742061207660448201526930b634b21037bbb732b960b11b60648201526084015b60405180910390fd5b506000818152602081815260408083206001600160a01b03861684529091529020545b92915050565b60006104cc81610cd6565b6104d582610ce3565b7fdb26230ffa9e2bd79c063acaff0a79b0926186d7edcaf06f306658ae2472c427826040516105049190611c48565b60405180910390a15050565b606061051b82610cef565b61052d5761052882610d04565b6104bb565b61053682610d04565b61053f83610d98565b6040516020016105509291906121e3565b60405160208183030381529060405292915050565b7f20162831d2f54c3e11eebafebfeda495d4c52c67b1708251179ec91fb76dd3b261058f81610cd6565b8351825114604051806040016040528060048152602001634534313960e01b815250906105cf5760405162461bcd60e51b815260040161048f9190611c48565b50600084516001600160401b038111156105eb576105eb611b11565b604051908082528060200260200182016040528015610614578160200160208202803683370190505b50905060005b855181101561066f57610631600480546001019055565b600061063c60045490565b90508083838151811061065157610651612222565b602090810291909101015250806106678161224e565b91505061061a565b5061067c86828787610ea0565b610684610ffa565b6001600160a01b031663acb69f52878388876040518563ffffffff1660e01b81526004016106b59493929190612267565b600060405180830381600087803b1580156106cf57600080fd5b505af11580156106e3573d6000803e3d6000fd5b50505050505050505050565b6040805180820190915260048152634533323960e01b60208201526001600160a01b0382166107315760405162461bcd60e51b815260040161048f9190611c48565b507fc34f336ef21a27e6cdbefdb1e201a57e5e6cb9d267e34fc3134d22f9decc8bbf80546001600160a01b03908116908316810361076e57505050565b6001600160a01b038116158061078c57506001600160a01b03811633145b604051806040016040528060048152602001632298981960e11b815250906107c75760405162461bcd60e51b815260040161048f9190611c48565b5081546001600160a01b0319166001600160a01b0384811691821784556040805192835290831660208301527f0a3a2d206ef02a769e7aaad7c9fb6d95dc9033159cd6ae7aaae65223fc321716910160405180910390a1505050565b6001600160a01b03851633148061083f575061083f8533610bb9565b61085b5760405162461bcd60e51b815260040161048f906122bc565b6108688585858585611065565b5050505050565b60008281526003602052604090206001015461088a81610cd6565b6108948383611207565b505050565b7f20162831d2f54c3e11eebafebfeda495d4c52c67b1708251179ec91fb76dd3b26108c381610cd6565b6108d1600480546001019055565b60006108dc60045490565b90506108ea8682878761128d565b8215610941576108f8610ffa565b6001600160a01b031663acb69f528761091084611376565b61091989611376565b61092288611376565b6040518563ffffffff1660e01b81526004016106b59493929190612267565b505050505050565b6001600160a01b03811633146109b95760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b606482015260840161048f565b6109c382826113c1565b5050565b6109d43385858585610823565b50505050565b6000610a0d7fc34f336ef21a27e6cdbefdb1e201a57e5e6cb9d267e34fc3134d22f9decc8bbf546001600160a01b031690565b905090565b60608151835114610a775760405162461bcd60e51b815260206004820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e677468604482015268040dad2e6dac2e8c6d60bb1b606482015260840161048f565b600083516001600160401b03811115610a9257610a92611b11565b604051908082528060200260200182016040528015610abb578160200160208202803683370190505b50905060005b8451811015610b3357610b06858281518110610adf57610adf612222565b6020026020010151858381518110610af957610af9612222565b6020026020010151610428565b828281518110610b1857610b18612222565b6020908102919091010152610b2c8161224e565b9050610ac1565b509392505050565b6000610b4660045490565b610a0d90600161230b565b60009182526003602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6109c3338383611428565b6109d43385858585610c91565b600082815260036020526040902060010154610baf81610cd6565b61089483836113c1565b60405163c455279160e01b81526001600160a01b038381166004830152600091818416917f0000000000000000000000000000000000000000000000000000000000000000169063c455279190602401602060405180830381865afa158015610c26573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c4a919061231e565b6001600160a01b031603610c60575060016104bb565b6001600160a01b0380841660009081526001602090815260408083209386168352929052205460ff165b9392505050565b6001600160a01b038516331480610cad5750610cad8533610bb9565b610cc95760405162461bcd60e51b815260040161048f906122bc565b6108688585858585611508565b610ce08133611640565b50565b60026109c382826123bb565b600080821180156104bb575050600454101590565b606060028054610d139061233b565b80601f0160208091040260200160405190810160405280929190818152602001828054610d3f9061233b565b8015610d8c5780601f10610d6157610100808354040283529160200191610d8c565b820191906000526020600020905b815481529060010190602001808311610d6f57829003601f168201915b50505050509050919050565b606081600003610dbf5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115610de95780610dd38161224e565b9150610de29050600a83612490565b9150610dc3565b6000816001600160401b03811115610e0357610e03611b11565b6040519080825280601f01601f191660200182016040528015610e2d576020820181803683370190505b5090505b8415610e9857610e426001836124a4565b9150610e4f600a866124b7565b610e5a90603061230b565b60f81b818381518110610e6f57610e6f612222565b60200101906001600160f81b031916908160001a905350610e91600a86612490565b9450610e31565b949350505050565b6001600160a01b038416610ec65760405162461bcd60e51b815260040161048f906124cb565b8151835114610ee75760405162461bcd60e51b815260040161048f9061250c565b33610ef7816000878787876116a4565b60005b8451811015610f9257838181518110610f1557610f15612222565b6020026020010151600080878481518110610f3257610f32612222565b602002602001015181526020019081526020016000206000886001600160a01b03166001600160a01b031681526020019081526020016000206000828254610f7a919061230b565b90915550819050610f8a8161224e565b915050610efa565b50846001600160a01b031660006001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051610fe3929190612554565b60405180910390a4610868816000878787876116ec565b60006110046109da565b6001600160a01b03166311a259076040518163ffffffff1660e01b8152600401602060405180830381865afa158015611041573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a0d919061231e565b81518351146110865760405162461bcd60e51b815260040161048f9061250c565b6001600160a01b0384166110ac5760405162461bcd60e51b815260040161048f90612582565b336110bb8187878787876116a4565b60005b84518110156111a15760008582815181106110db576110db612222565b6020026020010151905060008583815181106110f9576110f9612222565b602090810291909101810151600084815280835260408082206001600160a01b038e1683529093529190912054909150818110156111495760405162461bcd60e51b815260040161048f906125c7565b6000838152602081815260408083206001600160a01b038e8116855292528083208585039055908b1682528120805484929061118690849061230b565b925050819055505050508061119a9061224e565b90506110be565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb87876040516111f1929190612554565b60405180910390a46109418187878787876116ec565b6112118282610b51565b6109c35760008281526003602090815260408083206001600160a01b03851684529091529020805460ff191660011790556112493390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6001600160a01b0384166112b35760405162461bcd60e51b815260040161048f906124cb565b3360006112bf85611376565b905060006112cc85611376565b90506112dd836000898585896116a4565b6000868152602081815260408083206001600160a01b038b1684529091528120805487929061130d90849061230b565b909155505060408051878152602081018790526001600160a01b03808a1692600092918716917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a461136d83600089898989611847565b50505050505050565b604080516001808252818301909252606091600091906020808301908036833701905050905082816000815181106113b0576113b0612222565b602090810291909101015292915050565b6113cb8282610b51565b156109c35760008281526003602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b816001600160a01b0316836001600160a01b03160361149b5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2073657474696e6720617070726f76616c20737461747573604482015268103337b91039b2b63360b91b606482015260840161048f565b6001600160a01b03838116600081815260016020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6001600160a01b03841661152e5760405162461bcd60e51b815260040161048f90612582565b33600061153a85611376565b9050600061154785611376565b90506115578389898585896116a4565b6000868152602081815260408083206001600160a01b038c168452909152902054858110156115985760405162461bcd60e51b815260040161048f906125c7565b6000878152602081815260408083206001600160a01b038d8116855292528083208985039055908a168252812080548892906115d590849061230b565b909155505060408051888152602081018890526001600160a01b03808b16928c821692918816917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4611635848a8a8a8a8a611847565b505050505050505050565b61164a8282610b51565b6109c357611662816001600160a01b03166014611902565b61166d836020611902565b60405160200161167e929190612611565b60408051601f198184030181529082905262461bcd60e51b825261048f91600401611c48565b6001600160a01b03851615610941576116bb610ffa565b6001600160a01b03166388173e1c868686866040518563ffffffff1660e01b81526004016106b59493929190612686565b6001600160a01b0384163b156109415760405163bc197c8160e01b81526001600160a01b0385169063bc197c819061173090899089908890889088906004016126c4565b6020604051808303816000875af192505050801561176b575060408051601f3d908101601f1916820190925261176891810190612722565b60015b6118175761177761273f565b806308c379a0036117b0575061178b61275b565b8061179657506117b2565b8060405162461bcd60e51b815260040161048f9190611c48565b505b60405162461bcd60e51b815260206004820152603460248201527f455243313135353a207472616e7366657220746f206e6f6e20455243313135356044820152732932b1b2b4bb32b91034b6b83632b6b2b73a32b960611b606482015260840161048f565b6001600160e01b0319811663bc197c8160e01b1461136d5760405162461bcd60e51b815260040161048f906127e4565b6001600160a01b0384163b156109415760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e619061188b908990899088908890889060040161282c565b6020604051808303816000875af19250505080156118c6575060408051601f3d908101601f191682019092526118c391810190612722565b60015b6118d25761177761273f565b6001600160e01b0319811663f23a6e6160e01b1461136d5760405162461bcd60e51b815260040161048f906127e4565b60606000611911836002612866565b61191c90600261230b565b6001600160401b0381111561193357611933611b11565b6040519080825280601f01601f19166020018201604052801561195d576020820181803683370190505b509050600360fc1b8160008151811061197857611978612222565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106119a7576119a7612222565b60200101906001600160f81b031916908160001a90535060006119cb846002612866565b6119d690600161230b565b90505b6001811115611a4e576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110611a0a57611a0a612222565b1a60f81b828281518110611a2057611a20612222565b60200101906001600160f81b031916908160001a90535060049490941c93611a478161287d565b90506119d9565b508315610c8a5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604482015260640161048f565b6001600160a01b0381168114610ce057600080fd5b60008060408385031215611ac557600080fd5b8235611ad081611a9d565b946020939093013593505050565b6001600160e01b031981168114610ce057600080fd5b600060208284031215611b0657600080fd5b8135610c8a81611ade565b634e487b7160e01b600052604160045260246000fd5b601f8201601f191681016001600160401b0381118282101715611b4c57611b4c611b11565b6040525050565b60006001600160401b03831115611b6c57611b6c611b11565b604051611b83601f8501601f191660200182611b27565b809150838152848484011115611b9857600080fd5b83836020830137600060208583010152509392505050565b600060208284031215611bc257600080fd5b81356001600160401b03811115611bd857600080fd5b8201601f81018413611be957600080fd5b610e9884823560208401611b53565b60005b83811015611c13578181015183820152602001611bfb565b50506000910152565b60008151808452611c34816020860160208601611bf8565b601f01601f19169290920160200192915050565b602081526000610c8a6020830184611c1c565b600060208284031215611c6d57600080fd5b5035919050565b60006001600160401b03821115611c8d57611c8d611b11565b5060051b60200190565b600082601f830112611ca857600080fd5b81356020611cb582611c74565b604051611cc28282611b27565b83815260059390931b8501820192828101915086841115611ce257600080fd5b8286015b84811015611cfd5780358352918301918301611ce6565b509695505050505050565b600082601f830112611d1957600080fd5b610c8a83833560208501611b53565b60008060008060808587031215611d3e57600080fd5b8435611d4981611a9d565b935060208501356001600160401b0380821115611d6557600080fd5b611d7188838901611c97565b94506040870135915080821115611d8757600080fd5b611d9388838901611d08565b93506060870135915080821115611da957600080fd5b50611db687828801611c97565b91505092959194509250565b600060208284031215611dd457600080fd5b8135610c8a81611a9d565b600080600080600060a08688031215611df757600080fd5b8535611e0281611a9d565b94506020860135611e1281611a9d565b935060408601356001600160401b0380821115611e2e57600080fd5b611e3a89838a01611c97565b94506060880135915080821115611e5057600080fd5b611e5c89838a01611c97565b93506080880135915080821115611e7257600080fd5b50611e7f88828901611d08565b9150509295509295909350565b60008060408385031215611e9f57600080fd5b823591506020830135611eb181611a9d565b809150509250929050565b60008060008060808587031215611ed257600080fd5b8435611edd81611a9d565b93506020850135925060408501356001600160401b03811115611eff57600080fd5b611f0b87828801611d08565b949793965093946060013593505050565b60008060008060808587031215611f3257600080fd5b8435611f3d81611a9d565b935060208501356001600160401b0380821115611f5957600080fd5b611f6588838901611c97565b94506040870135915080821115611f7b57600080fd5b611f8788838901611c97565b93506060870135915080821115611f9d57600080fd5b50611db687828801611d08565b60008060408385031215611fbd57600080fd5b82356001600160401b0380821115611fd457600080fd5b818501915085601f830112611fe857600080fd5b81356020611ff582611c74565b6040516120028282611b27565b83815260059390931b850182019282810191508984111561202257600080fd5b948201945b8386101561204957853561203a81611a9d565b82529482019490820190612027565b9650508601359250508082111561205f57600080fd5b5061206c85828601611c97565b9150509250929050565b600081518084526020808501945080840160005b838110156120a65781518752958201959082019060010161208a565b509495945050505050565b602081526000610c8a6020830184612076565b600080604083850312156120d757600080fd5b82356120e281611a9d565b915060208301358015158114611eb157600080fd5b6000806000806080858703121561210d57600080fd5b843561211881611a9d565b9350602085013592506040850135915060608501356001600160401b0381111561214157600080fd5b611db687828801611d08565b6000806040838503121561216057600080fd5b823561216b81611a9d565b91506020830135611eb181611a9d565b600080600080600060a0868803121561219357600080fd5b853561219e81611a9d565b945060208601356121ae81611a9d565b9350604086013592506060860135915060808601356001600160401b038111156121d757600080fd5b611e7f88828901611d08565b600083516121f5818460208801611bf8565b835190830190612209818360208801611bf8565b64173539b7b760d91b9101908152600501949350505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60006001820161226057612260612238565b5060010190565b6001600160a01b038516815260806020820181905260009061228b90830186612076565b828103604084015261229d8186612076565b905082810360608401526122b18185612076565b979650505050505050565b6020808252602f908201527f455243313135353a2063616c6c6572206973206e6f7420746f6b656e206f776e60408201526e195c881b9bdc88185c1c1c9bdd9959608a1b606082015260800190565b808201808211156104bb576104bb612238565b60006020828403121561233057600080fd5b8151610c8a81611a9d565b600181811c9082168061234f57607f821691505b60208210810361236f57634e487b7160e01b600052602260045260246000fd5b50919050565b601f82111561089457600081815260208120601f850160051c8101602086101561239c5750805b601f850160051c820191505b81811015610941578281556001016123a8565b81516001600160401b038111156123d4576123d4611b11565b6123e8816123e2845461233b565b84612375565b602080601f83116001811461241d57600084156124055750858301515b600019600386901b1c1916600185901b178555610941565b600085815260208120601f198616915b8281101561244c5788860151825594840194600190910190840161242d565b508582101561246a5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052601260045260246000fd5b60008261249f5761249f61247a565b500490565b818103818111156104bb576104bb612238565b6000826124c6576124c661247a565b500690565b60208082526021908201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736040820152607360f81b606082015260800190565b60208082526028908201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206040820152670dad2e6dac2e8c6d60c31b606082015260800190565b6040815260006125676040830185612076565b82810360208401526125798185612076565b95945050505050565b60208082526025908201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604082015264647265737360d81b606082015260800190565b6020808252602a908201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60408201526939103a3930b739b332b960b11b606082015260800190565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351612649816017850160208801611bf8565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161267a816028840160208801611bf8565b01602801949350505050565b6001600160a01b038581168252841660208201526080604082018190526000906126b290830185612076565b82810360608401526122b18185612076565b6001600160a01b0386811682528516602082015260a0604082018190526000906126f090830186612076565b82810360608401526127028186612076565b905082810360808401526127168185611c1c565b98975050505050505050565b60006020828403121561273457600080fd5b8151610c8a81611ade565b600060033d11156127585760046000803e5060005160e01c5b90565b600060443d10156127695790565b6040516003193d81016004833e81513d6001600160401b03816024840111818411171561279857505050505090565b82850191508151818111156127b05750505050505090565b843d87010160208285010111156127ca5750505050505090565b6127d960208286010187611b27565b509095945050505050565b60208082526028908201527f455243313135353a204552433131353552656365697665722072656a656374656040820152676420746f6b656e7360c01b606082015260800190565b6001600160a01b03868116825285166020820152604081018490526060810183905260a0608082018190526000906122b190830184611c1c565b80820281158282048414176104bb576104bb612238565b60008161288c5761288c612238565b50600019019056fea2646970667358221220a8b1918fd4191e85279f6f16bd0422c7348bf86eaf42c7bbf87aad158c9eac6a64736f6c634300081100330000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a5409ec958c83c3f309868babaca7c86dcb077c10000000000000000000000007ca0f34b42a22dd3a0276d95a80837342cc6fc630000000000000000000000000000000000000000000000000000000000000007697066733a2f2f00000000000000000000000000000000000000000000000000
Deployed Bytecode
0x608060405234801561001057600080fd5b506004361061018d5760003560e01c80633afcad14116100de578063a22cb46511610097578063d547741f11610071578063d547741f146103c8578063e985e9c5146103db578063f242432a146103ee578063f5417e451461040157600080fd5b8063a22cb4651461037b578063ae28b68c1461038e578063b50cbd9f146103a157600080fd5b80633afcad14146102f55780634e1273f414610315578063637997131461033557806391d148541461033d57806395d89b4114610350578063a217fddf1461037357600080fd5b8063248a9ca31161014b5780632f2ff15d116101255780632f2ff15d146102a95780632fdacd9b146102bc57806336568abe146102cf578063368b2842146102e257600080fd5b8063248a9ca31461026057806325dc7ff6146102835780632eb2c2d61461029657600080fd5b8062fdd58e1461019257806301ffc9a7146101b857806302fe5305146101ec57806306fdde03146102015780630e89341c1461023a5780632332aa671461024d575b600080fd5b6101a56101a0366004611ab2565b610428565b6040519081526020015b60405180910390f35b6101dc6101c6366004611af4565b6001600160e01b031916636cdb3d1360e11b1490565b60405190151581526020016101af565b6101ff6101fa366004611bb0565b6104c1565b005b61022d6040518060400160405280600d81526020016c135a5b9d195c995cdd08139195609a1b81525081565b6040516101af9190611c48565b61022d610248366004611c5b565b610510565b6101ff61025b366004611d28565b610565565b6101a561026e366004611c5b565b60009081526003602052604090206001015490565b6101ff610291366004611dc2565b6106ef565b6101ff6102a4366004611ddf565b610823565b6101ff6102b7366004611e8c565b61086f565b6101ff6102ca366004611ebc565b610899565b6101ff6102dd366004611e8c565b610949565b6101ff6102f0366004611f1c565b6109c7565b6102fd6109da565b6040516001600160a01b0390911681526020016101af565b610328610323366004611faa565b610a12565b6040516101af91906120b1565b6101a5610b3b565b6101dc61034b366004611e8c565b610b51565b61022d604051806040016040528060048152602001631353919560e21b81525081565b6101a5600081565b6101ff6103893660046120c4565b610b7c565b6101ff61039c3660046120f7565b610b87565b6102fd7f000000000000000000000000a5409ec958c83c3f309868babaca7c86dcb077c181565b6101ff6103d6366004611e8c565b610b94565b6101dc6103e936600461214d565b610bb9565b6101ff6103fc36600461217b565b610c91565b6101a57f20162831d2f54c3e11eebafebfeda495d4c52c67b1708251179ec91fb76dd3b281565b60006001600160a01b0383166104985760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a2061646472657373207a65726f206973206e6f742061207660448201526930b634b21037bbb732b960b11b60648201526084015b60405180910390fd5b506000818152602081815260408083206001600160a01b03861684529091529020545b92915050565b60006104cc81610cd6565b6104d582610ce3565b7fdb26230ffa9e2bd79c063acaff0a79b0926186d7edcaf06f306658ae2472c427826040516105049190611c48565b60405180910390a15050565b606061051b82610cef565b61052d5761052882610d04565b6104bb565b61053682610d04565b61053f83610d98565b6040516020016105509291906121e3565b60405160208183030381529060405292915050565b7f20162831d2f54c3e11eebafebfeda495d4c52c67b1708251179ec91fb76dd3b261058f81610cd6565b8351825114604051806040016040528060048152602001634534313960e01b815250906105cf5760405162461bcd60e51b815260040161048f9190611c48565b50600084516001600160401b038111156105eb576105eb611b11565b604051908082528060200260200182016040528015610614578160200160208202803683370190505b50905060005b855181101561066f57610631600480546001019055565b600061063c60045490565b90508083838151811061065157610651612222565b602090810291909101015250806106678161224e565b91505061061a565b5061067c86828787610ea0565b610684610ffa565b6001600160a01b031663acb69f52878388876040518563ffffffff1660e01b81526004016106b59493929190612267565b600060405180830381600087803b1580156106cf57600080fd5b505af11580156106e3573d6000803e3d6000fd5b50505050505050505050565b6040805180820190915260048152634533323960e01b60208201526001600160a01b0382166107315760405162461bcd60e51b815260040161048f9190611c48565b507fc34f336ef21a27e6cdbefdb1e201a57e5e6cb9d267e34fc3134d22f9decc8bbf80546001600160a01b03908116908316810361076e57505050565b6001600160a01b038116158061078c57506001600160a01b03811633145b604051806040016040528060048152602001632298981960e11b815250906107c75760405162461bcd60e51b815260040161048f9190611c48565b5081546001600160a01b0319166001600160a01b0384811691821784556040805192835290831660208301527f0a3a2d206ef02a769e7aaad7c9fb6d95dc9033159cd6ae7aaae65223fc321716910160405180910390a1505050565b6001600160a01b03851633148061083f575061083f8533610bb9565b61085b5760405162461bcd60e51b815260040161048f906122bc565b6108688585858585611065565b5050505050565b60008281526003602052604090206001015461088a81610cd6565b6108948383611207565b505050565b7f20162831d2f54c3e11eebafebfeda495d4c52c67b1708251179ec91fb76dd3b26108c381610cd6565b6108d1600480546001019055565b60006108dc60045490565b90506108ea8682878761128d565b8215610941576108f8610ffa565b6001600160a01b031663acb69f528761091084611376565b61091989611376565b61092288611376565b6040518563ffffffff1660e01b81526004016106b59493929190612267565b505050505050565b6001600160a01b03811633146109b95760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b606482015260840161048f565b6109c382826113c1565b5050565b6109d43385858585610823565b50505050565b6000610a0d7fc34f336ef21a27e6cdbefdb1e201a57e5e6cb9d267e34fc3134d22f9decc8bbf546001600160a01b031690565b905090565b60608151835114610a775760405162461bcd60e51b815260206004820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e677468604482015268040dad2e6dac2e8c6d60bb1b606482015260840161048f565b600083516001600160401b03811115610a9257610a92611b11565b604051908082528060200260200182016040528015610abb578160200160208202803683370190505b50905060005b8451811015610b3357610b06858281518110610adf57610adf612222565b6020026020010151858381518110610af957610af9612222565b6020026020010151610428565b828281518110610b1857610b18612222565b6020908102919091010152610b2c8161224e565b9050610ac1565b509392505050565b6000610b4660045490565b610a0d90600161230b565b60009182526003602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6109c3338383611428565b6109d43385858585610c91565b600082815260036020526040902060010154610baf81610cd6565b61089483836113c1565b60405163c455279160e01b81526001600160a01b038381166004830152600091818416917f000000000000000000000000a5409ec958c83c3f309868babaca7c86dcb077c1169063c455279190602401602060405180830381865afa158015610c26573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c4a919061231e565b6001600160a01b031603610c60575060016104bb565b6001600160a01b0380841660009081526001602090815260408083209386168352929052205460ff165b9392505050565b6001600160a01b038516331480610cad5750610cad8533610bb9565b610cc95760405162461bcd60e51b815260040161048f906122bc565b6108688585858585611508565b610ce08133611640565b50565b60026109c382826123bb565b600080821180156104bb575050600454101590565b606060028054610d139061233b565b80601f0160208091040260200160405190810160405280929190818152602001828054610d3f9061233b565b8015610d8c5780601f10610d6157610100808354040283529160200191610d8c565b820191906000526020600020905b815481529060010190602001808311610d6f57829003601f168201915b50505050509050919050565b606081600003610dbf5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115610de95780610dd38161224e565b9150610de29050600a83612490565b9150610dc3565b6000816001600160401b03811115610e0357610e03611b11565b6040519080825280601f01601f191660200182016040528015610e2d576020820181803683370190505b5090505b8415610e9857610e426001836124a4565b9150610e4f600a866124b7565b610e5a90603061230b565b60f81b818381518110610e6f57610e6f612222565b60200101906001600160f81b031916908160001a905350610e91600a86612490565b9450610e31565b949350505050565b6001600160a01b038416610ec65760405162461bcd60e51b815260040161048f906124cb565b8151835114610ee75760405162461bcd60e51b815260040161048f9061250c565b33610ef7816000878787876116a4565b60005b8451811015610f9257838181518110610f1557610f15612222565b6020026020010151600080878481518110610f3257610f32612222565b602002602001015181526020019081526020016000206000886001600160a01b03166001600160a01b031681526020019081526020016000206000828254610f7a919061230b565b90915550819050610f8a8161224e565b915050610efa565b50846001600160a01b031660006001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051610fe3929190612554565b60405180910390a4610868816000878787876116ec565b60006110046109da565b6001600160a01b03166311a259076040518163ffffffff1660e01b8152600401602060405180830381865afa158015611041573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a0d919061231e565b81518351146110865760405162461bcd60e51b815260040161048f9061250c565b6001600160a01b0384166110ac5760405162461bcd60e51b815260040161048f90612582565b336110bb8187878787876116a4565b60005b84518110156111a15760008582815181106110db576110db612222565b6020026020010151905060008583815181106110f9576110f9612222565b602090810291909101810151600084815280835260408082206001600160a01b038e1683529093529190912054909150818110156111495760405162461bcd60e51b815260040161048f906125c7565b6000838152602081815260408083206001600160a01b038e8116855292528083208585039055908b1682528120805484929061118690849061230b565b925050819055505050508061119a9061224e565b90506110be565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb87876040516111f1929190612554565b60405180910390a46109418187878787876116ec565b6112118282610b51565b6109c35760008281526003602090815260408083206001600160a01b03851684529091529020805460ff191660011790556112493390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6001600160a01b0384166112b35760405162461bcd60e51b815260040161048f906124cb565b3360006112bf85611376565b905060006112cc85611376565b90506112dd836000898585896116a4565b6000868152602081815260408083206001600160a01b038b1684529091528120805487929061130d90849061230b565b909155505060408051878152602081018790526001600160a01b03808a1692600092918716917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a461136d83600089898989611847565b50505050505050565b604080516001808252818301909252606091600091906020808301908036833701905050905082816000815181106113b0576113b0612222565b602090810291909101015292915050565b6113cb8282610b51565b156109c35760008281526003602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b816001600160a01b0316836001600160a01b03160361149b5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2073657474696e6720617070726f76616c20737461747573604482015268103337b91039b2b63360b91b606482015260840161048f565b6001600160a01b03838116600081815260016020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6001600160a01b03841661152e5760405162461bcd60e51b815260040161048f90612582565b33600061153a85611376565b9050600061154785611376565b90506115578389898585896116a4565b6000868152602081815260408083206001600160a01b038c168452909152902054858110156115985760405162461bcd60e51b815260040161048f906125c7565b6000878152602081815260408083206001600160a01b038d8116855292528083208985039055908a168252812080548892906115d590849061230b565b909155505060408051888152602081018890526001600160a01b03808b16928c821692918816917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4611635848a8a8a8a8a611847565b505050505050505050565b61164a8282610b51565b6109c357611662816001600160a01b03166014611902565b61166d836020611902565b60405160200161167e929190612611565b60408051601f198184030181529082905262461bcd60e51b825261048f91600401611c48565b6001600160a01b03851615610941576116bb610ffa565b6001600160a01b03166388173e1c868686866040518563ffffffff1660e01b81526004016106b59493929190612686565b6001600160a01b0384163b156109415760405163bc197c8160e01b81526001600160a01b0385169063bc197c819061173090899089908890889088906004016126c4565b6020604051808303816000875af192505050801561176b575060408051601f3d908101601f1916820190925261176891810190612722565b60015b6118175761177761273f565b806308c379a0036117b0575061178b61275b565b8061179657506117b2565b8060405162461bcd60e51b815260040161048f9190611c48565b505b60405162461bcd60e51b815260206004820152603460248201527f455243313135353a207472616e7366657220746f206e6f6e20455243313135356044820152732932b1b2b4bb32b91034b6b83632b6b2b73a32b960611b606482015260840161048f565b6001600160e01b0319811663bc197c8160e01b1461136d5760405162461bcd60e51b815260040161048f906127e4565b6001600160a01b0384163b156109415760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e619061188b908990899088908890889060040161282c565b6020604051808303816000875af19250505080156118c6575060408051601f3d908101601f191682019092526118c391810190612722565b60015b6118d25761177761273f565b6001600160e01b0319811663f23a6e6160e01b1461136d5760405162461bcd60e51b815260040161048f906127e4565b60606000611911836002612866565b61191c90600261230b565b6001600160401b0381111561193357611933611b11565b6040519080825280601f01601f19166020018201604052801561195d576020820181803683370190505b509050600360fc1b8160008151811061197857611978612222565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106119a7576119a7612222565b60200101906001600160f81b031916908160001a90535060006119cb846002612866565b6119d690600161230b565b90505b6001811115611a4e576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110611a0a57611a0a612222565b1a60f81b828281518110611a2057611a20612222565b60200101906001600160f81b031916908160001a90535060049490941c93611a478161287d565b90506119d9565b508315610c8a5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604482015260640161048f565b6001600160a01b0381168114610ce057600080fd5b60008060408385031215611ac557600080fd5b8235611ad081611a9d565b946020939093013593505050565b6001600160e01b031981168114610ce057600080fd5b600060208284031215611b0657600080fd5b8135610c8a81611ade565b634e487b7160e01b600052604160045260246000fd5b601f8201601f191681016001600160401b0381118282101715611b4c57611b4c611b11565b6040525050565b60006001600160401b03831115611b6c57611b6c611b11565b604051611b83601f8501601f191660200182611b27565b809150838152848484011115611b9857600080fd5b83836020830137600060208583010152509392505050565b600060208284031215611bc257600080fd5b81356001600160401b03811115611bd857600080fd5b8201601f81018413611be957600080fd5b610e9884823560208401611b53565b60005b83811015611c13578181015183820152602001611bfb565b50506000910152565b60008151808452611c34816020860160208601611bf8565b601f01601f19169290920160200192915050565b602081526000610c8a6020830184611c1c565b600060208284031215611c6d57600080fd5b5035919050565b60006001600160401b03821115611c8d57611c8d611b11565b5060051b60200190565b600082601f830112611ca857600080fd5b81356020611cb582611c74565b604051611cc28282611b27565b83815260059390931b8501820192828101915086841115611ce257600080fd5b8286015b84811015611cfd5780358352918301918301611ce6565b509695505050505050565b600082601f830112611d1957600080fd5b610c8a83833560208501611b53565b60008060008060808587031215611d3e57600080fd5b8435611d4981611a9d565b935060208501356001600160401b0380821115611d6557600080fd5b611d7188838901611c97565b94506040870135915080821115611d8757600080fd5b611d9388838901611d08565b93506060870135915080821115611da957600080fd5b50611db687828801611c97565b91505092959194509250565b600060208284031215611dd457600080fd5b8135610c8a81611a9d565b600080600080600060a08688031215611df757600080fd5b8535611e0281611a9d565b94506020860135611e1281611a9d565b935060408601356001600160401b0380821115611e2e57600080fd5b611e3a89838a01611c97565b94506060880135915080821115611e5057600080fd5b611e5c89838a01611c97565b93506080880135915080821115611e7257600080fd5b50611e7f88828901611d08565b9150509295509295909350565b60008060408385031215611e9f57600080fd5b823591506020830135611eb181611a9d565b809150509250929050565b60008060008060808587031215611ed257600080fd5b8435611edd81611a9d565b93506020850135925060408501356001600160401b03811115611eff57600080fd5b611f0b87828801611d08565b949793965093946060013593505050565b60008060008060808587031215611f3257600080fd5b8435611f3d81611a9d565b935060208501356001600160401b0380821115611f5957600080fd5b611f6588838901611c97565b94506040870135915080821115611f7b57600080fd5b611f8788838901611c97565b93506060870135915080821115611f9d57600080fd5b50611db687828801611d08565b60008060408385031215611fbd57600080fd5b82356001600160401b0380821115611fd457600080fd5b818501915085601f830112611fe857600080fd5b81356020611ff582611c74565b6040516120028282611b27565b83815260059390931b850182019282810191508984111561202257600080fd5b948201945b8386101561204957853561203a81611a9d565b82529482019490820190612027565b9650508601359250508082111561205f57600080fd5b5061206c85828601611c97565b9150509250929050565b600081518084526020808501945080840160005b838110156120a65781518752958201959082019060010161208a565b509495945050505050565b602081526000610c8a6020830184612076565b600080604083850312156120d757600080fd5b82356120e281611a9d565b915060208301358015158114611eb157600080fd5b6000806000806080858703121561210d57600080fd5b843561211881611a9d565b9350602085013592506040850135915060608501356001600160401b0381111561214157600080fd5b611db687828801611d08565b6000806040838503121561216057600080fd5b823561216b81611a9d565b91506020830135611eb181611a9d565b600080600080600060a0868803121561219357600080fd5b853561219e81611a9d565b945060208601356121ae81611a9d565b9350604086013592506060860135915060808601356001600160401b038111156121d757600080fd5b611e7f88828901611d08565b600083516121f5818460208801611bf8565b835190830190612209818360208801611bf8565b64173539b7b760d91b9101908152600501949350505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60006001820161226057612260612238565b5060010190565b6001600160a01b038516815260806020820181905260009061228b90830186612076565b828103604084015261229d8186612076565b905082810360608401526122b18185612076565b979650505050505050565b6020808252602f908201527f455243313135353a2063616c6c6572206973206e6f7420746f6b656e206f776e60408201526e195c881b9bdc88185c1c1c9bdd9959608a1b606082015260800190565b808201808211156104bb576104bb612238565b60006020828403121561233057600080fd5b8151610c8a81611a9d565b600181811c9082168061234f57607f821691505b60208210810361236f57634e487b7160e01b600052602260045260246000fd5b50919050565b601f82111561089457600081815260208120601f850160051c8101602086101561239c5750805b601f850160051c820191505b81811015610941578281556001016123a8565b81516001600160401b038111156123d4576123d4611b11565b6123e8816123e2845461233b565b84612375565b602080601f83116001811461241d57600084156124055750858301515b600019600386901b1c1916600185901b178555610941565b600085815260208120601f198616915b8281101561244c5788860151825594840194600190910190840161242d565b508582101561246a5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052601260045260246000fd5b60008261249f5761249f61247a565b500490565b818103818111156104bb576104bb612238565b6000826124c6576124c661247a565b500690565b60208082526021908201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736040820152607360f81b606082015260800190565b60208082526028908201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206040820152670dad2e6dac2e8c6d60c31b606082015260800190565b6040815260006125676040830185612076565b82810360208401526125798185612076565b95945050505050565b60208082526025908201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604082015264647265737360d81b606082015260800190565b6020808252602a908201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60408201526939103a3930b739b332b960b11b606082015260800190565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351612649816017850160208801611bf8565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161267a816028840160208801611bf8565b01602801949350505050565b6001600160a01b038581168252841660208201526080604082018190526000906126b290830185612076565b82810360608401526122b18185612076565b6001600160a01b0386811682528516602082015260a0604082018190526000906126f090830186612076565b82810360608401526127028186612076565b905082810360808401526127168185611c1c565b98975050505050505050565b60006020828403121561273457600080fd5b8151610c8a81611ade565b600060033d11156127585760046000803e5060005160e01c5b90565b600060443d10156127695790565b6040516003193d81016004833e81513d6001600160401b03816024840111818411171561279857505050505090565b82850191508151818111156127b05750505050505090565b843d87010160208285010111156127ca5750505050505090565b6127d960208286010187611b27565b509095945050505050565b60208082526028908201527f455243313135353a204552433131353552656365697665722072656a656374656040820152676420746f6b656e7360c01b606082015260800190565b6001600160a01b03868116825285166020820152604081018490526060810183905260a0608082018190526000906122b190830184611c1c565b80820281158282048414176104bb576104bb612238565b60008161288c5761288c612238565b50600019019056fea2646970667358221220a8b1918fd4191e85279f6f16bd0422c7348bf86eaf42c7bbf87aad158c9eac6a64736f6c63430008110033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a5409ec958c83c3f309868babaca7c86dcb077c10000000000000000000000007ca0f34b42a22dd3a0276d95a80837342cc6fc630000000000000000000000000000000000000000000000000000000000000007697066733a2f2f00000000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : _baseURI (string): ipfs://
Arg [1] : _proxyRegistry (address): 0xa5409ec958C83C3f309868babACA7c86DCB077c1
Arg [2] : _admin (address): 0x7Ca0f34b42A22Dd3A0276d95A80837342cC6fc63
-----Encoded View---------------
5 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000060
Arg [1] : 000000000000000000000000a5409ec958c83c3f309868babaca7c86dcb077c1
Arg [2] : 0000000000000000000000007ca0f34b42a22dd3a0276d95a80837342cc6fc63
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000007
Arg [4] : 697066733a2f2f00000000000000000000000000000000000000000000000000
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.