Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
JavaScript
require("dotenv").config();
const BN = require("bn.js") 

const { sushiPrice} = require('./assist/sushiswap');
const { uniswapV2Price } = require('./assist/uniswapV2');
const { uniswapV3Price } =require('./assist/uniswapV3');
const { kyberPrice} = require('./assist/kyber')
const { pow} = require('./assist/math');



// Define token
 const token0address = process.env.weth
 const token1address = process.env.mkr
 let decima10 = 18 
 let decima11 = 18 
let tradeAmount = pow(10, decima10).mul(new BN (100))
 
 
 
const checkPrice = async() 
         const amountOutSushi = await sushiPrice (token0address, decimal0, tokenladdress, decimall, tradeAmount); 
         const  amountOutUniV2 = await 
uniswapV2Price (token0address Price(tokenaddress, decimal0, tokenladdress, decimal1, tradeAmount); 
         const  amountOutUniV3 =  await  
uniswapV3Price(token0address Price(token@address, decimal0, tokenladdress, decimall, tradeAmount); 
         const amountOutKyper = await kyberPrice (token0address, toe(token@address, token1address, tradeAmount) 
         console.log(amountOutSushi, amountOutUniV2, amountOutUniv
         
} 
checkPrice(); 
  

   
iV2, amountOutUniV3, amountOutKyper)


Hello friends, when running this code, it gives an error. No matter how much I think, I don't understand how to remove this error.
Can anyone help me?

What I have tried:

I expect this code to show me the price difference between decentralized exchanges, and I compiled the code in javascript online and remix environment, but it gives an error.
Posted
Updated 14-Jul-23 0:44am
v3
Comments
Richard MacCutchan 14-Jul-23 2:49am    
"when running this code, it gives an error."
What error, and where does it occur?
OriginalGriff 14-Jul-23 3:18am    
"It doesn't work" is probably the most useless problem report we get - and we get it a lot. It tells us nothing about what is happening, or when it happens.
So tell us what it is doing that you didn't expect, or not doing that you did.
Tell us what you did to get it to happen.
Tell us any error messages.
Use the "Improve question" widget to edit your question and provide better information.
Graeme_Grant 14-Jul-23 3:29am    
Hmmm... That tends to happen when using someone else's code or if asking ChatGPT to write it for you.

1 solution

At a guess it could be the fact that you create two variables named decima10 (decima-one-zero) and decima11 (decima-one-one), but then try to use two variables named decimal0 (decima-ell-zero)and decimal1 (decima-ell-one).
JavaScript
 let decima10 = 18 
 let decima11 = 18 
let tradeAmount = pow(10, decima10).mul(new BN (100))
 
 
 
const checkPrice = async() 
         const amountOutSushi = await sushiPrice (token0address, decimal0, tokenladdress, decimall, tradeAmount); 
         const  amountOutUniV2 = await 
uniswapV2Price (token0address Price(tokenaddress, decimal0, tokenladdress, decimal1, tradeAmount); 
         const  amountOutUniV3 =  await  
uniswapV3Price(token0address Price(token@address, decimal0, tokenladdress, decimall, tradeAmount); 

But that is still a guess as you did not tell us what the error is.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900