Pricing exchanges of cryptocurrency
Feb. 6th, 2025 09:05 am![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
At work, I had to learn about a particular distributed cryptocurrency exchange. Liquidity is provided by set of reserves that each contain coins of two different kinds, an equal value of each.
For pricing an exchange "from" the coin we hold "to" the coin we want, using one of these reserves of two different kinds of coin, we have:
I found this quite interesting. In my ignorance, I don't know if it's a standard approach for such currency exchanges. The formula seems to have some reasonable properties, in terms of things like how the price increases as one's swapping to a currency that there is now less of (or would be less of after the swap).
(Dreamwidth doesn't appear to allow
For pricing an exchange "from" the coin we hold "to" the coin we want, using one of these reserves of two different kinds of coin, we have:
- rf
- how much of the "from" coin is in the reserve
- rt
- how much of the "to" coin is in the reserve
- af
- how much of the "from" coin we want to exchange
- at
- how much of the "to" coin we are to receive
- cn
- a constant determining the transaction cost
- cd
- another constant determining the transaction cost, a little larger than cn
at = (af × rt × cn) / (af × cn + rf × cd)
I found this quite interesting. In my ignorance, I don't know if it's a standard approach for such currency exchanges. The formula seems to have some reasonable properties, in terms of things like how the price increases as one's swapping to a currency that there is now less of (or would be less of after the swap).
(Dreamwidth doesn't appear to allow
<math>
markup so I did what I could.)