---
eip: 8377
label: ERC-8377
title: Reference-Relative Slippage Bounds
status: Draft
type: Standards Track
category: ERC
created: 2026-08-05
requires: 165, 7726
official: https://eips.ethereum.org/EIPS/eip-8377
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-8377.md
canonical: https://eips.huatuo.xyz/eip-8377/
lang: en
tldr: A draft swap interface where slippage is checked against a fresh oracle price read at execution time instead of a minAmountOut fixed at signing, narrowing the gap sandwich bots exploit.
tags: [defi, swap, slippage, mev, oracle]
---

# ERC-8377: Reference-Relative Slippage Bounds

> An interface for swap slippage relative to a live reference price at execution time, not a static minimum fixed at signing time

**TL;DR:** A draft swap interface where slippage is checked against a fresh oracle price read at execution time instead of a minAmountOut fixed at signing, narrowing the gap sandwich bots exploit.

## What problem does it solve?

Today a swap is protected by one number, `minAmountOut`, chosen when the transaction is built. That number is a target for MEV:

- **It goes stale.** It is based on a quote from block N, but the swap runs at block N+k. A sandwich bot can push the price within that gap; as long as the output stays above the stale floor, the attack is profitable and the user never notices.
- **It is set wide.** To avoid failed transactions, wallets often default to 1–3 % slippage, and that headroom is exactly what can be extracted.
- **No standard.** Every router encodes slippage differently.

ERC-8377 lets the caller send a slippage **policy** instead of a fixed floor. The contract reads a reference price at execution time from an [ERC-7726](/eip-7726/) quote oracle and derives the floor from it.

## How it works

The caller passes a `SlippagePolicy`:

| Field | Meaning |
| --- | --- |
| `quoteOracle` | ERC-7726 oracle giving a mid price; must enforce freshness and must not be the pool being traded |
| `expectedCostBps` | Honest, expected discount from mid (pool fee + modeled price impact) |
| `maxDeviationBps` | Extra adverse shortfall tolerated beyond the expected output |
| `hardFloor` | Absolute minimum output, whatever the oracle says |
| `deadline` | Unix time after which the trade intent expires (0 = none) |

`swapWithPolicy` then must, in order:

1. Reject bad policies (`bps > 10_000`) and a zero recipient.
2. Revert `DeadlineExpired` if the deadline has passed, before touching the oracle.
3. Call `getQuote(amountIn, tokenIn, tokenOut)` on the oracle (never trust a caller-supplied reference).
4. Compute `expectedOut = ref × (10000 − expectedCostBps) / 10000` and `floor = max(expectedOut × (10000 − maxDeviationBps) / 10000, hardFloor)`.
5. Run the route and measure the output as the **recipient's** `tokenOut` balance increase, not what the route reports.
6. Revert `SlippageExceeded` if the output is below the floor.

Separating expected cost from adverse deviation is the key idea: an honest fill is always a bit below mid, so a single tolerance would have to be wide again. Implementations must support [ERC-165](/eip-165/) with interface id `0x41b46b60`.

## Sample code

The floor logic at the heart of an implementation (Solidity, route execution left abstract):

```solidity
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.20;

interface IERC7726 {
    function getQuote(uint256 baseAmount, address base, address quote) external view returns (uint256);
}
interface IERC20 { function balanceOf(address) external view returns (uint256); }

struct SlippagePolicy {
    address quoteOracle; uint32 expectedCostBps; uint32 maxDeviationBps; uint256 hardFloor; uint256 deadline;
}

abstract contract SlippageGuard {
    error SlippageExceeded(uint256 realizedOut, uint256 floor);
    error InvalidPolicy(uint32 expectedCostBps, uint32 maxDeviationBps);
    error InvalidRecipient();
    error DeadlineExpired(uint256 deadline, uint256 timestamp);

    function _route(address tokenIn, address tokenOut, uint256 amountIn, address recipient, bytes calldata routeData) internal virtual;

    function swapWithPolicy(address tokenIn, address tokenOut, uint256 amountIn, address recipient,
        SlippagePolicy calldata p, bytes calldata routeData) external returns (uint256 amountOut)
    {
        if (p.expectedCostBps > 10_000 || p.maxDeviationBps > 10_000) revert InvalidPolicy(p.expectedCostBps, p.maxDeviationBps);
        if (recipient == address(0)) revert InvalidRecipient();
        if (p.deadline != 0 && block.timestamp > p.deadline) revert DeadlineExpired(p.deadline, block.timestamp);

        uint256 ref = IERC7726(p.quoteOracle).getQuote(amountIn, tokenIn, tokenOut);
        uint256 expectedOut = ref * (10_000 - p.expectedCostBps) / 10_000;
        uint256 floor = expectedOut * (10_000 - p.maxDeviationBps) / 10_000;
        if (p.hardFloor > floor) floor = p.hardFloor;

        uint256 before = IERC20(tokenOut).balanceOf(recipient);
        _route(tokenIn, tokenOut, amountIn, recipient, routeData);
        amountOut = IERC20(tokenOut).balanceOf(recipient) - before;

        if (amountOut < floor) revert SlippageExceeded(amountOut, floor);
    }
}
```

Example from the spec: reference 1000, expected cost 30 bps, deviation 50 bps → floor 992; a fill of 991 reverts.

## Things to know

- **Status: Draft.** Field layout and the interface id may still change.
- The oracle is the trust root. A stale or manipulable oracle makes the floor manipulable; callers must check that the specific oracle instance actually enforces a freshness bound.
- It narrows, but does not eliminate, MEV. Extraction within `maxDeviationBps`, back-running and reordering remain; combine it with private mempools or similar protections.
- Honest trades can revert if the venue legitimately diverges from the reference (thin liquidity, fast moves), so size `maxDeviationBps` for the venue.
- It is complementary to [ERC-5143](/eip-5143/), which adds static slippage bounds to ERC-4626 vault calls. Routers can offer both this and classic `minAmountOut` entrypoints.


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-8377
