# How It Works

The lending flow follows a similar philosophy to the vault layer: build first, then execute. The client constructs the full set of transactions needed for a given action (including token approvals and any prerequisite steps), and the caller is responsible for signing and broadcasting them.

{% stepper %}
{% step %}

#### **Initialize**

Create a `CityLendingClient` with a public client (for reads) and a wallet client (for writes). The wallet client is optional if you only need to read on-chain state.
{% endstep %}

{% step %}

#### **Build**

Call the appropriate build method for the action you want to perform. The client returns a structured transaction payload, and in the case of Morpho, a set of prerequisite transactions as well.
{% endstep %}

{% step %}

#### **Execute**

Send each transaction through the user's wallet. For Morpho operations, prerequisites (such as token approvals) must be sent before the main bundler transaction. For Aave, approvals are handled separately by your application.
{% endstep %}

{% step %}

#### **Monitor**

Use read methods like `getAaveUserAccountData` to check account health, collateral ratios, and available borrowing power after execution.
{% endstep %}
{% endstepper %}


---

# 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://city-protocol.gitbook.io/docs/neofinance-as-a-service/lending-and-borrowing-module/how-it-works.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.
