CalculateSlippage
Calculate slippage and price-impact decomposition for a proposed swap on a Uniswap V2 or V3 pool. Returns spot vs execution price, slippage percentage, slippage cost in output-token units, and price impact. Also returns the maximum trade size that stays within 1% slippage for V2 pools; V3 returns null for that field because tick-crossing math has not yet been inverted.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rpc_url | Yes | An Ethereum (or L2) JSON-RPC URL used to read live pool state. Required; supplied by you per call (BYO-RPC) and may carry your provider key. The endpoint stores and logs nothing — the URL is never persisted or written to logs. | |
| chain_id | No | Optional guard. If supplied and the RPC reports a different chain id, the call is rejected. Defaults to 1 (Ethereum mainnet) conceptually; omit to skip the check. | |
| lwr_tick | No | Lower tick of the position (V3 only; null for V2). | |
| upr_tick | No | Upper tick of the position (V3 only; null for V2). | |
| amount_in | No | Amount of token_in to trade, in human units. Must be > 0. | |
| pool_type | Yes | Which protocol the pool at pool_address belongs to. This tool accepts uniswap_v2 | uniswap_v3. | |
| amounts_in | No | Optional batch form of 'amount_in': an array of values to evaluate in a single call. The pool is read once and the result is an array with one entry per element, in input order. Supply EITHER 'amount_in' (single) OR 'amounts_in' (batch), not both. Max 256 entries. | |
| block_number | No | Optional block number to pin the read to a historical block. Omit to read the latest block. | |
| pool_address | Yes | On-chain address of the pool/pair to analyze (Uniswap V2/V3 pair, Balancer weighted pool, or Curve stableswap pool). Required. Lowercase, uppercase, or checksum casing all work. | |
| token_in_name | Yes | Symbol of the input token for the trade (e.g. 'USDC', 'WETH'). Must be one of the two tokens in the pool. |