Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "comp"

Index

Functions

claimComp

  • claimComp(options?: any): Promise<any>
  • Create a transaction to claim accrued COMP tokens for the user.

    example
    const compound = new Compound(window.ethereum);
    
    (async function() {
    
      console.log('Claiming COMP...');
      const trx = await compound.claimComp();
      console.log('Ethers.js transaction object', trx);
    
    })().catch(console.error);

    Parameters

    • Default value options: any = {}

    Returns Promise<any>

    Returns an Ethers.js transaction object of the vote transaction.

createDelegateSignature

  • createDelegateSignature(delegatee: string, expiry?: number): Promise<any>
  • Create a delegate signature for Compound Governance using EIP-712. The signature can be created without burning gas. Anyone can post it to the blockchain using the delegateBySig method, which does have gas costs.

    example
    const compound = new Compound(window.ethereum);
    
    (async () => {
    
      const delegateSignature = await compound.createDelegateSignature('0xa0df350d2637096571F7A701CBc1C5fdE30dF76A');
      console.log('delegateSignature', delegateSignature);
    
    })().catch(console.error);

    Parameters

    • delegatee: string

      The address to delegate the user's voting rights to.

    • Default value expiry: number = 10000000000

    Returns Promise<any>

    Returns an object that contains the v, r, and s components of an Ethereum signature as hexadecimal strings.

delegate

  • delegate(_address: string, options?: any): Promise<any>
  • Create a transaction to delegate Compound Governance voting rights to an address.

    example
    const compound = new Compound(window.ethereum);
    
    (async function() {
      const delegateTx = await compound.delegate('0xa0df350d2637096571F7A701CBc1C5fdE30dF76A');
      console.log('Ethers.js transaction object', delegateTx);
    })().catch(console.error);

    Parameters

    • _address: string

      The address in which to delegate voting rights to.

    • Default value options: any = {}

    Returns Promise<any>

    Returns an Ethers.js transaction object of the vote transaction.

delegateBySig

  • delegateBySig(_address: string, nonce: number, expiry: number, signature?: any, options?: any): Promise<any>
  • Delegate voting rights in Compound Governance using an EIP-712 signature.

    example
    const compound = new Compound(window.ethereum);
    
    (async function() {
      const delegateTx = await compound.delegateBySig(
        '0xa0df350d2637096571F7A701CBc1C5fdE30dF76A',
        42,
        9999999999,
        {
          v: '0x1b',
          r: '0x130dbca2fafa07424c033b4479687cc1deeb65f08809e3ab397988cc4c6f2e78',
          s: '0x1debeb8250262f23906b1177161f0c7c9aa3641e8bff5b6f5c88a6bb78d5d8cd'
        }
      );
      console.log('Ethers.js transaction object', delegateTx);
    })().catch(console.error);

    Parameters

    • _address: string

      The address to delegate the user's voting rights to.

    • nonce: number

      The contract state required to match the signature. This can be retrieved from the COMP contract's public nonces mapping.

    • expiry: number

      The time at which to expire the signature. A block timestamp as seconds since the unix epoch.

    • Default value signature: any = {}

      An object that contains the v, r, and, s values of an EIP-712 signature.

    • Default value options: any = {}

    Returns Promise<any>

    Returns an Ethers.js transaction object of the vote transaction.

getCompAccrued

  • getCompAccrued(_address: string, _provider?: string): Promise<any>
  • Get the amount of COMP tokens accrued but not yet claimed by an address.

    example
    (async function () {
      const acc = await Compound.comp.getCompAccrued('0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5');
      console.log('Accrued', acc);
    })().catch(console.error);

    Parameters

    • _address: string

      The address in which to find the COMP accrued.

    • Default value _provider: string = "mainnet"

    Returns Promise<any>

    Returns a string of the numeric accruement of COMP. The value is scaled up by 18 decimal places.

getCompBalance

  • getCompBalance(_address: string, _provider?: string): Promise<any>
  • Get the balance of COMP tokens held by an address.

    example
    (async function () {
      const bal = await Compound.comp.getCompBalance('0x2775b1c75658Be0F640272CCb8c72ac986009e38');
      console.log('Balance', bal);
    })().catch(console.error);

    Parameters

    • _address: string

      The address in which to find the COMP balance.

    • Default value _provider: string = "mainnet"

    Returns Promise<any>

    Returns a string of the numeric balance of COMP. The value is scaled up by 18 decimal places.

toChecksumAddress

  • toChecksumAddress(_address: any): string
  • Applies the EIP-55 checksum to an Ethereum address.

    Parameters

    • _address: any

      The Ethereum address to apply the checksum.

    Returns string

    Returns a string of the Ethereum address.