> For the complete documentation index, see [llms.txt](https://wild-credit.gitbook.io/wild-credit/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wild-credit.gitbook.io/wild-credit/contract-docs/lending-pair.md).

# Lending Pair

## Events

### Liquidation

Emitted on each `liquidateAccount` function call.

```
event Liquidation(
  address indexed account,
  address indexed repayToken,
  address indexed supplyToken,
  uint repayAmount,
  uint supplyAmount
)
```

### Deposit

Emitted on any of the `deposit` function calls.

```
event Deposit(address indexed account, address indexed token, uint amount)
```

### Withdraw

Emitted on any of the `withdraw` function calls.

```
event Withdraw(address account, address indexed token, uint amount)
```

### Borrow

Emitted on each `borrow` function call.

```
event Borrow(address account, address indexed token, uint amount)
```

### Repay

Emitted on each `repay` function call.

```
event Repay(address indexed account, address indexed token, uint amount)
```

## Read-only functions

### debtOf

Borrowed token amount with interest for a given account. May not include currently pending interest.

```
debtOf(address token, address account)
```

### totalDebt

Total debt with interest for a given token. May not include currently pending interest.

```
totalDebt(address token)
```

### borrowBalanceConverted

Borrowed `borrowToken` amount with interest for a given `account`, converted into `returnToken` token based on the liquidation current [liquidation price](broken://pages/-MXBWQHQIpAYgQG0vrLD). Does not include slippage. May not include pending interest.

```
borrowBalance(address account, address borrowToken, address returnToken)
```

### supplyBalanceConverted

Borrowed `suppliedToken` amount with interest for a given `account`, converted into `returnToken` token based on the current [liquidation price](broken://pages/-MXBWQHQIpAYgQG0vrLD). Does not include slippage. May not include pending interest.

```
supplyBalance(address account, address borrowToken, address returnToken)
```

### accountHealth

Calculated as combined `supplyBalance` / `borrowBalance`of both tokens. When below `controller.liqMinHealth()`, the account may be liquidated.

```
accountHealth(address account)
```

### convertTokenValues

Convert`fromToken` amount into `toToken` amount based on the oracle prices.

```
convertTokenValues(address fromToken, address toToken, uint inputAmount)
```

## State-modifying functions

### deposit

Deposit `token` to earn interest or to provide collateral for borrowing another token.

```
deposit(address account, address token, uint amount)
```

### withdraw

Withdraw deposited token. If there is a positive `borrowBalance`, the account must stay above required  `accountHealth` after calling this function.

```
withdraw(address recipient, address token, uint amount)
```

### withdrawAll

Withdraw the full supply balance + pending interest.

```
withdrawAll(address recipient, address token)
```

### borrow

Borrow `token`. The account must stay above required  `accountHealth` after calling this function. The account cannot borrow the same token it's currently supplying.

```
borrow(address recipient, address token, uint amount)
```

### repay

Repay borrowed `token`.

```
repay(address account, address token, uint maxRepayAmount)
```
