Share articles to

Academy Industry Analysis Article
DeFi Liquidity mining DeFi Digest OKEx Insights

DeFi market surpasses $40 billion as Alpha Finance suffers worst flash loan attack in history

2021.02.17 Matthew Lam

OKEx Insights’ DeFi Digest is a weekly examination of the decentralized finance industry.

DeFi Digest image

The decentralized finance market again reached new highs off the back of BTC hitting the $50,000 milestone across global exchanges. The total value locked in DeFi products first surpassed $40 billion on Feb. 12 and has posted an 8% weekly gain.

The continued rise in the DeFi market has been evident in the lending sphere, where total borrowing volumes rose by 13% to $7.23 billion. Compound dominated the lending market with a 55% share.

The weekly average trading volume of decentralized exchanges dropped slightly to $2.28 billion, as of the time of this writing. Uniswap — which recently processed a cumulative volume of over $100 billion — continues to lead DEXs with a 38% market share. Aave replaced SushiSwap as the largest liquidity pool this week, with its total value locked amounting to $1.52 billion.

CategoryKey statisticsAmountWeekly % change
OverallTotal value locked (USD)$39.94 billion8%
Market dominance (%)Maker (16%)
LendingTotal borrowing vol.$7.23 billion13%
Market dominance (%)Compound (55%)
DEXsWeekly avg. trading vol.$2.28 billion-6%
Market dominance (%)Uniswap (38%)
Yield farmingLargest liquidity poolAave ($1.52 billion)
This week, both the total value locked and borrowing volumes rose, while weekly DEX trading volumes dropped 6%. Source: DeFi Pulse and DeBank

DeFi’s largest flash loan attack

While DeFi market participants were hyped about the $40 billion TVL milestone this week, Alpha Finance suffered a flash loan attack that led to an approximate loss of $38 million. This surpassed Harvest Finance’s hack of $34 million and became the largest flash loan attack in DeFi’s relatively brief history.

The Alpha Finance team first declared the flash loan attack on Feb. 13. The team released a post-mortem the next day to share the details of the Alpha Homora V2 exploit. 

The post-mortem stated that the attacker launched a complex exploit involving more than nine transactions, which was summarized in 13 steps. The team also listed the following loopholes in the Alpha Homora V2 smart contract that made the exploit possible:

  1. HomoraBankv2 had an sUSD pool that was under preparation and not publicly released. The sUSD pool had no liquidity and the attacker could inflate both the total debt amount and total debt share.
  2. The resolveReserve function could increase total debt without increasing the total debt share. This function could be executed by any user.
  3. There was a rounding miscalculation in the borrow function calculation. This was only applicable when the attacker was the sole borrower.
  4. HomoraBankv2 accepted any customized spell from users, given that the amount of collateral is larger than the borrowing amount. (A spell in Alpha Finance is similar to a strategy in Yearn Finance.)

To launch the complex flash loan attack, the attacker first created a spell in Alpha Homora V2. The attacker then swapped ETH to sUSD on Uniswap and deposited sUSD to the Iron Bank of Cream Finance. To manipulate the sUSD pool, the attacker borrowed 1,000e18 sUSD and bypassed the security check by depositing the liquidity pool token of UNI-WETH as collateral. The attacker obtained 1,000e18 sUSD debt shares in return. The attacker leveraged the first and fourth loopholes mentioned earlier to perform these steps.

While the attacker was the sole borrower in this Alpha Finance exploit, they capitalized on the rounding miscalculation in the borrow function by repaying the sUSD share of one less than the total borrowing amount. The attacker then executed the resolveReserve function on the sUSD bank, leading to an accrued debt of 19,709 billion sUSD as the total debt share remained one. 

The attacker repeated the above procedures 26 times and doubled the borrowed amount each time. As each borrowing was one less than the total debt value, this led to a corresponding borrowing share of zero, and the protocol could not recognize the borrowing. The attacker then obtained flash loans from Aave and laundered the funds in Curve.

Alpha Finance’s reaction 

As of the time of writing, the attacker held 10,925 ETH in their wallet address. While the attacker has deposited over $10 million worth of stablecoins under Curve’s gauge, they returned 1,000 ETH to the Alpha Homora V2 and Cream V2 developers, respectively. A tiny portion of the stolen ETH was sent to Tornado and Gitcoin Grant. The Alpha team estimated a total fund loss of $38 million.

The Alpha team stressed that the borrowing from attackers was a debt between the Alpha Homora V2 and Cream V2 platforms, meaning that users’ funds were not involved in this incident. The Alpha Finance team took the following immediate actions to halt the exploit:

  • It removed the borrowing and repaying functionality of sUSD, preventing users from opening new leveraged positions.
  • It ensured that only white-listed spells could be executed.
  • It ensured that only the governor could execute the “resolveReserve” function.
  • It contacted various parties to black-list the attacker’s address.

While liquidity providers cannot borrow in Alpha, they can still add collateral, repay debt, close positions and harvest their farmed tokens. Lenders in Alpha Finance, on the other hand, can lend and withdraw assets, as usual.

To mitigate the negative impact brought to Alpha Finance’s users, the team is partnering with Yearn Finance founder Andre Cronje and the Cream Finance team to resolve the debt.

As a medium- to long-term solution, the Alpha Finance team continued to seek external auditors and trusted developers to review their smart contracts. The team is also considering launching new and creative bug bounty programs for other DeFi protocols to follow.

OKEx Insights presents market analyses, in-depth features and curated news from crypto professionals.

Follow OKEx Insights on Twitter and Telegram.

Disclaimer: This material should not be taken as the basis for making investment decisions, nor be construed as a recommendation to engage in investment transactions. Trading digital assets involve significant risk and can result in the loss of your invested capital. You should ensure that you fully understand the risk involved and take into consideration your level of experience, investment objectives and seek independent financial advice if necessary.



%d bloggers like this: