# General Execution flow

### **User-facing functions**

Most of the core user-facing functions can be called from Pool.sol:

* supply, withdraw
* borrow, repay
* liquidate, etc

We will review these functions within this section and breakdown their logic and workflow to illustrate the inner workings of Aave.&#x20;

**Most functions share a similar structure in their execution flow**

1. cache storage variables
2. update the state, system-wide (interest accrued)
3. validate action to be taken against updated system
4. if validate, change state as per action
5. update rates, reflective of latest action taken

{% hint style="info" %}
**General execution flow**

* cache -> updateState -> validation -> changeState -> updateRates&#x20;

**Except flashloan**:&#x20;

* validation -> user payload -> cache -> updateState -> changeState -> updateRates
* to protect against reentrancy and rate manipulation within the user specified payload
  {% endhint %}

### **Common functions**

cache, updateState and updateRates are common components of almost all state-changing functions within Aave. They will be covered within [Common functions](#common-functions), along other repeated functions.

* cache, updateState, updateRates&#x20;
* getFlags, getDecimals
* getSupplyCap, getBorrowCap


---

# 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/general-execution-flow.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.
