> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cryptechtoday.com/llms.txt
> Use this file to discover all available pages before exploring further.

# AMM Liquidity & Exit Calculator

> Calculate real-world cashout amounts, price impact, and slippage before submitting a DEX swap

# AMM Exit Liquidity & Slippage Calculator

On decentralized exchanges (Uniswap, PancakeSwap, Raydium), tokens with small liquidity pools suffer dramatic price impact on larger sell orders.

In this recipe, you will learn how to use CrypTech's `sellability` object to inspect simulated cashouts from $100 to $50,000 to determine if an exit order will execute cleanly or suffer catastrophic slippage.

***

## Step 1: Install Axios

```bash theme={null}
npm install axios
```

***

## Step 2: Calculator Script (`exit_calculator.ts`)

```typescript theme={null}
import axios from 'axios';

interface Scenario {
  price_impact: string;
  sell_tax: string;
  total_cost: string;
  verdict: string;
  you_receive: string;
}

interface AnalyzeResponse {
  name: string;
  symbol: string;
  sellability: {
    is_sellable: boolean;
    sellability_label: string;
    max_safe_exit_usd: number;
    exit_scenarios: Record<string, Scenario>;
  };
}

async function verifyDEXExit(contractAddress: string) {
  const apiKey = process.env.CRYPTECH_API_KEY;
  if (!apiKey) {
    throw new Error('Please set CRYPTECH_API_KEY in your environment');
  }

  const { data } = await axios.post<AnalyzeResponse>(
    'https://api.cryptechtoday.com/api/v1/analyze',
    { address: contractAddress, chain: 'ethereum' },
    {
      headers: {
        'X-API-Key': apiKey,
        'Content-Type': 'application/json'
      }
    }
  );

  const { sellability, symbol, name } = data;

  console.log(`\n========================================`);
  console.log(`📊 AMM Exit Analysis: ${name} ($${symbol})`);
  console.log(`========================================`);
  console.log(`Status: ${sellability.sellability_label}`);
  console.log(`Can Sell: ${sellability.is_sellable ? 'YES ✅' : 'NO ❌'}`);
  console.log(`Max Safe Single Exit: $${sellability.max_safe_exit_usd.toLocaleString()}`);

  console.log(`\nCashout Simulation Matrix:`);
  console.log(`----------------------------------------------------------------------`);
  console.log(`Tier         | You Receive   | Price Impact | Total Cost | Verdict`);
  console.log(`----------------------------------------------------------------------`);

  for (const [tier, scenario] of Object.entries(sellability.exit_scenarios)) {
    const formattedTier = tier.replace('sell_', '').padEnd(12);
    const receive = scenario.you_receive.padEnd(13);
    const impact = scenario.price_impact.padEnd(12);
    const cost = scenario.total_cost.padEnd(10);
    console.log(`${formattedTier} | ${receive} | ${impact} | ${cost} | ${scenario.verdict}`);
  }
  console.log(`----------------------------------------------------------------------\n`);
}

// Example usage: ChainLink Token
verifyDEXExit('0x514910771AF9Ca656af840dff83E8264EcF986CA');
```

***

## Step 3: Output Preview

Running the script produces:

```text theme={null}
========================================
📊 AMM Exit Analysis: ChainLink Token ($LINK)
========================================
Status: LIQUID 🟢 (Normal exit possible)
Can Sell: YES ✅
Max Safe Single Exit: $10,000

Cashout Simulation Matrix:
----------------------------------------------------------------------
Tier         | You Receive   | Price Impact | Total Cost | Verdict
----------------------------------------------------------------------
$100         | $99.98        | 0.02%        | 0.02%      | ✅ Safe exit
$500         | $499.39       | 0.12%        | 0.12%      | ✅ Safe exit
$1,000       | $997.56       | 0.24%        | 0.24%      | ✅ Safe exit
$5,000       | $4939.58      | 1.21%        | 1.21%      | ✅ Safe exit
$10,000      | $9761.21      | 2.39%        | 2.39%      | ✅ Safe exit
$50,000      | $44550.71     | 10.90%       | 10.90%     | 🟠 Costly exit
----------------------------------------------------------------------
```


## Related topics

- [Introduction](https://docs.cryptechtoday.com/index.md)
- [Analyze Token](https://docs.cryptechtoday.com/api-reference/analyze-token.md)
- [AI & Model Context Protocol (MCP)](https://docs.cryptechtoday.com/ai-mcp/claude-cursor-mcp.md)
- [Quickstart](https://docs.cryptechtoday.com/quickstart.md)
- [Market Regime](https://docs.cryptechtoday.com/api-reference/market-regime.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.