We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Stonewater-Digital/snowdrop-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
"""Assess DEX liquidity depth for a potential trade."""
from __future__ import annotations
from datetime import datetime, timezone
from typing import Any
TOOL_META: dict[str, Any] = {
"name": "liquidity_depth_analyzer",
"description": "Estimates price impact and slippage for CFMM pools.",
"inputSchema": {
"type": "object",
"properties": {
"pool_reserves": {"type": "object"},
"trade_size": {"type": "number"},
},
"required": ["pool_reserves", "trade_size"],
},
"outputSchema": {
"type": "object",
"properties": {
"status": {"type": "string"},
"data": {
"type": "object",
"properties": {
"price_impact_pct": {"type": "number"},
"slippage_pct": {"type": "number"},
"effective_price": {"type": "number"},
"recommendation": {"type": "string"},
},
},
"timestamp": {"type": "string"},
},
},
}
def liquidity_depth_analyzer(
pool_reserves: dict[str, Any],
trade_size: float,
**_: Any,
) -> dict[str, Any]:
"""Return price impact diagnostics for an xy=k pool."""
try:
token_a_reserve = float(pool_reserves.get("token_a_reserve"))
token_b_reserve = float(pool_reserves.get("token_b_reserve"))
if token_a_reserve <= 0 or token_b_reserve <= 0:
raise ValueError("Pool reserves must be positive")
if trade_size <= 0:
raise ValueError("trade_size must be positive")
mid_price = token_b_reserve / token_a_reserve
k = token_a_reserve * token_b_reserve
new_token_a = token_a_reserve + trade_size
new_token_b = k / new_token_a
token_b_out = token_b_reserve - new_token_b
effective_price = token_b_out / trade_size
price_impact = (effective_price - mid_price) / mid_price
slippage = abs(price_impact) * 100
if slippage < 1:
recommendation = "proceed"
elif slippage < 3:
recommendation = "caution"
else:
recommendation = "abort"
data = {
"price_impact_pct": round(price_impact * 100, 4),
"slippage_pct": round(slippage, 4),
"effective_price": round(effective_price, 8),
"recommendation": recommendation,
}
return {
"status": "success",
"data": data,
"timestamp": datetime.now(timezone.utc).isoformat(),
}
except Exception as exc:
_log_lesson("liquidity_depth_analyzer", str(exc))
return {
"status": "error",
"data": {"error": str(exc)},
"timestamp": datetime.now(timezone.utc).isoformat(),
}
def _log_lesson(skill_name: str, error: str) -> None:
"""Append a Ralph Wiggum lesson entry."""
with open("logs/lessons.md", "a", encoding="utf-8") as handle:
handle.write(f"- [{datetime.now(timezone.utc).isoformat()}] {skill_name}: {error}\n")