Skip to content
This repository was archived by the owner on May 22, 2023. It is now read-only.

Commit ec90c1d

Browse files
committed
ETH staking contract
The contract is used to delegate stake in ETH to the specific operator with authorizer and beneficiary.
1 parent 100053c commit ec90c1d

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

solidity/contracts/ETHStaking.sol

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/**
2+
▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄
3+
▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
4+
▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓
5+
▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓
6+
▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
7+
▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀
8+
▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌
9+
▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓
10+
▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓
11+
12+
Trust math, not hardware.
13+
*/
14+
15+
pragma solidity 0.5.17;
16+
17+
import "@keep-network/keep-core/contracts/KeepRegistry.sol";
18+
import "@keep-network/keep-core/contracts/Authorizations.sol";
19+
import "@keep-network/keep-core/contracts/StakeDelegatable.sol";
20+
21+
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
22+
23+
/// @title ETH Staking
24+
/// @notice A staking contract for ETH staking. An owner of the ETH can delegate
25+
/// ETH as a stake to an operator. The value of ETH the owner is willing to stake
26+
/// should be deposited in `ETHBonding` contract for the given operator.
27+
contract ETHStaking is Authorizations, StakeDelegatable {
28+
constructor(KeepRegistry keepRegistry)
29+
public
30+
Authorizations(keepRegistry)
31+
{}
32+
33+
event Staked(
34+
address owner,
35+
address indexed operator,
36+
address indexed beneficiary,
37+
address indexed authorizer
38+
);
39+
40+
/// @notice Registers stake details. The function is used to register
41+
/// addresses of operator, beneficiary and authorizer for a stake from the
42+
/// caller.
43+
/// @param operator Address of the operator.
44+
/// @param beneficiary Address of the beneficiary.
45+
/// @param authorizer Address of the authorizer.
46+
function stake(
47+
address operator,
48+
address payable beneficiary,
49+
address authorizer
50+
) external payable {
51+
// TODO: Do we need to verify the caller in any way?
52+
address _from = msg.sender;
53+
54+
require(
55+
operators[operator].owner == address(0),
56+
"Operator already in use"
57+
);
58+
59+
operators[operator] = Operator(0, _from, beneficiary, authorizer);
60+
ownerOperators[_from].push(operator);
61+
62+
emit Staked(_from, operator, beneficiary, authorizer);
63+
}
64+
}

0 commit comments

Comments
 (0)