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).
- Use the
getCompBalanceMetadataExtmethod in the Lens contract https://etherscan.io/address/0xd513d22422a3062Bd342Ae374b4b9c20E0a9a074#code
- Lens address is posted here https://github.com/compound-finance/compound-protocol/blob/master/networks/mainnet.json#L11
- Here is the definition https://github.com/compound-finance/compound-protocol/blob/master/contracts/Lens/CompoundLens.sol#L278