Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 13 from a total of 13 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Transfer Ownersh... | 11278236 | 1387 days ago | IN | 0 ETH | 0.0014784 | ||||
Add Protocol | 11278106 | 1387 days ago | IN | 0 ETH | 0.04371564 | ||||
Add Protocol | 11278105 | 1387 days ago | IN | 0 ETH | 0.04371437 | ||||
Add Protocol | 11278101 | 1387 days ago | IN | 0 ETH | 0.04428206 | ||||
Add Protocol | 11278055 | 1387 days ago | IN | 0 ETH | 0.03953788 | ||||
Add Protocol | 11278045 | 1387 days ago | IN | 0 ETH | 0.03007321 | ||||
Add Protocol | 11278025 | 1387 days ago | IN | 0 ETH | 0.03974091 | ||||
Add Protocol | 11278013 | 1387 days ago | IN | 0 ETH | 0.03974323 | ||||
Add Protocol | 11277995 | 1387 days ago | IN | 0 ETH | 0.03974265 | ||||
Add Protocol | 11277987 | 1387 days ago | IN | 0 ETH | 0.03974034 | ||||
Add Protocol | 11277969 | 1387 days ago | IN | 0 ETH | 0.04046466 | ||||
Update Claim Man... | 11277931 | 1387 days ago | IN | 0 ETH | 0.00226522 | ||||
0x60806040 | 11277787 | 1387 days ago | IN | 0 ETH | 0.12833626 |
Latest 25 internal transactions (View All)
Advanced mode:
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
ProtocolFactory
Compiler Version
v0.7.3+commit.9bfce1f6
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: No License pragma solidity ^0.7.3; import "./proxy/InitializableAdminUpgradeabilityProxy.sol"; import "./utils/Address.sol"; import "./utils/Create2.sol"; import "./utils/Ownable.sol"; import "./interfaces/IProtocolFactory.sol"; /** * @title ProtocolFactory contract * @author crypto-pumpkin@github */ contract ProtocolFactory is IProtocolFactory, Ownable { bytes4 private constant PROTOCOL_INIT_SIGNITURE = bytes4(keccak256("initialize(bytes32,bool,address,uint48[],bytes32[])")); uint16 public override redeemFeeNumerator = 10; // 0 to 65,535 uint16 public override redeemFeeDenominator = 10000; // 0 to 65,535 address public override protocolImplementation; address public override coverImplementation; address public override coverERC20Implementation; address public override treasury; address public override governance; address public override claimManager; // not all protocols are active bytes32[] private protocolNames; mapping(bytes32 => address) public override protocols; modifier onlyGovernance() { require(msg.sender == governance, "COVER: caller not governance"); _; } constructor ( address _protocolImplementation, address _coverImplementation, address _coverERC20Implementation, address _governance, address _treasury ) { protocolImplementation = _protocolImplementation; coverImplementation = _coverImplementation; coverERC20Implementation = _coverERC20Implementation; governance = _governance; treasury = _treasury; initializeOwner(); } function getAllProtocolAddresses() external view override returns (address[] memory) { bytes32[] memory protocolNamesCopy = protocolNames; address[] memory protocolAddresses = new address[](protocolNamesCopy.length); for (uint i = 0; i < protocolNamesCopy.length; i++) { protocolAddresses[i] = protocols[protocolNamesCopy[i]]; } return protocolAddresses; } function getRedeemFees() external view override returns (uint16 _numerator, uint16 _denominator) { return (redeemFeeNumerator, redeemFeeDenominator); } function getProtocolsLength() external view override returns (uint256) { return protocolNames.length; } function getProtocolNameAndAddress(uint256 _index) external view override returns (bytes32, address) { bytes32 name = protocolNames[_index]; return (name, protocols[name]); } /// @notice return protocol contract address, the contract may not be deployed yet function getProtocolAddress(bytes32 _name) public view override returns (address) { return _computeAddress(keccak256(abi.encodePacked(_name)), address(this)); } /// @notice return cover contract address, the contract may not be deployed yet function getCoverAddress( bytes32 _protocolName, uint48 _timestamp, address _collateral, uint256 _claimNonce ) public view override returns (address) { return _computeAddress( keccak256(abi.encodePacked(_protocolName, _timestamp, _collateral, _claimNonce)), getProtocolAddress(_protocolName) ); } /// @notice return covToken contract address, the contract may not be deployed yet function getCovTokenAddress( bytes32 _protocolName, uint48 _timestamp, address _collateral, uint256 _claimNonce, bool _isClaimCovToken ) external view override returns (address) { return _computeAddress( keccak256(abi.encodePacked( _protocolName, _timestamp, _collateral, _claimNonce, _isClaimCovToken ? "CLAIM" : "NOCLAIM") ), getCoverAddress(_protocolName, _timestamp, _collateral, _claimNonce) ); } /// @dev Emits ProtocolInitiation, add a supported protocol in COVER function addProtocol( bytes32 _name, bool _active, address _collateral, uint48[] calldata _timestamps, bytes32[] calldata _timestampNames ) external override onlyOwner returns (address) { require(protocols[_name] == address(0), "COVER: protocol exists"); require(_timestamps.length == _timestampNames.length, "COVER: timestamp lengths don't match"); protocolNames.push(_name); bytes memory bytecode = type(InitializableAdminUpgradeabilityProxy).creationCode; // unique salt required for each protocol, salt + deployer decides contract address bytes32 salt = keccak256(abi.encodePacked(_name)); address payable proxyAddr = Create2.deploy(0, salt, bytecode); emit ProtocolInitiation(proxyAddr); bytes memory initData = abi.encodeWithSelector(PROTOCOL_INIT_SIGNITURE, _name, _active, _collateral, _timestamps, _timestampNames); InitializableAdminUpgradeabilityProxy(proxyAddr).initialize(protocolImplementation, owner(), initData); protocols[_name] = proxyAddr; return proxyAddr; } /// @dev update this will only affect protocols deployed after function updateProtocolImplementation(address _newImplementation) external override onlyOwner returns (bool) { require(Address.isContract(_newImplementation), "COVER: new implementation is not a contract"); protocolImplementation = _newImplementation; return true; } /// @dev update this will only affect covers of protocols deployed after function updateCoverImplementation(address _newImplementation) external override onlyOwner returns (bool) { require(Address.isContract(_newImplementation), "COVER: new implementation is not a contract"); coverImplementation = _newImplementation; return true; } /// @dev update this will only affect covTokens of covers of protocols deployed after function updateCoverERC20Implementation(address _newImplementation) external override onlyOwner returns (bool) { require(Address.isContract(_newImplementation), "COVER: new implementation is not a contract"); coverERC20Implementation = _newImplementation; return true; } function updateFees( uint16 _redeemFeeNumerator, uint16 _redeemFeeDenominator ) external override onlyGovernance returns (bool) { require(_redeemFeeDenominator > 0, "COVER: denominator cannot be 0"); redeemFeeNumerator = _redeemFeeNumerator; redeemFeeDenominator = _redeemFeeDenominator; return true; } function updateClaimManager(address _address) external override onlyOwner returns (bool) { require(_address != address(0), "COVER: address cannot be 0"); claimManager = _address; return true; } function updateGovernance(address _address) external override onlyGovernance returns (bool) { require(_address != address(0), "COVER: address cannot be 0"); require(_address != owner(), "COVER: governance cannot be owner"); governance = _address; return true; } function updateTreasury(address _address) external override onlyOwner returns (bool) { require(_address != address(0), "COVER: address cannot be 0"); treasury = _address; return true; } function _computeAddress(bytes32 salt, address deployer) private pure returns (address) { bytes memory bytecode = type(InitializableAdminUpgradeabilityProxy).creationCode; return Create2.computeAddress(salt, keccak256(bytecode), deployer); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.3; import "./utils/SafeMath.sol"; import "./utils/Ownable.sol"; import "./interfaces/IClaimConfig.sol"; import "./interfaces/IProtocol.sol"; /** * @title Config for ClaimManagement contract * @author Alan */ contract ClaimConfig is IClaimConfig, Ownable { using SafeMath for uint256; bool public override allowPartialClaim = true; address public override auditor; address public override governance; address public override treasury; address public override protocolFactory; // The max time allowed from filing a claim to a decision made uint256 public override maxClaimDecisionWindow = 7 days; uint256 public override baseClaimFee = 10e18; uint256 public override forceClaimFee = 500e18; uint256 public override feeMultiplier = 2; // protocol => claim fee mapping(address => uint256) private protocolClaimFee; IERC20 public override feeCurrency = IERC20(0x6B175474E89094C44Da98b954EedeAC495271d0F); modifier onlyGovernance() { require(msg.sender == governance, "COVER_CC: !governance"); _; } /** * @notice Set the address of governance * @dev Governance address cannot be set to owner or 0 address */ function setGovernance(address _governance) external override onlyGovernance { require(_governance != address(0), "COVER_CC: governance cannot be 0"); require(_governance != owner(), "COVER_CC: governance cannot be owner"); governance = _governance; } /** * @notice Set the address of treasury */ function setTreasury(address _treasury) external override onlyOwner { require(_treasury != address(0), "COVER_CC: treasury cannot be 0"); treasury = _treasury; } /** * @notice Set max time window allowed to decide a claim after filed, requires at least 3 days for voting */ function setMaxClaimDecisionWindow(uint256 _newTimeWindow) external override onlyOwner { require(_newTimeWindow < 3 days, "COVER_CC: window too short"); maxClaimDecisionWindow = _newTimeWindow; } /** * @notice Set the status and address of auditor */ function setAuditor(address _auditor) external override onlyOwner { auditor = _auditor; } /** * @notice Set the status of allowing partial claims */ function setPartialClaimStatus(bool _allowPartialClaim) external override onlyOwner { allowPartialClaim = _allowPartialClaim; } /** * @notice Set fees and currency of filing a claim * @dev `_forceClaimFee` must be > `_baseClaimFee` */ function setFeeAndCurrency(uint256 _baseClaimFee, uint256 _forceClaimFee, address _currency) external override onlyGovernance { require(_baseClaimFee > 0, "COVER_CC: baseClaimFee <= 0"); require(_forceClaimFee > _baseClaimFee, "COVER_CC: forceClaimFee <= baseClaimFee"); require(_currency != address(0), "COVER_CC: feeCurrency cannot be 0"); baseClaimFee = _baseClaimFee; forceClaimFee = _forceClaimFee; feeCurrency = IERC20(_currency); } /** * @notice Set the fee multiplier to `_multiplier` * @dev `_multiplier` must be atleast 1 */ function setFeeMultiplier(uint256 _multiplier) external override onlyGovernance { require(_multiplier >= 1, "COVER_CC: multiplier < 1"); feeMultiplier = _multiplier; } /** * @notice Get status of auditor voting * @dev Returns false if `auditor` is 0 * @return status of auditor voting in decideClaim */ function isAuditorVoting() public view override returns (bool) { return auditor != address(0); } /** * @notice Get the claim fee for protocol `_protocol` * @dev Will return `baseClaimFee` if fee is 0 * @return fee for filing a claim for protocol */ function getProtocolClaimFee(address _protocol) public view override returns (uint256) { return protocolClaimFee[_protocol] == 0 ? baseClaimFee : protocolClaimFee[_protocol]; } /** * @notice Get the time window allowed to file after an incident happened * @dev it is calculated based on the noclaimRedeemDelay of the protocol - (maxClaimDecisionWindow) - 1hour * @return time window */ function getFileClaimWindow(address _protocol) public view override returns (uint256) { uint256 noclaimRedeemDelay = IProtocol(_protocol).noclaimRedeemDelay(); return noclaimRedeemDelay.sub(maxClaimDecisionWindow).sub(1 hours); } /** * @notice Updates fee for protocol `_protocol` by multiplying current fee by `feeMultiplier` * @dev protocolClaimFee[protocol] cannot exceed `baseClaimFee` */ function _updateProtocolClaimFee(address _protocol) internal { uint256 newFee = getProtocolClaimFee(_protocol).mul(feeMultiplier); if (newFee <= forceClaimFee) { protocolClaimFee[_protocol] = newFee; } } /** * @notice Resets fee for protocol `_protocol` to `baseClaimFee` */ function _resetProtocolClaimFee(address _protocol) internal { protocolClaimFee[_protocol] = baseClaimFee; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.3; /** * @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: No License pragma solidity ^0.7.3; import "../interfaces/IOwnable.sol"; import "./Initializable.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. * @author crypto-pumpkin@github * * By initialization, the owner account will be the one that called initializeOwner. 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. */ contract Ownable is Initializable { address private _owner; address private _newOwner; event OwnershipTransferInitiated(address indexed previousOwner, address indexed newOwner); event OwnershipTransferCompleted(address indexed previousOwner, address indexed newOwner); /** * @dev COVER: Initializes the contract setting the deployer as the initial owner. */ function initializeOwner() internal initializer { _owner = msg.sender; emit OwnershipTransferCompleted(address(0), _owner); } /** * @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 == msg.sender, "Ownable: caller is not the owner"); _; } /** * @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 OwnershipTransferInitiated(_owner, newOwner); _newOwner = newOwner; } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function claimOwnership() public virtual { require(_newOwner == msg.sender, "Ownable: caller is not the owner"); emit OwnershipTransferCompleted(_owner, _newOwner); _owner = _newOwner; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.3; import "./IERC20.sol"; /** * @dev ClaimConfg contract interface. See {ClaimConfig}. * @author Alan */ interface IClaimConfig { function allowPartialClaim() external view returns (bool); function auditor() external view returns (address); function governance() external view returns (address); function treasury() external view returns (address); function protocolFactory() external view returns (address); function maxClaimDecisionWindow() external view returns (uint256); function baseClaimFee() external view returns (uint256); function forceClaimFee() external view returns (uint256); function feeMultiplier() external view returns (uint256); function feeCurrency() external view returns (IERC20); function getFileClaimWindow(address _protocol) external view returns (uint256); function isAuditorVoting() external view returns (bool); function getProtocolClaimFee(address _protocol) external view returns (uint256); // @notice only dev function setMaxClaimDecisionWindow(uint256 _newTimeWindow) external; function setTreasury(address _treasury) external; function setAuditor(address _auditor) external; function setPartialClaimStatus(bool _allowPartialClaim) external; // @dev Only callable by governance function setGovernance(address _governance) external; function setFeeAndCurrency(uint256 _baseClaimFee, uint256 _forceClaimFee, address _currency) external; function setFeeMultiplier(uint256 _multiplier) external; }
// SPDX-License-Identifier: No License pragma solidity ^0.7.3; /** * @dev Protocol contract interface. See {Protocol}. * @author crypto-pumpkin@github */ interface IProtocol { /// @notice emit when a claim against the protocol is accepted event ClaimAccepted(uint256 newClaimNonce); function getProtocolDetails() external view returns ( bytes32 _name, bool _active, uint256 _claimNonce, uint256 _claimRedeemDelay, uint256 _noclaimRedeemDelay, address[] memory _collaterals, uint48[] memory _expirationTimestamps, address[] memory _allCovers, address[] memory _allActiveCovers ); function active() external view returns (bool); function name() external view returns (bytes32); function claimNonce() external view returns (uint256); /// @notice delay # of seconds for redeem with accepted claim, redeemCollateral is not affected function claimRedeemDelay() external view returns (uint256); /// @notice delay # of seconds for redeem without accepted claim, redeemCollateral is not affected function noclaimRedeemDelay() external view returns (uint256); function activeCovers(uint256 _index) external view returns (address); function claimDetails(uint256 _claimNonce) external view returns (uint16 _payoutNumerator, uint16 _payoutDenominator, uint48 _incidentTimestamp, uint48 _timestamp); function collateralStatusMap(address _collateral) external view returns (uint8 _status); function expirationTimestampMap(uint48 _expirationTimestamp) external view returns (bytes32 _name, uint8 _status); function coverMap(address _collateral, uint48 _expirationTimestamp) external view returns (address); function collaterals(uint256 _index) external view returns (address); function collateralsLength() external view returns (uint256); function expirationTimestamps(uint256 _index) external view returns (uint48); function expirationTimestampsLength() external view returns (uint256); function activeCoversLength() external view returns (uint256); function claimsLength() external view returns (uint256); function addCover(address _collateral, uint48 _timestamp, uint256 _amount) external returns (bool); /// @notice access restriction - claimManager function enactClaim(uint16 _payoutNumerator, uint16 _payoutDenominator, uint48 _incidentTimestamp, uint256 _protocolNonce) external returns (bool); /// @notice access restriction - dev function setActive(bool _active) external returns (bool); function updateExpirationTimestamp(uint48 _expirationTimestamp, bytes32 _expirationTimestampName, uint8 _status) external returns (bool); function updateCollateral(address _collateral, uint8 _status) external returns (bool); /// @notice access restriction - governance function updateClaimRedeemDelay(uint256 _claimRedeemDelay) external returns (bool); function updateNoclaimRedeemDelay(uint256 _noclaimRedeemDelay) external returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.3; /** * @title Interface of Ownable */ interface IOwnable { function owner() external view returns (address); }
// SPDX-License-Identifier: MIT // solhint-disable-next-line compiler-version pragma solidity >=0.4.24 <0.8.0; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { require(_initializing || _isConstructor() || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } /// @dev Returns true if and only if the function is running in the constructor function _isConstructor() private view returns (bool) { // extcodesize checks the size of the code stored in an address, and // address returns the current address. Since the code is still not // deployed when running a constructor, any checks on its code size will // yield zero, making it an effective way to detect if a contract is // under construction or not. address self = address(this); uint256 cs; // solhint-disable-next-line no-inline-assembly assembly { cs := extcodesize(self) } return cs == 0; } }
// SPDX-License-Identifier: No License pragma solidity ^0.7.3; /** * @title Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); function symbol() external view returns (string memory); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function approve(address spender, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); function totalSupply() external view returns (uint256); function increaseAllowance(address spender, uint256 addedValue) external returns (bool); function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.3; pragma experimental ABIEncoderV2; import "./ClaimConfig.sol"; import "./interfaces/IProtocol.sol"; import "./interfaces/IProtocolFactory.sol"; import "./interfaces/IClaimManagement.sol"; import "./utils/SafeERC20.sol"; /** * @title Claim Management for claims filed for a COVER supported protocol * @author Alan */ contract ClaimManagement is IClaimManagement, ClaimConfig { using SafeERC20 for IERC20; using SafeMath for uint256; // protocol => nonce => Claim[] mapping(address => mapping(uint256 => Claim[])) public override protocolClaims; modifier onlyApprovedDecider() { if (isAuditorVoting()) { require(msg.sender == auditor, "COVER_CM: !auditor"); } else { require(msg.sender == governance, "COVER_CM: !governance"); } _; } modifier onlyWhenAuditorVoting() { require(isAuditorVoting(), "COVER_CM: !isAuditorVoting"); _; } /** * @notice Initialize governance and treasury addresses * @dev Governance address cannot be set to owner address; `_auditor` can be 0. * @param _governance address: address of the governance account * @param _auditor address: address of the auditor account * @param _treasury address: address of the treasury account * @param _protocolFactory address: address of the protocol factory */ constructor(address _governance, address _auditor, address _treasury, address _protocolFactory) { require( _governance != msg.sender && _governance != address(0), "COVER_CC: governance cannot be owner or 0" ); require(_treasury != address(0), "COVER_CM: treasury cannot be 0"); require(_protocolFactory != address(0), "COVER_CM: protocol factory cannot be 0"); governance = _governance; auditor = _auditor; treasury = _treasury; protocolFactory = _protocolFactory; initializeOwner(); } /** * @notice File a claim for a COVER-supported contract `_protocol` * by paying the `protocolClaimFee[_protocol]` fee * @dev `_incidentTimestamp` must be within the past 14 days * @param _protocol address: contract address of the protocol that COVER supports * @param _protocolName bytes32: protocol name for `_protocol` * @param _incidentTimestamp uint48: timestamp of the claim incident * * Emits ClaimFiled */ function fileClaim(address _protocol, bytes32 _protocolName, uint48 _incidentTimestamp) external override { require(_protocol != address(0), "COVER_CM: protocol cannot be 0"); require( _protocol == getAddressFromFactory(_protocolName), "COVER_CM: invalid protocol address" ); require( block.timestamp.sub(_incidentTimestamp) <= getFileClaimWindow(_protocol), "COVER_CM: block.timestamp - incidentTimestamp > fileClaimWindow" ); uint256 nonce = getProtocolNonce(_protocol); uint256 claimFee = getProtocolClaimFee(_protocol); protocolClaims[_protocol][nonce].push(Claim({ state: ClaimState.Filed, filedBy: msg.sender, payoutNumerator: 0, payoutDenominator: 1, filedTimestamp: uint48(block.timestamp), incidentTimestamp: _incidentTimestamp, decidedTimestamp: 0, feePaid: claimFee })); feeCurrency.safeTransferFrom(msg.sender, address(this), claimFee); _updateProtocolClaimFee(_protocol); emit ClaimFiled({ isForced: false, filedBy: msg.sender, protocol: _protocol, incidentTimestamp: _incidentTimestamp, nonce: nonce, index: protocolClaims[_protocol][nonce].length - 1, feePaid: claimFee }); } /** * @notice Force file a claim for a COVER-supported contract `_protocol` * that bypasses validateClaim by paying the `forceClaimFee` fee * @dev `_incidentTimestamp` must be within the past 14 days. * Only callable when isAuditorVoting is true * @param _protocol address: contract address of the protocol that COVER supports * @param _protocolName bytes32: protocol name for `_protocol` * @param _incidentTimestamp uint48: timestamp of the claim incident * * Emits ClaimFiled */ function forceFileClaim(address _protocol, bytes32 _protocolName, uint48 _incidentTimestamp) external override onlyWhenAuditorVoting { require(_protocol != address(0), "COVER_CM: protocol cannot be 0"); require( _protocol == getAddressFromFactory(_protocolName), "COVER_CM: invalid protocol address" ); require( block.timestamp.sub(_incidentTimestamp) <= getFileClaimWindow(_protocol), "COVER_CM: block.timestamp - incidentTimestamp > fileClaimWindow" ); uint256 nonce = getProtocolNonce(_protocol); protocolClaims[_protocol][nonce].push(Claim({ state: ClaimState.ForceFiled, filedBy: msg.sender, payoutNumerator: 0, payoutDenominator: 1, filedTimestamp: uint48(block.timestamp), incidentTimestamp: _incidentTimestamp, decidedTimestamp: 0, feePaid: forceClaimFee })); feeCurrency.safeTransferFrom(msg.sender, address(this), forceClaimFee); emit ClaimFiled({ isForced: true, filedBy: msg.sender, protocol: _protocol, incidentTimestamp: _incidentTimestamp, nonce: nonce, index: protocolClaims[_protocol][nonce].length - 1, feePaid: forceClaimFee }); } /** * @notice Validates whether claim will be passed to approvedDecider to decideClaim * @dev Only callable if isAuditorVoting is true * @param _protocol address: contract address of the protocol that COVER supports * @param _nonce uint256: nonce of the protocol * @param _index uint256: index of the claim * @param _claimIsValid bool: true if claim is valid and passed to auditor, false otherwise * * Emits ClaimValidated */ function validateClaim(address _protocol, uint256 _nonce, uint256 _index, bool _claimIsValid) external override onlyGovernance onlyWhenAuditorVoting { Claim storage claim = protocolClaims[_protocol][_nonce][_index]; require( _nonce == getProtocolNonce(_protocol), "COVER_CM: input nonce != protocol nonce" ); require(claim.state == ClaimState.Filed, "COVER_CM: claim not filed"); if (_claimIsValid) { claim.state = ClaimState.Validated; _resetProtocolClaimFee(_protocol); } else { claim.state = ClaimState.Invalidated; claim.decidedTimestamp = uint48(block.timestamp); feeCurrency.safeTransfer(treasury, claim.feePaid); } emit ClaimValidated({ claimIsValid: _claimIsValid, protocol: _protocol, nonce: _nonce, index: _index }); } /** * @notice Decide whether claim for a protocol should be accepted(will payout) or denied * @dev Only callable by approvedDecider * @param _protocol address: contract address of the protocol that COVER supports * @param _nonce uint256: nonce of the protocol * @param _index uint256: index of the claim * @param _claimIsAccepted bool: true if claim is accepted and will payout, otherwise false * @param _payoutNumerator uint256: numerator of percent payout, 0 if _claimIsAccepted = false * @param _payoutDenominator uint256: denominator of percent payout * * Emits ClaimDecided */ function decideClaim( address _protocol, uint256 _nonce, uint256 _index, bool _claimIsAccepted, uint16 _payoutNumerator, uint16 _payoutDenominator ) external override onlyApprovedDecider { require( _nonce == getProtocolNonce(_protocol), "COVER_CM: input nonce != protocol nonce" ); Claim storage claim = protocolClaims[_protocol][_nonce][_index]; if (isAuditorVoting()) { require( claim.state == ClaimState.Validated || claim.state == ClaimState.ForceFiled, "COVER_CM: claim not validated or forceFiled" ); } else { require(claim.state == ClaimState.Filed, "COVER_CM: claim not filed"); } if (_isDecisionWindowPassed(claim)) { // Max decision claim window passed, claim is default to Denied _claimIsAccepted = false; } if (_claimIsAccepted) { require(_payoutNumerator > 0, "COVER_CM: claim accepted, but payoutNumerator == 0"); if (allowPartialClaim) { require( _payoutNumerator <= _payoutDenominator, "COVER_CM: payoutNumerator > payoutDenominator" ); } else { require( _payoutNumerator == _payoutDenominator, "COVER_CM: payoutNumerator != payoutDenominator" ); } claim.state = ClaimState.Accepted; claim.payoutNumerator = _payoutNumerator; claim.payoutDenominator = _payoutDenominator; feeCurrency.safeTransfer(claim.filedBy, claim.feePaid); _resetProtocolClaimFee(_protocol); IProtocol(_protocol).enactClaim(_payoutNumerator, _payoutDenominator, claim.incidentTimestamp, _nonce); } else { require(_payoutNumerator == 0, "COVER_CM: claim denied (default if passed window), but payoutNumerator != 0"); claim.state = ClaimState.Denied; feeCurrency.safeTransfer(treasury, claim.feePaid); } claim.decidedTimestamp = uint48(block.timestamp); emit ClaimDecided({ claimIsAccepted: _claimIsAccepted, protocol: _protocol, nonce: _nonce, index: _index, payoutNumerator: _payoutNumerator, payoutDenominator: _payoutDenominator }); } /** * @notice Get all claims for protocol `_protocol` and nonce `_nonce` in state `_state` * @param _protocol address: contract address of the protocol that COVER supports * @param _nonce uint256: nonce of the protocol * @param _state ClaimState: state of claim * @return all claims for protocol and nonce in given state */ function getAllClaimsByState(address _protocol, uint256 _nonce, ClaimState _state) external view override returns (Claim[] memory) { Claim[] memory allClaims = protocolClaims[_protocol][_nonce]; uint256 count; Claim[] memory temp = new Claim[](allClaims.length); for (uint i = 0; i < allClaims.length; i++) { if (allClaims[i].state == _state) { temp[count] = allClaims[i]; count++; } } Claim[] memory claimsByState = new Claim[](count); for (uint i = 0; i < count; i++) { claimsByState[i] = temp[i]; } return claimsByState; } /** * @notice Get all claims for protocol `_protocol` and nonce `_nonce` * @param _protocol address: contract address of the protocol that COVER supports * @param _nonce uint256: nonce of the protocol * @return all claims for protocol and nonce */ function getAllClaimsByNonce(address _protocol, uint256 _nonce) external view override returns (Claim[] memory) { return protocolClaims[_protocol][_nonce]; } /** * @notice Get the protocol address from the protocol factory * @param _protocolName bytes32: protocol name * @return address corresponding to the protocol name `_protocolName` */ function getAddressFromFactory(bytes32 _protocolName) public view override returns (address) { return IProtocolFactory(protocolFactory).protocols(_protocolName); } /** * @notice Get the current nonce for protocol `_protocol` * @param _protocol address: contract address of the protocol that COVER supports * @return the current nonce for protocol `_protocol` */ function getProtocolNonce(address _protocol) public view override returns (uint256) { return IProtocol(_protocol).claimNonce(); } /** * The times passed since the claim was filed has to be less than the max claim decision window */ function _isDecisionWindowPassed(Claim memory claim) private view returns (bool) { return block.timestamp.sub(claim.filedTimestamp) > maxClaimDecisionWindow.sub(1 hours); } }
// SPDX-License-Identifier: No License pragma solidity ^0.7.3; /** * @dev ProtocolFactory contract interface. See {ProtocolFactory}. * @author crypto-pumpkin@github */ interface IProtocolFactory { /// @notice emit when a new protocol is supported in COVER event ProtocolInitiation(address protocolAddress); function getAllProtocolAddresses() external view returns (address[] memory); function getRedeemFees() external view returns (uint16 _numerator, uint16 _denominator); function redeemFeeNumerator() external view returns (uint16); function redeemFeeDenominator() external view returns (uint16); function protocolImplementation() external view returns (address); function coverImplementation() external view returns (address); function coverERC20Implementation() external view returns (address); function treasury() external view returns (address); function governance() external view returns (address); function claimManager() external view returns (address); function protocols(bytes32 _protocolName) external view returns (address); function getProtocolsLength() external view returns (uint256); function getProtocolNameAndAddress(uint256 _index) external view returns (bytes32, address); /// @notice return contract address, the contract may not be deployed yet function getProtocolAddress(bytes32 _name) external view returns (address); /// @notice return contract address, the contract may not be deployed yet function getCoverAddress(bytes32 _protocolName, uint48 _timestamp, address _collateral, uint256 _claimNonce) external view returns (address); /// @notice return contract address, the contract may not be deployed yet function getCovTokenAddress(bytes32 _protocolName, uint48 _timestamp, address _collateral, uint256 _claimNonce, bool _isClaimCovToken) external view returns (address); /// @notice access restriction - owner (dev) /// @dev update this will only affect contracts deployed after function updateProtocolImplementation(address _newImplementation) external returns (bool); /// @dev update this will only affect contracts deployed after function updateCoverImplementation(address _newImplementation) external returns (bool); /// @dev update this will only affect contracts deployed after function updateCoverERC20Implementation(address _newImplementation) external returns (bool); function addProtocol( bytes32 _name, bool _active, address _collateral, uint48[] calldata _timestamps, bytes32[] calldata _timestampNames ) external returns (address); function updateTreasury(address _address) external returns (bool); function updateClaimManager(address _address) external returns (bool); /// @notice access restriction - governance function updateFees(uint16 _redeemFeeNumerator, uint16 _redeemFeeDenominator) external returns (bool); function updateGovernance(address _address) external returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.3; pragma experimental ABIEncoderV2; /** * @dev ClaimManagement contract interface. See {ClaimManagement}. * @author Alan */ interface IClaimManagement { enum ClaimState { Filed, ForceFiled, Validated, Invalidated, Accepted, Denied } struct Claim { ClaimState state; // Current state of claim address filedBy; // Address of user who filed claim uint16 payoutNumerator; // Numerator of percent to payout uint16 payoutDenominator; // Denominator of percent to payout uint48 filedTimestamp; // Timestamp of submitted claim uint48 incidentTimestamp; // Timestamp of the incident the claim is filed for uint48 decidedTimestamp; // Timestamp when claim outcome is decided uint256 feePaid; // Fee paid to file the claim } function protocolClaims(address _protocol, uint256 _nonce, uint256 _index) external view returns ( ClaimState state, address filedBy, uint16 payoutNumerator, uint16 payoutDenominator, uint48 filedTimestamp, uint48 incidentTimestamp, uint48 decidedTimestamp, uint256 feePaid ); function fileClaim(address _protocol, bytes32 _protocolName, uint48 _incidentTimestamp) external; function forceFileClaim(address _protocol, bytes32 _protocolName, uint48 _incidentTimestamp) external; // @dev Only callable by owner when auditor is voting function validateClaim(address _protocol, uint256 _nonce, uint256 _index, bool _claimIsValid) external; // @dev Only callable by approved decider, governance or auditor (isAuditorVoting == true) function decideClaim(address _protocol, uint256 _nonce, uint256 _index, bool _claimIsAccepted, uint16 _payoutNumerator, uint16 _payoutDenominator) external; function getAllClaimsByState(address _protocol, uint256 _nonce, ClaimState _state) external view returns (Claim[] memory); function getAllClaimsByNonce(address _protocol, uint256 _nonce) external view returns (Claim[] memory); function getAddressFromFactory(bytes32 _protocolName) external view returns (address); function getProtocolNonce(address _protocol) external view returns (uint256); event ClaimFiled( bool indexed isForced, address indexed filedBy, address indexed protocol, uint48 incidentTimestamp, uint256 nonce, uint256 index, uint256 feePaid ); event ClaimValidated( bool indexed claimIsValid, address indexed protocol, uint256 nonce, uint256 index ); event ClaimDecided( bool indexed claimIsAccepted, address indexed protocol, uint256 nonce, uint256 index, uint16 payoutNumerator, uint16 payoutDenominator ); }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.3; import "../interfaces/IERC20.sol"; import "./SafeMath.sol"; import "./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.7.3; 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) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); 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: No License pragma solidity ^0.7.3; import "./proxy/InitializableAdminUpgradeabilityProxy.sol"; import "./utils/Create2.sol"; import "./utils/Initializable.sol"; import "./utils/Ownable.sol"; import "./utils/SafeMath.sol"; import "./utils/SafeERC20.sol"; import "./utils/ReentrancyGuard.sol"; import "./interfaces/ICover.sol"; import "./interfaces/IERC20.sol"; import "./interfaces/IOwnable.sol"; import "./interfaces/IProtocol.sol"; import "./interfaces/IProtocolFactory.sol"; /** * @title Protocol contract * @author crypto-pumpkin@github */ contract Protocol is IProtocol, Initializable, ReentrancyGuard, Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; struct ClaimDetails { uint16 payoutNumerator; // 0 to 65,535 uint16 payoutDenominator; // 0 to 65,535 uint48 incidentTimestamp; uint48 claimEnactedTimestamp; } struct ExpirationTimestampInfo { bytes32 name; uint8 status; // 0 never set; 1 active, 2 inactive } bytes4 private constant COVER_INIT_SIGNITURE = bytes4(keccak256("initialize(string,uint48,address,uint256)")); /// @notice only active (true) protocol allows adding more covers bool public override active; bytes32 public override name; // nonce of for the protocol's claim status, it also indicates count of accepted claim in the past uint256 public override claimNonce; // delay # of seconds for redeem with accepted claim, redeemCollateral is not affected uint256 public override claimRedeemDelay; // delay # of seconds for redeem without accepted claim, redeemCollateral is not affected uint256 public override noclaimRedeemDelay; // only active covers, once there is an accepted claim (enactClaim called successfully), this sets to []. address[] public override activeCovers; address[] private allCovers; /// @notice list of every supported expirationTimestamp, all may not be active. uint48[] public override expirationTimestamps; /// @notice list of every supported collateral, all may not be active. address[] public override collaterals; // [claimNonce] => accepted ClaimDetails ClaimDetails[] public override claimDetails; // @notice collateral => status. 0 never set; 1 active, 2 inactive mapping(address => uint8) public override collateralStatusMap; mapping(uint48 => ExpirationTimestampInfo) public override expirationTimestampMap; // collateral => timestamp => coverAddress, most recent cover created for the collateral and timestamp combination mapping(address => mapping(uint48 => address)) public override coverMap; modifier onlyActive() { require(active, "COVER: protocol not active"); _; } modifier onlyDev() { require(msg.sender == _dev(), "COVER: caller not dev"); _; } modifier onlyGovernance() { require(msg.sender == IProtocolFactory(owner()).governance(), "COVER: caller not governance"); _; } /// @dev Initialize, called once function initialize ( bytes32 _protocolName, bool _active, address _collateral, uint48[] calldata _expirationTimestamps, bytes32[] calldata _expirationTimestampNames ) external initializer { name = _protocolName; collaterals.push(_collateral); active = _active; expirationTimestamps = _expirationTimestamps; collateralStatusMap[_collateral] = 1; for (uint i = 0; i < _expirationTimestamps.length; i++) { if (block.timestamp < _expirationTimestamps[i]) { expirationTimestampMap[_expirationTimestamps[i]] = ExpirationTimestampInfo( _expirationTimestampNames[i], 1 ); } } // set default delay for redeem claimRedeemDelay = 2 days; noclaimRedeemDelay = 10 days; initializeOwner(); } function getProtocolDetails() external view override returns ( bytes32 _name, bool _active, uint256 _claimNonce, uint256 _claimRedeemDelay, uint256 _noclaimRedeemDelay, address[] memory _collaterals, uint48[] memory _expirationTimestamps, address[] memory _allCovers, address[] memory _allActiveCovers ) { return ( name, active, claimNonce, claimRedeemDelay, noclaimRedeemDelay, getCollaterals(), getExpirationTimestamps(), getAllCovers(), getAllActiveCovers() ); } function collateralsLength() external view override returns (uint256) { return collaterals.length; } function expirationTimestampsLength() external view override returns (uint256) { return expirationTimestamps.length; } function activeCoversLength() external view override returns (uint256) { return activeCovers.length; } function claimsLength() external view override returns (uint256) { return claimDetails.length; } /** * @notice add cover for sender * - transfer collateral from sender to cover contract * - mint the same amount CLAIM covToken to sender * - mint the same amount NOCLAIM covToken to sender */ function addCover(address _collateral, uint48 _timestamp, uint256 _amount) external override onlyActive nonReentrant returns (bool) { require(_amount > 0, "COVER: amount <= 0"); require(collateralStatusMap[_collateral] == 1, "COVER: invalid collateral"); require(block.timestamp < _timestamp && expirationTimestampMap[_timestamp].status == 1, "COVER: invalid expiration date"); // Validate sender collateral balance is > amount IERC20 collateral = IERC20(_collateral); require(collateral.balanceOf(msg.sender) >= _amount, "COVER: amount > collateral balance"); address addr = coverMap[_collateral][_timestamp]; // Deploy new cover contract if not exist or if claim accepted if (addr == address(0) || ICover(addr).claimNonce() != claimNonce) { string memory coverName = _generateCoverName(_timestamp, collateral.symbol()); bytes memory bytecode = type(InitializableAdminUpgradeabilityProxy).creationCode; bytes32 salt = keccak256(abi.encodePacked(name, _timestamp, _collateral, claimNonce)); addr = Create2.deploy(0, salt, bytecode); bytes memory initData = abi.encodeWithSelector(COVER_INIT_SIGNITURE, coverName, _timestamp, _collateral, claimNonce); address coverImplementation = IProtocolFactory(owner()).coverImplementation(); InitializableAdminUpgradeabilityProxy(payable(addr)).initialize( coverImplementation, IOwnable(owner()).owner(), initData ); activeCovers.push(addr); allCovers.push(addr); coverMap[_collateral][_timestamp] = addr; } // move collateral to the cover contract and mint CovTokens to sender uint256 coverBalanceBefore = collateral.balanceOf(addr); collateral.safeTransferFrom(msg.sender, addr, _amount); uint256 coverBalanceAfter = collateral.balanceOf(addr); require(coverBalanceAfter > coverBalanceBefore, "COVER: collateral transfer failed"); ICover(addr).mint(coverBalanceAfter.sub(coverBalanceBefore), msg.sender); return true; } /// @notice update status or add new expiration timestamp function updateExpirationTimestamp(uint48 _expirationTimestamp, bytes32 _expirationTimestampName, uint8 _status) external override onlyDev returns (bool) { require(block.timestamp < _expirationTimestamp, "COVER: invalid expiration date"); require(_status > 0 && _status < 3, "COVER: status not in (0, 2]"); if (expirationTimestampMap[_expirationTimestamp].status == 0) { expirationTimestamps.push(_expirationTimestamp); } expirationTimestampMap[_expirationTimestamp] = ExpirationTimestampInfo( _expirationTimestampName, _status ); return true; } /// @notice update status or add new collateral function updateCollateral(address _collateral, uint8 _status) external override onlyDev returns (bool) { require(_collateral != address(0), "COVER: address cannot be 0"); require(_status > 0 && _status < 3, "COVER: status not in (0, 2]"); if (collateralStatusMap[_collateral] == 0) { collaterals.push(_collateral); } collateralStatusMap[_collateral] = _status; return true; } /** * @dev enact accepted claim, all covers are to be paid out * - increment claimNonce * - delete activeCovers list * - only COVER claim manager can call this function * * Emit ClaimAccepted */ function enactClaim( uint16 _payoutNumerator, uint16 _payoutDenominator, uint48 _incidentTimestamp, uint256 _protocolNonce ) external override returns (bool) { require(_protocolNonce == claimNonce, "COVER: nonces do not match"); require(_payoutNumerator <= _payoutDenominator && _payoutNumerator > 0, "COVER: payout % is not in (0%, 100%]"); require(msg.sender == IProtocolFactory(owner()).claimManager(), "COVER: caller not claimManager"); claimNonce = claimNonce.add(1); delete activeCovers; claimDetails.push(ClaimDetails( _payoutNumerator, _payoutDenominator, _incidentTimestamp, uint48(block.timestamp) )); emit ClaimAccepted(_protocolNonce); return true; } // update status of protocol, if false, will pause new cover creation function setActive(bool _active) external override onlyDev returns (bool) { active = _active; return true; } function updateClaimRedeemDelay(uint256 _claimRedeemDelay) external override onlyGovernance returns (bool) { claimRedeemDelay = _claimRedeemDelay; return true; } function updateNoclaimRedeemDelay(uint256 _noclaimRedeemDelay) external override onlyGovernance returns (bool) { noclaimRedeemDelay = _noclaimRedeemDelay; return true; } function getAllCovers() private view returns (address[] memory) { return allCovers; } function getAllActiveCovers() private view returns (address[] memory) { return activeCovers; } function getCollaterals() private view returns (address[] memory) { return collaterals; } function getExpirationTimestamps() private view returns (uint48[] memory) { return expirationTimestamps; } /// @dev the owner of this contract is ProtocolFactory contract. The owner of ProtocolFactory is dev function _dev() private view returns (address) { return IOwnable(owner()).owner(); } /// @dev generate the cover name. Example: COVER_CURVE_2020_12_31_DAI_0 function _generateCoverName(uint48 _expirationTimestamp, string memory _collateralSymbol) internal view returns (string memory) { return string(abi.encodePacked( "COVER", "_", bytes32ToString(name), "_", bytes32ToString(expirationTimestampMap[_expirationTimestamp].name), "_", _collateralSymbol, "_", uintToString(claimNonce) )); } // string helper function bytes32ToString(bytes32 _bytes32) internal pure returns (string memory) { uint8 i = 0; while(i < 32 && _bytes32[i] != 0) { i++; } bytes memory bytesArray = new bytes(i); for (i = 0; i < 32 && _bytes32[i] != 0; i++) { bytesArray[i] = _bytes32[i]; } return string(bytesArray); } // string helper function uintToString(uint256 _i) internal pure returns (string memory _uintAsString) { if (_i == 0) { return "0"; } uint256 j = _i; uint256 len; while (j != 0) { len++; j /= 10; } bytes memory bstr = new bytes(len); uint256 k = len - 1; while (_i != 0) { bstr[k--] = byte(uint8(48 + _i % 10)); _i /= 10; } return string(bstr); } }
// SPDX-License-Identifier: No License pragma solidity ^0.7.3; import './BaseAdminUpgradeabilityProxy.sol'; /** * @title InitializableAdminUpgradeabilityProxy * @dev Extends from BaseAdminUpgradeabilityProxy with an initializer for * initializing the implementation, admin, and init data. */ contract InitializableAdminUpgradeabilityProxy is BaseAdminUpgradeabilityProxy { /** * Contract initializer. * @param _logic address of the initial implementation. * @param _admin Address of the proxy administrator. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ function initialize(address _logic, address _admin, bytes memory _data) public payable { require(_implementation() == address(0)); assert(IMPLEMENTATION_SLOT == bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)); _setImplementation(_logic); if(_data.length > 0) { (bool success,) = _logic.delegatecall(_data); require(success); } assert(ADMIN_SLOT == bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1)); _setAdmin(_admin); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.3; /** * @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer. * `CREATE2` can be used to compute in advance the address where a smart * contract will be deployed, which allows for interesting new mechanisms known * as 'counterfactual interactions'. * * See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more * information. */ library Create2 { /** * @dev Deploys a contract using `CREATE2`. The address where the contract * will be deployed can be known in advance via {computeAddress}. * * The bytecode for a contract can be obtained from Solidity with * `type(contractName).creationCode`. * * Requirements: * * - `bytecode` must not be empty. * - `salt` must have not been used for `bytecode` already. * - the factory must have a balance of at least `amount`. * - if `amount` is non-zero, `bytecode` must have a `payable` constructor. */ function deploy(uint256 amount, bytes32 salt, bytes memory bytecode) internal returns (address payable) { address payable addr; require(address(this).balance >= amount, "Create2: insufficient balance"); require(bytecode.length != 0, "Create2: bytecode length is zero"); // solhint-disable-next-line no-inline-assembly assembly { addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt) } require(addr != address(0), "Create2: Failed on deploy"); return addr; } /** * @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the * `bytecodeHash` or `salt` will result in a new destination address. */ function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) { return computeAddress(salt, bytecodeHash, address(this)); } /** * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}. */ function computeAddress(bytes32 salt, bytes32 bytecodeHash, address deployer) internal pure returns (address) { bytes32 _data = keccak256( abi.encodePacked(bytes1(0xff), deployer, salt, bytecodeHash) ); return address(uint256(_data)); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.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 () { _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: No License pragma solidity ^0.7.3; import "./ICoverERC20.sol"; /** * @title Cover contract interface. See {Cover}. * @author crypto-pumpkin@github */ interface ICover { event NewCoverERC20(address); function getCoverDetails() external view returns (string memory _name, uint48 _expirationTimestamp, address _collateral, uint256 _claimNonce, ICoverERC20 _claimCovToken, ICoverERC20 _noclaimCovToken); function expirationTimestamp() external view returns (uint48); function collateral() external view returns (address); function claimCovToken() external view returns (ICoverERC20); function noclaimCovToken() external view returns (ICoverERC20); function name() external view returns (string memory); function claimNonce() external view returns (uint256); function redeemClaim() external; function redeemNoclaim() external; function redeemCollateral(uint256 _amount) external; /// @notice access restriction - owner (Protocol) function mint(uint256 _amount, address _receiver) external; /// @notice access restriction - dev function setCovTokenSymbol(string calldata _name) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.3; import './BaseUpgradeabilityProxy.sol'; /** * @title BaseAdminUpgradeabilityProxy * @dev This contract combines an upgradeability proxy with an authorization * mechanism for administrative tasks. * All external functions in this contract must be guarded by the * `ifAdmin` modifier. See ethereum/solidity#3864 for a Solidity * feature proposal that would enable this to be done automatically. */ contract BaseAdminUpgradeabilityProxy is BaseUpgradeabilityProxy { /** * @dev Emitted when the administration has been transferred. * @param previousAdmin Address of the previous admin. * @param newAdmin Address of the new admin. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Modifier to check whether the `msg.sender` is the admin. * If it is, it will run the function. Otherwise, it will delegate the call * to the implementation. */ modifier ifAdmin() { if (msg.sender == _admin()) { _; } else { _fallback(); } } /** * @return The address of the proxy admin. */ function admin() external ifAdmin returns (address) { return _admin(); } /** * @return The address of the implementation. */ function implementation() external ifAdmin returns (address) { return _implementation(); } /** * @dev Changes the admin of the proxy. * Only the current admin can call this function. * @param newAdmin Address to transfer proxy administration to. */ function changeAdmin(address newAdmin) external ifAdmin { require(newAdmin != address(0), "Cannot change the admin of a proxy to the zero address"); emit AdminChanged(_admin(), newAdmin); _setAdmin(newAdmin); } /** * @dev Upgrade the backing implementation of the proxy. * Only the admin can call this function. * @param newImplementation Address of the new implementation. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeTo(newImplementation); } /** * @dev Upgrade the backing implementation of the proxy and call a function * on the new implementation. * This is useful to initialize the proxied contract. * @param newImplementation Address of the new implementation. * @param data Data to send as msg.data in the low level call. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. */ function upgradeToAndCall(address newImplementation, bytes calldata data) payable external ifAdmin { _upgradeTo(newImplementation); (bool success,) = newImplementation.delegatecall(data); require(success); } /** * @return adm The admin slot. */ function _admin() internal view returns (address adm) { bytes32 slot = ADMIN_SLOT; assembly { adm := sload(slot) } } /** * @dev Sets the address of the proxy admin. * @param newAdmin Address of the new proxy admin. */ function _setAdmin(address newAdmin) internal { bytes32 slot = ADMIN_SLOT; assembly { sstore(slot, newAdmin) } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.3; import "../utils/Address.sol"; import "./Proxy.sol"; /** * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an * implementation address that can be changed. This address is stored in storage in the location specified by * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the * implementation behind the proxy. * * Upgradeability is only provided internally through {_upgradeTo}. For an externally upgradeable proxy see * {TransparentUpgradeableProxy}. */ contract BaseUpgradeabilityProxy is Proxy { /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; event Upgraded(address indexed implementation); /** * @dev Returns the current implementation address. */ function _implementation() internal override view returns (address impl) { bytes32 slot = IMPLEMENTATION_SLOT; // solhint-disable-next-line no-inline-assembly assembly { impl := sload(slot) } } /** * @dev Upgrades the proxy to a new implementation. * * Emits an {Upgraded} event. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) internal { require(Address.isContract(newImplementation), "UpgradeableProxy: new implementation is not a contract"); bytes32 slot = IMPLEMENTATION_SLOT; // solhint-disable-next-line no-inline-assembly assembly { sstore(slot, newImplementation) } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.3; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _delegate(address implementation) internal { // solhint-disable-next-line no-inline-assembly assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal virtual view returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _fallback() internal { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback () payable external { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive () payable external { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overriden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual { } }
// SPDX-License-Identifier: No License pragma solidity ^0.7.3; import "./IERC20.sol"; /** * @title CoverERC20 contract interface, implements {IERC20}. See {CoverERC20}. * @author crypto-pumpkin@github */ interface ICoverERC20 is IERC20 { function burn(uint256 _amount) external returns (bool); /// @notice access restriction - owner (Cover) function mint(address _account, uint256 _amount) external returns (bool); function setSymbol(string calldata _symbol) external returns (bool); function burnByCover(address _account, uint256 _amount) external returns (bool); }
// SPDX-License-Identifier: No License pragma solidity ^0.7.3; import "./utils/Initializable.sol"; import "./utils/Ownable.sol"; import "./utils/SafeMath.sol"; import "./interfaces/ICoverERC20.sol"; /** * @title CoverERC20 implements {ERC20} standards with expended features for COVER * @author crypto-pumpkin@github * * COVER's covToken Features: * - Has mint and burn by owner (Cover contract) only feature. * - No limit on the totalSupply. * - Should only be created from Cover contract. See {Cover} */ contract CoverERC20 is ICoverERC20, Initializable, Ownable { using SafeMath for uint256; uint8 public constant decimals = 18; string public constant name = "covToken"; // The symbol of the contract string public override symbol; uint256 private _totalSupply; mapping(address => uint256) private balances; mapping(address => mapping (address => uint256)) private allowances; /// @notice Initialize, called once function initialize (string calldata _symbol) external initializer { symbol = _symbol; initializeOwner(); } /// @notice Standard ERC20 function function balanceOf(address account) external view override returns (uint256) { return balances[account]; } /// @notice Standard ERC20 function function totalSupply() external view override returns (uint256) { return _totalSupply; } /// @notice Standard ERC20 function function transfer(address recipient, uint256 amount) external virtual override returns (bool) { _transfer(msg.sender, recipient, amount); return true; } /// @notice Standard ERC20 function function allowance(address owner, address spender) external view virtual override returns (uint256) { return allowances[owner][spender]; } /// @notice Standard ERC20 function function approve(address spender, uint256 amount) external virtual override returns (bool) { _approve(msg.sender, spender, amount); return true; } /// @notice Standard ERC20 function function transferFrom(address sender, address recipient, uint256 amount) external virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, msg.sender, allowances[sender][msg.sender].sub(amount, "CoverERC20: transfer amount exceeds allowance")); return true; } /// @notice New ERC20 function function increaseAllowance(address spender, uint256 addedValue) public virtual override returns (bool) { _approve(msg.sender, spender, allowances[msg.sender][spender].add(addedValue)); return true; } /// @notice New ERC20 function function decreaseAllowance(address spender, uint256 subtractedValue) public virtual override returns (bool) { _approve(msg.sender, spender, allowances[msg.sender][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /// @notice COVER specific function function mint(address _account, uint256 _amount) external override onlyOwner returns (bool) { require(_account != address(0), "CoverERC20: mint to the zero address"); _totalSupply = _totalSupply.add(_amount); balances[_account] = balances[_account].add(_amount); emit Transfer(address(0), _account, _amount); return true; } /// @notice COVER specific function function setSymbol(string calldata _symbol) external override onlyOwner returns (bool) { symbol = _symbol; return true; } /// @notice COVER specific function function burnByCover(address _account, uint256 _amount) external override onlyOwner returns (bool) { _burn(_account, _amount); return true; } /// @notice COVER specific function function burn(uint256 _amount) external override returns (bool) { _burn(msg.sender, _amount); return true; } function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "CoverERC20: transfer from the zero address"); require(recipient != address(0), "CoverERC20: transfer to the zero address"); balances[sender] = balances[sender].sub(amount, "CoverERC20: transfer amount exceeds balance"); balances[recipient] = balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _burn(address account, uint256 amount) internal { require(account != address(0), "CoverERC20: burn from the zero address"); balances[account] = balances[account].sub(amount, "CoverERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint256 amount) internal { require(owner != address(0), "CoverERC20: approve from the zero address"); require(spender != address(0), "CoverERC20: approve to the zero address"); allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } }
// SPDX-License-Identifier: No License pragma solidity ^0.7.3; import "./proxy/InitializableAdminUpgradeabilityProxy.sol"; import "./utils/Create2.sol"; import "./utils/Initializable.sol"; import "./utils/Ownable.sol"; import "./utils/ReentrancyGuard.sol"; import "./utils/SafeMath.sol"; import "./utils/SafeERC20.sol"; import "./interfaces/ICover.sol"; import "./interfaces/ICoverERC20.sol"; import "./interfaces/IERC20.sol"; import "./interfaces/IOwnable.sol"; import "./interfaces/IProtocol.sol"; import "./interfaces/IProtocolFactory.sol"; /** * @title Cover contract * @author crypto-pumpkin@github * * The contract * - Holds collateral funds * - Mints and burns CovTokens (CoverERC20) * - Allows redeem from collateral pool with or without an accepted claim */ contract Cover is ICover, Initializable, Ownable, ReentrancyGuard { using SafeMath for uint256; using SafeERC20 for IERC20; bytes4 private constant COVERERC20_INIT_SIGNITURE = bytes4(keccak256("initialize(string)")); uint48 public override expirationTimestamp; address public override collateral; ICoverERC20 public override claimCovToken; ICoverERC20 public override noclaimCovToken; string public override name; uint256 public override claimNonce; modifier onlyNotExpired() { require(block.timestamp < expirationTimestamp, "COVER: cover expired"); _; } /// @dev Initialize, called once function initialize ( string calldata _name, uint48 _timestamp, address _collateral, uint256 _claimNonce ) public initializer { name = _name; expirationTimestamp = _timestamp; collateral = _collateral; claimNonce = _claimNonce; initializeOwner(); claimCovToken = _createCovToken("CLAIM"); noclaimCovToken = _createCovToken("NOCLAIM"); } function getCoverDetails() external view override returns (string memory _name, uint48 _expirationTimestamp, address _collateral, uint256 _claimNonce, ICoverERC20 _claimCovToken, ICoverERC20 _noclaimCovToken) { return (name, expirationTimestamp, collateral, claimNonce, claimCovToken, noclaimCovToken); } /// @notice only owner (covered protocol) can mint, collateral is transfered in Protocol function mint(uint256 _amount, address _receiver) external override onlyOwner onlyNotExpired { _noClaimAcceptedCheck(); // save gas than modifier claimCovToken.mint(_receiver, _amount); noclaimCovToken.mint(_receiver, _amount); } /// @notice redeem CLAIM covToken, only if there is a claim accepted and delayWithClaim period passed function redeemClaim() external override { IProtocol protocol = IProtocol(owner()); require(protocol.claimNonce() > claimNonce, "COVER: no claim accepted"); (uint16 _payoutNumerator, uint16 _payoutDenominator, uint48 _incidentTimestamp, uint48 _claimEnactedTimestamp) = _claimDetails(); require(_incidentTimestamp <= expirationTimestamp, "COVER: cover expired before incident"); require(block.timestamp >= uint256(_claimEnactedTimestamp) + protocol.claimRedeemDelay(), "COVER: not ready"); _paySender( claimCovToken, uint256(_payoutNumerator), uint256(_payoutDenominator) ); } /** * @notice redeem NOCLAIM covToken, accept * - if no claim accepted, cover is expired, and delayWithoutClaim period passed * - if claim accepted, but payout % < 1, and delayWithClaim period passed */ function redeemNoclaim() external override { IProtocol protocol = IProtocol(owner()); if (protocol.claimNonce() > claimNonce) { // protocol has an accepted claim (uint16 _payoutNumerator, uint16 _payoutDenominator, uint48 _incidentTimestamp, uint48 _claimEnactedTimestamp) = _claimDetails(); if (_incidentTimestamp > expirationTimestamp) { // incident happened after expiration date, redeem back full collateral require(block.timestamp >= uint256(expirationTimestamp) + protocol.noclaimRedeemDelay(), "COVER: not ready"); _paySender(noclaimCovToken, 1, 1); } else { // incident happened before expiration date, pay 1 - payout% // If claim payout is 100%, nothing is left for NOCLAIM covToken holders require(_payoutNumerator < _payoutDenominator, "COVER: claim payout 100%"); require(block.timestamp >= uint256(_claimEnactedTimestamp) + protocol.claimRedeemDelay(), "COVER: not ready"); _paySender( noclaimCovToken, uint256(_payoutDenominator).sub(uint256(_payoutNumerator)), uint256(_payoutDenominator) ); } } else { // protocol has no accepted claim require(block.timestamp >= uint256(expirationTimestamp) + protocol.noclaimRedeemDelay(), "COVER: not ready"); _paySender(noclaimCovToken, 1, 1); } } /// @notice redeem collateral, only when no claim accepted and not expired function redeemCollateral(uint256 _amount) external override onlyNotExpired { require(_amount > 0, "COVER: amount is 0"); _noClaimAcceptedCheck(); // save gas than modifier ICoverERC20 _claimCovToken = claimCovToken; // save gas ICoverERC20 _noclaimCovToken = noclaimCovToken; // save gas require(_amount <= _claimCovToken.balanceOf(msg.sender), "COVER: low CLAIM balance"); require(_amount <= _noclaimCovToken.balanceOf(msg.sender), "COVER: low NOCLAIM balance"); _claimCovToken.burnByCover(msg.sender, _amount); _noclaimCovToken.burnByCover(msg.sender, _amount); _payCollateral(msg.sender, _amount); } /** * @notice set CovTokenSymbol, will update symbols for both covTokens, only dev account (factory owner) * For example: * - COVER_CURVE_2020_12_31_DAI_0 */ function setCovTokenSymbol(string calldata _name) external override { require(_dev() == msg.sender, "COVER: not dev"); claimCovToken.setSymbol(string(abi.encodePacked(_name, "_CLAIM"))); noclaimCovToken.setSymbol(string(abi.encodePacked(_name, "_NOCLAIM"))); } /// @notice the owner of this contract is Protocol contract, the owner of Protocol is ProtocolFactory contract function _factory() private view returns (address) { return IOwnable(owner()).owner(); } // get the claim details for the corresponding nonce from protocol contract function _claimDetails() private view returns (uint16 _payoutNumerator, uint16 _payoutDenominator, uint48 _incidentTimestamp, uint48 _claimEnactedTimestamp) { return IProtocol(owner()).claimDetails(claimNonce); } /// @notice the owner of ProtocolFactory contract is dev, also see {_factory} function _dev() private view returns (address) { return IOwnable(_factory()).owner(); } /// @notice make sure no claim is accepted function _noClaimAcceptedCheck() private view { require(IProtocol(owner()).claimNonce() == claimNonce, "COVER: claim accepted"); } /// @notice transfer collateral (amount - fee) from this contract to recevier, transfer fee to COVER treasury function _payCollateral(address _receiver, uint256 _amount) private nonReentrant { IProtocolFactory factory = IProtocolFactory(_factory()); uint256 redeemFeeNumerator = factory.redeemFeeNumerator(); uint256 redeemFeeDenominator = factory.redeemFeeDenominator(); uint256 fee = _amount.mul(redeemFeeNumerator).div(redeemFeeDenominator); address treasury = factory.treasury(); IERC20 collateralToken = IERC20(collateral); collateralToken.safeTransfer(_receiver, _amount.sub(fee)); collateralToken.safeTransfer(treasury, fee); } /// @notice burn covToken and pay sender function _paySender( ICoverERC20 _covToken, uint256 _payoutNumerator, uint256 _payoutDenominator ) private { require(_payoutNumerator <= _payoutDenominator, "COVER: payout % is > 100%"); require(_payoutNumerator > 0, "COVER: payout % < 0%"); uint256 amount = _covToken.balanceOf(msg.sender); require(amount > 0, "COVER: low covToken balance"); _covToken.burnByCover(msg.sender, amount); uint256 payoutAmount = amount.mul(_payoutNumerator).div(_payoutDenominator); _payCollateral(msg.sender, payoutAmount); } /// @dev Emits NewCoverERC20 function _createCovToken(string memory _suffix) private returns (ICoverERC20) { bytes memory bytecode = type(InitializableAdminUpgradeabilityProxy).creationCode; bytes32 salt = keccak256(abi.encodePacked(IProtocol(owner()).name(), expirationTimestamp, collateral, claimNonce, _suffix)); address payable proxyAddr = Create2.deploy(0, salt, bytecode); bytes memory initData = abi.encodeWithSelector(COVERERC20_INIT_SIGNITURE, string(abi.encodePacked(name, "_", _suffix))); address coverERC20Implementation = IProtocolFactory(_factory()).coverERC20Implementation(); InitializableAdminUpgradeabilityProxy(proxyAddr).initialize( coverERC20Implementation, IOwnable(_factory()).owner(), initData ); emit NewCoverERC20(proxyAddr); return ICoverERC20(proxyAddr); } }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_protocolImplementation","type":"address"},{"internalType":"address","name":"_coverImplementation","type":"address"},{"internalType":"address","name":"_coverERC20Implementation","type":"address"},{"internalType":"address","name":"_governance","type":"address"},{"internalType":"address","name":"_treasury","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferCompleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferInitiated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"protocolAddress","type":"address"}],"name":"ProtocolInitiation","type":"event"},{"inputs":[{"internalType":"bytes32","name":"_name","type":"bytes32"},{"internalType":"bool","name":"_active","type":"bool"},{"internalType":"address","name":"_collateral","type":"address"},{"internalType":"uint48[]","name":"_timestamps","type":"uint48[]"},{"internalType":"bytes32[]","name":"_timestampNames","type":"bytes32[]"}],"name":"addProtocol","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimManager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"coverERC20Implementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"coverImplementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAllProtocolAddresses","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_protocolName","type":"bytes32"},{"internalType":"uint48","name":"_timestamp","type":"uint48"},{"internalType":"address","name":"_collateral","type":"address"},{"internalType":"uint256","name":"_claimNonce","type":"uint256"},{"internalType":"bool","name":"_isClaimCovToken","type":"bool"}],"name":"getCovTokenAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_protocolName","type":"bytes32"},{"internalType":"uint48","name":"_timestamp","type":"uint48"},{"internalType":"address","name":"_collateral","type":"address"},{"internalType":"uint256","name":"_claimNonce","type":"uint256"}],"name":"getCoverAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_name","type":"bytes32"}],"name":"getProtocolAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"getProtocolNameAndAddress","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getProtocolsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRedeemFees","outputs":[{"internalType":"uint16","name":"_numerator","type":"uint16"},{"internalType":"uint16","name":"_denominator","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"governance","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"protocolImplementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"protocols","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"redeemFeeDenominator","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"redeemFeeNumerator","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"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":[{"internalType":"address","name":"_address","type":"address"}],"name":"updateClaimManager","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newImplementation","type":"address"}],"name":"updateCoverERC20Implementation","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newImplementation","type":"address"}],"name":"updateCoverImplementation","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_redeemFeeNumerator","type":"uint16"},{"internalType":"uint16","name":"_redeemFeeDenominator","type":"uint16"}],"name":"updateFees","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"updateGovernance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newImplementation","type":"address"}],"name":"updateProtocolImplementation","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"updateTreasury","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60806040526001805461ffff60a01b1916600560a11b1761ffff60b01b191661027160b41b1790553480156200003457600080fd5b50604051620021f7380380620021f7833981810160405260a08110156200005a57600080fd5b508051602082015160408301516060840151608090940151600280546001600160a01b03199081166001600160a01b03808816919091179092556003805482168387161790556004805482168386161790556006805482168389161790556005805490911691831691909117905592939192909190620000d9620000e4565b5050505050620001ea565b600054610100900460ff168062000100575062000100620001e4565b806200010f575060005460ff16155b6200014c5760405162461bcd60e51b815260040180806020018281038252602e815260200180620021c9602e913960400191505060405180910390fd5b600054610100900460ff1615801562000178576000805460ff1961ff0019909116610100171660011790555b600080546201000033810262010000600160b01b0319909216919091178083556040519190046001600160a01b031691907fe9a5158ac7353c7c7322ececc080bc8e89334efa5795b6e21e40eb266b0003d6908290a38015620001e1576000805461ff00191690555b50565b303b1590565b611fcf80620001fa6000396000f3fe608060405234801561001057600080fd5b50600436106101a95760003560e01c80637f51bb1f116100f9578063b256126311610097578063f2fde38b11610071578063f2fde38b1461056a578063f3d2350e14610590578063f6688419146105b9578063f856f86e146105d3576101a9565b8063b2561263146104e4578063c12e90e91461050a578063ea7579d114610512576101a9565b8063935f9192116100d3578063935f9192146103ce5780639d699afe146103f4578063a6624cb6146104d4578063a9a36dcd146104dc576101a9565b80637f51bb1f1461037a5780638da5cb5b146103a05780638dc9b627146103a8576101a9565b80635515fe0a1161016657806361d027b31161014057806361d027b31461030d57806364bb44dc146103155780636b3bcc601461031d5780636b94e3be1461033a576101a9565b80635515fe0a146102a0578063592dc0c2146102bd5780635aa6e67514610305576101a9565b806306f38491146101ae5780630db60f37146101d257806313a401c2146101f15780632d4a819f1461021e5780633d0a6793146102585780634e71e0c814610296575b600080fd5b6101b66105f9565b604080516001600160a01b039092168252519081900360200190f35b6101da610608565b6040805161ffff9092168252519081900360200190f35b6101f9610619565b604051808361ffff1681526020018261ffff1681526020019250505060405180910390f35b6102446004803603602081101561023457600080fd5b50356001600160a01b0316610635565b604080519115158252519081900360200190f35b6102756004803603602081101561026e57600080fd5b50356106f2565b604080519283526001600160a01b0390911660208301528051918290030190f35b61029e610734565b005b6101b6600480360360208110156102b657600080fd5b50356107f0565b6101b6600480360360a08110156102d357600080fd5b5080359065ffffffffffff602082013516906001600160a01b036040820135169060608101359060800135151561080b565b6101b6610918565b6101b6610927565b6101b6610936565b6101b66004803603602081101561033357600080fd5b5035610945565b6101b66004803603608081101561035057600080fd5b5080359065ffffffffffff602082013516906001600160a01b03604082013516906060013561097d565b6102446004803603602081101561039057600080fd5b50356001600160a01b03166109ea565b6101b6610abb565b610244600480360360208110156103be57600080fd5b50356001600160a01b0316610ad0565b610244600480360360208110156103e457600080fd5b50356001600160a01b0316610b8d565b6101b6600480360360a081101561040a57600080fd5b81359160208101351515916001600160a01b03604083013516919081019060808101606082013564010000000081111561044357600080fd5b82018360208201111561045557600080fd5b8035906020019184602083028401116401000000008311171561047757600080fd5b91939092909160208101903564010000000081111561049557600080fd5b8201836020820111156104a757600080fd5b803590602001918460208302840111640100000000831117156104c957600080fd5b509092509050610c4a565b6101b6611017565b6101b6611026565b610244600480360360208110156104fa57600080fd5b50356001600160a01b0316611035565b6101da61116c565b61051a61117d565b60408051602080825283518183015283519192839290830191858101910280838360005b8381101561055657818101518382015260200161053e565b505050509050019250505060405180910390f35b61029e6004803603602081101561058057600080fd5b50356001600160a01b0316611293565b610244600480360360408110156105a657600080fd5b5061ffff8135811691602001351661138c565b6105c161147e565b60408051918252519081900360200190f35b610244600480360360208110156105e957600080fd5b50356001600160a01b0316611484565b6002546001600160a01b031681565b600154600160a01b900461ffff1681565b60015461ffff600160a01b8204811691600160b01b9004169091565b600080546201000090046001600160a01b03163314610689576040805162461bcd60e51b81526020600482018190526024820152600080516020611f56833981519152604482015290519081900360640190fd5b61069282611555565b6106cd5760405162461bcd60e51b815260040180806020018281038252602b815260200180611ee4602b913960400191505060405180910390fd5b50600380546001600160a01b0383166001600160a01b03199091161790556001919050565b60008060006008848154811061070457fe5b600091825260208083209091015480835260099091526040909120549093506001600160a01b0316915050915091565b6001546001600160a01b03163314610781576040805162461bcd60e51b81526020600482018190526024820152600080516020611f56833981519152604482015290519081900360640190fd5b600154600080546040516001600160a01b039384169362010000909204909116917fe9a5158ac7353c7c7322ececc080bc8e89334efa5795b6e21e40eb266b0003d691a36001546000805462010000600160b01b0319166001600160a01b039092166201000002919091179055565b6009602052600090815260409020546001600160a01b031681565b600061090e868686868661083e57604051806040016040528060078152602001664e4f434c41494d60c81b81525061085d565b60405180604001604052806005815260200164434c41494d60d81b8152505b604051602001808681526020018565ffffffffffff1660d01b8152600601846001600160a01b031660601b815260140183815260200182805190602001908083835b602083106108be5780518252601f19909201916020918201910161089f565b6001836020036101000a03801982511681845116808217855250505050505090500195505050505050604051602081830303815290604052805190602001206109098888888861097d565b611591565b9695505050505050565b6006546001600160a01b031681565b6005546001600160a01b031681565b6003546001600160a01b031681565b600061097782604051602001808281526020019150506040516020818303038152906040528051906020012030611591565b92915050565b60006109e185858585604051602001808581526020018465ffffffffffff1660d01b8152600601836001600160a01b031660601b81526014018281526020019450505050506040516020818303038152906040528051906020012061090987610945565b95945050505050565b600080546201000090046001600160a01b03163314610a3e576040805162461bcd60e51b81526020600482018190526024820152600080516020611f56833981519152604482015290519081900360640190fd5b6001600160a01b038216610a96576040805162461bcd60e51b815260206004820152601a6024820152790434f5645523a20616464726573732063616e6e6f7420626520360341b604482015290519081900360640190fd5b50600580546001600160a01b0383166001600160a01b03199091161790556001919050565b6000546201000090046001600160a01b031690565b600080546201000090046001600160a01b03163314610b24576040805162461bcd60e51b81526020600482018190526024820152600080516020611f56833981519152604482015290519081900360640190fd5b610b2d82611555565b610b685760405162461bcd60e51b815260040180806020018281038252602b815260200180611ee4602b913960400191505060405180910390fd5b50600280546001600160a01b0383166001600160a01b03199091161790556001919050565b600080546201000090046001600160a01b03163314610be1576040805162461bcd60e51b81526020600482018190526024820152600080516020611f56833981519152604482015290519081900360640190fd5b610bea82611555565b610c255760405162461bcd60e51b815260040180806020018281038252602b815260200180611ee4602b913960400191505060405180910390fd5b50600480546001600160a01b0383166001600160a01b03199091161790556001919050565b600080546201000090046001600160a01b03163314610c9e576040805162461bcd60e51b81526020600482018190526024820152600080516020611f56833981519152604482015290519081900360640190fd5b6000888152600960205260409020546001600160a01b031615610d01576040805162461bcd60e51b8152602060048201526016602482015275434f5645523a2070726f746f636f6c2065786973747360501b604482015290519081900360640190fd5b838214610d3f5760405162461bcd60e51b8152600401808060200182810382526024815260200180611f766024913960400191505060405180910390fd5b600880546001810182556000919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee301889055604051606090610d8660208201611739565b601f1982820381018352601f90910116604081815260208281018d905281518084038201815292820190915281519101209091506000610dc78183856115cd565b604080516001600160a01b038316815290519192507f669ab513336b21e9a90a66ce47559be181e60530bba21701ba70240b5bc47ecb919081900360200190a160607fb2cfb94d987d26810b32e43b1886a3b6a525269102fa5e00f85a702999a88b0e8c8c8c8c8c8c8c604051602401808881526020018715158152602001866001600160a01b0316815260200180602001806020018381038352878782818152602001925060200280828437600083820152601f01601f1916909101848103835285815260209081019150869086028082843760008184015260408051601f19601f9093018316909401848103909201845252506020810180516001600160e01b03199d909d166001600160e01b03909d169c909c17909b52505060025498995050506001600160a01b038981169763cf7a1d779750169450610f0f9350610abb92505050565b846040518463ffffffff1660e01b815260040180846001600160a01b03168152602001836001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610f7a578181015183820152602001610f62565b50505050905090810190601f168015610fa75780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b158015610fc857600080fd5b505af1158015610fdc573d6000803e3d6000fd5b50505060009c8d52505060096020526040909a2080546001600160a01b0319166001600160a01b038c16179055509798975050505050505050565b6004546001600160a01b031681565b6007546001600160a01b031681565b6006546000906001600160a01b03163314611097576040805162461bcd60e51b815260206004820152601c60248201527f434f5645523a2063616c6c6572206e6f7420676f7665726e616e636500000000604482015290519081900360640190fd5b6001600160a01b0382166110ef576040805162461bcd60e51b815260206004820152601a6024820152790434f5645523a20616464726573732063616e6e6f7420626520360341b604482015290519081900360640190fd5b6110f7610abb565b6001600160a01b0316826001600160a01b031614156111475760405162461bcd60e51b8152600401808060200182810382526021815260200180611f356021913960400191505060405180910390fd5b50600680546001600160a01b0383166001600160a01b03199091161790556001919050565b600154600160b01b900461ffff1681565b60608060088054806020026020016040519081016040528092919081815260200182805480156111cc57602002820191906000526020600020905b8154815260200190600101908083116111b8575b505050505090506060815167ffffffffffffffff811180156111ed57600080fd5b50604051908082528060200260200182016040528015611217578160200160208202803683370190505b50905060005b825181101561128c576009600084838151811061123657fe5b6020026020010151815260200190815260200160002060009054906101000a90046001600160a01b031682828151811061126c57fe5b6001600160a01b039092166020928302919091019091015260010161121d565b5091505090565b6000546201000090046001600160a01b031633146112e6576040805162461bcd60e51b81526020600482018190526024820152600080516020611f56833981519152604482015290519081900360640190fd5b6001600160a01b03811661132b5760405162461bcd60e51b8152600401808060200182810382526026815260200180611f0f6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516936201000090930416917fb150023a879fd806e3599b6ca8ee3b60f0e360ab3846d128d67ebce1a391639a91a3600180546001600160a01b0319166001600160a01b0392909216919091179055565b6006546000906001600160a01b031633146113ee576040805162461bcd60e51b815260206004820152601c60248201527f434f5645523a2063616c6c6572206e6f7420676f7665726e616e636500000000604482015290519081900360640190fd5b60008261ffff1611611447576040805162461bcd60e51b815260206004820152601e60248201527f434f5645523a2064656e6f6d696e61746f722063616e6e6f7420626520300000604482015290519081900360640190fd5b506001805461ffff928316600160b01b0261ffff60b01b1994909316600160a01b0261ffff60a01b19909116179290921617815590565b60085490565b600080546201000090046001600160a01b031633146114d8576040805162461bcd60e51b81526020600482018190526024820152600080516020611f56833981519152604482015290519081900360640190fd5b6001600160a01b038216611530576040805162461bcd60e51b815260206004820152601a6024820152790434f5645523a20616464726573732063616e6e6f7420626520360341b604482015290519081900360640190fd5b50600780546001600160a01b0383166001600160a01b03199091161790556001919050565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081811480159061158957508115155b949350505050565b60006060604051806020016115a590611739565b6020820181038252601f19601f820116604052509050611589848280519060200120856116de565b60008084471015611625576040805162461bcd60e51b815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e6365000000604482015290519081900360640190fd5b8251611678576040805162461bcd60e51b815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f604482015290519081900360640190fd5b8383516020850187f590506001600160a01b038116611589576040805162461bcd60e51b815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f7900000000000000604482015290519081900360640190fd5b604080516001600160f81b031960208083019190915260609390931b6bffffffffffffffffffffffff191660218201526035810194909452605580850193909352805180850390930183526075909301909252805191012090565b61079d806117478339019056fe608060405234801561001057600080fd5b5061077d806100206000396000f3fe6080604052600436106100595760003560e01c80633659cfe6146100705780634f1ef286146100a35780635c60da1b146101235780638f28397014610154578063cf7a1d7714610187578063f851a4401461024657610068565b366100685761006661025b565b005b61006661025b565b34801561007c57600080fd5b506100666004803603602081101561009357600080fd5b50356001600160a01b0316610275565b610066600480360360408110156100b957600080fd5b6001600160a01b0382351691908101906040810160208201356401000000008111156100e457600080fd5b8201836020820111156100f657600080fd5b8035906020019184600183028401116401000000008311171561011857600080fd5b5090925090506102af565b34801561012f57600080fd5b5061013861035c565b604080516001600160a01b039092168252519081900360200190f35b34801561016057600080fd5b506100666004803603602081101561017757600080fd5b50356001600160a01b0316610399565b6100666004803603606081101561019d57600080fd5b6001600160a01b0382358116926020810135909116918101906060810160408201356401000000008111156101d157600080fd5b8201836020820111156101e357600080fd5b8035906020019184600183028401116401000000008311171561020557600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610453945050505050565b34801561025257600080fd5b5061013861053a565b610263610273565b61027361026e610565565b61058a565b565b61027d6105ae565b6001600160a01b0316336001600160a01b031614156102a45761029f816105d3565b6102ac565b6102ac61025b565b50565b6102b76105ae565b6001600160a01b0316336001600160a01b0316141561034f576102d9836105d3565b6000836001600160a01b031683836040518083838082843760405192019450600093509091505080830381855af49150503d8060008114610336576040519150601f19603f3d011682016040523d82523d6000602084013e61033b565b606091505b505090508061034957600080fd5b50610357565b61035761025b565b505050565b60006103666105ae565b6001600160a01b0316336001600160a01b0316141561038e57610387610565565b9050610396565b61039661025b565b90565b6103a16105ae565b6001600160a01b0316336001600160a01b031614156102a4576001600160a01b0381166103ff5760405162461bcd60e51b81526004018080602001828103825260368152602001806106dc6036913960400191505060405180910390fd5b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104286105ae565b604080516001600160a01b03928316815291841660208301528051918290030190a161029f81610613565b600061045d610565565b6001600160a01b03161461047057600080fd5b61047983610637565b805115610531576000836001600160a01b0316826040518082805190602001908083835b602083106104bc5780518252601f19909201916020918201910161049d565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d806000811461051c576040519150601f19603f3d011682016040523d82523d6000602084013e610521565b606091505b505090508061052f57600080fd5b505b61035782610613565b60006105446105ae565b6001600160a01b0316336001600160a01b0316141561038e576103876105ae565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b3660008037600080366000845af43d6000803e8080156105a9573d6000f35b3d6000fd5b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035490565b6105dc81610637565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610355565b6106408161069f565b61067b5760405162461bcd60e51b81526004018080602001828103825260368152602001806107126036913960400191505060405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc55565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4708181148015906106d357508115155b94935050505056fe43616e6e6f74206368616e6765207468652061646d696e206f6620612070726f787920746f20746865207a65726f20616464726573735570677261646561626c6550726f78793a206e657720696d706c656d656e746174696f6e206973206e6f74206120636f6e7472616374a2646970667358221220bb1380c8baf572bad88171f2a9370ded98c1c442f5378d819a912f33b83f1bc964736f6c63430007030033434f5645523a206e657720696d706c656d656e746174696f6e206973206e6f74206120636f6e74726163744f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373434f5645523a20676f7665726e616e63652063616e6e6f74206265206f776e65724f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572434f5645523a2074696d657374616d70206c656e6774687320646f6e2774206d61746368a264697066735822122089ce56e5669c397a792ad3debef334bc0dec25ae1f2582eeade5c4e36a56e5b264736f6c63430007030033496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a6564000000000000000000000000b6886b2c3537673941e4ead63b95eacb47173f6a000000000000000000000000cb0900d9307da7fd4e000a9093f24ce25d937d42000000000000000000000000d18124029b167e03bbaab8d5d6fbb646ae020e1d000000000000000000000000c698645b5c5b662b52a5a5c092804f23e3f5b4c5000000000000000000000000859eefc267671595d987d0f6589d7771d4877113
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101a95760003560e01c80637f51bb1f116100f9578063b256126311610097578063f2fde38b11610071578063f2fde38b1461056a578063f3d2350e14610590578063f6688419146105b9578063f856f86e146105d3576101a9565b8063b2561263146104e4578063c12e90e91461050a578063ea7579d114610512576101a9565b8063935f9192116100d3578063935f9192146103ce5780639d699afe146103f4578063a6624cb6146104d4578063a9a36dcd146104dc576101a9565b80637f51bb1f1461037a5780638da5cb5b146103a05780638dc9b627146103a8576101a9565b80635515fe0a1161016657806361d027b31161014057806361d027b31461030d57806364bb44dc146103155780636b3bcc601461031d5780636b94e3be1461033a576101a9565b80635515fe0a146102a0578063592dc0c2146102bd5780635aa6e67514610305576101a9565b806306f38491146101ae5780630db60f37146101d257806313a401c2146101f15780632d4a819f1461021e5780633d0a6793146102585780634e71e0c814610296575b600080fd5b6101b66105f9565b604080516001600160a01b039092168252519081900360200190f35b6101da610608565b6040805161ffff9092168252519081900360200190f35b6101f9610619565b604051808361ffff1681526020018261ffff1681526020019250505060405180910390f35b6102446004803603602081101561023457600080fd5b50356001600160a01b0316610635565b604080519115158252519081900360200190f35b6102756004803603602081101561026e57600080fd5b50356106f2565b604080519283526001600160a01b0390911660208301528051918290030190f35b61029e610734565b005b6101b6600480360360208110156102b657600080fd5b50356107f0565b6101b6600480360360a08110156102d357600080fd5b5080359065ffffffffffff602082013516906001600160a01b036040820135169060608101359060800135151561080b565b6101b6610918565b6101b6610927565b6101b6610936565b6101b66004803603602081101561033357600080fd5b5035610945565b6101b66004803603608081101561035057600080fd5b5080359065ffffffffffff602082013516906001600160a01b03604082013516906060013561097d565b6102446004803603602081101561039057600080fd5b50356001600160a01b03166109ea565b6101b6610abb565b610244600480360360208110156103be57600080fd5b50356001600160a01b0316610ad0565b610244600480360360208110156103e457600080fd5b50356001600160a01b0316610b8d565b6101b6600480360360a081101561040a57600080fd5b81359160208101351515916001600160a01b03604083013516919081019060808101606082013564010000000081111561044357600080fd5b82018360208201111561045557600080fd5b8035906020019184602083028401116401000000008311171561047757600080fd5b91939092909160208101903564010000000081111561049557600080fd5b8201836020820111156104a757600080fd5b803590602001918460208302840111640100000000831117156104c957600080fd5b509092509050610c4a565b6101b6611017565b6101b6611026565b610244600480360360208110156104fa57600080fd5b50356001600160a01b0316611035565b6101da61116c565b61051a61117d565b60408051602080825283518183015283519192839290830191858101910280838360005b8381101561055657818101518382015260200161053e565b505050509050019250505060405180910390f35b61029e6004803603602081101561058057600080fd5b50356001600160a01b0316611293565b610244600480360360408110156105a657600080fd5b5061ffff8135811691602001351661138c565b6105c161147e565b60408051918252519081900360200190f35b610244600480360360208110156105e957600080fd5b50356001600160a01b0316611484565b6002546001600160a01b031681565b600154600160a01b900461ffff1681565b60015461ffff600160a01b8204811691600160b01b9004169091565b600080546201000090046001600160a01b03163314610689576040805162461bcd60e51b81526020600482018190526024820152600080516020611f56833981519152604482015290519081900360640190fd5b61069282611555565b6106cd5760405162461bcd60e51b815260040180806020018281038252602b815260200180611ee4602b913960400191505060405180910390fd5b50600380546001600160a01b0383166001600160a01b03199091161790556001919050565b60008060006008848154811061070457fe5b600091825260208083209091015480835260099091526040909120549093506001600160a01b0316915050915091565b6001546001600160a01b03163314610781576040805162461bcd60e51b81526020600482018190526024820152600080516020611f56833981519152604482015290519081900360640190fd5b600154600080546040516001600160a01b039384169362010000909204909116917fe9a5158ac7353c7c7322ececc080bc8e89334efa5795b6e21e40eb266b0003d691a36001546000805462010000600160b01b0319166001600160a01b039092166201000002919091179055565b6009602052600090815260409020546001600160a01b031681565b600061090e868686868661083e57604051806040016040528060078152602001664e4f434c41494d60c81b81525061085d565b60405180604001604052806005815260200164434c41494d60d81b8152505b604051602001808681526020018565ffffffffffff1660d01b8152600601846001600160a01b031660601b815260140183815260200182805190602001908083835b602083106108be5780518252601f19909201916020918201910161089f565b6001836020036101000a03801982511681845116808217855250505050505090500195505050505050604051602081830303815290604052805190602001206109098888888861097d565b611591565b9695505050505050565b6006546001600160a01b031681565b6005546001600160a01b031681565b6003546001600160a01b031681565b600061097782604051602001808281526020019150506040516020818303038152906040528051906020012030611591565b92915050565b60006109e185858585604051602001808581526020018465ffffffffffff1660d01b8152600601836001600160a01b031660601b81526014018281526020019450505050506040516020818303038152906040528051906020012061090987610945565b95945050505050565b600080546201000090046001600160a01b03163314610a3e576040805162461bcd60e51b81526020600482018190526024820152600080516020611f56833981519152604482015290519081900360640190fd5b6001600160a01b038216610a96576040805162461bcd60e51b815260206004820152601a6024820152790434f5645523a20616464726573732063616e6e6f7420626520360341b604482015290519081900360640190fd5b50600580546001600160a01b0383166001600160a01b03199091161790556001919050565b6000546201000090046001600160a01b031690565b600080546201000090046001600160a01b03163314610b24576040805162461bcd60e51b81526020600482018190526024820152600080516020611f56833981519152604482015290519081900360640190fd5b610b2d82611555565b610b685760405162461bcd60e51b815260040180806020018281038252602b815260200180611ee4602b913960400191505060405180910390fd5b50600280546001600160a01b0383166001600160a01b03199091161790556001919050565b600080546201000090046001600160a01b03163314610be1576040805162461bcd60e51b81526020600482018190526024820152600080516020611f56833981519152604482015290519081900360640190fd5b610bea82611555565b610c255760405162461bcd60e51b815260040180806020018281038252602b815260200180611ee4602b913960400191505060405180910390fd5b50600480546001600160a01b0383166001600160a01b03199091161790556001919050565b600080546201000090046001600160a01b03163314610c9e576040805162461bcd60e51b81526020600482018190526024820152600080516020611f56833981519152604482015290519081900360640190fd5b6000888152600960205260409020546001600160a01b031615610d01576040805162461bcd60e51b8152602060048201526016602482015275434f5645523a2070726f746f636f6c2065786973747360501b604482015290519081900360640190fd5b838214610d3f5760405162461bcd60e51b8152600401808060200182810382526024815260200180611f766024913960400191505060405180910390fd5b600880546001810182556000919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee301889055604051606090610d8660208201611739565b601f1982820381018352601f90910116604081815260208281018d905281518084038201815292820190915281519101209091506000610dc78183856115cd565b604080516001600160a01b038316815290519192507f669ab513336b21e9a90a66ce47559be181e60530bba21701ba70240b5bc47ecb919081900360200190a160607fb2cfb94d987d26810b32e43b1886a3b6a525269102fa5e00f85a702999a88b0e8c8c8c8c8c8c8c604051602401808881526020018715158152602001866001600160a01b0316815260200180602001806020018381038352878782818152602001925060200280828437600083820152601f01601f1916909101848103835285815260209081019150869086028082843760008184015260408051601f19601f9093018316909401848103909201845252506020810180516001600160e01b03199d909d166001600160e01b03909d169c909c17909b52505060025498995050506001600160a01b038981169763cf7a1d779750169450610f0f9350610abb92505050565b846040518463ffffffff1660e01b815260040180846001600160a01b03168152602001836001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610f7a578181015183820152602001610f62565b50505050905090810190601f168015610fa75780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b158015610fc857600080fd5b505af1158015610fdc573d6000803e3d6000fd5b50505060009c8d52505060096020526040909a2080546001600160a01b0319166001600160a01b038c16179055509798975050505050505050565b6004546001600160a01b031681565b6007546001600160a01b031681565b6006546000906001600160a01b03163314611097576040805162461bcd60e51b815260206004820152601c60248201527f434f5645523a2063616c6c6572206e6f7420676f7665726e616e636500000000604482015290519081900360640190fd5b6001600160a01b0382166110ef576040805162461bcd60e51b815260206004820152601a6024820152790434f5645523a20616464726573732063616e6e6f7420626520360341b604482015290519081900360640190fd5b6110f7610abb565b6001600160a01b0316826001600160a01b031614156111475760405162461bcd60e51b8152600401808060200182810382526021815260200180611f356021913960400191505060405180910390fd5b50600680546001600160a01b0383166001600160a01b03199091161790556001919050565b600154600160b01b900461ffff1681565b60608060088054806020026020016040519081016040528092919081815260200182805480156111cc57602002820191906000526020600020905b8154815260200190600101908083116111b8575b505050505090506060815167ffffffffffffffff811180156111ed57600080fd5b50604051908082528060200260200182016040528015611217578160200160208202803683370190505b50905060005b825181101561128c576009600084838151811061123657fe5b6020026020010151815260200190815260200160002060009054906101000a90046001600160a01b031682828151811061126c57fe5b6001600160a01b039092166020928302919091019091015260010161121d565b5091505090565b6000546201000090046001600160a01b031633146112e6576040805162461bcd60e51b81526020600482018190526024820152600080516020611f56833981519152604482015290519081900360640190fd5b6001600160a01b03811661132b5760405162461bcd60e51b8152600401808060200182810382526026815260200180611f0f6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516936201000090930416917fb150023a879fd806e3599b6ca8ee3b60f0e360ab3846d128d67ebce1a391639a91a3600180546001600160a01b0319166001600160a01b0392909216919091179055565b6006546000906001600160a01b031633146113ee576040805162461bcd60e51b815260206004820152601c60248201527f434f5645523a2063616c6c6572206e6f7420676f7665726e616e636500000000604482015290519081900360640190fd5b60008261ffff1611611447576040805162461bcd60e51b815260206004820152601e60248201527f434f5645523a2064656e6f6d696e61746f722063616e6e6f7420626520300000604482015290519081900360640190fd5b506001805461ffff928316600160b01b0261ffff60b01b1994909316600160a01b0261ffff60a01b19909116179290921617815590565b60085490565b600080546201000090046001600160a01b031633146114d8576040805162461bcd60e51b81526020600482018190526024820152600080516020611f56833981519152604482015290519081900360640190fd5b6001600160a01b038216611530576040805162461bcd60e51b815260206004820152601a6024820152790434f5645523a20616464726573732063616e6e6f7420626520360341b604482015290519081900360640190fd5b50600780546001600160a01b0383166001600160a01b03199091161790556001919050565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081811480159061158957508115155b949350505050565b60006060604051806020016115a590611739565b6020820181038252601f19601f820116604052509050611589848280519060200120856116de565b60008084471015611625576040805162461bcd60e51b815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e6365000000604482015290519081900360640190fd5b8251611678576040805162461bcd60e51b815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f604482015290519081900360640190fd5b8383516020850187f590506001600160a01b038116611589576040805162461bcd60e51b815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f7900000000000000604482015290519081900360640190fd5b604080516001600160f81b031960208083019190915260609390931b6bffffffffffffffffffffffff191660218201526035810194909452605580850193909352805180850390930183526075909301909252805191012090565b61079d806117478339019056fe608060405234801561001057600080fd5b5061077d806100206000396000f3fe6080604052600436106100595760003560e01c80633659cfe6146100705780634f1ef286146100a35780635c60da1b146101235780638f28397014610154578063cf7a1d7714610187578063f851a4401461024657610068565b366100685761006661025b565b005b61006661025b565b34801561007c57600080fd5b506100666004803603602081101561009357600080fd5b50356001600160a01b0316610275565b610066600480360360408110156100b957600080fd5b6001600160a01b0382351691908101906040810160208201356401000000008111156100e457600080fd5b8201836020820111156100f657600080fd5b8035906020019184600183028401116401000000008311171561011857600080fd5b5090925090506102af565b34801561012f57600080fd5b5061013861035c565b604080516001600160a01b039092168252519081900360200190f35b34801561016057600080fd5b506100666004803603602081101561017757600080fd5b50356001600160a01b0316610399565b6100666004803603606081101561019d57600080fd5b6001600160a01b0382358116926020810135909116918101906060810160408201356401000000008111156101d157600080fd5b8201836020820111156101e357600080fd5b8035906020019184600183028401116401000000008311171561020557600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610453945050505050565b34801561025257600080fd5b5061013861053a565b610263610273565b61027361026e610565565b61058a565b565b61027d6105ae565b6001600160a01b0316336001600160a01b031614156102a45761029f816105d3565b6102ac565b6102ac61025b565b50565b6102b76105ae565b6001600160a01b0316336001600160a01b0316141561034f576102d9836105d3565b6000836001600160a01b031683836040518083838082843760405192019450600093509091505080830381855af49150503d8060008114610336576040519150601f19603f3d011682016040523d82523d6000602084013e61033b565b606091505b505090508061034957600080fd5b50610357565b61035761025b565b505050565b60006103666105ae565b6001600160a01b0316336001600160a01b0316141561038e57610387610565565b9050610396565b61039661025b565b90565b6103a16105ae565b6001600160a01b0316336001600160a01b031614156102a4576001600160a01b0381166103ff5760405162461bcd60e51b81526004018080602001828103825260368152602001806106dc6036913960400191505060405180910390fd5b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104286105ae565b604080516001600160a01b03928316815291841660208301528051918290030190a161029f81610613565b600061045d610565565b6001600160a01b03161461047057600080fd5b61047983610637565b805115610531576000836001600160a01b0316826040518082805190602001908083835b602083106104bc5780518252601f19909201916020918201910161049d565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d806000811461051c576040519150601f19603f3d011682016040523d82523d6000602084013e610521565b606091505b505090508061052f57600080fd5b505b61035782610613565b60006105446105ae565b6001600160a01b0316336001600160a01b0316141561038e576103876105ae565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b3660008037600080366000845af43d6000803e8080156105a9573d6000f35b3d6000fd5b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035490565b6105dc81610637565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610355565b6106408161069f565b61067b5760405162461bcd60e51b81526004018080602001828103825260368152602001806107126036913960400191505060405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc55565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4708181148015906106d357508115155b94935050505056fe43616e6e6f74206368616e6765207468652061646d696e206f6620612070726f787920746f20746865207a65726f20616464726573735570677261646561626c6550726f78793a206e657720696d706c656d656e746174696f6e206973206e6f74206120636f6e7472616374a2646970667358221220bb1380c8baf572bad88171f2a9370ded98c1c442f5378d819a912f33b83f1bc964736f6c63430007030033434f5645523a206e657720696d706c656d656e746174696f6e206973206e6f74206120636f6e74726163744f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373434f5645523a20676f7665726e616e63652063616e6e6f74206265206f776e65724f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572434f5645523a2074696d657374616d70206c656e6774687320646f6e2774206d61746368a264697066735822122089ce56e5669c397a792ad3debef334bc0dec25ae1f2582eeade5c4e36a56e5b264736f6c63430007030033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000b6886b2c3537673941e4ead63b95eacb47173f6a000000000000000000000000cb0900d9307da7fd4e000a9093f24ce25d937d42000000000000000000000000d18124029b167e03bbaab8d5d6fbb646ae020e1d000000000000000000000000c698645b5c5b662b52a5a5c092804f23e3f5b4c5000000000000000000000000859eefc267671595d987d0f6589d7771d4877113
-----Decoded View---------------
Arg [0] : _protocolImplementation (address): 0xb6886B2C3537673941E4EAd63b95EaCb47173f6A
Arg [1] : _coverImplementation (address): 0xcB0900D9307Da7FD4e000A9093f24Ce25D937D42
Arg [2] : _coverERC20Implementation (address): 0xd18124029b167E03BBAaB8D5d6Fbb646aE020e1d
Arg [3] : _governance (address): 0xc698645B5C5b662B52a5A5C092804F23e3F5B4C5
Arg [4] : _treasury (address): 0x859Eefc267671595d987D0F6589D7771D4877113
-----Encoded View---------------
5 Constructor Arguments found :
Arg [0] : 000000000000000000000000b6886b2c3537673941e4ead63b95eacb47173f6a
Arg [1] : 000000000000000000000000cb0900d9307da7fd4e000a9093f24ce25d937d42
Arg [2] : 000000000000000000000000d18124029b167e03bbaab8d5d6fbb646ae020e1d
Arg [3] : 000000000000000000000000c698645b5c5b662b52a5a5c092804f23e3f5b4c5
Arg [4] : 000000000000000000000000859eefc267671595d987d0f6589d7771d4877113
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 26 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.