CRYPTO NEWS

What is chainwork?

If I run the RPC call getBlock on the bitcoin-qt client it gives me field called chainwork containing a hash. I cant find any information what this value is about.

Request:

getblock 0000000000000000073dacdd0178da5158bd78c543fbc79bd0dacf56a2021bcc 

Result:

{ "hash" : "0000000000000000073dacdd0178da5158bd78c543fbc79bd0dacf56a2021bcc", "confirmations" : 1, "size" : 182400, "height" : 304962, "version" : 2, "merkleroot" : "b144b39759d4669cb92ca8b9084d68d1f05f1e28e16887bf062f37e3b5f79fd2", "tx" : [ "3edc72d280edd0a7719670a5f0c97e8991a5bcfcfcfa77620969643f04d021a3", "841840f8a7863c8fb99e26975d45ff9151b0a5f021fb479aa9ff91a138d3cd3f", "a01af3f203313cdab4e8977cd2dccbd416872c9d9f76968fc7009f47ad630199" ], "time" : 1402334610, "nonce" : 2351732739, "bits" : "185d859a", "difficulty" : 11756551916.90395200, "chainwork" : "0000000000000000000000000000000000000000000086859f7a841475b236fd", "previousblockhash" : "000000000000000031132699bcb917e7e6ce3cc6cce1f20b6ad36a437436c821" } 

Crypto Hats, Crypto Shirts, Crypto Socks, Crypto Clothing

getReserves() function does not provide the information of the swap price

I’ve made a function to get swap prices of the Sushiswap rates using getReserves() function. As I have learned, in order to get the current swap price of 2 tokens, I need to divide the amount of reserves of the first token by the amount of reserves. But when I try to use this function::Listen

I’ve made a function to get swap prices of the Sushiswap rates using getReserves() function. As I have learned, in order to get the current swap price of 2 tokens, I need to divide the amount of reserves of the first token by the amount of reserves. But when I try to use this function I get the call revert exception (method="getReserves()", errorArgs=null, errorName=null, errorSignature=null, reason=null, code=CALL_EXCEPTION, version=abi/5.4.0) error.

But the strange thing is that when I do the same function on wETH token, I get all the results I need – the actual price.

    const runBot = async () => {     const sushiFactory = new ethers.Contract(       '0xC0AEe478e3658e2610c5F7A4A2E1777cE9e4f2Ac',       UniswapV2Factory.abi, wallet,     );     const uniswapFactory = new ethers.Contract(       '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f',       UniswapV2Factory.abi, wallet,     );     const usdcAddress = '0x6b175474e89094c44da98b954eedeac495271d0f';     const wethAddress = '0x6b3595068778dd592e39a122f4f5a5cf09c90fe2';        const sushi_address = '0x6b3595068778dd592e39a122f4f5a5cf09c90fe2'     const bnb_address = '0xB8c77482e45F1F44dE1745F52C74426C631bDD52'     const usdc_address  = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'     const eth_address = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'     const dai_address = '0x6b175474e89094c44da98b954eedeac495271d0f'     const btc_address = '0x2260fac5e5542a773aa44fbcfedf7c193bc2c599'      let sushiEthDai;     let uniswapEthDai;        const loadPairs = async () => {       sushiEthDai = new ethers.Contract(         await sushiFactory.getPair(btc_address, dai_address),         UniswapV2Pair.abi, wallet,       );       uniswapEthDai = new ethers.Contract(         await uniswapFactory.getPair(btc_address, dai_address),         UniswapV2Pair.abi, wallet,       );     };        await loadPairs();      provider.on('block', async (blockNumber) => {       try {         console.log(blockNumber);       const sushiReserves = await sushiEthDai.getReserves();     const uniswapReserves = await uniswapEthDai.getReserves();          const reserve0Sushi = Number(ethers.utils.formatUnits(sushiReserves[0], 18));     const reserve1Sushi = Number(ethers.utils.formatUnits(sushiReserves[1], 18));      const reserve0Uni = Number(ethers.utils.formatUnits(uniswapReserves[0], 18));     const reserve1Uni = Number(ethers.utils.formatUnits(uniswapReserves[1], 18));      const priceUniswap = reserve0Uni / reserve1Uni;     const priceSushiswap = reserve0Sushi / reserve1Sushi;          const shouldStartEth = priceUniswap < priceSushiswap;     const spread = Math.abs((priceSushiswap / priceUniswap - 1) * 100);          console.log(`SUSHI PRICE ${reserve0Sushi / reserve1Sushi}`)   }     catch (err) {     console.error(err);      }      })      }         runBot() 

What is chainwork?

Shopping cart
There are no products in the cart!
Continue shopping
0