Deep Dive Into UniLend OMNIS Code

Deep Dive Into UniLend 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.

Structural View of UniLend Protocol

Before we dive, check the following V2 contracts

Core Contract — https://github.com/UniLend/unilendv2/blob/main/contracts/core.sol

Pool Contract — https://github.com/UniLend/unilendv2/blob/main/contracts/pool.sol

Position Contract — https://github.com/UniLend/unilendv2/blob/main/contracts/position.sol

Oracle Contract — https://github.com/UniLend/unilendv2/blob/main/contracts/oracle.sol

Interest Rate Contract — https://github.com/UniLend/unilendv2/blob/main/contracts/interestrate.sol

Create Pool

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

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

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

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

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

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

Announcements Channel | Website | Telegram Community | | Twitter | Blog | Github | Reddit | Instagram

--

--

--

UniLend is a Multichain protocol for Lending & Borrowing all ERC20 tokens permissionlessly. We are developing a Futuristic Base Layer for all DeFi applications.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

What is continuation-passing style?

Employee Spotlight: Louis

Window too cut.

Secure Your Kubernetes Cluster With Pod Security Policies

Anyone area it.

10 Questions to Ask When Choosing a Magento Developer

How to write custom tamper scripts for sqlmap

Some of the payloads sent by sqlmap. Note the presence of AND keyword.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
UniLend Finance

UniLend Finance

UniLend is a Multichain protocol for Lending & Borrowing all ERC20 tokens permissionlessly. We are developing a Futuristic Base Layer for all DeFi applications.

More from Medium

Latest Updates on Cyclos

Reasons why Crypto currency is Best form of Financial freedom during economic recession.

POD at ETHDenver 2022: Building Data Collaboration Protocol (DCP) for Web3

UniLend Finance | Project Updates #17 | February 2022