Created
December 22, 2020 15:21
-
-
Save alexroan/bae179c2d8578129d1eda7e4af699d28 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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