Skip to content

Instantly share code, notes, and snippets.

View kavithashanmugan's full-sized avatar

Kavitha Shanmugan kavithashanmugan

  • BreezeLearn Technologies
  • 13:19 (UTC -06:00)
View GitHub Profile
@kavithashanmugan
kavithashanmugan / comp_earned.md
Last active February 18, 2022 14:21 — forked from ajb413/comp_earned.md
How do I retrieve the "COMP earned" value from the Compound protocol? Get the amount of accrued COMP token for an address using the Ethereum blockchain.

How do I retrieve the "COMP earned" value?

With a Smart Contract or JSON RPC

Get the value of COMP earned for an address that uses the Compound protocol. This can be done using the Lens contract with JSON RPC or another Smart Contract. If you do an eth_call with JSON RPC, it is free (no gas costs).

  1. Use the getCompBalanceMetadataExt method in the Lens contract https://etherscan.io/address/0xdCbDb7306c6Ff46f77B349188dC18cEd9DF30299#code
  2. Lens address is posted here https://github.com/compound-finance/compound-protocol/blob/master/networks/mainnet.json#L17
  3. Here is the definition https://github.com/compound-finance/compound-protocol/blob/master/contracts/Lens/CompoundLens.sol#L278