Hoyu blog

Loan Liquidation at the Limit: a Worked out Example

In this post, we build on a previous more abstract writeup and work out a numerical example that illustrates how Hoyu protocol operates at the boundary of its possibilities without creating bad loans.

Let us consider a pool (a trading market) for two generic tokens: ALT, which stands for altcoin, and CUR for currency. The reserves of the pool are 1 million ALT and 1 million CUR. This means that the price is 1 CUR/ALT. The Hoyu protocol supports a minimum collateral ratio (CR) of 110%. The loan-to-value (LTV) ratio is the inverse of the CR, which is 90% in this case if rounded down pessimistically. In other words, 90% is the highest LTV that the Hoyu protocol supports. Note that CR and LTV here are computed in terms of the reserve price (ie, the spot price), which is different from the liquidation price.

As we have seen in a previous blopost, this CR>1.1 restriction limits the total sum of outstanding loans. For now, let's take the 7.8% total loan restriction as given. This means that all users combined may have at most 78,000 CUR loans outstanding, inclusive of all fees and interest, since

78,000CUR1,000,000CUR=0.078.

It is a pessimistic restriction, meaning that it guarantees that collateral liquidation covers the whole loan with a slight excess to account for rounding errors etc in the actual implementation of the protocol.

For simplicity, let's say that a single user owes 78,000 CUR to the protocol. Their collateral must at this point be at least

78,000CUR1CUR/ALT×1.1=85,800ALT.

It turns out that to cover the outstanding 78,000 CUR, selling at least 84,854 ALT is needed which results in roughly 78,000.6 CUR according to the constant-product market maker formula

sCUR=RCUR×sALTRALT/γ+sALT,

where RCUR=RALT=1,000,000 are the reserves in the pool, sALT=84,854 is the amount of ALT that the user send to the pool, sCUR is the amount of CUR that the pool sends to the user, and γ=10.3/100 represents the 0.3% fee for swaps.

Note that the reserve price (spot price) before the swap was 1 CUR/ALT, whereas the actual swap (liquidation) price is

78,000.6CUR84,854ALT0.92CUR/ALT.

As we saw in a previous blopost as well, the reserve (spot) price moves due to this swap, and after the swap (liquidation) it stands at

RCURsCURRALT+sALT=1,000,000CUR78,000.6CUR1,000,000ALT+84,854ALT921,999CUR1,084,854ALT0.85CURALT.

To sum up, we have seen that even when a maximum allowed sum is lent out by the protocol at a marginal collateral ratio or loan-to-value of 90%, there is enough collateral to cover the debt.