# Features of LendingV2
[TOC]
## Notice:
- Gas consumption
- Library version (To verify later)
## Steps:
1. Cooperate with product team to confirm features and design implementation
2. Implementation + Verify
3. Formal Verification + Audit
4. Testnet Launch + Bounty Programs
5. Mainnet Alpha Launch
## Features - General Lending
### Isolation Mode
* isolated collateral asset with limited set of borrowing assets and debt ceiling.
- [x] Borrowers supplying an isolated asset as collateral cannot supply other assets as collateral (though they can still supply to capture yield), and can borrow permitted stablecoins up to a specified debt ceiling.
- [x] Uers can exit isolation mode at any time by disabling the isalated asset as collateral.
* Criterions
- [ ] Only allows asset as isolated mode simultaneously while adding it to markets.
- [ ] Disallows existing assets entering isolated mode.
- [x] Always allows enabling new assets borrowable in isolated mode.
- [ ] Disallows disabling borrowable assets in isolated mode.
- [x] All isolated assets share the same borrowable assets list.
[Skyge 04-14]
Q1. For borrowable assets in isolation mode, it can change from unborrowable to borrowable, so can it change from borrowable to unborrowable?
- [ ] Option1: No.
- [ ] Option2: Yes, it seems like does not affect the equity of users, but for the front-end, maybe need to do more to show borrowed assets that are unborrowable in isolation mode.
- [x] Q2. How to calculate current debt amount? 可以考虑直接用可被借资产的数量计量,这里已经假定了可借资产都是稳定币,并且不考虑价格(即:假定价格都为$1)
[Skyge 04-07] eg:
Under the isolation mode, one asset should behave like following
(Assuming Arb Token and OP Token are isolated assets, `debtCeiling = 500` , and only USDC, DAI can be borrowed):
*debtCeiling means total borrowed amount in the isolation mode, but it is yet to be confirmed.*
- Alice supplies 100 Arb Token, and then she sets Arb Token as collateral (enter markets), so now she enters the solation mode, and she can only borrow USDC, DAI.
- Alice supplies ETH, but it can not be used as collateral.
- Alice supplies OP Token, cause she has enterred the solation mode, so OP Token can not be used as collateral.
- Alice disables Arb Token as collateral(exist markets), now, she exists the solation mode,so she can set any token as collateral.
- Alice sets ETH as collateral, cause she has a non-isolated asset as collateral, so she will never enter the solation mode.
**TODO:**
- [ ] When add new parameters in struct Market, should not generate storage collision(04-07).
### Efficient Mode
- [x] Allow borrowers to extract the highest borrowing power out of their collateral by certain categories.
- [x] User is only allowed to enter one category simultaneously.
- [x] User is still allowed to supply other assets and to use them as collateral, but only collateral belonging to the same E-Mode category chosen by the user will have enhanced risk parameters.
- [x] In certain e-mode, only specific assets within the same category can be borrowed.
* Criterions
- [ ] An asset is only allowed in one E-Mode category and cannot appear in more than one category.
- [ ] Once one asset joins a category, it will be disallowed to exit.
- [x] Assets belonging to one category share the same risk parameters defined by the category, such as: collateral factor, liquidation threshold, liquidation bonus, close factor, etc.
[Skyge 04-24]
Q1: Should eMode risk parameters always increase?
- [ ] Option1: Yes
- [ ] Option2: No, e.g. eMode.ltv 97% -> 98% -> 97%. When decrease some parameters, it may decrease users' equity at the same time, although it is not a good idea, but owner can do like this.
~~Q2: An asset can appear in more than one category at now.~~
~~- [x] Option1: Yes~~
[Skyge:04-11]
- [x] Can set a new oracle in e-mode?
[A] According to the current requirement, it's not required.
### Liquidation Threshold
* seperate LTV and liquidation threshold, LTV/LT(liquidation threshold) per collaterals
### Variable liquidation close factor
* ~~gradual liquidation close-factor per loan assets, up to 100%.~~
### Withdraw&Borrow Timelock
1. **requirements**
* Single borrow / withdraw limit set, for example,
* letgo limit
* 1 block limit
* multi-blocks limit
* assets limit, for example,
* daily volumes limit
* whitelist strategies, for example,
* flag to enable/disable whitelists
* allow accounts in the whitelists having their own limit, for example tx limits and daily volumes limits.
2. **reference structure**
{accounts}{assets}[tx-limits][delay-blocks]
{accounts}{assets}[dailyVolume-limits][delay-blocks]
### Repay with deposits
* The feature looks like "ability to do external call before the end of redeeming", so users can exchange the redeems for borrows to repay the loans. This is so-called "repay with deposits".
* With the help of this feature, users can do lots of stuff, for example "switch your deposits".
### Permissionless Pool
* tools set to set up lending pool automatically
* parameters / oracle / web / api
### Action Conditions(newly added conditions)
Notes: in following cases, the actions will be disallowed.
| enableIsolated | enableCollaterals | disableIsolated | enableEMode | disableEMode | Borrow | Liquidate |
| -------------- | ----------------- | --------------- | --------------------------- | ------------ | ---------------------------------- | ----------------------------- |
| hasCollaterals | inIsolatedMode | - | inEMode | - | borrowsExcluedIsolated | solventByLiquidationThreshold |
| - | - | - | borrowsExcluedEModeCategory | - | borrowsExceededDebtCeilingIsolated | - |
| - | - | - | - | - | borrowsExcluedEModeCategory | - |
### Process(Skyge)
Current process is in the notion: https://www.notion.so/dforce/Technical-Design-Spec-b6804f4014a94055bcc0b469721bd693?pvs=4
---
---
## Features - Hybrid NFT Lending
### Support ERC-721
* NFT as collateral and instant borrowing power, build-in feature in general lending
* tokenize NFT deposit, act as social right of portrait
* oracle with ability of boosting "rare" portraits
* liquidation of NFT, auction and liquidity protection
* instance 'buy' leveraged by borrowing power as low as zero-downpayment
* instance 'sell' leverage by collaterl listing(repay & pay)
### Risk Framework
* THE very question: which type of Loan is really required by NFT holders? Peer-to-Pool OR Peer-to-Peer.
* Loan types: variable/fix rate, fix-term loans
## Reference
### AAVE V3
> [Key Features](https://hackmd.io/@0xSn0w/H1pPv-hX5)
### Euler
> [Key Features](https://hackmd.io/@0xSn0w/BJJppfvg3)
### ParaSpace
> [Key Features](https://hackmd.io/@0xSn0w/ByA1Azvg2)
### BendDao
> [Key Features](https://hackmd.io/@0xSn0w/rJKZd4Fl2)
### Zharta
> [Key Features](https://hackmd.io/@0xSn0w/B1zAlkjl2)