# Omnis Code

The DeFi is scaling and bringing the exposure of the lending and borrowing industry to Fiats, Synthetic assets, Stocks, NFTs, Metaverse, and Real-World Assets.

UniLend is leading this with the launch of **Omnis, a multi-contract DeFi protocol** that builds the infrastructure to allow lending and borrowing of any ERC20 asset in a permissionless nature and expanding the horizon of DeFi.

Our dev team lead by CTO Suryansh Kumar have built the protocol over the last 1 year to help developer communities and utilise these contracts to build new opportunities on the UniLend layer.

And with this guide the UniLend team intends to highlight the most crucial aspect of our contracts and how various functions come into play.



### Create Pool <a href="#b818" id="b818"></a>

UniLend protocol has concept of isolated pools of two different assets _token0_ and _token1_. The pool is created from the function _createPool_ in Core Contract and requires addresses of both the assets.

Internally the function uses IUniLendV2Pool interface to create a pool from Pool Contract with default parameter values of _defaultInterestRate, default\_LTV, default\_LB, default\_RF._



### Lend / Redeem <a href="#c29d" id="c29d"></a>

The lend function needs to be called with parameter \_pool (pool address), and \_amount (int) to start lending of the assets.

The token0 / token1 is selected respectively for +ve and -ve integer value of \_amount.



The logic here gets or creates a Non Fungible Position for user and pool association using interface _IUnilendV2Position_ and stores the information of each token’s address, lend balance and borrow balance for the user.

### Borrow / Repay <a href="#id-92d8" id="id-92d8"></a>

Similar to the lend function the _borrow_ function utilises the Pool Contract to create or update the Non Fungible Position.

The function here requires _\_collateral\_amount (uint)_ and _\_recipient (address)_ in addition to _\_pool_ and _\_amount._

The logic ensures validation of necessary liquidity in the pool to ensure the successful transaction.

### Liquidate <a href="#id-92d8" id="id-92d8"></a>

To keep the UniLend system active and stable the our protocols rely on a distributed network of liquidators independently to keep the overall protocol healthy.

These independent liquidators can use _liquidate_ or _liquidateMulti_ functions to help the system by repaying loans on behalf of defaulters and earn liquidation bonus.

### FlashLoan <a href="#fe96" id="fe96"></a>

The flashloan function allows smart contracts to access the liquidity of the pool within one transaction in an uncollateralized borrowing as long as the amount taken plus a fee is returned.



To initiate the flashloan function pass the following parameters

_\_receiver :_ The address of the contract receiving the funds. The receiver should implement the IFlashLoanReceiver interface.

\_pool: the address of the principal reserve pool

\_amount: the amount requested for this flashloan



## Summary <a href="#id-718b" id="id-718b"></a>

UniLend V2 Relies on a Dual Asset Lending Pool model to offer risk mitigation and flexible lending options. All loans are backed by collateral and represented by Non-Fungible Tokens, which accrue the interests. Various protocol parameters such as collateralization ratio and interest rate vary for different assets.

The UniLend team invites developers to build upon OMNIS infrastructure and explore the possibilities of an open financial institution. DeFi 2.0 is around the corner and builders have a chance to impact the world.

For any enquiries on code and project proposals for grants reach out to our team at hello@unilend.finance.

For the love of code ♥️♥️♥️

Team UniLend
