Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 4 from a total of 4 transactions
Latest 1 internal transaction
Advanced mode:
Parent Transaction Hash | Block |
From
|
To
|
|||
---|---|---|---|---|---|---|
11835106 | 1482 days ago | Contract Creation | 0 ETH |
Loading...
Loading
Minimal Proxy Contract for 0xa9e838fcb9295fa44d89d06ed59811ae1a22c105
Contract Name:
BondedECDSAKeep
Compiler Version
v0.5.17+commit.d19bba13
Contract Source Code (Solidity Standard Json-Input format)
1234567891011121314151617181920212223242526/**▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓Trust math, not hardware.*/pragma solidity 0.5.17;import "./AbstractBondedECDSAKeep.sol";import "./BondedECDSAKeepFactory.sol";import "@keep-network/keep-core/contracts/TokenStaking.sol";/// @title Bonded ECDSA Keep/// @notice ECDSA keep with additional signer bond requirement./// @dev This contract is used as a master contract for clone factory in/// BondedECDSAKeepFactory as per EIP-1167. It should never be removed after/// initial deployment as this will break functionality for all created clones.
1234567891011121314151617181920212223242526/**▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓Trust math, not hardware.*/pragma solidity 0.5.17;/// @title ECDSA Keep/// @notice Contract reflecting an ECDSA keep.contract IBondedECDSAKeep {/// @notice Returns public key of this keep./// @return Keeps's public key.function getPublicKey() external view returns (bytes memory);/// @notice Returns the amount of the keep's ETH bond in wei./// @return The amount of the keep's ETH bond in wei.function checkBondAmount() external view returns (uint256);
1234567891011121314151617181920212223242526/**▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓Trust math, not hardware.*/pragma solidity 0.5.17;import "./api/IBondedECDSAKeep.sol";import "./api/IBondingManagement.sol";import "@keep-network/keep-core/contracts/utils/AddressArrayUtils.sol";import "openzeppelin-solidity/contracts/math/SafeMath.sol";import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol";import "openzeppelin-solidity/contracts/token/ERC20/SafeERC20.sol";contract AbstractBondedECDSAKeep is IBondedECDSAKeep {
1234567891011121314151617181920212223242526/**▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓Trust math, not hardware.*/pragma solidity 0.5.17;import "@keep-network/sortition-pools/contracts/api/IBonding.sol";contract IBondingManagement is IBonding {/// @notice Add the provided value to operator's pool available for bonding./// @param operator Address of the operator.function deposit(address operator) public payable;/// @notice Withdraws amount from operator's value available for bonding./// @param amount Value to withdraw in wei./// @param operator Address of the operator.
1234567891011121314151617181920212223242526/**▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓Trust math, not hardware.*/pragma solidity 0.5.17;import "./BondedECDSAKeep.sol";import "./KeepBonding.sol";import "./api/IBondedECDSAKeepFactory.sol";import "./KeepCreator.sol";import "./GroupSelectionSeed.sol";import "./CandidatesPools.sol";import "@keep-network/sortition-pools/contracts/api/IStaking.sol";import "@keep-network/sortition-pools/contracts/api/IBonding.sol";import "@keep-network/sortition-pools/contracts/BondedSortitionPool.sol";
1234567891011121314151617181920212223242526/**▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓Trust math, not hardware.*/pragma solidity 0.5.17;/// @title Bonded ECDSA Keep Factory/// @notice Factory for Bonded ECDSA Keeps.interface IBondedECDSAKeepFactory {/// @notice Open a new ECDSA Keep./// @param _groupSize Number of members in the keep./// @param _honestThreshold Minimum number of honest keep members./// @param _owner Address of the keep owner./// @param _bond Value of ETH bond required from the keep./// @param _stakeLockDuration Stake lock duration in seconds./// @return Address of the opened keep.
1234567891011121314151617181920212223242526/**▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓Trust math, not hardware.*/pragma solidity 0.5.17;import "./CloneFactory.sol";contract KeepCreator is CloneFactory {// Holds the address of the keep contract that will be used as a master// contract for cloning.address public masterKeepAddress;// Keeps created by this factory.address[] public keeps;
1234567891011121314151617181920212223242526pragma solidity 0.5.17;/*The MIT License (MIT)Copyright (c) 2018 Murray Software, LLC.Permission is hereby granted, free of charge, to any person obtaininga copy of this software and associated documentation files (the"Software"), to deal in the Software without restriction, includingwithout limitation the rights to use, copy, modify, merge, publish,distribute, sublicense, and/or sell copies of the Software, and topermit persons to whom the Software is furnished to do so, subject tothe following conditions:The above copyright notice and this permission notice shall be includedin all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESSOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OFMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANYCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THESOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*///solhint-disable max-line-length//solhint-disable no-inline-assembly// Implementation of [EIP-1167] based on [clone-factory]
1234567891011121314151617181920212223242526pragma solidity 0.5.17;import "@keep-network/sortition-pools/contracts/AbstractSortitionPool.sol";contract CandidatesPools {// Notification that a new sortition pool has been created.event SortitionPoolCreated(address indexed application,address sortitionPool);// Mapping of pools with registered member candidates for each application.mapping(address => address) candidatesPools; // application -> candidates pool/// @notice Creates new sortition pool for the application./// @dev Emits an event after sortition pool creation./// @param _application Address of the application./// @return Address of the created sortition pool contract.function createSortitionPool(address _application)externalreturns (address){require(candidatesPools[_application] == address(0),"Sortition pool already exists");
1234567891011121314151617181920212223242526/**▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓Trust math, not hardware.*/pragma solidity 0.5.17;import "@keep-network/keep-core/contracts/IRandomBeacon.sol";import "openzeppelin-solidity/contracts/math/SafeMath.sol";import "openzeppelin-solidity/contracts/utils/ReentrancyGuard.sol";contract GroupSelectionSeed is IRandomBeaconConsumer, ReentrancyGuard {using SafeMath for uint256;IRandomBeacon randomBeacon;
1234567891011121314151617181920212223242526/**▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓Trust math, not hardware.*/pragma solidity 0.5.17;/// @title Keep Random Beacon////// @notice Keep Random Beacon generates verifiable randomness that is resistant/// to bad actors both in the relay network and on the anchoring blockchain.interface IRandomBeacon {/// @notice Event emitted for each new relay entry generated. It contains/// request ID allowing to associate the generated relay entry with relay/// request created previously with `requestRelayEntry` function. Event is/// emitted no matter if callback was executed or not.
1234567891011121314151617181920212223242526pragma solidity ^0.5.0;/*** @dev Contract module that helps prevent reentrant calls to a function.** Inheriting from `ReentrancyGuard` will make the `nonReentrant` modifier* available, which can be aplied 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.*/contract ReentrancyGuard {/// @dev counter to allow mutex lock with only one SSTORE operationuint256 private _guardCounter;constructor () internal {// The counter starts at one to prevent changing it from zero to a non-zero// value, which is a more expensive operation._guardCounter = 1;}/*** @dev Prevents a contract from calling itself, directly or indirectly.
1234567891011121314151617181920212223242526pragma solidity 0.5.17;import "./BondedSortitionPool.sol";import "./api/IBonding.sol";import "./api/IStaking.sol";/// @title Bonded Sortition Pool Factory/// @notice Factory for the creation of new bonded sortition pools.contract BondedSortitionPoolFactory {/// @notice Creates a new bonded sortition pool instance./// @return Address of the new bonded sortition pool contract instance.function createSortitionPool(IStaking stakingContract,IBonding bondingContract,uint256 minimumStake,uint256 initialMinimumBond,uint256 poolWeightDivisor) public returns (address) {returnaddress(new BondedSortitionPool(stakingContract,bondingContract,minimumStake,initialMinimumBond,poolWeightDivisor,
1234567891011121314151617181920212223242526pragma solidity 0.5.17;import "./AbstractSortitionPool.sol";import "./RNG.sol";import "./api/IStaking.sol";import "./api/IBonding.sol";import "./DynamicArray.sol";/// @title Bonded Sortition Pool/// @notice A logarithmic data structure used to store the pool of eligible/// operators weighted by their stakes. It allows to select a group of operators/// based on the provided pseudo-random seed and bonding requirements./// @dev Keeping pool up to date cannot be done eagerly as proliferation of/// privileged customers could be used to perform DOS attacks by increasing the/// cost of such updates. When a sortition pool prospectively selects an/// operator, the selected operator’s eligibility status and weight needs to be/// checked and, if necessary, updated in the sortition pool. If the changes/// would be detrimental to the operator, the operator selection is performed/// again with the updated input to ensure correctness./// The pool should specify a reasonable minimum bondable value for operators/// trying to join the pool, to prevent griefing the selection.contract BondedSortitionPool is AbstractSortitionPool {using DynamicArray for DynamicArray.UintArray;using DynamicArray for DynamicArray.AddressArray;using RNG for RNG.State;
1234567891011121314pragma solidity 0.5.17;interface IBonding {// Gives the amount of ETH// the `operator` has made available for bonding by the `bondCreator`.// If the operator doesn't exist,// or the bond creator isn't authorized,// returns 0.function availableUnbondedValue(address operator,address bondCreator,address authorizedSortitionPool) external view returns (uint256);}
1234567891011121314pragma solidity 0.5.17;interface IStaking {// Gives the amount of KEEP tokens staked by the `operator`// eligible for work selection in the specified `operatorContract`.//// If the operator doesn't exist or hasn't finished initializing,// or the operator contract hasn't been authorized for the operator,// returns 0.function eligibleStake(address operator,address operatorContract) external view returns (uint256);}
1234567891011121314151617181920212223242526pragma solidity 0.5.17;import "./GasStation.sol";import "./RNG.sol";import "./SortitionTree.sol";import "./DynamicArray.sol";import "./api/IStaking.sol";/// @title Abstract Sortition Pool/// @notice Abstract contract encapsulating common logic of all sortition pools./// @dev Inheriting implementations are expected to implement getEligibleWeight/// function.contract AbstractSortitionPool is SortitionTree, GasStation {using Leaf for uint256;using Position for uint256;using DynamicArray for DynamicArray.UintArray;using DynamicArray for DynamicArray.AddressArray;using RNG for RNG.State;enum Decision {Select, // Add to the group, and use new seedSkip, // Retry with same seed, skip this leafDelete, // Retry with same seed, delete this leafUpdateRetry, // Retry with same seed, update this leafUpdateSelect // Select and reseed, but also update this leaf}
1234567891011121314151617181920212223242526pragma solidity 0.5.17;import "./Leaf.sol";import "./Interval.sol";import "./DynamicArray.sol";library RNG {using DynamicArray for DynamicArray.UintArray;////////////////////////////////////////////////////////////////////////////// Parameters for configuration// How many bits a position uses per level of the tree;// each branch of the tree contains 2**SLOT_BITS slots.uint256 constant SLOT_BITS = 3;////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Derived constants, do not touchuint256 constant SLOT_COUNT = 2**SLOT_BITS;uint256 constant WEIGHT_WIDTH = 256 / SLOT_COUNT;////////////////////////////////////////////////////////////////////////////struct State {// RNG outputuint256 currentMappedIndex;uint256 currentTruncatedIndex;
1234567891011121314151617181920212223242526pragma solidity 0.5.17;library DynamicArray {// The in-memory dynamic Array is implemented// by recording the amount of allocated memory// separately from the length of the array.// This gives us a perfectly normal in-memory array// with all the behavior we're used to,// but also makes O(1) `push` operations possible// by expanding into the preallocated memory.//// When we run out of preallocated memory when trying to `push`,// we allocate twice as much and copy the array over.// With linear allocation costs this would amortize to O(1)// but with EVM allocations being actually quadratic// the real performance is a very technical O(N).// Nonetheless, this is reasonably performant in practice.//// A dynamic array can be useful// even when you aren't dealing with an unknown number of items.// Because the array tracks the allocated space// separately from the number of stored items,// you can push items into the dynamic array// and iterate over the currently present items// without tracking their number yourself,// or using a special null value for empty elements.
123456789101112131415161718192021pragma solidity 0.5.17;contract GasStation {mapping(address => mapping(uint256 => uint256)) gasDeposits;function depositGas(address addr) internal {setDeposit(addr, 1);}function releaseGas(address addr) internal {setDeposit(addr, 0);}function setDeposit(address addr, uint256 val) internal {for (uint256 i = 0; i < gasDepositSize(); i++) {gasDeposits[addr][i] = val;}}function gasDepositSize() internal pure returns (uint256);}
1234567891011121314151617181920212223242526pragma solidity 0.5.17;import "./StackLib.sol";import "./Branch.sol";import "./Position.sol";import "./Leaf.sol";contract SortitionTree {using StackLib for uint256[];using Branch for uint256;using Position for uint256;using Leaf for uint256;////////////////////////////////////////////////////////////////////////////// Parameters for configuration// How many bits a position uses per level of the tree;// each branch of the tree contains 2**SLOT_BITS slots.uint256 constant SLOT_BITS = 3;uint256 constant LEVELS = 7;////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Derived constants, do not touchuint256 constant SLOT_COUNT = 2**SLOT_BITS;uint256 constant SLOT_WIDTH = 256 / SLOT_COUNT;
1234567891011121314151617181920212223pragma solidity 0.5.17;library StackLib {function stackPeek(uint256[] storage _array) internal view returns (uint256) {require(_array.length > 0, "No value to peek, array is empty");return (_array[_array.length - 1]);}function stackPush(uint256[] storage _array, uint256 _element) public {_array.push(_element);}function stackPop(uint256[] storage _array) internal returns (uint256) {require(_array.length > 0, "No value to pop, array is empty");uint256 value = _array[_array.length - 1];_array.length -= 1;return value;}function getSize(uint256[] storage _array) internal view returns (uint256) {return _array.length;}}
1234567891011121314151617181920212223242526pragma solidity 0.5.17;/// @notice The implicit 8-ary trees of the sortition pool/// rely on packing 8 "slots" of 32-bit values into each uint256./// The Branch library permits efficient calculations on these slots.library Branch {////////////////////////////////////////////////////////////////////////////// Parameters for configuration// How many bits a position uses per level of the tree;// each branch of the tree contains 2**SLOT_BITS slots.uint256 constant SLOT_BITS = 3;////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Derived constants, do not touchuint256 constant SLOT_COUNT = 2**SLOT_BITS;uint256 constant SLOT_WIDTH = 256 / SLOT_COUNT;uint256 constant LAST_SLOT = SLOT_COUNT - 1;uint256 constant SLOT_MAX = (2**SLOT_WIDTH) - 1;/////////////////////////////////////////////////////////////////////////////// @notice Calculate the right shift required/// to make the 32 least significant bits of an uint256/// be the bits of the `position`th slot
1234567891011121314151617181920212223242526pragma solidity 0.5.17;library Position {////////////////////////////////////////////////////////////////////////////// Parameters for configuration// How many bits a position uses per level of the tree;// each branch of the tree contains 2**SLOT_BITS slots.uint256 constant SLOT_BITS = 3;////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Derived constants, do not touchuint256 constant SLOT_POINTER_MAX = (2**SLOT_BITS) - 1;uint256 constant LEAF_FLAG = 1 << 255;////////////////////////////////////////////////////////////////////////////// Return the last 3 bits of a position number,// corresponding to its slot in its parentfunction slot(uint256 a) internal pure returns (uint256) {return a & SLOT_POINTER_MAX;}// Return the parent of a position numberfunction parent(uint256 a) internal pure returns (uint256) {
1234567891011121314151617181920212223242526pragma solidity 0.5.17;library Leaf {////////////////////////////////////////////////////////////////////////////// Parameters for configuration// How many bits a position uses per level of the tree;// each branch of the tree contains 2**SLOT_BITS slots.uint256 constant SLOT_BITS = 3;////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Derived constants, do not touchuint256 constant SLOT_COUNT = 2**SLOT_BITS;uint256 constant SLOT_WIDTH = 256 / SLOT_COUNT;uint256 constant SLOT_MAX = (2**SLOT_WIDTH) - 1;uint256 constant WEIGHT_WIDTH = SLOT_WIDTH;uint256 constant WEIGHT_MAX = SLOT_MAX;uint256 constant BLOCKHEIGHT_WIDTH = 96 - WEIGHT_WIDTH;uint256 constant BLOCKHEIGHT_MAX = (2**BLOCKHEIGHT_WIDTH) - 1;////////////////////////////////////////////////////////////////////////////function make(
1234567891011121314151617181920212223242526pragma solidity 0.5.17;import "./Leaf.sol";import "./DynamicArray.sol";library Interval {using DynamicArray for DynamicArray.UintArray;////////////////////////////////////////////////////////////////////////////// Parameters for configuration// How many bits a position uses per level of the tree;// each branch of the tree contains 2**SLOT_BITS slots.uint256 constant SLOT_BITS = 3;////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Derived constants, do not touchuint256 constant SLOT_COUNT = 2**SLOT_BITS;uint256 constant SLOT_WIDTH = 256 / SLOT_COUNT;uint256 constant SLOT_MAX = (2**SLOT_WIDTH) - 1;uint256 constant WEIGHT_WIDTH = SLOT_WIDTH;uint256 constant WEIGHT_MAX = SLOT_MAX;uint256 constant START_INDEX_WIDTH = WEIGHT_WIDTH;uint256 constant START_INDEX_MAX = WEIGHT_MAX;
1234567891011121314151617181920212223242526pragma solidity 0.5.17;/// @title KeepRegistry/// @notice Governance owned registry of approved contracts and roles.contract KeepRegistry {enum ContractStatus {New, Approved, Disabled}// Governance role is to enable recovery from key compromise by rekeying// other roles. Also, it can disable operator contract panic buttons// permanently.address public governance;// Registry Keeper maintains approved operator contracts. Each operator// contract must be approved before it can be authorized by a staker or// used by a service contract.address public registryKeeper;// Each operator contract has a Panic Button which can disable malicious// or malfunctioning contract that have been previously approved by the// Registry Keeper.//// New operator contract added to the registry has a default panic button// value assigned (defaultPanicButton). Panic button for each operator// contract can be later updated by Governance to individual value.//
1234567891011121314151617181920212223242526/**▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓Trust math, not hardware.*/pragma solidity 0.5.17;import "openzeppelin-solidity/contracts/token/ERC20/ERC20Burnable.sol";import "openzeppelin-solidity/contracts/token/ERC20/SafeERC20.sol";import "openzeppelin-solidity/contracts/math/SafeMath.sol";import "./StakeDelegatable.sol";import "./libraries/staking/MinimumStakeSchedule.sol";import "./libraries/staking/GrantStaking.sol";import "./libraries/staking/Locks.sol";import "./libraries/staking/TopUps.sol";import "./utils/PercentUtils.sol";import "./utils/BytesLib.sol";
1234567891011121314151617181920212223242526/**▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓Trust math, not hardware.*/pragma solidity 0.5.17;import "./KeepRegistry.sol";/// @title AuthorityDelegator/// @notice An operator contract can delegate authority to other operator/// contracts by implementing the AuthorityDelegator interface.////// To delegate authority,/// the recipient of delegated authority must call `claimDelegatedAuthority`,/// specifying the contract it wants delegated authority from./// The staking contract calls `delegator.__isRecognized(recipient)`
12345678910111213141516171819202122232425pragma solidity 0.5.17;import "openzeppelin-solidity/contracts/math/SafeMath.sol";library UnlockingSchedule {using SafeMath for uint256;function getUnlockedAmount(uint256 _now,uint256 grantedAmount,uint256 duration,uint256 start,uint256 cliff) internal pure returns (uint256) {bool cliffNotReached = _now < cliff;if (cliffNotReached) { return 0; }uint256 timeElapsed = _now.sub(start);bool unlockingPeriodFinished = timeElapsed >= duration;if (unlockingPeriodFinished) { return grantedAmount; }return grantedAmount.mul(timeElapsed).div(duration);}}
1234567891011121314151617181920212223242526pragma solidity 0.5.17;library AddressArrayUtils {function contains(address[] memory self, address _address)internalpurereturns (bool){for (uint i = 0; i < self.length; i++) {if (_address == self[i]) {return true;}}return false;}function removeAddress(address[] storage self, address _addressToRemove)internalreturns (address[] storage){for (uint i = 0; i < self.length; i++) {// If address is found in array.if (_addressToRemove == self[i]) {// Delete element at index and shift array.
1234567891011121314151617181920212223242526pragma solidity 0.5.17;import "openzeppelin-solidity/contracts/token/ERC20/ERC20Burnable.sol";import "openzeppelin-solidity/contracts/token/ERC20/SafeERC20.sol";import "openzeppelin-solidity/contracts/math/SafeMath.sol";import "./TokenStaking.sol";import "./TokenSender.sol";import "./utils/BytesLib.sol";/// @dev Interface of sender contract for approveAndCall pattern.interface tokenSender {function approveAndCall(address _spender, uint256 _value, bytes calldata _extraData) external;}contract TokenGrantStake {using SafeMath for uint256;using BytesLib for bytes;ERC20Burnable token;TokenStaking tokenStaking;address tokenGrant; // Address of the master grant contract.uint256 grantId; // ID of the grant for this stake.uint256 amount; // Amount of staked tokens.address operator; // Operator of the stake.
1234567891011121314pragma solidity 0.5.17;/// @title GrantStakingPolicy/// @notice A staking policy defines the function `getStakeableAmount`/// which calculates how many tokens may be staked from a token grant.contract GrantStakingPolicy {function getStakeableAmount(uint256 _now,uint256 grantedAmount,uint256 duration,uint256 start,uint256 cliff,uint256 withdrawn) public view returns (uint256);}
1234567891011121314151617181920212223242526/**▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓Trust math, not hardware.*/pragma solidity 0.5.17;import "openzeppelin-solidity/contracts/ownership/Ownable.sol";import "openzeppelin-solidity/contracts/token/ERC20/SafeERC20.sol";import "openzeppelin-solidity/contracts/math/SafeMath.sol";import "./libraries/grant/UnlockingSchedule.sol";import "./utils/BytesLib.sol";import "./KeepToken.sol";import "./utils/BytesLib.sol";import "./TokenGrant.sol";import "./ManagedGrant.sol";
123456pragma solidity 0.5.17;/// @dev Interface of sender contract for approveAndCall pattern.interface TokenSender {function approveAndCall(address _spender, uint256 _value, bytes calldata _extraData) external;}
1234567891011121314151617181920212223242526pragma solidity 0.5.17;import "openzeppelin-solidity/contracts/token/ERC20/ERC20Burnable.sol";import "openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol";/// @dev Interface of recipient contract for approveAndCall pattern.interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes calldata _extraData) external; }/// @title KEEP Token/// @dev Standard ERC20Burnable tokencontract KeepToken is ERC20Burnable, ERC20Detailed {string public constant NAME = "KEEP Token";string public constant SYMBOL = "KEEP";uint8 public constant DECIMALS = 18; // The number of digits after the decimal place when displaying token values on-screen.uint256 public constant INITIAL_SUPPLY = 10**27; // 1 billion tokens, 18 decimal places./// @dev Gives msg.sender all of existing tokens.constructor() public ERC20Detailed(NAME, SYMBOL, DECIMALS) {_mint(msg.sender, INITIAL_SUPPLY);}/// @notice Set allowance for other address and notify./// Allows `_spender` to spend no more than `_value` tokens/// on your behalf and then ping the contract about it./// @param _spender The address authorized to spend.
1234567891011121314151617181920212223242526pragma solidity ^0.5.4;import "openzeppelin-solidity/contracts/token/ERC20/ERC20Burnable.sol";import "openzeppelin-solidity/contracts/token/ERC20/SafeERC20.sol";import "./TokenGrant.sol";/// @title ManagedGrant/// @notice A managed grant acts as the grantee towards the token grant contract,/// proxying instructions from the actual grantee./// The address used by the actual grantee/// to issue instructions and withdraw tokens/// can be reassigned with the consent of the grant manager.contract ManagedGrant {using SafeERC20 for ERC20Burnable;ERC20Burnable public token;TokenGrant public tokenGrant;address public grantManager;uint256 public grantId;address public grantee;address public requestedNewGrantee;event GranteeReassignmentRequested(address newGrantee);event GranteeReassignmentConfirmed(
1234567891011121314151617181920212223242526pragma solidity 0.5.17;import "../utils/AddressArrayUtils.sol";import "../StakeDelegatable.sol";import "../TokenGrant.sol";import "../ManagedGrant.sol";/// @title Roles Lookup/// @notice Library facilitating lookup of roles in stake delegation setup.library RolesLookup {using AddressArrayUtils for address[];/// @notice Returns true if the tokenOwner delegated tokens to operator/// using the provided stakeDelegatable contract. Othwerwise, returns false./// This function works only for the case when tokenOwner own those tokens/// and those are not tokens from a grant.function isTokenOwnerForOperator(address tokenOwner,address operator,StakeDelegatable stakeDelegatable) internal view returns (bool) {return stakeDelegatable.ownerOf(operator) == tokenOwner;}/// @notice Returns true if the grantee delegated tokens to operator/// with the provided tokenGrant contract. Otherwise, returns false.
1234567891011121314151617181920212223242526pragma solidity 0.5.17;library LockUtils {struct Lock {address creator;uint96 expiresAt;}/// @notice The LockSet is like an array of unique `uint256`s,/// but additionally supports O(1) membership tests and removals./// @dev Because the LockSet relies on a mapping,/// it can only be used in storage, not in memory.struct LockSet {// locks[positions[lock.creator] - 1] = lockLock[] locks;mapping(address => uint256) positions;}/// @notice Check whether the LockSet `self` contains a lock by `creator`function contains(LockSet storage self, address creator)internal view returns (bool) {return (self.positions[creator] != 0);}function getLockTime(LockSet storage self, address creator)internal view returns (uint96) {
1234567891011121314151617181920212223242526/**▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓Trust math, not hardware.*/pragma solidity 0.5.17;import "./utils/OperatorParams.sol";/// @title Stake Delegatable/// @notice A base contract to allow stake delegation for staking contracts.contract StakeDelegatable {using OperatorParams for uint256;mapping(address => Operator) internal operators;struct Operator {
1234567891011121314151617181920212223242526pragma solidity 0.5.17;library OperatorParams {// OperatorParams packs values that are commonly used together// into a single uint256 to reduce the cost functions// like querying eligibility.//// An OperatorParams uint256 contains:// - the operator's staked token amount (uint128)// - the operator's creation timestamp (uint64)// - the operator's undelegation timestamp (uint64)//// These are packed as [amount | createdAt | undelegatedAt]//// Staked KEEP is stored in an uint128,// which is sufficient because KEEP tokens have 18 decimals (2^60)// and there will be at most 10^9 KEEP in existence (2^30).//// Creation and undelegation times are stored in an uint64 each.// Thus uint64s would be sufficient for around 3*10^11 years.uint256 constant TIMESTAMP_WIDTH = 64;uint256 constant AMOUNT_WIDTH = 128;uint256 constant TIMESTAMP_MAX = (2**TIMESTAMP_WIDTH) - 1;uint256 constant AMOUNT_MAX = (2**AMOUNT_WIDTH) - 1;
1234567891011121314151617181920212223242526pragma solidity 0.5.17;import "openzeppelin-solidity/contracts/math/SafeMath.sol";/// @notice MinimumStakeSchedule defines the minimum stake parametrization and/// schedule. It starts with a minimum stake of 100k KEEP. Over the following/// 2 years, the minimum stake is lowered periodically using a uniform stepwise/// function, eventually ending at 10k.library MinimumStakeSchedule {using SafeMath for uint256;// 2 years in seconds (seconds per day * days in a year * years)uint256 public constant schedule = 86400 * 365 * 2;uint256 public constant steps = 10;uint256 public constant base = 10000 * 1e18;/// @notice Returns the current value of the minimum stake. The minimum/// stake is lowered periodically over the course of 2 years since the time/// of the shedule start and eventually ends at 10k KEEP.function current(uint256 scheduleStart) internal view returns (uint256) {if (now < scheduleStart.add(schedule)) {uint256 currentStep = steps.mul(now.sub(scheduleStart)).div(schedule);return base.mul(steps.sub(currentStep));}return base;}
1234567891011121314151617181920212223242526pragma solidity 0.5.17;import "../../TokenGrant.sol";import "../../TokenStakingEscrow.sol";import "../..//utils/BytesLib.sol";import "../RolesLookup.sol";/// @notice TokenStaking contract library allowing to capture the details of/// delegated grants and offering functions allowing to check grantee/// authentication for stake delegation management.library GrantStaking {using BytesLib for bytes;using RolesLookup for address payable;/// @dev Grant ID is flagged with the most significant bit set, to/// distinguish the grant ID `0` from default (null) value. The flag is/// toggled with bitwise XOR (`^`) which keeps all other bits intact but/// flips the flag bit. The flag should be set before writing to/// `operatorToGrant`, and unset after reading from `operatorToGrant`/// before using the value.uint256 constant GRANT_ID_FLAG = 1 << 255;struct Storage {/// @dev Do not read or write this mapping directly; please use/// `hasGrantDelegated`, `setGrantForOperator`, and `getGrantForOperator`/// instead.
1234567891011121314151617181920212223242526pragma solidity 0.5.17;import "openzeppelin-solidity/contracts/token/ERC20/ERC20Burnable.sol";import "openzeppelin-solidity/contracts/token/ERC20/SafeERC20.sol";import "openzeppelin-solidity/contracts/math/SafeMath.sol";import "./libraries/grant/UnlockingSchedule.sol";import "./utils/BytesLib.sol";import "./utils/AddressArrayUtils.sol";import "./TokenStaking.sol";import "./TokenGrantStake.sol";import "./GrantStakingPolicy.sol";/// @title TokenGrant/// @notice A token grant contract for a specified standard ERC20Burnable token./// Has additional functionality to stake delegate/undelegate token grants./// Tokens are granted to the grantee via unlocking scheme and can be/// withdrawn gradually based on the unlocking schedule cliff and unlocking duration./// Optionally grant can be revoked by the token grant manager.contract TokenGrant {using SafeMath for uint256;using UnlockingSchedule for uint256;using SafeERC20 for ERC20Burnable;using BytesLib for bytes;using AddressArrayUtils for address[];
1234567891011121314151617181920212223242526pragma solidity 0.5.17;import "openzeppelin-solidity/contracts/math/SafeMath.sol";import { AuthorityVerifier } from "../../Authorizations.sol";import "./LockUtils.sol";library Locks {using SafeMath for uint256;using LockUtils for LockUtils.LockSet;event StakeLocked(address indexed operator, address lockCreator, uint256 until);event LockReleased(address indexed operator, address lockCreator);event ExpiredLockReleased(address indexed operator, address lockCreator);uint256 public constant maximumLockDuration = 86400 * 200; // 200 days in secondsstruct Storage {// Locks placed on the operator.// `operatorLocks[operator]` returns all locks placed on the operator.// Each authorized operator contract can place one lock on an operator.mapping(address => LockUtils.LockSet) operatorLocks;}function lockStake(Storage storage self,address operator,
1234567891011121314151617181920212223242526pragma solidity 0.5.17;import "openzeppelin-solidity/contracts/math/SafeMath.sol";import "../../TokenStakingEscrow.sol";import "../../utils/OperatorParams.sol";/// @notice TokenStaking contract library allowing to perform two-step stake/// top-ups for existing delegations./// Top-up is a two-step process: it is initiated with a declared top-up value/// and after waiting for at least the initialization period it can be/// committed.library TopUps {using SafeMath for uint256;using OperatorParams for uint256;event TopUpInitiated(address indexed operator, uint256 topUp);event TopUpCompleted(address indexed operator, uint256 newAmount);struct TopUp {uint256 amount;uint256 createdAt;}struct Storage {
1234567891011121314151617181920pragma solidity 0.5.17;import "openzeppelin-solidity/contracts/math/SafeMath.sol";library PercentUtils {using SafeMath for uint256;// Return `b`% of `a`// 200.percent(40) == 80// Commutative, works both waysfunction percent(uint256 a, uint256 b) internal pure returns (uint256) {return a.mul(b).div(100);}// Return `a` as percentage of `b`:// 80.asPercentOf(200) == 40function asPercentOf(uint256 a, uint256 b) internal pure returns (uint256) {return a.mul(100).div(b);}}
1234567891011121314151617181920212223242526pragma solidity 0.5.17;/*Verison pulled from https://github.com/summa-tx/bitcoin-spv/blob/2535e4edaeaac4b2b095903fce684ae1c05761bc/solidity/contracts/BytesLib.sol*//*https://github.com/GNSPS/solidity-bytes-utils/This is free and unencumbered software released into the public domain.Anyone is free to copy, modify, publish, use, compile, sell, ordistribute this software, either in source code form or as a compiledbinary, for any purpose, commercial or non-commercial, and by anymeans.In jurisdictions that recognize copyright laws, the author or authorsof this software dedicate any and all copyright interest in thesoftware to the public domain. We make this dedication for the benefitof the public at large and to the detriment of our heirs andsuccessors. We intend this dedication to be an overt act ofrelinquishment in perpetuity of all present and future rights to thissoftware under copyright law.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OFMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OROTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
1234567891011121314151617181920212223242526pragma solidity ^0.5.0;import "./ERC20.sol";/*** @dev Extension of `ERC20` that allows token holders to destroy both their own* tokens and those that they have an allowance for, in a way that can be* recognized off-chain (via event analysis).*/contract ERC20Burnable is ERC20 {/*** @dev Destoys `amount` tokens from the caller.** See `ERC20._burn`.*/function burn(uint256 amount) public {_burn(msg.sender, amount);}/*** @dev See `ERC20._burnFrom`.*/function burnFrom(address account, uint256 amount) public {_burnFrom(account, amount);}}
1234567891011121314151617181920212223242526pragma solidity ^0.5.0;import "./IERC20.sol";import "../../math/SafeMath.sol";/*** @dev Implementation of the `IERC20` interface.** This implementation is agnostic to the way tokens are created. This means* that a supply mechanism has to be added in a derived contract using `_mint`.* For a generic mechanism see `ERC20Mintable`.** *For a detailed writeup see our guide [How to implement supply* mechanisms](https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226).*** We have followed general OpenZeppelin guidelines: functions revert instead* of returning `false` on failure. This behavior is nonetheless conventional* and does not conflict with the expectations of ERC20 applications.** Additionally, an `Approval` event is emitted on calls to `transferFrom`.* This allows applications to reconstruct the allowance for all accounts just* by listening to said events. Other implementations of the EIP may not emit* these events, as it isn't required by the specification.** Finally, the non-standard `decreaseAllowance` and `increaseAllowance`* functions have been added to mitigate the well-known issues around setting
1234567891011121314151617181920212223242526pragma solidity ^0.5.0;import "./IERC20.sol";/*** @dev Optional functions from the ERC20 standard.*/contract ERC20Detailed is IERC20 {string private _name;string private _symbol;uint8 private _decimals;/*** @dev Sets the values for `name`, `symbol`, and `decimals`. All three of* these values are immutable: they can only be set once during* construction.*/constructor (string memory name, string memory symbol, uint8 decimals) public {_name = name;_symbol = symbol;_decimals = decimals;}/*** @dev Returns the name of the token.*/
1234567891011121314151617181920212223242526pragma solidity ^0.5.0;/*** @dev Interface of the ERC20 standard as defined in the EIP. Does not include* the optional functions; to access them see `ERC20Detailed`.*/interface IERC20 {/*** @dev Returns the amount of tokens in existence.*/function totalSupply() external view returns (uint256);/*** @dev Returns the amount of tokens owned by `account`.*/function balanceOf(address account) external view returns (uint256);/*** @dev Moves `amount` tokens from the caller's account to `recipient`.** Returns a boolean value indicating whether the operation succeeded.** Emits a `Transfer` event.*/function transfer(address recipient, uint256 amount) external returns (bool);
1234567891011121314151617181920212223242526pragma solidity ^0.5.0;import "./IERC20.sol";import "../../math/SafeMath.sol";import "../../utils/Address.sol";/*** @title SafeERC20* @dev Wrappers around ERC20 operations that throw on failure (when the token* contract returns false). Tokens that return no value (and instead revert or* throw on failure) are also supported, non-reverting calls are assumed to be* successful.* To use this library you can add a `using SafeERC20 for ERC20;` 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));}
1234567891011121314151617181920212223242526pragma solidity ^0.5.0;/*** @dev Collection of functions related to the address type,*/library Address {/*** @dev Returns true if `account` is a contract.** This test is non-exhaustive, and there may be false-negatives: during the* execution of a contract's constructor, its address will be reported as* not containing a contract.** > It is unsafe to assume that an address for which this function returns* false is an externally-owned account (EOA) and not a contract.*/function isContract(address account) internal view returns (bool) {// This method relies in extcodesize, which returns 0 for contracts in// construction, since the code is only stored at the end of the// constructor execution.uint256 size;// solhint-disable-next-line no-inline-assemblyassembly { size := extcodesize(account) }return size > 0;}
1234567891011121314151617181920212223242526pragma solidity ^0.5.0;/*** @dev Wrappers over Solidity's arithmetic operations with added overflow* checks.** Arithmetic operations in Solidity wrap on overflow. This can easily result* in bugs, because programmers usually assume that an overflow raises an* error, which is the standard behavior in high level programming languages.* `SafeMath` restores this intuition by reverting the transaction when an* operation overflows.** Using this library instead of the unchecked operations eliminates an entire* class of bugs, so it's recommended to use it always.*/library SafeMath {/*** @dev Returns the addition of two unsigned integers, reverting on* overflow.** Counterpart to Solidity's `+` operator.** Requirements:* - Addition cannot overflow.*/function add(uint256 a, uint256 b) internal pure returns (uint256) {
1234567891011121314151617181920212223242526pragma solidity ^0.5.0;/*** @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.** This module is used through inheritance. It will make available the modifier* `onlyOwner`, which can be aplied to your functions to restrict their use to* the owner.*/contract Ownable {address private _owner;event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);/*** @dev Initializes the contract setting the deployer as the initial owner.*/constructor () internal {_owner = msg.sender;emit OwnershipTransferred(address(0), _owner);}/*** @dev Returns the address of the current owner.
1234567891011121314151617181920212223242526/**▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓Trust math, not hardware.*/pragma solidity 0.5.17;import "./AbstractBonding.sol";import "@keep-network/keep-core/contracts/TokenGrant.sol";import "@keep-network/keep-core/contracts/libraries/RolesLookup.sol";/// @title Keep Bonding/// @notice Contract holding deposits from keeps' operators.contract KeepBonding is AbstractBonding {using RolesLookup for address payable;
1234567891011121314151617181920212223242526/**▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓Trust math, not hardware.*/pragma solidity 0.5.17;import "./api/IBondingManagement.sol";import "@keep-network/keep-core/contracts/KeepRegistry.sol";import "openzeppelin-solidity/contracts/math/SafeMath.sol";/// @title Abstract Bonding/// @notice Contract holding deposits from keeps' operators.contract AbstractBonding is IBondingManagement {using SafeMath for uint256;
123456789101112131415161718{"metadata": {"useLiteralContent": true},"optimizer": {"enabled": true,"runs": 200},"outputSelection": {"*": {"*": ["evm.bytecode","evm.deployedBytecode","abi"]}}}
Contract ABI
API[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"submittingMember","type":"address"},{"indexed":false,"internalType":"bytes","name":"conflictingPublicKey","type":"bytes"}],"name":"ConflictingPublicKeySubmitted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ERC20RewardDistributed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ETHRewardDistributed","type":"event"},{"anonymous":false,"inputs":[],"name":"KeepClosed","type":"event"},{"anonymous":false,"inputs":[],"name":"KeepTerminated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"publicKey","type":"bytes"}],"name":"PublicKeyPublished","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"digest","type":"bytes32"}],"name":"SignatureRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"digest","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"r","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"s","type":"bytes32"},{"indexed":false,"internalType":"uint8","name":"recoveryID","type":"uint8"}],"name":"SignatureSubmitted","type":"event"},{"anonymous":false,"inputs":[],"name":"SlashingFailed","type":"event"},{"constant":true,"inputs":[],"name":"checkBondAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint8","name":"_v","type":"uint8"},{"internalType":"bytes32","name":"_r","type":"bytes32"},{"internalType":"bytes32","name":"_s","type":"bytes32"},{"internalType":"bytes32","name":"_signedDigest","type":"bytes32"},{"internalType":"bytes","name":"_preimage","type":"bytes"}],"name":"checkSignatureFraud","outputs":[{"internalType":"bool","name":"_isFraud","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"closeKeep","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"digest","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"digests","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_tokenAddress","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"distributeERC20Reward","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"distributeETHReward","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_member","type":"address"}],"name":"getMemberETHBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getMembers","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getOpenedTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getPublicKey","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"honestThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address[]","name":"_members","type":"address[]"},{"internalType":"uint256","name":"_honestThreshold","type":"uint256"},{"internalType":"uint256","name":"_memberStake","type":"uint256"},{"internalType":"uint256","name":"_stakeLockDuration","type":"uint256"},{"internalType":"address","name":"_tokenStaking","type":"address"},{"internalType":"address","name":"_keepBonding","type":"address"},{"internalType":"address payable","name":"_keepFactory","type":"address"}],"name":"initialize","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"isActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"_digest","type":"bytes32"}],"name":"isAwaitingSignature","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isClosed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isTerminated","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"memberStake","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"members","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"publicKey","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"returnPartialSignerBonds","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[],"name":"seizeSignerBonds","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"_digest","type":"bytes32"}],"name":"sign","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes","name":"_publicKey","type":"bytes"}],"name":"submitPublicKey","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"_r","type":"bytes32"},{"internalType":"bytes32","name":"_s","type":"bytes32"},{"internalType":"uint8","name":"_recoveryID","type":"uint8"}],"name":"submitSignature","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint8","name":"_v","type":"uint8"},{"internalType":"bytes32","name":"_r","type":"bytes32"},{"internalType":"bytes32","name":"_s","type":"bytes32"},{"internalType":"bytes32","name":"_signedDigest","type":"bytes32"},{"internalType":"bytes","name":"_preimage","type":"bytes"}],"name":"submitSignatureFraud","outputs":[{"internalType":"bool","name":"_isFraud","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_member","type":"address"}],"name":"withdraw","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 31 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.