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 —

Pool Contract —

Position Contract —

Oracle Contract —

Interest Rate Contract —

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.


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.


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


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

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

Deploy to Kubernetes in Google Cloud: Challenge Lab

How a smart integration layer strengthens your proposition

The Great Migration: An Angular to React Migration Two Years in the Making

Interactive Volumetric Fog With Fluid Dynamics and Arbitrary Boundaries

Not Everything Needs to be a Dashboard

Python Libraries For Data Science : DAY-5 →Matplotlib (HistogramsGraph)

I Decided to Attend a Coding Bootcamp

An in-depth introduction to SQOOP architecture

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

Discussing Unmarshal Telegram Genie Bot

RE: The False Promise Of Web3 — Welcome to the third-World


Decentralized cryptocurrency exchanges: how to pick the right one