initial commit

This commit is contained in:
Moon Man 2022-02-10 21:43:38 -07:00
commit 10dbdb4c68
2 changed files with 8624 additions and 0 deletions

37
index.js Normal file
View File

@ -0,0 +1,37 @@
const chainId = 8;
const name = "Ubiq";
const gransContractAddress = "0x0826180A4c981d5095Cb5c48BB2A098A44cf6f73";
const gransDecimals = 18;
const { ethers } = require("ethers");
const provider = new ethers.providers.JsonRpcProvider("http://localhost:8545", {name, chainId});
const UNISWAP = require('shinobi-sdk');
const CoinGecko = require('coingecko-api');
const CoinGeckoClient = new CoinGecko();
/*
const WUBQ = {
[chainId]: new UNISWAP.Token(
chainId,
"0x1FA6A37c64804C0D797bA6bC1955E50068FbF362", // wrapped ubiq erc20 contract
18,
"WUBQ",
"Wrapped Ubiq"
)
}
*/
const GRANS = new UNISWAP.Token(chainId, gransContractAddress, gransDecimals);
UNISWAP.Fetcher.fetchPairData(GRANS, UNISWAP.WETH[GRANS.chainId], provider).then(async pair => {
const route = new UNISWAP.Route([pair], UNISWAP.WETH[GRANS.chainId]);
const gransPerUbiq = route.midPrice.toSignificant(6);
const ubiqPerGrans = route.midPrice.invert().toSignificant(6);
const conversionData = await CoinGeckoClient.simple.price({ids: 'ubiq', vs_currencies: 'usd'});
const ubiqRate = conversionData.data.ubiq.usd;
const dollarsPerGrans = (ubiqPerGrans * ubiqRate).toFixed(2);
console.log(`1 GRANS is $${dollarsPerGrans}`);
});

8587
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff