├── .gitignore ├── LICENSE ├── README.md ├── build └── contracts │ ├── APROracle.json │ ├── APRWithPoolOracle.json │ ├── Address.json │ ├── Compound.json │ ├── Context.json │ ├── Decimal.json │ ├── DyDx.json │ ├── Fulcrum.json │ ├── IAPROracle.json │ ├── IDDEX.json │ ├── IDDEXModel.json │ ├── IERC20.json │ ├── ILendF.json │ ├── ILendFModel.json │ ├── IReserveInterestRateStrategy.json │ ├── InterestRateModel.json │ ├── LendingPoolAddressesProvider.json │ ├── LendingPoolCore.json │ ├── Migrations.json │ ├── Ownable.json │ ├── SafeMath.json │ └── Structs.json ├── contracts ├── APROracle.sol ├── APRWithPoolOracle.sol ├── IAPROracle.sol ├── IAPRWithPoolOracle.sol └── Migrations.sol ├── migrations └── 1_initial_migration.js ├── package.json └── truffle-config.js /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | #IDEs 4 | /.idea 5 | # dependencies 6 | /node_modules 7 | 8 | # testing 9 | /coverage 10 | 11 | # misc 12 | .DS_Store 13 | .env.local 14 | .env.development.local 15 | .env.test.local 16 | .env.production.local 17 | 18 | npm-debug.log* 19 | yarn-debug.log* 20 | yarn-error.log* 21 | node_modules 22 | 23 | deploy.js 24 | oracle.js 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 iearn 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Documentation 2 | 3 | [iearn.finance](https://docs.iearn.finance) 4 | 5 | # Smart Contract Interface 6 | 7 | | Contract | ABI | Address | 8 | | -- | -- | -- | 9 | | APROracle | [JSON](https://github.com/iearn-finance/apr-oracle/blob/master/build/contracts/APROracle.json) | [apr.iearn.eth](https://etherscan.io/address/0x97ff4a1b787ade6b94cca95b61f79417c673331d#code) | 10 | 11 | ## APR Interface 12 | 13 | {% tabs %} 14 | {% tab title="IAPROracle.sol" %} 15 | ```javascript 16 | // Solidity Interface 17 | 18 | interface IAPROracle { 19 | function recommendDAI() external view returns (string memory); 20 | function recommendETH() external view returns (string memory); 21 | function recommendUSDC() external view returns (string memory); 22 | function getAllCompoundAPR() 23 | external 24 | view 25 | returns ( 26 | uint256 cDAI, 27 | uint256 cBAT, 28 | uint256 cETH, 29 | uint256 cREP, 30 | uint256 cSAI, 31 | uint256 cUSDC, 32 | uint256 cWBTC, 33 | uint256 cZRC 34 | ); 35 | 36 | // Compound 37 | function getCDAIAPR() external view returns (uint256); 38 | function getCBATAPR() external view returns (uint256); 39 | function getCETHAPR() external view returns (uint256); 40 | function getCREPAPR() external view returns (uint256); 41 | function getCSAIAPR() external view returns (uint256); 42 | function getCUSDCAPR() external view returns (uint256); 43 | function getCWBTCAPR() external view returns (uint256); 44 | function getCZRCAPR() public view returns (uint256); 45 | function getCompoundAPR(address token) public view returns (uint256); 46 | 47 | function getAllDyDxAPR() 48 | external 49 | view 50 | returns ( 51 | uint256 dSAI, 52 | uint256 dETH, 53 | uint256 dUSDC, 54 | uint256 dDAI 55 | ); 56 | 57 | // dYdX 58 | function getDyDxSAIAPR() public view returns(uint256); 59 | function getDyDxETHAPR() public view returns(uint256); 60 | function getDyDxUSDCAPR() public view returns(uint256); 61 | function getDyDxDAIAPR() public view returns(uint256); 62 | 63 | function getAllFulcrumAPR() 64 | external 65 | view 66 | returns ( 67 | uint256 iZRX, 68 | uint256 iREP, 69 | uint256 iKNC, 70 | uint256 iWBTC, 71 | uint256 iUSDC, 72 | uint256 iETH, 73 | uint256 iSAI, 74 | uint256 iDAI, 75 | uint256 iLINK, 76 | uint256 iSUSD 77 | ); 78 | 79 | // Fulcrum 80 | function getIZRXAPR() public view returns (uint256); 81 | function getIREPAPR() public view returns (uint256); 82 | function getIKNCAPR() public view returns (uint256); 83 | function getIWBTCAPR() public view returns (uint256); 84 | function getIUSDCAPR() public view returns (uint256); 85 | function getIETHAPR() public view returns (uint256); 86 | function getISAIAPR() public view returns (uint256); 87 | function getIDAIAPR() public view returns (uint256); 88 | function getILINKAPR() public view returns (uint256); 89 | function getISUSDAPR() public view returns (uint256); 90 | 91 | function getFulcrumAPR(address token) public view returns(uint256); 92 | 93 | function getDyDxAPR(uint256 marketId) public view returns(uint256); 94 | 95 | function getAllAaveAPR() 96 | external 97 | view 98 | returns ( 99 | uint256 aDAI, 100 | uint256 aTUSD, 101 | uint256 aUSDC, 102 | uint256 aUSDT, 103 | uint256 aSUSD, 104 | uint256 aBAT, 105 | uint256 aETH, 106 | uint256 aLINK, 107 | uint256 aKNC, 108 | uint256 aREP, 109 | uint256 aZRX, 110 | uint256 aSNX 111 | ); 112 | 113 | function getADAIAPR() public view returns (uint256); 114 | function getATUSDAPR() public view returns (uint256); 115 | function getAUSDCAPR() public view returns (uint256); 116 | function getAUSDTAPR() public view returns (uint256); 117 | function getASUSDAPR() public view returns (uint256); 118 | function getALENDAPR() public view returns (uint256); 119 | function getABATAPR() public view returns (uint256); 120 | function getAETHAPR() public view returns (uint256); 121 | function getALINKAPR() public view returns (uint256); 122 | function getAKNCAPR() public view returns (uint256); 123 | function getAREPAPR() public view returns (uint256); 124 | function getAMKRAPR() public view returns (uint256); 125 | function getAMANAAPR() public view returns (uint256); 126 | function getAZRXAPR() public view returns (uint256); 127 | function getASNXAPR() public view returns (uint256); 128 | function getAWBTCAPR() public view returns (uint256); 129 | 130 | function getAaveAPR(address token) public view returns (uint256); 131 | } 132 | ``` 133 | {% endtab %} 134 | {% endtabs %} 135 | -------------------------------------------------------------------------------- /build/contracts/Migrations.json: -------------------------------------------------------------------------------- 1 | { 2 | "contractName": "Migrations", 3 | "abi": [ 4 | { 5 | "inputs": [], 6 | "payable": false, 7 | "stateMutability": "nonpayable", 8 | "type": "constructor" 9 | }, 10 | { 11 | "constant": true, 12 | "inputs": [], 13 | "name": "last_completed_migration", 14 | "outputs": [ 15 | { 16 | "internalType": "uint256", 17 | "name": "", 18 | "type": "uint256" 19 | } 20 | ], 21 | "payable": false, 22 | "stateMutability": "view", 23 | "type": "function" 24 | }, 25 | { 26 | "constant": true, 27 | "inputs": [], 28 | "name": "owner", 29 | "outputs": [ 30 | { 31 | "internalType": "address", 32 | "name": "", 33 | "type": "address" 34 | } 35 | ], 36 | "payable": false, 37 | "stateMutability": "view", 38 | "type": "function" 39 | }, 40 | { 41 | "constant": false, 42 | "inputs": [ 43 | { 44 | "internalType": "uint256", 45 | "name": "completed", 46 | "type": "uint256" 47 | } 48 | ], 49 | "name": "setCompleted", 50 | "outputs": [], 51 | "payable": false, 52 | "stateMutability": "nonpayable", 53 | "type": "function" 54 | }, 55 | { 56 | "constant": false, 57 | "inputs": [ 58 | { 59 | "internalType": "address", 60 | "name": "new_address", 61 | "type": "address" 62 | } 63 | ], 64 | "name": "upgrade", 65 | "outputs": [], 66 | "payable": false, 67 | "stateMutability": "nonpayable", 68 | "type": "function" 69 | } 70 | ], 71 | "metadata": "{\"compiler\":{\"version\":\"0.5.12+commit.7709ece9\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"constant\":true,\"inputs\":[],\"name\":\"last_completed_migration\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"completed\",\"type\":\"uint256\"}],\"name\":\"setCompleted\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"new_address\",\"type\":\"address\"}],\"name\":\"upgrade\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/D/ftm/apr-oracle/contracts/Migrations.sol\":\"Migrations\"},\"evmVersion\":\"petersburg\",\"libraries\":{},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"/D/ftm/apr-oracle/contracts/Migrations.sol\":{\"keccak256\":\"0x919f575f0939571a03f4870c607e9ac4f8893eb1e8ffed3ae2e1993633d9358d\",\"urls\":[\"bzz-raw://fcaff076ff00297a792470a886fe81f0bcd08b9d5849a96f1c448f4f3beae491\",\"dweb:/ipfs/QmUUnW8xpGC2QBaimEvdNU6zjrtPKuTyaConNPSfT2Dmr4\"]}},\"version\":1}", 72 | "bytecode": "0x608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506102b7806100606000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c80630900f01014610051578063445df0ac146100955780638da5cb5b146100b3578063fdacd576146100fd575b600080fd5b6100936004803603602081101561006757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061012b565b005b61009d6101f7565b6040518082815260200191505060405180910390f35b6100bb6101fd565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6101296004803603602081101561011357600080fd5b8101908080359060200190929190505050610222565b005b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156101f45760008190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156101da57600080fd5b505af11580156101ee573d6000803e3d6000fd5b50505050505b50565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561027f57806001819055505b5056fea265627a7a72315820f29a9afc92ea6a678056075f8b6a44c751604522975191034a63059ef93c331464736f6c634300050c0032", 73 | "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c80630900f01014610051578063445df0ac146100955780638da5cb5b146100b3578063fdacd576146100fd575b600080fd5b6100936004803603602081101561006757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061012b565b005b61009d6101f7565b6040518082815260200191505060405180910390f35b6100bb6101fd565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6101296004803603602081101561011357600080fd5b8101908080359060200190929190505050610222565b005b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156101f45760008190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156101da57600080fd5b505af11580156101ee573d6000803e3d6000fd5b50505050505b50565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561027f57806001819055505b5056fea265627a7a72315820f29a9afc92ea6a678056075f8b6a44c751604522975191034a63059ef93c331464736f6c634300050c0032", 74 | "sourceMap": "34:480:4:-;;;123:50;8:9:-1;5:2;;;30:1;27;20:12;5:2;123:50:4;158:10;150:5;;:18;;;;;;;;;;;;;;;;;;34:480;;;;;;", 75 | "deployedSourceMap": "34:480:4:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;34:480:4;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;347:165;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;347:165:4;;;;;;;;;;;;;;;;;;;:::i;:::-;;82:36;;;:::i;:::-;;;;;;;;;;;;;;;;;;;58:20;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;240:103;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;240:103:4;;;;;;;;;;;;;;;;;:::i;:::-;;347:165;223:5;;;;;;;;;;;209:19;;:10;:19;;;205:26;;;409:19;442:11;409:45;;460:8;:21;;;482:24;;460:47;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;460:47:4;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;460:47:4;;;;230:1;205:26;347:165;:::o;82:36::-;;;;:::o;58:20::-;;;;;;;;;;;;;:::o;240:103::-;223:5;;;;;;;;;;;209:19;;:10;:19;;;205:26;;;329:9;302:24;:36;;;;205:26;240:103;:::o", 76 | "source": "pragma solidity >=0.4.21 <0.7.0;\n\ncontract Migrations {\n address public owner;\n uint public last_completed_migration;\n\n constructor() public {\n owner = msg.sender;\n }\n\n modifier restricted() {\n if (msg.sender == owner) _;\n }\n\n function setCompleted(uint completed) public restricted {\n last_completed_migration = completed;\n }\n\n function upgrade(address new_address) public restricted {\n Migrations upgraded = Migrations(new_address);\n upgraded.setCompleted(last_completed_migration);\n }\n}\n", 77 | "sourcePath": "D:/ftm/apr-oracle/contracts/Migrations.sol", 78 | "ast": { 79 | "absolutePath": "/D/ftm/apr-oracle/contracts/Migrations.sol", 80 | "exportedSymbols": { 81 | "Migrations": [ 82 | 4644 83 | ] 84 | }, 85 | "id": 4645, 86 | "nodeType": "SourceUnit", 87 | "nodes": [ 88 | { 89 | "id": 4589, 90 | "literals": [ 91 | "solidity", 92 | ">=", 93 | "0.4", 94 | ".21", 95 | "<", 96 | "0.7", 97 | ".0" 98 | ], 99 | "nodeType": "PragmaDirective", 100 | "src": "0:32:4" 101 | }, 102 | { 103 | "baseContracts": [], 104 | "contractDependencies": [], 105 | "contractKind": "contract", 106 | "documentation": null, 107 | "fullyImplemented": true, 108 | "id": 4644, 109 | "linearizedBaseContracts": [ 110 | 4644 111 | ], 112 | "name": "Migrations", 113 | "nodeType": "ContractDefinition", 114 | "nodes": [ 115 | { 116 | "constant": false, 117 | "id": 4591, 118 | "name": "owner", 119 | "nodeType": "VariableDeclaration", 120 | "scope": 4644, 121 | "src": "58:20:4", 122 | "stateVariable": true, 123 | "storageLocation": "default", 124 | "typeDescriptions": { 125 | "typeIdentifier": "t_address", 126 | "typeString": "address" 127 | }, 128 | "typeName": { 129 | "id": 4590, 130 | "name": "address", 131 | "nodeType": "ElementaryTypeName", 132 | "src": "58:7:4", 133 | "stateMutability": "nonpayable", 134 | "typeDescriptions": { 135 | "typeIdentifier": "t_address", 136 | "typeString": "address" 137 | } 138 | }, 139 | "value": null, 140 | "visibility": "public" 141 | }, 142 | { 143 | "constant": false, 144 | "id": 4593, 145 | "name": "last_completed_migration", 146 | "nodeType": "VariableDeclaration", 147 | "scope": 4644, 148 | "src": "82:36:4", 149 | "stateVariable": true, 150 | "storageLocation": "default", 151 | "typeDescriptions": { 152 | "typeIdentifier": "t_uint256", 153 | "typeString": "uint256" 154 | }, 155 | "typeName": { 156 | "id": 4592, 157 | "name": "uint", 158 | "nodeType": "ElementaryTypeName", 159 | "src": "82:4:4", 160 | "typeDescriptions": { 161 | "typeIdentifier": "t_uint256", 162 | "typeString": "uint256" 163 | } 164 | }, 165 | "value": null, 166 | "visibility": "public" 167 | }, 168 | { 169 | "body": { 170 | "id": 4601, 171 | "nodeType": "Block", 172 | "src": "144:29:4", 173 | "statements": [ 174 | { 175 | "expression": { 176 | "argumentTypes": null, 177 | "id": 4599, 178 | "isConstant": false, 179 | "isLValue": false, 180 | "isPure": false, 181 | "lValueRequested": false, 182 | "leftHandSide": { 183 | "argumentTypes": null, 184 | "id": 4596, 185 | "name": "owner", 186 | "nodeType": "Identifier", 187 | "overloadedDeclarations": [], 188 | "referencedDeclaration": 4591, 189 | "src": "150:5:4", 190 | "typeDescriptions": { 191 | "typeIdentifier": "t_address", 192 | "typeString": "address" 193 | } 194 | }, 195 | "nodeType": "Assignment", 196 | "operator": "=", 197 | "rightHandSide": { 198 | "argumentTypes": null, 199 | "expression": { 200 | "argumentTypes": null, 201 | "id": 4597, 202 | "name": "msg", 203 | "nodeType": "Identifier", 204 | "overloadedDeclarations": [], 205 | "referencedDeclaration": 4659, 206 | "src": "158:3:4", 207 | "typeDescriptions": { 208 | "typeIdentifier": "t_magic_message", 209 | "typeString": "msg" 210 | } 211 | }, 212 | "id": 4598, 213 | "isConstant": false, 214 | "isLValue": false, 215 | "isPure": false, 216 | "lValueRequested": false, 217 | "memberName": "sender", 218 | "nodeType": "MemberAccess", 219 | "referencedDeclaration": null, 220 | "src": "158:10:4", 221 | "typeDescriptions": { 222 | "typeIdentifier": "t_address_payable", 223 | "typeString": "address payable" 224 | } 225 | }, 226 | "src": "150:18:4", 227 | "typeDescriptions": { 228 | "typeIdentifier": "t_address", 229 | "typeString": "address" 230 | } 231 | }, 232 | "id": 4600, 233 | "nodeType": "ExpressionStatement", 234 | "src": "150:18:4" 235 | } 236 | ] 237 | }, 238 | "documentation": null, 239 | "id": 4602, 240 | "implemented": true, 241 | "kind": "constructor", 242 | "modifiers": [], 243 | "name": "", 244 | "nodeType": "FunctionDefinition", 245 | "parameters": { 246 | "id": 4594, 247 | "nodeType": "ParameterList", 248 | "parameters": [], 249 | "src": "134:2:4" 250 | }, 251 | "returnParameters": { 252 | "id": 4595, 253 | "nodeType": "ParameterList", 254 | "parameters": [], 255 | "src": "144:0:4" 256 | }, 257 | "scope": 4644, 258 | "src": "123:50:4", 259 | "stateMutability": "nonpayable", 260 | "superFunction": null, 261 | "visibility": "public" 262 | }, 263 | { 264 | "body": { 265 | "id": 4610, 266 | "nodeType": "Block", 267 | "src": "199:37:4", 268 | "statements": [ 269 | { 270 | "condition": { 271 | "argumentTypes": null, 272 | "commonType": { 273 | "typeIdentifier": "t_address", 274 | "typeString": "address" 275 | }, 276 | "id": 4607, 277 | "isConstant": false, 278 | "isLValue": false, 279 | "isPure": false, 280 | "lValueRequested": false, 281 | "leftExpression": { 282 | "argumentTypes": null, 283 | "expression": { 284 | "argumentTypes": null, 285 | "id": 4604, 286 | "name": "msg", 287 | "nodeType": "Identifier", 288 | "overloadedDeclarations": [], 289 | "referencedDeclaration": 4659, 290 | "src": "209:3:4", 291 | "typeDescriptions": { 292 | "typeIdentifier": "t_magic_message", 293 | "typeString": "msg" 294 | } 295 | }, 296 | "id": 4605, 297 | "isConstant": false, 298 | "isLValue": false, 299 | "isPure": false, 300 | "lValueRequested": false, 301 | "memberName": "sender", 302 | "nodeType": "MemberAccess", 303 | "referencedDeclaration": null, 304 | "src": "209:10:4", 305 | "typeDescriptions": { 306 | "typeIdentifier": "t_address_payable", 307 | "typeString": "address payable" 308 | } 309 | }, 310 | "nodeType": "BinaryOperation", 311 | "operator": "==", 312 | "rightExpression": { 313 | "argumentTypes": null, 314 | "id": 4606, 315 | "name": "owner", 316 | "nodeType": "Identifier", 317 | "overloadedDeclarations": [], 318 | "referencedDeclaration": 4591, 319 | "src": "223:5:4", 320 | "typeDescriptions": { 321 | "typeIdentifier": "t_address", 322 | "typeString": "address" 323 | } 324 | }, 325 | "src": "209:19:4", 326 | "typeDescriptions": { 327 | "typeIdentifier": "t_bool", 328 | "typeString": "bool" 329 | } 330 | }, 331 | "falseBody": null, 332 | "id": 4609, 333 | "nodeType": "IfStatement", 334 | "src": "205:26:4", 335 | "trueBody": { 336 | "id": 4608, 337 | "nodeType": "PlaceholderStatement", 338 | "src": "230:1:4" 339 | } 340 | } 341 | ] 342 | }, 343 | "documentation": null, 344 | "id": 4611, 345 | "name": "restricted", 346 | "nodeType": "ModifierDefinition", 347 | "parameters": { 348 | "id": 4603, 349 | "nodeType": "ParameterList", 350 | "parameters": [], 351 | "src": "196:2:4" 352 | }, 353 | "src": "177:59:4", 354 | "visibility": "internal" 355 | }, 356 | { 357 | "body": { 358 | "id": 4622, 359 | "nodeType": "Block", 360 | "src": "296:47:4", 361 | "statements": [ 362 | { 363 | "expression": { 364 | "argumentTypes": null, 365 | "id": 4620, 366 | "isConstant": false, 367 | "isLValue": false, 368 | "isPure": false, 369 | "lValueRequested": false, 370 | "leftHandSide": { 371 | "argumentTypes": null, 372 | "id": 4618, 373 | "name": "last_completed_migration", 374 | "nodeType": "Identifier", 375 | "overloadedDeclarations": [], 376 | "referencedDeclaration": 4593, 377 | "src": "302:24:4", 378 | "typeDescriptions": { 379 | "typeIdentifier": "t_uint256", 380 | "typeString": "uint256" 381 | } 382 | }, 383 | "nodeType": "Assignment", 384 | "operator": "=", 385 | "rightHandSide": { 386 | "argumentTypes": null, 387 | "id": 4619, 388 | "name": "completed", 389 | "nodeType": "Identifier", 390 | "overloadedDeclarations": [], 391 | "referencedDeclaration": 4613, 392 | "src": "329:9:4", 393 | "typeDescriptions": { 394 | "typeIdentifier": "t_uint256", 395 | "typeString": "uint256" 396 | } 397 | }, 398 | "src": "302:36:4", 399 | "typeDescriptions": { 400 | "typeIdentifier": "t_uint256", 401 | "typeString": "uint256" 402 | } 403 | }, 404 | "id": 4621, 405 | "nodeType": "ExpressionStatement", 406 | "src": "302:36:4" 407 | } 408 | ] 409 | }, 410 | "documentation": null, 411 | "id": 4623, 412 | "implemented": true, 413 | "kind": "function", 414 | "modifiers": [ 415 | { 416 | "arguments": null, 417 | "id": 4616, 418 | "modifierName": { 419 | "argumentTypes": null, 420 | "id": 4615, 421 | "name": "restricted", 422 | "nodeType": "Identifier", 423 | "overloadedDeclarations": [], 424 | "referencedDeclaration": 4611, 425 | "src": "285:10:4", 426 | "typeDescriptions": { 427 | "typeIdentifier": "t_modifier$__$", 428 | "typeString": "modifier ()" 429 | } 430 | }, 431 | "nodeType": "ModifierInvocation", 432 | "src": "285:10:4" 433 | } 434 | ], 435 | "name": "setCompleted", 436 | "nodeType": "FunctionDefinition", 437 | "parameters": { 438 | "id": 4614, 439 | "nodeType": "ParameterList", 440 | "parameters": [ 441 | { 442 | "constant": false, 443 | "id": 4613, 444 | "name": "completed", 445 | "nodeType": "VariableDeclaration", 446 | "scope": 4623, 447 | "src": "262:14:4", 448 | "stateVariable": false, 449 | "storageLocation": "default", 450 | "typeDescriptions": { 451 | "typeIdentifier": "t_uint256", 452 | "typeString": "uint256" 453 | }, 454 | "typeName": { 455 | "id": 4612, 456 | "name": "uint", 457 | "nodeType": "ElementaryTypeName", 458 | "src": "262:4:4", 459 | "typeDescriptions": { 460 | "typeIdentifier": "t_uint256", 461 | "typeString": "uint256" 462 | } 463 | }, 464 | "value": null, 465 | "visibility": "internal" 466 | } 467 | ], 468 | "src": "261:16:4" 469 | }, 470 | "returnParameters": { 471 | "id": 4617, 472 | "nodeType": "ParameterList", 473 | "parameters": [], 474 | "src": "296:0:4" 475 | }, 476 | "scope": 4644, 477 | "src": "240:103:4", 478 | "stateMutability": "nonpayable", 479 | "superFunction": null, 480 | "visibility": "public" 481 | }, 482 | { 483 | "body": { 484 | "id": 4642, 485 | "nodeType": "Block", 486 | "src": "403:109:4", 487 | "statements": [ 488 | { 489 | "assignments": [ 490 | 4631 491 | ], 492 | "declarations": [ 493 | { 494 | "constant": false, 495 | "id": 4631, 496 | "name": "upgraded", 497 | "nodeType": "VariableDeclaration", 498 | "scope": 4642, 499 | "src": "409:19:4", 500 | "stateVariable": false, 501 | "storageLocation": "default", 502 | "typeDescriptions": { 503 | "typeIdentifier": "t_contract$_Migrations_$4644", 504 | "typeString": "contract Migrations" 505 | }, 506 | "typeName": { 507 | "contractScope": null, 508 | "id": 4630, 509 | "name": "Migrations", 510 | "nodeType": "UserDefinedTypeName", 511 | "referencedDeclaration": 4644, 512 | "src": "409:10:4", 513 | "typeDescriptions": { 514 | "typeIdentifier": "t_contract$_Migrations_$4644", 515 | "typeString": "contract Migrations" 516 | } 517 | }, 518 | "value": null, 519 | "visibility": "internal" 520 | } 521 | ], 522 | "id": 4635, 523 | "initialValue": { 524 | "argumentTypes": null, 525 | "arguments": [ 526 | { 527 | "argumentTypes": null, 528 | "id": 4633, 529 | "name": "new_address", 530 | "nodeType": "Identifier", 531 | "overloadedDeclarations": [], 532 | "referencedDeclaration": 4625, 533 | "src": "442:11:4", 534 | "typeDescriptions": { 535 | "typeIdentifier": "t_address", 536 | "typeString": "address" 537 | } 538 | } 539 | ], 540 | "expression": { 541 | "argumentTypes": [ 542 | { 543 | "typeIdentifier": "t_address", 544 | "typeString": "address" 545 | } 546 | ], 547 | "id": 4632, 548 | "name": "Migrations", 549 | "nodeType": "Identifier", 550 | "overloadedDeclarations": [], 551 | "referencedDeclaration": 4644, 552 | "src": "431:10:4", 553 | "typeDescriptions": { 554 | "typeIdentifier": "t_type$_t_contract$_Migrations_$4644_$", 555 | "typeString": "type(contract Migrations)" 556 | } 557 | }, 558 | "id": 4634, 559 | "isConstant": false, 560 | "isLValue": false, 561 | "isPure": false, 562 | "kind": "typeConversion", 563 | "lValueRequested": false, 564 | "names": [], 565 | "nodeType": "FunctionCall", 566 | "src": "431:23:4", 567 | "typeDescriptions": { 568 | "typeIdentifier": "t_contract$_Migrations_$4644", 569 | "typeString": "contract Migrations" 570 | } 571 | }, 572 | "nodeType": "VariableDeclarationStatement", 573 | "src": "409:45:4" 574 | }, 575 | { 576 | "expression": { 577 | "argumentTypes": null, 578 | "arguments": [ 579 | { 580 | "argumentTypes": null, 581 | "id": 4639, 582 | "name": "last_completed_migration", 583 | "nodeType": "Identifier", 584 | "overloadedDeclarations": [], 585 | "referencedDeclaration": 4593, 586 | "src": "482:24:4", 587 | "typeDescriptions": { 588 | "typeIdentifier": "t_uint256", 589 | "typeString": "uint256" 590 | } 591 | } 592 | ], 593 | "expression": { 594 | "argumentTypes": [ 595 | { 596 | "typeIdentifier": "t_uint256", 597 | "typeString": "uint256" 598 | } 599 | ], 600 | "expression": { 601 | "argumentTypes": null, 602 | "id": 4636, 603 | "name": "upgraded", 604 | "nodeType": "Identifier", 605 | "overloadedDeclarations": [], 606 | "referencedDeclaration": 4631, 607 | "src": "460:8:4", 608 | "typeDescriptions": { 609 | "typeIdentifier": "t_contract$_Migrations_$4644", 610 | "typeString": "contract Migrations" 611 | } 612 | }, 613 | "id": 4638, 614 | "isConstant": false, 615 | "isLValue": false, 616 | "isPure": false, 617 | "lValueRequested": false, 618 | "memberName": "setCompleted", 619 | "nodeType": "MemberAccess", 620 | "referencedDeclaration": 4623, 621 | "src": "460:21:4", 622 | "typeDescriptions": { 623 | "typeIdentifier": "t_function_external_nonpayable$_t_uint256_$returns$__$", 624 | "typeString": "function (uint256) external" 625 | } 626 | }, 627 | "id": 4640, 628 | "isConstant": false, 629 | "isLValue": false, 630 | "isPure": false, 631 | "kind": "functionCall", 632 | "lValueRequested": false, 633 | "names": [], 634 | "nodeType": "FunctionCall", 635 | "src": "460:47:4", 636 | "typeDescriptions": { 637 | "typeIdentifier": "t_tuple$__$", 638 | "typeString": "tuple()" 639 | } 640 | }, 641 | "id": 4641, 642 | "nodeType": "ExpressionStatement", 643 | "src": "460:47:4" 644 | } 645 | ] 646 | }, 647 | "documentation": null, 648 | "id": 4643, 649 | "implemented": true, 650 | "kind": "function", 651 | "modifiers": [ 652 | { 653 | "arguments": null, 654 | "id": 4628, 655 | "modifierName": { 656 | "argumentTypes": null, 657 | "id": 4627, 658 | "name": "restricted", 659 | "nodeType": "Identifier", 660 | "overloadedDeclarations": [], 661 | "referencedDeclaration": 4611, 662 | "src": "392:10:4", 663 | "typeDescriptions": { 664 | "typeIdentifier": "t_modifier$__$", 665 | "typeString": "modifier ()" 666 | } 667 | }, 668 | "nodeType": "ModifierInvocation", 669 | "src": "392:10:4" 670 | } 671 | ], 672 | "name": "upgrade", 673 | "nodeType": "FunctionDefinition", 674 | "parameters": { 675 | "id": 4626, 676 | "nodeType": "ParameterList", 677 | "parameters": [ 678 | { 679 | "constant": false, 680 | "id": 4625, 681 | "name": "new_address", 682 | "nodeType": "VariableDeclaration", 683 | "scope": 4643, 684 | "src": "364:19:4", 685 | "stateVariable": false, 686 | "storageLocation": "default", 687 | "typeDescriptions": { 688 | "typeIdentifier": "t_address", 689 | "typeString": "address" 690 | }, 691 | "typeName": { 692 | "id": 4624, 693 | "name": "address", 694 | "nodeType": "ElementaryTypeName", 695 | "src": "364:7:4", 696 | "stateMutability": "nonpayable", 697 | "typeDescriptions": { 698 | "typeIdentifier": "t_address", 699 | "typeString": "address" 700 | } 701 | }, 702 | "value": null, 703 | "visibility": "internal" 704 | } 705 | ], 706 | "src": "363:21:4" 707 | }, 708 | "returnParameters": { 709 | "id": 4629, 710 | "nodeType": "ParameterList", 711 | "parameters": [], 712 | "src": "403:0:4" 713 | }, 714 | "scope": 4644, 715 | "src": "347:165:4", 716 | "stateMutability": "nonpayable", 717 | "superFunction": null, 718 | "visibility": "public" 719 | } 720 | ], 721 | "scope": 4645, 722 | "src": "34:480:4" 723 | } 724 | ], 725 | "src": "0:515:4" 726 | }, 727 | "legacyAST": { 728 | "absolutePath": "/D/ftm/apr-oracle/contracts/Migrations.sol", 729 | "exportedSymbols": { 730 | "Migrations": [ 731 | 4644 732 | ] 733 | }, 734 | "id": 4645, 735 | "nodeType": "SourceUnit", 736 | "nodes": [ 737 | { 738 | "id": 4589, 739 | "literals": [ 740 | "solidity", 741 | ">=", 742 | "0.4", 743 | ".21", 744 | "<", 745 | "0.7", 746 | ".0" 747 | ], 748 | "nodeType": "PragmaDirective", 749 | "src": "0:32:4" 750 | }, 751 | { 752 | "baseContracts": [], 753 | "contractDependencies": [], 754 | "contractKind": "contract", 755 | "documentation": null, 756 | "fullyImplemented": true, 757 | "id": 4644, 758 | "linearizedBaseContracts": [ 759 | 4644 760 | ], 761 | "name": "Migrations", 762 | "nodeType": "ContractDefinition", 763 | "nodes": [ 764 | { 765 | "constant": false, 766 | "id": 4591, 767 | "name": "owner", 768 | "nodeType": "VariableDeclaration", 769 | "scope": 4644, 770 | "src": "58:20:4", 771 | "stateVariable": true, 772 | "storageLocation": "default", 773 | "typeDescriptions": { 774 | "typeIdentifier": "t_address", 775 | "typeString": "address" 776 | }, 777 | "typeName": { 778 | "id": 4590, 779 | "name": "address", 780 | "nodeType": "ElementaryTypeName", 781 | "src": "58:7:4", 782 | "stateMutability": "nonpayable", 783 | "typeDescriptions": { 784 | "typeIdentifier": "t_address", 785 | "typeString": "address" 786 | } 787 | }, 788 | "value": null, 789 | "visibility": "public" 790 | }, 791 | { 792 | "constant": false, 793 | "id": 4593, 794 | "name": "last_completed_migration", 795 | "nodeType": "VariableDeclaration", 796 | "scope": 4644, 797 | "src": "82:36:4", 798 | "stateVariable": true, 799 | "storageLocation": "default", 800 | "typeDescriptions": { 801 | "typeIdentifier": "t_uint256", 802 | "typeString": "uint256" 803 | }, 804 | "typeName": { 805 | "id": 4592, 806 | "name": "uint", 807 | "nodeType": "ElementaryTypeName", 808 | "src": "82:4:4", 809 | "typeDescriptions": { 810 | "typeIdentifier": "t_uint256", 811 | "typeString": "uint256" 812 | } 813 | }, 814 | "value": null, 815 | "visibility": "public" 816 | }, 817 | { 818 | "body": { 819 | "id": 4601, 820 | "nodeType": "Block", 821 | "src": "144:29:4", 822 | "statements": [ 823 | { 824 | "expression": { 825 | "argumentTypes": null, 826 | "id": 4599, 827 | "isConstant": false, 828 | "isLValue": false, 829 | "isPure": false, 830 | "lValueRequested": false, 831 | "leftHandSide": { 832 | "argumentTypes": null, 833 | "id": 4596, 834 | "name": "owner", 835 | "nodeType": "Identifier", 836 | "overloadedDeclarations": [], 837 | "referencedDeclaration": 4591, 838 | "src": "150:5:4", 839 | "typeDescriptions": { 840 | "typeIdentifier": "t_address", 841 | "typeString": "address" 842 | } 843 | }, 844 | "nodeType": "Assignment", 845 | "operator": "=", 846 | "rightHandSide": { 847 | "argumentTypes": null, 848 | "expression": { 849 | "argumentTypes": null, 850 | "id": 4597, 851 | "name": "msg", 852 | "nodeType": "Identifier", 853 | "overloadedDeclarations": [], 854 | "referencedDeclaration": 4659, 855 | "src": "158:3:4", 856 | "typeDescriptions": { 857 | "typeIdentifier": "t_magic_message", 858 | "typeString": "msg" 859 | } 860 | }, 861 | "id": 4598, 862 | "isConstant": false, 863 | "isLValue": false, 864 | "isPure": false, 865 | "lValueRequested": false, 866 | "memberName": "sender", 867 | "nodeType": "MemberAccess", 868 | "referencedDeclaration": null, 869 | "src": "158:10:4", 870 | "typeDescriptions": { 871 | "typeIdentifier": "t_address_payable", 872 | "typeString": "address payable" 873 | } 874 | }, 875 | "src": "150:18:4", 876 | "typeDescriptions": { 877 | "typeIdentifier": "t_address", 878 | "typeString": "address" 879 | } 880 | }, 881 | "id": 4600, 882 | "nodeType": "ExpressionStatement", 883 | "src": "150:18:4" 884 | } 885 | ] 886 | }, 887 | "documentation": null, 888 | "id": 4602, 889 | "implemented": true, 890 | "kind": "constructor", 891 | "modifiers": [], 892 | "name": "", 893 | "nodeType": "FunctionDefinition", 894 | "parameters": { 895 | "id": 4594, 896 | "nodeType": "ParameterList", 897 | "parameters": [], 898 | "src": "134:2:4" 899 | }, 900 | "returnParameters": { 901 | "id": 4595, 902 | "nodeType": "ParameterList", 903 | "parameters": [], 904 | "src": "144:0:4" 905 | }, 906 | "scope": 4644, 907 | "src": "123:50:4", 908 | "stateMutability": "nonpayable", 909 | "superFunction": null, 910 | "visibility": "public" 911 | }, 912 | { 913 | "body": { 914 | "id": 4610, 915 | "nodeType": "Block", 916 | "src": "199:37:4", 917 | "statements": [ 918 | { 919 | "condition": { 920 | "argumentTypes": null, 921 | "commonType": { 922 | "typeIdentifier": "t_address", 923 | "typeString": "address" 924 | }, 925 | "id": 4607, 926 | "isConstant": false, 927 | "isLValue": false, 928 | "isPure": false, 929 | "lValueRequested": false, 930 | "leftExpression": { 931 | "argumentTypes": null, 932 | "expression": { 933 | "argumentTypes": null, 934 | "id": 4604, 935 | "name": "msg", 936 | "nodeType": "Identifier", 937 | "overloadedDeclarations": [], 938 | "referencedDeclaration": 4659, 939 | "src": "209:3:4", 940 | "typeDescriptions": { 941 | "typeIdentifier": "t_magic_message", 942 | "typeString": "msg" 943 | } 944 | }, 945 | "id": 4605, 946 | "isConstant": false, 947 | "isLValue": false, 948 | "isPure": false, 949 | "lValueRequested": false, 950 | "memberName": "sender", 951 | "nodeType": "MemberAccess", 952 | "referencedDeclaration": null, 953 | "src": "209:10:4", 954 | "typeDescriptions": { 955 | "typeIdentifier": "t_address_payable", 956 | "typeString": "address payable" 957 | } 958 | }, 959 | "nodeType": "BinaryOperation", 960 | "operator": "==", 961 | "rightExpression": { 962 | "argumentTypes": null, 963 | "id": 4606, 964 | "name": "owner", 965 | "nodeType": "Identifier", 966 | "overloadedDeclarations": [], 967 | "referencedDeclaration": 4591, 968 | "src": "223:5:4", 969 | "typeDescriptions": { 970 | "typeIdentifier": "t_address", 971 | "typeString": "address" 972 | } 973 | }, 974 | "src": "209:19:4", 975 | "typeDescriptions": { 976 | "typeIdentifier": "t_bool", 977 | "typeString": "bool" 978 | } 979 | }, 980 | "falseBody": null, 981 | "id": 4609, 982 | "nodeType": "IfStatement", 983 | "src": "205:26:4", 984 | "trueBody": { 985 | "id": 4608, 986 | "nodeType": "PlaceholderStatement", 987 | "src": "230:1:4" 988 | } 989 | } 990 | ] 991 | }, 992 | "documentation": null, 993 | "id": 4611, 994 | "name": "restricted", 995 | "nodeType": "ModifierDefinition", 996 | "parameters": { 997 | "id": 4603, 998 | "nodeType": "ParameterList", 999 | "parameters": [], 1000 | "src": "196:2:4" 1001 | }, 1002 | "src": "177:59:4", 1003 | "visibility": "internal" 1004 | }, 1005 | { 1006 | "body": { 1007 | "id": 4622, 1008 | "nodeType": "Block", 1009 | "src": "296:47:4", 1010 | "statements": [ 1011 | { 1012 | "expression": { 1013 | "argumentTypes": null, 1014 | "id": 4620, 1015 | "isConstant": false, 1016 | "isLValue": false, 1017 | "isPure": false, 1018 | "lValueRequested": false, 1019 | "leftHandSide": { 1020 | "argumentTypes": null, 1021 | "id": 4618, 1022 | "name": "last_completed_migration", 1023 | "nodeType": "Identifier", 1024 | "overloadedDeclarations": [], 1025 | "referencedDeclaration": 4593, 1026 | "src": "302:24:4", 1027 | "typeDescriptions": { 1028 | "typeIdentifier": "t_uint256", 1029 | "typeString": "uint256" 1030 | } 1031 | }, 1032 | "nodeType": "Assignment", 1033 | "operator": "=", 1034 | "rightHandSide": { 1035 | "argumentTypes": null, 1036 | "id": 4619, 1037 | "name": "completed", 1038 | "nodeType": "Identifier", 1039 | "overloadedDeclarations": [], 1040 | "referencedDeclaration": 4613, 1041 | "src": "329:9:4", 1042 | "typeDescriptions": { 1043 | "typeIdentifier": "t_uint256", 1044 | "typeString": "uint256" 1045 | } 1046 | }, 1047 | "src": "302:36:4", 1048 | "typeDescriptions": { 1049 | "typeIdentifier": "t_uint256", 1050 | "typeString": "uint256" 1051 | } 1052 | }, 1053 | "id": 4621, 1054 | "nodeType": "ExpressionStatement", 1055 | "src": "302:36:4" 1056 | } 1057 | ] 1058 | }, 1059 | "documentation": null, 1060 | "id": 4623, 1061 | "implemented": true, 1062 | "kind": "function", 1063 | "modifiers": [ 1064 | { 1065 | "arguments": null, 1066 | "id": 4616, 1067 | "modifierName": { 1068 | "argumentTypes": null, 1069 | "id": 4615, 1070 | "name": "restricted", 1071 | "nodeType": "Identifier", 1072 | "overloadedDeclarations": [], 1073 | "referencedDeclaration": 4611, 1074 | "src": "285:10:4", 1075 | "typeDescriptions": { 1076 | "typeIdentifier": "t_modifier$__$", 1077 | "typeString": "modifier ()" 1078 | } 1079 | }, 1080 | "nodeType": "ModifierInvocation", 1081 | "src": "285:10:4" 1082 | } 1083 | ], 1084 | "name": "setCompleted", 1085 | "nodeType": "FunctionDefinition", 1086 | "parameters": { 1087 | "id": 4614, 1088 | "nodeType": "ParameterList", 1089 | "parameters": [ 1090 | { 1091 | "constant": false, 1092 | "id": 4613, 1093 | "name": "completed", 1094 | "nodeType": "VariableDeclaration", 1095 | "scope": 4623, 1096 | "src": "262:14:4", 1097 | "stateVariable": false, 1098 | "storageLocation": "default", 1099 | "typeDescriptions": { 1100 | "typeIdentifier": "t_uint256", 1101 | "typeString": "uint256" 1102 | }, 1103 | "typeName": { 1104 | "id": 4612, 1105 | "name": "uint", 1106 | "nodeType": "ElementaryTypeName", 1107 | "src": "262:4:4", 1108 | "typeDescriptions": { 1109 | "typeIdentifier": "t_uint256", 1110 | "typeString": "uint256" 1111 | } 1112 | }, 1113 | "value": null, 1114 | "visibility": "internal" 1115 | } 1116 | ], 1117 | "src": "261:16:4" 1118 | }, 1119 | "returnParameters": { 1120 | "id": 4617, 1121 | "nodeType": "ParameterList", 1122 | "parameters": [], 1123 | "src": "296:0:4" 1124 | }, 1125 | "scope": 4644, 1126 | "src": "240:103:4", 1127 | "stateMutability": "nonpayable", 1128 | "superFunction": null, 1129 | "visibility": "public" 1130 | }, 1131 | { 1132 | "body": { 1133 | "id": 4642, 1134 | "nodeType": "Block", 1135 | "src": "403:109:4", 1136 | "statements": [ 1137 | { 1138 | "assignments": [ 1139 | 4631 1140 | ], 1141 | "declarations": [ 1142 | { 1143 | "constant": false, 1144 | "id": 4631, 1145 | "name": "upgraded", 1146 | "nodeType": "VariableDeclaration", 1147 | "scope": 4642, 1148 | "src": "409:19:4", 1149 | "stateVariable": false, 1150 | "storageLocation": "default", 1151 | "typeDescriptions": { 1152 | "typeIdentifier": "t_contract$_Migrations_$4644", 1153 | "typeString": "contract Migrations" 1154 | }, 1155 | "typeName": { 1156 | "contractScope": null, 1157 | "id": 4630, 1158 | "name": "Migrations", 1159 | "nodeType": "UserDefinedTypeName", 1160 | "referencedDeclaration": 4644, 1161 | "src": "409:10:4", 1162 | "typeDescriptions": { 1163 | "typeIdentifier": "t_contract$_Migrations_$4644", 1164 | "typeString": "contract Migrations" 1165 | } 1166 | }, 1167 | "value": null, 1168 | "visibility": "internal" 1169 | } 1170 | ], 1171 | "id": 4635, 1172 | "initialValue": { 1173 | "argumentTypes": null, 1174 | "arguments": [ 1175 | { 1176 | "argumentTypes": null, 1177 | "id": 4633, 1178 | "name": "new_address", 1179 | "nodeType": "Identifier", 1180 | "overloadedDeclarations": [], 1181 | "referencedDeclaration": 4625, 1182 | "src": "442:11:4", 1183 | "typeDescriptions": { 1184 | "typeIdentifier": "t_address", 1185 | "typeString": "address" 1186 | } 1187 | } 1188 | ], 1189 | "expression": { 1190 | "argumentTypes": [ 1191 | { 1192 | "typeIdentifier": "t_address", 1193 | "typeString": "address" 1194 | } 1195 | ], 1196 | "id": 4632, 1197 | "name": "Migrations", 1198 | "nodeType": "Identifier", 1199 | "overloadedDeclarations": [], 1200 | "referencedDeclaration": 4644, 1201 | "src": "431:10:4", 1202 | "typeDescriptions": { 1203 | "typeIdentifier": "t_type$_t_contract$_Migrations_$4644_$", 1204 | "typeString": "type(contract Migrations)" 1205 | } 1206 | }, 1207 | "id": 4634, 1208 | "isConstant": false, 1209 | "isLValue": false, 1210 | "isPure": false, 1211 | "kind": "typeConversion", 1212 | "lValueRequested": false, 1213 | "names": [], 1214 | "nodeType": "FunctionCall", 1215 | "src": "431:23:4", 1216 | "typeDescriptions": { 1217 | "typeIdentifier": "t_contract$_Migrations_$4644", 1218 | "typeString": "contract Migrations" 1219 | } 1220 | }, 1221 | "nodeType": "VariableDeclarationStatement", 1222 | "src": "409:45:4" 1223 | }, 1224 | { 1225 | "expression": { 1226 | "argumentTypes": null, 1227 | "arguments": [ 1228 | { 1229 | "argumentTypes": null, 1230 | "id": 4639, 1231 | "name": "last_completed_migration", 1232 | "nodeType": "Identifier", 1233 | "overloadedDeclarations": [], 1234 | "referencedDeclaration": 4593, 1235 | "src": "482:24:4", 1236 | "typeDescriptions": { 1237 | "typeIdentifier": "t_uint256", 1238 | "typeString": "uint256" 1239 | } 1240 | } 1241 | ], 1242 | "expression": { 1243 | "argumentTypes": [ 1244 | { 1245 | "typeIdentifier": "t_uint256", 1246 | "typeString": "uint256" 1247 | } 1248 | ], 1249 | "expression": { 1250 | "argumentTypes": null, 1251 | "id": 4636, 1252 | "name": "upgraded", 1253 | "nodeType": "Identifier", 1254 | "overloadedDeclarations": [], 1255 | "referencedDeclaration": 4631, 1256 | "src": "460:8:4", 1257 | "typeDescriptions": { 1258 | "typeIdentifier": "t_contract$_Migrations_$4644", 1259 | "typeString": "contract Migrations" 1260 | } 1261 | }, 1262 | "id": 4638, 1263 | "isConstant": false, 1264 | "isLValue": false, 1265 | "isPure": false, 1266 | "lValueRequested": false, 1267 | "memberName": "setCompleted", 1268 | "nodeType": "MemberAccess", 1269 | "referencedDeclaration": 4623, 1270 | "src": "460:21:4", 1271 | "typeDescriptions": { 1272 | "typeIdentifier": "t_function_external_nonpayable$_t_uint256_$returns$__$", 1273 | "typeString": "function (uint256) external" 1274 | } 1275 | }, 1276 | "id": 4640, 1277 | "isConstant": false, 1278 | "isLValue": false, 1279 | "isPure": false, 1280 | "kind": "functionCall", 1281 | "lValueRequested": false, 1282 | "names": [], 1283 | "nodeType": "FunctionCall", 1284 | "src": "460:47:4", 1285 | "typeDescriptions": { 1286 | "typeIdentifier": "t_tuple$__$", 1287 | "typeString": "tuple()" 1288 | } 1289 | }, 1290 | "id": 4641, 1291 | "nodeType": "ExpressionStatement", 1292 | "src": "460:47:4" 1293 | } 1294 | ] 1295 | }, 1296 | "documentation": null, 1297 | "id": 4643, 1298 | "implemented": true, 1299 | "kind": "function", 1300 | "modifiers": [ 1301 | { 1302 | "arguments": null, 1303 | "id": 4628, 1304 | "modifierName": { 1305 | "argumentTypes": null, 1306 | "id": 4627, 1307 | "name": "restricted", 1308 | "nodeType": "Identifier", 1309 | "overloadedDeclarations": [], 1310 | "referencedDeclaration": 4611, 1311 | "src": "392:10:4", 1312 | "typeDescriptions": { 1313 | "typeIdentifier": "t_modifier$__$", 1314 | "typeString": "modifier ()" 1315 | } 1316 | }, 1317 | "nodeType": "ModifierInvocation", 1318 | "src": "392:10:4" 1319 | } 1320 | ], 1321 | "name": "upgrade", 1322 | "nodeType": "FunctionDefinition", 1323 | "parameters": { 1324 | "id": 4626, 1325 | "nodeType": "ParameterList", 1326 | "parameters": [ 1327 | { 1328 | "constant": false, 1329 | "id": 4625, 1330 | "name": "new_address", 1331 | "nodeType": "VariableDeclaration", 1332 | "scope": 4643, 1333 | "src": "364:19:4", 1334 | "stateVariable": false, 1335 | "storageLocation": "default", 1336 | "typeDescriptions": { 1337 | "typeIdentifier": "t_address", 1338 | "typeString": "address" 1339 | }, 1340 | "typeName": { 1341 | "id": 4624, 1342 | "name": "address", 1343 | "nodeType": "ElementaryTypeName", 1344 | "src": "364:7:4", 1345 | "stateMutability": "nonpayable", 1346 | "typeDescriptions": { 1347 | "typeIdentifier": "t_address", 1348 | "typeString": "address" 1349 | } 1350 | }, 1351 | "value": null, 1352 | "visibility": "internal" 1353 | } 1354 | ], 1355 | "src": "363:21:4" 1356 | }, 1357 | "returnParameters": { 1358 | "id": 4629, 1359 | "nodeType": "ParameterList", 1360 | "parameters": [], 1361 | "src": "403:0:4" 1362 | }, 1363 | "scope": 4644, 1364 | "src": "347:165:4", 1365 | "stateMutability": "nonpayable", 1366 | "superFunction": null, 1367 | "visibility": "public" 1368 | } 1369 | ], 1370 | "scope": 4645, 1371 | "src": "34:480:4" 1372 | } 1373 | ], 1374 | "src": "0:515:4" 1375 | }, 1376 | "compiler": { 1377 | "name": "solc", 1378 | "version": "0.5.12+commit.7709ece9.Emscripten.clang" 1379 | }, 1380 | "networks": {}, 1381 | "schemaVersion": "3.0.19", 1382 | "updatedAt": "2020-02-05T00:41:07.736Z", 1383 | "devdoc": { 1384 | "methods": {} 1385 | }, 1386 | "userdoc": { 1387 | "methods": {} 1388 | } 1389 | } -------------------------------------------------------------------------------- /contracts/APROracle.sol: -------------------------------------------------------------------------------- 1 | 2 | // File: @openzeppelin\contracts\token\ERC20\IERC20.sol 3 | 4 | pragma solidity ^0.5.0; 5 | 6 | /** 7 | * @dev Interface of the ERC20 standard as defined in the EIP. Does not include 8 | * the optional functions; to access them see {ERC20Detailed}. 9 | */ 10 | interface IERC20 { 11 | /** 12 | * @dev Returns the amount of tokens in existence. 13 | */ 14 | function totalSupply() external view returns (uint256); 15 | 16 | /** 17 | * @dev Returns the amount of tokens owned by `account`. 18 | */ 19 | function balanceOf(address account) external view returns (uint256); 20 | 21 | /** 22 | * @dev Moves `amount` tokens from the caller's account to `recipient`. 23 | * 24 | * Returns a boolean value indicating whether the operation succeeded. 25 | * 26 | * Emits a {Transfer} event. 27 | */ 28 | function transfer(address recipient, uint256 amount) external returns (bool); 29 | 30 | /** 31 | * @dev Returns the remaining number of tokens that `spender` will be 32 | * allowed to spend on behalf of `owner` through {transferFrom}. This is 33 | * zero by default. 34 | * 35 | * This value changes when {approve} or {transferFrom} are called. 36 | */ 37 | function allowance(address owner, address spender) external view returns (uint256); 38 | 39 | /** 40 | * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. 41 | * 42 | * Returns a boolean value indicating whether the operation succeeded. 43 | * 44 | * IMPORTANT: Beware that changing an allowance with this method brings the risk 45 | * that someone may use both the old and the new allowance by unfortunate 46 | * transaction ordering. One possible solution to mitigate this race 47 | * condition is to first reduce the spender's allowance to 0 and set the 48 | * desired value afterwards: 49 | * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 50 | * 51 | * Emits an {Approval} event. 52 | */ 53 | function approve(address spender, uint256 amount) external returns (bool); 54 | 55 | /** 56 | * @dev Moves `amount` tokens from `sender` to `recipient` using the 57 | * allowance mechanism. `amount` is then deducted from the caller's 58 | * allowance. 59 | * 60 | * Returns a boolean value indicating whether the operation succeeded. 61 | * 62 | * Emits a {Transfer} event. 63 | */ 64 | function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); 65 | 66 | /** 67 | * @dev Emitted when `value` tokens are moved from one account (`from`) to 68 | * another (`to`). 69 | * 70 | * Note that `value` may be zero. 71 | */ 72 | event Transfer(address indexed from, address indexed to, uint256 value); 73 | 74 | /** 75 | * @dev Emitted when the allowance of a `spender` for an `owner` is set by 76 | * a call to {approve}. `value` is the new allowance. 77 | */ 78 | event Approval(address indexed owner, address indexed spender, uint256 value); 79 | } 80 | 81 | // File: @openzeppelin\contracts\GSN\Context.sol 82 | 83 | pragma solidity ^0.5.0; 84 | 85 | /* 86 | * @dev Provides information about the current execution context, including the 87 | * sender of the transaction and its data. While these are generally available 88 | * via msg.sender and msg.data, they should not be accessed in such a direct 89 | * manner, since when dealing with GSN meta-transactions the account sending and 90 | * paying for execution may not be the actual sender (as far as an application 91 | * is concerned). 92 | * 93 | * This contract is only required for intermediate, library-like contracts. 94 | */ 95 | contract Context { 96 | // Empty internal constructor, to prevent people from mistakenly deploying 97 | // an instance of this contract, which should be used via inheritance. 98 | constructor () internal { } 99 | // solhint-disable-previous-line no-empty-blocks 100 | 101 | function _msgSender() internal view returns (address payable) { 102 | return msg.sender; 103 | } 104 | 105 | function _msgData() internal view returns (bytes memory) { 106 | this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 107 | return msg.data; 108 | } 109 | } 110 | 111 | // File: @openzeppelin\contracts\ownership\Ownable.sol 112 | 113 | pragma solidity ^0.5.0; 114 | 115 | /** 116 | * @dev Contract module which provides a basic access control mechanism, where 117 | * there is an account (an owner) that can be granted exclusive access to 118 | * specific functions. 119 | * 120 | * This module is used through inheritance. It will make available the modifier 121 | * `onlyOwner`, which can be applied to your functions to restrict their use to 122 | * the owner. 123 | */ 124 | contract Ownable is Context { 125 | address private _owner; 126 | 127 | event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); 128 | 129 | /** 130 | * @dev Initializes the contract setting the deployer as the initial owner. 131 | */ 132 | constructor () internal { 133 | _owner = _msgSender(); 134 | emit OwnershipTransferred(address(0), _owner); 135 | } 136 | 137 | /** 138 | * @dev Returns the address of the current owner. 139 | */ 140 | function owner() public view returns (address) { 141 | return _owner; 142 | } 143 | 144 | /** 145 | * @dev Throws if called by any account other than the owner. 146 | */ 147 | modifier onlyOwner() { 148 | require(isOwner(), "Ownable: caller is not the owner"); 149 | _; 150 | } 151 | 152 | /** 153 | * @dev Returns true if the caller is the current owner. 154 | */ 155 | function isOwner() public view returns (bool) { 156 | return _msgSender() == _owner; 157 | } 158 | 159 | /** 160 | * @dev Leaves the contract without owner. It will not be possible to call 161 | * `onlyOwner` functions anymore. Can only be called by the current owner. 162 | * 163 | * NOTE: Renouncing ownership will leave the contract without an owner, 164 | * thereby removing any functionality that is only available to the owner. 165 | */ 166 | function renounceOwnership() public onlyOwner { 167 | emit OwnershipTransferred(_owner, address(0)); 168 | _owner = address(0); 169 | } 170 | 171 | /** 172 | * @dev Transfers ownership of the contract to a new account (`newOwner`). 173 | * Can only be called by the current owner. 174 | */ 175 | function transferOwnership(address newOwner) public onlyOwner { 176 | _transferOwnership(newOwner); 177 | } 178 | 179 | /** 180 | * @dev Transfers ownership of the contract to a new account (`newOwner`). 181 | */ 182 | function _transferOwnership(address newOwner) internal { 183 | require(newOwner != address(0), "Ownable: new owner is the zero address"); 184 | emit OwnershipTransferred(_owner, newOwner); 185 | _owner = newOwner; 186 | } 187 | } 188 | 189 | // File: @openzeppelin\contracts\math\SafeMath.sol 190 | 191 | pragma solidity ^0.5.0; 192 | 193 | /** 194 | * @dev Wrappers over Solidity's arithmetic operations with added overflow 195 | * checks. 196 | * 197 | * Arithmetic operations in Solidity wrap on overflow. This can easily result 198 | * in bugs, because programmers usually assume that an overflow raises an 199 | * error, which is the standard behavior in high level programming languages. 200 | * `SafeMath` restores this intuition by reverting the transaction when an 201 | * operation overflows. 202 | * 203 | * Using this library instead of the unchecked operations eliminates an entire 204 | * class of bugs, so it's recommended to use it always. 205 | */ 206 | library SafeMath { 207 | /** 208 | * @dev Returns the addition of two unsigned integers, reverting on 209 | * overflow. 210 | * 211 | * Counterpart to Solidity's `+` operator. 212 | * 213 | * Requirements: 214 | * - Addition cannot overflow. 215 | */ 216 | function add(uint256 a, uint256 b) internal pure returns (uint256) { 217 | uint256 c = a + b; 218 | require(c >= a, "SafeMath: addition overflow"); 219 | 220 | return c; 221 | } 222 | 223 | /** 224 | * @dev Returns the subtraction of two unsigned integers, reverting on 225 | * overflow (when the result is negative). 226 | * 227 | * Counterpart to Solidity's `-` operator. 228 | * 229 | * Requirements: 230 | * - Subtraction cannot overflow. 231 | */ 232 | function sub(uint256 a, uint256 b) internal pure returns (uint256) { 233 | return sub(a, b, "SafeMath: subtraction overflow"); 234 | } 235 | 236 | /** 237 | * @dev Returns the subtraction of two unsigned integers, reverting with custom message on 238 | * overflow (when the result is negative). 239 | * 240 | * Counterpart to Solidity's `-` operator. 241 | * 242 | * Requirements: 243 | * - Subtraction cannot overflow. 244 | * 245 | * _Available since v2.4.0._ 246 | */ 247 | function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { 248 | require(b <= a, errorMessage); 249 | uint256 c = a - b; 250 | 251 | return c; 252 | } 253 | 254 | /** 255 | * @dev Returns the multiplication of two unsigned integers, reverting on 256 | * overflow. 257 | * 258 | * Counterpart to Solidity's `*` operator. 259 | * 260 | * Requirements: 261 | * - Multiplication cannot overflow. 262 | */ 263 | function mul(uint256 a, uint256 b) internal pure returns (uint256) { 264 | // Gas optimization: this is cheaper than requiring 'a' not being zero, but the 265 | // benefit is lost if 'b' is also tested. 266 | // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 267 | if (a == 0) { 268 | return 0; 269 | } 270 | 271 | uint256 c = a * b; 272 | require(c / a == b, "SafeMath: multiplication overflow"); 273 | 274 | return c; 275 | } 276 | 277 | /** 278 | * @dev Returns the integer division of two unsigned integers. Reverts on 279 | * division by zero. The result is rounded towards zero. 280 | * 281 | * Counterpart to Solidity's `/` operator. Note: this function uses a 282 | * `revert` opcode (which leaves remaining gas untouched) while Solidity 283 | * uses an invalid opcode to revert (consuming all remaining gas). 284 | * 285 | * Requirements: 286 | * - The divisor cannot be zero. 287 | */ 288 | function div(uint256 a, uint256 b) internal pure returns (uint256) { 289 | return div(a, b, "SafeMath: division by zero"); 290 | } 291 | 292 | /** 293 | * @dev Returns the integer division of two unsigned integers. Reverts with custom message on 294 | * division by zero. The result is rounded towards zero. 295 | * 296 | * Counterpart to Solidity's `/` operator. Note: this function uses a 297 | * `revert` opcode (which leaves remaining gas untouched) while Solidity 298 | * uses an invalid opcode to revert (consuming all remaining gas). 299 | * 300 | * Requirements: 301 | * - The divisor cannot be zero. 302 | * 303 | * _Available since v2.4.0._ 304 | */ 305 | function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { 306 | // Solidity only automatically asserts when dividing by 0 307 | require(b > 0, errorMessage); 308 | uint256 c = a / b; 309 | // assert(a == b * c + a % b); // There is no case in which this doesn't hold 310 | 311 | return c; 312 | } 313 | 314 | /** 315 | * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), 316 | * Reverts when dividing by zero. 317 | * 318 | * Counterpart to Solidity's `%` operator. This function uses a `revert` 319 | * opcode (which leaves remaining gas untouched) while Solidity uses an 320 | * invalid opcode to revert (consuming all remaining gas). 321 | * 322 | * Requirements: 323 | * - The divisor cannot be zero. 324 | */ 325 | function mod(uint256 a, uint256 b) internal pure returns (uint256) { 326 | return mod(a, b, "SafeMath: modulo by zero"); 327 | } 328 | 329 | /** 330 | * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), 331 | * Reverts with custom message when dividing by zero. 332 | * 333 | * Counterpart to Solidity's `%` operator. This function uses a `revert` 334 | * opcode (which leaves remaining gas untouched) while Solidity uses an 335 | * invalid opcode to revert (consuming all remaining gas). 336 | * 337 | * Requirements: 338 | * - The divisor cannot be zero. 339 | * 340 | * _Available since v2.4.0._ 341 | */ 342 | function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { 343 | require(b != 0, errorMessage); 344 | return a % b; 345 | } 346 | } 347 | 348 | // File: @openzeppelin\contracts\utils\Address.sol 349 | 350 | pragma solidity ^0.5.5; 351 | 352 | /** 353 | * @dev Collection of functions related to the address type 354 | */ 355 | library Address { 356 | /** 357 | * @dev Returns true if `account` is a contract. 358 | * 359 | * This test is non-exhaustive, and there may be false-negatives: during the 360 | * execution of a contract's constructor, its address will be reported as 361 | * not containing a contract. 362 | * 363 | * IMPORTANT: It is unsafe to assume that an address for which this 364 | * function returns false is an externally-owned account (EOA) and not a 365 | * contract. 366 | */ 367 | function isContract(address account) internal view returns (bool) { 368 | // This method relies in extcodesize, which returns 0 for contracts in 369 | // construction, since the code is only stored at the end of the 370 | // constructor execution. 371 | 372 | // According to EIP-1052, 0x0 is the value returned for not-yet created accounts 373 | // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned 374 | // for accounts without code, i.e. `keccak256('')` 375 | bytes32 codehash; 376 | bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; 377 | // solhint-disable-next-line no-inline-assembly 378 | assembly { codehash := extcodehash(account) } 379 | return (codehash != 0x0 && codehash != accountHash); 380 | } 381 | 382 | /** 383 | * @dev Converts an `address` into `address payable`. Note that this is 384 | * simply a type cast: the actual underlying value is not changed. 385 | * 386 | * _Available since v2.4.0._ 387 | */ 388 | function toPayable(address account) internal pure returns (address payable) { 389 | return address(uint160(account)); 390 | } 391 | 392 | /** 393 | * @dev Replacement for Solidity's `transfer`: sends `amount` wei to 394 | * `recipient`, forwarding all available gas and reverting on errors. 395 | * 396 | * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost 397 | * of certain opcodes, possibly making contracts go over the 2300 gas limit 398 | * imposed by `transfer`, making them unable to receive funds via 399 | * `transfer`. {sendValue} removes this limitation. 400 | * 401 | * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. 402 | * 403 | * IMPORTANT: because control is transferred to `recipient`, care must be 404 | * taken to not create reentrancy vulnerabilities. Consider using 405 | * {ReentrancyGuard} or the 406 | * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. 407 | * 408 | * _Available since v2.4.0._ 409 | */ 410 | function sendValue(address payable recipient, uint256 amount) internal { 411 | require(address(this).balance >= amount, "Address: insufficient balance"); 412 | 413 | // solhint-disable-next-line avoid-call-value 414 | (bool success, ) = recipient.call.value(amount)(""); 415 | require(success, "Address: unable to send value, recipient may have reverted"); 416 | } 417 | } 418 | 419 | // File: contracts\OracleStore.sol 420 | 421 | pragma solidity >=0.4.21 <0.7.0; 422 | pragma experimental ABIEncoderV2; 423 | 424 | 425 | 426 | // Compound 427 | interface Compound { 428 | function supply(address asset, uint amount) external returns (uint); 429 | function withdraw(address asset, uint requestedAmount) external returns (uint); 430 | function getSupplyBalance(address account, address asset) view external returns (uint); 431 | function supplyRatePerBlock() external view returns (uint); 432 | function mint(uint mintAmount) external returns (uint); 433 | function redeem(uint redeemTokens) external returns (uint); 434 | function balanceOf(address account) external view returns (uint); 435 | } 436 | 437 | // Fulcrum 438 | interface Fulcrum { 439 | function supplyInterestRate() external view returns (uint256); 440 | } 441 | 442 | interface DyDx { 443 | struct val { 444 | uint256 value; 445 | } 446 | 447 | struct set { 448 | uint128 borrow; 449 | uint128 supply; 450 | } 451 | 452 | function getEarningsRate() external view returns (val memory); 453 | function getMarketInterestRate(uint256 marketId) external view returns (val memory); 454 | function getMarketTotalPar(uint256 marketId) external view returns (set memory); 455 | } 456 | 457 | interface LendingPoolAddressesProvider { 458 | function getLendingPoolCore() external view returns (address); 459 | } 460 | 461 | interface LendingPoolCore { 462 | function getReserveCurrentLiquidityRate(address _reserve) 463 | external 464 | view 465 | returns ( 466 | uint256 liquidityRate 467 | ); 468 | } 469 | 470 | contract APROracle is Ownable { 471 | using SafeMath for uint256; 472 | using Address for address; 473 | 474 | uint256 DECIMAL = 10 ** 18; 475 | 476 | mapping(address => uint256) _priceStore; 477 | mapping(address => uint256) _liquidityStore; 478 | address public oracle; 479 | 480 | // MAINNET ADDRESSES 481 | address public DYDX; 482 | address public AAVE; 483 | 484 | // Ease of use functions, can also use generic lookups for new tokens 485 | address public CDAI; 486 | address public CBAT; 487 | address public CETH; 488 | address public CREP; 489 | address public CSAI; 490 | address public CUSDC; 491 | address public CWBTC; 492 | address public CZRX; 493 | 494 | address public IZRX; 495 | address public IREP; 496 | address public IKNC; 497 | address public IBAT; 498 | address public IWBTC; 499 | address public IUSDC; 500 | address public IETH; 501 | address public ISAI; 502 | address public IDAI; 503 | address public ILINK; 504 | address public ISUSD; 505 | 506 | address public ADAI; 507 | address public ATUSD; 508 | address public AUSDC; 509 | address public AUSDT; 510 | address public ASUSD; 511 | address public ALEND; 512 | address public ABAT; 513 | address public AETH; 514 | address public ALINK; 515 | address public AKNC; 516 | address public AREP; 517 | address public AMKR; 518 | address public AMANA; 519 | address public AZRX; 520 | address public ASNX; 521 | address public AWBTC; 522 | 523 | constructor() public { 524 | oracle = msg.sender; 525 | DYDX = address(0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e); 526 | AAVE = address(0x24a42fD28C976A61Df5D00D0599C34c4f90748c8); 527 | 528 | CDAI = address(0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643); 529 | CBAT = address(0x6C8c6b02E7b2BE14d4fA6022Dfd6d75921D90E4E); 530 | CETH = address(0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5); 531 | CREP = address(0x158079Ee67Fce2f58472A96584A73C7Ab9AC95c1); 532 | CSAI = address(0xF5DCe57282A584D2746FaF1593d3121Fcac444dC); 533 | CUSDC = address(0x39AA39c021dfbaE8faC545936693aC917d5E7563); 534 | CWBTC = address(0xC11b1268C1A384e55C48c2391d8d480264A3A7F4); 535 | CZRX = address(0xB3319f5D18Bc0D84dD1b4825Dcde5d5f7266d407); 536 | 537 | IZRX = address(0xA7Eb2bc82df18013ecC2A6C533fc29446442EDEe); 538 | IREP = address(0xBd56E9477Fc6997609Cf45F84795eFbDAC642Ff1); 539 | IKNC = address(0x1cC9567EA2eB740824a45F8026cCF8e46973234D); 540 | IWBTC = address(0xBA9262578EFef8b3aFf7F60Cd629d6CC8859C8b5); 541 | IUSDC = address(0xF013406A0B1d544238083DF0B93ad0d2cBE0f65f); 542 | IETH = address(0x77f973FCaF871459aa58cd81881Ce453759281bC); 543 | ISAI = address(0x14094949152EDDBFcd073717200DA82fEd8dC960); 544 | IDAI = address(0x493C57C4763932315A328269E1ADaD09653B9081); 545 | ILINK = address(0x1D496da96caf6b518b133736beca85D5C4F9cBc5); 546 | ISUSD = address(0x49f4592E641820e928F9919Ef4aBd92a719B4b49); 547 | 548 | ADAI = address(0x6B175474E89094C44Da98b954EedeAC495271d0F); 549 | ATUSD = address(0x0000000000085d4780B73119b644AE5ecd22b376); 550 | AUSDC = address(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48); 551 | AUSDT = address(0xdAC17F958D2ee523a2206206994597C13D831ec7); 552 | ASUSD = address(0x57Ab1ec28D129707052df4dF418D58a2D46d5f51); 553 | ALEND = address(0x80fB784B7eD66730e8b1DBd9820aFD29931aab03); 554 | ABAT = address(0x0D8775F648430679A709E98d2b0Cb6250d2887EF); 555 | AETH = address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE); 556 | ALINK = address(0x514910771AF9Ca656af840dff83E8264EcF986CA); 557 | AKNC = address(0xdd974D5C2e2928deA5F71b9825b8b646686BD200); 558 | AREP = address(0x1985365e9f78359a9B6AD760e32412f4a445E862); 559 | AMKR = address(0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2); 560 | AMANA = address(0x0F5D2fB29fb7d3CFeE444a200298f468908cC942); 561 | AZRX = address(0xE41d2489571d322189246DaFA5ebDe1F4699F498); 562 | ASNX = address(0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F); 563 | AWBTC = address(0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599); 564 | } 565 | 566 | function recommendDAI() public view returns (string memory) { 567 | uint256 max = 0; 568 | uint256 c = getCDAIAPR(); 569 | if (c > max) { 570 | max = c; 571 | } 572 | uint256 i = getIDAIAPR(); 573 | if (i > max) { 574 | max = i; 575 | } 576 | uint256 d = getDyDxDAIAPR(); 577 | if (d > max) { 578 | max = d; 579 | } 580 | uint256 a = getADAIAPR(); 581 | if (a > max) { 582 | max = a; 583 | } 584 | string memory best = 'none'; 585 | if (max == c) { 586 | best = 'Compound'; 587 | } 588 | if (max == i) { 589 | best = 'Fulcrum'; 590 | } 591 | if (max == d) { 592 | best = 'dYdX'; 593 | } 594 | if (max == a) { 595 | best = 'Aave'; 596 | } 597 | return best; 598 | } 599 | function recommendETH() public view returns (string memory) { 600 | uint256 max = 0; 601 | uint256 c = getCETHAPR(); 602 | if (c > max) { 603 | max = c; 604 | } 605 | uint256 i = getIETHAPR(); 606 | if (i > max) { 607 | max = i; 608 | } 609 | uint256 d = getDyDxETHAPR(); 610 | if (d > max) { 611 | max = d; 612 | } 613 | uint256 a = getAETHAPR(); 614 | if (a > max) { 615 | max = a; 616 | } 617 | string memory best = 'none'; 618 | if (max == c) { 619 | best = 'Compound'; 620 | } 621 | if (max == i) { 622 | best = 'Fulcrum'; 623 | } 624 | if (max == d) { 625 | best = 'dYdX'; 626 | } 627 | if (max == a) { 628 | best = 'Aave'; 629 | } 630 | return best; 631 | } 632 | function recommendUSDC() public view returns (string memory) { 633 | uint256 max = 0; 634 | uint256 c = getCUSDCAPR(); 635 | if (c > max) { 636 | max = c; 637 | } 638 | uint256 i = getIUSDCAPR(); 639 | if (i > max) { 640 | max = i; 641 | } 642 | uint256 d = getDyDxUSDCAPR(); 643 | if (d > max) { 644 | max = d; 645 | } 646 | uint256 a = getAUSDCAPR(); 647 | if (a > max) { 648 | max = a; 649 | } 650 | string memory best = 'none'; 651 | if (max == c) { 652 | best = 'Compound'; 653 | } 654 | if (max == i) { 655 | best = 'Fulcrum'; 656 | } 657 | if (max == d) { 658 | best = 'dYdX'; 659 | } 660 | if (max == a) { 661 | best = 'Aave'; 662 | } 663 | return best; 664 | } 665 | 666 | modifier restricted() { 667 | if (msg.sender == oracle) _; 668 | } 669 | 670 | function set_new_AAVE(address _new_AAVE) public restricted { 671 | AAVE = _new_AAVE; 672 | } 673 | 674 | function set_new_IZRX(address _new_IZRX) public restricted { 675 | IZRX = _new_IZRX; 676 | } 677 | 678 | function set_new_IREP(address _new_IREP) public restricted { 679 | IREP = _new_IREP; 680 | } 681 | 682 | function set_new_IKNC(address _new_IKNC) public restricted { 683 | IKNC = _new_IKNC; 684 | } 685 | 686 | function set_new_IWBTC(address _new_IWBTC) public restricted { 687 | IWBTC = _new_IWBTC; 688 | } 689 | 690 | function set_new_IUSDC(address _new_IUSDC) public restricted { 691 | IUSDC = _new_IUSDC; 692 | } 693 | 694 | function set_new_IETH(address _new_IETH) public restricted { 695 | IETH = _new_IETH; 696 | } 697 | 698 | function set_new_ISAI(address _new_ISAI) public restricted { 699 | ISAI = _new_ISAI; 700 | } 701 | 702 | function set_new_IDAI(address _new_IDAI) public restricted { 703 | IDAI = _new_IDAI; 704 | } 705 | 706 | function set_new_ILINK(address _new_ILINK) public restricted { 707 | ILINK = _new_ILINK; 708 | } 709 | 710 | function set_new_ISUSD(address _new_ISUSD) public restricted { 711 | ISUSD = _new_ISUSD; 712 | } 713 | 714 | function set_new_CDAI(address _new_CDAI) public restricted { 715 | CDAI = _new_CDAI; 716 | } 717 | 718 | function set_new_CBAT(address _new_CBAT) public restricted { 719 | CBAT = _new_CBAT; 720 | } 721 | 722 | function set_new_CETH(address _new_CETH) public restricted { 723 | CETH = _new_CETH; 724 | } 725 | 726 | function set_new_CREP(address _new_CREP) public restricted { 727 | CREP = _new_CREP; 728 | } 729 | 730 | function set_new_CSAI(address _new_CSAI) public restricted { 731 | CSAI = _new_CSAI; 732 | } 733 | 734 | function set_new_CUSDC(address _new_CUSDC) public restricted { 735 | CUSDC = _new_CUSDC; 736 | } 737 | 738 | function set_new_CWBTC(address _new_CWBTC) public restricted { 739 | CWBTC = _new_CWBTC; 740 | } 741 | 742 | function set_new_CZRX(address _new_CZRX) public restricted { 743 | CZRX = _new_CZRX; 744 | } 745 | 746 | function set_new_DYDX(address _new_DYDX) public restricted { 747 | DYDX = _new_DYDX; 748 | } 749 | 750 | function set_new_ADAI(address _new_ADAI) public restricted { 751 | ADAI = _new_ADAI; 752 | } 753 | 754 | function set_new_ATUSD(address _new_ATUSD) public restricted { 755 | ATUSD = _new_ATUSD; 756 | } 757 | 758 | function set_new_AUSDC(address _new_AUSDC) public restricted { 759 | AUSDC = _new_AUSDC; 760 | } 761 | 762 | function set_new_AUSDT(address _new_AUSDT) public restricted { 763 | AUSDT = _new_AUSDT; 764 | } 765 | 766 | function set_new_ASUSD(address _new_ASUSD) public restricted { 767 | ASUSD = _new_ASUSD; 768 | } 769 | 770 | function set_new_ALEND(address _new_ALEND) public restricted { 771 | ALEND = _new_ALEND; 772 | } 773 | 774 | function set_new_ABAT(address _new_ABAT) public restricted { 775 | ABAT = _new_ABAT; 776 | } 777 | 778 | function set_new_AETH(address _new_AETH) public restricted { 779 | AETH = _new_AETH; 780 | } 781 | 782 | function set_new_ALINK(address _new_ALINK) public restricted { 783 | ALINK = _new_ALINK; 784 | } 785 | 786 | function set_new_AKNC(address _new_AKNC) public restricted { 787 | AKNC = _new_AKNC; 788 | } 789 | 790 | function set_new_AREP(address _new_AREP) public restricted { 791 | AREP = _new_AREP; 792 | } 793 | 794 | function set_new_AMKR(address _new_AMKR) public restricted { 795 | AMKR = _new_AMKR; 796 | } 797 | 798 | function set_new_AMANA(address _new_AMANA) public restricted { 799 | AMANA = _new_AMANA; 800 | } 801 | 802 | function set_new_AZRX(address _new_AZRX) public restricted { 803 | AZRX = _new_AZRX; 804 | } 805 | 806 | function set_new_ASNX(address _new_ASNX) public restricted { 807 | ASNX = _new_ASNX; 808 | } 809 | 810 | function set_new_AWBTC(address _new_AWBTC) public restricted { 811 | AWBTC = _new_AWBTC; 812 | } 813 | 814 | function setPrice(address _token, uint256 _price) public restricted { 815 | _priceStore[_token] = _price; 816 | } 817 | 818 | function getPrice(address _token) public view returns (uint256) { 819 | return _priceStore[_token]; 820 | } 821 | 822 | function setLiquidity(address _token, uint256 _liquidity) public restricted { 823 | _liquidityStore[_token] = _liquidity; 824 | } 825 | 826 | function getLiquidity(address _token) public view returns (uint256) { 827 | return _liquidityStore[_token]; 828 | } 829 | 830 | function getAllCompoundAPR() 831 | external 832 | view 833 | returns ( 834 | uint256 cDAI, 835 | uint256 cBAT, 836 | uint256 cETH, 837 | uint256 cREP, 838 | uint256 cSAI, 839 | uint256 cUSDC, 840 | uint256 cWBTC, 841 | uint256 cZRC 842 | ) 843 | { 844 | return ( 845 | getCDAIAPR(), 846 | getCBATAPR(), 847 | getCETHAPR(), 848 | getCREPAPR(), 849 | getCSAIAPR(), 850 | getCUSDCAPR(), 851 | getCWBTCAPR(), 852 | getCZRCAPR() 853 | ); 854 | } 855 | 856 | // Compound 857 | function getCDAIAPR() public view returns (uint256) { 858 | return getCompoundAPR(CDAI); 859 | } 860 | function getCBATAPR() public view returns (uint256) { 861 | return getCompoundAPR(CBAT); 862 | } 863 | function getCETHAPR() public view returns (uint256) { 864 | return getCompoundAPR(CETH); 865 | } 866 | function getCREPAPR() public view returns (uint256) { 867 | return getCompoundAPR(CREP); 868 | } 869 | function getCSAIAPR() public view returns (uint256) { 870 | return getCompoundAPR(CSAI); 871 | } 872 | function getCUSDCAPR() public view returns (uint256) { 873 | return getCompoundAPR(CUSDC); 874 | } 875 | function getCWBTCAPR() public view returns (uint256) { 876 | return getCompoundAPR(CWBTC); 877 | } 878 | function getCZRCAPR() public view returns (uint256) { 879 | return getCompoundAPR(CZRX); 880 | } 881 | function getCompoundAPR(address token) public view returns (uint256) { 882 | return Compound(token).supplyRatePerBlock().mul(2102400); 883 | } 884 | 885 | function getAllDyDxAPR() 886 | external 887 | view 888 | returns ( 889 | uint256 dSAI, 890 | uint256 dETH, 891 | uint256 dUSDC, 892 | uint256 dDAI 893 | ) 894 | { 895 | return ( 896 | getDyDxSAIAPR(), 897 | getDyDxETHAPR(), 898 | getDyDxUSDCAPR(), 899 | getDyDxDAIAPR() 900 | ); 901 | } 902 | 903 | // dYdX 904 | function getDyDxSAIAPR() public view returns(uint256) { 905 | return getDyDxAPR(1); 906 | } 907 | function getDyDxETHAPR() public view returns(uint256) { 908 | return getDyDxAPR(0); 909 | } 910 | function getDyDxUSDCAPR() public view returns(uint256) { 911 | return getDyDxAPR(2); 912 | } 913 | function getDyDxDAIAPR() public view returns(uint256) { 914 | return getDyDxAPR(3); 915 | } 916 | 917 | function getAllFulcrumAPR() 918 | external 919 | view 920 | returns ( 921 | uint256 iZRX, 922 | uint256 iREP, 923 | uint256 iKNC, 924 | uint256 iWBTC, 925 | uint256 iUSDC, 926 | uint256 iETH, 927 | uint256 iSAI, 928 | uint256 iDAI, 929 | uint256 iLINK, 930 | uint256 iSUSD 931 | ) 932 | { 933 | return ( 934 | getIZRXAPR(), 935 | getIREPAPR(), 936 | getIKNCAPR(), 937 | getIWBTCAPR(), 938 | getIUSDCAPR(), 939 | getIETHAPR(), 940 | getISAIAPR(), 941 | getIDAIAPR(), 942 | getILINKAPR(), 943 | getISUSDAPR() 944 | ); 945 | } 946 | 947 | // Fulcrum 948 | function getIZRXAPR() public view returns (uint256) { 949 | return getFulcrumAPR(IZRX); 950 | } 951 | function getIREPAPR() public view returns (uint256) { 952 | return getFulcrumAPR(IREP); 953 | } 954 | function getIKNCAPR() public view returns (uint256) { 955 | return getFulcrumAPR(IKNC); 956 | } 957 | function getIWBTCAPR() public view returns (uint256) { 958 | return getFulcrumAPR(IWBTC); 959 | } 960 | function getIUSDCAPR() public view returns (uint256) { 961 | return getFulcrumAPR(IUSDC); 962 | } 963 | function getIETHAPR() public view returns (uint256) { 964 | return getFulcrumAPR(IETH); 965 | } 966 | function getISAIAPR() public view returns (uint256) { 967 | return getFulcrumAPR(ISAI); 968 | } 969 | function getIDAIAPR() public view returns (uint256) { 970 | return getFulcrumAPR(IDAI); 971 | } 972 | function getILINKAPR() public view returns (uint256) { 973 | return getFulcrumAPR(ILINK); 974 | } 975 | function getISUSDAPR() public view returns (uint256) { 976 | return getFulcrumAPR(ISUSD); 977 | } 978 | 979 | function getFulcrumAPR(address token) public view returns(uint256) { 980 | return Fulcrum(token).supplyInterestRate().div(100); 981 | } 982 | 983 | function getDyDxAPR(uint256 marketId) public view returns(uint256) { 984 | uint256 rate = DyDx(DYDX).getMarketInterestRate(marketId).value; 985 | uint256 aprBorrow = rate * 31622400; 986 | uint256 borrow = DyDx(DYDX).getMarketTotalPar(marketId).borrow; 987 | uint256 supply = DyDx(DYDX).getMarketTotalPar(marketId).supply; 988 | uint256 usage = (borrow * DECIMAL) / supply; 989 | uint256 apr = (((aprBorrow * usage) / DECIMAL) * DyDx(DYDX).getEarningsRate().value) / DECIMAL; 990 | return apr; 991 | } 992 | 993 | function getAllAaveAPR() 994 | external 995 | view 996 | returns ( 997 | uint256 aDAI, 998 | uint256 aTUSD, 999 | uint256 aUSDC, 1000 | uint256 aUSDT, 1001 | uint256 aSUSD, 1002 | uint256 aBAT, 1003 | uint256 aETH, 1004 | uint256 aLINK, 1005 | uint256 aKNC, 1006 | uint256 aREP, 1007 | uint256 aZRX, 1008 | uint256 aSNX 1009 | ) 1010 | { 1011 | return ( 1012 | getADAIAPR(), 1013 | getATUSDAPR(), 1014 | getAUSDCAPR(), 1015 | getAUSDTAPR(), 1016 | getASUSDAPR(), 1017 | getABATAPR(), 1018 | getAETHAPR(), 1019 | getALINKAPR(), 1020 | getAKNCAPR(), 1021 | getAREPAPR(), 1022 | getAZRXAPR(), 1023 | getASNXAPR() 1024 | ); 1025 | } 1026 | 1027 | function getADAIAPR() public view returns (uint256) { 1028 | return getAaveAPR(ADAI); 1029 | } 1030 | function getATUSDAPR() public view returns (uint256) { 1031 | return getAaveAPR(ATUSD); 1032 | } 1033 | function getAUSDCAPR() public view returns (uint256) { 1034 | return getAaveAPR(AUSDC); 1035 | } 1036 | function getAUSDTAPR() public view returns (uint256) { 1037 | return getAaveAPR(AUSDT); 1038 | } 1039 | function getASUSDAPR() public view returns (uint256) { 1040 | return getAaveAPR(ASUSD); 1041 | } 1042 | function getALENDAPR() public view returns (uint256) { 1043 | return getAaveAPR(ALEND); 1044 | } 1045 | function getABATAPR() public view returns (uint256) { 1046 | return getAaveAPR(ABAT); 1047 | } 1048 | function getAETHAPR() public view returns (uint256) { 1049 | return getAaveAPR(AETH); 1050 | } 1051 | function getALINKAPR() public view returns (uint256) { 1052 | return getAaveAPR(ALINK); 1053 | } 1054 | function getAKNCAPR() public view returns (uint256) { 1055 | return getAaveAPR(AKNC); 1056 | } 1057 | function getAREPAPR() public view returns (uint256) { 1058 | return getAaveAPR(AREP); 1059 | } 1060 | function getAMKRAPR() public view returns (uint256) { 1061 | return getAaveAPR(AMKR); 1062 | } 1063 | function getAMANAAPR() public view returns (uint256) { 1064 | return getAaveAPR(AMANA); 1065 | } 1066 | function getAZRXAPR() public view returns (uint256) { 1067 | return getAaveAPR(AZRX); 1068 | } 1069 | function getASNXAPR() public view returns (uint256) { 1070 | return getAaveAPR(ASNX); 1071 | } 1072 | function getAWBTCAPR() public view returns (uint256) { 1073 | return getAaveAPR(AWBTC); 1074 | } 1075 | 1076 | function getAaveCore() public view returns (address) { 1077 | return address(LendingPoolAddressesProvider(AAVE).getLendingPoolCore()); 1078 | } 1079 | 1080 | function getAaveAPR(address token) public view returns (uint256) { 1081 | LendingPoolCore core = LendingPoolCore(LendingPoolAddressesProvider(AAVE).getLendingPoolCore()); 1082 | return core.getReserveCurrentLiquidityRate(token).div(1e9); 1083 | } 1084 | 1085 | // incase of half-way error 1086 | function inCaseTokenGetsStuck(IERC20 _TokenAddress) onlyOwner public { 1087 | uint qty = _TokenAddress.balanceOf(address(this)); 1088 | _TokenAddress.transfer(msg.sender, qty); 1089 | } 1090 | // incase of half-way error 1091 | function inCaseETHGetsStuck() onlyOwner public{ 1092 | (bool result, ) = msg.sender.call.value(address(this).balance)(""); 1093 | require(result, "transfer of ETH failed"); 1094 | } 1095 | } 1096 | -------------------------------------------------------------------------------- /contracts/APRWithPoolOracle.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.0; 2 | pragma experimental ABIEncoderV2; 3 | 4 | interface IERC20 { 5 | function totalSupply() external view returns (uint256); 6 | function balanceOf(address account) external view returns (uint256); 7 | function transfer(address recipient, uint256 amount) external returns (bool); 8 | function allowance(address owner, address spender) external view returns (uint256); 9 | function decimals() external view returns (uint8); 10 | function approve(address spender, uint256 amount) external returns (bool); 11 | function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); 12 | event Transfer(address indexed from, address indexed to, uint256 value); 13 | event Approval(address indexed owner, address indexed spender, uint256 value); 14 | } 15 | 16 | contract Context { 17 | constructor () internal { } 18 | // solhint-disable-previous-line no-empty-blocks 19 | 20 | function _msgSender() internal view returns (address payable) { 21 | return msg.sender; 22 | } 23 | 24 | function _msgData() internal view returns (bytes memory) { 25 | this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 26 | return msg.data; 27 | } 28 | } 29 | contract Ownable is Context { 30 | address private _owner; 31 | 32 | event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); 33 | constructor () internal { 34 | _owner = _msgSender(); 35 | emit OwnershipTransferred(address(0), _owner); 36 | } 37 | function owner() public view returns (address) { 38 | return _owner; 39 | } 40 | modifier onlyOwner() { 41 | require(isOwner(), "Ownable: caller is not the owner"); 42 | _; 43 | } 44 | function isOwner() public view returns (bool) { 45 | return _msgSender() == _owner; 46 | } 47 | function renounceOwnership() public onlyOwner { 48 | emit OwnershipTransferred(_owner, address(0)); 49 | _owner = address(0); 50 | } 51 | function transferOwnership(address newOwner) public onlyOwner { 52 | _transferOwnership(newOwner); 53 | } 54 | function _transferOwnership(address newOwner) internal { 55 | require(newOwner != address(0), "Ownable: new owner is the zero address"); 56 | emit OwnershipTransferred(_owner, newOwner); 57 | _owner = newOwner; 58 | } 59 | } 60 | 61 | library SafeMath { 62 | function add(uint256 a, uint256 b) internal pure returns (uint256) { 63 | uint256 c = a + b; 64 | require(c >= a, "SafeMath: addition overflow"); 65 | 66 | return c; 67 | } 68 | function sub(uint256 a, uint256 b) internal pure returns (uint256) { 69 | return sub(a, b, "SafeMath: subtraction overflow"); 70 | } 71 | function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { 72 | require(b <= a, errorMessage); 73 | uint256 c = a - b; 74 | 75 | return c; 76 | } 77 | function mul(uint256 a, uint256 b) internal pure returns (uint256) { 78 | if (a == 0) { 79 | return 0; 80 | } 81 | 82 | uint256 c = a * b; 83 | require(c / a == b, "SafeMath: multiplication overflow"); 84 | 85 | return c; 86 | } 87 | function div(uint256 a, uint256 b) internal pure returns (uint256) { 88 | return div(a, b, "SafeMath: division by zero"); 89 | } 90 | function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { 91 | require(b > 0, errorMessage); 92 | uint256 c = a / b; 93 | 94 | return c; 95 | } 96 | function divCeil( 97 | uint256 a, 98 | uint256 b 99 | ) 100 | internal 101 | pure 102 | returns (uint256) 103 | { 104 | uint256 quotient = div(a, b); 105 | uint256 remainder = a - quotient * b; 106 | if (remainder > 0) { 107 | return quotient + 1; 108 | } else { 109 | return quotient; 110 | } 111 | } 112 | function mod(uint256 a, uint256 b) internal pure returns (uint256) { 113 | return mod(a, b, "SafeMath: modulo by zero"); 114 | } 115 | function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { 116 | require(b != 0, errorMessage); 117 | return a % b; 118 | } 119 | } 120 | 121 | library Decimal { 122 | using SafeMath for uint256; 123 | 124 | uint256 constant BASE = 10**18; 125 | 126 | function one() 127 | internal 128 | pure 129 | returns (uint256) 130 | { 131 | return BASE; 132 | } 133 | 134 | function onePlus( 135 | uint256 d 136 | ) 137 | internal 138 | pure 139 | returns (uint256) 140 | { 141 | return d.add(BASE); 142 | } 143 | 144 | function mulFloor( 145 | uint256 target, 146 | uint256 d 147 | ) 148 | internal 149 | pure 150 | returns (uint256) 151 | { 152 | return target.mul(d) / BASE; 153 | } 154 | 155 | function mulCeil( 156 | uint256 target, 157 | uint256 d 158 | ) 159 | internal 160 | pure 161 | returns (uint256) 162 | { 163 | return target.mul(d).divCeil(BASE); 164 | } 165 | 166 | function divFloor( 167 | uint256 target, 168 | uint256 d 169 | ) 170 | internal 171 | pure 172 | returns (uint256) 173 | { 174 | return target.mul(BASE).div(d); 175 | } 176 | 177 | function divCeil( 178 | uint256 target, 179 | uint256 d 180 | ) 181 | internal 182 | pure 183 | returns (uint256) 184 | { 185 | return target.mul(BASE).divCeil(d); 186 | } 187 | } 188 | 189 | library Address { 190 | function isContract(address account) internal view returns (bool) { 191 | bytes32 codehash; 192 | bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; 193 | // solhint-disable-next-line no-inline-assembly 194 | assembly { codehash := extcodehash(account) } 195 | return (codehash != 0x0 && codehash != accountHash); 196 | } 197 | function toPayable(address account) internal pure returns (address payable) { 198 | return address(uint160(account)); 199 | } 200 | function sendValue(address payable recipient, uint256 amount) internal { 201 | require(address(this).balance >= amount, "Address: insufficient balance"); 202 | 203 | // solhint-disable-next-line avoid-call-value 204 | (bool success, ) = recipient.call.value(amount)(""); 205 | require(success, "Address: unable to send value, recipient may have reverted"); 206 | } 207 | } 208 | 209 | // Compound 210 | interface Compound { 211 | function interestRateModel() external view returns (address); 212 | function reserveFactorMantissa() external view returns (uint256); 213 | function totalBorrows() external view returns (uint256); 214 | function totalReserves() external view returns (uint256); 215 | 216 | function supplyRatePerBlock() external view returns (uint); 217 | function getCash() external view returns (uint256); 218 | } 219 | 220 | // Fulcrum 221 | interface Fulcrum { 222 | function supplyInterestRate() external view returns (uint256); 223 | function nextSupplyInterestRate(uint256 supplyAmount) external view returns (uint256); 224 | } 225 | 226 | interface DyDx { 227 | struct val { 228 | uint256 value; 229 | } 230 | 231 | struct set { 232 | uint128 borrow; 233 | uint128 supply; 234 | } 235 | 236 | function getEarningsRate() external view returns (val memory); 237 | function getMarketInterestRate(uint256 marketId) external view returns (val memory); 238 | function getMarketTotalPar(uint256 marketId) external view returns (set memory); 239 | } 240 | 241 | interface LendingPoolAddressesProvider { 242 | function getLendingPoolCore() external view returns (address); 243 | } 244 | 245 | interface LendingPoolCore { 246 | function getReserveCurrentLiquidityRate(address _reserve) 247 | external 248 | view 249 | returns ( 250 | uint256 liquidityRate 251 | ); 252 | function getReserveInterestRateStrategyAddress(address _reserve) external view returns (address); 253 | function getReserveTotalBorrows(address _reserve) external view returns (uint256); 254 | function getReserveTotalBorrowsStable(address _reserve) external view returns (uint256); 255 | function getReserveTotalBorrowsVariable(address _reserve) external view returns (uint256); 256 | function getReserveCurrentAverageStableBorrowRate(address _reserve) 257 | external 258 | view 259 | returns (uint256); 260 | function getReserveAvailableLiquidity(address _reserve) external view returns (uint256); 261 | } 262 | 263 | interface IReserveInterestRateStrategy { 264 | 265 | function getBaseVariableBorrowRate() external view returns (uint256); 266 | function calculateInterestRates( 267 | address _reserve, 268 | uint256 _utilizationRate, 269 | uint256 _totalBorrowsStable, 270 | uint256 _totalBorrowsVariable, 271 | uint256 _averageStableBorrowRate) 272 | external 273 | view 274 | returns (uint256 liquidityRate, uint256 stableBorrowRate, uint256 variableBorrowRate); 275 | } 276 | 277 | interface InterestRateModel { 278 | function getSupplyRate(uint cash, uint borrows, uint reserves, uint reserveFactorMantissa) external view returns (uint); 279 | } 280 | 281 | contract Structs { 282 | struct Asset { 283 | address lendingPool; 284 | address priceOralce; 285 | address interestModel; 286 | } 287 | } 288 | 289 | contract IDDEX is Structs { 290 | 291 | function getInterestRates(address token, uint256 extraBorrowAmount) 292 | external 293 | view 294 | returns (uint256 borrowInterestRate, uint256 supplyInterestRate); 295 | function getIndex(address token) 296 | external 297 | view 298 | returns (uint256 supplyIndex, uint256 borrowIndex); 299 | function getTotalSupply(address asset) 300 | external 301 | view 302 | returns (uint256 amount); 303 | function getTotalBorrow(address asset) 304 | external 305 | view 306 | returns (uint256 amount); 307 | function getAsset(address token) 308 | external 309 | view returns (Asset memory asset); 310 | } 311 | 312 | interface IDDEXModel { 313 | function polynomialInterestModel(uint256 borrowRatio) external view returns (uint256); 314 | } 315 | 316 | interface ILendF { 317 | function getSupplyBalance(address account, address token) 318 | external 319 | view 320 | returns (uint256); 321 | function supplyBalances(address account, address token) 322 | external 323 | view 324 | returns (uint256 principal, uint256 interestIndex); 325 | function supply(address asset, uint256 amount) external; 326 | function withdraw(address asset, uint256 amount) external; 327 | function markets(address asset) external view returns ( 328 | bool isSupported, 329 | uint256 blockNumber, 330 | address interestRateModel, 331 | uint256 totalSupply, 332 | uint256 supplyRateMantissa, 333 | uint256 supplyIndex, 334 | uint256 totalBorrows, 335 | uint256 borrowRateMantissa, 336 | uint256 borrowIndex 337 | ); 338 | } 339 | 340 | interface ILendFModel { 341 | function getSupplyRate(address asset, uint cash, uint borrows) external view returns (uint, uint); 342 | } 343 | 344 | contract APRWithPoolOracle is Ownable, Structs { 345 | using SafeMath for uint256; 346 | using Address for address; 347 | 348 | uint256 DECIMAL = 10 ** 18; 349 | 350 | address public DYDX; 351 | address public AAVE; 352 | address public DDEX; 353 | address public LENDF; 354 | 355 | uint256 public liquidationRatio; 356 | uint256 public dydxModifier; 357 | 358 | constructor() public { 359 | DYDX = address(0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e); 360 | AAVE = address(0x24a42fD28C976A61Df5D00D0599C34c4f90748c8); 361 | DDEX = address(0x241e82C79452F51fbfc89Fac6d912e021dB1a3B7); 362 | LENDF = address(0x0eEe3E3828A45f7601D5F54bF49bB01d1A9dF5ea); 363 | liquidationRatio = 50000000000000000; 364 | dydxModifier = 20; 365 | } 366 | 367 | function set_new_AAVE(address _new_AAVE) public onlyOwner { 368 | AAVE = _new_AAVE; 369 | } 370 | function set_new_DDEX(address _new_DDEX) public onlyOwner { 371 | DDEX = _new_DDEX; 372 | } 373 | function set_new_DYDX(address _new_DYDX) public onlyOwner { 374 | DYDX = _new_DYDX; 375 | } 376 | function set_new_LENDF(address _new_LENDF) public onlyOwner { 377 | LENDF = _new_LENDF; 378 | } 379 | function set_new_Ratio(uint256 _new_Ratio) public onlyOwner { 380 | liquidationRatio = _new_Ratio; 381 | } 382 | function set_new_Modifier(uint256 _new_Modifier) public onlyOwner { 383 | dydxModifier = _new_Modifier; 384 | } 385 | 386 | function getLENDFAPR(address token) public view returns (uint256) { 387 | (,,,,uint256 supplyRateMantissa,,,,) = ILendF(LENDF).markets(token); 388 | return supplyRateMantissa.mul(2102400); 389 | } 390 | 391 | function getLENDFAPRAdjusted(address token, uint256 supply) public view returns (uint256) { 392 | if (token == address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)) { 393 | return 0; 394 | } 395 | uint256 totalCash = IERC20(token).balanceOf(LENDF).add(supply); 396 | (,, address interestRateModel,,,, uint256 totalBorrows,,) = ILendF(LENDF).markets(token); 397 | if (interestRateModel == address(0)) { 398 | return 0; 399 | } 400 | (, uint256 supplyRateMantissa) = ILendFModel(interestRateModel).getSupplyRate(token, totalCash, totalBorrows); 401 | return supplyRateMantissa.mul(2102400); 402 | } 403 | 404 | function getDDEXAPR(address token) public view returns (uint256) { 405 | if (token == address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)) { 406 | token = address(0x000000000000000000000000000000000000000E); 407 | } 408 | (uint256 supplyIndex,) = IDDEX(DDEX).getIndex(token); 409 | if (supplyIndex == 0) { 410 | return 0; 411 | } 412 | (,uint256 supplyRate) = IDDEX(DDEX).getInterestRates(token, 0); 413 | return supplyRate; 414 | } 415 | 416 | function getDDEXAPRAdjusted(address token, uint256 _supply) public view returns (uint256) { 417 | if (token == address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)) { 418 | token = address(0x000000000000000000000000000000000000000E); 419 | } 420 | (uint256 supplyIndex,) = IDDEX(DDEX).getIndex(token); 421 | if (supplyIndex == 0) { 422 | return 0; 423 | } 424 | uint256 supply = IDDEX(DDEX).getTotalSupply(token).add(_supply); 425 | uint256 borrow = IDDEX(DDEX).getTotalBorrow(token); 426 | uint256 borrowRatio = borrow.mul(Decimal.one()).div(supply); 427 | address interestRateModel = IDDEX(DDEX).getAsset(token).interestModel; 428 | uint256 borrowRate = IDDEXModel(interestRateModel).polynomialInterestModel(borrowRatio); 429 | uint256 borrowInterest = Decimal.mulCeil(borrow, borrowRate); 430 | uint256 supplyInterest = Decimal.mulFloor(borrowInterest, Decimal.one().sub(liquidationRatio)); 431 | return Decimal.divFloor(supplyInterest, supply); 432 | } 433 | 434 | function getCompoundAPR(address token) public view returns (uint256) { 435 | return Compound(token).supplyRatePerBlock().mul(2102400); 436 | } 437 | 438 | function getCompoundAPRAdjusted(address token, uint256 _supply) public view returns (uint256) { 439 | Compound c = Compound(token); 440 | address model = Compound(token).interestRateModel(); 441 | if (model == address(0)) { 442 | return c.supplyRatePerBlock().mul(2102400); 443 | } 444 | InterestRateModel i = InterestRateModel(model); 445 | uint256 cashPrior = c.getCash().add(_supply); 446 | return i.getSupplyRate(cashPrior, c.totalBorrows(), c.totalReserves().add(_supply), c.reserveFactorMantissa()).mul(2102400); 447 | } 448 | 449 | function getFulcrumAPR(address token) public view returns(uint256) { 450 | return Fulcrum(token).supplyInterestRate().div(100); 451 | } 452 | 453 | function getFulcrumAPRAdjusted(address token, uint256 _supply) public view returns(uint256) { 454 | return Fulcrum(token).nextSupplyInterestRate(_supply).div(100); 455 | } 456 | 457 | function getDyDxAPR(uint256 marketId) public view returns(uint256) { 458 | uint256 rate = DyDx(DYDX).getMarketInterestRate(marketId).value; 459 | uint256 aprBorrow = rate * 31622400; 460 | uint256 borrow = DyDx(DYDX).getMarketTotalPar(marketId).borrow; 461 | uint256 supply = DyDx(DYDX).getMarketTotalPar(marketId).supply; 462 | uint256 usage = (borrow * DECIMAL) / supply; 463 | uint256 apr = (((aprBorrow * usage) / DECIMAL) * DyDx(DYDX).getEarningsRate().value) / DECIMAL; 464 | return apr; 465 | } 466 | 467 | function getDyDxAPRAdjusted(uint256 marketId, uint256 _supply) public view returns(uint256) { 468 | uint256 rate = DyDx(DYDX).getMarketInterestRate(marketId).value; 469 | // Arbitrary value to offset calculations 470 | _supply = _supply.mul(dydxModifier); 471 | uint256 aprBorrow = rate * 31622400; 472 | uint256 borrow = DyDx(DYDX).getMarketTotalPar(marketId).borrow; 473 | uint256 supply = DyDx(DYDX).getMarketTotalPar(marketId).supply; 474 | supply = supply.add(_supply); 475 | uint256 usage = (borrow * DECIMAL) / supply; 476 | uint256 apr = (((aprBorrow * usage) / DECIMAL) * DyDx(DYDX).getEarningsRate().value) / DECIMAL; 477 | return apr; 478 | } 479 | 480 | function getAaveCore() public view returns (address) { 481 | return address(LendingPoolAddressesProvider(AAVE).getLendingPoolCore()); 482 | } 483 | 484 | function getAaveAPR(address token) public view returns (uint256) { 485 | LendingPoolCore core = LendingPoolCore(LendingPoolAddressesProvider(AAVE).getLendingPoolCore()); 486 | return core.getReserveCurrentLiquidityRate(token).div(1e9); 487 | } 488 | 489 | function getAaveAPRAdjusted(address token, uint256 _supply) public view returns (uint256) { 490 | LendingPoolCore core = LendingPoolCore(LendingPoolAddressesProvider(AAVE).getLendingPoolCore()); 491 | IReserveInterestRateStrategy apr = IReserveInterestRateStrategy(core.getReserveInterestRateStrategyAddress(token)); 492 | (uint256 newLiquidityRate,,) = apr.calculateInterestRates( 493 | token, 494 | core.getReserveAvailableLiquidity(token).add(_supply), 495 | core.getReserveTotalBorrowsStable(token), 496 | core.getReserveTotalBorrowsVariable(token), 497 | core.getReserveCurrentAverageStableBorrowRate(token) 498 | ); 499 | return newLiquidityRate.div(1e9); 500 | } 501 | 502 | // incase of half-way error 503 | function inCaseTokenGetsStuck(IERC20 _TokenAddress) onlyOwner public { 504 | uint qty = _TokenAddress.balanceOf(address(this)); 505 | _TokenAddress.transfer(msg.sender, qty); 506 | } 507 | // incase of half-way error 508 | function inCaseETHGetsStuck() onlyOwner public{ 509 | (bool result, ) = msg.sender.call.value(address(this).balance)(""); 510 | require(result, "transfer of ETH failed"); 511 | } 512 | } 513 | -------------------------------------------------------------------------------- /contracts/IAPROracle.sol: -------------------------------------------------------------------------------- 1 | 2 | interface IAPROracle { 3 | function recommendDAI() external view returns (string memory); 4 | function recommendETH() external view returns (string memory); 5 | function recommendUSDC() external view returns (string memory); 6 | function getAllCompoundAPR() 7 | external 8 | view 9 | returns ( 10 | uint256 cDAI, 11 | uint256 cBAT, 12 | uint256 cETH, 13 | uint256 cREP, 14 | uint256 cSAI, 15 | uint256 cUSDC, 16 | uint256 cWBTC, 17 | uint256 cZRC 18 | ); 19 | 20 | // Compound 21 | function getCDAIAPR() external view returns (uint256); 22 | function getCBATAPR() external view returns (uint256); 23 | function getCETHAPR() external view returns (uint256); 24 | function getCREPAPR() external view returns (uint256); 25 | function getCSAIAPR() external view returns (uint256); 26 | function getCUSDCAPR() external view returns (uint256); 27 | function getCWBTCAPR() external view returns (uint256); 28 | function getCZRCAPR() external view returns (uint256); 29 | function getCompoundAPR(address token) external view returns (uint256); 30 | 31 | function getAllDyDxAPR() 32 | external 33 | view 34 | returns ( 35 | uint256 dSAI, 36 | uint256 dETH, 37 | uint256 dUSDC, 38 | uint256 dDAI 39 | ); 40 | 41 | // dYdX 42 | function getDyDxSAIAPR() external view returns (uint256); 43 | function getDyDxETHAPR() external view returns (uint256); 44 | function getDyDxUSDCAPR() external view returns (uint256); 45 | function getDyDxDAIAPR() external view returns (uint256); 46 | 47 | function getAllFulcrumAPR() 48 | external 49 | view 50 | returns ( 51 | uint256 iZRX, 52 | uint256 iREP, 53 | uint256 iKNC, 54 | uint256 iWBTC, 55 | uint256 iUSDC, 56 | uint256 iETH, 57 | uint256 iSAI, 58 | uint256 iDAI, 59 | uint256 iLINK, 60 | uint256 iSUSD 61 | ); 62 | 63 | // Fulcrum 64 | function getIZRXAPR() external view returns (uint256); 65 | function getIREPAPR() external view returns (uint256); 66 | function getIKNCAPR() external view returns (uint256); 67 | function getIWBTCAPR() external view returns (uint256); 68 | function getIUSDCAPR() external view returns (uint256); 69 | function getIETHAPR() external view returns (uint256); 70 | function getISAIAPR() external view returns (uint256); 71 | function getIDAIAPR() external view returns (uint256); 72 | function getILINKAPR() external view returns (uint256); 73 | function getISUSDAPR() external view returns (uint256); 74 | 75 | function getFulcrumAPR(address token) external view returns(uint256); 76 | 77 | function getDyDxAPR(uint256 marketId) external view returns(uint256); 78 | 79 | function getAllAaveAPR() 80 | external 81 | view 82 | returns ( 83 | uint256 aDAI, 84 | uint256 aTUSD, 85 | uint256 aUSDC, 86 | uint256 aUSDT, 87 | uint256 aSUSD, 88 | uint256 aBAT, 89 | uint256 aETH, 90 | uint256 aLINK, 91 | uint256 aKNC, 92 | uint256 aREP, 93 | uint256 aZRX, 94 | uint256 aSNX 95 | ); 96 | 97 | function getADAIAPR() external view returns (uint256); 98 | function getATUSDAPR() external view returns (uint256); 99 | function getAUSDCAPR() external view returns (uint256); 100 | function getAUSDTAPR() external view returns (uint256); 101 | function getASUSDAPR() external view returns (uint256); 102 | function getALENDAPR() external view returns (uint256); 103 | function getABATAPR() external view returns (uint256); 104 | function getAETHAPR() external view returns (uint256); 105 | function getALINKAPR() external view returns (uint256); 106 | function getAKNCAPR() external view returns (uint256); 107 | function getAREPAPR() external view returns (uint256); 108 | function getAMKRAPR() external view returns (uint256); 109 | function getAMANAAPR() external view returns (uint256); 110 | function getAZRXAPR() external view returns (uint256); 111 | function getASNXAPR() external view returns (uint256); 112 | function getAWBTCAPR() external view returns (uint256); 113 | 114 | function getAaveAPR(address token) external view returns (uint256); 115 | } 116 | -------------------------------------------------------------------------------- /contracts/IAPRWithPoolOracle.sol: -------------------------------------------------------------------------------- 1 | 2 | interface APRWithPoolOracle { 3 | function getLENDFAPR(address token) external view returns (uint256); 4 | function getLENDFAPRAdjusted(address token, uint256 _supply) external view returns (uint256); 5 | function getDDEXAPR(address token) external view returns (uint256); 6 | function getDDEXAPRAdjusted(address token, uint256 _supply) external view returns (uint256); 7 | function getCompoundAPR(address token) external view returns (uint256); 8 | function getCompoundAPRAdjusted(address token, uint256 _supply) external view returns (uint256); 9 | function getFulcrumAPR(address token) external view returns(uint256); 10 | function getFulcrumAPRAdjusted(address token, uint256 _supply) external view returns(uint256); 11 | function getDyDxAPR(uint256 marketId) external view returns(uint256); 12 | function getDyDxAPRAdjusted(uint256 marketId, uint256 _supply) external view returns(uint256); 13 | function getAaveCore() external view returns (address); 14 | function getAaveAPR(address token) external view returns (uint256); 15 | function getAaveAPRAdjusted(address token, uint256 _supply) external view returns (uint256); 16 | } 17 | -------------------------------------------------------------------------------- /contracts/Migrations.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.4.21 <0.7.0; 2 | 3 | contract Migrations { 4 | address public owner; 5 | uint public last_completed_migration; 6 | 7 | constructor() public { 8 | owner = msg.sender; 9 | } 10 | 11 | modifier restricted() { 12 | if (msg.sender == owner) _; 13 | } 14 | 15 | function setCompleted(uint completed) public restricted { 16 | last_completed_migration = completed; 17 | } 18 | 19 | function upgrade(address new_address) public restricted { 20 | Migrations upgraded = Migrations(new_address); 21 | upgraded.setCompleted(last_completed_migration); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /migrations/1_initial_migration.js: -------------------------------------------------------------------------------- 1 | const Migrations = artifacts.require("Migrations"); 2 | 3 | module.exports = function(deployer) { 4 | deployer.deploy(Migrations); 5 | }; 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "apr-oracle", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "truffle-config.js", 6 | "directories": { 7 | "test": "test" 8 | }, 9 | "scripts": { 10 | "test": "echo \"Error: no test specified\" && exit 1" 11 | }, 12 | "author": "", 13 | "license": "ISC", 14 | "dependencies": { 15 | "chai": "^4.2.0", 16 | "solc": "^0.6.1" 17 | }, 18 | "devDependencies": { 19 | "@openzeppelin/contracts": "^2.4.0", 20 | "@truffle/hdwallet-provider": "^1.0.28", 21 | "bignumber": "^1.1.0", 22 | "bignumber.js": "^9.0.0", 23 | "chai-bignumber": "^3.0.0", 24 | "ethereumjs-common": "^1.5.0", 25 | "ethereumjs-tx": "^1.3.7", 26 | "ethereumjs-util": "^5.2.0", 27 | "openzeppelin-test-helpers": "^0.5.1", 28 | "truffle-hdwallet-provider": "^1.0.17", 29 | "web3": "1.0.0-beta.33" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /truffle-config.js: -------------------------------------------------------------------------------- 1 | var HDWalletProvider = require("truffle-hdwallet-provider"); 2 | /** 3 | * Use this file to configure your truffle project. It's seeded with some 4 | * common settings for different networks and features like migrations, 5 | * compilation and testing. Uncomment the ones you need or modify 6 | * them to suit your project as necessary. 7 | * 8 | * More information about configuration can be found at: 9 | * 10 | * truffleframework.com/docs/advanced/configuration 11 | * 12 | * To deploy via Infura you'll need a wallet provider (like truffle-hdwallet-provider) 13 | * to sign your transactions before they're sent to a remote public node. Infura accounts 14 | * are available for free at: infura.io/register. 15 | * 16 | * You'll also need a mnemonic - the twelve word phrase the wallet uses to generate 17 | * public/private key pairs. If you're publishing your code to GitHub make sure you load this 18 | * phrase from a file you've .gitignored so it doesn't accidentally become public. 19 | * 20 | */ 21 | 22 | // const HDWalletProvider = require('truffle-hdwallet-provider'); 23 | // const infuraKey = "fj4jll3k....."; 24 | // 25 | // const fs = require('fs'); 26 | // const mnemonic = fs.readFileSync(".secret").toString().trim(); 27 | 28 | module.exports = { 29 | /** 30 | * Networks define how you connect to your ethereum client and let you set the 31 | * defaults web3 uses to send transactions. If you don't specify one truffle 32 | * will spin up a development blockchain for you on port 9545 when you 33 | * run `develop` or `test`. You can ask a truffle command to use a specific 34 | * network from the command line, e.g 35 | * 36 | * $ truffle test --network 37 | */ 38 | 39 | networks: { 40 | // Useful for testing. The `development` name is special - truffle uses it by default 41 | // if it's defined here and no other network is specified at the command line. 42 | // You should run a client (like ganache-cli, geth or parity) in a separate terminal 43 | // tab if you use this network and you must also set the `host`, `port` and `network_id` 44 | // options below to some value. 45 | // 46 | // development: { 47 | // host: "127.0.0.1", // Localhost (default: none) 48 | // port: 8545, // Standard Ethereum port (default: none) 49 | // network_id: "*", // Any network (default: none) 50 | // }, 51 | 52 | // Another network with more advanced options... 53 | // advanced: { 54 | // port: 8777, // Custom port 55 | // network_id: 1342, // Custom network 56 | // gas: 8500000, // Gas sent with each transaction (default: ~6700000) 57 | // gasPrice: 20000000000, // 20 gwei (in wei) (default: 100 gwei) 58 | // from:
, // Account to send txs from (default: accounts[0]) 59 | // websockets: true // Enable EventEmitter interface for web3 (default: false) 60 | // }, 61 | 62 | // Useful for deploying to a public network. 63 | // NB: It's important to wrap the provider as a function. 64 | // ropsten: { 65 | // provider: () => new HDWalletProvider(mnemonic, `https://ropsten.infura.io/v3/YOUR-PROJECT-ID`), 66 | // network_id: 3, // Ropsten's id 67 | // gas: 5500000, // Ropsten has a lower block limit than mainnet 68 | // confirmations: 2, // # of confs to wait between deployments. (default: 0) 69 | // timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50) 70 | // skipDryRun: true // Skip dry run before migrations? (default: false for public nets ) 71 | // }, 72 | 73 | // Useful for private networks 74 | // private: { 75 | // provider: () => new HDWalletProvider(mnemonic, `https://network.io`), 76 | // network_id: 2111, // This network is yours, in the cloud. 77 | // production: true // Treats this network as if it was a public net. (default: false) 78 | // } 79 | }, 80 | 81 | // Set default mocha options here, use special reporters etc. 82 | mocha: { 83 | // timeout: 100000 84 | }, 85 | 86 | // Configure your compilers 87 | compilers: { 88 | solc: { 89 | // version: "0.5.1", // Fetch exact version from solc-bin (default: truffle's version) 90 | // docker: true, // Use "0.5.1" you've installed locally with docker (default: false) 91 | // settings: { // See the solidity docs for advice about optimization and evmVersion 92 | // optimizer: { 93 | // enabled: false, 94 | // runs: 200 95 | // }, 96 | // evmVersion: "byzantium" 97 | // } 98 | } 99 | } 100 | } 101 | --------------------------------------------------------------------------------