Skip to content

Is there a mistake in which formula to use when buying certain amount of X tokens ? #100

Discussion options

You must be logged in to vote

@falcon-lin-development
No need to switch the variables x and y and use the Δy formula. Instead, use the provided formulas as intended:

  • To find the output amount of token y when selling a known amount of token x, use Δy = (yrΔx) / (x+rΔx).
  • To find the input amount of token x needed to buy a known amount of token y, use Δx = (xΔy) / (r(y−Δy)).
    These formulas already incorporate the transaction fees and respect the relationships between supply and demand.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@falcon-lin-development
Comment options

Answer selected by falcon-lin-development
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants