# Aggregator

The core contract is crucial for verifying the legitimacy and alignment of matched offers. The `matchOffersV3()` function performs several checks, including ensuring that data from multiple orders are compatible. The caller of `matchOffersV3` is rewarded with 15% of the fees charged to the borrower. Given that anyone can execute this function, it's essential that all conditions.

* Ratio of lend and borrow orders
* Validation of oracle prices
* Verification of duration
* Types of tokens involved

This thorough verification process ensures smooth and secure operations.<br>

To ensure that the matching process respects the borrowing parameters, individual lending offers do not need to precisely match the conditions of the borrow order. Instead, the weighted average of parameters across all lending offers should align with the borrowing requirements, allowing for greater flexibility and optimization in matching offers.\ <br>

<figure><img src="/files/Cz4T4C9bm7G6dkBn77Kp" alt=""><figcaption><p>High-level contracts flow in order to create a loan</p></figcaption></figure>

`matchOffersV3` Function Overview

The `matchOffersV3` function facilitates the matching of lending orders with a borrow order. The core purpose is to ensure the lending offers meet the borrowing needs while maintaining specified financial ratios and limits, ensuring legitimacy and compliance with established loan and collateral parameters.<br>

#### Parameters

* **lendOrders**: Array of addresses, each representing a lending offer.
* **lendAmountPerOrder**: Array indicating the amount to be borrowed from each lending order.
* **porcentageOfRatioPerLendOrder**: Array indicating the ratio percentage of collateral to principle that each lending order is offering.
* **borrowOrder**: Address of the borrowing order.
* **principles**: Array of principles the borrower intends to acquire.
* **indexForPrinciple\_BorrowOrder**: Array defining the index of each principle in the accepted principles of the borrow order.
* **indexForCollateral\_LendOrder**: Array defining the index of each collateral in the accepted collaterals of the lend order.
* **indexPrinciple\_LendOrder**: Array defining the index of each principle within the lend order's principles.


---

# 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://docs.debita.org/lending/aggregator.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.
