Skip to content

Commit

Permalink
Adding interface for applications that use operator role and delay in…
Browse files Browse the repository at this point in the history
… authorization decrease
  • Loading branch information
vzotova committed Nov 10, 2023
1 parent 38debeb commit 845232a
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 0 deletions.
68 changes: 68 additions & 0 deletions contracts/staking/IApplicationWithDecreaseDelay.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// SPDX-License-Identifier: GPL-3.0-or-later

// ██████████████ ▐████▌ ██████████████
// ██████████████ ▐████▌ ██████████████
// ▐████▌ ▐████▌
// ▐████▌ ▐████▌
// ██████████████ ▐████▌ ██████████████
// ██████████████ ▐████▌ ██████████████
// ▐████▌ ▐████▌
// ▐████▌ ▐████▌
// ▐████▌ ▐████▌
// ▐████▌ ▐████▌
// ▐████▌ ▐████▌
// ▐████▌ ▐████▌

pragma solidity ^0.8.9;

import "./IApplication.sol";

/// @title Interface for Threshold Network applications with delay after decrease request
interface IApplicationWithDecreaseDelay is IApplication {
/// @notice Returns authorization-related parameters of the application.
/// @dev The minimum authorization is also returned by `minimumAuthorization()`
/// function, as a requirement of `IApplication` interface.
/// @return minimumAuthorization The minimum authorization amount required
/// so that operator can participate in the application.
/// @return authorizationDecreaseDelay Delay in seconds that needs to pass
/// between the time authorization decrease is requested and the
/// time that request gets approved. Protects against free-riders
/// earning rewards and not being active in the network.
/// @return authorizationDecreaseChangePeriod Authorization decrease change
/// period in seconds. It is the time, before authorization decrease
/// delay end, during which the pending authorization decrease
/// request can be overwritten.
/// If set to 0, pending authorization decrease request can not be
/// overwritten until the entire `authorizationDecreaseDelay` ends.
/// If set to value equal `authorizationDecreaseDelay`, request can
/// always be overwritten.
function authorizationParameters()
external
view
returns (
uint96 minimumAuthorization,
uint64 authorizationDecreaseDelay,
uint64 authorizationDecreaseChangePeriod
);

/// @notice Returns the amount of stake that is pending authorization
/// decrease for the given staking provider. If no authorization
/// decrease has been requested, returns zero.
function pendingAuthorizationDecrease(address _stakingProvider)
external
view
returns (uint96);

/// @notice Returns the remaining time in seconds that needs to pass before
/// the requested authorization decrease can be approved.
function remainingAuthorizationDecreaseDelay(address stakingProvider)
external
view
returns (uint64);

/// @notice Approves the previously registered authorization decrease
/// request. Reverts if authorization decrease delay has not passed
/// yet or if the authorization decrease was not requested for the
/// given staking provider.
function approveAuthorizationDecrease(address stakingProvider) external;

Check warning on line 67 in contracts/staking/IApplicationWithDecreaseDelay.sol

View workflow job for this annotation

GitHub Actions / code-lint-and-format

Function order is incorrect, external function can not go after external view function (line 58)
}
42 changes: 42 additions & 0 deletions contracts/staking/IApplicationWithOperator.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// SPDX-License-Identifier: GPL-3.0-or-later

// ██████████████ ▐████▌ ██████████████
// ██████████████ ▐████▌ ██████████████
// ▐████▌ ▐████▌
// ▐████▌ ▐████▌
// ██████████████ ▐████▌ ██████████████
// ██████████████ ▐████▌ ██████████████
// ▐████▌ ▐████▌
// ▐████▌ ▐████▌
// ▐████▌ ▐████▌
// ▐████▌ ▐████▌
// ▐████▌ ▐████▌
// ▐████▌ ▐████▌

pragma solidity ^0.8.9;

import "./IApplication.sol";

/// @title Interface for Threshold Network applications with operator role
interface IApplicationWithOperator is IApplication {
/// @notice Returns operator registered for the given staking provider.
function stakingProviderToOperator(address stakingProvider)
external
view
returns (address);

/// @notice Used by staking provider to set operator address that will
/// operate a node. The operator addressmust be unique.
/// Reverts if the operator is already set for the staking provider
/// or if the operator address is already in use.
/// @dev Depending on application the given staking provider can set operator
/// address only one or multiple times. Besides that application can decide
/// if function reverts if there is a pending authorization decrease for
/// the staking provider.
function registerOperator(address operator) external;

Check warning on line 36 in contracts/staking/IApplicationWithOperator.sol

View workflow job for this annotation

GitHub Actions / code-lint-and-format

Function order is incorrect, external function can not go after external view function (line 23)

// TODO consider that?
// /// @notice Used by additional role (owner for example) to set operator address that will
// /// operate a node for the specified staking provider.
// function registerOperator(address stakingProvider, address operator) external;
}

0 comments on commit 845232a

Please sign in to comment.