# Lending
URL: /docs/guides/lending
Let your users earn interest on deposits, borrow against them like a secured loan, repay and withdraw, from one quote endpoint.
Your users can deposit a currency to earn interest, and borrow another currency against that deposit, like a secured loan. Every lending action starts with a quote from [Create Lending Quote](/docs/api-reference/lending/CreateLendingQuoteController_handle_v1), which the user approves and you submit like any other operation. The deposit stays in the user's name; only the user can move their money, and Notus never holds it.
Your users can deposit tokens on [Aave](https://aave.com) to earn interest, and borrow other tokens against that deposit. Every lending action is one quote from [Create Lending Quote](/docs/api-reference/lending/CreateLendingQuoteController_handle_v1), signed and executed like any other operation. The deposit stays in the user's wallet's name on Aave; Notus never holds it.
## Deposit to earn interest [#deposit-to-earn-interest]
```ts
const USDC_BASE = '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913'
const quote = await notus.lending.createLendingQuote({
walletAddress,
provider: 'AAVE',
supply: { tokenAddress: USDC_BASE, amount: '100', chainId: 8453 },
gas: { tokenAddress: USDC_BASE, paymentMethod: 'DEDUCT_FROM_AMOUNT' },
})
const operation = quote.signData.find((item) => item.type === 'USER_OPERATION')
if (!operation?.hash) throw new Error(JSON.stringify(quote.revertReason))
await notus.userOperations.executeUserOperation({
userOperationHash: operation.hash,
signature: await signer.signMessage({ message: { raw: operation.hash } }),
})
```
This example deposits 100 digital dollars (USDC) on the Base network (`chainId: 8453`). Money lives on a network, like a bank system; `tokenAddress` is the currency's id on that network, `walletAddress` is the user's account address, and `amount` is how much to deposit, as text. Setting `gas` with `DEDUCT_FROM_AMOUNT` pays the network fee from the dollars being deposited.
A lending quote lists what the user needs to approve in `signData` instead of a top-level `userOperationHash`. Have the user approve the `USER_OPERATION` entry with their key, then send the approval to `executeUserOperation`.
A lending quote lists what to sign in `signData` instead of a top-level `userOperationHash`. Sign the `USER_OPERATION` hash and execute.
## What each request does [#what-each-request-does]
The legs you send decide the operation:
| Send | The user |
|---|---|
| `supply` | deposits and starts earning |
| `supply` + `borrow` | deposits and borrows against it in one step |
| `borrow` | borrows against what they already deposited |
| `repay` | pays back a loan |
| `withdraw` | takes a deposit back |
| `repay` + `withdraw` | repays and withdraws in one step |
Each leg takes `{ tokenAddress, amount, chainId }`: the currency's id, the amount as text, and the network's id. Legs sent together must be on the same network.
Each leg is `{ tokenAddress, amount, chainId }`. Legs sent together must be on the same chain.
## Show deposits and loans [#show-deposits-and-loans]
The user's [portfolio](/docs/guides/portfolio-and-history) with `includeLendingPositions=true` lists each deposit and loan (`positionType: 'supply' | 'borrow'`) with its value in dollars.
The wallet's [portfolio](/docs/guides/portfolio-and-history) with `includeLendingPositions=true` lists each deposit and loan (`positionType: 'supply' | 'borrow'`) with its value in dollars.
## Networks [#networks]
Available on Ethereum, OP Mainnet, BNB Smart Chain, Gnosis, Polygon, Base, Arbitrum, Avalanche and X Layer.
Aave V3 on Ethereum, OP Mainnet, BNB Smart Chain, Gnosis, Polygon, Base, Arbitrum, Avalanche and X Layer.
- **Morpho.** `provider: 'MORPHO'` uses Morpho markets on Polygon. Every leg then needs the market's `marketId`.
- **Signing.** `signData` holds a `USER_OPERATION` entry, and an `AUTHORIZATION` entry on an EIP-7702 wallet's first operation on that chain: sign its hash and send it as `authorization` on execute.
- **Borrow risk.** Notus watches open loans and sends a `lending.risk` webhook when a position gets close to liquidation, and `lending.liquidation` when one is liquidated. The history type for that is `LENDING_LIQUIDATION`.
- **Gas.** `DEDUCT_FROM_AMOUNT` takes the network fee from the leg whose token matches `gas.tokenAddress`; `ADD_TO_AMOUNT` charges it separately.
- **Errors.** `MARKET_NOT_FOUND` (token or chain without a market), `AMOUNT_TOO_LOW`, `INSUFFICIENT_BALANCE`, `UNSUPPORTED_LENDING_OPERATION_EXCEPTION` (for example `supply` with `repay`).