You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function _afterStake(address delegator, uint96 amount) internal virtual override;
38
+
```
39
+
40
+
### _afterUnstake
41
+
42
+
43
+
```solidity
44
+
function _afterUnstake(address delegator, uint96 amount) internal virtual override;
45
+
```
46
+
47
+
### _afterOperatorSelection
48
+
49
+
50
+
```solidity
51
+
function _afterOperatorSelection(address delegator, address operator) internal virtual override;
52
+
```
53
+
54
+
### _afterOperatorUndelegationAnnouncement
55
+
56
+
57
+
```solidity
58
+
function _afterOperatorUndelegationAnnouncement(address delegator) internal virtual override;
59
+
```
60
+
61
+
### _afterSlash
62
+
63
+
64
+
```solidity
65
+
function _afterSlash(address operator, uint256 remainingPercentage) internal virtual override;
66
+
```
67
+
26
68
### mint
27
69
28
70
Allows an operator to mint a new token to deposit into service contracts
@@ -66,11 +108,31 @@ function transferFrom(address, address, uint256) public pure override;
66
108
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public override;
67
109
```
68
110
69
-
### _isContract
111
+
### _reportOperatorStakeUpdate
112
+
113
+
*reports the new operator stake to the service contract, triggered by a balance change through a delegator action*
114
+
115
+
*if requireSuccess is true, the function will revert if the call to the service contract fails*
116
+
117
+
*if requireSuccess is false, the function will not revert if the call to the service contract fails, this ensures that a delegator cannot be bricked by a malicious operator, they should always be able to undelegate from the operator to withdraw their stake. To ensure an honest undelegation can be processed by the recipient of the call, a minimum amount of gas is enforced.*
118
+
119
+
120
+
```solidity
121
+
function _reportOperatorStakeUpdate(address delegator, bool requireSuccess) internal;
122
+
```
123
+
124
+
### _reportOperatorSlash
125
+
126
+
127
+
```solidity
128
+
function _reportOperatorSlash(address operator, uint256 remainingPercentage) internal;
129
+
```
130
+
131
+
### _isServiceContract
70
132
71
133
72
134
```solidity
73
-
function _isContract(address account) private view returns (bool);
135
+
function _isServiceContract(address account) private view returns (bool);
This interface is used by contracts that operators deposit their ERC-721 tokens into to operate for. It must implement the following functions in order to be notified of changes to operator's and delegator's stake.
8
+
9
+
10
+
## Functions
11
+
### reportOperatorStake
12
+
13
+
This function is called when a delegator's stake changes.
14
+
15
+
16
+
```solidity
17
+
function reportOperatorStake(address operator, uint96 newBalance, address delegator, uint96 newDelegatorStake)
18
+
external;
19
+
```
20
+
**Parameters**
21
+
22
+
|Name|Type|Description|
23
+
|----|----|-----------|
24
+
|`operator`|`address`|The address of the operator.|
25
+
|`newBalance`|`uint96`|The new balance of the operator.|
26
+
|`delegator`|`address`|The address of the delegator.|
27
+
|`newDelegatorStake`|`uint96`|The new stake of the delegator.|
28
+
29
+
30
+
### reportOperatorSlash
31
+
32
+
This function is called when an operator is slashed.
33
+
34
+
35
+
```solidity
36
+
function reportOperatorSlash(address operator, uint256 remainingPercentage) external;
37
+
```
38
+
**Parameters**
39
+
40
+
|Name|Type|Description|
41
+
|----|----|-----------|
42
+
|`operator`|`address`|The address of the operator.|
43
+
|`remainingPercentage`|`uint256`|The remaining percentage of the operator's stake.|
@@ -11,14 +11,41 @@ import {ERC721} from '@openzeppelin/contracts/token/ERC721/ERC721.sol';
11
11
/// @title Notifier - Base contract for the Notifier
12
12
/// @notice This contract allows operators to mint ERC721 tokens to deposit into service contracts they want to operate for. Whenever a delegator modifies their stake or the operator is slashed, the current owner of the token is notified (e.g., service contract). This allows the operator to participate in network upgrades by depositing their token into a new service contract. Additionally, it allows service contracts to implement arbitrary logic on deposits by requiring data to be sent alongside the token, implement their own migration logic, etc. Additionally, the operator can set a URI for their token where they can expose an endpoint to provide more information about themselves.
/// @dev only allow transfers to contracts and the operator
44
71
function safeTransferFrom(addressfrom, addressto, uint256tokenId, bytesmemorydata) publicoverride {
45
-
if (to !=_toAddress(tokenId) &&!_isContract(to)) revertInvalidRecipient();
72
+
if (to !=_toAddress(tokenId) &&!_isServiceContract(to)) revertInvalidRecipient();
46
73
super.safeTransferFrom(from, to, tokenId, data);
47
74
}
48
75
49
-
function _isContract(addressaccount) privateviewreturns (bool) {
76
+
/// @dev reports the new operator stake to the service contract, triggered by a balance change through a delegator action
77
+
/// @dev if requireSuccess is true, the function will revert if the call to the service contract fails
78
+
/// @dev if requireSuccess is false, the function will not revert if the call to the service contract fails, this ensures that a delegator cannot be bricked by a malicious operator, they should always be able to undelegate from the operator to withdraw their stake. To ensure an honest undelegation can be processed by the recipient of the call, a minimum amount of gas is enforced.
79
+
function _reportOperatorStakeUpdate(addressdelegator, boolrequireSuccess) internal {
80
+
address operator =delegates(delegator);
81
+
if (operator ==address(0)) return;
82
+
// this reverts if the operator token is not minted
/// @notice This interface is used by contracts that operators deposit their ERC-721 tokens into to operate for. It must implement the following functions in order to be notified of changes to operator's and delegator's stake.
8
+
interfaceIServiceisIERC165 {
9
+
/// @notice This function is called when a delegator's stake changes.
10
+
/// @param operator The address of the operator.
11
+
/// @param newBalance The new balance of the operator.
12
+
/// @param delegator The address of the delegator.
13
+
/// @param newDelegatorStake The new stake of the delegator.
14
+
function reportOperatorStake(addressoperator, uint96newBalance, addressdelegator, uint96newDelegatorStake)
15
+
external;
16
+
17
+
/// @notice This function is called when an operator is slashed.
18
+
/// @param operator The address of the operator.
19
+
/// @param remainingPercentage The remaining percentage of the operator's stake.
20
+
function reportOperatorSlash(addressoperator, uint256remainingPercentage) external;
0 commit comments