Last active
May 22, 2021 15:28
-
-
Save bhavya2611/0c21eaf0d7cdecee66640230c76bbef3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get DOGECOIN price in ETH | |
const getDogecoinPriceInETH = async () => { | |
try { | |
const DOGECOIN = new Token( | |
ChainId.MAINNET, //ChainId for Ethereum Mainnet | |
"0x4206931337dc273a630d328da6441786bfad668f", //DOGECOIN address on Ethereum Mainnet | |
8 //Number of Decimals | |
); | |
const pair = await Fetcher.fetchPairData(DOGECOIN, WETH[DOGECOIN.chainId]); | |
const route = new Route([pair], WETH[DOGECOIN.chainId]); | |
return route.midPrice.toSignificant(6); | |
} catch (e) { | |
console.log(e); | |
return 0; | |
} | |
}; | |
// Get DOGECOIN price in BNB | |
const getDodgecoinPriceInBNB = async () => { | |
try { | |
const response = await fetch("https://api.pancakeswap.info/api/v2/tokens"); | |
const priceData = await response.json(); | |
return priceData.data["0xbA2aE424d960c26247Dd6c32edC70B295c744C43"].price_BNB; //Address of DOGECOIN on BSC Mainnet | |
} catch (e) { | |
console.log(e); | |
return 0; | |
} | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment