> For the complete documentation index, see [llms.txt](https://docs.nondollar.life/autonomint/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nondollar.life/autonomint/blockchain-docs/core-contracts/borrowliquidation.md).

# BorrowLiquidation

## Write Functions

### liquidateBorrowPosition

```solidity
function liquidateBorrowPosition(
        address user,
        uint64 index,
        uint64 currentEthPrice,
        IBorrowing.LiquidationType liquidationType,
        uint256 _lastCumulativeRate
) external payable
```

| Param Name         | Type            | Description                       |
| ------------------ | --------------- | --------------------------------- |
| user               | address         | Address of the borrower.          |
| index              | uint64          | Index of the borrower's position. |
| currentEthPrice    | uint64          | Current ETH price.                |
| liquidationType    | LiquidationType | How to liquidate the psoition.    |
| lastCumulativeRate | uint256         | Cumulative rate.                  |

Liquidate the the borrower's position, if the current ETH price is below or equal to deposited LTV of deposited ETH price. Here the borrowed amount of USDa is burned, 10% of protected amount is going to ABOND USDa pool if the liquidated collateral is ETH. This function can only be called by borrowing contract.

{% hint style="info" %}
Here, the CDS users who opted for liquidation gains are liquidators.
{% endhint %}

### liquidationType1

```solidity
function liquidationType1(
    address user,
    uint64 index,
    uint64 currentEthPrice,
    uint256 lastCumulativeRate
) internal
```

| Param Name         | Type    | Description                       |
| ------------------ | ------- | --------------------------------- |
| user               | address | Address of the borrower.          |
| index              | uint64  | Index of the borrower's position. |
| currentEthPrice    | uint64  | Current ETH price.                |
| lastCumulativeRate | uint256 | Cumulative rate.                  |

Here the borrowed amount of USDa is burned, 10% of protected amount is going to ABOND USDa pool if the liquidated collateral is ETH.

### liquidationType2

```solidity
function liquidationType1(
    address user,
    uint64 index,
    uint64 currentEthPrice
) internal
```

| Param Name      | Type    | Description                       |
| --------------- | ------- | --------------------------------- |
| user            | address | Address of the borrower.          |
| index           | uint64  | Index of the borrower's position. |
| currentEthPrice | uint64  | Current ETH price.                |

Here the 50% of the deposited amount is transfer to synthetix for taking short position with 1X leverage.

### closeThePositionInSynthetix

```solidity
function closeThePositionInSynthetix() external
```

Submit the order to close the above opened short position in synthetix.

### executeOrdersInSynthetix

```solidity
function executeOrdersInSynthetix(
    bytes[] calldata priceUpdateData
) external 
```

Execute the submitted orders in synthetix.

### setTreasury

```solidity
function setTreasury(address _treasury)
```

| Param Name | Type    | Description               |
| ---------- | ------- | ------------------------- |
| \_treasury | address | Treasury contract addess. |

Sets treasury contract interface.

### setAdmin

```solidity
function setTreasury(address adminAddress)
```

| Param Name   | Type    | Description      |
| ------------ | ------- | ---------------- |
| adminAddress | address | Admin's address. |

Sets admin's address.
