Money Market on ICE: Part 1
The money market is a category of financial instruments that contains the world’s most liquid and risk-free debt securities. A decentralized system enables participants to conduct transactions without requiring a third party to validate the transaction. The blockchain is altering the way we do business, and the money market in Decentralized Finance (DeFi) is no exception.
A money market in a decentralized system is one in which smart contracts allow investors to transact directly with one another, with no intermediates involved. Some famous examples of money markets in DeFi are OMM, Cream, Aave, etc.
We will also be introducing Band Protocol as decentralized oracle in the testnet for ICE/SNOW called Arctic.
What will we be doing
This tutorial is going to be a three-part series of building a Money Market on ICE which would allow anyone to supply cryptocurrencies to earn interest as well as borrow cryptocurrencies for loans. In this tutorial we will also to be using Band Protocol oracle for fetching the price feeds from decentralized money market.
In this first part of the series, we will be focusing on the following points:
- Getting an overview of the ICE Money Market dApp
- Learning about some terminologies and main methods of smart contract
- Explaining workflow of main methods
- Overview of Band Protocol
Terminologies
Before looking at the UI, let’s start with some of the common terminologies of the DeFi world that would be used in the project:
Reserve: Reserve can be thought of as a bank. It is the place where you deposit your assets to earn interest as well as take the loan from.
Liquidity: It is the amount of tokens/cryptocurrencies available in the reserve.
hTokens: It is a new token minted to the user when they deposit their cryptocurrency on the reserve.
dTokens: It is a new token minted to the user when they borrow a cryptocurrency from the reserve.
Borrows: It is the amount of tokens/cryptocurrencies borrowed from the reserve.
Collateral: It is the amount of cryptocurrency that is pledged as security for the repayment of the loan.
Health Factor: It is used to represent how safe the loan/borrow is. Health factor ≤ 1 is NOT safe.
Utilization Rate: It is the utilization of the available liquidity. It is obtained by dividing Total Liquidity by Total Borrows.
Borrow Rate: It is the interest rate of the borrows. It is similar to the interest rate on the loan.
Liquidity Rate: It is the interest rate of the supplied liquidity. It is similar to the interest rate on your amount in the bank.
Cumulated/Cumulative Index: Unlike traditional/centralized finance where the interest rates are fixed over some time, the rates in the DeFi world can change after each transaction. To make it easier to calculate the interest amounts with ever-changing interest rates, we make use of this cumulated index.
UI overview
Let us take a glance at the UI of the ICE Money Market(IMM) dApp we are going to build.
Deposit/Redeem
The first function that a Money Market provides is to deposit your cryptocurrency. Depositing cryptocurrency increases the total liquidity of the particular reserve of cryptocurrency.
Similarly, the second main function you can do is to be able to redeem the cryptocurrency you have deposited along with the interest accrued over it.
In the UI, you can deposit/redeem this by adjusting the slider.
Borrow/Repay
Users can borrow cryptocurrencies from money market. For borrowing a particular cryptocurrency, a user should have deposited some cryptocurrency/assets that can be used as collateral.
The amount borrowed must be less than the amount that has been deposited. This is called over-collateralization of assets and is used to hedge against the volatility of the prices of crypto assets.
To clear the loan, you have to submit the original borrowed amount + some interest on the borrowed amount.
Similar to deposit/redeem, you can borrow/repay by adjusting the slider.
During the process of building a decentralized money market, we will need to fetch the price feeds of some tokens, which is same as consuming data from web API’s. But since smart contract are isolated so it cannot interact with the data outside of its native blockchain. Thus the need of oracle arises. Oracle provides a way for the smart contract to interact with the resources outside its blockchain which is also termed as ‘off-chain’.
Arctic Testnet is now integrated with Band Protocol, which is a decentralized oracle.
Introducing Band Protocol
Band Protocol, also known as Band oracle is a cross-chain data oracle platform that aggregates and connects real-world data and APIs to smart contracts.
To guarantee that decentralized money markets remain over-collateralized and do not become insolvent, real-time pricing data on each supported item on the exchange is required. Band’s oracle architecture provides a highly secure and dependable source of pricing data on a wide range of crypto assets to several on-chain money markets, including ICX. For this tutorial, we will be using band oracle for getting live price feeds through our smart contract.
NOTE: Arctic testnet is now supported by the band protocol oracle. You can view the list of networks supported by band protocol by visiting this link
Summary
Decentralized money markets are an important building piece for the DeFi ecosystem, on which innovative financial products may be constructed. In this first part of Money Market on ICE series, we got acquainted with the terminologies, UI of the dApp as well the main functions and their process flows.
In the next part, we will dive deep into the dApp and will learn about the mathematics and financial calculations of interest/borrow rates and we will also get an overview of smart contracts we will be writing later.