# withdraw

## Overview

This function is called when the user wishes to withdraw their previously supplied asset. User redeems their aTokens for the underlying asset.&#x20;

* User gives aDAI, withdraws DAI

<img src="https://1829638638-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0k7YXwFGMFZcsyqkM4q1%2Fuploads%2FrR5dIBwDwXpTfaiXB1AB%2Ffile.excalidraw.svg?alt=media&#x26;token=7d709770-b72e-4716-ae83-73b37cd55d97" alt="" class="gitbook-drawing">

* `executeWithdraw` contains the core logics of the withdraw function

## executeWithdraw

<figure><img src="https://1829638638-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0k7YXwFGMFZcsyqkM4q1%2Fuploads%2FFyKnnW4wvd5voEzvnXoR%2Fimage.png?alt=media&#x26;token=0c101b63-829b-4f2b-81e2-bad8bb744b83" alt=""><figcaption></figcaption></figure>

### Execution flow

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

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

## Visual Aid

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