Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- AggregatedPriceOracle
- Optimization enabled
- true
- Compiler version
- v0.8.17+commit.8df45f5f
- Optimization runs
- 200
- EVM Version
- default
- Verified at
- 2024-06-02T10:45:32.491997Z
Constructor Arguments
0x00000000000000000000000066f850099e6d5dbd712d15244b65bd822f36be7e
Arg [0] (address) : 0x66f850099e6d5dbd712d15244b65bd822f36be7e
contracts/multichain/taiko/AggregatedPriceOracle.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/utils/math/SafeCast.sol";
import "@api3/contracts/v0.8/interfaces/IProxy.sol";
import "../../interfaces/IMToken.sol";
import "../../interfaces/IPriceOracle.sol";
import "../../libraries/ErrorCodes.sol";
contract AggregatedPriceOracle is IPriceOracle, AccessControl {
using SafeCast for uint256;
using SafeCast for int256;
/**
* @notice List of supported oracle providers
*/
enum OracleProviderType {
Api3,
// For some tokens we can use multiplication of two oracles
// For example, for mETH we use mETH/ETH and ETH/USD oracles
Api3Aggregated
}
/**
* @notice Structure to store oracle related data for the token
*/
struct TokenConfig {
/// @dev The price feed contract address.
address proxyPriceFeedAddress;
/// @dev Second price feed (for Api3Aggregated oracle provider)
address secondaryProxyPriceFeedAddress;
/// @dev Maximum age of the on-chain price in seconds.
uint32 maxValidPriceAge;
// @dev Original token decimals
uint32 underlyingTokenDecimals;
// @dev For some tokens we use token-specific oracle providers
OracleProviderType oracleProviderType;
}
event NewTokenConfigSet(
address token,
address proxyPriceFeedAddress,
address secondaryProxyPriceFeedAddress,
uint32 maxValidPriceAge,
uint32 underlyingTokenDecimals,
OracleProviderType oracleProviderType
);
/// @dev Mapping to store oracle related configuration for tokens
mapping(address => TokenConfig) public feedProxies;
/**
* @notice Construct a AggregatedPriceOracle contract.
* @param admin The address of the Admin
*/
constructor(address admin) {
_grantRole(DEFAULT_ADMIN_ROLE, admin);
}
function pow10(uint8 power) private pure returns (uint256) {
if (power == 22) return 1e22;
else if (power == 20) return 1e20;
else if (power == 10) return 1e10;
else if (power == 1) return 1e1;
else if (power == 2) return 1e2;
else if (power == 3) return 1e3;
else if (power == 4) return 1e4;
else if (power == 5) return 1e5;
else if (power == 6) return 1e6;
else if (power == 7) return 1e7;
else if (power == 8) return 1e8;
else if (power == 9) return 1e9;
else if (power == 11) return 1e11;
else if (power == 12) return 1e12;
else if (power == 13) return 1e13;
else if (power == 14) return 1e14;
else if (power == 15) return 1e15;
else if (power == 16) return 1e16;
else if (power == 17) return 1e17;
else if (power == 18) return 1e18;
else if (power == 19) return 1e19;
else if (power == 21) return 1e21;
else if (power == 23) return 1e23;
else if (power == 24) return 1e24;
else if (power == 25) return 1e25;
else if (power == 26) return 1e26;
else if (power == 27) return 1e27;
else if (power == 28) return 1e28;
else if (power == 29) return 1e29;
else if (power == 30) return 1e30;
else if (power == 31) return 1e31;
else if (power == 32) return 1e32;
else if (power == 33) return 1e33;
else if (power == 34) return 1e34;
else if (power == 35) return 1e35;
else return 1e36;
}
/**
* @notice Convert price received from oracle to be scaled by (36 - tokenDecimals)
* @param config token config
* @param reportedPrice raw oracle price
* @return price scaled by (36 - tokenDecimals)
*/
function convertReportedPrice(TokenConfig memory config, int224 reportedPrice) internal pure returns (uint256) {
require(reportedPrice > 0, ErrorCodes.REPORTED_PRICE_SHOULD_BE_GREATER_THAN_ZERO);
uint256 unsignedPrice = uint256(uint224(reportedPrice));
if (config.underlyingTokenDecimals == 18) return unsignedPrice;
uint8 multiplier = 18 - uint8(config.underlyingTokenDecimals);
return unsignedPrice * pow10(multiplier);
}
/// @inheritdoc IPriceOracle
function getUnderlyingPrice(IMToken mToken) external view returns (uint256) {
require(address(mToken) != address(0), ErrorCodes.MTOKEN_ADDRESS_CANNOT_BE_ZERO);
return getAssetPrice(address(mToken.underlying()));
}
/// @inheritdoc IPriceOracle
function getAssetPrice(address underlyingAsset) public view returns (uint256) {
require(underlyingAsset != address(0), ErrorCodes.TOKEN_ADDRESS_CANNOT_BE_ZERO);
TokenConfig memory config = feedProxies[underlyingAsset];
require(config.proxyPriceFeedAddress != address(0), ErrorCodes.PRICE_FEED_ADDRESS_NOT_FOUND);
(int224 currentPrice, uint32 publishTime) = getRawPrice(config);
require(block.timestamp - publishTime <= config.maxValidPriceAge, ErrorCodes.ORACLE_PRICE_EXPIRED);
return convertReportedPrice(config, currentPrice);
}
/**
* @notice Return price and timestamp with regards to the oracle provider type
* @param config Token config
*/
function getRawPrice(TokenConfig memory config) internal view returns (int224, uint32) {
if (config.oracleProviderType == OracleProviderType.Api3) {
(int224 price, uint32 timestamp) = IProxy(config.proxyPriceFeedAddress).read();
return (price, timestamp);
} else if (config.oracleProviderType == OracleProviderType.Api3Aggregated) {
(int224 price1, uint32 timestamp1) = IProxy(config.proxyPriceFeedAddress).read();
(int224 price2, uint32 timestamp2) = IProxy(config.secondaryProxyPriceFeedAddress).read();
int224 price = (price1 * price2) / 1e18;
uint32 timestamp = timestamp1 > timestamp2 ? timestamp2 : timestamp1;
return (price, timestamp);
} else {
revert("Incorrect oracle provider type");
}
}
/**
* @notice Set the price config for a underlying asset
* @param underlyingAsset The address of underlying asset to set the price oracle for
* @param proxyPriceFeedAddress The address of price feed contract
* @param maxValidPriceAge Maximum age of the on-chain price in seconds.
* @param underlyingTokenDecimals Original token decimals
* @param oracleProviderType The identification of the oracle provider
* @dev RESTRICTION: Admin only
*/
function setTokenConfig(
address underlyingAsset,
address proxyPriceFeedAddress,
address secondaryProxyPriceFeedAddress,
uint32 maxValidPriceAge,
uint32 underlyingTokenDecimals,
OracleProviderType oracleProviderType
) external onlyRole(DEFAULT_ADMIN_ROLE) {
require(underlyingAsset != address(0), ErrorCodes.TOKEN_ADDRESS_CANNOT_BE_ZERO);
require(proxyPriceFeedAddress != address(0), ErrorCodes.OR_INCORRECT_PRICE_FEED_ADDRESS);
require(
(secondaryProxyPriceFeedAddress != address(0) && oracleProviderType == OracleProviderType.Api3Aggregated) ||
(secondaryProxyPriceFeedAddress == address(0) &&
oracleProviderType != OracleProviderType.Api3Aggregated),
ErrorCodes.OR_INCORRECT_SECONDARY_PRICE_FEED_ADDRESS
);
require(maxValidPriceAge > 0, ErrorCodes.OR_PRICE_AGE_CAN_NOT_BE_ZERO);
require(underlyingTokenDecimals > 0, ErrorCodes.OR_UNDERLYING_TOKENS_DECIMALS_SHOULD_BE_GREATER_THAN_ZERO);
require(underlyingTokenDecimals <= 18, ErrorCodes.OR_UNDERLYING_TOKENS_DECIMALS_TOO_BIG);
feedProxies[underlyingAsset] = TokenConfig(
proxyPriceFeedAddress,
secondaryProxyPriceFeedAddress,
maxValidPriceAge,
underlyingTokenDecimals,
oracleProviderType
);
emit NewTokenConfigSet(
underlyingAsset,
proxyPriceFeedAddress,
secondaryProxyPriceFeedAddress,
maxValidPriceAge,
underlyingTokenDecimals,
oracleProviderType
);
}
}
@api3/airnode-protocol-v1/contracts/api3-server-v1/proxies/interfaces/IProxy.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @dev See DapiProxy.sol for comments about usage
interface IProxy {
function read() external view returns (int224 value, uint32 timestamp);
function api3ServerV1() external view returns (address);
}
@api3/contracts/v0.8/interfaces/IProxy.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@api3/airnode-protocol-v1/contracts/api3-server-v1/proxies/interfaces/IProxy.sol";
@openzeppelin/contracts/access/AccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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:
*
* ```solidity
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```solidity
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
* to enforce additional security measures for this role.
*/
abstract contract 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(account),
" 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());
}
}
}
@openzeppelin/contracts/access/IAccessControl.sol
// 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;
}
@openzeppelin/contracts/interfaces/IERC3156FlashBorrower.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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 "ERC3156FlashBorrower.onFlashLoan"
*/
function onFlashLoan(
address initiator,
address token,
uint256 amount,
uint256 fee,
bytes calldata data
) external returns (bytes32);
}
@openzeppelin/contracts/interfaces/IERC3156FlashLender.sol
// 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);
}
@openzeppelin/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface 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);
}
@openzeppelin/contracts/utils/Context.sol
// 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;
}
}
@openzeppelin/contracts/utils/Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/Math.sol";
import "./math/SignedMath.sol";
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toString(int256 value) internal pure returns (string memory) {
return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return keccak256(bytes(a)) == keccak256(bytes(b));
}
}
@openzeppelin/contracts/utils/introspection/ERC165.sol
// 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;
}
}
@openzeppelin/contracts/utils/introspection/IERC165.sol
// 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);
}
@openzeppelin/contracts/utils/math/Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1, "Math: mulDiv overflow");
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
// See https://cs.stackexchange.com/q/138556/92363.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
// in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
}
}
}
@openzeppelin/contracts/utils/math/SafeCast.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.
pragma solidity ^0.8.0;
/**
* @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
* checks.
*
* Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
* easily result in undesired exploitation or bugs, since developers usually
* assume that overflows raise errors. `SafeCast` restores this intuition by
* reverting the transaction when such an operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*
* Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing
* all math on `uint256` and `int256` and then downcasting.
*/
library SafeCast {
/**
* @dev Returns the downcasted uint248 from uint256, reverting on
* overflow (when the input is greater than largest uint248).
*
* Counterpart to Solidity's `uint248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*
* _Available since v4.7._
*/
function toUint248(uint256 value) internal pure returns (uint248) {
require(value <= type(uint248).max, "SafeCast: value doesn't fit in 248 bits");
return uint248(value);
}
/**
* @dev Returns the downcasted uint240 from uint256, reverting on
* overflow (when the input is greater than largest uint240).
*
* Counterpart to Solidity's `uint240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*
* _Available since v4.7._
*/
function toUint240(uint256 value) internal pure returns (uint240) {
require(value <= type(uint240).max, "SafeCast: value doesn't fit in 240 bits");
return uint240(value);
}
/**
* @dev Returns the downcasted uint232 from uint256, reverting on
* overflow (when the input is greater than largest uint232).
*
* Counterpart to Solidity's `uint232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*
* _Available since v4.7._
*/
function toUint232(uint256 value) internal pure returns (uint232) {
require(value <= type(uint232).max, "SafeCast: value doesn't fit in 232 bits");
return uint232(value);
}
/**
* @dev Returns the downcasted uint224 from uint256, reverting on
* overflow (when the input is greater than largest uint224).
*
* Counterpart to Solidity's `uint224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*
* _Available since v4.2._
*/
function toUint224(uint256 value) internal pure returns (uint224) {
require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits");
return uint224(value);
}
/**
* @dev Returns the downcasted uint216 from uint256, reverting on
* overflow (when the input is greater than largest uint216).
*
* Counterpart to Solidity's `uint216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*
* _Available since v4.7._
*/
function toUint216(uint256 value) internal pure returns (uint216) {
require(value <= type(uint216).max, "SafeCast: value doesn't fit in 216 bits");
return uint216(value);
}
/**
* @dev Returns the downcasted uint208 from uint256, reverting on
* overflow (when the input is greater than largest uint208).
*
* Counterpart to Solidity's `uint208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*
* _Available since v4.7._
*/
function toUint208(uint256 value) internal pure returns (uint208) {
require(value <= type(uint208).max, "SafeCast: value doesn't fit in 208 bits");
return uint208(value);
}
/**
* @dev Returns the downcasted uint200 from uint256, reverting on
* overflow (when the input is greater than largest uint200).
*
* Counterpart to Solidity's `uint200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*
* _Available since v4.7._
*/
function toUint200(uint256 value) internal pure returns (uint200) {
require(value <= type(uint200).max, "SafeCast: value doesn't fit in 200 bits");
return uint200(value);
}
/**
* @dev Returns the downcasted uint192 from uint256, reverting on
* overflow (when the input is greater than largest uint192).
*
* Counterpart to Solidity's `uint192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*
* _Available since v4.7._
*/
function toUint192(uint256 value) internal pure returns (uint192) {
require(value <= type(uint192).max, "SafeCast: value doesn't fit in 192 bits");
return uint192(value);
}
/**
* @dev Returns the downcasted uint184 from uint256, reverting on
* overflow (when the input is greater than largest uint184).
*
* Counterpart to Solidity's `uint184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*
* _Available since v4.7._
*/
function toUint184(uint256 value) internal pure returns (uint184) {
require(value <= type(uint184).max, "SafeCast: value doesn't fit in 184 bits");
return uint184(value);
}
/**
* @dev Returns the downcasted uint176 from uint256, reverting on
* overflow (when the input is greater than largest uint176).
*
* Counterpart to Solidity's `uint176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*
* _Available since v4.7._
*/
function toUint176(uint256 value) internal pure returns (uint176) {
require(value <= type(uint176).max, "SafeCast: value doesn't fit in 176 bits");
return uint176(value);
}
/**
* @dev Returns the downcasted uint168 from uint256, reverting on
* overflow (when the input is greater than largest uint168).
*
* Counterpart to Solidity's `uint168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*
* _Available since v4.7._
*/
function toUint168(uint256 value) internal pure returns (uint168) {
require(value <= type(uint168).max, "SafeCast: value doesn't fit in 168 bits");
return uint168(value);
}
/**
* @dev Returns the downcasted uint160 from uint256, reverting on
* overflow (when the input is greater than largest uint160).
*
* Counterpart to Solidity's `uint160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*
* _Available since v4.7._
*/
function toUint160(uint256 value) internal pure returns (uint160) {
require(value <= type(uint160).max, "SafeCast: value doesn't fit in 160 bits");
return uint160(value);
}
/**
* @dev Returns the downcasted uint152 from uint256, reverting on
* overflow (when the input is greater than largest uint152).
*
* Counterpart to Solidity's `uint152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*
* _Available since v4.7._
*/
function toUint152(uint256 value) internal pure returns (uint152) {
require(value <= type(uint152).max, "SafeCast: value doesn't fit in 152 bits");
return uint152(value);
}
/**
* @dev Returns the downcasted uint144 from uint256, reverting on
* overflow (when the input is greater than largest uint144).
*
* Counterpart to Solidity's `uint144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*
* _Available since v4.7._
*/
function toUint144(uint256 value) internal pure returns (uint144) {
require(value <= type(uint144).max, "SafeCast: value doesn't fit in 144 bits");
return uint144(value);
}
/**
* @dev Returns the downcasted uint136 from uint256, reverting on
* overflow (when the input is greater than largest uint136).
*
* Counterpart to Solidity's `uint136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*
* _Available since v4.7._
*/
function toUint136(uint256 value) internal pure returns (uint136) {
require(value <= type(uint136).max, "SafeCast: value doesn't fit in 136 bits");
return uint136(value);
}
/**
* @dev Returns the downcasted uint128 from uint256, reverting on
* overflow (when the input is greater than largest uint128).
*
* Counterpart to Solidity's `uint128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*
* _Available since v2.5._
*/
function toUint128(uint256 value) internal pure returns (uint128) {
require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits");
return uint128(value);
}
/**
* @dev Returns the downcasted uint120 from uint256, reverting on
* overflow (when the input is greater than largest uint120).
*
* Counterpart to Solidity's `uint120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*
* _Available since v4.7._
*/
function toUint120(uint256 value) internal pure returns (uint120) {
require(value <= type(uint120).max, "SafeCast: value doesn't fit in 120 bits");
return uint120(value);
}
/**
* @dev Returns the downcasted uint112 from uint256, reverting on
* overflow (when the input is greater than largest uint112).
*
* Counterpart to Solidity's `uint112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*
* _Available since v4.7._
*/
function toUint112(uint256 value) internal pure returns (uint112) {
require(value <= type(uint112).max, "SafeCast: value doesn't fit in 112 bits");
return uint112(value);
}
/**
* @dev Returns the downcasted uint104 from uint256, reverting on
* overflow (when the input is greater than largest uint104).
*
* Counterpart to Solidity's `uint104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*
* _Available since v4.7._
*/
function toUint104(uint256 value) internal pure returns (uint104) {
require(value <= type(uint104).max, "SafeCast: value doesn't fit in 104 bits");
return uint104(value);
}
/**
* @dev Returns the downcasted uint96 from uint256, reverting on
* overflow (when the input is greater than largest uint96).
*
* Counterpart to Solidity's `uint96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*
* _Available since v4.2._
*/
function toUint96(uint256 value) internal pure returns (uint96) {
require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits");
return uint96(value);
}
/**
* @dev Returns the downcasted uint88 from uint256, reverting on
* overflow (when the input is greater than largest uint88).
*
* Counterpart to Solidity's `uint88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*
* _Available since v4.7._
*/
function toUint88(uint256 value) internal pure returns (uint88) {
require(value <= type(uint88).max, "SafeCast: value doesn't fit in 88 bits");
return uint88(value);
}
/**
* @dev Returns the downcasted uint80 from uint256, reverting on
* overflow (when the input is greater than largest uint80).
*
* Counterpart to Solidity's `uint80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*
* _Available since v4.7._
*/
function toUint80(uint256 value) internal pure returns (uint80) {
require(value <= type(uint80).max, "SafeCast: value doesn't fit in 80 bits");
return uint80(value);
}
/**
* @dev Returns the downcasted uint72 from uint256, reverting on
* overflow (when the input is greater than largest uint72).
*
* Counterpart to Solidity's `uint72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*
* _Available since v4.7._
*/
function toUint72(uint256 value) internal pure returns (uint72) {
require(value <= type(uint72).max, "SafeCast: value doesn't fit in 72 bits");
return uint72(value);
}
/**
* @dev Returns the downcasted uint64 from uint256, reverting on
* overflow (when the input is greater than largest uint64).
*
* Counterpart to Solidity's `uint64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*
* _Available since v2.5._
*/
function toUint64(uint256 value) internal pure returns (uint64) {
require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits");
return uint64(value);
}
/**
* @dev Returns the downcasted uint56 from uint256, reverting on
* overflow (when the input is greater than largest uint56).
*
* Counterpart to Solidity's `uint56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*
* _Available since v4.7._
*/
function toUint56(uint256 value) internal pure returns (uint56) {
require(value <= type(uint56).max, "SafeCast: value doesn't fit in 56 bits");
return uint56(value);
}
/**
* @dev Returns the downcasted uint48 from uint256, reverting on
* overflow (when the input is greater than largest uint48).
*
* Counterpart to Solidity's `uint48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*
* _Available since v4.7._
*/
function toUint48(uint256 value) internal pure returns (uint48) {
require(value <= type(uint48).max, "SafeCast: value doesn't fit in 48 bits");
return uint48(value);
}
/**
* @dev Returns the downcasted uint40 from uint256, reverting on
* overflow (when the input is greater than largest uint40).
*
* Counterpart to Solidity's `uint40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*
* _Available since v4.7._
*/
function toUint40(uint256 value) internal pure returns (uint40) {
require(value <= type(uint40).max, "SafeCast: value doesn't fit in 40 bits");
return uint40(value);
}
/**
* @dev Returns the downcasted uint32 from uint256, reverting on
* overflow (when the input is greater than largest uint32).
*
* Counterpart to Solidity's `uint32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*
* _Available since v2.5._
*/
function toUint32(uint256 value) internal pure returns (uint32) {
require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits");
return uint32(value);
}
/**
* @dev Returns the downcasted uint24 from uint256, reverting on
* overflow (when the input is greater than largest uint24).
*
* Counterpart to Solidity's `uint24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*
* _Available since v4.7._
*/
function toUint24(uint256 value) internal pure returns (uint24) {
require(value <= type(uint24).max, "SafeCast: value doesn't fit in 24 bits");
return uint24(value);
}
/**
* @dev Returns the downcasted uint16 from uint256, reverting on
* overflow (when the input is greater than largest uint16).
*
* Counterpart to Solidity's `uint16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*
* _Available since v2.5._
*/
function toUint16(uint256 value) internal pure returns (uint16) {
require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits");
return uint16(value);
}
/**
* @dev Returns the downcasted uint8 from uint256, reverting on
* overflow (when the input is greater than largest uint8).
*
* Counterpart to Solidity's `uint8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*
* _Available since v2.5._
*/
function toUint8(uint256 value) internal pure returns (uint8) {
require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits");
return uint8(value);
}
/**
* @dev Converts a signed int256 into an unsigned uint256.
*
* Requirements:
*
* - input must be greater than or equal to 0.
*
* _Available since v3.0._
*/
function toUint256(int256 value) internal pure returns (uint256) {
require(value >= 0, "SafeCast: value must be positive");
return uint256(value);
}
/**
* @dev Returns the downcasted int248 from int256, reverting on
* overflow (when the input is less than smallest int248 or
* greater than largest int248).
*
* Counterpart to Solidity's `int248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*
* _Available since v4.7._
*/
function toInt248(int256 value) internal pure returns (int248 downcasted) {
downcasted = int248(value);
require(downcasted == value, "SafeCast: value doesn't fit in 248 bits");
}
/**
* @dev Returns the downcasted int240 from int256, reverting on
* overflow (when the input is less than smallest int240 or
* greater than largest int240).
*
* Counterpart to Solidity's `int240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*
* _Available since v4.7._
*/
function toInt240(int256 value) internal pure returns (int240 downcasted) {
downcasted = int240(value);
require(downcasted == value, "SafeCast: value doesn't fit in 240 bits");
}
/**
* @dev Returns the downcasted int232 from int256, reverting on
* overflow (when the input is less than smallest int232 or
* greater than largest int232).
*
* Counterpart to Solidity's `int232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*
* _Available since v4.7._
*/
function toInt232(int256 value) internal pure returns (int232 downcasted) {
downcasted = int232(value);
require(downcasted == value, "SafeCast: value doesn't fit in 232 bits");
}
/**
* @dev Returns the downcasted int224 from int256, reverting on
* overflow (when the input is less than smallest int224 or
* greater than largest int224).
*
* Counterpart to Solidity's `int224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*
* _Available since v4.7._
*/
function toInt224(int256 value) internal pure returns (int224 downcasted) {
downcasted = int224(value);
require(downcasted == value, "SafeCast: value doesn't fit in 224 bits");
}
/**
* @dev Returns the downcasted int216 from int256, reverting on
* overflow (when the input is less than smallest int216 or
* greater than largest int216).
*
* Counterpart to Solidity's `int216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*
* _Available since v4.7._
*/
function toInt216(int256 value) internal pure returns (int216 downcasted) {
downcasted = int216(value);
require(downcasted == value, "SafeCast: value doesn't fit in 216 bits");
}
/**
* @dev Returns the downcasted int208 from int256, reverting on
* overflow (when the input is less than smallest int208 or
* greater than largest int208).
*
* Counterpart to Solidity's `int208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*
* _Available since v4.7._
*/
function toInt208(int256 value) internal pure returns (int208 downcasted) {
downcasted = int208(value);
require(downcasted == value, "SafeCast: value doesn't fit in 208 bits");
}
/**
* @dev Returns the downcasted int200 from int256, reverting on
* overflow (when the input is less than smallest int200 or
* greater than largest int200).
*
* Counterpart to Solidity's `int200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*
* _Available since v4.7._
*/
function toInt200(int256 value) internal pure returns (int200 downcasted) {
downcasted = int200(value);
require(downcasted == value, "SafeCast: value doesn't fit in 200 bits");
}
/**
* @dev Returns the downcasted int192 from int256, reverting on
* overflow (when the input is less than smallest int192 or
* greater than largest int192).
*
* Counterpart to Solidity's `int192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*
* _Available since v4.7._
*/
function toInt192(int256 value) internal pure returns (int192 downcasted) {
downcasted = int192(value);
require(downcasted == value, "SafeCast: value doesn't fit in 192 bits");
}
/**
* @dev Returns the downcasted int184 from int256, reverting on
* overflow (when the input is less than smallest int184 or
* greater than largest int184).
*
* Counterpart to Solidity's `int184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*
* _Available since v4.7._
*/
function toInt184(int256 value) internal pure returns (int184 downcasted) {
downcasted = int184(value);
require(downcasted == value, "SafeCast: value doesn't fit in 184 bits");
}
/**
* @dev Returns the downcasted int176 from int256, reverting on
* overflow (when the input is less than smallest int176 or
* greater than largest int176).
*
* Counterpart to Solidity's `int176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*
* _Available since v4.7._
*/
function toInt176(int256 value) internal pure returns (int176 downcasted) {
downcasted = int176(value);
require(downcasted == value, "SafeCast: value doesn't fit in 176 bits");
}
/**
* @dev Returns the downcasted int168 from int256, reverting on
* overflow (when the input is less than smallest int168 or
* greater than largest int168).
*
* Counterpart to Solidity's `int168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*
* _Available since v4.7._
*/
function toInt168(int256 value) internal pure returns (int168 downcasted) {
downcasted = int168(value);
require(downcasted == value, "SafeCast: value doesn't fit in 168 bits");
}
/**
* @dev Returns the downcasted int160 from int256, reverting on
* overflow (when the input is less than smallest int160 or
* greater than largest int160).
*
* Counterpart to Solidity's `int160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*
* _Available since v4.7._
*/
function toInt160(int256 value) internal pure returns (int160 downcasted) {
downcasted = int160(value);
require(downcasted == value, "SafeCast: value doesn't fit in 160 bits");
}
/**
* @dev Returns the downcasted int152 from int256, reverting on
* overflow (when the input is less than smallest int152 or
* greater than largest int152).
*
* Counterpart to Solidity's `int152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*
* _Available since v4.7._
*/
function toInt152(int256 value) internal pure returns (int152 downcasted) {
downcasted = int152(value);
require(downcasted == value, "SafeCast: value doesn't fit in 152 bits");
}
/**
* @dev Returns the downcasted int144 from int256, reverting on
* overflow (when the input is less than smallest int144 or
* greater than largest int144).
*
* Counterpart to Solidity's `int144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*
* _Available since v4.7._
*/
function toInt144(int256 value) internal pure returns (int144 downcasted) {
downcasted = int144(value);
require(downcasted == value, "SafeCast: value doesn't fit in 144 bits");
}
/**
* @dev Returns the downcasted int136 from int256, reverting on
* overflow (when the input is less than smallest int136 or
* greater than largest int136).
*
* Counterpart to Solidity's `int136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*
* _Available since v4.7._
*/
function toInt136(int256 value) internal pure returns (int136 downcasted) {
downcasted = int136(value);
require(downcasted == value, "SafeCast: value doesn't fit in 136 bits");
}
/**
* @dev Returns the downcasted int128 from int256, reverting on
* overflow (when the input is less than smallest int128 or
* greater than largest int128).
*
* Counterpart to Solidity's `int128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*
* _Available since v3.1._
*/
function toInt128(int256 value) internal pure returns (int128 downcasted) {
downcasted = int128(value);
require(downcasted == value, "SafeCast: value doesn't fit in 128 bits");
}
/**
* @dev Returns the downcasted int120 from int256, reverting on
* overflow (when the input is less than smallest int120 or
* greater than largest int120).
*
* Counterpart to Solidity's `int120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*
* _Available since v4.7._
*/
function toInt120(int256 value) internal pure returns (int120 downcasted) {
downcasted = int120(value);
require(downcasted == value, "SafeCast: value doesn't fit in 120 bits");
}
/**
* @dev Returns the downcasted int112 from int256, reverting on
* overflow (when the input is less than smallest int112 or
* greater than largest int112).
*
* Counterpart to Solidity's `int112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*
* _Available since v4.7._
*/
function toInt112(int256 value) internal pure returns (int112 downcasted) {
downcasted = int112(value);
require(downcasted == value, "SafeCast: value doesn't fit in 112 bits");
}
/**
* @dev Returns the downcasted int104 from int256, reverting on
* overflow (when the input is less than smallest int104 or
* greater than largest int104).
*
* Counterpart to Solidity's `int104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*
* _Available since v4.7._
*/
function toInt104(int256 value) internal pure returns (int104 downcasted) {
downcasted = int104(value);
require(downcasted == value, "SafeCast: value doesn't fit in 104 bits");
}
/**
* @dev Returns the downcasted int96 from int256, reverting on
* overflow (when the input is less than smallest int96 or
* greater than largest int96).
*
* Counterpart to Solidity's `int96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*
* _Available since v4.7._
*/
function toInt96(int256 value) internal pure returns (int96 downcasted) {
downcasted = int96(value);
require(downcasted == value, "SafeCast: value doesn't fit in 96 bits");
}
/**
* @dev Returns the downcasted int88 from int256, reverting on
* overflow (when the input is less than smallest int88 or
* greater than largest int88).
*
* Counterpart to Solidity's `int88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*
* _Available since v4.7._
*/
function toInt88(int256 value) internal pure returns (int88 downcasted) {
downcasted = int88(value);
require(downcasted == value, "SafeCast: value doesn't fit in 88 bits");
}
/**
* @dev Returns the downcasted int80 from int256, reverting on
* overflow (when the input is less than smallest int80 or
* greater than largest int80).
*
* Counterpart to Solidity's `int80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*
* _Available since v4.7._
*/
function toInt80(int256 value) internal pure returns (int80 downcasted) {
downcasted = int80(value);
require(downcasted == value, "SafeCast: value doesn't fit in 80 bits");
}
/**
* @dev Returns the downcasted int72 from int256, reverting on
* overflow (when the input is less than smallest int72 or
* greater than largest int72).
*
* Counterpart to Solidity's `int72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*
* _Available since v4.7._
*/
function toInt72(int256 value) internal pure returns (int72 downcasted) {
downcasted = int72(value);
require(downcasted == value, "SafeCast: value doesn't fit in 72 bits");
}
/**
* @dev Returns the downcasted int64 from int256, reverting on
* overflow (when the input is less than smallest int64 or
* greater than largest int64).
*
* Counterpart to Solidity's `int64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*
* _Available since v3.1._
*/
function toInt64(int256 value) internal pure returns (int64 downcasted) {
downcasted = int64(value);
require(downcasted == value, "SafeCast: value doesn't fit in 64 bits");
}
/**
* @dev Returns the downcasted int56 from int256, reverting on
* overflow (when the input is less than smallest int56 or
* greater than largest int56).
*
* Counterpart to Solidity's `int56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*
* _Available since v4.7._
*/
function toInt56(int256 value) internal pure returns (int56 downcasted) {
downcasted = int56(value);
require(downcasted == value, "SafeCast: value doesn't fit in 56 bits");
}
/**
* @dev Returns the downcasted int48 from int256, reverting on
* overflow (when the input is less than smallest int48 or
* greater than largest int48).
*
* Counterpart to Solidity's `int48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*
* _Available since v4.7._
*/
function toInt48(int256 value) internal pure returns (int48 downcasted) {
downcasted = int48(value);
require(downcasted == value, "SafeCast: value doesn't fit in 48 bits");
}
/**
* @dev Returns the downcasted int40 from int256, reverting on
* overflow (when the input is less than smallest int40 or
* greater than largest int40).
*
* Counterpart to Solidity's `int40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*
* _Available since v4.7._
*/
function toInt40(int256 value) internal pure returns (int40 downcasted) {
downcasted = int40(value);
require(downcasted == value, "SafeCast: value doesn't fit in 40 bits");
}
/**
* @dev Returns the downcasted int32 from int256, reverting on
* overflow (when the input is less than smallest int32 or
* greater than largest int32).
*
* Counterpart to Solidity's `int32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*
* _Available since v3.1._
*/
function toInt32(int256 value) internal pure returns (int32 downcasted) {
downcasted = int32(value);
require(downcasted == value, "SafeCast: value doesn't fit in 32 bits");
}
/**
* @dev Returns the downcasted int24 from int256, reverting on
* overflow (when the input is less than smallest int24 or
* greater than largest int24).
*
* Counterpart to Solidity's `int24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*
* _Available since v4.7._
*/
function toInt24(int256 value) internal pure returns (int24 downcasted) {
downcasted = int24(value);
require(downcasted == value, "SafeCast: value doesn't fit in 24 bits");
}
/**
* @dev Returns the downcasted int16 from int256, reverting on
* overflow (when the input is less than smallest int16 or
* greater than largest int16).
*
* Counterpart to Solidity's `int16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*
* _Available since v3.1._
*/
function toInt16(int256 value) internal pure returns (int16 downcasted) {
downcasted = int16(value);
require(downcasted == value, "SafeCast: value doesn't fit in 16 bits");
}
/**
* @dev Returns the downcasted int8 from int256, reverting on
* overflow (when the input is less than smallest int8 or
* greater than largest int8).
*
* Counterpart to Solidity's `int8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*
* _Available since v3.1._
*/
function toInt8(int256 value) internal pure returns (int8 downcasted) {
downcasted = int8(value);
require(downcasted == value, "SafeCast: value doesn't fit in 8 bits");
}
/**
* @dev Converts an unsigned uint256 into a signed int256.
*
* Requirements:
*
* - input must be less than or equal to maxInt256.
*
* _Available since v3.0._
*/
function toInt256(uint256 value) internal pure returns (int256) {
// Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256");
return int256(value);
}
}
@openzeppelin/contracts/utils/math/SignedMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMath {
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// must be unchecked in order to support `n = type(int256).min`
return uint256(n >= 0 ? n : -n);
}
}
}
contracts/interfaces/IInterestRateModel.sol
// 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);
}
contracts/interfaces/IMToken.sol
// 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 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;
}
contracts/interfaces/IPriceOracle.sol
// 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);
}
contracts/libraries/ErrorCodes.sol
// 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 LQ_INCORRECT_REPAY_AMOUNT = "E215";
string internal constant LQ_INSUFFICIENT_SEIZE_AMOUNT = "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 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 EB_MARKET_INDEX_IS_LESS_THAN_USER_INDEX = "E254";
string internal constant LQ_UNSUPPORTED_FULL_REPAY = "E255";
string internal constant LQ_UNSUPPORTED_FULL_SEIZE = "E256";
string internal constant LQ_UNSUPPORTED_MARKET_RECEIVED = "E257";
string internal constant LQ_UNSUCCESSFUL_CALLBACK = "E258";
string internal constant FL_UNAUTHORIZED_CALLBACK = "E270";
string internal constant FL_INCORRECT_TOKEN_OUT_DEVIATION = "E271";
string internal constant FL_SWAP_CALL_FAILS = "E272";
string internal constant FL_INVALID_AMOUNT_TOKEN_IN_SPENT = "E273";
string internal constant FL_INVALID_AMOUNT_TOKEN_OUT_RECEIVED = "E274";
string internal constant FL_EXACT_IN_INCORRECT_ALLOWANCE_AFTER = "E275";
string internal constant FL_RECEIVER_NOT_FOUND = "E276";
// 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 PRICE_FEED_ID_NOT_FOUND = "E327";
string internal constant INCORRECT_PRICE_MULTIPLIER = "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 PRICE_FEED_ADDRESS_NOT_FOUND = "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";
string internal constant OR_INCORRECT_PRICE_FEED_ID = "E432";
string internal constant OR_PRICE_AGE_CAN_NOT_BE_ZERO = "E433";
string internal constant OR_INCORRECT_PRICE_FEED_ADDRESS = "E434";
string internal constant OR_INCORRECT_SECONDARY_PRICE_FEED_ADDRESS = "E435";
string internal constant RH_COOLDOWN_START_ALREADY_SET = "E436";
string internal constant RH_INCORRECT_COOLDOWN_START = "E437";
string internal constant RH_COOLDOWN_IS_FINISHED = "E438";
string internal constant RH_INCORRECT_NUMBER_OF_CHARGES = "E439";
string internal constant RH_INCORRECT_CHARGE_SHARE = "E440";
string internal constant RH_COOLDOWN_START_NOT_SET = "E441";
}
Compiler Settings
{"outputSelection":{"*":{"*":["*"],"":["*"]}},"optimizer":{"runs":200,"enabled":true},"metadata":{"useLiteralContent":true},"libraries":{}}
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"admin","internalType":"address"}]},{"type":"event","name":"NewTokenConfigSet","inputs":[{"type":"address","name":"token","internalType":"address","indexed":false},{"type":"address","name":"proxyPriceFeedAddress","internalType":"address","indexed":false},{"type":"address","name":"secondaryProxyPriceFeedAddress","internalType":"address","indexed":false},{"type":"uint32","name":"maxValidPriceAge","internalType":"uint32","indexed":false},{"type":"uint32","name":"underlyingTokenDecimals","internalType":"uint32","indexed":false},{"type":"uint8","name":"oracleProviderType","internalType":"enum AggregatedPriceOracle.OracleProviderType","indexed":false}],"anonymous":false},{"type":"event","name":"RoleAdminChanged","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"previousAdminRole","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"newAdminRole","internalType":"bytes32","indexed":true}],"anonymous":false},{"type":"event","name":"RoleGranted","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"RoleRevoked","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"DEFAULT_ADMIN_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"proxyPriceFeedAddress","internalType":"address"},{"type":"address","name":"secondaryProxyPriceFeedAddress","internalType":"address"},{"type":"uint32","name":"maxValidPriceAge","internalType":"uint32"},{"type":"uint32","name":"underlyingTokenDecimals","internalType":"uint32"},{"type":"uint8","name":"oracleProviderType","internalType":"enum AggregatedPriceOracle.OracleProviderType"}],"name":"feedProxies","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getAssetPrice","inputs":[{"type":"address","name":"underlyingAsset","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getRoleAdmin","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getUnderlyingPrice","inputs":[{"type":"address","name":"mToken","internalType":"contract IMToken"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"grantRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"hasRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"revokeRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setTokenConfig","inputs":[{"type":"address","name":"underlyingAsset","internalType":"address"},{"type":"address","name":"proxyPriceFeedAddress","internalType":"address"},{"type":"address","name":"secondaryProxyPriceFeedAddress","internalType":"address"},{"type":"uint32","name":"maxValidPriceAge","internalType":"uint32"},{"type":"uint32","name":"underlyingTokenDecimals","internalType":"uint32"},{"type":"uint8","name":"oracleProviderType","internalType":"enum AggregatedPriceOracle.OracleProviderType"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"supportsInterface","inputs":[{"type":"bytes4","name":"interfaceId","internalType":"bytes4"}]}]
Contract Creation Code
0x608060405234801561001057600080fd5b50604051620017c5380380620017c5833981016040819052610031916100e1565b61003c600082610042565b50610111565b6000828152602081815260408083206001600160a01b038516845290915290205460ff166100dd576000828152602081815260408083206001600160a01b03851684529091529020805460ff1916600117905561009c3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b6000602082840312156100f357600080fd5b81516001600160a01b038116811461010a57600080fd5b9392505050565b6116a480620001216000396000f3fe608060405234801561001057600080fd5b50600436106100a95760003560e01c806391d148541161007157806391d148541461019b578063a217fddf146101ae578063b3596f07146101b6578063d4818fec146101c9578063d547741f146101dc578063fc57d4df146101ef57600080fd5b806301ffc9a7146100ae578063248a9ca3146100d65780632f2ff15d1461010757806336568abe1461011c57806343dab0801461012f575b600080fd5b6100c16100bc366004611223565b610202565b60405190151581526020015b60405180910390f35b6100f96100e436600461124d565b60009081526020819052604090206001015490565b6040519081526020016100cd565b61011a61011536600461127b565b610239565b005b61011a61012a36600461127b565b610263565b61018a61013d3660046112ab565b600160208190526000918252604090912080549101546001600160a01b039182169181169063ffffffff600160a01b8204811691600160c01b81049091169060ff600160e01b9091041685565b6040516100cd959493929190611300565b6100c16101a936600461127b565b6102e6565b6100f9600081565b6100f96101c43660046112ab565b61030f565b61011a6101d7366004611355565b6104af565b61011a6101ea36600461127b565b6107fb565b6100f96101fd3660046112ab565b610820565b60006001600160e01b03198216637965db0b60e01b148061023357506301ffc9a760e01b6001600160e01b03198316145b92915050565b600082815260208190526040902060010154610254816108cb565b61025e83836108d8565b505050565b6001600160a01b03811633146102d85760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b6102e2828261095c565b5050565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b60408051808201909152600481526308a6466760e31b60208201526000906001600160a01b0383166103545760405162461bcd60e51b81526004016102cf91906113ff565b506001600160a01b038083166000908152600160208181526040808420815160a081018352815487168152818501549687169381019390935263ffffffff600160a01b8704811692840192909252600160c01b860490911660608301529293909291608084019160ff600160e01b90910416908111156103d6576103d66112c8565b60018111156103e7576103e76112c8565b90525080516040805180820190915260048152634533333360e01b60208201529192506001600160a01b03166104305760405162461bcd60e51b81526004016102cf91906113ff565b5060008061043d836109c1565b91509150826040015163ffffffff168163ffffffff164261045e9190611448565b1115604051806040016040528060048152602001634533323160e01b8152509061049b5760405162461bcd60e51b81526004016102cf91906113ff565b506104a68383610be0565b95945050505050565b60006104ba816108cb565b60408051808201909152600481526308a6466760e31b60208201526001600160a01b0388166104fc5760405162461bcd60e51b81526004016102cf91906113ff565b50604080518082019091526004815263114d0ccd60e21b60208201526001600160a01b03871661053f5760405162461bcd60e51b81526004016102cf91906113ff565b506001600160a01b0385161580159061056957506001826001811115610567576105676112c8565b145b8061059857506001600160a01b03851615801561059857506001826001811115610595576105956112c8565b14155b604051806040016040528060048152602001634534333560e01b815250906105d35760405162461bcd60e51b81526004016102cf91906113ff565b506040805180820190915260048152634534333360e01b602082015263ffffffff85166106135760405162461bcd60e51b81526004016102cf91906113ff565b506040805180820190915260048152634534303960e01b602082015263ffffffff84166106535760405162461bcd60e51b81526004016102cf91906113ff565b50604080518082019091526004815263114d0c8d60e21b6020820152601263ffffffff851611156106975760405162461bcd60e51b81526004016102cf91906113ff565b506040518060a00160405280876001600160a01b03168152602001866001600160a01b031681526020018563ffffffff1681526020018463ffffffff1681526020018360018111156106eb576106eb6112c8565b90526001600160a01b03888116600090815260016020818152604092839020855181546001600160a01b031916908616178155908501518183018054948701516060880151929096166001600160c01b031990951694909417600160a01b63ffffffff968716021763ffffffff60c01b198116600160c01b969092169590950290811784556080860151919491939264ffffffffff60c01b1990921660ff60e01b199091161790600160e01b9084908111156107a9576107a96112c8565b02179055509050507fb1f726a2651cd9d021af39db810268f5c221cf3a5e599b109caeadcef66d330d8787878787876040516107ea9695949392919061145b565b60405180910390a150505050505050565b600082815260208190526040902060010154610816816108cb565b61025e838361095c565b6040805180820190915260048152634532333760e01b60208201526000906001600160a01b0383166108655760405162461bcd60e51b81526004016102cf91906113ff565b50610233826001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa1580156108a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101c491906114a7565b6108d58133610c70565b50565b6108e282826102e6565b6102e2576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556109183390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b61096682826102e6565b156102e2576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60008080836080015160018111156109db576109db6112c8565b03610a545760008084600001516001600160a01b03166357de26a46040518163ffffffff1660e01b81526004016040805180830381865afa158015610a24573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a4891906114c4565b90969095509350505050565b600183608001516001811115610a6c57610a6c6112c8565b03610b985760008084600001516001600160a01b03166357de26a46040518163ffffffff1660e01b81526004016040805180830381865afa158015610ab5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ad991906114c4565b9150915060008086602001516001600160a01b03166357de26a46040518163ffffffff1660e01b81526004016040805180830381865afa158015610b21573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b4591906114c4565b90925090506000670de0b6b3a7640000610b5f84876114f9565b610b699190611527565b905060008263ffffffff168563ffffffff1611610b865784610b88565b825b9199919850909650505050505050565b60405162461bcd60e51b815260206004820152601e60248201527f496e636f7272656374206f7261636c652070726f76696465722074797065000060448201526064016102cf565b60008082601b0b13604051806040016040528060048152602001632299199b60e11b81525090610c235760405162461bcd60e51b81526004016102cf91906113ff565b5060608301516001600160e01b0383169063ffffffff16601203610c48579050610233565b600084606001516012610c5b9190611573565b9050610c6681610cc9565b6104a6908361158c565b610c7a82826102e6565b6102e257610c878161106e565b610c92836020611080565b604051602001610ca39291906115a3565b60408051601f198184030181529082905262461bcd60e51b82526102cf916004016113ff565b60008160ff16601603610ce7575069021e19e0c9bab2400000919050565b8160ff16601403610d02575068056bc75e2d63100000919050565b8160ff16600a03610d1957506402540be400919050565b8160ff16600103610d2c5750600a919050565b8160ff16600203610d3f57506064919050565b8160ff16600303610d5357506103e8919050565b8160ff16600403610d675750612710919050565b8160ff16600503610d7c5750620186a0919050565b8160ff16600603610d915750620f4240919050565b8160ff16600703610da6575062989680919050565b8160ff16600803610dbc57506305f5e100919050565b8160ff16600903610dd25750633b9aca00919050565b8160ff16600b03610de9575064174876e800919050565b8160ff16600c03610e00575064e8d4a51000919050565b8160ff16600d03610e1857506509184e72a000919050565b8160ff16600e03610e305750655af3107a4000919050565b8160ff16600f03610e49575066038d7ea4c68000919050565b8160ff16601003610e625750662386f26fc10000919050565b8160ff16601103610e7c575067016345785d8a0000919050565b8160ff16601203610e965750670de0b6b3a7640000919050565b8160ff16601303610eb05750678ac7230489e80000919050565b8160ff16601503610ecb5750683635c9adc5dea00000919050565b8160ff16601703610ee7575069152d02c7e14af6800000919050565b8160ff16601803610f03575069d3c21bcecceda1000000919050565b8160ff16601903610f2057506a084595161401484a000000919050565b8160ff16601a03610f3d57506a52b7d2dcc80cd2e4000000919050565b8160ff16601b03610f5b57506b033b2e3c9fd0803ce8000000919050565b8160ff16601c03610f7957506b204fce5e3e25026110000000919050565b8160ff16601d03610f9857506c01431e0fae6d7217caa0000000919050565b8160ff16601e03610fb757506c0c9f2c9cd04674edea40000000919050565b8160ff16601f03610fd657506c7e37be2022c0914b2680000000919050565b8160ff16602003610ff657506d04ee2d6d415b85acef8100000000919050565b8160ff1660210361101657506d314dc6448d9338c15b0a00000000919050565b8160ff1660220361103757506e01ed09bead87c0378d8e6400000000919050565b8160ff1660230361105857506e13426172c74d822b878fe800000000919050565b506ec097ce7bc90715b34b9f1000000000919050565b60606102336001600160a01b03831660145b6060600061108f83600261158c565b61109a906002611618565b67ffffffffffffffff8111156110b2576110b261162b565b6040519080825280601f01601f1916602001820160405280156110dc576020820181803683370190505b509050600360fc1b816000815181106110f7576110f7611641565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061112657611126611641565b60200101906001600160f81b031916908160001a905350600061114a84600261158c565b611155906001611618565b90505b60018111156111cd576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061118957611189611641565b1a60f81b82828151811061119f5761119f611641565b60200101906001600160f81b031916908160001a90535060049490941c936111c681611657565b9050611158565b50831561121c5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016102cf565b9392505050565b60006020828403121561123557600080fd5b81356001600160e01b03198116811461121c57600080fd5b60006020828403121561125f57600080fd5b5035919050565b6001600160a01b03811681146108d557600080fd5b6000806040838503121561128e57600080fd5b8235915060208301356112a081611266565b809150509250929050565b6000602082840312156112bd57600080fd5b813561121c81611266565b634e487b7160e01b600052602160045260246000fd5b600281106112fc57634e487b7160e01b600052602160045260246000fd5b9052565b6001600160a01b0386811682528516602082015263ffffffff84811660408301528316606082015260a0810161133960808301846112de565b9695505050505050565b63ffffffff811681146108d557600080fd5b60008060008060008060c0878903121561136e57600080fd5b863561137981611266565b9550602087013561138981611266565b9450604087013561139981611266565b935060608701356113a981611343565b925060808701356113b981611343565b915060a0870135600281106113cd57600080fd5b809150509295509295509295565b60005b838110156113f65781810151838201526020016113de565b50506000910152565b602081526000825180602084015261141e8160408501602087016113db565b601f01601f19169190910160400192915050565b634e487b7160e01b600052601160045260246000fd5b8181038181111561023357610233611432565b6001600160a01b03878116825286811660208301528516604082015263ffffffff84811660608301528316608082015260c0810161149c60a08301846112de565b979650505050505050565b6000602082840312156114b957600080fd5b815161121c81611266565b600080604083850312156114d757600080fd5b825180601b0b81146114e857600080fd5b60208401519092506112a081611343565b600081601b0b83601b0b808202601b0b9250818305811482151761151f5761151f611432565b505092915050565b600081601b0b83601b0b8061154c57634e487b7160e01b600052601260045260246000fd5b6001600160df1b031982146000198214161561156a5761156a611432565b90059392505050565b60ff828116828216039081111561023357610233611432565b808202811582820484141761023357610233611432565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516115db8160178501602088016113db565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161160c8160288401602088016113db565b01602801949350505050565b8082018082111561023357610233611432565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b60008161166657611666611432565b50600019019056fea2646970667358221220c4602ab2509eb27d8730bae80145fff5134453c164442b7388c4fc715927e5f864736f6c6343000811003300000000000000000000000066f850099e6d5dbd712d15244b65bd822f36be7e
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c806391d148541161007157806391d148541461019b578063a217fddf146101ae578063b3596f07146101b6578063d4818fec146101c9578063d547741f146101dc578063fc57d4df146101ef57600080fd5b806301ffc9a7146100ae578063248a9ca3146100d65780632f2ff15d1461010757806336568abe1461011c57806343dab0801461012f575b600080fd5b6100c16100bc366004611223565b610202565b60405190151581526020015b60405180910390f35b6100f96100e436600461124d565b60009081526020819052604090206001015490565b6040519081526020016100cd565b61011a61011536600461127b565b610239565b005b61011a61012a36600461127b565b610263565b61018a61013d3660046112ab565b600160208190526000918252604090912080549101546001600160a01b039182169181169063ffffffff600160a01b8204811691600160c01b81049091169060ff600160e01b9091041685565b6040516100cd959493929190611300565b6100c16101a936600461127b565b6102e6565b6100f9600081565b6100f96101c43660046112ab565b61030f565b61011a6101d7366004611355565b6104af565b61011a6101ea36600461127b565b6107fb565b6100f96101fd3660046112ab565b610820565b60006001600160e01b03198216637965db0b60e01b148061023357506301ffc9a760e01b6001600160e01b03198316145b92915050565b600082815260208190526040902060010154610254816108cb565b61025e83836108d8565b505050565b6001600160a01b03811633146102d85760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b6102e2828261095c565b5050565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b60408051808201909152600481526308a6466760e31b60208201526000906001600160a01b0383166103545760405162461bcd60e51b81526004016102cf91906113ff565b506001600160a01b038083166000908152600160208181526040808420815160a081018352815487168152818501549687169381019390935263ffffffff600160a01b8704811692840192909252600160c01b860490911660608301529293909291608084019160ff600160e01b90910416908111156103d6576103d66112c8565b60018111156103e7576103e76112c8565b90525080516040805180820190915260048152634533333360e01b60208201529192506001600160a01b03166104305760405162461bcd60e51b81526004016102cf91906113ff565b5060008061043d836109c1565b91509150826040015163ffffffff168163ffffffff164261045e9190611448565b1115604051806040016040528060048152602001634533323160e01b8152509061049b5760405162461bcd60e51b81526004016102cf91906113ff565b506104a68383610be0565b95945050505050565b60006104ba816108cb565b60408051808201909152600481526308a6466760e31b60208201526001600160a01b0388166104fc5760405162461bcd60e51b81526004016102cf91906113ff565b50604080518082019091526004815263114d0ccd60e21b60208201526001600160a01b03871661053f5760405162461bcd60e51b81526004016102cf91906113ff565b506001600160a01b0385161580159061056957506001826001811115610567576105676112c8565b145b8061059857506001600160a01b03851615801561059857506001826001811115610595576105956112c8565b14155b604051806040016040528060048152602001634534333560e01b815250906105d35760405162461bcd60e51b81526004016102cf91906113ff565b506040805180820190915260048152634534333360e01b602082015263ffffffff85166106135760405162461bcd60e51b81526004016102cf91906113ff565b506040805180820190915260048152634534303960e01b602082015263ffffffff84166106535760405162461bcd60e51b81526004016102cf91906113ff565b50604080518082019091526004815263114d0c8d60e21b6020820152601263ffffffff851611156106975760405162461bcd60e51b81526004016102cf91906113ff565b506040518060a00160405280876001600160a01b03168152602001866001600160a01b031681526020018563ffffffff1681526020018463ffffffff1681526020018360018111156106eb576106eb6112c8565b90526001600160a01b03888116600090815260016020818152604092839020855181546001600160a01b031916908616178155908501518183018054948701516060880151929096166001600160c01b031990951694909417600160a01b63ffffffff968716021763ffffffff60c01b198116600160c01b969092169590950290811784556080860151919491939264ffffffffff60c01b1990921660ff60e01b199091161790600160e01b9084908111156107a9576107a96112c8565b02179055509050507fb1f726a2651cd9d021af39db810268f5c221cf3a5e599b109caeadcef66d330d8787878787876040516107ea9695949392919061145b565b60405180910390a150505050505050565b600082815260208190526040902060010154610816816108cb565b61025e838361095c565b6040805180820190915260048152634532333760e01b60208201526000906001600160a01b0383166108655760405162461bcd60e51b81526004016102cf91906113ff565b50610233826001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa1580156108a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101c491906114a7565b6108d58133610c70565b50565b6108e282826102e6565b6102e2576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556109183390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b61096682826102e6565b156102e2576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60008080836080015160018111156109db576109db6112c8565b03610a545760008084600001516001600160a01b03166357de26a46040518163ffffffff1660e01b81526004016040805180830381865afa158015610a24573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a4891906114c4565b90969095509350505050565b600183608001516001811115610a6c57610a6c6112c8565b03610b985760008084600001516001600160a01b03166357de26a46040518163ffffffff1660e01b81526004016040805180830381865afa158015610ab5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ad991906114c4565b9150915060008086602001516001600160a01b03166357de26a46040518163ffffffff1660e01b81526004016040805180830381865afa158015610b21573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b4591906114c4565b90925090506000670de0b6b3a7640000610b5f84876114f9565b610b699190611527565b905060008263ffffffff168563ffffffff1611610b865784610b88565b825b9199919850909650505050505050565b60405162461bcd60e51b815260206004820152601e60248201527f496e636f7272656374206f7261636c652070726f76696465722074797065000060448201526064016102cf565b60008082601b0b13604051806040016040528060048152602001632299199b60e11b81525090610c235760405162461bcd60e51b81526004016102cf91906113ff565b5060608301516001600160e01b0383169063ffffffff16601203610c48579050610233565b600084606001516012610c5b9190611573565b9050610c6681610cc9565b6104a6908361158c565b610c7a82826102e6565b6102e257610c878161106e565b610c92836020611080565b604051602001610ca39291906115a3565b60408051601f198184030181529082905262461bcd60e51b82526102cf916004016113ff565b60008160ff16601603610ce7575069021e19e0c9bab2400000919050565b8160ff16601403610d02575068056bc75e2d63100000919050565b8160ff16600a03610d1957506402540be400919050565b8160ff16600103610d2c5750600a919050565b8160ff16600203610d3f57506064919050565b8160ff16600303610d5357506103e8919050565b8160ff16600403610d675750612710919050565b8160ff16600503610d7c5750620186a0919050565b8160ff16600603610d915750620f4240919050565b8160ff16600703610da6575062989680919050565b8160ff16600803610dbc57506305f5e100919050565b8160ff16600903610dd25750633b9aca00919050565b8160ff16600b03610de9575064174876e800919050565b8160ff16600c03610e00575064e8d4a51000919050565b8160ff16600d03610e1857506509184e72a000919050565b8160ff16600e03610e305750655af3107a4000919050565b8160ff16600f03610e49575066038d7ea4c68000919050565b8160ff16601003610e625750662386f26fc10000919050565b8160ff16601103610e7c575067016345785d8a0000919050565b8160ff16601203610e965750670de0b6b3a7640000919050565b8160ff16601303610eb05750678ac7230489e80000919050565b8160ff16601503610ecb5750683635c9adc5dea00000919050565b8160ff16601703610ee7575069152d02c7e14af6800000919050565b8160ff16601803610f03575069d3c21bcecceda1000000919050565b8160ff16601903610f2057506a084595161401484a000000919050565b8160ff16601a03610f3d57506a52b7d2dcc80cd2e4000000919050565b8160ff16601b03610f5b57506b033b2e3c9fd0803ce8000000919050565b8160ff16601c03610f7957506b204fce5e3e25026110000000919050565b8160ff16601d03610f9857506c01431e0fae6d7217caa0000000919050565b8160ff16601e03610fb757506c0c9f2c9cd04674edea40000000919050565b8160ff16601f03610fd657506c7e37be2022c0914b2680000000919050565b8160ff16602003610ff657506d04ee2d6d415b85acef8100000000919050565b8160ff1660210361101657506d314dc6448d9338c15b0a00000000919050565b8160ff1660220361103757506e01ed09bead87c0378d8e6400000000919050565b8160ff1660230361105857506e13426172c74d822b878fe800000000919050565b506ec097ce7bc90715b34b9f1000000000919050565b60606102336001600160a01b03831660145b6060600061108f83600261158c565b61109a906002611618565b67ffffffffffffffff8111156110b2576110b261162b565b6040519080825280601f01601f1916602001820160405280156110dc576020820181803683370190505b509050600360fc1b816000815181106110f7576110f7611641565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061112657611126611641565b60200101906001600160f81b031916908160001a905350600061114a84600261158c565b611155906001611618565b90505b60018111156111cd576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061118957611189611641565b1a60f81b82828151811061119f5761119f611641565b60200101906001600160f81b031916908160001a90535060049490941c936111c681611657565b9050611158565b50831561121c5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016102cf565b9392505050565b60006020828403121561123557600080fd5b81356001600160e01b03198116811461121c57600080fd5b60006020828403121561125f57600080fd5b5035919050565b6001600160a01b03811681146108d557600080fd5b6000806040838503121561128e57600080fd5b8235915060208301356112a081611266565b809150509250929050565b6000602082840312156112bd57600080fd5b813561121c81611266565b634e487b7160e01b600052602160045260246000fd5b600281106112fc57634e487b7160e01b600052602160045260246000fd5b9052565b6001600160a01b0386811682528516602082015263ffffffff84811660408301528316606082015260a0810161133960808301846112de565b9695505050505050565b63ffffffff811681146108d557600080fd5b60008060008060008060c0878903121561136e57600080fd5b863561137981611266565b9550602087013561138981611266565b9450604087013561139981611266565b935060608701356113a981611343565b925060808701356113b981611343565b915060a0870135600281106113cd57600080fd5b809150509295509295509295565b60005b838110156113f65781810151838201526020016113de565b50506000910152565b602081526000825180602084015261141e8160408501602087016113db565b601f01601f19169190910160400192915050565b634e487b7160e01b600052601160045260246000fd5b8181038181111561023357610233611432565b6001600160a01b03878116825286811660208301528516604082015263ffffffff84811660608301528316608082015260c0810161149c60a08301846112de565b979650505050505050565b6000602082840312156114b957600080fd5b815161121c81611266565b600080604083850312156114d757600080fd5b825180601b0b81146114e857600080fd5b60208401519092506112a081611343565b600081601b0b83601b0b808202601b0b9250818305811482151761151f5761151f611432565b505092915050565b600081601b0b83601b0b8061154c57634e487b7160e01b600052601260045260246000fd5b6001600160df1b031982146000198214161561156a5761156a611432565b90059392505050565b60ff828116828216039081111561023357610233611432565b808202811582820484141761023357610233611432565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516115db8160178501602088016113db565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161160c8160288401602088016113db565b01602801949350505050565b8082018082111561023357610233611432565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b60008161166657611666611432565b50600019019056fea2646970667358221220c4602ab2509eb27d8730bae80145fff5134453c164442b7388c4fc715927e5f864736f6c63430008110033