# Summary

A peer-to-peer lending market for all assets

Debita is an innovative decentralised peer-to-peer lending protocol with custom terms and time-based liquidations that allows users to borrow against ERC20 compatible tokens and NFTs, with a strong focus on veNFTs, as collateral, facilitating streamlined and flexible interactions between borrowers and lenders.

Debita V3 introduces significant upgrades that improve capital efficiency and user experience, such as:

* Integration of oracles to calculate ratios upon order acceptance to prevent price fluctuations from rendering offer parameters outdated and removing risks that come with it for supported assets<br>
* Allowing borrowers to use their collateral to accept liquidity from multiple lenders at once.<br>
* The introduction of a new marketplace for trading veNFTs, which features Dutch Auctions, primarily to solve issues related to defaulted (unsplittable) veNFTs liquidations but open to public use.
* An advanced veNFT management tool that allows users to still have control over main features of the asset while utilising it inside Debita’s ecosystem.


# Orders

Debita works in an orderbook style where users create their borrow and lend orders. If the parameters can be matched, a loan is created.

Both lenders and borrowers need to create orders with their custom parameters, although it is possible to mirror other live orders as well as consulting the latest matched parameters for each asset.

Orders within the system are controlled by specific entities: the owner of the order, the aggregator, or an active loan (applicable only in the scenario of a perpetual lend order). This ensures that only authorised parties can engage with the orders, thereby maintaining the integrity and security of transactions.<br>

The orders specify the acceptable loan conditions set by the owner. These conditions are reviewed by our aggregator and have to be an interval on one side and a fixed amount on the other side in order to make the matching smoother.

Example: Borrowers specify the maximum acceptable APR range (up to x%), while lenders choose a fixed APR.<br>

The [aggregator](/lending/aggregator) holds the responsibility of fulfilling the orders. This means that it is the key player in executing and processing the orders to completion.

Orders are flexible; they can be edited at any time, allowing for adjustments and updates as necessary.

To attract more liquidity, lenders can accept multiple collaterals to fulfil their orders. Borrow orders can also use multiple principles. Both are generated via factories.\ <br>

<figure><img src="https://3472888840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxb6PZcKoOWnsfoeg1ASz%2Fuploads%2F3ETLNK4cltw6UB67RPn3%2FFrame%20693.png?alt=media&amp;token=f53bba12-9f46-4046-9ce9-e1eab1a69b2b" alt=""><figcaption><p>First row: Borrow Order, Second Row: Lend Order</p></figcaption></figure>

Key differences between orders:

**Lend Orders:**

* **Fixed APR**
* **Minimum and maximum duration**
* **Single principal asset**
* **Accepted collateral assets (single or multiple) (NFT supported)**
* **Maximum LTV**
* **Sole lender option** - This order will only be matched by itself, avoiding sharing debt with other lenders (Useful for lenders willing to keep unsplittable collaterals as they get to claim them from defaulted loans, instead of going into auction)
* **Perpetual option** - When the debt is paid back, the whole sum (previously lent amount + interest) goes back into the original order, with the same parameters, serving as a compounding set and forget order.

**Borrow Orders:**

* **Maximum interest**
* **Duration**
* **Accepted principle assets (single or multiple)**
* **Single collateral asset (NFT supported)**
* **Fixed LTV**


# 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="https://3472888840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxb6PZcKoOWnsfoeg1ASz%2Fuploads%2FFfpg8XHjvqPtN7LKigdN%2FFinalIncentives.svg?alt=media&amp;token=07dbf195-de55-4f12-8905-d7a20467e805" 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.


# Incentives

It is now possible to add external incentives to a specific market for either lenders or borrowers.

‘Epochs’ are newly introduced 14-day periods in Debita’s system.

Users can incentivise the borrowing or lending or an asset of a specific epoch.

Incentives are distributed to users whose loans initiate in the epoch that follows the one when incentives are deposited.

The distribution is pro-rata, based on volume, and does not depend on repayment or loan duration.<br>

The introduction of external incentives was primarily built for ecosystem incentive campaigns, such as tokenised points, but can be used by any protocol or user at their discretion following the incentive token whitelist curated by the team.

\
\ <br>


# Loans

At Debita, loans are time-based, rather than the usual price-based approach, ensuring that a loan concludes when the borrower either fully repays their debt or defaults it.

In an event of default, lenders retain the borrower's collateral. This system guarantees that once a loan is initiated, neither oracles nor external parties can interfere with the agreed upon deal.

In case of unsplittable assets (eg. veNFTs), unless the lender chooses to be the sole lender of a loan (lonely lender), the defaulted asset will go onto a Dutch Action and the proceeds of that auction will be split between all lenders on that loan proportionally to the amount of debt they were owed.

Once a loan is created, the only ones able to interact with it are the lender, borrower and, in case of an unsplittable asset being defaulted, the Dutch Auction contract.

To facilitate matching through the aggregator, a single borrow order can be matched by multiple lend orders. An individual lend order that cannot be matched with a borrow order on its own can potentially be combined with others to meet the criteria of the borrow order through a compatible weighted average. This system is designed to ensure no potential combination is overlooked, thereby maximizing liquidity.

In the process of creating a borrow order, the borrower has the option to specify all accepted principles along with their corresponding parameters. Consequently, a loan agreement might be structured the following way:

<br>

<figure><img src="https://3472888840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxb6PZcKoOWnsfoeg1ASz%2Fuploads%2FuwEYvgSOUR2VsEu1cXvP%2FFrame%20712.png?alt=media&amp;token=1643c3e1-5666-4c1c-ade0-ff27b238ea23" alt=""><figcaption></figcaption></figure>

## Default

Debita employs time-based liquidation policies, ensuring loan defaults occur solely due to missed payment deadlines. Fluctuations in price do not trigger defaults, maintaining financial stability unless the borrower fails to meet payment commitments on schedule.

## Payments

In order for a borrower to reclaim their collateral they must repay their debt in its entirety **before** the end of the loan.

If there is more than one lender participating in a loan, the borrower has the ability to choose to repay the debt owed to any single one of them and reclaim, proportionally, part of their collateral.

For unsplittable NFTs as collateral, the debt must be paid back in full in order to reclaim it. If partial repayments have been made, the borrower is granted with their proportional share of the auction proceeds.\
Example:\
Collateral: 2000 veAERO\
Borrowed amount: 1000 USDC\
Lenders: 4 (250 USDC each)\
Borrower pays back 2 lenders and defaults on the other 2\
veAERO is auctioned and sold\
Borrower receives 2/4 of the final split proceeds

## Early repayment

The first 1/10 of the loan's duration will have a fixed interest of 10% the total loan's interest.\
From that point on, the interest will increase at the constant APR rate.

What does that mean for users?

Lender:

A minimum 10% of the total interest guaranteed and constant APR after that with the possibility of having their funds back into the market ready for another loan.

Borrower:

After 1/10 of the duration has passed, an early repayment means a lower final interest.

At the moment of repayment, the borrower can specify to which lender they want to repay their debt to; this can help to pay off the orders with higher interest earlier.

***Example:***\
*You're paying a weighted average of 30% APR to 5 lenders and 1 of them is asking for 40% APR, if you pay back that single lender back, the average APR you will pay from that point on is going to be lower than 30%.*

## Deadline

The deadline for the payment of a loan is specified beforehand by the order creators, both lender and borrower.\
Some lenders might have a longer maximum duration than others and lend to the same borrower.\
In that case, the deadline for paying back the debt is dictated by the parameters of the lender with the shortest maximum duration.

Once one loan is defaulted, all loans are defaulted.

***Example:***\
*There are 5 lenders in a loan, 3 of them set a maximum loan duration at 40 days, 1 at 35 days and 1 at 30 days.*\
*If the debt isn't repaid in 30 days, all of the loans will be defaulted at the same time.*

It is possible, though, to repay the shortest duration loans and keep going with others.

If no loan is defaulted, the deadline for the default event adjusts to be the deadline for the shortest unpaid duration loan active.

***Following the same example above:***\
*If the borrower pays back the 30 day maximum duration loan, the next default event will be at the 35 day mark. If that one is also paid back, then it is the 45 day mark.*


# Oracles

Price feeds deployed by the Debita Team are immutable. The optional oracles include Chainlink, Pyth, RedStone and Custom Price Feeds for specific assets and situations.

Users get to choose which price feed they would like to use for each asset in their order.<br>

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXfEVkdiY54hU4GX_eIrjjddRhfih2B65ns8B1WQEXBVZ-No0VlszDU17Fo0XA6G6GLAz1pzaFLg2oPx5b3pwLw-4NshVbjdgR92MiIzk8V1mOd_9ihOTe6zSCndzV4tkQSv8TwOgA?key=N-a1mnI2CSmeNVlLRFH4s9nj" alt=""><figcaption><p>Price feed selection window</p></figcaption></figure>

For assets that do not count with a price feed we offer a static ratio option.

#### **Static Ratio**

In that case the user chooses the nominal value of tokens they want as collateral and principal and the LTV will fluctuate and not adjust with price movement between tokens.&#x20;

The LTV shown on static ratio orders is merely an approximation considering the value of both tokens at a specific moment and is not to be considered accurate.

This option is not advised to be used by inexperienced users.

#### Custom Price Feed

To enhance the experience for users utilising a token without a direct oracle, a custom oracle is created.

There are different ways to make a custom price feed and the team will decide which path to take on a case-to-case basis, taking into account all safety measures necessary.

*Assets that count with a custom price feed will have an explanation of how the price is being fetched.*


# Auctions

Auctions are a new feature on Debita v3 built to liquidate defaulted unsplittable positions. This feature is also open to the public, allowing any user to create auctions to sell their assets.\
\
When initiating an auction, the seller must define the initial price (and the token wanted as payment, maximum discount from initial price, and auction duration, all of which can be edit after the auction is live.

<figure><img src="https://3472888840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxb6PZcKoOWnsfoeg1ASz%2Fuploads%2FuChKEhaY32zDBTZEZSwD%2Fimage.png?alt=media&amp;token=d1fcefd4-9bd3-4b48-8d37-5ea896629dd3" alt=""><figcaption></figcaption></figure>

The duration pertains to the time taken to reduce from the initial to the floor amount, but the auction remains active until sold or canceled. A tick will be calculated to determine the rate of price decrease.

If the floor price is lowered — only to an amount less than the current floor — the tick remains unchanged. The auction duration will be extended by \_`(currentPrice - newFloor) / tick`


# Limit Order

Our marketplace also counts with 'Sell' orders (with 'Buy' orders on their way).

Any of the whitelisted tokens can be choose as payment by the order creator.

<figure><img src="https://3472888840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxb6PZcKoOWnsfoeg1ASz%2Fuploads%2FEYllvnQx1o7RIWc1gRwn%2Fimage.png?alt=media&amp;token=fc80c532-5e85-4c91-a21c-1e7a8927eaad" alt=""><figcaption></figcaption></figure>


# veNFTs

Non-Fungible Receipts are tokenised ownership receipts of your veNFT when it is deposited into a managing vault.

They allow users to have their veNFTs being used as collateral in active loans and still control the main functions of it by utilising not the asset itself, but the ownership over the vault where it is stored in our ecosystem.

This facilitates batch interactions and seamless transactions across contracts. Depositing your veNFT in a vault is essential to access all functionalities offered by Debita.

The user with the manager role retains the power over all main functions of the veNFT, such as voting power, rewards claiming, and lock extensions.

The manager role is granted to the user who deposits a veNFT into the vault and cannot be changed by anyone but the holder of that unique NFR.

When a veNFT is sold or defaulted on a loan, the new owner of the NFR needs to claim their manager role.

\ <br>

To use your veToken on Debita for management or loans, follow these steps:

1. **Deposit your veNFT:** Secure your veToken into our vaults and receive your NFR.

   This serves as your entry point into the Debita ecosystem, facilitating seamless transitions between contracts and enabling scalable governance of veTokens.
2. **Utilize on Debita**: Once your veNFT is secured in a vault, you can proceed to use it within the Debita ecosystem to borrow against it, list it for sale, start an auction or simply manage it.

## **Setting up veNFTs for locking**

\
**Resetting + Merging**\
\
Resetting veNFTs is considered a voting event. Therefore, it's important to note that it cannot be reset if it's already been voted with in the current epoch. This is to maintain the fairness of the voting system.

For the same reason, it will not be able to be voted with after being reset, so it must be merged into a freshly locked veNFT to retain voting power and not lose an epoch's worth of voting rewards.

When merging, you transfer the voting power from one veNFT to another while inheriting the longest lock time of the two.

The locked amount can be as small as you want, but it needs to be shorter or equal to the lock length of your original position if you want to keep the lock period the same.

**To reset and merge your veNFT on:**

<img src="https://docs.debita.org/~gitbook/image?url=https%3A%2F%2F321887439-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FOG34RYjpgAtiCrM5ZkK3%252Fuploads%252FAzEo3P0MmvXwBTKiz2rZ%252Fimage.png%3Falt%3Dmedia%26token%3Deee62c48-e4e1-4d3d-bd1b-88ee47965aba&#x26;width=39&#x26;dpr=4&#x26;quality=100&#x26;sign=e7f8a081&#x26;sv=2" alt="" data-size="line"> Equalizer:

Go to the "[Lock](https://equalizer.exchange/lock)" tab, on their menu, select "Manage" on your veNFT, go over to the "Reset" tab and reset it.

Go back to the main "Lock" tab, click on "Create Lock" and lock a small amount of $EQUAL for the shortest period possible (you can choose on the calendar by clicking on the date).

*Remember to check for pending rewards before the next step or they will be lost.*

Back at the main "Lock" tab, click "Manage" on the **NEW** veNFT, go to the "Merge" tab and merge the reset one into it.

#### &#x20;  <a href="#status-check" id="status-check"></a>


# Tax Tokens

Incorporating tax tokens necessitates a sophisticated approach due to their inherit incompatibility with Debita. This is where NFRs come into play.

To ensure functionality, our NFR smart contracts should be exempted from taxes, allowing users to deposit their tokens without penalty and still be able to use them as collateral.

**Transfer Restrictions of Receipt Tokens**

To prevent tax-free token transfers between wallets, tax token NFRs transfers are restricted to Debita contracts only. This ensures compliance and maintains the integrity.


# Loans

### Borrower's Fees

0.04% daily over the borrowed amount, with a minimum of 0.2% and a maximum of 0.8%.

15% of the borrowers' fees goes to the caller of the `matchOffersV3` function on the Aggregator.

### Lender's Fees

15% over the paid interest.


# Marketplace

### User created order and auction

1% over the paid amount.

### Defaulted asset auction

2% over the paid amount.


# Ranges

All protocol fees have their own range at which it can be set at.

The ranges are as follows:\
**Borrower fee:** from 0.5% to 1%.\
**Daily borrower fee increment**: from 0.01% to 0.1%\
**Incentivised matching fee**: from 5% to 20%.\
**Lender fee range**: 5% to 20%.\
**Users marketplace**: from 0% to 1%.\
**Default auctions**: from 0.5% to 2%.


# Addresses

<table><thead><tr><th>Contract</th><th>Address</th><th data-hidden></th></tr></thead><tbody><tr><td><strong>DebitaV3AggregatorContract</strong></td><td>0x512EF0b254FF8eA8EDE5ed8c8718281D86BfeCD1</td><td></td></tr><tr><td>A<strong>uctionFactoryContract</strong></td><td>0xb30b75792b1F9adFf3657b04C95143166ADFff1F</td><td></td></tr><tr><td><strong>DBOFactoryContract</strong></td><td>0x94C7D0766F49092c8b8Ed2E2d681D842B77BF94b</td><td></td></tr><tr><td><strong>Ownerships</strong></td><td>0x78F3C813a228536746966e73f75EB918E085d664</td><td></td></tr><tr><td>I<strong>ncentivesContract</strong></td><td>0xDb14Ed3A75753C51cFa00C49fb8696868F59cE3c</td><td></td></tr><tr><td><strong>DLOFactoryContract</strong></td><td>0xd360655FC407bB1BD5F845290498AfE9cfB1880d</td><td></td></tr></tbody></table>


# Security

{% file src="/files/QXKzDOnc9PrBX015xkZQ" %}


