# Using lending pools via RFQ API

## API details

Lending pools can be utilized using [QuoteLevelExt](/liquorice-docs/for-market-makers/basic-market-making-api.md#quote-level-extended) type of the quote level sent in [RFQQuote](/liquorice-docs/for-market-makers/basic-market-making-api.md#quote-level-extended) message\
\
Configuration of lending token transfer and lending parameters should be done using fields in `baseTokenData`and `quoteTokenData`&#x20;

```json5
{
    ...,
    baseTokenData: {
        /// Token address
        address: string,
        /// Total amount of baseToken to take from effectiveTrader,
        /// with up to 18 decimal places
        amount: string,     
        /// Portion of the amount to transfer to the recipieint
        toRecipient?: string,
        /// Portion of the amount to repay token debt with
        toRepay?: string,
        /// Portion of the amount to supply as collateral
        toSupply?: string, 
    },
    /// Data of token to be received by trader
    quoteTokenData: {
        /// Token address
        address: string,
        /// Total amount of quoteToken to take from signer,
        /// with up to 18 decimal places
        amount: string,
        /// Minimum amount of quoteToken to take for partial fills,
        minAmount: string,     
        /// Portion of the amount to be transferred from `signer`,
        toTrader?: string,
        /// Portion of the amount to be filled by withdrawing collateral
        toWithdraw?: string,
        /// Portion of the amount to be filled by borrowing
        toBorrow?: string,
    },
}
```

#### Lending Parameters Explained

Essentially, the Liquorice RFQ allows market makers to define how they would like to handle the base and quote amounts in any proportions they desire. The Liquorice smart contract will accept these parameters and execute the necessary token transfers and borrowing.

**Base Token Data**

* **`toRecipient`** – The amount of the base token to be transferred to the recipient's address.
  * *After settlement, this amount will be transferred directly to the recipient's address.*
* **`toRepay`** – The amount of the base token to be used to repay the market maker's debt (if applicable).
  * *After settlement, this amount will reduce the maker's debt for the given token (if applicable).*
* **`toSupply`** – The amount of the base token to be supplied to the lending pool as the market maker's collateral, which is used to facilitate any borrowing.
  * *After settlement, this amount will be locked as collateral in the lending pool to facilitate any borrowing.*

Note: The sum of the values in `toRecipient`, `toRepay`, and `toSupply` must equal the `amount`.

**Quote Token Data**

* **`toTrader`** – The amount of the quote token to be transferred from the signer’s address to the trader.
  * *After settlement, this amount will be transferred to the order originator’s address directly from signer's address.*
* **`toWithdraw`** – The amount of the quote token to be withdrawn from the lending pool and transferred to the trader.
  * *After settlement, the market maker will have less collateral locked in the lending pool.*
* **`toBorrow`** – The amount of the quote token to be borrowed from the lending pool and transferred to the trader.
  * *After settlement, the maker will have an outstanding debt that needs to be repaid.*

Note: The sum of the values in `toTrader`, `toWithdraw`, and `toBorrow` must equal the `amount`.


---

# 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://liquorice.gitbook.io/liquorice-docs/for-market-makers/lending-pools-intro/using-lending-pools-via-rfq-api.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.
