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

amount parameter in takeOrder function #581

Open
bugduino opened this issue Sep 7, 2018 · 0 comments
Open

amount parameter in takeOrder function #581

bugduino opened this issue Sep 7, 2018 · 0 comments

Comments

@bugduino
Copy link

bugduino commented Sep 7, 2018

Hi
I'm trying to take orders (both a buys orders and sells orders), following the taker.js example
the problem I have is with the amount parameter.
The example is doing the following things

desiredAmountBase = 0.001;
fraction = Math.min(desiredAmountBase} / order.ethAvailableVolumeBase, 1);
const amount = order.amountGet.times(new BigNumber(String(fraction)));

I have the following questions:

  1. should I always use ethAvailableVolumeBase both for buys and sells?

  2. fraction would obviously be a floating point and so would be amount, but amount should always be in amountGet terms which is in wei and so don't need to be a floating point, is it correct and safe to do

    amount = amount.toNumber();

to truncate decimals?

  1. the amount should be written as something like

    const amount = (order.amountGet - order.amountFilled).times(new BigNumber(String(fraction)));

because otherwise you could potentially trying to get more quantity than the available one, is this reasoning correct?

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