Fees & trade costs

How failed attempts change the cost of completing a swap

Add paid failed attempts to the cost of a completed swap and distinguish observed attempt costs from uncertain success probabilities.

The cost of completing a swap includes network fees paid for failed attempts that belong to the same task. A successful receipt alone can understate the total. Conversely, a rejected wallet request or an unbroadcast transaction should not be assigned an onchain fee without evidence.

A realized attempt ledger

Suppose a hypothetical first attempt reverts after paying $0.45, a second reverts after paying $0.60, and a third completes with $0.90 of network cost. The task consumed $1.95 in network fees. Reporting only $0.90 omits more than half the spending.

If the completed swap's output is worth $997 against a $1,000 input benchmark, the task-level shortfall is $3 plus $1.95, or $4.95. Avoid deducting any embedded swap fee again from the $997 output.

Ethereum charges for executed computation even when a transaction fails. The actual fee depends on what occurred; not every failed transaction necessarily consumes the same amount.

A forecast needs more assumptions

You can build favorable and adverse budgets using one attempt, two attempts or another explicit count. That is a scenario analysis. It is not a prediction that a particular number of retries will be necessary.

An expected-cost model based on a success probability is more demanding. It needs a defensible estimate, comparable transaction conditions and a retry policy. Failures may be correlated: repeating an unchanged transaction against the same problem does not create independent chances of success.

Keep completion rate visible

When comparing interfaces over several swaps, report both fees spent and how many intended swaps completed. An option with a low average fee per attempt can still have a high cost per completed task.

Record failed attempts rather than deleting them from the sample. If a user abandons the trade after paying for failures, report an uncompleted task with costs; do not assign it a zero-cost successful outcome.

Sources & verification (1)

Source-check date is recorded in the article details. URLs are provided for manual verification. Use Copy to keep this page open.

  1. Ethereum gas and fees: technical overview

    Gas cost calculation, maximum fee versus actual cost, and fees for executed failed transactions.

    https://ethereum.org/developers/docs/gas/

Continue reading

Why moving through liquidity boundaries can affect swap gas Convert native-token gas into the swap's comparison currency Why the final network fee differs from the estimate