Skip to content

Instantly share code, notes, and snippets.

@jjgonecrypto
Created July 3, 2019 21:54
Show Gist options
  • Save jjgonecrypto/bd208ce7e53160e1542452953337d772 to your computer and use it in GitHub Desktop.
Save jjgonecrypto/bd208ce7e53160e1542452953337d772 to your computer and use it in GitHub Desktop.
Get total issued debt at some specific block
const { SynthetixJs } = require('synthetix-js');
const snxjs = new SynthetixJs();
(async () => {
const provider = snxjs.ethers.getDefaultProvider();
const currentBlock = await provider.getBlockNumber();
const totalDebtInSystemAtBlock = await snxjs.Synthetix.contract.totalIssuedSynths(
snxjs.utils.toUtf8Bytes4('sUSD'),
{ blockTag: currentBlock }
);
console.log(snxjs.utils.formatEther(totalDebtInSystemAtBlock));
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment