// SPDX-License-Identifier: CC0-1.0pragmasolidity 0.8.9;import"@openzeppelin/contracts/token/ERC20/IERC20.sol";
/**
* @title Claimable
* @dev Implementation of the claiming utils that can be useful for withdrawing accidentally sent tokens.
*/contractClaimable{
/**
* @dev Withdraws the erc20 tokens or native coins from this contract.
* @param _token address of the claimed token or address(0) for native coins.
* @param _to address of the tokens/coins receiver.
*/function_claimValues(address _token, address _to) internal{
if (_token ==address(0)) {
_claimNativeCoins(_to);
} else {
_claimERC20Tokens(_token, _to);
}
}
/**
* @dev Internal function for withdrawing all native coins from the contract.
* @param _to address of the coins receiver.
*/function_claimNativeCoins(address _to) internal{
uint256 balance =address(this).balance;
payable(_to).transfer(balance);
}
/**
* @dev Internal function for withdrawing all tokens of some particular ERC20 contract from this contract.
* @param _token address of the claimed ERC20 token.
* @param _to address of the tokens receiver.
*/function_claimERC20Tokens(address _token, address _to) internal{
uint256 balance = IERC20(_token).balanceOf(address(this));
IERC20(_token).transfer(_to, balance);
}
}
Contract Source Code
File 2 of 12: Context.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.0;/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/abstractcontractContext{
function_msgSender() internalviewvirtualreturns (address) {
returnmsg.sender;
}
function_msgData() internalviewvirtualreturns (bytescalldata) {
returnmsg.data;
}
}
// SPDX-License-Identifier: CC0-1.0pragmasolidity 0.8.9;import"./EIP1967Admin.sol";
/**
* @title EIP1967Proxy
* @dev Upgradeable proxy pattern implementation according to minimalistic EIP1967.
*/contractEIP1967ProxyisEIP1967Admin{
// EIP 1967// bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)uint256internalconstant EIP1967_IMPLEMENTATION_STORAGE =0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
eventUpgraded(addressindexed implementation);
eventAdminChanged(address previousAdmin, address newAdmin);
functionadmin() publicviewreturns (address) {
return _admin();
}
functionimplementation() publicviewreturns (address res) {
assembly {
res :=sload(EIP1967_IMPLEMENTATION_STORAGE)
}
}
functionsetAdmin(address _admin) externalonlyAdmin{
_setAdmin(_admin);
}
functionupgradeTo(address _implementation) externalonlyAdmin{
_setImplementation(_implementation);
}
/**
* @dev Fallback function allowing to perform a delegatecall to the given implementation.
* This function will return whatever the implementation call returns
*/fallback() externalpayable{
address impl = implementation();
require(impl !=address(0));
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(), impl, 0, calldatasize(), 0, 0)
// Copy the returned data.returndatacopy(0, 0, returndatasize())
switch result
// delegatecall returns 0 on error.case0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
/**
* @dev Internal function for transfer current admin rights to a different account.
* @param _admin address of the new administrator.
*/function_setAdmin(address _admin) internal{
address previousAdmin = admin();
require(_admin !=address(0));
require(previousAdmin != _admin);
assembly {
sstore(EIP1967_ADMIN_STORAGE, _admin)
}
emit AdminChanged(previousAdmin, _admin);
}
/**
* @dev Internal function for setting a new implementation address.
* @param _implementation address of the new implementation contract.
*/function_setImplementation(address _implementation) internal{
require(_implementation !=address(0));
require(implementation() != _implementation);
assembly {
sstore(EIP1967_IMPLEMENTATION_STORAGE, _implementation)
}
emit Upgraded(_implementation);
}
}
Contract Source Code
File 5 of 12: IDepositContract.sol
// SPDX-License-Identifier: CC0-1.0pragmasolidity 0.8.9;interfaceIDepositContract{
/// @notice A processed deposit event.eventDepositEvent(bytes pubkey, bytes withdrawal_credentials, bytes amount, bytes signature, bytes index);
/// @notice Submit a Phase 0 DepositData object./// @param pubkey A BLS12-381 public key./// @param withdrawal_credentials Commitment to a public key for withdrawals./// @param signature A BLS12-381 signature./// @param deposit_data_root The SHA-256 hash of the SSZ-encoded DepositData object./// Used as a protection against malformed input.functiondeposit(bytesmemory pubkey,
bytesmemory withdrawal_credentials,
bytesmemory signature,
bytes32 deposit_data_root,
uint256 stake_amount
) external;
/// @notice Query the current deposit root hash./// @return The deposit root hash.functionget_deposit_root() externalviewreturns (bytes32);
/// @notice Query the current deposit count./// @return The deposit count encoded as a little endian 64-bit number.functionget_deposit_count() externalviewreturns (bytesmemory);
}
Contract Source Code
File 6 of 12: IERC165.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.0;/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/interfaceIERC165{
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/functionsupportsInterface(bytes4 interfaceId) externalviewreturns (bool);
}
Contract Source Code
File 7 of 12: IERC20.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.0;/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/interfaceIERC20{
/**
* @dev Returns the amount of tokens in existence.
*/functiontotalSupply() externalviewreturns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/functionbalanceOf(address account) externalviewreturns (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.
*/functiontransfer(address recipient, uint256 amount) externalreturns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/functionallowance(address owner, address spender) externalviewreturns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/functionapprove(address spender, uint256 amount) externalreturns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/functiontransferFrom(address sender,
address recipient,
uint256 amount
) externalreturns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/eventTransfer(addressindexedfrom, addressindexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/eventApproval(addressindexed owner, addressindexed spender, uint256 value);
}
// SPDX-License-Identifier: MITpragmasolidity ^0.8.0;import"../utils/Context.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/abstractcontractPausableisContext{
/**
* @dev Emitted when the pause is triggered by `account`.
*/eventPaused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/eventUnpaused(address account);
boolprivate _paused;
/**
* @dev Initializes the contract in unpaused state.
*/constructor() {
_paused =false;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/functionpaused() publicviewvirtualreturns (bool) {
return _paused;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/modifierwhenNotPaused() {
require(!paused(), "Pausable: paused");
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/modifierwhenPaused() {
require(paused(), "Pausable: not paused");
_;
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/function_pause() internalvirtualwhenNotPaused{
_paused =true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/function_unpause() internalvirtualwhenPaused{
_paused =false;
emit Unpaused(_msgSender());
}
}