Alpha Homora's smart contract can be found here. Alpha Homora will be launched onon Ethereum network.Thursday Oct. 8 @ 1.30pm UTC

Alpha Homora smart contract has been reviewed by PeckShield, see write-up.

Like any borrowing with leverage, Alpha Homora has its own risk. It is important that every user clearly understands the risk they are undertaking and this blog intends to outline risks involved. Alpha Homora, despite being reviewed by Peckshield, is still considered a beta product.

As stated in the Alpha Homora previous blog, Alpha Homora users may face the following risk:

take the risk of being liquidated, specifically when the farming token price drops significantly (relative to ETH).**Yield Farmers**share the risk of debts accrued by underwater positions in case liquidators did not liquidate in time.**ETH Lenders****Liquidators**take the risk of being front-run by other competitors, to get reward bonus from liquidations or reinvest bounties. If front-run, liquidators and bounty hunters pay gas fees for free (likely at high gas prices).**& Bounty Hunters**

To this end, Alpha Homora's key parameters are initialized to balance risk and reward for our users. This article will focus on providing insights behind these values.

Other protocol risks may include attack vectors via sequential function composition, e.g., the recent bZx flash loan hack. With our smart contract implementation, yield farmers aresafefrom forced liquidation through flash loan attacks. Still, the attacker can perform manual sequential attack vector or the miner can be the attacker. We will discuss more on this topic in future articles.

# Too Math; Don't Read (TM;DR)

Here's a brief version:

**5% Liquidation Bonus**and**2 ETH Minimum Debt Size**are to incentivize liquidators to liquidate positions at risk, earning sufficient ETH to pay gas fees.**3% Bounty Reward**is to incentivize bounty hunters to reinvest farmed yields__at least once per day__, to further maximize everyone’s profit.**70% Work Factor**and**80% Kill Factor***are to allow yield farmers to yield farm with high leverage (up to 3.33x) while opened positions can stay solvent even in high fluctuation of ETH prices.

For example, if a user opens a position with 3x leverage to farm on Uniswap ETH/USDT pool when ETH@$400, then the user's position will be at risk of liquidation when ETH price hits ~$576, a ~44% price increase, which is unlikely to happen within a few seconds/minutes.**10% APY Borrower’s Interest Rate**is to balance between the yield farmer’s risk (volatility of available yield farming’s 20-25% APY) and high rewards for ETH lenders.

*Note: The values 70% and 80% are pool-specific values. The values are for the 4 initial Uniswap farming pools due to the fact that they have deep liquidity and that ETH is relatively stable, relative to other altcoins.

# Risk Analysis

We provide a more detailed risk analysis for each of the above setting.

## 5% Liquidation Bonus & 2 ETH Min Debt Size 💧💵

__GOAL 🥅__: Provide sufficient incentive for liquidating positions at risk.__REQ. 📝__: Liquidation bonus > gas fee.__RESULT 📈__: In the worst case assumed, liquidation bonus \(\ge\) 0.1 ETH while gas fee \(\le\) 0.08 ETH. ✅__ANALYSIS 🤔__:

**5% Liquidation bonus**: With 5% liquidation bonus and 2 ETH minimum debt size, a successful liquidation guarantees liquidation bonus of at least \(5\%\cdot 2\) ETH = **0.1 ETH**.

**Gas fee** \(\le\) (400k gas) * (200 gwei/gas) = **0.08 ETH.**

Note 1: If liquidator acts at 80% debt ratio, the position value will be 2.5 ETH, providing the liquidator with 0.125 ETH bonus.

Note 2: In practice, liquidation bonus grows proportionally with position size while gas fee is constant, so incentives can be much higher.

## 3% Bounty Reward 💰

__GOAL 🥅__: Provide sufficient incentive for reinvesting at least every 24 hours__REQ. 📝__: Bounty reward > gas fee__RESULT 📈__: In the worst case assumed, bounty reward > **0.16 ETH** while gas fee \(\le\) **0.08 ETH**. ✅__ANALYSIS 🤔__: We assume:

- Total TVL of at least $5M
- ETH price < $500
- Farming APY > 20% (Uniswap APY at the time of writing)

**Bounty reward.** The 1-day reinvest bounty reward is at least

$5000000 * (1ETH/$500) * (20%/365) * 3% > **0.16 ETH**.

**Gas fee** \(\le\) (600k gas) * (200 gwei/gas) = **0.12 ETH**.

Note 1: With the current assumption, reinvest should happen roughly every 18 hours, when the reward is gaining profit.

Note 2: We assumed low TVL, high ETH price, and low farming APY. In practice, the reward can be much greater than stated, providing automatic reinvest incentive much more often.

## 70% Work Factor & 80% Kill Factor (Part I) 💥

Part I: Risk analysis for small positions.

__GOAL 🥅__: Provide yield farmers with sufficient liquidation safety, i.e., with sufficient tolerance to price volatility.__REQ. 📝__: Small positions should be able to tolerate up to a certain amount of price fluctuation before being at risk of liquidation.__RESULT 📈__: Small newly opened positions with maximum leverage (3.33x) can tolerate up to **~30% ETH** price increase (relative to farming token price), or equivalently, **~23%** farming token price drop (relative to ETH), before being at risk of liquidation.

For example, if Alice opens a new (small) position to farm on Uniswap ETH/USDT pool with 3.33x leverage when ETH@**$400**. Then, her position will be at risk when ETH price hits ~**$522**. ✅__ANALYSIS 🤔__: For small positions, we assume no slippage from swapping and no swap fee.

Let \(P\) be the ETH price (in USDT) when position is opened, and

let \(P'\) be the ETH price (in USDT) that causes the position to be at liquidation risk.

The goal is to find \(P'\) (in terms of \(P\)).

For simplicity, suppose the user opens a position worth **100 ETH** at ETH price \(P\) and 3.33x leverage (supply 30 ETH and borrow 70 ETH). Half of the position gets swapped to USDT, so the position becomes** 50 ETH + 50\(P\) USDT**, and gets converted to LP pool shares. Note that debt = 70 ETH.

When ETH market price becomes \(P'\), the pool also rebalances, so LP pool shares can instead withdraw **50\(\sqrt{P/P'}\) ETH + 50\(\sqrt{P\cdot P'}\) USDT**. By swapping USDT portion back to ETH, the user gets **50\(\sqrt{P/P'}\) ETH**.

So, the position's worth is now **100\(\sqrt{P/P'}\) ETH**.

Since the position will be at liquidation risk when position's value hits **87.5 ETH** (when the debt hits 80% the position's value).

Solving 100\(\sqrt{P/P'}\) ETH = 87.5 ETH yields

$$\frac{P'}{P} = \left(\frac{100}{87.5}\right)^2 = 1.3061.$$

Thus, positions with 3.33x leverage can tolerate up to **~30% ETH** **price increase**, relative to USDT (deducting 2*0.3% swap fee from 2 swaps). Equivalently, they can tolerate up to **~23% USDT** **price drop**, relative to ETH.

## 70% Work Factor & 80% Kill Factor (Part II) 💥

Part II: Risk analysis for larger positions.

__GOAL 🥅__: Provide yield farmers with sufficient liquidation safety, i.e., with sufficient tolerance to price volatility.__REQ. 📝__: Larger positions should still be able to tolerate up to a certain amount of price fluctuation before being at risk of liquidation.__RESULT 📈__: Larger newly opened positions (<2% pool’s total value) with maximum leverage (3.33x) can tolerate up to **~25%** ETH price increase (relative to farming token price), or equivalently,** ~20%** farming token price drop (relative to ETH), before being at risk of liquidation.

For example, if Alice opens a new (large) position to farm on Uniswap ETH/USDT pool with 3.33x leverage when ETH@**$400**. Then, her position will be at risk when ETH price hits ~**$480**. ✅__ANALYSIS 🤔__: We assume no swap fee for simplicity, and like the previous analysis, assume the user wants to farm on ETH/USDT Uniswap pool.

Let \(P\) be the ETH price (in USDT) when position is opened, and

let \(P'\) be the ETH price (in USDT) that causes the position to be at liquidation risk.

We proceed in steps:

- Initially, let the pool has assets
**\(k/ \sqrt{P}\) ETH + \(k\sqrt{P}\) USDT**(at equilibrium). - Now, suppose the user has
**\((c^2+2c)\cdot k/\sqrt{P}\) ETH**, for some constant \(c\). - The user swaps in \(c\cdot k\sqrt{P}\) ETH and gets \(\frac{c}{c+1}\cdot k\sqrt{P}\) USDT. The user now has
**\((c^2+c)\cdot k/\sqrt{P}\) ETH + \(\frac{c}{1+c}\cdot k\sqrt{P}\) USDT.** - The pool now has
**\((1+c)\cdot k/ \sqrt{P}\) ETH + \(\frac{1}{1+c}\cdot k\sqrt{P}\) USDT**. - The user supplies liquidity to the pool. The pool now has
**\((1+c)^2\cdot k/ \sqrt{P}\) ETH + \(k\sqrt{P}\) USDT**, and the user holds \(\frac{c}{1+c}\) portion of the total LP shares. - When ETH price becomes \(P'\), the pool at equilibrium becomes
**\((1+c)\cdot k/ \sqrt{P'}\) ETH + \((1+c)\cdot k\sqrt{P'}\) USDT**. - Withdrawing the received amount of LP shares and swapping to ETH, the pool will be left with
**\(\frac{1}{1+c}\cdot k/ \sqrt{P'}\) ETH + \((1+c)\cdot k\sqrt{P'}\) USDT**. - So, the user's position is now worth
**\(\frac{c^2+2c}{1+c}\cdot k/\sqrt{P'}\) ETH**.

Assuming the user opens a position with at 70% work factor, and the kill factor is at 80%, then we solve

$$ \frac{0.7 \cdot (c^2+2c)\cdot k/\sqrt{P}}{\frac{c^2+2c}{1+c}\cdot k/\sqrt{P'}} = 0.8, $$

or equivalently,

$$ \frac{P'}{P} = \frac{1}{(1+c)^2}\cdot \left(\frac{0.8}{0.7}\right)^2 . $$

When **\(c = 0.04\)**, the opening position size is worth \(\frac{c^2+2c}{2} \approx 0.04\) of the pool's value. The value \(P'/P\) is roughly 1.20, giving **~20%** ETH price increase tolerance.

Here is the table for price tolerance for each value of \(c\).*

c | Pool's Fraction | ETH price increase tolerance | USDT price drop tolerance |
---|---|---|---|

0 | 0% | 30.61% | 23.44% |

0.001 | 0.10% | 30.35% | 23.28% |

0.002 | 0.20% | 30.09% | 23.13% |

0.003 | 0.30% | 29.83% | 22.98% |

0.004 | 0.40% | 29.57% | 22.82% |

0.005 | 0.50% | 29.32% | 22.67% |

0.01 | 1.01% | 28.04% | 21.90% |

0.02 | 2.02% | 25.54% | 20.34% |

0.03 | 3.04% | 23.11% | 18.77% |

0.04 | 4.08% | 20.76% | 17.19% |

0.05 | 5.13% | 18.47% | 15.59% |

0.10 | 10.50% | 7.94% | 7.36% |

*Note: This calculation ignores 0.3% swap fee on 2 swaps. Simply subtract 0.6% from the price tolerance to get an approximation of price tolerance with swap fee included.

## Interest Rate Model

At first we started out with 10% fixed borrow interest rate to balance between ETH lenders’ reward and yield farmers’ risk. Lender's interest rate is calculated based on borrower's interest rate * asset utilization rate (this has not changed).

However, **within 15 hours since launch, Alpha Homora had accumulated a total value locked of > 17,600 ETH ($6M)**. Given this excessive demand to use Alpha Homora, we had to update the interest rate model to be dynamic, scale faster, and offer safer leveraged yield farming for everyone. ✅

See how borrower's interest rate and lender's interest rate here: https://blog.alphafinance.io/3-changes/

# Leverage Calculator 🧮

How much leverage should a user borrow while being safe from liquidation? A profit & loss calculator for your leverage can be found on this spreadsheet.

Please make a local copy of the spreadsheet before proceeding.

Note: The calculation ignores slippage. Use for approximation only.

# Final Note 📄

Hopefully each stakeholder now understands the risk involved in participating in Alpha Homora! Although the protocol allows yield farmers to earn higher APY with leveraged borrowing, yield farmers should remain *cautious* as the protocol is also risky, for example, you may lose your opened position from liquidation when asset prices are volatile.

Note: By yield farming on Alpha Homora, you are inherently half-shorting ETH, selling half of ETH to farming tokens. So, if ETH price goes up, your position's value will decrease.

# Joining as Beta Testers 👩🔬👨🔬

Feeling excited about this product and curious on what's more to come? Interested in joining as beta testers?

Fill out this form, and we'll get back to you!

### About Alpha

Alpha Finance Lab is an ecosystem of DeFi products, starting on Binance Smart Chain and Ethereum. Alpha Finance Lab is focused on building an ecosystem of automated yield-maximizing Alpha products that interoperate to bring optimal alpha to users on a cross-chain level.

We are moving at a rapid pace, so we encourage everyone to join our Discord for the latest updates, follow us on Twitter, or read more about us on our Blog!