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

Error: overflow (fault="overflow", operation="toNumber") #38

Closed
chekun opened this issue Aug 17, 2020 · 2 comments
Closed

Error: overflow (fault="overflow", operation="toNumber") #38

chekun opened this issue Aug 17, 2020 · 2 comments

Comments

@chekun
Copy link

chekun commented Aug 17, 2020

Hi guys, I follow the readme guide, but stuck with this error when calling getExpectedReturnWithGas, for destTokenEthPriceTimesGasPrice arg, it always return error with something like

Error: overflow (fault="overflow", operation="toNumber", value="925003271924762633938248194741364019606826595687598837055279805260905", code=NUMERIC_FAULT, version=bignumber/5.0.5)

Guide says arg destTokenEthPriceTimesGasPrice is returnAmount * gas_price, where returnAmount is result of getExpectedReturn(fromToken, destToken, amount, parts, flags), how do i get into this error? Please help me , Thank you very much.

Example code:

const { returnAmount, distribution } = await contract.methods.getExpectedReturn(
  '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
  daiAddress,
  web3.utils.toWei('100', 'ether'),
  parts,
  0x00,
).call();
console.log('expected return -> ', returnAmount);
const destTokenEthPriceTimesGasPrice = web3.utils.toBN(returnAmount).mul(web3.utils.toBN(200*Math.pow(10, 9)));

const { returnAmount: a, estimateGasAmount,  distribution: b} = await contract.methods.getExpectedReturnWithGas(
  '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
  daiAddress,
  web3.utils.toWei('100', 'ether'),
  parts,
  0x00,
  destTokenEthPriceTimesGasPrice,
).call();
console.log(a);

PS: i'm using web3@1.2.1

@chekun chekun closed this as completed Aug 18, 2020
@m0onspell
Copy link

hey, how did you solve it? can you please share?

@chekun
Copy link
Author

chekun commented Oct 9, 2020

@m0onspell
could not recall how i resole it, maybe try to approve ahead?

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

2 participants