# MIMOLeverage

The `MIMOLeverage` action contract handle the super vault empty vault logic described in [Leveraging](https://docs.parallel.best/products/parallel-v2/how-it-works/super-vaults-sv/leveraging).

### Process Flow

<figure><img src="https://1576197425-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MdnKrtV1Ev2ILZ6C4SC%2Fuploads%2Fqp4X5NUBMYAgUThOJPbc%2FLeverage.svg?alt=media&#x26;token=62f4ff5a-7343-447c-8e1d-5c32a788b406" alt=""><figcaption></figcaption></figure>

### Write Methods

#### `executeAction(bytes calldata _calldata) external`

Uses a flashloan to repay all debts for a vault and send all collateral in the vault to the owner.

Requirements :&#x20;

* Contract must be unpaused
* Must be called through the `MIMOProxy` `execute()` function
* Targeted vault must have been created by the `MIMOProxy`

| Param Name | Type  | Description                                                                                                                                                                                                   |
| ---------- | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| \_callData | bytes | <p>Abi encoded bytes with : </p><ul><li><code>uint256 depositAmount</code> </li><li><code>uint256 swapAmout</code></li><li><code>FlashloanData flData</code></li><li><code>SwapData swapData</code></li></ul> |

#### `executeOperation(address[] calldata assets, uint256[] calldata amounts, uint256[] calldata premiums, address initiator, bytes calldata params`

AAVE `Pool` contract flash loan callback function.

Requirements :&#x20;

* Contract must be unpaused
* Can only be called by the AAVE `Pool` contract
* Flash loan initiator must be the `MIMOProxy`

| Param Name  | Type       | Description                                                                              |
| ----------- | ---------- | ---------------------------------------------------------------------------------------- |
| `assets`    | address\[] | Address array with one element corresponding to the address of the target vault asset    |
| `amounts`   | uint256\[] | Uint array with one element corresponding to the amount of the target vault asset        |
| `premiums`  | uint256\[] | Uint array with one element corresponding to the flashLoan fees                          |
| `initiator` | address    | Initiator of the flashloan; can only be MIMOProxy owner                                  |
| `params`    | bytes      | Bytes sent by this contract containing MIMOProxy owner, target vault id, SwapData struct |

#### leverageOperation`(IERC20 token, uint256 swapAmount, uint256 flashLoanRepayAmount, SwapData calldata swapData)`

Performs a leverage logic within MIMOProxy context.

Requirements :&#x20;

* Contract must be unpaused
* Must be called through the `MIMOProxy` `execute()` function

| Param Name             | Type    | Description                                                                        |
| ---------------------- | ------- | ---------------------------------------------------------------------------------- |
| `token`                | IERC20  | Collateral of the vault to leverage                                                |
| `swapAmount`           | uint256 | Stablex swap amount                                                                |
| `flashLoanRepayAmount` | uint256 | Amount of collateral to repay to flash loan protocol at the end of the transaction |
| `swapData`             | struct  | SwapData passed from the flash loan call                                           |

### View Methods

`proxyFactory()`

Returns the `MIMOProxyFactory` address.
