Skip to content

Instantly share code, notes, and snippets.

@alexroan
Created December 22, 2020 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexroan/bae179c2d8578129d1eda7e4af699d28 to your computer and use it in GitHub Desktop.
Save alexroan/bae179c2d8578129d1eda7e4af699d28 to your computer and use it in GitHub Desktop.
pragma solidity ^0.5.0;
interface Oracle {
function getUnderlyingPrice(address cToken) external view returns (uint);
}
contract Comptroller {
Oracle public oracle;
}
contract GasMeasure {
address public comp;
address public cToken;
constructor() public{
comp = 0x5eAe89DC1C671724A672ff0630122ee834098657;
cToken = 0x4a77fAeE9650b09849Ff459eA1476eaB01606C7a;
}
function measureGasCost() public view returns (uint, uint) {
Oracle myOracle = Comptroller(comp).oracle();
uint startingGas = gasleft();
uint price = myOracle.getUnderlyingPrice(cToken);
uint finishingGas = gasleft();
return (startingGas - finishingGas, price);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment