ERC-8377 Execution-time reference price slippage protection (Reference-Relative Slippage Bounds)

Draft · Vaults & DeFi · created 2026-08-05

A swap protection standard that calculates the slippage floor using the real-time reference price at execution time, instead of a minimum receive amount fixed at signing time, narrowing the window for sandwich attacks.

Why it is needed

Swaps are usually protected by a single minAmountOut set when the transaction is created. This value is set based on the price of the block at signing time, but actual execution happens several blocks later, so even if a sandwich bot moves the pool price in between, the attack succeeds as long as the received amount stays above that fixed minimum, and the user has no way to notice. To avoid failed trades during volatility, wallets set slippage tolerance generously at 1 to 3 percent, and that margin becomes exactly what an attacker can take. Also, because routers, aggregators, and wallets each implement slippage differently, there is no way to compare or improve the level of protection across them.

What to implement

In depth

SlippagePolicy struct

The policy consists of quoteOracle (the ERC-7726 oracle address), expectedCostBps (the normal cost combining fees and price impact, capped at 10,000), maxDeviationBps (the additional adversarial shortfall allowed on top of that, capped at 10,000), hardFloor (the absolute minimum output accepted regardless of the reference price), and deadline (the last Unix timestamp at which this transaction intent is valid, unlimited if 0). The floor actually applied is whichever is larger between the reference-price-based floor and hardFloor.

Why expectedCostBps and maxDeviationBps are separated

Because the reference price returned by ERC-7726 is a mid price with no fees or price impact mixed in, even a normal fill always comes in lower than that. If there were only a single tolerance, it would have to absorb that normal cost too, pushing it well past 100bps and bringing back the wide attack margin this standard is meant to reduce. Separating the normal cost (expectedCostBps) from the adversarial shortfall (maxDeviationBps) lets honest execution cost be subtracted first, leaving only the adversarial deviation to monitor.

Floor calculation procedure

The execution contract gets referenceOut from IERC7726(quoteOracle).getQuote(amountIn, tokenIn, tokenOut). It subtracts the normal cost to get the expected output with expectedOut = referenceOut * (10,000 - expectedCostBps) / 10,000, and sets the final floor with floor = max(expectedOut * (10,000 - maxDeviationBps) / 10,000, hardFloor). If the actual output amount is less than this floor, it reverts with SlippageExceeded(realizedOut, floor).

Oracle freshness and independence requirements

Because ERC-7726's getQuote itself is stateless and does not guarantee freshness, this standard requires using only an oracle that enforces a freshness limit and reverts when it cannot be trusted. Also, quoteOracle cannot be the spot price of the pool where the current trade is being executed. If an attacker moves that pool, the reference price and the floor move together, and the protection falls into a self-referential contradiction.

Output amount is measured, not reported

swapWithPolicy does not trust the number reported by the route (routeData). Instead, it directly measures the change in the recipient's tokenOut balance before and after route execution and uses that as amountOut. Even if a malicious or buggy route reports success for an amount it never actually paid out, this measurement approach catches it. The measurement target is also set to recipient rather than the execution contract itself, so protection is not broken even if the execution contract intercepts the output in between.

The role of deadline

Because the reference-price-based floor is recalculated at execution time, there is no problem from a stale price, but the decision to trade itself can still become stale. deadline sets the last moment at which this signed intent is valid, so after that point it reverts immediately with DeadlineExpired before reading the oracle or executing the route. If deadline is 0, it is unlimited. However, this does not guarantee inclusion itself, and it cannot stop builders or relays from holding the transaction until the expiration point.

Relationship to ERC-5143

ERC-5143 is a standard that attaches a fixed minimum value set directly by the caller to an ERC-4626 vault's deposit, mint, withdraw, and redeem. This standard is complementary to ERC-5143 in that it widens the scope from vaults to general swaps and derives the floor from a real-time reference price read from ERC-7726 instead of a fixed value.

Interface detection and standard status

Implementations must support ERC-165 and supportsInterface must return true for 0x41b46b60, the interface ID of ISlippageBoundedSwap. This proposal is currently in Draft status, still undergoing community discussion and review, so details may change or progress may stall.

Things to watch out for

Original ERC · ← ERCs