
defi-math-mcp
defi-math-mcp computes impermanent loss via calc_il_v2 and calc_il_v3, V3 position characteristics with calc_v3_position, slippage using calc_curve_slippage, perp liquidation prices via calc_perp_liquidation, and LP vs HODL outcomes with compare_lp_vs_hodl. DeFi liquidity providers, traders, and developers use it to estimate risks, optimize ranges with optimize_v3_range, and rank strategies via compare_strategies without coding complex formulas.
Overview
The defi-math-mcp server delivers specialized calculators for DeFi mechanics like impermanent loss, slippage, yields, and position sizing. It enables users to quantify risks and returns in liquidity provision, perpetuals, and yield strategies using precise formulas. This matters for making data-driven decisions in volatile markets without deriving models manually.
Key Capabilities
Use calc_il_v2 to compute impermanent loss for constant-product AMMs given entry and current prices. calc_il_v3 estimates V3-style IL with range bounds and fee offsets, while calc_v3_position derives position traits from balances and ticks. Additional tools like calc_balancer_il, calc_curve_slippage, calc_perp_liquidation, compare_lp_vs_hodl, and optimize_v3_range handle weighted pools, stable swaps, funding costs, and range optimization.
Use Cases
A liquidity provider inputs entry price, current price, and range bounds into calc_il_v3 to check if fees offset IL before closing a position. A trader uses calc_perp_liquidation and calc_funding_rate_cost to assess liquidation risk and funding drag on a leveraged perpetual trade. An analyst runs compare_strategies and calc_yield_split to rank LP versus HODL outcomes, factoring in IL and gas costs. A yield farmer applies calc_gas_breakeven to determine if daily returns justify gas fees over time.
Who This Is For
DeFi traders, liquidity providers, and portfolio analysts familiar with AMMs, perps, and yield farming. Requires intermediate knowledge of DeFi concepts like ticks, invariants, and Kelly criterion. Developers integrating DeFi analytics into apps or dashboards will find the structured outputs directly usable.