Skip to content

Commit 189c7d2

Browse files
committed
docs: update StrategyManager docs with slashing delta
1 parent 44ece6d commit 189c7d2

File tree

1 file changed

+65
-37
lines changed

1 file changed

+65
-37
lines changed

docs/core/StrategyManager.md

Lines changed: 65 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,11 @@ This document organizes methods according to the following themes (click each to
2424

2525
#### Important state variables
2626

27-
* `mapping(address => mapping(IStrategy => uint256)) public stakerStrategyShares`: Tracks the current balance a Staker holds in a given strategy. Updated on deposit/withdraw.
27+
* `mapping(address => mapping(IStrategy => uint256)) public stakerDepositShares`: Tracks the current balance a Staker holds in a given strategy. Updated on deposit/withdraw.
28+
* Note that not all shares may be withdrawable in the event of a slashing.
2829
* `mapping(address => IStrategy[]) public stakerStrategyList`: Maintains a list of the strategies a Staker holds a nonzero number of shares in.
2930
* Updated as needed when Stakers deposit and withdraw: if a Staker has a zero balance in a Strategy, it is removed from the list. Likewise, if a Staker deposits into a Strategy and did not previously have a balance, it is added to the list.
3031
* `mapping(IStrategy => bool) public strategyIsWhitelistedForDeposit`: The `strategyWhitelister` is (as of M2) a permissioned role that can be changed by the contract owner. The `strategyWhitelister` has currently whitelisted 3 `StrategyBaseTVLLimits` contracts in this mapping, one for each supported LST.
31-
* `mapping(IStrategy => bool) public thirdPartyTransfersForbidden`: The `strategyWhitelister` can disable third party transfers for a given strategy. If `thirdPartyTransfersForbidden[strategy] == true`:
32-
* Users cannot deposit on behalf of someone else (see [`depositIntoStrategyWithSignature`](#depositintostrategywithsignature)).
33-
* Users cannot withdraw on behalf of someone else. (see [`DelegationManager.queueWithdrawals`](./DelegationManager.md#queuewithdrawals))
3432

3533
#### Helpful definitions
3634

@@ -55,8 +53,8 @@ Withdrawals are performed through the `DelegationManager` (see [`DelegationManag
5553

5654
```solidity
5755
function depositIntoStrategy(
58-
IStrategy strategy,
59-
IERC20 token,
56+
IStrategy strategy,
57+
IERC20 token,
6058
uint256 amount
6159
)
6260
external
@@ -75,13 +73,13 @@ If the Staker is delegated to an Operator, the Operator's delegated shares are i
7573
*Effects*:
7674
* `token.safeTransferFrom`: Transfers `amount` of `token` to `strategy` on behalf of the caller.
7775
* See [`StrategyBaseTVLLimits.deposit`](#strategybasetvllimitsdeposit)
78-
* `StrategyManager` awards the Staker with the newly-created shares
76+
* `StrategyManager` awards the Staker with the newly-created shares
7977
* See [`DelegationManager.increaseDelegatedShares`](./DelegationManager.md#increasedelegatedshares)
8078

8179
*Requirements*:
8280
* Pause status MUST NOT be set: `PAUSED_DEPOSITS`
8381
* Caller MUST allow at least `amount` of `token` to be transferred by `StrategyManager` to the strategy
84-
* `strategy` in question MUST be whitelisted for deposits.
82+
* `strategy` in question MUST be whitelisted for deposits.
8583
* See [`StrategyBaseTVLLimits.deposit`](#strategybasetvllimitsdeposit)
8684

8785
#### `depositIntoStrategyWithSignature`
@@ -115,20 +113,21 @@ This method has a similar purpose as `depositIntoStrategy()`, except it is inten
115113

116114
### Withdrawal Processing
117115

118-
These methods are callable ONLY by the `DelegationManager`, and are used when processing undelegations and withdrawals:
119-
* [`StrategyManager.removeShares`](#removeshares)
116+
These methods are callable ONLY by the `DelegationManager`, and are used when processing undelegations, withdrawals, and slashes:
117+
* [`StrategyManager.removeDepositShares`](#removedepositshares)
120118
* [`StrategyManager.addShares`](#addshares)
121119
* [`StrategyManager.withdrawSharesAsTokens`](#withdrawsharesastokens)
120+
* [`StrategyManager.burnShares`](#burnshares)
122121

123122
See [`DelegationManager.md`](./DelegationManager.md) for more context on how these methods are used.
124123

125-
#### `removeShares`
124+
#### `removeDepositShares`
126125

127126
```solidity
128-
function removeShares(
127+
function removeDepositShares(
129128
address staker,
130129
IStrategy strategy,
131-
uint256 shares
130+
uint256 depositSharesToRemove
132131
)
133132
external
134133
onlyDelegationManager
@@ -138,61 +137,68 @@ The `DelegationManager` calls this method when a Staker queues a withdrawal (or
138137

139138
The Staker's share balance for the `strategy` is decreased by the removed `shares`. If this causes the Staker's share balance to hit zero, the `strategy` is removed from the Staker's strategy list.
140139

140+
If the Staker has been slashed (i.e. it has delegated to an Operator which has been slashed), then the Staker would be ineligible to withdraw some amount of shares as enforced by the `DelegationManager`.
141+
141142
*Entry Points*:
142143
* `DelegationManager.undelegate`
143144
* `DelegationManager.queueWithdrawals`
144145

145146
*Effects*:
146-
* The Staker's share balance for the given `strategy` is decreased by the given `shares`
147+
* Decrease the Staker's share balance for the given `strategy` by the given `depositSharesToRemove`
147148
* If this causes the balance to hit zero, the `strategy` is removed from the Staker's strategy list
148149

149150
*Requirements*:
150151
* Caller MUST be the `DelegationManager`
151-
* `staker` parameter MUST NOT be zero
152-
* `shares` parameter MUST NOT be zero
153-
* `staker` MUST have at least `shares` balance for the given `strategy`
152+
* `depositSharesToRemove` parameter MUST NOT be zero
153+
* `staker` MUST have at least `depositSharesToRemove` balance for the given `strategy`
154154

155155
#### `addShares`
156156

157157
```solidity
158158
function addShares(
159159
address staker,
160160
IStrategy strategy,
161+
IERC20 token,
161162
uint256 shares
162-
)
163-
external
163+
)
164+
external
164165
onlyDelegationManager
166+
returns (uint256, uint256)
165167
```
166168

167-
The `DelegationManager` calls this method when a queued withdrawal is completed and the withdrawer specifies that they want to receive the withdrawal as "shares" (rather than as the underlying tokens). In this case, the `shares` originally removed (via `removeShares`) are awarded to the `staker` passed in by the `DelegationManager`.
169+
The `DelegationManager` calls this method when a queued withdrawal is completed and the withdrawer specifies that they want to receive the withdrawal as "shares" (rather than as the underlying tokens). In this case, the `shares` originally removed (via `removeDepositShares`) are awarded to the `staker` passed in by the `DelegationManager`.
170+
171+
If any slashing results need to be applied, the `DelegationManager` will calculate the number of shares to slash and return the remaining number of shares the user is eligible to withdraw, then redelegate them.
168172

169173
*Entry Points*:
170174
* `DelegationManager.completeQueuedWithdrawal`
171175
* `DelegationManager.completeQueuedWithdrawals`
172176

173177
*Effects*:
174-
* The `staker's` share balance for the given `strategy` is increased by `shares`
178+
* Increase the `staker's` share balance for the given `strategy` by `shares`
175179
* If the prior balance was zero, the `strategy` is added to the `staker's` strategy list
180+
* Emit a `Deposit` event
176181

177182
*Requirements*:
178183
* Caller MUST be the `DelegationManager`
179184
* `staker` parameter MUST NOT be zero
180185
* `shares` parameter MUST NOT be zero
186+
* Length of `stakerStrategyList` for the `staker` MUST NOT exceed `MAX_STAKER_STRATEGY_LIST_LENGTH`
181187

182188
#### `withdrawSharesAsTokens`
183189

184190
```solidity
185191
function withdrawSharesAsTokens(
186-
address recipient,
192+
address staker,
187193
IStrategy strategy,
188-
uint shares,
189-
IERC20 token
194+
IERC20 token,
195+
uint256 shares
190196
)
191197
external
192198
onlyDelegationManager
193199
```
194200

195-
The `DelegationManager` calls this method when a queued withdrawal is completed and the withdrawer specifies that they want to receive the withdrawal as the tokens underlying the shares. In this case, the `shares` originally removed (via `removeShares`) are converted to tokens within the `strategy` and sent to the `recipient`.
201+
The `DelegationManager` calls this method when a queued withdrawal is completed and the withdrawer specifies that they want to receive the withdrawal as the tokens underlying the shares. In this case, the `shares` originally removed (via `removeDepositShares`) are converted to tokens within the `strategy` and sent to the `recipient`.
196202

197203
*Entry Points*:
198204
* `DelegationManager.completeQueuedWithdrawal`
@@ -205,6 +211,28 @@ The `DelegationManager` calls this method when a queued withdrawal is completed
205211
* Caller MUST be the `DelegationManager`
206212
* See [`StrategyBaseTVLLimits.withdraw`](#strategybasetvllimitswithdraw)
207213

214+
#### `burnShares`
215+
216+
```solidity
217+
function burnShares(
218+
IStrategy strategy,
219+
uint256 sharesToBurn
220+
)
221+
external
222+
onlyDelegationManager
223+
```
224+
225+
The `AllocationManager` calls this method via the `DelegationManager` when an operator is slashed. This function will withdraw shares of a given strategy and transfer the corresponding amount of tokens to a predesignated `DEFAULT_BURN_ADDRESS`, disallowing the Staker from retrieving tokens by removing them from circulation.
226+
227+
*Entry Points*:
228+
* `DelegationManager.burnOperatorShares`
229+
230+
*Effects*:
231+
* Calls `withdraw` on the `strategy`, withdrawing shares and sending a corresponding amount of tokens to the `DEFAULT_BURN_ADDRESS`
232+
233+
*Requirements*:
234+
* Caller MUST be the `DelegationManager`
235+
208236
---
209237

210238
### Strategies
@@ -224,7 +252,7 @@ Additionally, using the `StrategyFactory`, anyone can deploy a new `StrategyBase
224252

225253
```solidity
226254
function deposit(
227-
IERC20 token,
255+
IERC20 token,
228256
uint256 amount
229257
)
230258
external
@@ -259,16 +287,16 @@ The new shares created are returned to the `StrategyManager` to be added to the
259287

260288
```solidity
261289
function withdraw(
262-
address recipient,
263-
IERC20 token,
290+
address recipient,
291+
IERC20 token,
264292
uint256 amountShares
265293
)
266294
external
267295
onlyWhenNotPaused(PAUSED_WITHDRAWALS)
268296
onlyStrategyManager
269297
```
270298

271-
The `StrategyManager` calls this method when a queued withdrawal is completed and the withdrawer has specified they would like to convert their withdrawn shares to tokens.
299+
The `StrategyManager` calls this method when a queued withdrawal is completed and the withdrawer has specified they would like to convert their withdrawn shares to tokens.
272300

273301
This method converts the withdrawal shares back into tokens using the strategy's exchange rate. The strategy's total shares are decreased to reflect the withdrawal before transferring the tokens to the `recipient`.
274302

@@ -336,8 +364,8 @@ Note that once the owner adds tokens to the blacklist, they cannot be removed. T
336364
function whitelistStrategies(
337365
IStrategy[] calldata strategiesToWhitelist,
338366
bool[] calldata thirdPartyTransfersForbiddenValues
339-
)
340-
external
367+
)
368+
external
341369
onlyOwner
342370
```
343371

@@ -410,8 +438,8 @@ Allows the `owner` to update the Strategy Whitelister address. Currently, the St
410438
function addStrategiesToDepositWhitelist(
411439
IStrategy[] calldata strategiesToWhitelist,
412440
bool[] calldata thirdPartyTransfersForbiddenValues
413-
)
414-
external
441+
)
442+
external
415443
onlyStrategyWhitelister
416444
```
417445

@@ -429,8 +457,8 @@ Allows the Strategy Whitelister to add any number of strategies to the `Strategy
429457
```solidity
430458
function removeStrategiesFromDepositWhitelist(
431459
IStrategy[] calldata strategiesToRemoveFromWhitelist
432-
)
433-
external
460+
)
461+
external
434462
onlyStrategyWhitelister
435463
```
436464

@@ -448,8 +476,8 @@ Allows the Strategy Whitelister to remove any number of strategies from the `Str
448476
function setThirdPartyTransfersForbidden(
449477
IStrategy strategy,
450478
bool value
451-
)
452-
external
479+
)
480+
external
453481
onlyStrategyWhitelister
454482
```
455483

0 commit comments

Comments
 (0)