The WhitePaper Reading Club Singapore [19]
Hyperliquid (HL) Decentralized Perp Exchange L1 13 Aug 2024
HotStuff or HotFuzz? Eugene (Avim), JingYi (Monad), Xulian (Hyperliquid), Arnold (the Block), Nishant (OffChain Labs), Rongxin (WPRC)
Summary
Onchain Binance with purpose-built 100k TPS L1
Why This Is Important
For finance to move onchain (with it trillions of dollars of value & billions of users), it needs a vastly more performant decentralized trading environment. Currently few DEXs can match their CEXs counterparts in fees and performance, but Hyperliquid is fast closing the gap via a purpose-built L1 with 100k TPS, with potential to scale to millions TPS as the need arises.
Overview of Hyperliquid: The Hyperliquid L1 is a highly performant blockchain designed to support the financial system. The first flagship product is Hyperliquid, the leading order book perps DEX by volume, open interest, and users. Hyperliquid Labs is one of the only teams building product and infrastructure in parallel. Jointly optimizing the full stack allows HL to deliver magical results for the end user, already converting tens of thousands of CEX traders to Hyperliquid.
Team
Founded by Jeff Yan and iliensinc, Harvard graduates in computer science and mathematics. Team of 8 included 5 engineers and 3 non-technical members from MIT, Caltech, and the University of Waterloo. Jeff Yan, a former quantitative analyst at Hudson River Trading, founded Chameleon Trading, a top crypto high-frequency trading firm. Most of Hyperliquid’s team came from Chameleon Trading. Co-founder iliensinc has a Twitter account but rarely posts. A “chief intern officer” and other volunteers with Chinese pinyin names were noted on Twitter, but there’s no information about Hyperliquid on LinkedIn.
Investors
They are not taking any VC investment, which is rare for such a popular Web3 product. Hyperliquid could have easily raised at a billion dollar valuation but the team consciously chose not to take investments and bootstrapped everything. This also means that community may get a larger share of the token supply upon TGE since there are no VC allocations.
Discussion Notes
Market Makers: (i) CEX and DEX markets are dominated by bots (est 90%), but Hyperliquid (HL) doesn’t attract MMs (iii) as they don’t get speed advantage, and liquidity isn’t deep enough yet. (iii) Also front-running & sandwich attacks by MEV bots are an issue (but HL doesn’t have MEV because HL guarantees ordering). (iv) Traders like HL because there is no MMs. (v) However, traders are making a loss ($38M - Link). Mostly the main HL MM pool is profitable. (vi) HIP-2 introduces parameters similar to Uniswap V3, enabling smaller market cap projects to bootstrap liquidity. Custom L1: Projects will create purpose built chain due to business constraints and allows for control of the stack. (i) E.g StraitsX, working with Alipay and Grab Pay, needs xSGD transactions to complete in under 5 seconds. (ii) They use Ava subnet because they can remove general-purpose opcodes in the VM. Ava also makes it easy to move assets across subnets. Centralization + Future: HL is currently centralized, with limited access to run nodes and unclear approval processes. (ii) But, they are still building trust with users by being transparent through their L1, (iii) they will likely open up for broader participation in the future and may extends beyond trading, maybe to develop consumer apps in future. MEV: A MEV sandwich attack in DeFi occurs when a trader detects a pending large transaction, front-runs it with a buy order to inflate the price, lets the victim’s transaction execute at the higher price, and then back-runs with a quick sell to profit, effectively “sandwiching” the victim’s trade.
Opinions
Innovation: Fully on-chain order book. One-click trading with no wallet approvals. Interesting note: One of the few L1s with no VC funding (entirely bootstrapped). Most L1s are general purpose chain; Hyperliquid L1 is specialized. Risks: (i) Currently most nodes are operated centrally - unproven if nodes can be run in a decentralized manner yet ensuring high chain performance (ii) Using only USDC could mean that all trades will be open to Circle censorship and depeg risks? (iii) Oracle attacks: it seems like they are using their own oracle infra for derivatives, where minor price movements can have large impacts. Question: Are validators incentives to be truthful? Pressing Questions: (i) They want to decentralize the platform eventually, so is the orderbook hosted on-chain? If it is not, then can it eventually be? How will that happen?(ii) Where (on-chain) is the aggregation of oracle prices calculated? Performing this calculation every 3s is intense, posting this aggregation on-chain, even more so. Will we expect running a HL validator node to be v computationally intensive?
Competitors
Other on-chain perp exchanges such as dYdX, SynFutures, RabbitX. Their combined daily volume typically still don’t beat Hyperliquid’s, whose daily volumes frequently surpass $1B.
Financial Components
Why start with Perps: (i) It is a realistic real-world application that demands more infrastructure than any existing L1 can handle, (ii) is the most valuable vertical in DeFi benefiting most user-built applications, and (iii) drives real users to interact with the underlying L1 infrastructure.
| Perp Assets | Hyperliquid currently supports trading of 100+ assets. Assets are added based on community input. Ultimately HL will feature a decentralized and permissionless listing process. Max leverage varies by asset, ranging from 3-50x. The maintenance margin is half of the initial margin at max leverage. E.g., if max leverage is 20x, the maintenance margin is 2.5%. Question: What is maintenance margin? Answer: Maintenance margin is also widely used in tradfi. It is the minimum sum of money a trader need to have in their margin account to keep the position open. |
|---|---|
| Fees | At the most basic tier, HL’s Taker fee is 0.035% and Maker free is 0.010%; This is competitive vs Binance’s Futures’ rate at 0.036% and 0.0144% respectively (also basic tier but applying BNB discounts for realistic benchmarking). |
| Margin | When opening a position, a margin mode is selected. Cross margin is the default, which allows for maximal capital efficiency by sharing collateral between all other cross margin positions. Isolated margin is also supported, which allows an asset's collateral to be constrained to that asset. Liquidations in that asset do not affect other isolated positions or cross positions. Question: Did cross margin also contribute to FTX’s crash? Answer: Cross margin is just a tool, FTX’s crash is due to poor risk management mainly (overly leveraged). But yes it did contribute to FTX’s crash. |
| Liquidations | When the account equity drops below maintenance margin, the positions are first attempted to be entirely closed by sending market orders the book. If the positions are entirely or partially closed such that the maintenance margin requirements are met, any remaining collateral remains with the trader. If the account equity drops below 2/3 of the maintenance margin without successful liquidation through the book, a backstop liquidation happens through the liquidator vault. (i) When a cross position is backstop liquidated, the trader's cross positions and cross margin are all transferred to the liquidator. In particular, if the trader has no isolated positions, the trader ends up with zero account equity. (ii) When an isolated position is backstop liquidated, that isolated position and isolated margin are transferred to the liquidator. The user's cross margin and positions are untouched. Question: So if you can’t repay margin, all your other assets are sold as well? |
| Funding rate | The funding rate on Hyperliquid is paid every hour (added or subtracted from the balance the contract holders at the funding interval).Funding rates for crypto perpetual contracts are a mechanism that is used to ensure the price of the contract stays close to the underlying asset's price. The funding rate is a periodic fee that is paid by one side of the contract (either long or short) to the other side. Funding is purely peer-to-peer and no fees are collected on the payments. The rate is calculated based on the difference between the contract's price and the spot price of the underlying asset. This represents the difference in cost to borrow USD versus spot crypto. |
| Insurance | A portion of net fees collected by Hyperliquid are directed towards the Hyperliquid insurance fund. Though "fund" is used to match the nomenclature of other exchanges, the Hyperliquid insurance fund will be governed by the usual decentralized L1 governance procedure. For special circumstances where the platform behaved unexpectedly, the insurance fund may be used to pay affected users. The purpose of what is called the "insurance fund" on other platforms is to take unwanted liquidations. This specific role of the insurance fund is performed by the Liquidator vault, which is the only liquidator on Hyperliquid. |
| Auto Deleverage | Auto-deleveraging strictly ensures that the platform stays solvent, as an important final safeguard. If a user's account value or isolated position value becomes negative, the users on the opposite side of the position are ranked by unrealized pnl & leverage used. Those traders' positions are closed at previous oracle price against the now underwater user, ensuring that platform has no bad debt. |
| Vaults | On Hyperliquid, vaults are a powerful and flexible primitive built into the Hyperliquid L1. Strategies running on vaults benefit from the same advanced features as the DEX, from liquidations of overleveraged accounts to high throughput market making strategies. No more depositing into vaults that simply rebalance two tokens. Anyone can deposit into a vault to earn a share of the profits: DAOs, protocols, institutions, or individuals. In exchange, the vault owner receives 10% of the total profits. (Note: Protocol vaults do not have any fees or profit share). Vaults can be managed by an individual trader or automated by a market maker. Of course, all strategies come with their own risk, and users should assess the risks and performance history of a vault before depositing. |
| HIP | HIP is the Hyperliquid Improvement Proposal, which simply means standards implemented on Hyperliquid. There are currently only 2 HIPs, but there will be more in future as more standards are required (i) HIP-1: Native token standardHIP-1 is a capped supply fungible token standard native to Hyperliquid. The analogous equivalent is ERC20 on ETH and SPL on SOL. It also features onchain spot order books between pairs of HIP-1 tokens.(ii) HIP-2: HyperliquidityThough HIP-1 is sufficient as a permissionless token standard, in practice it is often crucial to bootstrap liquidity. One of Hyperliquid's core design principles is that liquidity should be democratized. For perps trading, Hyperliquid can quote deep and tight liquidity based on CEX perp and spot prices, but a new model is needed for HIP-1 tokens that are in early phases of price discovery. HIP-2 solves this by aiding new HIP-1 tokens during early price discovery, providing sufficient liquidity on demand to buyers and sellers at key levels. HIP-2 is inspired by Uniswap, while interoperating with a native onchain order book to support sophisticated order book liquidity from end users. HIP-2 is a fully decentralized onchain strategy that is part of the block transition logic of the Hyperliquid L1. Unlike conventional automated order book strategies, there are no operators. The strategy logic is secured by the same consensus that operates the order book itself. Like smart-contract based pools on general purpose chains, HIP-2 requires no maintenance in the form of user transactions. One key improvement is that Hyperliquidity participates in a general purpose order book. Active liquidity providers can join in liquidity provision alongside Hyperliquidity at any time, allowing markets to adapt to increasing demand for liquidity. |
Technical Aspects
| L1 | (i) Consensus: Originally Tendermint, now moving to custom HyperBFT which is inspired by HotStuff and or HotStuff-2 -used by Aptos, Sui [REF 1]. Traditional consensus used by blockchain follows the Practical Byzantine Fault Tolerance (PBFT), but the issue is that there’s a lot of communication overhead O(n^3), which makes it difficult to scale well. HotStuff and HotStuff-2 reduces the communication overhead to O(n) which makes it scaling linearly with the number of nodes. (ii) EVM-based L1 (iii) Interacting with chain is mostly done using python SDK [REF 2] Pipelined Approach: The commitment to one view serves as the vote for the subsequent view.Network: The leader consolidates vote and commit messages before redistributing them, achieving linear communication efficiency and linear overhead.Responsiveness: An honest leader can consistently attain consensus within a time frame dependent on network delays, not on timeouts.An additional round of communication is necessary to ensure responsiveness |
|---|---|
| Bridge | (i) Only allow for bridging of USDC from Arbitrum to Hyperliquid L1. Bridged assets are validated with a ⅔ set, the contract is here [REF 4]. (ii) Withdrawals: Validators approve withdrawals, which are then verified and held for a dispute period before they can be finalized and funds released. Deposits: Validators verify and approve deposits to ensure funds are correctly credited to the system. Signatures: Signatures for transactions are collected in the same order as the validator list to ensure consistency. Lockers: Approved addresses can lock the system if there are issues, requiring more approvals to unlock it again. Finalizers: Certain addresses are responsible for finalizing transactions, adding an extra security layer by preventing unauthorized access .Unlocking: Unlocking the system sets and finalizes a new validator list, confirmed by approvals from cold wallets. |
| API Servers | The API servers are permissionless, and non-validating to create custom API servers for load balancing. A single API server listens for block updates, maintains a blockchain state, and forwards client requests to nodes. This design supports familiar APIs for traders and addresses load balancing and DDOS protection. |
| Clearinghouse | Perps clearinghouse manages the perps margin state for each address, which includes balance and position, and liquidates the position as necessary with price feed from the Oracle. |
| Validators | Oracles: (i) The validators publish spot oracle prices for each perp asset every 3 seconds, computed via a weighted median of 7 different CEXs. The oracle prices are used to compute funding rates and a component in the “mark price” which is used for margining, liquidations, and triggering TP/SL orders.Bridging: (ii) Validators manage transactions and security. They use two types of wallets for signing (hot and cold) and need approval from 2/3 of the group to process withdrawals and update the validator list. These actions can be paused if issues arise, requiring a higher level of approval to resume. Validators also handle deposits and check that transactions match the approved validator list. Additionally, they can lock the system if there’s a problem and finalize withdrawals once everything is verified. |
| Orderbook | Hyperliquid L1 state includes an order book for each asset. The order book works in essentially the same way as all CEXs. Orders are added where price is an integer multiple of the tick size, and size is an integer multiple of lot size. The orders are matched in price-time priority. |
Native token: $PURR is the Hyperliquid memecoin airdropped to points holders, and the first HIP-1 token. Question: It says this is a memecoin. Answer: It is a memecoin.
Questions
- Does it benefit token holders, early VCs, or Builders? Hyperliquid should benefit points holders (users) the most. No VC for Hyperliquid. Builders are rewarded to a certain extent - e.g. Rage Trade who launched their token on HL managed to raise $6m in record time.
- Does it benefit the overall web3 ecosystem? Yes, mainly enabling spots and perps trading on-chain with the similar level of UIUX as CEXs
- Does it enable more people to come into web3? For now, no, as HL traders are mostly Web3 natives. However, the UIUX is quite friendly to non-crypto natives, with strong potential to onboard Web2 traders. Caveat being on/off-ramp needs to be improved (currently only supports USDC).
REF:
- Comparison of HotStuff to other PBFT, TenderMint: https://decentralizedthoughts.github.io/2023-04-01-hotstuff-2
- Hyperliquid Python SDK: https://github.com/hyperliquid-dex/hyperliquid-python-sdk/blob/master/examples/basic_market_order.py
- Main documentation: https://hyperliquid.gitbook.io/hyperliquid-docs
- Bridge Ethereum Contract: https://github.com/hyperliquid-dex/contracts/blob/master/Bridge2.sol
- Github: https://github.com/hyperliquid-dex