Skip to content

Instantly share code, notes, and snippets.

@gregorynicholas
Forked from ajb413/comp_earned.md
Created November 8, 2020 18:15
Show Gist options
  • Save gregorynicholas/c988d294ba5572e8f730051d7c424f7e to your computer and use it in GitHub Desktop.
Save gregorynicholas/c988d294ba5572e8f730051d7c424f7e to your computer and use it in GitHub Desktop.

Revisions

  1. @ajb413 ajb413 revised this gist Jul 20, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion comp_earned.md
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@ https://etherscan.io/address/0xd513d22422a3062Bd342Ae374b4b9c20E0a9a074#code

    ## With API

    There is an API endpoint hosted by Compound Labs. This data is slightly behind the blockchain information with respect to time.
    There is an API endpoint hosted by Compound Labs. This data is slightly behind the blockchain information with respect to time. Use URL parameters to provide the `address` that you wish to retrieve the COMP accrued value.

    ```
    HTTP GET https://api.compound.finance/api/v2/governance/comp/account?address=0x123123123123abcabcabcabcabcab
  2. @ajb413 ajb413 revised this gist Jul 20, 2020. 1 changed file with 14 additions and 0 deletions.
    14 changes: 14 additions & 0 deletions comp_earned.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    # 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
    @@ -8,6 +10,18 @@ https://etherscan.io/address/0xd513d22422a3062Bd342Ae374b4b9c20E0a9a074#code
    3. Here is the definition https://github.com/compound-finance/compound-protocol/blob/master/contracts/Lens/CompoundLens.sol#L278
    4. pass: COMP contract address, Comptroller contract address, and the address you want to know the amount of COMP earned

    ## With API

    There is an API endpoint hosted by Compound Labs. This data is slightly behind the blockchain information with respect to time.

    ```
    HTTP GET https://api.compound.finance/api/v2/governance/comp/account?address=0x123123123123abcabcabcabcabcab
    ```

    Use the returned `comp_allocated` value in the JSON object response.

    ## Tools

    Alternatively there is a cool tool from KZen networks that does the same thing.
    https://github.com/KZen-networks/compound-playground#comp

  3. @ajb413 ajb413 revised this gist Jul 20, 2020. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions comp_earned.md
    Original file line number Diff line number Diff line change
    @@ -10,3 +10,5 @@ https://etherscan.io/address/0xd513d22422a3062Bd342Ae374b4b9c20E0a9a074#code

    Alternatively there is a cool tool from KZen networks that does the same thing.
    https://github.com/KZen-networks/compound-playground#comp

    KZen also created the COMP checker page: https://kzen-networks.github.io/comp-checker/
  4. @ajb413 ajb413 revised this gist Jul 13, 2020. No changes.
  5. @ajb413 ajb413 created this gist Jul 13, 2020.
    12 changes: 12 additions & 0 deletions comp_earned.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    # How do I retrieve the "COMP earned" value?

    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/0xd513d22422a3062Bd342Ae374b4b9c20E0a9a074#code
    2. Lens address is posted here https://github.com/compound-finance/compound-protocol/blob/master/networks/mainnet.json#L11
    3. Here is the definition https://github.com/compound-finance/compound-protocol/blob/master/contracts/Lens/CompoundLens.sol#L278
    4. pass: COMP contract address, Comptroller contract address, and the address you want to know the amount of COMP earned

    Alternatively there is a cool tool from KZen networks that does the same thing.
    https://github.com/KZen-networks/compound-playground#comp