UNPKG

@gnosis.pm/pm-contracts

Version:

Collection of smart contracts for the Gnosis prediction market platform

1,061 lines (1,060 loc) 529 kB
{ "contractName": "CampaignData", "abi": [ { "constant": true, "inputs": [], "name": "marketFactory", "outputs": [ { "name": "", "type": "address" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "marketMaker", "outputs": [ { "name": "", "type": "address" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "finalBalance", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "deadline", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "", "type": "address" } ], "name": "contributions", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "market", "outputs": [ { "name": "", "type": "address" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "stage", "outputs": [ { "name": "", "type": "uint8" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "funding", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "fee", "outputs": [ { "name": "", "type": "uint24" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "eventContract", "outputs": [ { "name": "", "type": "address" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "FEE_RANGE", "outputs": [ { "name": "", "type": "uint24" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "anonymous": false, "inputs": [ { "indexed": true, "name": "sender", "type": "address" }, { "indexed": false, "name": "funding", "type": "uint256" } ], "name": "CampaignFunding", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "name": "sender", "type": "address" }, { "indexed": false, "name": "refund", "type": "uint256" } ], "name": "CampaignRefund", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "name": "market", "type": "address" } ], "name": "MarketCreation", "type": "event" }, { "anonymous": false, "inputs": [], "name": "MarketClosing", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "name": "receiver", "type": "address" }, { "indexed": false, "name": "fees", "type": "uint256" } ], "name": "FeeWithdrawal", "type": "event" } ], "metadata": "{\"compiler\":{\"version\":\"0.5.6+commit.b259423e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"constant\":true,\"inputs\":[],\"name\":\"marketFactory\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"marketMaker\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"finalBalance\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"deadline\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"}],\"name\":\"contributions\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"market\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"stage\",\"outputs\":[{\"name\":\"\",\"type\":\"uint8\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"funding\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"fee\",\"outputs\":[{\"name\":\"\",\"type\":\"uint24\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"eventContract\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"FEE_RANGE\",\"outputs\":[{\"name\":\"\",\"type\":\"uint24\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"funding\",\"type\":\"uint256\"}],\"name\":\"CampaignFunding\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"refund\",\"type\":\"uint256\"}],\"name\":\"CampaignRefund\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"market\",\"type\":\"address\"}],\"name\":\"MarketCreation\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[],\"name\":\"MarketClosing\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"receiver\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"fees\",\"type\":\"uint256\"}],\"name\":\"FeeWithdrawal\",\"type\":\"event\"}],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/home/alan/src/github.com/gnosis/pm-contracts/contracts/Markets/Campaign.sol\":\"CampaignData\"},\"evmVersion\":\"petersburg\",\"libraries\":{},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"/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/MarketMakers/MarketMaker.sol\":{\"keccak256\":\"0xa71f8ce92412033d0900d44c01f0702aefced87d860cf116c6a4d3efe86913cf\",\"urls\":[\"bzzr://63c5bf60b931bb032fcab23514a3db171b680b11d8c6c05ac8caa88752e3be41\"]},\"/home/alan/src/github.com/gnosis/pm-contracts/contracts/Markets/Campaign.sol\":{\"keccak256\":\"0x747255f6e5d034164f791a042af53af9c4813d1ca0cae938cad5dff89a4d0329\",\"urls\":[\"bzzr://787c31a9d223fc6dc7d94b366babc16311fbf62b3737a3a2f47d46e30444fe7f\"]},\"/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/StandardMarketFactory.sol\":{\"keccak256\":\"0x8f8f3452e190afcf74b5d8245ff8aa98d253b683e63d64aaa8e425fe36abff45\",\"urls\":[\"bzzr://defea219cbd36bd316ce07e750994069afddd9790f6585df38344d79ead2ca7f\"]},\"/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": "0x608060405234801561001057600080fd5b50610420806100206000396000f3fe608060405234801561001057600080fd5b50600436106100a95760003560e01c806380f556051161007157806380f55605146101d6578063c040e6b814610220578063cb4c86b71461024c578063ddca3f431461026a578063e274fd2414610292578063fbde47f6146102dc576100a9565b806306ae7095146100ae5780631f21f9af146100f85780632129e25a1461014257806329dcb0cf1461016057806342e94c901461017e575b600080fd5b6100b6610304565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61010061032a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61014a610350565b6040518082815260200191505060405180910390f35b610168610356565b6040518082815260200191505060405180910390f35b6101c06004803603602081101561019457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061035c565b6040518082815260200191505060405180910390f35b6101de610374565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61022861039a565b6040518082600481111561023857fe5b60ff16815260200191505060405180910390f35b6102546103ad565b6040518082815260200191505060405180910390f35b6102726103b3565b604051808262ffffff1662ffffff16815260200191505060405180910390f35b61029a6103c8565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102e46103ed565b604051808262ffffff1662ffffff16815260200191505060405180910390f35b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60065481565b60055481565b60076020528060005260406000206000915090505481565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600860009054906101000a900460ff1681565b60045481565b600360149054906101000a900462ffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b620f42408156fea165627a7a72305820650a628a065e67868cd301b0c12b42d4f0faed7c086a15e3c5faf132f0aa6b980029", "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100a95760003560e01c806380f556051161007157806380f55605146101d6578063c040e6b814610220578063cb4c86b71461024c578063ddca3f431461026a578063e274fd2414610292578063fbde47f6146102dc576100a9565b806306ae7095146100ae5780631f21f9af146100f85780632129e25a1461014257806329dcb0cf1461016057806342e94c901461017e575b600080fd5b6100b6610304565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61010061032a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61014a610350565b6040518082815260200191505060405180910390f35b610168610356565b6040518082815260200191505060405180910390f35b6101c06004803603602081101561019457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061035c565b6040518082815260200191505060405180910390f35b6101de610374565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61022861039a565b6040518082600481111561023857fe5b60ff16815260200191505060405180910390f35b6102546103ad565b6040518082815260200191505060405180910390f35b6102726103b3565b604051808262ffffff1662ffffff16815260200191505060405180910390f35b61029a6103c8565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102e46103ed565b604051808262ffffff1662ffffff16815260200191505060405180910390f35b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60065481565b60055481565b60076020528060005260406000206000915090505481565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600860009054906101000a900460ff1681565b60045481565b600360149054906101000a900462ffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b620f42408156fea165627a7a72305820650a628a065e67868cd301b0c12b42d4f0faed7c086a15e3c5faf132f0aa6b980029", "sourceMap": "286:1235:6:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;286:1235:6;;;;;;;", "deployedSourceMap": "286:1235:6:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;286:1235:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;766:42;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;814:30;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;950:24;;;:::i;:::-;;;;;;;;;;;;;;;;;;;924:20;;;:::i;:::-;;;;;;;;;;;;;;;;;;;980:46;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;980:46:6;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;850:20;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;1032:19;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;899;;;:::i;:::-;;;;;;;;;;;;;;;;;;;876:17;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;734:26;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;646:42;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;766;;;;;;;;;;;;;:::o;814:30::-;;;;;;;;;;;;;:::o;950:24::-;;;;:::o;924:20::-;;;;:::o;980:46::-;;;;;;;;;;;;;;;;;:::o;850:20::-;;;;;;;;;;;;;:::o;1032:19::-;;;;;;;;;;;;;:::o;899:::-;;;;:::o;876:17::-;;;;;;;;;;;;;:::o;734:26::-;;;;;;;;;;;;;:::o;646:42::-;681:7;646:42;:::o", "source": "pragma solidity ^0.5.0;\nimport \"../Events/Event.sol\";\nimport \"../Markets/StandardMarketFactory.sol\";\nimport \"openzeppelin-solidity/contracts/math/SafeMath.sol\";\nimport \"openzeppelin-solidity/contracts/drafts/SignedSafeMath.sol\";\nimport \"@gnosis.pm/util-contracts/contracts/Proxy.sol\";\n\ncontract CampaignData {\n\n /*\n * Events\n */\n event CampaignFunding(address indexed sender, uint funding);\n event CampaignRefund(address indexed sender, uint refund);\n event MarketCreation(Market indexed market);\n event MarketClosing();\n event FeeWithdrawal(address indexed receiver, uint fees);\n\n /*\n * Constants\n */\n uint24 public constant FEE_RANGE = 1000000; // 100%\n\n /*\n * Storage\n */\n Event public eventContract;\n StandardMarketFactory public marketFactory;\n MarketMaker public marketMaker;\n Market public market;\n uint24 public fee;\n uint public funding;\n uint public deadline;\n uint public finalBalance;\n mapping (address => uint) public contributions;\n Stages public stage;\n\n enum Stages {\n AuctionStarted,\n AuctionSuccessful,\n AuctionFailed,\n MarketCreated,\n MarketClosed\n }\n\n /*\n * Modifiers\n */\n modifier atStage(Stages _stage) {\n // Contract has to be in given stage\n require(stage == _stage);\n _;\n }\n\n modifier timedTransitions() {\n if (stage == Stages.AuctionStarted && deadline < now)\n stage = Stages.AuctionFailed;\n _;\n }\n}\n\ncontract CampaignProxy is Proxy, CampaignData {\n /// @dev Constructor validates and sets campaign properties\n /// @param _eventContract Event contract\n /// @param _marketFactory Market factory contract\n /// @param _marketMaker Market maker contract\n /// @param _fee Market fee\n /// @param _funding Initial funding for market\n /// @param _deadline Campaign deadline\n constructor(\n address proxied,\n Event _eventContract,\n StandardMarketFactory _marketFactory,\n MarketMaker _marketMaker,\n uint24 _fee,\n uint _funding,\n uint _deadline\n )\n Proxy(proxied)\n public\n {\n // Validate input\n require( address(_eventContract) != address(0)\n && address(_marketFactory) != address(0)\n && address(_marketMaker) != address(0)\n && _fee < FEE_RANGE\n && _funding > 0\n && now < _deadline);\n eventContract = _eventContract;\n marketFactory = _marketFactory;\n marketMaker = _marketMaker;\n fee = _fee;\n funding = _funding;\n deadline = _deadline;\n }\n}\n\n/// @title Campaign contract - Allows to crowdfund a market\n/// @author Stefan George - <stefan@gnosis.pm>\ncontract Campaign is Proxied, CampaignData {\n using SignedSafeMath for int;\n using SafeMath for uint;\n\n /*\n * Public functions\n */\n /// @dev Allows to contribute to required market funding\n /// @param amount Amount of collateral tokens\n function fund(uint amount)\n public\n timedTransitions\n atStage(Stages.AuctionStarted)\n {\n uint raisedAmount = eventContract.collateralToken().balanceOf(address(this));\n uint maxAmount = funding.sub(raisedAmount);\n if (maxAmount < amount)\n amount = maxAmount;\n // Collect collateral tokens\n require(eventContract.collateralToken().transferFrom(msg.sender, address(this), amount));\n contributions[msg.sender] = contributions[msg.sender].add(amount);\n if (amount == maxAmount)\n stage = Stages.AuctionSuccessful;\n emit CampaignFunding(msg.sender, amount);\n }\n\n /// @dev Withdraws refund amount\n /// @return Refund amount\n function refund()\n public\n timedTransitions\n atStage(Stages.AuctionFailed)\n returns (uint refundAmount)\n {\n refundAmount = contributions[msg.sender];\n contributions[msg.sender] = 0;\n // Refund collateral tokens\n require(eventContract.collateralToken().transfer(msg.sender, refundAmount));\n emit CampaignRefund(msg.sender, refundAmount);\n }\n\n /// @dev Allows to create market after successful funding\n /// @return Market address\n function createMarket()\n public\n timedTransitions\n atStage(Stages.AuctionSuccessful)\n returns (Market)\n {\n market = marketFactory.createMarket(eventContract, marketMaker, fee);\n require(eventContract.collateralToken().approve(address(market), funding));\n market.fund(funding);\n stage = Stages.MarketCreated;\n emit MarketCreation(market);\n return market;\n }\n\n /// @dev Allows to withdraw fees from market contract to campaign contract\n /// @return Fee amount\n function closeMarket()\n public\n atStage(Stages.MarketCreated)\n {\n // Winning outcome should be set\n require(eventContract.isOutcomeSet());\n market.close();\n market.withdrawFees();\n eventContract.redeemWinnings();\n finalBalance = eventContract.collateralToken().balanceOf(address(this));\n stage = Stages.MarketClosed;\n emit MarketClosing();\n }\n\n /// @dev Allows to withdraw fees from campaign contract to contributor\n /// @return Fee amount\n function withdrawFees()\n public\n atStage(Stages.MarketClosed)\n returns (uint fees)\n {\n fees = finalBalance.mul(contributions[msg.sender]) / funding;\n contributions[msg.sender] = 0;\n // Send fee share to contributor\n require(eventContract.collateralToken().transfer(msg.sender, fees));\n emit FeeWithdrawal(msg.sender, fees);\n }\n}\n", "sourcePath": "/home/alan/src/github.com/gnosis/pm-contracts/contracts/Markets/Campaign.sol", "ast": { "absolutePath": "/home/alan/src/github.com/gnosis/pm-contracts/contracts/Markets/Campaign.sol", "exportedSymbols": { "Campaign": [ 2065 ], "CampaignData": [ 1699 ], "CampaignProxy": [ 1787 ] }, "id": 2066, "nodeType": "SourceUnit", "nodes": [ { "id": 1608, "literals": [ "solidity", "^", "0.5", ".0" ], "nodeType": "PragmaDirective", "src": "0:23:6" }, { "absolutePath": "/home/alan/src/github.com/gnosis/pm-contracts/contracts/Events/Event.sol", "file": "../Events/Event.sol", "id": 1609, "nodeType": "ImportDirective", "scope": 2066, "sourceUnit": 393, "src": "24:29:6", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "/home/alan/src/github.com/gnosis/pm-contracts/contracts/Markets/StandardMarketFactory.sol", "file": "../Markets/StandardMarketFactory.sol", "id": 1610, "nodeType": "ImportDirective", "scope": 2066, "sourceUnit": 3267, "src": "54:46:6", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "openzeppelin-solidity/contracts/math/SafeMath.sol", "file": "openzeppelin-solidity/contracts/math/SafeMath.sol", "id": 1611, "nodeType": "ImportDirective", "scope": 2066, "sourceUnit": 7382, "src": "101:59:6", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "openzeppelin-solidity/contracts/drafts/SignedSafeMath.sol", "file": "openzeppelin-solidity/contracts/drafts/SignedSafeMath.sol", "id": 1612, "nodeType": "ImportDirective", "scope": 2066, "sourceUnit": 7249, "src": "161:67:6", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "@gnosis.pm/util-contracts/contracts/Proxy.sol", "file": "@gnosis.pm/util-contracts/contracts/Proxy.sol", "id": 1613, "nodeType": "ImportDirective", "scope": 2066, "sourceUnit": 6829, "src": "229:55:6", "symbolAliases": [], "unitAlias": "" }, { "baseContracts": [], "contractDependencies": [], "contractKind": "contract", "documentation": null, "fullyImplemented": true, "id": 1699, "linearizedBaseContracts": [ 1699 ], "name": "CampaignData", "nodeType": "ContractDefinition", "nodes": [ { "anonymous": false, "documentation": null, "id": 1619, "name": "CampaignFunding", "nodeType": "EventDefinition", "parameters": { "id": 1618, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 1615, "indexed": true, "name": "sender", "nodeType": "VariableDeclaration", "scope": 1619, "src": "367:22:6", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 1614, "name": "address", "nodeType": "ElementaryTypeName", "src": "367:7:6", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 1617, "indexed": false, "name": "funding", "nodeType": "VariableDeclaration", "scope": 1619, "src": "391:12:6", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 1616, "name": "uint", "nodeType": "ElementaryTypeName", "src": "391:4:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" } ], "src": "366:38:6" }, "src": "345:60:6" }, { "anonymous": false, "documentation": null, "id": 1625, "name": "CampaignRefund", "nodeType": "EventDefinition", "parameters": { "id": 1624, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 1621, "indexed": true, "name": "sender", "nodeType": "VariableDeclaration", "scope": 1625, "src": "431:22:6", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 1620, "name": "address", "nodeType": "ElementaryTypeName", "src": "431:7:6", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 1623, "indexed": false, "name": "refund", "nodeType": "VariableDeclaration", "scope": 1625, "src": "455:11:6", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 1622, "name": "uint", "nodeType": "ElementaryTypeName", "src": "455:4:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" } ], "src": "430:37:6" }, "src": "410:58:6" }, { "anonymous": false, "documentation": null, "id": 1629, "name": "MarketCreation", "nodeType": "EventDefinition", "parameters": { "id": 1628, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 1627, "indexed": true, "name": "market", "nodeType": "VariableDeclaration", "scope": 1629, "src": "494:21:6", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_contract$_Market_$2296", "typeString": "contract Market" }, "typeName": { "contractScope": null, "id": 1626, "name": "Market", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 2296, "src": "494:6:6", "typeDescriptions": { "typeIdentifier": "t_contract$_Market_$2296", "typeString": "contract Market" } }, "value": null, "visibility": "internal" } ], "src": "493:23:6" }, "src": "473:44:6" }, { "anonymous": false, "documentation": null, "id": 1631, "name": "MarketClosing", "nodeType": "EventDefinition", "parameters": { "id": 1630, "nodeType": "ParameterList", "parameters": [], "src": "541:2:6" }, "src": "522:22:6" }, { "anonymous": false, "documentation": null, "id": 1637, "name": "FeeWithdrawal", "nodeType": "EventDefinition", "parameters": { "id": 1636, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 1633, "indexed": true, "name": "receiver", "nodeType": "VariableDeclaration", "scope": 1637, "src": "569:24:6", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 1632, "name": "address", "nodeType": "ElementaryTypeName", "src": "569:7:6", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 1635, "indexed": false, "name": "fees", "nodeType": "VariableDeclaration", "scope": 1637, "src": "595:9:6", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 1634, "name": "uint", "nodeType": "ElementaryTypeName", "src": "595:4:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" } ], "src": "568:37:6" }, "src": "549:57:6" }, { "constant": true, "id": 1640, "name": "FEE_RANGE", "nodeType": "VariableDeclaration", "scope": 1699, "src": "646:42:6", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint24", "typeString": "uint24" }, "typeName": { "id": 1638, "name": "uint24", "nodeType": "ElementaryTypeName", "src": "646:6:6", "typeDescriptions": { "typeIdentifier": "t_uint24", "typeString": "uint24" } }, "value": { "argumentTypes": null, "hexValue": "31303030303030", "id": 1639, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "681:7:6", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_1000000_by_1", "typeString": "int_const 1000000" }, "value": "1000000" }, "visibility": "public" }, { "constant": false, "id": 1642, "name": "eventContract", "nodeType": "VariableDeclaration", "scope": 1699, "src": "734:26:6", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_contract$_Event_$392", "typeString": "contract Event" }, "typeName": { "contractScope": null, "id": 1641, "name": "Event", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 392, "src": "734:5:6", "typeDescriptions": { "typeIdentifier": "t_contract$_Event_$392", "typeString": "contract Event" } }, "value": null, "visibility": "public" }, { "constant": false, "id": 1644, "name": "marketFactory", "nodeType": "VariableDeclaration", "scope": 1699, "src": "766:42:6", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_contract$_StandardMarketFactory_$3266", "typeString": "contract StandardMarketFactory" }, "typeName": { "contractScope": null, "id": 1643, "name": "StandardMarketFactory", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 3266, "src": "766:21:6", "typeDescriptions": { "typeIdentifier": "t_contract$_StandardMarketFactory_$3266", "typeString": "contract StandardMarketFactory" } }, "value": null, "visibility": "public" }, { "constant": false, "id": 1646, "name": "marketMaker", "nodeType": "VariableDeclaration", "scope": 1699, "src": "814:30:6", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_contract$_MarketMaker_$1606", "typeString": "contract MarketMaker" }, "typeName": { "contractScope": null, "id": 1645, "name": "MarketMaker", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 1606, "src": "814:11:6", "typeDescriptions": { "typeIdentifier": "t_contract$_MarketMaker_$1606", "typeString": "contract MarketMaker" } }, "value": null, "visibility": "public" }, { "constant": false, "id": 1648, "name": "market", "nodeType": "VariableDeclaration", "scope": 1699, "src": "850:20:6", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_contract$_Market_$2296", "typeString": "contract Market" }, "typeName": { "contractScope": null, "id": 1647, "name": "Market", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 2296, "src": "850:6:6", "typeDescriptions": { "typeIdentifier": "t_contract$_Market_$2296", "typeString": "contract Market" } }, "value": null, "visibility": "public" }, { "constant": false, "id": 1650, "name": "fee", "nodeType": "VariableDeclaration", "scope": 1699, "src": "876:17:6", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint24", "typeString": "uint24" }, "typeName": { "id": 1649, "name": "uint24", "nodeType": "ElementaryTypeName", "src": "876:6:6", "typeDescriptions": { "typeIdentifier": "t_uint24", "typeString": "uint24" } }, "value": null, "visibility": "public" }, { "constant": false, "id": 1652, "name": "funding", "nodeType": "VariableDeclaration", "scope": 1699, "src": "899:19:6", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 1651, "name": "uint", "nodeType": "ElementaryTypeName", "src": "899:4:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "public" }, { "constant": false, "id": 1654, "name": "deadline", "nodeType": "VariableDeclaration", "scope": 1699, "src": "924:20:6", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 1653, "name": "uint", "nodeType": "ElementaryTypeName", "src": "924:4:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "public" }, { "constant": false, "id": 1656, "name": "finalBalance", "nodeType": "VariableDeclaration", "scope": 1699, "src": "950:24:6", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 1655, "name": "uint", "nodeType": "ElementaryTypeName", "src": "950:4:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "public" }, { "constant": false, "id": 1660, "name": "contributions", "nodeType": "VariableDeclaration", "scope": 1699, "src": "980:46:6", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", "typeString": "mapping(address => uint256)" }, "typeName": { "id": 1659, "keyType": { "id": 1657, "name": "address", "nodeType": "ElementaryTypeName", "src": "989:7:6", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "nodeType": "Mapping", "src": "980:25:6", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", "typeString": "mapping(address => uint256)" }, "valueType": { "id": 1658, "name": "uint", "nodeType": "ElementaryTypeName", "src": "1000:4:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } }, "value": null, "visibility": "public" }, { "constant": false, "id": 1662, "name": "stage", "nodeType": "VariableDeclaration", "scope": 1699, "src": "1032:19:6", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_enum$_Stages_$1668", "typeString": "enum CampaignData.Stages" }, "typeName": { "contractScope": null, "id": 1661, "name": "Stages", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 1668, "src": "1032:6:6", "typeDescriptions": { "typeIdentifier": "t_enum$_Stages_$1668", "typeString": "enum CampaignData.Stages" } }, "value": null, "visibility": "public" }, { "canonicalName": "CampaignData.Stages", "id": 1668, "members": [ { "id": 1663, "name": "AuctionStarted", "nodeType": "EnumValue", "src": "1080:14:6" }, { "id": 1664, "name": "AuctionSuccessful", "nodeType": "EnumValue", "src": "1104:17:6" }, { "id": 1665, "name": "AuctionFailed", "nodeType": "EnumValue", "src": "1131:13:6" }, { "id": 1666, "name": "MarketCreated", "nodeType": "EnumValue", "src": "1154:13:6" }, { "id": 1667, "name": "MarketClosed", "nodeType": "EnumValue", "src": "1177:12:6" } ], "name": "Stages", "nodeType": "EnumDefinition", "src": "1058:137:6" }, { "body": { "id": 1679, "nodeType": "Block", "src": "1266:97:6", "statements": [ { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "commonType": { "typeIdentifier": "t_enum$_Stages_$1668", "typeString": "enum CampaignData.Stages" }, "id": 1675, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 1673, "name": "stage", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1662, "src": "1329:5:6", "typeDescriptions": { "typeIdentifier": "t_enum$_Stages_$1668", "typeString": "enum CampaignData.Stages" } }, "nodeType": "BinaryOperation", "operator": "==", "rightExpression": { "argumentTypes": null, "id": 1674, "name": "_stage", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1670, "src": "1338:6:6", "typeDescriptions": { "typeIdentifier": "t_enum$_Stages_$1668", "typeString": "enum CampaignData.Stages" } }, "src": "1329:15:6", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_bool", "typeString": "bool" } ], "id": 1672, "name": "require", "nodeType": "Identifier", "overloadedDeclarations": [ 7923, 7924 ], "referencedDeclaration": 7923, "src": "1321:7:6", "typeDescriptions": { "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", "typeString": "function (bool) pure" } }, "id": 1676, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1321:24:6", "typeDescriptions": {