UNPKG

@gnosis.pm/pm-contracts

Version:

Collection of smart contracts for the Gnosis prediction market platform

991 lines (990 loc) 481 kB
{ "contractName": "FutarchyOracleData", "abi": [ { "constant": true, "inputs": [], "name": "LONG", "outputs": [ { "name": "", "type": "uint8" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "winningMarketIndex", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "", "type": "uint256" } ], "name": "markets", "outputs": [ { "name": "", "type": "address" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "categoricalEvent", "outputs": [ { "name": "", "type": "address" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "isSet", "outputs": [ { "name": "", "type": "bool" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "tradingPeriod", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "anonymous": false, "inputs": [ { "indexed": false, "name": "funding", "type": "uint256" } ], "name": "FutarchyFunding", "type": "event" }, { "anonymous": false, "inputs": [], "name": "FutarchyClosing", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "name": "winningMarketIndex", "type": "uint256" } ], "name": "OutcomeAssignment", "type": "event" } ], "metadata": "{\"compiler\":{\"version\":\"0.5.6+commit.b259423e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"constant\":true,\"inputs\":[],\"name\":\"LONG\",\"outputs\":[{\"name\":\"\",\"type\":\"uint8\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"winningMarketIndex\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"markets\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"categoricalEvent\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"isSet\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"tradingPeriod\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"funding\",\"type\":\"uint256\"}],\"name\":\"FutarchyFunding\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[],\"name\":\"FutarchyClosing\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"winningMarketIndex\",\"type\":\"uint256\"}],\"name\":\"OutcomeAssignment\",\"type\":\"event\"}],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/home/alan/src/github.com/gnosis/pm-contracts/contracts/Oracles/FutarchyOracle.sol\":\"FutarchyOracleData\"},\"evmVersion\":\"petersburg\",\"libraries\":{},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"/home/alan/src/github.com/gnosis/pm-contracts/contracts/Events/CategoricalEvent.sol\":{\"keccak256\":\"0x0d618ff0e76444e82eb38603d60798a2ca697ca0262ef541ed0987503ed493da\",\"urls\":[\"bzzr://a8677480e10d1c369ab348a093598f84d85a51f400d114ece3d1d5055a09267a\"]},\"/home/alan/src/github.com/gnosis/pm-contracts/contracts/Events/Event.sol\":{\"keccak256\":\"0xdcacfa25145426b5681ad7d8bafb3c117c92a37b7a0175d72a10b42f130fb8c1\",\"urls\":[\"bzzr://bd10fbdb82f0d50866442c9e95317b3176c8ee067def27d764529973fb36420a\"]},\"/home/alan/src/github.com/gnosis/pm-contracts/contracts/Events/EventFactory.sol\":{\"keccak256\":\"0xd9c190f46a1f260cb6ca7aa455444cb79f4d0e732bbaa4485e36e7b6c344739c\",\"urls\":[\"bzzr://f84bccd78e77be6288cf97d3fc0cb4808d161f75d291b89df3f2232d394082f0\"]},\"/home/alan/src/github.com/gnosis/pm-contracts/contracts/Events/ScalarEvent.sol\":{\"keccak256\":\"0xb8113f1a3f63ec0b6ae2d1a833fbffcf2b2af9470d4d7591d8e2c2784a163b32\",\"urls\":[\"bzzr://feb468d84fdda273585ba31abbbf8cceb906df5a9142695ec30c98f000a05bd4\"]},\"/home/alan/src/github.com/gnosis/pm-contracts/contracts/MarketMakers/MarketMaker.sol\":{\"keccak256\":\"0xa71f8ce92412033d0900d44c01f0702aefced87d860cf116c6a4d3efe86913cf\",\"urls\":[\"bzzr://63c5bf60b931bb032fcab23514a3db171b680b11d8c6c05ac8caa88752e3be41\"]},\"/home/alan/src/github.com/gnosis/pm-contracts/contracts/Markets/Market.sol\":{\"keccak256\":\"0x7bc1ebf0ea0f4cd9b6e9bfff6c6ac9088c253bcfca4e27f31e5845799f0278d8\",\"urls\":[\"bzzr://5e3f86d96ab269d284b34563501469d539cc436d62f070dd0abda2519d5e60c0\"]},\"/home/alan/src/github.com/gnosis/pm-contracts/contracts/Markets/StandardMarket.sol\":{\"keccak256\":\"0x527abf1b0997e2d38ce3c97f7ed647b9e913424828594287e2b068f2fb41ad4c\",\"urls\":[\"bzzr://16756e1b212fd40f21de50d99c8b7a5dde0acc2b0b047af8beead831a1274bd7\"]},\"/home/alan/src/github.com/gnosis/pm-contracts/contracts/Markets/StandardMarketWithPriceLogger.sol\":{\"keccak256\":\"0xac611de823e324e444a9749619091be1f81edfd67af6109581c2f8655251fb8e\",\"urls\":[\"bzzr://feb7902d610a1e499e0330780e0e9638d4372ad941e5d5896cb1730df791405a\"]},\"/home/alan/src/github.com/gnosis/pm-contracts/contracts/Markets/StandardMarketWithPriceLoggerFactory.sol\":{\"keccak256\":\"0x81f233b1b25619bf83726af248a65e713660eb817098af83874cd93fddc7a4c4\",\"urls\":[\"bzzr://c37407f5fdc24b6fdcc5b7fad83b99da925ee9dcf0c4da1c8f4c7a7a4afe69a2\"]},\"/home/alan/src/github.com/gnosis/pm-contracts/contracts/Oracles/FutarchyOracle.sol\":{\"keccak256\":\"0x1873d44361476b4aec9203cf43db48690eebf9c1bb91ebc1730bed8b8d4ea072\",\"urls\":[\"bzzr://f5563fc2b82e53157b49f06d61333cf3cd9f4a9e7cf60237f53549241d3b4d3a\"]},\"/home/alan/src/github.com/gnosis/pm-contracts/contracts/Oracles/Oracle.sol\":{\"keccak256\":\"0xf4d12f4a59c17e66dfa6791188f621a8914e2038a4e3f72d6fc9fb903ca8e18e\",\"urls\":[\"bzzr://a477ccd203e677cc904b1a4f8fcc85251c5b5e09c5c10eed27e01318584b16d1\"]},\"/home/alan/src/github.com/gnosis/pm-contracts/contracts/Tokens/OutcomeToken.sol\":{\"keccak256\":\"0x3d4c9ec14a60cf7577d366da5116e919a4331da8d6d993174f7d599f84ae74e0\",\"urls\":[\"bzzr://20f87450259a3af24ff1769faa9ab3b714d01921e9d8fa4efa75a0c277837a8a\"]},\"@gnosis.pm/util-contracts/contracts/Proxy.sol\":{\"keccak256\":\"0xeab0e83a9ec9e7f052c0455a11577061ec6d1994db08dae429abd6faaabf6555\",\"urls\":[\"bzzr://b2c1273d4ec30e2f9e768eea8c510f8493a7359b03e01923d93eea86b57ec145\"]},\"openzeppelin-solidity/contracts/drafts/SignedSafeMath.sol\":{\"keccak256\":\"0xb4b45cd5475c318722ac0f8d7e2b9e77fee6f4f36374c1110fe615d50fbc0650\",\"urls\":[\"bzzr://a90fb457269c8a03ec5b811c71acef08a2751a4d2019b0661328610f9357dae7\"]},\"openzeppelin-solidity/contracts/math/SafeMath.sol\":{\"keccak256\":\"0x4ccf2d7b51873db1ccfd54ca2adae5eac3b184f9699911ed4490438419f1c690\",\"urls\":[\"bzzr://1604f5b6d6e916c154efd8c6720cda069e5ba32dfa0a9dedf2b42e5b02d07f89\"]},\"openzeppelin-solidity/contracts/token/ERC20/ERC20.sol\":{\"keccak256\":\"0x852793a3c2f86d336a683b30d688ec3dcfc57451af5a2bf5975cda3b7191a901\",\"urls\":[\"bzzr://07fb42206812a17c1f71e548cfa5cec6f9aa1ae0ca5df870718ca4aa9759d1a5\"]},\"openzeppelin-solidity/contracts/token/ERC20/IERC20.sol\":{\"keccak256\":\"0x90e8c2521653bbb1768b05889c5760031e688d9cd361f167489b89215e201b95\",\"urls\":[\"bzzr://aa8b45b57edafc3d67bc5d916327ea16807fae33f753ca163ae0c4061b789766\"]}},\"version\":1}", "bytecode": "0x608060405234801561001057600080fd5b50610253806100206000396000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c8063561cce0a1461006757806356cfb75f1461008b578063b1283e77146100a9578063c3730d0314610117578063c65fb38014610161578063f86e315314610183575b600080fd5b61006f6101a1565b604051808260ff1660ff16815260200191505060405180910390f35b6100936101a6565b6040518082815260200191505060405180910390f35b6100d5600480360360208110156100bf57600080fd5b81019080803590602001909291905050506101ac565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61011f6101e8565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61016961020e565b604051808215151515815260200191505060405180910390f35b61018b610221565b6040518082815260200191505060405180910390f35b600181565b60045481565b600181815481106101b957fe5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600560009054906101000a900460ff1681565b6003548156fea165627a7a72305820d77e9fab41ebf3c371c5aec0711945c5879b9593c9c723c95252230f76d5135f0029", "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100625760003560e01c8063561cce0a1461006757806356cfb75f1461008b578063b1283e77146100a9578063c3730d0314610117578063c65fb38014610161578063f86e315314610183575b600080fd5b61006f6101a1565b604051808260ff1660ff16815260200191505060405180910390f35b6100936101a6565b6040518082815260200191505060405180910390f35b6100d5600480360360208110156100bf57600080fd5b81019080803590602001909291905050506101ac565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61011f6101e8565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61016961020e565b604051808215151515815260200191505060405180910390f35b61018b610221565b6040518082815260200191505060405180910390f35b600181565b60045481565b600181815481106101b957fe5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600560009054906101000a900460ff1681565b6003548156fea165627a7a72305820d77e9fab41ebf3c371c5aec0711945c5879b9593c9c723c95252230f76d5135f0029", "sourceMap": "213:661:18:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;213:661:18;;;;;;;", "deployedSourceMap": "213:661:18:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;213:661:18;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;436:30;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;654;;;:::i;:::-;;;;;;;;;;;;;;;;;;;525:46;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;525:46:18;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;577:40;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;690:17;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;623:25;;;:::i;:::-;;;;;;;;;;;;;;;;;;;436:30;465:1;436:30;:::o;654:::-;;;;:::o;525:46::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;577:40::-;;;;;;;;;;;;;:::o;690:17::-;;;;;;;;;;;;;:::o;623:25::-;;;;:::o", "source": "pragma solidity ^0.5.0;\nimport \"../Oracles/Oracle.sol\";\nimport \"../Events/EventFactory.sol\";\nimport \"../Markets/StandardMarketWithPriceLoggerFactory.sol\";\nimport \"@gnosis.pm/util-contracts/contracts/Proxy.sol\";\n\n\ncontract FutarchyOracleData {\n\n /*\n * Events\n */\n event FutarchyFunding(uint funding);\n event FutarchyClosing();\n event OutcomeAssignment(uint winningMarketIndex);\n\n /*\n * Constants\n */\n uint8 public constant LONG = 1;\n\n /*\n * Storage\n */\n address creator;\n StandardMarketWithPriceLogger[] public markets;\n CategoricalEvent public categoricalEvent;\n uint public tradingPeriod;\n uint public winningMarketIndex;\n bool public isSet;\n\n /*\n * Modifiers\n */\n modifier isCreator() {\n // Only creator is allowed to proceed\n require(msg.sender == creator);\n _;\n }\n}\n\ncontract FutarchyOracleProxy is Proxy, FutarchyOracleData {\n\n /// @dev Constructor creates events and markets for futarchy oracle\n /// @param _creator Oracle creator\n /// @param eventFactory Event factory contract\n /// @param collateralToken Tokens used as collateral in exchange for outcome tokens\n /// @param oracle Oracle contract used to resolve the event\n /// @param outcomeCount Number of event outcomes\n /// @param lowerBound Lower bound for event outcome\n /// @param upperBound Lower bound for event outcome\n /// @param marketFactory Market factory contract\n /// @param marketMaker Market maker contract\n /// @param fee Market fee\n /// @param _tradingPeriod Trading period before decision can be determined\n /// @param startDate Start date for price logging\n constructor(\n address proxied,\n address _creator,\n EventFactory eventFactory,\n ERC20 collateralToken,\n Oracle oracle,\n uint8 outcomeCount,\n int lowerBound,\n int upperBound,\n StandardMarketWithPriceLoggerFactory marketFactory,\n MarketMaker marketMaker,\n uint24 fee,\n uint _tradingPeriod,\n uint startDate\n )\n Proxy(proxied)\n public\n {\n // trading period is at least a second\n require(_tradingPeriod > 0);\n // Create decision event\n categoricalEvent = eventFactory.createCategoricalEvent(collateralToken, Oracle(address(this)), outcomeCount);\n // Create outcome events\n for (uint8 i = 0; i < categoricalEvent.getOutcomeCount(); i++) {\n ScalarEvent scalarEvent = eventFactory.createScalarEvent(\n categoricalEvent.outcomeTokens(i),\n oracle,\n lowerBound,\n upperBound\n );\n markets.push(marketFactory.createMarket(scalarEvent, marketMaker, fee, startDate));\n }\n creator = _creator;\n tradingPeriod = _tradingPeriod;\n }\n}\n\n/// @title Futarchy oracle contract - Allows to create an oracle based on market behaviour\n/// @author Stefan George - <stefan@gnosis.pm>\ncontract FutarchyOracle is Proxied, Oracle, FutarchyOracleData {\n using SafeMath for *;\n\n /*\n * Public functions\n */\n /// @dev Funds all markets with equal amount of funding\n /// @param funding Amount of funding\n function fund(uint funding)\n public\n isCreator\n {\n // Buy all outcomes\n require( categoricalEvent.collateralToken().transferFrom(creator, address(this), funding)\n && categoricalEvent.collateralToken().approve(address(categoricalEvent), funding));\n categoricalEvent.buyAllOutcomes(funding);\n // Fund each market with outcome tokens from categorical event\n for (uint8 i = 0; i < markets.length; i++) {\n Market market = markets[i];\n // Approve funding for market\n require(market.eventContract().collateralToken().approve(address(market), funding));\n market.fund(funding);\n }\n emit FutarchyFunding(funding);\n }\n\n /// @dev Closes market for winning outcome and redeems winnings and sends all collateral tokens to creator\n function close()\n public\n isCreator\n {\n // Winning outcome has to be set\n Market market = markets[uint(getOutcome())];\n require(categoricalEvent.isOutcomeSet() && market.eventContract().isOutcomeSet());\n // Close market and transfer all outcome tokens from winning outcome to this contract\n market.close();\n market.eventContract().redeemWinnings();\n market.withdrawFees();\n // Redeem collateral token for winning outcome tokens and transfer collateral tokens to creator\n categoricalEvent.redeemWinnings();\n require(categoricalEvent.collateralToken().transfer(creator, categoricalEvent.collateralToken().balanceOf(address(this))));\n emit FutarchyClosing();\n }\n\n /// @dev Allows to set the oracle outcome based on the market with largest long position\n function setOutcome()\n public\n {\n // Outcome is not set yet and trading period is over\n require(!isSet && markets[0].startDate() + tradingPeriod < now);\n // Find market with highest marginal price for long outcome tokens\n uint highestAvgPrice = markets[0].getAvgPrice();\n uint highestIndex = 0;\n for (uint8 i = 1; i < markets.length; i++) {\n uint avgPrice = markets[i].getAvgPrice();\n if (avgPrice > highestAvgPrice) {\n highestAvgPrice = avgPrice;\n highestIndex = i;\n }\n }\n winningMarketIndex = highestIndex;\n isSet = true;\n emit OutcomeAssignment(winningMarketIndex);\n }\n\n /// @dev Returns if winning outcome is set\n /// @return Is outcome set?\n function isOutcomeSet()\n public\n view\n returns (bool)\n {\n return isSet;\n }\n\n /// @dev Returns winning outcome\n /// @return Outcome\n function getOutcome()\n public\n view\n returns (int)\n {\n return int(winningMarketIndex);\n }\n}\n", "sourcePath": "/home/alan/src/github.com/gnosis/pm-contracts/contracts/Oracles/FutarchyOracle.sol", "ast": { "absolutePath": "/home/alan/src/github.com/gnosis/pm-contracts/contracts/Oracles/FutarchyOracle.sol", "exportedSymbols": { "FutarchyOracle": [ 4380 ], "FutarchyOracleData": [ 4023 ], "FutarchyOracleProxy": [ 4127 ] }, "id": 4381, "nodeType": "SourceUnit", "nodes": [ { "id": 3981, "literals": [ "solidity", "^", "0.5", ".0" ], "nodeType": "PragmaDirective", "src": "0:23:18" }, { "absolutePath": "/home/alan/src/github.com/gnosis/pm-contracts/contracts/Oracles/Oracle.sol", "file": "../Oracles/Oracle.sol", "id": 3982, "nodeType": "ImportDirective", "scope": 4381, "sourceUnit": 4842, "src": "24:31:18", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "/home/alan/src/github.com/gnosis/pm-contracts/contracts/Events/EventFactory.sol", "file": "../Events/EventFactory.sol", "id": 3983, "nodeType": "ImportDirective", "scope": 4381, "sourceUnit": 603, "src": "56:36:18", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "/home/alan/src/github.com/gnosis/pm-contracts/contracts/Markets/StandardMarketWithPriceLoggerFactory.sol", "file": "../Markets/StandardMarketWithPriceLoggerFactory.sol", "id": 3984, "nodeType": "ImportDirective", "scope": 4381, "sourceUnit": 3623, "src": "93:61:18", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "@gnosis.pm/util-contracts/contracts/Proxy.sol", "file": "@gnosis.pm/util-contracts/contracts/Proxy.sol", "id": 3985, "nodeType": "ImportDirective", "scope": 4381, "sourceUnit": 6829, "src": "155:55:18", "symbolAliases": [], "unitAlias": "" }, { "baseContracts": [], "contractDependencies": [], "contractKind": "contract", "documentation": null, "fullyImplemented": true, "id": 4023, "linearizedBaseContracts": [ 4023 ], "name": "FutarchyOracleData", "nodeType": "ContractDefinition", "nodes": [ { "anonymous": false, "documentation": null, "id": 3989, "name": "FutarchyFunding", "nodeType": "EventDefinition", "parameters": { "id": 3988, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 3987, "indexed": false, "name": "funding", "nodeType": "VariableDeclaration", "scope": 3989, "src": "300:12:18", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 3986, "name": "uint", "nodeType": "ElementaryTypeName", "src": "300:4:18", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" } ], "src": "299:14:18" }, "src": "278:36:18" }, { "anonymous": false, "documentation": null, "id": 3991, "name": "FutarchyClosing", "nodeType": "EventDefinition", "parameters": { "id": 3990, "nodeType": "ParameterList", "parameters": [], "src": "340:2:18" }, "src": "319:24:18" }, { "anonymous": false, "documentation": null, "id": 3995, "name": "OutcomeAssignment", "nodeType": "EventDefinition", "parameters": { "id": 3994, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 3993, "indexed": false, "name": "winningMarketIndex", "nodeType": "VariableDeclaration", "scope": 3995, "src": "372:23:18", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 3992, "name": "uint", "nodeType": "ElementaryTypeName", "src": "372:4:18", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" } ], "src": "371:25:18" }, "src": "348:49:18" }, { "constant": true, "id": 3998, "name": "LONG", "nodeType": "VariableDeclaration", "scope": 4023, "src": "436:30:18", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint8", "typeString": "uint8" }, "typeName": { "id": 3996, "name": "uint8", "nodeType": "ElementaryTypeName", "src": "436:5:18", "typeDescriptions": { "typeIdentifier": "t_uint8", "typeString": "uint8" } }, "value": { "argumentTypes": null, "hexValue": "31", "id": 3997, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "465:1:18", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_1_by_1", "typeString": "int_const 1" }, "value": "1" }, "visibility": "public" }, { "constant": false, "id": 4000, "name": "creator", "nodeType": "VariableDeclaration", "scope": 4023, "src": "504:15:18", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 3999, "name": "address", "nodeType": "ElementaryTypeName", "src": "504:7:18", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 4003, "name": "markets", "nodeType": "VariableDeclaration", "scope": 4023, "src": "525:46:18", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_array$_t_contract$_StandardMarketWithPriceLogger_$3549_$dyn_storage", "typeString": "contract StandardMarketWithPriceLogger[]" }, "typeName": { "baseType": { "contractScope": null, "id": 4001, "name": "StandardMarketWithPriceLogger", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 3549, "src": "525:29:18", "typeDescriptions": { "typeIdentifier": "t_contract$_StandardMarketWithPriceLogger_$3549", "typeString": "contract StandardMarketWithPriceLogger" } }, "id": 4002, "length": null, "nodeType": "ArrayTypeName", "src": "525:31:18", "typeDescriptions": { "typeIdentifier": "t_array$_t_contract$_StandardMarketWithPriceLogger_$3549_$dyn_storage_ptr", "typeString": "contract StandardMarketWithPriceLogger[]" } }, "value": null, "visibility": "public" }, { "constant": false, "id": 4005, "name": "categoricalEvent", "nodeType": "VariableDeclaration", "scope": 4023, "src": "577:40:18", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_contract$_CategoricalEvent_$158", "typeString": "contract CategoricalEvent" }, "typeName": { "contractScope": null, "id": 4004, "name": "CategoricalEvent", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 158, "src": "577:16:18", "typeDescriptions": { "typeIdentifier": "t_contract$_CategoricalEvent_$158", "typeString": "contract CategoricalEvent" } }, "value": null, "visibility": "public" }, { "constant": false, "id": 4007, "name": "tradingPeriod", "nodeType": "VariableDeclaration", "scope": 4023, "src": "623:25:18", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 4006, "name": "uint", "nodeType": "ElementaryTypeName", "src": "623:4:18", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "public" }, { "constant": false, "id": 4009, "name": "winningMarketIndex", "nodeType": "VariableDeclaration", "scope": 4023, "src": "654:30:18", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 4008, "name": "uint", "nodeType": "ElementaryTypeName", "src": "654:4:18", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "public" }, { "constant": false, "id": 4011, "name": "isSet", "nodeType": "VariableDeclaration", "scope": 4023, "src": "690:17:18", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" }, "typeName": { "id": 4010, "name": "bool", "nodeType": "ElementaryTypeName", "src": "690:4:18", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "value": null, "visibility": "public" }, { "body": { "id": 4021, "nodeType": "Block", "src": "768:104:18", "statements": [ { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "commonType": { "typeIdentifier": "t_address", "typeString": "address" }, "id": 4017, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "expression": { "argumentTypes": null, "id": 4014, "name": "msg", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 7920, "src": "832:3:18", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" } }, "id": 4015, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "sender", "nodeType": "MemberAccess", "referencedDeclaration": null, "src": "832:10:18", "typeDescriptions": { "typeIdentifier": "t_address_payable", "typeString": "address payable" } }, "nodeType": "BinaryOperation", "operator": "==", "rightExpression": { "argumentTypes": null, "id": 4016, "name": "creator", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4000, "src": "846:7:18", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "src": "832:21:18", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_bool", "typeString": "bool" } ], "id": 4013, "name": "require", "nodeType": "Identifier", "overloadedDeclarations": [ 7923, 7924 ], "referencedDeclaration": 7923, "src": "824:7:18", "typeDescriptions": { "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", "typeString": "function (bool) pure" } }, "id": 4018, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "824:30:18", "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } }, "id": 4019, "nodeType": "ExpressionStatement", "src": "824:30:18" }, { "id": 4020, "nodeType": "PlaceholderStatement", "src": "864:1:18" } ] }, "documentation": null, "id": 4022, "name": "isCreator", "nodeType": "ModifierDefinition", "parameters": { "id": 4012, "nodeType": "ParameterList", "parameters": [], "src": "765:2:18" }, "src": "747:125:18", "visibility": "internal" } ], "scope": 4381, "src": "213:661:18" }, { "baseContracts": [ { "arguments": null, "baseName": { "contractScope": null, "id": 4024, "name": "Proxy", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 6828, "src": "908:5:18", "typeDescriptions": { "typeIdentifier": "t_contract$_Proxy_$6828", "typeString": "contract Proxy" } }, "id": 4025, "nodeType": "InheritanceSpecifier", "src": "908:5:18" }, { "arguments": null, "baseName": { "contractScope": null, "id": 4026, "name": "FutarchyOracleData", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 4023, "src": "915:18:18", "typeDescriptions": { "typeIdentifier": "t_contract$_FutarchyOracleData_$4023", "typeString": "contract FutarchyOracleData" } }, "id": 4027, "nodeType": "InheritanceSpecifier", "src": "915:18:18" } ], "contractDependencies": [ 4023, 6798, 6828 ], "contractKind": "contract", "documentation": null, "fullyImplemented": true, "id": 4127, "linearizedBaseContracts": [ 4127, 4023, 6828, 6798 ], "name": "FutarchyOracleProxy", "nodeType": "ContractDefinition", "nodes": [ { "body": { "id": 4125, "nodeType": "Block", "src": "2127:737:18", "statements": [ { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 4062, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 4060, "name": "_tradingPeriod", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4051, "src": "2192:14:18", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": ">", "rightExpression": { "argumentTypes": null, "hexValue": "30", "id": 4061, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "2209:1:18", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" }, "src": "2192:18:18", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_bool", "typeString": "bool" } ], "id": 4059, "name": "require", "nodeType": "Identifier", "overloadedDeclarations": [ 7923, 7924 ], "referencedDeclaration": 7923, "src": "2184:7:18", "typeDescriptions": { "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", "typeString": "function (bool) pure" } }, "id": 4063, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "2184:27:18", "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } }, "id": 4064, "nodeType": "ExpressionStatement", "src": "2184:27:18" }, { "expression": { "argumentTypes": null, "id": 4076, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "argumentTypes": null, "id": 4065, "name": "categoricalEvent", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4005, "src": "2254:16:18", "typeDescriptions": { "typeIdentifier": "t_contract$_CategoricalEvent_$158", "typeString": "contract CategoricalEvent" } }, "nodeType": "Assignment", "operator": "=", "rightHandSide": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 4068, "name": "collateralToken", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4035, "src": "2309:15:18", "typeDescriptions": { "typeIdentifier": "t_contract$_ERC20_$7778", "typeString": "contract ERC20" } }, { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 4071, "name": "this", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 8022, "src": "2341:4:18", "typeDescriptions": { "typeIdentifier": "t_contract$_FutarchyOracleProxy_$4127", "typeString": "contract FutarchyOracleProxy" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_contract$_FutarchyOracleProxy_$4127", "typeString": "contract FutarchyOracleProxy" } ], "id": 4070, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "2333:7:18", "typeDescriptions": { "typeIdentifier": "t_type$_t_address_$", "typeString": "type(address)" }, "typeName": "address" }, "id": 4072, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "2333:13:18", "typeDescriptions": { "typeIdentifier": "t_address_payable", "typeString": "address payable" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_address_payable", "typeString": "address payable" } ], "id": 4069, "name": "Oracle", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4841, "src": "2326:6:18", "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_Oracle_$4841_$", "typeString": "type(contract Oracle)" } }, "id": 4073, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "2326:21:18", "typeDescriptions": { "typeIdentifier": "t_contract$_Oracle_$4841", "typeString": "contract Oracle" } }, { "argumentTypes": null, "id": 4074, "name": "outcomeCount", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4039, "src": "2349:12:18", "typeDescriptions": { "typeIdentifier": "t_uint8", "typeString": "uint8" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_contract$_ERC20_$7778", "typeString": "contract ERC20" }, { "typeIdentifier": "t_contract$_Oracle_$4841", "typeString": "contract Oracle" }, { "typeIdentifier": "t_uint8", "typeString": "uint8" } ], "expression": { "argumentTypes": null, "id": 4066, "name": "eventFactory", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4033, "src": "2273:12:18", "typeDescriptions": { "typeIdentifier": "t_contract$_EventFactory_$602", "typeString": "contract EventFactory" } }, "id": 4067, "isConstant": false, "isLValue": false, "isPure": false,