UNPKG

@levelk/token-price-oracles

Version:

tools for creating token price data feeds and oracles that integrate with on-chain dex's

946 lines (945 loc) 135 kB
{ "contractName": "UniswapAdapter", "abi": [ { "constant": true, "inputs": [], "name": "uniswapFactory", "outputs": [ { "name": "", "type": "address" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "inputs": [ { "name": "_uniswapFactory", "type": "address" } ], "payable": false, "stateMutability": "nonpayable", "type": "constructor" }, { "constant": true, "inputs": [ { "name": "token1", "type": "address" }, { "name": "token2", "type": "address" } ], "name": "getPriceForTokenPair", "outputs": [ { "name": "price", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "token1", "type": "address" }, { "name": "token2", "type": "address" } ], "name": "tokenPairExists", "outputs": [ { "name": "", "type": "bool" } ], "payable": false, "stateMutability": "view", "type": "function" } ], "bytecode": "0x608060405234801561001057600080fd5b506040516020806108db83398101806040528101908080519060200190929190505050806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610858806100836000396000f300608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680635aaaa7951461005c5780638bdb2afa146100d3578063d6e7444d1461012a575b600080fd5b34801561006857600080fd5b506100bd600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506101a5565b6040518082815260200191505060405180910390f35b3480156100df57600080fd5b506100e8610540565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561013657600080fd5b5061018b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610565565b604051808215151515815260200191505060405180910390f35b60008060008060008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166306f2bf62886040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b15801561026957600080fd5b505af115801561027d573d6000803e3d6000fd5b505050506040513d602081101561029357600080fd5b810190808051906020019092919050505093506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166306f2bf62876040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b15801561036257600080fd5b505af1158015610376573d6000803e3d6000fd5b505050506040513d602081101561038c57600080fd5b810190808051906020019092919050505092508373ffffffffffffffffffffffffffffffffffffffff166395b68fe7670de0b6b3a76400006040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050602060405180830381600087803b15801561041657600080fd5b505af115801561042a573d6000803e3d6000fd5b505050506040513d602081101561044057600080fd5b810190808051906020019092919050505091508273ffffffffffffffffffffffffffffffffffffffff166395b68fe7670de0b6b3a76400006040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050602060405180830381600087803b1580156104ca57600080fd5b505af11580156104de573d6000803e3d6000fd5b505050506040513d60208110156104f457600080fd5b8101908080519060200190929190505050905061053481610526670de0b6b3a7640000856107c490919063ffffffff16565b61080290919063ffffffff16565b94505050505092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166306f2bf62856040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b15801561063a57600080fd5b505af115801561064e573d6000803e3d6000fd5b505050506040513d602081101561066457600080fd5b810190808051906020019092919050505073ffffffffffffffffffffffffffffffffffffffff16141580156107bc5750600073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166306f2bf62846040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b15801561076857600080fd5b505af115801561077c573d6000803e3d6000fd5b505050506040513d602081101561079257600080fd5b810190808051906020019092919050505073ffffffffffffffffffffffffffffffffffffffff1614155b905092915050565b60008060008414156107d957600091506107fb565b82840290508284828115156107ea57fe5b041415156107f757600080fd5b8091505b5092915050565b60008060008311151561081457600080fd5b828481151561081f57fe5b04905080915050929150505600a165627a7a723058209e605c6ad8ab20102a5afae2ebee91f8419e93a01201082d9084fdf0cadda8c60029", "deployedBytecode": "0x608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680635aaaa7951461005c5780638bdb2afa146100d3578063d6e7444d1461012a575b600080fd5b34801561006857600080fd5b506100bd600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506101a5565b6040518082815260200191505060405180910390f35b3480156100df57600080fd5b506100e8610540565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561013657600080fd5b5061018b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610565565b604051808215151515815260200191505060405180910390f35b60008060008060008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166306f2bf62886040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b15801561026957600080fd5b505af115801561027d573d6000803e3d6000fd5b505050506040513d602081101561029357600080fd5b810190808051906020019092919050505093506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166306f2bf62876040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b15801561036257600080fd5b505af1158015610376573d6000803e3d6000fd5b505050506040513d602081101561038c57600080fd5b810190808051906020019092919050505092508373ffffffffffffffffffffffffffffffffffffffff166395b68fe7670de0b6b3a76400006040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050602060405180830381600087803b15801561041657600080fd5b505af115801561042a573d6000803e3d6000fd5b505050506040513d602081101561044057600080fd5b810190808051906020019092919050505091508273ffffffffffffffffffffffffffffffffffffffff166395b68fe7670de0b6b3a76400006040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050602060405180830381600087803b1580156104ca57600080fd5b505af11580156104de573d6000803e3d6000fd5b505050506040513d60208110156104f457600080fd5b8101908080519060200190929190505050905061053481610526670de0b6b3a7640000856107c490919063ffffffff16565b61080290919063ffffffff16565b94505050505092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166306f2bf62856040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b15801561063a57600080fd5b505af115801561064e573d6000803e3d6000fd5b505050506040513d602081101561066457600080fd5b810190808051906020019092919050505073ffffffffffffffffffffffffffffffffffffffff16141580156107bc5750600073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166306f2bf62846040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b15801561076857600080fd5b505af115801561077c573d6000803e3d6000fd5b505050506040513d602081101561079257600080fd5b810190808051906020019092919050505073ffffffffffffffffffffffffffffffffffffffff1614155b905092915050565b60008060008414156107d957600091506107fb565b82840290508284828115156107ea57fe5b041415156107f757600080fd5b8091505b5092915050565b60008060008311151561081457600080fd5b828481151561081f57fe5b04905080915050929150505600a165627a7a723058209e605c6ad8ab20102a5afae2ebee91f8419e93a01201082d9084fdf0cadda8c60029", "sourceMap": "186:1069:6:-;;;314:103;8:9:-1;5:2;;;30:1;27;20:12;5:2;314:103:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;397:15;380:14;;:32;;;;;;;;;;;;;;;;;;314:103;186:1069;;;;;;", "deployedSourceMap": "186:1069:6:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;421:600;;8:9:-1;5:2;;;30:1;27;20:12;5:2;421:600:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;264:45;;8:9:-1;5:2;;;30:1;27;20:12;5:2;264:45:6;;;;;;;;;;;;;;;;;;;;;;;;;;;1025:228;;8:9:-1;5:2;;;30:1;27;20:12;5:2;1025:228:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;421:600;516:10;536:39;644;753:22;831;603:14;;;;;;;;;;;:26;;;630:6;603:34;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;603:34:6;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;603:34:6;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;603:34:6;;;;;;;;;;;;;;;;536:102;;711:14;;;;;;;;;;;:26;;;738:6;711:34;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;711:34:6;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;711:34:6;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;711:34:6;;;;;;;;;;;;;;;;644:102;;778:14;:38;;;817:7;778:47;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;778:47:6;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;778:47:6;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;778:47:6;;;;;;;;;;;;;;;;753:72;;856:14;:38;;;895:7;856:47;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;856:47:6;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;856:47:6;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;856:47:6;;;;;;;;;;;;;;;;831:72;;967:49;1001:14;968:27;987:7;968:14;:18;;:27;;;;:::i;:::-;967:33;;:49;;;;:::i;:::-;959:57;;421:600;;;;;;;;:::o;264:45::-;;;;;;;;;;;;;:::o;1025:228::-;1115:4;1188:1;1142:48;;:14;;;;;;;;;;;:26;;;1169:6;1142:34;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;1142:34:6;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;1142:34:6;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;1142:34:6;;;;;;;;;;;;;;;;:48;;;;:106;;;;;1246:1;1200:48;;:14;;;;;;;;;;;:26;;;1227:6;1200:34;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;1200:34:6;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;1200:34:6;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;1200:34:6;;;;;;;;;;;;;;;;:48;;;;1142:106;1129:119;;1025:228;;;;:::o;208:381:8:-;266:7;527:9;495:1;490;:6;486:35;;;513:1;506:8;;;;486:35;543:1;539;:5;527:17;;567:1;562;558;:5;;;;;;;;:10;550:19;;;;;;;;583:1;576:8;;208:381;;;;;;:::o;699:270::-;757:7;850:9;784:1;780;:5;772:14;;;;;;;;866:1;862;:5;;;;;;;;850:17;;963:1;956:8;;699:270;;;;;:::o", "source": "pragma solidity >=0.4.24;\n\nimport \"../TPSafeMath.sol\";\nimport \"./IExchangeAdapter.sol\";\nimport \"./Uniswap/UniswapExchangeInterface.sol\";\nimport \"./Uniswap/UniswapFactoryInterface.sol\";\n\ncontract UniswapAdapter is IExchangeAdapter {\n using TPSafeMath for uint;\n\n UniswapFactoryInterface public uniswapFactory;\n\n constructor(UniswapFactoryInterface _uniswapFactory) public {\n uniswapFactory = _uniswapFactory;\n }\n\n function getPriceForTokenPair(address token1, address token2)\n public\n view\n returns (uint price)\n {\n UniswapExchangeInterface token1Exchange = UniswapExchangeInterface(uniswapFactory.getExchange(token1));\n UniswapExchangeInterface token2Exchange = UniswapExchangeInterface(uniswapFactory.getExchange(token2));\n\n uint256 token1PriceEth = token1Exchange.getTokenToEthInputPrice(1 ether);\n uint256 token2PriceEth = token2Exchange.getTokenToEthInputPrice(1 ether);\n\n // calculate price in wei (price * 10 ** 18)\n price = (token1PriceEth.mul(1 ether)).div(token2PriceEth);\n }\n\n function tokenPairExists(address token1, address token2)\n public\n view\n returns (bool)\n {\n return\n uniswapFactory.getExchange(token1) != address(0) &&\n uniswapFactory.getExchange(token2) != address(0);\n }\n}\n", "sourcePath": "/Users/mfcalvanese/dev/eth/token-price-oracles/contracts/ExchangeAdapters/UniswapAdapter.sol", "ast": { "absolutePath": "/Users/mfcalvanese/dev/eth/token-price-oracles/contracts/ExchangeAdapters/UniswapAdapter.sol", "exportedSymbols": { "UniswapAdapter": [ 1129 ] }, "id": 1130, "nodeType": "SourceUnit", "nodes": [ { "id": 1026, "literals": [ "solidity", ">=", "0.4", ".24" ], "nodeType": "PragmaDirective", "src": "0:25:6" }, { "absolutePath": "/Users/mfcalvanese/dev/eth/token-price-oracles/contracts/TPSafeMath.sol", "file": "../TPSafeMath.sol", "id": 1027, "nodeType": "ImportDirective", "scope": 1130, "sourceUnit": 1261, "src": "27:27:6", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "/Users/mfcalvanese/dev/eth/token-price-oracles/contracts/ExchangeAdapters/IExchangeAdapter.sol", "file": "./IExchangeAdapter.sol", "id": 1028, "nodeType": "ImportDirective", "scope": 1130, "sourceUnit": 641, "src": "55:32:6", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "/Users/mfcalvanese/dev/eth/token-price-oracles/contracts/ExchangeAdapters/Uniswap/UniswapExchangeInterface.sol", "file": "./Uniswap/UniswapExchangeInterface.sol", "id": 1029, "nodeType": "ImportDirective", "scope": 1130, "sourceUnit": 985, "src": "88:48:6", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "/Users/mfcalvanese/dev/eth/token-price-oracles/contracts/ExchangeAdapters/Uniswap/UniswapFactoryInterface.sol", "file": "./Uniswap/UniswapFactoryInterface.sol", "id": 1030, "nodeType": "ImportDirective", "scope": 1130, "sourceUnit": 1025, "src": "137:47:6", "symbolAliases": [], "unitAlias": "" }, { "baseContracts": [ { "arguments": null, "baseName": { "contractScope": null, "id": 1031, "name": "IExchangeAdapter", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 640, "src": "213:16:6", "typeDescriptions": { "typeIdentifier": "t_contract$_IExchangeAdapter_$640", "typeString": "contract IExchangeAdapter" } }, "id": 1032, "nodeType": "InheritanceSpecifier", "src": "213:16:6" } ], "contractDependencies": [ 640 ], "contractKind": "contract", "documentation": null, "fullyImplemented": true, "id": 1129, "linearizedBaseContracts": [ 1129, 640 ], "name": "UniswapAdapter", "nodeType": "ContractDefinition", "nodes": [ { "id": 1035, "libraryName": { "contractScope": null, "id": 1033, "name": "TPSafeMath", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 1260, "src": "240:10:6", "typeDescriptions": { "typeIdentifier": "t_contract$_TPSafeMath_$1260", "typeString": "library TPSafeMath" } }, "nodeType": "UsingForDirective", "src": "234:26:6", "typeName": { "id": 1034, "name": "uint", "nodeType": "ElementaryTypeName", "src": "255:4:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } }, { "constant": false, "id": 1037, "name": "uniswapFactory", "nodeType": "VariableDeclaration", "scope": 1129, "src": "264:45:6", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_contract$_UniswapFactoryInterface_$1024", "typeString": "contract UniswapFactoryInterface" }, "typeName": { "contractScope": null, "id": 1036, "name": "UniswapFactoryInterface", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 1024, "src": "264:23:6", "typeDescriptions": { "typeIdentifier": "t_contract$_UniswapFactoryInterface_$1024", "typeString": "contract UniswapFactoryInterface" } }, "value": null, "visibility": "public" }, { "body": { "id": 1046, "nodeType": "Block", "src": "374:43:6", "statements": [ { "expression": { "argumentTypes": null, "id": 1044, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "argumentTypes": null, "id": 1042, "name": "uniswapFactory", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1037, "src": "380:14:6", "typeDescriptions": { "typeIdentifier": "t_contract$_UniswapFactoryInterface_$1024", "typeString": "contract UniswapFactoryInterface" } }, "nodeType": "Assignment", "operator": "=", "rightHandSide": { "argumentTypes": null, "id": 1043, "name": "_uniswapFactory", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1039, "src": "397:15:6", "typeDescriptions": { "typeIdentifier": "t_contract$_UniswapFactoryInterface_$1024", "typeString": "contract UniswapFactoryInterface" } }, "src": "380:32:6", "typeDescriptions": { "typeIdentifier": "t_contract$_UniswapFactoryInterface_$1024", "typeString": "contract UniswapFactoryInterface" } }, "id": 1045, "nodeType": "ExpressionStatement", "src": "380:32:6" } ] }, "documentation": null, "id": 1047, "implemented": true, "isConstructor": true, "isDeclaredConst": false, "modifiers": [], "name": "", "nodeType": "FunctionDefinition", "parameters": { "id": 1040, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 1039, "name": "_uniswapFactory", "nodeType": "VariableDeclaration", "scope": 1047, "src": "326:39:6", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_contract$_UniswapFactoryInterface_$1024", "typeString": "contract UniswapFactoryInterface" }, "typeName": { "contractScope": null, "id": 1038, "name": "UniswapFactoryInterface", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 1024, "src": "326:23:6", "typeDescriptions": { "typeIdentifier": "t_contract$_UniswapFactoryInterface_$1024", "typeString": "contract UniswapFactoryInterface" } }, "value": null, "visibility": "internal" } ], "src": "325:41:6" }, "payable": false, "returnParameters": { "id": 1041, "nodeType": "ParameterList", "parameters": [], "src": "374:0:6" }, "scope": 1129, "src": "314:103:6", "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" }, { "body": { "id": 1099, "nodeType": "Block", "src": "530:491:6", "statements": [ { "assignments": [ 1057 ], "declarations": [ { "constant": false, "id": 1057, "name": "token1Exchange", "nodeType": "VariableDeclaration", "scope": 1100, "src": "536:39:6", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_contract$_UniswapExchangeInterface_$984", "typeString": "contract UniswapExchangeInterface" }, "typeName": { "contractScope": null, "id": 1056, "name": "UniswapExchangeInterface", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 984, "src": "536:24:6", "typeDescriptions": { "typeIdentifier": "t_contract$_UniswapExchangeInterface_$984", "typeString": "contract UniswapExchangeInterface" } }, "value": null, "visibility": "internal" } ], "id": 1064, "initialValue": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 1061, "name": "token1", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1049, "src": "630:6:6", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_address", "typeString": "address" } ], "expression": { "argumentTypes": null, "id": 1059, "name": "uniswapFactory", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1037, "src": "603:14:6", "typeDescriptions": { "typeIdentifier": "t_contract$_UniswapFactoryInterface_$1024", "typeString": "contract UniswapFactoryInterface" } }, "id": 1060, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "getExchange", "nodeType": "MemberAccess", "referencedDeclaration": 1004, "src": "603:26:6", "typeDescriptions": { "typeIdentifier": "t_function_external_view$_t_address_$returns$_t_address_$", "typeString": "function (address) view external returns (address)" } }, "id": 1062, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "603:34:6", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_address", "typeString": "address" } ], "id": 1058, "name": "UniswapExchangeInterface", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 984, "src": "578:24:6", "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_UniswapExchangeInterface_$984_$", "typeString": "type(contract UniswapExchangeInterface)" } }, "id": 1063, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "578:60:6", "typeDescriptions": { "typeIdentifier": "t_contract$_UniswapExchangeInterface_$984", "typeString": "contract UniswapExchangeInterface" } }, "nodeType": "VariableDeclarationStatement", "src": "536:102:6" }, { "assignments": [ 1066 ], "declarations": [ { "constant": false, "id": 1066, "name": "token2Exchange", "nodeType": "VariableDeclaration", "scope": 1100, "src": "644:39:6", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_contract$_UniswapExchangeInterface_$984", "typeString": "contract UniswapExchangeInterface" }, "typeName": { "contractScope": null, "id": 1065, "name": "UniswapExchangeInterface", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 984, "src": "644:24:6", "typeDescriptions": { "typeIdentifier": "t_contract$_UniswapExchangeInterface_$984", "typeString": "contract UniswapExchangeInterface" } }, "value": null, "visibility": "internal" } ], "id": 1073, "initialValue": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 1070, "name": "token2", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1051, "src": "738:6:6", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_address", "typeString": "address" } ], "expression": { "argumentTypes": null, "id": 1068, "name": "uniswapFactory", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1037, "src": "711:14:6", "typeDescriptions": { "typeIdentifier": "t_contract$_UniswapFactoryInterface_$1024", "typeString": "contract UniswapFactoryInterface" } }, "id": 1069, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "getExchange", "nodeType": "MemberAccess", "referencedDeclaration": 1004, "src": "711:26:6", "typeDescriptions": { "typeIdentifier": "t_function_external_view$_t_address_$returns$_t_address_$", "typeString": "function (address) view external returns (address)" } }, "id": 1071, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "711:34:6", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_address", "typeString": "address" } ], "id": 1067, "name": "UniswapExchangeInterface", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 984, "src": "686:24:6", "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_UniswapExchangeInterface_$984_$", "typeString": "type(contract UniswapExchangeInterface)" } }, "id": 1072, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "686:60:6", "typeDescriptions": { "typeIdentifier": "t_contract$_UniswapExchangeInterface_$984", "typeString": "contract UniswapExchangeInterface" } }, "nodeType": "VariableDeclarationStatement", "src": "644:102:6" }, { "assignments": [ 1075 ], "declarations": [ { "constant": false, "id": 1075, "name": "token1PriceEth", "nodeType": "VariableDeclaration", "scope": 1100, "src": "753:22:6", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 1074, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "753:7:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" } ], "id": 1080, "initialValue": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "hexValue": "31", "id": 1078, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "817:7:6", "subdenomination": "ether", "typeDescriptions": { "typeIdentifier": "t_rational_1000000000000000000_by_1", "typeString": "int_const 1000000000000000000" }, "value": "1" } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_rational_1000000000000000000_by_1", "typeString": "int_const 1000000000000000000" } ], "expression": { "argumentTypes": null, "id": 1076, "name": "token1Exchange", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1057, "src": "778:14:6", "typeDescriptions": { "typeIdentifier": "t_contract$_UniswapExchangeInterface_$984", "typeString": "contract UniswapExchangeInterface" } }, "id": 1077, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "getTokenToEthInputPrice", "nodeType": "MemberAccess", "referencedDeclaration": 699, "src": "778:38:6", "typeDescriptions": { "typeIdentifier": "t_function_external_view$_t_uint256_$returns$_t_uint256_$", "typeString": "function (uint256) view external returns (uint256)" } }, "id": 1079, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "778:47:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "VariableDeclarationStatement", "src": "753:72:6" }, { "assignments": [ 1082 ], "declarations": [ { "constant": false, "id": 1082, "name": "token2PriceEth", "nodeType": "VariableDeclaration", "scope": 1100, "src": "831:22:6", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 1081, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "831:7:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" } ], "id": 1087, "initialValue": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "hexValue": "31", "id": 1085, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "895:7:6", "subdenomination": "ether", "typeDescriptions": { "typeIdentifier": "t_rational_1000000000000000000_by_1", "typeString": "int_const 1000000000000000000" }, "value": "1" } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_rational_1000000000000000000_by_1", "typeString": "int_const 1000000000000000000" } ], "expression": { "argumentTypes": null, "id": 1083, "name": "token2Exchange", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1066, "src": "856:14:6", "typeDescriptions": { "typeIdentifier": "t_contract$_UniswapExchangeInterface_$984", "typeString": "contract UniswapExchangeInterface" } }, "id": 1084, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "getTokenToEthInputPrice", "nodeType": "MemberAccess", "referencedDeclaration": 699, "src": "856:38:6", "typeDescriptions": { "typeIdentifier": "t_function_external_view$_t_uint256_$returns$_t_uint256_$", "typeString": "function (uint256) view external returns (uint256)" } }, "id": 1086, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "856:47:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "VariableDeclarationStatement", "src": "831:72:6" }, { "expression": { "argumentTypes": null, "id": 1097, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "argumentTypes": null, "id": 1088, "name": "price", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1054, "src": "959:5:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "Assignment", "operator": "=", "rightHandSide": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 1095, "name": "token2PriceEth", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1082, "src": "1001:14:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_uint256", "typeString": "uint256" } ], "expression": { "argumentTypes": null, "components": [ { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "hexValue": "31", "id": 1091, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "987:7:6", "subdenomination": "ether", "typeDescriptions": { "typeIdentifier": "t_rational_1000000000000000000_by_1", "typeString": "int_const 1000000000000000000" }, "value": "1" } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_rational_1000000000000000000_by_1", "typeString": "int_const 1000000000000000000" } ], "expression": { "argumentTypes": null, "id": 1089, "name": "token1PriceEth", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1075, "src": "968:14:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "id": 1090, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "mul", "nodeType": "MemberAccess", "referencedDeclaration": 1167, "src": "968:18:6", "typeDescriptions": { "typeIdentifier": "t_function_internal_pure$_t_uint256_$_t_uint256_$returns$_t_uint256_$bound_to$_t_uint256_$",