# Repay Variable Rate

```mermaid
sequenceDiagram
  actor User
  participant VRLM as Variable Rate LendingMarket

  Note over User,VRLM: User approves USDC to VRLM (ERC20 approve)
  User->>VRLM: repay(marketParamsUSDC, usdcToRepay, 0, user, "")
  VRLM-->>User: position updated (borrow reduced)
```

## Details

* **Goal**: Repay outstanding variable-rate USDC debt.
* **Preconditions**: USDC approval to LendingMarket.

## Function call

```
repay(marketParamsUSDC, assets, shares, onBehalf, data)
```

* For asset-based repay: set `assets = usdcToRepay`, `shares = 0`, `onBehalf = user`, `data = ""`
* To repay max via shares: set `shares` to the user's borrow shares and `assets = 0`

## Views and events

**Views**

* `LendingMarket.getUserPosition(marketParamsUSDC, user)` (pre/post) → `borrowAssets`
* `LendingMarket.market(idUSDC)` → `totalBorrowAssets` (consider `accrueInterest(marketParamsUSDC)` before reading)
* `LendingMarket.position(idUSDC, user)` (optional)

**Events**

* `EventsLib.Repay` (assets, shares)
* `EventsLib.AccrueInterest` (optional, if triggered)
