Skip to content

Commit 0c74099

Browse files
authored
Merge pull request #157 from threshold-network/app-interfaces
Adding interface for applications that use operator role and delay in…
2 parents d808b0c + 9b61552 commit 0c74099

File tree

2 files changed

+111
-0
lines changed

2 files changed

+111
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// SPDX-License-Identifier: GPL-3.0-or-later
2+
3+
// ██████████████ ▐████▌ ██████████████
4+
// ██████████████ ▐████▌ ██████████████
5+
// ▐████▌ ▐████▌
6+
// ▐████▌ ▐████▌
7+
// ██████████████ ▐████▌ ██████████████
8+
// ██████████████ ▐████▌ ██████████████
9+
// ▐████▌ ▐████▌
10+
// ▐████▌ ▐████▌
11+
// ▐████▌ ▐████▌
12+
// ▐████▌ ▐████▌
13+
// ▐████▌ ▐████▌
14+
// ▐████▌ ▐████▌
15+
16+
pragma solidity ^0.8.9;
17+
18+
import "./IApplication.sol";
19+
20+
/// @title Interface for Threshold Network applications with delay after decrease request
21+
interface IApplicationWithDecreaseDelay is IApplication {
22+
/// @notice Returns authorization-related parameters of the application.
23+
/// @dev The minimum authorization is also returned by `minimumAuthorization()`
24+
/// function, as a requirement of `IApplication` interface.
25+
/// @return _minimumAuthorization The minimum authorization amount required
26+
/// so that operator can participate in the application.
27+
/// @return authorizationDecreaseDelay Delay in seconds that needs to pass
28+
/// between the time authorization decrease is requested and the
29+
/// time that request gets approved. Protects against participants
30+
/// earning rewards and not being active in the network.
31+
/// @return authorizationDecreaseChangePeriod Authorization decrease change
32+
/// period in seconds. It is the time window, before authorization decrease
33+
/// delay ends, during which the pending authorization decrease
34+
/// request can be overwritten.
35+
/// If set to 0, pending authorization decrease request can not be
36+
/// overwritten until the entire `authorizationDecreaseDelay` ends.
37+
/// If set to a value equal to `authorizationDecreaseDelay`, request can
38+
/// always be overwritten.
39+
function authorizationParameters()
40+
external
41+
view
42+
returns (
43+
uint96 _minimumAuthorization,
44+
uint64 authorizationDecreaseDelay,
45+
uint64 authorizationDecreaseChangePeriod
46+
);
47+
48+
/// @notice Returns the amount of stake that is pending authorization
49+
/// decrease for the given staking provider. If no authorization
50+
/// decrease has been requested, returns zero.
51+
function pendingAuthorizationDecrease(address _stakingProvider)
52+
external
53+
view
54+
returns (uint96);
55+
56+
/// @notice Returns the remaining time in seconds that needs to pass before
57+
/// the requested authorization decrease can be approved.
58+
function remainingAuthorizationDecreaseDelay(address stakingProvider)
59+
external
60+
view
61+
returns (uint64);
62+
63+
/// @notice Approves the previously registered authorization decrease
64+
/// request. Reverts if authorization decrease delay has not passed
65+
/// yet or if the authorization decrease was not requested for the
66+
/// given staking provider.
67+
function approveAuthorizationDecrease(address stakingProvider) external;
68+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// SPDX-License-Identifier: GPL-3.0-or-later
2+
3+
// ██████████████ ▐████▌ ██████████████
4+
// ██████████████ ▐████▌ ██████████████
5+
// ▐████▌ ▐████▌
6+
// ▐████▌ ▐████▌
7+
// ██████████████ ▐████▌ ██████████████
8+
// ██████████████ ▐████▌ ██████████████
9+
// ▐████▌ ▐████▌
10+
// ▐████▌ ▐████▌
11+
// ▐████▌ ▐████▌
12+
// ▐████▌ ▐████▌
13+
// ▐████▌ ▐████▌
14+
// ▐████▌ ▐████▌
15+
16+
pragma solidity ^0.8.9;
17+
18+
import "./IApplication.sol";
19+
20+
/// @title Interface for Threshold Network applications with operator role
21+
interface IApplicationWithOperator is IApplication {
22+
/// @notice Returns operator registered for the given staking provider.
23+
function stakingProviderToOperator(address stakingProvider)
24+
external
25+
view
26+
returns (address);
27+
28+
/// @notice Returns staking provider of the given operator.
29+
function operatorToStakingProvider(address operator)
30+
external
31+
view
32+
returns (address);
33+
34+
/// @notice Used by staking provider to set operator address that will
35+
/// operate a node. The operator address must be unique.
36+
/// Reverts if the operator is already set for the staking provider
37+
/// or if the operator address is already in use.
38+
/// @dev Depending on application the given staking provider can set operator
39+
/// address only once or multiple times. Besides that, application can decide
40+
/// if function reverts if there is a pending authorization decrease for
41+
/// the staking provider.
42+
function registerOperator(address operator) external;
43+
}

0 commit comments

Comments
 (0)