More Info
Private Name Tags
ContractCreator
Latest 15 from a total of 15 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Liquidate Vault | 20243862 | 196 days ago | IN | 0.01456218 ETH | 0.00083505 | ||||
Remove Collatera... | 17576270 | 570 days ago | IN | 0 ETH | 0.00174086 | ||||
Burn | 17576237 | 570 days ago | IN | 0.00767243 ETH | 0.00168995 | ||||
Burn | 16826490 | 676 days ago | IN | 0.00483449 ETH | 0.0071578 | ||||
Mint | 16809516 | 678 days ago | IN | 0 ETH | 0.00230822 | ||||
Mint | 16809488 | 678 days ago | IN | 0 ETH | 0.00262604 | ||||
Add Collateral | 16809472 | 678 days ago | IN | 0 ETH | 0.00140402 | ||||
Create Vault | 16809448 | 678 days ago | IN | 0 ETH | 0.00181985 | ||||
Remove Collatera... | 15905512 | 805 days ago | IN | 0 ETH | 0.00070411 | ||||
Add Collateral | 15905495 | 805 days ago | IN | 0 ETH | 0.00119835 | ||||
Create Vault | 15905481 | 805 days ago | IN | 0 ETH | 0.00146541 | ||||
Create Vault | 15824090 | 816 days ago | IN | 0 ETH | 0.00134039 | ||||
Liquidate Vault | 15357622 | 885 days ago | IN | 0.00907719 ETH | 0.0014261 | ||||
Liquidate Vault | 15355329 | 885 days ago | IN | 0.0035227 ETH | 0.00312959 | ||||
Create Vault | 14798805 | 976 days ago | IN | 0 ETH | 0.00314323 |
Latest 12 internal transactions
Advanced mode:
Parent Transaction Hash | Block |
From
|
To
|
|||
---|---|---|---|---|---|---|
20243862 | 196 days ago | 0.00014418 ETH | ||||
20243862 | 196 days ago | 0.014418 ETH | ||||
17576237 | 570 days ago | 0.00007596 ETH | ||||
17576237 | 570 days ago | 0.00759647 ETH | ||||
17360710 | 600 days ago | 0.02198401 ETH | ||||
17360710 | 600 days ago | 0.02198401 ETH | ||||
16826490 | 676 days ago | 0.00004786 ETH | ||||
16826490 | 676 days ago | 0.00478662 ETH | ||||
15357622 | 885 days ago | 0.00008987 ETH | ||||
15357622 | 885 days ago | 0.00898732 ETH | ||||
15355329 | 885 days ago | 0.00003487 ETH | ||||
15355329 | 885 days ago | 0.00348782 ETH |
Loading...
Loading
Contract Name:
ERC20VaultHandler
Compiler Version
v0.7.5+commit.eb77ed08
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.7.5; import "./IVaultHandler.sol"; import "./Orchestrator.sol"; /** * @title ERC-20 TCAP Vault * @author Cryptex.finance * @notice Contract in charge of handling the TCAP Vault and stake using a Collateral ERC20 */ contract ERC20VaultHandler is IVaultHandler { /** * @notice Constructor * @param _orchestrator address * @param _divisor uint256 * @param _ratio uint256 * @param _burnFee uint256 * @param _liquidationPenalty uint256 * @param _tcapOracle address * @param _tcapAddress address * @param _collateralAddress address * @param _collateralOracle address * @param _ethOracle address * @param _treasury address * @param _minimumTCAP uint256 */ constructor( Orchestrator _orchestrator, uint256 _divisor, uint256 _ratio, uint256 _burnFee, uint256 _liquidationPenalty, address _tcapOracle, TCAP _tcapAddress, address _collateralAddress, address _collateralOracle, address _ethOracle, address _treasury, uint256 _minimumTCAP ) IVaultHandler( _orchestrator, _divisor, _ratio, _burnFee, _liquidationPenalty, _tcapOracle, _tcapAddress, _collateralAddress, _collateralOracle, _ethOracle, _treasury, _minimumTCAP ) {} }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0; interface AggregatorV3Interface { function decimals() external view returns (uint8); function description() external view returns (string memory); function version() external view returns (uint256); // getRoundData and latestRoundData should both raise "No data present" // if they do not have data to report, instead of returning unset values // which could be misinterpreted as actual reported values. function getRoundData(uint80 _roundId) external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); function latestRoundData() external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../utils/EnumerableSet.sol"; import "../utils/Address.sol"; import "../GSN/Context.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context { using EnumerableSet for EnumerableSet.AddressSet; using Address for address; struct RoleData { EnumerableSet.AddressSet members; bytes32 adminRole; } mapping (bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @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 {_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) public view returns (bool) { return _roles[role].members.contains(account); } /** * @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 returns (uint256) { return _roles[role].members.length(); } /** * @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 returns (address) { return _roles[role].members.at(index); } /** * @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 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. */ function grantRole(bytes32 role, address account) public virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant"); _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. */ function revokeRole(bytes32 role, address account) public virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke"); _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 granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual { 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. * * [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}. * ==== */ 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 { emit RoleAdminChanged(role, _roles[role].adminRole, adminRole); _roles[role].adminRole = adminRole; } function _grantRole(bytes32 role, address account) private { if (_roles[role].members.add(account)) { emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (_roles[role].members.remove(account)) { emit RoleRevoked(role, account, _msgSender()); } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../GSN/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @dev Library used to query support of an interface declared via {IERC165}. * * Note that these functions return the actual result of the query: they do not * `revert` if an interface is not supported. It is up to the caller to decide * what to do in these cases. */ library ERC165Checker { // As per the EIP-165 spec, no interface should ever match 0xffffffff bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff; /* * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7 */ bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7; /** * @dev Returns true if `account` supports the {IERC165} interface, */ function supportsERC165(address account) internal view returns (bool) { // Any contract that implements ERC165 must explicitly indicate support of // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid return _supportsERC165Interface(account, _INTERFACE_ID_ERC165) && !_supportsERC165Interface(account, _INTERFACE_ID_INVALID); } /** * @dev Returns true if `account` supports the interface defined by * `interfaceId`. Support for {IERC165} itself is queried automatically. * * See {IERC165-supportsInterface}. */ function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) { // query support of both ERC165 as per the spec and support of _interfaceId return supportsERC165(account) && _supportsERC165Interface(account, interfaceId); } /** * @dev Returns true if `account` supports all the interfaces defined in * `interfaceIds`. Support for {IERC165} itself is queried automatically. * * Batch-querying can lead to gas savings by skipping repeated checks for * {IERC165} support. * * See {IERC165-supportsInterface}. */ function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) { // query support of ERC165 itself if (!supportsERC165(account)) { return false; } // query support of each interface in _interfaceIds for (uint256 i = 0; i < interfaceIds.length; i++) { if (!_supportsERC165Interface(account, interfaceIds[i])) { return false; } } // all interfaces supported return true; } /** * @notice Query if a contract implements an interface, does not check ERC165 support * @param account The address of the contract to query for support of an interface * @param interfaceId The interface identifier, as specified in ERC-165 * @return true if the contract at account indicates support of the interface with * identifier interfaceId, false otherwise * @dev Assumes that account contains a contract that supports ERC165, otherwise * the behavior of this method is undefined. This precondition can be checked * with {supportsERC165}. * Interface identification is specified in ERC-165. */ function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) { // success determines whether the staticcall succeeded and result determines // whether the contract at account indicates support of _interfaceId (bool success, bool result) = _callERC165SupportsInterface(account, interfaceId); return (success && result); } /** * @notice Calls the function with selector 0x01ffc9a7 (ERC165) and suppresses throw * @param account The address of the contract to query for support of an interface * @param interfaceId The interface identifier, as specified in ERC-165 * @return success true if the STATICCALL succeeded, false otherwise * @return result true if the STATICCALL succeeded and the contract at account * indicates support of the interface with identifier interfaceId, false otherwise */ function _callERC165SupportsInterface(address account, bytes4 interfaceId) private view returns (bool, bool) { bytes memory encodedParams = abi.encodeWithSelector(_INTERFACE_ID_ERC165, interfaceId); (bool success, bytes memory result) = account.staticcall{ gas: 30000 }(encodedParams); if (result.length < 32) return (false, false); return (success, abi.decode(result, (bool))); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } }
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../../GSN/Context.sol"; import "./IERC20.sol"; import "../../math/SafeMath.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) public { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @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 `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, 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 `sender` to `recipient` 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 sender, address recipient, uint256 amount) external returns (bool); /** * @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); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./IERC20.sol"; import "../../math/SafeMath.sol"; import "../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 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"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (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"); // solhint-disable-next-line avoid-low-level-calls (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"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private 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 // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../math/SafeMath.sol"; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented or decremented by one. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` * Since it is not possible to overflow a 256 bit integer with increments of one, `increment` can skip the {SafeMath} * overflow check, thereby saving gas. This does assume however correct usage, in that the underlying `_value` is never * directly accessed. */ library Counters { using SafeMath for uint256; struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { // The {SafeMath} overflow check can be skipped here, see the comment at the top counter._value += 1; } function decrement(Counter storage counter) internal { counter._value = counter._value.sub(1); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <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. */ library EnumerableSet { // 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; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. 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] = toDeleteIndex + 1; // All indexes are 1-based // 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) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // 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); } // 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(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(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(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(uint256(_at(set._inner, index))); } // 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)); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../GSN/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor () internal { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!_paused, "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(_paused, "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor () internal { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. * * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing * all math on `uint256` and `int256` and then downcasting. */ library SafeCast { /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits */ function toUint128(uint256 value) internal pure returns (uint128) { require(value < 2**128, "SafeCast: value doesn\'t fit in 128 bits"); return uint128(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits */ function toUint64(uint256 value) internal pure returns (uint64) { require(value < 2**64, "SafeCast: value doesn\'t fit in 64 bits"); return uint64(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits */ function toUint32(uint256 value) internal pure returns (uint32) { require(value < 2**32, "SafeCast: value doesn\'t fit in 32 bits"); return uint32(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits */ function toUint16(uint256 value) internal pure returns (uint16) { require(value < 2**16, "SafeCast: value doesn\'t fit in 16 bits"); return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits. */ function toUint8(uint256 value) internal pure returns (uint8) { require(value < 2**8, "SafeCast: value doesn\'t fit in 8 bits"); return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. */ function toUint256(int256 value) internal pure returns (uint256) { require(value >= 0, "SafeCast: value must be positive"); return uint256(value); } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v3.1._ */ function toInt128(int256 value) internal pure returns (int128) { require(value >= -2**127 && value < 2**127, "SafeCast: value doesn\'t fit in 128 bits"); return int128(value); } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v3.1._ */ function toInt64(int256 value) internal pure returns (int64) { require(value >= -2**63 && value < 2**63, "SafeCast: value doesn\'t fit in 64 bits"); return int64(value); } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v3.1._ */ function toInt32(int256 value) internal pure returns (int32) { require(value >= -2**31 && value < 2**31, "SafeCast: value doesn\'t fit in 32 bits"); return int32(value); } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v3.1._ */ function toInt16(int256 value) internal pure returns (int16) { require(value >= -2**15 && value < 2**15, "SafeCast: value doesn\'t fit in 16 bits"); return int16(value); } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits. * * _Available since v3.1._ */ function toInt8(int256 value) internal pure returns (int8) { require(value >= -2**7 && value < 2**7, "SafeCast: value doesn\'t fit in 8 bits"); return int8(value); } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. */ function toInt256(uint256 value) internal pure returns (int256) { require(value < 2**255, "SafeCast: value doesn't fit in an int256"); return int256(value); } }
// SPDX-License-Identifier: MIT pragma solidity 0.7.5; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/math/Math.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/utils/SafeCast.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "@openzeppelin/contracts/utils/Pausable.sol"; import "@openzeppelin/contracts/introspection/IERC165.sol"; import "./TCAP.sol"; import "./Orchestrator.sol"; import "./oracles/ChainlinkOracle.sol"; /** * @title TCAP Vault Handler Abstract Contract * @author Cryptex.Finance * @notice Contract in charge of handling the TCAP Token and stake */ abstract contract IVaultHandler is Ownable, AccessControl, ReentrancyGuard, Pausable, IERC165 { /// @notice Open Zeppelin libraries using SafeMath for uint256; using SafeCast for int256; using Counters for Counters.Counter; using SafeERC20 for IERC20; /** * @notice Vault object created to manage the mint and burns of TCAP tokens * @param Id, unique identifier of the vault * @param Collateral, current collateral on vault * @param Debt, current amount of TCAP tokens minted * @param Owner, owner of the vault */ struct Vault { uint256 Id; uint256 Collateral; uint256 Debt; address Owner; } /// @notice Vault Id counter Counters.Counter public counter; /// @notice value used to divide collateral to adjust the decimal places uint256 public immutable collateralDecimalsAdjustmentFactor; /// @notice TCAP Token Address TCAP public immutable TCAPToken; /// @notice Total Market Cap/USD Oracle Address ChainlinkOracle public immutable tcapOracle; /// @notice Collateral Token Address IERC20 public immutable collateralContract; /// @notice Collateral/USD Oracle Address ChainlinkOracle public immutable collateralPriceOracle; /// @notice ETH/USD Oracle Address ChainlinkOracle public immutable ETHPriceOracle; /// @notice Value used as divisor with the total market cap, just like the S&P 500 or any major financial index would to define the final tcap token price uint256 public divisor; /// @notice Minimum ratio required to prevent liquidation of vault uint256 public ratio; /// @notice Fee percentage of the total amount to burn charged on ETH when burning TCAP Tokens uint256 public burnFee; /// @notice Penalty charged to vault owner when a vault is liquidated, this value goes to the liquidator uint256 public liquidationPenalty; /// @notice Minimum amount of TCAP an user can mint uint256 public minimumTCAP = 0; /// @notice Address of the treasury contract (usually the timelock) where the funds generated by the protocol are sent address public treasury; /// @notice Owner address to Vault Id mapping(address => uint256) public userToVault; /// @notice Id To Vault mapping(uint256 => Vault) public vaults; /// @notice value used to multiply chainlink oracle for handling decimals uint256 public constant oracleDigits = 10000000000; /// @notice Maximum decimal places that are supported by the collateral uint8 public constant MAX_DECIMAL_PLACES = 18; /// @notice Minimum value that the ratio can be set to uint256 public constant MIN_RATIO = 100; /// @notice Maximum value that the burn fee can be set to, the fee has two decimals, so it's multiplied by 100 uint256 public constant MAX_FEE = 1000; /// max fee 10% /** * @dev the computed interface ID according to ERC-165. The interface ID is a XOR of interface method selectors. * setRatio.selector ^ * setBurnFee.selector ^ * setLiquidationPenalty.selector ^ * pause.selector ^ * unpause.selector => 0x9e75ab0c */ bytes4 private constant _INTERFACE_ID_IVAULT = 0x9e75ab0c; /// @dev bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7 bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7; /// @notice An event emitted when the ratio is updated event NewRatio(address indexed _owner, uint256 _ratio); /// @notice An event emitted when the burn fee is updated event NewBurnFee(address indexed _owner, uint256 _burnFee); /// @notice An event emitted when the liquidation penalty is updated event NewLiquidationPenalty( address indexed _owner, uint256 _liquidationPenalty ); /// @notice An event emitted when the minimum required TCAP is updated event NewMinimumTCAP( address indexed _owner, uint256 _minimumTCAP ); /// @notice An event emitted when the treasury contract is updated event NewTreasury(address indexed _owner, address _tresury); /// @notice An event emitted when a vault is created event VaultCreated(address indexed _owner, uint256 indexed _id); /// @notice An event emitted when collateral is added to a vault event CollateralAdded( address indexed _owner, uint256 indexed _id, uint256 _amount ); /// @notice An event emitted when collateral is removed from a vault event CollateralRemoved( address indexed _owner, uint256 indexed _id, uint256 _amount ); /// @notice An event emitted when tokens are minted event TokensMinted( address indexed _owner, uint256 indexed _id, uint256 _amount ); /// @notice An event emitted when tokens are burned event TokensBurned( address indexed _owner, uint256 indexed _id, uint256 _amount ); /// @notice An event emitted when a vault is liquidated event VaultLiquidated( uint256 indexed _vaultId, address indexed _liquidator, uint256 _liquidationCollateral, uint256 _reward ); /// @notice An event emitted when a erc20 token is recovered event Recovered(address _token, uint256 _amount); /** * @notice Constructor * @param _orchestrator address * @param _divisor uint256 * @param _ratio uint256 * @param _burnFee uint256 * @param _liquidationPenalty uint256 * @param _tcapOracle address * @param _tcapAddress address * @param _collateralAddress address * @param _collateralOracle address * @param _ethOracle address * @param _treasury address * @param _minimumTCAP uint256 */ constructor( Orchestrator _orchestrator, uint256 _divisor, uint256 _ratio, uint256 _burnFee, uint256 _liquidationPenalty, address _tcapOracle, TCAP _tcapAddress, address _collateralAddress, address _collateralOracle, address _ethOracle, address _treasury, uint256 _minimumTCAP ) { require( _liquidationPenalty.add(100) < _ratio, "VaultHandler::constructor: liquidation penalty too high" ); require( _ratio >= MIN_RATIO, "VaultHandler::constructor: ratio lower than MIN_RATIO" ); require( _burnFee <= MAX_FEE, "VaultHandler::constructor: burn fee higher than MAX_FEE" ); divisor = _divisor; ratio = _ratio; burnFee = _burnFee; liquidationPenalty = _liquidationPenalty; tcapOracle = ChainlinkOracle(_tcapOracle); collateralContract = IERC20(_collateralAddress); collateralPriceOracle = ChainlinkOracle(_collateralOracle); ETHPriceOracle = ChainlinkOracle(_ethOracle); TCAPToken = _tcapAddress; treasury = _treasury; minimumTCAP = _minimumTCAP; uint8 _collateralDecimals = ERC20(_collateralAddress).decimals(); require( _collateralDecimals <= MAX_DECIMAL_PLACES, "Collateral decimals greater than MAX_DECIMAL_PLACES" ); collateralDecimalsAdjustmentFactor = 10 ** (MAX_DECIMAL_PLACES - _collateralDecimals); /// @dev counter starts in 1 as 0 is reserved for empty objects counter.increment(); /// @dev transfer ownership to orchestrator _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); transferOwnership(address(_orchestrator)); } /// @notice Reverts if the user hasn't created a vault. modifier vaultExists() { require( userToVault[msg.sender] != 0, "VaultHandler::vaultExists: no vault created" ); _; } /// @notice Reverts if value is 0. modifier notZero(uint256 _value) { require(_value != 0, "VaultHandler::notZero: value can't be 0"); _; } /** * @notice Sets the collateral ratio needed to mint tokens * @param _ratio uint * @dev Only owner can call it */ function setRatio(uint256 _ratio) external virtual onlyOwner { require( _ratio >= MIN_RATIO, "VaultHandler::setRatio: ratio lower than MIN_RATIO" ); require( liquidationPenalty.add(100) < _ratio, "VaultHandler::setRatio: liquidation penalty too high" ); ratio = _ratio; emit NewRatio(msg.sender, _ratio); } /** * @notice Sets the burn fee percentage an user pays when burning tcap tokens * @param _burnFee uint * @dev Only owner can call it */ function setBurnFee(uint256 _burnFee) external virtual onlyOwner { require( _burnFee <= MAX_FEE, "VaultHandler::setBurnFee: burn fee higher than MAX_FEE" ); burnFee = _burnFee; emit NewBurnFee(msg.sender, _burnFee); } /** * @notice Sets the liquidation penalty % charged on liquidation * @param _liquidationPenalty uint * @dev Only owner can call it * @dev recommended value is between 1-15% and can't be above 100% */ function setLiquidationPenalty(uint256 _liquidationPenalty) external virtual onlyOwner { require( _liquidationPenalty.add(100) < ratio, "VaultHandler::setLiquidationPenalty: liquidation penalty too high" ); liquidationPenalty = _liquidationPenalty; emit NewLiquidationPenalty(msg.sender, _liquidationPenalty); } /** * @notice Sets the minimum TCAP a vault owner can mint * @param _minimumTCAP uint * @dev Only owner can call it * @dev this is mostly used on hard mode vaults with low collateral ratio vaults */ function setMinimumTCAP(uint256 _minimumTCAP) external virtual onlyOwner { minimumTCAP = _minimumTCAP; emit NewMinimumTCAP(msg.sender, _minimumTCAP); } /** * @notice Sets the treasury contract address where fees are transferred to * @param _treasury address * @dev Only owner can call it */ function setTreasury(address _treasury) external virtual onlyOwner { require( _treasury != address(0), "VaultHandler::setTreasury: not a valid treasury" ); treasury = _treasury; emit NewTreasury(msg.sender, _treasury); } /** * @notice Allows an user to create an unique Vault * @dev Only one vault per address can be created */ function createVault() external virtual whenNotPaused { require( userToVault[msg.sender] == 0, "VaultHandler::createVault: vault already created" ); uint256 id = counter.current(); userToVault[msg.sender] = id; Vault memory vault = Vault(id, 0, 0, msg.sender); vaults[id] = vault; counter.increment(); emit VaultCreated(msg.sender, id); } /** * @notice Allows users to add collateral to their vaults * @param _amount of collateral to be added * @dev _amount should be higher than 0 * @dev ERC20 token must be approved first */ function addCollateral(uint256 _amount) external virtual nonReentrant vaultExists whenNotPaused notZero(_amount) { require( collateralContract.transferFrom(msg.sender, address(this), _amount), "VaultHandler::addCollateral: ERC20 transfer did not succeed" ); Vault storage vault = vaults[userToVault[msg.sender]]; vault.Collateral = vault.Collateral.add(_amount); emit CollateralAdded(msg.sender, vault.Id, _amount); } /** * @notice Allows users to remove collateral currently not being used to generate TCAP tokens from their vaults * @param _amount of collateral to remove * @dev reverts if the resulting ratio is less than the minimum ratio * @dev _amount should be higher than 0 * @dev transfers the collateral back to the user */ function removeCollateral(uint256 _amount) external virtual nonReentrant vaultExists whenNotPaused notZero(_amount) { Vault storage vault = vaults[userToVault[msg.sender]]; uint256 currentRatio = getVaultRatio(vault.Id); require( vault.Collateral >= _amount, "VaultHandler::removeCollateral: retrieve amount higher than collateral" ); vault.Collateral = vault.Collateral.sub(_amount); if (currentRatio != 0) { require( getVaultRatio(vault.Id) >= ratio, "VaultHandler::removeCollateral: collateral below min required ratio" ); } require( collateralContract.transfer(msg.sender, _amount), "VaultHandler::removeCollateral: ERC20 transfer did not succeed" ); emit CollateralRemoved(msg.sender, vault.Id, _amount); } /** * @notice Uses collateral to generate debt on TCAP Tokens which are minted and assigned to caller * @param _amount of tokens to mint * @dev _amount should be higher than 0 * @dev requires to have a vault ratio above the minimum ratio * @dev if reward handler is set stake to earn rewards */ function mint(uint256 _amount) external virtual nonReentrant vaultExists whenNotPaused notZero(_amount) { Vault storage vault = vaults[userToVault[msg.sender]]; uint256 collateral = requiredCollateral(_amount); require( vault.Collateral >= collateral, "VaultHandler::mint: not enough collateral" ); vault.Debt = vault.Debt.add(_amount); require( getVaultRatio(vault.Id) >= ratio, "VaultHandler::mint: collateral below min required ratio" ); require(vault.Debt >= minimumTCAP, "VaultHandler::mint: mint amount less than required"); TCAPToken.mint(msg.sender, _amount); emit TokensMinted(msg.sender, vault.Id, _amount); } /** * @notice Pays the debt of TCAP tokens resulting them on burn, this releases collateral up to minimum vault ratio * @param _amount of tokens to burn * @dev _amount should be higher than 0 * @dev A fee of exactly burnFee must be sent as value on ETH * @dev The fee goes to the treasury contract * @dev if reward handler is set exit rewards */ function burn(uint256 _amount) external payable virtual nonReentrant vaultExists whenNotPaused notZero(_amount) { uint256 fee = getFee(_amount); require( msg.value >= fee, "VaultHandler::burn: burn fee less than required" ); Vault memory vault = vaults[userToVault[msg.sender]]; _burn(vault.Id, _amount); safeTransferETH(treasury, fee); //send back ETH above fee safeTransferETH(msg.sender, msg.value.sub(fee)); emit TokensBurned(msg.sender, vault.Id, _amount); } /** * @notice Allow users to burn TCAP tokens to liquidate vaults with vault collateral ratio under the minimum ratio, the liquidator receives the staked collateral of the liquidated vault at a premium * @param _vaultId to liquidate * @param _maxTCAP max amount of TCAP the liquidator is willing to pay to liquidate vault * @dev Resulting ratio must be above or equal minimum ratio * @dev A fee of exactly burnFee must be sent as value on ETH * @dev The fee goes to the treasury contract */ function liquidateVault(uint256 _vaultId, uint256 _maxTCAP) external payable nonReentrant whenNotPaused { Vault storage vault = vaults[_vaultId]; require(vault.Id != 0, "VaultHandler::liquidateVault: no vault created"); uint256 vaultRatio = getVaultRatio(vault.Id); require( vaultRatio < ratio, "VaultHandler::liquidateVault: vault is not liquidable" ); uint256 requiredTCAP = requiredLiquidationTCAP(vault.Id); require( _maxTCAP >= requiredTCAP, "VaultHandler::liquidateVault: liquidation amount different than required" ); uint256 fee = getFee(requiredTCAP); require( msg.value >= fee, "VaultHandler::liquidateVault: burn fee less than required" ); uint256 reward = liquidationReward(vault.Id); _burn(vault.Id, requiredTCAP); //Removes the collateral that is rewarded to liquidator vault.Collateral = vault.Collateral.sub(reward); require( collateralContract.transfer(msg.sender, reward), "VaultHandler::liquidateVault: ERC20 transfer did not succeed" ); safeTransferETH(treasury, fee); //send back ETH above fee safeTransferETH(msg.sender, msg.value.sub(fee)); emit VaultLiquidated(vault.Id, msg.sender, requiredTCAP, reward); } /** * @notice Allows the owner to Pause the Contract */ function pause() external onlyOwner { _pause(); } /** * @notice Allows the owner to Unpause the Contract */ function unpause() external onlyOwner { _unpause(); } /** * @notice Added to support recovering LP Rewards from other systems such as BAL to be distributed to holders * @param _tokenAddress address * @param _tokenAmount uint * @dev Only owner can call it */ function recoverERC20(address _tokenAddress, uint256 _tokenAmount) external onlyOwner { // Cannot recover the collateral token require( _tokenAddress != address(collateralContract), "Cannot withdraw the collateral tokens" ); IERC20(_tokenAddress).safeTransfer(owner(), _tokenAmount); emit Recovered(_tokenAddress, _tokenAmount); } /** * @notice Allows the safe transfer of ETH * @param _to account to transfer ETH * @param _value amount of ETH */ function safeTransferETH(address _to, uint256 _value) internal { (bool success,) = _to.call{value : _value}(new bytes(0)); require(success, "IVaultHandler::safeTransferETH: ETH transfer failed"); } /** * @notice ERC165 Standard for support of interfaces * @param _interfaceId bytes of interface * @return bool */ function supportsInterface(bytes4 _interfaceId) external pure override returns (bool) { return (_interfaceId == _INTERFACE_ID_IVAULT || _interfaceId == _INTERFACE_ID_ERC165); } /** * @notice Returns the Vault information of specified identifier * @param _id of vault * @return Id, Collateral, Owner, Debt */ function getVault(uint256 _id) external view virtual returns ( uint256, uint256, address, uint256 ) { Vault memory vault = vaults[_id]; return (vault.Id, vault.Collateral, vault.Owner, vault.Debt); } /** * @notice Returns the price of the chainlink oracle multiplied by the digits to get 18 decimals format * @param _oracle to be the price called * @return price * @dev The price returned here is in USD is equivalent to 1 `ether` unit times 10 ** 18 * eg. For ETH This will return the price of USD of 1 ETH * 10 ** 18 and **not** 1 wei * 10 ** 18 * eg. For DAI This will return the price of USD of 1 DAI * 10 ** 18 and **not** (1 / 10 ** 18) * 10 ** 18 */ function getOraclePrice(ChainlinkOracle _oracle) public view virtual returns (uint256 price) { price = _oracle.getLatestAnswer().toUint256().mul(oracleDigits); } /** * @notice Returns the price of the TCAP token * @return price of the TCAP Token * @dev TCAP token is 18 decimals * @dev oracle totalMarketPrice must be in wei format * @dev P = T / d * P = TCAP Token Price * T = Total Crypto Market Cap * d = Divisor */ function TCAPPrice() public view virtual returns (uint256 price) { uint256 totalMarketPrice = getOraclePrice(tcapOracle); price = totalMarketPrice.div(divisor); } /** * @notice Returns the minimal required collateral to mint TCAP token * @param _amount uint amount to mint * @return collateral of the TCAP Token * @dev TCAP token is 18 decimals * @dev C = ((P * A * r) / 100) / (cp * cdaf) * C = Required Collateral * P = TCAP Token Price * A = Amount to Mint * cp = Collateral Price * r = Minimum Ratio for Liquidation * cdaf = Collateral decimals adjust factor */ function requiredCollateral(uint256 _amount) public view virtual returns (uint256 collateral) { uint256 tcapPrice = TCAPPrice(); uint256 collateralPrice = getOraclePrice(collateralPriceOracle); collateral = ((tcapPrice.mul(_amount).mul(ratio)).div(100)).div( collateralPrice ).div(collateralDecimalsAdjustmentFactor); } /** * @notice Returns the minimal required TCAP to liquidate a Vault * @param _vaultId of the vault to liquidate * @return amount required of the TCAP Token * @dev LT = ((((D * r) / 100) - cTcap) * 100) / (r - (p + 100)) * cTcap = ((C * cdaf * cp) / P) * LT = Required TCAP * D = Vault Debt * C = Required Collateral * P = TCAP Token Price * cdaf = Collateral Decimals adjustment Factor * cp = Collateral Price * r = Min Vault Ratio * p = Liquidation Penalty */ function requiredLiquidationTCAP(uint256 _vaultId) public view virtual returns (uint256 amount) { Vault memory vault = vaults[_vaultId]; uint256 tcapPrice = TCAPPrice(); uint256 collateralPrice = getOraclePrice(collateralPriceOracle); uint256 collateralTcap = ( vault.Collateral.mul(collateralDecimalsAdjustmentFactor).mul(collateralPrice) ).div(tcapPrice); uint256 reqDividend = (((vault.Debt.mul(ratio)).div(100)).sub(collateralTcap)).mul(100); uint256 reqDivisor = ratio.sub(liquidationPenalty.add(100)); amount = Math.min(vault.Debt, reqDividend.div(reqDivisor)); } /** * @notice Returns the Reward Collateral amount for liquidating a vault * @param _vaultId of the vault to liquidate * @return rewardCollateral for liquidating Vault * @dev the returned value is returned as collateral currency * @dev R = (LT * (p + 100)) / 100 * @dev RC = R / (cp * cdaf) * R = Liquidation Reward * RC = Liquidation Reward Collateral * LT = Required Liquidation TCAP * p = liquidation penalty * cp = Collateral Price * cdaf = Collateral Decimals adjustment factor */ function liquidationReward(uint256 _vaultId) public view virtual returns (uint256 rewardCollateral) { Vault memory vault = vaults[_vaultId]; uint256 req = requiredLiquidationTCAP(_vaultId); uint256 tcapPrice = TCAPPrice(); uint256 collateralPrice = getOraclePrice(collateralPriceOracle); uint256 reward = (req.mul(liquidationPenalty.add(100))); uint256 _rewardCollateral = ( reward.mul(tcapPrice) ).div( collateralPrice.mul(100) ).div(collateralDecimalsAdjustmentFactor); rewardCollateral = Math.min(vault.Collateral, _rewardCollateral); } /** * @notice Returns the Collateral Ratio of the Vault * @param _vaultId id of vault * @return currentRatio * @dev vr = (cp * (C * 100 * cdaf)) / D * P * vr = Vault Ratio * C = Vault Collateral * cdaf = Collateral Decimals Adjustment Factor * cp = Collateral Price * D = Vault Debt * P = TCAP Token Price */ function getVaultRatio(uint256 _vaultId) public view virtual returns (uint256 currentRatio) { Vault memory vault = vaults[_vaultId]; if (vault.Id == 0 || vault.Debt == 0) { currentRatio = 0; } else { uint256 collateralPrice = getOraclePrice(collateralPriceOracle); currentRatio = (( collateralPrice.mul(vault.Collateral.mul(100).mul(collateralDecimalsAdjustmentFactor) )).div( vault.Debt.mul(TCAPPrice()) ) ); } } /** * @notice Returns the required fee of ETH to burn the TCAP tokens * @param _amount to burn * @return fee * @dev The returned value is returned in wei * @dev f = (((P * A * b)/ 10000))/ EP * f = Burn Fee Value in wei * P = TCAP Token Price * A = TCAP Amount to Burn * b = Burn Fee % * EP = ETH Price * 10000 = the value is 100 multiplied by 100 to support two decimals on the burn fee */ function getFee(uint256 _amount) public view virtual returns (uint256 fee) { uint256 ethPrice = getOraclePrice(ETHPriceOracle); fee = (TCAPPrice().mul(_amount).mul(burnFee)).div(10000).div(ethPrice); } /** * @notice Burns an amount of TCAP Tokens * @param _vaultId vault id * @param _amount to burn */ function _burn(uint256 _vaultId, uint256 _amount) internal { Vault storage vault = vaults[_vaultId]; require( vault.Debt >= _amount, "VaultHandler::burn: amount greater than debt" ); vault.Debt = vault.Debt.sub(_amount); TCAPToken.burn(msg.sender, _amount); } }
// SPDX-License-Identifier: MIT pragma solidity 0.7.5; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/introspection/ERC165Checker.sol"; import "./IVaultHandler.sol"; import "./TCAP.sol"; import "./oracles/ChainlinkOracle.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /** * @title TCAP Orchestrator * @author Cryptex.finance * @notice Orchestrator contract in charge of managing the settings of the vaults, rewards and TCAP token. It acts as the owner of these contracts. */ contract Orchestrator is Ownable { /// @dev Enum which saves the available functions to emergency call. enum Functions {BURNFEE, LIQUIDATION, PAUSE} /// @notice Address that can set to 0 the fees or pause the vaults in an emergency event address public guardian; /** @dev Interface constants*/ bytes4 private constant _INTERFACE_ID_IVAULT = 0x9e75ab0c; bytes4 private constant _INTERFACE_ID_TCAP = 0xbd115939; bytes4 private constant _INTERFACE_ID_CHAINLINK_ORACLE = 0x85be402b; /// @dev tracks which vault was emergency called mapping(IVaultHandler => mapping(Functions => bool)) private emergencyCalled; /// @notice An event emitted when the guardian is updated event GuardianSet(address indexed _owner, address guardian); /// @notice An event emitted when a transaction is executed event TransactionExecuted( address indexed target, uint256 value, string signature, bytes data ); /** * @notice Constructor * @param _guardian The guardian address */ constructor(address _guardian) { require( _guardian != address(0), "Orchestrator::constructor: guardian can't be zero" ); guardian = _guardian; } /// @notice Throws if called by any account other than the guardian modifier onlyGuardian() { require( msg.sender == guardian, "Orchestrator::onlyGuardian: caller is not the guardian" ); _; } /** * @notice Throws if vault is not valid. * @param _vault address */ modifier validVault(IVaultHandler _vault) { require( ERC165Checker.supportsInterface(address(_vault), _INTERFACE_ID_IVAULT), "Orchestrator::validVault: not a valid vault" ); _; } /** * @notice Throws if TCAP Token is not valid * @param _tcap address */ modifier validTCAP(TCAP _tcap) { require( ERC165Checker.supportsInterface(address(_tcap), _INTERFACE_ID_TCAP), "Orchestrator::validTCAP: not a valid TCAP ERC20" ); _; } /** * @notice Throws if Chainlink Oracle is not valid * @param _oracle address */ modifier validChainlinkOracle(address _oracle) { require( ERC165Checker.supportsInterface( address(_oracle), _INTERFACE_ID_CHAINLINK_ORACLE ), "Orchestrator::validChainlinkOrchestrator: not a valid Chainlink Oracle" ); _; } /** * @notice Sets the guardian of the orchestrator * @param _guardian address of the guardian * @dev Only owner can call it */ function setGuardian(address _guardian) external onlyOwner { require( _guardian != address(0), "Orchestrator::setGuardian: guardian can't be zero" ); guardian = _guardian; emit GuardianSet(msg.sender, _guardian); } /** * @notice Sets the ratio of a vault * @param _vault address * @param _ratio value * @dev Only owner can call it */ function setRatio(IVaultHandler _vault, uint256 _ratio) external onlyOwner validVault(_vault) { _vault.setRatio(_ratio); } /** * @notice Sets the burn fee of a vault * @param _vault address * @param _burnFee value * @dev Only owner can call it */ function setBurnFee(IVaultHandler _vault, uint256 _burnFee) external onlyOwner validVault(_vault) { _vault.setBurnFee(_burnFee); } /** * @notice Sets the burn fee to 0, only used on a black swan event * @param _vault address * @dev Only guardian can call it * @dev Validates if _vault is valid */ function setEmergencyBurnFee(IVaultHandler _vault) external onlyGuardian validVault(_vault) { require( emergencyCalled[_vault][Functions.BURNFEE] != true, "Orchestrator::setEmergencyBurnFee: emergency call already used" ); emergencyCalled[_vault][Functions.BURNFEE] = true; _vault.setBurnFee(0); } /** * @notice Sets the liquidation penalty of a vault * @param _vault address * @param _liquidationPenalty value * @dev Only owner can call it */ function setLiquidationPenalty( IVaultHandler _vault, uint256 _liquidationPenalty ) external onlyOwner validVault(_vault) { _vault.setLiquidationPenalty(_liquidationPenalty); } /** * @notice Sets the liquidation penalty of a vault to 0, only used on a black swan event * @param _vault address * @dev Only guardian can call it * @dev Validates if _vault is valid */ function setEmergencyLiquidationPenalty(IVaultHandler _vault) external onlyGuardian validVault(_vault) { require( emergencyCalled[_vault][Functions.LIQUIDATION] != true, "Orchestrator::setEmergencyLiquidationPenalty: emergency call already used" ); emergencyCalled[_vault][Functions.LIQUIDATION] = true; _vault.setLiquidationPenalty(0); } /** * @notice Pauses the Vault * @param _vault address * @dev Only guardian can call it * @dev Validates if _vault is valid */ function pauseVault(IVaultHandler _vault) external onlyGuardian validVault(_vault) { require( emergencyCalled[_vault][Functions.PAUSE] != true, "Orchestrator::pauseVault: emergency call already used" ); emergencyCalled[_vault][Functions.PAUSE] = true; _vault.pause(); } /** * @notice Unpauses the Vault * @param _vault address * @dev Only guardian can call it * @dev Validates if _vault is valid */ function unpauseVault(IVaultHandler _vault) external onlyGuardian validVault(_vault) { _vault.unpause(); } /** * @notice Enables or disables the TCAP Cap * @param _tcap address * @param _enable bool * @dev Only owner can call it * @dev Validates if _tcap is valid */ function enableTCAPCap(TCAP _tcap, bool _enable) external onlyOwner validTCAP(_tcap) { _tcap.enableCap(_enable); } /** * @notice Sets the TCAP maximum minting value * @param _tcap address * @param _cap uint value * @dev Only owner can call it * @dev Validates if _tcap is valid */ function setTCAPCap(TCAP _tcap, uint256 _cap) external onlyOwner validTCAP(_tcap) { _tcap.setCap(_cap); } /** * @notice Adds Vault to TCAP ERC20 * @param _tcap address * @param _vault address * @dev Only owner can call it * @dev Validates if _tcap is valid * @dev Validates if _vault is valid */ function addTCAPVault(TCAP _tcap, IVaultHandler _vault) external onlyOwner validTCAP(_tcap) validVault(_vault) { _tcap.addVaultHandler(address(_vault)); } /** * @notice Removes Vault to TCAP ERC20 * @param _tcap address * @param _vault address * @dev Only owner can call it * @dev Validates if _tcap is valid * @dev Validates if _vault is valid */ function removeTCAPVault(TCAP _tcap, IVaultHandler _vault) external onlyOwner validTCAP(_tcap) validVault(_vault) { _tcap.removeVaultHandler(address(_vault)); } /** * @notice Allows the owner to execute custom transactions * @param target address * @param value uint256 * @param signature string * @param data bytes * @dev Only owner can call it */ function executeTransaction( address target, uint256 value, string memory signature, bytes memory data ) external payable onlyOwner returns (bytes memory) { bytes memory callData; if (bytes(signature).length == 0) { callData = data; } else { callData = abi.encodePacked(bytes4(keccak256(bytes(signature))), data); } require( target != address(0), "Orchestrator::executeTransaction: target can't be zero" ); // solium-disable-next-line security/no-call-value (bool success, bytes memory returnData) = target.call{value : value}(callData); require( success, "Orchestrator::executeTransaction: Transaction execution reverted." ); emit TransactionExecuted(target, value, signature, data); (target, value, signature, data); return returnData; } /** * @notice Retrieves the eth stuck on the orchestrator * @param _to address * @dev Only owner can call it */ function retrieveETH(address _to) external onlyOwner { require( _to != address(0), "Orchestrator::retrieveETH: address can't be zero" ); uint256 amount = address(this).balance; payable(_to).transfer(amount); } /// @notice Allows the contract to receive ETH receive() external payable {} }
// SPDX-License-Identifier: MIT pragma solidity 0.7.5; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/introspection/IERC165.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "./Orchestrator.sol"; /** * @title Total Market Cap Token * @author Cryptex.finance * @notice ERC20 token on the Ethereum Blockchain that provides total exposure to the cryptocurrency sector. */ contract TCAP is ERC20, Ownable, IERC165 { /// @notice Open Zeppelin libraries using SafeMath for uint256; /// @notice if enabled TCAP can't be minted if the total supply is above or equal the cap value bool public capEnabled = false; /// @notice Maximum value the total supply of TCAP uint256 public cap; /** * @notice Address to Vault Handler * @dev Only vault handlers can mint and burn TCAP */ mapping(address => bool) public vaultHandlers; /** * @dev the computed interface ID according to ERC-165. The interface ID is a XOR of interface method selectors. * mint.selector ^ * burn.selector ^ * setCap.selector ^ * enableCap.selector ^ * transfer.selector ^ * transferFrom.selector ^ * addVaultHandler.selector ^ * removeVaultHandler.selector ^ * approve.selector => 0xbd115939 */ bytes4 private constant _INTERFACE_ID_TCAP = 0xbd115939; /// @dev bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7 bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7; /// @notice An event emitted when a vault handler is added event VaultHandlerAdded( address indexed _owner, address indexed _tokenHandler ); /// @notice An event emitted when a vault handler is removed event VaultHandlerRemoved( address indexed _owner, address indexed _tokenHandler ); /// @notice An event emitted when the cap value is updated event NewCap(address indexed _owner, uint256 _amount); /// @notice An event emitted when the cap is enabled or disabled event NewCapEnabled(address indexed _owner, bool _enable); /** * @notice Constructor * @param _name uint256 * @param _symbol uint256 * @param _cap uint256 * @param _orchestrator address */ constructor( string memory _name, string memory _symbol, uint256 _cap, Orchestrator _orchestrator ) ERC20(_name, _symbol) { cap = _cap; /// @dev transfer ownership to orchestrator transferOwnership(address(_orchestrator)); } /// @notice Reverts if called by any account that is not a vault. modifier onlyVault() { require( vaultHandlers[msg.sender], "TCAP::onlyVault: caller is not a vault" ); _; } /** * @notice Adds a new address as a vault * @param _vaultHandler address of a contract with permissions to mint and burn tokens * @dev Only owner can call it */ function addVaultHandler(address _vaultHandler) external onlyOwner { vaultHandlers[_vaultHandler] = true; emit VaultHandlerAdded(msg.sender, _vaultHandler); } /** * @notice Removes an address as a vault * @param _vaultHandler address of the contract to be removed as vault * @dev Only owner can call it */ function removeVaultHandler(address _vaultHandler) external onlyOwner { vaultHandlers[_vaultHandler] = false; emit VaultHandlerRemoved(msg.sender, _vaultHandler); } /** * @notice Mints TCAP Tokens * @param _account address of the receiver of tokens * @param _amount uint of tokens to mint * @dev Only vault can call it */ function mint(address _account, uint256 _amount) external onlyVault { _mint(_account, _amount); } /** * @notice Burns TCAP Tokens * @param _account address of the account which is burning tokens. * @param _amount uint of tokens to burn * @dev Only vault can call it */ function burn(address _account, uint256 _amount) external onlyVault { _burn(_account, _amount); } /** * @notice Sets maximum value the total supply of TCAP can have * @param _cap value * @dev When capEnabled is true, mint is not allowed to issue tokens that would increase the total supply above or equal the specified capacity. * @dev Only owner can call it */ function setCap(uint256 _cap) external onlyOwner { cap = _cap; emit NewCap(msg.sender, _cap); } /** * @notice Enables or Disables the Total Supply Cap. * @param _enable value * @dev When capEnabled is true, minting will not be allowed above the max capacity. It can exist a supply above the cap, but it prevents minting above the cap. * @dev Only owner can call it */ function enableCap(bool _enable) external onlyOwner { capEnabled = _enable; emit NewCapEnabled(msg.sender, _enable); } /** * @notice ERC165 Standard for support of interfaces * @param _interfaceId bytes of interface * @return bool */ function supportsInterface(bytes4 _interfaceId) external pure override returns (bool) { return (_interfaceId == _INTERFACE_ID_TCAP || _interfaceId == _INTERFACE_ID_ERC165); } /** * @notice executes before each token transfer or mint * @param _from address * @param _to address * @param _amount value to transfer * @dev See {ERC20-_beforeTokenTransfer}. * @dev minted tokens must not cause the total supply to go over the cap. * @dev Reverts if the to address is equal to token address */ function _beforeTokenTransfer( address _from, address _to, uint256 _amount ) internal virtual override { super._beforeTokenTransfer(_from, _to, _amount); require( _to != address(this), "TCAP::transfer: can't transfer to TCAP contract" ); if (_from == address(0) && capEnabled) { // When minting tokens require( totalSupply().add(_amount) <= cap, "TCAP::Transfer: TCAP cap exceeded" ); } } }
// SPDX-License-Identifier: MIT pragma solidity 0.7.5; import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/introspection/IERC165.sol"; /** * @title Chainlink Oracle * @author Cryptex.finance * @notice Contract in charge or reading the information from a Chainlink Oracle. TCAP contracts read the price directly from this contract. More information can be found on Chainlink Documentation */ contract ChainlinkOracle is Ownable, IERC165 { AggregatorV3Interface internal aggregatorContract; /* * setReferenceContract.selector ^ * getLatestAnswer.selector ^ * getLatestTimestamp.selector ^ * getPreviousAnswer.selector ^ * getPreviousTimestamp.selector => 0x85be402b */ bytes4 private constant _INTERFACE_ID_CHAINLINK_ORACLE = 0x85be402b; /* * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7 */ bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7; /** * @notice Called once the contract is deployed. * Set the Chainlink Oracle as an aggregator. */ constructor(address _aggregator, address _owner) { require(_aggregator != address(0) && _owner != address(0), "address can't be 0"); aggregatorContract = AggregatorV3Interface(_aggregator); transferOwnership(_owner); } /** * @notice Changes the reference contract. * @dev Only owner can call it. */ function setReferenceContract(address _aggregator) public onlyOwner() { aggregatorContract = AggregatorV3Interface(_aggregator); } /** * @notice Returns the latest answer from the reference contract. * @return price */ function getLatestAnswer() public view returns (int256) { ( uint80 roundID, int256 price, , uint256 timeStamp, uint80 answeredInRound ) = aggregatorContract.latestRoundData(); require( timeStamp != 0, "ChainlinkOracle::getLatestAnswer: round is not complete" ); require( answeredInRound >= roundID, "ChainlinkOracle::getLatestAnswer: stale data" ); return price; } /** * @notice Returns the latest round from the reference contract. */ function getLatestRound() public view returns ( uint80, int256, uint256, uint256, uint80 ) { ( uint80 roundID, int256 price, uint256 startedAt, uint256 timeStamp, uint80 answeredInRound ) = aggregatorContract.latestRoundData(); return (roundID, price, startedAt, timeStamp, answeredInRound); } /** * @notice Returns a given round from the reference contract. * @param _id of round */ function getRound(uint80 _id) public view returns ( uint80, int256, uint256, uint256, uint80 ) { ( uint80 roundID, int256 price, uint256 startedAt, uint256 timeStamp, uint80 answeredInRound ) = aggregatorContract.getRoundData(_id); return (roundID, price, startedAt, timeStamp, answeredInRound); } /** * @notice Returns the last time the Oracle was updated. */ function getLatestTimestamp() public view returns (uint256) { (, , , uint256 timeStamp, ) = aggregatorContract.latestRoundData(); return timeStamp; } /** * @notice Returns a previous answer updated on the Oracle. * @param _id of round * @return price */ function getPreviousAnswer(uint80 _id) public view returns (int256) { (uint80 roundID, int256 price, , , ) = aggregatorContract.getRoundData(_id); require( _id <= roundID, "ChainlinkOracle::getPreviousAnswer: not enough history" ); return price; } /** * @notice Returns a previous time the Oracle was updated. * @param _id of round * @return timeStamp */ function getPreviousTimestamp(uint80 _id) public view returns (uint256) { (uint80 roundID, , , uint256 timeStamp, ) = aggregatorContract.getRoundData(_id); require( _id <= roundID, "ChainlinkOracle::getPreviousTimestamp: not enough history" ); return timeStamp; } /** * @notice ERC165 Standard for support of interfaces. */ function supportsInterface(bytes4 interfaceId) external pure override returns (bool) { return (interfaceId == _INTERFACE_ID_CHAINLINK_ORACLE || interfaceId == _INTERFACE_ID_ERC165); } }
{ "evmVersion": "istanbul", "libraries": {}, "metadata": { "bytecodeHash": "ipfs", "useLiteralContent": true }, "optimizer": { "enabled": true, "runs": 200 }, "remappings": [], "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"contract Orchestrator","name":"_orchestrator","type":"address"},{"internalType":"uint256","name":"_divisor","type":"uint256"},{"internalType":"uint256","name":"_ratio","type":"uint256"},{"internalType":"uint256","name":"_burnFee","type":"uint256"},{"internalType":"uint256","name":"_liquidationPenalty","type":"uint256"},{"internalType":"address","name":"_tcapOracle","type":"address"},{"internalType":"contract TCAP","name":"_tcapAddress","type":"address"},{"internalType":"address","name":"_collateralAddress","type":"address"},{"internalType":"address","name":"_collateralOracle","type":"address"},{"internalType":"address","name":"_ethOracle","type":"address"},{"internalType":"address","name":"_treasury","type":"address"},{"internalType":"uint256","name":"_minimumTCAP","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"_id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"CollateralAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"_id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"CollateralRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"_burnFee","type":"uint256"}],"name":"NewBurnFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"_liquidationPenalty","type":"uint256"}],"name":"NewLiquidationPenalty","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"_minimumTCAP","type":"uint256"}],"name":"NewMinimumTCAP","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"_ratio","type":"uint256"}],"name":"NewRatio","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":false,"internalType":"address","name":"_tresury","type":"address"}],"name":"NewTreasury","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_token","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"Recovered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"_id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"TokensBurned","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"_id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"TokensMinted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"_id","type":"uint256"}],"name":"VaultCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_vaultId","type":"uint256"},{"indexed":true,"internalType":"address","name":"_liquidator","type":"address"},{"indexed":false,"internalType":"uint256","name":"_liquidationCollateral","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_reward","type":"uint256"}],"name":"VaultLiquidated","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ETHPriceOracle","outputs":[{"internalType":"contract ChainlinkOracle","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_DECIMAL_PLACES","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_FEE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_RATIO","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TCAPPrice","outputs":[{"internalType":"uint256","name":"price","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TCAPToken","outputs":[{"internalType":"contract TCAP","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"addCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"burnFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"collateralContract","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"collateralDecimalsAdjustmentFactor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"collateralPriceOracle","outputs":[{"internalType":"contract ChainlinkOracle","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"counter","outputs":[{"internalType":"uint256","name":"_value","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"createVault","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"divisor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"getFee","outputs":[{"internalType":"uint256","name":"fee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ChainlinkOracle","name":"_oracle","type":"address"}],"name":"getOraclePrice","outputs":[{"internalType":"uint256","name":"price","type":"uint256"}],"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":"uint256","name":"_id","type":"uint256"}],"name":"getVault","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_vaultId","type":"uint256"}],"name":"getVaultRatio","outputs":[{"internalType":"uint256","name":"currentRatio","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":"uint256","name":"_vaultId","type":"uint256"},{"internalType":"uint256","name":"_maxTCAP","type":"uint256"}],"name":"liquidateVault","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"liquidationPenalty","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_vaultId","type":"uint256"}],"name":"liquidationReward","outputs":[{"internalType":"uint256","name":"rewardCollateral","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minimumTCAP","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"oracleDigits","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ratio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_tokenAddress","type":"address"},{"internalType":"uint256","name":"_tokenAmount","type":"uint256"}],"name":"recoverERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"removeCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"requiredCollateral","outputs":[{"internalType":"uint256","name":"collateral","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_vaultId","type":"uint256"}],"name":"requiredLiquidationTCAP","outputs":[{"internalType":"uint256","name":"amount","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":[{"internalType":"uint256","name":"_burnFee","type":"uint256"}],"name":"setBurnFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_liquidationPenalty","type":"uint256"}],"name":"setLiquidationPenalty","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minimumTCAP","type":"uint256"}],"name":"setMinimumTCAP","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_ratio","type":"uint256"}],"name":"setRatio","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_treasury","type":"address"}],"name":"setTreasury","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"tcapOracle","outputs":[{"internalType":"contract ChainlinkOracle","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"treasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userToVault","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"vaults","outputs":[{"internalType":"uint256","name":"Id","type":"uint256"},{"internalType":"uint256","name":"Collateral","type":"uint256"},{"internalType":"uint256","name":"Debt","type":"uint256"},{"internalType":"address","name":"Owner","type":"address"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
61014060405260006009553480156200001757600080fd5b50604051620044b4380380620044b483398181016040526101808110156200003e57600080fd5b508051602082015160408301516060840151608085015160a086015160c087015160e08801516101008901516101208a01516101408b0151610160909b0151999a9899979896979596949593949293919290918b8b8b8b8b8b8b8b8b8b8b8b6000620000a96200034d565b600080546001600160a01b0319166001600160a01b03831690811782556040519293509160008051602062004494833981519152908290a35060016002556003805460ff19169055896200010b89606462000351602090811b62002afb17901c565b10620001495760405162461bcd60e51b8152600401808060200182810382526037815260200180620043f36037913960400191505060405180910390fd5b60648a10156200018b5760405162461bcd60e51b8152600401808060200182810382526035815260200180620043986035913960400191505060405180910390fd5b6103e8891115620001ce5760405162461bcd60e51b81526004018080602001828103825260378152602001806200442a6037913960400191505060405180910390fd5b60058b905560068a9055600789905560088890556001600160601b0319606088811b821660c05286811b821660e05285811b82166101005284811b82166101205287901b1660a052600a80546001600160a01b038481166001600160a01b03199092169190911790915560098290556040805163313ce56760e01b8152905160009288169163313ce567916004808301926020929190829003018186803b1580156200027957600080fd5b505afa1580156200028e573d6000803e3d6000fd5b505050506040513d6020811015620002a557600080fd5b50519050601260ff82161115620002ee5760405162461bcd60e51b8152600401808060200182810382526033815260200180620044616033913960400191505060405180910390fd5b8060120360ff16600a0a60808181525050620003166004620003b560201b62002b551760201c565b62000323600033620003be565b6200032e8d620003ce565b50505050505050505050505050505050505050505050505050620005bf565b3390565b600082820183811015620003ac576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b90505b92915050565b80546001019055565b620003ca8282620004cc565b5050565b620003d86200034d565b6000546001600160a01b039081169116146200043b576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b038116620004825760405162461bcd60e51b8152600401808060200182810382526026815260200180620043cd6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216916000805160206200449483398151915291a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6000828152600160209081526040909120620004f391839062002b5e62000547821b17901c565b15620003ca57620005036200034d565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000620003ac836001600160a01b0384166000620005668383620005a7565b6200059e57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155620003af565b506000620003af565b60009081526001919091016020526040902054151590565b60805160a05160601c60c05160601c60e05160601c6101005160601c6101205160601c613d306200066860003980611f895280612ab9525080610bd852806118b15280611ad752806122de52806127e652508061102f528061198d5280611e6952806125cd52806126f0525080610c84528061142d52508061176752806122215280612e66525080610c295280611b1e5280611fad5280612309528061281b5250613d306000f3fe6080604052600436106103355760003560e01c8063842e357c116101ab578063a217fddf116100f7578063ca15c87311610095578063f0f442601161006f578063f0f4426014610a86578063f2fde38b14610ab9578063fce589d814610aec578063fcee45f414610b0157610335565b8063ca15c873146109f9578063d547741f14610a23578063de9952c914610a5c57610335565b8063bc063e1a116100d1578063bc063e1a14610972578063bc721a9614610987578063bcc46e83146109ba578063c6e1c7c9146109e457610335565b8063a217fddf14610909578063abb7bc4a1461091e578063b2237ba31461094857610335565b80639010d07c11610164578063952cc86a1161013e578063952cc86a1461089257806397994e30146108b55780639d9b5818146108ca578063a0712d68146108df57610335565b80639010d07c146107d157806391d14854146108015780639403b6341461083a57610335565b8063842e357c146106d65780638456cb59146106eb5780638980f11f146107005780638c01f211146107395780638c64ea4a146107635780638da5cb5b146107bc57610335565b8063422b91811161028557806361bc221a116102235780636ca2143c116101fd5780636ca2143c14610664578063715018a61461067957806371ca337d1461068e57806375f620ac146106a357610335565b806361bc221a1461062557806361d027b31461063a5780636ae7adc11461064f57610335565b80634bf2c7c91161025f5780634bf2c7c9146105a7578063574b786d146105d15780635c975abb146105fb5780635d12928b1461061057610335565b8063422b91811461056057806342966c681461057557806346dc90071461059257610335565b8063248a9ca3116102f25780632f2ff15d116102cc5780632f2ff15d146104af5780633237c158146104e857806336568abe146105125780633f4ba83a1461054b57610335565b8063248a9ca31461042e5780632806a743146104585780632c5a81421461048457610335565b806301ffc9a71461033a5780630f0aeb8d1461038257806311d850e8146103a95780631cc244ba146103d35780631f2dc5ef1461040457806323f5589a14610419575b600080fd5b34801561034657600080fd5b5061036e6004803603602081101561035d57600080fd5b50356001600160e01b031916610b2b565b604080519115158252519081900360200190f35b34801561038e57600080fd5b50610397610b62565b60408051918252519081900360200190f35b3480156103b557600080fd5b50610397600480360360208110156103cc57600080fd5b5035610b67565b3480156103df57600080fd5b506103e8610c82565b604080516001600160a01b039092168252519081900360200190f35b34801561041057600080fd5b50610397610ca6565b34801561042557600080fd5b50610397610cac565b34801561043a57600080fd5b506103976004803603602081101561045157600080fd5b5035610cb2565b34801561046457600080fd5b506104826004803603602081101561047b57600080fd5b5035610cc7565b005b34801561049057600080fd5b50610499610da7565b6040805160ff9092168252519081900360200190f35b3480156104bb57600080fd5b50610482600480360360408110156104d257600080fd5b50803590602001356001600160a01b0316610dac565b3480156104f457600080fd5b506104826004803603602081101561050b57600080fd5b5035610e18565b34801561051e57600080fd5b506104826004803603604081101561053557600080fd5b50803590602001356001600160a01b0316611121565b34801561055757600080fd5b50610482611182565b34801561056c57600080fd5b506103976111e4565b6104826004803603602081101561058b57600080fd5b50356111ea565b34801561059e57600080fd5b50610397611425565b3480156105b357600080fd5b50610482600480360360208110156105ca57600080fd5b503561146e565b3480156105dd57600080fd5b50610482600480360360208110156105f457600080fd5b5035611545565b34801561060757600080fd5b5061036e6115db565b34801561061c57600080fd5b506104826115e4565b34801561063157600080fd5b50610397611747565b34801561064657600080fd5b506103e861174d565b34801561065b57600080fd5b5061039761175c565b34801561067057600080fd5b506103e8611765565b34801561068557600080fd5b50610482611789565b34801561069a57600080fd5b5061039761182b565b3480156106af57600080fd5b50610397600480360360208110156106c657600080fd5b50356001600160a01b0316611831565b3480156106e257600080fd5b506103e86118af565b3480156106f757600080fd5b506104826118d3565b34801561070c57600080fd5b506104826004803603604081101561072357600080fd5b506001600160a01b038135169060200135611933565b34801561074557600080fd5b506103976004803603602081101561075c57600080fd5b5035611a60565b34801561076f57600080fd5b5061078d6004803603602081101561078657600080fd5b5035611b66565b604080519485526020850193909352838301919091526001600160a01b03166060830152519081900360800190f35b3480156107c857600080fd5b506103e8611b96565b3480156107dd57600080fd5b506103e8600480360360408110156107f457600080fd5b5080359060200135611ba5565b34801561080d57600080fd5b5061036e6004803603604081101561082457600080fd5b50803590602001356001600160a01b0316611bc4565b34801561084657600080fd5b506108646004803603602081101561085d57600080fd5b5035611bdc565b6040805194855260208501939093526001600160a01b03909116838301526060830152519081900360800190f35b610482600480360360408110156108a857600080fd5b5080359060200135611c43565b3480156108c157600080fd5b506103e8611f87565b3480156108d657600080fd5b50610397611fab565b3480156108eb57600080fd5b506104826004803603602081101561090257600080fd5b5035611fcf565b34801561091557600080fd5b506103976122c5565b34801561092a57600080fd5b506103976004803603602081101561094157600080fd5b50356122ca565b34801561095457600080fd5b506104826004803603602081101561096b57600080fd5b503561234a565b34801561097e57600080fd5b5061039761246c565b34801561099357600080fd5b50610397600480360360208110156109aa57600080fd5b50356001600160a01b0316612472565b3480156109c657600080fd5b50610482600480360360208110156109dd57600080fd5b5035612484565b3480156109f057600080fd5b506103e86126ee565b348015610a0557600080fd5b5061039760048036036020811015610a1c57600080fd5b5035612712565b348015610a2f57600080fd5b5061048260048036036040811015610a4657600080fd5b50803590602001356001600160a01b0316612729565b348015610a6857600080fd5b5061039760048036036020811015610a7f57600080fd5b5035612782565b348015610a9257600080fd5b5061048260048036036020811015610aa957600080fd5b50356001600160a01b03166128bf565b348015610ac557600080fd5b5061048260048036036020811015610adc57600080fd5b50356001600160a01b03166129b3565b348015610af857600080fd5b50610397612aab565b348015610b0d57600080fd5b5061039760048036036020811015610b2457600080fd5b5035612ab1565b60006001600160e01b0319821663279d6ac360e21b1480610b5c57506001600160e01b031982166301ffc9a760e01b145b92915050565b606481565b6000610b7161364d565b506000828152600c60209081526040808320815160808101835281548152600182015493810193909352600281015491830191909152600301546001600160a01b0316606082015290610bc384612782565b90506000610bcf611425565b90506000610bfc7f0000000000000000000000000000000000000000000000000000000000000000611831565b90506000610c20610c196064600854612afb90919063ffffffff16565b8590612b73565b90506000610c667f0000000000000000000000000000000000000000000000000000000000000000610c60610c56866064612b73565b610c608689612b73565b90612bcc565b9050610c76866020015182612c0e565b98975050505050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b60055481565b60085481565b60009081526001602052604090206002015490565b610ccf612c24565b6000546001600160a01b03908116911614610d1f576040805162461bcd60e51b81526020600482018190526024820152600080516020613b1b833981519152604482015290519081900360640190fd5b600654610d2d826064612afb565b10610d695760405162461bcd60e51b8152600401808060200182810382526041815260200180613a436041913960600191505060405180910390fd5b600881905560408051828152905133917f76fea7ef18b6b073facb4f15d873d45dc60e1ac9448931a44b388f40c49e3267919081900360200190a250565b601281565b600082815260016020526040902060020154610dcf90610dca612c24565b611bc4565b610e0a5760405162461bcd60e51b815260040180806020018281038252602f81526020018061370c602f913960400191505060405180910390fd5b610e148282612c28565b5050565b600280541415610e5d576040805162461bcd60e51b815260206004820152601f602482015260008051602061373b833981519152604482015290519081900360640190fd5b60028055336000908152600b6020526040902054610eac5760405162461bcd60e51b815260040180806020018281038252602b815260200180613780602b913960400191505060405180910390fd5b60035460ff1615610ef7576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b8080610f345760405162461bcd60e51b8152600401808060200182810382526027815260200180613be56027913960400191505060405180910390fd5b336000908152600b60209081526040808320548352600c90915281208054909190610f5e90611a60565b90508382600101541015610fa35760405162461bcd60e51b81526004018080602001828103825260468152602001806139fd6046913960600191505060405180910390fd5b6001820154610fb29085612c91565b60018301558015611008576006548254610fcb90611a60565b10156110085760405162461bcd60e51b8152600401808060200182810382526043815260200180613a846043913960600191505060405180910390fd5b6040805163a9059cbb60e01b81523360048201526024810186905290516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163a9059cbb9160448083019260209291908290030181600087803b15801561107757600080fd5b505af115801561108b573d6000803e3d6000fd5b505050506040513d60208110156110a157600080fd5b50516110de5760405162461bcd60e51b815260040180806020018281038252603e815260200180613b72603e913960400191505060405180910390fd5b815460408051868152905133917f47e1336b6fdb5f42c3a1d28b558fa98786d820c3705d726358dcc8e63a401eef919081900360200190a3505060016002555050565b611129612c24565b6001600160a01b0316816001600160a01b0316146111785760405162461bcd60e51b815260040180806020018281038252602f815260200180613ccc602f913960400191505060405180910390fd5b610e148282612cd3565b61118a612c24565b6000546001600160a01b039081169116146111da576040805162461bcd60e51b81526020600482018190526024820152600080516020613b1b833981519152604482015290519081900360640190fd5b6111e2612d3c565b565b60095481565b60028054141561122f576040805162461bcd60e51b815260206004820152601f602482015260008051602061373b833981519152604482015290519081900360640190fd5b60028055336000908152600b602052604090205461127e5760405162461bcd60e51b815260040180806020018281038252602b815260200180613780602b913960400191505060405180910390fd5b60035460ff16156112c9576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b80806113065760405162461bcd60e51b8152600401808060200182810382526027815260200180613be56027913960400191505060405180910390fd5b600061131183612ab1565b9050803410156113525760405162461bcd60e51b815260040180806020018281038252602f815260200180613c64602f913960400191505060405180910390fd5b61135a61364d565b50336000908152600b60209081526040808320548352600c82529182902082516080810184528154808252600183015493820193909352600282015493810193909352600301546001600160a01b031660608301526113b99085612dda565b600a546113cf906001600160a01b031683612eca565b6113e2336113dd3485612c91565b612eca565b805160408051868152905133917fccbea4088a3b7ae9ca2d15fab9a9742a4075b4d7247768a1eecea917565aba00919081900360200190a3505060016002555050565b6000806114517f0000000000000000000000000000000000000000000000000000000000000000611831565b905061146860055482612bcc90919063ffffffff16565b91505090565b611476612c24565b6000546001600160a01b039081169116146114c6576040805162461bcd60e51b81526020600482018190526024820152600080516020613b1b833981519152604482015290519081900360640190fd5b6103e88111156115075760405162461bcd60e51b81526004018080602001828103825260368152602001806139c76036913960400191505060405180910390fd5b600781905560408051828152905133917f2b29c7e5fe28010036a94929b56a0eb76bf5e90700e842a971eaa6e4abc45f04919081900360200190a250565b61154d612c24565b6000546001600160a01b0390811691161461159d576040805162461bcd60e51b81526020600482018190526024820152600080516020613b1b833981519152604482015290519081900360640190fd5b600981905560408051828152905133917fb276aeff8481b22fb866569892ac1e4127fe82fefd28354c38957d5dc76bd86c919081900360200190a250565b60035460ff1690565b60035460ff161561162f576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b336000908152600b60205260409020541561167b5760405162461bcd60e51b815260040180806020018281038252603081526020018061367f6030913960400191505060405180910390fd5b60006116876004612fc2565b336000908152600b6020526040902081905590506116a361364d565b5060408051608081018252828152600060208083018281528385018381523360608601908152878552600c909352949092208351815591516001830155925160028201559151600390920180546001600160a01b0319166001600160a01b03909316929092179091556117166004612b55565b604051829033907fa510df27d6e51efd91d3f55722bad1f26bf924a63e5dcee07c2ab4c3d4992dcc90600090a35050565b60045481565b600a546001600160a01b031681565b6402540be40081565b7f000000000000000000000000000000000000000000000000000000000000000081565b611791612c24565b6000546001600160a01b039081169116146117e1576040805162461bcd60e51b81526020600482018190526024820152600080516020613b1b833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b60065481565b6000610b5c6402540be4006118a9846001600160a01b03166396237c026040518163ffffffff1660e01b815260040160206040518083038186803b15801561187857600080fd5b505afa15801561188c573d6000803e3d6000fd5b505050506040513d60208110156118a257600080fd5b5051612fc6565b90612b73565b7f000000000000000000000000000000000000000000000000000000000000000081565b6118db612c24565b6000546001600160a01b0390811691161461192b576040805162461bcd60e51b81526020600482018190526024820152600080516020613b1b833981519152604482015290519081900360640190fd5b6111e2613021565b61193b612c24565b6000546001600160a01b0390811691161461198b576040805162461bcd60e51b81526020600482018190526024820152600080516020613b1b833981519152604482015290519081900360640190fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b031614156119fc5760405162461bcd60e51b815260040180806020018281038252602581526020018061375b6025913960400191505060405180910390fd5b611a18611a07611b96565b6001600160a01b03841690836130a2565b604080516001600160a01b03841681526020810183905281517f8c1256b8896378cd5044f80c202f9772b9d77dc85c8a6eb51967210b09bfaa28929181900390910190a15050565b6000611a6a61364d565b506000828152600c602090815260409182902082516080810184528154808252600183015493820193909352600282015493810193909352600301546001600160a01b031660608301521580611ac257506040810151155b15611ad05760009150611b60565b6000611afb7f0000000000000000000000000000000000000000000000000000000000000000611831565b9050611b5c611b16611b0b611425565b604085015190612b73565b610c60611b557f00000000000000000000000000000000000000000000000000000000000000006118a960648860200151612b7390919063ffffffff16565b8490612b73565b9250505b50919050565b600c602052600090815260409020805460018201546002830154600390930154919290916001600160a01b031684565b6000546001600160a01b031690565b6000828152600160205260408120611bbd90836130f4565b9392505050565b6000828152600160205260408120611bbd9083613100565b600080600080611bea61364d565b50505060009283525050600c602090815260409182902082516080810184528154808252600183015493820184905260028301549482018590526003909201546001600160a01b03166060909101819052909391929091565b600280541415611c88576040805162461bcd60e51b815260206004820152601f602482015260008051602061373b833981519152604482015290519081900360640190fd5b6002805560035460ff1615611cd7576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6000828152600c602052604090208054611d225760405162461bcd60e51b815260040180806020018281038252602e815260200180613c36602e913960400191505060405180910390fd5b6000611d318260000154611a60565b90506006548110611d735760405162461bcd60e51b8152600401808060200182810382526035815260200180613bb06035913960400191505060405180910390fd5b6000611d828360000154612782565b905080841015611dc35760405162461bcd60e51b815260040180806020018281038252604881526020018061385b6048913960600191505060405180910390fd5b6000611dce82612ab1565b905080341015611e0f5760405162461bcd60e51b8152600401808060200182810382526039815260200180613c936039913960400191505060405180910390fd5b6000611e1e8560000154610b67565b9050611e2e856000015484612dda565b6001850154611e3d9082612c91565b60018601556040805163a9059cbb60e01b81523360048201526024810183905290516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163a9059cbb9160448083019260209291908290030181600087803b158015611eb157600080fd5b505af1158015611ec5573d6000803e3d6000fd5b505050506040513d6020811015611edb57600080fd5b5051611f185760405162461bcd60e51b815260040180806020018281038252603c8152602001806138a3603c913960400191505060405180910390fd5b600a54611f2e906001600160a01b031683612eca565b611f3c336113dd3485612c91565b8454604080518581526020810184905281513393927fba5789da846390370bbfbf693007be2c95d0cfac69a8d175805f742dc7938321928290030190a3505060016002555050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b600280541415612014576040805162461bcd60e51b815260206004820152601f602482015260008051602061373b833981519152604482015290519081900360640190fd5b60028055336000908152600b60205260409020546120635760405162461bcd60e51b815260040180806020018281038252602b815260200180613780602b913960400191505060405180910390fd5b60035460ff16156120ae576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b80806120eb5760405162461bcd60e51b8152600401808060200182810382526027815260200180613be56027913960400191505060405180910390fd5b336000908152600b60209081526040808320548352600c909152812090612111846122ca565b905080826001015410156121565760405162461bcd60e51b81526004018080602001828103825260298152602001806138006029913960400191505060405180910390fd5b60028201546121659085612afb565b6002830155600654825461217890611a60565b10156121b55760405162461bcd60e51b8152600401808060200182810382526037815260200180613b3b6037913960400191505060405180910390fd5b600954826002015410156121fa5760405162461bcd60e51b81526004018080602001828103825260328152602001806138296032913960400191505060405180910390fd5b604080516340c10f1960e01b81523360048201526024810186905290516001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016916340c10f1991604480830192600092919082900301818387803b15801561226857600080fd5b505af115801561227c573d6000803e3d6000fd5b505083546040805188815290519193503392507f2e8ac5177a616f2aec08c3048f5021e4e9743ece034e8d83ba5caf76688bb475919081900360200190a3505060016002555050565b600081565b6000806122d5611425565b905060006123027f0000000000000000000000000000000000000000000000000000000000000000611831565b9050611b5c7f0000000000000000000000000000000000000000000000000000000000000000610c6083610c606064610c606006546118a98c8b612b7390919063ffffffff16565b612352612c24565b6000546001600160a01b039081169116146123a2576040805162461bcd60e51b81526020600482018190526024820152600080516020613b1b833981519152604482015290519081900360640190fd5b60648110156123e25760405162461bcd60e51b81526004018080602001828103825260328152602001806139956032913960400191505060405180910390fd5b60085481906123f2906064612afb565b1061242e5760405162461bcd60e51b81526004018080602001828103825260348152602001806139056034913960400191505060405180910390fd5b600681905560408051828152905133917f6126d9241e4aeb647b01ddffba35de720a5b4ad692f117a43b5b281e49126fc4919081900360200190a250565b6103e881565b600b6020526000908152604090205481565b6002805414156124c9576040805162461bcd60e51b815260206004820152601f602482015260008051602061373b833981519152604482015290519081900360640190fd5b60028055336000908152600b60205260409020546125185760405162461bcd60e51b815260040180806020018281038252602b815260200180613780602b913960400191505060405180910390fd5b60035460ff1615612563576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b80806125a05760405162461bcd60e51b8152600401808060200182810382526027815260200180613be56027913960400191505060405180910390fd5b604080516323b872dd60e01b81523360048201523060248201526044810184905290516001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016916323b872dd9160648083019260209291908290030181600087803b15801561261557600080fd5b505af1158015612629573d6000803e3d6000fd5b505050506040513d602081101561263f57600080fd5b505161267c5760405162461bcd60e51b815260040180806020018281038252603b8152602001806136d1603b913960400191505060405180910390fd5b336000908152600b60209081526040808320548352600c909152902060018101546126a79084612afb565b6001820155805460408051858152905133917f11f8990ac38271f23dea447d5728e9914fca7cea2edda43af6c43c415f8bc30b919081900360200190a35050600160025550565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000818152600160205260408120610b5c90613115565b60008281526001602052604090206002015461274790610dca612c24565b6111785760405162461bcd60e51b81526004018080602001828103825260308152602001806139396030913960400191505060405180910390fd5b600061278c61364d565b506000828152600c60209081526040808320815160808101835281548152600182015493810193909352600281015491830191909152600301546001600160a01b03166060820152906127dd611425565b9050600061280a7f0000000000000000000000000000000000000000000000000000000000000000611831565b9050600061284d83610c60846118a97f00000000000000000000000000000000000000000000000000000000000000008960200151612b7390919063ffffffff16565b9050600061287e60646118a9846128786064610c606006548c60400151612b7390919063ffffffff16565b90612c91565b905060006128a461289b6064600854612afb90919063ffffffff16565b60065490612c91565b6040870151909150610c76906128ba8484612bcc565b612c0e565b6128c7612c24565b6000546001600160a01b03908116911614612917576040805162461bcd60e51b81526020600482018190526024820152600080516020613b1b833981519152604482015290519081900360640190fd5b6001600160a01b03811661295c5760405162461bcd60e51b815260040180806020018281038252602f8152602001806137d1602f913960400191505060405180910390fd5b600a80546001600160a01b0383166001600160a01b03199091168117909155604080519182525133917f567657fa3f286518b318f4a29870674f433f622fdfc819691acb13105b228225919081900360200190a250565b6129bb612c24565b6000546001600160a01b03908116911614612a0b576040805162461bcd60e51b81526020600482018190526024820152600080516020613b1b833981519152604482015290519081900360640190fd5b6001600160a01b038116612a505760405162461bcd60e51b81526004018080602001828103825260268152602001806137ab6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b60075481565b600080612add7f0000000000000000000000000000000000000000000000000000000000000000611831565b9050611bbd81610c60612710610c606007546118a9896118a9611425565b600082820183811015611bbd576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b80546001019055565b6000611bbd836001600160a01b038416613120565b600082612b8257506000610b5c565b82820282848281612b8f57fe5b0414611bbd5760405162461bcd60e51b8152600401808060200182810382526021815260200180613afa6021913960400191505060405180910390fd5b6000611bbd83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061316a565b6000818310612c1d5781611bbd565b5090919050565b3390565b6000828152600160205260409020612c409082612b5e565b15610e1457612c4d612c24565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000611bbd83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061320c565b6000828152600160205260409020612ceb9082613266565b15610e1457612cf8612c24565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b60035460ff16612d8a576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b6003805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa612dbd612c24565b604080516001600160a01b039092168252519081900360200190a1565b6000828152600c602052604090206002810154821115612e2b5760405162461bcd60e51b815260040180806020018281038252602c815260200180613969602c913960400191505060405180910390fd5b6002810154612e3a9083612c91565b600282015560408051632770a7eb60e21b81523360048201526024810184905290516001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001691639dc29fac91604480830192600092919082900301818387803b158015612ead57600080fd5b505af1158015612ec1573d6000803e3d6000fd5b50505050505050565b604080516000808252602082019092526001600160a01b0384169083906040518082805190602001908083835b60208310612f165780518252601f199092019160209182019101612ef7565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114612f78576040519150601f19603f3d011682016040523d82523d6000602084013e612f7d565b606091505b5050905080612fbd5760405162461bcd60e51b8152600401808060200182810382526033815260200180613ac76033913960400191505060405180910390fd5b505050565b5490565b60008082121561301d576040805162461bcd60e51b815260206004820181905260248201527f53616665436173743a2076616c7565206d75737420626520706f736974697665604482015290519081900360640190fd5b5090565b60035460ff161561306c576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6003805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612dbd612c24565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052612fbd90849061327b565b6000611bbd838361332c565b6000611bbd836001600160a01b038416613390565b6000610b5c82612fc2565b600061312c8383613390565b61316257508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610b5c565b506000610b5c565b600081836131f65760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156131bb5781810151838201526020016131a3565b50505050905090810190601f1680156131e85780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161320257fe5b0495945050505050565b6000818484111561325e5760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156131bb5781810151838201526020016131a3565b505050900390565b6000611bbd836001600160a01b0384166133a8565b60606132d0826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661346e9092919063ffffffff16565b805190915015612fbd578080602001905160208110156132ef57600080fd5b5051612fbd5760405162461bcd60e51b815260040180806020018281038252602a815260200180613c0c602a913960400191505060405180910390fd5b8154600090821061336e5760405162461bcd60e51b81526004018080602001828103825260228152602001806136af6022913960400191505060405180910390fd5b82600001828154811061337d57fe5b9060005260206000200154905092915050565b60009081526001919091016020526040902054151590565b6000818152600183016020526040812054801561346457835460001980830191908101906000908790839081106133db57fe5b90600052602060002001549050808760000184815481106133f857fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061342857fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610b5c565b6000915050610b5c565b606061347d8484600085613485565b949350505050565b6060824710156134c65760405162461bcd60e51b81526004018080602001828103825260268152602001806138df6026913960400191505060405180910390fd5b6134cf856135e1565b613520576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b6020831061355f5780518252601f199092019160209182019101613540565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146135c1576040519150601f19603f3d011682016040523d82523d6000602084013e6135c6565b606091505b50915091506135d68282866135e7565b979650505050505050565b3b151590565b606083156135f6575081611bbd565b8251156136065782518084602001fd5b60405162461bcd60e51b81526020600482018181528451602484015284518593919283926044019190850190808383600083156131bb5781810151838201526020016131a3565b604051806080016040528060008152602001600081526020016000815260200160006001600160a01b03168152509056fe5661756c7448616e646c65723a3a6372656174655661756c743a207661756c7420616c72656164792063726561746564456e756d657261626c655365743a20696e646578206f7574206f6620626f756e64735661756c7448616e646c65723a3a616464436f6c6c61746572616c3a204552433230207472616e7366657220646964206e6f742073756363656564416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f206772616e745265656e7472616e637947756172643a207265656e7472616e742063616c6c0043616e6e6f742077697468647261772074686520636f6c6c61746572616c20746f6b656e735661756c7448616e646c65723a3a7661756c744578697374733a206e6f207661756c7420637265617465644f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573735661756c7448616e646c65723a3a73657454726561737572793a206e6f7420612076616c69642074726561737572795661756c7448616e646c65723a3a6d696e743a206e6f7420656e6f75676820636f6c6c61746572616c5661756c7448616e646c65723a3a6d696e743a206d696e7420616d6f756e74206c657373207468616e2072657175697265645661756c7448616e646c65723a3a6c69717569646174655661756c743a206c69717569646174696f6e20616d6f756e7420646966666572656e74207468616e2072657175697265645661756c7448616e646c65723a3a6c69717569646174655661756c743a204552433230207472616e7366657220646964206e6f742073756363656564416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c5661756c7448616e646c65723a3a736574526174696f3a206c69717569646174696f6e2070656e616c747920746f6f2068696768416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f207265766f6b655661756c7448616e646c65723a3a6275726e3a20616d6f756e742067726561746572207468616e20646562745661756c7448616e646c65723a3a736574526174696f3a20726174696f206c6f776572207468616e204d494e5f524154494f5661756c7448616e646c65723a3a7365744275726e4665653a206275726e2066656520686967686572207468616e204d41585f4645455661756c7448616e646c65723a3a72656d6f7665436f6c6c61746572616c3a20726574726965766520616d6f756e7420686967686572207468616e20636f6c6c61746572616c5661756c7448616e646c65723a3a7365744c69717569646174696f6e50656e616c74793a206c69717569646174696f6e2070656e616c747920746f6f20686967685661756c7448616e646c65723a3a72656d6f7665436f6c6c61746572616c3a20636f6c6c61746572616c2062656c6f77206d696e20726571756972656420726174696f495661756c7448616e646c65723a3a736166655472616e736665724554483a20455448207472616e73666572206661696c6564536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65725661756c7448616e646c65723a3a6d696e743a20636f6c6c61746572616c2062656c6f77206d696e20726571756972656420726174696f5661756c7448616e646c65723a3a72656d6f7665436f6c6c61746572616c3a204552433230207472616e7366657220646964206e6f7420737563636565645661756c7448616e646c65723a3a6c69717569646174655661756c743a207661756c74206973206e6f74206c697175696461626c655661756c7448616e646c65723a3a6e6f745a65726f3a2076616c75652063616e277420626520305361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645661756c7448616e646c65723a3a6c69717569646174655661756c743a206e6f207661756c7420637265617465645661756c7448616e646c65723a3a6275726e3a206275726e20666565206c657373207468616e2072657175697265645661756c7448616e646c65723a3a6c69717569646174655661756c743a206275726e20666565206c657373207468616e207265717569726564416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636520726f6c657320666f722073656c66a26469706673582212205b2788d58c96a62a319be261873061641d4a88eb51e4b617ee5956918c03dcb864736f6c634300070500335661756c7448616e646c65723a3a636f6e7374727563746f723a20726174696f206c6f776572207468616e204d494e5f524154494f4f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573735661756c7448616e646c65723a3a636f6e7374727563746f723a206c69717569646174696f6e2070656e616c747920746f6f20686967685661756c7448616e646c65723a3a636f6e7374727563746f723a206275726e2066656520686967686572207468616e204d41585f464545436f6c6c61746572616c20646563696d616c732067726561746572207468616e204d41585f444543494d414c5f504c414345538be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0000000000000000000000000373c74bce7893097ab26d22f05691907d4f2c18e00000000000000000000000000000000000000000000000000000002540be400000000000000000000000000000000000000000000000000000000000000006e00000000000000000000000000000000000000000000000000000000000000320000000000000000000000000000000000000000000000000000000000000005000000000000000000000000a4e581bd159b869e8290707a7fbf841fe7fe97b600000000000000000000000016c52ceece2ed57dad87319d91b5e3637d50afa40000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000006b5a75f38bea1ef59bc43a5d9602e77bcbe65e460000000000000000000000002cfeaf282fe9ae050b210e7bda65d288c40c6104000000000000000000000000a54074b2cc0e96a43048d4a68472f7f046ac0da8000000000000000000000000000000000000000000000001158e460913d00000
Deployed Bytecode
0x6080604052600436106103355760003560e01c8063842e357c116101ab578063a217fddf116100f7578063ca15c87311610095578063f0f442601161006f578063f0f4426014610a86578063f2fde38b14610ab9578063fce589d814610aec578063fcee45f414610b0157610335565b8063ca15c873146109f9578063d547741f14610a23578063de9952c914610a5c57610335565b8063bc063e1a116100d1578063bc063e1a14610972578063bc721a9614610987578063bcc46e83146109ba578063c6e1c7c9146109e457610335565b8063a217fddf14610909578063abb7bc4a1461091e578063b2237ba31461094857610335565b80639010d07c11610164578063952cc86a1161013e578063952cc86a1461089257806397994e30146108b55780639d9b5818146108ca578063a0712d68146108df57610335565b80639010d07c146107d157806391d14854146108015780639403b6341461083a57610335565b8063842e357c146106d65780638456cb59146106eb5780638980f11f146107005780638c01f211146107395780638c64ea4a146107635780638da5cb5b146107bc57610335565b8063422b91811161028557806361bc221a116102235780636ca2143c116101fd5780636ca2143c14610664578063715018a61461067957806371ca337d1461068e57806375f620ac146106a357610335565b806361bc221a1461062557806361d027b31461063a5780636ae7adc11461064f57610335565b80634bf2c7c91161025f5780634bf2c7c9146105a7578063574b786d146105d15780635c975abb146105fb5780635d12928b1461061057610335565b8063422b91811461056057806342966c681461057557806346dc90071461059257610335565b8063248a9ca3116102f25780632f2ff15d116102cc5780632f2ff15d146104af5780633237c158146104e857806336568abe146105125780633f4ba83a1461054b57610335565b8063248a9ca31461042e5780632806a743146104585780632c5a81421461048457610335565b806301ffc9a71461033a5780630f0aeb8d1461038257806311d850e8146103a95780631cc244ba146103d35780631f2dc5ef1461040457806323f5589a14610419575b600080fd5b34801561034657600080fd5b5061036e6004803603602081101561035d57600080fd5b50356001600160e01b031916610b2b565b604080519115158252519081900360200190f35b34801561038e57600080fd5b50610397610b62565b60408051918252519081900360200190f35b3480156103b557600080fd5b50610397600480360360208110156103cc57600080fd5b5035610b67565b3480156103df57600080fd5b506103e8610c82565b604080516001600160a01b039092168252519081900360200190f35b34801561041057600080fd5b50610397610ca6565b34801561042557600080fd5b50610397610cac565b34801561043a57600080fd5b506103976004803603602081101561045157600080fd5b5035610cb2565b34801561046457600080fd5b506104826004803603602081101561047b57600080fd5b5035610cc7565b005b34801561049057600080fd5b50610499610da7565b6040805160ff9092168252519081900360200190f35b3480156104bb57600080fd5b50610482600480360360408110156104d257600080fd5b50803590602001356001600160a01b0316610dac565b3480156104f457600080fd5b506104826004803603602081101561050b57600080fd5b5035610e18565b34801561051e57600080fd5b506104826004803603604081101561053557600080fd5b50803590602001356001600160a01b0316611121565b34801561055757600080fd5b50610482611182565b34801561056c57600080fd5b506103976111e4565b6104826004803603602081101561058b57600080fd5b50356111ea565b34801561059e57600080fd5b50610397611425565b3480156105b357600080fd5b50610482600480360360208110156105ca57600080fd5b503561146e565b3480156105dd57600080fd5b50610482600480360360208110156105f457600080fd5b5035611545565b34801561060757600080fd5b5061036e6115db565b34801561061c57600080fd5b506104826115e4565b34801561063157600080fd5b50610397611747565b34801561064657600080fd5b506103e861174d565b34801561065b57600080fd5b5061039761175c565b34801561067057600080fd5b506103e8611765565b34801561068557600080fd5b50610482611789565b34801561069a57600080fd5b5061039761182b565b3480156106af57600080fd5b50610397600480360360208110156106c657600080fd5b50356001600160a01b0316611831565b3480156106e257600080fd5b506103e86118af565b3480156106f757600080fd5b506104826118d3565b34801561070c57600080fd5b506104826004803603604081101561072357600080fd5b506001600160a01b038135169060200135611933565b34801561074557600080fd5b506103976004803603602081101561075c57600080fd5b5035611a60565b34801561076f57600080fd5b5061078d6004803603602081101561078657600080fd5b5035611b66565b604080519485526020850193909352838301919091526001600160a01b03166060830152519081900360800190f35b3480156107c857600080fd5b506103e8611b96565b3480156107dd57600080fd5b506103e8600480360360408110156107f457600080fd5b5080359060200135611ba5565b34801561080d57600080fd5b5061036e6004803603604081101561082457600080fd5b50803590602001356001600160a01b0316611bc4565b34801561084657600080fd5b506108646004803603602081101561085d57600080fd5b5035611bdc565b6040805194855260208501939093526001600160a01b03909116838301526060830152519081900360800190f35b610482600480360360408110156108a857600080fd5b5080359060200135611c43565b3480156108c157600080fd5b506103e8611f87565b3480156108d657600080fd5b50610397611fab565b3480156108eb57600080fd5b506104826004803603602081101561090257600080fd5b5035611fcf565b34801561091557600080fd5b506103976122c5565b34801561092a57600080fd5b506103976004803603602081101561094157600080fd5b50356122ca565b34801561095457600080fd5b506104826004803603602081101561096b57600080fd5b503561234a565b34801561097e57600080fd5b5061039761246c565b34801561099357600080fd5b50610397600480360360208110156109aa57600080fd5b50356001600160a01b0316612472565b3480156109c657600080fd5b50610482600480360360208110156109dd57600080fd5b5035612484565b3480156109f057600080fd5b506103e86126ee565b348015610a0557600080fd5b5061039760048036036020811015610a1c57600080fd5b5035612712565b348015610a2f57600080fd5b5061048260048036036040811015610a4657600080fd5b50803590602001356001600160a01b0316612729565b348015610a6857600080fd5b5061039760048036036020811015610a7f57600080fd5b5035612782565b348015610a9257600080fd5b5061048260048036036020811015610aa957600080fd5b50356001600160a01b03166128bf565b348015610ac557600080fd5b5061048260048036036020811015610adc57600080fd5b50356001600160a01b03166129b3565b348015610af857600080fd5b50610397612aab565b348015610b0d57600080fd5b5061039760048036036020811015610b2457600080fd5b5035612ab1565b60006001600160e01b0319821663279d6ac360e21b1480610b5c57506001600160e01b031982166301ffc9a760e01b145b92915050565b606481565b6000610b7161364d565b506000828152600c60209081526040808320815160808101835281548152600182015493810193909352600281015491830191909152600301546001600160a01b0316606082015290610bc384612782565b90506000610bcf611425565b90506000610bfc7f0000000000000000000000006b5a75f38bea1ef59bc43a5d9602e77bcbe65e46611831565b90506000610c20610c196064600854612afb90919063ffffffff16565b8590612b73565b90506000610c667f0000000000000000000000000000000000000000000000000000000000000001610c60610c56866064612b73565b610c608689612b73565b90612bcc565b9050610c76866020015182612c0e565b98975050505050505050565b7f000000000000000000000000a4e581bd159b869e8290707a7fbf841fe7fe97b681565b60055481565b60085481565b60009081526001602052604090206002015490565b610ccf612c24565b6000546001600160a01b03908116911614610d1f576040805162461bcd60e51b81526020600482018190526024820152600080516020613b1b833981519152604482015290519081900360640190fd5b600654610d2d826064612afb565b10610d695760405162461bcd60e51b8152600401808060200182810382526041815260200180613a436041913960600191505060405180910390fd5b600881905560408051828152905133917f76fea7ef18b6b073facb4f15d873d45dc60e1ac9448931a44b388f40c49e3267919081900360200190a250565b601281565b600082815260016020526040902060020154610dcf90610dca612c24565b611bc4565b610e0a5760405162461bcd60e51b815260040180806020018281038252602f81526020018061370c602f913960400191505060405180910390fd5b610e148282612c28565b5050565b600280541415610e5d576040805162461bcd60e51b815260206004820152601f602482015260008051602061373b833981519152604482015290519081900360640190fd5b60028055336000908152600b6020526040902054610eac5760405162461bcd60e51b815260040180806020018281038252602b815260200180613780602b913960400191505060405180910390fd5b60035460ff1615610ef7576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b8080610f345760405162461bcd60e51b8152600401808060200182810382526027815260200180613be56027913960400191505060405180910390fd5b336000908152600b60209081526040808320548352600c90915281208054909190610f5e90611a60565b90508382600101541015610fa35760405162461bcd60e51b81526004018080602001828103825260468152602001806139fd6046913960600191505060405180910390fd5b6001820154610fb29085612c91565b60018301558015611008576006548254610fcb90611a60565b10156110085760405162461bcd60e51b8152600401808060200182810382526043815260200180613a846043913960600191505060405180910390fd5b6040805163a9059cbb60e01b81523360048201526024810186905290516001600160a01b037f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f169163a9059cbb9160448083019260209291908290030181600087803b15801561107757600080fd5b505af115801561108b573d6000803e3d6000fd5b505050506040513d60208110156110a157600080fd5b50516110de5760405162461bcd60e51b815260040180806020018281038252603e815260200180613b72603e913960400191505060405180910390fd5b815460408051868152905133917f47e1336b6fdb5f42c3a1d28b558fa98786d820c3705d726358dcc8e63a401eef919081900360200190a3505060016002555050565b611129612c24565b6001600160a01b0316816001600160a01b0316146111785760405162461bcd60e51b815260040180806020018281038252602f815260200180613ccc602f913960400191505060405180910390fd5b610e148282612cd3565b61118a612c24565b6000546001600160a01b039081169116146111da576040805162461bcd60e51b81526020600482018190526024820152600080516020613b1b833981519152604482015290519081900360640190fd5b6111e2612d3c565b565b60095481565b60028054141561122f576040805162461bcd60e51b815260206004820152601f602482015260008051602061373b833981519152604482015290519081900360640190fd5b60028055336000908152600b602052604090205461127e5760405162461bcd60e51b815260040180806020018281038252602b815260200180613780602b913960400191505060405180910390fd5b60035460ff16156112c9576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b80806113065760405162461bcd60e51b8152600401808060200182810382526027815260200180613be56027913960400191505060405180910390fd5b600061131183612ab1565b9050803410156113525760405162461bcd60e51b815260040180806020018281038252602f815260200180613c64602f913960400191505060405180910390fd5b61135a61364d565b50336000908152600b60209081526040808320548352600c82529182902082516080810184528154808252600183015493820193909352600282015493810193909352600301546001600160a01b031660608301526113b99085612dda565b600a546113cf906001600160a01b031683612eca565b6113e2336113dd3485612c91565b612eca565b805160408051868152905133917fccbea4088a3b7ae9ca2d15fab9a9742a4075b4d7247768a1eecea917565aba00919081900360200190a3505060016002555050565b6000806114517f000000000000000000000000a4e581bd159b869e8290707a7fbf841fe7fe97b6611831565b905061146860055482612bcc90919063ffffffff16565b91505090565b611476612c24565b6000546001600160a01b039081169116146114c6576040805162461bcd60e51b81526020600482018190526024820152600080516020613b1b833981519152604482015290519081900360640190fd5b6103e88111156115075760405162461bcd60e51b81526004018080602001828103825260368152602001806139c76036913960400191505060405180910390fd5b600781905560408051828152905133917f2b29c7e5fe28010036a94929b56a0eb76bf5e90700e842a971eaa6e4abc45f04919081900360200190a250565b61154d612c24565b6000546001600160a01b0390811691161461159d576040805162461bcd60e51b81526020600482018190526024820152600080516020613b1b833981519152604482015290519081900360640190fd5b600981905560408051828152905133917fb276aeff8481b22fb866569892ac1e4127fe82fefd28354c38957d5dc76bd86c919081900360200190a250565b60035460ff1690565b60035460ff161561162f576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b336000908152600b60205260409020541561167b5760405162461bcd60e51b815260040180806020018281038252603081526020018061367f6030913960400191505060405180910390fd5b60006116876004612fc2565b336000908152600b6020526040902081905590506116a361364d565b5060408051608081018252828152600060208083018281528385018381523360608601908152878552600c909352949092208351815591516001830155925160028201559151600390920180546001600160a01b0319166001600160a01b03909316929092179091556117166004612b55565b604051829033907fa510df27d6e51efd91d3f55722bad1f26bf924a63e5dcee07c2ab4c3d4992dcc90600090a35050565b60045481565b600a546001600160a01b031681565b6402540be40081565b7f00000000000000000000000016c52ceece2ed57dad87319d91b5e3637d50afa481565b611791612c24565b6000546001600160a01b039081169116146117e1576040805162461bcd60e51b81526020600482018190526024820152600080516020613b1b833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b60065481565b6000610b5c6402540be4006118a9846001600160a01b03166396237c026040518163ffffffff1660e01b815260040160206040518083038186803b15801561187857600080fd5b505afa15801561188c573d6000803e3d6000fd5b505050506040513d60208110156118a257600080fd5b5051612fc6565b90612b73565b7f0000000000000000000000006b5a75f38bea1ef59bc43a5d9602e77bcbe65e4681565b6118db612c24565b6000546001600160a01b0390811691161461192b576040805162461bcd60e51b81526020600482018190526024820152600080516020613b1b833981519152604482015290519081900360640190fd5b6111e2613021565b61193b612c24565b6000546001600160a01b0390811691161461198b576040805162461bcd60e51b81526020600482018190526024820152600080516020613b1b833981519152604482015290519081900360640190fd5b7f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f6001600160a01b0316826001600160a01b031614156119fc5760405162461bcd60e51b815260040180806020018281038252602581526020018061375b6025913960400191505060405180910390fd5b611a18611a07611b96565b6001600160a01b03841690836130a2565b604080516001600160a01b03841681526020810183905281517f8c1256b8896378cd5044f80c202f9772b9d77dc85c8a6eb51967210b09bfaa28929181900390910190a15050565b6000611a6a61364d565b506000828152600c602090815260409182902082516080810184528154808252600183015493820193909352600282015493810193909352600301546001600160a01b031660608301521580611ac257506040810151155b15611ad05760009150611b60565b6000611afb7f0000000000000000000000006b5a75f38bea1ef59bc43a5d9602e77bcbe65e46611831565b9050611b5c611b16611b0b611425565b604085015190612b73565b610c60611b557f00000000000000000000000000000000000000000000000000000000000000016118a960648860200151612b7390919063ffffffff16565b8490612b73565b9250505b50919050565b600c602052600090815260409020805460018201546002830154600390930154919290916001600160a01b031684565b6000546001600160a01b031690565b6000828152600160205260408120611bbd90836130f4565b9392505050565b6000828152600160205260408120611bbd9083613100565b600080600080611bea61364d565b50505060009283525050600c602090815260409182902082516080810184528154808252600183015493820184905260028301549482018590526003909201546001600160a01b03166060909101819052909391929091565b600280541415611c88576040805162461bcd60e51b815260206004820152601f602482015260008051602061373b833981519152604482015290519081900360640190fd5b6002805560035460ff1615611cd7576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6000828152600c602052604090208054611d225760405162461bcd60e51b815260040180806020018281038252602e815260200180613c36602e913960400191505060405180910390fd5b6000611d318260000154611a60565b90506006548110611d735760405162461bcd60e51b8152600401808060200182810382526035815260200180613bb06035913960400191505060405180910390fd5b6000611d828360000154612782565b905080841015611dc35760405162461bcd60e51b815260040180806020018281038252604881526020018061385b6048913960600191505060405180910390fd5b6000611dce82612ab1565b905080341015611e0f5760405162461bcd60e51b8152600401808060200182810382526039815260200180613c936039913960400191505060405180910390fd5b6000611e1e8560000154610b67565b9050611e2e856000015484612dda565b6001850154611e3d9082612c91565b60018601556040805163a9059cbb60e01b81523360048201526024810183905290516001600160a01b037f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f169163a9059cbb9160448083019260209291908290030181600087803b158015611eb157600080fd5b505af1158015611ec5573d6000803e3d6000fd5b505050506040513d6020811015611edb57600080fd5b5051611f185760405162461bcd60e51b815260040180806020018281038252603c8152602001806138a3603c913960400191505060405180910390fd5b600a54611f2e906001600160a01b031683612eca565b611f3c336113dd3485612c91565b8454604080518581526020810184905281513393927fba5789da846390370bbfbf693007be2c95d0cfac69a8d175805f742dc7938321928290030190a3505060016002555050505050565b7f0000000000000000000000002cfeaf282fe9ae050b210e7bda65d288c40c610481565b7f000000000000000000000000000000000000000000000000000000000000000181565b600280541415612014576040805162461bcd60e51b815260206004820152601f602482015260008051602061373b833981519152604482015290519081900360640190fd5b60028055336000908152600b60205260409020546120635760405162461bcd60e51b815260040180806020018281038252602b815260200180613780602b913960400191505060405180910390fd5b60035460ff16156120ae576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b80806120eb5760405162461bcd60e51b8152600401808060200182810382526027815260200180613be56027913960400191505060405180910390fd5b336000908152600b60209081526040808320548352600c909152812090612111846122ca565b905080826001015410156121565760405162461bcd60e51b81526004018080602001828103825260298152602001806138006029913960400191505060405180910390fd5b60028201546121659085612afb565b6002830155600654825461217890611a60565b10156121b55760405162461bcd60e51b8152600401808060200182810382526037815260200180613b3b6037913960400191505060405180910390fd5b600954826002015410156121fa5760405162461bcd60e51b81526004018080602001828103825260328152602001806138296032913960400191505060405180910390fd5b604080516340c10f1960e01b81523360048201526024810186905290516001600160a01b037f00000000000000000000000016c52ceece2ed57dad87319d91b5e3637d50afa416916340c10f1991604480830192600092919082900301818387803b15801561226857600080fd5b505af115801561227c573d6000803e3d6000fd5b505083546040805188815290519193503392507f2e8ac5177a616f2aec08c3048f5021e4e9743ece034e8d83ba5caf76688bb475919081900360200190a3505060016002555050565b600081565b6000806122d5611425565b905060006123027f0000000000000000000000006b5a75f38bea1ef59bc43a5d9602e77bcbe65e46611831565b9050611b5c7f0000000000000000000000000000000000000000000000000000000000000001610c6083610c606064610c606006546118a98c8b612b7390919063ffffffff16565b612352612c24565b6000546001600160a01b039081169116146123a2576040805162461bcd60e51b81526020600482018190526024820152600080516020613b1b833981519152604482015290519081900360640190fd5b60648110156123e25760405162461bcd60e51b81526004018080602001828103825260328152602001806139956032913960400191505060405180910390fd5b60085481906123f2906064612afb565b1061242e5760405162461bcd60e51b81526004018080602001828103825260348152602001806139056034913960400191505060405180910390fd5b600681905560408051828152905133917f6126d9241e4aeb647b01ddffba35de720a5b4ad692f117a43b5b281e49126fc4919081900360200190a250565b6103e881565b600b6020526000908152604090205481565b6002805414156124c9576040805162461bcd60e51b815260206004820152601f602482015260008051602061373b833981519152604482015290519081900360640190fd5b60028055336000908152600b60205260409020546125185760405162461bcd60e51b815260040180806020018281038252602b815260200180613780602b913960400191505060405180910390fd5b60035460ff1615612563576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b80806125a05760405162461bcd60e51b8152600401808060200182810382526027815260200180613be56027913960400191505060405180910390fd5b604080516323b872dd60e01b81523360048201523060248201526044810184905290516001600160a01b037f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f16916323b872dd9160648083019260209291908290030181600087803b15801561261557600080fd5b505af1158015612629573d6000803e3d6000fd5b505050506040513d602081101561263f57600080fd5b505161267c5760405162461bcd60e51b815260040180806020018281038252603b8152602001806136d1603b913960400191505060405180910390fd5b336000908152600b60209081526040808320548352600c909152902060018101546126a79084612afb565b6001820155805460408051858152905133917f11f8990ac38271f23dea447d5728e9914fca7cea2edda43af6c43c415f8bc30b919081900360200190a35050600160025550565b7f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f81565b6000818152600160205260408120610b5c90613115565b60008281526001602052604090206002015461274790610dca612c24565b6111785760405162461bcd60e51b81526004018080602001828103825260308152602001806139396030913960400191505060405180910390fd5b600061278c61364d565b506000828152600c60209081526040808320815160808101835281548152600182015493810193909352600281015491830191909152600301546001600160a01b03166060820152906127dd611425565b9050600061280a7f0000000000000000000000006b5a75f38bea1ef59bc43a5d9602e77bcbe65e46611831565b9050600061284d83610c60846118a97f00000000000000000000000000000000000000000000000000000000000000018960200151612b7390919063ffffffff16565b9050600061287e60646118a9846128786064610c606006548c60400151612b7390919063ffffffff16565b90612c91565b905060006128a461289b6064600854612afb90919063ffffffff16565b60065490612c91565b6040870151909150610c76906128ba8484612bcc565b612c0e565b6128c7612c24565b6000546001600160a01b03908116911614612917576040805162461bcd60e51b81526020600482018190526024820152600080516020613b1b833981519152604482015290519081900360640190fd5b6001600160a01b03811661295c5760405162461bcd60e51b815260040180806020018281038252602f8152602001806137d1602f913960400191505060405180910390fd5b600a80546001600160a01b0383166001600160a01b03199091168117909155604080519182525133917f567657fa3f286518b318f4a29870674f433f622fdfc819691acb13105b228225919081900360200190a250565b6129bb612c24565b6000546001600160a01b03908116911614612a0b576040805162461bcd60e51b81526020600482018190526024820152600080516020613b1b833981519152604482015290519081900360640190fd5b6001600160a01b038116612a505760405162461bcd60e51b81526004018080602001828103825260268152602001806137ab6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b60075481565b600080612add7f0000000000000000000000002cfeaf282fe9ae050b210e7bda65d288c40c6104611831565b9050611bbd81610c60612710610c606007546118a9896118a9611425565b600082820183811015611bbd576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b80546001019055565b6000611bbd836001600160a01b038416613120565b600082612b8257506000610b5c565b82820282848281612b8f57fe5b0414611bbd5760405162461bcd60e51b8152600401808060200182810382526021815260200180613afa6021913960400191505060405180910390fd5b6000611bbd83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061316a565b6000818310612c1d5781611bbd565b5090919050565b3390565b6000828152600160205260409020612c409082612b5e565b15610e1457612c4d612c24565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000611bbd83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061320c565b6000828152600160205260409020612ceb9082613266565b15610e1457612cf8612c24565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b60035460ff16612d8a576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b6003805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa612dbd612c24565b604080516001600160a01b039092168252519081900360200190a1565b6000828152600c602052604090206002810154821115612e2b5760405162461bcd60e51b815260040180806020018281038252602c815260200180613969602c913960400191505060405180910390fd5b6002810154612e3a9083612c91565b600282015560408051632770a7eb60e21b81523360048201526024810184905290516001600160a01b037f00000000000000000000000016c52ceece2ed57dad87319d91b5e3637d50afa41691639dc29fac91604480830192600092919082900301818387803b158015612ead57600080fd5b505af1158015612ec1573d6000803e3d6000fd5b50505050505050565b604080516000808252602082019092526001600160a01b0384169083906040518082805190602001908083835b60208310612f165780518252601f199092019160209182019101612ef7565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114612f78576040519150601f19603f3d011682016040523d82523d6000602084013e612f7d565b606091505b5050905080612fbd5760405162461bcd60e51b8152600401808060200182810382526033815260200180613ac76033913960400191505060405180910390fd5b505050565b5490565b60008082121561301d576040805162461bcd60e51b815260206004820181905260248201527f53616665436173743a2076616c7565206d75737420626520706f736974697665604482015290519081900360640190fd5b5090565b60035460ff161561306c576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6003805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612dbd612c24565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052612fbd90849061327b565b6000611bbd838361332c565b6000611bbd836001600160a01b038416613390565b6000610b5c82612fc2565b600061312c8383613390565b61316257508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610b5c565b506000610b5c565b600081836131f65760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156131bb5781810151838201526020016131a3565b50505050905090810190601f1680156131e85780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161320257fe5b0495945050505050565b6000818484111561325e5760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156131bb5781810151838201526020016131a3565b505050900390565b6000611bbd836001600160a01b0384166133a8565b60606132d0826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661346e9092919063ffffffff16565b805190915015612fbd578080602001905160208110156132ef57600080fd5b5051612fbd5760405162461bcd60e51b815260040180806020018281038252602a815260200180613c0c602a913960400191505060405180910390fd5b8154600090821061336e5760405162461bcd60e51b81526004018080602001828103825260228152602001806136af6022913960400191505060405180910390fd5b82600001828154811061337d57fe5b9060005260206000200154905092915050565b60009081526001919091016020526040902054151590565b6000818152600183016020526040812054801561346457835460001980830191908101906000908790839081106133db57fe5b90600052602060002001549050808760000184815481106133f857fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061342857fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610b5c565b6000915050610b5c565b606061347d8484600085613485565b949350505050565b6060824710156134c65760405162461bcd60e51b81526004018080602001828103825260268152602001806138df6026913960400191505060405180910390fd5b6134cf856135e1565b613520576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b6020831061355f5780518252601f199092019160209182019101613540565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146135c1576040519150601f19603f3d011682016040523d82523d6000602084013e6135c6565b606091505b50915091506135d68282866135e7565b979650505050505050565b3b151590565b606083156135f6575081611bbd565b8251156136065782518084602001fd5b60405162461bcd60e51b81526020600482018181528451602484015284518593919283926044019190850190808383600083156131bb5781810151838201526020016131a3565b604051806080016040528060008152602001600081526020016000815260200160006001600160a01b03168152509056fe5661756c7448616e646c65723a3a6372656174655661756c743a207661756c7420616c72656164792063726561746564456e756d657261626c655365743a20696e646578206f7574206f6620626f756e64735661756c7448616e646c65723a3a616464436f6c6c61746572616c3a204552433230207472616e7366657220646964206e6f742073756363656564416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f206772616e745265656e7472616e637947756172643a207265656e7472616e742063616c6c0043616e6e6f742077697468647261772074686520636f6c6c61746572616c20746f6b656e735661756c7448616e646c65723a3a7661756c744578697374733a206e6f207661756c7420637265617465644f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573735661756c7448616e646c65723a3a73657454726561737572793a206e6f7420612076616c69642074726561737572795661756c7448616e646c65723a3a6d696e743a206e6f7420656e6f75676820636f6c6c61746572616c5661756c7448616e646c65723a3a6d696e743a206d696e7420616d6f756e74206c657373207468616e2072657175697265645661756c7448616e646c65723a3a6c69717569646174655661756c743a206c69717569646174696f6e20616d6f756e7420646966666572656e74207468616e2072657175697265645661756c7448616e646c65723a3a6c69717569646174655661756c743a204552433230207472616e7366657220646964206e6f742073756363656564416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c5661756c7448616e646c65723a3a736574526174696f3a206c69717569646174696f6e2070656e616c747920746f6f2068696768416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f207265766f6b655661756c7448616e646c65723a3a6275726e3a20616d6f756e742067726561746572207468616e20646562745661756c7448616e646c65723a3a736574526174696f3a20726174696f206c6f776572207468616e204d494e5f524154494f5661756c7448616e646c65723a3a7365744275726e4665653a206275726e2066656520686967686572207468616e204d41585f4645455661756c7448616e646c65723a3a72656d6f7665436f6c6c61746572616c3a20726574726965766520616d6f756e7420686967686572207468616e20636f6c6c61746572616c5661756c7448616e646c65723a3a7365744c69717569646174696f6e50656e616c74793a206c69717569646174696f6e2070656e616c747920746f6f20686967685661756c7448616e646c65723a3a72656d6f7665436f6c6c61746572616c3a20636f6c6c61746572616c2062656c6f77206d696e20726571756972656420726174696f495661756c7448616e646c65723a3a736166655472616e736665724554483a20455448207472616e73666572206661696c6564536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65725661756c7448616e646c65723a3a6d696e743a20636f6c6c61746572616c2062656c6f77206d696e20726571756972656420726174696f5661756c7448616e646c65723a3a72656d6f7665436f6c6c61746572616c3a204552433230207472616e7366657220646964206e6f7420737563636565645661756c7448616e646c65723a3a6c69717569646174655661756c743a207661756c74206973206e6f74206c697175696461626c655661756c7448616e646c65723a3a6e6f745a65726f3a2076616c75652063616e277420626520305361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645661756c7448616e646c65723a3a6c69717569646174655661756c743a206e6f207661756c7420637265617465645661756c7448616e646c65723a3a6275726e3a206275726e20666565206c657373207468616e2072657175697265645661756c7448616e646c65723a3a6c69717569646174655661756c743a206275726e20666565206c657373207468616e207265717569726564416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636520726f6c657320666f722073656c66a26469706673582212205b2788d58c96a62a319be261873061641d4a88eb51e4b617ee5956918c03dcb864736f6c63430007050033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000373c74bce7893097ab26d22f05691907d4f2c18e00000000000000000000000000000000000000000000000000000002540be400000000000000000000000000000000000000000000000000000000000000006e00000000000000000000000000000000000000000000000000000000000000320000000000000000000000000000000000000000000000000000000000000005000000000000000000000000a4e581bd159b869e8290707a7fbf841fe7fe97b600000000000000000000000016c52ceece2ed57dad87319d91b5e3637d50afa40000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000006b5a75f38bea1ef59bc43a5d9602e77bcbe65e460000000000000000000000002cfeaf282fe9ae050b210e7bda65d288c40c6104000000000000000000000000a54074b2cc0e96a43048d4a68472f7f046ac0da8000000000000000000000000000000000000000000000001158e460913d00000
-----Decoded View---------------
Arg [0] : _orchestrator (address): 0x373C74BcE7893097ab26d22f05691907D4f2c18e
Arg [1] : _divisor (uint256): 10000000000
Arg [2] : _ratio (uint256): 110
Arg [3] : _burnFee (uint256): 50
Arg [4] : _liquidationPenalty (uint256): 5
Arg [5] : _tcapOracle (address): 0xa4e581BD159B869e8290707A7FBF841fe7FE97b6
Arg [6] : _tcapAddress (address): 0x16c52CeeCE2ed57dAd87319D91B5e3637d50aFa4
Arg [7] : _collateralAddress (address): 0x6B175474E89094C44Da98b954EedeAC495271d0F
Arg [8] : _collateralOracle (address): 0x6b5a75f38BeA1Ef59Bc43A5d9602e77Bcbe65e46
Arg [9] : _ethOracle (address): 0x2cFeaf282FE9ae050b210e7BDa65D288C40c6104
Arg [10] : _treasury (address): 0xa54074b2cc0e96a43048d4a68472F7F046aC0DA8
Arg [11] : _minimumTCAP (uint256): 20000000000000000000
-----Encoded View---------------
12 Constructor Arguments found :
Arg [0] : 000000000000000000000000373c74bce7893097ab26d22f05691907d4f2c18e
Arg [1] : 00000000000000000000000000000000000000000000000000000002540be400
Arg [2] : 000000000000000000000000000000000000000000000000000000000000006e
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000032
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000005
Arg [5] : 000000000000000000000000a4e581bd159b869e8290707a7fbf841fe7fe97b6
Arg [6] : 00000000000000000000000016c52ceece2ed57dad87319d91b5e3637d50afa4
Arg [7] : 0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f
Arg [8] : 0000000000000000000000006b5a75f38bea1ef59bc43a5d9602e77bcbe65e46
Arg [9] : 0000000000000000000000002cfeaf282fe9ae050b210e7bda65d288c40c6104
Arg [10] : 000000000000000000000000a54074b2cc0e96a43048d4a68472f7f046ac0da8
Arg [11] : 000000000000000000000000000000000000000000000001158e460913d00000
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.