UNPKG

@gnosis.pm/pm-contracts

Version:

Collection of smart contracts for the Gnosis prediction market platform

842 lines (841 loc) 492 kB
{ "contractName": "FutarchyOracleProxy", "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": "masterCopy", "outputs": [ { "name": "", "type": "address" } ], "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" }, { "inputs": [ { "name": "proxied", "type": "address" }, { "name": "_creator", "type": "address" }, { "name": "eventFactory", "type": "address" }, { "name": "collateralToken", "type": "address" }, { "name": "oracle", "type": "address" }, { "name": "outcomeCount", "type": "uint8" }, { "name": "lowerBound", "type": "int256" }, { "name": "upperBound", "type": "int256" }, { "name": "marketFactory", "type": "address" }, { "name": "marketMaker", "type": "address" }, { "name": "fee", "type": "uint24" }, { "name": "_tradingPeriod", "type": "uint256" }, { "name": "startDate", "type": "uint256" } ], "payable": false, "stateMutability": "nonpayable", "type": "constructor" }, { "payable": true, "stateMutability": "payable", "type": "fallback" }, { "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\":\"masterCopy\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"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\"},{\"inputs\":[{\"name\":\"proxied\",\"type\":\"address\"},{\"name\":\"_creator\",\"type\":\"address\"},{\"name\":\"eventFactory\",\"type\":\"address\"},{\"name\":\"collateralToken\",\"type\":\"address\"},{\"name\":\"oracle\",\"type\":\"address\"},{\"name\":\"outcomeCount\",\"type\":\"uint8\"},{\"name\":\"lowerBound\",\"type\":\"int256\"},{\"name\":\"upperBound\",\"type\":\"int256\"},{\"name\":\"marketFactory\",\"type\":\"address\"},{\"name\":\"marketMaker\",\"type\":\"address\"},{\"name\":\"fee\",\"type\":\"uint24\"},{\"name\":\"_tradingPeriod\",\"type\":\"uint256\"},{\"name\":\"startDate\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"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\":{\"constructor\":{\"details\":\"Constructor creates events and markets for futarchy oracle\",\"params\":{\"_creator\":\"Oracle creator\",\"_tradingPeriod\":\"Trading period before decision can be determined\",\"collateralToken\":\"Tokens used as collateral in exchange for outcome tokens\",\"eventFactory\":\"Event factory contract\",\"fee\":\"Market fee\",\"lowerBound\":\"Lower bound for event outcome\",\"marketFactory\":\"Market factory contract\",\"marketMaker\":\"Market maker contract\",\"oracle\":\"Oracle contract used to resolve the event\",\"outcomeCount\":\"Number of event outcomes\",\"startDate\":\"Start date for price logging\",\"upperBound\":\"Lower bound for event outcome\"}}}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/home/alan/src/github.com/gnosis/pm-contracts/contracts/Oracles/FutarchyOracle.sol\":\"FutarchyOracleProxy\"},\"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": "0x608060405234801561001057600080fd5b506040516101a080610a3c83398101806040526101a081101561003257600080fd5b81019080805190602001909291908051906020019092919080519060200190929190805190602001909291908051906020019092919080519060200190929190805190602001909291908051906020019092919080519060200190929190805190602001909291908051906020019092919080519060200190929190805190602001909291905050508c600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100f657600080fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550506000821161014457600080fd5b8a73ffffffffffffffffffffffffffffffffffffffff16639df0c1768b308b6040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018260ff1660ff1681526020019350505050602060405180830381600087803b15801561020557600080fd5b505af1158015610219573d6000803e3d6000fd5b505050506040513d602081101561022f57600080fd5b8101908080519060200190929190505050600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008090505b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16637dc8f0866040518163ffffffff1660e01b815260040160206040518083038186803b1580156102ee57600080fd5b505afa158015610302573d6000803e3d6000fd5b505050506040513d602081101561031857600080fd5b810190808051906020019092919050505060ff168160ff1610156106635760008c73ffffffffffffffffffffffffffffffffffffffff16635ea194a3600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638abe59ea856040518263ffffffff1660e01b8152600401808260ff16815260200191505060206040518083038186803b1580156103ca57600080fd5b505afa1580156103de573d6000803e3d6000fd5b505050506040513d60208110156103f457600080fd5b81019080805190602001909291905050508d8c8c6040518563ffffffff1660e01b8152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828152602001945050505050602060405180830381600087803b1580156104ab57600080fd5b505af11580156104bf573d6000803e3d6000fd5b505050506040513d60208110156104d557600080fd5b8101908080519060200190929190505050905060028773ffffffffffffffffffffffffffffffffffffffff16638e44df53838989886040518563ffffffff1660e01b8152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018362ffffff1662ffffff168152602001828152602001945050505050602060405180830381600087803b1580156105b757600080fd5b505af11580156105cb573d6000803e3d6000fd5b505050506040513d60208110156105e157600080fd5b810190808051906020019092919050505090806001815401808255809150509060018203906000526020600020016000909192909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050508080600101915050610286565b508b600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508160048190555050505050505050505050505050610374806106c86000396000f3fe6080604052600436106100705760003560e01c8063b1283e771161004e578063b1283e7714610171578063c3730d03146101ec578063c65fb38014610243578063f86e31531461027257610070565b8063561cce0a146100be57806356cfb75f146100ef578063a619486e1461011a575b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050366000803760008036600084600019f43d6000803e80600081146100b9573d6000f35b3d6000fd5b3480156100ca57600080fd5b506100d361029d565b604051808260ff1660ff16815260200191505060405180910390f35b3480156100fb57600080fd5b506101046102a2565b6040518082815260200191505060405180910390f35b34801561012657600080fd5b5061012f6102a8565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561017d57600080fd5b506101aa6004803603602081101561019457600080fd5b81019080803590602001909291905050506102cd565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156101f857600080fd5b50610201610309565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561024f57600080fd5b5061025861032f565b604051808215151515815260200191505060405180910390f35b34801561027e57600080fd5b50610287610342565b6040518082815260200191505060405180910390f35b600181565b60055481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600281815481106102da57fe5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600660009054906101000a900460ff1681565b6004548156fea165627a7a72305820e72d49ac417234af3f2eb3049a61a1d340e545656857db604411626b9bf0643a0029", "deployedBytecode": "0x6080604052600436106100705760003560e01c8063b1283e771161004e578063b1283e7714610171578063c3730d03146101ec578063c65fb38014610243578063f86e31531461027257610070565b8063561cce0a146100be57806356cfb75f146100ef578063a619486e1461011a575b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050366000803760008036600084600019f43d6000803e80600081146100b9573d6000f35b3d6000fd5b3480156100ca57600080fd5b506100d361029d565b604051808260ff1660ff16815260200191505060405180910390f35b3480156100fb57600080fd5b506101046102a2565b6040518082815260200191505060405180910390f35b34801561012657600080fd5b5061012f6102a8565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561017d57600080fd5b506101aa6004803603602081101561019457600080fd5b81019080803590602001909291905050506102cd565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156101f857600080fd5b50610201610309565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561024f57600080fd5b5061025861032f565b604051808215151515815260200191505060405180910390f35b34801561027e57600080fd5b50610287610342565b6040518082815260200191505060405180910390f35b600181565b60055481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600281815481106102da57fe5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600660009054906101000a900460ff1681565b6004548156fea165627a7a72305820e72d49ac417234af3f2eb3049a61a1d340e545656857db604411626b9bf0643a0029", "sourceMap": "876:1990:18:-;;;1685:1179;8:9:-1;5:2;;;30:1;27;20:12;5:2;1685:1179:18;;;;;;;;;;;;;13:3:-1;8;5:12;2:2;;;30:1;27;20:12;2:2;1685:1179:18;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2099:7;644:1:29;621:25;;:11;:25;;;;613:34;;;;;;670:11;657:10;;:24;;;;;;;;;;;;;;;;;;551:137;2209:1:18;2192:14;:18;2184:27;;;;;;2273:12;:35;;;2309:15;2341:4;2349:12;2273:89;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;2273:89:18;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;2273:89:18;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;2273:89:18;;;;;;;;;;;;;;;;2254:16;;:108;;;;;;;;;;;;;;;;;;2410:7;2420:1;2410:11;;2405:385;2427:16;;;;;;;;;;;:32;;;:34;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;2427:34:18;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;2427:34:18;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;2427:34:18;;;;;;;;;;;;;;;;2423:38;;:1;:38;;;2405:385;;;2482:23;2508:12;:30;;;2556:16;;;;;;;;;;;:30;;;2587:1;2556:33;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;2556:33:18;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;2556:33:18;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;2556:33:18;;;;;;;;;;;;;;;;2607:6;2631:10;2659;2508:175;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;2508:175:18;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;2508:175:18;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;2508:175:18;;;;;;;;;;;;;;;;2482:201;;2697:7;2710:13;:26;;;2737:11;2750;2763:3;2768:9;2710:68;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;2710:68:18;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;2710:68:18;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;2710:68:18;;;;;;;;;;;;;;;;2697:82;;39:1:-1;33:3;27:10;23:18;57:10;52:3;45:23;79:10;72:17;;0:93;2697:82:18;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2405:385;2463:3;;;;;;;2405:385;;;;2809:8;2799:7;;:18;;;;;;;;;;;;;;;;;;2843:14;2827:13;:30;;;;1685:1179;;;;;;;;;;;;;876:1990;;;;;;", "deployedSourceMap": "876:1990:18:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;848:19:29;870:10;;;;;;;;;;;848:32;;932:14;929:1;926;913:34;1031:1;1028;1012:14;1009:1;996:11;992:1;988:6;975:58;1067:16;1064:1;1061;1046:38;1104:7;1129:1;1124:38;;;;1195:16;1192:1;1185:27;1124:38;1143:16;1140:1;1133:27;436:30:18;;8:9:-1;5:2;;;30:1;27;20:12;5:2;436:30:18;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;654;;8:9:-1;5:2;;;30:1;27;20:12;5:2;654:30:18;;;:::i;:::-;;;;;;;;;;;;;;;;;;;205:25:29;;8:9:-1;5:2;;;30:1;27;20:12;5:2;205:25:29;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;525:46:18;;8:9:-1;5:2;;;30:1;27;20:12;5:2;525:46:18;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;525:46:18;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;577:40;;8:9:-1;5:2;;;30:1;27;20:12;5:2;577:40:18;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;690:17;;8:9:-1;5:2;;;30:1;27;20:12;5:2;690:17:18;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;623:25;;8:9:-1;5:2;;;30:1;27;20:12;5:2;623:25:18;;;:::i;:::-;;;;;;;;;;;;;;;;;;;436:30;465:1;436:30;:::o;654:::-;;;;:::o;205:25:29:-;;;;;;;;;;;;;:::o;525:46:18:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::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,