Meteora 백서

Meteora

원문

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

00 } \right\rceil ``` If `variable fee control` is `0`, the variable fee is `0`. The volatility accumulator updates from bin movement: ```math theme={"system"} \text{volatility accumulator} = \min( \text{volatility reference} + |\text{index reference} - \text{active id}| \times 10{,}000, \text{max volatility accumulator} ) ``` The volatility reference decays based on elapsed time: | Time Since Last Update | Program Behavior | | - | - | | Less than `filter_period` | Keep the existing reference. | | Between `filter_period` and `decay_period` | `volatility reference = volatility accumulator × reduction factor / 10,000` | | Greater than or equal to `decay_period` | `volatility reference = 0` | This lets fees increase when swaps move across bins and cool down after quieter periods. ## Fee Amounts The program supports two common fee calculations. When the fee is part of the amount already provided by the trader: ```math theme={"system"} \text{fee amount} = \left\lceil \frac{\text{amount with fee} \times \text{total fee rate}}{1{,}000{,}000{,}000} \right\rceil ``` ```math theme={"system"} \text{amount excluding fee} = \text{amount with fee} - \text{fee amount} ``` When the fee must be added on top of an amount that does not include fees: ```math theme={"system"} \text{fee amount} = \left\lceil \frac{ \text{amount excluding fee} \times \text{total fee rate} }{ 1{,}000{,}000{,}000 - \text{total fee rate} } \right\rceil ``` ```math theme={"system"} \text{amount including fee} = \text{amount excluding fee} + \text{fee amount} ``` Which form is used depends on the swap direction and the pool's [Collect Fee Mode](/core-products/dlmm/collect-fee-mode). ## Fee Split How a bin's **trading fee** is distributed depends on the pool's [function mode](/core-products/dlmm/what-is-dlmm#pool-function-modes): | Pool mode | Liquidity sources | Limit-order fee path | | - | - | - | | Liquidity mining | MM positions only | No | | Limit order | MM positions and/or limit orders | Yes | Both modes use the same `protocol share` for MM liquidity and the same referral **host fee** rule. Limit-order pools add an extra split when limit-order liquidity contributes to the fill. <Note>These rates apply to how the **trading fee** is shared among recipients. They are separate from the pool's base fee, variable fee, and total fee cap.</Note> ### MM protocol and LP shares For any fill that comes from MM positions, the MM slice of the trading fee is split by the pool's `protocol share`: | Pool type | Protocol | LP | | - | - | - | | Standard pool | `10%` (`protocol share` = `1,000` bps) | `90%` | | Launch Pool | `20%` (`ILM_PROTOCOL_SHARE` = `2,000` bps) | `80%` | ```math theme={"system"} \text{protocol fee} = \left\lfloor \frac{\text{trading fee} \times \text{protocol share}}{10{,}000} \right\rfloor ``` ```math theme={"system"} \text{LP fee} = \text{trading fee} - \text{protocol fee} ``` On limit-order pools, replace `trading fee` with `total MM fee` when the fill also includes limit-order liquidity (see below). ### Referral host fee When a swap passes a **referral account**, the host receives `20%` of the applicable protocol fee (`HOST_FEE_BPS` = `2,000` bps). The rest stays as protocol treasury fee. ```math theme={"system"} \text{host fee} = \left\lfloor \frac{\text{protocol fee} \times 2{,}000}{10{,}000} \right\rfloor ``` ```math theme={"system"} \text{protocol fee remainder} = \text{protocol fee} - \text{host fee} ``` Without a referral account, `host fee = 0` and `protocol fee remainder = protocol fee`. On limit-order pools with mixed fills, host fee can also include a capped share from the limit-order protocol slice (see below). ### Liquidity mining pools Liquidity mining pools do not support limit orders. Every swap fill is MM liquidity, so the entire trading fee uses the MM formulas above with no liquidity-source split. ```math theme={"system"} \text{trading fee} = \text{LP fee} + \text{protocol fee remainder} + \text{host fee} ``` ### Limit-order pools Limit-order pools can fill from MM positions, limit orders, or both in the same bin. The program first assigns the trading fee by **liquidity source**, then applies the recipient splits above. **By liquidity source** (rounding favors MM): ```math theme={"system"} \text{total MM fee} = \left\lceil \text{trading fee} \times \frac{\text{MM amount in}}{\text{total amount in}} \right\rceil ``` ```math theme={"system"} \text{total limit order fee} = \text{trading fee} - \text{total MM fee} ``` **MM slice** — split with `protocol share` as in the table above: ```math theme={"system"} \text{MM protocol fee} = \left\lfloor \frac{\text{total MM fee} \times \text{protocol share}}{10{,}000} \right\rfloor ``` ```math theme={"system"} \text{MM LP fee} = \text{total MM fee} - \text{MM protocol fee} ``` **Limit-order slice** — always `50%` / `50%` via `LIMIT_ORDER_FEE_SHARE` (`5,000` bps), independent of pool type: ```math theme={"system"} \text{limit order participant fee} = \left\lfloor \frac{\text{total limit order fee} \times 5{,}000}{10{,}000} \right\rfloor ``` ```math theme={"system"} \text{limit order protocol fee} = \text{total limit order fee} - \text{limit order participant fee} ``` **Referral host fee** — `20%` of `MM protocol fee`, plus a capped share from the limit-order protocol slice: ```math theme={"system"} \text{host fee on limit order} = \min \left( \left\lfloor \frac{ \left\lfloor \frac{\text{total limit order fee} \times \text{protocol share}}{10{,}000} \right\rfloor \times 2{,}000 }{ 10{,}000 } \right\rfloor, \text{limit order protocol fee} \right) ``` ```math theme={"system"} \text{host fee} = \left\lfloor \frac{\text{MM protocol fee} \times 2{,}000}{10{,}000} \right\rfloor + \text{host fee on limit order} ``` ```math theme={"system"} \text{protocol fee remainder} = \text{MM protocol fee} + \text{limit order protocol fee} - \text{host fee} ``` When a swap fills only MM liquidity, `total limit order fee = 0` and the limit-order paths above are zero — the result matches a liquidity mining pool. ```math theme={"system"} \text{trading fee} = \text{MM LP fee} + \text{limit order participant fee} + \text{protocol fee remainder} + \text{host fee} ``` ## Liquidity Shares When a user deposits into a bin, the program first computes the liquidity value of the deposit: ```math theme={"system"} L_\text{in} = P \cdot x_\text{in} + y_\text{in} ``` If the bin has no existing liquidity supply, the new liquidity share equals the deposit liquidity: ```math theme={"system"} \text{liquidity share} = L_\text{in} ``` If the bin already has liquidity, the new share is: ```math theme={"system"} \text{liquidity share} = \left\lfloor \frac{ L_\text{in} \times \text{existing liquidity supply} }{ L_\text{bin} } \right\rfloor ``` Where: * `L_in` is the liquidity value of the user's deposit * `L_bin` is the existing liquidity value of the bin before the deposit * `existing liquidity supply` is the bin's current share supply Those shares determine the position's proportional claim on bin liquidity, fees, and eligible rewards. ## Withdrawal Amounts When liquidity is removed from a bin, token amounts are returned pro rata: ```math theme={"system"} \text{amount out}_X = \left\lfloor \frac{ \text{liquidity share removed} \times \text{bin amount}_X }{ \text{bin liquidity supply} } \right\rfloor ``` ```math theme={"system"} \text{amount out}_Y = \left\lfloor \frac{ \text{liquidity share removed} \times \text{bin amount}_Y }{ \text{bin liquidity supply} } \right\rfloor ``` ## Composition Fee When adding liquidity to the active bin of a bin that already has liquidity, the program may charge a **composition fee** if the deposit changes the bin composition in a way that resembles a swap. The composition fee is based on the token delta and the current total fee rate: ```math theme={"system"} \text{composition fee} = \left\lfloor \frac{ \Delta \text{amount} \times \text{total fee rate} \times (1{,}000{,}000{,}000 + \text{total fee rate}) }{ 1{,}000{,}000{,}000^2 } \right\rfloor ``` The protocol share is then taken from the composition fee using the same protocol-fee formula: ```math theme={"system"} \text{composition protocol fee} = \left\lfloor \frac{\text{composition fee} \times \text{protocol share}}{10{,}000} \right\rfloor ``` No composition fee is charged when depositing into an empty bin or a non-active bin. ## Liquidity Mining Rewards For reward-enabled pools, rewards are tracked per token of liquidity for eligible bins. The reward emission rate is funded over a reward duration. If a reward is funded while a previous reward period is still active, the program includes the remaining unvested reward amount in the new rate calculation: ```math theme={"system"} \text{reward rate} = \frac{\text{new funded amount} + \text{remaining reward amount}}{\text{reward duration}} ``` If the funder chooses to carry forward ineligible rewards from empty-liquidity time, that carry-forward amount is also included in the new funded amount. In the program, `reward_rate` is stored in fixed-point precision. On active-bin reward updates, the per-token reward increment is: ```math theme={"system"} \Delta \text{reward per token} = \left\lfloor \frac{ \text{seconds elapsed} \times \text{reward rate} }{ \text{active bin liquidity supply} } \right\rfloor ``` If the active bin has no liquidity, the program records the elapsed empty-liquidity time instead of assigning rewards to LPs. During v2 swaps, accumulated rewards can also be split across crossed bins with liquidity, up to the program's reward-bin split limit. ## Price Impact Guard Some swap flows can include a maximum price impact limit. The program computes a guard price from the active bin price: For X to Y swaps: ```math theme={"system"} \text{minimum price} = P_\text{active} \times \frac{10{,}000 - \text{max price impact bps}}{10{,}000} ``` For Y to X swaps: ```math theme={"system"} \text{maximum effective price} = P_\text{active} \times \frac{10{,}000}{10{,}000 - \text{max price impact bps}} ``` This protects users from swaps that would move too far from their expected active-bin price. # DLMM Limit Order Source: https://docs.meteora.ag/core-products/dlmm/limit-order Learn how DLMM Limit Orders place liquidity at selected price bins to create on-chain buy and sell strategies inside limit-order-enabled DLMM pools. DLMM Limit Order lets users place liquidity at specific bins so their position behaves like a buy or sell order at a chosen price. It brings a familiar orderbook-style experience into DLMM's on-chain bin model. Limit orders are available only on DLMM pools whose function mode supports limit orders. In the `lb_clmm` program, a pool supports either liquidity mining or limit-order behavior; it does not run both modes at the same time. Instead of submitting a market swap immediately, a user can place an order at a target bin. When swaps move through that bin, the order can be filled by normal pool activity. This creates a more flexible trading and liquidity experience: users can express a price view, while the pool still benefits from deeper liquidity at those prices. ## Why Limit Orders Matter <CardGroup> <Card title="Price-Targeted Liquidity" icon="bullseye"> Users can place liquidity where they want to buy or sell, instead of manually watching the market and swapping at the right moment. </Card> <Card title="More Useful Pool Depth" icon="layer-group"> Limit orders add liquidity to specific bins, strengthening depth around the prices where traders expect activity. </Card> <Card title="DCA Strategies" icon="chart-line-up"> Users can place orders across multiple bins to gradually enter or exit a position as price moves. </Card> <Card title="Native DLMM Execution" icon="bolt"> Orders are filled through DLMM swap flow, so they can participate in the same bin-based market structure as other liquidity. </Card> </CardGroup> ## How It Works A DLMM pool is a ladder of bins. A limit order chooses one or more bins and places a token amount there. One limit-order account can cover up to `50` bins. ```text theme={"system"} Lower prices Target bin Higher prices [ bin ][ bin ][ bin ] -> [ limit order ] -> [ bin ][ bin ][ bin ] ``` If the market reaches the selected bin and swaps consume the order's liquidity, the order is filled. If the market never reaches that bin, the order remains open until the user cancels it. DLMM supports both sides: * **Bid side:** place token Y at bins at or below the active bin to buy token X when price reaches those bins. * **Ask side:** place token X at bins at or above the active bin to sell token X for token Y when price reaches those bins. Orders can be placed by absolute bin ID or by relative bin offset from an observed active bin. Relative placement includes a max active-bin slippage check so the order is not created if the live active bin has moved too far from the user's expected active bin. <Info>A limit order is not a separate centralized orderbook. It is an on-chain DLMM account that places order liquidity into selected bins.</Info> ## Limit Orders vs LP Positions Both LP positions and limit orders use DLMM bins, but they are designed for different goals. | Feature | LP Position | Limit Order | | - | - | - | | Primary goal | Earn fees by providing liquidity across a range | Buy or sell at selected prices | | Price coverage | Usually multiple bins across a strategy range | Specific target bins | | Active management | Rebalance to stay near market activity | Cancel if the order no longer matches your view | | Outcome | Position composition changes as price moves | Order fills when swaps cross the selected bin | ## Fee Sharing When a swap fills both market-maker liquidity and limit-order liquidity, the trading fee is split between the relevant participants according to the pool's fee logic. DLMM allocates a share of the applicable fee to limit-order liquidity when it contributes to the fill. This means limit orders are not just passive instructions waiting on a matching engine. They are part of the liquidity surface that traders route through. At the program level, filled limit-order liquidity and market-maker liquidity are accounted separately. Limit-order fee accounting is tracked per bin for ask-side and bid-side orders, and the current program constant allocates `50%` of the limit-order portion of fees to limit-order participants, with the remaining portion treated as protocol-side fee according to the fee split logic. ## Product Use Cases <AccordionGroup> <Accordion title="Buy the dip"> Place bid-side orders below the current price. If the market moves down into those bins, your order can buy token X with token Y. </Accordion> <Accordion title="Take profit"> Place ask-side orders above the current price. If demand pushes the market upward, your order can sell token X into token Y. </Accordion> <Accordion title="DCA into a token"> Split orders across several lower bins. This creates a gradual entry strategy instead of one large market buy. </Accordion> <Accordion title="DCA out of a token"> Split ask orders across several higher bins. This creates a gradual exit strategy as price rises. </Accordion> </AccordionGroup> ## Important Considerations Limit orders are still exposed to on-chain execution realities. A target bin may never be reached, may be partially filled, or may fill during a volatile market move. Users should monitor open orders and cancel orders that no longer match their strategy. <Warning>A DLMM Limit Order is not guaranteed execution. It only fills if swap flow reaches the selected bin and consumes the order's available liquidity.</Warning> # DLMM Liquidity Mining Source: https://docs.meteora.ag/core-products/dlmm/liquidity-mining Learn how DLMM Liquidity Mining incentivizes active liquidity, how reward-enabled pools distribute rewards, and how LPs claim eligible rewards. DLMM Liquidity Mining is the token reward mechanism for LPs who provide useful, active liquidity in a DLMM pool. In the `lb_clmm` program, this feature is represented by the `LiquidityMining` function type and liquidity mining support checks. Liquidity mining is a pool function mode. A reward-enabled DLMM pool supports liquidity mining and does not support limit-order placement at the same time. Each pool can track up to `2` reward tokens. Rewards are designed to flow to liquidity where trading is actually happening, not liquidity that sits far away from the market price. Rewards accrue through your [DLMM Dynamic Position](/core-products/dlmm/dynamic-positions) when your liquidity is in the active bin or, during swap processing, in eligible bins crossed by swaps. ## Why Liquidity Mining Matters <CardGroup> <Card title="Incentivize Useful Liquidity" icon="seedling"> Rewards flow to bins that support active trading, helping pools deepen liquidity where traders need it most. </Card> <Card title="Boost LP Returns" icon="coins"> LPs can earn liquidity mining rewards in addition to trading fees when their position is active and eligible. </Card> <Card title="Support Launch Growth" icon="rocket"> Token teams can use rewards to attract liquidity during important launch or growth periods. </Card> <Card title="Align With DLMM Design" icon="arrows-to-circle"> Rewards follow DLMM's bin model, so incentive distribution stays tied to the same liquidity that powers swaps. </Card> </CardGroup> ## Who Earns Rewards Rewards are distributed to positions with liquidity in the **active bin** during normal reward updates. If a swap moves the active price across multiple bins, the v2 swap flow can also distribute elapsed rewards across bins with liquidity that were crossed during that swap, up to the program's `15` bin reward-split limit. Your reward share depends on your share of liquidity in the eligible bin or bins. ```text theme={"system"} Your reward share = your liquidity in eligible bins / total liquidity in eligible bins ``` If your position is out of range, it does not earn liquidity mining rewards because it is not supporting active trading. If a bin has no liquidity, no LP receives rewards from that bin. <Note>In DLMM, the same idea applies to fees and rewards: active liquidity matters. A position that is not in range does not earn trading fees or liquidity mining rewards until price returns or the LP rebalances.</Note> ## How Rewards Are Distributed Liquidity mining rewards are emitted at a fixed rate over the reward period. For example, a pool could distribute 50,000 USDC over four weeks. That budget is streamed over time and allocated to eligible bins. When the active bin stays in one place, rewards go to liquidity in that active bin. When a v2 swap crosses multiple bins with liquidity, rewards accumulated since the last update can be split across crossed bins and then distributed proportionally to LPs in each bin. ```text theme={"system"} Reward budget over time -> active bin or crossed bins -> LPs in those bins, based on liquidity share ``` ## Example Suppose a pool distributes `50,000 USDC` over four weeks, equal to about `1,785.71 USDC` per day. | Moment | What Happens | Who Earns | | - | - | - | | Position A deposits in bin 0 | Bin 0 is the active bin | Position A earns rewards from bin 0 | | Position B joins bin 0 | Bin 0 is still active | Positions A and B share rewards based on liquidity share | | Position C adds liquidity in bin 1 | Bin 1 is not active yet | Position C does not earn until bin 1 becomes active or is crossed | | A swap moves price from bin 0 to bin 1 | Both bins are crossed | Rewards are allocated across bin 0 and bin 1, then shared by LPs in each bin | This example shows the core principle: liquidity mining rewards follow active market participation. ## Claiming Rewards DLMM liquidity mining rewards do not auto-compound. They accrue to eligible positions and must be claimed manually.
프로젝트로 돌아가기