ethToTokenInput on the Uniswap V1 contract converts all the sent ether to tokens and transfers the tokens to the recipient.

Lets assume 1 ether buys you 3.9 tokens according to getInputPrice(). If you send 1 ether with ethToTokenInput(1, ...), the contract will send you 3 tokens even though 3 tokens only cost rougly 0.8 ether.

  • Why does this function not refund the remaining ~0.2 ether?
  • Is the "overpaid" ether distributed among liquidity providers (added to the eth_reserves)?
  • In the function that you have linked, there is no indication of what you're saying. The only thing you "lose" is the non-integer part of token wei. – goodvibration May 18 '20 at 4:24
  • Yeah, what I am saying is that in this example it doesnt matter if I send 1 ether or 0.8 ether: I will get 3 tokens for it. My question is, why is there no refund implemented to refund the amount above the price for the floored token amount. If you use ethToTokenOutput() instead, there is such a refund mechanic implemented. I was wondering why for one function its there and for another its missing – Newti May 18 '20 at 18:39

Your Answer

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

Browse other questions tagged or ask your own question.