@@ -233,7 +233,7 @@ contract VaultAdmin is VaultStorage {
233233 }
234234
235235 /**
236- * @notice Move assets from one Strategy to another
236+ * @dev Move assets from one Strategy to another
237237 * @param _strategyFromAddress Address of Strategy to move assets from.
238238 * @param _strategyToAddress Address of Strategy to move assets to.
239239 * @param _assets Array of asset address that will be moved
@@ -246,27 +246,103 @@ contract VaultAdmin is VaultStorage {
246246 uint256 [] calldata _amounts
247247 ) external onlyGovernorOrStrategist {
248248 require (
249- strategies[_strategyFromAddress ].isSupported,
250- "Invalid from Strategy "
249+ strategies[_strategyToAddress ].isSupported,
250+ "Invalid to Strategy "
251251 );
252+ require (_assets.length == _amounts.length , "Parameter length mismatch " );
253+ _withdrawFromStrategy (
254+ _strategyToAddress,
255+ _strategyFromAddress,
256+ _assets,
257+ _amounts
258+ );
259+
260+ IStrategy strategyTo = IStrategy (_strategyToAddress);
261+ for (uint256 i = 0 ; i < _assets.length ; i++ ) {
262+ require (strategyTo.supportsAsset (_assets[i]), "Asset unsupported " );
263+ }
264+ // Tell new Strategy to deposit into protocol
265+ strategyTo.depositAll ();
266+ }
267+
268+ /**
269+ * @dev Deposit multiple assets from the vault into the strategy.
270+ * @param _strategyToAddress Address of the Strategy to deposit assets into.
271+ * @param _assets Array of asset address that will be deposited into the strategy.
272+ * @param _amounts Array of amounts of each corresponding asset to deposit.
273+ */
274+ function depositToStrategy (
275+ address _strategyToAddress ,
276+ address [] calldata _assets ,
277+ uint256 [] calldata _amounts
278+ ) external onlyGovernorOrStrategist {
279+ _depositToStrategy (_strategyToAddress, _assets, _amounts);
280+ }
281+
282+ function _depositToStrategy (
283+ address _strategyToAddress ,
284+ address [] calldata _assets ,
285+ uint256 [] calldata _amounts
286+ ) internal {
252287 require (
253288 strategies[_strategyToAddress].isSupported,
254289 "Invalid to Strategy "
255290 );
256291 require (_assets.length == _amounts.length , "Parameter length mismatch " );
257292
258- IStrategy strategyFrom = IStrategy (_strategyFromAddress);
259293 IStrategy strategyTo = IStrategy (_strategyToAddress);
260294
261295 for (uint256 i = 0 ; i < _assets.length ; i++ ) {
262296 require (strategyTo.supportsAsset (_assets[i]), "Asset unsupported " );
263- // Withdraw from Strategy and pass other Strategy as recipient
264- strategyFrom. withdraw ( address (strategyTo), _assets[i], _amounts[i]);
297+ // Send required amount of funds to the strategy
298+ IERC20 ( _assets[i]). safeTransfer (_strategyToAddress , _amounts[i]);
265299 }
266- // Tell new Strategy to deposit into protocol
300+
301+ // Deposit all the funds that have been sent to the strategy
267302 strategyTo.depositAll ();
268303 }
269304
305+ /**
306+ * @dev Withdraw multiple assets from the strategy to the vault.
307+ * @param _strategyFromAddress Address of the Strategy to withdraw assets from.
308+ * @param _assets Array of asset address that will be withdrawn from the strategy.
309+ * @param _amounts Array of amounts of each corresponding asset to withdraw.
310+ */
311+ function withdrawFromStrategy (
312+ address _strategyFromAddress ,
313+ address [] calldata _assets ,
314+ uint256 [] calldata _amounts
315+ ) external onlyGovernorOrStrategist {
316+ _withdrawFromStrategy (
317+ address (this ),
318+ _strategyFromAddress,
319+ _assets,
320+ _amounts
321+ );
322+ }
323+
324+ /**
325+ * @param _recipient can either be a strategy or the Vault
326+ */
327+ function _withdrawFromStrategy (
328+ address _recipient ,
329+ address _strategyFromAddress ,
330+ address [] calldata _assets ,
331+ uint256 [] calldata _amounts
332+ ) internal {
333+ require (
334+ strategies[_strategyFromAddress].isSupported,
335+ "Invalid from Strategy "
336+ );
337+ require (_assets.length == _amounts.length , "Parameter length mismatch " );
338+
339+ IStrategy strategyFrom = IStrategy (_strategyFromAddress);
340+ for (uint256 i = 0 ; i < _assets.length ; i++ ) {
341+ // Withdraw from Strategy to the recipient
342+ strategyFrom.withdraw (_recipient, _assets[i], _amounts[i]);
343+ }
344+ }
345+
270346 /**
271347 * @dev Sets the maximum allowable difference between
272348 * total supply and backing assets' value.
0 commit comments