crypto_dex-slippage
Estimate slippage on a DEX trade using constant-product AMM math. Input trade amount and pool reserves to get effective price, price impact, and output after fees.
Instructions
DEX slippage estimator for constant-product AMM (x*y=k).
Use when estimating slippage on a DEX trade using constant-product AMM math. Provide trade size and pool reserves. Returns: effective price, price impact percentage, and output amount after slippage.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fee_bps | No | DEX fee in basis points (e.g. 30 = 0.3%) | |
| reserve_a | Yes | Pool reserve of token A | |
| reserve_b | Yes | Pool reserve of token B | |
| trade_amount | Yes | Amount of input token to swap | |
| trade_direction | No | Swap direction | a_to_b |