Lighter 백서

Lighter

원문

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

by taking them over in ascending order of unrealized PnL. For each position, the LLP takes it over only if doing so would keep the LLP's total account value above the Initial Margin Requirement. Any positions that would cause the LLP to fall below this threshold are instead auto-deleveraged. 5. **Auto-deleveraging (ADL)** When an account has a negative value and the LLP does not have enough capital to cover the losses of the bankrupt account, the exchange initiates auto-deleveraging (ADL) for the bankrupt account’s positions. A bankrupt account, by definition, has at least one open position. The exchange identifies positions on the opposite side of the bankrupt positions and executes trades between these accounts if their zero prices align. This ensures that ADL does not decrease the health of any account, as the execution price cannot be worse than the zero price of the position. When selecting positions for ADL on the opposite side, the system ranks users based on their leverage and unrealized PnL. ### Isolated Liquidations When a users sets a market to the isolated mode, the position will be treated as a separate account and won't be affected by the other positions. The calculations and the flow will be the same as above, but the collateral for an isolated position is called AllocatedMargin. # LLP Strategies LLP funds are held within a single account, which acts as the counterparty to all LLP trading and liquidations. For additional details on Liquidations and ADL, please refer to the [relevant section](https://docs.lighter.xyz/trading/liquidations-and-llp-insurance-fund) of the documentation. Under the existing structure, **Auto-Deleverage (ADL) events are fully backstopped by LLP,** meaning that liquidity providers absorb the associated risk. LLP Strategies allow collateral to be allocated across distinct strategy buckets (that now includes RWAs, too). Each market is assigned to a specific strategy. From a system perspective, each strategy behaves similarly to a segregated collateral shard (comparable to a sub-account for risk purposes). However, strategies are not separate accounts — all positions remain under the LLP — but risk and losses are isolated at the strategy level. For example, LLP may allocate: * One strategy for Crypto Perpetuals * One strategy for FX * One strategy for Equities / RWAs The exact market-to-strategy mappings will be communicated separately. Under this framework, if a given strategy has $1M in allocated collateral, its maximum loss exposure is limited to that $1M. If the allocated collateral is fully depleted, the strategy would be subject to ADL, while collateral allocated to other strategies remains unaffected. ### RWAs & LLP Strategies The Real World Assets (RWA) perpetual markets are now subject to standard liquidation fees, consistent with all other markets, as LLP serves as the primary protocol liquidity provider. # Multi-Asset Margin Multi-Asset Margin enables users to use non-USDC assets as margin for trading. Users deposit supported assets (e.g. ETH) into their margin balance, and the value of these assets — discounted by a haircut — counts toward the account's total margin. This allows users to trade perpetual futures and spot markets using their existing holdings without first converting to USDC. Multi-Asset Margin offers convenience when it comes to margin usage. That said, as we add ETH as the first asset to be used for this feature, and as we roll out more assets with time, we want to be conscious in our approach with conservative user and global supply limits, which can be found within this section.&#x20; Multi-Asset Margin is available exclusively to accounts with Unified Trading Accounts enabled. {% hint style="warning" %} USDC spot trading with non-USDC collateral isn’t included at launch—coming soon. At release, Multi-Asset Margin supports perpetual futures only, and we’ll share updates ahead of each new rollout. {% endhint %} {% hint style="info" %} When no non-USDC margin assets are held, Multi-Asset Margin accounts behave identically to standard cross-margin accounts. All existing margin calculations remain unchanged. {% endhint %} *** #### How It Works 1. A user deposits a supported asset (e.g. ETH) into their margin balance. 2. The asset's value, discounted by LTV, is added to the account's Total Account Value. 3. The account can use this value to open perpetual futures positions, execute spot trades, or both. 4. A single health check monitors the account continuously using the Total Account Liquidation Threshold. 5. If the account's health falls below the Maintenance Margin Requirement, liquidation is triggered — for both perp positions and spot margin assets in a unified flow. **Example Use Cases** * **Basis trade:** A user deposits ETH as margin and opens a short ETH perpetual position. The spot ETH and the short perp offset each other, creating a delta-neutral position that earns funding. * **Leveraged spot:** A user deposits ETH, and uses the additional margin to buy more ETH on the spot market — effectively creating a leveraged long. *** ### Margin Assets Each margin-enabled asset is configured with the following parameters: | Parameter | Description | | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | | **LTV** | Loan-to-Value ratio. Determines how much of the asset's value counts toward Total Account Value. | | **LT** | Liquidation Threshold. Determines how much of the asset's value counts toward Total Account Liquidation Threshold. Always greater than or equal to LTV. | | **LF** | Liquidation Factor. Determines the minimum value the user receives per unit of collateral during liquidation. Always greater than or equal to LT. | | **Liquidation Fee** | Maximum fee paid when spot collateral is seized during liquidation. Capped so that the user always receives at least the LF discounted value. | | **User Supply Cap** | Maximum amount a single user can hold as margin (in asset units). | | **Global Supply Cap** | Maximum total amount held as margin across all users. | *** ### Total Account Value Total Account Value (TAV) represents the risk-adjusted value of the entire account. It extends the existing Total Account Value by including non-USDC margin assets discounted by their LTV: $$ \text{TAV}(\text{USDC}) = \text{PortfolioBalance}(\text{USDC}) + \sum\_{j} \text{LTV}\_j \times \text{MarginBalance}\_j \times \text{IndexPrice}\_j $$ Where Portfolio Balance is the USDC value of the account including unrealized PnL on perpetual positions, as defined in the [PnL And Total Account Value](/trading/pnl-and-total-account-value) section. Total Account Value is used for all risk checks when opening new positions or placing orders. ### Total Account Liquidation Threshold Total Account Liquidation Threshold (TALT) represents the account's value under the less conservative LT discount. It is used to determine when the account enters liquidation: $$ \text{TALT}(\text{USDC}) = \text{PortfolioBalance}(\text{USDC}) + \sum\_{j} \text{LT}\_j \times \text{MarginBalance}\_j \times \text{IndexPrice}\_j $$ {% hint style="info" %} Since $$\text{LT} \geq \text{LTV},$$ it always holds that $$\text{TALT} \geq \text{TAV}$$. {% endhint %} *** ### Health Checks Multi-Asset Margin accounts use a single unified health check that covers both perpetual positions and spot margin assets. The margin requirements IMR, MMR, and CMR remain unchanged from the existing contract specifications. $$ \begin{aligned} \textbf{Healthy:} \quad & \text{TAV} \geq \text{IMR} \\\[4pt] \textbf{Pre-Liquidation:} \quad & \text{TALT} \geq \text{MMR} \quad \text{and} \quad \text{TAV} < \text{IMR} \\\[4pt] \textbf{Partial Liquidation:} \quad & \text{TALT} < \text{MMR} \quad \text{and} \quad \text{TALT} \geq \text{CMR} \\\[4pt] \textbf{Full Liquidation:} \quad & \text{TALT} < \text{CMR} \end{aligned} $$ In pre-liquidation, only operations that improve the account's health ratio and reduce position size are permitted. When TALT falls below MMR, both perpetual positions and spot margin assets become eligible for liquidation in a unified flow. {% hint style="info" %} When no non-USDC margin assets are held, TAV and TALT both reduce to Portfolio Balance (USDC). The health check becomes identical to the existing cross-margin system.&#x20; {% endhint %} *** ### Liquidation When an account enters liquidation $$(\text{TALT} < \text{MMR})$$, the liquidation engine can close both perpetual positions and spot margin assets. Open orders are canceled first. If the account remains below MMR, the liquidation engine sends IoC limit orders at the respective zero prices through the corresponding order books to close positions. Liquidation stops as soon as the account becomes healthy. #### Perp Zero Price The perp zero price is modified to account for the value of non-USDC margin assets, properly maintaining the health ratio as an invariant. $$ \text{ZeroPrice}\_i(\text{long}) = \text{markPrice}\_i \times \left(1 - \frac{M\_i \times \text{TALT}}{\text{MMR}}\right) \\ \text{ZeroPrice}\_i(\text{short}) = \text{markPrice}\_i \times \left(1 + \frac{M\_i \times \text{TALT}}{\text{MMR}}\right) $$ This ensures that executing a perp trade at the zero price preserves the account's health ratio. When no non-USDC margin assets are held, TALV reduces to Portfolio Balance and the formulas are identical to the standard zero price. #### Spot Zero Price When partially liquidating a spot margin asset, the exchange sends an Immediate-or-Cancel (IoC) order to the spot order book on behalf of the user. The zero price for a spot asset is: $$ \text{SpotZeroPrice}\_j = \text{IndexPrice}\_j \times \text{LF}\_j $$ The liquidation fee is collected up to the configured amount, with the constraint that the user receives at least the LF-discounted value in USDC for each unit of collateral sold. This ensures that liquidation execution is always at least as favorable as the LF price. *** ### Supported Collateral Assets Each collateral asset carries a set of risk parameters that control how much margin value it provides and how it behaves during liquidation. Current live values are always available from the `assetDetails` API endpoint, where `margin_mode: "enabled"` marks assets accepted as collateral. #### Lighter | Asset | Loan-to-Value | Liquidation Threshold | Liquidation Factor | Liquidation Fee | User Supply Cap | Global Supply Cap | | ----- | :-----------: | :-------------------: | :----------------: | :-------------: | :-------------: | :---------------: | | ETH | 70% | 85% | 95% | 2% | 2000 ETH | 10000 ETH | | XAUT | 70% | 85% | 95% | 2% | 500 XAUT | 2000 XAUT | #### Robinhood Chain Lighter | Asset | Loan-to-Value | Liquidation Threshold | Liquidation Factor | Liquidation Fee | User Supply Cap | Global Supply Cap | | ----- | :-----------: | :-------------------: | :----------------: | :-------------: | :-------------: | :---------------: | | SPY | 50% | 75% | 95% | 2% | 25 SPY | 200 SPY | | USO | 50% | 75% | 95% | 2% | 100 USO | 750 USO | USDC (Lighter) and USDG (Robinhood Chain Lighter) remain the base collateral and are always valued at 100% with no liquidation fee or supply cap. # Collateral Supply Limits We are taking a measured approach to non-USDC collateral, starting with conservative user and global supply limits outlined in this section. As the product matures, spot liquidity deepens, and USDC supply grows, we plan to support additional collateral assets and introduce new features. Important note: users can choose *how much* of their available collateral to allocate as margin on a per-asset basis. #### Global Supply Limit Caps List of current assets available to be used as collateral: <table><thead><tr><th width="228.3359375">Asset</th><th width="210.3828125">Global Cap</th></tr></thead><tbody><tr><td>ETH</td><td><em>10000 ETH</em></td></tr><tr><td>XAUT</td><td><em>2000 XAUT</em></td></tr></tbody></table> # Funding ### Overview The funding mechanism is a crucial component of perpetual futures trading. It ensures that the price of the perpetual contract closely tracks the underlying asset’s spot price. Unlike traditional futures contracts, perpetual futures do not have an expiration date. To maintain price stability and avoid significant deviations from the spot price, a periodic funding mechanism is implemented. Funding payments occur at each hour mark. Traders holding long and short positions pay or receive a funding fee based on the difference between the contract price and the spot price. These payments are fully peer-to-peer with no fees taken by the exchange. The funding payment for an account position depends on the size and side of the position, as well as the funding rate. The funding rate represents the difference between the mark price of the perpetual futures market and the index price, which is equivalent to the spot market price of the underlying asset. When the funding rate is positive, users with long positions pay a funding fee to users with short positions. When the funding rate is negative, users with short positions pay a fee to users with long positions. ### Premium Calculation For each minute, at a random time, Lighter calculates the premium of each market, which represents the deviation of the mark price from the index price for the corresponding market: $$ \text{premium}\_t ================= \frac{ \max(0,\ \text{ImpactBidPrice}\_t - \text{index}\_t) ---------------------------------------------------- \max(0,\ \text{index}\_t - \text{ImpactAskPrice}\_t) }{ \text{index}\_t } $$ {% hint style="info" %} For the premium to be positive (i.e. for long positions to pay funding to short positions), the impact bid price needs to be higher than the index price. When $$\text{ImpactBidPrice}\_t \leq \text{index}\_t \leq \text{ImpactAskPrice}\_t$$, the $$\text{premium}\_t$$ is 0. {% endhint %} ### Funding Rate Calculation At the end of each hour, a 1-hour premium is calculated as the time-weighted average of the 60 premiums calculated over the course of the last hour. In addition to the premium component, each market has a fixed interest rate component that accounts for the difference in interest rates of the base and quote currencies. The funding rate is then calculated as: $$ \begin{aligned} \text{premium} &= \text{Average of premium}\_t \text{ since the latest funding} \times \text{FundingPremiumMultiplier} \\\[4pt] \text{smallClamp} &= \text{SmallClamp} \times \text{FundingPremiumMultiplier} \\\[4pt] \text{smallClampedPremium} &= \text{premium} * \operatorname{clamp}\bigl( \text{InterestRate} - \text{premium},\ -\text{smallClamp},\ +\text{smallClamp} \bigr) \\\[4pt] \text{fundingRate} &= \frac{ \operatorname{clamp}\bigl( \text{smallClampedPremium},\ -\text{BigClamp},\ +\text{BigClamp} \bigr) }{8} \\\[4pt] \text{where}\quad \operatorname{clamp}(x, a, b) &= \max\bigl(a, \min(b, x)\bigr) \end{aligned} $$ Dividing the 1-hour premium by 8 ensures that funding payments for the premium are distributed over 8 hours, closely aligning with the approach adopted by centralized perpetual exchanges. #### Parameters The values used for the majority of the markets are the following: $$ \text{SmallClamp} = 0.05%, \qquad \text{BigClamp} = 4%, \qquad \text{InterestRate} = 0.01% $$ * $$\text{SmallClamp}$$ pulls the $$\text{premium}$$ towards the $$\text{InterestRate}$$. If $$\text{InterestRate} - \text{smallClamp} \leq \text{premium} \leq \text{InterestRate} + \text{smallClamp}$$, then $$\text{fundingRate} = \text{InterestRate} / 8$$. In other words, if the premium is within 5 basis points (scaled by the market’s $$\text{FundingPremiumMultiplier}$$) of the interest rate, funding defaults to the normal value of 1 basis point per 8 hours. * $$\text{BigClamp}$$ limits funding payments to $$4%$$ per 8 hours, or $$0.5%$$ per hour. * $$\text{FundingPremiumMultiplier}$$ is configurable per market and ranges over $$(0, 1]$$. It is set to $$1$$ for crypto markets, $$1/2$$ for RWA markets, and $$1/100$$ for Pre-IPO and Pre-Markets. #### Example For a crypto market ($$\text{FundingPremiumMultiplier} = 1$$) with a premium of $$0.1%$$: $$ \begin{aligned} \text{smallClampedPremium} &= 0.1% * \operatorname{clamp}\bigl( 0.01% - 0.1%,\ -0.05%,\ +0.05% \bigr) \= 0.05% \\\[4pt] \text{fundingRate} &= \frac{\operatorname{clamp}(0.05%,\ -4%,\ +4%)}{8} \= 0.00625% \end{aligned} $$ ### Funding Payment The funding payment for account $$i$$ in market $$j$$ is calculated as follows: $$ \text{funding}\_{i,j} ===================== -,\text{position}\_{i,j} \times \text{index}\_j \times \text{fundingRate}\_j $$ A positive $$\text{funding}\_{i,j}$$ is credited to the account and a negative value is charged. # PnL And Total Account Value ### **Perps Trading** ***Unrealized PnL*** shows how much you would gain or lose if you closed your positions at the current [mark price](/trading/fair-price-marking). Let $$pos\_i$$ be the current position size of an account. $$pos\_i$$ is positive if the account position is long and negative if it is short. The unrealized PnL of the account can be calculated as: $$ \text{Unrealized PnL} := \sum(\text{markPrice}\_i - \text{avgEntryPrice}\_i) \times position\_i $$ **Realized PnL** is the gain / loss that has already been captured from the position after closing or due to funding payments. It is calculated based on the difference in USDC value between your average entry price and exit price. Additionally, all funding payments for the position are immediately applied to its realized PNL. * When the user is closing a portion of an existing long or short position, average entry price stays the same and exchange realizes the difference in average exit and entry prices. $$ \Delta Collateral := (\text{exitPrice}\_i - \text{avgEntryPrice}\_i) \times \Delta position\_i $$ * When the user is increasing the size of their open position, no PnL is realized. Exchange updates the average entry price according to the following formula $$ \text{avgEntryPrice}*{i, new} := \frac{{avgEntryPrice}*{i, old }\times {position\_{i, old}} + {tradePrice\times tradeSize}}{position\_{i, new}} $$ ### **Spot Trading** ### Total Account Value ***Total Account Value*** represents the total USDC value of an account in Lighter, including all open positions and collateral. It is calculated as follows: $$ \text{Total Account Value} = \text{Collateral} + \text{Unrealized PnL} $$ Note: Isolated positions use a separate collateral balance (Allocated Margin) dedicated solely to that specific position. It functions the same as collateral but applies only to the relevant position and should be treated as collateral in the calculations above. # Fair Price Marking ***Mark price*** is the fair price of a perpetual contract. Mark price is calculated using the liquidity in the perpetual market order book and the ***index price*** (spot price of the underlying market). At any point in time, mark price is defined as follows: $$ \small \text{Impact Notional Amount} = 500 \text{ USDC} / \text{Initial Margin Fraction} \\ \text{Impact Bid Price}\_t = \text{Avg execution price for a market sell of the impact notional value} \\ \text{Impact Ask Price}\_t = \text{Avg execution price for a market buy of the impact notional value} \\ \text{Impact Price}\_t = (\text{Impact Bid Price}\_t + \text{Impact Ask Price}\_t) / 2 \\ \\\~\\ \text{price1}*t = index\_t + \operatorname{EMA}*{8\ \mathrm{min}}( \text{clamp}( \text{Impact Price}*t - index\_t, -index\_t/200,+index\_t/200 )) \\ \text{where} \operatorname{clamp}(x,a,b) = \max\bigl(a,;\min(b,x)\bigr) \\ \text{and} \operatorname{EMA}*{8\ \mathrm{min}} \text{refers to the Exponential Moving Average of the value over 8 minutes} \\\~\\ \text{price2}\_t = median(\text{cexPrices}\_t) \\ \text{wher
프로젝트로 돌아가기