UNPKG

@gnosis.pm/pm-contracts

Version:

Collection of smart contracts for the Gnosis prediction market platform

1,070 lines 588 kB
{ "contractName": "UltimateOracleData", "abi": [ { "constant": true, "inputs": [], "name": "forwardedOracle", "outputs": [ { "name": "", "type": "address" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "frontRunnerPeriod", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "frontRunner", "outputs": [ { "name": "", "type": "int256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "totalAmount", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "", "type": "int256" } ], "name": "totalOutcomeAmounts", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "forwardedOutcomeSetTimestamp", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "frontRunnerSetTimestamp", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "forwardedOutcome", "outputs": [ { "name": "", "type": "int256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "challengeAmount", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "collateralToken", "outputs": [ { "name": "", "type": "address" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "", "type": "address" }, { "name": "", "type": "int256" } ], "name": "outcomeAmounts", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "spreadMultiplier", "outputs": [ { "name": "", "type": "uint8" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "challengePeriod", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "anonymous": false, "inputs": [ { "indexed": false, "name": "outcome", "type": "int256" } ], "name": "ForwardedOracleOutcomeAssignment", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "name": "sender", "type": "address" }, { "indexed": false, "name": "outcome", "type": "int256" } ], "name": "OutcomeChallenge", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "name": "sender", "type": "address" }, { "indexed": false, "name": "outcome", "type": "int256" }, { "indexed": false, "name": "amount", "type": "uint256" } ], "name": "OutcomeVote", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "name": "sender", "type": "address" }, { "indexed": false, "name": "amount", "type": "uint256" } ], "name": "Withdrawal", "type": "event" } ], "metadata": "{\"compiler\":{\"version\":\"0.5.6+commit.b259423e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"constant\":true,\"inputs\":[],\"name\":\"forwardedOracle\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"frontRunnerPeriod\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"frontRunner\",\"outputs\":[{\"name\":\"\",\"type\":\"int256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalAmount\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"int256\"}],\"name\":\"totalOutcomeAmounts\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"forwardedOutcomeSetTimestamp\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"frontRunnerSetTimestamp\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"forwardedOutcome\",\"outputs\":[{\"name\":\"\",\"type\":\"int256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"challengeAmount\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"collateralToken\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"},{\"name\":\"\",\"type\":\"int256\"}],\"name\":\"outcomeAmounts\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"spreadMultiplier\",\"outputs\":[{\"name\":\"\",\"type\":\"uint8\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"challengePeriod\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"outcome\",\"type\":\"int256\"}],\"name\":\"ForwardedOracleOutcomeAssignment\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"outcome\",\"type\":\"int256\"}],\"name\":\"OutcomeChallenge\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"outcome\",\"type\":\"int256\"},{\"indexed\":false,\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"OutcomeVote\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Withdrawal\",\"type\":\"event\"}],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/home/alan/src/github.com/gnosis/pm-contracts/contracts/Oracles/UltimateOracle.sol\":\"UltimateOracleData\"},\"evmVersion\":\"petersburg\",\"libraries\":{},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"/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/Oracles/UltimateOracle.sol\":{\"keccak256\":\"0x58cd0fc631023fdc5be8ca10d38d470c45b9bd6a07c55a32b1e37c5017c15c9d\",\"urls\":[\"bzzr://75b2c3baa37871dbb7604d38fc3c1a113dec600c55f7ad22a97f41675cf6c873\"]},\"@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": "0x608060405234801561001057600080fd5b50610417806100206000396000f3fe608060405234801561001057600080fd5b50600436106100cf5760003560e01c80638ef8125e1161008c578063b2016bd411610066578063b2016bd414610232578063c427af9b1461027c578063d84d2a47146102de578063f3f480d914610302576100cf565b80638ef8125e146101d8578063984a470a146101f65780639d89e7d414610214576100cf565b8063061a85c7146100d45780630853f7eb1461011e5780630f3e94381461013c5780631a39d8ef1461015a5780631ff1431114610178578063466ae314146101ba575b600080fd5b6100dc610320565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610126610345565b6040518082815260200191505060405180910390f35b61014461034b565b6040518082815260200191505060405180910390f35b610162610351565b6040518082815260200191505060405180910390f35b6101a46004803603602081101561018e57600080fd5b8101908080359060200190929190505050610357565b6040518082815260200191505060405180910390f35b6101c261036f565b6040518082815260200191505060405180910390f35b6101e0610375565b6040518082815260200191505060405180910390f35b6101fe61037b565b6040518082815260200191505060405180910390f35b61021c610381565b6040518082815260200191505060405180910390f35b61023a610387565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102c86004803603604081101561029257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506103ad565b6040518082815260200191505060405180910390f35b6102e66103d2565b604051808260ff1660ff16815260200191505060405180910390f35b61030a6103e5565b6040518082815260200191505060405180910390f35b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60045481565b60075481565b60095481565b600a6020528060005260406000206000915090505481565b60065481565b60085481565b60055481565b60035481565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600b602052816000526040600020602052806000526040600020600091509150505481565b600160149054906101000a900460ff1681565b6002548156fea165627a7a72305820258289516ff3e90aa7bd8ddaa7150057e328e2818cdc88c90fdef32f57346a1a0029", "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c80638ef8125e1161008c578063b2016bd411610066578063b2016bd414610232578063c427af9b1461027c578063d84d2a47146102de578063f3f480d914610302576100cf565b80638ef8125e146101d8578063984a470a146101f65780639d89e7d414610214576100cf565b8063061a85c7146100d45780630853f7eb1461011e5780630f3e94381461013c5780631a39d8ef1461015a5780631ff1431114610178578063466ae314146101ba575b600080fd5b6100dc610320565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610126610345565b6040518082815260200191505060405180910390f35b61014461034b565b6040518082815260200191505060405180910390f35b610162610351565b6040518082815260200191505060405180910390f35b6101a46004803603602081101561018e57600080fd5b8101908080359060200190929190505050610357565b6040518082815260200191505060405180910390f35b6101c261036f565b6040518082815260200191505060405180910390f35b6101e0610375565b6040518082815260200191505060405180910390f35b6101fe61037b565b6040518082815260200191505060405180910390f35b61021c610381565b6040518082815260200191505060405180910390f35b61023a610387565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102c86004803603604081101561029257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506103ad565b6040518082815260200191505060405180910390f35b6102e66103d2565b604051808260ff1660ff16815260200191505060405180910390f35b61030a6103e5565b6040518082815260200191505060405180910390f35b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60045481565b60075481565b60095481565b600a6020528060005260406000206000915090505481565b60065481565b60085481565b60055481565b60035481565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600b602052816000526040600020602052806000526040600020600091509150505481565b600160149054906101000a900460ff1681565b6002548156fea165627a7a72305820258289516ff3e90aa7bd8ddaa7150057e328e2818cdc88c90fdef32f57346a1a0029", "sourceMap": "306:856:25:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;306:856:25;;;;;;;", "deployedSourceMap": "306:856:25:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;306:856:25;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;657:29;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;827;;;:::i;:::-;;;;;;;;;;;;;;;;;;;942:22;;;:::i;:::-;;;;;;;;;;;;;;;;;;;1012:23;;;:::i;:::-;;;;;;;;;;;;;;;;;;;1041:48;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;1041:48:25;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;896:40;;;:::i;:::-;;;;;;;;;;;;;;;;;;;970:35;;;:::i;:::-;;;;;;;;;;;;;;;;;;;863:27;;;:::i;:::-;;;;;;;;;;;;;;;;;;;794;;;:::i;:::-;;;;;;;;;;;;;;;;;;;692:28;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;1095:64;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;1095:64:25;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;726:29;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;761:27;;;:::i;:::-;;;;;;;;;;;;;;;;;;;657:29;;;;;;;;;;;;;:::o;827:::-;;;;:::o;942:22::-;;;;:::o;1012:23::-;;;;:::o;1041:48::-;;;;;;;;;;;;;;;;;:::o;896:40::-;;;;:::o;970:35::-;;;;:::o;863:27::-;;;;:::o;794:::-;;;;:::o;692:28::-;;;;;;;;;;;;;:::o;1095:64::-;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;726:29::-;;;;;;;;;;;;;:::o;761:27::-;;;;:::o", "source": "pragma solidity ^0.5.0;\nimport \"../Oracles/Oracle.sol\";\nimport \"openzeppelin-solidity/contracts/token/ERC20/ERC20.sol\";\nimport \"openzeppelin-solidity/contracts/math/SafeMath.sol\";\nimport \"openzeppelin-solidity/contracts/drafts/SignedSafeMath.sol\";\nimport \"@gnosis.pm/util-contracts/contracts/Proxy.sol\";\n\n\ncontract UltimateOracleData {\n\n /*\n * Events\n */\n event ForwardedOracleOutcomeAssignment(int outcome);\n event OutcomeChallenge(address indexed sender, int outcome);\n event OutcomeVote(address indexed sender, int outcome, uint amount);\n event Withdrawal(address indexed sender, uint amount);\n\n /*\n * Storage\n */\n Oracle public forwardedOracle;\n ERC20 public collateralToken;\n uint8 public spreadMultiplier;\n uint public challengePeriod;\n uint public challengeAmount;\n uint public frontRunnerPeriod;\n\n int public forwardedOutcome;\n uint public forwardedOutcomeSetTimestamp;\n int public frontRunner;\n uint public frontRunnerSetTimestamp;\n\n uint public totalAmount;\n mapping (int => uint) public totalOutcomeAmounts;\n mapping (address => mapping (int => uint)) public outcomeAmounts;\n}\n\ncontract UltimateOracleProxy is Proxy, UltimateOracleData {\n\n /// @dev Constructor sets ultimate oracle properties\n /// @param _forwardedOracle Oracle address\n /// @param _collateralToken Collateral token address\n /// @param _spreadMultiplier Defines the spread as a multiple of the money bet on other outcomes\n /// @param _challengePeriod Time to challenge oracle outcome\n /// @param _challengeAmount Amount to challenge the outcome\n /// @param _frontRunnerPeriod Time to overbid the front-runner\n constructor(\n address proxied,\n Oracle _forwardedOracle,\n ERC20 _collateralToken,\n uint8 _spreadMultiplier,\n uint _challengePeriod,\n uint _challengeAmount,\n uint _frontRunnerPeriod\n )\n Proxy(proxied)\n public\n {\n // Validate inputs\n require( address(_forwardedOracle) != address(0)\n && address(_collateralToken) != address(0)\n && _spreadMultiplier >= 2\n && _challengePeriod > 0\n && _challengeAmount > 0\n && _frontRunnerPeriod > 0);\n forwardedOracle = _forwardedOracle;\n collateralToken = _collateralToken;\n spreadMultiplier = _spreadMultiplier;\n challengePeriod = _challengePeriod;\n challengeAmount = _challengeAmount;\n frontRunnerPeriod = _frontRunnerPeriod;\n }\n}\n\n/// @title Ultimate oracle contract - Allows to swap oracle result for ultimate oracle result\n/// @author Stefan George - <stefan@gnosis.pm>\ncontract UltimateOracle is Proxied, Oracle, UltimateOracleData {\n using SignedSafeMath for int;\n using SafeMath for uint;\n\n /*\n * Public functions\n */\n /// @dev Allows to set oracle outcome\n function setForwardedOutcome()\n public\n {\n // There was no challenge and the outcome was not set yet in the ultimate oracle but in the forwarded oracle\n require( !isChallenged()\n && forwardedOutcomeSetTimestamp == 0\n && forwardedOracle.isOutcomeSet());\n forwardedOutcome = forwardedOracle.getOutcome();\n forwardedOutcomeSetTimestamp = now;\n emit ForwardedOracleOutcomeAssignment(forwardedOutcome);\n }\n\n /// @dev Allows to challenge the oracle outcome\n /// @param _outcome Outcome to bid on\n function challengeOutcome(int _outcome)\n public\n {\n // There was no challenge yet or the challenge period expired\n require( !isChallenged()\n && !isChallengePeriodOver()\n && collateralToken.transferFrom(msg.sender, address(this), challengeAmount));\n outcomeAmounts[msg.sender][_outcome] = challengeAmount;\n totalOutcomeAmounts[_outcome] = challengeAmount;\n totalAmount = challengeAmount;\n frontRunner = _outcome;\n frontRunnerSetTimestamp = now;\n emit OutcomeChallenge(msg.sender, _outcome);\n }\n\n /// @dev Allows to challenge the oracle outcome\n /// @param _outcome Outcome to bid on\n /// @param amount Amount to bid\n function voteForOutcome(int _outcome, uint amount)\n public\n {\n uint maxAmount = (totalAmount - totalOutcomeAmounts[_outcome]).mul(spreadMultiplier);\n\n if (maxAmount > totalOutcomeAmounts[_outcome])\n maxAmount -= totalOutcomeAmounts[_outcome];\n else\n maxAmount = 0;\n\n if (amount > maxAmount)\n amount = maxAmount;\n // Outcome is challenged and front runner period is not over yet and tokens can be transferred\n require( isChallenged()\n && !isFrontRunnerPeriodOver()\n && collateralToken.transferFrom(msg.sender, address(this), amount));\n outcomeAmounts[msg.sender][_outcome] = outcomeAmounts[msg.sender][_outcome].add(amount);\n totalOutcomeAmounts[_outcome] = totalOutcomeAmounts[_outcome].add(amount);\n totalAmount = totalAmount.add(amount);\n if (_outcome != frontRunner && totalOutcomeAmounts[_outcome] > totalOutcomeAmounts[frontRunner])\n {\n frontRunner = _outcome;\n frontRunnerSetTimestamp = now;\n }\n emit OutcomeVote(msg.sender, _outcome, amount);\n }\n\n /// @dev Withdraws winnings for user\n /// @return Winnings\n function withdraw()\n public\n returns (uint amount)\n {\n // Outcome was challenged and ultimate outcome decided\n require(isFrontRunnerPeriodOver());\n amount = totalAmount.mul(outcomeAmounts[msg.sender][frontRunner]) / totalOutcomeAmounts[frontRunner];\n outcomeAmounts[msg.sender][frontRunner] = 0;\n // Transfer earnings to contributor\n require(collateralToken.transfer(msg.sender, amount));\n emit Withdrawal(msg.sender, amount);\n }\n\n /// @dev Checks if time to challenge the outcome is over\n /// @return Is challenge period over?\n function isChallengePeriodOver()\n public\n view\n returns (bool)\n {\n return forwardedOutcomeSetTimestamp != 0 && now.sub(forwardedOutcomeSetTimestamp) > challengePeriod;\n }\n\n /// @dev Checks if time to overbid the front runner is over\n /// @return Is front runner period over?\n function isFrontRunnerPeriodOver()\n public\n view\n returns (bool)\n {\n return frontRunnerSetTimestamp != 0 && now.sub(frontRunnerSetTimestamp) > frontRunnerPeriod;\n }\n\n /// @dev Checks if outcome was challenged\n /// @return Is challenged?\n function isChallenged()\n public\n view\n returns (bool)\n {\n return frontRunnerSetTimestamp != 0;\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 isChallengePeriodOver() && !isChallenged()\n || isFrontRunnerPeriodOver();\n }\n\n /// @dev Returns winning outcome\n /// @return Outcome\n function getOutcome()\n public\n view\n returns (int)\n {\n if (isFrontRunnerPeriodOver())\n return frontRunner;\n return forwardedOutcome;\n }\n}\n", "sourcePath": "/home/alan/src/github.com/gnosis/pm-contracts/contracts/Oracles/UltimateOracle.sol", "ast": { "absolutePath": "/home/alan/src/github.com/gnosis/pm-contracts/contracts/Oracles/UltimateOracle.sol", "exportedSymbols": { "UltimateOracle": [ 5603 ], "UltimateOracleData": [ 5165 ], "UltimateOracleProxy": [ 5249 ] }, "id": 5604, "nodeType": "SourceUnit", "nodes": [ { "id": 5103, "literals": [ "solidity", "^", "0.5", ".0" ], "nodeType": "PragmaDirective", "src": "0:23:25" }, { "absolutePath": "/home/alan/src/github.com/gnosis/pm-contracts/contracts/Oracles/Oracle.sol", "file": "../Oracles/Oracle.sol", "id": 5104, "nodeType": "ImportDirective", "scope": 5604, "sourceUnit": 4842, "src": "24:31:25", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol", "file": "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol", "id": 5105, "nodeType": "ImportDirective", "scope": 5604, "sourceUnit": 7779, "src": "56:63:25", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "openzeppelin-solidity/contracts/math/SafeMath.sol", "file": "openzeppelin-solidity/contracts/math/SafeMath.sol", "id": 5106, "nodeType": "ImportDirective", "scope": 5604, "sourceUnit": 7382, "src": "120:59:25", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "openzeppelin-solidity/contracts/drafts/SignedSafeMath.sol", "file": "openzeppelin-solidity/contracts/drafts/SignedSafeMath.sol", "id": 5107, "nodeType": "ImportDirective", "scope": 5604, "sourceUnit": 7249, "src": "180:67:25", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "@gnosis.pm/util-contracts/contracts/Proxy.sol", "file": "@gnosis.pm/util-contracts/contracts/Proxy.sol", "id": 5108, "nodeType": "ImportDirective", "scope": 5604, "sourceUnit": 6829, "src": "248:55:25", "symbolAliases": [], "unitAlias": "" }, { "baseContracts": [], "contractDependencies": [], "contractKind": "contract", "documentation": null, "fullyImplemented": true, "id": 5165, "linearizedBaseContracts": [ 5165 ], "name": "UltimateOracleData", "nodeType": "ContractDefinition", "nodes": [ { "anonymous": false, "documentation": null, "id": 5112, "name": "ForwardedOracleOutcomeAssignment", "nodeType": "EventDefinition", "parameters": { "id": 5111, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 5110, "indexed": false, "name": "outcome", "nodeType": "VariableDeclaration", "scope": 5112, "src": "410:11:25", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_int256", "typeString": "int256" }, "typeName": { "id": 5109, "name": "int", "nodeType": "ElementaryTypeName", "src": "410:3:25", "typeDescriptions": { "typeIdentifier": "t_int256", "typeString": "int256" } }, "value": null, "visibility": "internal" } ], "src": "409:13:25" }, "src": "371:52:25" }, { "anonymous": false, "documentation": null, "id": 5118, "name": "OutcomeChallenge", "nodeType": "EventDefinition", "parameters": { "id": 5117, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 5114, "indexed": true, "name": "sender", "nodeType": "VariableDeclaration", "scope": 5118, "src": "451:22:25", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 5113, "name": "address", "nodeType": "ElementaryTypeName", "src": "451:7:25", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 5116, "indexed": false, "name": "outcome", "nodeType": "VariableDeclaration", "scope": 5118, "src": "475:11:25", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_int256", "typeString": "int256" }, "typeName": { "id": 5115, "name": "int", "nodeType": "ElementaryTypeName", "src": "475:3:25", "typeDescriptions": { "typeIdentifier": "t_int256", "typeString": "int256" } }, "value": null, "visibility": "internal" } ], "src": "450:37:25" }, "src": "428:60:25" }, { "anonymous": false, "documentation": null, "id": 5126, "name": "OutcomeVote", "nodeType": "EventDefinition", "parameters": { "id": 5125, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 5120, "indexed": true, "name": "sender", "nodeType": "VariableDeclaration", "scope": 5126, "src": "511:22:25", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 5119, "name": "address", "nodeType": "ElementaryTypeName", "src": "511:7:25", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 5122, "indexed": false, "name": "outcome", "nodeType": "VariableDeclaration", "scope": 5126, "src": "535:11:25", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_int256", "typeString": "int256" }, "typeName": { "id": 5121, "name": "int", "nodeType": "ElementaryTypeName", "src": "535:3:25", "typeDescriptions": { "typeIdentifier": "t_int256", "typeString": "int256" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 5124, "indexed": false, "name": "amount", "nodeType": "VariableDeclaration", "scope": 5126, "src": "548:11:25", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 5123, "name": "uint", "nodeType": "ElementaryTypeName", "src": "548:4:25", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" } ], "src": "510:50:25" }, "src": "493:68:25" }, { "anonymous": false, "documentation": null, "id": 5132, "name": "Withdrawal", "nodeType": "EventDefinition", "parameters": { "id": 5131, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 5128, "indexed": true, "name": "sender", "nodeType": "VariableDeclaration", "scope": 5132, "src": "583:22:25", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 5127, "name": "address", "nodeType": "ElementaryTypeName", "src": "583:7:25", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 5130, "indexed": false, "name": "amount", "nodeType": "VariableDeclaration", "scope": 5132, "src": "607:11:25", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 5129, "name": "uint", "nodeType": "ElementaryTypeName", "src": "607:4:25", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" } ], "src": "582:37:25" }, "src": "566:54:25" }, { "constant": false, "id": 5134, "name": "forwardedOracle", "nodeType": "VariableDeclaration", "scope": 5165, "src": "657:29:25", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_contract$_Oracle_$4841", "typeString": "contract Oracle" }, "typeName": { "contractScope": null, "id": 5133, "name": "Oracle", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 4841, "src": "657:6:25", "typeDescriptions": { "typeIdentifier": "t_contract$_Oracle_$4841", "typeString": "contract Oracle" } }, "value": null, "visibility": "public" }, { "constant": false, "id": 5136, "name": "collateralToken", "nodeType": "VariableDeclaration", "scope": 5165, "src": "692:28:25", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_contract$_ERC20_$7778", "typeString": "contract ERC20" }, "typeName": { "contractScope": null, "id": 5135, "name": "ERC20", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 7778, "src": "692:5:25", "typeDescriptions": { "typeIdentifier": "t_contract$_ERC20_$7778", "typeString": "contract ERC20" } }, "value": null, "visibility": "public" }, { "constant": false, "id": 5138, "name": "spreadMultiplier", "nodeType": "VariableDeclaration", "scope": 5165, "src": "726:29:25", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint8", "typeString": "uint8" }, "typeName": { "id": 5137, "name": "uint8", "nodeType": "ElementaryTypeName", "src": "726:5:25", "typeDescriptions": { "typeIdentifier": "t_uint8", "typeString": "uint8" } }, "value": null, "visibility": "public" }, { "constant": false, "id": 5140, "name": "challengePeriod", "nodeType": "VariableDeclaration", "scope": 5165, "src": "761:27:25", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 5139, "name": "uint", "nodeType": "ElementaryTypeName", "src": "761:4:25", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "public" }, { "constant": false, "id": 5142, "name": "challengeAmount", "nodeType": "VariableDeclaration", "scope": 5165, "src": "794:27:25", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 5141, "name": "uint", "nodeType": "ElementaryTypeName", "src": "794:4:25", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "public" }, { "constant": false, "id": 5144, "name": "frontRunnerPeriod", "nodeType": "VariableDeclaration", "scope": 5165, "src": "827:29:25", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 5143, "name": "uint", "nodeType": "ElementaryTypeName", "src": "827:4:25", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "public" }, { "constant": false, "id": 5146, "name": "forwardedOutcome", "nodeType": "VariableDeclaration", "scope": 5165, "src": "863:27:25", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_int256", "typeString": "int256" }, "typeName": { "id": 5145, "name": "int", "nodeType": "ElementaryTypeName", "src": "863:3:25", "typeDescriptions": { "typeIdentifier": "t_int256", "typeString": "int256" } }, "value": null, "visibility": "public" }, { "constant": false, "id": 5148, "name": "forwardedOutcomeSetTimestamp", "nodeType": "VariableDeclaration", "scope": 5165, "src": "896:40:25", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 5147, "name": "uint", "nodeType": "ElementaryTypeName", "src": "896:4:25", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "public" }, { "constant": false, "id": 5150, "name": "frontRunner", "nodeType": "VariableDeclaration", "scope": 5165, "src": "942:22:25", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_int256", "typeString": "int256" }, "typeName": { "id": 5149, "name": "int", "nodeType": "ElementaryTypeName", "src": "942:3:25", "typeDescriptions": { "typeIdentifier": "t_int256", "typeString": "int256" } }, "value": null, "visibility": "public" }, { "constant": false, "id": 5152, "name": "frontRunnerSetTimestamp", "nodeType": "VariableDeclaration", "scope": 5165, "src": "970:35:25", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 5151, "name": "uint", "nodeType": "ElementaryTypeName", "src": "970:4:25", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "public" }, { "constant": false, "id": 5154, "name": "totalAmount", "nodeType": "VariableDeclaration", "scope": 5165, "src": "1012:23:25", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 5153, "name": "uint", "nodeType": "ElementaryTypeName", "src": "1012:4:25", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "public" }, { "constant": false, "id": 5158, "name": "totalOutcomeAmounts", "nodeType": "VariableDeclaration", "scope": 5165, "src": "1041:48:25", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_int256_$_t_uint256_$", "typeString": "mapping(int256 => uint256)" }, "typeName": { "id": 5157, "keyType": { "id": 5155, "name": "int", "nodeType": "ElementaryTypeName", "src": "1050:3:25", "typeDescriptions": { "typeIdentifier": "t_int256", "typeString": "int256" } }, "nodeType": "Mapping", "src": "1041:21:25", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_int256_$_t_uint256_$", "typeString": "mapping(int256 => uint256)" }, "valueType": { "id": 5156, "name": "uint", "nodeType": "ElementaryTypeName", "src": "1057:4:25", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } }, "value": null, "visibility": "public" }, { "constant": false, "id": 5164, "name": "outcomeAmounts", "nodeType": "VariableDeclaration", "scope": 5165, "src": "1095:64:25", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_address_$_t_mapping$_t_int256_$_t_uint256_$_$", "typeString": "mapping(address => mapping(int256 => uint256))" }, "typeName": { "id": 5163, "keyType": { "id": 5159, "name": "address", "nodeType": "ElementaryTypeName", "src": "1104:7:25", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "nodeType": "Mapping", "src": "1095:42:25", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_address_$_t_mapping$_t_int256_$_t_uint256_$_$", "typeString": "mapping(address => mapping(int256 => uint256))" }, "valueType": { "id": 5162, "keyType": { "id": 5160, "name": "int", "nodeType": "ElementaryTypeName", "src": "1124:3:25", "typeDescriptions": { "typeIdentifier": "t_int256", "typeString": "int256" } }, "nodeType": "Mapping", "src": "1115:21:25", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_int256_$_t_uint256_$", "typeString": "mapping(int256 => uint256)" }, "valueType": { "id": 5161, "name": "uint", "nodeType": "ElementaryTypeName", "src": "1131:4:25", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } } }, "value": null, "visibility": "public" } ], "scope": 5604, "src": "306:856:25" }, { "baseContracts": [ { "arguments": null, "baseName": { "contractScope": null, "id": 5166, "name": "Proxy", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 6828, "src": "1196:5:25", "typeDescriptions": { "typeIdentifier": "t_contract$_Proxy_$6828", "typeString": "contract Proxy" } }, "id": 5167, "nodeType": "InheritanceSpecifier",