Meteora 백서

Meteora

원문

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

final fee | | Reduction factor | How much the fee changes each step | DAMM v2 supports two market cap scheduler curves: linear and exponential. ## Linear Market Cap Scheduler The linear market-cap scheduler decreases the fee numerator by the same fixed amount each time the pool square-root price moves through a configured step. ```math theme={"system"} \text{Fee Numerator} = \text{Cliff Fee Numerator} - (\text{Price Steps Passed} \times \text{Reduction Factor}) ``` In product terms, the fee moves down in predictable price milestones. Each upward price step unlocks the next fee reduction. Use linear market cap scheduling when you want each price milestone to reduce fees by the same amount. ## Exponential Market Cap Scheduler The exponential market-cap scheduler reduces the fee by applying the reduction factor as price milestones are reached. ```math theme={"system"} \text{Fee Numerator} = \text{Cliff Fee Numerator} \times \left(1 - \frac{\text{Reduction Factor}}{10{,}000}\right)^{\text{Price Steps Passed}} ``` In product terms, fees can drop faster in early price-growth stages, then slow as they approach the final fee. Use exponential market cap scheduling when you want the launch curve to feel smoother than a fixed step-down schedule. ## Why Use Market Cap Scheduler Fees <CardGroup> <Card title="Price-Based Fee Decay" icon="chart-line"> Fees decrease when price increases, not simply because time passes. </Card> <Card title="Launch Protection" icon="shield"> Fees can remain elevated until the market reaches real price milestones. </Card> <Card title="Market Growth Alignment" icon="arrow-trend-up"> The schedule rewards upward price discovery with lower trading fees. </Card> <Card title="Expiration Fallback" icon="calendar-check"> The scheduler settles at its final-period fee after the configured expiration duration. </Card> </CardGroup> ## Expiration and Validation If the scheduler expires, or if a pre-activation alpha-vault buy is being processed, the program uses the final period. If the current square-root price is at or below the initial square-root price before expiration, the scheduler uses period `0`. The program requires all of these values to be non-zero: * `reduction_factor` * `sqrt_price_step_bps` * `scheduler_expiration_duration` * `number_of_period` ## Linear vs Exponential | Curve | Best For | Fee Behavior | | - | - | - | | Linear | Clear market-cap milestones | Fee numerator decreases by a fixed amount each step | | Exponential | Smoother price-growth fee curve | Fee numerator decreases by a percentage-style factor each step | ## When To Choose It Use a market cap scheduler when fees should stay elevated until the pool shows upward price movement. This can be useful for launch markets where the team wants protection to follow market behavior. Use [Time Scheduler Fees](/core-products/damm-v2/fees/time-scheduler) instead when fees should decrease according to elapsed time. # DAMM v2 Fees Source: https://docs.meteora.ag/core-products/damm-v2/fees/overview Understand DAMM v2 fee layers, collect fee modes, base fee modes, dynamic fees, protocol fees, referral fees, and update constraints. DAMM v2 fees are configurable, but they are not arbitrary. The `cp-amm` program combines one base fee mode, an optional dynamic fee layer, a protocol fee split, an optional referral split, and a collect fee mode that determines which token pays the fee. ## Fee Layers DAMM v2 first calculates the total fee numerator: ```math theme={"system"} \text{Total Fee Numerator} = \min(\text{Base Fee Numerator} + \text{Dynamic Fee Numerator}, \text{Pool Fee Cap}) ``` The denominator is `1,000,000,000`. A fee of 1 bps is `100,000` in numerator units. After the trading fee is calculated, DAMM v2 splits it: | Component | Program Behavior | | - | - | | Protocol fee | Defaults to `20%` of the trading fee | | Referral fee | Defaults to `20%` of the protocol fee when a referral is present | | LP fee | Trading fee after protocol fee | | Compounding fee | In compounding mode only, a share of the LP fee added back to reserves | | Claimable fee | LP fee remaining after the compounding share | ## Base Fee Modes DAMM v2 has five on-chain base fee modes, where Time Scheduler and Market Cap Scheduler each have linear and exponential curves. Rate limiter mode is deprecated for new configs and new pools. <CardGroup> <Card title="Time Scheduler" href="/core-products/damm-v2/fees/time-scheduler" icon="clock"> Fee is fixed or decays over time using a linear or exponential curve. </Card> <Card title="Market Cap Scheduler" href="/core-products/damm-v2/fees/market-cap-scheduler" icon="chart-line"> Fee decreases as the square-root price moves above the initial price, using a linear or exponential curve. </Card> </CardGroup> <CardGroup> <Card title="Rate Limiter" href="/core-products/damm-v2/fees/rate-limiter" icon="gauge-high"> Deprecated for new configs. Existing pools can still use buy-size-sensitive fees during the limiter window. </Card> </CardGroup> ## Dynamic Fees <CardGroup> <Card title="Dynamic Fees" href="/core-products/damm-v2/fees/dynamic-fees" icon="wave-pulse"> Optional volatility-based fee layer on top of the selected base fee mode. </Card> </CardGroup> ## Collect Fee Modes Collect fee mode determines which token pays LP and protocol fees. | Mode | A-to-B swap | B-to-A swap | Notes | | - | - | - | - | | `BothToken` | Fee taken from token B output | Fee taken from token A output | Fees can accrue in both tokens | | `OnlyB` | Fee taken from token B output | Fee taken from token B input | Quote-token fee collection | | `Compounding` | Fee taken from token B output | Fee taken from token B input | Token B fees, with atomic LP fee compounding | <Note> Rate limiter mode is only valid with `OnlyB` collect fee mode. Compounding pools use `Compounding` collect fee mode and require a non-zero `compounding_fee_bps`. </Note> ## Fee Caps and Updates The current pool version supports total fee caps up to `99%`. Older version 0 pools are capped at `50%`. The minimum fee is 1 bps. ## Choosing a Fee Design <AccordionGroup> <Accordion title="I want fees to decay over time after launch"> Use a time scheduler. Linear decay changes by a fixed amount each period; exponential decay changes by a percentage-style factor each period. </Accordion> <Accordion title="I want fees to decay only if price grows"> Use a market-cap scheduler. Fees stay elevated until the square-root price advances through configured steps, or until the scheduler expires. </Accordion> <Accordion title="I want large launch buys to pay more"> Rate limiter mode is deprecated for new configs. Use a high starting scheduler fee, or add dynamic fees, instead of creating a new rate-limiter config. </Accordion> <Accordion title="I want fees to react to volatility"> Add dynamic fees. They sit on top of the base fee and rise when recent price movement increases the volatility accumulator. </Accordion> </AccordionGroup> # DAMM v2 Rate Limiter Source: https://docs.meteora.ag/core-products/damm-v2/fees/rate-limiter Learn how DAMM v2 rate limiter fees increase with buy size during a bounded launch window. The DAMM v2 rate limiter is a deprecated base fee mode that increases the effective fee as buy size increases. <Warning> Rate limiter mode is deprecated for new configs and new pools. `create_config`, `initialize_customizable_pool`, `initialize_pool_with_dynamic_config`, and `initialize_pool` reject `BaseFeeMode::RateLimiter`. Existing rate-limiter pools can still be quoted and swapped. Operators can still call `fix_pool_fee_params`, `fix_config_fee_params`, and `update_pool_fees` on those existing pools and configs. </Warning> It was designed for launch pools where oversized early buys can distort distribution or create a poor trading experience. Instead of charging every buy the same fee, the rate limiter behaves like a fee slope. ## How It Works The pool defines a reference amount. Buys up to that amount pay the cliff fee. As the token B input amount grows beyond the reference amount, DAMM v2 applies higher fee tiers until the configured maximum fee is reached. In product terms, a small buy may pay the base fee, while a much larger buy pays a higher average fee. ## Key Settings | Setting | Product Meaning | | - | - | | Cliff fee numerator | Starting fee for the first reference amount | | Reference amount | Trade size unit used for the fee slope | | Fee increment bps | How much the fee increases per step | | Max fee bps | Highest fee the limiter can charge | | Max limiter duration | How long the limiter is active after launch | ## Requirements Rate limiter mode has specific product constraints: * It applies only when the trade direction is B-to-A. * It is valid only with `OnlyB` collect fee mode. * It starts at the activation point and lasts only through the configured limiter duration. * DAMM v2 validates that rate-limited swaps are not bundled as multiple swaps against the same pool in one transaction. * The limiter duration is capped at 12 hours: `43,200` seconds for timestamp activation or `108,000` slots for slot activation. <Info> If `reference_amount`, `max_limiter_duration`, `max_fee_bps`, and `fee_increment_bps` are all zero, the rate limiter acts as a fixed cliff-fee mode. </Info> <Warning> Rate limiter is mutually exclusive with the time scheduler and market cap scheduler base fee modes. A DAMM v2 pool chooses one base fee mode. </Warning> ## Why Use It <CardGroup> <Card title="Discourage Oversized Buys" icon="scale-balanced"> Larger launch buys can pay progressively higher fees. </Card> <Card title="Protect Early Distribution" icon="shield"> The fee slope helps reduce the advantage of very large first movers. </Card> <Card title="Quote Token Fee Capture" icon="coins"> Fees are aligned with quote-token collection, which is common for launches. </Card> <Card title="Short Launch Window" icon="hourglass-half"> The limiter is meant for early trading, not permanent pool behavior. </Card> </CardGroup> ## When To Choose Rate Limiter Use the rate limiter when the main risk is not just early timing, but early trade size. It is best for launches that want to allow public trading while making very large buys increasingly expensive during the first launch window. # DAMM v2 Time Scheduler Source: https://docs.meteora.ag/core-products/damm-v2/fees/time-scheduler Learn how DAMM v2 time scheduler fees can stay fixed or decay over configured time periods using linear or exponential curves. DAMM v2 time scheduler fees let a pool use a fixed base fee or start with a higher launch fee and reduce that fee over time. This is useful when a launch needs stronger early protection, but should gradually move toward normal trading conditions. Time scheduler fees are based on a clock: after trading activates, DAMM v2 counts configured periods and adjusts the fee as each period passes. ## How It Works A time scheduler uses four core settings: | Setting | Product Meaning | | - | - | | Cliff fee numerator | Starting fee when the pool opens | | Number of periods | How many fee reductions happen | | Period frequency | How long each period lasts | | Reduction factor | How much the fee changes each period | DAMM v2 supports two time scheduler curves: linear and exponential. ## Linear Time Scheduler The linear time scheduler decreases the fee numerator by the same fixed amount each period. ```math theme={"system"} \text{Fee Numerator} = \text{Cliff Fee Numerator} - (\text{Passed Periods} \times \text{Reduction Factor}) ``` In product terms, the fee walks down a staircase. Every step is the same size, so teams can explain exactly when the fee will drop and by how much. Use linear time scheduling when you want a simple, predictable launch schedule such as "fees decrease by the same amount every few minutes until the launch window ends." ## Exponential Time Scheduler The exponential time scheduler reduces the fee by applying the reduction factor each period. ```math theme={"system"} \text{Fee Numerator} = \text{Cliff Fee Numerator} \times \left(1 - \frac{\text{Reduction Factor}}{10{,}000}\right)^{\text{Passed Periods}} ``` In product terms, the fee drops faster early, then slows as it approaches the final fee. The exact on-chain calculation uses integer math. ## Fixed Fee Configuration A time scheduler can also behave as a fixed fee. If `period_frequency`, `number_of_period`, and `reduction_factor` are all zero, the program returns the cliff fee numerator for every swap. <Warning> If any of those three scheduler fields is non-zero, all three must be non-zero. Mixed zero/non-zero scheduler settings are invalid. </Warning> ## Pre-Activation Behavior If the current slot or timestamp is before the pool activation point, the time scheduler uses the final period. This path is used for pre-activation alpha-vault buying, not normal public trading. ## Why Use Time Scheduler Fees <CardGroup> <Card title="Launch Protection" icon="shield"> Early trades can face higher fees when launch sniping risk is often highest. </Card> <Card title="Predictable Decay" icon="clock"> Fees move according to a configured time schedule rather than manual updates. </Card> <Card title="Flexible Curve Choice" icon="chart-line"> Linear decay is easier to communicate, while exponential decay drops faster at the start. </Card> <Card title="Launchpad Friendly" icon="rocket"> Time schedulers work well for repeatable launch templates and public launch windows. </Card> </CardGroup> ## Linear vs Exponential | Curve | Best For | Fee Behavior | | - | - | - | | Linear | Simple, transparent schedules | Fee numerator decreases by a fixed amount each period | | Exponential | Strong early protection with faster early relief | Fee numerator decreases by a percentage-style factor each period | ## When To Choose It Use a time scheduler when the launch plan is time-based. If fees should come down after a fixed number of slots or seconds, time scheduling is the clearest choice. Use [Market Cap Scheduler Fees](/core-products/damm-v2/fees/market-cap-scheduler) instead when fees should decrease only as the pool price grows. # DAMM v2 Formulas Source: https://docs.meteora.ag/core-products/damm-v2/formulas Understand the product math behind DAMM v2 prices, liquidity, fees, compounding, and rewards. DAMM v2 is designed around constant-product liquidity. The formulas below explain the product math and the implementation details users most often need to reason about. On-chain values use integer math, so rounding matters. ## Constant Product The basic AMM idea is simple: ```math theme={"system"} x \times y = k ``` `x` is the token A reserve, `y` is the token B reserve, and `k` is the pool's liquidity invariant. In compounding mode this is reserve-based. In concentrated mode, the same idea is bounded by the pool's configured square-root price range. ## Price and Square-Root Price DAMM v2 stores price as a square-root price: ```math theme={"system"} \sqrt{P} = \sqrt{\frac{\text{token B amount}}{\text{token A amount}}} ``` This format makes liquidity math more precise and efficient on-chain. Product users can still think of it as the pool price expressed in a form that is easier for the program to update during swaps and liquidity changes. ## Concentrated Liquidity In concentrated liquidity mode, a DAMM v2 pool has a fixed lower and upper square-root price: ```math theme={"system"} \sqrt{P_{\min}} \le \sqrt{P} \le \sqrt{P_{\max}} ``` For a liquidity amount `L`, the token amounts are: ```math theme={"system"} \Delta A = L \times \left(\frac{1}{\sqrt{P}} - \frac{1}{\sqrt{P_{\max}}}\right) ``` ```math theme={"system"} \Delta B = L \times (\sqrt{P} - \sqrt{P_{\min}}) ``` The program rounds required deposit amounts up and withdrawal or swap output amounts down. Token A calculations also guard against values larger than `u64::MAX`. ## Compounding Liquidity In compounding mode, DAMM v2 uses full-range constant-product liquidity and prices the pool from reserves: ```math theme={"system"} \text{token A reserve} \times \text{token B reserve} = k ``` ```math theme={"system"} P = \frac{\text{token B reserve}}{\text{token A reserve}} ``` At initialization, compounding mode derives reserves from liquidity and square-root price: ```math theme={"system"} A_0 = \left\lceil \frac{L}{\sqrt{P}} \right\rceil ``` ```math theme={"system"} B_0 = \left\lceil \frac{L \times \sqrt{P}}{2^{128}} \right\rceil ``` The first position receives: ```math theme={"system"} L_{\text{position}} = L - (100 \ll 64) ``` because `100 << 64` is kept as dead liquidity in the pool. ## Trading Fees DAMM v2 fee rates are stored as numerators over `1,000,000,000`: ```math theme={"system"} \text{Total Fee Numerator} = \min(\text{Base Fee Numerator} + \text{Dynamic Fee Numerator}, \text{Pool Fee Cap}) ``` For fees taken from an amount that already includes the fee, the program rounds the fee up: ```math theme={"system"} \text{Trading Fee} = \left\lceil \frac{\text{Included Amount} \times \text{Fee Numerator}}{1{,}000{,}000{,}000} \right\rceil ``` For fees added to an amount that excludes the fee: ```math theme={"system"} \text{Included Amount} = \left\lceil \frac{\text{Excluded Amount} \times 1{,}000{,}000{,}000}{1{,}000{,}000{,}000 - \text{Fee Numerator}} \right\rceil ``` After the trading fee is calculated, DAMM v2 splits it: ```math theme={"system"} \text{Protocol Fee} = \left\lfloor \text{Trading Fee} \times \frac{\text{Protocol Fee Percent}}{100} \right\rfloor ``` ```math theme={"system"} \text{LP Fee Before Compounding} = \text{Trading Fee} - \text{Protocol Fee} ``` If the pool uses compounding mode, the LP fee can be split again: ```math theme={"system"} \text{Compounding Fee} = \left\lfloor \text{LP Fee Before Compounding} \times \frac{\text{Compounding Fee Bps}}{10{,}000} \right\rfloor ``` ```math theme={"system"} \text{Claimable Fee} = \text{LP Fee Before Compounding} - \text{Compounding Fee} ``` If a referral is present, the referral fee is taken from the protocol fee: ```math theme={"system"} \text{Referral Fee} = \left\lfloor \text{Protocol Fee} \times \frac{\text{Referral Fee Percent}}{100} \right\rfloor ``` DAMM v2's default protocol fee percent is `20`, and the referral fee percent is `20` of the protocol fee when a referral account is used. ## Dynamic Fee Dynamic fees use a volatility accumulator. When price changes quickly, the accumulator rises. When the market calms down, it decays. ```math theme={"system"} \text{Dynamic Fee Numerator} = \left\lceil \frac{(\text{Volatility Accumulator} \times \text{Bin Step})^2 \times \text{Variable Fee Control}}{100{,}000{,}000{,}000} \right\rceil ``` In the current implementation, dynamic fee `bin_step` must be `1` bps and `bin_step_u128` must match the default 1 bps fixed-point value. `filter_period` must be lower than `decay_period`, and both `variable_fee_control` and `max_volatility_accumulator` are capped at `0xffffff`. ## Liquidity Mining Rewards DAMM v2 liquidity mining distributes reward tokens by position liquidity: ```math theme={"system"} \text{Reward Per Liquidity} = \frac{\text{Elapsed Time} \times \text{Reward Rate}}{\text{Total Pool Liquidity}} ``` ```math theme={"system"} \text{Position Reward} = \text{Position Liquidity} \times \text{Reward Per Liquidity Since Last Checkpoint} ``` This means LPs earn rewards in proportion to their share of pool liquidity. Unlocked, vesting, and permanently locked liquidity can all count toward rewards because the position's total liquidity is used for reward accounting. The reward rate is stored as a fixed-point value scaled by `2^64`, while reward-per-liquidity accounting is accumulated with a `2^128` liquidity scale. Integer division truncates fractional rewards. # DAMM v2 Liquidity Mining Source: https://docs.meteora.
프로젝트로 돌아가기