Hyperliquid 백서

Hyperliquid

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 27쪽 중 7쪽

mark price, which combines external CEX prices with Hyperliquid's book state. This makes liquidations more robust than using a single instantaneous book price. During times of high volatility or on highly leveraged positions, mark price may be significantly different from book price. It is recommended to use the exact formula for precise monitoring of liquidations. ### Motivation As described above, the majority of liquidations on Hyperliquid are sent directly to the order book. This allows all users to compete for the liquidation flow, and allows the liquidated user to keep any remaining margin. Unlike CEXs there is no clearance fee on liquidations.  The resulting system is transparent and prioritizes retaining as much capital as possible for the liquidated user. ### Partial Liquidations For liquidatable positions larger than 100k USDC (10k USDC on testnet for easier testing), only 20% of the position will be sent as a market liquidation order to the book. After a block where any position of a user is partially liquidated, there is a cooldown period of 30 seconds. During this cooldown period, all market liquidation orders for that user will be for the entire position. ### Liquidator Vault Backstop liquidations on Hyperliquid are democratized through the liquidator vault, which is a component strategy of HLP. Positions that are below 2/3 of the maintenance margin can be taken over by the liquidator vault.  On average, backstop liquidations are profitable for the liquidator. On most venues, this profit goes to the exchange operator or privileged market makers who internalize the flow. On Hyperliquid, the pnl stream from liquidations go entirely to the community through HLP.  ### Computing Liquidation Price When entering a trade, an estimated liquidation price is shown. This estimation may be inaccurate compared to the position's estimated liquidation price due to changing liquidity on the book. Once a position is opened, a liquidation price is shown. This price has the certainty of the entry price, but still may not be the actual liquidation price due to funding payments or changes in unrealized pnl in other positions (for cross margin positions). The actual liquidation price is independent on the leverage set for cross margin positions. A cross margin position at lower leverage simply uses more collateral. The liquidation price does depend on leverage set for isolated margin positions, because the amount of isolated margin allocated depends on the initial margin set. When there is insufficient margin to make the trade, the liquidation price estimate assumes that the account is topped up to the initial margin requirement.  The precise formula for the liquidation price of a position is `liq_price = price - side * margin_available / position_size / (1 - l * side)` where `l = 1 / MAINTENANCE_LEVERAGE` . For assets with margin tiers, maintenance leverage depends on the unique margin tier corresponding to the position value at the liquidation price. `side = 1 for long and -1 for short` `margin_available (cross) = account_value - maintenance_margin_required` `margin_available (isolated) = isolated_margin - maintenance_margin_required` # Auto-deleveraging Auto-deleveraging strictly ensures that the platform stays solvent. 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 and leverage used. Backstop liquidated positions have no special treatment in the ADL queue logic. The specific sorting index to determine the affected users in profit is `(mark_price / entry_price) * (notional_position / account_value)`. Those traders' positions are closed at the previous mark price against the now underwater user, ensuring that the platform has no bad debt.   Auto-deleveraging is an important final safeguard on the solvency of the platform. There is a strict invariant that under all operations, a user who has no open positions will not socialize any losses of the platform. # Funding ### Overview 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. For consistency with CEXs, interest rate component is predetermined at 0.01% every 8 hours, which is 0.00125% every hour, or 11.6% APR paid to short. This represents the difference in cost to borrow USD versus spot crypto.  The premium component fluctuates based on the difference between the perpetual contract's price and the underlying spot oracle price. If the contract's price is higher than the oracle price, the premium and hence the funding rate will be positive, and the long position will pay the short position. Conversely, if the contract's price is lower than the spot price, the funding rate will be negative, and the short position will pay the long position. The funding rate on Hyperliquid is paid every hour. The funding rate is added or subtracted from the balance of contract holders at the funding interval. Funding rates are designed to prevent large price disparities between the perpetual contract and the underlying asset. When the funding rate is high, it can incentivize traders to take the opposite position and help to bring the contract's price closer to the spot price of the underlying asset. ### Technical details Funding on Hyperliquid is designed to closely match the process used by centralized perpetual exchanges.  The funding rate formula applies to 8 hour funding rate. However, funding is paid every hour at one eighth of the computed rate for each hour. The specific formula is `Funding Rate (F) = Average Premium Index (P) + clamp (interest rate - Premium Index (P), -0.0005, 0.0005)`. The premium is sampled every 5 seconds and averaged over the hour. As described in the [clearinghouse](/hyperliquid-docs/hypercore/clearinghouse) section, the oracle prices are computed by each validator as the weighted median of CEX spot prices for each asset, with weights depending on the liquidity of the CEX.  `premium = impact_price_difference / oracle_price`  where  `impact_price_difference = max(impact_bid_px - oracle_px, 0) - max(oracle_px - impact_ask_px, 0)` . and `impact_bid_px` and `impact_ask_px` are the average execution prices to trade`impact_notional_usd` on the bid and ask sides, respectively. See the contract specifications for the impact notional used, as well as other contract specific parameters. For HIP-3 perps, a more responsive premium formula is used to allow deployers to express a larger range of funding behaviors using the funding rate multiplier and interest rate: `premium = (0.5 * (impact_bid_px + impact_ask_px) / oracle_px) - 1` . Funding on Hyperliquid is capped at 4%/hour. Note that this is much less aggressive capping than CEX counterparts. The funding cap and funding interval do not depend on the asset.  Note that the funding payment at the end of the interval is `position_size * oracle_price * funding_rate`. In particular, the spot oracle price is used to convert the position size to notional value, *not the mark price.* ### Numerical Example Here is an explicit example computation: 1. The interest rate is 0.01% (fixed). 2. The perpetual contract is trading at a premium, with the impact bid price being $10,100, and the spot price at $10,000. 3. The premium index is calculated as the difference between the two prices, which is $100 in this case. 4. The funding interval is 1 hour. 5. You hold a long position of 10 contracts, each representing 1 BTC. First, calculate the premium: Premium = (Impact bid price - Spot Price) / Spot Price = ($10,100 - $10,000) / $10,000 Premium = 0.01 (or 1%) Next, clamp the interest rate minus the premium rate at 0.05%: Clamped Difference = min(max(Interest Rate - Premium Rate, -0.05%), 0.05%)  Clamped Difference = min(max(0.01% - 1%, -0.05%), 0.05%)  Clamped Difference = min(max(-0.99%, -0.05%), 0.05%) Clamped Difference = -0.05% Now, calculate the funding rate: Funding Rate = Premium Rate + Clamped Difference Funding Rate = 1% + (-0.05%)  Funding Rate = 0.95% # Order book The order book works in essentially the same way as all centralized exchanges but is fully on-chain. 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.  See this[ ](/hyperliquid-docs/hypercore/order-book)[section](/hyperliquid-docs/hypercore/order-book) for further details on order book implementation. # Order types ### Order types * Market: An order that executes immediately at the current market price * Limit: An order that executes at the selected limit price or better * Stop Market: A market order that is activated when the price reaches the selected trigger price. For long orders, the trigger price needs to be higher than the mid price. For short orders, the trigger price needs to be lower than the mid price * Stop Limit: A limit order that is activated when the price reaches the selected trigger price * Take Market: A market order that is activated when the price reaches the selected trigger price. For long orders, the trigger price needs to be lower than the mid price. For short orders, the trigger price needs to be higher than the mid price * Take Limit: A limit order that is activated when the price reaches the selected trigger price * Chase: A Post Only (ALO) limit order that automatically re-prices to track the best bid or ask until it is filled or terminated. The order rests one tick above the best bid (for buys) or one tick below the best ask (for sells), or at the best bid/ask when the spread is a single tick. Chase orders run in the browser tab where they are created, and up to 5 can be active at once * Scale: Multiple limit orders in a set price range   * Trailing Stop: A market order that is activated when the mark price retraces from its best level by the selected distance or percentage. For trailing stops that close long positions, or open shorts, the trigger price follows the highest mark price reached since activation. For trailing stops that close short position, or open longs, it follows the lowest. The trigger price never moves in the opposite direction. Trailing stops are available for perp markets * TWAP: A large order divided into smaller suborders and executed at regular intervals, based on order size and running time inputs. Intervals are a minimum of 30 seconds. TWAP suborders have a maximum slippage of 3% * Randomize: If enabled, the size of each sub-order will be adjusted randomly up to ±20% of the original trade size * Trigger Price: The TWAP order will be activated when the mark price reaches the trigger price set * Max/Min Price: The TWAP order will be terminated when the mark price reaches the stop price set ### TWAP details During execution, a TWAP order attempts to meet an execution target which is defined as the elapsed time divided by the total time times the total size. Suborders are sent at a fixed interval, calculated from the total size and running time inputs. Larger orders over shorter durations are split into suborders sent as often as every 30 seconds; smaller orders over longer durations are split into suborders spaced further apart. Running time can be set from 5 minutes to 7 days, with a $100 minimum total order size.\ \ Example: * A $10,000 order over 1 hour is split into \~121 suborders of \~$83, sent every 30 seconds * A $10,000 order over 4 days is split into \~1,000 suborders of \~$10, sent roughly every 6 minutes A suborder is constrained to have a max slippage of 3%. When suborders do not fully fill because of market conditions (e.g., wide spread, low liquidity, etc.), the TWAP may fall behind its execution target. In this case, the TWAP will try to catch up to this execution target during later suborders. These later suborders will be larger but subject to the constraint of 3 times the normal suborder size (defined as total TWAP size divided by number of suborders). It is possible that if too many suborders did not fill then the TWAP order may not fully catch up to the total size by the end. Like normal market orders, TWAP suborders do not fill during the post-only period of a network upgrade. ### Order options * Reduce Only: An order that reduces a current position as opposed to opening a new position in the opposite direction  * Good Til Cancel (GTC): An order that rests on the order book until it is filled or canceled  * Post Only (ALO): An order that is added to the order book but doesn’t execute immediately. It is only executed as a resting order * Immediate or Cancel (IOC): An order that will be canceled if it is not immediately filled * Take Profit: An order that triggers when the Take Profit (TP) price is reached. * Stop Loss: An order that triggers when the Stop Loss (SL) price is reached * TP and SL orders are often used by traders to set targets and protect profits or minimize losses on positions. TP and SL are automatically market orders. You can set a limit price and configure the amount of the position to have a TP or SL # Take profit and stop loss orders (TP/SL) TP/SL orders close your position when a certain profit (resp. loss) has realized on your position. The [mark price](/hyperliquid-docs/trading/robust-price-indices) is used to trigger TP/SL orders.  TP/SL orders can be dragged on the TradingView chart. Note that dragging in a way that causes the order to immediately execute will lead to an error. Usually this prevents user mistakes, but if this is your desired behavior you can manually close the order from the position table or order form.  ### Limit vs Market TP/SL orders Users can choose between TP/SL market and limit orders. TP/SL market orders have a slippage tolerance of 10%. By setting the limit price on TP/SL orders, users can control the slippage tolerance of a triggered order. The more aggressive the limit price, the more likely the TP/SL order will be filled upon triggering, but the higher the potential slippage upon filling.  As a concrete example, a SL order to close a long with trigger price $10 and limit price $10 will hit the book when the mark price drops below $10. If the price drops from $11 to $9 instantly it is quite likely this SL order would rest at $10 instead of filling. However, if the limit price were $8 instead of $10, it's likely to fill at some price between $9 and $8.  ### TP/SL associated with a position TP/SL opened from the position form will have a size equal to the entire position by default. These orders will attempt to close the entire position at the time of trigger. If a specific size is configured on these TP/SL orders, they will be fixed-sized (i.e. they will not resize with the position after being placed). ### TP/SL associated with a parent order (a.k.a one-cancels-other, OCO)  This style of TP/SL is more complicated. Read the below carefully to avoid unexpected outcomes. TP/SL opened from the order form have a fixed size equal to the order they are tied to. If the parent order is fully filled at placement, the children TP and/or SL orders are immediately placed. This behavior is similar to the TP/SL assocated with a position. When the parent order is not fully filled, the children orders enter an untriggered state. The TP/SL orders have not been placed, and upon cancelation of an unfilled parent order, the child TP/SL orders will be canceled. If the trader cancels a partially filled parent order, ***the child TP/SL orders are fully canceled as well***. If the trader desires a TP/SL for the partially filled size, they must do so manually, e.g. by placing a separate TP/SL orders associated with the new position. However, if the parent order is partially filled and then canceled due to insufficient margin, the TP/SL orders will be placed as if the order were fully filled.  In conclusion, ***children TP/SL orders associated with a parent order will be placed if and only if the parent order fully fills or is partially filled followed by a cancelation for insufficient margin***.   # Entry price and pnl On the Hyperliquid DEX, entry price, unrealized pnl, and closed pnl are purely frontend components provided for user convenience. The fundamental accounting is based on margin (balance for spot) and trades.  ### Perps Perp trades are considered `opening` when the absolute value of the position increases. In other words, longing when already long or shorting when already short. For opening trades, the entry price is updated to an average of current entry price and trade price weighted by size. For closing trades, the entry price is kept the same. Unrealized pnl is defined as `side * (mark_price - entry_price) * position_size` where `side = 1` for a long position and `side = -1` for a short position Closed pnl is `fee + side * (mark_price - entry_price) * position_size` for a closing trade and only the fee for an opening trade. ### Spot Spot trades use the same formulas as perps with the following modifications: Spot trades are considered `opening` for buys and `closing` for sells. Transfers are treated as buys or sells at mark price, and genesis distributions are treated as having entry price at `10000 USDC` market cap. Note that while 0 is the correct answer as genesis distributions are not bought, it leads to undefined return on equity.  Pre-existing spot balances are assigned an entry price equal to the first trade or send after the feature was enabled around July 3 08:00 UTC. # Self-trade prevention Trades between the same address cancel the resting order instead of causing a fill. No fees are deducted, nor does the the cancel show up in the trade feed. On CEXs this behavior is often labeled as "expire maker." This is a commonly preferred behavior for market making algorithms, where the aggressing order would like to continue getting fills against liquidity behind the maker order up until the limit price. # Index perpetual contracts Index contracts track a formula instead of a spot asset price as the underlying index, but otherwise function exactly the same as normal perpetual contracts. Instead of tracking the median price across a set of liquid CEXs, index perpetual contracts require the validators to periodically publish the value of the index formula to the Hyperliquid L1. The median of these reported values are then used in place of the spot oracle formula to compute funding rates. ### **NFTI-USD** `NFTI-USD` is an index of blue-chip NFT collections, including Bored Ape Yacht Club, Mutant Ape Yacht Club, Azuki, DeGods, Pudgy Penguins, and Milady Maker.  The index is a 3-minute EMA of the aggregate floor price. The aggregate floor price is sum of the floor price of each collection, with BAYC divided by 10. Floor prices are computed by aggregating OpenSea and Blur. CryptoPunks were not included because they predate the NFT standard and are not listed on these marketplaces.  Floor prices are converted to USDT using the ETH-USDT spot oracle price `Index = 3 minute ema of [(BAYC floor price / 10) + (MAYC floor price) + (Azuki floor price) + (DeGods floor price) + (Pudgy Penguins floor price) + (Milady Maker floor price)] / 10000`   ### FRIEND-USD `FRIEND-USD` is the first index perpetual contract listed by Hyperliquid.  Previously based on community feedback, the top 20 friendtech index rebalanced biweekly. The top subjects were announced by EOD Monday UTC every ot
프로젝트로 돌아가기