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
Copy file name to clipboardExpand all lines: docs/core/StrategyManager.md
+65-37Lines changed: 65 additions & 37 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,13 +24,11 @@ This document organizes methods according to the following themes (click each to
24
24
25
25
#### Important state variables
26
26
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.
28
29
*`mapping(address => IStrategy[]) public stakerStrategyList`: Maintains a list of the strategies a Staker holds a nonzero number of shares in.
29
30
* 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.
30
31
*`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))
34
32
35
33
#### Helpful definitions
36
34
@@ -55,8 +53,8 @@ Withdrawals are performed through the `DelegationManager` (see [`DelegationManag
55
53
56
54
```solidity
57
55
function depositIntoStrategy(
58
-
IStrategy strategy,
59
-
IERC20 token,
56
+
IStrategy strategy,
57
+
IERC20 token,
60
58
uint256 amount
61
59
)
62
60
external
@@ -75,13 +73,13 @@ If the Staker is delegated to an Operator, the Operator's delegated shares are i
75
73
*Effects*:
76
74
*`token.safeTransferFrom`: Transfers `amount` of `token` to `strategy` on behalf of the caller.
77
75
* See [`StrategyBaseTVLLimits.deposit`](#strategybasetvllimitsdeposit)
78
-
*`StrategyManager` awards the Staker with the newly-created shares
76
+
*`StrategyManager` awards the Staker with the newly-created shares
79
77
* See [`DelegationManager.increaseDelegatedShares`](./DelegationManager.md#increasedelegatedshares)
80
78
81
79
*Requirements*:
82
80
* Pause status MUST NOT be set: `PAUSED_DEPOSITS`
83
81
* 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.
85
83
* See [`StrategyBaseTVLLimits.deposit`](#strategybasetvllimitsdeposit)
86
84
87
85
#### `depositIntoStrategyWithSignature`
@@ -115,20 +113,21 @@ This method has a similar purpose as `depositIntoStrategy()`, except it is inten
115
113
116
114
### Withdrawal Processing
117
115
118
-
These methods are callable ONLY by the `DelegationManager`, and are used when processing undelegationsand withdrawals:
119
-
*[`StrategyManager.removeShares`](#removeshares)
116
+
These methods are callable ONLY by the `DelegationManager`, and are used when processing undelegations, withdrawals, and slashes:
See [`DelegationManager.md`](./DelegationManager.md) for more context on how these methods are used.
124
123
125
-
#### `removeShares`
124
+
#### `removeDepositShares`
126
125
127
126
```solidity
128
-
function removeShares(
127
+
function removeDepositShares(
129
128
address staker,
130
129
IStrategy strategy,
131
-
uint256 shares
130
+
uint256 depositSharesToRemove
132
131
)
133
132
external
134
133
onlyDelegationManager
@@ -138,61 +137,68 @@ The `DelegationManager` calls this method when a Staker queues a withdrawal (or
138
137
139
138
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.
140
139
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
+
141
142
*Entry Points*:
142
143
*`DelegationManager.undelegate`
143
144
*`DelegationManager.queueWithdrawals`
144
145
145
146
*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`
147
148
* If this causes the balance to hit zero, the `strategy` is removed from the Staker's strategy list
148
149
149
150
*Requirements*:
150
151
* 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`
154
154
155
155
#### `addShares`
156
156
157
157
```solidity
158
158
function addShares(
159
159
address staker,
160
160
IStrategy strategy,
161
+
IERC20 token,
161
162
uint256 shares
162
-
)
163
-
external
163
+
)
164
+
external
164
165
onlyDelegationManager
166
+
returns (uint256, uint256)
165
167
```
166
168
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.
168
172
169
173
*Entry Points*:
170
174
*`DelegationManager.completeQueuedWithdrawal`
171
175
*`DelegationManager.completeQueuedWithdrawals`
172
176
173
177
*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`
175
179
* If the prior balance was zero, the `strategy` is added to the `staker's` strategy list
180
+
* Emit a `Deposit` event
176
181
177
182
*Requirements*:
178
183
* Caller MUST be the `DelegationManager`
179
184
*`staker` parameter MUST NOT be zero
180
185
*`shares` parameter MUST NOT be zero
186
+
* Length of `stakerStrategyList` for the `staker` MUST NOT exceed `MAX_STAKER_STRATEGY_LIST_LENGTH`
181
187
182
188
#### `withdrawSharesAsTokens`
183
189
184
190
```solidity
185
191
function withdrawSharesAsTokens(
186
-
address recipient,
192
+
address staker,
187
193
IStrategy strategy,
188
-
uint shares,
189
-
IERC20 token
194
+
IERC20 token,
195
+
uint256 shares
190
196
)
191
197
external
192
198
onlyDelegationManager
193
199
```
194
200
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`.
196
202
197
203
*Entry Points*:
198
204
*`DelegationManager.completeQueuedWithdrawal`
@@ -205,6 +211,28 @@ The `DelegationManager` calls this method when a queued withdrawal is completed
205
211
* Caller MUST be the `DelegationManager`
206
212
* See [`StrategyBaseTVLLimits.withdraw`](#strategybasetvllimitswithdraw)
207
213
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
+
208
236
---
209
237
210
238
### Strategies
@@ -224,7 +252,7 @@ Additionally, using the `StrategyFactory`, anyone can deploy a new `StrategyBase
224
252
225
253
```solidity
226
254
function deposit(
227
-
IERC20 token,
255
+
IERC20 token,
228
256
uint256 amount
229
257
)
230
258
external
@@ -259,16 +287,16 @@ The new shares created are returned to the `StrategyManager` to be added to the
259
287
260
288
```solidity
261
289
function withdraw(
262
-
address recipient,
263
-
IERC20 token,
290
+
address recipient,
291
+
IERC20 token,
264
292
uint256 amountShares
265
293
)
266
294
external
267
295
onlyWhenNotPaused(PAUSED_WITHDRAWALS)
268
296
onlyStrategyManager
269
297
```
270
298
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.
272
300
273
301
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`.
274
302
@@ -336,8 +364,8 @@ Note that once the owner adds tokens to the blacklist, they cannot be removed. T
0 commit comments