EatTheBlocks Forum

Normalize Kyber Prices Returns Error (from the Flash Course)

const kyberResults = await Promise.all([

SyntaxError: await is only valid in async function
e[90m at wrapSafe (internal/modules/cjs/loader.js:1053:16)e[39m
e[90m at Module._compile (internal/modules/cjs/loader.js:1101:27)e[39m
e[90m at Object.Module._extensions…js (internal/modules/cjs/loader.js:1157:10)e[39m
e[90m at Module.load (internal/modules/cjs/loader.js:985:32)e[39m
e[90m at Function.Module._load (internal/modules/cjs/loader.js:878:14)e[39m
e[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)e[39m
e[90m at internal/main/run_main_module.js:17:47e[39m

I even copied and pasted the run-arbitrage.js code from the tutorial source code but still can not find the reason for the error.

You probably made a typo, await should always be wrapped in an async function. Make sure to copy paste exactly the code from the Github repo.

Thank you for the assist. I solved that error and now have another one. Please see below error and advise:

Error: Please pass numbers as strings or BN objects to avoid precision errors.
at Object.toWei (C:\Users\rwell\Desktop\Vero\profitable-flashloans\VFL\node_modules\web3-utils\src\index.js:280:15)
at Object. (C:\Users\rwell\Desktop\Vero\profitable-flashloans\VFL\run-arbitrage.js:18:35)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47


When you create a number with web3.utils.toWei(), make sure to pass number as string.