Last active
January 20, 2021 01:22
-
-
Save ajb413/d14f36b5b11bea99818d051120dea500 to your computer and use it in GitHub Desktop.
Get COMP accrued for an account on mainnet using Compound.js (https://github.com/compound-finance/compound-js)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment