You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It assumes that the browser bundle has been added to the codepen (or page), exposing the synthetix global to window.
constnetwork='mainnet';const{ formatEther }=window.synthetix.ethers.utils;constsnxjs=window.synthetix({ network });// this instance exposes props for the given network: synths, sources, targets, users, as well as helper function toBytes32 - as per synthetix: https://github.com/Synthetixio/synthetix/blob/develop/index.js#L199constsynths=snxjs.synths.map(({ name })=>name);constfromBlock=blockTarget.value;constblockOptions=fromBlock ? {blockTag: Number(fromBlock)} : {};lettotalInUSD=0;// note how I can pass it a string and it will convert it to bytes32 for meconstsnxPrice=formatEther(awaitsnxjs.ExchangeRates.rateForCurrency('SNX',blockOptions));// note blockOptions must be passed to `ethers.Contract` as the final parameter (and fails if no archive node)// or better yet, can't we just expose these functions top level? constsnxPrice=formatEther(awaitsnxjs.rateForCurrency('SNX',blockOptions));letresults=awaitPromise.all(synths.map(asyncsynth=>{consttotalAmount=awaitsnxjs[synth].contract.totalSupply(blockOptions);consttotalSupply=formatEther(totalAmount);constrateForSynth=formatEther(awaitsnxjs.rateForCurrency(synth,blockOptions));consttotalSupplyInUSD=rateForSynth*totalSupply;totalInUSD+=totalSupplyInUSD;constrateIsFrozen=awaitsnxjs.rateIsFrozen(synth,blockOptions);return{ synth, totalAmount, totalSupply, rateForSynth, totalSupplyInUSD, rateIsFrozen };}));
The text was updated successfully, but these errors were encountered:
This is from the codepen I have on synth distribution: https://codepen.io/justinjmoses/pen/vMKywz
It assumes that the browser bundle has been added to the codepen (or page), exposing the
synthetix
global towindow
.The text was updated successfully, but these errors were encountered: