ERC20
This contract is an ERC20 token.
                Name
                
                        Compound
                
            
            
                Symbol
                COMP
            
            
                Decimals
                18
            
            
                Total Supply
                10,000,000 COMP
            
            
            
        
                About
                    
                        link
                    
                    
            
            
                Compound (COMP) is a cryptocurrency and operates on the Ethereum platform. Compound has a current supply of 10,000,000 with 5,357,510.00906166 in circulation. The last known price of Compound is 386.67880646 USD and is down -5.63 over the last 24 hours. It is currently trading on 210 active market(s) with $194,547,263.72 traded over the last 24 hours. More information can be found at https://compound.finance/governance/comp.
            
        Stats
                Public Functions
                9
            
            
                Event Types
                4
            
            
                Code Size
                12,596 bytes
            
        Events (4) keyboard_arrow_up
Constants (6) keyboard_arrow_up
State Variables (6) keyboard_arrow_up
Functions
allowance keyboard_arrow_up
approve keyboard_arrow_up
Source Code
function approve(address spender, uint256 rawAmount) external returns (bool) {
  uint96 amount;
  if (rawAmount == uint256(-1)) {
    amount = uint96(-1);
  } else {
    amount = safe96(rawAmount, "Comp::approve: amount exceeds 96 bits");
  }
  allowances[msg.sender][spender] = amount;
  emit Approval(msg.sender, spender, amount);
  return true;
}
                balanceOf keyboard_arrow_up
transfer keyboard_arrow_up
Requirements help
Source Code
function transfer(address dst, uint256 rawAmount) external returns (bool) {
  uint96 amount = safe96(rawAmount, "Comp::transfer: amount exceeds 96 bits");
  _transferTokens(msg.sender, dst, amount);
  return true;
}
                transferFrom keyboard_arrow_up
Requirements help
Source Code
function transferFrom(
  address src,
  address dst,
  uint256 rawAmount
) external returns (bool) {
  address spender = msg.sender;
  uint96 spenderAllowance = allowances[src][spender];
  uint96 amount = safe96(rawAmount, "Comp::approve: amount exceeds 96 bits");
  if (spender != src && spenderAllowance != uint96(-1)) {
    uint96 newAllowance = sub96(
      spenderAllowance,
      amount,
      "Comp::transferFrom: transfer amount exceeds spender allowance"
    );
    allowances[src][spender] = newAllowance;
    emit Approval(src, spender, newAllowance);
  }
  _transferTokens(src, dst, amount);
  return true;
}
                delegate keyboard_arrow_up
delegateBySig keyboard_arrow_up
Parameters help
Requirements help
Source Code
function delegateBySig(
  address delegatee,
  uint256 nonce,
  uint256 expiry,
  uint8 v,
  bytes32 r,
  bytes32 s
) public {
  bytes32 domainSeparator = keccak256(
    abi.encode(
      DOMAIN_TYPEHASH,
      keccak256(bytes(name)),
      getChainId(),
      address(this)
    )
  );
  bytes32 structHash = keccak256(
    abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry)
  );
  bytes32 digest = keccak256(
    abi.encodePacked("\x19\x01", domainSeparator, structHash)
  );
  address signatory = ecrecover(digest, v, r, s);
  require(signatory != address(0), "Comp::delegateBySig: invalid signature");
  require(nonce == nonces[signatory]++, "Comp::delegateBySig: invalid nonce");
  require(now <= expiry, "Comp::delegateBySig: signature expired");
  return _delegate(signatory, delegatee);
}
                getCurrentVotes keyboard_arrow_up
Source Code
function getCurrentVotes(address account) external view returns (uint96) {
  uint32 nCheckpoints = numCheckpoints[account];
  return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;
}
                getPriorVotes keyboard_arrow_up
Requirements help
Source Code
function getPriorVotes(address account, uint256 blockNumber)
  public
  view
  returns (uint96)
{
  require(
    blockNumber < block.number,
    "Comp::getPriorVotes: not yet determined"
  );
  uint32 nCheckpoints = numCheckpoints[account];
  if (nCheckpoints == 0) {
    return 0;
  }
  // First check most recent balance
  if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
    return checkpoints[account][nCheckpoints - 1].votes;
  }
  // Next check implicit zero balance
  if (checkpoints[account][0].fromBlock > blockNumber) {
    return 0;
  }
  uint32 lower = 0;
  uint32 upper = nCheckpoints - 1;
  while (upper > lower) {
    uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow
    Checkpoint memory cp = checkpoints[account][center];
    if (cp.fromBlock == blockNumber) {
      return cp.votes;
    } else if (cp.fromBlock < blockNumber) {
      lower = center;
    } else {
      upper = center - 1;
    }
  }
  return checkpoints[account][lower].votes;
}
                Internal Functions
Internal functions are parts of the contract that can't be used directly, but instead are used by the public functions listed above.
internal Comp._delegate keyboard_arrow_up
Source Code
function _delegate(address delegator, address delegatee) internal {
  address currentDelegate = delegates[delegator];
  uint96 delegatorBalance = balances[delegator];
  delegates[delegator] = delegatee;
  emit DelegateChanged(delegator, currentDelegate, delegatee);
  _moveDelegates(currentDelegate, delegatee, delegatorBalance);
}
                internal Comp._transferTokens keyboard_arrow_up
Requirements help
Source Code
function _transferTokens(
  address src,
  address dst,
  uint96 amount
) internal {
  require(
    src != address(0),
    "Comp::_transferTokens: cannot transfer from the zero address"
  );
  require(
    dst != address(0),
    "Comp::_transferTokens: cannot transfer to the zero address"
  );
  balances[src] = sub96(
    balances[src],
    amount,
    "Comp::_transferTokens: transfer amount exceeds balance"
  );
  balances[dst] = add96(
    balances[dst],
    amount,
    "Comp::_transferTokens: transfer amount overflows"
  );
  emit Transfer(src, dst, amount);
  _moveDelegates(delegates[src], delegates[dst], amount);
}
                internal Comp._moveDelegates keyboard_arrow_up
Source Code
function _moveDelegates(
  address srcRep,
  address dstRep,
  uint96 amount
) internal {
  if (srcRep != dstRep && amount > 0) {
    if (srcRep != address(0)) {
      uint32 srcRepNum = numCheckpoints[srcRep];
      uint96 srcRepOld = srcRepNum > 0
        ? checkpoints[srcRep][srcRepNum - 1].votes
        : 0;
      uint96 srcRepNew = sub96(
        srcRepOld,
        amount,
        "Comp::_moveVotes: vote amount underflows"
      );
      _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);
    }
    if (dstRep != address(0)) {
      uint32 dstRepNum = numCheckpoints[dstRep];
      uint96 dstRepOld = dstRepNum > 0
        ? checkpoints[dstRep][dstRepNum - 1].votes
        : 0;
      uint96 dstRepNew = add96(
        dstRepOld,
        amount,
        "Comp::_moveVotes: vote amount overflows"
      );
      _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
    }
  }
}
                internal Comp._writeCheckpoint keyboard_arrow_up
Parameters help
Source Code
function _writeCheckpoint(
  address delegatee,
  uint32 nCheckpoints,
  uint96 oldVotes,
  uint96 newVotes
) internal {
  uint32 blockNumber = safe32(
    block.number,
    "Comp::_writeCheckpoint: block number exceeds 32 bits"
  );
  if (
    nCheckpoints > 0 &&
    checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber
  ) {
    checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;
  } else {
    checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);
    numCheckpoints[delegatee] = nCheckpoints + 1;
  }
  emit DelegateVotesChanged(delegatee, oldVotes, newVotes);
}
                internal Comp.safe32 keyboard_arrow_up
Source Code
function safe32(uint256 n, string memory errorMessage)
  internal
  pure
  returns (uint32)
{
  require(n < 2**32, errorMessage);
  return uint32(n);
}
                internal Comp.safe96 keyboard_arrow_up
Source Code
function safe96(uint256 n, string memory errorMessage)
  internal
  pure
  returns (uint96)
{
  require(n < 2**96, errorMessage);
  return uint96(n);
}
                internal Comp.add96 keyboard_arrow_up
Source Code
function add96(
  uint96 a,
  uint96 b,
  string memory errorMessage
) internal pure returns (uint96) {
  uint96 c = a + b;
  require(c >= a, errorMessage);
  return c;
}
                internal Comp.sub96 keyboard_arrow_up
Source Code
function sub96(
  uint96 a,
  uint96 b,
  string memory errorMessage
) internal pure returns (uint96) {
  require(b <= a, errorMessage);
  return a - b;
}
                
        
    



