# burn ATokens

## Overview

<figure><img src="https://1829638638-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0k7YXwFGMFZcsyqkM4q1%2Fuploads%2FFiSjuFHG83qd3tYDHv2p%2Fimage.png?alt=media&#x26;token=f4b2b130-41e7-44c0-ac24-509ed1c9d54e" alt=""><figcaption></figcaption></figure>

* [x] <mark style="color:orange;">cache</mark>
* [x] <mark style="color:orange;">updateState</mark>
* [x] get user's AToken balance + amount to withdraw
* [x] validateWithdraw: confirm user has sufficient balance and asset isActive
* [x] <mark style="color:orange;">updateInterestRates</mark>
* [x] collateral check
* [ ] burn ATokens
* [ ] Ensure existing loans are collateralized

<img src="https://1829638638-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0k7YXwFGMFZcsyqkM4q1%2Fuploads%2FRQIcA11bR7TGr2wKvk2o%2Ffile.excalidraw.svg?alt=media&#x26;token=b9da4140-1bc4-4a4c-8edf-371a727540d0" alt="" class="gitbook-drawing">

## burn ATokens

* `burn` calls `_burnScaled`

<figure><img src="https://1829638638-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0k7YXwFGMFZcsyqkM4q1%2Fuploads%2FAz0nPRBhOuc7dEzb7vKE%2Fimage.png?alt=media&#x26;token=3304e38d-deaf-4679-8d09-185e9250748b" alt=""><figcaption></figcaption></figure>

Amount of tokens burnt is scaled against current liquidity index

* amount = 100
* liquidity index = 1.1
* `amountScaled` = 100 / 1.1 = 90

This is to account for interest accrued.&#x20;

{% hint style="info" %}
If you are confused regarding `balanceIncrease` and `_userState` see: [mint](https://calnix.gitbook.io/aave-book/supply/transfer-and-mint#mint)
{% endhint %}

`_burnScaled` has an interesting approach, in that it looks to mint or burn the difference between unbooked interest accrued and the burn amount.

* unbooked interest accrued: interest accumulated since last update that has not been minted&#x20;

**If `balanceIncrease > amount`**

* interest accrued since last update is larger than burn amount
* mint the difference to the user as aTokens

**If `balanceIncrease <= amount`**

* burn amount exceeds interest accrued
* burn the difference from the user


---

# 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/withdraw/burn-atokens.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.
