Token swap

A token swap is a direct exchange of one token for another, most often on a decentralized exchange through a smart contract and a liquidity pool. The user places no orders and receives the new token at once, at a price calculated by the pool's formula.

How a swap works

The user picks a pair, say USDT for ether, enters an amount and sees a quote: how much they will receive, the fee and how far the trade will move the price. They then approve the contract to spend the token and sign the swap. The contract takes tokens from a liquidity pool according to an automated market maker formula, and the new coins land in the wallet right away. The word swap is also used for a simple conversion on a centralized exchange without an order book. Do not confuse it with a financial swap, a contract to exchange payments in the derivatives market.

What shapes the swap rate

Besides the market rate, three things affect the result. The pool fee, usually a fraction of a percent, goes to liquidity providers. Price impact: the larger the amount relative to the pool, the worse the average rate. Slippage: while the transaction waits for confirmation, the price may move, so the user sets a tolerance, for example 0.5%. On top comes the network fee for the transaction itself. Swap aggregators split a large trade across several pools and exchanges to get a better result.

Risks

The main risk is a counterfeit token. Anyone can create a token with the name and ticker of a popular coin, so buy only by a verified contract address. Setting slippage tolerance too wide makes the trade easy prey for bots that buy just before you and sell right after, which is known as a sandwich attack. An unlimited spending approval can later be exploited if the contract turns out to be malicious. Illiquid tokens may have so little money in the pool that selling back is impossible without huge losses.

Practical tips

Before a large swap, do a test with a small amount. Compare the result with quotes on several venues and check the price impact figure: if it is more than a couple of percent, split the trade or wait. Use a reasonable slippage tolerance and do not give unlimited approvals to unfamiliar contracts. For a Russian user, swapping one cryptocurrency for another may also create taxable income, so keep a record of trades. This is not investment advice.

Example

Hypothetical example: a pool holds 1,000 ETH and 3,000,000 USDT, so the price is 3,000 USDT per ETH. A user swaps 30,000 USDT, or 1% of the pool. By the formula they receive about 9.9 ETH rather than 10, an average price of about 3,030 USDT. Another 0.3% goes to the pool fee, leaving roughly 9.87 ETH. Had they swapped 300,000 USDT, the price impact would have been about 10%, and splitting the trade would have made more sense.

Related terms

Decentralized ExchangeAutomated Market MakerSlippageLiquidity PoolToken Contract AddressSwap

On the site

Coin categoriesNew coinsMarket makers

This article was written by AI. Check specific rates, taxes and broker terms with primary sources.

↑ Top