UNPKG

@gnosis.pm/pm-contracts

Version:

Collection of smart contracts for the Gnosis prediction market platform

454 lines 615 kB
{ "contractName": "UltimateOracle", "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": "masterCopy", "outputs": [ { "name": "", "type": "address" } ], "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" }, { "constant": false, "inputs": [], "name": "setForwardedOutcome", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "_outcome", "type": "int256" } ], "name": "challengeOutcome", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "_outcome", "type": "int256" }, { "name": "amount", "type": "uint256" } ], "name": "voteForOutcome", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [], "name": "withdraw", "outputs": [ { "name": "amount", "type": "uint256" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [], "name": "isChallengePeriodOver", "outputs": [ { "name": "", "type": "bool" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "isFrontRunnerPeriodOver", "outputs": [ { "name": "", "type": "bool" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "isChallenged", "outputs": [ { "name": "", "type": "bool" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "isOutcomeSet", "outputs": [ { "name": "", "type": "bool" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "getOutcome", "outputs": [ { "name": "", "type": "int256" } ], "payable": false, "stateMutability": "view", "type": "function" } ], "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\":\"isFrontRunnerPeriodOver\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"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\":false,\"inputs\":[],\"name\":\"withdraw\",\"outputs\":[{\"name\":\"amount\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"forwardedOutcomeSetTimestamp\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"isChallengePeriodOver\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"setForwardedOutcome\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getOutcome\",\"outputs\":[{\"name\":\"\",\"type\":\"int256\"}],\"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\":\"isChallenged\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_outcome\",\"type\":\"int256\"}],\"name\":\"challengeOutcome\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"masterCopy\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"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\":\"isOutcomeSet\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"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\"},{\"constant\":false,\"inputs\":[{\"name\":\"_outcome\",\"type\":\"int256\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"voteForOutcome\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"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\":{\"author\":\"Stefan George - <stefan@gnosis.pm>\",\"methods\":{\"challengeOutcome(int256)\":{\"details\":\"Allows to challenge the oracle outcome\",\"params\":{\"_outcome\":\"Outcome to bid on\"}},\"getOutcome()\":{\"details\":\"Returns winning outcome\",\"return\":\"Outcome\"},\"isChallengePeriodOver()\":{\"details\":\"Checks if time to challenge the outcome is over\",\"return\":\"Is challenge period over?\"},\"isChallenged()\":{\"details\":\"Checks if outcome was challenged\",\"return\":\"Is challenged?\"},\"isFrontRunnerPeriodOver()\":{\"details\":\"Checks if time to overbid the front runner is over\",\"return\":\"Is front runner period over?\"},\"isOutcomeSet()\":{\"details\":\"Returns if winning outcome is set\",\"return\":\"Is outcome set?\"},\"setForwardedOutcome()\":{\"details\":\"Allows to set oracle outcome\"},\"voteForOutcome(int256,uint256)\":{\"details\":\"Allows to challenge the oracle outcome\",\"params\":{\"_outcome\":\"Outcome to bid on\",\"amount\":\"Amount to bid\"}},\"withdraw()\":{\"details\":\"Withdraws winnings for user\",\"return\":\"Winnings\"}},\"title\":\"Ultimate oracle contract - Allows to swap oracle result for ultimate oracle result\"},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/home/alan/src/github.com/gnosis/pm-contracts/contracts/Oracles/UltimateOracle.sol\":\"UltimateOracle\"},\"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": "0x608060405234801561001057600080fd5b50611231806100206000396000f3fe608060405234801561001057600080fd5b506004361061014d5760003560e01c80638ef8125e116100c3578063b2016bd41161007c578063b2016bd4146103d4578063c427af9b1461041e578063ccdf68f314610480578063d84d2a47146104a2578063f3f480d9146104c6578063f7553098146104e45761014d565b80638ef8125e146102e0578063984a470a146102fe5780639d89e7d41461031c5780639df4d0fe1461033a5780639f0de4901461035c578063a619486e1461038a5761014d565b80631ff14311116101155780631ff14311146102185780633ccfd60b1461025a578063466ae3141461027857806372b8de1414610296578063739b8c48146102b85780637e7e4b47146102c25761014d565b8063061a85c7146101525780630853f7eb1461019c5780630f3e9438146101ba5780631a39d8ef146101d85780631a4f5b67146101f6575b600080fd5b61015a61051c565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6101a4610542565b6040518082815260200191505060405180910390f35b6101c2610548565b6040518082815260200191505060405180910390f35b6101e061054e565b6040518082815260200191505060405180910390f35b6101fe610554565b604051808215151515815260200191505060405180910390f35b6102446004803603602081101561022e57600080fd5b8101908080359060200190929190505050610582565b6040518082815260200191505060405180910390f35b61026261059a565b6040518082815260200191505060405180910390f35b6102806107ca565b6040518082815260200191505060405180910390f35b61029e6107d0565b604051808215151515815260200191505060405180910390f35b6102c06107fe565b005b6102ca6109b4565b6040518082815260200191505060405180910390f35b6102e86109d6565b6040518082815260200191505060405180910390f35b6103066109dc565b6040518082815260200191505060405180910390f35b6103246109e2565b6040518082815260200191505060405180910390f35b6103426109e8565b604051808215151515815260200191505060405180910390f35b6103886004803603602081101561037257600080fd5b81019080803590602001909291905050506109f5565b005b610392610c13565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103dc610c38565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61046a6004803603604081101561043457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c5e565b6040518082815260200191505060405180910390f35b610488610c83565b604051808215151515815260200191505060405180910390f35b6104aa610cb2565b604051808260ff1660ff16815260200191505060405180910390f35b6104ce610cc5565b6040518082815260200191505060405180910390f35b61051a600480360360408110156104fa57600080fd5b810190808035906020019092919080359060200190929190505050610ccb565b005b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60055481565b60085481565b600a5481565b6000806009541415801561057d575060055461057b6009544261104d90919063ffffffff16565b115b905090565b600b6020528060005260406000206000915090505481565b60006105a4610554565b6105ad57600080fd5b600b600060085481526020019081526020016000205461062a600c60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000600854815260200190815260200160002054600a546110d690919063ffffffff16565b8161063157fe5b0490506000600c60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000600854815260200190815260200160002081905550600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33836040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561073557600080fd5b505af1158015610749573d6000803e3d6000fd5b505050506040513d602081101561075f57600080fd5b810190808051906020019092919050505061077957600080fd5b3373ffffffffffffffffffffffffffffffffffffffff167f7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65826040518082815260200191505060405180910390a290565b60075481565b600080600754141580156107f957506003546107f76007544261104d90919063ffffffff16565b115b905090565b6108066109e8565b15801561081557506000600754145b80156108c05750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ccdf68f36040518163ffffffff1660e01b815260040160206040518083038186803b15801561088457600080fd5b505afa158015610898573d6000803e3d6000fd5b505050506040513d60208110156108ae57600080fd5b81019080805190602001909291905050505b6108c957600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16637e7e4b476040518163ffffffff1660e01b815260040160206040518083038186803b15801561093157600080fd5b505afa158015610945573d6000803e3d6000fd5b505050506040513d602081101561095b57600080fd5b8101908080519060200190929190505050600681905550426007819055507f6eab3db94ac766c1ac203bcd9c9636476993422eaa067ad449e20ce8501b2a8f6006546040518082815260200191505060405180910390a1565b60006109be610554565b156109cd5760085490506109d3565b60065490505b90565b60095481565b60065481565b60045481565b6000806009541415905090565b6109fd6109e8565b158015610a0f5750610a0d6107d0565b155b8015610b315750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd33306004546040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b158015610af557600080fd5b505af1158015610b09573d6000803e3d6000fd5b505050506040513d6020811015610b1f57600080fd5b81019080805190602001909291905050505b610b3a57600080fd5b600454600c60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550600454600b600083815260200190815260200160002081905550600454600a8190555080600881905550426009819055503373ffffffffffffffffffffffffffffffffffffffff167fd0fdeb84e66d569a89718f40a99496b38d6c13249a9c9f623fbaa3d8ef343a9d826040518082815260200191505060405180910390a250565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600c602052816000526040600020602052806000526040600020600091509150505481565b6000610c8d6107d0565b8015610c9e5750610c9c6109e8565b155b80610cad5750610cac610554565b5b905090565b600260149054906101000a900460ff1681565b60035481565b6000610d09600260149054906101000a900460ff1660ff16600b600086815260200190815260200160002054600a54036110d690919063ffffffff16565b9050600b600084815260200190815260200160002054811115610d4357600b60008481526020019081526020016000205481039050610d48565b600090505b80821115610d54578091505b610d5c6109e8565b8015610d6d5750610d6b610554565b155b8015610e8d5750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3330856040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b158015610e5157600080fd5b505af1158015610e65573d6000803e3d6000fd5b505050506040513d6020811015610e7b57600080fd5b81019080805190602001909291905050505b610e9657600080fd5b610ef982600c60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008681526020019081526020016000205461115c90919063ffffffff16565b600c60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600085815260200190815260200160002081905550610f7382600b60008681526020019081526020016000205461115c90919063ffffffff16565b600b600085815260200190815260200160002081905550610f9f82600a5461115c90919063ffffffff16565b600a819055506008548314158015610fde5750600b6000600854815260200190815260200160002054600b600085815260200190815260200160002054115b15610ff25782600881905550426009819055505b3373ffffffffffffffffffffffffffffffffffffffff167f86fa706979a07f1dd01a49718016881d95ada425549c353ec9e55a627b98a93b8484604051808381526020018281526020019250505060405180910390a2505050565b6000828211156110c5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525060200191505060405180910390fd5b600082840390508091505092915050565b6000808314156110e95760009050611156565b60008284029050828482816110fa57fe5b0414611151576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806111e56021913960400191505060405180910390fd5b809150505b92915050565b6000808284019050838110156111da576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a165627a7a72305820eb8d84c125731148d090392c34afc062e15a09fd4d2b6491bf545106db0224070029", "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061014d5760003560e01c80638ef8125e116100c3578063b2016bd41161007c578063b2016bd4146103d4578063c427af9b1461041e578063ccdf68f314610480578063d84d2a47146104a2578063f3f480d9146104c6578063f7553098146104e45761014d565b80638ef8125e146102e0578063984a470a146102fe5780639d89e7d41461031c5780639df4d0fe1461033a5780639f0de4901461035c578063a619486e1461038a5761014d565b80631ff14311116101155780631ff14311146102185780633ccfd60b1461025a578063466ae3141461027857806372b8de1414610296578063739b8c48146102b85780637e7e4b47146102c25761014d565b8063061a85c7146101525780630853f7eb1461019c5780630f3e9438146101ba5780631a39d8ef146101d85780631a4f5b67146101f6575b600080fd5b61015a61051c565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6101a4610542565b6040518082815260200191505060405180910390f35b6101c2610548565b6040518082815260200191505060405180910390f35b6101e061054e565b6040518082815260200191505060405180910390f35b6101fe610554565b604051808215151515815260200191505060405180910390f35b6102446004803603602081101561022e57600080fd5b8101908080359060200190929190505050610582565b6040518082815260200191505060405180910390f35b61026261059a565b6040518082815260200191505060405180910390f35b6102806107ca565b6040518082815260200191505060405180910390f35b61029e6107d0565b604051808215151515815260200191505060405180910390f35b6102c06107fe565b005b6102ca6109b4565b6040518082815260200191505060405180910390f35b6102e86109d6565b6040518082815260200191505060405180910390f35b6103066109dc565b6040518082815260200191505060405180910390f35b6103246109e2565b6040518082815260200191505060405180910390f35b6103426109e8565b604051808215151515815260200191505060405180910390f35b6103886004803603602081101561037257600080fd5b81019080803590602001909291905050506109f5565b005b610392610c13565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103dc610c38565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61046a6004803603604081101561043457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c5e565b6040518082815260200191505060405180910390f35b610488610c83565b604051808215151515815260200191505060405180910390f35b6104aa610cb2565b604051808260ff1660ff16815260200191505060405180910390f35b6104ce610cc5565b6040518082815260200191505060405180910390f35b61051a600480360360408110156104fa57600080fd5b810190808035906020019092919080359060200190929190505050610ccb565b005b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60055481565b60085481565b600a5481565b6000806009541415801561057d575060055461057b6009544261104d90919063ffffffff16565b115b905090565b600b6020528060005260406000206000915090505481565b60006105a4610554565b6105ad57600080fd5b600b600060085481526020019081526020016000205461062a600c60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000600854815260200190815260200160002054600a546110d690919063ffffffff16565b8161063157fe5b0490506000600c60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000600854815260200190815260200160002081905550600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33836040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561073557600080fd5b505af1158015610749573d6000803e3d6000fd5b505050506040513d602081101561075f57600080fd5b810190808051906020019092919050505061077957600080fd5b3373ffffffffffffffffffffffffffffffffffffffff167f7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65826040518082815260200191505060405180910390a290565b60075481565b600080600754141580156107f957506003546107f76007544261104d90919063ffffffff16565b115b905090565b6108066109e8565b15801561081557506000600754145b80156108c05750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ccdf68f36040518163ffffffff1660e01b815260040160206040518083038186803b15801561088457600080fd5b505afa158015610898573d6000803e3d6000fd5b505050506040513d60208110156108ae57600080fd5b81019080805190602001909291905050505b6108c957600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16637e7e4b476040518163ffffffff1660e01b815260040160206040518083038186803b15801561093157600080fd5b505afa158015610945573d6000803e3d6000fd5b505050506040513d602081101561095b57600080fd5b8101908080519060200190929190505050600681905550426007819055507f6eab3db94ac766c1ac203bcd9c9636476993422eaa067ad449e20ce8501b2a8f6006546040518082815260200191505060405180910390a1565b60006109be610554565b156109cd5760085490506109d3565b60065490505b90565b60095481565b60065481565b60045481565b6000806009541415905090565b6109fd6109e8565b158015610a0f5750610a0d6107d0565b155b8015610b315750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd33306004546040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b158015610af557600080fd5b505af1158015610b09573d6000803e3d6000fd5b505050506040513d6020811015610b1f57600080fd5b81019080805190602001909291905050505b610b3a57600080fd5b600454600c60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550600454600b600083815260200190815260200160002081905550600454600a8190555080600881905550426009819055503373ffffffffffffffffffffffffffffffffffffffff167fd0fdeb84e66d569a89718f40a99496b38d6c13249a9c9f623fbaa3d8ef343a9d826040518082815260200191505060405180910390a250565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600c602052816000526040600020602052806000526040600020600091509150505481565b6000610c8d6107d0565b8015610c9e5750610c9c6109e8565b155b80610cad5750610cac610554565b5b905090565b600260149054906101000a900460ff1681565b60035481565b6000610d09600260149054906101000a900460ff1660ff16600b600086815260200190815260200160002054600a54036110d690919063ffffffff16565b9050600b600084815260200190815260200160002054811115610d4357600b60008481526020019081526020016000205481039050610d48565b600090505b80821115610d54578091505b610d5c6109e8565b8015610d6d5750610d6b610554565b155b8015610e8d5750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3330856040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b158015610e5157600080fd5b505af1158015610e65573d6000803e3d6000fd5b505050506040513d6020811015610e7b57600080fd5b81019080805190602001909291905050505b610e9657600080fd5b610ef982600c60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008681526020019081526020016000205461115c90919063ffffffff16565b600c60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600085815260200190815260200160002081905550610f7382600b60008681526020019081526020016000205461115c90919063ffffffff16565b600b600085815260200190815260200160002081905550610f9f82600a5461115c90919063ffffffff16565b600a819055506008548314158015610fde5750600b6000600854815260200190815260200160002054600b600085815260200190815260200160002054115b15610ff25782600881905550426009819055505b3373ffffffffffffffffffffffffffffffffffffffff167f86fa706979a07f1dd01a49718016881d95ada425549c353ec9e55a627b98a93b8484604051808381526020018281526020019250505060405180910390a2505050565b6000828211156110c5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525060200191505060405180910390fd5b600082840390508091505092915050565b6000808314156110e95760009050611156565b60008284029050828482816110fa57fe5b0414611151576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806111e56021913960400191505060405180910390fd5b809150505b92915050565b6000808284019050838110156111da576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a165627a7a72305820eb8d84c125731148d090392c34afc062e15a09fd4d2b6491bf545106db0224070029", "sourceMap": "2698:4610:25:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;2698:4610:25;;;;;;;", "deployedSourceMap": "2698:4610:25:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;2698:4610:25;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;657:29;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;827;;;:::i;:::-;;;;;;;;;;;;;;;;;;;942:22;;;:::i;:::-;;;;;;;;;;;;;;;;;;;1012:23;;;:::i;:::-;;;;;;;;;;;;;;;;;;;6363:198;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;1041:48;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;1041:48:25;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;5437:498;;;:::i;:::-;;;;;;;;;;;;;;;;;;;896:40;;;:::i;:::-;;;;;;;;;;;;;;;;;;;6044:204;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;2913:480;;;:::i;:::-;;7119:187;;;:::i;:::-;;;;;;;;;;;;;;;;;;;970:35;;;:::i;:::-;;;;;;;;;;;;;;;;;;;863:27;;;:::i;:::-;;;;;;;;;;;;;;;;;;;794;;;:::i;:::-;;;;;;;;;;;;;;;;;;;6644:131;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;3493:593;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;3493:593:25;;;;;;;;;;;;;;;;;:::i;:::-;;205:25:29;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;692:28:25;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;1095:64;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;1095:64:25;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;6860:192;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;726:29;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;761:27;;;:::i;:::-;;;;;;;;;;;;;;;;;;;4222:1143;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;4222:1143:25;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;657:29;;;;;;;;;;;;;:::o;827:::-;;;;:::o;942:22::-;;;;:::o;1012:23::-;;;;:::o;6363:198::-;6443:4;6497:1;6470:23;;:28;;:84;;;;;6537:17;;6502:32;6510:23;;6502:3;:7;;:32;;;;:::i;:::-;:52;6470:84;6463:91;;6363:198;:::o;1041:48::-;;;;;;;;;;;;;;;;;:::o;5437:498::-;5489:11;5587:25;:23;:25::i;:::-;5579:34;;;;;;5691:19;:32;5711:11;;5691:32;;;;;;;;;;;;5632:56;5648:14;:26;5663:10;5648:26;;;;;;;;;;;;;;;:39;5675:11;;5648:39;;;;;;;;;;;;5632:11;;:15;;:56;;;;:::i;:::-;:91;;;;;;5623:100;;5775:1;5733:14;:26;5748:10;5733:26;;;;;;;;;;;;;;;:39;5760:11;;5733:39;;;;;;;;;;;:43;;;;5838:15;;;;;;;;;;;:24;;;5863:10;5875:6;5838:44;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;5838:44:25;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;5838:44:25;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;5838:44:25;;;;;;;;;;;;;;;;5830:53;;;;;;5909:10;5898:30;;;5921:6;5898:30;;;;;;;;;;;;;;;;;;5437:498;:::o;896:40::-;;;;:::o;6044:204::-;6122:4;6181:1;6149:28;;:33;;:92;;;;;6226:15;;6186:37;6194:28;;6186:3;:7;;:37;;;;:::i;:::-;:55;6149:92;6142:99;;6044:204;:::o;2913:480::-;3102:14;:12;:14::i;:::-;3101:15;:68;;;;;3168:1;3136:28;;:33;3101:68;:118;;;;;3189:15;;;;;;;;;;;:28;;;:30;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;3189:30:25;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;3189:30:25;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;3189:30:25;;;;;;;;;;;;;;;;3101:118;3090:130;;;;;;3249:15;;;;;;;;;;;:26;;;:28;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;3249:28:25;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;3249:28:25;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;3249:28:25;;;;;;;;;;;;;;;;3230:16;:47;;;;3318:3;3287:28;:34;;;;3336:50;3369:16;;3336:50;;;;;;;;;;;;;;;;;;2913:480::o;7119:187::-;7186:3;7209:25;:23;:25::i;:::-;7205:61;;;7255:11;;7248:18;;;;7205:61;7283:16;;7276:23;;7119:187;;:::o;970:35::-;;;;:::o;863:27::-;;;;:::o;794:::-;;;;:::o;6644:131::-;6713:4;6767:1;6740:23;;:28;;6733:35;;6644:131;:::o;3493:593::-;3644:14;:12;:14::i;:::-;3643:15;:59;;;;;3679:23;:21;:23::i;:::-;3678:24;3643:59;:151;;;;;3722:15;;;;;;;;;;;:28;;;3751:10;3771:4;3778:15;;3722:72;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;3722:72:25;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;3722:72:25;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;3722:72:25;;;;;;;;;;;;;;;;3643:151;3632:163;;;;;;3844:15;;3805:14;:26;3820:10;3805:26;;;;;;;;;;;;;;;:36;3832:8;3805:36;;;;;;;;;;;:54;;;;3901:15;;3869:19;:29;3889:8;3869:29;;;;;;;;;;;:47;;;;3940:15;;3926:11;:29;;;;3979:8;3965:11;:22;;;;4023:3;3997:23;:29;;;;4058:10;4041:38;;;4070:8;4041:38;;;;;;;;;;;;;;;;;;3493:593;:::o;205:25:29:-;;;;;;;;;;;;;:::o;692:28:25:-;;;;;;;;;;;;;:::o;1095:64::-;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;6860:192::-;6929:4;6959:23;:21;:23::i;:::-;:42;;;;;6987:14;:12;:14::i;:::-;6986:15;6959:42;:86;;;;7020:25;:23;:25::i;:::-;6959:86;6949:96;;6860:192;:::o;726:29::-;;;;;;;;;;;;;:::o;761:27::-;;;;:::o;4222:1143::-;4302:14;4319:67;4369:16;;;;;;;;;;;4319:67;;4334:19;:29;4354:8;4334:29;;;;;;;;;;;;4320:11;;:43;4319:49;;:67;;;;:::i;:::-;4302:84;;4413:19;:29;4433:8;4413:29;;;;;;;;;;;;4401:9;:41;4397:141;;;4469:19;:29;4489:8;4469:29;;;;;;;;;;;;4456:42;;;;4397:141;;;4537:1;4525:13;;4397:141;4562:9;4553:6;:18;4549:54;;;4594:9;4585:18;;4549:54;4727:14;:12;:14::i;:::-;:60;;;;;4762:25;:23;:25::i;:::-;4761:26;4727:60;:143;;;;;4807:15;;;;;;;;;;;:28;;;4836:10;4856:4;4863:6;4807:63;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;4807:63:25;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;4807:63:25;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;4807:63:25;;;;;;;;;;;;;;;;4727:143;4716:155;;;;;;4920:48;4961:6;4920:14;:26;4935:10;4920:26;;;;;;;;;;;;;;;:36;4947:8;4920:36;;;;;;;;;;;;:40;;:48;;;;:::i;:::-;4881:14;:26;4896:10;4881:26;;;;;;;;;;;;;;;:36;4908:8;4881:36;;;;;;;;;;;:87;;;;5010:41;5044:6;5010:19;:29;5030:8;5010:29;;;;;;;;;;;;:33;;:41;;;;:::i;:::-;4978:19;:29;4998:8;4978:29;;;;;;;;;;;:73;;;;5075:23;5091:6;5075:11;;:15;;:23;;;;:::i;:::-;5061:11;:37;;;;5124:11;;5112:8;:23;;:91;;;;;5171:19;:32;5191:11;;5171:32;;;;;;;;;;;;5139:19;:29;5159:8;5139:29;;;;;;;;;;;;:64;5112:91;5108:195;;;5241:8;5227:11;:22;;;;5289:3;5263:23;:29;;;;5108:195;5329:10;5317:41;;;5341:8;5351:6;5317:41;;;;;;;;;;;;;;;;;;;;;;;;4222:1143;;;:::o;1274:179:32:-;1332:7;1364:1;1359;:6;;1351:49;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1410:9;1426:1;1422;:5;1410:17;;1445:1;1438:8;;;1274:179;;;;:::o;1693:458::-;1751:7;1996:1;1991;:6;1987:45;;;2020:1;2013:8;;;;1987:45;2042:9;2058:1;2054;:5;2042:17;;2086:1;2081;2077;:5;;;;;;:10;2069:56;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2143:1;2136:8;;;1693:458;;;;;:::o;834:176::-;892:7;911:9;927:1;923;:5;911:17;;951:1;946;:6;;938:46;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1002:1;995:8;;;834:176;;;;:::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/