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
Initiates an escrow for a given `operatorSet`, `slashId`, and `strategy`. This function can be called multiple times in the same transaction by the `StrategyManager`, as a single slash can contain multiple strategies. The `operatorSet`, `slashId`, and `strategy` are each stored in an [EnumerableSet](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.9.0/contracts/utils/structs/EnumerableSet.sol).
49
49
50
50
*Effects*:
51
-
* Adds the `operatorSet `to `pendingOperatorSets`
52
-
* Adds the `slashId` to the operatorSet's `pendingSlashIds`
51
+
* If the operatorSet and slashID have not already been set to pending:
52
+
* The `SlashEscrow` contract is [deployed](#deployslashescrow)
53
+
* Adds the `operatorSet `to `pendingOperatorSets`
54
+
* Adds the `slashId` to the operatorSet's `pendingSlashIds`
53
55
* Adds the strategy to `pendingStrategiesForSlashId`
54
56
* Emits a `StartEscrow` event
55
57
56
58
*Requirements*:
57
59
* Can only be called by the `StrategyManager`
58
60
59
-
#### `releaseSlashEscrow`
61
+
#### `deploySlashEscrow`
62
+
63
+
```solidity
64
+
/**
65
+
* @notice Deploys a counterfactual `SlashEscrow` if code hasn't already been deployed.
66
+
* @param operatorSet The operator set whose slash escrow is being deployed.
67
+
* @param slashId The slash ID of the slash escrow that is being deployed.
68
+
*/
69
+
function _deploySlashEscrow(
70
+
OperatorSet calldata operatorSet,
71
+
uint256 slashId)
72
+
internal;
73
+
```
60
74
61
-
## Release Escrow
75
+
The internal function is called on `initiateEscrow`. A unique slash escrow contract is deployed per `operatorSet` and `slashId`
76
+
77
+
SlashEscrows are deployed deterministically using [Open Zeppelin's Clones Upgradeable Library](https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/blob/f6febd79e2a3a17e26969dd0d450c6ebd64bf459/contracts/proxy/ClonesUpgradeable.sol), which is a minimal, non-upgradeable proxy. The deployment salt is a concatenation of the `operatorSet` and `slashId`, which together are guaranteed to be unique.
* @notice Releases an escrow for a single strategy in a slash.
97
+
* @param operatorSet The operator set whose escrow is being released.
98
+
* @param slashId The slash ID of the escrow that is being released.
99
+
* @param strategy The strategy whose escrow is being released.
100
+
* @dev The caller must be the redistribution recipient, unless the redistribution recipient
101
+
* is the default burn address in which case anyone can call.
102
+
* @dev The slash escrow is released once the delay for ALL strategies has elapsed.
103
+
*/
104
+
function releaseSlashEscrowByStrategy(
105
+
OperatorSet calldata operatorSet,
106
+
uint256 slashId,
107
+
IStrategy strategy
108
+
) external;
76
109
```
77
110
At or after the `getEscrowCompleteBlock`, tokens are transferred from the `SlashEscrow` contract to the [`redistributionRecipient`](./AllocationManager.md#createredistributingoperatorsets) of an `operatorSet`.
78
111
79
-
For each `strategy` in the `slash`, tokens are transferred from the slash's unique `SlashEscrow` contract to the `redistributionRecipient`.
112
+
For each `strategy` in the `slash`, tokens are transferred from the slash's unique `SlashEscrow` contract to the `redistributionRecipient`.
113
+
114
+
To accommodate the unlimited number of strategies that can be added to an operatorSet, and a token transfer failures blocking other releases, a user can release a single strategy from escrow via `releaseSlashEscrowByStrategy`.
80
115
81
116
*Effects*:
82
-
* If not deployed, the `SlashEscrow` is [deployed](#deployslashescrow)
83
-
* Call [`StrategyManager.decreaseBurnOrRedistributableShares`](./StrategyManager.md#decreaseburnorredistributableshares). This function may have already been called prior and will no-op if so. We call it again for sanity to ensure that all tokens are transferred to the `SlashEscrow` contract
84
-
* For each strategy, call [`SlashEscrow.releaseTokens`](#releasetokens)
85
-
* For each strategy, emits an `EscrowComplete`
86
-
* Remove the `strategy` from the `_pendingStrategiesForSlashId`
87
-
* Remove the `slashId` from `_pendingSlashIds`
88
-
* Delete the start block for the `slashId`
117
+
* Call [`StrategyManager.clearBurnOrRedistributableShares`](./StrategyManager.md#clearburnorredistributableshares). This function may have already been called prior and will no-op if so. We call it again for sanity to ensure that all tokens are transferred to the `SlashEscrow` contract. For `releaseEscrowByStrategy` we call the by strategy variant: `StrategyManager.clearBurnOrRedistributableSharesByStrategy`
* Remove the `strategy` from the `_pendingStrategiesForSlashId`
122
+
* If all strategies from an operatorSet/slashId have been released:
123
+
* Remove the `slashId` from `_pendingSlashIds`
124
+
* Delete the start block for the `slashId`
89
125
* If the `operatorSet` has no more pending slashes, remove it from `pendingOperatorSets`
90
126
91
127
*Requirements*:
92
-
* Paused status MUST NOT bee set: `PAUSED_RELEASE_ESCROW`
128
+
* The global paused status MUST NOT be set: `PAUSED_RELEASE_ESCROW`
129
+
* The escrow paused status MUST NOT be set: `pauseEscrow`
93
130
* If the operatorSet is redistributable, caller MUST be the `redistributionRecipient`
94
131
* The escrow delay must have elapsed
95
132
96
-
### `deploySlashEscrow`
97
-
98
-
```solidity
99
-
/**
100
-
* @notice Deploys a counterfactual `SlashEscrow` if code hasn't already been deployed.
101
-
* @param operatorSet The operator set whose slash escrow is being deployed.
102
-
* @param slashId The slash ID of the slash escrow that is being deployed.
103
-
* @return The deployed `SlashEscrow`.
104
-
*/
105
-
function deploySlashEscrow(
106
-
OperatorSet calldata operatorSet,
107
-
uint256 slashId)
108
-
external returns (ISlashEscrow);
109
-
```
110
-
111
-
Deploys a unique slash escrow contract per `operatorSet` and `slashId`. Note that this `SlashEscrow` contract is counterfactual because slashed tokens can be transferred to the contract via [StrategyManager.decreaseBurnOrRedistributableShares](./StrategyManager.md#decreaseburnorredistributableshares) prior to the contract being deployed.
112
-
113
-
SlashEscrows are deployed deterministically using [Open Zeppelin's Clones Upgradeable Library](https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/blob/f6febd79e2a3a17e26969dd0d450c6ebd64bf459/contracts/proxy/ClonesUpgradeable.sol), which is a minimal, non-upgradeable proxy. The deployment salt is a concatenation of the `operatorSet` and `slashId`, which together are guaranteed to be unique.
114
-
115
-
116
133
## SlashEscrow
117
134
118
135
A [minimal proxy](https://eips.ethereum.org/EIPS/eip-1167) contract deployed from the `SlashEscrowFactory`. This contract releases funds once an escrow has elapsed.
Copy file name to clipboardExpand all lines: docs/core/StrategyManager.md
+18-18Lines changed: 18 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -248,12 +248,13 @@ This method directs the `strategy` to convert the input deposit shares to tokens
248
248
249
249
---
250
250
251
-
## Burning Or Redistributing Slashed Shares
251
+
## Increasing/Clearing Slashed Shares
252
252
253
253
Slashes shares are marked as burnable or redistributable. Anybody can call
254
-
`burnOrRedistributeShares` to send tokens to the slash's `SlashEscrow` contract. Burn or redistributable shares are stored in `_burnOrRedistributableShares`, a nested [EnumerableMap](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.9.0/contracts/utils/structs/EnumerableMap.sol). The operatorSet and slashId are used to index int o the enumerableMap of strategies to shares. The following methods handle burn or redistribution of slashed shares:
254
+
`clearBurnOrRedistributableShares` to send tokens to the slash's `SlashEscrow` contract. Shares to clear are stored in `_burnOrRedistributableShares`, a nested [EnumerableMap](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.9.0/contracts/utils/structs/EnumerableMap.sol). The operatorSet and slashId are used to index into the enumerableMap of strategies to shares. The following methods handle clearing burn or redistributable shares:
*[`StrategyManager.burnShares`](#burnshares) - Legacy burnShares function
258
259
259
260
#### `increaseBurnOrRedistributableShares`
@@ -291,42 +292,41 @@ Anyone can then convert the shares to tokens and trigger a burn via `burnShares`
291
292
* The `burnOrRedistributableShares` for the given `operatorSet` and `slashId` must not contain the `strategy`
292
293
293
294
294
-
#### `decreaseBurnOrRedistributableSHares`
295
+
#### `clearBurnOrRedistributableShares`
295
296
296
297
```solidity
297
298
/**
298
299
* @notice Removes burned shares from storage and transfers the underlying tokens for the slashId to the slash escrow.
299
300
* @param operatorSet The operator set to burn shares in.
300
301
* @param slashId The slash ID to burn shares in.
301
-
* @return the amounts of tokens transferred to the slash escrow for each strategy
302
+
* @return The amounts of tokens transferred to the slash escrow for each strategy
302
303
*/
303
-
function decreaseBurnOrRedistributableShares(
304
+
function clearBurnOrRedistributableShares(
304
305
OperatorSet calldata operatorSet,
305
-
uint256 slashId
306
-
) external returns (uint256[] memory);
306
+
uint256 slashId)
307
+
external returns (uint256[] memory);
307
308
308
309
/**
309
310
* @notice Removes a single strategy's shares from storage and transfers the underlying tokens for the slashId to the slash escrow.
310
311
* @param operatorSet The operator set to burn shares in.
311
312
* @param slashId The slash ID to burn shares in.
312
-
* @param index The index of the strategy to burn shares in. Returns the amount of shares that were burned.
313
-
* @return The number of tokens transferred to the slash escrow.
313
+
* @param strategy The strategy to burn shares in.
314
+
* @return The amount of shares that were burned.
314
315
*/
315
-
function decreaseBurnOrRedistributableShares(
316
+
function clearBurnOrRedistributableSharesByStrategy(
316
317
OperatorSet calldata operatorSet,
317
318
uint256 slashId,
318
-
uint256 index
319
+
IStrategy strategy
319
320
) external returns (uint256);
320
321
```
321
322
322
-
Anyone can call this method to transfer slashed shares to the slash's `SlashEscrow` contract. This method sets the `burnOrRedistributableShares` for the given `slashId` and `operatorSet` to 0. To accommodate the unlimited number of strategies that can be added to an operatorSet, users can also pass in an index of a strategy to transfer to the `SlashEscrow` contract.
323
-
324
-
The `strategy` is not called if the strategy had no burnable shares.
323
+
Anyone can call this method to transfer slashed shares to the slash's `SlashEscrow` contract. This method sets the `burnOrRedistributableShares` for the given `slashId` and `operatorSet` to 0. To accommodate the unlimited number of strategies that can be added to an operatorSet, users can also pass in a strategy to clear via `clearBurnOrRedistributableSharesByStrategy`. The strategies that haven not been cleared can be retrieved by calling `getBurnOrRedistributableShares(operatorSet, slashId)`.
325
324
326
325
*Effects*:
327
-
* Resets the strategy's burn or redistributable shares for the operatorSet to 0
328
-
* Calls `withdraw` on the `strategy`, withdrawing shares and sending a corresponding amount of tokens to the slash's `slashEscrow` contract
329
-
* Emits a `BurnOrRedistributableSharesDecreased` event
326
+
* Resets the strategy's burn or redistributable shares for the operatorSet and slashId to 0
327
+
* If the shares to remove are nonzero:
328
+
* Calls `withdraw` on the `strategy`, withdrawing shares and sending a corresponding amount of tokens to the slash's `slashEscrow` contract
0 commit comments