@gnosis.pm/pm-contracts
Version:
Collection of smart contracts for the Gnosis prediction market platform
944 lines • 536 kB
JSON
{
"contractName": "CampaignProxy",
"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": "masterCopy",
"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"
},
{
"inputs": [
{
"name": "proxied",
"type": "address"
},
{
"name": "_eventContract",
"type": "address"
},
{
"name": "_marketFactory",
"type": "address"
},
{
"name": "_marketMaker",
"type": "address"
},
{
"name": "_fee",
"type": "uint24"
},
{
"name": "_funding",
"type": "uint256"
},
{
"name": "_deadline",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"payable": true,
"stateMutability": "payable",
"type": "fallback"
},
{
"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\":\"masterCopy\",\"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\"},{\"inputs\":[{\"name\":\"proxied\",\"type\":\"address\"},{\"name\":\"_eventContract\",\"type\":\"address\"},{\"name\":\"_marketFactory\",\"type\":\"address\"},{\"name\":\"_marketMaker\",\"type\":\"address\"},{\"name\":\"_fee\",\"type\":\"uint24\"},{\"name\":\"_funding\",\"type\":\"uint256\"},{\"name\":\"_deadline\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"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\":{\"constructor\":{\"details\":\"Constructor validates and sets campaign properties\",\"params\":{\"_deadline\":\"Campaign deadline\",\"_eventContract\":\"Event contract\",\"_fee\":\"Market fee\",\"_funding\":\"Initial funding for market\",\"_marketFactory\":\"Market factory contract\",\"_marketMaker\":\"Market maker contract\"}}}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/home/alan/src/github.com/gnosis/pm-contracts/contracts/Markets/Campaign.sol\":\"CampaignProxy\"},\"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": "0x608060405234801561001057600080fd5b5060405160e08061084d833981018060405260e081101561003057600080fd5b810190808051906020019092919080519060200190929190805190602001909291908051906020019092919080519060200190929190805190602001909291908051906020019092919050505086600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100b857600080fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16141580156101635750600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614155b801561019c5750600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b80156101b45750620f424062ffffff168362ffffff16105b80156101c05750600082115b80156101cb57508042105b6101d457600080fd5b85600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555084600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555083600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555082600460146101000a81548162ffffff021916908362ffffff160217905550816005819055508060068190555050505050505050610573806102da6000396000f3fe6080604052600436106100a75760003560e01c8063a619486e11610064578063a619486e146102b5578063c040e6b81461030c578063cb4c86b714610345578063ddca3f4314610370578063e274fd24146103a5578063fbde47f6146103fc576100a7565b806306ae7095146100f55780631f21f9af1461014c5780632129e25a146101a357806329dcb0cf146101ce57806342e94c90146101f957806380f556051461025e575b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050366000803760008036600084600019f43d6000803e80600081146100f0573d6000f35b3d6000fd5b34801561010157600080fd5b5061010a610431565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561015857600080fd5b50610161610457565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156101af57600080fd5b506101b861047d565b6040518082815260200191505060405180910390f35b3480156101da57600080fd5b506101e3610483565b6040518082815260200191505060405180910390f35b34801561020557600080fd5b506102486004803603602081101561021c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610489565b6040518082815260200191505060405180910390f35b34801561026a57600080fd5b506102736104a1565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156102c157600080fd5b506102ca6104c7565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561031857600080fd5b506103216104ec565b6040518082600481111561033157fe5b60ff16815260200191505060405180910390f35b34801561035157600080fd5b5061035a6104ff565b6040518082815260200191505060405180910390f35b34801561037c57600080fd5b50610385610505565b604051808262ffffff1662ffffff16815260200191505060405180910390f35b3480156103b157600080fd5b506103ba61051a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561040857600080fd5b50610411610540565b604051808262ffffff1662ffffff16815260200191505060405180910390f35b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60075481565b60065481565b60086020528060005260406000206000915090505481565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600960009054906101000a900460ff1681565b60055481565b600460149054906101000a900462ffffff1681565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b620f42408156fea165627a7a723058205dbeb163496208d117a70c09096a520cefef917bb9fb82a74139135d7fe78f6f0029",
"deployedBytecode": "0x6080604052600436106100a75760003560e01c8063a619486e11610064578063a619486e146102b5578063c040e6b81461030c578063cb4c86b714610345578063ddca3f4314610370578063e274fd24146103a5578063fbde47f6146103fc576100a7565b806306ae7095146100f55780631f21f9af1461014c5780632129e25a146101a357806329dcb0cf146101ce57806342e94c90146101f957806380f556051461025e575b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050366000803760008036600084600019f43d6000803e80600081146100f0573d6000f35b3d6000fd5b34801561010157600080fd5b5061010a610431565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561015857600080fd5b50610161610457565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156101af57600080fd5b506101b861047d565b6040518082815260200191505060405180910390f35b3480156101da57600080fd5b506101e3610483565b6040518082815260200191505060405180910390f35b34801561020557600080fd5b506102486004803603602081101561021c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610489565b6040518082815260200191505060405180910390f35b34801561026a57600080fd5b506102736104a1565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156102c157600080fd5b506102ca6104c7565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561031857600080fd5b506103216104ec565b6040518082600481111561033157fe5b60ff16815260200191505060405180910390f35b34801561035157600080fd5b5061035a6104ff565b6040518082815260200191505060405180910390f35b34801561037c57600080fd5b50610385610505565b604051808262ffffff1662ffffff16815260200191505060405180910390f35b3480156103b157600080fd5b506103ba61051a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561040857600080fd5b50610411610540565b604051808262ffffff1662ffffff16815260200191505060405180910390f35b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60075481565b60065481565b60086020528060005260406000206000915090505481565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600960009054906101000a900460ff1681565b60055481565b600460149054906101000a900462ffffff1681565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b620f42408156fea165627a7a723058205dbeb163496208d117a70c09096a520cefef917bb9fb82a74139135d7fe78f6f0029",
"sourceMap": "1523:1156:6:-;;;1913:764;8:9:-1;5:2;;;30:1;27;20:12;5:2;1913:764:6;;;;;;;;;;;;;13:3:-1;8;5:12;2:2;;;30:1;27;20:12;2:2;1913:764:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2148:7;644:1:29;621:25;;:11;:25;;;;613:34;;;;;;670:11;657:10;;:24;;;;;;;;;;;;;;;;;;551:137;2258:1:6;2223:37;;2231:14;2223:37;;;;:94;;;;;2315:1;2280:37;;2288:14;2280:37;;;;2223:94;:149;;;;;2370:1;2337:35;;2345:12;2337:35;;;;2223:149;:185;;;;;681:7;2392:16;;:4;:16;;;2223:185;:217;;;;;2439:1;2428:8;:12;2223:217;:252;;;;;2466:9;2460:3;:15;2223:252;2212:264;;;;;;2502:14;2486:13;;:30;;;;;;;;;;;;;;;;;;2542:14;2526:13;;:30;;;;;;;;;;;;;;;;;;2580:12;2566:11;;:26;;;;;;;;;;;;;;;;;;2608:4;2602:3;;:10;;;;;;;;;;;;;;;;;;2632:8;2622:7;:18;;;;2661:9;2650:8;:20;;;;1913:764;;;;;;;1523:1156;;;;;;",
"deployedSourceMap": "1523:1156:6:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;848:19:29;870:10;;;;;;;;;;;848:32;;932:14;929:1;926;913:34;1031:1;1028;1012:14;1009:1;996:11;992:1;988:6;975:58;1067:16;1064:1;1061;1046:38;1104:7;1129:1;1124:38;;;;1195:16;1192:1;1185:27;1124:38;1143:16;1140:1;1133:27;766:42:6;;8:9:-1;5:2;;;30:1;27;20:12;5:2;766:42:6;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;814:30;;8:9:-1;5:2;;;30:1;27;20:12;5:2;814:30:6;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;950:24;;8:9:-1;5:2;;;30:1;27;20:12;5:2;950:24:6;;;:::i;:::-;;;;;;;;;;;;;;;;;;;924:20;;8:9:-1;5:2;;;30:1;27;20:12;5:2;924:20:6;;;:::i;:::-;;;;;;;;;;;;;;;;;;;980:46;;8:9:-1;5:2;;;30:1;27;20:12;5:2;980:46:6;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;980:46:6;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;850:20;;8:9:-1;5:2;;;30:1;27;20:12;5:2;850:20:6;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;205:25:29;;8:9:-1;5:2;;;30:1;27;20:12;5:2;205:25:29;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;1032:19:6;;8:9:-1;5:2;;;30:1;27;20:12;5:2;1032:19:6;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;899;;8:9:-1;5:2;;;30:1;27;20:12;5:2;899:19:6;;;:::i;:::-;;;;;;;;;;;;;;;;;;;876:17;;8:9:-1;5:2;;;30:1;27;20:12;5:2;876:17:6;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;734:26;;8:9:-1;5:2;;;30:1;27;20:12;5:2;734:26:6;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;646:42;;8:9:-1;5:2;;;30:1;27;20:12;5:2;646:42:6;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;766;;;;;;;;;;;;;:::o;814:30::-;;;;;;;;;;;;;:::o;950:24::-;;;;:::o;924:20::-;;;;:::o;980:46::-;;;;;;;;;;;;;;;;;:::o;850:20::-;;;;;;;;;;;;;:::o;205:25:29:-;;;;;;;;;;;;;:::o;1032:19:6:-;;;;;;;;;;;;;:::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": {
"typeIdentifi