Skip to content

Commit ffba678

Browse files
authored
Merge pull request #7 from vzotova/staking
Token staking contract
2 parents 9991ae1 + c0efaa9 commit ffba678

15 files changed

+8294
-166
lines changed

contracts/governance/Checkpoints.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: MIT
22

3-
pragma solidity ^0.8.0;
3+
pragma solidity 0.8.9;
44

55
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
66
import "@openzeppelin/contracts/utils/math/Math.sol";

contracts/staking/IApplication.sol

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-3.0-or-later
22

3-
pragma solidity 0.8.4;
3+
pragma solidity 0.8.9;
44

55
/// @title Application interface for Threshold Network applications
66
/// @notice Generic interface for an application. Application is an external
@@ -9,25 +9,25 @@ pragma solidity 0.8.4;
99
/// operator are eligible to slash the stake delegated to that operator.
1010
interface IApplication {
1111
/// @notice Used by T staking contract to inform the application that the
12-
/// authorized amount for the given operator increased. The
13-
/// application may do any necessary housekeeping.
14-
function authorizationIncreased(address worker, uint256 amount) external;
12+
/// authorized amount for the given operator increased to the
13+
/// given amount. The application may do any necessary housekeeping.
14+
function authorizationIncreased(address operator, uint96 amount) external;
1515

1616
/// @notice Used by T staking contract to inform the application that the
1717
/// given operator requested to decrease the authorization to the
1818
/// given amount. The application should mark the authorization as
1919
/// pending decrease and respond to the staking contract with
2020
/// `approveAuthorizationDecrease` at its discretion. It may
2121
/// happen right away but it also may happen several months later.
22-
function authorizationDecreaseRequested(address worker, uint256 amount)
22+
function authorizationDecreaseRequested(address operator, uint96 amount)
2323
external;
2424

2525
/// @notice Used by T staking contract to inform the application the
2626
/// authorization has been decreased for the given operator to the
2727
/// given amount involuntarily, as a result of slashing. Lets the
2828
/// application to do any housekeeping neccessary. Called with 250k
2929
/// gas limit and does not revert the transaction if
30-
/// `involuntaryAllocationDecrease` call failed.
31-
function involuntaryAllocationDecrease(address worker, uint256 amount)
30+
/// `involuntaryAuthorizationDecrease` call failed.
31+
function involuntaryAuthorizationDecrease(address operator, uint96 amount)
3232
external;
3333
}
+18-64
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-3.0-or-later
22

3-
pragma solidity 0.8.4;
3+
pragma solidity 0.8.9;
44

55
/// @title IKeepTokenStaking
66
/// @notice Interface for Keep TokenStaking contract
@@ -20,12 +20,12 @@ interface IKeepTokenStaking {
2020
) external;
2121

2222
/// @notice Gets stake delegation info for the given operator.
23-
/// @param _operator Operator address.
23+
/// @param operator Operator address.
2424
/// @return amount The amount of tokens the given operator delegated.
2525
/// @return createdAt The time when the stake has been delegated.
2626
/// @return undelegatedAt The time when undelegation has been requested.
2727
/// If undelegation has not been requested, 0 is returned.
28-
function getDelegationInfo(address _operator)
28+
function getDelegationInfo(address operator)
2929
external
3030
view
3131
returns (
@@ -36,18 +36,18 @@ interface IKeepTokenStaking {
3636

3737
/// @notice Gets the stake owner for the specified operator address.
3838
/// @return Stake owner address.
39-
function ownerOf(address _operator) external view returns (address);
39+
function ownerOf(address operator) external view returns (address);
4040

4141
/// @notice Gets the beneficiary for the specified operator address.
4242
/// @return Beneficiary address.
43-
function beneficiaryOf(address _operator)
43+
function beneficiaryOf(address operator)
4444
external
4545
view
4646
returns (address payable);
4747

4848
/// @notice Gets the authorizer for the specified operator address.
4949
/// @return Authorizer address.
50-
function authorizerOf(address _operator) external view returns (address);
50+
function authorizerOf(address operator) external view returns (address);
5151

5252
/// @notice Gets the eligible stake balance of the specified address.
5353
/// An eligible stake is a stake that passed the initialization period
@@ -57,10 +57,10 @@ interface IKeepTokenStaking {
5757
/// Operator with a minimum required amount of eligible stake can join the
5858
/// network and participate in new work selection.
5959
///
60-
/// @param _operator address of stake operator.
61-
/// @param _operatorContract address of operator contract.
60+
/// @param operator address of stake operator.
61+
/// @param operatorContract address of operator contract.
6262
/// @return balance an uint256 representing the eligible stake balance.
63-
function eligibleStake(address _operator, address _operatorContract)
63+
function eligibleStake(address operator, address operatorContract)
6464
external
6565
view
6666
returns (uint256 balance);
@@ -70,15 +70,15 @@ interface IKeepTokenStaking {
7070
/// @notice Interface for NuCypher StakingEscrow contract
7171
interface INuCypherStakingEscrow {
7272
/// @notice Slash the staker's stake and reward the investigator
73-
/// @param _staker Staker's address
74-
/// @param _penalty Penalty
75-
/// @param _investigator Investigator
76-
/// @param _reward Reward for the investigator
73+
/// @param staker Staker's address
74+
/// @param penalty Penalty
75+
/// @param investigator Investigator
76+
/// @param reward Reward for the investigator
7777
function slashStaker(
78-
address _staker,
79-
uint256 _penalty,
80-
address _investigator,
81-
uint256 _reward
78+
address staker,
79+
uint256 penalty,
80+
address investigator,
81+
uint256 reward
8282
) external;
8383

8484
/// @notice Request merge between NuCypher staking contract and T staking contract.
@@ -88,51 +88,5 @@ interface INuCypherStakingEscrow {
8888
returns (uint256);
8989

9090
/// @notice Get all tokens belonging to the staker
91-
function getAllTokens(address _staker) external view returns (uint256);
92-
}
93-
94-
/// @title IKeepTokenGrant
95-
/// @notice Interface for Keep TokenGrant contract
96-
interface IKeepTokenGrant {
97-
/// @notice Gets grant by ID. Returns only basic grant data.
98-
/// @param _id ID of the token grant.
99-
/// @return amount The amount of tokens the grant provides.
100-
/// @return withdrawn The amount of tokens that have already been withdrawn
101-
/// from the grant.
102-
/// @return staked The amount of tokens that have been staked from the grant.
103-
/// @return revokedAmount The number of tokens revoked from the grantee.
104-
/// @return revokedAt Timestamp at which grant was revoked by the grant manager.
105-
/// @return grantee The grantee of grant.
106-
function getGrant(uint256 _id)
107-
external
108-
view
109-
returns (
110-
uint256 amount,
111-
uint256 withdrawn,
112-
uint256 staked,
113-
uint256 revokedAmount,
114-
uint256 revokedAt,
115-
address grantee
116-
);
117-
118-
/// @notice Gets grant stake details of the given operator.
119-
/// @param operator The operator address.
120-
/// @return grantId ID of the token grant.
121-
/// @return amount The amount of tokens the given operator delegated.
122-
/// @return stakingContract The address of staking contract.
123-
function getGrantStakeDetails(address operator)
124-
external
125-
view
126-
returns (
127-
uint256 grantId,
128-
uint256 amount,
129-
address stakingContract
130-
);
131-
}
132-
133-
/// @title IKeepManagedGrant
134-
/// @notice Interface for Keep ManagedGrant contract
135-
interface IKeepManagedGrant {
136-
/// @notice Returns address of grantee
137-
function grantee() external view returns (address);
91+
function getAllTokens(address staker) external view returns (uint256);
13892
}

0 commit comments

Comments
 (0)