# Common Frontend Flows

#### Lending Flow

1. Read available markets or pools using `getMorphoMarket` or Aave pool data.
2. Use `previewDeposit`-style reads or balance checks to show the user how much they can supply.
3. For Morpho, call `buildSupply` and execute the returned `requirements` followed by `bundlerTx`. For Aave, send an approval transaction first, then execute the tx from `buildAaveSupplyTx`.

#### Borrow Flow with Health Monitoring

1. After supplying collateral, read the user's account health via `getAaveUserAccountData` (for Aave) or `getMorphoPosition` (for Morpho).
2. Display available borrow power and health factor in the UI so the user can choose a safe borrow amount.
3. Call the relevant build method and execute.
4. After borrowing, re-read account health and update the UI.

#### Recommended Data Split

For the best frontend experience, combine data sources the same way you would with vaults:

Use `CityLendingClient` read methods for live on-chain state like positions, health factors, and market utilization. Pair this with `CityPortfolioClient` subgraph queries if you need historical lending activity or indexed transaction logs.


---

# 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/software-development-kit/lending-borrowing/common-frontend-flows.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.
