Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send excess tokens when using maxDestAmount on Kyber trade #447

Open
ilanDoron opened this issue Oct 10, 2019 · 0 comments
Open

Send excess tokens when using maxDestAmount on Kyber trade #447

ilanDoron opened this issue Oct 10, 2019 · 0 comments

Comments

@ilanDoron
Copy link
Contributor

Current trade flow (assuming maxDestAmount is valid):

  1. network query rate from reserve with src amount. rate result name networkRate
  2. actualSrcAmount = destAmount / networkRate
  3. call reserve.trade with actualSrcAmount and networkRate
  4. when actualSrcAmount << traderSrcAmount --> actualRate << networkRate and we have extra tokens from trade.
  • for FPR we don't have extra tokens, since it uses networkRate for the trade.
  1. reserve calculates expectedDestAmount = actualSrcAmoun * networkRate
  2. reserve sends to network expectedDestAmount

required fixes:

  1. reserve sends network total received amount from the trade.
  2. reserve.trade API returns totalAmount as return value.
  3. network reads total amount and claims the full amount.
  4. network sends trader the full amount.

This fix requires API change = reserve interface should be updated across all deployed reserves.

@ilanDoron ilanDoron changed the title Send token "change" when using maxDestAmount on Kyber trade Send excess tokens when using maxDestAmount on Kyber trade Oct 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant