DEX essentials

Sender, spender and recipient: who does what in a swap?

Identify the account that signs, the contract authorized to spend, and the address that receives the output of a swap.

The sender initiates or authorizes an action, the spender has permission to move input tokens, and the recipient receives output. They can be different addresses. Seeing several addresses in one swap flow is therefore normal, but each needs a clear role.

Separate the three questions

  • Who authorizes? A user account may sign a transaction or order.
  • Who can transfer the input? A token allowance or another authorization mechanism names a spender.
  • Where does the output go? The execution request specifies a recipient, directly or through protocol rules.

The ERC-20 standard distinguishes balances, transfers and third-party spending allowances. 0x's contract guide provides a concrete example in which approval and execution responsibilities differ.

The transaction destination is not always the final recipient

Suppose Alice submits a call to Router R, permits Spender S to transfer Token A, and asks the route to deliver Token B to Bob. The outer transaction's destination is R. The token output recipient is Bob. Reading only the outer destination would misidentify who receives the purchased asset.

This is a hypothetical role map, not a recommendation to authorize any particular contract. Real implementations may combine roles or introduce additional settlement components.

Intermediaries do not necessarily own the economic result

A route may temporarily move tokens through contracts or pools while fulfilling one transaction. These transfers do not mean the user chose each intermediate address as a final beneficiary. The intended result is determined by the complete call and its enforced conditions.

When documenting a swap, label addresses by function rather than pasting an unexplained list. “Transaction target,” “approved spender” and “output recipient” are more informative than “swap address.” This vocabulary also makes inconsistencies easier to discuss: an unexpected recipient is a different issue from a different execution contract or an absent allowance.

For smart accounts and delegated execution, the transaction submitter can introduce another role. Avoid assuming that the account paying network charges must also own the input tokens.

Sources & verification (3)

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

  1. ERC-20: Token Standard

    Token transfer, allowance, optional symbol and decimals; standard is CC0.

    https://eips.ethereum.org/EIPS/eip-20
  2. Contracts | 0x Docs

    Approval and execution contracts have distinct roles.

    https://docs.0x.org/docs/core-concepts/contracts
  3. Transactions | ethereum.org

    Transaction fields, native value versus calldata, inclusion and finality.

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

Continue reading

Why transaction value can be zero during a token swap What atomic execution means for a DEX route DEX aggregator vs bridge: trading and moving assets