# liquidation-manager

1. `calculate-user-global-data`: Calculates the global data of a user across all assets.
2. `liquidation-call`: Performs a liquidation call on an undercollateralized position.
3. `calculate-available-collateral-to-liquidate`: Calculates the available collateral that can be liquidated.

#### `calculate-user-global-data`

Calculates the global data of a user across all assets.

| Parameter | Type        | Description                                     |
| --------- | ----------- | ----------------------------------------------- |
| `user`    | `principal` | The user for whom the data is being calculated. |
| `assets`  | `list`      | A list of assets to include in the calculation. |

#### `liquidation-call`

Performs a liquidation call on an undercollateralized position.

| Parameter              | Type        | Description                                       |
| ---------------------- | ----------- | ------------------------------------------------- |
| `assets`               | `list`      | A list of assets involved in the liquidation.     |
| `lp-token`             | `<a-token>` | The LP token associated with the collateral.      |
| `collateral`           | `<ft>`      | The collateral asset to be liquidated.            |
| `debt-asset`           | `<ft>`      | The debt asset to be repaid.                      |
| `collateral-oracle`    | `<oracle>`  | The oracle for the collateral asset.              |
| `debt-asset-oracle`    | `<oracle>`  | The oracle for the debt asset.                    |
| `user`                 | `principal` | The borrower's address.                           |
| `debt-purchase-amount` | `uint`      | The amount of debt the liquidator wants to repay. |
| `to-receive-atoken`    | `bool`      | Whether the liquidator wants to receive aTokens.  |

#### `calculate-available-collateral-to-liquidate`

Calculates the available collateral that can be liquidated.

| Parameter                 | Type       | Description                                     |
| ------------------------- | ---------- | ----------------------------------------------- |
| `collateral`              | `<ft>`     | The collateral asset.                           |
| `principal-asset`         | `<ft>`     | The principal asset for which the debt is owed. |
| `collateral-oracle`       | `<oracle>` | The oracle for the collateral asset.            |
| `principal-oracle`        | `<oracle>` | The oracle for the principal asset.             |
| `debt-to-liquidate`       | `uint`     | The amount of debt to liquidate.                |
| `user-collateral-balance` | `uint`     | The user's balance of the collateral asset.     |
