# swapBorrowRateMode

### Overview

This function is called when the user wishes to swap his current interest mode to the other:

* stable -> variable
* or vice versa

{% hint style="info" %}
Users can only have a debt position in **either** stable or variable. Cannot have both stable and variable debt for the same asset.
{% endhint %}

<figure><img src="/files/NOtKlaUHNoqZIPonIlxy" alt=""><figcaption></figcaption></figure>

### Execution flow

* [ ] <mark style="color:orange;">cache + updateState</mark>
* [ ] getUserCurrentDebt
* [ ] validateSwapRateMode
* [ ] Swap interest rate mode
* [ ] <mark style="color:orange;">updateInterestRates</mark>

We will breakdown and examine the unique sections of logics within **swapBorrowRateMode**. Code delineated in orange are common functions and can be explored in that [section](/aave-book/functions/common-functions.md).

## Visual Aid

{% embed url="<https://link.excalidraw.com/readonly/YXcOdQXk6i8oUviCXrOx?darkMode=true>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://calnix.gitbook.io/aave-book/functions/swapborrowratemode.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
