Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
0x60806040 | 11277783 | 1445 days ago | IN | 0 ETH | 0.18245519 |
View more zero value Internal Transactions in Advanced View mode
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:
Cover
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/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); } }
// 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 "./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: 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); } }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"","type":"address"}],"name":"NewCoverERC20","type":"event"},{"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"},{"inputs":[],"name":"claimCovToken","outputs":[{"internalType":"contract ICoverERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimNonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"collateral","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"expirationTimestamp","outputs":[{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCoverDetails","outputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"uint48","name":"_expirationTimestamp","type":"uint48"},{"internalType":"address","name":"_collateral","type":"address"},{"internalType":"uint256","name":"_claimNonce","type":"uint256"},{"internalType":"contract ICoverERC20","name":"_claimCovToken","type":"address"},{"internalType":"contract ICoverERC20","name":"_noclaimCovToken","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"uint48","name":"_timestamp","type":"uint48"},{"internalType":"address","name":"_collateral","type":"address"},{"internalType":"uint256","name":"_claimNonce","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_receiver","type":"address"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"noclaimCovToken","outputs":[{"internalType":"contract ICoverERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"redeemClaim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"redeemCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"redeemNoclaim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_name","type":"string"}],"name":"setCovTokenSymbol","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b50600160025561317a806100256000396000f3fe608060405234801561001057600080fd5b50600436106101005760003560e01c806394bf804d11610097578063d8dfeb4511610066578063d8dfeb45146103a1578063dc059a10146103a9578063f2fde38b146103b1578063f888098e146103d757610100565b806394bf804d1461031b5780639f43ddd214610347578063a5212d9a1461036a578063bd37b7751461038457610100565b80634e71e0c8116100d35780634e71e0c8146102df57806383f16054146102e75780638da5cb5b1461030b57806391b0cd811461031357610100565b806306fdde03146101055780631c75d880146101825780631e45234e1461018c57806325153b7b14610219575b600080fd5b61010d610447565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561014757818101518382015260200161012f565b50505050905090810190601f1680156101745780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61018a6104d5565b005b61018a600480360360808110156101a257600080fd5b8101906020810181356401000000008111156101bd57600080fd5b8201836020820111156101cf57600080fd5b803590602001918460018302840111640100000000831117156101f157600080fd5b919350915065ffffffffffff813516906001600160a01b03602082013516906040013561086b565b6102216109f3565b60405180806020018765ffffffffffff168152602001866001600160a01b03168152602001858152602001846001600160a01b03168152602001836001600160a01b03168152602001828103825288818151815260200191508051906020019080838360005b8381101561029f578181015183820152602001610287565b50505050905090810190601f1680156102cc5780820380516001836020036101000a031916815260200191505b5097505050505050505060405180910390f35b61018a610ad7565b6102ef610ba5565b604080516001600160a01b039092168252519081900360200190f35b6102ef610bb4565b6102ef610bc9565b61018a6004803603604081101561033157600080fd5b50803590602001356001600160a01b0316610bd8565b61034f610da6565b6040805165ffffffffffff9092168252519081900360200190f35b610372610db4565b60408051918252519081900360200190f35b61018a6004803603602081101561039a57600080fd5b5035610dba565b6102ef611103565b61018a611119565b61018a600480360360208110156103c757600080fd5b50356001600160a01b031661131f565b61018a600480360360208110156103ed57600080fd5b81019060208101813564010000000081111561040857600080fd5b82018360208201111561041a57600080fd5b8035906020019184600183028401116401000000008311171561043c57600080fd5b50909250905061142a565b6006805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156104cd5780601f106104a2576101008083540402835291602001916104cd565b820191906000526020600020905b8154815290600101906020018083116104b057829003601f168201915b505050505081565b60006104df610bb4565b9050600754816001600160a01b031663a5212d9a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561051d57600080fd5b505afa158015610531573d6000803e3d6000fd5b505050506040513d602081101561054757600080fd5b505111156107985760008060008061055d611681565b6003549397509195509350915065ffffffffffff908116908316111561065257846001600160a01b03166381c4fb5b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156105b657600080fd5b505afa1580156105ca573d6000803e3d6000fd5b505050506040513d60208110156105e057600080fd5b505160035465ffffffffffff1601421015610635576040805162461bcd60e51b815260206004820152601060248201526f434f5645523a206e6f7420726561647960801b604482015290519081900360640190fd5b60055461064d906001600160a01b031660018061171f565b61078f565b8261ffff168461ffff16106106ae576040805162461bcd60e51b815260206004820152601860248201527f434f5645523a20636c61696d207061796f757420313030250000000000000000604482015290519081900360640190fd5b846001600160a01b0316637cd690d36040518163ffffffff1660e01b815260040160206040518083038186803b1580156106e757600080fd5b505afa1580156106fb573d6000803e3d6000fd5b505050506040513d602081101561071157600080fd5b505165ffffffffffff821601421015610764576040805162461bcd60e51b815260206004820152601060248201526f434f5645523a206e6f7420726561647960801b604482015290519081900360640190fd5b60055461078f906001600160a01b031661078561ffff86811690881661192d565b8561ffff1661171f565b50505050610868565b806001600160a01b03166381c4fb5b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156107d157600080fd5b505afa1580156107e5573d6000803e3d6000fd5b505050506040513d60208110156107fb57600080fd5b505160035465ffffffffffff1601421015610850576040805162461bcd60e51b815260206004820152601060248201526f434f5645523a206e6f7420726561647960801b604482015290519081900360640190fd5b600554610868906001600160a01b031660018061171f565b50565b600054610100900460ff16806108845750610884611978565b80610892575060005460ff16155b6108cd5760405162461bcd60e51b815260040180806020018281038252602e8152602001806130a8602e913960400191505060405180910390fd5b600054610100900460ff161580156108f8576000805460ff1961ff0019909116610100171660011790555b61090460068787612844565b506003805465ffffffffffff191665ffffffffffff8616176601000000000000600160d01b031916600160301b6001600160a01b03861602179055600782905561094c61197e565b61097260405180604001604052806005815260200164434c41494d60d81b815250611a75565b600480546001600160a01b0319166001600160a01b03929092169190911790556040805180820190915260078152664e4f434c41494d60c81b60208201526109b990611a75565b600580546001600160a01b0319166001600160a01b039290921691909117905580156109eb576000805461ff00191690555b505050505050565b6003546007546004546005546006805460408051602060026101006001861615026000190190941693909304601f81018490048402820184019092528181526060976000978897889788978897909665ffffffffffff861696600160301b9096046001600160a01b03908116969481169493169291889190830182828015610abc5780601f10610a9157610100808354040283529160200191610abc565b820191906000526020600020905b815481529060010190602001808311610a9f57829003601f168201915b50505050509550955095509550955095509550909192939495565b6001546001600160a01b03163314610b36576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600154600080546040516001600160a01b039384169362010000909204909116917fe9a5158ac7353c7c7322ececc080bc8e89334efa5795b6e21e40eb266b0003d691a36001546000805462010000600160b01b0319166001600160a01b039092166201000002919091179055565b6004546001600160a01b031681565b6000546201000090046001600160a01b031690565b6005546001600160a01b031681565b6000546201000090046001600160a01b03163314610c3d576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60035465ffffffffffff164210610c92576040805162461bcd60e51b815260206004820152601460248201527310d3d591548e8818dbdd995c88195e1c1a5c995960621b604482015290519081900360640190fd5b610c9a611f8d565b60048054604080516340c10f1960e01b81526001600160a01b038581169482019490945260248101869052905192909116916340c10f19916044808201926020929091908290030181600087803b158015610cf457600080fd5b505af1158015610d08573d6000803e3d6000fd5b505050506040513d6020811015610d1e57600080fd5b5050600554604080516340c10f1960e01b81526001600160a01b03848116600483015260248201869052915191909216916340c10f199160448083019260209291908290030181600087803b158015610d7657600080fd5b505af1158015610d8a573d6000803e3d6000fd5b505050506040513d6020811015610da057600080fd5b50505050565b60035465ffffffffffff1681565b60075481565b60035465ffffffffffff164210610e0f576040805162461bcd60e51b815260206004820152601460248201527310d3d591548e8818dbdd995c88195e1c1a5c995960621b604482015290519081900360640190fd5b60008111610e59576040805162461bcd60e51b81526020600482015260126024820152710434f5645523a20616d6f756e7420697320360741b604482015290519081900360640190fd5b610e61611f8d565b60048054600554604080516370a0823160e01b81523394810194909452516001600160a01b0392831693919092169183916370a08231916024808301926020929190829003018186803b158015610eb757600080fd5b505afa158015610ecb573d6000803e3d6000fd5b505050506040513d6020811015610ee157600080fd5b5051831115610f37576040805162461bcd60e51b815260206004820152601860248201527f434f5645523a206c6f7720434c41494d2062616c616e63650000000000000000604482015290519081900360640190fd5b604080516370a0823160e01b815233600482015290516001600160a01b038316916370a08231916024808301926020929190829003018186803b158015610f7d57600080fd5b505afa158015610f91573d6000803e3d6000fd5b505050506040513d6020811015610fa757600080fd5b5051831115610ffd576040805162461bcd60e51b815260206004820152601a60248201527f434f5645523a206c6f77204e4f434c41494d2062616c616e6365000000000000604482015290519081900360640190fd5b6040805163f8cc02df60e01b81523360048201526024810185905290516001600160a01b0384169163f8cc02df9160448083019260209291908290030181600087803b15801561104c57600080fd5b505af1158015611060573d6000803e3d6000fd5b505050506040513d602081101561107657600080fd5b50506040805163f8cc02df60e01b81523360048201526024810185905290516001600160a01b0383169163f8cc02df9160448083019260209291908290030181600087803b1580156110c757600080fd5b505af11580156110db573d6000803e3d6000fd5b505050506040513d60208110156110f157600080fd5b506110fe90503384612048565b505050565b600354600160301b90046001600160a01b031681565b6000611123610bb4565b9050600754816001600160a01b031663a5212d9a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561116157600080fd5b505afa158015611175573d6000803e3d6000fd5b505050506040513d602081101561118b57600080fd5b5051116111df576040805162461bcd60e51b815260206004820152601860248201527f434f5645523a206e6f20636c61696d2061636365707465640000000000000000604482015290519081900360640190fd5b6000806000806111ed611681565b6003549397509195509350915065ffffffffffff90811690831611156112445760405162461bcd60e51b81526004018080602001828103825260248152602001806130f76024913960400191505060405180910390fd5b846001600160a01b0316637cd690d36040518163ffffffff1660e01b815260040160206040518083038186803b15801561127d57600080fd5b505afa158015611291573d6000803e3d6000fd5b505050506040513d60208110156112a757600080fd5b505165ffffffffffff8216014210156112fa576040805162461bcd60e51b815260206004820152601060248201526f434f5645523a206e6f7420726561647960801b604482015290519081900360640190fd5b600454611318906001600160a01b031661ffff80871690861661171f565b5050505050565b6000546201000090046001600160a01b03163314611384576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166113c95760405162461bcd60e51b81526004018080602001828103825260268152602001806130826026913960400191505060405180910390fd5b600080546040516001600160a01b03808516936201000090930416917fb150023a879fd806e3599b6ca8ee3b60f0e360ab3846d128d67ebce1a391639a91a3600180546001600160a01b0319166001600160a01b0392909216919091179055565b33611433612264565b6001600160a01b03161461147f576040805162461bcd60e51b815260206004820152600e60248201526d21a7ab22a91d103737ba103232bb60911b604482015290519081900360640190fd5b6004546040516001600160a01b039091169063b84c8246908490849060200180838380828437655f434c41494d60d01b9201918252506040805160191981840301815260068301918290526001600160e01b031960e088901b169091526020600a83018181528251602a85015282519296509450849350604a9092019185019080838360005b8381101561151d578181015183820152602001611505565b50505050905090810190601f16801561154a5780820380516001836020036101000a031916815260200191505b5092505050602060405180830381600087803b15801561156957600080fd5b505af115801561157d573d6000803e3d6000fd5b505050506040513d602081101561159357600080fd5b50506005546040516001600160a01b039091169063b84c8246908490849060200180838380828437675f4e4f434c41494d60c01b9201918252506040805160171981840301815260088301918290526001600160e01b031960e088901b169091526020600c83018181528251602c85015282519296509450849350604c9092019185019080838360005b8381101561163557818101518382015260200161161d565b50505050905090810190601f1680156116625780820380516001836020036101000a031916815260200191505b5092505050602060405180830381600087803b158015610d7657600080fd5b60008060008061168f610bb4565b6001600160a01b0316633d040c6c6007546040518263ffffffff1660e01b81526004018082815260200191505060806040518083038186803b1580156116d457600080fd5b505afa1580156116e8573d6000803e3d6000fd5b505050506040513d60808110156116fe57600080fd5b50805160208201516040830151606090930151919790965091945092509050565b80821115611774576040805162461bcd60e51b815260206004820152601960248201527f434f5645523a207061796f75742025206973203e203130302500000000000000604482015290519081900360640190fd5b600082116117c0576040805162461bcd60e51b8152602060048201526014602482015273434f5645523a207061796f75742025203c20302560601b604482015290519081900360640190fd5b6000836001600160a01b03166370a08231336040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561180f57600080fd5b505afa158015611823573d6000803e3d6000fd5b505050506040513d602081101561183957600080fd5b505190508061188f576040805162461bcd60e51b815260206004820152601b60248201527f434f5645523a206c6f7720636f76546f6b656e2062616c616e63650000000000604482015290519081900360640190fd5b6040805163f8cc02df60e01b81523360048201526024810183905290516001600160a01b0386169163f8cc02df9160448083019260209291908290030181600087803b1580156118de57600080fd5b505af11580156118f2573d6000803e3d6000fd5b505050506040513d602081101561190857600080fd5b50600090506119218361191b84876122d7565b90612330565b90506113183382612048565b600061196f83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612372565b90505b92915050565b303b1590565b600054610100900460ff16806119975750611997611978565b806119a5575060005460ff16155b6119e05760405162461bcd60e51b815260040180806020018281038252602e8152602001806130a8602e913960400191505060405180910390fd5b600054610100900460ff16158015611a0b576000805460ff1961ff0019909116610100171660011790555b600080546201000033810262010000600160b01b0319909216919091178083556040519190046001600160a01b031691907fe9a5158ac7353c7c7322ececc080bc8e89334efa5795b6e21e40eb266b0003d6908290a38015610868576000805461ff001916905550565b6000606060405180602001611a89906128c2565b601f1982820381018352601f9091011660405290506000611aa8610bb4565b6001600160a01b03166306fdde036040518163ffffffff1660e01b815260040160206040518083038186803b158015611ae057600080fd5b505afa158015611af4573d6000803e3d6000fd5b505050506040513d6020811015611b0a57600080fd5b505160035460075460408051602080820186815260d086901b6001600160d01b03191693830193909352600160301b8504606081901b6bffffffffffffffffffffffff19166046840152605a83018590528a5165ffffffffffff909616956001600160a01b0390911694938b939092607a90910191908401908083835b60208310611ba65780518252601f199092019160209182019101611b87565b6001836020036101000a038019825116818451168082178552505050505050905001955050505050506040516020818303038152906040528051906020012090506000611bf560008385612409565b905060607ff62d188800b594eda156757988de1a22139f89fbcb7bfc58e96e79b054b5cb476006876040516020018083805460018160011615610100020316600290048015611c7b5780601f10611c59576101008083540402835291820191611c7b565b820191906000526020600020905b815481529060010190602001808311611c67575b505080605f60f81b81525060010182805190602001908083835b60208310611cb45780518252601f199092019160209182019101611c95565b51815160209384036101000a60001901801990921691161790526040805192909401828103601f19018352938490526024840181815282516044860152825192975095508594506064909301928601915080838360005b83811015611d23578181015183820152602001611d0b565b50505050905090810190601f168015611d505780820380516001836020036101000a031916815260200191505b5092505050604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b03838183161783525050505090506000611d94612522565b6001600160a01b031663a6624cb66040518163ffffffff1660e01b815260040160206040518083038186803b158015611dcc57600080fd5b505afa158015611de0573d6000803e3d6000fd5b505050506040513d6020811015611df657600080fd5b505190506001600160a01b03831663cf7a1d7782611e12612522565b6001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b158015611e4a57600080fd5b505afa158015611e5e573d6000803e3d6000fd5b505050506040513d6020811015611e7457600080fd5b50516040516001600160e01b031960e085901b1681526001600160a01b03808416600483019081529083166024830152606060448301908152885160648401528851899360840190602085019080838360005b83811015611edf578181015183820152602001611ec7565b50505050905090810190601f168015611f0c5780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b158015611f2d57600080fd5b505af1158015611f41573d6000803e3d6000fd5b5050604080516001600160a01b038716815290517f1119c1c5c819bb048b45a79c62a0f993269f2abac47b9040c310843a73fea2519350908190036020019150a1509095945050505050565b600754611f98610bb4565b6001600160a01b031663a5212d9a6040518163ffffffff1660e01b815260040160206040518083038186803b158015611fd057600080fd5b505afa158015611fe4573d6000803e3d6000fd5b505050506040513d6020811015611ffa57600080fd5b505114612046576040805162461bcd60e51b815260206004820152601560248201527410d3d591548e8818db185a5b481858d8d95c1d1959605a1b604482015290519081900360640190fd5b565b60028054141561209f576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002805560006120ad612522565b90506000816001600160a01b0316630db60f376040518163ffffffff1660e01b815260040160206040518083038186803b1580156120ea57600080fd5b505afa1580156120fe573d6000803e3d6000fd5b505050506040513d602081101561211457600080fd5b50516040805163c12e90e960e01b8152905161ffff90921692506000916001600160a01b0385169163c12e90e9916004808301926020929190829003018186803b15801561216157600080fd5b505afa158015612175573d6000803e3d6000fd5b505050506040513d602081101561218b57600080fd5b505161ffff16905060006121a38261191b87866122d7565b90506000846001600160a01b03166361d027b36040518163ffffffff1660e01b815260040160206040518083038186803b1580156121e057600080fd5b505afa1580156121f4573d6000803e3d6000fd5b505050506040513d602081101561220a57600080fd5b5051600354909150600160301b90046001600160a01b031661224188612230898661192d565b6001600160a01b038416919061252c565b6122556001600160a01b038216838561252c565b50506001600255505050505050565b600061226e612522565b6001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156122a657600080fd5b505afa1580156122ba573d6000803e3d6000fd5b505050506040513d60208110156122d057600080fd5b5051905090565b6000826122e657506000611972565b828202828482816122f357fe5b041461196f5760405162461bcd60e51b81526004018080602001828103825260218152602001806130d66021913960400191505060405180910390fd5b600061196f83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061257e565b600081848411156124015760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156123c65781810151838201526020016123ae565b50505050905090810190601f1680156123f35780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b60008084471015612461576040805162461bcd60e51b815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e6365000000604482015290519081900360640190fd5b82516124b4576040805162461bcd60e51b815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f604482015290519081900360640190fd5b8383516020850187f590506001600160a01b03811661251a576040805162461bcd60e51b815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f7900000000000000604482015290519081900360640190fd5b949350505050565b600061226e610bb4565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526110fe9084906125e3565b600081836125cd5760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156123c65781810151838201526020016123ae565b5060008385816125d957fe5b0495945050505050565b6060612638826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166126949092919063ffffffff16565b8051909150156110fe5780806020019051602081101561265757600080fd5b50516110fe5760405162461bcd60e51b815260040180806020018281038252602a81526020018061311b602a913960400191505060405180910390fd5b606061251a848460008560606126a98561280b565b6126fa576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106127395780518252601f19909201916020918201910161271a565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d806000811461279b576040519150601f19603f3d011682016040523d82523d6000602084013e6127a0565b606091505b509150915081156127b457915061251a9050565b8051156127c45780518082602001fd5b60405162461bcd60e51b81526020600482018181528651602484015286518793919283926044019190850190808383600083156123c65781810151838201526020016123ae565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081811480159061251a575050151592915050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106128855782800160ff198235161785556128b2565b828001600101855582156128b2579182015b828111156128b2578235825591602001919060010190612897565b506128be9291506128cf565b5090565b61079d806128e583390190565b5b808211156128be57600081556001016128d056fe608060405234801561001057600080fd5b5061077d806100206000396000f3fe6080604052600436106100595760003560e01c80633659cfe6146100705780634f1ef286146100a35780635c60da1b146101235780638f28397014610154578063cf7a1d7714610187578063f851a4401461024657610068565b366100685761006661025b565b005b61006661025b565b34801561007c57600080fd5b506100666004803603602081101561009357600080fd5b50356001600160a01b0316610275565b610066600480360360408110156100b957600080fd5b6001600160a01b0382351691908101906040810160208201356401000000008111156100e457600080fd5b8201836020820111156100f657600080fd5b8035906020019184600183028401116401000000008311171561011857600080fd5b5090925090506102af565b34801561012f57600080fd5b5061013861035c565b604080516001600160a01b039092168252519081900360200190f35b34801561016057600080fd5b506100666004803603602081101561017757600080fd5b50356001600160a01b0316610399565b6100666004803603606081101561019d57600080fd5b6001600160a01b0382358116926020810135909116918101906060810160408201356401000000008111156101d157600080fd5b8201836020820111156101e357600080fd5b8035906020019184600183028401116401000000008311171561020557600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610453945050505050565b34801561025257600080fd5b5061013861053a565b610263610273565b61027361026e610565565b61058a565b565b61027d6105ae565b6001600160a01b0316336001600160a01b031614156102a45761029f816105d3565b6102ac565b6102ac61025b565b50565b6102b76105ae565b6001600160a01b0316336001600160a01b0316141561034f576102d9836105d3565b6000836001600160a01b031683836040518083838082843760405192019450600093509091505080830381855af49150503d8060008114610336576040519150601f19603f3d011682016040523d82523d6000602084013e61033b565b606091505b505090508061034957600080fd5b50610357565b61035761025b565b505050565b60006103666105ae565b6001600160a01b0316336001600160a01b0316141561038e57610387610565565b9050610396565b61039661025b565b90565b6103a16105ae565b6001600160a01b0316336001600160a01b031614156102a4576001600160a01b0381166103ff5760405162461bcd60e51b81526004018080602001828103825260368152602001806106dc6036913960400191505060405180910390fd5b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104286105ae565b604080516001600160a01b03928316815291841660208301528051918290030190a161029f81610613565b600061045d610565565b6001600160a01b03161461047057600080fd5b61047983610637565b805115610531576000836001600160a01b0316826040518082805190602001908083835b602083106104bc5780518252601f19909201916020918201910161049d565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d806000811461051c576040519150601f19603f3d011682016040523d82523d6000602084013e610521565b606091505b505090508061052f57600080fd5b505b61035782610613565b60006105446105ae565b6001600160a01b0316336001600160a01b0316141561038e576103876105ae565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b3660008037600080366000845af43d6000803e8080156105a9573d6000f35b3d6000fd5b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035490565b6105dc81610637565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610355565b6106408161069f565b61067b5760405162461bcd60e51b81526004018080602001828103825260368152602001806107126036913960400191505060405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc55565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4708181148015906106d357508115155b94935050505056fe43616e6e6f74206368616e6765207468652061646d696e206f6620612070726f787920746f20746865207a65726f20616464726573735570677261646561626c6550726f78793a206e657720696d706c656d656e746174696f6e206973206e6f74206120636f6e7472616374a2646970667358221220bb1380c8baf572bad88171f2a9370ded98c1c442f5378d819a912f33b83f1bc964736f6c634300070300334f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a6564536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77434f5645523a20636f7665722065787069726564206265666f726520696e636964656e745361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a26469706673582212207fb192fc36b1c1e15dabeca4535efb3f06bc54cbf4ff084833ec5ba24eafd56764736f6c63430007030033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101005760003560e01c806394bf804d11610097578063d8dfeb4511610066578063d8dfeb45146103a1578063dc059a10146103a9578063f2fde38b146103b1578063f888098e146103d757610100565b806394bf804d1461031b5780639f43ddd214610347578063a5212d9a1461036a578063bd37b7751461038457610100565b80634e71e0c8116100d35780634e71e0c8146102df57806383f16054146102e75780638da5cb5b1461030b57806391b0cd811461031357610100565b806306fdde03146101055780631c75d880146101825780631e45234e1461018c57806325153b7b14610219575b600080fd5b61010d610447565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561014757818101518382015260200161012f565b50505050905090810190601f1680156101745780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61018a6104d5565b005b61018a600480360360808110156101a257600080fd5b8101906020810181356401000000008111156101bd57600080fd5b8201836020820111156101cf57600080fd5b803590602001918460018302840111640100000000831117156101f157600080fd5b919350915065ffffffffffff813516906001600160a01b03602082013516906040013561086b565b6102216109f3565b60405180806020018765ffffffffffff168152602001866001600160a01b03168152602001858152602001846001600160a01b03168152602001836001600160a01b03168152602001828103825288818151815260200191508051906020019080838360005b8381101561029f578181015183820152602001610287565b50505050905090810190601f1680156102cc5780820380516001836020036101000a031916815260200191505b5097505050505050505060405180910390f35b61018a610ad7565b6102ef610ba5565b604080516001600160a01b039092168252519081900360200190f35b6102ef610bb4565b6102ef610bc9565b61018a6004803603604081101561033157600080fd5b50803590602001356001600160a01b0316610bd8565b61034f610da6565b6040805165ffffffffffff9092168252519081900360200190f35b610372610db4565b60408051918252519081900360200190f35b61018a6004803603602081101561039a57600080fd5b5035610dba565b6102ef611103565b61018a611119565b61018a600480360360208110156103c757600080fd5b50356001600160a01b031661131f565b61018a600480360360208110156103ed57600080fd5b81019060208101813564010000000081111561040857600080fd5b82018360208201111561041a57600080fd5b8035906020019184600183028401116401000000008311171561043c57600080fd5b50909250905061142a565b6006805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156104cd5780601f106104a2576101008083540402835291602001916104cd565b820191906000526020600020905b8154815290600101906020018083116104b057829003601f168201915b505050505081565b60006104df610bb4565b9050600754816001600160a01b031663a5212d9a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561051d57600080fd5b505afa158015610531573d6000803e3d6000fd5b505050506040513d602081101561054757600080fd5b505111156107985760008060008061055d611681565b6003549397509195509350915065ffffffffffff908116908316111561065257846001600160a01b03166381c4fb5b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156105b657600080fd5b505afa1580156105ca573d6000803e3d6000fd5b505050506040513d60208110156105e057600080fd5b505160035465ffffffffffff1601421015610635576040805162461bcd60e51b815260206004820152601060248201526f434f5645523a206e6f7420726561647960801b604482015290519081900360640190fd5b60055461064d906001600160a01b031660018061171f565b61078f565b8261ffff168461ffff16106106ae576040805162461bcd60e51b815260206004820152601860248201527f434f5645523a20636c61696d207061796f757420313030250000000000000000604482015290519081900360640190fd5b846001600160a01b0316637cd690d36040518163ffffffff1660e01b815260040160206040518083038186803b1580156106e757600080fd5b505afa1580156106fb573d6000803e3d6000fd5b505050506040513d602081101561071157600080fd5b505165ffffffffffff821601421015610764576040805162461bcd60e51b815260206004820152601060248201526f434f5645523a206e6f7420726561647960801b604482015290519081900360640190fd5b60055461078f906001600160a01b031661078561ffff86811690881661192d565b8561ffff1661171f565b50505050610868565b806001600160a01b03166381c4fb5b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156107d157600080fd5b505afa1580156107e5573d6000803e3d6000fd5b505050506040513d60208110156107fb57600080fd5b505160035465ffffffffffff1601421015610850576040805162461bcd60e51b815260206004820152601060248201526f434f5645523a206e6f7420726561647960801b604482015290519081900360640190fd5b600554610868906001600160a01b031660018061171f565b50565b600054610100900460ff16806108845750610884611978565b80610892575060005460ff16155b6108cd5760405162461bcd60e51b815260040180806020018281038252602e8152602001806130a8602e913960400191505060405180910390fd5b600054610100900460ff161580156108f8576000805460ff1961ff0019909116610100171660011790555b61090460068787612844565b506003805465ffffffffffff191665ffffffffffff8616176601000000000000600160d01b031916600160301b6001600160a01b03861602179055600782905561094c61197e565b61097260405180604001604052806005815260200164434c41494d60d81b815250611a75565b600480546001600160a01b0319166001600160a01b03929092169190911790556040805180820190915260078152664e4f434c41494d60c81b60208201526109b990611a75565b600580546001600160a01b0319166001600160a01b039290921691909117905580156109eb576000805461ff00191690555b505050505050565b6003546007546004546005546006805460408051602060026101006001861615026000190190941693909304601f81018490048402820184019092528181526060976000978897889788978897909665ffffffffffff861696600160301b9096046001600160a01b03908116969481169493169291889190830182828015610abc5780601f10610a9157610100808354040283529160200191610abc565b820191906000526020600020905b815481529060010190602001808311610a9f57829003601f168201915b50505050509550955095509550955095509550909192939495565b6001546001600160a01b03163314610b36576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600154600080546040516001600160a01b039384169362010000909204909116917fe9a5158ac7353c7c7322ececc080bc8e89334efa5795b6e21e40eb266b0003d691a36001546000805462010000600160b01b0319166001600160a01b039092166201000002919091179055565b6004546001600160a01b031681565b6000546201000090046001600160a01b031690565b6005546001600160a01b031681565b6000546201000090046001600160a01b03163314610c3d576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60035465ffffffffffff164210610c92576040805162461bcd60e51b815260206004820152601460248201527310d3d591548e8818dbdd995c88195e1c1a5c995960621b604482015290519081900360640190fd5b610c9a611f8d565b60048054604080516340c10f1960e01b81526001600160a01b038581169482019490945260248101869052905192909116916340c10f19916044808201926020929091908290030181600087803b158015610cf457600080fd5b505af1158015610d08573d6000803e3d6000fd5b505050506040513d6020811015610d1e57600080fd5b5050600554604080516340c10f1960e01b81526001600160a01b03848116600483015260248201869052915191909216916340c10f199160448083019260209291908290030181600087803b158015610d7657600080fd5b505af1158015610d8a573d6000803e3d6000fd5b505050506040513d6020811015610da057600080fd5b50505050565b60035465ffffffffffff1681565b60075481565b60035465ffffffffffff164210610e0f576040805162461bcd60e51b815260206004820152601460248201527310d3d591548e8818dbdd995c88195e1c1a5c995960621b604482015290519081900360640190fd5b60008111610e59576040805162461bcd60e51b81526020600482015260126024820152710434f5645523a20616d6f756e7420697320360741b604482015290519081900360640190fd5b610e61611f8d565b60048054600554604080516370a0823160e01b81523394810194909452516001600160a01b0392831693919092169183916370a08231916024808301926020929190829003018186803b158015610eb757600080fd5b505afa158015610ecb573d6000803e3d6000fd5b505050506040513d6020811015610ee157600080fd5b5051831115610f37576040805162461bcd60e51b815260206004820152601860248201527f434f5645523a206c6f7720434c41494d2062616c616e63650000000000000000604482015290519081900360640190fd5b604080516370a0823160e01b815233600482015290516001600160a01b038316916370a08231916024808301926020929190829003018186803b158015610f7d57600080fd5b505afa158015610f91573d6000803e3d6000fd5b505050506040513d6020811015610fa757600080fd5b5051831115610ffd576040805162461bcd60e51b815260206004820152601a60248201527f434f5645523a206c6f77204e4f434c41494d2062616c616e6365000000000000604482015290519081900360640190fd5b6040805163f8cc02df60e01b81523360048201526024810185905290516001600160a01b0384169163f8cc02df9160448083019260209291908290030181600087803b15801561104c57600080fd5b505af1158015611060573d6000803e3d6000fd5b505050506040513d602081101561107657600080fd5b50506040805163f8cc02df60e01b81523360048201526024810185905290516001600160a01b0383169163f8cc02df9160448083019260209291908290030181600087803b1580156110c757600080fd5b505af11580156110db573d6000803e3d6000fd5b505050506040513d60208110156110f157600080fd5b506110fe90503384612048565b505050565b600354600160301b90046001600160a01b031681565b6000611123610bb4565b9050600754816001600160a01b031663a5212d9a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561116157600080fd5b505afa158015611175573d6000803e3d6000fd5b505050506040513d602081101561118b57600080fd5b5051116111df576040805162461bcd60e51b815260206004820152601860248201527f434f5645523a206e6f20636c61696d2061636365707465640000000000000000604482015290519081900360640190fd5b6000806000806111ed611681565b6003549397509195509350915065ffffffffffff90811690831611156112445760405162461bcd60e51b81526004018080602001828103825260248152602001806130f76024913960400191505060405180910390fd5b846001600160a01b0316637cd690d36040518163ffffffff1660e01b815260040160206040518083038186803b15801561127d57600080fd5b505afa158015611291573d6000803e3d6000fd5b505050506040513d60208110156112a757600080fd5b505165ffffffffffff8216014210156112fa576040805162461bcd60e51b815260206004820152601060248201526f434f5645523a206e6f7420726561647960801b604482015290519081900360640190fd5b600454611318906001600160a01b031661ffff80871690861661171f565b5050505050565b6000546201000090046001600160a01b03163314611384576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166113c95760405162461bcd60e51b81526004018080602001828103825260268152602001806130826026913960400191505060405180910390fd5b600080546040516001600160a01b03808516936201000090930416917fb150023a879fd806e3599b6ca8ee3b60f0e360ab3846d128d67ebce1a391639a91a3600180546001600160a01b0319166001600160a01b0392909216919091179055565b33611433612264565b6001600160a01b03161461147f576040805162461bcd60e51b815260206004820152600e60248201526d21a7ab22a91d103737ba103232bb60911b604482015290519081900360640190fd5b6004546040516001600160a01b039091169063b84c8246908490849060200180838380828437655f434c41494d60d01b9201918252506040805160191981840301815260068301918290526001600160e01b031960e088901b169091526020600a83018181528251602a85015282519296509450849350604a9092019185019080838360005b8381101561151d578181015183820152602001611505565b50505050905090810190601f16801561154a5780820380516001836020036101000a031916815260200191505b5092505050602060405180830381600087803b15801561156957600080fd5b505af115801561157d573d6000803e3d6000fd5b505050506040513d602081101561159357600080fd5b50506005546040516001600160a01b039091169063b84c8246908490849060200180838380828437675f4e4f434c41494d60c01b9201918252506040805160171981840301815260088301918290526001600160e01b031960e088901b169091526020600c83018181528251602c85015282519296509450849350604c9092019185019080838360005b8381101561163557818101518382015260200161161d565b50505050905090810190601f1680156116625780820380516001836020036101000a031916815260200191505b5092505050602060405180830381600087803b158015610d7657600080fd5b60008060008061168f610bb4565b6001600160a01b0316633d040c6c6007546040518263ffffffff1660e01b81526004018082815260200191505060806040518083038186803b1580156116d457600080fd5b505afa1580156116e8573d6000803e3d6000fd5b505050506040513d60808110156116fe57600080fd5b50805160208201516040830151606090930151919790965091945092509050565b80821115611774576040805162461bcd60e51b815260206004820152601960248201527f434f5645523a207061796f75742025206973203e203130302500000000000000604482015290519081900360640190fd5b600082116117c0576040805162461bcd60e51b8152602060048201526014602482015273434f5645523a207061796f75742025203c20302560601b604482015290519081900360640190fd5b6000836001600160a01b03166370a08231336040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561180f57600080fd5b505afa158015611823573d6000803e3d6000fd5b505050506040513d602081101561183957600080fd5b505190508061188f576040805162461bcd60e51b815260206004820152601b60248201527f434f5645523a206c6f7720636f76546f6b656e2062616c616e63650000000000604482015290519081900360640190fd5b6040805163f8cc02df60e01b81523360048201526024810183905290516001600160a01b0386169163f8cc02df9160448083019260209291908290030181600087803b1580156118de57600080fd5b505af11580156118f2573d6000803e3d6000fd5b505050506040513d602081101561190857600080fd5b50600090506119218361191b84876122d7565b90612330565b90506113183382612048565b600061196f83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612372565b90505b92915050565b303b1590565b600054610100900460ff16806119975750611997611978565b806119a5575060005460ff16155b6119e05760405162461bcd60e51b815260040180806020018281038252602e8152602001806130a8602e913960400191505060405180910390fd5b600054610100900460ff16158015611a0b576000805460ff1961ff0019909116610100171660011790555b600080546201000033810262010000600160b01b0319909216919091178083556040519190046001600160a01b031691907fe9a5158ac7353c7c7322ececc080bc8e89334efa5795b6e21e40eb266b0003d6908290a38015610868576000805461ff001916905550565b6000606060405180602001611a89906128c2565b601f1982820381018352601f9091011660405290506000611aa8610bb4565b6001600160a01b03166306fdde036040518163ffffffff1660e01b815260040160206040518083038186803b158015611ae057600080fd5b505afa158015611af4573d6000803e3d6000fd5b505050506040513d6020811015611b0a57600080fd5b505160035460075460408051602080820186815260d086901b6001600160d01b03191693830193909352600160301b8504606081901b6bffffffffffffffffffffffff19166046840152605a83018590528a5165ffffffffffff909616956001600160a01b0390911694938b939092607a90910191908401908083835b60208310611ba65780518252601f199092019160209182019101611b87565b6001836020036101000a038019825116818451168082178552505050505050905001955050505050506040516020818303038152906040528051906020012090506000611bf560008385612409565b905060607ff62d188800b594eda156757988de1a22139f89fbcb7bfc58e96e79b054b5cb476006876040516020018083805460018160011615610100020316600290048015611c7b5780601f10611c59576101008083540402835291820191611c7b565b820191906000526020600020905b815481529060010190602001808311611c67575b505080605f60f81b81525060010182805190602001908083835b60208310611cb45780518252601f199092019160209182019101611c95565b51815160209384036101000a60001901801990921691161790526040805192909401828103601f19018352938490526024840181815282516044860152825192975095508594506064909301928601915080838360005b83811015611d23578181015183820152602001611d0b565b50505050905090810190601f168015611d505780820380516001836020036101000a031916815260200191505b5092505050604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b03838183161783525050505090506000611d94612522565b6001600160a01b031663a6624cb66040518163ffffffff1660e01b815260040160206040518083038186803b158015611dcc57600080fd5b505afa158015611de0573d6000803e3d6000fd5b505050506040513d6020811015611df657600080fd5b505190506001600160a01b03831663cf7a1d7782611e12612522565b6001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b158015611e4a57600080fd5b505afa158015611e5e573d6000803e3d6000fd5b505050506040513d6020811015611e7457600080fd5b50516040516001600160e01b031960e085901b1681526001600160a01b03808416600483019081529083166024830152606060448301908152885160648401528851899360840190602085019080838360005b83811015611edf578181015183820152602001611ec7565b50505050905090810190601f168015611f0c5780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b158015611f2d57600080fd5b505af1158015611f41573d6000803e3d6000fd5b5050604080516001600160a01b038716815290517f1119c1c5c819bb048b45a79c62a0f993269f2abac47b9040c310843a73fea2519350908190036020019150a1509095945050505050565b600754611f98610bb4565b6001600160a01b031663a5212d9a6040518163ffffffff1660e01b815260040160206040518083038186803b158015611fd057600080fd5b505afa158015611fe4573d6000803e3d6000fd5b505050506040513d6020811015611ffa57600080fd5b505114612046576040805162461bcd60e51b815260206004820152601560248201527410d3d591548e8818db185a5b481858d8d95c1d1959605a1b604482015290519081900360640190fd5b565b60028054141561209f576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002805560006120ad612522565b90506000816001600160a01b0316630db60f376040518163ffffffff1660e01b815260040160206040518083038186803b1580156120ea57600080fd5b505afa1580156120fe573d6000803e3d6000fd5b505050506040513d602081101561211457600080fd5b50516040805163c12e90e960e01b8152905161ffff90921692506000916001600160a01b0385169163c12e90e9916004808301926020929190829003018186803b15801561216157600080fd5b505afa158015612175573d6000803e3d6000fd5b505050506040513d602081101561218b57600080fd5b505161ffff16905060006121a38261191b87866122d7565b90506000846001600160a01b03166361d027b36040518163ffffffff1660e01b815260040160206040518083038186803b1580156121e057600080fd5b505afa1580156121f4573d6000803e3d6000fd5b505050506040513d602081101561220a57600080fd5b5051600354909150600160301b90046001600160a01b031661224188612230898661192d565b6001600160a01b038416919061252c565b6122556001600160a01b038216838561252c565b50506001600255505050505050565b600061226e612522565b6001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156122a657600080fd5b505afa1580156122ba573d6000803e3d6000fd5b505050506040513d60208110156122d057600080fd5b5051905090565b6000826122e657506000611972565b828202828482816122f357fe5b041461196f5760405162461bcd60e51b81526004018080602001828103825260218152602001806130d66021913960400191505060405180910390fd5b600061196f83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061257e565b600081848411156124015760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156123c65781810151838201526020016123ae565b50505050905090810190601f1680156123f35780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b60008084471015612461576040805162461bcd60e51b815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e6365000000604482015290519081900360640190fd5b82516124b4576040805162461bcd60e51b815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f604482015290519081900360640190fd5b8383516020850187f590506001600160a01b03811661251a576040805162461bcd60e51b815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f7900000000000000604482015290519081900360640190fd5b949350505050565b600061226e610bb4565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526110fe9084906125e3565b600081836125cd5760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156123c65781810151838201526020016123ae565b5060008385816125d957fe5b0495945050505050565b6060612638826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166126949092919063ffffffff16565b8051909150156110fe5780806020019051602081101561265757600080fd5b50516110fe5760405162461bcd60e51b815260040180806020018281038252602a81526020018061311b602a913960400191505060405180910390fd5b606061251a848460008560606126a98561280b565b6126fa576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106127395780518252601f19909201916020918201910161271a565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d806000811461279b576040519150601f19603f3d011682016040523d82523d6000602084013e6127a0565b606091505b509150915081156127b457915061251a9050565b8051156127c45780518082602001fd5b60405162461bcd60e51b81526020600482018181528651602484015286518793919283926044019190850190808383600083156123c65781810151838201526020016123ae565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081811480159061251a575050151592915050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106128855782800160ff198235161785556128b2565b828001600101855582156128b2579182015b828111156128b2578235825591602001919060010190612897565b506128be9291506128cf565b5090565b61079d806128e583390190565b5b808211156128be57600081556001016128d056fe608060405234801561001057600080fd5b5061077d806100206000396000f3fe6080604052600436106100595760003560e01c80633659cfe6146100705780634f1ef286146100a35780635c60da1b146101235780638f28397014610154578063cf7a1d7714610187578063f851a4401461024657610068565b366100685761006661025b565b005b61006661025b565b34801561007c57600080fd5b506100666004803603602081101561009357600080fd5b50356001600160a01b0316610275565b610066600480360360408110156100b957600080fd5b6001600160a01b0382351691908101906040810160208201356401000000008111156100e457600080fd5b8201836020820111156100f657600080fd5b8035906020019184600183028401116401000000008311171561011857600080fd5b5090925090506102af565b34801561012f57600080fd5b5061013861035c565b604080516001600160a01b039092168252519081900360200190f35b34801561016057600080fd5b506100666004803603602081101561017757600080fd5b50356001600160a01b0316610399565b6100666004803603606081101561019d57600080fd5b6001600160a01b0382358116926020810135909116918101906060810160408201356401000000008111156101d157600080fd5b8201836020820111156101e357600080fd5b8035906020019184600183028401116401000000008311171561020557600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610453945050505050565b34801561025257600080fd5b5061013861053a565b610263610273565b61027361026e610565565b61058a565b565b61027d6105ae565b6001600160a01b0316336001600160a01b031614156102a45761029f816105d3565b6102ac565b6102ac61025b565b50565b6102b76105ae565b6001600160a01b0316336001600160a01b0316141561034f576102d9836105d3565b6000836001600160a01b031683836040518083838082843760405192019450600093509091505080830381855af49150503d8060008114610336576040519150601f19603f3d011682016040523d82523d6000602084013e61033b565b606091505b505090508061034957600080fd5b50610357565b61035761025b565b505050565b60006103666105ae565b6001600160a01b0316336001600160a01b0316141561038e57610387610565565b9050610396565b61039661025b565b90565b6103a16105ae565b6001600160a01b0316336001600160a01b031614156102a4576001600160a01b0381166103ff5760405162461bcd60e51b81526004018080602001828103825260368152602001806106dc6036913960400191505060405180910390fd5b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104286105ae565b604080516001600160a01b03928316815291841660208301528051918290030190a161029f81610613565b600061045d610565565b6001600160a01b03161461047057600080fd5b61047983610637565b805115610531576000836001600160a01b0316826040518082805190602001908083835b602083106104bc5780518252601f19909201916020918201910161049d565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d806000811461051c576040519150601f19603f3d011682016040523d82523d6000602084013e610521565b606091505b505090508061052f57600080fd5b505b61035782610613565b60006105446105ae565b6001600160a01b0316336001600160a01b0316141561038e576103876105ae565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b3660008037600080366000845af43d6000803e8080156105a9573d6000f35b3d6000fd5b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035490565b6105dc81610637565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610355565b6106408161069f565b61067b5760405162461bcd60e51b81526004018080602001828103825260368152602001806107126036913960400191505060405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc55565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4708181148015906106d357508115155b94935050505056fe43616e6e6f74206368616e6765207468652061646d696e206f6620612070726f787920746f20746865207a65726f20616464726573735570677261646561626c6550726f78793a206e657720696d706c656d656e746174696f6e206973206e6f74206120636f6e7472616374a2646970667358221220bb1380c8baf572bad88171f2a9370ded98c1c442f5378d819a912f33b83f1bc964736f6c634300070300334f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a6564536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77434f5645523a20636f7665722065787069726564206265666f726520696e636964656e745361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a26469706673582212207fb192fc36b1c1e15dabeca4535efb3f06bc54cbf4ff084833ec5ba24eafd56764736f6c63430007030033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ 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.