Contract Overview
Balance:
0 DEV
My Name Tag:
Not Available
Txn Hash | Method |
Block
|
From
|
To
|
Value | [Txn Fee] | |||
---|---|---|---|---|---|---|---|---|---|
0x67f487325ad16f330dd34bf0d311acad6f6bc1d15d9b8ac9fbf7d01315b6dc11 | 0x60806040 | 3134243 | 214 days 20 hrs ago | 0xb6010d7ac4a8e9fa3e88b25f287fe725f2215208 | IN | Create: QAdmin | 0 DEV | 0.002759623 |
[ Download CSV Export ]
Latest 25 internal transaction
[ Download CSV Export ]
Contract Name:
QAdmin
Compiler Version
v0.8.10+commit.fc410830
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
//SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.9; import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "./interfaces/IFixedRateMarket.sol"; import "./interfaces/IQollateralManager.sol"; import "./interfaces/IFeeEmissionsQontroller.sol"; import "./interfaces/IStakingEmissionsQontroller.sol"; import "./interfaces/ITradingEmissionsQontroller.sol"; import "./interfaces/IQAdmin.sol"; import "./interfaces/IVeQoda.sol"; import "./libraries/QTypes.sol"; contract QAdmin is Initializable, AccessControlEnumerableUpgradeable, IQAdmin { /// @notice Identifier of the admin role bytes32 public constant ADMIN_ROLE = keccak256("ADMIN"); /// @notice Identifier of the market role bytes32 public constant MARKET_ROLE = keccak256("MARKET"); /// @notice Identifier of the role who allows accounts to mint tokens in QodaERC20 bytes32 public constant MINTER_ROLE = keccak256("MINTER"); /// @notice Identifier of the veToken role to do stake / unstake in StakingEmissionsQontroller bytes32 public constant VETOKEN_ROLE = keccak256("VETOKEN"); /// @notice Contract for managing user collateral IQollateralManager private _qollateralManager; /// @notice Contract for staking rewards IStakingEmissionsQontroller private _stakingEmissionsQontroller; /// @notice Contract for trading volume rewards ITradingEmissionsQontroller private _tradingEmissionsQontroller; /// @notice Contract for handling protocol fee charging and emission IFeeEmissionsQontroller private _feeEmissionsQontroller; /// @notice Contract for veQoda Token IVeQoda private _veQoda; /// @notice Iterable list of all `Asset` addresses address[] private _allAssets; /// @notice Default value for `minCollateralRatio` if it is not defined in `_creditFacilityMap` for given address /// Scaled by 1e8 uint private _minCollateralRatio; /// @notice Default value for `initCollateralRatio` if it is not defined in `_creditFacilityMap` for given address /// Scaled by 1e8 uint private _initCollateralRatio; /// @notice The percent, ranging from 0% to 100%, of a liquidatable account's /// borrow that can be repaid in a single liquidate transaction. /// Scaled by 1e8 uint private _closeFactor; /// @notice Grace period (in seconds) after maturity before liquidators are allowed to /// liquidate underwater accounts. uint private _repaymentGracePeriod; /// @notice Grace period (in seconds) after maturity before lenders are allowed to /// redeem their qTokens for underlying tokens uint private _maturityGracePeriod; /// @notice Additional collateral given to liquidator as incentive to liquidate /// underwater accounts. For example, if liquidation incentive is 1.1, liquidator /// receives extra 10% of borrowers' collateral /// Scaled by 1e8 uint private _liquidationIncentive; /// @notice threshold in USD where protocol fee from each market will be transferred into `FeeEmissionsQontroller` /// once this amount is reached, scaled by 1e6 uint private _thresholdUSD; /// @notice Mapping for the annualized fee for loans in basis points for each `FixedRateMarket`. /// The fee is charged to both the lender and the borrower on any given deal. The fee rate will /// need to be scaled for loans that mature outside of 1 year. /// Scaled by 1e4 mapping(IFixedRateMarket => uint) private _protocolFee; /// @notice All enabled `Asset`s /// tokenAddress => Asset mapping(IERC20 => QTypes.Asset) private _assets; /// @notice Get the `FixedRateMarket` contract address for any given /// token and maturity time /// tokenAddress => maturity => fixedRateMarket mapping(IERC20 => mapping(uint => IFixedRateMarket)) private _fixedRateMarkets; /// @notice Mapping for the MToken market corresponding to any underlying ERC20 /// tokenAddress => mTokenAddress mapping(IERC20 => address) private _underlyingToMToken; /// @notice Mapping to determine whether a `FixedRateMarket` address /// is enabled or not /// fixedRateMarket => bool mapping(IFixedRateMarket => bool) private _enabledMarkets; /// @notice Mapping to determine the minimum quote size for any `FixedRateMarket` /// in PV terms, denominated in local currency /// fixedRateMarket => minQuoteSize mapping(IFixedRateMarket => uint) private _minQuoteSize; /// @notice Mapping to determine collateral ratio and credit limit of each address /// userAddress => creditInfo mapping(address => QTypes.CreditFacility) private _creditFacilityMap; /// @notice Constructor for upgradeable contracts function initialize(address admin) public initializer { // Initialize access control __AccessControlEnumerable_init(); _setupRole(ADMIN_ROLE, admin); _setupRole(MARKET_ROLE, admin); _setupRole(MINTER_ROLE, admin); _setupRole(VETOKEN_ROLE, admin); _setRoleAdmin(ADMIN_ROLE, ADMIN_ROLE); _setRoleAdmin(MARKET_ROLE, ADMIN_ROLE); _setRoleAdmin(MINTER_ROLE, ADMIN_ROLE); _setRoleAdmin(VETOKEN_ROLE, ADMIN_ROLE); // Set initial values for parameters _minCollateralRatio = 1e8; _initCollateralRatio = 1.1e8; _closeFactor = 0.5e8; _repaymentGracePeriod = 14400; _maturityGracePeriod = 28800; _liquidationIncentive = 1.1e8; } modifier onlyAdmin() { require(hasRole(ADMIN_ROLE, msg.sender), "QAdmin: only admin"); _; } modifier onlyMarket() { require(hasRole(MARKET_ROLE, msg.sender), "QAdmin: only market"); _; } modifier onlyVeToken() { require(hasRole(VETOKEN_ROLE, msg.sender), "QAdmin: only veToken"); _; } /** ADMIN FUNCTIONS **/ /// @notice Call upon initialization after deploying `QollateralManager` contract /// @param qollateralManagerAddress Address of `QollateralManager` deployment function _setQollateralManager(address qollateralManagerAddress) external onlyAdmin { // Initialize the value _qollateralManager = IQollateralManager(qollateralManagerAddress); // Emit the event emit SetQollateralManager(qollateralManagerAddress); } /// @notice Call upon initialization after deploying `StakingEmissionsQontroller` contract /// @param stakingEmissionsQontrollerAddress Address of `StakingEmissionsQontroller` deployment function _setStakingEmissionsQontroller(address stakingEmissionsQontrollerAddress) external onlyAdmin { // Initialize the value _stakingEmissionsQontroller = IStakingEmissionsQontroller(stakingEmissionsQontrollerAddress); // Emit the event emit SetStakingEmissionsQontroller(stakingEmissionsQontrollerAddress); } /// @notice Call upon initialization after deploying `TradingEmissionsQontroller` contract /// @param tradingEmissionsQontrollerAddress Address of `TradingEmissionsQontroller` deployment function _setTradingEmissionsQontroller(address tradingEmissionsQontrollerAddress) external onlyAdmin { // Initialize the value _tradingEmissionsQontroller = ITradingEmissionsQontroller(tradingEmissionsQontrollerAddress); // Emit the event emit SetTradingEmissionsQontroller(tradingEmissionsQontrollerAddress); } /// @notice Call upon initialization after deploying `FeeEmissionsQontroller` contract /// @param feeEmissionsQontrollerAddress Address of `FeeEmissionsQontroller` deployment function _setFeeEmissionsQontroller(address feeEmissionsQontrollerAddress) external onlyAdmin { _feeEmissionsQontroller = IFeeEmissionsQontroller(feeEmissionsQontrollerAddress); // Emit the event emit SetFeeEmissionsQontroller(feeEmissionsQontrollerAddress); } /// @notice Call upon initialization after deploying `veQoda` contract /// @param veQodaAddress Address of `veQoda` deployment function _setVeQoda(address veQodaAddress) external onlyAdmin { // Initialize the value _veQoda = IVeQoda(veQodaAddress); // Give `veQoda` the VETOKEN access control role _setupRole(VETOKEN_ROLE, veQodaAddress); // Emit the event emit SetVeQoda(veQodaAddress); } /// @notice Admin function for adding new Assets. An Asset must be added before it /// can be used as collateral or borrowed. Note: We can create functionality for /// allowing borrows of a token but not using it as collateral by setting /// `collateralFactor` to zero. /// @param token ERC20 token corresponding to the Asset /// @param isYieldBearing True if token bears interest (eg aToken, cToken, mToken, etc) /// @param underlying Address of the underlying token /// @param oracleFeed Chainlink price feed address /// @param collateralFactor_ 0.0 to 1.0 (scaled to 1e8) for discounting risky assets /// @param marketFactor_ 0.0 to 1.0 (scaled to 1e8) for premium on risky borrows function _addAsset( IERC20 token, bool isYieldBearing, address underlying, address oracleFeed, uint collateralFactor_, uint marketFactor_ ) external onlyAdmin { // Cannot add the same asset twice require(!_assets[token].isEnabled, "QAdmin: asset already exists"); // `collateralFactor` must be between 0 and 1 (scaled to 1e8) require( collateralFactor_ <= MAX_COLLATERAL_FACTOR(), "QAdmin: invalid collateral factor" ); // `marketFactor` must be between 0 and 1 (scaled to 1e8) require( marketFactor_ <= MAX_MARKET_FACTOR(), "QAdmin: invalid market factor" ); // Initialize the `Asset` with the given parameters, and no enabled // maturities to begin with uint[] memory maturities_; QTypes.Asset memory asset = QTypes.Asset( true, isYieldBearing, underlying, oracleFeed, collateralFactor_, marketFactor_, maturities_ ); _assets[token] = asset; _allAssets.push(address(token)); // Add yield-bearing assets to the (underlying => MToken) mapping if(isYieldBearing) { _underlyingToMToken[IERC20(underlying)]= address(token); } // Emit the event emit AddAsset(address(token), isYieldBearing, oracleFeed, collateralFactor_, marketFactor_); } /// @notice Adds a new `FixedRateMarket` contract into the internal mapping of /// whitelisted market addresses /// @param market New `FixedRateMarket` contract address /// @param protocolFee_ Corresponding protocol fee in basis points /// @param minQuoteSize_ Size in PV terms, local currency function _addFixedRateMarket( IFixedRateMarket market, uint protocolFee_, uint minQuoteSize_ ) external onlyAdmin { // Get athe values from the corresponding `FixedRateMarket` contract uint maturity = market.maturity(); IERC20 token = market.underlyingToken(); // Don't allow zero address require(address(token) != address(0), "QAdmin: invalid token address"); // Only allow `Markets` where the corresponding `Asset` is enabled require(_assets[token].isEnabled, "QAdmin: unsupported asset"); // Check that this market hasn't already been instantiated before require( address(_fixedRateMarkets[token][maturity]) == address(0), "QAdmin: market already exists" ); // Add the maturity as enabled to the corresponding Asset QTypes.Asset storage asset = _assets[token]; asset.maturities.push(maturity); // Add newly-created `FixedRateMarket` to the lookup list _fixedRateMarkets[token][maturity] = market; // Enable newly-created `FixedRateMarket` _enabledMarkets[market] = true; // Give `FixedRateMarket` the MARKET access control role _setupRole(MARKET_ROLE, address(market)); // Emit the event emit CreateFixedRateMarket( address(market), address(token), maturity ); // Initialize the protocol fee for this `market` _setProtocolFee(market, protocolFee_); // Initialize the minimum `Quote` size for this `market` _setMinQuoteSize(market, minQuoteSize_); } /// @notice Update the `collateralFactor` for a given `Asset` /// @param token ERC20 token corresponding to the Asset /// @param collateralFactor_ 0.0 to 1.0 (scaled to 1e8) for discounting risky assets function _setCollateralFactor( IERC20 token, uint collateralFactor_ ) external onlyAdmin { // Asset must already be enabled require(_assets[token].isEnabled, "QAdmin: asset not enabled"); // `collateralFactor` must be between 0 and 1 (scaled to 1e8) require( collateralFactor_ <= MAX_COLLATERAL_FACTOR(), "QAdmin: invalid collateral factor" ); // Look up the corresponding asset QTypes.Asset storage asset = _assets[token]; // Emit the event emit SetCollateralFactor(address(token), asset.collateralFactor, collateralFactor_); // Set `collateralFactor` asset.collateralFactor = collateralFactor_; } /// @notice Update the `marketFactor` for a given `Asset` /// @param token Address of the token corresponding to the Asset /// @param marketFactor_ 0.0 to 1.0 (scaled to 1e8) for discounting risky assets function _setMarketFactor( IERC20 token, uint marketFactor_ ) external onlyAdmin { // Asset must already be enabled require(_assets[token].isEnabled, "QAdmin: asset not enabled"); // `marketFactor` must be between 0 and 1 (scaled to 1e8) require( marketFactor_ <= MAX_MARKET_FACTOR(), "QAdmin: invalid asset factor" ); // Look up the corresponding asset QTypes.Asset storage asset = _assets[token]; // Emit the event emit SetMarketFactor(address(token), asset.marketFactor, marketFactor_); // Set `marketFactor` asset.marketFactor = marketFactor_; } /// @notice Set the minimum quote size for a particular `FixedRateMarket` /// @param market Address of the `FixedRateMarket` contract /// @param minQuoteSize_ Size in PV terms, local currency function _setMinQuoteSize(IFixedRateMarket market, uint minQuoteSize_) public onlyAdmin { // `FixedRateMarket` must already exist require( address(_fixedRateMarkets[market.underlyingToken()][market.maturity()]) != address(0), "QAdmin: market doesn't exist" ); // Emit the event emit SetMinQuoteSize(address(market), _minQuoteSize[market], minQuoteSize_); // Set `minQuoteSize` _minQuoteSize[market] = minQuoteSize_; } /// @notice Set the global minimum and initial collateral ratio /// @param minCollateralRatio_ New global minimum collateral ratio value /// @param initCollateralRatio_ New global initial collateral ratio value function _setCollateralRatio(uint minCollateralRatio_, uint initCollateralRatio_) external onlyAdmin { // `minCollateralRatio_` cannot be above `initCollateralRatio_` require( minCollateralRatio_ <= initCollateralRatio_, "QAdmin: min collateral ratio must be less than or equal to init collateral ratio" ); // Emit the event emit SetCollateralRatio(_minCollateralRatio, _initCollateralRatio, minCollateralRatio_, initCollateralRatio_); // Set `_minCollateralRatio` to new value _minCollateralRatio = minCollateralRatio_; // Set `_initCollateralRatio` to new value _initCollateralRatio = initCollateralRatio_; } /// @notice Set credit facility for specified account /// @param account_ account for credit facility adjustment /// @param enabled_ If credit facility should be enabled /// @param minCollateralRatio_ New minimum collateral ratio value /// @param initCollateralRatio_ New initial collateral ratio value /// @param creditLimit_ new credit limit in USD, scaled by 1e18 function _setCreditFacility(address account_, bool enabled_, uint minCollateralRatio_, uint initCollateralRatio_, uint creditLimit_) external onlyAdmin { // `minCollateralRatio_` cannot be above `initCollateralRatio_` require( minCollateralRatio_ <= initCollateralRatio_, "QAdmin: min collateral ratio must be less than or equal to init collateral ratio" ); // Emit the event emit SetCreditFacility( account_, _creditFacilityMap[account_].enabled, _creditFacilityMap[account_].minCollateralRatio, _creditFacilityMap[account_].initCollateralRatio, _creditFacilityMap[account_].creditLimit, enabled_, minCollateralRatio_, initCollateralRatio_, creditLimit_); // Set CreditFacility to new value _creditFacilityMap[account_].enabled = enabled_; _creditFacilityMap[account_].minCollateralRatio = minCollateralRatio_; _creditFacilityMap[account_].initCollateralRatio = initCollateralRatio_; _creditFacilityMap[account_].creditLimit = creditLimit_; } /// @notice Set the global close factor /// @param closeFactor_ New close factor value function _setCloseFactor(uint closeFactor_) external onlyAdmin { // `_closeFactor` needs to be between 0 and 1 require(closeFactor_ <= MANTISSA_FACTORS(), "QAdmin: must be between 0 and 1"); // Emit the event emit SetCloseFactor(_closeFactor, closeFactor_); // Set `_closeFactor` to new value _closeFactor = closeFactor_; } /// @notice Set the global repayment grace period /// @param repaymentGracePeriod_ New repayment grace period function _setRepaymentGracePeriod(uint repaymentGracePeriod_) external onlyAdmin { // `_repaymentGracePeriod` needs to be <= 60*60*24 (ie 24 hours) require(repaymentGracePeriod_ <= 86400, "QAdmin: must be below 1 day"); // Emit the event emit SetRepaymentGracePeriod(_repaymentGracePeriod, repaymentGracePeriod_); // set `_repaymentGracePeriod` to new value _repaymentGracePeriod = repaymentGracePeriod_; } /// @notice Set the global maturity grace period /// @param maturityGracePeriod_ New maturity grace period function _setMaturityGracePeriod(uint maturityGracePeriod_) external onlyAdmin { // `_maturityGracePeriod` needs to be <= 60*60*24 (ie 24 hours) require(maturityGracePeriod_ <= 86400, "QAdmin: must be below 1 day"); // Emit the event emit SetMaturityGracePeriod(_maturityGracePeriod, maturityGracePeriod_); // set `_maturityGracePeriod` to new value _maturityGracePeriod = maturityGracePeriod_; } /// @notice Set the global liquidation incetive /// @param liquidationIncentive_ New liquidation incentive value function _setLiquidationIncentive(uint liquidationIncentive_) external onlyAdmin { // `_liquidationIncentive` needs to be greater than or equal to 1 require( liquidationIncentive_ >= MANTISSA_FACTORS(), "QAdmin: must be greater than or equal to 1" ); // Emit the event emit SetLiquidationIncentive(_liquidationIncentive, liquidationIncentive_); // Set `_liquidationIncentive` to new value _liquidationIncentive = liquidationIncentive_; } /// @notice Set the annualized protocol fees for each market in basis points /// @param market Address of the `FixedRateMarket` contract /// @param protocolFee_ New protocol fee value (scaled to 1e4) function _setProtocolFee(IFixedRateMarket market, uint protocolFee_) public onlyAdmin { // Max annual protocol fees of 250 basis points require(protocolFee_ <= 250, "QAdmin: must be less than 2.5%"); // Min annual protocol fees of 1 basis point require(protocolFee_ >= 1, "QAdmin: must be greater than .01%"); // Emit the event emit SetProtocolFee(_protocolFee[market], protocolFee_); // Set `_protocolFee` to new value _protocolFee[market] = protocolFee_; } /// @notice Set the global threshold in USD for protocol fee transfer /// @param thresholdUSD_ New threshold USD value (scaled by 1e6) function _setThresholdUSD(uint thresholdUSD_) external { _thresholdUSD = thresholdUSD_; } /** VIEW FUNCTIONS **/ /// @notice Get the address of the `QollateralManager` contract function qollateralManager() external view returns(address) { return address(_qollateralManager); } /// @notice Get the address of the `QPriceOracle` contract function qPriceOracle() external view returns(address) { if(address(_qollateralManager) != address(0)){ return _qollateralManager.qPriceOracle(); }else { return address(0); } } /// @notice Get the address of the `StakingEmissionsQontroller` contract function stakingEmissionsQontroller() external view returns(address) { return address(_stakingEmissionsQontroller); } /// @notice Get the address of the `TradingEmissionsQontroller` contract function tradingEmissionsQontroller() external view returns(address) { return address(_tradingEmissionsQontroller); } /// @notice Get the address of the `FeeEmissionsQontroller` contract function feeEmissionsQontroller() external view returns(address) { return address(_feeEmissionsQontroller); } /// @notice Get the address of the `veQoda` contract function veQoda() external view returns(address) { return address(_veQoda); } /// @notice Get the credit limit with associated address, scaled by 1e6 function creditLimit(address account_) external view returns(uint) { return _creditFacilityMap[account_].enabled? _creditFacilityMap[account_].creditLimit: UINT_MAX(); } /// @notice Gets the `Asset` mapped to the address of a ERC20 token /// @param token ERC20 token /// @return QTypes.Asset Associated `Asset` function assets(IERC20 token) external view returns(QTypes.Asset memory) { return _assets[token]; } /// @notice Get all enabled `Asset`s /// @return address[] iterable list of enabled `Asset`s function allAssets() external view returns(address[] memory) { return _allAssets; } /// @notice Gets the `CollateralFactor` associated with a ERC20 token /// @param token ERC20 token /// @return uint Collateral Factor, scaled by 1e8 function collateralFactor(IERC20 token) external view returns(uint) { return _assets[token].collateralFactor; } /// @notice Gets the `MarketFactor` associated with a ERC20 token /// @param token ERC20 token /// @return uint Market Factor, scaled by 1e8 function marketFactor(IERC20 token) external view returns(uint) { return _assets[token].marketFactor; } /// @notice Gets the `maturities` associated with a ERC20 token /// @param token ERC20 token /// @return uint[] array of UNIX timestamps (in seconds) of the maturity dates function maturities(IERC20 token) external view returns(uint[] memory) { return _assets[token].maturities; } /// @notice Get the MToken market corresponding to any underlying ERC20 /// tokenAddress => mTokenAddress function underlyingToMToken(IERC20 token) external view returns(address) { return _underlyingToMToken[token]; } /// @notice Gets the address of the `FixedRateMarket` contract /// @param token ERC20 token /// @param maturity UNIX timestamp of the maturity date /// @return IFixedRateMarket Address of `FixedRateMarket` contract function fixedRateMarkets( IERC20 token, uint maturity ) external view returns(IFixedRateMarket){ return _fixedRateMarkets[token][maturity]; } /// @notice Check whether an address is a valid FixedRateMarket address. /// Can be used for checks for inter-contract admin/restricted function call. /// @param market `FixedRateMarket` contract /// @return bool True if valid false otherwise function isMarketEnabled(IFixedRateMarket market) external view returns(bool){ return _enabledMarkets[market]; } function minQuoteSize(IFixedRateMarket market) external view returns(uint) { return _minQuoteSize[market]; } function minCollateralRatio() public view returns(uint){ return minCollateralRatio(msg.sender); } function minCollateralRatio(address account) public view returns(uint){ return _creditFacilityMap[account].enabled? _creditFacilityMap[account].minCollateralRatio: _minCollateralRatio; } function initCollateralRatio() public view returns(uint){ return initCollateralRatio(msg.sender); } function initCollateralRatio(address account) public view returns(uint){ return _creditFacilityMap[account].enabled? _creditFacilityMap[account].initCollateralRatio: _initCollateralRatio; } function closeFactor() public view returns(uint){ return _closeFactor; } function repaymentGracePeriod() public view returns(uint){ return _repaymentGracePeriod; } function maturityGracePeriod() public view returns(uint){ return _maturityGracePeriod; } function liquidationIncentive() public view returns(uint){ return _liquidationIncentive; } /// @notice Annualized protocol fee in basis points, scaled by 1e4 function protocolFee(IFixedRateMarket market) public view returns(uint){ return _protocolFee[market]; } /// @notice threshold in USD where protocol fee from each market will be transferred into `FeeEmissionsQontroller` /// once this amount is reached, scaled by 1e6 function thresholdUSD() external view returns(uint) { return _thresholdUSD; } /// @notice 2**256 - 1 function UINT_MAX() public pure returns(uint){ return type(uint).max; } /// @notice Generic mantissa corresponding to ETH decimals function MANTISSA_DEFAULT() public pure returns(uint){ return 1e18; } /// @notice Mantissa for USD function MANTISSA_USD() public pure returns(uint){ return 1e18; } /// @notice Mantissa for collateral ratio function MANTISSA_COLLATERAL_RATIO() public pure returns(uint){ return 1e8; } /// @notice `assetFactor` and `marketFactor` have up to 8 decimal places precision function MANTISSA_FACTORS() public pure returns(uint){ return 1e8; } /// @notice Basis points have 4 decimal place precision function MANTISSA_BPS() public pure returns(uint){ return 1e4; } /// @notice Staked Qoda has 6 decimal place precision function MANTISSA_STAKING() public pure returns(uint) { return 1e6; } /// @notice `collateralFactor` cannot be above 1.0 function MAX_COLLATERAL_FACTOR() public pure returns(uint){ return 1e8; } /// @notice `marketFactor` cannot be above 1.0 function MAX_MARKET_FACTOR() public pure returns(uint){ return 1e8; } /// @notice version number of this contract, will be bumped upon contractual change function VERSION_NUMBER() public pure returns(string memory){ return "0.2.3 "; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol) pragma solidity ^0.8.0; import "./IAccessControlEnumerableUpgradeable.sol"; import "./AccessControlUpgradeable.sol"; import "../utils/structs/EnumerableSetUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Extension of {AccessControl} that allows enumerating the members of each role. */ abstract contract AccessControlEnumerableUpgradeable is Initializable, IAccessControlEnumerableUpgradeable, AccessControlUpgradeable { function __AccessControlEnumerable_init() internal onlyInitializing { } function __AccessControlEnumerable_init_unchained() internal onlyInitializing { } using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet; mapping(bytes32 => EnumerableSetUpgradeable.AddressSet) private _roleMembers; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlEnumerableUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) { return _roleMembers[role].at(index); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) { return _roleMembers[role].length(); } /** * @dev Overload {_grantRole} to track enumerable memberships */ function _grantRole(bytes32 role, address account) internal virtual override { super._grantRole(role, account); _roleMembers[role].add(account); } /** * @dev Overload {_revokeRole} to track enumerable memberships */ function _revokeRole(bytes32 role, address account) internal virtual override { super._revokeRole(role, account); _roleMembers[role].remove(account); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ``` * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original * initialization step. This is essential to configure modules that are added through upgrades and that require * initialization. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized < type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
//SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.9; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IFixedRateMarket is IERC20Upgradeable, IERC20MetadataUpgradeable { /// @notice Emitted when a borrower repays borrow. /// Boolean flag `withQTokens`= true if repaid via qTokens, false otherwise. event RepayBorrow(address indexed borrower, uint amount, bool withQTokens); /// @notice Emitted when a borrower is liquidated event LiquidateBorrow( address indexed borrower, address indexed liquidator, uint amount, address collateralTokenAddress, uint reward ); /// @notice Emitted when a borrower and lender are matched for a fixed rate loan event FixedRateLoan( bytes32 indexed quoteId, address indexed borrower, address indexed lender, uint amountPV, uint amountFV, uint feeIncurred); /// @notice Emitted when an account cancels their Quote event CancelQuote(address indexed account, uint nonce); /// @notice Emitted when an account redeems their qTokens event RedeemQTokens(address indexed account, uint amount); /** USER INTERFACE **/ /// @notice Execute against Quote as a borrower. /// @param amountPV Amount that the borrower wants to execute as PV /// @param lender Account of the lender /// @param quoteType *Lender's* type preference, 0 for PV+APR, 1 for FV+APR /// @param quoteExpiryTime Timestamp after which the quote is no longer valid /// @param APR In decimal form scaled by 1e4 (ex. 10.52% = 1052) /// @param cashflow Can be PV or FV depending on `quoteType` /// @param nonce For uniqueness of signature /// @param signature signed hash of the Quote message /// @return uint, uint Loan amount (`amountPV`) and repayment amount (`amountFV`) function borrow( uint amountPV, address lender, uint8 quoteType, uint64 quoteExpiryTime, uint64 APR, uint cashflow, uint nonce, bytes memory signature ) external returns(uint, uint); /// @notice Execute against Quote as a lender. /// @param amountPV Amount that the lender wants to execute as PV /// @param borrower Account of the borrower /// @param quoteType *Borrower's* type preference, 0 for PV+APR, 1 for FV+APR /// @param quoteExpiryTime Timestamp after which the quote is no longer valid /// @param APR In decimal form scaled by 1e4 (ex. 10.52% = 1052) /// @param cashflow Can be PV or FV depending on `quoteType` /// @param nonce For uniqueness of signature /// @param signature signed hash of the Quote message /// @return uint, uint Loan amount (`amountPV`) and repayment amount (`amountFV`) function lend( uint amountPV, address borrower, uint8 quoteType, uint64 quoteExpiryTime, uint64 APR, uint cashflow, uint nonce, bytes memory signature ) external returns(uint, uint); /// @notice Borrower will make repayments to the smart contract, which /// holds the value in escrow until maturity to release to lenders. /// @param amount Amount to repay /// @return uint Remaining account borrow amount function repayBorrow(uint amount) external returns(uint); /// @notice By setting the nonce in `_voidNonces` to true, this is equivalent to /// invalidating the Quote (i.e. cancelling the quote) /// param nonce Nonce of the Quote to be cancelled function cancelQuote(uint nonce) external; /// @notice This function allows net lenders to redeem qTokens for the /// underlying token. Redemptions may only be permitted after loan maturity /// plus `_maturityGracePeriod`. The public interface redeems specified amount /// of qToken from existing balance. /// @param amount Amount of qTokens to redeem /// @return uint Amount of qTokens redeemed function redeemQTokensByRatio(uint amount) external returns(uint); /// @notice This function allows net lenders to redeem qTokens for the /// underlying token. Redemptions may only be permitted after loan maturity /// plus `_maturityGracePeriod`. The public interface redeems the entire qToken /// balance. /// @return uint Amount of qTokens redeemed function redeemAllQTokensByRatio() external returns(uint); /// @notice Get amount of qTokens user can redeem based on current loan repayment ratio /// @return uint amount of qTokens user can redeem function redeemableQTokens() external view returns(uint); /// @notice Get amount of qTokens user can redeem based on current loan repayment ratio /// @param account Account to query /// @return uint amount of qTokens user can redeem function redeemableQTokens(address account) external view returns(uint); /// @notice If an account is in danger of being undercollateralized (i.e. /// collateralRatio < 1.0) or has not repaid past maturity plus `_repaymentGracePeriod`, /// any user may liquidate that account by paying back the loan on behalf of the account. /// In return, the liquidator receives collateral belonging to the account equal in value to /// the repayment amount in USD plus the liquidation incentive amount as a bonus. /// @param borrower Address of account that is undercollateralized /// @param amount Amount to repay on behalf of account /// @param collateralToken Liquidator's choice of which currency to be paid in function liquidateBorrow( address borrower, uint amount, IERC20 collateralToken ) external; /** VIEW FUNCTIONS **/ /// @notice Get the address of the `QAdmin` contract /// @return address Address of `QAdmin` contract function qAdmin() external view returns(address); /// @notice Get the address of the `QollateralManager` /// @return address function qollateralManager() external view returns(address); /// @notice Get the address of the ERC20 token which the loan will be denominated /// @return IERC20 function underlyingToken() external view returns(IERC20); /// @notice Get the UNIX timestamp (in seconds) when the market matures /// @return uint function maturity() external view returns(uint); /// @notice Get the minimum quote size for this market /// @return uint Minimum quote size, in PV terms, local currency function minQuoteSize() external view returns(uint); /// @notice True if a nonce for a Quote is voided, false otherwise. /// Used for checking if a Quote is a duplicated. /// @param account Account to query /// @param nonce Nonce to query /// @return bool True if used, false otherwise function isNonceVoid(address account, uint nonce) external view returns(bool); /// @notice Get the total balance of borrows by user /// @param account Account to query /// @return uint Borrows function accountBorrows(address account) external view returns(uint); /// @notice Get the current total partial fill for a Quote /// @param quoteId ID of the Quote - this is the keccak256 hash of the signature /// @return uint Partial fill function quoteFill(bytes32 quoteId) external view returns(uint); /// @notice Get the `protocolFee` associated with this market /// @return uint annualized protocol fee, scaled by 1e4 function protocolFee() external view returns(uint); /// @notice Get the `protocolFee` associated with this market, prorated by time till maturity /// @param amount loan amount /// @param timeNow block timestamp for calculating time till maturity /// @return uint prorated protocol fee, scaled by 1e4 function proratedProtocolFee(uint amount, uint timeNow) external view returns(uint); /// @notice Get the `protocolFee` associated with this market, prorated by time till maturity from now /// @param amount loan amount /// @return uint prorated protocol fee, scaled by 1e4 function proratedProtocolFeeNow(uint amount) external view returns(uint); /// @notice Gets the current `redemptionRatio` where owned qTokens can be redeemed up to /// @return uint redemption ratio, capped and scaled by 1e18 function redemptionRatio() external view returns(uint); /// @notice Tokens redeemed across all users so far /// @return uint redeemed amount of qToken function tokensRedeemedTotal() external view returns(uint); /// @notice Get total protocol fee accrued in this market so far, in local currency /// @return uint accrued fee function totalAccruedFees() external view returns(uint); }
//SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.9; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "./IFixedRateMarket.sol"; interface IQollateralManager { /// @notice Emitted when an account deposits collateral into the contract event DepositCollateral(address indexed account, address tokenAddress, uint amount); /// @notice Emitted when an account withdraws collateral from the contract event WithdrawCollateral(address indexed account, address tokenAddress, uint amount); /// @notice Emitted when an account first interacts with the `Market` event AddAccountMarket(address indexed account, address indexed market); /// @notice Emitted when collateral is transferred from one account to another event TransferCollateral(address indexed tokenAddress, address indexed from, address indexed to, uint amount); /// @notice Constructor for upgradeable contracts /// @param qAdminAddress_ Address of the `QAdmin` contract /// @param qPriceOracleAddress_ Address of the `QPriceOracle` contract function initialize(address qAdminAddress_, address qPriceOracleAddress_) external; /** ADMIN/RESTRICTED FUNCTIONS **/ /// @notice Record when an account has either borrowed or lent into a /// `FixedRateMarket`. This is necessary because we need to iterate /// across all markets that an account has borrowed/lent to to calculate their /// `borrowValue`. Only the `FixedRateMarket` contract itself may call /// this function /// @param account User account /// @param market Address of the `FixedRateMarket` market function _addAccountMarket(address account, IFixedRateMarket market) external; /// @notice Transfer collateral balances from one account to another. Only /// `FixedRateMarket` contracts can call this restricted function. This is used /// for when a liquidator liquidates an account. /// @param token ERC20 token /// @param from Sender address /// @param to Recipient address /// @param amount Amount to transfer function _transferCollateral(IERC20 token, address from, address to, uint amount) external; /** USER INTERFACE **/ /// @notice Users call this to deposit collateral to fund their borrows /// @param token ERC20 token /// @param amount Amount to deposit (in local ccy) /// @return uint New collateral balance function depositCollateral(IERC20 token, uint amount) external returns(uint); /// @notice Users call this to deposit collateral to fund their borrows, where their /// collateral is automatically wrapped into MTokens for convenience so users can /// automatically earn interest on their collateral. /// @param underlying Underlying ERC20 token /// @param amount Amount to deposit (in underlying local currency) /// @return uint New collateral balance (in MToken balance) function depositCollateralWithMTokenWrap(IERC20 underlying, uint amount) external returns(uint); /// @notice Users call this to withdraw collateral /// @param token ERC20 token /// @param amount Amount to withdraw (in local ccy) /// @return uint New collateral balance function withdrawCollateral(IERC20 token, uint amount) external returns(uint); /// @notice Users call this to withdraw mToken collateral, where their /// collateral is automatically unwrapped into underlying tokens for /// convenience. /// @param mTokenAddress Yield-bearing token address /// @param amount Amount to withdraw (in mToken local currency) /// @return uint New collateral balance (in MToken balance) function withdrawCollateralWithMTokenUnwrap( address mTokenAddress, uint amount ) external returns(uint); /** VIEW FUNCTIONS **/ /// @notice Get the address of the `QAdmin` contract /// @return address Address of `QAdmin` contract function qAdmin() external view returns(address); /// @notice Get the address of the `QPriceOracle` contract /// @return address Address of `QPriceOracle` contract function qPriceOracle() external view returns(address); /// @notice Get all enabled `Asset`s /// @return address[] iterable list of enabled `Asset`s function allAssets() external view returns(address[] memory); /// @notice Gets the `CollateralFactor` associated with a ERC20 token /// @param token ERC20 token /// @return uint Collateral Factor, scaled by 1e8 function collateralFactor(IERC20 token) external view returns(uint); /// @notice Gets the `MarketFactor` associated with a ERC20 token /// @param token ERC20 token /// @return uint Market Factor, scaled by 1e8 function marketFactor(IERC20 token) external view returns(uint); /// @notice Return what the collateral ratio for an account would be /// with a hypothetical collateral withdraw/deposit and/or token borrow/lend. /// The collateral ratio is calculated as: /// (`virtualCollateralValue` / `virtualBorrowValue`) /// If the returned value falls below 1e8, the account can be liquidated /// @param account User account /// @param hypotheticalToken Currency of hypothetical withdraw / deposit /// @param withdrawAmount Amount of hypothetical withdraw in local currency /// @param depositAmount Amount of hypothetical deposit in local currency /// @param hypotheticalMarket Market of hypothetical borrow /// @param borrowAmount Amount of hypothetical borrow in local ccy /// @param lendAmount Amount of hypothetical lend in local ccy /// @return uint Hypothetical collateral ratio function hypotheticalCollateralRatio( address account, IERC20 hypotheticalToken, uint withdrawAmount, uint depositAmount, IFixedRateMarket hypotheticalMarket, uint borrowAmount, uint lendAmount ) external view returns(uint); /// @notice Return the current collateral ratio for an account. /// The collateral ratio is calculated as: /// (`virtualCollateralValue` / `virtualBorrowValue`) /// If the returned value falls below 1e8, the account can be liquidated /// @param account User account /// @return uint Collateral ratio function collateralRatio(address account) external view returns(uint); /// @notice Get the `collateralFactor` weighted value (in USD) of all the /// collateral deposited for an account /// @param account Account to query /// @return uint Total value of account in USD, scaled to 1e18 function virtualCollateralValue(address account) external view returns(uint); /// @notice Get the `collateralFactor` weighted value (in USD) for the tokens /// deposited for an account /// @param account Account to query /// @param token ERC20 token /// @return uint Value of token collateral of account in USD, scaled to 1e18 function virtualCollateralValueByToken( address account, IERC20 token ) external view returns(uint); /// @notice Get the `marketFactor` weighted net borrows (i.e. borrows - lends) /// in USD summed across all `Market`s participated in by the user /// @param account Account to query /// @return uint Borrow value of account in USD, scaled to 1e18 function virtualBorrowValue(address account) external view returns(uint); /// @notice Get the `marketFactor` weighted net borrows (i.e. borrows - lends) /// in USD for a particular `Market` /// @param account Account to query /// @param market `FixedRateMarket` contract /// @return uint Borrow value of account in USD, scaled to 1e18 function virtualBorrowValueByMarket( address account, IFixedRateMarket market ) external view returns(uint); /// @notice Return what the weighted total borrow value for an account would be with a hypothetical borrow /// @param account Account to query /// @param hypotheticalMarket Market of hypothetical borrow / lend /// @param borrowAmount Amount of hypothetical borrow in local ccy /// @param lendAmount Amount of hypothetical lend in local ccy /// @return uint Borrow value of account in USD, scaled to 1e18 function hypotheticalVirtualBorrowValue( address account, IFixedRateMarket hypotheticalMarket, uint borrowAmount, uint lendAmount ) external view returns(uint); /// @notice Get the unweighted value (in USD) of all the collateral deposited /// for an account /// @param account Account to query /// @return uint Total value of account in USD, scaled to 1e18 function realCollateralValue(address account) external view returns(uint); /// @notice Get the unweighted value (in USD) of the tokens deposited /// for an account /// @param account Account to query /// @param token ERC20 token /// @return uint Value of token collateral of account in USD, scaled to 1e18 function realCollateralValueByToken( address account, IERC20 token ) external view returns(uint); /// @notice Get the unweighted current net value borrowed (i.e. borrows - lends) /// in USD summed across all `Market`s participated in by the user /// @param account Account to query /// @return uint Borrow value of account in USD, scaled to 1e18 function realBorrowValue(address account) external view returns(uint); /// @notice Get the unweighted current net value borrowed (i.e. borrows - lends) /// in USD for a particular `Market` /// @param account Account to query /// @param market `FixedRateMarket` contract /// @return uint Borrow value of account in USD, scaled to 1e18 function realBorrowValueByMarket( address account, IFixedRateMarket market ) external view returns(uint); /// @notice Get an account's maximum available borrow amount in a specific FixedRateMarket. /// For example, what is the maximum amount of GLMRJUL22 that an account can borrow /// while ensuring their account health continues to be acceptable? /// Note: This function will return 0 if market to borrow is disabled /// Note: This function will return creditLimit() if maximum amount allowed for one market exceeds creditLimit() /// Note: User can only borrow up to `initCollateralRatio` for their own protection against instant liquidations /// @param account User account /// @param borrowMarket Address of the `FixedRateMarket` market to borrow /// @return uint Maximum available amount user can borrow (in FV) without breaching `initCollateralRatio` function hypotheticalMaxBorrowFV(address account, IFixedRateMarket borrowMarket) external view returns(uint); /// @notice Get the minimum collateral ratio. Scaled by 1e8. /// @return uint Minimum collateral ratio function minCollateralRatio() external view returns(uint); /// @notice Get the minimum collateral ratio for a user account. Scaled by 1e8. /// @param account User account /// @return uint Minimum collateral ratio function minCollateralRatio(address account) external view returns(uint); /// @notice Get the initial collateral ratio. Scaled by 1e8 /// @return uint Initial collateral ratio function initCollateralRatio() external view returns(uint); /// @notice Get the initial collateral ratio for a user account. Scaled by 1e8 /// @param account User account /// @return uint Initial collateral ratio function initCollateralRatio(address account) external view returns(uint); /// @notice Get the close factor. Scaled by 1e8 /// @return uint Close factor function closeFactor() external view returns(uint); /// @notice Get the liquidation incentive. Scaled by 1e8 /// @return uint Liquidation incentive function liquidationIncentive() external view returns(uint); /// @notice Use this for quick lookups of collateral balances by asset /// @param account User account /// @param token ERC20 token /// @return uint Balance in local function collateralBalance(address account, IERC20 token) external view returns(uint); /// @notice Get iterable list of collateral addresses which an account has nonzero balance. /// @param account User account /// @return address[] Iterable list of ERC20 token addresses function iterableCollateralAddresses(address account) external view returns(IERC20[] memory); /// @notice Quick lookup of whether an account has a particular collateral /// @param account User account /// @param token ERC20 token addresses /// @return bool True if account has collateralized with given ERC20 token, false otherwise function accountCollateral(address account, IERC20 token) external view returns(bool); /// @notice Get iterable list of all Markets which an account has participated /// @param account User account /// @return address[] Iterable list of `FixedRateLoanMarket` contract addresses function iterableAccountMarkets(address account) external view returns(IFixedRateMarket[] memory); /// @notice Quick lookup of whether an account has participated in a Market /// @param account User account /// @param market`FixedRateLoanMarket` contract /// @return bool True if participated, false otherwise function accountMarkets(address account, IFixedRateMarket market) external view returns(bool); /// @notice Converts any local value into its value in USD using oracle feed price /// @param token ERC20 token /// @param amountLocal Amount denominated in terms of the ERC20 token /// @return uint Amount in USD, scaled to 1e18 function localToUSD(IERC20 token, uint amountLocal) external view returns(uint); /// @notice Converts any value in USD into its value in local using oracle feed price /// @param token ERC20 token /// @param valueUSD Amount in USD /// @return uint Amount denominated in terms of the ERC20 token function USDToLocal(IERC20 token, uint valueUSD) external view returns(uint); }
//SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.9; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IFeeEmissionsQontroller { /// @notice Emitted when user claims emissions event ClaimEmissions(address account, uint amount); /// @notice Emitted when fee is accrued in a round event FeesAccrued(uint round, address token, uint amount, uint amountInRound); /// @notice Emitted when we move to a new round event NewFeeEmissionsRound(uint indexed currentPeriod, uint startBlock, uint endBlock); /** ACCESS CONTROLLED FUNCTIONS **/ function receiveFees(IERC20 underlyingToken, uint feeLocal) external; function veIncrease(address account, uint veIncreased) external; function veReset(address account) external; /** USER INTERFACE **/ function claimEmissions() external; function claimEmissions(address account) external; /** VIEW FUNCTIONS **/ function claimableEmissions(address account) external view returns(uint); function qAdmin() external view returns (address); function veToken() external view returns (address); function swapContract() external view returns (address); function WETH() external view returns (IERC20); function emissionsRound() external view returns (uint, uint, uint); function emissionsRound(uint round_) external view returns (uint, uint, uint); function blocksTillRoundEnd() external view returns (uint); function stakedVeAtRound(address account, uint round) external view returns (uint); function roundInterval() external view returns (uint); function currentRound() external view returns (uint); function lastClaimedRound() external view returns (uint); function lastClaimedRound(address account) external view returns (uint); function lastClaimedVeBalance() external view returns (uint); function lastClaimedVeBalance(address account) external view returns (uint); function totalFeesAccrued() external view returns (uint); function totalFeesClaimed() external view returns (uint); }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.9; interface IStakingEmissionsQontroller { /** EVENTS **/ /// @notice Emitted when we move to a new emissions regime event NewEmissionsPerBlock(uint indexed currentPeriod, uint startBlock, uint emissions, uint numBlocks); /// @notice Emitted when user claims emissions event ClaimEmissions(address indexed account, uint emission); /// @notice Emitted when user deposits event Deposit(address indexed account, uint amount); /// @notice Emitted when user withdraws event Withdraw(address indexed account, uint amount); /** ACCESS CONTROLLED FUNCTIONS **/ /// @notice Credits the account with the given amount in `StakingEmissionsQontroller` /// This function should only be called by the veToken contract when the user /// claims their accrued veTokens. /// @param account Address of the user /// @param amount Amount to credit the account function deposit(address account, uint amount) external; /// @notice Cancels account's full amount and debt from `StakingEmissionsQontroller` /// and claims any remaining emissions for that account. This should only /// be called by the veToken contract when the user unstakes the underlying /// @param account Address of the user. function withdraw(address account) external; /// @notice Function to start reward distribution, can only be invoked once. /// @param startBlock starting block for reward distribution, 0 for current block function _startStaking(uint startBlock) external; /** USER INTERFACE **/ /// @notice Transfer accrued emissions from `StakingEmissionsQontroller` to veToken holder /// This function can be called by the user anytime and as often as they wish. function claimEmissions() external; /// @notice Update emissions variables of the pool function updatePool() external; /** VIEW FUNCTIONS **/ /// @notice Calculates the amount of emissions claimable by a user by updating /// the pool info in memory without writing to storage so that viewing the /// claimable amount does not incur gas costs. /// @param account Address of the user /// @return uint Amount claimable function claimableEmissions(address account) external view returns(uint); /// @notice Get the address of the `QAdmin` contract /// @return address Address of `QAdmin` contract function qAdmin() external view returns(address); /// @notice Get the address of the `QodaERC20` contract /// @return address Address of `QodaERC20` contract function qodaERC20() external view returns(address); /// @notice Get the address of the `veQoda` contract /// @return address Address of `veQoda` contract function veToken() external view returns(address); function numPeriods() external view returns(uint); function accTokenPerShare() external view returns(uint); function currentPeriod() external view returns(uint); function endBlock() external view returns(uint); function lastEmissionsBlock() external view returns(uint); function emissions() external view returns(uint); function numBlocks() external view returns(uint); // @return emissions per block, scaled by 1e6 function emissionsPerBlock() external view returns(uint); function userInfo(address account) external view returns(uint, uint); function stakingPeriod(uint i) external view returns(uint, uint); }
//SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.9; interface ITradingEmissionsQontroller { /** ACCESS CONTROLLED FUNCTIONS **/ /// @notice Use the fees generated (in USD) as basis to calculate how much /// token reward to disburse for trading volumes. Only `FixedRateMarket` /// contracts may call this function. /// @param borrower Address of the borrower /// @param lender Address of the lender /// @param feeUSD Fees generated (in USD, scaled to 1e18) function updateRewards(address borrower, address lender, uint feeUSD) external; /** USER INTERFACE **/ /// @notice Mint the unclaimed rewards to user and reset their claimable emissions function claimEmissions() external; /** VIEW FUNCTIONS **/ /// @notice Checks the amount of unclaimed trading rewards that the user can claim /// @param account Address of the user /// @return uint Amount of QODA token rewards the user may claim function claimableEmissions(address account) external view returns(uint); /// @notice Get the address of the `QAdmin` contract /// @return address Address of `QAdmin` contract function qAdmin() external view returns(address); /// @notice Get the address of the `QodaERC20` contract /// @return address Address of `QodaERC20` contract function qodaERC20() external view returns(address); function numPhases() external view returns(uint); function currentPhase() external view returns(uint); function totalAllocation() external view returns(uint); function emissionsPhase(uint phase) external view returns(uint, uint, uint); }
//SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.9; import "@openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "./IFixedRateMarket.sol"; import "../libraries/QTypes.sol"; interface IQAdmin is IAccessControlUpgradeable { /// @notice Emitted when a new FixedRateMarket is deployed event CreateFixedRateMarket(address indexed marketAddress, address indexed tokenAddress, uint maturity); /// @notice Emitted when a new `Asset` is added event AddAsset( address indexed tokenAddress, bool isYieldBearing, address oracleFeed, uint collateralFactor, uint marketFactor); /// @notice Emitted when setting `_qollateralManager` event SetQollateralManager(address qollateralManagerAddress); /// @notice Emitted when setting `_stakingEmissionsQontroller` event SetStakingEmissionsQontroller(address stakingEmissionsQontrollerAddress); /// @notice Emitted when setting `_tradingEmissionsQontroller` event SetTradingEmissionsQontroller(address tradingEmissionsQontrollerAddress); /// @notice Emitted when setting `_feeEmissionsQontroller` event SetFeeEmissionsQontroller(address feeEmissionsQontrollerAddress); /// @notice Emitted when setting `_veQoda` event SetVeQoda(address veQodaAddress); /// @notice Emitted when setting `collateralFactor` event SetCollateralFactor(address indexed tokenAddress, uint oldValue, uint newValue); /// @notice Emitted when setting `marketFactor` event SetMarketFactor(address indexed tokenAddress, uint oldValue, uint newValue); /// @notice Emitted when setting `minQuoteSize` event SetMinQuoteSize(address indexed tokenAddress, uint oldValue, uint newValue); /// @notice Emitted when `_minCollateralRatioDefault` and `_initCollateralRatioDefault` get updated event SetCollateralRatio(uint oldMinValue, uint oldInitValue, uint newMinValue, uint newInitValue); /// @notice Emitted when `CreditFacility` gets updated event SetCreditFacility(address account, bool oldEnabled, uint oldMinValue, uint oldInitValue, uint oldCreditValue, bool newEnabled, uint newMinValue, uint newInitValue, uint newCreditValue); /// @notice Emitted when `_closeFactor` gets updated event SetCloseFactor(uint oldValue, uint newValue); /// @notice Emitted when `_repaymentGracePeriod` gets updated event SetRepaymentGracePeriod(uint oldValue, uint newValue); /// @notice Emitted when `_maturityGracePeriod` gets updated event SetMaturityGracePeriod(uint oldValue, uint newValue); /// @notice Emitted when `_liquidationIncentive` gets updated event SetLiquidationIncentive(uint oldValue, uint newValue); /// @notice Emitted when `_protocolFee` gets updated event SetProtocolFee(uint oldValue, uint newValue); /** ADMIN FUNCTIONS **/ /// @notice Call upon initialization after deploying `QollateralManager` contract /// @param qollateralManagerAddress Address of `QollateralManager` deployment function _setQollateralManager(address qollateralManagerAddress) external; /// @notice Call upon initialization after deploying `StakingEmissionsQontroller` contract /// @param stakingEmissionsQontrollerAddress Address of `StakingEmissionsQontroller` deployment function _setStakingEmissionsQontroller(address stakingEmissionsQontrollerAddress) external; /// @notice Call upon initialization after deploying `TradingEmissionsQontroller` contract /// @param tradingEmissionsQontrollerAddress Address of `TradingEmissionsQontroller` deployment function _setTradingEmissionsQontroller(address tradingEmissionsQontrollerAddress) external; /// @notice Call upon initialization after deploying `FeeEmissionsQontroller` contract /// @param feeEmissionsQontrollerAddress Address of `FeeEmissionsQontroller` deployment function _setFeeEmissionsQontroller(address feeEmissionsQontrollerAddress) external; /// @notice Call upon initialization after deploying `veQoda` contract /// @param veQodaAddress Address of `veQoda` deployment function _setVeQoda(address veQodaAddress) external; /// @notice Set credit facility for specified account /// @param account_ account for credit facility adjustment /// @param enabled_ If credit facility should be enabled /// @param minCollateralRatio_ New minimum collateral ratio value /// @param initCollateralRatio_ New initial collateral ratio value /// @param creditLimit_ new credit limit in USD, scaled by 1e18 function _setCreditFacility(address account_, bool enabled_, uint minCollateralRatio_, uint initCollateralRatio_, uint creditLimit_) external; /// @notice Admin function for adding new Assets. An Asset must be added before it /// can be used as collateral or borrowed. Note: We can create functionality for /// allowing borrows of a token but not using it as collateral by setting /// `collateralFactor` to zero. /// @param token ERC20 token corresponding to the Asset /// @param isYieldBearing True if token bears interest (eg aToken, cToken, mToken, etc) /// @param underlying Address of the underlying token /// @param oracleFeed Chainlink price feed address /// @param collateralFactor 0.0 to 1.0 (scaled to 1e8) for discounting risky assets /// @param marketFactor 0.0 to 1.0 (scaled to 1e8) for premium on risky borrows function _addAsset( IERC20 token, bool isYieldBearing, address underlying, address oracleFeed, uint collateralFactor, uint marketFactor ) external; /// @notice Adds a new `FixedRateMarket` contract into the internal mapping of /// whitelisted market addresses /// @param market New `FixedRateMarket` contract address /// @param protocolFee_ Corresponding protocol fee in basis points /// @param minQuoteSize_ Size in PV terms, local currency function _addFixedRateMarket( IFixedRateMarket market, uint protocolFee_, uint minQuoteSize_ ) external; /// @notice Update the `collateralFactor` for a given `Asset` /// @param token ERC20 token corresponding to the Asset /// @param collateralFactor 0.0 to 1.0 (scaled to 1e8) for discounting risky assets function _setCollateralFactor(IERC20 token, uint collateralFactor) external; /// @notice Update the `marketFactor` for a given `Asset` /// @param token Address of the token corresponding to the Asset /// @param marketFactor 0.0 to 1.0 (scaled to 1e8) for discounting risky assets function _setMarketFactor(IERC20 token, uint marketFactor) external; /// @notice Set the minimum quote size for a particular `FixedRateMarket` /// @param market Address of the `FixedRateMarket` contract /// @param minQuoteSize_ Size in PV terms, local currency function _setMinQuoteSize(IFixedRateMarket market, uint minQuoteSize_) external; /// @notice Set the global minimum and initial collateral ratio /// @param minCollateralRatio_ New global minimum collateral ratio value /// @param initCollateralRatio_ New global initial collateral ratio value function _setCollateralRatio(uint minCollateralRatio_, uint initCollateralRatio_) external; /// @notice Set the global close factor /// @param closeFactor_ New close factor value function _setCloseFactor(uint closeFactor_) external; /// @notice Set the global repayment grace period /// @param repaymentGracePeriod_ New repayment grace period function _setRepaymentGracePeriod(uint repaymentGracePeriod_) external; /// @notice Set the global maturity grace period /// @param maturityGracePeriod_ New maturity grace period function _setMaturityGracePeriod(uint maturityGracePeriod_) external; /// @notice Set the global liquidation incetive /// @param liquidationIncentive_ New liquidation incentive value function _setLiquidationIncentive(uint liquidationIncentive_) external; /// @notice Set the global annualized protocol fees for each market in basis points /// @param market Address of the `FixedRateMarket` contract /// @param protocolFee_ New protocol fee value (scaled to 1e4) function _setProtocolFee(IFixedRateMarket market, uint protocolFee_) external; /// @notice Set the global threshold in USD for protocol fee transfer /// @param thresholdUSD_ New threshold USD value (scaled by 1e6) function _setThresholdUSD(uint thresholdUSD_) external; /** VIEW FUNCTIONS **/ function ADMIN_ROLE() external view returns(bytes32); function MARKET_ROLE() external view returns(bytes32); function MINTER_ROLE() external view returns(bytes32); function VETOKEN_ROLE() external view returns(bytes32); /// @notice Get the address of the `QollateralManager` contract function qollateralManager() external view returns(address); /// @notice Get the address of the `QPriceOracle` contract function qPriceOracle() external view returns(address); /// @notice Get the address of the `StakingEmissionsQontroller` contract function stakingEmissionsQontroller() external view returns(address); /// @notice Get the address of the `TradingEmissionsQontroller` contract function tradingEmissionsQontroller() external view returns(address); /// @notice Get the address of the `FeeEmissionsQontroller` contract function feeEmissionsQontroller() external view returns(address); /// @notice Get the address of the `veQoda` contract function veQoda() external view returns(address); /// @notice Get the credit limit with associated address, scaled by 1e18 function creditLimit(address account_) external view returns(uint); /// @notice Gets the `Asset` mapped to the address of a ERC20 token /// @param token ERC20 token /// @return QTypes.Asset Associated `Asset` function assets(IERC20 token) external view returns(QTypes.Asset memory); /// @notice Get all enabled `Asset`s /// @return address[] iterable list of enabled `Asset`s function allAssets() external view returns(address[] memory); /// @notice Gets the `CollateralFactor` associated with a ERC20 token /// @param token ERC20 token /// @return uint Collateral Factor, scaled by 1e8 function collateralFactor(IERC20 token) external view returns(uint); /// @notice Gets the `MarketFactor` associated with a ERC20 token /// @param token ERC20 token /// @return uint Market Factor, scaled by 1e8 function marketFactor(IERC20 token) external view returns(uint); /// @notice Gets the `maturities` associated with a ERC20 token /// @param token ERC20 token /// @return uint[] array of UNIX timestamps (in seconds) of the maturity dates function maturities(IERC20 token) external view returns(uint[] memory); /// @notice Get the MToken market corresponding to any underlying ERC20 /// tokenAddress => mTokenAddress function underlyingToMToken(IERC20 token) external view returns(address); /// @notice Gets the address of the `FixedRateMarket` contract /// @param token ERC20 token /// @param maturity UNIX timestamp of the maturity date /// @return IFixedRateMarket Address of `FixedRateMarket` contract function fixedRateMarkets(IERC20 token, uint maturity) external view returns(IFixedRateMarket); /// @notice Check whether an address is a valid FixedRateMarket address. /// Can be used for checks for inter-contract admin/restricted function call. /// @param market `FixedRateMarket` contract /// @return bool True if valid false otherwise function isMarketEnabled(IFixedRateMarket market) external view returns(bool); function minQuoteSize(IFixedRateMarket market) external view returns(uint); function minCollateralRatio() external view returns(uint); function minCollateralRatio(address account) external view returns(uint); function initCollateralRatio() external view returns(uint); function initCollateralRatio(address account) external view returns(uint); function closeFactor() external view returns(uint); function repaymentGracePeriod() external view returns(uint); function maturityGracePeriod() external view returns(uint); function liquidationIncentive() external view returns(uint); /// @notice Annualized protocol fee in basis points, scaled by 1e4 function protocolFee(IFixedRateMarket market) external view returns(uint); /// @notice threshold in USD where protocol fee from each market will be transferred into `FeeEmissionsQontroller` /// once this amount is reached, scaled by 1e6 function thresholdUSD() external view returns(uint); /// @notice 2**256 - 1 function UINT_MAX() external pure returns(uint); /// @notice Generic mantissa corresponding to ETH decimals function MANTISSA_DEFAULT() external pure returns(uint); /// @notice Mantissa for USD function MANTISSA_USD() external pure returns(uint); /// @notice Mantissa for collateral ratio function MANTISSA_COLLATERAL_RATIO() external pure returns(uint); /// @notice `assetFactor` and `marketFactor` have up to 8 decimal places precision function MANTISSA_FACTORS() external pure returns(uint); /// @notice Basis points have 4 decimal place precision function MANTISSA_BPS() external pure returns(uint); /// @notice Staked Qoda has 6 decimal place precision function MANTISSA_STAKING() external pure returns(uint); /// @notice `collateralFactor` cannot be above 1.0 function MAX_COLLATERAL_FACTOR() external pure returns(uint); /// @notice `marketFactor` cannot be above 1.0 function MAX_MARKET_FACTOR() external pure returns(uint); /// @notice version number of this contract, will be bumped upon contractual change function VERSION_NUMBER() external pure returns(string memory); }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.9; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IVeQoda is IERC20 { /** EVENTS **/ /// @notice Emitted when user stakes underlying QODA event Stake(address indexed account, uint amount); /// @notice Emitted when user unstakes underlying QODA event Unstake(address indexed account, uint amount); /// @notice Emitted when user claims veToken event Claim(address indexed account, uint amount); /** USER INTERFACE **/ /// @notice Stake underlying into contract /// @param amount Amount of underlying to stake function stake(uint256 amount) external; /// @notice Unstake underlying tokens /// NOTE: You will lose ALL your veToken if you unstake ANY amount of underlying tokens /// @param amount Amount of underlying tokens to unstake function unstake(uint amount) external; /// @notice Claims accumulated veToken function claimVeToken() external; /** VIEW FUNCTIONS **/ /// @notice checks whether user has underlying staked /// @param account The user address to check /// @return true if the user has underlying in stake, false otherwise function hasStaked(address account) external view returns (bool); /// @notice Calculate the amount of veToken that can be claimed by user /// @param account Address to check /// @return uint Amount of veToken that can be claimed by user function claimableVeToken(address account) external view returns(uint); /// @notice Returns the underlying amount of underlying staked by the user /// @param account User address to check /// @return uint Amount of staked underlying underlying function getStakedAmount(address account) external view returns(uint); function qodaERC20() external view returns(address); function stakingEmissionsQontroller() external view returns(address); function feeEmissionsQontroller() external view returns(address); function veTokenPerBlock() external view returns(uint); function maxVeToken() external view returns(uint); }
//SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.9; library QTypes { /// @notice Contains all the details of an Asset. Assets must be defined /// before they can be used as collateral. /// @member isEnabled True if an asset is defined, false otherwise /// @member isYieldBearing True if token bears interest (eg aToken, cToken, mToken, etc) /// @member underlying Address of the underlying token /// @member oracleFeed Address of the corresponding chainlink oracle feed /// @member collateralFactor 0.0 to 1.0 (scaled to 1e8) for discounting risky assets /// @member marketFactor 0.0 1.0 for premium on risky borrows /// @member maturities Iterable storage for all enabled maturities struct Asset { bool isEnabled; bool isYieldBearing; address underlying; address oracleFeed; uint collateralFactor; uint marketFactor; uint[] maturities; } /// @notice Contains all the fields of a published Quote /// @notice quoteId ID of the quote - this is the keccak256 hash of signature /// @param marketAddress Address of `FixedRateLoanMarket` contract /// @param quoter Account of the Quoter /// @param quoteType 0 for PV+APR, 1 for FV+APR /// @param side 0 if Quoter is borrowing, 1 if Quoter is lending /// @param quoteExpiryTime Timestamp after which the quote is no longer valid /// @param APR In decimal form scaled by 1e4 (ex. 10.52% = 1052) /// @param cashflow Can be PV or FV depending on `quoteType` /// @param nonce For uniqueness of signature /// @param signature Signed hash of the Quote message struct Quote { bytes32 quoteId; address marketAddress; address quoter; uint8 quoteType; uint8 side; uint64 quoteExpiryTime; //if 0, then quote never expires uint64 APR; uint cashflow; uint nonce; bytes signature; } /// @notice Contains all the configurations customizable to an address /// @member enabled If config for an address is enabled. When enabled is false, credit limit is infinite even if value is 0 /// @member minCollateralRatio If collateral ratio falls below `_minCollateralRatio`, it is subject to liquidation. Scaled by 1e8 /// @member initCollateralRatio When initially taking a loan, collateral ratio must be higher than this. `initCollateralRatio` should always be higher than `minCollateralRatio`. Scaled by 1e8 /// @member creditLimit Allowed limit in virtual USD for each address to do uncollateralized borrow, scaled by 1e18 struct CreditFacility { bool enabled; uint minCollateralRatio; uint initCollateralRatio; uint creditLimit; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol) pragma solidity ^0.8.0; import "./IAccessControlUpgradeable.sol"; /** * @dev External interface of AccessControlEnumerable declared to support ERC165 detection. */ interface IAccessControlEnumerableUpgradeable is IAccessControlUpgradeable { /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) external view returns (address); /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControlUpgradeable.sol"; import "../utils/ContextUpgradeable.sol"; import "../utils/StringsUpgradeable.sol"; import "../utils/introspection/ERC165Upgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable { function __AccessControl_init() internal onlyInitializing { } function __AccessControl_init_unchained() internal onlyInitializing { } struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", StringsUpgradeable.toHexString(uint160(account), 20), " is missing role ", StringsUpgradeable.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * May emit a {RoleGranted} event. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol) pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an array of EnumerableSet. * ==== */ library EnumerableSetUpgradeable { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastValue; // Update the index for the moved value set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { return _values(set._inner); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControlUpgradeable { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal onlyInitializing { } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20MetadataUpgradeable is IERC20Upgradeable { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":false,"internalType":"bool","name":"isYieldBearing","type":"bool"},{"indexed":false,"internalType":"address","name":"oracleFeed","type":"address"},{"indexed":false,"internalType":"uint256","name":"collateralFactor","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"marketFactor","type":"uint256"}],"name":"AddAsset","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"marketAddress","type":"address"},{"indexed":true,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"maturity","type":"uint256"}],"name":"CreateFixedRateMarket","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newValue","type":"uint256"}],"name":"SetCloseFactor","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"oldValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newValue","type":"uint256"}],"name":"SetCollateralFactor","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldMinValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"oldInitValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newMinValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newInitValue","type":"uint256"}],"name":"SetCollateralRatio","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"oldEnabled","type":"bool"},{"indexed":false,"internalType":"uint256","name":"oldMinValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"oldInitValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"oldCreditValue","type":"uint256"},{"indexed":false,"internalType":"bool","name":"newEnabled","type":"bool"},{"indexed":false,"internalType":"uint256","name":"newMinValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newInitValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newCreditValue","type":"uint256"}],"name":"SetCreditFacility","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"feeEmissionsQontrollerAddress","type":"address"}],"name":"SetFeeEmissionsQontroller","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newValue","type":"uint256"}],"name":"SetLiquidationIncentive","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"oldValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newValue","type":"uint256"}],"name":"SetMarketFactor","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newValue","type":"uint256"}],"name":"SetMaturityGracePeriod","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"oldValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newValue","type":"uint256"}],"name":"SetMinQuoteSize","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newValue","type":"uint256"}],"name":"SetProtocolFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"qollateralManagerAddress","type":"address"}],"name":"SetQollateralManager","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newValue","type":"uint256"}],"name":"SetRepaymentGracePeriod","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"stakingEmissionsQontrollerAddress","type":"address"}],"name":"SetStakingEmissionsQontroller","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"tradingEmissionsQontrollerAddress","type":"address"}],"name":"SetTradingEmissionsQontroller","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"veQodaAddress","type":"address"}],"name":"SetVeQoda","type":"event"},{"inputs":[],"name":"ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MANTISSA_BPS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"MANTISSA_COLLATERAL_RATIO","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"MANTISSA_DEFAULT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"MANTISSA_FACTORS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"MANTISSA_STAKING","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"MANTISSA_USD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"MARKET_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_COLLATERAL_FACTOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"MAX_MARKET_FACTOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"MINTER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UINT_MAX","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"VERSION_NUMBER","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"VETOKEN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"bool","name":"isYieldBearing","type":"bool"},{"internalType":"address","name":"underlying","type":"address"},{"internalType":"address","name":"oracleFeed","type":"address"},{"internalType":"uint256","name":"collateralFactor_","type":"uint256"},{"internalType":"uint256","name":"marketFactor_","type":"uint256"}],"name":"_addAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IFixedRateMarket","name":"market","type":"address"},{"internalType":"uint256","name":"protocolFee_","type":"uint256"},{"internalType":"uint256","name":"minQuoteSize_","type":"uint256"}],"name":"_addFixedRateMarket","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"closeFactor_","type":"uint256"}],"name":"_setCloseFactor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"uint256","name":"collateralFactor_","type":"uint256"}],"name":"_setCollateralFactor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"minCollateralRatio_","type":"uint256"},{"internalType":"uint256","name":"initCollateralRatio_","type":"uint256"}],"name":"_setCollateralRatio","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account_","type":"address"},{"internalType":"bool","name":"enabled_","type":"bool"},{"internalType":"uint256","name":"minCollateralRatio_","type":"uint256"},{"internalType":"uint256","name":"initCollateralRatio_","type":"uint256"},{"internalType":"uint256","name":"creditLimit_","type":"uint256"}],"name":"_setCreditFacility","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"feeEmissionsQontrollerAddress","type":"address"}],"name":"_setFeeEmissionsQontroller","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"liquidationIncentive_","type":"uint256"}],"name":"_setLiquidationIncentive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"uint256","name":"marketFactor_","type":"uint256"}],"name":"_setMarketFactor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"maturityGracePeriod_","type":"uint256"}],"name":"_setMaturityGracePeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IFixedRateMarket","name":"market","type":"address"},{"internalType":"uint256","name":"minQuoteSize_","type":"uint256"}],"name":"_setMinQuoteSize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IFixedRateMarket","name":"market","type":"address"},{"internalType":"uint256","name":"protocolFee_","type":"uint256"}],"name":"_setProtocolFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"qollateralManagerAddress","type":"address"}],"name":"_setQollateralManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"repaymentGracePeriod_","type":"uint256"}],"name":"_setRepaymentGracePeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"stakingEmissionsQontrollerAddress","type":"address"}],"name":"_setStakingEmissionsQontroller","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"thresholdUSD_","type":"uint256"}],"name":"_setThresholdUSD","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tradingEmissionsQontrollerAddress","type":"address"}],"name":"_setTradingEmissionsQontroller","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"veQodaAddress","type":"address"}],"name":"_setVeQoda","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"allAssets","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"}],"name":"assets","outputs":[{"components":[{"internalType":"bool","name":"isEnabled","type":"bool"},{"internalType":"bool","name":"isYieldBearing","type":"bool"},{"internalType":"address","name":"underlying","type":"address"},{"internalType":"address","name":"oracleFeed","type":"address"},{"internalType":"uint256","name":"collateralFactor","type":"uint256"},{"internalType":"uint256","name":"marketFactor","type":"uint256"},{"internalType":"uint256[]","name":"maturities","type":"uint256[]"}],"internalType":"struct QTypes.Asset","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"closeFactor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"}],"name":"collateralFactor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account_","type":"address"}],"name":"creditLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeEmissionsQontroller","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"uint256","name":"maturity","type":"uint256"}],"name":"fixedRateMarkets","outputs":[{"internalType":"contract IFixedRateMarket","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"initCollateralRatio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"initCollateralRatio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"admin","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IFixedRateMarket","name":"market","type":"address"}],"name":"isMarketEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"liquidationIncentive","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"}],"name":"marketFactor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"}],"name":"maturities","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maturityGracePeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"minCollateralRatio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minCollateralRatio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IFixedRateMarket","name":"market","type":"address"}],"name":"minQuoteSize","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IFixedRateMarket","name":"market","type":"address"}],"name":"protocolFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"qPriceOracle","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"qollateralManager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"repaymentGracePeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stakingEmissionsQontroller","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"thresholdUSD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tradingEmissionsQontroller","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"}],"name":"underlyingToMToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"veQoda","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b506130f6806100206000396000f3fe608060405234801561001057600080fd5b50600436106103fb5760003560e01c80637c813c5a11610215578063b683795611610125578063d0e9ae42116100b8578063e26a28a711610087578063e26a28a714610568578063e4028eee146108fc578063ea8aebe21461090f578063f11b818814610920578063fbcc6f5e1461094057600080fd5b8063d0e9ae42146108af578063d5391393146108c2578063d547741f146108e9578063de01c9cb1461056857600080fd5b8063c0654f58116100f4578063c0654f581461086e578063c4d66de814610881578063c8b82f5b14610894578063ca15c8731461089c57600080fd5b8063b683795614610816578063b8f3ece114610829578063bb6b027614610831578063bc9574ad1461084257600080fd5b806396bd2278116101a8578063a0ee956011610177578063a0ee9560146107b7578063a117468e146107bf578063a217fddf146107d2578063aac4c005146107da578063b62b31e4146107ed57600080fd5b806396bd227814610778578063982a08721461078b57806399189bc1146107935780639c4d1ff7146107a457600080fd5b80638b2f81d6116101e45780638b2f81d6146105685780638c765e941461074a5780639010d07c1461075257806391d148541461076557600080fd5b80637c813c5a146106f45780637d2cdd17146107075780638025e3031461071a57806384da26661461074257600080fd5b80632f2ff15d116103105780636607250b116102a35780637620647711610272578063762064771461068757806376d708d7146106b3578063782d2b53146106c8578063791db024146106d057806379ff7546146106e157600080fd5b80636607250b14610635578063751a425314610655578063753d0a901461065d57806375b238fc1461067257600080fd5b806349d649ea116102df57806349d649ea146105c85780634fd42e17146105fe57806358dd3d34146106115780635f2ead681461062457600080fd5b80632f2ff15d1461057a578063317b0b771461058d57806336568abe146105a05780633e27ec9b146105b357600080fd5b806308bfc403116103935780631f429f50116103625780631f429f501461051f578063248a9ca31461053257806328621949146105555780632d114020146105685780632d8dea9c1461057257600080fd5b806308bfc403146104ba5780630df09d25146104cd5780630f13f9b3146104cd5780631f3dda36146104db57600080fd5b806305308b9f116103cf57806305308b9f14610479578063054ebc2414610481578063072557e21461049457806307711ea6146104a757600080fd5b8062c63ad21461040057806301ffc9a7146104185780630209fd9c1461043b5780630525927a14610464575b600080fd5b620f42405b6040519081526020015b60405180910390f35b61042b610426366004612a93565b61096c565b604051901515815260200161040f565b610405610449366004612ad2565b6001600160a01b0316600090815260db602052604090205490565b610477610472366004612aef565b610997565b005b60d154610405565b61047761048f366004612ad2565b610aef565b6104056104a2366004612ad2565b610b78565b6104776104b5366004612aef565b610bbf565b6104776104c8366004612b1b565b60d555565b670de0b6b3a7640000610405565b6105076104e9366004612ad2565b6001600160a01b03908116600090815260d960205260409020541690565b6040516001600160a01b03909116815260200161040f565b61040561052d366004612ad2565b610d0b565b610405610540366004612b1b565b60009081526065602052604090206001015490565b610477610563366004612b49565b610d52565b6305f5e100610405565b612710610405565b610477610588366004612bb5565b61108b565b61047761059b366004612b1b565b6110b5565b6104776105ae366004612bb5565b61117e565b6104056000805160206130a183398151915281565b6105076105d6366004612aef565b6001600160a01b03918216600090815260d86020908152604080832093835292905220541690565b61047761060c366004612b1b565b6111fc565b61047761061f366004612be5565b6112d8565b60c9546001600160a01b0316610507565b610648610643366004612ad2565b611385565b60405161040f9190612c07565b60d554610405565b61040560008051602061306183398151915281565b61040560008051602061308183398151915281565b610405610695366004612ad2565b6001600160a01b0316600090815260d7602052604090206003015490565b6106bb6113f4565b60405161040f9190612c4b565b600019610405565b60cc546001600160a01b0316610507565b6104776106ef366004612ad2565b611456565b610477610702366004612ad2565b6114d8565b610477610715366004612c8c565b61155a565b604080518082018252600681526501817191719960d51b6020820152905161040f9190612d0b565b610405611686565b60d454610405565b610507610760366004612be5565b611696565b61042b610773366004612bb5565b6116b5565b610477610786366004612b1b565b6116e0565b60d254610405565b60ca546001600160a01b0316610507565b6104056107b2366004612ad2565b6117a8565b6105076117ef565b6104776107cd366004612ad2565b611880565b610405600081565b6104776107e8366004612ad2565b611902565b6104056107fb366004612ad2565b6001600160a01b0316600090815260d6602052604090205490565b610477610824366004612b1b565b6119a2565b610405611a6a565b60cb546001600160a01b0316610507565b61042b610850366004612ad2565b6001600160a01b0316600090815260da602052604090205460ff1690565b61047761087c366004612d3e565b611a75565b61047761088f366004612ad2565b611d95565b60d354610405565b6104056108aa366004612b1b565b611fdd565b6104776108bd366004612aef565b611ff4565b6104057ff0887ba65ee2024ea881d91b74c2450ef19e1557f03bed3ea9f16b037cbe2dc981565b6104776108f7366004612bb5565b6121f4565b61047761090a366004612aef565b612219565b60cd546001600160a01b0316610507565b61093361092e366004612ad2565b612335565b60405161040f9190612d73565b61040561094e366004612ad2565b6001600160a01b0316600090815260d7602052604090206002015490565b60006001600160e01b03198216635a05180f60e01b1480610991575061099182612452565b92915050565b6109af600080516020613081833981519152336116b5565b6109d45760405162461bcd60e51b81526004016109cb90612e15565b60405180910390fd5b60fa811115610a255760405162461bcd60e51b815260206004820152601e60248201527f5141646d696e3a206d757374206265206c657373207468616e20322e3525000060448201526064016109cb565b6001811015610a805760405162461bcd60e51b815260206004820152602160248201527f5141646d696e3a206d7573742062652067726561746572207468616e202e30316044820152602560f81b60648201526084016109cb565b6001600160a01b038216600090815260d660209081526040918290205482519081529081018390527fb0df0e3854f8ed75bd359e4e361eb0a7e115718da7cfc470f766116975520b28910160405180910390a16001600160a01b03909116600090815260d66020526040902055565b610b07600080516020613081833981519152336116b5565b610b235760405162461bcd60e51b81526004016109cb90612e15565b60cb80546001600160a01b0319166001600160a01b0383169081179091556040519081527f5389d387cc695b1aa07e7be5f99b1f9a4eb662a7592fe34444a7a1008323470c906020015b60405180910390a150565b6001600160a01b038116600090815260dc602052604081205460ff16610ba05760cf54610991565b506001600160a01b0316600090815260dc602052604090206001015490565b610bd7600080516020613081833981519152336116b5565b610bf35760405162461bcd60e51b81526004016109cb90612e15565b6001600160a01b038216600090815260d7602052604090205460ff16610c575760405162461bcd60e51b81526020600482015260196024820152781450591b5a5b8e88185cdcd95d081b9bdd08195b98589b1959603a1b60448201526064016109cb565b6305f5e100811115610cab5760405162461bcd60e51b815260206004820152601c60248201527f5141646d696e3a20696e76616c696420617373657420666163746f720000000060448201526064016109cb565b6001600160a01b038216600081815260d760209081526040918290206003810154835190815291820185905292917f901b1e298d4829abe8b5a457938a72dd7c79d2796d3b0134e322190dc3ca7071910160405180910390a26003015550565b6001600160a01b038116600090815260dc602052604081205460ff16610d3357600019610991565b506001600160a01b0316600090815260dc602052604090206003015490565b610d6a600080516020613081833981519152336116b5565b610d865760405162461bcd60e51b81526004016109cb90612e15565b6001600160a01b038616600090815260d7602052604090205460ff1615610def5760405162461bcd60e51b815260206004820152601c60248201527f5141646d696e3a20617373657420616c7265616479206578697374730000000060448201526064016109cb565b6305f5e100821115610e135760405162461bcd60e51b81526004016109cb90612e41565b6305f5e100811115610e675760405162461bcd60e51b815260206004820152601d60248201527f5141646d696e3a20696e76616c6964206d61726b657420666163746f7200000060448201526064016109cb565b606060006040518060e001604052806001151581526020018815158152602001876001600160a01b03168152602001866001600160a01b031681526020018581526020018481526020018381525090508060d760008a6001600160a01b03166001600160a01b0316815260200190815260200160002060008201518160000160006101000a81548160ff02191690831515021790555060208201518160000160016101000a81548160ff02191690831515021790555060408201518160000160026101000a8154816001600160a01b0302191690836001600160a01b0316021790555060608201518160010160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506080820151816002015560a0820151816003015560c0820151816004019080519060200190610fa7929190612a33565b505060ce80546001810182556000919091527fd36cd1c74ef8d7326d8021b776c18fb5a5724b7f7bc93c2f42e43e10ef27d12a0180546001600160a01b0319166001600160a01b038b1617905550861561102a576001600160a01b03868116600090815260d96020526040902080546001600160a01b031916918a169190911790555b6040805188151581526001600160a01b03878116602083015291810186905260608101859052908916907fcc53b588a2b51a142275ed9b4311a49b14e07e98373668519a1e6e2af487b0739060800160405180910390a25050505050505050565b6000828152606560205260409020600101546110a681612487565b6110b08383612494565b505050565b6110cd600080516020613081833981519152336116b5565b6110e95760405162461bcd60e51b81526004016109cb90612e15565b6305f5e10081111561113d5760405162461bcd60e51b815260206004820152601f60248201527f5141646d696e3a206d757374206265206265747765656e203020616e6420310060448201526064016109cb565b60d15460408051918252602082018390527fc1b1fc9ada8fd300eb932823ffb8c1d779c1042acda828503783d493f648fcf9910160405180910390a160d155565b6001600160a01b03811633146111ee5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084016109cb565b6111f882826124b6565b5050565b611214600080516020613081833981519152336116b5565b6112305760405162461bcd60e51b81526004016109cb90612e15565b6305f5e1008110156112975760405162461bcd60e51b815260206004820152602a60248201527f5141646d696e3a206d7573742062652067726561746572207468616e206f7220604482015269657175616c20746f203160b01b60648201526084016109cb565b60d45460408051918252602082018390527f3d369be389ba99d698569ad414af64d17df6e7efb03058b6e265db27b29bfd77910160405180910390a160d455565b6112f0600080516020613081833981519152336116b5565b61130c5760405162461bcd60e51b81526004016109cb90612e15565b8082111561132c5760405162461bcd60e51b81526004016109cb90612e82565b60cf5460d0546040805192835260208301919091528101839052606081018290527ffe472f00ba40e0859ffe584ce9c42a06b39e5570fdcd2e4deb774a84d0a81dbf9060800160405180910390a160cf9190915560d055565b6001600160a01b038116600090815260d760209081526040918290206004018054835181840281018401909452808452606093928301828280156113e857602002820191906000526020600020905b8154815260200190600101908083116113d4575b50505050509050919050565b606060ce80548060200260200160405190810160405280929190818152602001828054801561144c57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161142e575b5050505050905090565b61146e600080516020613081833981519152336116b5565b61148a5760405162461bcd60e51b81526004016109cb90612e15565b60c980546001600160a01b0319166001600160a01b0383169081179091556040519081527f495be02bb0505e1312925c97fde89c71f648277b12a6a52db63a750619bfe36990602001610b6d565b6114f0600080516020613081833981519152336116b5565b61150c5760405162461bcd60e51b81526004016109cb90612e15565b60cc80546001600160a01b0319166001600160a01b0383169081179091556040519081527fe3c86ccd9ff8fc5156ad5bb943f9af945e0862a87d9e757e6f759b850218545390602001610b6d565b611572600080516020613081833981519152336116b5565b61158e5760405162461bcd60e51b81526004016109cb90612e15565b818311156115ae5760405162461bcd60e51b81526004016109cb90612e82565b6001600160a01b038516600081815260dc6020908152604091829020805460018201546002830154600390930154855196875260ff909216151593860193909352848401929092526060840152608083015285151560a083015260c0820185905260e082018490526101008201839052517fb0e62e9ddb68797f34e446de044567490db9159ca928bc68af0cbb897603e56a918190036101200190a16001600160a01b0394909416600090815260dc60205260409020805460ff19169315159390931783556001830191909155600282015560030155565b600061169133610b78565b905090565b60008281526097602052604081206116ae90836124d8565b9392505050565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6116f8600080516020613081833981519152336116b5565b6117145760405162461bcd60e51b81526004016109cb90612e15565b620151808111156117675760405162461bcd60e51b815260206004820152601b60248201527f5141646d696e3a206d7573742062652062656c6f77203120646179000000000060448201526064016109cb565b60d25460408051918252602082018390527f1ed48433b1c0c3c4b0c420cd4bfaab5d6889a8e6fcd420529a100f2746e61eab910160405180910390a160d255565b6001600160a01b038116600090815260dc602052604081205460ff166117d05760d054610991565b506001600160a01b0316600090815260dc602052604090206002015490565b60c9546000906001600160a01b03161561187a5760c960009054906101000a90046001600160a01b03166001600160a01b031663a0ee95606040518163ffffffff1660e01b8152600401602060405180830381865afa158015611856573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116919190612ef8565b50600090565b611898600080516020613081833981519152336116b5565b6118b45760405162461bcd60e51b81526004016109cb90612e15565b60ca80546001600160a01b0319166001600160a01b0383169081179091556040519081527faf657d8ee0afc40d774fc83c1dacaf864eed0dba95d6c956e17b013cb0d08fd490602001610b6d565b61191a600080516020613081833981519152336116b5565b6119365760405162461bcd60e51b81526004016109cb90612e15565b60cd80546001600160a01b0319166001600160a01b038316179055611969600080516020613061833981519152826124e4565b6040516001600160a01b03821681527f37b3beacdce80032a6dddd70d9fcc42584b99f5cbf1982636f88df10f679725390602001610b6d565b6119ba600080516020613081833981519152336116b5565b6119d65760405162461bcd60e51b81526004016109cb90612e15565b62015180811115611a295760405162461bcd60e51b815260206004820152601b60248201527f5141646d696e3a206d7573742062652062656c6f77203120646179000000000060448201526064016109cb565b60d35460408051918252602082018390527f585967d0aaf5c47b2749bb5087e7db5d8aef654bef94b7e878aa7bc8cb331145910160405180910390a160d355565b6000611691336117a8565b611a8d600080516020613081833981519152336116b5565b611aa95760405162461bcd60e51b81526004016109cb90612e15565b6000836001600160a01b031663204f83f96040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ae9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b0d9190612f15565b90506000846001600160a01b0316632495a5996040518163ffffffff1660e01b8152600401602060405180830381865afa158015611b4f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b739190612ef8565b90506001600160a01b038116611bcb5760405162461bcd60e51b815260206004820152601d60248201527f5141646d696e3a20696e76616c696420746f6b656e206164647265737300000060448201526064016109cb565b6001600160a01b038116600090815260d7602052604090205460ff16611c335760405162461bcd60e51b815260206004820152601960248201527f5141646d696e3a20756e737570706f727465642061737365740000000000000060448201526064016109cb565b6001600160a01b03818116600090815260d8602090815260408083208684529091529020541615611ca65760405162461bcd60e51b815260206004820152601d60248201527f5141646d696e3a206d61726b657420616c72656164792065786973747300000060448201526064016109cb565b6001600160a01b03818116600081815260d760209081526040808320600481018054600180820183559186528486200189905594845260d88352818420888552835281842080546001600160a01b031916968c16968717905594835260da9091529020805460ff19169091179055611d2c6000805160206130a1833981519152876124e4565b816001600160a01b0316866001600160a01b03167fe859e176358e907f148f3af2f48c81e3cb2e4675d15bfb9350cd2e06ba96829e85604051611d7191815260200190565b60405180910390a3611d838686610997565b611d8d8685611ff4565b505050505050565b600054610100900460ff1615808015611db55750600054600160ff909116105b80611dcf5750303b158015611dcf575060005460ff166001145b611e325760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016109cb565b6000805460ff191660011790558015611e55576000805461ff0019166101001790555b611e5d6124ee565b611e75600080516020613081833981519152836124e4565b611e8d6000805160206130a1833981519152836124e4565b611eb77ff0887ba65ee2024ea881d91b74c2450ef19e1557f03bed3ea9f16b037cbe2dc9836124e4565b611ecf600080516020613061833981519152836124e4565b611ee76000805160206130818339815191528061255b565b611f0d6000805160206130a183398151915260008051602061308183398151915261255b565b611f457ff0887ba65ee2024ea881d91b74c2450ef19e1557f03bed3ea9f16b037cbe2dc960008051602061308183398151915261255b565b611f6b60008051602061306183398151915260008051602061308183398151915261255b565b6305f5e10060cf5563068e778060d08190556302faf08060d15561384060d25561708060d35560d45580156111f8576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15050565b6000818152609760205260408120610991906125a6565b61200c600080516020613081833981519152336116b5565b6120285760405162461bcd60e51b81526004016109cb90612e15565b60006001600160a01b031660d86000846001600160a01b0316632495a5996040518163ffffffff1660e01b8152600401602060405180830381865afa158015612075573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120999190612ef8565b6001600160a01b03166001600160a01b031681526020019081526020016000206000846001600160a01b031663204f83f96040518163ffffffff1660e01b8152600401602060405180830381865afa1580156120f9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061211d9190612f15565b81526020810191909152604001600020546001600160a01b031614156121855760405162461bcd60e51b815260206004820152601c60248201527f5141646d696e3a206d61726b657420646f65736e27742065786973740000000060448201526064016109cb565b6001600160a01b038216600081815260db60209081526040918290205482519081529081018490527f0e5379c527fef02e70cc444763588ef064c27c8ac3e105640f1042e3665da046910160405180910390a26001600160a01b03909116600090815260db6020526040902055565b60008281526065602052604090206001015461220f81612487565b6110b083836124b6565b612231600080516020613081833981519152336116b5565b61224d5760405162461bcd60e51b81526004016109cb90612e15565b6001600160a01b038216600090815260d7602052604090205460ff166122b15760405162461bcd60e51b81526020600482015260196024820152781450591b5a5b8e88185cdcd95d081b9bdd08195b98589b1959603a1b60448201526064016109cb565b6305f5e1008111156122d55760405162461bcd60e51b81526004016109cb90612e41565b6001600160a01b038216600081815260d760209081526040918290206002810154835190815291820185905292917ff017a81504568de5a99d16d7eeeeccc712f06bde2c913fd00f4d472949556dce910160405180910390a26002015550565b61238b6040518060e0016040528060001515815260200160001515815260200160006001600160a01b0316815260200160006001600160a01b031681526020016000815260200160008152602001606081525090565b6001600160a01b03808316600090815260d76020908152604091829020825160e081018452815460ff808216151583526101008204161515828501526201000090048516818501526001820154909416606085015260028101546080850152600381015460a0850152600481018054845181850281018501909552808552919360c086019390929083018282801561244257602002820191906000526020600020905b81548152602001906001019080831161242e575b5050505050815250509050919050565b60006001600160e01b03198216637965db0b60e01b148061099157506301ffc9a760e01b6001600160e01b0319831614610991565b61249181336125b0565b50565b61249e8282612614565b60008281526097602052604090206110b0908261269a565b6124c082826126af565b60008281526097602052604090206110b09082612716565b60006116ae838361272b565b6111f88282612494565b600054610100900460ff166125595760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016109cb565b565b600082815260656020526040808220600101805490849055905190918391839186917fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff9190a4505050565b6000610991825490565b6125ba82826116b5565b6111f8576125d2816001600160a01b03166014612755565b6125dd836020612755565b6040516020016125ee929190612f2e565b60408051601f198184030181529082905262461bcd60e51b82526109cb91600401612d0b565b61261e82826116b5565b6111f85760008281526065602090815260408083206001600160a01b03851684529091529020805460ff191660011790556126563390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60006116ae836001600160a01b0384166128f1565b6126b982826116b5565b156111f85760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60006116ae836001600160a01b038416612940565b600082600001828154811061274257612742612fa3565b9060005260206000200154905092915050565b60606000612764836002612fcf565b61276f906002612fee565b67ffffffffffffffff81111561278757612787613006565b6040519080825280601f01601f1916602001820160405280156127b1576020820181803683370190505b509050600360fc1b816000815181106127cc576127cc612fa3565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106127fb576127fb612fa3565b60200101906001600160f81b031916908160001a905350600061281f846002612fcf565b61282a906001612fee565b90505b60018111156128a2576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061285e5761285e612fa3565b1a60f81b82828151811061287457612874612fa3565b60200101906001600160f81b031916908160001a90535060049490941c9361289b8161301c565b905061282d565b5083156116ae5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016109cb565b600081815260018301602052604081205461293857508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610991565b506000610991565b60008181526001830160205260408120548015612a29576000612964600183613033565b855490915060009061297890600190613033565b90508181146129dd57600086600001828154811061299857612998612fa3565b90600052602060002001549050808760000184815481106129bb576129bb612fa3565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806129ee576129ee61304a565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610991565b6000915050610991565b828054828255906000526020600020908101928215612a6e579160200282015b82811115612a6e578251825591602001919060010190612a53565b50612a7a929150612a7e565b5090565b5b80821115612a7a5760008155600101612a7f565b600060208284031215612aa557600080fd5b81356001600160e01b0319811681146116ae57600080fd5b6001600160a01b038116811461249157600080fd5b600060208284031215612ae457600080fd5b81356116ae81612abd565b60008060408385031215612b0257600080fd5b8235612b0d81612abd565b946020939093013593505050565b600060208284031215612b2d57600080fd5b5035919050565b80358015158114612b4457600080fd5b919050565b60008060008060008060c08789031215612b6257600080fd5b8635612b6d81612abd565b9550612b7b60208801612b34565b94506040870135612b8b81612abd565b93506060870135612b9b81612abd565b9598949750929560808101359460a0909101359350915050565b60008060408385031215612bc857600080fd5b823591506020830135612bda81612abd565b809150509250929050565b60008060408385031215612bf857600080fd5b50508035926020909101359150565b6020808252825182820181905260009190848201906040850190845b81811015612c3f57835183529284019291840191600101612c23565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b81811015612c3f5783516001600160a01b031683529284019291840191600101612c67565b600080600080600060a08688031215612ca457600080fd5b8535612caf81612abd565b9450612cbd60208701612b34565b94979496505050506040830135926060810135926080909101359150565b60005b83811015612cf6578181015183820152602001612cde565b83811115612d05576000848401525b50505050565b6020815260008251806020840152612d2a816040850160208701612cdb565b601f01601f19169190910160400192915050565b600080600060608486031215612d5357600080fd5b8335612d5e81612abd565b95602085013595506040909401359392505050565b60006020808352610100830184511515828501528185015115156040850152604085015160018060a01b0380821660608701528060608801511660808701525050608085015160a085015260a085015160c085015260c085015160e080860152818151808452610120870191508483019350600092505b80831015612e0a5783518252928401926001929092019190840190612dea565b509695505050505050565b60208082526012908201527128a0b236b4b71d1037b7363c9030b236b4b760711b604082015260600190565b60208082526021908201527f5141646d696e3a20696e76616c696420636f6c6c61746572616c20666163746f6040820152603960f91b606082015260800190565b60208082526050908201527f5141646d696e3a206d696e20636f6c6c61746572616c20726174696f206d757360408201527f74206265206c657373207468616e206f7220657175616c20746f20696e69742060608201526f636f6c6c61746572616c20726174696f60801b608082015260a00190565b600060208284031215612f0a57600080fd5b81516116ae81612abd565b600060208284031215612f2757600080fd5b5051919050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351612f66816017850160208801612cdb565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351612f97816028840160208801612cdb565b01602801949350505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000816000190483118215151615612fe957612fe9612fb9565b500290565b6000821982111561300157613001612fb9565b500190565b634e487b7160e01b600052604160045260246000fd5b60008161302b5761302b612fb9565b506000190190565b60008282101561304557613045612fb9565b500390565b634e487b7160e01b600052603160045260246000fdfed626b41c3f367ca674d295df116c7f3753fa8d2f187a97c7b4e2f1ad64935595df8b4c520ffe197c5343c6f5aec59570151ef9a492f2c624fd45ddde6135ec4223acc66832ff38a7ce3c1caf89922410f4374ba8fd897ffa98f088747997bc6da2646970667358221220e6d1dfc38dda4f49658b94cd7e4b520f3ab5459d59e1de00c92132195f81b5ce64736f6c634300080a0033
Age | Block | Fee Address | BC Fee Address | Voting Power | Jailed | Incoming |
---|