0

Is every trade in a decentralised exchange a new smart contract? How does exchanging work in decentralised exchanges?

1

Depends on the exchange, but I doubt a trade is a new contract in any dex (decentralized exchange).

A trade is typically a call to a certain function in a contract. That function executes the trade by calling some background contract functionality to calculate ratios and so on.

If you wish to trade token A for token B, the trade looks typically something like this:

  1. You call token A's token contract and add allowance for the dex to withdraw some amount of token A from you

  2. You call the dex to tell that you want to trade A for B

  3. The dex withdraws token A from you (because you have given it allowance to do so) and returns you token B

2
  • Hey. I am wondering. When the dev withdraws token A from me, who pays the gas price for that transaction? Or is there no gas price?
    – YulePale
    Apr 6 '21 at 12:05
  • 1
    Whoever issues the transaction, pays for it. So if person A withdraws token from somewhere, he issues a transaction for it, and since also pays for it. Apr 6 '21 at 12:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.