slippage-modeling
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSlippage Modeling
滑点建模
Estimate execution costs, model slippage curves from AMM mechanics and empirical quotes, and determine optimal trade sizes that keep costs within acceptable thresholds.
估算执行成本,基于AMM机制和实际报价构建滑点曲线模型,并确定能将成本控制在可接受阈值内的最优交易规模。
What Is Slippage?
什么是滑点?
Slippage is the difference between the expected price at the time you decide to trade and the actual execution price you receive. On decentralized exchanges, slippage is deterministic and measurable — unlike CEX slippage, which depends on hidden order book dynamics.
Example: You expect to buy a token at 0.001 SOL. Your trade executes at 0.00105 SOL. That 5% difference is slippage — it directly reduces your profit and increases your break-even threshold.
滑点是指你决定交易时的预期价格与实际成交时的执行价格之间的差额。在去中心化交易所(DEX)中,滑点是可确定、可量化的——这与中心化交易所(CEX)的滑点不同,后者取决于隐藏的订单簿动态。
示例:你期望以0.001 SOL的价格买入某代币,实际成交价格为0.00105 SOL。这5%的差额就是滑点——它会直接减少你的利润,提高盈亏平衡点。
Sources of Slippage
滑点的来源
1. AMM Price Impact (Primary Source)
1. AMM价格冲击(主要来源)
Automated market makers use bonding curves that move price as liquidity is consumed. On a constant-product AMM ():
x * y = kprice_impact = Δx / (x + Δx)Where is the reserve of the input token and is your trade size. A 1 SOL trade against a pool with 100 SOL reserves produces ~1% price impact. Against 10 SOL reserves, it produces ~10%.
xΔxSee for full derivations and CLMM adjustments.
references/slippage_math.md自动化做市商(AMM)采用绑定曲线,流动性被消耗时价格会随之变动。对于恒定乘积型AMM():
x * y = kprice_impact = Δx / (x + Δx)其中是输入代币的储备量,是你的交易规模。若在持有100 SOL储备的池中进行1 SOL交易,会产生约1%的价格冲击;若在仅持有10 SOL储备的池中交易,则会产生约10%的价格冲击。
xΔx完整推导过程及CLMM调整细节请参考。
references/slippage_math.md2. DEX Fees
2. DEX手续费
Every swap incurs a fee taken from the trade:
| DEX | Fee | Notes |
|---|---|---|
| Raydium | 0.25% | Standard AMM pools |
| Orca | 0.30% | Whirlpool concentrated pools |
| Meteora | 0.1–2.0% | Dynamic fees based on volatility |
| PumpFun | 1.0% | Bonding curve phase |
每笔交易都会收取手续费,从交易金额中扣除:
| DEX | 手续费 | 说明 |
|---|---|---|
| Raydium | 0.25% | 标准AMM池 |
| Orca | 0.30% | Whirlpool集中流动性池 |
| Meteora | 0.1–2.0% | 基于波动率的动态手续费 |
| PumpFun | 1.0% | 绑定曲线阶段 |
3. Priority Fees
3. 优先级手续费
Solana validators prioritize transactions with higher compute unit prices. During congestion or for time-sensitive trades:
- Normal: 0.0001 SOL (negligible)
- Competitive: 0.001–0.01 SOL
- High congestion: 0.01–0.1 SOL
Solana验证节点会优先处理计算单元价格更高的交易。在网络拥堵或时间敏感型交易场景下:
- 常规:0.0001 SOL(可忽略不计)
- 竞争型:0.001–0.01 SOL
- 高拥堵:0.01–0.1 SOL
4. MEV (Sandwich Attacks)
4. MEV(三明治攻击)
Searchers detect pending swaps and sandwich them — buying before your trade (raising the price) and selling after (capturing the difference). MEV cost depends on:
- Trade size (larger = more attractive target)
- Token liquidity (thin pools = easier to manipulate)
- Slippage tolerance setting (higher tolerance = more extractable)
Typical MEV cost: 0–200 bps on vulnerable trades.
搜索者会检测待处理的交易并进行三明治攻击——在你的交易前买入(推高价格),交易后卖出(赚取差价)。MEV成本取决于:
- 交易规模(规模越大,越容易成为目标)
- 代币流动性(流动性稀薄的池子更易被操纵)
- 滑点容忍度设置(容忍度越高,可提取的MEV越多)
典型MEV成本:易受攻击的交易为0–200 bps。
5. Stale Quotes
5. 报价过时
Between receiving a quote and landing the transaction on-chain (0.4–2 seconds on Solana), the price may move. Volatile tokens can shift 50–500 bps in that window.
在获取报价到交易上链的时间段内(Solana上为0.4–2秒),价格可能已发生变动。高波动代币在这段时间内的价格波动可达50–500 bps。
Constant-Product Slippage Formula
恒定乘积滑点公式
For a pool with reserves and invariant :
(x, y)k = x * yBuying tokens with SOL (input Δx SOL):
tokens_received = y * Δx / (x + Δx)
effective_price = Δx / tokens_received = (x + Δx) / y
spot_price = x / y
price_impact = effective_price / spot_price - 1 = Δx / (x + Δx)Selling tokens for SOL (input Δy tokens):
sol_received = x * Δy / (y + Δy)
effective_price = sol_received / Δy = x / (y + Δy)
spot_price = x / y
price_impact = 1 - effective_price / spot_price = Δy / (y + Δy)Key insight: Slippage scales with . This is approximately linear for small trades and accelerates sharply as trade size approaches reserve size.
trade_size / (reserves + trade_size)对于储备为、不变量为的池子:
(x, y)k = x * y用SOL买入代币(输入Δx SOL):
tokens_received = y * Δx / (x + Δx)
effective_price = Δx / tokens_received = (x + Δx) / y
spot_price = x / y
price_impact = effective_price / spot_price - 1 = Δx / (x + Δx)卖出代币换取SOL(输入Δy代币):
sol_received = x * Δy / (y + Δy)
effective_price = sol_received / Δy = x / (y + Δy)
spot_price = x / y
price_impact = 1 - effective_price / spot_price = Δy / (y + Δy)核心结论:滑点与成正比。对于小额交易近似线性增长,当交易规模接近储备量时,滑点会急剧上升。
交易规模 / (储备量 + 交易规模)Quick Reference Table
快速参考表
| Trade / Reserve Ratio | Approximate Slippage |
|---|---|
| 0.1% | 0.1% (1 bp) |
| 1% | 1.0% (100 bps) |
| 5% | 4.8% (476 bps) |
| 10% | 9.1% (909 bps) |
| 25% | 20% (2000 bps) |
| 50% | 33% (3333 bps) |
| 交易/储备比率 | 近似滑点 |
|---|---|
| 0.1% | 0.1%(1 bp) |
| 1% | 1.0%(100 bps) |
| 5% | 4.8%(476 bps) |
| 10% | 9.1%(909 bps) |
| 25% | 20%(2000 bps) |
| 50% | 33%(3333 bps) |
CLMM Slippage
CLMM滑点
Concentrated Liquidity Market Makers (Orca Whirlpools, Meteora DLMM) concentrate liquidity in specific price ranges:
- Within the active range: slippage is lower than constant-product by a concentration factor
- Crossing tick boundaries: additional slippage as the next tick's liquidity may be sparse
- Approximation:
clmm_slippage ≈ cp_slippage / concentration_factor
Typical concentration factors: 5–50x for well-managed positions.
集中流动性做市商(CLMM,如Orca Whirlpools、Meteora DLMM)将流动性集中在特定价格区间:
- 在活跃价格区间内:滑点比恒定乘积型AMM低,倍数为集中度因子
- 跨越刻度边界时:若下一刻度的流动性不足,会产生额外滑点
- 近似公式:
clmm_slippage ≈ cp_slippage / concentration_factor
典型集中度因子:管理良好的仓位为5–50倍。
Empirical Slippage Measurement
实际滑点测量
Theoretical formulas assume single-pool routing. In practice, Jupiter aggregates across multiple pools and routes. Empirical measurement is more accurate:
- Query Jupiter at multiple trade sizes (0.01, 0.1, 1, 5, 10, 50 SOL)
/quote - Record output amount and effective price at each size
- Compute slippage in bps relative to smallest trade (proxy for spot)
- Fit a power-law model:
slippage_bps = a * trade_size^b
This captures real routing behavior, multi-pool splitting, and available liquidity.
See for the full implementation.
scripts/slippage_curve.py理论公式假设单池路由,但实际中Jupiter会聚合多个池子进行路由。实际测量结果更准确:
- 针对不同交易规模(0.01、0.1、1、5、10、50 SOL)调用Jupiter 接口
/quote - 记录每个规模下的输出数量和有效价格
- 计算相对于最小交易规模(作为现货价格代理)的滑点(bps)
- 拟合幂律模型:
slippage_bps = a * trade_size^b
该模型能反映真实路由行为、多池拆分情况及可用流动性。
完整实现请参考。
scripts/slippage_curve.pyTotal Execution Cost Model
总执行成本模型
total_cost_bps = price_impact_bps + fee_bps + priority_fee_bps + mev_risk_bps
total_cost_sol = trade_size_sol * total_cost_bps / 10_000See for component breakdowns and worked examples.
references/cost_model.mdtotal_cost_bps = price_impact_bps + fee_bps + priority_fee_bps + mev_risk_bps
total_cost_sol = trade_size_sol * total_cost_bps / 10_000各组成部分的详细分解及示例请参考。
references/cost_model.mdBreak-Even Analysis
盈亏平衡分析
For a roundtrip (buy + sell):
roundtrip_cost_bps = entry_impact + exit_impact + 2 * fee_bps + 2 * priority_bps + mev_bpsThe token must move more than in your favor to be profitable. For a token with 200 bps entry slippage, 200 bps exit slippage, and 50 bps fees:
roundtrip_cost_bpsroundtrip = 200 + 200 + 50 = 450 bps = 4.5%You need at least a 4.5% price move just to break even.
See for automated cost estimation.
scripts/execution_cost.py对于往返交易(买入+卖出):
roundtrip_cost_bps = entry_impact + exit_impact + 2 * fee_bps + 2 * priority_bps + mev_bps代币价格必须向对你有利的方向变动超过才能盈利。若某代币的入场滑点为200 bps、出场滑点为200 bps、手续费为50 bps:
roundtrip_cost_bps往返成本 = 200 + 200 + 50 = 450 bps = 4.5%你需要至少4.5%的价格涨幅才能实现盈亏平衡。
自动化成本估算工具请参考。
scripts/execution_cost.pyOptimal Trade Sizing
最优交易规模
Maximum Size for Slippage Threshold
滑点阈值对应的最大交易规模
Given a slippage curve , solve for max trade size:
s(q) = a * q^bq_max = (threshold_bps / a) ^ (1/b)给定滑点曲线,求解最大交易规模:
s(q) = a * q^bq_max = (threshold_bps / a) ^ (1/b)Multi-Tranche Execution
分批次执行
For large orders, splitting reduces total slippage because each tranche faces a partially-reset order book (on CLMMs) or allows arbitrageurs to rebalance between tranches:
n_tranches = ceil(total_size / q_max)
tranche_size = total_size / n_tranches
wait_between = 2-10 seconds (allow arb rebalancing)对于大额订单,拆分交易可降低总滑点,因为每一批次面对的是部分重置的订单簿(CLMM场景),或允许套利者在批次间重新平衡流动性:
n_tranches = ceil(total_size / q_max)
tranche_size = total_size / n_tranches
wait_between = 2-10 seconds(等待套利者重新平衡)TWAP Strategy
TWAP策略
Time-Weighted Average Price execution:
- Divide total order into equal-sized tranches
- Execute one tranche per interval (e.g., every 10 seconds)
- Total slippage is significantly lower than single execution
- Tradeoff: price may move against you during execution window
时间加权平均价格(TWAP)执行:
- 将总订单拆分为等额批次
- 按固定间隔执行一批次(如每10秒一次)
- 总滑点远低于单次执行
- 权衡点:执行期间价格可能对你不利
Slippage by Token Category
不同代币类别的滑点情况
| Category | Typical Pool TVL | Slippage for 1 SOL | Slippage for 10 SOL |
|---|---|---|---|
| Blue chip | >$10M | <5 bps | <20 bps |
| Mid-cap | $100K–$10M | 10–50 bps | 50–500 bps |
| Small-cap | $10K–$100K | 50–200 bps | 500–2000 bps |
| Micro/PumpFun | <$10K | 200–2000 bps | Often impossible |
| 代币类别 | 典型池子TVL | 1 SOL交易滑点 | 10 SOL交易滑点 |
|---|---|---|---|
| 蓝筹币 | >$10M | <5 bps | <20 bps |
| 中市值币 | $100K–$10M | 10–50 bps | 50–500 bps |
| 小市值币 | $10K–$100K | 50–200 bps | 500–2000 bps |
| 微市值/PumpFun | <$10K | 200–2000 bps | 通常无法完成交易 |
Integration Points
集成点
- liquidity-analysis: Get pool TVL and reserve data to feed slippage estimates
- position-sizing: Use max trade size from slippage curve as a position size constraint
- jupiter-api: Fetch real quotes for empirical slippage measurement
- risk-management: Include execution costs in risk/reward calculations
- dex-pool-analysis: Understand pool mechanics that drive slippage
- liquidity-analysis:获取池子TVL和储备数据,为滑点估算提供输入
- position-sizing:将滑点曲线得出的最大交易规模作为仓位限制
- jupiter-api:获取实时报价用于实际滑点测量
- risk-management:将执行成本纳入风险/收益计算
- dex-pool-analysis:理解驱动滑点的池子机制
Files
文件
References
参考文档
| File | Description |
|---|---|
| AMM slippage derivations, CLMM adjustments, multi-pool routing math |
| Total execution cost components, break-even analysis, cost comparison tables |
| 文件 | 描述 |
|---|---|
| AMM滑点推导、CLMM调整、多池路由数学模型 |
| 总执行成本组成、盈亏平衡分析、成本对比表 |
Scripts
脚本
| File | Description |
|---|---|
| Build empirical slippage curves from Jupiter quotes, fit power-law model |
| Estimate total execution cost and break-even for a specific trade |
| 文件 | 描述 |
|---|---|
| 基于Jupiter报价构建实际滑点曲线,拟合幂律模型 |
| 估算特定交易的总执行成本及盈亏平衡点 |