Protocol Math
as of 06/02/2022
The Hatom protocol contracts use a system of exponential math, Exponential.toam, to represent fractional quantities with sufficient precision.
Most numbers are represented as a mantissa, an unsigned integer scaled by 1 * 10 ^ 18, to perform basic math at a high level of precision.

Interest Rate Model

Asset Utilization:
At a given point in time t, the money market utilization factor U(t) is:
Where B(t) is the total borrowed amount and L(t) is the amount of underlying liquidity available, given by:
In which C(t) is the remaining cash and R(t) are the protocol reserves.
The borrowing cost of each money market is represented by an interest rate based on the demand and supply of each asset, such that:
Where r0, m1, m2 and Uoptimal are model parameters.
The supplier’s interest rate is given by:
Where Fr, the reserve factor, is the fraction of interest set aside for reserves.

Liquidity Incentive Structure

The Hatom protocol depends on the interest rate model to encourage users to provide Liquidity to the protocol. The protocol doesn't guarantee liquidity, which means that in case of high demand for an asset, the liquidity of that asset available to be withdrawn or borrowed will decline; if this happens, interest rate rise, encouraging supply, and disincentivizing borrowing.

Implementation & Architecture

Hatom protocol is open-source, and all smart contracts will be publicly available, but it's forbidden to fork it for commercial use, as Hatom Protocol is protected and subject to a "Business Source License" which is a trademark of MariaDB Corporation Ab.

HToken Contracts

The exchange rate between underlying and hTokens in a given money market is just the quotient between the underlying available liquidity and the total supply of hTokens H(t):

Interest Rate Mechanics

Hatom money markets are based on an interest rate model built around the supply and demand ratio of the asset. The interest rate of each asset changes constantly depending on market conditions. The Interest Rate Index captures the history of each interest rate money market. The Interest rate changes continuously as users mint, redeem, borrow, repay or liquidate an asset.
Market & Borrow Dynamics:
The total borrowed amount or total debt dynamics are governed by the following differential equation:
This translates to the following difference equation when applying a simple discretization scheme:
Each money market must track both the total borrowed amount as well as each individual account borrows. In that context, the money market smart contract computes and stores an Interest Rate Index given by:
With initial condition I0 = 1. This index is updated every time a transaction occurs and is also stored when an account takes or repays a borrow. This allows translating any borrowed amount to a present value, e.g. a borrow Bj taken at time tj
t has a present value given by:
In other words, defining a discount factor D(t, T) as:
With t
T, we get:
Finally, it is worth describing the protocol reserves dynamics. Basically, a portion determined by the reserve factor Fr of the accrued interest is set aside as reserves, such that:
Which translates to:

Export as PDF
Copy link
Outline
Interest Rate Model
Liquidity Incentive Structure
Implementation & Architecture
HToken Contracts
Interest Rate Mechanics