const Compound = require('@compound-finance/compound-js'); const provider = 'https://mainnet.infura.io/v3/' + process.env.infuraApiKey; // mainnet const CompoundLens = Compound.util.getAddress(Compound.CompoundLens); const LensAbi = Compound.util.getAbi(Compound.CompoundLens); const COMP = Compound.util.getAddress(Compound.COMP); const Comptroller = Compound.util.getAddress(Compound.Comptroller); const me = '0xa0df350d2637096571F7A701CBc1C5fdE30dF76A'; (async function() { let metadata = await Compound.eth.read( CompoundLens, 'getCompBalanceMetadataExt', [ COMP, Comptroller, me ], { provider, abi: LensAbi } ); console.log('allocated', +metadata.allocated.toString() / 1e18); })().catch(console.error);