ERC20 – How Does ‘Swap’ Work Between ERC20 Tokens?

dapp-developmenterc-20exchangesswaps

What is "swap" presicely between ERC20 tokens? Is it exchanging one ERC20 token for the other without fees, in the most possible native way?

How is it different from "convert"?

Let's say I want to "swap" my Ethereum for Dai or some other ERC20 token. Can I do it on my own? I'm a programmer, so writing a bit of code, if required, for it would be ok.

Best Answer

What is "swap" presicely between ERC20 tokens? Is it exchanging one ERC20 token for the other without fees,

A "swap" is a trade, which may or may not include an explicit fee. By "trade" I mean you are buying one currency or token for another.

As we're talking about ERC20 tokens, and not derivatives*, the term "swap" has been popularised by decentralised exchanges such as Uniswap and Sushiswap. These exchanges charge an explicit fee of 0.3%. And they are just as the name suggests: exchanges, where two or more transacting parties can buy and sell (i.e. exchange) tokens from each other.

...in the most possible native way?

I think by this you mean "without fees, and for the correct current market price".

Which market? There are many markets, and prices aren't static. To get the "best" or "fairest" prices, you need to find the market with greatest liquidity. In general, you can't do this by yourself, you have to go somewhere that this liquidity exists (i.e. an exchange).

How is it different from "convert"?

What do you mean by convert? I would posit that there's no such thing as a currency conversion; there's only a trade.

When you go to a bank or Travelex desk at an airport you are not "converting" one currency for another, you're entering into commercial transaction. The bank or exchange is selling currency to you in exchange for another currency. (In their case they often claim not to charge fees, but in reality they just transact above the market rate in their own favour.) Do they have access to sufficient liquidity to give you a fair price? Probably. Do they? Not in my experience. (Yes, some banks claim to use the Interbank Exchange Rate... )

Let's say I want to "swap" my Ethereum for Dai or some other ERC20 token. Can I do it on my own?

Who will be on the other side of the trade? If you can find someone to trade with, then yes. But as above, you're more likely to get a "fair" price if you trade in a place with sufficient liquidity for fair prices to exist.

(*Not relevant here, but in the world of trading instruments, a swap is a type of financial instrument that defines a sequence of cash flows between parties.)

Related Topic